@globalbrain/sefirot
Advanced tools
Comparing version 0.18.0 to 0.19.0
@@ -0,1 +1,7 @@ | ||
# [0.19.0](https://github.com/globalbrain/sefirot/compare/v0.18.0...v0.19.0) (2021-01-07) | ||
### Features | ||
* **input-dropdown:** add dropdown input component ([9fbb802](https://github.com/globalbrain/sefirot/commit/9fbb8025658bacb503ed65cb82da30efdc0b663e)) | ||
# [0.18.0](https://github.com/globalbrain/sefirot/compare/v0.17.0...v0.18.0) (2021-01-05) | ||
@@ -2,0 +8,0 @@ |
@@ -5,3 +5,3 @@ import { reactive } from '@vue/composition-api' | ||
export function useFormData <T extends Data> (data: T) { | ||
export function useFormData <T extends Data>(data: T) { | ||
const wrapped = reactive(data) | ||
@@ -8,0 +8,0 @@ |
@@ -29,3 +29,3 @@ import { Ref, ComputedRef, ref, computed } from '@vue/composition-api' | ||
export function useFormValidation (data: Data, rules: Rules, rootData?: Data): Validation { | ||
export function useFormValidation(data: Data, rules: Rules, rootData?: Data): Validation { | ||
const validation = {} as Validation | ||
@@ -40,3 +40,3 @@ | ||
function setValidations (validation: Validation, data: Data, rules: Rules, rootData: Data): void { | ||
function setValidations(validation: Validation, data: Data, rules: Rules, rootData: Data): void { | ||
for (const name in rules) { | ||
@@ -51,3 +51,3 @@ const validatorsOrRules = rules[name] | ||
function createValidation (name: string, data: Data, rules: Rule[], rootData: Data): Validation { | ||
function createValidation(name: string, data: Data, rules: Rule[], rootData: Data): Validation { | ||
const isDirty = ref(false) | ||
@@ -57,11 +57,11 @@ const isValid = computed(() => errors.value.length === 0) | ||
function touch (): void { | ||
function touch(): void { | ||
isDirty.value = true | ||
} | ||
function reset (): void { | ||
function reset(): void { | ||
isDirty.value = false | ||
} | ||
function validate (): boolean { | ||
function validate(): boolean { | ||
touch() | ||
@@ -82,3 +82,3 @@ return isValid.value | ||
function setupValidation (validation: Validation): void { | ||
function setupValidation(validation: Validation): void { | ||
const isDirty = computed(() => { | ||
@@ -101,7 +101,7 @@ return Object.keys(validation).every((field) => { | ||
function touch (): void { | ||
function touch(): void { | ||
callAll(validation, 'touch') | ||
} | ||
function reset (): void { | ||
function reset(): void { | ||
callAll(validation, 'reset') | ||
@@ -123,3 +123,3 @@ } | ||
function getErrors (name: string, data: Data, rules: Rule[], rootData: Data): Error[] { | ||
function getErrors(name: string, data: Data, rules: Rule[], rootData: Data): Error[] { | ||
return rules.reduce<Error[]>((errors, rule) => { | ||
@@ -140,3 +140,3 @@ const value = data[name] | ||
function callAll (validation: Validation, method: 'touch' | 'reset'): void { | ||
function callAll(validation: Validation, method: 'touch' | 'reset'): void { | ||
for (const field in validation) { | ||
@@ -148,4 +148,4 @@ const v = validation[field] | ||
function isValidation (obj: any): obj is Validation { | ||
function isValidation(obj: any): obj is Validation { | ||
return obj !== null && typeof obj === 'object' && !Array.isArray(obj) && obj.$isValidation | ||
} |
import { getCurrentInstance } from '@vue/composition-api' | ||
import VueRouter, { Route } from 'vue-router' | ||
export function useRouter () { | ||
export function useRouter() { | ||
const vm = getCurrentInstance() as any | ||
@@ -10,3 +10,3 @@ | ||
export function useRoute () { | ||
export function useRoute() { | ||
const vm = getCurrentInstance() as any | ||
@@ -13,0 +13,0 @@ |
import { getCurrentInstance } from '@vue/composition-api' | ||
import { Store } from 'vuex' | ||
export function useStore () { | ||
export function useStore() { | ||
const vm = getCurrentInstance() as any | ||
@@ -6,0 +6,0 @@ |
@@ -9,3 +9,3 @@ import { reactive, markRaw } from '@vue/composition-api' | ||
export default function useForm (definition: FormDefinition) { | ||
export default function useForm(definition: FormDefinition) { | ||
const data = reactive(definition.data) | ||
@@ -12,0 +12,0 @@ const validation = markRaw(createValidation(data, definition.rules)) |
@@ -9,3 +9,3 @@ import { ResizeObserver } from '@juggle/resize-observer' | ||
export default function useResizeObserver (target: Ref<HTMLElement | null>) { | ||
export default function useResizeObserver(target: Ref<HTMLElement | null>) { | ||
const el = reactive({ w: 0, h: 0 }) | ||
@@ -12,0 +12,0 @@ |
@@ -1,2 +0,2 @@ | ||
function pad (n: number, width: number): string { | ||
function pad(n: number, width: number): string { | ||
const number = String(n) | ||
@@ -6,3 +6,3 @@ return number.length >= width ? number : new Array(width - number.length + 1).join('0') + number | ||
function createTimes (from: number, to: number): string[] { | ||
function createTimes(from: number, to: number): string[] { | ||
const hours: string[] = [] | ||
@@ -17,3 +17,3 @@ | ||
export default function useTime () { | ||
export default function useTime() { | ||
const hours = createTimes(0, 23) | ||
@@ -20,0 +20,0 @@ const minutes = createTimes(0, 59) |
@@ -18,3 +18,3 @@ import { ActionTree, ActionContext } from 'vuex' | ||
export const actions: ActionTree<any, RootState> = { | ||
open (context: ActionContext<any, RootState>, { type = 'info', title, text, actions }): void { | ||
open(context: ActionContext<any, RootState>, { type = 'info', title, text, actions }): void { | ||
context.dispatch('modal/open', { | ||
@@ -26,3 +26,3 @@ name: 'alert', | ||
close (context: ActionContext<any, RootState>): void { | ||
close(context: ActionContext<any, RootState>): void { | ||
context.dispatch('modal/close', null, { root: true }) | ||
@@ -29,0 +29,0 @@ } |
@@ -24,3 +24,3 @@ import { ActionTree, ActionContext } from 'vuex' | ||
export const actions: ActionTree<any, RootState> = { | ||
open (context: ActionContext<any, RootState>, { type = 'confirm', title, text, progress, actions = [] }: PayloadOpen): void { | ||
open(context: ActionContext<any, RootState>, { type = 'confirm', title, text, progress, actions = [] }: PayloadOpen): void { | ||
context.dispatch('modal/open', { | ||
@@ -32,7 +32,7 @@ name: 'dialog', | ||
update (context: ActionContext<any, RootState>, data): void { | ||
update(context: ActionContext<any, RootState>, data): void { | ||
context.dispatch('modal/update', data, { root: true }) | ||
}, | ||
close (context: ActionContext<any, RootState>): void { | ||
close(context: ActionContext<any, RootState>): void { | ||
context.dispatch('modal/close', null, { root: true }) | ||
@@ -39,0 +39,0 @@ } |
@@ -15,3 +15,3 @@ import { ActionTree, ActionContext, MutationTree } from 'vuex' | ||
export function state (): State { | ||
export function state(): State { | ||
return { | ||
@@ -25,11 +25,11 @@ id: 0, | ||
export const actions: ActionTree<State, RootState> = { | ||
open (context: ActionContext<State, RootState>, { name, data }: PayloadOpen): void { | ||
open(context: ActionContext<State, RootState>, { name, data }: PayloadOpen): void { | ||
context.commit('set', { name, data }) | ||
}, | ||
update (context: ActionContext<State, RootState>, data: Record<string, any>): void { | ||
update(context: ActionContext<State, RootState>, data: Record<string, any>): void { | ||
context.commit('update', data) | ||
}, | ||
close (context: ActionContext<State, RootState>): void { | ||
close(context: ActionContext<State, RootState>): void { | ||
context.commit('delete') | ||
@@ -40,3 +40,3 @@ } | ||
export const mutations: MutationTree<State> = { | ||
set (state: State, { name, data = {} }: PayloadOpen): void { | ||
set(state: State, { name, data = {} }: PayloadOpen): void { | ||
state.id++ | ||
@@ -47,7 +47,7 @@ state.name = name | ||
update (state: State, data: Record<string, any>): void { | ||
update(state: State, data: Record<string, any>): void { | ||
state.data = { ...state.data, ...data } | ||
}, | ||
delete (state: State): void { | ||
delete(state: State): void { | ||
state.id = 0 | ||
@@ -54,0 +54,0 @@ state.name = null |
@@ -14,3 +14,3 @@ import { ActionTree, ActionContext, MutationTree } from 'vuex' | ||
export function state (): State { | ||
export function state(): State { | ||
return { | ||
@@ -23,7 +23,7 @@ name: null, | ||
export const actions: ActionTree<State, RootState> = { | ||
open (context: ActionContext<State, RootState>, { name, data }: PayloadOpen): void { | ||
open(context: ActionContext<State, RootState>, { name, data }: PayloadOpen): void { | ||
context.commit('set', { name, data }) | ||
}, | ||
close (context: ActionContext<State, RootState>): void { | ||
close(context: ActionContext<State, RootState>): void { | ||
context.commit('set', { | ||
@@ -37,3 +37,3 @@ name: null, | ||
export const mutations: MutationTree<State> = { | ||
set (state: State, { name, data = {} }: PayloadOpen): void { | ||
set(state: State, { name, data = {} }: PayloadOpen): void { | ||
state.name = name | ||
@@ -40,0 +40,0 @@ state.data = data |
@@ -28,3 +28,3 @@ import { ActionTree, ActionContext, MutationTree } from 'vuex' | ||
export function state (): State { | ||
export function state(): State { | ||
return { | ||
@@ -36,3 +36,3 @@ items: [] | ||
export const actions: ActionTree<State, RootState> = { | ||
push (context: ActionContext<State, RootState>, payload: Snackbar): void { | ||
push(context: ActionContext<State, RootState>, payload: Snackbar): void { | ||
const id = nextId++ | ||
@@ -49,3 +49,3 @@ | ||
pop (context: ActionContext<State, RootState>, id: number): void { | ||
pop(context: ActionContext<State, RootState>, id: number): void { | ||
context.commit('pop', id) | ||
@@ -56,3 +56,3 @@ } | ||
export const mutations: MutationTree<State> = { | ||
push (state: State, item: SnackbarWithId): void { | ||
push(state: State, item: SnackbarWithId): void { | ||
if (state.items.length > maxItemSize) { | ||
@@ -65,3 +65,3 @@ state.items.shift() | ||
pop (state: State, id: number): void { | ||
pop(state: State, id: number): void { | ||
state.items = state.items.filter(item => item.id !== id) | ||
@@ -68,0 +68,0 @@ } |
@@ -9,7 +9,7 @@ import { ActionTree, ActionContext } from 'vuex' | ||
export const actions: ActionTree<any, RootState> = { | ||
open (context: ActionContext<any, RootState>, { name }: PayloadOpen): void { | ||
open(context: ActionContext<any, RootState>, { name }: PayloadOpen): void { | ||
context.dispatch('modal/open', { name }, { root: true }) | ||
}, | ||
close (context: ActionContext<any, RootState>): void { | ||
close(context: ActionContext<any, RootState>): void { | ||
context.dispatch('modal/close', null, { root: true }) | ||
@@ -16,0 +16,0 @@ } |
import { email as baseEmail } from '../validators' | ||
import { Rule } from './' | ||
export default function email (message?: string): Rule { | ||
export default function email(message?: string): Rule { | ||
return { | ||
@@ -6,0 +6,0 @@ name: 'email', |
import { regex as baseRegex } from '../validators' | ||
import { Rule } from './' | ||
export default function required (regExp: RegExp, message?: string): Rule { | ||
export default function required(regExp: RegExp, message?: string): Rule { | ||
return { | ||
@@ -6,0 +6,0 @@ name: 'regex', |
import { required as baseRequired } from '../validators' | ||
import { Rule } from './' | ||
export default function required (message?: string): Rule { | ||
export default function required(message?: string): Rule { | ||
return { | ||
@@ -6,0 +6,0 @@ name: 'required', |
import { Rule } from './' | ||
export default function rule (options: Rule): Rule { | ||
export default function rule(options: Rule): Rule { | ||
return options | ||
} |
import { url as baseUrl } from '../validators' | ||
import { Rule } from './' | ||
export default function url (message?: string): Rule { | ||
export default function url(message?: string): Rule { | ||
return { | ||
@@ -6,0 +6,0 @@ name: 'url', |
@@ -24,3 +24,3 @@ import { ref, computed, toRefs, Ref } from '@vue/composition-api' | ||
export function createValidation (data: Data, rules: Rules, rootData?: Data): Validation { | ||
export function createValidation(data: Data, rules: Rules, rootData?: Data): Validation { | ||
const validation = createInitialValidation() | ||
@@ -32,3 +32,3 @@ setNestedValidations(validation, data, rootData ?? data, rules) | ||
function createInitialValidation (): Validation { | ||
function createInitialValidation(): Validation { | ||
return { | ||
@@ -48,3 +48,3 @@ _isValidation: true, | ||
function createNestedValidation (name: string, data: Data, rootData: Data, validators: Rule[]): Validation { | ||
function createNestedValidation(name: string, data: Data, rootData: Data, validators: Rule[]): Validation { | ||
const initData = data[name] | ||
@@ -100,3 +100,3 @@ const dataRef = toRefs(data)[name] | ||
function setValidation (validation: Validation): void { | ||
function setValidation(validation: Validation): void { | ||
const isDirty = computed(() => { | ||
@@ -136,3 +136,3 @@ return Object.keys(validation).every((field) => { | ||
function setNestedValidations (validation: Validation, data: Data, rootData: Data, rules: Rules): void { | ||
function setNestedValidations(validation: Validation, data: Data, rootData: Data, rules: Rules): void { | ||
for (const name in rules) { | ||
@@ -147,3 +147,3 @@ const validators = rules[name] | ||
function callAll (validation: Validation, method: 'touch' | 'reset' | 'init'): void { | ||
function callAll(validation: Validation, method: 'touch' | 'reset' | 'init'): void { | ||
for (const field in validation) { | ||
@@ -155,4 +155,4 @@ const v = validation[field] | ||
function isValidation (value: MaybeValidation): value is Validation { | ||
function isValidation(value: MaybeValidation): value is Validation { | ||
return value !== null && typeof value === 'object' && !Array.isArray(value) && value._isValidation | ||
} |
const regex = /(^$|^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$)/ | ||
export default function email (value: any): boolean { | ||
export default function email(value: any): boolean { | ||
return regex.test(value) | ||
} |
@@ -1,3 +0,3 @@ | ||
export default function regex (value: any, regExp: RegExp): boolean { | ||
export default function regex(value: any, regExp: RegExp): boolean { | ||
return regExp.test(value) | ||
} |
@@ -1,2 +0,2 @@ | ||
export default function required (value: any): boolean { | ||
export default function required(value: any): boolean { | ||
if (Array.isArray(value)) { | ||
@@ -3,0 +3,0 @@ return !!value.length |
const regex = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00A1-\uFFFF0-9]-*)*[a-z\u00A1-\uFFFF0-9]+)(?:\.(?:[a-z\u00A1-\uFFFF0-9]-*)*[a-z\u00A1-\uFFFF0-9]+)*(?:\.(?:[a-z\u00A1-\uFFFF]{2,})))(?::\d{2,5})?(?:[/?#]\S*)?$/i | ||
export default function url (value: any): boolean { | ||
export default function url(value: any): boolean { | ||
return regex.test(value) | ||
} |
{ | ||
"name": "@globalbrain/sefirot", | ||
"version": "0.18.0", | ||
"version": "0.19.0", | ||
"description": "Vue Components for Global Brain Design System.", | ||
@@ -52,2 +52,3 @@ "files": [ | ||
"@types/jest": "^26.0.19", | ||
"@types/lodash-es": "^4.17.4", | ||
"@vue/composition-api": "^1.0.0-beta.21", | ||
@@ -64,4 +65,6 @@ "@vue/test-utils": "^1.1.2", | ||
"eslint": "^7.15.0", | ||
"fuse.js": "^6.4.6", | ||
"jest": "^26.6.3", | ||
"jest-serializer-vue": "^2.0.2", | ||
"lodash-es": "^4.17.20", | ||
"mutation-observer": "^1.0.3", | ||
@@ -68,0 +71,0 @@ "normalize.css": "^8.0.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
193546
144
1197
49