yuyeon 0.0.47-rc.11 → 0.0.47-rc.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/yuyeon.js +2519 -2462
- package/dist/yuyeon.umd.cjs +6 -6
- package/lib/components/field-input/YFieldInput.mjs +8 -11
- package/lib/components/field-input/YFieldInput.mjs.map +1 -1
- package/lib/components/form/YForm.mjs +53 -68
- package/lib/components/form/YForm.mjs.map +1 -1
- package/lib/components/input/YInput.mjs +22 -18
- package/lib/components/input/YInput.mjs.map +1 -1
- package/lib/components/textarea/YTextarea.mjs +2 -8
- package/lib/components/textarea/YTextarea.mjs.map +1 -1
- package/lib/composables/communication.mjs.map +1 -1
- package/lib/composables/form.mjs +100 -0
- package/lib/composables/form.mjs.map +1 -0
- package/lib/composables/validation.mjs +26 -1
- package/lib/composables/validation.mjs.map +1 -1
- package/package.json +1 -1
- package/types/components/checkbox/YCheckbox.d.ts +2 -2
- package/types/components/checkbox/YInputCheckbox.d.ts +2 -2
- package/types/components/field-input/YFieldInput.d.ts +11 -7
- package/types/components/form/YForm.d.ts +32 -23
- package/types/components/input/YInput.d.ts +17 -20
- package/types/components/select/YSelect.d.ts +7 -0
- package/types/components/textarea/YTextarea.d.ts +21 -45
- package/types/composables/communication.d.ts +1 -1
- package/types/composables/form.d.ts +126 -0
- package/types/composables/validation.d.ts +6 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"communication.mjs","names":["computed","getCurrentInstance","ref","toRaw","watch","hasOwnProperty","kebabToCamel","toKebabCase","useToggleScope","useModelDuplex","props","prop","arguments","length","undefined","defaultValue","getIn","v","setOut","vm","kebabProp","property","txValue","getProp","isDefinedProp","registeredProps","vnode","value","model","get","set","neo","current","emit","Object","defineProperty","useProvided","provided","internal"],"sources":["../../src/composables/communication.ts"],"sourcesContent":["import { computed, getCurrentInstance, ref, toRaw, watch } from 'vue';\
|
|
1
|
+
{"version":3,"file":"communication.mjs","names":["computed","getCurrentInstance","ref","toRaw","watch","hasOwnProperty","kebabToCamel","toKebabCase","useToggleScope","useModelDuplex","props","prop","arguments","length","undefined","defaultValue","getIn","v","setOut","vm","kebabProp","property","txValue","getProp","isDefinedProp","registeredProps","vnode","value","model","get","set","neo","current","emit","Object","defineProperty","useProvided","provided","internal"],"sources":["../../src/composables/communication.ts"],"sourcesContent":["import { WritableComputedRef } from '@vue/runtime-core';\nimport { computed, getCurrentInstance, ref, toRaw, watch } from 'vue';\nimport type { Ref } from 'vue';\n\nimport { hasOwnProperty } from '../util/common';\nimport { kebabToCamel, toKebabCase } from '../util/string';\nimport { useToggleScope } from './scope';\n\nexport function useModelDuplex(\n props: any,\n prop: string = 'modelValue',\n defaultValue?: any,\n getIn: (value?: any) => any = (v: any) => v,\n setOut: (value: any) => any = (v: any) => v,\n) {\n const vm = getCurrentInstance()!;\n const kebabProp = toKebabCase(prop);\n const property = kebabProp === prop ? kebabToCamel(prop) : prop;\n const txValue = ref(\n props[property] !== undefined ? props[property] : defaultValue,\n );\n\n function getProp() {\n return props[property];\n }\n\n const isDefinedProp = computed(() => {\n getProp();\n const registeredProps = vm.vnode.props;\n return (\n (hasOwnProperty(registeredProps, kebabProp) ||\n hasOwnProperty(registeredProps, property)) &&\n (hasOwnProperty(registeredProps, `onUpdate:${kebabProp}`) ||\n hasOwnProperty(registeredProps, `onUpdate:${property}`))\n );\n });\n\n useToggleScope(\n () => !isDefinedProp.value,\n () => {\n watch(\n () => getProp(),\n (value) => {\n txValue.value = value;\n },\n );\n },\n );\n\n const model = computed({\n get(): any {\n return getIn(isDefinedProp.value ? getProp() : txValue.value);\n },\n set(value) {\n const neo = setOut(value);\n const current = toRaw(isDefinedProp.value ? getProp() : txValue.value);\n if (current === neo || getIn(current) === value) {\n return;\n }\n txValue.value = neo;\n vm?.emit(`update:${property}`, neo);\n },\n }) as WritableComputedRef<any> & { readonly rxValue: any };\n\n Object.defineProperty(model, 'rxValue', {\n get: () => (isDefinedProp.value ? getProp() : txValue.value),\n });\n\n return model;\n}\n\nexport function useProvided<T>(props: any, prop: string, provided: Ref<T>) {\n const internal = useModelDuplex(props, prop, props[prop] ?? provided.value);\n\n watch(provided, (value) => {\n if (props[prop] == null) {\n internal.value = value;\n }\n });\n return internal;\n}\n"],"mappings":"AACA,SAASA,QAAQ,EAAEC,kBAAkB,EAAEC,GAAG,EAAEC,KAAK,EAAEC,KAAK,QAAQ,KAAK;AAAC,SAG7DC,cAAc;AAAA,SACdC,YAAY,EAAEC,WAAW;AAAA,SACzBC,cAAc;AAEvB,OAAO,SAASC,cAAcA,CAC5BC,KAAU,EAKV;EAAA,IAJAC,IAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,YAAY;EAAA,IAC3BG,YAAkB,GAAAH,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAAA,IAClBE,KAA2B,GAAAJ,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAIK,CAAM,IAAKA,CAAC;EAAA,IAC3CC,MAA2B,GAAAN,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAIK,CAAM,IAAKA,CAAC;EAE3C,MAAME,EAAE,GAAGlB,kBAAkB,CAAC,CAAE;EAChC,MAAMmB,SAAS,GAAGb,WAAW,CAACI,IAAI,CAAC;EACnC,MAAMU,QAAQ,GAAGD,SAAS,KAAKT,IAAI,GAAGL,YAAY,CAACK,IAAI,CAAC,GAAGA,IAAI;EAC/D,MAAMW,OAAO,GAAGpB,GAAG,CACjBQ,KAAK,CAACW,QAAQ,CAAC,KAAKP,SAAS,GAAGJ,KAAK,CAACW,QAAQ,CAAC,GAAGN,YACpD,CAAC;EAED,SAASQ,OAAOA,CAAA,EAAG;IACjB,OAAOb,KAAK,CAACW,QAAQ,CAAC;EACxB;EAEA,MAAMG,aAAa,GAAGxB,QAAQ,CAAC,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aAAa,CAACG,KAAK,GAAGJ,OAAO,CAAC,CAAC,GAAGD,OAAO,CAACK;EACxD,CAAC,CAAC;EAEF,OAAOC,KAAK;AACd;AAEA,OAAO,SAASQ,WAAWA,CAAI1B,KAAU,EAAEC,IAAY,EAAE0B,QAAgB,EAAE;EACzE,MAAMC,QAAQ,GAAG7B,cAAc,CAACC,KAAK,EAAEC,IAAI,EAAED,KAAK,CAACC,IAAI,CAAC,IAAI0B,QAAQ,CAACV,KAAK,CAAC;EAE3EvB,KAAK,CAACiC,QAAQ,EAAGV,KAAK,IAAK;IACzB,IAAIjB,KAAK,CAACC,IAAI,CAAC,IAAI,IAAI,EAAE;MACvB2B,QAAQ,CAACX,KAAK,GAAGA,KAAK;IACxB;EACF,CAAC,CAAC;EACF,OAAOW,QAAQ;AACjB"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { computed, inject, provide, ref, shallowRef, toRef } from 'vue';
|
|
2
|
+
import { propsFactory } from "../util/vue-component.mjs";
|
|
3
|
+
import { useModelDuplex } from "./communication.mjs";
|
|
4
|
+
export const YUYEON_FORM_KEY = Symbol.for('yuyeon.form');
|
|
5
|
+
export const pressFormPropsOptions = propsFactory({
|
|
6
|
+
readonly: Boolean,
|
|
7
|
+
disabled: Boolean,
|
|
8
|
+
loading: Boolean,
|
|
9
|
+
modelValue: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: null
|
|
12
|
+
},
|
|
13
|
+
validateOn: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: 'input'
|
|
16
|
+
}
|
|
17
|
+
}, 'form');
|
|
18
|
+
export function createForm(props) {
|
|
19
|
+
const model = useModelDuplex(props);
|
|
20
|
+
const isValidating = shallowRef(false);
|
|
21
|
+
const inputs = ref([]);
|
|
22
|
+
const errors = ref([]);
|
|
23
|
+
const isReadonly = computed(() => props.readonly);
|
|
24
|
+
const isDisabled = computed(() => props.disabled);
|
|
25
|
+
const isLoading = computed(() => props.loading);
|
|
26
|
+
async function validate() {
|
|
27
|
+
const results = [];
|
|
28
|
+
let valid = true;
|
|
29
|
+
errors.value = [];
|
|
30
|
+
isValidating.value = true;
|
|
31
|
+
for (const item of inputs.value) {
|
|
32
|
+
const itemErrors = await item.validate();
|
|
33
|
+
if (itemErrors.length > 0) {
|
|
34
|
+
valid = false;
|
|
35
|
+
results.push({
|
|
36
|
+
id: item.id,
|
|
37
|
+
vnode: item.vnode,
|
|
38
|
+
exposed: item.vnode.component?.exposed,
|
|
39
|
+
errors: itemErrors
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
errors.value = results;
|
|
44
|
+
isValidating.value = false;
|
|
45
|
+
return {
|
|
46
|
+
valid,
|
|
47
|
+
errors: errors.value
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function register(input) {
|
|
51
|
+
const {
|
|
52
|
+
id,
|
|
53
|
+
validate,
|
|
54
|
+
vnode
|
|
55
|
+
} = input;
|
|
56
|
+
inputs.value.push({
|
|
57
|
+
id,
|
|
58
|
+
validate,
|
|
59
|
+
vnode,
|
|
60
|
+
isError: null,
|
|
61
|
+
errors: []
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function unregister(id) {
|
|
65
|
+
inputs.value = inputs.value.filter(input => input.id !== id);
|
|
66
|
+
}
|
|
67
|
+
function update(id, isError, errors) {
|
|
68
|
+
const found = inputs.value.find(item => item.id === id);
|
|
69
|
+
if (!found) return;
|
|
70
|
+
found.isError = isError;
|
|
71
|
+
found.errors = errors;
|
|
72
|
+
}
|
|
73
|
+
const provideInstance = {
|
|
74
|
+
inputs,
|
|
75
|
+
isDisabled,
|
|
76
|
+
isReadonly,
|
|
77
|
+
isLoading,
|
|
78
|
+
isValid: model,
|
|
79
|
+
isValidating,
|
|
80
|
+
register,
|
|
81
|
+
unregister,
|
|
82
|
+
update,
|
|
83
|
+
validateOn: toRef(props, 'validateOn')
|
|
84
|
+
};
|
|
85
|
+
provide(YUYEON_FORM_KEY, provideInstance);
|
|
86
|
+
return {
|
|
87
|
+
inputs,
|
|
88
|
+
errors,
|
|
89
|
+
isValid: model,
|
|
90
|
+
isDisabled,
|
|
91
|
+
isReadonly,
|
|
92
|
+
isLoading,
|
|
93
|
+
isValidating,
|
|
94
|
+
validate
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export function useForm() {
|
|
98
|
+
return inject(YUYEON_FORM_KEY, null);
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=form.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.mjs","names":["computed","inject","provide","ref","shallowRef","toRef","propsFactory","useModelDuplex","YUYEON_FORM_KEY","Symbol","for","pressFormPropsOptions","readonly","Boolean","disabled","loading","modelValue","type","default","validateOn","String","createForm","props","model","isValidating","inputs","errors","isReadonly","isDisabled","isLoading","validate","results","valid","value","item","itemErrors","length","push","id","vnode","exposed","component","register","input","isError","unregister","filter","update","found","find","provideInstance","isValid","useForm"],"sources":["../../src/composables/form.ts"],"sourcesContent":["import {\n ComputedRef,\n InjectionKey,\n PropType,\n Ref,\n computed,\n inject,\n provide,\n ref,\n shallowRef,\n toRef, VNode,\n} from 'vue';\n\nimport { EventProp, propsFactory } from '../util/vue-component';\nimport { useModelDuplex } from './communication';\nimport { ValidationProps } from './validation';\n\nexport interface FormInput {\n id: number | string;\n vnode: VNode;\n validate: () => Promise<any[]>;\n isError: boolean | undefined | null;\n errors: any[];\n}\n\nexport interface InputValidationResult {\n id: number | string;\n vnode: VNode;\n exposed: any;\n errors: any[];\n}\n\nexport interface FormValidationResult {\n valid: boolean;\n errors: InputValidationResult[];\n}\n\nexport interface SubmitEventPromise\n extends SubmitEvent,\n Promise<FormValidationResult> {}\n\nexport interface FormInstance {\n register: (input: {\n id: number | string;\n vnode: VNode;\n validate: () => Promise<any[]>;\n resetValidation: () => Promise<void>;\n }) => void;\n unregister: (id: number | string) => void;\n update: (\n id: number | string,\n isError: boolean | undefined | null,\n errors: any[],\n ) => void;\n inputs: Ref<FormInput[]>;\n isDisabled: ComputedRef<boolean>;\n isReadonly: ComputedRef<boolean>;\n isLoading: ComputedRef<boolean>;\n isValidating: Ref<boolean>;\n isValid: Ref<boolean | null>;\n validateOn: Ref<FormProps['validateOn']>;\n}\n\nexport const YUYEON_FORM_KEY: InjectionKey<FormInstance> =\n Symbol.for('yuyeon.form');\n\nexport interface FormProps {\n readonly: boolean;\n disabled: boolean;\n loading: boolean;\n modelValue: boolean | null;\n 'onUpdate:modelValue': EventProp<[boolean | null]> | undefined;\n validateOn: ValidationProps['validateOn'];\n}\n\nexport const pressFormPropsOptions = propsFactory(\n {\n readonly: Boolean,\n disabled: Boolean,\n loading: Boolean,\n modelValue: {\n type: Boolean as PropType<boolean | null>,\n default: null,\n },\n validateOn: {\n type: String as PropType<ValidationProps['validateOn']>,\n default: 'input',\n },\n },\n 'form',\n);\n\nexport function createForm(props: FormProps) {\n const model = useModelDuplex(props);\n const isValidating = shallowRef(false);\n const inputs = ref<FormInput[]>([]);\n const errors = ref<InputValidationResult[]>([]);\n\n const isReadonly = computed(() => props.readonly);\n const isDisabled = computed(() => props.disabled);\n const isLoading = computed(() => props.loading);\n\n async function validate() {\n const results: InputValidationResult[] = [];\n let valid = true;\n\n errors.value = [];\n isValidating.value = true;\n\n for (const item of inputs.value) {\n const itemErrors = await item.validate();\n\n if (itemErrors.length > 0) {\n valid = false;\n\n results.push({\n id: item.id,\n vnode: item.vnode,\n exposed: item.vnode.component?.exposed,\n errors: itemErrors,\n });\n }\n }\n\n errors.value = results;\n isValidating.value = false;\n\n return { valid, errors: errors.value };\n }\n\n function register(input: {\n id: number | string;\n vnode: VNode;\n validate: () => Promise<any[]>;\n }) {\n const { id, validate, vnode } = input;\n inputs.value.push({\n id,\n validate,\n vnode,\n isError: null,\n errors: [],\n });\n }\n\n function unregister(id: number | string) {\n inputs.value = inputs.value.filter((input) => input.id !== id);\n }\n\n function update(\n id: number | string,\n isError: boolean | undefined | null,\n errors: any[],\n ) {\n const found = inputs.value.find((item) => item.id === id);\n\n if (!found) return;\n\n found.isError = isError;\n found.errors = errors;\n }\n\n const provideInstance: FormInstance = {\n inputs,\n isDisabled,\n isReadonly,\n isLoading,\n isValid: model,\n isValidating,\n register,\n unregister,\n update,\n validateOn: toRef(props, 'validateOn'),\n };\n\n provide(YUYEON_FORM_KEY, provideInstance);\n\n return {\n inputs,\n errors,\n isValid: model,\n isDisabled,\n isReadonly,\n isLoading,\n isValidating,\n validate,\n };\n}\n\nexport function useForm() {\n return inject(YUYEON_FORM_KEY, null);\n}\n"],"mappings":"AAAA,SAKEA,QAAQ,EACRC,MAAM,EACNC,OAAO,EACPC,GAAG,EACHC,UAAU,EACVC,KAAK,QACA,KAAK;AAAC,SAEOC,YAAY;AAAA,SACvBC,cAAc;AAiDvB,OAAO,MAAMC,eAA2C,GACtDC,MAAM,CAACC,GAAG,CAAC,aAAa,CAAC;AAW3B,OAAO,MAAMC,qBAAqB,GAAGL,YAAY,CAC/C;EACEM,QAAQ,EAAEC,OAAO;EACjBC,QAAQ,EAAED,OAAO;EACjBE,OAAO,EAAEF,OAAO;EAChBG,UAAU,EAAE;IACVC,IAAI,EAAEJ,OAAmC;IACzCK,OAAO,EAAE;EACX,CAAC;EACDC,UAAU,EAAE;IACVF,IAAI,EAAEG,MAAiD;IACvDF,OAAO,EAAE;EACX;AACF,CAAC,EACD,MACF,CAAC;AAED,OAAO,SAASG,UAAUA,CAACC,KAAgB,EAAE;EAC3C,MAAMC,KAAK,GAAGhB,cAAc,CAACe,KAAK,CAAC;EACnC,MAAME,YAAY,GAAGpB,UAAU,CAAC,KAAK,CAAC;EACtC,MAAMqB,MAAM,GAAGtB,GAAG,CAAc,EAAE,CAAC;EACnC,MAAMuB,MAAM,GAAGvB,GAAG,CAA0B,EAAE,CAAC;EAE/C,MAAMwB,UAAU,GAAG3B,QAAQ,CAAC,MAAMsB,KAAK,CAACV,QAAQ,CAAC;EACjD,MAAMgB,UAAU,GAAG5B,QAA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AAKA,KAAK,CAACL,EAAE,KAAKA,EAAE,CAAC;EAChE;EAEA,SAASS,MAAMA,CACbT,EAAmB,EACnBM,OAAmC,EACnClB,MAAa,EACb;IACA,MAAMsB,KAAK,GAAGvB,MAAM,CAACQ,KAAK,CAACgB,IAAI,CAAEf,IAAI,IAAKA,IAAI,CAACI,EAAE,KAAKA,EAAE,CAAC;IAEzD,IAAI,CAACU,KAAK,EAAE;IAEZA,KAAK,CAACJ,OAAO,GAAGA,OAAO;IACvBI,KAAK,CAACtB,MAAM,GAAGA,MAAM;EACvB;EAEA,MAAMwB,eAA6B,GAAG;IACpCzB,MAAM;IACNG,UAAU;IACVD,UAAU;IACVE,SAAS;IACTsB,OAAO,EAAE5B,KAAK;IACdC,YAAY;IACZkB,QAAQ;IACRG,UAAU;IACVE,MAAM;IACN5B,UAAU,EAAEd,KAAK,CAACiB,KAAK,EAAE,YAAY;EACvC,CAAC;EAEDpB,OAAO,CAACM,eAAe,EAAE0C,eAAe,CAAC;EAEzC,OAAO;IACLzB,MAAM;IACNC,MAAM;IACNyB,OAAO,EAAE5B,KAAK;IACdK,UAAU;IACVD,UAAU;IACVE,SAAS;IACTL,YAAY;IACZM;EACF,CAAC;AACH;AAEA,OAAO,SAASsB,OAAOA,CAAA,EAAG;EACxB,OAAOnD,MAAM,CAACO,eAAe,EAAE,IAAI,CAAC;AACtC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { computed, ref, watch } from 'vue';
|
|
1
|
+
import { computed, getCurrentInstance, onBeforeMount, ref, watch } from 'vue';
|
|
2
2
|
import { getUid, propsFactory } from "../util/index.mjs";
|
|
3
3
|
import { useModelDuplex } from "./communication.mjs";
|
|
4
|
+
import { useForm } from "./form.mjs";
|
|
4
5
|
import { useToggleScope } from "./scope.mjs";
|
|
5
6
|
export const pressValidationPropsOptions = propsFactory({
|
|
6
7
|
readonly: Boolean,
|
|
@@ -24,8 +25,11 @@ export const pressValidationPropsOptions = propsFactory({
|
|
|
24
25
|
}, 'validation');
|
|
25
26
|
export function useValidation(props, name) {
|
|
26
27
|
let uid = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getUid();
|
|
28
|
+
const cid = computed(() => props.name ?? uid);
|
|
27
29
|
const model = useModelDuplex(props, 'modelValue');
|
|
28
30
|
const validationModel = computed(() => props.validationValue === undefined ? model.value : props.validationValue);
|
|
31
|
+
const vm = getCurrentInstance();
|
|
32
|
+
const form = useForm();
|
|
29
33
|
const validating = ref(false);
|
|
30
34
|
const validateOn = computed(() => {
|
|
31
35
|
let value = props.validateOn || 'input';
|
|
@@ -40,6 +44,9 @@ export function useValidation(props, name) {
|
|
|
40
44
|
});
|
|
41
45
|
const errorResult = ref();
|
|
42
46
|
const errors = ref([]);
|
|
47
|
+
const isReadonly = computed(() => props.readonly ?? form?.isReadonly.value);
|
|
48
|
+
const isDisabled = computed(() => props.disabled ?? form?.isDisabled.value);
|
|
49
|
+
const isLoading = computed(() => props.loading ?? form?.isLoading.value);
|
|
43
50
|
const isError = computed(() => {
|
|
44
51
|
return props.status === 'error' || errors.value.length > 0;
|
|
45
52
|
});
|
|
@@ -87,6 +94,21 @@ export function useValidation(props, name) {
|
|
|
87
94
|
errors.value = [];
|
|
88
95
|
errorResult.value = undefined;
|
|
89
96
|
}
|
|
97
|
+
async function resetValidation() {
|
|
98
|
+
if (!validateOn.value.lazy) {
|
|
99
|
+
await invokeValidators();
|
|
100
|
+
} else {
|
|
101
|
+
resetError();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
onBeforeMount(() => {
|
|
105
|
+
form?.register({
|
|
106
|
+
id: cid.value,
|
|
107
|
+
vnode: vm.vnode,
|
|
108
|
+
resetValidation,
|
|
109
|
+
validate: invokeValidators
|
|
110
|
+
});
|
|
111
|
+
});
|
|
90
112
|
return {
|
|
91
113
|
invokeValidators,
|
|
92
114
|
resetError,
|
|
@@ -94,6 +116,9 @@ export function useValidation(props, name) {
|
|
|
94
116
|
validateOn,
|
|
95
117
|
errorResult,
|
|
96
118
|
errors,
|
|
119
|
+
isReadonly,
|
|
120
|
+
isDisabled,
|
|
121
|
+
isLoading,
|
|
97
122
|
isError,
|
|
98
123
|
isSuccess
|
|
99
124
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.mjs","names":["computed","ref","watch","getUid","propsFactory","useModelDuplex","useToggleScope","pressValidationPropsOptions","readonly","Boolean","disabled","status","type","String","validator","value","includes","helperText","validators","Array","validateOn","validationValue","maxErrors","Number","default","useValidation","props","name","uid","arguments","length","undefined","model","validationModel","validating","onSet","Set","split","blur","has","input","lazy","submit","errorResult","errors","isError","isSuccess","invokeValidators","focused","unwatch","val","results","isArray","handler","result","console","warn","push","resetError"],"sources":["../../src/composables/validation.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"validation.mjs","names":["computed","getCurrentInstance","onBeforeMount","ref","watch","getUid","propsFactory","useModelDuplex","useForm","useToggleScope","pressValidationPropsOptions","readonly","Boolean","disabled","status","type","String","validator","value","includes","helperText","validators","Array","validateOn","validationValue","maxErrors","Number","default","useValidation","props","name","uid","arguments","length","undefined","cid","model","validationModel","vm","form","validating","onSet","Set","split","blur","has","input","lazy","submit","errorResult","errors","isReadonly","isDisabled","isLoading","loading","isError","isSuccess","invokeValidators","focused","unwatch","val","results","isArray","handler","result","console","warn","push","resetError","resetValidation","register","id","vnode","validate"],"sources":["../../src/composables/validation.ts"],"sourcesContent":["import {\n PropType,\n computed,\n getCurrentInstance,\n onBeforeMount,\n ref,\n watch,\n} from 'vue';\n\nimport { getUid, propsFactory } from '../util';\nimport { useModelDuplex } from './communication';\nimport { useForm } from './form';\nimport { useToggleScope } from './scope';\n\nexport interface ValidationProps {\n validateOn: 'input' | 'blur' | 'lazy' | 'submit' | string;\n}\n\nexport const pressValidationPropsOptions = propsFactory(\n {\n readonly: Boolean as PropType<boolean>,\n disabled: Boolean as PropType<boolean>,\n status: {\n type: String as PropType<'success' | 'warning' | 'error' | undefined>,\n validator(value: string) {\n return ['success', 'warning', 'error'].includes(value);\n },\n },\n helperText: String,\n validators: Array as PropType<((v: any) => boolean | string)[] | string[]>,\n validateOn: {\n type: String as PropType<ValidationProps['validateOn']>,\n },\n validationValue: null,\n maxErrors: {\n type: [Number, String] as PropType<number | string>,\n default: 1,\n },\n },\n 'validation',\n);\n\nexport function useValidation(props: any, name: string, uid = getUid()) {\n const cid = computed(() => props.name ?? uid);\n const model = useModelDuplex(props, 'modelValue');\n const validationModel = computed(() =>\n props.validationValue === undefined ? model.value : props.validationValue,\n );\n const vm = getCurrentInstance()!;\n const form = useForm();\n const validating = ref(false);\n const validateOn = computed(() => {\n let value = props.validateOn || 'input';\n if (value === 'lazy') value = 'input,lazy';\n const onSet = new Set(value?.split(',') ?? []);\n\n return {\n blur: onSet.has('blur') || onSet.has('input'),\n input: onSet.has('input'),\n lazy: onSet.has('lazy'),\n submit: onSet.has('submit'),\n };\n });\n\n const errorResult = ref();\n const errors = ref<any[]>([]);\n\n const isReadonly = computed(() => props.readonly ?? form?.isReadonly.value);\n\n const isDisabled = computed(() => props.disabled ?? form?.isDisabled.value);\n\n const isLoading = computed(() => props.loading ?? form?.isLoading.value);\n\n const isError = computed(() => {\n return props.status === 'error' || errors.value.length > 0;\n });\n\n const isSuccess = computed(() => {\n return !isError.value && props.status === 'success';\n });\n\n useToggleScope(\n () => validateOn.value.input,\n () => {\n watch(validationModel, () => {\n if (validationModel.value != null) {\n invokeValidators();\n } else if (props.focused) {\n const unwatch = watch(\n () => props.focused,\n (val) => {\n if (!val) invokeValidators();\n\n unwatch();\n },\n );\n }\n });\n },\n );\n\n async function invokeValidators() {\n const results: any[] = [];\n validating.value = true;\n\n if (Array.isArray(props.validators)) {\n for (const validator of props.validators) {\n if (results.length >= +(props.maxErrors ?? 1)) {\n break;\n }\n\n const handler =\n typeof validator === 'function' ? validator : () => validator;\n const result = await handler(validationModel.value);\n\n if (result === true) {\n continue;\n }\n\n if (result !== false && typeof result !== 'string') {\n console.warn('Wrong validator return type');\n continue;\n }\n results.push(result || '');\n }\n }\n validating.value = false;\n errors.value = results;\n errorResult.value = results?.[0];\n\n return results;\n }\n\n function resetError() {\n errors.value = [];\n errorResult.value = undefined;\n }\n\n async function resetValidation() {\n if (!validateOn.value.lazy) {\n await invokeValidators();\n } else {\n resetError();\n }\n }\n\n onBeforeMount(() => {\n form?.register({\n id: cid.value,\n vnode: vm.vnode,\n resetValidation,\n validate: invokeValidators,\n });\n });\n\n return {\n invokeValidators,\n resetError,\n validating,\n validateOn,\n errorResult,\n errors,\n isReadonly,\n isDisabled,\n isLoading,\n isError,\n isSuccess,\n };\n}\n"],"mappings":"AAAA,SAEEA,QAAQ,EACRC,kBAAkB,EAClBC,aAAa,EACbC,GAAG,EACHC,KAAK,QACA,KAAK;AAAC,SAEJC,MAAM,EAAEC,YAAY;AAAA,SACpBC,cAAc;AAAA,SACdC,OAAO;AAAA,SACPC,cAAc;AAMvB,OAAO,MAAMC,2BAA2B,GAAGJ,YAAY,CACrD;EACEK,QAAQ,EAAEC,OAA4B;EACtCC,QAAQ,EAAED,OAA4B;EACtCE,MAAM,EAAE;IACNC,IAAI,EAAEC,MAA+D;IACrEC,SAASA,CAACC,KAAa,EAAE;MACvB,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAACC,QAAQ,CAACD,KAAK,CAAC;IACxD;EACF,CAAC;EACDE,UAAU,EAAEJ,MAAM;EAClBK,UAAU,EAAEC,KAA8D;EAC1EC,UAAU,EAAE;IACVR,IAAI,EAAEC;EACR,CAAC;EACDQ,eAAe,EAAE,IAAI;EACrBC,SAAS,EAAE;IACTV,IAAI,EAAE,CAACW,MAAM,EAAEV,MAAM,CAA8B;IACnDW,OAAO,EAAE;EACX;AACF,CAAC,EACD,YACF,CAAC;AAED,OAAO,SAASC,aAAaA,CAACC,KAAU,EAAEC,IAAY,EAAkB;EAAA,IAAhBC,GAAG,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE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C;EACJ,CAAC,CAAC;EAEF,OAAO;IACLA,gBAAgB;IAChBW,UAAU;IACV5B,UAAU;IACVjB,UAAU;IACV0B,WAAW;IACXC,MAAM;IACNC,UAAU;IACVC,UAAU;IACVC,SAAS;IACTE,OAAO;IACPC;EACF,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@ export declare const YCheckbox: import("vue").DefineComponent<{
|
|
|
18
18
|
readonly: PropType<boolean>;
|
|
19
19
|
}, {
|
|
20
20
|
checked: import("vue").Ref<boolean>;
|
|
21
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("click" | "
|
|
21
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("click" | "blur" | "focus" | "update:modelValue" | "change")[], "click" | "blur" | "focus" | "update:modelValue" | "change", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
22
22
|
modelValue: PropType<boolean | any[]>;
|
|
23
23
|
value: PropType<any>;
|
|
24
24
|
label: PropType<string>;
|
|
@@ -37,8 +37,8 @@ export declare const YCheckbox: import("vue").DefineComponent<{
|
|
|
37
37
|
readonly: PropType<boolean>;
|
|
38
38
|
}>> & {
|
|
39
39
|
onClick?: ((...args: any[]) => any) | undefined;
|
|
40
|
-
onFocus?: ((...args: any[]) => any) | undefined;
|
|
41
40
|
onBlur?: ((...args: any[]) => any) | undefined;
|
|
41
|
+
onFocus?: ((...args: any[]) => any) | undefined;
|
|
42
42
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
43
43
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
44
44
|
}, {
|
|
@@ -34,7 +34,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
34
34
|
onFocus(e: FocusEvent): void;
|
|
35
35
|
onBlur(e: FocusEvent): void;
|
|
36
36
|
onClick(event: MouseEvent): void;
|
|
37
|
-
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("click" | "
|
|
37
|
+
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("click" | "blur" | "focus")[], "click" | "blur" | "focus", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
38
38
|
id: PropType<string>;
|
|
39
39
|
value: PropType<boolean>;
|
|
40
40
|
icon: PropType<string>;
|
|
@@ -46,8 +46,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
46
46
|
readonly: PropType<boolean>;
|
|
47
47
|
}>> & {
|
|
48
48
|
onClick?: ((...args: any[]) => any) | undefined;
|
|
49
|
-
onFocus?: ((...args: any[]) => any) | undefined;
|
|
50
49
|
onBlur?: ((...args: any[]) => any) | undefined;
|
|
50
|
+
onFocus?: ((...args: any[]) => any) | undefined;
|
|
51
51
|
}, {
|
|
52
52
|
color: string;
|
|
53
53
|
}, {}>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { PropType, SlotsType } from 'vue';
|
|
2
|
+
import { YInputDefaultSlotProps } from '../input';
|
|
2
3
|
export declare const pressYFieldInputPropsOptions: <Defaults extends {
|
|
4
|
+
extended?: unknown;
|
|
3
5
|
focused?: unknown;
|
|
4
6
|
'onUpdate:focused'?: unknown;
|
|
5
7
|
readonly?: unknown;
|
|
@@ -33,6 +35,10 @@ export declare const pressYFieldInputPropsOptions: <Defaults extends {
|
|
|
33
35
|
tabindex?: unknown;
|
|
34
36
|
type?: unknown;
|
|
35
37
|
} = {}>(defaults?: Defaults | undefined) => {
|
|
38
|
+
extended: unknown extends Defaults["extended"] ? PropType<any> : {
|
|
39
|
+
type: PropType<unknown extends Defaults["extended"] ? any : any>;
|
|
40
|
+
default: unknown extends Defaults["extended"] ? any : any;
|
|
41
|
+
};
|
|
36
42
|
focused: unknown extends Defaults["focused"] ? BooleanConstructor : {
|
|
37
43
|
type: PropType<unknown extends Defaults["focused"] ? boolean : boolean | Defaults["focused"]>;
|
|
38
44
|
default: unknown extends Defaults["focused"] ? boolean : boolean | Defaults["focused"];
|
|
@@ -229,6 +235,7 @@ export declare const pressYFieldInputPropsOptions: <Defaults extends {
|
|
|
229
235
|
};
|
|
230
236
|
};
|
|
231
237
|
export declare const YFieldInput: import("vue").DefineComponent<{
|
|
238
|
+
extended: PropType<any>;
|
|
232
239
|
focused: BooleanConstructor;
|
|
233
240
|
'onUpdate:focused': PropType<(v: boolean) => void>;
|
|
234
241
|
readonly: PropType<boolean>;
|
|
@@ -299,7 +306,8 @@ export declare const YFieldInput: import("vue").DefineComponent<{
|
|
|
299
306
|
readonly rxValue: any;
|
|
300
307
|
};
|
|
301
308
|
inValue: any;
|
|
302
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("click" | "
|
|
309
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("click" | "input" | "blur" | "focus" | "mousedown" | "mouseup" | "mousedown:display" | "update:modelValue" | "update:focused" | "change" | "keydown" | "keyup")[], "click" | "input" | "blur" | "focus" | "mousedown" | "mouseup" | "mousedown:display" | "update:modelValue" | "update:focused" | "change" | "keydown" | "keyup", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
310
|
+
extended: PropType<any>;
|
|
303
311
|
focused: BooleanConstructor;
|
|
304
312
|
'onUpdate:focused': PropType<(v: boolean) => void>;
|
|
305
313
|
readonly: PropType<boolean>;
|
|
@@ -368,10 +376,10 @@ export declare const YFieldInput: import("vue").DefineComponent<{
|
|
|
368
376
|
}>> & {
|
|
369
377
|
onClick?: ((...args: any[]) => any) | undefined;
|
|
370
378
|
"onUpdate:focused"?: ((...args: any[]) => any) | undefined;
|
|
379
|
+
onBlur?: ((...args: any[]) => any) | undefined;
|
|
371
380
|
onFocus?: ((...args: any[]) => any) | undefined;
|
|
372
381
|
onMousedown?: ((...args: any[]) => any) | undefined;
|
|
373
382
|
onMouseup?: ((...args: any[]) => any) | undefined;
|
|
374
|
-
onBlur?: ((...args: any[]) => any) | undefined;
|
|
375
383
|
"onMousedown:display"?: ((...args: any[]) => any) | undefined;
|
|
376
384
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
377
385
|
onInput?: ((...args: any[]) => any) | undefined;
|
|
@@ -392,11 +400,7 @@ export declare const YFieldInput: import("vue").DefineComponent<{
|
|
|
392
400
|
prepend: any;
|
|
393
401
|
append: any;
|
|
394
402
|
label: any;
|
|
395
|
-
default:
|
|
396
|
-
value: any;
|
|
397
|
-
formLoading: boolean;
|
|
398
|
-
attrId: string;
|
|
399
|
-
};
|
|
403
|
+
default: YInputDefaultSlotProps;
|
|
400
404
|
leading: {
|
|
401
405
|
error: boolean;
|
|
402
406
|
};
|
|
@@ -1,32 +1,41 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SubmitEventPromise } from '../../composables/form';
|
|
2
2
|
export declare const YForm: import("vue").DefineComponent<{
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
readonly: BooleanConstructor;
|
|
4
|
+
disabled: BooleanConstructor;
|
|
5
|
+
loading: BooleanConstructor;
|
|
6
|
+
modelValue: {
|
|
7
|
+
type: import("vue").PropType<boolean | null>;
|
|
8
|
+
default: null;
|
|
9
|
+
};
|
|
10
|
+
validateOn: {
|
|
11
|
+
type: import("vue").PropType<string>;
|
|
5
12
|
default: string;
|
|
6
|
-
validator(value: string): boolean;
|
|
7
13
|
};
|
|
14
|
+
}, void, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
15
|
+
'update:modelValue': (val: boolean | null) => true;
|
|
16
|
+
submit: (e: SubmitEventPromise) => true;
|
|
17
|
+
'keydown.enter': (e: Event) => true;
|
|
18
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
19
|
+
readonly: BooleanConstructor;
|
|
20
|
+
disabled: BooleanConstructor;
|
|
8
21
|
loading: BooleanConstructor;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
register(component: any): void;
|
|
16
|
-
unregister(component: any): void;
|
|
17
|
-
validate(): boolean;
|
|
18
|
-
}, import("vue").DefineComponent<{}, {}, {
|
|
19
|
-
attrs_$: any;
|
|
20
|
-
listeners_$: any;
|
|
21
|
-
}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
22
|
-
tag: {
|
|
23
|
-
type: PropType<string>;
|
|
22
|
+
modelValue: {
|
|
23
|
+
type: import("vue").PropType<boolean | null>;
|
|
24
|
+
default: null;
|
|
25
|
+
};
|
|
26
|
+
validateOn: {
|
|
27
|
+
type: import("vue").PropType<string>;
|
|
24
28
|
default: string;
|
|
25
|
-
validator(value: string): boolean;
|
|
26
29
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
}>> & {
|
|
31
|
+
"onUpdate:modelValue"?: ((val: boolean | null) => any) | undefined;
|
|
32
|
+
onSubmit?: ((e: SubmitEventPromise) => any) | undefined;
|
|
33
|
+
"onKeydown.enter"?: ((e: Event) => any) | undefined;
|
|
34
|
+
}, {
|
|
35
|
+
disabled: boolean;
|
|
30
36
|
loading: boolean;
|
|
37
|
+
modelValue: boolean | null;
|
|
38
|
+
validateOn: string;
|
|
39
|
+
readonly: boolean;
|
|
31
40
|
}, {}>;
|
|
32
41
|
export type YForm = InstanceType<typeof YForm>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { PropType, SlotsType
|
|
1
|
+
import { PropType, SlotsType } from 'vue';
|
|
2
2
|
export declare const pressYInputPropsOptions: <Defaults extends {
|
|
3
|
+
extended?: unknown;
|
|
3
4
|
focused?: unknown;
|
|
4
5
|
'onUpdate:focused'?: unknown;
|
|
5
6
|
readonly?: unknown;
|
|
@@ -27,6 +28,10 @@ export declare const pressYInputPropsOptions: <Defaults extends {
|
|
|
27
28
|
filled?: unknown;
|
|
28
29
|
ceramic?: unknown;
|
|
29
30
|
} = {}>(defaults?: Defaults | undefined) => {
|
|
31
|
+
extended: unknown extends Defaults["extended"] ? PropType<any> : {
|
|
32
|
+
type: PropType<unknown extends Defaults["extended"] ? any : any>;
|
|
33
|
+
default: unknown extends Defaults["extended"] ? any : any;
|
|
34
|
+
};
|
|
30
35
|
focused: unknown extends Defaults["focused"] ? BooleanConstructor : {
|
|
31
36
|
type: PropType<unknown extends Defaults["focused"] ? boolean : boolean | Defaults["focused"]>;
|
|
32
37
|
default: unknown extends Defaults["focused"] ? boolean : boolean | Defaults["focused"];
|
|
@@ -180,7 +185,13 @@ export declare const pressYInputPropsOptions: <Defaults extends {
|
|
|
180
185
|
default: unknown extends Defaults["ceramic"] ? boolean : boolean | Defaults["ceramic"];
|
|
181
186
|
};
|
|
182
187
|
};
|
|
188
|
+
export interface YInputDefaultSlotProps {
|
|
189
|
+
value: any;
|
|
190
|
+
loading: boolean;
|
|
191
|
+
attrId: string;
|
|
192
|
+
}
|
|
183
193
|
export declare const YInput: import("vue").DefineComponent<{
|
|
194
|
+
extended: PropType<any>;
|
|
184
195
|
focused: BooleanConstructor;
|
|
185
196
|
'onUpdate:focused': PropType<(v: boolean) => void>;
|
|
186
197
|
readonly: PropType<boolean>;
|
|
@@ -232,19 +243,8 @@ export declare const YInput: import("vue").DefineComponent<{
|
|
|
232
243
|
filled: PropType<boolean>;
|
|
233
244
|
ceramic: PropType<boolean>;
|
|
234
245
|
theme: PropType<string>;
|
|
235
|
-
}, {
|
|
236
|
-
|
|
237
|
-
isFocused: import("vue").WritableComputedRef<any> & {
|
|
238
|
-
readonly rxValue: any;
|
|
239
|
-
};
|
|
240
|
-
focusedClasses: import("vue").ComputedRef<{
|
|
241
|
-
[x: string]: any;
|
|
242
|
-
}>;
|
|
243
|
-
whenFocus: () => void;
|
|
244
|
-
whenBlur: () => void;
|
|
245
|
-
createLabel: () => VNode | undefined;
|
|
246
|
-
invokeValidators: () => Promise<any[]>;
|
|
247
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("click" | "error" | "focus" | "mousedown" | "mouseup" | "blur" | "mousedown:display" | "mouseup:display" | "click:leading" | "update:modelValue" | "update:focused")[], "click" | "error" | "focus" | "mousedown" | "mouseup" | "blur" | "mousedown:display" | "mouseup:display" | "click:leading" | "update:modelValue" | "update:focused", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
246
|
+
}, any, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("click" | "error" | "blur" | "focus" | "mousedown" | "mouseup" | "mousedown:display" | "mouseup:display" | "click:leading" | "update:modelValue" | "update:focused")[], "click" | "error" | "blur" | "focus" | "mousedown" | "mouseup" | "mousedown:display" | "mouseup:display" | "click:leading" | "update:modelValue" | "update:focused", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
247
|
+
extended: PropType<any>;
|
|
248
248
|
focused: BooleanConstructor;
|
|
249
249
|
'onUpdate:focused': PropType<(v: boolean) => void>;
|
|
250
250
|
readonly: PropType<boolean>;
|
|
@@ -300,10 +300,10 @@ export declare const YInput: import("vue").DefineComponent<{
|
|
|
300
300
|
onClick?: ((...args: any[]) => any) | undefined;
|
|
301
301
|
"onUpdate:focused"?: ((...args: any[]) => any) | undefined;
|
|
302
302
|
onError?: ((...args: any[]) => any) | undefined;
|
|
303
|
+
onBlur?: ((...args: any[]) => any) | undefined;
|
|
303
304
|
onFocus?: ((...args: any[]) => any) | undefined;
|
|
304
305
|
onMousedown?: ((...args: any[]) => any) | undefined;
|
|
305
306
|
onMouseup?: ((...args: any[]) => any) | undefined;
|
|
306
|
-
onBlur?: ((...args: any[]) => any) | undefined;
|
|
307
307
|
"onMousedown:display"?: ((...args: any[]) => any) | undefined;
|
|
308
308
|
"onMouseup:display"?: ((...args: any[]) => any) | undefined;
|
|
309
309
|
"onClick:leading"?: ((...args: any[]) => any) | undefined;
|
|
@@ -319,11 +319,7 @@ export declare const YInput: import("vue").DefineComponent<{
|
|
|
319
319
|
prepend: any;
|
|
320
320
|
append: any;
|
|
321
321
|
label: any;
|
|
322
|
-
default:
|
|
323
|
-
value: any;
|
|
324
|
-
formLoading: boolean;
|
|
325
|
-
attrId: string;
|
|
326
|
-
};
|
|
322
|
+
default: YInputDefaultSlotProps;
|
|
327
323
|
leading: {
|
|
328
324
|
error: boolean;
|
|
329
325
|
};
|
|
@@ -331,6 +327,7 @@ export declare const YInput: import("vue").DefineComponent<{
|
|
|
331
327
|
'helper-text': {
|
|
332
328
|
error: boolean;
|
|
333
329
|
errorResult: string | undefined;
|
|
330
|
+
errors: any[];
|
|
334
331
|
};
|
|
335
332
|
}>>;
|
|
336
333
|
export type YInput = InstanceType<typeof YInput>;
|
|
@@ -600,6 +600,7 @@ export declare const pressYSelectPropsOptions: <Defaults extends {
|
|
|
600
600
|
origin?: unknown;
|
|
601
601
|
offset?: unknown;
|
|
602
602
|
viewportMargin?: unknown;
|
|
603
|
+
extended?: unknown;
|
|
603
604
|
focused?: unknown;
|
|
604
605
|
'onUpdate:focused'?: unknown;
|
|
605
606
|
readonly?: unknown;
|
|
@@ -702,6 +703,10 @@ export declare const pressYSelectPropsOptions: <Defaults extends {
|
|
|
702
703
|
type: PropType<unknown extends Defaults["viewportMargin"] ? number : number | Defaults["viewportMargin"]>;
|
|
703
704
|
default: unknown extends Defaults["viewportMargin"] ? number : number | Defaults["viewportMargin"];
|
|
704
705
|
};
|
|
706
|
+
extended: unknown extends Defaults["extended"] ? PropType<any> : {
|
|
707
|
+
type: PropType<unknown extends Defaults["extended"] ? any : any>;
|
|
708
|
+
default: unknown extends Defaults["extended"] ? any : any;
|
|
709
|
+
};
|
|
705
710
|
focused: unknown extends Defaults["focused"] ? BooleanConstructor : {
|
|
706
711
|
type: PropType<unknown extends Defaults["focused"] ? boolean : boolean | Defaults["focused"]>;
|
|
707
712
|
default: unknown extends Defaults["focused"] ? boolean : boolean | Defaults["focused"];
|
|
@@ -1536,6 +1541,7 @@ export declare const YSelect: import("vue").DefineComponent<{
|
|
|
1536
1541
|
type: NumberConstructor;
|
|
1537
1542
|
default: number;
|
|
1538
1543
|
};
|
|
1544
|
+
extended: PropType<any>;
|
|
1539
1545
|
focused: BooleanConstructor;
|
|
1540
1546
|
'onUpdate:focused': PropType<(v: boolean) => void>;
|
|
1541
1547
|
readonly: PropType<boolean>;
|
|
@@ -5661,6 +5667,7 @@ export declare const YSelect: import("vue").DefineComponent<{
|
|
|
5661
5667
|
type: NumberConstructor;
|
|
5662
5668
|
default: number;
|
|
5663
5669
|
};
|
|
5670
|
+
extended: PropType<any>;
|
|
5664
5671
|
focused: BooleanConstructor;
|
|
5665
5672
|
'onUpdate:focused': PropType<(v: boolean) => void>;
|
|
5666
5673
|
readonly: PropType<boolean>;
|