@editora/ui-core 0.1.10 → 0.1.13
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 +5 -5
- package/dist/alert-dialog.cjs.js +18 -18
- package/dist/alert-dialog.esm.js +130 -117
- package/dist/app-header.cjs.js +22 -2
- package/dist/app-header.esm.js +22 -2
- package/dist/badge.cjs.js +5 -5
- package/dist/badge.esm.js +9 -8
- package/dist/color-picker.cjs.js +4 -4
- package/dist/color-picker.esm.js +39 -31
- package/dist/combobox.cjs.js +21 -21
- package/dist/combobox.esm.js +79 -40
- package/dist/command-palette.cjs.js +1 -1
- package/dist/command-palette.esm.js +2 -2
- package/dist/components/date-time-utils.d.ts +2 -1
- package/dist/components/date-time-utils.d.ts.map +1 -1
- package/dist/components/ui-alert-dialog.d.ts +2 -0
- package/dist/components/ui-alert-dialog.d.ts.map +1 -1
- package/dist/components/ui-app-header.d.ts.map +1 -1
- package/dist/components/ui-badge.d.ts.map +1 -1
- package/dist/components/ui-color-picker.d.ts.map +1 -1
- package/dist/components/ui-combobox.d.ts +4 -1
- package/dist/components/ui-combobox.d.ts.map +1 -1
- package/dist/components/ui-date-picker.d.ts +3 -0
- package/dist/components/ui-date-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-picker.d.ts +3 -0
- package/dist/components/ui-date-range-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-time-picker.d.ts +3 -0
- package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
- package/dist/components/ui-date-time-picker.d.ts +3 -0
- package/dist/components/ui-date-time-picker.d.ts.map +1 -1
- package/dist/components/ui-dialog.d.ts +3 -0
- package/dist/components/ui-dialog.d.ts.map +1 -1
- package/dist/components/ui-drawer.d.ts +14 -0
- package/dist/components/ui-drawer.d.ts.map +1 -1
- package/dist/components/ui-floating-toolbar.d.ts.map +1 -1
- package/dist/components/ui-icon.d.ts.map +1 -1
- package/dist/components/ui-menu.d.ts +1 -0
- package/dist/components/ui-menu.d.ts.map +1 -1
- package/dist/components/ui-menubar.d.ts +1 -0
- package/dist/components/ui-menubar.d.ts.map +1 -1
- package/dist/components/ui-quick-actions.d.ts.map +1 -1
- package/dist/components/ui-radio.d.ts +47 -0
- package/dist/components/ui-radio.d.ts.map +1 -0
- package/dist/components/ui-select.d.ts +8 -0
- package/dist/components/ui-select.d.ts.map +1 -1
- package/dist/components/ui-selection-popup.d.ts.map +1 -1
- package/dist/components/ui-split-button.d.ts +2 -0
- package/dist/components/ui-split-button.d.ts.map +1 -1
- package/dist/components/ui-stepper.d.ts.map +1 -1
- package/dist/components/ui-time-picker.d.ts +3 -0
- package/dist/components/ui-time-picker.d.ts.map +1 -1
- package/dist/context-menu.cjs.js +2 -2
- package/dist/context-menu.esm.js +2 -2
- package/dist/date-field.cjs.js +1 -1
- package/dist/date-field.esm.js +2 -2
- package/dist/date-picker.cjs.js +13 -13
- package/dist/date-picker.esm.js +100 -67
- package/dist/date-range-picker.cjs.js +14 -14
- package/dist/date-range-picker.esm.js +98 -65
- package/dist/date-range-time-picker.cjs.js +13 -13
- package/dist/date-range-time-picker.esm.js +76 -45
- package/dist/date-time-picker.cjs.js +13 -13
- package/dist/date-time-picker.esm.js +132 -101
- package/dist/date-time-utils-378ecc21.js +1 -0
- package/dist/{date-time-utils-bdceb7af.mjs → date-time-utils-a8b17ea7.mjs} +128 -102
- package/dist/dialog.cjs.js +29 -20
- package/dist/dialog.esm.js +90 -70
- package/dist/drawer.cjs.js +16 -16
- package/dist/drawer.esm.js +216 -98
- package/dist/floating-toolbar.cjs.js +3 -13
- package/dist/floating-toolbar.esm.js +17 -27
- package/dist/hover-card.cjs.js +1 -1
- package/dist/hover-card.esm.js +1 -1
- package/dist/{icon-eaa486b3.js → icon-9e9da03b.js} +4 -4
- package/dist/{icon-9ed13093.mjs → icon-e2a85cc1.mjs} +22 -18
- package/dist/icon.cjs.js +1 -1
- package/dist/icon.esm.js +1 -1
- package/dist/icons.d.ts +1 -1
- package/dist/icons.d.ts.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +246 -244
- package/dist/menu.cjs.js +2 -2
- package/dist/menu.esm.js +118 -110
- package/dist/menubar.cjs.js +5 -5
- package/dist/menubar.esm.js +83 -78
- package/dist/{overlayManager-ece06517.js → overlayManager-0eda4e08.js} +1 -1
- package/dist/{overlayManager-86454af7.mjs → overlayManager-5bbd4dc3.mjs} +1 -1
- package/dist/popover.cjs.js +1 -1
- package/dist/popover.esm.js +2 -2
- package/dist/{portal-1cf392ca.mjs → portal-9060f7a6.mjs} +7 -7
- package/dist/portal-d9bae456.js +1 -0
- package/dist/{positioner-fbd61bf1.mjs → positioner-16f3cca1.mjs} +16 -16
- package/dist/positioner-43b1c75a.js +1 -0
- package/dist/positioner.cjs.js +1 -1
- package/dist/positioner.esm.js +1 -1
- package/dist/quick-actions.cjs.js +10 -4
- package/dist/quick-actions.esm.js +27 -21
- package/dist/radio.cjs.js +259 -0
- package/dist/radio.esm.js +455 -0
- package/dist/{runtime-5f282bc8.js → runtime-668914fe.js} +1 -1
- package/dist/{runtime-4ac0107b.mjs → runtime-864efe2f.mjs} +1 -1
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.esm.js +2 -2
- package/dist/scroll-lock-31da444f.mjs +56 -0
- package/dist/scroll-lock-d7b0df21.js +1 -0
- package/dist/scroll-lock.d.ts.map +1 -1
- package/dist/select.cjs.js +14 -15
- package/dist/select.esm.js +117 -97
- package/dist/selection-popup.cjs.js +4 -7
- package/dist/selection-popup.esm.js +8 -11
- package/dist/split-button.cjs.js +137 -62
- package/dist/split-button.esm.js +235 -145
- package/dist/standalone/radio.d.ts +2 -0
- package/dist/standalone/radio.d.ts.map +1 -0
- package/dist/stepper.cjs.js +19 -50
- package/dist/stepper.esm.js +17 -48
- package/dist/time-field.cjs.js +1 -1
- package/dist/time-field.esm.js +14 -14
- package/dist/time-picker.cjs.js +15 -15
- package/dist/time-picker.esm.js +99 -68
- package/dist/tooltip.cjs.js +1 -1
- package/dist/tooltip.esm.js +1 -1
- package/package.json +2 -2
- package/dist/date-time-utils-5cf58cd0.js +0 -1
- package/dist/portal-d8d7fbca.js +0 -1
- package/dist/positioner-accc6e5f.js +0 -1
- package/dist/scroll-lock-48793569.js +0 -1
- package/dist/scroll-lock-9de6d328.mjs +0 -53
package/dist/color-picker.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { E as V } from "./ElementBase-909688f3.mjs";
|
|
2
|
-
import { r as W,
|
|
2
|
+
import { r as W, e as K, l as G, i as I, s as X, c as Y } from "./date-time-utils-a8b17ea7.mjs";
|
|
3
3
|
import "./calendar-2c11b824.mjs";
|
|
4
|
-
import "./scroll-lock-
|
|
4
|
+
import "./scroll-lock-31da444f.mjs";
|
|
5
5
|
function g(s, t, e) {
|
|
6
6
|
return Math.max(t, Math.min(e, s));
|
|
7
7
|
}
|
|
@@ -41,7 +41,7 @@ function H(s) {
|
|
|
41
41
|
const e = Number(t.slice(0, -1));
|
|
42
42
|
return Number.isFinite(e) ? g(e, 0, 100) : null;
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function j(s) {
|
|
45
45
|
const t = s.trim().toLowerCase();
|
|
46
46
|
if (!t)
|
|
47
47
|
return null;
|
|
@@ -91,7 +91,7 @@ function F(s) {
|
|
|
91
91
|
alpha: e[3] ?? null
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function J(s) {
|
|
95
95
|
const t = s.trim().replace(/^#/, "");
|
|
96
96
|
if (![3, 4, 6, 8].includes(t.length) || !/^[0-9a-f]+$/i.test(t))
|
|
97
97
|
return null;
|
|
@@ -102,7 +102,7 @@ function j(s) {
|
|
|
102
102
|
const e = parseInt(t.slice(0, 2), 16), r = parseInt(t.slice(2, 4), 16), i = parseInt(t.slice(4, 6), 16), a = t.length === 8 ? parseInt(t.slice(6, 8), 16) / 255 : 1;
|
|
103
103
|
return h({ r: e, g: r, b: i, a });
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function Q(s) {
|
|
106
106
|
const t = /^rgba?\((.+)\)$/i.exec(s.trim());
|
|
107
107
|
if (!t)
|
|
108
108
|
return null;
|
|
@@ -115,14 +115,14 @@ function J(s) {
|
|
|
115
115
|
const n = e.alpha != null ? O(e.alpha) : 1;
|
|
116
116
|
return n == null ? null : h({ r, g: i, b: a, a: n });
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function Z(s) {
|
|
119
119
|
const t = /^hsla?\((.+)\)$/i.exec(s.trim());
|
|
120
120
|
if (!t)
|
|
121
121
|
return null;
|
|
122
122
|
const e = F(t[1]);
|
|
123
123
|
if (!e || e.channels.length < 3)
|
|
124
124
|
return null;
|
|
125
|
-
const r =
|
|
125
|
+
const r = j(e.channels[0]), i = H(e.channels[1]), a = H(e.channels[2]);
|
|
126
126
|
if (r == null || i == null || a == null)
|
|
127
127
|
return null;
|
|
128
128
|
const n = e.alpha != null ? O(e.alpha) : 1;
|
|
@@ -138,17 +138,17 @@ function h(s) {
|
|
|
138
138
|
}
|
|
139
139
|
function f(s) {
|
|
140
140
|
const t = (s || "").trim();
|
|
141
|
-
return t ? t.startsWith("#") ?
|
|
141
|
+
return t ? t.startsWith("#") ? J(t) : /^rgba?\(/i.test(t) ? Q(t) : /^hsla?\(/i.test(t) ? Z(t) : null : null;
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function tt(s, t = !1) {
|
|
144
144
|
const e = h(s), r = (a) => a.toString(16).padStart(2, "0"), i = `#${r(e.r)}${r(e.g)}${r(e.b)}`;
|
|
145
145
|
return t ? `${i}${r(Math.round(e.a * 255))}` : i;
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function et(s, t = !0) {
|
|
148
148
|
const e = h(s);
|
|
149
149
|
return !t || e.a >= 1 ? `rgb(${e.r} ${e.g} ${e.b})` : `rgb(${e.r} ${e.g} ${e.b} / ${m(e.a, 3)})`;
|
|
150
150
|
}
|
|
151
|
-
function
|
|
151
|
+
function rt(s, t = !0) {
|
|
152
152
|
const e = Math.round(w(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);
|
|
153
153
|
return !t || a >= 1 ? `hsl(${e} ${r}% ${i}%)` : `hsl(${e} ${r}% ${i}% / ${a})`;
|
|
154
154
|
}
|
|
@@ -164,7 +164,7 @@ function T(s) {
|
|
|
164
164
|
a: t.a
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
|
-
function
|
|
167
|
+
function it(s) {
|
|
168
168
|
const t = w(s.h), e = g(s.s, 0, 100) / 100, r = g(s.v, 0, 100) / 100, i = r * e, a = i * (1 - Math.abs(t / 60 % 2 - 1)), n = r - i;
|
|
169
169
|
let o = 0, l = 0, c = 0;
|
|
170
170
|
return t < 60 ? (o = i, l = a) : t < 120 ? (o = a, l = i) : t < 180 ? (l = i, c = a) : t < 240 ? (l = a, c = i) : t < 300 ? (o = a, c = i) : (o = i, c = a), h({
|
|
@@ -195,15 +195,15 @@ function U(s) {
|
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
197
|
function x(s, t) {
|
|
198
|
-
return
|
|
198
|
+
return tt(s, t).toUpperCase();
|
|
199
199
|
}
|
|
200
200
|
function S(s, t) {
|
|
201
|
-
return
|
|
201
|
+
return et(s, t);
|
|
202
202
|
}
|
|
203
|
-
function
|
|
204
|
-
return
|
|
203
|
+
function at(s, t) {
|
|
204
|
+
return rt(L(s), t);
|
|
205
205
|
}
|
|
206
|
-
const z = "#2563eb", $ = "editora:ui-color-picker:recent",
|
|
206
|
+
const z = "#2563eb", $ = "editora:ui-color-picker:recent", nt = `
|
|
207
207
|
<svg viewBox="0 0 20 20" aria-hidden="true" focusable="false">
|
|
208
208
|
<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"/>
|
|
209
209
|
</svg>
|
|
@@ -854,7 +854,7 @@ const z = "#2563eb", $ = "editora:ui-color-picker:recent", at = `
|
|
|
854
854
|
border-color: Highlight;
|
|
855
855
|
}
|
|
856
856
|
}
|
|
857
|
-
`,
|
|
857
|
+
`, st = `
|
|
858
858
|
.overlay {
|
|
859
859
|
position: fixed;
|
|
860
860
|
inset: 0;
|
|
@@ -901,9 +901,11 @@ function M(s, t) {
|
|
|
901
901
|
function A(s) {
|
|
902
902
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
903
903
|
}
|
|
904
|
-
class
|
|
904
|
+
class ot extends V {
|
|
905
905
|
constructor() {
|
|
906
|
-
super(), this._syncing = !1, this._initialized = !1, this._rgba = h(f(z) || { r: 37, g: 99, b: 235, a: 1 }), this._hsva = T(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 = W(() => 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 = () =>
|
|
906
|
+
super(), this._syncing = !1, this._initialized = !1, this._rgba = h(f(z) || { r: 37, g: 99, b: 235, a: 1 }), this._hsva = T(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 = W(() => 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) => {
|
|
907
|
+
K(t, [this._overlay]) || this._scheduleOverlayPosition.run();
|
|
908
|
+
}, this._applyValueAttribute(!1), this._applyFormatAttribute(), this._open = this.hasAttribute("open"), this._parsePresetsAttribute();
|
|
907
909
|
}
|
|
908
910
|
static get observedAttributes() {
|
|
909
911
|
return [
|
|
@@ -1041,7 +1043,7 @@ class st extends V {
|
|
|
1041
1043
|
>
|
|
1042
1044
|
<span class="trigger-preview" data-role="trigger-preview"></span>
|
|
1043
1045
|
<span class="trigger-value" data-role="trigger-value"></span>
|
|
1044
|
-
<span class="trigger-chevron" aria-hidden="true">${
|
|
1046
|
+
<span class="trigger-chevron" aria-hidden="true">${nt}</span>
|
|
1045
1047
|
</button>
|
|
1046
1048
|
</div>
|
|
1047
1049
|
<div class="panel-inline" data-role="inline-panel" part="popover">
|
|
@@ -1138,14 +1140,14 @@ class st extends V {
|
|
|
1138
1140
|
this._syncOverlayHostAttributes();
|
|
1139
1141
|
const t = this._isMobileSheet(), e = t ? "sheet" : "popover";
|
|
1140
1142
|
this._overlay.dataset.mode !== e && (this._overlay.dataset.mode = e, this._overlayRoot.innerHTML = `
|
|
1141
|
-
<style>${q}${
|
|
1143
|
+
<style>${q}${st}</style>
|
|
1142
1144
|
<section class="overlay">
|
|
1143
1145
|
${t ? '<div class="sheet-backdrop" data-action="close-popover"></div>' : ""}
|
|
1144
1146
|
<div class="${t ? "sheet-shell" : "popover-shell"}">
|
|
1145
1147
|
${this._panelMarkup("overlay")}
|
|
1146
1148
|
</div>
|
|
1147
1149
|
</section>
|
|
1148
|
-
`, t && !this._isSheetOpen && (this._isSheetOpen = !0, this._releaseScrollLock =
|
|
1150
|
+
`, t && !this._isSheetOpen && (this._isSheetOpen = !0, this._releaseScrollLock = G()), !t && this._isSheetOpen && (this._isSheetOpen = !1, this._releaseScrollLock && (this._releaseScrollLock(), this._releaseScrollLock = null)));
|
|
1149
1151
|
}
|
|
1150
1152
|
_isPopoverMode() {
|
|
1151
1153
|
return (this.getAttribute("mode") || "inline") === "popover";
|
|
@@ -1173,7 +1175,7 @@ class st extends V {
|
|
|
1173
1175
|
t("size"), t("variant"), t("state"), t("tone"), t("close-on-escape"), t("aria-label"), t("aria-labelledby"), t("aria-describedby"), e("disabled"), e("readonly");
|
|
1174
1176
|
}
|
|
1175
1177
|
_isMobileSheet() {
|
|
1176
|
-
return
|
|
1178
|
+
return X(this.getAttribute("mode") || "inline");
|
|
1177
1179
|
}
|
|
1178
1180
|
_alphaEnabled() {
|
|
1179
1181
|
return I(this.getAttribute("alpha"), !1);
|
|
@@ -1289,7 +1291,7 @@ class st extends V {
|
|
|
1289
1291
|
};
|
|
1290
1292
|
}
|
|
1291
1293
|
_serializeValue(t = this._format) {
|
|
1292
|
-
return t === "rgb" ? S(this._rgba, this._alphaEnabled()) : t === "hsl" ?
|
|
1294
|
+
return t === "rgb" ? S(this._rgba, this._alphaEnabled()) : t === "hsl" ? at(this._rgba, this._alphaEnabled()) : x(this._rgba, this._alphaEnabled());
|
|
1293
1295
|
}
|
|
1294
1296
|
_currentHex() {
|
|
1295
1297
|
return x(this._rgba, this._alphaEnabled());
|
|
@@ -1371,7 +1373,7 @@ class st extends V {
|
|
|
1371
1373
|
const t = document.createElement("div");
|
|
1372
1374
|
t.style.position = "fixed", t.style.inset = "0", t.style.zIndex = "var(--ui-cp-z, 1600)", t.style.pointerEvents = "auto";
|
|
1373
1375
|
const e = t.attachShadow({ mode: "open" });
|
|
1374
|
-
t.addEventListener("click", (r) => this._onPanelClick(r, "overlay")), t.addEventListener("input", (r) => this._onPanelInput(r, "overlay")), t.addEventListener("change", (r) => this._onPanelChange(r, "overlay")), t.addEventListener("keydown", (r) => this._onPanelKeyDown(r, "overlay")), t.addEventListener("pointerdown", (r) => this._onPanelPointerDown(r, "overlay")), t.addEventListener("pointermove", (r) => this._onPanelPointerMove(r)), t.addEventListener("pointerup", (r) => this._onPanelPointerUp(r)), t.addEventListener("pointercancel", (r) => this._onPanelPointerCancel(r)), document.body.appendChild(t), this._overlay = t, this._overlayRoot = e, this._syncOverlayHostAttributes(), document.addEventListener("pointerdown", this._onDocumentPointerDownBound, !0), document.addEventListener("keydown", this._onDocumentKeyDownBound), window.addEventListener("resize", this._onWindowResizeBound), window.addEventListener("scroll", this._onWindowScrollBound, !0);
|
|
1376
|
+
t.addEventListener("click", (r) => this._onPanelClick(r, "overlay")), t.addEventListener("input", (r) => this._onPanelInput(r, "overlay")), t.addEventListener("change", (r) => this._onPanelChange(r, "overlay")), t.addEventListener("keydown", (r) => this._onPanelKeyDown(r, "overlay")), t.addEventListener("pointerdown", (r) => this._onPanelPointerDown(r, "overlay")), t.addEventListener("pointermove", (r) => this._onPanelPointerMove(r)), t.addEventListener("pointerup", (r) => this._onPanelPointerUp(r)), t.addEventListener("pointercancel", (r) => this._onPanelPointerCancel(r)), document.body.appendChild(t), this._overlay = t, this._overlayRoot = e, this._syncOverlayHostAttributes(), document.addEventListener("pointerdown", this._onDocumentPointerDownBound, !0), document.addEventListener("keydown", this._onDocumentKeyDownBound), window.addEventListener("resize", this._onWindowResizeBound), window.addEventListener("scroll", this._onWindowScrollBound, { passive: !0, capture: !0 });
|
|
1375
1377
|
}
|
|
1376
1378
|
_destroyOverlay() {
|
|
1377
1379
|
this._scheduleOverlayPosition.cancel(), typeof document < "u" && (document.removeEventListener("pointerdown", this._onDocumentPointerDownBound, !0), document.removeEventListener("keydown", this._onDocumentKeyDownBound)), typeof window < "u" && (window.removeEventListener("resize", this._onWindowResizeBound), window.removeEventListener("scroll", this._onWindowScrollBound, !0)), this._overlay && this._overlay.parentElement && this._overlay.parentElement.removeChild(this._overlay), this._overlay = null, this._overlayRoot = null, this._panelCache = /* @__PURE__ */ new WeakMap(), this._isSheetOpen && (this._isSheetOpen = !1, this._releaseScrollLock && (this._releaseScrollLock(), this._releaseScrollLock = null));
|
|
@@ -1385,8 +1387,14 @@ class st extends V {
|
|
|
1385
1387
|
const r = e.querySelector(".panel");
|
|
1386
1388
|
if (!r)
|
|
1387
1389
|
return;
|
|
1388
|
-
const i =
|
|
1389
|
-
|
|
1390
|
+
const i = e.getAttribute("data-placement"), a = Y(
|
|
1391
|
+
t.getBoundingClientRect(),
|
|
1392
|
+
r.getBoundingClientRect(),
|
|
1393
|
+
8,
|
|
1394
|
+
8,
|
|
1395
|
+
i === "top" ? "top" : i === "bottom" ? "bottom" : null
|
|
1396
|
+
);
|
|
1397
|
+
e.style.top = `${Math.round(a.top)}px`, e.style.left = `${Math.round(a.left)}px`, e.setAttribute("data-placement", a.placement);
|
|
1390
1398
|
}
|
|
1391
1399
|
_onDocumentPointerDown(t) {
|
|
1392
1400
|
var i;
|
|
@@ -1737,7 +1745,7 @@ class st extends V {
|
|
|
1737
1745
|
v: u(t.v, 0, 100),
|
|
1738
1746
|
a: this._alphaEnabled() ? u(t.a, 0, 1) : 1
|
|
1739
1747
|
}, r = this._hsva;
|
|
1740
|
-
return M(r.h, e.h) && M(r.s, e.s) && M(r.v, e.v) && M(r.a, e.a) ? !1 : (this._hsva = e, this._rgba = this._normalizeByAlpha(
|
|
1748
|
+
return M(r.h, e.h) && M(r.s, e.s) && M(r.v, e.v) && M(r.a, e.a) ? !1 : (this._hsva = e, this._rgba = this._normalizeByAlpha(it(this._hsva)), this._error = "", !0);
|
|
1741
1749
|
}
|
|
1742
1750
|
_stopDrag(t) {
|
|
1743
1751
|
this._cancelDragFrame();
|
|
@@ -1803,7 +1811,7 @@ class st extends V {
|
|
|
1803
1811
|
e ? t.setAttribute("aria-labelledby", e) : t.removeAttribute("aria-labelledby"), r ? t.setAttribute("aria-describedby", r) : t.removeAttribute("aria-describedby"), i ? t.setAttribute("aria-label", i) : e || t.setAttribute("aria-label", "Color picker");
|
|
1804
1812
|
}
|
|
1805
1813
|
}
|
|
1806
|
-
customElements.get("ui-color-picker") || customElements.define("ui-color-picker",
|
|
1814
|
+
customElements.get("ui-color-picker") || customElements.define("ui-color-picker", ot);
|
|
1807
1815
|
export {
|
|
1808
|
-
|
|
1816
|
+
ot as UIColorPicker
|
|
1809
1817
|
};
|
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 C=require("./ElementBase-1b301e7f.js"),h=require("./collection-a2969ad2.js"),k=require("./dismissable-layer-193e3bed.js"),L=require("./listbox-ef2f708e.js");require("./collection.cjs.js");const F=`
|
|
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
|
+
`,$=`
|
|
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
|
+
`,E=`
|
|
10
10
|
:host {
|
|
11
11
|
--ui-combobox-width: var(--ui-width, 100%);
|
|
12
12
|
--ui-combobox-min-width: 248px;
|
|
@@ -467,29 +467,29 @@
|
|
|
467
467
|
color: HighlightText;
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
|
-
`;function a(d){return d.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function x(d){if(d==null)return!1;const t=String(d).toLowerCase();return t!=="false"&&t!=="0"}class
|
|
470
|
+
`;function a(d){return d.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function x(d){if(d==null)return!1;const t=String(d).toLowerCase();return t!=="false"&&t!=="0"}class A extends C.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["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(){var t;this._unbindGlobalListeners(),this._detachDomListeners(),(t=this._dismissableLayer)==null||t.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 x(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 s={open:t,previousOpen:e,source:i};this.dispatchEvent(new CustomEvent(t?"open":"close",{detail:s,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(t?"ui-open":"ui-close",{detail:s,bubbles:!0,composed:!0}))}_attachFormRegistration(){var t;try{const i=this.getRootNode().host,r=((t=i==null?void 0:i.closest)==null?void 0:t.call(i,"ui-form"))||null||this.closest("ui-form"),o=this.getAttribute("name");r&&typeof r.registerField=="function"&&o&&(this._formUnregister=r.registerField(o,{name:o,getValue:()=>this.value,setValue:n=>{this.value=n},validate:async()=>{const n=this._isCurrentValueValid();return{valid:n,message:n?void 0:"Please select a value from the list."}},setError:n=>{n?(this.setAttribute("validation","error"),this.setAttribute("data-error",n)):(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,s)=>{const r=i.tagName.toLowerCase()==="option",o=i,n=r?o.value||o.textContent||"":i.getAttribute("value")||i.getAttribute("data-value")||i.textContent||"",l=r?(o.label||o.textContent||o.value||"").trim():(i.getAttribute("label")||i.textContent||n).trim(),b=(i.getAttribute("description")||i.getAttribute("data-description")||"").trim(),u=r?o.disabled:x(i.getAttribute("disabled")),c=n.trim();if(!c&&!l)return null;const m=`${c}::${l}`;return e.has(m)?null:(e.add(m),{value:c,label:l,description:b,disabled:u,sourceIndex:s})}).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"),s=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!=null&&t.preserveHighlight&&s){const o=this._filtered.findIndex(n=>n.sourceIndex===s.sourceIndex);if(o>=0&&!this._filtered[o].disabled){this._highlightedIndex=o;return}}const r=this._findOptionByValue(this.value);if(r){const o=this._filtered.findIndex(n=>n.sourceIndex===r.sourceIndex);if(o>=0&&!this._filtered[o].disabled){this._highlightedIndex=o;return}}this._highlightedIndex=L.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">${a(e)}</div>`,this._listStructureFingerprint=i,this._panel.refresh(),this._panel.clearActive(),this._syncActiveDescendant();return}const s=this.value,r=this._filtered.map((o,n)=>{const l=o.value===s,b=n===this._highlightedIndex,u=o.disabled;return`
|
|
471
471
|
<button
|
|
472
472
|
type="button"
|
|
473
|
-
id="${`${this._uid}-option-${
|
|
473
|
+
id="${`${this._uid}-option-${o.sourceIndex}`}"
|
|
474
474
|
class="option"
|
|
475
475
|
role="option"
|
|
476
|
-
aria-selected="${
|
|
476
|
+
aria-selected="${l?"true":"false"}"
|
|
477
477
|
aria-disabled="${u?"true":"false"}"
|
|
478
|
-
data-option-index="${
|
|
479
|
-
data-highlighted="${
|
|
480
|
-
data-selected="${
|
|
478
|
+
data-option-index="${n}"
|
|
479
|
+
data-highlighted="${b?"true":"false"}"
|
|
480
|
+
data-selected="${l?"true":"false"}"
|
|
481
481
|
${u?"disabled":""}>
|
|
482
482
|
<span class="option-text">
|
|
483
|
-
<span class="option-label">${a(
|
|
484
|
-
${
|
|
483
|
+
<span class="option-label">${a(o.label)}</span>
|
|
484
|
+
${o.description?`<span class="option-description">${a(o.description)}</span>`:""}
|
|
485
485
|
</span>
|
|
486
486
|
<span class="option-check" aria-hidden="true">✓</span>
|
|
487
487
|
</button>
|
|
488
|
-
`}).join("");this._panel.innerHTML=`${t}${
|
|
489
|
-
${t?"":`<style>${
|
|
490
|
-
${
|
|
488
|
+
`}).join("");this._panel.innerHTML=`${t}${r}`,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,s)=>{const r=this._filtered[s];if(!r)return;const o=r.value===e,n=s===this._highlightedIndex;i.setAttribute("aria-selected",o?"true":"false"),i.setAttribute("aria-disabled",r.disabled?"true":"false"),i.setAttribute("data-highlighted",n?"true":"false"),i.setAttribute("data-selected",o?"true":"false"),i.disabled=r.disabled}),this._syncActiveDescendant(),this._scrollHighlightedIntoView(),!0}_renderStateRow(){const t=this._state(),e=this._stateText();return e?`<div class="status-row" part="status" data-state="${a(t)}" aria-live="polite">${a(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(){var e,i;if(!this._input)return;const t=(e=this._panel)==null?void 0:e.querySelector(`[data-option-index="${this._highlightedIndex}"]`);if(t&&this._panel){this._panel.setActiveItem(t,{focus:!1,owner:this._input,scroll:!1});return}(i=this._panel)==null||i.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(){var i;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(),(i=this._dismissableLayer)==null||i.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(){var t;!this.open||!this._panel||((t=this._dismissableLayer)==null||t.destroy(),this._dismissableLayer=k.createDismissableLayer({node:this._panel,trigger:this._control,closeOnEscape:!1,closeOnPointerOutside:!0,onDismiss:e=>{e==="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){var r,o;if(this._filtered.length===0)return;const e=(r=this._panel)==null?void 0:r.querySelector(`[data-option-index="${this._highlightedIndex}"]`),i=((o=this._panel)==null?void 0:o.move(t>0?1:-1,{current:e,focus:!1,owner:this._input,scroll:!0}))||null;if(!i)return;const s=Number(i.getAttribute("data-option-index")||"-1");s<0||(this._highlightedIndex=s,this._renderList())}render(){const t=this.hasAttribute("headless"),e=this.getAttribute("disabled"),i=x(e),s=this._isReadonly(),r=this._state(),o=r==="loading",n=this.getAttribute("placeholder")||"Search...",l=this.getAttribute("maxlength"),b=this.hasAttribute("required"),u=this.getAttribute("label")||"",c=this.getAttribute("description")||"",f=this.getAttribute("data-error")||""||(r==="error"?this._stateText()||"Unable to load options.":""),_=this.getAttribute("validation")==="error"||r==="error"||!!f,v=!!(u||this.querySelector('[slot="label"]')),g=!!(c||this.querySelector('[slot="description"]')),y=`${this._uid}-error`,w=[g?`${this._uid}-description`:"",_?y:""].filter(Boolean).join(" ");if(this._options=this._readOptions(),!this._query){const p=this._findOptionByValue(this.value);this._query=p?p.label:this.value}this._rebuildFiltered({preserveHighlight:!1}),this.setContent(`
|
|
489
|
+
${t?"":`<style>${E}</style>`}
|
|
490
|
+
${v||g?`
|
|
491
491
|
<div class="label-row">
|
|
492
|
-
<label class="label" part="label" id="${this._uid}-label"><slot name="label">${a(
|
|
492
|
+
<label class="label" part="label" id="${this._uid}-label"><slot name="label">${a(u)}</slot></label>
|
|
493
493
|
<div class="description" part="description" id="${this._uid}-description"><slot name="description">${a(c)}</slot></div>
|
|
494
494
|
</div>
|
|
495
495
|
`:""}
|
|
@@ -504,7 +504,7 @@
|
|
|
504
504
|
aria-autocomplete="list"
|
|
505
505
|
aria-expanded="${this.open?"true":"false"}"
|
|
506
506
|
aria-controls="${this._uid}-listbox"
|
|
507
|
-
${
|
|
507
|
+
${v?`aria-labelledby="${this._uid}-label"`:""}
|
|
508
508
|
${w?`aria-describedby="${w}"`:""}
|
|
509
509
|
${_?'aria-invalid="true"':""}
|
|
510
510
|
aria-busy="${o?"true":"false"}"
|
|
@@ -512,14 +512,14 @@
|
|
|
512
512
|
placeholder="${a(n)}"
|
|
513
513
|
${i?"disabled":""}
|
|
514
514
|
${s?"readonly":""}
|
|
515
|
-
${
|
|
515
|
+
${b?"required":""}
|
|
516
516
|
${l?`maxlength="${a(l)}"`:""}
|
|
517
517
|
/>
|
|
518
|
-
<button type="button" part="clear" class="icon-btn clear-btn" aria-label="Clear value" hidden ${s?"disabled":""}>${
|
|
519
|
-
<button type="button" part="toggle" class="icon-btn toggle-btn" data-open="${this.open?"true":"false"}" aria-label="Toggle options">${
|
|
518
|
+
<button type="button" part="clear" class="icon-btn clear-btn" aria-label="Clear value" hidden ${s?"disabled":""}>${F}</button>
|
|
519
|
+
<button type="button" part="toggle" class="icon-btn toggle-btn" data-open="${this.open?"true":"false"}" aria-label="Toggle options">${$}</button>
|
|
520
520
|
</div>
|
|
521
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="${a(r)}" ${this.open?'data-open="true" aria-hidden="false"':'hidden aria-hidden="true"'}></ui-listbox>
|
|
522
522
|
</div>
|
|
523
523
|
<slot hidden></slot>
|
|
524
|
-
<div class="error" part="error" id="${y}" ${_?"":"hidden"}>${a(
|
|
525
|
-
`),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._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")&&
|
|
524
|
+
<div class="error" part="error" id="${y}" ${_?"":"hidden"}>${a(f)}</div>
|
|
525
|
+
`),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(()=>{var p;this._autofocusFrame=0;try{(p=this._input)==null||p.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){var e,i;if(!this._isDisabled()&&this._input){if(t.key==="Home"&&this.open){t.preventDefault();const s=((e=this._panel)==null?void 0:e.focusBoundary("first",{focus:!1,owner:this._input,scroll:!0}))||null;this._highlightedIndex=Number((s==null?void 0:s.getAttribute("data-option-index"))||"-1"),this._renderList();return}if(t.key==="End"&&this.open){t.preventDefault();const s=((i=this._panel)==null?void 0:i.focusBoundary("last",{focus:!1,owner:this._input,scroll:!0}))||null;this._highlightedIndex=Number((s==null?void 0:s.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 s=this._filtered[this._highlightedIndex];s&&this._commitSelection(s)}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 s=this._findExactOptionByQuery(this._query);s&&(t.preventDefault(),this._commitSelection(s))}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){var e;t.preventDefault(),!this._isDisabled()&&(this.open?this._closePanel("toggle"):this._openPanel("toggle"),(e=this._input)==null||e.focus())}_onPanelPointerDown(t){if(this._isReadonly())return;const e=t.target;e!=null&&e.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 s=i.getAttribute("data-option-index"),r=s==null?-1:Number(s);if(!Number.isFinite(r)||r<0)return;const o=this._filtered[r];!o||o.disabled||this._commitSelection(o)}}typeof customElements<"u"&&!customElements.get("ui-combobox")&&customElements.define("ui-combobox",A);exports.UICombobox=A;
|