@milaboratories/uikit 2.10.45 → 2.10.46

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.
Files changed (41) hide show
  1. package/.turbo/turbo-build.log +19 -19
  2. package/.turbo/turbo-formatter$colon$check.log +2 -2
  3. package/.turbo/turbo-linter$colon$check.log +2 -2
  4. package/.turbo/turbo-types$colon$check.log +1 -1
  5. package/CHANGELOG.md +6 -0
  6. package/dist/components/PlNumberField/PlNumberField.js.map +1 -1
  7. package/dist/components/PlNumberField/PlNumberField.vue.d.ts +45 -75
  8. package/dist/components/PlNumberField/PlNumberField.vue.d.ts.map +1 -1
  9. package/dist/components/PlNumberField/PlNumberField.vue2.js +129 -121
  10. package/dist/components/PlNumberField/PlNumberField.vue2.js.map +1 -1
  11. package/dist/components/PlNumberField/__test__/PlNumberField.spec.d.ts.map +1 -0
  12. package/dist/components/PlNumberField/__test__/parseNumber.spec.d.ts +2 -0
  13. package/dist/components/PlNumberField/__test__/parseNumber.spec.d.ts.map +1 -0
  14. package/dist/components/PlNumberField/parseNumber.d.ts +56 -7
  15. package/dist/components/PlNumberField/parseNumber.d.ts.map +1 -1
  16. package/dist/components/PlNumberField/parseNumber.js +40 -56
  17. package/dist/components/PlNumberField/parseNumber.js.map +1 -1
  18. package/dist/components/PlNumberField/pl-number-field.css +1 -1
  19. package/dist/components/PlSearchField/PlSearchField.js.map +1 -1
  20. package/dist/components/PlSearchField/PlSearchField.style.js.map +1 -1
  21. package/dist/components/PlSearchField/PlSearchField.vue.d.ts +20 -32
  22. package/dist/components/PlSearchField/PlSearchField.vue.d.ts.map +1 -1
  23. package/dist/components/PlSearchField/PlSearchField.vue2.js +4 -2
  24. package/dist/components/PlSearchField/PlSearchField.vue2.js.map +1 -1
  25. package/dist/components/PlTextField/PlTextField.js.map +1 -1
  26. package/dist/components/PlTextField/PlTextField.vue.d.ts +46 -118
  27. package/dist/components/PlTextField/PlTextField.vue.d.ts.map +1 -1
  28. package/dist/components/PlTextField/PlTextField.vue2.js +61 -58
  29. package/dist/components/PlTextField/PlTextField.vue2.js.map +1 -1
  30. package/package.json +5 -5
  31. package/src/components/PlNumberField/PlNumberField.vue +151 -143
  32. package/src/components/PlNumberField/__test__/PlNumberField.spec.ts +296 -0
  33. package/src/components/PlNumberField/__test__/parseNumber.spec.ts +204 -0
  34. package/src/components/PlNumberField/parseNumber.ts +125 -98
  35. package/src/components/PlNumberField/pl-number-field.scss +17 -4
  36. package/src/components/PlSearchField/PlSearchField.vue +8 -4
  37. package/src/components/PlTextField/PlTextField.vue +37 -49
  38. package/src/components/PlTextField/__tests__/TextField.spec.ts +2 -2
  39. package/dist/components/PlNumberField/__tests__/PlNumberField.spec.d.ts.map +0 -1
  40. package/src/components/PlNumberField/__tests__/PlNumberField.spec.ts +0 -182
  41. /package/dist/components/PlNumberField/{__tests__ → __test__}/PlNumberField.spec.d.ts +0 -0
