@nuralyui/input 0.0.13 → 0.0.15
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 +49 -98
- package/package.json +1 -1
package/bundle.js
CHANGED
|
@@ -1,53 +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,r=Symbol(),e=new WeakMap;class n{constructor(t,i,e){if(this._$cssResult$=!0,e!==r)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o;const r=this.t;if(i&&void 0===t){const i=void 0!==r&&1===r.length;i&&(t=e.get(r)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&e.set(r,t))}return t}toString(){return this.cssText}}const a=(t,...i)=>{const e=1===t.length?t[0]:i.reduce(((i,r,e)=>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.")})(r)+t[e+1]),t[0]);return new n(e,t,r)},o=i?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let i="";for(const r of t.cssRules)i+=r.cssText;return(t=>new n("string"==typeof t?t:t+"",void 0,r))(i)})(t):t
|
|
7
|
-
/**
|
|
8
|
-
* @license
|
|
9
|
-
* Copyright 2017 Google LLC
|
|
10
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
-
*/;var s;const l=window,d=l.trustedTypes,u=d?d.emptyScript:"",h=l.reactiveElementPolyfillSupport,c={toAttribute(t,i){switch(i){case Boolean:t=t?u:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,i){let r=t;switch(i){case Boolean:r=null!==t;break;case Number:r=null===t?null:Number(t);break;case Object:case Array:try{r=JSON.parse(t)}catch(t){r=null}}return r}},p=(t,i)=>i!==t&&(i==i||t==t),v={attribute:!0,type:String,converter:c,reflect:!1,hasChanged:p},f="finalized";class g 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,r)=>{const e=this._$Ep(r,i);void 0!==e&&(this._$Ev.set(e,r),t.push(e))})),t}static createProperty(t,i=v){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){const r="symbol"==typeof t?Symbol():"__"+t,e=this.getPropertyDescriptor(t,r,i);void 0!==e&&Object.defineProperty(this.prototype,t,e)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(e){const n=this[t];this[i]=e,this.requestUpdate(t,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||v}static finalize(){if(this.hasOwnProperty(f))return!1;this[f]=!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 r of i)this.createProperty(r,t[r])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const i=[];if(Array.isArray(t)){const r=new Set(t.flat(1/0).reverse());for(const t of r)i.unshift(o(t))}else void 0!==t&&i.push(o(t));return i}static _$Ep(t,i){const r=i.attribute;return!1===r?void 0:"string"==typeof r?r:"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,r;(null!==(i=this._$ES)&&void 0!==i?i:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(r=t.hostConnected)||void 0===r||r.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 r;const e=null!==(r=this.shadowRoot)&&void 0!==r?r:this.attachShadow(this.constructor.shadowRootOptions);return((r,e)=>{i?r.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((i=>{const e=document.createElement("style"),n=t.litNonce;void 0!==n&&e.setAttribute("nonce",n),e.textContent=i.cssText,r.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,r){this._$AK(t,r)}_$EO(t,i,r=v){var e;const n=this.constructor._$Ep(t,r);if(void 0!==n&&!0===r.reflect){const a=(void 0!==(null===(e=r.converter)||void 0===e?void 0:e.toAttribute)?r.converter:c).toAttribute(i,r.type);this._$El=t,null==a?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(t,i){var r;const e=this.constructor,n=e._$Ev.get(t);if(void 0!==n&&this._$El!==n){const t=e.getPropertyOptions(n),a="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(r=t.converter)||void 0===r?void 0:r.fromAttribute)?t.converter:c;this._$El=n,this[n]=a.fromAttribute(i,t.type),this._$El=null}}requestUpdate(t,i,r){let e=!0;void 0!==t&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||p)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),!0===r.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,r))):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 r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),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(r)):this._$Ek()}catch(t){throw i=!1,this._$Ek(),t}i&&this._$AE(r)}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;g[f]=!0,g.elementProperties=new Map,g.elementStyles=[],g.shadowRootOptions={mode:"open"},null==h||h({ReactiveElement:g}),(null!==(s=l.reactiveElementVersions)&&void 0!==s?s:l.reactiveElementVersions=[]).push("1.6.3");const y=window,b=y.trustedTypes,w=b?b.createPolicy("lit-html",{createHTML:t=>t}):void 0,x="$lit$",$=`lit$${(Math.random()+"").slice(9)}$`,A="?"+$,S=`<${A}>`,k=document,E=()=>k.createComment(""),V=t=>null===t||"object"!=typeof t&&"function"!=typeof t,C=Array.isArray,N="[ \t\n\f\r]",z=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,T=/-->/g,I=/>/g,P=RegExp(`>|${N}(?:([^\\s"'>=/]+)(${N}*=${N}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),R=/'/g,_=/"/g,M=/^(?:script|style|textarea|title)$/i,O=Symbol.for("lit-noChange"),D=Symbol.for("lit-nothing"),U=new WeakMap,j=k.createTreeWalker(k,129,null,!1);function L(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==w?w.createHTML(i):i}class B{constructor({strings:t,_$litType$:i},r){let e;this.parts=[];let n=0,a=0;const o=t.length-1,s=this.parts,[l,d]=((t,i)=>{const r=t.length-1,e=[];let n,a=2===i?"<svg>":"",o=z;for(let i=0;i<r;i++){const r=t[i];let s,l,d=-1,u=0;for(;u<r.length&&(o.lastIndex=u,l=o.exec(r),null!==l);)u=o.lastIndex,o===z?"!--"===l[1]?o=T:void 0!==l[1]?o=I:void 0!==l[2]?(M.test(l[2])&&(n=RegExp("</"+l[2],"g")),o=P):void 0!==l[3]&&(o=P):o===P?">"===l[0]?(o=null!=n?n:z,d=-1):void 0===l[1]?d=-2:(d=o.lastIndex-l[2].length,s=l[1],o=void 0===l[3]?P:'"'===l[3]?_:R):o===_||o===R?o=P:o===T||o===I?o=z:(o=P,n=void 0);const h=o===P&&t[i+1].startsWith("/>")?" ":"";a+=o===z?r+S:d>=0?(e.push(s),r.slice(0,d)+x+r.slice(d)+$+h):r+$+(-2===d?(e.push(void 0),i):h)}return[L(t,a+(t[r]||"<?>")+(2===i?"</svg>":"")),e]})(t,i);if(this.el=B.createElement(l,r),j.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(e=j.nextNode())&&s.length<o;){if(1===e.nodeType){if(e.hasAttributes()){const t=[];for(const i of e.getAttributeNames())if(i.endsWith(x)||i.startsWith($)){const r=d[a++];if(t.push(i),void 0!==r){const t=e.getAttribute(r.toLowerCase()+x).split($),i=/([.?@])?(.*)/.exec(r);s.push({type:1,index:n,name:i[2],strings:t,ctor:"."===i[1]?Z:"?"===i[1]?Y:"@"===i[1]?G:q})}else s.push({type:6,index:n})}for(const i of t)e.removeAttribute(i)}if(M.test(e.tagName)){const t=e.textContent.split($),i=t.length-1;if(i>0){e.textContent=b?b.emptyScript:"";for(let r=0;r<i;r++)e.append(t[r],E()),j.nextNode(),s.push({type:2,index:++n});e.append(t[i],E())}}}else if(8===e.nodeType)if(e.data===A)s.push({type:2,index:n});else{let t=-1;for(;-1!==(t=e.data.indexOf($,t+1));)s.push({type:7,index:n}),t+=$.length-1}n++}}static createElement(t,i){const r=k.createElement("template");return r.innerHTML=t,r}}function F(t,i,r=t,e){var n,a,o,s;if(i===O)return i;let l=void 0!==e?null===(n=r._$Co)||void 0===n?void 0:n[e]:r._$Cl;const d=V(i)?void 0:i._$litDirective$;return(null==l?void 0:l.constructor)!==d&&(null===(a=null==l?void 0:l._$AO)||void 0===a||a.call(l,!1),void 0===d?l=void 0:(l=new d(t),l._$AT(t,r,e)),void 0!==e?(null!==(o=(s=r)._$Co)&&void 0!==o?o:s._$Co=[])[e]=l:r._$Cl=l),void 0!==l&&(i=F(t,l._$AS(t,i.values),l,e)),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:r},parts:e}=this._$AD,n=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:k).importNode(r,!0);j.currentNode=n;let a=j.nextNode(),o=0,s=0,l=e[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new W(a,a.nextSibling,this,t):1===l.type?i=new l.ctor(a,l.name,l.strings,this,t):6===l.type&&(i=new J(a,this,t)),this._$AV.push(i),l=e[++s]}o!==(null==l?void 0:l.index)&&(a=j.nextNode(),o++)}return j.currentNode=k,n}v(t){let i=0;for(const r of this._$AV)void 0!==r&&(void 0!==r.strings?(r._$AI(t,r,i),i+=r.strings.length-2):r._$AI(t[i])),i++}}class W{constructor(t,i,r,e){var n;this.type=2,this._$AH=D,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=r,this.options=e,this._$Cp=null===(n=null==e?void 0:e.isConnected)||void 0===n||n}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),V(t)?t===D||null==t||""===t?(this._$AH!==D&&this._$AR(),this._$AH=D):t!==this._$AH&&t!==O&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>C(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&&V(this._$AH)?this._$AA.nextSibling.data=t:this.$(k.createTextNode(t)),this._$AH=t}g(t){var i;const{values:r,_$litType$:e}=t,n="number"==typeof e?this._$AC(t):(void 0===e.el&&(e.el=B.createElement(L(e.h,e.h[0]),this.options)),e);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===n)this._$AH.v(r);else{const t=new H(n,this),i=t.u(this.options);t.v(r),this.$(i),this._$AH=t}}_$AC(t){let i=U.get(t.strings);return void 0===i&&U.set(t.strings,i=new B(t)),i}T(t){C(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let r,e=0;for(const n of t)e===i.length?i.push(r=new W(this.k(E()),this.k(E()),this,this.options)):r=i[e],r._$AI(n),e++;e<i.length&&(this._$AR(r&&r._$AB.nextSibling,e),i.length=e)}_$AR(t=this._$AA.nextSibling,i){var r;for(null===(r=this._$AP)||void 0===r||r.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,r,e,n){this.type=1,this._$AH=D,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=n,r.length>2||""!==r[0]||""!==r[1]?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=D}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,r,e){const n=this.strings;let a=!1;if(void 0===n)t=F(this,t,i,0),a=!V(t)||t!==this._$AH&&t!==O,a&&(this._$AH=t);else{const e=t;let o,s;for(t=n[0],o=0;o<n.length-1;o++)s=F(this,e[r+o],i,o),s===O&&(s=this._$AH[o]),a||(a=!V(s)||s!==this._$AH[o]),s===D?t=D:t!==D&&(t+=(null!=s?s:"")+n[o+1]),this._$AH[o]=s}a&&!e&&this.j(t)}j(t){t===D?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class Z extends q{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===D?void 0:t}}const K=b?b.emptyScript:"";class Y extends q{constructor(){super(...arguments),this.type=4}j(t){t&&t!==D?this.element.setAttribute(this.name,K):this.element.removeAttribute(this.name)}}class G extends q{constructor(t,i,r,e,n){super(t,i,r,e,n),this.type=5}_$AI(t,i=this){var r;if((t=null!==(r=F(this,t,i,0))&&void 0!==r?r:D)===O)return;const e=this._$AH,n=t===D&&e!==D||t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive,a=t!==D&&(e===D||n);n&&this.element.removeEventListener(this.name,this,e),a&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,r;"function"==typeof this._$AH?this._$AH.call(null!==(r=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==r?r:this.element,t):this._$AH.handleEvent(t)}}class J{constructor(t,i,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){F(this,t)}}const X=y.litHtmlPolyfillSupport;
|
|
18
|
-
/**
|
|
19
|
-
* @license
|
|
20
|
-
* Copyright 2017 Google LLC
|
|
21
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
|
-
*/
|
|
23
|
-
var Q;null==X||X(B,W),(null!==(m=y.litHtmlVersions)&&void 0!==m?m:y.litHtmlVersions=[]).push("2.8.0");const tt=window,it=tt.trustedTypes,rt=it?it.createPolicy("lit-html",{createHTML:t=>t}):void 0,et="$lit$",nt=`lit$${(Math.random()+"").slice(9)}$`,at="?"+nt,ot=`<${at}>`,st=document,lt=()=>st.createComment(""),dt=t=>null===t||"object"!=typeof t&&"function"!=typeof t,ut=Array.isArray,ht="[ \t\n\f\r]",ct=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,pt=/-->/g,vt=/>/g,ft=RegExp(`>|${ht}(?:([^\\s"'>=/]+)(${ht}*=${ht}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),gt=/'/g,mt=/"/g,yt=/^(?:script|style|textarea|title)$/i,bt=(t=>(i,...r)=>({_$litType$:t,strings:i,values:r}))(1),wt=Symbol.for("lit-noChange"),xt=Symbol.for("lit-nothing"),$t=new WeakMap,At=st.createTreeWalker(st,129,null,!1);function St(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==rt?rt.createHTML(i):i}const kt=(t,i)=>{const r=t.length-1,e=[];let n,a=2===i?"<svg>":"",o=ct;for(let i=0;i<r;i++){const r=t[i];let s,l,d=-1,u=0;for(;u<r.length&&(o.lastIndex=u,l=o.exec(r),null!==l);)u=o.lastIndex,o===ct?"!--"===l[1]?o=pt:void 0!==l[1]?o=vt:void 0!==l[2]?(yt.test(l[2])&&(n=RegExp("</"+l[2],"g")),o=ft):void 0!==l[3]&&(o=ft):o===ft?">"===l[0]?(o=null!=n?n:ct,d=-1):void 0===l[1]?d=-2:(d=o.lastIndex-l[2].length,s=l[1],o=void 0===l[3]?ft:'"'===l[3]?mt:gt):o===mt||o===gt?o=ft:o===pt||o===vt?o=ct:(o=ft,n=void 0);const h=o===ft&&t[i+1].startsWith("/>")?" ":"";a+=o===ct?r+ot:d>=0?(e.push(s),r.slice(0,d)+et+r.slice(d)+nt+h):r+nt+(-2===d?(e.push(void 0),i):h)}return[St(t,a+(t[r]||"<?>")+(2===i?"</svg>":"")),e]};class Et{constructor({strings:t,_$litType$:i},r){let e;this.parts=[];let n=0,a=0;const o=t.length-1,s=this.parts,[l,d]=kt(t,i);if(this.el=Et.createElement(l,r),At.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(e=At.nextNode())&&s.length<o;){if(1===e.nodeType){if(e.hasAttributes()){const t=[];for(const i of e.getAttributeNames())if(i.endsWith(et)||i.startsWith(nt)){const r=d[a++];if(t.push(i),void 0!==r){const t=e.getAttribute(r.toLowerCase()+et).split(nt),i=/([.?@])?(.*)/.exec(r);s.push({type:1,index:n,name:i[2],strings:t,ctor:"."===i[1]?Tt:"?"===i[1]?Pt:"@"===i[1]?Rt:zt})}else s.push({type:6,index:n})}for(const i of t)e.removeAttribute(i)}if(yt.test(e.tagName)){const t=e.textContent.split(nt),i=t.length-1;if(i>0){e.textContent=it?it.emptyScript:"";for(let r=0;r<i;r++)e.append(t[r],lt()),At.nextNode(),s.push({type:2,index:++n});e.append(t[i],lt())}}}else if(8===e.nodeType)if(e.data===at)s.push({type:2,index:n});else{let t=-1;for(;-1!==(t=e.data.indexOf(nt,t+1));)s.push({type:7,index:n}),t+=nt.length-1}n++}}static createElement(t,i){const r=st.createElement("template");return r.innerHTML=t,r}}function Vt(t,i,r=t,e){var n,a,o,s;if(i===wt)return i;let l=void 0!==e?null===(n=r._$Co)||void 0===n?void 0:n[e]:r._$Cl;const d=dt(i)?void 0:i._$litDirective$;return(null==l?void 0:l.constructor)!==d&&(null===(a=null==l?void 0:l._$AO)||void 0===a||a.call(l,!1),void 0===d?l=void 0:(l=new d(t),l._$AT(t,r,e)),void 0!==e?(null!==(o=(s=r)._$Co)&&void 0!==o?o:s._$Co=[])[e]=l:r._$Cl=l),void 0!==l&&(i=Vt(t,l._$AS(t,i.values),l,e)),i}class Ct{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:r},parts:e}=this._$AD,n=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:st).importNode(r,!0);At.currentNode=n;let a=At.nextNode(),o=0,s=0,l=e[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new Nt(a,a.nextSibling,this,t):1===l.type?i=new l.ctor(a,l.name,l.strings,this,t):6===l.type&&(i=new _t(a,this,t)),this._$AV.push(i),l=e[++s]}o!==(null==l?void 0:l.index)&&(a=At.nextNode(),o++)}return At.currentNode=st,n}v(t){let i=0;for(const r of this._$AV)void 0!==r&&(void 0!==r.strings?(r._$AI(t,r,i),i+=r.strings.length-2):r._$AI(t[i])),i++}}class Nt{constructor(t,i,r,e){var n;this.type=2,this._$AH=xt,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=r,this.options=e,this._$Cp=null===(n=null==e?void 0:e.isConnected)||void 0===n||n}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=Vt(this,t,i),dt(t)?t===xt||null==t||""===t?(this._$AH!==xt&&this._$AR(),this._$AH=xt):t!==this._$AH&&t!==wt&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>ut(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!==xt&&dt(this._$AH)?this._$AA.nextSibling.data=t:this.$(st.createTextNode(t)),this._$AH=t}g(t){var i;const{values:r,_$litType$:e}=t,n="number"==typeof e?this._$AC(t):(void 0===e.el&&(e.el=Et.createElement(St(e.h,e.h[0]),this.options)),e);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===n)this._$AH.v(r);else{const t=new Ct(n,this),i=t.u(this.options);t.v(r),this.$(i),this._$AH=t}}_$AC(t){let i=$t.get(t.strings);return void 0===i&&$t.set(t.strings,i=new Et(t)),i}T(t){ut(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let r,e=0;for(const n of t)e===i.length?i.push(r=new Nt(this.k(lt()),this.k(lt()),this,this.options)):r=i[e],r._$AI(n),e++;e<i.length&&(this._$AR(r&&r._$AB.nextSibling,e),i.length=e)}_$AR(t=this._$AA.nextSibling,i){var r;for(null===(r=this._$AP)||void 0===r||r.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 zt{constructor(t,i,r,e,n){this.type=1,this._$AH=xt,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=n,r.length>2||""!==r[0]||""!==r[1]?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=xt}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,r,e){const n=this.strings;let a=!1;if(void 0===n)t=Vt(this,t,i,0),a=!dt(t)||t!==this._$AH&&t!==wt,a&&(this._$AH=t);else{const e=t;let o,s;for(t=n[0],o=0;o<n.length-1;o++)s=Vt(this,e[r+o],i,o),s===wt&&(s=this._$AH[o]),a||(a=!dt(s)||s!==this._$AH[o]),s===xt?t=xt:t!==xt&&(t+=(null!=s?s:"")+n[o+1]),this._$AH[o]=s}a&&!e&&this.j(t)}j(t){t===xt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class Tt extends zt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===xt?void 0:t}}const It=it?it.emptyScript:"";class Pt extends zt{constructor(){super(...arguments),this.type=4}j(t){t&&t!==xt?this.element.setAttribute(this.name,It):this.element.removeAttribute(this.name)}}class Rt extends zt{constructor(t,i,r,e,n){super(t,i,r,e,n),this.type=5}_$AI(t,i=this){var r;if((t=null!==(r=Vt(this,t,i,0))&&void 0!==r?r:xt)===wt)return;const e=this._$AH,n=t===xt&&e!==xt||t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive,a=t!==xt&&(e===xt||n);n&&this.element.removeEventListener(this.name,this,e),a&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,r;"function"==typeof this._$AH?this._$AH.call(null!==(r=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==r?r:this.element,t):this._$AH.handleEvent(t)}}class _t{constructor(t,i,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){Vt(this,t)}}const Mt=tt.litHtmlPolyfillSupport;null==Mt||Mt(Et,Nt),(null!==(Q=tt.litHtmlVersions)&&void 0!==Q?Q:tt.litHtmlVersions=[]).push("2.8.0");
|
|
24
|
-
/**
|
|
25
|
-
* @license
|
|
26
|
-
* Copyright 2017 Google LLC
|
|
27
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
28
|
-
*/
|
|
29
|
-
var Ot,Dt;class Ut extends g{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,i;const r=super.createRenderRoot();return null!==(t=(i=this.renderOptions).renderBefore)&&void 0!==t||(i.renderBefore=r.firstChild),r}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,i,r)=>{var e,n;const a=null!==(e=null==r?void 0:r.renderBefore)&&void 0!==e?e:i;let o=a._$litPart$;if(void 0===o){const t=null!==(n=null==r?void 0:r.renderBefore)&&void 0!==n?n:null;a._$litPart$=o=new Nt(i.insertBefore(lt(),t),t,void 0,null!=r?r:{})}return o._$AI(t),o})(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 wt}}Ut.finalized=!0,Ut._$litElement$=!0,null===(Ot=globalThis.litElementHydrateSupport)||void 0===Ot||Ot.call(globalThis,{LitElement:Ut});const jt=globalThis.litElementPolyfillSupport;null==jt||jt({LitElement:Ut}),(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 Lt=(t,i)=>"method"===i.kind&&i.descriptor&&!("value"in i.descriptor)?{...i,finisher(r){r.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(r){r.createProperty(i.key,t)}},Bt=(t,i,r)=>{i.constructor.createProperty(r,t)};
|
|
36
|
-
/**
|
|
37
|
-
* @license
|
|
38
|
-
* Copyright 2017 Google LLC
|
|
39
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
40
|
-
*/function Ft(t){return(i,r)=>void 0!==r?Bt(t,i,r):Lt(t,i)
|
|
41
|
-
/**
|
|
42
|
-
* @license
|
|
43
|
-
* Copyright 2017 Google LLC
|
|
44
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
45
|
-
*/}function Ht(t){return Ft({...t,state:!0})}
|
|
46
|
-
/**
|
|
47
|
-
* @license
|
|
48
|
-
* Copyright 2021 Google LLC
|
|
49
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
50
|
-
*/var Wt;null===(Wt=window.HTMLSlotElement)||void 0===Wt||Wt.prototype.assignedElements;const qt=[a`
|
|
1
|
+
import{css as t,html as r,nothing as i,LitElement as n}from"lit";import{property as a,state as e,customElement as o}from"lit/decorators.js";import{NuralyUIBaseMixin as s}from"@nuralyui/common/mixins";const l=[t`
|
|
51
2
|
/*
|
|
52
3
|
* Host element base styles
|
|
53
4
|
* Container for the input component with flexible layout
|
|
@@ -674,7 +625,7 @@ const Lt=(t,i)=>"method"===i.kind&&i.descriptor&&!("value"in i.descriptor)?{...i
|
|
|
674
625
|
opacity: var(--nuraly-input-disabled-icon-opacity, var(--nuraly-disabled-icon-opacity));
|
|
675
626
|
color: var(--nuraly-input-disabled-prefix-suffix-color, var(--nuraly-disabled-prefix-suffix-color));
|
|
676
627
|
}
|
|
677
|
-
`,
|
|
628
|
+
`,t`
|
|
678
629
|
/* ========================================
|
|
679
630
|
* SIZE VARIATIONS
|
|
680
631
|
* ======================================== */
|
|
@@ -868,79 +819,79 @@ const Lt=(t,i)=>"method"===i.kind&&i.descriptor&&!("value"in i.descriptor)?{...i
|
|
|
868
819
|
}
|
|
869
820
|
}
|
|
870
821
|
*/
|
|
871
|
-
`],
|
|
822
|
+
`],d={EMAIL:/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,URL:/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/,PHONE:/^[\+]?[1-9][\d]{0,15}$/,PASSWORD_STRONG:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/,ALPHANUMERIC:/^[a-zA-Z0-9]+$/,NUMERIC:/^\d+$/,ALPHA:/^[a-zA-Z]+$/,USERNAME:/^[a-zA-Z0-9_-]{3,16}$/,HEX_COLOR:/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,IPV4:/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,CREDIT_CARD:/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|3[0-9]{13}|6(?:011|5[0-9]{2})[0-9]{12})$/},u=t=>({required:!0,message:t||"This field is required"}),c=t=>({type:"email",pattern:d.EMAIL,message:t||"Please enter a valid email address"}),p=t=>({type:"url",pattern:d.URL,message:t||"Please enter a valid URL"}),h=(t,r)=>({maxLength:t,message:r||`Maximum length is ${t} characters`}),v=(t,r)=>({type:"number",min:t,message:r||`Minimum value is ${t}`}),m=(t,r)=>({type:"number",max:t,message:r||`Maximum value is ${t}`});
|
|
872
823
|
/**
|
|
873
824
|
* @license
|
|
874
825
|
* Copyright 2023 Google Laabidi Aymen
|
|
875
826
|
* SPDX-License-Identifier: MIT
|
|
876
827
|
*/
|
|
877
|
-
class
|
|
828
|
+
class b{static validateNumericProperties(t,r,i,n){"number"===t&&(r&&isNaN(Number(r))&&console.warn(`Invalid min value: "${r}" is not a valid number`),i&&isNaN(Number(i))&&console.warn(`Invalid max value: "${i}" is not a valid number`),n&&isNaN(Number(n))&&console.warn(`Invalid step value: "${n}" is not a valid number`),r&&i&&Number(r)>=Number(i)&&console.warn(`Invalid range: min value (${r}) should be less than max value (${i})`))}static preventNonNumericInput(t,r){const i=t.key,n=t.target,a=n.value,e=n.selectionStart||0;if(!(t.ctrlKey||t.metaKey||["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(i)||/^\d$/.test(i))){if("."===i||","===i){if(!(a.includes(".")||a.includes(",")))return}if("-"===i){const t=a.includes("-"),i=!r||Number(r)<0;if(!t&&0===e&&i)return}if("+"===i){if(!a.includes("+")&&0===e)return}t.preventDefault()}}static validateNumericValue(t,r,i){const n=[];if(!t)return{isValid:!0,warnings:n};const a=Number(t);return isNaN(a)?{isValid:!1,warnings:[`Invalid numeric value: "${t}"`]}:(r&&a<Number(r)&&n.push(`Value ${a} is below minimum ${r}`),i&&a>Number(i)&&n.push(`Value ${a} is above maximum ${i}`),{isValid:!0,warnings:n})}}
|
|
878
829
|
/**
|
|
879
830
|
* @license
|
|
880
831
|
* Copyright 2023 Google Laabidi Aymen
|
|
881
832
|
* SPDX-License-Identifier: MIT
|
|
882
|
-
*/class
|
|
833
|
+
*/class y{static renderPrefix(){return r`
|
|
883
834
|
<div class="input-prefix">
|
|
884
835
|
<slot name="prefix"></slot>
|
|
885
836
|
</div>
|
|
886
|
-
`}static renderSuffix(){return
|
|
837
|
+
`}static renderSuffix(){return r`
|
|
887
838
|
<div class="input-suffix">
|
|
888
839
|
<slot name="suffix"></slot>
|
|
889
840
|
</div>
|
|
890
|
-
`}static renderAddonBefore(t,
|
|
841
|
+
`}static renderAddonBefore(t,n){return t?r`
|
|
891
842
|
<div class="input-addon-before">
|
|
892
|
-
<slot name="addon-before" @slotchange=${
|
|
843
|
+
<slot name="addon-before" @slotchange=${n}></slot>
|
|
893
844
|
</div>
|
|
894
|
-
`:
|
|
845
|
+
`:i}static renderAddonAfter(t,n){return t?r`
|
|
895
846
|
<div class="input-addon-after">
|
|
896
|
-
<slot name="addon-after" @slotchange=${
|
|
847
|
+
<slot name="addon-after" @slotchange=${n}></slot>
|
|
897
848
|
</div>
|
|
898
|
-
`:
|
|
849
|
+
`:i}static renderCopyIcon(t,n,a,e,o){return t?r`<nr-icon
|
|
899
850
|
name="copy"
|
|
900
851
|
type="regular"
|
|
901
852
|
id="copy-icon"
|
|
902
853
|
role="button"
|
|
903
854
|
aria-label="Copy input value"
|
|
904
855
|
tabindex="0"
|
|
905
|
-
@click=${
|
|
906
|
-
@keydown=${
|
|
907
|
-
></nr-icon>`:
|
|
856
|
+
@click=${n||a?i:e}
|
|
857
|
+
@keydown=${o}
|
|
858
|
+
></nr-icon>`:i}static renderClearIcon(t,n,a,e,o,s){return!t||!n||a||e?i:r`<nr-icon
|
|
908
859
|
name="times-circle"
|
|
909
860
|
type="regular"
|
|
910
861
|
id="clear-icon"
|
|
911
862
|
role="button"
|
|
912
863
|
aria-label="Clear input value"
|
|
913
864
|
tabindex="0"
|
|
914
|
-
@click=${
|
|
915
|
-
@keydown=${
|
|
916
|
-
></nr-icon>`}static renderStateIcon(t){switch(t){case"warning":return
|
|
865
|
+
@click=${o}
|
|
866
|
+
@keydown=${s}
|
|
867
|
+
></nr-icon>`}static renderStateIcon(t){switch(t){case"warning":return r`<nr-icon name="warning" id="warning-icon"></nr-icon>`;case"error":return r`<nr-icon name="exclamation-circle" id="error-icon"></nr-icon>`;default:return i}}static renderCalendarIcon(t,n){return"default"!==t||"calendar"!==n?i:r`<nr-icon name="calendar" type="regular" id="calendar-icon"></nr-icon>`}static renderPasswordIcon(t,n,a,e,o,s){return"password"!==t?i:"text"===n?r`<nr-icon
|
|
917
868
|
name="eye-slash"
|
|
918
869
|
type="regular"
|
|
919
870
|
id="password-icon"
|
|
920
871
|
role="button"
|
|
921
872
|
aria-label="Hide password"
|
|
922
873
|
tabindex="0"
|
|
923
|
-
@click=${
|
|
924
|
-
@keydown=${
|
|
925
|
-
></nr-icon>`:
|
|
874
|
+
@click=${a||e?i:o}
|
|
875
|
+
@keydown=${s}
|
|
876
|
+
></nr-icon>`:r`<nr-icon
|
|
926
877
|
name="eye"
|
|
927
878
|
type="regular"
|
|
928
879
|
id="password-icon"
|
|
929
880
|
role="button"
|
|
930
881
|
aria-label="Show password"
|
|
931
882
|
tabindex="0"
|
|
932
|
-
@click=${
|
|
933
|
-
@keydown=${
|
|
934
|
-
></nr-icon>`}static renderNumberIcons(t,
|
|
883
|
+
@click=${a||e?i:o}
|
|
884
|
+
@keydown=${s}
|
|
885
|
+
></nr-icon>`}static renderNumberIcons(t,n,a,e,o,s,l){return"number"!==t?i:r`
|
|
935
886
|
<div id="number-icons">
|
|
936
|
-
${"default"!==
|
|
887
|
+
${"default"!==n?r`<span id="icons-separator">|</span>`:i}
|
|
937
888
|
<nr-icon
|
|
938
889
|
name="minus"
|
|
939
890
|
aria-label="Decrease value"
|
|
940
891
|
role="button"
|
|
941
892
|
tabindex="0"
|
|
942
|
-
@click=${
|
|
943
|
-
@keydown=${
|
|
893
|
+
@click=${a||e?i:s}
|
|
894
|
+
@keydown=${l}
|
|
944
895
|
></nr-icon>
|
|
945
896
|
<span id="icons-separator">|</span>
|
|
946
897
|
<nr-icon
|
|
@@ -948,8 +899,8 @@ class ni{static validateNumericProperties(t,i,r,e){"number"===t&&(i&&isNaN(Numbe
|
|
|
948
899
|
aria-label="Increase value"
|
|
949
900
|
role="button"
|
|
950
901
|
tabindex="0"
|
|
951
|
-
@click=${
|
|
952
|
-
@keydown=${
|
|
902
|
+
@click=${a||e?i:o}
|
|
903
|
+
@keydown=${l}
|
|
953
904
|
></nr-icon>
|
|
954
905
|
</div>
|
|
955
906
|
`}}
|
|
@@ -957,7 +908,7 @@ class ni{static validateNumericProperties(t,i,r,e){"number"===t&&(i&&isNaN(Numbe
|
|
|
957
908
|
* @license
|
|
958
909
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
959
910
|
* SPDX-License-Identifier: MIT
|
|
960
|
-
*/const
|
|
911
|
+
*/const g=t=>class extends t{get inputElement(){var t;const r=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector("#input, input, textarea");if(r)return r;const i=this.querySelector("input, textarea");if(!i)throw new Error("SelectionMixin requires an input or textarea element");return i}selectAll(){const t=this.inputElement;t&&t.select()}selectRange(t,r){const i=this.inputElement;i&&i.setSelectionRange&&(i.focus(),i.setSelectionRange(t,r))}getCursorPosition(){const t=this.inputElement;return t&&"number"==typeof t.selectionStart?t.selectionStart:null}setCursorPosition(t){const r=this.inputElement;r&&r.setSelectionRange&&(r.focus(),r.setSelectionRange(t,t))}getSelectedText(){const t=this.inputElement;return t&&null!==t.selectionStart&&null!==t.selectionEnd?t.value.substring(t.selectionStart,t.selectionEnd):""}},f=t=>class extends t{get inputElement(){var t;const r=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector("#input, input, textarea");if(r)return r;const i=this.querySelector("input, textarea");if(!i)throw new Error("FocusMixin requires an input or textarea element");return i}focus(t={}){const r=this.inputElement;r&&(r.focus({preventScroll:t.preventScroll}),t.selectText&&r.select())}blur(){const t=this.inputElement;t&&t.blur()}isFocused(){const t=this.inputElement;return!!t&&document.activeElement===t}},w=t=>class extends t{get inputElement(){var t;const r=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector("#input, input");if(r)return r;const i=this.querySelector("input");if(!i)throw new Error("NumberMixin requires an input element");return i}dispatchInputEvent(t,r){"_dispatchInputEvent"in this&&"function"==typeof this._dispatchInputEvent?this._dispatchInputEvent(t,r):this.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0}))}increment(){try{const t=this.inputElement;if(!t.value){const r=t.getAttribute("min");t.value=r||"0"}t.stepUp();const r=t.value;this.dispatchInputEvent("nr-input",{value:r,target:t,action:"increment"}),"value"in this&&(this.value=r)}catch(t){console.warn("Failed to increment value:",t),this.dispatchInputEvent("nr-increment-error",{error:t,value:this.inputElement.value,target:this.inputElement})}}decrement(){try{const t=this.inputElement;t.stepDown();const r=t.value;this.dispatchInputEvent("nr-input",{value:r,target:t,action:"decrement"}),"value"in this&&(this.value=r)}catch(t){console.warn("Failed to decrement value:",t),this.dispatchInputEvent("nr-decrement-error",{error:t,value:this.inputElement.value,target:this.inputElement})}}setStep(t){const r=this.inputElement;t&&this.isValidStep(t)?r.setAttribute("step",t):r.removeAttribute("step")}isValidStep(t){if(!t)return!0;const r=parseFloat(t);return!isNaN(r)&&r>0}};
|
|
961
912
|
/**
|
|
962
913
|
* @license
|
|
963
914
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
@@ -968,48 +919,48 @@ class ni{static validateNumericProperties(t,i,r,e){"number"===t&&(i&&isNaN(Numbe
|
|
|
968
919
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
969
920
|
* SPDX-License-Identifier: MIT
|
|
970
921
|
*/
|
|
971
|
-
class
|
|
922
|
+
class x{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,r){console.error(`[InputController:${r}]`,t),this.dispatchEvent(new CustomEvent("nr-controller-error",{detail:{error:t,context:r,controller:this.constructor.name},bubbles:!0,composed:!0}))}}
|
|
972
923
|
/**
|
|
973
924
|
* @license
|
|
974
925
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
975
926
|
* SPDX-License-Identifier: MIT
|
|
976
|
-
*/var
|
|
927
|
+
*/var k;!function(t){t.Pristine="pristine",t.Pending="pending",t.Valid="valid",t.Invalid="invalid",t.Warning="warning"}(k||(k={}));class S extends x{constructor(){super(...arguments),this._validationState=k.Pristine,this._isValidating=!1,this._isValid=!0,this._validationMessage="",this._validationResult={isValid:!0,errors:[],warnings:[],hasError:!1,hasWarning:!1},this._debounceTimer=null}get stateHost(){return this.host}get validationState(){return this._validationState}get isValidating(){return this._isValidating}get isValid(){return this._isValid}get validationMessage(){return this._validationMessage}get validationResult(){return this._validationResult}setValidationState(t){if(this._validationState!==t){const r=this._validationState;this._validationState=t,this.dispatchStateChangeEvent(r,t),this.requestUpdate()}}setValidationResult(t){this._validationResult=t,this._isValid=t.isValid,this._validationMessage=t.hasError?t.errorMessage||"":t.hasWarning&&t.warningMessage||"";let r=k.Valid;t.hasError?r=k.Invalid:t.hasWarning&&this.stateHost.allowWarnings&&(r=k.Warning),this.setValidationState(r)}setValidating(t){this._isValidating!==t&&(this._isValidating=t,t&&this.setValidationState(k.Pending),this.requestUpdate())}shouldValidateOnChange(){return this.stateHost.validateOnChangeInput&&("change"===this.stateHost.validationTrigger||this._validationState!==k.Pristine)}shouldValidateOnBlur(){return this.stateHost.validateOnBlurInput&&("blur"===this.stateHost.validationTrigger||"change"===this.stateHost.validationTrigger)}clearDebounceTimer(){null!==this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null)}debounceValidation(t){this.clearDebounceTimer();const r=this.stateHost.validationDebounce;r&&r>0?this._debounceTimer=window.setTimeout((()=>{this._debounceTimer=null,t()}),r):t()}resetValidationState(){this.clearDebounceTimer(),this._validationState=k.Pristine,this._isValidating=!1,this._isValid=!0,this._validationMessage="",this._validationResult={isValid:!0,errors:[],warnings:[],hasError:!1,hasWarning:!1},this.requestUpdate()}markAsTouched(){this._validationState===k.Pristine&&this.setValidationState(k.Valid)}isPristine(){return this._validationState===k.Pristine}hasError(){return this._validationState===k.Invalid}hasWarning(){return this._validationState===k.Warning}isPending(){return this._validationState===k.Pending}getStateSummary(){return{state:this._validationState,isValidating:this._isValidating,isValid:this._isValid,message:this._validationMessage,result:this._validationResult,isPristine:this.isPristine(),hasError:this.hasError(),hasWarning:this.hasWarning(),shouldValidateOnChange:this.shouldValidateOnChange(),shouldValidateOnBlur:this.shouldValidateOnBlur()}}hostDisconnected(){super.hostDisconnected(),this.clearDebounceTimer()}dispatchStateChangeEvent(t,r){this.dispatchEvent(new CustomEvent("nr-validation-state-change",{detail:{previousState:t,newState:r,isValidating:this._isValidating,isValid:this._isValid,validationResult:this._validationResult},bubbles:!0,composed:!0}))}}
|
|
977
928
|
/**
|
|
978
929
|
* @license
|
|
979
930
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
980
931
|
* SPDX-License-Identifier: MIT
|
|
981
|
-
*/var ci=function(t,i,r,e){return new(r||(r=Promise))((function(n,a){function o(t){try{l(e.next(t))}catch(t){a(t)}}function s(t){try{l(e.throw(t))}catch(t){a(t)}}function l(t){var i;t.done?n(t.value):(i=t.value,i instanceof r?i:new r((function(t){t(i)}))).then(o,s)}l((e=e.apply(t,i||[])).next())}))};class pi extends di{constructor(t){super(t),this.stateController=new hi(this._host)}get validationHost(){return this._host}get isValid(){return this.stateController.isValid}get validationMessage(){return this.stateController.validationMessage}get validationState(){return this.stateController.validationState}get validationResult(){return this.stateController.validationResult}get isValidating(){return this.stateController.isValidating}hostConnected(){this.setupValidationRules()}hostUpdated(){}setupValidationRules(){const t=[],i=this.validationHost;"email"===i.type&&t.push(Yt()),"url"===i.type&&t.push(Gt()),i.required&&t.push(Kt(i.label?`${i.label} is required`:void 0)),i.maxLength&&t.push(Jt(i.maxLength)),"number"===i.type&&(void 0!==i.min&&t.push(Xt(Number(i.min))),void 0!==i.max&&t.push(Qt(Number(i.max))));const r=i.rules||[],e=[...t.filter((t=>!r.some((i=>this.isSameRuleType(t,i))))),...r];JSON.stringify(i.rules)!==JSON.stringify(e)&&(i.rules=e,this.requestUpdate())}validate(){try{this.stateController.setValidationState(ui.Pending),this.stateController.setValidating(!0),this.dispatchValidationEvent();if(this.hasAsyncValidators())return this.performAsyncValidation(this.validationHost.value),!0;const t=this.performDetailedValidation(this.validationHost.value);return this.stateController.setValidationResult(t),t.hasError?this.setValidationResult(!1,this.stateController.validationMessage,ui.Invalid):t.hasWarning&&this.validationHost.allowWarnings?this.setValidationResult(!0,this.stateController.validationMessage,ui.Warning):this.setValidationResult(!0,"",ui.Valid),this.stateController.setValidating(!1),this.updateHostValidationState(),t.isValid}catch(t){return this.handleError(t,"validate"),this.stateController.setValidating(!1),this.setValidationResult(!1,"Validation error occurred",ui.Invalid),this.updateHostValidationState(),!1}}validateOnChange(){this.stateController.shouldValidateOnChange()&&this.stateController.debounceValidation((()=>{this.validate()}))}validateOnBlur(){this.stateController.shouldValidateOnBlur()&&(this.stateController.clearDebounceTimer(),this.validate())}addRule(t){const i=this.validationHost.rules||[];this.validationHost.rules=[...i,t],this.requestUpdate()}removeRule(t){const i=this.validationHost.rules||[];this.validationHost.rules=i.filter((i=>!t(i))),this.requestUpdate()}clearRules(){this.validationHost.rules=[],this.reset()}hasAsyncValidators(){return(this.validationHost.rules||[]).some((t=>t.asyncValidator||t.validator&&this.isValidatorAsync(t.validator)))}isValidatorAsync(t){const i=t.toString();return i.includes("Promise")||i.includes("async")||i.includes("setTimeout")||i.includes("new Promise")}performAsyncValidation(t){return ci(this,void 0,void 0,(function*(){try{this.stateController.setValidating(!0),this.updateHostValidationState();const i=[],r=[],e=this.validationHost.rules||[];for(const n of e)if(!(n.asyncValidator||n.validator&&this.isValidatorAsync(n.validator))){const e=this.validateRule(n,t);e.isValid||(n.warningOnly&&this.validationHost.allowWarnings?r.push(e.message):i.push(e.message))}if(i.length>0)return this.stateController.setValidationResult({isValid:!1,errors:i,warnings:r,hasError:!0,hasWarning:r.length>0,errorMessage:i[0],warningMessage:r[0]}),this.setValidationResult(!1,this.stateController.validationMessage,ui.Invalid),this.stateController.setValidating(!1),void this.updateHostValidationState();for(const n of e)if(n.asyncValidator||n.validator&&this.isValidatorAsync(n.validator))try{yield this.validateAsyncRule(n,t)}catch(t){const e=t.message||n.message||"Validation failed";n.warningOnly&&this.validationHost.allowWarnings?r.push(e):i.push(e)}const n=i.length>0,a=r.length>0;this.stateController.setValidationResult({isValid:!n,errors:i,warnings:r,hasError:n,hasWarning:a,errorMessage:i[0],warningMessage:r[0]}),n?this.setValidationResult(!1,this.stateController.validationMessage,ui.Invalid):a&&this.validationHost.allowWarnings?this.setValidationResult(!0,this.stateController.validationMessage,ui.Warning):this.setValidationResult(!0,"",ui.Valid),this.stateController.setValidating(!1),this.updateHostValidationState()}catch(t){this.handleError(t,"performAsyncValidation"),this.stateController.setValidating(!1),this.setValidationResult(!1,"Async validation error occurred",ui.Invalid),this.updateHostValidationState()}}))}validateAsyncRule(t,i){return ci(this,void 0,void 0,(function*(){if(t.asyncValidator)yield t.asyncValidator(t,i);else if(t.validator){const r=t.validator(t,i);r&&"object"==typeof r&&"then"in r&&(yield r)}}))}reset(){this.stateController.setValidationResult({isValid:!0,errors:[],warnings:[],hasError:!1,hasWarning:!1}),this.stateController.setValidationState(ui.Pristine),this.stateController.setValidating(!1),this.updateHostValidationState(),this.dispatchValidationEvent()}getValidationStatus(){return{isValid:this.stateController.validationResult.isValid,isValidating:this.stateController.isValidating,errors:this.stateController.validationResult.errors,warnings:this.stateController.validationResult.warnings,validationResult:this.stateController.validationResult}}setValidationStatus(t){this.stateController.setValidationResult(t),t.hasError?this.setValidationResult(!1,this.stateController.validationMessage,ui.Invalid):t.hasWarning?this.setValidationResult(!0,this.stateController.validationMessage,ui.Warning):t.isValid?this.setValidationResult(!0,"",ui.Valid):this.setValidationResult(!0,"",ui.Pristine),this.updateHostValidationState()}performDetailedValidation(t){const i=[],r=[],e=this.validationHost.rules||[];for(const n of e){const e=this.validateRule(n,t);e.isValid||(n.warningOnly&&this.validationHost.allowWarnings?r.push(e.message):i.push(e.message))}const n=i.length>0;return{isValid:!n,errors:i,warnings:r,hasError:n,hasWarning:r.length>0,errorMessage:i[0],warningMessage:r[0]}}validateRule(t,i){if(t.asyncValidator||t.validator&&this.isValidatorAsync(t.validator))return{isValid:!0,message:""};const r=t.transform?t.transform(i):i;if(t.required&&this.isValueEmpty(i))return{isValid:!1,message:t.message||`${this.validationHost.label||"This field"} is required`};if(this.isValueEmpty(i)&&!t.required)return{isValid:!0,message:""};if(t.type){const i=this.validateType(t.type,r);if(!i.isValid)return{isValid:!1,message:t.message||i.message}}if(t.pattern&&!t.pattern.test(r))return{isValid:!1,message:t.message||"Invalid format"};if(void 0!==t.minLength&&r.length<t.minLength)return{isValid:!1,message:t.message||`Minimum length is ${t.minLength} characters`};if(void 0!==t.maxLength&&r.length>t.maxLength)return{isValid:!1,message:t.message||`Maximum length is ${t.maxLength} characters`};if("number"===t.type||"number"===this.validationHost.type){const i=Number(r);if(void 0!==t.min&&i<t.min)return{isValid:!1,message:t.message||`Minimum value is ${t.min}`};if(void 0!==t.max&&i>t.max)return{isValid:!1,message:t.message||`Maximum value is ${t.max}`}}if(t.enum&&!t.enum.includes(r))return{isValid:!1,message:t.message||`Value must be one of: ${t.enum.join(", ")}`};if(t.validator)try{const i=t.validator(t,r);return i&&"object"==typeof i&&"isValid"in i?{isValid:i.isValid,message:i.isValid?"":i.message||t.message||"Validation failed"}:{isValid:!0,message:""}}catch(i){return{isValid:!1,message:t.message||i.message||"Validation failed"}}return{isValid:!0,message:""}}validateType(t,i){switch(t){case"email":return{isValid:Zt.EMAIL.test(i),message:"Please enter a valid email address"};case"url":return{isValid:Zt.URL.test(i),message:"Please enter a valid URL"};case"number":case"integer":return{isValid:!isNaN(Number(i))&&("number"===t||Number.isInteger(Number(i))),message:`Please enter a valid ${t}`};case"float":return{isValid:!isNaN(parseFloat(i)),message:"Please enter a valid number"};default:return{isValid:!0,message:""}}}isValueEmpty(t){return null==t||""===t}isSameRuleType(t,i){return t.type===i.type&&t.required===i.required&&!!t.pattern==!!i.pattern}setValidationResult(t,i,r){const e=this.stateController.isValid!==t||this.stateController.validationMessage!==i||this.stateController.validationState!==r;this.stateController.setValidationState(r),this.stateController.setValidationResult({isValid:t,errors:t?[]:[i],warnings:[],hasError:!t,hasWarning:!1,errorMessage:t?"":i,warningMessage:""}),e&&this.dispatchValidationEvent()}updateHostValidationState(){this.dispatchValidationEvent()}dispatchValidationEvent(){const t={isValid:this.stateController.isValid,validationMessage:this.stateController.validationMessage,validationState:this.stateController.validationState,errors:this.stateController.validationResult.errors,warnings:this.stateController.validationResult.warnings,validationResult:this.stateController.validationResult};this.dispatchEvent(new CustomEvent("nr-validation",{detail:t,bubbles:!0,composed:!0}))}getValidationClasses(){const t=this.host,i=this.host;return{valid:this.stateController.validationResult.isValid&&!this.stateController.validationResult.hasWarning,invalid:this.stateController.validationResult.hasError,warning:this.stateController.validationResult.hasWarning&&!this.stateController.validationResult.hasError,validating:this.stateController.isValidating,"has-feedback":i.hasFeedback||!1,touched:t.isTouched||!1,dirty:t.isDirty||!1,required:this.host.required||!1}}hasValidationFeedback(){const t=this.host;return!!t.hasFeedback&&(this.stateController.isValidating||this.stateController.validationResult.hasError||this.stateController.validationResult.hasWarning||this.stateController.validationResult.isValid&&t.value&&""!==t.value.trim()&&this.stateController.validationState!==ui.Pristine)}renderValidationIcon(){const t=this.host;if(!t.hasFeedback)return"";let i="",r="";return this.stateController.isValidating?(i="hourglass-half",r="validation-loading"):this.stateController.validationResult.hasError?(i="exclamation-circle",r="validation-error"):this.stateController.validationResult.hasWarning?(i="exclamation-triangle",r="validation-warning"):this.stateController.validationResult.isValid&&t.value&&""!==t.value.trim()&&this.stateController.validationState!==ui.Pristine&&(i="check-circle",r="validation-success"),i?bt`
|
|
932
|
+
*/var V=function(t,r,i,n){return new(i||(i=Promise))((function(a,e){function o(t){try{l(n.next(t))}catch(t){e(t)}}function s(t){try{l(n.throw(t))}catch(t){e(t)}}function l(t){var r;t.done?a(t.value):(r=t.value,r instanceof i?r:new i((function(t){t(r)}))).then(o,s)}l((n=n.apply(t,r||[])).next())}))};class $ extends x{constructor(t){super(t),this.stateController=new S(this._host)}get validationHost(){return this._host}get isValid(){return this.stateController.isValid}get validationMessage(){return this.stateController.validationMessage}get validationState(){return this.stateController.validationState}get validationResult(){return this.stateController.validationResult}get isValidating(){return this.stateController.isValidating}hostConnected(){this.setupValidationRules()}hostUpdated(){}setupValidationRules(){const t=[],r=this.validationHost;"email"===r.type&&t.push(c()),"url"===r.type&&t.push(p()),r.required&&t.push(u(r.label?`${r.label} is required`:void 0)),r.maxLength&&t.push(h(r.maxLength)),"number"===r.type&&(void 0!==r.min&&t.push(v(Number(r.min))),void 0!==r.max&&t.push(m(Number(r.max))));const i=r.rules||[],n=[...t.filter((t=>!i.some((r=>this.isSameRuleType(t,r))))),...i];JSON.stringify(r.rules)!==JSON.stringify(n)&&(r.rules=n,this.requestUpdate())}validate(){try{this.stateController.setValidationState(k.Pending),this.stateController.setValidating(!0),this.dispatchValidationEvent();if(this.hasAsyncValidators())return this.performAsyncValidation(this.validationHost.value),!0;const t=this.performDetailedValidation(this.validationHost.value);return this.stateController.setValidationResult(t),t.hasError?this.setValidationResult(!1,this.stateController.validationMessage,k.Invalid):t.hasWarning&&this.validationHost.allowWarnings?this.setValidationResult(!0,this.stateController.validationMessage,k.Warning):this.setValidationResult(!0,"",k.Valid),this.stateController.setValidating(!1),this.updateHostValidationState(),t.isValid}catch(t){return this.handleError(t,"validate"),this.stateController.setValidating(!1),this.setValidationResult(!1,"Validation error occurred",k.Invalid),this.updateHostValidationState(),!1}}validateOnChange(){this.stateController.shouldValidateOnChange()&&this.stateController.debounceValidation((()=>{this.validate()}))}validateOnBlur(){this.stateController.shouldValidateOnBlur()&&(this.stateController.clearDebounceTimer(),this.validate())}addRule(t){const r=this.validationHost.rules||[];this.validationHost.rules=[...r,t],this.requestUpdate()}removeRule(t){const r=this.validationHost.rules||[];this.validationHost.rules=r.filter((r=>!t(r))),this.requestUpdate()}clearRules(){this.validationHost.rules=[],this.reset()}hasAsyncValidators(){return(this.validationHost.rules||[]).some((t=>t.asyncValidator||t.validator&&this.isValidatorAsync(t.validator)))}isValidatorAsync(t){const r=t.toString();return r.includes("Promise")||r.includes("async")||r.includes("setTimeout")||r.includes("new Promise")}performAsyncValidation(t){return V(this,void 0,void 0,(function*(){try{this.stateController.setValidating(!0),this.updateHostValidationState();const r=[],i=[],n=this.validationHost.rules||[];for(const a of n)if(!(a.asyncValidator||a.validator&&this.isValidatorAsync(a.validator))){const n=this.validateRule(a,t);n.isValid||(a.warningOnly&&this.validationHost.allowWarnings?i.push(n.message):r.push(n.message))}if(r.length>0)return this.stateController.setValidationResult({isValid:!1,errors:r,warnings:i,hasError:!0,hasWarning:i.length>0,errorMessage:r[0],warningMessage:i[0]}),this.setValidationResult(!1,this.stateController.validationMessage,k.Invalid),this.stateController.setValidating(!1),void this.updateHostValidationState();for(const a of n)if(a.asyncValidator||a.validator&&this.isValidatorAsync(a.validator))try{yield this.validateAsyncRule(a,t)}catch(t){const n=t.message||a.message||"Validation failed";a.warningOnly&&this.validationHost.allowWarnings?i.push(n):r.push(n)}const a=r.length>0,e=i.length>0;this.stateController.setValidationResult({isValid:!a,errors:r,warnings:i,hasError:a,hasWarning:e,errorMessage:r[0],warningMessage:i[0]}),a?this.setValidationResult(!1,this.stateController.validationMessage,k.Invalid):e&&this.validationHost.allowWarnings?this.setValidationResult(!0,this.stateController.validationMessage,k.Warning):this.setValidationResult(!0,"",k.Valid),this.stateController.setValidating(!1),this.updateHostValidationState()}catch(t){this.handleError(t,"performAsyncValidation"),this.stateController.setValidating(!1),this.setValidationResult(!1,"Async validation error occurred",k.Invalid),this.updateHostValidationState()}}))}validateAsyncRule(t,r){return V(this,void 0,void 0,(function*(){if(t.asyncValidator)yield t.asyncValidator(t,r);else if(t.validator){const i=t.validator(t,r);i&&"object"==typeof i&&"then"in i&&(yield i)}}))}reset(){this.stateController.setValidationResult({isValid:!0,errors:[],warnings:[],hasError:!1,hasWarning:!1}),this.stateController.setValidationState(k.Pristine),this.stateController.setValidating(!1),this.updateHostValidationState(),this.dispatchValidationEvent()}getValidationStatus(){return{isValid:this.stateController.validationResult.isValid,isValidating:this.stateController.isValidating,errors:this.stateController.validationResult.errors,warnings:this.stateController.validationResult.warnings,validationResult:this.stateController.validationResult}}setValidationStatus(t){this.stateController.setValidationResult(t),t.hasError?this.setValidationResult(!1,this.stateController.validationMessage,k.Invalid):t.hasWarning?this.setValidationResult(!0,this.stateController.validationMessage,k.Warning):t.isValid?this.setValidationResult(!0,"",k.Valid):this.setValidationResult(!0,"",k.Pristine),this.updateHostValidationState()}performDetailedValidation(t){const r=[],i=[],n=this.validationHost.rules||[];for(const a of n){const n=this.validateRule(a,t);n.isValid||(a.warningOnly&&this.validationHost.allowWarnings?i.push(n.message):r.push(n.message))}const a=r.length>0;return{isValid:!a,errors:r,warnings:i,hasError:a,hasWarning:i.length>0,errorMessage:r[0],warningMessage:i[0]}}validateRule(t,r){if(t.asyncValidator||t.validator&&this.isValidatorAsync(t.validator))return{isValid:!0,message:""};const i=t.transform?t.transform(r):r;if(t.required&&this.isValueEmpty(r))return{isValid:!1,message:t.message||`${this.validationHost.label||"This field"} is required`};if(this.isValueEmpty(r)&&!t.required)return{isValid:!0,message:""};if(t.type){const r=this.validateType(t.type,i);if(!r.isValid)return{isValid:!1,message:t.message||r.message}}if(t.pattern&&!t.pattern.test(i))return{isValid:!1,message:t.message||"Invalid format"};if(void 0!==t.minLength&&i.length<t.minLength)return{isValid:!1,message:t.message||`Minimum length is ${t.minLength} characters`};if(void 0!==t.maxLength&&i.length>t.maxLength)return{isValid:!1,message:t.message||`Maximum length is ${t.maxLength} characters`};if("number"===t.type||"number"===this.validationHost.type){const r=Number(i);if(void 0!==t.min&&r<t.min)return{isValid:!1,message:t.message||`Minimum value is ${t.min}`};if(void 0!==t.max&&r>t.max)return{isValid:!1,message:t.message||`Maximum value is ${t.max}`}}if(t.enum&&!t.enum.includes(i))return{isValid:!1,message:t.message||`Value must be one of: ${t.enum.join(", ")}`};if(t.validator)try{const r=t.validator(t,i);return r&&"object"==typeof r&&"isValid"in r?{isValid:r.isValid,message:r.isValid?"":r.message||t.message||"Validation failed"}:{isValid:!0,message:""}}catch(r){return{isValid:!1,message:t.message||r.message||"Validation failed"}}return{isValid:!0,message:""}}validateType(t,r){switch(t){case"email":return{isValid:d.EMAIL.test(r),message:"Please enter a valid email address"};case"url":return{isValid:d.URL.test(r),message:"Please enter a valid URL"};case"number":case"integer":return{isValid:!isNaN(Number(r))&&("number"===t||Number.isInteger(Number(r))),message:`Please enter a valid ${t}`};case"float":return{isValid:!isNaN(parseFloat(r)),message:"Please enter a valid number"};default:return{isValid:!0,message:""}}}isValueEmpty(t){return null==t||""===t}isSameRuleType(t,r){return t.type===r.type&&t.required===r.required&&!!t.pattern==!!r.pattern}setValidationResult(t,r,i){const n=this.stateController.isValid!==t||this.stateController.validationMessage!==r||this.stateController.validationState!==i;this.stateController.setValidationState(i),this.stateController.setValidationResult({isValid:t,errors:t?[]:[r],warnings:[],hasError:!t,hasWarning:!1,errorMessage:t?"":r,warningMessage:""}),n&&this.dispatchValidationEvent()}updateHostValidationState(){this.dispatchValidationEvent()}dispatchValidationEvent(){const t={isValid:this.stateController.isValid,validationMessage:this.stateController.validationMessage,validationState:this.stateController.validationState,errors:this.stateController.validationResult.errors,warnings:this.stateController.validationResult.warnings,validationResult:this.stateController.validationResult};this.dispatchEvent(new CustomEvent("nr-validation",{detail:t,bubbles:!0,composed:!0}))}getValidationClasses(){const t=this.host,r=this.host;return{valid:this.stateController.validationResult.isValid&&!this.stateController.validationResult.hasWarning,invalid:this.stateController.validationResult.hasError,warning:this.stateController.validationResult.hasWarning&&!this.stateController.validationResult.hasError,validating:this.stateController.isValidating,"has-feedback":r.hasFeedback||!1,touched:t.isTouched||!1,dirty:t.isDirty||!1,required:this.host.required||!1}}hasValidationFeedback(){const t=this.host;return!!t.hasFeedback&&(this.stateController.isValidating||this.stateController.validationResult.hasError||this.stateController.validationResult.hasWarning||this.stateController.validationResult.isValid&&t.value&&""!==t.value.trim()&&this.stateController.validationState!==k.Pristine)}renderValidationIcon(){const t=this.host;if(!t.hasFeedback)return"";let i="",n="";return this.stateController.isValidating?(i="hourglass-half",n="validation-loading"):this.stateController.validationResult.hasError?(i="exclamation-circle",n="validation-error"):this.stateController.validationResult.hasWarning?(i="exclamation-triangle",n="validation-warning"):this.stateController.validationResult.isValid&&t.value&&""!==t.value.trim()&&this.stateController.validationState!==k.Pristine&&(i="check-circle",n="validation-success"),i?r`
|
|
982
933
|
<nr-icon
|
|
983
934
|
name="${i}"
|
|
984
|
-
class="validation-icon ${
|
|
935
|
+
class="validation-icon ${n}"
|
|
985
936
|
part="validation-icon">
|
|
986
937
|
</nr-icon>
|
|
987
|
-
`:""}renderValidationMessage(){const t=this.stateController.validationResult.hasError,i=this.stateController.validationResult.hasWarning&&!t,
|
|
938
|
+
`:""}renderValidationMessage(){const t=this.stateController.validationResult.hasError,i=this.stateController.validationResult.hasWarning&&!t,n=t?this.stateController.validationResult.errorMessage:i?this.stateController.validationResult.warningMessage:"";return n?r`
|
|
988
939
|
<div class="validation-message ${t?"error":"warning"}"
|
|
989
940
|
part="validation-message"
|
|
990
941
|
role="alert"
|
|
991
942
|
aria-live="polite">
|
|
992
|
-
${
|
|
943
|
+
${n}
|
|
993
944
|
</div>
|
|
994
945
|
`:""}clearDebounceTimer(){this.stateController.clearDebounceTimer()}getValidationRenderState(){return{classes:this.getValidationClasses(),hasValidationFeedback:this.hasValidationFeedback(),isValidating:this.stateController.isValidating,validationResult:this.stateController.validationResult,validationState:this.stateController.validationState}}}
|
|
995
946
|
/**
|
|
996
947
|
* @license
|
|
997
948
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
998
949
|
* SPDX-License-Identifier: MIT
|
|
999
|
-
*/var
|
|
950
|
+
*/var A=function(t,r,i,n){return new(i||(i=Promise))((function(a,e){function o(t){try{l(n.next(t))}catch(t){e(t)}}function s(t){try{l(n.throw(t))}catch(t){e(t)}}function l(t){var r;t.done?a(t.value):(r=t.value,r instanceof i?r:new i((function(t){t(r)}))).then(o,s)}l((n=n.apply(t,r||[])).next())}))};class E extends x{constructor(){super(...arguments),this.handleKeyDown=t=>{!this.eventHost.readonly||this.isReadonlyKeyAllowed(t)?"Enter"!==t.key?"number"===this.eventHost.type&&this.handleNumericKeyDown(t):this.dispatchEnterEvent(t):t.preventDefault()},this.handleValueChange=t=>{if(this.eventHost.readonly)return void t.preventDefault();const r=t.target,i=r.value;if(this.eventHost.maxLength&&i.length>this.eventHost.maxLength)return void t.preventDefault();"number"===this.eventHost.type&&i&&this.validateNumericValue(i,t),this.eventHost.value=i;const n=this.eventHost;n.validationController&&"function"==typeof n.validationController.validateOnChange&&n.validationController.validateOnChange(),this.eventHost.dispatchInputEvent("nr-input",{value:this.eventHost.value,target:r,originalEvent:t})},this.handleFocus=t=>{var r;this.setFocusState(!0);const i=t.target;this.restoreCursorPosition(i);const n={focused:!0,cursorPosition:null!==(r=this.getCursorPosition())&&void 0!==r?r:void 0,selectedText:this.getSelectedText()};this.eventHost.dispatchFocusEvent("nr-focus",Object.assign({target:t.target,value:this.eventHost.value},n)),this.eventHost.dispatchFocusEvent("nr-focus-change",n)},this.handleBlur=t=>{var r;this.setFocusState(!1);const i={focused:!1,cursorPosition:null!==(r=this.getCursorPosition())&&void 0!==r?r:void 0,selectedText:this.getSelectedText()},n=this.eventHost;n.validationController&&"function"==typeof n.validationController.validateOnBlur&&n.validationController.validateOnBlur(),this.eventHost.dispatchFocusEvent("nr-blur",Object.assign({target:t.target,value:this.eventHost.value},i)),this.eventHost.dispatchFocusEvent("nr-focus-change",i)},this.handleIconKeydown=t=>{if(!this.isActivationKey(t))return;t.preventDefault();const r=t.target;switch(r.id){case"copy-icon":this.handleCopy();break;case"clear-icon":this.handleClear();break;case"password-icon":this.handleTogglePassword();break;default:r.closest("#number-icons")&&this.handleNumberIconAction(r)}},this.handleCopy=()=>A(this,void 0,void 0,(function*(){if(this.eventHost.withCopy&&!this.eventHost.disabled)try{const t=this.inputElement;if(!t)return;t.select(),yield navigator.clipboard.writeText(t.value),this.eventHost.dispatchActionEvent("nr-copy-success",{value:t.value,action:"copy"})}catch(t){this.handleError(t,"copy"),this.eventHost.dispatchActionEvent("nr-copy-error",{error:t,action:"copy"})}})),this.handleClear=()=>{if(this.eventHost.disabled||this.eventHost.readonly||!this.eventHost.allowClear)return;const t=this.eventHost.value;this.eventHost.value="";const r=this.inputElement;r&&(r.value="",r.focus()),this.eventHost.dispatchActionEvent("nr-clear",{previousValue:t,newValue:this.eventHost.value,target:r,action:"clear"}),this.eventHost.dispatchInputEvent("nr-input",{value:this.eventHost.value,target:r,action:"clear"})},this.handleTogglePassword=()=>{if("password"!==this.eventHost.type)return;const t="password"===this.eventHost.inputType?"text":"password";this.eventHost.inputType=t,this.requestUpdate(),this.eventHost.dispatchActionEvent("nr-password-toggle",{visible:"text"===t,action:"password-toggle"})},this.handleIncrement=()=>{"number"===this.eventHost.type&&this.eventHost.increment&&this.eventHost.increment()},this.handleDecrement=()=>{"number"===this.eventHost.type&&this.eventHost.decrement&&this.eventHost.decrement()}}get eventHost(){return this.host}get inputElement(){var t;return(null===(t=this.eventHost.shadowRoot)||void 0===t?void 0:t.querySelector("#input"))||null}handleNumericKeyDown(t){["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(t.key)||t.ctrlKey||t.metaKey||"."!==t.key&&"-"!==t.key&&(/^\d$/.test(t.key)||t.preventDefault())}handleNumberIconAction(t){const r=t.classList.contains("increment")||t.closest(".increment"),i=t.classList.contains("decrement")||t.closest(".decrement");r?this.handleIncrement():i&&this.handleDecrement()}dispatchEnterEvent(t){this.eventHost.dispatchInputEvent("nr-enter",{value:this.eventHost.value,target:t.target,originalEvent:t})}validateNumericValue(t,r){}restoreCursorPosition(t){if(t.dataset.restoreCursor){const r=parseInt(t.dataset.restoreCursor,10);isNaN(r)||t.setSelectionRange(r,r),delete t.dataset.restoreCursor}}setFocusState(t){this.eventHost.hasOwnProperty("focused")&&(this.eventHost.focused=t,this.requestUpdate())}getCursorPosition(){if(this.eventHost.getCursorPosition)return this.eventHost.getCursorPosition();const t=this.inputElement;return t?t.selectionStart:null}getSelectedText(){if(this.eventHost.getSelectedText)return this.eventHost.getSelectedText();const t=this.inputElement;return t&&null!==t.selectionStart&&null!==t.selectionEnd?t.value.substring(t.selectionStart,t.selectionEnd):""}isReadonlyKeyAllowed(t){if(this.eventHost.isReadonlyKeyAllowed)return this.eventHost.isReadonlyKeyAllowed(t);return t.ctrlKey||t.metaKey?["KeyA","KeyC"].includes(t.code):["Tab","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key)}isActivationKey(t){return this.eventHost.isActivationKey?this.eventHost.isActivationKey(t):"Enter"===t.key||" "===t.key}}
|
|
1000
951
|
/**
|
|
1001
952
|
* @license
|
|
1002
953
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
1003
954
|
* SPDX-License-Identifier: MIT
|
|
1004
|
-
*/var
|
|
955
|
+
*/var z=function(t,r,i,n){for(var a,e=arguments.length,o=e<3?r:null===n?n=Object.getOwnPropertyDescriptor(r,i):n,s=t.length-1;s>=0;s--)(a=t[s])&&(o=(e<3?a(o):e>3?a(r,i,o):a(r,i))||o);return e>3&&o&&Object.defineProperty(r,i,o),o},N=function(t,r,i,n){return new(i||(i=Promise))((function(a,e){function o(t){try{l(n.next(t))}catch(t){e(t)}}function s(t){try{l(n.throw(t))}catch(t){e(t)}}function l(t){var r;t.done?a(t.value):(r=t.value,r instanceof i?r:new i((function(t){t(r)}))).then(o,s)}l((n=n.apply(t,r||[])).next())}))};let C=class extends(w(f(g(s(n))))){constructor(){super(...arguments),this.validationController=new $(this),this.eventController=new E(this),this.disabled=!1,this.readonly=!1,this.state="default",this.value="",this.size="medium",this.variant="underlined",this.type="text",this.placeholder="",this.autocomplete="off",this.withCopy=!1,this.allowClear=!1,this.showCount=!1,this.rules=[],this.validateOnChangeInput=!0,this.validateOnBlurInput=!0,this.hasFeedback=!1,this.allowWarnings=!1,this.validationTrigger="change",this.inputType="",this.hasAddonBefore=!1,this.hasAddonAfter=!1,this.focused=!1,this.requiredComponents=["nr-icon"],this._handleValidationEvent=t=>{const r=t.detail;this.validationMessage=r.validationMessage||"";let i="default";r.validationResult.hasError?i="error":r.validationResult.hasWarning&&this.allowWarnings?i="warning":r.validationResult.isValid&&this.value&&this.hasFeedback&&(i="success"),this.state!==i&&(this.state=i),this.requestUpdate()},this._handleKeyDown=t=>{this.eventController.handleKeyDown(t)},this._valueChange=t=>{this.eventController.handleValueChange(t)},this._focusEvent=t=>{this.eventController.handleFocus(t)},this._blurEvent=t=>{this.eventController.handleBlur(t)},this._handleIconKeydown=t=>{this.eventController.handleIconKeydown(t)}}get _input(){return this.shadowRoot.querySelector("#input")}get characterCountDisplay(){const t=this.value.length;return this.maxLength?`${t}/${this.maxLength}`:`${t}`}get isOverCharacterLimit(){return!!this.maxLength&&this.value.length>this.maxLength}get input(){return this._input}get inputElement(){return this._input}connectedCallback(){super.connectedCallback(),this.addEventListener("nr-validation",this._handleValidationEvent)}disconnectedCallback(){var t,r;super.disconnectedCallback(),this.removeEventListener("nr-validation",this._handleValidationEvent),null===(r=(t=this.validationController).clearDebounceTimer)||void 0===r||r.call(t)}willUpdate(t){super.willUpdate(t),!t.has("type")&&this.inputType||(this.inputType=this.type),(t.has("type")||t.has("min"))&&"number"===this.type&&this.min&&!this.value&&(this.value=this.min),(t.has("type")||t.has("min")||t.has("max")||t.has("step"))&&b.validateNumericProperties(this.type,this.min,this.max,this.step),(t.has("type")||t.has("required")||t.has("maxLength")||t.has("min")||t.has("max"))&&this.validationController.setupValidationRules()}updated(t){if(t.has("step")||t.has("min")||t.has("max")||t.has("maxLength")){const t=this.input;t&&(this.setStep(this.step),this.min?t.setAttribute("min",this.min):t.removeAttribute("min"),this.max?t.setAttribute("max",this.max):t.removeAttribute("max"),this.maxLength?t.setAttribute("maxlength",this.maxLength.toString()):t.removeAttribute("maxlength"))}}firstUpdated(){this._checkInitialSlotContent()}_checkInitialSlotContent(){const t=this.querySelectorAll('[slot="addon-before"]');this.hasAddonBefore=t.length>0;const r=this.querySelectorAll('[slot="addon-after"]');this.hasAddonAfter=r.length>0}_handleSlotChange(t){const r=t.target,i=r.name;"addon-before"===i?this.hasAddonBefore=r.assignedElements().length>0:"addon-after"===i&&(this.hasAddonAfter=r.assignedElements().length>0)}_onCopy(){return N(this,void 0,void 0,(function*(){yield this.eventController.handleCopy()}))}_onClear(){this.eventController.handleClear()}_increment(){this.eventController.handleIncrement()}_decrement(){this.eventController.handleDecrement()}_togglePasswordIcon(){this.eventController.handleTogglePassword()}_getAriaDescribedBy(){var t;const r=[],i=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('slot[name="helper-text"]');return i&&i.assignedNodes().length>0&&r.push("helper-text"),r.join(" ")||""}validateValue(t){return this.validationController.validate()}addRule(t){this.validationController.addRule(t)}removeRule(t){this.validationController.removeRule(t)}clearRules(){this.validationController.clearRules()}getValidationStatus(){return this.validationController.getValidationStatus()}validateInput(){return N(this,void 0,void 0,(function*(){const t=this.validationController.validate();return this.validationController.isValidating?new Promise((t=>{const r=()=>{this.validationController.isValidating?setTimeout(r,50):t(this.validationController.isValid)};r()})):t}))}setValidationStatus(t){this.validationController.setValidationStatus(t)}getValidationClasses(){return this.validationController.getValidationClasses()}renderValidationIcon(){return this.validationController.renderValidationIcon()}renderValidationMessage(){return this.validationController.renderValidationMessage()}render(){const t=this.getValidationClasses(),i=this.validationController.getValidationRenderState();return r`
|
|
1005
956
|
<slot name="label"></slot>
|
|
1006
957
|
<div class="input-wrapper ${Object.entries(t).filter((([,t])=>t)).map((([t])=>t)).join(" ")}"
|
|
1007
958
|
part="input-wrapper"
|
|
1008
959
|
data-theme="${this.currentTheme}"
|
|
1009
960
|
?data-validating="${i.isValidating}">
|
|
1010
|
-
${
|
|
961
|
+
${y.renderAddonBefore(this.hasAddonBefore,(t=>this._handleSlotChange(t)))}
|
|
1011
962
|
<div data-size=${this.size} id="input-container" part="input-container">
|
|
1012
|
-
${
|
|
963
|
+
${y.renderPrefix()}
|
|
1013
964
|
<input
|
|
1014
965
|
id="input"
|
|
1015
966
|
part="input"
|
|
@@ -1026,21 +977,21 @@ class di{constructor(t){this._host=t,this._host.addController(this)}get host(){r
|
|
|
1026
977
|
@blur=${this._blurEvent}
|
|
1027
978
|
@keydown=${this._handleKeyDown}
|
|
1028
979
|
/>
|
|
1029
|
-
${
|
|
1030
|
-
${
|
|
1031
|
-
${
|
|
1032
|
-
${i.hasValidationFeedback?this.renderValidationIcon():
|
|
1033
|
-
${
|
|
1034
|
-
${
|
|
1035
|
-
${
|
|
980
|
+
${y.renderSuffix()}
|
|
981
|
+
${y.renderCopyIcon(this.withCopy,this.disabled,this.readonly,(()=>this._onCopy()),(t=>this._handleIconKeydown(t)))}
|
|
982
|
+
${y.renderClearIcon(this.allowClear,this.value,this.disabled,this.readonly,(()=>this._onClear()),(t=>this._handleIconKeydown(t)))}
|
|
983
|
+
${i.hasValidationFeedback?this.renderValidationIcon():y.renderStateIcon(this.state)}
|
|
984
|
+
${y.renderCalendarIcon(this.state,this.type)}
|
|
985
|
+
${y.renderPasswordIcon(this.type,this.inputType,this.disabled,this.readonly,(()=>this._togglePasswordIcon()),(t=>this._handleIconKeydown(t)))}
|
|
986
|
+
${y.renderNumberIcons(this.type,this.state,this.disabled,this.readonly,(()=>this._increment()),(()=>this._decrement()),(t=>this._handleIconKeydown(t)))}
|
|
1036
987
|
</div>
|
|
1037
|
-
${
|
|
988
|
+
${y.renderAddonAfter(this.hasAddonAfter,(t=>this._handleSlotChange(t)))}
|
|
1038
989
|
</div>
|
|
1039
990
|
<slot name="helper-text"></slot>
|
|
1040
991
|
${this.renderValidationMessage()}
|
|
1041
|
-
${this.showCount?
|
|
992
|
+
${this.showCount?r`
|
|
1042
993
|
<div class="character-count" part="character-count" ?data-over-limit=${this.isOverCharacterLimit}>
|
|
1043
994
|
${this.characterCountDisplay}
|
|
1044
995
|
</div>
|
|
1045
996
|
`:""}
|
|
1046
|
-
`}};
|
|
997
|
+
`}};C.styles=l,z([a({type:Boolean,reflect:!0})],C.prototype,"disabled",void 0),z([a({type:Boolean,reflect:!0})],C.prototype,"readonly",void 0),z([a({type:String,reflect:!0})],C.prototype,"state",void 0),z([a({type:String})],C.prototype,"value",void 0),z([a({type:String})],C.prototype,"size",void 0),z([a({type:String,reflect:!0})],C.prototype,"variant",void 0),z([a({reflect:!0})],C.prototype,"type",void 0),z([a({type:String})],C.prototype,"step",void 0),z([a({type:String})],C.prototype,"min",void 0),z([a({type:String})],C.prototype,"max",void 0),z([a({type:String})],C.prototype,"placeholder",void 0),z([a({type:String})],C.prototype,"autocomplete",void 0),z([a({type:String})],C.prototype,"name",void 0),z([a({type:Boolean})],C.prototype,"required",void 0),z([a({type:Boolean,reflect:!0})],C.prototype,"withCopy",void 0),z([a({type:Boolean,reflect:!0})],C.prototype,"allowClear",void 0),z([a({type:Boolean,reflect:!0})],C.prototype,"showCount",void 0),z([a({type:Number})],C.prototype,"maxLength",void 0),z([a({type:Array})],C.prototype,"rules",void 0),z([a({type:Boolean,attribute:"validate-on-change"})],C.prototype,"validateOnChangeInput",void 0),z([a({type:Boolean,attribute:"validate-on-blur"})],C.prototype,"validateOnBlurInput",void 0),z([a({type:Boolean,attribute:"has-feedback"})],C.prototype,"hasFeedback",void 0),z([a({type:Boolean,attribute:"allow-warnings"})],C.prototype,"allowWarnings",void 0),z([a({type:String,attribute:"validation-trigger"})],C.prototype,"validationTrigger",void 0),z([a({type:Number,attribute:"validation-debounce"})],C.prototype,"validationDebounce",void 0),z([a({type:String})],C.prototype,"label",void 0),z([e()],C.prototype,"validationMessage",void 0),z([e()],C.prototype,"inputType",void 0),z([e()],C.prototype,"hasAddonBefore",void 0),z([e()],C.prototype,"hasAddonAfter",void 0),z([e()],C.prototype,"focused",void 0),C=z([o("nr-input")],C);var I=Object.freeze({__proto__:null,PORT:/^(?:[1-9]\d{0,4}|[1-5]\d{5}|6[0-4]\d{4}|65[0-4]\d{3}|655[0-2]\d{2}|6553[0-5])$/,NOT_EMPTY:/^.+$/});export{C as NrInputElement,I as Validations};
|