@editora/ui-core 0.1.21 → 0.1.23
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/README.md +292 -221
- package/dist/{ElementBase-YlTLMsGk.mjs → ElementBase-BeZT54Hj.mjs} +3 -2
- package/dist/ElementBase-DxbvhLJs.js +1 -0
- package/dist/ElementBase.d.ts +2 -1
- package/dist/ElementBase.d.ts.map +1 -1
- package/dist/__tests__/setup.d.ts +0 -2
- package/dist/__tests__/setup.d.ts.map +1 -1
- package/dist/accordion.cjs.js +4 -4
- package/dist/accordion.esm.js +4 -4
- package/dist/alert-dialog.cjs.js +32 -32
- package/dist/alert-dialog.esm.js +95 -75
- package/dist/alert.cjs.js +7 -7
- package/dist/alert.esm.js +7 -7
- package/dist/anchor.cjs.js +3 -3
- package/dist/anchor.esm.js +6 -5
- package/dist/animated-beam.cjs.js +1 -1
- package/dist/animated-beam.esm.js +1 -1
- package/dist/animated-list.cjs.js +5 -5
- package/dist/animated-list.esm.js +5 -5
- package/dist/animated-text.cjs.js +5 -5
- package/dist/animated-text.esm.js +5 -5
- package/dist/app-header.cjs.js +4 -4
- package/dist/app-header.esm.js +4 -4
- package/dist/aspect-ratio.cjs.js +4 -4
- package/dist/aspect-ratio.esm.js +4 -4
- package/dist/avatar.cjs.js +14 -14
- package/dist/avatar.esm.js +31 -29
- package/dist/badge.cjs.js +5 -5
- package/dist/badge.esm.js +5 -5
- package/dist/block-controls.cjs.js +5 -5
- package/dist/block-controls.esm.js +5 -5
- package/dist/box.cjs.js +3 -3
- package/dist/box.esm.js +3 -3
- package/dist/breadcrumb.cjs.js +6 -6
- package/dist/breadcrumb.esm.js +6 -6
- package/dist/button.cjs.js +1 -1
- package/dist/button.esm.js +1 -1
- package/dist/{calendar-DLY4acgn.mjs → calendar-B3PUKHQm.mjs} +227 -183
- package/dist/{calendar-Dkof-FTK.js → calendar-D-mXMgqc.js} +74 -35
- package/dist/calendar.cjs.js +1 -1
- package/dist/calendar.esm.js +1 -1
- package/dist/card.cjs.js +8 -8
- package/dist/card.esm.js +63 -20
- package/dist/chart.cjs.js +5 -5
- package/dist/chart.esm.js +7 -7
- package/dist/checkbox.cjs.js +3 -3
- package/dist/checkbox.esm.js +3 -3
- package/dist/collapsible.cjs.js +8 -8
- package/dist/collapsible.esm.js +8 -8
- package/dist/collection.cjs.js +1 -1
- package/dist/collection.esm.js +9 -8
- package/dist/color-picker.cjs.js +30 -10
- package/dist/color-picker.esm.js +84 -62
- package/dist/combobox.cjs.js +29 -27
- package/dist/combobox.esm.js +51 -45
- package/dist/command-palette.cjs.js +1 -1
- package/dist/command-palette.esm.js +1 -1
- package/dist/command.cjs.js +2 -2
- package/dist/command.esm.js +3 -3
- package/dist/components/ui-alert-dialog.d.ts +1 -0
- package/dist/components/ui-alert-dialog.d.ts.map +1 -1
- package/dist/components/ui-anchor.d.ts +2 -1
- package/dist/components/ui-anchor.d.ts.map +1 -1
- package/dist/components/ui-avatar.d.ts +1 -0
- package/dist/components/ui-avatar.d.ts.map +1 -1
- package/dist/components/ui-button.d.ts +1 -0
- package/dist/components/ui-button.d.ts.map +1 -1
- package/dist/components/ui-calendar.d.ts.map +1 -1
- package/dist/components/ui-card.d.ts +3 -0
- package/dist/components/ui-card.d.ts.map +1 -1
- package/dist/components/ui-checkbox.d.ts.map +1 -1
- package/dist/components/ui-collection.d.ts +2 -1
- package/dist/components/ui-collection.d.ts.map +1 -1
- package/dist/components/ui-color-picker.d.ts.map +1 -1
- package/dist/components/ui-combobox.d.ts.map +1 -1
- package/dist/components/ui-data-table.d.ts.map +1 -1
- package/dist/components/ui-date-field.d.ts.map +1 -1
- package/dist/components/ui-date-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
- package/dist/components/ui-date-time-picker.d.ts.map +1 -1
- package/dist/components/ui-dock.d.ts +1 -0
- package/dist/components/ui-dock.d.ts.map +1 -1
- package/dist/components/ui-drawer.d.ts.map +1 -1
- package/dist/components/ui-dropdown.d.ts.map +1 -1
- package/dist/components/ui-field.d.ts.map +1 -1
- package/dist/components/ui-file-upload.d.ts.map +1 -1
- package/dist/components/ui-form.d.ts +1 -0
- package/dist/components/ui-form.d.ts.map +1 -1
- package/dist/components/ui-gantt.d.ts.map +1 -1
- package/dist/components/ui-input.d.ts.map +1 -1
- package/dist/components/ui-menu.d.ts.map +1 -1
- package/dist/components/ui-multi-select.d.ts.map +1 -1
- package/dist/components/ui-number-field.d.ts.map +1 -1
- package/dist/components/ui-password-field.d.ts.map +1 -1
- package/dist/components/ui-pin-input.d.ts +1 -0
- package/dist/components/ui-pin-input.d.ts.map +1 -1
- package/dist/components/ui-placement-grid.d.ts.map +1 -1
- package/dist/components/ui-progress.d.ts.map +1 -1
- package/dist/components/ui-radio.d.ts.map +1 -1
- package/dist/components/ui-rating.d.ts +1 -0
- package/dist/components/ui-rating.d.ts.map +1 -1
- package/dist/components/ui-roving-focus-group.d.ts +2 -1
- package/dist/components/ui-roving-focus-group.d.ts.map +1 -1
- package/dist/components/ui-select.d.ts.map +1 -1
- package/dist/components/ui-sortable.d.ts.map +1 -1
- package/dist/components/ui-switch.d.ts.map +1 -1
- package/dist/components/ui-table.d.ts.map +1 -1
- package/dist/components/ui-tabs.d.ts +1 -0
- package/dist/components/ui-tabs.d.ts.map +1 -1
- package/dist/components/ui-tags-input.d.ts +1 -0
- package/dist/components/ui-tags-input.d.ts.map +1 -1
- package/dist/components/ui-textarea.d.ts.map +1 -1
- package/dist/components/ui-time-field.d.ts.map +1 -1
- package/dist/components/ui-toggle-group.d.ts.map +1 -1
- package/dist/components/ui-toggle.d.ts.map +1 -1
- package/dist/components/ui-tree.d.ts.map +1 -1
- package/dist/components/ui-wizard.d.ts.map +1 -1
- package/dist/container.cjs.js +1 -1
- package/dist/container.esm.js +1 -1
- package/dist/context-menu.cjs.js +3 -3
- package/dist/context-menu.esm.js +5 -5
- package/dist/control-group.cjs.js +1 -1
- package/dist/control-group.esm.js +1 -1
- package/dist/control-name-BmoI1m3a.js +1 -0
- package/dist/control-name-Bpj7F34X.mjs +48 -0
- package/dist/data-table.cjs.js +6 -3
- package/dist/data-table.esm.js +146 -143
- package/dist/date-field.cjs.js +5 -5
- package/dist/date-field.esm.js +34 -31
- package/dist/date-picker.cjs.js +16 -16
- package/dist/date-picker.esm.js +49 -45
- package/dist/date-range-picker.cjs.js +5 -5
- package/dist/date-range-picker.esm.js +120 -118
- package/dist/date-range-time-picker.cjs.js +22 -22
- package/dist/date-range-time-picker.esm.js +89 -85
- package/dist/date-time-picker.cjs.js +23 -23
- package/dist/date-time-picker.esm.js +103 -99
- package/dist/{date-time-utils-y1N2gvG2.mjs → date-time-utils-BTlxnz5j.mjs} +1 -1
- package/dist/{date-time-utils-Dmost5Ee.js → date-time-utils-y3AvNvGe.js} +1 -1
- package/dist/description.cjs.js +4 -4
- package/dist/description.esm.js +4 -4
- package/dist/dialog.cjs.js +3 -3
- package/dist/dialog.esm.js +3 -3
- package/dist/direction-provider.cjs.js +1 -1
- package/dist/direction-provider.esm.js +1 -1
- package/dist/dismissable-layer.cjs.js +1 -1
- package/dist/dismissable-layer.esm.js +1 -1
- package/dist/dock.cjs.js +12 -12
- package/dist/dock.esm.js +73 -75
- package/dist/domElement-DazSZBjV.js +1 -0
- package/dist/domElement-ZlSGVP0l.mjs +5 -0
- package/dist/domElement.d.ts +2 -0
- package/dist/domElement.d.ts.map +1 -0
- package/dist/drawer.cjs.js +19 -19
- package/dist/drawer.esm.js +58 -58
- package/dist/dropdown.cjs.js +13 -13
- package/dist/dropdown.esm.js +50 -49
- package/dist/empty-state.cjs.js +4 -4
- package/dist/empty-state.esm.js +4 -4
- package/dist/field-error.cjs.js +2 -2
- package/dist/field-error.esm.js +2 -2
- package/dist/field.cjs.js +12 -12
- package/dist/field.esm.js +84 -75
- package/dist/fieldset.cjs.js +5 -5
- package/dist/fieldset.esm.js +5 -5
- package/dist/file-upload.cjs.js +4 -4
- package/dist/file-upload.esm.js +6 -4
- package/dist/flex.cjs.js +1 -1
- package/dist/flex.esm.js +1 -1
- package/dist/floating-toolbar.cjs.js +8 -8
- package/dist/floating-toolbar.esm.js +10 -10
- package/dist/focus-scope.cjs.js +1 -1
- package/dist/focus-scope.esm.js +1 -1
- package/dist/form.cjs.js +13 -13
- package/dist/form.esm.js +23 -13
- package/dist/gantt.cjs.js +43 -32
- package/dist/gantt.esm.js +100 -89
- package/dist/grid.cjs.js +1 -1
- package/dist/grid.esm.js +1 -1
- package/dist/hover-card.cjs.js +1 -1
- package/dist/hover-card.esm.js +1 -1
- package/dist/icon-cloud.cjs.js +4 -4
- package/dist/icon-cloud.esm.js +4 -4
- package/dist/icon.cjs.js +1 -1
- package/dist/icon.esm.js +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +121 -118
- package/dist/inline-edit.cjs.js +2 -2
- package/dist/inline-edit.esm.js +2 -2
- package/dist/input.cjs.js +14 -14
- package/dist/input.esm.js +40 -33
- package/dist/label.cjs.js +4 -4
- package/dist/label.esm.js +4 -4
- package/dist/layout.cjs.js +1 -1
- package/dist/layout.esm.js +1 -1
- package/dist/{listbox-B6QgECax.js → listbox-CTpRpuF7.js} +1 -1
- package/dist/{listbox-DJamVeFj.mjs → listbox-hMVOhKHC.mjs} +1 -1
- package/dist/listbox.cjs.js +1 -1
- package/dist/listbox.esm.js +1 -1
- package/dist/marquee.cjs.js +4 -4
- package/dist/marquee.esm.js +4 -4
- package/dist/masonry-grid.cjs.js +1 -1
- package/dist/masonry-grid.esm.js +1 -1
- package/dist/{menu-item-styles-CbNUEwP2.js → menu-item-styles-B4onAr4C.js} +3 -3
- package/dist/{menu-item-styles-CZiPwPwl.mjs → menu-item-styles-IGSFLAHu.mjs} +3 -3
- package/dist/menu.cjs.js +7 -7
- package/dist/menu.esm.js +30 -29
- package/dist/menubar.cjs.js +1 -1
- package/dist/menubar.esm.js +3 -3
- package/dist/meter.cjs.js +2 -2
- package/dist/meter.esm.js +2 -2
- package/dist/multi-select.cjs.js +17 -17
- package/dist/multi-select.esm.js +52 -44
- package/dist/navigation-menu.cjs.js +2 -2
- package/dist/navigation-menu.esm.js +2 -2
- package/dist/number-field.cjs.js +11 -13
- package/dist/number-field.esm.js +30 -28
- package/dist/number-ticker.cjs.js +5 -5
- package/dist/number-ticker.esm.js +5 -5
- package/dist/odometer.cjs.js +3 -3
- package/dist/odometer.esm.js +3 -3
- package/dist/orbiter.cjs.js +4 -4
- package/dist/orbiter.esm.js +4 -4
- package/dist/pagination.cjs.js +2 -2
- package/dist/pagination.esm.js +2 -2
- package/dist/{panel-group-CaD0_KQf.js → panel-group-BVHJEdfx.js} +1 -1
- package/dist/{panel-group-8sVNnGxg.mjs → panel-group-BxO_eNW6.mjs} +1 -1
- package/dist/panel-group.cjs.js +1 -1
- package/dist/panel-group.esm.js +1 -1
- package/dist/panel.cjs.js +1 -1
- package/dist/panel.esm.js +1 -1
- package/dist/password-field.cjs.js +23 -23
- package/dist/password-field.esm.js +48 -47
- package/dist/pin-input.cjs.js +8 -6
- package/dist/pin-input.esm.js +21 -15
- package/dist/placement-grid.cjs.js +4 -4
- package/dist/placement-grid.esm.js +58 -58
- package/dist/plugin-panel.cjs.js +2 -2
- package/dist/plugin-panel.esm.js +2 -2
- package/dist/popover.cjs.js +6 -6
- package/dist/popover.esm.js +5 -5
- package/dist/portal.cjs.js +1 -1
- package/dist/portal.esm.js +1 -1
- package/dist/positioner.cjs.js +1 -1
- package/dist/positioner.esm.js +1 -1
- package/dist/presence.cjs.js +1 -1
- package/dist/presence.esm.js +1 -1
- package/dist/primitives/control-name.d.ts +30 -0
- package/dist/primitives/control-name.d.ts.map +1 -0
- package/dist/primitives/trigger.d.ts +2 -0
- package/dist/primitives/trigger.d.ts.map +1 -0
- package/dist/progress.cjs.js +4 -4
- package/dist/progress.esm.js +20 -18
- package/dist/quick-actions.cjs.js +4 -4
- package/dist/quick-actions.esm.js +4 -4
- package/dist/radio-group.cjs.js +2 -2
- package/dist/radio-group.esm.js +2 -2
- package/dist/radio.cjs.js +3 -3
- package/dist/radio.esm.js +3 -3
- package/dist/rating.cjs.js +18 -17
- package/dist/rating.esm.js +91 -92
- package/dist/roving-focus-group.cjs.js +1 -1
- package/dist/roving-focus-group.esm.js +11 -10
- package/dist/{runtime-D1gFh1fS.mjs → runtime-CFnK53iC.mjs} +133 -94
- package/dist/runtime-DwE-tizc.js +1 -0
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.esm.js +29 -26
- package/dist/scroll-area.cjs.js +1 -1
- package/dist/scroll-area.esm.js +1 -1
- package/dist/section.cjs.js +1 -1
- package/dist/section.esm.js +1 -1
- package/dist/select.cjs.js +20 -19
- package/dist/select.esm.js +37 -33
- package/dist/selection-popup.cjs.js +3 -3
- package/dist/selection-popup.esm.js +3 -3
- package/dist/separator.cjs.js +8 -8
- package/dist/separator.esm.js +8 -8
- package/dist/sidebar.cjs.js +9 -9
- package/dist/sidebar.esm.js +16 -16
- package/dist/skeleton.cjs.js +8 -8
- package/dist/skeleton.esm.js +8 -8
- package/dist/slider.cjs.js +4 -4
- package/dist/slider.esm.js +4 -4
- package/dist/slot.cjs.js +4 -4
- package/dist/slot.esm.js +4 -4
- package/dist/sortable.cjs.js +43 -44
- package/dist/sortable.esm.js +100 -101
- package/dist/spinning-text.cjs.js +4 -4
- package/dist/spinning-text.esm.js +4 -4
- package/dist/split-button.cjs.js +1 -1
- package/dist/split-button.esm.js +2 -2
- package/dist/splitter.cjs.js +1 -1
- package/dist/splitter.esm.js +1 -1
- package/dist/stepper.cjs.js +2 -2
- package/dist/stepper.esm.js +2 -2
- package/dist/switch.cjs.js +11 -13
- package/dist/switch.esm.js +11 -13
- package/dist/table.cjs.js +10 -7
- package/dist/table.esm.js +47 -44
- package/dist/tabs.cjs.js +21 -22
- package/dist/tabs.esm.js +71 -67
- package/dist/tags-input.cjs.js +9 -9
- package/dist/tags-input.esm.js +32 -25
- package/dist/textarea.cjs.js +10 -10
- package/dist/textarea.esm.js +30 -21
- package/dist/theme.d.ts +18 -0
- package/dist/theme.d.ts.map +1 -1
- package/dist/time-field.cjs.js +5 -5
- package/dist/time-field.esm.js +21 -18
- package/dist/time-picker.cjs.js +4 -4
- package/dist/time-picker.esm.js +6 -6
- package/dist/timeline.cjs.js +3 -3
- package/dist/timeline.esm.js +5 -5
- package/dist/toast.cjs.js +7 -7
- package/dist/toast.esm.js +14 -14
- package/dist/toggle-group.cjs.js +6 -7
- package/dist/toggle-group.esm.js +64 -61
- package/dist/toggle.cjs.js +18 -18
- package/dist/toggle.esm.js +32 -31
- package/dist/toolbar.cjs.js +1 -1
- package/dist/toolbar.esm.js +1 -1
- package/dist/tooltip.cjs.js +5 -5
- package/dist/tooltip.esm.js +5 -5
- package/dist/transfer-list.cjs.js +4 -4
- package/dist/transfer-list.esm.js +4 -4
- package/dist/{tree-B3kE8ESs.mjs → tree-B_oQput6.mjs} +35 -34
- package/dist/tree-SivHxcAy.js +39 -0
- package/dist/tree-item.cjs.js +1 -1
- package/dist/tree-item.esm.js +1 -1
- package/dist/tree.cjs.js +1 -1
- package/dist/tree.esm.js +1 -1
- package/dist/trigger-BjnxLCeQ.mjs +9 -0
- package/dist/trigger-DkPsKxsP.js +1 -0
- package/dist/{ui-button-rXQOS9QJ.js → ui-button-BPrzJScZ.js} +29 -28
- package/dist/{ui-button-Q0GNNWKC.mjs → ui-button-Co8Sid6t.mjs} +70 -49
- package/dist/{ui-icon-BzVNC_lr.js → ui-icon-D3avtxX_.js} +5 -5
- package/dist/{ui-icon-YI6lyuqU.mjs → ui-icon-DLhB08Fo.mjs} +3 -3
- package/dist/visually-hidden.cjs.js +1 -1
- package/dist/visually-hidden.esm.js +1 -1
- package/dist/wizard.cjs.js +12 -13
- package/dist/wizard.esm.js +18 -16
- package/package.json +2 -2
- package/dist/ElementBase-EV6mVBUV.js +0 -1
- package/dist/runtime-CTaOSmBj.js +0 -1
- package/dist/tree-Dx_kv_ih.js +0 -39
package/dist/color-picker.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { E as q } from "./ElementBase-
|
|
2
|
-
import { r as O, e as F, l as U, i as A, s as N, c as V } from "./date-time-utils-
|
|
1
|
+
import { E as q } from "./ElementBase-BeZT54Hj.mjs";
|
|
2
|
+
import { r as O, e as F, l as U, i as A, s as N, c as V } from "./date-time-utils-BTlxnz5j.mjs";
|
|
3
3
|
function g(s, t, e) {
|
|
4
4
|
return Math.max(t, Math.min(e, s));
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function m(s, t = 3) {
|
|
7
7
|
const e = 10 ** t;
|
|
8
8
|
return Math.round(s * e) / e;
|
|
9
9
|
}
|
|
@@ -20,7 +20,7 @@ function D(s) {
|
|
|
20
20
|
const e = Number(t);
|
|
21
21
|
return Number.isFinite(e) ? g(e, 0, 1) : null;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function C(s) {
|
|
24
24
|
const t = s.trim();
|
|
25
25
|
if (!t) return null;
|
|
26
26
|
if (t.endsWith("%")) {
|
|
@@ -98,7 +98,7 @@ function G(s) {
|
|
|
98
98
|
if (!t) return null;
|
|
99
99
|
const e = T(t[1]);
|
|
100
100
|
if (!e || e.channels.length < 3) return null;
|
|
101
|
-
const r =
|
|
101
|
+
const r = C(e.channels[0]), i = C(e.channels[1]), a = C(e.channels[2]);
|
|
102
102
|
if (r == null || i == null || a == null) return null;
|
|
103
103
|
const n = e.alpha != null ? D(e.alpha) : 1;
|
|
104
104
|
return n == null ? null : b({ r, g: i, b: a, a: n });
|
|
@@ -118,7 +118,7 @@ function b(s) {
|
|
|
118
118
|
r: S(s.r),
|
|
119
119
|
g: S(s.g),
|
|
120
120
|
b: S(s.b),
|
|
121
|
-
a:
|
|
121
|
+
a: m(g(s.a, 0, 1), 4)
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
function f(s) {
|
|
@@ -131,21 +131,21 @@ function Y(s, t = !1) {
|
|
|
131
131
|
}
|
|
132
132
|
function j(s, t = !0) {
|
|
133
133
|
const e = b(s);
|
|
134
|
-
return !t || e.a >= 1 ? `rgb(${e.r} ${e.g} ${e.b})` : `rgb(${e.r} ${e.g} ${e.b} / ${
|
|
134
|
+
return !t || e.a >= 1 ? `rgb(${e.r} ${e.g} ${e.b})` : `rgb(${e.r} ${e.g} ${e.b} / ${m(e.a, 3)})`;
|
|
135
135
|
}
|
|
136
136
|
function J(s, t = !0) {
|
|
137
|
-
const e = Math.round(y(s.h)), r = Math.round(g(s.s, 0, 100)), i = Math.round(g(s.l, 0, 100)), a =
|
|
137
|
+
const e = Math.round(y(s.h)), r = Math.round(g(s.s, 0, 100)), i = Math.round(g(s.l, 0, 100)), a = m(g(s.a, 0, 1), 3);
|
|
138
138
|
return !t || a >= 1 ? `hsl(${e} ${r}% ${i}%)` : `hsl(${e} ${r}% ${i}% / ${a})`;
|
|
139
139
|
}
|
|
140
140
|
function z(s) {
|
|
141
141
|
const t = b(s), e = t.r / 255, r = t.g / 255, i = t.b / 255, a = Math.max(e, r, i), n = Math.min(e, r, i), o = a - n;
|
|
142
142
|
let l = 0;
|
|
143
143
|
o !== 0 && (a === e ? l = (r - i) / o % 6 : a === r ? l = (i - e) / o + 2 : l = (e - r) / o + 4, l *= 60, l < 0 && (l += 360));
|
|
144
|
-
const c = a === 0 ? 0 : o / a * 100,
|
|
144
|
+
const c = a === 0 ? 0 : o / a * 100, p = a * 100;
|
|
145
145
|
return {
|
|
146
|
-
h:
|
|
147
|
-
s:
|
|
148
|
-
v:
|
|
146
|
+
h: m(l, 3),
|
|
147
|
+
s: m(c, 3),
|
|
148
|
+
v: m(p, 3),
|
|
149
149
|
a: t.a
|
|
150
150
|
};
|
|
151
151
|
}
|
|
@@ -159,13 +159,13 @@ function Q(s) {
|
|
|
159
159
|
a: s.a
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
|
-
function
|
|
162
|
+
function M(s) {
|
|
163
163
|
const t = b(s), e = t.r / 255, r = t.g / 255, i = t.b / 255, a = Math.max(e, r, i), n = Math.min(e, r, i), o = a - n, l = (a + n) / 2;
|
|
164
|
-
let c = 0,
|
|
165
|
-
return o !== 0 && (
|
|
166
|
-
h:
|
|
167
|
-
s:
|
|
168
|
-
l:
|
|
164
|
+
let c = 0, p = 0;
|
|
165
|
+
return o !== 0 && (p = o / (1 - Math.abs(2 * l - 1)), a === e ? c = (r - i) / o % 6 : a === r ? c = (i - e) / o + 2 : c = (e - r) / o + 4, c *= 60, c < 0 && (c += 360)), {
|
|
166
|
+
h: m(c, 3),
|
|
167
|
+
s: m(p * 100, 3),
|
|
168
|
+
l: m(l * 100, 3),
|
|
169
169
|
a: t.a
|
|
170
170
|
};
|
|
171
171
|
}
|
|
@@ -179,16 +179,16 @@ function $(s) {
|
|
|
179
179
|
a: s.a
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
|
-
function
|
|
182
|
+
function _(s, t) {
|
|
183
183
|
return Y(s, t).toUpperCase();
|
|
184
184
|
}
|
|
185
185
|
function w(s, t) {
|
|
186
186
|
return j(s, t);
|
|
187
187
|
}
|
|
188
188
|
function Z(s, t) {
|
|
189
|
-
return J(
|
|
189
|
+
return J(M(s), t);
|
|
190
190
|
}
|
|
191
|
-
const
|
|
191
|
+
const I = "#2563eb", L = "editora:ui-color-picker:recent", tt = `
|
|
192
192
|
<svg viewBox="0 0 20 20" aria-hidden="true" focusable="false">
|
|
193
193
|
<path d="m5.6 7.6 4.4 4.6 4.4-4.6" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
|
|
194
194
|
</svg>
|
|
@@ -197,10 +197,10 @@ const C = "#2563eb", L = "editora:ui-color-picker:recent", tt = `
|
|
|
197
197
|
--ui-cp-bg: color-mix(in srgb, var(--ui-color-surface, #ffffff) 96%, transparent);
|
|
198
198
|
--ui-cp-border: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 74%, transparent);
|
|
199
199
|
--ui-cp-text: var(--ui-color-text, #0f172a);
|
|
200
|
-
--ui-cp-muted: var(--ui-color-muted, #
|
|
200
|
+
--ui-cp-muted: var(--ui-color-muted, #526175);
|
|
201
201
|
--ui-cp-accent: var(--ui-color-primary, #2563eb);
|
|
202
|
-
--ui-cp-success: var(--ui-color-success, #
|
|
203
|
-
--ui-cp-warning: var(--ui-color-warning, #
|
|
202
|
+
--ui-cp-success: var(--ui-color-success, #15803d);
|
|
203
|
+
--ui-cp-warning: var(--ui-color-warning, #b45309);
|
|
204
204
|
--ui-cp-danger: var(--ui-color-danger, #dc2626);
|
|
205
205
|
--ui-cp-radius: 14px;
|
|
206
206
|
--ui-cp-shadow: none;
|
|
@@ -509,11 +509,15 @@ const C = "#2563eb", L = "editora:ui-color-picker:recent", tt = `
|
|
|
509
509
|
}
|
|
510
510
|
|
|
511
511
|
.sv:focus-visible,
|
|
512
|
-
.slider:focus-visible {
|
|
512
|
+
.slider:focus-visible::after {
|
|
513
513
|
outline: 2px solid color-mix(in srgb, var(--ui-cp-accent) 64%, transparent);
|
|
514
514
|
outline-offset: 1px;
|
|
515
515
|
}
|
|
516
516
|
|
|
517
|
+
.slider:focus-visible {
|
|
518
|
+
outline: none;
|
|
519
|
+
}
|
|
520
|
+
|
|
517
521
|
.thumb {
|
|
518
522
|
position: absolute;
|
|
519
523
|
inline-size: 12px;
|
|
@@ -528,19 +532,35 @@ const C = "#2563eb", L = "editora:ui-color-picker:recent", tt = `
|
|
|
528
532
|
transform: translate3d(0, 0, 0);
|
|
529
533
|
}
|
|
530
534
|
|
|
535
|
+
/* The track is 12px, but the element is 24px tall (WCAG 2.5.8): the padding is the extra hit area,
|
|
536
|
+
the track is painted in the content box and the ring is drawn by ::after over just the track. */
|
|
531
537
|
.slider {
|
|
532
538
|
position: relative;
|
|
539
|
+
box-sizing: content-box;
|
|
533
540
|
block-size: 12px;
|
|
541
|
+
padding-block: 6px;
|
|
534
542
|
border-radius: 999px;
|
|
535
|
-
|
|
543
|
+
background-clip: content-box;
|
|
544
|
+
background-origin: content-box;
|
|
536
545
|
cursor: pointer;
|
|
537
546
|
touch-action: none;
|
|
538
547
|
overflow: visible;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
.slider::after {
|
|
551
|
+
content: "";
|
|
552
|
+
position: absolute;
|
|
553
|
+
inset-inline: 0;
|
|
554
|
+
inset-block: 6px;
|
|
555
|
+
box-sizing: border-box;
|
|
556
|
+
border-radius: 999px;
|
|
557
|
+
border: 1px solid color-mix(in srgb, var(--ui-cp-border) 82%, transparent);
|
|
539
558
|
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ui-cp-border) 40%, transparent);
|
|
559
|
+
pointer-events: none;
|
|
540
560
|
}
|
|
541
561
|
|
|
542
562
|
.slider.hue {
|
|
543
|
-
background: linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000);
|
|
563
|
+
background-image: linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000);
|
|
544
564
|
}
|
|
545
565
|
|
|
546
566
|
.slider.alpha {
|
|
@@ -888,7 +908,7 @@ function k(s) {
|
|
|
888
908
|
}
|
|
889
909
|
class rt extends q {
|
|
890
910
|
constructor() {
|
|
891
|
-
super(), this._syncing = !1, this._initialized = !1, this._rgba = b(f(
|
|
911
|
+
super(), this._syncing = !1, this._initialized = !1, this._rgba = b(f(I) || { r: 37, g: 99, b: 235, a: 1 }), this._hsva = z(this._rgba), this._format = "hex", this._open = !1, this._error = "", this._presets = [], this._recentColors = [], this._panelCache = /* @__PURE__ */ new WeakMap(), this._overlay = null, this._overlayRoot = null, this._releaseScrollLock = null, this._restoreFocusEl = null, this._isSheetOpen = !1, this._dragTarget = null, this._dragPointerId = -1, this._dragRect = null, this._dragX = 0, this._dragY = 0, this._dragRaf = 0, this._dragChanged = !1, this._dragSource = "drag", this._renderingSwatches = !1, this._scheduleOverlayPosition = O(() => this._positionOverlay()), this._onRootClickBound = (t) => this._onPanelClick(t, "root"), this._onRootInputBound = (t) => this._onPanelInput(t, "root"), this._onRootChangeBound = (t) => this._onPanelChange(t, "root"), this._onRootKeyDownBound = (t) => this._onPanelKeyDown(t, "root"), this._onRootPointerDownBound = (t) => this._onPanelPointerDown(t, "root"), this._onRootPointerMoveBound = (t) => this._onPanelPointerMove(t), this._onRootPointerUpBound = (t) => this._onPanelPointerUp(t), this._onRootPointerCancelBound = (t) => this._onPanelPointerCancel(t), this._onDocumentPointerDownBound = (t) => this._onDocumentPointerDown(t), this._onDocumentKeyDownBound = (t) => this._onDocumentKeyDown(t), this._onWindowResizeBound = () => this._scheduleOverlayPosition.run(), this._onWindowScrollBound = (t) => {
|
|
892
912
|
F(t, [this._overlay]) || this._scheduleOverlayPosition.run();
|
|
893
913
|
}, this._applyValueAttribute(!1), this._applyFormatAttribute(), this._open = this.hasAttribute("open"), this._parsePresetsAttribute();
|
|
894
914
|
}
|
|
@@ -984,7 +1004,7 @@ class rt extends q {
|
|
|
984
1004
|
getColor() {
|
|
985
1005
|
const t = b(this._rgba);
|
|
986
1006
|
return {
|
|
987
|
-
hex:
|
|
1007
|
+
hex: _(t, this._alphaEnabled()),
|
|
988
1008
|
rgba: t,
|
|
989
1009
|
hsva: { ...this._hsva }
|
|
990
1010
|
};
|
|
@@ -1198,7 +1218,7 @@ class rt extends q {
|
|
|
1198
1218
|
_applyValueAttribute(t) {
|
|
1199
1219
|
const e = this.getAttribute("value");
|
|
1200
1220
|
if (!e) {
|
|
1201
|
-
this._applyRgba(f(
|
|
1221
|
+
this._applyRgba(f(I) || this._rgba, !1);
|
|
1202
1222
|
return;
|
|
1203
1223
|
}
|
|
1204
1224
|
const r = f(e);
|
|
@@ -1225,7 +1245,7 @@ class rt extends q {
|
|
|
1225
1245
|
if (typeof i != "string") continue;
|
|
1226
1246
|
const a = f(i);
|
|
1227
1247
|
if (!a) continue;
|
|
1228
|
-
const n =
|
|
1248
|
+
const n = _(this._normalizeByAlpha(a), this._alphaEnabled());
|
|
1229
1249
|
r.includes(n) || r.push(n);
|
|
1230
1250
|
}
|
|
1231
1251
|
this._presets = r;
|
|
@@ -1244,7 +1264,7 @@ class rt extends q {
|
|
|
1244
1264
|
if (!t) return;
|
|
1245
1265
|
const e = JSON.parse(t);
|
|
1246
1266
|
if (!Array.isArray(e)) return;
|
|
1247
|
-
this._recentColors = e.filter((r) => typeof r == "string").map((r) => f(r)).filter((r) => !!r).map((r) =>
|
|
1267
|
+
this._recentColors = e.filter((r) => typeof r == "string").map((r) => f(r)).filter((r) => !!r).map((r) => _(this._normalizeByAlpha(r), this._alphaEnabled())).slice(0, this._maxRecent());
|
|
1248
1268
|
} catch {
|
|
1249
1269
|
this._recentColors = [];
|
|
1250
1270
|
}
|
|
@@ -1269,17 +1289,17 @@ class rt extends q {
|
|
|
1269
1289
|
};
|
|
1270
1290
|
}
|
|
1271
1291
|
_serializeValue(t = this._format) {
|
|
1272
|
-
return t === "rgb" ? w(this._rgba, this._alphaEnabled()) : t === "hsl" ? Z(this._rgba, this._alphaEnabled()) :
|
|
1292
|
+
return t === "rgb" ? w(this._rgba, this._alphaEnabled()) : t === "hsl" ? Z(this._rgba, this._alphaEnabled()) : _(this._rgba, this._alphaEnabled());
|
|
1273
1293
|
}
|
|
1274
1294
|
_currentHex() {
|
|
1275
|
-
return
|
|
1295
|
+
return _(this._rgba, this._alphaEnabled());
|
|
1276
1296
|
}
|
|
1277
1297
|
_eventDetail(t) {
|
|
1278
1298
|
return {
|
|
1279
1299
|
value: this._serializeValue(),
|
|
1280
1300
|
hex: this._currentHex(),
|
|
1281
1301
|
rgba: { ...this._rgba },
|
|
1282
|
-
hsla:
|
|
1302
|
+
hsla: M(this._rgba),
|
|
1283
1303
|
source: t
|
|
1284
1304
|
};
|
|
1285
1305
|
}
|
|
@@ -1459,18 +1479,18 @@ class rt extends q {
|
|
|
1459
1479
|
return this._isPopoverMode() && this._open && this._overlayRoot ? this._overlayRoot.querySelector('[data-cp-panel="overlay"]') : this.root.querySelector('[data-cp-panel="inline"]');
|
|
1460
1480
|
}
|
|
1461
1481
|
_updateUI(t, e = !1) {
|
|
1462
|
-
const r = this.root.querySelector('[data-role="trigger-wrap"]'), i = this.root.querySelector(".trigger"), a = this.root.querySelector('[data-role="trigger-value"]'), n = this.root.querySelector('[data-role="trigger-preview"]'), o = this.root.querySelector('[data-role="inline-panel"]'), l = this._isPopoverMode(), c = this._state(),
|
|
1463
|
-
r && (r.hidden = !l), i && (i.disabled = h || v, i.dataset.state = c, i.dataset.tone =
|
|
1482
|
+
const r = this.root.querySelector('[data-role="trigger-wrap"]'), i = this.root.querySelector(".trigger"), a = this.root.querySelector('[data-role="trigger-value"]'), n = this.root.querySelector('[data-role="trigger-preview"]'), o = this.root.querySelector('[data-role="inline-panel"]'), l = this._isPopoverMode(), c = this._state(), p = this._tone(), v = c === "loading", h = this._isDisabled(), x = this._isReadonly(), R = this._serializeValue() || this._placeholder();
|
|
1483
|
+
r && (r.hidden = !l), i && (i.disabled = h || v, i.dataset.state = c, i.dataset.tone = p, i.setAttribute("aria-expanded", l && this._open ? "true" : "false"), this._applyAria(i, R)), a && (a.textContent = R), n && (n.style.background = w(this._rgba, !0)), o && (o.hidden = l), this._forEachPanel((d) => this._updatePanel(d, { skipSwatches: t, disabled: h, readonly: x, loading: v, state: c, tone: p, modePopover: l, liveOnly: e }));
|
|
1464
1484
|
}
|
|
1465
1485
|
_updatePanel(t, e) {
|
|
1466
|
-
const r = this._rgba, i =
|
|
1486
|
+
const r = this._rgba, i = M(r), a = this._hsva, n = `hsl(${Math.round(a.h)} 100% 50%)`, o = t.panel.getAttribute("data-cp-panel") === "overlay", l = !!this._error || e.state === "error", c = e.disabled || e.readonly || e.loading;
|
|
1467
1487
|
if (this._applyAria(t.panel), t.panel.dataset.state = l ? "error" : e.state, t.panel.dataset.tone = e.tone, t.panel.setAttribute("aria-busy", e.loading ? "true" : "false"), o && e.modePopover ? (t.panel.setAttribute("role", "dialog"), t.panel.setAttribute("aria-modal", "true"), t.panel.tabIndex = -1) : (t.panel.removeAttribute("role"), t.panel.removeAttribute("aria-modal"), t.panel.removeAttribute("tabindex")), t.label && (t.label.textContent = this._labelText()), t.valueText && (t.valueText.textContent = this._serializeValue()), t.preview && (t.preview.style.background = w(r, !0)), t.status) {
|
|
1468
|
-
let
|
|
1469
|
-
l ?
|
|
1488
|
+
let d = "";
|
|
1489
|
+
l ? d = "Error" : e.state === "loading" ? d = "Syncing" : e.state === "success" && (d = "Saved"), t.status.hidden = !d, t.status.textContent = d, t.status.dataset.tone = e.tone;
|
|
1470
1490
|
}
|
|
1471
1491
|
if (t.sv && (t.sv.style.background = `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, ${n})`, t.sv.setAttribute("aria-valuetext", `Saturation ${Math.round(a.s)}%, Value ${Math.round(a.v)}%`), t.sv.setAttribute("aria-disabled", c ? "true" : "false"), t.sv.tabIndex = c ? -1 : 0), t.svThumb) {
|
|
1472
|
-
const
|
|
1473
|
-
t.svThumb.style.left = `${
|
|
1492
|
+
const d = u(a.s, 1, 99), P = u(100 - a.v, 1, 99);
|
|
1493
|
+
t.svThumb.style.left = `${d}%`, t.svThumb.style.top = `${P}%`;
|
|
1474
1494
|
}
|
|
1475
1495
|
t.hue && (t.hue.setAttribute("aria-valuemin", "0"), t.hue.setAttribute("aria-valuemax", "360"), t.hue.setAttribute("aria-valuenow", String(Math.round(a.h))), t.hue.setAttribute("aria-disabled", c ? "true" : "false"), t.hue.tabIndex = c ? -1 : 0), t.hueThumb && (t.hueThumb.style.left = `${u(a.h / 360 * 100, 1, 99)}%`), t.alphaRow && (t.alphaRow.hidden = !this._alphaEnabled()), t.alpha && (t.alpha.setAttribute("aria-valuemin", "0"), t.alpha.setAttribute("aria-valuemax", "100"), t.alpha.setAttribute("aria-valuenow", String(Math.round(a.a * 100))), t.alpha.setAttribute("aria-disabled", c || !this._alphaEnabled() ? "true" : "false"), t.alpha.tabIndex = c ? -1 : 0, t.alpha.style.backgroundImage = `
|
|
1476
1496
|
linear-gradient(45deg, var(--ui-cp-checker-a) 25%, transparent 25%),
|
|
@@ -1479,20 +1499,20 @@ class rt extends q {
|
|
|
1479
1499
|
linear-gradient(-45deg, transparent 75%, var(--ui-cp-checker-a) 75%),
|
|
1480
1500
|
linear-gradient(to right, rgba(${r.r}, ${r.g}, ${r.b}, 0), rgba(${r.r}, ${r.g}, ${r.b}, 1))
|
|
1481
1501
|
`), t.alphaThumb && (t.alphaThumb.style.left = `${u(a.a * 100, 1, 99)}%`);
|
|
1482
|
-
const
|
|
1483
|
-
if (t.inputHex && h !== "hex" && (t.inputHex.value =
|
|
1502
|
+
const p = t.panel.getRootNode(), v = p instanceof ShadowRoot ? p.activeElement : t.panel.ownerDocument.activeElement, h = v && t.panel.contains(v) ? v.getAttribute("data-input") : null;
|
|
1503
|
+
if (t.inputHex && h !== "hex" && (t.inputHex.value = _(r, this._alphaEnabled())), t.inputR && h !== "r" && (t.inputR.value = String(r.r)), t.inputG && h !== "g" && (t.inputG.value = String(r.g)), t.inputB && h !== "b" && (t.inputB.value = String(r.b)), t.inputA1 && h !== "a1" && (t.inputA1.value = this._alphaEnabled() ? String(Number(r.a.toFixed(3))) : "1"), t.inputH && h !== "h" && (t.inputH.value = String(Math.round(i.h))), t.inputS && h !== "s" && (t.inputS.value = String(Math.round(i.s))), t.inputL && h !== "l" && (t.inputL.value = String(Math.round(i.l))), t.inputA2 && h !== "a2" && (t.inputA2.value = this._alphaEnabled() ? String(Number(r.a.toFixed(3))) : "1"), e.liveOnly) return;
|
|
1484
1504
|
if (t.tabHex && (t.tabHex.dataset.active = String(this._format === "hex")), t.tabRgb && (t.tabRgb.dataset.active = String(this._format === "rgb")), t.tabHsl && (t.tabHsl.dataset.active = String(this._format === "hsl")), t.groupHex && (t.groupHex.hidden = this._format !== "hex"), t.groupRgb && (t.groupRgb.hidden = this._format !== "rgb"), t.groupHsl && (t.groupHsl.hidden = this._format !== "hsl"), t.inputA1 && (t.inputA1.disabled = !this._alphaEnabled() || c), t.inputA2 && (t.inputA2.disabled = !this._alphaEnabled() || c), t.error) {
|
|
1485
|
-
const
|
|
1486
|
-
t.error.hidden = !
|
|
1505
|
+
const d = this._error || (e.state === "error" ? "Unable to validate current color value." : "");
|
|
1506
|
+
t.error.hidden = !d, t.error.textContent = d;
|
|
1487
1507
|
}
|
|
1488
1508
|
const x = c;
|
|
1489
1509
|
if (t.copyHex && (t.copyHex.disabled = e.disabled || e.loading), t.copyRgb && (t.copyRgb.disabled = e.disabled || e.loading), t.eyedropper) {
|
|
1490
|
-
const
|
|
1491
|
-
t.eyedropper.hidden = !
|
|
1510
|
+
const d = typeof window < "u" && typeof window.EyeDropper == "function";
|
|
1511
|
+
t.eyedropper.hidden = !d, t.eyedropper.disabled = x || !d;
|
|
1492
1512
|
}
|
|
1493
|
-
if (t.clear && (t.clear.disabled = x), t.apply && (t.apply.hidden = !e.modePopover, t.apply.disabled = x), t.panel.querySelectorAll(".input").forEach((
|
|
1494
|
-
const
|
|
1495
|
-
|
|
1513
|
+
if (t.clear && (t.clear.disabled = x), t.apply && (t.apply.hidden = !e.modePopover, t.apply.disabled = x), t.panel.querySelectorAll(".input").forEach((d) => {
|
|
1514
|
+
const P = d;
|
|
1515
|
+
P.disabled = x;
|
|
1496
1516
|
}), !e.skipSwatches && !this._renderingSwatches) {
|
|
1497
1517
|
this._renderingSwatches = !0;
|
|
1498
1518
|
try {
|
|
@@ -1507,12 +1527,12 @@ class rt extends q {
|
|
|
1507
1527
|
t.presets && (t.presets.innerHTML = this._presets.map((r) => {
|
|
1508
1528
|
const i = f(r);
|
|
1509
1529
|
if (!i) return "";
|
|
1510
|
-
const a =
|
|
1530
|
+
const a = _(this._normalizeByAlpha(i), this._alphaEnabled()), n = a.toLowerCase() === e ? ' data-selected="true"' : "";
|
|
1511
1531
|
return `<button type="button" class="swatch" part="swatch" data-action="preset" data-color="${k(a)}"${n} title="${k(a)}" style="background:${k(w(i, !0))}"></button>`;
|
|
1512
1532
|
}).join("")), t.recentTitle && (t.recentTitle.hidden = !this._recentEnabled() || this._recentColors.length === 0), t.recent && (t.recent.hidden = !this._recentEnabled() || this._recentColors.length === 0, t.recent.innerHTML = this._recentColors.map((r) => {
|
|
1513
1533
|
const i = f(r);
|
|
1514
1534
|
if (!i) return "";
|
|
1515
|
-
const a =
|
|
1535
|
+
const a = _(this._normalizeByAlpha(i), this._alphaEnabled()), n = a.toLowerCase() === e ? ' data-selected="true"' : "";
|
|
1516
1536
|
return `<button type="button" class="swatch" part="swatch recent" data-action="recent" data-color="${k(a)}"${n} title="${k(a)}" style="background:${k(w(i, !0))}"></button>`;
|
|
1517
1537
|
}).join(""));
|
|
1518
1538
|
}
|
|
@@ -1552,7 +1572,7 @@ class rt extends q {
|
|
|
1552
1572
|
}
|
|
1553
1573
|
if (a === "clear") {
|
|
1554
1574
|
if (this._isReadonly()) return;
|
|
1555
|
-
const n = f(
|
|
1575
|
+
const n = f(I);
|
|
1556
1576
|
n && (this._applyRgba(n, !1), this._error = "", this._syncValueAttribute(), this._emitInput("text"), this._emitChange("text"), this._pushRecent(this._currentHex()), this._updateUI(!1));
|
|
1557
1577
|
return;
|
|
1558
1578
|
}
|
|
@@ -1629,12 +1649,12 @@ class rt extends q {
|
|
|
1629
1649
|
if (!t) return null;
|
|
1630
1650
|
const e = this._panelRefs(t);
|
|
1631
1651
|
if (this._format === "hex") {
|
|
1632
|
-
const l = e.inputHex?.value || "", c = l.trim().startsWith("#") ? l.trim() : `#${l.trim()}`,
|
|
1633
|
-
return
|
|
1652
|
+
const l = e.inputHex?.value || "", c = l.trim().startsWith("#") ? l.trim() : `#${l.trim()}`, p = f(c);
|
|
1653
|
+
return p ? this._normalizeByAlpha(p) : null;
|
|
1634
1654
|
}
|
|
1635
1655
|
if (this._format === "rgb") {
|
|
1636
|
-
const l = Number(e.inputR?.value ?? ""), c = Number(e.inputG?.value ?? ""),
|
|
1637
|
-
return [l, c,
|
|
1656
|
+
const l = Number(e.inputR?.value ?? ""), c = Number(e.inputG?.value ?? ""), p = Number(e.inputB?.value ?? ""), v = this._alphaEnabled() ? Number(e.inputA1?.value ?? "") : 1;
|
|
1657
|
+
return [l, c, p, v].every((h) => Number.isFinite(h)) ? this._normalizeByAlpha({ r: l, g: c, b: p, a: v }) : null;
|
|
1638
1658
|
}
|
|
1639
1659
|
const r = Number(e.inputH?.value ?? ""), i = Number(e.inputS?.value ?? ""), a = Number(e.inputL?.value ?? ""), n = this._alphaEnabled() ? Number(e.inputA2?.value ?? "") : 1;
|
|
1640
1660
|
if (![r, i, a, n].every((l) => Number.isFinite(l))) return null;
|
|
@@ -1744,12 +1764,14 @@ class rt extends q {
|
|
|
1744
1764
|
else
|
|
1745
1765
|
this.dispatchEvent(new CustomEvent("toast", { detail: { message: r }, bubbles: !0, composed: !0 }));
|
|
1746
1766
|
}
|
|
1747
|
-
_applyAria(t) {
|
|
1748
|
-
const
|
|
1749
|
-
|
|
1767
|
+
_applyAria(t, e = "") {
|
|
1768
|
+
const r = this.getAttribute("aria-labelledby"), i = this.getAttribute("aria-describedby"), a = this.getAttribute("aria-label"), n = this.getRootNode(), o = r ? r.split(/\s+/).map((p) => n.getElementById?.(p)?.textContent?.trim() || "").filter(Boolean).join(" ") : "";
|
|
1769
|
+
t.removeAttribute("aria-labelledby"), i ? t.setAttribute("aria-describedby", i) : t.removeAttribute("aria-describedby");
|
|
1770
|
+
const l = o || a || "Color picker", c = e && !l.includes(e) ? `${l}, ${e}` : l;
|
|
1771
|
+
t.setAttribute("aria-label", c);
|
|
1750
1772
|
}
|
|
1751
1773
|
}
|
|
1752
|
-
customElements.get("ui-color-picker")
|
|
1774
|
+
typeof customElements < "u" && !customElements.get("ui-color-picker") && customElements.define("ui-color-picker", rt);
|
|
1753
1775
|
export {
|
|
1754
1776
|
rt as UIColorPicker
|
|
1755
1777
|
};
|
package/dist/combobox.cjs.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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 L=require("./ElementBase-DxbvhLJs.js"),F=require("./control-name-BmoI1m3a.js"),h=require("./collection-qv8A8rq4.js"),$=require("./dismissable-layer-DNfrKA20.js"),E=require("./listbox-CTpRpuF7.js"),D=`
|
|
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
|
+
`,I=`
|
|
6
6
|
<svg viewBox="0 0 20 20" aria-hidden="true" focusable="false">
|
|
7
7
|
<path d="m5.6 7.6 4.4 4.6 4.4-4.6" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
|
|
8
8
|
</svg>
|
|
9
|
-
`,
|
|
9
|
+
`,B=`
|
|
10
10
|
:host {
|
|
11
11
|
--ui-combobox-width: var(--ui-width, 100%);
|
|
12
12
|
--ui-combobox-min-width: 248px;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
--ui-combobox-radius: var(--ui-radius, 12px);
|
|
16
16
|
--ui-combobox-bg: color-mix(in srgb, var(--ui-color-surface, #ffffff) 96%, transparent);
|
|
17
17
|
--ui-combobox-text: var(--ui-color-text, #0f172a);
|
|
18
|
-
--ui-combobox-muted: var(--ui-color-muted, #
|
|
18
|
+
--ui-combobox-muted: var(--ui-color-muted, #526175);
|
|
19
19
|
--ui-combobox-border-color: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 78%, transparent);
|
|
20
20
|
--ui-combobox-border: 1px solid var(--ui-combobox-border-color);
|
|
21
21
|
--ui-combobox-shadow: none;
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
--ui-combobox-option-hover: color-mix(in srgb, var(--ui-color-primary, #2563eb) 11%, transparent);
|
|
30
30
|
--ui-combobox-option-active: color-mix(in srgb, var(--ui-color-primary, #2563eb) 18%, transparent);
|
|
31
31
|
--ui-combobox-error: var(--ui-color-danger, #dc2626);
|
|
32
|
-
--ui-combobox-success: var(--ui-color-success, #
|
|
33
|
-
--ui-combobox-warning: var(--ui-color-warning, #
|
|
32
|
+
--ui-combobox-success: var(--ui-color-success, #15803d);
|
|
33
|
+
--ui-combobox-warning: var(--ui-color-warning, #b45309);
|
|
34
34
|
--ui-combobox-duration: 150ms;
|
|
35
35
|
--ui-combobox-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
36
36
|
|
|
@@ -65,7 +65,8 @@
|
|
|
65
65
|
.root {
|
|
66
66
|
position: relative;
|
|
67
67
|
width: var(--ui-combobox-width);
|
|
68
|
-
|
|
68
|
+
/* The host already clamps its minimum to its container; the control inside has to as well. */
|
|
69
|
+
min-width: min(100%, var(--ui-combobox-min-width));
|
|
69
70
|
max-width: 100%;
|
|
70
71
|
}
|
|
71
72
|
|
|
@@ -467,7 +468,7 @@
|
|
|
467
468
|
color: HighlightText;
|
|
468
469
|
}
|
|
469
470
|
}
|
|
470
|
-
`;function
|
|
471
|
+
`;function n(d){return d.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function _(d){if(d==null)return!1;const t=String(d).toLowerCase();return t!=="false"&&t!=="0"}class k extends L.ElementBase{constructor(){super(),this._input=null,this._control=null,this._panel=null,this._clearBtn=null,this._toggleBtn=null,this._options=[],this._filtered=[],this._highlightedIndex=-1,this._query="",this._debounceTimer=null,this._observer=null,this._uid=Math.random().toString(36).slice(2,8),this._formUnregister=null,this._isFocused=!1,this._suppressValueSync=!1,this._globalListenersBound=!1,this._dismissableLayer=null,this._nextOpenSource="attribute",this._optionsRefreshFrame=0,this._autofocusFrame=0,this._listStructureFingerprint="",this._panelPointerDown=!1,this._onInput=this._onInput.bind(this),this._onNativeChange=this._onNativeChange.bind(this),this._onFocusIn=this._onFocusIn.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onClearClick=this._onClearClick.bind(this),this._onToggleClick=this._onToggleClick.bind(this),this._onPanelPointerDown=this._onPanelPointerDown.bind(this),this._onPanelClick=this._onPanelClick.bind(this)}static get observedAttributes(){return["aria-label","aria-description","aria-describedby","value","placeholder","disabled","clearable","debounce","maxlength","readonly","autofocus","name","required","validation","state","state-text","size","variant","radius","label","description","open","headless","empty-text","no-filter","allow-custom"]}connectedCallback(){super.connectedCallback(),this._observer=new MutationObserver(()=>{this._scheduleOptionsRefresh()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","label","disabled","data-combobox-option"]}),this._attachFormRegistration()}disconnectedCallback(){this._unbindGlobalListeners(),this._detachDomListeners(),this._dismissableLayer?.destroy(),this._dismissableLayer=null,this._observer&&(this._observer.disconnect(),this._observer=null),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null),this._optionsRefreshFrame&&(cancelAnimationFrame(this._optionsRefreshFrame),this._optionsRefreshFrame=0),this._autofocusFrame&&(cancelAnimationFrame(this._autofocusFrame),this._autofocusFrame=0),this._formUnregister&&(this._formUnregister(),this._formUnregister=null),super.disconnectedCallback()}attributeChangedCallback(t,e,i){if(e!==i){if(t==="value"){this._suppressValueSync||this._syncInputFromValue(),this._updateClearButton(),this._renderList();return}if(t==="open"){this._applyOpenState(),e!==i&&this._emitOpenState(i!=null,e!=null,this._nextOpenSource),this._nextOpenSource="attribute";return}if(t==="disabled"){this._isDisabled()&&this.open&&this._setOpen(!1,"attribute"),this.isConnected&&this.requestRender();return}if(t==="state"){this.isConnected&&this.requestRender();return}if(t==="state-text"){this._renderList();return}this.isConnected&&this.requestRender()}}get value(){return this.getAttribute("value")||""}set value(t){const e=t||"";e!==this.value&&this.setAttribute("value",e)}get open(){return this.hasAttribute("open")}set open(t){this._setOpen(t,"api")}_isDisabled(){return _(this.getAttribute("disabled"))}_isReadonly(){return this.hasAttribute("readonly")}_state(){const t=(this.getAttribute("state")||"idle").trim().toLowerCase();return t==="loading"||t==="error"||t==="success"?t:"idle"}_isLoading(){return this._state()==="loading"}_stateText(){const t=this.getAttribute("state-text");if(t)return t;const e=this._state();return e==="loading"?"Syncing results":e==="error"?"Unable to load results":e==="success"?"Results up to date":""}_emitOpenState(t,e,i){const r={open:t,previousOpen:e,source:i};this.dispatchEvent(new CustomEvent(t?"open":"close",{detail:r,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(t?"ui-open":"ui-close",{detail:r,bubbles:!0,composed:!0}))}_attachFormRegistration(){try{const r=this.getRootNode().host?.closest?.("ui-form")||null||this.closest("ui-form"),s=this.getAttribute("name");r&&typeof r.registerField=="function"&&s&&(this._formUnregister=r.registerField(s,{name:s,getValue:()=>this.value,setValue:o=>{this.value=o},validate:async()=>{const o=this._isCurrentValueValid();return{valid:o,message:o?void 0:"Please select a value from the list."}},setError:o=>{o?(this.setAttribute("validation","error"),this.setAttribute("data-error",o)):(this.removeAttribute("validation"),this.removeAttribute("data-error"))}}))}catch{}}_isCurrentValueValid(){const t=this.hasAttribute("required"),e=this.value;return!t&&!e?!0:t&&!e?!1:this.hasAttribute("allow-custom")?!0:this._options.some(i=>i.value===e)}_readOptions(){const t=Array.from(this.querySelectorAll("option,[data-combobox-option]")),e=new Set;return t.map((i,r)=>{const s=i.tagName.toLowerCase()==="option",o=i,a=s?o.value||o.textContent||"":i.getAttribute("value")||i.getAttribute("data-value")||i.textContent||"",l=s?(o.label||o.textContent||o.value||"").trim():(i.getAttribute("label")||i.textContent||a).trim(),b=(i.getAttribute("description")||i.getAttribute("data-description")||"").trim(),u=s?o.disabled:_(i.getAttribute("disabled")),c=a.trim();if(!c&&!l)return null;const p=`${c}::${l}`;return e.has(p)?null:(e.add(p),{value:c,label:l,description:b,disabled:u,sourceIndex:r})}).filter(i=>!!i)}_findOptionByValue(t){return this._options.find(e=>e.value===t)||null}_findExactOptionByQuery(t){const e=h.normalizeCollectionText(t);return e&&this._options.find(i=>!i.disabled&&(h.normalizeCollectionText(i.label)===e||h.normalizeCollectionText(i.value)===e))||null}_rebuildFiltered(t){const e=h.normalizeCollectionText(this._query),i=this.hasAttribute("no-filter"),r=this._filtered[this._highlightedIndex];if(this._filtered=this._options.filter(o=>i||!e?!0:h.normalizeCollectionText(o.label).includes(e)||h.normalizeCollectionText(o.value).includes(e)),t?.preserveHighlight&&r){const o=this._filtered.findIndex(a=>a.sourceIndex===r.sourceIndex);if(o>=0&&!this._filtered[o].disabled){this._highlightedIndex=o;return}}const s=this._findOptionByValue(this.value);if(s){const o=this._filtered.findIndex(a=>a.sourceIndex===s.sourceIndex);if(o>=0&&!this._filtered[o].disabled){this._highlightedIndex=o;return}}this._highlightedIndex=E.resolveListboxActiveIndex(this._filtered,{getDisabled:o=>o.disabled})}_renderList(){if(!this._panel)return;const t=this._renderStateRow(),e=this.getAttribute("empty-text")||"No matches found",i=[t,e,this._filtered.length===0?"empty":"options",...this._filtered.map(o=>[o.sourceIndex,o.value,o.label,o.description,o.disabled?"1":"0"].join(""))].join("");if(i===this._listStructureFingerprint&&this._syncRenderedListState())return;if(this._filtered.length===0){this._panel.innerHTML=`${t}<div class="empty" part="empty">${n(e)}</div>`,this._listStructureFingerprint=i,this._panel.refresh(),this._panel.clearActive(),this._syncActiveDescendant();return}const r=this.value,s=this._filtered.map((o,a)=>{const l=o.value===r,b=a===this._highlightedIndex,u=o.disabled;return`
|
|
471
472
|
<button
|
|
472
473
|
type="button"
|
|
473
474
|
id="${`${this._uid}-option-${o.sourceIndex}`}"
|
|
@@ -475,27 +476,27 @@
|
|
|
475
476
|
role="option"
|
|
476
477
|
aria-selected="${l?"true":"false"}"
|
|
477
478
|
aria-disabled="${u?"true":"false"}"
|
|
478
|
-
data-option-index="${
|
|
479
|
+
data-option-index="${a}"
|
|
479
480
|
data-highlighted="${b?"true":"false"}"
|
|
480
481
|
data-selected="${l?"true":"false"}"
|
|
481
482
|
${u?"disabled":""}>
|
|
482
483
|
<span class="option-text">
|
|
483
|
-
<span class="option-label">${
|
|
484
|
-
${o.description?`<span class="option-description">${
|
|
484
|
+
<span class="option-label">${n(o.label)}</span>
|
|
485
|
+
${o.description?`<span class="option-description">${n(o.description)}</span>`:""}
|
|
485
486
|
</span>
|
|
486
487
|
<span class="option-check" aria-hidden="true">✓</span>
|
|
487
488
|
</button>
|
|
488
|
-
`}).join("");this._panel.innerHTML=`${t}${s}`,this._listStructureFingerprint=i,this._panel.refresh(),this._syncActiveDescendant(),this._scrollHighlightedIntoView()}_syncRenderedListState(){if(!this._panel)return!1;if(this._filtered.length===0)return this._panel.querySelector(".empty")?(this._panel.clearActive(),this._syncActiveDescendant(),!0):!1;const t=Array.from(this._panel.querySelectorAll(".option[data-option-index]"));if(t.length!==this._filtered.length)return!1;const e=this.value;return t.forEach((i,r)=>{const s=this._filtered[r];if(!s)return;const o=s.value===e,
|
|
489
|
-
${t?"":`<style>${
|
|
490
|
-
${f||
|
|
489
|
+
`}).join("");this._panel.innerHTML=`${t}${s}`,this._listStructureFingerprint=i,this._panel.refresh(),this._syncActiveDescendant(),this._scrollHighlightedIntoView()}_syncRenderedListState(){if(!this._panel)return!1;if(this._filtered.length===0)return this._panel.querySelector(".empty")?(this._panel.clearActive(),this._syncActiveDescendant(),!0):!1;const t=Array.from(this._panel.querySelectorAll(".option[data-option-index]"));if(t.length!==this._filtered.length)return!1;const e=this.value;return t.forEach((i,r)=>{const s=this._filtered[r];if(!s)return;const o=s.value===e,a=r===this._highlightedIndex;i.setAttribute("aria-selected",o?"true":"false"),i.setAttribute("aria-disabled",s.disabled?"true":"false"),i.setAttribute("data-highlighted",a?"true":"false"),i.setAttribute("data-selected",o?"true":"false"),i.disabled=s.disabled}),this._syncActiveDescendant(),this._scrollHighlightedIntoView(),!0}_renderStateRow(){const t=this._state(),e=this._stateText();return e?`<div class="status-row" part="status" data-state="${n(t)}" aria-live="polite">${n(e)}</div>`:""}_syncInputFromValue(){if(!this._input||this._isFocused&&this.open)return;const t=this._findOptionByValue(this.value);t?(this._query=t.label,this._input.value=t.label):(this._query=this.value,this._input.value=this.value),this._rebuildFiltered({preserveHighlight:!1}),this._renderList()}_syncActiveDescendant(){if(!this._input)return;const t=this._panel?.querySelector(`[data-option-index="${this._highlightedIndex}"]`);if(t&&this._panel){this._panel.setActiveItem(t,{focus:!1,owner:this._input,scroll:!1});return}this._panel?.clearActive(),this._input.removeAttribute("aria-activedescendant")}_scrollHighlightedIntoView(){if(!this._panel||this._highlightedIndex<0)return;const t=this._panel.querySelector(`[data-option-index="${this._highlightedIndex}"]`);this._panel.setActiveItem(t,{focus:!1,owner:this._input,scroll:!0})}_updateClearButton(){if(!this._clearBtn)return;this.hasAttribute("clearable")&&!this._isDisabled()&&!this._isReadonly()&&!this._isLoading()&&(this._query.length>0||this.value.length>0)?this._clearBtn.removeAttribute("hidden"):this._clearBtn.setAttribute("hidden","")}_applyOpenState(){if(!this._panel||!this._input||!this._toggleBtn)return;const t=this.open,e=this._isLoading();t?(this._bindGlobalListeners(),this._panel.setAttribute("data-open","true"),this._panel.removeAttribute("hidden"),this._panel.setAttribute("aria-hidden","false"),this._input.setAttribute("aria-expanded","true"),this._toggleBtn.setAttribute("data-open","true"),this._rebuildFiltered({preserveHighlight:!0}),this._renderList(),this._syncDismissableLayer()):(this._unbindGlobalListeners(),this._dismissableLayer?.destroy(),this._dismissableLayer=null,this._panel.setAttribute("hidden",""),this._panel.removeAttribute("data-open"),this._panel.setAttribute("aria-hidden","true"),this._input.setAttribute("aria-expanded","false"),this._toggleBtn.setAttribute("data-open","false")),this._toggleBtn.disabled=this._isDisabled(),this._clearBtn&&(this._clearBtn.disabled=this._isDisabled()||this._isReadonly()),this._input.setAttribute("aria-busy",e?"true":"false"),this._panel.setAttribute("aria-busy",e?"true":"false")}_bindGlobalListeners(){this._globalListenersBound||(this._globalListenersBound=!0)}_unbindGlobalListeners(){this._globalListenersBound&&(this._globalListenersBound=!1)}_syncDismissableLayer(){!this.open||!this._panel||(this._dismissableLayer?.destroy(),this._dismissableLayer=$.createDismissableLayer({node:this._panel,trigger:this._control,closeOnEscape:!1,closeOnPointerOutside:!0,onDismiss:t=>{t==="outside-pointer"&&(this.hasAttribute("allow-custom")?this._commitCustomValue():this._syncInputFromValue(),this._closePanel("outside"))}}))}_setOpen(t,e="api"){t!==this.open&&(t&&this._isDisabled()||(this._nextOpenSource=e,t?this.setAttribute("open",""):this.removeAttribute("open")))}_openPanel(t="api"){this._setOpen(!0,t)}_closePanel(t="api"){this._setOpen(!1,t)}_commitSelection(t){if(this._isDisabled()||this._isReadonly()||t.disabled)return;const e=this.value;this._suppressValueSync=!0,this.value=t.value,this._suppressValueSync=!1,this._input&&(this._input.value=t.label),this._query=t.label,this._rebuildFiltered({preserveHighlight:!1}),this._renderList(),this._updateClearButton(),this._closePanel("selection"),e!==t.value&&this.dispatchEvent(new CustomEvent("change",{detail:{value:t.value,label:t.label},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("select",{detail:{value:t.value,label:t.label},bubbles:!0,composed:!0}))}_commitCustomValue(){if(this._isDisabled()||this._isReadonly()||!this.hasAttribute("allow-custom"))return;const t=this._query.trim(),e=this.value;this._suppressValueSync=!0,this.value=t,this._suppressValueSync=!1,this._updateClearButton(),e!==t&&this.dispatchEvent(new CustomEvent("change",{detail:{value:t,label:t,custom:!0},bubbles:!0,composed:!0}))}_moveHighlight(t){if(this._filtered.length===0)return;const e=this._panel?.querySelector(`[data-option-index="${this._highlightedIndex}"]`),i=this._panel?.move(t>0?1:-1,{current:e,focus:!1,owner:this._input,scroll:!0})||null;if(!i)return;const r=Number(i.getAttribute("data-option-index")||"-1");r<0||(this._highlightedIndex=r,this._renderList())}render(){const t=this.hasAttribute("headless"),e=this.getAttribute("disabled"),i=_(e),r=this._isReadonly(),s=this._state(),o=s==="loading",a=this.getAttribute("placeholder")||"Search...",l=this.getAttribute("maxlength"),b=this.hasAttribute("required"),u=this.getAttribute("label")||"",c=this.getAttribute("description")||"",x=this.getAttribute("data-error")||""||(s==="error"?this._stateText()||"Unable to load options.":""),m=this.getAttribute("validation")==="error"||s==="error"||!!x,f=!!(u||this.querySelector('[slot="label"]')),g=(this.getAttribute("aria-label")||"").trim(),v=!!(c||this.querySelector('[slot="description"]')),y=`${this._uid}-error`,w=F.externalDescriptionMarkup(this,this._uid),A=[v?`${this._uid}-description`:"",m?y:"",w.id].filter(Boolean).join(" ");if(this._options=this._readOptions(),!this._query){const C=this._findOptionByValue(this.value);this._query=C?C.label:this.value}this._rebuildFiltered({preserveHighlight:!1}),this.setContent(`
|
|
490
|
+
${t?"":`<style>${B}</style>`}
|
|
491
|
+
${f||v?`
|
|
491
492
|
<div class="label-row">
|
|
492
|
-
<label class="label" part="label" id="${this._uid}-label"><slot name="label">${
|
|
493
|
-
<div class="description" part="description" id="${this._uid}-description"><slot name="description">${
|
|
493
|
+
<label class="label" part="label" id="${this._uid}-label"><slot name="label">${n(u)}</slot></label>
|
|
494
|
+
<div class="description" part="description" id="${this._uid}-description"><slot name="description">${n(c)}</slot></div>
|
|
494
495
|
</div>
|
|
495
496
|
`:""}
|
|
496
497
|
|
|
497
498
|
<div class="root" part="root">
|
|
498
|
-
<div class="control" part="control" data-focused="${this._isFocused?"true":"false"}" data-state="${
|
|
499
|
+
<div class="control" part="control" data-focused="${this._isFocused?"true":"false"}" data-state="${n(s)}">
|
|
499
500
|
<input
|
|
500
501
|
id="${this._uid}-input"
|
|
501
502
|
part="input"
|
|
@@ -504,22 +505,23 @@
|
|
|
504
505
|
aria-autocomplete="list"
|
|
505
506
|
aria-expanded="${this.open?"true":"false"}"
|
|
506
507
|
aria-controls="${this._uid}-listbox"
|
|
507
|
-
${f?`aria-labelledby="${this._uid}-label"`:""}
|
|
508
|
-
${
|
|
508
|
+
${f?`aria-labelledby="${this._uid}-label"`:g?`aria-label="${n(g)}"`:""}
|
|
509
|
+
${A?`aria-describedby="${A}"`:""}
|
|
509
510
|
${m?'aria-invalid="true"':""}
|
|
510
511
|
aria-busy="${o?"true":"false"}"
|
|
511
|
-
value="${
|
|
512
|
-
placeholder="${a
|
|
512
|
+
value="${n(this._query)}"
|
|
513
|
+
placeholder="${n(a)}"
|
|
513
514
|
${i?"disabled":""}
|
|
514
515
|
${r?"readonly":""}
|
|
515
516
|
${b?"required":""}
|
|
516
|
-
${l?`maxlength="${
|
|
517
|
+
${l?`maxlength="${n(l)}"`:""}
|
|
517
518
|
/>
|
|
518
|
-
<button type="button" part="clear" class="icon-btn clear-btn" aria-label="Clear value" hidden ${r?"disabled":""}>${
|
|
519
|
-
<button type="button" part="toggle" class="icon-btn toggle-btn" data-open="${this.open?"true":"false"}" aria-label="Toggle options">${
|
|
519
|
+
<button type="button" part="clear" class="icon-btn clear-btn" aria-label="Clear value" hidden ${r?"disabled":""}>${D}</button>
|
|
520
|
+
<button type="button" part="toggle" class="icon-btn toggle-btn" data-open="${this.open?"true":"false"}" aria-label="Toggle options">${I}</button>
|
|
520
521
|
</div>
|
|
521
|
-
<ui-listbox class="panel" id="${this._uid}-listbox" part="panel" role="listbox" item-selector=".option[data-option-index]" item-role="option" active-attribute="data-highlighted" aria-busy="${o?"true":"false"}" data-state="${
|
|
522
|
+
<ui-listbox class="panel" id="${this._uid}-listbox" part="panel" role="listbox" item-selector=".option[data-option-index]" item-role="option" active-attribute="data-highlighted" aria-busy="${o?"true":"false"}" data-state="${n(s)}" ${this.open?'data-open="true" aria-hidden="false"':'hidden aria-hidden="true"'}></ui-listbox>
|
|
522
523
|
</div>
|
|
523
524
|
<slot hidden></slot>
|
|
524
|
-
<div class="error" part="error" id="${
|
|
525
|
-
|
|
525
|
+
<div class="error" part="error" id="${y}" ${m?"":"hidden"}>${n(x)}</div>
|
|
526
|
+
${w.html}
|
|
527
|
+
`),this._detachDomListeners(),this._input=this.root.querySelector("input"),this._control=this.root.querySelector(".control"),this._panel=this.root.querySelector("ui-listbox.panel"),this._clearBtn=this.root.querySelector(".clear-btn"),this._toggleBtn=this.root.querySelector(".toggle-btn"),this._listStructureFingerprint="",this._renderList(),this._updateClearButton(),this._applyOpenState(),this._input&&(this._input.addEventListener("input",this._onInput),this._input.addEventListener("change",this._onNativeChange),this._input.addEventListener("focus",this._onFocusIn),this._input.addEventListener("blur",this._onFocusOut),this._input.addEventListener("keydown",this._onKeyDown),this.hasAttribute("autofocus")&&(this._autofocusFrame&&cancelAnimationFrame(this._autofocusFrame),this._autofocusFrame=requestAnimationFrame(()=>{this._autofocusFrame=0;try{this._input?.focus()}catch{}}))),this._clearBtn&&this._clearBtn.addEventListener("click",this._onClearClick),this._toggleBtn&&this._toggleBtn.addEventListener("click",this._onToggleClick),this._panel&&(this._panel.addEventListener("pointerdown",this._onPanelPointerDown),this._panel.addEventListener("click",this._onPanelClick))}_detachDomListeners(){this._input&&(this._input.removeEventListener("input",this._onInput),this._input.removeEventListener("change",this._onNativeChange),this._input.removeEventListener("focus",this._onFocusIn),this._input.removeEventListener("blur",this._onFocusOut),this._input.removeEventListener("keydown",this._onKeyDown)),this._clearBtn&&this._clearBtn.removeEventListener("click",this._onClearClick),this._toggleBtn&&this._toggleBtn.removeEventListener("click",this._onToggleClick),this._panel&&(this._panel.removeEventListener("pointerdown",this._onPanelPointerDown),this._panel.removeEventListener("click",this._onPanelClick))}_onInput(t){if(!this._input||this._isDisabled()||this._isReadonly())return;const e=t.target.value;this._query=e,this._openPanel("keyboard"),this._rebuildFiltered({preserveHighlight:!1}),this._renderList(),this._updateClearButton(),this.dispatchEvent(new CustomEvent("input",{detail:{query:e,value:this.value},bubbles:!0,composed:!0}));const i=Number(this.getAttribute("debounce")||0);this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null),i>0?this._debounceTimer=setTimeout(()=>{this.dispatchEvent(new CustomEvent("debounced-input",{detail:{query:e,value:this.value},bubbles:!0,composed:!0}))},i):this.dispatchEvent(new CustomEvent("debounced-input",{detail:{query:e,value:this.value},bubbles:!0,composed:!0}))}_onNativeChange(){this._isDisabled()||this._isReadonly()||this.hasAttribute("allow-custom")&&this._commitCustomValue()}_onFocusIn(){this._isFocused=!0,this._control&&this._control.setAttribute("data-focused","true"),this._isReadonly()||this._openPanel("keyboard")}_onFocusOut(){this._isFocused=!1,this._control&&this._control.setAttribute("data-focused","false"),queueMicrotask(()=>{if(this._panelPointerDown){this._panelPointerDown=!1;return}this.root.activeElement||this.open&&(this.hasAttribute("allow-custom")?this._commitCustomValue():this._syncInputFromValue(),this._closePanel("outside"))})}_refreshOptionsFromDom(){this._options=this._readOptions();const t=this._isFocused&&this.open;if(!t){const e=this._findOptionByValue(this.value),i=e?e.label:this.value;this._query=i,this._input&&(this._input.value=i)}this._rebuildFiltered({preserveHighlight:t}),this._renderList(),this._updateClearButton()}_scheduleOptionsRefresh(){this._optionsRefreshFrame||(this._optionsRefreshFrame=requestAnimationFrame(()=>{this._optionsRefreshFrame=0,this.isConnected&&this._refreshOptionsFromDom()}))}_onKeyDown(t){if(!this._isDisabled()&&this._input){if(t.key==="Home"&&this.open){t.preventDefault();const e=this._panel?.focusBoundary("first",{focus:!1,owner:this._input,scroll:!0})||null;this._highlightedIndex=Number(e?.getAttribute("data-option-index")||"-1"),this._renderList();return}if(t.key==="End"&&this.open){t.preventDefault();const e=this._panel?.focusBoundary("last",{focus:!1,owner:this._input,scroll:!0})||null;this._highlightedIndex=Number(e?.getAttribute("data-option-index")||"-1"),this._renderList();return}if(t.key==="ArrowDown"){t.preventDefault(),this._openPanel("keyboard"),this._moveHighlight(1);return}if(t.key==="ArrowUp"){t.preventDefault(),this._openPanel("keyboard"),this._moveHighlight(-1);return}if(t.key==="Enter"){if(this.open&&this._highlightedIndex>=0){t.preventDefault();const e=this._filtered[this._highlightedIndex];e&&this._commitSelection(e)}else if(this.hasAttribute("allow-custom"))t.preventDefault(),this._commitCustomValue(),this._closePanel("keyboard");else if(this.open)t.preventDefault(),this._syncInputFromValue(),this._closePanel("keyboard");else{const e=this._findExactOptionByQuery(this._query);e&&(t.preventDefault(),this._commitSelection(e))}return}if(t.key==="Escape"){this.open&&(t.preventDefault(),this.hasAttribute("allow-custom")||this._syncInputFromValue(),this._closePanel("keyboard"));return}t.key==="Tab"&&(this.hasAttribute("allow-custom")?this._commitCustomValue():this._syncInputFromValue(),this._closePanel("keyboard"))}}_onClearClick(t){t.preventDefault(),this._input&&(this._isDisabled()||this._isReadonly()||(this._query="",this._input.value="",this._suppressValueSync=!0,this.value="",this._suppressValueSync=!1,this._rebuildFiltered({preserveHighlight:!1}),this._renderList(),this._updateClearButton(),this._openPanel("clear"),this.dispatchEvent(new CustomEvent("clear",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("input",{detail:{query:"",value:""},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:"",label:""},bubbles:!0,composed:!0}))))}_onToggleClick(t){t.preventDefault(),!this._isDisabled()&&(this.open?this._closePanel("toggle"):this._openPanel("toggle"),this._input?.focus())}_onPanelPointerDown(t){this._isReadonly()||!t.target?.closest("[data-option-index]")||(this._panelPointerDown=!0,t.preventDefault())}_onPanelClick(t){if(this._isReadonly())return;const i=t.target.closest("[data-option-index]");if(!i)return;const r=i.getAttribute("data-option-index"),s=r==null?-1:Number(r);if(!Number.isFinite(s)||s<0)return;const o=this._filtered[s];!o||o.disabled||this._commitSelection(o)}}typeof customElements<"u"&&!customElements.get("ui-combobox")&&customElements.define("ui-combobox",k);exports.UICombobox=k;
|