@webority/ui-elements 0.37.0 → 0.38.0

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 (116) hide show
  1. package/dist/WuiAutocomplete-Comrnbmf.js +13 -0
  2. package/dist/WuiCommandPalette-CKna1GlO.js +2 -0
  3. package/dist/WuiConsentBanner-CFll7vxN.js +201 -0
  4. package/dist/WuiContextMenu-CBy0O4HT.js +1 -0
  5. package/dist/WuiCountrySelect-oLBUHvMM.js +1 -0
  6. package/dist/WuiDatePicker-nB1B3eWW.js +31 -0
  7. package/dist/WuiDateRange-Di5YE9mg.js +25 -0
  8. package/dist/WuiDock-BD2HgMmP.js +1 -0
  9. package/dist/WuiImageCrop-Cr3D2iPo.js +17 -0
  10. package/dist/WuiMultiSelect-BUw-7apM.js +25 -0
  11. package/dist/WuiOtp-BbO_75RB.js +14 -0
  12. package/dist/WuiPhone-GJglNelp.js +15 -0
  13. package/dist/WuiSelect-DvtN4qC2.js +14 -0
  14. package/dist/WuiSlider-Br6V2amU.js +49 -0
  15. package/dist/WuiSortable-Bd7Fz5Ox.js +1 -0
  16. package/dist/WuiTagInput-DzEZooIn.js +6 -0
  17. package/dist/WuiTimePicker-Bolpp93P.js +9 -0
  18. package/dist/WuiTour-DiKZEWeb.js +15 -0
  19. package/dist/WuiTree-SA0QU9AF.js +1 -0
  20. package/dist/WuiWizardStep-DIHxrXn9.js +1 -0
  21. package/dist/anchorOverlay-WcDeH46q.js +1 -0
  22. package/dist/calendarMath-BC2wGCD-.js +1 -0
  23. package/dist/countries-CvmZ2xpG.js +1 -0
  24. package/dist/elementBase-BlsR4tqa.js +1 -0
  25. package/dist/elements/autocomplete.js +1 -6
  26. package/dist/elements/command-palette.js +1 -6
  27. package/dist/elements/consent-banner.js +1 -6
  28. package/dist/elements/context-menu.js +1 -6
  29. package/dist/elements/country-select.js +1 -6
  30. package/dist/elements/date-range.js +1 -6
  31. package/dist/elements/datepicker.js +1 -6
  32. package/dist/elements/dock.js +1 -6
  33. package/dist/elements/image-crop.js +1 -6
  34. package/dist/elements/kanban.js +1 -6
  35. package/dist/elements/multiselect.js +1 -6
  36. package/dist/elements/otp.js +1 -6
  37. package/dist/elements/phone.js +1 -6
  38. package/dist/elements/select.js +1 -6
  39. package/dist/elements/slider.js +1 -6
  40. package/dist/elements/sortable.js +1 -6
  41. package/dist/elements/status-icon.js +1 -6
  42. package/dist/elements/taginput.js +1 -6
  43. package/dist/elements/timepicker.js +1 -6
  44. package/dist/elements/tour.js +1 -6
  45. package/dist/elements/tree.js +1 -6
  46. package/dist/elements/wizard.js +1 -5
  47. package/dist/examples.mobile.json-GS1_MGh9.js +1 -0
  48. package/dist/fileViewerImage-Y9QBn2Rj.js +6 -0
  49. package/dist/fileViewerMedia-CaJaVnjE.js +1 -0
  50. package/dist/fileViewerPdf-BN0zuehw.js +19 -0
  51. package/dist/fileViewerUi-DasgDsU-.js +1 -0
  52. package/dist/focusOrigin-2imUSs-u.js +1 -0
  53. package/dist/formMirror-BgY7zkC3.js +1 -0
  54. package/dist/formatters-BAE__8ye.js +1 -0
  55. package/dist/helpers.js +1 -5
  56. package/dist/iconGlyphs.g-CUm_mfze.js +1 -0
  57. package/dist/kanban-CdELdS3U.js +1 -0
  58. package/dist/listboxKeyNav-DMIvs9d6.js +1 -0
  59. package/dist/max-CNrKnpEj.js +17 -0
  60. package/dist/optionLabel-DsX2fhWs.js +1 -0
  61. package/dist/statusIcons-2X4iGkKL.js +10 -0
  62. package/dist/textMatch-wdY7XLIc.js +1 -0
  63. package/dist/themeTransition-lkmQm8FR.js +1 -0
  64. package/dist/tokenCommit-BKckxgtg.js +2 -0
  65. package/dist/ui-calendar.global.js +1 -1
  66. package/dist/ui-calendar.js +1 -9905
  67. package/dist/ui-chart.js +21 -34563
  68. package/dist/ui-chat-core.js +10 -347
  69. package/dist/ui-chat.js +10 -1066
  70. package/dist/ui-elements.global.js +52 -53
  71. package/dist/ui-elements.js +1 -692
  72. package/dist/ui-file-viewer.js +1 -311
  73. package/dist/ui-rich-text.js +193 -16887
  74. package/dist/wuiHttp-BC8co934.js +1 -0
  75. package/package.json +5 -7
  76. package/dist/WuiAutocomplete-ByxnwJNQ.js +0 -283
  77. package/dist/WuiCommandPalette-CtZ04JxZ.js +0 -130
  78. package/dist/WuiConsentBanner-oVe-jxCO.js +0 -399
  79. package/dist/WuiContextMenu-Bx_U2X3t.js +0 -211
  80. package/dist/WuiCountrySelect-CUAwKnL9.js +0 -28
  81. package/dist/WuiDatePicker-DkNbc-z7.js +0 -325
  82. package/dist/WuiDateRange-BocnVO6L.js +0 -233
  83. package/dist/WuiDock-BSDY9g8Q.js +0 -57
  84. package/dist/WuiImageCrop-1yaAONTk.js +0 -462
  85. package/dist/WuiMultiSelect-BrCGRNCt.js +0 -416
  86. package/dist/WuiOtp-D8-4Pqil.js +0 -128
  87. package/dist/WuiPhone-BvbhiP2r.js +0 -731
  88. package/dist/WuiSelect-BXrpiuXG.js +0 -214
  89. package/dist/WuiSlider-BcU0psYf.js +0 -256
  90. package/dist/WuiSortable-JjJqstSU.js +0 -280
  91. package/dist/WuiTagInput-D1ay3OcL.js +0 -158
  92. package/dist/WuiTimePicker-C7n-VFGt.js +0 -370
  93. package/dist/WuiTour-R5O9l--J.js +0 -205
  94. package/dist/WuiTree-DXP7pGeI.js +0 -393
  95. package/dist/WuiWizardStep-BU5w9_Ds.js +0 -221
  96. package/dist/anchorOverlay-DluGZ8ef.js +0 -23
  97. package/dist/calendarMath-BAF2Jkg_.js +0 -42
  98. package/dist/countries-B-M_LTgS.js +0 -1234
  99. package/dist/elementBase-Bg1xpvup.js +0 -9
  100. package/dist/examples.mobile.json-BMXTGiGC.js +0 -250
  101. package/dist/fileViewerImage-Dky4nQZS.js +0 -185
  102. package/dist/fileViewerMedia-DPk_YcvC.js +0 -133
  103. package/dist/fileViewerPdf-BnIsj-J-.js +0 -15799
  104. package/dist/fileViewerUi-R6hlcShk.js +0 -272
  105. package/dist/formMirror-jGf5M4gk.js +0 -29
  106. package/dist/formatters-DusKbTyV.js +0 -138
  107. package/dist/iconGlyphs.g-Cpg1BUHm.js +0 -215
  108. package/dist/kanban-BIiEMkTK.js +0 -985
  109. package/dist/listboxKeyNav-zts_8d5e.js +0 -36
  110. package/dist/max-BDKx469G.js +0 -14478
  111. package/dist/optionLabel-Dn-I7zyp.js +0 -16
  112. package/dist/statusIcons-C3zjycpa.js +0 -37
  113. package/dist/textMatch-DEUjlkdy.js +0 -27
  114. package/dist/themeTransition-BpCuMnjk.js +0 -589
  115. package/dist/tokenCommit-VWz-2jEf.js +0 -20
  116. package/dist/wuiHttp-oeHs7X_c.js +0 -118
