@webority/ui-elements 0.34.0 → 0.35.1

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.
Files changed (62) hide show
  1. package/dist/WuiAutocomplete-ByxnwJNQ.js +283 -0
  2. package/dist/WuiCommandPalette-CtZ04JxZ.js +130 -0
  3. package/dist/WuiConsentBanner-oVe-jxCO.js +399 -0
  4. package/dist/WuiContextMenu-Bx_U2X3t.js +211 -0
  5. package/dist/WuiCountrySelect-CUAwKnL9.js +28 -0
  6. package/dist/WuiDatePicker-DkNbc-z7.js +325 -0
  7. package/dist/WuiDateRange-BocnVO6L.js +233 -0
  8. package/dist/WuiDock-BSDY9g8Q.js +57 -0
  9. package/dist/WuiImageCrop-1yaAONTk.js +462 -0
  10. package/dist/WuiMultiSelect-BrCGRNCt.js +416 -0
  11. package/dist/WuiOtp-D8-4Pqil.js +128 -0
  12. package/dist/WuiPhone-BvbhiP2r.js +731 -0
  13. package/dist/WuiSelect-BXrpiuXG.js +214 -0
  14. package/dist/WuiSlider-BcU0psYf.js +256 -0
  15. package/dist/WuiSortable-JjJqstSU.js +280 -0
  16. package/dist/WuiTagInput-D1ay3OcL.js +158 -0
  17. package/dist/WuiTimePicker-C7n-VFGt.js +370 -0
  18. package/dist/WuiTour-R5O9l--J.js +205 -0
  19. package/dist/WuiTree-Ds-8tNgs.js +393 -0
  20. package/dist/WuiWizardStep-BU5w9_Ds.js +221 -0
  21. package/dist/anchorOverlay-DluGZ8ef.js +23 -0
  22. package/dist/calendarMath-BAF2Jkg_.js +42 -0
  23. package/dist/countries-B-M_LTgS.js +1234 -0
  24. package/dist/elementBase-Bg1xpvup.js +9 -0
  25. package/dist/elements/autocomplete.js +6 -0
  26. package/dist/elements/command-palette.js +6 -0
  27. package/dist/elements/consent-banner.js +6 -0
  28. package/dist/elements/context-menu.js +6 -0
  29. package/dist/elements/country-select.js +6 -0
  30. package/dist/elements/date-range.js +6 -0
  31. package/dist/elements/datepicker.js +6 -0
  32. package/dist/elements/dock.js +6 -0
  33. package/dist/elements/image-crop.js +6 -0
  34. package/dist/elements/kanban.js +6 -0
  35. package/dist/elements/multiselect.js +6 -0
  36. package/dist/elements/otp.js +6 -0
  37. package/dist/elements/phone.js +6 -0
  38. package/dist/elements/select.js +6 -0
  39. package/dist/elements/slider.js +6 -0
  40. package/dist/elements/sortable.js +6 -0
  41. package/dist/elements/status-icon.js +6 -0
  42. package/dist/elements/taginput.js +6 -0
  43. package/dist/elements/timepicker.js +6 -0
  44. package/dist/elements/tour.js +6 -0
  45. package/dist/elements/tree.js +6 -0
  46. package/dist/elements/wizard.js +5 -0
  47. package/dist/formMirror-jGf5M4gk.js +29 -0
  48. package/dist/formatters-DusKbTyV.js +138 -0
  49. package/dist/helpers.js +5 -0
  50. package/dist/iconGlyphs.g-Cpg1BUHm.js +215 -0
  51. package/dist/kanban-BeVAItir.js +972 -0
  52. package/dist/listboxKeyNav-zts_8d5e.js +36 -0
  53. package/dist/optionLabel-Dn-I7zyp.js +16 -0
  54. package/dist/statusIcons-C3zjycpa.js +37 -0
  55. package/dist/textMatch-DEUjlkdy.js +27 -0
  56. package/dist/themeTransition-BpCuMnjk.js +589 -0
  57. package/dist/tokenCommit-VWz-2jEf.js +20 -0
  58. package/dist/ui-elements.global.js +118 -129
  59. package/dist/ui-elements.js +253 -8864
  60. package/dist/ui-phone.global.js +14 -0
  61. package/dist/wuiHttp-m0yQadwQ.js +117 -0
  62. package/package.json +28 -3
