@madgex/design-system-ce 5.6.1 → 5.6.3
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 +271 -268
- package/components/combobox/ComboboxAriaLive.vue +40 -0
- 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 +17 -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,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<li
|
|
3
|
-
ref="listItem"
|
|
3
|
+
ref="$listItem"
|
|
4
4
|
class="mds-combobox__option"
|
|
5
5
|
role="option"
|
|
6
6
|
:class="{ 'mds-combobox__option--focused': focused }"
|
|
@@ -10,41 +10,30 @@
|
|
|
10
10
|
/>
|
|
11
11
|
</template>
|
|
12
12
|
|
|
13
|
-
<script>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
watch: {
|
|
31
|
-
searchValue(newSearchValue) {
|
|
32
|
-
return newSearchValue;
|
|
33
|
-
},
|
|
34
|
-
focused(value) {
|
|
35
|
-
if (value) {
|
|
36
|
-
this.$refs.listItem.scrollIntoView({block: 'nearest', inline: 'nearest'});
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
methods: {
|
|
41
|
-
highlightOption() {
|
|
42
|
-
const optionLabelHtml = this.option.label.replace(
|
|
43
|
-
new RegExp(this.searchValue, 'gi'),
|
|
44
|
-
(match) => `<span class="mds-combobox__option--marked">${match}</span>`
|
|
45
|
-
);
|
|
46
|
-
return optionLabelHtml;
|
|
47
|
-
},
|
|
13
|
+
<script setup>
|
|
14
|
+
import { useTemplateRef, watch } from 'vue';
|
|
15
|
+
|
|
16
|
+
const props = defineProps({
|
|
17
|
+
optionLabel: { type: String, required: true },
|
|
18
|
+
focused: { type: Boolean, default: false },
|
|
19
|
+
searchValue: { type: String, default: '' },
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const $listItem = useTemplateRef('$listItem');
|
|
23
|
+
|
|
24
|
+
watch(
|
|
25
|
+
() => props.focused,
|
|
26
|
+
(value) => {
|
|
27
|
+
if (value) {
|
|
28
|
+
$listItem.value?.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
29
|
+
}
|
|
48
30
|
},
|
|
49
|
-
|
|
31
|
+
);
|
|
32
|
+
function highlightOption() {
|
|
33
|
+
const optionLabelHtml = props.optionLabel.replace(
|
|
34
|
+
new RegExp(props.searchValue, 'gi'),
|
|
35
|
+
(match) => `<span class="mds-combobox__option--marked">${match}</span>`,
|
|
36
|
+
);
|
|
37
|
+
return optionLabelHtml;
|
|
38
|
+
}
|
|
50
39
|
</script>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{v as I,a as p,i as c,f as x,u as _,q as b,b as j,x as D,t as N,y as k,z as U,e as q,r as y,A as h,B as C,p as A,j as K,C as se,F as re,l as ie,s as ue}from"../runtime-dom.esm-bundler.js";function ce(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var L=de;function de(n,e,l){if(!n)return l;var a,t;if(Array.isArray(e)&&(a=e.slice(0)),typeof e=="string"&&(a=e.split(".")),typeof e=="symbol"&&(a=[e]),!Array.isArray(a))throw new Error("props arg must be an array, a string or a symbol");for(;a.length;)if(t=a.shift(),!n||(n=n[t],n===void 0))return l;return n}var V=pe;function pe(n,e,l){var a=null,t=null,o=function(){a&&(clearTimeout(a),t=null,a=null)},s=function(){var d=t;o(),d&&d()},i=function(){if(!e)return n.apply(this,arguments);var d=this,w=arguments,m=l&&!a;if(o(),t=function(){n.apply(d,w)},a=setTimeout(function(){if(a=null,!m){var f=t;return t=null,f()}},e),m)return t()};return i.cancel=o,i.flush=s,i}var M={},R;function fe(){return R||(R=1,(function(n){const e={suspectRx:/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*\:/};n.parse=function(l,...a){const t=typeof a[0]=="object"&&a[0],o=a.length>1||!t?a[0]:void 0,s=a.length>1&&a[1]||t||{},i=JSON.parse(l,o);return s.protoAction==="ignore"||!i||typeof i!="object"||!l.match(e.suspectRx)||n.scan(i,s),i},n.scan=function(l,a={}){let t=[l];for(;t.length;){const o=t;t=[];for(const s of o){if(Object.prototype.hasOwnProperty.call(s,"__proto__")){if(a.protoAction!=="remove")throw new SyntaxError("Object contains forbidden prototype property");delete s.__proto__}for(const i in s){const d=s[i];d&&typeof d=="object"&&t.push(s[i])}}}},n.safeParse=function(l,a){try{return n.parse(l,a)}catch{return null}}})(M)),M}var ve=fe();const me=ce(ve),be=["aria-label","title"],he={"aria-hidden":"true",focusable:"false",class:"mds-icon mds-icon--close mds-icon--sm"},ye=["href"],ge={__name:"ComboboxClear",setup(n){const e=I("iconPath"),l=I("clearInput");return(a,t)=>(c(),p("button",{class:"mds-combobox__clear mds-button mds-button--plain",type:"button",onClick:t[0]||(t[0]=o=>a.$emit("clear",o)),onKeydown:t[1]||(t[1]=b(o=>a.$emit("clear",o),["enter"])),"aria-label":_(l),title:_(l)},[(c(),p("svg",he,[x("use",{href:`${_(e)}#icon-close`},null,8,ye)]))],40,be))}},_e=["hidden"],xe={key:0,class:"mds-combobox-loading"},$e={"aria-hidden":"true",focusable:"true",class:"mds-icon mds-icon--spinner mds-icon--after"},Ie=["href"],we={class:"mds-visually-hidden"},Se={__name:"ListBox",props:{hidden:{type:Boolean,default:!0},isLoading:{type:Boolean,default:!0}},setup(n){const e=I("iconPath"),l=I("loadingText");return(a,t)=>(c(),p("ul",{class:"mds-combobox__listbox",role:"listbox",hidden:n.hidden},[n.isLoading?(c(),p("li",xe,[(c(),p("svg",$e,[x("use",{href:`${_(e)}#icon-spinner`},null,8,Ie)])),x("span",we,N(_(l)),1)])):j("",!0),D(a.$slots,"default")],8,_e))}},Oe=["aria-selected","innerHTML"],Ce={__name:"ListBoxOption",props:{optionLabel:{type:String,required:!0},focused:{type:Boolean,default:!1},searchValue:{type:String,default:""}},setup(n){const e=n,l=k("$listItem");U(()=>e.focused,t=>{t&&l.value?.scrollIntoView({block:"nearest",inline:"nearest"})});function a(){return e.optionLabel.replace(new RegExp(e.searchValue,"gi"),o=>`<span class="mds-combobox__option--marked">${o}</span>`)}return(t,o)=>(c(),p("li",{ref_key:"$listItem",ref:l,class:q(["mds-combobox__option",{"mds-combobox__option--focused":n.focused}]),role:"option","aria-selected":n.focused.toString(),onMousedown:o[0]||(o[0]=s=>t.$emit("mousedown",s)),innerHTML:a()},null,42,Oe))}},Le={role:"status",class:"mds-visually-hidden"},Me={__name:"ComboboxAriaLive",props:{visibleOptions:{type:Array,default:()=>[]},expanded:{type:Boolean,default:!1},resultsMessage:{type:String},resultsMessage_plural:{type:String}},setup(n){const e=n;U([()=>e.expanded,()=>e.visibleOptions],()=>{t()},{deep:!0});const l=y(null),a=V(function(){const s=e.visibleOptions.length===1?e.resultsMessage:e.resultsMessage_plural;l.value=s.replace("{count}",e.visibleOptions.length)},1400);function t(){l.value=null,e.expanded&&a()}return(o,s)=>(c(),p("div",Le,N(l.value),1))}},ke=["id","value","name","placeholder","aria-controls","aria-expanded","aria-describedby","aria-activedescendant","aria-invalid"],Be={__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:String,default:"[]"},iconpath:{type:String,default:"/assets/icons.svg"},dataAriaInvalid:{type:String,default:""},i18n:{type:String,default:""},describedbyId:{type:String,default:""},minSearchCharacters:{type:Number,default:2},apiUrl:{type:String,default:void 0},apiQueryKey:{type:String,default:"searchText"},apiOptionsPath:{type:String,default:void 0},optionLabelPath:{type:String,default:"label"}},setup(n){const e=n,l=k("$comboInput"),a=k("$targetInputs"),t=y(!1),o=y(null),s=y(e.value),i=y(!1),d=y([]),w=h(()=>{try{return me.parse(e.options)}catch(r){return console.error(r),[]}}),m=h(()=>e.i18n?JSON.parse(e.i18n):{loadingText:"Loading",resultsMessage:"{count} result available",resultsMessage_plural:"{count} results available",clearInput:"clear input"}),f=h(()=>e.apiUrl?d.value:w.value.filter(r=>S(r).toLowerCase().includes(s.value.toLowerCase()))),B=h(()=>`${e.comboboxid}-listbox`);function E(r){if(typeof r=="number"&&r>-1)return`${e.comboboxid}-option-${r}`}const H=h(()=>t.value?"true":"false"),Q=h(()=>e.dataAriaInvalid?"true":"false");function F(r){s.value=S(r),P(r),$(),o.value=null}function P(r){const v=Array.from(a.value?.querySelectorAll("[data-key]"));for(const u of v)u.value=r?L(r,u.getAttribute("data-key")):"",u.dispatchEvent(new Event("input",{bubbles:!0}))}function z(){t.value=!0}function $(){t.value=!1}function T(){s.value="",P()}const J=V(async function(){if(!e.apiUrl||i.value)return;const v=s?.value?.trim();try{i.value=!0;let u=await fetch(`${e.apiUrl}?${e.apiQueryKey}=${encodeURIComponent(v)}`);if(!u.ok)return;u=await u.json();const g=e.apiOptionsPath?L(u,e.apiOptionsPath):u;d.value=g||[]}finally{i.value=!1}},200);function S(r){const v=L(r,e.optionLabelPath);return String(v)}function G(r){o.value=null,s.value=r.target?r.target.value:"",O(),J()}function O(){s.value.length===0&&T(),s.value.length>=e.minSearchCharacters?z():$()}function W(){O()}function X(){T(),l.value?.focus()}function Y(r){F(r)}function Z(r){if(t.value){r.preventDefault();const v=f.value?.[o.value];F(v)}}function ee(){$()}function te(){t.value&&(o.value!==null?o.value=Math.min(o.value+1,f.value.length-1):o.value=0)}function ne(){t.value&&(o.value!==null?o.value=Math.max(o.value-1,0):o.value=f.value.length-1)}function ae(){t.value&&(o.value=0)}function oe(){t.value&&(o.value=f.value.length-1)}function le(){$()}return C("iconPath",e.iconpath),C("loadingText",m.value.loadingText),C("clearInput",m.value.clearInput),(r,v)=>(c(),p("div",{class:q(["mds-combobox",{"mds-combobox--active":t.value}]),onKeydown:[b(te,["down"]),b(ne,["up"]),b(ae,["home"]),b(oe,["end"]),b(le,["esc"]),b(Z,["enter"])]},[x("input",{id:n.comboboxid,ref_key:"$comboInput",ref:l,value:s.value,class:"mds-form-control",autocomplete:"off",type:"text",role:"combobox",name:n.name,placeholder:n.placeholder,"aria-controls":B.value,"aria-expanded":H.value,"aria-autocomplete":"list","aria-describedby":n.describedbyId,"aria-activedescendant":E(o.value),"aria-invalid":Q.value,onInput:G,onChange:O,onBlur:ee,onFocus:W},null,40,ke),s.value.length>0?(c(),A(ge,{key:0,onClear:X})):j("",!0),K(Se,{id:B.value,hidden:!t.value,"aria-labelledby":`${n.comboboxid}-label`,"is-loading":i.value},{default:se(()=>[(c(!0),p(re,null,ie(f.value,(u,g)=>(c(),A(Ce,{id:E(g),key:g,"option-label":S(u),focused:o.value===g,"search-value":s.value,onMousedown:Ee=>Y(u)},null,8,["id","option-label","focused","search-value","onMousedown"]))),128))]),_:1},8,["id","hidden","aria-labelledby","is-loading"]),K(Me,{"visible-options":f.value,expanded:t.value,"results-message":m.value.resultsMessage,"results-message_plural":m.value.resultsMessage_plural},null,8,["visible-options","expanded","results-message","results-message_plural"]),x("span",{ref_key:"$targetInputs",ref:a},[D(r.$slots,"target-inputs")],512)],34))}},Pe=ue(Be,{shadowRoot:!1});export{Pe as default};
|