@editora/ui-core 0.1.19 → 0.1.20
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/{ElementBase-1b301e7f.js → ElementBase-EV6mVBUV.js} +1 -1
- package/dist/{ElementBase-909688f3.mjs → ElementBase-YlTLMsGk.mjs} +3 -3
- package/dist/accordion.cjs.js +3 -3
- package/dist/accordion.esm.js +39 -62
- package/dist/alert-dialog.cjs.js +19 -19
- package/dist/alert-dialog.esm.js +69 -87
- package/dist/alert.cjs.js +1 -1
- package/dist/alert.esm.js +4 -7
- package/dist/anchor.cjs.js +2 -2
- package/dist/anchor.esm.js +3 -3
- package/dist/animated-beam.cjs.js +83 -83
- package/dist/animated-beam.esm.js +250 -277
- package/dist/animated-list.cjs.js +4 -4
- package/dist/animated-list.esm.js +47 -61
- package/dist/animated-text.cjs.js +2 -2
- package/dist/animated-text.esm.js +13 -24
- package/dist/app-header.cjs.js +3 -3
- package/dist/app-header.esm.js +11 -13
- package/dist/aspect-ratio.cjs.js +1 -1
- package/dist/aspect-ratio.esm.js +4 -7
- package/dist/avatar.cjs.js +1 -1
- package/dist/avatar.esm.js +7 -13
- package/dist/badge.cjs.js +1 -1
- package/dist/badge.esm.js +4 -7
- package/dist/block-controls.cjs.js +2 -2
- package/dist/block-controls.esm.js +19 -35
- package/dist/box.cjs.js +1 -1
- package/dist/box.esm.js +8 -15
- package/dist/breadcrumb.cjs.js +2 -2
- package/dist/breadcrumb.esm.js +20 -37
- package/dist/button.cjs.js +1 -521
- package/dist/button.esm.js +2 -671
- package/dist/{calendar-2c11b824.mjs → calendar-DLY4acgn.mjs} +293 -342
- package/dist/{calendar-a8735e40.js → calendar-Dkof-FTK.js} +25 -25
- package/dist/calendar.cjs.js +1 -1
- package/dist/calendar.esm.js +8 -9
- package/dist/card.cjs.js +4 -4
- package/dist/card.esm.js +13 -19
- package/dist/chart.cjs.js +64 -64
- package/dist/chart.esm.js +223 -254
- package/dist/checkbox.cjs.js +1 -1
- package/dist/checkbox.esm.js +2 -3
- package/dist/collapsible.cjs.js +1 -1
- package/dist/collapsible.esm.js +5 -9
- package/dist/{collection-a1aac0c6.mjs → collection-C7URGjEI.mjs} +8 -14
- package/dist/collection.cjs.js +1 -1
- package/dist/collection.esm.js +4 -7
- package/dist/color-picker.cjs.js +9 -9
- package/dist/color-picker.esm.js +189 -252
- package/dist/combobox.cjs.js +13 -13
- package/dist/combobox.esm.js +93 -126
- package/dist/command-palette.cjs.js +3 -3
- package/dist/command-palette.esm.js +19 -30
- package/dist/command.cjs.js +4 -4
- package/dist/command.esm.js +41 -53
- package/dist/components/ui-orbiter.d.ts.map +1 -1
- package/dist/components/ui-skeleton.d.ts.map +1 -1
- package/dist/components/ui-split-button.d.ts +1 -0
- package/dist/components/ui-split-button.d.ts.map +1 -1
- package/dist/components/ui-time-picker.d.ts.map +1 -1
- package/dist/container.cjs.js +2 -2
- package/dist/container.esm.js +2 -3
- package/dist/context-menu.cjs.js +8 -8
- package/dist/context-menu.esm.js +157 -219
- package/dist/control-group.cjs.js +1 -1
- package/dist/control-group.esm.js +2 -3
- package/dist/data-table.cjs.js +4 -4
- package/dist/data-table.esm.js +299 -381
- package/dist/date-field.cjs.js +3 -3
- package/dist/date-field.esm.js +68 -80
- package/dist/date-picker.cjs.js +9 -9
- package/dist/date-picker.esm.js +69 -97
- package/dist/date-range-picker.cjs.js +3 -3
- package/dist/date-range-picker.esm.js +32 -56
- package/dist/date-range-time-picker.cjs.js +9 -9
- package/dist/date-range-time-picker.esm.js +111 -140
- package/dist/date-time-picker.cjs.js +4 -4
- package/dist/date-time-picker.esm.js +112 -144
- package/dist/date-time-utils-Dmost5Ee.js +1 -0
- package/dist/date-time-utils-y1N2gvG2.mjs +268 -0
- package/dist/description.cjs.js +1 -1
- package/dist/description.esm.js +3 -5
- package/dist/dialog.cjs.js +12 -12
- package/dist/dialog.esm.js +44 -63
- package/dist/direction-provider.cjs.js +1 -1
- package/dist/direction-provider.esm.js +2 -3
- package/dist/{dismissable-layer-9c7e6b58.mjs → dismissable-layer-BmPIoK80.mjs} +29 -33
- package/dist/dismissable-layer-DNfrKA20.js +1 -0
- package/dist/dismissable-layer.cjs.js +2 -2
- package/dist/dismissable-layer.esm.js +4 -6
- package/dist/dock.cjs.js +5 -5
- package/dist/dock.esm.js +134 -155
- package/dist/drawer.cjs.js +2 -2
- package/dist/drawer.esm.js +18 -35
- package/dist/dropdown.cjs.js +2 -2
- package/dist/dropdown.esm.js +119 -149
- package/dist/dropzone.cjs.js +1 -1
- package/dist/dropzone.esm.js +0 -1
- package/dist/empty-state.cjs.js +1 -1
- package/dist/empty-state.esm.js +1 -1
- package/dist/field-error.cjs.js +1 -1
- package/dist/field-error.esm.js +3 -5
- package/dist/field.cjs.js +5 -5
- package/dist/field.esm.js +27 -34
- package/dist/fieldset.cjs.js +4 -4
- package/dist/fieldset.esm.js +19 -24
- package/dist/file-upload.cjs.js +4 -4
- package/dist/file-upload.esm.js +69 -93
- package/dist/flex.cjs.js +1 -1
- package/dist/flex.esm.js +5 -9
- package/dist/floating-toolbar.cjs.js +4 -4
- package/dist/floating-toolbar.esm.js +60 -85
- package/dist/focus-scope-Bwug2gDv.js +1 -0
- package/dist/{focus-scope-103833ee.mjs → focus-scope-CmEsG5UZ.mjs} +39 -48
- package/dist/focus-scope.cjs.js +2 -2
- package/dist/focus-scope.esm.js +15 -20
- package/dist/form.cjs.js +2 -2
- package/dist/form.esm.js +26 -53
- package/dist/gantt.cjs.js +43 -43
- package/dist/gantt.esm.js +295 -322
- package/dist/grid.cjs.js +1 -1
- package/dist/grid.esm.js +5 -9
- package/dist/hover-card.cjs.js +4 -4
- package/dist/hover-card.esm.js +22 -28
- package/dist/icon-cloud.cjs.js +7 -7
- package/dist/icon-cloud.esm.js +48 -62
- package/dist/icon.cjs.js +1 -1
- package/dist/icon.esm.js +2 -4
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +378 -390
- package/dist/inline-edit.cjs.js +11 -11
- package/dist/inline-edit.esm.js +32 -36
- package/dist/input.cjs.js +17 -17
- package/dist/input.esm.js +50 -63
- package/dist/label.cjs.js +2 -2
- package/dist/label.esm.js +8 -17
- package/dist/layout.cjs.js +2 -2
- package/dist/layout.esm.js +20 -26
- package/dist/listbox-B6QgECax.js +46 -0
- package/dist/listbox-DJamVeFj.mjs +200 -0
- package/dist/listbox.cjs.js +1 -1
- package/dist/listbox.esm.js +2 -4
- package/dist/marquee.cjs.js +5 -5
- package/dist/marquee.esm.js +33 -50
- package/dist/masonry-grid.cjs.js +1 -1
- package/dist/masonry-grid.esm.js +5 -9
- package/dist/menu.cjs.js +3 -3
- package/dist/menu.esm.js +106 -126
- package/dist/menubar.cjs.js +5 -5
- package/dist/menubar.esm.js +118 -164
- package/dist/meter.cjs.js +2 -2
- package/dist/meter.esm.js +4 -4
- package/dist/multi-select.cjs.js +4 -4
- package/dist/multi-select.esm.js +120 -140
- package/dist/navigation-menu.cjs.js +4 -4
- package/dist/navigation-menu.esm.js +44 -55
- package/dist/number-field.cjs.js +2 -2
- package/dist/number-field.esm.js +73 -98
- package/dist/number-ticker.cjs.js +3 -3
- package/dist/number-ticker.esm.js +22 -43
- package/dist/odometer.cjs.js +1 -1
- package/dist/odometer.esm.js +5 -9
- package/dist/orbiter.cjs.js +13 -13
- package/dist/orbiter.esm.js +79 -90
- package/dist/{overlayManager-5bbd4dc3.mjs → overlayManager-BJjU1VA8.mjs} +4 -5
- package/dist/{overlayManager-0eda4e08.js → overlayManager-CSy3fJmJ.js} +1 -1
- package/dist/pagination.cjs.js +2 -2
- package/dist/pagination.esm.js +14 -18
- package/dist/{panel-group-a376cc5e.mjs → panel-group-8sVNnGxg.mjs} +24 -46
- package/dist/panel-group-CaD0_KQf.js +36 -0
- package/dist/panel-group.cjs.js +1 -1
- package/dist/panel-group.esm.js +2 -5
- package/dist/panel.cjs.js +4 -4
- package/dist/panel.esm.js +8 -10
- package/dist/password-field.cjs.js +9 -9
- package/dist/password-field.esm.js +62 -82
- package/dist/pin-input.cjs.js +3 -3
- package/dist/pin-input.esm.js +33 -39
- package/dist/placement-grid.cjs.js +4 -4
- package/dist/placement-grid.esm.js +108 -131
- package/dist/plugin-panel.cjs.js +7 -7
- package/dist/plugin-panel.esm.js +13 -15
- package/dist/popover.cjs.js +2 -2
- package/dist/popover.esm.js +21 -31
- package/dist/portal-DgpQ3Jo1.js +1 -0
- package/dist/{portal-fe73e5cc.mjs → portal-bR42gHvG.mjs} +43 -48
- package/dist/portal.cjs.js +2 -2
- package/dist/portal.esm.js +10 -19
- package/dist/{positioner-e9770c66.mjs → positioner-D0VGxtYU.mjs} +189 -209
- package/dist/positioner-D_fqyx_j.js +1 -0
- package/dist/positioner.cjs.js +2 -2
- package/dist/positioner.esm.js +11 -18
- package/dist/presence.cjs.js +1 -1
- package/dist/presence.esm.js +7 -13
- package/dist/progress.cjs.js +1 -1
- package/dist/progress.esm.js +5 -9
- package/dist/quick-actions.cjs.js +6 -6
- package/dist/quick-actions.esm.js +52 -62
- package/dist/radio-group.cjs.js +13 -13
- package/dist/radio-group.esm.js +39 -51
- package/dist/radio.cjs.js +1 -1
- package/dist/radio.esm.js +5 -9
- package/dist/rating.cjs.js +1 -1
- package/dist/rating.esm.js +12 -23
- package/dist/{roving-focus-group-4350c9a7.mjs → roving-focus-group-Dbm1Jko_.mjs} +3 -6
- package/dist/roving-focus-group.cjs.js +1 -1
- package/dist/roving-focus-group.esm.js +3 -5
- package/dist/runtime-CTaOSmBj.js +1 -0
- package/dist/{runtime-161f68a2.mjs → runtime-D1gFh1fS.mjs} +338 -366
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.esm.js +6 -6
- package/dist/scroll-area.cjs.js +3 -3
- package/dist/scroll-area.esm.js +38 -46
- package/dist/{scroll-lock-31da444f.mjs → scroll-lock-LfqXXqsu.mjs} +5 -9
- package/dist/section.cjs.js +1 -1
- package/dist/section.esm.js +1 -1
- package/dist/select.cjs.js +7 -7
- package/dist/select.esm.js +67 -97
- package/dist/selection-popup.cjs.js +1 -1
- package/dist/selection-popup.esm.js +8 -15
- package/dist/separator.cjs.js +1 -1
- package/dist/separator.esm.js +1 -1
- package/dist/sidebar.cjs.js +18 -18
- package/dist/sidebar.esm.js +117 -139
- package/dist/skeleton.cjs.js +11 -11
- package/dist/skeleton.esm.js +27 -24
- package/dist/slider.cjs.js +1 -1
- package/dist/slider.esm.js +6 -11
- package/dist/slot.cjs.js +4 -4
- package/dist/slot.esm.js +16 -19
- package/dist/sortable.cjs.js +45 -45
- package/dist/sortable.esm.js +421 -524
- package/dist/spinning-text.cjs.js +12 -12
- package/dist/spinning-text.esm.js +80 -92
- package/dist/split-button.cjs.js +4 -4
- package/dist/split-button.esm.js +77 -62
- package/dist/splitter.cjs.js +1 -1
- package/dist/splitter.esm.js +1 -1
- package/dist/stepper.cjs.js +8 -8
- package/dist/stepper.esm.js +32 -52
- package/dist/switch.cjs.js +7 -7
- package/dist/switch.esm.js +23 -31
- package/dist/table.cjs.js +2 -2
- package/dist/table.esm.js +46 -56
- package/dist/tabs.cjs.js +3 -3
- package/dist/tabs.esm.js +35 -55
- package/dist/tags-input.cjs.js +4 -4
- package/dist/tags-input.esm.js +45 -62
- package/dist/textarea.cjs.js +6 -6
- package/dist/textarea.esm.js +32 -41
- package/dist/time-field.cjs.js +4 -4
- package/dist/time-field.esm.js +70 -84
- package/dist/time-picker.cjs.js +22 -22
- package/dist/time-picker.esm.js +88 -110
- package/dist/timeline.cjs.js +1 -1
- package/dist/timeline.esm.js +3 -5
- package/dist/toast.cjs.js +2 -2
- package/dist/toast.esm.js +33 -47
- package/dist/toggle-group.cjs.js +6 -6
- package/dist/toggle-group.esm.js +85 -105
- package/dist/toggle.cjs.js +1 -1
- package/dist/toggle.esm.js +3 -5
- package/dist/toolbar.cjs.js +1 -1
- package/dist/toolbar.esm.js +13 -24
- package/dist/tooltip.cjs.js +2 -2
- package/dist/tooltip.esm.js +31 -42
- package/dist/transfer-list.cjs.js +19 -19
- package/dist/transfer-list.esm.js +98 -111
- package/dist/{tree-dcd74a4a.mjs → tree-B3kE8ESs.mjs} +55 -62
- package/dist/tree-Dx_kv_ih.js +39 -0
- package/dist/tree-item.cjs.js +2 -2
- package/dist/tree-item.esm.js +2 -3
- package/dist/tree.cjs.js +1 -1
- package/dist/tree.esm.js +2 -5
- package/dist/ui-button-Q0GNNWKC.mjs +665 -0
- package/dist/ui-button-rXQOS9QJ.js +521 -0
- package/dist/{icon-9e9da03b.js → ui-icon-BzVNC_lr.js} +4 -4
- package/dist/{icon-e2a85cc1.mjs → ui-icon-YI6lyuqU.mjs} +58 -65
- package/dist/visually-hidden.cjs.js +1 -1
- package/dist/visually-hidden.esm.js +1 -1
- package/dist/wizard.cjs.js +14 -14
- package/dist/wizard.esm.js +85 -105
- package/package.json +2 -2
- package/dist/date-time-utils-66480de4.js +0 -1
- package/dist/date-time-utils-a2c7af25.mjs +0 -307
- package/dist/dismissable-layer-193e3bed.js +0 -1
- package/dist/focus-scope-2b12b4e7.js +0 -1
- package/dist/listbox-308789a0.mjs +0 -210
- package/dist/listbox-ef2f708e.js +0 -46
- package/dist/panel-group-40254cdd.js +0 -36
- package/dist/portal-c69756c0.js +0 -1
- package/dist/positioner-33529bb8.js +0 -1
- package/dist/runtime-3f13807b.js +0 -1
- package/dist/tree-0a7a8d05.js +0 -39
- /package/dist/{collection-a2969ad2.js → collection-qv8A8rq4.js} +0 -0
- /package/dist/{menu-item-styles-27fdbac4.mjs → menu-item-styles-CZiPwPwl.mjs} +0 -0
- /package/dist/{menu-item-styles-83ad1e22.js → menu-item-styles-CbNUEwP2.js} +0 -0
- /package/dist/{roving-focus-group-5c059bf9.js → roving-focus-group-BdJ_4Njm.js} +0 -0
- /package/dist/{scroll-lock-d7b0df21.js → scroll-lock-BX6e3Ced.js} +0 -0
package/dist/tabs.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as m } from "./ElementBase-
|
|
2
|
-
import { s as v, r as y, f as _, g as p, m as w } from "./roving-focus-group-
|
|
1
|
+
import { E as m } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
|
+
import { s as v, r as y, f as _, g as p, m as w } from "./roving-focus-group-Dbm1Jko_.mjs";
|
|
3
3
|
const A = `
|
|
4
4
|
:host {
|
|
5
5
|
--ui-tabs-nav-bg: var(--ui-color-surface, #ffffff);
|
|
@@ -490,8 +490,7 @@ function f(u) {
|
|
|
490
490
|
return String(u).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
491
491
|
}
|
|
492
492
|
function g(u) {
|
|
493
|
-
if (u == null)
|
|
494
|
-
return !1;
|
|
493
|
+
if (u == null) return !1;
|
|
495
494
|
const t = String(u).toLowerCase();
|
|
496
495
|
return t !== "false" && t !== "0" && t !== "off";
|
|
497
496
|
}
|
|
@@ -568,24 +567,19 @@ class S extends m {
|
|
|
568
567
|
}
|
|
569
568
|
_tabsModel() {
|
|
570
569
|
return this._sourceTabs().map((t, e) => {
|
|
571
|
-
|
|
572
|
-
const i = t.getAttribute("data-value") || t.getAttribute("value") || String(e), a = t.getAttribute("data-label") || ((b = t.textContent) == null ? void 0 : b.trim()) || `Tab ${e + 1}`, r = t.getAttribute("data-icon") || "", s = t.hasAttribute("disabled") || g(t.getAttribute("data-disabled")), n = `${this._uid}-tab-${e}`, o = `${this._uid}-panel-${e}`;
|
|
570
|
+
const i = t.getAttribute("data-value") || t.getAttribute("value") || String(e), a = t.getAttribute("data-label") || t.textContent?.trim() || `Tab ${e + 1}`, r = t.getAttribute("data-icon") || "", s = t.hasAttribute("disabled") || g(t.getAttribute("data-disabled")), n = `${this._uid}-tab-${e}`, o = `${this._uid}-panel-${e}`;
|
|
573
571
|
return { index: e, value: i, label: a, icon: r, disabled: s, tabId: n, panelId: o };
|
|
574
572
|
});
|
|
575
573
|
}
|
|
576
574
|
_resolveSelectedIndex(t) {
|
|
577
|
-
if (!t.length)
|
|
578
|
-
return -1;
|
|
575
|
+
if (!t.length) return -1;
|
|
579
576
|
const e = this.getAttribute("selected"), i = this.getAttribute("value"), a = this._sourceTabs();
|
|
580
577
|
let r = -1;
|
|
581
578
|
if (e != null && e !== "") {
|
|
582
579
|
const s = Number(e);
|
|
583
580
|
Number.isFinite(s) ? r = Math.trunc(s) : r = t.findIndex((n) => n.value === e);
|
|
584
581
|
}
|
|
585
|
-
return r < 0 && i && (r = t.findIndex((s) => s.value === i)), r < 0 && (r = t.findIndex((s, n) =>
|
|
586
|
-
var o;
|
|
587
|
-
return !!((o = a[n]) != null && o.hasAttribute("data-active")) && !s.disabled;
|
|
588
|
-
})), (r < 0 || !t[r] || t[r].disabled) && (r = t.findIndex((s) => !s.disabled)), r;
|
|
582
|
+
return r < 0 && i && (r = t.findIndex((s) => s.value === i)), r < 0 && (r = t.findIndex((s, n) => !!a[n]?.hasAttribute("data-active") && !s.disabled)), (r < 0 || !t[r] || t[r].disabled) && (r = t.findIndex((s) => !s.disabled)), r;
|
|
589
583
|
}
|
|
590
584
|
_syncSelectedAttributes(t, e) {
|
|
591
585
|
const i = t[e];
|
|
@@ -602,8 +596,7 @@ class S extends m {
|
|
|
602
596
|
}
|
|
603
597
|
_emit(t, e, i) {
|
|
604
598
|
const a = e[i];
|
|
605
|
-
if (!a)
|
|
606
|
-
return;
|
|
599
|
+
if (!a) return;
|
|
607
600
|
const r = {
|
|
608
601
|
selected: i,
|
|
609
602
|
index: i,
|
|
@@ -616,8 +609,7 @@ class S extends m {
|
|
|
616
609
|
}
|
|
617
610
|
_setSelectedByIndex(t, e, i) {
|
|
618
611
|
const a = t[e];
|
|
619
|
-
if (!a || a.disabled)
|
|
620
|
-
return;
|
|
612
|
+
if (!a || a.disabled) return;
|
|
621
613
|
if (this._resolveSelectedIndex(t) === e) {
|
|
622
614
|
this._focusTab(e);
|
|
623
615
|
return;
|
|
@@ -625,32 +617,28 @@ class S extends m {
|
|
|
625
617
|
this._focusIndex = e, this.setAttribute("selected", String(e)), this.setAttribute("value", a.value), i && (this._emit("change", t, e), this._emit("select", t, e));
|
|
626
618
|
}
|
|
627
619
|
_syncSelectionUi() {
|
|
628
|
-
if (!this.isConnected)
|
|
629
|
-
return;
|
|
620
|
+
if (!this.isConnected) return;
|
|
630
621
|
if (!this.root.querySelector(".nav")) {
|
|
631
622
|
this.requestRender();
|
|
632
623
|
return;
|
|
633
624
|
}
|
|
634
625
|
const t = this._tabsModel();
|
|
635
|
-
if (!t.length)
|
|
636
|
-
return;
|
|
626
|
+
if (!t.length) return;
|
|
637
627
|
const e = this._resolveSelectedIndex(t), i = this._resolveFocusIndex(t, e);
|
|
638
628
|
this._syncSelectedAttributes(t, e);
|
|
639
629
|
const a = Array.from(this.root.querySelectorAll(".tab"));
|
|
640
630
|
a.forEach((s, n) => {
|
|
641
631
|
const o = t[n];
|
|
642
|
-
if (!o)
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
s.setAttribute("aria-selected", b ? "true" : "false"), s.setAttribute("aria-controls", o.panelId), s.setAttribute("aria-disabled", o.disabled ? "true" : "false"), o.disabled ? s.setAttribute("disabled", "") : s.removeAttribute("disabled");
|
|
632
|
+
if (!o) return;
|
|
633
|
+
const l = n === e;
|
|
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");
|
|
646
635
|
}), v(a, a[i] || null, { activeAttribute: null });
|
|
647
636
|
const r = t[e];
|
|
648
637
|
this._syncIndicator(e), r ? (this.setAttribute("aria-activedescendant", r.tabId), this.setAttribute("aria-controls", r.panelId), this._scrollSelectedTabIntoView(e)) : (this.removeAttribute("aria-activedescendant"), this.removeAttribute("aria-controls")), this._syncPanels(t, e);
|
|
649
638
|
}
|
|
650
639
|
_syncIndicator(t) {
|
|
651
640
|
const e = this.root.querySelector(".nav");
|
|
652
|
-
if (!e)
|
|
653
|
-
return;
|
|
641
|
+
if (!e) return;
|
|
654
642
|
const i = this.getAttribute("variant") || "default", a = i === "indicator";
|
|
655
643
|
if (!a && !(i === "indicator-line")) {
|
|
656
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");
|
|
@@ -662,8 +650,8 @@ class S extends m {
|
|
|
662
650
|
return;
|
|
663
651
|
}
|
|
664
652
|
const n = this.getAttribute("orientation") === "vertical" ? "vertical" : "horizontal", o = getComputedStyle(this).direction === "rtl";
|
|
665
|
-
let
|
|
666
|
-
a ? (
|
|
653
|
+
let l = s.offsetLeft, d = s.offsetTop, c = s.offsetWidth, b = s.offsetHeight;
|
|
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");
|
|
667
655
|
}
|
|
668
656
|
_syncPanels(t, e) {
|
|
669
657
|
const i = this._sourcePanels(), a = this.root.querySelector(".panel-wrap");
|
|
@@ -671,7 +659,7 @@ class S extends m {
|
|
|
671
659
|
try {
|
|
672
660
|
i.forEach((r, s) => {
|
|
673
661
|
const n = t[s], o = s === e;
|
|
674
|
-
r.id =
|
|
662
|
+
r.id = n?.panelId || `${this._uid}-panel-${s}`, r.setAttribute("role", "tabpanel"), r.setAttribute("tabindex", o ? "0" : "-1"), r.setAttribute("aria-hidden", o ? "false" : "true"), n && r.setAttribute("aria-labelledby", n.tabId), o ? r.removeAttribute("hidden") : r.setAttribute("hidden", "");
|
|
675
663
|
});
|
|
676
664
|
} finally {
|
|
677
665
|
this._isSyncing = !1;
|
|
@@ -698,8 +686,7 @@ class S extends m {
|
|
|
698
686
|
}
|
|
699
687
|
_scrollSelectedTabIntoView(t) {
|
|
700
688
|
const e = this.root.querySelector(".nav"), i = this.root.querySelector(`.tab[data-index="${t}"]`);
|
|
701
|
-
if (!e || !i)
|
|
702
|
-
return;
|
|
689
|
+
if (!e || !i) return;
|
|
703
690
|
const a = this.getAttribute("orientation") !== "vertical", r = typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
704
691
|
typeof i.scrollIntoView == "function" && i.scrollIntoView({
|
|
705
692
|
behavior: r ? "auto" : "smooth",
|
|
@@ -708,32 +695,27 @@ class S extends m {
|
|
|
708
695
|
});
|
|
709
696
|
}
|
|
710
697
|
_onClick(t) {
|
|
711
|
-
const
|
|
712
|
-
if (!i || i.disabled)
|
|
713
|
-
return;
|
|
698
|
+
const i = t.target?.closest(".tab");
|
|
699
|
+
if (!i || i.disabled) return;
|
|
714
700
|
const a = Number(i.getAttribute("data-index"));
|
|
715
|
-
if (!Number.isFinite(a))
|
|
716
|
-
return;
|
|
701
|
+
if (!Number.isFinite(a)) return;
|
|
717
702
|
const r = this._tabsModel();
|
|
718
703
|
this._setSelectedByIndex(r, a, !0);
|
|
719
704
|
}
|
|
720
705
|
_onKeyDown(t) {
|
|
721
|
-
const
|
|
722
|
-
if (!i)
|
|
723
|
-
return;
|
|
706
|
+
const i = t.target?.closest(".tab");
|
|
707
|
+
if (!i) return;
|
|
724
708
|
const a = this._tabsModel();
|
|
725
|
-
if (!a.length)
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
if (!Number.isFinite(b))
|
|
729
|
-
return;
|
|
709
|
+
if (!a.length) return;
|
|
710
|
+
const r = 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(i.getAttribute("data-index"));
|
|
711
|
+
if (!Number.isFinite(l)) return;
|
|
730
712
|
const d = (c) => {
|
|
731
|
-
const
|
|
713
|
+
const b = w(a, l, c, {
|
|
732
714
|
wrap: n,
|
|
733
715
|
fallbackIndex: this._resolveFocusIndex(a, this._resolveSelectedIndex(a)),
|
|
734
716
|
getDisabled: (h) => h.disabled
|
|
735
717
|
});
|
|
736
|
-
|
|
718
|
+
b != null && (this._focusTab(b), s === "auto" ? this._setSelectedByIndex(a, b, !0) : this._emit("focus", a, b));
|
|
737
719
|
};
|
|
738
720
|
if (r === "horizontal" && (t.key === "ArrowRight" && !o || t.key === "ArrowLeft" && o) || r === "vertical" && t.key === "ArrowDown") {
|
|
739
721
|
t.preventDefault(), d(1);
|
|
@@ -745,27 +727,25 @@ class S extends m {
|
|
|
745
727
|
}
|
|
746
728
|
if (t.key === "Home") {
|
|
747
729
|
t.preventDefault();
|
|
748
|
-
const c = p(a, "first", (
|
|
749
|
-
if (c < 0)
|
|
750
|
-
return;
|
|
730
|
+
const c = p(a, "first", (b) => b.disabled);
|
|
731
|
+
if (c < 0) return;
|
|
751
732
|
this._focusTab(c), s === "auto" ? this._setSelectedByIndex(a, c, !0) : this._emit("focus", a, c);
|
|
752
733
|
return;
|
|
753
734
|
}
|
|
754
735
|
if (t.key === "End") {
|
|
755
736
|
t.preventDefault();
|
|
756
|
-
const c = p(a, "last", (
|
|
757
|
-
if (c < 0)
|
|
758
|
-
return;
|
|
737
|
+
const c = p(a, "last", (b) => b.disabled);
|
|
738
|
+
if (c < 0) return;
|
|
759
739
|
this._focusTab(c), s === "auto" ? this._setSelectedByIndex(a, c, !0) : this._emit("focus", a, c);
|
|
760
740
|
return;
|
|
761
741
|
}
|
|
762
|
-
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), this._setSelectedByIndex(a,
|
|
742
|
+
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), this._setSelectedByIndex(a, l, !0));
|
|
763
743
|
}
|
|
764
744
|
render() {
|
|
765
745
|
const t = this._tabsModel(), e = this._resolveSelectedIndex(t), i = this._resolveFocusIndex(t, e);
|
|
766
746
|
this._syncSelectedAttributes(t, e);
|
|
767
747
|
const a = this.getAttribute("orientation") === "vertical" ? "vertical" : "horizontal", r = t.map((n) => {
|
|
768
|
-
const o = n.index === e,
|
|
748
|
+
const o = n.index === e, l = n.icon ? `<span class="tab-icon" aria-hidden="true">${f(n.icon)}</span>` : "";
|
|
769
749
|
return `
|
|
770
750
|
<button
|
|
771
751
|
type="button"
|
|
@@ -780,7 +760,7 @@ class S extends m {
|
|
|
780
760
|
tabindex="${n.index === i && !n.disabled ? "0" : "-1"}"
|
|
781
761
|
${n.disabled ? "disabled" : ""}
|
|
782
762
|
>
|
|
783
|
-
${
|
|
763
|
+
${l}
|
|
784
764
|
<span class="tab-label">${f(n.label)}</span>
|
|
785
765
|
</button>
|
|
786
766
|
`;
|
package/dist/tags-input.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const E=require("./ElementBase-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const E=require("./ElementBase-EV6mVBUV.js"),A=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-tags-input-padding: 10px 12px;
|
|
4
4
|
--ui-tags-input-border-color: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 78%, transparent);
|
|
@@ -181,8 +181,8 @@
|
|
|
181
181
|
:host([readonly]) .chip-remove {
|
|
182
182
|
pointer-events: none;
|
|
183
183
|
}
|
|
184
|
-
`;function m(
|
|
185
|
-
`))?JSON.stringify(
|
|
184
|
+
`;function m(r,t){return r.length===t.length&&r.every((i,e)=>i===t[e])}function d(r){if(!r)return[];const t=r.trim();if(!t)return[];if(t.startsWith("["))try{const i=JSON.parse(t);if(Array.isArray(i))return i.map(e=>String(e).trim()).filter(Boolean)}catch{}return t.split(",").map(i=>i.trim()).filter(Boolean)}function S(r){return r.length?r.some(t=>t.includes(",")||t.includes(`
|
|
185
|
+
`))?JSON.stringify(r):r.join(", "):""}function c(r){return r.replace(/\s+/g," ").trim()}class f extends E.ElementBase{constructor(){super(),this._tags=[],this._draft="",this._suppressValueAttr=!1,this._formUnregister=null,this._rootEl=null,this._shellEl=null,this._chipsEl=null,this._inputEl=null,this._labelEl=null,this._descriptionEl=null,this._errorEl=null,this._assistEl=null,this._counterEl=null,this._focused=!1,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusIn=this._onFocusIn.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onPaste=this._onPaste.bind(this),this._onShellClick=this._onShellClick.bind(this),this._onChipClick=this._onChipClick.bind(this)}static get observedAttributes(){return["value","label","description","placeholder","data-error","required","disabled","readonly","name","max-tags","counter"]}get value(){return[...this._tags]}set value(t){const i=Array.isArray(t)?t.map(e=>c(String(e))).filter(Boolean):d(String(t??""));this._applyTags(i,"api")}addTag(t){return this._addTag(t,"api")}removeTag(t){if(typeof t=="number"){if(t<0||t>=this._tags.length)return;this._removeTagAt(t,"api");return}const i=this._tags.indexOf(t);i>=0&&this._removeTagAt(i,"api")}clearTags(){this._applyTags([],"api")}focusInput(){this._inputEl?.focus()}connectedCallback(){super.connectedCallback(),this._registerWithForm()}disconnectedCallback(){this._formUnregister&&(this._formUnregister(),this._formUnregister=null),super.disconnectedCallback()}attributeChangedCallback(t,i,e){if(i!==e){if(t==="name"&&this.isConnected&&this._registerWithForm(),t==="value"&&!this._suppressValueAttr){const s=d(e);m(s,this._tags)||(this._tags=s)}this._rootEl&&this._syncUi()}}shouldRenderOnAttributeChange(){return!1}render(){this.setContent(`
|
|
186
186
|
<style>${A}</style>
|
|
187
187
|
<div class="root">
|
|
188
188
|
<div class="meta" hidden>
|
|
@@ -199,4 +199,4 @@
|
|
|
199
199
|
<div class="counter"></div>
|
|
200
200
|
</div>
|
|
201
201
|
</div>
|
|
202
|
-
`),this._rootEl=this.root.querySelector(".root"),this._shellEl=this.root.querySelector(".shell"),this._chipsEl=this.root.querySelector(".chips"),this._inputEl=this.root.querySelector(".input"),this._labelEl=this.root.querySelector(".label"),this._descriptionEl=this.root.querySelector(".description"),this._errorEl=this.root.querySelector(".error"),this._assistEl=this.root.querySelector(".assist"),this._counterEl=this.root.querySelector(".counter"),
|
|
202
|
+
`),this._rootEl=this.root.querySelector(".root"),this._shellEl=this.root.querySelector(".shell"),this._chipsEl=this.root.querySelector(".chips"),this._inputEl=this.root.querySelector(".input"),this._labelEl=this.root.querySelector(".label"),this._descriptionEl=this.root.querySelector(".description"),this._errorEl=this.root.querySelector(".error"),this._assistEl=this.root.querySelector(".assist"),this._counterEl=this.root.querySelector(".counter"),this._inputEl?.addEventListener("input",this._onInput),this._inputEl?.addEventListener("keydown",this._onKeyDown),this._inputEl?.addEventListener("focus",this._onFocusIn),this._inputEl?.addEventListener("blur",this._onFocusOut),this._inputEl?.addEventListener("paste",this._onPaste),this._shellEl?.addEventListener("click",this._onShellClick),this.root.addEventListener("click",this._onChipClick),this._tags=d(this.getAttribute("value")),this._syncUi()}_readOnly(){return this.hasAttribute("readonly")}_disabled(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}_allowDuplicates(){return this.hasAttribute("allow-duplicates")}_maxTags(){const t=this.getAttribute("max-tags");if(!t)return null;const i=Number(t);return Number.isFinite(i)&&i>0?Math.floor(i):null}_emit(t,i){this.dispatchEvent(new CustomEvent(t,{detail:i,bubbles:!0,composed:!0}))}_setValueAttr(t){const i=S(t);this._suppressValueAttr=!0;try{i?this.getAttribute("value")!==i&&this.setAttribute("value",i):this.removeAttribute("value")}finally{this._suppressValueAttr=!1}}_applyTags(t,i){const e=t.map(l=>c(l)).filter(Boolean),s=this._allowDuplicates()?e:e.filter((l,o)=>e.indexOf(l)===o),n=this._maxTags()!=null?s.slice(0,this._maxTags()):s;if(m(n,this._tags))return this._syncUi(),!1;const a=[...this._tags];return this._tags=[...n],this._setValueAttr(this._tags),this._syncUi(),this._emit("change",{value:[...this._tags],previousValue:a,source:i}),!0}_addTag(t,i){if(this._disabled()||this._readOnly())return!1;const e=c(t);if(!e)return!1;if(!this._allowDuplicates()&&this._tags.includes(e))return this._syncUi("Duplicate tag"),!1;const s=this._maxTags();if(s!=null&&this._tags.length>=s)return this._syncUi(`Maximum ${s} tags`),!1;const n=this._applyTags([...this._tags,e],i);return n&&this._emit("tag-add",{tag:e,value:[...this._tags],source:i}),n}_removeTagAt(t,i){if(this._disabled()||this._readOnly())return;const e=this._tags[t];if(!e)return;const s=this._tags.filter((a,l)=>l!==t);this._applyTags(s,i)&&this._emit("tag-remove",{tag:e,index:t,value:[...this._tags],source:i})}_commitDraft(t){const i=this._draft;this._draft="",this._inputEl&&(this._inputEl.value=""),this._addTag(i,t),this._syncUi()}_syncUi(t){if(!this._shellEl||!this._chipsEl||!this._inputEl||!this._labelEl||!this._descriptionEl||!this._errorEl||!this._assistEl||!this._counterEl)return;const i=(this.getAttribute("label")||"").trim(),e=(this.getAttribute("description")||"").trim(),s=(this.getAttribute("data-error")||"").trim(),n=this.hasAttribute("required"),a=this._disabled(),l=this._readOnly(),o=this._maxTags(),b=this.hasAttribute("counter")||o!=null,v=!!s||!!t||n&&this._tags.length===0&&this.hasAttribute("invalid");this._labelEl.hidden=!i,this._labelEl.querySelector(".label-text").textContent=i,this._labelEl.querySelector(".required").hidden=!n,this._descriptionEl.hidden=!e,this._descriptionEl.textContent=e,this.root.querySelector(".meta").hidden=!i&&!e,this._shellEl.setAttribute("data-focused",this._focused?"true":"false"),this._shellEl.setAttribute("data-invalid",v?"true":"false"),this._inputEl.disabled=a,this._inputEl.readOnly=l,this._inputEl.placeholder=this._tags.length===0?this.getAttribute("placeholder")||"Add tags":"",this._inputEl.value=this._draft;const y=a||o!=null&&this._tags.length>=o;this._inputEl.setAttribute("aria-disabled",y?"true":"false"),this._chipsEl.replaceChildren(...this._tags.map((_,x)=>{const h=document.createElement("span");h.className="chip",h.setAttribute("part","chip");const p=document.createElement("span");p.className="chip-label",p.textContent=_;const u=document.createElement("button");return u.type="button",u.className="chip-remove",u.setAttribute("data-index",String(x)),u.setAttribute("aria-label",`Remove ${_}`),u.textContent="×",u.disabled=a||l,h.append(p,u),h}));const g=t||s;this._errorEl.hidden=!g,this._errorEl.textContent=g,this._assistEl.hidden=!b,this._counterEl.textContent=o!=null?`${this._tags.length}/${o}`:String(this._tags.length)}_registerWithForm(){this._formUnregister&&(this._formUnregister(),this._formUnregister=null);try{const s=this.getRootNode().host?.closest?.("ui-form")||null||this.closest("ui-form"),n=this.getAttribute("name");s&&typeof s.registerField=="function"&&n&&(this._formUnregister=s.registerField(n,{name:n,getValue:()=>[...this._tags],setValue:a=>{Array.isArray(a)?this._applyTags(a.map(l=>String(l)),"form"):this._applyTags(d(String(a??"")),"form")},validate:async()=>this.hasAttribute("required")&&this._tags.length===0?{valid:!1,message:"At least one tag is required"}:{valid:!0},setError:a=>{a?this.setAttribute("data-error",a):this.removeAttribute("data-error"),this._syncUi()}}))}catch{}}_onInput(t){const i=t.target;this._draft=i?.value||"",this._emit("input",{draft:this._draft,value:[...this._tags]}),this._syncUi()}_onKeyDown(t){if(t.key==="Enter"||t.key===","){t.preventDefault(),this._commitDraft("keyboard");return}t.key==="Backspace"&&!this._draft&&this._removeTagAt(this._tags.length-1,"keyboard")}_onPaste(t){const i=t.clipboardData?.getData("text")||"";if(!/[,\n]/.test(i))return;t.preventDefault();const e=i.split(/[,\n]+/).map(c).filter(Boolean);e.length&&(this._draft="",this._inputEl&&(this._inputEl.value=""),this._applyTags([...this._tags,...e],"paste"))}_onFocusIn(){this._focused=!0,this._syncUi()}_onFocusOut(){this._focused=!1,this.hasAttribute("add-on-blur")&&this._draft?this._commitDraft("blur"):this._syncUi()}_onShellClick(t){t.target?.closest(".chip-remove")||this._inputEl?.focus()}_onChipClick(t){const e=t.target?.closest(".chip-remove");if(!e)return;const s=Number(e.getAttribute("data-index"));Number.isFinite(s)&&this._removeTagAt(s,"remove-button")}}typeof customElements<"u"&&!customElements.get("ui-tags-input")&&customElements.define("ui-tags-input",f);exports.UITagsInput=f;
|
package/dist/tags-input.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as x } from "./ElementBase-
|
|
1
|
+
import { E as x } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
2
|
const E = `
|
|
3
3
|
:host {
|
|
4
4
|
--ui-tags-input-padding: 10px 12px;
|
|
@@ -183,15 +183,13 @@ const E = `
|
|
|
183
183
|
pointer-events: none;
|
|
184
184
|
}
|
|
185
185
|
`;
|
|
186
|
-
function m(
|
|
187
|
-
return
|
|
186
|
+
function m(r, t) {
|
|
187
|
+
return r.length === t.length && r.every((i, e) => i === t[e]);
|
|
188
188
|
}
|
|
189
|
-
function d(
|
|
190
|
-
if (!
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (!t)
|
|
194
|
-
return [];
|
|
189
|
+
function d(r) {
|
|
190
|
+
if (!r) return [];
|
|
191
|
+
const t = r.trim();
|
|
192
|
+
if (!t) return [];
|
|
195
193
|
if (t.startsWith("["))
|
|
196
194
|
try {
|
|
197
195
|
const i = JSON.parse(t);
|
|
@@ -201,12 +199,12 @@ function d(a) {
|
|
|
201
199
|
}
|
|
202
200
|
return t.split(",").map((i) => i.trim()).filter(Boolean);
|
|
203
201
|
}
|
|
204
|
-
function A(
|
|
205
|
-
return
|
|
206
|
-
`)) ? JSON.stringify(
|
|
202
|
+
function A(r) {
|
|
203
|
+
return r.length ? r.some((t) => t.includes(",") || t.includes(`
|
|
204
|
+
`)) ? JSON.stringify(r) : r.join(", ") : "";
|
|
207
205
|
}
|
|
208
|
-
function c(
|
|
209
|
-
return
|
|
206
|
+
function c(r) {
|
|
207
|
+
return r.replace(/\s+/g, " ").trim();
|
|
210
208
|
}
|
|
211
209
|
class S extends x {
|
|
212
210
|
constructor() {
|
|
@@ -239,8 +237,7 @@ class S extends x {
|
|
|
239
237
|
}
|
|
240
238
|
removeTag(t) {
|
|
241
239
|
if (typeof t == "number") {
|
|
242
|
-
if (t < 0 || t >= this._tags.length)
|
|
243
|
-
return;
|
|
240
|
+
if (t < 0 || t >= this._tags.length) return;
|
|
244
241
|
this._removeTagAt(t, "api");
|
|
245
242
|
return;
|
|
246
243
|
}
|
|
@@ -251,8 +248,7 @@ class S extends x {
|
|
|
251
248
|
this._applyTags([], "api");
|
|
252
249
|
}
|
|
253
250
|
focusInput() {
|
|
254
|
-
|
|
255
|
-
(t = this._inputEl) == null || t.focus();
|
|
251
|
+
this._inputEl?.focus();
|
|
256
252
|
}
|
|
257
253
|
connectedCallback() {
|
|
258
254
|
super.connectedCallback(), this._registerWithForm();
|
|
@@ -273,7 +269,6 @@ class S extends x {
|
|
|
273
269
|
return !1;
|
|
274
270
|
}
|
|
275
271
|
render() {
|
|
276
|
-
var t, i, e, s, r, l;
|
|
277
272
|
this.setContent(`
|
|
278
273
|
<style>${E}</style>
|
|
279
274
|
<div class="root">
|
|
@@ -291,7 +286,7 @@ class S extends x {
|
|
|
291
286
|
<div class="counter"></div>
|
|
292
287
|
</div>
|
|
293
288
|
</div>
|
|
294
|
-
`), this._rootEl = this.root.querySelector(".root"), this._shellEl = this.root.querySelector(".shell"), this._chipsEl = this.root.querySelector(".chips"), this._inputEl = this.root.querySelector(".input"), this._labelEl = this.root.querySelector(".label"), this._descriptionEl = this.root.querySelector(".description"), this._errorEl = this.root.querySelector(".error"), this._assistEl = this.root.querySelector(".assist"), this._counterEl = this.root.querySelector(".counter"),
|
|
289
|
+
`), this._rootEl = this.root.querySelector(".root"), this._shellEl = this.root.querySelector(".shell"), this._chipsEl = this.root.querySelector(".chips"), this._inputEl = this.root.querySelector(".input"), this._labelEl = this.root.querySelector(".label"), this._descriptionEl = this.root.querySelector(".description"), this._errorEl = this.root.querySelector(".error"), this._assistEl = this.root.querySelector(".assist"), this._counterEl = this.root.querySelector(".counter"), this._inputEl?.addEventListener("input", this._onInput), this._inputEl?.addEventListener("keydown", this._onKeyDown), this._inputEl?.addEventListener("focus", this._onFocusIn), this._inputEl?.addEventListener("blur", this._onFocusOut), this._inputEl?.addEventListener("paste", this._onPaste), this._shellEl?.addEventListener("click", this._onShellClick), this.root.addEventListener("click", this._onChipClick), this._tags = d(this.getAttribute("value")), this._syncUi();
|
|
295
290
|
}
|
|
296
291
|
_readOnly() {
|
|
297
292
|
return this.hasAttribute("readonly");
|
|
@@ -304,8 +299,7 @@ class S extends x {
|
|
|
304
299
|
}
|
|
305
300
|
_maxTags() {
|
|
306
301
|
const t = this.getAttribute("max-tags");
|
|
307
|
-
if (!t)
|
|
308
|
-
return null;
|
|
302
|
+
if (!t) return null;
|
|
309
303
|
const i = Number(t);
|
|
310
304
|
return Number.isFinite(i) && i > 0 ? Math.floor(i) : null;
|
|
311
305
|
}
|
|
@@ -322,33 +316,29 @@ class S extends x {
|
|
|
322
316
|
}
|
|
323
317
|
}
|
|
324
318
|
_applyTags(t, i) {
|
|
325
|
-
const e = t.map((
|
|
326
|
-
if (m(
|
|
319
|
+
const e = t.map((l) => c(l)).filter(Boolean), s = this._allowDuplicates() ? e : e.filter((l, o) => e.indexOf(l) === o), n = this._maxTags() != null ? s.slice(0, this._maxTags()) : s;
|
|
320
|
+
if (m(n, this._tags))
|
|
327
321
|
return this._syncUi(), !1;
|
|
328
|
-
const
|
|
329
|
-
return this._tags = [...
|
|
322
|
+
const a = [...this._tags];
|
|
323
|
+
return this._tags = [...n], this._setValueAttr(this._tags), this._syncUi(), this._emit("change", { value: [...this._tags], previousValue: a, source: i }), !0;
|
|
330
324
|
}
|
|
331
325
|
_addTag(t, i) {
|
|
332
|
-
if (this._disabled() || this._readOnly())
|
|
333
|
-
return !1;
|
|
326
|
+
if (this._disabled() || this._readOnly()) return !1;
|
|
334
327
|
const e = c(t);
|
|
335
|
-
if (!e)
|
|
336
|
-
return !1;
|
|
328
|
+
if (!e) return !1;
|
|
337
329
|
if (!this._allowDuplicates() && this._tags.includes(e))
|
|
338
330
|
return this._syncUi("Duplicate tag"), !1;
|
|
339
331
|
const s = this._maxTags();
|
|
340
332
|
if (s != null && this._tags.length >= s)
|
|
341
333
|
return this._syncUi(`Maximum ${s} tags`), !1;
|
|
342
|
-
const
|
|
343
|
-
return
|
|
334
|
+
const n = this._applyTags([...this._tags, e], i);
|
|
335
|
+
return n && this._emit("tag-add", { tag: e, value: [...this._tags], source: i }), n;
|
|
344
336
|
}
|
|
345
337
|
_removeTagAt(t, i) {
|
|
346
|
-
if (this._disabled() || this._readOnly())
|
|
347
|
-
return;
|
|
338
|
+
if (this._disabled() || this._readOnly()) return;
|
|
348
339
|
const e = this._tags[t];
|
|
349
|
-
if (!e)
|
|
350
|
-
|
|
351
|
-
const s = this._tags.filter((l, n) => n !== t);
|
|
340
|
+
if (!e) return;
|
|
341
|
+
const s = this._tags.filter((a, l) => l !== t);
|
|
352
342
|
this._applyTags(s, i) && this._emit("tag-remove", { tag: e, index: t, value: [...this._tags], source: i });
|
|
353
343
|
}
|
|
354
344
|
_commitDraft(t) {
|
|
@@ -356,36 +346,34 @@ class S extends x {
|
|
|
356
346
|
this._draft = "", this._inputEl && (this._inputEl.value = ""), this._addTag(i, t), this._syncUi();
|
|
357
347
|
}
|
|
358
348
|
_syncUi(t) {
|
|
359
|
-
if (!this._shellEl || !this._chipsEl || !this._inputEl || !this._labelEl || !this._descriptionEl || !this._errorEl || !this._assistEl || !this._counterEl)
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
const v = l || o != null && this._tags.length >= o;
|
|
349
|
+
if (!this._shellEl || !this._chipsEl || !this._inputEl || !this._labelEl || !this._descriptionEl || !this._errorEl || !this._assistEl || !this._counterEl) return;
|
|
350
|
+
const i = (this.getAttribute("label") || "").trim(), e = (this.getAttribute("description") || "").trim(), s = (this.getAttribute("data-error") || "").trim(), n = this.hasAttribute("required"), a = this._disabled(), l = this._readOnly(), o = this._maxTags(), f = this.hasAttribute("counter") || o != null, b = !!s || !!t || n && this._tags.length === 0 && this.hasAttribute("invalid");
|
|
351
|
+
this._labelEl.hidden = !i, this._labelEl.querySelector(".label-text").textContent = i, this._labelEl.querySelector(".required").hidden = !n, this._descriptionEl.hidden = !e, this._descriptionEl.textContent = e, this.root.querySelector(".meta").hidden = !i && !e, this._shellEl.setAttribute("data-focused", this._focused ? "true" : "false"), this._shellEl.setAttribute("data-invalid", b ? "true" : "false"), this._inputEl.disabled = a, this._inputEl.readOnly = l, this._inputEl.placeholder = this._tags.length === 0 ? this.getAttribute("placeholder") || "Add tags" : "", this._inputEl.value = this._draft;
|
|
352
|
+
const v = a || o != null && this._tags.length >= o;
|
|
364
353
|
this._inputEl.setAttribute("aria-disabled", v ? "true" : "false"), this._chipsEl.replaceChildren(...this._tags.map((_, y) => {
|
|
365
354
|
const h = document.createElement("span");
|
|
366
355
|
h.className = "chip", h.setAttribute("part", "chip");
|
|
367
356
|
const p = document.createElement("span");
|
|
368
357
|
p.className = "chip-label", p.textContent = _;
|
|
369
358
|
const u = document.createElement("button");
|
|
370
|
-
return u.type = "button", u.className = "chip-remove", u.setAttribute("data-index", String(y)), u.setAttribute("aria-label", `Remove ${_}`), u.textContent = "×", u.disabled =
|
|
359
|
+
return u.type = "button", u.className = "chip-remove", u.setAttribute("data-index", String(y)), u.setAttribute("aria-label", `Remove ${_}`), u.textContent = "×", u.disabled = a || l, h.append(p, u), h;
|
|
371
360
|
}));
|
|
372
361
|
const g = t || s;
|
|
373
362
|
this._errorEl.hidden = !g, this._errorEl.textContent = g, this._assistEl.hidden = !f, this._counterEl.textContent = o != null ? `${this._tags.length}/${o}` : String(this._tags.length);
|
|
374
363
|
}
|
|
375
364
|
_registerWithForm() {
|
|
376
|
-
var t;
|
|
377
365
|
this._formUnregister && (this._formUnregister(), this._formUnregister = null);
|
|
378
366
|
try {
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
name:
|
|
367
|
+
const s = this.getRootNode().host?.closest?.("ui-form") || null || this.closest("ui-form"), n = this.getAttribute("name");
|
|
368
|
+
s && typeof s.registerField == "function" && n && (this._formUnregister = s.registerField(n, {
|
|
369
|
+
name: n,
|
|
382
370
|
getValue: () => [...this._tags],
|
|
383
|
-
setValue: (
|
|
384
|
-
Array.isArray(
|
|
371
|
+
setValue: (a) => {
|
|
372
|
+
Array.isArray(a) ? this._applyTags(a.map((l) => String(l)), "form") : this._applyTags(d(String(a ?? "")), "form");
|
|
385
373
|
},
|
|
386
374
|
validate: async () => this.hasAttribute("required") && this._tags.length === 0 ? { valid: !1, message: "At least one tag is required" } : { valid: !0 },
|
|
387
|
-
setError: (
|
|
388
|
-
|
|
375
|
+
setError: (a) => {
|
|
376
|
+
a ? this.setAttribute("data-error", a) : this.removeAttribute("data-error"), this._syncUi();
|
|
389
377
|
}
|
|
390
378
|
}));
|
|
391
379
|
} catch {
|
|
@@ -393,7 +381,7 @@ class S extends x {
|
|
|
393
381
|
}
|
|
394
382
|
_onInput(t) {
|
|
395
383
|
const i = t.target;
|
|
396
|
-
this._draft =
|
|
384
|
+
this._draft = i?.value || "", this._emit("input", { draft: this._draft, value: [...this._tags] }), this._syncUi();
|
|
397
385
|
}
|
|
398
386
|
_onKeyDown(t) {
|
|
399
387
|
if (t.key === "Enter" || t.key === ",") {
|
|
@@ -403,10 +391,8 @@ class S extends x {
|
|
|
403
391
|
t.key === "Backspace" && !this._draft && this._removeTagAt(this._tags.length - 1, "keyboard");
|
|
404
392
|
}
|
|
405
393
|
_onPaste(t) {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
if (!/[,\n]/.test(i))
|
|
409
|
-
return;
|
|
394
|
+
const i = t.clipboardData?.getData("text") || "";
|
|
395
|
+
if (!/[,\n]/.test(i)) return;
|
|
410
396
|
t.preventDefault();
|
|
411
397
|
const e = i.split(/[,\n]+/).map(c).filter(Boolean);
|
|
412
398
|
e.length && (this._draft = "", this._inputEl && (this._inputEl.value = ""), this._applyTags([...this._tags, ...e], "paste"));
|
|
@@ -418,14 +404,11 @@ class S extends x {
|
|
|
418
404
|
this._focused = !1, this.hasAttribute("add-on-blur") && this._draft ? this._commitDraft("blur") : this._syncUi();
|
|
419
405
|
}
|
|
420
406
|
_onShellClick(t) {
|
|
421
|
-
|
|
422
|
-
const i = t.target;
|
|
423
|
-
i != null && i.closest(".chip-remove") || (e = this._inputEl) == null || e.focus();
|
|
407
|
+
t.target?.closest(".chip-remove") || this._inputEl?.focus();
|
|
424
408
|
}
|
|
425
409
|
_onChipClick(t) {
|
|
426
|
-
const
|
|
427
|
-
if (!e)
|
|
428
|
-
return;
|
|
410
|
+
const e = t.target?.closest(".chip-remove");
|
|
411
|
+
if (!e) return;
|
|
429
412
|
const s = Number(e.getAttribute("data-index"));
|
|
430
413
|
Number.isFinite(s) && this._removeTagAt(s, "remove-button");
|
|
431
414
|
}
|
package/dist/textarea.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("./ElementBase-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("./ElementBase-EV6mVBUV.js"),_=`
|
|
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>
|
|
@@ -308,22 +308,22 @@
|
|
|
308
308
|
color: CanvasText;
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
|
-
`;function d(
|
|
311
|
+
`;function d(l){return l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function x(l,t){const e=Number(l);return Number.isFinite(e)?e:t}class p extends v.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=this.getAttribute("maxlength"),i=this.getAttribute("minlength"),r=x(this.getAttribute("rows"),4),a=this.hasAttribute("disabled"),u=this.hasAttribute("readonly"),s=this.hasAttribute("required"),c=this.getAttribute("name")||"",h=this.getAttribute("resize")||"vertical",g=this.getAttribute("validation"),b=this.getAttribute("color"),o=this.getAttribute("radius");this._textarea.placeholder=t,this._textarea.disabled=a,this._textarea.readOnly=u,this._textarea.required=s,this._textarea.rows=Math.max(1,r),this._textarea.name=c,this._textarea.style.resize=h,e&&Number.isFinite(Number(e))?this._textarea.maxLength=Number(e):this._textarea.removeAttribute("maxlength"),i&&Number.isFinite(Number(i))?this._textarea.minLength=Number(i):this._textarea.removeAttribute("minlength"),g==="error"?this._textarea.setAttribute("aria-invalid","true"):this._textarea.removeAttribute("aria-invalid"),b?this.style.setProperty("--ui-textarea-accent",b):this.style.removeProperty("--ui-textarea-accent"),o&&o!=="none"&&o!=="large"&&o!=="full"?this.style.setProperty("--ui-textarea-radius",o):this.style.removeProperty("--ui-textarea-radius");const n=[],m=!!(this.getAttribute("description")||this.querySelector('[slot="description"]')),f=!!(this.getAttribute("data-error")||this.querySelector('[slot="error"]'));m&&n.push(`${this._uid}-description`),f&&n.push(`${this._uid}-error`),(this.hasAttribute("show-count")||this.hasAttribute("maxlength"))&&n.push(`${this._uid}-count`),!!(this.getAttribute("label")||this.querySelector('[slot="label"]'))?this._textarea.setAttribute("aria-labelledby",`${this._uid}-label`):this._textarea.removeAttribute("aria-labelledby"),n.length?this._textarea.setAttribute("aria-describedby",n.join(" ")):this._textarea.removeAttribute("aria-describedby")}_syncDynamicUi(){const t=this._textarea?.value||this.getAttribute("value")||"",e=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?(this._countEl.removeAttribute("hidden"),e&&Number.isFinite(Number(e))?this._countEl.textContent=`${t.length} / ${Number(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=x(this.getAttribute("max-rows"),0);if(e>0){const i=getComputedStyle(this._textarea),r=parseFloat(i.lineHeight||"20")||20,a=parseFloat(i.borderTopWidth||"0")||0,u=parseFloat(i.borderBottomWidth||"0")||0,s=parseFloat(i.paddingTop||"0")||0,c=parseFloat(i.paddingBottom||"0")||0,h=r*e+a+u+s+c;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=x(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")||"",r=this.getAttribute("data-error")||"",a=!!(e||i||this.querySelector('[slot="label"]')||this.querySelector('[slot="description"]')),s=this.hasAttribute("clearable")&&!!t&&!this.hasAttribute("disabled")&&!this.hasAttribute("readonly");this.setContent(`
|
|
312
312
|
<style>${y}</style>
|
|
313
313
|
<div class="shell" part="shell">
|
|
314
|
-
<div class="meta" part="meta" ${
|
|
314
|
+
<div class="meta" part="meta" ${a?"":"hidden"}>
|
|
315
315
|
<label id="${this._uid}-label" class="label" part="label"><slot name="label">${d(e)}</slot></label>
|
|
316
316
|
<div id="${this._uid}-description" class="description" part="description"><slot name="description">${d(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" ${s?"":"hidden"}>${_}</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">${d(
|
|
325
|
+
<div id="${this._uid}-error" class="error" part="error"><slot name="error">${d(r)}</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),
|
|
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",p);exports.UITextarea=p;
|