@@ -1,985 +0,0 @@
1
- import { t as e } from "./elementBase-Bg1xpvup.js";
2
- import { m as t, s as n, t as r } from "./formatters-DusKbTyV.js";
3
- import { c as i, o as a } from "./wuiHttp-oeHs7X_c.js";
4
- //#region src/remoteModal.js
5
- var o = "wui-remote-modal", s = "wui-modal-fullscreen", c = Object.freeze({
6
- sm: 380,
7
- md: 440,
8
- lg: 640,
9
- xl: 880
10
- }), l = Object.freeze({
11
- loading: "Loading",
12
- close: "Close",
13
- retry: "Try again",
14
- errorTitle: "This could not be loaded",
15
- forbidden: "You do not have access to this.",
16
- client: "It may have been moved or deleted.",
17
- server: "Something went wrong on our side. Try again in a moment.",
18
- network: "Could not reach the server. Check your connection and try again.",
19
- submitFailed: "Your changes were not saved.",
20
- invalid: "Some fields need attention."
21
- }), u = "a[href],button:not([disabled]),input:not([disabled]):not([type=\"hidden\"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex=\"-1\"])", d = "[aria-invalid=\"true\"], .is-invalid, .input-validation-error", f = ".wui-error-summary, [data-wui-form-errors], .validation-summary-errors, [data-valmsg-summary]", p = "[data-wui-modal-content]", m = "<button type=\"button\" class=\"wui-modal-close\" data-bs-dismiss=\"modal\" aria-label=\"Close\"><svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M18 6 6 18M6 6l12 12\"></path></svg></button>", h = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new WeakSet(), _ = () => Object.assign(/* @__PURE__ */ Error("The remote modal load was aborted."), { name: "AbortError" }), ee = (e) => {
22
- let t = window.bootstrap?.Modal;
23
- if (!t) throw Error(`WUI.modal.load(${String(e)}): Bootstrap's bundle (window.bootstrap) is not loaded on this page.`);
24
- return t;
25
- }, v = (e) => {
26
- let t = document.createElement("span");
27
- return t.textContent = e ?? "", t.innerHTML;
28
- };
29
- function te(e) {
30
- if (e == null || e === "") return null;
31
- if (e === "fullscreen") return { fullscreen: !0 };
32
- if (Object.hasOwn(c, e)) return { px: c[e] };
33
- let t = typeof e == "number" ? e : /^\d+$/.test(String(e)) ? Number(e) : NaN;
34
- if (Number.isInteger(t) && t > 0) return { px: t };
35
- throw TypeError(`Unsupported modal size "${String(e)}". Use sm, md, lg, xl, fullscreen or a px number.`);
36
- }
37
- var ne = (e) => {
38
- if (e.classList.contains("wui-modal-fullscreen")) return { fullscreen: !0 };
39
- let t = Number.parseInt(e.style.getPropertyValue("--wui-modal-max-width"), 10);
40
- return { px: t > 0 ? t : c.md };
41
- }, y = (e, t) => {
42
- e.classList.toggle(s, !!t.fullscreen), t.fullscreen ? e.style.removeProperty("--wui-modal-max-width") : e.style.setProperty("--wui-modal-max-width", `${t.px}px`);
43
- }, re = ["center", "top"];
44
- function ie() {
45
- let e = document.getElementById(o);
46
- return e || (e = document.createElement("div"), e.id = o, e.className = "modal fade wui-modal-shell", e.tabIndex = -1, e.setAttribute("aria-hidden", "true"), e.setAttribute("role", "dialog"), e.setAttribute("aria-modal", "true"), e.style.setProperty("--wui-modal-max-width", `${c.md}px`), e.innerHTML = "<div class=\"modal-dialog modal-dialog-centered wui-rb-dialog\"><div class=\"modal-content wui-modal\"></div></div>", document.body.appendChild(e), e);
47
- }
48
- var b = (e) => `<div class="wui-modal-header"><div class="wui-modal-heading"><div class="wui-modal-headtext"><div class="wui-modal-title">${v(e)}</div></div></div>${m}</div>`, ae = (e) => `<div class="modal-content wui-modal" aria-busy="true">${b(e)}<div class="wui-modal-body"><div class="wui-modal-loading" role="status"><span class="visually-hidden">${v(l.loading)}</span><div class="skeleton wui-modal-skeleton"></div><div class="skeleton wui-modal-skeleton"></div><div class="skeleton wui-modal-skeleton wui-modal-skeleton--short"></div></div></div></div>`, oe = (e, t) => `<div class="modal-content wui-modal" data-wui-modal-error="${v(t)}">${b(e)}<div class="wui-modal-body"><div class="wui-modal-state" role="alert"><p class="wui-modal-state-title">${v(l.errorTitle)}</p><p class="wui-modal-state-text">${v(l[t] || l.server)}</p><div class="wui-modal-state-actions"><button type="button" class="btn btn-secondary" data-bs-dismiss="modal">${v(l.close)}</button><button type="button" class="btn btn-primary" data-wui-modal-retry>${v(l.retry)}</button></div></div></div></div>`, x = (e) => {
49
- let t = document.createElement("template");
50
- return t.innerHTML = e, t.content.querySelector(".modal-content");
51
- }, S = (e) => e.shell.querySelector(".modal-content");
52
- function se(e) {
53
- if (!e) return;
54
- e.dispatchEvent(new CustomEvent("wui:teardown", { bubbles: !0 }));
55
- let t = window.bootstrap, n = [
56
- t?.Tooltip,
57
- t?.Popover,
58
- t?.Dropdown
59
- ].filter((e) => e?.getInstance);
60
- for (let t of [e, ...e.querySelectorAll("*")]) for (let e of n) e.getInstance(t)?.dispose();
61
- }
62
- function C(e, t) {
63
- let n = S(e);
64
- se(n), n ? n.replaceWith(t) : e.shell.querySelector(".modal-dialog").appendChild(t), window.WUI?.refresh?.();
65
- }
66
- var w = (e) => e.shell.classList.contains("show");
67
- function T(e, t) {
68
- let n = t && e.querySelector(d), r = n ? n.matches(u) ? n : n.querySelector(u) || n : null;
69
- if (!r) {
70
- let t = [...e.querySelectorAll(u)];
71
- r = e.querySelector("[data-autofocus]") || t.find((e) => !e.classList.contains("wui-modal-close")) || t[0] || e;
72
- }
73
- r.focus?.();
74
- }
75
- function ce(e, t) {
76
- let n = e.shell.querySelector("[data-wui-modal-live]");
77
- n || (n = document.createElement("div"), n.className = "visually-hidden", n.setAttribute("aria-live", "assertive"), n.setAttribute("data-wui-modal-live", ""), e.shell.querySelector(".modal-dialog").appendChild(n)), n.textContent = "", n.textContent = t;
78
- }
79
- var E = (e, t, n) => e.dispatchEvent(new CustomEvent(t, {
80
- bubbles: !0,
81
- detail: n
82
- }));
83
- function D(e) {
84
- let t = h.get(e);
85
- return t || (t = {
86
- shell: e,
87
- queue: a(),
88
- defaultSize: ne(e),
89
- defaultLabel: e.getAttribute("aria-label"),
90
- placeholder: S({ shell: e })?.outerHTML || "<div class=\"modal-content wui-modal\"></div>",
91
- remoteUrl: e.getAttribute("data-wui-remote-url"),
92
- cache: e.getAttribute("data-wui-remote-cache") === "true",
93
- loadedUrl: null,
94
- session: null
95
- }, h.set(e, t), e.addEventListener("submit", (e) => me(t, e)), e.addEventListener("click", (e) => {
96
- !e.target.closest?.("[data-wui-modal-retry]") || !t.session || (e.preventDefault(), j(t, t.session));
97
- }), e.addEventListener("hidden.bs.modal", (n) => {
98
- n.target === e && le(t);
99
- }), e.addEventListener("shown.bs.modal", (n) => {
100
- let r = S(t);
101
- n.target === e && t.session && r?.matches(p) && !r.contains(document.activeElement) && T(r, !1);
102
- }), t.remoteUrl && e.addEventListener("show.bs.modal", (n) => {
103
- n.target === e && ue(t, n);
104
- }), t);
105
- }
106
- function O(e, t, n) {
107
- e.session && (e.queue.abort(), e.session.resolveClosed({
108
- status: "dismissed",
109
- detail: { replaced: !0 }
110
- }));
111
- let r, i = new Promise((e) => {
112
- r = e;
113
- }), a = {
114
- url: t,
115
- method: (n.method || "GET").toUpperCase(),
116
- body: n.body,
117
- options: n,
118
- trigger: n.trigger || null,
119
- explicitSize: null,
120
- closing: null,
121
- resolveClosed: r,
122
- handle: null
123
- };
124
- return a.handle = {
125
- el: e.shell,
126
- closed: i,
127
- close: () => k(e, a, "dismissed", null),
128
- reload: () => j(e, a)
129
- }, e.session = a, a;
130
- }
131
- function k(e, t, n, r) {
132
- e.session === t && (t.closing = {
133
- status: n,
134
- detail: r
135
- }, window.bootstrap?.Modal?.getOrCreateInstance(e.shell).hide());
136
- }
137
- function le(e) {
138
- let t = e.session;
139
- if (e.queue.abort(), e.session = null, t) {
140
- let { status: n, detail: r } = t.closing || {
141
- status: "dismissed",
142
- detail: null
143
- };
144
- t.resolveClosed({
145
- status: n,
146
- detail: r
147
- }), E(e.shell, "wui:modal:closed", {
148
- status: n,
149
- url: t.url
150
- });
151
- let i = document.activeElement;
152
- t.trigger?.isConnected && (!i || i === document.body || e.shell.contains(i)) && t.trigger.focus?.();
153
- }
154
- e.cache || (C(e, x(e.placeholder)), e.loadedUrl = null, y(e.shell, e.defaultSize), e.defaultLabel ? e.shell.setAttribute("aria-label", e.defaultLabel) : e.shell.removeAttribute("aria-label"));
155
- }
156
- function ue(e, t) {
157
- let n = t.relatedTarget instanceof Element ? t.relatedTarget : null, r = n?.getAttribute("data-wui-url") || e.remoteUrl, i = O(e, r, { trigger: n });
158
- i.explicitSize = A(n?.getAttribute("data-wui-size")), i.explicitSize && y(e.shell, i.explicitSize), !(e.cache && e.loadedUrl === r) && (e.loadedUrl && C(e, x(e.placeholder)), j(e, i, { keepPlaceholder: !0 }));
159
- }
160
- function A(e) {
161
- try {
162
- return te(e);
163
- } catch (e) {
164
- return console.error(e), null;
165
- }
166
- }
167
- async function j(e, t, { keepPlaceholder: n = !1 } = {}) {
168
- n || C(e, x(ae(t.options.title || M(e))));
169
- let r = await e.queue.run(t.url, {
170
- method: t.method,
171
- body: t.body,
172
- navigate: t.options.navigate
173
- });
174
- if (e.session !== t || r.kind === "aborted" || r.kind === "stale") return "aborted";
175
- if (r.kind === "session") return "session";
176
- if ((r.kind === "ok" || r.kind === "validation") && N(e, t, r.html, !1)) return e.loadedUrl = t.url, E(e.shell, "wui:modal:loaded", {
177
- url: t.url,
178
- handle: t.handle
179
- }), "loaded";
180
- let i = r.kind === "ok" || r.kind === "validation" ? "server" : r.kind;
181
- return C(e, x(oe(t.options.title || M(e), i))), w(e) && T(S(e), !1), E(e.shell, "wui:modal:error", {
182
- url: t.url,
183
- kind: i,
184
- status: r.status
185
- }), "error";
186
- }
187
- var M = (e) => S(e)?.querySelector(".wui-modal-title")?.textContent || e.shell.getAttribute("aria-label") || "";
188
- function N(e, t, n, r) {
189
- let i = document.createElement("template");
190
- i.innerHTML = n;
191
- let a = i.content.querySelectorAll("script");
192
- if (a.length) {
193
- console.warn(`WUI.modal: ${t.url} returned a fragment with script; it was removed. Keep page behaviour in the page.`);
194
- for (let e of a) e.remove();
195
- }
196
- let o = i.content.querySelector(p);
197
- if (!o) return console.error(`WUI.modal: ${t.url} did not answer with an <app-modal-content> fragment.`), !1;
198
- C(e, o), y(e.shell, t.explicitSize || A(o.getAttribute("data-wui-size")) || e.defaultSize);
199
- let s = o.getAttribute("data-wui-title");
200
- return s && e.shell.setAttribute("aria-label", s), w(e) && T(o, r), !0;
201
- }
202
- var de = "button[type=\"submit\"], button:not([type]), input[type=\"submit\"], input[type=\"image\"]";
203
- function P(e, t, n) {
204
- let r = [...e.elements].filter((e) => e.matches(de));
205
- if (n) {
206
- e.setAttribute("data-wui-submitting", "");
207
- let n = t && r.includes(t) ? t : r[0];
208
- for (let e of r) e.toggleAttribute("data-wui-was-disabled", e.disabled), e.disabled = !0;
209
- n && (n.classList.add("is-loading"), n.setAttribute("aria-busy", "true"), n.tagName === "BUTTON" && n.insertAdjacentHTML("afterbegin", "<span class=\"spinner-border spinner-border-sm me-2\" aria-hidden=\"true\" data-wui-submit-spinner></span>"));
210
- return;
211
- }
212
- e.removeAttribute("data-wui-submitting");
213
- for (let e of r) e.disabled = e.hasAttribute("data-wui-was-disabled"), e.removeAttribute("data-wui-was-disabled"), e.classList.remove("is-loading"), e.removeAttribute("aria-busy"), e.querySelector("[data-wui-submit-spinner]")?.remove();
214
- }
215
- function fe(e, t, n) {
216
- let r = t.closest(".wui-modal-body") || t;
217
- r.querySelector("[data-wui-modal-submit-error]")?.remove();
218
- let i = document.createElement("div");
219
- i.className = "alert alert-danger wui-modal-submit-error", i.setAttribute("role", "alert"), i.setAttribute("data-wui-modal-submit-error", ""), i.textContent = `${l.submitFailed} ${l[n] || l.server}`, r.prepend(i), ce(e, i.textContent);
220
- }
221
- var pe = (e, t) => {
222
- let n = new URL(e, window.location.href);
223
- for (let [e, r] of t) typeof r == "string" && n.searchParams.append(e, r);
224
- return n.origin === window.location.origin ? n.pathname + n.search : n.href;
225
- };
226
- async function me(e, t) {
227
- let n = t.target, r = e.session;
228
- if (!(n instanceof HTMLFormElement) || !r || n.hasAttribute("data-wui-native") || !n.closest(p) || (t.preventDefault(), n.hasAttribute("data-wui-submitting"))) return;
229
- let i = t.submitter || null, a = i?.getAttribute("formaction") || n.getAttribute("action") || r.url, o = (i?.getAttribute("formmethod") || n.getAttribute("method") || "GET").toUpperCase(), s = new FormData(n);
230
- i?.name && !s.has(i.name) && s.append(i.name, i.value);
231
- let c = o === "GET";
232
- P(n, i, !0);
233
- let u = await e.queue.run(c ? pe(a, s) : a, {
234
- method: o,
235
- body: c ? void 0 : s,
236
- navigate: r.options.navigate
237
- });
238
- if (e.session === r) {
239
- if (n.isConnected && P(n, i, !1), u.kind === "ok" && u.result === "success") {
240
- he(e, r, u);
241
- return;
242
- }
243
- if (!(u.kind === "aborted" || u.kind === "stale" || u.kind === "session")) {
244
- if (u.kind === "validation" && N(e, r, u.html, !0)) {
245
- let t = S(e).querySelector(f)?.textContent.replace(/\s+/g, " ").trim();
246
- ce(e, t || l.invalid);
247
- return;
248
- }
249
- u.kind === "ok" && u.html && N(e, r, u.html, !1) || fe(e, n, u.kind === "ok" || u.kind === "validation" ? "server" : u.kind);
250
- }
251
- }
252
- }
253
- function he(e, t, n) {
254
- let r = n.message, i = n.redirect || null, a = {
255
- url: t.url,
256
- trigger: t.trigger,
257
- handle: t.handle,
258
- message: r,
259
- redirect: i
260
- };
261
- if (r && window.WUI?.toast?.(r, { variant: "success" }), E(t.trigger?.isConnected ? t.trigger : document, "wui:modal:success", a), t.options.onSuccess?.(a, t.handle), i && (t.options.navigate || ((e) => window.location.assign(e)))(i), n.keepOpen) {
262
- n.html && N(e, t, n.html, !1);
263
- return;
264
- }
265
- k(e, t, "success", a);
266
- }
267
- function ge(e) {
268
- let t = e.target.closest?.("[data-wui-modal]");
269
- t && (t.matches("a[href]") && (e.ctrlKey || e.metaKey || e.shiftKey || e.button !== 0) || (e.preventDefault(), I(t.getAttribute("data-wui-modal"), {
270
- size: t.getAttribute("data-wui-size") || void 0,
271
- title: t.getAttribute("data-wui-title") || void 0,
272
- trigger: t
273
- }).catch((e) => {
274
- e?.name !== "AbortError" && console.error(e);
275
- })));
276
- }
277
- function F(e = document) {
278
- let t = e.ownerDocument || e;
279
- g.has(t) || (g.add(t), t.addEventListener("click", ge));
280
- let n = [...e.querySelectorAll?.(".modal[data-wui-remote-url]") || []];
281
- e.matches?.(".modal[data-wui-remote-url]") && n.unshift(e);
282
- for (let e of n) D(e);
283
- }
284
- function I(e, t = {}) {
285
- try {
286
- if (!e) throw TypeError("WUI.modal.load: a fragment url is required.");
287
- let n = ee(e), r = te(t.size), i = t.placement || "center";
288
- if (!re.includes(i)) throw TypeError(`WUI.modal.load: unsupported placement "${i}". Use center or top.`);
289
- if (t.signal?.aborted) return Promise.reject(_());
290
- let a = ie();
291
- F(document);
292
- let o = D(a), s = w(o), c = O(o, e, t);
293
- c.explicitSize = r, y(a, r || o.defaultSize), a.querySelector(".modal-dialog").classList.toggle("modal-dialog-centered", i === "center"), t.title && a.setAttribute("aria-label", t.title), s || (n.getInstance(a)?.dispose(), n.getOrCreateInstance(a, {
294
- backdrop: !t.staticBackdrop || "static",
295
- keyboard: !t.staticBackdrop
296
- }));
297
- let l = s ? Promise.resolve() : new Promise((e) => a.addEventListener("shown.bs.modal", () => e(), { once: !0 })), u = j(o, c);
298
- s || n.getOrCreateInstance(a).show();
299
- let d = new Promise((e, n) => {
300
- t.signal?.addEventListener("abort", () => {
301
- o.session === c && (o.queue.abort(), k(o, c, "dismissed", { aborted: !0 })), n(_());
302
- }, { once: !0 });
303
- }), f = Promise.all([l, u]).then(([, t]) => {
304
- if (t === "aborted") throw _();
305
- if (t === "session") throw Error(`WUI.modal.load(${e}): the session expired; the browser is signing in again.`);
306
- return c.handle;
307
- });
308
- return Promise.race([f, d]);
309
- } catch (e) {
310
- return Promise.reject(e);
311
- }
312
- }
313
- //#endregion
314
- //#region src/kanban.js
315
- var _e = Object.freeze([
316
- "neutral",
317
- "primary",
318
- "info",
319
- "success",
320
- "warning",
321
- "danger"
322
- ]), L = Object.freeze([
323
- "number",
324
- "currency",
325
- "compact"
326
- ]), R = "wui-kanban:", ve = "(max-width: 767.98px)", ye = 400, be = 6, z = Object.freeze({
327
- help: "Press Space to pick up the card. Use the Left and Right arrow keys to choose a column, then Space to drop it, or Escape to cancel.",
328
- empty: "Nothing here",
329
- collapse: (e) => `Collapse ${e}`,
330
- expand: (e) => `Expand ${e}`,
331
- lifted: (e, t) => `Picked up ${e} in ${t}. Use the Left and Right arrow keys to choose a column.`,
332
- over: (e, t) => `${e}, ${t === 1 ? "1 card" : `${t} cards`}. Drop allowed.`,
333
- overSource: (e) => `${e}, where the card started.`,
334
- overRefused: (e, t) => `${e}. ${t}`,
335
- dropHere: (e, t) => `Drop here to move ${e} to ${t}.`,
336
- refused: (e, t) => `Cards in ${e} cannot move to ${t}.`,
337
- moved: (e, t) => `Moved ${e} to ${t}.`,
338
- saving: (e, t) => `Moving ${e} to ${t}.`,
339
- cancelled: (e) => `${e} was not moved.`,
340
- rolledBack: (e, t) => `${e} went back to ${t}.`,
341
- locked: (e) => `${e} cannot be moved.`,
342
- more: (e) => `Show ${e} more`,
343
- fewer: "Show fewer",
344
- swipeHint: "Swipe sideways or tap a column",
345
- busy: "This card is still saving. Try again in a moment.",
346
- failed: Object.freeze({
347
- forbidden: "You do not have permission to move this card.",
348
- client: "This card could not be moved. Refresh the board and try again.",
349
- validation: "This card could not be moved. Refresh the board and try again.",
350
- server: "Something went wrong on our side, so the card went back. Try again in a moment.",
351
- network: "Could not reach the server, so the card went back. Check your connection and try again."
352
- })
353
- }), B = "[data-wui-column]", V = "[data-wui-body]", H = "[data-wui-card]", xe = "[data-wui-count]", Se = "[data-wui-summary]", Ce = "[data-wui-empty]", we = "[data-wui-drop-note]", Te = "[data-wui-live]", Ee = "[data-wui-help]", U = "[data-wui-switch]", De = "[data-wui-scroller]", Oe = "[data-wui-collapse]", ke = "[data-wui-more]", Ae = "data-wui-visible-limit", W = "data-wui-overflow", je = "input, select, textarea, [contenteditable=\"\"], [contenteditable=\"true\"], [data-wui-no-drag]", G = 48, K = 16, q = (e) => e.getAttribute("data-wui-column"), J = (e) => e.getAttribute("data-wui-card"), Y = (e) => e.hidden || e.hasAttribute("hidden"), Me = (e) => Y(e) || e.hasAttribute(W);
354
- function Ne(e) {
355
- if (e == null || e === "") return null;
356
- let t = typeof e == "number" ? e : Number(e);
357
- if (!Number.isInteger(t) || t < 1) throw TypeError(`Unsupported kanban visible limit "${String(e)}". Use a whole number of 1 or more.`);
358
- return t;
359
- }
360
- function Pe(e, t, n, r) {
361
- let i = /* @__PURE__ */ new Set();
362
- if (t == null || n) return i;
363
- let a = 0;
364
- for (let n of e) r.has(n) || (a < t ? a++ : i.add(n));
365
- return i;
366
- }
367
- function X(e) {
368
- let t = (e.getAttribute("aria-label") || e.textContent || "").replace(/\s+/g, " ").trim();
369
- return t.length > 80 ? `${t.slice(0, 79)}…` : t || J(e) || "Card";
370
- }
371
- function Z(e) {
372
- return e ? `${R}${e}` : null;
373
- }
374
- function Q(e, t = globalThis.localStorage) {
375
- let n = Z(e);
376
- if (!n || !t) return {};
377
- try {
378
- let e = JSON.parse(t.getItem(n) || "null");
379
- return e && typeof e.collapsed == "object" && e.collapsed ? e.collapsed : {};
380
- } catch {
381
- return {};
382
- }
383
- }
384
- function Fe(e, t, n, r = globalThis.localStorage) {
385
- let i = Z(e);
386
- if (!i || !r) return;
387
- let a = {
388
- ...Q(e, r),
389
- [t]: !!n
390
- };
391
- try {
392
- r.setItem(i, JSON.stringify({ collapsed: a }));
393
- } catch {}
394
- }
395
- function Ie(e, t) {
396
- if (!L.includes(e)) throw TypeError(`Unsupported kanban summary format "${String(e)}". Use ${L.join(", ")}.`);
397
- if (t != null && t !== "" && !n.includes(t)) throw TypeError(`Unsupported kanban summary unit "${String(t)}". Use ${n.join(", ")}.`);
398
- return e === "currency" ? {
399
- style: "currency",
400
- unit: t || "rupees"
401
- } : e === "compact" ? {
402
- style: "compact",
403
- currency: r[0],
404
- unit: t || "rupees"
405
- } : {
406
- style: "number",
407
- decimals: 0
408
- };
409
- }
410
- function Le(e) {
411
- let t = 0;
412
- for (let n of e) {
413
- if (n == null || n === "") continue;
414
- let e = typeof n == "number" ? n : Number(n);
415
- Number.isFinite(e) && (t += e);
416
- }
417
- return t;
418
- }
419
- var $ = (e, t) => {
420
- e && window.WUI?.toast?.(e, { variant: t });
421
- }, Re = class extends e {
422
- constructor() {
423
- super(), this._wired = !1, this._filter = null, this._expanded = /* @__PURE__ */ new Set(), this._revealed = /* @__PURE__ */ new Set(), this._press = null, this._drag = null, this._kbd = null, this._suppressClick = !1, this._observer = null, this._refreshQueued = !1, this._scrollTimer = 0, this._onPointerMove = (e) => this._pointerMove(e), this._onPointerUp = (e) => this._pointerUp(e), this._onPointerCancel = () => this._endPointer(!1), this._onDocKeyDown = (e) => {
424
- e.key === "Escape" && this._drag && (e.preventDefault(), this._endPointer(!1));
425
- }, this._onScroll = () => {
426
- clearTimeout(this._scrollTimer), this._scrollTimer = setTimeout(() => this._syncSwitcherFromScroll(), 80);
427
- };
428
- }
429
- _controlled() {
430
- return this.hasAttribute("controlled");
431
- }
432
- connectedCallback() {
433
- if (!this._wired) {
434
- this._wired = !0, this.addEventListener("pointerdown", (e) => this._pointerDown(e)), this.addEventListener("keydown", (e) => this._keyDown(e)), this.addEventListener("click", (e) => this._click(e), !0), this.addEventListener("dragstart", (e) => {
435
- e.target.closest?.(H) && e.preventDefault();
436
- }), this.addEventListener("touchmove", (e) => {
437
- this._drag && e.preventDefault();
438
- }, { passive: !1 }), this._scroller()?.addEventListener("scroll", this._onScroll, { passive: !0 }), this._restoreCollapsed();
439
- for (let e of this._allCards()) this._prepareCard(e);
440
- if (typeof MutationObserver == "function") {
441
- this._observer = new MutationObserver((e) => {
442
- for (let t of e) for (let e of t.addedNodes) e.nodeType === 1 && e.matches(H) && this._prepareCard(e);
443
- this._queueRefresh();
444
- });
445
- for (let e of this.querySelectorAll(V)) this._observer.observe(e, { childList: !0 });
446
- }
447
- this.refresh();
448
- }
449
- }
450
- disconnectedCallback() {
451
- this._endPointer(!1), this._observer?.disconnect(), this._observer = null, this._scroller()?.removeEventListener("scroll", this._onScroll), clearTimeout(this._scrollTimer), this._wired = !1;
452
- }
453
- setFilter(e) {
454
- if (e != null && typeof e != "function") throw TypeError("wui-kanban setFilter: pass a function or null.");
455
- if (this._filter = e, !e) for (let e of this._allCards()) e.hidden = !1;
456
- this.refresh();
457
- }
458
- refresh() {
459
- if (this._controlled()) return;
460
- this._refreshQueued = !1;
461
- let e = this._summaryFormat();
462
- for (let n of this._columns()) {
463
- let r = q(n), i = Ne(n.getAttribute(Ae)), a = [], o = [];
464
- for (let e of this._cardsIn(n)) {
465
- if (this._filter && (e.hidden = this._filter(e) === !1), Y(e)) {
466
- e.removeAttribute(W);
467
- continue;
468
- }
469
- a.push(e), o.push(e.getAttribute("data-wui-value"));
470
- }
471
- let s = this._expanded.has(r), c = Pe(a.map(J), i, s, this._revealed);
472
- for (let e of a) e.toggleAttribute(W, c.has(J(e)));
473
- let l = String(a.length);
474
- for (let e of this._countsOf(n)) e.textContent !== l && (e.textContent = l);
475
- let u = n.querySelector(Ce);
476
- if (u && (u.hidden = a.length > 0), e) {
477
- let r = n.querySelector(Se);
478
- r && (r.textContent = t(Le(o), e));
479
- }
480
- let d = n.querySelector(ke);
481
- if (d) {
482
- d.hidden = i == null || (s ? a.length <= i : c.size === 0), d.setAttribute("aria-expanded", s ? "true" : "false");
483
- let e = s ? z.fewer : z.more(c.size);
484
- d.textContent !== e && (d.textContent = e);
485
- }
486
- }
487
- }
488
- moveCard(e, t, n) {
489
- let r = this._cardByKey(e);
490
- if (!r) throw Error(`wui-kanban moveCard: no card "${String(e)}" on this board.`);
491
- if (!this._columnByKey(t)) throw Error(`wui-kanban moveCard: no column "${String(t)}" on this board.`);
492
- return this._commit(r, t, n);
493
- }
494
- _columns() {
495
- return [...this.querySelectorAll(B)];
496
- }
497
- _columnByKey(e) {
498
- return this._columns().find((t) => q(t) === e) || null;
499
- }
500
- _columnOf(e) {
501
- return e.closest(B);
502
- }
503
- _titleOf(e) {
504
- return (e.querySelector(".wui-kanban-title")?.textContent || q(e) || "").replace(/\s+/g, " ").trim();
505
- }
506
- _bodyOf(e) {
507
- return e.querySelector(V);
508
- }
509
- _cardsIn(e) {
510
- let t = this._bodyOf(e);
511
- return t ? [...t.children].filter((e) => e.matches(H)) : [];
512
- }
513
- _visibleCardsIn(e) {
514
- return this._cardsIn(e).filter((e) => !Me(e));
515
- }
516
- _allCards() {
517
- return [...this.querySelectorAll(`${V} > ${H}`)];
518
- }
519
- _cardByKey(e) {
520
- return this._allCards().find((t) => J(t) === e) || null;
521
- }
522
- _countsOf(e) {
523
- let t = q(e), n = [...this.querySelectorAll(U)].filter((e) => e.getAttribute("data-wui-switch") === t);
524
- return [...e.querySelectorAll(xe), ...n.flatMap((e) => [...e.querySelectorAll(xe)])];
525
- }
526
- _scroller() {
527
- return this.querySelector(De);
528
- }
529
- _summaryFormat() {
530
- let e = this.getAttribute("summary-format");
531
- return e ? Ie(e, this.getAttribute("summary-unit")) : null;
532
- }
533
- _queueRefresh() {
534
- this._refreshQueued || (this._refreshQueued = !0, queueMicrotask(() => {
535
- this._refreshQueued && this.refresh();
536
- }));
537
- }
538
- _prepareCard(e) {
539
- let t = this.querySelector(Ee);
540
- t?.id && !e.hasAttribute("aria-describedby") && e.setAttribute("aria-describedby", t.id), e.hasAttribute("tabindex") || (e.tabIndex = 0);
541
- }
542
- _announce(e) {
543
- let t = this.querySelector(Te);
544
- !t || !e || (t.textContent = "", t.textContent = e);
545
- }
546
- _fire(e, t, n = !1) {
547
- return this.dispatchEvent(new CustomEvent(e, {
548
- bubbles: !0,
549
- cancelable: n,
550
- detail: t
551
- }));
552
- }
553
- _canLift(e) {
554
- let t = X(e), n = this.hasAttribute("readonly");
555
- return n || e.hasAttribute("data-wui-locked") ? (this._announce(z.locked(t)), this._fire("wui:kanban:locked", {
556
- key: J(e),
557
- card: e,
558
- reason: n ? "readonly" : "locked"
559
- }, !0), !1) : e.getAttribute("aria-busy") === "true" ? (this._announce(z.busy), $(z.busy, "info"), !1) : !0;
560
- }
561
- _check(e, t, n) {
562
- if (t === n) return {
563
- ok: !1,
564
- source: !0,
565
- reason: null
566
- };
567
- let r = this._columnByKey(t), i = this._columnByKey(n), a = z.refused(r ? this._titleOf(r) : t, i ? this._titleOf(i) : n), o = i?.getAttribute("data-accept-from");
568
- if (o != null && !o.split(/\s+/).filter(Boolean).includes(t)) return {
569
- ok: !1,
570
- reason: a
571
- };
572
- if (typeof this.accept == "function") {
573
- let r = this.accept(e, t, n);
574
- if (r === !1) return {
575
- ok: !1,
576
- reason: a
577
- };
578
- if (typeof r == "string" && r) return {
579
- ok: !1,
580
- reason: r
581
- };
582
- }
583
- return {
584
- ok: !0,
585
- reason: null
586
- };
587
- }
588
- _markTargets(e, t) {
589
- let n = X(e), r = /* @__PURE__ */ new Map();
590
- for (let i of this._columns()) {
591
- let a = q(i), o = this._check(e, t, a);
592
- r.set(a, o), i.setAttribute("data-wui-drop", o.source ? "source" : o.ok ? "ok" : "refused");
593
- let s = i.querySelector(we);
594
- s && !o.source && (s.textContent = o.ok ? z.dropHere(n, this._titleOf(i)) : o.reason, s.hidden = !1);
595
- }
596
- return r;
597
- }
598
- _clearTargets() {
599
- for (let e of this._columns()) {
600
- e.removeAttribute("data-wui-drop"), e.removeAttribute("data-wui-over"), e.removeAttribute("data-wui-target");
601
- let t = e.querySelector(we);
602
- t && (t.hidden = !0, t.textContent = "");
603
- }
604
- }
605
- async _commit(e, t, n) {
606
- let r = this._columnOf(e), a = q(r), o = this._columnByKey(t), s = X(e);
607
- if (a === t || !this._canLift(e)) return !1;
608
- let c = this._check(e, a, t);
609
- if (!c.ok) return this._announce(c.reason), $(c.reason, "info"), !1;
610
- let l = this._cardsIn(o), u = Number.isInteger(n) ? Math.max(0, Math.min(n, l.length)) : l.length, d = {
611
- key: J(e),
612
- card: e,
613
- from: a,
614
- to: t,
615
- index: u
616
- }, f = e.contains(document.activeElement);
617
- if (this._controlled()) return this._fire("wui:kanban:move", d), this._announce(z.moved(s, this._titleOf(o))), f && this._refocusSoon(d.key), !0;
618
- if (!this._fire("wui:kanban:move", d, !0)) return !1;
619
- let p = o.hasAttribute(Ae) && !this._revealed.has(d.key);
620
- p && this._revealed.add(d.key);
621
- let m = {
622
- parent: e.parentNode,
623
- next: e.nextSibling,
624
- column: r,
625
- revealed: p
626
- };
627
- this._bodyOf(o).insertBefore(e, l[u] || null), f && this._focusMoved(e), this.refresh();
628
- let h = o.getAttribute("data-wui-step");
629
- if (h) return this._runStep(e, d, m, h, o.getAttribute("data-wui-step-size"));
630
- let g = this.getAttribute("move-url");
631
- if (!g) return this._announce(z.moved(s, this._titleOf(o))), this._fire("wui:kanban:moved", {
632
- ...d,
633
- result: null
634
- }), !0;
635
- this._lock(e, !0), this._announce(z.saving(s, this._titleOf(o)));
636
- let _ = await i(g, {
637
- method: "POST",
638
- body: new URLSearchParams({
639
- card: d.key,
640
- from: a,
641
- to: t,
642
- index: String(u)
643
- })
644
- });
645
- if (this._lock(e, !1), _.kind === "session") return !1;
646
- if (_.ok) {
647
- let t = this._applyFragment(_.html) || e;
648
- return $(_.message, "success"), this._announce(z.moved(X(t), this._titleOf(o))), this._fire("wui:kanban:moved", {
649
- ...d,
650
- card: t,
651
- result: _
652
- }), !0;
653
- }
654
- return this._rollback(e, m), _.kind !== "aborted" && $(_.message || z.failed[_.kind] || z.failed.server, "danger"), this._fire("wui:kanban:failed", {
655
- ...d,
656
- kind: _.kind,
657
- status: _.status,
658
- message: _.message
659
- }), !1;
660
- }
661
- async _runStep(e, t, n, r, a) {
662
- let o = X(e), s = this._columnByKey(t.to), c = new URLSearchParams({
663
- card: t.key,
664
- from: t.from,
665
- to: t.to
666
- }).toString(), l = r + (r.includes("?") ? "&" : "?") + c;
667
- this._lock(e, !0);
668
- let u;
669
- try {
670
- u = await (await I(l, {
671
- trigger: e,
672
- size: a || void 0
673
- })).closed;
674
- } catch (r) {
675
- return this._lock(e, !1), this._rollback(e, n), r?.name !== "AbortError" && $(z.failed.server, "danger"), this._fire("wui:kanban:failed", {
676
- ...t,
677
- kind: "step",
678
- status: 0,
679
- message: r?.message ?? null
680
- }), !1;
681
- }
682
- if (u?.status !== "success") return this._lock(e, !1), this._rollback(e, n), this._announce(z.cancelled(o)), this._fire("wui:kanban:failed", {
683
- ...t,
684
- kind: "dismissed",
685
- status: 0,
686
- message: null
687
- }), !1;
688
- let d = e, f = this.getAttribute("card-url");
689
- if (f) {
690
- let n = await i(`${f}${f.includes("?") ? "&" : "?"}${new URLSearchParams({ card: t.key })}`);
691
- n.ok && (d = this._applyFragment(n.html) || e);
692
- }
693
- return this._lock(d, !1), this._announce(z.moved(X(d), this._titleOf(s))), this._fire("wui:kanban:moved", {
694
- ...t,
695
- card: d,
696
- result: u
697
- }), !0;
698
- }
699
- _lock(e, t) {
700
- t ? (e.setAttribute("aria-busy", "true"), e.setAttribute("data-wui-saving", "")) : (e.removeAttribute("aria-busy"), e.removeAttribute("data-wui-saving"));
701
- }
702
- _rollback(e, t) {
703
- let n = e.contains(document.activeElement), r = t.next && t.next.parentNode === t.parent ? t.next : null;
704
- t.revealed && this._revealed.delete(J(e)), t.parent.insertBefore(e, r), n && e.focus(), this.refresh(), this._announce(z.rolledBack(X(e), this._titleOf(t.column)));
705
- }
706
- _applyFragment(e) {
707
- if (!e) return null;
708
- let t = document.createElement("template");
709
- t.innerHTML = e;
710
- for (let e of t.content.querySelectorAll("script")) console.warn("[@webority/ui-elements] A kanban fragment carried a script tag; it was removed, not run."), e.remove();
711
- let n = null;
712
- for (let e of [...t.content.querySelectorAll(H)]) {
713
- if (e.closest("template")) continue;
714
- let t = this._cardByKey(J(e));
715
- if (!t) continue;
716
- let r = t.contains(document.activeElement);
717
- t.dispatchEvent(new CustomEvent("wui:teardown", { bubbles: !0 })), t.hidden && (e.hidden = !0), t.replaceWith(e), this._prepareCard(e), r && e.focus(), n ??= e;
718
- }
719
- for (let e of t.content.querySelectorAll("template[data-wui-kanban-summary]")) this._columnByKey(e.getAttribute("data-wui-kanban-summary"))?.querySelector(Se)?.replaceChildren(e.content.cloneNode(!0));
720
- return this.refresh(), window.WUI?.refresh?.(), n;
721
- }
722
- _refocusSoon(e) {
723
- let t = () => {
724
- let t = this._cardByKey(e);
725
- t && this._focusMoved(t);
726
- };
727
- typeof requestAnimationFrame == "function" ? requestAnimationFrame(t) : setTimeout(t, 0);
728
- }
729
- _focusMoved(e) {
730
- e.focus({ preventScroll: !0 }), e.scrollIntoView?.({ block: "nearest" });
731
- }
732
- _pointerDown(e) {
733
- if (e.button !== 0 || e.isPrimary === !1 || this._drag || this._kbd) return;
734
- let t = e.target.closest?.(H);
735
- if (!t || !this.contains(t) || e.target.closest(je)) return;
736
- let n = {
737
- card: t,
738
- id: e.pointerId,
739
- x: e.clientX,
740
- y: e.clientY,
741
- type: e.pointerType,
742
- timer: 0
743
- };
744
- this._press = n, e.pointerType === "touch" && (n.timer = setTimeout(() => {
745
- this._press === n && this._startDrag(n, n.x, n.y);
746
- }, 400)), window.addEventListener("pointermove", this._onPointerMove), window.addEventListener("pointerup", this._onPointerUp), window.addEventListener("pointercancel", this._onPointerCancel);
747
- }
748
- _pointerMove(e) {
749
- let t = this._press;
750
- if (!(!t || e.pointerId !== t.id)) {
751
- if (!this._drag) {
752
- if (!(Math.hypot(e.clientX - t.x, e.clientY - t.y) > 6)) return;
753
- if (t.type === "touch") {
754
- this._endPointer(!1);
755
- return;
756
- }
757
- if (this._startDrag(t, e.clientX, e.clientY), !this._drag) return;
758
- }
759
- this._dragTo(e.clientX, e.clientY);
760
- }
761
- }
762
- _pointerUp(e) {
763
- !this._press || e.pointerId !== this._press.id || this._endPointer(!!this._drag);
764
- }
765
- _startDrag(e, t, n) {
766
- let r = e.card;
767
- if (!this._canLift(r)) {
768
- this._endPointer(!1);
769
- return;
770
- }
771
- let i = q(this._columnOf(r)), a = r.getBoundingClientRect(), o = r.cloneNode(!0);
772
- for (let e of [o, ...o.querySelectorAll("[id]")]) e.removeAttribute("id");
773
- o.removeAttribute("data-wui-card"), o.removeAttribute("tabindex"), o.setAttribute("aria-hidden", "true"), o.classList.add("wui-kanban-ghost"), o.style.width = `${a.width}px`, this.appendChild(o), r.setAttribute("data-wui-dragging", ""), this.setAttribute("data-wui-dragging", ""), this._drag = {
774
- card: r,
775
- from: i,
776
- ghost: o,
777
- dx: t - a.left,
778
- dy: n - a.top,
779
- over: null,
780
- verdicts: this._markTargets(r, i)
781
- }, this._announce(z.lifted(X(r), this._titleOf(this._columnOf(r)))), document.addEventListener("keydown", this._onDocKeyDown), this._dragTo(t, n);
782
- }
783
- _dragTo(e, t) {
784
- let n = this._drag;
785
- n.x = e, n.y = t, n.ghost.style.transform = `translate(${e - n.dx}px, ${t - n.dy}px)`;
786
- let r = this._columnAt(e, t);
787
- r !== n.over && (n.over?.removeAttribute("data-wui-over"), r?.setAttribute("data-wui-over", ""), n.over = r), this._autoScroll(e, t, r);
788
- }
789
- _columnAt(e, t) {
790
- for (let n of this._columns()) {
791
- let r = n.getBoundingClientRect();
792
- if (e >= r.left && e <= r.right && t >= r.top && t <= r.bottom) return n;
793
- }
794
- return null;
795
- }
796
- _indexAt(e, t) {
797
- let n = this._visibleCardsIn(e).filter((e) => e !== this._drag?.card).find((e) => {
798
- let n = e.getBoundingClientRect();
799
- return t < n.top + n.height / 2;
800
- }), r = this._cardsIn(e).filter((e) => e !== this._drag?.card);
801
- return n ? r.indexOf(n) : r.length;
802
- }
803
- _autoScroll(e, t, n) {
804
- let r = this._scroller();
805
- if (r) {
806
- let t = r.getBoundingClientRect();
807
- t.width > 0 && (e < t.left + G ? r.scrollBy?.({ left: -16 }) : e > t.right - G && r.scrollBy?.({ left: K }));
808
- }
809
- if (n && this._scrollColumn(n, t)) return;
810
- let i = window.innerHeight || 0;
811
- i > 0 && (t < G ? window.scrollBy?.({ top: -16 }) : t > i - G && window.scrollBy?.({ top: K }));
812
- }
813
- _scrollColumn(e, t) {
814
- let n = this._bodyOf(e);
815
- if (!n || e.hasAttribute("data-collapsed") || n.scrollHeight <= n.clientHeight) return !1;
816
- let r = n.getBoundingClientRect();
817
- return t < r.top + G && n.scrollTop > 0 ? (n.scrollBy?.({ top: -16 }), !0) : t > r.bottom - G && n.scrollTop + n.clientHeight < n.scrollHeight - 1 ? (n.scrollBy?.({ top: K }), !0) : !1;
818
- }
819
- _endPointer(e) {
820
- let t = this._press, n = this._drag;
821
- if (t && clearTimeout(t.timer), this._press = null, this._drag = null, window.removeEventListener("pointermove", this._onPointerMove), window.removeEventListener("pointerup", this._onPointerUp), window.removeEventListener("pointercancel", this._onPointerCancel), document.removeEventListener("keydown", this._onDocKeyDown), !n) return;
822
- n.ghost.remove(), n.card.removeAttribute("data-wui-dragging"), this.removeAttribute("data-wui-dragging"), this._suppressClick = !0, setTimeout(() => {
823
- this._suppressClick = !1;
824
- }, 0);
825
- let r = n.over;
826
- if (this._clearTargets(), !e || !r) {
827
- this._announce(z.cancelled(X(n.card)));
828
- return;
829
- }
830
- let i = q(r), a = n.verdicts.get(i);
831
- if (a?.source) {
832
- this._announce(z.cancelled(X(n.card)));
833
- return;
834
- }
835
- if (!a?.ok) {
836
- this._announce(a?.reason), $(a?.reason, "info");
837
- return;
838
- }
839
- this._commit(n.card, i, this._indexAt(r, n.y));
840
- }
841
- _click(e) {
842
- if (this._suppressClick && e.target.closest?.(H)) {
843
- e.preventDefault(), e.stopPropagation(), this._suppressClick = !1;
844
- return;
845
- }
846
- let t = e.target.closest?.(Oe);
847
- if (t && this.contains(t)) {
848
- let e = t.closest(B);
849
- e && this._setCollapsed(e, !e.hasAttribute("data-collapsed"), !0);
850
- return;
851
- }
852
- let n = e.target.closest?.(ke);
853
- if (n && this.contains(n)) {
854
- this._controlled() || this._toggleMore(n.closest(B));
855
- return;
856
- }
857
- let r = e.target.closest?.(U);
858
- r && this.contains(r) && this._showColumn(r.getAttribute("data-wui-switch"));
859
- }
860
- _keyDown(e) {
861
- if (this._kbd) {
862
- this._liftedKey(e);
863
- return;
864
- }
865
- let t = e.target;
866
- if (!t.matches?.(H) || !this.contains(t)) return;
867
- let n = this._columnOf(t);
868
- switch (e.key) {
869
- case " ":
870
- case "Spacebar": {
871
- if (e.preventDefault(), !this._canLift(t)) return;
872
- let r = q(n), i = this._columns();
873
- this._kbd = {
874
- card: t,
875
- from: r,
876
- target: i.indexOf(n),
877
- verdicts: this._markTargets(t, r)
878
- }, t.setAttribute("data-wui-lifted", ""), this.setAttribute("data-wui-dragging", ""), n.setAttribute("data-wui-target", ""), this._announce(z.lifted(X(t), this._titleOf(n)));
879
- return;
880
- }
881
- case "ArrowDown":
882
- case "ArrowUp": {
883
- let r = this._visibleCardsIn(n), i = r[r.indexOf(t) + (e.key === "ArrowDown" ? 1 : -1)];
884
- i && (e.preventDefault(), i.focus());
885
- return;
886
- }
887
- case "ArrowLeft":
888
- case "ArrowRight": {
889
- let t = this._columns(), r = e.key === "ArrowRight" ? 1 : -1;
890
- for (let i = t.indexOf(n) + r; i >= 0 && i < t.length; i += r) {
891
- let n = this._visibleCardsIn(t[i])[0];
892
- if (n && !t[i].hasAttribute("data-collapsed")) {
893
- e.preventDefault(), n.focus();
894
- return;
895
- }
896
- }
897
- return;
898
- }
899
- default:
900
- }
901
- }
902
- _liftedKey(e) {
903
- let t = this._kbd, n = this._columns();
904
- switch (e.key) {
905
- case "ArrowLeft":
906
- case "ArrowRight": {
907
- e.preventDefault();
908
- let r = t.target + (e.key === "ArrowRight" ? 1 : -1);
909
- if (r < 0 || r >= n.length) return;
910
- n[t.target]?.removeAttribute("data-wui-target"), t.target = r;
911
- let i = n[r];
912
- i.setAttribute("data-wui-target", ""), this._showColumn(q(i), !1);
913
- let a = t.verdicts.get(q(i)), o = this._titleOf(i);
914
- this._announce(a.source ? z.overSource(o) : a.ok ? z.over(o, this._cardsIn(i).filter((e) => !Y(e)).length) : z.overRefused(o, a.reason));
915
- return;
916
- }
917
- case " ":
918
- case "Spacebar":
919
- case "Enter": {
920
- e.preventDefault();
921
- let r = n[t.target], i = q(r), a = t.verdicts.get(i);
922
- if (!a.source && !a.ok) {
923
- this._announce(a.reason);
924
- return;
925
- }
926
- this._endKeyboard(), a.source ? this._announce(z.cancelled(X(t.card))) : this._commit(t.card, i);
927
- return;
928
- }
929
- case "Escape":
930
- case "Tab":
931
- e.key === "Escape" && e.preventDefault(), this._endKeyboard(), this._showColumn(t.from, !1), this._announce(z.cancelled(X(t.card)));
932
- return;
933
- default:
934
- }
935
- }
936
- _endKeyboard() {
937
- let e = this._kbd;
938
- this._kbd = null, e && (e.card.removeAttribute("data-wui-lifted"), this.removeAttribute("data-wui-dragging"), this._clearTargets());
939
- }
940
- _restoreCollapsed() {
941
- let e = Q(this.getAttribute("board-id"));
942
- for (let t of this._columns()) {
943
- let n = q(t);
944
- t.hasAttribute("data-collapsible") && Object.hasOwn(e, n) && this._setCollapsed(t, e[n], !1);
945
- }
946
- }
947
- _setCollapsed(e, t, n) {
948
- let r = q(e);
949
- e.toggleAttribute("data-collapsed", t);
950
- let i = this._titleOf(e);
951
- for (let n of e.querySelectorAll(Oe)) n.setAttribute("aria-expanded", t ? "false" : "true"), n.setAttribute("aria-label", t ? z.expand(i) : z.collapse(i));
952
- n && (Fe(this.getAttribute("board-id"), r, t), this._fire("wui:kanban:collapse", {
953
- column: r,
954
- collapsed: t
955
- }));
956
- }
957
- _toggleMore(e) {
958
- if (!e) return;
959
- let t = q(e);
960
- if (this._expanded.delete(t)) for (let t of this._cardsIn(e)) this._revealed.delete(J(t));
961
- else this._expanded.add(t);
962
- this.refresh();
963
- }
964
- _isPhone() {
965
- return typeof matchMedia == "function" && matchMedia("(max-width: 767.98px)").matches;
966
- }
967
- _showColumn(e, t = !0) {
968
- for (let t of this.querySelectorAll(U)) t.getAttribute("data-wui-switch") === e ? t.setAttribute("aria-current", "true") : t.removeAttribute("aria-current");
969
- let n = this._columnByKey(e), r = this._scroller();
970
- if (!n || !r || !t && !this._isPhone()) return;
971
- let i = typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
972
- r.scrollTo?.({
973
- left: n.offsetLeft - r.offsetLeft,
974
- behavior: i ? "auto" : "smooth"
975
- });
976
- }
977
- _syncSwitcherFromScroll() {
978
- let e = this._scroller();
979
- if (!e || !this._isPhone()) return;
980
- let t = e.clientWidth || 1, n = this._columns()[Math.round(e.scrollLeft / t)];
981
- if (n) for (let e of this.querySelectorAll(U)) e.getAttribute("data-wui-switch") === q(n) ? e.setAttribute("aria-current", "true") : e.removeAttribute("aria-current");
982
- }
983
- };
984
- //#endregion
985
- export { c as _, L as a, Re as c, Z as d, Ie as f, Fe as g, Le as h, R as i, X as l, Q as m, ye as n, z as o, Ne as p, ve as r, _e as s, be as t, Pe as u, F as v, I as y };