@sovereignsquad/gds-core 6.8.0 → 6.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -0
- package/dist/{QuickStartCard-CB7r-85z.d.ts → QuickStartCard-Bgjdfs_t.d.ts} +3340 -42
- package/dist/{QuickStartCard-xIP1gbCL.d.mts → QuickStartCard-DnZMDjzb.d.mts} +3340 -42
- package/dist/{chunk-TJ3WMH25.mjs → chunk-3B5MK2PG.mjs} +1317 -705
- package/dist/{chunk-BH2SMTND.mjs → chunk-5G3XZWSW.mjs} +1590 -1318
- package/dist/{chunk-GKNSUUUE.mjs → chunk-5GH7XD7X.mjs} +93 -1
- package/dist/{chunk-6PBDLFSF.mjs → chunk-6WDH57MJ.mjs} +93 -1
- package/dist/{chunk-2XZMNT7I.mjs → chunk-A32PWTD2.mjs} +93 -1
- package/dist/{chunk-GGDCO5HR.mjs → chunk-BD5XQH5Z.mjs} +93 -1
- package/dist/{chunk-4LG6EED4.mjs → chunk-DBJE4TRO.mjs} +93 -1
- package/dist/{chunk-H2QNW4D5.mjs → chunk-EQ7Y2PUI.mjs} +123 -49
- package/dist/{chunk-IHPZ7BNV.mjs → chunk-F76YTG3S.mjs} +93 -1
- package/dist/{chunk-NWS7KJ2G.mjs → chunk-HJVDKPVW.mjs} +1 -1
- package/dist/{chunk-GMK5GXWR.mjs → chunk-IMT3UTOT.mjs} +93 -1
- package/dist/{chunk-QO653DAE.mjs → chunk-KEYBUMOR.mjs} +93 -1
- package/dist/{chunk-BHR4A3C6.mjs → chunk-KLFTBWEG.mjs} +93 -1
- package/dist/{chunk-ZCQXBKDM.mjs → chunk-KNP35WAB.mjs} +5 -2
- package/dist/{chunk-CNTTKK3H.mjs → chunk-LERXSJHD.mjs} +93 -1
- package/dist/{chunk-JTMPFTCK.mjs → chunk-MKEWYVTJ.mjs} +93 -1
- package/dist/{chunk-VU2JLVD3.mjs → chunk-NTNVQZJU.mjs} +1 -1
- package/dist/{chunk-SHQDVHGR.mjs → chunk-OH5HH4G3.mjs} +93 -1
- package/dist/{chunk-MPZFCWWS.mjs → chunk-SPPTDVJC.mjs} +2 -1
- package/dist/{chunk-KFEPREUF.mjs → chunk-WI24JME4.mjs} +1 -1
- package/dist/client.d.mts +340 -47
- package/dist/client.d.ts +340 -47
- package/dist/client.js +12401 -10327
- package/dist/client.mjs +47 -19
- package/dist/{en-Dd7uvXnv.d.ts → en-D9CWSH3F.d.mts} +92 -0
- package/dist/{en-Dd7uvXnv.d.mts → en-D9CWSH3F.d.ts} +92 -0
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +9807 -7709
- package/dist/index.mjs +87 -29
- package/dist/locales/lazy/all.js +5149 -0
- package/dist/locales/lazy/all.mjs +50 -24
- package/dist/locales/lazy/ar.js +190 -3
- package/dist/locales/lazy/ar.mjs +10 -4
- package/dist/locales/lazy/de.js +190 -3
- package/dist/locales/lazy/de.mjs +10 -4
- package/dist/locales/lazy/es.js +190 -3
- package/dist/locales/lazy/es.mjs +10 -4
- package/dist/locales/lazy/fr.js +190 -3
- package/dist/locales/lazy/fr.mjs +10 -4
- package/dist/locales/lazy/he.js +190 -3
- package/dist/locales/lazy/he.mjs +10 -4
- package/dist/locales/lazy/hu.js +190 -3
- package/dist/locales/lazy/hu.mjs +10 -4
- package/dist/locales/lazy/index.d.mts +1 -1
- package/dist/locales/lazy/index.d.ts +1 -1
- package/dist/locales/lazy/index.js +97 -2
- package/dist/locales/lazy/index.mjs +2 -2
- package/dist/locales/lazy/it.js +190 -3
- package/dist/locales/lazy/it.mjs +10 -4
- package/dist/locales/lazy/ja.js +190 -3
- package/dist/locales/lazy/ja.mjs +10 -4
- package/dist/locales/lazy/ko.js +190 -3
- package/dist/locales/lazy/ko.mjs +10 -4
- package/dist/locales/lazy/ru.js +190 -3
- package/dist/locales/lazy/ru.mjs +10 -4
- package/dist/locales/lazy/zh.js +190 -3
- package/dist/locales/lazy/zh.mjs +10 -4
- package/dist/map.css +3 -9
- package/dist/map.js +2 -1
- package/dist/map.mjs +2 -2
- package/dist/reference-theme-explorer.js +1192 -26
- package/dist/reference-theme-explorer.mjs +15 -15
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2610 -1156
- package/dist/server.mjs +27 -19
- package/package.json +10 -5
- package/dist/chunk-2AX4NCID.mjs +0 -9
- package/dist/chunk-2IUOZG4C.mjs +0 -9
- package/dist/chunk-3D7BVS7D.mjs +0 -9
- package/dist/chunk-6LULEPIE.mjs +0 -9
- package/dist/chunk-J6MXKFIM.mjs +0 -9
- package/dist/chunk-LNVLXOLI.mjs +0 -9
- package/dist/chunk-MAIU557K.mjs +0 -9
- package/dist/chunk-OC3M4CZY.mjs +0 -9
- package/dist/chunk-RCLWUNMR.mjs +0 -9
- package/dist/chunk-WNOWHB26.mjs +0 -9
- package/dist/chunk-XLPTCIXT.mjs +0 -9
|
@@ -5,19 +5,23 @@ import {
|
|
|
5
5
|
CtaButtonGroup,
|
|
6
6
|
GdsInline,
|
|
7
7
|
GdsStack,
|
|
8
|
+
InlineAlert,
|
|
8
9
|
LastCheckedLabel,
|
|
9
10
|
MediaPreviewCard,
|
|
10
11
|
MetadataText,
|
|
11
12
|
NotificationCenterView,
|
|
13
|
+
PageTemplateFrame,
|
|
12
14
|
PublicFlowShell,
|
|
15
|
+
TemplateStateGate,
|
|
13
16
|
createGdsAccessGateEvent,
|
|
14
17
|
createGdsNotificationAuditEvent,
|
|
18
|
+
formatGdsDate,
|
|
15
19
|
getGdsLayoutTemplates,
|
|
16
20
|
getGdsNotificationLivePolicy,
|
|
17
21
|
renderGdsLayoutWithDiagnostics,
|
|
18
22
|
sortGdsAccessGateActions,
|
|
19
23
|
validateGdsAccessGateContract
|
|
20
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-5G3XZWSW.mjs";
|
|
21
25
|
import {
|
|
22
26
|
FormField,
|
|
23
27
|
SectionPanel,
|
|
@@ -25,10 +29,10 @@ import {
|
|
|
25
29
|
getSemanticActionLabel,
|
|
26
30
|
resolveGdsCardContract,
|
|
27
31
|
resolveSemanticActionConfig
|
|
28
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-EQ7Y2PUI.mjs";
|
|
29
33
|
import {
|
|
30
34
|
StateBlock
|
|
31
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-SPPTDVJC.mjs";
|
|
32
36
|
import {
|
|
33
37
|
GdsIcon,
|
|
34
38
|
GdsIcons
|
|
@@ -37,7 +41,7 @@ import {
|
|
|
37
41
|
// src/SemanticButton.tsx
|
|
38
42
|
import { useEffect, useState } from "react";
|
|
39
43
|
import { Button, VisuallyHidden } from "@mantine/core";
|
|
40
|
-
import { useGdsTranslation } from "@sovereignsquad/gds-theme";
|
|
44
|
+
import { gdsDevWarnOnce, useGdsTranslation } from "@sovereignsquad/gds-theme";
|
|
41
45
|
import { IconCheck, IconX } from "@tabler/icons-react";
|
|
42
46
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
43
47
|
var GDS_BUTTON_FEEDBACK_DURATION_MS = 2e3;
|
|
@@ -86,6 +90,12 @@ function SemanticButton({
|
|
|
86
90
|
label: labelOverride,
|
|
87
91
|
...props
|
|
88
92
|
}) {
|
|
93
|
+
if (props.children !== void 0) {
|
|
94
|
+
gdsDevWarnOnce(
|
|
95
|
+
"SemanticButton:children",
|
|
96
|
+
"SemanticButton ignores children: its text comes from `action` or the `label` prop. Pass the text as `label`."
|
|
97
|
+
);
|
|
98
|
+
}
|
|
89
99
|
const { t } = useGdsTranslation();
|
|
90
100
|
const config = resolveSemanticActionConfig(action, vocabularyPacks);
|
|
91
101
|
const [mounted, setMounted] = useState(!prerenderLabelOnly);
|
|
@@ -144,6 +154,7 @@ function SemanticButton({
|
|
|
144
154
|
|
|
145
155
|
// src/ConfirmDialog.tsx
|
|
146
156
|
import { Modal, Group, Text } from "@mantine/core";
|
|
157
|
+
import { useGdsTranslation as useGdsTranslation2 } from "@sovereignsquad/gds-theme";
|
|
147
158
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
148
159
|
function ConfirmDialog({
|
|
149
160
|
opened,
|
|
@@ -154,15 +165,29 @@ function ConfirmDialog({
|
|
|
154
165
|
confirmAction = "confirm",
|
|
155
166
|
cancelAction = "cancel",
|
|
156
167
|
isDanger = true,
|
|
157
|
-
loading = false
|
|
168
|
+
loading = false,
|
|
169
|
+
confirmLabel,
|
|
170
|
+
cancelLabel
|
|
158
171
|
}) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
172
|
+
const { t } = useGdsTranslation2();
|
|
173
|
+
return /* @__PURE__ */ jsxs2(
|
|
174
|
+
Modal,
|
|
175
|
+
{
|
|
176
|
+
opened,
|
|
177
|
+
onClose,
|
|
178
|
+
title,
|
|
179
|
+
centered: true,
|
|
180
|
+
trapFocus: true,
|
|
181
|
+
closeButtonProps: { "aria-label": t("gds.overlay.close", "Close") },
|
|
182
|
+
children: [
|
|
183
|
+
/* @__PURE__ */ jsx2(Text, { component: "div", size: "sm", mb: "xl", children }),
|
|
184
|
+
/* @__PURE__ */ jsxs2(Group, { justify: "flex-end", children: [
|
|
185
|
+
/* @__PURE__ */ jsx2(SemanticButton, { action: cancelAction, label: cancelLabel, variant: "default", onClick: onClose, disabled: loading }),
|
|
186
|
+
/* @__PURE__ */ jsx2(SemanticButton, { action: confirmAction, label: confirmLabel, color: isDanger ? "red" : void 0, onClick: onConfirm, loading })
|
|
187
|
+
] })
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
);
|
|
166
191
|
}
|
|
167
192
|
|
|
168
193
|
// src/GameBoardTile.tsx
|
|
@@ -217,10 +242,418 @@ function useGdsCardContract(options = {}) {
|
|
|
217
242
|
return resolveGdsCardContract({ density: ambientDensity, ...options });
|
|
218
243
|
}
|
|
219
244
|
|
|
245
|
+
// src/GdsShapeScope.tsx
|
|
246
|
+
import { Box } from "@mantine/core";
|
|
247
|
+
import { GDS_RADIUS_ROLES, GDS_SHAPE_PROFILES } from "@sovereignsquad/gds-theme";
|
|
248
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
249
|
+
function getGdsShapeScopeStyle(profile) {
|
|
250
|
+
const roles = profile === "default" ? {} : GDS_SHAPE_PROFILES[profile];
|
|
251
|
+
const style = {};
|
|
252
|
+
for (const role of GDS_RADIUS_ROLES) {
|
|
253
|
+
const step = roles[role];
|
|
254
|
+
if (step) style[`--gds-radius-${role}`] = `var(--gds-radius-${step})`;
|
|
255
|
+
}
|
|
256
|
+
return style;
|
|
257
|
+
}
|
|
258
|
+
function GdsShapeScope({ profile, style, children, ...others }) {
|
|
259
|
+
return /* @__PURE__ */ jsx5(Box, { ...others, "data-gds-shape-profile": profile, style: { ...getGdsShapeScopeStyle(profile), ...style }, children });
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// src/GdsTreeView.tsx
|
|
263
|
+
import { useCallback, useMemo, useRef, useState as useState2 } from "react";
|
|
264
|
+
import { Box as Box2, Button as Button2, Group as Group2, Loader, Paper as Paper2, Text as Text3 } from "@mantine/core";
|
|
265
|
+
import { useUncontrolled } from "@mantine/hooks";
|
|
266
|
+
import { useGdsTranslation as useGdsTranslation3 } from "@sovereignsquad/gds-theme";
|
|
267
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
268
|
+
function GdsTreeView({
|
|
269
|
+
nodes,
|
|
270
|
+
ariaLabel,
|
|
271
|
+
expandedIds,
|
|
272
|
+
defaultExpandedIds = [],
|
|
273
|
+
onExpandedChange,
|
|
274
|
+
selectedId,
|
|
275
|
+
defaultSelectedId = null,
|
|
276
|
+
onSelect,
|
|
277
|
+
loadChildren
|
|
278
|
+
}) {
|
|
279
|
+
const { t } = useGdsTranslation3();
|
|
280
|
+
const [expanded, setExpanded] = useUncontrolled({ value: expandedIds, defaultValue: defaultExpandedIds, finalValue: [], onChange: onExpandedChange });
|
|
281
|
+
const [selected, setSelected] = useUncontrolled({ value: selectedId, defaultValue: defaultSelectedId, finalValue: null });
|
|
282
|
+
const [loads, setLoads] = useState2({});
|
|
283
|
+
const [focusedId, setFocusedId] = useState2(null);
|
|
284
|
+
const itemRefs = useRef(/* @__PURE__ */ new Map());
|
|
285
|
+
const childrenOf = useCallback((node) => {
|
|
286
|
+
if (node.children) return node.children;
|
|
287
|
+
const load2 = loads[node.id];
|
|
288
|
+
return load2?.status === "loaded" ? load2.children : void 0;
|
|
289
|
+
}, [loads]);
|
|
290
|
+
const visible = useMemo(() => {
|
|
291
|
+
const out = [];
|
|
292
|
+
const walk = (list, level, parentId) => {
|
|
293
|
+
for (const node of list) {
|
|
294
|
+
const children = childrenOf(node);
|
|
295
|
+
const expandable = Boolean(node.children?.length) || Boolean(node.hasChildren);
|
|
296
|
+
const isExpanded = expandable && expanded.includes(node.id);
|
|
297
|
+
out.push({ node, level, parentId, expandable, expanded: isExpanded, children });
|
|
298
|
+
if (isExpanded && children) walk(children, level + 1, node.id);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
walk(nodes, 1, null);
|
|
302
|
+
return out;
|
|
303
|
+
}, [nodes, expanded, childrenOf]);
|
|
304
|
+
const tabStop = focusedId && visible.some((item) => item.node.id === focusedId) ? focusedId : selected && visible.some((item) => item.node.id === selected) ? selected : visible[0]?.node.id;
|
|
305
|
+
const focus = (id) => {
|
|
306
|
+
if (!id) return;
|
|
307
|
+
setFocusedId(id);
|
|
308
|
+
itemRefs.current.get(id)?.focus();
|
|
309
|
+
};
|
|
310
|
+
const load = async (node) => {
|
|
311
|
+
if (!loadChildren || node.children || loads[node.id]?.status === "loading" || loads[node.id]?.status === "loaded") return;
|
|
312
|
+
setLoads((prev) => ({ ...prev, [node.id]: { status: "loading" } }));
|
|
313
|
+
try {
|
|
314
|
+
const children = await loadChildren(node);
|
|
315
|
+
setLoads((prev) => ({ ...prev, [node.id]: { status: "loaded", children } }));
|
|
316
|
+
} catch {
|
|
317
|
+
setLoads((prev) => ({ ...prev, [node.id]: { status: "error" } }));
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
const setOpen = (item, open) => {
|
|
321
|
+
if (!item.expandable || item.expanded === open) return;
|
|
322
|
+
setExpanded(open ? [...expanded, item.node.id] : expanded.filter((id) => id !== item.node.id));
|
|
323
|
+
if (open) void load(item.node);
|
|
324
|
+
};
|
|
325
|
+
const select = (item) => {
|
|
326
|
+
setSelected(item.node.id);
|
|
327
|
+
onSelect?.(item.node.id, item.node);
|
|
328
|
+
};
|
|
329
|
+
const onKeyDown = (event, index) => {
|
|
330
|
+
const item = visible[index];
|
|
331
|
+
switch (event.key) {
|
|
332
|
+
case "ArrowDown":
|
|
333
|
+
focus(visible[index + 1]?.node.id);
|
|
334
|
+
break;
|
|
335
|
+
case "ArrowUp":
|
|
336
|
+
focus(visible[index - 1]?.node.id);
|
|
337
|
+
break;
|
|
338
|
+
case "Home":
|
|
339
|
+
focus(visible[0]?.node.id);
|
|
340
|
+
break;
|
|
341
|
+
case "End":
|
|
342
|
+
focus(visible[visible.length - 1]?.node.id);
|
|
343
|
+
break;
|
|
344
|
+
case "ArrowRight":
|
|
345
|
+
if (item.expandable && !item.expanded) setOpen(item, true);
|
|
346
|
+
else if (item.expanded && item.children?.length) focus(visible[index + 1]?.node.id);
|
|
347
|
+
break;
|
|
348
|
+
case "ArrowLeft":
|
|
349
|
+
if (item.expanded) setOpen(item, false);
|
|
350
|
+
else focus(item.parentId ?? void 0);
|
|
351
|
+
break;
|
|
352
|
+
case "Enter":
|
|
353
|
+
case " ":
|
|
354
|
+
select(item);
|
|
355
|
+
break;
|
|
356
|
+
default:
|
|
357
|
+
if (event.key.length === 1 && /\S/.test(event.key)) {
|
|
358
|
+
const key = event.key.toLowerCase();
|
|
359
|
+
const ordered = [...visible.slice(index + 1), ...visible.slice(0, index + 1)];
|
|
360
|
+
focus(ordered.find((candidate) => candidate.node.label.toLowerCase().startsWith(key))?.node.id);
|
|
361
|
+
break;
|
|
362
|
+
}
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
event.preventDefault();
|
|
366
|
+
};
|
|
367
|
+
const renderLevel = (list, level) => list.map((node) => {
|
|
368
|
+
const index = visible.findIndex((item2) => item2.node.id === node.id);
|
|
369
|
+
const item = visible[index];
|
|
370
|
+
if (!item) return null;
|
|
371
|
+
const loadState = loads[node.id];
|
|
372
|
+
const isSelected = selected === node.id;
|
|
373
|
+
return /* @__PURE__ */ jsxs3(Box2, { component: "li", role: "none", style: { listStyle: "none" }, children: [
|
|
374
|
+
/* @__PURE__ */ jsxs3(
|
|
375
|
+
Box2,
|
|
376
|
+
{
|
|
377
|
+
ref: (el) => {
|
|
378
|
+
if (el) itemRefs.current.set(node.id, el);
|
|
379
|
+
else itemRefs.current.delete(node.id);
|
|
380
|
+
},
|
|
381
|
+
role: "treeitem",
|
|
382
|
+
"aria-level": level,
|
|
383
|
+
"aria-expanded": item.expandable ? item.expanded : void 0,
|
|
384
|
+
"aria-selected": isSelected,
|
|
385
|
+
"aria-busy": loadState?.status === "loading" || void 0,
|
|
386
|
+
tabIndex: tabStop === node.id ? 0 : -1,
|
|
387
|
+
"data-gds-tree-item": "",
|
|
388
|
+
"data-selected": isSelected || void 0,
|
|
389
|
+
onKeyDown: (event) => onKeyDown(event, index),
|
|
390
|
+
onFocus: () => setFocusedId(node.id),
|
|
391
|
+
onClick: () => {
|
|
392
|
+
select(item);
|
|
393
|
+
if (item.expandable) setOpen(item, !item.expanded);
|
|
394
|
+
},
|
|
395
|
+
style: {
|
|
396
|
+
display: "flex",
|
|
397
|
+
alignItems: "center",
|
|
398
|
+
gap: "var(--gds-space-xs)",
|
|
399
|
+
minHeight: "var(--gds-control-height-sm)",
|
|
400
|
+
paddingInlineStart: `calc(var(--gds-space-xs) + ${level - 1} * var(--gds-space-md))`,
|
|
401
|
+
paddingInlineEnd: "var(--gds-space-xs)",
|
|
402
|
+
borderRadius: "var(--gds-radius-sm)",
|
|
403
|
+
cursor: "pointer",
|
|
404
|
+
background: isSelected ? "var(--gds-nav-active-bg)" : void 0,
|
|
405
|
+
color: isSelected ? "var(--gds-nav-active-fg)" : void 0
|
|
406
|
+
},
|
|
407
|
+
children: [
|
|
408
|
+
/* @__PURE__ */ jsx6(Box2, { component: "span", "aria-hidden": "true", style: { inlineSize: "var(--gds-space-md)", flex: "none", textAlign: "center" }, children: item.expandable ? item.expanded ? "\u25BE" : "\u25B8" : "" }),
|
|
409
|
+
node.icon ? /* @__PURE__ */ jsx6(Box2, { component: "span", "aria-hidden": "true", style: { display: "inline-flex" }, children: node.icon }) : null,
|
|
410
|
+
/* @__PURE__ */ jsx6(Text3, { component: "span", size: "sm", children: node.label })
|
|
411
|
+
]
|
|
412
|
+
}
|
|
413
|
+
),
|
|
414
|
+
item.expanded ? /* @__PURE__ */ jsxs3(Box2, { component: "ul", role: "group", style: { margin: 0, padding: 0 }, children: [
|
|
415
|
+
loadState?.status === "loading" ? /* @__PURE__ */ jsx6(Box2, { component: "li", role: "none", style: { listStyle: "none", paddingInlineStart: `calc(var(--gds-space-xs) + ${level} * var(--gds-space-md))` }, children: /* @__PURE__ */ jsxs3(Group2, { gap: "xs", children: [
|
|
416
|
+
/* @__PURE__ */ jsx6(Loader, { size: "xs" }),
|
|
417
|
+
/* @__PURE__ */ jsx6(Text3, { size: "sm", children: t("gds.treeView.loading", "Loading\u2026") })
|
|
418
|
+
] }) }) : null,
|
|
419
|
+
loadState?.status === "error" ? /* @__PURE__ */ jsx6(Box2, { component: "li", role: "none", style: { listStyle: "none", paddingInlineStart: `calc(var(--gds-space-xs) + ${level} * var(--gds-space-md))` }, children: /* @__PURE__ */ jsxs3(Group2, { gap: "xs", children: [
|
|
420
|
+
/* @__PURE__ */ jsx6(Text3, { size: "sm", role: "alert", children: t("gds.treeView.loadError", "Could not load these items.") }),
|
|
421
|
+
/* @__PURE__ */ jsx6(Button2, { size: "compact-xs", variant: "subtle", onClick: () => void load(node), children: t("gds.treeView.retry", "Retry") })
|
|
422
|
+
] }) }) : null,
|
|
423
|
+
item.children ? renderLevel(item.children, level + 1) : null
|
|
424
|
+
] }) : null
|
|
425
|
+
] }, node.id);
|
|
426
|
+
});
|
|
427
|
+
return /* @__PURE__ */ jsx6(Paper2, { withBorder: true, p: "xs", style: { ["--paper-border-color"]: "var(--gds-border-subtle)" }, "data-gds-tree-view": "", children: /* @__PURE__ */ jsx6(Box2, { component: "ul", role: "tree", "aria-label": ariaLabel, style: { margin: 0, padding: 0 }, children: renderLevel(nodes, 1) }) });
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// src/GdsBulkActionBar.tsx
|
|
431
|
+
import { Button as Button3, Group as Group3, Paper as Paper3, Text as Text4, VisuallyHidden as VisuallyHidden2 } from "@mantine/core";
|
|
432
|
+
import { useGdsTranslation as useGdsTranslation4 } from "@sovereignsquad/gds-theme";
|
|
433
|
+
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
434
|
+
function GdsBulkActionBar({ selectedCount, actions, onClearSelection, vocabularyPacks = [] }) {
|
|
435
|
+
const { t } = useGdsTranslation4();
|
|
436
|
+
const countText = t("gds.bulkActions.selectedCount", "{count} selected").replace("{count}", String(selectedCount));
|
|
437
|
+
const announcement = selectedCount > 0 ? countText : t("gds.bulkActions.selectionCleared", "Selection cleared");
|
|
438
|
+
return /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
439
|
+
/* @__PURE__ */ jsx7(VisuallyHidden2, { role: "status", "aria-live": "polite", "data-gds-bulk-action-status": "", children: announcement }),
|
|
440
|
+
selectedCount > 0 ? /* @__PURE__ */ jsx7(
|
|
441
|
+
Paper3,
|
|
442
|
+
{
|
|
443
|
+
withBorder: true,
|
|
444
|
+
p: "xs",
|
|
445
|
+
role: "toolbar",
|
|
446
|
+
"aria-label": t("gds.bulkActions.toolbarLabel", "Bulk actions"),
|
|
447
|
+
"data-gds-bulk-action-bar": "",
|
|
448
|
+
style: { background: "var(--gds-bg-raised)", ["--paper-border-color"]: "var(--gds-border-strong)" },
|
|
449
|
+
children: /* @__PURE__ */ jsxs4(Group3, { justify: "space-between", gap: "sm", wrap: "wrap", children: [
|
|
450
|
+
/* @__PURE__ */ jsx7(Text4, { size: "sm", fw: 600, "aria-hidden": "true", children: countText }),
|
|
451
|
+
/* @__PURE__ */ jsxs4(Group3, { gap: "xs", wrap: "wrap", children: [
|
|
452
|
+
actions.map((item) => {
|
|
453
|
+
const Icon = resolveSemanticActionConfig(item.action, vocabularyPacks)?.icon;
|
|
454
|
+
const label = item.label ?? getSemanticActionLabel(item.action, t, vocabularyPacks);
|
|
455
|
+
return /* @__PURE__ */ jsx7(
|
|
456
|
+
Button3,
|
|
457
|
+
{
|
|
458
|
+
size: "xs",
|
|
459
|
+
variant: "light",
|
|
460
|
+
leftSection: Icon ? /* @__PURE__ */ jsx7(Icon, { size: "1rem", stroke: 1.5 }) : void 0,
|
|
461
|
+
onClick: item.onClick,
|
|
462
|
+
disabled: item.disabled,
|
|
463
|
+
children: label
|
|
464
|
+
},
|
|
465
|
+
String(item.action)
|
|
466
|
+
);
|
|
467
|
+
}),
|
|
468
|
+
/* @__PURE__ */ jsx7(Button3, { size: "xs", variant: "subtle", onClick: onClearSelection, children: t("gds.bulkActions.clearSelection", "Clear selection") })
|
|
469
|
+
] })
|
|
470
|
+
] })
|
|
471
|
+
}
|
|
472
|
+
) : null
|
|
473
|
+
] });
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// src/GdsThreadList.tsx
|
|
477
|
+
import { Avatar, Box as Box3, Button as Button4, Group as Group4, Stack, Text as Text5, UnstyledButton as UnstyledButton2, VisuallyHidden as VisuallyHidden3 } from "@mantine/core";
|
|
478
|
+
import { useGdsTranslation as useGdsTranslation5 } from "@sovereignsquad/gds-theme";
|
|
479
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
480
|
+
function formatTimestamp(value, locale) {
|
|
481
|
+
const date = new Date(value);
|
|
482
|
+
const sameDay = date.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
|
|
483
|
+
return formatGdsDate(date, sameDay ? { locale, timeStyle: "short" } : { locale, dateStyle: "medium" });
|
|
484
|
+
}
|
|
485
|
+
function GdsThreadList({
|
|
486
|
+
threads,
|
|
487
|
+
ariaLabel,
|
|
488
|
+
selectedId,
|
|
489
|
+
onSelect,
|
|
490
|
+
loading = false,
|
|
491
|
+
error,
|
|
492
|
+
onRetry,
|
|
493
|
+
hasMore = false,
|
|
494
|
+
onLoadMore,
|
|
495
|
+
loadingMore = false,
|
|
496
|
+
emptyTitle,
|
|
497
|
+
stateTitleOrder
|
|
498
|
+
}) {
|
|
499
|
+
const { t, locale } = useGdsTranslation5();
|
|
500
|
+
if (error) {
|
|
501
|
+
return /* @__PURE__ */ jsx8(
|
|
502
|
+
StateBlock,
|
|
503
|
+
{
|
|
504
|
+
variant: "error",
|
|
505
|
+
compact: true,
|
|
506
|
+
titleOrder: stateTitleOrder,
|
|
507
|
+
title: t("gds.threadList.errorTitle", "Conversations could not be loaded"),
|
|
508
|
+
description: error,
|
|
509
|
+
action: onRetry ? /* @__PURE__ */ jsx8(Button4, { size: "xs", variant: "light", onClick: onRetry, children: t("gds.threadList.retry", "Retry") }) : void 0
|
|
510
|
+
}
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
if (loading) {
|
|
514
|
+
return /* @__PURE__ */ jsx8(StateBlock, { variant: "loading", compact: true, titleOrder: stateTitleOrder, title: t("gds.threadList.loading", "Loading conversations") });
|
|
515
|
+
}
|
|
516
|
+
if (threads.length === 0) {
|
|
517
|
+
return /* @__PURE__ */ jsx8(StateBlock, { variant: "empty", compact: true, titleOrder: stateTitleOrder, title: emptyTitle ?? t("gds.threadList.emptyTitle", "No conversations yet") });
|
|
518
|
+
}
|
|
519
|
+
return /* @__PURE__ */ jsxs5(Stack, { gap: "xs", "data-gds-thread-list": "", children: [
|
|
520
|
+
/* @__PURE__ */ jsx8(Box3, { component: "ul", "aria-label": ariaLabel, style: { listStyle: "none", margin: 0, padding: 0 }, children: threads.map((thread) => {
|
|
521
|
+
const isSelected = selectedId === thread.id;
|
|
522
|
+
return /* @__PURE__ */ jsx8(Box3, { component: "li", children: /* @__PURE__ */ jsx8(
|
|
523
|
+
UnstyledButton2,
|
|
524
|
+
{
|
|
525
|
+
onClick: () => onSelect?.(thread.id),
|
|
526
|
+
"aria-current": isSelected ? "true" : void 0,
|
|
527
|
+
"data-gds-thread-item": "",
|
|
528
|
+
"data-unread": thread.unread || void 0,
|
|
529
|
+
style: {
|
|
530
|
+
display: "block",
|
|
531
|
+
inlineSize: "100%",
|
|
532
|
+
padding: "var(--gds-space-xs) var(--gds-space-sm)",
|
|
533
|
+
borderRadius: "var(--gds-radius-sm)",
|
|
534
|
+
background: isSelected ? "var(--gds-nav-active-bg)" : void 0,
|
|
535
|
+
color: isSelected ? "var(--gds-nav-active-fg)" : void 0,
|
|
536
|
+
boxShadow: isSelected ? "inset var(--gds-focus-ring-width) 0 0 var(--gds-nav-active-indicator)" : void 0
|
|
537
|
+
},
|
|
538
|
+
children: /* @__PURE__ */ jsxs5(Group4, { gap: "sm", wrap: "nowrap", align: "flex-start", children: [
|
|
539
|
+
/* @__PURE__ */ jsx8(Avatar, { src: thread.avatarSrc, name: thread.avatarName ?? thread.title, alt: thread.avatarName ?? thread.title, radius: "xl", size: "md" }),
|
|
540
|
+
/* @__PURE__ */ jsxs5(Box3, { style: { minWidth: 0, flex: 1 }, children: [
|
|
541
|
+
/* @__PURE__ */ jsxs5(Group4, { gap: "xs", justify: "space-between", wrap: "nowrap", children: [
|
|
542
|
+
/* @__PURE__ */ jsx8(Text5, { size: "sm", fw: thread.unread ? 700 : 500, truncate: true, children: thread.title }),
|
|
543
|
+
thread.timestamp !== void 0 ? /* @__PURE__ */ jsx8(Text5, { size: "xs", c: "dimmed", style: { flex: "none" }, children: formatTimestamp(thread.timestamp, locale) }) : null
|
|
544
|
+
] }),
|
|
545
|
+
/* @__PURE__ */ jsxs5(Group4, { gap: "xs", wrap: "nowrap", children: [
|
|
546
|
+
thread.unread ? /* @__PURE__ */ jsx8(
|
|
547
|
+
Box3,
|
|
548
|
+
{
|
|
549
|
+
component: "span",
|
|
550
|
+
"aria-hidden": "true",
|
|
551
|
+
style: { flex: "none", inlineSize: "var(--gds-space-2xs)", blockSize: "var(--gds-space-2xs)", borderRadius: "var(--gds-radius-pill)", background: "var(--gds-nav-active-indicator)" }
|
|
552
|
+
}
|
|
553
|
+
) : null,
|
|
554
|
+
thread.unread ? /* @__PURE__ */ jsx8(VisuallyHidden3, { children: t("gds.threadList.unread", "Unread") }) : null,
|
|
555
|
+
thread.preview ? /* @__PURE__ */ jsx8(Text5, { size: "xs", c: thread.unread ? void 0 : "dimmed", fw: thread.unread ? 600 : 400, truncate: true, children: thread.preview }) : null
|
|
556
|
+
] })
|
|
557
|
+
] })
|
|
558
|
+
] })
|
|
559
|
+
}
|
|
560
|
+
) }, thread.id);
|
|
561
|
+
}) }),
|
|
562
|
+
hasMore ? /* @__PURE__ */ jsx8(Button4, { variant: "subtle", size: "xs", fullWidth: true, onClick: onLoadMore, loading: loadingMore, children: t("gds.threadList.loadMore", "Load more") }) : null
|
|
563
|
+
] });
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
// src/GdsMessageThread.tsx
|
|
567
|
+
import { Avatar as Avatar2, Box as Box4, Divider, Group as Group5, Stack as Stack2, Text as Text6, VisuallyHidden as VisuallyHidden4 } from "@mantine/core";
|
|
568
|
+
import { useGdsTranslation as useGdsTranslation6 } from "@sovereignsquad/gds-theme";
|
|
569
|
+
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
570
|
+
var dayKey = (date) => `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;
|
|
571
|
+
function GdsMessageThread({ messages, selfId, ariaLabel }) {
|
|
572
|
+
const { t, locale } = useGdsTranslation6();
|
|
573
|
+
const youLabel = t("gds.messageThread.you", "You");
|
|
574
|
+
const rows = [];
|
|
575
|
+
let previousDay = "";
|
|
576
|
+
let previousSender = "";
|
|
577
|
+
for (const message of messages) {
|
|
578
|
+
const date = new Date(message.createdAt);
|
|
579
|
+
const day = dayKey(date);
|
|
580
|
+
if (day !== previousDay) {
|
|
581
|
+
rows.push(
|
|
582
|
+
/* @__PURE__ */ jsx9(
|
|
583
|
+
Divider,
|
|
584
|
+
{
|
|
585
|
+
role: "separator",
|
|
586
|
+
label: formatGdsDate(date, { locale, dateStyle: "medium" }),
|
|
587
|
+
labelPosition: "center",
|
|
588
|
+
"data-gds-message-day": ""
|
|
589
|
+
},
|
|
590
|
+
`day-${day}`
|
|
591
|
+
)
|
|
592
|
+
);
|
|
593
|
+
previousDay = day;
|
|
594
|
+
previousSender = "";
|
|
595
|
+
}
|
|
596
|
+
const isSelf = message.senderId === selfId;
|
|
597
|
+
const showHeader = message.senderId !== previousSender;
|
|
598
|
+
previousSender = message.senderId;
|
|
599
|
+
const time = formatGdsDate(date, { locale, timeStyle: "short" });
|
|
600
|
+
const sender = isSelf ? youLabel : message.senderName;
|
|
601
|
+
rows.push(
|
|
602
|
+
/* @__PURE__ */ jsxs6(Stack2, { gap: 4, align: isSelf ? "flex-end" : "flex-start", "data-gds-message": isSelf ? "self" : "other", children: [
|
|
603
|
+
showHeader ? /* @__PURE__ */ jsxs6(Group5, { gap: "xs", wrap: "nowrap", "aria-hidden": "true", children: [
|
|
604
|
+
!isSelf ? /* @__PURE__ */ jsx9(Avatar2, { src: message.senderAvatarSrc, name: message.senderName, radius: "xl", size: "sm" }) : null,
|
|
605
|
+
/* @__PURE__ */ jsx9(Text6, { size: "xs", fw: 600, children: sender })
|
|
606
|
+
] }) : null,
|
|
607
|
+
/* @__PURE__ */ jsxs6(
|
|
608
|
+
Box4,
|
|
609
|
+
{
|
|
610
|
+
style: {
|
|
611
|
+
maxInlineSize: "80%",
|
|
612
|
+
padding: "var(--gds-space-xs) var(--gds-space-sm)",
|
|
613
|
+
borderRadius: "var(--gds-radius-card)",
|
|
614
|
+
background: isSelf ? "var(--gds-message-self-bg)" : "var(--gds-message-other-bg)",
|
|
615
|
+
color: isSelf ? "var(--gds-message-self-fg)" : "var(--gds-message-other-fg)",
|
|
616
|
+
border: isSelf ? void 0 : "calc(var(--gds-focus-ring-width) / 2) solid var(--gds-border-subtle)"
|
|
617
|
+
},
|
|
618
|
+
children: [
|
|
619
|
+
/* @__PURE__ */ jsx9(VisuallyHidden4, { children: `${sender}, ${time}: ` }),
|
|
620
|
+
/* @__PURE__ */ jsx9(Box4, { children: message.content }),
|
|
621
|
+
/* @__PURE__ */ jsx9(Text6, { size: "xs", "aria-hidden": "true", ta: isSelf ? "end" : "start", children: time })
|
|
622
|
+
]
|
|
623
|
+
}
|
|
624
|
+
)
|
|
625
|
+
] }, message.id)
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
return /* @__PURE__ */ jsx9(Stack2, { gap: "sm", role: "log", "aria-label": ariaLabel, "aria-live": "polite", "data-gds-message-thread": "", children: rows });
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// src/GdsViewToggle.tsx
|
|
632
|
+
import { SegmentedControl } from "@mantine/core";
|
|
633
|
+
import { useGdsTranslation as useGdsTranslation7 } from "@sovereignsquad/gds-theme";
|
|
634
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
635
|
+
function GdsViewToggle({ value, onChange, ariaLabel }) {
|
|
636
|
+
const { t } = useGdsTranslation7();
|
|
637
|
+
return /* @__PURE__ */ jsx10(
|
|
638
|
+
SegmentedControl,
|
|
639
|
+
{
|
|
640
|
+
"aria-label": ariaLabel ?? t("gds.dataView.toggleLabel", "Layout"),
|
|
641
|
+
value,
|
|
642
|
+
onChange: (next) => onChange(next),
|
|
643
|
+
data: [
|
|
644
|
+
{ value: "table", label: t("gds.dataView.table", "Table") },
|
|
645
|
+
{ value: "grid", label: t("gds.dataView.grid", "Grid") }
|
|
646
|
+
],
|
|
647
|
+
style: { alignSelf: "flex-start" },
|
|
648
|
+
"data-gds-view-toggle": ""
|
|
649
|
+
}
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
|
|
220
653
|
// src/ProviderCTA.tsx
|
|
221
|
-
import { Text as
|
|
222
|
-
import { useGdsTranslation as
|
|
223
|
-
import { jsx as
|
|
654
|
+
import { Text as Text7 } from "@mantine/core";
|
|
655
|
+
import { useGdsTranslation as useGdsTranslation8 } from "@sovereignsquad/gds-theme";
|
|
656
|
+
import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
224
657
|
var containerStyle = {
|
|
225
658
|
background: "var(--gds-bg-info-tag, var(--mantine-color-gray-1))",
|
|
226
659
|
border: "1px solid var(--gds-border-card, var(--gds-vibe-border, var(--mantine-color-default-border)))",
|
|
@@ -239,7 +672,7 @@ function ProviderCTA({
|
|
|
239
672
|
secondaryLabel,
|
|
240
673
|
onSecondary
|
|
241
674
|
}) {
|
|
242
|
-
const { t } =
|
|
675
|
+
const { t } = useGdsTranslation8();
|
|
243
676
|
const resolvedHeadline = headline ?? t("gds.providerCta.headline", "Are you the provider?");
|
|
244
677
|
const resolvedBody = body ?? t(
|
|
245
678
|
"gds.providerCta.body",
|
|
@@ -257,13 +690,13 @@ function ProviderCTA({
|
|
|
257
690
|
secondary: { defaultMessage: toButtonLabel(secondaryLabel), icon: GdsIcons.Info }
|
|
258
691
|
})
|
|
259
692
|
] : void 0;
|
|
260
|
-
return /* @__PURE__ */
|
|
261
|
-
/* @__PURE__ */
|
|
262
|
-
/* @__PURE__ */
|
|
263
|
-
/* @__PURE__ */
|
|
693
|
+
return /* @__PURE__ */ jsx11("div", { style: containerStyle, children: /* @__PURE__ */ jsxs7(GdsStack, { gap: "xs", children: [
|
|
694
|
+
/* @__PURE__ */ jsx11(Text7, { fw: 700, size: "sm", c: "inherit", children: resolvedHeadline }),
|
|
695
|
+
/* @__PURE__ */ jsx11(Text7, { size: "xs", c: "inherit", children: resolvedBody }),
|
|
696
|
+
/* @__PURE__ */ jsx11(
|
|
264
697
|
CtaButtonGroup,
|
|
265
698
|
{
|
|
266
|
-
primary: /* @__PURE__ */
|
|
699
|
+
primary: /* @__PURE__ */ jsx11(
|
|
267
700
|
SemanticButton,
|
|
268
701
|
{
|
|
269
702
|
action: "providerCta:claim",
|
|
@@ -274,7 +707,7 @@ function ProviderCTA({
|
|
|
274
707
|
onClick: onAction
|
|
275
708
|
}
|
|
276
709
|
),
|
|
277
|
-
secondary: showSecondary ? /* @__PURE__ */
|
|
710
|
+
secondary: showSecondary ? /* @__PURE__ */ jsx11(
|
|
278
711
|
SemanticButton,
|
|
279
712
|
{
|
|
280
713
|
action: "providerCta:secondary",
|
|
@@ -291,8 +724,8 @@ function ProviderCTA({
|
|
|
291
724
|
}
|
|
292
725
|
|
|
293
726
|
// src/ListingState.client.tsx
|
|
294
|
-
import { createContext as createContext2, useContext as useContext2, useMemo, useReducer } from "react";
|
|
295
|
-
import { jsx as
|
|
727
|
+
import { createContext as createContext2, useContext as useContext2, useMemo as useMemo2, useReducer } from "react";
|
|
728
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
296
729
|
function createInitialState(config = {}) {
|
|
297
730
|
return {
|
|
298
731
|
search: "",
|
|
@@ -347,8 +780,8 @@ function ListingProvider({
|
|
|
347
780
|
config
|
|
348
781
|
}) {
|
|
349
782
|
const [state, dispatch] = useReducer(listingQueryReducer, config, createInitialState);
|
|
350
|
-
const value =
|
|
351
|
-
return /* @__PURE__ */
|
|
783
|
+
const value = useMemo2(() => ({ state, dispatch }), [state]);
|
|
784
|
+
return /* @__PURE__ */ jsx12(ListingStateContext.Provider, { value, children });
|
|
352
785
|
}
|
|
353
786
|
function useListingState() {
|
|
354
787
|
const context = useContext2(ListingStateContext);
|
|
@@ -359,10 +792,10 @@ function useListingState() {
|
|
|
359
792
|
}
|
|
360
793
|
|
|
361
794
|
// src/BrowseSelection.client.ts
|
|
362
|
-
import { useState as
|
|
795
|
+
import { useState as useState3 } from "react";
|
|
363
796
|
function useGdsBrowseSelection(options = {}) {
|
|
364
797
|
const { defaultSelectedId = null, selectedId, onChange } = options;
|
|
365
|
-
const [internalSelectedId, setInternalSelectedId] =
|
|
798
|
+
const [internalSelectedId, setInternalSelectedId] = useState3(defaultSelectedId);
|
|
366
799
|
const isControlled = selectedId !== void 0;
|
|
367
800
|
const current = isControlled ? selectedId : internalSelectedId;
|
|
368
801
|
const commit = (next) => {
|
|
@@ -392,17 +825,17 @@ var gdsBreakpointByAlias = {
|
|
|
392
825
|
};
|
|
393
826
|
|
|
394
827
|
// src/DiscoveryShell.tsx
|
|
395
|
-
import { useGdsTranslation as
|
|
396
|
-
import { useEffect as useEffect2, useState as
|
|
397
|
-
import { AppShell as MantineAppShell, Box, Burger, Group as
|
|
828
|
+
import { useGdsTranslation as useGdsTranslation9 } from "@sovereignsquad/gds-theme";
|
|
829
|
+
import { useEffect as useEffect2, useState as useState4 } from "react";
|
|
830
|
+
import { AppShell as MantineAppShell, Box as Box5, Burger, Group as Group6, ScrollArea } from "@mantine/core";
|
|
398
831
|
import { useMediaQuery as useMediaQuery2 } from "@mantine/hooks";
|
|
399
|
-
import { jsx as
|
|
832
|
+
import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
400
833
|
function useDiscoveryShellState({
|
|
401
834
|
defaultSidebarOpen = false,
|
|
402
835
|
sidebarStorageKey,
|
|
403
836
|
onSidebarOpenedChange
|
|
404
837
|
} = {}) {
|
|
405
|
-
const [opened, setOpenedState] =
|
|
838
|
+
const [opened, setOpenedState] = useState4(defaultSidebarOpen);
|
|
406
839
|
useEffect2(() => {
|
|
407
840
|
if (!sidebarStorageKey || typeof window === "undefined") {
|
|
408
841
|
return;
|
|
@@ -460,7 +893,7 @@ function DiscoveryShell({
|
|
|
460
893
|
collapseBreakpoint = "sm",
|
|
461
894
|
closeMobileNavigationOnItemSelect = true
|
|
462
895
|
}) {
|
|
463
|
-
const { t } =
|
|
896
|
+
const { t } = useGdsTranslation9();
|
|
464
897
|
const mobileNavigationLabel = mobileNavigationLabelProp ?? t("gds.discoveryShell.mobileNavigationLabel", "Toggle navigation");
|
|
465
898
|
const desktopNavigationLabel = desktopNavigationLabelProp ?? t("gds.discoveryShell.desktopNavigationLabel", "Toggle sidebar");
|
|
466
899
|
const isMobile = useMediaQuery2(`(max-width: ${gdsBreakpointByAlias[collapseBreakpoint]})`);
|
|
@@ -472,7 +905,7 @@ function DiscoveryShell({
|
|
|
472
905
|
"--app-shell-navbar-transform": "translateX(0)",
|
|
473
906
|
"--app-shell-navbar-transform-rtl": "translateX(0)"
|
|
474
907
|
} : void 0;
|
|
475
|
-
return /* @__PURE__ */
|
|
908
|
+
return /* @__PURE__ */ jsxs8(
|
|
476
909
|
MantineAppShell,
|
|
477
910
|
{
|
|
478
911
|
header: { height: headerHeight },
|
|
@@ -487,8 +920,8 @@ function DiscoveryShell({
|
|
|
487
920
|
},
|
|
488
921
|
padding: shellPadding,
|
|
489
922
|
children: [
|
|
490
|
-
/* @__PURE__ */
|
|
491
|
-
hideMobileNavigationToggle ? null : /* @__PURE__ */
|
|
923
|
+
/* @__PURE__ */ jsx13(MantineAppShell.Header, { children: /* @__PURE__ */ jsxs8(Group6, { h: "100%", px: "md", gap: "sm", wrap: "nowrap", children: [
|
|
924
|
+
hideMobileNavigationToggle ? null : /* @__PURE__ */ jsx13(
|
|
492
925
|
Burger,
|
|
493
926
|
{
|
|
494
927
|
opened,
|
|
@@ -498,7 +931,7 @@ function DiscoveryShell({
|
|
|
498
931
|
"aria-label": mobileNavigationLabel
|
|
499
932
|
}
|
|
500
933
|
),
|
|
501
|
-
desktopCollapsible ? /* @__PURE__ */
|
|
934
|
+
desktopCollapsible ? /* @__PURE__ */ jsx13(
|
|
502
935
|
Burger,
|
|
503
936
|
{
|
|
504
937
|
opened,
|
|
@@ -508,9 +941,9 @@ function DiscoveryShell({
|
|
|
508
941
|
"aria-label": desktopNavigationLabel
|
|
509
942
|
}
|
|
510
943
|
) : null,
|
|
511
|
-
/* @__PURE__ */
|
|
944
|
+
/* @__PURE__ */ jsx13(Box5, { style: { flex: 1, minWidth: 0 }, children: header })
|
|
512
945
|
] }) }),
|
|
513
|
-
/* @__PURE__ */
|
|
946
|
+
/* @__PURE__ */ jsx13(
|
|
514
947
|
MantineAppShell.Navbar,
|
|
515
948
|
{
|
|
516
949
|
p: "md",
|
|
@@ -521,8 +954,8 @@ function DiscoveryShell({
|
|
|
521
954
|
close();
|
|
522
955
|
}
|
|
523
956
|
},
|
|
524
|
-
children: /* @__PURE__ */
|
|
525
|
-
|
|
957
|
+
children: /* @__PURE__ */ jsx13(ScrollArea, { h: "100%", type: "auto", children: /* @__PURE__ */ jsx13(
|
|
958
|
+
Box5,
|
|
526
959
|
{
|
|
527
960
|
h: "100%",
|
|
528
961
|
style: stickySidebar ? {
|
|
@@ -534,8 +967,8 @@ function DiscoveryShell({
|
|
|
534
967
|
) })
|
|
535
968
|
}
|
|
536
969
|
),
|
|
537
|
-
footer ? /* @__PURE__ */
|
|
538
|
-
/* @__PURE__ */
|
|
970
|
+
footer ? /* @__PURE__ */ jsx13(MantineAppShell.Footer, { children: /* @__PURE__ */ jsx13(Group6, { h: "100%", px: "md", justify: "space-around", wrap: "nowrap", children: footer }) }) : null,
|
|
971
|
+
/* @__PURE__ */ jsx13(
|
|
539
972
|
MantineAppShell.Main,
|
|
540
973
|
{
|
|
541
974
|
onClick: () => {
|
|
@@ -552,25 +985,25 @@ function DiscoveryShell({
|
|
|
552
985
|
}
|
|
553
986
|
|
|
554
987
|
// src/DocsShell.tsx
|
|
555
|
-
import { useState as
|
|
556
|
-
import { Box as
|
|
557
|
-
import { useGdsTranslation as
|
|
558
|
-
import { Fragment as
|
|
988
|
+
import { useState as useState5 } from "react";
|
|
989
|
+
import { Box as Box6, Burger as Burger2, Container, Divider as Divider2, Group as Group7, NativeSelect, Paper as Paper4, Stack as Stack3, Text as Text8, Transition } from "@mantine/core";
|
|
990
|
+
import { useGdsTranslation as useGdsTranslation10 } from "@sovereignsquad/gds-theme";
|
|
991
|
+
import { Fragment as Fragment3, jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
559
992
|
var navigationActivationSelector2 = 'a[href], button, [role="menuitem"], [data-gds-nav-close]';
|
|
560
993
|
function isNavigationActivationTarget2(target) {
|
|
561
994
|
return target instanceof HTMLElement && Boolean(target.closest(navigationActivationSelector2));
|
|
562
995
|
}
|
|
563
996
|
function DocsShellSidebar({ primaryNavigation, secondaryNavigation }) {
|
|
564
|
-
const { t } =
|
|
565
|
-
return /* @__PURE__ */
|
|
566
|
-
primaryNavigation ? /* @__PURE__ */
|
|
567
|
-
/* @__PURE__ */
|
|
997
|
+
const { t } = useGdsTranslation10();
|
|
998
|
+
return /* @__PURE__ */ jsxs9(Stack3, { gap: "md", h: "100%", children: [
|
|
999
|
+
primaryNavigation ? /* @__PURE__ */ jsxs9(Stack3, { gap: "xs", children: [
|
|
1000
|
+
/* @__PURE__ */ jsx14(Text8, { size: "xs", fw: 700, c: "dimmed", children: t("gds.navigation.primary", "Primary") }),
|
|
568
1001
|
primaryNavigation
|
|
569
1002
|
] }) : null,
|
|
570
|
-
secondaryNavigation ? /* @__PURE__ */
|
|
571
|
-
/* @__PURE__ */
|
|
572
|
-
/* @__PURE__ */
|
|
573
|
-
/* @__PURE__ */
|
|
1003
|
+
secondaryNavigation ? /* @__PURE__ */ jsxs9(Fragment3, { children: [
|
|
1004
|
+
/* @__PURE__ */ jsx14(Divider2, {}),
|
|
1005
|
+
/* @__PURE__ */ jsxs9(Stack3, { gap: "xs", children: [
|
|
1006
|
+
/* @__PURE__ */ jsx14(Text8, { size: "xs", fw: 700, c: "dimmed", children: t("gds.navigation.more", "More") }),
|
|
574
1007
|
secondaryNavigation
|
|
575
1008
|
] })
|
|
576
1009
|
] }) : null
|
|
@@ -589,7 +1022,7 @@ function DocsHeaderActionSelect({
|
|
|
589
1022
|
onChange,
|
|
590
1023
|
...props
|
|
591
1024
|
}) {
|
|
592
|
-
return /* @__PURE__ */
|
|
1025
|
+
return /* @__PURE__ */ jsx14(
|
|
593
1026
|
NativeSelect,
|
|
594
1027
|
{
|
|
595
1028
|
"aria-label": label,
|
|
@@ -618,13 +1051,13 @@ function DocsShell({
|
|
|
618
1051
|
children,
|
|
619
1052
|
contentWidth = "full"
|
|
620
1053
|
}) {
|
|
621
|
-
const [mobileNavOpen, setMobileNavOpen] =
|
|
622
|
-
const { t } =
|
|
623
|
-
return /* @__PURE__ */
|
|
1054
|
+
const [mobileNavOpen, setMobileNavOpen] = useState5(false);
|
|
1055
|
+
const { t } = useGdsTranslation10();
|
|
1056
|
+
return /* @__PURE__ */ jsx14(
|
|
624
1057
|
DiscoveryShell,
|
|
625
1058
|
{
|
|
626
|
-
header: /* @__PURE__ */
|
|
627
|
-
|
|
1059
|
+
header: /* @__PURE__ */ jsxs9(
|
|
1060
|
+
Box6,
|
|
628
1061
|
{
|
|
629
1062
|
"data-gds-docs-shell-header": true,
|
|
630
1063
|
h: "100%",
|
|
@@ -638,8 +1071,8 @@ function DocsShell({
|
|
|
638
1071
|
overflow: "hidden"
|
|
639
1072
|
},
|
|
640
1073
|
children: [
|
|
641
|
-
/* @__PURE__ */
|
|
642
|
-
|
|
1074
|
+
/* @__PURE__ */ jsxs9(
|
|
1075
|
+
Group7,
|
|
643
1076
|
{
|
|
644
1077
|
"data-gds-docs-shell-brand-row": true,
|
|
645
1078
|
gap: "sm",
|
|
@@ -648,8 +1081,8 @@ function DocsShell({
|
|
|
648
1081
|
miw: 0,
|
|
649
1082
|
style: { overflow: "hidden" },
|
|
650
1083
|
children: [
|
|
651
|
-
mobileNavigationMode === "inline-collapse" && mobileNavigation ? /* @__PURE__ */
|
|
652
|
-
/* @__PURE__ */
|
|
1084
|
+
mobileNavigationMode === "inline-collapse" && mobileNavigation ? /* @__PURE__ */ jsxs9(Fragment3, { children: [
|
|
1085
|
+
/* @__PURE__ */ jsx14(
|
|
653
1086
|
Burger2,
|
|
654
1087
|
{
|
|
655
1088
|
opened: mobileNavOpen,
|
|
@@ -659,8 +1092,8 @@ function DocsShell({
|
|
|
659
1092
|
"aria-label": t("gds.navigation.openMobile", "Open docs navigation")
|
|
660
1093
|
}
|
|
661
1094
|
),
|
|
662
|
-
/* @__PURE__ */
|
|
663
|
-
|
|
1095
|
+
/* @__PURE__ */ jsx14(Transition, { mounted: mobileNavOpen, transition: "pop", duration: 120, children: (styles) => /* @__PURE__ */ jsx14(Box6, { style: styles, children: /* @__PURE__ */ jsx14(
|
|
1096
|
+
Paper4,
|
|
664
1097
|
{
|
|
665
1098
|
mt: "xs",
|
|
666
1099
|
p: "sm",
|
|
@@ -675,8 +1108,8 @@ function DocsShell({
|
|
|
675
1108
|
}
|
|
676
1109
|
) }) })
|
|
677
1110
|
] }) : null,
|
|
678
|
-
/* @__PURE__ */
|
|
679
|
-
|
|
1111
|
+
/* @__PURE__ */ jsx14(
|
|
1112
|
+
Box6,
|
|
680
1113
|
{
|
|
681
1114
|
"data-gds-docs-shell-brand": true,
|
|
682
1115
|
flex: "1 1 auto",
|
|
@@ -691,12 +1124,12 @@ function DocsShell({
|
|
|
691
1124
|
children: brand
|
|
692
1125
|
}
|
|
693
1126
|
),
|
|
694
|
-
headerContext ? /* @__PURE__ */
|
|
1127
|
+
headerContext ? /* @__PURE__ */ jsx14(Text8, { visibleFrom: "sm", size: "sm", c: "dimmed", lineClamp: 1, miw: 0, flex: "0 1 auto", children: headerContext }) : null
|
|
695
1128
|
]
|
|
696
1129
|
}
|
|
697
1130
|
),
|
|
698
|
-
/* @__PURE__ */
|
|
699
|
-
|
|
1131
|
+
/* @__PURE__ */ jsx14(
|
|
1132
|
+
Group7,
|
|
700
1133
|
{
|
|
701
1134
|
"data-gds-docs-shell-actions": true,
|
|
702
1135
|
gap: "xs",
|
|
@@ -711,7 +1144,7 @@ function DocsShell({
|
|
|
711
1144
|
]
|
|
712
1145
|
}
|
|
713
1146
|
),
|
|
714
|
-
sidebar: /* @__PURE__ */
|
|
1147
|
+
sidebar: /* @__PURE__ */ jsx14(
|
|
715
1148
|
DocsShellSidebar,
|
|
716
1149
|
{
|
|
717
1150
|
primaryNavigation,
|
|
@@ -722,25 +1155,26 @@ function DocsShell({
|
|
|
722
1155
|
mobileNavigationLabel: t("gds.navigation.openMobile", "Open docs navigation"),
|
|
723
1156
|
hideMobileNavigationToggle: mobileNavigationMode === "inline-collapse" && Boolean(mobileNavigation),
|
|
724
1157
|
headerHeight: 72,
|
|
725
|
-
children: /* @__PURE__ */
|
|
1158
|
+
children: /* @__PURE__ */ jsx14(Container, { size: resolveContentContainerSize(contentWidth), px: "md", py: "lg", w: "100%", children })
|
|
726
1159
|
}
|
|
727
1160
|
);
|
|
728
1161
|
}
|
|
729
1162
|
|
|
730
1163
|
// src/SidebarNav.tsx
|
|
731
1164
|
import { forwardRef } from "react";
|
|
732
|
-
import { Box as
|
|
733
|
-
import {
|
|
734
|
-
import {
|
|
1165
|
+
import { Box as Box7, NavLink, Stack as Stack4, Text as Text9, createPolymorphicComponent } from "@mantine/core";
|
|
1166
|
+
import { useUncontrolled as useUncontrolled2 } from "@mantine/hooks";
|
|
1167
|
+
import { useGdsTranslation as useGdsTranslation11 } from "@sovereignsquad/gds-theme";
|
|
1168
|
+
import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
735
1169
|
function SidebarNav({ children, ariaLabel: ariaLabelProp, gap = "md" }) {
|
|
736
|
-
const { t } =
|
|
1170
|
+
const { t } = useGdsTranslation11();
|
|
737
1171
|
const ariaLabel = ariaLabelProp ?? t("gds.sidebarNav.ariaLabel", "Primary navigation");
|
|
738
|
-
return /* @__PURE__ */
|
|
1172
|
+
return /* @__PURE__ */ jsx15(Stack4, { component: "nav", "aria-label": ariaLabel, gap, h: "100%", children });
|
|
739
1173
|
}
|
|
740
1174
|
function SidebarNavSection({ label, children, pushToBottom = false }) {
|
|
741
|
-
return /* @__PURE__ */
|
|
742
|
-
label ? /* @__PURE__ */
|
|
743
|
-
/* @__PURE__ */
|
|
1175
|
+
return /* @__PURE__ */ jsxs10(Stack4, { gap: "xs", mt: pushToBottom ? "auto" : void 0, children: [
|
|
1176
|
+
label ? /* @__PURE__ */ jsx15(Text9, { size: "xs", fw: 700, c: "dimmed", children: label }) : null,
|
|
1177
|
+
/* @__PURE__ */ jsx15(Stack4, { gap: 4, children })
|
|
744
1178
|
] });
|
|
745
1179
|
}
|
|
746
1180
|
var _SidebarNavItem = forwardRef(
|
|
@@ -753,23 +1187,34 @@ var _SidebarNavItem = forwardRef(
|
|
|
753
1187
|
"aria-label": ariaLabel,
|
|
754
1188
|
"aria-current": ariaCurrent,
|
|
755
1189
|
vocabularyPacks = [],
|
|
1190
|
+
children,
|
|
1191
|
+
opened: openedProp,
|
|
1192
|
+
defaultOpened,
|
|
1193
|
+
onChange,
|
|
1194
|
+
childrenOffset = "var(--gds-space-md)",
|
|
756
1195
|
...props
|
|
757
1196
|
}, ref) => {
|
|
758
|
-
const { t } =
|
|
1197
|
+
const { t } = useGdsTranslation11();
|
|
1198
|
+
const hasChildren = Boolean(children);
|
|
1199
|
+
const [opened, setOpened] = useUncontrolled2({ value: openedProp, defaultValue: defaultOpened, finalValue: false, onChange });
|
|
1200
|
+
const disclosureProps = hasChildren ? { component: "button", type: "button", "aria-expanded": opened, opened, onChange: setOpened } : {};
|
|
759
1201
|
const config = action ? resolveSemanticActionConfig(action, vocabularyPacks) : null;
|
|
760
1202
|
const Icon = config?.icon;
|
|
761
1203
|
const resolvedLabel = label ?? (action ? getSemanticActionLabel(action, t, vocabularyPacks) : void 0);
|
|
762
|
-
return /* @__PURE__ */
|
|
1204
|
+
return /* @__PURE__ */ jsx15(
|
|
763
1205
|
NavLink,
|
|
764
1206
|
{
|
|
765
1207
|
ref,
|
|
766
1208
|
label: resolvedLabel,
|
|
767
1209
|
description,
|
|
768
|
-
leftSection: icon ?? (Icon ? /* @__PURE__ */
|
|
769
|
-
rightSection: badge ? /* @__PURE__ */
|
|
1210
|
+
leftSection: icon ?? (Icon ? /* @__PURE__ */ jsx15(Icon, { size: "1rem", stroke: 1.5 }) : void 0),
|
|
1211
|
+
rightSection: badge ? /* @__PURE__ */ jsx15(Box7, { children: badge }) : props.rightSection,
|
|
770
1212
|
"aria-label": ariaLabel ?? (typeof resolvedLabel === "string" ? resolvedLabel : void 0),
|
|
771
1213
|
"aria-current": props.active ? "page" : ariaCurrent,
|
|
772
|
-
|
|
1214
|
+
childrenOffset,
|
|
1215
|
+
...disclosureProps,
|
|
1216
|
+
...props,
|
|
1217
|
+
children
|
|
773
1218
|
}
|
|
774
1219
|
);
|
|
775
1220
|
}
|
|
@@ -777,11 +1222,11 @@ var _SidebarNavItem = forwardRef(
|
|
|
777
1222
|
var SidebarNavItem = createPolymorphicComponent(_SidebarNavItem);
|
|
778
1223
|
|
|
779
1224
|
// src/DocsCodeBlock.tsx
|
|
780
|
-
import { useState as
|
|
781
|
-
import { ActionIcon, Code, Group as
|
|
782
|
-
import { jsx as
|
|
1225
|
+
import { useState as useState6 } from "react";
|
|
1226
|
+
import { ActionIcon, Code, Group as Group8, Paper as Paper5, Stack as Stack5, Text as Text10 } from "@mantine/core";
|
|
1227
|
+
import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
783
1228
|
function DocsCodeBlock({ code, language, title, withCopy = true }) {
|
|
784
|
-
const [copied, setCopied] =
|
|
1229
|
+
const [copied, setCopied] = useState6(false);
|
|
785
1230
|
const handleCopy = async () => {
|
|
786
1231
|
if (!navigator?.clipboard) {
|
|
787
1232
|
return;
|
|
@@ -790,13 +1235,13 @@ function DocsCodeBlock({ code, language, title, withCopy = true }) {
|
|
|
790
1235
|
setCopied(true);
|
|
791
1236
|
window.setTimeout(() => setCopied(false), 1200);
|
|
792
1237
|
};
|
|
793
|
-
return /* @__PURE__ */
|
|
794
|
-
title || withCopy ? /* @__PURE__ */
|
|
795
|
-
/* @__PURE__ */
|
|
796
|
-
title ? /* @__PURE__ */
|
|
797
|
-
language ? /* @__PURE__ */
|
|
1238
|
+
return /* @__PURE__ */ jsx16(Paper5, { withBorder: true, radius: "lg", p: "md", children: /* @__PURE__ */ jsxs11(Stack5, { gap: "sm", children: [
|
|
1239
|
+
title || withCopy ? /* @__PURE__ */ jsxs11(Group8, { justify: "space-between", align: "center", children: [
|
|
1240
|
+
/* @__PURE__ */ jsxs11(Stack5, { gap: 0, children: [
|
|
1241
|
+
title ? /* @__PURE__ */ jsx16(Text10, { fw: 600, children: title }) : null,
|
|
1242
|
+
language ? /* @__PURE__ */ jsx16(Text10, { size: "xs", c: "dimmed", children: language }) : null
|
|
798
1243
|
] }),
|
|
799
|
-
withCopy ? /* @__PURE__ */
|
|
1244
|
+
withCopy ? /* @__PURE__ */ jsx16(
|
|
800
1245
|
ActionIcon,
|
|
801
1246
|
{
|
|
802
1247
|
"data-gds-copy-action": true,
|
|
@@ -806,19 +1251,19 @@ function DocsCodeBlock({ code, language, title, withCopy = true }) {
|
|
|
806
1251
|
onClick: () => {
|
|
807
1252
|
void handleCopy();
|
|
808
1253
|
},
|
|
809
|
-
children: /* @__PURE__ */
|
|
1254
|
+
children: /* @__PURE__ */ jsx16(GdsIcons.Copy, { size: "1rem" })
|
|
810
1255
|
}
|
|
811
1256
|
) : null
|
|
812
1257
|
] }) : null,
|
|
813
|
-
/* @__PURE__ */
|
|
1258
|
+
/* @__PURE__ */ jsx16(Code, { block: true, children: code })
|
|
814
1259
|
] }) });
|
|
815
1260
|
}
|
|
816
1261
|
|
|
817
1262
|
// src/ShareButtonGroup.tsx
|
|
818
|
-
import { useGdsTranslation as
|
|
819
|
-
import { useState as
|
|
820
|
-
import { ActionIcon as ActionIcon2, Button as
|
|
821
|
-
import { jsx as
|
|
1263
|
+
import { useGdsTranslation as useGdsTranslation12 } from "@sovereignsquad/gds-theme";
|
|
1264
|
+
import { useState as useState7 } from "react";
|
|
1265
|
+
import { ActionIcon as ActionIcon2, Button as Button5, Group as Group9, Stack as Stack6, Text as Text11 } from "@mantine/core";
|
|
1266
|
+
import { jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
822
1267
|
var channelLabels = {
|
|
823
1268
|
native: "Share",
|
|
824
1269
|
copy: "Copy link",
|
|
@@ -853,9 +1298,9 @@ function ShareAction({
|
|
|
853
1298
|
const label = channelLabels[channel];
|
|
854
1299
|
const Icon = channel === "copy" ? GdsIcons.Copy : channel === "mail" ? GdsIcons.Mail : channel === "message" ? GdsIcons.Message : GdsIcons.Refer;
|
|
855
1300
|
if (compact) {
|
|
856
|
-
return href ? /* @__PURE__ */
|
|
1301
|
+
return href ? /* @__PURE__ */ jsx17(ActionIcon2, { component: "a", href, target: "_blank", rel: "noreferrer", variant: "subtle", size: "lg", "aria-label": label, children: /* @__PURE__ */ jsx17(Icon, { size: "1rem", stroke: 1.75 }) }) : /* @__PURE__ */ jsx17(ActionIcon2, { variant: "subtle", size: "lg", "aria-label": label, onClick, children: /* @__PURE__ */ jsx17(Icon, { size: "1rem", stroke: 1.75 }) });
|
|
857
1302
|
}
|
|
858
|
-
return href ? /* @__PURE__ */
|
|
1303
|
+
return href ? /* @__PURE__ */ jsx17(Button5, { component: "a", href, target: "_blank", rel: "noreferrer", variant: "default", leftSection: /* @__PURE__ */ jsx17(Icon, { size: "1rem", stroke: 1.75 }), children: label }) : /* @__PURE__ */ jsx17(Button5, { variant: "default", leftSection: /* @__PURE__ */ jsx17(Icon, { size: "1rem", stroke: 1.75 }), onClick, children: label });
|
|
859
1304
|
}
|
|
860
1305
|
function ShareButtonGroup({
|
|
861
1306
|
url,
|
|
@@ -866,10 +1311,10 @@ function ShareButtonGroup({
|
|
|
866
1311
|
label: labelProp,
|
|
867
1312
|
description
|
|
868
1313
|
}) {
|
|
869
|
-
const { t } =
|
|
1314
|
+
const { t } = useGdsTranslation12();
|
|
870
1315
|
const label = labelProp ?? t("gds.shareButtonGroup.label", "Share this");
|
|
871
|
-
const [copied, setCopied] =
|
|
872
|
-
const [shared, setShared] =
|
|
1316
|
+
const [copied, setCopied] = useState7(false);
|
|
1317
|
+
const [shared, setShared] = useState7(false);
|
|
873
1318
|
const hrefs = encodeShare(url, title, text);
|
|
874
1319
|
async function handleCopy() {
|
|
875
1320
|
await navigator.clipboard?.writeText?.(url);
|
|
@@ -885,30 +1330,30 @@ function ShareButtonGroup({
|
|
|
885
1330
|
}
|
|
886
1331
|
await handleCopy();
|
|
887
1332
|
}
|
|
888
|
-
return /* @__PURE__ */
|
|
889
|
-
/* @__PURE__ */
|
|
890
|
-
/* @__PURE__ */
|
|
891
|
-
description ? /* @__PURE__ */
|
|
1333
|
+
return /* @__PURE__ */ jsxs12(Stack6, { gap: "sm", children: [
|
|
1334
|
+
/* @__PURE__ */ jsxs12(Stack6, { gap: 2, children: [
|
|
1335
|
+
/* @__PURE__ */ jsx17(Text11, { fw: 600, children: label }),
|
|
1336
|
+
description ? /* @__PURE__ */ jsx17(Text11, { size: "sm", c: "dimmed", children: description }) : null
|
|
892
1337
|
] }),
|
|
893
|
-
/* @__PURE__ */
|
|
1338
|
+
/* @__PURE__ */ jsx17(Group9, { gap: "sm", wrap: "wrap", children: channels.map((channel) => {
|
|
894
1339
|
if (channel === "copy") {
|
|
895
|
-
return /* @__PURE__ */
|
|
1340
|
+
return /* @__PURE__ */ jsx17(ShareAction, { channel, compact, onClick: () => void handleCopy() }, channel);
|
|
896
1341
|
}
|
|
897
1342
|
if (channel === "native") {
|
|
898
|
-
return /* @__PURE__ */
|
|
1343
|
+
return /* @__PURE__ */ jsx17(ShareAction, { channel, compact, onClick: () => void handleNativeShare() }, channel);
|
|
899
1344
|
}
|
|
900
|
-
return /* @__PURE__ */
|
|
1345
|
+
return /* @__PURE__ */ jsx17(ShareAction, { channel, compact, href: hrefs[channel] }, channel);
|
|
901
1346
|
}) }),
|
|
902
|
-
copied ? /* @__PURE__ */
|
|
903
|
-
shared ? /* @__PURE__ */
|
|
1347
|
+
copied ? /* @__PURE__ */ jsx17(Text11, { size: "sm", c: "teal", children: "Link copied." }) : null,
|
|
1348
|
+
shared ? /* @__PURE__ */ jsx17(Text11, { size: "sm", c: "teal", children: "Share sheet opened." }) : null
|
|
904
1349
|
] });
|
|
905
1350
|
}
|
|
906
1351
|
|
|
907
1352
|
// src/UploadDropzone.tsx
|
|
908
|
-
import { useGdsTranslation as
|
|
909
|
-
import { useRef, useState as
|
|
910
|
-
import { Badge, Box as
|
|
911
|
-
import { jsx as
|
|
1353
|
+
import { useGdsTranslation as useGdsTranslation13 } from "@sovereignsquad/gds-theme";
|
|
1354
|
+
import { useRef as useRef2, useState as useState8 } from "react";
|
|
1355
|
+
import { Badge, Box as Box8, Button as Button6, Group as Group10, Progress, Stack as Stack7, Text as Text12 } from "@mantine/core";
|
|
1356
|
+
import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
912
1357
|
function UploadDropzone({
|
|
913
1358
|
title,
|
|
914
1359
|
description,
|
|
@@ -932,10 +1377,10 @@ function UploadDropzone({
|
|
|
932
1377
|
removeAction,
|
|
933
1378
|
readonly = false
|
|
934
1379
|
}) {
|
|
935
|
-
const { t } =
|
|
1380
|
+
const { t } = useGdsTranslation13();
|
|
936
1381
|
const actionLabel = actionLabelProp ?? t("gds.uploadDropzone.actionLabel", "Choose files");
|
|
937
|
-
const inputRef =
|
|
938
|
-
const [dragging, setDragging] =
|
|
1382
|
+
const inputRef = useRef2(null);
|
|
1383
|
+
const [dragging, setDragging] = useState8(false);
|
|
939
1384
|
const UploadIcon = GdsIcons.Upload;
|
|
940
1385
|
const effectiveState = readonly ? "readonly" : dragging ? "drag-active" : state;
|
|
941
1386
|
const isDisabled = readonly || effectiveState === "upload-pending";
|
|
@@ -947,8 +1392,8 @@ function UploadDropzone({
|
|
|
947
1392
|
}
|
|
948
1393
|
onFilesSelected(Array.from(files));
|
|
949
1394
|
};
|
|
950
|
-
return /* @__PURE__ */
|
|
951
|
-
|
|
1395
|
+
return /* @__PURE__ */ jsxs13(
|
|
1396
|
+
Box8,
|
|
952
1397
|
{
|
|
953
1398
|
onDragOver: (event) => {
|
|
954
1399
|
event.preventDefault();
|
|
@@ -971,7 +1416,7 @@ function UploadDropzone({
|
|
|
971
1416
|
},
|
|
972
1417
|
"aria-invalid": isError || void 0,
|
|
973
1418
|
children: [
|
|
974
|
-
/* @__PURE__ */
|
|
1419
|
+
/* @__PURE__ */ jsx18(
|
|
975
1420
|
"input",
|
|
976
1421
|
{
|
|
977
1422
|
id: inputId,
|
|
@@ -988,30 +1433,30 @@ function UploadDropzone({
|
|
|
988
1433
|
onChange: (event) => forwardFiles(event.currentTarget.files)
|
|
989
1434
|
}
|
|
990
1435
|
),
|
|
991
|
-
/* @__PURE__ */
|
|
992
|
-
/* @__PURE__ */
|
|
993
|
-
/* @__PURE__ */
|
|
994
|
-
/* @__PURE__ */
|
|
995
|
-
description ? /* @__PURE__ */
|
|
996
|
-
acceptedTypesLabel || maxSizeLabel ? /* @__PURE__ */
|
|
997
|
-
acceptedTypesLabel ? /* @__PURE__ */
|
|
998
|
-
maxSizeLabel ? /* @__PURE__ */
|
|
1436
|
+
/* @__PURE__ */ jsxs13(Stack7, { align: mode === "inline" ? "flex-start" : "center", ta: mode === "inline" ? "left" : "center", gap: "sm", children: [
|
|
1437
|
+
/* @__PURE__ */ jsx18(UploadIcon, { size: "1.5rem" }),
|
|
1438
|
+
/* @__PURE__ */ jsx18(Badge, { variant: "light", color: isError ? "red" : effectiveState === "selected" ? "blue" : effectiveState === "upload-pending" ? "violet" : "gray", children: effectiveState.replace("-", " ") }),
|
|
1439
|
+
/* @__PURE__ */ jsx18(Text12, { fw: 600, children: title }),
|
|
1440
|
+
description ? /* @__PURE__ */ jsx18(Text12, { size: "sm", c: "dimmed", children: description }) : null,
|
|
1441
|
+
acceptedTypesLabel || maxSizeLabel ? /* @__PURE__ */ jsxs13(Group10, { gap: "xs", justify: mode === "inline" ? "flex-start" : "center", children: [
|
|
1442
|
+
acceptedTypesLabel ? /* @__PURE__ */ jsx18(Badge, { variant: "outline", color: "gray", children: acceptedTypesLabel }) : null,
|
|
1443
|
+
maxSizeLabel ? /* @__PURE__ */ jsx18(Badge, { variant: "outline", color: "gray", children: maxSizeLabel }) : null
|
|
999
1444
|
] }) : null,
|
|
1000
|
-
selectedFiles.length ? /* @__PURE__ */
|
|
1445
|
+
selectedFiles.length ? /* @__PURE__ */ jsxs13(Text12, { size: "sm", children: [
|
|
1001
1446
|
"Selected: ",
|
|
1002
1447
|
selectedFiles.join(", ")
|
|
1003
1448
|
] }) : null,
|
|
1004
|
-
effectiveState === "upload-pending" && normalizedProgress !== void 0 ? /* @__PURE__ */
|
|
1005
|
-
/* @__PURE__ */
|
|
1006
|
-
/* @__PURE__ */
|
|
1449
|
+
effectiveState === "upload-pending" && normalizedProgress !== void 0 ? /* @__PURE__ */ jsxs13(Box8, { w: "100%", maw: 360, children: [
|
|
1450
|
+
/* @__PURE__ */ jsx18(Progress, { value: normalizedProgress, "aria-label": `${title} upload progress` }),
|
|
1451
|
+
/* @__PURE__ */ jsxs13(Text12, { size: "xs", c: "dimmed", mt: 4, children: [
|
|
1007
1452
|
Math.round(normalizedProgress),
|
|
1008
1453
|
"% uploaded"
|
|
1009
1454
|
] })
|
|
1010
1455
|
] }) : null,
|
|
1011
|
-
policyText ? /* @__PURE__ */
|
|
1012
|
-
error ? /* @__PURE__ */
|
|
1013
|
-
/* @__PURE__ */
|
|
1014
|
-
/* @__PURE__ */
|
|
1456
|
+
policyText ? /* @__PURE__ */ jsx18(Text12, { size: "sm", c: isError ? "red.7" : "dimmed", children: policyText }) : null,
|
|
1457
|
+
error ? /* @__PURE__ */ jsx18(Text12, { size: "sm", c: "red.7", role: "alert", children: error }) : null,
|
|
1458
|
+
/* @__PURE__ */ jsxs13(Group10, { children: [
|
|
1459
|
+
/* @__PURE__ */ jsx18(Button6, { variant: "light", onClick: () => inputRef.current?.click(), disabled: isDisabled, children: actionLabel }),
|
|
1015
1460
|
retryAction,
|
|
1016
1461
|
removeAction
|
|
1017
1462
|
] })
|
|
@@ -1022,9 +1467,9 @@ function UploadDropzone({
|
|
|
1022
1467
|
}
|
|
1023
1468
|
|
|
1024
1469
|
// src/GdsAssetManager.client.tsx
|
|
1025
|
-
import { useCallback, useMemo as
|
|
1026
|
-
import { Button as
|
|
1027
|
-
import { jsx as
|
|
1470
|
+
import { useCallback as useCallback2, useMemo as useMemo3, useState as useState9 } from "react";
|
|
1471
|
+
import { Button as Button7, Group as Group11, Stack as Stack8, Text as Text13, TextInput } from "@mantine/core";
|
|
1472
|
+
import { jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1028
1473
|
function emitAssetEvent(onEvent, type, message) {
|
|
1029
1474
|
onEvent?.({ type, message, timestamp: Date.now(), privacy: "metadata-only" });
|
|
1030
1475
|
}
|
|
@@ -1067,8 +1512,8 @@ function useGdsAssetUploadQueue({
|
|
|
1067
1512
|
onEvent,
|
|
1068
1513
|
timeoutMs = 1e4
|
|
1069
1514
|
}) {
|
|
1070
|
-
const [items, setItems] =
|
|
1071
|
-
const uploadItem =
|
|
1515
|
+
const [items, setItems] = useState9([]);
|
|
1516
|
+
const uploadItem = useCallback2(async (item) => {
|
|
1072
1517
|
if (!item.file) return;
|
|
1073
1518
|
const controller = new AbortController();
|
|
1074
1519
|
const timer = window.setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -1091,7 +1536,7 @@ function useGdsAssetUploadQueue({
|
|
|
1091
1536
|
window.clearTimeout(timer);
|
|
1092
1537
|
}
|
|
1093
1538
|
}, [adapter, onEvent, policy, timeoutMs]);
|
|
1094
|
-
const selectFiles =
|
|
1539
|
+
const selectFiles = useCallback2(async (files) => {
|
|
1095
1540
|
for (const file of files) {
|
|
1096
1541
|
const id = assetIdFromFile(file);
|
|
1097
1542
|
emitAssetEvent(onEvent, "asset_selected");
|
|
@@ -1105,16 +1550,16 @@ function useGdsAssetUploadQueue({
|
|
|
1105
1550
|
}
|
|
1106
1551
|
}
|
|
1107
1552
|
}, [onEvent, policy, uploadItem]);
|
|
1108
|
-
const retry =
|
|
1553
|
+
const retry = useCallback2(async (itemId) => {
|
|
1109
1554
|
const item = items.find((entry) => entry.id === itemId);
|
|
1110
1555
|
if (item) await uploadItem(item);
|
|
1111
1556
|
}, [items, uploadItem]);
|
|
1112
|
-
const remove =
|
|
1557
|
+
const remove = useCallback2(async (itemId) => {
|
|
1113
1558
|
const item = items.find((entry) => entry.id === itemId);
|
|
1114
1559
|
if (item?.asset) await adapter.remove?.(item.asset.id);
|
|
1115
1560
|
setItems((current) => current.filter((entry) => entry.id !== itemId));
|
|
1116
1561
|
}, [adapter, items]);
|
|
1117
|
-
const saveMetadata =
|
|
1562
|
+
const saveMetadata = useCallback2((itemId, metadata) => {
|
|
1118
1563
|
setItems((current) => current.map((entry) => {
|
|
1119
1564
|
if (entry.id !== itemId || !entry.asset) return entry;
|
|
1120
1565
|
const asset = { ...entry.asset, ...metadata };
|
|
@@ -1126,7 +1571,7 @@ function useGdsAssetUploadQueue({
|
|
|
1126
1571
|
return { items, selectFiles, retry, remove, saveMetadata };
|
|
1127
1572
|
}
|
|
1128
1573
|
function GdsAssetPreviewCard({ asset, aspectRatio = "1:1" }) {
|
|
1129
|
-
return /* @__PURE__ */
|
|
1574
|
+
return /* @__PURE__ */ jsx19(
|
|
1130
1575
|
MediaPreviewCard,
|
|
1131
1576
|
{
|
|
1132
1577
|
title: asset.fileName,
|
|
@@ -1156,9 +1601,9 @@ function GdsAssetManager({
|
|
|
1156
1601
|
displayMode = "cover"
|
|
1157
1602
|
}) {
|
|
1158
1603
|
const queue = useGdsAssetUploadQueue({ adapter, policy, onEvent, timeoutMs });
|
|
1159
|
-
const accept =
|
|
1160
|
-
return /* @__PURE__ */
|
|
1161
|
-
/* @__PURE__ */
|
|
1604
|
+
const accept = useMemo3(() => policy?.acceptedTypes?.join(",") ?? void 0, [policy]);
|
|
1605
|
+
return /* @__PURE__ */ jsxs14(Stack8, { gap: "md", children: [
|
|
1606
|
+
/* @__PURE__ */ jsx19(
|
|
1162
1607
|
UploadDropzone,
|
|
1163
1608
|
{
|
|
1164
1609
|
title,
|
|
@@ -1174,28 +1619,28 @@ function GdsAssetManager({
|
|
|
1174
1619
|
selectedFiles: queue.items.map((item) => item.fileName)
|
|
1175
1620
|
}
|
|
1176
1621
|
),
|
|
1177
|
-
!queue.items.length ? /* @__PURE__ */
|
|
1178
|
-
queue.items.map((item) => /* @__PURE__ */
|
|
1179
|
-
item.asset ? /* @__PURE__ */
|
|
1180
|
-
item.status === "failed" ? /* @__PURE__ */
|
|
1622
|
+
!queue.items.length ? /* @__PURE__ */ jsx19(StateBlock, { variant: "empty", title: "No assets selected", description: "Choose files to start the governed upload queue.", compact: true }) : null,
|
|
1623
|
+
queue.items.map((item) => /* @__PURE__ */ jsxs14(Stack8, { gap: "xs", children: [
|
|
1624
|
+
item.asset ? /* @__PURE__ */ jsx19(GdsAssetPreviewCard, { asset: { ...item.asset, displayMode } }) : /* @__PURE__ */ jsx19(StateBlock, { variant: item.status === "failed" ? "error" : "loading", title: item.fileName, description: item.error ?? `${item.status} ${item.progress}%`, compact: true }),
|
|
1625
|
+
item.status === "failed" ? /* @__PURE__ */ jsx19(Button7, { onClick: () => {
|
|
1181
1626
|
void queue.retry(item.id);
|
|
1182
1627
|
}, children: "Retry upload" }) : null,
|
|
1183
|
-
item.asset ? /* @__PURE__ */
|
|
1184
|
-
/* @__PURE__ */
|
|
1185
|
-
/* @__PURE__ */
|
|
1186
|
-
/* @__PURE__ */
|
|
1628
|
+
item.asset ? /* @__PURE__ */ jsxs14(Group11, { align: "end", children: [
|
|
1629
|
+
/* @__PURE__ */ jsx19(TextInput, { "aria-label": `Alt text for ${item.fileName}`, label: "Alt text", value: item.asset.alt ?? "", onChange: (event) => queue.saveMetadata(item.id, { alt: event.currentTarget.value, caption: item.asset?.caption, displayMode }) }),
|
|
1630
|
+
/* @__PURE__ */ jsx19(TextInput, { "aria-label": `Caption for ${item.fileName}`, label: "Caption", value: item.asset.caption ?? "", onChange: (event) => queue.saveMetadata(item.id, { alt: item.asset?.alt, caption: event.currentTarget.value, displayMode }) }),
|
|
1631
|
+
/* @__PURE__ */ jsx19(Button7, { variant: "light", color: "red", onClick: () => {
|
|
1187
1632
|
void queue.remove(item.id);
|
|
1188
1633
|
}, children: "Remove" })
|
|
1189
1634
|
] }) : null,
|
|
1190
|
-
item.status === "metadata-incomplete" ? /* @__PURE__ */
|
|
1635
|
+
item.status === "metadata-incomplete" ? /* @__PURE__ */ jsx19(Text13, { role: "alert", size: "sm", c: "red.7", children: "Metadata incomplete. Alt text or caption is required before publish." }) : null
|
|
1191
1636
|
] }, item.id))
|
|
1192
1637
|
] });
|
|
1193
1638
|
}
|
|
1194
1639
|
|
|
1195
1640
|
// src/AccessRecoveryPanel.tsx
|
|
1196
|
-
import { Group as
|
|
1197
|
-
import { useGdsTranslation as
|
|
1198
|
-
import { jsx as
|
|
1641
|
+
import { Group as Group12 } from "@mantine/core";
|
|
1642
|
+
import { useGdsTranslation as useGdsTranslation14 } from "@sovereignsquad/gds-theme";
|
|
1643
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
1199
1644
|
var stateBlockVariantByState = {
|
|
1200
1645
|
unauthenticated: "permission",
|
|
1201
1646
|
"expired-session": "info",
|
|
@@ -1275,7 +1720,7 @@ function ActionGroup({
|
|
|
1275
1720
|
if (actions.length === 0) {
|
|
1276
1721
|
return null;
|
|
1277
1722
|
}
|
|
1278
|
-
return /* @__PURE__ */
|
|
1723
|
+
return /* @__PURE__ */ jsx20(Group12, { gap: "sm", justify: "center", wrap: "wrap", children: actions.map((actionConfig, index) => /* @__PURE__ */ jsx20(
|
|
1279
1724
|
SemanticButton,
|
|
1280
1725
|
{
|
|
1281
1726
|
action: actionConfig.action,
|
|
@@ -1301,7 +1746,7 @@ function AccessRecoveryPanel({
|
|
|
1301
1746
|
supportAction,
|
|
1302
1747
|
compact = false
|
|
1303
1748
|
}) {
|
|
1304
|
-
const { t } =
|
|
1749
|
+
const { t } = useGdsTranslation14();
|
|
1305
1750
|
const defaultCopy = defaultCopyByState[state];
|
|
1306
1751
|
const defaults = defaultActionsForState(state, {
|
|
1307
1752
|
onRetry,
|
|
@@ -1309,14 +1754,14 @@ function AccessRecoveryPanel({
|
|
|
1309
1754
|
onBack,
|
|
1310
1755
|
supportAction
|
|
1311
1756
|
});
|
|
1312
|
-
return /* @__PURE__ */
|
|
1757
|
+
return /* @__PURE__ */ jsx20(
|
|
1313
1758
|
StateBlock,
|
|
1314
1759
|
{
|
|
1315
1760
|
variant: stateBlockVariantByState[state],
|
|
1316
1761
|
compact,
|
|
1317
1762
|
title: title ?? t(`gds.accessRecovery.${state}.title`, defaultCopy.title),
|
|
1318
1763
|
description: description ?? t(`gds.accessRecovery.${state}.description`, defaultCopy.description),
|
|
1319
|
-
action: /* @__PURE__ */
|
|
1764
|
+
action: /* @__PURE__ */ jsx20(
|
|
1320
1765
|
ActionGroup,
|
|
1321
1766
|
{
|
|
1322
1767
|
primaryAction: primaryAction ?? defaults.primary,
|
|
@@ -1330,9 +1775,9 @@ function AccessRecoveryPanel({
|
|
|
1330
1775
|
|
|
1331
1776
|
// src/GdsAccessGate.tsx
|
|
1332
1777
|
import { useEffect as useEffect3, useId } from "react";
|
|
1333
|
-
import { Badge as Badge2, Box as
|
|
1334
|
-
import { gdsDevWarnOnce, useGdsTranslation as
|
|
1335
|
-
import { jsx as
|
|
1778
|
+
import { Badge as Badge2, Box as Box9, Button as Button8, Card, Group as Group13, Skeleton, Stack as Stack9, Text as Text14, Title } from "@mantine/core";
|
|
1779
|
+
import { gdsDevWarnOnce as gdsDevWarnOnce2, useGdsTranslation as useGdsTranslation15 } from "@sovereignsquad/gds-theme";
|
|
1780
|
+
import { jsx as jsx21, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1336
1781
|
var defaultReasonByState = {
|
|
1337
1782
|
locked: "login-required",
|
|
1338
1783
|
"permission-denied": "role-required",
|
|
@@ -1405,7 +1850,7 @@ function GdsAccessGate({
|
|
|
1405
1850
|
onAction,
|
|
1406
1851
|
onEvent
|
|
1407
1852
|
}) {
|
|
1408
|
-
const { t } =
|
|
1853
|
+
const { t } = useGdsTranslation15();
|
|
1409
1854
|
const teaserLabel = teaserLabelProp ?? t("gds.gdsAccessGate.teaserLabel", "Preview");
|
|
1410
1855
|
const headingId = useId();
|
|
1411
1856
|
const sortedActions = sortGdsAccessGateActions(actions);
|
|
@@ -1424,7 +1869,7 @@ function GdsAccessGate({
|
|
|
1424
1869
|
protectedContentPolicy
|
|
1425
1870
|
});
|
|
1426
1871
|
if (validation.length > 0) {
|
|
1427
|
-
|
|
1872
|
+
gdsDevWarnOnce2(
|
|
1428
1873
|
`GdsAccessGate:contract:${validation.join("|")}`,
|
|
1429
1874
|
`GdsAccessGate received an invalid contract: ${validation.join("; ")} Fix the state/reason/action combination \u2014 the gate may render an inconsistent state.`
|
|
1430
1875
|
);
|
|
@@ -1442,7 +1887,7 @@ function GdsAccessGate({
|
|
|
1442
1887
|
void action.onClick?.();
|
|
1443
1888
|
void onAction?.(action);
|
|
1444
1889
|
};
|
|
1445
|
-
return /* @__PURE__ */
|
|
1890
|
+
return /* @__PURE__ */ jsx21(
|
|
1446
1891
|
Card,
|
|
1447
1892
|
{
|
|
1448
1893
|
component: "section",
|
|
@@ -1452,17 +1897,17 @@ function GdsAccessGate({
|
|
|
1452
1897
|
p: "lg",
|
|
1453
1898
|
"data-gds-access-gate": id,
|
|
1454
1899
|
"data-gds-access-state": state,
|
|
1455
|
-
children: /* @__PURE__ */
|
|
1456
|
-
/* @__PURE__ */
|
|
1457
|
-
/* @__PURE__ */
|
|
1458
|
-
/* @__PURE__ */
|
|
1459
|
-
/* @__PURE__ */
|
|
1460
|
-
/* @__PURE__ */
|
|
1900
|
+
children: /* @__PURE__ */ jsxs15(Stack9, { gap: "lg", children: [
|
|
1901
|
+
/* @__PURE__ */ jsxs15(Group13, { justify: "space-between", gap: "md", align: "flex-start", wrap: "wrap", children: [
|
|
1902
|
+
/* @__PURE__ */ jsxs15(Stack9, { gap: 4, children: [
|
|
1903
|
+
/* @__PURE__ */ jsx21(Badge2, { variant: "light", children: teaserLabel }),
|
|
1904
|
+
/* @__PURE__ */ jsx21(Title, { id: headingId, order: 3, children: title }),
|
|
1905
|
+
/* @__PURE__ */ jsx21(Text14, { c: "dimmed", children: description })
|
|
1461
1906
|
] }),
|
|
1462
|
-
entitlementLabel ? /* @__PURE__ */
|
|
1907
|
+
entitlementLabel ? /* @__PURE__ */ jsx21(Badge2, { variant: unlocked ? "filled" : "outline", children: entitlementLabel }) : null
|
|
1463
1908
|
] }),
|
|
1464
|
-
/* @__PURE__ */
|
|
1465
|
-
loading ? /* @__PURE__ */
|
|
1909
|
+
/* @__PURE__ */ jsx21(Box9, { "data-gds-access-preview": true, children: preview }),
|
|
1910
|
+
loading ? /* @__PURE__ */ jsx21(
|
|
1466
1911
|
StateBlock,
|
|
1467
1912
|
{
|
|
1468
1913
|
variant: "loading",
|
|
@@ -1471,11 +1916,11 @@ function GdsAccessGate({
|
|
|
1471
1916
|
compact: true
|
|
1472
1917
|
}
|
|
1473
1918
|
) : null,
|
|
1474
|
-
unlocked ? /* @__PURE__ */
|
|
1475
|
-
!unlocked && softGate && !loading ? /* @__PURE__ */
|
|
1476
|
-
!unlocked && !loading ? /* @__PURE__ */
|
|
1477
|
-
/* @__PURE__ */
|
|
1478
|
-
/* @__PURE__ */
|
|
1919
|
+
unlocked ? /* @__PURE__ */ jsx21(Box9, { "data-gds-access-protected": true, children: renderProtectedContent(protectedContent) }) : null,
|
|
1920
|
+
!unlocked && softGate && !loading ? /* @__PURE__ */ jsx21(Box9, { "data-gds-access-degraded": true, "aria-hidden": !unlocked, inert: !unlocked || void 0, children: renderProtectedContent(protectedContent) }) : null,
|
|
1921
|
+
!unlocked && !loading ? /* @__PURE__ */ jsxs15(Stack9, { gap: "md", "data-gds-access-locked": true, children: [
|
|
1922
|
+
/* @__PURE__ */ jsx21(Box9, { "aria-hidden": "true", children: lockedPlaceholder ?? /* @__PURE__ */ jsx21(Skeleton, { height: 96, radius: "lg" }) }),
|
|
1923
|
+
/* @__PURE__ */ jsx21(
|
|
1479
1924
|
AccessRecoveryPanel,
|
|
1480
1925
|
{
|
|
1481
1926
|
state: recoveryStateForGate(state, reason),
|
|
@@ -1504,8 +1949,8 @@ function GdsAccessGate({
|
|
|
1504
1949
|
} : null
|
|
1505
1950
|
}
|
|
1506
1951
|
),
|
|
1507
|
-
sortedActions.some((action) => action.label) ? /* @__PURE__ */
|
|
1508
|
-
|
|
1952
|
+
sortedActions.some((action) => action.label) ? /* @__PURE__ */ jsx21(Group13, { gap: "xs", wrap: "wrap", children: sortedActions.filter((action) => action.label).map((action) => /* @__PURE__ */ jsx21(
|
|
1953
|
+
Button8,
|
|
1509
1954
|
{
|
|
1510
1955
|
variant: "subtle",
|
|
1511
1956
|
size: "xs",
|
|
@@ -1524,8 +1969,8 @@ function GdsAccessGate({
|
|
|
1524
1969
|
|
|
1525
1970
|
// src/GdsDateInput.client.tsx
|
|
1526
1971
|
import { DateInput, DatePickerInput, DateTimePicker } from "@mantine/dates";
|
|
1527
|
-
import { gdsDevWarnOnce as
|
|
1528
|
-
import { jsx as
|
|
1972
|
+
import { gdsDevWarnOnce as gdsDevWarnOnce3 } from "@sovereignsquad/gds-theme";
|
|
1973
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
1529
1974
|
function resolveDateValue(value) {
|
|
1530
1975
|
if (value instanceof Date) return value;
|
|
1531
1976
|
if (typeof value === "string" && value.length > 0) return new Date(value);
|
|
@@ -1543,7 +1988,7 @@ function warnOnDateBounds(component, minDate, maxDate, values) {
|
|
|
1543
1988
|
const min = resolveBoundDate(minDate);
|
|
1544
1989
|
const max = resolveBoundDate(maxDate);
|
|
1545
1990
|
if (min && max && !Number.isNaN(min.getTime()) && !Number.isNaN(max.getTime()) && min.getTime() > max.getTime()) {
|
|
1546
|
-
|
|
1991
|
+
gdsDevWarnOnce3(
|
|
1547
1992
|
`${component}:min-after-max`,
|
|
1548
1993
|
`${component}: minDate (${isoDay(min)}) is after maxDate (${isoDay(max)}), so no date is selectable. Swap the two bounds.`
|
|
1549
1994
|
);
|
|
@@ -1551,13 +1996,13 @@ function warnOnDateBounds(component, minDate, maxDate, values) {
|
|
|
1551
1996
|
for (const value of values) {
|
|
1552
1997
|
if (!value || Number.isNaN(value.getTime())) continue;
|
|
1553
1998
|
if (min && !Number.isNaN(min.getTime()) && value.getTime() < min.getTime()) {
|
|
1554
|
-
|
|
1999
|
+
gdsDevWarnOnce3(
|
|
1555
2000
|
`${component}:value-before-min`,
|
|
1556
2001
|
`${component}: value (${isoDay(value)}) is before minDate (${isoDay(min)}); it will not be selectable through the calendar.`
|
|
1557
2002
|
);
|
|
1558
2003
|
}
|
|
1559
2004
|
if (max && !Number.isNaN(max.getTime()) && value.getTime() > max.getTime()) {
|
|
1560
|
-
|
|
2005
|
+
gdsDevWarnOnce3(
|
|
1561
2006
|
`${component}:value-after-max`,
|
|
1562
2007
|
`${component}: value (${isoDay(value)}) is after maxDate (${isoDay(max)}); it will not be selectable through the calendar.`
|
|
1563
2008
|
);
|
|
@@ -1566,7 +2011,7 @@ function warnOnDateBounds(component, minDate, maxDate, values) {
|
|
|
1566
2011
|
}
|
|
1567
2012
|
function GdsDateInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
1568
2013
|
warnOnDateBounds("GdsDateInput", minDate, maxDate, [resolveDateValue(value)]);
|
|
1569
|
-
return /* @__PURE__ */
|
|
2014
|
+
return /* @__PURE__ */ jsx22(
|
|
1570
2015
|
DateInput,
|
|
1571
2016
|
{
|
|
1572
2017
|
value: resolveDateValue(value),
|
|
@@ -1580,7 +2025,7 @@ function GdsDateInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
|
1580
2025
|
}
|
|
1581
2026
|
function GdsDateTimeInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
1582
2027
|
warnOnDateBounds("GdsDateTimeInput", minDate, maxDate, [resolveDateValue(value)]);
|
|
1583
|
-
return /* @__PURE__ */
|
|
2028
|
+
return /* @__PURE__ */ jsx22(
|
|
1584
2029
|
DateTimePicker,
|
|
1585
2030
|
{
|
|
1586
2031
|
value: resolveDateValue(value),
|
|
@@ -1594,7 +2039,7 @@ function GdsDateTimeInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
|
1594
2039
|
}
|
|
1595
2040
|
function GdsDateRangeInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
1596
2041
|
warnOnDateBounds("GdsDateRangeInput", minDate, maxDate, value ?? [null, null]);
|
|
1597
|
-
return /* @__PURE__ */
|
|
2042
|
+
return /* @__PURE__ */ jsx22(
|
|
1598
2043
|
DatePickerInput,
|
|
1599
2044
|
{
|
|
1600
2045
|
type: "range",
|
|
@@ -1609,10 +2054,10 @@ function GdsDateRangeInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
|
1609
2054
|
}
|
|
1610
2055
|
|
|
1611
2056
|
// src/GdsForm.client.tsx
|
|
1612
|
-
import { useGdsTranslation as
|
|
1613
|
-
import { createContext as createContext3, useCallback as
|
|
1614
|
-
import { Alert, Anchor, Stack as
|
|
1615
|
-
import { jsx as
|
|
2057
|
+
import { useGdsTranslation as useGdsTranslation16 } from "@sovereignsquad/gds-theme";
|
|
2058
|
+
import { createContext as createContext3, useCallback as useCallback3, useContext as useContext3, useMemo as useMemo4, useReducer as useReducer2, useRef as useRef3, useState as useState10 } from "react";
|
|
2059
|
+
import { Alert, Anchor, Stack as Stack10, Text as Text15 } from "@mantine/core";
|
|
2060
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
1616
2061
|
function createFieldState(value) {
|
|
1617
2062
|
return { value, touched: false, dirty: false };
|
|
1618
2063
|
}
|
|
@@ -1727,7 +2172,7 @@ function useGdsForm({
|
|
|
1727
2172
|
return false;
|
|
1728
2173
|
}
|
|
1729
2174
|
};
|
|
1730
|
-
return
|
|
2175
|
+
return useMemo4(
|
|
1731
2176
|
() => ({
|
|
1732
2177
|
snapshot,
|
|
1733
2178
|
setFieldValue: (field, value) => dispatch({ type: "set-field", field, value }),
|
|
@@ -1750,13 +2195,13 @@ function useGdsFormOrchestration({
|
|
|
1750
2195
|
onEvent
|
|
1751
2196
|
}) {
|
|
1752
2197
|
const [snapshot, dispatch] = useReducer2(gdsFormReducer, initialValues, createSnapshot);
|
|
1753
|
-
const submitAttempt =
|
|
1754
|
-
const [lastSubmitFailed, setLastSubmitFailed] =
|
|
1755
|
-
const setFieldValue =
|
|
2198
|
+
const submitAttempt = useRef3(0);
|
|
2199
|
+
const [lastSubmitFailed, setLastSubmitFailed] = useState10(false);
|
|
2200
|
+
const setFieldValue = useCallback3((field, value) => {
|
|
1756
2201
|
dispatch({ type: "set-field", field, value });
|
|
1757
2202
|
emitFormEvent(onEvent, "dirty_changed", "idle");
|
|
1758
2203
|
}, [onEvent]);
|
|
1759
|
-
const validateSnapshot =
|
|
2204
|
+
const validateSnapshot = useCallback3(async () => {
|
|
1760
2205
|
dispatch({ type: "set-submit-state", submitState: "validating" });
|
|
1761
2206
|
const syncIssues = sortIssues(validate ? validate(snapshot) : []);
|
|
1762
2207
|
const asyncIssues = syncIssues.some((issue) => issue.severity === "blocking") || !validateAsync ? [] : sortIssues(await validateAsync(snapshot));
|
|
@@ -1769,7 +2214,7 @@ function useGdsFormOrchestration({
|
|
|
1769
2214
|
}
|
|
1770
2215
|
return true;
|
|
1771
2216
|
}, [onEvent, snapshot, validate, validateAsync]);
|
|
1772
|
-
const autosaveDraft =
|
|
2217
|
+
const autosaveDraft = useCallback3(async () => {
|
|
1773
2218
|
if (!draftAdapter) return false;
|
|
1774
2219
|
dispatch({ type: "set-submit-state", submitState: "autosaving" });
|
|
1775
2220
|
await draftAdapter.save(snapshotValues(snapshot));
|
|
@@ -1777,7 +2222,7 @@ function useGdsFormOrchestration({
|
|
|
1777
2222
|
emitFormEvent(onEvent, "autosave_succeeded", "saved");
|
|
1778
2223
|
return true;
|
|
1779
2224
|
}, [draftAdapter, onEvent, snapshot]);
|
|
1780
|
-
const submit =
|
|
2225
|
+
const submit = useCallback3(async () => {
|
|
1781
2226
|
const attempt = submitAttempt.current + 1;
|
|
1782
2227
|
submitAttempt.current = attempt;
|
|
1783
2228
|
const valid = await validateSnapshot();
|
|
@@ -1813,7 +2258,7 @@ function useGdsFormOrchestration({
|
|
|
1813
2258
|
return false;
|
|
1814
2259
|
}
|
|
1815
2260
|
}, [autosave, autosaveDraft, draftAdapter, lastSubmitFailed, mapServerErrors, onEvent, onSubmit, optimisticSubmit, snapshot, validateSnapshot]);
|
|
1816
|
-
const restoreDraft =
|
|
2261
|
+
const restoreDraft = useCallback3(async () => {
|
|
1817
2262
|
const draft = await draftAdapter?.load();
|
|
1818
2263
|
if (!draft) return false;
|
|
1819
2264
|
dispatch({ type: "reset", values: draft });
|
|
@@ -1821,10 +2266,10 @@ function useGdsFormOrchestration({
|
|
|
1821
2266
|
emitFormEvent(onEvent, "draft_restored", "restored");
|
|
1822
2267
|
return true;
|
|
1823
2268
|
}, [draftAdapter, onEvent]);
|
|
1824
|
-
const discardDraft =
|
|
2269
|
+
const discardDraft = useCallback3(async () => {
|
|
1825
2270
|
await draftAdapter?.clear();
|
|
1826
2271
|
}, [draftAdapter]);
|
|
1827
|
-
return
|
|
2272
|
+
return useMemo4(
|
|
1828
2273
|
() => ({
|
|
1829
2274
|
snapshot,
|
|
1830
2275
|
setFieldValue,
|
|
@@ -1840,7 +2285,7 @@ function useGdsFormOrchestration({
|
|
|
1840
2285
|
}
|
|
1841
2286
|
var GdsFormContext = createContext3(null);
|
|
1842
2287
|
function GdsFormProvider({ snapshot, children }) {
|
|
1843
|
-
return /* @__PURE__ */
|
|
2288
|
+
return /* @__PURE__ */ jsx23(GdsFormContext.Provider, { value: { snapshot }, children });
|
|
1844
2289
|
}
|
|
1845
2290
|
function useGdsFormSnapshot() {
|
|
1846
2291
|
const context = useContext3(GdsFormContext);
|
|
@@ -1850,14 +2295,14 @@ function useGdsFormSnapshot() {
|
|
|
1850
2295
|
return context.snapshot;
|
|
1851
2296
|
}
|
|
1852
2297
|
function FormErrorSummary({ title: titleProp }) {
|
|
1853
|
-
const { t } =
|
|
2298
|
+
const { t } = useGdsTranslation16();
|
|
1854
2299
|
const title = titleProp ?? t("gds.gdsForm.title", "Please review the following issues.");
|
|
1855
2300
|
const snapshot = useGdsFormSnapshot();
|
|
1856
2301
|
const blocking = snapshot.issues.filter((issue) => issue.severity === "blocking");
|
|
1857
2302
|
if (blocking.length === 0) {
|
|
1858
2303
|
return null;
|
|
1859
2304
|
}
|
|
1860
|
-
return /* @__PURE__ */
|
|
2305
|
+
return /* @__PURE__ */ jsx23(Alert, { color: "red", title, children: /* @__PURE__ */ jsx23(Stack10, { gap: 4, children: blocking.map((issue) => /* @__PURE__ */ jsx23(Anchor, { href: `#${issue.field}`, children: issue.message }, `${issue.field}-${issue.message}`)) }) });
|
|
1861
2306
|
}
|
|
1862
2307
|
var GdsValidationSummary = FormErrorSummary;
|
|
1863
2308
|
function ValidatedFieldMessage({ field }) {
|
|
@@ -1866,14 +2311,14 @@ function ValidatedFieldMessage({ field }) {
|
|
|
1866
2311
|
if (!issue) {
|
|
1867
2312
|
return null;
|
|
1868
2313
|
}
|
|
1869
|
-
return /* @__PURE__ */
|
|
2314
|
+
return /* @__PURE__ */ jsx23(Text15, { size: "xs", c: "red.7", id: `${field}-error`, children: issue.message });
|
|
1870
2315
|
}
|
|
1871
2316
|
|
|
1872
2317
|
// src/GdsSchemaForm.client.tsx
|
|
1873
|
-
import { useCallback as
|
|
1874
|
-
import { Button as
|
|
1875
|
-
import { useGdsTranslation as
|
|
1876
|
-
import { jsx as
|
|
2318
|
+
import { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo5, useRef as useRef4, useState as useState11 } from "react";
|
|
2319
|
+
import { Button as Button9, Checkbox, Group as Group14, Paper as Paper6, Stack as Stack11, Text as Text16, Title as Title2 } from "@mantine/core";
|
|
2320
|
+
import { useGdsTranslation as useGdsTranslation17 } from "@sovereignsquad/gds-theme";
|
|
2321
|
+
import { jsx as jsx24, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1877
2322
|
function toIsoDateString(date) {
|
|
1878
2323
|
const year = date.getFullYear();
|
|
1879
2324
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
@@ -2127,23 +2572,23 @@ function FileUploadField({
|
|
|
2127
2572
|
onUploadEvent,
|
|
2128
2573
|
onChange
|
|
2129
2574
|
}) {
|
|
2130
|
-
const abortRef =
|
|
2131
|
-
const lastFilesRef =
|
|
2132
|
-
const [adapterState, setAdapterState] =
|
|
2133
|
-
const [adapterProgress, setAdapterProgress] =
|
|
2134
|
-
const [adapterError, setAdapterError] =
|
|
2575
|
+
const abortRef = useRef4(null);
|
|
2576
|
+
const lastFilesRef = useRef4([]);
|
|
2577
|
+
const [adapterState, setAdapterState] = useState11();
|
|
2578
|
+
const [adapterProgress, setAdapterProgress] = useState11();
|
|
2579
|
+
const [adapterError, setAdapterError] = useState11();
|
|
2135
2580
|
const selectedFiles = getUploadFileNames(value);
|
|
2136
2581
|
const oversize = Array.isArray(value) && maxFileSizeBytes ? value.some((file) => isFileValue(file) && file.size > maxFileSizeBytes) : false;
|
|
2137
2582
|
const effectiveState = adapterState ?? state ?? (oversize ? "too-large" : selectedFiles.length > 0 ? "selected" : "idle");
|
|
2138
2583
|
const effectivePolicyText = oversize ? `One or more files exceed ${maxFileSizeLabel ?? `${maxFileSizeBytes} bytes`}.` : policyText;
|
|
2139
2584
|
const effectiveProgressValue = adapterProgress ?? progressValue;
|
|
2140
|
-
const emitUploadEvent =
|
|
2585
|
+
const emitUploadEvent = useCallback4((type, message) => {
|
|
2141
2586
|
onUploadEvent?.(createSchemaEvent(type, message, field?.name ?? id));
|
|
2142
2587
|
}, [field?.name, id, onUploadEvent]);
|
|
2143
2588
|
useEffect4(() => () => {
|
|
2144
2589
|
abortRef.current?.abort();
|
|
2145
2590
|
}, []);
|
|
2146
|
-
const uploadFiles =
|
|
2591
|
+
const uploadFiles = useCallback4((files) => {
|
|
2147
2592
|
const selectedOversize = Boolean(maxFileSizeBytes && files.some((file) => file.size > maxFileSizeBytes));
|
|
2148
2593
|
if (!uploadAdapter || !field || selectedOversize) {
|
|
2149
2594
|
onChange?.(files);
|
|
@@ -2235,7 +2680,7 @@ function FileUploadField({
|
|
|
2235
2680
|
emitUploadEvent("upload_failed", error instanceof Error ? error.message : void 0);
|
|
2236
2681
|
});
|
|
2237
2682
|
};
|
|
2238
|
-
return /* @__PURE__ */
|
|
2683
|
+
return /* @__PURE__ */ jsx24(Stack11, { gap: 4, children: /* @__PURE__ */ jsx24(
|
|
2239
2684
|
UploadDropzone,
|
|
2240
2685
|
{
|
|
2241
2686
|
title: label,
|
|
@@ -2254,8 +2699,8 @@ function FileUploadField({
|
|
|
2254
2699
|
progressValue: effectiveProgressValue,
|
|
2255
2700
|
error: adapterError,
|
|
2256
2701
|
mode: "inline",
|
|
2257
|
-
retryAction: effectiveState === "upload-failed" && uploadAdapter ? /* @__PURE__ */
|
|
2258
|
-
removeAction: effectiveState === "upload-pending" && uploadAdapter ? /* @__PURE__ */
|
|
2702
|
+
retryAction: effectiveState === "upload-failed" && uploadAdapter ? /* @__PURE__ */ jsx24(Button9, { size: "xs", variant: "light", onClick: retryUpload, children: "Retry upload" }) : void 0,
|
|
2703
|
+
removeAction: effectiveState === "upload-pending" && uploadAdapter ? /* @__PURE__ */ jsx24(Button9, { size: "xs", variant: "subtle", onClick: cancelUpload, children: "Cancel upload" }) : selectedFiles.length > 0 ? /* @__PURE__ */ jsx24(Button9, { size: "xs", variant: "subtle", onClick: removeUpload, children: "Remove" }) : void 0,
|
|
2259
2704
|
onFilesSelected: handleFilesSelected
|
|
2260
2705
|
}
|
|
2261
2706
|
) });
|
|
@@ -2276,7 +2721,7 @@ function CheckboxGroupField({ field, value, setValue, describedBy, invalid }) {
|
|
|
2276
2721
|
const toggle = (optionValue, checked) => {
|
|
2277
2722
|
setValue(checked ? [...selected, optionValue] : selected.filter((entry) => entry !== optionValue));
|
|
2278
2723
|
};
|
|
2279
|
-
return /* @__PURE__ */
|
|
2724
|
+
return /* @__PURE__ */ jsxs16(
|
|
2280
2725
|
"fieldset",
|
|
2281
2726
|
{
|
|
2282
2727
|
"data-gds-checkbox-group": field.name,
|
|
@@ -2284,11 +2729,11 @@ function CheckboxGroupField({ field, value, setValue, describedBy, invalid }) {
|
|
|
2284
2729
|
"aria-invalid": invalid || void 0,
|
|
2285
2730
|
style: { border: 0, margin: 0, padding: 0, minInlineSize: "auto" },
|
|
2286
2731
|
children: [
|
|
2287
|
-
/* @__PURE__ */
|
|
2288
|
-
/* @__PURE__ */
|
|
2732
|
+
/* @__PURE__ */ jsx24("legend", { style: visuallyHidden, children: field.label }),
|
|
2733
|
+
/* @__PURE__ */ jsx24(Stack11, { gap: 6, children: (field.options ?? []).map((option) => (
|
|
2289
2734
|
// Mantine Checkbox (not a raw native input) so the control inherits the GDS
|
|
2290
2735
|
// theme styling and the governed forced-colors remap like every other control.
|
|
2291
|
-
/* @__PURE__ */
|
|
2736
|
+
/* @__PURE__ */ jsx24(
|
|
2292
2737
|
Checkbox,
|
|
2293
2738
|
{
|
|
2294
2739
|
value: option.value,
|
|
@@ -2305,7 +2750,7 @@ function CheckboxGroupField({ field, value, setValue, describedBy, invalid }) {
|
|
|
2305
2750
|
);
|
|
2306
2751
|
}
|
|
2307
2752
|
function RepeatableField({ field, value, setValue, describedBy, invalid, renderers, uploadAdapter, onEvent }) {
|
|
2308
|
-
const { t } =
|
|
2753
|
+
const { t } = useGdsTranslation17();
|
|
2309
2754
|
const rows = Array.isArray(value) ? value : [];
|
|
2310
2755
|
const subFields = field.fields ?? [];
|
|
2311
2756
|
const minRows = field.minRows ?? 0;
|
|
@@ -2314,10 +2759,10 @@ function RepeatableField({ field, value, setValue, describedBy, invalid, rendere
|
|
|
2314
2759
|
const addLabel = field.addRowLabel ?? t("gds.schemaForm.addRow", "Add row");
|
|
2315
2760
|
const removeLabel = field.removeRowLabel ?? t("gds.schemaForm.removeRow", "Remove");
|
|
2316
2761
|
const rowNoun = (count) => count === 1 ? t("gds.schemaForm.rowOne", "row") : t("gds.schemaForm.rowMany", "rows");
|
|
2317
|
-
const containerRef =
|
|
2318
|
-
const addButtonRef =
|
|
2319
|
-
const pendingFocus =
|
|
2320
|
-
const [announcement, setAnnouncement] =
|
|
2762
|
+
const containerRef = useRef4(null);
|
|
2763
|
+
const addButtonRef = useRef4(null);
|
|
2764
|
+
const pendingFocus = useRef4(null);
|
|
2765
|
+
const [announcement, setAnnouncement] = useState11("");
|
|
2321
2766
|
useEffect4(() => {
|
|
2322
2767
|
if (pendingFocus.current === "add") {
|
|
2323
2768
|
const lastRow = containerRef.current?.querySelector(`[data-gds-repeatable-row="${rows.length - 1}"]`);
|
|
@@ -2342,12 +2787,12 @@ function RepeatableField({ field, value, setValue, describedBy, invalid, rendere
|
|
|
2342
2787
|
const setRowFieldValue = (index, name, next) => {
|
|
2343
2788
|
setValue(rows.map((row, rowIndex) => rowIndex === index ? { ...row, [name]: next } : row));
|
|
2344
2789
|
};
|
|
2345
|
-
return /* @__PURE__ */
|
|
2346
|
-
rows.map((row, index) => /* @__PURE__ */
|
|
2347
|
-
/* @__PURE__ */
|
|
2348
|
-
/* @__PURE__ */
|
|
2349
|
-
/* @__PURE__ */
|
|
2350
|
-
|
|
2790
|
+
return /* @__PURE__ */ jsxs16(Stack11, { gap: "sm", ref: containerRef, "data-gds-repeatable": field.name, "aria-describedby": describedBy, "aria-invalid": invalid || void 0, children: [
|
|
2791
|
+
rows.map((row, index) => /* @__PURE__ */ jsx24(Paper6, { withBorder: true, radius: "md", p: "sm", "data-gds-repeatable-row": index, children: /* @__PURE__ */ jsxs16(Stack11, { gap: "xs", children: [
|
|
2792
|
+
/* @__PURE__ */ jsxs16(Group14, { justify: "space-between", align: "center", wrap: "nowrap", children: [
|
|
2793
|
+
/* @__PURE__ */ jsx24(Text16, { size: "xs", fw: 600, c: "dimmed", children: `${field.label} ${index + 1}` }),
|
|
2794
|
+
/* @__PURE__ */ jsx24(
|
|
2795
|
+
Button9,
|
|
2351
2796
|
{
|
|
2352
2797
|
type: "button",
|
|
2353
2798
|
size: "xs",
|
|
@@ -2369,11 +2814,11 @@ function RepeatableField({ field, value, setValue, describedBy, invalid, rendere
|
|
|
2369
2814
|
invalid: false
|
|
2370
2815
|
};
|
|
2371
2816
|
const subRenderer = renderers[sub.name] ?? renderers[sub.type];
|
|
2372
|
-
return /* @__PURE__ */
|
|
2817
|
+
return /* @__PURE__ */ jsx24(FormField, { label: `${sub.label}${sub.required ? ` ${t("gds.schemaForm.requiredMarker", "(required)")}` : ""}`, children: subRenderer ? subRenderer(subContext) : renderDefaultField(subContext, { uploadAdapter, onEvent, renderers }) }, sub.name);
|
|
2373
2818
|
})
|
|
2374
2819
|
] }) }, index)),
|
|
2375
|
-
/* @__PURE__ */
|
|
2376
|
-
/* @__PURE__ */
|
|
2820
|
+
/* @__PURE__ */ jsx24(Group14, { children: /* @__PURE__ */ jsx24(Button9, { ref: addButtonRef, type: "button", size: "xs", variant: "light", disabled: !canAdd, onClick: addRow, children: addLabel }) }),
|
|
2821
|
+
/* @__PURE__ */ jsx24("div", { "aria-live": "polite", style: visuallyHidden, children: announcement })
|
|
2377
2822
|
] });
|
|
2378
2823
|
}
|
|
2379
2824
|
function renderDefaultField({ field, value, setValue, describedBy, invalid }, options = {}) {
|
|
@@ -2385,7 +2830,7 @@ function renderDefaultField({ field, value, setValue, describedBy, invalid }, op
|
|
|
2385
2830
|
required: field.required
|
|
2386
2831
|
};
|
|
2387
2832
|
if (field.type === "file-upload") {
|
|
2388
|
-
return /* @__PURE__ */
|
|
2833
|
+
return /* @__PURE__ */ jsx24(
|
|
2389
2834
|
FileUploadField,
|
|
2390
2835
|
{
|
|
2391
2836
|
...common,
|
|
@@ -2407,10 +2852,10 @@ function renderDefaultField({ field, value, setValue, describedBy, invalid }, op
|
|
|
2407
2852
|
);
|
|
2408
2853
|
}
|
|
2409
2854
|
if (field.type === "checkbox-group") {
|
|
2410
|
-
return /* @__PURE__ */
|
|
2855
|
+
return /* @__PURE__ */ jsx24(CheckboxGroupField, { field, value, setValue, describedBy, invalid });
|
|
2411
2856
|
}
|
|
2412
2857
|
if (field.type === "repeatable") {
|
|
2413
|
-
return /* @__PURE__ */
|
|
2858
|
+
return /* @__PURE__ */ jsx24(
|
|
2414
2859
|
RepeatableField,
|
|
2415
2860
|
{
|
|
2416
2861
|
field,
|
|
@@ -2425,17 +2870,17 @@ function renderDefaultField({ field, value, setValue, describedBy, invalid }, op
|
|
|
2425
2870
|
);
|
|
2426
2871
|
}
|
|
2427
2872
|
const textEntryStyle = { fontSize: "max(1rem, 1em)" };
|
|
2428
|
-
if (field.type === "boolean") return /* @__PURE__ */
|
|
2429
|
-
if (field.type === "number") return /* @__PURE__ */
|
|
2873
|
+
if (field.type === "boolean") return /* @__PURE__ */ jsx24("input", { ...common, type: "checkbox", checked: Boolean(value), onChange: (event) => setValue(event.currentTarget.checked) });
|
|
2874
|
+
if (field.type === "number") return /* @__PURE__ */ jsx24("input", { ...common, style: textEntryStyle, type: "number", value: String(value ?? ""), onChange: (event) => setValue(event.currentTarget.value === "" ? "" : Number(event.currentTarget.value)) });
|
|
2430
2875
|
if (field.type === "select") {
|
|
2431
|
-
return /* @__PURE__ */
|
|
2432
|
-
/* @__PURE__ */
|
|
2433
|
-
(field.options ?? []).map((option) => /* @__PURE__ */
|
|
2876
|
+
return /* @__PURE__ */ jsxs16("select", { ...common, style: textEntryStyle, value: String(value ?? ""), onChange: (event) => setValue(event.currentTarget.value), children: [
|
|
2877
|
+
/* @__PURE__ */ jsx24("option", { value: "", children: "Select..." }),
|
|
2878
|
+
(field.options ?? []).map((option) => /* @__PURE__ */ jsx24("option", { value: option.value, children: option.label }, option.value))
|
|
2434
2879
|
] });
|
|
2435
2880
|
}
|
|
2436
|
-
if (field.type === "textarea") return /* @__PURE__ */
|
|
2881
|
+
if (field.type === "textarea") return /* @__PURE__ */ jsx24("textarea", { ...common, style: textEntryStyle, value: String(value ?? ""), onChange: (event) => setValue(event.currentTarget.value) });
|
|
2437
2882
|
if (field.type === "date") {
|
|
2438
|
-
return /* @__PURE__ */
|
|
2883
|
+
return /* @__PURE__ */ jsx24(
|
|
2439
2884
|
GdsDateInput,
|
|
2440
2885
|
{
|
|
2441
2886
|
...common,
|
|
@@ -2444,7 +2889,7 @@ function renderDefaultField({ field, value, setValue, describedBy, invalid }, op
|
|
|
2444
2889
|
}
|
|
2445
2890
|
);
|
|
2446
2891
|
}
|
|
2447
|
-
return /* @__PURE__ */
|
|
2892
|
+
return /* @__PURE__ */ jsx24("input", { ...common, style: textEntryStyle, type: field.type === "password" ? "password" : field.type === "email" ? "email" : field.type === "url" ? "url" : "text", value: String(value ?? ""), onChange: (event) => setValue(event.currentTarget.value) });
|
|
2448
2893
|
}
|
|
2449
2894
|
function GdsSchemaForm({
|
|
2450
2895
|
schema,
|
|
@@ -2454,9 +2899,9 @@ function GdsSchemaForm({
|
|
|
2454
2899
|
onEvent,
|
|
2455
2900
|
submitLabel: submitLabelProp
|
|
2456
2901
|
}) {
|
|
2457
|
-
const { t } =
|
|
2902
|
+
const { t } = useGdsTranslation17();
|
|
2458
2903
|
const submitLabel = submitLabelProp ?? t("gds.gdsSchemaForm.submitLabel", "Submit");
|
|
2459
|
-
const initialValues =
|
|
2904
|
+
const initialValues = useMemo5(() => getInitialValues(schema), [schema]);
|
|
2460
2905
|
const form = useGdsFormOrchestration({
|
|
2461
2906
|
initialValues,
|
|
2462
2907
|
validate: (snapshot) => validateSchemaValues(schema, Object.fromEntries(Object.entries(snapshot.fields).map(([name, field]) => [name, field.value])), renderers, { uploadAdapter, t }),
|
|
@@ -2470,15 +2915,15 @@ function GdsSchemaForm({
|
|
|
2470
2915
|
},
|
|
2471
2916
|
onEvent
|
|
2472
2917
|
});
|
|
2473
|
-
return /* @__PURE__ */
|
|
2474
|
-
schema.title ? /* @__PURE__ */
|
|
2475
|
-
schema.description ? /* @__PURE__ */
|
|
2476
|
-
/* @__PURE__ */
|
|
2918
|
+
return /* @__PURE__ */ jsx24(GdsFormProvider, { snapshot: form.snapshot, children: /* @__PURE__ */ jsxs16(Stack11, { gap: "md", children: [
|
|
2919
|
+
schema.title ? /* @__PURE__ */ jsx24(Title2, { order: 4, children: schema.title }) : null,
|
|
2920
|
+
schema.description ? /* @__PURE__ */ jsx24(Text16, { size: "sm", c: "dimmed", children: schema.description }) : null,
|
|
2921
|
+
/* @__PURE__ */ jsx24(GdsValidationSummary, {}),
|
|
2477
2922
|
schema.fields.map((field) => {
|
|
2478
2923
|
if (field.hidden || field.type === "hidden") return null;
|
|
2479
2924
|
const issue = form.snapshot.issues.find((item) => item.field === field.name && item.severity === "blocking");
|
|
2480
2925
|
if (field.type === "unsupported" && !renderers[field.name] && !renderers[field.type]) {
|
|
2481
|
-
return /* @__PURE__ */
|
|
2926
|
+
return /* @__PURE__ */ jsx24(StateBlock, { variant: "error", title: `Unsupported field: ${field.label}`, description: field.unsupportedReason ?? "Provide a renderer override for this field.", compact: true }, field.name);
|
|
2482
2927
|
}
|
|
2483
2928
|
const context = {
|
|
2484
2929
|
field,
|
|
@@ -2488,29 +2933,29 @@ function GdsSchemaForm({
|
|
|
2488
2933
|
invalid: Boolean(issue)
|
|
2489
2934
|
};
|
|
2490
2935
|
const renderer = renderers[field.name] ?? renderers[field.type];
|
|
2491
|
-
return /* @__PURE__ */
|
|
2936
|
+
return /* @__PURE__ */ jsxs16(
|
|
2492
2937
|
FormField,
|
|
2493
2938
|
{
|
|
2494
2939
|
label: `${field.label}${field.required ? ` ${t("gds.schemaForm.requiredMarker", "(required)")}` : ""}`,
|
|
2495
|
-
description: field.description ? /* @__PURE__ */
|
|
2940
|
+
description: field.description ? /* @__PURE__ */ jsx24(Text16, { id: `${field.name}-description`, size: "xs", c: "dimmed", children: field.description }) : void 0,
|
|
2496
2941
|
children: [
|
|
2497
2942
|
renderer ? renderer(context) : renderDefaultField(context, { uploadAdapter, onEvent, renderers }),
|
|
2498
|
-
/* @__PURE__ */
|
|
2943
|
+
/* @__PURE__ */ jsx24("span", { id: `${field.name}-error`, children: /* @__PURE__ */ jsx24(ValidatedFieldMessage, { field: field.name }) })
|
|
2499
2944
|
]
|
|
2500
2945
|
},
|
|
2501
2946
|
field.name
|
|
2502
2947
|
);
|
|
2503
2948
|
}),
|
|
2504
|
-
/* @__PURE__ */
|
|
2949
|
+
/* @__PURE__ */ jsx24(Button9, { type: "button", onClick: () => {
|
|
2505
2950
|
void form.submit();
|
|
2506
2951
|
}, loading: form.snapshot.submitState === "validating" || form.snapshot.submitState === "submitting" || form.snapshot.submitState === "optimistic", children: submitLabel })
|
|
2507
2952
|
] }) });
|
|
2508
2953
|
}
|
|
2509
2954
|
|
|
2510
2955
|
// src/AdvancedDataTable.client.tsx
|
|
2511
|
-
import { useMemo as
|
|
2512
|
-
import { Checkbox as Checkbox2, Group as
|
|
2513
|
-
import { jsx as
|
|
2956
|
+
import { useMemo as useMemo6, useState as useState12 } from "react";
|
|
2957
|
+
import { Checkbox as Checkbox2, Group as Group15, ScrollArea as ScrollArea2, SegmentedControl as SegmentedControl2, Stack as Stack12, Table, Text as Text17 } from "@mantine/core";
|
|
2958
|
+
import { jsx as jsx25, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2514
2959
|
function compareValues(a, b) {
|
|
2515
2960
|
if (typeof a === "number" && typeof b === "number") {
|
|
2516
2961
|
return a - b;
|
|
@@ -2533,14 +2978,14 @@ function AdvancedDataTable({
|
|
|
2533
2978
|
onSortChange,
|
|
2534
2979
|
responsiveFallback = "stacked-cards"
|
|
2535
2980
|
}) {
|
|
2536
|
-
const [densityState, setDensityState] =
|
|
2537
|
-
const [sortState, setSortState] =
|
|
2538
|
-
const [selectionState, setSelectionState] =
|
|
2981
|
+
const [densityState, setDensityState] = useState12(densityProp ?? "comfortable");
|
|
2982
|
+
const [sortState, setSortState] = useState12({ key: sortByProp ?? null, direction: sortDirectionProp ?? "asc" });
|
|
2983
|
+
const [selectionState, setSelectionState] = useState12([]);
|
|
2539
2984
|
const density = densityProp ?? densityState;
|
|
2540
2985
|
const sortBy = sortByProp ?? sortState.key;
|
|
2541
2986
|
const sortDirection = sortDirectionProp ?? sortState.direction;
|
|
2542
2987
|
const selection = selectedRowIds ?? selectionState;
|
|
2543
|
-
const sortedRows =
|
|
2988
|
+
const sortedRows = useMemo6(() => {
|
|
2544
2989
|
if (!sortBy) {
|
|
2545
2990
|
return rows;
|
|
2546
2991
|
}
|
|
@@ -2556,16 +3001,16 @@ function AdvancedDataTable({
|
|
|
2556
3001
|
});
|
|
2557
3002
|
return next;
|
|
2558
3003
|
}, [rows, columns, sortBy, sortDirection]);
|
|
2559
|
-
const allIds =
|
|
3004
|
+
const allIds = useMemo6(() => sortedRows.map((row, index) => rowId(row, index)), [sortedRows, rowId]);
|
|
2560
3005
|
const allSelected = allIds.length > 0 && allIds.every((id) => selection.includes(id));
|
|
2561
3006
|
if (error) {
|
|
2562
|
-
return /* @__PURE__ */
|
|
3007
|
+
return /* @__PURE__ */ jsx25(StateBlock, { variant: "error", title: "Unable to load table", description: error, compact: true });
|
|
2563
3008
|
}
|
|
2564
3009
|
if (loading) {
|
|
2565
|
-
return /* @__PURE__ */
|
|
3010
|
+
return /* @__PURE__ */ jsx25(StateBlock, { variant: "loading", title: "Loading table", description: "Preparing enterprise data grid.", compact: true });
|
|
2566
3011
|
}
|
|
2567
3012
|
if (!rows.length) {
|
|
2568
|
-
return /* @__PURE__ */
|
|
3013
|
+
return /* @__PURE__ */ jsx25(
|
|
2569
3014
|
StateBlock,
|
|
2570
3015
|
{
|
|
2571
3016
|
variant: "empty",
|
|
@@ -2577,14 +3022,14 @@ function AdvancedDataTable({
|
|
|
2577
3022
|
}
|
|
2578
3023
|
const horizontalSpacing = density === "compact" ? "xs" : "md";
|
|
2579
3024
|
const verticalSpacing = density === "compact" ? 6 : 10;
|
|
2580
|
-
return /* @__PURE__ */
|
|
2581
|
-
/* @__PURE__ */
|
|
2582
|
-
/* @__PURE__ */
|
|
3025
|
+
return /* @__PURE__ */ jsxs17(Stack12, { gap: "sm", children: [
|
|
3026
|
+
/* @__PURE__ */ jsxs17(Group15, { justify: "space-between", align: "center", children: [
|
|
3027
|
+
/* @__PURE__ */ jsxs17(Text17, { size: "sm", fw: 600, children: [
|
|
2583
3028
|
rows.length,
|
|
2584
3029
|
" rows"
|
|
2585
3030
|
] }),
|
|
2586
|
-
/* @__PURE__ */
|
|
2587
|
-
|
|
3031
|
+
/* @__PURE__ */ jsx25(
|
|
3032
|
+
SegmentedControl2,
|
|
2588
3033
|
{
|
|
2589
3034
|
size: "xs",
|
|
2590
3035
|
value: density,
|
|
@@ -2596,7 +3041,7 @@ function AdvancedDataTable({
|
|
|
2596
3041
|
}
|
|
2597
3042
|
)
|
|
2598
3043
|
] }),
|
|
2599
|
-
/* @__PURE__ */
|
|
3044
|
+
/* @__PURE__ */ jsx25(ScrollArea2, { children: /* @__PURE__ */ jsxs17(
|
|
2600
3045
|
Table,
|
|
2601
3046
|
{
|
|
2602
3047
|
stickyHeader,
|
|
@@ -2607,8 +3052,8 @@ function AdvancedDataTable({
|
|
|
2607
3052
|
horizontalSpacing,
|
|
2608
3053
|
verticalSpacing,
|
|
2609
3054
|
children: [
|
|
2610
|
-
/* @__PURE__ */
|
|
2611
|
-
/* @__PURE__ */
|
|
3055
|
+
/* @__PURE__ */ jsx25(Table.Thead, { children: /* @__PURE__ */ jsxs17(Table.Tr, { children: [
|
|
3056
|
+
/* @__PURE__ */ jsx25(Table.Th, { children: /* @__PURE__ */ jsx25(
|
|
2612
3057
|
Checkbox2,
|
|
2613
3058
|
{
|
|
2614
3059
|
className: "gds-touch-target-pad-checkbox",
|
|
@@ -2626,7 +3071,7 @@ function AdvancedDataTable({
|
|
|
2626
3071
|
}
|
|
2627
3072
|
}
|
|
2628
3073
|
) }),
|
|
2629
|
-
columns.map((column) => /* @__PURE__ */
|
|
3074
|
+
columns.map((column) => /* @__PURE__ */ jsx25(Table.Th, { style: column.width ? { width: column.width } : void 0, children: column.sortable ? /* @__PURE__ */ jsx25(
|
|
2630
3075
|
"button",
|
|
2631
3076
|
{
|
|
2632
3077
|
type: "button",
|
|
@@ -2643,11 +3088,11 @@ function AdvancedDataTable({
|
|
|
2643
3088
|
}
|
|
2644
3089
|
) : column.label }, column.key))
|
|
2645
3090
|
] }) }),
|
|
2646
|
-
/* @__PURE__ */
|
|
3091
|
+
/* @__PURE__ */ jsx25(Table.Tbody, { children: sortedRows.map((row, index) => {
|
|
2647
3092
|
const id = rowId(row, index);
|
|
2648
3093
|
const checked = selection.includes(id);
|
|
2649
|
-
return /* @__PURE__ */
|
|
2650
|
-
/* @__PURE__ */
|
|
3094
|
+
return /* @__PURE__ */ jsxs17(Table.Tr, { children: [
|
|
3095
|
+
/* @__PURE__ */ jsx25(Table.Td, { children: /* @__PURE__ */ jsx25(
|
|
2651
3096
|
Checkbox2,
|
|
2652
3097
|
{
|
|
2653
3098
|
"aria-label": `Select row ${id}`,
|
|
@@ -2662,15 +3107,15 @@ function AdvancedDataTable({
|
|
|
2662
3107
|
}
|
|
2663
3108
|
}
|
|
2664
3109
|
) }),
|
|
2665
|
-
columns.map((column) => /* @__PURE__ */
|
|
3110
|
+
columns.map((column) => /* @__PURE__ */ jsx25(Table.Td, { children: column.render ? column.render(row) : String(row[column.key] ?? "") }, column.key))
|
|
2666
3111
|
] }, id);
|
|
2667
3112
|
}) })
|
|
2668
3113
|
]
|
|
2669
3114
|
}
|
|
2670
3115
|
) }),
|
|
2671
|
-
responsiveFallback === "stacked-cards" ? /* @__PURE__ */
|
|
3116
|
+
responsiveFallback === "stacked-cards" ? /* @__PURE__ */ jsx25(Stack12, { gap: "xs", children: sortedRows.slice(0, 3).map((row, index) => {
|
|
2672
3117
|
const id = rowId(row, index);
|
|
2673
|
-
return /* @__PURE__ */
|
|
3118
|
+
return /* @__PURE__ */ jsx25(
|
|
2674
3119
|
StateBlock,
|
|
2675
3120
|
{
|
|
2676
3121
|
variant: "info",
|
|
@@ -2685,10 +3130,10 @@ function AdvancedDataTable({
|
|
|
2685
3130
|
}
|
|
2686
3131
|
|
|
2687
3132
|
// src/GdsDataTable.client.tsx
|
|
2688
|
-
import { useGdsTranslation as
|
|
2689
|
-
import { useCallback as
|
|
2690
|
-
import { Button as
|
|
2691
|
-
import { jsx as
|
|
3133
|
+
import { useGdsTranslation as useGdsTranslation18 } from "@sovereignsquad/gds-theme";
|
|
3134
|
+
import { useCallback as useCallback5, useEffect as useEffect5, useMemo as useMemo7, useRef as useRef5, useState as useState13 } from "react";
|
|
3135
|
+
import { Button as Button10, Checkbox as Checkbox3, Group as Group16, Pagination, ScrollArea as ScrollArea3, Stack as Stack13, Table as Table2, Text as Text18, TextInput as TextInput2, VisuallyHidden as VisuallyHidden5 } from "@mantine/core";
|
|
3136
|
+
import { jsx as jsx26, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2692
3137
|
function emitTableEvent(onEvent, type, message) {
|
|
2693
3138
|
onEvent?.({ type, message, timestamp: Date.now(), privacy: "metadata-only" });
|
|
2694
3139
|
}
|
|
@@ -2751,13 +3196,13 @@ function useGdsDataTable({
|
|
|
2751
3196
|
timeoutMs = 8e3,
|
|
2752
3197
|
virtualizedRowLimit
|
|
2753
3198
|
}) {
|
|
2754
|
-
const [query, setQuery] =
|
|
2755
|
-
const [rows, setRows] =
|
|
2756
|
-
const [total, setTotal] =
|
|
2757
|
-
const [status, setStatus] =
|
|
2758
|
-
const [error, setError] =
|
|
2759
|
-
const [selectedRowIds, setSelectedRowIds] =
|
|
2760
|
-
const [reloadKey, setReloadKey] =
|
|
3199
|
+
const [query, setQuery] = useState13(() => createDefaultQuery(initialQuery));
|
|
3200
|
+
const [rows, setRows] = useState13([]);
|
|
3201
|
+
const [total, setTotal] = useState13(0);
|
|
3202
|
+
const [status, setStatus] = useState13("idle");
|
|
3203
|
+
const [error, setError] = useState13();
|
|
3204
|
+
const [selectedRowIds, setSelectedRowIds] = useState13([]);
|
|
3205
|
+
const [reloadKey, setReloadKey] = useState13(0);
|
|
2761
3206
|
useEffect5(() => {
|
|
2762
3207
|
const controller = new AbortController();
|
|
2763
3208
|
const timer = window.setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -2784,12 +3229,12 @@ function useGdsDataTable({
|
|
|
2784
3229
|
window.clearTimeout(timer);
|
|
2785
3230
|
};
|
|
2786
3231
|
}, [adapter, onEvent, query, reloadKey, rowId, timeoutMs]);
|
|
2787
|
-
const setSearch =
|
|
3232
|
+
const setSearch = useCallback5((value) => {
|
|
2788
3233
|
setQuery((current) => ({ ...current, search: value, page: 1 }));
|
|
2789
3234
|
setSelectedRowIds([]);
|
|
2790
3235
|
emitTableEvent(onEvent, "filter_changed");
|
|
2791
3236
|
}, [onEvent]);
|
|
2792
|
-
const setSort =
|
|
3237
|
+
const setSort = useCallback5((columnKey) => {
|
|
2793
3238
|
setQuery((current) => ({
|
|
2794
3239
|
...current,
|
|
2795
3240
|
sortBy: columnKey,
|
|
@@ -2799,23 +3244,23 @@ function useGdsDataTable({
|
|
|
2799
3244
|
setSelectedRowIds([]);
|
|
2800
3245
|
emitTableEvent(onEvent, "sort_changed");
|
|
2801
3246
|
}, [onEvent]);
|
|
2802
|
-
const setPage =
|
|
2803
|
-
const setPageSize =
|
|
2804
|
-
const setFilter =
|
|
3247
|
+
const setPage = useCallback5((page) => setQuery((current) => ({ ...current, page: Math.max(1, Math.floor(page)) })), []);
|
|
3248
|
+
const setPageSize = useCallback5((pageSize) => setQuery((current) => ({ ...current, page: 1, pageSize: Math.max(1, Math.floor(pageSize)) })), []);
|
|
3249
|
+
const setFilter = useCallback5((columnKey, value) => {
|
|
2805
3250
|
setQuery((current) => ({ ...current, filters: { ...current.filters, [columnKey]: value }, page: 1 }));
|
|
2806
3251
|
setSelectedRowIds([]);
|
|
2807
3252
|
emitTableEvent(onEvent, "filter_changed");
|
|
2808
3253
|
}, [onEvent]);
|
|
2809
|
-
const visibleRows =
|
|
2810
|
-
const visibleIds =
|
|
2811
|
-
const toggleRow =
|
|
3254
|
+
const visibleRows = useMemo7(() => rows.slice(0, virtualizedRowLimit ?? rows.length), [rows, virtualizedRowLimit]);
|
|
3255
|
+
const visibleIds = useMemo7(() => visibleRows.map((row, index) => rowId(row, index)), [rowId, visibleRows]);
|
|
3256
|
+
const toggleRow = useCallback5((id) => {
|
|
2812
3257
|
setSelectedRowIds((current) => {
|
|
2813
3258
|
const next = current.includes(id) ? current.filter((item) => item !== id) : [...current, id];
|
|
2814
3259
|
emitTableEvent(onEvent, "selection_changed");
|
|
2815
3260
|
return next;
|
|
2816
3261
|
});
|
|
2817
3262
|
}, [onEvent]);
|
|
2818
|
-
const toggleAllVisible =
|
|
3263
|
+
const toggleAllVisible = useCallback5(() => {
|
|
2819
3264
|
setSelectedRowIds((current) => {
|
|
2820
3265
|
const allSelected = visibleIds.length > 0 && visibleIds.every((id) => current.includes(id));
|
|
2821
3266
|
const next = allSelected ? current.filter((id) => !visibleIds.includes(id)) : [.../* @__PURE__ */ new Set([...current, ...visibleIds])];
|
|
@@ -2823,7 +3268,7 @@ function useGdsDataTable({
|
|
|
2823
3268
|
return next;
|
|
2824
3269
|
});
|
|
2825
3270
|
}, [onEvent, visibleIds]);
|
|
2826
|
-
const exportRows =
|
|
3271
|
+
const exportRows = useCallback5(async () => {
|
|
2827
3272
|
setStatus("exporting");
|
|
2828
3273
|
emitTableEvent(onEvent, "export_requested");
|
|
2829
3274
|
await onExport?.({ query, rows, selectedRowIds });
|
|
@@ -2862,9 +3307,9 @@ function getInteractiveCellElements(cell) {
|
|
|
2862
3307
|
return Array.from(cell.querySelectorAll(interactiveCellSelector)).filter((element) => !element.hasAttribute("hidden") && element.getAttribute("aria-hidden") !== "true");
|
|
2863
3308
|
}
|
|
2864
3309
|
function useGdsTableKeyNav(rowCount, columnCount) {
|
|
2865
|
-
const tbodyRef =
|
|
2866
|
-
const [focusedCell, setFocusedCell] =
|
|
2867
|
-
const focusCell =
|
|
3310
|
+
const tbodyRef = useRef5(null);
|
|
3311
|
+
const [focusedCell, setFocusedCell] = useState13(rowCount > 0 && columnCount > 0 ? { rowIndex: 0, columnIndex: 0 } : null);
|
|
3312
|
+
const focusCell = useCallback5((rowIndex, columnIndex) => {
|
|
2868
3313
|
const rows = tbodyRef.current?.querySelectorAll("tr[data-gds-row]") ?? [];
|
|
2869
3314
|
const nextRowIndex = Math.max(0, Math.min(rowIndex, rows.length - 1));
|
|
2870
3315
|
const cells = rows[nextRowIndex]?.querySelectorAll("[data-gds-cell]") ?? [];
|
|
@@ -2873,7 +3318,7 @@ function useGdsTableKeyNav(rowCount, columnCount) {
|
|
|
2873
3318
|
setFocusedCell({ rowIndex: nextRowIndex, columnIndex: nextColumnIndex });
|
|
2874
3319
|
cells[nextColumnIndex]?.focus();
|
|
2875
3320
|
}, []);
|
|
2876
|
-
const handleKeyDown =
|
|
3321
|
+
const handleKeyDown = useCallback5((event) => {
|
|
2877
3322
|
const rows = tbodyRef.current?.querySelectorAll("tr[data-gds-row]") ?? [];
|
|
2878
3323
|
if (rows.length === 0 || columnCount === 0) return;
|
|
2879
3324
|
const target = event.target instanceof HTMLElement ? event.target : null;
|
|
@@ -2937,7 +3382,7 @@ function GdsDataTable({
|
|
|
2937
3382
|
retryLabel: retryLabelProp,
|
|
2938
3383
|
mobileCards = true
|
|
2939
3384
|
}) {
|
|
2940
|
-
const { t } =
|
|
3385
|
+
const { t } = useGdsTranslation18();
|
|
2941
3386
|
const caption = captionProp ?? t("gds.gdsDataTable.caption", "Data table");
|
|
2942
3387
|
const exportLabel = exportLabelProp ?? t("gds.gdsDataTable.exportLabel", "Export");
|
|
2943
3388
|
const retryLabel = retryLabelProp ?? t("gds.gdsDataTable.retryLabel", "Retry");
|
|
@@ -2947,49 +3392,49 @@ function GdsDataTable({
|
|
|
2947
3392
|
const gridColumnCount = visibleColumns.length + 1;
|
|
2948
3393
|
const { tbodyRef, handleKeyDown, focusedCell, setFocusedCell } = useGdsTableKeyNav(table.visibleRows.length, gridColumnCount);
|
|
2949
3394
|
const focusedColumnLabel = focusedCell ? focusedCell.columnIndex === 0 ? "Selection" : visibleColumns[focusedCell.columnIndex - 1]?.label : void 0;
|
|
2950
|
-
if (table.status === "loading") return /* @__PURE__ */
|
|
2951
|
-
if (table.status === "error") return /* @__PURE__ */
|
|
2952
|
-
if (table.status === "empty") return /* @__PURE__ */
|
|
2953
|
-
if (table.status === "filtered-empty") return /* @__PURE__ */
|
|
2954
|
-
return /* @__PURE__ */
|
|
2955
|
-
/* @__PURE__ */
|
|
2956
|
-
/* @__PURE__ */
|
|
2957
|
-
/* @__PURE__ */
|
|
2958
|
-
summary ? /* @__PURE__ */
|
|
2959
|
-
/* @__PURE__ */
|
|
3395
|
+
if (table.status === "loading") return /* @__PURE__ */ jsx26(StateBlock, { variant: "loading", title: "Loading table", description: "Preparing governed data rows.", compact: true });
|
|
3396
|
+
if (table.status === "error") return /* @__PURE__ */ jsx26(StateBlock, { variant: "error", title: "Unable to load table", description: table.error ?? "The data adapter failed.", action: /* @__PURE__ */ jsx26(Button10, { onClick: table.retry, children: retryLabel }), compact: true });
|
|
3397
|
+
if (table.status === "empty") return /* @__PURE__ */ jsx26(StateBlock, { variant: "empty", title: "No rows available", description: "There is no data for this table yet.", compact: true });
|
|
3398
|
+
if (table.status === "filtered-empty") return /* @__PURE__ */ jsx26(StateBlock, { variant: "empty", title: "No matching rows", description: "Adjust search or filters to broaden the result set.", compact: true });
|
|
3399
|
+
return /* @__PURE__ */ jsxs18(Stack13, { gap: "sm", children: [
|
|
3400
|
+
/* @__PURE__ */ jsxs18(Group16, { justify: "space-between", align: "end", children: [
|
|
3401
|
+
/* @__PURE__ */ jsxs18(Stack13, { gap: 2, children: [
|
|
3402
|
+
/* @__PURE__ */ jsx26(Text18, { size: "sm", fw: 700, children: caption }),
|
|
3403
|
+
summary ? /* @__PURE__ */ jsx26(Text18, { size: "xs", c: "dimmed", children: summary }) : null,
|
|
3404
|
+
/* @__PURE__ */ jsxs18(Text18, { size: "xs", c: "dimmed", children: [
|
|
2960
3405
|
table.total,
|
|
2961
3406
|
" rows",
|
|
2962
3407
|
table.status === "partial" ? " (partial data)" : ""
|
|
2963
3408
|
] })
|
|
2964
3409
|
] }),
|
|
2965
|
-
/* @__PURE__ */
|
|
2966
|
-
/* @__PURE__ */
|
|
2967
|
-
/* @__PURE__ */
|
|
3410
|
+
/* @__PURE__ */ jsxs18(Group16, { gap: "xs", children: [
|
|
3411
|
+
/* @__PURE__ */ jsx26(TextInput2, { "aria-label": "Search rows", placeholder: "Search rows", value: table.query.search, onChange: (event) => table.setSearch(event.currentTarget.value) }),
|
|
3412
|
+
/* @__PURE__ */ jsx26(Button10, { variant: "light", onClick: () => {
|
|
2968
3413
|
void table.exportRows();
|
|
2969
3414
|
}, loading: table.status === "exporting", children: exportLabel })
|
|
2970
3415
|
] })
|
|
2971
3416
|
] }),
|
|
2972
|
-
/* @__PURE__ */
|
|
2973
|
-
/* @__PURE__ */
|
|
2974
|
-
/* @__PURE__ */
|
|
2975
|
-
/* @__PURE__ */
|
|
2976
|
-
visibleColumns.map((column) => /* @__PURE__ */
|
|
3417
|
+
/* @__PURE__ */ jsx26(ScrollArea3, { children: /* @__PURE__ */ jsxs18(Table2, { withTableBorder: true, striped: true, highlightOnHover: true, role: "grid", "aria-label": caption, "aria-rowcount": table.total, children: [
|
|
3418
|
+
/* @__PURE__ */ jsx26("caption", { children: caption }),
|
|
3419
|
+
/* @__PURE__ */ jsx26(Table2.Thead, { children: /* @__PURE__ */ jsxs18(Table2.Tr, { children: [
|
|
3420
|
+
/* @__PURE__ */ jsx26(Table2.Th, { scope: "col", children: /* @__PURE__ */ jsx26(Checkbox3, { "aria-label": "Select all visible rows", checked: visibleColumns.length > 0 && table.visibleRows.length > 0 && table.visibleRows.every((row, index) => table.selectedRowIds.includes(rowId(row, index))), onChange: table.toggleAllVisible }) }),
|
|
3421
|
+
visibleColumns.map((column) => /* @__PURE__ */ jsx26(Table2.Th, { scope: "col", "aria-sort": table.query.sortBy === column.key ? table.query.sortDirection === "asc" ? "ascending" : "descending" : "none", style: column.width ? { width: column.width } : void 0, children: column.sortable ? /* @__PURE__ */ jsx26("button", { type: "button", onClick: () => table.setSort(column.key), children: column.label }) : column.label }, column.key))
|
|
2977
3422
|
] }) }),
|
|
2978
|
-
/* @__PURE__ */
|
|
3423
|
+
/* @__PURE__ */ jsx26(
|
|
2979
3424
|
Table2.Tbody,
|
|
2980
3425
|
{
|
|
2981
3426
|
ref: tbodyRef,
|
|
2982
3427
|
onKeyDown: handleKeyDown,
|
|
2983
3428
|
children: table.visibleRows.map((row, rowIndex) => {
|
|
2984
3429
|
const id = rowId(row, rowIndex);
|
|
2985
|
-
return /* @__PURE__ */
|
|
3430
|
+
return /* @__PURE__ */ jsxs18(
|
|
2986
3431
|
Table2.Tr,
|
|
2987
3432
|
{
|
|
2988
3433
|
"data-gds-row": true,
|
|
2989
3434
|
"aria-selected": table.selectedRowIds.includes(id),
|
|
2990
3435
|
"aria-rowindex": (table.query.page - 1) * table.query.pageSize + rowIndex + 2,
|
|
2991
3436
|
children: [
|
|
2992
|
-
/* @__PURE__ */
|
|
3437
|
+
/* @__PURE__ */ jsx26(
|
|
2993
3438
|
Table2.Td,
|
|
2994
3439
|
{
|
|
2995
3440
|
role: "gridcell",
|
|
@@ -3000,13 +3445,13 @@ function GdsDataTable({
|
|
|
3000
3445
|
"aria-colindex": 1,
|
|
3001
3446
|
onFocus: () => setFocusedCell({ rowIndex, columnIndex: 0 }),
|
|
3002
3447
|
style: focusedCell?.rowIndex === rowIndex && focusedCell.columnIndex === 0 ? { outline: "2px solid var(--mantine-color-blue-5)", outlineOffset: "-2px" } : void 0,
|
|
3003
|
-
children: /* @__PURE__ */
|
|
3448
|
+
children: /* @__PURE__ */ jsx26(Checkbox3, { "aria-label": `Select row ${id}`, checked: table.selectedRowIds.includes(id), onChange: () => table.toggleRow(id), tabIndex: -1 })
|
|
3004
3449
|
}
|
|
3005
3450
|
),
|
|
3006
3451
|
visibleColumns.map((column, columnIndex) => {
|
|
3007
3452
|
const gridColumnIndex = columnIndex + 1;
|
|
3008
3453
|
const isCellFocused = focusedCell?.rowIndex === rowIndex && focusedCell.columnIndex === gridColumnIndex;
|
|
3009
|
-
return /* @__PURE__ */
|
|
3454
|
+
return /* @__PURE__ */ jsx26(
|
|
3010
3455
|
Table2.Td,
|
|
3011
3456
|
{
|
|
3012
3457
|
role: "gridcell",
|
|
@@ -3032,24 +3477,24 @@ function GdsDataTable({
|
|
|
3032
3477
|
}
|
|
3033
3478
|
)
|
|
3034
3479
|
] }) }),
|
|
3035
|
-
/* @__PURE__ */
|
|
3036
|
-
virtualizedRowLimit && table.rows.length > table.visibleRows.length ? /* @__PURE__ */
|
|
3480
|
+
/* @__PURE__ */ jsx26(VisuallyHidden5, { "aria-live": "polite", "aria-atomic": "true", children: focusedCell ? `Row ${focusedCell.rowIndex + 1} of ${table.visibleRows.length}, ${focusedColumnLabel ?? `column ${focusedCell.columnIndex + 1}`} column` : "" }),
|
|
3481
|
+
virtualizedRowLimit && table.rows.length > table.visibleRows.length ? /* @__PURE__ */ jsxs18(Text18, { size: "xs", c: "dimmed", children: [
|
|
3037
3482
|
table.visibleRows.length,
|
|
3038
3483
|
" of ",
|
|
3039
3484
|
table.rows.length,
|
|
3040
3485
|
" rows rendered in the virtualized window."
|
|
3041
3486
|
] }) : null,
|
|
3042
|
-
/* @__PURE__ */
|
|
3043
|
-
/* @__PURE__ */
|
|
3487
|
+
/* @__PURE__ */ jsxs18(Group16, { justify: "space-between", children: [
|
|
3488
|
+
/* @__PURE__ */ jsxs18(Text18, { size: "xs", c: "dimmed", children: [
|
|
3044
3489
|
table.selectedRowIds.length,
|
|
3045
3490
|
" selected"
|
|
3046
3491
|
] }),
|
|
3047
|
-
/* @__PURE__ */
|
|
3492
|
+
/* @__PURE__ */ jsx26(Pagination, { total: pageCount, value: table.query.page, onChange: table.setPage, size: "sm" })
|
|
3048
3493
|
] }),
|
|
3049
|
-
mobileCards ? /* @__PURE__ */
|
|
3494
|
+
mobileCards ? /* @__PURE__ */ jsx26(Stack13, { gap: "xs", "aria-label": "Mobile row cards", children: table.visibleRows.slice(0, 6).map((row, index) => {
|
|
3050
3495
|
const ordered = [...visibleColumns].sort((left, right) => (left.mobilePriority ?? 99) - (right.mobilePriority ?? 99));
|
|
3051
3496
|
const id = rowId(row, index);
|
|
3052
|
-
return /* @__PURE__ */
|
|
3497
|
+
return /* @__PURE__ */ jsx26(
|
|
3053
3498
|
StateBlock,
|
|
3054
3499
|
{
|
|
3055
3500
|
variant: "info",
|
|
@@ -3064,10 +3509,10 @@ function GdsDataTable({
|
|
|
3064
3509
|
}
|
|
3065
3510
|
|
|
3066
3511
|
// src/GdsResourceManager.client.tsx
|
|
3067
|
-
import { useGdsTranslation as
|
|
3068
|
-
import { useCallback as
|
|
3069
|
-
import { Button as
|
|
3070
|
-
import { jsx as
|
|
3512
|
+
import { useGdsTranslation as useGdsTranslation19 } from "@sovereignsquad/gds-theme";
|
|
3513
|
+
import { useCallback as useCallback6, useEffect as useEffect6, useMemo as useMemo8, useState as useState14 } from "react";
|
|
3514
|
+
import { Button as Button11, Group as Group17, Stack as Stack14, Text as Text19 } from "@mantine/core";
|
|
3515
|
+
import { jsx as jsx27, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3071
3516
|
function emitResourceEvent(onEvent, event) {
|
|
3072
3517
|
onEvent?.({ ...event, timestamp: Date.now(), privacy: "metadata-only" });
|
|
3073
3518
|
}
|
|
@@ -3129,11 +3574,11 @@ function useGdsResourceManager({
|
|
|
3129
3574
|
timeoutMs = 8e3,
|
|
3130
3575
|
confirmAction
|
|
3131
3576
|
}) {
|
|
3132
|
-
const [resources, setResources] =
|
|
3133
|
-
const [selectedResource, setSelectedResource] =
|
|
3134
|
-
const [state, setState] =
|
|
3135
|
-
const [error, setError] =
|
|
3136
|
-
const [reloadKey, setReloadKey] =
|
|
3577
|
+
const [resources, setResources] = useState14([]);
|
|
3578
|
+
const [selectedResource, setSelectedResource] = useState14(null);
|
|
3579
|
+
const [state, setState] = useState14("loading-list");
|
|
3580
|
+
const [error, setError] = useState14();
|
|
3581
|
+
const [reloadKey, setReloadKey] = useState14(0);
|
|
3137
3582
|
useEffect6(() => {
|
|
3138
3583
|
const controller = new AbortController();
|
|
3139
3584
|
const timer = window.setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -3154,12 +3599,12 @@ function useGdsResourceManager({
|
|
|
3154
3599
|
window.clearTimeout(timer);
|
|
3155
3600
|
};
|
|
3156
3601
|
}, [adapter, onEvent, reloadKey, timeoutMs]);
|
|
3157
|
-
const loadList =
|
|
3158
|
-
const permissions =
|
|
3159
|
-
const canRunAction =
|
|
3602
|
+
const loadList = useCallback6(() => setReloadKey((value) => value + 1), []);
|
|
3603
|
+
const permissions = useMemo8(() => adapter.getPermissions?.(selectedResource) ?? defaultPermissions(selectedResource), [adapter, selectedResource]);
|
|
3604
|
+
const canRunAction = useCallback6((action, resource = selectedResource) => {
|
|
3160
3605
|
return (adapter.getPermissions?.(resource) ?? defaultPermissions(resource)).find((permission) => permission.action === action) ?? { action, allowed: false, reason: "Action is not available." };
|
|
3161
3606
|
}, [adapter, selectedResource]);
|
|
3162
|
-
const openDetail =
|
|
3607
|
+
const openDetail = useCallback6(async (id) => {
|
|
3163
3608
|
setState("detail-loading");
|
|
3164
3609
|
try {
|
|
3165
3610
|
const resource = adapter.detail ? await adapter.detail(id) : resources.find((item) => item.id === id) ?? null;
|
|
@@ -3180,7 +3625,7 @@ function useGdsResourceManager({
|
|
|
3180
3625
|
return null;
|
|
3181
3626
|
}
|
|
3182
3627
|
}, [adapter, onEvent, resources]);
|
|
3183
|
-
const runAction =
|
|
3628
|
+
const runAction = useCallback6(async (action, resource, values = {}) => {
|
|
3184
3629
|
const permission = canRunAction(action, resource);
|
|
3185
3630
|
if (!permission.allowed) {
|
|
3186
3631
|
setState("permission-denied");
|
|
@@ -3246,30 +3691,30 @@ function GdsResourceManager({
|
|
|
3246
3691
|
timeoutMs,
|
|
3247
3692
|
confirmAction
|
|
3248
3693
|
}) {
|
|
3249
|
-
const { t } =
|
|
3694
|
+
const { t } = useGdsTranslation19();
|
|
3250
3695
|
const emptyLabel = emptyLabelProp ?? t("gds.gdsResourceManager.emptyLabel", "No resources available");
|
|
3251
3696
|
const manager = useGdsResourceManager({ adapter, onEvent, timeoutMs, confirmAction });
|
|
3252
|
-
const tableColumns =
|
|
3697
|
+
const tableColumns = useMemo8(() => columns ?? [
|
|
3253
3698
|
{ key: "title", label: "Title", sortable: true, filterable: true, mobilePriority: 1 },
|
|
3254
3699
|
{ key: "status", label: "Status", sortable: true, filterable: true, mobilePriority: 2 },
|
|
3255
3700
|
{ key: "updatedAt", label: "Updated", sortable: true, mobilePriority: 3 }
|
|
3256
3701
|
], [columns]);
|
|
3257
|
-
const tableAdapter =
|
|
3258
|
-
if (manager.state === "loading-list") return /* @__PURE__ */
|
|
3259
|
-
if (manager.state === "error") return /* @__PURE__ */
|
|
3260
|
-
if (manager.state === "empty") return /* @__PURE__ */
|
|
3261
|
-
return /* @__PURE__ */
|
|
3262
|
-
/* @__PURE__ */
|
|
3263
|
-
/* @__PURE__ */
|
|
3264
|
-
/* @__PURE__ */
|
|
3265
|
-
description ? /* @__PURE__ */
|
|
3266
|
-
manager.error ? /* @__PURE__ */
|
|
3702
|
+
const tableAdapter = useMemo8(() => createGdsTableAdapter(manager.resources, tableColumns), [manager.resources, tableColumns]);
|
|
3703
|
+
if (manager.state === "loading-list") return /* @__PURE__ */ jsx27(StateBlock, { variant: "loading", title: "Loading resources", description: "Preparing the governed resource list.", compact: true });
|
|
3704
|
+
if (manager.state === "error") return /* @__PURE__ */ jsx27(StateBlock, { variant: "error", title: "Resource workflow failed", description: manager.error ?? "The resource manager could not recover.", action: /* @__PURE__ */ jsx27(Button11, { onClick: manager.loadList, children: "Retry" }), compact: true });
|
|
3705
|
+
if (manager.state === "empty") return /* @__PURE__ */ jsx27(StateBlock, { variant: "empty", title: emptyLabel, description: "Create or import a resource to continue.", compact: true });
|
|
3706
|
+
return /* @__PURE__ */ jsxs19(Stack14, { gap: "md", children: [
|
|
3707
|
+
/* @__PURE__ */ jsxs19(Group17, { justify: "space-between", align: "start", children: [
|
|
3708
|
+
/* @__PURE__ */ jsxs19(Stack14, { gap: 2, children: [
|
|
3709
|
+
/* @__PURE__ */ jsx27(Text19, { fw: 700, children: title }),
|
|
3710
|
+
description ? /* @__PURE__ */ jsx27(Text19, { size: "sm", c: "dimmed", children: description }) : null,
|
|
3711
|
+
manager.error ? /* @__PURE__ */ jsx27(Text19, { role: "alert", size: "sm", c: "red.7", children: manager.error }) : null
|
|
3267
3712
|
] }),
|
|
3268
|
-
/* @__PURE__ */
|
|
3713
|
+
/* @__PURE__ */ jsx27(Button11, { onClick: () => {
|
|
3269
3714
|
void manager.runAction("create", null, { title: "Untitled resource" });
|
|
3270
3715
|
}, children: "Create" })
|
|
3271
3716
|
] }),
|
|
3272
|
-
/* @__PURE__ */
|
|
3717
|
+
/* @__PURE__ */ jsx27(
|
|
3273
3718
|
GdsDataTable,
|
|
3274
3719
|
{
|
|
3275
3720
|
caption: `${title} resources`,
|
|
@@ -3278,17 +3723,17 @@ function GdsResourceManager({
|
|
|
3278
3723
|
{
|
|
3279
3724
|
key: "id",
|
|
3280
3725
|
label: "Actions",
|
|
3281
|
-
render: (row) => /* @__PURE__ */
|
|
3282
|
-
/* @__PURE__ */
|
|
3726
|
+
render: (row) => /* @__PURE__ */ jsxs19(Group17, { gap: "xs", children: [
|
|
3727
|
+
/* @__PURE__ */ jsx27(Button11, { size: "xs", variant: "light", onClick: () => {
|
|
3283
3728
|
void manager.openDetail(row.id);
|
|
3284
3729
|
}, children: "Details" }),
|
|
3285
|
-
/* @__PURE__ */
|
|
3730
|
+
/* @__PURE__ */ jsx27(Button11, { size: "xs", variant: "light", onClick: () => {
|
|
3286
3731
|
void manager.runAction("activate", row);
|
|
3287
3732
|
}, disabled: !manager.canRunAction("activate", row).allowed, children: "Activate" }),
|
|
3288
|
-
/* @__PURE__ */
|
|
3733
|
+
/* @__PURE__ */ jsx27(Button11, { size: "xs", variant: "light", color: "red", onClick: () => {
|
|
3289
3734
|
void manager.runAction("delete", row);
|
|
3290
3735
|
}, disabled: !manager.canRunAction("delete", row).allowed, children: "Delete" }),
|
|
3291
|
-
/* @__PURE__ */
|
|
3736
|
+
/* @__PURE__ */ jsx27(Button11, { size: "xs", variant: "subtle", onClick: () => {
|
|
3292
3737
|
void manager.runAction("copy-preview", row);
|
|
3293
3738
|
}, disabled: !manager.canRunAction("copy-preview", row).allowed, children: "Copy preview" })
|
|
3294
3739
|
] })
|
|
@@ -3299,7 +3744,7 @@ function GdsResourceManager({
|
|
|
3299
3744
|
onEvent: (event) => onEvent?.({ type: event.type === "load_failed" ? "action_failed" : "resource_loaded", timestamp: event.timestamp, privacy: "metadata-only", message: event.message })
|
|
3300
3745
|
}
|
|
3301
3746
|
),
|
|
3302
|
-
manager.selectedResource ? /* @__PURE__ */
|
|
3747
|
+
manager.selectedResource ? /* @__PURE__ */ jsx27("section", { "aria-label": `${manager.selectedResource.title} detail`, children: renderDetail ? renderDetail(manager.selectedResource, manager) : /* @__PURE__ */ jsx27(
|
|
3303
3748
|
StateBlock,
|
|
3304
3749
|
{
|
|
3305
3750
|
variant: "info",
|
|
@@ -3312,10 +3757,10 @@ function GdsResourceManager({
|
|
|
3312
3757
|
}
|
|
3313
3758
|
|
|
3314
3759
|
// src/OverlayManager.client.tsx
|
|
3315
|
-
import { createContext as createContext4, useCallback as
|
|
3760
|
+
import { createContext as createContext4, useCallback as useCallback7, useContext as useContext4, useEffect as useEffect7, useMemo as useMemo9, useRef as useRef6, useState as useState15 } from "react";
|
|
3316
3761
|
import { Drawer, Modal as Modal2 } from "@mantine/core";
|
|
3317
|
-
import { getGdsMotionPreset, useGdsTranslation as
|
|
3318
|
-
import { jsx as
|
|
3762
|
+
import { getGdsMotionPreset, gdsDevWarnOnce as gdsDevWarnOnce4, useGdsTranslation as useGdsTranslation20 } from "@sovereignsquad/gds-theme";
|
|
3763
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
3319
3764
|
var defaultOverlayPolicy = {
|
|
3320
3765
|
closeOnEscape: true,
|
|
3321
3766
|
closeOnOutsideClick: true,
|
|
@@ -3357,13 +3802,13 @@ function OverlayManagerProvider({
|
|
|
3357
3802
|
routeKey,
|
|
3358
3803
|
onOverlayEvent
|
|
3359
3804
|
}) {
|
|
3360
|
-
const [stack, setStack] =
|
|
3361
|
-
const focusReturnTargets =
|
|
3362
|
-
const previousRouteKey =
|
|
3363
|
-
const emit =
|
|
3805
|
+
const [stack, setStack] = useState15([]);
|
|
3806
|
+
const focusReturnTargets = useRef6(/* @__PURE__ */ new Map());
|
|
3807
|
+
const previousRouteKey = useRef6(routeKey);
|
|
3808
|
+
const emit = useCallback7((type, item, reason) => {
|
|
3364
3809
|
onOverlayEvent?.(createOverlayEvent(type, item, reason));
|
|
3365
3810
|
}, [onOverlayEvent]);
|
|
3366
|
-
const registerOverlay =
|
|
3811
|
+
const registerOverlay = useCallback7((overlay) => {
|
|
3367
3812
|
const policy = normalizePolicy(defaultPolicy, overlay.policy);
|
|
3368
3813
|
const focusTarget = getFocusableElement(overlay.invokerId);
|
|
3369
3814
|
if (policy.returnFocus && focusTarget) {
|
|
@@ -3383,7 +3828,7 @@ function OverlayManagerProvider({
|
|
|
3383
3828
|
return [...base, item];
|
|
3384
3829
|
});
|
|
3385
3830
|
}, [defaultPolicy, emit, singleOverlayMode]);
|
|
3386
|
-
const unregisterOverlay =
|
|
3831
|
+
const unregisterOverlay = useCallback7((id, reason = "programmatic") => {
|
|
3387
3832
|
setStack((current) => {
|
|
3388
3833
|
const target = current.find((item) => item.id === id);
|
|
3389
3834
|
if (target) {
|
|
@@ -3397,8 +3842,8 @@ function OverlayManagerProvider({
|
|
|
3397
3842
|
focusReturnTargets.current.delete(id);
|
|
3398
3843
|
}
|
|
3399
3844
|
}, [emit]);
|
|
3400
|
-
const isTopMost =
|
|
3401
|
-
const requestClose =
|
|
3845
|
+
const isTopMost = useCallback7((id) => stack.length > 0 && stack[stack.length - 1]?.id === id, [stack]);
|
|
3846
|
+
const requestClose = useCallback7((id, reason) => {
|
|
3402
3847
|
const target = stack.find((item) => item.id === id);
|
|
3403
3848
|
if (!target || !isTopMost(id)) {
|
|
3404
3849
|
if (target) emit("blocked_close", { ...target, status: "blocked-close" }, reason);
|
|
@@ -3415,7 +3860,7 @@ function OverlayManagerProvider({
|
|
|
3415
3860
|
}
|
|
3416
3861
|
return reason;
|
|
3417
3862
|
}, [defaultPolicy, emit, isTopMost, stack]);
|
|
3418
|
-
const closeOverlay =
|
|
3863
|
+
const closeOverlay = useCallback7((id, reason = "programmatic") => {
|
|
3419
3864
|
const acceptedReason = requestClose(id, reason);
|
|
3420
3865
|
if (!acceptedReason) return false;
|
|
3421
3866
|
unregisterOverlay(id, acceptedReason);
|
|
@@ -3438,7 +3883,7 @@ function OverlayManagerProvider({
|
|
|
3438
3883
|
return preserved;
|
|
3439
3884
|
});
|
|
3440
3885
|
}, [defaultPolicy, emit, routeKey]);
|
|
3441
|
-
const value =
|
|
3886
|
+
const value = useMemo9(() => ({
|
|
3442
3887
|
stack,
|
|
3443
3888
|
registerOverlay,
|
|
3444
3889
|
unregisterOverlay,
|
|
@@ -3448,7 +3893,7 @@ function OverlayManagerProvider({
|
|
|
3448
3893
|
getOverlay: (id) => stack.find((item) => item.id === id),
|
|
3449
3894
|
requestClose
|
|
3450
3895
|
}), [closeOverlay, isTopMost, registerOverlay, requestClose, stack, unregisterOverlay]);
|
|
3451
|
-
return /* @__PURE__ */
|
|
3896
|
+
return /* @__PURE__ */ jsx28(OverlayManagerContext.Provider, { value, children });
|
|
3452
3897
|
}
|
|
3453
3898
|
function useOverlayManager() {
|
|
3454
3899
|
const context = useContext4(OverlayManagerContext);
|
|
@@ -3468,17 +3913,26 @@ function useOverlaySurface({
|
|
|
3468
3913
|
onClose,
|
|
3469
3914
|
onBlockedClose
|
|
3470
3915
|
}) {
|
|
3471
|
-
const
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3916
|
+
const manager = useContext4(OverlayManagerContext);
|
|
3917
|
+
if (!manager) {
|
|
3918
|
+
gdsDevWarnOnce4(
|
|
3919
|
+
"OverlayManager:missing-provider",
|
|
3920
|
+
"A GDS overlay (GdsModal, GdsDialog, GdsDrawer or GdsSheet) rendered without an OverlayManagerProvider. It works standalone; wrap the app in OverlayManagerProvider for stacking, the overlay registry and close blocking."
|
|
3921
|
+
);
|
|
3922
|
+
}
|
|
3923
|
+
const registerOverlay = manager?.registerOverlay;
|
|
3924
|
+
const unregisterOverlay = manager?.unregisterOverlay;
|
|
3925
|
+
const requestOverlayClose = manager?.requestClose;
|
|
3476
3926
|
useEffect7(() => {
|
|
3477
|
-
if (!opened) return void 0;
|
|
3927
|
+
if (!registerOverlay || !unregisterOverlay || !opened) return void 0;
|
|
3478
3928
|
registerOverlay({ id, kind, title, description, invokerId, policy });
|
|
3479
3929
|
return () => unregisterOverlay(id);
|
|
3480
3930
|
}, [description, id, invokerId, kind, opened, policy, registerOverlay, title, unregisterOverlay]);
|
|
3481
|
-
const requestClose =
|
|
3931
|
+
const requestClose = useCallback7((reason) => {
|
|
3932
|
+
if (!requestOverlayClose || !unregisterOverlay) {
|
|
3933
|
+
onClose();
|
|
3934
|
+
return;
|
|
3935
|
+
}
|
|
3482
3936
|
const acceptedReason = requestOverlayClose(id, reason);
|
|
3483
3937
|
if (!acceptedReason) {
|
|
3484
3938
|
onBlockedClose?.(reason);
|
|
@@ -3503,8 +3957,8 @@ function GdsModal({
|
|
|
3503
3957
|
}) {
|
|
3504
3958
|
const requestClose = useOverlaySurface({ id, opened, kind: "modal", title, description, children, invokerId, policy, onClose, onBlockedClose });
|
|
3505
3959
|
const motion = getGdsMotionPreset("overlay");
|
|
3506
|
-
const { t } =
|
|
3507
|
-
return /* @__PURE__ */
|
|
3960
|
+
const { t } = useGdsTranslation20();
|
|
3961
|
+
return /* @__PURE__ */ jsx28(
|
|
3508
3962
|
Modal2,
|
|
3509
3963
|
{
|
|
3510
3964
|
...modalProps,
|
|
@@ -3535,8 +3989,8 @@ function GdsDrawer({
|
|
|
3535
3989
|
}) {
|
|
3536
3990
|
const requestClose = useOverlaySurface({ id, opened, kind: "drawer", title, description, children, invokerId, policy, onClose, onBlockedClose });
|
|
3537
3991
|
const motion = getGdsMotionPreset("drawer");
|
|
3538
|
-
const { t } =
|
|
3539
|
-
return /* @__PURE__ */
|
|
3992
|
+
const { t } = useGdsTranslation20();
|
|
3993
|
+
return /* @__PURE__ */ jsx28(
|
|
3540
3994
|
Drawer,
|
|
3541
3995
|
{
|
|
3542
3996
|
...drawerProps,
|
|
@@ -3555,19 +4009,20 @@ function GdsDrawer({
|
|
|
3555
4009
|
);
|
|
3556
4010
|
}
|
|
3557
4011
|
function GdsSheet(props) {
|
|
3558
|
-
return /* @__PURE__ */
|
|
4012
|
+
return /* @__PURE__ */ jsx28(GdsDrawer, { ...props, position: props.position ?? "bottom", policy: { mobileFullscreen: true, ...props.policy } });
|
|
3559
4013
|
}
|
|
3560
4014
|
function GdsDialog(props) {
|
|
3561
|
-
return /* @__PURE__ */
|
|
4015
|
+
return /* @__PURE__ */ jsx28(GdsModal, { ...props });
|
|
3562
4016
|
}
|
|
3563
4017
|
function GdsSidePanel(props) {
|
|
3564
|
-
return /* @__PURE__ */
|
|
4018
|
+
return /* @__PURE__ */ jsx28(GdsDrawer, { ...props, position: props.position ?? "right" });
|
|
3565
4019
|
}
|
|
3566
4020
|
|
|
3567
4021
|
// src/Notifications.client.tsx
|
|
3568
|
-
import { useGdsTranslation as
|
|
3569
|
-
import {
|
|
3570
|
-
import {
|
|
4022
|
+
import { gdsSafeAreaInset, gdsZIndexToken, useGdsTranslation as useGdsTranslation21 } from "@sovereignsquad/gds-theme";
|
|
4023
|
+
import { Box as Box10, Button as Button12, Group as Group18, Text as Text20 } from "@mantine/core";
|
|
4024
|
+
import { createContext as createContext5, useCallback as useCallback8, useContext as useContext5, useMemo as useMemo10, useRef as useRef7, useState as useState16 } from "react";
|
|
4025
|
+
import { jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
3571
4026
|
var GdsNotificationContext = createContext5(null);
|
|
3572
4027
|
function shouldAutoClose(message) {
|
|
3573
4028
|
if (message.autoCloseMs === false) return false;
|
|
@@ -3598,13 +4053,13 @@ function GdsNotificationProvider({
|
|
|
3598
4053
|
defaultPolicy,
|
|
3599
4054
|
onAuditEvent
|
|
3600
4055
|
}) {
|
|
3601
|
-
const [notifications, setNotifications] =
|
|
3602
|
-
const [announcement, setAnnouncement] =
|
|
3603
|
-
const timers =
|
|
3604
|
-
const audit =
|
|
4056
|
+
const [notifications, setNotifications] = useState16([]);
|
|
4057
|
+
const [announcement, setAnnouncement] = useState16(null);
|
|
4058
|
+
const timers = useRef7(/* @__PURE__ */ new Map());
|
|
4059
|
+
const audit = useCallback8((type, notification, metadata = {}) => {
|
|
3605
4060
|
onAuditEvent?.(createGdsNotificationAuditEvent(type, notification, metadata));
|
|
3606
4061
|
}, [onAuditEvent]);
|
|
3607
|
-
const scheduleAutoClose =
|
|
4062
|
+
const scheduleAutoClose = useCallback8((message) => {
|
|
3608
4063
|
const existingTimer = timers.current.get(message.id);
|
|
3609
4064
|
if (existingTimer) {
|
|
3610
4065
|
window.clearTimeout(existingTimer);
|
|
@@ -3621,7 +4076,7 @@ function GdsNotificationProvider({
|
|
|
3621
4076
|
}, message.autoCloseMs);
|
|
3622
4077
|
timers.current.set(message.id, timer);
|
|
3623
4078
|
}, [audit]);
|
|
3624
|
-
const updateNotification =
|
|
4079
|
+
const updateNotification = useCallback8((id, patch) => {
|
|
3625
4080
|
setNotifications((current) => current.map((item) => {
|
|
3626
4081
|
if (item.id !== id) return item;
|
|
3627
4082
|
const updated = normalizeNotification({ ...item, ...patch, id }, defaultPolicy);
|
|
@@ -3630,7 +4085,7 @@ function GdsNotificationProvider({
|
|
|
3630
4085
|
return updated;
|
|
3631
4086
|
}));
|
|
3632
4087
|
}, [audit, defaultPolicy, scheduleAutoClose]);
|
|
3633
|
-
const dismissNotification =
|
|
4088
|
+
const dismissNotification = useCallback8((id) => {
|
|
3634
4089
|
setNotifications((current) => {
|
|
3635
4090
|
const target = current.find((item) => item.id === id);
|
|
3636
4091
|
if (target) audit("dismissed", { ...target, status: "dismissed" });
|
|
@@ -3642,13 +4097,11 @@ function GdsNotificationProvider({
|
|
|
3642
4097
|
return current.filter((item) => item.id !== id);
|
|
3643
4098
|
});
|
|
3644
4099
|
}, [audit]);
|
|
3645
|
-
const notify =
|
|
4100
|
+
const notify = useCallback8((message, policy) => {
|
|
3646
4101
|
const mergedPolicy = { ...defaultPolicy, ...policy };
|
|
3647
4102
|
const next = normalizeNotification(message, mergedPolicy);
|
|
3648
4103
|
audit("shown", next);
|
|
3649
|
-
|
|
3650
|
-
setAnnouncement(next);
|
|
3651
|
-
}
|
|
4104
|
+
setAnnouncement(next);
|
|
3652
4105
|
if (disabled) return next.id;
|
|
3653
4106
|
const dedupe = mergedPolicy.dedupe ?? "replace";
|
|
3654
4107
|
setNotifications((current) => {
|
|
@@ -3659,7 +4112,7 @@ function GdsNotificationProvider({
|
|
|
3659
4112
|
scheduleAutoClose(next);
|
|
3660
4113
|
return next.id;
|
|
3661
4114
|
}, [audit, defaultPolicy, disabled, scheduleAutoClose]);
|
|
3662
|
-
const value =
|
|
4115
|
+
const value = useMemo10(() => ({
|
|
3663
4116
|
notifications,
|
|
3664
4117
|
notify,
|
|
3665
4118
|
updateNotification,
|
|
@@ -3715,9 +4168,9 @@ function GdsNotificationProvider({
|
|
|
3715
4168
|
}
|
|
3716
4169
|
}), [audit, dismissNotification, notifications, notify, updateNotification]);
|
|
3717
4170
|
const livePolicy = announcement ? getGdsNotificationLivePolicy(announcement) : "polite";
|
|
3718
|
-
return /* @__PURE__ */
|
|
4171
|
+
return /* @__PURE__ */ jsxs20(GdsNotificationContext.Provider, { value, children: [
|
|
3719
4172
|
children,
|
|
3720
|
-
/* @__PURE__ */
|
|
4173
|
+
/* @__PURE__ */ jsx29(
|
|
3721
4174
|
"span",
|
|
3722
4175
|
{
|
|
3723
4176
|
role: announcement?.severity === "error" ? "alert" : "status",
|
|
@@ -3750,7 +4203,7 @@ function NotificationCenter({
|
|
|
3750
4203
|
title: titleProp,
|
|
3751
4204
|
emptyMessage: emptyMessageProp
|
|
3752
4205
|
}) {
|
|
3753
|
-
const { t } =
|
|
4206
|
+
const { t } = useGdsTranslation21();
|
|
3754
4207
|
const title = titleProp ?? t("gds.notifications.title", "Notifications");
|
|
3755
4208
|
const emptyMessage = emptyMessageProp ?? t("gds.notifications.emptyMessage", "No active notifications.");
|
|
3756
4209
|
const {
|
|
@@ -3760,9 +4213,10 @@ function NotificationCenter({
|
|
|
3760
4213
|
runRetry,
|
|
3761
4214
|
runAction
|
|
3762
4215
|
} = useGdsNotifications();
|
|
3763
|
-
return /* @__PURE__ */
|
|
4216
|
+
return /* @__PURE__ */ jsx29(
|
|
3764
4217
|
NotificationCenterView,
|
|
3765
4218
|
{
|
|
4219
|
+
live: false,
|
|
3766
4220
|
title,
|
|
3767
4221
|
emptyMessage,
|
|
3768
4222
|
notifications,
|
|
@@ -3778,11 +4232,61 @@ function NotificationCenter({
|
|
|
3778
4232
|
);
|
|
3779
4233
|
}
|
|
3780
4234
|
var GdsNotificationCenter = NotificationCenter;
|
|
4235
|
+
function GdsToastViewport({ position = "bottom-end", maxVisible = 3 }) {
|
|
4236
|
+
const { t } = useGdsTranslation21();
|
|
4237
|
+
const { notifications, dismissNotification, runAction, runRetry } = useGdsNotifications();
|
|
4238
|
+
const visible = notifications.filter((item) => item.persistence !== "announcement-only" && !item.announcementOnly);
|
|
4239
|
+
if (visible.length === 0) return null;
|
|
4240
|
+
const shown = visible.slice(-Math.max(1, maxVisible));
|
|
4241
|
+
const hiddenCount = visible.length - shown.length;
|
|
4242
|
+
const [vertical, horizontal] = position.split("-");
|
|
4243
|
+
const sideInset = `calc(var(--gds-space-md) + max(${gdsSafeAreaInset.left}, ${gdsSafeAreaInset.right}))`;
|
|
4244
|
+
const edgeInset = `calc(var(--gds-space-md) + ${vertical === "top" ? gdsSafeAreaInset.top : gdsSafeAreaInset.bottom})`;
|
|
4245
|
+
return /* @__PURE__ */ jsx29(
|
|
4246
|
+
Box10,
|
|
4247
|
+
{
|
|
4248
|
+
component: "section",
|
|
4249
|
+
"aria-label": t("gds.toast.regionLabel", "Recent notifications"),
|
|
4250
|
+
"data-gds-toast-viewport": position,
|
|
4251
|
+
style: {
|
|
4252
|
+
position: "fixed",
|
|
4253
|
+
zIndex: gdsZIndexToken.max,
|
|
4254
|
+
[vertical]: edgeInset,
|
|
4255
|
+
insetInlineStart: horizontal === "start" ? sideInset : void 0,
|
|
4256
|
+
insetInlineEnd: horizontal === "end" ? sideInset : void 0,
|
|
4257
|
+
inlineSize: "calc(100% - 2 * var(--gds-space-md))",
|
|
4258
|
+
display: "flex",
|
|
4259
|
+
justifyContent: horizontal === "end" ? "flex-end" : "flex-start",
|
|
4260
|
+
pointerEvents: "none"
|
|
4261
|
+
},
|
|
4262
|
+
children: /* @__PURE__ */ jsxs20(GdsStack, { gap: "sm", maxWidth: "aside", style: { inlineSize: "100%", pointerEvents: "auto" }, children: [
|
|
4263
|
+
hiddenCount > 0 ? /* @__PURE__ */ jsx29(Text20, { size: "xs", c: "dimmed", children: t("gds.toast.more", "{count} more").replace("{count}", String(hiddenCount)) }) : null,
|
|
4264
|
+
shown.map((item) => /* @__PURE__ */ jsx29(
|
|
4265
|
+
InlineAlert,
|
|
4266
|
+
{
|
|
4267
|
+
live: false,
|
|
4268
|
+
severity: item.severity,
|
|
4269
|
+
status: item.status,
|
|
4270
|
+
title: item.title,
|
|
4271
|
+
message: item.message,
|
|
4272
|
+
action: /* @__PURE__ */ jsxs20(Group18, { gap: "xs", children: [
|
|
4273
|
+
item.actions?.map((action) => /* @__PURE__ */ jsx29(Button12, { size: "xs", variant: "default", onClick: () => runAction(item.id, action.id), disabled: action.disabled, children: action.label }, action.id)),
|
|
4274
|
+
item.retry ? /* @__PURE__ */ jsx29(Button12, { size: "xs", variant: "default", onClick: () => void runRetry(item.id), disabled: item.status === "retrying", children: item.status === "retrying" ? t("gds.notifications.status.retrying", "Retrying") : item.retry.label ?? t("gds.notifications.retry", "Retry") }) : null,
|
|
4275
|
+
/* @__PURE__ */ jsx29(Button12, { size: "xs", variant: "subtle", onClick: () => dismissNotification(item.id), children: t("gds.notifications.dismiss", "Dismiss") })
|
|
4276
|
+
] })
|
|
4277
|
+
},
|
|
4278
|
+
item.id
|
|
4279
|
+
))
|
|
4280
|
+
] })
|
|
4281
|
+
}
|
|
4282
|
+
);
|
|
4283
|
+
}
|
|
3781
4284
|
|
|
3782
4285
|
// src/FeedbackRuntime.client.tsx
|
|
3783
|
-
import { createContext as createContext6, useCallback as
|
|
3784
|
-
import {
|
|
3785
|
-
import {
|
|
4286
|
+
import { createContext as createContext6, useCallback as useCallback9, useContext as useContext6, useMemo as useMemo11, useRef as useRef8, useState as useState17 } from "react";
|
|
4287
|
+
import { useGdsTranslation as useGdsTranslation22 } from "@sovereignsquad/gds-theme";
|
|
4288
|
+
import { Alert as Alert2, Button as Button13, Group as Group19, Paper as Paper7, Stack as Stack15, Text as Text21 } from "@mantine/core";
|
|
4289
|
+
import { Fragment as Fragment4, jsx as jsx30, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
3786
4290
|
var GdsConfirmContext = createContext6(null);
|
|
3787
4291
|
function createConfirmationEvent(type, request, status) {
|
|
3788
4292
|
return {
|
|
@@ -3804,20 +4308,21 @@ function GdsConfirmProvider({
|
|
|
3804
4308
|
defaultTimeoutMs = 1e4,
|
|
3805
4309
|
onConfirmationEvent
|
|
3806
4310
|
}) {
|
|
3807
|
-
const
|
|
3808
|
-
const [
|
|
3809
|
-
const
|
|
3810
|
-
const
|
|
3811
|
-
const
|
|
3812
|
-
const
|
|
4311
|
+
const { t } = useGdsTranslation22();
|
|
4312
|
+
const [activeRequest, setActiveRequest] = useState17(null);
|
|
4313
|
+
const [undoState, setUndoState] = useState17(null);
|
|
4314
|
+
const activeResolver = useRef8(null);
|
|
4315
|
+
const actionResolver = useRef8(null);
|
|
4316
|
+
const focusReturnTarget = useRef8(null);
|
|
4317
|
+
const emit = useCallback9((type, request, status) => {
|
|
3813
4318
|
onConfirmationEvent?.(createConfirmationEvent(type, request, status));
|
|
3814
4319
|
}, [onConfirmationEvent]);
|
|
3815
|
-
const restoreFocus =
|
|
4320
|
+
const restoreFocus = useCallback9(() => {
|
|
3816
4321
|
const target = focusReturnTarget.current;
|
|
3817
4322
|
focusReturnTarget.current = null;
|
|
3818
4323
|
if (target) window.setTimeout(() => target.focus(), 0);
|
|
3819
4324
|
}, []);
|
|
3820
|
-
const openConfirm =
|
|
4325
|
+
const openConfirm = useCallback9((request) => new Promise((resolve) => {
|
|
3821
4326
|
if (activeResolver.current) {
|
|
3822
4327
|
activeResolver.current(false);
|
|
3823
4328
|
}
|
|
@@ -3826,7 +4331,7 @@ function GdsConfirmProvider({
|
|
|
3826
4331
|
emit("opened", request, "open");
|
|
3827
4332
|
setActiveRequest({ ...request, mode: "boolean", status: "open", resolve });
|
|
3828
4333
|
}), [emit]);
|
|
3829
|
-
const openActionConfirm =
|
|
4334
|
+
const openActionConfirm = useCallback9((request) => new Promise((resolve) => {
|
|
3830
4335
|
if (actionResolver.current) {
|
|
3831
4336
|
actionResolver.current({ status: "cancelled" });
|
|
3832
4337
|
}
|
|
@@ -3844,7 +4349,7 @@ function GdsConfirmProvider({
|
|
|
3844
4349
|
resolve: resolver
|
|
3845
4350
|
});
|
|
3846
4351
|
}), [emit]);
|
|
3847
|
-
const resolveActive =
|
|
4352
|
+
const resolveActive = useCallback9((confirmed) => {
|
|
3848
4353
|
if (activeRequest?.mode === "boolean") {
|
|
3849
4354
|
emit(confirmed ? "confirmed" : "cancelled", activeRequest, confirmed ? "succeeded" : "cancelled");
|
|
3850
4355
|
}
|
|
@@ -3853,7 +4358,7 @@ function GdsConfirmProvider({
|
|
|
3853
4358
|
setActiveRequest(null);
|
|
3854
4359
|
restoreFocus();
|
|
3855
4360
|
}, [activeRequest, emit, restoreFocus]);
|
|
3856
|
-
const cancelAction =
|
|
4361
|
+
const cancelAction = useCallback9(() => {
|
|
3857
4362
|
if (activeRequest?.mode === "action") {
|
|
3858
4363
|
emit("cancelled", activeRequest, "cancelled");
|
|
3859
4364
|
actionResolver.current?.({ status: "cancelled", payload: activeRequest.payload });
|
|
@@ -3862,7 +4367,7 @@ function GdsConfirmProvider({
|
|
|
3862
4367
|
setActiveRequest(null);
|
|
3863
4368
|
restoreFocus();
|
|
3864
4369
|
}, [activeRequest, emit, restoreFocus]);
|
|
3865
|
-
const runAction =
|
|
4370
|
+
const runAction = useCallback9(async (retry = false) => {
|
|
3866
4371
|
if (!activeRequest || activeRequest.mode !== "action") return;
|
|
3867
4372
|
const request = activeRequest;
|
|
3868
4373
|
if (retry) emit("retry", request, "executing");
|
|
@@ -3887,7 +4392,7 @@ function GdsConfirmProvider({
|
|
|
3887
4392
|
const undoPolicy = request.undo;
|
|
3888
4393
|
setUndoState({
|
|
3889
4394
|
id: request.id ?? "confirmation-undo",
|
|
3890
|
-
label: undoPolicy.label
|
|
4395
|
+
label: undoPolicy.label,
|
|
3891
4396
|
expiresAt,
|
|
3892
4397
|
onUndo: async () => {
|
|
3893
4398
|
emit("undo_started", request, "undoable");
|
|
@@ -3907,28 +4412,28 @@ function GdsConfirmProvider({
|
|
|
3907
4412
|
setActiveRequest(null);
|
|
3908
4413
|
restoreFocus();
|
|
3909
4414
|
} catch (error) {
|
|
3910
|
-
const message = error instanceof Error ? error.message :
|
|
4415
|
+
const message = error instanceof Error ? error.message : void 0;
|
|
3911
4416
|
emit("failed", request, "failed");
|
|
3912
4417
|
setActiveRequest({ ...request, status: "failed", error: message });
|
|
3913
4418
|
}
|
|
3914
4419
|
}, [activeRequest, defaultTimeoutMs, emit, restoreFocus]);
|
|
3915
|
-
const value =
|
|
4420
|
+
const value = useMemo11(() => ({
|
|
3916
4421
|
confirm: openConfirm,
|
|
3917
4422
|
confirmDestructive: (request) => openConfirm({ ...request, danger: true, confirmAction: request.confirmAction ?? "delete" }),
|
|
3918
4423
|
confirmAction: openActionConfirm
|
|
3919
4424
|
}), [openActionConfirm, openConfirm]);
|
|
3920
|
-
return /* @__PURE__ */
|
|
4425
|
+
return /* @__PURE__ */ jsxs21(GdsConfirmContext.Provider, { value, children: [
|
|
3921
4426
|
children,
|
|
3922
|
-
undoState ? /* @__PURE__ */
|
|
3923
|
-
/* @__PURE__ */
|
|
3924
|
-
/* @__PURE__ */
|
|
3925
|
-
/* @__PURE__ */
|
|
4427
|
+
undoState ? /* @__PURE__ */ jsx30(Paper7, { withBorder: true, radius: "md", p: "sm", mb: "sm", role: "status", "aria-live": "polite", "aria-label": t("gds.confirm.undoTitle", "Action can be undone"), children: /* @__PURE__ */ jsxs21(Group19, { justify: "space-between", children: [
|
|
4428
|
+
/* @__PURE__ */ jsxs21(Stack15, { gap: 2, children: [
|
|
4429
|
+
/* @__PURE__ */ jsx30(Text21, { fw: 700, size: "sm", children: t("gds.confirm.undoTitle", "Action can be undone") }),
|
|
4430
|
+
/* @__PURE__ */ jsx30(Text21, { size: "sm", children: t("gds.confirm.undoDescription", "Undo is available until the recovery window expires.") })
|
|
3926
4431
|
] }),
|
|
3927
|
-
/* @__PURE__ */
|
|
4432
|
+
/* @__PURE__ */ jsx30(Button13, { size: "xs", variant: "default", onClick: () => {
|
|
3928
4433
|
void undoState.onUndo();
|
|
3929
|
-
}, children: undoState.label })
|
|
4434
|
+
}, children: undoState.label ?? t("gds.confirm.undo", "Undo") })
|
|
3930
4435
|
] }) }) : null,
|
|
3931
|
-
/* @__PURE__ */
|
|
4436
|
+
/* @__PURE__ */ jsx30(
|
|
3932
4437
|
ConfirmDialog,
|
|
3933
4438
|
{
|
|
3934
4439
|
opened: Boolean(activeRequest),
|
|
@@ -3939,18 +4444,18 @@ function GdsConfirmProvider({
|
|
|
3939
4444
|
cancelAction: activeRequest?.cancelAction ?? "cancel",
|
|
3940
4445
|
isDanger: activeRequest?.danger ?? false,
|
|
3941
4446
|
loading: activeRequest?.status === "executing" || activeRequest?.status === "validating",
|
|
3942
|
-
children: /* @__PURE__ */
|
|
3943
|
-
activeRequest?.targetName ? /* @__PURE__ */
|
|
3944
|
-
activeRequest?.targetName ? /* @__PURE__ */
|
|
4447
|
+
children: /* @__PURE__ */ jsxs21(Stack15, { gap: "xs", children: [
|
|
4448
|
+
activeRequest?.targetName ? /* @__PURE__ */ jsx30("strong", { children: activeRequest.targetName }) : null,
|
|
4449
|
+
activeRequest?.targetName ? /* @__PURE__ */ jsx30("br", {}) : null,
|
|
3945
4450
|
activeRequest?.message,
|
|
3946
|
-
activeRequest?.consequence ? /* @__PURE__ */
|
|
3947
|
-
/* @__PURE__ */
|
|
4451
|
+
activeRequest?.consequence ? /* @__PURE__ */ jsxs21(Fragment4, { children: [
|
|
4452
|
+
/* @__PURE__ */ jsx30("br", {}),
|
|
3948
4453
|
activeRequest.consequence
|
|
3949
4454
|
] }) : null,
|
|
3950
|
-
activeRequest?.mode === "action" && activeRequest.preview ? /* @__PURE__ */
|
|
3951
|
-
activeRequest?.mode === "action" && activeRequest.status === "failed" ? /* @__PURE__ */
|
|
3952
|
-
/* @__PURE__ */
|
|
3953
|
-
activeRequest.retryable ? /* @__PURE__ */
|
|
4455
|
+
activeRequest?.mode === "action" && activeRequest.preview ? /* @__PURE__ */ jsx30("div", { children: activeRequest.preview }) : null,
|
|
4456
|
+
activeRequest?.mode === "action" && activeRequest.status === "failed" ? /* @__PURE__ */ jsxs21(Alert2, { color: "red", title: t("gds.confirm.failedTitle", "Action failed"), role: "alert", children: [
|
|
4457
|
+
/* @__PURE__ */ jsx30(Text21, { size: "sm", children: activeRequest.error ?? t("gds.confirm.failedDescription", "The action did not complete.") }),
|
|
4458
|
+
activeRequest.retryable ? /* @__PURE__ */ jsx30(Text21, { size: "xs", children: t("gds.confirm.retryHint", "Use the primary action to retry.") }) : null
|
|
3954
4459
|
] }) : null
|
|
3955
4460
|
] })
|
|
3956
4461
|
}
|
|
@@ -3968,12 +4473,15 @@ var GdsToastContext = createContext6(null);
|
|
|
3968
4473
|
function createToastId(prefix) {
|
|
3969
4474
|
return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
3970
4475
|
}
|
|
3971
|
-
function GdsToastProvider({ children }) {
|
|
3972
|
-
return /* @__PURE__ */
|
|
4476
|
+
function GdsToastProvider({ children, viewport = true }) {
|
|
4477
|
+
return /* @__PURE__ */ jsxs21(GdsNotificationProvider, { children: [
|
|
4478
|
+
/* @__PURE__ */ jsx30(GdsToastProviderInner, { children }),
|
|
4479
|
+
viewport ? /* @__PURE__ */ jsx30(GdsToastViewport, { ...viewport === true ? {} : viewport }) : null
|
|
4480
|
+
] });
|
|
3973
4481
|
}
|
|
3974
4482
|
function GdsToastProviderInner({ children }) {
|
|
3975
4483
|
const { notify } = useGdsNotifications();
|
|
3976
|
-
const value =
|
|
4484
|
+
const value = useMemo11(() => ({
|
|
3977
4485
|
notifySuccess: (message) => notify({
|
|
3978
4486
|
...message,
|
|
3979
4487
|
id: message.id ?? createToastId("success"),
|
|
@@ -3985,7 +4493,7 @@ function GdsToastProviderInner({ children }) {
|
|
|
3985
4493
|
id: message.id ?? createToastId("error"),
|
|
3986
4494
|
severity: "error",
|
|
3987
4495
|
autoCloseMs: message.autoCloseMs ?? false,
|
|
3988
|
-
retry: message.retry ? { onRetry: message.retry, maxAttempts: 3
|
|
4496
|
+
retry: message.retry ? { onRetry: message.retry, maxAttempts: 3 } : void 0
|
|
3989
4497
|
}),
|
|
3990
4498
|
notifyActionComplete: (message) => notify({
|
|
3991
4499
|
...message,
|
|
@@ -3994,7 +4502,7 @@ function GdsToastProviderInner({ children }) {
|
|
|
3994
4502
|
autoCloseMs: message.autoCloseMs ?? 3e3
|
|
3995
4503
|
})
|
|
3996
4504
|
}), [notify]);
|
|
3997
|
-
return /* @__PURE__ */
|
|
4505
|
+
return /* @__PURE__ */ jsx30(GdsToastContext.Provider, { value, children });
|
|
3998
4506
|
}
|
|
3999
4507
|
function useGdsToasts() {
|
|
4000
4508
|
const context = useContext6(GdsToastContext);
|
|
@@ -4005,9 +4513,9 @@ function useGdsToasts() {
|
|
|
4005
4513
|
}
|
|
4006
4514
|
|
|
4007
4515
|
// src/CommandPalette.client.tsx
|
|
4008
|
-
import { createContext as createContext7, useContext as useContext7, useEffect as useEffect8, useMemo as
|
|
4009
|
-
import { ActionIcon as ActionIcon3, Group as
|
|
4010
|
-
import { jsx as
|
|
4516
|
+
import { createContext as createContext7, useContext as useContext7, useEffect as useEffect8, useMemo as useMemo12, useState as useState18 } from "react";
|
|
4517
|
+
import { ActionIcon as ActionIcon3, Group as Group20, Modal as Modal3, Stack as Stack16, Text as Text22, TextInput as TextInput3 } from "@mantine/core";
|
|
4518
|
+
import { jsx as jsx31, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
4011
4519
|
var CommandPaletteContext = createContext7(null);
|
|
4012
4520
|
function normalize(text) {
|
|
4013
4521
|
return text.trim().toLowerCase();
|
|
@@ -4025,17 +4533,17 @@ function scoreCommand(command, query, recentUse) {
|
|
|
4025
4533
|
return 0.6 * prefix + 0.3 * keyword + 0.1 * recent;
|
|
4026
4534
|
}
|
|
4027
4535
|
function CommandRegistryProvider({ children }) {
|
|
4028
|
-
const [commands, setCommands] =
|
|
4029
|
-
const [opened, setOpened] =
|
|
4030
|
-
const value =
|
|
4536
|
+
const [commands, setCommands] = useState18([]);
|
|
4537
|
+
const [opened, setOpened] = useState18(false);
|
|
4538
|
+
const value = useMemo12(() => ({
|
|
4031
4539
|
commands,
|
|
4032
4540
|
registerCommands: (next) => setCommands(next),
|
|
4033
4541
|
open: () => setOpened(true),
|
|
4034
4542
|
close: () => setOpened(false)
|
|
4035
4543
|
}), [commands]);
|
|
4036
|
-
return /* @__PURE__ */
|
|
4544
|
+
return /* @__PURE__ */ jsxs22(CommandPaletteContext.Provider, { value, children: [
|
|
4037
4545
|
children,
|
|
4038
|
-
/* @__PURE__ */
|
|
4546
|
+
/* @__PURE__ */ jsx31(CommandPalette, { opened, onClose: () => setOpened(false) })
|
|
4039
4547
|
] });
|
|
4040
4548
|
}
|
|
4041
4549
|
function useCommandLauncher() {
|
|
@@ -4055,8 +4563,8 @@ function CommandPalette({ opened, onClose }) {
|
|
|
4055
4563
|
throw new Error("CommandPalette must be used within CommandRegistryProvider.");
|
|
4056
4564
|
}
|
|
4057
4565
|
const registry = contextValue;
|
|
4058
|
-
const [query, setQuery] =
|
|
4059
|
-
const [recentUse, setRecentUse] =
|
|
4566
|
+
const [query, setQuery] = useState18("");
|
|
4567
|
+
const [recentUse, setRecentUse] = useState18({});
|
|
4060
4568
|
const enabledCommands = registry.commands.filter((command) => command.enabledWhen ? command.enabledWhen() : true);
|
|
4061
4569
|
const filteredCommands = [...enabledCommands].map((command) => ({ command, score: scoreCommand(command, query, recentUse) })).filter(({ command, score }) => normalize(query) === "" || score > 0 || normalize(command.label).includes(normalize(query))).sort((a, b) => b.score - a.score).map((item) => item.command);
|
|
4062
4570
|
useEffect8(() => {
|
|
@@ -4072,8 +4580,8 @@ function CommandPalette({ opened, onClose }) {
|
|
|
4072
4580
|
window.addEventListener("keydown", onKeyDown);
|
|
4073
4581
|
return () => window.removeEventListener("keydown", onKeyDown);
|
|
4074
4582
|
}, [registry, opened, onClose]);
|
|
4075
|
-
return /* @__PURE__ */
|
|
4076
|
-
/* @__PURE__ */
|
|
4583
|
+
return /* @__PURE__ */ jsx31(Modal3, { opened, onClose, title: "Quick actions", centered: true, children: /* @__PURE__ */ jsxs22(Stack16, { gap: "sm", children: [
|
|
4584
|
+
/* @__PURE__ */ jsx31(
|
|
4077
4585
|
TextInput3,
|
|
4078
4586
|
{
|
|
4079
4587
|
"aria-label": "Command search",
|
|
@@ -4082,8 +4590,8 @@ function CommandPalette({ opened, onClose }) {
|
|
|
4082
4590
|
onChange: (event) => setQuery(event.currentTarget.value)
|
|
4083
4591
|
}
|
|
4084
4592
|
),
|
|
4085
|
-
filteredCommands.length === 0 ? /* @__PURE__ */
|
|
4086
|
-
/* @__PURE__ */
|
|
4593
|
+
filteredCommands.length === 0 ? /* @__PURE__ */ jsx31(Text22, { size: "sm", c: "dimmed", children: "No matching commands." }) : filteredCommands.map((command) => /* @__PURE__ */ jsxs22(Group20, { justify: "space-between", wrap: "nowrap", children: [
|
|
4594
|
+
/* @__PURE__ */ jsx31(
|
|
4087
4595
|
"button",
|
|
4088
4596
|
{
|
|
4089
4597
|
type: "button",
|
|
@@ -4096,26 +4604,26 @@ function CommandPalette({ opened, onClose }) {
|
|
|
4096
4604
|
children: command.label
|
|
4097
4605
|
}
|
|
4098
4606
|
),
|
|
4099
|
-
command.shortcut ? /* @__PURE__ */
|
|
4607
|
+
command.shortcut ? /* @__PURE__ */ jsx31(Text22, { size: "xs", c: "dimmed", children: command.shortcut }) : null
|
|
4100
4608
|
] }, command.id)),
|
|
4101
|
-
/* @__PURE__ */
|
|
4609
|
+
/* @__PURE__ */ jsx31(Group20, { justify: "flex-end", children: /* @__PURE__ */ jsx31(ActionIcon3, { variant: "subtle", "aria-label": "Close command palette", onClick: onClose, children: /* @__PURE__ */ jsx31(GdsIcons.Close, { size: "1rem" }) }) })
|
|
4102
4610
|
] }) });
|
|
4103
4611
|
}
|
|
4104
4612
|
|
|
4105
4613
|
// src/GdsTour.client.tsx
|
|
4106
4614
|
import {
|
|
4107
4615
|
createContext as createContext8,
|
|
4108
|
-
useCallback as
|
|
4616
|
+
useCallback as useCallback10,
|
|
4109
4617
|
useContext as useContext8,
|
|
4110
4618
|
useEffect as useEffect9,
|
|
4111
4619
|
useLayoutEffect,
|
|
4112
|
-
useMemo as
|
|
4113
|
-
useRef as
|
|
4114
|
-
useState as
|
|
4620
|
+
useMemo as useMemo13,
|
|
4621
|
+
useRef as useRef9,
|
|
4622
|
+
useState as useState19
|
|
4115
4623
|
} from "react";
|
|
4116
4624
|
import { createPortal } from "react-dom";
|
|
4117
|
-
import { useGdsTranslation as
|
|
4118
|
-
import { Fragment as
|
|
4625
|
+
import { useGdsTranslation as useGdsTranslation23 } from "@sovereignsquad/gds-theme";
|
|
4626
|
+
import { Fragment as Fragment5, jsx as jsx32, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4119
4627
|
var GdsTourContext = createContext8(null);
|
|
4120
4628
|
var SEEN_KEY_PREFIX = "gds-tour-seen:";
|
|
4121
4629
|
function hasSeen(tourId) {
|
|
@@ -4134,7 +4642,7 @@ function markSeen(tourId) {
|
|
|
4134
4642
|
}
|
|
4135
4643
|
}
|
|
4136
4644
|
function useHasSeenTour(tourId) {
|
|
4137
|
-
const [seen, setSeen] =
|
|
4645
|
+
const [seen, setSeen] = useState19(false);
|
|
4138
4646
|
useEffect9(() => {
|
|
4139
4647
|
setSeen(hasSeen(tourId));
|
|
4140
4648
|
}, [tourId]);
|
|
@@ -4190,29 +4698,29 @@ function computeCardPosition(hole, card, placement) {
|
|
|
4190
4698
|
}
|
|
4191
4699
|
var FOCUSABLE = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
4192
4700
|
function GdsTourProvider({ children }) {
|
|
4193
|
-
const { t } =
|
|
4194
|
-
const [tourId, setTourId] =
|
|
4195
|
-
const [steps, setSteps] =
|
|
4196
|
-
const [index, setIndex] =
|
|
4197
|
-
const [status, setStatus] =
|
|
4198
|
-
const [rect, setRect] =
|
|
4199
|
-
const [cardPos, setCardPos] =
|
|
4200
|
-
const [mounted, setMounted] =
|
|
4201
|
-
const optionsRef =
|
|
4202
|
-
const invokerRef =
|
|
4203
|
-
const cardRef =
|
|
4204
|
-
const targetElRef =
|
|
4701
|
+
const { t } = useGdsTranslation23();
|
|
4702
|
+
const [tourId, setTourId] = useState19(null);
|
|
4703
|
+
const [steps, setSteps] = useState19([]);
|
|
4704
|
+
const [index, setIndex] = useState19(0);
|
|
4705
|
+
const [status, setStatus] = useState19("idle");
|
|
4706
|
+
const [rect, setRect] = useState19(null);
|
|
4707
|
+
const [cardPos, setCardPos] = useState19(null);
|
|
4708
|
+
const [mounted, setMounted] = useState19(false);
|
|
4709
|
+
const optionsRef = useRef9({});
|
|
4710
|
+
const invokerRef = useRef9(null);
|
|
4711
|
+
const cardRef = useRef9(null);
|
|
4712
|
+
const targetElRef = useRef9(null);
|
|
4205
4713
|
useEffect9(() => setMounted(true), []);
|
|
4206
4714
|
const running = status === "running";
|
|
4207
4715
|
const activeStep = running ? steps[index] ?? null : null;
|
|
4208
4716
|
const count = steps.length;
|
|
4209
|
-
const clearActiveTargetAttr =
|
|
4717
|
+
const clearActiveTargetAttr = useCallback10(() => {
|
|
4210
4718
|
if (targetElRef.current) {
|
|
4211
4719
|
targetElRef.current.removeAttribute("data-gds-tour-active-target");
|
|
4212
4720
|
targetElRef.current = null;
|
|
4213
4721
|
}
|
|
4214
4722
|
}, []);
|
|
4215
|
-
const finish =
|
|
4723
|
+
const finish = useCallback10(
|
|
4216
4724
|
(nextStatus, reason) => {
|
|
4217
4725
|
const opts = optionsRef.current;
|
|
4218
4726
|
const id = tourId;
|
|
@@ -4231,10 +4739,10 @@ function GdsTourProvider({ children }) {
|
|
|
4231
4739
|
},
|
|
4232
4740
|
[clearActiveTargetAttr, tourId]
|
|
4233
4741
|
);
|
|
4234
|
-
const stop =
|
|
4742
|
+
const stop = useCallback10((reason = "programmatic") => {
|
|
4235
4743
|
finish(reason === "finished" ? "finished" : "skipped", reason);
|
|
4236
4744
|
}, [finish]);
|
|
4237
|
-
const start =
|
|
4745
|
+
const start = useCallback10(
|
|
4238
4746
|
(id, tourSteps, options = {}) => {
|
|
4239
4747
|
if (!tourSteps.length) return;
|
|
4240
4748
|
optionsRef.current = options;
|
|
@@ -4246,7 +4754,7 @@ function GdsTourProvider({ children }) {
|
|
|
4246
4754
|
},
|
|
4247
4755
|
[]
|
|
4248
4756
|
);
|
|
4249
|
-
const goTo =
|
|
4757
|
+
const goTo = useCallback10(
|
|
4250
4758
|
(nextIndex) => {
|
|
4251
4759
|
setIndex((current) => {
|
|
4252
4760
|
const clamped = Math.max(0, Math.min(nextIndex, steps.length - 1));
|
|
@@ -4256,14 +4764,14 @@ function GdsTourProvider({ children }) {
|
|
|
4256
4764
|
},
|
|
4257
4765
|
[steps]
|
|
4258
4766
|
);
|
|
4259
|
-
const next =
|
|
4767
|
+
const next = useCallback10(() => {
|
|
4260
4768
|
if (index >= steps.length - 1) {
|
|
4261
4769
|
finish("finished", "finished");
|
|
4262
4770
|
} else {
|
|
4263
4771
|
goTo(index + 1);
|
|
4264
4772
|
}
|
|
4265
4773
|
}, [index, steps.length, finish, goTo]);
|
|
4266
|
-
const back =
|
|
4774
|
+
const back = useCallback10(() => {
|
|
4267
4775
|
if (index > 0) goTo(index - 1);
|
|
4268
4776
|
}, [index, goTo]);
|
|
4269
4777
|
useLayoutEffect(() => {
|
|
@@ -4366,20 +4874,20 @@ function GdsTourProvider({ children }) {
|
|
|
4366
4874
|
window.addEventListener("keydown", onKeyDown, true);
|
|
4367
4875
|
return () => window.removeEventListener("keydown", onKeyDown, true);
|
|
4368
4876
|
}, [running, activeStep, next, back, finish]);
|
|
4369
|
-
const value =
|
|
4877
|
+
const value = useMemo13(
|
|
4370
4878
|
() => ({ status, tourId, index, count, activeStep, start, next, back, goTo, stop }),
|
|
4371
4879
|
[status, tourId, index, count, activeStep, start, next, back, goTo, stop]
|
|
4372
4880
|
);
|
|
4373
4881
|
const overlay = mounted && running && activeStep && rect ? createPortal(
|
|
4374
|
-
/* @__PURE__ */
|
|
4375
|
-
/* @__PURE__ */
|
|
4882
|
+
/* @__PURE__ */ jsxs23(Fragment5, { children: [
|
|
4883
|
+
/* @__PURE__ */ jsxs23(
|
|
4376
4884
|
"div",
|
|
4377
4885
|
{
|
|
4378
4886
|
className: `gds-tour-spotlight${activeStep.interaction === "allow-target" ? " gds-tour-spotlight--interactive" : ""}`,
|
|
4379
4887
|
"data-gds-tour-overlay": "",
|
|
4380
4888
|
children: [
|
|
4381
|
-
activeStep.interaction !== "allow-target" ? /* @__PURE__ */
|
|
4382
|
-
/* @__PURE__ */
|
|
4889
|
+
activeStep.interaction !== "allow-target" ? /* @__PURE__ */ jsx32("div", { className: "gds-tour-spotlight__blocker", "aria-hidden": "true" }) : null,
|
|
4890
|
+
/* @__PURE__ */ jsx32(
|
|
4383
4891
|
"div",
|
|
4384
4892
|
{
|
|
4385
4893
|
className: "gds-tour-spotlight__hole",
|
|
@@ -4390,7 +4898,7 @@ function GdsTourProvider({ children }) {
|
|
|
4390
4898
|
]
|
|
4391
4899
|
}
|
|
4392
4900
|
),
|
|
4393
|
-
/* @__PURE__ */
|
|
4901
|
+
/* @__PURE__ */ jsxs23(
|
|
4394
4902
|
"div",
|
|
4395
4903
|
{
|
|
4396
4904
|
ref: cardRef,
|
|
@@ -4402,11 +4910,11 @@ function GdsTourProvider({ children }) {
|
|
|
4402
4910
|
tabIndex: -1,
|
|
4403
4911
|
style: cardPos ? { top: cardPos.top, left: cardPos.left } : { top: 16, left: 16, visibility: "hidden" },
|
|
4404
4912
|
children: [
|
|
4405
|
-
/* @__PURE__ */
|
|
4406
|
-
/* @__PURE__ */
|
|
4407
|
-
/* @__PURE__ */
|
|
4408
|
-
/* @__PURE__ */
|
|
4409
|
-
activeStep.canSkip !== false ? /* @__PURE__ */
|
|
4913
|
+
/* @__PURE__ */ jsx32("p", { className: "gds-tour-card__progress", "aria-live": "polite", children: t("gds.tour.stepOfTotal", "Step {n} of {m}").replace("{n}", String(index + 1)).replace("{m}", String(count)) }),
|
|
4914
|
+
/* @__PURE__ */ jsx32("h2", { id: "gds-tour-title", className: "gds-tour-card__title", children: activeStep.title }),
|
|
4915
|
+
/* @__PURE__ */ jsx32("div", { id: "gds-tour-body", className: "gds-tour-card__body", children: activeStep.body }),
|
|
4916
|
+
/* @__PURE__ */ jsxs23("div", { className: "gds-tour-card__actions", children: [
|
|
4917
|
+
activeStep.canSkip !== false ? /* @__PURE__ */ jsx32(
|
|
4410
4918
|
"button",
|
|
4411
4919
|
{
|
|
4412
4920
|
type: "button",
|
|
@@ -4414,10 +4922,10 @@ function GdsTourProvider({ children }) {
|
|
|
4414
4922
|
onClick: () => finish("skipped", "skipped"),
|
|
4415
4923
|
children: t("gds.tour.skip", "Skip")
|
|
4416
4924
|
}
|
|
4417
|
-
) : /* @__PURE__ */
|
|
4418
|
-
/* @__PURE__ */
|
|
4419
|
-
index > 0 ? /* @__PURE__ */
|
|
4420
|
-
/* @__PURE__ */
|
|
4925
|
+
) : /* @__PURE__ */ jsx32("span", {}),
|
|
4926
|
+
/* @__PURE__ */ jsxs23("div", { className: "gds-tour-card__nav", children: [
|
|
4927
|
+
index > 0 ? /* @__PURE__ */ jsx32("button", { type: "button", className: "gds-tour-btn gds-tour-btn--secondary", onClick: back, children: t("gds.tour.back", "Back") }) : null,
|
|
4928
|
+
/* @__PURE__ */ jsx32("button", { type: "button", className: "gds-tour-btn gds-tour-btn--primary", onClick: next, children: index >= count - 1 ? t("gds.tour.done", "Done") : t("gds.tour.next", "Next") })
|
|
4421
4929
|
] })
|
|
4422
4930
|
] })
|
|
4423
4931
|
]
|
|
@@ -4426,7 +4934,7 @@ function GdsTourProvider({ children }) {
|
|
|
4426
4934
|
] }),
|
|
4427
4935
|
document.body
|
|
4428
4936
|
) : null;
|
|
4429
|
-
return /* @__PURE__ */
|
|
4937
|
+
return /* @__PURE__ */ jsxs23(GdsTourContext.Provider, { value, children: [
|
|
4430
4938
|
children,
|
|
4431
4939
|
overlay
|
|
4432
4940
|
] });
|
|
@@ -4440,7 +4948,7 @@ function useGdsTour() {
|
|
|
4440
4948
|
}
|
|
4441
4949
|
function GdsGuidedTour({ id, steps, open = false, defaultStep, ...options }) {
|
|
4442
4950
|
const { start, status } = useGdsTour();
|
|
4443
|
-
const startedRef =
|
|
4951
|
+
const startedRef = useRef9(false);
|
|
4444
4952
|
useEffect9(() => {
|
|
4445
4953
|
if (!open || startedRef.current || status === "running") return;
|
|
4446
4954
|
if (options.persist === "localStorage" && hasSeen(id)) return;
|
|
@@ -4463,8 +4971,8 @@ function GdsTourButton({
|
|
|
4463
4971
|
...buttonProps
|
|
4464
4972
|
}) {
|
|
4465
4973
|
const { start } = useGdsTour();
|
|
4466
|
-
const { t } =
|
|
4467
|
-
return /* @__PURE__ */
|
|
4974
|
+
const { t } = useGdsTranslation23();
|
|
4975
|
+
return /* @__PURE__ */ jsx32(
|
|
4468
4976
|
"button",
|
|
4469
4977
|
{
|
|
4470
4978
|
type: "button",
|
|
@@ -4477,10 +4985,10 @@ function GdsTourButton({
|
|
|
4477
4985
|
}
|
|
4478
4986
|
|
|
4479
4987
|
// src/LayoutTemplatePreview.client.tsx
|
|
4480
|
-
import { useGdsTranslation as
|
|
4481
|
-
import { useMemo as
|
|
4482
|
-
import { Alert as Alert3, Button as
|
|
4483
|
-
import { jsx as
|
|
4988
|
+
import { useGdsTranslation as useGdsTranslation24 } from "@sovereignsquad/gds-theme";
|
|
4989
|
+
import { useMemo as useMemo14, useState as useState20 } from "react";
|
|
4990
|
+
import { Alert as Alert3, Button as Button14, Group as Group21, NativeSelect as NativeSelect2, Stack as Stack17, Text as Text23, Textarea } from "@mantine/core";
|
|
4991
|
+
import { jsx as jsx33, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
4484
4992
|
function templateText(template) {
|
|
4485
4993
|
return JSON.stringify(template.schema, null, 2);
|
|
4486
4994
|
}
|
|
@@ -4493,24 +5001,24 @@ function GdsLayoutTemplatePreview({
|
|
|
4493
5001
|
title: titleProp,
|
|
4494
5002
|
description: descriptionProp
|
|
4495
5003
|
}) {
|
|
4496
|
-
const { t } =
|
|
5004
|
+
const { t } = useGdsTranslation24();
|
|
4497
5005
|
const title = titleProp ?? t("gds.layoutTemplatePreview.title", "Template cookbook");
|
|
4498
5006
|
const description = descriptionProp ?? t("gds.layoutTemplatePreview.description", "Pick a template, edit JSON, then apply to preview live diagnostics and rendered layout.");
|
|
4499
5007
|
const initialTemplate = templates.find((template) => template.id === initialTemplateId) ?? templates[0];
|
|
4500
5008
|
const initialText = initialTemplate ? templateText(initialTemplate) : '{\n "version": "1",\n "blocks": []\n}';
|
|
4501
|
-
const [selectedTemplateId, setSelectedTemplateId] =
|
|
4502
|
-
const [schemaText, setSchemaText] =
|
|
4503
|
-
const [appliedSchemaText, setAppliedSchemaText] =
|
|
4504
|
-
const [editorError, setEditorError] =
|
|
4505
|
-
const [copyState, setCopyState] =
|
|
5009
|
+
const [selectedTemplateId, setSelectedTemplateId] = useState20(initialTemplate?.id ?? "");
|
|
5010
|
+
const [schemaText, setSchemaText] = useState20(initialText);
|
|
5011
|
+
const [appliedSchemaText, setAppliedSchemaText] = useState20(initialText);
|
|
5012
|
+
const [editorError, setEditorError] = useState20("");
|
|
5013
|
+
const [copyState, setCopyState] = useState20("idle");
|
|
4506
5014
|
const selectedTemplate = templates.find((template) => template.id === selectedTemplateId);
|
|
4507
|
-
const renderedTemplate =
|
|
5015
|
+
const renderedTemplate = useMemo14(() => {
|
|
4508
5016
|
try {
|
|
4509
5017
|
return renderGdsLayoutWithDiagnostics(parseSchema(appliedSchemaText));
|
|
4510
5018
|
} catch {
|
|
4511
5019
|
return {
|
|
4512
5020
|
issues: [{ blockId: "schema", message: "Unable to parse schema JSON. Make sure the payload is valid JSON." }],
|
|
4513
|
-
node: /* @__PURE__ */
|
|
5021
|
+
node: /* @__PURE__ */ jsx33(
|
|
4514
5022
|
StateBlock,
|
|
4515
5023
|
{
|
|
4516
5024
|
variant: "error",
|
|
@@ -4559,8 +5067,8 @@ function GdsLayoutTemplatePreview({
|
|
|
4559
5067
|
}
|
|
4560
5068
|
};
|
|
4561
5069
|
const issueCount = renderedTemplate.issues.length;
|
|
4562
|
-
return /* @__PURE__ */
|
|
4563
|
-
/* @__PURE__ */
|
|
5070
|
+
return /* @__PURE__ */ jsx33(SectionPanel, { title, description, children: /* @__PURE__ */ jsxs24(Stack17, { gap: "md", children: [
|
|
5071
|
+
/* @__PURE__ */ jsx33(
|
|
4564
5072
|
NativeSelect2,
|
|
4565
5073
|
{
|
|
4566
5074
|
label: "Template preset",
|
|
@@ -4570,7 +5078,7 @@ function GdsLayoutTemplatePreview({
|
|
|
4570
5078
|
data: templates.map((template) => ({ value: template.id, label: template.title }))
|
|
4571
5079
|
}
|
|
4572
5080
|
),
|
|
4573
|
-
/* @__PURE__ */
|
|
5081
|
+
/* @__PURE__ */ jsx33(
|
|
4574
5082
|
Textarea,
|
|
4575
5083
|
{
|
|
4576
5084
|
label: "Current template summary",
|
|
@@ -4581,7 +5089,7 @@ Use case: ${selectedTemplate.useCase}` : "",
|
|
|
4581
5089
|
minRows: 2
|
|
4582
5090
|
}
|
|
4583
5091
|
),
|
|
4584
|
-
/* @__PURE__ */
|
|
5092
|
+
/* @__PURE__ */ jsx33(
|
|
4585
5093
|
Textarea,
|
|
4586
5094
|
{
|
|
4587
5095
|
label: "Layout schema JSON",
|
|
@@ -4592,19 +5100,19 @@ Use case: ${selectedTemplate.useCase}` : "",
|
|
|
4592
5100
|
onChange: (event) => setSchemaText(event.currentTarget.value)
|
|
4593
5101
|
}
|
|
4594
5102
|
),
|
|
4595
|
-
/* @__PURE__ */
|
|
4596
|
-
/* @__PURE__ */
|
|
4597
|
-
/* @__PURE__ */
|
|
4598
|
-
/* @__PURE__ */
|
|
5103
|
+
/* @__PURE__ */ jsxs24(Group21, { gap: "sm", children: [
|
|
5104
|
+
/* @__PURE__ */ jsx33(Button14, { type: "button", onClick: applySchema, children: "Apply schema" }),
|
|
5105
|
+
/* @__PURE__ */ jsx33(Button14, { type: "button", variant: "default", onClick: resetTemplate, children: "Reset to template" }),
|
|
5106
|
+
/* @__PURE__ */ jsx33(Button14, { type: "button", variant: "light", onClick: () => void copySchema(), children: "Copy schema" })
|
|
4599
5107
|
] }),
|
|
4600
|
-
editorError ? /* @__PURE__ */
|
|
4601
|
-
copyState === "success" ? /* @__PURE__ */
|
|
4602
|
-
copyState === "error" ? /* @__PURE__ */
|
|
4603
|
-
/* @__PURE__ */
|
|
5108
|
+
editorError ? /* @__PURE__ */ jsx33(StateBlock, { variant: "error", title: "Invalid JSON", description: editorError }) : null,
|
|
5109
|
+
copyState === "success" ? /* @__PURE__ */ jsx33(Alert3, { color: "green", children: "Schema copied to clipboard." }) : null,
|
|
5110
|
+
copyState === "error" ? /* @__PURE__ */ jsx33(Alert3, { color: "yellow", children: "Clipboard copy is unavailable in this browser context." }) : null,
|
|
5111
|
+
/* @__PURE__ */ jsxs24(Text23, { "aria-live": "polite", children: [
|
|
4604
5112
|
"Diagnostic result: ",
|
|
4605
5113
|
issueCount === 0 ? "no issues" : `${issueCount} issue${issueCount === 1 ? "" : "s"}`
|
|
4606
5114
|
] }),
|
|
4607
|
-
/* @__PURE__ */
|
|
5115
|
+
/* @__PURE__ */ jsx33(
|
|
4608
5116
|
SectionPanel,
|
|
4609
5117
|
{
|
|
4610
5118
|
title: `Schema render preview (${selectedTemplate?.schema.version ?? "1"})`,
|
|
@@ -4612,7 +5120,7 @@ Use case: ${selectedTemplate.useCase}` : "",
|
|
|
4612
5120
|
children: renderedTemplate.node
|
|
4613
5121
|
}
|
|
4614
5122
|
),
|
|
4615
|
-
issueCount ? /* @__PURE__ */
|
|
5123
|
+
issueCount ? /* @__PURE__ */ jsx33(SectionPanel, { title: "Schema issues", description: "Fix these payload issues before using the template in production code.", children: /* @__PURE__ */ jsx33(Stack17, { component: "ul", gap: 4, children: renderedTemplate.issues.map((issue, index) => /* @__PURE__ */ jsxs24("li", { children: [
|
|
4616
5124
|
issue.blockId ? `${issue.blockId}: ` : "",
|
|
4617
5125
|
issue.message
|
|
4618
5126
|
] }, `${issue.blockId ?? "schema"}-${index}`)) }) }) : null
|
|
@@ -4620,8 +5128,8 @@ Use case: ${selectedTemplate.useCase}` : "",
|
|
|
4620
5128
|
}
|
|
4621
5129
|
|
|
4622
5130
|
// src/Telemetry.client.tsx
|
|
4623
|
-
import { createContext as createContext9, useContext as useContext9, useMemo as
|
|
4624
|
-
import { jsx as
|
|
5131
|
+
import { createContext as createContext9, useContext as useContext9, useMemo as useMemo15 } from "react";
|
|
5132
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
4625
5133
|
var gdsOperationalEventTypes = [
|
|
4626
5134
|
"submit",
|
|
4627
5135
|
"submit_success",
|
|
@@ -4840,11 +5348,11 @@ function GdsTelemetryProvider({
|
|
|
4840
5348
|
payloadPolicy,
|
|
4841
5349
|
onAdapterError
|
|
4842
5350
|
}) {
|
|
4843
|
-
const value =
|
|
5351
|
+
const value = useMemo15(() => ({
|
|
4844
5352
|
emit: (event) => emitGdsEvent({ adapter, sink, sampleRate, payloadPolicy, onAdapterError }, event),
|
|
4845
5353
|
emitGdsEvent: (event) => emitGdsEvent({ adapter, sink, sampleRate, payloadPolicy, onAdapterError }, event)
|
|
4846
5354
|
}), [adapter, onAdapterError, payloadPolicy, sampleRate, sink]);
|
|
4847
|
-
return /* @__PURE__ */
|
|
5355
|
+
return /* @__PURE__ */ jsx34(GdsTelemetryContext.Provider, { value, children });
|
|
4848
5356
|
}
|
|
4849
5357
|
function useGdsTelemetry() {
|
|
4850
5358
|
const context = useContext9(GdsTelemetryContext);
|
|
@@ -4855,8 +5363,8 @@ function useGdsTelemetry() {
|
|
|
4855
5363
|
}
|
|
4856
5364
|
|
|
4857
5365
|
// src/PublicCaptureFlow.tsx
|
|
4858
|
-
import { Stack as
|
|
4859
|
-
import { jsx as
|
|
5366
|
+
import { Stack as Stack18, Text as Text24 } from "@mantine/core";
|
|
5367
|
+
import { jsx as jsx35, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
4860
5368
|
var stageCopy = {
|
|
4861
5369
|
identify: { title: "Who are you?", description: "Enter the information required for this public flow." },
|
|
4862
5370
|
consent: { title: "Review consent", description: "Confirm the required consent before continuing." },
|
|
@@ -4875,10 +5383,10 @@ function toFlowStatus(state) {
|
|
|
4875
5383
|
}
|
|
4876
5384
|
function runtimeStateBody(state) {
|
|
4877
5385
|
if (state === "permission-denied") {
|
|
4878
|
-
return /* @__PURE__ */
|
|
5386
|
+
return /* @__PURE__ */ jsx35(StateBlock, { variant: "permission", title: "Permission required", description: "Allow access or use the provided recovery action to continue." });
|
|
4879
5387
|
}
|
|
4880
5388
|
if (state === "hardware-unavailable") {
|
|
4881
|
-
return /* @__PURE__ */
|
|
5389
|
+
return /* @__PURE__ */ jsx35(StateBlock, { variant: "error", title: "Capture unavailable", description: "The required hardware surface is not available on this device." });
|
|
4882
5390
|
}
|
|
4883
5391
|
return null;
|
|
4884
5392
|
}
|
|
@@ -4896,8 +5404,8 @@ function PublicCaptureFlow({
|
|
|
4896
5404
|
}) {
|
|
4897
5405
|
const copy = stageCopy[stage];
|
|
4898
5406
|
const runtimeBody = runtimeStateBody(state);
|
|
4899
|
-
const flowBody = runtimeBody ?? (stage === "share" && share ? /* @__PURE__ */
|
|
4900
|
-
return /* @__PURE__ */
|
|
5407
|
+
const flowBody = runtimeBody ?? (stage === "share" && share ? /* @__PURE__ */ jsx35(PublicShareOverlay, { ...share }) : body);
|
|
5408
|
+
return /* @__PURE__ */ jsx35(
|
|
4901
5409
|
PublicFlowShell,
|
|
4902
5410
|
{
|
|
4903
5411
|
exitAction,
|
|
@@ -4915,34 +5423,34 @@ function PublicCaptureFlow({
|
|
|
4915
5423
|
);
|
|
4916
5424
|
}
|
|
4917
5425
|
function PublicIdentityStep({ children }) {
|
|
4918
|
-
return /* @__PURE__ */
|
|
5426
|
+
return /* @__PURE__ */ jsx35(Stack18, { gap: "md", children });
|
|
4919
5427
|
}
|
|
4920
5428
|
function PublicConsentStep({ consentText, control }) {
|
|
4921
|
-
return /* @__PURE__ */
|
|
4922
|
-
/* @__PURE__ */
|
|
5429
|
+
return /* @__PURE__ */ jsxs25(Stack18, { gap: "md", children: [
|
|
5430
|
+
/* @__PURE__ */ jsx35(Text24, { children: consentText }),
|
|
4923
5431
|
control
|
|
4924
5432
|
] });
|
|
4925
5433
|
}
|
|
4926
5434
|
function PublicAcceptStep({ preview, actions }) {
|
|
4927
|
-
return /* @__PURE__ */
|
|
5435
|
+
return /* @__PURE__ */ jsxs25(Stack18, { gap: "md", children: [
|
|
4928
5436
|
preview,
|
|
4929
5437
|
actions
|
|
4930
5438
|
] });
|
|
4931
5439
|
}
|
|
4932
5440
|
function PublicCtaStep({ children }) {
|
|
4933
|
-
return /* @__PURE__ */
|
|
5441
|
+
return /* @__PURE__ */ jsx35(Stack18, { gap: "md", children });
|
|
4934
5442
|
}
|
|
4935
5443
|
function PublicRestartStep({ children }) {
|
|
4936
|
-
return /* @__PURE__ */
|
|
5444
|
+
return /* @__PURE__ */ jsx35(Stack18, { gap: "md", children });
|
|
4937
5445
|
}
|
|
4938
5446
|
function PublicShareOverlay(props) {
|
|
4939
|
-
return /* @__PURE__ */
|
|
5447
|
+
return /* @__PURE__ */ jsx35(ShareButtonGroup, { ...props });
|
|
4940
5448
|
}
|
|
4941
5449
|
|
|
4942
5450
|
// src/PlaybackControls.client.tsx
|
|
4943
5451
|
import { useEffect as useEffect10 } from "react";
|
|
4944
|
-
import { ActionIcon as ActionIcon4, Group as
|
|
4945
|
-
import { jsx as
|
|
5452
|
+
import { ActionIcon as ActionIcon4, Group as Group22, Text as Text25 } from "@mantine/core";
|
|
5453
|
+
import { jsx as jsx36, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
4946
5454
|
function isInteractiveTarget(target) {
|
|
4947
5455
|
if (!(target instanceof HTMLElement)) return false;
|
|
4948
5456
|
return ["INPUT", "TEXTAREA", "SELECT", "BUTTON", "A"].includes(target.tagName) || target.isContentEditable;
|
|
@@ -4986,33 +5494,127 @@ function PlaybackControls({
|
|
|
4986
5494
|
}) {
|
|
4987
5495
|
const playing = state === "playing";
|
|
4988
5496
|
const disabled = state === "loading" || state === "empty" || state === "error";
|
|
4989
|
-
return /* @__PURE__ */
|
|
4990
|
-
/* @__PURE__ */
|
|
4991
|
-
/* @__PURE__ */
|
|
4992
|
-
/* @__PURE__ */
|
|
4993
|
-
onRestart ? /* @__PURE__ */
|
|
4994
|
-
onFullscreenChange ? /* @__PURE__ */
|
|
4995
|
-
/* @__PURE__ */
|
|
5497
|
+
return /* @__PURE__ */ jsxs26(Group22, { gap: "xs", wrap: "wrap", align: "center", children: [
|
|
5498
|
+
/* @__PURE__ */ jsx36(ActionIcon4, { variant: "default", size: "lg", "aria-label": "Previous", onClick: onPrevious, disabled: disabled || !canGoPrevious, children: /* @__PURE__ */ jsx36(GdsIcons.Back, { size: "1rem" }) }),
|
|
5499
|
+
/* @__PURE__ */ jsx36(ActionIcon4, { variant: "filled", size: "lg", "aria-label": playing ? "Pause" : "Play", onClick: onPlayPause, disabled, children: playing ? /* @__PURE__ */ jsx36(GdsIcons.Pause, { size: "1rem" }) : /* @__PURE__ */ jsx36(GdsIcons.Play, { size: "1rem" }) }),
|
|
5500
|
+
/* @__PURE__ */ jsx36(ActionIcon4, { variant: "default", size: "lg", "aria-label": "Next", onClick: onNext, disabled: disabled || !canGoNext, children: /* @__PURE__ */ jsx36(GdsIcons.Forward, { size: "1rem" }) }),
|
|
5501
|
+
onRestart ? /* @__PURE__ */ jsx36(ActionIcon4, { variant: "subtle", size: "lg", "aria-label": "Restart", onClick: onRestart, disabled: state === "loading", children: /* @__PURE__ */ jsx36(GdsIcons.Refresh, { size: "1rem" }) }) : null,
|
|
5502
|
+
onFullscreenChange ? /* @__PURE__ */ jsx36(ActionIcon4, { variant: "subtle", size: "lg", "aria-label": fullscreen ? "Exit fullscreen" : "Enter fullscreen", onClick: () => onFullscreenChange(!fullscreen), children: /* @__PURE__ */ jsx36(GdsIcons.Launch, { size: "1rem" }) }) : null,
|
|
5503
|
+
/* @__PURE__ */ jsx36(Text25, { size: "sm", c: "dimmed", "aria-live": "polite", children: state })
|
|
4996
5504
|
] });
|
|
4997
5505
|
}
|
|
4998
5506
|
function PlaybackOverlayControls(props) {
|
|
4999
|
-
return /* @__PURE__ */
|
|
5507
|
+
return /* @__PURE__ */ jsx36(PlaybackControls, { ...props });
|
|
5508
|
+
}
|
|
5509
|
+
|
|
5510
|
+
// src/GdsPageTemplates.client.tsx
|
|
5511
|
+
import { useEffect as useEffect11, useId as useId2, useRef as useRef10 } from "react";
|
|
5512
|
+
import { Box as Box11, Button as Button15, Grid, Title as Title3 } from "@mantine/core";
|
|
5513
|
+
import { useMediaQuery as useMediaQuery3, useUncontrolled as useUncontrolled3 } from "@mantine/hooks";
|
|
5514
|
+
import { useGdsTranslation as useGdsTranslation25 } from "@sovereignsquad/gds-theme";
|
|
5515
|
+
import { jsx as jsx37, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
5516
|
+
function GdsAssetManagerTemplate({
|
|
5517
|
+
state = "ready",
|
|
5518
|
+
tree,
|
|
5519
|
+
toolbar,
|
|
5520
|
+
bulkActions,
|
|
5521
|
+
table,
|
|
5522
|
+
grid,
|
|
5523
|
+
view: viewProp,
|
|
5524
|
+
defaultView = "table",
|
|
5525
|
+
onViewChange,
|
|
5526
|
+
upload,
|
|
5527
|
+
detail,
|
|
5528
|
+
shapeProfile = "operations",
|
|
5529
|
+
onRetry,
|
|
5530
|
+
retryLabel,
|
|
5531
|
+
...props
|
|
5532
|
+
}) {
|
|
5533
|
+
const { t } = useGdsTranslation25();
|
|
5534
|
+
const [view, setView] = useUncontrolled3({ value: viewProp, defaultValue: defaultView, finalValue: "table", onChange: onViewChange });
|
|
5535
|
+
const items = table && grid ? view === "grid" ? grid : table : table ?? grid;
|
|
5536
|
+
return /* @__PURE__ */ jsx37(GdsShapeScope, { profile: shapeProfile, children: /* @__PURE__ */ jsx37(PageTemplateFrame, { id: "asset-manager", state, ...props, children: /* @__PURE__ */ jsx37(
|
|
5537
|
+
TemplateStateGate,
|
|
5538
|
+
{
|
|
5539
|
+
state,
|
|
5540
|
+
onRetry,
|
|
5541
|
+
retryLabel,
|
|
5542
|
+
successContent: /* @__PURE__ */ jsxs27(Grid, { style: { gap: "var(--gds-space-md)" }, children: [
|
|
5543
|
+
tree ? /* @__PURE__ */ jsx37(Grid.Col, { span: { base: 12, md: 3 }, children: /* @__PURE__ */ jsx37(Box11, { component: "nav", "aria-label": t("gds.assetManagerTemplate.folders", "Folders"), "data-gds-asset-tree": "", children: tree }) }) : null,
|
|
5544
|
+
/* @__PURE__ */ jsx37(Grid.Col, { span: { base: 12, md: tree ? 9 : 12 }, children: /* @__PURE__ */ jsxs27(GdsStack, { gap: "md", children: [
|
|
5545
|
+
toolbar,
|
|
5546
|
+
bulkActions ? /* @__PURE__ */ jsx37(GdsBulkActionBar, { ...bulkActions }) : null,
|
|
5547
|
+
table && grid ? /* @__PURE__ */ jsx37(GdsViewToggle, { value: view, onChange: setView }) : null,
|
|
5548
|
+
items ?? /* @__PURE__ */ jsx37(StateBlock, { variant: "empty", compact: true, titleOrder: 2, title: t("gds.assetManagerTemplate.emptyTitle", "This folder is empty") }),
|
|
5549
|
+
upload,
|
|
5550
|
+
detail ? /* @__PURE__ */ jsx37(SectionPanel, { titleOrder: 2, title: t("gds.assetManagerTemplate.detailTitle", "Selected item"), children: detail }) : null
|
|
5551
|
+
] }) })
|
|
5552
|
+
] })
|
|
5553
|
+
}
|
|
5554
|
+
) }) });
|
|
5555
|
+
}
|
|
5556
|
+
function GdsWorkspaceInboxTemplate({
|
|
5557
|
+
state = "ready",
|
|
5558
|
+
navigation,
|
|
5559
|
+
threadList,
|
|
5560
|
+
detail,
|
|
5561
|
+
detailTitle,
|
|
5562
|
+
hasSelection = false,
|
|
5563
|
+
detailLoading = false,
|
|
5564
|
+
onBack,
|
|
5565
|
+
regionHeight,
|
|
5566
|
+
onRetry,
|
|
5567
|
+
retryLabel,
|
|
5568
|
+
...props
|
|
5569
|
+
}) {
|
|
5570
|
+
const { t } = useGdsTranslation25();
|
|
5571
|
+
const narrow = useMediaQuery3("(max-width: 48em)");
|
|
5572
|
+
const headingId = useId2();
|
|
5573
|
+
const headingRef = useRef10(null);
|
|
5574
|
+
useEffect11(() => {
|
|
5575
|
+
if (narrow && hasSelection) headingRef.current?.focus();
|
|
5576
|
+
}, [narrow, hasSelection]);
|
|
5577
|
+
const scroll = regionHeight ? { maxBlockSize: regionHeight, overflowY: "auto" } : void 0;
|
|
5578
|
+
const conversationsLabel = t("gds.workspaceInboxTemplate.conversations", "Conversations");
|
|
5579
|
+
const title = detailTitle ?? t("gds.workspaceInboxTemplate.conversation", "Conversation");
|
|
5580
|
+
const listRegion = /* @__PURE__ */ jsx37(Box11, { component: "section", "aria-label": conversationsLabel, style: scroll, "data-gds-inbox-list": "", children: threadList });
|
|
5581
|
+
const detailRegion = /* @__PURE__ */ jsx37(Box11, { component: "section", "aria-labelledby": headingId, style: scroll, "data-gds-inbox-detail": "", children: /* @__PURE__ */ jsxs27(GdsStack, { gap: "sm", children: [
|
|
5582
|
+
narrow && hasSelection && onBack ? /* @__PURE__ */ jsx37(Button15, { variant: "subtle", size: "xs", onClick: onBack, style: { alignSelf: "flex-start" }, children: t("gds.workspaceInboxTemplate.back", "Back to conversations") }) : null,
|
|
5583
|
+
/* @__PURE__ */ jsx37(Title3, { order: 2, size: "h4", id: headingId, ref: headingRef, tabIndex: -1, children: title }),
|
|
5584
|
+
detailLoading ? /* @__PURE__ */ jsx37(StateBlock, { variant: "loading", compact: true, titleOrder: 3, title: t("gds.workspaceInboxTemplate.loading", "Loading conversation") }) : hasSelection ? detail : /* @__PURE__ */ jsx37(StateBlock, { variant: "empty", compact: true, titleOrder: 3, title: t("gds.workspaceInboxTemplate.noSelection", "Select a conversation") })
|
|
5585
|
+
] }) });
|
|
5586
|
+
return /* @__PURE__ */ jsx37(PageTemplateFrame, { id: "workspace-inbox", state, ...props, children: /* @__PURE__ */ jsx37(
|
|
5587
|
+
TemplateStateGate,
|
|
5588
|
+
{
|
|
5589
|
+
state,
|
|
5590
|
+
onRetry,
|
|
5591
|
+
retryLabel,
|
|
5592
|
+
successContent: narrow ? hasSelection ? detailRegion : /* @__PURE__ */ jsxs27(GdsStack, { gap: "md", children: [
|
|
5593
|
+
navigation ? /* @__PURE__ */ jsx37(Box11, { component: "nav", "aria-label": t("gds.workspaceInboxTemplate.navigation", "Workspace"), children: navigation }) : null,
|
|
5594
|
+
listRegion
|
|
5595
|
+
] }) : /* @__PURE__ */ jsxs27(Grid, { style: { gap: "var(--gds-space-md)" }, children: [
|
|
5596
|
+
navigation ? /* @__PURE__ */ jsx37(Grid.Col, { span: { base: 12, md: 2 }, children: /* @__PURE__ */ jsx37(Box11, { component: "nav", "aria-label": t("gds.workspaceInboxTemplate.navigation", "Workspace"), style: scroll, children: navigation }) }) : null,
|
|
5597
|
+
/* @__PURE__ */ jsx37(Grid.Col, { span: { base: 12, md: navigation ? 4 : 5 }, children: listRegion }),
|
|
5598
|
+
/* @__PURE__ */ jsx37(Grid.Col, { span: { base: 12, md: navigation ? 6 : 7 }, children: detailRegion })
|
|
5599
|
+
] })
|
|
5600
|
+
}
|
|
5601
|
+
) });
|
|
5000
5602
|
}
|
|
5001
5603
|
|
|
5002
5604
|
// src/TrustLayer.client.tsx
|
|
5003
|
-
import { useRef as
|
|
5004
|
-
import { Button as
|
|
5005
|
-
import { useGdsTranslation as
|
|
5006
|
-
import { Fragment as
|
|
5605
|
+
import { useRef as useRef11, useState as useState21 } from "react";
|
|
5606
|
+
import { Button as Button16, Checkbox as Checkbox4, Group as Group23, Paper as Paper8, Stack as Stack19, Text as Text26, VisuallyHidden as VisuallyHidden6 } from "@mantine/core";
|
|
5607
|
+
import { useGdsTranslation as useGdsTranslation26, GDS_MIN_TARGET_PX } from "@sovereignsquad/gds-theme";
|
|
5608
|
+
import { Fragment as Fragment6, jsx as jsx38, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
5007
5609
|
var ROLE_SUCCESS = "var(--gds-state-success, var(--mantine-color-green-7))";
|
|
5008
5610
|
var ROLE_WARNING = "var(--gds-state-warning, var(--mantine-color-yellow-8))";
|
|
5009
5611
|
var ROLE_META = "var(--gds-text-meta, var(--gds-vibe-muted, var(--mantine-color-gray-7)))";
|
|
5010
5612
|
var ROLE_WARNING_TINT_BG = "var(--gds-badge-soft-warning, var(--mantine-color-yellow-0))";
|
|
5011
5613
|
var ROLE_WARNING_TINT_FG = "var(--gds-badge-soft-warning-fg, var(--mantine-color-yellow-9))";
|
|
5012
5614
|
function ReportOutdatedLink({ onReport, label }) {
|
|
5013
|
-
const { t } =
|
|
5014
|
-
const [sent, setSent] =
|
|
5015
|
-
const sentRef =
|
|
5615
|
+
const { t } = useGdsTranslation26();
|
|
5616
|
+
const [sent, setSent] = useState21(false);
|
|
5617
|
+
const sentRef = useRef11(false);
|
|
5016
5618
|
const actionLabel = label ?? t("gds.trust.report.action", "Report outdated info");
|
|
5017
5619
|
const thanksText = t("gds.trust.report.thanks", "Thanks \u2014 we'll re-check this listing.");
|
|
5018
5620
|
const handleActivate = () => {
|
|
@@ -5021,25 +5623,25 @@ function ReportOutdatedLink({ onReport, label }) {
|
|
|
5021
5623
|
setSent(true);
|
|
5022
5624
|
onReport?.();
|
|
5023
5625
|
};
|
|
5024
|
-
return /* @__PURE__ */
|
|
5025
|
-
sent ? /* @__PURE__ */
|
|
5026
|
-
|
|
5626
|
+
return /* @__PURE__ */ jsxs28(Fragment6, { children: [
|
|
5627
|
+
sent ? /* @__PURE__ */ jsx38(Text26, { component: "span", size: "sm", fw: 600, c: ROLE_SUCCESS, children: thanksText }) : /* @__PURE__ */ jsx38(
|
|
5628
|
+
Button16,
|
|
5027
5629
|
{
|
|
5028
5630
|
type: "button",
|
|
5029
5631
|
variant: "subtle",
|
|
5030
5632
|
color: "gray",
|
|
5031
5633
|
size: "sm",
|
|
5032
|
-
leftSection: /* @__PURE__ */
|
|
5634
|
+
leftSection: /* @__PURE__ */ jsx38(GdsIcon, { icon: "Flag", size: "xs" }),
|
|
5033
5635
|
onClick: handleActivate,
|
|
5034
5636
|
styles: { root: { minHeight: `${GDS_MIN_TARGET_PX}px` } },
|
|
5035
5637
|
children: actionLabel
|
|
5036
5638
|
}
|
|
5037
5639
|
),
|
|
5038
|
-
/* @__PURE__ */
|
|
5640
|
+
/* @__PURE__ */ jsx38(VisuallyHidden6, { role: "status", "aria-live": "polite", "aria-atomic": "true", children: sent ? thanksText : "" })
|
|
5039
5641
|
] });
|
|
5040
5642
|
}
|
|
5041
5643
|
function useSourceRowStatusLabels() {
|
|
5042
|
-
const { t } =
|
|
5644
|
+
const { t } = useGdsTranslation26();
|
|
5043
5645
|
return {
|
|
5044
5646
|
estimate: t("gds.trust.source.statusEstimate", "Estimate"),
|
|
5045
5647
|
confirmed: t("gds.trust.source.statusConfirmed", "Confirmed"),
|
|
@@ -5050,8 +5652,8 @@ function sourceRowStatusRole(status) {
|
|
|
5050
5652
|
return status === "confirmed" ? ROLE_SUCCESS : ROLE_WARNING;
|
|
5051
5653
|
}
|
|
5052
5654
|
function SourceBlockRow({ label, children }) {
|
|
5053
|
-
return /* @__PURE__ */
|
|
5054
|
-
|
|
5655
|
+
return /* @__PURE__ */ jsxs28(
|
|
5656
|
+
Group23,
|
|
5055
5657
|
{
|
|
5056
5658
|
justify: "space-between",
|
|
5057
5659
|
align: "center",
|
|
@@ -5060,41 +5662,41 @@ function SourceBlockRow({ label, children }) {
|
|
|
5060
5662
|
py: 4,
|
|
5061
5663
|
style: { borderTop: "1px solid var(--gds-border-card, var(--mantine-color-gray-3))" },
|
|
5062
5664
|
children: [
|
|
5063
|
-
/* @__PURE__ */
|
|
5665
|
+
/* @__PURE__ */ jsx38(Text26, { size: "sm", fw: 500, c: ROLE_META, children: label }),
|
|
5064
5666
|
children
|
|
5065
5667
|
]
|
|
5066
5668
|
}
|
|
5067
5669
|
);
|
|
5068
5670
|
}
|
|
5069
5671
|
function SourceBlock({ sourceType, sourceUrl, lastChecked, priceStatus, scheduleStatus, onReport }) {
|
|
5070
|
-
const { t } =
|
|
5672
|
+
const { t } = useGdsTranslation26();
|
|
5071
5673
|
const statusLabels = useSourceRowStatusLabels();
|
|
5072
5674
|
const unknownValue = t("gds.trust.source.unknownValue", "Unknown \u2014 confirm with provider");
|
|
5073
5675
|
let sourceTypeContent;
|
|
5074
5676
|
if (sourceUrl) {
|
|
5075
|
-
sourceTypeContent = /* @__PURE__ */
|
|
5677
|
+
sourceTypeContent = /* @__PURE__ */ jsx38(GdsInlineLink, { href: sourceUrl, external: true, children: sourceType || unknownValue });
|
|
5076
5678
|
} else if (sourceType) {
|
|
5077
|
-
sourceTypeContent = /* @__PURE__ */
|
|
5679
|
+
sourceTypeContent = /* @__PURE__ */ jsx38(Text26, { size: "sm", children: sourceType });
|
|
5078
5680
|
} else {
|
|
5079
|
-
sourceTypeContent = /* @__PURE__ */
|
|
5681
|
+
sourceTypeContent = /* @__PURE__ */ jsx38(Text26, { size: "sm", c: ROLE_META, children: unknownValue });
|
|
5080
5682
|
}
|
|
5081
|
-
return /* @__PURE__ */
|
|
5082
|
-
/* @__PURE__ */
|
|
5083
|
-
/* @__PURE__ */
|
|
5084
|
-
/* @__PURE__ */
|
|
5683
|
+
return /* @__PURE__ */ jsx38(Paper8, { withBorder: true, radius: "lg", p: "md", "data-gds-source-block": "", children: /* @__PURE__ */ jsxs28(Stack19, { gap: "xs", children: [
|
|
5684
|
+
/* @__PURE__ */ jsxs28(Group23, { gap: "xs", children: [
|
|
5685
|
+
/* @__PURE__ */ jsx38(GdsIcon, { icon: "SourceInfo", size: "sm" }),
|
|
5686
|
+
/* @__PURE__ */ jsx38(Text26, { fw: 600, children: t("gds.trust.source.title", "Information source") })
|
|
5085
5687
|
] }),
|
|
5086
|
-
/* @__PURE__ */
|
|
5087
|
-
/* @__PURE__ */
|
|
5088
|
-
/* @__PURE__ */
|
|
5089
|
-
/* @__PURE__ */
|
|
5090
|
-
/* @__PURE__ */
|
|
5688
|
+
/* @__PURE__ */ jsxs28(Stack19, { gap: 0, children: [
|
|
5689
|
+
/* @__PURE__ */ jsx38(SourceBlockRow, { label: t("gds.trust.source.sourceType", "Source type"), children: sourceTypeContent }),
|
|
5690
|
+
/* @__PURE__ */ jsx38(SourceBlockRow, { label: t("gds.trust.source.lastChecked", "Last checked"), children: lastChecked !== void 0 ? /* @__PURE__ */ jsx38(LastCheckedLabel, { date: lastChecked }) : /* @__PURE__ */ jsx38(Text26, { size: "sm", c: ROLE_META, children: unknownValue }) }),
|
|
5691
|
+
/* @__PURE__ */ jsx38(SourceBlockRow, { label: t("gds.trust.source.priceStatus", "Price status"), children: priceStatus ? /* @__PURE__ */ jsx38(Text26, { size: "sm", c: sourceRowStatusRole(priceStatus), children: statusLabels[priceStatus] }) : /* @__PURE__ */ jsx38(Text26, { size: "sm", c: ROLE_META, children: unknownValue }) }),
|
|
5692
|
+
/* @__PURE__ */ jsx38(SourceBlockRow, { label: t("gds.trust.source.scheduleStatus", "Schedule status"), children: scheduleStatus ? /* @__PURE__ */ jsx38(Text26, { size: "sm", c: sourceRowStatusRole(scheduleStatus), children: statusLabels[scheduleStatus] }) : /* @__PURE__ */ jsx38(Text26, { size: "sm", c: ROLE_META, children: unknownValue }) })
|
|
5091
5693
|
] }),
|
|
5092
|
-
/* @__PURE__ */
|
|
5093
|
-
onReport ? /* @__PURE__ */
|
|
5694
|
+
/* @__PURE__ */ jsx38(Text26, { size: "xs", c: ROLE_META, children: t("gds.trust.source.confirmLine", "Always confirm final details directly with the provider before attending.") }),
|
|
5695
|
+
onReport ? /* @__PURE__ */ jsx38(ReportOutdatedLink, { onReport }) : null
|
|
5094
5696
|
] }) });
|
|
5095
5697
|
}
|
|
5096
5698
|
function ConfirmChecklist({ items, title }) {
|
|
5097
|
-
const { t } =
|
|
5699
|
+
const { t } = useGdsTranslation26();
|
|
5098
5700
|
const defaultItems = [
|
|
5099
5701
|
t("gds.trust.checklist.exactSchedule", "Exact schedule"),
|
|
5100
5702
|
t("gds.trust.checklist.currentPrice", "Current price"),
|
|
@@ -5105,36 +5707,36 @@ function ConfirmChecklist({ items, title }) {
|
|
|
5105
5707
|
];
|
|
5106
5708
|
const resolvedItems = items ?? defaultItems;
|
|
5107
5709
|
const resolvedTitle = title ?? t("gds.trust.checklist.title", "Check before booking");
|
|
5108
|
-
const [checked, setChecked] =
|
|
5710
|
+
const [checked, setChecked] = useState21({});
|
|
5109
5711
|
if (resolvedItems.length === 0) {
|
|
5110
5712
|
return null;
|
|
5111
5713
|
}
|
|
5112
5714
|
const toggle = (key) => {
|
|
5113
5715
|
setChecked((current) => ({ ...current, [key]: !current[key] }));
|
|
5114
5716
|
};
|
|
5115
|
-
return /* @__PURE__ */
|
|
5116
|
-
|
|
5717
|
+
return /* @__PURE__ */ jsx38(
|
|
5718
|
+
Paper8,
|
|
5117
5719
|
{
|
|
5118
5720
|
withBorder: true,
|
|
5119
5721
|
radius: "lg",
|
|
5120
5722
|
p: "md",
|
|
5121
5723
|
"data-gds-confirm-checklist": "",
|
|
5122
5724
|
style: { background: ROLE_WARNING_TINT_BG, borderColor: "var(--gds-state-warning, var(--mantine-color-yellow-6))" },
|
|
5123
|
-
children: /* @__PURE__ */
|
|
5124
|
-
/* @__PURE__ */
|
|
5125
|
-
/* @__PURE__ */
|
|
5126
|
-
/* @__PURE__ */
|
|
5725
|
+
children: /* @__PURE__ */ jsxs28("fieldset", { style: { border: 0, margin: 0, padding: 0, minInlineSize: "auto" }, children: [
|
|
5726
|
+
/* @__PURE__ */ jsxs28(Group23, { component: "legend", gap: "xs", wrap: "nowrap", style: { padding: 0, color: ROLE_WARNING_TINT_FG }, children: [
|
|
5727
|
+
/* @__PURE__ */ jsx38(GdsIcon, { icon: "Checklist", size: "sm" }),
|
|
5728
|
+
/* @__PURE__ */ jsx38(Text26, { fw: 600, c: "inherit", children: resolvedTitle })
|
|
5127
5729
|
] }),
|
|
5128
|
-
/* @__PURE__ */
|
|
5730
|
+
/* @__PURE__ */ jsx38(Stack19, { gap: "xs", mt: "sm", children: resolvedItems.map((item, index) => {
|
|
5129
5731
|
const key = `${index}:${item}`;
|
|
5130
5732
|
const isChecked = Boolean(checked[key]);
|
|
5131
|
-
return /* @__PURE__ */
|
|
5733
|
+
return /* @__PURE__ */ jsx38(Group23, { wrap: "nowrap", align: "center", gap: "xs", style: { minHeight: `${GDS_MIN_TARGET_PX}px` }, children: /* @__PURE__ */ jsx38(
|
|
5132
5734
|
Checkbox4,
|
|
5133
5735
|
{
|
|
5134
5736
|
checked: isChecked,
|
|
5135
5737
|
onChange: () => toggle(key),
|
|
5136
|
-
label: /* @__PURE__ */
|
|
5137
|
-
|
|
5738
|
+
label: /* @__PURE__ */ jsx38(
|
|
5739
|
+
Text26,
|
|
5138
5740
|
{
|
|
5139
5741
|
component: "span",
|
|
5140
5742
|
c: ROLE_WARNING_TINT_FG,
|
|
@@ -5151,10 +5753,10 @@ function ConfirmChecklist({ items, title }) {
|
|
|
5151
5753
|
}
|
|
5152
5754
|
|
|
5153
5755
|
// src/HeroSearchPanel.client.tsx
|
|
5154
|
-
import { useState as
|
|
5155
|
-
import { Box as
|
|
5156
|
-
import { useGdsTranslation as
|
|
5157
|
-
import { jsx as
|
|
5756
|
+
import { useState as useState22 } from "react";
|
|
5757
|
+
import { Box as Box12, Button as Button17, TextInput as TextInput4 } from "@mantine/core";
|
|
5758
|
+
import { useGdsTranslation as useGdsTranslation27, GDS_MIN_TARGET_PX as GDS_MIN_TARGET_PX2 } from "@sovereignsquad/gds-theme";
|
|
5759
|
+
import { jsx as jsx39, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
5158
5760
|
var GDS_HERO_SEARCH_FIELD_FLEX_BASIS_PX = 120;
|
|
5159
5761
|
var GDS_HERO_SEARCH_FIELD_MIN_WIDTH_PX = 110;
|
|
5160
5762
|
function dedupeHeroSearchFields(fields) {
|
|
@@ -5191,10 +5793,10 @@ function HeroSearchPanel({
|
|
|
5191
5793
|
ariaLabel: ariaLabelProp,
|
|
5192
5794
|
disabled = false
|
|
5193
5795
|
}) {
|
|
5194
|
-
const { t } =
|
|
5796
|
+
const { t } = useGdsTranslation27();
|
|
5195
5797
|
const ariaLabel = ariaLabelProp ?? t("gds.heroSearchPanel.ariaLabel", "Search");
|
|
5196
5798
|
const controlled = values !== void 0;
|
|
5197
|
-
const [internalValues, setInternalValues] =
|
|
5799
|
+
const [internalValues, setInternalValues] = useState22(defaultValues ?? {});
|
|
5198
5800
|
const currentValues = controlled ? values : internalValues;
|
|
5199
5801
|
const edit = (key, value) => {
|
|
5200
5802
|
const next = { ...currentValues, [key]: value };
|
|
@@ -5211,16 +5813,16 @@ function HeroSearchPanel({
|
|
|
5211
5813
|
const renderedFields = dedupeHeroSearchFields(fields);
|
|
5212
5814
|
const showSecondaryAction = Boolean(secondaryActionLabel && onSecondaryAction);
|
|
5213
5815
|
const primaryVocabularyPacks = primaryActionLabel ? [createGdsVocabularyPack("heroSearchPanel", { primary: { defaultMessage: primaryActionLabel, icon: GdsIcons.Search } })] : void 0;
|
|
5214
|
-
return /* @__PURE__ */
|
|
5215
|
-
renderedFields.length > 0 ? /* @__PURE__ */
|
|
5216
|
-
|
|
5816
|
+
return /* @__PURE__ */ jsx39("form", { role: "search", "aria-label": ariaLabel, onSubmit: submit, style: panelSurfaceStyle, children: /* @__PURE__ */ jsxs29(GdsStack, { gap: "sm", children: [
|
|
5817
|
+
renderedFields.length > 0 ? /* @__PURE__ */ jsx39(GdsInline, { gap: "sm", wrap: "wrap", align: "start", children: renderedFields.map((field) => /* @__PURE__ */ jsx39(
|
|
5818
|
+
Box12,
|
|
5217
5819
|
{
|
|
5218
5820
|
style: {
|
|
5219
5821
|
flex: `1 1 ${GDS_HERO_SEARCH_FIELD_FLEX_BASIS_PX}px`,
|
|
5220
5822
|
minWidth: `${GDS_HERO_SEARCH_FIELD_MIN_WIDTH_PX}px`,
|
|
5221
5823
|
overflowWrap: "anywhere"
|
|
5222
5824
|
},
|
|
5223
|
-
children: /* @__PURE__ */
|
|
5825
|
+
children: /* @__PURE__ */ jsx39(FormField, { label: field.label, children: /* @__PURE__ */ jsx39(
|
|
5224
5826
|
TextInput4,
|
|
5225
5827
|
{
|
|
5226
5828
|
value: currentValues[field.key] ?? "",
|
|
@@ -5233,8 +5835,8 @@ function HeroSearchPanel({
|
|
|
5233
5835
|
},
|
|
5234
5836
|
field.key
|
|
5235
5837
|
)) }) : null,
|
|
5236
|
-
/* @__PURE__ */
|
|
5237
|
-
/* @__PURE__ */
|
|
5838
|
+
/* @__PURE__ */ jsxs29(GdsInline, { gap: "sm", wrap: "wrap", children: [
|
|
5839
|
+
/* @__PURE__ */ jsx39(
|
|
5238
5840
|
SemanticButton,
|
|
5239
5841
|
{
|
|
5240
5842
|
action: primaryActionLabel ? "heroSearchPanel:primary" : "search",
|
|
@@ -5243,17 +5845,17 @@ function HeroSearchPanel({
|
|
|
5243
5845
|
vocabularyPacks: primaryVocabularyPacks
|
|
5244
5846
|
}
|
|
5245
5847
|
),
|
|
5246
|
-
showSecondaryAction ? /* @__PURE__ */
|
|
5848
|
+
showSecondaryAction ? /* @__PURE__ */ jsx39(Button17, { type: "button", variant: "default", disabled, onClick: onSecondaryAction, children: secondaryActionLabel }) : null
|
|
5247
5849
|
] }),
|
|
5248
|
-
trustLine ? /* @__PURE__ */
|
|
5850
|
+
trustLine ? /* @__PURE__ */ jsx39(MetadataText, { children: trustLine }) : null
|
|
5249
5851
|
] }) });
|
|
5250
5852
|
}
|
|
5251
5853
|
|
|
5252
5854
|
// src/KanbanBoard.client.tsx
|
|
5253
|
-
import { useEffect as
|
|
5254
|
-
import { ActionIcon as ActionIcon5, Badge as Badge3, Box as
|
|
5255
|
-
import { useMediaQuery as
|
|
5256
|
-
import { useGdsTranslation as
|
|
5855
|
+
import { useEffect as useEffect12, useId as useId3, useRef as useRef12, useState as useState23 } from "react";
|
|
5856
|
+
import { ActionIcon as ActionIcon5, Badge as Badge3, Box as Box13, Group as Group24, Menu, Paper as Paper9, ScrollArea as ScrollArea4, Stack as Stack20, Text as Text27, Title as Title4 } from "@mantine/core";
|
|
5857
|
+
import { useMediaQuery as useMediaQuery4 } from "@mantine/hooks";
|
|
5858
|
+
import { useGdsTranslation as useGdsTranslation28 } from "@sovereignsquad/gds-theme";
|
|
5257
5859
|
import {
|
|
5258
5860
|
DndContext,
|
|
5259
5861
|
DragOverlay,
|
|
@@ -5266,21 +5868,21 @@ import {
|
|
|
5266
5868
|
} from "@dnd-kit/core";
|
|
5267
5869
|
import { SortableContext, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
5268
5870
|
import { CSS as CSS2 } from "@dnd-kit/utilities";
|
|
5269
|
-
import { Fragment as
|
|
5871
|
+
import { Fragment as Fragment7, jsx as jsx40, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
5270
5872
|
function useGdsKanbanOrientation({
|
|
5271
5873
|
stackedBreakpoint = "xs"
|
|
5272
5874
|
} = {}) {
|
|
5273
|
-
const isPortrait =
|
|
5274
|
-
const isNarrow =
|
|
5875
|
+
const isPortrait = useMediaQuery4("(orientation: portrait)");
|
|
5876
|
+
const isNarrow = useMediaQuery4(`(max-width: ${gdsBreakpointByAlias[stackedBreakpoint]})`);
|
|
5275
5877
|
return isPortrait && isNarrow ? "stacked" : "columns";
|
|
5276
5878
|
}
|
|
5277
5879
|
function DragGripGlyph() {
|
|
5278
|
-
return /* @__PURE__ */
|
|
5279
|
-
(x) => [2, 8, 14].map((y) => /* @__PURE__ */
|
|
5880
|
+
return /* @__PURE__ */ jsx40("svg", { width: "10", height: "16", viewBox: "0 0 10 16", "aria-hidden": "true", focusable: "false", children: [2, 8].flatMap(
|
|
5881
|
+
(x) => [2, 8, 14].map((y) => /* @__PURE__ */ jsx40("circle", { cx: x, cy: y, r: 1.4, fill: "currentColor" }, `${x}-${y}`))
|
|
5280
5882
|
) });
|
|
5281
5883
|
}
|
|
5282
5884
|
function ColumnDisclosureGlyph({ collapsed }) {
|
|
5283
|
-
return /* @__PURE__ */
|
|
5885
|
+
return /* @__PURE__ */ jsx40(
|
|
5284
5886
|
"svg",
|
|
5285
5887
|
{
|
|
5286
5888
|
width: "12",
|
|
@@ -5289,7 +5891,7 @@ function ColumnDisclosureGlyph({ collapsed }) {
|
|
|
5289
5891
|
"aria-hidden": "true",
|
|
5290
5892
|
focusable: "false",
|
|
5291
5893
|
style: { transform: collapsed ? "rotate(-90deg)" : "none", transition: "transform var(--gds-motion-duration-fast, 120ms) var(--gds-motion-ease-standard, ease)" },
|
|
5292
|
-
children: /* @__PURE__ */
|
|
5894
|
+
children: /* @__PURE__ */ jsx40("path", { d: "M2.5 4.5 L6 8 L9.5 4.5", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
5293
5895
|
}
|
|
5294
5896
|
);
|
|
5295
5897
|
}
|
|
@@ -5298,7 +5900,7 @@ function columnTitleText(column) {
|
|
|
5298
5900
|
return column.ariaLabel ?? (typeof column.title === "string" ? column.title : column.id);
|
|
5299
5901
|
}
|
|
5300
5902
|
function KanbanCard({ item, column, columns, onMoveItem, renderItem, enableDrag, moveMenuIcon, moveMenuLabel }) {
|
|
5301
|
-
const { t } =
|
|
5903
|
+
const { t } = useGdsTranslation28();
|
|
5302
5904
|
const moveTargets = columns.filter((candidate) => candidate.id !== column.id);
|
|
5303
5905
|
const accessibleName = item.ariaLabel ?? (typeof item.title === "string" ? item.title : void 0);
|
|
5304
5906
|
const moveVerb = moveMenuLabel ?? t("gds.kanban.moveItem", "Move");
|
|
@@ -5310,8 +5912,8 @@ function KanbanCard({ item, column, columns, onMoveItem, renderItem, enableDrag,
|
|
|
5310
5912
|
transition: sortable.transition,
|
|
5311
5913
|
opacity: sortable.isDragging ? 0.4 : 1
|
|
5312
5914
|
} : void 0;
|
|
5313
|
-
return /* @__PURE__ */
|
|
5314
|
-
|
|
5915
|
+
return /* @__PURE__ */ jsx40(
|
|
5916
|
+
Paper9,
|
|
5315
5917
|
{
|
|
5316
5918
|
withBorder: true,
|
|
5317
5919
|
radius: "md",
|
|
@@ -5319,9 +5921,9 @@ function KanbanCard({ item, column, columns, onMoveItem, renderItem, enableDrag,
|
|
|
5319
5921
|
"data-gds-kanban-card": item.id,
|
|
5320
5922
|
ref: enableDrag ? sortable.setNodeRef : void 0,
|
|
5321
5923
|
style: dragStyle,
|
|
5322
|
-
children: /* @__PURE__ */
|
|
5323
|
-
/* @__PURE__ */
|
|
5324
|
-
enableDrag ? /* @__PURE__ */
|
|
5924
|
+
children: /* @__PURE__ */ jsxs30(Stack20, { gap: 6, children: [
|
|
5925
|
+
/* @__PURE__ */ jsxs30(Group24, { justify: "space-between", align: "flex-start", gap: "xs", wrap: "nowrap", children: [
|
|
5926
|
+
enableDrag ? /* @__PURE__ */ jsx40(
|
|
5325
5927
|
ActionIcon5,
|
|
5326
5928
|
{
|
|
5327
5929
|
variant: "subtle",
|
|
@@ -5333,23 +5935,23 @@ function KanbanCard({ item, column, columns, onMoveItem, renderItem, enableDrag,
|
|
|
5333
5935
|
style: { cursor: "grab", touchAction: "none", flexShrink: 0 },
|
|
5334
5936
|
...sortable.listeners,
|
|
5335
5937
|
...sortable.attributes,
|
|
5336
|
-
children: /* @__PURE__ */
|
|
5938
|
+
children: /* @__PURE__ */ jsx40(DragGripGlyph, {})
|
|
5337
5939
|
}
|
|
5338
5940
|
) : null,
|
|
5339
|
-
/* @__PURE__ */
|
|
5340
|
-
typeof item.title === "string" ? /* @__PURE__ */
|
|
5341
|
-
item.description ? /* @__PURE__ */
|
|
5941
|
+
/* @__PURE__ */ jsx40(Box13, { style: { minWidth: 0, flex: 1 }, children: renderItem ? renderItem(item, column) : /* @__PURE__ */ jsxs30(Stack20, { gap: 2, children: [
|
|
5942
|
+
typeof item.title === "string" ? /* @__PURE__ */ jsx40(Text27, { fw: 600, size: "sm", children: item.title }) : item.title,
|
|
5943
|
+
item.description ? /* @__PURE__ */ jsx40(Text27, { size: "xs", c: "dimmed", children: item.description }) : null
|
|
5342
5944
|
] }) }),
|
|
5343
|
-
onMoveItem && moveTargets.length > 0 ? /* @__PURE__ */
|
|
5344
|
-
/* @__PURE__ */
|
|
5345
|
-
/* @__PURE__ */
|
|
5945
|
+
onMoveItem && moveTargets.length > 0 ? /* @__PURE__ */ jsxs30(Menu, { withinPortal: true, position: "bottom-end", shadow: "md", children: [
|
|
5946
|
+
/* @__PURE__ */ jsx40(Menu.Target, { children: /* @__PURE__ */ jsx40(ActionIcon5, { variant: "subtle", color: "gray", size: "sm", "data-gds-target-exception": "dense-toolbar", "aria-label": moveLabel, children: moveMenuIcon ?? /* @__PURE__ */ jsx40(GdsIcon, { icon: "More", decorative: true }) }) }),
|
|
5947
|
+
/* @__PURE__ */ jsx40(Menu.Dropdown, { children: moveTargets.map((target) => /* @__PURE__ */ jsxs30(Menu.Item, { onClick: () => onMoveItem(item.id, column.id, target.id), children: [
|
|
5346
5948
|
t("gds.kanban.moveTo", "Move to"),
|
|
5347
5949
|
" ",
|
|
5348
5950
|
target.title
|
|
5349
5951
|
] }, target.id)) })
|
|
5350
5952
|
] }) : null
|
|
5351
5953
|
] }),
|
|
5352
|
-
item.status ? /* @__PURE__ */
|
|
5954
|
+
item.status ? /* @__PURE__ */ jsx40(Badge3, { variant: "light", size: "sm", children: item.status }) : null
|
|
5353
5955
|
] })
|
|
5354
5956
|
}
|
|
5355
5957
|
);
|
|
@@ -5370,12 +5972,12 @@ function KanbanColumn({
|
|
|
5370
5972
|
collapsed,
|
|
5371
5973
|
onCollapsedChange
|
|
5372
5974
|
}) {
|
|
5373
|
-
const { t } =
|
|
5975
|
+
const { t } = useGdsTranslation28();
|
|
5374
5976
|
const droppable = useDroppable({ id: column.id, disabled: !enableDrag });
|
|
5375
5977
|
const isControlledCollapse = collapsed !== void 0;
|
|
5376
|
-
const [internalCollapsed, setInternalCollapsed] =
|
|
5978
|
+
const [internalCollapsed, setInternalCollapsed] = useState23(false);
|
|
5377
5979
|
const resolvedCollapsed = collapsible ? isControlledCollapse ? Boolean(collapsed) : internalCollapsed : false;
|
|
5378
|
-
const bodyId =
|
|
5980
|
+
const bodyId = useId3();
|
|
5379
5981
|
function handleToggleCollapsed() {
|
|
5380
5982
|
const next = !resolvedCollapsed;
|
|
5381
5983
|
if (!isControlledCollapse) {
|
|
@@ -5387,7 +5989,7 @@ function KanbanColumn({
|
|
|
5387
5989
|
const toggleVerb = resolvedCollapsed ? t("gds.kanban.expandColumn", "Expand column") : t("gds.kanban.collapseColumn", "Collapse column");
|
|
5388
5990
|
const toggleLabel = columnName ? `${toggleVerb}: ${columnName}` : toggleVerb;
|
|
5389
5991
|
const count = column.totalCount ?? column.items.length;
|
|
5390
|
-
const cards = column.items.length ? /* @__PURE__ */
|
|
5992
|
+
const cards = column.items.length ? /* @__PURE__ */ jsx40(Stack20, { gap: "xs", ref: enableDrag ? droppable.setNodeRef : void 0, "data-gds-kanban-drop-zone": column.id, children: column.items.map((item) => /* @__PURE__ */ jsx40(
|
|
5391
5993
|
KanbanCard,
|
|
5392
5994
|
{
|
|
5393
5995
|
item,
|
|
@@ -5400,8 +6002,8 @@ function KanbanColumn({
|
|
|
5400
6002
|
moveMenuLabel
|
|
5401
6003
|
},
|
|
5402
6004
|
item.id
|
|
5403
|
-
)) }) : /* @__PURE__ */
|
|
5404
|
-
|
|
6005
|
+
)) }) : /* @__PURE__ */ jsx40(
|
|
6006
|
+
Text27,
|
|
5405
6007
|
{
|
|
5406
6008
|
size: "xs",
|
|
5407
6009
|
c: "dimmed",
|
|
@@ -5411,12 +6013,12 @@ function KanbanColumn({
|
|
|
5411
6013
|
}
|
|
5412
6014
|
);
|
|
5413
6015
|
const footerNode = renderFooter ? renderFooter(column) : footer;
|
|
5414
|
-
const body = /* @__PURE__ */
|
|
5415
|
-
enableDrag ? /* @__PURE__ */
|
|
5416
|
-
footerNode != null && footerNode !== false ? /* @__PURE__ */
|
|
6016
|
+
const body = /* @__PURE__ */ jsxs30(Fragment7, { children: [
|
|
6017
|
+
enableDrag ? /* @__PURE__ */ jsx40(SortableContext, { items: column.items.map((item) => item.id), strategy: verticalListSortingStrategy, children: cards }) : cards,
|
|
6018
|
+
footerNode != null && footerNode !== false ? /* @__PURE__ */ jsx40(Box13, { "data-gds-kanban-footer": column.id, children: footerNode }) : null
|
|
5417
6019
|
] });
|
|
5418
|
-
return /* @__PURE__ */
|
|
5419
|
-
|
|
6020
|
+
return /* @__PURE__ */ jsx40(
|
|
6021
|
+
Paper9,
|
|
5420
6022
|
{
|
|
5421
6023
|
withBorder: true,
|
|
5422
6024
|
radius: "lg",
|
|
@@ -5424,10 +6026,10 @@ function KanbanColumn({
|
|
|
5424
6026
|
style: width ? { minWidth: width, flex: "0 0 auto" } : void 0,
|
|
5425
6027
|
"data-gds-kanban-column": column.id,
|
|
5426
6028
|
"data-gds-kanban-column-collapsed": collapsible && resolvedCollapsed ? "true" : void 0,
|
|
5427
|
-
children: /* @__PURE__ */
|
|
5428
|
-
/* @__PURE__ */
|
|
5429
|
-
/* @__PURE__ */
|
|
5430
|
-
collapsible ? /* @__PURE__ */
|
|
6029
|
+
children: /* @__PURE__ */ jsxs30(Stack20, { gap: "sm", children: [
|
|
6030
|
+
/* @__PURE__ */ jsxs30(Group24, { justify: "space-between", align: "center", wrap: "nowrap", "data-gds-kanban-column-header": column.id, children: [
|
|
6031
|
+
/* @__PURE__ */ jsxs30(Group24, { gap: "xs", wrap: "nowrap", style: { minWidth: 0 }, children: [
|
|
6032
|
+
collapsible ? /* @__PURE__ */ jsx40(
|
|
5431
6033
|
ActionIcon5,
|
|
5432
6034
|
{
|
|
5433
6035
|
variant: "subtle",
|
|
@@ -5439,14 +6041,14 @@ function KanbanColumn({
|
|
|
5439
6041
|
"aria-controls": bodyId,
|
|
5440
6042
|
onClick: handleToggleCollapsed,
|
|
5441
6043
|
style: { flexShrink: 0 },
|
|
5442
|
-
children: /* @__PURE__ */
|
|
6044
|
+
children: /* @__PURE__ */ jsx40(ColumnDisclosureGlyph, { collapsed: resolvedCollapsed })
|
|
5443
6045
|
}
|
|
5444
6046
|
) : null,
|
|
5445
|
-
/* @__PURE__ */
|
|
6047
|
+
/* @__PURE__ */ jsx40(Title4, { order: 4, children: column.title })
|
|
5446
6048
|
] }),
|
|
5447
|
-
/* @__PURE__ */
|
|
6049
|
+
/* @__PURE__ */ jsx40(Badge3, { variant: "light", children: count })
|
|
5448
6050
|
] }),
|
|
5449
|
-
collapsible ? /* @__PURE__ */
|
|
6051
|
+
collapsible ? /* @__PURE__ */ jsx40("div", { id: bodyId, hidden: resolvedCollapsed, "data-gds-kanban-column-body": column.id, children: resolvedCollapsed ? null : /* @__PURE__ */ jsx40(Stack20, { gap: "sm", children: body }) }) : body
|
|
5450
6052
|
] })
|
|
5451
6053
|
}
|
|
5452
6054
|
);
|
|
@@ -5476,16 +6078,16 @@ function KanbanBoard({
|
|
|
5476
6078
|
collapsedColumnIds,
|
|
5477
6079
|
onCollapsedChange
|
|
5478
6080
|
}) {
|
|
5479
|
-
const { t } =
|
|
6081
|
+
const { t } = useGdsTranslation28();
|
|
5480
6082
|
const autoOrientation = useGdsKanbanOrientation();
|
|
5481
6083
|
const resolvedOrientation = orientation === "auto" ? autoOrientation : orientation;
|
|
5482
6084
|
const regionLabel = boardLabel ?? (typeof title === "string" ? title : t("gds.kanban.boardLabel", "Kanban board"));
|
|
5483
|
-
const [activeItem, setActiveItem] =
|
|
5484
|
-
const [internalCollapsedIds, setInternalCollapsedIds] =
|
|
6085
|
+
const [activeItem, setActiveItem] = useState23(null);
|
|
6086
|
+
const [internalCollapsedIds, setInternalCollapsedIds] = useState23([]);
|
|
5485
6087
|
const isCollapseControlled = collapsedColumnIds !== void 0;
|
|
5486
6088
|
const collapsedIds = isCollapseControlled ? collapsedColumnIds : internalCollapsedIds;
|
|
5487
|
-
const viewportRef =
|
|
5488
|
-
|
|
6089
|
+
const viewportRef = useRef12(null);
|
|
6090
|
+
useEffect12(() => {
|
|
5489
6091
|
const viewport = viewportRef.current;
|
|
5490
6092
|
if (!viewport || columnPanZone !== "header" || resolvedOrientation === "stacked") {
|
|
5491
6093
|
return void 0;
|
|
@@ -5581,7 +6183,7 @@ function KanbanBoard({
|
|
|
5581
6183
|
"To pick up a card, press the space bar. While dragging, use the arrow keys to move the card between and within columns. Press space again to drop the card, or press escape to cancel."
|
|
5582
6184
|
)
|
|
5583
6185
|
};
|
|
5584
|
-
const columnList = (width) => columns.map((column) => /* @__PURE__ */
|
|
6186
|
+
const columnList = (width) => columns.map((column) => /* @__PURE__ */ jsx40(
|
|
5585
6187
|
KanbanColumn,
|
|
5586
6188
|
{
|
|
5587
6189
|
column,
|
|
@@ -5600,14 +6202,14 @@ function KanbanBoard({
|
|
|
5600
6202
|
},
|
|
5601
6203
|
column.id
|
|
5602
6204
|
));
|
|
5603
|
-
const board = /* @__PURE__ */
|
|
5604
|
-
title ? typeof title === "string" ? /* @__PURE__ */
|
|
5605
|
-
resolvedOrientation === "stacked" ? /* @__PURE__ */
|
|
6205
|
+
const board = /* @__PURE__ */ jsxs30(Stack20, { gap: "md", role: "region", "aria-label": regionLabel, "data-gds-kanban-orientation": resolvedOrientation, children: [
|
|
6206
|
+
title ? typeof title === "string" ? /* @__PURE__ */ jsx40(Title4, { order: 3, children: title }) : title : null,
|
|
6207
|
+
resolvedOrientation === "stacked" ? /* @__PURE__ */ jsx40(Stack20, { gap: "lg", children: columnList(void 0) }) : /* @__PURE__ */ jsx40(ScrollArea4, { type: "auto", scrollbarSize: 8, offsetScrollbars: true, viewportRef, children: /* @__PURE__ */ jsx40(Group24, { gap: "md", wrap: "nowrap", align: "flex-start", children: columnList(columnWidth) }) })
|
|
5606
6208
|
] });
|
|
5607
6209
|
if (!dragActive) {
|
|
5608
6210
|
return board;
|
|
5609
6211
|
}
|
|
5610
|
-
return /* @__PURE__ */
|
|
6212
|
+
return /* @__PURE__ */ jsxs30(
|
|
5611
6213
|
DndContext,
|
|
5612
6214
|
{
|
|
5613
6215
|
sensors,
|
|
@@ -5618,7 +6220,7 @@ function KanbanBoard({
|
|
|
5618
6220
|
onDragEnd: handleDragEnd,
|
|
5619
6221
|
children: [
|
|
5620
6222
|
board,
|
|
5621
|
-
/* @__PURE__ */
|
|
6223
|
+
/* @__PURE__ */ jsx40(DragOverlay, { children: activeItem ? /* @__PURE__ */ jsx40(Paper9, { withBorder: true, radius: "md", p: "sm", shadow: "md", children: /* @__PURE__ */ jsx40(Stack20, { gap: 2, children: typeof activeItem.item.title === "string" ? /* @__PURE__ */ jsx40(Text27, { fw: 600, size: "sm", children: activeItem.item.title }) : activeItem.item.title }) }) : null })
|
|
5622
6224
|
]
|
|
5623
6225
|
}
|
|
5624
6226
|
);
|
|
@@ -5634,6 +6236,13 @@ export {
|
|
|
5634
6236
|
GdsDensityProvider,
|
|
5635
6237
|
useGdsDensity,
|
|
5636
6238
|
useGdsCardContract,
|
|
6239
|
+
getGdsShapeScopeStyle,
|
|
6240
|
+
GdsShapeScope,
|
|
6241
|
+
GdsTreeView,
|
|
6242
|
+
GdsBulkActionBar,
|
|
6243
|
+
GdsThreadList,
|
|
6244
|
+
GdsMessageThread,
|
|
6245
|
+
GdsViewToggle,
|
|
5637
6246
|
ProviderCTA,
|
|
5638
6247
|
listingQueryReducer,
|
|
5639
6248
|
ListingProvider,
|
|
@@ -5694,6 +6303,7 @@ export {
|
|
|
5694
6303
|
useGdsNotifications,
|
|
5695
6304
|
NotificationCenter,
|
|
5696
6305
|
GdsNotificationCenter,
|
|
6306
|
+
GdsToastViewport,
|
|
5697
6307
|
GdsConfirmProvider,
|
|
5698
6308
|
useGdsConfirm,
|
|
5699
6309
|
GdsToastProvider,
|
|
@@ -5724,6 +6334,8 @@ export {
|
|
|
5724
6334
|
usePlaybackKeyboardControls,
|
|
5725
6335
|
PlaybackControls,
|
|
5726
6336
|
PlaybackOverlayControls,
|
|
6337
|
+
GdsAssetManagerTemplate,
|
|
6338
|
+
GdsWorkspaceInboxTemplate,
|
|
5727
6339
|
ReportOutdatedLink,
|
|
5728
6340
|
SourceBlock,
|
|
5729
6341
|
ConfirmChecklist,
|