@davincihealthcare/elty-design-system-vue 2.10.1 → 2.10.2

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue"),D=require("./input.cjs.js"),N=require("../ElDropdown.vue.cjs2.js"),F=require("../ElInputChip.vue.cjs2.js"),T=require("../../node_modules/@vueuse/core/index.cjs.js"),z=require("../ElSpinner.vue.cjs2.js"),L=require("./ElInputContainer.vue.cjs2.js"),K=require("../../node_modules/@vueuse/core/node_modules/@vueuse/shared/index.cjs.js"),O={class:"flex flex-col gap-1"},P={class:"flex items-center gap-1 px-2"},U=["disabled","validation","placeholder"],W={key:0,class:"text-xs font-normal text-error"},j=l.defineComponent({__name:"ElInputAutocomplete",props:{...D.withCommonElInputProps(),modelValue:{type:[Array,String],required:!1,default:void 0},placeholder:{type:String,default:"",required:!1},items:{type:Array,required:!1,default:()=>[]},selectedItems:{type:Array,default:()=>[]},labelSelectAll:{type:String,default:"Seleziona tutto"},labelDeselectAll:{type:String,default:"Deseleziona tutto"},focusOnMount:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},debounceTime:{type:Number,default:300,requied:!1},dataController:{type:Function,required:!1,default:void 0}},emits:["update:modelValue","item:click","update:selectedItems"],setup(p,{expose:w,emit:B}){const o=p,c=B,b=l.ref(!1),i=l.ref(!1),r=l.ref(o.modelValue),u=l.ref([]),n=l.ref(o.selectedItems),f=l.ref(),v=l.ref();l.onMounted(async()=>{if(o.dataController){const e=await g(r.value);u.value=(e==null?void 0:e.data)||[]}else u.value=o.items});const E=l.computed(()=>{var t;const e=(t=u.value)==null?void 0:t.map((a,d)=>({...a,text:a.label||a.text,check:n.value.some(s=>s.text?s.text===a.text:s.label===a.label),onClick:()=>{var s;if(o.multiple){const I=n.value.findIndex(m=>m.text?m.text===a.text:m.label===a.label);I!==-1?n.value=n.value.filter((m,A)=>A!==I):n.value.push({...a,check:!0}),r.value="",v.value=void 0,(s=f.value)==null||s.focus(),c("update:selectedItems",n.value)}else r.value=a.text||a.label||a.value||"";c("update:modelValue",a.text||a.label||a.value||""),c("item:click",d)}}));return o.multiple&&e.unshift({text:n.value.length===u.value.length?o.labelDeselectAll:o.labelSelectAll,check:!1,onClick:()=>{var a;n.value.length===u.value.length?n.value=[]:n.value=u.value,(a=f.value)==null||a.focus(),c("update:selectedItems",n.value)}}),e}),y=T.useMemoize(async e=>{var t;return await((t=o.dataController)==null?void 0:t.call(o,e))}),g=K.useDebounceFn(y,o.debounceTime),_=()=>y.cache.clear(),S=async()=>{var t;r.value=void 0,u.value=o.items,n.value=o.selectedItems;const e=await((t=o.dataController)==null?void 0:t.call(o,r.value));u.value=(e==null?void 0:e.data)||[]},x=e=>{var t;((t=e.relatedTarget)==null?void 0:t.role)!=="option"&&(i.value?i.value=!1:i.value=!0)},q=({target:e})=>{e instanceof HTMLInputElement&&e.value.charAt(e.value.length-1)!==" "&&M(e.value)},k=(e,t)=>{n.value=n.value.filter(a=>a.text!==t.text),c("update:selectedItems",n.value)},M=async e=>{if(o.dataController){b.value=!0;const t=await g(e);i.value=!!t,b.value=!t,u.value=(t==null?void 0:t.data)||[]}else e?u.value=o.items.filter(t=>{var a;return(a=t.text)==null?void 0:a.toLowerCase().includes(e.toLowerCase())}):u.value=o.items;c("update:modelValue",e)},C=e=>{var t,a;if(!r.value)if(n.value.length>0&&!v.value){const d=n.value.length-1;v.value=n.value[d],(t=document.getElementById(d.toString()))==null||t.focus()}else k(e,v.value),v.value=void 0,(a=f.value)==null||a.focus()},h=e=>{const t=e.currentTarget;t.scrollLeft+=e.deltaY,e.preventDefault()},V=e=>{o.multiple?i.value=!0:i.value=e};return w({resetAllAndFetch:S,clearCache:_}),(e,t)=>(l.openBlock(),l.createElementBlock("div",O,[l.createElementVNode("label",{class:l.normalizeClass(["text-sm font-semibold",{"text-error":e.errorMessage,"text-neutral-darker":!e.errorMessage}])},l.toDisplayString(e.label),3),l.createVNode(N.default,{items:E.value,multiple:p.multiple,"is-open":i.value,disabled:e.disabled,"onUpdate:isOpen":t[7]||(t[7]=a=>V(a))},{anchor:l.withCtx(()=>[l.createVNode(L.default,{color:e.color,name:e.name},{default:l.withCtx(()=>[l.createElementVNode("div",P,[p.multiple?(l.openBlock(),l.createElementBlock("div",{key:0,name:"scrollable-container",class:"flex items-center gap-1 overflow-x-scroll no-scrollbar cursor-grab active:cursor-grabbing",onWheel:h},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(n.value,(a,d)=>(l.openBlock(),l.createBlock(F.default,{id:d,key:d,text:a.text||a.label||"",class:"border flex-shrink-0 rounded-md px-3 py-2",onClick:s=>k(s,a),onKeydown:t[0]||(t[0]=l.withKeys(s=>C(s),["backspace"]))},null,8,["id","text","onClick"]))),128))],32)):l.createCommentVNode("",!0),l.withDirectives(l.createElementVNode("input",{ref_key:"inputField",ref:f,"onUpdate:modelValue":t[1]||(t[1]=a=>r.value=a),disabled:e.disabled,type:"text",class:l.normalizeClass(["border-none tex-tsm font-normal flex flex-1 focus:outline-none focus:ring-0",{"cursor-not-allowed":e.disabled}]),validation:e.validation,placeholder:p.placeholder,onInput:t[2]||(t[2]=a=>q(a)),onKeydown:t[3]||(t[3]=l.withKeys(a=>C(a),["backspace"])),onClick:t[4]||(t[4]=l.withModifiers(a=>x(a),["prevent"])),onBlur:t[5]||(t[5]=l.withModifiers(a=>x(a),["prevent"])),onWheel:t[6]||(t[6]=a=>h(a))},null,42,U),[[l.vModelText,r.value]]),b.value?(l.openBlock(),l.createBlock(z.default,{key:1,class:"mx-2",size:"normal"})):l.createCommentVNode("",!0)])]),_:1},8,["color","name"])]),_:1},8,["items","multiple","is-open","disabled"]),e.errorMessage?(l.openBlock(),l.createElementBlock("label",W,l.toDisplayString(e.errorMessage),1)):l.createCommentVNode("",!0)]))}});exports.default=j;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue"),D=require("./input.cjs.js"),N=require("../ElDropdown.vue.cjs2.js"),F=require("../ElInputChip.vue.cjs2.js"),T=require("../../node_modules/@vueuse/core/index.cjs.js"),z=require("../ElSpinner.vue.cjs2.js"),L=require("./ElInputContainer.vue.cjs2.js"),K=require("../../node_modules/@vueuse/core/node_modules/@vueuse/shared/index.cjs.js"),O={class:"flex flex-col gap-1"},P={class:"flex items-center gap-1 px-2"},U=["disabled","validation","placeholder"],W={key:0,class:"text-xs font-normal text-error"},j=l.defineComponent({__name:"ElInputAutocomplete",props:{...D.withCommonElInputProps(),modelValue:{type:[Array,String],required:!1,default:void 0},placeholder:{type:String,default:"",required:!1},items:{type:Array,required:!1,default:()=>[]},selectedItems:{type:Array,default:()=>[]},labelSelectAll:{type:String,default:"Seleziona tutto"},labelDeselectAll:{type:String,default:"Deseleziona tutto"},focusOnMount:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},debounceTime:{type:Number,default:300,requied:!1},dataController:{type:Function,required:!1,default:void 0}},emits:["update:modelValue","item:click","update:selectedItems"],setup(p,{expose:w,emit:B}){const o=p,c=B,b=l.ref(!1),i=l.ref(!1),r=l.ref(o.modelValue),u=l.ref([]),n=l.ref(o.selectedItems),f=l.ref(),v=l.ref();l.onMounted(async()=>{if(o.dataController){const e=await g(r.value);u.value=(e==null?void 0:e.data)||[]}else u.value=o.items});const E=l.computed(()=>{var t;const e=(t=u.value)==null?void 0:t.map((a,d)=>({...a,text:a.label||a.text,check:n.value.some(s=>s.text?s.text===a.text:s.label===a.label),onClick:()=>{var s;if(o.multiple){const I=n.value.findIndex(m=>m.text?m.text===a.text:m.label===a.label);I!==-1?n.value=n.value.filter((m,A)=>A!==I):n.value.push({...a,check:!0}),r.value="",v.value=void 0,(s=f.value)==null||s.focus(),c("update:selectedItems",n.value)}else r.value=a.text||a.label||a.value||"";c("update:modelValue",a.text||a.label||a.value||""),c("item:click",d)}}));return o.multiple&&e.unshift({text:n.value.length===u.value.length?o.labelDeselectAll:o.labelSelectAll,check:!1,onClick:()=>{var a;n.value.length===u.value.length?n.value=[]:n.value=u.value,(a=f.value)==null||a.focus(),c("update:selectedItems",n.value)}}),e}),y=T.useMemoize(async e=>{var t;return await((t=o.dataController)==null?void 0:t.call(o,e))}),g=K.useDebounceFn(y,o.debounceTime),_=()=>y.cache.clear(),S=async()=>{var t;r.value=void 0,u.value=o.items,n.value=o.selectedItems;const e=await((t=o.dataController)==null?void 0:t.call(o,r.value));u.value=(e==null?void 0:e.data)||[]},x=e=>{var t;((t=e.relatedTarget)==null?void 0:t.role)!=="option"&&(i.value?i.value=!1:i.value=!0)},q=({target:e})=>{e instanceof HTMLInputElement&&e.value.charAt(e.value.length-1)!==" "&&M(e.value)},k=(e,t)=>{n.value=n.value.filter(a=>a.text!==t.text),c("update:selectedItems",n.value)},M=async e=>{if(o.dataController){b.value=!0;const t=await g(e);i.value=!!t,b.value=!t,u.value=(t==null?void 0:t.data)||[]}else e?u.value=o.items.filter(t=>{var a;return(a=t.text)==null?void 0:a.toLowerCase().includes(e.toLowerCase())}):u.value=o.items;c("update:modelValue",e)},C=e=>{var t,a;if(!r.value)if(n.value.length>0&&!v.value){const d=n.value.length-1;v.value=n.value[d],(t=document.getElementById(d.toString()))==null||t.focus()}else k(e,v.value),v.value=void 0,(a=f.value)==null||a.focus()},h=e=>{const t=e.currentTarget;t.scrollLeft+=e.deltaY,e.preventDefault()},V=e=>{o.multiple?i.value=!0:i.value=e};return w({resetAllAndFetch:S,clearCache:_}),(e,t)=>(l.openBlock(),l.createElementBlock("div",O,[l.createElementVNode("label",{class:l.normalizeClass(["text-sm font-semibold",{"text-error":e.errorMessage,"text-neutral-darker":!e.errorMessage}])},l.toDisplayString(e.label),3),l.createVNode(N.default,{items:E.value,multiple:p.multiple,"is-open":i.value,disabled:e.disabled,"onUpdate:isOpen":t[7]||(t[7]=a=>V(a))},{anchor:l.withCtx(()=>[l.createVNode(L.default,{color:e.color,name:e.name},{default:l.withCtx(()=>[l.createElementVNode("div",P,[p.multiple?(l.openBlock(),l.createElementBlock("div",{key:0,name:"scrollable-container",class:"flex items-center gap-1 overflow-x-scroll no-scrollbar cursor-grab active:cursor-grabbing",onWheel:h},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(n.value,(a,d)=>(l.openBlock(),l.createBlock(F.default,{id:d,key:d,text:a.text||a.label||"",class:"border flex-shrink-0 rounded-md px-3 py-2",onClick:s=>k(s,a),onKeydown:t[0]||(t[0]=l.withKeys(s=>C(s),["backspace"]))},null,8,["id","text","onClick"]))),128))],32)):l.createCommentVNode("",!0),l.withDirectives(l.createElementVNode("input",{ref_key:"inputField",ref:f,"onUpdate:modelValue":t[1]||(t[1]=a=>r.value=a),disabled:e.disabled,type:"text",class:l.normalizeClass(["border-none tex-tsm font-normal flex flex-1 focus:outline-none focus:ring-0",{"cursor-not-allowed":e.disabled}]),validation:e.validation,placeholder:p.placeholder,onInput:t[2]||(t[2]=a=>q(a)),onKeydown:t[3]||(t[3]=l.withKeys(a=>C(a),["backspace"])),onClick:t[4]||(t[4]=l.withModifiers(a=>x(a),["prevent"])),onBlur:t[5]||(t[5]=l.withModifiers(a=>x(a),["prevent"])),onWheel:t[6]||(t[6]=a=>h(a))},null,42,U),[[l.vModelText,r.value]]),b.value?(l.openBlock(),l.createBlock(z.default,{key:1,class:"mx-2",size:"normal"})):l.createCommentVNode("",!0)])]),_:1},8,["color","name"])]),_:1},8,["items","multiple","is-open","disabled"]),e.errorMessage?(l.openBlock(),l.createElementBlock("div",W,l.toDisplayString(e.errorMessage),1)):l.createCommentVNode("",!0)]))}});exports.default=j;
2
2
  //# sourceMappingURL=ElInputAutocomplete.vue.cjs2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ElInputAutocomplete.vue.cjs2.js","sources":["../../../src/forms/ElInputAutocomplete.vue"],"sourcesContent":["<script lang=\"ts\">\nexport type InputAutocompleteItemsDataControl = string;\nexport type ElInputAutocompleteItems = Array<DropdownItem & { label?: string; value?: string }>;\n</script>\n\n<script lang=\"ts\" setup>\nimport { computed, onMounted, PropType, ref } from 'vue';\nimport { TextualValueType, withCommonElInputProps } from './input';\nimport ElDropdown, { DropdownItem } from '@/ElDropdown.vue';\nimport ElInputChip from '@/ElInputChip.vue';\nimport { useDebounceFn, useMemoize } from '@vueuse/core';\nimport ElSpinner from '@/ElSpinner.vue';\nimport ElInputContainer from './ElInputContainer.vue';\n\nconst props = defineProps({\n ...withCommonElInputProps(),\n modelValue: {\n type: [Array, String] as PropType<TextualValueType>,\n required: false,\n default: undefined,\n },\n placeholder: {\n type: String,\n default: '',\n required: false,\n },\n items: {\n type: Array as PropType<ElInputAutocompleteItems>,\n required: false,\n default: () => [],\n },\n selectedItems: {\n type: Array as PropType<ElInputAutocompleteItems>,\n default: () => [],\n },\n labelSelectAll: {\n type: String,\n default: 'Seleziona tutto',\n },\n labelDeselectAll: {\n type: String,\n default: 'Deseleziona tutto',\n },\n focusOnMount: {\n type: Boolean,\n default: false,\n },\n multiple: {\n type: Boolean as PropType<InstanceType<typeof ElDropdown>['multiple']>,\n default: false,\n },\n debounceTime: {\n type: Number,\n default: 300,\n requied: false,\n },\n dataController: {\n type: Function as PropType<(args: TextualValueType) => Promise<{ data: ElInputAutocompleteItems }>>,\n required: false,\n default: undefined,\n },\n});\n\nconst emit = defineEmits<{\n (event: 'update:modelValue', value: TextualValueType): void;\n (event: 'item:click', itemIndex: number): void;\n (event: 'update:selectedItems', value: ElInputAutocompleteItems): void;\n}>();\n\nconst isLoading = ref(false);\nconst isOpen = ref(false);\nconst query = ref<TextualValueType>(props.modelValue);\nconst filteredItems = ref<ElInputAutocompleteItems>([]);\nconst selectedItems = ref<ElInputAutocompleteItems>(props.selectedItems);\nconst inputField = ref<HTMLInputElement>();\nconst lastSelectedItem = ref();\n\nonMounted(async () => {\n if (props.dataController) {\n const response = await debounceDataController(query.value);\n filteredItems.value = response?.data || [];\n } else {\n filteredItems.value = props.items;\n }\n});\n\nconst items = computed(() => {\n const mappedItems = filteredItems.value?.map((item, index) => ({\n ...item,\n text: item.label || item.text,\n check: selectedItems.value.some(selectedItem =>\n selectedItem.text ? selectedItem.text === item.text : selectedItem.label === item.label,\n ),\n onClick: () => {\n if (props.multiple) {\n // If the item is already selected, remove it from the selectedItems array\n const clickedItemIndex = selectedItems.value.findIndex(currentItem =>\n currentItem.text ? currentItem.text === item.text : currentItem.label === item.label,\n );\n\n if (clickedItemIndex !== -1) {\n selectedItems.value = selectedItems.value.filter((_, index) => index !== clickedItemIndex);\n } else {\n selectedItems.value.push({ ...item, check: true });\n }\n\n // Reset query to empty string to clear the input\n query.value = '';\n // Reset last selected item because the selectedItems array is updated\n lastSelectedItem.value = undefined;\n inputField.value?.focus();\n\n emit('update:selectedItems', selectedItems.value);\n } else {\n query.value = item.text || item.label || item.value || '';\n }\n\n emit('update:modelValue', item.text || item.label || item.value || '');\n emit('item:click', index);\n },\n }));\n\n if (props.multiple) {\n mappedItems.unshift({\n text: selectedItems.value.length === filteredItems.value.length ? props.labelDeselectAll : props.labelSelectAll,\n check: false,\n onClick: () => {\n if (selectedItems.value.length === filteredItems.value.length) {\n selectedItems.value = [];\n } else {\n selectedItems.value = filteredItems.value;\n }\n\n inputField.value?.focus();\n emit('update:selectedItems', selectedItems.value);\n },\n });\n }\n\n return mappedItems;\n});\n\nconst debounceFunction = useMemoize(async (value: TextualValueType) => {\n return await props.dataController?.(value);\n});\n\nconst debounceDataController = useDebounceFn(debounceFunction, props.debounceTime);\nconst clearCache = () => debounceFunction.cache.clear();\n\nconst resetAllAndFetch = async () => {\n query.value = undefined;\n filteredItems.value = props.items;\n selectedItems.value = props.selectedItems;\n const response = await props.dataController?.(query.value);\n filteredItems.value = response?.data || [];\n};\n\n/**\n * Handle input click event necessary to open or close dropdown\n * @param e FocusEvent\n */\nconst onInputClick = (e: FocusEvent) => {\n if ((e.relatedTarget as HTMLElement)?.role !== 'option') {\n if (!isOpen.value) {\n isOpen.value = true;\n } else {\n isOpen.value = false;\n }\n }\n};\n\n/**\n * Handle input change event to update model value\n * @param event Event\n */\nconst onChangeEvent = ({ target }: Event) => {\n if (target instanceof HTMLInputElement) {\n if (target.value.charAt(target.value.length - 1) !== ' ') {\n updateModel(target.value);\n }\n }\n};\n\n/**\n * Handle remove item from selected items by clicking on the item\n * @param _event Event\n * @param item DropdownItem\n */\nconst onRemoveItem = (_event: Event, item: DropdownItem) => {\n selectedItems.value = selectedItems.value.filter(currentItem => currentItem.text !== item.text);\n emit('update:selectedItems', selectedItems.value);\n};\n\nconst updateModel = async (value: TextualValueType) => {\n if (props.dataController) {\n isLoading.value = true;\n const response = await debounceDataController(value);\n isOpen.value = !!response;\n isLoading.value = !response;\n filteredItems.value = response?.data || [];\n } else {\n if (value) {\n filteredItems.value = props.items.filter(result => result.text?.toLowerCase().includes(value.toLowerCase()));\n } else {\n filteredItems.value = props.items;\n }\n }\n\n emit('update:modelValue', value);\n};\n\n/**\n Handle backspace key press to remove last selected item when multiple is true\n param e KeyboardEvent\n */\nconst onDeleteKeyPress = (e: KeyboardEvent) => {\n if (!query.value) {\n if (selectedItems.value.length > 0 && !lastSelectedItem.value) {\n const lastItemIndex = selectedItems.value.length - 1;\n lastSelectedItem.value = selectedItems.value[lastItemIndex];\n document.getElementById(lastItemIndex.toString())?.focus();\n } else {\n onRemoveItem(e, lastSelectedItem.value);\n lastSelectedItem.value = undefined;\n inputField.value?.focus();\n }\n }\n};\n\n/**\n Handle wheel scroll event to scroll the listbox horizontally\n param event WheelEvent\n */\nconst onWheelScroll = (event: WheelEvent) => {\n const container = event.currentTarget as HTMLElement;\n container.scrollLeft += event.deltaY;\n // Prevent vertical scrolling of the page\n event.preventDefault();\n};\n\n/**\n Handle update isOpen event to open the dropdown when multiple is true\n param event boolean\n */\nconst onUpdateIsOpen = (event: boolean) => {\n if (props.multiple) {\n isOpen.value = true;\n } else {\n isOpen.value = event;\n }\n};\n\ndefineExpose({\n resetAllAndFetch,\n clearCache,\n});\n</script>\n\n<template>\n <div class=\"flex flex-col gap-1\">\n <label class=\"text-sm font-semibold\" :class=\"{ 'text-error': errorMessage, 'text-neutral-darker': !errorMessage }\">\n {{ label }}\n </label>\n <ElDropdown :items=\"items\" :multiple=\"multiple\" :is-open=\"isOpen\" :disabled=\"disabled\" @update:is-open=\"onUpdateIsOpen($event)\">\n <template #anchor>\n <ElInputContainer :color=\"color\" :name=\"name\">\n <template #default>\n <div class=\"flex items-center gap-1 px-2\">\n <div\n v-if=\"multiple\"\n name=\"scrollable-container\"\n class=\"flex items-center gap-1 overflow-x-scroll no-scrollbar cursor-grab active:cursor-grabbing\"\n @wheel=\"onWheelScroll\"\n >\n <ElInputChip\n v-for=\"(item, index) in selectedItems\"\n :id=\"index\"\n :key=\"index\"\n :text=\"item.text || item.label || ''\"\n class=\"border flex-shrink-0 rounded-md px-3 py-2\"\n @click=\"onRemoveItem($event, item)\"\n @keydown.backspace=\"onDeleteKeyPress($event)\"\n />\n </div>\n\n <input\n ref=\"inputField\"\n v-model=\"query\"\n :disabled=\"disabled\"\n type=\"text\"\n class=\"border-none tex-tsm font-normal flex flex-1 focus:outline-none focus:ring-0\"\n :class=\"{ 'cursor-not-allowed': disabled }\"\n :validation=\"validation\"\n :placeholder=\"placeholder\"\n @input=\"onChangeEvent($event)\"\n @keydown.backspace=\"onDeleteKeyPress($event)\"\n @click.prevent=\"onInputClick($event)\"\n @blur.prevent=\"onInputClick($event)\"\n @wheel=\"onWheelScroll($event)\"\n />\n\n <ElSpinner v-if=\"isLoading\" class=\"mx-2\" size=\"normal\" />\n </div>\n </template>\n </ElInputContainer>\n </template>\n </ElDropdown>\n <label v-if=\"errorMessage\" class=\"text-xs font-normal text-error\">{{ errorMessage }}</label>\n </div>\n</template>\n"],"names":["props","__props","emit","__emit","isLoading","ref","isOpen","query","filteredItems","selectedItems","inputField","lastSelectedItem","onMounted","response","debounceDataController","items","computed","mappedItems","_a","item","index","selectedItem","clickedItemIndex","currentItem","_","debounceFunction","useMemoize","value","useDebounceFn","clearCache","resetAllAndFetch","onInputClick","onChangeEvent","target","updateModel","onRemoveItem","_event","result","onDeleteKeyPress","lastItemIndex","_b","onWheelScroll","event","container","onUpdateIsOpen","__expose"],"mappings":"oxCAcA,MAAMA,EAAQC,EAiDRC,EAAOC,EAMPC,EAAYC,MAAI,EAAK,EACrBC,EAASD,MAAI,EAAK,EAClBE,EAAQF,EAAAA,IAAsBL,EAAM,UAAU,EAC9CQ,EAAgBH,MAA8B,CAAA,CAAE,EAChDI,EAAgBJ,EAAAA,IAA8BL,EAAM,aAAa,EACjEU,EAAaL,EAAAA,MACbM,EAAmBN,EAAAA,MAEzBO,EAAAA,UAAU,SAAY,CACpB,GAAIZ,EAAM,eAAgB,CACxB,MAAMa,EAAW,MAAMC,EAAuBP,EAAM,KAAK,EAC3CC,EAAA,OAAQK,GAAA,YAAAA,EAAU,OAAQ,CAAA,CAAC,MAEzCL,EAAc,MAAQR,EAAM,KAC9B,CACD,EAEK,MAAAe,EAAQC,EAAAA,SAAS,IAAM,OAC3B,MAAMC,GAAcC,EAAAV,EAAc,QAAd,YAAAU,EAAqB,IAAI,CAACC,EAAMC,KAAW,CAC7D,GAAGD,EACH,KAAMA,EAAK,OAASA,EAAK,KACzB,MAAOV,EAAc,MAAM,KAAKY,GAC9BA,EAAa,KAAOA,EAAa,OAASF,EAAK,KAAOE,EAAa,QAAUF,EAAK,KACpF,EACA,QAAS,IAAM,OACb,GAAInB,EAAM,SAAU,CAEZ,MAAAsB,EAAmBb,EAAc,MAAM,UAAUc,GACrDA,EAAY,KAAOA,EAAY,OAASJ,EAAK,KAAOI,EAAY,QAAUJ,EAAK,KAAA,EAG7EG,IAAqB,GACTb,EAAA,MAAQA,EAAc,MAAM,OAAO,CAACe,EAAGJ,IAAUA,IAAUE,CAAgB,EAEzFb,EAAc,MAAM,KAAK,CAAE,GAAGU,EAAM,MAAO,GAAM,EAInDZ,EAAM,MAAQ,GAEdI,EAAiB,MAAQ,QAC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AAQoC,CACjB,EAGW,OAAAG,EAAA,CACX,iBAAAf,EACA,WAAAD,CAAA,CACD"}