@@ -1 +1 @@
1
- .pl-number-field{--contour-color:var(--txt-01);--contour-border-width:1px;--options-bg:#fff;--option-hover-bg:var(--btn-sec-hover-grey);--label-offset-left-x:8px;--label-offset-right-x:8px;--label-color:var(--txt-01);--color-hint:#9d9eae}.pl-number-field ::placeholder{color:#cfd1db;opacity:1}.pl-number-field__main-wrapper{height:40px;position:relative}.pl-number-field__wrapper{border-radius:6px;padding-left:12px}.pl-number-field__wrapper.withoutArrows{padding-right:12px}.pl-number-field__icons{border-left:1px solid var(--contour-color);border-radius:0 6px 6px 0;width:40px}.pl-number-field__icon{line-height:0}.pl-number-field__icon.disabled{cursor:not-allowed;z-index:1;position:relative}.pl-number-field__icon.disabled svg path{fill:#cfd1db}.pl-number-field__icon:hover{background-color:#9babcc29}.pl-number-field__icon:first-child{border-bottom:1px solid var(--contour-color)}.pl-number-field__hint{color:var(--color-hint);margin-top:3px}.pl-number-field__error{color:var(--txt-error);margin-top:3px;font-size:12px;font-weight:500;line-height:16px}.pl-number-field input{background:unset;text-overflow:ellipsis;border:none;outline:none;width:100%}.pl-number-field__contour{border-radius:var(--border-radius-control);border:var(--contour-border-width) solid var(--contour-color);box-shadow:var(--contour-box-shadow);z-index:0;pointer-events:none;transition:all .3s}.pl-number-field:focus-within:not(.error){--label-color:var(--txt-focus);--contour-color:var(--border-color-focus);--contour-border-width:2px;--contour-box-shadow:0 0 0 4px var(--border-color-focus-shadow)}.pl-number-field:focus-within.error{--contour-border-width:2px;--contour-box-shadow:0 0 0 4px var(--color-error-shadow)}.pl-number-field.error{--contour-color:var(--txt-error);--label-color:var(--txt-error);--color-hint:var(--txt-error)}.pl-number-field.disabled{--contour-color:var(--color-dis-01);--control-mask-fill:var(--color-dis-01);cursor:not-allowed}.pl-number-field.disabled label,.pl-number-field.disabled .mi-number-field__hint,.pl-number-field.disabled input{color:var(--contour-color)}.pl-number-field.disabled svg path{fill:var(--contour-color)}.pl-number-field.disabled .mi-number-field__icons{pointer-events:none}.pl-number-field label{top:0;left:var(--label-offset-left-x);white-space:pre;text-overflow:ellipsis;cursor:inherit;color:var(--label-color);align-items:center;padding:0 4px;transition:color .3s;display:flex;position:absolute;overflow:hidden;transform:translateY(-60%)}.pl-number-field label .required{color:var(--txt-error);margin-right:4px;font-size:12px;font-weight:500;line-height:16px;display:inline-block}
1
+ .pl-number-field{--contour-color:var(--txt-01);--contour-border-width:1px;--options-bg:#fff;--option-hover-bg:var(--btn-sec-hover-grey);--label-offset-left-x:8px;--label-offset-right-x:8px;--label-color:var(--txt-01);--color-hint:#9d9eae;--show-clearable:none}.pl-number-field ::placeholder{color:#cfd1db;opacity:1}.pl-number-field__main-wrapper{height:40px;position:relative}.pl-number-field__wrapper{border-radius:6px;gap:8px;padding-left:12px;padding-right:8px}.pl-number-field__icons{border-left:1px solid var(--contour-color);border-radius:0 6px 6px 0;width:40px}.pl-number-field__icon{line-height:0}.pl-number-field__icon.disabled{cursor:not-allowed;z-index:1;position:relative}.pl-number-field__icon.disabled svg path{fill:#cfd1db}.pl-number-field__icon:hover{background-color:#9babcc29}.pl-number-field__icon:first-child{border-bottom:1px solid var(--contour-color)}.pl-number-field__clearable{cursor:pointer;display:var(--show-clearable)!important;--icon-color:var(--ic-02)!important}.pl-number-field__hint{color:var(--color-hint);margin-top:3px}.pl-number-field__error{color:var(--txt-error);margin-top:3px;font-size:12px;font-weight:500;line-height:16px}.pl-number-field input{background:unset;text-overflow:ellipsis;border:none;outline:none;width:100%}.pl-number-field__contour{border-radius:var(--border-radius-control);border:var(--contour-border-width) solid var(--contour-color);box-shadow:var(--contour-box-shadow);z-index:0;pointer-events:none;transition:all .3s}.pl-number-field:hover,.pl-number-field:focus-within{--show-clearable:inline-block}.pl-number-field:focus-within:not(.error){--label-color:var(--txt-focus);--contour-color:var(--border-color-focus);--contour-border-width:2px;--contour-box-shadow:0 0 0 4px var(--border-color-focus-shadow)}.pl-number-field:focus-within.error{--contour-border-width:2px;--contour-box-shadow:0 0 0 4px var(--color-error-shadow)}.pl-number-field.error{--contour-color:var(--txt-error);--label-color:var(--txt-error);--color-hint:var(--txt-error)}.pl-number-field.disabled{--contour-color:var(--color-dis-01);--control-mask-fill:var(--color-dis-01);cursor:not-allowed}.pl-number-field.disabled label,.pl-number-field.disabled .mi-number-field__hint,.pl-number-field.disabled input{color:var(--contour-color)}.pl-number-field.disabled svg path{fill:var(--contour-color)}.pl-number-field.disabled .mi-number-field__icons{pointer-events:none}.pl-number-field label{top:0;left:var(--label-offset-left-x);white-space:pre;text-overflow:ellipsis;cursor:inherit;color:var(--label-color);align-items:center;padding:0 4px;transition:color .3s;display:flex;position:absolute;overflow:hidden;transform:translateY(-60%)}.pl-number-field label .required{color:var(--txt-error);margin-right:4px;font-size:12px;font-weight:500;line-height:16px;display:inline-block}
@@ -1 +1 @@
1
- {"version":3,"file":"PlSearchField.js","names":[],"sources":["../../../src/components/PlSearchField/PlSearchField.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { PlIcon16 } from \"../PlIcon16\";\nimport { PlIcon24 } from \"../PlIcon24\";\nimport { computed } from \"vue\";\nimport PlTooltip from \"../PlTooltip/PlTooltip.vue\";\n\nconst model = defineModel<string>({ required: true });\n\nconst props = defineProps<{\n modelValue?: string;\n clearable?: boolean;\n placeholder?: string;\n disabled?: boolean;\n helper?: string;\n}>();\nconst slots = defineSlots<{\n helper: () => unknown;\n}>();\n\nconst nonEmpty = computed(() => model.value != null && model.value.length > 0);\nconst hasHelper = computed(() => props.helper != null || slots.helper != null);\n\nconst clear = () => (model.value = \"\");\n</script>\n\n<template>\n <div ref=\"root\" :class=\"$style.component\">\n <PlIcon24 name=\"search\" />\n <input\n ref=\"input\"\n v-model=\"model\"\n :disabled=\"props.disabled\"\n :placeholder=\"props.placeholder || 'Find...'\"\n type=\"text\"\n spellcheck=\"false\"\n />\n <PlIcon16\n v-if=\"props.clearable && nonEmpty\"\n :class=\"$style.clear\"\n name=\"delete-clear\"\n @click.stop=\"clear\"\n />\n\n <PlTooltip v-if=\"hasHelper\" class=\"info\" position=\"bottom\">\n <template #tooltip>\n <slot name=\"helper\">\n {{ props.helper }}\n </slot>\n </template>\n </PlTooltip>\n </div>\n</template>\n\n<style lang=\"scss\" module>\n.component {\n --pl-search-field-border-bottom-color: var(--txt-01);\n --pl-search-field-bg: transparent;\n --pl-search-field-caret-color: auto;\n --pl-search-field-clear-display: none;\n\n position: relative;\n display: flex;\n align-items: center;\n min-height: calc(var(--control-height) - 2px);\n line-height: calc(var(--control-height) - 2px);\n background-color: var(--pl-search-field-bg);\n padding: 0 0 0 0;\n border-bottom: 1px solid var(--pl-search-field-border-bottom-color);\n\n input {\n margin-left: 8px;\n width: 100%;\n height: 20px;\n border: none;\n outline: none;\n background-color: transparent;\n font-size: 14px;\n font-weight: 500;\n line-height: 20px;\n caret-color: var(--pl-search-field-caret-color);\n }\n\n &:focus-within {\n --pl-search-field-border-bottom-color: var(--txt-focus);\n --pl-search-field-caret-color: var(--border-color-focus);\n --pl-search-field-clear-display: block;\n }\n\n &:hover {\n --pl-search-field-clear-display: block;\n }\n\n .clear {\n --icon-color: var(--ic-02);\n cursor: pointer;\n margin-left: auto;\n display: var(--pl-search-field-clear-display);\n }\n}\n</style>\n"],"mappings":""}
1
+ {"version":3,"file":"PlSearchField.js","names":[],"sources":["../../../src/components/PlSearchField/PlSearchField.vue"],"sourcesContent":["<script lang=\"ts\" setup generic=\"V extends undefined | string, C extends V\">\nimport { PlIcon16 } from \"../PlIcon16\";\nimport { PlIcon24 } from \"../PlIcon24\";\nimport { computed } from \"vue\";\nimport PlTooltip from \"../PlTooltip/PlTooltip.vue\";\n\nconst model = defineModel<V>({ required: true });\n\nconst props = defineProps<{\n modelValue?: string;\n clearable?: boolean | (() => C);\n placeholder?: string;\n disabled?: boolean;\n helper?: string;\n}>();\nconst slots = defineSlots<{\n helper: () => unknown;\n}>();\n\nconst nonEmpty = computed(() => model.value != null && model.value.length > 0);\nconst hasHelper = computed(() => props.helper != null || slots.helper != null);\n\nconst clear = () => {\n if (props.clearable) {\n model.value = (typeof props.clearable === \"function\" ? props.clearable() : \"\") as V;\n }\n};\n</script>\n\n<template>\n <div ref=\"root\" :class=\"$style.component\">\n <PlIcon24 name=\"search\" />\n <input\n ref=\"input\"\n v-model=\"model\"\n :disabled=\"props.disabled\"\n :placeholder=\"props.placeholder || 'Find...'\"\n type=\"text\"\n spellcheck=\"false\"\n />\n <PlIcon16\n v-if=\"props.clearable && nonEmpty\"\n :class=\"$style.clear\"\n name=\"delete-clear\"\n @click.stop=\"clear\"\n />\n\n <PlTooltip v-if=\"hasHelper\" class=\"info\" position=\"bottom\">\n <template #tooltip>\n <slot name=\"helper\">\n {{ props.helper }}\n </slot>\n </template>\n </PlTooltip>\n </div>\n</template>\n\n<style lang=\"scss\" module>\n.component {\n --pl-search-field-border-bottom-color: var(--txt-01);\n --pl-search-field-bg: transparent;\n --pl-search-field-caret-color: auto;\n --pl-search-field-clear-display: none;\n\n position: relative;\n display: flex;\n align-items: center;\n min-height: calc(var(--control-height) - 2px);\n line-height: calc(var(--control-height) - 2px);\n background-color: var(--pl-search-field-bg);\n padding: 0 0 0 0;\n border-bottom: 1px solid var(--pl-search-field-border-bottom-color);\n\n input {\n margin-left: 8px;\n width: 100%;\n height: 20px;\n border: none;\n outline: none;\n background-color: transparent;\n font-size: 14px;\n font-weight: 500;\n line-height: 20px;\n caret-color: var(--pl-search-field-caret-color);\n }\n\n &:focus-within {\n --pl-search-field-border-bottom-color: var(--txt-focus);\n --pl-search-field-caret-color: var(--border-color-focus);\n --pl-search-field-clear-display: block;\n }\n\n &:hover {\n --pl-search-field-clear-display: block;\n }\n\n .clear {\n --icon-color: var(--ic-02);\n cursor: pointer;\n margin-left: auto;\n display: var(--pl-search-field-clear-display);\n }\n}\n</style>\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"PlSearchField.vue_vue_type_style_index_0_lang.module.js","names":[],"sources":["../../../src/components/PlSearchField/PlSearchField.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { PlIcon16 } from \"../PlIcon16\";\nimport { PlIcon24 } from \"../PlIcon24\";\nimport { computed } from \"vue\";\nimport PlTooltip from \"../PlTooltip/PlTooltip.vue\";\n\nconst model = defineModel<string>({ required: true });\n\nconst props = defineProps<{\n modelValue?: string;\n clearable?: boolean;\n placeholder?: string;\n disabled?: boolean;\n helper?: string;\n}>();\nconst slots = defineSlots<{\n helper: () => unknown;\n}>();\n\nconst nonEmpty = computed(() => model.value != null && model.value.length > 0);\nconst hasHelper = computed(() => props.helper != null || slots.helper != null);\n\nconst clear = () => (model.value = \"\");\n</script>\n\n<template>\n <div ref=\"root\" :class=\"$style.component\">\n <PlIcon24 name=\"search\" />\n <input\n ref=\"input\"\n v-model=\"model\"\n :disabled=\"props.disabled\"\n :placeholder=\"props.placeholder || 'Find...'\"\n type=\"text\"\n spellcheck=\"false\"\n />\n <PlIcon16\n v-if=\"props.clearable && nonEmpty\"\n :class=\"$style.clear\"\n name=\"delete-clear\"\n @click.stop=\"clear\"\n />\n\n <PlTooltip v-if=\"hasHelper\" class=\"info\" position=\"bottom\">\n <template #tooltip>\n <slot name=\"helper\">\n {{ props.helper }}\n </slot>\n </template>\n </PlTooltip>\n </div>\n</template>\n\n<style lang=\"scss\" module>\n.component {\n --pl-search-field-border-bottom-color: var(--txt-01);\n --pl-search-field-bg: transparent;\n --pl-search-field-caret-color: auto;\n --pl-search-field-clear-display: none;\n\n position: relative;\n display: flex;\n align-items: center;\n min-height: calc(var(--control-height) - 2px);\n line-height: calc(var(--control-height) - 2px);\n background-color: var(--pl-search-field-bg);\n padding: 0 0 0 0;\n border-bottom: 1px solid var(--pl-search-field-border-bottom-color);\n\n input {\n margin-left: 8px;\n width: 100%;\n height: 20px;\n border: none;\n outline: none;\n background-color: transparent;\n font-size: 14px;\n font-weight: 500;\n line-height: 20px;\n caret-color: var(--pl-search-field-caret-color);\n }\n\n &:focus-within {\n --pl-search-field-border-bottom-color: var(--txt-focus);\n --pl-search-field-caret-color: var(--border-color-focus);\n --pl-search-field-clear-display: block;\n }\n\n &:hover {\n --pl-search-field-clear-display: block;\n }\n\n .clear {\n --icon-color: var(--ic-02);\n cursor: pointer;\n margin-left: auto;\n display: var(--pl-search-field-clear-display);\n }\n}\n</style>\n"],"mappings":""}
1
+ {"version":3,"file":"PlSearchField.vue_vue_type_style_index_0_lang.module.js","names":[],"sources":["../../../src/components/PlSearchField/PlSearchField.vue"],"sourcesContent":["<script lang=\"ts\" setup generic=\"V extends undefined | string, C extends V\">\nimport { PlIcon16 } from \"../PlIcon16\";\nimport { PlIcon24 } from \"../PlIcon24\";\nimport { computed } from \"vue\";\nimport PlTooltip from \"../PlTooltip/PlTooltip.vue\";\n\nconst model = defineModel<V>({ required: true });\n\nconst props = defineProps<{\n modelValue?: string;\n clearable?: boolean | (() => C);\n placeholder?: string;\n disabled?: boolean;\n helper?: string;\n}>();\nconst slots = defineSlots<{\n helper: () => unknown;\n}>();\n\nconst nonEmpty = computed(() => model.value != null && model.value.length > 0);\nconst hasHelper = computed(() => props.helper != null || slots.helper != null);\n\nconst clear = () => {\n if (props.clearable) {\n model.value = (typeof props.clearable === \"function\" ? props.clearable() : \"\") as V;\n }\n};\n</script>\n\n<template>\n <div ref=\"root\" :class=\"$style.component\">\n <PlIcon24 name=\"search\" />\n <input\n ref=\"input\"\n v-model=\"model\"\n :disabled=\"props.disabled\"\n :placeholder=\"props.placeholder || 'Find...'\"\n type=\"text\"\n spellcheck=\"false\"\n />\n <PlIcon16\n v-if=\"props.clearable && nonEmpty\"\n :class=\"$style.clear\"\n name=\"delete-clear\"\n @click.stop=\"clear\"\n />\n\n <PlTooltip v-if=\"hasHelper\" class=\"info\" position=\"bottom\">\n <template #tooltip>\n <slot name=\"helper\">\n {{ props.helper }}\n </slot>\n </template>\n </PlTooltip>\n </div>\n</template>\n\n<style lang=\"scss\" module>\n.component {\n --pl-search-field-border-bottom-color: var(--txt-01);\n --pl-search-field-bg: transparent;\n --pl-search-field-caret-color: auto;\n --pl-search-field-clear-display: none;\n\n position: relative;\n display: flex;\n align-items: center;\n min-height: calc(var(--control-height) - 2px);\n line-height: calc(var(--control-height) - 2px);\n background-color: var(--pl-search-field-bg);\n padding: 0 0 0 0;\n border-bottom: 1px solid var(--pl-search-field-border-bottom-color);\n\n input {\n margin-left: 8px;\n width: 100%;\n height: 20px;\n border: none;\n outline: none;\n background-color: transparent;\n font-size: 14px;\n font-weight: 500;\n line-height: 20px;\n caret-color: var(--pl-search-field-caret-color);\n }\n\n &:focus-within {\n --pl-search-field-border-bottom-color: var(--txt-focus);\n --pl-search-field-caret-color: var(--border-color-focus);\n --pl-search-field-clear-display: block;\n }\n\n &:hover {\n --pl-search-field-clear-display: block;\n }\n\n .clear {\n --icon-color: var(--ic-02);\n cursor: pointer;\n margin-left: auto;\n display: var(--pl-search-field-clear-display);\n }\n}\n</style>\n"],"mappings":""}
@@ -1,40 +1,28 @@
1
- type __VLS_Props = {
2
- modelValue?: string;
3
- clearable?: boolean;
4
- placeholder?: string;
5
- disabled?: boolean;
6
- helper?: string;
7
- };
8
- type __VLS_PublicProps = {
9
- modelValue: string;
10
- } & __VLS_Props;
11
- declare function __VLS_template(): {
12
- attrs: Partial<{}>;
1
+ declare const _default: <V extends undefined | string, C extends V>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
2
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
3
+ readonly "onUpdate:modelValue"?: ((value: V) => any) | undefined;
4
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onUpdate:modelValue"> & ({
5
+ modelValue: V;
6
+ } & {
7
+ modelValue?: string;
8
+ clearable?: boolean | (() => C);
9
+ placeholder?: string;
10
+ disabled?: boolean;
11
+ helper?: string;
12
+ }) & Partial<{}>> & import('vue').PublicProps;
13
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
14
+ attrs: any;
13
15
  slots: Readonly<{
14
16
  helper: () => unknown;
15
17
  }> & {
16
18
  helper: () => unknown;
17
19
  };
18
- refs: {
19
- root: HTMLDivElement;
20
- input: HTMLInputElement;
21
- };
22
- rootEl: HTMLDivElement;
20
+ emit: (evt: "update:modelValue", value: V) => void;
21
+ }>) => import('vue').VNode & {
22
+ __ctx?: Awaited<typeof __VLS_setup>;
23
23
  };
