@madgex/design-system-ce 5.6.1 → 5.6.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.
- package/components/combobox/Combobox.ce.vue +217 -253
- package/components/combobox/ComboboxClear.vue +5 -5
- package/components/combobox/ListBox.vue +10 -15
- package/components/combobox/ListBoxOption.vue +26 -37
- package/dist/custom-elements/mds-combobox.js +1 -1
- package/dist/custom-elements/mds-text-editor.js +20 -20
- package/dist/index.js +1 -1
- package/dist/manifest.json +17 -13
- package/dist/runtime-dom.esm-bundler.js +18 -0
- package/package.json +14 -12
- package/vite.config.js +1 -1
- package/components/combobox/Combobox.ce.spec.js +0 -76
- package/dist/plugin-vue_export-helper.js +0 -18
- package/eslint.config.js +0 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{v as C,a as p,i as r,f as I,u as _,q as b,b as D,x as oe,t as F,y as E,z as se,e as N,r as y,A as s,B as ue,C as O,p as q,j as ie,D as re,F as ce,l as de,s as ve}from"../runtime-dom.esm-bundler.js";const fe=["aria-label","title"],pe={"aria-hidden":"true",focusable:"false",class:"mds-icon mds-icon--close mds-icon--sm"},me=["href"],be={__name:"ComboboxClear",setup(l){const c=C("iconPath"),t=C("clearInput");return(i,o)=>(r(),p("button",{class:"mds-combobox__clear mds-button mds-button--plain",type:"button",onClick:o[0]||(o[0]=u=>i.$emit("clear",u)),onKeydown:o[1]||(o[1]=b(u=>i.$emit("clear",u),["enter"])),"aria-label":_(t),title:_(t)},[(r(),p("svg",pe,[I("use",{href:`${_(c)}#icon-close`},null,8,me)]))],40,fe))}},he=["hidden"],ge={key:0,class:"mds-combobox-loading"},xe={"aria-hidden":"true",focusable:"true",class:"mds-icon mds-icon--spinner mds-icon--after"},ye=["href"],_e={class:"mds-visually-hidden"},Ie={__name:"ListBox",props:{hidden:{type:Boolean,default:!0},isLoading:{type:Boolean,default:!0}},setup(l){const c=C("iconPath"),t=C("loadingText");return(i,o)=>(r(),p("ul",{class:"mds-combobox__listbox",role:"listbox",hidden:l.hidden},[l.isLoading?(r(),p("li",ge,[(r(),p("svg",xe,[I("use",{href:`${_(c)}#icon-spinner`},null,8,ye)])),I("span",_e,F(_(t)),1)])):D("",!0),oe(i.$slots,"default")],8,he))}},$e=["aria-selected","innerHTML"],Ce={__name:"ListBoxOption",props:{option:{type:Object,required:!0},focused:{type:Boolean,default:!1},searchValue:{type:String,default:""}},setup(l){const c=l,t=E("$listItem");se(()=>c.focused,o=>{o&&t.value?.scrollIntoView({block:"nearest",inline:"nearest"})});function i(){return c.option.label.replace(new RegExp(c.searchValue,"gi"),u=>`<span class="mds-combobox__option--marked">${u}</span>`)}return(o,u)=>(r(),p("li",{ref_key:"$listItem",ref:t,class:N(["mds-combobox__option",{"mds-combobox__option--focused":l.focused}]),role:"option","aria-selected":l.focused.toString(),onMousedown:u[0]||(u[0]=f=>o.$emit("mousedown",f)),innerHTML:i()},null,42,$e))}},Se=["id","value","name","placeholder","aria-controls","aria-expanded","aria-describedby","aria-activedescendant","aria-invalid"],ke={"aria-live":"polite",role:"status",class:"mds-visually-hidden"},we={__name:"Combobox.ce",props:{comboboxid:{type:String,required:!0},placeholder:{type:String,default:""},name:{type:[String,Boolean],default:!1},value:{type:String,default:""},options:{type:Array,default:()=>[]},filterOptions:{type:Boolean,default:!0},iconpath:{type:String,default:"/assets/icons.svg"},dataAriaInvalid:{type:String,default:""},i18n:{type:String,default:""},describedbyId:{type:String,default:""},minSearchCharacters:{type:Number,default:2}},emits:["search","select-option","clear-all"],setup(l,{emit:c}){const t=l,i=c,o=E("$el"),u=E("$comboInput"),f=y(!1),T=y(null),S=y(null),d=y(t.value),k=y(null),$=s(()=>t.i18n?JSON.parse(t.i18n):{loadingText:"Loading",resultsMessage:"{count} result available",resultsMessage_plural:"{count} results available",clearInput:"clear input"}),P=s(()=>g.value?g.value.label:d.value),a=s(()=>t.filterOptions?t.options.filter(e=>e.label.toLowerCase().includes(d.value.toLowerCase())):t.options),K=s(()=>`${t.comboboxid}-listbox`),V=s(()=>`${t.comboboxid}-option`),j=s(()=>t.options.length===0&&f.value),R=s(()=>{const e=a.value.findIndex(v=>String(v.value)===String(n.value?.value));if(e>-1)return`${V.value}-${e}`}),h=s(()=>!f.value),w=s(()=>a.value.length-1),z=s(()=>f.value?"true":"false"),J=s(()=>t.dataAriaInvalid?"true":"false"),n=s({get(){return T.value},set(e){T.value=e}}),g=s({get(){return S.value},set(e){S.value=e,n.value=e,i("select-option",S.value)}});ue(()=>{const e=o.value?.parentElement?.parentElement?.querySelector(".mds-form-element__fallback input"),v=o.value?.parentElement?.parentElement?.querySelector(".mds-form-element__fallback select");e&&e.remove(),v&&v.removeAttribute("id")});function U(){f.value=!0}function x(){f.value=!1}function G(e){g.value=null,d.value=e.target?e.target.value:"",B(),i("search",d.value),a.value.length>0&&L()}function B(){d.value.length===0&&A(),d.value.length>=t.minSearchCharacters?(U(),L()):x()}function Q(){B(),a.value.length>1&&L()}function W(){A(),u.value?.focus()}function A(){d.value="",g.value=null,i("clear-all")}function X(e=n.value){g.value=e,x()}function Y(e){f.value&&(e.preventDefault(),Z())}function Z(){g.value=n.value,x(),M()}function ee(){x(),M()}function te(){if(!h.value)if(n.value){const e=a.value.findIndex(m=>m.value===n.value.value),v=e===w.value?e:e+1;n.value=a.value[v]}else[n.value]=a.value}function ae(){if(!h.value)if(n.value){const e=a.value.findIndex(m=>m.value===n.value.value),v=e===0?e:e-1;n.value=a.value[v]}else n.value=a.value[w.value]}function ne(){h.value||([n.value]=a.value)}function le(){h.value||(n.value=a.value[w.value])}function L(){M(),setTimeout(()=>{const e=a.value.length===1?$.value.resultsMessage:$.value.resultsMessage_plural;k.value=e.replace("{count}",a.value.length)},1400)}function M(){k.value=null}return O("iconPath",t.iconpath),O("loadingText",$.value.loadingText),O("clearInput",$.value.clearInput),(e,v)=>(r(),p("div",{ref_key:"$el",ref:o,class:N(["mds-combobox",{"mds-combobox--active":!h.value}]),onKeydown:[b(te,["down"]),b(ae,["up"]),b(ne,["home"]),b(le,["end"]),b(x,["esc"]),b(Y,["enter"])]},[I("input",{id:l.comboboxid,ref_key:"$comboInput",ref:u,value:P.value,class:"mds-form-control",autocomplete:"off",type:"text",role:"combobox",name:l.name,placeholder:l.placeholder,"aria-controls":K.value,"aria-expanded":z.value,"aria-autocomplete":"list","aria-describedby":l.describedbyId,"aria-activedescendant":R.value,"aria-invalid":J.value,onInput:G,onChange:B,onBlur:ee,onFocus:Q},null,40,Se),d.value.length>0?(r(),q(be,{key:0,onClear:W})):D("",!0),ie(Ie,{id:K.value,hidden:h.value,"aria-labelledby":`${l.comboboxid}-label`,"is-loading":j.value},{default:re(()=>[(r(!0),p(ce,null,de(a.value,(m,H)=>(r(),q(Ce,{id:`${V.value}-${H}`,key:H,option:m,focused:n.value?.value===m?.value,"search-value":d.value,onMousedown:Be=>X(m)},null,8,["id","option","focused","search-value","onMousedown"]))),128))]),_:1},8,["id","hidden","aria-labelledby","is-loading"]),I("div",ke,F(k.value),1)],34))}},Me=ve(we,{shadowRoot:!1});export{Me as default};
|