1
+ {"version":3,"file":"ElInputAutocomplete.vue.cjs2.js","sources":["../../../src/forms/ElInputAutocomplete.vue"],"sourcesContent":["<script lang=\"ts\">\nexport type InputAutocompleteItemsDataControl = string;\nexport type ElInputAutocompleteItems = Array<DropdownItem & { label?: string; value?: string }>;\n</script>\n\n<script lang=\"ts\" setup>\nimport { computed, onMounted, PropType, ref } from 'vue';\nimport { TextualValueType, withCommonElInputProps } from './input';\nimport ElDropdown, { DropdownItem } from '@/ElDropdown.vue';\nimport ElInputChip from '@/ElInputChip.vue';\nimport { useDebounceFn, useMemoize } from '@vueuse/core';\nimport ElSpinner from '@/ElSpinner.vue';\nimport ElInputContainer from './ElInputContainer.vue';\n\nconst props = defineProps({\n ...withCommonElInputProps(),\n modelValue: {\n type: [Array, String] as PropType<TextualValueType>,\n required: false,\n default: undefined,\n },\n placeholder: {\n type: String,\n default: '',\n required: false,\n },\n items: {\n type: Array as PropType<ElInputAutocompleteItems>,\n required: false,\n default: () => [],\n },\n selectedItems: {\n type: Array as PropType<ElInputAutocompleteItems>,\n default: () => [],\n },\n labelSelectAll: {\n type: String,\n default: 'Seleziona tutto',\n },\n labelDeselectAll: {\n type: String,\n default: 'Deseleziona tutto',\n },\n focusOnMount: {\n type: Boolean,\n default: false,\n },\n multiple: {\n type: Boolean as PropType<InstanceType<typeof ElDropdown>['multiple']>,\n default: false,\n },\n debounceTime: {\n type: Number,\n default: 300,\n requied: false,\n },\n dataController: {\n type: Function as PropType<(args: TextualValueType) => Promise<{ data: ElInputAutocompleteItems }>>,\n required: false,\n default: undefined,\n },\n});\n\nconst emit = defineEmits<{\n (event: 'update:modelValue', value: TextualValueType): void;\n (event: 'item:click', itemIndex: number): void;\n (event: 'update:selectedItems', value: ElInputAutocompleteItems): void;\n}>();\n\nconst isLoading = ref(false);\nconst isOpen = ref(false);\nconst query = ref<TextualValueType>(props.modelValue);\nconst filteredItems = ref<ElInputAutocompleteItems>([]);\nconst selectedItems = ref<ElInputAutocompleteItems>(props.selectedItems);\nconst inputField = ref<HTMLInputElement>();\nconst lastSelectedItem = ref();\n\nonMounted(async () => {\n if (props.dataController) {\n const response = await debounceDataController(query.value);\n filteredItems.value = response?.data || [];\n } else {\n filteredItems.value = props.items;\n }\n});\n\nconst items = computed(() => {\n const mappedItems = filteredItems.value?.map((item, index) => ({\n ...item,\n text: item.label || item.text,\n check: selectedItems.value.some(selectedItem =>\n selectedItem.text ? selectedItem.text === item.text : selectedItem.label === item.label,\n ),\n onClick: () => {\n if (props.multiple) {\n // If the item is already selected, remove it from the selectedItems array\n const clickedItemIndex = selectedItems.value.findIndex(currentItem =>\n currentItem.text ? currentItem.text === item.text : currentItem.label === item.label,\n );\n\n if (clickedItemIndex !== -1) {\n selectedItems.value = selectedItems.value.filter((_, index) => index !== clickedItemIndex);\n } else {\n selectedItems.value.push({ ...item, check: true });\n }\n\n // Reset query to empty string to clear the input\n query.value = '';\n // Reset last selected item because the selectedItems array is updated\n lastSelectedItem.value = undefined;\n inputField.value?.focus();\n\n emit('update:selectedItems', selectedItems.value);\n } else {\n query.value = item.text || item.label || item.value || '';\n }\n\n emit('update:modelValue', item.text || item.label || item.value || '');\n emit('item:click', index);\n },\n }));\n\n if (props.multiple) {\n mappedItems.unshift({\n text: selectedItems.value.length === filteredItems.value.length ? props.labelDeselectAll : props.labelSelectAll,\n check: false,\n onClick: () => {\n if (selectedItems.value.length === filteredItems.value.length) {\n selectedItems.value = [];\n } else {\n selectedItems.value = filteredItems.value;\n }\n\n inputField.value?.focus();\n emit('update:selectedItems', selectedItems.value);\n },\n });\n }\n\n return mappedItems;\n});\n\nconst debounceFunction = useMemoize(async (value: TextualValueType) => {\n return await props.dataController?.(value);\n});\n\nconst debounceDataController = useDebounceFn(debounceFunction, props.debounceTime);\nconst clearCache = () => debounceFunction.cache.clear();\n\nconst resetAllAndFetch = async () => {\n query.value = undefined;\n filteredItems.value = props.items;\n selectedItems.value = props.selectedItems;\n const response = await props.dataController?.(query.value);\n filteredItems.value = response?.data || [];\n};\n\n/**\n * Handle input click event necessary to open or close dropdown\n * @param e FocusEvent\n */\nconst onInputClick = (e: FocusEvent) => {\n if ((e.relatedTarget as HTMLElement)?.role !== 'option') {\n if (!isOpen.value) {\n isOpen.value = true;\n } else {\n isOpen.value = false;\n }\n }\n};\n\n/**\n * Handle input change event to update model value\n * @param event Event\n */\nconst onChangeEvent = ({ target }: Event) => {\n if (target instanceof HTMLInputElement) {\n if (target.value.charAt(target.value.length - 1) !== ' ') {\n updateModel(target.value);\n }\n }\n};\n\n/**\n * Handle remove item from selected items by clicking on the item\n * @param _event Event\n * @param item DropdownItem\n */\nconst onRemoveItem = (_event: Event, item: DropdownItem) => {\n selectedItems.value = selectedItems.value.filter(currentItem => currentItem.text !== item.text);\n emit('update:selectedItems', selectedItems.value);\n};\n\nconst updateModel = async (value: TextualValueType) => {\n if (props.dataController) {\n isLoading.value = true;\n const response = await debounceDataController(value);\n isOpen.value = !!response;\n isLoading.value = !response;\n filteredItems.value = response?.data || [];\n } else {\n if (value) {\n filteredItems.value = props.items.filter(result => result.text?.toLowerCase().includes(value.toLowerCase()));\n } else {\n filteredItems.value = props.items;\n }\n }\n\n emit('update:modelValue', value);\n};\n\n/**\n Handle backspace key press to remove last selected item when multiple is true\n param e KeyboardEvent\n */\nconst onDeleteKeyPress = (e: KeyboardEvent) => {\n if (!query.value) {\n if (selectedItems.value.length > 0 && !lastSelectedItem.value) {\n const lastItemIndex = selectedItems.value.length - 1;\n lastSelectedItem.value = selectedItems.value[lastItemIndex];\n document.getElementById(lastItemIndex.toString())?.focus();\n } else {\n onRemoveItem(e, lastSelectedItem.value);\n lastSelectedItem.value = undefined;\n inputField.value?.focus();\n }\n }\n};\n\n/**\n Handle wheel scroll event to scroll the listbox horizontally\n param event WheelEvent\n */\nconst onWheelScroll = (event: WheelEvent) => {\n const container = event.currentTarget as HTMLElement;\n container.scrollLeft += event.deltaY;\n // Prevent vertical scrolling of the page\n event.preventDefault();\n};\n\n/**\n Handle update isOpen event to open the dropdown when multiple is true\n param event boolean\n */\nconst onUpdateIsOpen = (event: boolean) => {\n if (props.multiple) {\n isOpen.value = true;\n } else {\n isOpen.value = event;\n }\n};\n\ndefineExpose({\n resetAllAndFetch,\n clearCache,\n});\n</script>\n\n<template>\n <div class=\"flex flex-col gap-1\">\n <label class=\"text-sm font-semibold\" :class=\"{ 'text-error': errorMessage, 'text-neutral-darker': !errorMessage }\">\n {{ label }}\n </label>\n <ElDropdown :items=\"items\" :multiple=\"multiple\" :is-open=\"isOpen\" :disabled=\"disabled\" @update:is-open=\"onUpdateIsOpen($event)\">\n <template #anchor>\n <ElInputContainer :color=\"color\" :name=\"name\">\n <template #default>\n <div class=\"flex items-center gap-1 px-2\">\n <div\n v-if=\"multiple\"\n name=\"scrollable-container\"\n class=\"flex items-center gap-1 overflow-x-scroll no-scrollbar cursor-grab active:cursor-grabbing\"\n @wheel=\"onWheelScroll\"\n >\n <ElInputChip\n v-for=\"(item, index) in selectedItems\"\n :id=\"index\"\n :key=\"index\"\n :text=\"item.text || item.label || ''\"\n class=\"border flex-shrink-0 rounded-md px-3 py-2\"\n @click=\"onRemoveItem($event, item)\"\n @keydown.backspace=\"onDeleteKeyPress($event)\"\n />\n </div>\n\n <input\n ref=\"inputField\"\n v-model=\"query\"\n :disabled=\"disabled\"\n type=\"text\"\n class=\"border-none tex-tsm font-normal flex flex-1 focus:outline-none focus:ring-0\"\n :class=\"{ 'cursor-not-allowed': disabled }\"\n :validation=\"validation\"\n :placeholder=\"placeholder\"\n @input=\"onChangeEvent($event)\"\n @keydown.backspace=\"onDeleteKeyPress($event)\"\n @click.prevent=\"onInputClick($event)\"\n @blur.prevent=\"onInputClick($event)\"\n @wheel=\"onWheelScroll($event)\"\n />\n\n <ElSpinner v-if=\"isLoading\" class=\"mx-2\" size=\"normal\" />\n </div>\n </template>\n </ElInputContainer>\n </template>\n </ElDropdown>\n <div v-if=\"errorMessage\" class=\"text-xs font-normal text-error\">{{ errorMessage }}</div>\n </div>\n</template>\n"],"names":["props","__props","emit","__emit","isLoading","ref","isOpen","query","filteredItems","selectedItems","inputField","lastSelectedItem","onMounted","response","debounceDataController","items","computed","mappedItems","_a","item","index","selectedItem","clickedItemIndex","currentItem","_","debounceFunction","useMemoize","value","useDebounceFn","clearCache","resetAllAndFetch","onInputClick","onChangeEvent","target","updateModel","onRemoveItem","_event","result","onDeleteKeyPress","lastItemIndex","_b","onWheelScroll","event","container","onUpdateIsOpen","__expose"],"mappings":"oxCAcA,MAAMA,EAAQC,EAiDRC,EAAOC,EAMPC,EAAYC,MAAI,EAAK,EACrBC,EAASD,MAAI,EAAK,EAClBE,EAAQF,EAAAA,IAAsBL,EAAM,UAAU,EAC9CQ,EAAgBH,MAA8B,CAAA,CAAE,EAChDI,EAAgBJ,EAAAA,IAA8BL,EAAM,aAAa,EACjEU,EAAaL,EAAAA,MACbM,EAAmBN,EAAAA,MAEzBO,EAAAA,UAAU,SAAY,CACpB,GAAIZ,EAAM,eAAgB,CACxB,MAAMa,EAAW,MAAMC,EAAuBP,EAAM,KAAK,EAC3CC,EAAA,OAAQK,GAAA,YAAAA,EAAU,OAAQ,CAAA,CAAC,MAEzCL,EAAc,MAAQR,EAAM,KAC9B,CACD,EAEK,MAAAe,EAAQC,EAAAA,SAAS,IAAM,OAC3B,MAAMC,GAAcC,EAAAV,EAAc,QAAd,YAAAU,EAAqB,IAAI,CAACC,EAAMC,KAAW,CAC7D,GAAGD,EACH,KAAMA,EAAK,OAASA,EAAK,KACzB,MAAOV,EAAc,MAAM,KAAKY,GAC9BA,EAAa,KAAOA,EAAa,OAASF,EAAK,KAAOE,EAAa,QAAUF,EAAK,KACpF,EACA,QAAS,IAAM,OACb,GAAInB,EAAM,SAAU,CAEZ,MAAAsB,EAAmBb,EAAc,MAAM,UAAUc,GACrDA,EAAY,KAAOA,EAAY,OAASJ,EAAK,KAAOI,EAAY,QAAUJ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W,QAAX,MAAA8B,EAAkB,OAEtB,EAOIC,EAAiBC,GAAsB,CAC3C,MAAMC,EAAYD,EAAM,cACxBC,EAAU,YAAcD,EAAM,OAE9BA,EAAM,eAAe,CAAA,EAOjBE,EAAkBF,GAAmB,CACrC1C,EAAM,SACRM,EAAO,MAAQ,GAEfA,EAAO,MAAQoC,CACjB,EAGW,OAAAG,EAAA,CACX,iBAAAf,EACA,WAAAD,CAAA,CACD"}
@@ -1,2 +1,2 @@
1
- import{defineComponent as H,ref as d,onMounted as R,computed as Y,openBlock as f,createElementBlock as x,createElementVNode as g,normalizeClass as D,toDisplayString as V,createVNode as B,withCtx as E,Fragment as j,renderList as G,createBlock as F,withKeys as q,createCommentVNode as k,withDirectives as J,withModifiers as L,vModelText as Q}from"vue";import{withCommonElInputProps as X}from"./input.esm.js";import Z from"../ElDropdown.vue.esm2.js";import _ from"../ElInputChip.vue.esm2.js";import{useMemoize as ee}from"../../node_modules/@vueuse/core/index.esm.js";import le from"../ElSpinner.vue.esm2.js";import te from"./ElInputContainer.vue.esm2.js";import{useDebounceFn as ae}from"../../node_modules/@vueuse/core/node_modules/@vueuse/shared/index.esm.js";const oe={class:"flex flex-col gap-1"},ne={class:"flex items-center gap-1 px-2"},se=["disabled","validation","placeholder"],ue={key:0,class:"text-xs font-normal text-error"},be=H({__name:"ElInputAutocomplete",props:{...X(),modelValue:{type:[Array,String],required:!1,default:void 0},placeholder:{type:String,default:"",required:!1},items:{type:Array,required:!1,default:()=>[]},selectedItems:{type:Array,default:()=>[]},labelSelectAll:{type:String,default:"Seleziona tutto"},labelDeselectAll:{type:String,default:"Deseleziona tutto"},focusOnMount:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},debounceTime:{type:Number,default:300,requied:!1},dataController:{type:Function,required:!1,default:void 0}},emits:["update:modelValue","item:click","update:selectedItems"],setup(v,{expose:T,emit:z}){const a=v,c=z,y=d(!1),r=d(!1),u=d(a.modelValue),n=d([]),o=d(a.selectedItems),p=d(),m=d();R(async()=>{if(a.dataController){const e=await h(u.value);n.value=(e==null?void 0:e.data)||[]}else n.value=a.items});const K=Y(()=>{var l;const e=(l=n.value)==null?void 0:l.map((t,i)=>({...t,text:t.label||t.text,check:o.value.some(s=>s.text?s.text===t.text:s.label===t.label),onClick:()=>{var s;if(a.multiple){const S=o.value.findIndex(b=>b.text?b.text===t.text:b.label===t.label);S!==-1?o.value=o.value.filter((b,P)=>P!==S):o.value.push({...t,check:!0}),u.value="",m.value=void 0,(s=p.value)==null||s.focus(),c("update:selectedItems",o.value)}else u.value=t.text||t.label||t.value||"";c("update:modelValue",t.text||t.label||t.value||""),c("item:click",i)}}));return a.multiple&&e.unshift({text:o.value.length===n.value.length?a.labelDeselectAll:a.labelSelectAll,check:!1,onClick:()=>{var t;o.value.length===n.value.length?o.value=[]:o.value=n.value,(t=p.value)==null||t.focus(),c("update:selectedItems",o.value)}}),e}),C=ee(async e=>{var l;return await((l=a.dataController)==null?void 0:l.call(a,e))}),h=ae(C,a.debounceTime),N=()=>C.cache.clear(),O=async()=>{var l;u.value=void 0,n.value=a.items,o.value=a.selectedItems;const e=await((l=a.dataController)==null?void 0:l.call(a,u.value));n.value=(e==null?void 0:e.data)||[]},I=e=>{var l;((l=e.relatedTarget)==null?void 0:l.role)!=="option"&&(r.value?r.value=!1:r.value=!0)},$=({target:e})=>{e instanceof HTMLInputElement&&e.value.charAt(e.value.length-1)!==" "&&U(e.value)},w=(e,l)=>{o.value=o.value.filter(t=>t.text!==l.text),c("update:selectedItems",o.value)},U=async e=>{if(a.dataController){y.value=!0;const l=await h(e);r.value=!!l,y.value=!l,n.value=(l==null?void 0:l.data)||[]}else e?n.value=a.items.filter(l=>{var t;return(t=l.text)==null?void 0:t.toLowerCase().includes(e.toLowerCase())}):n.value=a.items;c("update:modelValue",e)},A=e=>{var l,t;if(!u.value)if(o.value.length>0&&!m.value){const i=o.value.length-1;m.value=o.value[i],(l=document.getElementById(i.toString()))==null||l.focus()}else w(e,m.value),m.value=void 0,(t=p.value)==null||t.focus()},M=e=>{const l=e.currentTarget;l.scrollLeft+=e.deltaY,e.preventDefault()},W=e=>{a.multiple?r.value=!0:r.value=e};return T({resetAllAndFetch:O,clearCache:N}),(e,l)=>(f(),x("div",oe,[g("label",{class:D(["text-sm font-semibold",{"text-error":e.errorMessage,"text-neutral-darker":!e.errorMessage}])},V(e.label),3),B(Z,{items:K.value,multiple:v.multiple,"is-open":r.value,disabled:e.disabled,"onUpdate:isOpen":l[7]||(l[7]=t=>W(t))},{anchor:E(()=>[B(te,{color:e.color,name:e.name},{default:E(()=>[g("div",ne,[v.multiple?(f(),x("div",{key:0,name:"scrollable-container",class:"flex items-center gap-1 overflow-x-scroll no-scrollbar cursor-grab active:cursor-grabbing",onWheel:M},[(f(!0),x(j,null,G(o.value,(t,i)=>(f(),F(_,{id:i,key:i,text:t.text||t.label||"",class:"border flex-shrink-0 rounded-md px-3 py-2",onClick:s=>w(s,t),onKeydown:l[0]||(l[0]=q(s=>A(s),["backspace"]))},null,8,["id","text","onClick"]))),128))],32)):k("",!0),J(g("input",{ref_key:"inputField",ref:p,"onUpdate:modelValue":l[1]||(l[1]=t=>u.value=t),disabled:e.disabled,type:"text",class:D(["border-none tex-tsm font-normal flex flex-1 focus:outline-none focus:ring-0",{"cursor-not-allowed":e.disabled}]),validation:e.validation,placeholder:v.placeholder,onInput:l[2]||(l[2]=t=>$(t)),onKeydown:l[3]||(l[3]=q(t=>A(t),["backspace"])),onClick:l[4]||(l[4]=L(t=>I(t),["prevent"])),onBlur:l[5]||(l[5]=L(t=>I(t),["prevent"])),onWheel:l[6]||(l[6]=t=>M(t))},null,42,se),[[Q,u.value]]),y.value?(f(),F(le,{key:1,class:"mx-2",size:"normal"})):k("",!0)])]),_:1},8,["color","name"])]),_:1},8,["items","multiple","is-open","disabled"]),e.errorMessage?(f(),x("label",ue,V(e.errorMessage),1)):k("",!0)]))}});export{be as default};
1
+ import{defineComponent as H,ref as d,onMounted as R,computed as Y,openBlock as f,createElementBlock as x,createElementVNode as g,normalizeClass as D,toDisplayString as V,createVNode as B,withCtx as E,Fragment as j,renderList as G,createBlock as F,withKeys as q,createCommentVNode as k,withDirectives as J,withModifiers as L,vModelText as Q}from"vue";import{withCommonElInputProps as X}from"./input.esm.js";import Z from"../ElDropdown.vue.esm2.js";import _ from"../ElInputChip.vue.esm2.js";import{useMemoize as ee}from"../../node_modules/@vueuse/core/index.esm.js";import le from"../ElSpinner.vue.esm2.js";import te from"./ElInputContainer.vue.esm2.js";import{useDebounceFn as ae}from"../../node_modules/@vueuse/core/node_modules/@vueuse/shared/index.esm.js";const oe={class:"flex flex-col gap-1"},ne={class:"flex items-center gap-1 px-2"},se=["disabled","validation","placeholder"],ue={key:0,class:"text-xs font-normal text-error"},be=H({__name:"ElInputAutocomplete",props:{...X(),modelValue:{type:[Array,String],required:!1,default:void 0},placeholder:{type:String,default:"",required:!1},items:{type:Array,required:!1,default:()=>[]},selectedItems:{type:Array,default:()=>[]},labelSelectAll:{type:String,default:"Seleziona tutto"},labelDeselectAll:{type:String,default:"Deseleziona tutto"},focusOnMount:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},debounceTime:{type:Number,default:300,requied:!1},dataController:{type:Function,required:!1,default:void 0}},emits:["update:modelValue","item:click","update:selectedItems"],setup(v,{expose:T,emit:z}){const a=v,c=z,y=d(!1),r=d(!1),u=d(a.modelValue),n=d([]),o=d(a.selectedItems),p=d(),m=d();R(async()=>{if(a.dataController){const e=await h(u.value);n.value=(e==null?void 0:e.data)||[]}else n.value=a.items});const K=Y(()=>{var l;const e=(l=n.value)==null?void 0:l.map((t,i)=>({...t,text:t.label||t.text,check:o.value.some(s=>s.text?s.text===t.text:s.label===t.label),onClick:()=>{var s;if(a.multiple){const S=o.value.findIndex(b=>b.text?b.text===t.text:b.label===t.label);S!==-1?o.value=o.value.filter((b,P)=>P!==S):o.value.push({...t,check:!0}),u.value="",m.value=void 0,(s=p.value)==null||s.focus(),c("update:selectedItems",o.value)}else u.value=t.text||t.label||t.value||"";c("update:modelValue",t.text||t.label||t.value||""),c("item:click",i)}}));return a.multiple&&e.unshift({text:o.value.length===n.value.length?a.labelDeselectAll:a.labelSelectAll,check:!1,onClick:()=>{var t;o.value.length===n.value.length?o.value=[]:o.value=n.value,(t=p.value)==null||t.focus(),c("update:selectedItems",o.value)}}),e}),C=ee(async e=>{var l;return await((l=a.dataController)==null?void 0:l.call(a,e))}),h=ae(C,a.debounceTime),N=()=>C.cache.clear(),O=async()=>{var l;u.value=void 0,n.value=a.items,o.value=a.selectedItems;const e=await((l=a.dataController)==null?void 0:l.call(a,u.value));n.value=(e==null?void 0:e.data)||[]},I=e=>{var l;((l=e.relatedTarget)==null?void 0:l.role)!=="option"&&(r.value?r.value=!1:r.value=!0)},$=({target:e})=>{e instanceof HTMLInputElement&&e.value.charAt(e.value.length-1)!==" "&&U(e.value)},w=(e,l)=>{o.value=o.value.filter(t=>t.text!==l.text),c("update:selectedItems",o.value)},U=async e=>{if(a.dataController){y.value=!0;const l=await h(e);r.value=!!l,y.value=!l,n.value=(l==null?void 0:l.data)||[]}else e?n.value=a.items.filter(l=>{var t;return(t=l.text)==null?void 0:t.toLowerCase().includes(e.toLowerCase())}):n.value=a.items;c("update:modelValue",e)},A=e=>{var l,t;if(!u.value)if(o.value.length>0&&!m.value){const i=o.value.length-1;m.value=o.value[i],(l=document.getElementById(i.toString()))==null||l.focus()}else w(e,m.value),m.value=void 0,(t=p.value)==null||t.focus()},M=e=>{const l=e.currentTarget;l.scrollLeft+=e.deltaY,e.preventDefault()},W=e=>{a.multiple?r.value=!0:r.value=e};return T({resetAllAndFetch:O,clearCache:N}),(e,l)=>(f(),x("div",oe,[g("label",{class:D(["text-sm font-semibold",{"text-error":e.errorMessage,"text-neutral-darker":!e.errorMessage}])},V(e.label),3),B(Z,{items:K.value,multiple:v.multiple,"is-open":r.value,disabled:e.disabled,"onUpdate:isOpen":l[7]||(l[7]=t=>W(t))},{anchor:E(()=>[B(te,{color:e.color,name:e.name},{default:E(()=>[g("div",ne,[v.multiple?(f(),x("div",{key:0,name:"scrollable-container",class:"flex items-center gap-1 overflow-x-scroll no-scrollbar cursor-grab active:cursor-grabbing",onWheel:M},[(f(!0),x(j,null,G(o.value,(t,i)=>(f(),F(_,{id:i,key:i,text:t.text||t.label||"",class:"border flex-shrink-0 rounded-md px-3 py-2",onClick:s=>w(s,t),onKeydown:l[0]||(l[0]=q(s=>A(s),["backspace"]))},null,8,["id","text","onClick"]))),128))],32)):k("",!0),J(g("input",{ref_key:"inputField",ref:p,"onUpdate:modelValue":l[1]||(l[1]=t=>u.value=t),disabled:e.disabled,type:"text",class:D(["border-none tex-tsm font-normal flex flex-1 focus:outline-none focus:ring-0",{"cursor-not-allowed":e.disabled}]),validation:e.validation,placeholder:v.placeholder,onInput:l[2]||(l[2]=t=>$(t)),onKeydown:l[3]||(l[3]=q(t=>A(t),["backspace"])),onClick:l[4]||(l[4]=L(t=>I(t),["prevent"])),onBlur:l[5]||(l[5]=L(t=>I(t),["prevent"])),onWheel:l[6]||(l[6]=t=>M(t))},null,42,se),[[Q,u.value]]),y.value?(f(),F(le,{key:1,class:"mx-2",size:"normal"})):k("",!0)])]),_:1},8,["color","name"])]),_:1},8,["items","multiple","is-open","disabled"]),e.errorMessage?(f(),x("div",ue,V(e.errorMessage),1)):k("",!0)]))}});export{be as default};
2
2
  //# sourceMappingURL=ElInputAutocomplete.vue.esm2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ElInputAutocomplete.vue.esm2.js","sources":["../../../src/forms/ElInputAutocomplete.vue"],"sourcesContent":["<script lang=\"ts\">\nexport type InputAutocompleteItemsDataControl = string;\nexport type ElInputAutocompleteItems = Array<DropdownItem & { label?: string; value?: string }>;\n</script>\n\n<script lang=\"ts\" setup>\nimport { computed, onMounted, PropType, ref } from 'vue';\nimport { TextualValueType, withCommonElInputProps } from './input';\nimport ElDropdown, { DropdownItem } from '@/ElDropdown.vue';\nimport ElInputChip from '@/ElInputChip.vue';\nimport { useDebounceFn, useMemoize } from '@vueuse/core';\nimport ElSpinner from '@/ElSpinner.vue';\nimport ElInputContainer from './ElInputContainer.vue';\n\nconst props = defineProps({\n ...withCommonElInputProps(),\n modelValue: {\n type: [Array, String] as PropType<TextualValueType>,\n required: false,\n default: undefined,\n },\n placeholder: {\n type: String,\n default: '',\n required: false,\n },\n items: {\n type: Array as PropType<ElInputAutocompleteItems>,\n required: false,\n default: () => [],\n },\n selectedItems: {\n type: Array as PropType<ElInputAutocompleteItems>,\n default: () => [],\n },\n labelSelectAll: {\n type: String,\n default: 'Seleziona tutto',\n },\n labelDeselectAll: {\n type: String,\n default: 'Deseleziona tutto',\n },\n focusOnMount: {\n type: Boolean,\n default: false,\n },\n multiple: {\n type: Boolean as PropType<InstanceType<typeof ElDropdown>['multiple']>,\n default: false,\n },\n debounceTime: {\n type: Number,\n default: 300,\n requied: false,\n },\n dataController: {\n type: Function as PropType<(args: TextualValueType) => Promise<{ data: ElInputAutocompleteItems }>>,\n required: false,\n default: undefined,\n },\n});\n\nconst emit = defineEmits<{\n (event: 'update:modelValue', value: TextualValueType): void;\n (event: 'item:click', itemIndex: number): void;\n (event: 'update:selectedItems', value: ElInputAutocompleteItems): void;\n}>();\n\nconst isLoading = ref(false);\nconst isOpen = ref(false);\nconst query = ref<TextualValueType>(props.modelValue);\nconst filteredItems = ref<ElInputAutocompleteItems>([]);\nconst selectedItems = ref<ElInputAutocompleteItems>(props.selectedItems);\nconst inputField = ref<HTMLInputElement>();\nconst lastSelectedItem = ref();\n\nonMounted(async () => {\n if (props.dataController) {\n const response = await debounceDataController(query.value);\n filteredItems.value = response?.data || [];\n } else {\n filteredItems.value = props.items;\n }\n});\n\nconst items = computed(() => {\n const mappedItems = filteredItems.value?.map((item, index) => ({\n ...item,\n text: item.label || item.text,\n check: selectedItems.value.some(selectedItem =>\n selectedItem.text ? selectedItem.text === item.text : selectedItem.label === item.label,\n ),\n onClick: () => {\n if (props.multiple) {\n // If the item is already selected, remove it from the selectedItems array\n const clickedItemIndex = selectedItems.value.findIndex(currentItem =>\n currentItem.text ? currentItem.text === item.text : currentItem.label === item.label,\n );\n\n if (clickedItemIndex !== -1) {\n selectedItems.value = selectedItems.value.filter((_, index) => index !== clickedItemIndex);\n } else {\n selectedItems.value.push({ ...item, check: true });\n }\n\n // Reset query to empty string to clear the input\n query.value = '';\n // Reset last selected item because the selectedItems array is updated\n lastSelectedItem.value = undefined;\n inputField.value?.focus();\n\n emit('update:selectedItems', selectedItems.value);\n } else {\n query.value = item.text || item.label || item.value || '';\n }\n\n emit('update:modelValue', item.text || item.label || item.value || '');\n emit('item:click', index);\n },\n }));\n\n if (props.multiple) {\n mappedItems.unshift({\n text: selectedItems.value.length === filteredItems.value.length ? props.labelDeselectAll : props.labelSelectAll,\n check: false,\n onClick: () => {\n if (selectedItems.value.length === filteredItems.value.length) {\n selectedItems.value = [];\n } else {\n selectedItems.value = filteredItems.value;\n }\n\n inputField.value?.focus();\n emit('update:selectedItems', selectedItems.value);\n },\n });\n }\n\n return mappedItems;\n});\n\nconst debounceFunction = useMemoize(async (value: TextualValueType) => {\n return await props.dataController?.(value);\n});\n\nconst debounceDataController = useDebounceFn(debounceFunction, props.debounceTime);\nconst clearCache = () => debounceFunction.cache.clear();\n\nconst resetAllAndFetch = async () => {\n query.value = undefined;\n filteredItems.value = props.items;\n selectedItems.value = props.selectedItems;\n const response = await props.dataController?.(query.value);\n filteredItems.value = response?.data || [];\n};\n\n/**\n * Handle input click event necessary to open or close dropdown\n * @param e FocusEvent\n */\nconst onInputClick = (e: FocusEvent) => {\n if ((e.relatedTarget as HTMLElement)?.role !== 'option') {\n if (!isOpen.value) {\n isOpen.value = true;\n } else {\n isOpen.value = false;\n }\n }\n};\n\n/**\n * Handle input change event to update model value\n * @param event Event\n */\nconst onChangeEvent = ({ target }: Event) => {\n if (target instanceof HTMLInputElement) {\n if (target.value.charAt(target.value.length - 1) !== ' ') {\n updateModel(target.value);\n }\n }\n};\n\n/**\n * Handle remove item from selected items by clicking on the item\n * @param _event Event\n * @param item DropdownItem\n */\nconst onRemoveItem = (_event: Event, item: DropdownItem) => {\n selectedItems.value = selectedItems.value.filter(currentItem => currentItem.text !== item.text);\n emit('update:selectedItems', selectedItems.value);\n};\n\nconst updateModel = async (value: TextualValueType) => {\n if (props.dataController) {\n isLoading.value = true;\n const response = await debounceDataController(value);\n isOpen.value = !!response;\n isLoading.value = !response;\n filteredItems.value = response?.data || [];\n } else {\n if (value) {\n filteredItems.value = props.items.filter(result => result.text?.toLowerCase().includes(value.toLowerCase()));\n } else {\n filteredItems.value = props.items;\n }\n }\n\n emit('update:modelValue', value);\n};\n\n/**\n Handle backspace key press to remove last selected item when multiple is true\n param e KeyboardEvent\n */\nconst onDeleteKeyPress = (e: KeyboardEvent) => {\n if (!query.value) {\n if (selectedItems.value.length > 0 && !lastSelectedItem.value) {\n const lastItemIndex = selectedItems.value.length - 1;\n lastSelectedItem.value = selectedItems.value[lastItemIndex];\n document.getElementById(lastItemIndex.toString())?.focus();\n } else {\n onRemoveItem(e, lastSelectedItem.value);\n lastSelectedItem.value = undefined;\n inputField.value?.focus();\n }\n }\n};\n\n/**\n Handle wheel scroll event to scroll the listbox horizontally\n param event WheelEvent\n */\nconst onWheelScroll = (event: WheelEvent) => {\n const container = event.currentTarget as HTMLElement;\n container.scrollLeft += event.deltaY;\n // Prevent vertical scrolling of the page\n event.preventDefault();\n};\n\n/**\n Handle update isOpen event to open the dropdown when multiple is true\n param event boolean\n */\nconst onUpdateIsOpen = (event: boolean) => {\n if (props.multiple) {\n isOpen.value = true;\n } else {\n isOpen.value = event;\n }\n};\n\ndefineExpose({\n resetAllAndFetch,\n clearCache,\n});\n</script>\n\n<template>\n <div class=\"flex flex-col gap-1\">\n <label class=\"text-sm font-semibold\" :class=\"{ 'text-error': errorMessage, 'text-neutral-darker': !errorMessage }\">\n {{ label }}\n </label>\n <ElDropdown :items=\"items\" :multiple=\"multiple\" :is-open=\"isOpen\" :disabled=\"disabled\" @update:is-open=\"onUpdateIsOpen($event)\">\n <template #anchor>\n <ElInputContainer :color=\"color\" :name=\"name\">\n <template #default>\n <div class=\"flex items-center gap-1 px-2\">\n <div\n v-if=\"multiple\"\n name=\"scrollable-container\"\n class=\"flex items-center gap-1 overflow-x-scroll no-scrollbar cursor-grab active:cursor-grabbing\"\n @wheel=\"onWheelScroll\"\n >\n <ElInputChip\n v-for=\"(item, index) in selectedItems\"\n :id=\"index\"\n :key=\"index\"\n :text=\"item.text || item.label || ''\"\n class=\"border flex-shrink-0 rounded-md px-3 py-2\"\n @click=\"onRemoveItem($event, item)\"\n @keydown.backspace=\"onDeleteKeyPress($event)\"\n />\n </div>\n\n <input\n ref=\"inputField\"\n v-model=\"query\"\n :disabled=\"disabled\"\n type=\"text\"\n class=\"border-none tex-tsm font-normal flex flex-1 focus:outline-none focus:ring-0\"\n :class=\"{ 'cursor-not-allowed': disabled }\"\n :validation=\"validation\"\n :placeholder=\"placeholder\"\n @input=\"onChangeEvent($event)\"\n @keydown.backspace=\"onDeleteKeyPress($event)\"\n @click.prevent=\"onInputClick($event)\"\n @blur.prevent=\"onInputClick($event)\"\n @wheel=\"onWheelScroll($event)\"\n />\n\n <ElSpinner v-if=\"isLoading\" class=\"mx-2\" size=\"normal\" />\n </div>\n </template>\n </ElInputContainer>\n </template>\n </ElDropdown>\n <label v-if=\"errorMessage\" class=\"text-xs font-normal text-error\">{{ errorMessage }}</label>\n </div>\n</template>\n"],"names":["props","__props","emit","__emit","isLoading","ref","isOpen","query","filteredItems","selectedItems","inputField","lastSelectedItem","onMounted","response","debounceDataController","items","computed","mappedItems","_a","item","index","selectedItem","clickedItemIndex","currentItem","_","debounceFunction","useMemoize","value","useDebounceFn","clearCache","resetAllAndFetch","onInputClick","onChangeEvent","target","updateModel","onRemoveItem","_event","result","onDeleteKeyPress","lastItemIndex","_b","onWheelScroll","event","container","onUpdateIsOpen","__expose"],"mappings":"8hDAcA,MAAMA,EAAQC,EAiDRC,EAAOC,EAMPC,EAAY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,EAAc,MAAOP,GAA4B,CACrD,GAAI3B,EAAM,eAAgB,CACxBI,EAAU,MAAQ,GACZ,MAAAS,EAAW,MAAMC,EAAuBa,CAAK,EAC5CrB,EAAA,MAAQ,CAAC,CAACO,EACjBT,EAAU,MAAQ,CAACS,EACLL,EAAA,OAAQK,GAAA,YAAAA,EAAU,OAAQ,CAAA,CAAC,MAErCc,EACFnB,EAAc,MAAQR,EAAM,MAAM,OAAiBqC,GAAA,OAAA,OAAAnB,EAAAmB,EAAO,OAAP,YAAAnB,EAAa,cAAc,SAASS,EAAM,YAAA,GAAc,EAE3GnB,EAAc,MAAQR,EAAM,MAIhCE,EAAK,oBAAqByB,CAAK,CAAA,EAO3BW,EAAoB,GAAqB,SACzC,GAAA,CAAC/B,EAAM,MACT,GAAIE,EAAc,MAAM,OAAS,GAAK,CAACE,EAAiB,MAAO,CACvD,MAAA4B,EAAgB9B,EAAc,MAAM,OAAS,EAClCE,EAAA,MAAQF,EAAc,MAAM8B,CAAa,GAC1DrB,EAAA,SAAS,eAAeqB,EAAc,SAAS,CAAC,IAAhD,MAAArB,EAAmD,OAAM,MAE5CiB,EAAA,EAAGxB,EAAiB,KAAK,EACtCA,EAAiB,MAAQ,QACzB6B,EAAA9B,EAAW,QAAX,MAAA8B,EAAkB,OAEtB,EAOIC,EAAiBC,GAAsB,CAC3C,MAAMC,EAAYD,EAAM,cACxBC,EAAU,YAAcD,EAAM,OAE9BA,EAAM,eAAe,CAAA,EAOjBE,EAAkBF,GAAmB,CACrC1C,EAAM,SACRM,EAAO,MAAQ,GAEfA,EAAO,MAAQoC,CACjB,EAGW,OAAAG,EAAA,CACX,iBAAAf,EACA,WAAAD,CAAA,CACD"}
