@gits-id/autocomplete
Advanced tools
Comparing version
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.10.7](https://github.com/gitsindonesia/ui-component/compare/v0.10.6...v0.10.7) (2022-07-08) | ||
**Note:** Version bump only for package @gits-id/autocomplete | ||
## [0.10.5](https://github.com/gitsindonesia/ui-component/compare/v0.10.4...v0.10.5) (2022-07-06) | ||
@@ -8,0 +16,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e=require("vue"),n=require("@headlessui/vue"),k=require("vee-validate"),d=require("vue-remix-icons");const C={class:"relative mt-1"},N={class:"relative w-full text-left bg-white border border-gray-400 rounded cursor-default focus:outline-none focus-within:ring focus-within:ring-primary-500 focus-within:border-primary-500 focus-within:ring-opacity-50 sm:text-sm overflow-hidden transition duration-300"},B={class:"absolute inset-y-0 right-0 flex items-center pr-4"},E={key:0,class:"cursor-default select-none relative py-2 px-4 text-gray-700"},S={key:1,class:"cursor-default select-none relative py-2 px-4 text-gray-700"},T={key:0,class:"absolute inset-y-0 left-0 flex items-center pl-3"},D={class:"text-error text-sm mt-1"},p=e.defineComponent({props:{modelValue:{default:void 0},searchBy:{default:"text"},displayText:{default:"text"},placeholder:{default:"Search..."},label:{default:""},items:{default:()=>[]},name:{default:""},rules:{default:""},notFoundText:{default:"Nothing found."},noDataText:{default:"No data."},clearable:{type:Boolean,default:!1}},emits:["update:modelValue","update:query"],setup(t,{emit:c}){const y=t,{modelValue:m,searchBy:x,items:f,name:g,rules:h}=e.toRefs(y),{value:r,errorMessage:b}=k.useField(g,h,{initialValue:m.value}),l=e.ref("");e.watch(m,o=>{r.value=o}),e.watch(r,o=>{c("update:modelValue",o)}),e.watch(l,o=>{c("update:query",o)});const i=e.computed(()=>l.value===""?f.value:f.value.filter(o=>String(o[x.value]).toLowerCase().replace(/\s+/g,"").includes(l.value.toLowerCase().replace(/\s+/g,"")))),V=()=>{r.value="",l.value=""};return(o,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(n.Combobox),{modelValue:e.unref(r),"onUpdate:modelValue":u[2]||(u[2]=a=>e.isRef(r)?r.value=a:null),class:"mb-4",as:"div"},{default:e.withCtx(()=>[t.label?(e.openBlock(),e.createBlock(e.unref(n.ComboboxLabel),{key:0,class:"mb-2 font-medium"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.label),1)]),_:1})):e.createCommentVNode("",!0),e.createElementVNode("div",C,[e.createElementVNode("div",N,[e.createVNode(e.unref(n.ComboboxInput),{class:"w-full border-none focus:ring-0 py-3 pl-3 pr-20 leading-5 text-gray-600","display-value":a=>a[t.displayText]||"",placeholder:t.placeholder,onChange:u[0]||(u[0]=a=>l.value=a.target.value)},null,8,["display-value","placeholder"]),e.createElementVNode("div",B,[t.clearable&&e.unref(r)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"mr-1 text-gray-400 hover:text-gray-700 hover:bg-gray-100 rounded-full p-1 transition duration-300",onClick:V},[e.createVNode(e.unref(d.RiCloseLine),{class:"w-6 h-6 fill-current text-gray-500","aria-hidden":"true"})])):e.createCommentVNode("",!0),e.createVNode(e.unref(n.ComboboxButton),null,{default:e.withCtx(()=>[e.createVNode(e.unref(d.RiArrowDownSLine),{class:"w-6 h-6 fill-current text-gray-500","aria-hidden":"true"})]),_:1})])]),e.createVNode(e.unref(n.TransitionRoot),{leave:"transition ease-in duration-100","leave-from":"opacity-100","leave-to":"opacity-0",onAfterLeave:u[1]||(u[1]=a=>l.value="")},{default:e.withCtx(()=>[e.createVNode(e.unref(n.ComboboxOptions),{class:"absolute z-10 w-full py-1 mt-1 overflow-auto text-base bg-white rounded-md shadow-lg max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"},{default:e.withCtx(()=>[e.unref(i).length===0&&l.value===""?(e.openBlock(),e.createElementBlock("div",E,e.toDisplayString(t.noDataText),1)):e.createCommentVNode("",!0),e.unref(i).length===0&&l.value!==""?(e.openBlock(),e.createElementBlock("div",S,e.toDisplayString(t.notFoundText),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i),(a,w)=>(e.openBlock(),e.createBlock(e.unref(n.ComboboxOption),{key:w,as:"template",value:a},{default:e.withCtx(({selected:s,active:v})=>[e.createElementVNode("li",{class:e.normalizeClass(["cursor-default select-none relative py-2 pl-10 pr-4",{"bg-gray-100":v,"text-gray-900":!v}])},[e.createElementVNode("span",{class:e.normalizeClass(["block truncate",{"font-medium text-primary-500":s,"font-normal":!s}])},e.toDisplayString(a[t.displayText]),3),s?(e.openBlock(),e.createElementBlock("span",T,[e.createVNode(e.unref(d.RiCheckLine),{class:"w-5 h-5 fill-current text-primary-500","aria-hidden":"true"})])):e.createCommentVNode("",!0)],2)]),_:2},1032,["value"]))),128))]),_:1})]),_:1})])]),_:1},8,["modelValue"]),e.createElementVNode("div",D,e.toDisplayString(e.unref(b)),1)],64))}});exports.Autocomplete=p;exports.default=p; | ||
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e=require("vue"),n=require("@headlessui/vue"),k=require("vee-validate"),d=require("vue-remix-icons");const C={class:"relative mt-1"},N={class:"relative w-full text-left bg-white border border-gray-400 rounded cursor-default focus:outline-none focus-within:ring focus-within:ring-primary-500 focus-within:border-primary-500 focus-within:ring-opacity-50 sm:text-sm overflow-hidden transition duration-300"},B={class:"absolute inset-y-0 right-0 flex items-center pr-4"},E={key:0,class:"cursor-default select-none relative py-2 px-4 text-gray-700"},S={key:1,class:"cursor-default select-none relative py-2 px-4 text-gray-700"},T={key:0,class:"absolute inset-y-0 left-0 flex items-center pl-3"},D={class:"text-error text-sm mt-1"},p=e.defineComponent({props:{modelValue:{default:void 0},searchBy:{default:"text"},displayText:{default:"text"},placeholder:{default:"Search..."},label:{default:""},items:{default:()=>[]},name:{default:""},rules:{default:""},notFoundText:{default:"Nothing found."},noDataText:{default:"No data."},clearable:{type:Boolean,default:!1}},emits:["update:modelValue","update:query"],setup(t,{emit:c}){const y=t,{modelValue:m,searchBy:x,items:f,name:g,rules:h}=e.toRefs(y),{value:r,errorMessage:b}=k.useField(g,h,{initialValue:m.value}),l=e.ref("");e.watch(m,o=>{r.value=o}),e.watch(r,o=>{c("update:modelValue",o)}),e.watch(l,o=>{c("update:query",o)});const i=e.computed(()=>l.value===""?f.value:f.value.filter(o=>String(o[x.value]).toLowerCase().replace(/\s+/g,"").includes(l.value.toLowerCase().replace(/\s+/g,"")))),V=()=>{r.value="",l.value=""};return(o,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(n.Combobox),{modelValue:e.unref(r),"onUpdate:modelValue":u[2]||(u[2]=a=>e.isRef(r)?r.value=a:null),class:"mb-4",as:"div"},{default:e.withCtx(()=>[t.label?(e.openBlock(),e.createBlock(e.unref(n.ComboboxLabel),{key:0,class:"mb-2 font-medium"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.label),1)]),_:1})):e.createCommentVNode("",!0),e.createElementVNode("div",C,[e.createElementVNode("div",N,[e.createVNode(e.unref(n.ComboboxInput),{class:"w-full border-none focus:ring-0 py-3 pl-3 pr-20 leading-5 text-gray-600","display-value":a=>a?.[t.displayText]||"",placeholder:t.placeholder,onChange:u[0]||(u[0]=a=>l.value=a.target.value)},null,8,["display-value","placeholder"]),e.createElementVNode("div",B,[t.clearable&&e.unref(r)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"mr-1 text-gray-400 hover:text-gray-700 hover:bg-gray-100 rounded-full p-1 transition duration-300",onClick:V},[e.createVNode(e.unref(d.RiCloseLine),{class:"w-6 h-6 fill-current text-gray-500","aria-hidden":"true"})])):e.createCommentVNode("",!0),e.createVNode(e.unref(n.ComboboxButton),null,{default:e.withCtx(()=>[e.createVNode(e.unref(d.RiArrowDownSLine),{class:"w-6 h-6 fill-current text-gray-500","aria-hidden":"true"})]),_:1})])]),e.createVNode(e.unref(n.TransitionRoot),{leave:"transition ease-in duration-100","leave-from":"opacity-100","leave-to":"opacity-0",onAfterLeave:u[1]||(u[1]=a=>l.value="")},{default:e.withCtx(()=>[e.createVNode(e.unref(n.ComboboxOptions),{class:"absolute z-10 w-full py-1 mt-1 overflow-auto text-base bg-white rounded-md shadow-lg max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"},{default:e.withCtx(()=>[e.unref(i).length===0&&l.value===""?(e.openBlock(),e.createElementBlock("div",E,e.toDisplayString(t.noDataText),1)):e.createCommentVNode("",!0),e.unref(i).length===0&&l.value!==""?(e.openBlock(),e.createElementBlock("div",S,e.toDisplayString(t.notFoundText),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i),(a,w)=>(e.openBlock(),e.createBlock(e.unref(n.ComboboxOption),{key:w,as:"template",value:a},{default:e.withCtx(({selected:s,active:v})=>[e.createElementVNode("li",{class:e.normalizeClass(["cursor-default select-none relative py-2 pl-10 pr-4",{"bg-gray-100":v,"text-gray-900":!v}])},[e.createElementVNode("span",{class:e.normalizeClass(["block truncate",{"font-medium text-primary-500":s,"font-normal":!s}])},e.toDisplayString(a[t.displayText]),3),s?(e.openBlock(),e.createElementBlock("span",T,[e.createVNode(e.unref(d.RiCheckLine),{class:"w-5 h-5 fill-current text-primary-500","aria-hidden":"true"})])):e.createCommentVNode("",!0)],2)]),_:2},1032,["value"]))),128))]),_:1})]),_:1})])]),_:1},8,["modelValue"]),e.createElementVNode("div",D,e.toDisplayString(e.unref(b)),1)],64))}});exports.Autocomplete=p;exports.default=p; |
@@ -80,3 +80,3 @@ import { defineComponent, toRefs, ref, watch, computed, openBlock, createElementBlock, Fragment, createVNode, unref, isRef, withCtx, createBlock, createTextVNode, toDisplayString, createCommentVNode, createElementVNode, renderList, normalizeClass } from 'vue'; | ||
class: "w-full border-none focus:ring-0 py-3 pl-3 pr-20 leading-5 text-gray-600", | ||
"display-value": (item) => item[__props.displayText] || "", | ||
"display-value": (item) => item?.[__props.displayText] || "", | ||
placeholder: __props.placeholder, | ||
@@ -83,0 +83,0 @@ onChange: _cache[0] || (_cache[0] = ($event) => query.value = $event.target.value) |
@@ -1,1 +0,1 @@ | ||
var Dropdown=function(s,e,r,h,d){"use strict";const x={class:"relative mt-1"},b={class:"relative w-full text-left bg-white border border-gray-400 rounded cursor-default focus:outline-none focus-within:ring focus-within:ring-primary-500 focus-within:border-primary-500 focus-within:ring-opacity-50 sm:text-sm overflow-hidden transition duration-300"},V={class:"absolute inset-y-0 right-0 flex items-center pr-4"},w={key:0,class:"cursor-default select-none relative py-2 px-4 text-gray-700"},k={key:1,class:"cursor-default select-none relative py-2 px-4 text-gray-700"},C={key:0,class:"absolute inset-y-0 left-0 flex items-center pl-3"},N={class:"text-error text-sm mt-1"},m=e.defineComponent({props:{modelValue:{default:void 0},searchBy:{default:"text"},displayText:{default:"text"},placeholder:{default:"Search..."},label:{default:""},items:{default:()=>[]},name:{default:""},rules:{default:""},notFoundText:{default:"Nothing found."},noDataText:{default:"No data."},clearable:{type:Boolean,default:!1}},emits:["update:modelValue","update:query"],setup(t,{emit:u}){const B=t,{modelValue:p,searchBy:E,items:y,name:S,rules:T}=e.toRefs(B),{value:n,errorMessage:D}=h.useField(S,T,{initialValue:p.value}),a=e.ref("");e.watch(p,o=>{n.value=o}),e.watch(n,o=>{u("update:modelValue",o)}),e.watch(a,o=>{u("update:query",o)});const c=e.computed(()=>a.value===""?y.value:y.value.filter(o=>String(o[E.value]).toLowerCase().replace(/\s+/g,"").includes(a.value.toLowerCase().replace(/\s+/g,"")))),L=()=>{n.value="",a.value=""};return(o,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(r.Combobox),{modelValue:e.unref(n),"onUpdate:modelValue":i[2]||(i[2]=l=>e.isRef(n)?n.value=l:null),class:"mb-4",as:"div"},{default:e.withCtx(()=>[t.label?(e.openBlock(),e.createBlock(e.unref(r.ComboboxLabel),{key:0,class:"mb-2 font-medium"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.label),1)]),_:1})):e.createCommentVNode("",!0),e.createElementVNode("div",x,[e.createElementVNode("div",b,[e.createVNode(e.unref(r.ComboboxInput),{class:"w-full border-none focus:ring-0 py-3 pl-3 pr-20 leading-5 text-gray-600","display-value":l=>l[t.displayText]||"",placeholder:t.placeholder,onChange:i[0]||(i[0]=l=>a.value=l.target.value)},null,8,["display-value","placeholder"]),e.createElementVNode("div",V,[t.clearable&&e.unref(n)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"mr-1 text-gray-400 hover:text-gray-700 hover:bg-gray-100 rounded-full p-1 transition duration-300",onClick:L},[e.createVNode(e.unref(d.RiCloseLine),{class:"w-6 h-6 fill-current text-gray-500","aria-hidden":"true"})])):e.createCommentVNode("",!0),e.createVNode(e.unref(r.ComboboxButton),null,{default:e.withCtx(()=>[e.createVNode(e.unref(d.RiArrowDownSLine),{class:"w-6 h-6 fill-current text-gray-500","aria-hidden":"true"})]),_:1})])]),e.createVNode(e.unref(r.TransitionRoot),{leave:"transition ease-in duration-100","leave-from":"opacity-100","leave-to":"opacity-0",onAfterLeave:i[1]||(i[1]=l=>a.value="")},{default:e.withCtx(()=>[e.createVNode(e.unref(r.ComboboxOptions),{class:"absolute z-10 w-full py-1 mt-1 overflow-auto text-base bg-white rounded-md shadow-lg max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"},{default:e.withCtx(()=>[e.unref(c).length===0&&a.value===""?(e.openBlock(),e.createElementBlock("div",w,e.toDisplayString(t.noDataText),1)):e.createCommentVNode("",!0),e.unref(c).length===0&&a.value!==""?(e.openBlock(),e.createElementBlock("div",k,e.toDisplayString(t.notFoundText),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(c),(l,F)=>(e.openBlock(),e.createBlock(e.unref(r.ComboboxOption),{key:F,as:"template",value:l},{default:e.withCtx(({selected:f,active:g})=>[e.createElementVNode("li",{class:e.normalizeClass(["cursor-default select-none relative py-2 pl-10 pr-4",{"bg-gray-100":g,"text-gray-900":!g}])},[e.createElementVNode("span",{class:e.normalizeClass(["block truncate",{"font-medium text-primary-500":f,"font-normal":!f}])},e.toDisplayString(l[t.displayText]),3),f?(e.openBlock(),e.createElementBlock("span",C,[e.createVNode(e.unref(d.RiCheckLine),{class:"w-5 h-5 fill-current text-primary-500","aria-hidden":"true"})])):e.createCommentVNode("",!0)],2)]),_:2},1032,["value"]))),128))]),_:1})]),_:1})])]),_:1},8,["modelValue"]),e.createElementVNode("div",N,e.toDisplayString(e.unref(D)),1)],64))}});return s.Autocomplete=m,s.default=m,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),s}({},Vue,vue$1,veeValidate,vueRemixIcons); | ||
var Dropdown=function(s,e,r,h,d){"use strict";const x={class:"relative mt-1"},b={class:"relative w-full text-left bg-white border border-gray-400 rounded cursor-default focus:outline-none focus-within:ring focus-within:ring-primary-500 focus-within:border-primary-500 focus-within:ring-opacity-50 sm:text-sm overflow-hidden transition duration-300"},V={class:"absolute inset-y-0 right-0 flex items-center pr-4"},w={key:0,class:"cursor-default select-none relative py-2 px-4 text-gray-700"},k={key:1,class:"cursor-default select-none relative py-2 px-4 text-gray-700"},C={key:0,class:"absolute inset-y-0 left-0 flex items-center pl-3"},N={class:"text-error text-sm mt-1"},m=e.defineComponent({props:{modelValue:{default:void 0},searchBy:{default:"text"},displayText:{default:"text"},placeholder:{default:"Search..."},label:{default:""},items:{default:()=>[]},name:{default:""},rules:{default:""},notFoundText:{default:"Nothing found."},noDataText:{default:"No data."},clearable:{type:Boolean,default:!1}},emits:["update:modelValue","update:query"],setup(t,{emit:u}){const B=t,{modelValue:p,searchBy:E,items:y,name:S,rules:T}=e.toRefs(B),{value:n,errorMessage:D}=h.useField(S,T,{initialValue:p.value}),a=e.ref("");e.watch(p,o=>{n.value=o}),e.watch(n,o=>{u("update:modelValue",o)}),e.watch(a,o=>{u("update:query",o)});const c=e.computed(()=>a.value===""?y.value:y.value.filter(o=>String(o[E.value]).toLowerCase().replace(/\s+/g,"").includes(a.value.toLowerCase().replace(/\s+/g,"")))),L=()=>{n.value="",a.value=""};return(o,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(r.Combobox),{modelValue:e.unref(n),"onUpdate:modelValue":i[2]||(i[2]=l=>e.isRef(n)?n.value=l:null),class:"mb-4",as:"div"},{default:e.withCtx(()=>[t.label?(e.openBlock(),e.createBlock(e.unref(r.ComboboxLabel),{key:0,class:"mb-2 font-medium"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.label),1)]),_:1})):e.createCommentVNode("",!0),e.createElementVNode("div",x,[e.createElementVNode("div",b,[e.createVNode(e.unref(r.ComboboxInput),{class:"w-full border-none focus:ring-0 py-3 pl-3 pr-20 leading-5 text-gray-600","display-value":l=>l?.[t.displayText]||"",placeholder:t.placeholder,onChange:i[0]||(i[0]=l=>a.value=l.target.value)},null,8,["display-value","placeholder"]),e.createElementVNode("div",V,[t.clearable&&e.unref(n)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"mr-1 text-gray-400 hover:text-gray-700 hover:bg-gray-100 rounded-full p-1 transition duration-300",onClick:L},[e.createVNode(e.unref(d.RiCloseLine),{class:"w-6 h-6 fill-current text-gray-500","aria-hidden":"true"})])):e.createCommentVNode("",!0),e.createVNode(e.unref(r.ComboboxButton),null,{default:e.withCtx(()=>[e.createVNode(e.unref(d.RiArrowDownSLine),{class:"w-6 h-6 fill-current text-gray-500","aria-hidden":"true"})]),_:1})])]),e.createVNode(e.unref(r.TransitionRoot),{leave:"transition ease-in duration-100","leave-from":"opacity-100","leave-to":"opacity-0",onAfterLeave:i[1]||(i[1]=l=>a.value="")},{default:e.withCtx(()=>[e.createVNode(e.unref(r.ComboboxOptions),{class:"absolute z-10 w-full py-1 mt-1 overflow-auto text-base bg-white rounded-md shadow-lg max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"},{default:e.withCtx(()=>[e.unref(c).length===0&&a.value===""?(e.openBlock(),e.createElementBlock("div",w,e.toDisplayString(t.noDataText),1)):e.createCommentVNode("",!0),e.unref(c).length===0&&a.value!==""?(e.openBlock(),e.createElementBlock("div",k,e.toDisplayString(t.notFoundText),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(c),(l,F)=>(e.openBlock(),e.createBlock(e.unref(r.ComboboxOption),{key:F,as:"template",value:l},{default:e.withCtx(({selected:f,active:g})=>[e.createElementVNode("li",{class:e.normalizeClass(["cursor-default select-none relative py-2 pl-10 pr-4",{"bg-gray-100":g,"text-gray-900":!g}])},[e.createElementVNode("span",{class:e.normalizeClass(["block truncate",{"font-medium text-primary-500":f,"font-normal":!f}])},e.toDisplayString(l[t.displayText]),3),f?(e.openBlock(),e.createElementBlock("span",C,[e.createVNode(e.unref(d.RiCheckLine),{class:"w-5 h-5 fill-current text-primary-500","aria-hidden":"true"})])):e.createCommentVNode("",!0)],2)]),_:2},1032,["value"]))),128))]),_:1})]),_:1})])]),_:1},8,["modelValue"]),e.createElementVNode("div",N,e.toDisplayString(e.unref(D)),1)],64))}});return s.Autocomplete=m,s.default=m,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),s}({},Vue,vue$1,veeValidate,vueRemixIcons); |
@@ -1,1 +0,1 @@ | ||
(function(t,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@headlessui/vue"),require("vee-validate"),require("vue-remix-icons")):typeof define=="function"&&define.amd?define(["exports","vue","@headlessui/vue","vee-validate","vue-remix-icons"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t.Dropdown={},t.Vue,t.vue$1,t.veeValidate,t.vueRemixIcons))})(this,function(t,e,n,x,d){"use strict";const g={class:"relative mt-1"},b={class:"relative w-full text-left bg-white border border-gray-400 rounded cursor-default focus:outline-none focus-within:ring focus-within:ring-primary-500 focus-within:border-primary-500 focus-within:ring-opacity-50 sm:text-sm overflow-hidden transition duration-300"},V={class:"absolute inset-y-0 right-0 flex items-center pr-4"},w={key:0,class:"cursor-default select-none relative py-2 px-4 text-gray-700"},k={key:1,class:"cursor-default select-none relative py-2 px-4 text-gray-700"},C={key:0,class:"absolute inset-y-0 left-0 flex items-center pl-3"},N={class:"text-error text-sm mt-1"},u=e.defineComponent({props:{modelValue:{default:void 0},searchBy:{default:"text"},displayText:{default:"text"},placeholder:{default:"Search..."},label:{default:""},items:{default:()=>[]},name:{default:""},rules:{default:""},notFoundText:{default:"Nothing found."},noDataText:{default:"No data."},clearable:{type:Boolean,default:!1}},emits:["update:modelValue","update:query"],setup(a,{emit:m}){const B=a,{modelValue:p,searchBy:E,items:y,name:T,rules:S}=e.toRefs(B),{value:i,errorMessage:D}=x.useField(T,S,{initialValue:p.value}),o=e.ref("");e.watch(p,r=>{i.value=r}),e.watch(i,r=>{m("update:modelValue",r)}),e.watch(o,r=>{m("update:query",r)});const c=e.computed(()=>o.value===""?y.value:y.value.filter(r=>String(r[E.value]).toLowerCase().replace(/\s+/g,"").includes(o.value.toLowerCase().replace(/\s+/g,"")))),L=()=>{i.value="",o.value=""};return(r,s)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(n.Combobox),{modelValue:e.unref(i),"onUpdate:modelValue":s[2]||(s[2]=l=>e.isRef(i)?i.value=l:null),class:"mb-4",as:"div"},{default:e.withCtx(()=>[a.label?(e.openBlock(),e.createBlock(e.unref(n.ComboboxLabel),{key:0,class:"mb-2 font-medium"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.label),1)]),_:1})):e.createCommentVNode("",!0),e.createElementVNode("div",g,[e.createElementVNode("div",b,[e.createVNode(e.unref(n.ComboboxInput),{class:"w-full border-none focus:ring-0 py-3 pl-3 pr-20 leading-5 text-gray-600","display-value":l=>l[a.displayText]||"",placeholder:a.placeholder,onChange:s[0]||(s[0]=l=>o.value=l.target.value)},null,8,["display-value","placeholder"]),e.createElementVNode("div",V,[a.clearable&&e.unref(i)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"mr-1 text-gray-400 hover:text-gray-700 hover:bg-gray-100 rounded-full p-1 transition duration-300",onClick:L},[e.createVNode(e.unref(d.RiCloseLine),{class:"w-6 h-6 fill-current text-gray-500","aria-hidden":"true"})])):e.createCommentVNode("",!0),e.createVNode(e.unref(n.ComboboxButton),null,{default:e.withCtx(()=>[e.createVNode(e.unref(d.RiArrowDownSLine),{class:"w-6 h-6 fill-current text-gray-500","aria-hidden":"true"})]),_:1})])]),e.createVNode(e.unref(n.TransitionRoot),{leave:"transition ease-in duration-100","leave-from":"opacity-100","leave-to":"opacity-0",onAfterLeave:s[1]||(s[1]=l=>o.value="")},{default:e.withCtx(()=>[e.createVNode(e.unref(n.ComboboxOptions),{class:"absolute z-10 w-full py-1 mt-1 overflow-auto text-base bg-white rounded-md shadow-lg max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"},{default:e.withCtx(()=>[e.unref(c).length===0&&o.value===""?(e.openBlock(),e.createElementBlock("div",w,e.toDisplayString(a.noDataText),1)):e.createCommentVNode("",!0),e.unref(c).length===0&&o.value!==""?(e.openBlock(),e.createElementBlock("div",k,e.toDisplayString(a.notFoundText),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(c),(l,q)=>(e.openBlock(),e.createBlock(e.unref(n.ComboboxOption),{key:q,as:"template",value:l},{default:e.withCtx(({selected:f,active:h})=>[e.createElementVNode("li",{class:e.normalizeClass(["cursor-default select-none relative py-2 pl-10 pr-4",{"bg-gray-100":h,"text-gray-900":!h}])},[e.createElementVNode("span",{class:e.normalizeClass(["block truncate",{"font-medium text-primary-500":f,"font-normal":!f}])},e.toDisplayString(l[a.displayText]),3),f?(e.openBlock(),e.createElementBlock("span",C,[e.createVNode(e.unref(d.RiCheckLine),{class:"w-5 h-5 fill-current text-primary-500","aria-hidden":"true"})])):e.createCommentVNode("",!0)],2)]),_:2},1032,["value"]))),128))]),_:1})]),_:1})])]),_:1},8,["modelValue"]),e.createElementVNode("div",N,e.toDisplayString(e.unref(D)),1)],64))}});t.Autocomplete=u,t.default=u,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
(function(t,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@headlessui/vue"),require("vee-validate"),require("vue-remix-icons")):typeof define=="function"&&define.amd?define(["exports","vue","@headlessui/vue","vee-validate","vue-remix-icons"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t.Dropdown={},t.Vue,t.vue$1,t.veeValidate,t.vueRemixIcons))})(this,function(t,e,n,x,d){"use strict";const g={class:"relative mt-1"},b={class:"relative w-full text-left bg-white border border-gray-400 rounded cursor-default focus:outline-none focus-within:ring focus-within:ring-primary-500 focus-within:border-primary-500 focus-within:ring-opacity-50 sm:text-sm overflow-hidden transition duration-300"},V={class:"absolute inset-y-0 right-0 flex items-center pr-4"},w={key:0,class:"cursor-default select-none relative py-2 px-4 text-gray-700"},k={key:1,class:"cursor-default select-none relative py-2 px-4 text-gray-700"},C={key:0,class:"absolute inset-y-0 left-0 flex items-center pl-3"},N={class:"text-error text-sm mt-1"},u=e.defineComponent({props:{modelValue:{default:void 0},searchBy:{default:"text"},displayText:{default:"text"},placeholder:{default:"Search..."},label:{default:""},items:{default:()=>[]},name:{default:""},rules:{default:""},notFoundText:{default:"Nothing found."},noDataText:{default:"No data."},clearable:{type:Boolean,default:!1}},emits:["update:modelValue","update:query"],setup(a,{emit:m}){const B=a,{modelValue:p,searchBy:E,items:y,name:T,rules:S}=e.toRefs(B),{value:i,errorMessage:D}=x.useField(T,S,{initialValue:p.value}),o=e.ref("");e.watch(p,r=>{i.value=r}),e.watch(i,r=>{m("update:modelValue",r)}),e.watch(o,r=>{m("update:query",r)});const c=e.computed(()=>o.value===""?y.value:y.value.filter(r=>String(r[E.value]).toLowerCase().replace(/\s+/g,"").includes(o.value.toLowerCase().replace(/\s+/g,"")))),L=()=>{i.value="",o.value=""};return(r,s)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(n.Combobox),{modelValue:e.unref(i),"onUpdate:modelValue":s[2]||(s[2]=l=>e.isRef(i)?i.value=l:null),class:"mb-4",as:"div"},{default:e.withCtx(()=>[a.label?(e.openBlock(),e.createBlock(e.unref(n.ComboboxLabel),{key:0,class:"mb-2 font-medium"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.label),1)]),_:1})):e.createCommentVNode("",!0),e.createElementVNode("div",g,[e.createElementVNode("div",b,[e.createVNode(e.unref(n.ComboboxInput),{class:"w-full border-none focus:ring-0 py-3 pl-3 pr-20 leading-5 text-gray-600","display-value":l=>l?.[a.displayText]||"",placeholder:a.placeholder,onChange:s[0]||(s[0]=l=>o.value=l.target.value)},null,8,["display-value","placeholder"]),e.createElementVNode("div",V,[a.clearable&&e.unref(i)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"mr-1 text-gray-400 hover:text-gray-700 hover:bg-gray-100 rounded-full p-1 transition duration-300",onClick:L},[e.createVNode(e.unref(d.RiCloseLine),{class:"w-6 h-6 fill-current text-gray-500","aria-hidden":"true"})])):e.createCommentVNode("",!0),e.createVNode(e.unref(n.ComboboxButton),null,{default:e.withCtx(()=>[e.createVNode(e.unref(d.RiArrowDownSLine),{class:"w-6 h-6 fill-current text-gray-500","aria-hidden":"true"})]),_:1})])]),e.createVNode(e.unref(n.TransitionRoot),{leave:"transition ease-in duration-100","leave-from":"opacity-100","leave-to":"opacity-0",onAfterLeave:s[1]||(s[1]=l=>o.value="")},{default:e.withCtx(()=>[e.createVNode(e.unref(n.ComboboxOptions),{class:"absolute z-10 w-full py-1 mt-1 overflow-auto text-base bg-white rounded-md shadow-lg max-h-60 ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"},{default:e.withCtx(()=>[e.unref(c).length===0&&o.value===""?(e.openBlock(),e.createElementBlock("div",w,e.toDisplayString(a.noDataText),1)):e.createCommentVNode("",!0),e.unref(c).length===0&&o.value!==""?(e.openBlock(),e.createElementBlock("div",k,e.toDisplayString(a.notFoundText),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(c),(l,q)=>(e.openBlock(),e.createBlock(e.unref(n.ComboboxOption),{key:q,as:"template",value:l},{default:e.withCtx(({selected:f,active:h})=>[e.createElementVNode("li",{class:e.normalizeClass(["cursor-default select-none relative py-2 pl-10 pr-4",{"bg-gray-100":h,"text-gray-900":!h}])},[e.createElementVNode("span",{class:e.normalizeClass(["block truncate",{"font-medium text-primary-500":f,"font-normal":!f}])},e.toDisplayString(l[a.displayText]),3),f?(e.openBlock(),e.createElementBlock("span",C,[e.createVNode(e.unref(d.RiCheckLine),{class:"w-5 h-5 fill-current text-primary-500","aria-hidden":"true"})])):e.createCommentVNode("",!0)],2)]),_:2},1032,["value"]))),128))]),_:1})]),_:1})])]),_:1},8,["modelValue"]),e.createElementVNode("div",N,e.toDisplayString(e.unref(D)),1)],64))}});t.Autocomplete=u,t.default=u,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); |
{ | ||
"name": "@gits-id/autocomplete", | ||
"version": "0.10.5", | ||
"version": "0.10.7", | ||
"description": "GITS Autocomplete Component", | ||
@@ -39,3 +39,3 @@ "scripts": { | ||
"types": "./dist/types/index.d.ts", | ||
"gitHead": "69fb4d1d1004ffd7bebf6ab7e078accad215f062" | ||
"gitHead": "ad0f3d9700f503c969d24dbb3f02e3439bfa2862" | ||
} |
Sorry, the diff of this file is not supported yet
47038
0.38%