@editora/ui-core 0.1.20 → 0.1.21
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/dist/collection.cjs.js +1 -1
- package/dist/collection.esm.js +27 -23
- package/dist/color-picker.cjs.js +8 -8
- package/dist/color-picker.esm.js +7 -7
- package/dist/components/ui-collection.d.ts.map +1 -1
- package/dist/components/ui-multi-select.d.ts.map +1 -1
- package/dist/components/ui-portal.d.ts.map +1 -1
- package/dist/components/ui-positioner.d.ts.map +1 -1
- package/dist/components/ui-sortable.d.ts +8 -0
- package/dist/components/ui-sortable.d.ts.map +1 -1
- package/dist/components/ui-tabs.d.ts.map +1 -1
- package/dist/components/ui-textarea.d.ts.map +1 -1
- package/dist/date-time-picker.cjs.js +4 -4
- package/dist/date-time-picker.esm.js +7 -7
- package/dist/multi-select.cjs.js +3 -3
- package/dist/multi-select.esm.js +39 -31
- package/dist/portal.cjs.js +3 -3
- package/dist/portal.esm.js +11 -10
- package/dist/positioner.cjs.js +2 -2
- package/dist/positioner.esm.js +15 -14
- package/dist/primitives/auto-scroll.d.ts +9 -0
- package/dist/primitives/auto-scroll.d.ts.map +1 -0
- package/dist/primitives/selector.d.ts +4 -0
- package/dist/primitives/selector.d.ts.map +1 -0
- package/dist/selector-BvAh35ve.js +1 -0
- package/dist/selector-WI8pD7YO.mjs +18 -0
- package/dist/sortable.cjs.js +70 -56
- package/dist/sortable.esm.js +644 -561
- package/dist/tabs.cjs.js +7 -7
- package/dist/tabs.esm.js +67 -67
- package/dist/textarea.cjs.js +9 -9
- package/dist/textarea.esm.js +31 -25
- package/dist/transfer-list.cjs.js +29 -29
- package/dist/transfer-list.esm.js +54 -54
- package/package.json +1 -1
package/dist/tabs.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("./ElementBase-EV6mVBUV.js"),d=require("./roving-focus-group-BdJ_4Njm.js"),_=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-tabs-nav-bg: var(--ui-color-surface, #ffffff);
|
|
4
4
|
--ui-tabs-panel-bg: var(--ui-color-surface, #ffffff);
|
|
@@ -483,7 +483,7 @@
|
|
|
483
483
|
border-color: Highlight;
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
|
-
|
|
486
|
+
`,p="data-ui-tabs-auto-label";function f(h){return String(h).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function g(h){if(h==null)return!1;const t=String(h).toLowerCase();return t!=="false"&&t!=="0"&&t!=="off"}const w=new Set(["orientation","activation","headless","variant","size","density","tone","stretched","shape","elevation","bare"]);class x extends y.ElementBase{constructor(){super(),this._uid=`ui-tabs-${Math.random().toString(36).slice(2,9)}`,this._observer=null,this._resizeObserver=null,this._isSyncing=!1,this._isSyncingSelectionAttributes=!1,this._focusIndex=-1,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onWindowResize=this._onWindowResize.bind(this)}static get observedAttributes(){return["selected","value","orientation","activation","headless","variant","size","density","tone","stretched","shape","elevation","loop","bare"]}connectedCallback(){super.connectedCallback(),this.root.addEventListener("click",this._onClick),this.root.addEventListener("keydown",this._onKeyDown),this._observer=new MutationObserver(()=>{this._isSyncing||this.requestRender()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["slot","data-label","data-value","data-icon","data-disabled","disabled","data-active"]}),typeof ResizeObserver<"u"?(this._resizeObserver=new ResizeObserver(()=>this._syncSelectionUi()),this._resizeObserver.observe(this)):window.addEventListener("resize",this._onWindowResize),this._syncSelectionUi()}disconnectedCallback(){this.root.removeEventListener("click",this._onClick),this.root.removeEventListener("keydown",this._onKeyDown),this._observer&&(this._observer.disconnect(),this._observer=null),this._resizeObserver?(this._resizeObserver.disconnect(),this._resizeObserver=null):window.removeEventListener("resize",this._onWindowResize),super.disconnectedCallback()}attributeChangedCallback(t,e,r){if(e!==r){if(t==="selected"||t==="value"){this._isSyncingSelectionAttributes||this._syncSelectionUi();return}w.has(t)&&this.isConnected&&this.requestRender()}}get selected(){return this.getAttribute("selected")||"0"}set selected(t){const e=String(t);e?this.setAttribute("selected",e):this.removeAttribute("selected")}_sourceTabs(){return Array.from(this.querySelectorAll('[slot="tab"]'))}_sourcePanels(){return Array.from(this.querySelectorAll('[slot="panel"]'))}_tabsModel(){return this._sourceTabs().map((t,e)=>{const r=t.getAttribute("data-value")||t.getAttribute("value")||String(e),a=t.getAttribute("data-label")||t.textContent?.trim()||`Tab ${e+1}`,i=t.getAttribute("data-icon")||"",s=t.hasAttribute("disabled")||g(t.getAttribute("data-disabled")),n=`${this._uid}-tab-${e}`,o=`${this._uid}-panel-${e}`;return{index:e,value:r,label:a,icon:i,disabled:s,tabId:n,panelId:o}})}_resolveSelectedIndex(t){if(!t.length)return-1;const e=this.getAttribute("selected"),r=this.getAttribute("value"),a=this._sourceTabs();let i=-1;if(e!=null&&e!==""){const s=Number(e);Number.isFinite(s)?i=Math.trunc(s):i=t.findIndex(n=>n.value===e)}return i<0&&r&&(i=t.findIndex(s=>s.value===r)),i<0&&(i=t.findIndex((s,n)=>!!a[n]?.hasAttribute("data-active")&&!s.disabled)),(i<0||!t[i]||t[i].disabled)&&(i=t.findIndex(s=>!s.disabled)),i}_syncSelectedAttributes(t,e){const r=t[e];this._isSyncingSelectionAttributes=!0;try{if(!r){this.removeAttribute("selected"),this.removeAttribute("value");return}this.getAttribute("selected")!==String(e)&&this.setAttribute("selected",String(e)),this.getAttribute("value")!==r.value&&this.setAttribute("value",r.value)}finally{this._isSyncingSelectionAttributes=!1}}_emit(t,e,r){const a=e[r];if(!a)return;const i={selected:r,index:r,value:a.value,label:a.label,tabId:a.tabId,panelId:a.panelId};this.dispatchEvent(new CustomEvent(t,{detail:i,bubbles:!0,composed:!0}))}_setSelectedByIndex(t,e,r){const a=t[e];if(!a||a.disabled)return;if(this._resolveSelectedIndex(t)===e){this._focusTab(e);return}this._focusIndex=e,this.setAttribute("selected",String(e)),this.setAttribute("value",a.value),r&&(this._emit("change",t,e),this._emit("select",t,e))}_syncSelectionUi(){if(!this.isConnected)return;if(!this.root.querySelector(".nav")){this.requestRender();return}const t=this._tabsModel();if(!t.length)return;const e=this._resolveSelectedIndex(t),r=this._resolveFocusIndex(t,e);this._syncSelectedAttributes(t,e);const a=Array.from(this.root.querySelectorAll(".tab"));a.forEach((s,n)=>{const o=t[n];if(!o)return;const l=n===e;s.setAttribute("aria-selected",l?"true":"false"),s.setAttribute("aria-controls",o.panelId),s.setAttribute("aria-disabled",o.disabled?"true":"false"),o.disabled?s.setAttribute("disabled",""):s.removeAttribute("disabled")}),d.syncRovingTabStops(a,a[r]||null,{activeAttribute:null});const i=t[e];this._syncIndicator(e),i?(this.setAttribute("aria-activedescendant",i.tabId),this.setAttribute("aria-controls",i.panelId),this._scrollSelectedTabIntoView(e)):(this.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-controls")),this._syncPanels(t,e)}_syncIndicator(t){const e=this.root.querySelector(".nav");if(!e)return;const r=this.getAttribute("variant")||"default",a=r==="indicator";if(!a&&!(r==="indicator-line")){e.removeAttribute("data-indicator-ready"),e.style.removeProperty("--ui-tabs-indicator-x"),e.style.removeProperty("--ui-tabs-indicator-y"),e.style.removeProperty("--ui-tabs-indicator-w"),e.style.removeProperty("--ui-tabs-indicator-h");return}const s=this.root.querySelector(`.tab[data-index="${t}"]`);if(!s){e.removeAttribute("data-indicator-ready");return}const n=this.getAttribute("orientation")==="vertical"?"vertical":"horizontal",o=getComputedStyle(this).direction==="rtl";let l=s.offsetLeft,u=s.offsetTop,c=s.offsetWidth,b=s.offsetHeight;a?(l+=2,u+=2,c=Math.max(0,c-4),b=Math.max(0,b-4)):n==="vertical"?(u+=5,b=Math.max(8,b-10),c=3,l+=o?s.offsetWidth-3-2:2):(l+=8,c=Math.max(12,c-16),b=2,u+=s.offsetHeight-2-2),e.style.setProperty("--ui-tabs-indicator-x",`${l}px`),e.style.setProperty("--ui-tabs-indicator-y",`${u}px`),e.style.setProperty("--ui-tabs-indicator-w",`${c}px`),e.style.setProperty("--ui-tabs-indicator-h",`${b}px`),e.setAttribute("data-indicator-ready","true")}_syncPanels(t,e){const r=this._sourcePanels(),a=this.root.querySelector(".panel-wrap");a&&(r.length?a.removeAttribute("hidden"):a.setAttribute("hidden","")),this._isSyncing=!0;try{r.forEach((i,s)=>{const n=t[s],o=s===e;i.id=n?.panelId||`${this._uid}-panel-${s}`,i.setAttribute("role","tabpanel"),i.setAttribute("tabindex",o?"0":"-1"),i.setAttribute("aria-hidden",o?"false":"true"),n&&(i.getAttribute("aria-labelledby")===n.tabId&&i.removeAttribute("aria-labelledby"),i.hasAttribute("aria-labelledby")||i.hasAttribute("aria-label")&&!i.hasAttribute(p)||(i.setAttribute("aria-label",n.label),i.setAttribute(p,""))),o?i.removeAttribute("hidden"):i.setAttribute("hidden","")})}finally{this._isSyncing=!1}}_enabledIndices(t){return t.filter(e=>!e.disabled).map(e=>e.index)}_resolveFocusIndex(t,e){const r=d.resolveRovingFocusIndex(t,{activeIndex:this._focusIndex,selectedIndex:e,getDisabled:a=>a.disabled});return this._focusIndex=r,r}_onWindowResize(){this._syncSelectionUi()}_focusTab(t){this._focusIndex=t;const e=this.root.querySelector(`.tab[data-index="${t}"]`),r=Array.from(this.root.querySelectorAll(".tab"));d.syncRovingTabStops(r,e,{activeAttribute:null}),d.focusRovingItem(e)}_scrollSelectedTabIntoView(t){const e=this.root.querySelector(".nav"),r=this.root.querySelector(`.tab[data-index="${t}"]`);if(!e||!r)return;const a=this.getAttribute("orientation")!=="vertical",i=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;typeof r.scrollIntoView=="function"&&r.scrollIntoView({behavior:i?"auto":"smooth",block:"nearest",inline:a?"center":"nearest"})}_onClick(t){const r=t.target?.closest(".tab");if(!r||r.disabled)return;const a=Number(r.getAttribute("data-index"));if(!Number.isFinite(a))return;const i=this._tabsModel();this._setSelectedByIndex(i,a,!0)}_onKeyDown(t){const r=t.target?.closest(".tab");if(!r)return;const a=this._tabsModel();if(!a.length)return;const i=this.getAttribute("orientation")==="vertical"?"vertical":"horizontal",s=this.getAttribute("activation")==="manual"?"manual":"auto",n=!this.hasAttribute("loop")||g(this.getAttribute("loop")),o=getComputedStyle(this).direction==="rtl",l=Number(r.getAttribute("data-index"));if(!Number.isFinite(l))return;const u=c=>{const b=d.moveRovingFocusIndex(a,l,c,{wrap:n,fallbackIndex:this._resolveFocusIndex(a,this._resolveSelectedIndex(a)),getDisabled:v=>v.disabled});b!=null&&(this._focusTab(b),s==="auto"?this._setSelectedByIndex(a,b,!0):this._emit("focus",a,b))};if(i==="horizontal"&&(t.key==="ArrowRight"&&!o||t.key==="ArrowLeft"&&o)||i==="vertical"&&t.key==="ArrowDown"){t.preventDefault(),u(1);return}if(i==="horizontal"&&(t.key==="ArrowLeft"&&!o||t.key==="ArrowRight"&&o)||i==="vertical"&&t.key==="ArrowUp"){t.preventDefault(),u(-1);return}if(t.key==="Home"){t.preventDefault();const c=d.getRovingFocusBoundaryIndex(a,"first",b=>b.disabled);if(c<0)return;this._focusTab(c),s==="auto"?this._setSelectedByIndex(a,c,!0):this._emit("focus",a,c);return}if(t.key==="End"){t.preventDefault();const c=d.getRovingFocusBoundaryIndex(a,"last",b=>b.disabled);if(c<0)return;this._focusTab(c),s==="auto"?this._setSelectedByIndex(a,c,!0):this._emit("focus",a,c);return}(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this._setSelectedByIndex(a,l,!0))}render(){const t=this._tabsModel(),e=this._resolveSelectedIndex(t),r=this._resolveFocusIndex(t,e);this._syncSelectedAttributes(t,e);const a=this.getAttribute("orientation")==="vertical"?"vertical":"horizontal",i=t.map(n=>{const o=n.index===e,l=n.icon?`<span class="tab-icon" aria-hidden="true">${f(n.icon)}</span>`:"";return`
|
|
487
487
|
<button
|
|
488
488
|
type="button"
|
|
489
489
|
class="tab"
|
|
@@ -494,22 +494,22 @@
|
|
|
494
494
|
aria-selected="${o?"true":"false"}"
|
|
495
495
|
aria-controls="${n.panelId}"
|
|
496
496
|
aria-disabled="${n.disabled?"true":"false"}"
|
|
497
|
-
tabindex="${n.index===
|
|
497
|
+
tabindex="${n.index===r&&!n.disabled?"0":"-1"}"
|
|
498
498
|
${n.disabled?"disabled":""}
|
|
499
499
|
>
|
|
500
500
|
${l}
|
|
501
|
-
<span class="tab-label">${
|
|
501
|
+
<span class="tab-label">${f(n.label)}</span>
|
|
502
502
|
</button>
|
|
503
503
|
`}).join("");this.setContent(`
|
|
504
|
-
<style>${
|
|
504
|
+
<style>${_}</style>
|
|
505
505
|
<section class="shell" part="shell">
|
|
506
506
|
<div class="nav" role="tablist" aria-orientation="${a}" part="nav">
|
|
507
507
|
<span class="indicator" part="indicator" aria-hidden="true"></span>
|
|
508
|
-
${
|
|
508
|
+
${i}
|
|
509
509
|
</div>
|
|
510
510
|
<div class="panel-wrap" part="panel-wrap" aria-live="polite">
|
|
511
511
|
<slot name="panel"></slot>
|
|
512
512
|
</div>
|
|
513
513
|
</section>
|
|
514
514
|
<slot class="source-tabs" name="tab"></slot>
|
|
515
|
-
`);const s=t[e];s?(this.setAttribute("aria-activedescendant",s.tabId),this.setAttribute("aria-controls",s.panelId)):(this.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-controls")),this._syncIndicator(e),this._syncPanels(t,e)}}typeof customElements<"u"&&!customElements.get("ui-tabs")&&customElements.define("ui-tabs",
|
|
515
|
+
`);const s=t[e];s?(this.setAttribute("aria-activedescendant",s.tabId),this.setAttribute("aria-controls",s.panelId)):(this.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-controls")),this._syncIndicator(e),this._syncPanels(t,e)}}typeof customElements<"u"&&!customElements.get("ui-tabs")&&customElements.define("ui-tabs",x);exports.UITabs=x;
|
package/dist/tabs.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
import { s as v, r as
|
|
3
|
-
const
|
|
1
|
+
import { E as y } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
|
+
import { s as v, r as _, f as w, g as p, m as A } from "./roving-focus-group-Dbm1Jko_.mjs";
|
|
3
|
+
const k = `
|
|
4
4
|
:host {
|
|
5
5
|
--ui-tabs-nav-bg: var(--ui-color-surface, #ffffff);
|
|
6
6
|
--ui-tabs-panel-bg: var(--ui-color-surface, #ffffff);
|
|
@@ -485,16 +485,16 @@ const A = `
|
|
|
485
485
|
border-color: Highlight;
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
-
|
|
489
|
-
function
|
|
488
|
+
`, f = "data-ui-tabs-auto-label";
|
|
489
|
+
function g(u) {
|
|
490
490
|
return String(u).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
491
491
|
}
|
|
492
|
-
function
|
|
492
|
+
function x(u) {
|
|
493
493
|
if (u == null) return !1;
|
|
494
494
|
const t = String(u).toLowerCase();
|
|
495
495
|
return t !== "false" && t !== "0" && t !== "off";
|
|
496
496
|
}
|
|
497
|
-
const
|
|
497
|
+
const S = /* @__PURE__ */ new Set([
|
|
498
498
|
"orientation",
|
|
499
499
|
"activation",
|
|
500
500
|
"headless",
|
|
@@ -507,7 +507,7 @@ const k = /* @__PURE__ */ new Set([
|
|
|
507
507
|
"elevation",
|
|
508
508
|
"bare"
|
|
509
509
|
]);
|
|
510
|
-
class
|
|
510
|
+
class I extends y {
|
|
511
511
|
constructor() {
|
|
512
512
|
super(), this._uid = `ui-tabs-${Math.random().toString(36).slice(2, 9)}`, this._observer = null, this._resizeObserver = null, this._isSyncing = !1, this._isSyncingSelectionAttributes = !1, this._focusIndex = -1, this._onClick = this._onClick.bind(this), this._onKeyDown = this._onKeyDown.bind(this), this._onWindowResize = this._onWindowResize.bind(this);
|
|
513
513
|
}
|
|
@@ -543,13 +543,13 @@ class S extends m {
|
|
|
543
543
|
disconnectedCallback() {
|
|
544
544
|
this.root.removeEventListener("click", this._onClick), this.root.removeEventListener("keydown", this._onKeyDown), this._observer && (this._observer.disconnect(), this._observer = null), this._resizeObserver ? (this._resizeObserver.disconnect(), this._resizeObserver = null) : window.removeEventListener("resize", this._onWindowResize), super.disconnectedCallback();
|
|
545
545
|
}
|
|
546
|
-
attributeChangedCallback(t, e,
|
|
547
|
-
if (e !==
|
|
546
|
+
attributeChangedCallback(t, e, r) {
|
|
547
|
+
if (e !== r) {
|
|
548
548
|
if (t === "selected" || t === "value") {
|
|
549
549
|
this._isSyncingSelectionAttributes || this._syncSelectionUi();
|
|
550
550
|
return;
|
|
551
551
|
}
|
|
552
|
-
|
|
552
|
+
S.has(t) && this.isConnected && this.requestRender();
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
555
|
get selected() {
|
|
@@ -567,54 +567,54 @@ class S extends m {
|
|
|
567
567
|
}
|
|
568
568
|
_tabsModel() {
|
|
569
569
|
return this._sourceTabs().map((t, e) => {
|
|
570
|
-
const
|
|
571
|
-
return { index: e, value:
|
|
570
|
+
const r = t.getAttribute("data-value") || t.getAttribute("value") || String(e), a = t.getAttribute("data-label") || t.textContent?.trim() || `Tab ${e + 1}`, i = t.getAttribute("data-icon") || "", s = t.hasAttribute("disabled") || x(t.getAttribute("data-disabled")), n = `${this._uid}-tab-${e}`, o = `${this._uid}-panel-${e}`;
|
|
571
|
+
return { index: e, value: r, label: a, icon: i, disabled: s, tabId: n, panelId: o };
|
|
572
572
|
});
|
|
573
573
|
}
|
|
574
574
|
_resolveSelectedIndex(t) {
|
|
575
575
|
if (!t.length) return -1;
|
|
576
|
-
const e = this.getAttribute("selected"),
|
|
577
|
-
let
|
|
576
|
+
const e = this.getAttribute("selected"), r = this.getAttribute("value"), a = this._sourceTabs();
|
|
577
|
+
let i = -1;
|
|
578
578
|
if (e != null && e !== "") {
|
|
579
579
|
const s = Number(e);
|
|
580
|
-
Number.isFinite(s) ?
|
|
580
|
+
Number.isFinite(s) ? i = Math.trunc(s) : i = t.findIndex((n) => n.value === e);
|
|
581
581
|
}
|
|
582
|
-
return
|
|
582
|
+
return i < 0 && r && (i = t.findIndex((s) => s.value === r)), i < 0 && (i = t.findIndex((s, n) => !!a[n]?.hasAttribute("data-active") && !s.disabled)), (i < 0 || !t[i] || t[i].disabled) && (i = t.findIndex((s) => !s.disabled)), i;
|
|
583
583
|
}
|
|
584
584
|
_syncSelectedAttributes(t, e) {
|
|
585
|
-
const
|
|
585
|
+
const r = t[e];
|
|
586
586
|
this._isSyncingSelectionAttributes = !0;
|
|
587
587
|
try {
|
|
588
|
-
if (!
|
|
588
|
+
if (!r) {
|
|
589
589
|
this.removeAttribute("selected"), this.removeAttribute("value");
|
|
590
590
|
return;
|
|
591
591
|
}
|
|
592
|
-
this.getAttribute("selected") !== String(e) && this.setAttribute("selected", String(e)), this.getAttribute("value") !==
|
|
592
|
+
this.getAttribute("selected") !== String(e) && this.setAttribute("selected", String(e)), this.getAttribute("value") !== r.value && this.setAttribute("value", r.value);
|
|
593
593
|
} finally {
|
|
594
594
|
this._isSyncingSelectionAttributes = !1;
|
|
595
595
|
}
|
|
596
596
|
}
|
|
597
|
-
_emit(t, e,
|
|
598
|
-
const a = e[
|
|
597
|
+
_emit(t, e, r) {
|
|
598
|
+
const a = e[r];
|
|
599
599
|
if (!a) return;
|
|
600
|
-
const
|
|
601
|
-
selected:
|
|
602
|
-
index:
|
|
600
|
+
const i = {
|
|
601
|
+
selected: r,
|
|
602
|
+
index: r,
|
|
603
603
|
value: a.value,
|
|
604
604
|
label: a.label,
|
|
605
605
|
tabId: a.tabId,
|
|
606
606
|
panelId: a.panelId
|
|
607
607
|
};
|
|
608
|
-
this.dispatchEvent(new CustomEvent(t, { detail:
|
|
608
|
+
this.dispatchEvent(new CustomEvent(t, { detail: i, bubbles: !0, composed: !0 }));
|
|
609
609
|
}
|
|
610
|
-
_setSelectedByIndex(t, e,
|
|
610
|
+
_setSelectedByIndex(t, e, r) {
|
|
611
611
|
const a = t[e];
|
|
612
612
|
if (!a || a.disabled) return;
|
|
613
613
|
if (this._resolveSelectedIndex(t) === e) {
|
|
614
614
|
this._focusTab(e);
|
|
615
615
|
return;
|
|
616
616
|
}
|
|
617
|
-
this._focusIndex = e, this.setAttribute("selected", String(e)), this.setAttribute("value", a.value),
|
|
617
|
+
this._focusIndex = e, this.setAttribute("selected", String(e)), this.setAttribute("value", a.value), r && (this._emit("change", t, e), this._emit("select", t, e));
|
|
618
618
|
}
|
|
619
619
|
_syncSelectionUi() {
|
|
620
620
|
if (!this.isConnected) return;
|
|
@@ -624,7 +624,7 @@ class S extends m {
|
|
|
624
624
|
}
|
|
625
625
|
const t = this._tabsModel();
|
|
626
626
|
if (!t.length) return;
|
|
627
|
-
const e = this._resolveSelectedIndex(t),
|
|
627
|
+
const e = this._resolveSelectedIndex(t), r = this._resolveFocusIndex(t, e);
|
|
628
628
|
this._syncSelectedAttributes(t, e);
|
|
629
629
|
const a = Array.from(this.root.querySelectorAll(".tab"));
|
|
630
630
|
a.forEach((s, n) => {
|
|
@@ -632,15 +632,15 @@ class S extends m {
|
|
|
632
632
|
if (!o) return;
|
|
633
633
|
const l = n === e;
|
|
634
634
|
s.setAttribute("aria-selected", l ? "true" : "false"), s.setAttribute("aria-controls", o.panelId), s.setAttribute("aria-disabled", o.disabled ? "true" : "false"), o.disabled ? s.setAttribute("disabled", "") : s.removeAttribute("disabled");
|
|
635
|
-
}), v(a, a[
|
|
636
|
-
const
|
|
637
|
-
this._syncIndicator(e),
|
|
635
|
+
}), v(a, a[r] || null, { activeAttribute: null });
|
|
636
|
+
const i = t[e];
|
|
637
|
+
this._syncIndicator(e), i ? (this.setAttribute("aria-activedescendant", i.tabId), this.setAttribute("aria-controls", i.panelId), this._scrollSelectedTabIntoView(e)) : (this.removeAttribute("aria-activedescendant"), this.removeAttribute("aria-controls")), this._syncPanels(t, e);
|
|
638
638
|
}
|
|
639
639
|
_syncIndicator(t) {
|
|
640
640
|
const e = this.root.querySelector(".nav");
|
|
641
641
|
if (!e) return;
|
|
642
|
-
const
|
|
643
|
-
if (!a && !(
|
|
642
|
+
const r = this.getAttribute("variant") || "default", a = r === "indicator";
|
|
643
|
+
if (!a && !(r === "indicator-line")) {
|
|
644
644
|
e.removeAttribute("data-indicator-ready"), e.style.removeProperty("--ui-tabs-indicator-x"), e.style.removeProperty("--ui-tabs-indicator-y"), e.style.removeProperty("--ui-tabs-indicator-w"), e.style.removeProperty("--ui-tabs-indicator-h");
|
|
645
645
|
return;
|
|
646
646
|
}
|
|
@@ -654,12 +654,12 @@ class S extends m {
|
|
|
654
654
|
a ? (l += 2, d += 2, c = Math.max(0, c - 4), b = Math.max(0, b - 4)) : n === "vertical" ? (d += 5, b = Math.max(8, b - 10), c = 3, l += o ? s.offsetWidth - 3 - 2 : 2) : (l += 8, c = Math.max(12, c - 16), b = 2, d += s.offsetHeight - 2 - 2), e.style.setProperty("--ui-tabs-indicator-x", `${l}px`), e.style.setProperty("--ui-tabs-indicator-y", `${d}px`), e.style.setProperty("--ui-tabs-indicator-w", `${c}px`), e.style.setProperty("--ui-tabs-indicator-h", `${b}px`), e.setAttribute("data-indicator-ready", "true");
|
|
655
655
|
}
|
|
656
656
|
_syncPanels(t, e) {
|
|
657
|
-
const
|
|
658
|
-
a && (
|
|
657
|
+
const r = this._sourcePanels(), a = this.root.querySelector(".panel-wrap");
|
|
658
|
+
a && (r.length ? a.removeAttribute("hidden") : a.setAttribute("hidden", "")), this._isSyncing = !0;
|
|
659
659
|
try {
|
|
660
|
-
|
|
660
|
+
r.forEach((i, s) => {
|
|
661
661
|
const n = t[s], o = s === e;
|
|
662
|
-
|
|
662
|
+
i.id = n?.panelId || `${this._uid}-panel-${s}`, i.setAttribute("role", "tabpanel"), i.setAttribute("tabindex", o ? "0" : "-1"), i.setAttribute("aria-hidden", o ? "false" : "true"), n && (i.getAttribute("aria-labelledby") === n.tabId && i.removeAttribute("aria-labelledby"), i.hasAttribute("aria-labelledby") || i.hasAttribute("aria-label") && !i.hasAttribute(f) || (i.setAttribute("aria-label", n.label), i.setAttribute(f, ""))), o ? i.removeAttribute("hidden") : i.setAttribute("hidden", "");
|
|
663
663
|
});
|
|
664
664
|
} finally {
|
|
665
665
|
this._isSyncing = !1;
|
|
@@ -669,59 +669,59 @@ class S extends m {
|
|
|
669
669
|
return t.filter((e) => !e.disabled).map((e) => e.index);
|
|
670
670
|
}
|
|
671
671
|
_resolveFocusIndex(t, e) {
|
|
672
|
-
const
|
|
672
|
+
const r = _(t, {
|
|
673
673
|
activeIndex: this._focusIndex,
|
|
674
674
|
selectedIndex: e,
|
|
675
675
|
getDisabled: (a) => a.disabled
|
|
676
676
|
});
|
|
677
|
-
return this._focusIndex =
|
|
677
|
+
return this._focusIndex = r, r;
|
|
678
678
|
}
|
|
679
679
|
_onWindowResize() {
|
|
680
680
|
this._syncSelectionUi();
|
|
681
681
|
}
|
|
682
682
|
_focusTab(t) {
|
|
683
683
|
this._focusIndex = t;
|
|
684
|
-
const e = this.root.querySelector(`.tab[data-index="${t}"]`),
|
|
685
|
-
v(
|
|
684
|
+
const e = this.root.querySelector(`.tab[data-index="${t}"]`), r = Array.from(this.root.querySelectorAll(".tab"));
|
|
685
|
+
v(r, e, { activeAttribute: null }), w(e);
|
|
686
686
|
}
|
|
687
687
|
_scrollSelectedTabIntoView(t) {
|
|
688
|
-
const e = this.root.querySelector(".nav"),
|
|
689
|
-
if (!e || !
|
|
690
|
-
const a = this.getAttribute("orientation") !== "vertical",
|
|
691
|
-
typeof
|
|
692
|
-
behavior:
|
|
688
|
+
const e = this.root.querySelector(".nav"), r = this.root.querySelector(`.tab[data-index="${t}"]`);
|
|
689
|
+
if (!e || !r) return;
|
|
690
|
+
const a = this.getAttribute("orientation") !== "vertical", i = typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
691
|
+
typeof r.scrollIntoView == "function" && r.scrollIntoView({
|
|
692
|
+
behavior: i ? "auto" : "smooth",
|
|
693
693
|
block: "nearest",
|
|
694
694
|
inline: a ? "center" : "nearest"
|
|
695
695
|
});
|
|
696
696
|
}
|
|
697
697
|
_onClick(t) {
|
|
698
|
-
const
|
|
699
|
-
if (!
|
|
700
|
-
const a = Number(
|
|
698
|
+
const r = t.target?.closest(".tab");
|
|
699
|
+
if (!r || r.disabled) return;
|
|
700
|
+
const a = Number(r.getAttribute("data-index"));
|
|
701
701
|
if (!Number.isFinite(a)) return;
|
|
702
|
-
const
|
|
703
|
-
this._setSelectedByIndex(
|
|
702
|
+
const i = this._tabsModel();
|
|
703
|
+
this._setSelectedByIndex(i, a, !0);
|
|
704
704
|
}
|
|
705
705
|
_onKeyDown(t) {
|
|
706
|
-
const
|
|
707
|
-
if (!
|
|
706
|
+
const r = t.target?.closest(".tab");
|
|
707
|
+
if (!r) return;
|
|
708
708
|
const a = this._tabsModel();
|
|
709
709
|
if (!a.length) return;
|
|
710
|
-
const
|
|
710
|
+
const i = this.getAttribute("orientation") === "vertical" ? "vertical" : "horizontal", s = this.getAttribute("activation") === "manual" ? "manual" : "auto", n = !this.hasAttribute("loop") || x(this.getAttribute("loop")), o = getComputedStyle(this).direction === "rtl", l = Number(r.getAttribute("data-index"));
|
|
711
711
|
if (!Number.isFinite(l)) return;
|
|
712
712
|
const d = (c) => {
|
|
713
|
-
const b =
|
|
713
|
+
const b = A(a, l, c, {
|
|
714
714
|
wrap: n,
|
|
715
715
|
fallbackIndex: this._resolveFocusIndex(a, this._resolveSelectedIndex(a)),
|
|
716
716
|
getDisabled: (h) => h.disabled
|
|
717
717
|
});
|
|
718
718
|
b != null && (this._focusTab(b), s === "auto" ? this._setSelectedByIndex(a, b, !0) : this._emit("focus", a, b));
|
|
719
719
|
};
|
|
720
|
-
if (
|
|
720
|
+
if (i === "horizontal" && (t.key === "ArrowRight" && !o || t.key === "ArrowLeft" && o) || i === "vertical" && t.key === "ArrowDown") {
|
|
721
721
|
t.preventDefault(), d(1);
|
|
722
722
|
return;
|
|
723
723
|
}
|
|
724
|
-
if (
|
|
724
|
+
if (i === "horizontal" && (t.key === "ArrowLeft" && !o || t.key === "ArrowRight" && o) || i === "vertical" && t.key === "ArrowUp") {
|
|
725
725
|
t.preventDefault(), d(-1);
|
|
726
726
|
return;
|
|
727
727
|
}
|
|
@@ -742,10 +742,10 @@ class S extends m {
|
|
|
742
742
|
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), this._setSelectedByIndex(a, l, !0));
|
|
743
743
|
}
|
|
744
744
|
render() {
|
|
745
|
-
const t = this._tabsModel(), e = this._resolveSelectedIndex(t),
|
|
745
|
+
const t = this._tabsModel(), e = this._resolveSelectedIndex(t), r = this._resolveFocusIndex(t, e);
|
|
746
746
|
this._syncSelectedAttributes(t, e);
|
|
747
|
-
const a = this.getAttribute("orientation") === "vertical" ? "vertical" : "horizontal",
|
|
748
|
-
const o = n.index === e, l = n.icon ? `<span class="tab-icon" aria-hidden="true">${
|
|
747
|
+
const a = this.getAttribute("orientation") === "vertical" ? "vertical" : "horizontal", i = t.map((n) => {
|
|
748
|
+
const o = n.index === e, l = n.icon ? `<span class="tab-icon" aria-hidden="true">${g(n.icon)}</span>` : "";
|
|
749
749
|
return `
|
|
750
750
|
<button
|
|
751
751
|
type="button"
|
|
@@ -757,20 +757,20 @@ class S extends m {
|
|
|
757
757
|
aria-selected="${o ? "true" : "false"}"
|
|
758
758
|
aria-controls="${n.panelId}"
|
|
759
759
|
aria-disabled="${n.disabled ? "true" : "false"}"
|
|
760
|
-
tabindex="${n.index ===
|
|
760
|
+
tabindex="${n.index === r && !n.disabled ? "0" : "-1"}"
|
|
761
761
|
${n.disabled ? "disabled" : ""}
|
|
762
762
|
>
|
|
763
763
|
${l}
|
|
764
|
-
<span class="tab-label">${
|
|
764
|
+
<span class="tab-label">${g(n.label)}</span>
|
|
765
765
|
</button>
|
|
766
766
|
`;
|
|
767
767
|
}).join("");
|
|
768
768
|
this.setContent(`
|
|
769
|
-
<style>${
|
|
769
|
+
<style>${k}</style>
|
|
770
770
|
<section class="shell" part="shell">
|
|
771
771
|
<div class="nav" role="tablist" aria-orientation="${a}" part="nav">
|
|
772
772
|
<span class="indicator" part="indicator" aria-hidden="true"></span>
|
|
773
|
-
${
|
|
773
|
+
${i}
|
|
774
774
|
</div>
|
|
775
775
|
<div class="panel-wrap" part="panel-wrap" aria-live="polite">
|
|
776
776
|
<slot name="panel"></slot>
|
|
@@ -782,7 +782,7 @@ class S extends m {
|
|
|
782
782
|
s ? (this.setAttribute("aria-activedescendant", s.tabId), this.setAttribute("aria-controls", s.panelId)) : (this.removeAttribute("aria-activedescendant"), this.removeAttribute("aria-controls")), this._syncIndicator(e), this._syncPanels(t, e);
|
|
783
783
|
}
|
|
784
784
|
}
|
|
785
|
-
typeof customElements < "u" && !customElements.get("ui-tabs") && customElements.define("ui-tabs",
|
|
785
|
+
typeof customElements < "u" && !customElements.get("ui-tabs") && customElements.define("ui-tabs", I);
|
|
786
786
|
export {
|
|
787
|
-
|
|
787
|
+
I as UITabs
|
|
788
788
|
};
|
package/dist/textarea.cjs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const _=require("./ElementBase-EV6mVBUV.js"),y=`
|
|
2
2
|
<svg viewBox="0 0 20 20" aria-hidden="true" focusable="false">
|
|
3
3
|
<path d="m6 6 8 8M14 6l-8 8" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>
|
|
4
4
|
</svg>
|
|
5
|
-
`,
|
|
5
|
+
`,A=`
|
|
6
6
|
:host {
|
|
7
7
|
--ui-textarea-bg: var(--ui-color-surface, #ffffff);
|
|
8
8
|
--ui-textarea-text: var(--ui-color-text, #0f172a);
|
|
@@ -308,22 +308,22 @@
|
|
|
308
308
|
color: CanvasText;
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
|
-
`;function
|
|
312
|
-
<style>${
|
|
311
|
+
`;function x(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function b(r,t){const e=Number(r);return Number.isFinite(e)?e:t}const z=2147483647;function c(r){if(!r)return null;const t=Number(r);return!Number.isFinite(t)||t<0||t>z?null:Math.trunc(t)}class g extends _.ElementBase{constructor(){super(),this._uid=`ui-textarea-${Math.random().toString(36).slice(2,9)}`,this._textarea=null,this._clearBtn=null,this._countEl=null,this._debounceTimer=null,this._formUnregister=null,this._onInput=this._onInput.bind(this),this._onChange=this._onChange.bind(this),this._onClear=this._onClear.bind(this)}static get observedAttributes(){return["value","placeholder","disabled","clearable","size","validation","debounce","maxlength","minlength","rows","readonly","autofocus","resize","name","required","variant","color","radius","label","description","autosize","max-rows","show-count","density","tone","headless","data-error"]}connectedCallback(){super.connectedCallback(),this._tryRegisterWithForm()}disconnectedCallback(){this._detachListeners(),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null),this._formUnregister&&(this._formUnregister(),this._formUnregister=null),super.disconnectedCallback()}attributeChangedCallback(t,e,i){if(e===i)return;if(t==="name"&&this._tryRegisterWithForm(),t==="value"&&this._textarea){const a=i||"";this._textarea.value!==a&&(this._textarea.value=a),this._syncDynamicUi(),this._applyAutosize();return}if(new Set(["placeholder","disabled","maxlength","minlength","rows","readonly","required","resize","name","validation","show-count","clearable","autosize","max-rows","variant","size","density","tone","headless","color","radius","autofocus"]).has(t)){this._syncControlAttrs(),this._syncDynamicUi(),this._applyAutosize(),t==="autofocus"&&this.hasAttribute("autofocus")&&queueMicrotask(()=>{this._textarea?.focus()});return}this.isConnected&&this.requestRender()}get value(){return this.getAttribute("value")||""}set value(t){this.setAttribute("value",t||"")}_tryRegisterWithForm(){try{const t=this.closest?.("ui-form"),e=this.getAttribute("name");if(!t||typeof t.registerField!="function"||!e)return;this._formUnregister=t.registerField(e,{name:e,getValue:()=>this.value,setValue:i=>{this.value=i},validate:async()=>this._textarea?{valid:this._textarea.checkValidity(),message:this._textarea.validationMessage||void 0}:{valid:!0},setError:i=>{i?(this.setAttribute("validation","error"),this.setAttribute("data-error",i)):(this.removeAttribute("validation"),this.removeAttribute("data-error"))}})}catch{}}_detachListeners(){this._textarea&&(this._textarea.removeEventListener("input",this._onInput),this._textarea.removeEventListener("change",this._onChange)),this._clearBtn&&this._clearBtn.removeEventListener("click",this._onClear),this._clearBtn=null}_syncControlAttrs(){if(!this._textarea)return;const t=this.getAttribute("placeholder")||"",e=c(this.getAttribute("maxlength")),i=c(this.getAttribute("minlength")),s=b(this.getAttribute("rows"),4),a=this.hasAttribute("disabled"),u=this.hasAttribute("readonly"),o=this.hasAttribute("required"),d=this.getAttribute("name")||"",h=this.getAttribute("resize")||"vertical",m=this.getAttribute("validation"),p=this.getAttribute("color"),n=this.getAttribute("radius");this._textarea.placeholder=t,this._textarea.disabled=a,this._textarea.readOnly=u,this._textarea.required=o,this._textarea.rows=Math.max(1,s),this._textarea.name=d,this._textarea.style.resize=h,e!==null?this._textarea.maxLength=e:this._textarea.removeAttribute("maxlength"),i!==null?this._textarea.minLength=i:this._textarea.removeAttribute("minlength"),m==="error"?this._textarea.setAttribute("aria-invalid","true"):this._textarea.removeAttribute("aria-invalid"),p?this.style.setProperty("--ui-textarea-accent",p):this.style.removeProperty("--ui-textarea-accent"),n&&n!=="none"&&n!=="large"&&n!=="full"?this.style.setProperty("--ui-textarea-radius",n):this.style.removeProperty("--ui-textarea-radius");const l=[],f=!!(this.getAttribute("description")||this.querySelector('[slot="description"]')),v=!!(this.getAttribute("data-error")||this.querySelector('[slot="error"]'));f&&l.push(`${this._uid}-description`),v&&l.push(`${this._uid}-error`),(this.hasAttribute("show-count")||c(this.getAttribute("maxlength"))!==null)&&l.push(`${this._uid}-count`),!!(this.getAttribute("label")||this.querySelector('[slot="label"]'))?this._textarea.setAttribute("aria-labelledby",`${this._uid}-label`):this._textarea.removeAttribute("aria-labelledby"),l.length?this._textarea.setAttribute("aria-describedby",l.join(" ")):this._textarea.removeAttribute("aria-describedby")}_syncDynamicUi(){const t=this._textarea?.value||this.getAttribute("value")||"",e=c(this.getAttribute("maxlength")),i=this.hasAttribute("clearable");this._clearBtn&&(i&&t&&!this.hasAttribute("disabled")&&!this.hasAttribute("readonly")?this._clearBtn.removeAttribute("hidden"):this._clearBtn.setAttribute("hidden","")),this._countEl&&(this.hasAttribute("show-count")||e!==null?(this._countEl.removeAttribute("hidden"),e!==null?this._countEl.textContent=`${t.length} / ${e}`:this._countEl.textContent=`${t.length}`):this._countEl.setAttribute("hidden",""))}_applyAutosize(){if(!this._textarea)return;if(!this.hasAttribute("autosize")){this._textarea.style.height="",this._textarea.style.overflowY="";return}this._textarea.style.height="auto";const t=this._textarea.scrollHeight,e=b(this.getAttribute("max-rows"),0);if(e>0){const i=getComputedStyle(this._textarea),s=parseFloat(i.lineHeight||"20")||20,a=parseFloat(i.borderTopWidth||"0")||0,u=parseFloat(i.borderBottomWidth||"0")||0,o=parseFloat(i.paddingTop||"0")||0,d=parseFloat(i.paddingBottom||"0")||0,h=s*e+a+u+o+d;this._textarea.style.height=`${Math.min(t,h)}px`,this._textarea.style.overflowY=t>h?"auto":"hidden";return}this._textarea.style.height=`${t}px`,this._textarea.style.overflowY="hidden"}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{detail:{value:e,length:e.length,name:this.getAttribute("name")||""},bubbles:!0,composed:!0}))}_onInput(t){const e=t.target.value;this.getAttribute("value")!==e&&this.setAttribute("value",e),this._syncDynamicUi(),this._applyAutosize(),this._emit("input",e);const i=b(this.getAttribute("debounce"),0);i>0?(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._emit("debounced-input",e),this._debounceTimer=null},i)):this._emit("debounced-input",e)}_onChange(t){const e=t.target.value;this._emit("change",e)}_onClear(t){t.preventDefault(),!(this.hasAttribute("disabled")||this.hasAttribute("readonly"))&&(this.value="",this._textarea&&(this._textarea.value="",this._textarea.focus()),this._syncDynamicUi(),this._applyAutosize(),this._emit("input",""),this._emit("change",""),this.dispatchEvent(new CustomEvent("clear",{bubbles:!0,composed:!0})))}render(){const t=this.getAttribute("value")||"",e=this.getAttribute("label")||"",i=this.getAttribute("description")||"",s=this.getAttribute("data-error")||"",a=!!(e||i||this.querySelector('[slot="label"]')||this.querySelector('[slot="description"]')),o=this.hasAttribute("clearable")&&!!t&&!this.hasAttribute("disabled")&&!this.hasAttribute("readonly");this.setContent(`
|
|
312
|
+
<style>${A}</style>
|
|
313
313
|
<div class="shell" part="shell">
|
|
314
314
|
<div class="meta" part="meta" ${a?"":"hidden"}>
|
|
315
|
-
<label id="${this._uid}-label" class="label" part="label"><slot name="label">${
|
|
316
|
-
<div id="${this._uid}-description" class="description" part="description"><slot name="description">${
|
|
315
|
+
<label id="${this._uid}-label" class="label" part="label"><slot name="label">${x(e)}</slot></label>
|
|
316
|
+
<div id="${this._uid}-description" class="description" part="description"><slot name="description">${x(i)}</slot></div>
|
|
317
317
|
</div>
|
|
318
318
|
|
|
319
319
|
<div class="field" part="field">
|
|
320
320
|
<textarea part="textarea"></textarea>
|
|
321
|
-
<button type="button" part="clear" class="clear-btn" aria-label="Clear text" ${
|
|
321
|
+
<button type="button" part="clear" class="clear-btn" aria-label="Clear text" ${o?"":"hidden"}>${y}</button>
|
|
322
322
|
</div>
|
|
323
323
|
|
|
324
324
|
<div class="footer" part="footer">
|
|
325
|
-
<div id="${this._uid}-error" class="error" part="error"><slot name="error">${
|
|
325
|
+
<div id="${this._uid}-error" class="error" part="error"><slot name="error">${x(s)}</slot></div>
|
|
326
326
|
<div id="${this._uid}-count" class="count" part="count" hidden></div>
|
|
327
327
|
</div>
|
|
328
328
|
</div>
|
|
329
|
-
`),this._detachListeners(),this._textarea=this.root.querySelector("textarea"),this._clearBtn=this.root.querySelector(".clear-btn"),this._countEl=this.root.querySelector(".count"),this._textarea&&(this._textarea.value=t,this._syncControlAttrs(),this._syncDynamicUi(),this._applyAutosize(),this._textarea.addEventListener("input",this._onInput),this._textarea.addEventListener("change",this._onChange),this._clearBtn?.addEventListener("click",this._onClear),this.hasAttribute("autofocus")&&queueMicrotask(()=>{this._textarea?.focus()}))}shouldRenderOnAttributeChange(t,e,i){return t==="label"||t==="description"||t==="data-error"}}typeof customElements<"u"&&!customElements.get("ui-textarea")&&customElements.define("ui-textarea",
|
|
329
|
+
`),this._detachListeners(),this._textarea=this.root.querySelector("textarea"),this._clearBtn=this.root.querySelector(".clear-btn"),this._countEl=this.root.querySelector(".count"),this._textarea&&(this._textarea.value=t,this._syncControlAttrs(),this._syncDynamicUi(),this._applyAutosize(),this._textarea.addEventListener("input",this._onInput),this._textarea.addEventListener("change",this._onChange),this._clearBtn?.addEventListener("click",this._onClear),this.hasAttribute("autofocus")&&queueMicrotask(()=>{this._textarea?.focus()}))}shouldRenderOnAttributeChange(t,e,i){return t==="label"||t==="description"||t==="data-error"}}typeof customElements<"u"&&!customElements.get("ui-textarea")&&customElements.define("ui-textarea",g);exports.UITextarea=g;
|