24
- type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
25
- declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
26
- "update:modelValue": (value: string) => any;
27
- }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
28
- "onUpdate:modelValue"?: ((value: string) => any) | undefined;
29
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
30
- root: HTMLDivElement;
31
- input: HTMLInputElement;
32
- }, HTMLDivElement>;
33
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
34
24
  export default _default;
35
- type __VLS_WithTemplateSlots<T, S> = T & {
36
- new (): {
37
- $slots: S;
38
- };
39
- };
25
+ type __VLS_PrettifyLocal<T> = {
26
+ [K in keyof T]: T[K];
27
+ } & {};
40
28
  //# sourceMappingURL=PlSearchField.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlSearchField.vue.d.ts","sourceRoot":"","sources":["../../../src/components/PlSearchField/PlSearchField.vue"],"names":[],"mappings":"AA6GA,KAAK,WAAW,GAAG;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAcF,KAAK,iBAAiB,GAAG;IACzB,UAAU,EAAE,MAAM,CAAC;CAClB,GAAG,WAAW,CAAC;AAKhB,iBAAS,cAAc;WA4FT,OAAO,IAA6B;;gBA9GxC,MAAM,OAAO;;gBAAb,MAAM,OAAO;;;;;;;EAmHtB;AAgBD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;;;kBASnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAapG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"PlSearchField.vue.d.ts","sourceRoot":"","sources":["../../../src/components/PlSearchField/PlSearchField.vue"],"names":[],"mappings":"yBA+GiB,CAAC,SAAS,SAAS,GAAG,MAAM,EAAE,CAAC,SAAS,CAAC,EACzD,aAAa,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,EAC9D,YAAY,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,EAC3G,eAAe,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EACjE;WA0JO,mBAAmB,CAAC;;;oBAzHhB,CAAC;;qBA7BE,MAAM;oBACP,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC;sBACjB,MAAM;mBACT,OAAO;iBACT,MAAM;oBAkJ6E,CAAC,4BAA2B;oBACzG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;gBAhJD,MAAM,OAAO;;gBAAb,MAAM,OAAO;;;EAoJnB,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AArKzE,wBAqK4E;AAM5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -8,7 +8,7 @@ var C = ["disabled", "placeholder"], w = /* @__PURE__ */ u({
8
8
  __name: "PlSearchField",
