@aurodesignsystem-dev/auro-formkit 0.0.0-pr1452.1 → 0.0.0-pr1452.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/checkbox/demo/api.js +17 -0
- package/components/checkbox/demo/api.min.js +26 -0
- package/components/checkbox/demo/index.min.js +1 -1
- package/components/checkbox/dist/index.js +1 -1
- package/components/checkbox/dist/registered.js +1 -1
- package/components/combobox/demo/registered.min.js +3 -3
- package/components/combobox/dist/index.js +3 -3
- package/components/combobox/dist/registered.js +3 -3
- package/components/counter/demo/auro-counter-group.min.js +2 -2
- package/components/counter/dist/index.js +13 -240
- package/components/counter/dist/registered.js +1 -1
- package/components/datepicker/demo/accessibility.html +0 -1
- package/components/datepicker/demo/auro-datepicker.min.js +3 -3
- package/components/datepicker/dist/index.js +3 -3
- package/components/datepicker/dist/registered.js +3 -3
- package/components/dropdown/demo/auro-dropdown.min.js +1 -1
- package/components/dropdown/dist/index.js +1 -1
- package/components/dropdown/dist/registered.js +1 -1
- package/components/form/demo/keyboard-behavior.md +38 -0
- package/components/form/demo/pages.json +1 -1
- package/components/form/demo/registerDemoDeps.min.js +257 -257
- package/components/input/demo/api.js +8 -0
- package/components/input/demo/api.min.js +9 -0
- package/components/input/demo/auro-input.min.js +1 -1
- package/components/input/dist/index.js +1 -1
- package/components/input/dist/registered.js +1 -1
- package/components/menu/demo/api.js +29 -0
- package/components/menu/demo/api.min.js +121 -0
- package/components/menu/demo/auro-menuoption.min.js +2289 -0
- package/components/menu/demo/index.min.js +1 -2287
- package/components/radio/demo/index.min.js +1 -1
- package/components/radio/dist/index.js +1 -1
- package/components/radio/dist/registered.js +1 -1
- package/components/select/demo/api.js +39 -0
- package/components/select/demo/api.min.js +83 -0
- package/components/select/demo/getting-started.min.js +1 -31
- package/components/select/demo/registered.min.js +2 -2
- package/components/select/demo/update-active-option.min.js +32 -0
- package/components/select/dist/index.js +2 -2
- package/components/select/dist/registered.js +2 -2
- package/package.json +1 -1
- package/components/combobox/demo/install.html +0 -50
- package/components/combobox/demo/styles.css +0 -974
- package/components/select/demo/keyboardBehavior.html +0 -48
|
@@ -0,0 +1,2289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
const t$2=globalThis,e$5=t$2.ShadowRoot&&(void 0===t$2.ShadyCSS||t$2.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$6=Symbol(),o$5=new WeakMap;let n$4 = class n{constructor(t,e,o){if(this._$cssResult$=true,o!==s$6)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$5&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$5.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$5.set(s,t));}return t}toString(){return this.cssText}};const r$2=t=>new n$4("string"==typeof t?t:t+"",void 0,s$6),i$6=(t,...e)=>{const o=1===t.length?t[0]:e.reduce((e,s,o)=>e+(t=>{if(true===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[o+1],t[0]);return new n$4(o,t,s$6)},S$1=(s,o)=>{if(e$5)s.adoptedStyleSheets=o.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const e of o){const o=document.createElement("style"),n=t$2.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$5?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$2(e)})(t):t;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @license
|
|
10
|
+
* Copyright 2017 Google LLC
|
|
11
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
12
|
+
*/const{is:i$5,defineProperty:e$4,getOwnPropertyDescriptor:h$1,getOwnPropertyNames:r$1,getOwnPropertySymbols:o$4,getPrototypeOf:n$3}=Object,a$2=globalThis,c$1=a$2.trustedTypes,l$2=c$1?c$1.emptyScript:"",p$2=a$2.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$3={toAttribute(t,s){switch(s){case Boolean:t=t?l$2:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f$2=(t,s)=>!i$5(t,s),b$1={attribute:true,type:String,converter:u$3,reflect:false,useDefault:false,hasChanged:f$2};Symbol.metadata??=Symbol("metadata"),a$2.litPropertyMetadata??=new WeakMap;let y$2 = class y extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=b$1){if(s.state&&(s.attribute=false),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=true),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e$4(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h$1(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get:e,set(s){const h=e?.call(this);r?.call(this,s),this.requestUpdate(t,h,i);},configurable:true,enumerable:true}}static getPropertyOptions(t){return this.elementProperties.get(t)??b$1}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$3(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=true,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...r$1(t),...o$4(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$2(s));}else void 0!==s&&i.push(c$2(s));return i}static _$Eu(t,s){const i=s.attribute;return false===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=false,this.hasUpdated=false,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S$1(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(true),this._$EO?.forEach(t=>t.hostConnected?.());}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.());}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$ET(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&true===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:u$3).toAttribute(s,i.type);this._$Em=t,null==h?this.removeAttribute(e):this.setAttribute(e,h),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),h="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u$3;this._$Em=e;const r=h.fromAttribute(s,t.type);this[e]=r??this._$Ej?.get(e)??r,this._$Em=null;}}requestUpdate(t,s,i,e=false,h){if(void 0!==t){const r=this.constructor;if(false===e&&(h=this[t]),i??=r.getPropertyOptions(t),!((i.hasChanged??f$2)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(r._$Eu(t,i))))return;this.C(t,s,i);} false===this.isUpdatePending&&(this._$ES=this._$EP());}C(t,s,{useDefault:i,reflect:e,wrapped:h},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??s??this[t]),true!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),true===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t));}async _$EP(){this.isUpdatePending=true;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t){const{wrapped:t}=i,e=this[s];true!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e);}}let t=false;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(s)):this._$EM();}catch(s){throw t=false,this._$EM(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=true,this.firstUpdated(t)),this.updated(t);}_$EM(){this._$AL=new Map,this.isUpdatePending=false;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return true}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM();}updated(t){}firstUpdated(t){}};y$2.elementStyles=[],y$2.shadowRootOptions={mode:"open"},y$2[d$1("elementProperties")]=new Map,y$2[d$1("finalized")]=new Map,p$2?.({ReactiveElement:y$2}),(a$2.reactiveElementVersions??=[]).push("2.1.2");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @license
|
|
16
|
+
* Copyright 2017 Google LLC
|
|
17
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
18
|
+
*/
|
|
19
|
+
const t$1=globalThis,i$4=t=>t,s$5=t$1.trustedTypes,e$3=s$5?s$5.createPolicy("lit-html",{createHTML:t=>t}):void 0,h="$lit$",o$3=`lit$${Math.random().toFixed(9).slice(2)}$`,n$2="?"+o$3,r=`<${n$2}>`,l$1=document,c=()=>l$1.createComment(""),a$1=t=>null===t||"object"!=typeof t&&"function"!=typeof t,u$2=Array.isArray,d=t=>u$2(t)||"function"==typeof t?.[Symbol.iterator],f$1="[ \t\n\f\r]",v=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,_$1=/-->/g,m$1=/>/g,p$1=RegExp(`>|${f$1}(?:([^\\s"'>=/]+)(${f$1}*=${f$1}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),g$1=/'/g,$=/"/g,y$1=/^(?:script|style|textarea|title)$/i,x=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),b=x(1),E=Symbol.for("lit-noChange"),A=Symbol.for("lit-nothing"),C=new WeakMap,P=l$1.createTreeWalker(l$1,129);function V(t,i){if(!u$2(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==e$3?e$3.createHTML(i):i}const N=(t,i)=>{const s=t.length-1,e=[];let n,l=2===i?"<svg>":3===i?"<math>":"",c=v;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,f=0;for(;f<s.length&&(c.lastIndex=f,u=c.exec(s),null!==u);)f=c.lastIndex,c===v?"!--"===u[1]?c=_$1:void 0!==u[1]?c=m$1:void 0!==u[2]?(y$1.test(u[2])&&(n=RegExp("</"+u[2],"g")),c=p$1):void 0!==u[3]&&(c=p$1):c===p$1?">"===u[0]?(c=n??v,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?p$1:'"'===u[3]?$:g$1):c===$||c===g$1?c=p$1:c===_$1||c===m$1?c=v:(c=p$1,n=void 0);const x=c===p$1&&t[i+1].startsWith("/>")?" ":"";l+=c===v?s+r:d>=0?(e.push(a),s.slice(0,d)+h+s.slice(d)+o$3+x):s+o$3+(-2===d?i:x);}return [V(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),e]};class S{constructor({strings:t,_$litType$:i},e){let r;this.parts=[];let l=0,a=0;const u=t.length-1,d=this.parts,[f,v]=N(t,i);if(this.el=S.createElement(f,e),P.currentNode=this.el.content,2===i||3===i){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=P.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(h)){const i=v[a++],s=r.getAttribute(t).split(o$3),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:l,name:e[2],strings:s,ctor:"."===e[1]?I:"?"===e[1]?L:"@"===e[1]?z$1:H}),r.removeAttribute(t);}else t.startsWith(o$3)&&(d.push({type:6,index:l}),r.removeAttribute(t));if(y$1.test(r.tagName)){const t=r.textContent.split(o$3),i=t.length-1;if(i>0){r.textContent=s$5?s$5.emptyScript:"";for(let s=0;s<i;s++)r.append(t[s],c()),P.nextNode(),d.push({type:2,index:++l});r.append(t[i],c());}}}else if(8===r.nodeType)if(r.data===n$2)d.push({type:2,index:l});else {let t=-1;for(;-1!==(t=r.data.indexOf(o$3,t+1));)d.push({type:7,index:l}),t+=o$3.length-1;}l++;}}static createElement(t,i){const s=l$1.createElement("template");return s.innerHTML=t,s}}function M$1(t,i,s=t,e){if(i===E)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=a$1(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(false),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=M$1(t,h._$AS(t,i.values),h,e)),i}class R{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??l$1).importNode(i,true);P.currentNode=e;let h=P.nextNode(),o=0,n=0,r=s[0];for(;void 0!==r;){if(o===r.index){let i;2===r.type?i=new k$1(h,h.nextSibling,this,t):1===r.type?i=new r.ctor(h,r.name,r.strings,this,t):6===r.type&&(i=new Z(h,this,t)),this._$AV.push(i),r=s[++n];}o!==r?.index&&(h=P.nextNode(),o++);}return P.currentNode=l$1,e}p(t){let i=0;for(const s of this._$AV) void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}let k$1 = class k{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=A,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??true;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=M$1(this,t,i),a$1(t)?t===A||null==t||""===t?(this._$AH!==A&&this._$AR(),this._$AH=A):t!==this._$AH&&t!==E&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):d(t)?this.k(t):this._(t);}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t));}_(t){this._$AH!==A&&a$1(this._$AH)?this._$AA.nextSibling.data=t:this.T(l$1.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=S.createElement(V(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new R(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=C.get(t.strings);return void 0===i&&C.set(t.strings,i=new S(t)),i}k(t){u$2(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new k(this.O(c()),this.O(c()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,s){for(this._$AP?.(false,true,s);t!==this._$AB;){const s=i$4(t).nextSibling;i$4(t).remove(),t=s;}}setConnected(t){ void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}};class H{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=A,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=A;}_$AI(t,i=this,s,e){const h=this.strings;let o=false;if(void 0===h)t=M$1(this,t,i,0),o=!a$1(t)||t!==this._$AH&&t!==E,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=M$1(this,e[s+n],i,n),r===E&&(r=this._$AH[n]),o||=!a$1(r)||r!==this._$AH[n],r===A?t=A:t!==A&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===A?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class I extends H{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===A?void 0:t;}}class L extends H{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==A);}}let z$1 = class z extends H{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=M$1(this,t,i,0)??A)===E)return;const s=this._$AH,e=t===A&&s!==A||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==A&&(s===A||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}};class Z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){M$1(this,t);}}const B=t$1.litHtmlPolyfillSupport;B?.(S,k$1),(t$1.litHtmlVersions??=[]).push("3.3.2");const D=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new k$1(i.insertBefore(c(),t),t,void 0,s??{});}return h._$AI(t),h};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @license
|
|
23
|
+
* Copyright 2017 Google LLC
|
|
24
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
25
|
+
*/const s$4=globalThis;let i$3 = class i extends y$2{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0;}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=D(r,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(true);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(false);}render(){return E}};i$3._$litElement$=true,i$3["finalized"]=true,s$4.litElementHydrateSupport?.({LitElement:i$3});const o$2=s$4.litElementPolyfillSupport;o$2?.({LitElement:i$3});(s$4.litElementVersions??=[]).push("4.2.2");
|
|
26
|
+
|
|
27
|
+
var styleCss$1 = i$6`:focus:not(:focus-visible){outline:3px solid transparent}.body-default{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-default-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-default-font-size, 1rem);line-height:var(--wcss-body-default-line-height, 1.5rem)}.body-default-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-default-emphasized-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-default-emphasized-font-size, 1rem);line-height:var(--wcss-body-default-emphasized-line-height, 1.5rem)}.body-lg{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-lg-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-lg-font-size, 1.125rem);line-height:var(--wcss-body-lg-line-height, 1.625rem)}.body-lg-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-lg-emphasized-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-lg-emphasized-font-size, 1.125rem);line-height:var(--wcss-body-lg-emphasized-line-height, 1.625rem)}.body-sm{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-sm-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-sm-font-size, 0.875rem);line-height:var(--wcss-body-sm-line-height, 1.25rem)}.body-sm-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-sm-emphasized-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-sm-emphasized-font-size, 0.875rem);line-height:var(--wcss-body-sm-emphasized-line-height, 1.25rem)}.body-xs{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-xs-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-xs-font-size, 0.75rem);line-height:var(--wcss-body-xs-line-height, 1rem)}.body-xs-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-xs-emphasized-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-xs-emphasized-font-size, 0.75rem);line-height:var(--wcss-body-xs-emphasized-line-height, 1rem)}.body-2xs{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-2xs-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-2xs-font-size, 0.625rem);line-height:var(--wcss-body-2xs-line-height, 0.875rem)}.body-2xs-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-2xs-emphasized-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-2xs-emphasized-font-size, 0.625rem);line-height:var(--wcss-body-2xs-emphasized-line-height, 0.875rem)}.display-2xl{font-family:var(--wcss-display-2xl-family, "AS Circular"),var(--wcss-display-2xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-display-2xl-weight, 300);line-height:var(--wcss-display-2xl-line-height, 1.3);font-size:var(--wcss-display-2xl-font-size, clamp(3.5rem, 6vw, 5.375rem));letter-spacing:var(--wcss-display-2xl-letter-spacing, 0)}.display-xl{font-family:var(--wcss-display-xl-family, "AS Circular"),var(--wcss-display-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-display-xl-weight, 300);line-height:var(--wcss-display-xl-line-height, 1.3);font-size:var(--wcss-display-xl-font-size, clamp(3rem, 5.3333333333vw, 4.5rem));letter-spacing:var(--wcss-display-xl-letter-spacing, 0)}.display-lg{font-family:var(--wcss-display-lg-family, "AS Circular"),var(--wcss-display-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-display-lg-weight, 300);line-height:var(--wcss-display-lg-line-height, 1.3);font-size:var(--wcss-display-lg-font-size, clamp(2.75rem, 4.6666666667vw, 4rem));letter-spacing:var(--wcss-display-lg-letter-spacing, 0)}.display-md{font-family:var(--wcss-display-md-family, "AS Circular"),var(--wcss-display-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-display-md-weight, 300);line-height:var(--wcss-display-md-line-height, 1.3);font-size:var(--wcss-display-md-font-size, clamp(2.5rem, 4vw, 3.5rem));letter-spacing:var(--wcss-display-md-letter-spacing, 0)}.display-sm{font-family:var(--wcss-display-sm-family, "AS Circular"),var(--wcss-display-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-display-sm-weight, 300);line-height:var(--wcss-display-sm-line-height, 1.3);font-size:var(--wcss-display-sm-font-size, clamp(2rem, 3.6666666667vw, 3rem));letter-spacing:var(--wcss-display-sm-letter-spacing, 0)}.display-xs{font-family:var(--wcss-display-xs-family, "AS Circular"),var(--wcss-display-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-display-xs-weight, 300);line-height:var(--wcss-display-xs-line-height, 1.3);font-size:var(--wcss-display-xs-font-size, clamp(1.75rem, 3vw, 2.375rem));letter-spacing:var(--wcss-display-xs-letter-spacing, 0)}.heading-xl{font-family:var(--wcss-heading-xl-family, "AS Circular"),var(--wcss-heading-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-heading-xl-weight, 300);line-height:var(--wcss-heading-xl-line-height, 1.3);font-size:var(--wcss-heading-xl-font-size, clamp(2rem, 3vw, 2.5rem));letter-spacing:var(--wcss-heading-xl-letter-spacing, 0)}.heading-lg{font-family:var(--wcss-heading-lg-family, "AS Circular"),var(--wcss-heading-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-heading-lg-weight, 300);line-height:var(--wcss-heading-lg-line-height, 1.3);font-size:var(--wcss-heading-lg-font-size, clamp(1.75rem, 2.6666666667vw, 2.25rem));letter-spacing:var(--wcss-heading-lg-letter-spacing, 0)}.heading-md{font-family:var(--wcss-heading-md-family, "AS Circular"),var(--wcss-heading-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-heading-md-weight, 300);line-height:var(--wcss-heading-md-line-height, 1.3);font-size:var(--wcss-heading-md-font-size, clamp(1.625rem, 2.3333333333vw, 1.75rem));letter-spacing:var(--wcss-heading-md-letter-spacing, 0)}.heading-sm{font-family:var(--wcss-heading-sm-family, "AS Circular"),var(--wcss-heading-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-heading-sm-weight, 300);line-height:var(--wcss-heading-sm-line-height, 1.3);font-size:var(--wcss-heading-sm-font-size, clamp(1.375rem, 2vw, 1.5rem));letter-spacing:var(--wcss-heading-sm-letter-spacing, 0)}.heading-xs{font-family:var(--wcss-heading-xs-family, "AS Circular"),var(--wcss-heading-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-heading-xs-weight, 300);line-height:var(--wcss-heading-xs-line-height, 1.3);font-size:var(--wcss-heading-xs-font-size, clamp(1.25rem, 1.6666666667vw, 1.25rem));letter-spacing:var(--wcss-heading-xs-letter-spacing, 0)}.heading-2xs{font-family:var(--wcss-heading-2xs-family, "AS Circular"),var(--wcss-heading-2xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-heading-2xs-weight, 300);line-height:var(--wcss-heading-2xs-line-height, 1.3);font-size:var(--wcss-heading-2xs-font-size, clamp(1.125rem, 1.5vw, 1.125rem));letter-spacing:var(--wcss-heading-2xs-letter-spacing, 0)}.accent-2xl{font-family:var(--wcss-accent-2xl-family, "Good OT"),var(--wcss-accent-2xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-accent-2xl-weight, 450);line-height:var(--wcss-accent-2xl-line-height, 1);font-size:var(--wcss-accent-2xl-font-size, clamp(2rem, 3.1666666667vw, 2.375rem));letter-spacing:var(--wcss-accent-2xl-letter-spacing, 0.05em);text-transform:uppercase}.accent-xl{font-family:var(--wcss-accent-xl-family, "Good OT"),var(--wcss-accent-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-accent-xl-weight, 450);line-height:var(--wcss-accent-xl-line-height, 1.3);font-size:var(--wcss-accent-xl-font-size, clamp(1.625rem, 2.3333333333vw, 2rem));letter-spacing:var(--wcss-accent-xl-letter-spacing, 0.05em);text-transform:uppercase}.accent-lg{font-family:var(--wcss-accent-lg-family, "Good OT"),var(--wcss-accent-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-accent-lg-weight, 450);line-height:var(--wcss-accent-lg-line-height, 1.3);font-size:var(--wcss-accent-lg-font-size, clamp(1.5rem, 2.1666666667vw, 1.75rem));letter-spacing:var(--wcss-accent-lg-letter-spacing, 0.05em);text-transform:uppercase}.accent-md{font-family:var(--wcss-accent-md-family, "Good OT"),var(--wcss-accent-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-accent-md-weight, 500);line-height:var(--wcss-accent-md-line-height, 1.3);font-size:var(--wcss-accent-md-font-size, clamp(1.375rem, 1.8333333333vw, 1.5rem));letter-spacing:var(--wcss-accent-md-letter-spacing, 0.05em);text-transform:uppercase}.accent-sm{font-family:var(--wcss-accent-sm-family, "Good OT"),var(--wcss-accent-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-accent-sm-weight, 500);line-height:var(--wcss-accent-sm-line-height, 1.3);font-size:var(--wcss-accent-sm-font-size, clamp(1.125rem, 1.5vw, 1.25rem));letter-spacing:var(--wcss-accent-sm-letter-spacing, 0.05em);text-transform:uppercase}.accent-xs{font-family:var(--wcss-accent-xs-family, "Good OT"),var(--wcss-accent-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-accent-xs-weight, 500);line-height:var(--wcss-accent-xs-line-height, 1.3);font-size:var(--wcss-accent-xs-font-size, clamp(1rem, 1.3333333333vw, 1rem));letter-spacing:var(--wcss-accent-xs-letter-spacing, 0.1em);text-transform:uppercase}.accent-2xs{font-family:var(--wcss-accent-2xs-family, "Good OT"),var(--wcss-accent-2xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-accent-2xs-weight, 450);line-height:var(--wcss-accent-2xs-line-height, 1.3);font-size:var(--wcss-accent-2xs-font-size, clamp(0.875rem, 1.1666666667vw, 0.875rem));letter-spacing:var(--wcss-accent-2xs-letter-spacing, 0.1em);text-transform:uppercase}:host{display:block;line-height:0;overflow-y:auto}:host .menuWrapper{box-sizing:border-box;display:flex;flex-direction:column;width:100%;margin:0;padding:0}:host ::slotted(hr){box-sizing:content-box !important;height:0 !important;overflow:visible !important;margin:var(--ds-size-100, 0.5rem) 0 !important;border-width:0 !important;border-top-width:1px !important;border-top-style:solid !important}:host [loadingplaceholder].empty{opacity:0;position:absolute}:host [loadingplaceholder] slot[name=loadingIcon]{vertical-align:middle;display:inline-block;margin-bottom:var(--ds-size-25, 0.125rem)}:host [loadingplaceholder] slot[name=loadingIcon]::slotted(*){margin-right:var(--ds-size-150, 0.75rem)}:host([root]) .menuWrapper.lg{padding:var(--ds-size-150, 0.75rem);gap:var(--ds-size-50, 0.25rem)}:host([root]) .menuWrapper.xl{padding:var(--ds-size-200, 1rem);gap:var(--ds-size-100, 0.5rem)}`;
|
|
28
|
+
|
|
29
|
+
var colorCss$1 = i$6`:host ::slotted(hr){border-top-color:var(--ds-auro-menu-divider-color)}[loadingplaceholder] slot[name=loadingIcon]{color:var(--ds-auro-menu-loader-color)}[loadingplaceholder] slot[name=loadingText]{color:var(--ds-auro-menu-loader-text-color)}`;
|
|
30
|
+
|
|
31
|
+
var tokensCss = i$6`:host{--ds-auro-menu-divider-color: var(--ds-basic-color-border-divider, rgba(0, 0, 0, 0.15));--ds-auro-menu-loader-color: var(--ds-basic-color-brand-primary, #01426a);--ds-auro-menu-loader-text-color: var(--ds-basic-color-texticon-default, #2a2a2a);--ds-auro-menuoption-container-color: transparent;--ds-auro-menuoption-container-border-color: var(--ds-auro-menuoption-container-color);--ds-auro-menuoption-icon-color: transparent;--ds-auro-menuoption-text-color: var(--ds-basic-color-texticon-default, #2a2a2a)}`;
|
|
32
|
+
|
|
33
|
+
class AuroElement extends i$3 {
|
|
34
|
+
static get properties() {
|
|
35
|
+
return {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Defines the language of an element.
|
|
39
|
+
* @default {'default'}
|
|
40
|
+
*/
|
|
41
|
+
layout: {
|
|
42
|
+
type: String,
|
|
43
|
+
attribute: "layout",
|
|
44
|
+
reflect: true
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
shape: {
|
|
48
|
+
type: String,
|
|
49
|
+
attribute: "shape",
|
|
50
|
+
reflect: true
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
size: {
|
|
54
|
+
type: String,
|
|
55
|
+
attribute: "size",
|
|
56
|
+
reflect: true
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
onDark: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
attribute: "ondark",
|
|
62
|
+
reflect: true
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Returns true if the element has focus.
|
|
69
|
+
* @private
|
|
70
|
+
* @returns {boolean} - Returns true if the element has focus.
|
|
71
|
+
*/
|
|
72
|
+
get componentHasFocus() {
|
|
73
|
+
return this.matches(':focus') || this.matches(':focus-within');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
resetShapeClasses() {
|
|
77
|
+
const wrapper = this.shadowRoot.querySelector('.wrapper');
|
|
78
|
+
|
|
79
|
+
if (wrapper) {
|
|
80
|
+
wrapper.classList.forEach((className) => {
|
|
81
|
+
if (className.startsWith('shape-')) {
|
|
82
|
+
wrapper.classList.remove(className);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
if (this.shape && this.size) {
|
|
87
|
+
wrapper.classList.add(`shape-${this.shape.toLowerCase()}-${this.size.toLowerCase()}`);
|
|
88
|
+
} else {
|
|
89
|
+
wrapper.classList.add('shape-none');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
resetLayoutClasses() {
|
|
96
|
+
if (this.layout) {
|
|
97
|
+
const wrapper = this.shadowRoot.querySelector('.wrapper');
|
|
98
|
+
|
|
99
|
+
if (wrapper) {
|
|
100
|
+
wrapper.classList.forEach((className) => {
|
|
101
|
+
if (className.startsWith('layout-')) {
|
|
102
|
+
wrapper.classList.remove(className);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
wrapper.classList.add(`layout-${this.layout.toLowerCase()}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
updateComponentArchitecture() {
|
|
112
|
+
this.resetLayoutClasses();
|
|
113
|
+
this.resetShapeClasses();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
updated(changedProperties) {
|
|
117
|
+
if (changedProperties.has('layout') || changedProperties.has('shape') || changedProperties.has('size')) {
|
|
118
|
+
this.updateComponentArchitecture();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Try to render the defined `this.layout` layout. If that fails, fall back to the default layout.
|
|
123
|
+
// This will catch if an invalid layout value is passed in and render the default layout if so.
|
|
124
|
+
render() {
|
|
125
|
+
try {
|
|
126
|
+
return this.renderLayout();
|
|
127
|
+
} catch (error) {
|
|
128
|
+
// failed to get the defined layout
|
|
129
|
+
console.error('Failed to get the defined layout - using the default layout', error); // eslint-disable-line no-console
|
|
130
|
+
|
|
131
|
+
// fallback to the default layout
|
|
132
|
+
return this.getLayout('default');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @license
|
|
139
|
+
* Copyright 2021 Google LLC
|
|
140
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
141
|
+
*/
|
|
142
|
+
let s$3 = class s extends Event{constructor(s,t,e,o){super("context-request",{bubbles:true,composed:true}),this.context=s,this.contextTarget=t,this.callback=e,this.subscribe=o??false;}};
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @license
|
|
146
|
+
* Copyright 2021 Google LLC
|
|
147
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
148
|
+
*/
|
|
149
|
+
function n$1(n){return n}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @license
|
|
153
|
+
* Copyright 2021 Google LLC
|
|
154
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
155
|
+
*/let s$2 = class s{constructor(t,s,i,h){if(this.subscribe=false,this.provided=false,this.value=void 0,this.t=(t,s)=>{this.unsubscribe&&(this.unsubscribe!==s&&(this.provided=false,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=t,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=true,this.callback&&this.callback(t,s)),this.unsubscribe=s;},this.host=t,void 0!==s.context){const t=s;this.context=t.context,this.callback=t.callback,this.subscribe=t.subscribe??false;}else this.context=s,this.callback=i,this.subscribe=h??false;this.host.addController(this);}hostConnected(){this.dispatchRequest();}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0);}dispatchRequest(){this.host.dispatchEvent(new s$3(this.context,this.host,this.t,this.subscribe));}};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @license
|
|
159
|
+
* Copyright 2021 Google LLC
|
|
160
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
161
|
+
*/
|
|
162
|
+
let s$1 = class s{get value(){return this.o}set value(s){this.setValue(s);}setValue(s,t=false){const i=t||!Object.is(s,this.o);this.o=s,i&&this.updateObservers();}constructor(s){this.subscriptions=new Map,this.updateObservers=()=>{for(const[s,{disposer:t}]of this.subscriptions)s(this.o,t);},void 0!==s&&(this.value=s);}addCallback(s,t,i){if(!i)return void s(this.value);this.subscriptions.has(s)||this.subscriptions.set(s,{disposer:()=>{this.subscriptions.delete(s);},consumerHost:t});const{disposer:h}=this.subscriptions.get(s);s(this.value,h);}clearCallbacks(){this.subscriptions.clear();}};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* @license
|
|
166
|
+
* Copyright 2021 Google LLC
|
|
167
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
168
|
+
*/let e$2 = class e extends Event{constructor(t,s){super("context-provider",{bubbles:true,composed:true}),this.context=t,this.contextTarget=s;}};let i$2 = class i extends s$1{constructor(s,e,i){super(void 0!==e.context?e.initialValue:i),this.onContextRequest=t=>{if(t.context!==this.context)return;const s=t.contextTarget??t.composedPath()[0];s!==this.host&&(t.stopPropagation(),this.addCallback(t.callback,s,t.subscribe));},this.onProviderRequest=s=>{if(s.context!==this.context)return;if((s.contextTarget??s.composedPath()[0])===this.host)return;const e=new Set;for(const[s,{consumerHost:i}]of this.subscriptions)e.has(s)||(e.add(s),i.dispatchEvent(new s$3(this.context,i,s,true)));s.stopPropagation();},this.host=s,void 0!==e.context?this.context=e.context:this.context=e,this.attachListeners(),this.host.addController?.(this);}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest);}hostConnected(){this.host.dispatchEvent(new e$2(this.context,this.host));}};
|
|
169
|
+
|
|
170
|
+
/* eslint-disable */
|
|
171
|
+
|
|
172
|
+
class MenuService {
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* PROPERTIES AND GETTERS
|
|
176
|
+
*/
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Gets the list of registered menu options.
|
|
180
|
+
* @returns {AuroMenuOption[]}
|
|
181
|
+
*/
|
|
182
|
+
get menuOptions() {
|
|
183
|
+
return this._menuOptions;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Gets the currently highlighted option.
|
|
188
|
+
* @returns {AuroMenuOption|null}
|
|
189
|
+
*/
|
|
190
|
+
get highlightedOption() {
|
|
191
|
+
return this._menuOptions[this.highlightedIndex] || null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Gets the current value(s) of the selected option(s).
|
|
196
|
+
* @returns {string|string[]|undefined}
|
|
197
|
+
*/
|
|
198
|
+
get currentValue() {
|
|
199
|
+
const values = (this.selectedOptions || []).map(option => option.value);
|
|
200
|
+
return this.multiSelect ? values : values[0];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Gets the label(s) of the currently selected option(s).
|
|
205
|
+
* @returns {string}
|
|
206
|
+
*/
|
|
207
|
+
get currentLabel() {
|
|
208
|
+
const labels = (this.selectedOptions || []).map(option => option.textContent);
|
|
209
|
+
return this.multiSelect ? labels.join(", ") : labels[0] || '';
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Gets the string representation of the current value(s).
|
|
214
|
+
* For multi-select, this is a JSON stringified array.
|
|
215
|
+
* @returns {string|undefined}
|
|
216
|
+
*/
|
|
217
|
+
get stringValue() {
|
|
218
|
+
const { currentValue } = this;
|
|
219
|
+
|
|
220
|
+
if (Array.isArray(currentValue)) {
|
|
221
|
+
if (currentValue.length > 0) {
|
|
222
|
+
return JSON.stringify(currentValue);
|
|
223
|
+
}
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (typeof currentValue === 'string') {
|
|
228
|
+
if (currentValue.length > 0) {
|
|
229
|
+
return currentValue;
|
|
230
|
+
}
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Future: handle other types here (e.g., number, object, etc.)
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Gets the key(s) of the currently selected option(s).
|
|
240
|
+
* @returns {string|string[]|undefined}
|
|
241
|
+
*/
|
|
242
|
+
get currentKeys() {
|
|
243
|
+
const keys = (this.selectedOptions || []).map(option => option.key);
|
|
244
|
+
return this.multiSelect ? keys : keys[0];
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* CONSTRUCTOR
|
|
249
|
+
*/
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Creates a new MenuService instance.
|
|
253
|
+
* @param {Object} options - The options object.
|
|
254
|
+
* @param {AuroMenu} options.host - The host element that this service will control. Required.
|
|
255
|
+
* @throws {Error} If the host is not provided.
|
|
256
|
+
*/
|
|
257
|
+
constructor({ host } = {}) {
|
|
258
|
+
|
|
259
|
+
// Ensure a host was passed
|
|
260
|
+
if (!host) {
|
|
261
|
+
throw new Error("MenuService requires a host element.");
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Attach the service to the host
|
|
265
|
+
this.host = host;
|
|
266
|
+
this.host.addController(this);
|
|
267
|
+
|
|
268
|
+
// Set default properties
|
|
269
|
+
this.size = undefined;
|
|
270
|
+
this.shape = undefined;
|
|
271
|
+
this.noCheckmark = undefined;
|
|
272
|
+
this.disabled = undefined;
|
|
273
|
+
this.matchWord = undefined;
|
|
274
|
+
this.multiSelect = undefined;
|
|
275
|
+
this.allowDeselect = undefined;
|
|
276
|
+
this.selectAllMatchingOptions = undefined;
|
|
277
|
+
|
|
278
|
+
this.highlightedIndex = -1;
|
|
279
|
+
|
|
280
|
+
this._menuOptions = [];
|
|
281
|
+
this._subscribers = [];
|
|
282
|
+
this.internalUpdateInProgress = false;
|
|
283
|
+
this.selectedOptions = [];
|
|
284
|
+
this._pendingValue = null;
|
|
285
|
+
this._pendingRetryScheduled = false;
|
|
286
|
+
this._pendingRetryCount = 0;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* PROPERTY SYNCING
|
|
291
|
+
*/
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Handles host updates.
|
|
295
|
+
* This is a lit reactive lifecycle method.
|
|
296
|
+
* This comes from the Lit controller interface provided by adding this service as a controller to the host.
|
|
297
|
+
* See constructor for `this.host.addController(this)`
|
|
298
|
+
* You can read more about Lit reactive controllers here: https://lit.dev/docs/composition/controllers/
|
|
299
|
+
*/
|
|
300
|
+
hostUpdated() {
|
|
301
|
+
|
|
302
|
+
// Reset selection if multiSelect mode changes
|
|
303
|
+
if (this.host.multiSelect !== this.multiSelect) {
|
|
304
|
+
this.selectedOptions = [];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// Update properties on host update
|
|
308
|
+
this.setProperties({
|
|
309
|
+
size: this.host.size,
|
|
310
|
+
shape: this.host.shape,
|
|
311
|
+
noCheckmark: this.host.noCheckmark,
|
|
312
|
+
disabled: this.host.disabled,
|
|
313
|
+
matchWord: this.host.matchWord,
|
|
314
|
+
multiSelect: this.host.multiSelect,
|
|
315
|
+
allowDeselect: this.host.allowDeselect,
|
|
316
|
+
selectAllMatchingOptions: this.host.selectAllMatchingOptions
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Handles host disconnection and memory cleanup.
|
|
322
|
+
*/
|
|
323
|
+
hostDisconnected() {
|
|
324
|
+
this._subscribers = [];
|
|
325
|
+
this._menuOptions = [];
|
|
326
|
+
this._pendingValue = null;
|
|
327
|
+
this._pendingRetryScheduled = false;
|
|
328
|
+
this._pendingRetryCount = 0;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Sets a property value if it exists on the instance and the value has changed.
|
|
333
|
+
* @param {string} property
|
|
334
|
+
* @param {any} value
|
|
335
|
+
*/
|
|
336
|
+
setProperty(property, value) {
|
|
337
|
+
|
|
338
|
+
// Only update if we are tracking the property in this service
|
|
339
|
+
if (this.hasOwnProperty(property)) {
|
|
340
|
+
|
|
341
|
+
// Check if the value has changed
|
|
342
|
+
const valueChanged = this[property] !== value;
|
|
343
|
+
|
|
344
|
+
// Update and notify if changed
|
|
345
|
+
if (valueChanged) {
|
|
346
|
+
this[property] = value;
|
|
347
|
+
this.notify({ property, value });
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Sets multiple properties on the instance.
|
|
354
|
+
* @param {Object} properties - Key-value pairs of properties to set.
|
|
355
|
+
*/
|
|
356
|
+
setProperties(properties) {
|
|
357
|
+
for (const [key, value] of Object.entries(properties)) {
|
|
358
|
+
this.setProperty(key, value);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* MENU OPTION HIGHLIGHTING
|
|
364
|
+
*/
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Highlights the next active option in the menu.
|
|
368
|
+
*/
|
|
369
|
+
highlightNext() {
|
|
370
|
+
this.moveHighlightedOption("next");
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Highlights the previous active option in the menu.
|
|
375
|
+
*/
|
|
376
|
+
highlightPrevious() {
|
|
377
|
+
this.moveHighlightedOption("previous");
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Moves the highlighted option in the specified direction.
|
|
382
|
+
* @param {string} direction - The direction to move the highlight ("next" or "previous").
|
|
383
|
+
*/
|
|
384
|
+
moveHighlightedOption(direction) {
|
|
385
|
+
|
|
386
|
+
// Get the active options
|
|
387
|
+
const activeOptions = this._menuOptions.filter(option => option.isActive);
|
|
388
|
+
|
|
389
|
+
// Get the currently active option
|
|
390
|
+
const currentActiveOption = activeOptions[activeOptions.indexOf(this.highlightedOption)];
|
|
391
|
+
|
|
392
|
+
// Determine the new index based on the currently active option and direction
|
|
393
|
+
let newIndex = currentActiveOption
|
|
394
|
+
? direction === "previous"
|
|
395
|
+
? activeOptions.indexOf(currentActiveOption) - 1
|
|
396
|
+
: activeOptions.indexOf(currentActiveOption) + 1
|
|
397
|
+
: direction === "previous"
|
|
398
|
+
? activeOptions.length - 1
|
|
399
|
+
: 0;
|
|
400
|
+
|
|
401
|
+
// Wrap around the index if needed
|
|
402
|
+
newIndex = newIndex < 0 ? activeOptions.length - 1 : newIndex >= activeOptions.length ? 0 : newIndex;
|
|
403
|
+
|
|
404
|
+
// Get the new active option and set it as highlighted
|
|
405
|
+
const newActiveOption = activeOptions[newIndex];
|
|
406
|
+
this.setHighlightedOption(newActiveOption);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Sets the highlighted index to the specified option.
|
|
411
|
+
* @param {AuroMenuOption} option - The option to highlight.
|
|
412
|
+
*/
|
|
413
|
+
setHighlightedOption(option) {
|
|
414
|
+
|
|
415
|
+
if (!option) return;
|
|
416
|
+
|
|
417
|
+
// Get the index of the option to highlight
|
|
418
|
+
const index = this._menuOptions.indexOf(option);
|
|
419
|
+
|
|
420
|
+
// Update highlighted index
|
|
421
|
+
this.highlightedIndex = index;
|
|
422
|
+
|
|
423
|
+
// Notify subscribers of highlight change
|
|
424
|
+
this.notify({ type: 'highlightChange', option, index: this.highlightedIndex });
|
|
425
|
+
|
|
426
|
+
// Dispatch the change event
|
|
427
|
+
this.dispatchChangeEvent('auroMenu-activatedOption', option);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Sets the highlighted option to the option at the specified index if it exists.
|
|
432
|
+
* @param {number} index
|
|
433
|
+
*/
|
|
434
|
+
setHighlightedIndex(index) {
|
|
435
|
+
const option = this._menuOptions[index] || null;
|
|
436
|
+
this.setHighlightedOption(option);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Selects the currently highlighted option.
|
|
441
|
+
*/
|
|
442
|
+
selectHighlightedOption() {
|
|
443
|
+
if (this.highlightedOption) {
|
|
444
|
+
this.toggleOption(this.highlightedOption);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* SELECTION AND DESELECTION METHODS
|
|
450
|
+
*/
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Selects one or more options in a batch operation
|
|
454
|
+
* @param {AuroMenuOption|AuroMenuOption[]} options - Single option or array of options to select
|
|
455
|
+
*/
|
|
456
|
+
selectOptions(options) {
|
|
457
|
+
let optionsToSelect = Array.isArray(options) ? options : [options];
|
|
458
|
+
|
|
459
|
+
// Filter out options that are inactive
|
|
460
|
+
optionsToSelect = optionsToSelect.filter(option => option.isActive);
|
|
461
|
+
|
|
462
|
+
if (!optionsToSelect.length) return;
|
|
463
|
+
|
|
464
|
+
if (this.multiSelect) {
|
|
465
|
+
this.selectedOptions = [...(this.selectedOptions || []), ...optionsToSelect];
|
|
466
|
+
} else {
|
|
467
|
+
// In single select mode, only take the last option
|
|
468
|
+
this.selectedOptions = [optionsToSelect[optionsToSelect.length - 1]];
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
this.stageUpdate();
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Deselects one or more options in a batch operation
|
|
476
|
+
* @param {AuroMenuOption|AuroMenuOption[]} options - Single option or array of options to deselect
|
|
477
|
+
*/
|
|
478
|
+
deselectOptions(options) {
|
|
479
|
+
const optionsToDeselect = Array.isArray(options) ? options : [options];
|
|
480
|
+
|
|
481
|
+
if (!optionsToDeselect.length) return;
|
|
482
|
+
|
|
483
|
+
// Check if deselection should be prevented
|
|
484
|
+
const shouldPreventDeselect = !this.allowDeselect && !this.multiSelect;
|
|
485
|
+
const isOnlySelectedOption = this.selectedOptions.length === 1 && optionsToDeselect.includes(this.selectedOptions[0]);
|
|
486
|
+
|
|
487
|
+
// Prevent deselecting the only selected option if not allowed
|
|
488
|
+
if (shouldPreventDeselect && isOnlySelectedOption) {
|
|
489
|
+
optionsToDeselect.forEach(option => {
|
|
490
|
+
option.selected = true;
|
|
491
|
+
});
|
|
492
|
+
this.dispatchChangeEvent('auroMenu-deselectPrevented', {
|
|
493
|
+
values: optionsToDeselect
|
|
494
|
+
});
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
const optionsSet = new Set(optionsToDeselect);
|
|
499
|
+
this.selectedOptions = (this.selectedOptions || [])
|
|
500
|
+
.filter(opt => !optionsSet.has(opt));
|
|
501
|
+
|
|
502
|
+
this.stageUpdate();
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Selects a single option.
|
|
507
|
+
* @param {AuroMenuOption} option
|
|
508
|
+
*/
|
|
509
|
+
selectOption(option) {
|
|
510
|
+
this.selectOptions(option);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Deselects a single option.
|
|
515
|
+
* @param {AuroMenuOption} option
|
|
516
|
+
*/
|
|
517
|
+
deselectOption(option) {
|
|
518
|
+
this.deselectOptions(option);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Toggles the selection state of a single option.
|
|
523
|
+
* @param {AuroMenuOption} option
|
|
524
|
+
*/
|
|
525
|
+
toggleOption(option) {
|
|
526
|
+
if (option.selected) {
|
|
527
|
+
this.deselectOption(option);
|
|
528
|
+
} else {
|
|
529
|
+
this.selectOption(option);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Selects options based on their value(s) when compared to a passed value or values.
|
|
535
|
+
* Value or values are normalized to an array of strings that can be matched to option keys.
|
|
536
|
+
* @param {string|number|Array<string|number>} value - The value(s) to select.
|
|
537
|
+
*/
|
|
538
|
+
selectByValue(value) {
|
|
539
|
+
const isEmptyValue = value === undefined ||
|
|
540
|
+
value === null ||
|
|
541
|
+
(Array.isArray(value) && value.length === 0) ||
|
|
542
|
+
(typeof value === 'string' && value.trim() === '');
|
|
543
|
+
|
|
544
|
+
// Early exit for invalid/empty values
|
|
545
|
+
if (isEmptyValue) {
|
|
546
|
+
this.selectedOptions.forEach(opt => opt.selected = false);
|
|
547
|
+
this.selectedOptions = [];
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
// If an internal update cycle is still in progress, defer value application
|
|
552
|
+
// rather than dropping it.
|
|
553
|
+
if (this.internalUpdateInProgress || this.host.internalUpdateInProgress) {
|
|
554
|
+
this.queuePendingValue(value);
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// Normalize values to array of strings
|
|
559
|
+
const normalizedValues = this._getNormalizedValues(value);
|
|
560
|
+
|
|
561
|
+
// Validate for single-select mode
|
|
562
|
+
let validatedValues = normalizedValues;
|
|
563
|
+
if (normalizedValues.length > 1 && !this.multiSelect) {
|
|
564
|
+
console.warn("MenuService - Multiple values provided for single-select menu. Only the first value will be selected.");
|
|
565
|
+
validatedValues = [normalizedValues[0]];
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
if (this._menuOptions.length === 0) {
|
|
569
|
+
this.queuePendingValue(value);
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// Find matching options by comparing available options to validated values
|
|
574
|
+
const trackedKeys = new Set();
|
|
575
|
+
const optionsToSelect = this._menuOptions.filter(option => {
|
|
576
|
+
const passesFilter = validatedValues.includes(option.key);
|
|
577
|
+
const alreadyTracked = trackedKeys.has(option.key);
|
|
578
|
+
const isActive = option.isActive;
|
|
579
|
+
|
|
580
|
+
trackedKeys.add(option.key);
|
|
581
|
+
|
|
582
|
+
// Include the option in the options to be selected if it passes the filter check and
|
|
583
|
+
// either hasn't been tracked yet or selectAllMatchingOptions is true
|
|
584
|
+
return isActive && passesFilter && (!alreadyTracked || (alreadyTracked && this.selectAllMatchingOptions));
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
// Handle no matches: clear existing selection, but do not dispatch an intermediate
|
|
588
|
+
// undefined value that can overwrite the host value in parent components.
|
|
589
|
+
if (!optionsToSelect.length) {
|
|
590
|
+
const hasUnresolvedKeys = this._menuOptions.some((option) => option.isActive && option.key == null);
|
|
591
|
+
|
|
592
|
+
if (hasUnresolvedKeys) {
|
|
593
|
+
this.queuePendingValue(value);
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
this.clearPendingValue();
|
|
598
|
+
|
|
599
|
+
if (this.selectedOptions.length > 0) {
|
|
600
|
+
this.selectedOptions = [];
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
// Always notify so the host resets any stale invalid value, even when
|
|
604
|
+
// selectedOptions was already empty (e.g. double-clicking set-invalid).
|
|
605
|
+
this.stageUpdate({ reason: 'no-match' });
|
|
606
|
+
|
|
607
|
+
// Dispatch failure event if no matches found
|
|
608
|
+
if (validatedValues.length) {
|
|
609
|
+
this.dispatchChangeEvent('auroMenu-selectValueFailure', {
|
|
610
|
+
message: 'No matching options found for the provided value(s).',
|
|
611
|
+
values: validatedValues
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
this.clearPendingValue();
|
|
619
|
+
|
|
620
|
+
if (this.optionsArraysMatch(optionsToSelect, this.selectedOptions)) {
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// Apply programmatic selection as a single transaction and emit one final state.
|
|
625
|
+
this.selectedOptions = optionsToSelect;
|
|
626
|
+
this.stageUpdate();
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Queues a pending value and schedules a bounded retry.
|
|
631
|
+
* @param {string|number|Array<string|number>} value - The value to retry.
|
|
632
|
+
*/
|
|
633
|
+
queuePendingValue(value) {
|
|
634
|
+
this._pendingValue = value;
|
|
635
|
+
|
|
636
|
+
if (this._pendingRetryScheduled || this._pendingRetryCount >= 5) {
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
this._pendingRetryScheduled = true;
|
|
641
|
+
this._pendingRetryCount += 1;
|
|
642
|
+
|
|
643
|
+
setTimeout(() => {
|
|
644
|
+
this._pendingRetryScheduled = false;
|
|
645
|
+
|
|
646
|
+
if (this._pendingValue == null) {
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
const pendingValue = this._pendingValue;
|
|
651
|
+
this.selectByValue(pendingValue);
|
|
652
|
+
}, 0);
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Clears pending retry state.
|
|
657
|
+
*/
|
|
658
|
+
clearPendingValue() {
|
|
659
|
+
this._pendingValue = null;
|
|
660
|
+
this._pendingRetryScheduled = false;
|
|
661
|
+
this._pendingRetryCount = 0;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Resets the selected options to an empty array.
|
|
666
|
+
*/
|
|
667
|
+
reset() {
|
|
668
|
+
const previousOptions = [...this.selectedOptions];
|
|
669
|
+
previousOptions.forEach(opt => opt.selected = false);
|
|
670
|
+
this.selectedOptions = [];
|
|
671
|
+
|
|
672
|
+
// Single update after clearing all
|
|
673
|
+
if (previousOptions.length) {
|
|
674
|
+
this.stageUpdate();
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* SUBSCRIPTION, NOTIFICATION AND EVENT DISPATCH METHODS
|
|
680
|
+
*/
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Subscribes a callback to menu service events.
|
|
684
|
+
* @param {Function} callback - The callback to invoke on events.
|
|
685
|
+
*/
|
|
686
|
+
subscribe(callback) {
|
|
687
|
+
this._subscribers.push(callback);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Remove a previously subscribed callback from menu service events.
|
|
692
|
+
* @param {Function} callback
|
|
693
|
+
*/
|
|
694
|
+
unsubscribe(callback) {
|
|
695
|
+
this._subscribers = this._subscribers.filter(cb => cb !== callback);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Stages an update to notify subscribers of state and value changes.
|
|
700
|
+
*/
|
|
701
|
+
stageUpdate(meta = {}) {
|
|
702
|
+
this.notifyStateChange(meta);
|
|
703
|
+
this.notifyValueChange(meta);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* Notifies subscribers of a menu service event.
|
|
708
|
+
* All notifications are sent to all subscribers.
|
|
709
|
+
* @param {string} event - The event to send to subscribers.
|
|
710
|
+
*/
|
|
711
|
+
notify(event) {
|
|
712
|
+
this._subscribers.forEach(callback => callback(event));
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Notifies subscribers of a state change (selected options has changed).
|
|
717
|
+
*/
|
|
718
|
+
notifyStateChange(meta = {}) {
|
|
719
|
+
this.notify({
|
|
720
|
+
type: 'stateChange',
|
|
721
|
+
selectedOptions: this.selectedOptions,
|
|
722
|
+
...meta
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Notifies subscribers of a value change (current value has changed).
|
|
728
|
+
*/
|
|
729
|
+
notifyValueChange(meta = {}) {
|
|
730
|
+
|
|
731
|
+
// Prepare details for the event
|
|
732
|
+
const details = {
|
|
733
|
+
value: this.currentValue,
|
|
734
|
+
stringValue: this.stringValue,
|
|
735
|
+
keys: this.currentKeys,
|
|
736
|
+
options: this.selectedOptions,
|
|
737
|
+
label: this.currentLabel
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
// If only one option is selected, include its index
|
|
741
|
+
if (this.selectedOptions.length === 1) details.index = this._menuOptions.indexOf(this.selectedOptions[0]);
|
|
742
|
+
|
|
743
|
+
this.notify({
|
|
744
|
+
type: 'valueChange',
|
|
745
|
+
...meta,
|
|
746
|
+
...details
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Dispatches a custom event from the host element.
|
|
752
|
+
* @param {string} eventName
|
|
753
|
+
* @param {any} detail
|
|
754
|
+
*/
|
|
755
|
+
dispatchChangeEvent(eventName, detail) {
|
|
756
|
+
this.host.dispatchEvent(new CustomEvent(eventName, {
|
|
757
|
+
bubbles: true,
|
|
758
|
+
cancelable: false,
|
|
759
|
+
composed: true,
|
|
760
|
+
detail
|
|
761
|
+
}));
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* MENU OPTION MANAGEMENT METHODS
|
|
766
|
+
*/
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Adds a menu option to the service's list.
|
|
770
|
+
* @param {AuroMenuOption} option - the option to track
|
|
771
|
+
*/
|
|
772
|
+
addMenuOption(option) {
|
|
773
|
+
this._menuOptions.push(option);
|
|
774
|
+
this.notify({ type: 'optionsChange', options: this._menuOptions });
|
|
775
|
+
|
|
776
|
+
if (this._pendingValue != null) {
|
|
777
|
+
this.queuePendingValue(this._pendingValue);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* Removes a menu option from the service's list.
|
|
783
|
+
* @param {AuroMenuOption} option - the option to remove
|
|
784
|
+
*/
|
|
785
|
+
removeMenuOption(option) {
|
|
786
|
+
this._menuOptions = this._menuOptions.filter(opt => opt !== option);
|
|
787
|
+
this.notify({ type: 'optionsChange', options: this._menuOptions });
|
|
788
|
+
|
|
789
|
+
if (this._menuOptions.length === 0) {
|
|
790
|
+
this.clearPendingValue();
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* UTILITIES
|
|
796
|
+
*/
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Normalizes a value or array of values into an array of strings for option selection.
|
|
800
|
+
* This function ensures that input values are consistently formatted for matching menu options.
|
|
801
|
+
*
|
|
802
|
+
* @param {string|number|Array<string|number>} value - The value(s) to normalize.
|
|
803
|
+
* @returns {Array<string>} An array of string values suitable for option matching.
|
|
804
|
+
* @throws {Error} If any value is not a string or number.
|
|
805
|
+
*/
|
|
806
|
+
_getNormalizedValues(value) {
|
|
807
|
+
let values = value;
|
|
808
|
+
|
|
809
|
+
// Handle JSON string and single value string input
|
|
810
|
+
if (!Array.isArray(values) && typeof values === 'string') {
|
|
811
|
+
|
|
812
|
+
// Attempt to parse as JSON array
|
|
813
|
+
try {
|
|
814
|
+
|
|
815
|
+
// Normalize single quotes to double quotes for JSON parsing
|
|
816
|
+
// This will not handle complex cases but will cover basic usage
|
|
817
|
+
const parseValue = values.replace(/'([^']*?)'/g, '"$1"');
|
|
818
|
+
|
|
819
|
+
// Attempt parse
|
|
820
|
+
const parsed = JSON.parse(parseValue);
|
|
821
|
+
|
|
822
|
+
// Ensure parsed value is an array
|
|
823
|
+
if (!Array.isArray(parsed)) throw new Error('Not an array');
|
|
824
|
+
|
|
825
|
+
// Set values to parsed array
|
|
826
|
+
values = parsed;
|
|
827
|
+
} catch (err) {
|
|
828
|
+
|
|
829
|
+
// If parsing fails, treat as single value
|
|
830
|
+
values = [value];
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// Handle a single number being passed
|
|
835
|
+
if (typeof values === 'number') {
|
|
836
|
+
values = [String(values)];
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
// Coerce each value to string and validate types
|
|
840
|
+
values.forEach((val, index) => {
|
|
841
|
+
|
|
842
|
+
// Throw an error for invalid value types
|
|
843
|
+
if (typeof val !== 'string' && typeof val !== 'number') {
|
|
844
|
+
throw new Error('Value contains invalid value type. Supported types are string and number.');
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
// Convert numbers to strings for consistency
|
|
848
|
+
if (typeof val === 'number') {
|
|
849
|
+
values[index] = String(val);
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
|
|
853
|
+
// Return the resulting array of string values
|
|
854
|
+
return values;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* Returns whether two arrays of options contain the same elements.
|
|
859
|
+
* @param {AuroMenuOption[]} arr1 - First array of options.
|
|
860
|
+
* @param {AuroMenuOption[]} arr2 - Second array of options.
|
|
861
|
+
* @returns {boolean} True if arrays match, false otherwise.
|
|
862
|
+
*/
|
|
863
|
+
optionsArraysMatch(arr1, arr2) {
|
|
864
|
+
if (arr1.length !== arr2.length) return false;
|
|
865
|
+
|
|
866
|
+
const set1 = new Set(arr1);
|
|
867
|
+
const set2 = new Set(arr2);
|
|
868
|
+
|
|
869
|
+
for (let item of set1) {
|
|
870
|
+
if (!set2.has(item)) {
|
|
871
|
+
return false;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
return true;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
const MenuContext = n$1('menu-context');
|
|
880
|
+
|
|
881
|
+
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
882
|
+
// See LICENSE in the project root for license information.
|
|
883
|
+
|
|
884
|
+
// ---------------------------------------------------------------------
|
|
885
|
+
|
|
886
|
+
/* eslint-disable line-comment-position, no-inline-comments, no-confusing-arrow, no-nested-ternary, implicit-arrow-linebreak */
|
|
887
|
+
|
|
888
|
+
class AuroLibraryRuntimeUtils {
|
|
889
|
+
|
|
890
|
+
/* eslint-disable jsdoc/require-param */
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* This will register a new custom element with the browser.
|
|
894
|
+
* @param {String} name - The name of the custom element.
|
|
895
|
+
* @param {Object} componentClass - The class to register as a custom element.
|
|
896
|
+
* @returns {void}
|
|
897
|
+
*/
|
|
898
|
+
registerComponent(name, componentClass) {
|
|
899
|
+
if (!customElements.get(name)) {
|
|
900
|
+
customElements.define(name, class extends componentClass {});
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* Finds and returns the closest HTML Element based on a selector.
|
|
906
|
+
* @returns {void}
|
|
907
|
+
*/
|
|
908
|
+
closestElement(
|
|
909
|
+
selector, // selector like in .closest()
|
|
910
|
+
base = this, // extra functionality to skip a parent
|
|
911
|
+
__Closest = (el, found = el && el.closest(selector)) =>
|
|
912
|
+
!el || el === document || el === window
|
|
913
|
+
? null // standard .closest() returns null for non-found selectors also
|
|
914
|
+
: found
|
|
915
|
+
? found // found a selector INside this element
|
|
916
|
+
: __Closest(el.getRootNode().host) // recursion!! break out to parent DOM
|
|
917
|
+
) {
|
|
918
|
+
return __Closest(base);
|
|
919
|
+
}
|
|
920
|
+
/* eslint-enable jsdoc/require-param */
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* If the element passed is registered with a different tag name than what is passed in, the tag name is added as an attribute to the element.
|
|
924
|
+
* @param {Object} elem - The element to check.
|
|
925
|
+
* @param {String} tagName - The name of the Auro component to check for or add as an attribute.
|
|
926
|
+
* @returns {void}
|
|
927
|
+
*/
|
|
928
|
+
handleComponentTagRename(elem, tagName) {
|
|
929
|
+
const tag = tagName.toLowerCase();
|
|
930
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
931
|
+
|
|
932
|
+
if (elemTag !== tag) {
|
|
933
|
+
elem.setAttribute(tag, true);
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* Validates if an element is a specific Auro component.
|
|
939
|
+
* @param {Object} elem - The element to validate.
|
|
940
|
+
* @param {String} tagName - The name of the Auro component to check against.
|
|
941
|
+
* @returns {Boolean} - Returns true if the element is the specified Auro component.
|
|
942
|
+
*/
|
|
943
|
+
elementMatch(elem, tagName) {
|
|
944
|
+
const tag = tagName.toLowerCase();
|
|
945
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
946
|
+
|
|
947
|
+
return elemTag === tag || elem.hasAttribute(tag);
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* Gets the text content of a named slot.
|
|
952
|
+
* @returns {String}
|
|
953
|
+
* @private
|
|
954
|
+
*/
|
|
955
|
+
getSlotText(elem, name) {
|
|
956
|
+
const slot = elem.shadowRoot?.querySelector(`slot[name="${name}"]`);
|
|
957
|
+
const nodes = slot?.assignedNodes({ flatten: true }) || [];
|
|
958
|
+
const text = nodes.map(n => n.textContent?.trim()).join(' ').trim();
|
|
959
|
+
|
|
960
|
+
return text || null;
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
// Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
965
|
+
// See LICENSE in the project root for license information.
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* Helper method to dispatch custom events.
|
|
970
|
+
* @param {HTMLElement} element - Element to dispatch event from.
|
|
971
|
+
* @param {string} eventName - Name of the event to dispatch.
|
|
972
|
+
* @param {Object} [detail] - Optional detail object to include with the event.
|
|
973
|
+
*/
|
|
974
|
+
function dispatchMenuEvent(element, eventName, detail = null) {
|
|
975
|
+
const eventConfig = {
|
|
976
|
+
bubbles: true,
|
|
977
|
+
cancelable: false,
|
|
978
|
+
composed: true
|
|
979
|
+
};
|
|
980
|
+
|
|
981
|
+
if (detail !== null) {
|
|
982
|
+
eventConfig.detail = detail;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
element.dispatchEvent(new CustomEvent(eventName, eventConfig));
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* @license
|
|
990
|
+
* Copyright 2017 Google LLC
|
|
991
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
992
|
+
*/
|
|
993
|
+
const t={ATTRIBUTE:1},e$1=t=>(...e)=>({_$litDirective$:t,values:e});let i$1 = class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i;}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* @license
|
|
997
|
+
* Copyright 2018 Google LLC
|
|
998
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
999
|
+
*/const e=e$1(class extends i$1{constructor(t$1){if(super(t$1),t$1.type!==t.ATTRIBUTE||"class"!==t$1.name||t$1.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return " "+Object.keys(t).filter(s=>t[s]).join(" ")+" "}update(s,[i]){if(void 0===this.st){this.st=new Set,void 0!==s.strings&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter(t=>""!==t)));for(const t in i)i[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(i)}const r=s.element.classList;for(const t of this.st)t in i||(r.remove(t),this.st.delete(t));for(const t in i){const s=!!i[t];s===this.st.has(t)||this.nt?.has(t)||(s?(r.add(t),this.st.add(t)):(r.remove(t),this.st.delete(t)));}return E}});
|
|
1000
|
+
|
|
1001
|
+
/* eslint-disable no-underscore-dangle */
|
|
1002
|
+
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
1003
|
+
// See LICENSE in the project root for license information.
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* The `auro-menu` element provides users a way to select from a list of options.
|
|
1009
|
+
* @customElement auro-menu
|
|
1010
|
+
*
|
|
1011
|
+
* @event {CustomEvent<Element>} auroMenu-activatedOption - Notifies that a menuoption has been made `active`.
|
|
1012
|
+
* @event {CustomEvent<any>} auroMenu-customEventFired - Notifies that a custom event has been fired.
|
|
1013
|
+
* @event {CustomEvent<{ loading: boolean; hasLoadingPlaceholder: boolean; }>} auroMenu-loadingChange - Notifies when the loading attribute is changed.
|
|
1014
|
+
* @event {CustomEvent<any>} auroMenu-selectValueFailure - Notifies that an attempt to select a menuoption by matching a value has failed.
|
|
1015
|
+
* @event {CustomEvent<{ values: HTMLElement[] }>} auroMenu-deselectPrevented - Notifies that deselection was prevented and includes the affected options in `detail.values`.
|
|
1016
|
+
* @event {CustomEvent<any>} auroMenu-selectValueReset - Notifies that the component value has been reset.
|
|
1017
|
+
* @event {CustomEvent<any>} auroMenu-selectedOption - Notifies that a new menuoption selection has been made.
|
|
1018
|
+
* @slot loadingText - Text to show while loading attribute is set
|
|
1019
|
+
* @slot loadingIcon - Icon to show while loading attribute is set
|
|
1020
|
+
* @slot - Slot for insertion of menu options.
|
|
1021
|
+
*/
|
|
1022
|
+
|
|
1023
|
+
/* eslint-disable max-lines */
|
|
1024
|
+
|
|
1025
|
+
class AuroMenu extends AuroElement {
|
|
1026
|
+
|
|
1027
|
+
constructor() {
|
|
1028
|
+
super();
|
|
1029
|
+
|
|
1030
|
+
// State properties (reactive)
|
|
1031
|
+
|
|
1032
|
+
/**
|
|
1033
|
+
* @private
|
|
1034
|
+
*/
|
|
1035
|
+
this.shape = "box";
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
* @private
|
|
1039
|
+
*/
|
|
1040
|
+
this.size = "sm";
|
|
1041
|
+
|
|
1042
|
+
// Value of the selected options
|
|
1043
|
+
this.value = undefined;
|
|
1044
|
+
// Currently selected option
|
|
1045
|
+
this.optionSelected = undefined;
|
|
1046
|
+
// String used for highlighting/filtering
|
|
1047
|
+
this.matchWord = undefined;
|
|
1048
|
+
// Hide the checkmark icon on selected options
|
|
1049
|
+
this.noCheckmark = false;
|
|
1050
|
+
// Currently active option
|
|
1051
|
+
this.optionActive = undefined;
|
|
1052
|
+
// Loading state
|
|
1053
|
+
this.loading = false;
|
|
1054
|
+
// Multi-select mode
|
|
1055
|
+
this.multiSelect = false;
|
|
1056
|
+
// Allow deselecting of menu options
|
|
1057
|
+
this.allowDeselect = false;
|
|
1058
|
+
// Select all matching options when setting value in multi-select mode
|
|
1059
|
+
this.selectAllMatchingOptions = false;
|
|
1060
|
+
|
|
1061
|
+
// Event Bindings
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* @private
|
|
1065
|
+
*/
|
|
1066
|
+
this.handleSlotChange = this.handleSlotChange.bind(this);
|
|
1067
|
+
|
|
1068
|
+
// Instance properties (non-reactive)
|
|
1069
|
+
|
|
1070
|
+
/**
|
|
1071
|
+
* @private
|
|
1072
|
+
*/
|
|
1073
|
+
Object.assign(this, {
|
|
1074
|
+
// Root-level menu (true) or a nested submenu (false)
|
|
1075
|
+
rootMenu: true,
|
|
1076
|
+
// Currently focused/active menu item index
|
|
1077
|
+
_index: -1,
|
|
1078
|
+
// Nested menu spacer
|
|
1079
|
+
nestingSpacer: '<span class="nestingSpacer"></span>',
|
|
1080
|
+
// Loading indicator for slot elements
|
|
1081
|
+
loadingSlots: null,
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
static get properties() {
|
|
1086
|
+
return {
|
|
1087
|
+
...super.properties,
|
|
1088
|
+
|
|
1089
|
+
/**
|
|
1090
|
+
* Allows deselecting an already selected option when clicked again in single-select mode.
|
|
1091
|
+
*/
|
|
1092
|
+
allowDeselect: {
|
|
1093
|
+
type: Boolean,
|
|
1094
|
+
reflect: true,
|
|
1095
|
+
},
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* When true, the entire menu and all options are disabled.
|
|
1099
|
+
*/
|
|
1100
|
+
disabled: {
|
|
1101
|
+
type: Boolean,
|
|
1102
|
+
reflect: true
|
|
1103
|
+
},
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
* Indicates whether the menu has a loadingIcon or loadingText to render when in a loading state.
|
|
1107
|
+
*/
|
|
1108
|
+
hasLoadingPlaceholder: {
|
|
1109
|
+
type: Boolean
|
|
1110
|
+
},
|
|
1111
|
+
|
|
1112
|
+
/**
|
|
1113
|
+
* @private
|
|
1114
|
+
*/
|
|
1115
|
+
layout: {
|
|
1116
|
+
type: String
|
|
1117
|
+
},
|
|
1118
|
+
|
|
1119
|
+
/**
|
|
1120
|
+
* Indent level for submenus.
|
|
1121
|
+
* @private
|
|
1122
|
+
*/
|
|
1123
|
+
level: {
|
|
1124
|
+
type: Number,
|
|
1125
|
+
reflect: false,
|
|
1126
|
+
attribute: false
|
|
1127
|
+
},
|
|
1128
|
+
|
|
1129
|
+
/**
|
|
1130
|
+
* When true, displays a loading state using the loadingIcon and loadingText slots if provided.
|
|
1131
|
+
*/
|
|
1132
|
+
loading: {
|
|
1133
|
+
type: Boolean,
|
|
1134
|
+
reflect: true
|
|
1135
|
+
},
|
|
1136
|
+
|
|
1137
|
+
/**
|
|
1138
|
+
* Specifies a string used to highlight matched string parts in options.
|
|
1139
|
+
*/
|
|
1140
|
+
matchWord: {
|
|
1141
|
+
type: String,
|
|
1142
|
+
attribute: 'matchword'
|
|
1143
|
+
},
|
|
1144
|
+
|
|
1145
|
+
/**
|
|
1146
|
+
* When true, the selected option can be multiple options.
|
|
1147
|
+
*/
|
|
1148
|
+
multiSelect: {
|
|
1149
|
+
type: Boolean,
|
|
1150
|
+
reflect: true,
|
|
1151
|
+
attribute: 'multiselect'
|
|
1152
|
+
},
|
|
1153
|
+
|
|
1154
|
+
/**
|
|
1155
|
+
* When true, selected option will not show the checkmark.
|
|
1156
|
+
*/
|
|
1157
|
+
noCheckmark: {
|
|
1158
|
+
type: Boolean,
|
|
1159
|
+
reflect: true,
|
|
1160
|
+
attribute: 'nocheckmark'
|
|
1161
|
+
},
|
|
1162
|
+
|
|
1163
|
+
/**
|
|
1164
|
+
* Specifies the current active menuOption.
|
|
1165
|
+
*/
|
|
1166
|
+
optionActive: {
|
|
1167
|
+
type: Object,
|
|
1168
|
+
attribute: 'optionactive'
|
|
1169
|
+
},
|
|
1170
|
+
|
|
1171
|
+
/**
|
|
1172
|
+
* An array of currently selected menu options, type `HTMLElement` by default. In multi-select mode, `optionSelected` is an array of HTML elements.
|
|
1173
|
+
*/
|
|
1174
|
+
optionSelected: {
|
|
1175
|
+
// Allow HTMLElement, HTMLElement[] arrays and undefined
|
|
1176
|
+
type: Object
|
|
1177
|
+
},
|
|
1178
|
+
|
|
1179
|
+
/**
|
|
1180
|
+
* Available menu options.
|
|
1181
|
+
* @readonly
|
|
1182
|
+
*/
|
|
1183
|
+
options: {
|
|
1184
|
+
type: Array,
|
|
1185
|
+
reflect: false,
|
|
1186
|
+
attribute: false
|
|
1187
|
+
},
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* Sets the size of the menu.
|
|
1191
|
+
* @type {'sm' | 'md'}
|
|
1192
|
+
* @default 'sm'
|
|
1193
|
+
*/
|
|
1194
|
+
size: {
|
|
1195
|
+
type: String,
|
|
1196
|
+
reflect: true
|
|
1197
|
+
},
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* When true, selects all options that match the provided value/key when setting value and multiselect is enabled.
|
|
1201
|
+
*/
|
|
1202
|
+
selectAllMatchingOptions: {
|
|
1203
|
+
type: Boolean,
|
|
1204
|
+
reflect: true,
|
|
1205
|
+
},
|
|
1206
|
+
|
|
1207
|
+
/**
|
|
1208
|
+
* Sets the shape of the menu.
|
|
1209
|
+
* @type {'box' | 'round'}
|
|
1210
|
+
* @default 'box'
|
|
1211
|
+
*/
|
|
1212
|
+
shape: {
|
|
1213
|
+
type: String,
|
|
1214
|
+
reflect: true
|
|
1215
|
+
},
|
|
1216
|
+
|
|
1217
|
+
/**
|
|
1218
|
+
* The value of the selected option. In multi-select mode, this is a JSON stringified array of selected option values.
|
|
1219
|
+
*/
|
|
1220
|
+
value: {
|
|
1221
|
+
type: String,
|
|
1222
|
+
reflect: true,
|
|
1223
|
+
attribute: 'value'
|
|
1224
|
+
}
|
|
1225
|
+
};
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
static get styles() {
|
|
1229
|
+
return [
|
|
1230
|
+
styleCss$1,
|
|
1231
|
+
colorCss$1,
|
|
1232
|
+
tokensCss
|
|
1233
|
+
];
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
/**
|
|
1237
|
+
* @readonly
|
|
1238
|
+
* @returns {string} - Returns the label of the currently selected option(s).
|
|
1239
|
+
*/
|
|
1240
|
+
get currentLabel() {
|
|
1241
|
+
return this.menuService.currentLabel;
|
|
1242
|
+
};
|
|
1243
|
+
|
|
1244
|
+
/**
|
|
1245
|
+
* @readonly
|
|
1246
|
+
* @returns {Array<HTMLElement>} - Returns the array of available menu options.
|
|
1247
|
+
* @deprecated Use `options` property instead.
|
|
1248
|
+
*/
|
|
1249
|
+
get items() {
|
|
1250
|
+
return this.options;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
/**
|
|
1254
|
+
* @returns {number} - Returns the index of the currently active option.
|
|
1255
|
+
*/
|
|
1256
|
+
get index() {
|
|
1257
|
+
return this._index;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
/**
|
|
1261
|
+
* @param {number} value - Sets the index of the currently active option.
|
|
1262
|
+
*/
|
|
1263
|
+
set index(value) {
|
|
1264
|
+
this.menuService.setHighlightedIndex(value);
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
/**
|
|
1268
|
+
* This will register this element with the browser.
|
|
1269
|
+
* @param {string} [name="auro-menu"] - The name of the element that you want to register.
|
|
1270
|
+
*
|
|
1271
|
+
* @example
|
|
1272
|
+
* AuroMenu.register("custom-menu") // this will register this element to <custom-menu/>
|
|
1273
|
+
*
|
|
1274
|
+
*/
|
|
1275
|
+
static register(name = "auro-menu") {
|
|
1276
|
+
AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroMenu);
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
/**
|
|
1280
|
+
* Formatted value based on `multiSelect` state.
|
|
1281
|
+
* Default type is `String`, changing to `Array<String>` when `multiSelect` is true.
|
|
1282
|
+
* @private
|
|
1283
|
+
* @returns {String|Array<String>}
|
|
1284
|
+
*/
|
|
1285
|
+
get formattedValue() {
|
|
1286
|
+
return this.menuService.currentValue;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
/**
|
|
1290
|
+
* Gets the current property values for the menu service.
|
|
1291
|
+
* @private
|
|
1292
|
+
* @returns {Object}
|
|
1293
|
+
*/
|
|
1294
|
+
get propertyValues() {
|
|
1295
|
+
return {
|
|
1296
|
+
size: this.size,
|
|
1297
|
+
shape: this.shape,
|
|
1298
|
+
noCheckmark: this.nocheckmark,
|
|
1299
|
+
disabled: this.disabled
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
/**
|
|
1304
|
+
* Provides the menu context to child components.
|
|
1305
|
+
* Initializes the MenuService and subscribes to menu changes.
|
|
1306
|
+
* @protected
|
|
1307
|
+
*/
|
|
1308
|
+
provideContext() {
|
|
1309
|
+
if (this.parentElement && this.parentElement.closest('auro-menu, [auro-menu]')) {
|
|
1310
|
+
this.rootMenu = false;
|
|
1311
|
+
this.menuService = this.parentElement.menuService;
|
|
1312
|
+
this._contextProvider = this.parentElement._contextProvider;
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
this.menuService = new MenuService({host: this});
|
|
1317
|
+
this.menuService.setProperties(this.propertyValues);
|
|
1318
|
+
this.menuService.subscribe(this.handleMenuChange.bind(this));
|
|
1319
|
+
this._contextProvider = new i$2(this, {
|
|
1320
|
+
context: MenuContext,
|
|
1321
|
+
initialValue: this.menuService
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
/**
|
|
1326
|
+
* Updates the currently active option in the menu.
|
|
1327
|
+
* @param {HTMLElement} option - The option to set as active.
|
|
1328
|
+
*/
|
|
1329
|
+
updateActiveOption(option) {
|
|
1330
|
+
this.menuService.setHighlightedOption(option);
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
/**
|
|
1334
|
+
* Sets the internal value and manages update state.
|
|
1335
|
+
* @param {String|Array<String>} value - The value to set.
|
|
1336
|
+
* @protected
|
|
1337
|
+
*/
|
|
1338
|
+
setInternalValue(value) {
|
|
1339
|
+
if (this.value !== value) {
|
|
1340
|
+
this.internalUpdateInProgress = true;
|
|
1341
|
+
this.value = value;
|
|
1342
|
+
|
|
1343
|
+
setTimeout(() => {
|
|
1344
|
+
this.internalUpdateInProgress = false;
|
|
1345
|
+
});
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
/**
|
|
1350
|
+
* Handles changes from the menu service and updates component state.
|
|
1351
|
+
* @param {Object} event - The event object from the menu service.
|
|
1352
|
+
* @protected
|
|
1353
|
+
*/
|
|
1354
|
+
handleMenuChange(event) {
|
|
1355
|
+
if (event.type === 'valueChange') {
|
|
1356
|
+
|
|
1357
|
+
// New option is array value or first option with fallback to undefined for empty array in all cases
|
|
1358
|
+
const newOption = this.multiSelect && event.options.length ? event.options : event.options[0] || undefined;
|
|
1359
|
+
const newValue = event.stringValue;
|
|
1360
|
+
|
|
1361
|
+
// Check if the option or value has actually changed
|
|
1362
|
+
if (this.optionSelected !== newOption || this.stringValue !== newValue) {
|
|
1363
|
+
this.optionSelected = newOption;
|
|
1364
|
+
this.setInternalValue(newValue);
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
// Notify components of selection change
|
|
1368
|
+
this.notifySelectionChange(event);
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
if (event.type === 'highlightChange') {
|
|
1372
|
+
this.optionActive = event.option;
|
|
1373
|
+
this._index = event.index;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
if (event.type === 'optionsChange') {
|
|
1377
|
+
this.options = event.options;
|
|
1378
|
+
this.dispatchEvent(new CustomEvent('auroMenu-optionsChange', {
|
|
1379
|
+
detail: {
|
|
1380
|
+
options: event.options
|
|
1381
|
+
}
|
|
1382
|
+
}));
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
/**
|
|
1387
|
+
* Gets the currently selected options.
|
|
1388
|
+
* @returns {Array<HTMLElement>}
|
|
1389
|
+
*/
|
|
1390
|
+
get selectedOptions() {
|
|
1391
|
+
return this.menuService ? this.menuService.selectedOptions : [];
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
/**
|
|
1395
|
+
* Gets the first selected option, or null if none.
|
|
1396
|
+
* @returns {HTMLElement|null}
|
|
1397
|
+
*/
|
|
1398
|
+
get selectedOption() {
|
|
1399
|
+
return this.menuService ? this.menuService.selectedOptions[0] : null;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
// Lifecycle Methods
|
|
1403
|
+
|
|
1404
|
+
connectedCallback() {
|
|
1405
|
+
super.connectedCallback();
|
|
1406
|
+
|
|
1407
|
+
this.provideContext();
|
|
1408
|
+
|
|
1409
|
+
// this.addEventListener('keydown', this.handleKeyDown);
|
|
1410
|
+
this.addEventListener('auroMenuOption-click', this.handleMouseSelect);
|
|
1411
|
+
this.addEventListener('auroMenuOption-mouseover', this.handleOptionHover);
|
|
1412
|
+
this.addEventListener('slotchange', this.handleSlotChange);
|
|
1413
|
+
this.setTagAttribute("auro-menu");
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
disconnectedCallback() {
|
|
1417
|
+
// this.removeEventListener('keydown', this.handleKeyDown);
|
|
1418
|
+
this.removeEventListener('auroMenuOption-click', this.handleMouseSelect);
|
|
1419
|
+
this.removeEventListener('auroMenuOption-mouseover', this.handleOptionHover);
|
|
1420
|
+
this.removeEventListener('slotchange', this.handleSlotChange);
|
|
1421
|
+
|
|
1422
|
+
super.disconnectedCallback();
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
firstUpdated() {
|
|
1426
|
+
AuroLibraryRuntimeUtils.prototype.handleComponentTagRename(this, 'auro-menu');
|
|
1427
|
+
|
|
1428
|
+
this.loadingSlots = this.querySelectorAll("[slot='loadingText'], [slot='loadingIcon']");
|
|
1429
|
+
this.initializeMenu();
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
updated(changedProperties) {
|
|
1434
|
+
super.updated(changedProperties);
|
|
1435
|
+
|
|
1436
|
+
// Apply value selection synchronously so that static-HTML fixtures
|
|
1437
|
+
// resolve within a single update cycle. The refactored selectByValue
|
|
1438
|
+
// no longer calls reset() first, so the destructive intermediate-event
|
|
1439
|
+
// cascade that originally required deferral is eliminated. If option
|
|
1440
|
+
// keys are not yet resolved (framework mount-order race), selectByValue
|
|
1441
|
+
// queues a bounded retry automatically via queuePendingValue.
|
|
1442
|
+
if (changedProperties.has('value') && !this.internalUpdateInProgress) {
|
|
1443
|
+
this.menuService.selectByValue(this.value);
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
// Handle loading state changes
|
|
1447
|
+
if (changedProperties.has('loading')) {
|
|
1448
|
+
this.setLoadingState(this.loading);
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
if (changedProperties.has('multiSelect') && this.rootMenu) {
|
|
1452
|
+
if (this.multiSelect) {
|
|
1453
|
+
this.setAttribute('aria-multiselectable', 'true');
|
|
1454
|
+
} else {
|
|
1455
|
+
this.removeAttribute('aria-multiselectable');
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
/**
|
|
1461
|
+
* Sets an attribute that matches the default tag name if the tag name is not the default.
|
|
1462
|
+
* @param {string} tagName - The tag name to set as an attribute.
|
|
1463
|
+
* @private
|
|
1464
|
+
*/
|
|
1465
|
+
setTagAttribute(tagName) {
|
|
1466
|
+
if (this.tagName.toLowerCase() !== tagName) {
|
|
1467
|
+
this.setAttribute(tagName, true);
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
/**
|
|
1472
|
+
* Sets the loading state and dispatches a loading change event.
|
|
1473
|
+
* @param {boolean} isLoading - Whether the menu is loading.
|
|
1474
|
+
* @protected
|
|
1475
|
+
*/
|
|
1476
|
+
setLoadingState(isLoading) {
|
|
1477
|
+
this.setAttribute("aria-busy", isLoading);
|
|
1478
|
+
dispatchMenuEvent(this, "auroMenu-loadingChange", {
|
|
1479
|
+
loading: isLoading,
|
|
1480
|
+
hasLoadingPlaceholder: this.hasLoadingPlaceholder
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
// Init Methods
|
|
1485
|
+
|
|
1486
|
+
/**
|
|
1487
|
+
* Initializes the menu's state and structure.
|
|
1488
|
+
* @private
|
|
1489
|
+
*/
|
|
1490
|
+
initializeMenu() {
|
|
1491
|
+
if (this.rootMenu) {
|
|
1492
|
+
this.setAttribute('role', 'listbox');
|
|
1493
|
+
this.setAttribute('root', '');
|
|
1494
|
+
|
|
1495
|
+
if (this.multiSelect) {
|
|
1496
|
+
this.setAttribute('aria-multiselectable', 'true');
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
this.handleNestedMenus(this);
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
/**
|
|
1504
|
+
* Selects the currently highlighted option.
|
|
1505
|
+
* @protected
|
|
1506
|
+
*/
|
|
1507
|
+
makeSelection() {
|
|
1508
|
+
this.menuService.selectHighlightedOption();
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
/**
|
|
1512
|
+
* Resets all options to their default state.
|
|
1513
|
+
* @private
|
|
1514
|
+
*/
|
|
1515
|
+
clearSelection() {
|
|
1516
|
+
this.optionSelected = undefined;
|
|
1517
|
+
this.value = undefined;
|
|
1518
|
+
this._index = -1;
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
/**
|
|
1522
|
+
* Resets the menu to its initial state.
|
|
1523
|
+
* This is the only way to return value to undefined.
|
|
1524
|
+
* @public
|
|
1525
|
+
*/
|
|
1526
|
+
reset() {
|
|
1527
|
+
this.menuService.reset();
|
|
1528
|
+
|
|
1529
|
+
// Dispatch reset event
|
|
1530
|
+
dispatchMenuEvent(this, 'auroMenu-selectValueReset');
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
/**
|
|
1534
|
+
* Handles nested menu structure.
|
|
1535
|
+
* @private
|
|
1536
|
+
* @param {HTMLElement} menu - Root menu element.
|
|
1537
|
+
*/
|
|
1538
|
+
handleNestedMenus(menu) {
|
|
1539
|
+
menu.level = menu.parentElement.level >= 0 ? menu.parentElement.level + 1 : 0;
|
|
1540
|
+
|
|
1541
|
+
if (menu.level > 0) {
|
|
1542
|
+
menu.setAttribute('role', 'group');
|
|
1543
|
+
menu.removeAttribute("root");
|
|
1544
|
+
if (!menu.hasAttribute('aria-label')) {
|
|
1545
|
+
menu.setAttribute('aria-label', 'submenu');
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
const options = menu.querySelectorAll(':scope > auro-menuoption, :scope > [auro-menuoption]');
|
|
1550
|
+
options.forEach((option) => {
|
|
1551
|
+
const regex = new RegExp(this.nestingSpacer, "gu");
|
|
1552
|
+
option.innerHTML = this.nestingSpacer.repeat(menu.level) + option.innerHTML.replace(regex, '');
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
/**
|
|
1557
|
+
* Navigates the menu options in the specified direction.
|
|
1558
|
+
* @param {'up'|'down'} direction - The direction to navigate.
|
|
1559
|
+
* @protected
|
|
1560
|
+
*/
|
|
1561
|
+
navigateOptions(direction) {
|
|
1562
|
+
if (direction === 'up') {
|
|
1563
|
+
this.menuService.highlightPrevious();
|
|
1564
|
+
} else if (direction === 'down') {
|
|
1565
|
+
this.menuService.highlightNext();
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
/**
|
|
1570
|
+
* Handles slot change events.
|
|
1571
|
+
* @private
|
|
1572
|
+
*/
|
|
1573
|
+
handleSlotChange() {
|
|
1574
|
+
if (this.rootMenu) {
|
|
1575
|
+
this.initializeMenu();
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
/**
|
|
1580
|
+
* Handles custom events defined on options.
|
|
1581
|
+
* @private
|
|
1582
|
+
* @param {HTMLElement} option - Option with custom event.
|
|
1583
|
+
*/
|
|
1584
|
+
handleCustomEvent(option) {
|
|
1585
|
+
const eventName = option.getAttribute('event');
|
|
1586
|
+
dispatchMenuEvent(this, eventName);
|
|
1587
|
+
dispatchMenuEvent(this, 'auroMenu-customEventFired');
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
/**
|
|
1591
|
+
* Notifies selection change to parent components.
|
|
1592
|
+
* @param {any} source - The source that triggers this event.
|
|
1593
|
+
* @private
|
|
1594
|
+
*/
|
|
1595
|
+
notifySelectionChange({value, stringValue, keys, options, reason} = {}) {
|
|
1596
|
+
dispatchMenuEvent(this, 'auroMenu-selectedOption', {
|
|
1597
|
+
value,
|
|
1598
|
+
stringValue,
|
|
1599
|
+
keys,
|
|
1600
|
+
options,
|
|
1601
|
+
reason
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
/**
|
|
1606
|
+
* Checks if an option is currently selected.
|
|
1607
|
+
* @private
|
|
1608
|
+
* @param {HTMLElement} option - The option to check.
|
|
1609
|
+
* @returns {boolean}
|
|
1610
|
+
*/
|
|
1611
|
+
isOptionSelected(option) {
|
|
1612
|
+
if (!this.optionSelected) {
|
|
1613
|
+
return false;
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
if (this.multiSelect) {
|
|
1617
|
+
// In multi-select mode, check if the option is in the selected array
|
|
1618
|
+
return Array.isArray(this.optionSelected) && this.optionSelected.some((selectedOption) => selectedOption === option);
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
return this.optionSelected === option;
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
/**
|
|
1625
|
+
* Getter for loading placeholder state.
|
|
1626
|
+
* @returns {boolean} - True if loading slots are present and non-empty.
|
|
1627
|
+
*/
|
|
1628
|
+
get hasLoadingPlaceholder() {
|
|
1629
|
+
return this.loadingSlots && this.loadingSlots.length > 0;
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
/**
|
|
1633
|
+
* Getter for wrapper classes based on size.
|
|
1634
|
+
* @returns {Object} - Class map for the wrapper element.
|
|
1635
|
+
* @private
|
|
1636
|
+
*/
|
|
1637
|
+
get wrapperClasses() {
|
|
1638
|
+
return e({
|
|
1639
|
+
'menuWrapper': true,
|
|
1640
|
+
[this.size]: true,
|
|
1641
|
+
});
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
/**
|
|
1645
|
+
* Logic to determine the layout of the component.
|
|
1646
|
+
* @protected
|
|
1647
|
+
* @returns {void}
|
|
1648
|
+
*/
|
|
1649
|
+
renderLayout() {
|
|
1650
|
+
if (this.loading) {
|
|
1651
|
+
return b`
|
|
1652
|
+
<div class="${this.wrapperClasses}">
|
|
1653
|
+
<auro-menuoption
|
|
1654
|
+
disabled
|
|
1655
|
+
loadingplaceholder
|
|
1656
|
+
class="${this.hasLoadingPlaceholder ? "" : "empty"}"
|
|
1657
|
+
>
|
|
1658
|
+
<div>
|
|
1659
|
+
<slot name="loadingIcon" class="body-lg"></slot>
|
|
1660
|
+
<slot name="loadingText"></slot>
|
|
1661
|
+
</div>
|
|
1662
|
+
</auro-menuoption>
|
|
1663
|
+
</div>
|
|
1664
|
+
`;
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
return b`
|
|
1668
|
+
<div class="${this.wrapperClasses}">
|
|
1669
|
+
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
1670
|
+
</div>
|
|
1671
|
+
`;
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
/**
|
|
1676
|
+
* @license
|
|
1677
|
+
* Copyright 2020 Google LLC
|
|
1678
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
1679
|
+
*/
|
|
1680
|
+
const a=Symbol.for(""),o$1=t=>{if(t?.r===a)return t?._$litStatic$},s=t=>({_$litStatic$:t,r:a}),i=(t,...r)=>({_$litStatic$:r.reduce((r,e,a)=>r+(t=>{if(void 0!==t._$litStatic$)return t._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${t}. Use 'unsafeStatic' to pass non-literal values, but\n take care to ensure page security.`)})(e)+t[a+1],t[0]),r:a}),l=new Map,n=t=>(r,...e)=>{const a=e.length;let s,i;const n=[],u=[];let c,$=0,f=false;for(;$<a;){for(c=r[$];$<a&&void 0!==(i=e[$],s=o$1(i));)c+=s+r[++$],f=true;$!==a&&u.push(i),n.push(c),$++;}if($===a&&n.push(r[a]),f){const t=n.join("$$lit$$");void 0===(r=l.get(t))&&(n.raw=n,l.set(t,r=n)),e=u;}return t(r,...e)},u$1=n(b);
|
|
1681
|
+
|
|
1682
|
+
var styleCss = i$6`.body-default{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-default-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-default-font-size, 1rem);line-height:var(--wcss-body-default-line-height, 1.5rem)}.body-default-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-default-emphasized-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-default-emphasized-font-size, 1rem);line-height:var(--wcss-body-default-emphasized-line-height, 1.5rem)}.body-lg{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-lg-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-lg-font-size, 1.125rem);line-height:var(--wcss-body-lg-line-height, 1.625rem)}.body-lg-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-lg-emphasized-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-lg-emphasized-font-size, 1.125rem);line-height:var(--wcss-body-lg-emphasized-line-height, 1.625rem)}.body-sm{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-sm-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-sm-font-size, 0.875rem);line-height:var(--wcss-body-sm-line-height, 1.25rem)}.body-sm-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-sm-emphasized-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-sm-emphasized-font-size, 0.875rem);line-height:var(--wcss-body-sm-emphasized-line-height, 1.25rem)}.body-xs{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-xs-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-xs-font-size, 0.75rem);line-height:var(--wcss-body-xs-line-height, 1rem)}.body-xs-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-xs-emphasized-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-xs-emphasized-font-size, 0.75rem);line-height:var(--wcss-body-xs-emphasized-line-height, 1rem)}.body-2xs{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-2xs-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-2xs-font-size, 0.625rem);line-height:var(--wcss-body-2xs-line-height, 0.875rem)}.body-2xs-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-2xs-emphasized-weight, );letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-2xs-emphasized-font-size, 0.625rem);line-height:var(--wcss-body-2xs-emphasized-line-height, 0.875rem)}.display-2xl{font-family:var(--wcss-display-2xl-family, "AS Circular"),var(--wcss-display-2xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-display-2xl-weight, 300);line-height:var(--wcss-display-2xl-line-height, 1.3);font-size:var(--wcss-display-2xl-font-size, clamp(3.5rem, 6vw, 5.375rem));letter-spacing:var(--wcss-display-2xl-letter-spacing, 0)}.display-xl{font-family:var(--wcss-display-xl-family, "AS Circular"),var(--wcss-display-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-display-xl-weight, 300);line-height:var(--wcss-display-xl-line-height, 1.3);font-size:var(--wcss-display-xl-font-size, clamp(3rem, 5.3333333333vw, 4.5rem));letter-spacing:var(--wcss-display-xl-letter-spacing, 0)}.display-lg{font-family:var(--wcss-display-lg-family, "AS Circular"),var(--wcss-display-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-display-lg-weight, 300);line-height:var(--wcss-display-lg-line-height, 1.3);font-size:var(--wcss-display-lg-font-size, clamp(2.75rem, 4.6666666667vw, 4rem));letter-spacing:var(--wcss-display-lg-letter-spacing, 0)}.display-md{font-family:var(--wcss-display-md-family, "AS Circular"),var(--wcss-display-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-display-md-weight, 300);line-height:var(--wcss-display-md-line-height, 1.3);font-size:var(--wcss-display-md-font-size, clamp(2.5rem, 4vw, 3.5rem));letter-spacing:var(--wcss-display-md-letter-spacing, 0)}.display-sm{font-family:var(--wcss-display-sm-family, "AS Circular"),var(--wcss-display-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-display-sm-weight, 300);line-height:var(--wcss-display-sm-line-height, 1.3);font-size:var(--wcss-display-sm-font-size, clamp(2rem, 3.6666666667vw, 3rem));letter-spacing:var(--wcss-display-sm-letter-spacing, 0)}.display-xs{font-family:var(--wcss-display-xs-family, "AS Circular"),var(--wcss-display-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-display-xs-weight, 300);line-height:var(--wcss-display-xs-line-height, 1.3);font-size:var(--wcss-display-xs-font-size, clamp(1.75rem, 3vw, 2.375rem));letter-spacing:var(--wcss-display-xs-letter-spacing, 0)}.heading-xl{font-family:var(--wcss-heading-xl-family, "AS Circular"),var(--wcss-heading-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-heading-xl-weight, 300);line-height:var(--wcss-heading-xl-line-height, 1.3);font-size:var(--wcss-heading-xl-font-size, clamp(2rem, 3vw, 2.5rem));letter-spacing:var(--wcss-heading-xl-letter-spacing, 0)}.heading-lg{font-family:var(--wcss-heading-lg-family, "AS Circular"),var(--wcss-heading-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-heading-lg-weight, 300);line-height:var(--wcss-heading-lg-line-height, 1.3);font-size:var(--wcss-heading-lg-font-size, clamp(1.75rem, 2.6666666667vw, 2.25rem));letter-spacing:var(--wcss-heading-lg-letter-spacing, 0)}.heading-md{font-family:var(--wcss-heading-md-family, "AS Circular"),var(--wcss-heading-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-heading-md-weight, 300);line-height:var(--wcss-heading-md-line-height, 1.3);font-size:var(--wcss-heading-md-font-size, clamp(1.625rem, 2.3333333333vw, 1.75rem));letter-spacing:var(--wcss-heading-md-letter-spacing, 0)}.heading-sm{font-family:var(--wcss-heading-sm-family, "AS Circular"),var(--wcss-heading-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-heading-sm-weight, 300);line-height:var(--wcss-heading-sm-line-height, 1.3);font-size:var(--wcss-heading-sm-font-size, clamp(1.375rem, 2vw, 1.5rem));letter-spacing:var(--wcss-heading-sm-letter-spacing, 0)}.heading-xs{font-family:var(--wcss-heading-xs-family, "AS Circular"),var(--wcss-heading-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-heading-xs-weight, 300);line-height:var(--wcss-heading-xs-line-height, 1.3);font-size:var(--wcss-heading-xs-font-size, clamp(1.25rem, 1.6666666667vw, 1.25rem));letter-spacing:var(--wcss-heading-xs-letter-spacing, 0)}.heading-2xs{font-family:var(--wcss-heading-2xs-family, "AS Circular"),var(--wcss-heading-2xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-heading-2xs-weight, 300);line-height:var(--wcss-heading-2xs-line-height, 1.3);font-size:var(--wcss-heading-2xs-font-size, clamp(1.125rem, 1.5vw, 1.125rem));letter-spacing:var(--wcss-heading-2xs-letter-spacing, 0)}.accent-2xl{font-family:var(--wcss-accent-2xl-family, "Good OT"),var(--wcss-accent-2xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-accent-2xl-weight, 450);line-height:var(--wcss-accent-2xl-line-height, 1);font-size:var(--wcss-accent-2xl-font-size, clamp(2rem, 3.1666666667vw, 2.375rem));letter-spacing:var(--wcss-accent-2xl-letter-spacing, 0.05em);text-transform:uppercase}.accent-xl{font-family:var(--wcss-accent-xl-family, "Good OT"),var(--wcss-accent-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-accent-xl-weight, 450);line-height:var(--wcss-accent-xl-line-height, 1.3);font-size:var(--wcss-accent-xl-font-size, clamp(1.625rem, 2.3333333333vw, 2rem));letter-spacing:var(--wcss-accent-xl-letter-spacing, 0.05em);text-transform:uppercase}.accent-lg{font-family:var(--wcss-accent-lg-family, "Good OT"),var(--wcss-accent-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-accent-lg-weight, 450);line-height:var(--wcss-accent-lg-line-height, 1.3);font-size:var(--wcss-accent-lg-font-size, clamp(1.5rem, 2.1666666667vw, 1.75rem));letter-spacing:var(--wcss-accent-lg-letter-spacing, 0.05em);text-transform:uppercase}.accent-md{font-family:var(--wcss-accent-md-family, "Good OT"),var(--wcss-accent-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-accent-md-weight, 500);line-height:var(--wcss-accent-md-line-height, 1.3);font-size:var(--wcss-accent-md-font-size, clamp(1.375rem, 1.8333333333vw, 1.5rem));letter-spacing:var(--wcss-accent-md-letter-spacing, 0.05em);text-transform:uppercase}.accent-sm{font-family:var(--wcss-accent-sm-family, "Good OT"),var(--wcss-accent-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-accent-sm-weight, 500);line-height:var(--wcss-accent-sm-line-height, 1.3);font-size:var(--wcss-accent-sm-font-size, clamp(1.125rem, 1.5vw, 1.25rem));letter-spacing:var(--wcss-accent-sm-letter-spacing, 0.05em);text-transform:uppercase}.accent-xs{font-family:var(--wcss-accent-xs-family, "Good OT"),var(--wcss-accent-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-accent-xs-weight, 500);line-height:var(--wcss-accent-xs-line-height, 1.3);font-size:var(--wcss-accent-xs-font-size, clamp(1rem, 1.3333333333vw, 1rem));letter-spacing:var(--wcss-accent-xs-letter-spacing, 0.1em);text-transform:uppercase}.accent-2xs{font-family:var(--wcss-accent-2xs-family, "Good OT"),var(--wcss-accent-2xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-weight:var(--wcss-accent-2xs-weight, 450);line-height:var(--wcss-accent-2xs-line-height, 1.3);font-size:var(--wcss-accent-2xs-font-size, clamp(0.875rem, 1.1666666667vw, 0.875rem));letter-spacing:var(--wcss-accent-2xs-letter-spacing, 0.1em);text-transform:uppercase}:host{cursor:pointer;user-select:none;text-overflow:ellipsis;max-width:100dvw}:host .wrapper{display:flex;align-items:center;height:var(--ds-size-400, 2rem);padding-right:var(--ds-size-200, 1rem);padding-left:calc(var(--ds-size-150, 0.75rem) + var(--ds-size-300, 1.5rem) + var(--ds-size-100, 0.5rem));border-radius:var(--ds-size-100, 0.5rem);-webkit-tap-highlight-color:transparent}:host .wrapper[class*=shape-box]{border-radius:unset}:host .wrapper[class*=shape-snowflake]{border-radius:unset;line-height:24px}:host .wrapper[class*=shape-pill]{border-radius:30px}:host .wrapper[class*=-lg]{padding-top:var(--ds-size-75, 0.375rem);padding-bottom:var(--ds-size-75, 0.375rem);padding-right:var(--ds-size-150, 0.75rem);line-height:26px}:host .wrapper[class*=-xl]{padding-top:var(--ds-size-100, 0.5rem);padding-bottom:var(--ds-size-100, 0.5rem);padding-right:var(--ds-size-200, 1rem);line-height:26px}:host slot{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host [auro-icon]{--ds-auro-icon-size: var(--ds-size-300, 1.5rem);margin-right:var(--ds-size-150, 0.75rem);margin-left:var(--ds-size-100, 0.5rem)}:host ::slotted(.nestingSpacer){display:inline-block;width:var(--ds-size-300, 1.5rem)}[slot=displayValue]{display:none}:host([loadingplaceholder]) .wrapper{padding-left:calc(var(--ds-size-150, 0.75rem) + var(--ds-size-300, 1.5rem) + var(--ds-size-100, 0.5rem))}:host([selected]) .wrapper{padding-left:0}:host([nocheckmark]) .wrapper{padding-left:var(--ds-size-150, 0.75rem)}:host([nocheckmark]) .wrapper[class*=-lg]{padding-left:var(--ds-size-150, 0.75rem)}:host([nocheckmark]) .wrapper[class*=-xl]{padding-left:var(--ds-size-200, 1rem)}:host([hidden]){display:none}:host([static]){pointer-events:none}:host([disabled]:hover){cursor:auto}:host([disabled]){user-select:none;pointer-events:none}`;
|
|
1683
|
+
|
|
1684
|
+
var colorCss = i$6`:host .wrapper{background-color:var(--ds-auro-menuoption-container-color, transparent);box-shadow:inset 0 0 0 1px var(--ds-auro-menuoption-container-border-color, transparent);color:var(--ds-auro-menuoption-text-color)}:host svg{fill:var(--ds-auro-menuoption-icon-color)}:host([disabled]){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-default, #ffffff);--ds-auro-menuoption-text-color: var(--ds-basic-color-texticon-disabled, #d0d0d0);--ds-auro-menuoption-icon-color: var(--ds-basic-color-texticon-disabled, #d0d0d0)}:host(.active){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-muted, #ebfafd)}@media(hover: hover){:host(:hover){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-muted, #ebfafd)}}:host(:focus){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-default, #ffffff);--ds-auro-menuoption-container-border-color: var(--ds-basic-color-border-brand, #00274a)}:host([selected]){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-subtle, #b4eff9);--ds-auro-menuoption-text-color: var(--ds-basic-color-texticon-default, #2a2a2a);--ds-auro-menuoption-icon-color: var(--ds-basic-color-texticon-default, #2a2a2a)}:host([selected].active){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-muted, #ebfafd)}@media(hover: hover){:host([selected]:hover){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-muted, #ebfafd)}}:host([selected]:focus){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-subtle, #b4eff9);--ds-auro-menuoption-container-border-color: var(--ds-basic-color-border-brand, #00274a)}:host(:focus.active){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-muted, #ebfafd);--ds-auro-menuoption-container-border-color: var(--ds-basic-color-border-brand, #00274a)}@media(hover: hover){:host(:focus:hover){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-muted, #ebfafd);--ds-auro-menuoption-container-border-color: var(--ds-basic-color-border-brand, #00274a)}}:host([selected]:focus.active){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-muted, #ebfafd);--ds-auro-menuoption-container-border-color: var(--ds-basic-color-border-brand, #00274a)}@media(hover: hover){:host([selected]:focus:hover){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-muted, #ebfafd);--ds-auro-menuoption-container-border-color: var(--ds-basic-color-border-brand, #00274a)}}`;
|
|
1685
|
+
|
|
1686
|
+
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
1687
|
+
// See LICENSE in the project root for license information.
|
|
1688
|
+
|
|
1689
|
+
|
|
1690
|
+
class AuroDependencyVersioning {
|
|
1691
|
+
|
|
1692
|
+
/**
|
|
1693
|
+
* Generates a unique string to be used for child auro element naming.
|
|
1694
|
+
* @private
|
|
1695
|
+
* @param {string} baseName - Defines the first part of the unique element name.
|
|
1696
|
+
* @param {string} version - Version of the component that will be appended to the baseName.
|
|
1697
|
+
* @returns {string} - Unique string to be used for naming.
|
|
1698
|
+
*/
|
|
1699
|
+
generateElementName(baseName, version) {
|
|
1700
|
+
let result = baseName;
|
|
1701
|
+
|
|
1702
|
+
result += '-';
|
|
1703
|
+
result += version.replace(/[.]/g, '_');
|
|
1704
|
+
|
|
1705
|
+
return result;
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
/**
|
|
1709
|
+
* Generates a unique string to be used for child auro element naming.
|
|
1710
|
+
* @param {string} baseName - Defines the first part of the unique element name.
|
|
1711
|
+
* @param {string} version - Version of the component that will be appended to the baseName.
|
|
1712
|
+
* @returns {string} - Unique string to be used for naming.
|
|
1713
|
+
*/
|
|
1714
|
+
generateTag(baseName, version, tagClass) {
|
|
1715
|
+
const elementName = this.generateElementName(baseName, version);
|
|
1716
|
+
const tag = i`${s(elementName)}`;
|
|
1717
|
+
|
|
1718
|
+
if (!customElements.get(elementName)) {
|
|
1719
|
+
customElements.define(elementName, class extends tagClass {});
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
return tag;
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
/**
|
|
1727
|
+
* @license
|
|
1728
|
+
* Copyright 2018 Google LLC
|
|
1729
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
1730
|
+
*/const o=o=>o??A;
|
|
1731
|
+
|
|
1732
|
+
class p{registerComponent(t,a){customElements.get(t)||customElements.define(t,class extends a{});}closestElement(t,a=this,e=(a,s=a&&a.closest(t))=>a&&a!==document&&a!==window?s||e(a.getRootNode().host):null){return e(a)}handleComponentTagRename(t,a){const e=a.toLowerCase();t.tagName.toLowerCase()!==e&&t.setAttribute(e,true);}elementMatch(t,a){const e=a.toLowerCase();return t.tagName.toLowerCase()===e||t.hasAttribute(e)}getSlotText(t,a){const e=t.shadowRoot?.querySelector(`slot[name="${a}"]`);return (e?.assignedNodes({flatten:true})||[]).map(t=>t.textContent?.trim()).join(" ").trim()||null}}var u='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-labelledby="error__desc" class="ico_squareLarge" data-deprecated="true" role="img" style="min-width:var(--auro-size-lg, var(--ds-size-300, 1.5rem));height:var(--auro-size-lg, var(--ds-size-300, 1.5rem));fill:currentColor" viewBox="0 0 24 24" part="svg"><title/><desc id="error__desc">Error alert indicator.</desc><path d="m13.047 5.599 6.786 11.586A1.207 1.207 0 0 1 18.786 19H5.214a1.207 1.207 0 0 1-1.047-1.815l6.786-11.586a1.214 1.214 0 0 1 2.094 0m-1.165.87a.23.23 0 0 0-.085.085L5.419 17.442a.232.232 0 0 0 .203.35h12.756a.234.234 0 0 0 .203-.35L12.203 6.554a.236.236 0 0 0-.321-.084M12 15.5a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m-.024-6.22c.325 0 .589.261.589.583v4.434a.586.586 0 0 1-.589.583.586.586 0 0 1-.588-.583V9.863c0-.322.264-.583.588-.583"/></svg>',g='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" style="min-width:100%;height:auto;fill:currentColor" viewBox="0 0 142 138" part="svg"><title id="tail-DEFAULT__title">Airplane tail default image with light gray color</title><path fill="url(#paint0_linear_9225_2069)" fill-rule="evenodd" d="M124.093 14.665a3.26 3.26 0 0 1 3.208 3.829L101.097 119.85c-.47 1.087-2.211 3.398-5.692 3.471l-.106.001-80.65.013A659230 659230 0 0 1 99.08 17.412c1.214-1.497 3.275-2.722 5.372-2.747z" clip-rule="evenodd"/><defs><linearGradient id="paint0_linear_9225_2069" x1="114.823" x2="60.061" y1="14.665" y2="123.335" gradientUnits="userSpaceOnUse"><stop offset=".5" stop-color="#707984"/><stop offset=".5" stop-color="#646E7B"/></linearGradient></defs></svg>';class m extends i$3{static get properties(){return {hidden:{type:Boolean,reflect:true},hiddenVisually:{type:Boolean,reflect:true},hiddenAudible:{type:Boolean,reflect:true}}}hideAudible(t){return t?"true":"false"}}const f=new Map,w=(t,a={})=>{const e=a.responseParser||(t=>t.text());return f.has(t)||f.set(t,fetch(t).then(e)),f.get(t)};var z=i$6`:focus:not(:focus-visible){outline:3px solid transparent}.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock,:host{display:block}.util_displayFlex{display:flex}.util_displayHidden,:host([hidden]:not(:focus):not(:active)){display:none}.util_displayHiddenVisually,:host([hiddenVisually]:not(:focus):not(:active)){position:absolute;overflow:hidden;clip:rect(1px,1px,1px,1px);width:1px;height:1px;padding:0;border:0}.ico_squareLarge{fill:currentColor;height:var(--auro-size-lg, var(--ds-size-300, 1.5rem))}.ico_squareSmall{fill:currentColor;height:.6rem}.ico_squareMed{fill:currentColor;height:var(--auro-size-md, var(--ds-size-200, 1rem))}.ico_squareSml{fill:currentColor;height:var(--auro-size-sm, var(--ds-size-150, .75rem))}:host{color:currentColor;vertical-align:middle;display:inline-block}svg{min-width:var(--ds-auro-icon-size, 1.5rem)!important;width:var(--ds-auro-icon-size, 1.5rem)!important;height:var(--ds-auro-icon-size, 1.5rem)!important}.componentWrapper{display:flex;line-height:var(--ds-auro-icon-size)}.svgWrapper{height:var(--ds-auro-icon-size);width:var(--ds-auro-icon-size)}.svgWrapper [part=svg]{display:flex}.labelWrapper{margin-left:var(--ds-size-50, .25rem)}.labelWrapper ::slotted(*){line-height:inherit!important}
|
|
1733
|
+
`;class y extends m{constructor(){super(),this._initializeDefaults();}_initializeDefaults(){this.onDark=false,this.appearance="default";}static get properties(){return {...m.properties,onDark:{type:Boolean,reflect:true},appearance:{type:String,reflect:true},svg:{attribute:false,reflect:true}}}static get styles(){return z}async fetchIcon(t,a){let e="";e="logos"===t?await w(`${this.uri}/${t}/${a}.svg`):await w(`${this.uri}/icons/${t}/${a}.svg`);return (new DOMParser).parseFromString(e,"text/html").body.querySelector("svg")}async firstUpdated(){try{if(!this.customSvg){const t=await this.fetchIcon(this.category,this.name);if(t)this.svg=t;else if(!t){const t=this.name?.startsWith("tail-")?g:u;this.svg=(new DOMParser).parseFromString(t,"text/html").body.querySelector("svg");}}}catch(t){this.svg=void 0;}}}i$6`.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock,:host{display:block}.util_displayFlex{display:flex}.util_displayHidden,:host([hidden]:not(:focus):not(:active)){display:none}.util_displayHiddenVisually,:host([hiddenVisually]:not(:focus):not(:active)){position:absolute;overflow:hidden;clip:rect(1px,1px,1px,1px);width:1px;height:1px;padding:0;border:0}:host{display:inline-block;--ds-auro-icon-size: 100%;width:100%;height:100%}:host .logo{color:var(--ds-auro-alaska-color)}:host([onDark]),:host([appearance=inverse]){--ds-auro-alaska-color: #FFF}
|
|
1734
|
+
`;var M=i$6`:host{--ds-auro-icon-color: var(--ds-basic-color-texticon-default, #2a2a2a);--ds-auro-alaska-color: #02426D;--ds-auro-icon-size: var(--ds-size-300, 1.5rem)}
|
|
1735
|
+
`;var _=i$6`:host{color:var(--ds-auro-icon-color)}:host([customColor]){color:inherit}:host(:not([onDark])[variant=accent1]),:host(:not([appearance=inverse])[variant=accent1]){--ds-auro-icon-color: var(--ds-basic-color-texticon-accent1, #265688)}:host(:not([onDark])[variant=disabled]),:host(:not([appearance=inverse])[variant=disabled]){--ds-auro-icon-color: var(--ds-basic-color-texticon-disabled, #d0d0d0)}:host(:not([onDark])[variant=muted]),:host(:not([appearance=inverse])[variant=muted]){--ds-auro-icon-color: var(--ds-basic-color-texticon-muted, #676767)}:host(:not([onDark])[variant=statusDefault]),:host(:not([appearance=inverse])[variant=statusDefault]){--ds-auro-icon-color: var(--ds-basic-color-status-default, #afb9c6)}:host(:not([onDark])[variant=statusInfo]),:host(:not([appearance=inverse])[variant=statusInfo]){--ds-auro-icon-color: var(--ds-basic-color-status-info, #01426a)}:host(:not([onDark])[variant=statusSuccess]),:host(:not([appearance=inverse])[variant=statusSuccess]){--ds-auro-icon-color: var(--ds-basic-color-status-success, #447a1f)}:host(:not([onDark])[variant=statusWarning]),:host(:not([appearance=inverse])[variant=statusWarning]){--ds-auro-icon-color: var(--ds-basic-color-status-warning, #fac200)}:host(:not([onDark])[variant=statusError]),:host(:not([appearance=inverse])[variant=statusError]){--ds-auro-icon-color: var(--ds-basic-color-status-error, #e31f26)}:host(:not([onDark])[variant=statusInfoSubtle]),:host(:not([appearance=inverse])[variant=statusInfoSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-info-subtle, #ebf3f9)}:host(:not([onDark])[variant=statusSuccessSubtle]),:host(:not([appearance=inverse])[variant=statusSuccessSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-success-subtle, #d6eac7)}:host(:not([onDark])[variant=statusWarningSubtle]),:host(:not([appearance=inverse])[variant=statusWarningSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-warning-subtle, #fff0b2)}:host(:not([onDark])[variant=statusErrorSubtle]),:host(:not([appearance=inverse])[variant=statusErrorSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-error-subtle, #fbc6c6)}:host(:not([onDark])[variant=fareBasicEconomy]),:host(:not([appearance=inverse])[variant=fareBasicEconomy]){--ds-auro-icon-color: var(--ds-basic-color-fare-basiceconomy, #97eaf8)}:host(:not([onDark])[variant=fareBusiness]),:host(:not([appearance=inverse])[variant=fareBusiness]){--ds-auro-icon-color: var(--ds-basic-color-fare-business, #01426a)}:host(:not([onDark])[variant=fareEconomy]),:host(:not([appearance=inverse])[variant=fareEconomy]){--ds-auro-icon-color: var(--ds-basic-color-fare-economy, #0074ca)}:host(:not([onDark])[variant=fareFirst]),:host(:not([appearance=inverse])[variant=fareFirst]){--ds-auro-icon-color: var(--ds-basic-color-fare-first, #00274a)}:host(:not([onDark])[variant=farePremiumEconomy]),:host(:not([appearance=inverse])[variant=farePremiumEconomy]){--ds-auro-icon-color: var(--ds-basic-color-fare-premiumeconomy, #005154)}:host(:not([onDark])[variant=tierOneWorldEmerald]),:host(:not([appearance=inverse])[variant=tierOneWorldEmerald]){--ds-auro-icon-color: var(--ds-basic-color-tier-program-oneworld-emerald, #139142)}:host(:not([onDark])[variant=tierOneWorldSapphire]),:host(:not([appearance=inverse])[variant=tierOneWorldSapphire]){--ds-auro-icon-color: var(--ds-basic-color-tier-program-oneworld-sapphire, #015daa)}:host(:not([onDark])[variant=tierOneWorldRuby]),:host(:not([appearance=inverse])[variant=tierOneWorldRuby]){--ds-auro-icon-color: var(--ds-basic-color-tier-program-oneworld-ruby, #a41d4a)}:host([onDark]),:host([appearance=inverse]){--ds-auro-icon-color: var(--ds-basic-color-texticon-inverse, #ffffff)}:host([onDark][variant=disabled]),:host([appearance=inverse][variant=disabled]){--ds-auro-icon-color: var(--ds-basic-color-texticon-inverse-disabled, #7e8894)}:host([onDark][variant=muted]),:host([appearance=inverse][variant=muted]){--ds-auro-icon-color: var(--ds-basic-color-texticon-inverse-muted, #ccd2db)}:host([onDark][variant=statusError]),:host([appearance=inverse][variant=statusError]){--ds-auro-icon-color: var(--ds-advanced-color-state-error-inverse, #f9a4a8)}
|
|
1736
|
+
`;class k extends y{constructor(){super(),this._initializeDefaults();}_initializeDefaults(){this.variant=void 0,this.uri="https://cdn.jsdelivr.net/npm/@alaskaairux/icons@latest/dist",this.runtimeUtils=new p;}static get properties(){return {...y.properties,ariaHidden:{type:String,reflect:true},category:{type:String,reflect:true},customColor:{type:Boolean,reflect:true},customSvg:{type:Boolean},label:{type:Boolean,reflect:true},name:{type:String,reflect:true},variant:{type:String,reflect:true}}}static get styles(){return [y.styles,M,z,_]}static register(t="auro-icon"){p.prototype.registerComponent(t,k);}connectedCallback(){super.connectedCallback(),this.runtimeUtils.handleComponentTagRename(this,"auro-icon");}exposeCssParts(){this.setAttribute("exportparts","svg:iconSvg");}async firstUpdated(){if(await super.firstUpdated(),this.hasAttribute("ariaHidden")&&this.svg){const t=this.svg.querySelector("desc");t&&(t.remove(),this.svg.removeAttribute("aria-labelledby"));}}render(){const t={labelWrapper:true,util_displayHiddenVisually:!this.label};return b`
|
|
1737
|
+
<div class="componentWrapper">
|
|
1738
|
+
<div
|
|
1739
|
+
class="${e({svgWrapper:true})}"
|
|
1740
|
+
title="${o(this.title||void 0)}">
|
|
1741
|
+
<span aria-hidden="${o(this.ariaHidden||true)}" part="svg">
|
|
1742
|
+
${this.customSvg?b`
|
|
1743
|
+
<slot name="svg"></slot>
|
|
1744
|
+
`:b`
|
|
1745
|
+
${this.svg}
|
|
1746
|
+
`}
|
|
1747
|
+
</span>
|
|
1748
|
+
</div>
|
|
1749
|
+
|
|
1750
|
+
<div class="${e(t)}" part="label">
|
|
1751
|
+
<slot></slot>
|
|
1752
|
+
</div>
|
|
1753
|
+
</div>
|
|
1754
|
+
`}}
|
|
1755
|
+
|
|
1756
|
+
var iconVersion = '9.1.2';
|
|
1757
|
+
|
|
1758
|
+
var checkmarkIcon = {"svg":"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" aria-labelledby=\"checkmark-sm__desc\" class=\"ico_squareLarge\" role=\"img\" style=\"min-width:var(--auro-size-lg, var(--ds-size-300, 1.5rem));height:var(--auro-size-lg, var(--ds-size-300, 1.5rem));fill:currentColor\" viewBox=\"0 0 24 24\" part=\"svg\"><title/><desc id=\"checkmark-sm__desc\">a small check mark.</desc><path d=\"M8.461 11.84a.625.625 0 1 0-.922.844l2.504 2.738c.247.27.674.27.922 0l5.496-6a.625.625 0 1 0-.922-.844l-5.035 5.496z\"/></svg>"};
|
|
1759
|
+
|
|
1760
|
+
// Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
1761
|
+
// See LICENSE in the project root for license information.
|
|
1762
|
+
|
|
1763
|
+
|
|
1764
|
+
let menuOptionIdCounter = 0;
|
|
1765
|
+
|
|
1766
|
+
/**
|
|
1767
|
+
* The `auro-menuoption` element provides users a way to define a menu option.
|
|
1768
|
+
* @customElement auro-menuoption
|
|
1769
|
+
*
|
|
1770
|
+
* @slot default - The default slot for the menu option text.
|
|
1771
|
+
*
|
|
1772
|
+
* @event auroMenuOption-mouseover - Notifies that this option has been hovered over.
|
|
1773
|
+
*/
|
|
1774
|
+
class AuroMenuOption extends AuroElement {
|
|
1775
|
+
|
|
1776
|
+
/**
|
|
1777
|
+
* This will register this element with the browser.
|
|
1778
|
+
* @param {string} [name="auro-menuoption"] - The name of the element that you want to register.
|
|
1779
|
+
*
|
|
1780
|
+
* @example
|
|
1781
|
+
* AuroMenuOption.register("custom-menuoption") // this will register this element to <custom-menuoption/>
|
|
1782
|
+
*
|
|
1783
|
+
*/
|
|
1784
|
+
static register(name = "auro-menuoption") {
|
|
1785
|
+
AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroMenuOption);
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
/**
|
|
1789
|
+
* Returns whether the menu option is currently active and selectable.
|
|
1790
|
+
* An option is considered active if it is not hidden, not disabled, and not static.
|
|
1791
|
+
* @returns {boolean} True if the option is active, false otherwise.
|
|
1792
|
+
*/
|
|
1793
|
+
get isActive() {
|
|
1794
|
+
return !this.hasAttribute('hidden') &&
|
|
1795
|
+
!this.disabled &&
|
|
1796
|
+
!this.hasAttribute('static');
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
constructor() {
|
|
1800
|
+
super();
|
|
1801
|
+
|
|
1802
|
+
this.bindEvents();
|
|
1803
|
+
|
|
1804
|
+
/**
|
|
1805
|
+
* @private
|
|
1806
|
+
*/
|
|
1807
|
+
this.shape = undefined;
|
|
1808
|
+
|
|
1809
|
+
/**
|
|
1810
|
+
* @private
|
|
1811
|
+
*/
|
|
1812
|
+
this.size = undefined;
|
|
1813
|
+
|
|
1814
|
+
/**
|
|
1815
|
+
* Generate unique names for dependency components.
|
|
1816
|
+
*/
|
|
1817
|
+
const versioning = new AuroDependencyVersioning();
|
|
1818
|
+
this.iconTag = versioning.generateTag('auro-formkit-menuoption-icon', iconVersion, k);
|
|
1819
|
+
|
|
1820
|
+
this.selected = false;
|
|
1821
|
+
this.noCheckmark = false;
|
|
1822
|
+
this.disabled = false;
|
|
1823
|
+
this.noMatch = false;
|
|
1824
|
+
|
|
1825
|
+
/**
|
|
1826
|
+
* @private
|
|
1827
|
+
*/
|
|
1828
|
+
this.runtimeUtils = new AuroLibraryRuntimeUtils();
|
|
1829
|
+
|
|
1830
|
+
// Initialize context-related properties
|
|
1831
|
+
this.menuService = null;
|
|
1832
|
+
this.unsubscribe = null;
|
|
1833
|
+
|
|
1834
|
+
/**
|
|
1835
|
+
* @private
|
|
1836
|
+
*/
|
|
1837
|
+
this.handleMenuChange = this.handleMenuChange.bind(this);
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
static get properties() {
|
|
1841
|
+
return {
|
|
1842
|
+
...super.properties,
|
|
1843
|
+
|
|
1844
|
+
/**
|
|
1845
|
+
* When true, disables the menu option.
|
|
1846
|
+
*/
|
|
1847
|
+
disabled: {
|
|
1848
|
+
type: Boolean,
|
|
1849
|
+
reflect: true
|
|
1850
|
+
},
|
|
1851
|
+
|
|
1852
|
+
/**
|
|
1853
|
+
* @private
|
|
1854
|
+
*/
|
|
1855
|
+
event: {
|
|
1856
|
+
type: String,
|
|
1857
|
+
reflect: true
|
|
1858
|
+
},
|
|
1859
|
+
|
|
1860
|
+
/**
|
|
1861
|
+
* @private
|
|
1862
|
+
*/
|
|
1863
|
+
layout: {
|
|
1864
|
+
type: String
|
|
1865
|
+
},
|
|
1866
|
+
|
|
1867
|
+
/**
|
|
1868
|
+
* Allows users to set a unique key for the menu option for specified option selection. If no key is provided, the value property will be used.
|
|
1869
|
+
*/
|
|
1870
|
+
key: {
|
|
1871
|
+
type: String,
|
|
1872
|
+
reflect: true
|
|
1873
|
+
},
|
|
1874
|
+
|
|
1875
|
+
/**
|
|
1876
|
+
* @private
|
|
1877
|
+
*/
|
|
1878
|
+
menuService: {
|
|
1879
|
+
type: Object,
|
|
1880
|
+
state: true
|
|
1881
|
+
},
|
|
1882
|
+
|
|
1883
|
+
/**
|
|
1884
|
+
* @private
|
|
1885
|
+
*/
|
|
1886
|
+
matchWord: {
|
|
1887
|
+
type: String,
|
|
1888
|
+
state: true
|
|
1889
|
+
},
|
|
1890
|
+
|
|
1891
|
+
/**
|
|
1892
|
+
* @private
|
|
1893
|
+
*/
|
|
1894
|
+
noCheckmark: {
|
|
1895
|
+
type: Boolean,
|
|
1896
|
+
reflect: true
|
|
1897
|
+
},
|
|
1898
|
+
|
|
1899
|
+
/**
|
|
1900
|
+
* When true, marks this option as the "no matching results" placeholder shown by combobox when the user's input does not match any available options. Enables distinct styling and prevents the option from being treated as a selectable match.
|
|
1901
|
+
*/
|
|
1902
|
+
noMatch: {
|
|
1903
|
+
type: Boolean,
|
|
1904
|
+
reflect: true,
|
|
1905
|
+
attribute: 'nomatch'
|
|
1906
|
+
},
|
|
1907
|
+
|
|
1908
|
+
/**
|
|
1909
|
+
* Specifies that an option is selected.
|
|
1910
|
+
*/
|
|
1911
|
+
selected: {
|
|
1912
|
+
type: Boolean,
|
|
1913
|
+
reflect: true
|
|
1914
|
+
},
|
|
1915
|
+
|
|
1916
|
+
/**
|
|
1917
|
+
* Specifies the tab index of the menu option.
|
|
1918
|
+
*/
|
|
1919
|
+
tabIndex: {
|
|
1920
|
+
type: Number,
|
|
1921
|
+
reflect: true
|
|
1922
|
+
},
|
|
1923
|
+
|
|
1924
|
+
/**
|
|
1925
|
+
* Specifies the value to be sent to a server.
|
|
1926
|
+
*/
|
|
1927
|
+
value: {
|
|
1928
|
+
type: String,
|
|
1929
|
+
reflect: true
|
|
1930
|
+
},
|
|
1931
|
+
};
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
static get styles() {
|
|
1935
|
+
return [
|
|
1936
|
+
styleCss,
|
|
1937
|
+
colorCss,
|
|
1938
|
+
tokensCss
|
|
1939
|
+
];
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
connectedCallback() {
|
|
1943
|
+
super.connectedCallback();
|
|
1944
|
+
|
|
1945
|
+
// Add the tag name as an attribute if it is different than the component name
|
|
1946
|
+
// Add this step soon as this node gets attached to the DOM to avoid racing condition with menu's value setting logic.
|
|
1947
|
+
this.runtimeUtils.handleComponentTagRename(this, 'auro-menuoption');
|
|
1948
|
+
|
|
1949
|
+
// Set up context consumption in connectedCallback
|
|
1950
|
+
this._contextConsumer = new s$2(this, {
|
|
1951
|
+
context: MenuContext,
|
|
1952
|
+
callback: this.attachTo.bind(this),
|
|
1953
|
+
subscribe: true
|
|
1954
|
+
});
|
|
1955
|
+
|
|
1956
|
+
// Establish the key property as early as possible.
|
|
1957
|
+
// When a framework (e.g. Svelte) inserts the element into the DOM before
|
|
1958
|
+
// setting its `value` property, both `getAttribute('value')` and
|
|
1959
|
+
// `getAttribute('key')` return null here. Setting `this.key = null`
|
|
1960
|
+
// would block the fallback in `updated()` that assigns key from the
|
|
1961
|
+
// value property (the guard checked `=== undefined`). Only assign key
|
|
1962
|
+
// if at least one source attribute is actually present so that the
|
|
1963
|
+
// `updated()` fallback can run when the value property arrives later.
|
|
1964
|
+
const valueAttr = this.getAttribute('value');
|
|
1965
|
+
const keyAttr = this.getAttribute('key');
|
|
1966
|
+
const resolvedKey = keyAttr !== null ? keyAttr : valueAttr;
|
|
1967
|
+
if (resolvedKey !== null) {
|
|
1968
|
+
this.key = resolvedKey;
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
firstUpdated() {
|
|
1973
|
+
// Add the tag name as an attribute if it is different than the component name
|
|
1974
|
+
this.runtimeUtils.handleComponentTagRename(this, 'auro-menuoption');
|
|
1975
|
+
|
|
1976
|
+
// Generate unique ID if not already set (required for aria-activedescendant)
|
|
1977
|
+
if (!this.id) {
|
|
1978
|
+
menuOptionIdCounter += 1;
|
|
1979
|
+
this.id = `menuoption-${menuOptionIdCounter}`;
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
this.setAttribute('role', 'option');
|
|
1983
|
+
this.setAttribute('aria-selected', 'false');
|
|
1984
|
+
|
|
1985
|
+
this.addEventListener('mouseover', () => {
|
|
1986
|
+
this.dispatchEvent(new CustomEvent('auroMenuOption-mouseover', {
|
|
1987
|
+
bubbles: true,
|
|
1988
|
+
cancelable: false,
|
|
1989
|
+
composed: true,
|
|
1990
|
+
detail: this
|
|
1991
|
+
}));
|
|
1992
|
+
});
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
updated(changedProperties) {
|
|
1996
|
+
super.updated(changedProperties);
|
|
1997
|
+
|
|
1998
|
+
// Update aria-selected attribute if selected changed
|
|
1999
|
+
if (changedProperties.has('selected')) {
|
|
2000
|
+
|
|
2001
|
+
// Update aria-selected attribute
|
|
2002
|
+
this.setAttribute('aria-selected', this.selected.toString());
|
|
2003
|
+
|
|
2004
|
+
// Update menu service selection state if this isn't an internal update
|
|
2005
|
+
if (this.internalUpdateInProgress !== true && this.menuService) {
|
|
2006
|
+
this.menuService[this.selected ? 'selectOption' : 'deselectOption'](this);
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
|
|
2010
|
+
if (changedProperties.has('disabled')) {
|
|
2011
|
+
if (this.disabled) {
|
|
2012
|
+
this.setAttribute('aria-disabled', 'true');
|
|
2013
|
+
} else {
|
|
2014
|
+
this.removeAttribute('aria-disabled');
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
if (changedProperties.has('active')) {
|
|
2019
|
+
this.updateActiveClasses();
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
// Update text highlight if matchWord changed
|
|
2023
|
+
if (changedProperties.has('matchWord')) {
|
|
2024
|
+
this.updateTextHighlight();
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
// Set the key to be the passed value if no key is provided.
|
|
2028
|
+
// Loose equality (== null) is intentional: it catches both null AND
|
|
2029
|
+
// undefined. When a framework (e.g. Svelte, React) inserts the element
|
|
2030
|
+
// before setting its value property, connectedCallback skips key
|
|
2031
|
+
// assignment because both attributes are null at that point. The Lit
|
|
2032
|
+
// property default for `key` is undefined (not null), so strict
|
|
2033
|
+
// === null would miss the case and the fallback would never run.
|
|
2034
|
+
if (changedProperties.has('value') && this.key == null) { // eslint-disable-line eqeqeq, no-eq-null
|
|
2035
|
+
this.key = this.value;
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
disconnectedCallback() {
|
|
2040
|
+
if (this.menuService) {
|
|
2041
|
+
this.menuService.unsubscribe(this.handleMenuChange);
|
|
2042
|
+
this.menuService.removeMenuOption(this);
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
/**
|
|
2047
|
+
* Sets up event listeners for user interaction with the menu option.
|
|
2048
|
+
* This function enables click and mouse enter events to trigger selection and highlighting logic.
|
|
2049
|
+
*/
|
|
2050
|
+
bindEvents() {
|
|
2051
|
+
this.addEventListener('click', this.handleClick.bind(this));
|
|
2052
|
+
this.addEventListener('mouseenter', this.handleMouseEnter.bind(this));
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
/**
|
|
2056
|
+
* Attaches this menu option to a menu service and subscribes to its events.
|
|
2057
|
+
* This method enables the option to participate in menu selection and highlighting logic.
|
|
2058
|
+
* @param {Object} service - The menu service instance to attach to.
|
|
2059
|
+
*/
|
|
2060
|
+
attachTo(service) {
|
|
2061
|
+
if (!service) {
|
|
2062
|
+
return;
|
|
2063
|
+
}
|
|
2064
|
+
this.menuService = service;
|
|
2065
|
+
this.menuService.addMenuOption(this);
|
|
2066
|
+
this.menuService.subscribe(this.handleMenuChange);
|
|
2067
|
+
}
|
|
2068
|
+
|
|
2069
|
+
/**
|
|
2070
|
+
* Handles changes from the menu service and updates the option's state.
|
|
2071
|
+
* This function synchronizes the option's properties and selection/highlight state with menu events.
|
|
2072
|
+
* @param {Object} event - The event object from the menu service.
|
|
2073
|
+
*/
|
|
2074
|
+
handleMenuChange(event) {
|
|
2075
|
+
|
|
2076
|
+
// Ignore events without a type or property
|
|
2077
|
+
if (!event || (!event.type && !event.property)) {
|
|
2078
|
+
return;
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
// Update reactive properties based on event type
|
|
2082
|
+
if (event.property && Object.keys(AuroMenuOption.properties).includes(event.property)) {
|
|
2083
|
+
this[event.property] = event.value;
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
// Handle highlight changes
|
|
2087
|
+
if (event.type === 'highlightChange') {
|
|
2088
|
+
const isActive = event.option === this;
|
|
2089
|
+
this.active = isActive;
|
|
2090
|
+
this.updateActiveClasses();
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
if (event.type === 'stateChange') {
|
|
2094
|
+
const isSelected = event.selectedOptions.includes(this);
|
|
2095
|
+
this.setInternalSelected(isSelected);
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
/**
|
|
2100
|
+
* Updates the internal selected state of the menu option bypassing 'updated' and triggers custom events if selected.
|
|
2101
|
+
* This function ensures the option's selection state is synchronized with menu logic and notifies listeners.
|
|
2102
|
+
* @param {boolean} isSelected - Whether the option should be marked as selected.
|
|
2103
|
+
*/
|
|
2104
|
+
setInternalSelected(isSelected) {
|
|
2105
|
+
this.internalUpdateInProgress = true;
|
|
2106
|
+
this.selected = isSelected;
|
|
2107
|
+
|
|
2108
|
+
// Fire custom event if selected
|
|
2109
|
+
if (isSelected) {
|
|
2110
|
+
this.handleCustomEvent();
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
setTimeout(() => {
|
|
2114
|
+
this.internalUpdateInProgress = false;
|
|
2115
|
+
}, 0);
|
|
2116
|
+
}
|
|
2117
|
+
|
|
2118
|
+
/**
|
|
2119
|
+
* Sets the selected state of the menu option.
|
|
2120
|
+
* This function updates whether the option is currently selected.
|
|
2121
|
+
* @param {boolean} isSelected - Whether the option should be marked as selected.
|
|
2122
|
+
* @deprecated Simply modify the `selected` property directly instead.
|
|
2123
|
+
*/
|
|
2124
|
+
setSelected(isSelected) {
|
|
2125
|
+
this.selected = isSelected;
|
|
2126
|
+
}
|
|
2127
|
+
|
|
2128
|
+
/**
|
|
2129
|
+
* Updates the active state and visual highlighting of the menu option.
|
|
2130
|
+
* This function toggles the option's active status and applies or removes the active CSS class.
|
|
2131
|
+
* @param {boolean} isActive - Whether the option should be marked as active.
|
|
2132
|
+
* @deprecated Simply modify the `active` property directly instead.
|
|
2133
|
+
*/
|
|
2134
|
+
updateActive(isActive) {
|
|
2135
|
+
|
|
2136
|
+
// Set active state
|
|
2137
|
+
this.active = isActive;
|
|
2138
|
+
this.updateActiveClasses();
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
/**
|
|
2142
|
+
* Updates the CSS class for the menu option based on its active state.
|
|
2143
|
+
* This function adds or removes the 'active' class to visually indicate the option's active status.
|
|
2144
|
+
* @private
|
|
2145
|
+
*/
|
|
2146
|
+
updateActiveClasses() {
|
|
2147
|
+
// Update class based on active state
|
|
2148
|
+
if (this.active) this.classList.add('active');
|
|
2149
|
+
else this.classList.remove('active');
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
|
|
2153
|
+
/**
|
|
2154
|
+
* Updates the visual highlighting of text within the menu option based on the current match word.
|
|
2155
|
+
* This function highlights matching text segments and manages nested spacers for display formatting.
|
|
2156
|
+
* @private
|
|
2157
|
+
*/
|
|
2158
|
+
updateTextHighlight() {
|
|
2159
|
+
|
|
2160
|
+
// Regex for matchWord if needed
|
|
2161
|
+
let regexWord = null;
|
|
2162
|
+
|
|
2163
|
+
if (this.matchWord && this.matchWord.length) {
|
|
2164
|
+
const escapedWord = this.matchWord.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&');
|
|
2165
|
+
regexWord = new RegExp(escapedWord, 'giu');
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
// Update text highlighting if matchWord changed
|
|
2169
|
+
if (regexWord &&
|
|
2170
|
+
this.isActive && !this.hasAttribute('persistent')) {
|
|
2171
|
+
const nested = this.querySelectorAll('.nestingSpacer');
|
|
2172
|
+
|
|
2173
|
+
const displayValueEl = this.querySelector('[slot="displayValue"]');
|
|
2174
|
+
if (displayValueEl) {
|
|
2175
|
+
this.removeChild(displayValueEl);
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
// Create nested spacers
|
|
2179
|
+
const nestingSpacerBundle = [...nested].map(() => this.nestingSpacer).join('');
|
|
2180
|
+
|
|
2181
|
+
// Update with spacers and matchWord
|
|
2182
|
+
this.innerHTML = nestingSpacerBundle +
|
|
2183
|
+
this.textContent.replace(
|
|
2184
|
+
regexWord,
|
|
2185
|
+
(match) => `<strong>${match}</strong>`
|
|
2186
|
+
);
|
|
2187
|
+
if (displayValueEl) {
|
|
2188
|
+
this.append(displayValueEl);
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
/**
|
|
2194
|
+
* Handles click events on the menu option, toggling its selected state.
|
|
2195
|
+
* This function dispatches a click event and updates selection if the option is not disabled.
|
|
2196
|
+
* @private
|
|
2197
|
+
*/
|
|
2198
|
+
handleClick() {
|
|
2199
|
+
if (!this.disabled) {
|
|
2200
|
+
this.dispatchClickEvent();
|
|
2201
|
+
this.selected = !this.selected;
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
/**
|
|
2206
|
+
* Handles mouse enter events to highlight the menu option.
|
|
2207
|
+
* This function updates the menu service to set this option as the currently highlighted item if not disabled.
|
|
2208
|
+
* @private
|
|
2209
|
+
*/
|
|
2210
|
+
handleMouseEnter() {
|
|
2211
|
+
if (!this.disabled) {
|
|
2212
|
+
this.menuService.setHighlightedOption(this);
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
|
|
2216
|
+
/**
|
|
2217
|
+
* Dispatches custom events defined for this menu option.
|
|
2218
|
+
* This function notifies listeners when a custom event is triggered by the option.
|
|
2219
|
+
* @private
|
|
2220
|
+
*/
|
|
2221
|
+
handleCustomEvent() {
|
|
2222
|
+
if (this.event) {
|
|
2223
|
+
dispatchMenuEvent(this, this.event, { option: this });
|
|
2224
|
+
dispatchMenuEvent(this, 'auroMenu-customEventFired', { option: this });
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2228
|
+
/**
|
|
2229
|
+
* Dispatches a click event for this menu option.
|
|
2230
|
+
* This function notifies listeners that the option has been clicked.
|
|
2231
|
+
* @private
|
|
2232
|
+
*/
|
|
2233
|
+
dispatchClickEvent() {
|
|
2234
|
+
this.dispatchEvent(new CustomEvent('auroMenuOption-click', {
|
|
2235
|
+
bubbles: true,
|
|
2236
|
+
cancelable: false,
|
|
2237
|
+
composed: true,
|
|
2238
|
+
detail: this
|
|
2239
|
+
}));
|
|
2240
|
+
}
|
|
2241
|
+
|
|
2242
|
+
/**
|
|
2243
|
+
* Generates an HTML element containing an SVG icon based on the provided `svgContent`.
|
|
2244
|
+
*
|
|
2245
|
+
* @private
|
|
2246
|
+
* @param {string} svgContent - The SVG content to be embedded.
|
|
2247
|
+
* @returns {Element} The HTML element containing the SVG icon.
|
|
2248
|
+
*/
|
|
2249
|
+
generateIconHtml(svgContent) {
|
|
2250
|
+
const dom = new DOMParser().parseFromString(svgContent, 'text/html');
|
|
2251
|
+
const svg = dom.body.firstChild;
|
|
2252
|
+
|
|
2253
|
+
svg.setAttribute('slot', 'svg');
|
|
2254
|
+
|
|
2255
|
+
return u$1`<${this.iconTag} customColor customSvg>${svg}</${this.iconTag}>`;
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
/**
|
|
2259
|
+
* Logic to determine the layout of the component.
|
|
2260
|
+
* @protected
|
|
2261
|
+
* @returns {void}
|
|
2262
|
+
*/
|
|
2263
|
+
renderLayout() {
|
|
2264
|
+
|
|
2265
|
+
const fontClassMap = {
|
|
2266
|
+
xs: 'body-sm',
|
|
2267
|
+
sm: 'body-default',
|
|
2268
|
+
md: 'body-default',
|
|
2269
|
+
lg: 'body-lg',
|
|
2270
|
+
xl: 'body-lg'
|
|
2271
|
+
};
|
|
2272
|
+
|
|
2273
|
+
const classes = e({
|
|
2274
|
+
'wrapper': true,
|
|
2275
|
+
[this.size ? fontClassMap[this.size] : 'body-sm']: true,
|
|
2276
|
+
});
|
|
2277
|
+
|
|
2278
|
+
return u$1`
|
|
2279
|
+
<div class="${classes}">
|
|
2280
|
+
${this.selected && !this.noCheckmark
|
|
2281
|
+
? this.generateIconHtml(checkmarkIcon.svg)
|
|
2282
|
+
: undefined}
|
|
2283
|
+
<slot></slot>
|
|
2284
|
+
</div>
|
|
2285
|
+
`;
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
export { AuroMenu as A, AuroMenuOption as a };
|