@@ -0,0 +1,214 @@
1
+ import { t as e } from "./elementBase-Bg1xpvup.js";
2
+ import { n as t, r as n, t as r } from "./anchorOverlay-DluGZ8ef.js";
3
+ import { t as i } from "./formMirror-jGf5M4gk.js";
4
+ import { t as a } from "./iconGlyphs.g-Cpg1BUHm.js";
5
+ import { n as o, t as s } from "./listboxKeyNav-zts_8d5e.js";
6
+ import { n as c, r as l, t as u } from "./optionLabel-Dn-I7zyp.js";
7
+ //#region src/WuiSelect.js
8
+ var d = class extends e {
9
+ static formAssociated = !0;
10
+ static get observedAttributes() {
11
+ return [
12
+ "value",
13
+ "placeholder",
14
+ "search-placeholder",
15
+ "searchable",
16
+ "disabled",
17
+ "compact",
18
+ "size",
19
+ "clearable",
20
+ "icon",
21
+ "prefix",
22
+ "aria-label",
23
+ "aria-invalid"
24
+ ];
25
+ }
26
+ _accessibleName() {
27
+ return this.getAttribute("aria-label") || this.getAttribute("placeholder") || "Select";
28
+ }
29
+ constructor() {
30
+ super();
31
+ try {
32
+ this._internals = this.attachInternals();
33
+ } catch {
34
+ this._internals = null;
35
+ }
36
+ this._value = "", this._optionsProp = null, this._active = -1, this._typeahead = "", this._typeaheadTimer = null;
37
+ }
38
+ connectedCallback() {
39
+ if (!this._rendered) {
40
+ this.render();
41
+ return;
42
+ }
43
+ this._bindGlobal?.();
44
+ }
45
+ attributeChangedCallback(e, t, n) {
46
+ if (e === "value") {
47
+ this.value = n;
48
+ return;
49
+ }
50
+ if (e === "aria-invalid") {
51
+ this._syncInvalid();
52
+ return;
53
+ }
54
+ this._rendered && this.render();
55
+ }
56
+ _syncInvalid() {
57
+ let e = this.querySelector(".search-select-control");
58
+ e && (this.hasAttribute("aria-invalid") ? e.setAttribute("aria-invalid", "true") : e.removeAttribute("aria-invalid"));
59
+ }
60
+ formResetCallback() {
61
+ this.value = this._defaultValue || "";
62
+ }
63
+ get value() {
64
+ return this._value;
65
+ }
66
+ set value(e) {
67
+ this._value = e == null ? "" : String(e), i(this, this._value), this._syncSelected(), this._syncReset();
68
+ }
69
+ set options(e) {
70
+ this._optionsProp = Array.isArray(e) ? e : null, this.isConnected && this.render();
71
+ }
72
+ get options() {
73
+ return this._readOptions();
74
+ }
75
+ _snapshotDeclared() {
76
+ if (this._declared) return;
77
+ let e = [...this.querySelectorAll(":scope > wui-option")];
78
+ e.length && (this._declared = e.map((e) => ({
79
+ value: e.getAttribute("value") ?? e.textContent.trim(),
80
+ label: e.innerHTML,
81
+ icon: e.getAttribute("icon") || void 0,
82
+ [u]: !0,
83
+ selected: e.hasAttribute("selected")
84
+ })));
85
+ }
86
+ _readOptions() {
87
+ return this._optionsProp ? this._optionsProp : (this._snapshotDeclared(), this._declared || []);
88
+ }
89
+ render() {
90
+ this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || ""), this._snapshotDeclared();
91
+ let e = this._readOptions(), t = this.hasAttribute("searchable"), n = this.hasAttribute("clearable"), r = this.getAttribute("size"), o = r === "sm" ? " search-select-sm" : r === "lg" ? " search-select-lg" : "", s = this.getAttribute("icon"), u = this.getAttribute("prefix"), d = this.getAttribute("placeholder") || "Select...", p = this.getAttribute("search-placeholder") || "Search...", m = e.find((e) => String(e.value) === String(this._value)) || e.find((e) => e.selected);
92
+ m && (this._value = String(m.value)), i(this, this._value), this.id ||= `wui-select-${Math.random().toString(36).slice(2, 9)}`;
93
+ let h = `${this.id}-listbox`;
94
+ this._listboxId = h;
95
+ let g = e.map((e, t) => {
96
+ let n = String(e.value) === String(this._value);
97
+ return `<button type="button" role="option" id="${f(`${h}-opt-${t}`)}" class="search-select-option${n ? " selected" : ""}" data-value="${f(e.value)}" aria-selected="${n}">${l(e)}</button>`;
98
+ }).join("");
99
+ this.innerHTML = `
100
+ <div class="search-select${this.hasAttribute("compact") ? " search-select-compact" : ""}${o}">
101
+ <button type="button" role="combobox" class="input search-select-control" aria-haspopup="listbox" aria-expanded="false" aria-controls="${f(h)}" aria-label="${f(this._accessibleName())}"${this.hasAttribute("aria-invalid") ? " aria-invalid=\"true\"" : ""}${this.hasAttribute("disabled") ? " disabled" : ""}>
102
+ ${s ? a(s, { className: "search-select-icon" }) : ""}
103
+ ${u ? `<span class="search-select-prefix">${c(u)}</span>` : ""}
104
+ <span class="${m ? "" : "search-select-placeholder"}" data-label>${m ? l(m) : c(d)}</span>
105
+ ${n ? `<span class="search-select-reset" role="button" aria-label="Clear selection" hidden>${a("x")}</span>` : ""}
106
+ ${a("chevron-down", { className: "search-select-caret" })}
107
+ </button>
108
+ <div class="search-select-menu search-select-menu-fixed" role="listbox" id="${f(h)}" tabindex="-1" hidden>
109
+ ${t ? `<div class="search-select-search">${a("search")}<input class="search-select-input" placeholder="${f(p)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden>${a("x")}</button></div>` : ""}
110
+ <div class="search-select-options">${g}<div class="search-select-empty" hidden>No matches</div></div>
111
+ </div>
112
+ </div>`, this._rendered = !0, i(this, this._value), this._wire(), this._syncReset();
113
+ }
114
+ _refs() {
115
+ return {
116
+ control: this.querySelector(".search-select-control"),
117
+ menu: this.querySelector(".search-select-menu"),
118
+ label: this.querySelector("[data-label]"),
119
+ reset: this.querySelector(".search-select-reset"),
120
+ search: this.querySelector(".search-select-input"),
121
+ clear: this.querySelector(".search-select-clear"),
122
+ empty: this.querySelector(".search-select-empty"),
123
+ optionsWrap: this.querySelector(".search-select-options")
124
+ };
125
+ }
126
+ _optionEls() {
127
+ return [...this.querySelectorAll(".search-select-option")];
128
+ }
129
+ _visible() {
130
+ return this._optionEls().filter((e) => !e.hidden);
131
+ }
132
+ _syncSelected() {
133
+ let { label: e } = this._refs(), t = this._readOptions().find((e) => String(e.value) === String(this._value));
134
+ for (let e of this._optionEls()) {
135
+ let t = e.dataset.value === String(this._value);
136
+ e.classList.toggle("selected", t), e.setAttribute("aria-selected", String(t));
137
+ }
138
+ e && (e.innerHTML = t ? l(t) : c(this.getAttribute("placeholder") || "Select..."), e.classList.toggle("search-select-placeholder", !t));
139
+ }
140
+ _syncReset() {
141
+ let { reset: e } = this._refs();
142
+ e && (e.hidden = !(this.hasAttribute("clearable") && this._value !== "" && !this.hasAttribute("disabled")));
143
+ }
144
+ _wire() {
145
+ this._teardown();
146
+ let e = this._refs();
147
+ if (!e.control || !e.menu) return;
148
+ let i = () => {
149
+ if (this.hasAttribute("compact")) {
150
+ let t = e.control.getBoundingClientRect();
151
+ e.menu.style.width = "max-content", e.menu.style.minWidth = `${t.width}px`, e.menu.style.maxWidth = "280px", r(e.control, e.menu);
152
+ } else r(e.control, e.menu, { matchWidth: !0 });
153
+ }, a = (t, { reveal: n = !0 } = {}) => {
154
+ let r = this._visible();
155
+ this._active = t, o(e.optionsWrap, t >= 0 && r[t] || null), t >= 0 && r[t] ? (n && r[t].scrollIntoView({ block: "nearest" }), e.control.setAttribute("aria-activedescendant", r[t].id)) : e.control.removeAttribute("aria-activedescendant");
156
+ }, c = (t) => {
157
+ let n = t.trim().toLowerCase(), r = 0;
158
+ for (let e of this._optionEls()) {
159
+ let t = !n || e.textContent.toLowerCase().includes(n);
160
+ e.hidden = !t, t && (r += 1);
161
+ }
162
+ e.empty && (e.empty.hidden = r > 0), e.clear && (e.clear.hidden = !n), e.menu.hidden || i();
163
+ }, l = () => !e.menu.hidden, u = () => {
164
+ l() && i();
165
+ }, d = () => {
166
+ e.menu.hidden = !1, e.control.setAttribute("aria-expanded", "true"), e.control.classList.add("open"), i(), t(this, u), e.search && (e.search.value = "", c(""), e.search.focus()), a(this._optionEls().findIndex((e) => e.classList.contains("selected")));
167
+ }, f = () => {
168
+ e.menu.hidden = !0, e.control.setAttribute("aria-expanded", "false"), e.control.classList.remove("open"), a(-1), n(this);
169
+ }, p = (t) => {
170
+ this.value = t.dataset.value, this.dispatchEvent(new Event("change", { bubbles: !0 })), f(), e.control.focus();
171
+ };
172
+ this._navHandler = s({
173
+ getVisibleOptions: () => this._visible(),
174
+ getActive: () => this._active,
175
+ setActive: (e) => a(e),
176
+ onEnter: (e) => {
177
+ e && p(e);
178
+ },
179
+ onEscape: () => {
180
+ this._navHandler.clearTypeahead(), f(), e.control.focus();
181
+ }
182
+ }), e.reset?.addEventListener("click", (t) => {
183
+ t.stopPropagation(), this.value = "", this.dispatchEvent(new Event("change", { bubbles: !0 })), e.control.focus();
184
+ }), e.control.addEventListener("click", () => l() ? f() : d()), e.control.addEventListener("keydown", (e) => {
185
+ if (l()) {
186
+ this._navHandler.handler(e);
187
+ return;
188
+ }
189
+ (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") && (e.preventDefault(), d());
190
+ }), e.optionsWrap.addEventListener("click", (e) => {
191
+ let t = e.target.closest(".search-select-option");
192
+ t && p(t);
193
+ }), e.optionsWrap.addEventListener("mousemove", (e) => {
194
+ let t = e.target.closest(".search-select-option");
195
+ t && !t.classList.contains("is-active") && a(this._visible().indexOf(t), { reveal: !1 });
196
+ }), e.optionsWrap.addEventListener("mouseleave", () => a(-1)), e.search?.addEventListener("input", () => {
197
+ c(e.search.value), a(-1);
198
+ }), e.clear?.addEventListener("click", () => {
199
+ e.search.value = "", c(""), e.search.focus();
200
+ }), e.menu.addEventListener("keydown", this._navHandler.handler), this._bindGlobal = () => {
201
+ this._teardown(), this._onDocClick = (e) => {
202
+ l() && !this.contains(e.target) && f();
203
+ }, document.addEventListener("click", this._onDocClick), l() && t(this, u);
204
+ }, this._bindGlobal();
205
+ }
206
+ _teardown() {
207
+ this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), n(this), this._navHandler?.teardown();
208
+ }
209
+ disconnectedCallback() {
210
+ this._teardown();
211
+ }
212
+ }, f = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
213
+ //#endregion
214
+ export { d as t };
@@ -0,0 +1,256 @@
1
+ import { t as e } from "./elementBase-Bg1xpvup.js";
2
+ import { t } from "./formMirror-jGf5M4gk.js";
3
+ //#region src/WuiSlider.js
4
+ var n = class extends e {
5
+ static formAssociated = !0;
6
+ static get observedAttributes() {
7
+ return [
8
+ "min",
9
+ "max",
10
+ "step",
11
+ "value",
12
+ "start",
13
+ "end",
14
+ "name",
15
+ "start-name",
16
+ "end-name",
17
+ "disabled",
18
+ "size",
19
+ "show-value",
20
+ "unit",
21
+ "aria-label"
22
+ ];
23
+ }
24
+ constructor() {
25
+ super();
26
+ try {
27
+ this._internals = this.attachInternals();
28
+ } catch {
29
+ this._internals = null;
30
+ }
31
+ this._value = 50, this._start = 25, this._end = 75, this._isDragging = !1, this._dragThumb = null, this._pointerDownListener = null, this._pointerMoveListener = null, this._pointerUpListener = null, this._thumbKeyListener = null, this._trackClickListener = null;
32
+ }
33
+ connectedCallback() {
34
+ if (!this._rendered) {
35
+ this.render();
36
+ return;
37
+ }
38
+ this._wire();
39
+ }
40
+ get value() {
41
+ return this._value;
42
+ }
43
+ set value(e) {
44
+ this._value = this._snapToStep(this._clamp(r(e, this._value))), this._syncValue(), this._syncMirrors();
45
+ }
46
+ get start() {
47
+ return this._start;
48
+ }
49
+ set start(e) {
50
+ this._start = Math.min(this._snapToStep(this._clamp(r(e, this._start))), this._end), this._syncValue(), this._syncMirrors();
51
+ }
52
+ get end() {
53
+ return this._end;
54
+ }
55
+ set end(e) {
56
+ this._end = Math.max(this._snapToStep(this._clamp(r(e, this._end))), this._start), this._syncValue(), this._syncMirrors();
57
+ }
58
+ attributeChangedCallback(e, t, n) {
59
+ if (e === "value" || e === "start" || e === "end" || e === "min" || e === "max" || e === "step") {
60
+ this._updateFromAttribute(e), this._rendered && (this._syncValue(), this._syncMirrors());
61
+ return;
62
+ }
63
+ this._rendered && this.render();
64
+ }
65
+ formResetCallback() {
66
+ this._isRange() ? this._resetRange() : this._resetSingle();
67
+ }
68
+ _updateFromAttribute(e) {
69
+ e === "value" ? this._value = this._snapToStep(this._clamp(r(this.getAttribute("value"), this._value))) : e === "start" ? this._start = this._snapToStep(this._clamp(r(this.getAttribute("start"), this._start))) : e === "end" && (this._end = this._snapToStep(this._clamp(r(this.getAttribute("end"), this._end))));
70
+ }
71
+ _isRange() {
72
+ return this.hasAttribute("range");
73
+ }
74
+ _min() {
75
+ return r(this.getAttribute("min"), 0);
76
+ }
77
+ _max() {
78
+ return r(this.getAttribute("max"), 100);
79
+ }
80
+ _step() {
81
+ return r(this.getAttribute("step"), 1);
82
+ }
83
+ _clamp(e) {
84
+ return Math.max(this._min(), Math.min(e, this._max()));
85
+ }
86
+ _snapToStep(e) {
87
+ let t = this._step();
88
+ if (t <= 0) return e;
89
+ let n = this._min();
90
+ return this._clamp(n + Math.round((e - n) / t) * t);
91
+ }
92
+ _captureDefaults() {
93
+ this._defaultsCaptured ||= (this._isRange() ? (this._defaultStart = this._start, this._defaultEnd = this._end) : this._defaultValue = this._value, !0);
94
+ }
95
+ _resetSingle() {
96
+ this._value = this._defaultValue ?? 50, this._syncValue(), this._syncMirrors();
97
+ }
98
+ _resetRange() {
99
+ this._start = this._defaultStart ?? 25, this._end = this._defaultEnd ?? 75, this._syncValue(), this._syncMirrors();
100
+ }
101
+ render() {
102
+ this._captureDefaults();
103
+ let e = this._min(), t = this._max(), n = this._isRange(), r = this.getAttribute("size"), a = r === "sm" ? " slider-sm" : r === "lg" ? " slider-lg" : "", o = this.hasAttribute("disabled");
104
+ n ? (this._start = this._clamp(this._start), this._end = this._clamp(this._end), this._start > this._end && ([this._start, this._end] = [this._end, this._start])) : this._value = this._clamp(this._value);
105
+ let s = (n) => t === e ? 0 : (n - e) / (t - e) * 100, c = n ? s(this._start) : 0, l = s(n ? this._end : this._value);
106
+ this.innerHTML = `
107
+ <div class="slider${a}">
108
+ <div class="slider-track" role="presentation"></div>
109
+ <div class="slider-fill" style="left: ${c}%; right: ${100 - l}%;" role="presentation"></div>
110
+ ${n ? `
111
+ <button
112
+ type="button"
113
+ role="slider"
114
+ class="slider-thumb"
115
+ data-thumb="start"
116
+ style="left: ${c}%;"
117
+ aria-label="Minimum"
118
+ aria-valuemin="${e}"
119
+ aria-valuemax="${t}"
120
+ aria-valuenow="${this._start}"
121
+ aria-valuetext="${this._formatValue(this._start)}"
122
+ ${o ? "disabled" : ""}
123
+ ></button>
124
+ <button
125
+ type="button"
126
+ role="slider"
127
+ class="slider-thumb"
128
+ data-thumb="end"
129
+ style="left: ${l}%;"
130
+ aria-label="Maximum"
131
+ aria-valuemin="${e}"
132
+ aria-valuemax="${t}"
133
+ aria-valuenow="${this._end}"
134
+ aria-valuetext="${this._formatValue(this._end)}"
135
+ ${o ? "disabled" : ""}
136
+ ></button>
137
+ ` : `
138
+ <button
139
+ type="button"
140
+ role="slider"
141
+ class="slider-thumb"
142
+ data-thumb="single"
143
+ style="left: ${l}%;"
144
+ aria-valuemin="${e}"
145
+ aria-valuemax="${t}"
146
+ aria-valuenow="${this._value}"
147
+ aria-valuetext="${this._formatValue(this._value)}"
148
+ ${o ? "disabled" : ""}
149
+ aria-label="${i(this.getAttribute("aria-label") || "Value")}"
150
+ ></button>
151
+ `}
152
+ ${this.hasAttribute("show-value") ? n ? `<span class="slider-value">${this._formatValue(this._start)} to ${this._formatValue(this._end)}</span>` : `<span class="slider-value">${this._formatValue(this._value)}</span>` : ""}
153
+ </div>
154
+ `, this._rendered = !0, this._placeParts(), this._syncMirrors(), this._wire();
155
+ }
156
+ _formatValue(e) {
157
+ return `${e}${this.getAttribute("unit") || ""}`;
158
+ }
159
+ _placeParts() {
160
+ let e = this._min(), t = this._max(), n = (n) => t === e ? 0 : (n - e) / (t - e), r = this._isRange(), i = r ? n(this._start) : 0, a = n(r ? this._end : this._value), o = this.querySelector(".slider-fill");
161
+ o && (o.style.left = `${i * 100}%`, o.style.right = `${100 - a * 100}%`, r && o.style.setProperty("--wui-fill-start", String(i)), o.style.setProperty("--wui-fill-end", String(a)));
162
+ let s = (e, t) => {
163
+ e && (e.style.left = `${t * 100}%`, e.style.setProperty("--wui-t", String(t)));
164
+ };
165
+ r ? (s(this.querySelector("[data-thumb=\"start\"]"), i), s(this.querySelector("[data-thumb=\"end\"]"), a)) : s(this.querySelector(".slider-thumb"), a);
166
+ }
167
+ _syncValue() {
168
+ if (this._rendered) if (this._placeParts(), this._isRange()) {
169
+ let e = this.querySelector("[data-thumb=\"start\"]"), t = this.querySelector("[data-thumb=\"end\"]");
170
+ e && (e.setAttribute("aria-valuenow", String(this._start)), e.setAttribute("aria-valuetext", this._formatValue(this._start))), t && (t.setAttribute("aria-valuenow", String(this._end)), t.setAttribute("aria-valuetext", this._formatValue(this._end)));
171
+ let n = this.querySelector(".slider-value");
172
+ n && (n.textContent = `${this._formatValue(this._start)} to ${this._formatValue(this._end)}`);
173
+ } else {
174
+ let e = this.querySelector(".slider-thumb");
175
+ e && (e.setAttribute("aria-valuenow", String(this._value)), e.setAttribute("aria-valuetext", this._formatValue(this._value)));
176
+ let t = this.querySelector(".slider-value");
177
+ t && (t.textContent = this._formatValue(this._value));
178
+ }
179
+ }
180
+ _syncMirrors() {
181
+ this._isRange() ? this._syncRangeMirrors() : this._syncSingleMirror();
182
+ }
183
+ _syncSingleMirror() {
184
+ this.getAttribute("name") && t(this, String(this._value));
185
+ }
186
+ _syncRangeMirrors() {
187
+ let e = this.getAttribute("start-name") || this.getAttribute("name"), t = this.getAttribute("end-name");
188
+ this._mirrorRange("start", e, this._start), this._mirrorRange("end", t, this._end);
189
+ }
190
+ _mirrorRange(e, t, n) {
191
+ if (!t) return;
192
+ let r = this.querySelector(`input[type="hidden"][data-slider-mirror="${e}"]`);
193
+ r || (r = document.createElement("input"), r.type = "hidden", r.setAttribute("data-slider-mirror", e), this.appendChild(r)), r.name = t, r.value = String(n), r.disabled = this.hasAttribute("disabled");
194
+ }
195
+ _valueAtPosition(e) {
196
+ let t = this.querySelector(".slider-track");
197
+ if (!t) return this._min();
198
+ let n = t.getBoundingClientRect(), r = this.querySelector(".slider-thumb"), i = r ? r.offsetWidth / 2 : 0, a = n.width - i * 2, o = a > 0 ? Math.max(0, Math.min(1, (e - n.left - i) / a)) : 0, s = this._min() + o * (this._max() - this._min());
199
+ return this._snapToStep(s);
200
+ }
201
+ _nearestThumb(e) {
202
+ return Math.abs(e - this._start) <= Math.abs(e - this._end) ? "start" : "end";
203
+ }
204
+ _wire() {
205
+ if (this._teardown(), this.hasAttribute("disabled")) return;
206
+ let e = this.querySelectorAll(".slider-thumb"), t = this.querySelector(".slider-track"), n = this._isRange();
207
+ this._pointerDownListener = (e) => {
208
+ if (this.hasAttribute("disabled")) return;
209
+ let t = e.target.closest(".slider-thumb");
210
+ t && (e.preventDefault(), this._isDragging = !0, this._dragThumb = t.getAttribute("data-thumb"), document.addEventListener("pointermove", this._pointerMoveListener), document.addEventListener("pointerup", this._pointerUpListener), document.addEventListener("pointercancel", this._pointerUpListener));
211
+ }, this._pointerMoveListener = (e) => {
212
+ if (!this._isDragging) return;
213
+ e.preventDefault();
214
+ let t = this._valueAtPosition(e.clientX);
215
+ if (this._dragThumb === "single") this._value = this._clamp(t), this._syncValue(), this.dispatchEvent(new CustomEvent("slide", { detail: { value: this._value } }));
216
+ else if (this._dragThumb === "start") {
217
+ let e = Math.min(t, this._end);
218
+ this._start = this._clamp(e), this._syncValue(), this.dispatchEvent(new CustomEvent("slide", { detail: {
219
+ start: this._start,
220
+ end: this._end
221
+ } }));
222
+ } else if (this._dragThumb === "end") {
223
+ let e = Math.max(t, this._start);
224
+ this._end = this._clamp(e), this._syncValue(), this.dispatchEvent(new CustomEvent("slide", { detail: {
225
+ start: this._start,
226
+ end: this._end
227
+ } }));
228
+ }
229
+ }, this._pointerUpListener = () => {
230
+ this._isDragging && (this._isDragging = !1, this._dragThumb = null, document.removeEventListener("pointermove", this._pointerMoveListener), document.removeEventListener("pointerup", this._pointerUpListener), document.removeEventListener("pointercancel", this._pointerUpListener), this._syncMirrors(), this.dispatchEvent(new Event("change", { bubbles: !0 })));
231
+ }, this._thumbKeyListener = (e) => {
232
+ let t = e.currentTarget;
233
+ if (this.hasAttribute("disabled")) return;
234
+ let n = this._step(), r = n * 10, i = null, a = t.getAttribute("data-thumb"), o = a === "end" ? this._end : a === "start" ? this._start : this._value;
235
+ e.key === "ArrowLeft" || e.key === "ArrowDown" ? (e.preventDefault(), i = o - n) : e.key === "ArrowRight" || e.key === "ArrowUp" ? (e.preventDefault(), i = o + n) : e.key === "PageDown" ? (e.preventDefault(), i = o - r) : e.key === "PageUp" ? (e.preventDefault(), i = o + r) : e.key === "Home" ? (e.preventDefault(), i = this._min()) : e.key === "End" && (e.preventDefault(), i = this._max()), i != null && (i = this._clamp(i), a === "single" ? this._value = i : a === "start" ? this._start = Math.min(i, this._end) : a === "end" && (this._end = Math.max(i, this._start)), this._syncValue(), this._syncMirrors(), this.dispatchEvent(new Event("change", { bubbles: !0 })));
236
+ }, this._trackClickListener = (e) => {
237
+ if (this.hasAttribute("disabled")) return;
238
+ let t = this._valueAtPosition(e.clientX);
239
+ n ? this._nearestThumb(t) === "start" ? this._start = Math.min(this._clamp(t), this._end) : this._end = Math.max(this._clamp(t), this._start) : this._value = this._clamp(t), this._syncValue(), this._syncMirrors(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
240
+ }, e.forEach((e) => {
241
+ e.addEventListener("pointerdown", this._pointerDownListener), e.addEventListener("keydown", this._thumbKeyListener);
242
+ }), t?.addEventListener("click", this._trackClickListener);
243
+ }
244
+ _teardown() {
245
+ for (let e of this.querySelectorAll(".slider-thumb")) e.removeEventListener("pointerdown", this._pointerDownListener), e.removeEventListener("keydown", this._thumbKeyListener);
246
+ document.removeEventListener("pointermove", this._pointerMoveListener), document.removeEventListener("pointerup", this._pointerUpListener), document.removeEventListener("pointercancel", this._pointerUpListener), this._isDragging = !1, this._dragThumb = null, this.querySelector(".slider-track")?.removeEventListener("click", this._trackClickListener);
247
+ }
248
+ disconnectedCallback() {
249
+ this._teardown();
250
+ }
251
+ }, r = (e, t) => {
252
+ let n = Number.parseFloat(e);
253
+ return Number.isFinite(n) ? n : t;
254
+ }, i = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
255
+ //#endregion
256
+ export { n as t };