@editora/ui-core 0.1.19 → 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/{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 +30 -29
- package/dist/color-picker.cjs.js +10 -10
- package/dist/color-picker.esm.js +190 -253
- 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-collection.d.ts.map +1 -1
- package/dist/components/ui-multi-select.d.ts.map +1 -1
- package/dist/components/ui-orbiter.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-skeleton.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-split-button.d.ts +1 -0
- package/dist/components/ui-split-button.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/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 +7 -7
- package/dist/date-time-picker.esm.js +115 -147
- 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 +5 -5
- package/dist/multi-select.esm.js +125 -137
- 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 +3 -3
- package/dist/portal.esm.js +20 -28
- 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 +22 -28
- package/dist/presence.cjs.js +1 -1
- package/dist/presence.esm.js +7 -13
- 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/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/selector-BvAh35ve.js +1 -0
- package/dist/selector-WI8pD7YO.mjs +18 -0
- 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 +79 -65
- package/dist/sortable.esm.js +714 -734
- 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 +8 -8
- package/dist/tabs.esm.js +89 -109
- package/dist/tags-input.cjs.js +4 -4
- package/dist/tags-input.esm.js +45 -62
- package/dist/textarea.cjs.js +10 -10
- package/dist/textarea.esm.js +49 -52
- 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 +31 -31
- package/dist/transfer-list.esm.js +114 -127
- 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/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,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
|
-
<div class="meta" part="meta" ${
|
|
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">${
|
|
314
|
+
<div class="meta" part="meta" ${a?"":"hidden"}>
|
|
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),
|
|
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;
|
package/dist/textarea.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
const
|
|
1
|
+
import { E as v } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
|
+
const _ = `
|
|
3
3
|
<svg viewBox="0 0 20 20" aria-hidden="true" focusable="false">
|
|
4
4
|
<path d="m6 6 8 8M14 6l-8 8" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>
|
|
5
5
|
</svg>
|
|
6
|
-
`,
|
|
6
|
+
`, y = `
|
|
7
7
|
:host {
|
|
8
8
|
--ui-textarea-bg: var(--ui-color-surface, #ffffff);
|
|
9
9
|
--ui-textarea-text: var(--ui-color-text, #0f172a);
|
|
@@ -310,14 +310,20 @@ const v = `
|
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
`;
|
|
313
|
-
function
|
|
314
|
-
return
|
|
313
|
+
function x(r) {
|
|
314
|
+
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
315
315
|
}
|
|
316
|
-
function
|
|
317
|
-
const e = Number(
|
|
316
|
+
function b(r, t) {
|
|
317
|
+
const e = Number(r);
|
|
318
318
|
return Number.isFinite(e) ? e : t;
|
|
319
319
|
}
|
|
320
|
-
|
|
320
|
+
const A = 2147483647;
|
|
321
|
+
function c(r) {
|
|
322
|
+
if (!r) return null;
|
|
323
|
+
const t = Number(r);
|
|
324
|
+
return !Number.isFinite(t) || t < 0 || t > A ? null : Math.trunc(t);
|
|
325
|
+
}
|
|
326
|
+
class z extends v {
|
|
321
327
|
constructor() {
|
|
322
328
|
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);
|
|
323
329
|
}
|
|
@@ -359,11 +365,10 @@ class y extends f {
|
|
|
359
365
|
this._detachListeners(), this._debounceTimer && (clearTimeout(this._debounceTimer), this._debounceTimer = null), this._formUnregister && (this._formUnregister(), this._formUnregister = null), super.disconnectedCallback();
|
|
360
366
|
}
|
|
361
367
|
attributeChangedCallback(t, e, i) {
|
|
362
|
-
if (e === i)
|
|
363
|
-
return;
|
|
368
|
+
if (e === i) return;
|
|
364
369
|
if (t === "name" && this._tryRegisterWithForm(), t === "value" && this._textarea) {
|
|
365
|
-
const
|
|
366
|
-
this._textarea.value !==
|
|
370
|
+
const a = i || "";
|
|
371
|
+
this._textarea.value !== a && (this._textarea.value = a), this._syncDynamicUi(), this._applyAutosize();
|
|
367
372
|
return;
|
|
368
373
|
}
|
|
369
374
|
if ((/* @__PURE__ */ new Set([
|
|
@@ -391,8 +396,7 @@ class y extends f {
|
|
|
391
396
|
"autofocus"
|
|
392
397
|
])).has(t)) {
|
|
393
398
|
this._syncControlAttrs(), this._syncDynamicUi(), this._applyAutosize(), t === "autofocus" && this.hasAttribute("autofocus") && queueMicrotask(() => {
|
|
394
|
-
|
|
395
|
-
(r = this._textarea) == null || r.focus();
|
|
399
|
+
this._textarea?.focus();
|
|
396
400
|
});
|
|
397
401
|
return;
|
|
398
402
|
}
|
|
@@ -405,20 +409,18 @@ class y extends f {
|
|
|
405
409
|
this.setAttribute("value", t || "");
|
|
406
410
|
}
|
|
407
411
|
_tryRegisterWithForm() {
|
|
408
|
-
var t;
|
|
409
412
|
try {
|
|
410
|
-
const
|
|
411
|
-
if (!
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
name: i,
|
|
413
|
+
const t = this.closest?.("ui-form"), e = this.getAttribute("name");
|
|
414
|
+
if (!t || typeof t.registerField != "function" || !e) return;
|
|
415
|
+
this._formUnregister = t.registerField(e, {
|
|
416
|
+
name: e,
|
|
415
417
|
getValue: () => this.value,
|
|
416
|
-
setValue: (
|
|
417
|
-
this.value =
|
|
418
|
+
setValue: (i) => {
|
|
419
|
+
this.value = i;
|
|
418
420
|
},
|
|
419
421
|
validate: async () => this._textarea ? { valid: this._textarea.checkValidity(), message: this._textarea.validationMessage || void 0 } : { valid: !0 },
|
|
420
|
-
setError: (
|
|
421
|
-
|
|
422
|
+
setError: (i) => {
|
|
423
|
+
i ? (this.setAttribute("validation", "error"), this.setAttribute("data-error", i)) : (this.removeAttribute("validation"), this.removeAttribute("data-error"));
|
|
422
424
|
}
|
|
423
425
|
});
|
|
424
426
|
} catch {
|
|
@@ -428,30 +430,27 @@ class y extends f {
|
|
|
428
430
|
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;
|
|
429
431
|
}
|
|
430
432
|
_syncControlAttrs() {
|
|
431
|
-
if (!this._textarea)
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
g && u.push(`${this._uid}-description`), m && u.push(`${this._uid}-error`), (this.hasAttribute("show-count") || this.hasAttribute("maxlength")) && u.push(`${this._uid}-count`), !!(this.getAttribute("label") || this.querySelector('[slot="label"]')) ? this._textarea.setAttribute("aria-labelledby", `${this._uid}-label`) : this._textarea.removeAttribute("aria-labelledby"), u.length ? this._textarea.setAttribute("aria-describedby", u.join(" ")) : this._textarea.removeAttribute("aria-describedby");
|
|
433
|
+
if (!this._textarea) return;
|
|
434
|
+
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", g = this.getAttribute("validation"), p = this.getAttribute("color"), n = this.getAttribute("radius");
|
|
435
|
+
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"), g === "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");
|
|
436
|
+
const l = [], m = !!(this.getAttribute("description") || this.querySelector('[slot="description"]')), f = !!(this.getAttribute("data-error") || this.querySelector('[slot="error"]'));
|
|
437
|
+
m && l.push(`${this._uid}-description`), f && 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");
|
|
437
438
|
}
|
|
438
439
|
_syncDynamicUi() {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
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", ""));
|
|
440
|
+
const t = this._textarea?.value || this.getAttribute("value") || "", e = c(this.getAttribute("maxlength")), i = this.hasAttribute("clearable");
|
|
441
|
+
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", ""));
|
|
442
442
|
}
|
|
443
443
|
_applyAutosize() {
|
|
444
|
-
if (!this._textarea)
|
|
445
|
-
return;
|
|
444
|
+
if (!this._textarea) return;
|
|
446
445
|
if (!this.hasAttribute("autosize")) {
|
|
447
446
|
this._textarea.style.height = "", this._textarea.style.overflowY = "";
|
|
448
447
|
return;
|
|
449
448
|
}
|
|
450
449
|
this._textarea.style.height = "auto";
|
|
451
|
-
const t = this._textarea.scrollHeight, e =
|
|
450
|
+
const t = this._textarea.scrollHeight, e = b(this.getAttribute("max-rows"), 0);
|
|
452
451
|
if (e > 0) {
|
|
453
|
-
const i = getComputedStyle(this._textarea),
|
|
454
|
-
this._textarea.style.height = `${Math.min(t,
|
|
452
|
+
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;
|
|
453
|
+
this._textarea.style.height = `${Math.min(t, h)}px`, this._textarea.style.overflowY = t > h ? "auto" : "hidden";
|
|
455
454
|
return;
|
|
456
455
|
}
|
|
457
456
|
this._textarea.style.height = `${t}px`, this._textarea.style.overflowY = "hidden";
|
|
@@ -472,7 +471,7 @@ class y extends f {
|
|
|
472
471
|
_onInput(t) {
|
|
473
472
|
const e = t.target.value;
|
|
474
473
|
this.getAttribute("value") !== e && this.setAttribute("value", e), this._syncDynamicUi(), this._applyAutosize(), this._emit("input", e);
|
|
475
|
-
const i =
|
|
474
|
+
const i = b(this.getAttribute("debounce"), 0);
|
|
476
475
|
i > 0 ? (this._debounceTimer && clearTimeout(this._debounceTimer), this._debounceTimer = setTimeout(() => {
|
|
477
476
|
this._emit("debounced-input", e), this._debounceTimer = null;
|
|
478
477
|
}, i)) : this._emit("debounced-input", e);
|
|
@@ -485,36 +484,34 @@ class y extends f {
|
|
|
485
484
|
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 })));
|
|
486
485
|
}
|
|
487
486
|
render() {
|
|
488
|
-
|
|
489
|
-
const t = this.getAttribute("value") || "", e = this.getAttribute("label") || "", i = this.getAttribute("description") || "", a = this.getAttribute("data-error") || "", r = !!(e || i || this.querySelector('[slot="label"]') || this.querySelector('[slot="description"]')), n = this.hasAttribute("clearable") && !!t && !this.hasAttribute("disabled") && !this.hasAttribute("readonly");
|
|
487
|
+
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");
|
|
490
488
|
this.setContent(`
|
|
491
|
-
<style>${
|
|
489
|
+
<style>${y}</style>
|
|
492
490
|
<div class="shell" part="shell">
|
|
493
|
-
<div class="meta" part="meta" ${
|
|
494
|
-
<label id="${this._uid}-label" class="label" part="label"><slot name="label">${
|
|
495
|
-
<div id="${this._uid}-description" class="description" part="description"><slot name="description">${
|
|
491
|
+
<div class="meta" part="meta" ${a ? "" : "hidden"}>
|
|
492
|
+
<label id="${this._uid}-label" class="label" part="label"><slot name="label">${x(e)}</slot></label>
|
|
493
|
+
<div id="${this._uid}-description" class="description" part="description"><slot name="description">${x(i)}</slot></div>
|
|
496
494
|
</div>
|
|
497
495
|
|
|
498
496
|
<div class="field" part="field">
|
|
499
497
|
<textarea part="textarea"></textarea>
|
|
500
|
-
<button type="button" part="clear" class="clear-btn" aria-label="Clear text" ${
|
|
498
|
+
<button type="button" part="clear" class="clear-btn" aria-label="Clear text" ${o ? "" : "hidden"}>${_}</button>
|
|
501
499
|
</div>
|
|
502
500
|
|
|
503
501
|
<div class="footer" part="footer">
|
|
504
|
-
<div id="${this._uid}-error" class="error" part="error"><slot name="error">${
|
|
502
|
+
<div id="${this._uid}-error" class="error" part="error"><slot name="error">${x(s)}</slot></div>
|
|
505
503
|
<div id="${this._uid}-count" class="count" part="count" hidden></div>
|
|
506
504
|
</div>
|
|
507
505
|
</div>
|
|
508
|
-
`), 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),
|
|
509
|
-
|
|
510
|
-
(s = this._textarea) == null || s.focus();
|
|
506
|
+
`), 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(() => {
|
|
507
|
+
this._textarea?.focus();
|
|
511
508
|
}));
|
|
512
509
|
}
|
|
513
510
|
shouldRenderOnAttributeChange(t, e, i) {
|
|
514
511
|
return t === "label" || t === "description" || t === "data-error";
|
|
515
512
|
}
|
|
516
513
|
}
|
|
517
|
-
typeof customElements < "u" && !customElements.get("ui-textarea") && customElements.define("ui-textarea",
|
|
514
|
+
typeof customElements < "u" && !customElements.get("ui-textarea") && customElements.define("ui-textarea", z);
|
|
518
515
|
export {
|
|
519
|
-
|
|
516
|
+
z as UITextarea
|
|
520
517
|
};
|
package/dist/time-field.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 C=require("./ElementBase-EV6mVBUV.js"),c=require("./date-time-utils-Dmost5Ee.js");let T=0;const B=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-time-field-border-color: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 78%, transparent);
|
|
4
4
|
--ui-time-field-border: 1px solid var(--ui-time-field-border-color);
|
|
@@ -127,8 +127,8 @@
|
|
|
127
127
|
:host([readonly]) .segment {
|
|
128
128
|
cursor: default;
|
|
129
129
|
}
|
|
130
|
-
`;function
|
|
131
|
-
<style>${
|
|
130
|
+
`;function b(l,e){return c.parseTimeInput(l||"")||null}function p(l){return{hour:l.hours%12||12,meridiem:l.hours>=12?"PM":"AM"}}function E(l,e){return e==="AM"?l===12?0:l:l===12?12:l+12}function V(l){return l==="meridiem"?"AM":l==="hour"?"HH":l==="minute"?"MM":"SS"}const g=class g extends C.ElementBase{constructor(){super(),this._value=null,this._activeSegment="hour",this._segmentButtons=new Map,this._segmentsEl=null,this._shellEl=null,this._errorEl=null,this._formUnregister=null,this._bufferBySegment={hour:"",minute:"",second:""},this._bufferTimer=null,this._internals=null,this._uid=`ui-time-field-${++T}`,this._defaultValue=null;try{this._internals=typeof this.attachInternals=="function"?this.attachInternals():null}catch{this._internals=null}this._onSegmentKeyDown=this._onSegmentKeyDown.bind(this),this._onSegmentClick=this._onSegmentClick.bind(this),this._onFocusIn=this._onFocusIn.bind(this),this._onFocusOut=this._onFocusOut.bind(this)}static get observedAttributes(){return["value","min","max","format","seconds","label","description","data-error","required","disabled","readonly","name","locale"]}get value(){return this._value||""}set value(e){this._setValue(e||null,"api")}clearValue(){this._setValue(null,"clear")}formResetCallback(){this._setValue(this._defaultValue,"form")}connectedCallback(){super.connectedCallback(),this._defaultValue==null&&(this._defaultValue=this.getAttribute("value")),this._registerWithForm()}disconnectedCallback(){this._formUnregister&&(this._formUnregister(),this._formUnregister=null),this._bufferTimer!=null&&(window.clearTimeout(this._bufferTimer),this._bufferTimer=null),super.disconnectedCallback()}attributeChangedCallback(e,i,t){i!==t&&(e==="value"&&(this._value=this._normalizeTimeValue(t)),e==="name"&&this.isConnected&&this._registerWithForm(),this._shellEl&&this._syncUi())}shouldRenderOnAttributeChange(){return!1}render(){this.setContent(`
|
|
131
|
+
<style>${B}</style>
|
|
132
132
|
<div class="root">
|
|
133
133
|
<div class="meta" hidden>
|
|
134
134
|
<div class="label" hidden><span class="label-text"></span><span class="required" hidden>*</span></div>
|
|
@@ -139,4 +139,4 @@
|
|
|
139
139
|
</div>
|
|
140
140
|
<div class="error" part="error" hidden></div>
|
|
141
141
|
</div>
|
|
142
|
-
`),this._segmentsEl=this.root.querySelector(".segments"),this._shellEl=this.root.querySelector(".shell"),this._errorEl=this.root.querySelector(".error"),
|
|
142
|
+
`),this._segmentsEl=this.root.querySelector(".segments"),this._shellEl=this.root.querySelector(".shell"),this._errorEl=this.root.querySelector(".error"),this._shellEl?.addEventListener("focusin",this._onFocusIn),this._shellEl?.addEventListener("focusout",this._onFocusOut),this._value=this._normalizeTimeValue(this.getAttribute("value")),this._syncFormValue(),this._syncUi()}_showSeconds(){return this.hasAttribute("seconds")}_is12h(){return(this.getAttribute("format")||"").toLowerCase()==="12h"}_normalizeTimeValue(e){const i=c.parseTimeInput(e||"");if(!i)return null;const t=c.formatTime(i,this._showSeconds()),s=this.getAttribute("min"),r=this.getAttribute("max");return c.clampTime(t,s,r)}_partsOrFallback(){return b(this._value,this._showSeconds())||b(this.getAttribute("min"),this._showSeconds())||{hours:9,minutes:0,seconds:0}}_order(){const e=["hour","minute"];return this._showSeconds()&&e.push("second"),this._is12h()&&e.push("meridiem"),e}_focusSegment(e){this._activeSegment=e,this._syncUi(),this._segmentButtons.get(e)?.focus()}_moveSegmentFocus(e){const i=this._order(),t=i.indexOf(this._activeSegment),s=i[(t+e+i.length)%i.length];this._focusSegment(s)}_setBuffer(e,i){this._bufferBySegment[e]=i,this._bufferTimer!=null&&window.clearTimeout(this._bufferTimer),this._bufferTimer=window.setTimeout(()=>{this._bufferBySegment.hour="",this._bufferBySegment.minute="",this._bufferBySegment.second="",this._bufferTimer=null},900)}_applyParts(e,i){const t=this._normalizeTimeValue(c.formatTime(e,this._showSeconds()));this._setValue(t,i)}_setValue(e,i){const t=this._normalizeTimeValue(e);if(t===this._value){this._syncFormValue(),this._syncUi();return}const s=this._value;this._value=t,t?this.setAttribute("value",t):this.removeAttribute("value"),this._syncFormValue(),this._syncUi(),this.dispatchEvent(new CustomEvent("change",{detail:{value:t,previousValue:s,source:i},bubbles:!0,composed:!0}))}_syncFormValue(){try{this._internals?.setFormValue(this.value||"")}catch{}}_increment(e,i){const t=this._partsOrFallback();if(e==="meridiem"){t.hours=(t.hours+12)%24,this._applyParts(t,"keyboard");return}const a=(t.hours*3600+t.minutes*60+t.seconds+i*(e==="hour"?3600:e==="minute"?60:1)+86400)%86400,d={hours:Math.floor(a/3600),minutes:Math.floor(a%3600/60),seconds:a%60};this._applyParts(d,"keyboard")}_applyNumericInput(e,i){const t=`${this._bufferBySegment[e]}${i}`.slice(-2);if(this._setBuffer(e,t),t.length<2)return;const s=this._partsOrFallback(),r=Number(t);if(Number.isFinite(r)){if(e==="hour")if(this._is12h()){const{meridiem:a}=p(s),d=Math.min(Math.max(r,1),12);s.hours=E(d,a)}else s.hours=Math.min(Math.max(r,0),23);else e==="minute"?s.minutes=Math.min(Math.max(r,0),59):s.seconds=Math.min(Math.max(r,0),59);this._applyParts(s,"keyboard"),this._moveSegmentFocus(1)}}_onSegmentClick(e){const i=e.currentTarget.getAttribute("data-segment");i&&this._focusSegment(i)}_onSegmentKeyDown(e){if(this.hasAttribute("disabled")||this.hasAttribute("readonly"))return;const i=e.currentTarget.getAttribute("data-segment");if(i){if(e.key==="ArrowLeft"){e.preventDefault(),this._moveSegmentFocus(-1);return}if(e.key==="ArrowRight"){e.preventDefault(),this._moveSegmentFocus(1);return}if(e.key==="ArrowUp"||e.key==="ArrowDown"){e.preventDefault(),this._increment(i,e.key==="ArrowUp"?1:-1);return}if(e.key==="Backspace"||e.key==="Delete"){e.preventDefault(),this.clearValue();return}if(i==="meridiem"&&/^[ap]$/i.test(e.key)){e.preventDefault();const t=this._partsOrFallback(),s=e.key.toLowerCase()==="a"?"AM":"PM",r=p(t).hour;t.hours=E(r,s),this._applyParts(t,"keyboard");return}/^\d$/.test(e.key)&&i!=="meridiem"&&(e.preventDefault(),this._applyNumericInput(i,e.key))}}_registerWithForm(){this._formUnregister&&(this._formUnregister(),this._formUnregister=null);try{const s=this.getRootNode().host?.closest?.("ui-form")||null||this.closest("ui-form"),r=this.getAttribute("name");s&&typeof s.registerField=="function"&&r&&(this._formUnregister=s.registerField(r,{name:r,getValue:()=>this.value,setValue:a=>this._setValue(a?String(a):null,"form"),validate:async()=>this.hasAttribute("required")&&!this.value?{valid:!1,message:"Time is required"}:{valid:!0},setError:a=>{a?this.setAttribute("data-error",a):this.removeAttribute("data-error"),this._syncUi()}}))}catch{}}_onFocusIn(){this._shellEl?.setAttribute("data-focused","true")}_onFocusOut(e){this._shellEl?.contains(e.relatedTarget)||this._shellEl?.setAttribute("data-focused","false")}_syncUi(){if(!this._segmentsEl||!this._shellEl||!this._errorEl)return;const e=this.root.activeElement,i=!!e&&this._segmentsEl.contains(e),t=(this.getAttribute("label")||"").trim(),s=(this.getAttribute("description")||"").trim(),r=(this.getAttribute("data-error")||"").trim(),a=this.root.querySelector(".meta"),d=this.root.querySelector(".label"),k=this.root.querySelector(".label-text"),w=this.root.querySelector(".required"),f=this.root.querySelector(".description"),y=`${this._uid}-label`,v=`${this._uid}-description`,x=`${this._uid}-error`;a.hidden=!t&&!s,d.hidden=!t,d.id=t?y:"",k.textContent=t,w.hidden=!this.hasAttribute("required"),f.hidden=!s,f.id=s?v:"",f.textContent=s,this._errorEl.hidden=!r,this._errorEl.id=r?x:"",this._errorEl.textContent=r,this._shellEl.setAttribute("data-invalid",r?"true":"false"),this._shellEl.setAttribute("role","group"),t?this._shellEl.setAttribute("aria-labelledby",y):this._shellEl.removeAttribute("aria-labelledby");const S=[s?v:null,r?x:null].filter(Boolean).join(" ");S?this._shellEl.setAttribute("aria-describedby",S):this._shellEl.removeAttribute("aria-describedby"),this._shellEl.setAttribute("aria-invalid",r?"true":"false"),this._shellEl.setAttribute("aria-required",this.hasAttribute("required")?"true":"false"),this._shellEl.setAttribute("aria-disabled",this.hasAttribute("disabled")?"true":"false"),this._shellEl.setAttribute("aria-readonly",this.hasAttribute("readonly")?"true":"false");const u=b(this._value,this._showSeconds()),F=this._order(),_=[];this._segmentButtons.clear();const A=u?p(u):null;if(F.forEach((o,M)=>{if(M>0){const h=document.createElement("span");h.className="literal",h.textContent=o==="meridiem"?" ":":",_.push(h)}const n=document.createElement("button");if(n.type="button",n.className="segment",n.setAttribute("data-segment",o),n.setAttribute("data-active",this._activeSegment===o?"true":"false"),n.setAttribute("data-empty",u?"false":"true"),n.setAttribute("aria-label",o==="hour"?"Hour":o==="minute"?"Minute":o==="second"?"Second":"AM or PM"),n.tabIndex=this._activeSegment===o?0:-1,n.disabled=this.hasAttribute("disabled"),n.addEventListener("click",this._onSegmentClick),n.addEventListener("keydown",this._onSegmentKeyDown),!u)n.textContent=V(o);else if(o==="hour"){const h=this._is12h()?A.hour:u.hours;n.textContent=String(h).padStart(2,"0")}else o==="minute"?n.textContent=String(u.minutes).padStart(2,"0"):o==="second"?n.textContent=String(u.seconds).padStart(2,"0"):n.textContent=A.meridiem;this._segmentButtons.set(o,n),_.push(n)}),this._segmentsEl.replaceChildren(..._),i){const o=this._segmentButtons.get(this._activeSegment);try{o?.focus({preventScroll:!0})}catch{o?.focus()}}}};g.formAssociated=!0;let m=g;typeof customElements<"u"&&!customElements.get("ui-time-field")&&customElements.define("ui-time-field",m);exports.UITimeField=m;
|