@ux-builder/ui 0.0.0-stage → 0.6.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/AGENTS.md +275 -0
- package/README.md +293 -2
- package/THIRD-PARTY-NOTICES.md +195 -0
- package/catalogue.json +19424 -0
- package/dist/icons.js +2 -0
- package/dist/index.js +537 -0
- package/dist/index.js.map +1 -0
- package/dist/patterns.css +900 -0
- package/dist/patterns.js +4235 -0
- package/dist/patterns.js.map +1 -0
- package/dist/shared-Bom_GJww.js +18858 -0
- package/dist/shared-Bom_GJww.js.map +1 -0
- package/dist/shared-CjrUPFqv.js +1501 -0
- package/dist/shared-CjrUPFqv.js.map +1 -0
- package/dist/ui.css +997 -0
- package/licenses/carbon.LICENSE +201 -0
- package/licenses/fluent.LICENSE +24 -0
- package/licenses/lucide.LICENSE +43 -0
- package/licenses/material.LICENSE +202 -0
- package/licenses/vendored.json +214 -0
- package/lint/core.mjs +158 -0
- package/lint/eslint.mjs +128 -0
- package/lint/stylelint.mjs +35 -0
- package/package.json +104 -4
- package/skill/ux-builder-ui/SKILL.md +280 -0
package/dist/patterns.js
ADDED
|
@@ -0,0 +1,4235 @@
|
|
|
1
|
+
import { _ as e, a as t, b as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, p as d, r as f, s as p, t as m, u as h } from "./shared-CjrUPFqv.js";
|
|
2
|
+
import { Fragment as g, cloneElement as _, useCallback as v, useEffect as y, useId as b, useLayoutEffect as x, useMemo as S, useRef as C, useState as w } from "react";
|
|
3
|
+
import { Fragment as T, jsx as E, jsxs as D } from "react/jsx-runtime";
|
|
4
|
+
//#region src/patterns/Layout.jsx
|
|
5
|
+
var O = [
|
|
6
|
+
"compact",
|
|
7
|
+
"medium",
|
|
8
|
+
"expanded",
|
|
9
|
+
"large",
|
|
10
|
+
"extraLarge"
|
|
11
|
+
], k = {
|
|
12
|
+
compact: "compact",
|
|
13
|
+
medium: "medium",
|
|
14
|
+
expanded: "expanded",
|
|
15
|
+
large: "large",
|
|
16
|
+
extraLarge: "extra-large"
|
|
17
|
+
}, A = (e, t) => Number.isInteger(e) && e >= 0 && e <= 8 ? e : t, j = (...e) => e.filter(Boolean).join(" ");
|
|
18
|
+
function M({ gap: e = 4, align: t = "stretch", as: n = "div", className: r, children: i, ...a }) {
|
|
19
|
+
return /* @__PURE__ */ E(n, {
|
|
20
|
+
className: j("piq-stack", r),
|
|
21
|
+
"data-gap": A(e, 4),
|
|
22
|
+
"data-align": t,
|
|
23
|
+
...a,
|
|
24
|
+
children: i
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function N({ gap: e = 3, justify: t = "start", align: n = "center", wrap: r = !0, as: i = "div", className: a, children: o, ...s }) {
|
|
28
|
+
return /* @__PURE__ */ E(i, {
|
|
29
|
+
className: j("piq-cluster", a),
|
|
30
|
+
"data-gap": A(e, 3),
|
|
31
|
+
"data-justify": t,
|
|
32
|
+
"data-align": n,
|
|
33
|
+
"data-wrap": r ? "true" : "false",
|
|
34
|
+
...s,
|
|
35
|
+
children: o
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function P({ columns: e = {
|
|
39
|
+
compact: 1,
|
|
40
|
+
medium: 2,
|
|
41
|
+
expanded: 3,
|
|
42
|
+
large: 4
|
|
43
|
+
}, gap: t = 4, as: n = "div", className: r, children: i, ...a }) {
|
|
44
|
+
let o = {}, s = 1;
|
|
45
|
+
for (let t of O) {
|
|
46
|
+
let n = typeof e == "number" ? e : e?.[t];
|
|
47
|
+
s = Number.isInteger(n) ? Math.min(6, Math.max(1, n)) : s, o[`data-cols-${k[t]}`] = s;
|
|
48
|
+
}
|
|
49
|
+
return /* @__PURE__ */ E("div", {
|
|
50
|
+
className: j("piq-grid", r),
|
|
51
|
+
"data-gap": A(t, 4),
|
|
52
|
+
...o,
|
|
53
|
+
children: /* @__PURE__ */ E(n, {
|
|
54
|
+
className: "piq-grid__items",
|
|
55
|
+
...a,
|
|
56
|
+
children: i
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function F({ width: e = "page", as: t = "div", className: n, children: r, ...i }) {
|
|
61
|
+
return /* @__PURE__ */ E("div", {
|
|
62
|
+
className: j("piq-page", n),
|
|
63
|
+
"data-width": e,
|
|
64
|
+
children: /* @__PURE__ */ E(t, {
|
|
65
|
+
className: "piq-page__body",
|
|
66
|
+
...i,
|
|
67
|
+
children: r
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function I({ primary: e, secondary: t, show: n = "primary", ratio: r = "1:2", primaryLabel: i, secondaryLabel: a, className: o, ...s }) {
|
|
72
|
+
return /* @__PURE__ */ E("div", {
|
|
73
|
+
className: j("piq-split", o),
|
|
74
|
+
"data-show": n === "secondary" ? "secondary" : "primary",
|
|
75
|
+
"data-ratio": r,
|
|
76
|
+
...s,
|
|
77
|
+
children: /* @__PURE__ */ D("div", {
|
|
78
|
+
className: "piq-split__panes",
|
|
79
|
+
children: [/* @__PURE__ */ E("div", {
|
|
80
|
+
className: "piq-split__pane",
|
|
81
|
+
"data-pane": "primary",
|
|
82
|
+
role: i ? "region" : void 0,
|
|
83
|
+
"aria-label": i,
|
|
84
|
+
children: e
|
|
85
|
+
}), /* @__PURE__ */ E("div", {
|
|
86
|
+
className: "piq-split__pane",
|
|
87
|
+
"data-pane": "secondary",
|
|
88
|
+
role: a ? "region" : void 0,
|
|
89
|
+
"aria-label": a,
|
|
90
|
+
children: t
|
|
91
|
+
})]
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/patterns/Navigation.jsx
|
|
97
|
+
var L = (e, t) => e.current === !0 || t !== void 0 && e.id === t, R = (e, t) => L(e, t) || (e.items ?? []).some((e) => R(e, t));
|
|
98
|
+
function z({ item: e, current: t, onNavigate: r }) {
|
|
99
|
+
let [i, a] = w(() => R(e, t)), o = b();
|
|
100
|
+
return /* @__PURE__ */ D("li", {
|
|
101
|
+
className: "piq-primary-nav__item",
|
|
102
|
+
children: [/* @__PURE__ */ D("button", {
|
|
103
|
+
type: "button",
|
|
104
|
+
className: "piq-primary-nav__link piq-primary-nav__group",
|
|
105
|
+
"aria-expanded": i,
|
|
106
|
+
"aria-controls": o,
|
|
107
|
+
onClick: () => a((e) => !e),
|
|
108
|
+
children: [
|
|
109
|
+
e.icon && /* @__PURE__ */ E(n, { name: e.icon }),
|
|
110
|
+
/* @__PURE__ */ E("span", {
|
|
111
|
+
className: "piq-primary-nav__label",
|
|
112
|
+
children: e.label
|
|
113
|
+
}),
|
|
114
|
+
/* @__PURE__ */ E(n, {
|
|
115
|
+
name: i ? "chevron-up" : "chevron-down",
|
|
116
|
+
className: "piq-primary-nav__chevron"
|
|
117
|
+
})
|
|
118
|
+
]
|
|
119
|
+
}), /* @__PURE__ */ E("ul", {
|
|
120
|
+
id: o,
|
|
121
|
+
className: "piq-primary-nav__list piq-primary-nav__sublist",
|
|
122
|
+
hidden: !i,
|
|
123
|
+
children: e.items.map((e) => /* @__PURE__ */ E(B, {
|
|
124
|
+
item: e,
|
|
125
|
+
current: t,
|
|
126
|
+
onNavigate: r
|
|
127
|
+
}, e.id ?? e.label))
|
|
128
|
+
})]
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function B({ item: e, current: t, onNavigate: r }) {
|
|
132
|
+
if (e.items?.length) return /* @__PURE__ */ E(z, {
|
|
133
|
+
item: e,
|
|
134
|
+
current: t,
|
|
135
|
+
onNavigate: r
|
|
136
|
+
});
|
|
137
|
+
let i = L(e, t);
|
|
138
|
+
return /* @__PURE__ */ E("li", {
|
|
139
|
+
className: "piq-primary-nav__item",
|
|
140
|
+
children: /* @__PURE__ */ D("a", {
|
|
141
|
+
href: e.href,
|
|
142
|
+
className: "piq-primary-nav__link",
|
|
143
|
+
"aria-current": i ? "page" : void 0,
|
|
144
|
+
onClick: (t) => {
|
|
145
|
+
r && (t.preventDefault(), r(e, t));
|
|
146
|
+
},
|
|
147
|
+
children: [e.icon && /* @__PURE__ */ E(n, { name: e.icon }), /* @__PURE__ */ E("span", {
|
|
148
|
+
className: "piq-primary-nav__label",
|
|
149
|
+
children: e.label
|
|
150
|
+
})]
|
|
151
|
+
})
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function V({ items: e = [], current: t, label: n = "Main", onNavigate: r, className: i, ...a }) {
|
|
155
|
+
return /* @__PURE__ */ E("nav", {
|
|
156
|
+
"aria-label": n,
|
|
157
|
+
className: `piq-primary-nav${i ? ` ${i}` : ""}`,
|
|
158
|
+
...a,
|
|
159
|
+
children: /* @__PURE__ */ E("ul", {
|
|
160
|
+
className: "piq-primary-nav__list",
|
|
161
|
+
children: e.map((e) => /* @__PURE__ */ E(B, {
|
|
162
|
+
item: e,
|
|
163
|
+
current: t,
|
|
164
|
+
onNavigate: r
|
|
165
|
+
}, e.id ?? e.label))
|
|
166
|
+
})
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
function ee({ workspaces: e = [], current: t, onSwitch: r, label: i = "Workspace", searchLabel: a = "Search workspaces", searchAt: c = 8, emptyLabel: l = "No workspace matches", className: u }) {
|
|
170
|
+
let d = e.find((e) => e.id === t) ?? e[0], [f, p] = w(!1), [m, h] = w(""), [g, _] = w(0), v = C(null), x = C(null), S = C(null), T = b();
|
|
171
|
+
if (y(() => {
|
|
172
|
+
f && S.current?.focus();
|
|
173
|
+
}, [f]), y(() => {
|
|
174
|
+
if (!f) return;
|
|
175
|
+
let e = (e) => {
|
|
176
|
+
!v.current?.contains(e.target) && !x.current?.contains(e.target) && p(!1);
|
|
177
|
+
};
|
|
178
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
179
|
+
}, [f]), e.length < c) return /* @__PURE__ */ E(s, {
|
|
180
|
+
className: u,
|
|
181
|
+
variant: "text",
|
|
182
|
+
label: d?.label,
|
|
183
|
+
buttonLabel: `${i}: ${d?.label ?? ""}`,
|
|
184
|
+
items: e.map((e) => ({
|
|
185
|
+
label: e.label,
|
|
186
|
+
checked: e.id === d?.id,
|
|
187
|
+
onSelect: () => r?.(e.id)
|
|
188
|
+
}))
|
|
189
|
+
});
|
|
190
|
+
let O = e.filter((e) => e.label.toLowerCase().includes(m.trim().toLowerCase())), k = () => {
|
|
191
|
+
p(!1), h(""), _(0), v.current?.focus();
|
|
192
|
+
}, A = (e) => {
|
|
193
|
+
k(), e.id !== d?.id && r?.(e.id);
|
|
194
|
+
};
|
|
195
|
+
function j(e) {
|
|
196
|
+
e.key === "ArrowDown" ? (e.preventDefault(), _((e) => Math.min(e + 1, O.length - 1))) : e.key === "ArrowUp" ? (e.preventDefault(), _((e) => Math.max(e - 1, 0))) : e.key === "Enter" ? (e.preventDefault(), O[g] && A(O[g])) : e.key === "Escape" && (e.preventDefault(), k());
|
|
197
|
+
}
|
|
198
|
+
return /* @__PURE__ */ D("div", {
|
|
199
|
+
className: `piq-menubutton piq-workspace${u ? ` ${u}` : ""}`,
|
|
200
|
+
children: [/* @__PURE__ */ D(o, {
|
|
201
|
+
ref: v,
|
|
202
|
+
variant: "text",
|
|
203
|
+
"aria-haspopup": "dialog",
|
|
204
|
+
"aria-expanded": f,
|
|
205
|
+
"aria-label": `${i}: ${d?.label ?? ""}`,
|
|
206
|
+
onClick: () => f ? k() : p(!0),
|
|
207
|
+
children: [d?.label, /* @__PURE__ */ E(n, {
|
|
208
|
+
name: "chevron-down",
|
|
209
|
+
className: "piq-menubutton__chevron"
|
|
210
|
+
})]
|
|
211
|
+
}), f && /* @__PURE__ */ D("div", {
|
|
212
|
+
ref: x,
|
|
213
|
+
role: "dialog",
|
|
214
|
+
"aria-label": i,
|
|
215
|
+
className: "piq-menu piq-menubutton__menu piq-workspace__popup",
|
|
216
|
+
children: [
|
|
217
|
+
/* @__PURE__ */ E("input", {
|
|
218
|
+
ref: S,
|
|
219
|
+
type: "search",
|
|
220
|
+
role: "combobox",
|
|
221
|
+
className: "piq-field__input piq-workspace__search",
|
|
222
|
+
"aria-label": a,
|
|
223
|
+
"aria-expanded": "true",
|
|
224
|
+
"aria-controls": `${T}-list`,
|
|
225
|
+
"aria-autocomplete": "list",
|
|
226
|
+
"aria-activedescendant": O[g] ? `${T}-${O[g].id}` : void 0,
|
|
227
|
+
value: m,
|
|
228
|
+
onChange: (e) => {
|
|
229
|
+
h(e.target.value), _(0);
|
|
230
|
+
},
|
|
231
|
+
onKeyDown: j
|
|
232
|
+
}),
|
|
233
|
+
/* @__PURE__ */ E("ul", {
|
|
234
|
+
id: `${T}-list`,
|
|
235
|
+
role: "listbox",
|
|
236
|
+
"aria-label": i,
|
|
237
|
+
className: "piq-workspace__list",
|
|
238
|
+
children: O.map((e, t) => /* @__PURE__ */ E("li", {
|
|
239
|
+
id: `${T}-${e.id}`,
|
|
240
|
+
role: "option",
|
|
241
|
+
"aria-selected": e.id === d?.id,
|
|
242
|
+
className: `piq-menu__item${t === g ? " is-hover" : ""}`,
|
|
243
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
244
|
+
onClick: () => A(e),
|
|
245
|
+
children: e.label
|
|
246
|
+
}, e.id))
|
|
247
|
+
}),
|
|
248
|
+
!O.length && /* @__PURE__ */ E("p", {
|
|
249
|
+
className: "piq-workspace__empty",
|
|
250
|
+
role: "status",
|
|
251
|
+
children: l
|
|
252
|
+
})
|
|
253
|
+
]
|
|
254
|
+
})]
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function te({ nav: e = [], current: t, navLabel: r = "Main", brand: i, actions: a, breadcrumbs: o, onNavigate: s, moreLabel: c = "More", skipLabel: l = "Skip to content", adapt: d = "window", children: f, className: p }) {
|
|
258
|
+
let [m, h] = w(!1), g = b(), _ = C(null), v = e.length <= 5 ? e : [...e.slice(0, 4), {
|
|
259
|
+
id: "piq-more",
|
|
260
|
+
label: c,
|
|
261
|
+
icon: "more",
|
|
262
|
+
more: !0
|
|
263
|
+
}];
|
|
264
|
+
y(() => {
|
|
265
|
+
if (!m || d === "container" || typeof window.matchMedia != "function") return;
|
|
266
|
+
let e = window.matchMedia("(min-width: 600px)"), t = () => {
|
|
267
|
+
e.matches && (h(!1), requestAnimationFrame(() => _.current?.querySelector("[aria-current=\"page\"]")?.focus()));
|
|
268
|
+
};
|
|
269
|
+
return e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
270
|
+
}, [m]);
|
|
271
|
+
let x = (e) => (t) => {
|
|
272
|
+
if (e.more || e.items?.length) {
|
|
273
|
+
t.preventDefault(), h(!0);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
s && (t.preventDefault(), s(e, t));
|
|
277
|
+
}, S = s ? (e, t) => {
|
|
278
|
+
h(!1), s(e, t);
|
|
279
|
+
} : void 0, O = /* @__PURE__ */ D("div", {
|
|
280
|
+
className: `piq-shell${p ? ` ${p}` : ""}`,
|
|
281
|
+
"data-adapt": d === "container" ? "container" : void 0,
|
|
282
|
+
children: [
|
|
283
|
+
/* @__PURE__ */ E("a", {
|
|
284
|
+
className: "piq-shell__skip",
|
|
285
|
+
href: `#${g}`,
|
|
286
|
+
children: l
|
|
287
|
+
}),
|
|
288
|
+
/* @__PURE__ */ D("header", {
|
|
289
|
+
className: "piq-shell__top",
|
|
290
|
+
children: [i && /* @__PURE__ */ E("div", {
|
|
291
|
+
className: "piq-shell__brand",
|
|
292
|
+
children: i
|
|
293
|
+
}), a && /* @__PURE__ */ E("div", {
|
|
294
|
+
className: "piq-shell__actions",
|
|
295
|
+
children: a
|
|
296
|
+
})]
|
|
297
|
+
}),
|
|
298
|
+
/* @__PURE__ */ E("div", {
|
|
299
|
+
ref: _,
|
|
300
|
+
className: "piq-shell__side",
|
|
301
|
+
children: /* @__PURE__ */ E(V, {
|
|
302
|
+
items: e,
|
|
303
|
+
current: t,
|
|
304
|
+
label: r,
|
|
305
|
+
onNavigate: s
|
|
306
|
+
})
|
|
307
|
+
}),
|
|
308
|
+
/* @__PURE__ */ D("main", {
|
|
309
|
+
id: g,
|
|
310
|
+
className: "piq-shell__main",
|
|
311
|
+
tabIndex: -1,
|
|
312
|
+
children: [o && /* @__PURE__ */ E("div", {
|
|
313
|
+
className: "piq-shell__breadcrumbs",
|
|
314
|
+
children: o
|
|
315
|
+
}), f]
|
|
316
|
+
}),
|
|
317
|
+
/* @__PURE__ */ E("nav", {
|
|
318
|
+
className: "piq-shell__bar",
|
|
319
|
+
"aria-label": r,
|
|
320
|
+
children: /* @__PURE__ */ E("ul", {
|
|
321
|
+
className: "piq-shell__bar-list",
|
|
322
|
+
children: v.map((e) => {
|
|
323
|
+
let r = !e.more && R(e, t), i = /* @__PURE__ */ D(T, { children: [e.icon && /* @__PURE__ */ E(n, { name: e.icon }), /* @__PURE__ */ E("span", {
|
|
324
|
+
className: "piq-shell__bar-label",
|
|
325
|
+
children: e.label
|
|
326
|
+
})] });
|
|
327
|
+
return /* @__PURE__ */ E("li", { children: e.more || e.items?.length ? /* @__PURE__ */ E("button", {
|
|
328
|
+
type: "button",
|
|
329
|
+
className: "piq-shell__bar-item",
|
|
330
|
+
"aria-haspopup": "dialog",
|
|
331
|
+
"aria-expanded": m,
|
|
332
|
+
"data-current": r || void 0,
|
|
333
|
+
onClick: x(e),
|
|
334
|
+
children: i
|
|
335
|
+
}) : /* @__PURE__ */ E("a", {
|
|
336
|
+
href: e.href,
|
|
337
|
+
className: "piq-shell__bar-item",
|
|
338
|
+
"aria-current": r ? "page" : void 0,
|
|
339
|
+
onClick: x(e),
|
|
340
|
+
children: i
|
|
341
|
+
}) }, e.id ?? e.label);
|
|
342
|
+
})
|
|
343
|
+
})
|
|
344
|
+
}),
|
|
345
|
+
/* @__PURE__ */ E(u, {
|
|
346
|
+
open: m,
|
|
347
|
+
onClose: () => h(!1),
|
|
348
|
+
label: r,
|
|
349
|
+
side: "start",
|
|
350
|
+
children: /* @__PURE__ */ E(V, {
|
|
351
|
+
items: e,
|
|
352
|
+
current: t,
|
|
353
|
+
label: r,
|
|
354
|
+
onNavigate: S
|
|
355
|
+
})
|
|
356
|
+
})
|
|
357
|
+
]
|
|
358
|
+
});
|
|
359
|
+
return d === "container" ? /* @__PURE__ */ E("div", {
|
|
360
|
+
className: "piq-shell-frame",
|
|
361
|
+
children: O
|
|
362
|
+
}) : O;
|
|
363
|
+
}
|
|
364
|
+
//#endregion
|
|
365
|
+
//#region src/patterns/ErrorScreen.jsx
|
|
366
|
+
var H = {
|
|
367
|
+
"not-found": {
|
|
368
|
+
icon: "search",
|
|
369
|
+
title: "We can't find that page",
|
|
370
|
+
text: "The link may be out of date, or the page may have moved."
|
|
371
|
+
},
|
|
372
|
+
forbidden: {
|
|
373
|
+
icon: "lock",
|
|
374
|
+
title: "You don't have access to this page",
|
|
375
|
+
text: "Ask the person who manages this workspace to give you access."
|
|
376
|
+
},
|
|
377
|
+
offline: {
|
|
378
|
+
icon: "warning",
|
|
379
|
+
title: "You're offline",
|
|
380
|
+
text: "Check your connection. What you were doing is kept on this page."
|
|
381
|
+
},
|
|
382
|
+
maintenance: {
|
|
383
|
+
icon: "settings",
|
|
384
|
+
title: "This service is being updated",
|
|
385
|
+
text: "It will be back shortly. Try again in a few minutes."
|
|
386
|
+
},
|
|
387
|
+
"session-expired": {
|
|
388
|
+
icon: "user",
|
|
389
|
+
title: "Your session has ended",
|
|
390
|
+
text: "For your security you were signed out. Sign in again to carry on."
|
|
391
|
+
}
|
|
392
|
+
}, ne = {
|
|
393
|
+
"not-found": {
|
|
394
|
+
label: "Go to the start",
|
|
395
|
+
href: "/"
|
|
396
|
+
},
|
|
397
|
+
forbidden: {
|
|
398
|
+
label: "Go back",
|
|
399
|
+
back: !0
|
|
400
|
+
},
|
|
401
|
+
offline: {
|
|
402
|
+
label: "Try again",
|
|
403
|
+
reload: !0
|
|
404
|
+
},
|
|
405
|
+
maintenance: {
|
|
406
|
+
label: "Try again",
|
|
407
|
+
reload: !0
|
|
408
|
+
},
|
|
409
|
+
"session-expired": {
|
|
410
|
+
label: "Sign in again",
|
|
411
|
+
reload: !0
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
function re({ kind: e = "not-found", title: t, children: r, actions: i, className: a, ...s }) {
|
|
415
|
+
let c = H[e] ?? H["not-found"], l = ne[e] ?? ne["not-found"], u = l.href ? /* @__PURE__ */ E("a", {
|
|
416
|
+
className: "piq-btn",
|
|
417
|
+
href: l.href,
|
|
418
|
+
children: l.label
|
|
419
|
+
}) : /* @__PURE__ */ E(o, {
|
|
420
|
+
onClick: () => l.back ? window.history.back() : window.location.reload(),
|
|
421
|
+
children: l.label
|
|
422
|
+
});
|
|
423
|
+
return /* @__PURE__ */ D("section", {
|
|
424
|
+
className: `piq-error-screen${a ? ` ${a}` : ""}`,
|
|
425
|
+
"data-kind": e,
|
|
426
|
+
...s,
|
|
427
|
+
children: [
|
|
428
|
+
/* @__PURE__ */ E(n, {
|
|
429
|
+
name: c.icon,
|
|
430
|
+
className: "piq-error-screen__mark"
|
|
431
|
+
}),
|
|
432
|
+
/* @__PURE__ */ E("h1", {
|
|
433
|
+
className: "piq-error-screen__title",
|
|
434
|
+
children: t ?? c.title
|
|
435
|
+
}),
|
|
436
|
+
/* @__PURE__ */ E("div", {
|
|
437
|
+
className: "piq-error-screen__text",
|
|
438
|
+
children: r ?? /* @__PURE__ */ E("p", { children: c.text })
|
|
439
|
+
}),
|
|
440
|
+
/* @__PURE__ */ E("div", {
|
|
441
|
+
className: "piq-error-screen__actions",
|
|
442
|
+
children: i ?? u
|
|
443
|
+
})
|
|
444
|
+
]
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
//#endregion
|
|
448
|
+
//#region src/patterns/Regions.jsx
|
|
449
|
+
var U = {
|
|
450
|
+
compact: 0,
|
|
451
|
+
medium: 600,
|
|
452
|
+
expanded: 840,
|
|
453
|
+
large: 1200,
|
|
454
|
+
"extra-large": 1600
|
|
455
|
+
};
|
|
456
|
+
function ie(e) {
|
|
457
|
+
return Object.entries(U).filter(([, t]) => e >= t).at(-1)[0];
|
|
458
|
+
}
|
|
459
|
+
function W(e) {
|
|
460
|
+
let [t, n] = w("compact");
|
|
461
|
+
return x(() => {
|
|
462
|
+
let t = e.current;
|
|
463
|
+
if (!t || typeof ResizeObserver != "function") return;
|
|
464
|
+
n(ie(t.getBoundingClientRect().width));
|
|
465
|
+
let r = new ResizeObserver(([e]) => n(ie(e.contentRect.width)));
|
|
466
|
+
return r.observe(t), () => r.disconnect();
|
|
467
|
+
}, [e]), t;
|
|
468
|
+
}
|
|
469
|
+
function G(e, t) {
|
|
470
|
+
return U[e] >= U[t];
|
|
471
|
+
}
|
|
472
|
+
function K(e, t = !0) {
|
|
473
|
+
x(() => {
|
|
474
|
+
let n = e.current;
|
|
475
|
+
if (!t || !n) return;
|
|
476
|
+
let r = n.parentElement;
|
|
477
|
+
for (; r && !/(auto|scroll)/.test(getComputedStyle(r).overflowY);) r = r.parentElement;
|
|
478
|
+
r ??= document.scrollingElement ?? document.documentElement;
|
|
479
|
+
let i = r.style.scrollPaddingBlockEnd, a = () => {
|
|
480
|
+
r.style.scrollPaddingBlockEnd = `${n.getBoundingClientRect().height + 8}px`;
|
|
481
|
+
};
|
|
482
|
+
a();
|
|
483
|
+
let o = typeof ResizeObserver == "function" ? new ResizeObserver(a) : null;
|
|
484
|
+
return o?.observe(n), () => {
|
|
485
|
+
o?.disconnect(), r.style.scrollPaddingBlockEnd = i;
|
|
486
|
+
};
|
|
487
|
+
}, [e, t]);
|
|
488
|
+
}
|
|
489
|
+
function q({ title: e, breadcrumbs: t, status: n, description: r, actions: i, secondaryActions: a, overflow: o, overflowLabel: c = "More actions", className: l }) {
|
|
490
|
+
return /* @__PURE__ */ D("header", {
|
|
491
|
+
className: `piq-page-header${l ? ` ${l}` : ""}`,
|
|
492
|
+
children: [
|
|
493
|
+
t,
|
|
494
|
+
/* @__PURE__ */ D("div", {
|
|
495
|
+
className: "piq-page-header__row",
|
|
496
|
+
children: [/* @__PURE__ */ D("div", {
|
|
497
|
+
className: "piq-page-header__heading",
|
|
498
|
+
children: [/* @__PURE__ */ E("h1", {
|
|
499
|
+
className: "piq-page-header__title",
|
|
500
|
+
children: e
|
|
501
|
+
}), n]
|
|
502
|
+
}), (i || a || o?.length) && /* @__PURE__ */ D("div", {
|
|
503
|
+
className: "piq-page-header__actions",
|
|
504
|
+
children: [
|
|
505
|
+
a,
|
|
506
|
+
i,
|
|
507
|
+
o?.length ? /* @__PURE__ */ E(s, {
|
|
508
|
+
icon: "more",
|
|
509
|
+
buttonLabel: c,
|
|
510
|
+
variant: "text",
|
|
511
|
+
align: "end",
|
|
512
|
+
items: o
|
|
513
|
+
}) : null
|
|
514
|
+
]
|
|
515
|
+
})]
|
|
516
|
+
}),
|
|
517
|
+
r && /* @__PURE__ */ E("p", {
|
|
518
|
+
className: "piq-page-header__description",
|
|
519
|
+
children: r
|
|
520
|
+
})
|
|
521
|
+
]
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
function ae({ search: e, onSearchChange: t, searchLabel: r = "Search", filters: i = [], onRemoveFilter: a, onClearAll: s, clearLabel: c = "Clear all", onOpenFilters: l, filtersOpen: u, filtersLabel: d = "Filters", appliedLabel: f = "Applied filters", removeLabel: p = (e) => `Remove filter: ${e.label}`, children: m, className: h }) {
|
|
525
|
+
let g = b();
|
|
526
|
+
return /* @__PURE__ */ D("div", {
|
|
527
|
+
className: `piq-filter-bar${h ? ` ${h}` : ""}`,
|
|
528
|
+
children: [/* @__PURE__ */ D("div", {
|
|
529
|
+
className: "piq-filter-bar__row",
|
|
530
|
+
children: [
|
|
531
|
+
t && /* @__PURE__ */ D("div", {
|
|
532
|
+
role: "search",
|
|
533
|
+
className: "piq-filter-bar__search",
|
|
534
|
+
children: [
|
|
535
|
+
/* @__PURE__ */ E("label", {
|
|
536
|
+
className: "piq-visually-hidden",
|
|
537
|
+
htmlFor: g,
|
|
538
|
+
children: r
|
|
539
|
+
}),
|
|
540
|
+
/* @__PURE__ */ E(n, {
|
|
541
|
+
name: "search",
|
|
542
|
+
className: "piq-filter-bar__search-icon"
|
|
543
|
+
}),
|
|
544
|
+
/* @__PURE__ */ E("input", {
|
|
545
|
+
id: g,
|
|
546
|
+
type: "search",
|
|
547
|
+
className: "piq-field__input",
|
|
548
|
+
placeholder: r,
|
|
549
|
+
value: e ?? "",
|
|
550
|
+
onChange: (e) => t(e.target.value)
|
|
551
|
+
})
|
|
552
|
+
]
|
|
553
|
+
}),
|
|
554
|
+
m,
|
|
555
|
+
l && /* @__PURE__ */ D(o, {
|
|
556
|
+
variant: "secondary",
|
|
557
|
+
className: "piq-filter-bar__open",
|
|
558
|
+
"aria-expanded": u,
|
|
559
|
+
onClick: l,
|
|
560
|
+
children: [/* @__PURE__ */ E(n, { name: "filter" }), i.length ? `${d} (${i.length})` : d]
|
|
561
|
+
})
|
|
562
|
+
]
|
|
563
|
+
}), i.length > 0 && /* @__PURE__ */ D("ul", {
|
|
564
|
+
className: "piq-filter-bar__chips",
|
|
565
|
+
"aria-label": f,
|
|
566
|
+
children: [i.map((e) => /* @__PURE__ */ D("li", {
|
|
567
|
+
className: "piq-chip",
|
|
568
|
+
children: [/* @__PURE__ */ E("span", { children: e.label }), a && /* @__PURE__ */ E("button", {
|
|
569
|
+
type: "button",
|
|
570
|
+
className: "piq-chip__remove",
|
|
571
|
+
"aria-label": p(e),
|
|
572
|
+
onClick: () => a(e),
|
|
573
|
+
children: /* @__PURE__ */ E(n, { name: "close" })
|
|
574
|
+
})]
|
|
575
|
+
}, e.id)), s && /* @__PURE__ */ E("li", { children: /* @__PURE__ */ E(o, {
|
|
576
|
+
variant: "text",
|
|
577
|
+
size: "sm",
|
|
578
|
+
onClick: s,
|
|
579
|
+
children: c
|
|
580
|
+
}) })]
|
|
581
|
+
})]
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
function oe({ open: e = !1, onClose: t, mode: r = "inline", title: i = "Filters", closeLabel: a = "Close filters", footer: s, children: c, className: l }) {
|
|
585
|
+
return r === "sheet" ? /* @__PURE__ */ D(u, {
|
|
586
|
+
open: e,
|
|
587
|
+
onClose: t,
|
|
588
|
+
title: i,
|
|
589
|
+
side: "full",
|
|
590
|
+
closeLabel: a,
|
|
591
|
+
className: l,
|
|
592
|
+
children: [c, s]
|
|
593
|
+
}) : e ? /* @__PURE__ */ D("aside", {
|
|
594
|
+
className: `piq-filter-panel${l ? ` ${l}` : ""}`,
|
|
595
|
+
"aria-label": i,
|
|
596
|
+
children: [
|
|
597
|
+
/* @__PURE__ */ D("div", {
|
|
598
|
+
className: "piq-filter-panel__head",
|
|
599
|
+
children: [/* @__PURE__ */ E("h2", {
|
|
600
|
+
className: "piq-filter-panel__title",
|
|
601
|
+
children: i
|
|
602
|
+
}), /* @__PURE__ */ E(o, {
|
|
603
|
+
variant: "text",
|
|
604
|
+
"aria-label": a,
|
|
605
|
+
onClick: () => t?.(),
|
|
606
|
+
children: /* @__PURE__ */ E(n, { name: "close" })
|
|
607
|
+
})]
|
|
608
|
+
}),
|
|
609
|
+
c,
|
|
610
|
+
s
|
|
611
|
+
]
|
|
612
|
+
}) : null;
|
|
613
|
+
}
|
|
614
|
+
function se({ title: e, count: t, defaultOpen: n = !0, children: r, className: i }) {
|
|
615
|
+
return /* @__PURE__ */ D("details", {
|
|
616
|
+
className: `piq-filter-section${i ? ` ${i}` : ""}`,
|
|
617
|
+
open: n,
|
|
618
|
+
children: [/* @__PURE__ */ D("summary", {
|
|
619
|
+
className: "piq-filter-section__title",
|
|
620
|
+
children: [e, t != null && /* @__PURE__ */ E("span", {
|
|
621
|
+
className: "piq-filter-section__count",
|
|
622
|
+
children: t
|
|
623
|
+
})]
|
|
624
|
+
}), /* @__PURE__ */ E("div", {
|
|
625
|
+
className: "piq-filter-section__body",
|
|
626
|
+
children: r
|
|
627
|
+
})]
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
var ce = {
|
|
631
|
+
empty: {
|
|
632
|
+
icon: "add",
|
|
633
|
+
title: "Nothing here yet",
|
|
634
|
+
text: "When there is something to show, it will be listed here."
|
|
635
|
+
},
|
|
636
|
+
"no-results": {
|
|
637
|
+
icon: "search",
|
|
638
|
+
title: "No results match",
|
|
639
|
+
text: "Try different words, or remove a filter."
|
|
640
|
+
},
|
|
641
|
+
forbidden: {
|
|
642
|
+
icon: "lock",
|
|
643
|
+
title: "You don't have access to this",
|
|
644
|
+
text: "Ask the person who manages this workspace to give you access."
|
|
645
|
+
},
|
|
646
|
+
error: {
|
|
647
|
+
icon: "error",
|
|
648
|
+
title: "This didn't load",
|
|
649
|
+
text: "Something went wrong on our side. Try again."
|
|
650
|
+
},
|
|
651
|
+
partial: {
|
|
652
|
+
icon: "warning",
|
|
653
|
+
title: "Some of this didn't load",
|
|
654
|
+
text: "What loaded is shown below. Try again for the rest."
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
function J({ kind: e = "empty", title: t, children: r, action: i, filters: a = [], onClearFilters: s, clearLabel: c = "Clear filters", onRetry: l, retryLabel: u = "Try again", activeLabel: d = "Active filters:", className: f }) {
|
|
658
|
+
let p = ce[e] ?? ce.empty;
|
|
659
|
+
return /* @__PURE__ */ D("div", {
|
|
660
|
+
className: `piq-state-panel${f ? ` ${f}` : ""}`,
|
|
661
|
+
"data-kind": e,
|
|
662
|
+
role: e === "error" ? "alert" : "status",
|
|
663
|
+
children: [
|
|
664
|
+
/* @__PURE__ */ E(n, {
|
|
665
|
+
name: p.icon,
|
|
666
|
+
className: "piq-state-panel__mark"
|
|
667
|
+
}),
|
|
668
|
+
/* @__PURE__ */ E("p", {
|
|
669
|
+
className: "piq-state-panel__title",
|
|
670
|
+
children: t ?? p.title
|
|
671
|
+
}),
|
|
672
|
+
/* @__PURE__ */ E("div", {
|
|
673
|
+
className: "piq-state-panel__text",
|
|
674
|
+
children: r ?? /* @__PURE__ */ E("p", { children: p.text })
|
|
675
|
+
}),
|
|
676
|
+
e === "no-results" && a.length > 0 && /* @__PURE__ */ D("p", {
|
|
677
|
+
className: "piq-state-panel__filters",
|
|
678
|
+
children: [
|
|
679
|
+
d,
|
|
680
|
+
" ",
|
|
681
|
+
a.map((e) => e.label).join(", ")
|
|
682
|
+
]
|
|
683
|
+
}),
|
|
684
|
+
/* @__PURE__ */ D("div", {
|
|
685
|
+
className: "piq-state-panel__actions",
|
|
686
|
+
children: [
|
|
687
|
+
e === "no-results" && s && /* @__PURE__ */ E(o, {
|
|
688
|
+
variant: "secondary",
|
|
689
|
+
onClick: s,
|
|
690
|
+
children: c
|
|
691
|
+
}),
|
|
692
|
+
(e === "error" || e === "partial") && l && /* @__PURE__ */ E(o, {
|
|
693
|
+
onClick: l,
|
|
694
|
+
children: u
|
|
695
|
+
}),
|
|
696
|
+
i
|
|
697
|
+
]
|
|
698
|
+
})
|
|
699
|
+
]
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
function le({ count: e = 0, children: t, onClearSelection: n, clearLabel: r = "Clear selection", label: i = "Bulk actions", selectedText: a = (e) => `${e} selected`, className: s }) {
|
|
703
|
+
let c = C(null);
|
|
704
|
+
K(c, e > 0);
|
|
705
|
+
function l(e) {
|
|
706
|
+
if (e.key !== "ArrowRight" && e.key !== "ArrowLeft") return;
|
|
707
|
+
let t = [...e.currentTarget.querySelectorAll("button:not([disabled]), a[href], input:not([disabled])")], n = t.indexOf(document.activeElement);
|
|
708
|
+
if (n < 0) return;
|
|
709
|
+
let r = getComputedStyle(e.currentTarget).direction === "rtl", i = e.key === "ArrowRight" === r ? -1 : 1;
|
|
710
|
+
e.preventDefault(), t[(n + i + t.length) % t.length].focus();
|
|
711
|
+
}
|
|
712
|
+
return /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E("span", {
|
|
713
|
+
className: "piq-visually-hidden",
|
|
714
|
+
role: "status",
|
|
715
|
+
"aria-live": "polite",
|
|
716
|
+
children: e ? a(e) : ""
|
|
717
|
+
}), e > 0 && /* @__PURE__ */ D("div", {
|
|
718
|
+
ref: c,
|
|
719
|
+
role: "toolbar",
|
|
720
|
+
"aria-label": i,
|
|
721
|
+
className: `piq-bulk-bar${s ? ` ${s}` : ""}`,
|
|
722
|
+
onKeyDown: l,
|
|
723
|
+
children: [
|
|
724
|
+
/* @__PURE__ */ E("span", {
|
|
725
|
+
className: "piq-bulk-bar__count",
|
|
726
|
+
children: a(e)
|
|
727
|
+
}),
|
|
728
|
+
/* @__PURE__ */ E("div", {
|
|
729
|
+
className: "piq-bulk-bar__actions",
|
|
730
|
+
children: t
|
|
731
|
+
}),
|
|
732
|
+
n && /* @__PURE__ */ E(o, {
|
|
733
|
+
variant: "text",
|
|
734
|
+
onClick: n,
|
|
735
|
+
children: r
|
|
736
|
+
})
|
|
737
|
+
]
|
|
738
|
+
})] });
|
|
739
|
+
}
|
|
740
|
+
//#endregion
|
|
741
|
+
//#region src/patterns/Forms.jsx
|
|
742
|
+
function ue(e) {
|
|
743
|
+
y(() => {
|
|
744
|
+
if (!e) return;
|
|
745
|
+
let t = (e) => {
|
|
746
|
+
e.preventDefault(), e.returnValue = "";
|
|
747
|
+
};
|
|
748
|
+
return window.addEventListener("beforeunload", t), () => window.removeEventListener("beforeunload", t);
|
|
749
|
+
}, [e]);
|
|
750
|
+
}
|
|
751
|
+
function de({ initial: e = {}, validate: t = () => ({}), onSubmit: n } = {}) {
|
|
752
|
+
let r = b(), [i, a] = w(e), [o, s] = w({}), [c, l] = w(!1), [u, d] = w(0), [f, p] = w(!1), m = C(e), h = S(() => Object.fromEntries(Object.entries(t(i) ?? {}).filter(([, e]) => e)), [i, t]), g = Object.keys({
|
|
753
|
+
...m.current,
|
|
754
|
+
...i
|
|
755
|
+
}).some((e) => i[e] !== m.current[e]), _ = v((e) => `${r}-${e}`, [r]), y = (e) => ({
|
|
756
|
+
id: _(e),
|
|
757
|
+
name: e,
|
|
758
|
+
value: i[e] ?? "",
|
|
759
|
+
onChange: (t) => a((n) => ({
|
|
760
|
+
...n,
|
|
761
|
+
[e]: t?.target ? t.target.type === "checkbox" ? t.target.checked : t.target.value : t
|
|
762
|
+
})),
|
|
763
|
+
onBlur: () => s((t) => ({
|
|
764
|
+
...t,
|
|
765
|
+
[e]: !0
|
|
766
|
+
})),
|
|
767
|
+
error: o[e] || c ? h[e] : void 0
|
|
768
|
+
});
|
|
769
|
+
async function x(e) {
|
|
770
|
+
if (e?.preventDefault?.(), l(!0), d((e) => e + 1), Object.keys(h).length) return !1;
|
|
771
|
+
p(!0);
|
|
772
|
+
try {
|
|
773
|
+
await n?.(i), m.current = i;
|
|
774
|
+
} finally {
|
|
775
|
+
p(!1);
|
|
776
|
+
}
|
|
777
|
+
return !0;
|
|
778
|
+
}
|
|
779
|
+
return {
|
|
780
|
+
values: i,
|
|
781
|
+
setValues: a,
|
|
782
|
+
errors: h,
|
|
783
|
+
shownErrors: c ? h : {},
|
|
784
|
+
field: y,
|
|
785
|
+
submit: x,
|
|
786
|
+
reset: (e = m.current) => {
|
|
787
|
+
m.current = e, a(e), s({}), l(!1);
|
|
788
|
+
},
|
|
789
|
+
dirty: g,
|
|
790
|
+
busy: f,
|
|
791
|
+
submitted: c,
|
|
792
|
+
attempt: u,
|
|
793
|
+
idOf: _
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
function fe({ errors: e = {}, idOf: t = (e) => e, title: n = "There is a problem", attempt: r = 0, className: i }) {
|
|
797
|
+
let a = C(null), o = Object.entries(e);
|
|
798
|
+
return y(() => {
|
|
799
|
+
o.length && a.current?.focus();
|
|
800
|
+
}, [r]), o.length ? /* @__PURE__ */ D("div", {
|
|
801
|
+
ref: a,
|
|
802
|
+
tabIndex: -1,
|
|
803
|
+
className: `piq-error-summary${i ? ` ${i}` : ""}`,
|
|
804
|
+
"aria-labelledby": `${t("summary")}-title`,
|
|
805
|
+
children: [/* @__PURE__ */ E("h2", {
|
|
806
|
+
id: `${t("summary")}-title`,
|
|
807
|
+
className: "piq-error-summary__title",
|
|
808
|
+
children: n
|
|
809
|
+
}), /* @__PURE__ */ E("ul", {
|
|
810
|
+
className: "piq-error-summary__list",
|
|
811
|
+
children: o.map(([e, n]) => /* @__PURE__ */ E("li", { children: /* @__PURE__ */ E("a", {
|
|
812
|
+
href: `#${t(e)}`,
|
|
813
|
+
onClick: (n) => {
|
|
814
|
+
n.preventDefault();
|
|
815
|
+
let r = document.getElementById(t(e));
|
|
816
|
+
r?.focus(), r?.scrollIntoView?.({ block: "center" });
|
|
817
|
+
},
|
|
818
|
+
children: n
|
|
819
|
+
}) }, e))
|
|
820
|
+
})]
|
|
821
|
+
}) : null;
|
|
822
|
+
}
|
|
823
|
+
function Y({ title: e, description: t, children: n, className: r }) {
|
|
824
|
+
return /* @__PURE__ */ D("fieldset", {
|
|
825
|
+
className: `piq-form-section${r ? ` ${r}` : ""}`,
|
|
826
|
+
children: [
|
|
827
|
+
/* @__PURE__ */ E("legend", {
|
|
828
|
+
className: "piq-form-section__title",
|
|
829
|
+
children: e
|
|
830
|
+
}),
|
|
831
|
+
t && /* @__PURE__ */ E("p", {
|
|
832
|
+
className: "piq-form-section__description",
|
|
833
|
+
children: t
|
|
834
|
+
}),
|
|
835
|
+
/* @__PURE__ */ E("div", {
|
|
836
|
+
className: "piq-form-section__fields",
|
|
837
|
+
children: n
|
|
838
|
+
})
|
|
839
|
+
]
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
function pe({ title: e, breadcrumbs: n, description: r, form: i, onCancel: a, submitLabel: s = "Save", cancelLabel: c = "Cancel", discardTitle: l = "Discard your changes?", discardText: u = "What you have typed will be lost.", keepLabel: d = "Keep editing", discardLabel: f = "Discard", children: p, className: m }) {
|
|
843
|
+
let h = C(null), g = C(null), [_, v] = w(!1);
|
|
844
|
+
return K(h, !0), ue(i?.dirty), /* @__PURE__ */ D("form", {
|
|
845
|
+
className: `piq-form-page${m ? ` ${m}` : ""}`,
|
|
846
|
+
noValidate: !0,
|
|
847
|
+
onSubmit: i?.submit,
|
|
848
|
+
children: [
|
|
849
|
+
/* @__PURE__ */ E(q, {
|
|
850
|
+
title: e,
|
|
851
|
+
breadcrumbs: n,
|
|
852
|
+
description: r
|
|
853
|
+
}),
|
|
854
|
+
/* @__PURE__ */ E(fe, {
|
|
855
|
+
errors: i?.shownErrors,
|
|
856
|
+
idOf: i?.idOf,
|
|
857
|
+
attempt: i?.attempt
|
|
858
|
+
}),
|
|
859
|
+
/* @__PURE__ */ E("div", {
|
|
860
|
+
className: "piq-form-page__fields",
|
|
861
|
+
children: p
|
|
862
|
+
}),
|
|
863
|
+
/* @__PURE__ */ D("div", {
|
|
864
|
+
ref: h,
|
|
865
|
+
className: "piq-form-page__actions",
|
|
866
|
+
children: [/* @__PURE__ */ E(o, {
|
|
867
|
+
type: "submit",
|
|
868
|
+
busy: i?.busy,
|
|
869
|
+
children: s
|
|
870
|
+
}), a && /* @__PURE__ */ E(o, {
|
|
871
|
+
variant: "secondary",
|
|
872
|
+
onClick: () => i?.dirty ? v(!0) : a?.(),
|
|
873
|
+
children: c
|
|
874
|
+
})]
|
|
875
|
+
}),
|
|
876
|
+
/* @__PURE__ */ E(t, {
|
|
877
|
+
open: _,
|
|
878
|
+
onClose: () => v(!1),
|
|
879
|
+
role: "alertdialog",
|
|
880
|
+
title: l,
|
|
881
|
+
description: u,
|
|
882
|
+
initialFocus: g,
|
|
883
|
+
actions: /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E(o, {
|
|
884
|
+
ref: g,
|
|
885
|
+
variant: "secondary",
|
|
886
|
+
onClick: () => v(!1),
|
|
887
|
+
children: d
|
|
888
|
+
}), /* @__PURE__ */ E(o, {
|
|
889
|
+
onClick: () => {
|
|
890
|
+
v(!1), a?.();
|
|
891
|
+
},
|
|
892
|
+
children: f
|
|
893
|
+
})] })
|
|
894
|
+
})
|
|
895
|
+
]
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
function X() {
|
|
899
|
+
let e = "(min-width: 600px)", [t, n] = w(() => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(e).matches);
|
|
900
|
+
return y(() => {
|
|
901
|
+
if (typeof window.matchMedia != "function") return;
|
|
902
|
+
let t = window.matchMedia(e), r = () => n(t.matches);
|
|
903
|
+
return r(), t.addEventListener("change", r), () => t.removeEventListener("change", r);
|
|
904
|
+
}, []), t;
|
|
905
|
+
}
|
|
906
|
+
function me({ open: e = !1, onClose: n, title: r, form: i, submitLabel: a = "Save", cancelLabel: s = "Cancel", children: c, className: l }) {
|
|
907
|
+
let d = X(), f = /* @__PURE__ */ D("form", {
|
|
908
|
+
className: "piq-quick-edit",
|
|
909
|
+
noValidate: !0,
|
|
910
|
+
onSubmit: async (e) => {
|
|
911
|
+
await i?.submit(e) && n?.();
|
|
912
|
+
},
|
|
913
|
+
children: [
|
|
914
|
+
/* @__PURE__ */ E(fe, {
|
|
915
|
+
errors: i?.shownErrors,
|
|
916
|
+
idOf: i?.idOf,
|
|
917
|
+
attempt: i?.attempt
|
|
918
|
+
}),
|
|
919
|
+
/* @__PURE__ */ E("div", {
|
|
920
|
+
className: "piq-quick-edit__fields",
|
|
921
|
+
children: c
|
|
922
|
+
}),
|
|
923
|
+
/* @__PURE__ */ D("div", {
|
|
924
|
+
className: "piq-quick-edit__actions",
|
|
925
|
+
children: [/* @__PURE__ */ E(o, {
|
|
926
|
+
type: "submit",
|
|
927
|
+
busy: i?.busy,
|
|
928
|
+
children: a
|
|
929
|
+
}), /* @__PURE__ */ E(o, {
|
|
930
|
+
variant: "secondary",
|
|
931
|
+
onClick: () => n?.(),
|
|
932
|
+
children: s
|
|
933
|
+
})]
|
|
934
|
+
})
|
|
935
|
+
]
|
|
936
|
+
});
|
|
937
|
+
return d ? /* @__PURE__ */ E(t, {
|
|
938
|
+
open: e,
|
|
939
|
+
onClose: n,
|
|
940
|
+
title: r,
|
|
941
|
+
className: l,
|
|
942
|
+
children: f
|
|
943
|
+
}) : /* @__PURE__ */ E(u, {
|
|
944
|
+
open: e,
|
|
945
|
+
onClose: n,
|
|
946
|
+
title: r,
|
|
947
|
+
side: "full",
|
|
948
|
+
className: l,
|
|
949
|
+
children: f
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
function Z({ open: e = !1, onConfirm: n, onCancel: r, title: i, objectName: a, consequence: s, confirmLabel: c = "Delete", cancelLabel: l = "Cancel", requireTyping: u = !1, typeLabel: d = (e) => `Type ${e} to confirm`, className: f }) {
|
|
953
|
+
let p = C(null), [m, h] = w(""), g = b();
|
|
954
|
+
y(() => {
|
|
955
|
+
e || h("");
|
|
956
|
+
}, [e]);
|
|
957
|
+
let _ = !u || m.trim() === String(a);
|
|
958
|
+
return /* @__PURE__ */ E(t, {
|
|
959
|
+
open: e,
|
|
960
|
+
onClose: r,
|
|
961
|
+
role: "alertdialog",
|
|
962
|
+
title: i ?? `Delete ${a}?`,
|
|
963
|
+
description: s,
|
|
964
|
+
initialFocus: p,
|
|
965
|
+
className: `piq-confirm${f ? ` ${f}` : ""}`,
|
|
966
|
+
actions: /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E(o, {
|
|
967
|
+
ref: p,
|
|
968
|
+
variant: "secondary",
|
|
969
|
+
onClick: () => r?.(),
|
|
970
|
+
children: l
|
|
971
|
+
}), /* @__PURE__ */ E(o, {
|
|
972
|
+
className: "piq-confirm__action",
|
|
973
|
+
disabled: !_,
|
|
974
|
+
onClick: () => _ && n?.(),
|
|
975
|
+
children: c
|
|
976
|
+
})] }),
|
|
977
|
+
children: u && /* @__PURE__ */ D("div", {
|
|
978
|
+
className: "piq-field",
|
|
979
|
+
children: [/* @__PURE__ */ E("label", {
|
|
980
|
+
className: "piq-field__label",
|
|
981
|
+
htmlFor: g,
|
|
982
|
+
children: d(a)
|
|
983
|
+
}), /* @__PURE__ */ E("input", {
|
|
984
|
+
id: g,
|
|
985
|
+
className: "piq-field__input",
|
|
986
|
+
autoComplete: "off",
|
|
987
|
+
spellCheck: !1,
|
|
988
|
+
value: m,
|
|
989
|
+
onChange: (e) => h(e.target.value)
|
|
990
|
+
})]
|
|
991
|
+
})
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
//#endregion
|
|
995
|
+
//#region src/patterns/CollectionList.jsx
|
|
996
|
+
var he = /* @__PURE__ */ new Set(["ready", "partial"]);
|
|
997
|
+
function ge({ key: e = "list", defaults: t = {} } = {}) {
|
|
998
|
+
let n = C(null);
|
|
999
|
+
n.current = {
|
|
1000
|
+
page: 1,
|
|
1001
|
+
pageSize: 20,
|
|
1002
|
+
q: "",
|
|
1003
|
+
filters: [],
|
|
1004
|
+
sort: null,
|
|
1005
|
+
...t
|
|
1006
|
+
};
|
|
1007
|
+
let r = v(() => {
|
|
1008
|
+
let t = n.current;
|
|
1009
|
+
if (typeof window > "u") return t;
|
|
1010
|
+
let r = new URLSearchParams(window.location.search), i = (t) => r.get(`${e}.${t}`), [a, o] = (i("sort") ?? "").split(":");
|
|
1011
|
+
return {
|
|
1012
|
+
page: Number(i("page")) || t.page,
|
|
1013
|
+
pageSize: Number(i("size")) || t.pageSize,
|
|
1014
|
+
q: i("q") ?? t.q,
|
|
1015
|
+
filters: i("f") ? i("f").split(",").filter(Boolean) : t.filters,
|
|
1016
|
+
sort: a ? {
|
|
1017
|
+
key: a,
|
|
1018
|
+
dir: o === "descending" ? "descending" : "ascending"
|
|
1019
|
+
} : t.sort
|
|
1020
|
+
};
|
|
1021
|
+
}, [e]), [i, a] = w(r);
|
|
1022
|
+
return y(() => {
|
|
1023
|
+
let e = () => a(r());
|
|
1024
|
+
return window.addEventListener("popstate", e), () => window.removeEventListener("popstate", e);
|
|
1025
|
+
}, [r]), [i, v((t) => {
|
|
1026
|
+
a((r) => {
|
|
1027
|
+
let i = n.current, a = {
|
|
1028
|
+
...r,
|
|
1029
|
+
...t
|
|
1030
|
+
};
|
|
1031
|
+
("q" in t || "filters" in t) && !("page" in t) && (a.page = 1);
|
|
1032
|
+
let o = new URLSearchParams(window.location.search), s = (t, n, r) => n === r || n === "" || n == null ? o.delete(`${e}.${t}`) : o.set(`${e}.${t}`, n);
|
|
1033
|
+
s("page", a.page, i.page), s("size", a.pageSize, i.pageSize), s("q", a.q, ""), s("f", a.filters.join(","), ""), s("sort", a.sort ? `${a.sort.key}:${a.sort.dir}` : null, null);
|
|
1034
|
+
let c = o.toString();
|
|
1035
|
+
return window.history.replaceState(window.history.state, "", `${window.location.pathname}${c ? `?${c}` : ""}${window.location.hash}`), a;
|
|
1036
|
+
});
|
|
1037
|
+
}, [e])];
|
|
1038
|
+
}
|
|
1039
|
+
function _e(e) {
|
|
1040
|
+
let t = e.filter((e) => e.priority).map((e) => e.key);
|
|
1041
|
+
return new Set(t.length ? t : e.slice(0, 2).map((e) => e.key));
|
|
1042
|
+
}
|
|
1043
|
+
var ve = (e, t) => e.render ? e.render(t) : t[e.key];
|
|
1044
|
+
function ye({ rows: e, keyOf: t, selected: n, onChange: r, label: i }) {
|
|
1045
|
+
let a = C(null), o = e.filter((e) => n.includes(t(e))).length;
|
|
1046
|
+
return y(() => {
|
|
1047
|
+
a.current && (a.current.indeterminate = o > 0 && o < e.length);
|
|
1048
|
+
}, [o, e.length]), /* @__PURE__ */ E("label", {
|
|
1049
|
+
className: "piq-collection__hit",
|
|
1050
|
+
children: /* @__PURE__ */ E("input", {
|
|
1051
|
+
ref: a,
|
|
1052
|
+
type: "checkbox",
|
|
1053
|
+
className: "piq-check__box",
|
|
1054
|
+
"aria-label": i,
|
|
1055
|
+
checked: e.length > 0 && o === e.length,
|
|
1056
|
+
onChange: (i) => r(i.target.checked ? [.../* @__PURE__ */ new Set([...n, ...e.map(t)])] : n.filter((n) => !e.some((e) => t(e) === n)))
|
|
1057
|
+
})
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
function be({ title: t, breadcrumbs: r, statusPill: i, actions: a, secondaryActions: c, overflow: l, columns: u = [], rows: d = [], rowKey: p = "id", rowLabel: m, caption: h, status: g = "ready", onRetry: _, search: v, onSearchChange: y, searchLabel: x = "Search", filters: S = [], onRemoveFilter: T, onClearFilters: O, filterPanel: k, filtersLabel: A = "Filters", selectable: j = !1, selected: M = [], onSelectedChange: N, bulkActions: P, rowActions: F, rowActionsLabel: I = (e) => `Actions for ${e}`, selectRowLabel: L = (e) => `Select ${e}`, selectAllLabel: R = "Select all on this page", sort: z, onSortChange: B, page: V = 1, pageSize: ee = 20, total: te, onPageChange: H, pageSizes: ne, onPageSizeChange: re, empty: U, showResultsLabel: ie = "Show results", className: K }) {
|
|
1061
|
+
let se = C(null), ce = W(se), [ue, de] = w(!1), fe = b(), Y = (e) => e[p], pe = (e) => String(m ? m(e) : e[u[0]?.key] ?? Y(e)), X = _e(u), me = S.length > 0 || !!v, Z = g === "empty" && me ? "no-results" : g, ge = (e, t) => N?.(t ? [...M, Y(e)] : M.filter((t) => t !== Y(e))), be = G(ce, "expanded") ? "inline" : "sheet", xe = (e) => B?.(z?.key === e.key && z.dir === "ascending" ? {
|
|
1062
|
+
key: e.key,
|
|
1063
|
+
dir: "descending"
|
|
1064
|
+
} : {
|
|
1065
|
+
key: e.key,
|
|
1066
|
+
dir: "ascending"
|
|
1067
|
+
}), Se = (e) => {
|
|
1068
|
+
let t = F?.(e);
|
|
1069
|
+
return t?.length ? /* @__PURE__ */ E(s, {
|
|
1070
|
+
icon: "more",
|
|
1071
|
+
variant: "text",
|
|
1072
|
+
size: "sm",
|
|
1073
|
+
align: "end",
|
|
1074
|
+
buttonLabel: I(pe(e)),
|
|
1075
|
+
items: t
|
|
1076
|
+
}) : null;
|
|
1077
|
+
}, Ce = (e, t) => /* @__PURE__ */ E("label", {
|
|
1078
|
+
className: "piq-collection__hit",
|
|
1079
|
+
children: /* @__PURE__ */ E("input", {
|
|
1080
|
+
type: "checkbox",
|
|
1081
|
+
className: "piq-check__box",
|
|
1082
|
+
id: `${fe}-${t}-${Y(e)}`,
|
|
1083
|
+
"aria-label": L(pe(e)),
|
|
1084
|
+
checked: M.includes(Y(e)),
|
|
1085
|
+
onChange: (t) => ge(e, t.target.checked)
|
|
1086
|
+
})
|
|
1087
|
+
}), we = Math.min(ee, 50), Te;
|
|
1088
|
+
return Te = Z === "loading" ? /* @__PURE__ */ D("div", {
|
|
1089
|
+
className: "piq-collection__results",
|
|
1090
|
+
"aria-busy": "true",
|
|
1091
|
+
children: [/* @__PURE__ */ E("ul", {
|
|
1092
|
+
className: "piq-collection__items",
|
|
1093
|
+
"aria-hidden": "true",
|
|
1094
|
+
children: Array.from({ length: we }, (t, n) => /* @__PURE__ */ E("li", {
|
|
1095
|
+
className: "piq-collection__item",
|
|
1096
|
+
children: /* @__PURE__ */ E(e, { lines: 2 })
|
|
1097
|
+
}, n))
|
|
1098
|
+
}), /* @__PURE__ */ E("div", {
|
|
1099
|
+
className: "piq-collection__table-wrap",
|
|
1100
|
+
"aria-hidden": "true",
|
|
1101
|
+
children: /* @__PURE__ */ D("table", {
|
|
1102
|
+
className: "piq-table piq-collection__table",
|
|
1103
|
+
children: [/* @__PURE__ */ E("thead", { children: /* @__PURE__ */ D("tr", { children: [
|
|
1104
|
+
j && /* @__PURE__ */ E("th", {
|
|
1105
|
+
className: "piq-collection__select",
|
|
1106
|
+
children: /* @__PURE__ */ E("span", {
|
|
1107
|
+
className: "piq-collection__hit",
|
|
1108
|
+
children: /* @__PURE__ */ E("input", {
|
|
1109
|
+
type: "checkbox",
|
|
1110
|
+
className: "piq-check__box",
|
|
1111
|
+
disabled: !0,
|
|
1112
|
+
tabIndex: -1
|
|
1113
|
+
})
|
|
1114
|
+
})
|
|
1115
|
+
}),
|
|
1116
|
+
u.map((e) => /* @__PURE__ */ E("th", {
|
|
1117
|
+
"data-priority": X.has(e.key),
|
|
1118
|
+
className: e.numeric ? "piq-num" : void 0,
|
|
1119
|
+
children: e.label
|
|
1120
|
+
}, e.key)),
|
|
1121
|
+
F && /* @__PURE__ */ E("th", { className: "piq-collection__actions" })
|
|
1122
|
+
] }) }), /* @__PURE__ */ E("tbody", { children: Array.from({ length: we }, (t, r) => /* @__PURE__ */ D("tr", { children: [
|
|
1123
|
+
j && /* @__PURE__ */ E("td", {
|
|
1124
|
+
className: "piq-collection__select",
|
|
1125
|
+
children: /* @__PURE__ */ E("span", {
|
|
1126
|
+
className: "piq-collection__hit",
|
|
1127
|
+
children: /* @__PURE__ */ E("input", {
|
|
1128
|
+
type: "checkbox",
|
|
1129
|
+
className: "piq-check__box",
|
|
1130
|
+
disabled: !0,
|
|
1131
|
+
tabIndex: -1
|
|
1132
|
+
})
|
|
1133
|
+
})
|
|
1134
|
+
}),
|
|
1135
|
+
u.map((t) => /* @__PURE__ */ E("td", {
|
|
1136
|
+
"data-priority": X.has(t.key),
|
|
1137
|
+
children: /* @__PURE__ */ E(e, {})
|
|
1138
|
+
}, t.key)),
|
|
1139
|
+
F && /* @__PURE__ */ E("td", {
|
|
1140
|
+
className: "piq-collection__actions",
|
|
1141
|
+
children: /* @__PURE__ */ E(o, {
|
|
1142
|
+
variant: "text",
|
|
1143
|
+
size: "sm",
|
|
1144
|
+
disabled: !0,
|
|
1145
|
+
tabIndex: -1,
|
|
1146
|
+
children: /* @__PURE__ */ E(n, { name: "more" })
|
|
1147
|
+
})
|
|
1148
|
+
})
|
|
1149
|
+
] }, r)) })]
|
|
1150
|
+
})
|
|
1151
|
+
})]
|
|
1152
|
+
}) : he.has(Z) ? /* @__PURE__ */ D("div", {
|
|
1153
|
+
className: "piq-collection__results",
|
|
1154
|
+
children: [
|
|
1155
|
+
Z === "partial" && /* @__PURE__ */ E(J, {
|
|
1156
|
+
kind: "partial",
|
|
1157
|
+
onRetry: _
|
|
1158
|
+
}),
|
|
1159
|
+
/* @__PURE__ */ E("ul", {
|
|
1160
|
+
className: "piq-collection__items",
|
|
1161
|
+
"aria-label": h ?? t,
|
|
1162
|
+
children: d.map((e) => {
|
|
1163
|
+
let t = u.filter((e) => X.has(e.key));
|
|
1164
|
+
return /* @__PURE__ */ D("li", {
|
|
1165
|
+
className: "piq-collection__item",
|
|
1166
|
+
"data-selected": j && M.includes(Y(e)) ? "" : void 0,
|
|
1167
|
+
children: [
|
|
1168
|
+
j && Ce(e, "item"),
|
|
1169
|
+
/* @__PURE__ */ E("div", {
|
|
1170
|
+
className: "piq-collection__fields",
|
|
1171
|
+
children: t.map((t, n) => n === 0 ? /* @__PURE__ */ E("p", {
|
|
1172
|
+
className: "piq-collection__primary",
|
|
1173
|
+
children: ve(t, e)
|
|
1174
|
+
}, t.key) : /* @__PURE__ */ D("p", {
|
|
1175
|
+
className: "piq-collection__field",
|
|
1176
|
+
children: [/* @__PURE__ */ D("span", {
|
|
1177
|
+
className: "piq-visually-hidden",
|
|
1178
|
+
children: [t.label, ": "]
|
|
1179
|
+
}), ve(t, e)]
|
|
1180
|
+
}, t.key))
|
|
1181
|
+
}),
|
|
1182
|
+
Se(e)
|
|
1183
|
+
]
|
|
1184
|
+
}, Y(e));
|
|
1185
|
+
})
|
|
1186
|
+
}),
|
|
1187
|
+
/* @__PURE__ */ E("div", {
|
|
1188
|
+
className: "piq-collection__table-wrap",
|
|
1189
|
+
children: /* @__PURE__ */ D("table", {
|
|
1190
|
+
className: "piq-table piq-collection__table",
|
|
1191
|
+
children: [
|
|
1192
|
+
(h ?? t) && /* @__PURE__ */ E("caption", {
|
|
1193
|
+
className: "piq-visually-hidden",
|
|
1194
|
+
children: h ?? t
|
|
1195
|
+
}),
|
|
1196
|
+
/* @__PURE__ */ E("thead", { children: /* @__PURE__ */ D("tr", { children: [
|
|
1197
|
+
j && /* @__PURE__ */ E("th", {
|
|
1198
|
+
scope: "col",
|
|
1199
|
+
className: "piq-collection__select",
|
|
1200
|
+
children: /* @__PURE__ */ E(ye, {
|
|
1201
|
+
rows: d,
|
|
1202
|
+
keyOf: Y,
|
|
1203
|
+
selected: M,
|
|
1204
|
+
onChange: (e) => N?.(e),
|
|
1205
|
+
label: R
|
|
1206
|
+
})
|
|
1207
|
+
}),
|
|
1208
|
+
u.map((e) => {
|
|
1209
|
+
let t = z?.key === e.key ? z.dir : void 0;
|
|
1210
|
+
return /* @__PURE__ */ E("th", {
|
|
1211
|
+
scope: "col",
|
|
1212
|
+
"data-priority": X.has(e.key),
|
|
1213
|
+
className: e.numeric ? "piq-num" : void 0,
|
|
1214
|
+
"aria-sort": e.sortable ? t ?? "none" : void 0,
|
|
1215
|
+
children: e.sortable && B ? /* @__PURE__ */ D("button", {
|
|
1216
|
+
type: "button",
|
|
1217
|
+
className: "piq-table__sort",
|
|
1218
|
+
onClick: () => xe(e),
|
|
1219
|
+
children: [e.label, /* @__PURE__ */ E("span", {
|
|
1220
|
+
className: "piq-table__arrow",
|
|
1221
|
+
"aria-hidden": "true",
|
|
1222
|
+
children: t === "descending" ? "↓" : t === "ascending" ? "↑" : "↕"
|
|
1223
|
+
})]
|
|
1224
|
+
}) : e.label
|
|
1225
|
+
}, e.key);
|
|
1226
|
+
}),
|
|
1227
|
+
F && /* @__PURE__ */ E("th", {
|
|
1228
|
+
scope: "col",
|
|
1229
|
+
className: "piq-collection__actions",
|
|
1230
|
+
children: /* @__PURE__ */ E("span", {
|
|
1231
|
+
className: "piq-visually-hidden",
|
|
1232
|
+
children: "Actions"
|
|
1233
|
+
})
|
|
1234
|
+
})
|
|
1235
|
+
] }) }),
|
|
1236
|
+
/* @__PURE__ */ E("tbody", { children: d.map((e) => /* @__PURE__ */ D("tr", {
|
|
1237
|
+
"data-selected": j && M.includes(Y(e)) ? "" : void 0,
|
|
1238
|
+
children: [
|
|
1239
|
+
j && /* @__PURE__ */ E("td", {
|
|
1240
|
+
className: "piq-collection__select",
|
|
1241
|
+
children: Ce(e, "row")
|
|
1242
|
+
}),
|
|
1243
|
+
u.map((t) => /* @__PURE__ */ E("td", {
|
|
1244
|
+
"data-priority": X.has(t.key),
|
|
1245
|
+
className: t.numeric ? "piq-num" : void 0,
|
|
1246
|
+
children: ve(t, e)
|
|
1247
|
+
}, t.key)),
|
|
1248
|
+
F && /* @__PURE__ */ E("td", {
|
|
1249
|
+
className: "piq-collection__actions",
|
|
1250
|
+
children: Se(e)
|
|
1251
|
+
})
|
|
1252
|
+
]
|
|
1253
|
+
}, Y(e))) })
|
|
1254
|
+
]
|
|
1255
|
+
})
|
|
1256
|
+
}),
|
|
1257
|
+
te > 0 && H && /* @__PURE__ */ E(f, {
|
|
1258
|
+
page: V,
|
|
1259
|
+
pageSize: ee,
|
|
1260
|
+
total: te,
|
|
1261
|
+
onPageChange: H,
|
|
1262
|
+
pageSizes: ne,
|
|
1263
|
+
onPageSizeChange: re
|
|
1264
|
+
})
|
|
1265
|
+
]
|
|
1266
|
+
}) : /* @__PURE__ */ E("div", {
|
|
1267
|
+
className: "piq-collection__results",
|
|
1268
|
+
children: Z === "empty" && U ? U : /* @__PURE__ */ E(J, {
|
|
1269
|
+
kind: Z,
|
|
1270
|
+
filters: S,
|
|
1271
|
+
onClearFilters: O,
|
|
1272
|
+
onRetry: _
|
|
1273
|
+
})
|
|
1274
|
+
}), /* @__PURE__ */ D("div", {
|
|
1275
|
+
ref: se,
|
|
1276
|
+
className: `piq-collection${K ? ` ${K}` : ""}`,
|
|
1277
|
+
"data-size": ce,
|
|
1278
|
+
children: [
|
|
1279
|
+
/* @__PURE__ */ E(q, {
|
|
1280
|
+
title: t,
|
|
1281
|
+
breadcrumbs: r,
|
|
1282
|
+
status: i,
|
|
1283
|
+
actions: a,
|
|
1284
|
+
secondaryActions: c,
|
|
1285
|
+
overflow: l
|
|
1286
|
+
}),
|
|
1287
|
+
/* @__PURE__ */ E(ae, {
|
|
1288
|
+
search: v,
|
|
1289
|
+
onSearchChange: y,
|
|
1290
|
+
searchLabel: x,
|
|
1291
|
+
filters: S,
|
|
1292
|
+
onRemoveFilter: T,
|
|
1293
|
+
onClearAll: O,
|
|
1294
|
+
onOpenFilters: k ? () => de((e) => !e) : void 0,
|
|
1295
|
+
filtersOpen: k ? ue : void 0,
|
|
1296
|
+
filtersLabel: A
|
|
1297
|
+
}),
|
|
1298
|
+
/* @__PURE__ */ D("div", {
|
|
1299
|
+
className: "piq-collection__body",
|
|
1300
|
+
"data-panel": ue && be === "inline" ? "open" : void 0,
|
|
1301
|
+
children: [k && /* @__PURE__ */ E(oe, {
|
|
1302
|
+
open: ue,
|
|
1303
|
+
mode: be,
|
|
1304
|
+
title: A,
|
|
1305
|
+
onClose: () => de(!1),
|
|
1306
|
+
footer: be === "sheet" ? /* @__PURE__ */ E(o, {
|
|
1307
|
+
onClick: () => de(!1),
|
|
1308
|
+
children: ie
|
|
1309
|
+
}) : null,
|
|
1310
|
+
children: k
|
|
1311
|
+
}), Te]
|
|
1312
|
+
}),
|
|
1313
|
+
j && /* @__PURE__ */ E(le, {
|
|
1314
|
+
count: M.length,
|
|
1315
|
+
onClearSelection: () => N?.([]),
|
|
1316
|
+
children: P
|
|
1317
|
+
})
|
|
1318
|
+
]
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
//#endregion
|
|
1322
|
+
//#region src/patterns/Record.jsx
|
|
1323
|
+
function xe({ items: e = [], className: t, ...n }) {
|
|
1324
|
+
return /* @__PURE__ */ E("div", {
|
|
1325
|
+
className: `piq-description-list${t ? ` ${t}` : ""}`,
|
|
1326
|
+
...n,
|
|
1327
|
+
children: /* @__PURE__ */ E("dl", {
|
|
1328
|
+
className: "piq-description-list__grid",
|
|
1329
|
+
children: e.map((e, t) => /* @__PURE__ */ D("div", {
|
|
1330
|
+
className: "piq-description-list__item",
|
|
1331
|
+
"data-wide": e.wide || void 0,
|
|
1332
|
+
children: [/* @__PURE__ */ E("dt", {
|
|
1333
|
+
className: "piq-description-list__label",
|
|
1334
|
+
children: e.label
|
|
1335
|
+
}), /* @__PURE__ */ E("dd", {
|
|
1336
|
+
className: "piq-description-list__value",
|
|
1337
|
+
children: e.value ?? "—"
|
|
1338
|
+
})]
|
|
1339
|
+
}, e.key ?? t))
|
|
1340
|
+
})
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1343
|
+
var Se = {
|
|
1344
|
+
comment: {
|
|
1345
|
+
icon: "edit",
|
|
1346
|
+
label: "Comment"
|
|
1347
|
+
},
|
|
1348
|
+
change: {
|
|
1349
|
+
icon: "refresh",
|
|
1350
|
+
label: "Change"
|
|
1351
|
+
},
|
|
1352
|
+
system: {
|
|
1353
|
+
icon: "info",
|
|
1354
|
+
label: "System"
|
|
1355
|
+
}
|
|
1356
|
+
}, Ce = (e) => e instanceof Date ? e : new Date(e);
|
|
1357
|
+
function we({ events: e = [], label: t = "Activity", order: r = "newest", kindLabels: i = {}, locale: a, className: o }) {
|
|
1358
|
+
let s = [...e].sort((e, t) => (r === "oldest" ? 1 : -1) * (Ce(e.time) - Ce(t.time))), c = new Intl.DateTimeFormat(a, {
|
|
1359
|
+
dateStyle: "medium",
|
|
1360
|
+
timeStyle: "short"
|
|
1361
|
+
});
|
|
1362
|
+
return /* @__PURE__ */ E("section", {
|
|
1363
|
+
className: `piq-timeline${o ? ` ${o}` : ""}`,
|
|
1364
|
+
"aria-label": t,
|
|
1365
|
+
children: /* @__PURE__ */ E("ol", {
|
|
1366
|
+
className: "piq-timeline__list",
|
|
1367
|
+
children: s.map((e, t) => {
|
|
1368
|
+
let r = Se[e.kind] ?? Se.system, a = Ce(e.time);
|
|
1369
|
+
return /* @__PURE__ */ D("li", {
|
|
1370
|
+
className: "piq-timeline__event",
|
|
1371
|
+
"data-kind": e.kind,
|
|
1372
|
+
children: [/* @__PURE__ */ E(n, {
|
|
1373
|
+
name: r.icon,
|
|
1374
|
+
className: "piq-timeline__mark"
|
|
1375
|
+
}), /* @__PURE__ */ D("div", {
|
|
1376
|
+
className: "piq-timeline__content",
|
|
1377
|
+
children: [
|
|
1378
|
+
/* @__PURE__ */ D("p", {
|
|
1379
|
+
className: "piq-timeline__line",
|
|
1380
|
+
children: [
|
|
1381
|
+
/* @__PURE__ */ E("span", {
|
|
1382
|
+
className: "piq-timeline__kind",
|
|
1383
|
+
children: i[e.kind] ?? r.label
|
|
1384
|
+
}),
|
|
1385
|
+
/* @__PURE__ */ E("span", {
|
|
1386
|
+
className: "piq-timeline__actor",
|
|
1387
|
+
children: e.actor
|
|
1388
|
+
}),
|
|
1389
|
+
/* @__PURE__ */ E("span", {
|
|
1390
|
+
className: "piq-timeline__action",
|
|
1391
|
+
children: e.action
|
|
1392
|
+
})
|
|
1393
|
+
]
|
|
1394
|
+
}),
|
|
1395
|
+
/* @__PURE__ */ E("time", {
|
|
1396
|
+
className: "piq-timeline__time",
|
|
1397
|
+
dateTime: a.toISOString(),
|
|
1398
|
+
children: c.format(a)
|
|
1399
|
+
}),
|
|
1400
|
+
e.body && /* @__PURE__ */ E("div", {
|
|
1401
|
+
className: "piq-timeline__body",
|
|
1402
|
+
children: e.body
|
|
1403
|
+
})
|
|
1404
|
+
]
|
|
1405
|
+
})]
|
|
1406
|
+
}, e.id ?? t);
|
|
1407
|
+
})
|
|
1408
|
+
})
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
function Te({ tabs: e = [], param: t = "tab", label: n, defaultValue: r, onChange: i, className: a }) {
|
|
1412
|
+
let o = () => {
|
|
1413
|
+
if (typeof window > "u") return;
|
|
1414
|
+
let n = new URLSearchParams(window.location.search).get(t);
|
|
1415
|
+
return e.some((e) => String(e.id) === n) ? e.find((e) => String(e.id) === n).id : void 0;
|
|
1416
|
+
}, [s, c] = w(() => o() ?? r ?? e[0]?.id);
|
|
1417
|
+
return y(() => {
|
|
1418
|
+
let t = () => c(o() ?? r ?? e[0]?.id);
|
|
1419
|
+
return window.addEventListener("popstate", t), () => window.removeEventListener("popstate", t);
|
|
1420
|
+
}), /* @__PURE__ */ E(m, {
|
|
1421
|
+
className: `piq-tabs-section${a ? ` ${a}` : ""}`,
|
|
1422
|
+
tabs: e,
|
|
1423
|
+
value: s,
|
|
1424
|
+
onChange: (e) => {
|
|
1425
|
+
c(e);
|
|
1426
|
+
let n = new URLSearchParams(window.location.search);
|
|
1427
|
+
n.set(t, e), window.history.replaceState(window.history.state, "", `${window.location.pathname}?${n}${window.location.hash}`), i?.(e);
|
|
1428
|
+
},
|
|
1429
|
+
label: n
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
function Ee({ title: t, statusPill: n, actions: r, secondaryActions: i, overflow: a, breadcrumbs: o, back: s, fields: c, tabs: l, tabsParam: u = "tab", tabsLabel: d, activity: f, activityLabel: p = "Activity", status: m = "ready", onRetry: h, emptyTitle: g = "Choose a record", emptyText: _ = "Select a record in the list to see it here.", notFoundTitle: v = "This record no longer exists", children: y, className: b }) {
|
|
1433
|
+
if (m !== "ready" && m !== "loading") {
|
|
1434
|
+
let e = {
|
|
1435
|
+
empty: /* @__PURE__ */ E(J, {
|
|
1436
|
+
kind: "empty",
|
|
1437
|
+
title: g,
|
|
1438
|
+
children: /* @__PURE__ */ E("p", { children: _ })
|
|
1439
|
+
}),
|
|
1440
|
+
error: /* @__PURE__ */ E(J, {
|
|
1441
|
+
kind: "error",
|
|
1442
|
+
onRetry: h
|
|
1443
|
+
}),
|
|
1444
|
+
forbidden: /* @__PURE__ */ E(J, { kind: "forbidden" }),
|
|
1445
|
+
"not-found": /* @__PURE__ */ E(J, {
|
|
1446
|
+
kind: "empty",
|
|
1447
|
+
title: v,
|
|
1448
|
+
children: /* @__PURE__ */ E("p", { children: "It may have been deleted or moved." })
|
|
1449
|
+
})
|
|
1450
|
+
}[m] ?? /* @__PURE__ */ E(J, {
|
|
1451
|
+
kind: "error",
|
|
1452
|
+
onRetry: h
|
|
1453
|
+
});
|
|
1454
|
+
return /* @__PURE__ */ D("div", {
|
|
1455
|
+
className: `piq-record${b ? ` ${b}` : ""}`,
|
|
1456
|
+
"data-status": m,
|
|
1457
|
+
children: [s, e]
|
|
1458
|
+
});
|
|
1459
|
+
}
|
|
1460
|
+
return m === "loading" ? /* @__PURE__ */ D("div", {
|
|
1461
|
+
className: `piq-record${b ? ` ${b}` : ""}`,
|
|
1462
|
+
"data-status": "loading",
|
|
1463
|
+
"aria-busy": "true",
|
|
1464
|
+
children: [
|
|
1465
|
+
s,
|
|
1466
|
+
/* @__PURE__ */ E(e, {
|
|
1467
|
+
variant: "rect",
|
|
1468
|
+
height: 40
|
|
1469
|
+
}),
|
|
1470
|
+
/* @__PURE__ */ E(e, { lines: 6 })
|
|
1471
|
+
]
|
|
1472
|
+
}) : /* @__PURE__ */ D("article", {
|
|
1473
|
+
className: `piq-record${b ? ` ${b}` : ""}`,
|
|
1474
|
+
"data-status": "ready",
|
|
1475
|
+
children: [
|
|
1476
|
+
s,
|
|
1477
|
+
/* @__PURE__ */ E(q, {
|
|
1478
|
+
title: t,
|
|
1479
|
+
breadcrumbs: o,
|
|
1480
|
+
status: n,
|
|
1481
|
+
actions: r,
|
|
1482
|
+
secondaryActions: i,
|
|
1483
|
+
overflow: a
|
|
1484
|
+
}),
|
|
1485
|
+
/* @__PURE__ */ D("div", {
|
|
1486
|
+
className: "piq-record__body",
|
|
1487
|
+
"data-activity": f ? "" : void 0,
|
|
1488
|
+
children: [/* @__PURE__ */ D("div", {
|
|
1489
|
+
className: "piq-record__main",
|
|
1490
|
+
children: [
|
|
1491
|
+
c?.length ? /* @__PURE__ */ E(xe, { items: c }) : null,
|
|
1492
|
+
l?.length ? /* @__PURE__ */ E(Te, {
|
|
1493
|
+
tabs: l,
|
|
1494
|
+
param: u,
|
|
1495
|
+
label: d ?? t
|
|
1496
|
+
}) : null,
|
|
1497
|
+
y
|
|
1498
|
+
]
|
|
1499
|
+
}), f && /* @__PURE__ */ E("aside", {
|
|
1500
|
+
className: "piq-record__aside",
|
|
1501
|
+
"aria-label": p,
|
|
1502
|
+
children: /* @__PURE__ */ E(we, {
|
|
1503
|
+
events: f,
|
|
1504
|
+
label: p
|
|
1505
|
+
})
|
|
1506
|
+
})]
|
|
1507
|
+
})
|
|
1508
|
+
]
|
|
1509
|
+
});
|
|
1510
|
+
}
|
|
1511
|
+
function De({ items: e = [], selected: t, onSelect: r, renderItem: i = (e) => e.label ?? e.id, listLabel: a = "Records", detail: s, backLabel: c = "Back", ratio: l = "1:2", className: u }) {
|
|
1512
|
+
let d = C(null), f = C(null), p = C(null), m = W(d), h = G(m, "expanded"), [g, _] = w(t == null ? "list" : "detail"), [x, S] = w(t ?? e[0]?.id), T = b(), O = e.findIndex((e) => e.id === x), k = v((e) => {
|
|
1513
|
+
[...f.current?.querySelectorAll("[role=\"option\"]") ?? []].find((t) => t.dataset.id === String(e))?.focus();
|
|
1514
|
+
}, []), A = (e) => {
|
|
1515
|
+
r?.(e), S(e), h || (_("detail"), requestAnimationFrame(() => p.current?.focus()));
|
|
1516
|
+
};
|
|
1517
|
+
function j(t) {
|
|
1518
|
+
let n = null;
|
|
1519
|
+
if (t.key === "ArrowDown") n = Math.min(O + 1, e.length - 1);
|
|
1520
|
+
else if (t.key === "ArrowUp") n = Math.max(O - 1, 0);
|
|
1521
|
+
else if (t.key === "Home") n = 0;
|
|
1522
|
+
else if (t.key === "End") n = e.length - 1;
|
|
1523
|
+
else if ((t.key === "Enter" || t.key === " ") && x != null) {
|
|
1524
|
+
t.preventDefault(), A(x);
|
|
1525
|
+
return;
|
|
1526
|
+
}
|
|
1527
|
+
if (n === null || n < 0) return;
|
|
1528
|
+
t.preventDefault();
|
|
1529
|
+
let i = e[n].id;
|
|
1530
|
+
S(i), k(i), h && r?.(i);
|
|
1531
|
+
}
|
|
1532
|
+
let M = () => {
|
|
1533
|
+
_("list"), requestAnimationFrame(() => k(t ?? x));
|
|
1534
|
+
}, N = (e) => () => {
|
|
1535
|
+
h && _(e);
|
|
1536
|
+
};
|
|
1537
|
+
return y(() => {
|
|
1538
|
+
t != null && S(t);
|
|
1539
|
+
}, [t]), /* @__PURE__ */ E("div", {
|
|
1540
|
+
ref: d,
|
|
1541
|
+
className: `piq-list-detail${u ? ` ${u}` : ""}`,
|
|
1542
|
+
"data-size": m,
|
|
1543
|
+
children: /* @__PURE__ */ E(I, {
|
|
1544
|
+
show: g === "detail" ? "secondary" : "primary",
|
|
1545
|
+
ratio: l,
|
|
1546
|
+
primary: /* @__PURE__ */ E("div", {
|
|
1547
|
+
onFocus: N("list"),
|
|
1548
|
+
children: /* @__PURE__ */ E("ul", {
|
|
1549
|
+
ref: f,
|
|
1550
|
+
role: "listbox",
|
|
1551
|
+
"aria-label": a,
|
|
1552
|
+
className: "piq-list-detail__list",
|
|
1553
|
+
onKeyDown: j,
|
|
1554
|
+
children: e.map((n) => /* @__PURE__ */ E("li", {
|
|
1555
|
+
id: `${T}-${n.id}`,
|
|
1556
|
+
role: "option",
|
|
1557
|
+
"data-id": n.id,
|
|
1558
|
+
"aria-selected": n.id === t,
|
|
1559
|
+
tabIndex: n.id === (x ?? e[0]?.id) ? 0 : -1,
|
|
1560
|
+
className: "piq-list-detail__option",
|
|
1561
|
+
onClick: () => A(n.id),
|
|
1562
|
+
onFocus: () => S(n.id),
|
|
1563
|
+
children: i(n)
|
|
1564
|
+
}, n.id))
|
|
1565
|
+
})
|
|
1566
|
+
}),
|
|
1567
|
+
secondary: /* @__PURE__ */ D("div", {
|
|
1568
|
+
ref: p,
|
|
1569
|
+
tabIndex: -1,
|
|
1570
|
+
className: "piq-list-detail__detail",
|
|
1571
|
+
onFocus: N("detail"),
|
|
1572
|
+
children: [/* @__PURE__ */ D(o, {
|
|
1573
|
+
variant: "text",
|
|
1574
|
+
className: "piq-list-detail__back",
|
|
1575
|
+
onClick: M,
|
|
1576
|
+
children: [/* @__PURE__ */ E(n, { name: "arrow-left" }), c]
|
|
1577
|
+
}), s]
|
|
1578
|
+
})
|
|
1579
|
+
})
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
//#endregion
|
|
1583
|
+
//#region src/patterns/Reporting.jsx
|
|
1584
|
+
var Oe = {
|
|
1585
|
+
up: {
|
|
1586
|
+
icon: "arrow-right",
|
|
1587
|
+
word: "up"
|
|
1588
|
+
},
|
|
1589
|
+
down: {
|
|
1590
|
+
icon: "arrow-right",
|
|
1591
|
+
word: "down"
|
|
1592
|
+
},
|
|
1593
|
+
flat: {
|
|
1594
|
+
icon: "arrow-right",
|
|
1595
|
+
word: "no change"
|
|
1596
|
+
}
|
|
1597
|
+
};
|
|
1598
|
+
function ke({ label: e, value: t, change: r, words: i = Oe, className: a }) {
|
|
1599
|
+
let o = r ? i[r.direction] ?? i.flat : null;
|
|
1600
|
+
return /* @__PURE__ */ D("section", {
|
|
1601
|
+
className: `piq-stat-tile${a ? ` ${a}` : ""}`,
|
|
1602
|
+
"aria-label": e,
|
|
1603
|
+
children: [
|
|
1604
|
+
/* @__PURE__ */ E("p", {
|
|
1605
|
+
className: "piq-stat-tile__label",
|
|
1606
|
+
children: e
|
|
1607
|
+
}),
|
|
1608
|
+
/* @__PURE__ */ E("p", {
|
|
1609
|
+
className: "piq-stat-tile__value",
|
|
1610
|
+
children: t
|
|
1611
|
+
}),
|
|
1612
|
+
r && /* @__PURE__ */ D("p", {
|
|
1613
|
+
className: "piq-stat-tile__change",
|
|
1614
|
+
"data-direction": r.direction,
|
|
1615
|
+
children: [/* @__PURE__ */ E(n, {
|
|
1616
|
+
name: o.icon,
|
|
1617
|
+
className: "piq-stat-tile__arrow"
|
|
1618
|
+
}), /* @__PURE__ */ E("span", { children: [
|
|
1619
|
+
o.word,
|
|
1620
|
+
r.direction === "flat" ? null : r.amount,
|
|
1621
|
+
r.comparison
|
|
1622
|
+
].filter(Boolean).join(" ") })]
|
|
1623
|
+
})
|
|
1624
|
+
]
|
|
1625
|
+
});
|
|
1626
|
+
}
|
|
1627
|
+
function Ae({ title: t, description: n, legend: r = [], table: i, status: a = "ready", onRetry: s, showTableLabel: c = "Show data table", hideTableLabel: l = "Hide data table", emptyTitle: u = "No data for this period", actions: d, children: f, className: p }) {
|
|
1628
|
+
let [m, h] = w(!1), g = b(), _ = f;
|
|
1629
|
+
return a === "loading" ? _ = /* @__PURE__ */ E("div", {
|
|
1630
|
+
className: "piq-chart-frame__state",
|
|
1631
|
+
"aria-busy": "true",
|
|
1632
|
+
children: /* @__PURE__ */ E(e, {
|
|
1633
|
+
variant: "rect",
|
|
1634
|
+
height: "100%"
|
|
1635
|
+
})
|
|
1636
|
+
}) : a === "empty" ? _ = /* @__PURE__ */ E("div", {
|
|
1637
|
+
className: "piq-chart-frame__state",
|
|
1638
|
+
children: /* @__PURE__ */ E(J, {
|
|
1639
|
+
kind: "empty",
|
|
1640
|
+
title: u,
|
|
1641
|
+
children: /* @__PURE__ */ E("p", { children: "Try a different date range or filters." })
|
|
1642
|
+
})
|
|
1643
|
+
}) : a === "error" && (_ = /* @__PURE__ */ E("div", {
|
|
1644
|
+
className: "piq-chart-frame__state",
|
|
1645
|
+
children: /* @__PURE__ */ E(J, {
|
|
1646
|
+
kind: "error",
|
|
1647
|
+
onRetry: s
|
|
1648
|
+
})
|
|
1649
|
+
})), /* @__PURE__ */ D("figure", {
|
|
1650
|
+
className: `piq-chart-frame${p ? ` ${p}` : ""}`,
|
|
1651
|
+
"aria-labelledby": `${g}-title`,
|
|
1652
|
+
"data-status": a,
|
|
1653
|
+
children: [
|
|
1654
|
+
/* @__PURE__ */ D("div", {
|
|
1655
|
+
className: "piq-chart-frame__head",
|
|
1656
|
+
children: [/* @__PURE__ */ E("figcaption", {
|
|
1657
|
+
id: `${g}-title`,
|
|
1658
|
+
className: "piq-chart-frame__title",
|
|
1659
|
+
children: t
|
|
1660
|
+
}), d && /* @__PURE__ */ E("div", {
|
|
1661
|
+
className: "piq-chart-frame__actions",
|
|
1662
|
+
children: d
|
|
1663
|
+
})]
|
|
1664
|
+
}),
|
|
1665
|
+
n && /* @__PURE__ */ E("p", {
|
|
1666
|
+
className: "piq-chart-frame__description",
|
|
1667
|
+
children: n
|
|
1668
|
+
}),
|
|
1669
|
+
/* @__PURE__ */ E("div", {
|
|
1670
|
+
className: "piq-chart-frame__chart",
|
|
1671
|
+
children: _
|
|
1672
|
+
}),
|
|
1673
|
+
a === "ready" && r.length > 0 && /* @__PURE__ */ E("ul", {
|
|
1674
|
+
className: "piq-chart-frame__legend",
|
|
1675
|
+
"aria-label": "Legend",
|
|
1676
|
+
children: r.map((e, t) => /* @__PURE__ */ D("li", {
|
|
1677
|
+
className: "piq-chart-frame__legend-item",
|
|
1678
|
+
children: [e.marker, /* @__PURE__ */ E("span", { children: e.label })]
|
|
1679
|
+
}, t))
|
|
1680
|
+
}),
|
|
1681
|
+
a === "ready" && i && /* @__PURE__ */ D("div", {
|
|
1682
|
+
className: "piq-chart-frame__data",
|
|
1683
|
+
children: [/* @__PURE__ */ E(o, {
|
|
1684
|
+
variant: "text",
|
|
1685
|
+
size: "sm",
|
|
1686
|
+
"aria-expanded": m,
|
|
1687
|
+
"aria-controls": `${g}-table`,
|
|
1688
|
+
onClick: () => h((e) => !e),
|
|
1689
|
+
children: m ? l : c
|
|
1690
|
+
}), /* @__PURE__ */ E("div", {
|
|
1691
|
+
id: `${g}-table`,
|
|
1692
|
+
hidden: !m,
|
|
1693
|
+
className: "piq-table-wrap",
|
|
1694
|
+
children: /* @__PURE__ */ D("table", {
|
|
1695
|
+
className: "piq-table",
|
|
1696
|
+
children: [
|
|
1697
|
+
/* @__PURE__ */ E("caption", {
|
|
1698
|
+
className: "piq-visually-hidden",
|
|
1699
|
+
children: t
|
|
1700
|
+
}),
|
|
1701
|
+
/* @__PURE__ */ E("thead", { children: /* @__PURE__ */ E("tr", { children: i.columns.map((e) => /* @__PURE__ */ E("th", {
|
|
1702
|
+
scope: "col",
|
|
1703
|
+
className: e.numeric ? "piq-num" : void 0,
|
|
1704
|
+
children: e.label
|
|
1705
|
+
}, e.key)) }) }),
|
|
1706
|
+
/* @__PURE__ */ E("tbody", { children: i.rows.map((e, t) => /* @__PURE__ */ E("tr", { children: i.columns.map((t) => /* @__PURE__ */ E("td", {
|
|
1707
|
+
className: t.numeric ? "piq-num" : void 0,
|
|
1708
|
+
children: e[t.key]
|
|
1709
|
+
}, t.key)) }, t)) })
|
|
1710
|
+
]
|
|
1711
|
+
})
|
|
1712
|
+
})]
|
|
1713
|
+
})
|
|
1714
|
+
]
|
|
1715
|
+
});
|
|
1716
|
+
}
|
|
1717
|
+
var je = (e, t) => e ? new Intl.DateTimeFormat(t, { timeStyle: "short" }).format(e instanceof Date ? e : new Date(e)) : null;
|
|
1718
|
+
function Me({ title: e, breadcrumbs: t, actions: n, filters: r, dateRange: i, refreshedAt: a, refreshedLabel: o = "Last refreshed", locale: s, tiles: c = [], charts: l = [], children: u, className: d }) {
|
|
1719
|
+
let f = je(a, s);
|
|
1720
|
+
return /* @__PURE__ */ D("div", {
|
|
1721
|
+
className: `piq-dashboard${d ? ` ${d}` : ""}`,
|
|
1722
|
+
children: [
|
|
1723
|
+
/* @__PURE__ */ E(q, {
|
|
1724
|
+
title: e,
|
|
1725
|
+
breadcrumbs: t,
|
|
1726
|
+
actions: n
|
|
1727
|
+
}),
|
|
1728
|
+
(r || i || f) && /* @__PURE__ */ D("div", {
|
|
1729
|
+
className: "piq-dashboard__toolbar",
|
|
1730
|
+
children: [
|
|
1731
|
+
r,
|
|
1732
|
+
i,
|
|
1733
|
+
f && /* @__PURE__ */ D("p", {
|
|
1734
|
+
className: "piq-dashboard__refreshed",
|
|
1735
|
+
children: [
|
|
1736
|
+
o,
|
|
1737
|
+
" ",
|
|
1738
|
+
/* @__PURE__ */ E("time", {
|
|
1739
|
+
dateTime: new Date(a).toISOString(),
|
|
1740
|
+
children: f
|
|
1741
|
+
})
|
|
1742
|
+
]
|
|
1743
|
+
})
|
|
1744
|
+
]
|
|
1745
|
+
}),
|
|
1746
|
+
c.length > 0 && /* @__PURE__ */ E("div", {
|
|
1747
|
+
className: "piq-dashboard__tiles",
|
|
1748
|
+
children: c
|
|
1749
|
+
}),
|
|
1750
|
+
l.length > 0 && /* @__PURE__ */ E("div", {
|
|
1751
|
+
className: "piq-dashboard__charts",
|
|
1752
|
+
children: l
|
|
1753
|
+
}),
|
|
1754
|
+
u
|
|
1755
|
+
]
|
|
1756
|
+
});
|
|
1757
|
+
}
|
|
1758
|
+
function Ne({ title: t, breadcrumbs: r, parameters: i, onRun: a, runLabel: s = "Run report", parametersLabel: c = "Parameters", applied: l = [], appliedLabel: d = "Run with", results: f, status: p = "ready", onRetry: m, onExport: h, exportLabel: g = "Export", onPrint: _, printLabel: v = "Print", className: y }) {
|
|
1759
|
+
let x = C(null), S = W(x), [T, O] = w(!1), k = b(), A = G(S, "expanded") ? "side" : G(S, "medium") ? "collapsible" : "sheet", j = /* @__PURE__ */ D("form", {
|
|
1760
|
+
className: "piq-report__form",
|
|
1761
|
+
onSubmit: (e) => {
|
|
1762
|
+
e.preventDefault(), O(!1), a?.();
|
|
1763
|
+
},
|
|
1764
|
+
children: [i, /* @__PURE__ */ E(o, {
|
|
1765
|
+
type: "submit",
|
|
1766
|
+
children: s
|
|
1767
|
+
})]
|
|
1768
|
+
});
|
|
1769
|
+
return /* @__PURE__ */ D("div", {
|
|
1770
|
+
ref: x,
|
|
1771
|
+
className: `piq-report${y ? ` ${y}` : ""}`,
|
|
1772
|
+
"data-mode": A,
|
|
1773
|
+
children: [/* @__PURE__ */ E(q, {
|
|
1774
|
+
title: t,
|
|
1775
|
+
breadcrumbs: r,
|
|
1776
|
+
actions: /* @__PURE__ */ D("div", {
|
|
1777
|
+
className: "piq-report__actions",
|
|
1778
|
+
children: [
|
|
1779
|
+
A !== "side" && /* @__PURE__ */ D(o, {
|
|
1780
|
+
variant: "secondary",
|
|
1781
|
+
"aria-expanded": T,
|
|
1782
|
+
"aria-controls": A === "collapsible" ? `${k}-params` : void 0,
|
|
1783
|
+
onClick: () => O((e) => !e),
|
|
1784
|
+
children: [/* @__PURE__ */ E(n, { name: "filter" }), c]
|
|
1785
|
+
}),
|
|
1786
|
+
h && /* @__PURE__ */ D(o, {
|
|
1787
|
+
variant: "secondary",
|
|
1788
|
+
onClick: h,
|
|
1789
|
+
children: [/* @__PURE__ */ E(n, { name: "download" }), g]
|
|
1790
|
+
}),
|
|
1791
|
+
/* @__PURE__ */ E(o, {
|
|
1792
|
+
variant: "secondary",
|
|
1793
|
+
onClick: () => _ ? _() : window.print(),
|
|
1794
|
+
children: v
|
|
1795
|
+
})
|
|
1796
|
+
]
|
|
1797
|
+
})
|
|
1798
|
+
}), /* @__PURE__ */ D("div", {
|
|
1799
|
+
className: "piq-report__body",
|
|
1800
|
+
children: [
|
|
1801
|
+
A === "side" && /* @__PURE__ */ E("aside", {
|
|
1802
|
+
className: "piq-report__params",
|
|
1803
|
+
"aria-label": c,
|
|
1804
|
+
children: j
|
|
1805
|
+
}),
|
|
1806
|
+
A === "collapsible" && /* @__PURE__ */ E("section", {
|
|
1807
|
+
id: `${k}-params`,
|
|
1808
|
+
className: "piq-report__params",
|
|
1809
|
+
"aria-label": c,
|
|
1810
|
+
hidden: !T,
|
|
1811
|
+
children: j
|
|
1812
|
+
}),
|
|
1813
|
+
A === "sheet" && /* @__PURE__ */ E(u, {
|
|
1814
|
+
open: T,
|
|
1815
|
+
onClose: () => O(!1),
|
|
1816
|
+
title: c,
|
|
1817
|
+
side: "full",
|
|
1818
|
+
children: j
|
|
1819
|
+
}),
|
|
1820
|
+
/* @__PURE__ */ D("div", {
|
|
1821
|
+
className: "piq-report__results",
|
|
1822
|
+
children: [l.length > 0 && /* @__PURE__ */ E("dl", {
|
|
1823
|
+
className: "piq-report__applied",
|
|
1824
|
+
"aria-label": d,
|
|
1825
|
+
children: l.map((e, t) => /* @__PURE__ */ D("div", {
|
|
1826
|
+
className: "piq-chip",
|
|
1827
|
+
children: [/* @__PURE__ */ D("dt", { children: [e.label, ":"] }), /* @__PURE__ */ E("dd", { children: e.value })]
|
|
1828
|
+
}, t))
|
|
1829
|
+
}), p === "ready" ? f : p === "loading" ? /* @__PURE__ */ E("div", {
|
|
1830
|
+
"aria-busy": "true",
|
|
1831
|
+
children: /* @__PURE__ */ E(e, { lines: 8 })
|
|
1832
|
+
}) : /* @__PURE__ */ E(J, {
|
|
1833
|
+
kind: p,
|
|
1834
|
+
onRetry: m
|
|
1835
|
+
})]
|
|
1836
|
+
})
|
|
1837
|
+
]
|
|
1838
|
+
})]
|
|
1839
|
+
});
|
|
1840
|
+
}
|
|
1841
|
+
//#endregion
|
|
1842
|
+
//#region src/patterns/Settings.jsx
|
|
1843
|
+
function Pe({ title: e = "Settings", breadcrumbs: t, sections: r = [], current: i, onChange: a, navLabel: s = "Settings sections", backLabel: c = "All settings", className: l }) {
|
|
1844
|
+
let u = C(null), d = W(u), f = G(d, "expanded"), p = r.filter((e) => !e.hidden), m = p.filter((e) => !e.disabled), [h, g] = w(i ?? m[0]?.id), _ = i ?? h, [v, x] = w("list"), S = b(), T = C({});
|
|
1845
|
+
y(() => {
|
|
1846
|
+
f && _ != null && x("section");
|
|
1847
|
+
}, [f, _]);
|
|
1848
|
+
let O = (e) => {
|
|
1849
|
+
i === void 0 && g(e), a?.(e), x("section"), requestAnimationFrame(() => T.current[e]?.focus());
|
|
1850
|
+
};
|
|
1851
|
+
return m.length ? /* @__PURE__ */ D("div", {
|
|
1852
|
+
ref: u,
|
|
1853
|
+
className: `piq-settings${l ? ` ${l}` : ""}`,
|
|
1854
|
+
"data-size": d,
|
|
1855
|
+
children: [/* @__PURE__ */ E(q, {
|
|
1856
|
+
title: e,
|
|
1857
|
+
breadcrumbs: t
|
|
1858
|
+
}), /* @__PURE__ */ E(I, {
|
|
1859
|
+
show: v === "section" ? "secondary" : "primary",
|
|
1860
|
+
primary: /* @__PURE__ */ E("nav", {
|
|
1861
|
+
"aria-label": s,
|
|
1862
|
+
className: "piq-settings__nav",
|
|
1863
|
+
children: /* @__PURE__ */ E("ul", {
|
|
1864
|
+
className: "piq-primary-nav__list",
|
|
1865
|
+
children: p.map((e) => /* @__PURE__ */ D("li", {
|
|
1866
|
+
className: "piq-primary-nav__item",
|
|
1867
|
+
children: [/* @__PURE__ */ D("button", {
|
|
1868
|
+
type: "button",
|
|
1869
|
+
"data-section": e.id,
|
|
1870
|
+
className: "piq-primary-nav__link",
|
|
1871
|
+
"aria-current": e.id === _ ? "true" : void 0,
|
|
1872
|
+
"aria-disabled": e.disabled ? "true" : void 0,
|
|
1873
|
+
"aria-describedby": e.disabled ? `${S}-${e.id}-why` : void 0,
|
|
1874
|
+
onClick: () => !e.disabled && O(e.id),
|
|
1875
|
+
children: [/* @__PURE__ */ E("span", {
|
|
1876
|
+
className: "piq-primary-nav__label",
|
|
1877
|
+
children: e.label
|
|
1878
|
+
}), !e.disabled && /* @__PURE__ */ E(n, {
|
|
1879
|
+
name: "chevron-right",
|
|
1880
|
+
className: "piq-settings__chevron"
|
|
1881
|
+
})]
|
|
1882
|
+
}), e.disabled && /* @__PURE__ */ E("p", {
|
|
1883
|
+
id: `${S}-${e.id}-why`,
|
|
1884
|
+
className: "piq-settings__why",
|
|
1885
|
+
children: typeof e.disabled == "string" ? e.disabled : "Not available to you"
|
|
1886
|
+
})]
|
|
1887
|
+
}, e.id))
|
|
1888
|
+
})
|
|
1889
|
+
}),
|
|
1890
|
+
secondary: /* @__PURE__ */ D("div", {
|
|
1891
|
+
className: "piq-settings__sections",
|
|
1892
|
+
children: [/* @__PURE__ */ D(o, {
|
|
1893
|
+
variant: "text",
|
|
1894
|
+
className: "piq-settings__back",
|
|
1895
|
+
onClick: () => {
|
|
1896
|
+
x("list"), requestAnimationFrame(() => u.current?.querySelector(`[data-section="${_}"]`)?.focus());
|
|
1897
|
+
},
|
|
1898
|
+
children: [/* @__PURE__ */ E(n, { name: "arrow-left" }), c]
|
|
1899
|
+
}), m.map((e) => /* @__PURE__ */ D("section", {
|
|
1900
|
+
className: "piq-settings__section",
|
|
1901
|
+
"aria-labelledby": `${S}-${e.id}-h`,
|
|
1902
|
+
hidden: e.id !== _,
|
|
1903
|
+
children: [/* @__PURE__ */ E("h2", {
|
|
1904
|
+
id: `${S}-${e.id}-h`,
|
|
1905
|
+
tabIndex: -1,
|
|
1906
|
+
ref: (t) => {
|
|
1907
|
+
T.current[e.id] = t;
|
|
1908
|
+
},
|
|
1909
|
+
className: "piq-settings__heading",
|
|
1910
|
+
children: e.label
|
|
1911
|
+
}), e.content]
|
|
1912
|
+
}, e.id))]
|
|
1913
|
+
})
|
|
1914
|
+
})]
|
|
1915
|
+
}) : /* @__PURE__ */ D("div", {
|
|
1916
|
+
ref: u,
|
|
1917
|
+
className: `piq-settings${l ? ` ${l}` : ""}`,
|
|
1918
|
+
children: [/* @__PURE__ */ E(q, {
|
|
1919
|
+
title: e,
|
|
1920
|
+
breadcrumbs: t
|
|
1921
|
+
}), /* @__PURE__ */ E(J, { kind: "forbidden" })]
|
|
1922
|
+
});
|
|
1923
|
+
}
|
|
1924
|
+
//#endregion
|
|
1925
|
+
//#region src/patterns/Workflow.jsx
|
|
1926
|
+
var Fe = (e) => {
|
|
1927
|
+
if (!e) return {};
|
|
1928
|
+
let t = {}, n = e.ownerDocument?.defaultView?.FormData ?? FormData;
|
|
1929
|
+
for (let [r, i] of new n(e)) t[r] = r in t ? [].concat(t[r], i) : i;
|
|
1930
|
+
return t;
|
|
1931
|
+
};
|
|
1932
|
+
function Ie({ title: e, steps: t = [], review: n, onSaveDraft: r, onFinish: i, saveDraftLabel: s = "Save draft", backLabel: c = "Back", nextLabel: l = "Continue", finishLabel: u = "Submit", reviewTitle: d = "Check your answers", className: f }) {
|
|
1933
|
+
let p = n ? [...t, {
|
|
1934
|
+
id: "review",
|
|
1935
|
+
title: d,
|
|
1936
|
+
content: ({ data: e }) => n(e)
|
|
1937
|
+
}] : t, [m, h] = w(0), [g, _] = w({}), [v, y] = w(0), [x, S] = w({}), T = C(null), O = C(null), k = b(), A = p[m], j = m === p.length - 1, M = () => Fe(T.current), N = (e) => {
|
|
1938
|
+
S(M()), _({}), h(e), requestAnimationFrame(() => O.current?.focus());
|
|
1939
|
+
};
|
|
1940
|
+
function P(e) {
|
|
1941
|
+
e.preventDefault();
|
|
1942
|
+
let t = M(), n = Object.fromEntries(Object.entries(A.validate?.(t) ?? {}).filter(([, e]) => e));
|
|
1943
|
+
if (Object.keys(n).length) {
|
|
1944
|
+
S(t), _(n), y((e) => e + 1);
|
|
1945
|
+
return;
|
|
1946
|
+
}
|
|
1947
|
+
if (j) {
|
|
1948
|
+
i?.(t);
|
|
1949
|
+
return;
|
|
1950
|
+
}
|
|
1951
|
+
N(m + 1);
|
|
1952
|
+
}
|
|
1953
|
+
return /* @__PURE__ */ D("form", {
|
|
1954
|
+
ref: T,
|
|
1955
|
+
className: `piq-wizard${f ? ` ${f}` : ""}`,
|
|
1956
|
+
noValidate: !0,
|
|
1957
|
+
onSubmit: P,
|
|
1958
|
+
children: [
|
|
1959
|
+
e && /* @__PURE__ */ E("p", {
|
|
1960
|
+
className: "piq-wizard__task",
|
|
1961
|
+
children: e
|
|
1962
|
+
}),
|
|
1963
|
+
/* @__PURE__ */ E("ol", {
|
|
1964
|
+
className: "piq-wizard__steps",
|
|
1965
|
+
"aria-label": "Steps",
|
|
1966
|
+
children: p.map((e, t) => /* @__PURE__ */ E("li", {
|
|
1967
|
+
className: "piq-wizard__step",
|
|
1968
|
+
"aria-current": t === m ? "step" : void 0,
|
|
1969
|
+
"data-done": t < m || void 0,
|
|
1970
|
+
children: e.title
|
|
1971
|
+
}, e.id))
|
|
1972
|
+
}),
|
|
1973
|
+
/* @__PURE__ */ E("div", {
|
|
1974
|
+
className: "piq-wizard__progress",
|
|
1975
|
+
children: /* @__PURE__ */ E(a, {
|
|
1976
|
+
label: `Step ${m + 1} of ${p.length}`,
|
|
1977
|
+
value: m + 1,
|
|
1978
|
+
max: p.length,
|
|
1979
|
+
valueText: `Step ${m + 1} of ${p.length}`
|
|
1980
|
+
})
|
|
1981
|
+
}),
|
|
1982
|
+
/* @__PURE__ */ E("h2", {
|
|
1983
|
+
ref: O,
|
|
1984
|
+
tabIndex: -1,
|
|
1985
|
+
className: "piq-wizard__heading",
|
|
1986
|
+
id: `${k}-h`,
|
|
1987
|
+
children: `Step ${m + 1} of ${p.length}: ${A?.title ?? ""}`
|
|
1988
|
+
}),
|
|
1989
|
+
/* @__PURE__ */ E(fe, {
|
|
1990
|
+
errors: g,
|
|
1991
|
+
idOf: (e) => T.current?.elements.namedItem(e)?.id ?? e,
|
|
1992
|
+
attempt: v
|
|
1993
|
+
}),
|
|
1994
|
+
p.map((e, t) => /* @__PURE__ */ E("section", {
|
|
1995
|
+
className: "piq-wizard__panel",
|
|
1996
|
+
hidden: t !== m,
|
|
1997
|
+
"aria-labelledby": t === m ? `${k}-h` : void 0,
|
|
1998
|
+
children: typeof e.content == "function" ? e.content({
|
|
1999
|
+
data: x,
|
|
2000
|
+
errors: t === m ? g : {}
|
|
2001
|
+
}) : e.content
|
|
2002
|
+
}, e.id)),
|
|
2003
|
+
/* @__PURE__ */ D("div", {
|
|
2004
|
+
className: "piq-wizard__actions",
|
|
2005
|
+
children: [
|
|
2006
|
+
/* @__PURE__ */ E(o, {
|
|
2007
|
+
type: "submit",
|
|
2008
|
+
onClick: (e) => {
|
|
2009
|
+
e.preventDefault(), P(e);
|
|
2010
|
+
},
|
|
2011
|
+
children: j ? u : l
|
|
2012
|
+
}),
|
|
2013
|
+
m > 0 && /* @__PURE__ */ E(o, {
|
|
2014
|
+
variant: "secondary",
|
|
2015
|
+
onClick: () => N(m - 1),
|
|
2016
|
+
children: c
|
|
2017
|
+
}),
|
|
2018
|
+
r && /* @__PURE__ */ E(o, {
|
|
2019
|
+
variant: "text",
|
|
2020
|
+
onClick: () => r(M()),
|
|
2021
|
+
children: s
|
|
2022
|
+
})
|
|
2023
|
+
]
|
|
2024
|
+
})
|
|
2025
|
+
]
|
|
2026
|
+
});
|
|
2027
|
+
}
|
|
2028
|
+
var Le = {
|
|
2029
|
+
"not-started": "Not started",
|
|
2030
|
+
"in-progress": "In progress",
|
|
2031
|
+
completed: "Completed"
|
|
2032
|
+
};
|
|
2033
|
+
function Re({ title: e, sections: t = [], statusLabels: n = Le, completedText: r = (e, t) => `${e} of ${t} sections completed`, onSelect: i, className: a }) {
|
|
2034
|
+
let o = t.filter((e) => e.status === "completed").length;
|
|
2035
|
+
return /* @__PURE__ */ D("section", {
|
|
2036
|
+
className: `piq-task-list${a ? ` ${a}` : ""}`,
|
|
2037
|
+
"aria-label": e,
|
|
2038
|
+
children: [
|
|
2039
|
+
e && /* @__PURE__ */ E("h2", {
|
|
2040
|
+
className: "piq-task-list__title",
|
|
2041
|
+
children: e
|
|
2042
|
+
}),
|
|
2043
|
+
/* @__PURE__ */ E("p", {
|
|
2044
|
+
className: "piq-task-list__count",
|
|
2045
|
+
children: r(o, t.length)
|
|
2046
|
+
}),
|
|
2047
|
+
/* @__PURE__ */ E("ol", {
|
|
2048
|
+
className: "piq-task-list__items",
|
|
2049
|
+
children: t.map((e) => /* @__PURE__ */ D("li", {
|
|
2050
|
+
className: "piq-task-list__item",
|
|
2051
|
+
children: [/* @__PURE__ */ E("a", {
|
|
2052
|
+
href: e.href,
|
|
2053
|
+
onClick: (t) => {
|
|
2054
|
+
i && (t.preventDefault(), i(e.id, t));
|
|
2055
|
+
},
|
|
2056
|
+
"aria-describedby": `${e.id}-status`,
|
|
2057
|
+
children: e.label
|
|
2058
|
+
}), /* @__PURE__ */ E("strong", {
|
|
2059
|
+
id: `${e.id}-status`,
|
|
2060
|
+
className: "piq-task-list__status",
|
|
2061
|
+
"data-status": e.status,
|
|
2062
|
+
children: n[e.status] ?? e.status
|
|
2063
|
+
})]
|
|
2064
|
+
}, e.id))
|
|
2065
|
+
})
|
|
2066
|
+
]
|
|
2067
|
+
});
|
|
2068
|
+
}
|
|
2069
|
+
function ze({ title: e = "Check your answers", sections: t = [], consequence: n, submitLabel: r = "Submit", onSubmit: i, changeLabel: a = "Change", result: s, className: c }) {
|
|
2070
|
+
let l = C(null);
|
|
2071
|
+
return y(() => {
|
|
2072
|
+
s && l.current?.focus();
|
|
2073
|
+
}, [s]), s ? /* @__PURE__ */ D("div", {
|
|
2074
|
+
ref: l,
|
|
2075
|
+
tabIndex: -1,
|
|
2076
|
+
className: `piq-confirmation${c ? ` ${c}` : ""}`,
|
|
2077
|
+
role: "status",
|
|
2078
|
+
children: [
|
|
2079
|
+
/* @__PURE__ */ E("h2", {
|
|
2080
|
+
className: "piq-confirmation__title",
|
|
2081
|
+
children: s.title
|
|
2082
|
+
}),
|
|
2083
|
+
s.reference && /* @__PURE__ */ D("p", {
|
|
2084
|
+
className: "piq-confirmation__reference",
|
|
2085
|
+
children: ["Reference ", /* @__PURE__ */ E("strong", { children: s.reference })]
|
|
2086
|
+
}),
|
|
2087
|
+
s.text && /* @__PURE__ */ E("p", {
|
|
2088
|
+
className: "piq-confirmation__text",
|
|
2089
|
+
children: s.text
|
|
2090
|
+
})
|
|
2091
|
+
]
|
|
2092
|
+
}) : /* @__PURE__ */ D("div", {
|
|
2093
|
+
className: `piq-review${c ? ` ${c}` : ""}`,
|
|
2094
|
+
children: [
|
|
2095
|
+
/* @__PURE__ */ E("h2", {
|
|
2096
|
+
className: "piq-review__title",
|
|
2097
|
+
children: e
|
|
2098
|
+
}),
|
|
2099
|
+
t.map((e) => /* @__PURE__ */ D("section", {
|
|
2100
|
+
className: "piq-review__section",
|
|
2101
|
+
"aria-labelledby": `${e.id}-review`,
|
|
2102
|
+
children: [/* @__PURE__ */ D("div", {
|
|
2103
|
+
className: "piq-review__head",
|
|
2104
|
+
children: [/* @__PURE__ */ E("h3", {
|
|
2105
|
+
id: `${e.id}-review`,
|
|
2106
|
+
className: "piq-review__section-title",
|
|
2107
|
+
children: e.title
|
|
2108
|
+
}), /* @__PURE__ */ D("a", {
|
|
2109
|
+
href: e.href,
|
|
2110
|
+
className: "piq-review__change",
|
|
2111
|
+
children: [a, /* @__PURE__ */ D("span", {
|
|
2112
|
+
className: "piq-visually-hidden",
|
|
2113
|
+
children: [" ", e.title]
|
|
2114
|
+
})]
|
|
2115
|
+
})]
|
|
2116
|
+
}), /* @__PURE__ */ E(xe, { items: e.answers })]
|
|
2117
|
+
}, e.id)),
|
|
2118
|
+
n && /* @__PURE__ */ E("p", {
|
|
2119
|
+
className: "piq-review__consequence",
|
|
2120
|
+
children: n
|
|
2121
|
+
}),
|
|
2122
|
+
/* @__PURE__ */ E(o, {
|
|
2123
|
+
onClick: () => i?.(),
|
|
2124
|
+
children: r
|
|
2125
|
+
})
|
|
2126
|
+
]
|
|
2127
|
+
});
|
|
2128
|
+
}
|
|
2129
|
+
//#endregion
|
|
2130
|
+
//#region src/patterns/EditableGrid.jsx
|
|
2131
|
+
function Be({ label: e, columns: t = [], rows: i = [], rowKey: a = "id", onChange: s, errors: c = {}, newRow: l = () => ({}), addLabel: d = "Add row", removeLabel: f = (e) => `Remove row ${e}`, editLabel: p = (e) => `Edit row ${e}`, totalLabel: m = "Total", saveLabel: h = "Save", className: g }) {
|
|
2132
|
+
let _ = C(null), v = C(null), x = W(_), S = !G(x, "medium"), [T, O] = w({
|
|
2133
|
+
r: 0,
|
|
2134
|
+
c: 0
|
|
2135
|
+
}), [k, A] = w(null), [j, M] = w(null), N = b(), P = (e, t) => e[a] ?? t, F = t.length + 1, I = t.filter((e) => e.numeric), L = (e) => i.reduce((t, n) => t + (Number(n[e]) || 0), 0), R = (e, t) => {
|
|
2136
|
+
let n = v.current?.querySelector(`[data-r="${e}"][data-c="${t}"]`);
|
|
2137
|
+
return n?.querySelector("button") ?? n;
|
|
2138
|
+
}, z = (e, t) => requestAnimationFrame(() => R(e, t)?.focus());
|
|
2139
|
+
y(() => {
|
|
2140
|
+
T.r >= i.length && i.length && O({
|
|
2141
|
+
r: i.length - 1,
|
|
2142
|
+
c: T.c
|
|
2143
|
+
});
|
|
2144
|
+
}, [i.length, T]);
|
|
2145
|
+
let B = () => {
|
|
2146
|
+
let { r: e, c: n, value: r } = k, a = t[n];
|
|
2147
|
+
s?.(i.map((t, n) => n === e ? {
|
|
2148
|
+
...t,
|
|
2149
|
+
[a.key]: a.numeric && r !== "" ? Number(r) : r
|
|
2150
|
+
} : t)), A(null), z(e, n);
|
|
2151
|
+
};
|
|
2152
|
+
function V(e) {
|
|
2153
|
+
if (k) {
|
|
2154
|
+
if (e.key === "Enter") e.preventDefault(), B();
|
|
2155
|
+
else if (e.key === "Escape") {
|
|
2156
|
+
e.preventDefault();
|
|
2157
|
+
let { r: t, c: n } = k;
|
|
2158
|
+
A(null), z(t, n);
|
|
2159
|
+
}
|
|
2160
|
+
return;
|
|
2161
|
+
}
|
|
2162
|
+
let { r: n, c: r } = T, a = {
|
|
2163
|
+
ArrowRight: [0, 1],
|
|
2164
|
+
ArrowLeft: [0, -1],
|
|
2165
|
+
ArrowDown: [1, 0],
|
|
2166
|
+
ArrowUp: [-1, 0]
|
|
2167
|
+
}[e.key];
|
|
2168
|
+
if (a) {
|
|
2169
|
+
e.preventDefault();
|
|
2170
|
+
let t = {
|
|
2171
|
+
r: Math.min(Math.max(n + a[0], 0), i.length - 1),
|
|
2172
|
+
c: Math.min(Math.max(r + a[1], 0), F - 1)
|
|
2173
|
+
};
|
|
2174
|
+
O(t), z(t.r, t.c);
|
|
2175
|
+
return;
|
|
2176
|
+
}
|
|
2177
|
+
if (e.key === "Home" || e.key === "End") {
|
|
2178
|
+
e.preventDefault();
|
|
2179
|
+
let t = {
|
|
2180
|
+
r: n,
|
|
2181
|
+
c: e.key === "Home" ? 0 : F - 1
|
|
2182
|
+
};
|
|
2183
|
+
O(t), z(t.r, t.c);
|
|
2184
|
+
return;
|
|
2185
|
+
}
|
|
2186
|
+
if ((e.key === "Enter" || e.key === "F2") && r < t.length) {
|
|
2187
|
+
if (e.preventDefault(), S) {
|
|
2188
|
+
M({
|
|
2189
|
+
r: n,
|
|
2190
|
+
values: { ...i[n] }
|
|
2191
|
+
});
|
|
2192
|
+
return;
|
|
2193
|
+
}
|
|
2194
|
+
if (t[r].editable === !1) return;
|
|
2195
|
+
A({
|
|
2196
|
+
r: n,
|
|
2197
|
+
c: r,
|
|
2198
|
+
value: i[n]?.[t[r].key] ?? ""
|
|
2199
|
+
});
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
let ee = () => {
|
|
2203
|
+
let e = [...i, l()];
|
|
2204
|
+
s?.(e), O({
|
|
2205
|
+
r: e.length - 1,
|
|
2206
|
+
c: 0
|
|
2207
|
+
}), z(e.length - 1, 0);
|
|
2208
|
+
}, te = (e) => {
|
|
2209
|
+
s?.(i.filter((t, n) => n !== e));
|
|
2210
|
+
let t = {
|
|
2211
|
+
r: Math.max(0, e - 1),
|
|
2212
|
+
c: 0
|
|
2213
|
+
};
|
|
2214
|
+
O(t), i.length > 1 && z(t.r, 0);
|
|
2215
|
+
}, H = () => {
|
|
2216
|
+
let { r: e, values: t } = j;
|
|
2217
|
+
s?.(i.map((n, r) => r === e ? t : n)), M(null), z(e, 0);
|
|
2218
|
+
};
|
|
2219
|
+
return /* @__PURE__ */ D("div", {
|
|
2220
|
+
ref: _,
|
|
2221
|
+
className: `piq-grid-edit${g ? ` ${g}` : ""}`,
|
|
2222
|
+
"data-size": x,
|
|
2223
|
+
children: [
|
|
2224
|
+
/* @__PURE__ */ E("div", {
|
|
2225
|
+
className: "piq-table-wrap",
|
|
2226
|
+
children: /* @__PURE__ */ D("table", {
|
|
2227
|
+
ref: v,
|
|
2228
|
+
role: "grid",
|
|
2229
|
+
"aria-label": e,
|
|
2230
|
+
className: "piq-table piq-grid-edit__table",
|
|
2231
|
+
onKeyDown: V,
|
|
2232
|
+
children: [
|
|
2233
|
+
/* @__PURE__ */ E("thead", { children: /* @__PURE__ */ D("tr", { children: [t.map((e) => /* @__PURE__ */ E("th", {
|
|
2234
|
+
scope: "col",
|
|
2235
|
+
className: e.numeric ? "piq-num" : void 0,
|
|
2236
|
+
children: e.label
|
|
2237
|
+
}, e.key)), /* @__PURE__ */ E("th", {
|
|
2238
|
+
scope: "col",
|
|
2239
|
+
children: /* @__PURE__ */ E("span", {
|
|
2240
|
+
className: "piq-visually-hidden",
|
|
2241
|
+
children: "Actions"
|
|
2242
|
+
})
|
|
2243
|
+
})] }) }),
|
|
2244
|
+
/* @__PURE__ */ E("tbody", { children: i.map((e, r) => /* @__PURE__ */ D("tr", { children: [t.map((t, n) => {
|
|
2245
|
+
let i = c[P(e, r)]?.[t.key], a = `${N}-${r}-${n}-err`, o = k?.r === r && k?.c === n;
|
|
2246
|
+
return /* @__PURE__ */ D("td", {
|
|
2247
|
+
role: "gridcell",
|
|
2248
|
+
"data-r": r,
|
|
2249
|
+
"data-c": n,
|
|
2250
|
+
tabIndex: T.r === r && T.c === n && !o ? 0 : -1,
|
|
2251
|
+
"aria-invalid": i ? "true" : void 0,
|
|
2252
|
+
"aria-describedby": i ? a : void 0,
|
|
2253
|
+
"aria-readonly": t.editable === !1 ? "true" : void 0,
|
|
2254
|
+
className: `${t.numeric ? "piq-num " : ""}piq-grid-edit__cell`,
|
|
2255
|
+
onFocus: () => O({
|
|
2256
|
+
r,
|
|
2257
|
+
c: n
|
|
2258
|
+
}),
|
|
2259
|
+
onDoubleClick: () => S ? M({
|
|
2260
|
+
r,
|
|
2261
|
+
values: { ...e }
|
|
2262
|
+
}) : t.editable !== !1 && A({
|
|
2263
|
+
r,
|
|
2264
|
+
c: n,
|
|
2265
|
+
value: e[t.key] ?? ""
|
|
2266
|
+
}),
|
|
2267
|
+
children: [o ? /* @__PURE__ */ E("input", {
|
|
2268
|
+
autoFocus: !0,
|
|
2269
|
+
"aria-label": `${t.label}, row ${r + 1}`,
|
|
2270
|
+
className: "piq-field__input piq-grid-edit__input",
|
|
2271
|
+
inputMode: t.numeric ? "decimal" : void 0,
|
|
2272
|
+
value: k.value,
|
|
2273
|
+
onChange: (e) => A({
|
|
2274
|
+
...k,
|
|
2275
|
+
value: e.target.value
|
|
2276
|
+
}),
|
|
2277
|
+
onBlur: () => k && B()
|
|
2278
|
+
}) : /* @__PURE__ */ E("span", {
|
|
2279
|
+
className: "piq-grid-edit__value",
|
|
2280
|
+
children: e[t.key]
|
|
2281
|
+
}), i && /* @__PURE__ */ E("span", {
|
|
2282
|
+
id: a,
|
|
2283
|
+
className: "piq-field__error",
|
|
2284
|
+
children: i
|
|
2285
|
+
})]
|
|
2286
|
+
}, t.key);
|
|
2287
|
+
}), /* @__PURE__ */ D("td", {
|
|
2288
|
+
role: "gridcell",
|
|
2289
|
+
"data-r": r,
|
|
2290
|
+
"data-c": t.length,
|
|
2291
|
+
className: "piq-grid-edit__row-actions",
|
|
2292
|
+
children: [S && /* @__PURE__ */ E(o, {
|
|
2293
|
+
variant: "text",
|
|
2294
|
+
size: "sm",
|
|
2295
|
+
tabIndex: -1,
|
|
2296
|
+
"aria-label": p(r + 1),
|
|
2297
|
+
onClick: () => M({
|
|
2298
|
+
r,
|
|
2299
|
+
values: { ...e }
|
|
2300
|
+
}),
|
|
2301
|
+
children: /* @__PURE__ */ E(n, { name: "edit" })
|
|
2302
|
+
}), /* @__PURE__ */ E(o, {
|
|
2303
|
+
variant: "text",
|
|
2304
|
+
size: "sm",
|
|
2305
|
+
tabIndex: T.r === r && T.c === t.length ? 0 : -1,
|
|
2306
|
+
"aria-label": f(r + 1),
|
|
2307
|
+
onClick: () => te(r),
|
|
2308
|
+
onFocus: () => O({
|
|
2309
|
+
r,
|
|
2310
|
+
c: t.length
|
|
2311
|
+
}),
|
|
2312
|
+
children: /* @__PURE__ */ E(n, { name: "delete" })
|
|
2313
|
+
})]
|
|
2314
|
+
})] }, P(e, r))) }),
|
|
2315
|
+
I.length > 0 && /* @__PURE__ */ E("tfoot", { children: /* @__PURE__ */ D("tr", {
|
|
2316
|
+
className: "piq-grid-edit__totals",
|
|
2317
|
+
children: [t.map((e, t) => /* @__PURE__ */ E("td", {
|
|
2318
|
+
className: e.numeric ? "piq-num" : void 0,
|
|
2319
|
+
children: e.numeric ? L(e.key) : t === 0 ? /* @__PURE__ */ E("strong", { children: m }) : null
|
|
2320
|
+
}, e.key)), /* @__PURE__ */ E("td", {})]
|
|
2321
|
+
}) })
|
|
2322
|
+
]
|
|
2323
|
+
})
|
|
2324
|
+
}),
|
|
2325
|
+
/* @__PURE__ */ D(o, {
|
|
2326
|
+
variant: "secondary",
|
|
2327
|
+
onClick: ee,
|
|
2328
|
+
children: [/* @__PURE__ */ E(n, { name: "add" }), d]
|
|
2329
|
+
}),
|
|
2330
|
+
/* @__PURE__ */ E(u, {
|
|
2331
|
+
open: !!j,
|
|
2332
|
+
onClose: () => {
|
|
2333
|
+
let e = j?.r;
|
|
2334
|
+
M(null), e != null && z(e, 0);
|
|
2335
|
+
},
|
|
2336
|
+
title: j ? p(j.r + 1) : "",
|
|
2337
|
+
side: "bottom",
|
|
2338
|
+
children: j && /* @__PURE__ */ D("form", {
|
|
2339
|
+
className: "piq-quick-edit",
|
|
2340
|
+
onSubmit: (e) => {
|
|
2341
|
+
e.preventDefault(), H();
|
|
2342
|
+
},
|
|
2343
|
+
children: [t.filter((e) => e.editable !== !1).map((e) => /* @__PURE__ */ E(r, {
|
|
2344
|
+
label: e.label,
|
|
2345
|
+
inputMode: e.numeric ? "decimal" : void 0,
|
|
2346
|
+
value: j.values[e.key] ?? "",
|
|
2347
|
+
onChange: (t) => M({
|
|
2348
|
+
...j,
|
|
2349
|
+
values: {
|
|
2350
|
+
...j.values,
|
|
2351
|
+
[e.key]: e.numeric && t.target.value !== "" ? Number(t.target.value) : t.target.value
|
|
2352
|
+
}
|
|
2353
|
+
})
|
|
2354
|
+
}, e.key)), /* @__PURE__ */ E("div", {
|
|
2355
|
+
className: "piq-quick-edit__actions",
|
|
2356
|
+
children: /* @__PURE__ */ E(o, {
|
|
2357
|
+
type: "submit",
|
|
2358
|
+
children: h
|
|
2359
|
+
})
|
|
2360
|
+
})]
|
|
2361
|
+
})
|
|
2362
|
+
})
|
|
2363
|
+
]
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
//#endregion
|
|
2367
|
+
//#region src/patterns/WorkQueue.jsx
|
|
2368
|
+
var Ve = [
|
|
2369
|
+
[
|
|
2370
|
+
"J",
|
|
2371
|
+
"Next item",
|
|
2372
|
+
"next"
|
|
2373
|
+
],
|
|
2374
|
+
[
|
|
2375
|
+
"K",
|
|
2376
|
+
"Previous item",
|
|
2377
|
+
"previous"
|
|
2378
|
+
],
|
|
2379
|
+
[
|
|
2380
|
+
"A",
|
|
2381
|
+
"Approve",
|
|
2382
|
+
"approve"
|
|
2383
|
+
],
|
|
2384
|
+
[
|
|
2385
|
+
"R",
|
|
2386
|
+
"Reject",
|
|
2387
|
+
"reject"
|
|
2388
|
+
]
|
|
2389
|
+
];
|
|
2390
|
+
function He({ items: e = [], index: n = 0, onIndexChange: r, onApprove: i, onReject: a, onAssign: c, people: u = [], title: d = "Review queue", emptyTitle: f = "Nothing to review", emptyText: p = "New items will appear here.", className: m }) {
|
|
2391
|
+
let [g, _] = w(!0), [v, x] = w(!1), [S, T] = w(""), [O, k] = w(!1), [A, j] = w(!1), M = C(null), N = b(), P = Math.min(Math.max(n, 0), Math.max(e.length - 1, 0)), F = e[P], I = (t) => {
|
|
2392
|
+
t >= 0 && t < e.length && r?.(t);
|
|
2393
|
+
}, L = {
|
|
2394
|
+
next: () => I(P + 1),
|
|
2395
|
+
previous: () => I(P - 1),
|
|
2396
|
+
approve: () => F && i?.(F),
|
|
2397
|
+
reject: () => F && x(!0)
|
|
2398
|
+
};
|
|
2399
|
+
return y(() => {
|
|
2400
|
+
if (!g || !F) return;
|
|
2401
|
+
let e = (e) => {
|
|
2402
|
+
if (e.ctrlKey || e.metaKey || e.altKey || e.defaultPrevented || e.target.closest?.("input, textarea, select, [contenteditable], dialog[open]")) return;
|
|
2403
|
+
let t = Ve.find(([t]) => t.toLowerCase() === e.key.toLowerCase());
|
|
2404
|
+
t && (e.preventDefault(), L[t[2]]());
|
|
2405
|
+
};
|
|
2406
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
2407
|
+
}), e.length ? /* @__PURE__ */ D("section", {
|
|
2408
|
+
className: `piq-queue${m ? ` ${m}` : ""}`,
|
|
2409
|
+
"aria-label": d,
|
|
2410
|
+
children: [
|
|
2411
|
+
/* @__PURE__ */ D("div", {
|
|
2412
|
+
className: "piq-queue__bar",
|
|
2413
|
+
children: [
|
|
2414
|
+
/* @__PURE__ */ E("p", {
|
|
2415
|
+
className: "piq-queue__position",
|
|
2416
|
+
"aria-live": "polite",
|
|
2417
|
+
children: `${P + 1} of ${e.length}`
|
|
2418
|
+
}),
|
|
2419
|
+
/* @__PURE__ */ D("div", {
|
|
2420
|
+
className: "piq-queue__nav",
|
|
2421
|
+
children: [/* @__PURE__ */ E(o, {
|
|
2422
|
+
variant: "secondary",
|
|
2423
|
+
size: "sm",
|
|
2424
|
+
disabled: P === 0,
|
|
2425
|
+
onClick: L.previous,
|
|
2426
|
+
children: "Previous"
|
|
2427
|
+
}), /* @__PURE__ */ E(o, {
|
|
2428
|
+
variant: "secondary",
|
|
2429
|
+
size: "sm",
|
|
2430
|
+
disabled: P === e.length - 1,
|
|
2431
|
+
onClick: L.next,
|
|
2432
|
+
children: "Next"
|
|
2433
|
+
})]
|
|
2434
|
+
}),
|
|
2435
|
+
/* @__PURE__ */ E(o, {
|
|
2436
|
+
variant: "text",
|
|
2437
|
+
size: "sm",
|
|
2438
|
+
"aria-haspopup": "dialog",
|
|
2439
|
+
onClick: () => j(!0),
|
|
2440
|
+
children: "Keyboard shortcuts"
|
|
2441
|
+
})
|
|
2442
|
+
]
|
|
2443
|
+
}),
|
|
2444
|
+
/* @__PURE__ */ D("article", {
|
|
2445
|
+
className: "piq-queue__item",
|
|
2446
|
+
"aria-labelledby": `${N}-t`,
|
|
2447
|
+
children: [/* @__PURE__ */ E("h2", {
|
|
2448
|
+
id: `${N}-t`,
|
|
2449
|
+
className: "piq-queue__title",
|
|
2450
|
+
children: F.title
|
|
2451
|
+
}), F.content]
|
|
2452
|
+
}),
|
|
2453
|
+
/* @__PURE__ */ D("div", {
|
|
2454
|
+
className: "piq-queue__actions",
|
|
2455
|
+
children: [
|
|
2456
|
+
/* @__PURE__ */ E(o, {
|
|
2457
|
+
onClick: L.approve,
|
|
2458
|
+
children: "Approve"
|
|
2459
|
+
}),
|
|
2460
|
+
/* @__PURE__ */ E(o, {
|
|
2461
|
+
variant: "secondary",
|
|
2462
|
+
onClick: L.reject,
|
|
2463
|
+
children: "Reject"
|
|
2464
|
+
}),
|
|
2465
|
+
u.length > 0 && /* @__PURE__ */ E(s, {
|
|
2466
|
+
label: "Assign",
|
|
2467
|
+
items: u.map((e) => ({
|
|
2468
|
+
label: e.label,
|
|
2469
|
+
onSelect: () => c?.(F, e)
|
|
2470
|
+
}))
|
|
2471
|
+
})
|
|
2472
|
+
]
|
|
2473
|
+
}),
|
|
2474
|
+
/* @__PURE__ */ E(t, {
|
|
2475
|
+
open: v,
|
|
2476
|
+
onClose: () => {
|
|
2477
|
+
x(!1), k(!1);
|
|
2478
|
+
},
|
|
2479
|
+
title: `Reject ${F.title}`,
|
|
2480
|
+
children: /* @__PURE__ */ D("form", {
|
|
2481
|
+
className: "piq-quick-edit",
|
|
2482
|
+
noValidate: !0,
|
|
2483
|
+
onSubmit: (e) => {
|
|
2484
|
+
if (e.preventDefault(), k(!0), !S.trim()) {
|
|
2485
|
+
M.current?.querySelector("textarea")?.focus();
|
|
2486
|
+
return;
|
|
2487
|
+
}
|
|
2488
|
+
a?.(F, S.trim()), x(!1), T(""), k(!1);
|
|
2489
|
+
},
|
|
2490
|
+
children: [/* @__PURE__ */ E("div", {
|
|
2491
|
+
ref: M,
|
|
2492
|
+
children: /* @__PURE__ */ E(h, {
|
|
2493
|
+
label: "Comment",
|
|
2494
|
+
required: !0,
|
|
2495
|
+
"aria-required": "true",
|
|
2496
|
+
value: S,
|
|
2497
|
+
onChange: (e) => T(e.target.value),
|
|
2498
|
+
hint: "Say why, so the author can fix it.",
|
|
2499
|
+
error: O && !S.trim() ? "A comment is required to reject" : void 0
|
|
2500
|
+
})
|
|
2501
|
+
}), /* @__PURE__ */ D("div", {
|
|
2502
|
+
className: "piq-quick-edit__actions",
|
|
2503
|
+
children: [/* @__PURE__ */ E(o, {
|
|
2504
|
+
type: "submit",
|
|
2505
|
+
children: "Reject"
|
|
2506
|
+
}), /* @__PURE__ */ E(o, {
|
|
2507
|
+
variant: "secondary",
|
|
2508
|
+
onClick: () => x(!1),
|
|
2509
|
+
children: "Cancel"
|
|
2510
|
+
})]
|
|
2511
|
+
})]
|
|
2512
|
+
})
|
|
2513
|
+
}),
|
|
2514
|
+
/* @__PURE__ */ D(t, {
|
|
2515
|
+
open: A,
|
|
2516
|
+
onClose: () => j(!1),
|
|
2517
|
+
title: "Keyboard shortcuts",
|
|
2518
|
+
actions: /* @__PURE__ */ E(o, {
|
|
2519
|
+
variant: "secondary",
|
|
2520
|
+
onClick: () => j(!1),
|
|
2521
|
+
children: "Close"
|
|
2522
|
+
}),
|
|
2523
|
+
children: [/* @__PURE__ */ D("table", {
|
|
2524
|
+
className: "piq-table piq-queue__keys",
|
|
2525
|
+
children: [/* @__PURE__ */ E("thead", { children: /* @__PURE__ */ D("tr", { children: [/* @__PURE__ */ E("th", {
|
|
2526
|
+
scope: "col",
|
|
2527
|
+
children: "Key"
|
|
2528
|
+
}), /* @__PURE__ */ E("th", {
|
|
2529
|
+
scope: "col",
|
|
2530
|
+
children: "Action"
|
|
2531
|
+
})] }) }), /* @__PURE__ */ E("tbody", { children: Ve.map(([e, t]) => /* @__PURE__ */ D("tr", { children: [/* @__PURE__ */ E("td", { children: /* @__PURE__ */ E("kbd", { children: e }) }), /* @__PURE__ */ E("td", { children: t })] }, e)) })]
|
|
2532
|
+
}), /* @__PURE__ */ E(l, {
|
|
2533
|
+
label: "Use single-key shortcuts",
|
|
2534
|
+
checked: g,
|
|
2535
|
+
onChange: (e) => _(e.target.checked)
|
|
2536
|
+
})]
|
|
2537
|
+
})
|
|
2538
|
+
]
|
|
2539
|
+
}) : /* @__PURE__ */ E("section", {
|
|
2540
|
+
className: `piq-queue${m ? ` ${m}` : ""}`,
|
|
2541
|
+
"aria-label": d,
|
|
2542
|
+
children: /* @__PURE__ */ E(J, {
|
|
2543
|
+
kind: "empty",
|
|
2544
|
+
title: f,
|
|
2545
|
+
children: /* @__PURE__ */ E("p", { children: p })
|
|
2546
|
+
})
|
|
2547
|
+
});
|
|
2548
|
+
}
|
|
2549
|
+
//#endregion
|
|
2550
|
+
//#region src/patterns/ImportExport.jsx
|
|
2551
|
+
var Ue = [
|
|
2552
|
+
"Upload",
|
|
2553
|
+
"Map columns",
|
|
2554
|
+
"Validate",
|
|
2555
|
+
"Preview",
|
|
2556
|
+
"Import"
|
|
2557
|
+
];
|
|
2558
|
+
function We({ title: e = "Import records", onFile: t, columns: r = [], fields: i = [], onMap: a, errors: s = [], failedRowsHref: l, preview: u, onCommit: d, result: f, accept: p = ".csv,.xlsx", className: m }) {
|
|
2559
|
+
let [h, g] = w(0), [_, v] = w(null), [y, x] = w({}), [S, T] = w(!1), O = C(null), k = b(), A = (e) => {
|
|
2560
|
+
e && (v(e), t?.(e));
|
|
2561
|
+
}, j = f ? Ue.length : h, M;
|
|
2562
|
+
return f ? M = /* @__PURE__ */ E("div", {
|
|
2563
|
+
className: "piq-import__result",
|
|
2564
|
+
role: "status",
|
|
2565
|
+
children: f
|
|
2566
|
+
}) : h === 0 ? M = /* @__PURE__ */ D("div", {
|
|
2567
|
+
className: `piq-import__drop${S ? " is-over" : ""}`,
|
|
2568
|
+
onDragOver: (e) => {
|
|
2569
|
+
e.preventDefault(), T(!0);
|
|
2570
|
+
},
|
|
2571
|
+
onDragLeave: () => T(!1),
|
|
2572
|
+
onDrop: (e) => {
|
|
2573
|
+
e.preventDefault(), T(!1), A(e.dataTransfer?.files?.[0]);
|
|
2574
|
+
},
|
|
2575
|
+
children: [
|
|
2576
|
+
/* @__PURE__ */ E(n, { name: "upload" }),
|
|
2577
|
+
/* @__PURE__ */ E("input", {
|
|
2578
|
+
ref: O,
|
|
2579
|
+
id: `${k}-file`,
|
|
2580
|
+
type: "file",
|
|
2581
|
+
accept: p,
|
|
2582
|
+
className: "piq-visually-hidden",
|
|
2583
|
+
onChange: (e) => A(e.target.files?.[0])
|
|
2584
|
+
}),
|
|
2585
|
+
/* @__PURE__ */ E(o, {
|
|
2586
|
+
variant: "secondary",
|
|
2587
|
+
onClick: () => O.current?.click(),
|
|
2588
|
+
children: "Choose a file"
|
|
2589
|
+
}),
|
|
2590
|
+
/* @__PURE__ */ E("p", {
|
|
2591
|
+
className: "piq-import__hint",
|
|
2592
|
+
children: "or drop it here"
|
|
2593
|
+
}),
|
|
2594
|
+
_ && /* @__PURE__ */ E("p", {
|
|
2595
|
+
className: "piq-import__file",
|
|
2596
|
+
children: _.name
|
|
2597
|
+
})
|
|
2598
|
+
]
|
|
2599
|
+
}) : h === 1 ? M = /* @__PURE__ */ E("div", {
|
|
2600
|
+
className: "piq-import__mapping",
|
|
2601
|
+
children: r.map((e) => /* @__PURE__ */ E(c, {
|
|
2602
|
+
label: `File column “${e}”`,
|
|
2603
|
+
placeholder: "Choose a field",
|
|
2604
|
+
value: y[e] ?? "",
|
|
2605
|
+
options: [...i, {
|
|
2606
|
+
value: "__skip",
|
|
2607
|
+
label: "Don't import"
|
|
2608
|
+
}],
|
|
2609
|
+
onChange: (t) => x({
|
|
2610
|
+
...y,
|
|
2611
|
+
[e]: t.target.value
|
|
2612
|
+
})
|
|
2613
|
+
}, e))
|
|
2614
|
+
}) : h === 2 ? M = s.length ? /* @__PURE__ */ D("div", {
|
|
2615
|
+
className: "piq-import__errors",
|
|
2616
|
+
children: [
|
|
2617
|
+
/* @__PURE__ */ E("p", { children: `${s.length} ${s.length === 1 ? "row needs" : "rows need"} fixing. They will be skipped unless you fix the file and upload it again.` }),
|
|
2618
|
+
/* @__PURE__ */ E("ul", { children: s.map((e, t) => /* @__PURE__ */ D("li", { children: [/* @__PURE__ */ E("strong", { children: `Row ${e.row}` }), `: ${e.message}`] }, t)) }),
|
|
2619
|
+
l && /* @__PURE__ */ D("a", {
|
|
2620
|
+
className: "piq-btn piq-btn--secondary",
|
|
2621
|
+
href: l,
|
|
2622
|
+
download: !0,
|
|
2623
|
+
children: [/* @__PURE__ */ E(n, { name: "download" }), "Download the failed rows"]
|
|
2624
|
+
})
|
|
2625
|
+
]
|
|
2626
|
+
}) : /* @__PURE__ */ E("p", { children: "Every row is ready to import." }) : (h === 3 || h === 4) && (M = u ? /* @__PURE__ */ E("div", {
|
|
2627
|
+
className: "piq-table-wrap",
|
|
2628
|
+
children: /* @__PURE__ */ D("table", {
|
|
2629
|
+
className: "piq-table",
|
|
2630
|
+
children: [
|
|
2631
|
+
/* @__PURE__ */ E("caption", {
|
|
2632
|
+
className: "piq-visually-hidden",
|
|
2633
|
+
children: "Rows to import"
|
|
2634
|
+
}),
|
|
2635
|
+
/* @__PURE__ */ E("thead", { children: /* @__PURE__ */ E("tr", { children: u.columns.map((e) => /* @__PURE__ */ E("th", {
|
|
2636
|
+
scope: "col",
|
|
2637
|
+
children: e.label
|
|
2638
|
+
}, e.key)) }) }),
|
|
2639
|
+
/* @__PURE__ */ E("tbody", { children: u.rows.map((e, t) => /* @__PURE__ */ E("tr", { children: u.columns.map((t) => /* @__PURE__ */ E("td", { children: e[t.key] }, t.key)) }, t)) })
|
|
2640
|
+
]
|
|
2641
|
+
})
|
|
2642
|
+
}) : null), /* @__PURE__ */ D("section", {
|
|
2643
|
+
className: `piq-import${m ? ` ${m}` : ""}`,
|
|
2644
|
+
"aria-labelledby": `${k}-h`,
|
|
2645
|
+
children: [
|
|
2646
|
+
/* @__PURE__ */ E("h2", {
|
|
2647
|
+
id: `${k}-h`,
|
|
2648
|
+
className: "piq-import__title",
|
|
2649
|
+
children: e
|
|
2650
|
+
}),
|
|
2651
|
+
/* @__PURE__ */ E("ol", {
|
|
2652
|
+
className: "piq-wizard__steps piq-import__steps",
|
|
2653
|
+
"aria-label": "Steps",
|
|
2654
|
+
children: Ue.map((e, t) => /* @__PURE__ */ E("li", {
|
|
2655
|
+
className: "piq-wizard__step",
|
|
2656
|
+
"aria-current": t === j ? "step" : void 0,
|
|
2657
|
+
"data-done": t < j || void 0,
|
|
2658
|
+
children: e
|
|
2659
|
+
}, e))
|
|
2660
|
+
}),
|
|
2661
|
+
M,
|
|
2662
|
+
!f && /* @__PURE__ */ D("div", {
|
|
2663
|
+
className: "piq-wizard__actions",
|
|
2664
|
+
children: [
|
|
2665
|
+
h < 3 && /* @__PURE__ */ E(o, {
|
|
2666
|
+
disabled: h === 0 && !_,
|
|
2667
|
+
onClick: () => {
|
|
2668
|
+
h === 1 && a?.(y), g(h + 1);
|
|
2669
|
+
},
|
|
2670
|
+
children: "Continue"
|
|
2671
|
+
}),
|
|
2672
|
+
h === 3 && /* @__PURE__ */ E(o, {
|
|
2673
|
+
onClick: () => {
|
|
2674
|
+
g(4), d?.();
|
|
2675
|
+
},
|
|
2676
|
+
children: `Import ${u?.rows.length ?? ""} rows`.replace(" ", " ")
|
|
2677
|
+
}),
|
|
2678
|
+
h > 0 && h < 4 && /* @__PURE__ */ E(o, {
|
|
2679
|
+
variant: "secondary",
|
|
2680
|
+
onClick: () => g(h - 1),
|
|
2681
|
+
children: "Back"
|
|
2682
|
+
})
|
|
2683
|
+
]
|
|
2684
|
+
})
|
|
2685
|
+
]
|
|
2686
|
+
});
|
|
2687
|
+
}
|
|
2688
|
+
function Ge({ open: e = !1, onClose: n, title: r = "Export", formats: s = [], fields: c = [], onExport: l, progress: u = null, ready: f, exportLabel: p = "Export", className: m }) {
|
|
2689
|
+
let [h, g] = w(s[0]?.value), [_, v] = w(c.map((e) => e.value)), y = (e, t) => v((n) => t ? [...n, e] : n.filter((t) => t !== e));
|
|
2690
|
+
return /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ D(t, {
|
|
2691
|
+
open: e,
|
|
2692
|
+
onClose: n,
|
|
2693
|
+
title: r,
|
|
2694
|
+
className: m,
|
|
2695
|
+
actions: /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E(o, {
|
|
2696
|
+
disabled: !_.length,
|
|
2697
|
+
onClick: () => l?.({
|
|
2698
|
+
format: h,
|
|
2699
|
+
fields: _
|
|
2700
|
+
}),
|
|
2701
|
+
children: p
|
|
2702
|
+
}), /* @__PURE__ */ E(o, {
|
|
2703
|
+
variant: "secondary",
|
|
2704
|
+
onClick: () => n?.(),
|
|
2705
|
+
children: "Close"
|
|
2706
|
+
})] }),
|
|
2707
|
+
children: [
|
|
2708
|
+
/* @__PURE__ */ E(d, {
|
|
2709
|
+
label: "Format",
|
|
2710
|
+
name: "export-format",
|
|
2711
|
+
options: s,
|
|
2712
|
+
value: h,
|
|
2713
|
+
onChange: (e) => g(e?.target ? e.target.value : e)
|
|
2714
|
+
}),
|
|
2715
|
+
/* @__PURE__ */ D("fieldset", {
|
|
2716
|
+
className: "piq-export__fields",
|
|
2717
|
+
children: [/* @__PURE__ */ E("legend", {
|
|
2718
|
+
className: "piq-field__label",
|
|
2719
|
+
children: "Fields"
|
|
2720
|
+
}), c.map((e) => /* @__PURE__ */ E(i, {
|
|
2721
|
+
label: e.label,
|
|
2722
|
+
checked: _.includes(e.value),
|
|
2723
|
+
onChange: (t) => y(e.value, t.target.checked)
|
|
2724
|
+
}, e.value))]
|
|
2725
|
+
}),
|
|
2726
|
+
u != null && /* @__PURE__ */ E(a, {
|
|
2727
|
+
label: "Exporting",
|
|
2728
|
+
value: u,
|
|
2729
|
+
showValue: !0
|
|
2730
|
+
})
|
|
2731
|
+
]
|
|
2732
|
+
}), /* @__PURE__ */ D("div", {
|
|
2733
|
+
className: "piq-export__status",
|
|
2734
|
+
role: "status",
|
|
2735
|
+
children: [u != null && !e && /* @__PURE__ */ E(a, {
|
|
2736
|
+
label: "Exporting",
|
|
2737
|
+
value: u,
|
|
2738
|
+
showValue: !0
|
|
2739
|
+
}), f && /* @__PURE__ */ D("p", {
|
|
2740
|
+
className: "piq-export__ready",
|
|
2741
|
+
children: ["Your export is ready. ", /* @__PURE__ */ E("a", {
|
|
2742
|
+
href: f.href,
|
|
2743
|
+
download: !0,
|
|
2744
|
+
children: f.label ?? "Download it"
|
|
2745
|
+
})]
|
|
2746
|
+
})]
|
|
2747
|
+
})] });
|
|
2748
|
+
}
|
|
2749
|
+
//#endregion
|
|
2750
|
+
//#region src/patterns/Planning.jsx
|
|
2751
|
+
function Ke({ label: e, columns: t = [], cards: n = [], onMove: r, moveLabel: i = "Move to", className: a }) {
|
|
2752
|
+
let o = C(null), c = W(o), [l, u] = w(null), d = (e) => n.filter((t) => t.status === e), f = (e) => `${e.title} (${d(e.id).length})`, p = (e) => /* @__PURE__ */ D("li", {
|
|
2753
|
+
className: "piq-board__card",
|
|
2754
|
+
draggable: !0,
|
|
2755
|
+
onDragStart: (t) => {
|
|
2756
|
+
u(e.id), t.dataTransfer?.setData("text/plain", e.id);
|
|
2757
|
+
},
|
|
2758
|
+
onDragEnd: () => u(null),
|
|
2759
|
+
children: [
|
|
2760
|
+
/* @__PURE__ */ E("p", {
|
|
2761
|
+
className: "piq-board__card-title",
|
|
2762
|
+
children: e.title
|
|
2763
|
+
}),
|
|
2764
|
+
e.content,
|
|
2765
|
+
/* @__PURE__ */ E(s, {
|
|
2766
|
+
label: i,
|
|
2767
|
+
size: "sm",
|
|
2768
|
+
variant: "text",
|
|
2769
|
+
buttonLabel: `${i}: ${e.title}`,
|
|
2770
|
+
items: t.filter((t) => t.id !== e.status).map((t) => ({
|
|
2771
|
+
label: t.title,
|
|
2772
|
+
onSelect: () => r?.(e, t.id)
|
|
2773
|
+
}))
|
|
2774
|
+
})
|
|
2775
|
+
]
|
|
2776
|
+
}, e.id), h = (e, t = !0) => /* @__PURE__ */ D("section", {
|
|
2777
|
+
className: "piq-board__column",
|
|
2778
|
+
"aria-label": f(e),
|
|
2779
|
+
onDragOver: (e) => e.preventDefault(),
|
|
2780
|
+
onDrop: (t) => {
|
|
2781
|
+
t.preventDefault();
|
|
2782
|
+
let i = t.dataTransfer?.getData("text/plain") || l, a = n.find((e) => e.id === i);
|
|
2783
|
+
a && a.status !== e.id && r?.(a, e.id), u(null);
|
|
2784
|
+
},
|
|
2785
|
+
children: [t && /* @__PURE__ */ E("h3", {
|
|
2786
|
+
className: "piq-board__heading",
|
|
2787
|
+
children: f(e)
|
|
2788
|
+
}), /* @__PURE__ */ E("ul", {
|
|
2789
|
+
className: "piq-board__cards",
|
|
2790
|
+
children: d(e.id).map(p)
|
|
2791
|
+
})]
|
|
2792
|
+
}, e.id);
|
|
2793
|
+
return /* @__PURE__ */ E("div", {
|
|
2794
|
+
ref: o,
|
|
2795
|
+
className: `piq-board${a ? ` ${a}` : ""}`,
|
|
2796
|
+
role: "region",
|
|
2797
|
+
"aria-label": e,
|
|
2798
|
+
"data-size": c,
|
|
2799
|
+
children: G(c, "medium") ? /* @__PURE__ */ E("div", {
|
|
2800
|
+
className: "piq-board__columns",
|
|
2801
|
+
children: t.map((e) => h(e))
|
|
2802
|
+
}) : /* @__PURE__ */ E(m, {
|
|
2803
|
+
label: e,
|
|
2804
|
+
tabs: t.map((e) => ({
|
|
2805
|
+
id: e.id,
|
|
2806
|
+
label: e.title,
|
|
2807
|
+
count: d(e.id).length,
|
|
2808
|
+
panel: h(e, !1)
|
|
2809
|
+
}))
|
|
2810
|
+
})
|
|
2811
|
+
});
|
|
2812
|
+
}
|
|
2813
|
+
var qe = (e) => new Date(e.getFullYear(), e.getMonth(), e.getDate()), Je = (e, t) => e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate(), Q = (e, t) => new Date(e.getFullYear(), e.getMonth(), e.getDate() + t), $ = (e) => `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
|
|
2814
|
+
function Ye({ label: e = "Calendar", events: t = [], date: n = /* @__PURE__ */ new Date(), view: r, onViewChange: i, locale: a, className: o }) {
|
|
2815
|
+
let s = C(null), c = C(null), l = W(s), [u, d] = w("month"), f = r ?? u, p = qe(new Date(n)), [m, h] = w(p), g = b(), _ = new Intl.DateTimeFormat(a, {
|
|
2816
|
+
hour: "2-digit",
|
|
2817
|
+
minute: "2-digit"
|
|
2818
|
+
}), v = new Intl.DateTimeFormat(a, {
|
|
2819
|
+
weekday: "long",
|
|
2820
|
+
day: "numeric",
|
|
2821
|
+
month: "long"
|
|
2822
|
+
}), y = new Intl.DateTimeFormat(a, { weekday: "short" }), x = t.map((e) => ({
|
|
2823
|
+
...e,
|
|
2824
|
+
at: new Date(e.start)
|
|
2825
|
+
})).sort((e, t) => e.at - t.at), S = (e) => x.filter((t) => Je(t.at, e)), T = (e) => /* @__PURE__ */ D("li", {
|
|
2826
|
+
className: "piq-calendar__event",
|
|
2827
|
+
children: [
|
|
2828
|
+
/* @__PURE__ */ E("time", {
|
|
2829
|
+
dateTime: e.at.toISOString(),
|
|
2830
|
+
children: _.format(e.at)
|
|
2831
|
+
}),
|
|
2832
|
+
" ",
|
|
2833
|
+
e.title
|
|
2834
|
+
]
|
|
2835
|
+
}, e.id), O = (e) => {
|
|
2836
|
+
r === void 0 && d(e), i?.(e);
|
|
2837
|
+
};
|
|
2838
|
+
if (!G(l, "medium")) {
|
|
2839
|
+
let t = [...new Set(x.map((e) => $(e.at)))];
|
|
2840
|
+
return /* @__PURE__ */ E("section", {
|
|
2841
|
+
ref: s,
|
|
2842
|
+
className: `piq-calendar piq-calendar--agenda${o ? ` ${o}` : ""}`,
|
|
2843
|
+
"aria-label": e,
|
|
2844
|
+
"data-size": l,
|
|
2845
|
+
children: t.map((e) => {
|
|
2846
|
+
let t = /* @__PURE__ */ new Date(`${e}T00:00`);
|
|
2847
|
+
return /* @__PURE__ */ D("div", {
|
|
2848
|
+
className: "piq-calendar__agenda-day",
|
|
2849
|
+
children: [/* @__PURE__ */ E("h3", {
|
|
2850
|
+
className: "piq-calendar__date",
|
|
2851
|
+
children: v.format(t)
|
|
2852
|
+
}), /* @__PURE__ */ E("ul", {
|
|
2853
|
+
className: "piq-calendar__events",
|
|
2854
|
+
children: S(t).map(T)
|
|
2855
|
+
})]
|
|
2856
|
+
}, e);
|
|
2857
|
+
})
|
|
2858
|
+
});
|
|
2859
|
+
}
|
|
2860
|
+
let k = new Date(p.getFullYear(), p.getMonth(), 1), A = Q(k, -((k.getDay() + 6) % 7)), j = Array.from({ length: 6 }, (e, t) => Array.from({ length: 7 }, (e, n) => Q(A, t * 7 + n))), M = (e) => {
|
|
2861
|
+
h(e), requestAnimationFrame(() => c.current?.querySelector(`[data-date="${$(e)}"]`)?.focus());
|
|
2862
|
+
};
|
|
2863
|
+
function N(e) {
|
|
2864
|
+
let t = {
|
|
2865
|
+
ArrowRight: 1,
|
|
2866
|
+
ArrowLeft: -1,
|
|
2867
|
+
ArrowDown: 7,
|
|
2868
|
+
ArrowUp: -7
|
|
2869
|
+
}[e.key];
|
|
2870
|
+
t ? (e.preventDefault(), M(Q(m, t))) : e.key === "Home" ? (e.preventDefault(), M(Q(m, -((m.getDay() + 6) % 7)))) : e.key === "End" && (e.preventDefault(), M(Q(m, 6 - (m.getDay() + 6) % 7)));
|
|
2871
|
+
}
|
|
2872
|
+
let P = Q(p, -((p.getDay() + 6) % 7));
|
|
2873
|
+
return /* @__PURE__ */ D("section", {
|
|
2874
|
+
ref: s,
|
|
2875
|
+
className: `piq-calendar${o ? ` ${o}` : ""}`,
|
|
2876
|
+
"aria-label": e,
|
|
2877
|
+
"data-size": l,
|
|
2878
|
+
children: [
|
|
2879
|
+
/* @__PURE__ */ E("div", {
|
|
2880
|
+
className: "piq-calendar__views",
|
|
2881
|
+
role: "radiogroup",
|
|
2882
|
+
"aria-label": "View",
|
|
2883
|
+
children: [
|
|
2884
|
+
"month",
|
|
2885
|
+
"week",
|
|
2886
|
+
"day"
|
|
2887
|
+
].map((e) => /* @__PURE__ */ E("button", {
|
|
2888
|
+
type: "button",
|
|
2889
|
+
role: "radio",
|
|
2890
|
+
"aria-checked": f === e,
|
|
2891
|
+
className: "piq-calendar__view",
|
|
2892
|
+
onClick: () => O(e),
|
|
2893
|
+
children: e[0].toUpperCase() + e.slice(1)
|
|
2894
|
+
}, e))
|
|
2895
|
+
}),
|
|
2896
|
+
f === "month" && /* @__PURE__ */ D("table", {
|
|
2897
|
+
ref: c,
|
|
2898
|
+
role: "grid",
|
|
2899
|
+
"aria-label": new Intl.DateTimeFormat(a, {
|
|
2900
|
+
month: "long",
|
|
2901
|
+
year: "numeric"
|
|
2902
|
+
}).format(p),
|
|
2903
|
+
className: "piq-calendar__month",
|
|
2904
|
+
onKeyDown: N,
|
|
2905
|
+
children: [/* @__PURE__ */ E("thead", { children: /* @__PURE__ */ E("tr", { children: j[0].map((e) => /* @__PURE__ */ E("th", {
|
|
2906
|
+
scope: "col",
|
|
2907
|
+
children: y.format(e)
|
|
2908
|
+
}, $(e))) }) }), /* @__PURE__ */ E("tbody", { children: j.map((e, t) => /* @__PURE__ */ E("tr", { children: e.map((e) => /* @__PURE__ */ D("td", {
|
|
2909
|
+
role: "gridcell",
|
|
2910
|
+
"data-date": $(e),
|
|
2911
|
+
tabIndex: Je(e, m) ? 0 : -1,
|
|
2912
|
+
"aria-label": v.format(e),
|
|
2913
|
+
"data-outside": e.getMonth() !== p.getMonth() || void 0,
|
|
2914
|
+
className: "piq-calendar__day",
|
|
2915
|
+
onFocus: () => h(e),
|
|
2916
|
+
children: [/* @__PURE__ */ E("span", {
|
|
2917
|
+
className: "piq-calendar__number",
|
|
2918
|
+
"aria-hidden": "true",
|
|
2919
|
+
children: e.getDate()
|
|
2920
|
+
}), /* @__PURE__ */ E("ul", {
|
|
2921
|
+
className: "piq-calendar__events",
|
|
2922
|
+
children: S(e).map(T)
|
|
2923
|
+
})]
|
|
2924
|
+
}, $(e))) }, t)) })]
|
|
2925
|
+
}),
|
|
2926
|
+
f === "week" && /* @__PURE__ */ E("ol", {
|
|
2927
|
+
className: "piq-calendar__week",
|
|
2928
|
+
"aria-label": `Week of ${v.format(P)}`,
|
|
2929
|
+
children: Array.from({ length: 7 }, (e, t) => Q(P, t)).map((e) => /* @__PURE__ */ D("li", {
|
|
2930
|
+
className: "piq-calendar__week-day",
|
|
2931
|
+
children: [/* @__PURE__ */ E("h3", {
|
|
2932
|
+
className: "piq-calendar__date",
|
|
2933
|
+
children: v.format(e)
|
|
2934
|
+
}), /* @__PURE__ */ E("ul", {
|
|
2935
|
+
className: "piq-calendar__events",
|
|
2936
|
+
children: S(e).map(T)
|
|
2937
|
+
})]
|
|
2938
|
+
}, $(e)))
|
|
2939
|
+
}),
|
|
2940
|
+
f === "day" && /* @__PURE__ */ D("div", {
|
|
2941
|
+
className: "piq-calendar__single",
|
|
2942
|
+
id: `${g}-day`,
|
|
2943
|
+
children: [/* @__PURE__ */ E("h3", {
|
|
2944
|
+
className: "piq-calendar__date",
|
|
2945
|
+
children: v.format(p)
|
|
2946
|
+
}), /* @__PURE__ */ E("ul", {
|
|
2947
|
+
className: "piq-calendar__events",
|
|
2948
|
+
children: S(p).map(T)
|
|
2949
|
+
})]
|
|
2950
|
+
})
|
|
2951
|
+
]
|
|
2952
|
+
});
|
|
2953
|
+
}
|
|
2954
|
+
var Xe = (e) => e >= 1048576 ? `${(e / 1048576).toFixed(1)} MB` : e >= 1024 ? `${Math.round(e / 1024)} KB` : `${e} B`;
|
|
2955
|
+
function Ze({ label: e = "Attachments", files: t = [], onUpload: r, onRemove: i, accept: a, uploadLabel: s = "Upload a file", className: c }) {
|
|
2956
|
+
let l = C(null), [u, d] = w(!1), [f, p] = w(null);
|
|
2957
|
+
return /* @__PURE__ */ D("section", {
|
|
2958
|
+
className: `piq-attachments${c ? ` ${c}` : ""}`,
|
|
2959
|
+
"aria-label": e,
|
|
2960
|
+
onDragOver: (e) => {
|
|
2961
|
+
e.preventDefault(), d(!0);
|
|
2962
|
+
},
|
|
2963
|
+
onDragLeave: () => d(!1),
|
|
2964
|
+
onDrop: (e) => {
|
|
2965
|
+
e.preventDefault(), d(!1);
|
|
2966
|
+
let t = e.dataTransfer?.files?.[0];
|
|
2967
|
+
t && r?.(t);
|
|
2968
|
+
},
|
|
2969
|
+
"data-over": u || void 0,
|
|
2970
|
+
children: [
|
|
2971
|
+
/* @__PURE__ */ D("div", {
|
|
2972
|
+
className: "piq-attachments__bar",
|
|
2973
|
+
children: [
|
|
2974
|
+
/* @__PURE__ */ E("input", {
|
|
2975
|
+
ref: l,
|
|
2976
|
+
type: "file",
|
|
2977
|
+
accept: a,
|
|
2978
|
+
className: "piq-visually-hidden",
|
|
2979
|
+
tabIndex: -1,
|
|
2980
|
+
"aria-hidden": "true",
|
|
2981
|
+
onChange: (e) => {
|
|
2982
|
+
let t = e.target.files?.[0];
|
|
2983
|
+
t && r?.(t), e.target.value = "";
|
|
2984
|
+
}
|
|
2985
|
+
}),
|
|
2986
|
+
/* @__PURE__ */ D(o, {
|
|
2987
|
+
variant: "secondary",
|
|
2988
|
+
onClick: () => l.current?.click(),
|
|
2989
|
+
children: [/* @__PURE__ */ E(n, { name: "upload" }), s]
|
|
2990
|
+
}),
|
|
2991
|
+
/* @__PURE__ */ E("span", {
|
|
2992
|
+
className: "piq-attachments__hint",
|
|
2993
|
+
children: "or drop a file here"
|
|
2994
|
+
})
|
|
2995
|
+
]
|
|
2996
|
+
}),
|
|
2997
|
+
/* @__PURE__ */ E("div", {
|
|
2998
|
+
className: "piq-table-wrap",
|
|
2999
|
+
children: /* @__PURE__ */ D("table", {
|
|
3000
|
+
className: "piq-table piq-attachments__list",
|
|
3001
|
+
children: [
|
|
3002
|
+
/* @__PURE__ */ E("caption", {
|
|
3003
|
+
className: "piq-visually-hidden",
|
|
3004
|
+
children: e
|
|
3005
|
+
}),
|
|
3006
|
+
/* @__PURE__ */ E("thead", { children: /* @__PURE__ */ D("tr", { children: [
|
|
3007
|
+
/* @__PURE__ */ E("th", {
|
|
3008
|
+
scope: "col",
|
|
3009
|
+
children: "Name"
|
|
3010
|
+
}),
|
|
3011
|
+
/* @__PURE__ */ E("th", {
|
|
3012
|
+
scope: "col",
|
|
3013
|
+
children: "Type"
|
|
3014
|
+
}),
|
|
3015
|
+
/* @__PURE__ */ E("th", {
|
|
3016
|
+
scope: "col",
|
|
3017
|
+
className: "piq-num",
|
|
3018
|
+
children: "Size"
|
|
3019
|
+
}),
|
|
3020
|
+
/* @__PURE__ */ E("th", {
|
|
3021
|
+
scope: "col",
|
|
3022
|
+
children: "Version"
|
|
3023
|
+
}),
|
|
3024
|
+
/* @__PURE__ */ E("th", {
|
|
3025
|
+
scope: "col",
|
|
3026
|
+
children: /* @__PURE__ */ E("span", {
|
|
3027
|
+
className: "piq-visually-hidden",
|
|
3028
|
+
children: "Actions"
|
|
3029
|
+
})
|
|
3030
|
+
})
|
|
3031
|
+
] }) }),
|
|
3032
|
+
/* @__PURE__ */ E("tbody", { children: t.map((e) => /* @__PURE__ */ D("tr", { children: [
|
|
3033
|
+
/* @__PURE__ */ E("td", { children: /* @__PURE__ */ E("a", {
|
|
3034
|
+
href: e.href,
|
|
3035
|
+
children: e.name
|
|
3036
|
+
}) }),
|
|
3037
|
+
/* @__PURE__ */ E("td", { children: e.type }),
|
|
3038
|
+
/* @__PURE__ */ E("td", {
|
|
3039
|
+
className: "piq-num",
|
|
3040
|
+
children: Xe(e.size ?? 0)
|
|
3041
|
+
}),
|
|
3042
|
+
/* @__PURE__ */ E("td", { children: e.version }),
|
|
3043
|
+
/* @__PURE__ */ E("td", { children: /* @__PURE__ */ E(o, {
|
|
3044
|
+
variant: "text",
|
|
3045
|
+
size: "sm",
|
|
3046
|
+
"aria-label": `Remove ${e.name}`,
|
|
3047
|
+
onClick: () => p(e),
|
|
3048
|
+
children: /* @__PURE__ */ E(n, { name: "delete" })
|
|
3049
|
+
}) })
|
|
3050
|
+
] }, e.id)) })
|
|
3051
|
+
]
|
|
3052
|
+
})
|
|
3053
|
+
}),
|
|
3054
|
+
/* @__PURE__ */ E(Z, {
|
|
3055
|
+
open: !!f,
|
|
3056
|
+
objectName: f?.name,
|
|
3057
|
+
title: f ? `Remove ${f.name}?` : "",
|
|
3058
|
+
confirmLabel: "Remove",
|
|
3059
|
+
consequence: "The file is removed from this record for everyone.",
|
|
3060
|
+
onCancel: () => p(null),
|
|
3061
|
+
onConfirm: () => {
|
|
3062
|
+
i?.(f), p(null);
|
|
3063
|
+
}
|
|
3064
|
+
})
|
|
3065
|
+
]
|
|
3066
|
+
});
|
|
3067
|
+
}
|
|
3068
|
+
//#endregion
|
|
3069
|
+
//#region src/patterns/Analysis.jsx
|
|
3070
|
+
function Qe({ param: e = "drill" } = {}) {
|
|
3071
|
+
let t = () => {
|
|
3072
|
+
let t = new URLSearchParams(window.location.search).get(e);
|
|
3073
|
+
return t ? t.split("/") : [];
|
|
3074
|
+
}, [n, r] = w(t);
|
|
3075
|
+
y(() => {
|
|
3076
|
+
let e = () => r(t());
|
|
3077
|
+
return window.addEventListener("popstate", e), () => window.removeEventListener("popstate", e);
|
|
3078
|
+
}, [e]);
|
|
3079
|
+
let i = (t) => {
|
|
3080
|
+
let n = new URLSearchParams(window.location.search);
|
|
3081
|
+
t.length ? n.set(e, t.join("/")) : n.delete(e), window.history.pushState({ [e]: t }, "", `${window.location.pathname}${n.toString() ? `?${n}` : ""}${window.location.hash}`), r(t);
|
|
3082
|
+
};
|
|
3083
|
+
return {
|
|
3084
|
+
path: n,
|
|
3085
|
+
drill: (e) => i([...n, e]),
|
|
3086
|
+
goTo: (e) => i(n.slice(0, e))
|
|
3087
|
+
};
|
|
3088
|
+
}
|
|
3089
|
+
function $e({ trail: e = [], onSelect: t, label: n = "Drill-down", children: r, className: i }) {
|
|
3090
|
+
return /* @__PURE__ */ D("section", {
|
|
3091
|
+
className: `piq-drill${i ? ` ${i}` : ""}`,
|
|
3092
|
+
"aria-label": n,
|
|
3093
|
+
children: [/* @__PURE__ */ E("nav", {
|
|
3094
|
+
"aria-label": "Levels",
|
|
3095
|
+
className: "piq-breadcrumbs",
|
|
3096
|
+
children: /* @__PURE__ */ E("ol", {
|
|
3097
|
+
className: "piq-breadcrumbs__list piq-drill__trail",
|
|
3098
|
+
children: e.map((n, r) => /* @__PURE__ */ E("li", {
|
|
3099
|
+
className: "piq-breadcrumbs__item",
|
|
3100
|
+
children: r === e.length - 1 ? /* @__PURE__ */ E("span", {
|
|
3101
|
+
"aria-current": "location",
|
|
3102
|
+
children: n.label
|
|
3103
|
+
}) : /* @__PURE__ */ E("a", {
|
|
3104
|
+
href: "#",
|
|
3105
|
+
onClick: (e) => {
|
|
3106
|
+
e.preventDefault(), t?.(r);
|
|
3107
|
+
},
|
|
3108
|
+
children: n.label
|
|
3109
|
+
})
|
|
3110
|
+
}, r))
|
|
3111
|
+
})
|
|
3112
|
+
}), r]
|
|
3113
|
+
});
|
|
3114
|
+
}
|
|
3115
|
+
function et({ label: e, current: t, previous: r, comparison: i = "on the previous period", format: a = (e) => String(e), currentLabel: o = "This period", previousLabel: s = "Previous", className: c }) {
|
|
3116
|
+
let l = t - r, u = r ? Math.round(Math.abs(l) / Math.abs(r) * 100) : null, d = l === 0 ? `no change ${i}` : `${l > 0 ? "up" : "down"}${u == null ? "" : ` ${u}%`} ${i}`;
|
|
3117
|
+
return /* @__PURE__ */ D("section", {
|
|
3118
|
+
className: `piq-comparison${c ? ` ${c}` : ""}`,
|
|
3119
|
+
"aria-label": e,
|
|
3120
|
+
children: [
|
|
3121
|
+
/* @__PURE__ */ E("p", {
|
|
3122
|
+
className: "piq-comparison__label",
|
|
3123
|
+
children: e
|
|
3124
|
+
}),
|
|
3125
|
+
/* @__PURE__ */ D("dl", {
|
|
3126
|
+
className: "piq-comparison__values",
|
|
3127
|
+
children: [
|
|
3128
|
+
/* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("dt", { children: o }), /* @__PURE__ */ E("dd", {
|
|
3129
|
+
className: "piq-comparison__current",
|
|
3130
|
+
children: a(t)
|
|
3131
|
+
})] }),
|
|
3132
|
+
/* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("dt", { children: s }), /* @__PURE__ */ E("dd", { children: a(r) })] }),
|
|
3133
|
+
/* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("dt", { children: "Difference" }), /* @__PURE__ */ E("dd", {
|
|
3134
|
+
className: "piq-comparison__diff",
|
|
3135
|
+
children: `${l > 0 ? "+" : l < 0 ? "−" : "±"}${a(Math.abs(l))}`
|
|
3136
|
+
})] })
|
|
3137
|
+
]
|
|
3138
|
+
}),
|
|
3139
|
+
/* @__PURE__ */ D("p", {
|
|
3140
|
+
className: "piq-comparison__words",
|
|
3141
|
+
"data-direction": l > 0 ? "up" : l < 0 ? "down" : "flat",
|
|
3142
|
+
children: [/* @__PURE__ */ E(n, {
|
|
3143
|
+
name: "arrow-right",
|
|
3144
|
+
className: "piq-comparison__arrow"
|
|
3145
|
+
}), d]
|
|
3146
|
+
})
|
|
3147
|
+
]
|
|
3148
|
+
});
|
|
3149
|
+
}
|
|
3150
|
+
function tt({ title: e, logo: t, runDate: n, locale: r, sections: i = [], children: a, className: o }) {
|
|
3151
|
+
let s = C(null);
|
|
3152
|
+
y(() => {
|
|
3153
|
+
let e = null, t = null, n = () => {
|
|
3154
|
+
e = s.current?.closest("[data-theme]") ?? document.documentElement, t = e.getAttribute("data-appearance"), e.setAttribute("data-appearance", "light");
|
|
3155
|
+
}, r = () => {
|
|
3156
|
+
e &&= (t == null ? e.removeAttribute("data-appearance") : e.setAttribute("data-appearance", t), null);
|
|
3157
|
+
};
|
|
3158
|
+
return window.addEventListener("beforeprint", n), window.addEventListener("afterprint", r), () => {
|
|
3159
|
+
window.removeEventListener("beforeprint", n), window.removeEventListener("afterprint", r);
|
|
3160
|
+
};
|
|
3161
|
+
}, []);
|
|
3162
|
+
let c = n ? new Intl.DateTimeFormat(r, {
|
|
3163
|
+
dateStyle: "long",
|
|
3164
|
+
timeStyle: "short"
|
|
3165
|
+
}).format(new Date(n)) : null;
|
|
3166
|
+
return /* @__PURE__ */ D("article", {
|
|
3167
|
+
ref: s,
|
|
3168
|
+
className: `piq-print${o ? ` ${o}` : ""}`,
|
|
3169
|
+
children: [
|
|
3170
|
+
/* @__PURE__ */ D("header", {
|
|
3171
|
+
className: "piq-print__header",
|
|
3172
|
+
children: [
|
|
3173
|
+
t && /* @__PURE__ */ E("div", {
|
|
3174
|
+
className: "piq-print__logo",
|
|
3175
|
+
children: t
|
|
3176
|
+
}),
|
|
3177
|
+
/* @__PURE__ */ E("h1", {
|
|
3178
|
+
className: "piq-print__title",
|
|
3179
|
+
children: e
|
|
3180
|
+
}),
|
|
3181
|
+
c && /* @__PURE__ */ D("p", {
|
|
3182
|
+
className: "piq-print__date",
|
|
3183
|
+
children: ["Run ", /* @__PURE__ */ E("time", {
|
|
3184
|
+
dateTime: new Date(n).toISOString(),
|
|
3185
|
+
children: c
|
|
3186
|
+
})]
|
|
3187
|
+
})
|
|
3188
|
+
]
|
|
3189
|
+
}),
|
|
3190
|
+
i.map((e) => /* @__PURE__ */ D("section", {
|
|
3191
|
+
className: "piq-print__section",
|
|
3192
|
+
"aria-label": e.title,
|
|
3193
|
+
children: [/* @__PURE__ */ E("h2", {
|
|
3194
|
+
className: "piq-print__section-title",
|
|
3195
|
+
children: e.title
|
|
3196
|
+
}), e.content]
|
|
3197
|
+
}, e.id)),
|
|
3198
|
+
a
|
|
3199
|
+
]
|
|
3200
|
+
});
|
|
3201
|
+
}
|
|
3202
|
+
function nt({ label: e, groups: t = [], columns: r = [], value: i = () => 0, format: a = (e) => String(e), totalLabel: o = "Total", className: s }) {
|
|
3203
|
+
let [c, l] = w({}), [u, d] = w(t[0]?.id), f = C(null), p = (e, t) => e.reduce((e, n) => e + (Number(i(n, t)) || 0), 0), m = t.flatMap((e) => [{
|
|
3204
|
+
id: e.id,
|
|
3205
|
+
group: e
|
|
3206
|
+
}, ...c[e.id] ? e.rows.map((t) => ({
|
|
3207
|
+
id: t.id,
|
|
3208
|
+
row: t,
|
|
3209
|
+
parent: e.id
|
|
3210
|
+
})) : []]), h = (e) => {
|
|
3211
|
+
d(e), requestAnimationFrame(() => f.current?.querySelector(`[data-row="${e}"]`)?.focus());
|
|
3212
|
+
};
|
|
3213
|
+
function _(e) {
|
|
3214
|
+
let t = m.findIndex((e) => e.id === u), n = m[t];
|
|
3215
|
+
n && (e.key === "ArrowDown" && t < m.length - 1 ? (e.preventDefault(), h(m[t + 1].id)) : e.key === "ArrowUp" && t > 0 ? (e.preventDefault(), h(m[t - 1].id)) : e.key === "ArrowRight" && n.group ? (e.preventDefault(), c[n.id] ? n.group.rows[0] && h(n.group.rows[0].id) : l({
|
|
3216
|
+
...c,
|
|
3217
|
+
[n.id]: !0
|
|
3218
|
+
})) : e.key === "ArrowLeft" && (e.preventDefault(), n.group && c[n.id] ? l({
|
|
3219
|
+
...c,
|
|
3220
|
+
[n.id]: !1
|
|
3221
|
+
}) : n.parent && h(n.parent)));
|
|
3222
|
+
}
|
|
3223
|
+
let v = t.flatMap((e) => e.rows.map((e) => e.id));
|
|
3224
|
+
return /* @__PURE__ */ E("div", {
|
|
3225
|
+
className: "piq-table-wrap",
|
|
3226
|
+
children: /* @__PURE__ */ D("table", {
|
|
3227
|
+
role: "treegrid",
|
|
3228
|
+
"aria-label": e,
|
|
3229
|
+
className: `piq-table piq-pivot${s ? ` ${s}` : ""}`,
|
|
3230
|
+
children: [
|
|
3231
|
+
/* @__PURE__ */ E("thead", { children: /* @__PURE__ */ D("tr", { children: [
|
|
3232
|
+
/* @__PURE__ */ E("th", {
|
|
3233
|
+
scope: "col",
|
|
3234
|
+
children: /* @__PURE__ */ E("span", {
|
|
3235
|
+
className: "piq-visually-hidden",
|
|
3236
|
+
children: "Row"
|
|
3237
|
+
})
|
|
3238
|
+
}),
|
|
3239
|
+
r.map((e) => /* @__PURE__ */ E("th", {
|
|
3240
|
+
scope: "col",
|
|
3241
|
+
className: "piq-num",
|
|
3242
|
+
children: e.label
|
|
3243
|
+
}, e.key)),
|
|
3244
|
+
/* @__PURE__ */ E("th", {
|
|
3245
|
+
scope: "col",
|
|
3246
|
+
className: "piq-num",
|
|
3247
|
+
children: o
|
|
3248
|
+
})
|
|
3249
|
+
] }) }),
|
|
3250
|
+
/* @__PURE__ */ E("tbody", {
|
|
3251
|
+
ref: f,
|
|
3252
|
+
onKeyDown: _,
|
|
3253
|
+
children: t.map((e) => {
|
|
3254
|
+
let t = e.rows.map((e) => e.id);
|
|
3255
|
+
return /* @__PURE__ */ D(g, { children: [/* @__PURE__ */ D("tr", {
|
|
3256
|
+
"data-row": e.id,
|
|
3257
|
+
"aria-level": 1,
|
|
3258
|
+
"aria-expanded": !!c[e.id],
|
|
3259
|
+
tabIndex: u === e.id ? 0 : -1,
|
|
3260
|
+
className: "piq-pivot__group",
|
|
3261
|
+
onFocus: () => d(e.id),
|
|
3262
|
+
onClick: () => l({
|
|
3263
|
+
...c,
|
|
3264
|
+
[e.id]: !c[e.id]
|
|
3265
|
+
}),
|
|
3266
|
+
children: [
|
|
3267
|
+
/* @__PURE__ */ D("th", {
|
|
3268
|
+
scope: "row",
|
|
3269
|
+
role: "rowheader",
|
|
3270
|
+
children: [
|
|
3271
|
+
/* @__PURE__ */ E(n, {
|
|
3272
|
+
name: c[e.id] ? "chevron-down" : "chevron-right",
|
|
3273
|
+
className: "piq-pivot__toggle"
|
|
3274
|
+
}),
|
|
3275
|
+
e.label,
|
|
3276
|
+
" ",
|
|
3277
|
+
/* @__PURE__ */ E("span", {
|
|
3278
|
+
className: "piq-pivot__subtotal",
|
|
3279
|
+
children: "subtotal"
|
|
3280
|
+
})
|
|
3281
|
+
]
|
|
3282
|
+
}),
|
|
3283
|
+
r.map((e) => /* @__PURE__ */ E("td", {
|
|
3284
|
+
role: "gridcell",
|
|
3285
|
+
className: "piq-num",
|
|
3286
|
+
children: a(p(t, e.key))
|
|
3287
|
+
}, e.key)),
|
|
3288
|
+
/* @__PURE__ */ E("td", {
|
|
3289
|
+
role: "gridcell",
|
|
3290
|
+
className: "piq-num",
|
|
3291
|
+
children: a(r.reduce((e, n) => e + p(t, n.key), 0))
|
|
3292
|
+
})
|
|
3293
|
+
]
|
|
3294
|
+
}), c[e.id] && e.rows.map((e) => /* @__PURE__ */ D("tr", {
|
|
3295
|
+
"data-row": e.id,
|
|
3296
|
+
"aria-level": 2,
|
|
3297
|
+
tabIndex: u === e.id ? 0 : -1,
|
|
3298
|
+
className: "piq-pivot__row",
|
|
3299
|
+
onFocus: () => d(e.id),
|
|
3300
|
+
children: [
|
|
3301
|
+
/* @__PURE__ */ E("th", {
|
|
3302
|
+
scope: "row",
|
|
3303
|
+
role: "rowheader",
|
|
3304
|
+
className: "piq-pivot__child",
|
|
3305
|
+
children: e.label
|
|
3306
|
+
}),
|
|
3307
|
+
r.map((t) => /* @__PURE__ */ E("td", {
|
|
3308
|
+
role: "gridcell",
|
|
3309
|
+
className: "piq-num",
|
|
3310
|
+
children: a(Number(i(e.id, t.key)) || 0)
|
|
3311
|
+
}, t.key)),
|
|
3312
|
+
/* @__PURE__ */ E("td", {
|
|
3313
|
+
role: "gridcell",
|
|
3314
|
+
className: "piq-num",
|
|
3315
|
+
children: a(r.reduce((t, n) => t + (Number(i(e.id, n.key)) || 0), 0))
|
|
3316
|
+
})
|
|
3317
|
+
]
|
|
3318
|
+
}, e.id))] }, e.id);
|
|
3319
|
+
})
|
|
3320
|
+
}),
|
|
3321
|
+
/* @__PURE__ */ E("tfoot", { children: /* @__PURE__ */ D("tr", {
|
|
3322
|
+
className: "piq-pivot__total",
|
|
3323
|
+
children: [
|
|
3324
|
+
/* @__PURE__ */ E("th", {
|
|
3325
|
+
scope: "row",
|
|
3326
|
+
children: o
|
|
3327
|
+
}),
|
|
3328
|
+
r.map((e) => /* @__PURE__ */ E("td", {
|
|
3329
|
+
className: "piq-num",
|
|
3330
|
+
children: a(p(v, e.key))
|
|
3331
|
+
}, e.key)),
|
|
3332
|
+
/* @__PURE__ */ E("td", {
|
|
3333
|
+
className: "piq-num",
|
|
3334
|
+
children: a(r.reduce((e, t) => e + p(v, t.key), 0))
|
|
3335
|
+
})
|
|
3336
|
+
]
|
|
3337
|
+
}) })
|
|
3338
|
+
]
|
|
3339
|
+
})
|
|
3340
|
+
});
|
|
3341
|
+
}
|
|
3342
|
+
function rt({ measures: e = [], groupings: t = [], preview: n = () => [], onSave: a, saveLabel: s = "Save report", className: c }) {
|
|
3343
|
+
let [l, u] = w([]), [d, f] = w([]), [p, m] = w(""), [h, g] = w(!1), _ = (e, t, n) => e((e) => n ? [...e, t] : e.filter((e) => e !== t)), v = [...t.filter((e) => d.includes(e.value)), ...e.filter((e) => l.includes(e.value))], y = v.length ? n({
|
|
3344
|
+
measures: l,
|
|
3345
|
+
groupings: d
|
|
3346
|
+
}) : [];
|
|
3347
|
+
return /* @__PURE__ */ D("form", {
|
|
3348
|
+
className: `piq-report-builder${c ? ` ${c}` : ""}`,
|
|
3349
|
+
noValidate: !0,
|
|
3350
|
+
onSubmit: (e) => {
|
|
3351
|
+
e.preventDefault(), g(!0), p.trim() && a?.({
|
|
3352
|
+
name: p.trim(),
|
|
3353
|
+
measures: l,
|
|
3354
|
+
groupings: d
|
|
3355
|
+
});
|
|
3356
|
+
},
|
|
3357
|
+
children: [
|
|
3358
|
+
/* @__PURE__ */ D("div", {
|
|
3359
|
+
className: "piq-report-builder__choices",
|
|
3360
|
+
children: [/* @__PURE__ */ D("fieldset", {
|
|
3361
|
+
className: "piq-export__fields",
|
|
3362
|
+
children: [/* @__PURE__ */ E("legend", {
|
|
3363
|
+
className: "piq-field__label",
|
|
3364
|
+
children: "Measures"
|
|
3365
|
+
}), e.map((e) => /* @__PURE__ */ E(i, {
|
|
3366
|
+
label: e.label,
|
|
3367
|
+
checked: l.includes(e.value),
|
|
3368
|
+
onChange: (t) => _(u, e.value, t.target.checked)
|
|
3369
|
+
}, e.value))]
|
|
3370
|
+
}), /* @__PURE__ */ D("fieldset", {
|
|
3371
|
+
className: "piq-export__fields",
|
|
3372
|
+
children: [/* @__PURE__ */ E("legend", {
|
|
3373
|
+
className: "piq-field__label",
|
|
3374
|
+
children: "Group by"
|
|
3375
|
+
}), t.map((e) => /* @__PURE__ */ E(i, {
|
|
3376
|
+
label: e.label,
|
|
3377
|
+
checked: d.includes(e.value),
|
|
3378
|
+
onChange: (t) => _(f, e.value, t.target.checked)
|
|
3379
|
+
}, e.value))]
|
|
3380
|
+
})]
|
|
3381
|
+
}),
|
|
3382
|
+
/* @__PURE__ */ E("div", {
|
|
3383
|
+
className: "piq-table-wrap",
|
|
3384
|
+
"aria-live": "polite",
|
|
3385
|
+
children: /* @__PURE__ */ D("table", {
|
|
3386
|
+
className: "piq-table piq-report-builder__preview",
|
|
3387
|
+
children: [
|
|
3388
|
+
/* @__PURE__ */ E("caption", {
|
|
3389
|
+
className: "piq-visually-hidden",
|
|
3390
|
+
children: "Preview"
|
|
3391
|
+
}),
|
|
3392
|
+
/* @__PURE__ */ E("thead", { children: /* @__PURE__ */ E("tr", { children: v.map((e) => /* @__PURE__ */ E("th", {
|
|
3393
|
+
scope: "col",
|
|
3394
|
+
children: e.label
|
|
3395
|
+
}, e.value)) }) }),
|
|
3396
|
+
/* @__PURE__ */ E("tbody", { children: y.map((e, t) => /* @__PURE__ */ E("tr", { children: v.map((t) => /* @__PURE__ */ E("td", { children: e[t.value] }, t.value)) }, t)) })
|
|
3397
|
+
]
|
|
3398
|
+
})
|
|
3399
|
+
}),
|
|
3400
|
+
/* @__PURE__ */ E(r, {
|
|
3401
|
+
label: "Report name",
|
|
3402
|
+
required: !0,
|
|
3403
|
+
"aria-required": "true",
|
|
3404
|
+
value: p,
|
|
3405
|
+
onChange: (e) => m(e.target.value),
|
|
3406
|
+
error: h && !p.trim() ? "Enter a name for the report" : void 0
|
|
3407
|
+
}),
|
|
3408
|
+
/* @__PURE__ */ E("div", {
|
|
3409
|
+
className: "piq-wizard__actions",
|
|
3410
|
+
children: /* @__PURE__ */ E(o, {
|
|
3411
|
+
type: "submit",
|
|
3412
|
+
children: s
|
|
3413
|
+
})
|
|
3414
|
+
})
|
|
3415
|
+
]
|
|
3416
|
+
});
|
|
3417
|
+
}
|
|
3418
|
+
function it({ items: e = [], onAdd: i, onPause: a, onDelete: s, title: c = "Subscriptions", className: l }) {
|
|
3419
|
+
let [u, f] = w(!1), [p, m] = w(null), [h, g] = w({
|
|
3420
|
+
kind: "delivery",
|
|
3421
|
+
name: "",
|
|
3422
|
+
frequency: "Weekly",
|
|
3423
|
+
threshold: "",
|
|
3424
|
+
recipients: ""
|
|
3425
|
+
}), _ = b();
|
|
3426
|
+
return /* @__PURE__ */ D("section", {
|
|
3427
|
+
className: `piq-subscriptions${l ? ` ${l}` : ""}`,
|
|
3428
|
+
"aria-labelledby": `${_}-h`,
|
|
3429
|
+
children: [
|
|
3430
|
+
/* @__PURE__ */ D("div", {
|
|
3431
|
+
className: "piq-subscriptions__head",
|
|
3432
|
+
children: [/* @__PURE__ */ E("h2", {
|
|
3433
|
+
id: `${_}-h`,
|
|
3434
|
+
className: "piq-import__title",
|
|
3435
|
+
children: c
|
|
3436
|
+
}), /* @__PURE__ */ D(o, {
|
|
3437
|
+
variant: "secondary",
|
|
3438
|
+
onClick: () => f(!0),
|
|
3439
|
+
children: [/* @__PURE__ */ E(n, { name: "add" }), "Add"]
|
|
3440
|
+
})]
|
|
3441
|
+
}),
|
|
3442
|
+
/* @__PURE__ */ E("ul", {
|
|
3443
|
+
className: "piq-subscriptions__list",
|
|
3444
|
+
children: e.map((e) => /* @__PURE__ */ D("li", {
|
|
3445
|
+
className: "piq-subscriptions__item",
|
|
3446
|
+
children: [/* @__PURE__ */ D("div", {
|
|
3447
|
+
className: "piq-subscriptions__text",
|
|
3448
|
+
children: [/* @__PURE__ */ D("p", {
|
|
3449
|
+
className: "piq-subscriptions__name",
|
|
3450
|
+
children: [e.name, e.paused && /* @__PURE__ */ E("strong", {
|
|
3451
|
+
className: "piq-subscriptions__paused",
|
|
3452
|
+
children: " Paused"
|
|
3453
|
+
})]
|
|
3454
|
+
}), /* @__PURE__ */ D("p", {
|
|
3455
|
+
className: "piq-subscriptions__detail",
|
|
3456
|
+
children: [
|
|
3457
|
+
e.kind === "alert" ? `Alert when ${e.threshold}` : e.frequency,
|
|
3458
|
+
" · ",
|
|
3459
|
+
`To ${e.recipients.join(", ")}`
|
|
3460
|
+
]
|
|
3461
|
+
})]
|
|
3462
|
+
}), /* @__PURE__ */ D("div", {
|
|
3463
|
+
className: "piq-subscriptions__actions",
|
|
3464
|
+
children: [!e.paused && /* @__PURE__ */ E(o, {
|
|
3465
|
+
variant: "text",
|
|
3466
|
+
size: "sm",
|
|
3467
|
+
onClick: () => a?.(e),
|
|
3468
|
+
"aria-label": `Pause ${e.name}`,
|
|
3469
|
+
children: "Pause"
|
|
3470
|
+
}), /* @__PURE__ */ E(o, {
|
|
3471
|
+
variant: "text",
|
|
3472
|
+
size: "sm",
|
|
3473
|
+
onClick: () => m(e),
|
|
3474
|
+
"aria-label": `Delete ${e.name}`,
|
|
3475
|
+
children: /* @__PURE__ */ E(n, { name: "delete" })
|
|
3476
|
+
})]
|
|
3477
|
+
})]
|
|
3478
|
+
}, e.id))
|
|
3479
|
+
}),
|
|
3480
|
+
/* @__PURE__ */ E(t, {
|
|
3481
|
+
open: u,
|
|
3482
|
+
onClose: () => f(!1),
|
|
3483
|
+
title: "Add a subscription",
|
|
3484
|
+
children: /* @__PURE__ */ D("form", {
|
|
3485
|
+
className: "piq-quick-edit",
|
|
3486
|
+
onSubmit: (e) => {
|
|
3487
|
+
e.preventDefault();
|
|
3488
|
+
let { kind: t, name: n, frequency: r, threshold: a, recipients: o } = h;
|
|
3489
|
+
i?.({
|
|
3490
|
+
kind: t,
|
|
3491
|
+
name: n,
|
|
3492
|
+
...t === "delivery" ? { frequency: r } : { threshold: a },
|
|
3493
|
+
recipients: o.split(",").map((e) => e.trim()).filter(Boolean)
|
|
3494
|
+
}), f(!1);
|
|
3495
|
+
},
|
|
3496
|
+
children: [
|
|
3497
|
+
/* @__PURE__ */ E(d, {
|
|
3498
|
+
label: "Kind",
|
|
3499
|
+
name: `${_}-kind`,
|
|
3500
|
+
value: h.kind,
|
|
3501
|
+
onChange: (e) => g({
|
|
3502
|
+
...h,
|
|
3503
|
+
kind: e
|
|
3504
|
+
}),
|
|
3505
|
+
options: [{
|
|
3506
|
+
value: "delivery",
|
|
3507
|
+
label: "Scheduled delivery"
|
|
3508
|
+
}, {
|
|
3509
|
+
value: "alert",
|
|
3510
|
+
label: "Alert"
|
|
3511
|
+
}]
|
|
3512
|
+
}),
|
|
3513
|
+
/* @__PURE__ */ E(r, {
|
|
3514
|
+
label: "Name",
|
|
3515
|
+
value: h.name,
|
|
3516
|
+
onChange: (e) => g({
|
|
3517
|
+
...h,
|
|
3518
|
+
name: e.target.value
|
|
3519
|
+
})
|
|
3520
|
+
}),
|
|
3521
|
+
h.kind === "delivery" ? /* @__PURE__ */ E(r, {
|
|
3522
|
+
label: "Frequency",
|
|
3523
|
+
value: h.frequency,
|
|
3524
|
+
onChange: (e) => g({
|
|
3525
|
+
...h,
|
|
3526
|
+
frequency: e.target.value
|
|
3527
|
+
})
|
|
3528
|
+
}) : /* @__PURE__ */ E(r, {
|
|
3529
|
+
label: "Threshold",
|
|
3530
|
+
value: h.threshold,
|
|
3531
|
+
onChange: (e) => g({
|
|
3532
|
+
...h,
|
|
3533
|
+
threshold: e.target.value
|
|
3534
|
+
})
|
|
3535
|
+
}),
|
|
3536
|
+
/* @__PURE__ */ E(r, {
|
|
3537
|
+
label: "Recipients",
|
|
3538
|
+
hint: "Email addresses, separated by commas",
|
|
3539
|
+
value: h.recipients,
|
|
3540
|
+
onChange: (e) => g({
|
|
3541
|
+
...h,
|
|
3542
|
+
recipients: e.target.value
|
|
3543
|
+
})
|
|
3544
|
+
}),
|
|
3545
|
+
/* @__PURE__ */ D("div", {
|
|
3546
|
+
className: "piq-quick-edit__actions",
|
|
3547
|
+
children: [/* @__PURE__ */ E(o, {
|
|
3548
|
+
type: "submit",
|
|
3549
|
+
children: "Add"
|
|
3550
|
+
}), /* @__PURE__ */ E(o, {
|
|
3551
|
+
variant: "secondary",
|
|
3552
|
+
onClick: () => f(!1),
|
|
3553
|
+
children: "Cancel"
|
|
3554
|
+
})]
|
|
3555
|
+
})
|
|
3556
|
+
]
|
|
3557
|
+
})
|
|
3558
|
+
}),
|
|
3559
|
+
/* @__PURE__ */ E(Z, {
|
|
3560
|
+
open: !!p,
|
|
3561
|
+
objectName: p?.name,
|
|
3562
|
+
consequence: "Its recipients stop receiving it.",
|
|
3563
|
+
onCancel: () => m(null),
|
|
3564
|
+
onConfirm: () => {
|
|
3565
|
+
s?.(p), m(null);
|
|
3566
|
+
}
|
|
3567
|
+
})
|
|
3568
|
+
]
|
|
3569
|
+
});
|
|
3570
|
+
}
|
|
3571
|
+
//#endregion
|
|
3572
|
+
//#region src/patterns/Admin.jsx
|
|
3573
|
+
var at = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
3574
|
+
function ot({ title: e = "Members", members: i = [], roles: a = [], onInvite: s, onRoleChange: l, className: u }) {
|
|
3575
|
+
let [d, f] = w(!1), [p, m] = w(""), [h, g] = w(a[0]?.value ?? ""), [_, v] = w(!1), y = b(), x = !at.test(p.trim()), S = (e) => a.find((t) => t.value === e)?.label ?? e;
|
|
3576
|
+
return /* @__PURE__ */ D("section", {
|
|
3577
|
+
className: `piq-members${u ? ` ${u}` : ""}`,
|
|
3578
|
+
"aria-labelledby": `${y}-h`,
|
|
3579
|
+
children: [
|
|
3580
|
+
/* @__PURE__ */ D("div", {
|
|
3581
|
+
className: "piq-subscriptions__head",
|
|
3582
|
+
children: [/* @__PURE__ */ E("h2", {
|
|
3583
|
+
id: `${y}-h`,
|
|
3584
|
+
className: "piq-import__title",
|
|
3585
|
+
children: e
|
|
3586
|
+
}), /* @__PURE__ */ D(o, {
|
|
3587
|
+
onClick: () => f(!0),
|
|
3588
|
+
children: [/* @__PURE__ */ E(n, { name: "add" }), "Invite"]
|
|
3589
|
+
})]
|
|
3590
|
+
}),
|
|
3591
|
+
/* @__PURE__ */ E("div", {
|
|
3592
|
+
className: "piq-table-wrap",
|
|
3593
|
+
children: /* @__PURE__ */ D("table", {
|
|
3594
|
+
className: "piq-table",
|
|
3595
|
+
children: [
|
|
3596
|
+
/* @__PURE__ */ E("caption", {
|
|
3597
|
+
className: "piq-visually-hidden",
|
|
3598
|
+
children: e
|
|
3599
|
+
}),
|
|
3600
|
+
/* @__PURE__ */ E("thead", { children: /* @__PURE__ */ D("tr", { children: [
|
|
3601
|
+
/* @__PURE__ */ E("th", {
|
|
3602
|
+
scope: "col",
|
|
3603
|
+
children: "Name"
|
|
3604
|
+
}),
|
|
3605
|
+
/* @__PURE__ */ E("th", {
|
|
3606
|
+
scope: "col",
|
|
3607
|
+
children: "Email"
|
|
3608
|
+
}),
|
|
3609
|
+
/* @__PURE__ */ E("th", {
|
|
3610
|
+
scope: "col",
|
|
3611
|
+
children: "Role"
|
|
3612
|
+
})
|
|
3613
|
+
] }) }),
|
|
3614
|
+
/* @__PURE__ */ E("tbody", { children: i.map((e) => /* @__PURE__ */ D("tr", { children: [
|
|
3615
|
+
/* @__PURE__ */ E("th", {
|
|
3616
|
+
scope: "row",
|
|
3617
|
+
children: e.name
|
|
3618
|
+
}),
|
|
3619
|
+
/* @__PURE__ */ E("td", { children: e.email }),
|
|
3620
|
+
/* @__PURE__ */ D("td", {
|
|
3621
|
+
className: "piq-members__role",
|
|
3622
|
+
children: [/* @__PURE__ */ E("span", {
|
|
3623
|
+
className: "piq-members__current",
|
|
3624
|
+
children: S(e.role)
|
|
3625
|
+
}), /* @__PURE__ */ E(c, {
|
|
3626
|
+
label: /* @__PURE__ */ E("span", {
|
|
3627
|
+
className: "piq-visually-hidden",
|
|
3628
|
+
children: `Change role for ${e.name}`
|
|
3629
|
+
}),
|
|
3630
|
+
className: "piq-members__select",
|
|
3631
|
+
value: e.role,
|
|
3632
|
+
options: a,
|
|
3633
|
+
onChange: (t) => l?.(e, t.target.value)
|
|
3634
|
+
})]
|
|
3635
|
+
})
|
|
3636
|
+
] }, e.id)) })
|
|
3637
|
+
]
|
|
3638
|
+
})
|
|
3639
|
+
}),
|
|
3640
|
+
/* @__PURE__ */ E(t, {
|
|
3641
|
+
open: d,
|
|
3642
|
+
onClose: () => f(!1),
|
|
3643
|
+
title: "Invite a member",
|
|
3644
|
+
children: /* @__PURE__ */ D("form", {
|
|
3645
|
+
className: "piq-quick-edit",
|
|
3646
|
+
noValidate: !0,
|
|
3647
|
+
onSubmit: (e) => {
|
|
3648
|
+
e.preventDefault(), v(!0), !x && (s?.({
|
|
3649
|
+
email: p.trim(),
|
|
3650
|
+
role: h
|
|
3651
|
+
}), f(!1), m(""), v(!1));
|
|
3652
|
+
},
|
|
3653
|
+
children: [
|
|
3654
|
+
/* @__PURE__ */ E(r, {
|
|
3655
|
+
label: "Email address",
|
|
3656
|
+
type: "email",
|
|
3657
|
+
autoComplete: "email",
|
|
3658
|
+
value: p,
|
|
3659
|
+
onChange: (e) => m(e.target.value),
|
|
3660
|
+
error: _ && x ? "Enter an email address, like name@example.com" : void 0
|
|
3661
|
+
}),
|
|
3662
|
+
/* @__PURE__ */ E(c, {
|
|
3663
|
+
label: "Role",
|
|
3664
|
+
value: h,
|
|
3665
|
+
options: a,
|
|
3666
|
+
onChange: (e) => g(e.target.value)
|
|
3667
|
+
}),
|
|
3668
|
+
/* @__PURE__ */ D("div", {
|
|
3669
|
+
className: "piq-quick-edit__actions",
|
|
3670
|
+
children: [/* @__PURE__ */ E(o, {
|
|
3671
|
+
type: "submit",
|
|
3672
|
+
children: "Send invite"
|
|
3673
|
+
}), /* @__PURE__ */ E(o, {
|
|
3674
|
+
variant: "secondary",
|
|
3675
|
+
onClick: () => f(!1),
|
|
3676
|
+
children: "Cancel"
|
|
3677
|
+
})]
|
|
3678
|
+
})
|
|
3679
|
+
]
|
|
3680
|
+
})
|
|
3681
|
+
})
|
|
3682
|
+
]
|
|
3683
|
+
});
|
|
3684
|
+
}
|
|
3685
|
+
function st({ title: e = "Permissions", roles: t = [], permissions: r = [], has: i = () => !1, yes: a = "Yes", no: o = "No", className: s }) {
|
|
3686
|
+
return /* @__PURE__ */ E("div", {
|
|
3687
|
+
className: "piq-table-wrap",
|
|
3688
|
+
children: /* @__PURE__ */ D("table", {
|
|
3689
|
+
className: `piq-table piq-matrix${s ? ` ${s}` : ""}`,
|
|
3690
|
+
children: [
|
|
3691
|
+
/* @__PURE__ */ E("caption", {
|
|
3692
|
+
className: "piq-matrix__caption",
|
|
3693
|
+
children: e
|
|
3694
|
+
}),
|
|
3695
|
+
/* @__PURE__ */ E("thead", { children: /* @__PURE__ */ D("tr", { children: [/* @__PURE__ */ E("th", {
|
|
3696
|
+
scope: "col",
|
|
3697
|
+
children: "Permission"
|
|
3698
|
+
}), t.map((e) => /* @__PURE__ */ E("th", {
|
|
3699
|
+
scope: "col",
|
|
3700
|
+
children: e.label
|
|
3701
|
+
}, e.value))] }) }),
|
|
3702
|
+
/* @__PURE__ */ E("tbody", { children: r.map((e) => /* @__PURE__ */ D("tr", { children: [/* @__PURE__ */ E("th", {
|
|
3703
|
+
scope: "row",
|
|
3704
|
+
children: e.label
|
|
3705
|
+
}), t.map((t) => {
|
|
3706
|
+
let r = i(t.value, e.value);
|
|
3707
|
+
return /* @__PURE__ */ D("td", {
|
|
3708
|
+
"data-on": r || void 0,
|
|
3709
|
+
children: [/* @__PURE__ */ E(n, { name: r ? "check" : "close" }), r ? a : o]
|
|
3710
|
+
}, t.value);
|
|
3711
|
+
})] }, e.value)) })
|
|
3712
|
+
]
|
|
3713
|
+
})
|
|
3714
|
+
});
|
|
3715
|
+
}
|
|
3716
|
+
function ct({ title: e = "Audit log", entries: t = [], people: n = [], actions: r = [], filters: i = [], onFilter: a, onRemoveFilter: s, onClearFilters: l, locale: u, className: d }) {
|
|
3717
|
+
let [f, m] = w(""), [h, g] = w(""), [_, v] = w({
|
|
3718
|
+
from: "",
|
|
3719
|
+
to: ""
|
|
3720
|
+
}), y = b(), x = new Intl.DateTimeFormat(u, {
|
|
3721
|
+
dateStyle: "medium",
|
|
3722
|
+
timeStyle: "short"
|
|
3723
|
+
});
|
|
3724
|
+
return /* @__PURE__ */ D("section", {
|
|
3725
|
+
className: `piq-audit-log${d ? ` ${d}` : ""}`,
|
|
3726
|
+
"aria-labelledby": `${y}-h`,
|
|
3727
|
+
children: [
|
|
3728
|
+
/* @__PURE__ */ E("h2", {
|
|
3729
|
+
id: `${y}-h`,
|
|
3730
|
+
className: "piq-import__title",
|
|
3731
|
+
children: e
|
|
3732
|
+
}),
|
|
3733
|
+
/* @__PURE__ */ D("form", {
|
|
3734
|
+
className: "piq-audit-log__filters",
|
|
3735
|
+
onSubmit: (e) => {
|
|
3736
|
+
e.preventDefault(), a?.({
|
|
3737
|
+
person: f || null,
|
|
3738
|
+
action: h || null,
|
|
3739
|
+
from: _.from || null,
|
|
3740
|
+
to: _.to || null
|
|
3741
|
+
});
|
|
3742
|
+
},
|
|
3743
|
+
children: [
|
|
3744
|
+
/* @__PURE__ */ E(c, {
|
|
3745
|
+
label: "Person",
|
|
3746
|
+
placeholder: "Anyone",
|
|
3747
|
+
value: f,
|
|
3748
|
+
options: n,
|
|
3749
|
+
onChange: (e) => m(e.target.value)
|
|
3750
|
+
}),
|
|
3751
|
+
/* @__PURE__ */ E(c, {
|
|
3752
|
+
label: "Action",
|
|
3753
|
+
placeholder: "Any action",
|
|
3754
|
+
value: h,
|
|
3755
|
+
options: r,
|
|
3756
|
+
onChange: (e) => g(e.target.value)
|
|
3757
|
+
}),
|
|
3758
|
+
/* @__PURE__ */ E(p, {
|
|
3759
|
+
label: "Date",
|
|
3760
|
+
from: _.from,
|
|
3761
|
+
to: _.to,
|
|
3762
|
+
onChange: v
|
|
3763
|
+
}),
|
|
3764
|
+
/* @__PURE__ */ E(o, {
|
|
3765
|
+
type: "submit",
|
|
3766
|
+
variant: "secondary",
|
|
3767
|
+
children: "Filter"
|
|
3768
|
+
})
|
|
3769
|
+
]
|
|
3770
|
+
}),
|
|
3771
|
+
/* @__PURE__ */ E(ae, {
|
|
3772
|
+
filters: i,
|
|
3773
|
+
onRemoveFilter: s,
|
|
3774
|
+
onClearAll: l
|
|
3775
|
+
}),
|
|
3776
|
+
/* @__PURE__ */ E("div", {
|
|
3777
|
+
className: "piq-table-wrap",
|
|
3778
|
+
children: /* @__PURE__ */ D("table", {
|
|
3779
|
+
className: "piq-table piq-audit-log__table",
|
|
3780
|
+
children: [
|
|
3781
|
+
/* @__PURE__ */ E("caption", {
|
|
3782
|
+
className: "piq-visually-hidden",
|
|
3783
|
+
children: e
|
|
3784
|
+
}),
|
|
3785
|
+
/* @__PURE__ */ E("thead", { children: /* @__PURE__ */ D("tr", { children: [
|
|
3786
|
+
/* @__PURE__ */ E("th", {
|
|
3787
|
+
scope: "col",
|
|
3788
|
+
children: "When"
|
|
3789
|
+
}),
|
|
3790
|
+
/* @__PURE__ */ E("th", {
|
|
3791
|
+
scope: "col",
|
|
3792
|
+
children: "Who"
|
|
3793
|
+
}),
|
|
3794
|
+
/* @__PURE__ */ E("th", {
|
|
3795
|
+
scope: "col",
|
|
3796
|
+
children: "What"
|
|
3797
|
+
}),
|
|
3798
|
+
/* @__PURE__ */ E("th", {
|
|
3799
|
+
scope: "col",
|
|
3800
|
+
children: "Before"
|
|
3801
|
+
}),
|
|
3802
|
+
/* @__PURE__ */ E("th", {
|
|
3803
|
+
scope: "col",
|
|
3804
|
+
children: "After"
|
|
3805
|
+
})
|
|
3806
|
+
] }) }),
|
|
3807
|
+
/* @__PURE__ */ E("tbody", { children: t.map((e) => /* @__PURE__ */ D("tr", { children: [
|
|
3808
|
+
/* @__PURE__ */ E("td", { children: /* @__PURE__ */ E("time", {
|
|
3809
|
+
dateTime: new Date(e.time).toISOString(),
|
|
3810
|
+
children: x.format(new Date(e.time))
|
|
3811
|
+
}) }),
|
|
3812
|
+
/* @__PURE__ */ E("td", { children: e.actor }),
|
|
3813
|
+
/* @__PURE__ */ E("td", { children: e.action }),
|
|
3814
|
+
/* @__PURE__ */ E("td", { children: e.before ?? "—" }),
|
|
3815
|
+
/* @__PURE__ */ E("td", { children: e.after ?? "—" })
|
|
3816
|
+
] }, e.id)) })
|
|
3817
|
+
]
|
|
3818
|
+
})
|
|
3819
|
+
})
|
|
3820
|
+
]
|
|
3821
|
+
});
|
|
3822
|
+
}
|
|
3823
|
+
//#endregion
|
|
3824
|
+
//#region src/patterns/Notifications.jsx
|
|
3825
|
+
function lt({ notifications: e = [], onMarkRead: t, onMarkAllRead: r, preferences: i, onPreferenceChange: a, label: s = "Notifications", className: c }) {
|
|
3826
|
+
let [d, f] = w(!1), p = e.filter((e) => !e.read).length;
|
|
3827
|
+
return /* @__PURE__ */ D("div", {
|
|
3828
|
+
className: `piq-notifications${c ? ` ${c}` : ""}`,
|
|
3829
|
+
children: [/* @__PURE__ */ E(o, {
|
|
3830
|
+
variant: "text",
|
|
3831
|
+
"aria-label": p ? `${s}, ${p} unread` : s,
|
|
3832
|
+
"aria-haspopup": "dialog",
|
|
3833
|
+
"aria-expanded": d,
|
|
3834
|
+
badge: p || void 0,
|
|
3835
|
+
onClick: () => f(!0),
|
|
3836
|
+
children: /* @__PURE__ */ E(n, { name: "info" })
|
|
3837
|
+
}), /* @__PURE__ */ D(u, {
|
|
3838
|
+
open: d,
|
|
3839
|
+
onClose: () => f(!1),
|
|
3840
|
+
title: s,
|
|
3841
|
+
side: "end",
|
|
3842
|
+
children: [
|
|
3843
|
+
p > 0 && /* @__PURE__ */ E(o, {
|
|
3844
|
+
variant: "secondary",
|
|
3845
|
+
size: "sm",
|
|
3846
|
+
onClick: () => r?.(),
|
|
3847
|
+
children: "Mark all as read"
|
|
3848
|
+
}),
|
|
3849
|
+
/* @__PURE__ */ E("ul", {
|
|
3850
|
+
className: "piq-notifications__list",
|
|
3851
|
+
children: e.map((e) => /* @__PURE__ */ D("li", {
|
|
3852
|
+
className: "piq-notifications__item",
|
|
3853
|
+
"data-read": e.read || void 0,
|
|
3854
|
+
children: [
|
|
3855
|
+
/* @__PURE__ */ E("span", {
|
|
3856
|
+
className: "piq-notifications__state",
|
|
3857
|
+
children: e.read ? "Read" : "Unread"
|
|
3858
|
+
}),
|
|
3859
|
+
/* @__PURE__ */ E("a", {
|
|
3860
|
+
href: e.href,
|
|
3861
|
+
className: "piq-notifications__link",
|
|
3862
|
+
children: e.title
|
|
3863
|
+
}),
|
|
3864
|
+
!e.read && /* @__PURE__ */ D(o, {
|
|
3865
|
+
variant: "text",
|
|
3866
|
+
size: "sm",
|
|
3867
|
+
onClick: () => t?.(e),
|
|
3868
|
+
children: ["Mark as read", /* @__PURE__ */ E("span", {
|
|
3869
|
+
className: "piq-visually-hidden",
|
|
3870
|
+
children: `: ${e.title}`
|
|
3871
|
+
})]
|
|
3872
|
+
})
|
|
3873
|
+
]
|
|
3874
|
+
}, e.id))
|
|
3875
|
+
}),
|
|
3876
|
+
i && /* @__PURE__ */ E("div", {
|
|
3877
|
+
className: "piq-table-wrap",
|
|
3878
|
+
children: /* @__PURE__ */ D("table", {
|
|
3879
|
+
className: "piq-table piq-notifications__prefs",
|
|
3880
|
+
children: [
|
|
3881
|
+
/* @__PURE__ */ E("caption", {
|
|
3882
|
+
className: "piq-matrix__caption",
|
|
3883
|
+
children: "Notify me by"
|
|
3884
|
+
}),
|
|
3885
|
+
/* @__PURE__ */ E("thead", { children: /* @__PURE__ */ D("tr", { children: [/* @__PURE__ */ E("th", {
|
|
3886
|
+
scope: "col",
|
|
3887
|
+
children: "Notification"
|
|
3888
|
+
}), i.channels.map((e) => /* @__PURE__ */ E("th", {
|
|
3889
|
+
scope: "col",
|
|
3890
|
+
children: e.label
|
|
3891
|
+
}, e.value))] }) }),
|
|
3892
|
+
/* @__PURE__ */ E("tbody", { children: i.kinds.map((e) => /* @__PURE__ */ D("tr", { children: [/* @__PURE__ */ E("th", {
|
|
3893
|
+
scope: "row",
|
|
3894
|
+
children: e.label
|
|
3895
|
+
}), i.channels.map((t) => /* @__PURE__ */ E("td", { children: /* @__PURE__ */ E(l, {
|
|
3896
|
+
label: /* @__PURE__ */ E("span", {
|
|
3897
|
+
className: "piq-visually-hidden",
|
|
3898
|
+
children: `${t.label} for ${e.label}`
|
|
3899
|
+
}),
|
|
3900
|
+
checked: !!i.value?.[e.value]?.[t.value],
|
|
3901
|
+
onChange: (n) => a?.(e.value, t.value, n.target.checked)
|
|
3902
|
+
}) }, t.value))] }, e.value)) })
|
|
3903
|
+
]
|
|
3904
|
+
})
|
|
3905
|
+
})
|
|
3906
|
+
]
|
|
3907
|
+
})]
|
|
3908
|
+
});
|
|
3909
|
+
}
|
|
3910
|
+
function ut({ title: e = "Integrations", items: t = [], onConnect: n, onDisconnect: r, className: i }) {
|
|
3911
|
+
return /* @__PURE__ */ E("section", {
|
|
3912
|
+
className: `piq-integrations${i ? ` ${i}` : ""}`,
|
|
3913
|
+
"aria-label": e,
|
|
3914
|
+
children: /* @__PURE__ */ E("ul", {
|
|
3915
|
+
className: "piq-integrations__list",
|
|
3916
|
+
children: t.map((e) => /* @__PURE__ */ D("li", {
|
|
3917
|
+
className: "piq-integrations__item",
|
|
3918
|
+
children: [
|
|
3919
|
+
/* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("p", {
|
|
3920
|
+
className: "piq-subscriptions__name",
|
|
3921
|
+
children: e.name
|
|
3922
|
+
}), e.description && /* @__PURE__ */ E("p", {
|
|
3923
|
+
className: "piq-subscriptions__detail",
|
|
3924
|
+
children: e.description
|
|
3925
|
+
})] }),
|
|
3926
|
+
/* @__PURE__ */ E("strong", {
|
|
3927
|
+
className: "piq-integrations__status",
|
|
3928
|
+
"data-connected": e.connected || void 0,
|
|
3929
|
+
children: e.connected ? "Connected" : "Not connected"
|
|
3930
|
+
}),
|
|
3931
|
+
e.connected ? /* @__PURE__ */ E(o, {
|
|
3932
|
+
variant: "secondary",
|
|
3933
|
+
size: "sm",
|
|
3934
|
+
"aria-label": `Disconnect ${e.name}`,
|
|
3935
|
+
onClick: () => r?.(e),
|
|
3936
|
+
children: "Disconnect"
|
|
3937
|
+
}) : /* @__PURE__ */ E(o, {
|
|
3938
|
+
size: "sm",
|
|
3939
|
+
"aria-label": `Connect ${e.name}`,
|
|
3940
|
+
onClick: () => n?.(e),
|
|
3941
|
+
children: "Connect"
|
|
3942
|
+
})
|
|
3943
|
+
]
|
|
3944
|
+
}, e.id))
|
|
3945
|
+
})
|
|
3946
|
+
});
|
|
3947
|
+
}
|
|
3948
|
+
function dt({ title: e = "API keys", keys: t = [], created: r, onCreate: i, onCreatedClose: a, onRevoke: s, className: c }) {
|
|
3949
|
+
let [l, u] = w(!1), [d, f] = w(null);
|
|
3950
|
+
return /* @__PURE__ */ D("section", {
|
|
3951
|
+
className: `piq-api-keys${c ? ` ${c}` : ""}`,
|
|
3952
|
+
"aria-label": e,
|
|
3953
|
+
children: [
|
|
3954
|
+
/* @__PURE__ */ D("div", {
|
|
3955
|
+
className: "piq-subscriptions__head",
|
|
3956
|
+
children: [/* @__PURE__ */ E("h2", {
|
|
3957
|
+
className: "piq-import__title",
|
|
3958
|
+
children: e
|
|
3959
|
+
}), /* @__PURE__ */ D(o, {
|
|
3960
|
+
onClick: () => i?.(),
|
|
3961
|
+
children: [/* @__PURE__ */ E(n, { name: "add" }), "Create a key"]
|
|
3962
|
+
})]
|
|
3963
|
+
}),
|
|
3964
|
+
r && /* @__PURE__ */ D("div", {
|
|
3965
|
+
className: "piq-api-keys__created",
|
|
3966
|
+
role: "status",
|
|
3967
|
+
children: [
|
|
3968
|
+
/* @__PURE__ */ D("p", { children: [/* @__PURE__ */ E("strong", { children: r.name }), ": copy this key now. You will not be able to see it again."] }),
|
|
3969
|
+
/* @__PURE__ */ E("code", {
|
|
3970
|
+
className: "piq-api-keys__secret",
|
|
3971
|
+
children: r.secret
|
|
3972
|
+
}),
|
|
3973
|
+
/* @__PURE__ */ D("div", {
|
|
3974
|
+
className: "piq-quick-edit__actions",
|
|
3975
|
+
children: [/* @__PURE__ */ D(o, {
|
|
3976
|
+
variant: "secondary",
|
|
3977
|
+
onClick: async () => {
|
|
3978
|
+
await navigator.clipboard?.writeText(r.secret), u(!0);
|
|
3979
|
+
},
|
|
3980
|
+
children: [/* @__PURE__ */ E(n, { name: "copy" }), l ? "Copied" : "Copy key"]
|
|
3981
|
+
}), /* @__PURE__ */ E(o, {
|
|
3982
|
+
variant: "text",
|
|
3983
|
+
onClick: () => {
|
|
3984
|
+
u(!1), a?.();
|
|
3985
|
+
},
|
|
3986
|
+
children: "Done"
|
|
3987
|
+
})]
|
|
3988
|
+
})
|
|
3989
|
+
]
|
|
3990
|
+
}),
|
|
3991
|
+
/* @__PURE__ */ E("ul", {
|
|
3992
|
+
className: "piq-integrations__list",
|
|
3993
|
+
children: t.map((e) => /* @__PURE__ */ D("li", {
|
|
3994
|
+
className: "piq-integrations__item",
|
|
3995
|
+
children: [/* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("p", {
|
|
3996
|
+
className: "piq-subscriptions__name",
|
|
3997
|
+
children: e.name
|
|
3998
|
+
}), /* @__PURE__ */ E("code", {
|
|
3999
|
+
className: "piq-api-keys__masked",
|
|
4000
|
+
"aria-label": `Key ending ${e.last4}`,
|
|
4001
|
+
children: `•••• •••• •••• ${e.last4}`
|
|
4002
|
+
})] }), /* @__PURE__ */ E(o, {
|
|
4003
|
+
variant: "text",
|
|
4004
|
+
size: "sm",
|
|
4005
|
+
"aria-label": `Revoke ${e.name}`,
|
|
4006
|
+
onClick: () => f(e),
|
|
4007
|
+
children: "Revoke"
|
|
4008
|
+
})]
|
|
4009
|
+
}, e.id))
|
|
4010
|
+
}),
|
|
4011
|
+
/* @__PURE__ */ E(Z, {
|
|
4012
|
+
open: !!d,
|
|
4013
|
+
objectName: d?.name,
|
|
4014
|
+
title: d ? `Revoke ${d.name}?` : "",
|
|
4015
|
+
confirmLabel: "Revoke",
|
|
4016
|
+
consequence: "Anything using this key stops working at once.",
|
|
4017
|
+
onCancel: () => f(null),
|
|
4018
|
+
onConfirm: () => {
|
|
4019
|
+
s?.(d), f(null);
|
|
4020
|
+
}
|
|
4021
|
+
})
|
|
4022
|
+
]
|
|
4023
|
+
});
|
|
4024
|
+
}
|
|
4025
|
+
//#endregion
|
|
4026
|
+
//#region src/patterns/Home.jsx
|
|
4027
|
+
function ft({ list: e }) {
|
|
4028
|
+
let t = b();
|
|
4029
|
+
return /* @__PURE__ */ D("section", {
|
|
4030
|
+
className: "piq-home__list",
|
|
4031
|
+
"aria-labelledby": t,
|
|
4032
|
+
children: [/* @__PURE__ */ E("h2", {
|
|
4033
|
+
id: t,
|
|
4034
|
+
className: "piq-home__heading",
|
|
4035
|
+
children: e.title
|
|
4036
|
+
}), e.items?.length ? /* @__PURE__ */ E("ul", {
|
|
4037
|
+
className: "piq-home__items",
|
|
4038
|
+
children: e.items.map((e) => /* @__PURE__ */ D("li", { children: [/* @__PURE__ */ E("a", {
|
|
4039
|
+
href: e.href,
|
|
4040
|
+
children: e.label
|
|
4041
|
+
}), e.meta && /* @__PURE__ */ E("span", {
|
|
4042
|
+
className: "piq-home__meta",
|
|
4043
|
+
children: e.meta
|
|
4044
|
+
})] }, e.id))
|
|
4045
|
+
}) : /* @__PURE__ */ E("p", {
|
|
4046
|
+
className: "piq-home__empty",
|
|
4047
|
+
children: e.emptyText ?? "Nothing here yet."
|
|
4048
|
+
})]
|
|
4049
|
+
});
|
|
4050
|
+
}
|
|
4051
|
+
function pt({ title: e = "Home", tiles: t = [], assigned: n, recent: r, children: i, className: a }) {
|
|
4052
|
+
return /* @__PURE__ */ D("div", {
|
|
4053
|
+
className: `piq-home${a ? ` ${a}` : ""}`,
|
|
4054
|
+
children: [
|
|
4055
|
+
/* @__PURE__ */ E(q, { title: e }),
|
|
4056
|
+
t.length > 0 && /* @__PURE__ */ E("div", {
|
|
4057
|
+
className: "piq-dashboard__tiles piq-home__tiles",
|
|
4058
|
+
children: t
|
|
4059
|
+
}),
|
|
4060
|
+
/* @__PURE__ */ D("div", {
|
|
4061
|
+
className: "piq-home__lists",
|
|
4062
|
+
children: [n && /* @__PURE__ */ E(ft, { list: n }), r && /* @__PURE__ */ E(ft, { list: r })]
|
|
4063
|
+
}),
|
|
4064
|
+
i
|
|
4065
|
+
]
|
|
4066
|
+
});
|
|
4067
|
+
}
|
|
4068
|
+
function mt({ recent: e = [], results: r = [], onSearch: i, onSelect: a, buttonLabel: s = "Search", placeholder: c = "Search records and actions", recentLabel: l = "Recent", emptyLabel: u = "No results", className: d }) {
|
|
4069
|
+
let [f, p] = w(!1), [m, h] = w(""), [g, _] = w(0), v = C(null), x = b(), S = m.trim() ? r : e.length ? [{
|
|
4070
|
+
label: l,
|
|
4071
|
+
items: e
|
|
4072
|
+
}] : [], T = S.flatMap((e) => e.items);
|
|
4073
|
+
y(() => {
|
|
4074
|
+
let e = (e) => {
|
|
4075
|
+
(e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "k" && (e.preventDefault(), p(!0));
|
|
4076
|
+
};
|
|
4077
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
4078
|
+
}, []), y(() => {
|
|
4079
|
+
f || (h(""), _(0));
|
|
4080
|
+
}, [f]);
|
|
4081
|
+
function O(e) {
|
|
4082
|
+
if (e.key === "ArrowDown") e.preventDefault(), _((e) => Math.min(e + 1, T.length - 1));
|
|
4083
|
+
else if (e.key === "ArrowUp") e.preventDefault(), _((e) => Math.max(e - 1, 0));
|
|
4084
|
+
else if (e.key === "Enter") {
|
|
4085
|
+
e.preventDefault();
|
|
4086
|
+
let t = T[g];
|
|
4087
|
+
t && (p(!1), a?.(t));
|
|
4088
|
+
}
|
|
4089
|
+
}
|
|
4090
|
+
let k = -1;
|
|
4091
|
+
return /* @__PURE__ */ D("div", {
|
|
4092
|
+
className: `piq-palette${d ? ` ${d}` : ""}`,
|
|
4093
|
+
children: [/* @__PURE__ */ D(o, {
|
|
4094
|
+
variant: "secondary",
|
|
4095
|
+
"aria-haspopup": "dialog",
|
|
4096
|
+
"aria-keyshortcuts": "Control+K Meta+K",
|
|
4097
|
+
onClick: () => p(!0),
|
|
4098
|
+
children: [
|
|
4099
|
+
/* @__PURE__ */ E(n, { name: "search" }),
|
|
4100
|
+
s,
|
|
4101
|
+
/* @__PURE__ */ E("kbd", {
|
|
4102
|
+
className: "piq-palette__kbd",
|
|
4103
|
+
"aria-hidden": "true",
|
|
4104
|
+
children: "⌘K"
|
|
4105
|
+
})
|
|
4106
|
+
]
|
|
4107
|
+
}), /* @__PURE__ */ D(t, {
|
|
4108
|
+
open: f,
|
|
4109
|
+
onClose: () => p(!1),
|
|
4110
|
+
title: s,
|
|
4111
|
+
initialFocus: v,
|
|
4112
|
+
className: "piq-palette__dialog",
|
|
4113
|
+
children: [
|
|
4114
|
+
/* @__PURE__ */ E("input", {
|
|
4115
|
+
ref: v,
|
|
4116
|
+
type: "text",
|
|
4117
|
+
role: "combobox",
|
|
4118
|
+
"aria-label": c,
|
|
4119
|
+
placeholder: c,
|
|
4120
|
+
className: "piq-field__input",
|
|
4121
|
+
autoComplete: "off",
|
|
4122
|
+
"aria-expanded": T.length > 0,
|
|
4123
|
+
"aria-controls": `${x}-list`,
|
|
4124
|
+
"aria-autocomplete": "list",
|
|
4125
|
+
"aria-activedescendant": T[g] ? `${x}-${T[g].id}` : void 0,
|
|
4126
|
+
value: m,
|
|
4127
|
+
onChange: (e) => {
|
|
4128
|
+
h(e.target.value), _(0), i?.(e.target.value);
|
|
4129
|
+
},
|
|
4130
|
+
onKeyDown: O
|
|
4131
|
+
}),
|
|
4132
|
+
/* @__PURE__ */ E("div", {
|
|
4133
|
+
id: `${x}-list`,
|
|
4134
|
+
role: "listbox",
|
|
4135
|
+
"aria-label": "Results",
|
|
4136
|
+
className: "piq-palette__results",
|
|
4137
|
+
children: S.map((e) => /* @__PURE__ */ D("div", {
|
|
4138
|
+
role: "group",
|
|
4139
|
+
"aria-labelledby": `${x}-${e.label}-g`,
|
|
4140
|
+
className: "piq-palette__group",
|
|
4141
|
+
children: [/* @__PURE__ */ E("p", {
|
|
4142
|
+
id: `${x}-${e.label}-g`,
|
|
4143
|
+
className: "piq-palette__group-label",
|
|
4144
|
+
role: "presentation",
|
|
4145
|
+
children: e.label
|
|
4146
|
+
}), e.items.map((e) => {
|
|
4147
|
+
k++;
|
|
4148
|
+
let t = k;
|
|
4149
|
+
return /* @__PURE__ */ E("div", {
|
|
4150
|
+
id: `${x}-${e.id}`,
|
|
4151
|
+
role: "option",
|
|
4152
|
+
"aria-selected": t === g,
|
|
4153
|
+
className: `piq-menu__item${t === g ? " is-hover" : ""}`,
|
|
4154
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
4155
|
+
onClick: () => {
|
|
4156
|
+
p(!1), a?.(e);
|
|
4157
|
+
},
|
|
4158
|
+
children: e.label
|
|
4159
|
+
}, e.id);
|
|
4160
|
+
})]
|
|
4161
|
+
}, e.label))
|
|
4162
|
+
}),
|
|
4163
|
+
m.trim() && !T.length && /* @__PURE__ */ E("p", {
|
|
4164
|
+
role: "status",
|
|
4165
|
+
className: "piq-workspace__empty",
|
|
4166
|
+
children: u
|
|
4167
|
+
})
|
|
4168
|
+
]
|
|
4169
|
+
})]
|
|
4170
|
+
});
|
|
4171
|
+
}
|
|
4172
|
+
function ht({ items: e = [], label: t = "Actions", children: n }) {
|
|
4173
|
+
let [r, i] = w(null), [a, o] = w(0), s = C(null), c = C(null);
|
|
4174
|
+
y(() => {
|
|
4175
|
+
r && s.current?.querySelectorAll("[role=\"menuitem\"]")[a]?.focus();
|
|
4176
|
+
}, [r, a]), y(() => {
|
|
4177
|
+
if (!r) return;
|
|
4178
|
+
let e = (e) => {
|
|
4179
|
+
s.current?.contains(e.target) || i(null);
|
|
4180
|
+
};
|
|
4181
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
4182
|
+
}, [r]);
|
|
4183
|
+
let l = (e, t) => {
|
|
4184
|
+
o(0), i({
|
|
4185
|
+
x: e,
|
|
4186
|
+
y: t
|
|
4187
|
+
});
|
|
4188
|
+
}, u = () => {
|
|
4189
|
+
i(null), c.current?.focus();
|
|
4190
|
+
}, d = _(n, {
|
|
4191
|
+
ref: c,
|
|
4192
|
+
"aria-haspopup": "menu",
|
|
4193
|
+
onContextMenu: (e) => {
|
|
4194
|
+
e.preventDefault(), c.current = e.currentTarget, l(e.clientX, e.clientY);
|
|
4195
|
+
},
|
|
4196
|
+
onKeyDown: (e) => {
|
|
4197
|
+
if (n.props.onKeyDown?.(e), e.shiftKey && e.key === "F10" || e.key === "ContextMenu") {
|
|
4198
|
+
e.preventDefault(), c.current = e.currentTarget;
|
|
4199
|
+
let t = e.currentTarget.getBoundingClientRect();
|
|
4200
|
+
l(t.left, t.bottom);
|
|
4201
|
+
}
|
|
4202
|
+
}
|
|
4203
|
+
});
|
|
4204
|
+
function f(t) {
|
|
4205
|
+
t.key === "ArrowDown" ? (t.preventDefault(), o((t) => (t + 1) % e.length)) : t.key === "ArrowUp" ? (t.preventDefault(), o((t) => (t - 1 + e.length) % e.length)) : t.key === "Home" ? (t.preventDefault(), o(0)) : t.key === "End" ? (t.preventDefault(), o(e.length - 1)) : (t.key === "Escape" || t.key === "Tab") && (t.preventDefault(), u());
|
|
4206
|
+
}
|
|
4207
|
+
return /* @__PURE__ */ D(T, { children: [d, r && /* @__PURE__ */ E("ul", {
|
|
4208
|
+
ref: s,
|
|
4209
|
+
role: "menu",
|
|
4210
|
+
"aria-label": t,
|
|
4211
|
+
className: "piq-menu piq-context-menu",
|
|
4212
|
+
style: {
|
|
4213
|
+
insetInlineStart: `${r.x}px`,
|
|
4214
|
+
insetBlockStart: `${r.y}px`
|
|
4215
|
+
},
|
|
4216
|
+
onKeyDown: f,
|
|
4217
|
+
children: e.map((e, t) => /* @__PURE__ */ E("li", {
|
|
4218
|
+
role: "none",
|
|
4219
|
+
children: /* @__PURE__ */ E("button", {
|
|
4220
|
+
type: "button",
|
|
4221
|
+
role: "menuitem",
|
|
4222
|
+
tabIndex: -1,
|
|
4223
|
+
className: `piq-menu__item${t === a ? " is-hover" : ""}`,
|
|
4224
|
+
onClick: () => {
|
|
4225
|
+
u(), e.onSelect?.();
|
|
4226
|
+
},
|
|
4227
|
+
children: e.label
|
|
4228
|
+
})
|
|
4229
|
+
}, t))
|
|
4230
|
+
})] });
|
|
4231
|
+
}
|
|
4232
|
+
//#endregion
|
|
4233
|
+
export { dt as ApiKeys, te as AppShell, Ze as Attachments, ct as AuditLog, Ke as Board, le as BulkActionBar, Ye as Calendar, Ae as ChartFrame, N as Cluster, be as CollectionList, mt as CommandPalette, Z as ConfirmDialog, ht as ContextMenu, Me as Dashboard, xe as DescriptionList, $e as DrillDown, Be as EditableGrid, re as ErrorScreen, fe as ErrorSummary, Ge as ExportDialog, ae as FilterBar, oe as FilterPanel, se as FilterSection, pe as FormPage, Y as FormSection, P as Grid, pt as HomeScreen, We as ImportFlow, ut as Integrations, De as ListDetail, lt as NotificationCentre, F as Page, q as PageHeader, et as PeriodComparison, st as PermissionsMatrix, nt as PivotTable, V as PrimaryNav, tt as PrintLayout, me as QuickEdit, Ee as RecordDetail, rt as ReportBuilder, Ne as ReportViewer, ze as ReviewConfirm, Pe as SettingsPage, I as SplitView, M as Stack, ke as StatTile, J as StatePanel, it as Subscriptions, Te as TabsSection, Re as TaskList, we as Timeline, ot as UsersAndRoles, Ie as Wizard, He as WorkQueue, ee as WorkspaceSwitcher, G as sizeAtLeast, ie as sizeClassOf, Qe as useDrillPath, de as useFormState, ge as useListQuery, W as useSizeClass, K as useStickyClearance, ue as useUnsavedChangesWarning };
|
|
4234
|
+
|
|
4235
|
+
//# sourceMappingURL=patterns.js.map
|