@nuralyui/textarea 0.1.2 → 0.1.4
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 +15 -76
- package/package.json +1 -1
package/bundle.js
CHANGED
|
@@ -1,59 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2019 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/
|
|
6
|
-
const t=window,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,i=Symbol(),s=new WeakMap;class r{constructor(t,e,s){if(this._$cssResult$=!0,s!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=s.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&s.set(i,t))}return t}toString(){return this.cssText}}const o=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new r("string"==typeof t?t:t+"",void 0,i))(e)})(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,c={toAttribute(t,e){switch(e){case Boolean:t=t?h:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},u=(t,e)=>e!==t&&(e==e||t==t),v={attribute:!0,type:String,converter:c,reflect:!1,hasChanged:u},p="finalized";class f extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var e;this.finalize(),(null!==(e=this.h)&&void 0!==e?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const s=this._$Ep(i,e);void 0!==s&&(this._$Ev.set(s,i),t.push(s))})),t}static createProperty(t,e=v){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,s=this.getPropertyDescriptor(t,i,e);void 0!==s&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(s){const r=this[t];this[e]=s,this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||v}static finalize(){if(this.hasOwnProperty(p))return!1;this[p]=!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,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(o(t))}else void 0!==t&&e.push(o(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"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 e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var i;const s=null!==(i=this.shadowRoot)&&void 0!==i?i:this.attachShadow(this.constructor.shadowRootOptions);return((i,s)=>{e?i.adoptedStyleSheets=s.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):s.forEach((e=>{const s=document.createElement("style"),r=t.litNonce;void 0!==r&&s.setAttribute("nonce",r),s.textContent=e.cssText,i.appendChild(s)}))})(s,this.constructor.elementStyles),s}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 e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=v){var s;const r=this.constructor._$Ep(t,i);if(void 0!==r&&!0===i.reflect){const o=(void 0!==(null===(s=i.converter)||void 0===s?void 0:s.toAttribute)?i.converter:c).toAttribute(e,i.type);this._$El=t,null==o?this.removeAttribute(r):this.setAttribute(r,o),this._$El=null}}_$AK(t,e){var i;const s=this.constructor,r=s._$Ev.get(t);if(void 0!==r&&this._$El!==r){const t=s.getPropertyOptions(r),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(i=t.converter)||void 0===i?void 0:i.fromAttribute)?t.converter:c;this._$El=r,this[r]=o.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,i){let s=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||u)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):s=!1),!this.isUpdatePending&&s&&(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,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$Ek()}catch(t){throw e=!1,this._$Ek(),t}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.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,e)=>this._$EO(e,this[e],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 b;f[p]=!0,f.elementProperties=new Map,f.elementStyles=[],f.shadowRootOptions={mode:"open"},null==d||d({ReactiveElement:f}),(null!==(n=a.reactiveElementVersions)&&void 0!==n?n:a.reactiveElementVersions=[]).push("1.6.3");const g=window,m=g.trustedTypes,y=m?m.createPolicy("lit-html",{createHTML:t=>t}):void 0,x="$lit$",w=`lit$${(Math.random()+"").slice(9)}$`,$="?"+w,E=`<${$}>`,C=document,S=()=>C.createComment(""),k=t=>null===t||"object"!=typeof t&&"function"!=typeof t,A=Array.isArray,R="[ \t\n\f\r]",z=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,_=/-->/g,T=/>/g,O=RegExp(`>|${R}(?:([^\\s"'>=/]+)(${R}*=${R}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),V=/'/g,U=/"/g,j=/^(?:script|style|textarea|title)$/i,I=Symbol.for("lit-noChange"),M=Symbol.for("lit-nothing"),N=new WeakMap,P=C.createTreeWalker(C,129,null,!1);function B(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==y?y.createHTML(e):e}class D{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let r=0,o=0;const n=t.length-1,a=this.parts,[l,h]=((t,e)=>{const i=t.length-1,s=[];let r,o=2===e?"<svg>":"",n=z;for(let e=0;e<i;e++){const i=t[e];let a,l,h=-1,d=0;for(;d<i.length&&(n.lastIndex=d,l=n.exec(i),null!==l);)d=n.lastIndex,n===z?"!--"===l[1]?n=_:void 0!==l[1]?n=T:void 0!==l[2]?(j.test(l[2])&&(r=RegExp("</"+l[2],"g")),n=O):void 0!==l[3]&&(n=O):n===O?">"===l[0]?(n=null!=r?r:z,h=-1):void 0===l[1]?h=-2:(h=n.lastIndex-l[2].length,a=l[1],n=void 0===l[3]?O:'"'===l[3]?U:V):n===U||n===V?n=O:n===_||n===T?n=z:(n=O,r=void 0);const c=n===O&&t[e+1].startsWith("/>")?" ":"";o+=n===z?i+E:h>=0?(s.push(a),i.slice(0,h)+x+i.slice(h)+w+c):i+w+(-2===h?(s.push(void 0),e):c)}return[B(t,o+(t[i]||"<?>")+(2===e?"</svg>":"")),s]})(t,e);if(this.el=D.createElement(l,i),P.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(s=P.nextNode())&&a.length<n;){if(1===s.nodeType){if(s.hasAttributes()){const t=[];for(const e of s.getAttributeNames())if(e.endsWith(x)||e.startsWith(w)){const i=h[o++];if(t.push(e),void 0!==i){const t=s.getAttribute(i.toLowerCase()+x).split(w),e=/([.?@])?(.*)/.exec(i);a.push({type:1,index:r,name:e[2],strings:t,ctor:"."===e[1]?F:"?"===e[1]?Z:"@"===e[1]?J:q})}else a.push({type:6,index:r})}for(const e of t)s.removeAttribute(e)}if(j.test(s.tagName)){const t=s.textContent.split(w),e=t.length-1;if(e>0){s.textContent=m?m.emptyScript:"";for(let i=0;i<e;i++)s.append(t[i],S()),P.nextNode(),a.push({type:2,index:++r});s.append(t[e],S())}}}else if(8===s.nodeType)if(s.data===$)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=s.data.indexOf(w,t+1));)a.push({type:7,index:r}),t+=w.length-1}r++}}static createElement(t,e){const i=C.createElement("template");return i.innerHTML=t,i}}function L(t,e,i=t,s){var r,o,n,a;if(e===I)return e;let l=void 0!==s?null===(r=i._$Co)||void 0===r?void 0:r[s]:i._$Cl;const h=k(e)?void 0:e._$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,i,s)),void 0!==s?(null!==(n=(a=i)._$Co)&&void 0!==n?n:a._$Co=[])[s]=l:i._$Cl=l),void 0!==l&&(e=L(t,l._$AS(t,e.values),l,s)),e}class K{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var e;const{el:{content:i},parts:s}=this._$AD,r=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:C).importNode(i,!0);P.currentNode=r;let o=P.nextNode(),n=0,a=0,l=s[0];for(;void 0!==l;){if(n===l.index){let e;2===l.type?e=new H(o,o.nextSibling,this,t):1===l.type?e=new l.ctor(o,l.name,l.strings,this,t):6===l.type&&(e=new G(o,this,t)),this._$AV.push(e),l=s[++a]}n!==(null==l?void 0:l.index)&&(o=P.nextNode(),n++)}return P.currentNode=C,r}v(t){let e=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class H{constructor(t,e,i,s){var r;this.type=2,this._$AH=M,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cp=null===(r=null==s?void 0:s.isConnected)||void 0===r||r}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===(null==t?void 0:t.nodeType)&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=L(this,t,e),k(t)?t===M||null==t||""===t?(this._$AH!==M&&this._$AR(),this._$AH=M):t!==this._$AH&&t!==I&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>A(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!==M&&k(this._$AH)?this._$AA.nextSibling.data=t:this.$(C.createTextNode(t)),this._$AH=t}g(t){var e;const{values:i,_$litType$:s}=t,r="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=D.createElement(B(s.h,s.h[0]),this.options)),s);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.v(i);else{const t=new K(r,this),e=t.u(this.options);t.v(i),this.$(e),this._$AH=t}}_$AC(t){let e=N.get(t.strings);return void 0===e&&N.set(t.strings,e=new D(t)),e}T(t){A(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const r of t)s===e.length?e.push(i=new H(this.k(S()),this.k(S()),this,this.options)):i=e[s],i._$AI(r),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cp=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class q{constructor(t,e,i,s,r){this.type=1,this._$AH=M,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=M}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,s){const r=this.strings;let o=!1;if(void 0===r)t=L(this,t,e,0),o=!k(t)||t!==this._$AH&&t!==I,o&&(this._$AH=t);else{const s=t;let n,a;for(t=r[0],n=0;n<r.length-1;n++)a=L(this,s[i+n],e,n),a===I&&(a=this._$AH[n]),o||(o=!k(a)||a!==this._$AH[n]),a===M?t=M:t!==M&&(t+=(null!=a?a:"")+r[n+1]),this._$AH[n]=a}o&&!s&&this.j(t)}j(t){t===M?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class F extends q{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===M?void 0:t}}const W=m?m.emptyScript:"";class Z extends q{constructor(){super(...arguments),this.type=4}j(t){t&&t!==M?this.element.setAttribute(this.name,W):this.element.removeAttribute(this.name)}}class J extends q{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type=5}_$AI(t,e=this){var i;if((t=null!==(i=L(this,t,e,0))&&void 0!==i?i:M)===I)return;const s=this._$AH,r=t===M&&s!==M||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,o=t!==M&&(s===M||r);r&&this.element.removeEventListener(this.name,this,s),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==i?i:this.element,t):this._$AH.handleEvent(t)}}class G{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){L(this,t)}}const Q=g.litHtmlPolyfillSupport;
|
|
18
|
-
/**
|
|
19
|
-
* @license
|
|
20
|
-
* Copyright 2017 Google LLC
|
|
21
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
|
-
*/
|
|
23
|
-
var X;null==Q||Q(D,H),(null!==(b=g.litHtmlVersions)&&void 0!==b?b:g.litHtmlVersions=[]).push("2.8.0");const Y=window,tt=Y.trustedTypes,et=tt?tt.createPolicy("lit-html",{createHTML:t=>t}):void 0,it="$lit$",st=`lit$${(Math.random()+"").slice(9)}$`,rt="?"+st,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]",ct=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ut=/-->/g,vt=/>/g,pt=RegExp(`>|${dt}(?:([^\\s"'>=/]+)(${dt}*=${dt}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),ft=/'/g,bt=/"/g,gt=/^(?:script|style|textarea|title)$/i,mt=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),yt=Symbol.for("lit-noChange"),xt=Symbol.for("lit-nothing"),wt=new WeakMap,$t=nt.createTreeWalker(nt,129,null,!1);function Et(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==et?et.createHTML(e):e}const Ct=(t,e)=>{const i=t.length-1,s=[];let r,o=2===e?"<svg>":"",n=ct;for(let e=0;e<i;e++){const i=t[e];let a,l,h=-1,d=0;for(;d<i.length&&(n.lastIndex=d,l=n.exec(i),null!==l);)d=n.lastIndex,n===ct?"!--"===l[1]?n=ut:void 0!==l[1]?n=vt:void 0!==l[2]?(gt.test(l[2])&&(r=RegExp("</"+l[2],"g")),n=pt):void 0!==l[3]&&(n=pt):n===pt?">"===l[0]?(n=null!=r?r:ct,h=-1):void 0===l[1]?h=-2:(h=n.lastIndex-l[2].length,a=l[1],n=void 0===l[3]?pt:'"'===l[3]?bt:ft):n===bt||n===ft?n=pt:n===ut||n===vt?n=ct:(n=pt,r=void 0);const c=n===pt&&t[e+1].startsWith("/>")?" ":"";o+=n===ct?i+ot:h>=0?(s.push(a),i.slice(0,h)+it+i.slice(h)+st+c):i+st+(-2===h?(s.push(void 0),e):c)}return[Et(t,o+(t[i]||"<?>")+(2===e?"</svg>":"")),s]};class St{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let r=0,o=0;const n=t.length-1,a=this.parts,[l,h]=Ct(t,e);if(this.el=St.createElement(l,i),$t.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(s=$t.nextNode())&&a.length<n;){if(1===s.nodeType){if(s.hasAttributes()){const t=[];for(const e of s.getAttributeNames())if(e.endsWith(it)||e.startsWith(st)){const i=h[o++];if(t.push(e),void 0!==i){const t=s.getAttribute(i.toLowerCase()+it).split(st),e=/([.?@])?(.*)/.exec(i);a.push({type:1,index:r,name:e[2],strings:t,ctor:"."===e[1]?_t:"?"===e[1]?Ot:"@"===e[1]?Vt:zt})}else a.push({type:6,index:r})}for(const e of t)s.removeAttribute(e)}if(gt.test(s.tagName)){const t=s.textContent.split(st),e=t.length-1;if(e>0){s.textContent=tt?tt.emptyScript:"";for(let i=0;i<e;i++)s.append(t[i],at()),$t.nextNode(),a.push({type:2,index:++r});s.append(t[e],at())}}}else if(8===s.nodeType)if(s.data===rt)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=s.data.indexOf(st,t+1));)a.push({type:7,index:r}),t+=st.length-1}r++}}static createElement(t,e){const i=nt.createElement("template");return i.innerHTML=t,i}}function kt(t,e,i=t,s){var r,o,n,a;if(e===yt)return e;let l=void 0!==s?null===(r=i._$Co)||void 0===r?void 0:r[s]:i._$Cl;const h=lt(e)?void 0:e._$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,i,s)),void 0!==s?(null!==(n=(a=i)._$Co)&&void 0!==n?n:a._$Co=[])[s]=l:i._$Cl=l),void 0!==l&&(e=kt(t,l._$AS(t,e.values),l,s)),e}class At{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var e;const{el:{content:i},parts:s}=this._$AD,r=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:nt).importNode(i,!0);$t.currentNode=r;let o=$t.nextNode(),n=0,a=0,l=s[0];for(;void 0!==l;){if(n===l.index){let e;2===l.type?e=new Rt(o,o.nextSibling,this,t):1===l.type?e=new l.ctor(o,l.name,l.strings,this,t):6===l.type&&(e=new Ut(o,this,t)),this._$AV.push(e),l=s[++a]}n!==(null==l?void 0:l.index)&&(o=$t.nextNode(),n++)}return $t.currentNode=nt,r}v(t){let e=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class Rt{constructor(t,e,i,s){var r;this.type=2,this._$AH=xt,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cp=null===(r=null==s?void 0:s.isConnected)||void 0===r||r}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===(null==t?void 0:t.nodeType)&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=kt(this,t,e),lt(t)?t===xt||null==t||""===t?(this._$AH!==xt&&this._$AR(),this._$AH=xt):t!==this._$AH&&t!==yt&&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!==xt&<(this._$AH)?this._$AA.nextSibling.data=t:this.$(nt.createTextNode(t)),this._$AH=t}g(t){var e;const{values:i,_$litType$:s}=t,r="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=St.createElement(Et(s.h,s.h[0]),this.options)),s);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.v(i);else{const t=new At(r,this),e=t.u(this.options);t.v(i),this.$(e),this._$AH=t}}_$AC(t){let e=wt.get(t.strings);return void 0===e&&wt.set(t.strings,e=new St(t)),e}T(t){ht(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const r of t)s===e.length?e.push(i=new Rt(this.k(at()),this.k(at()),this,this.options)):i=e[s],i._$AI(r),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cp=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class zt{constructor(t,e,i,s,r){this.type=1,this._$AH=xt,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=xt}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,s){const r=this.strings;let o=!1;if(void 0===r)t=kt(this,t,e,0),o=!lt(t)||t!==this._$AH&&t!==yt,o&&(this._$AH=t);else{const s=t;let n,a;for(t=r[0],n=0;n<r.length-1;n++)a=kt(this,s[i+n],e,n),a===yt&&(a=this._$AH[n]),o||(o=!lt(a)||a!==this._$AH[n]),a===xt?t=xt:t!==xt&&(t+=(null!=a?a:"")+r[n+1]),this._$AH[n]=a}o&&!s&&this.j(t)}j(t){t===xt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class _t extends zt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===xt?void 0:t}}const Tt=tt?tt.emptyScript:"";class Ot extends zt{constructor(){super(...arguments),this.type=4}j(t){t&&t!==xt?this.element.setAttribute(this.name,Tt):this.element.removeAttribute(this.name)}}class Vt extends zt{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type=5}_$AI(t,e=this){var i;if((t=null!==(i=kt(this,t,e,0))&&void 0!==i?i:xt)===yt)return;const s=this._$AH,r=t===xt&&s!==xt||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,o=t!==xt&&(s===xt||r);r&&this.element.removeEventListener(this.name,this,s),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==i?i:this.element,t):this._$AH.handleEvent(t)}}class Ut{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){kt(this,t)}}const jt=Y.litHtmlPolyfillSupport;null==jt||jt(St,Rt),(null!==(X=Y.litHtmlVersions)&&void 0!==X?X:Y.litHtmlVersions=[]).push("2.8.0");
|
|
24
|
-
/**
|
|
25
|
-
* @license
|
|
26
|
-
* Copyright 2017 Google LLC
|
|
27
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
28
|
-
*/
|
|
29
|
-
var It,Mt;class Nt extends f{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,i)=>{var s,r;const o=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:e;let n=o._$litPart$;if(void 0===n){const t=null!==(r=null==i?void 0:i.renderBefore)&&void 0!==r?r:null;o._$litPart$=n=new Rt(e.insertBefore(at(),t),t,void 0,null!=i?i:{})}return n._$AI(t),n})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return yt}}Nt.finalized=!0,Nt._$litElement$=!0,null===(It=globalThis.litElementHydrateSupport)||void 0===It||It.call(globalThis,{LitElement:Nt});const Pt=globalThis.litElementPolyfillSupport;null==Pt||Pt({LitElement:Nt}),(null!==(Mt=globalThis.litElementVersions)&&void 0!==Mt?Mt:globalThis.litElementVersions=[]).push("3.3.3");
|
|
30
|
-
/**
|
|
31
|
-
* @license
|
|
32
|
-
* Copyright 2017 Google LLC
|
|
33
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
34
|
-
*/
|
|
35
|
-
const Bt=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(i){i.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}},Dt=(t,e,i)=>{e.constructor.createProperty(i,t)};
|
|
36
|
-
/**
|
|
37
|
-
* @license
|
|
38
|
-
* Copyright 2017 Google LLC
|
|
39
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
40
|
-
*/function Lt(t){return(e,i)=>void 0!==i?Dt(t,e,i):Bt(t,e)
|
|
41
|
-
/**
|
|
42
|
-
* @license
|
|
43
|
-
* Copyright 2017 Google LLC
|
|
44
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
45
|
-
*/}function Kt(t){return Lt({...t,state:!0})}
|
|
46
|
-
/**
|
|
47
|
-
* @license
|
|
48
|
-
* Copyright 2017 Google LLC
|
|
49
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
50
|
-
*/
|
|
51
|
-
/**
|
|
52
|
-
* @license
|
|
53
|
-
* Copyright 2021 Google LLC
|
|
54
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
55
|
-
*/
|
|
56
|
-
var Ht;null===(Ht=window.HTMLSlotElement)||void 0===Ht||Ht.prototype.assignedElements;const qt=((t,...e)=>{const s=1===t.length?t[0]:e.reduce(((e,i,s)=>e+(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.")})(i)+t[s+1]),t[0]);return new r(s,t,i)})`
|
|
1
|
+
import{css as t,LitElement as e,html as r}from"lit";import{query as a,property as i,state as o,customElement as s}from"lit/decorators.js";import{NuralyUIBaseMixin as n}from"@nuralyui/common/mixins";const l=t`
|
|
57
2
|
:host {
|
|
58
3
|
display: block;
|
|
59
4
|
position: relative;
|
|
@@ -379,33 +324,33 @@ var Ht;null===(Ht=window.HTMLSlotElement)||void 0===Ht||Ht.prototype.assignedEle
|
|
|
379
324
|
* ======================================== */
|
|
380
325
|
|
|
381
326
|
/* No theme-specific overrides - themes handle styling through CSS variables */
|
|
382
|
-
`,
|
|
327
|
+
`,d=3,h=50;
|
|
383
328
|
/**
|
|
384
329
|
* @license
|
|
385
330
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
386
331
|
* SPDX-License-Identifier: MIT
|
|
387
332
|
*/
|
|
388
|
-
class
|
|
333
|
+
class c{constructor(t){this._host=t,this._host.addController(this)}get host(){return this._host}hostConnected(){}hostDisconnected(){}hostUpdated(){}hostUpdate(){}handleError(t,e){console.error(`[${this.constructor.name}] Error in ${e}:`,t);const r=new CustomEvent("textarea-controller-error",{detail:{error:t.message,context:e,controller:this.constructor.name},bubbles:!0,composed:!0});this._host.dispatchEvent(r)}safeExecute(t,e,r){try{return t()}catch(t){return this.handleError(t,e),r}}requestHostUpdate(){this.safeExecute((()=>this._host.requestUpdate()),"requestHostUpdate")}debounce(t,e){let r;return(...a)=>{clearTimeout(r),r=setTimeout((()=>t.apply(this,a)),e)}}}
|
|
389
334
|
/**
|
|
390
335
|
* @license
|
|
391
336
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
392
337
|
* SPDX-License-Identifier: MIT
|
|
393
|
-
*/var
|
|
338
|
+
*/var u=function(t,e,r,a){return new(r||(r=Promise))((function(i,o){function s(t){try{l(a.next(t))}catch(t){o(t)}}function n(t){try{l(a.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,n)}l((a=a.apply(t,e||[])).next())}))};class v extends c{constructor(t){super(t),this._validationDebounceMs=300}get validationHost(){return this._host}get validationResult(){return this._validationResult}setValidationDebounce(t){this._validationDebounceMs=t}validate(t){return u(this,void 0,void 0,(function*(){const e=null!=t?t:this.validationHost.value,r=this.validationHost.rules||[];if(0===r.length)return this._validationResult=void 0,{isValid:!0,messages:[],level:"success",blocking:!1};const a=[];let i=!1,o=!1,s=!1;for(const t of r)try{(yield t.validator(e))||(a.push(t.message),"error"!==t.level&&t.level?"warning"===t.level&&(o=!0):(i=!0,!1!==t.blocking&&(s=!0)))}catch(t){this.handleError(t,"validation"),a.push(`Validation error: ${t}`),i=!0,s=!0}const n=i?"error":o?"warning":"success";return this._validationResult={isValid:!i&&!o,messages:a,level:n,blocking:s},this.updateHostValidationState(),this.dispatchValidationEvent(),this._validationResult}))}validateDebounced(t){return new Promise((e=>{this._validationTimeout&&clearTimeout(this._validationTimeout),this._validationTimeout=setTimeout((()=>u(this,void 0,void 0,(function*(){const r=yield this.validate(t);e(r)}))),this._validationDebounceMs)}))}validateOnChangeIfEnabled(t){return u(this,void 0,void 0,(function*(){if(this.validationHost.validateOnChange&&(this.validationHost.rules||[]).length>0)return yield this.validateDebounced(t)}))}validateOnBlurIfEnabled(t){return u(this,void 0,void 0,(function*(){if(this.validationHost.validateOnBlur&&(this.validationHost.rules||[]).length>0)return yield this.validate(t)}))}clearValidation(){this._validationResult=void 0,this._validationTimeout&&(clearTimeout(this._validationTimeout),this._validationTimeout=void 0),"default"!==this.validationHost.state&&(this.validationHost.state="default",this.requestHostUpdate()),this.dispatchValidationEvent()}isValid(){var t,e;return null===(e=null===(t=this._validationResult)||void 0===t?void 0:t.isValid)||void 0===e||e}isBlocking(){var t,e;return null!==(e=null===(t=this._validationResult)||void 0===t?void 0:t.blocking)&&void 0!==e&&e}getValidationMessages(){var t,e;return null!==(e=null===(t=this._validationResult)||void 0===t?void 0:t.messages)&&void 0!==e?e:[]}addRule(t){const e=this.validationHost.rules||[];e.push(t),this.validationHost.rules=e,this.requestHostUpdate()}removeRule(t){const e=this.validationHost.rules||[];this.validationHost.rules=e.filter((e=>!t(e))),this.requestHostUpdate()}clearRules(){this.validationHost.rules=[],this.clearValidation()}static createRequiredRule(t="This field is required"){return{validator:t=>t.trim().length>0,message:t,level:"error",blocking:!0}}static createMinLengthRule(t,e){return{validator:e=>e.length>=t,message:e||`Minimum ${t} characters required`,level:"error",blocking:!0}}static createMaxLengthRule(t,e){return{validator:e=>e.length<=t,message:e||`Maximum ${t} characters allowed`,level:"error",blocking:!0}}static createPatternRule(t,e){return{validator:e=>t.test(e),message:e,level:"error",blocking:!0}}updateHostValidationState(){if(!this._validationResult)return;const{level:t}=this._validationResult;"error"===t?this.validationHost.state="error":"warning"===t?this.validationHost.state="warning":this.validationHost.rules.length>0&&(this.validationHost.state="success"),this.requestHostUpdate()}dispatchValidationEvent(){var t,e,r,a,i,o,s,n;const l={isValid:null===(e=null===(t=this._validationResult)||void 0===t?void 0:t.isValid)||void 0===e||e,validationMessage:null!==(a=null===(r=this._validationResult)||void 0===r?void 0:r.messages.join(", "))&&void 0!==a?a:"",errors:null!==(o=null===(i=this._validationResult)||void 0===i?void 0:i.messages.filter((()=>{var t;return"error"===(null===(t=this._validationResult)||void 0===t?void 0:t.level)})))&&void 0!==o?o:[],warnings:null!==(n=null===(s=this._validationResult)||void 0===s?void 0:s.messages.filter((()=>{var t;return"warning"===(null===(t=this._validationResult)||void 0===t?void 0:t.level)})))&&void 0!==n?n:[],validationResult:this._validationResult||{isValid:!0,messages:[],level:"success",blocking:!1}},d=new CustomEvent("textarea-validation",{detail:l,bubbles:!0,composed:!0});this.safeExecute((()=>this._host.dispatchEvent(d)),"dispatchValidationEvent")}hostDisconnected(){this._validationTimeout&&(clearTimeout(this._validationTimeout),this._validationTimeout=void 0)}}
|
|
394
339
|
/**
|
|
395
340
|
* @license
|
|
396
341
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
397
342
|
* SPDX-License-Identifier: MIT
|
|
398
|
-
*/class
|
|
343
|
+
*/class p extends c{constructor(t){super(t),this._hasFocus=!1,this._inputDebounceMs=150}get eventHost(){return this._host}get hasFocus(){return this._hasFocus}setInputDebounce(t){this._inputDebounceMs=t}hostConnected(){super.hostConnected(),this.setupEventListeners()}hostDisconnected(){super.hostDisconnected(),this.cleanupEventListeners()}setupEventListeners(){this.safeExecute((()=>{var t,e;const r=this._host;this._textareaElement=null===(t=r.shadowRoot)||void 0===t?void 0:t.querySelector("textarea"),this._clearButtonElement=null===(e=r.shadowRoot)||void 0===e?void 0:e.querySelector(".clear-button"),this._textareaElement&&this.addTextareaEventListeners(),this._clearButtonElement&&this.eventHost.clearable&&this.addClearButtonEventListeners()}),"setupEventListeners")}cleanupEventListeners(){this._inputTimeout&&(clearTimeout(this._inputTimeout),this._inputTimeout=void 0)}handleInput(t){if(this.eventHost.readonly||this.eventHost.disabled)return;const e=t.target,r=e.value;this._inputTimeout&&clearTimeout(this._inputTimeout),this.eventHost.value=r,this.eventHost.autoResize&&this.handleAutoResize(e),this._inputTimeout=setTimeout((()=>{this.dispatchInputEvent(r,t)}),this._inputDebounceMs),this.requestHostUpdate()}handleFocus(t){this.eventHost.disabled||(this._hasFocus=!0,this.requestHostUpdate(),this.dispatchFocusEvent(t))}handleBlur(t){this._hasFocus=!1,this.requestHostUpdate(),this.dispatchBlurEvent(t)}handleKeyDown(t){if(this.eventHost.readonly||this.eventHost.disabled)return;const{key:e,ctrlKey:r,metaKey:a}=t;"Escape"!==e?"Enter"!==e||!r&&!a?this.dispatchKeydownEvent(t):this.handleSubmit(t):this.handleEscape(t)}handleKeyUp(t){this.dispatchKeyupEvent(t)}handlePaste(t){this.eventHost.readonly||this.eventHost.disabled?t.preventDefault():this.dispatchPasteEvent(t)}handleClear(t){if(this.eventHost.readonly||this.eventHost.disabled)return;const e=this.eventHost.value;this.eventHost.value="",this._textareaElement&&this._textareaElement.focus(),this.requestHostUpdate(),this.dispatchClearEvent(e,t)}handleAutoResize(t){if(!this.eventHost.autoResize)return;const e=t||this._textareaElement;e&&this.safeExecute((()=>{e.style.height="auto",e.style.height=`${e.scrollHeight}px`}),"handleAutoResize")}focus(){this.safeExecute((()=>{var t;null===(t=this._textareaElement)||void 0===t||t.focus()}),"focus")}blur(){this.safeExecute((()=>{var t;null===(t=this._textareaElement)||void 0===t||t.blur()}),"blur")}selectAll(){this.safeExecute((()=>{var t;null===(t=this._textareaElement)||void 0===t||t.select()}),"selectAll")}setCursorPosition(t){this.safeExecute((()=>{this._textareaElement&&this._textareaElement.setSelectionRange(t,t)}),"setCursorPosition")}getCursorPosition(){var t,e;return null!==(e=null===(t=this._textareaElement)||void 0===t?void 0:t.selectionStart)&&void 0!==e?e:0}addTextareaEventListeners(){if(!this._textareaElement)return;const t=this._textareaElement;t.addEventListener("input",this.handleInput.bind(this)),t.addEventListener("focus",this.handleFocus.bind(this)),t.addEventListener("blur",this.handleBlur.bind(this)),t.addEventListener("keydown",this.handleKeyDown.bind(this)),t.addEventListener("keyup",this.handleKeyUp.bind(this)),t.addEventListener("paste",this.handlePaste.bind(this))}addClearButtonEventListeners(){this._clearButtonElement&&this._clearButtonElement.addEventListener("click",this.handleClear.bind(this))}handleEscape(t){this.blur(),this.dispatchEscapeEvent(t)}handleSubmit(t){this.dispatchSubmitEvent(t)}dispatchInputEvent(t,e){const r=new CustomEvent("textarea-input",{detail:{value:t,originalEvent:e,cursorPosition:this.getCursorPosition()},bubbles:!0,composed:!0});this.safeExecute((()=>this._host.dispatchEvent(r)),"dispatchInputEvent")}dispatchFocusEvent(t){const e=new CustomEvent("textarea-focus",{detail:{originalEvent:t,value:this.eventHost.value},bubbles:!0,composed:!0});this.safeExecute((()=>this._host.dispatchEvent(e)),"dispatchFocusEvent")}dispatchBlurEvent(t){const e=new CustomEvent("textarea-blur",{detail:{originalEvent:t,value:this.eventHost.value},bubbles:!0,composed:!0});this.safeExecute((()=>this._host.dispatchEvent(e)),"dispatchBlurEvent")}dispatchKeydownEvent(t){const e=new CustomEvent("textarea-keydown",{detail:{originalEvent:t,key:t.key,ctrlKey:t.ctrlKey,metaKey:t.metaKey,value:this.eventHost.value},bubbles:!0,composed:!0});this.safeExecute((()=>this._host.dispatchEvent(e)),"dispatchKeydownEvent")}dispatchKeyupEvent(t){const e=new CustomEvent("textarea-keyup",{detail:{originalEvent:t,key:t.key,value:this.eventHost.value},bubbles:!0,composed:!0});this.safeExecute((()=>this._host.dispatchEvent(e)),"dispatchKeyupEvent")}dispatchPasteEvent(t){const e=new CustomEvent("textarea-paste",{detail:{originalEvent:t,value:this.eventHost.value},bubbles:!0,composed:!0});this.safeExecute((()=>this._host.dispatchEvent(e)),"dispatchPasteEvent")}dispatchClearEvent(t,e){const r=new CustomEvent("textarea-clear",{detail:{previousValue:t,originalEvent:e,value:this.eventHost.value},bubbles:!0,composed:!0});this.safeExecute((()=>this._host.dispatchEvent(r)),"dispatchClearEvent")}dispatchEscapeEvent(t){const e=new CustomEvent("textarea-escape",{detail:{originalEvent:t,value:this.eventHost.value},bubbles:!0,composed:!0});this.safeExecute((()=>this._host.dispatchEvent(e)),"dispatchEscapeEvent")}dispatchSubmitEvent(t){const e=new CustomEvent("textarea-submit",{detail:{originalEvent:t,value:this.eventHost.value},bubbles:!0,composed:!0});this.safeExecute((()=>this._host.dispatchEvent(e)),"dispatchSubmitEvent")}}
|
|
399
344
|
/**
|
|
400
345
|
* @license
|
|
401
346
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
402
347
|
* SPDX-License-Identifier: MIT
|
|
403
|
-
*/var
|
|
348
|
+
*/var b=function(t,e,r,a){for(var i,o=arguments.length,s=o<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,r):a,n=t.length-1;n>=0;n--)(i=t[n])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},x=function(t,e,r,a){return new(r||(r=Promise))((function(i,o){function s(t){try{l(a.next(t))}catch(t){o(t)}}function n(t){try{l(a.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,n)}l((a=a.apply(t,e||[])).next())}))};let f=class extends(n(e)){constructor(){super(),this.validationController=new v(this),this.eventController=new p(this),this.disabled=!1,this.readonly=!1,this.state="default",this.value="",this.size="medium",this.variant="underlined",this.resize="vertical",this.rows=d,this.cols=h,this.placeholder="",this.autocomplete="off",this.allowClear=!1,this.showCount=!1,this.autoResize=!1,this.rules=[],this.validateOnChange=!0,this.validateOnBlur=!0,this.hasFeedback=!1,this.isFocused=!1,this.characterCount=0,this.characterCount=this.value.length,this.setupControllerListeners()}get clearable(){return this.allowClear}setupControllerListeners(){this.addEventListener("textarea-validation",(t=>{this.validationResult=t.detail.validationResult})),this.addEventListener("textarea-input",(t=>{this.handleControllerInput(t.detail.value)})),this.addEventListener("textarea-focus",(()=>{this.isFocused=!0})),this.addEventListener("textarea-blur",(()=>{this.isFocused=!1,this.validateOnBlur&&this.validationController.validateOnBlurIfEnabled()})),this.addEventListener("textarea-clear",(t=>{this.handleControllerClear(t.detail.previousValue)}))}handleControllerInput(t){this.maxLength&&t.length>this.maxLength?this.value=t.slice(0,this.maxLength):this.value=t,this.characterCount=this.value.length,this.autoResizeIfNeeded(),this.dispatchChangeEvent(),this.validateOnChange&&this.validationController.validateOnChangeIfEnabled(this.value)}handleControllerClear(t){this.characterCount=0,this.dispatchChangeEvent(),this.dispatchEvent(new CustomEvent("nr-clear",{detail:{value:this.value,previousValue:t},bubbles:!0}))}connectedCallback(){super.connectedCallback(),this.setupResizeObserver()}disconnectedCallback(){super.disconnectedCallback(),this.cleanupResizeObserver()}firstUpdated(t){super.firstUpdated(t),this.updateTextareaValue(),this.autoResizeIfNeeded(),this.resizeObserver&&this.textareaElement&&this.resizeObserver.observe(this.textareaElement),this.eventController.setupEventListeners()}updated(t){super.updated(t),t.has("value")&&(this.characterCount=this.value.length,this.updateTextareaValue(),this.autoResizeIfNeeded()),t.has("autoResize")&&this.autoResizeIfNeeded(),t.has("rules")&&(this.validationController.clearValidation(),this.rules.length>0&&this.value&&this.validationController.validate(this.value))}setupResizeObserver(){"undefined"!=typeof ResizeObserver&&(this.resizeObserver=new ResizeObserver((t=>{for(const e of t){const{width:t,height:r}=e.contentRect;this.dispatchResizeEvent(t,r)}})))}cleanupResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=void 0)}updateTextareaValue(){this.textareaElement&&this.textareaElement.value!==this.value&&(this.textareaElement.value=this.value)}autoResizeIfNeeded(){if(!this.autoResize||!this.textareaElement)return;this.textareaElement.style.height="auto";let t=this.textareaElement.scrollHeight;this.minHeight&&t<this.minHeight&&(t=this.minHeight),this.maxHeight&&t>this.maxHeight&&(t=this.maxHeight),this.textareaElement.style.height=`${t}px`}handleInput(t){this.eventController.handleInput(t)}handleFocus(t){this.eventController.handleFocus(t),this.dispatchEvent(new CustomEvent("nr-focus",{detail:{focused:!0,originalEvent:t},bubbles:!0}))}handleBlur(t){this.eventController.handleBlur(t),this.dispatchEvent(new CustomEvent("nr-blur",{detail:{focused:!1,originalEvent:t},bubbles:!0}))}handleClear(){this.eventController.handleClear()}dispatchChangeEvent(){const t={value:this.value,length:this.characterCount,exceedsMaxLength:!!this.maxLength&&this.characterCount>this.maxLength,validation:this.validationResult};this.dispatchEvent(new CustomEvent("nr-textarea-change",{detail:t,bubbles:!0}))}dispatchResizeEvent(t,e){const r={width:t,height:e,direction:this.resize};this.dispatchEvent(new CustomEvent("nr-resize",{detail:r,bubbles:!0}))}focus(t){this.eventController.focus(),(void 0!==(null==t?void 0:t.cursor)||(null==t?void 0:t.select))&&setTimeout((()=>{this.textareaElement&&(void 0!==(null==t?void 0:t.cursor)?"number"==typeof t.cursor?this.eventController.setCursorPosition(t.cursor):"start"===t.cursor?this.eventController.setCursorPosition(0):"end"===t.cursor?this.eventController.setCursorPosition(this.value.length):"all"===t.cursor&&this.eventController.selectAll():(null==t?void 0:t.select)&&this.eventController.selectAll())}))}blur(){this.eventController.blur()}getValidationResult(){return this.validationController.validationResult}validate(){return x(this,void 0,void 0,(function*(){return(yield this.validationController.validate(this.value)).isValid}))}clearValidation(){this.validationController.clearValidation()}clear(){this.eventController.handleClear()}addRule(t){this.validationController.addRule(t)}removeRule(t){this.validationController.removeRule(t)}clearRules(){this.validationController.clearRules()}getValidationStatus(){var t;const e=this.validationController.validationResult;return{isValid:null===(t=null==e?void 0:e.isValid)||void 0===t||t,errors:"error"===(null==e?void 0:e.level)?e.messages:[],warnings:"warning"===(null==e?void 0:e.level)?e.messages:[]}}isValid(){return this.validationController.isValid()}checkValidity(){return this.validationController.isValid()}reportValidity(){const t=this.validationController.isValid();return t||this.validationController.validate(this.value),t}setCustomValidity(t){t?this.validationController.addRule({validator:()=>!1,message:t,level:"error",blocking:!0}):this.validationController.removeRule((e=>e.message===t))}validateTextarea(){return x(this,void 0,void 0,(function*(){return(yield this.validationController.validate(this.value)).isValid}))}setValidationStatus(t){this.validationResult=t,"error"===t.level?this.state="error":"warning"===t.level?this.state="warning":t.isValid&&(this.state="success"),this.requestUpdate()}renderLabel(){return r`
|
|
404
349
|
<div class="textarea-label">
|
|
405
350
|
<slot name="label"></slot>
|
|
406
|
-
${this.required?
|
|
351
|
+
${this.required?r`<span class="required-indicator">*</span>`:""}
|
|
407
352
|
</div>
|
|
408
|
-
`}renderTextarea(){return
|
|
353
|
+
`}renderTextarea(){return r`
|
|
409
354
|
<textarea
|
|
410
355
|
class="textarea-element"
|
|
411
356
|
.value=${this.value}
|
|
@@ -423,13 +368,13 @@ class Xt{constructor(t){this._host=t,this._host.addController(this)}get host(){r
|
|
|
423
368
|
@focus=${this.handleFocus}
|
|
424
369
|
@blur=${this.handleBlur}
|
|
425
370
|
></textarea>
|
|
426
|
-
`}renderValidationIcon(){if(!this.hasFeedback||!this.validationResult)return"";const t="error"===this.validationResult.level?"error":"warning"===this.validationResult.level?"warning":"check-circle";return
|
|
371
|
+
`}renderValidationIcon(){if(!this.hasFeedback||!this.validationResult)return"";const t="error"===this.validationResult.level?"error":"warning"===this.validationResult.level?"warning":"check-circle";return r`
|
|
427
372
|
<nr-icon
|
|
428
373
|
class="validation-icon ${this.validationResult.level}"
|
|
429
374
|
name="${t}"
|
|
430
375
|
size="small"
|
|
431
376
|
></nr-icon>
|
|
432
|
-
`}renderClearButton(){return!this.allowClear||!this.value||this.disabled||this.readonly?"":
|
|
377
|
+
`}renderClearButton(){return!this.allowClear||!this.value||this.disabled||this.readonly?"":r`
|
|
433
378
|
<button
|
|
434
379
|
class="clear-button"
|
|
435
380
|
type="button"
|
|
@@ -438,15 +383,15 @@ class Xt{constructor(t){this._host=t,this._host.addController(this)}get host(){r
|
|
|
438
383
|
>
|
|
439
384
|
<nr-icon name="x" size="small"></nr-icon>
|
|
440
385
|
</button>
|
|
441
|
-
`}renderCharacterCount(){if(!this.showCount)return"";const t=this.maxLength?` / ${this.maxLength}`:"",e=this.maxLength&&this.characterCount>this.maxLength;return
|
|
386
|
+
`}renderCharacterCount(){if(!this.showCount)return"";const t=this.maxLength?` / ${this.maxLength}`:"",e=this.maxLength&&this.characterCount>this.maxLength;return r`
|
|
442
387
|
<div class="character-count ${e?"over-limit":""}">
|
|
443
388
|
${this.characterCount}${t}
|
|
444
389
|
</div>
|
|
445
|
-
`}renderHelperText(){var t,e;const
|
|
390
|
+
`}renderHelperText(){var t,e;const a=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('slot[name="helper-text"]'),i=null==a?void 0:a.assignedNodes().length,o=null===(e=this.validationResult)||void 0===e?void 0:e.messages.length;return i||o?r`
|
|
446
391
|
<div class="helper-text">
|
|
447
|
-
${
|
|
392
|
+
${o?this.validationResult.messages.map((t=>r`<div class="validation-message ${this.validationResult.level}">${t}</div>`)):r`<slot name="helper-text"></slot>`}
|
|
448
393
|
</div>
|
|
449
|
-
`:""}render(){const t=["textarea-container",`size-${this.size}`,`variant-${this.variant}`,`state-${this.state}`,this.isFocused?"focused":"",this.disabled?"disabled":"",this.readonly?"readonly":"",this.validationResult?`validation-${this.validationResult.level}`:""].filter(Boolean).join(" ");return
|
|
394
|
+
`:""}render(){const t=["textarea-container",`size-${this.size}`,`variant-${this.variant}`,`state-${this.state}`,this.isFocused?"focused":"",this.disabled?"disabled":"",this.readonly?"readonly":"",this.validationResult?`validation-${this.validationResult.level}`:""].filter(Boolean).join(" ");return r`
|
|
450
395
|
<div class="${t}">
|
|
451
396
|
${this.renderLabel()}
|
|
452
397
|
|
|
@@ -471,10 +416,4 @@ class Xt{constructor(t){this._host=t,this._host.addController(this)}get host(){r
|
|
|
471
416
|
${this.renderCharacterCount()}
|
|
472
417
|
</div>
|
|
473
418
|
</div>
|
|
474
|
-
`}};
|
|
475
|
-
/**
|
|
476
|
-
* @license
|
|
477
|
-
* Copyright 2017 Google LLC
|
|
478
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
479
|
-
*/
|
|
480
|
-
function(t,e){return(({finisher:t,descriptor:e})=>(i,s)=>{var r;if(void 0===s){const s=null!==(r=i.originalKey)&&void 0!==r?r:i.key,o=null!=e?{kind:"method",placement:"prototype",key:s,descriptor:e(i.key)}:{...i,key:s};return null!=t&&(o.finisher=function(e){t(e,s)}),o}{const r=i.constructor;void 0!==e&&Object.defineProperty(i,s,e(s)),null==t||t(r,s)}})({descriptor:i=>{const s={get(){var e,i;return null!==(i=null===(e=this.renderRoot)||void 0===e?void 0:e.querySelector(t))&&void 0!==i?i:null},enumerable:!0,configurable:!0};if(e){const e="symbol"==typeof i?Symbol():"__"+i;s.get=function(){var i,s;return void 0===this[e]&&(this[e]=null!==(s=null===(i=this.renderRoot)||void 0===i?void 0:i.querySelector(t))&&void 0!==s?s:null),this[e]}}return s}})}("textarea")],re.prototype,"textareaElement",void 0),ie([Lt({type:Boolean,reflect:!0})],re.prototype,"disabled",void 0),ie([Lt({type:Boolean,reflect:!0})],re.prototype,"readonly",void 0),ie([Lt({type:String,reflect:!0})],re.prototype,"state",void 0),ie([Lt({type:String})],re.prototype,"value",void 0),ie([Lt({type:String})],re.prototype,"size",void 0),ie([Lt({type:String,reflect:!0})],re.prototype,"variant",void 0),ie([Lt({type:String})],re.prototype,"resize",void 0),ie([Lt({type:Number})],re.prototype,"rows",void 0),ie([Lt({type:Number})],re.prototype,"cols",void 0),ie([Lt({type:String})],re.prototype,"placeholder",void 0),ie([Lt({type:String})],re.prototype,"autocomplete",void 0),ie([Lt({type:String})],re.prototype,"name",void 0),ie([Lt({type:Boolean})],re.prototype,"required",void 0),ie([Lt({type:Boolean,reflect:!0})],re.prototype,"allowClear",void 0),ie([Lt({type:Boolean,reflect:!0})],re.prototype,"showCount",void 0),ie([Lt({type:Number})],re.prototype,"maxLength",void 0),ie([Lt({type:Number})],re.prototype,"minHeight",void 0),ie([Lt({type:Number})],re.prototype,"maxHeight",void 0),ie([Lt({type:Boolean})],re.prototype,"autoResize",void 0),ie([Lt({type:Array})],re.prototype,"rules",void 0),ie([Lt({type:Boolean,attribute:"validate-on-change"})],re.prototype,"validateOnChange",void 0),ie([Lt({type:Boolean,attribute:"validate-on-blur"})],re.prototype,"validateOnBlur",void 0),ie([Lt({type:Boolean,attribute:"has-feedback"})],re.prototype,"hasFeedback",void 0),ie([Lt({type:String,attribute:"validation-message"})],re.prototype,"validationMessage",void 0),ie([Kt()],re.prototype,"isFocused",void 0),ie([Kt()],re.prototype,"validationResult",void 0),ie([Kt()],re.prototype,"characterCount",void 0),re=ie([(t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:i,elements:s}=e;return{kind:i,elements:s,finisher(e){customElements.define(t,e)}}})(t,e))("nr-textarea")],re);export{re as NrTextareaElement};
|
|
419
|
+
`}};f.styles=l,b([a("textarea")],f.prototype,"textareaElement",void 0),b([i({type:Boolean,reflect:!0})],f.prototype,"disabled",void 0),b([i({type:Boolean,reflect:!0})],f.prototype,"readonly",void 0),b([i({type:String,reflect:!0})],f.prototype,"state",void 0),b([i({type:String})],f.prototype,"value",void 0),b([i({type:String})],f.prototype,"size",void 0),b([i({type:String,reflect:!0})],f.prototype,"variant",void 0),b([i({type:String})],f.prototype,"resize",void 0),b([i({type:Number})],f.prototype,"rows",void 0),b([i({type:Number})],f.prototype,"cols",void 0),b([i({type:String})],f.prototype,"placeholder",void 0),b([i({type:String})],f.prototype,"autocomplete",void 0),b([i({type:String})],f.prototype,"name",void 0),b([i({type:Boolean})],f.prototype,"required",void 0),b([i({type:Boolean,reflect:!0})],f.prototype,"allowClear",void 0),b([i({type:Boolean,reflect:!0})],f.prototype,"showCount",void 0),b([i({type:Number})],f.prototype,"maxLength",void 0),b([i({type:Number})],f.prototype,"minHeight",void 0),b([i({type:Number})],f.prototype,"maxHeight",void 0),b([i({type:Boolean})],f.prototype,"autoResize",void 0),b([i({type:Array})],f.prototype,"rules",void 0),b([i({type:Boolean,attribute:"validate-on-change"})],f.prototype,"validateOnChange",void 0),b([i({type:Boolean,attribute:"validate-on-blur"})],f.prototype,"validateOnBlur",void 0),b([i({type:Boolean,attribute:"has-feedback"})],f.prototype,"hasFeedback",void 0),b([i({type:String,attribute:"validation-message"})],f.prototype,"validationMessage",void 0),b([o()],f.prototype,"isFocused",void 0),b([o()],f.prototype,"validationResult",void 0),b([o()],f.prototype,"characterCount",void 0),f=b([s("nr-textarea")],f);export{f as NrTextareaElement};
|