@nuralyui/dropdown 0.0.18 → 0.0.20
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/bundle.js +32 -91
- package/package.json +1 -1
package/bundle.js
CHANGED
|
@@ -1,48 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2019 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/
|
|
6
|
-
const t=window,i=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,o=Symbol(),n=new WeakMap;class e{constructor(t,i,n){if(this._$cssResult$=!0,n!==o)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o;const o=this.t;if(i&&void 0===t){const i=void 0!==o&&1===o.length;i&&(t=n.get(o)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&n.set(o,t))}return t}toString(){return this.cssText}}const s=i?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let i="";for(const o of t.cssRules)i+=o.cssText;return(t=>new e("string"==typeof t?t:t+"",void 0,o))(i)})(t):t
|
|
7
|
-
/**
|
|
8
|
-
* @license
|
|
9
|
-
* Copyright 2017 Google LLC
|
|
10
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
-
*/;var r;const d=window,a=d.trustedTypes,l=a?a.emptyScript:"",h=d.reactiveElementPolyfillSupport,u={toAttribute(t,i){switch(i){case Boolean:t=t?l:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,i){let o=t;switch(i){case Boolean:o=null!==t;break;case Number:o=null===t?null:Number(t);break;case Object:case Array:try{o=JSON.parse(t)}catch(t){o=null}}return o}},c=(t,i)=>i!==t&&(i==i||t==t),p={attribute:!0,type:String,converter:u,reflect:!1,hasChanged:c},v="finalized";class w extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var i;this.finalize(),(null!==(i=this.h)&&void 0!==i?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((i,o)=>{const n=this._$Ep(o,i);void 0!==n&&(this._$Ev.set(n,o),t.push(n))})),t}static createProperty(t,i=p){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){const o="symbol"==typeof t?Symbol():"__"+t,n=this.getPropertyDescriptor(t,o,i);void 0!==n&&Object.defineProperty(this.prototype,t,n)}}static getPropertyDescriptor(t,i,o){return{get(){return this[i]},set(n){const e=this[t];this[i]=n,this.requestUpdate(t,e,o)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||p}static finalize(){if(this.hasOwnProperty(v))return!1;this[v]=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),void 0!==t.h&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,i=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const o of i)this.createProperty(o,t[o])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const i=[];if(Array.isArray(t)){const o=new Set(t.flat(1/0).reverse());for(const t of o)i.unshift(s(t))}else void 0!==t&&i.push(s(t));return i}static _$Ep(t,i){const o=i.attribute;return!1===o?void 0:"string"==typeof o?o:"string"==typeof t?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var i,o;(null!==(i=this._$ES)&&void 0!==i?i:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(o=t.hostConnected)||void 0===o||o.call(t))}removeController(t){var i;null===(i=this._$ES)||void 0===i||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])}))}createRenderRoot(){var o;const n=null!==(o=this.shadowRoot)&&void 0!==o?o:this.attachShadow(this.constructor.shadowRootOptions);return((o,n)=>{i?o.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):n.forEach((i=>{const n=document.createElement("style"),e=t.litNonce;void 0!==e&&n.setAttribute("nonce",e),n.textContent=i.cssText,o.appendChild(n)}))})(n,this.constructor.elementStyles),n}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostConnected)||void 0===i?void 0:i.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostDisconnected)||void 0===i?void 0:i.call(t)}))}attributeChangedCallback(t,i,o){this._$AK(t,o)}_$EO(t,i,o=p){var n;const e=this.constructor._$Ep(t,o);if(void 0!==e&&!0===o.reflect){const s=(void 0!==(null===(n=o.converter)||void 0===n?void 0:n.toAttribute)?o.converter:u).toAttribute(i,o.type);this._$El=t,null==s?this.removeAttribute(e):this.setAttribute(e,s),this._$El=null}}_$AK(t,i){var o;const n=this.constructor,e=n._$Ev.get(t);if(void 0!==e&&this._$El!==e){const t=n.getPropertyOptions(e),s="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(o=t.converter)||void 0===o?void 0:o.fromAttribute)?t.converter:u;this._$El=e,this[e]=s.fromAttribute(i,t.type),this._$El=null}}requestUpdate(t,i,o){let n=!0;void 0!==t&&(((o=o||this.constructor.getPropertyOptions(t)).hasChanged||c)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),!0===o.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,o))):n=!1),!this.isUpdatePending&&n&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,i)=>this[i]=t)),this._$Ei=void 0);let i=!1;const o=this._$AL;try{i=this.shouldUpdate(o),i?(this.willUpdate(o),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostUpdate)||void 0===i?void 0:i.call(t)})),this.update(o)):this._$Ek()}catch(t){throw i=!1,this._$Ek(),t}i&&this._$AE(o)}willUpdate(t){}_$AE(t){var i;null===(i=this._$ES)||void 0===i||i.forEach((t=>{var i;return null===(i=t.hostUpdated)||void 0===i?void 0:i.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,i)=>this._$EO(i,this[i],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}
|
|
12
|
-
/**
|
|
13
|
-
* @license
|
|
14
|
-
* Copyright 2017 Google LLC
|
|
15
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
|
-
*/
|
|
17
|
-
var m;w[v]=!0,w.elementProperties=new Map,w.elementStyles=[],w.shadowRootOptions={mode:"open"},null==h||h({ReactiveElement:w}),(null!==(r=d.reactiveElementVersions)&&void 0!==r?r:d.reactiveElementVersions=[]).push("1.6.3");const f=window,_=f.trustedTypes,y=_?_.createPolicy("lit-html",{createHTML:t=>t}):void 0,b="$lit$",g=`lit$${(Math.random()+"").slice(9)}$`,$="?"+g,x=`<${$}>`,S=document,k=()=>S.createComment(""),A=t=>null===t||"object"!=typeof t&&"function"!=typeof t,E=Array.isArray,C="[ \t\n\f\r]",T=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,z=/-->/g,O=/>/g,U=RegExp(`>|${C}(?:([^\\s"'>=/]+)(${C}*=${C}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,M=/"/g,N=/^(?:script|style|textarea|title)$/i,R=Symbol.for("lit-noChange"),D=Symbol.for("lit-nothing"),I=new WeakMap,L=S.createTreeWalker(S,129,null,!1);function P(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==y?y.createHTML(i):i}class B{constructor({strings:t,_$litType$:i},o){let n;this.parts=[];let e=0,s=0;const r=t.length-1,d=this.parts,[a,l]=((t,i)=>{const o=t.length-1,n=[];let e,s=2===i?"<svg>":"",r=T;for(let i=0;i<o;i++){const o=t[i];let d,a,l=-1,h=0;for(;h<o.length&&(r.lastIndex=h,a=r.exec(o),null!==a);)h=r.lastIndex,r===T?"!--"===a[1]?r=z:void 0!==a[1]?r=O:void 0!==a[2]?(N.test(a[2])&&(e=RegExp("</"+a[2],"g")),r=U):void 0!==a[3]&&(r=U):r===U?">"===a[0]?(r=null!=e?e:T,l=-1):void 0===a[1]?l=-2:(l=r.lastIndex-a[2].length,d=a[1],r=void 0===a[3]?U:'"'===a[3]?M:j):r===M||r===j?r=U:r===z||r===O?r=T:(r=U,e=void 0);const u=r===U&&t[i+1].startsWith("/>")?" ":"";s+=r===T?o+x:l>=0?(n.push(d),o.slice(0,l)+b+o.slice(l)+g+u):o+g+(-2===l?(n.push(void 0),i):u)}return[P(t,s+(t[o]||"<?>")+(2===i?"</svg>":"")),n]})(t,i);if(this.el=B.createElement(a,o),L.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(n=L.nextNode())&&d.length<r;){if(1===n.nodeType){if(n.hasAttributes()){const t=[];for(const i of n.getAttributeNames())if(i.endsWith(b)||i.startsWith(g)){const o=l[s++];if(t.push(i),void 0!==o){const t=n.getAttribute(o.toLowerCase()+b).split(g),i=/([.?@])?(.*)/.exec(o);d.push({type:1,index:e,name:i[2],strings:t,ctor:"."===i[1]?W:"?"===i[1]?q:"@"===i[1]?V:K})}else d.push({type:6,index:e})}for(const i of t)n.removeAttribute(i)}if(N.test(n.tagName)){const t=n.textContent.split(g),i=t.length-1;if(i>0){n.textContent=_?_.emptyScript:"";for(let o=0;o<i;o++)n.append(t[o],k()),L.nextNode(),d.push({type:2,index:++e});n.append(t[i],k())}}}else if(8===n.nodeType)if(n.data===$)d.push({type:2,index:e});else{let t=-1;for(;-1!==(t=n.data.indexOf(g,t+1));)d.push({type:7,index:e}),t+=g.length-1}e++}}static createElement(t,i){const o=S.createElement("template");return o.innerHTML=t,o}}function F(t,i,o=t,n){var e,s,r,d;if(i===R)return i;let a=void 0!==n?null===(e=o._$Co)||void 0===e?void 0:e[n]:o._$Cl;const l=A(i)?void 0:i._$litDirective$;return(null==a?void 0:a.constructor)!==l&&(null===(s=null==a?void 0:a._$AO)||void 0===s||s.call(a,!1),void 0===l?a=void 0:(a=new l(t),a._$AT(t,o,n)),void 0!==n?(null!==(r=(d=o)._$Co)&&void 0!==r?r:d._$Co=[])[n]=a:o._$Cl=a),void 0!==a&&(i=F(t,a._$AS(t,i.values),a,n)),i}class H{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){var i;const{el:{content:o},parts:n}=this._$AD,e=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:S).importNode(o,!0);L.currentNode=e;let s=L.nextNode(),r=0,d=0,a=n[0];for(;void 0!==a;){if(r===a.index){let i;2===a.type?i=new Y(s,s.nextSibling,this,t):1===a.type?i=new a.ctor(s,a.name,a.strings,this,t):6===a.type&&(i=new Z(s,this,t)),this._$AV.push(i),a=n[++d]}r!==(null==a?void 0:a.index)&&(s=L.nextNode(),r++)}return L.currentNode=S,e}v(t){let i=0;for(const o of this._$AV)void 0!==o&&(void 0!==o.strings?(o._$AI(t,o,i),i+=o.strings.length-2):o._$AI(t[i])),i++}}class Y{constructor(t,i,o,n){var e;this.type=2,this._$AH=D,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=o,this.options=n,this._$Cp=null===(e=null==n?void 0:n.isConnected)||void 0===e||e}get _$AU(){var t,i;return null!==(i=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==i?i:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===(null==t?void 0:t.nodeType)&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=F(this,t,i),A(t)?t===D||null==t||""===t?(this._$AH!==D&&this._$AR(),this._$AH=D):t!==this._$AH&&t!==R&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>E(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==D&&A(this._$AH)?this._$AA.nextSibling.data=t:this.$(S.createTextNode(t)),this._$AH=t}g(t){var i;const{values:o,_$litType$:n}=t,e="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=B.createElement(P(n.h,n.h[0]),this.options)),n);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===e)this._$AH.v(o);else{const t=new H(e,this),i=t.u(this.options);t.v(o),this.$(i),this._$AH=t}}_$AC(t){let i=I.get(t.strings);return void 0===i&&I.set(t.strings,i=new B(t)),i}T(t){E(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let o,n=0;for(const e of t)n===i.length?i.push(o=new Y(this.k(k()),this.k(k()),this,this.options)):o=i[n],o._$AI(e),n++;n<i.length&&(this._$AR(o&&o._$AB.nextSibling,n),i.length=n)}_$AR(t=this._$AA.nextSibling,i){var o;for(null===(o=this._$AP)||void 0===o||o.call(this,!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var i;void 0===this._$AM&&(this._$Cp=t,null===(i=this._$AP)||void 0===i||i.call(this,t))}}class K{constructor(t,i,o,n,e){this.type=1,this._$AH=D,this._$AN=void 0,this.element=t,this.name=i,this._$AM=n,this.options=e,o.length>2||""!==o[0]||""!==o[1]?(this._$AH=Array(o.length-1).fill(new String),this.strings=o):this._$AH=D}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,o,n){const e=this.strings;let s=!1;if(void 0===e)t=F(this,t,i,0),s=!A(t)||t!==this._$AH&&t!==R,s&&(this._$AH=t);else{const n=t;let r,d;for(t=e[0],r=0;r<e.length-1;r++)d=F(this,n[o+r],i,r),d===R&&(d=this._$AH[r]),s||(s=!A(d)||d!==this._$AH[r]),d===D?t=D:t!==D&&(t+=(null!=d?d:"")+e[r+1]),this._$AH[r]=d}s&&!n&&this.j(t)}j(t){t===D?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class W extends K{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===D?void 0:t}}const X=_?_.emptyScript:"";class q extends K{constructor(){super(...arguments),this.type=4}j(t){t&&t!==D?this.element.setAttribute(this.name,X):this.element.removeAttribute(this.name)}}class V extends K{constructor(t,i,o,n,e){super(t,i,o,n,e),this.type=5}_$AI(t,i=this){var o;if((t=null!==(o=F(this,t,i,0))&&void 0!==o?o:D)===R)return;const n=this._$AH,e=t===D&&n!==D||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,s=t!==D&&(n===D||e);e&&this.element.removeEventListener(this.name,this,n),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,o;"function"==typeof this._$AH?this._$AH.call(null!==(o=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==o?o:this.element,t):this._$AH.handleEvent(t)}}class Z{constructor(t,i,o){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=o}get _$AU(){return this._$AM._$AU}_$AI(t){F(this,t)}}const J=f.litHtmlPolyfillSupport;
|
|
18
|
-
/**
|
|
19
|
-
* @license
|
|
20
|
-
* Copyright 2017 Google LLC
|
|
21
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
|
-
*/
|
|
23
|
-
var G;null==J||J(B,Y),(null!==(m=f.litHtmlVersions)&&void 0!==m?m:f.litHtmlVersions=[]).push("2.8.0");const Q=window,tt=Q.trustedTypes,it=tt?tt.createPolicy("lit-html",{createHTML:t=>t}):void 0,ot="$lit$",nt=`lit$${(Math.random()+"").slice(9)}$`,et="?"+nt,st=`<${et}>`,rt=document,dt=()=>rt.createComment(""),at=t=>null===t||"object"!=typeof t&&"function"!=typeof t,lt=Array.isArray,ht="[ \t\n\f\r]",ut=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ct=/-->/g,pt=/>/g,vt=RegExp(`>|${ht}(?:([^\\s"'>=/]+)(${ht}*=${ht}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),wt=/'/g,mt=/"/g,ft=/^(?:script|style|textarea|title)$/i,_t=(t=>(i,...o)=>({_$litType$:t,strings:i,values:o}))(1),yt=Symbol.for("lit-noChange"),bt=Symbol.for("lit-nothing"),gt=new WeakMap,$t=rt.createTreeWalker(rt,129,null,!1);function xt(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==it?it.createHTML(i):i}const St=(t,i)=>{const o=t.length-1,n=[];let e,s=2===i?"<svg>":"",r=ut;for(let i=0;i<o;i++){const o=t[i];let d,a,l=-1,h=0;for(;h<o.length&&(r.lastIndex=h,a=r.exec(o),null!==a);)h=r.lastIndex,r===ut?"!--"===a[1]?r=ct:void 0!==a[1]?r=pt:void 0!==a[2]?(ft.test(a[2])&&(e=RegExp("</"+a[2],"g")),r=vt):void 0!==a[3]&&(r=vt):r===vt?">"===a[0]?(r=null!=e?e:ut,l=-1):void 0===a[1]?l=-2:(l=r.lastIndex-a[2].length,d=a[1],r=void 0===a[3]?vt:'"'===a[3]?mt:wt):r===mt||r===wt?r=vt:r===ct||r===pt?r=ut:(r=vt,e=void 0);const u=r===vt&&t[i+1].startsWith("/>")?" ":"";s+=r===ut?o+st:l>=0?(n.push(d),o.slice(0,l)+ot+o.slice(l)+nt+u):o+nt+(-2===l?(n.push(void 0),i):u)}return[xt(t,s+(t[o]||"<?>")+(2===i?"</svg>":"")),n]};class kt{constructor({strings:t,_$litType$:i},o){let n;this.parts=[];let e=0,s=0;const r=t.length-1,d=this.parts,[a,l]=St(t,i);if(this.el=kt.createElement(a,o),$t.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(n=$t.nextNode())&&d.length<r;){if(1===n.nodeType){if(n.hasAttributes()){const t=[];for(const i of n.getAttributeNames())if(i.endsWith(ot)||i.startsWith(nt)){const o=l[s++];if(t.push(i),void 0!==o){const t=n.getAttribute(o.toLowerCase()+ot).split(nt),i=/([.?@])?(.*)/.exec(o);d.push({type:1,index:e,name:i[2],strings:t,ctor:"."===i[1]?zt:"?"===i[1]?Ut:"@"===i[1]?jt:Tt})}else d.push({type:6,index:e})}for(const i of t)n.removeAttribute(i)}if(ft.test(n.tagName)){const t=n.textContent.split(nt),i=t.length-1;if(i>0){n.textContent=tt?tt.emptyScript:"";for(let o=0;o<i;o++)n.append(t[o],dt()),$t.nextNode(),d.push({type:2,index:++e});n.append(t[i],dt())}}}else if(8===n.nodeType)if(n.data===et)d.push({type:2,index:e});else{let t=-1;for(;-1!==(t=n.data.indexOf(nt,t+1));)d.push({type:7,index:e}),t+=nt.length-1}e++}}static createElement(t,i){const o=rt.createElement("template");return o.innerHTML=t,o}}function At(t,i,o=t,n){var e,s,r,d;if(i===yt)return i;let a=void 0!==n?null===(e=o._$Co)||void 0===e?void 0:e[n]:o._$Cl;const l=at(i)?void 0:i._$litDirective$;return(null==a?void 0:a.constructor)!==l&&(null===(s=null==a?void 0:a._$AO)||void 0===s||s.call(a,!1),void 0===l?a=void 0:(a=new l(t),a._$AT(t,o,n)),void 0!==n?(null!==(r=(d=o)._$Co)&&void 0!==r?r:d._$Co=[])[n]=a:o._$Cl=a),void 0!==a&&(i=At(t,a._$AS(t,i.values),a,n)),i}class Et{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){var i;const{el:{content:o},parts:n}=this._$AD,e=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:rt).importNode(o,!0);$t.currentNode=e;let s=$t.nextNode(),r=0,d=0,a=n[0];for(;void 0!==a;){if(r===a.index){let i;2===a.type?i=new Ct(s,s.nextSibling,this,t):1===a.type?i=new a.ctor(s,a.name,a.strings,this,t):6===a.type&&(i=new Mt(s,this,t)),this._$AV.push(i),a=n[++d]}r!==(null==a?void 0:a.index)&&(s=$t.nextNode(),r++)}return $t.currentNode=rt,e}v(t){let i=0;for(const o of this._$AV)void 0!==o&&(void 0!==o.strings?(o._$AI(t,o,i),i+=o.strings.length-2):o._$AI(t[i])),i++}}class Ct{constructor(t,i,o,n){var e;this.type=2,this._$AH=bt,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=o,this.options=n,this._$Cp=null===(e=null==n?void 0:n.isConnected)||void 0===e||e}get _$AU(){var t,i;return null!==(i=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==i?i:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===(null==t?void 0:t.nodeType)&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=At(this,t,i),at(t)?t===bt||null==t||""===t?(this._$AH!==bt&&this._$AR(),this._$AH=bt):t!==this._$AH&&t!==yt&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>lt(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==bt&&at(this._$AH)?this._$AA.nextSibling.data=t:this.$(rt.createTextNode(t)),this._$AH=t}g(t){var i;const{values:o,_$litType$:n}=t,e="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=kt.createElement(xt(n.h,n.h[0]),this.options)),n);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===e)this._$AH.v(o);else{const t=new Et(e,this),i=t.u(this.options);t.v(o),this.$(i),this._$AH=t}}_$AC(t){let i=gt.get(t.strings);return void 0===i&>.set(t.strings,i=new kt(t)),i}T(t){lt(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let o,n=0;for(const e of t)n===i.length?i.push(o=new Ct(this.k(dt()),this.k(dt()),this,this.options)):o=i[n],o._$AI(e),n++;n<i.length&&(this._$AR(o&&o._$AB.nextSibling,n),i.length=n)}_$AR(t=this._$AA.nextSibling,i){var o;for(null===(o=this._$AP)||void 0===o||o.call(this,!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var i;void 0===this._$AM&&(this._$Cp=t,null===(i=this._$AP)||void 0===i||i.call(this,t))}}class Tt{constructor(t,i,o,n,e){this.type=1,this._$AH=bt,this._$AN=void 0,this.element=t,this.name=i,this._$AM=n,this.options=e,o.length>2||""!==o[0]||""!==o[1]?(this._$AH=Array(o.length-1).fill(new String),this.strings=o):this._$AH=bt}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,o,n){const e=this.strings;let s=!1;if(void 0===e)t=At(this,t,i,0),s=!at(t)||t!==this._$AH&&t!==yt,s&&(this._$AH=t);else{const n=t;let r,d;for(t=e[0],r=0;r<e.length-1;r++)d=At(this,n[o+r],i,r),d===yt&&(d=this._$AH[r]),s||(s=!at(d)||d!==this._$AH[r]),d===bt?t=bt:t!==bt&&(t+=(null!=d?d:"")+e[r+1]),this._$AH[r]=d}s&&!n&&this.j(t)}j(t){t===bt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class zt extends Tt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===bt?void 0:t}}const Ot=tt?tt.emptyScript:"";class Ut extends Tt{constructor(){super(...arguments),this.type=4}j(t){t&&t!==bt?this.element.setAttribute(this.name,Ot):this.element.removeAttribute(this.name)}}class jt extends Tt{constructor(t,i,o,n,e){super(t,i,o,n,e),this.type=5}_$AI(t,i=this){var o;if((t=null!==(o=At(this,t,i,0))&&void 0!==o?o:bt)===yt)return;const n=this._$AH,e=t===bt&&n!==bt||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,s=t!==bt&&(n===bt||e);e&&this.element.removeEventListener(this.name,this,n),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,o;"function"==typeof this._$AH?this._$AH.call(null!==(o=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==o?o:this.element,t):this._$AH.handleEvent(t)}}class Mt{constructor(t,i,o){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=o}get _$AU(){return this._$AM._$AU}_$AI(t){At(this,t)}}const Nt=Q.litHtmlPolyfillSupport;null==Nt||Nt(kt,Ct),(null!==(G=Q.litHtmlVersions)&&void 0!==G?G:Q.litHtmlVersions=[]).push("2.8.0");
|
|
24
|
-
/**
|
|
25
|
-
* @license
|
|
26
|
-
* Copyright 2017 Google LLC
|
|
27
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
28
|
-
*/
|
|
29
|
-
var Rt,Dt;class It extends w{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,i;const o=super.createRenderRoot();return null!==(t=(i=this.renderOptions).renderBefore)&&void 0!==t||(i.renderBefore=o.firstChild),o}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,i,o)=>{var n,e;const s=null!==(n=null==o?void 0:o.renderBefore)&&void 0!==n?n:i;let r=s._$litPart$;if(void 0===r){const t=null!==(e=null==o?void 0:o.renderBefore)&&void 0!==e?e:null;s._$litPart$=r=new Ct(i.insertBefore(dt(),t),t,void 0,null!=o?o:{})}return r._$AI(t),r})(i,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return yt}}It.finalized=!0,It._$litElement$=!0,null===(Rt=globalThis.litElementHydrateSupport)||void 0===Rt||Rt.call(globalThis,{LitElement:It});const Lt=globalThis.litElementPolyfillSupport;null==Lt||Lt({LitElement:It}),(null!==(Dt=globalThis.litElementVersions)&&void 0!==Dt?Dt:globalThis.litElementVersions=[]).push("3.3.3");
|
|
30
|
-
/**
|
|
31
|
-
* @license
|
|
32
|
-
* Copyright 2017 Google LLC
|
|
33
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
34
|
-
*/
|
|
35
|
-
const Pt=(t,i)=>"method"===i.kind&&i.descriptor&&!("value"in i.descriptor)?{...i,finisher(o){o.createProperty(i.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:i.key,initializer(){"function"==typeof i.initializer&&(this[i.key]=i.initializer.call(this))},finisher(o){o.createProperty(i.key,t)}};
|
|
36
|
-
/**
|
|
37
|
-
* @license
|
|
38
|
-
* Copyright 2017 Google LLC
|
|
39
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
40
|
-
*/function Bt(t){return(i,o)=>void 0!==o?((t,i,o)=>{i.constructor.createProperty(o,t)})(t,i,o):Pt(t,i)
|
|
41
|
-
/**
|
|
42
|
-
* @license
|
|
43
|
-
* Copyright 2021 Google LLC
|
|
44
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
45
|
-
*/}var Ft;null===(Ft=window.HTMLSlotElement)||void 0===Ft||Ft.prototype.assignedElements;const Ht=((t,...i)=>{const n=1===t.length?t[0]:i.reduce(((i,o,n)=>i+(t=>{if(!0===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.")})(o)+t[n+1]),t[0]);return new e(n,t,o)})`
|
|
1
|
+
import{css as o,LitElement as t,nothing as n,html as i}from"lit";import{property as e,customElement as r}from"lit/decorators.js";import{classMap as d}from"lit/directives/class-map.js";import{styleMap as s}from"lit/directives/style-map.js";import{NuralyUIBaseMixin as a}from"@nuralyui/common/mixins";const l=o`
|
|
46
2
|
:host {
|
|
47
3
|
display: inline-block;
|
|
48
4
|
position: relative;
|
|
@@ -490,81 +446,66 @@ const Pt=(t,i)=>"method"===i.kind&&i.descriptor&&!("value"in i.descriptor)?{...i
|
|
|
490
446
|
display: none !important;
|
|
491
447
|
}
|
|
492
448
|
|
|
493
|
-
`
|
|
494
|
-
/**
|
|
495
|
-
* @license
|
|
496
|
-
* Copyright 2017 Google LLC
|
|
497
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
498
|
-
*/,Yt=1,Kt=t=>(...i)=>({_$litDirective$:t,values:i});class Wt{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,i,o){this._$Ct=t,this._$AM=i,this._$Ci=o}_$AS(t,i){return this.update(t,i)}update(t,i){return this.render(...i)}}
|
|
499
|
-
/**
|
|
500
|
-
* @license
|
|
501
|
-
* Copyright 2018 Google LLC
|
|
502
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
503
|
-
*/const Xt=Kt(class extends Wt{constructor(t){var i;if(super(t),t.type!==Yt||"class"!==t.name||(null===(i=t.strings)||void 0===i?void 0:i.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((i=>t[i])).join(" ")+" "}update(t,[i]){var o,n;if(void 0===this.it){this.it=new Set,void 0!==t.strings&&(this.nt=new Set(t.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in i)i[t]&&!(null===(o=this.nt)||void 0===o?void 0:o.has(t))&&this.it.add(t);return this.render(i)}const e=t.element.classList;this.it.forEach((t=>{t in i||(e.remove(t),this.it.delete(t))}));for(const t in i){const o=!!i[t];o===this.it.has(t)||(null===(n=this.nt)||void 0===n?void 0:n.has(t))||(o?(e.add(t),this.it.add(t)):(e.remove(t),this.it.delete(t)))}return R}}),qt="important",Vt=" !"+qt,Zt=Kt(class extends Wt{constructor(t){var i;if(super(t),t.type!==Yt||"style"!==t.name||(null===(i=t.strings)||void 0===i?void 0:i.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce(((i,o)=>{const n=t[o];return null==n?i:i+`${o=o.includes("-")?o:o.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${n};`}),"")}update(t,[i]){const{style:o}=t.element;if(void 0===this.ht){this.ht=new Set;for(const t in i)this.ht.add(t);return this.render(i)}this.ht.forEach((t=>{null==i[t]&&(this.ht.delete(t),t.includes("-")?o.removeProperty(t):o[t]="")}));for(const t in i){const n=i[t];if(null!=n){this.ht.add(t);const i="string"==typeof n&&n.endsWith(Vt);t.includes("-")||i?o.setProperty(t,i?n.slice(0,-11):n,i?qt:""):o[t]=n}}return R}}),Jt=t=>class extends t{constructor(){super(...arguments),this.handleSystemThemeChange=()=>{this.closest("[data-theme]")||document.documentElement.hasAttribute("data-theme")||this.requestUpdate()}}connectedCallback(){super.connectedCallback(),this.setupThemeObserver(),this.setupDesignSystemObserver(),this.setupSystemThemeListener()}disconnectedCallback(){var t,i,o;super.disconnectedCallback(),null===(t=this.themeObserver)||void 0===t||t.disconnect(),null===(i=this.designSystemObserver)||void 0===i||i.disconnect(),null===(o=this.mediaQuery)||void 0===o||o.removeEventListener("change",this.handleSystemThemeChange)}get currentTheme(){var t,i;const o=(null===(t=this.closest("[data-theme]"))||void 0===t?void 0:t.getAttribute("data-theme"))||document.documentElement.getAttribute("data-theme");return o||((null===(i=window.matchMedia)||void 0===i?void 0:i.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light")}get currentDesignSystem(){var t;const i=(null===(t=this.closest("[design-system]"))||void 0===t?void 0:t.getAttribute("design-system"))||document.documentElement.getAttribute("design-system");return"carbon"===i?i:"default"}setupThemeObserver(){this.themeObserver=new MutationObserver((()=>{this.requestUpdate()})),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})}setupDesignSystemObserver(){this.designSystemObserver=new MutationObserver((()=>{this.requestUpdate()})),this.designSystemObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["design-system"]})}setupSystemThemeListener(){window.matchMedia&&(this.mediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.mediaQuery.addEventListener("change",this.handleSystemThemeChange))}},Gt=()=>{var t;return void 0!==globalThis.litElementVersions||"undefined"!=typeof process&&"development"===(null===(t=process.env)||void 0===t?void 0:t.NODE_ENV)||"undefined"!=typeof window&&("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname)},Qt=t=>class extends t{constructor(){super(...arguments),this.requiredComponents=[]}validateDependencies(){if(Gt())for(const t of this.requiredComponents)if(!this.isComponentAvailable(t))throw new Error(`Required component "${t}" is not registered. Please import and register the component before using ${this.tagName.toLowerCase()}. Example: import '@nuralyui/${t}';`)}validateDependenciesWithHandler(t){if(!Gt())return!0;let i=!0;for(const o of this.requiredComponents)if(!this.isComponentAvailable(o)){i=!1;const n=new Error(`Required component "${o}" is not registered. Please import and register the component before using ${this.tagName.toLowerCase()}.`);t?t(o,n):console.error(n.message)}return i}isComponentAvailable(t){return!!customElements.get(t)}getMissingDependencies(){return this.requiredComponents.filter((t=>!this.isComponentAvailable(t)))}areDependenciesAvailable(){return this.requiredComponents.every((t=>this.isComponentAvailable(t)))}addRequiredComponent(t){this.requiredComponents.includes(t)||this.requiredComponents.push(t)}removeRequiredComponent(t){const i=this.requiredComponents.indexOf(t);i>-1&&this.requiredComponents.splice(i,1)}},ti=t=>class extends t{dispatchCustomEvent(t,i){this.dispatchEvent(new CustomEvent(t,{detail:i,bubbles:!0,composed:!0}))}dispatchEventWithMetadata(t,i){var o;const n=Object.assign(Object.assign({},i),{timestamp:Date.now(),componentName:(null===(o=this.tagName)||void 0===o?void 0:o.toLowerCase())||"unknown"});this.dispatchCustomEvent(t,n)}dispatchInputEvent(t,i){const o=Object.assign({target:i.target||this,value:i.value,originalEvent:i.originalEvent},i);this.dispatchCustomEvent(t,o)}dispatchFocusEvent(t,i){const o=Object.assign({target:i.target||this,value:i.value,focused:i.focused,cursorPosition:i.cursorPosition,selectedText:i.selectedText},i);this.dispatchCustomEvent(t,o)}dispatchValidationEvent(t,i){var o;const n=Object.assign({target:i.target||this,value:i.value,isValid:null!==(o=i.isValid)&&void 0!==o&&o,error:i.error},i);this.dispatchCustomEvent(t,n)}dispatchActionEvent(t,i){const o=Object.assign({target:i.target||this,action:i.action,previousValue:i.previousValue,newValue:i.newValue},i);this.dispatchCustomEvent(t,o)}isReadonlyKeyAllowed(t){if(t.ctrlKey||t.metaKey){return["KeyA","KeyC"].includes(t.code)}return["Tab","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key)}isActivationKey(t){return"Enter"===t.key||" "===t.key}};
|
|
504
|
-
/**
|
|
505
|
-
* @license
|
|
506
|
-
* Copyright 2018 Google LLC
|
|
507
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
508
|
-
*/class ii{constructor(t){this._host=t,this._host.addController(this)}get host(){return this._host}hostConnected(){}hostDisconnected(){}hostUpdate(){}hostUpdated(){}requestUpdate(){this._host.requestUpdate()}dispatchEvent(t){return this._host.dispatchEvent(t)}handleError(t,i){console.error(`Dropdown Controller Error in ${i}:`,t)}findElement(t){var i;return null===(i=this._host.shadowRoot)||void 0===i?void 0:i.querySelector(t)}findElements(t){var i;return null===(i=this._host.shadowRoot)||void 0===i?void 0:i.querySelectorAll(t)}}class oi extends ii{constructor(t){super(t),this._isOpen=!1,this._position={top:0,left:0,width:0,placement:"bottom"},this._triggerElement=null,this._dropdownElement=null,this._outsideClickHandler=null,this._keydownHandler=null,this._hoverTimer=null,this._triggerClickHandler=null,this._triggerHoverHandler=null,this._triggerLeaveHandler=null,this._triggerFocusHandler=null,this._triggerBlurHandler=null,this._scrollHandler=null,this._resizeHandler=null,this._isOpen=t.open}get isOpen(){return this._isOpen}get position(){return Object.assign({},this._position)}hostConnected(){}hostUpdated(){this._isOpen!==this.host.open&&(this._isOpen=this.host.open),this._triggerElement||this.setupTriggerListeners()}hostDisconnected(){this.cleanup()}open(){try{this._isOpen||this.host.disabled||(this._isOpen=!0,this.host.open=!0,this.requestUpdate(),setTimeout((()=>{this.calculatePosition(),this.setupEventListeners()}),10),this.dispatchEvent(new CustomEvent("nr-dropdown-open",{bubbles:!0,composed:!0,detail:{dropdown:this.host}})))}catch(t){this.handleError(t,"open")}}close(){try{this._isOpen&&(this.removeEventListeners(),this._isOpen=!1,this.host.open=!1,this.requestUpdate(),this.dispatchEvent(new CustomEvent("nr-dropdown-close",{bubbles:!0,composed:!0,detail:{dropdown:this.host}})))}catch(t){this.handleError(t,"close")}}toggle(){try{this._isOpen?this.close():this.open()}catch(t){this.handleError(t,"toggle")}}removeTriggerListeners(){this._triggerElement&&(this._triggerClickHandler&&(this._triggerElement.removeEventListener("click",this._triggerClickHandler),this._triggerClickHandler=null),this._triggerHoverHandler&&(this._triggerElement.removeEventListener("mouseenter",this._triggerHoverHandler),this._triggerHoverHandler=null),this._triggerLeaveHandler&&(this._triggerElement.removeEventListener("mouseleave",this._triggerLeaveHandler),this._triggerLeaveHandler=null),this._triggerFocusHandler&&(this._triggerElement.removeEventListener("focusin",this._triggerFocusHandler),this._triggerFocusHandler=null),this._triggerBlurHandler&&(this._triggerElement.removeEventListener("focusout",this._triggerBlurHandler),this._triggerBlurHandler=null))}findDropdownElements(){this._dropdownElement=this.findElement(".dropdown__panel"),this._triggerElement=this.findElement(".dropdown__trigger")}setupTriggerListeners(){if(this.findDropdownElements(),this._triggerElement)switch(this.removeTriggerListeners(),this.host.trigger){case"click":this._triggerClickHandler=this.handleTriggerClick.bind(this),this._triggerElement.addEventListener("click",this._triggerClickHandler);break;case"hover":this._triggerHoverHandler=this.handleTriggerHover.bind(this),this._triggerLeaveHandler=this.handleTriggerLeave.bind(this),this._triggerElement.addEventListener("mouseenter",this._triggerHoverHandler),this._triggerElement.addEventListener("mouseleave",this._triggerLeaveHandler);break;case"focus":this._triggerFocusHandler=this.handleTriggerFocus.bind(this),this._triggerBlurHandler=this.handleTriggerBlur.bind(this),this._triggerElement.addEventListener("focusin",this._triggerFocusHandler),this._triggerElement.addEventListener("focusout",this._triggerBlurHandler)}}setupEventListeners(){this.host.closeOnOutsideClick&&(this._outsideClickHandler=this.handleOutsideClick.bind(this),document.addEventListener("click",this._outsideClickHandler,!0)),this.host.closeOnEscape&&(this._keydownHandler=this.handleKeydown.bind(this),document.addEventListener("keydown",this._keydownHandler)),this._scrollHandler=this.handleScroll.bind(this),this._resizeHandler=this.handleResize.bind(this),window.addEventListener("scroll",this._scrollHandler,!0),window.addEventListener("resize",this._resizeHandler)}removeEventListeners(){this._outsideClickHandler&&(document.removeEventListener("click",this._outsideClickHandler,!0),this._outsideClickHandler=null),this._keydownHandler&&(document.removeEventListener("keydown",this._keydownHandler),this._keydownHandler=null),this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null),this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}handleTriggerClick(){this.host.disabled||this.toggle()}handleTriggerHover(){this.host.disabled||(this._hoverTimer&&clearTimeout(this._hoverTimer),this._hoverTimer=window.setTimeout((()=>{this.open()}),this.host.delay))}handleTriggerLeave(){this._hoverTimer&&(clearTimeout(this._hoverTimer),this._hoverTimer=null),setTimeout((()=>{this.isHoveringDropdown()||this.close()}),100)}handleTriggerFocus(){this.host.disabled||this.open()}handleTriggerBlur(){setTimeout((()=>{this.isDropdownFocused()||this.close()}),100)}handleOutsideClick(t){var i,o;const n=t.target;if(null===(i=this._triggerElement)||void 0===i?void 0:i.contains(n))return;if(n.closest(".dropdown__panel"))return;if(null===(o=this._dropdownElement)||void 0===o?void 0:o.contains(n))return;if(n.closest("nr-dropdown"))return;if(n.closest(".dropdown__custom-content"))return;if(["INPUT","BUTTON","TEXTAREA","SELECT","A"].includes(n.tagName)){if(n.closest(".dropdown__panel"))return}n.closest(".dropdown")||n.closest('[class*="dropdown"]')||this.host.closeOnOutsideClick&&this.close()}handleKeydown(t){"Escape"===t.key&&this.close()}handleScroll(){}handleResize(){this._isOpen&&this.calculatePosition()}calculatePosition(){var t;try{if(this._dropdownElement&&this._triggerElement||this.findDropdownElements(),!this._dropdownElement||!this._triggerElement)return;const i=this._triggerElement.getBoundingClientRect(),o=((null===(t=window.visualViewport)||void 0===t?void 0:t.height)||window.innerHeight)-i.bottom,n=i.top,e=200,s=this.determineOptimalPlacement(e,n,o);this.applyPlacement(s)}catch(t){this.handleError(t,"calculatePosition")}}determineOptimalPlacement(t,i,o){return o>=t?"bottom":i>=t||i>o?"top":"bottom"}applyPlacement(t){this._dropdownElement&&(this._dropdownElement.classList.remove("dropdown__panel--top","dropdown__panel--bottom"),this._dropdownElement.classList.add(`dropdown__panel--${t}`),this._position.placement=t)}isHoveringDropdown(){var t;return(null===(t=this._dropdownElement)||void 0===t?void 0:t.matches(":hover"))||!1}isDropdownFocused(){var t;const i=document.activeElement;if(!i)return!1;if(null===(t=this._dropdownElement)||void 0===t?void 0:t.contains(i))return!0;if(i.closest(".dropdown__custom-content"))return!0;if(["INPUT","BUTTON","TEXTAREA","SELECT","A"].includes(i.tagName)){if(i.closest(".dropdown__panel"))return!0}return!1}handleItemClick(t){this.dispatchEvent(new CustomEvent("nr-dropdown-item-click",{bubbles:!0,composed:!0,detail:{item:t,dropdown:this.host}})),this.host.autoClose&&this.close()}cleanup(){this.removeEventListeners(),this.removeTriggerListeners(),this._hoverTimer&&(clearTimeout(this._hoverTimer),this._hoverTimer=null)}}
|
|
449
|
+
`;class p{constructor(o){this._host=o,this._host.addController(this)}get host(){return this._host}hostConnected(){}hostDisconnected(){}hostUpdate(){}hostUpdated(){}requestUpdate(){this._host.requestUpdate()}dispatchEvent(o){return this._host.dispatchEvent(o)}handleError(o,t){console.error(`Dropdown Controller Error in ${t}:`,o)}findElement(o){var t;return null===(t=this._host.shadowRoot)||void 0===t?void 0:t.querySelector(o)}findElements(o){var t;return null===(t=this._host.shadowRoot)||void 0===t?void 0:t.querySelectorAll(o)}}class h extends p{constructor(o){super(o),this._isOpen=!1,this._position={top:0,left:0,width:0,placement:"bottom"},this._triggerElement=null,this._dropdownElement=null,this._outsideClickHandler=null,this._keydownHandler=null,this._hoverTimer=null,this._triggerClickHandler=null,this._triggerHoverHandler=null,this._triggerLeaveHandler=null,this._triggerFocusHandler=null,this._triggerBlurHandler=null,this._scrollHandler=null,this._resizeHandler=null,this._isOpen=o.open}get isOpen(){return this._isOpen}get position(){return Object.assign({},this._position)}hostConnected(){}hostUpdated(){this._isOpen!==this.host.open&&(this._isOpen=this.host.open),this._triggerElement||this.setupTriggerListeners()}hostDisconnected(){this.cleanup()}open(){try{this._isOpen||this.host.disabled||(this._isOpen=!0,this.host.open=!0,this.requestUpdate(),setTimeout((()=>{this.calculatePosition(),this.setupEventListeners()}),10),this.dispatchEvent(new CustomEvent("nr-dropdown-open",{bubbles:!0,composed:!0,detail:{dropdown:this.host}})))}catch(o){this.handleError(o,"open")}}close(){try{this._isOpen&&(this.removeEventListeners(),this._isOpen=!1,this.host.open=!1,this.requestUpdate(),this.dispatchEvent(new CustomEvent("nr-dropdown-close",{bubbles:!0,composed:!0,detail:{dropdown:this.host}})))}catch(o){this.handleError(o,"close")}}toggle(){try{this._isOpen?this.close():this.open()}catch(o){this.handleError(o,"toggle")}}removeTriggerListeners(){this._triggerElement&&(this._triggerClickHandler&&(this._triggerElement.removeEventListener("click",this._triggerClickHandler),this._triggerClickHandler=null),this._triggerHoverHandler&&(this._triggerElement.removeEventListener("mouseenter",this._triggerHoverHandler),this._triggerHoverHandler=null),this._triggerLeaveHandler&&(this._triggerElement.removeEventListener("mouseleave",this._triggerLeaveHandler),this._triggerLeaveHandler=null),this._triggerFocusHandler&&(this._triggerElement.removeEventListener("focusin",this._triggerFocusHandler),this._triggerFocusHandler=null),this._triggerBlurHandler&&(this._triggerElement.removeEventListener("focusout",this._triggerBlurHandler),this._triggerBlurHandler=null))}findDropdownElements(){this._dropdownElement=this.findElement(".dropdown__panel"),this._triggerElement=this.findElement(".dropdown__trigger")}setupTriggerListeners(){if(this.findDropdownElements(),this._triggerElement)switch(this.removeTriggerListeners(),this.host.trigger){case"click":this._triggerClickHandler=this.handleTriggerClick.bind(this),this._triggerElement.addEventListener("click",this._triggerClickHandler);break;case"hover":this._triggerHoverHandler=this.handleTriggerHover.bind(this),this._triggerLeaveHandler=this.handleTriggerLeave.bind(this),this._triggerElement.addEventListener("mouseenter",this._triggerHoverHandler),this._triggerElement.addEventListener("mouseleave",this._triggerLeaveHandler);break;case"focus":this._triggerFocusHandler=this.handleTriggerFocus.bind(this),this._triggerBlurHandler=this.handleTriggerBlur.bind(this),this._triggerElement.addEventListener("focusin",this._triggerFocusHandler),this._triggerElement.addEventListener("focusout",this._triggerBlurHandler)}}setupEventListeners(){this.host.closeOnOutsideClick&&(this._outsideClickHandler=this.handleOutsideClick.bind(this),document.addEventListener("click",this._outsideClickHandler,!0)),this.host.closeOnEscape&&(this._keydownHandler=this.handleKeydown.bind(this),document.addEventListener("keydown",this._keydownHandler)),this._scrollHandler=this.handleScroll.bind(this),this._resizeHandler=this.handleResize.bind(this),window.addEventListener("scroll",this._scrollHandler,!0),window.addEventListener("resize",this._resizeHandler)}removeEventListeners(){this._outsideClickHandler&&(document.removeEventListener("click",this._outsideClickHandler,!0),this._outsideClickHandler=null),this._keydownHandler&&(document.removeEventListener("keydown",this._keydownHandler),this._keydownHandler=null),this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null),this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}handleTriggerClick(){this.host.disabled||this.toggle()}handleTriggerHover(){this.host.disabled||(this._hoverTimer&&clearTimeout(this._hoverTimer),this._hoverTimer=window.setTimeout((()=>{this.open()}),this.host.delay))}handleTriggerLeave(){this._hoverTimer&&(clearTimeout(this._hoverTimer),this._hoverTimer=null),setTimeout((()=>{this.isHoveringDropdown()||this.close()}),100)}handleTriggerFocus(){this.host.disabled||this.open()}handleTriggerBlur(){setTimeout((()=>{this.isDropdownFocused()||this.close()}),100)}handleOutsideClick(o){var t,n;const i=o.target;if(null===(t=this._triggerElement)||void 0===t?void 0:t.contains(i))return;if(i.closest(".dropdown__panel"))return;if(null===(n=this._dropdownElement)||void 0===n?void 0:n.contains(i))return;if(i.closest("nr-dropdown"))return;if(i.closest(".dropdown__custom-content"))return;if(["INPUT","BUTTON","TEXTAREA","SELECT","A"].includes(i.tagName)){if(i.closest(".dropdown__panel"))return}i.closest(".dropdown")||i.closest('[class*="dropdown"]')||this.host.closeOnOutsideClick&&this.close()}handleKeydown(o){"Escape"===o.key&&this.close()}handleScroll(){}handleResize(){this._isOpen&&this.calculatePosition()}calculatePosition(){var o;try{if(this._dropdownElement&&this._triggerElement||this.findDropdownElements(),!this._dropdownElement||!this._triggerElement)return;const t=this._triggerElement.getBoundingClientRect(),n=((null===(o=window.visualViewport)||void 0===o?void 0:o.height)||window.innerHeight)-t.bottom,i=t.top,e=200,r=this.determineOptimalPlacement(e,i,n);this.applyPlacement(r)}catch(o){this.handleError(o,"calculatePosition")}}determineOptimalPlacement(o,t,n){return n>=o?"bottom":t>=o||t>n?"top":"bottom"}applyPlacement(o){this._dropdownElement&&(this._dropdownElement.classList.remove("dropdown__panel--top","dropdown__panel--bottom"),this._dropdownElement.classList.add(`dropdown__panel--${o}`),this._position.placement=o)}isHoveringDropdown(){var o;return(null===(o=this._dropdownElement)||void 0===o?void 0:o.matches(":hover"))||!1}isDropdownFocused(){var o;const t=document.activeElement;if(!t)return!1;if(null===(o=this._dropdownElement)||void 0===o?void 0:o.contains(t))return!0;if(t.closest(".dropdown__custom-content"))return!0;if(["INPUT","BUTTON","TEXTAREA","SELECT","A"].includes(t.tagName)){if(t.closest(".dropdown__panel"))return!0}return!1}handleItemClick(o){this.dispatchEvent(new CustomEvent("nr-dropdown-item-click",{bubbles:!0,composed:!0,detail:{item:o,dropdown:this.host}})),this.host.autoClose&&this.close()}cleanup(){this.removeEventListeners(),this.removeTriggerListeners(),this._hoverTimer&&(clearTimeout(this._hoverTimer),this._hoverTimer=null)}}
|
|
509
450
|
/**
|
|
510
451
|
* @license
|
|
511
452
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
512
453
|
* SPDX-License-Identifier: MIT
|
|
513
|
-
*/var
|
|
454
|
+
*/var c=function(o,t,n,i){for(var e,r=arguments.length,d=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i,s=o.length-1;s>=0;s--)(e=o[s])&&(d=(r<3?e(d):r>3?e(t,n,d):e(t,n))||d);return r>3&&d&&Object.defineProperty(t,n,d),d};let u=class extends(a(t)){constructor(){super(...arguments),this.requiredComponents=["nr-icon"],this.items=[],this.open=!1,this.placement="bottom",this.trigger="hover",this.size="medium",this.animation="fade",this.disabled=!1,this.arrow=!1,this.autoClose=!1,this.closeOnOutsideClick=!0,this.closeOnEscape=!0,this.offset=4,this.delay=50,this.maxHeight="300px",this.minWidth="auto",this.cascadeDirection="auto",this.cascadeDelay=50,this.cascadeOnHover=!0,this.dropdownController=new h(this),this.openSubmenus=new Set,this.submenuTimers=new Map,this.handleDropdownPanelClick=o=>{o.stopPropagation()},this.handleItemClick=o=>{o.disabled||(o.options&&o.options.length>0||o.customContent?this.toggleSubmenu(o.id):this.dropdownController.handleItemClick(o))},this.handleItemHover=o=>{var t;if(((null===(t=o.options)||void 0===t?void 0:t.length)||o.customContent)&&(this.clearSubmenuTimer(o.id),this.cascadeOnHover)){const t=window.setTimeout((()=>{this.showSubmenu(o.id)}),this.cascadeDelay);this.submenuTimers.set(o.id,t)}},this.handleItemLeave=o=>{var t;if(!(null===(t=o.options)||void 0===t?void 0:t.length)&&!o.customContent)return;this.clearSubmenuTimer(o.id);const n=window.setTimeout((()=>{this.hideSubmenu(o.id)}),100);this.submenuTimers.set(`hide-${o.id}`,n)},this.handleSubmenuEnter=o=>{this.clearSubmenuTimer(`hide-${o}`)},this.handleSubmenuLeave=o=>{const t=window.setTimeout((()=>{this.hideSubmenu(o)}),100);this.submenuTimers.set(`hide-${o}`,t)}}connectedCallback(){super.connectedCallback(),this.updateCascadingAttribute()}updated(o){super.updated(o),o.has("items")&&this.updateCascadingAttribute()}disconnectedCallback(){super.disconnectedCallback()}firstUpdated(){}updateCascadingAttribute(){this.items.some((o=>o.options&&o.options.length>0||!!o.customContent))?this.setAttribute("has-cascading",""):this.removeAttribute("has-cascading")}clearSubmenuTimer(o){const t=this.submenuTimers.get(o);t&&(clearTimeout(t),this.submenuTimers.delete(o))}toggleSubmenu(o){this.openSubmenus.has(o)?this.hideSubmenu(o):this.showSubmenu(o)}showSubmenu(o){this.openSubmenus.add(o),this.requestUpdate()}hideSubmenu(o){this.openSubmenus.delete(o),this.requestUpdate()}show(){this.dropdownController.open()}hide(){this.dropdownController.close()}toggle(){this.dropdownController.toggle()}renderItems(){return this.items.length?i`
|
|
514
455
|
<div class="dropdown__items">
|
|
515
|
-
${this.items.map((
|
|
516
|
-
<div class="dropdown__item-container ${
|
|
456
|
+
${this.items.map((o=>{if(o.divider)return i`<div class="dropdown__divider"></div>`;const t=!!(o.options&&o.options.length>0)||!!o.customContent,e=t&&this.openSubmenus.has(o.id);return i`
|
|
457
|
+
<div class="dropdown__item-container ${d({"dropdown__item-container--has-submenu":t})}">
|
|
517
458
|
<button
|
|
518
|
-
class="dropdown__item ${
|
|
519
|
-
?disabled="${
|
|
520
|
-
@click="${()=>this.handleItemClick(
|
|
521
|
-
@mouseenter="${()=>
|
|
522
|
-
@mouseleave="${()=>
|
|
459
|
+
class="dropdown__item ${d({"dropdown__item--disabled":!!o.disabled,"dropdown__item--has-submenu":t})}"
|
|
460
|
+
?disabled="${o.disabled}"
|
|
461
|
+
@click="${()=>this.handleItemClick(o)}"
|
|
462
|
+
@mouseenter="${()=>t&&this.handleItemHover(o)}"
|
|
463
|
+
@mouseleave="${()=>t&&this.handleItemLeave(o)}"
|
|
523
464
|
>
|
|
524
|
-
${
|
|
525
|
-
<span class="dropdown__item-label">${
|
|
526
|
-
${i
|
|
465
|
+
${o.icon?i`<nr-icon name="${o.icon}" class="dropdown__item-icon"></nr-icon>`:n}
|
|
466
|
+
<span class="dropdown__item-label">${o.label}</span>
|
|
467
|
+
${t?i`<nr-icon name="chevron-right" class="dropdown__submenu-arrow"></nr-icon>`:n}
|
|
527
468
|
</button>
|
|
528
469
|
|
|
529
|
-
${
|
|
530
|
-
<div class="dropdown__submenu ${
|
|
531
|
-
@mouseenter="${()=>this.handleSubmenuEnter(
|
|
532
|
-
@mouseleave="${()=>this.handleSubmenuLeave(
|
|
533
|
-
${
|
|
470
|
+
${t&&e?i`
|
|
471
|
+
<div class="dropdown__submenu ${d({"dropdown__submenu--right":"right"===this.cascadeDirection||"auto"===this.cascadeDirection,"dropdown__submenu--left":"left"===this.cascadeDirection})}"
|
|
472
|
+
@mouseenter="${()=>this.handleSubmenuEnter(o.id)}"
|
|
473
|
+
@mouseleave="${()=>this.handleSubmenuLeave(o.id)}">
|
|
474
|
+
${o.customContent?i`
|
|
534
475
|
<div class="dropdown__custom-content">
|
|
535
|
-
${"string"==typeof
|
|
476
|
+
${"string"==typeof o.customContent?i`<div .innerHTML="${o.customContent}"></div>`:o.customContent}
|
|
536
477
|
</div>
|
|
537
|
-
`:
|
|
478
|
+
`:i`
|
|
538
479
|
<div class="dropdown__items">
|
|
539
|
-
${
|
|
480
|
+
${o.options.map((o=>o.divider?i`<div class="dropdown__divider"></div>`:i`
|
|
540
481
|
<button
|
|
541
|
-
class="dropdown__item ${
|
|
542
|
-
?disabled="${
|
|
543
|
-
@click="${()=>this.handleItemClick(
|
|
482
|
+
class="dropdown__item ${d({"dropdown__item--disabled":!!o.disabled})}"
|
|
483
|
+
?disabled="${o.disabled}"
|
|
484
|
+
@click="${()=>this.handleItemClick(o)}"
|
|
544
485
|
>
|
|
545
|
-
${
|
|
546
|
-
<span class="dropdown__item-label">${
|
|
486
|
+
${o.icon?i`<nr-icon name="${o.icon}" class="dropdown__item-icon"></nr-icon>`:n}
|
|
487
|
+
<span class="dropdown__item-label">${o.label}</span>
|
|
547
488
|
</button>
|
|
548
489
|
`))}
|
|
549
490
|
</div>
|
|
550
491
|
`}
|
|
551
492
|
</div>
|
|
552
|
-
`:
|
|
493
|
+
`:n}
|
|
553
494
|
</div>
|
|
554
495
|
`}))}
|
|
555
496
|
</div>
|
|
556
|
-
`:
|
|
497
|
+
`:n}render(){const o={dropdown__panel:!0,"dropdown__panel--open":this.open,[`dropdown__panel--${this.size}`]:!0,[`dropdown__panel--${this.animation}`]:!0,[`dropdown__panel--${this.placement}`]:!0,"dropdown__panel--with-arrow":this.arrow},t={maxHeight:this.maxHeight,minWidth:this.minWidth};return i`
|
|
557
498
|
<div class="dropdown">
|
|
558
499
|
<div class="dropdown__trigger">
|
|
559
500
|
<slot name="trigger"></slot>
|
|
560
501
|
</div>
|
|
561
502
|
|
|
562
503
|
<div
|
|
563
|
-
class="${
|
|
564
|
-
style="${
|
|
504
|
+
class="${d(o)}"
|
|
505
|
+
style="${s(t)}"
|
|
565
506
|
@click="${this.handleDropdownPanelClick}"
|
|
566
507
|
>
|
|
567
|
-
${this.arrow?
|
|
508
|
+
${this.arrow?i`<div class="dropdown__arrow"></div>`:n}
|
|
568
509
|
|
|
569
510
|
<slot name="header"></slot>
|
|
570
511
|
|
|
@@ -575,4 +516,4 @@ const Pt=(t,i)=>"method"===i.kind&&i.descriptor&&!("value"in i.descriptor)?{...i
|
|
|
575
516
|
<slot name="footer"></slot>
|
|
576
517
|
</div>
|
|
577
518
|
</div>
|
|
578
|
-
`}};
|
|
519
|
+
`}};u.styles=l,c([e({type:Array})],u.prototype,"items",void 0),c([e({type:Boolean,reflect:!0})],u.prototype,"open",void 0),c([e({type:String})],u.prototype,"placement",void 0),c([e({type:String})],u.prototype,"trigger",void 0),c([e({type:String})],u.prototype,"size",void 0),c([e({type:String})],u.prototype,"animation",void 0),c([e({type:Boolean})],u.prototype,"disabled",void 0),c([e({type:Boolean})],u.prototype,"arrow",void 0),c([e({type:Boolean,attribute:"auto-close"})],u.prototype,"autoClose",void 0),c([e({type:Boolean,attribute:"close-on-outside-click"})],u.prototype,"closeOnOutsideClick",void 0),c([e({type:Boolean,attribute:"close-on-escape"})],u.prototype,"closeOnEscape",void 0),c([e({type:Number})],u.prototype,"offset",void 0),c([e({type:Number})],u.prototype,"delay",void 0),c([e({type:String,attribute:"max-height"})],u.prototype,"maxHeight",void 0),c([e({type:String,attribute:"min-width"})],u.prototype,"minWidth",void 0),c([e({type:String,attribute:"cascade-direction"})],u.prototype,"cascadeDirection",void 0),c([e({type:Number,attribute:"cascade-delay"})],u.prototype,"cascadeDelay",void 0),c([e({type:Boolean,attribute:"cascade-on-hover"})],u.prototype,"cascadeOnHover",void 0),u=c([r("nr-dropdown")],u);export{u as NrDropdownElement};
|