@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.
- package/dist/WuiAutocomplete-ByxnwJNQ.js +283 -0
- package/dist/WuiCommandPalette-CtZ04JxZ.js +130 -0
- package/dist/WuiConsentBanner-oVe-jxCO.js +399 -0
- package/dist/WuiContextMenu-Bx_U2X3t.js +211 -0
- package/dist/WuiCountrySelect-CUAwKnL9.js +28 -0
- package/dist/WuiDatePicker-DkNbc-z7.js +325 -0
- package/dist/WuiDateRange-BocnVO6L.js +233 -0
- package/dist/WuiDock-BSDY9g8Q.js +57 -0
- package/dist/WuiImageCrop-1yaAONTk.js +462 -0
- package/dist/WuiMultiSelect-BrCGRNCt.js +416 -0
- package/dist/WuiOtp-D8-4Pqil.js +128 -0
- package/dist/WuiPhone-BvbhiP2r.js +731 -0
- package/dist/WuiSelect-BXrpiuXG.js +214 -0
- package/dist/WuiSlider-BcU0psYf.js +256 -0
- package/dist/WuiSortable-JjJqstSU.js +280 -0
- package/dist/WuiTagInput-D1ay3OcL.js +158 -0
- package/dist/WuiTimePicker-C7n-VFGt.js +370 -0
- package/dist/WuiTour-R5O9l--J.js +205 -0
- package/dist/WuiTree-Ds-8tNgs.js +393 -0
- package/dist/WuiWizardStep-BU5w9_Ds.js +221 -0
- package/dist/anchorOverlay-DluGZ8ef.js +23 -0
- package/dist/calendarMath-BAF2Jkg_.js +42 -0
- package/dist/countries-B-M_LTgS.js +1234 -0
- package/dist/elementBase-Bg1xpvup.js +9 -0
- package/dist/elements/autocomplete.js +6 -0
- package/dist/elements/command-palette.js +6 -0
- package/dist/elements/consent-banner.js +6 -0
- package/dist/elements/context-menu.js +6 -0
- package/dist/elements/country-select.js +6 -0
- package/dist/elements/date-range.js +6 -0
- package/dist/elements/datepicker.js +6 -0
- package/dist/elements/dock.js +6 -0
- package/dist/elements/image-crop.js +6 -0
- package/dist/elements/kanban.js +6 -0
- package/dist/elements/multiselect.js +6 -0
- package/dist/elements/otp.js +6 -0
- package/dist/elements/phone.js +6 -0
- package/dist/elements/select.js +6 -0
- package/dist/elements/slider.js +6 -0
- package/dist/elements/sortable.js +6 -0
- package/dist/elements/status-icon.js +6 -0
- package/dist/elements/taginput.js +6 -0
- package/dist/elements/timepicker.js +6 -0
- package/dist/elements/tour.js +6 -0
- package/dist/elements/tree.js +6 -0
- package/dist/elements/wizard.js +5 -0
- package/dist/formMirror-jGf5M4gk.js +29 -0
- package/dist/formatters-DusKbTyV.js +138 -0
- package/dist/helpers.js +5 -0
- package/dist/iconGlyphs.g-Cpg1BUHm.js +215 -0
- package/dist/kanban-BeVAItir.js +972 -0
- package/dist/listboxKeyNav-zts_8d5e.js +36 -0
- package/dist/optionLabel-Dn-I7zyp.js +16 -0
- package/dist/statusIcons-C3zjycpa.js +37 -0
- package/dist/textMatch-DEUjlkdy.js +27 -0
- package/dist/themeTransition-BpCuMnjk.js +589 -0
- package/dist/tokenCommit-VWz-2jEf.js +20 -0
- package/dist/ui-elements.global.js +118 -129
- package/dist/ui-elements.js +253 -8864
- package/dist/ui-phone.global.js +14 -0
- package/dist/wuiHttp-m0yQadwQ.js +117 -0
- package/package.json +28 -3
|
@@ -0,0 +1,972 @@
|
|
|
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-m0yQadwQ.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]", U = "[data-wui-count]", xe = "[data-wui-summary]", Se = "[data-wui-empty]", Ce = "[data-wui-drop-note]", we = "[data-wui-live]", Te = "[data-wui-help]", W = "[data-wui-switch]", Ee = "[data-wui-scroller]", De = "[data-wui-collapse]", Oe = "[data-wui-more]", ke = "data-wui-visible-limit", G = "data-wui-overflow", Ae = "input, select, textarea, [contenteditable=\"\"], [contenteditable=\"true\"], [data-wui-no-drag]", K = 48, je = 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(G);
|
|
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(ke)), 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(G);
|
|
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(G, 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(Se);
|
|
476
|
+
if (u && (u.hidden = a.length > 0), e) {
|
|
477
|
+
let r = n.querySelector(xe);
|
|
478
|
+
r && (r.textContent = t(Le(o), e));
|
|
479
|
+
}
|
|
480
|
+
let d = n.querySelector(Oe);
|
|
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(W)].filter((e) => e.getAttribute("data-wui-switch") === t);
|
|
524
|
+
return [...e.querySelectorAll(U), ...n.flatMap((e) => [...e.querySelectorAll(U)])];
|
|
525
|
+
}
|
|
526
|
+
_scroller() {
|
|
527
|
+
return this.querySelector(Ee);
|
|
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(Te);
|
|
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(we);
|
|
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(Ce);
|
|
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(Ce);
|
|
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(ke) && !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 && e.focus(), 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(xe)?.replaceChildren(e.content.cloneNode(!0));
|
|
720
|
+
return this.refresh(), window.WUI?.refresh?.(), n;
|
|
721
|
+
}
|
|
722
|
+
_refocusSoon(e) {
|
|
723
|
+
let t = () => this._cardByKey(e)?.focus();
|
|
724
|
+
typeof requestAnimationFrame == "function" ? requestAnimationFrame(t) : setTimeout(t, 0);
|
|
725
|
+
}
|
|
726
|
+
_pointerDown(e) {
|
|
727
|
+
if (e.button !== 0 || e.isPrimary === !1 || this._drag || this._kbd) return;
|
|
728
|
+
let t = e.target.closest?.(H);
|
|
729
|
+
if (!t || !this.contains(t) || e.target.closest(Ae)) return;
|
|
730
|
+
let n = {
|
|
731
|
+
card: t,
|
|
732
|
+
id: e.pointerId,
|
|
733
|
+
x: e.clientX,
|
|
734
|
+
y: e.clientY,
|
|
735
|
+
type: e.pointerType,
|
|
736
|
+
timer: 0
|
|
737
|
+
};
|
|
738
|
+
this._press = n, e.pointerType === "touch" && (n.timer = setTimeout(() => {
|
|
739
|
+
this._press === n && this._startDrag(n, n.x, n.y);
|
|
740
|
+
}, 400)), window.addEventListener("pointermove", this._onPointerMove), window.addEventListener("pointerup", this._onPointerUp), window.addEventListener("pointercancel", this._onPointerCancel);
|
|
741
|
+
}
|
|
742
|
+
_pointerMove(e) {
|
|
743
|
+
let t = this._press;
|
|
744
|
+
if (!(!t || e.pointerId !== t.id)) {
|
|
745
|
+
if (!this._drag) {
|
|
746
|
+
if (!(Math.hypot(e.clientX - t.x, e.clientY - t.y) > 6)) return;
|
|
747
|
+
if (t.type === "touch") {
|
|
748
|
+
this._endPointer(!1);
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
if (this._startDrag(t, e.clientX, e.clientY), !this._drag) return;
|
|
752
|
+
}
|
|
753
|
+
this._dragTo(e.clientX, e.clientY);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
_pointerUp(e) {
|
|
757
|
+
!this._press || e.pointerId !== this._press.id || this._endPointer(!!this._drag);
|
|
758
|
+
}
|
|
759
|
+
_startDrag(e, t, n) {
|
|
760
|
+
let r = e.card;
|
|
761
|
+
if (!this._canLift(r)) {
|
|
762
|
+
this._endPointer(!1);
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
let i = q(this._columnOf(r)), a = r.getBoundingClientRect(), o = r.cloneNode(!0);
|
|
766
|
+
for (let e of [o, ...o.querySelectorAll("[id]")]) e.removeAttribute("id");
|
|
767
|
+
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 = {
|
|
768
|
+
card: r,
|
|
769
|
+
from: i,
|
|
770
|
+
ghost: o,
|
|
771
|
+
dx: t - a.left,
|
|
772
|
+
dy: n - a.top,
|
|
773
|
+
over: null,
|
|
774
|
+
verdicts: this._markTargets(r, i)
|
|
775
|
+
}, this._announce(z.lifted(X(r), this._titleOf(this._columnOf(r)))), document.addEventListener("keydown", this._onDocKeyDown), this._dragTo(t, n);
|
|
776
|
+
}
|
|
777
|
+
_dragTo(e, t) {
|
|
778
|
+
let n = this._drag;
|
|
779
|
+
n.x = e, n.y = t, n.ghost.style.transform = `translate(${e - n.dx}px, ${t - n.dy}px)`;
|
|
780
|
+
let r = this._columnAt(e, t);
|
|
781
|
+
r !== n.over && (n.over?.removeAttribute("data-wui-over"), r?.setAttribute("data-wui-over", ""), n.over = r), this._autoScroll(e, t);
|
|
782
|
+
}
|
|
783
|
+
_columnAt(e, t) {
|
|
784
|
+
for (let n of this._columns()) {
|
|
785
|
+
let r = n.getBoundingClientRect();
|
|
786
|
+
if (e >= r.left && e <= r.right && t >= r.top && t <= r.bottom) return n;
|
|
787
|
+
}
|
|
788
|
+
return null;
|
|
789
|
+
}
|
|
790
|
+
_indexAt(e, t) {
|
|
791
|
+
let n = this._visibleCardsIn(e).filter((e) => e !== this._drag?.card).find((e) => {
|
|
792
|
+
let n = e.getBoundingClientRect();
|
|
793
|
+
return t < n.top + n.height / 2;
|
|
794
|
+
}), r = this._cardsIn(e).filter((e) => e !== this._drag?.card);
|
|
795
|
+
return n ? r.indexOf(n) : r.length;
|
|
796
|
+
}
|
|
797
|
+
_autoScroll(e, t) {
|
|
798
|
+
let n = this._scroller();
|
|
799
|
+
if (n) {
|
|
800
|
+
let t = n.getBoundingClientRect();
|
|
801
|
+
t.width > 0 && (e < t.left + K ? n.scrollBy?.({ left: -16 }) : e > t.right - K && n.scrollBy?.({ left: je }));
|
|
802
|
+
}
|
|
803
|
+
let r = window.innerHeight || 0;
|
|
804
|
+
r > 0 && (t < K ? window.scrollBy?.({ top: -16 }) : t > r - K && window.scrollBy?.({ top: je }));
|
|
805
|
+
}
|
|
806
|
+
_endPointer(e) {
|
|
807
|
+
let t = this._press, n = this._drag;
|
|
808
|
+
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;
|
|
809
|
+
n.ghost.remove(), n.card.removeAttribute("data-wui-dragging"), this.removeAttribute("data-wui-dragging"), this._suppressClick = !0, setTimeout(() => {
|
|
810
|
+
this._suppressClick = !1;
|
|
811
|
+
}, 0);
|
|
812
|
+
let r = n.over;
|
|
813
|
+
if (this._clearTargets(), !e || !r) {
|
|
814
|
+
this._announce(z.cancelled(X(n.card)));
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
let i = q(r), a = n.verdicts.get(i);
|
|
818
|
+
if (a?.source) {
|
|
819
|
+
this._announce(z.cancelled(X(n.card)));
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
if (!a?.ok) {
|
|
823
|
+
this._announce(a?.reason), $(a?.reason, "info");
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
this._commit(n.card, i, this._indexAt(r, n.y));
|
|
827
|
+
}
|
|
828
|
+
_click(e) {
|
|
829
|
+
if (this._suppressClick && e.target.closest?.(H)) {
|
|
830
|
+
e.preventDefault(), e.stopPropagation(), this._suppressClick = !1;
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
let t = e.target.closest?.(De);
|
|
834
|
+
if (t && this.contains(t)) {
|
|
835
|
+
let e = t.closest(B);
|
|
836
|
+
e && this._setCollapsed(e, !e.hasAttribute("data-collapsed"), !0);
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
let n = e.target.closest?.(Oe);
|
|
840
|
+
if (n && this.contains(n)) {
|
|
841
|
+
this._controlled() || this._toggleMore(n.closest(B));
|
|
842
|
+
return;
|
|
843
|
+
}
|
|
844
|
+
let r = e.target.closest?.(W);
|
|
845
|
+
r && this.contains(r) && this._showColumn(r.getAttribute("data-wui-switch"));
|
|
846
|
+
}
|
|
847
|
+
_keyDown(e) {
|
|
848
|
+
if (this._kbd) {
|
|
849
|
+
this._liftedKey(e);
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
let t = e.target;
|
|
853
|
+
if (!t.matches?.(H) || !this.contains(t)) return;
|
|
854
|
+
let n = this._columnOf(t);
|
|
855
|
+
switch (e.key) {
|
|
856
|
+
case " ":
|
|
857
|
+
case "Spacebar": {
|
|
858
|
+
if (e.preventDefault(), !this._canLift(t)) return;
|
|
859
|
+
let r = q(n), i = this._columns();
|
|
860
|
+
this._kbd = {
|
|
861
|
+
card: t,
|
|
862
|
+
from: r,
|
|
863
|
+
target: i.indexOf(n),
|
|
864
|
+
verdicts: this._markTargets(t, r)
|
|
865
|
+
}, t.setAttribute("data-wui-lifted", ""), this.setAttribute("data-wui-dragging", ""), n.setAttribute("data-wui-target", ""), this._announce(z.lifted(X(t), this._titleOf(n)));
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
case "ArrowDown":
|
|
869
|
+
case "ArrowUp": {
|
|
870
|
+
let r = this._visibleCardsIn(n), i = r[r.indexOf(t) + (e.key === "ArrowDown" ? 1 : -1)];
|
|
871
|
+
i && (e.preventDefault(), i.focus());
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
case "ArrowLeft":
|
|
875
|
+
case "ArrowRight": {
|
|
876
|
+
let t = this._columns(), r = e.key === "ArrowRight" ? 1 : -1;
|
|
877
|
+
for (let i = t.indexOf(n) + r; i >= 0 && i < t.length; i += r) {
|
|
878
|
+
let n = this._visibleCardsIn(t[i])[0];
|
|
879
|
+
if (n && !t[i].hasAttribute("data-collapsed")) {
|
|
880
|
+
e.preventDefault(), n.focus();
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
886
|
+
default:
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
_liftedKey(e) {
|
|
890
|
+
let t = this._kbd, n = this._columns();
|
|
891
|
+
switch (e.key) {
|
|
892
|
+
case "ArrowLeft":
|
|
893
|
+
case "ArrowRight": {
|
|
894
|
+
e.preventDefault();
|
|
895
|
+
let r = t.target + (e.key === "ArrowRight" ? 1 : -1);
|
|
896
|
+
if (r < 0 || r >= n.length) return;
|
|
897
|
+
n[t.target]?.removeAttribute("data-wui-target"), t.target = r;
|
|
898
|
+
let i = n[r];
|
|
899
|
+
i.setAttribute("data-wui-target", ""), this._showColumn(q(i), !1);
|
|
900
|
+
let a = t.verdicts.get(q(i)), o = this._titleOf(i);
|
|
901
|
+
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));
|
|
902
|
+
return;
|
|
903
|
+
}
|
|
904
|
+
case " ":
|
|
905
|
+
case "Spacebar":
|
|
906
|
+
case "Enter": {
|
|
907
|
+
e.preventDefault();
|
|
908
|
+
let r = n[t.target], i = q(r), a = t.verdicts.get(i);
|
|
909
|
+
if (!a.source && !a.ok) {
|
|
910
|
+
this._announce(a.reason);
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
this._endKeyboard(), a.source ? this._announce(z.cancelled(X(t.card))) : this._commit(t.card, i);
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
case "Escape":
|
|
917
|
+
case "Tab":
|
|
918
|
+
e.key === "Escape" && e.preventDefault(), this._endKeyboard(), this._showColumn(t.from, !1), this._announce(z.cancelled(X(t.card)));
|
|
919
|
+
return;
|
|
920
|
+
default:
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
_endKeyboard() {
|
|
924
|
+
let e = this._kbd;
|
|
925
|
+
this._kbd = null, e && (e.card.removeAttribute("data-wui-lifted"), this.removeAttribute("data-wui-dragging"), this._clearTargets());
|
|
926
|
+
}
|
|
927
|
+
_restoreCollapsed() {
|
|
928
|
+
let e = Q(this.getAttribute("board-id"));
|
|
929
|
+
for (let t of this._columns()) {
|
|
930
|
+
let n = q(t);
|
|
931
|
+
t.hasAttribute("data-collapsible") && Object.hasOwn(e, n) && this._setCollapsed(t, e[n], !1);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
_setCollapsed(e, t, n) {
|
|
935
|
+
let r = q(e);
|
|
936
|
+
e.toggleAttribute("data-collapsed", t);
|
|
937
|
+
let i = this._titleOf(e);
|
|
938
|
+
for (let n of e.querySelectorAll(De)) n.setAttribute("aria-expanded", t ? "false" : "true"), n.setAttribute("aria-label", t ? z.expand(i) : z.collapse(i));
|
|
939
|
+
n && (Fe(this.getAttribute("board-id"), r, t), this._fire("wui:kanban:collapse", {
|
|
940
|
+
column: r,
|
|
941
|
+
collapsed: t
|
|
942
|
+
}));
|
|
943
|
+
}
|
|
944
|
+
_toggleMore(e) {
|
|
945
|
+
if (!e) return;
|
|
946
|
+
let t = q(e);
|
|
947
|
+
if (this._expanded.delete(t)) for (let t of this._cardsIn(e)) this._revealed.delete(J(t));
|
|
948
|
+
else this._expanded.add(t);
|
|
949
|
+
this.refresh();
|
|
950
|
+
}
|
|
951
|
+
_isPhone() {
|
|
952
|
+
return typeof matchMedia == "function" && matchMedia("(max-width: 767.98px)").matches;
|
|
953
|
+
}
|
|
954
|
+
_showColumn(e, t = !0) {
|
|
955
|
+
for (let t of this.querySelectorAll(W)) t.getAttribute("data-wui-switch") === e ? t.setAttribute("aria-current", "true") : t.removeAttribute("aria-current");
|
|
956
|
+
let n = this._columnByKey(e), r = this._scroller();
|
|
957
|
+
if (!n || !r || !t && !this._isPhone()) return;
|
|
958
|
+
let i = typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
959
|
+
r.scrollTo?.({
|
|
960
|
+
left: n.offsetLeft - r.offsetLeft,
|
|
961
|
+
behavior: i ? "auto" : "smooth"
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
_syncSwitcherFromScroll() {
|
|
965
|
+
let e = this._scroller();
|
|
966
|
+
if (!e || !this._isPhone()) return;
|
|
967
|
+
let t = e.clientWidth || 1, n = this._columns()[Math.round(e.scrollLeft / t)];
|
|
968
|
+
if (n) for (let e of this.querySelectorAll(W)) e.getAttribute("data-wui-switch") === q(n) ? e.setAttribute("aria-current", "true") : e.removeAttribute("aria-current");
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
//#endregion
|
|
972
|
+
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 };
|