@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/textarea.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as f } from "./ElementBase-
|
|
1
|
+
import { E as f } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
2
|
const v = `
|
|
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"/>
|
|
@@ -310,11 +310,11 @@ const v = `
|
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
`;
|
|
313
|
-
function d(
|
|
314
|
-
return
|
|
313
|
+
function d(l) {
|
|
314
|
+
return l.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
315
315
|
}
|
|
316
|
-
function x(
|
|
317
|
-
const e = Number(
|
|
316
|
+
function x(l, t) {
|
|
317
|
+
const e = Number(l);
|
|
318
318
|
return Number.isFinite(e) ? e : t;
|
|
319
319
|
}
|
|
320
320
|
class y extends f {
|
|
@@ -359,11 +359,10 @@ class y extends f {
|
|
|
359
359
|
this._detachListeners(), this._debounceTimer && (clearTimeout(this._debounceTimer), this._debounceTimer = null), this._formUnregister && (this._formUnregister(), this._formUnregister = null), super.disconnectedCallback();
|
|
360
360
|
}
|
|
361
361
|
attributeChangedCallback(t, e, i) {
|
|
362
|
-
if (e === i)
|
|
363
|
-
return;
|
|
362
|
+
if (e === i) return;
|
|
364
363
|
if (t === "name" && this._tryRegisterWithForm(), t === "value" && this._textarea) {
|
|
365
|
-
const
|
|
366
|
-
this._textarea.value !==
|
|
364
|
+
const a = i || "";
|
|
365
|
+
this._textarea.value !== a && (this._textarea.value = a), this._syncDynamicUi(), this._applyAutosize();
|
|
367
366
|
return;
|
|
368
367
|
}
|
|
369
368
|
if ((/* @__PURE__ */ new Set([
|
|
@@ -391,8 +390,7 @@ class y extends f {
|
|
|
391
390
|
"autofocus"
|
|
392
391
|
])).has(t)) {
|
|
393
392
|
this._syncControlAttrs(), this._syncDynamicUi(), this._applyAutosize(), t === "autofocus" && this.hasAttribute("autofocus") && queueMicrotask(() => {
|
|
394
|
-
|
|
395
|
-
(r = this._textarea) == null || r.focus();
|
|
393
|
+
this._textarea?.focus();
|
|
396
394
|
});
|
|
397
395
|
return;
|
|
398
396
|
}
|
|
@@ -405,20 +403,18 @@ class y extends f {
|
|
|
405
403
|
this.setAttribute("value", t || "");
|
|
406
404
|
}
|
|
407
405
|
_tryRegisterWithForm() {
|
|
408
|
-
var t;
|
|
409
406
|
try {
|
|
410
|
-
const
|
|
411
|
-
if (!
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
name: i,
|
|
407
|
+
const t = this.closest?.("ui-form"), e = this.getAttribute("name");
|
|
408
|
+
if (!t || typeof t.registerField != "function" || !e) return;
|
|
409
|
+
this._formUnregister = t.registerField(e, {
|
|
410
|
+
name: e,
|
|
415
411
|
getValue: () => this.value,
|
|
416
|
-
setValue: (
|
|
417
|
-
this.value =
|
|
412
|
+
setValue: (i) => {
|
|
413
|
+
this.value = i;
|
|
418
414
|
},
|
|
419
415
|
validate: async () => this._textarea ? { valid: this._textarea.checkValidity(), message: this._textarea.validationMessage || void 0 } : { valid: !0 },
|
|
420
|
-
setError: (
|
|
421
|
-
|
|
416
|
+
setError: (i) => {
|
|
417
|
+
i ? (this.setAttribute("validation", "error"), this.setAttribute("data-error", i)) : (this.removeAttribute("validation"), this.removeAttribute("data-error"));
|
|
422
418
|
}
|
|
423
419
|
});
|
|
424
420
|
} catch {
|
|
@@ -428,21 +424,18 @@ class y extends f {
|
|
|
428
424
|
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
425
|
}
|
|
430
426
|
_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");
|
|
427
|
+
if (!this._textarea) return;
|
|
428
|
+
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", p = this.getAttribute("validation"), b = this.getAttribute("color"), o = this.getAttribute("radius");
|
|
429
|
+
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"), p === "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");
|
|
430
|
+
const n = [], g = !!(this.getAttribute("description") || this.querySelector('[slot="description"]')), m = !!(this.getAttribute("data-error") || this.querySelector('[slot="error"]'));
|
|
431
|
+
g && n.push(`${this._uid}-description`), m && 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");
|
|
437
432
|
}
|
|
438
433
|
_syncDynamicUi() {
|
|
439
|
-
|
|
440
|
-
const t = ((a = this._textarea) == null ? void 0 : a.value) || this.getAttribute("value") || "", e = this.getAttribute("maxlength"), i = this.hasAttribute("clearable");
|
|
434
|
+
const t = this._textarea?.value || this.getAttribute("value") || "", e = this.getAttribute("maxlength"), i = this.hasAttribute("clearable");
|
|
441
435
|
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", ""));
|
|
442
436
|
}
|
|
443
437
|
_applyAutosize() {
|
|
444
|
-
if (!this._textarea)
|
|
445
|
-
return;
|
|
438
|
+
if (!this._textarea) return;
|
|
446
439
|
if (!this.hasAttribute("autosize")) {
|
|
447
440
|
this._textarea.style.height = "", this._textarea.style.overflowY = "";
|
|
448
441
|
return;
|
|
@@ -450,8 +443,8 @@ class y extends f {
|
|
|
450
443
|
this._textarea.style.height = "auto";
|
|
451
444
|
const t = this._textarea.scrollHeight, e = x(this.getAttribute("max-rows"), 0);
|
|
452
445
|
if (e > 0) {
|
|
453
|
-
const i = getComputedStyle(this._textarea),
|
|
454
|
-
this._textarea.style.height = `${Math.min(t,
|
|
446
|
+
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;
|
|
447
|
+
this._textarea.style.height = `${Math.min(t, h)}px`, this._textarea.style.overflowY = t > h ? "auto" : "hidden";
|
|
455
448
|
return;
|
|
456
449
|
}
|
|
457
450
|
this._textarea.style.height = `${t}px`, this._textarea.style.overflowY = "hidden";
|
|
@@ -485,29 +478,27 @@ class y extends f {
|
|
|
485
478
|
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
479
|
}
|
|
487
480
|
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");
|
|
481
|
+
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");
|
|
490
482
|
this.setContent(`
|
|
491
483
|
<style>${_}</style>
|
|
492
484
|
<div class="shell" part="shell">
|
|
493
|
-
<div class="meta" part="meta" ${
|
|
485
|
+
<div class="meta" part="meta" ${a ? "" : "hidden"}>
|
|
494
486
|
<label id="${this._uid}-label" class="label" part="label"><slot name="label">${d(e)}</slot></label>
|
|
495
487
|
<div id="${this._uid}-description" class="description" part="description"><slot name="description">${d(i)}</slot></div>
|
|
496
488
|
</div>
|
|
497
489
|
|
|
498
490
|
<div class="field" part="field">
|
|
499
491
|
<textarea part="textarea"></textarea>
|
|
500
|
-
<button type="button" part="clear" class="clear-btn" aria-label="Clear text" ${
|
|
492
|
+
<button type="button" part="clear" class="clear-btn" aria-label="Clear text" ${s ? "" : "hidden"}>${v}</button>
|
|
501
493
|
</div>
|
|
502
494
|
|
|
503
495
|
<div class="footer" part="footer">
|
|
504
|
-
<div id="${this._uid}-error" class="error" part="error"><slot name="error">${d(
|
|
496
|
+
<div id="${this._uid}-error" class="error" part="error"><slot name="error">${d(r)}</slot></div>
|
|
505
497
|
<div id="${this._uid}-count" class="count" part="count" hidden></div>
|
|
506
498
|
</div>
|
|
507
499
|
</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();
|
|
500
|
+
`), 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(() => {
|
|
501
|
+
this._textarea?.focus();
|
|
511
502
|
}));
|
|
512
503
|
}
|
|
513
504
|
shouldRenderOnAttributeChange(t, e, i) {
|
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;
|
package/dist/time-field.esm.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
import { q as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import "./positioner-e9770c66.mjs";
|
|
6
|
-
let V = 0;
|
|
7
|
-
const B = `
|
|
1
|
+
import { E as V } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
|
+
import { q as k, u as A, v as B } from "./date-time-utils-y1N2gvG2.mjs";
|
|
3
|
+
let T = 0;
|
|
4
|
+
const I = `
|
|
8
5
|
:host {
|
|
9
6
|
--ui-time-field-border-color: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 78%, transparent);
|
|
10
7
|
--ui-time-field-border: 1px solid var(--ui-time-field-border-color);
|
|
@@ -135,20 +132,20 @@ const B = `
|
|
|
135
132
|
}
|
|
136
133
|
`;
|
|
137
134
|
function f(l, e) {
|
|
138
|
-
return
|
|
135
|
+
return k(l || "") || null;
|
|
139
136
|
}
|
|
140
137
|
function _(l) {
|
|
141
138
|
return { hour: l.hours % 12 || 12, meridiem: l.hours >= 12 ? "PM" : "AM" };
|
|
142
139
|
}
|
|
143
|
-
function
|
|
140
|
+
function E(l, e) {
|
|
144
141
|
return e === "AM" ? l === 12 ? 0 : l : l === 12 ? 12 : l + 12;
|
|
145
142
|
}
|
|
146
|
-
function
|
|
143
|
+
function q(l) {
|
|
147
144
|
return l === "meridiem" ? "AM" : l === "hour" ? "HH" : l === "minute" ? "MM" : "SS";
|
|
148
145
|
}
|
|
149
|
-
class
|
|
146
|
+
const p = class p extends V {
|
|
150
147
|
constructor() {
|
|
151
|
-
super(), this._value = null, this._activeSegment = "hour", this._segmentButtons = /* @__PURE__ */ 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-${++
|
|
148
|
+
super(), this._value = null, this._activeSegment = "hour", this._segmentButtons = /* @__PURE__ */ 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;
|
|
152
149
|
try {
|
|
153
150
|
this._internals = typeof this.attachInternals == "function" ? this.attachInternals() : null;
|
|
154
151
|
} catch {
|
|
@@ -184,9 +181,8 @@ class E extends M {
|
|
|
184
181
|
return !1;
|
|
185
182
|
}
|
|
186
183
|
render() {
|
|
187
|
-
var e, i;
|
|
188
184
|
this.setContent(`
|
|
189
|
-
<style>${
|
|
185
|
+
<style>${I}</style>
|
|
190
186
|
<div class="root">
|
|
191
187
|
<div class="meta" hidden>
|
|
192
188
|
<div class="label" hidden><span class="label-text"></span><span class="required" hidden>*</span></div>
|
|
@@ -197,7 +193,7 @@ class E extends M {
|
|
|
197
193
|
</div>
|
|
198
194
|
<div class="error" part="error" hidden></div>
|
|
199
195
|
</div>
|
|
200
|
-
`), this._segmentsEl = this.root.querySelector(".segments"), this._shellEl = this.root.querySelector(".shell"), this._errorEl = this.root.querySelector(".error"),
|
|
196
|
+
`), 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();
|
|
201
197
|
}
|
|
202
198
|
_showSeconds() {
|
|
203
199
|
return this.hasAttribute("seconds");
|
|
@@ -206,11 +202,10 @@ class E extends M {
|
|
|
206
202
|
return (this.getAttribute("format") || "").toLowerCase() === "12h";
|
|
207
203
|
}
|
|
208
204
|
_normalizeTimeValue(e) {
|
|
209
|
-
const i =
|
|
210
|
-
if (!i)
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
return T(t, r, s);
|
|
205
|
+
const i = k(e || "");
|
|
206
|
+
if (!i) return null;
|
|
207
|
+
const t = A(i, this._showSeconds()), s = this.getAttribute("min"), r = this.getAttribute("max");
|
|
208
|
+
return B(t, s, r);
|
|
214
209
|
}
|
|
215
210
|
_partsOrFallback() {
|
|
216
211
|
return f(this._value, this._showSeconds()) || f(this.getAttribute("min"), this._showSeconds()) || { hours: 9, minutes: 0, seconds: 0 };
|
|
@@ -220,12 +215,11 @@ class E extends M {
|
|
|
220
215
|
return this._showSeconds() && e.push("second"), this._is12h() && e.push("meridiem"), e;
|
|
221
216
|
}
|
|
222
217
|
_focusSegment(e) {
|
|
223
|
-
|
|
224
|
-
this._activeSegment = e, this._syncUi(), (i = this._segmentButtons.get(e)) == null || i.focus();
|
|
218
|
+
this._activeSegment = e, this._syncUi(), this._segmentButtons.get(e)?.focus();
|
|
225
219
|
}
|
|
226
220
|
_moveSegmentFocus(e) {
|
|
227
|
-
const i = this._order(), t = i.indexOf(this._activeSegment),
|
|
228
|
-
this._focusSegment(
|
|
221
|
+
const i = this._order(), t = i.indexOf(this._activeSegment), s = i[(t + e + i.length) % i.length];
|
|
222
|
+
this._focusSegment(s);
|
|
229
223
|
}
|
|
230
224
|
_setBuffer(e, i) {
|
|
231
225
|
this._bufferBySegment[e] = i, this._bufferTimer != null && window.clearTimeout(this._bufferTimer), this._bufferTimer = window.setTimeout(() => {
|
|
@@ -233,7 +227,7 @@ class E extends M {
|
|
|
233
227
|
}, 900);
|
|
234
228
|
}
|
|
235
229
|
_applyParts(e, i) {
|
|
236
|
-
const t = this._normalizeTimeValue(
|
|
230
|
+
const t = this._normalizeTimeValue(A(e, this._showSeconds()));
|
|
237
231
|
this._setValue(t, i);
|
|
238
232
|
}
|
|
239
233
|
_setValue(e, i) {
|
|
@@ -242,19 +236,18 @@ class E extends M {
|
|
|
242
236
|
this._syncFormValue(), this._syncUi();
|
|
243
237
|
return;
|
|
244
238
|
}
|
|
245
|
-
const
|
|
239
|
+
const s = this._value;
|
|
246
240
|
this._value = t, t ? this.setAttribute("value", t) : this.removeAttribute("value"), this._syncFormValue(), this._syncUi(), this.dispatchEvent(
|
|
247
241
|
new CustomEvent("change", {
|
|
248
|
-
detail: { value: t, previousValue:
|
|
242
|
+
detail: { value: t, previousValue: s, source: i },
|
|
249
243
|
bubbles: !0,
|
|
250
244
|
composed: !0
|
|
251
245
|
})
|
|
252
246
|
);
|
|
253
247
|
}
|
|
254
248
|
_syncFormValue() {
|
|
255
|
-
var e;
|
|
256
249
|
try {
|
|
257
|
-
|
|
250
|
+
this._internals?.setFormValue(this.value || "");
|
|
258
251
|
} catch {
|
|
259
252
|
}
|
|
260
253
|
}
|
|
@@ -264,28 +257,26 @@ class E extends M {
|
|
|
264
257
|
t.hours = (t.hours + 12) % 24, this._applyParts(t, "keyboard");
|
|
265
258
|
return;
|
|
266
259
|
}
|
|
267
|
-
const
|
|
268
|
-
hours: Math.floor(
|
|
269
|
-
minutes: Math.floor(
|
|
270
|
-
seconds:
|
|
260
|
+
const a = (t.hours * 3600 + t.minutes * 60 + t.seconds + i * (e === "hour" ? 3600 : e === "minute" ? 60 : 1) + 86400) % 86400, h = {
|
|
261
|
+
hours: Math.floor(a / 3600),
|
|
262
|
+
minutes: Math.floor(a % 3600 / 60),
|
|
263
|
+
seconds: a % 60
|
|
271
264
|
};
|
|
272
|
-
this._applyParts(
|
|
265
|
+
this._applyParts(h, "keyboard");
|
|
273
266
|
}
|
|
274
267
|
_applyNumericInput(e, i) {
|
|
275
268
|
const t = `${this._bufferBySegment[e]}${i}`.slice(-2);
|
|
276
|
-
if (this._setBuffer(e, t), t.length < 2)
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
if (Number.isFinite(s)) {
|
|
269
|
+
if (this._setBuffer(e, t), t.length < 2) return;
|
|
270
|
+
const s = this._partsOrFallback(), r = Number(t);
|
|
271
|
+
if (Number.isFinite(r)) {
|
|
280
272
|
if (e === "hour")
|
|
281
273
|
if (this._is12h()) {
|
|
282
|
-
const { meridiem:
|
|
283
|
-
|
|
274
|
+
const { meridiem: a } = _(s), h = Math.min(Math.max(r, 1), 12);
|
|
275
|
+
s.hours = E(h, a);
|
|
284
276
|
} else
|
|
285
|
-
|
|
286
|
-
else
|
|
287
|
-
|
|
288
|
-
this._applyParts(r, "keyboard"), this._moveSegmentFocus(1);
|
|
277
|
+
s.hours = Math.min(Math.max(r, 0), 23);
|
|
278
|
+
else e === "minute" ? s.minutes = Math.min(Math.max(r, 0), 59) : s.seconds = Math.min(Math.max(r, 0), 59);
|
|
279
|
+
this._applyParts(s, "keyboard"), this._moveSegmentFocus(1);
|
|
289
280
|
}
|
|
290
281
|
}
|
|
291
282
|
_onSegmentClick(e) {
|
|
@@ -293,8 +284,7 @@ class E extends M {
|
|
|
293
284
|
i && this._focusSegment(i);
|
|
294
285
|
}
|
|
295
286
|
_onSegmentKeyDown(e) {
|
|
296
|
-
if (this.hasAttribute("disabled") || this.hasAttribute("readonly"))
|
|
297
|
-
return;
|
|
287
|
+
if (this.hasAttribute("disabled") || this.hasAttribute("readonly")) return;
|
|
298
288
|
const i = e.currentTarget.getAttribute("data-segment");
|
|
299
289
|
if (i) {
|
|
300
290
|
if (e.key === "ArrowLeft") {
|
|
@@ -315,20 +305,19 @@ class E extends M {
|
|
|
315
305
|
}
|
|
316
306
|
if (i === "meridiem" && /^[ap]$/i.test(e.key)) {
|
|
317
307
|
e.preventDefault();
|
|
318
|
-
const t = this._partsOrFallback(),
|
|
319
|
-
t.hours =
|
|
308
|
+
const t = this._partsOrFallback(), s = e.key.toLowerCase() === "a" ? "AM" : "PM", r = _(t).hour;
|
|
309
|
+
t.hours = E(r, s), this._applyParts(t, "keyboard");
|
|
320
310
|
return;
|
|
321
311
|
}
|
|
322
312
|
/^\d$/.test(e.key) && i !== "meridiem" && (e.preventDefault(), this._applyNumericInput(i, e.key));
|
|
323
313
|
}
|
|
324
314
|
}
|
|
325
315
|
_registerWithForm() {
|
|
326
|
-
var e;
|
|
327
316
|
this._formUnregister && (this._formUnregister(), this._formUnregister = null);
|
|
328
317
|
try {
|
|
329
|
-
const
|
|
330
|
-
s && typeof s.registerField == "function" &&
|
|
331
|
-
name:
|
|
318
|
+
const s = this.getRootNode().host?.closest?.("ui-form") || null || this.closest("ui-form"), r = this.getAttribute("name");
|
|
319
|
+
s && typeof s.registerField == "function" && r && (this._formUnregister = s.registerField(r, {
|
|
320
|
+
name: r,
|
|
332
321
|
getValue: () => this.value,
|
|
333
322
|
setValue: (a) => this._setValue(a ? String(a) : null, "form"),
|
|
334
323
|
validate: async () => this.hasAttribute("required") && !this.value ? { valid: !1, message: "Time is required" } : { valid: !0 },
|
|
@@ -340,49 +329,46 @@ class E extends M {
|
|
|
340
329
|
}
|
|
341
330
|
}
|
|
342
331
|
_onFocusIn() {
|
|
343
|
-
|
|
344
|
-
(e = this._shellEl) == null || e.setAttribute("data-focused", "true");
|
|
332
|
+
this._shellEl?.setAttribute("data-focused", "true");
|
|
345
333
|
}
|
|
346
334
|
_onFocusOut(e) {
|
|
347
|
-
|
|
348
|
-
(i = this._shellEl) != null && i.contains(e.relatedTarget) || (t = this._shellEl) == null || t.setAttribute("data-focused", "false");
|
|
335
|
+
this._shellEl?.contains(e.relatedTarget) || this._shellEl?.setAttribute("data-focused", "false");
|
|
349
336
|
}
|
|
350
337
|
_syncUi() {
|
|
351
|
-
if (!this._segmentsEl || !this._shellEl || !this._errorEl)
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
const d = f(this._value, this._showSeconds()), F = this._order(), m = [];
|
|
338
|
+
if (!this._segmentsEl || !this._shellEl || !this._errorEl) return;
|
|
339
|
+
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"), h = this.root.querySelector(".label"), w = this.root.querySelector(".label-text"), F = this.root.querySelector(".required"), c = this.root.querySelector(".description"), g = `${this._uid}-label`, y = `${this._uid}-description`, v = `${this._uid}-error`;
|
|
340
|
+
a.hidden = !t && !s, h.hidden = !t, h.id = t ? g : "", w.textContent = t, F.hidden = !this.hasAttribute("required"), c.hidden = !s, c.id = s ? y : "", c.textContent = s, this._errorEl.hidden = !r, this._errorEl.id = r ? v : "", this._errorEl.textContent = r, this._shellEl.setAttribute("data-invalid", r ? "true" : "false"), this._shellEl.setAttribute("role", "group"), t ? this._shellEl.setAttribute("aria-labelledby", g) : this._shellEl.removeAttribute("aria-labelledby");
|
|
341
|
+
const x = [s ? y : null, r ? v : null].filter(Boolean).join(" ");
|
|
342
|
+
x ? this._shellEl.setAttribute("aria-describedby", x) : 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");
|
|
343
|
+
const u = f(this._value, this._showSeconds()), C = this._order(), m = [];
|
|
358
344
|
this._segmentButtons.clear();
|
|
359
|
-
const
|
|
360
|
-
if (
|
|
361
|
-
if (
|
|
362
|
-
const
|
|
363
|
-
|
|
345
|
+
const S = u ? _(u) : null;
|
|
346
|
+
if (C.forEach((n, M) => {
|
|
347
|
+
if (M > 0) {
|
|
348
|
+
const d = document.createElement("span");
|
|
349
|
+
d.className = "literal", d.textContent = n === "meridiem" ? " " : ":", m.push(d);
|
|
364
350
|
}
|
|
365
|
-
const
|
|
366
|
-
if (
|
|
367
|
-
|
|
368
|
-
else if (
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
} else
|
|
372
|
-
|
|
373
|
-
this._segmentButtons.set(o, n), m.push(n);
|
|
351
|
+
const o = document.createElement("button");
|
|
352
|
+
if (o.type = "button", o.className = "segment", o.setAttribute("data-segment", n), o.setAttribute("data-active", this._activeSegment === n ? "true" : "false"), o.setAttribute("data-empty", u ? "false" : "true"), o.setAttribute("aria-label", n === "hour" ? "Hour" : n === "minute" ? "Minute" : n === "second" ? "Second" : "AM or PM"), o.tabIndex = this._activeSegment === n ? 0 : -1, o.disabled = this.hasAttribute("disabled"), o.addEventListener("click", this._onSegmentClick), o.addEventListener("keydown", this._onSegmentKeyDown), !u)
|
|
353
|
+
o.textContent = q(n);
|
|
354
|
+
else if (n === "hour") {
|
|
355
|
+
const d = this._is12h() ? S.hour : u.hours;
|
|
356
|
+
o.textContent = String(d).padStart(2, "0");
|
|
357
|
+
} else n === "minute" ? o.textContent = String(u.minutes).padStart(2, "0") : n === "second" ? o.textContent = String(u.seconds).padStart(2, "0") : o.textContent = S.meridiem;
|
|
358
|
+
this._segmentButtons.set(n, o), m.push(o);
|
|
374
359
|
}), this._segmentsEl.replaceChildren(...m), i) {
|
|
375
|
-
const
|
|
360
|
+
const n = this._segmentButtons.get(this._activeSegment);
|
|
376
361
|
try {
|
|
377
|
-
|
|
362
|
+
n?.focus({ preventScroll: !0 });
|
|
378
363
|
} catch {
|
|
379
|
-
|
|
364
|
+
n?.focus();
|
|
380
365
|
}
|
|
381
366
|
}
|
|
382
367
|
}
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
|
|
368
|
+
};
|
|
369
|
+
p.formAssociated = !0;
|
|
370
|
+
let b = p;
|
|
371
|
+
typeof customElements < "u" && !customElements.get("ui-time-field") && customElements.define("ui-time-field", b);
|
|
386
372
|
export {
|
|
387
|
-
|
|
373
|
+
b as UITimeField
|
|
388
374
|
};
|