1
+ {"version":3,"file":"ElInputAutocomplete.vue.esm2.js","sources":["../../../src/forms/ElInputAutocomplete.vue"],"sourcesContent":["<script lang=\"ts\">\nexport type InputAutocompleteItemsDataControl = string;\nexport type ElInputAutocompleteItems = Array<DropdownItem & { label?: string; value?: string }>;\n</script>\n\n<script lang=\"ts\" setup>\nimport { computed, onMounted, PropType, ref } from 'vue';\nimport { TextualValueType, withCommonElInputProps } from './input';\nimport ElDropdown, { DropdownItem } from '@/ElDropdown.vue';\nimport ElInputChip from '@/ElInputChip.vue';\nimport { useDebounceFn, useMemoize } from '@vueuse/core';\nimport ElSpinner from '@/ElSpinner.vue';\nimport ElInputContainer from './ElInputContainer.vue';\n\nconst props = defineProps({\n ...withCommonElInputProps(),\n modelValue: {\n type: [Array, String] as PropType<TextualValueType>,\n required: false,\n default: undefined,\n },\n placeholder: {\n type: String,\n default: '',\n required: false,\n },\n items: {\n type: Array as PropType<ElInputAutocompleteItems>,\n required: false,\n default: () => [],\n },\n selectedItems: {\n type: Array as PropType<ElInputAutocompleteItems>,\n default: () => [],\n },\n labelSelectAll: {\n type: String,\n default: 'Seleziona tutto',\n },\n labelDeselectAll: {\n type: String,\n default: 'Deseleziona tutto',\n },\n focusOnMount: {\n type: Boolean,\n default: false,\n },\n multiple: {\n type: Boolean as PropType<InstanceType<typeof ElDropdown>['multiple']>,\n default: false,\n },\n debounceTime: {\n type: Number,\n default: 300,\n requied: false,\n },\n dataController: {\n type: Function as PropType<(args: TextualValueType) => Promise<{ data: ElInputAutocompleteItems }>>,\n required: false,\n default: undefined,\n },\n});\n\nconst emit = defineEmits<{\n (event: 'update:modelValue', value: TextualValueType): void;\n (event: 'item:click', itemIndex: number): void;\n (event: 'update:selectedItems', value: ElInputAutocompleteItems): void;\n}>();\n\nconst isLoading = ref(false);\nconst isOpen = ref(false);\nconst query = ref<TextualValueType>(props.modelValue);\nconst filteredItems = ref<ElInputAutocompleteItems>([]);\nconst selectedItems = ref<ElInputAutocompleteItems>(props.selectedItems);\nconst inputField = ref<HTMLInputElement>();\nconst lastSelectedItem = ref();\n\nonMounted(async () => {\n if (props.dataController) {\n const response = await debounceDataController(query.value);\n filteredItems.value = response?.data || [];\n } else {\n filteredItems.value = props.items;\n }\n});\n\nconst items = computed(() => {\n const mappedItems = filteredItems.value?.map((item, index) => ({\n ...item,\n text: item.label || item.text,\n check: selectedItems.value.some(selectedItem =>\n selectedItem.text ? selectedItem.text === item.text : selectedItem.label === item.label,\n ),\n onClick: () => {\n if (props.multiple) {\n // If the item is already selected, remove it from the selectedItems array\n const clickedItemIndex = selectedItems.value.findIndex(currentItem =>\n currentItem.text ? currentItem.text === item.text : currentItem.label === item.label,\n );\n\n if (clickedItemIndex !== -1) {\n selectedItems.value = selectedItems.value.filter((_, index) => index !== clickedItemIndex);\n } else {\n selectedItems.value.push({ ...item, check: true });\n }\n\n // Reset query to empty string to clear the input\n query.value = '';\n // Reset last selected item because the selectedItems array is updated\n lastSelectedItem.value = undefined;\n inputField.value?.focus();\n\n emit('update:selectedItems', selectedItems.value);\n } else {\n query.value = item.text || item.label || item.value || '';\n }\n\n emit('update:modelValue', item.text || item.label || item.value || '');\n emit('item:click', index);\n },\n }));\n\n if (props.multiple) {\n mappedItems.unshift({\n text: selectedItems.value.length === filteredItems.value.length ? props.labelDeselectAll : props.labelSelectAll,\n check: false,\n onClick: () => {\n if (selectedItems.value.length === filteredItems.value.length) {\n selectedItems.value = [];\n } else {\n selectedItems.value = filteredItems.value;\n }\n\n inputField.value?.focus();\n emit('update:selectedItems', selectedItems.value);\n },\n });\n }\n\n return mappedItems;\n});\n\nconst debounceFunction = useMemoize(async (value: TextualValueType) => {\n return await props.dataController?.(value);\n});\n\nconst debounceDataController = useDebounceFn(debounceFunction, props.debounceTime);\nconst clearCache = () => debounceFunction.cache.clear();\n\nconst resetAllAndFetch = async () => {\n query.value = undefined;\n filteredItems.value = props.items;\n selectedItems.value = props.selectedItems;\n const response = await props.dataController?.(query.value);\n filteredItems.value = response?.data || [];\n};\n\n/**\n * Handle input click event necessary to open or close dropdown\n * @param e FocusEvent\n */\nconst onInputClick = (e: FocusEvent) => {\n if ((e.relatedTarget as HTMLElement)?.role !== 'option') {\n if (!isOpen.value) {\n isOpen.value = true;\n } else {\n isOpen.value = false;\n }\n }\n};\n\n/**\n * Handle input change event to update model value\n * @param event Event\n */\nconst onChangeEvent = ({ target }: Event) => {\n if (target instanceof HTMLInputElement) {\n if (target.value.charAt(target.value.length - 1) !== ' ') {\n updateModel(target.value);\n }\n }\n};\n\n/**\n * Handle remove item from selected items by clicking on the item\n * @param _event Event\n * @param item DropdownItem\n */\nconst onRemoveItem = (_event: Event, item: DropdownItem) => {\n selectedItems.value = selectedItems.value.filter(currentItem => currentItem.text !== item.text);\n emit('update:selectedItems', selectedItems.value);\n};\n\nconst updateModel = async (value: TextualValueType) => {\n if (props.dataController) {\n isLoading.value = true;\n const response = await debounceDataController(value);\n isOpen.value = !!response;\n isLoading.value = !response;\n filteredItems.value = response?.data || [];\n } else {\n if (value) {\n filteredItems.value = props.items.filter(result => result.text?.toLowerCase().includes(value.toLowerCase()));\n } else {\n filteredItems.value = props.items;\n }\n }\n\n emit('update:modelValue', value);\n};\n\n/**\n Handle backspace key press to remove last selected item when multiple is true\n param e KeyboardEvent\n */\nconst onDeleteKeyPress = (e: KeyboardEvent) => {\n if (!query.value) {\n if (selectedItems.value.length > 0 && !lastSelectedItem.value) {\n const lastItemIndex = selectedItems.value.length - 1;\n lastSelectedItem.value = selectedItems.value[lastItemIndex];\n document.getElementById(lastItemIndex.toString())?.focus();\n } else {\n onRemoveItem(e, lastSelectedItem.value);\n lastSelectedItem.value = undefined;\n inputField.value?.focus();\n }\n }\n};\n\n/**\n Handle wheel scroll event to scroll the listbox horizontally\n param event WheelEvent\n */\nconst onWheelScroll = (event: WheelEvent) => {\n const container = event.currentTarget as HTMLElement;\n container.scrollLeft += event.deltaY;\n // Prevent vertical scrolling of the page\n event.preventDefault();\n};\n\n/**\n Handle update isOpen event to open the dropdown when multiple is true\n param event boolean\n */\nconst onUpdateIsOpen = (event: boolean) => {\n if (props.multiple) {\n isOpen.value = true;\n } else {\n isOpen.value = event;\n }\n};\n\ndefineExpose({\n resetAllAndFetch,\n clearCache,\n});\n</script>\n\n<template>\n <div class=\"flex flex-col gap-1\">\n <label class=\"text-sm font-semibold\" :class=\"{ 'text-error': errorMessage, 'text-neutral-darker': !errorMessage }\">\n {{ label }}\n </label>\n <ElDropdown :items=\"items\" :multiple=\"multiple\" :is-open=\"isOpen\" :disabled=\"disabled\" @update:is-open=\"onUpdateIsOpen($event)\">\n <template #anchor>\n <ElInputContainer :color=\"color\" :name=\"name\">\n <template #default>\n <div class=\"flex items-center gap-1 px-2\">\n <div\n v-if=\"multiple\"\n name=\"scrollable-container\"\n class=\"flex items-center gap-1 overflow-x-scroll no-scrollbar cursor-grab active:cursor-grabbing\"\n @wheel=\"onWheelScroll\"\n >\n <ElInputChip\n v-for=\"(item, index) in selectedItems\"\n :id=\"index\"\n :key=\"index\"\n :text=\"item.text || item.label || ''\"\n class=\"border flex-shrink-0 rounded-md px-3 py-2\"\n @click=\"onRemoveItem($event, item)\"\n @keydown.backspace=\"onDeleteKeyPress($event)\"\n />\n </div>\n\n <input\n ref=\"inputField\"\n v-model=\"query\"\n :disabled=\"disabled\"\n type=\"text\"\n class=\"border-none tex-tsm font-normal flex flex-1 focus:outline-none focus:ring-0\"\n :class=\"{ 'cursor-not-allowed': disabled }\"\n :validation=\"validation\"\n :placeholder=\"placeholder\"\n @input=\"onChangeEvent($event)\"\n @keydown.backspace=\"onDeleteKeyPress($event)\"\n @click.prevent=\"onInputClick($event)\"\n @blur.prevent=\"onInputClick($event)\"\n @wheel=\"onWheelScroll($event)\"\n />\n\n <ElSpinner v-if=\"isLoading\" class=\"mx-2\" size=\"normal\" />\n </div>\n </template>\n </ElInputContainer>\n </template>\n </ElDropdown>\n <div v-if=\"errorMessage\" class=\"text-xs font-normal text-error\">{{ errorMessage }}</div>\n </div>\n</template>\n"],"names":["props","__props","emit","__emit","isLoading","ref","isOpen","query","filteredItems","selectedItems","inputField","lastSelectedItem","onMounted","response","debounceDataController","items","computed","mappedItems","_a","item","index","selectedItem","clickedItemIndex","currentItem","_","debounceFunction","useMemoize","value","useDebounceFn","clearCache","resetAllAndFetch","onInputClick","onChangeEvent","target","updateModel","onRemoveItem","_event","result","onDeleteKeyPress","lastItemIndex","_b","onWheelScroll","event","container","onUpdateIsOpen","__expose"],"mappings":"8hDAcA,MAAMA,EAAQC,EAiDRC,EAAOC,EAMPC,EAAYC,EAAI,EAAK,EACrBC,EAASD,EAAI,EAAK,EAClBE,EAAQF,EAAsBL,EAAM,UAAU,EAC9CQ,EAAgBH,EAA8B,CAAA,CAAE,EAChDI,EAAgBJ,EAA8BL,EAAM,aAAa,EACjEU,EAAaL,IACbM,EAAmBN,IAEzBO,EAAU,SAAY,CACpB,GAAIZ,EAAM,eAAgB,CACxB,MAAMa,EAAW,MAAMC,EAAuBP,EAAM,KAAK,EAC3CC,EAAA,OAAQK,GAAA,YAAAA,EAAU,OAAQ,CAAA,CAAC,MAEzCL,EAAc,MAAQR,EAAM,KAC9B,CACD,EAEK,MAAAe,EAAQC,EAAS,IAAM,OAC3B,MAAMC,GAAcC,EAAAV,EAAc,QAAd,YAAAU,EAAqB,IAAI,CAACC,EAAMC,KAAW,CAC7D,GAAGD,EACH,KAAMA,EAAK,OAASA,EAAK,KACzB,MAAOV,EAAc,MAAM,KAAKY,GAC9BA,EAAa,KAAOA,EAAa,OAASF,EAAK,KAAOE,EAAa,QAAUF,EAAK,KACpF,EACA,QAAS,IAAM,OACb,GAAInB,EAAM,SAAU,CAEZ,MAAAsB,EAAmBb,EAAc,MAAM,UAAUc,GACrDA,EAAY,KAAOA,EAAY,OAASJ,EAAK,KAAOI,EAAY,QAAUJ,EAAK,KAAA,EAG7EG,IAAqB,GACTb,EAAA,MAAQA,EAAc,MAAM,OAAO,CAACe,EAAGJ,IAAUA,IAAUE,CAAgB,EAEzFb,EAAc,MAAM,KAAK,CAAE,GAAGU,EAAM,MAAO,GAAM,EAInDZ,EAAM,MAAQ,GAEdI,EAAiB,MAAQ,QACzBO,EAAAR,EAAW,QAAX,MAAAQ,EAAkB,QAEbhB,EAAA,uBAAwBO,EAAc,KAAK,CAAA,MAEhDF,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strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("vue"),o=["for"],l={key:0,class:"ml-0 text-sm font-light"},a={key:0,class:"text-neutral-lighter group-focus-within:text-error group-active-within:text-error mt-1 text-sm"},s=["primary","secondary","error"],i=r.defineComponent({__name:"ElInputContainer",props:{modelValue:{default:""},name:{},label:{default:""},errorMessage:{type:[String,Boolean],default:!1},hiddenErrorMessage:{type:Boolean},setRequiredMark:{type:Boolean},color:{default:"primary"},noBorder:{type:Boolean,default:!1}},setup(n){return(e,t)=>(r.openBlock(),r.createElementBlock("div",r.mergeProps(e.$attrs,{class:["el-input-container group border-0 p-1 flex flex-col gap-1",{error:!!e.errorMessage}]}),[r.createElementVNode("div",{class:r.normalizeClass(["flex align-middle text-base",{"text-neutral-darker":!e.errorMessage,"text-error":!!e.errorMessage}])},[r.createElementVNode("label",{for:e.name,class:"block text-base font-medium"},r.toDisplayString(e.label),9,o),e.label&&e.setRequiredMark?(r.openBlock(),r.createElementBlock("span",l,"*")):r.createCommentVNode("",!0)],2),r.createElementVNode("div",r.mergeProps(e.$attrs,{class:["el-input-container group rounded overflow-hidden text-neutral-darker focus-within:ring focus-within:ring-opacity-50",{error:!!e.errorMessage,"border border-neutral-inactive":!e.noBorder,"focus-within:border-primary-pressed focus-within:ring-outlined-primary":e.color==="primary"&&!e.modelValue,"focus-within:border-primary-active focus-within:ring-outlined-primary ":e.color==="primary"&&e.modelValue,"focus-within:border-secondary-pressed focus-within:ring-outlined-secondary ":e.color==="secondary","focus-within:border-secondary-active focus-within:ring-outlined-secondary ":e.color==="secondary","focus-within:border-error focus-within:ring-outlined-error":e.color==="error"}]}),[r.createElementVNode("div",{class:r.normalizeClass(["relative",{"gap-1":e.label.length>0}])},[r.createElementVNode("div",{class:r.normalizeClass({"fill-neutral-inactive":!e.modelValue,"focus-within:fill-primary-pressed":e.color==="primary"&&!e.modelValue,"focus-within:fill-primary-active":e.color==="primary"&&e.modelValue,"focus-within:fill-secondary-pressed":e.color==="secondary"&&!e.modelValue,"focus-within:fill-secondary-active":e.color==="secondary"&&e.modelValue,"fill-error":e.color==="error","fill-neutral-darker":e.modelValue})},[r.renderSlot(e.$slots,"leading",r.normalizeProps(r.guardReactiveProps({error:!!e.errorMessage})))],2),r.renderSlot(e.$slots,"default",r.normalizeProps(r.guardReactiveProps({error:!!e.errorMessage}))),r.createElementVNode("div",{class:r.normalizeClass(["pointer-events-auto absolute inset-y-0 right-2 z-20 flex cursor-pointer items-center",{"text-error":!!e.errorMessage}])},[r.renderSlot(e.$slots,"trailing",r.normalizeProps(r.guardReactiveProps({error:!!e.errorMessage})))],2)],2),r.renderSlot(e.$slots,"after"),e.errorMessage&&!e.errorMessage&&!e.hiddenErrorMessage?(r.openBlock(),r.createElementBlock("p",a,r.toDisplayString(e.errorMessage),1)):r.createCommentVNode("",!0)],16)],16))}});exports.default=i;exports.elInputContainerColor=s;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("vue"),o=["for"],l={key:0,class:"ml-0 text-sm font-light"},a={key:0,class:"text-neutral-lighter group-focus-within:text-error group-active-within:text-error mt-1 text-sm"},s=["primary","secondary","error"],i=r.defineComponent({__name:"ElInputContainer",props:{modelValue:{default:""},name:{},label:{default:""},errorMessage:{type:[String,Boolean],default:!1},hiddenErrorMessage:{type:Boolean},setRequiredMark:{type:Boolean},color:{default:"primary"},noBorder:{type:Boolean,default:!1}},setup(n){return(e,t)=>(r.openBlock(),r.createElementBlock("div",r.mergeProps(e.$attrs,{class:["el-input-container group border-0 p-1 flex flex-col gap-1",{error:!!e.errorMessage}]}),[r.createElementVNode("div",{class:r.normalizeClass(["flex align-middle text-base",{"text-neutral-darker":!e.errorMessage,"text-error":!!e.errorMessage}])},[r.createElementVNode("label",{for:e.name,class:"block text-base font-medium"},r.toDisplayString(e.label),9,o),e.label&&e.setRequiredMark?(r.openBlock(),r.createElementBlock("span",l,"*")):r.createCommentVNode("",!0)],2),r.createElementVNode("div",r.mergeProps(e.$attrs,{class:["el-input-container group rounded overflow-hidden text-neutral-darker focus-within:ring focus-within:ring-opacity-50",{error:!!e.errorMessage,"border border-neutral-inactive":!e.noBorder,"focus-within:border-primary-pressed focus-within:ring-outlined-primary":e.color==="primary"&&!e.modelValue,"focus-within:border-primary-active focus-within:ring-outlined-primary ":e.color==="primary"&&e.modelValue,"focus-within:border-secondary-pressed focus-within:ring-outlined-secondary ":e.color==="secondary","focus-within:border-secondary-active focus-within:ring-outlined-secondary ":e.color==="secondary","focus-within:border-error focus-within:ring-outlined-error":e.color==="error"}]}),[r.createElementVNode("div",{class:r.normalizeClass(["relative",{"gap-1":e.label.length>0}])},[r.createElementVNode("div",{class:r.normalizeClass({"fill-neutral-inactive":!e.modelValue,"focus-within:fill-primary-pressed":e.color==="primary"&&!e.modelValue,"focus-within:fill-primary-active":e.color==="primary"&&e.modelValue,"focus-within:fill-secondary-pressed":e.color==="secondary"&&!e.modelValue,"focus-within:fill-secondary-active":e.color==="secondary"&&e.modelValue,"fill-error":e.color==="error","fill-neutral-darker":e.modelValue})},[r.renderSlot(e.$slots,"leading",r.normalizeProps(r.guardReactiveProps({error:!!e.errorMessage})))],2),r.renderSlot(e.$slots,"default",r.normalizeProps(r.guardReactiveProps({error:!!e.errorMessage}))),r.createElementVNode("div",{class:r.normalizeClass(["pointer-events-auto absolute inset-y-0 right-2 z-20 flex cursor-pointer items-center",{"text-error":!!e.errorMessage}])},[r.renderSlot(e.$slots,"trailing",r.normalizeProps(r.guardReactiveProps({error:!!e.errorMessage})))],2)],2),r.renderSlot(e.$slots,"after")],16),e.errorMessage&&e.errorMessage!==!0&&!e.hiddenErrorMessage?(r.openBlock(),r.createElementBlock("div",a,r.toDisplayString(e.errorMessage),1)):r.createCommentVNode("",!0)],16))}});exports.default=i;exports.elInputContainerColor=s;
2
2
  //# sourceMappingURL=ElInputContainer.vue.cjs2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ElInputContainer.vue.cjs2.js","sources":["../../../src/forms/ElInputContainer.vue"],"sourcesContent":["<script lang=\"ts\">\nexport const elInputContainerColor = ['primary', 'secondary', 'error'] as const;\nexport type ElInputContainerColor = (typeof elInputContainerColor)[number];\n</script>\n\n<script lang=\"ts\" setup>\nimport { NumberValueType, TextualValueType } from './input';\n\nwithDefaults(\n defineProps<{\n modelValue?: TextualValueType | NumberValueType;\n name: string;\n label?: string;\n errorMessage?: string | boolean;\n hiddenErrorMessage?: boolean;\n setRequiredMark?: boolean;\n color?: ElInputContainerColor;\n noBorder?: boolean;\n }>(),\n {\n modelValue: '',\n color: 'primary',\n label: '',\n errorMessage: false,\n noBorder: false,\n },\n);\n</script>\n\n<template>\n <div\n v-bind=\"$attrs\"\n class=\"el-input-container group border-0 p-1 flex flex-col gap-1\"\n :class=\"{\n error: !!errorMessage,\n }\"\n >\n <div class=\"flex align-middle text-base\" :class=\"{ 'text-neutral-darker': !errorMessage, 'text-error': !!errorMessage }\">\n <label :for=\"name\" class=\"block text-base font-medium\">{{ label }}</label>\n <span v-if=\"label && setRequiredMark\" class=\"ml-0 text-sm font-light\">*</span>\n </div>\n <div\n v-bind=\"$attrs\"\n class=\"el-input-container group rounded overflow-hidden text-neutral-darker focus-within:ring focus-within:ring-opacity-50\"\n :class=\"{\n error: !!errorMessage,\n 'border border-neutral-inactive': !noBorder,\n 'focus-within:border-primary-pressed focus-within:ring-outlined-primary': color === 'primary' && !modelValue,\n 'focus-within:border-primary-active focus-within:ring-outlined-primary ': color === 'primary' && modelValue,\n\n 'focus-within:border-secondary-pressed focus-within:ring-outlined-secondary ': color === 'secondary',\n 'focus-within:border-secondary-active focus-within:ring-outlined-secondary ': color === 'secondary',\n\n 'focus-within:border-error focus-within:ring-outlined-error': color === 'error',\n }\"\n >\n <div\n class=\"relative\"\n :class=\"{\n 'gap-1': label.length > 0,\n }\"\n >\n <div\n :class=\"{\n 'fill-neutral-inactive': !modelValue,\n\n 'focus-within:fill-primary-pressed': color === 'primary' && !modelValue,\n 'focus-within:fill-primary-active': color === 'primary' && modelValue,\n\n 'focus-within:fill-secondary-pressed': color === 'secondary' && !modelValue,\n 'focus-within:fill-secondary-active': color === 'secondary' && modelValue,\n\n 'fill-error': color === 'error',\n 'fill-neutral-darker': modelValue,\n }\"\n >\n <slot name=\"leading\" v-bind=\"{ error: !!errorMessage }\" />\n </div>\n <slot v-bind=\"{ error: !!errorMessage }\" />\n <div\n class=\"pointer-events-auto absolute inset-y-0 right-2 z-20 flex cursor-pointer items-center\"\n :class=\"{ 'text-error': !!errorMessage }\"\n >\n <slot name=\"trailing\" v-bind=\"{ error: !!errorMessage }\"> </slot>\n </div>\n </div>\n <slot name=\"after\" />\n <p\n v-if=\"!!errorMessage && !errorMessage && !hiddenErrorMessage\"\n class=\"text-neutral-lighter group-focus-within:text-error group-active-within:text-error mt-1 text-sm\"\n >\n {{ errorMessage }}\n </p>\n </div>\n </div>\n</template>\n"],"names":["elInputContainerColor"],"mappings":"wSACaA,EAAwB,CAAC,UAAW,YAAa,OAAO"}
1
+ {"version":3,"file":"ElInputContainer.vue.cjs2.js","sources":["../../../src/forms/ElInputContainer.vue"],"sourcesContent":["<script lang=\"ts\">\nexport const elInputContainerColor = ['primary', 'secondary', 'error'] as const;\nexport type ElInputContainerColor = (typeof elInputContainerColor)[number];\n</script>\n\n<script lang=\"ts\" setup>\nimport { NumberValueType, TextualValueType } from './input';\n\nwithDefaults(\n defineProps<{\n modelValue?: TextualValueType | NumberValueType;\n name: string;\n label?: string;\n errorMessage?: string | boolean;\n hiddenErrorMessage?: boolean;\n setRequiredMark?: boolean;\n color?: ElInputContainerColor;\n noBorder?: boolean;\n }>(),\n {\n modelValue: '',\n color: 'primary',\n label: '',\n errorMessage: false,\n noBorder: false,\n },\n);\n</script>\n\n<template>\n <div\n v-bind=\"$attrs\"\n class=\"el-input-container group border-0 p-1 flex flex-col gap-1\"\n :class=\"{\n error: !!errorMessage,\n }\"\n >\n <div class=\"flex align-middle text-base\" :class=\"{ 'text-neutral-darker': !errorMessage, 'text-error': !!errorMessage }\">\n <label :for=\"name\" class=\"block text-base font-medium\">{{ label }}</label>\n <span v-if=\"label && setRequiredMark\" class=\"ml-0 text-sm font-light\">*</span>\n </div>\n <div\n v-bind=\"$attrs\"\n class=\"el-input-container group rounded overflow-hidden text-neutral-darker focus-within:ring focus-within:ring-opacity-50\"\n :class=\"{\n error: !!errorMessage,\n 'border border-neutral-inactive': !noBorder,\n 'focus-within:border-primary-pressed focus-within:ring-outlined-primary': color === 'primary' && !modelValue,\n 'focus-within:border-primary-active focus-within:ring-outlined-primary ': color === 'primary' && modelValue,\n\n 'focus-within:border-secondary-pressed focus-within:ring-outlined-secondary ': color === 'secondary',\n 'focus-within:border-secondary-active focus-within:ring-outlined-secondary ': color === 'secondary',\n\n 'focus-within:border-error focus-within:ring-outlined-error': color === 'error',\n }\"\n >\n <div\n class=\"relative\"\n :class=\"{\n 'gap-1': label.length > 0,\n }\"\n >\n <div\n :class=\"{\n 'fill-neutral-inactive': !modelValue,\n\n 'focus-within:fill-primary-pressed': color === 'primary' && !modelValue,\n 'focus-within:fill-primary-active': color === 'primary' && modelValue,\n\n 'focus-within:fill-secondary-pressed': color === 'secondary' && !modelValue,\n 'focus-within:fill-secondary-active': color === 'secondary' && modelValue,\n\n 'fill-error': color === 'error',\n 'fill-neutral-darker': modelValue,\n }\"\n >\n <slot name=\"leading\" v-bind=\"{ error: !!errorMessage }\" />\n </div>\n <slot v-bind=\"{ error: !!errorMessage }\" />\n <div\n class=\"pointer-events-auto absolute inset-y-0 right-2 z-20 flex cursor-pointer items-center\"\n :class=\"{ 'text-error': !!errorMessage }\"\n >\n <slot name=\"trailing\" v-bind=\"{ error: !!errorMessage }\"> </slot>\n </div>\n </div>\n <slot name=\"after\" />\n </div>\n <div\n v-if=\"!!errorMessage && errorMessage !== true && !hiddenErrorMessage\"\n class=\"text-neutral-lighter group-focus-within:text-error group-active-within:text-error mt-1 text-sm\"\n >\n {{ errorMessage }}\n </div>\n </div>\n</template>\n"],"names":["elInputContainerColor"],"mappings":"wSACaA,EAAwB,CAAC,UAAW,YAAa,OAAO"}
@@ -1,2 +1,2 @@
1
- import{defineComponent as p,openBlock as s,createElementBlock as l,mergeProps as t,createElementVNode as r,normalizeClass as o,toDisplayString as d,createCommentVNode as u,renderSlot as a,normalizeProps as i,guardReactiveProps as n}from"vue";const f=["for"],m={key:0,class:"ml-0 text-sm font-light"},g={key:0,class:"text-neutral-lighter group-focus-within:text-error group-active-within:text-error mt-1 text-sm"},w=["primary","secondary","error"],b=p({__name:"ElInputContainer",props:{modelValue:{default:""},name:{},label:{default:""},errorMessage:{type:[String,Boolean],default:!1},hiddenErrorMessage:{type:Boolean},setRequiredMark:{type:Boolean},color:{default:"primary"},noBorder:{type:Boolean,default:!1}},setup(c){return(e,y)=>(s(),l("div",t(e.$attrs,{class:["el-input-container group border-0 p-1 flex flex-col gap-1",{error:!!e.errorMessage}]}),[r("div",{class:o(["flex align-middle text-base",{"text-neutral-darker":!e.errorMessage,"text-error":!!e.errorMessage}])},[r("label",{for:e.name,class:"block text-base font-medium"},d(e.label),9,f),e.label&&e.setRequiredMark?(s(),l("span",m,"*")):u("",!0)],2),r("div",t(e.$attrs,{class:["el-input-container group rounded overflow-hidden text-neutral-darker focus-within:ring focus-within:ring-opacity-50",{error:!!e.errorMessage,"border border-neutral-inactive":!e.noBorder,"focus-within:border-primary-pressed focus-within:ring-outlined-primary":e.color==="primary"&&!e.modelValue,"focus-within:border-primary-active focus-within:ring-outlined-primary ":e.color==="primary"&&e.modelValue,"focus-within:border-secondary-pressed focus-within:ring-outlined-secondary ":e.color==="secondary","focus-within:border-secondary-active focus-within:ring-outlined-secondary ":e.color==="secondary","focus-within:border-error focus-within:ring-outlined-error":e.color==="error"}]}),[r("div",{class:o(["relative",{"gap-1":e.label.length>0}])},[r("div",{class:o({"fill-neutral-inactive":!e.modelValue,"focus-within:fill-primary-pressed":e.color==="primary"&&!e.modelValue,"focus-within:fill-primary-active":e.color==="primary"&&e.modelValue,"focus-within:fill-secondary-pressed":e.color==="secondary"&&!e.modelValue,"focus-within:fill-secondary-active":e.color==="secondary"&&e.modelValue,"fill-error":e.color==="error","fill-neutral-darker":e.modelValue})},[a(e.$slots,"leading",i(n({error:!!e.errorMessage})))],2),a(e.$slots,"default",i(n({error:!!e.errorMessage}))),r("div",{class:o(["pointer-events-auto absolute inset-y-0 right-2 z-20 flex cursor-pointer items-center",{"text-error":!!e.errorMessage}])},[a(e.$slots,"trailing",i(n({error:!!e.errorMessage})))],2)],2),a(e.$slots,"after"),e.errorMessage&&!e.errorMessage&&!e.hiddenErrorMessage?(s(),l("p",g,d(e.errorMessage),1)):u("",!0)],16)],16))}});export{b as default,w as elInputContainerColor};
1
+ import{defineComponent as p,openBlock as s,createElementBlock as i,mergeProps as t,createElementVNode as r,normalizeClass as o,toDisplayString as d,createCommentVNode as u,renderSlot as a,normalizeProps as l,guardReactiveProps as n}from"vue";const f=["for"],m={key:0,class:"ml-0 text-sm font-light"},g={key:0,class:"text-neutral-lighter group-focus-within:text-error group-active-within:text-error mt-1 text-sm"},w=["primary","secondary","error"],v=p({__name:"ElInputContainer",props:{modelValue:{default:""},name:{},label:{default:""},errorMessage:{type:[String,Boolean],default:!1},hiddenErrorMessage:{type:Boolean},setRequiredMark:{type:Boolean},color:{default:"primary"},noBorder:{type:Boolean,default:!1}},setup(c){return(e,y)=>(s(),i("div",t(e.$attrs,{class:["el-input-container group border-0 p-1 flex flex-col gap-1",{error:!!e.errorMessage}]}),[r("div",{class:o(["flex align-middle text-base",{"text-neutral-darker":!e.errorMessage,"text-error":!!e.errorMessage}])},[r("label",{for:e.name,class:"block text-base font-medium"},d(e.label),9,f),e.label&&e.setRequiredMark?(s(),i("span",m,"*")):u("",!0)],2),r("div",t(e.$attrs,{class:["el-input-container group rounded overflow-hidden text-neutral-darker focus-within:ring focus-within:ring-opacity-50",{error:!!e.errorMessage,"border border-neutral-inactive":!e.noBorder,"focus-within:border-primary-pressed focus-within:ring-outlined-primary":e.color==="primary"&&!e.modelValue,"focus-within:border-primary-active focus-within:ring-outlined-primary ":e.color==="primary"&&e.modelValue,"focus-within:border-secondary-pressed focus-within:ring-outlined-secondary ":e.color==="secondary","focus-within:border-secondary-active focus-within:ring-outlined-secondary ":e.color==="secondary","focus-within:border-error focus-within:ring-outlined-error":e.color==="error"}]}),[r("div",{class:o(["relative",{"gap-1":e.label.length>0}])},[r("div",{class:o({"fill-neutral-inactive":!e.modelValue,"focus-within:fill-primary-pressed":e.color==="primary"&&!e.modelValue,"focus-within:fill-primary-active":e.color==="primary"&&e.modelValue,"focus-within:fill-secondary-pressed":e.color==="secondary"&&!e.modelValue,"focus-within:fill-secondary-active":e.color==="secondary"&&e.modelValue,"fill-error":e.color==="error","fill-neutral-darker":e.modelValue})},[a(e.$slots,"leading",l(n({error:!!e.errorMessage})))],2),a(e.$slots,"default",l(n({error:!!e.errorMessage}))),r("div",{class:o(["pointer-events-auto absolute inset-y-0 right-2 z-20 flex cursor-pointer items-center",{"text-error":!!e.errorMessage}])},[a(e.$slots,"trailing",l(n({error:!!e.errorMessage})))],2)],2),a(e.$slots,"after")],16),e.errorMessage&&e.errorMessage!==!0&&!e.hiddenErrorMessage?(s(),i("div",g,d(e.errorMessage),1)):u("",!0)],16))}});export{v as default,w as elInputContainerColor};
2
2
  //# sourceMappingURL=ElInputContainer.vue.esm2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ElInputContainer.vue.esm2.js","sources":["../../../src/forms/ElInputContainer.vue"],"sourcesContent":["<script lang=\"ts\">\nexport const elInputContainerColor = ['primary', 'secondary', 'error'] as const;\nexport type ElInputContainerColor = (typeof elInputContainerColor)[number];\n</script>\n\n<script lang=\"ts\" setup>\nimport { NumberValueType, TextualValueType } from './input';\n\nwithDefaults(\n defineProps<{\n modelValue?: TextualValueType | NumberValueType;\n name: string;\n label?: string;\n errorMessage?: string | boolean;\n hiddenErrorMessage?: boolean;\n setRequiredMark?: boolean;\n color?: ElInputContainerColor;\n noBorder?: boolean;\n }>(),\n {\n modelValue: '',\n color: 'primary',\n label: '',\n errorMessage: false,\n noBorder: false,\n },\n);\n</script>\n\n<template>\n <div\n v-bind=\"$attrs\"\n class=\"el-input-container group border-0 p-1 flex flex-col gap-1\"\n :class=\"{\n error: !!errorMessage,\n }\"\n >\n <div class=\"flex align-middle text-base\" :class=\"{ 'text-neutral-darker': !errorMessage, 'text-error': !!errorMessage }\">\n <label :for=\"name\" class=\"block text-base font-medium\">{{ label }}</label>\n <span v-if=\"label && setRequiredMark\" class=\"ml-0 text-sm font-light\">*</span>\n </div>\n <div\n v-bind=\"$attrs\"\n class=\"el-input-container group rounded overflow-hidden text-neutral-darker focus-within:ring focus-within:ring-opacity-50\"\n :class=\"{\n error: !!errorMessage,\n 'border border-neutral-inactive': !noBorder,\n 'focus-within:border-primary-pressed focus-within:ring-outlined-primary': color === 'primary' && !modelValue,\n 'focus-within:border-primary-active focus-within:ring-outlined-primary ': color === 'primary' && modelValue,\n\n 'focus-within:border-secondary-pressed focus-within:ring-outlined-secondary ': color === 'secondary',\n 'focus-within:border-secondary-active focus-within:ring-outlined-secondary ': color === 'secondary',\n\n 'focus-within:border-error focus-within:ring-outlined-error': color === 'error',\n }\"\n >\n <div\n class=\"relative\"\n :class=\"{\n 'gap-1': label.length > 0,\n }\"\n >\n <div\n :class=\"{\n 'fill-neutral-inactive': !modelValue,\n\n 'focus-within:fill-primary-pressed': color === 'primary' && !modelValue,\n 'focus-within:fill-primary-active': color === 'primary' && modelValue,\n\n 'focus-within:fill-secondary-pressed': color === 'secondary' && !modelValue,\n 'focus-within:fill-secondary-active': color === 'secondary' && modelValue,\n\n 'fill-error': color === 'error',\n 'fill-neutral-darker': modelValue,\n }\"\n >\n <slot name=\"leading\" v-bind=\"{ error: !!errorMessage }\" />\n </div>\n <slot v-bind=\"{ error: !!errorMessage }\" />\n <div\n class=\"pointer-events-auto absolute inset-y-0 right-2 z-20 flex cursor-pointer items-center\"\n :class=\"{ 'text-error': !!errorMessage }\"\n >\n <slot name=\"trailing\" v-bind=\"{ error: !!errorMessage }\"> </slot>\n </div>\n </div>\n <slot name=\"after\" />\n <p\n v-if=\"!!errorMessage && !errorMessage && !hiddenErrorMessage\"\n class=\"text-neutral-lighter group-focus-within:text-error group-active-within:text-error mt-1 text-sm\"\n >\n {{ errorMessage }}\n </p>\n </div>\n </div>\n</template>\n"],"names":["elInputContainerColor"],"mappings":"6ZACaA,EAAwB,CAAC,UAAW,YAAa,OAAO"}
1
+ {"version":3,"file":"ElInputContainer.vue.esm2.js","sources":["../../../src/forms/ElInputContainer.vue"],"sourcesContent":["<script lang=\"ts\">\nexport const elInputContainerColor = ['primary', 'secondary', 'error'] as const;\nexport type ElInputContainerColor = (typeof elInputContainerColor)[number];\n</script>\n\n<script lang=\"ts\" setup>\nimport { NumberValueType, TextualValueType } from './input';\n\nwithDefaults(\n defineProps<{\n modelValue?: TextualValueType | NumberValueType;\n name: string;\n label?: string;\n errorMessage?: string | boolean;\n hiddenErrorMessage?: boolean;\n setRequiredMark?: boolean;\n color?: ElInputContainerColor;\n noBorder?: boolean;\n }>(),\n {\n modelValue: '',\n color: 'primary',\n label: '',\n errorMessage: false,\n noBorder: false,\n },\n);\n</script>\n\n<template>\n <div\n v-bind=\"$attrs\"\n class=\"el-input-container group border-0 p-1 flex flex-col gap-1\"\n :class=\"{\n error: !!errorMessage,\n }\"\n >\n <div class=\"flex align-middle text-base\" :class=\"{ 'text-neutral-darker': !errorMessage, 'text-error': !!errorMessage }\">\n <label :for=\"name\" class=\"block text-base font-medium\">{{ label }}</label>\n <span v-if=\"label && setRequiredMark\" class=\"ml-0 text-sm font-light\">*</span>\n </div>\n <div\n v-bind=\"$attrs\"\n class=\"el-input-container group rounded overflow-hidden text-neutral-darker focus-within:ring focus-within:ring-opacity-50\"\n :class=\"{\n error: !!errorMessage,\n 'border border-neutral-inactive': !noBorder,\n 'focus-within:border-primary-pressed focus-within:ring-outlined-primary': color === 'primary' && !modelValue,\n 'focus-within:border-primary-active focus-within:ring-outlined-primary ': color === 'primary' && modelValue,\n\n 'focus-within:border-secondary-pressed focus-within:ring-outlined-secondary ': color === 'secondary',\n 'focus-within:border-secondary-active focus-within:ring-outlined-secondary ': color === 'secondary',\n\n 'focus-within:border-error focus-within:ring-outlined-error': color === 'error',\n }\"\n >\n <div\n class=\"relative\"\n :class=\"{\n 'gap-1': label.length > 0,\n }\"\n >\n <div\n :class=\"{\n 'fill-neutral-inactive': !modelValue,\n\n 'focus-within:fill-primary-pressed': color === 'primary' && !modelValue,\n 'focus-within:fill-primary-active': color === 'primary' && modelValue,\n\n 'focus-within:fill-secondary-pressed': color === 'secondary' && !modelValue,\n 'focus-within:fill-secondary-active': color === 'secondary' && modelValue,\n\n 'fill-error': color === 'error',\n 'fill-neutral-darker': modelValue,\n }\"\n >\n <slot name=\"leading\" v-bind=\"{ error: !!errorMessage }\" />\n </div>\n <slot v-bind=\"{ error: !!errorMessage }\" />\n <div\n class=\"pointer-events-auto absolute inset-y-0 right-2 z-20 flex cursor-pointer items-center\"\n :class=\"{ 'text-error': !!errorMessage }\"\n >\n <slot name=\"trailing\" v-bind=\"{ error: !!errorMessage }\"> </slot>\n </div>\n </div>\n <slot name=\"after\" />\n </div>\n <div\n v-if=\"!!errorMessage && errorMessage !== true && !hiddenErrorMessage\"\n class=\"text-neutral-lighter group-focus-within:text-error group-active-within:text-error mt-1 text-sm\"\n >\n {{ errorMessage }}\n </div>\n </div>\n</template>\n"],"names":["elInputContainerColor"],"mappings":"6ZACaA,EAAwB,CAAC,UAAW,YAAa,OAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@davincihealthcare/elty-design-system-vue",
3
- "version": "2.10.1",
3
+ "version": "2.10.2",
4
4
  "license": "UNLICENSED",
5
5
  "main": "dist/index.umd.cjs",
6
6
  "types": "dist/index.d.ts",