init component
This commit is contained in:
1
node_modules/buetify/lib/composables/validation/index.d.ts
generated
vendored
Executable file
1
node_modules/buetify/lib/composables/validation/index.d.ts
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
export * from './useValidation';
|
||||
2
node_modules/buetify/lib/composables/validation/index.js
generated
vendored
Executable file
2
node_modules/buetify/lib/composables/validation/index.js
generated
vendored
Executable file
@@ -0,0 +1,2 @@
|
||||
export * from './useValidation';
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/buetify/lib/composables/validation/index.js.map
generated
vendored
Executable file
1
node_modules/buetify/lib/composables/validation/index.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/composables/validation/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAd","sourcesContent":["export * from './useValidation';\n"],"sourceRoot":"","file":"index.js"}
|
||||
37
node_modules/buetify/lib/composables/validation/useValidation.d.ts
generated
vendored
Executable file
37
node_modules/buetify/lib/composables/validation/useValidation.d.ts
generated
vendored
Executable file
@@ -0,0 +1,37 @@
|
||||
import { FunctionN } from 'fp-ts/lib/function';
|
||||
import { Ref, ExtractPropTypes, PropType } from 'vue';
|
||||
export declare const UseValidationPropsDefinition: {
|
||||
isDisabled: {
|
||||
type: PropType<boolean>;
|
||||
required: boolean;
|
||||
default: boolean;
|
||||
};
|
||||
isReadonly: {
|
||||
type: PropType<boolean>;
|
||||
required: boolean;
|
||||
default: boolean;
|
||||
};
|
||||
disableIfReadonly: {
|
||||
type: PropType<boolean>;
|
||||
required: boolean;
|
||||
default: boolean;
|
||||
};
|
||||
useNativeValidation: {
|
||||
type: PropType<boolean>;
|
||||
default: boolean;
|
||||
};
|
||||
isValid: {
|
||||
type: PropType<boolean>;
|
||||
default: boolean;
|
||||
};
|
||||
'onUpdate:isValid': {
|
||||
type: PropType<FunctionN<[boolean], void>>;
|
||||
default: import("fp-ts/lib/function").Lazy<() => void>;
|
||||
};
|
||||
};
|
||||
export declare type UseValidationProps = ExtractPropTypes<typeof UseValidationPropsDefinition>;
|
||||
export declare function useValidation(props: UseValidationProps, ref: Ref<HTMLElement>): {
|
||||
isDisabled: Ref<boolean>;
|
||||
isValid: Ref<boolean>;
|
||||
validate: () => void;
|
||||
};
|
||||
61
node_modules/buetify/lib/composables/validation/useValidation.js
generated
vendored
Executable file
61
node_modules/buetify/lib/composables/validation/useValidation.js
generated
vendored
Executable file
@@ -0,0 +1,61 @@
|
||||
import { constant, constVoid } from 'fp-ts/lib/function';
|
||||
import { shallowRef, watch } from 'vue';
|
||||
import { isString } from '../../utils/helpers';
|
||||
import { useDisable, UseDisablePropsDefinition } from '../disable';
|
||||
import { useFieldData } from '../fieldData';
|
||||
export const UseValidationPropsDefinition = {
|
||||
useNativeValidation: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
isValid: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
'onUpdate:isValid': {
|
||||
type: Function,
|
||||
default: constant(constVoid)
|
||||
},
|
||||
...UseDisablePropsDefinition
|
||||
};
|
||||
|
||||
function isHtmlInputElement(el) {
|
||||
const newEl = el;
|
||||
return el && typeof newEl.checkValidity === 'function' && isString(newEl.validationMessage);
|
||||
}
|
||||
|
||||
export function useValidation(props, ref) {
|
||||
const {
|
||||
setters
|
||||
} = useFieldData();
|
||||
const isDisabled = useDisable(props);
|
||||
const isValid = shallowRef(props.isValid);
|
||||
watch(isValid, newValue => {
|
||||
props['onUpdate:isValid'](newValue);
|
||||
});
|
||||
|
||||
function validate() {
|
||||
if (!isDisabled.value && props.useNativeValidation) {
|
||||
if (isHtmlInputElement(ref.value)) {
|
||||
const el = ref.value;
|
||||
|
||||
if (!el.checkValidity()) {
|
||||
setters.onNewVariant('is-danger');
|
||||
setters.onNewMessage(el.validationMessage);
|
||||
isValid.value = false;
|
||||
} else {
|
||||
setters.onNewVariant('is-success');
|
||||
setters.onNewMessage('');
|
||||
isValid.value = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
isDisabled,
|
||||
isValid,
|
||||
validate
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=useValidation.js.map
|
||||
1
node_modules/buetify/lib/composables/validation/useValidation.js.map
generated
vendored
Executable file
1
node_modules/buetify/lib/composables/validation/useValidation.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/composables/validation/useValidation.ts"],"names":[],"mappings":"AAAA,SAAS,QAAT,EAAmB,SAAnB,QAA+C,oBAA/C;AACA,SAAgC,UAAhC,EAAsD,KAAtD,QAAmE,KAAnE;AACA,SAAS,QAAT,QAAyB,qBAAzB;AACA,SAAS,UAAT,EAAqB,yBAArB,QAAsD,YAAtD;AACA,SAAS,YAAT,QAA6B,cAA7B;AAEA,OAAO,MAAM,4BAA4B,GAAG;AAC1C,EAAA,mBAAmB,EAAE;AACnB,IAAA,IAAI,EAAE,OADa;AAEnB,IAAA,OAAO,EAAE;AAFU,GADqB;AAK1C,EAAA,OAAO,EAAE;AACP,IAAA,IAAI,EAAE,OADC;AAEP,IAAA,OAAO,EAAE;AAFF,GALiC;AAS1C,sBAAoB;AAClB,IAAA,IAAI,EAAE,QADY;AAElB,IAAA,OAAO,EAAE,QAAQ,CAAC,SAAD;AAFC,GATsB;AAa1C,KAAG;AAbuC,CAArC;;AAkBP,SAAS,kBAAT,CAA4B,EAA5B,EAA2C;AACzC,QAAM,KAAK,GAAI,EAAf;AACA,SAAO,EAAE,IAAI,OAAO,KAAK,CAAC,aAAb,KAA+B,UAArC,IAAmD,QAAQ,CAAC,KAAK,CAAC,iBAAP,CAAlE;AACD;;AAED,OAAM,SAAU,aAAV,CAAwB,KAAxB,EAAmD,GAAnD,EAAwE;AAC5E,QAAM;AAAE,IAAA;AAAF,MAAc,YAAY,EAAhC;AACA,QAAM,UAAU,GAAG,UAAU,CAAC,KAAD,CAA7B;AACA,QAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,OAAP,CAA1B;AACA,EAAA,KAAK,CAAC,OAAD,EAAU,QAAQ,IAAG;AACxB,IAAA,KAAK,CAAC,kBAAD,CAAL,CAA0B,QAA1B;AACD,GAFI,CAAL;;AAGA,WAAS,QAAT,GAAiB;AACf,QAAI,CAAC,UAAU,CAAC,KAAZ,IAAqB,KAAK,CAAC,mBAA/B,EAAoD;AAClD,UAAI,kBAAkB,CAAC,GAAG,CAAC,KAAL,CAAtB,EAAmC;AACjC,cAAM,EAAE,GAAG,GAAG,CAAC,KAAf;;AACA,YAAI,CAAC,EAAE,CAAC,aAAH,EAAL,EAAyB;AACvB,UAAA,OAAO,CAAC,YAAR,CAAqB,WAArB;AACA,UAAA,OAAO,CAAC,YAAR,CAAqB,EAAE,CAAC,iBAAxB;AACA,UAAA,OAAO,CAAC,KAAR,GAAgB,KAAhB;AACD,SAJD,MAIO;AACL,UAAA,OAAO,CAAC,YAAR,CAAqB,YAArB;AACA,UAAA,OAAO,CAAC,YAAR,CAAqB,EAArB;AACA,UAAA,OAAO,CAAC,KAAR,GAAgB,IAAhB;AACD;AACF;AACF;AACF;;AACD,SAAO;AACL,IAAA,UADK;AAEL,IAAA,OAFK;AAGL,IAAA;AAHK,GAAP;AAKD","sourcesContent":["import { constant, constVoid, FunctionN } from 'fp-ts/lib/function';\nimport { Ref, ExtractPropTypes, shallowRef, PropType, watch } from 'vue';\nimport { isString } from '../../utils/helpers';\nimport { useDisable, UseDisablePropsDefinition } from '../disable';\nimport { useFieldData } from '../fieldData';\n\nexport const UseValidationPropsDefinition = {\n useNativeValidation: {\n type: Boolean as PropType<boolean>,\n default: true\n },\n isValid: {\n type: Boolean as PropType<boolean>,\n default: true\n },\n 'onUpdate:isValid': {\n type: Function as PropType<FunctionN<[boolean], void>>,\n default: constant(constVoid)\n },\n ...UseDisablePropsDefinition\n};\n\nexport type UseValidationProps = ExtractPropTypes<typeof UseValidationPropsDefinition>;\n\nfunction isHtmlInputElement(el: HTMLElement): el is HTMLInputElement {\n const newEl = (el as unknown) as HTMLInputElement;\n return el && typeof newEl.checkValidity === 'function' && isString(newEl.validationMessage);\n}\n\nexport function useValidation(props: UseValidationProps, ref: Ref<HTMLElement>) {\n const { setters } = useFieldData();\n const isDisabled = useDisable(props);\n const isValid = shallowRef(props.isValid);\n watch(isValid, newValue => {\n props['onUpdate:isValid'](newValue);\n });\n function validate() {\n if (!isDisabled.value && props.useNativeValidation) {\n if (isHtmlInputElement(ref.value)) {\n const el = ref.value;\n if (!el.checkValidity()) {\n setters.onNewVariant('is-danger');\n setters.onNewMessage(el.validationMessage);\n isValid.value = false;\n } else {\n setters.onNewVariant('is-success');\n setters.onNewMessage('');\n isValid.value = true;\n }\n }\n }\n }\n return {\n isDisabled,\n isValid,\n validate\n };\n}\n"],"sourceRoot":"","file":"useValidation.js"}
|
||||
Reference in New Issue
Block a user