@nuralyui/radio-group 0.0.8 → 0.0.9
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 +8 -395
- package/package.json +1 -1
package/bundle.js
CHANGED
|
@@ -1,424 +1,37 @@
|
|
|
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,s=Symbol(),e=new WeakMap;class r{constructor(t,i,e){if(this._$cssResult$=!0,e!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o;const s=this.t;if(i&&void 0===t){const i=void 0!==s&&1===s.length;i&&(t=e.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&e.set(s,t))}return t}toString(){return this.cssText}}const o=i?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let i="";for(const s of t.cssRules)i+=s.cssText;return(t=>new r("string"==typeof t?t:t+"",void 0,s))(i)})(t):t
|
|
7
|
-
/**
|
|
8
|
-
* @license
|
|
9
|
-
* Copyright 2017 Google LLC
|
|
10
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
-
*/;var n;const a=window,l=a.trustedTypes,h=l?l.emptyScript:"",d=a.reactiveElementPolyfillSupport,u={toAttribute(t,i){switch(i){case Boolean:t=t?h:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,i){let s=t;switch(i){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},c=(t,i)=>i!==t&&(i==i||t==t),p={attribute:!0,type:String,converter:u,reflect:!1,hasChanged:c},v="finalized";class b 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,s)=>{const e=this._$Ep(s,i);void 0!==e&&(this._$Ev.set(e,s),t.push(e))})),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 s="symbol"==typeof t?Symbol():"__"+t,e=this.getPropertyDescriptor(t,s,i);void 0!==e&&Object.defineProperty(this.prototype,t,e)}}static getPropertyDescriptor(t,i,s){return{get(){return this[i]},set(e){const r=this[t];this[i]=e,this.requestUpdate(t,r,s)},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 s of i)this.createProperty(s,t[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const i=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)i.unshift(o(t))}else void 0!==t&&i.push(o(t));return i}static _$Ep(t,i){const s=i.attribute;return!1===s?void 0:"string"==typeof s?s:"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,s;(null!==(i=this._$ES)&&void 0!==i?i:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(s=t.hostConnected)||void 0===s||s.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 s;const e=null!==(s=this.shadowRoot)&&void 0!==s?s:this.attachShadow(this.constructor.shadowRootOptions);return((s,e)=>{i?s.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((i=>{const e=document.createElement("style"),r=t.litNonce;void 0!==r&&e.setAttribute("nonce",r),e.textContent=i.cssText,s.appendChild(e)}))})(e,this.constructor.elementStyles),e}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,s){this._$AK(t,s)}_$EO(t,i,s=p){var e;const r=this.constructor._$Ep(t,s);if(void 0!==r&&!0===s.reflect){const o=(void 0!==(null===(e=s.converter)||void 0===e?void 0:e.toAttribute)?s.converter:u).toAttribute(i,s.type);this._$El=t,null==o?this.removeAttribute(r):this.setAttribute(r,o),this._$El=null}}_$AK(t,i){var s;const e=this.constructor,r=e._$Ev.get(t);if(void 0!==r&&this._$El!==r){const t=e.getPropertyOptions(r),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(s=t.converter)||void 0===s?void 0:s.fromAttribute)?t.converter:u;this._$El=r,this[r]=o.fromAttribute(i,t.type),this._$El=null}}requestUpdate(t,i,s){let e=!0;void 0!==t&&(((s=s||this.constructor.getPropertyOptions(t)).hasChanged||c)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),!0===s.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,s))):e=!1),!this.isUpdatePending&&e&&(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 s=this._$AL;try{i=this.shouldUpdate(s),i?(this.willUpdate(s),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(s)):this._$Ek()}catch(t){throw i=!1,this._$Ek(),t}i&&this._$AE(s)}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 f;b[v]=!0,b.elementProperties=new Map,b.elementStyles=[],b.shadowRootOptions={mode:"open"},null==d||d({ReactiveElement:b}),(null!==(n=a.reactiveElementVersions)&&void 0!==n?n:a.reactiveElementVersions=[]).push("1.6.3");const g=window,y=g.trustedTypes,m=y?y.createPolicy("lit-html",{createHTML:t=>t}):void 0,$="$lit$",w=`lit$${(Math.random()+"").slice(9)}$`,x="?"+w,S=`<${x}>`,E=document,A=()=>E.createComment(""),k=t=>null===t||"object"!=typeof t&&"function"!=typeof t,O=Array.isArray,C="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,T=/-->/g,_=/>/g,D=RegExp(`>|${C}(?:([^\\s"'>=/]+)(${C}*=${C}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),U=/'/g,M=/"/g,j=/^(?:script|style|textarea|title)$/i,z=Symbol.for("lit-noChange"),I=Symbol.for("lit-nothing"),N=new WeakMap,P=E.createTreeWalker(E,129,null,!1);function F(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==m?m.createHTML(i):i}class V{constructor({strings:t,_$litType$:i},s){let e;this.parts=[];let r=0,o=0;const n=t.length-1,a=this.parts,[l,h]=((t,i)=>{const s=t.length-1,e=[];let r,o=2===i?"<svg>":"",n=R;for(let i=0;i<s;i++){const s=t[i];let a,l,h=-1,d=0;for(;d<s.length&&(n.lastIndex=d,l=n.exec(s),null!==l);)d=n.lastIndex,n===R?"!--"===l[1]?n=T:void 0!==l[1]?n=_:void 0!==l[2]?(j.test(l[2])&&(r=RegExp("</"+l[2],"g")),n=D):void 0!==l[3]&&(n=D):n===D?">"===l[0]?(n=null!=r?r:R,h=-1):void 0===l[1]?h=-2:(h=n.lastIndex-l[2].length,a=l[1],n=void 0===l[3]?D:'"'===l[3]?M:U):n===M||n===U?n=D:n===T||n===_?n=R:(n=D,r=void 0);const u=n===D&&t[i+1].startsWith("/>")?" ":"";o+=n===R?s+S:h>=0?(e.push(a),s.slice(0,h)+$+s.slice(h)+w+u):s+w+(-2===h?(e.push(void 0),i):u)}return[F(t,o+(t[s]||"<?>")+(2===i?"</svg>":"")),e]})(t,i);if(this.el=V.createElement(l,s),P.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(e=P.nextNode())&&a.length<n;){if(1===e.nodeType){if(e.hasAttributes()){const t=[];for(const i of e.getAttributeNames())if(i.endsWith($)||i.startsWith(w)){const s=h[o++];if(t.push(i),void 0!==s){const t=e.getAttribute(s.toLowerCase()+$).split(w),i=/([.?@])?(.*)/.exec(s);a.push({type:1,index:r,name:i[2],strings:t,ctor:"."===i[1]?K:"?"===i[1]?H:"@"===i[1]?Y:q})}else a.push({type:6,index:r})}for(const i of t)e.removeAttribute(i)}if(j.test(e.tagName)){const t=e.textContent.split(w),i=t.length-1;if(i>0){e.textContent=y?y.emptyScript:"";for(let s=0;s<i;s++)e.append(t[s],A()),P.nextNode(),a.push({type:2,index:++r});e.append(t[i],A())}}}else if(8===e.nodeType)if(e.data===x)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=e.data.indexOf(w,t+1));)a.push({type:7,index:r}),t+=w.length-1}r++}}static createElement(t,i){const s=E.createElement("template");return s.innerHTML=t,s}}function L(t,i,s=t,e){var r,o,n,a;if(i===z)return i;let l=void 0!==e?null===(r=s._$Co)||void 0===r?void 0:r[e]:s._$Cl;const h=k(i)?void 0:i._$litDirective$;return(null==l?void 0:l.constructor)!==h&&(null===(o=null==l?void 0:l._$AO)||void 0===o||o.call(l,!1),void 0===h?l=void 0:(l=new h(t),l._$AT(t,s,e)),void 0!==e?(null!==(n=(a=s)._$Co)&&void 0!==n?n:a._$Co=[])[e]=l:s._$Cl=l),void 0!==l&&(i=L(t,l._$AS(t,i.values),l,e)),i}class B{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:s},parts:e}=this._$AD,r=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:E).importNode(s,!0);P.currentNode=r;let o=P.nextNode(),n=0,a=0,l=e[0];for(;void 0!==l;){if(n===l.index){let i;2===l.type?i=new W(o,o.nextSibling,this,t):1===l.type?i=new l.ctor(o,l.name,l.strings,this,t):6===l.type&&(i=new Z(o,this,t)),this._$AV.push(i),l=e[++a]}n!==(null==l?void 0:l.index)&&(o=P.nextNode(),n++)}return P.currentNode=E,r}v(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++}}class W{constructor(t,i,s,e){var r;this.type=2,this._$AH=I,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cp=null===(r=null==e?void 0:e.isConnected)||void 0===r||r}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=L(this,t,i),k(t)?t===I||null==t||""===t?(this._$AH!==I&&this._$AR(),this._$AH=I):t!==this._$AH&&t!==z&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>O(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!==I&&k(this._$AH)?this._$AA.nextSibling.data=t:this.$(E.createTextNode(t)),this._$AH=t}g(t){var i;const{values:s,_$litType$:e}=t,r="number"==typeof e?this._$AC(t):(void 0===e.el&&(e.el=V.createElement(F(e.h,e.h[0]),this.options)),e);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===r)this._$AH.v(s);else{const t=new B(r,this),i=t.u(this.options);t.v(s),this.$(i),this._$AH=t}}_$AC(t){let i=N.get(t.strings);return void 0===i&&N.set(t.strings,i=new V(t)),i}T(t){O(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const r of t)e===i.length?i.push(s=new W(this.k(A()),this.k(A()),this,this.options)):s=i[e],s._$AI(r),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e)}_$AR(t=this._$AA.nextSibling,i){var s;for(null===(s=this._$AP)||void 0===s||s.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 q{constructor(t,i,s,e,r){this.type=1,this._$AH=I,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=r,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=I}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,s,e){const r=this.strings;let o=!1;if(void 0===r)t=L(this,t,i,0),o=!k(t)||t!==this._$AH&&t!==z,o&&(this._$AH=t);else{const e=t;let n,a;for(t=r[0],n=0;n<r.length-1;n++)a=L(this,e[s+n],i,n),a===z&&(a=this._$AH[n]),o||(o=!k(a)||a!==this._$AH[n]),a===I?t=I:t!==I&&(t+=(null!=a?a:"")+r[n+1]),this._$AH[n]=a}o&&!e&&this.j(t)}j(t){t===I?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class K extends q{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===I?void 0:t}}const G=y?y.emptyScript:"";class H extends q{constructor(){super(...arguments),this.type=4}j(t){t&&t!==I?this.element.setAttribute(this.name,G):this.element.removeAttribute(this.name)}}class Y extends q{constructor(t,i,s,e,r){super(t,i,s,e,r),this.type=5}_$AI(t,i=this){var s;if((t=null!==(s=L(this,t,i,0))&&void 0!==s?s:I)===z)return;const e=this._$AH,r=t===I&&e!==I||t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive,o=t!==I&&(e===I||r);r&&this.element.removeEventListener(this.name,this,e),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,s;"function"==typeof this._$AH?this._$AH.call(null!==(s=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==s?s: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){L(this,t)}}const J=g.litHtmlPolyfillSupport;
|
|
18
|
-
/**
|
|
19
|
-
* @license
|
|
20
|
-
* Copyright 2017 Google LLC
|
|
21
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
|
-
*/
|
|
23
|
-
var Q;null==J||J(V,W),(null!==(f=g.litHtmlVersions)&&void 0!==f?f:g.litHtmlVersions=[]).push("2.8.0");const X=window,tt=X.trustedTypes,it=tt?tt.createPolicy("lit-html",{createHTML:t=>t}):void 0,st="$lit$",et=`lit$${(Math.random()+"").slice(9)}$`,rt="?"+et,ot=`<${rt}>`,nt=document,at=()=>nt.createComment(""),lt=t=>null===t||"object"!=typeof t&&"function"!=typeof t,ht=Array.isArray,dt="[ \t\n\f\r]",ut=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ct=/-->/g,pt=/>/g,vt=RegExp(`>|${dt}(?:([^\\s"'>=/]+)(${dt}*=${dt}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),bt=/'/g,ft=/"/g,gt=/^(?:script|style|textarea|title)$/i,yt=(t=>(i,...s)=>({_$litType$:t,strings:i,values:s}))(1),mt=Symbol.for("lit-noChange"),$t=Symbol.for("lit-nothing"),wt=new WeakMap,xt=nt.createTreeWalker(nt,129,null,!1);function St(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==it?it.createHTML(i):i}const Et=(t,i)=>{const s=t.length-1,e=[];let r,o=2===i?"<svg>":"",n=ut;for(let i=0;i<s;i++){const s=t[i];let a,l,h=-1,d=0;for(;d<s.length&&(n.lastIndex=d,l=n.exec(s),null!==l);)d=n.lastIndex,n===ut?"!--"===l[1]?n=ct:void 0!==l[1]?n=pt:void 0!==l[2]?(gt.test(l[2])&&(r=RegExp("</"+l[2],"g")),n=vt):void 0!==l[3]&&(n=vt):n===vt?">"===l[0]?(n=null!=r?r:ut,h=-1):void 0===l[1]?h=-2:(h=n.lastIndex-l[2].length,a=l[1],n=void 0===l[3]?vt:'"'===l[3]?ft:bt):n===ft||n===bt?n=vt:n===ct||n===pt?n=ut:(n=vt,r=void 0);const u=n===vt&&t[i+1].startsWith("/>")?" ":"";o+=n===ut?s+ot:h>=0?(e.push(a),s.slice(0,h)+st+s.slice(h)+et+u):s+et+(-2===h?(e.push(void 0),i):u)}return[St(t,o+(t[s]||"<?>")+(2===i?"</svg>":"")),e]};class At{constructor({strings:t,_$litType$:i},s){let e;this.parts=[];let r=0,o=0;const n=t.length-1,a=this.parts,[l,h]=Et(t,i);if(this.el=At.createElement(l,s),xt.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(e=xt.nextNode())&&a.length<n;){if(1===e.nodeType){if(e.hasAttributes()){const t=[];for(const i of e.getAttributeNames())if(i.endsWith(st)||i.startsWith(et)){const s=h[o++];if(t.push(i),void 0!==s){const t=e.getAttribute(s.toLowerCase()+st).split(et),i=/([.?@])?(.*)/.exec(s);a.push({type:1,index:r,name:i[2],strings:t,ctor:"."===i[1]?Tt:"?"===i[1]?Dt:"@"===i[1]?Ut:Rt})}else a.push({type:6,index:r})}for(const i of t)e.removeAttribute(i)}if(gt.test(e.tagName)){const t=e.textContent.split(et),i=t.length-1;if(i>0){e.textContent=tt?tt.emptyScript:"";for(let s=0;s<i;s++)e.append(t[s],at()),xt.nextNode(),a.push({type:2,index:++r});e.append(t[i],at())}}}else if(8===e.nodeType)if(e.data===rt)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=e.data.indexOf(et,t+1));)a.push({type:7,index:r}),t+=et.length-1}r++}}static createElement(t,i){const s=nt.createElement("template");return s.innerHTML=t,s}}function kt(t,i,s=t,e){var r,o,n,a;if(i===mt)return i;let l=void 0!==e?null===(r=s._$Co)||void 0===r?void 0:r[e]:s._$Cl;const h=lt(i)?void 0:i._$litDirective$;return(null==l?void 0:l.constructor)!==h&&(null===(o=null==l?void 0:l._$AO)||void 0===o||o.call(l,!1),void 0===h?l=void 0:(l=new h(t),l._$AT(t,s,e)),void 0!==e?(null!==(n=(a=s)._$Co)&&void 0!==n?n:a._$Co=[])[e]=l:s._$Cl=l),void 0!==l&&(i=kt(t,l._$AS(t,i.values),l,e)),i}class Ot{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:s},parts:e}=this._$AD,r=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:nt).importNode(s,!0);xt.currentNode=r;let o=xt.nextNode(),n=0,a=0,l=e[0];for(;void 0!==l;){if(n===l.index){let i;2===l.type?i=new Ct(o,o.nextSibling,this,t):1===l.type?i=new l.ctor(o,l.name,l.strings,this,t):6===l.type&&(i=new Mt(o,this,t)),this._$AV.push(i),l=e[++a]}n!==(null==l?void 0:l.index)&&(o=xt.nextNode(),n++)}return xt.currentNode=nt,r}v(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++}}class Ct{constructor(t,i,s,e){var r;this.type=2,this._$AH=$t,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cp=null===(r=null==e?void 0:e.isConnected)||void 0===r||r}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=kt(this,t,i),lt(t)?t===$t||null==t||""===t?(this._$AH!==$t&&this._$AR(),this._$AH=$t):t!==this._$AH&&t!==mt&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>ht(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!==$t&<(this._$AH)?this._$AA.nextSibling.data=t:this.$(nt.createTextNode(t)),this._$AH=t}g(t){var i;const{values:s,_$litType$:e}=t,r="number"==typeof e?this._$AC(t):(void 0===e.el&&(e.el=At.createElement(St(e.h,e.h[0]),this.options)),e);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===r)this._$AH.v(s);else{const t=new Ot(r,this),i=t.u(this.options);t.v(s),this.$(i),this._$AH=t}}_$AC(t){let i=wt.get(t.strings);return void 0===i&&wt.set(t.strings,i=new At(t)),i}T(t){ht(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const r of t)e===i.length?i.push(s=new Ct(this.k(at()),this.k(at()),this,this.options)):s=i[e],s._$AI(r),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e)}_$AR(t=this._$AA.nextSibling,i){var s;for(null===(s=this._$AP)||void 0===s||s.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 Rt{constructor(t,i,s,e,r){this.type=1,this._$AH=$t,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=r,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=$t}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,s,e){const r=this.strings;let o=!1;if(void 0===r)t=kt(this,t,i,0),o=!lt(t)||t!==this._$AH&&t!==mt,o&&(this._$AH=t);else{const e=t;let n,a;for(t=r[0],n=0;n<r.length-1;n++)a=kt(this,e[s+n],i,n),a===mt&&(a=this._$AH[n]),o||(o=!lt(a)||a!==this._$AH[n]),a===$t?t=$t:t!==$t&&(t+=(null!=a?a:"")+r[n+1]),this._$AH[n]=a}o&&!e&&this.j(t)}j(t){t===$t?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class Tt extends Rt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===$t?void 0:t}}const _t=tt?tt.emptyScript:"";class Dt extends Rt{constructor(){super(...arguments),this.type=4}j(t){t&&t!==$t?this.element.setAttribute(this.name,_t):this.element.removeAttribute(this.name)}}class Ut extends Rt{constructor(t,i,s,e,r){super(t,i,s,e,r),this.type=5}_$AI(t,i=this){var s;if((t=null!==(s=kt(this,t,i,0))&&void 0!==s?s:$t)===mt)return;const e=this._$AH,r=t===$t&&e!==$t||t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive,o=t!==$t&&(e===$t||r);r&&this.element.removeEventListener(this.name,this,e),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,s;"function"==typeof this._$AH?this._$AH.call(null!==(s=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==s?s:this.element,t):this._$AH.handleEvent(t)}}class Mt{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){kt(this,t)}}const jt=X.litHtmlPolyfillSupport;null==jt||jt(At,Ct),(null!==(Q=X.litHtmlVersions)&&void 0!==Q?Q:X.litHtmlVersions=[]).push("2.8.0");
|
|
24
|
-
/**
|
|
25
|
-
* @license
|
|
26
|
-
* Copyright 2017 Google LLC
|
|
27
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
28
|
-
*/
|
|
29
|
-
var zt,It;class Nt extends b{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,i;const s=super.createRenderRoot();return null!==(t=(i=this.renderOptions).renderBefore)&&void 0!==t||(i.renderBefore=s.firstChild),s}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,i,s)=>{var e,r;const o=null!==(e=null==s?void 0:s.renderBefore)&&void 0!==e?e:i;let n=o._$litPart$;if(void 0===n){const t=null!==(r=null==s?void 0:s.renderBefore)&&void 0!==r?r:null;o._$litPart$=n=new Ct(i.insertBefore(at(),t),t,void 0,null!=s?s:{})}return n._$AI(t),n})(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 mt}}Nt.finalized=!0,Nt._$litElement$=!0,null===(zt=globalThis.litElementHydrateSupport)||void 0===zt||zt.call(globalThis,{LitElement:Nt});const Pt=globalThis.litElementPolyfillSupport;null==Pt||Pt({LitElement:Nt}),(null!==(It=globalThis.litElementVersions)&&void 0!==It?It:globalThis.litElementVersions=[]).push("3.3.3");
|
|
30
|
-
/**
|
|
31
|
-
* @license
|
|
32
|
-
* Copyright 2017 Google LLC
|
|
33
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
34
|
-
*/
|
|
35
|
-
const Ft=(t,i)=>"method"===i.kind&&i.descriptor&&!("value"in i.descriptor)?{...i,finisher(s){s.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(s){s.createProperty(i.key,t)}};
|
|
36
|
-
/**
|
|
37
|
-
* @license
|
|
38
|
-
* Copyright 2017 Google LLC
|
|
39
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
40
|
-
*/function Vt(t){return(i,s)=>void 0!==s?((t,i,s)=>{i.constructor.createProperty(s,t)})(t,i,s):Ft(t,i)
|
|
41
|
-
/**
|
|
42
|
-
* @license
|
|
43
|
-
* Copyright 2021 Google LLC
|
|
44
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
45
|
-
*/}var Lt;null===(Lt=window.HTMLSlotElement)||void 0===Lt||Lt.prototype.assignedElements;
|
|
46
|
-
/**
|
|
47
|
-
* @license
|
|
48
|
-
* Copyright 2021 Google LLC
|
|
49
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
50
|
-
*/
|
|
51
|
-
const Bt=1;
|
|
52
|
-
/**
|
|
53
|
-
* @license
|
|
54
|
-
* Copyright 2017 Google LLC
|
|
55
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
56
|
-
*/class Wt{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,i,s){this._$Ct=t,this._$AM=i,this._$Ci=s}_$AS(t,i){return this.update(t,i)}update(t,i){return this.render(...i)}}
|
|
57
|
-
/**
|
|
58
|
-
* @license
|
|
59
|
-
* Copyright 2018 Google LLC
|
|
60
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
-
*/const qt=(t=>(...i)=>({_$litDirective$:t,values:i}))(class extends Wt{constructor(t){var i;if(super(t),t.type!==Bt||"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 s,e;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===(s=this.nt)||void 0===s?void 0:s.has(t))&&this.it.add(t);return this.render(i)}const r=t.element.classList;this.it.forEach((t=>{t in i||(r.remove(t),this.it.delete(t))}));for(const t in i){const s=!!i[t];s===this.it.has(t)||(null===(e=this.nt)||void 0===e?void 0:e.has(t))||(s?(r.add(t),this.it.add(t)):(r.remove(t),this.it.delete(t)))}return z}}),Kt=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,s;super.disconnectedCallback(),null===(t=this.themeObserver)||void 0===t||t.disconnect(),null===(i=this.designSystemObserver)||void 0===i||i.disconnect(),null===(s=this.mediaQuery)||void 0===s||s.removeEventListener("change",this.handleSystemThemeChange)}get currentTheme(){var t,i;const s=(null===(t=this.closest("[data-theme]"))||void 0===t?void 0:t.getAttribute("data-theme"))||document.documentElement.getAttribute("data-theme");return s||((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)},Ht=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 s of this.requiredComponents)if(!this.isComponentAvailable(s)){i=!1;const e=new Error(`Required component "${s}" is not registered. Please import and register the component before using ${this.tagName.toLowerCase()}.`);t?t(s,e):console.error(e.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)}},Yt=t=>class extends t{dispatchCustomEvent(t,i){this.dispatchEvent(new CustomEvent(t,{detail:i,bubbles:!0,composed:!0}))}dispatchEventWithMetadata(t,i){var s;const e=Object.assign(Object.assign({},i),{timestamp:Date.now(),componentName:(null===(s=this.tagName)||void 0===s?void 0:s.toLowerCase())||"unknown"});this.dispatchCustomEvent(t,e)}dispatchInputEvent(t,i){const s=Object.assign({target:i.target||this,value:i.value,originalEvent:i.originalEvent},i);this.dispatchCustomEvent(t,s)}dispatchFocusEvent(t,i){const s=Object.assign({target:i.target||this,value:i.value,focused:i.focused,cursorPosition:i.cursorPosition,selectedText:i.selectedText},i);this.dispatchCustomEvent(t,s)}dispatchValidationEvent(t,i){var s;const e=Object.assign({target:i.target||this,value:i.value,isValid:null!==(s=i.isValid)&&void 0!==s&&s,error:i.error},i);this.dispatchCustomEvent(t,e)}dispatchActionEvent(t,i){const s=Object.assign({target:i.target||this,action:i.action,previousValue:i.previousValue,newValue:i.newValue},i);this.dispatchCustomEvent(t,s)}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}};
|
|
62
|
-
/**
|
|
63
|
-
* @license
|
|
64
|
-
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
65
|
-
* SPDX-License-Identifier: MIT
|
|
66
|
-
*/
|
|
67
|
-
/**
|
|
68
|
-
* @license
|
|
69
|
-
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
70
|
-
* SPDX-License-Identifier: MIT
|
|
71
|
-
*/
|
|
72
|
-
class Zt{constructor(t){this.host=t,t.addController(this)}hostConnected(){if(this.host.defaultValue&&!this.host.value){const t=this.host.options.find((t=>t.value===this.host.defaultValue));t&&!this.isOptionDisabled(t)&&this.selectOption(t)}}hostDisconnected(){}selectOption(t){if(this.isOptionDisabled(t))return;const i=this.host.value;this.host.value=t.value,this.dispatchChangeEvent(t,i),this.host.requestUpdate()}getSelectedOption(){return this.host.options.find((t=>t.value===this.host.value))}isOptionSelected(t){return t.value===this.host.value}isOptionDisabled(t){return this.host.disabled||Boolean(t.disabled)}getFormData(){return this.host.name?{[this.host.name]:this.host.value}:{}}reset(){this.host.value=this.host.defaultValue||"",this.host.requestUpdate()}getSelectedValue(){return this.host.value}dispatchChangeEvent(t,i){const s=new CustomEvent("nr-change",{detail:{value:t.value,option:t,oldValue:i},bubbles:!0,composed:!0});this.host.dispatchEvent(s)}}
|
|
1
|
+
import{css as t,LitElement as r,html as i,nothing as o}from"lit";import{property as e,customElement as s}from"lit/decorators.js";import{choose as n}from"lit/directives/choose.js";import{classMap as a}from"lit/directives/class-map.js";import{NuralyUIBaseMixin as l}from"@nuralyui/common/mixins";import{throttle as d}from"@nuralyui/common/utils";
|
|
73
2
|
/**
|
|
74
3
|
* @license
|
|
75
4
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
76
5
|
* SPDX-License-Identifier: MIT
|
|
77
|
-
*/class
|
|
6
|
+
*/class u{constructor(t){this.host=t,t.addController(this)}hostConnected(){if(this.host.defaultValue&&!this.host.value){const t=this.host.options.find((t=>t.value===this.host.defaultValue));t&&!this.isOptionDisabled(t)&&this.selectOption(t)}}hostDisconnected(){}selectOption(t){if(this.isOptionDisabled(t))return;const r=this.host.value;this.host.value=t.value,this.dispatchChangeEvent(t,r),this.host.requestUpdate()}getSelectedOption(){return this.host.options.find((t=>t.value===this.host.value))}isOptionSelected(t){return t.value===this.host.value}isOptionDisabled(t){return this.host.disabled||Boolean(t.disabled)}getFormData(){return this.host.name?{[this.host.name]:this.host.value}:{}}reset(){this.host.value=this.host.defaultValue||"",this.host.requestUpdate()}getSelectedValue(){return this.host.value}dispatchChangeEvent(t,r){const i=new CustomEvent("nr-change",{detail:{value:t.value,option:t,oldValue:r},bubbles:!0,composed:!0});this.host.dispatchEvent(i)}}
|
|
78
7
|
/**
|
|
79
8
|
* @license
|
|
80
9
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
81
10
|
* SPDX-License-Identifier: MIT
|
|
82
|
-
*/class
|
|
11
|
+
*/class c{constructor(t,r){this.groupController=r,this.host=t,this.boundKeyDownHandler=this.handleKeyDown.bind(this),t.addController(this)}hostConnected(){this.host.addEventListener("keydown",this.boundKeyDownHandler)}hostDisconnected(){this.host.removeEventListener("keydown",this.boundKeyDownHandler)}handleKeyDown(t){const r=this.host.options;if(!r||0===r.length)return;const i=r.findIndex((t=>this.groupController.isOptionSelected(t)));switch(t.key){case"ArrowDown":case"ArrowRight":t.preventDefault(),this.selectNextOption(r,i);break;case"ArrowUp":case"ArrowLeft":t.preventDefault(),this.selectPreviousOption(r,i);break;case" ":case"Enter":t.preventDefault(),-1===i&&this.selectFirstEnabledOption(r);break;case"Home":t.preventDefault(),this.selectFirstEnabledOption(r);break;case"End":t.preventDefault(),this.selectLastEnabledOption(r)}}selectNextOption(t,r){const i=-1===r?0:r+1;for(let r=0;r<t.length;r++){const o=t[(i+r)%t.length];if(!this.groupController.isOptionDisabled(o)){this.groupController.selectOption(o);break}}}selectPreviousOption(t,r){const i=-1===r?t.length-1:r-1;for(let r=0;r<t.length;r++){const o=t[(i-r+t.length)%t.length];if(!this.groupController.isOptionDisabled(o)){this.groupController.selectOption(o);break}}}selectFirstEnabledOption(t){const r=t.find((t=>!this.groupController.isOptionDisabled(t)));r&&this.groupController.selectOption(r)}selectLastEnabledOption(t){const r=t.filter((t=>!this.groupController.isOptionDisabled(t))),i=r[r.length-1];i&&this.groupController.selectOption(i)}}
|
|
83
12
|
/**
|
|
84
13
|
* @license
|
|
85
14
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
86
15
|
* SPDX-License-Identifier: MIT
|
|
87
|
-
*/class
|
|
16
|
+
*/class h{constructor(t){this._focusedIndex=-1,this._hasFocus=!1,this.host=t,this.boundFocusInHandler=this.handleFocusIn.bind(this),this.boundFocusOutHandler=this.handleFocusOut.bind(this),t.addController(this)}hostConnected(){this.host.addEventListener("focusin",this.boundFocusInHandler),this.host.addEventListener("focusout",this.boundFocusOutHandler)}hostDisconnected(){this.host.removeEventListener("focusin",this.boundFocusInHandler),this.host.removeEventListener("focusout",this.boundFocusOutHandler)}get focusedIndex(){return this._focusedIndex}get hasFocus(){return this._hasFocus}setFocusedOption(t){const r=this._focusedIndex;this._focusedIndex=t,r!==t&&this.host.requestUpdate()}getFocusedIndex(){return this._focusedIndex}clearFocus(){this._focusedIndex=-1,this._hasFocus=!1,this.host.requestUpdate()}handleFocusIn(t){var r;this._hasFocus=!0;const i=t.target;if(i&&i.matches('input[type="radio"], nr-button[role="radio"]')){const t=null===(r=this.host.shadowRoot)||void 0===r?void 0:r.querySelectorAll('input[type="radio"], nr-button[role="radio"]');if(t){const r=Array.from(t).indexOf(i);-1!==r&&this.setFocusedOption(r)}}this.host.requestUpdate()}handleFocusOut(t){const r=t.relatedTarget,i=this.host;r&&i.contains(r)||(this._hasFocus=!1,this.host.requestUpdate())}focus(){const t=this.host.options,r=this.host.value,i=t.findIndex((t=>t.value===r));if(-1!==i)return void this.focusOptionAtIndex(i);const o=t.findIndex((t=>!t.disabled));-1!==o&&this.focusOptionAtIndex(o)}blur(){const t=this.host.shadowRoot;if(!t)return;const r=t.querySelector('input[type="radio"]:focus, nr-button[role="radio"]:focus');r&&"function"==typeof r.blur&&r.blur()}focusOptionAtIndex(t){const r=this.host.shadowRoot;if(!r)return;this.updateTabIndices(t);const i=r.querySelectorAll('input[type="radio"]');if(i[t])return void i[t].focus();const o=r.querySelectorAll('nr-button[role="radio"]');o[t]&&o[t].focus()}updateTabIndices(t){const r=this.host.shadowRoot;if(!r)return;const i=this.host.options,o=this.host.value;let e=t;if(void 0===e){const t=i.findIndex((t=>t.value===o));e=-1!==t?t:i.findIndex((t=>!t.disabled))}r.querySelectorAll('input[type="radio"]').forEach(((t,r)=>{t.tabIndex=r===e?0:-1}));r.querySelectorAll('nr-button[role="radio"]').forEach(((t,r)=>{t.tabIndex=r===e?0:-1}))}hostUpdated(){this.updateTabIndices()}}
|
|
88
17
|
/**
|
|
89
18
|
* @license
|
|
90
19
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
91
20
|
* SPDX-License-Identifier: MIT
|
|
92
|
-
*/
|
|
21
|
+
*/class p{constructor(t){this._isValid=!0,this._validationMessage="",this.host=t,t.addController(this)}hostConnected(){}hostDisconnected(){}get isValid(){return this._isValid}get validationMessage(){return this._validationMessage}validate(){const t=this.host.required,r=this.host.value;return t&&!r?(this._isValid=!1,this._validationMessage="Please select an option",this.host.requestUpdate(),!1):(this._isValid=!0,this._validationMessage="",this.host.requestUpdate(),!0)}setCustomValidity(t){this._isValid=!t,this._validationMessage=t,this.host.requestUpdate()}clearValidation(){this._isValid=!0,this._validationMessage="",this.host.requestUpdate()}getFormData(){const t=this.host.name,r=this.host.value;return t?{[t]:r}:{}}checkValidity(){return this.validate()}reportValidity(){const t=this.validate();if(!t){const t=new CustomEvent("invalid",{detail:{message:this._validationMessage},bubbles:!0,composed:!0});this.host.dispatchEvent(t)}return t}reset(){this.clearValidation()}getFormDataObject(){const t=this.host.name,r=this.host.value;if(!t||!r)return null;const i=new FormData;return i.append(t,r),i}validateOnChange(){this._isValid||this.validate()}}
|
|
93
22
|
/**
|
|
94
23
|
* @license
|
|
95
24
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
96
25
|
* SPDX-License-Identifier: MIT
|
|
97
|
-
*/
|
|
98
|
-
class ti{constructor(t){this._rippleEnabled=!0,this.activeRipples=new Set,this.ripplePool=[],this.host=t,this.boundClickHandler=this.handleClick.bind(this),t.addController(this);const i=this.addRippleEffect.bind(this);this.addRippleEffect=function(t,i){let s;return function(...e){s||(t.apply(this,e),s=!0,setTimeout((()=>s=!1),i))}}(i,16)}hostConnected(){this.host.addEventListener("click",this.boundClickHandler)}hostDisconnected(){this.host.removeEventListener("click",this.boundClickHandler)}get rippleEnabled(){return this._rippleEnabled}set rippleEnabled(t){this._rippleEnabled=t}handleClick(t){if(!this._rippleEnabled)return;const i=t.target;i&&i.matches('input[type="radio"]')&&this.addRippleToElement(i),i&&i.matches('nr-button[role="radio"]')&&this.addButtonRippleEffect(i)}addRippleEffect(t){const i=t.target;i&&this.addRippleToElement(i)}addRippleToElement(t){t.style.animation="none",t.offsetHeight;const i=getComputedStyle(t).getPropertyValue("--nuraly-radio-ripple-duration")||getComputedStyle(t).getPropertyValue("--nuraly-radio-local-ripple-duration")||"300ms";t.style.animation=`radioRipple ${i} ease-out`;const s=this.parseDuration(i);setTimeout((()=>{t.style.animation=""}),s)}addButtonRippleEffect(t){const i=this.createRippleElement(t);i&&(t.appendChild(i),setTimeout((()=>{i.parentNode&&i.parentNode.removeChild(i)}),600))}createRippleElement(t){const i=this.getRippleElement(t);return i.style.animation="radioRippleSpread 600ms ease-out",i}parseDuration(t){const i=t.match(/^([\d.]+)(s|ms)$/);if(!i)return 300;const s=parseFloat(i[1]);return"s"===i[2]?1e3*s:s}triggerRipple(t){if(!this._rippleEnabled)return;const i=this.host.shadowRoot;if(!i)return;let s=null;s=t?i.querySelector(`input[type="radio"][value="${t}"]`):i.querySelector('input[type="radio"]:checked'),s&&this.addRippleToElement(s)}disableRipple(){this._rippleEnabled=!1}enableRipple(){this._rippleEnabled=!0}clearRipples(){this.activeRipples.forEach((t=>{t.parentNode&&t.parentNode.removeChild(t),this.ripplePool.length<10&&(t.style.animation="",t.style.transform="scale(0)",this.ripplePool.push(t))})),this.activeRipples.clear();const t=this.host.shadowRoot;if(t){t.querySelectorAll('input[type="radio"]').forEach((t=>{t.style.animation=""}))}}getRippleElement(t){let i=this.ripplePool.pop();i||(i=document.createElement("span"),i.className="radio-ripple",i.style.position="absolute",i.style.borderRadius="50%",i.style.background="currentColor",i.style.opacity="0.1",i.style.pointerEvents="none");const s=t.getBoundingClientRect(),e=Math.max(s.width,s.height);return i.style.width=`${e}px`,i.style.height=`${e}px`,i.style.left=-e/2+"px",i.style.top=-e/2+"px",i.style.transform="scale(0)",this.activeRipples.add(i),i}addRippleEffectToElement(t){this.addRippleToElement(t)}setRippleEnabled(t){this._rippleEnabled=t}}
|
|
26
|
+
*/class b{constructor(t){this._rippleEnabled=!0,this.activeRipples=new Set,this.ripplePool=[],this.host=t,this.boundClickHandler=this.handleClick.bind(this),t.addController(this);const r=this.addRippleEffect.bind(this);this.addRippleEffect=d(r,16)}hostConnected(){this.host.addEventListener("click",this.boundClickHandler)}hostDisconnected(){this.host.removeEventListener("click",this.boundClickHandler)}get rippleEnabled(){return this._rippleEnabled}set rippleEnabled(t){this._rippleEnabled=t}handleClick(t){if(!this._rippleEnabled)return;const r=t.target;r&&r.matches('input[type="radio"]')&&this.addRippleToElement(r),r&&r.matches('nr-button[role="radio"]')&&this.addButtonRippleEffect(r)}addRippleEffect(t){const r=t.target;r&&this.addRippleToElement(r)}addRippleToElement(t){t.style.animation="none",t.offsetHeight;const r=getComputedStyle(t).getPropertyValue("--nuraly-radio-ripple-duration")||getComputedStyle(t).getPropertyValue("--nuraly-radio-local-ripple-duration")||"300ms";t.style.animation=`radioRipple ${r} ease-out`;const i=this.parseDuration(r);setTimeout((()=>{t.style.animation=""}),i)}addButtonRippleEffect(t){const r=this.createRippleElement(t);r&&(t.appendChild(r),setTimeout((()=>{r.parentNode&&r.parentNode.removeChild(r)}),600))}createRippleElement(t){const r=this.getRippleElement(t);return r.style.animation="radioRippleSpread 600ms ease-out",r}parseDuration(t){const r=t.match(/^([\d.]+)(s|ms)$/);if(!r)return 300;const i=parseFloat(r[1]);return"s"===r[2]?1e3*i:i}triggerRipple(t){if(!this._rippleEnabled)return;const r=this.host.shadowRoot;if(!r)return;let i=null;i=t?r.querySelector(`input[type="radio"][value="${t}"]`):r.querySelector('input[type="radio"]:checked'),i&&this.addRippleToElement(i)}disableRipple(){this._rippleEnabled=!1}enableRipple(){this._rippleEnabled=!0}clearRipples(){this.activeRipples.forEach((t=>{t.parentNode&&t.parentNode.removeChild(t),this.ripplePool.length<10&&(t.style.animation="",t.style.transform="scale(0)",this.ripplePool.push(t))})),this.activeRipples.clear();const t=this.host.shadowRoot;if(t){t.querySelectorAll('input[type="radio"]').forEach((t=>{t.style.animation=""}))}}getRippleElement(t){let r=this.ripplePool.pop();r||(r=document.createElement("span"),r.className="radio-ripple",r.style.position="absolute",r.style.borderRadius="50%",r.style.background="currentColor",r.style.opacity="0.1",r.style.pointerEvents="none");const i=t.getBoundingClientRect(),o=Math.max(i.width,i.height);return r.style.width=`${o}px`,r.style.height=`${o}px`,r.style.left=-o/2+"px",r.style.top=-o/2+"px",r.style.transform="scale(0)",this.activeRipples.add(r),r}addRippleEffectToElement(t){this.addRippleToElement(t)}setRippleEnabled(t){this._rippleEnabled=t}}
|
|
99
27
|
/**
|
|
100
28
|
* @license
|
|
101
29
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
102
30
|
* SPDX-License-Identifier: MIT
|
|
103
|
-
*/const
|
|
104
|
-
:host {
|
|
105
|
-
/* ========================================
|
|
106
|
-
* CSS CUSTOM PROPERTIES - RADIO GROUP
|
|
107
|
-
* ======================================== */
|
|
108
|
-
|
|
109
|
-
/* Group Layout */
|
|
110
|
-
--nuraly-radio-group-gap: 12px;
|
|
111
|
-
--nuraly-radio-group-horizontal-gap: 16px;
|
|
112
|
-
|
|
113
|
-
/* Colors - Error/Warning states */
|
|
114
|
-
--nuraly-radio-group-error-icon-color: var(--nuraly-color-radio-error-icon, #ef4444);
|
|
115
|
-
--nuraly-radio-group-error-text-color: var(--nuraly-color-radio-error-text, #ef4444);
|
|
116
|
-
--nuraly-radio-group-warning-icon-color: var(--nuraly-color-radio-warning-icon, #f59e0b);
|
|
117
|
-
--nuraly-radio-group-warning-text-color: var(--nuraly-color-radio-warning-text, #f59e0b);
|
|
118
|
-
|
|
119
|
-
/* Typography */
|
|
120
|
-
--nuraly-radio-group-font-family: var(--nuraly-font-family-radio, Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif);
|
|
121
|
-
--nuraly-radio-group-message-font-size: var(--nuraly-font-size-radio-message, 12px);
|
|
122
|
-
|
|
123
|
-
/* Button type styling */
|
|
124
|
-
--nuraly-radio-group-button-border-radius: 4px;
|
|
125
|
-
--nuraly-radio-group-button-hover-color: var(--nuraly-color-radio-border-hover, #7c3aed);
|
|
126
|
-
|
|
127
|
-
/* Slot container styling */
|
|
128
|
-
--nuraly-radio-group-slot-hover-bg: rgba(124, 58, 237, 0.04);
|
|
129
|
-
--nuraly-radio-group-slot-selected-bg: rgba(124, 58, 237, 0.08);
|
|
130
|
-
--nuraly-radio-group-slot-border-radius: 6px;
|
|
131
|
-
|
|
132
|
-
/* ========================================
|
|
133
|
-
* COMPONENT STYLES
|
|
134
|
-
* ======================================== */
|
|
135
|
-
|
|
136
|
-
width: fit-content;
|
|
137
|
-
display: block;
|
|
138
|
-
font-family: var(--nuraly-radio-group-font-family);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/* ========================================
|
|
142
|
-
* RADIO GROUP LAYOUT
|
|
143
|
-
* ======================================== */
|
|
144
|
-
|
|
145
|
-
.radio-group {
|
|
146
|
-
display: flex;
|
|
147
|
-
flex-direction: column;
|
|
148
|
-
gap: var(--nuraly-radio-group-gap);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.radio-group.horizontal {
|
|
152
|
-
flex-direction: row;
|
|
153
|
-
flex-wrap: wrap;
|
|
154
|
-
gap: var(--nuraly-radio-group-horizontal-gap);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.radio-wrapper {
|
|
158
|
-
display: flex;
|
|
159
|
-
flex-direction: column;
|
|
160
|
-
gap: 4px;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/* ========================================
|
|
164
|
-
* MESSAGE CONTAINERS (Error/Warning)
|
|
165
|
-
* ======================================== */
|
|
166
|
-
|
|
167
|
-
.radio-wrapper .message-container {
|
|
168
|
-
display: flex;
|
|
169
|
-
align-items: center;
|
|
170
|
-
gap: 6px;
|
|
171
|
-
font-size: var(--nuraly-radio-group-message-font-size);
|
|
172
|
-
padding-left: 28px; /* Align with radio label */
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
nr-icon {
|
|
176
|
-
display: flex;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
.radio-wrapper.error nr-icon {
|
|
180
|
-
--nuraly-icon-color: var(--nuraly-radio-group-error-icon-color);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
.radio-wrapper.warning nr-icon {
|
|
184
|
-
--nuraly-icon-color: var(--nuraly-radio-group-warning-icon-color);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
.radio-wrapper.error .message-container {
|
|
188
|
-
color: var(--nuraly-radio-group-error-text-color);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
.radio-wrapper.warning .message-container {
|
|
192
|
-
color: var(--nuraly-radio-group-warning-text-color);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/* ========================================
|
|
196
|
-
* BUTTON TYPE STYLING
|
|
197
|
-
* ======================================== */
|
|
198
|
-
|
|
199
|
-
.type-button {
|
|
200
|
-
display: inline-flex;
|
|
201
|
-
gap: 0px;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/* Button border radius for first and last child */
|
|
205
|
-
.type-button :first-child {
|
|
206
|
-
--nuraly-button-border-top-left-radius: var(--nuraly-radio-group-button-border-radius);
|
|
207
|
-
--nuraly-button-border-bottom-left-radius: var(--nuraly-radio-group-button-border-radius);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
.type-button :last-child {
|
|
211
|
-
--nuraly-button-border-top-right-radius: var(--nuraly-radio-group-button-border-radius);
|
|
212
|
-
--nuraly-button-border-bottom-right-radius: var(--nuraly-radio-group-button-border-radius);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
.type-button nr-button:not(:last-child) {
|
|
216
|
-
margin-right: -1px;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
.type-button nr-button {
|
|
220
|
-
position: relative;
|
|
221
|
-
z-index: 1;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
.type-button nr-button[type="default"]:hover {
|
|
225
|
-
--nuraly-button-color: var(--nuraly-radio-group-button-hover-color);
|
|
226
|
-
--nuraly-button-border-color: var(--nuraly-radio-group-button-hover-color);
|
|
227
|
-
z-index: 2;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
.type-button nr-button[type="primary"] {
|
|
231
|
-
z-index: 1;
|
|
232
|
-
position: relative;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/* Disabled button states */
|
|
236
|
-
.type-button nr-button[disabled] {
|
|
237
|
-
opacity: 0.6;
|
|
238
|
-
cursor: not-allowed;
|
|
239
|
-
pointer-events: none;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
.type-button nr-button[disabled]:hover {
|
|
243
|
-
z-index: auto;
|
|
244
|
-
--nuraly-button-border-color: var(--nuraly-button-disabled-border-color, var(--nuraly-button-local-disabled-border-color));
|
|
245
|
-
--nuraly-button-background-color: var(--nuraly-button-disabled-background-color, var(--nuraly-button-local-disabled-background-color));
|
|
246
|
-
--nuraly-button-color: var(--nuraly-button-disabled-text-color, var(--nuraly-button-local-disabled-text-color));
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
.type-button nr-button[type="primary"][disabled] {
|
|
250
|
-
--nuraly-button-background-color: var(--nuraly-button-primary-disabled-background-color, var(--nuraly-button-local-primary-disabled-background-color));
|
|
251
|
-
--nuraly-button-border-color: var(--nuraly-button-primary-disabled-border-color, var(--nuraly-button-local-primary-disabled-border-color));
|
|
252
|
-
--nuraly-button-color: var(--nuraly-button-primary-disabled-text-color, var(--nuraly-button-local-primary-disabled-text-color));
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
.type-button nr-button[type="primary"][disabled] nr-icon {
|
|
256
|
-
--nuraly-icon-color: var(--nuraly-button-primary-disabled-text-color, var(--nuraly-button-local-primary-disabled-text-color));
|
|
257
|
-
--nuraly-icon-local-color: var(--nuraly-button-primary-disabled-text-color, var(--nuraly-button-local-primary-disabled-text-color));
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/* ========================================
|
|
261
|
-
* SLOT-BASED RADIO STYLING
|
|
262
|
-
* ======================================== */
|
|
263
|
-
|
|
264
|
-
.slot-wrapper {
|
|
265
|
-
display: flex;
|
|
266
|
-
align-items: flex-start;
|
|
267
|
-
gap: 12px;
|
|
268
|
-
cursor: pointer;
|
|
269
|
-
transition: all 0.2s ease;
|
|
270
|
-
padding: 8px;
|
|
271
|
-
border-radius: var(--nuraly-radio-group-slot-border-radius);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
.slot-wrapper:hover {
|
|
275
|
-
background-color: var(--nuraly-radio-group-slot-hover-bg);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
.slot-wrapper nr-radio {
|
|
279
|
-
flex-shrink: 0;
|
|
280
|
-
margin-top: 2px;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
.slot-wrapper .slot-content {
|
|
284
|
-
flex: 1;
|
|
285
|
-
min-width: 0;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
.slot-container.selected .slot-wrapper {
|
|
289
|
-
background-color: var(--nuraly-radio-group-slot-selected-bg);
|
|
290
|
-
}
|
|
291
|
-
`;var si,ei,ri,oi,ni;!function(t){t.Horizontal="horizontal",t.Vertical="vertical"}(si||(si={})),function(t){t.Left="left",t.Right="right"}(ei||(ei={})),function(t){t.Default="default",t.Button="button",t.Slot="slot"}(ri||(ri={})),function(t){t.Small="small",t.Medium="medium",t.Large="large"}(oi||(oi={})),function(t){t.Default="default",t.Solid="solid"}(ni||(ni={}));
|
|
31
|
+
*/const y=t`:host{--nuraly-radio-group-gap:12px;--nuraly-radio-group-horizontal-gap:16px;--nuraly-radio-group-error-icon-color:var(--nuraly-color-radio-error-icon, #ef4444);--nuraly-radio-group-error-text-color:var(--nuraly-color-radio-error-text, #ef4444);--nuraly-radio-group-warning-icon-color:var(--nuraly-color-radio-warning-icon, #f59e0b);--nuraly-radio-group-warning-text-color:var(--nuraly-color-radio-warning-text, #f59e0b);--nuraly-radio-group-font-family:var(--nuraly-font-family-radio, Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif);--nuraly-radio-group-message-font-size:var(--nuraly-font-size-radio-message, 12px);--nuraly-radio-group-button-border-radius:4px;--nuraly-radio-group-button-hover-color:var(--nuraly-color-radio-border-hover, #7c3aed);--nuraly-radio-group-slot-hover-bg:rgba(124, 58, 237, 0.04);--nuraly-radio-group-slot-selected-bg:rgba(124, 58, 237, 0.08);--nuraly-radio-group-slot-border-radius:6px;width:fit-content;display:block;font-family:var(--nuraly-radio-group-font-family)}.radio-group{display:flex;flex-direction:column;gap:var(--nuraly-radio-group-gap)}.radio-group.horizontal{flex-direction:row;flex-wrap:wrap;gap:var(--nuraly-radio-group-horizontal-gap)}.radio-wrapper{display:flex;flex-direction:column;gap:4px}.radio-wrapper .message-container{display:flex;align-items:center;gap:6px;font-size:var(--nuraly-radio-group-message-font-size);padding-left:28px}nr-icon{display:flex}.radio-wrapper.error nr-icon{--nuraly-icon-color:var(--nuraly-radio-group-error-icon-color)}.radio-wrapper.warning nr-icon{--nuraly-icon-color:var(--nuraly-radio-group-warning-icon-color)}.radio-wrapper.error .message-container{color:var(--nuraly-radio-group-error-text-color)}.radio-wrapper.warning .message-container{color:var(--nuraly-radio-group-warning-text-color)}.type-button{display:inline-flex;gap:0}.type-button :first-child{--nuraly-button-border-top-left-radius:var(--nuraly-radio-group-button-border-radius);--nuraly-button-border-bottom-left-radius:var(--nuraly-radio-group-button-border-radius)}.type-button :last-child{--nuraly-button-border-top-right-radius:var(--nuraly-radio-group-button-border-radius);--nuraly-button-border-bottom-right-radius:var(--nuraly-radio-group-button-border-radius)}.type-button nr-button:not(:last-child){margin-right:-1px}.type-button nr-button{position:relative;z-index:1}.type-button nr-button[type=default]:hover{--nuraly-button-color:var(--nuraly-radio-group-button-hover-color);--nuraly-button-border-color:var(--nuraly-radio-group-button-hover-color);z-index:2}.type-button nr-button[type=primary]{z-index:1;position:relative}.type-button nr-button[disabled]{opacity:.6;cursor:not-allowed;pointer-events:none}.type-button nr-button[disabled]:hover{z-index:auto;--nuraly-button-border-color:var(--nuraly-button-disabled-border-color, var(--nuraly-button-local-disabled-border-color));--nuraly-button-background-color:var(--nuraly-button-disabled-background-color, var(--nuraly-button-local-disabled-background-color));--nuraly-button-color:var(--nuraly-button-disabled-text-color, var(--nuraly-button-local-disabled-text-color))}.type-button nr-button[type=primary][disabled]{--nuraly-button-background-color:var(--nuraly-button-primary-disabled-background-color, var(--nuraly-button-local-primary-disabled-background-color));--nuraly-button-border-color:var(--nuraly-button-primary-disabled-border-color, var(--nuraly-button-local-primary-disabled-border-color));--nuraly-button-color:var(--nuraly-button-primary-disabled-text-color, var(--nuraly-button-local-primary-disabled-text-color))}.type-button nr-button[type=primary][disabled] nr-icon{--nuraly-icon-color:var(--nuraly-button-primary-disabled-text-color, var(--nuraly-button-local-primary-disabled-text-color));--nuraly-icon-local-color:var(--nuraly-button-primary-disabled-text-color, var(--nuraly-button-local-primary-disabled-text-color))}.slot-wrapper{display:flex;align-items:flex-start;gap:12px;cursor:pointer;transition:all .2s ease;padding:8px;border-radius:var(--nuraly-radio-group-slot-border-radius)}.slot-wrapper:hover{background-color:var(--nuraly-radio-group-slot-hover-bg)}.slot-wrapper nr-radio{flex-shrink:0;margin-top:2px}.slot-wrapper .slot-content{flex:1;min-width:0}.slot-container.selected .slot-wrapper{background-color:var(--nuraly-radio-group-slot-selected-bg)}`;var g,v,m,f,$;!function(t){t.Horizontal="horizontal",t.Vertical="vertical"}(g||(g={})),function(t){t.Left="left",t.Right="right"}(v||(v={})),function(t){t.Default="default",t.Button="button",t.Slot="slot"}(m||(m={})),function(t){t.Small="small",t.Medium="medium",t.Large="large"}(f||(f={})),function(t){t.Default="default",t.Solid="solid"}($||($={}));
|
|
292
32
|
/**
|
|
293
33
|
* @license
|
|
294
34
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
295
35
|
* SPDX-License-Identifier: MIT
|
|
296
36
|
*/
|
|
297
|
-
var
|
|
298
|
-
<div
|
|
299
|
-
role="radiogroup"
|
|
300
|
-
aria-labelledby="radio-group-label"
|
|
301
|
-
class="radio-group ${this.direction}"
|
|
302
|
-
>
|
|
303
|
-
${this.options.map(((t,i)=>yt`
|
|
304
|
-
<div
|
|
305
|
-
class="${qt({"radio-wrapper":!0,error:"error"===t.state,warning:"warning"===t.state,[t.className||""]:Boolean(t.className)})}"
|
|
306
|
-
data-theme="${this.currentTheme}"
|
|
307
|
-
style="${t.style||""}"
|
|
308
|
-
title="${t.title||""}"
|
|
309
|
-
>
|
|
310
|
-
<nr-radio
|
|
311
|
-
id="${t.id||t.value}"
|
|
312
|
-
name="${this.name}"
|
|
313
|
-
value="${t.value}"
|
|
314
|
-
size="${this.size}"
|
|
315
|
-
?checked="${this.isOptionSelected(t)}"
|
|
316
|
-
?disabled="${this.isOptionDisabled(t)||this.disabled}"
|
|
317
|
-
?required="${this.required}"
|
|
318
|
-
tabindex="${this.isOptionSelected(t)?"0":"-1"}"
|
|
319
|
-
@change="${i=>{this.addRippleEffect(i),this.handleSelectionChange(t)}}"
|
|
320
|
-
@focus="${()=>this.setFocusedOption(i)}"
|
|
321
|
-
>
|
|
322
|
-
${t.label}
|
|
323
|
-
</nr-radio>
|
|
324
|
-
${t.state&&t.message?yt`<div class="message-container" id="${t.value}-message">
|
|
325
|
-
<nr-icon name="${"error"===t.state?"exclamation-circle":"warning"}"></nr-icon>
|
|
326
|
-
<span>${t.message}</span>
|
|
327
|
-
</div>`:$t}
|
|
328
|
-
</div>
|
|
329
|
-
`))}
|
|
330
|
-
</div>
|
|
331
|
-
`}renderOptionsWithButtons(){return yt`
|
|
332
|
-
<div
|
|
333
|
-
class="type-button"
|
|
334
|
-
role="radiogroup"
|
|
335
|
-
aria-labelledby="radio-group-label"
|
|
336
|
-
@keydown="${this.handleKeyDown}"
|
|
337
|
-
>
|
|
338
|
-
${this.options.map(((t,i)=>yt`
|
|
339
|
-
<nr-button
|
|
340
|
-
class="${this.isOptionSelected(t)?"selected":""}"
|
|
341
|
-
type="${this.isOptionSelected(t)?"primary":"default"}"
|
|
342
|
-
role="radio"
|
|
343
|
-
aria-checked="${this.isOptionSelected(t)}"
|
|
344
|
-
aria-describedby="${t.state&&t.message?`${t.value}-message`:$t}"
|
|
345
|
-
tabindex="${this.isOptionSelected(t)?"0":"-1"}"
|
|
346
|
-
.icon="${t.icon?[t.icon]:[]}"
|
|
347
|
-
.disabled="${this.isOptionDisabled(t)}"
|
|
348
|
-
@click="${()=>this.handleSelectionChange(t)}"
|
|
349
|
-
@focus="${()=>this.setFocusedOption(i)}"
|
|
350
|
-
>
|
|
351
|
-
${t.label}
|
|
352
|
-
</nr-button>
|
|
353
|
-
${t.state&&t.message?yt`<div class="message-container" id="${t.value}-message">
|
|
354
|
-
<nr-icon name="${"error"===t.state?"exclamation-circle":"warning"}"></nr-icon>
|
|
355
|
-
<span>${t.message}</span>
|
|
356
|
-
</div>`:$t}
|
|
357
|
-
`))}
|
|
358
|
-
</div>
|
|
359
|
-
`}renderOptionsWithSlots(){return yt`
|
|
360
|
-
<div
|
|
361
|
-
role="radiogroup"
|
|
362
|
-
aria-labelledby="radio-group-label"
|
|
363
|
-
class="radio-group slot-group ${this.direction}"
|
|
364
|
-
>
|
|
365
|
-
${this.options.map(((t,i)=>yt`
|
|
366
|
-
<div
|
|
367
|
-
class="${qt({"radio-wrapper":!0,"slot-container":!0,error:"error"===t.state,warning:"warning"===t.state,selected:this.isOptionSelected(t),[t.className||""]:Boolean(t.className)})}"
|
|
368
|
-
data-theme="${this.currentTheme}"
|
|
369
|
-
style="${t.style||""}"
|
|
370
|
-
title="${t.title||""}"
|
|
371
|
-
>
|
|
372
|
-
<div class="slot-wrapper" @click="${()=>this.handleSelectionChange(t)}">
|
|
373
|
-
<nr-radio
|
|
374
|
-
id="${t.id||t.value}"
|
|
375
|
-
name="${this.name}"
|
|
376
|
-
value="${t.value}"
|
|
377
|
-
size="${this.size}"
|
|
378
|
-
?checked="${this.isOptionSelected(t)}"
|
|
379
|
-
?disabled="${this.isOptionDisabled(t)||this.disabled}"
|
|
380
|
-
?required="${this.required}"
|
|
381
|
-
tabindex="${this.isOptionSelected(t)?"0":"-1"}"
|
|
382
|
-
@change="${i=>{this.addRippleEffect(i),this.handleSelectionChange(t)}}"
|
|
383
|
-
@focus="${()=>this.setFocusedOption(i)}"
|
|
384
|
-
>
|
|
385
|
-
</nr-radio>
|
|
386
|
-
<div class="slot-content">
|
|
387
|
-
<slot name="${t.value}"></slot>
|
|
388
|
-
</div>
|
|
389
|
-
</div>
|
|
390
|
-
${t.state&&t.message?yt`<div class="message-container" id="${t.value}-message">
|
|
391
|
-
<nr-icon name="${"error"===t.state?"exclamation-circle":"warning"}"></nr-icon>
|
|
392
|
-
<span>${t.message}</span>
|
|
393
|
-
</div>`:$t}
|
|
394
|
-
</div>
|
|
395
|
-
`))}
|
|
396
|
-
</div>
|
|
397
|
-
`}renderButtonsWithSlots(){return yt`
|
|
398
|
-
<div
|
|
399
|
-
class="type-button"
|
|
400
|
-
role="radiogroup"
|
|
401
|
-
aria-labelledby="radio-group-label"
|
|
402
|
-
@keydown="${this.handleKeyDown}"
|
|
403
|
-
>
|
|
404
|
-
${this.options.map(((t,i)=>yt`
|
|
405
|
-
<nr-button
|
|
406
|
-
class="${this.isOptionSelected(t)?"selected":""}"
|
|
407
|
-
type="${this.isOptionSelected(t)?"primary":"default"}"
|
|
408
|
-
role="radio"
|
|
409
|
-
aria-checked="${this.isOptionSelected(t)}"
|
|
410
|
-
aria-describedby="${t.state&&t.message?`${t.value}-message`:$t}"
|
|
411
|
-
tabindex="${this.isOptionSelected(t)?"0":"-1"}"
|
|
412
|
-
.disabled="${this.isOptionDisabled(t)}"
|
|
413
|
-
@click="${()=>this.handleSelectionChange(t)}"
|
|
414
|
-
@focus="${()=>this.setFocusedOption(i)}"
|
|
415
|
-
>
|
|
416
|
-
<slot name="${t.value}" slot="default"></slot>
|
|
417
|
-
</nr-button>
|
|
418
|
-
${t.state&&t.message?yt`<div class="message-container" id="${t.value}-message">
|
|
419
|
-
<nr-icon name="${"error"===t.state?"exclamation-circle":"warning"}"></nr-icon>
|
|
420
|
-
<span>${t.message}</span>
|
|
421
|
-
</div>`:$t}
|
|
422
|
-
`))}
|
|
423
|
-
</div>
|
|
424
|
-
`}render(){return yt`${((t,i,s)=>{for(const s of i)if(s[0]===t)return(0,s[1])();return null==s?void 0:s()})(this.type,[[ri.Default,()=>this.renderOptionDefault()],[ri.Button,()=>this.renderOptionsWithButtons()],[ri.Slot,()=>this.renderOptionsWithSlots()],["button-slot",()=>this.renderButtonsWithSlots()]])} `}};li.styles=ii,ai([Vt({type:Array})],li.prototype,"options",void 0),ai([Vt({type:String,attribute:"default-value"})],li.prototype,"defaultValue",void 0),ai([Vt({type:String})],li.prototype,"value",void 0),ai([Vt({type:String})],li.prototype,"name",void 0),ai([Vt({type:String})],li.prototype,"direction",void 0),ai([Vt({type:String})],li.prototype,"type",void 0),ai([Vt({type:Boolean})],li.prototype,"required",void 0),ai([Vt({type:Boolean})],li.prototype,"disabled",void 0),ai([Vt({type:String})],li.prototype,"size",void 0),ai([Vt({type:String})],li.prototype,"position",void 0),li=ai([(t=>i=>"function"==typeof i?((t,i)=>(customElements.define(t,i),i))(t,i):((t,i)=>{const{kind:s,elements:e}=i;return{kind:s,elements:e,finisher(i){customElements.define(t,i)}}})(t,i))("nr-radio-group")],li);export{li as NrRadioGroupElement,si as RadioButtonDirection,ei as RadioButtonPosition,oi as RadioButtonSize,ri as RadioButtonType,ni as RadioButtonVariant};
|
|
37
|
+
var x=function(t,r,i,o){for(var e,s=arguments.length,n=s<3?r:null===o?o=Object.getOwnPropertyDescriptor(r,i):o,a=t.length-1;a>=0;a--)(e=t[a])&&(n=(s<3?e(n):s>3?e(r,i,n):e(r,i))||n);return s>3&&n&&Object.defineProperty(r,i,n),n};let w=class extends(l(r)){constructor(){super(...arguments),this.requiredComponents=["nr-icon","nr-radio"],this.options=[],this.defaultValue="",this.value="",this.name="radioGroup",this.direction="vertical",this.type=m.Default,this.required=!1,this.disabled=!1,this.size="medium",this.position="left",this.groupController=new u(this),this.keyboardController=new c(this,this.groupController),this.focusController=new h(this),this.validationController=new p(this),this.rippleController=new b(this)}get selectedOption(){return this.groupController.getSelectedOption()}isOptionSelected(t){return this.groupController.isOptionSelected(t)}isOptionDisabled(t){return this.groupController.isOptionDisabled(t)}handleSelectionChange(t){this.groupController.selectOption(t)}setFocusedOption(t){this.focusController.setFocusedOption(t)}handleKeyDown(t){}addRippleEffect(t){this.rippleController.addRippleEffect(t)}validate(){return this.validationController.validate()}get validationMessage(){return this.validationController.validationMessage}get isValid(){return this.validationController.isValid}getFormData(){return this.validationController.getFormData()}reset(){this.validationController.reset()}get formData(){return this.validationController.getFormDataObject()}checkValidity(){return this.validate()}reportValidity(){return this.validationController.reportValidity()}focus(){this.focusController.focus()}blur(){this.focusController.blur()}renderOptionDefault(){return i`<div role="radiogroup" aria-labelledby="radio-group-label" class="radio-group ${this.direction}">${this.options.map(((t,r)=>i`<div class="${a({"radio-wrapper":!0,error:"error"===t.state,warning:"warning"===t.state,[t.className||""]:Boolean(t.className)})}" data-theme="${this.currentTheme}" style="${t.style||""}" title="${t.title||""}"><nr-radio id="${t.id||t.value}" name="${this.name}" value="${t.value}" size="${this.size}" ?checked="${this.isOptionSelected(t)}" ?disabled="${this.isOptionDisabled(t)||this.disabled}" ?required="${this.required}" tabindex="${this.isOptionSelected(t)?"0":"-1"}" @change="${r=>{this.addRippleEffect(r),this.handleSelectionChange(t)}}" @focus="${()=>this.setFocusedOption(r)}">${t.label}</nr-radio>${t.state&&t.message?i`<div class="message-container" id="${t.value}-message"><nr-icon name="${"error"===t.state?"exclamation-circle":"warning"}"></nr-icon><span>${t.message}</span></div>`:o}</div>`))}</div>`}renderOptionsWithButtons(){return i`<div class="type-button" role="radiogroup" aria-labelledby="radio-group-label" @keydown="${this.handleKeyDown}">${this.options.map(((t,r)=>i`<nr-button class="${this.isOptionSelected(t)?"selected":""}" type="${this.isOptionSelected(t)?"primary":"default"}" role="radio" aria-checked="${this.isOptionSelected(t)}" aria-describedby="${t.state&&t.message?`${t.value}-message`:o}" tabindex="${this.isOptionSelected(t)?"0":"-1"}" .icon="${t.icon?[t.icon]:[]}" .disabled="${this.isOptionDisabled(t)}" @click="${()=>this.handleSelectionChange(t)}" @focus="${()=>this.setFocusedOption(r)}">${t.label}</nr-button>${t.state&&t.message?i`<div class="message-container" id="${t.value}-message"><nr-icon name="${"error"===t.state?"exclamation-circle":"warning"}"></nr-icon><span>${t.message}</span></div>`:o}`))}</div>`}renderOptionsWithSlots(){return i`<div role="radiogroup" aria-labelledby="radio-group-label" class="radio-group slot-group ${this.direction}">${this.options.map(((t,r)=>i`<div class="${a({"radio-wrapper":!0,"slot-container":!0,error:"error"===t.state,warning:"warning"===t.state,selected:this.isOptionSelected(t),[t.className||""]:Boolean(t.className)})}" data-theme="${this.currentTheme}" style="${t.style||""}" title="${t.title||""}"><div class="slot-wrapper" @click="${()=>this.handleSelectionChange(t)}"><nr-radio id="${t.id||t.value}" name="${this.name}" value="${t.value}" size="${this.size}" ?checked="${this.isOptionSelected(t)}" ?disabled="${this.isOptionDisabled(t)||this.disabled}" ?required="${this.required}" tabindex="${this.isOptionSelected(t)?"0":"-1"}" @change="${r=>{this.addRippleEffect(r),this.handleSelectionChange(t)}}" @focus="${()=>this.setFocusedOption(r)}"></nr-radio><div class="slot-content"><slot name="${t.value}"></slot></div></div>${t.state&&t.message?i`<div class="message-container" id="${t.value}-message"><nr-icon name="${"error"===t.state?"exclamation-circle":"warning"}"></nr-icon><span>${t.message}</span></div>`:o}</div>`))}</div>`}renderButtonsWithSlots(){return i`<div class="type-button" role="radiogroup" aria-labelledby="radio-group-label" @keydown="${this.handleKeyDown}">${this.options.map(((t,r)=>i`<nr-button class="${this.isOptionSelected(t)?"selected":""}" type="${this.isOptionSelected(t)?"primary":"default"}" role="radio" aria-checked="${this.isOptionSelected(t)}" aria-describedby="${t.state&&t.message?`${t.value}-message`:o}" tabindex="${this.isOptionSelected(t)?"0":"-1"}" .disabled="${this.isOptionDisabled(t)}" @click="${()=>this.handleSelectionChange(t)}" @focus="${()=>this.setFocusedOption(r)}"><slot name="${t.value}" slot="default"></slot></nr-button>${t.state&&t.message?i`<div class="message-container" id="${t.value}-message"><nr-icon name="${"error"===t.state?"exclamation-circle":"warning"}"></nr-icon><span>${t.message}</span></div>`:o}`))}</div>`}render(){return i`${n(this.type,[[m.Default,()=>this.renderOptionDefault()],[m.Button,()=>this.renderOptionsWithButtons()],[m.Slot,()=>this.renderOptionsWithSlots()],["button-slot",()=>this.renderButtonsWithSlots()]])}`}};w.styles=y,x([e({type:Array})],w.prototype,"options",void 0),x([e({type:String,attribute:"default-value"})],w.prototype,"defaultValue",void 0),x([e({type:String})],w.prototype,"value",void 0),x([e({type:String})],w.prototype,"name",void 0),x([e({type:String})],w.prototype,"direction",void 0),x([e({type:String})],w.prototype,"type",void 0),x([e({type:Boolean})],w.prototype,"required",void 0),x([e({type:Boolean})],w.prototype,"disabled",void 0),x([e({type:String})],w.prototype,"size",void 0),x([e({type:String})],w.prototype,"position",void 0),w=x([s("nr-radio-group")],w);export{w as NrRadioGroupElement,g as RadioButtonDirection,v as RadioButtonPosition,f as RadioButtonSize,m as RadioButtonType,$ as RadioButtonVariant};
|