@nuralyui/textarea 0.1.2 → 0.1.3
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 +5 -463
- package/package.json +1 -1
package/bundle.js
CHANGED
|
@@ -1,480 +1,22 @@
|
|
|
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)})`
|
|
57
|
-
:host {
|
|
58
|
-
display: block;
|
|
59
|
-
position: relative;
|
|
60
|
-
font-family: var(--nuraly-font-family-textarea, Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.textarea-container {
|
|
64
|
-
display: flex;
|
|
65
|
-
flex-direction: column;
|
|
66
|
-
gap: var(--nuraly-spacing-textarea-gap, 8px);
|
|
67
|
-
width: 100%;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.textarea-label {
|
|
71
|
-
display: flex;
|
|
72
|
-
align-items: center;
|
|
73
|
-
gap: 4px;
|
|
74
|
-
font-size: var(--nuraly-font-size-textarea, 16px);
|
|
75
|
-
font-weight: 500;
|
|
76
|
-
color: var(--nuraly-color-textarea-label, #262626);
|
|
77
|
-
line-height: var(--nuraly-line-height-textarea, 1.5);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.required-indicator {
|
|
81
|
-
color: var(--nuraly-color-textarea-error, #ef4444);
|
|
82
|
-
font-weight: 600;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.textarea-wrapper {
|
|
86
|
-
display: flex;
|
|
87
|
-
align-items: flex-start;
|
|
88
|
-
gap: var(--nuraly-spacing-textarea-gap, 8px);
|
|
89
|
-
position: relative;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.addon-before,
|
|
93
|
-
.addon-after {
|
|
94
|
-
display: flex;
|
|
95
|
-
align-items: flex-start;
|
|
96
|
-
padding-top: var(--nuraly-padding-textarea, 12px);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.textarea-input-container {
|
|
100
|
-
position: relative;
|
|
101
|
-
flex: 1;
|
|
102
|
-
display: flex;
|
|
103
|
-
align-items: flex-start;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.textarea-element {
|
|
107
|
-
width: 100%;
|
|
108
|
-
min-height: 80px;
|
|
109
|
-
padding: var(--nuraly-padding-textarea, 12px);
|
|
110
|
-
border-top: var(--nuraly-border-width-textarea, 1px) solid var(--nuraly-color-textarea-border, #d9d9d9);
|
|
111
|
-
border-left: var(--nuraly-border-width-textarea, 1px) solid var(--nuraly-color-textarea-border, #d9d9d9);
|
|
112
|
-
border-right: var(--nuraly-border-width-textarea, 1px) solid var(--nuraly-color-textarea-border, #d9d9d9);
|
|
113
|
-
border-bottom: var(--nuraly-border-width-textarea, 1px) solid var(--nuraly-color-textarea-border-bottom, var(--nuraly-color-textarea-border, #d9d9d9));
|
|
114
|
-
border-radius: var(--nuraly-border-radius-textarea, 6px);
|
|
115
|
-
background-color: var(--nuraly-color-textarea-background, #ffffff);
|
|
116
|
-
color: var(--nuraly-color-textarea-text, #262626);
|
|
117
|
-
font-family: var(--nuraly-font-family-textarea, Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif);
|
|
118
|
-
font-size: var(--nuraly-font-size-textarea, 16px);
|
|
119
|
-
line-height: var(--nuraly-line-height-textarea, 1.5);
|
|
120
|
-
outline: none;
|
|
121
|
-
transition: border-color 0.2s ease-in-out;
|
|
122
|
-
box-sizing: border-box;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.textarea-element::placeholder {
|
|
126
|
-
color: var(--nuraly-color-textarea-placeholder, #8c8c8c);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
.textarea-element:hover:not(:disabled):not(:focus) {
|
|
130
|
-
border-top-color: var(--nuraly-color-textarea-border-hover, #7c3aed);
|
|
131
|
-
border-left-color: var(--nuraly-color-textarea-border-hover, #7c3aed);
|
|
132
|
-
border-right-color: var(--nuraly-color-textarea-border-hover, #7c3aed);
|
|
133
|
-
border-bottom-color: var(--nuraly-color-textarea-border-hover, #7c3aed);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.textarea-element:focus {
|
|
137
|
-
border-top-color: var(--nuraly-color-textarea-border-focus, #7c3aed);
|
|
138
|
-
border-left-color: var(--nuraly-color-textarea-border-focus, #7c3aed);
|
|
139
|
-
border-right-color: var(--nuraly-color-textarea-border-focus, #7c3aed);
|
|
140
|
-
border-bottom-color: var(--nuraly-color-textarea-border-focus, #7c3aed);
|
|
141
|
-
box-shadow: 0 0 0 1px var(--nuraly-color-textarea-border-focus, #7c3aed);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.textarea-element:disabled {
|
|
145
|
-
background-color: var(--nuraly-color-surface-disabled, #f5f5f5);
|
|
146
|
-
color: var(--nuraly-color-text-disabled, #8c8c8c);
|
|
147
|
-
border-color: var(--nuraly-color-border-disabled, #d9d9d9);
|
|
148
|
-
cursor: not-allowed;
|
|
149
|
-
resize: none;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.textarea-element:disabled {
|
|
153
|
-
background-color: var(--nuraly-color-surface-disabled, #f5f5f5);
|
|
154
|
-
color: var(--nuraly-color-text-disabled, #8c8c8c);
|
|
155
|
-
border-color: var(--nuraly-color-border-disabled, #d9d9d9);
|
|
156
|
-
cursor: not-allowed;
|
|
157
|
-
resize: none;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
.textarea-element:read-only {
|
|
161
|
-
background-color: var(--nuraly-color-surface-readonly, #f9f9f9);
|
|
162
|
-
cursor: default;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/* Size variants */
|
|
166
|
-
.size-small .textarea-element {
|
|
167
|
-
font-size: var(--nuraly-font-size-textarea-small, 14px);
|
|
168
|
-
padding: calc(var(--nuraly-padding-textarea, 12px) * 0.75);
|
|
169
|
-
min-height: 60px;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
.size-large .textarea-element {
|
|
173
|
-
font-size: var(--nuraly-font-size-textarea-large, 18px);
|
|
174
|
-
padding: calc(var(--nuraly-padding-textarea, 12px) * 1.25);
|
|
175
|
-
min-height: 100px;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/* Variant styles */
|
|
179
|
-
.variant-outlined .textarea-element {
|
|
180
|
-
border: var(--nuraly-border-width-textarea, 1px) solid var(--nuraly-color-textarea-border, #d9d9d9);
|
|
181
|
-
background-color: var(--nuraly-color-textarea-background, #ffffff);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.variant-filled .textarea-element {
|
|
185
|
-
border: var(--nuraly-border-width-textarea, 1px) solid transparent;
|
|
186
|
-
background-color: var(--nuraly-color-surface-secondary, #f5f5f5);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
.variant-filled .textarea-element:focus {
|
|
190
|
-
background-color: var(--nuraly-color-textarea-background, #ffffff);
|
|
191
|
-
border-color: var(--nuraly-color-textarea-border-focus, #7c3aed);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
.variant-borderless .textarea-element {
|
|
195
|
-
border: none;
|
|
196
|
-
background-color: transparent;
|
|
197
|
-
padding-left: 0;
|
|
198
|
-
padding-right: 0;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
.variant-underlined .textarea-element {
|
|
202
|
-
border: none;
|
|
203
|
-
border-bottom: var(--nuraly-border-width-textarea, 1px) solid var(--nuraly-color-textarea-border, #d9d9d9);
|
|
204
|
-
border-radius: 0;
|
|
205
|
-
background-color: transparent;
|
|
206
|
-
padding-left: 0;
|
|
207
|
-
padding-right: 0;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
.variant-underlined .textarea-element:focus {
|
|
211
|
-
border-bottom-color: var(--nuraly-color-textarea-border-focus, #7c3aed);
|
|
212
|
-
box-shadow: none;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/* State styles */
|
|
216
|
-
.state-error .textarea-element,
|
|
217
|
-
.validation-error .textarea-element {
|
|
218
|
-
border-color: var(--nuraly-color-textarea-error, #ef4444);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
.state-error .textarea-element:focus,
|
|
222
|
-
.validation-error .textarea-element:focus {
|
|
223
|
-
border-color: var(--nuraly-color-textarea-error, #ef4444);
|
|
224
|
-
box-shadow: 0 0 0 1px var(--nuraly-color-textarea-error, #ef4444);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
.state-warning .textarea-element,
|
|
228
|
-
.validation-warning .textarea-element {
|
|
229
|
-
border-color: var(--nuraly-color-textarea-warning, #f59e0b);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
.state-warning .textarea-element:focus,
|
|
233
|
-
.validation-warning .textarea-element:focus {
|
|
234
|
-
border-color: var(--nuraly-color-textarea-warning, #f59e0b);
|
|
235
|
-
box-shadow: 0 0 0 1px var(--nuraly-color-textarea-warning, #f59e0b);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/* Icons */
|
|
239
|
-
.validation-icon,
|
|
240
|
-
.clear-button {
|
|
241
|
-
position: absolute;
|
|
242
|
-
top: var(--nuraly-padding-textarea, 12px);
|
|
243
|
-
right: var(--nuraly-padding-textarea, 12px);
|
|
244
|
-
z-index: 1;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
.validation-icon {
|
|
248
|
-
color: var(--nuraly-color-textarea-icon, #8c8c8c);
|
|
249
|
-
pointer-events: none;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
.validation-icon.error {
|
|
253
|
-
color: var(--nuraly-color-textarea-error, #ef4444);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
.validation-icon.warning {
|
|
257
|
-
color: var(--nuraly-color-textarea-warning, #f59e0b);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
.validation-icon.success {
|
|
261
|
-
color: var(--nuraly-color-textarea-success, #10b981);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
.clear-button {
|
|
265
|
-
display: flex;
|
|
266
|
-
align-items: center;
|
|
267
|
-
justify-content: center;
|
|
268
|
-
background: none;
|
|
269
|
-
border: none;
|
|
270
|
-
cursor: pointer;
|
|
271
|
-
color: var(--nuraly-color-textarea-icon, #8c8c8c);
|
|
272
|
-
padding: 2px;
|
|
273
|
-
border-radius: 4px;
|
|
274
|
-
transition: color 0.2s ease-in-out, background-color 0.2s ease-in-out;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
.clear-button:hover {
|
|
278
|
-
color: var(--nuraly-color-textarea-icon-hover, #7c3aed);
|
|
279
|
-
background-color: var(--nuraly-color-surface-hover, rgba(0, 0, 0, 0.05));
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
.clear-button:active {
|
|
283
|
-
color: var(--nuraly-color-textarea-icon-active, #6d28d9);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/* Adjust textarea padding when icons are present */
|
|
287
|
-
:host([allow-clear]) .textarea-element,
|
|
288
|
-
:host([has-feedback]) .textarea-element {
|
|
289
|
-
padding-right: calc(var(--nuraly-padding-textarea, 12px) + 16px + 8px);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/* Footer */
|
|
293
|
-
.textarea-footer {
|
|
294
|
-
display: flex;
|
|
295
|
-
justify-content: space-between;
|
|
296
|
-
align-items: flex-start;
|
|
297
|
-
gap: var(--nuraly-spacing-textarea-gap, 8px);
|
|
298
|
-
min-height: 20px;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
.helper-text {
|
|
302
|
-
flex: 1;
|
|
303
|
-
font-size: var(--nuraly-font-size-textarea-small, 14px);
|
|
304
|
-
line-height: 1.4;
|
|
305
|
-
color: var(--nuraly-color-textarea-helper-text, #666666);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
.validation-message {
|
|
309
|
-
margin-bottom: 4px;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
.validation-message:last-child {
|
|
313
|
-
margin-bottom: 0;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
.validation-message.error {
|
|
317
|
-
color: var(--nuraly-color-textarea-error, #ef4444);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
.validation-message.warning {
|
|
321
|
-
color: var(--nuraly-color-textarea-warning, #f59e0b);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
.validation-message.success {
|
|
325
|
-
color: var(--nuraly-color-textarea-success, #10b981);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
.character-count {
|
|
329
|
-
font-size: var(--nuraly-font-size-textarea-small, 14px);
|
|
330
|
-
color: var(--nuraly-color-textarea-counter, #666666);
|
|
331
|
-
white-space: nowrap;
|
|
332
|
-
line-height: 1.4;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
.character-count.over-limit {
|
|
336
|
-
color: var(--nuraly-color-textarea-counter-over, #ef4444);
|
|
337
|
-
font-weight: 500;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
/* Responsive adjustments */
|
|
341
|
-
@media (max-width: 640px) {
|
|
342
|
-
.textarea-footer {
|
|
343
|
-
flex-direction: column;
|
|
344
|
-
align-items: stretch;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
.character-count {
|
|
348
|
-
text-align: right;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/* Focus-visible for accessibility */
|
|
353
|
-
.textarea-element:focus-visible {
|
|
354
|
-
outline: 2px solid var(--nuraly-color-textarea-border-focus, #7c3aed);
|
|
355
|
-
outline-offset: 2px;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
/* High contrast mode support */
|
|
359
|
-
@media (prefers-contrast: high) {
|
|
360
|
-
.textarea-element {
|
|
361
|
-
border-width: 2px;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
.textarea-element:focus {
|
|
365
|
-
box-shadow: 0 0 0 2px var(--nuraly-color-textarea-border-focus, #7c3aed);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
/* Reduced motion support */
|
|
370
|
-
@media (prefers-reduced-motion: reduce) {
|
|
371
|
-
.textarea-element,
|
|
372
|
-
.clear-button {
|
|
373
|
-
transition: none;
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/* ========================================
|
|
378
|
-
* THEME SPECIFIC OVERRIDES
|
|
379
|
-
* ======================================== */
|
|
380
|
-
|
|
381
|
-
/* No theme-specific overrides - themes handle styling through CSS variables */
|
|
382
|
-
`,Ft=3,Wt=50,Zt=t=>class extends t{constructor(){super(...arguments),this.handleSystemThemeChange=()=>{this.closest("[data-theme]")||document.documentElement.hasAttribute("data-theme")||this.requestUpdate()}}connectedCallback(){super.connectedCallback(),this.setupThemeObserver(),this.setupDesignSystemObserver(),this.setupSystemThemeListener()}disconnectedCallback(){var t,e,i;super.disconnectedCallback(),null===(t=this.themeObserver)||void 0===t||t.disconnect(),null===(e=this.designSystemObserver)||void 0===e||e.disconnect(),null===(i=this.mediaQuery)||void 0===i||i.removeEventListener("change",this.handleSystemThemeChange)}get currentTheme(){var t,e;const i=(null===(t=this.closest("[data-theme]"))||void 0===t?void 0:t.getAttribute("data-theme"))||document.documentElement.getAttribute("data-theme");return i||((null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light")}get currentDesignSystem(){var t;const e=(null===(t=this.closest("[design-system]"))||void 0===t?void 0:t.getAttribute("design-system"))||document.documentElement.getAttribute("design-system");return"carbon"===e?e:"default"}setupThemeObserver(){this.themeObserver=new MutationObserver((()=>{this.requestUpdate()})),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})}setupDesignSystemObserver(){this.designSystemObserver=new MutationObserver((()=>{this.requestUpdate()})),this.designSystemObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["design-system"]})}setupSystemThemeListener(){window.matchMedia&&(this.mediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.mediaQuery.addEventListener("change",this.handleSystemThemeChange))}},Jt=()=>{var t;return void 0!==globalThis.litElementVersions||"undefined"!=typeof process&&"development"===(null===(t=process.env)||void 0===t?void 0:t.NODE_ENV)||"undefined"!=typeof window&&("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname)},Gt=t=>class extends t{constructor(){super(...arguments),this.requiredComponents=[]}validateDependencies(){if(Jt())for(const t of this.requiredComponents)if(!this.isComponentAvailable(t))throw new Error(`Required component "${t}" is not registered. Please import and register the component before using ${this.tagName.toLowerCase()}. Example: import '@nuralyui/${t}';`)}validateDependenciesWithHandler(t){if(!Jt())return!0;let e=!0;for(const i of this.requiredComponents)if(!this.isComponentAvailable(i)){e=!1;const s=new Error(`Required component "${i}" is not registered. Please import and register the component before using ${this.tagName.toLowerCase()}.`);t?t(i,s):console.error(s.message)}return e}isComponentAvailable(t){return!!customElements.get(t)}getMissingDependencies(){return this.requiredComponents.filter((t=>!this.isComponentAvailable(t)))}areDependenciesAvailable(){return this.requiredComponents.every((t=>this.isComponentAvailable(t)))}addRequiredComponent(t){this.requiredComponents.includes(t)||this.requiredComponents.push(t)}removeRequiredComponent(t){const e=this.requiredComponents.indexOf(t);e>-1&&this.requiredComponents.splice(e,1)}},Qt=t=>class extends t{dispatchCustomEvent(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}dispatchEventWithMetadata(t,e){var i;const s=Object.assign(Object.assign({},e),{timestamp:Date.now(),componentName:(null===(i=this.tagName)||void 0===i?void 0:i.toLowerCase())||"unknown"});this.dispatchCustomEvent(t,s)}dispatchInputEvent(t,e){const i=Object.assign({target:e.target||this,value:e.value,originalEvent:e.originalEvent},e);this.dispatchCustomEvent(t,i)}dispatchFocusEvent(t,e){const i=Object.assign({target:e.target||this,value:e.value,focused:e.focused,cursorPosition:e.cursorPosition,selectedText:e.selectedText},e);this.dispatchCustomEvent(t,i)}dispatchValidationEvent(t,e){var i;const s=Object.assign({target:e.target||this,value:e.value,isValid:null!==(i=e.isValid)&&void 0!==i&&i,error:e.error},e);this.dispatchCustomEvent(t,s)}dispatchActionEvent(t,e){const i=Object.assign({target:e.target||this,action:e.action,previousValue:e.previousValue,newValue:e.newValue},e);this.dispatchCustomEvent(t,i)}isReadonlyKeyAllowed(t){if(t.ctrlKey||t.metaKey){return["KeyA","KeyC"].includes(t.code)}return["Tab","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key)}isActivationKey(t){return"Enter"===t.key||" "===t.key}};
|
|
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`:host{display:block;position:relative;font-family:var(--nuraly-font-family-textarea, Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif)}.textarea-container{display:flex;flex-direction:column;gap:var(--nuraly-spacing-textarea-gap,8px);width:100%}.textarea-label{display:flex;align-items:center;gap:4px;font-size:var(--nuraly-font-size-textarea,16px);font-weight:500;color:var(--nuraly-color-textarea-label,#262626);line-height:var(--nuraly-line-height-textarea,1.5)}.required-indicator{color:var(--nuraly-color-textarea-error,#ef4444);font-weight:600}.textarea-wrapper{display:flex;align-items:flex-start;gap:var(--nuraly-spacing-textarea-gap,8px);position:relative}.addon-after,.addon-before{display:flex;align-items:flex-start;padding-top:var(--nuraly-padding-textarea,12px)}.textarea-input-container{position:relative;flex:1;display:flex;align-items:flex-start}.textarea-element{width:100%;min-height:80px;padding:var(--nuraly-padding-textarea,12px);border-top:var(--nuraly-border-width-textarea,1px) solid var(--nuraly-color-textarea-border,#d9d9d9);border-left:var(--nuraly-border-width-textarea,1px) solid var(--nuraly-color-textarea-border,#d9d9d9);border-right:var(--nuraly-border-width-textarea,1px) solid var(--nuraly-color-textarea-border,#d9d9d9);border-bottom:var(--nuraly-border-width-textarea,1px) solid var(--nuraly-color-textarea-border-bottom,var(--nuraly-color-textarea-border,#d9d9d9));border-radius:var(--nuraly-border-radius-textarea,6px);background-color:var(--nuraly-color-textarea-background,#fff);color:var(--nuraly-color-textarea-text,#262626);font-family:var(--nuraly-font-family-textarea, Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif);font-size:var(--nuraly-font-size-textarea,16px);line-height:var(--nuraly-line-height-textarea,1.5);outline:0;transition:border-color .2s ease-in-out;box-sizing:border-box}.textarea-element::placeholder{color:var(--nuraly-color-textarea-placeholder,#8c8c8c)}.textarea-element:hover:not(:disabled):not(:focus){border-top-color:var(--nuraly-color-textarea-border-hover,#7c3aed);border-left-color:var(--nuraly-color-textarea-border-hover,#7c3aed);border-right-color:var(--nuraly-color-textarea-border-hover,#7c3aed);border-bottom-color:var(--nuraly-color-textarea-border-hover,#7c3aed)}.textarea-element:focus{border-top-color:var(--nuraly-color-textarea-border-focus,#7c3aed);border-left-color:var(--nuraly-color-textarea-border-focus,#7c3aed);border-right-color:var(--nuraly-color-textarea-border-focus,#7c3aed);border-bottom-color:var(--nuraly-color-textarea-border-focus,#7c3aed);box-shadow:0 0 0 1px var(--nuraly-color-textarea-border-focus,#7c3aed)}.textarea-element:disabled{background-color:var(--nuraly-color-surface-disabled,#f5f5f5);color:var(--nuraly-color-text-disabled,#8c8c8c);border-color:var(--nuraly-color-border-disabled,#d9d9d9);cursor:not-allowed;resize:none}.textarea-element:disabled{background-color:var(--nuraly-color-surface-disabled,#f5f5f5);color:var(--nuraly-color-text-disabled,#8c8c8c);border-color:var(--nuraly-color-border-disabled,#d9d9d9);cursor:not-allowed;resize:none}.textarea-element:read-only{background-color:var(--nuraly-color-surface-readonly,#f9f9f9);cursor:default}.size-small .textarea-element{font-size:var(--nuraly-font-size-textarea-small,14px);padding:calc(var(--nuraly-padding-textarea,12px) * .75);min-height:60px}.size-large .textarea-element{font-size:var(--nuraly-font-size-textarea-large,18px);padding:calc(var(--nuraly-padding-textarea,12px) * 1.25);min-height:100px}.variant-outlined .textarea-element{border:var(--nuraly-border-width-textarea,1px) solid var(--nuraly-color-textarea-border,#d9d9d9);background-color:var(--nuraly-color-textarea-background,#fff)}.variant-filled .textarea-element{border:var(--nuraly-border-width-textarea,1px) solid transparent;background-color:var(--nuraly-color-surface-secondary,#f5f5f5)}.variant-filled .textarea-element:focus{background-color:var(--nuraly-color-textarea-background,#fff);border-color:var(--nuraly-color-textarea-border-focus,#7c3aed)}.variant-borderless .textarea-element{border:none;background-color:transparent;padding-left:0;padding-right:0}.variant-underlined .textarea-element{border:none;border-bottom:var(--nuraly-border-width-textarea,1px) solid var(--nuraly-color-textarea-border,#d9d9d9);border-radius:0;background-color:transparent;padding-left:0;padding-right:0}.variant-underlined .textarea-element:focus{border-bottom-color:var(--nuraly-color-textarea-border-focus,#7c3aed);box-shadow:none}.state-error .textarea-element,.validation-error .textarea-element{border-color:var(--nuraly-color-textarea-error,#ef4444)}.state-error .textarea-element:focus,.validation-error .textarea-element:focus{border-color:var(--nuraly-color-textarea-error,#ef4444);box-shadow:0 0 0 1px var(--nuraly-color-textarea-error,#ef4444)}.state-warning .textarea-element,.validation-warning .textarea-element{border-color:var(--nuraly-color-textarea-warning,#f59e0b)}.state-warning .textarea-element:focus,.validation-warning .textarea-element:focus{border-color:var(--nuraly-color-textarea-warning,#f59e0b);box-shadow:0 0 0 1px var(--nuraly-color-textarea-warning,#f59e0b)}.clear-button,.validation-icon{position:absolute;top:var(--nuraly-padding-textarea,12px);right:var(--nuraly-padding-textarea,12px);z-index:1}.validation-icon{color:var(--nuraly-color-textarea-icon,#8c8c8c);pointer-events:none}.validation-icon.error{color:var(--nuraly-color-textarea-error,#ef4444)}.validation-icon.warning{color:var(--nuraly-color-textarea-warning,#f59e0b)}.validation-icon.success{color:var(--nuraly-color-textarea-success,#10b981)}.clear-button{display:flex;align-items:center;justify-content:center;background:0 0;border:none;cursor:pointer;color:var(--nuraly-color-textarea-icon,#8c8c8c);padding:2px;border-radius:4px;transition:color .2s ease-in-out,background-color .2s ease-in-out}.clear-button:hover{color:var(--nuraly-color-textarea-icon-hover,#7c3aed);background-color:var(--nuraly-color-surface-hover,rgba(0,0,0,.05))}.clear-button:active{color:var(--nuraly-color-textarea-icon-active,#6d28d9)}:host([allow-clear]) .textarea-element,:host([has-feedback]) .textarea-element{padding-right:calc(var(--nuraly-padding-textarea,12px) + 16px + 8px)}.textarea-footer{display:flex;justify-content:space-between;align-items:flex-start;gap:var(--nuraly-spacing-textarea-gap,8px);min-height:20px}.helper-text{flex:1;font-size:var(--nuraly-font-size-textarea-small,14px);line-height:1.4;color:var(--nuraly-color-textarea-helper-text,#666)}.validation-message{margin-bottom:4px}.validation-message:last-child{margin-bottom:0}.validation-message.error{color:var(--nuraly-color-textarea-error,#ef4444)}.validation-message.warning{color:var(--nuraly-color-textarea-warning,#f59e0b)}.validation-message.success{color:var(--nuraly-color-textarea-success,#10b981)}.character-count{font-size:var(--nuraly-font-size-textarea-small,14px);color:var(--nuraly-color-textarea-counter,#666);white-space:nowrap;line-height:1.4}.character-count.over-limit{color:var(--nuraly-color-textarea-counter-over,#ef4444);font-weight:500}@media (max-width:640px){.textarea-footer{flex-direction:column;align-items:stretch}.character-count{text-align:right}}.textarea-element:focus-visible{outline:2px solid var(--nuraly-color-textarea-border-focus,#7c3aed);outline-offset:2px}@media (prefers-contrast:high){.textarea-element{border-width:2px}.textarea-element:focus{box-shadow:0 0 0 2px var(--nuraly-color-textarea-border-focus,#7c3aed)}}@media (prefers-reduced-motion:reduce){.clear-button,.textarea-element{transition:none}}`,d=3,h=50;
|
|
383
2
|
/**
|
|
384
3
|
* @license
|
|
385
4
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
386
5
|
* SPDX-License-Identifier: MIT
|
|
387
6
|
*/
|
|
388
|
-
class
|
|
7
|
+
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
8
|
/**
|
|
390
9
|
* @license
|
|
391
10
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
392
11
|
* SPDX-License-Identifier: MIT
|
|
393
|
-
*/var
|
|
12
|
+
*/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
13
|
/**
|
|
395
14
|
* @license
|
|
396
15
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
397
16
|
* SPDX-License-Identifier: MIT
|
|
398
|
-
*/class
|
|
17
|
+
*/class b 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
18
|
/**
|
|
400
19
|
* @license
|
|
401
20
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
402
21
|
* SPDX-License-Identifier: MIT
|
|
403
|
-
*/var ie=function(t,e,i,s){for(var r,o=arguments.length,n=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s,a=t.length-1;a>=0;a--)(r=t[a])&&(n=(o<3?r(n):o>3?r(e,i,n):r(e,i))||n);return o>3&&n&&Object.defineProperty(e,i,n),n},se=function(t,e,i,s){return new(i||(i=Promise))((function(r,o){function n(t){try{l(s.next(t))}catch(t){o(t)}}function a(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(n,a)}l((s=s.apply(t,e||[])).next())}))};let re=class extends((t=>Gt(Zt(Qt(t))))(Nt)){constructor(){super(),this.validationController=new te(this),this.eventController=new ee(this),this.disabled=!1,this.readonly=!1,this.state="default",this.value="",this.size="medium",this.variant="underlined",this.resize="vertical",this.rows=Ft,this.cols=Wt,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:i}=e.contentRect;this.dispatchResizeEvent(t,i)}})))}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 i={width:t,height:e,direction:this.resize};this.dispatchEvent(new CustomEvent("nr-resize",{detail:i,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 se(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 se(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 mt`
|
|
404
|
-
<div class="textarea-label">
|
|
405
|
-
<slot name="label"></slot>
|
|
406
|
-
${this.required?mt`<span class="required-indicator">*</span>`:""}
|
|
407
|
-
</div>
|
|
408
|
-
`}renderTextarea(){return mt`
|
|
409
|
-
<textarea
|
|
410
|
-
class="textarea-element"
|
|
411
|
-
.value=${this.value}
|
|
412
|
-
.disabled=${this.disabled}
|
|
413
|
-
.readOnly=${this.readonly}
|
|
414
|
-
.required=${this.required||!1}
|
|
415
|
-
.rows=${this.rows}
|
|
416
|
-
.cols=${this.cols}
|
|
417
|
-
.placeholder=${this.placeholder}
|
|
418
|
-
.autocomplete=${this.autocomplete}
|
|
419
|
-
.name=${this.name||""}
|
|
420
|
-
maxlength=${this.maxLength||""}
|
|
421
|
-
style="resize: ${this.resize}"
|
|
422
|
-
@input=${this.handleInput}
|
|
423
|
-
@focus=${this.handleFocus}
|
|
424
|
-
@blur=${this.handleBlur}
|
|
425
|
-
></textarea>
|
|
426
|
-
`}renderValidationIcon(){if(!this.hasFeedback||!this.validationResult)return"";const t="error"===this.validationResult.level?"error":"warning"===this.validationResult.level?"warning":"check-circle";return mt`
|
|
427
|
-
<nr-icon
|
|
428
|
-
class="validation-icon ${this.validationResult.level}"
|
|
429
|
-
name="${t}"
|
|
430
|
-
size="small"
|
|
431
|
-
></nr-icon>
|
|
432
|
-
`}renderClearButton(){return!this.allowClear||!this.value||this.disabled||this.readonly?"":mt`
|
|
433
|
-
<button
|
|
434
|
-
class="clear-button"
|
|
435
|
-
type="button"
|
|
436
|
-
@click=${this.handleClear}
|
|
437
|
-
aria-label="Clear textarea"
|
|
438
|
-
>
|
|
439
|
-
<nr-icon name="x" size="small"></nr-icon>
|
|
440
|
-
</button>
|
|
441
|
-
`}renderCharacterCount(){if(!this.showCount)return"";const t=this.maxLength?` / ${this.maxLength}`:"",e=this.maxLength&&this.characterCount>this.maxLength;return mt`
|
|
442
|
-
<div class="character-count ${e?"over-limit":""}">
|
|
443
|
-
${this.characterCount}${t}
|
|
444
|
-
</div>
|
|
445
|
-
`}renderHelperText(){var t,e;const i=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('slot[name="helper-text"]'),s=null==i?void 0:i.assignedNodes().length,r=null===(e=this.validationResult)||void 0===e?void 0:e.messages.length;return s||r?mt`
|
|
446
|
-
<div class="helper-text">
|
|
447
|
-
${r?this.validationResult.messages.map((t=>mt`<div class="validation-message ${this.validationResult.level}">${t}</div>`)):mt`<slot name="helper-text"></slot>`}
|
|
448
|
-
</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 mt`
|
|
450
|
-
<div class="${t}">
|
|
451
|
-
${this.renderLabel()}
|
|
452
|
-
|
|
453
|
-
<div class="textarea-wrapper">
|
|
454
|
-
<div class="addon-before">
|
|
455
|
-
<slot name="addon-before"></slot>
|
|
456
|
-
</div>
|
|
457
|
-
|
|
458
|
-
<div class="textarea-input-container">
|
|
459
|
-
${this.renderTextarea()}
|
|
460
|
-
${this.renderValidationIcon()}
|
|
461
|
-
${this.renderClearButton()}
|
|
462
|
-
</div>
|
|
463
|
-
|
|
464
|
-
<div class="addon-after">
|
|
465
|
-
<slot name="addon-after"></slot>
|
|
466
|
-
</div>
|
|
467
|
-
</div>
|
|
468
|
-
|
|
469
|
-
<div class="textarea-footer">
|
|
470
|
-
${this.renderHelperText()}
|
|
471
|
-
${this.renderCharacterCount()}
|
|
472
|
-
</div>
|
|
473
|
-
</div>
|
|
474
|
-
`}};re.styles=qt,ie([
|
|
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};
|
|
22
|
+
*/var x=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},p=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 b(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 p(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 p(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`<div class="textarea-label"><slot name="label"></slot>${this.required?r`<span class="required-indicator">*</span>`:""}</div>`}renderTextarea(){return r`<textarea class="textarea-element" .value="${this.value}" .disabled="${this.disabled}" .readOnly="${this.readonly}" .required="${this.required||!1}" .rows="${this.rows}" .cols="${this.cols}" .placeholder="${this.placeholder}" .autocomplete="${this.autocomplete}" .name="${this.name||""}" maxlength="${this.maxLength||""}" style="resize:${this.resize}" @input="${this.handleInput}" @focus="${this.handleFocus}" @blur="${this.handleBlur}"></textarea>`}renderValidationIcon(){if(!this.hasFeedback||!this.validationResult)return"";const t="error"===this.validationResult.level?"error":"warning"===this.validationResult.level?"warning":"check-circle";return r`<nr-icon class="validation-icon ${this.validationResult.level}" name="${t}" size="small"></nr-icon>`}renderClearButton(){return!this.allowClear||!this.value||this.disabled||this.readonly?"":r`<button class="clear-button" type="button" @click="${this.handleClear}" aria-label="Clear textarea"><nr-icon name="x" size="small"></nr-icon></button>`}renderCharacterCount(){if(!this.showCount)return"";const t=this.maxLength?` / ${this.maxLength}`:"",e=this.maxLength&&this.characterCount>this.maxLength;return r`<div class="character-count ${e?"over-limit":""}">${this.characterCount}${t}</div>`}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`<div class="helper-text">${o?this.validationResult.messages.map((t=>r`<div class="validation-message ${this.validationResult.level}">${t}</div>`)):r`<slot name="helper-text"></slot>`}</div>`:""}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`<div class="${t}">${this.renderLabel()}<div class="textarea-wrapper"><div class="addon-before"><slot name="addon-before"></slot></div><div class="textarea-input-container">${this.renderTextarea()} ${this.renderValidationIcon()} ${this.renderClearButton()}</div><div class="addon-after"><slot name="addon-after"></slot></div></div><div class="textarea-footer">${this.renderHelperText()} ${this.renderCharacterCount()}</div></div>`}};f.styles=l,x([a("textarea")],f.prototype,"textareaElement",void 0),x([i({type:Boolean,reflect:!0})],f.prototype,"disabled",void 0),x([i({type:Boolean,reflect:!0})],f.prototype,"readonly",void 0),x([i({type:String,reflect:!0})],f.prototype,"state",void 0),x([i({type:String})],f.prototype,"value",void 0),x([i({type:String})],f.prototype,"size",void 0),x([i({type:String,reflect:!0})],f.prototype,"variant",void 0),x([i({type:String})],f.prototype,"resize",void 0),x([i({type:Number})],f.prototype,"rows",void 0),x([i({type:Number})],f.prototype,"cols",void 0),x([i({type:String})],f.prototype,"placeholder",void 0),x([i({type:String})],f.prototype,"autocomplete",void 0),x([i({type:String})],f.prototype,"name",void 0),x([i({type:Boolean})],f.prototype,"required",void 0),x([i({type:Boolean,reflect:!0})],f.prototype,"allowClear",void 0),x([i({type:Boolean,reflect:!0})],f.prototype,"showCount",void 0),x([i({type:Number})],f.prototype,"maxLength",void 0),x([i({type:Number})],f.prototype,"minHeight",void 0),x([i({type:Number})],f.prototype,"maxHeight",void 0),x([i({type:Boolean})],f.prototype,"autoResize",void 0),x([i({type:Array})],f.prototype,"rules",void 0),x([i({type:Boolean,attribute:"validate-on-change"})],f.prototype,"validateOnChange",void 0),x([i({type:Boolean,attribute:"validate-on-blur"})],f.prototype,"validateOnBlur",void 0),x([i({type:Boolean,attribute:"has-feedback"})],f.prototype,"hasFeedback",void 0),x([i({type:String,attribute:"validation-message"})],f.prototype,"validationMessage",void 0),x([o()],f.prototype,"isFocused",void 0),x([o()],f.prototype,"validationResult",void 0),x([o()],f.prototype,"characterCount",void 0),f=x([s("nr-textarea")],f);export{f as NrTextareaElement};
|