9
9
  props: /* @__PURE__ */ d({
10
10
  modelValue: {},
11
- clearable: { type: Boolean },
11
+ clearable: { type: [Boolean, Function] },
12
12
  placeholder: {},
13
13
  disabled: { type: Boolean },
14
14
  helper: {}
@@ -18,7 +18,9 @@ var C = ["disabled", "placeholder"], w = /* @__PURE__ */ u({
18
18
  }),
19
19
  emits: ["update:modelValue"],
20
20
  setup(u) {
21
- let d = _(u, "modelValue"), w = u, T = v(), E = r(() => d.value != null && d.value.length > 0), D = r(() => w.helper != null || T.helper != null), O = () => d.value = "";
21
+ let d = _(u, "modelValue"), w = u, T = v(), E = r(() => d.value != null && d.value.length > 0), D = r(() => w.helper != null || T.helper != null), O = () => {
22
+ w.clearable && (d.value = typeof w.clearable == "function" ? w.clearable() : "");
23
+ };
22
24
  return (r, u) => (p(), o("div", {
23
25
  ref: "root",
24
26
  class: f(r.$style.component)
@@ -1 +1 @@
1
- {"version":3,"file":"PlSearchField.vue_vue_type_script_setup_true_lang.js","names":["$style"],"sources":["../../../src/components/PlSearchField/PlSearchField.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { PlIcon16 } from \"../PlIcon16\";\nimport { PlIcon24 } from \"../PlIcon24\";\nimport { computed } from \"vue\";\nimport PlTooltip from \"../PlTooltip/PlTooltip.vue\";\n\nconst model = defineModel<string>({ required: true });\n\nconst props = defineProps<{\n modelValue?: string;\n clearable?: boolean;\n placeholder?: string;\n disabled?: boolean;\n helper?: string;\n}>();\nconst slots = defineSlots<{\n helper: () => unknown;\n}>();\n\nconst nonEmpty = computed(() => model.value != null && model.value.length > 0);\nconst hasHelper = computed(() => props.helper != null || slots.helper != null);\n\nconst clear = () => (model.value = \"\");\n</script>\n\n<template>\n <div ref=\"root\" :class=\"$style.component\">\n <PlIcon24 name=\"search\" />\n <input\n ref=\"input\"\n v-model=\"model\"\n :disabled=\"props.disabled\"\n :placeholder=\"props.placeholder || 'Find...'\"\n type=\"text\"\n spellcheck=\"false\"\n />\n <PlIcon16\n v-if=\"props.clearable && nonEmpty\"\n :class=\"$style.clear\"\n name=\"delete-clear\"\n @click.stop=\"clear\"\n />\n\n <PlTooltip v-if=\"hasHelper\" class=\"info\" position=\"bottom\">\n <template #tooltip>\n <slot name=\"helper\">\n {{ props.helper }}\n </slot>\n </template>\n </PlTooltip>\n </div>\n</template>\n\n<style lang=\"scss\" module>\n.component {\n --pl-search-field-border-bottom-color: var(--txt-01);\n --pl-search-field-bg: transparent;\n --pl-search-field-caret-color: auto;\n --pl-search-field-clear-display: none;\n\n position: relative;\n display: flex;\n align-items: center;\n min-height: calc(var(--control-height) - 2px);\n line-height: calc(var(--control-height) - 2px);\n background-color: var(--pl-search-field-bg);\n padding: 0 0 0 0;\n border-bottom: 1px solid var(--pl-search-field-border-bottom-color);\n\n input {\n margin-left: 8px;\n width: 100%;\n height: 20px;\n border: none;\n outline: none;\n background-color: transparent;\n font-size: 14px;\n font-weight: 500;\n line-height: 20px;\n caret-color: var(--pl-search-field-caret-color);\n }\n\n &:focus-within {\n --pl-search-field-border-bottom-color: var(--txt-focus);\n --pl-search-field-caret-color: var(--border-color-focus);\n --pl-search-field-clear-display: block;\n }\n\n &:hover {\n --pl-search-field-clear-display: block;\n }\n\n .clear {\n --icon-color: var(--ic-02);\n cursor: pointer;\n margin-left: auto;\n display: var(--pl-search-field-clear-display);\n }\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EAMA,IAAM,IAAQ,EAAmB,GAAA,aAAoB,EAE/C,IAAQ,GAOR,IAAQ,GAEV,EAEE,IAAW,QAAe,EAAM,SAAS,QAAQ,EAAM,MAAM,SAAS,EAAE,EACxE,IAAY,QAAe,EAAM,UAAU,QAAQ,EAAM,UAAU,KAAK,EAExE,UAAe,EAAM,QAAQ;yBAIjC,EAwBM,OAAA;GAxBD,KAAI;GAAQ,OAAK,EAAEA,EAAAA,OAAO,UAAS;;GACtC,EAA0B,EAAA,EAAA,EAAA,EAAhB,MAAK,UAAQ,CAAA;KACvB,EAOE,SAAA;IANA,KAAI;6CACU,QAAA;IACb,UAAU,EAAM;IAChB,aAAa,EAAM,eAAW;IAC/B,MAAK;IACL,YAAW;wBAJF,EAAA,MAAK,CAAA,CAAA;GAOR,EAAM,aAAa,EAAA,SAAA,GAAA,EAD3B,EAKE,EAAA,EAAA,EAAA;;IAHC,OAAK,EAAEA,EAAAA,OAAO,MAAK;IACpB,MAAK;IACJ,SAAK,EAAO,GAAK,CAAA,OAAA,CAAA;;GAGH,EAAA,SAAA,GAAA,EAAjB,EAMY,GAAA;;IANgB,OAAM;IAAO,UAAS;;IACrC,SAAO,QAGT,CAFP,EAEO,EAAA,QAAA,UAAA,EAAA,QAAA,CAAA,EAAA,EADF,EAAM,OAAM,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"PlSearchField.vue_vue_type_script_setup_true_lang.js","names":["$style"],"sources":["../../../src/components/PlSearchField/PlSearchField.vue"],"sourcesContent":["<script lang=\"ts\" setup generic=\"V extends undefined | string, C extends V\">\nimport { PlIcon16 } from \"../PlIcon16\";\nimport { PlIcon24 } from \"../PlIcon24\";\nimport { computed } from \"vue\";\nimport PlTooltip from \"../PlTooltip/PlTooltip.vue\";\n\nconst model = defineModel<V>({ required: true });\n\nconst props = defineProps<{\n modelValue?: string;\n clearable?: boolean | (() => C);\n placeholder?: string;\n disabled?: boolean;\n helper?: string;\n}>();\nconst slots = defineSlots<{\n helper: () => unknown;\n}>();\n\nconst nonEmpty = computed(() => model.value != null && model.value.length > 0);\nconst hasHelper = computed(() => props.helper != null || slots.helper != null);\n\nconst clear = () => {\n if (props.clearable) {\n model.value = (typeof props.clearable === \"function\" ? props.clearable() : \"\") as V;\n }\n};\n</script>\n\n<template>\n <div ref=\"root\" :class=\"$style.component\">\n <PlIcon24 name=\"search\" />\n <input\n ref=\"input\"\n v-model=\"model\"\n :disabled=\"props.disabled\"\n :placeholder=\"props.placeholder || 'Find...'\"\n type=\"text\"\n spellcheck=\"false\"\n />\n <PlIcon16\n v-if=\"props.clearable && nonEmpty\"\n :class=\"$style.clear\"\n name=\"delete-clear\"\n @click.stop=\"clear\"\n />\n\n <PlTooltip v-if=\"hasHelper\" class=\"info\" position=\"bottom\">\n <template #tooltip>\n <slot name=\"helper\">\n {{ props.helper }}\n </slot>\n </template>\n </PlTooltip>\n </div>\n</template>\n\n<style lang=\"scss\" module>\n.component {\n --pl-search-field-border-bottom-color: var(--txt-01);\n --pl-search-field-bg: transparent;\n --pl-search-field-caret-color: auto;\n --pl-search-field-clear-display: none;\n\n position: relative;\n display: flex;\n align-items: center;\n min-height: calc(var(--control-height) - 2px);\n line-height: calc(var(--control-height) - 2px);\n background-color: var(--pl-search-field-bg);\n padding: 0 0 0 0;\n border-bottom: 1px solid var(--pl-search-field-border-bottom-color);\n\n input {\n margin-left: 8px;\n width: 100%;\n height: 20px;\n border: none;\n outline: none;\n background-color: transparent;\n font-size: 14px;\n font-weight: 500;\n line-height: 20px;\n caret-color: var(--pl-search-field-caret-color);\n }\n\n &:focus-within {\n --pl-search-field-border-bottom-color: var(--txt-focus);\n --pl-search-field-caret-color: var(--border-color-focus);\n --pl-search-field-clear-display: block;\n }\n\n &:hover {\n --pl-search-field-clear-display: block;\n }\n\n .clear {\n --icon-color: var(--ic-02);\n cursor: pointer;\n margin-left: auto;\n display: var(--pl-search-field-clear-display);\n }\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EAMA,IAAM,IAAQ,EAAc,GAAA,aAAoB,EAE1C,IAAQ,GAOR,IAAQ,GAEV,EAEE,IAAW,QAAe,EAAM,SAAS,QAAQ,EAAM,MAAM,SAAS,EAAE,EACxE,IAAY,QAAe,EAAM,UAAU,QAAQ,EAAM,UAAU,KAAK,EAExE,UAAc;AAClB,GAAI,EAAM,cACR,EAAM,QAAS,OAAO,EAAM,aAAc,aAAa,EAAM,WAAW,GAAG;;yBAM7E,EAwBM,OAAA;GAxBD,KAAI;GAAQ,OAAK,EAAEA,EAAAA,OAAO,UAAS;;GACtC,EAA0B,EAAA,EAAA,EAAA,EAAhB,MAAK,UAAQ,CAAA;KACvB,EAOE,SAAA;IANA,KAAI;6CACU,QAAA;IACb,UAAU,EAAM;IAChB,aAAa,EAAM,eAAW;IAC/B,MAAK;IACL,YAAW;wBAJF,EAAA,MAAK,CAAA,CAAA;GAOR,EAAM,aAAa,EAAA,SAAA,GAAA,EAD3B,EAKE,EAAA,EAAA,EAAA;;IAHC,OAAK,EAAEA,EAAAA,OAAO,MAAK;IACpB,MAAK;IACJ,SAAK,EAAO,GAAK,CAAA,OAAA,CAAA;;GAGH,EAAA,SAAA,GAAA,EAAjB,EAMY,GAAA;;IANgB,OAAM;IAAO,UAAS;;IACrC,SAAO,QAGT,CAFP,EAEO,EAAA,QAAA,UAAA,EAAA,QAAA,CAAA,EAAA,EADF,EAAM,OAAM,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"PlTextField.js","names":[],"sources":["../../../src/components/PlTextField/PlTextField.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Component for one-line string data manipulation\n */\nexport default {\n name: \"PlTextField\",\n};\n</script>\n\n<script lang=\"ts\" setup>\nimport { computed, ref, useSlots } from \"vue\";\nimport SvgRequired from \"../../assets/images/required.svg?raw\";\nimport { getErrorMessage } from \"../../helpers/error.ts\";\nimport DoubleContour from \"../../utils/DoubleContour.vue\";\nimport { useLabelNotch } from \"../../utils/useLabelNotch\";\nimport { useValidation } from \"../../utils/useValidation\";\nimport { PlIcon16 } from \"../PlIcon16\";\nimport { PlIcon24 } from \"../PlIcon24\";\nimport { PlSvg } from \"../PlSvg\";\nimport { PlTooltip } from \"../PlTooltip\";\nimport \"./pl-text-field.scss\";\n\nconst slots = useSlots();\n\n/**\n * The current value of the input field.\n */\nconst model = defineModel<string>({\n default: \"\",\n});\n\nconst props = defineProps<{\n /**\n * The label to display above the input field.\n */\n label?: string;\n /**\n * If `true`, a clear icon will appear in the input field to clear the value (set it to empty string).\n */\n clearable?: boolean;\n /**\n * If `true`, the input field is marked as required.\n */\n required?: boolean;\n /**\n * An error message to display below the input field.\n */\n error?: unknown;\n /**\n * A helper text to display below the input field when there are no errors.\n */\n helper?: string;\n /**\n * A placeholder text to display inside the input field when it is empty.\n */\n placeholder?: string;\n /**\n * If `true`, the input field is disabled and cannot be interacted with.\n */\n disabled?: boolean;\n /**\n * If `true`, the input field has a dashed border.\n */\n dashed?: boolean;\n /**\n * A prefix text to display inside the input field before the value.\n */\n prefix?: string;\n /**\n * An array of validation rules to apply to the input field. Each rule is a function that takes the current value and returns `true` if valid or an error message if invalid.\n */\n rules?: ((v: string) => boolean | string)[];\n /**\n * The string specifies whether the field should be a password or not, value could be \"password\" or undefined.\n */\n type?: \"password\";\n /**\n * Makes some of corners not rounded\n * */\n groupPosition?:\n | \"top\"\n | \"bottom\"\n | \"left\"\n | \"right\"\n | \"top-left\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-right\"\n | \"middle\";\n}>();\n\nconst rootRef = ref<HTMLInputElement | undefined>(undefined);\n\nconst inputRef = ref<HTMLInputElement | undefined>();\n\nconst showPassword = ref(false);\n\nconst fieldType = computed(() => {\n if (props.type && props.type === \"password\") {\n return showPassword.value ? \"text\" : props.type;\n } else {\n return \"text\";\n }\n});\n\nconst passwordIcon = computed(() => (showPassword.value ? \"view-show\" : \"view-hide\"));\n\nconst clear = () => {\n if (props.clearable) {\n model.value = \"\";\n }\n};\n\nconst validationData = useValidation(model, props.rules || []);\n\nconst isEmpty = computed(() => model.value === \"\");\n\nconst nonEmpty = computed(() => !isEmpty.value);\n\nconst displayErrors = computed(() => {\n const errors: string[] = [];\n const propsError = getErrorMessage(props.error);\n if (propsError) {\n errors.push(propsError);\n }\n if (!validationData.value.isValid) {\n errors.push(...validationData.value.errors);\n }\n return errors;\n});\n\nconst hasErrors = computed(() => displayErrors.value.length > 0);\n\nconst canShowClearable = computed(\n () => props.clearable && nonEmpty.value && props.type !== \"password\" && !props.disabled,\n);\n\nconst togglePasswordVisibility = () => (showPassword.value = !showPassword.value);\n\nconst setFocusOnInput = () => inputRef.value?.focus();\n\nuseLabelNotch(rootRef);\n</script>\n\n<template>\n <div class=\"pl-text-field__envelope\">\n <div\n ref=\"rootRef\"\n class=\"pl-text-field\"\n :class=\"{\n error: hasErrors,\n disabled,\n dashed,\n nonEmpty,\n }\"\n >\n <label v-if=\"label\" ref=\"label\">\n <PlSvg v-if=\"required\" :uri=\"SvgRequired\" />\n <span>{{ label }}</span>\n <PlTooltip v-if=\"slots.tooltip\" class=\"info\" position=\"top\">\n <template #tooltip>\n <slot name=\"tooltip\" />\n </template>\n </PlTooltip>\n </label>\n <div v-if=\"prefix\" class=\"pl-text-field__prefix\">\n {{ prefix }}\n </div>\n <input\n ref=\"inputRef\"\n v-model=\"model\"\n :disabled=\"disabled\"\n :placeholder=\"placeholder || '...'\"\n :type=\"fieldType\"\n spellcheck=\"false\"\n />\n <div class=\"pl-text-field__append\" @click=\"setFocusOnInput\">\n <PlIcon16\n v-if=\"canShowClearable\"\n class=\"pl-text-field__clearable\"\n name=\"delete-clear\"\n @click.stop=\"clear\"\n />\n <PlIcon24\n v-if=\"type === 'password'\"\n :name=\"passwordIcon\"\n style=\"cursor: pointer\"\n @click.stop=\"togglePasswordVisibility\"\n />\n <slot name=\"append\" />\n </div>\n <DoubleContour class=\"pl-text-field__contour\" :group-position=\"groupPosition\" />\n </div>\n <div v-if=\"hasErrors\" class=\"pl-text-field__error\">\n {{ displayErrors.join(\" \") }}\n </div>\n <div v-else-if=\"helper\" class=\"pl-text-field__helper\">{{ helper }}</div>\n </div>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"PlTextField.js","names":[],"sources":["../../../src/components/PlTextField/PlTextField.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Component for one-line string data manipulation\n */\nexport default {\n name: \"PlTextField\",\n};\n</script>\n\n<script\n lang=\"ts\"\n setup\n generic=\"\n R extends true | false,\n V extends undefined | string,\n C extends Exclude<V, R extends true ? undefined : never>\n \"\n>\nimport { computed, ref, useSlots } from \"vue\";\nimport SvgRequired from \"../../assets/images/required.svg?raw\";\nimport { getErrorMessage } from \"../../helpers/error.ts\";\nimport DoubleContour from \"../../utils/DoubleContour.vue\";\nimport { useLabelNotch } from \"../../utils/useLabelNotch\";\nimport { PlIcon16 } from \"../PlIcon16\";\nimport { PlIcon24 } from \"../PlIcon24\";\nimport { PlSvg } from \"../PlSvg\";\nimport { PlTooltip } from \"../PlTooltip\";\nimport \"./pl-text-field.scss\";\n\nconst slots = useSlots();\n\n/**\n * The current value of the input field.\n */\nconst model = defineModel<V>({\n required: true,\n});\n\nconst props = defineProps<{\n /** The label to display above the input field. */\n label?: string;\n /**\n * If `true`, a clear icon will appear in the input field to clear the value (set it to empty string).\n * If a function, calls it to get the reset value.\n */\n clearable?: (R extends true ? never : boolean) | (() => C);\n /** If `true`, the input field is marked as required and will show an error if left empty. */\n required?: R;\n /** An error message to display below the input field. */\n error?: unknown;\n /** A helper text to display below the input field when there are no errors. */\n helper?: string;\n /** A placeholder text to display inside the input field when it is empty. */\n placeholder?: string;\n /** If `true`, the input field is disabled and cannot be interacted with. */\n disabled?: boolean;\n /** If `true`, the input field has a dashed border. */\n dashed?: boolean;\n /** A prefix text to display inside the input field before the value. */\n prefix?: string;\n /** Additional validity check for input value that must return an error text if failed */\n validate?: (v: V) => string | undefined;\n /** The string specifies whether the field should be a password or not, value could be \"password\" or undefined. */\n type?: \"password\";\n /** Makes some of corners not rounded */\n groupPosition?:\n | \"top\"\n | \"bottom\"\n | \"left\"\n | \"right\"\n | \"top-left\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-right\"\n | \"middle\";\n}>();\n\nconst rootRef = ref<HTMLInputElement | undefined>(undefined);\n\nconst inputRef = ref<HTMLInputElement | undefined>();\n\nconst showPassword = ref(false);\n\nconst fieldType = computed(() => {\n if (props.type && props.type === \"password\") {\n return showPassword.value ? \"text\" : props.type;\n } else {\n return \"text\";\n }\n});\n\nconst passwordIcon = computed(() => (showPassword.value ? \"view-show\" : \"view-hide\"));\n\nconst clear = () => {\n if (props.clearable) {\n model.value = (typeof props.clearable === \"function\" ? props.clearable() : \"\") as V;\n }\n};\n\nconst isEmpty = computed(() => model.value === \"\");\n\nconst displayErrors = computed(() => {\n const errors: string[] = [];\n const propsError = getErrorMessage(props.error);\n if (propsError) {\n errors.push(propsError);\n }\n if (props.validate) {\n const error = props.validate(model.value as V);\n if (error) {\n errors.push(error);\n }\n }\n if (props.required && isEmpty.value) {\n errors.push(\"Value is required\");\n }\n return errors;\n});\n\nconst hasErrors = computed(() => displayErrors.value.length > 0);\n\nconst canShowClearable = computed(\n () => props.clearable && !isEmpty.value && props.type !== \"password\" && !props.disabled,\n);\n\nconst togglePasswordVisibility = () => (showPassword.value = !showPassword.value);\n\nconst setFocusOnInput = () => inputRef.value?.focus();\n\nuseLabelNotch(rootRef);\n</script>\n\n<template>\n <div class=\"pl-text-field__envelope\">\n <div\n ref=\"rootRef\"\n class=\"pl-text-field\"\n :class=\"{\n error: hasErrors,\n disabled,\n dashed,\n nonEmpty: !isEmpty,\n }\"\n >\n <label v-if=\"label\" ref=\"label\">\n <PlSvg v-if=\"required\" :uri=\"SvgRequired\" />\n <span>{{ label }}</span>\n <PlTooltip v-if=\"slots.tooltip\" class=\"info\" position=\"top\">\n <template #tooltip>\n <slot name=\"tooltip\" />\n </template>\n </PlTooltip>\n </label>\n <div v-if=\"prefix\" class=\"pl-text-field__prefix\">\n {{ prefix }}\n </div>\n <input\n ref=\"inputRef\"\n v-model=\"model\"\n :disabled=\"disabled\"\n :placeholder=\"placeholder || '...'\"\n :type=\"fieldType\"\n spellcheck=\"false\"\n />\n <div class=\"pl-text-field__append\" @click=\"setFocusOnInput\">\n <PlIcon16\n v-if=\"canShowClearable\"\n class=\"pl-text-field__clearable\"\n name=\"delete-clear\"\n @click.stop=\"clear\"\n />\n <PlIcon24\n v-if=\"type === 'password'\"\n :name=\"passwordIcon\"\n style=\"cursor: pointer\"\n @click.stop=\"togglePasswordVisibility\"\n />\n <slot name=\"append\" />\n </div>\n <DoubleContour class=\"pl-text-field__contour\" :group-position=\"groupPosition\" />\n </div>\n <div v-if=\"hasErrors\" class=\"pl-text-field__error\">\n {{ displayErrors.join(\" \") }}\n </div>\n <div v-else-if=\"helper\" class=\"pl-text-field__helper\">{{ helper }}</div>\n </div>\n</template>\n"],"mappings":""}
@@ -1,124 +1,52 @@
1
1
  /**
2
2
  * Component for one-line string data manipulation
3
3
  */
4
- declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<{
5
- modelValue?: string;
6
- } & {
7
- /**
8
- * The label to display above the input field.
9
- */
10
- label?: string;
11
- /**
12
- * If `true`, a clear icon will appear in the input field to clear the value (set it to empty string).
13
- */
14
- clearable?: boolean;
15
- /**
16
- * If `true`, the input field is marked as required.
17
- */
18
- required?: boolean;
19
- /**
20
- * An error message to display below the input field.
21
- */
22
- error?: unknown;
23
- /**
24
- * A helper text to display below the input field when there are no errors.
25
- */
26
- helper?: string;
27
- /**
28
- * A placeholder text to display inside the input field when it is empty.
29
- */
30
- placeholder?: string;
31
- /**
32
- * If `true`, the input field is disabled and cannot be interacted with.
33
- */
34
- disabled?: boolean;
35
- /**
36
- * If `true`, the input field has a dashed border.
37
- */
38
- dashed?: boolean;
39
- /**
40
- * A prefix text to display inside the input field before the value.
41
- */
42
- prefix?: string;
43
- /**
44
- * An array of validation rules to apply to the input field. Each rule is a function that takes the current value and returns `true` if valid or an error message if invalid.
45
- */
46
- rules?: ((v: string) => boolean | string)[];
47
- /**
48
- * The string specifies whether the field should be a password or not, value could be "password" or undefined.
49
- */
50
- type?: "password";
51
- /**
52
- * Makes some of corners not rounded
53
- * */
54
- groupPosition?: "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "middle";
55
- }, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
56
- "update:modelValue": (value: string) => any;
57
- }, string, import('vue').PublicProps, Readonly<{
58
- modelValue?: string;
59
- } & {
60
- /**
61
- * The label to display above the input field.
62
- */
63
- label?: string;
64
- /**
65
- * If `true`, a clear icon will appear in the input field to clear the value (set it to empty string).
66
- */
67
- clearable?: boolean;
68
- /**
69
- * If `true`, the input field is marked as required.
70
- */
71
- required?: boolean;
72
- /**
73
- * An error message to display below the input field.
74
- */
75
- error?: unknown;
76
- /**
77
- * A helper text to display below the input field when there are no errors.
78
- */
79
- helper?: string;
80
- /**
81
- * A placeholder text to display inside the input field when it is empty.
82
- */
83
- placeholder?: string;
84
- /**
85
- * If `true`, the input field is disabled and cannot be interacted with.
86
- */
87
- disabled?: boolean;
88
- /**
89
- * If `true`, the input field has a dashed border.
90
- */
91
- dashed?: boolean;
92
- /**
93
- * A prefix text to display inside the input field before the value.
94
- */
95
- prefix?: string;
96
- /**
97
- * An array of validation rules to apply to the input field. Each rule is a function that takes the current value and returns `true` if valid or an error message if invalid.
98
- */
99
- rules?: ((v: string) => boolean | string)[];
100
- /**
101
- * The string specifies whether the field should be a password or not, value could be "password" or undefined.
102
- */
103
- type?: "password";
104
- /**
105
- * Makes some of corners not rounded
106
- * */
107
- groupPosition?: "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "middle";
108
- }> & Readonly<{
109
- "onUpdate:modelValue"?: ((value: string) => any) | undefined;
110
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
111
- rootRef: HTMLDivElement;
112
- label: HTMLLabelElement;
113
- inputRef: HTMLInputElement;
114
- }, HTMLDivElement>, {
115
- tooltip?(_: {}): any;
116
- append?(_: {}): any;
117
- }>;
118
- export default _default;
119
- type __VLS_WithTemplateSlots<T, S> = T & {
120
- new (): {
121
- $slots: S;
4
+ declare const _default: <R extends true | false, V extends undefined | string, C extends Exclude<V, R extends true ? undefined : never>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
5
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
6
+ readonly "onUpdate:modelValue"?: ((value: V) => any) | undefined;
7
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onUpdate:modelValue"> & ({
8
+ modelValue: V;
9
+ } & {
10
+ /** The label to display above the input field. */
11
+ label?: string;
12
+ /**
13
+ * If `true`, a clear icon will appear in the input field to clear the value (set it to empty string).
14
+ * If a function, calls it to get the reset value.
15
+ */
16
+ clearable?: (R extends true ? never : boolean) | (() => C);
17
+ /** If `true`, the input field is marked as required and will show an error if left empty. */
18
+ required?: R;
19
+ /** An error message to display below the input field. */
20
+ error?: unknown;
21
+ /** A helper text to display below the input field when there are no errors. */
22
+ helper?: string;
23
+ /** A placeholder text to display inside the input field when it is empty. */
24
+ placeholder?: string;
25
+ /** If `true`, the input field is disabled and cannot be interacted with. */
26
+ disabled?: boolean;
27
+ /** If `true`, the input field has a dashed border. */
28
+ dashed?: boolean;
29
+ /** A prefix text to display inside the input field before the value. */
30
+ prefix?: string;
31
+ /** Additional validity check for input value that must return an error text if failed */
32
+ validate?: (v: V) => string | undefined;
33
+ /** The string specifies whether the field should be a password or not, value could be "password" or undefined. */
34
+ type?: "password";
35
+ /** Makes some of corners not rounded */
36
+ groupPosition?: "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "middle";
37
+ }) & Partial<{}>> & import('vue').PublicProps;
38
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
39
+ attrs: any;
40
+ slots: {
41
+ tooltip?(_: {}): any;
42
+ append?(_: {}): any;
122
43
  };
44
+ emit: (evt: "update:modelValue", value: V) => void;
45
+ }>) => import('vue').VNode & {
46
+ __ctx?: Awaited<typeof __VLS_setup>;
123
47
  };
48
+ export default _default;
49
+ type __VLS_PrettifyLocal<T> = {
50
+ [K in keyof T]: T[K];
51
+ } & {};
124
52
  //# sourceMappingURL=PlTextField.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlTextField.vue.d.ts","sourceRoot":"","sources":["../../../src/components/PlTextField/PlTextField.vue"],"names":[],"mappings":"AAmNA,OAAO,sBAAsB,CAAC;AAG9B;;GAEG;;iBAiIU,MAAM;;IArHjB;;OAEG;YACK,MAAM;IACd;;OAEG;gBACS,OAAO;IACnB;;OAEG;eACQ,OAAO;IAClB;;OAEG;YACK,OAAO;IACf;;OAEG;aACM,MAAM;IACf;;OAEG;kBACW,MAAM;IACpB;;OAEG;eACQ,OAAO;IAClB;;OAEG;aACM,OAAO;IAChB;;OAEG;aACM,MAAM;IACf;;OAEG;YACK,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM,CAAC,EAAE;IAC3C;;OAEG;WACI,UAAU;IACjB;;SAEK;oBAED,KAAK,GACL,QAAQ,GACR,MAAM,GACN,OAAO,GACP,UAAU,GACV,WAAW,GACX,aAAa,GACb,cAAc,GACd,QAAQ;;;;iBA6DD,MAAM;;IArHjB;;OAEG;YACK,MAAM;IACd;;OAEG;gBACS,OAAO;IACnB;;OAEG;eACQ,OAAO;IAClB;;OAEG;YACK,OAAO;IACf;;OAEG;aACM,MAAM;IACf;;OAEG;kBACW,MAAM;IACpB;;OAEG;eACQ,OAAO;IAClB;;OAEG;aACM,OAAO;IAChB;;OAEG;aACM,MAAM;IACf;;OAEG;YACK,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM,CAAC,EAAE;IAC3C;;OAEG;WACI,UAAU;IACjB;;SAEK;oBAED,KAAK,GACL,QAAQ,GACR,MAAM,GACN,OAAO,GACP,UAAU,GACV,WAAW,GACX,aAAa,GACb,cAAc,GACd,QAAQ;;;;;;;;qBA4NgB,GAAG;oBACJ,GAAG;;AAhShC,wBA8VK;AASL,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"PlTextField.vue.d.ts","sourceRoot":"","sources":["../../../src/components/PlTextField/PlTextField.vue"],"names":[],"mappings":"AAsMA,OAAO,sBAAsB,CAAC;AAG9B;;GAEG;yBAEC,CAAC,SAAS,IAA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AO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AAlVzE,wBAkV4E;AAG5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -10,112 +10,115 @@ import a from "../../utils/DoubleContour.js";
10
10
  import { useLabelNotch as o } from "../../utils/useLabelNotch.js";
11
11
  import "../PlIcon16/index.js";
12
12
  import s from "../../assets/images/required.js";
13
- import { useValidation as c } from "../../utils/useValidation.js";
14
13
  import './pl-text-field.css';/* empty css */
15
- import { computed as l, createBlock as u, createCommentVNode as d, createElementBlock as f, createElementVNode as p, createVNode as m, defineComponent as h, mergeModels as g, normalizeClass as _, openBlock as v, ref as y, renderSlot as b, toDisplayString as x, unref as S, useModel as C, useSlots as w, vModelDynamic as T, withCtx as E, withDirectives as D, withModifiers as O } from "vue";
16
- var k = { class: "pl-text-field__envelope" }, A = {
14
+ import { computed as c, createBlock as l, createCommentVNode as u, createElementBlock as d, createElementVNode as f, createVNode as p, defineComponent as m, mergeModels as h, normalizeClass as g, openBlock as _, ref as v, renderSlot as y, toDisplayString as b, unref as x, useModel as S, useSlots as C, vModelDynamic as w, withCtx as T, withDirectives as E, withModifiers as D } from "vue";
15
+ var O = { class: "pl-text-field__envelope" }, k = {
17
16
  key: 0,
18
17
  ref: "label"
19
- }, j = {
18
+ }, A = {
20
19
  key: 1,
21
20
  class: "pl-text-field__prefix"
22
- }, M = [
21
+ }, j = [
23
22
  "disabled",
24
23
  "placeholder",
25
24
  "type"
26
- ], N = {
25
+ ], M = {
27
26
  key: 0,
28
27
  class: "pl-text-field__error"
29
- }, P = {
28
+ }, N = {
30
29
  key: 1,
31
30
  class: "pl-text-field__helper"
32
- }, F = /* @__PURE__ */ h({
31
+ }, P = /* @__PURE__ */ m({
33
32
  name: "PlTextField",
34
- props: /* @__PURE__ */ g({
33
+ props: /* @__PURE__ */ h({
35
34
  label: {},
36
- clearable: { type: Boolean },
37
- required: { type: Boolean },
35
+ clearable: { type: Function },
36
+ required: {},
38
37
  error: {},
39
38
  helper: {},
40
39
  placeholder: {},
41
40
  disabled: { type: Boolean },
42
41
  dashed: { type: Boolean },
43
42
  prefix: {},
44
- rules: {},
43
+ validate: { type: Function },
45
44
  type: {},
46
45
  groupPosition: {}
47
46
  }, {
48
- modelValue: { default: "" },
47
+ modelValue: { required: !0 },
49
48
  modelModifiers: {}
50
49
  }),
51
50
  emits: ["update:modelValue"],
52
- setup(h) {
53
- let g = w(), F = C(h, "modelValue"), I = h, L = y(void 0), R = y(), z = y(!1), B = l(() => I.type && I.type === "password" ? z.value ? "text" : I.type : "text"), V = l(() => z.value ? "view-show" : "view-hide"), H = () => {
54
- I.clearable && (F.value = "");
55
- }, U = c(F, I.rules || []), W = l(() => F.value === ""), G = l(() => !W.value), K = l(() => {
56
- let e = [], n = t(I.error);
57
- return n && e.push(n), U.value.isValid || e.push(...U.value.errors), e;
58
- }), q = l(() => K.value.length > 0), J = l(() => I.clearable && G.value && I.type !== "password" && !I.disabled), Y = () => z.value = !z.value, X = () => R.value?.focus();
59
- return o(L), (t, o) => (v(), f("div", k, [p("div", {
51
+ setup(m) {
52
+ let h = C(), P = S(m, "modelValue"), F = m, I = v(void 0), L = v(), R = v(!1), z = c(() => F.type && F.type === "password" ? R.value ? "text" : F.type : "text"), B = c(() => R.value ? "view-show" : "view-hide"), V = () => {
53
+ F.clearable && (P.value = typeof F.clearable == "function" ? F.clearable() : "");
54
+ }, H = c(() => P.value === ""), U = c(() => {
55
+ let e = [], n = t(F.error);
56
+ if (n && e.push(n), F.validate) {
57
+ let t = F.validate(P.value);
58
+ t && e.push(t);
59
+ }
60
+ return F.required && H.value && e.push("Value is required"), e;
61
+ }), W = c(() => U.value.length > 0), G = c(() => F.clearable && !H.value && F.type !== "password" && !F.disabled), K = () => R.value = !R.value, q = () => L.value?.focus();
62
+ return o(I), (t, o) => (_(), d("div", O, [f("div", {
60
63
  ref_key: "rootRef",
61
- ref: L,
62
- class: _(["pl-text-field", {
63
- error: q.value,
64
- disabled: h.disabled,
65
- dashed: h.dashed,
66
- nonEmpty: G.value
64
+ ref: I,
65
+ class: g(["pl-text-field", {
66
+ error: W.value,
67
+ disabled: m.disabled,
68
+ dashed: m.dashed,
69
+ nonEmpty: !H.value
67
70
  }])
68
71
  }, [
69
- h.label ? (v(), f("label", A, [
70
- h.required ? (v(), u(S(n), {
72
+ m.label ? (_(), d("label", k, [
73
+ m.required ? (_(), l(x(n), {
71
74
  key: 0,
72
- uri: S(s)
73
- }, null, 8, ["uri"])) : d("", !0),
74
- p("span", null, x(h.label), 1),
75
- S(g).tooltip ? (v(), u(S(e), {
75
+ uri: x(s)
76
+ }, null, 8, ["uri"])) : u("", !0),
77
+ f("span", null, b(m.label), 1),
78
+ x(h).tooltip ? (_(), l(x(e), {
76
79
  key: 1,
77
80
  class: "info",
78
81
  position: "top"
79
82
  }, {
80
- tooltip: E(() => [b(t.$slots, "tooltip")]),
83
+ tooltip: T(() => [y(t.$slots, "tooltip")]),
81
84
  _: 3
82
- })) : d("", !0)
83
- ], 512)) : d("", !0),
84
- h.prefix ? (v(), f("div", j, x(h.prefix), 1)) : d("", !0),
85
- D(p("input", {
85
+ })) : u("", !0)
86
+ ], 512)) : u("", !0),
87
+ m.prefix ? (_(), d("div", A, b(m.prefix), 1)) : u("", !0),
88
+ E(f("input", {
86
89
  ref_key: "inputRef",
87
- ref: R,
88
- "onUpdate:modelValue": o[0] ||= (e) => F.value = e,
89
- disabled: h.disabled,
90
- placeholder: h.placeholder || "...",
91
- type: B.value,
90
+ ref: L,
91
+ "onUpdate:modelValue": o[0] ||= (e) => P.value = e,
92
+ disabled: m.disabled,
93
+ placeholder: m.placeholder || "...",
94
+ type: z.value,
92
95
  spellcheck: "false"
93
- }, null, 8, M), [[T, F.value]]),
94
- p("div", {
96
+ }, null, 8, j), [[w, P.value]]),
97
+ f("div", {
95
98
  class: "pl-text-field__append",
96
- onClick: X
99
+ onClick: q
97
100
  }, [
98
- J.value ? (v(), u(S(i), {
101
+ G.value ? (_(), l(x(i), {
99
102
  key: 0,
100
103
  class: "pl-text-field__clearable",
101
104
  name: "delete-clear",
102
- onClick: O(H, ["stop"])
103
- })) : d("", !0),
104
- h.type === "password" ? (v(), u(S(r), {
105
+ onClick: D(V, ["stop"])
106
+ })) : u("", !0),
107
+ m.type === "password" ? (_(), l(x(r), {
105
108
  key: 1,
106
- name: V.value,
109
+ name: B.value,
107
110
  style: { cursor: "pointer" },
108
- onClick: O(Y, ["stop"])
109
- }, null, 8, ["name"])) : d("", !0),
110
- b(t.$slots, "append")
111
+ onClick: D(K, ["stop"])
112
+ }, null, 8, ["name"])) : u("", !0),
113
+ y(t.$slots, "append")
111
114
  ]),
112
- m(a, {
115
+ p(a, {
113
116
  class: "pl-text-field__contour",
114
- "group-position": h.groupPosition
117
+ "group-position": m.groupPosition
115
118
  }, null, 8, ["group-position"])
116
- ], 2), q.value ? (v(), f("div", N, x(K.value.join(" ")), 1)) : h.helper ? (v(), f("div", P, x(h.helper), 1)) : d("", !0)]));
119
+ ], 2), W.value ? (_(), d("div", M, b(U.value.join(" ")), 1)) : m.helper ? (_(), d("div", N, b(m.helper), 1)) : u("", !0)]));
117
120
  }
118
121
  });
119
- export { F as default };
122
+ export { P as default };
120
123
 
121
124
  //# sourceMappingURL=PlTextField.vue2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlTextField.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../../src/components/PlTextField/PlTextField.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Component for one-line string data manipulation\n */\nexport default {\n name: \"PlTextField\",\n};\n</script>\n\n<script lang=\"ts\" setup>\nimport { computed, ref, useSlots } from \"vue\";\nimport SvgRequired from \"../../assets/images/required.svg?raw\";\nimport { getErrorMessage } from \"../../helpers/error.ts\";\nimport DoubleContour from \"../../utils/DoubleContour.vue\";\nimport { useLabelNotch } from \"../../utils/useLabelNotch\";\nimport { useValidation } from \"../../utils/useValidation\";\nimport { PlIcon16 } from \"../PlIcon16\";\nimport { PlIcon24 } from \"../PlIcon24\";\nimport { PlSvg } from \"../PlSvg\";\nimport { PlTooltip } from \"../PlTooltip\";\nimport \"./pl-text-field.scss\";\n\nconst slots = useSlots();\n\n/**\n * The current value of the input field.\n */\nconst model = defineModel<string>({\n default: \"\",\n});\n\nconst props = defineProps<{\n /**\n * The label to display above the input field.\n */\n label?: string;\n /**\n * If `true`, a clear icon will appear in the input field to clear the value (set it to empty string).\n */\n clearable?: boolean;\n /**\n * If `true`, the input field is marked as required.\n */\n required?: boolean;\n /**\n * An error message to display below the input field.\n */\n error?: unknown;\n /**\n * A helper text to display below the input field when there are no errors.\n */\n helper?: string;\n /**\n * A placeholder text to display inside the input field when it is empty.\n */\n placeholder?: string;\n /**\n * If `true`, the input field is disabled and cannot be interacted with.\n */\n disabled?: boolean;\n /**\n * If `true`, the input field has a dashed border.\n */\n dashed?: boolean;\n /**\n * A prefix text to display inside the input field before the value.\n */\n prefix?: string;\n /**\n * An array of validation rules to apply to the input field. Each rule is a function that takes the current value and returns `true` if valid or an error message if invalid.\n */\n rules?: ((v: string) => boolean | string)[];\n /**\n * The string specifies whether the field should be a password or not, value could be \"password\" or undefined.\n */\n type?: \"password\";\n /**\n * Makes some of corners not rounded\n * */\n groupPosition?:\n | \"top\"\n | \"bottom\"\n | \"left\"\n | \"right\"\n | \"top-left\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-right\"\n | \"middle\";\n}>();\n\nconst rootRef = ref<HTMLInputElement | undefined>(undefined);\n\nconst inputRef = ref<HTMLInputElement | undefined>();\n\nconst showPassword = ref(false);\n\nconst fieldType = computed(() => {\n if (props.type && props.type === \"password\") {\n return showPassword.value ? \"text\" : props.type;\n } else {\n return \"text\";\n }\n});\n\nconst passwordIcon = computed(() => (showPassword.value ? \"view-show\" : \"view-hide\"));\n\nconst clear = () => {\n if (props.clearable) {\n model.value = \"\";\n }\n};\n\nconst validationData = useValidation(model, props.rules || []);\n\nconst isEmpty = computed(() => model.value === \"\");\n\nconst nonEmpty = computed(() => !isEmpty.value);\n\nconst displayErrors = computed(() => {\n const errors: string[] = [];\n const propsError = getErrorMessage(props.error);\n if (propsError) {\n errors.push(propsError);\n }\n if (!validationData.value.isValid) {\n errors.push(...validationData.value.errors);\n }\n return errors;\n});\n\nconst hasErrors = computed(() => displayErrors.value.length > 0);\n\nconst canShowClearable = computed(\n () => props.clearable && nonEmpty.value && props.type !== \"password\" && !props.disabled,\n);\n\nconst togglePasswordVisibility = () => (showPassword.value = !showPassword.value);\n\nconst setFocusOnInput = () => inputRef.value?.focus();\n\nuseLabelNotch(rootRef);\n</script>\n\n<template>\n <div class=\"pl-text-field__envelope\">\n <div\n ref=\"rootRef\"\n class=\"pl-text-field\"\n :class=\"{\n error: hasErrors,\n disabled,\n dashed,\n nonEmpty,\n }\"\n >\n <label v-if=\"label\" ref=\"label\">\n <PlSvg v-if=\"required\" :uri=\"SvgRequired\" />\n <span>{{ label }}</span>\n <PlTooltip v-if=\"slots.tooltip\" class=\"info\" position=\"top\">\n <template #tooltip>\n <slot name=\"tooltip\" />\n </template>\n </PlTooltip>\n </label>\n <div v-if=\"prefix\" class=\"pl-text-field__prefix\">\n {{ prefix }}\n </div>\n <input\n ref=\"inputRef\"\n v-model=\"model\"\n :disabled=\"disabled\"\n :placeholder=\"placeholder || '...'\"\n :type=\"fieldType\"\n spellcheck=\"false\"\n />\n <div class=\"pl-text-field__append\" @click=\"setFocusOnInput\">\n <PlIcon16\n v-if=\"canShowClearable\"\n class=\"pl-text-field__clearable\"\n name=\"delete-clear\"\n @click.stop=\"clear\"\n />\n <PlIcon24\n v-if=\"type === 'password'\"\n :name=\"passwordIcon\"\n style=\"cursor: pointer\"\n @click.stop=\"togglePasswordVisibility\"\n />\n <slot name=\"append\" />\n </div>\n <DoubleContour class=\"pl-text-field__contour\" :group-position=\"groupPosition\" />\n </div>\n <div v-if=\"hasErrors\"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_setup_true_lang.js","names":[],"sources":["../../../src/components/PlTextField/PlTextField.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Component for one-line string data manipulation\n */\nexport default {\n name: \"PlTextField\",\n};\n</script>\n\n<script\n lang=\"ts\"\n setup\n generic=\"\n R extends true | false,\n V extends undefined | string,\n C extends Exclude<V, R extends true ? undefined : never>\n \"\n>\nimport { computed, ref, useSlots } from \"vue\";\nimport SvgRequired from \"../../assets/images/required.svg?raw\";\nimport { getErrorMessage } from \"../../helpers/error.ts\";\nimport DoubleContour from \"../../utils/DoubleContour.vue\";\nimport { useLabelNotch } from \"../../utils/useLabelNotch\";\nimport { PlIcon16 } from \"../PlIcon16\";\nimport { PlIcon24 } from \"../PlIcon24\";\nimport { PlSvg } from \"../PlSvg\";\nimport { PlTooltip } from \"../PlTooltip\";\nimport \"./pl-text-field.scss\";\n\nconst slots = useSlots();\n\n/**\n * The current value of the input field.\n */\nconst model = defineModel<V>({\n required: true,\n});\n\nconst props = defineProps<{\n /** The label to display above the input field. */\n label?: string;\n /**\n * If `true`, a clear icon will appear in the input field to clear the value (set it to empty string).\n * If a function, calls it to get the reset value.\n */\n clearable?: (R extends true ? never : boolean) | (() => C);\n /** If `true`, the input field is marked as required and will show an error if left empty. */\n required?: R;\n /** An error message to display below the input field. */\n error?: unknown;\n /** A helper text to display below the input field when there are no errors. */\n helper?: string;\n /** A placeholder text to display inside the input field when it is empty. */\n placeholder?: string;\n /** If `true`, the input field is disabled and cannot be interacted with. */\n disabled?: boolean;\n /** If `true`, the input field has a dashed border. */\n dashed?: boolean;\n /** A prefix text to display inside the input field before the value. */\n prefix?: string;\n /** Additional validity check for input value that must return an error text if failed */\n validate?: (v: V) => string | undefined;\n /** The string specifies whether the field should be a password or not, value could be \"password\" or undefined. */\n type?: \"password\";\n /** Makes some of corners not rounded */\n groupPosition?:\n | \"top\"\n | \"bottom\"\n | \"left\"\n | \"right\"\n | \"top-left\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-right\"\n | \"middle\";\n}>();\n\nconst rootRef = ref<HTMLInputElement | undefined>(undefined);\n\nconst inputRef = ref<HTMLInputElement | undefined>();\n\nconst showPassword = ref(false);\n\nconst fieldType = computed(() => {\n if (props.type && props.type === \"password\") {\n return showPassword.value ? \"text\" : props.type;\n } else {\n return \"text\";\n }\n});\n\nconst passwordIcon = computed(() => (showPassword.value ? \"view-show\" : \"view-hide\"));\n\nconst clear = () => {\n if (props.clearable) {\n model.value = (typeof props.clearable === \"function\" ? props.clearable() : \"\") as V;\n }\n};\n\nconst isEmpty = computed(() => model.value === \"\");\n\nconst displayErrors = computed(() => {\n const errors: string[] = [];\n const propsError = getErrorMessage(props.error);\n if (propsError) {\n errors.push(propsError);\n }\n if (props.validate) {\n const error = props.validate(model.value as V);\n if (error) {\n errors.push(error);\n }\n }\n if (props.required && isEmpty.value) {\n errors.push(\"Value is required\");\n }\n return errors;\n});\n\nconst hasErrors = computed(() => displayErrors.value.length > 0);\n\nconst canShowClearable = computed(\n () => props.clearable && !isEmpty.value && props.type !== \"password\" && !props.disabled,\n);\n\nconst togglePasswordVisibility = () => (showPassword.value = !showPassword.value);\n\nconst setFocusOnInput = () => inputRef.value?.focus();\n\nuseLabelNotch(rootRef);\n</script>\n\n<template>\n <div class=\"pl-text-field__envelope\">\n <div\n ref=\"rootRef\"\n class=\"pl-text-field\"\n :class=\"{\n error: hasErrors,\n disabled,\n dashed,\n nonEmpty: !isEmpty,\n }\"\n >\n <label v-if=\"label\" ref=\"label\">\n <PlSvg v-if=\"required\" :uri=\"SvgRequired\" />\n <span>{{ label }}</span>\n <PlTooltip v-if=\"slots.tooltip\" class=\"info\" position=\"top\">\n <template #tooltip>\n <slot name=\"tooltip\" />\n </template>\n </PlTooltip>\n </label>\n <div v-if=\"prefix\" class=\"pl-text-field__prefix\">\n {{ prefix }}\n </div>\n <input\n ref=\"inputRef\"\n v-model=\"model\"\n :disabled=\"disabled\"\n :placeholder=\"placeholder || '...'\"\n :type=\"fieldType\"\n spellcheck=\"false\"\n />\n <div class=\"pl-text-field__append\" @click=\"setFocusOnInput\">\n <PlIcon16\n v-if=\"canShowClearable\"\n class=\"pl-text-field__clearable\"\n name=\"delete-clear\"\n @click.stop=\"clear\"\n />\n <PlIcon24\n v-if=\"type === 'password'\"\n :name=\"passwordIcon\"\n style=\"cursor: pointer\"\n @click.stop=\"togglePasswordVisibility\"\n />\n <slot name=\"append\" />\n </div>\n <DoubleContour class=\"pl-text-field__contour\" :group-position=\"groupPosition\" />\n </div>\n <div v-if=\"hasErrors\" class=\"pl-text-field__error\">\n {{ displayErrors.join(\" \") }}\n </div>\n <div v-else-if=\"helper\" class=\"pl-text-field__helper\">{{ helper }}</div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKE,MAAM;;;;;;;;;;;;;;;;;;;;EAwBR,IAAM,IAAQ,GAAU,EAKlB,IAAQ,EAAc,GAAA,aAE1B,EAEI,IAAQ,GAuCR,IAAU,EAAkC,KAAA,EAAU,EAEtD,IAAW,GAAmC,EAE9C,IAAe,EAAI,GAAM,EAEzB,IAAY,QACZ,EAAM,QAAQ,EAAM,SAAS,aACxB,EAAa,QAAQ,SAAS,EAAM,OAEpC,OAET,EAEI,IAAe,QAAgB,EAAa,QAAQ,cAAc,YAAa,EAE/E,UAAc;AAClB,GAAI,EAAM,cACR,EAAM,QAAS,OAAO,EAAM,aAAc,aAAa,EAAM,WAAW,GAAG;KAIzE,IAAU,QAAe,EAAM,UAAU,GAAG,EAE5C,IAAgB,QAAe;GACnC,IAAM,IAAmB,EAAE,EACrB,IAAa,EAAgB,EAAM,MAAM;AAI/C,OAHI,KACF,EAAO,KAAK,EAAW,EAErB,EAAM,UAAU;IAClB,IAAM,IAAQ,EAAM,SAAS,EAAM,MAAW;AAC9C,IAAI,KACF,EAAO,KAAK,EAAM;;AAMtB,UAHI,EAAM,YAAY,EAAQ,SAC5B,EAAO,KAAK,oBAAoB,EAE3B;IACP,EAEI,I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