@sovereignsquad/gds-core 6.8.0 → 6.10.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/{GdsBadge-DqTdnomt.d.mts → GdsBadge-j_kQnIL0.d.mts} +1 -1
- package/dist/{GdsBadge-DqTdnomt.d.ts → GdsBadge-j_kQnIL0.d.ts} +1 -1
- package/dist/{PartnerDiscovery-Bwxixtka.d.mts → PartnerDiscovery-Dy3YnO02.d.mts} +15 -8
- package/dist/{PartnerDiscovery-As_-JKtb.d.ts → PartnerDiscovery-pdJmaKwq.d.ts} +15 -8
- package/dist/{QuickStartCard-CB7r-85z.d.ts → QuickStartCard-BqbYrKRY.d.ts} +4373 -131
- package/dist/{QuickStartCard-xIP1gbCL.d.mts → QuickStartCard-lE9kMqH8.d.mts} +4373 -131
- package/dist/{chunk-QO653DAE.mjs → chunk-7NNKXZFF.mjs} +120 -3
- package/dist/{chunk-GMK5GXWR.mjs → chunk-CWMDWMYL.mjs} +120 -3
- package/dist/{chunk-GGDCO5HR.mjs → chunk-D65VHUXK.mjs} +120 -3
- package/dist/{chunk-JTMPFTCK.mjs → chunk-J4TSXITU.mjs} +120 -3
- package/dist/{chunk-TJ3WMH25.mjs → chunk-LTNPECWV.mjs} +1696 -757
- package/dist/{chunk-BH2SMTND.mjs → chunk-MO5TLIIB.mjs} +1716 -2010
- package/dist/{chunk-VU2JLVD3.mjs → chunk-NTNVQZJU.mjs} +1 -1
- package/dist/{chunk-KFEPREUF.mjs → chunk-PCG34VRY.mjs} +13 -2
- package/dist/{chunk-H2QNW4D5.mjs → chunk-PJR3OJJD.mjs} +912 -212
- package/dist/{chunk-IHPZ7BNV.mjs → chunk-PLJT4I7B.mjs} +164 -47
- package/dist/{chunk-BHR4A3C6.mjs → chunk-RBXAJJB2.mjs} +120 -3
- package/dist/{chunk-MPZFCWWS.mjs → chunk-SPPTDVJC.mjs} +2 -1
- package/dist/{chunk-NWS7KJ2G.mjs → chunk-SV3VL3GG.mjs} +3 -2
- package/dist/{chunk-ZCQXBKDM.mjs → chunk-TD3JPMMO.mjs} +5 -2
- package/dist/{chunk-GKNSUUUE.mjs → chunk-TVGDH5O5.mjs} +120 -3
- package/dist/{chunk-SHQDVHGR.mjs → chunk-V5WUGRFL.mjs} +120 -3
- package/dist/{chunk-4LG6EED4.mjs → chunk-V6SP5O4D.mjs} +147 -30
- package/dist/{chunk-2XZMNT7I.mjs → chunk-XL7MGQJ4.mjs} +120 -3
- package/dist/{chunk-CNTTKK3H.mjs → chunk-YASVRGKJ.mjs} +121 -4
- package/dist/{chunk-6PBDLFSF.mjs → chunk-Z6XXK57E.mjs} +120 -3
- package/dist/client.d.mts +459 -51
- package/dist/client.d.ts +459 -51
- package/dist/client.js +13279 -10520
- package/dist/client.mjs +73 -33
- package/dist/{en-Dd7uvXnv.d.ts → en-CzuiMnTG.d.mts} +119 -2
- package/dist/{en-Dd7uvXnv.d.mts → en-CzuiMnTG.d.ts} +119 -2
- package/dist/index.d.mts +24 -22
- package/dist/index.d.ts +24 -22
- package/dist/index.js +10850 -7951
- package/dist/index.mjs +250 -71
- package/dist/locales/lazy/all.js +5449 -0
- package/dist/locales/lazy/all.mjs +50 -24
- package/dist/locales/lazy/ar.js +244 -7
- package/dist/locales/lazy/ar.mjs +10 -4
- package/dist/locales/lazy/de.js +244 -7
- package/dist/locales/lazy/de.mjs +10 -4
- package/dist/locales/lazy/es.js +244 -7
- package/dist/locales/lazy/es.mjs +10 -4
- package/dist/locales/lazy/fr.js +244 -7
- package/dist/locales/lazy/fr.mjs +10 -4
- package/dist/locales/lazy/he.js +245 -8
- package/dist/locales/lazy/he.mjs +10 -4
- package/dist/locales/lazy/hu.js +244 -7
- 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 +124 -4
- package/dist/locales/lazy/index.mjs +2 -2
- package/dist/locales/lazy/it.js +244 -7
- package/dist/locales/lazy/it.mjs +10 -4
- package/dist/locales/lazy/ja.js +244 -7
- package/dist/locales/lazy/ja.mjs +10 -4
- package/dist/locales/lazy/ko.js +288 -51
- package/dist/locales/lazy/ko.mjs +10 -4
- package/dist/locales/lazy/ru.js +244 -7
- package/dist/locales/lazy/ru.mjs +10 -4
- package/dist/locales/lazy/zh.js +271 -34
- package/dist/locales/lazy/zh.mjs +10 -4
- package/dist/map.css +3 -9
- package/dist/map.d.mts +1 -1
- package/dist/map.d.ts +1 -1
- package/dist/map.js +2 -1
- package/dist/map.mjs +2 -2
- package/dist/reference-theme-explorer.d.mts +3 -1
- package/dist/reference-theme-explorer.d.ts +3 -1
- package/dist/reference-theme-explorer.js +2607 -509
- package/dist/reference-theme-explorer.mjs +58 -38
- package/dist/server.d.mts +6 -6
- package/dist/server.d.ts +6 -6
- package/dist/server.js +3336 -1513
- package/dist/server.mjs +43 -33
- 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
|
@@ -2,45 +2,57 @@ import {
|
|
|
2
2
|
GdsInlineLink
|
|
3
3
|
} from "./chunk-W5O2JSVK.mjs";
|
|
4
4
|
import {
|
|
5
|
+
BodyText,
|
|
6
|
+
CardTitle,
|
|
5
7
|
CtaButtonGroup,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
InlineAlert,
|
|
9
|
+
InlineEmphasis,
|
|
10
|
+
InlineText,
|
|
8
11
|
LastCheckedLabel,
|
|
9
12
|
MediaPreviewCard,
|
|
10
13
|
MetadataText,
|
|
11
14
|
NotificationCenterView,
|
|
15
|
+
PageTemplateFrame,
|
|
12
16
|
PublicFlowShell,
|
|
17
|
+
TemplateStateGate,
|
|
13
18
|
createGdsAccessGateEvent,
|
|
14
19
|
createGdsNotificationAuditEvent,
|
|
20
|
+
formatGdsDate,
|
|
15
21
|
getGdsLayoutTemplates,
|
|
16
22
|
getGdsNotificationLivePolicy,
|
|
17
23
|
renderGdsLayoutWithDiagnostics,
|
|
18
24
|
sortGdsAccessGateActions,
|
|
19
25
|
validateGdsAccessGateContract
|
|
20
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-MO5TLIIB.mjs";
|
|
21
27
|
import {
|
|
22
28
|
FormField,
|
|
29
|
+
GdsBox,
|
|
30
|
+
GdsInline,
|
|
31
|
+
GdsStack,
|
|
23
32
|
SectionPanel,
|
|
24
33
|
createGdsVocabularyPack,
|
|
25
34
|
getSemanticActionLabel,
|
|
26
35
|
resolveGdsCardContract,
|
|
27
36
|
resolveSemanticActionConfig
|
|
28
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-PJR3OJJD.mjs";
|
|
29
38
|
import {
|
|
30
39
|
StateBlock
|
|
31
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-SPPTDVJC.mjs";
|
|
32
41
|
import {
|
|
33
42
|
GdsIcon,
|
|
34
43
|
GdsIcons
|
|
35
44
|
} from "./chunk-J66ITCXC.mjs";
|
|
36
45
|
|
|
37
46
|
// src/SemanticButton.tsx
|
|
38
|
-
import { useEffect, useState } from "react";
|
|
47
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
39
48
|
import { Button, VisuallyHidden } from "@mantine/core";
|
|
40
|
-
import { useGdsTranslation } from "@sovereignsquad/gds-theme";
|
|
41
|
-
import { IconCheck, IconX } from "@tabler/icons-react";
|
|
49
|
+
import { gdsDevWarnOnce, useGdsTranslation } from "@sovereignsquad/gds-theme";
|
|
50
|
+
import { IconCheck, IconLoader2, IconX } from "@tabler/icons-react";
|
|
42
51
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
43
52
|
var GDS_BUTTON_FEEDBACK_DURATION_MS = 2e3;
|
|
53
|
+
var GDS_BUTTON_PENDING_DELAY_MS = 500;
|
|
54
|
+
var GDS_BUTTON_PENDING_MIN_MS = 200;
|
|
55
|
+
var GDS_BUTTON_CONFIRM_WINDOW_MS = 3e3;
|
|
44
56
|
var GDS_BUTTON_GRADIENT_TEXT_FLOOR = { fontSizePx: 14, fontWeight: 600 };
|
|
45
57
|
var GDS_BUTTON_OUTLINE_ACCENT_STROKE_PX = 1.5;
|
|
46
58
|
var brandButtonStyles = {
|
|
@@ -75,21 +87,110 @@ var brandButtonStyles = {
|
|
|
75
87
|
"outline-accent": {},
|
|
76
88
|
gradient: {}
|
|
77
89
|
};
|
|
90
|
+
var ICON_SIZE = "1rem";
|
|
91
|
+
function pendingLabel(action, t) {
|
|
92
|
+
switch (action) {
|
|
93
|
+
case "send":
|
|
94
|
+
return t("gds.pending.send", "Sending\u2026");
|
|
95
|
+
case "save":
|
|
96
|
+
return t("gds.pending.save", "Saving\u2026");
|
|
97
|
+
case "copy":
|
|
98
|
+
return t("gds.pending.copy", "Copying\u2026");
|
|
99
|
+
case "delete":
|
|
100
|
+
return t("gds.pending.delete", "Deleting\u2026");
|
|
101
|
+
case "add":
|
|
102
|
+
return t("gds.pending.add", "Adding\u2026");
|
|
103
|
+
case "download":
|
|
104
|
+
return t("gds.pending.download", "Downloading\u2026");
|
|
105
|
+
case "upload":
|
|
106
|
+
return t("gds.pending.upload", "Uploading\u2026");
|
|
107
|
+
case "refresh":
|
|
108
|
+
return t("gds.pending.refresh", "Refreshing\u2026");
|
|
109
|
+
case "complete":
|
|
110
|
+
return t("gds.pending.complete", "Completing\u2026");
|
|
111
|
+
case "submit":
|
|
112
|
+
return t("gds.pending.submit", "Submitting\u2026");
|
|
113
|
+
default:
|
|
114
|
+
return t("gds.pending.working", "Working\u2026");
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function Layer({ motion, after, children }) {
|
|
118
|
+
return /* @__PURE__ */ jsx("span", { "data-gds-motion": motion ? "" : void 0, "data-gds-button-motion": motion, "data-gds-button-motion-after": after, children });
|
|
119
|
+
}
|
|
120
|
+
function ButtonIcon({ phase, motion, Icon, SuccessIcon, fromRest }) {
|
|
121
|
+
let layers;
|
|
122
|
+
if (phase === "pending") {
|
|
123
|
+
const pending = motion?.pending ?? "spinner";
|
|
124
|
+
layers = pending === "spinner" ? /* @__PURE__ */ jsx(Layer, { motion: "spin", children: /* @__PURE__ */ jsx(IconLoader2, { size: ICON_SIZE }) }) : /* @__PURE__ */ jsx(Layer, { motion: pending, children: /* @__PURE__ */ jsx(Icon, { size: ICON_SIZE }) });
|
|
125
|
+
} else if (phase === "success") {
|
|
126
|
+
const success = motion?.success;
|
|
127
|
+
if ((success === "fly-off" || success === "turn") && fromRest) {
|
|
128
|
+
layers = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
129
|
+
/* @__PURE__ */ jsx(Layer, { motion: success === "fly-off" ? "fly-off" : "turn-out", children: /* @__PURE__ */ jsx(Icon, { size: ICON_SIZE }) }),
|
|
130
|
+
/* @__PURE__ */ jsx(Layer, { motion: "pop-in", after: "exit", children: /* @__PURE__ */ jsx(IconCheck, { size: ICON_SIZE }) })
|
|
131
|
+
] });
|
|
132
|
+
} else if (success === "fly-off" || success === "turn" || success === "check-pop") {
|
|
133
|
+
layers = /* @__PURE__ */ jsx(Layer, { motion: "pop-in", children: /* @__PURE__ */ jsx(IconCheck, { size: ICON_SIZE }) });
|
|
134
|
+
} else if (success === "check-draw") {
|
|
135
|
+
layers = /* @__PURE__ */ jsx(Layer, { motion: "draw", children: /* @__PURE__ */ jsx(IconCheck, { size: ICON_SIZE }) });
|
|
136
|
+
} else if (success === "draw") {
|
|
137
|
+
layers = /* @__PURE__ */ jsx(Layer, { motion: "draw", children: /* @__PURE__ */ jsx(SuccessIcon, { size: ICON_SIZE }) });
|
|
138
|
+
} else {
|
|
139
|
+
layers = /* @__PURE__ */ jsx(Layer, { motion: "pop", children: /* @__PURE__ */ jsx(SuccessIcon, { size: ICON_SIZE }) });
|
|
140
|
+
}
|
|
141
|
+
} else if (phase === "error") {
|
|
142
|
+
layers = /* @__PURE__ */ jsx(Layer, { children: /* @__PURE__ */ jsx(IconX, { size: ICON_SIZE }) });
|
|
143
|
+
} else {
|
|
144
|
+
layers = /* @__PURE__ */ jsx(Layer, { children: /* @__PURE__ */ jsx(Icon, { size: ICON_SIZE }) });
|
|
145
|
+
}
|
|
146
|
+
return /* @__PURE__ */ jsx("span", { "data-gds-button-icon": "", children: layers });
|
|
147
|
+
}
|
|
78
148
|
function SemanticButton({
|
|
79
149
|
action,
|
|
80
150
|
brandVariant,
|
|
81
151
|
loading,
|
|
82
152
|
feedbackState,
|
|
83
153
|
feedbackText,
|
|
154
|
+
onAction,
|
|
84
155
|
prerenderLabelOnly = true,
|
|
85
156
|
vocabularyPacks = [],
|
|
86
157
|
label: labelOverride,
|
|
87
158
|
...props
|
|
88
159
|
}) {
|
|
160
|
+
if (props.children !== void 0) {
|
|
161
|
+
gdsDevWarnOnce(
|
|
162
|
+
"SemanticButton:children",
|
|
163
|
+
"SemanticButton ignores children: its text comes from `action` or the `label` prop. Pass the text as `label`."
|
|
164
|
+
);
|
|
165
|
+
}
|
|
89
166
|
const { t } = useGdsTranslation();
|
|
90
167
|
const config = resolveSemanticActionConfig(action, vocabularyPacks);
|
|
168
|
+
const motion = config.motion;
|
|
91
169
|
const [mounted, setMounted] = useState(!prerenderLabelOnly);
|
|
92
|
-
const [
|
|
170
|
+
const [phase, setPhaseState] = useState("idle");
|
|
171
|
+
const [cycle, setCycle] = useState(0);
|
|
172
|
+
const [fromRest, setFromRest] = useState(true);
|
|
173
|
+
const phaseRef = useRef("idle");
|
|
174
|
+
const timers = useRef([]);
|
|
175
|
+
const alive = useRef(true);
|
|
176
|
+
const setPhase = useCallback((next) => {
|
|
177
|
+
phaseRef.current = next;
|
|
178
|
+
setPhaseState(next);
|
|
179
|
+
}, []);
|
|
180
|
+
const clearTimers = useCallback(() => {
|
|
181
|
+
for (const timer of timers.current) clearTimeout(timer);
|
|
182
|
+
timers.current = [];
|
|
183
|
+
}, []);
|
|
184
|
+
const later = useCallback((ms, fn) => {
|
|
185
|
+
timers.current.push(setTimeout(fn, ms));
|
|
186
|
+
}, []);
|
|
187
|
+
useEffect(() => {
|
|
188
|
+
alive.current = true;
|
|
189
|
+
return () => {
|
|
190
|
+
alive.current = false;
|
|
191
|
+
clearTimers();
|
|
192
|
+
};
|
|
193
|
+
}, [clearTimers]);
|
|
93
194
|
useEffect(() => {
|
|
94
195
|
if (prerenderLabelOnly) {
|
|
95
196
|
setMounted(true);
|
|
@@ -97,53 +198,122 @@ function SemanticButton({
|
|
|
97
198
|
}, [prerenderLabelOnly]);
|
|
98
199
|
useEffect(() => {
|
|
99
200
|
if (feedbackState) {
|
|
100
|
-
|
|
101
|
-
|
|
201
|
+
setFromRest(true);
|
|
202
|
+
setCycle((n) => n + 1);
|
|
203
|
+
setPhase(feedbackState);
|
|
204
|
+
const timer = setTimeout(() => setPhase("idle"), GDS_BUTTON_FEEDBACK_DURATION_MS);
|
|
102
205
|
return () => clearTimeout(timer);
|
|
103
206
|
}
|
|
104
|
-
}, [feedbackState]);
|
|
105
|
-
|
|
106
|
-
|
|
207
|
+
}, [feedbackState, setPhase]);
|
|
208
|
+
const { onClick, ...buttonRest } = props;
|
|
209
|
+
const handleClick = useCallback(async (event) => {
|
|
210
|
+
if (!onAction) {
|
|
211
|
+
onClick?.(event);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const current = phaseRef.current;
|
|
215
|
+
if (current === "busy" || current === "pending") {
|
|
216
|
+
event.preventDefault();
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
clearTimers();
|
|
220
|
+
if (motion?.confirm && current !== "confirm") {
|
|
221
|
+
setPhase("confirm");
|
|
222
|
+
later(GDS_BUTTON_CONFIRM_WINDOW_MS, () => setPhase("idle"));
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
onClick?.(event);
|
|
226
|
+
setCycle((n) => n + 1);
|
|
227
|
+
setPhase("busy");
|
|
228
|
+
let shownAt = 0;
|
|
229
|
+
later(GDS_BUTTON_PENDING_DELAY_MS, () => {
|
|
230
|
+
shownAt = Date.now();
|
|
231
|
+
setPhase("pending");
|
|
232
|
+
});
|
|
233
|
+
let ok = true;
|
|
234
|
+
try {
|
|
235
|
+
await onAction();
|
|
236
|
+
} catch {
|
|
237
|
+
ok = false;
|
|
238
|
+
}
|
|
239
|
+
clearTimers();
|
|
240
|
+
if (shownAt) {
|
|
241
|
+
const remaining = GDS_BUTTON_PENDING_MIN_MS - (Date.now() - shownAt);
|
|
242
|
+
if (remaining > 0) await new Promise((resolve) => setTimeout(resolve, remaining));
|
|
243
|
+
}
|
|
244
|
+
if (!alive.current) return;
|
|
245
|
+
setFromRest(!shownAt);
|
|
246
|
+
setCycle((n) => n + 1);
|
|
247
|
+
setPhase(ok ? "success" : "error");
|
|
248
|
+
later(GDS_BUTTON_FEEDBACK_DURATION_MS, () => setPhase("idle"));
|
|
249
|
+
}, [onAction, onClick, motion?.confirm, clearTimers, later, setPhase]);
|
|
250
|
+
const restLabel = labelOverride ?? getSemanticActionLabel(action, t, vocabularyPacks);
|
|
251
|
+
const feedbackConfig = config.feedback ?? { icon: IconCheck, color: "teal", messageId: "gds.feedback.saved" };
|
|
252
|
+
const successLabel = feedbackText || t(feedbackConfig.messageId, "Success");
|
|
253
|
+
const failedLabel = feedbackText || t("gds.feedback.failed", "Failed");
|
|
254
|
+
const errorAnnouncement = feedbackText || t("gds.feedback.error", "Something went wrong");
|
|
255
|
+
const confirmLabel = t("gds.feedback.confirmAgain", "Click again to confirm");
|
|
256
|
+
const workingLabel = pendingLabel(action, t);
|
|
257
|
+
const reservesWidth = Boolean(onAction) || feedbackState !== void 0;
|
|
107
258
|
let color = props.color;
|
|
108
259
|
const brandStyle = brandVariant ? brandButtonStyles[brandVariant] : void 0;
|
|
109
260
|
const disabled = props.disabled || brandVariant === "disabled";
|
|
261
|
+
const showingFeedback = phase === "success" || phase === "error";
|
|
110
262
|
const isStylesheetPaintedBrand = brandVariant === "outline-accent" || brandVariant === "gradient";
|
|
111
|
-
const brandButtonAttr = isStylesheetPaintedBrand &&
|
|
263
|
+
const brandButtonAttr = isStylesheetPaintedBrand && showingFeedback ? void 0 : brandVariant;
|
|
112
264
|
if (!mounted) {
|
|
113
|
-
const { leftSection, style, ...
|
|
114
|
-
return /* @__PURE__ */ jsx(Button, { ...
|
|
265
|
+
const { leftSection, style, ...prerenderProps } = buttonRest;
|
|
266
|
+
return /* @__PURE__ */ jsx(Button, { ...prerenderProps, onClick: onAction ? void 0 : onClick, loading, color, "data-gds-brand-button": brandButtonAttr, disabled, "aria-busy": loading ? true : void 0, style: { ...brandStyle, ...style }, children: labelOverride ?? getSemanticActionLabel(action, void 0, vocabularyPacks) });
|
|
115
267
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
268
|
+
let visibleLabel = restLabel;
|
|
269
|
+
let announcement = "";
|
|
270
|
+
if (phase === "success") {
|
|
271
|
+
visibleLabel = successLabel;
|
|
272
|
+
announcement = successLabel;
|
|
273
|
+
color = feedbackConfig.color;
|
|
274
|
+
} else if (phase === "error") {
|
|
275
|
+
visibleLabel = failedLabel;
|
|
276
|
+
announcement = errorAnnouncement;
|
|
124
277
|
color = "red";
|
|
278
|
+
} else if (phase === "pending") {
|
|
279
|
+
visibleLabel = workingLabel;
|
|
280
|
+
announcement = workingLabel;
|
|
281
|
+
} else if (phase === "confirm") {
|
|
282
|
+
visibleLabel = confirmLabel;
|
|
283
|
+
announcement = confirmLabel;
|
|
125
284
|
}
|
|
285
|
+
const ghosts = [restLabel, successLabel, failedLabel];
|
|
286
|
+
if (onAction) ghosts.push(workingLabel);
|
|
287
|
+
if (onAction && motion?.confirm) ghosts.push(confirmLabel);
|
|
288
|
+
const busy = phase === "busy" || phase === "pending";
|
|
126
289
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
127
290
|
/* @__PURE__ */ jsx(
|
|
128
291
|
Button,
|
|
129
292
|
{
|
|
130
|
-
...
|
|
131
|
-
|
|
293
|
+
...buttonRest,
|
|
294
|
+
onClick: handleClick,
|
|
295
|
+
leftSection: /* @__PURE__ */ jsx(ButtonIcon, { phase, motion, Icon: config.icon, SuccessIcon: feedbackConfig.icon, fromRest }, `${phase}-${cycle}`),
|
|
132
296
|
loading,
|
|
133
297
|
color,
|
|
134
298
|
"data-gds-brand-button": brandButtonAttr,
|
|
299
|
+
"data-gds-button-phase": phase === "idle" ? void 0 : phase,
|
|
135
300
|
disabled,
|
|
136
|
-
"aria-
|
|
301
|
+
"aria-disabled": busy ? true : void 0,
|
|
302
|
+
"aria-busy": loading || busy ? true : void 0,
|
|
137
303
|
style: { ...brandStyle, ...props.style },
|
|
138
|
-
children: label
|
|
304
|
+
children: reservesWidth ? /* @__PURE__ */ jsxs("span", { "data-gds-button-label-stack": "", children: [
|
|
305
|
+
ghosts.map((ghost, index) => /* @__PURE__ */ jsx("span", { "data-gds-button-label-ghost": "", "aria-hidden": "true", children: ghost }, index)),
|
|
306
|
+
/* @__PURE__ */ jsx("span", { "data-gds-button-label": "", children: visibleLabel })
|
|
307
|
+
] }) : visibleLabel
|
|
139
308
|
}
|
|
140
309
|
),
|
|
141
|
-
|
|
310
|
+
reservesWidth ? /* @__PURE__ */ jsx(VisuallyHidden, { role: "status", "aria-live": "polite", "aria-atomic": "true", children: announcement }) : null
|
|
142
311
|
] });
|
|
143
312
|
}
|
|
144
313
|
|
|
145
314
|
// src/ConfirmDialog.tsx
|
|
146
315
|
import { Modal, Group, Text } from "@mantine/core";
|
|
316
|
+
import { useGdsTranslation as useGdsTranslation2 } from "@sovereignsquad/gds-theme";
|
|
147
317
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
148
318
|
function ConfirmDialog({
|
|
149
319
|
opened,
|
|
@@ -154,15 +324,29 @@ function ConfirmDialog({
|
|
|
154
324
|
confirmAction = "confirm",
|
|
155
325
|
cancelAction = "cancel",
|
|
156
326
|
isDanger = true,
|
|
157
|
-
loading = false
|
|
327
|
+
loading = false,
|
|
328
|
+
confirmLabel,
|
|
329
|
+
cancelLabel
|
|
158
330
|
}) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
331
|
+
const { t } = useGdsTranslation2();
|
|
332
|
+
return /* @__PURE__ */ jsxs2(
|
|
333
|
+
Modal,
|
|
334
|
+
{
|
|
335
|
+
opened,
|
|
336
|
+
onClose,
|
|
337
|
+
title,
|
|
338
|
+
centered: true,
|
|
339
|
+
trapFocus: true,
|
|
340
|
+
closeButtonProps: { "aria-label": t("gds.overlay.close", "Close") },
|
|
341
|
+
children: [
|
|
342
|
+
/* @__PURE__ */ jsx2(Text, { component: "div", size: "sm", mb: "xl", children }),
|
|
343
|
+
/* @__PURE__ */ jsxs2(Group, { justify: "flex-end", children: [
|
|
344
|
+
/* @__PURE__ */ jsx2(SemanticButton, { action: cancelAction, label: cancelLabel, variant: "default", onClick: onClose, disabled: loading }),
|
|
345
|
+
/* @__PURE__ */ jsx2(SemanticButton, { action: confirmAction, label: confirmLabel, color: isDanger ? "red" : void 0, onClick: onConfirm, loading })
|
|
346
|
+
] })
|
|
347
|
+
]
|
|
348
|
+
}
|
|
349
|
+
);
|
|
166
350
|
}
|
|
167
351
|
|
|
168
352
|
// src/GameBoardTile.tsx
|
|
@@ -217,10 +401,418 @@ function useGdsCardContract(options = {}) {
|
|
|
217
401
|
return resolveGdsCardContract({ density: ambientDensity, ...options });
|
|
218
402
|
}
|
|
219
403
|
|
|
404
|
+
// src/GdsShapeScope.tsx
|
|
405
|
+
import { Box } from "@mantine/core";
|
|
406
|
+
import { GDS_RADIUS_ROLES, GDS_SHAPE_PROFILES } from "@sovereignsquad/gds-theme";
|
|
407
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
408
|
+
function getGdsShapeScopeStyle(profile) {
|
|
409
|
+
const roles = profile === "default" ? {} : GDS_SHAPE_PROFILES[profile];
|
|
410
|
+
const style = {};
|
|
411
|
+
for (const role of GDS_RADIUS_ROLES) {
|
|
412
|
+
const step = roles[role];
|
|
413
|
+
if (step) style[`--gds-radius-${role}`] = `var(--gds-radius-${step})`;
|
|
414
|
+
}
|
|
415
|
+
return style;
|
|
416
|
+
}
|
|
417
|
+
function GdsShapeScope({ profile, style, children, ...others }) {
|
|
418
|
+
return /* @__PURE__ */ jsx5(Box, { ...others, "data-gds-shape-profile": profile, style: { ...getGdsShapeScopeStyle(profile), ...style }, children });
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// src/GdsTreeView.tsx
|
|
422
|
+
import { useCallback as useCallback2, useMemo, useRef as useRef2, useState as useState2 } from "react";
|
|
423
|
+
import { Box as Box2, Button as Button2, Group as Group2, Loader, Paper as Paper2, Text as Text3 } from "@mantine/core";
|
|
424
|
+
import { useUncontrolled } from "@mantine/hooks";
|
|
425
|
+
import { useGdsTranslation as useGdsTranslation3 } from "@sovereignsquad/gds-theme";
|
|
426
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
427
|
+
function GdsTreeView({
|
|
428
|
+
nodes,
|
|
429
|
+
ariaLabel,
|
|
430
|
+
expandedIds,
|
|
431
|
+
defaultExpandedIds = [],
|
|
432
|
+
onExpandedChange,
|
|
433
|
+
selectedId,
|
|
434
|
+
defaultSelectedId = null,
|
|
435
|
+
onSelect,
|
|
436
|
+
loadChildren
|
|
437
|
+
}) {
|
|
438
|
+
const { t } = useGdsTranslation3();
|
|
439
|
+
const [expanded, setExpanded] = useUncontrolled({ value: expandedIds, defaultValue: defaultExpandedIds, finalValue: [], onChange: onExpandedChange });
|
|
440
|
+
const [selected, setSelected] = useUncontrolled({ value: selectedId, defaultValue: defaultSelectedId, finalValue: null });
|
|
441
|
+
const [loads, setLoads] = useState2({});
|
|
442
|
+
const [focusedId, setFocusedId] = useState2(null);
|
|
443
|
+
const itemRefs = useRef2(/* @__PURE__ */ new Map());
|
|
444
|
+
const childrenOf = useCallback2((node) => {
|
|
445
|
+
if (node.children) return node.children;
|
|
446
|
+
const load2 = loads[node.id];
|
|
447
|
+
return load2?.status === "loaded" ? load2.children : void 0;
|
|
448
|
+
}, [loads]);
|
|
449
|
+
const visible = useMemo(() => {
|
|
450
|
+
const out = [];
|
|
451
|
+
const walk = (list, level, parentId) => {
|
|
452
|
+
for (const node of list) {
|
|
453
|
+
const children = childrenOf(node);
|
|
454
|
+
const expandable = Boolean(node.children?.length) || Boolean(node.hasChildren);
|
|
455
|
+
const isExpanded = expandable && expanded.includes(node.id);
|
|
456
|
+
out.push({ node, level, parentId, expandable, expanded: isExpanded, children });
|
|
457
|
+
if (isExpanded && children) walk(children, level + 1, node.id);
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
walk(nodes, 1, null);
|
|
461
|
+
return out;
|
|
462
|
+
}, [nodes, expanded, childrenOf]);
|
|
463
|
+
const tabStop = focusedId && visible.some((item) => item.node.id === focusedId) ? focusedId : selected && visible.some((item) => item.node.id === selected) ? selected : visible[0]?.node.id;
|
|
464
|
+
const focus = (id) => {
|
|
465
|
+
if (!id) return;
|
|
466
|
+
setFocusedId(id);
|
|
467
|
+
itemRefs.current.get(id)?.focus();
|
|
468
|
+
};
|
|
469
|
+
const load = async (node) => {
|
|
470
|
+
if (!loadChildren || node.children || loads[node.id]?.status === "loading" || loads[node.id]?.status === "loaded") return;
|
|
471
|
+
setLoads((prev) => ({ ...prev, [node.id]: { status: "loading" } }));
|
|
472
|
+
try {
|
|
473
|
+
const children = await loadChildren(node);
|
|
474
|
+
setLoads((prev) => ({ ...prev, [node.id]: { status: "loaded", children } }));
|
|
475
|
+
} catch {
|
|
476
|
+
setLoads((prev) => ({ ...prev, [node.id]: { status: "error" } }));
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
const setOpen = (item, open) => {
|
|
480
|
+
if (!item.expandable || item.expanded === open) return;
|
|
481
|
+
setExpanded(open ? [...expanded, item.node.id] : expanded.filter((id) => id !== item.node.id));
|
|
482
|
+
if (open) void load(item.node);
|
|
483
|
+
};
|
|
484
|
+
const select = (item) => {
|
|
485
|
+
setSelected(item.node.id);
|
|
486
|
+
onSelect?.(item.node.id, item.node);
|
|
487
|
+
};
|
|
488
|
+
const onKeyDown = (event, index) => {
|
|
489
|
+
const item = visible[index];
|
|
490
|
+
switch (event.key) {
|
|
491
|
+
case "ArrowDown":
|
|
492
|
+
focus(visible[index + 1]?.node.id);
|
|
493
|
+
break;
|
|
494
|
+
case "ArrowUp":
|
|
495
|
+
focus(visible[index - 1]?.node.id);
|
|
496
|
+
break;
|
|
497
|
+
case "Home":
|
|
498
|
+
focus(visible[0]?.node.id);
|
|
499
|
+
break;
|
|
500
|
+
case "End":
|
|
501
|
+
focus(visible[visible.length - 1]?.node.id);
|
|
502
|
+
break;
|
|
503
|
+
case "ArrowRight":
|
|
504
|
+
if (item.expandable && !item.expanded) setOpen(item, true);
|
|
505
|
+
else if (item.expanded && item.children?.length) focus(visible[index + 1]?.node.id);
|
|
506
|
+
break;
|
|
507
|
+
case "ArrowLeft":
|
|
508
|
+
if (item.expanded) setOpen(item, false);
|
|
509
|
+
else focus(item.parentId ?? void 0);
|
|
510
|
+
break;
|
|
511
|
+
case "Enter":
|
|
512
|
+
case " ":
|
|
513
|
+
select(item);
|
|
514
|
+
break;
|
|
515
|
+
default:
|
|
516
|
+
if (event.key.length === 1 && /\S/.test(event.key)) {
|
|
517
|
+
const key = event.key.toLowerCase();
|
|
518
|
+
const ordered = [...visible.slice(index + 1), ...visible.slice(0, index + 1)];
|
|
519
|
+
focus(ordered.find((candidate) => candidate.node.label.toLowerCase().startsWith(key))?.node.id);
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
event.preventDefault();
|
|
525
|
+
};
|
|
526
|
+
const renderLevel = (list, level) => list.map((node) => {
|
|
527
|
+
const index = visible.findIndex((item2) => item2.node.id === node.id);
|
|
528
|
+
const item = visible[index];
|
|
529
|
+
if (!item) return null;
|
|
530
|
+
const loadState = loads[node.id];
|
|
531
|
+
const isSelected = selected === node.id;
|
|
532
|
+
return /* @__PURE__ */ jsxs3(Box2, { component: "li", role: "none", style: { listStyle: "none" }, children: [
|
|
533
|
+
/* @__PURE__ */ jsxs3(
|
|
534
|
+
Box2,
|
|
535
|
+
{
|
|
536
|
+
ref: (el) => {
|
|
537
|
+
if (el) itemRefs.current.set(node.id, el);
|
|
538
|
+
else itemRefs.current.delete(node.id);
|
|
539
|
+
},
|
|
540
|
+
role: "treeitem",
|
|
541
|
+
"aria-level": level,
|
|
542
|
+
"aria-expanded": item.expandable ? item.expanded : void 0,
|
|
543
|
+
"aria-selected": isSelected,
|
|
544
|
+
"aria-busy": loadState?.status === "loading" || void 0,
|
|
545
|
+
tabIndex: tabStop === node.id ? 0 : -1,
|
|
546
|
+
"data-gds-tree-item": "",
|
|
547
|
+
"data-selected": isSelected || void 0,
|
|
548
|
+
onKeyDown: (event) => onKeyDown(event, index),
|
|
549
|
+
onFocus: () => setFocusedId(node.id),
|
|
550
|
+
onClick: () => {
|
|
551
|
+
select(item);
|
|
552
|
+
if (item.expandable) setOpen(item, !item.expanded);
|
|
553
|
+
},
|
|
554
|
+
style: {
|
|
555
|
+
display: "flex",
|
|
556
|
+
alignItems: "center",
|
|
557
|
+
gap: "var(--gds-space-xs)",
|
|
558
|
+
minHeight: "var(--gds-control-height-sm)",
|
|
559
|
+
paddingInlineStart: `calc(var(--gds-space-xs) + ${level - 1} * var(--gds-space-md))`,
|
|
560
|
+
paddingInlineEnd: "var(--gds-space-xs)",
|
|
561
|
+
borderRadius: "var(--gds-radius-sm)",
|
|
562
|
+
cursor: "pointer",
|
|
563
|
+
background: isSelected ? "var(--gds-nav-active-bg)" : void 0,
|
|
564
|
+
color: isSelected ? "var(--gds-nav-active-fg)" : void 0
|
|
565
|
+
},
|
|
566
|
+
children: [
|
|
567
|
+
/* @__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" : "" }),
|
|
568
|
+
node.icon ? /* @__PURE__ */ jsx6(Box2, { component: "span", "aria-hidden": "true", style: { display: "inline-flex" }, children: node.icon }) : null,
|
|
569
|
+
/* @__PURE__ */ jsx6(Text3, { component: "span", size: "sm", children: node.label })
|
|
570
|
+
]
|
|
571
|
+
}
|
|
572
|
+
),
|
|
573
|
+
item.expanded ? /* @__PURE__ */ jsxs3(Box2, { component: "ul", role: "group", style: { margin: 0, padding: 0 }, children: [
|
|
574
|
+
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: [
|
|
575
|
+
/* @__PURE__ */ jsx6(Loader, { size: "xs" }),
|
|
576
|
+
/* @__PURE__ */ jsx6(Text3, { size: "sm", children: t("gds.treeView.loading", "Loading\u2026") })
|
|
577
|
+
] }) }) : null,
|
|
578
|
+
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: [
|
|
579
|
+
/* @__PURE__ */ jsx6(Text3, { size: "sm", role: "alert", children: t("gds.treeView.loadError", "Could not load these items.") }),
|
|
580
|
+
/* @__PURE__ */ jsx6(Button2, { size: "compact-xs", variant: "subtle", onClick: () => void load(node), children: t("gds.treeView.retry", "Retry") })
|
|
581
|
+
] }) }) : null,
|
|
582
|
+
item.children ? renderLevel(item.children, level + 1) : null
|
|
583
|
+
] }) : null
|
|
584
|
+
] }, node.id);
|
|
585
|
+
});
|
|
586
|
+
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) }) });
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// src/GdsBulkActionBar.tsx
|
|
590
|
+
import { Button as Button3, Group as Group3, Paper as Paper3, Text as Text4, VisuallyHidden as VisuallyHidden2 } from "@mantine/core";
|
|
591
|
+
import { useGdsTranslation as useGdsTranslation4 } from "@sovereignsquad/gds-theme";
|
|
592
|
+
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
593
|
+
function GdsBulkActionBar({ selectedCount, actions, onClearSelection, vocabularyPacks = [] }) {
|
|
594
|
+
const { t } = useGdsTranslation4();
|
|
595
|
+
const countText = t("gds.bulkActions.selectedCount", "{count} selected").replace("{count}", String(selectedCount));
|
|
596
|
+
const announcement = selectedCount > 0 ? countText : t("gds.bulkActions.selectionCleared", "Selection cleared");
|
|
597
|
+
return /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
598
|
+
/* @__PURE__ */ jsx7(VisuallyHidden2, { role: "status", "aria-live": "polite", "data-gds-bulk-action-status": "", children: announcement }),
|
|
599
|
+
selectedCount > 0 ? /* @__PURE__ */ jsx7(
|
|
600
|
+
Paper3,
|
|
601
|
+
{
|
|
602
|
+
withBorder: true,
|
|
603
|
+
p: "xs",
|
|
604
|
+
role: "toolbar",
|
|
605
|
+
"aria-label": t("gds.bulkActions.toolbarLabel", "Bulk actions"),
|
|
606
|
+
"data-gds-bulk-action-bar": "",
|
|
607
|
+
style: { background: "var(--gds-bg-raised)", ["--paper-border-color"]: "var(--gds-border-strong)" },
|
|
608
|
+
children: /* @__PURE__ */ jsxs4(Group3, { justify: "space-between", gap: "sm", wrap: "wrap", children: [
|
|
609
|
+
/* @__PURE__ */ jsx7(Text4, { size: "sm", fw: 600, "aria-hidden": "true", children: countText }),
|
|
610
|
+
/* @__PURE__ */ jsxs4(Group3, { gap: "xs", wrap: "wrap", children: [
|
|
611
|
+
actions.map((item) => {
|
|
612
|
+
const Icon = resolveSemanticActionConfig(item.action, vocabularyPacks)?.icon;
|
|
613
|
+
const label = item.label ?? getSemanticActionLabel(item.action, t, vocabularyPacks);
|
|
614
|
+
return /* @__PURE__ */ jsx7(
|
|
615
|
+
Button3,
|
|
616
|
+
{
|
|
617
|
+
size: "xs",
|
|
618
|
+
variant: "light",
|
|
619
|
+
leftSection: Icon ? /* @__PURE__ */ jsx7(Icon, { size: "1rem", stroke: 1.5 }) : void 0,
|
|
620
|
+
onClick: item.onClick,
|
|
621
|
+
disabled: item.disabled,
|
|
622
|
+
children: label
|
|
623
|
+
},
|
|
624
|
+
String(item.action)
|
|
625
|
+
);
|
|
626
|
+
}),
|
|
627
|
+
/* @__PURE__ */ jsx7(Button3, { size: "xs", variant: "subtle", onClick: onClearSelection, children: t("gds.bulkActions.clearSelection", "Clear selection") })
|
|
628
|
+
] })
|
|
629
|
+
] })
|
|
630
|
+
}
|
|
631
|
+
) : null
|
|
632
|
+
] });
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// src/GdsThreadList.tsx
|
|
636
|
+
import { Avatar, Box as Box3, Button as Button4, Group as Group4, Stack, Text as Text5, UnstyledButton as UnstyledButton2, VisuallyHidden as VisuallyHidden3 } from "@mantine/core";
|
|
637
|
+
import { useGdsTranslation as useGdsTranslation5 } from "@sovereignsquad/gds-theme";
|
|
638
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
639
|
+
function formatTimestamp(value, locale) {
|
|
640
|
+
const date = new Date(value);
|
|
641
|
+
const sameDay = date.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
|
|
642
|
+
return formatGdsDate(date, sameDay ? { locale, timeStyle: "short" } : { locale, dateStyle: "medium" });
|
|
643
|
+
}
|
|
644
|
+
function GdsThreadList({
|
|
645
|
+
threads,
|
|
646
|
+
ariaLabel,
|
|
647
|
+
selectedId,
|
|
648
|
+
onSelect,
|
|
649
|
+
loading = false,
|
|
650
|
+
error,
|
|
651
|
+
onRetry,
|
|
652
|
+
hasMore = false,
|
|
653
|
+
onLoadMore,
|
|
654
|
+
loadingMore = false,
|
|
655
|
+
emptyTitle,
|
|
656
|
+
stateTitleOrder
|
|
657
|
+
}) {
|
|
658
|
+
const { t, locale } = useGdsTranslation5();
|
|
659
|
+
if (error) {
|
|
660
|
+
return /* @__PURE__ */ jsx8(
|
|
661
|
+
StateBlock,
|
|
662
|
+
{
|
|
663
|
+
variant: "error",
|
|
664
|
+
compact: true,
|
|
665
|
+
titleOrder: stateTitleOrder,
|
|
666
|
+
title: t("gds.threadList.errorTitle", "Conversations could not be loaded"),
|
|
667
|
+
description: error,
|
|
668
|
+
action: onRetry ? /* @__PURE__ */ jsx8(Button4, { size: "xs", variant: "light", onClick: onRetry, children: t("gds.threadList.retry", "Retry") }) : void 0
|
|
669
|
+
}
|
|
670
|
+
);
|
|
671
|
+
}
|
|
672
|
+
if (loading) {
|
|
673
|
+
return /* @__PURE__ */ jsx8(StateBlock, { variant: "loading", compact: true, titleOrder: stateTitleOrder, title: t("gds.threadList.loading", "Loading conversations") });
|
|
674
|
+
}
|
|
675
|
+
if (threads.length === 0) {
|
|
676
|
+
return /* @__PURE__ */ jsx8(StateBlock, { variant: "empty", compact: true, titleOrder: stateTitleOrder, title: emptyTitle ?? t("gds.threadList.emptyTitle", "No conversations yet") });
|
|
677
|
+
}
|
|
678
|
+
return /* @__PURE__ */ jsxs5(Stack, { gap: "xs", "data-gds-thread-list": "", children: [
|
|
679
|
+
/* @__PURE__ */ jsx8(Box3, { component: "ul", "aria-label": ariaLabel, style: { listStyle: "none", margin: 0, padding: 0 }, children: threads.map((thread) => {
|
|
680
|
+
const isSelected = selectedId === thread.id;
|
|
681
|
+
return /* @__PURE__ */ jsx8(Box3, { component: "li", children: /* @__PURE__ */ jsx8(
|
|
682
|
+
UnstyledButton2,
|
|
683
|
+
{
|
|
684
|
+
onClick: () => onSelect?.(thread.id),
|
|
685
|
+
"aria-current": isSelected ? "true" : void 0,
|
|
686
|
+
"data-gds-thread-item": "",
|
|
687
|
+
"data-unread": thread.unread || void 0,
|
|
688
|
+
style: {
|
|
689
|
+
display: "block",
|
|
690
|
+
inlineSize: "100%",
|
|
691
|
+
padding: "var(--gds-space-xs) var(--gds-space-sm)",
|
|
692
|
+
borderRadius: "var(--gds-radius-sm)",
|
|
693
|
+
background: isSelected ? "var(--gds-nav-active-bg)" : void 0,
|
|
694
|
+
color: isSelected ? "var(--gds-nav-active-fg)" : void 0,
|
|
695
|
+
boxShadow: isSelected ? "inset var(--gds-focus-ring-width) 0 0 var(--gds-nav-active-indicator)" : void 0
|
|
696
|
+
},
|
|
697
|
+
children: /* @__PURE__ */ jsxs5(Group4, { gap: "sm", wrap: "nowrap", align: "flex-start", children: [
|
|
698
|
+
/* @__PURE__ */ jsx8(Avatar, { src: thread.avatarSrc, name: thread.avatarName ?? thread.title, alt: thread.avatarName ?? thread.title, radius: "xl", size: "md" }),
|
|
699
|
+
/* @__PURE__ */ jsxs5(Box3, { style: { minWidth: 0, flex: 1 }, children: [
|
|
700
|
+
/* @__PURE__ */ jsxs5(Group4, { gap: "xs", justify: "space-between", wrap: "nowrap", children: [
|
|
701
|
+
/* @__PURE__ */ jsx8(Text5, { size: "sm", fw: thread.unread ? 700 : 500, truncate: true, children: thread.title }),
|
|
702
|
+
thread.timestamp !== void 0 ? /* @__PURE__ */ jsx8(Text5, { size: "xs", c: "dimmed", style: { flex: "none" }, children: formatTimestamp(thread.timestamp, locale) }) : null
|
|
703
|
+
] }),
|
|
704
|
+
/* @__PURE__ */ jsxs5(Group4, { gap: "xs", wrap: "nowrap", children: [
|
|
705
|
+
thread.unread ? /* @__PURE__ */ jsx8(
|
|
706
|
+
Box3,
|
|
707
|
+
{
|
|
708
|
+
component: "span",
|
|
709
|
+
"aria-hidden": "true",
|
|
710
|
+
style: { flex: "none", inlineSize: "var(--gds-space-2xs)", blockSize: "var(--gds-space-2xs)", borderRadius: "var(--gds-radius-pill)", background: "var(--gds-nav-active-indicator)" }
|
|
711
|
+
}
|
|
712
|
+
) : null,
|
|
713
|
+
thread.unread ? /* @__PURE__ */ jsx8(VisuallyHidden3, { children: t("gds.threadList.unread", "Unread") }) : null,
|
|
714
|
+
thread.preview ? /* @__PURE__ */ jsx8(Text5, { size: "xs", c: thread.unread ? void 0 : "dimmed", fw: thread.unread ? 600 : 400, truncate: true, children: thread.preview }) : null
|
|
715
|
+
] })
|
|
716
|
+
] })
|
|
717
|
+
] })
|
|
718
|
+
}
|
|
719
|
+
) }, thread.id);
|
|
720
|
+
}) }),
|
|
721
|
+
hasMore ? /* @__PURE__ */ jsx8(Button4, { variant: "subtle", size: "xs", fullWidth: true, onClick: onLoadMore, loading: loadingMore, children: t("gds.threadList.loadMore", "Load more") }) : null
|
|
722
|
+
] });
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
// src/GdsMessageThread.tsx
|
|
726
|
+
import { Avatar as Avatar2, Box as Box4, Divider, Group as Group5, Stack as Stack2, Text as Text6, VisuallyHidden as VisuallyHidden4 } from "@mantine/core";
|
|
727
|
+
import { useGdsTranslation as useGdsTranslation6 } from "@sovereignsquad/gds-theme";
|
|
728
|
+
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
729
|
+
var dayKey = (date) => `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;
|
|
730
|
+
function GdsMessageThread({ messages, selfId, ariaLabel }) {
|
|
731
|
+
const { t, locale } = useGdsTranslation6();
|
|
732
|
+
const youLabel = t("gds.messageThread.you", "You");
|
|
733
|
+
const rows = [];
|
|
734
|
+
let previousDay = "";
|
|
735
|
+
let previousSender = "";
|
|
736
|
+
for (const message of messages) {
|
|
737
|
+
const date = new Date(message.createdAt);
|
|
738
|
+
const day = dayKey(date);
|
|
739
|
+
if (day !== previousDay) {
|
|
740
|
+
rows.push(
|
|
741
|
+
/* @__PURE__ */ jsx9(
|
|
742
|
+
Divider,
|
|
743
|
+
{
|
|
744
|
+
role: "separator",
|
|
745
|
+
label: formatGdsDate(date, { locale, dateStyle: "medium" }),
|
|
746
|
+
labelPosition: "center",
|
|
747
|
+
"data-gds-message-day": ""
|
|
748
|
+
},
|
|
749
|
+
`day-${day}`
|
|
750
|
+
)
|
|
751
|
+
);
|
|
752
|
+
previousDay = day;
|
|
753
|
+
previousSender = "";
|
|
754
|
+
}
|
|
755
|
+
const isSelf = message.senderId === selfId;
|
|
756
|
+
const showHeader = message.senderId !== previousSender;
|
|
757
|
+
previousSender = message.senderId;
|
|
758
|
+
const time = formatGdsDate(date, { locale, timeStyle: "short" });
|
|
759
|
+
const sender = isSelf ? youLabel : message.senderName;
|
|
760
|
+
rows.push(
|
|
761
|
+
/* @__PURE__ */ jsxs6(Stack2, { gap: 4, align: isSelf ? "flex-end" : "flex-start", "data-gds-message": isSelf ? "self" : "other", children: [
|
|
762
|
+
showHeader ? /* @__PURE__ */ jsxs6(Group5, { gap: "xs", wrap: "nowrap", "aria-hidden": "true", children: [
|
|
763
|
+
!isSelf ? /* @__PURE__ */ jsx9(Avatar2, { src: message.senderAvatarSrc, name: message.senderName, radius: "xl", size: "sm" }) : null,
|
|
764
|
+
/* @__PURE__ */ jsx9(Text6, { size: "xs", fw: 600, children: sender })
|
|
765
|
+
] }) : null,
|
|
766
|
+
/* @__PURE__ */ jsxs6(
|
|
767
|
+
Box4,
|
|
768
|
+
{
|
|
769
|
+
style: {
|
|
770
|
+
maxInlineSize: "80%",
|
|
771
|
+
padding: "var(--gds-space-xs) var(--gds-space-sm)",
|
|
772
|
+
borderRadius: "var(--gds-radius-card)",
|
|
773
|
+
background: isSelf ? "var(--gds-message-self-bg)" : "var(--gds-message-other-bg)",
|
|
774
|
+
color: isSelf ? "var(--gds-message-self-fg)" : "var(--gds-message-other-fg)",
|
|
775
|
+
border: isSelf ? void 0 : "calc(var(--gds-focus-ring-width) / 2) solid var(--gds-border-subtle)"
|
|
776
|
+
},
|
|
777
|
+
children: [
|
|
778
|
+
/* @__PURE__ */ jsx9(VisuallyHidden4, { children: `${sender}, ${time}: ` }),
|
|
779
|
+
/* @__PURE__ */ jsx9(Box4, { children: message.content }),
|
|
780
|
+
/* @__PURE__ */ jsx9(Text6, { size: "xs", "aria-hidden": "true", ta: isSelf ? "end" : "start", children: time })
|
|
781
|
+
]
|
|
782
|
+
}
|
|
783
|
+
)
|
|
784
|
+
] }, message.id)
|
|
785
|
+
);
|
|
786
|
+
}
|
|
787
|
+
return /* @__PURE__ */ jsx9(Stack2, { gap: "sm", role: "log", "aria-label": ariaLabel, "aria-live": "polite", "data-gds-message-thread": "", children: rows });
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
// src/GdsViewToggle.tsx
|
|
791
|
+
import { SegmentedControl } from "@mantine/core";
|
|
792
|
+
import { useGdsTranslation as useGdsTranslation7 } from "@sovereignsquad/gds-theme";
|
|
793
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
794
|
+
function GdsViewToggle({ value, onChange, ariaLabel }) {
|
|
795
|
+
const { t } = useGdsTranslation7();
|
|
796
|
+
return /* @__PURE__ */ jsx10(
|
|
797
|
+
SegmentedControl,
|
|
798
|
+
{
|
|
799
|
+
"aria-label": ariaLabel ?? t("gds.dataView.toggleLabel", "Layout"),
|
|
800
|
+
value,
|
|
801
|
+
onChange: (next) => onChange(next),
|
|
802
|
+
data: [
|
|
803
|
+
{ value: "table", label: t("gds.dataView.table", "Table") },
|
|
804
|
+
{ value: "grid", label: t("gds.dataView.grid", "Grid") }
|
|
805
|
+
],
|
|
806
|
+
style: { alignSelf: "flex-start" },
|
|
807
|
+
"data-gds-view-toggle": ""
|
|
808
|
+
}
|
|
809
|
+
);
|
|
810
|
+
}
|
|
811
|
+
|
|
220
812
|
// src/ProviderCTA.tsx
|
|
221
|
-
import { Text as
|
|
222
|
-
import { useGdsTranslation as
|
|
223
|
-
import { jsx as
|
|
813
|
+
import { Text as Text7 } from "@mantine/core";
|
|
814
|
+
import { useGdsTranslation as useGdsTranslation8 } from "@sovereignsquad/gds-theme";
|
|
815
|
+
import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
224
816
|
var containerStyle = {
|
|
225
817
|
background: "var(--gds-bg-info-tag, var(--mantine-color-gray-1))",
|
|
226
818
|
border: "1px solid var(--gds-border-card, var(--gds-vibe-border, var(--mantine-color-default-border)))",
|
|
@@ -239,7 +831,7 @@ function ProviderCTA({
|
|
|
239
831
|
secondaryLabel,
|
|
240
832
|
onSecondary
|
|
241
833
|
}) {
|
|
242
|
-
const { t } =
|
|
834
|
+
const { t } = useGdsTranslation8();
|
|
243
835
|
const resolvedHeadline = headline ?? t("gds.providerCta.headline", "Are you the provider?");
|
|
244
836
|
const resolvedBody = body ?? t(
|
|
245
837
|
"gds.providerCta.body",
|
|
@@ -257,13 +849,13 @@ function ProviderCTA({
|
|
|
257
849
|
secondary: { defaultMessage: toButtonLabel(secondaryLabel), icon: GdsIcons.Info }
|
|
258
850
|
})
|
|
259
851
|
] : void 0;
|
|
260
|
-
return /* @__PURE__ */
|
|
261
|
-
/* @__PURE__ */
|
|
262
|
-
/* @__PURE__ */
|
|
263
|
-
/* @__PURE__ */
|
|
852
|
+
return /* @__PURE__ */ jsx11("div", { style: containerStyle, children: /* @__PURE__ */ jsxs7(GdsStack, { gap: "xs", children: [
|
|
853
|
+
/* @__PURE__ */ jsx11(Text7, { fw: 700, size: "sm", c: "inherit", children: resolvedHeadline }),
|
|
854
|
+
/* @__PURE__ */ jsx11(Text7, { size: "xs", c: "inherit", children: resolvedBody }),
|
|
855
|
+
/* @__PURE__ */ jsx11(
|
|
264
856
|
CtaButtonGroup,
|
|
265
857
|
{
|
|
266
|
-
primary: /* @__PURE__ */
|
|
858
|
+
primary: /* @__PURE__ */ jsx11(
|
|
267
859
|
SemanticButton,
|
|
268
860
|
{
|
|
269
861
|
action: "providerCta:claim",
|
|
@@ -274,7 +866,7 @@ function ProviderCTA({
|
|
|
274
866
|
onClick: onAction
|
|
275
867
|
}
|
|
276
868
|
),
|
|
277
|
-
secondary: showSecondary ? /* @__PURE__ */
|
|
869
|
+
secondary: showSecondary ? /* @__PURE__ */ jsx11(
|
|
278
870
|
SemanticButton,
|
|
279
871
|
{
|
|
280
872
|
action: "providerCta:secondary",
|
|
@@ -291,8 +883,8 @@ function ProviderCTA({
|
|
|
291
883
|
}
|
|
292
884
|
|
|
293
885
|
// src/ListingState.client.tsx
|
|
294
|
-
import { createContext as createContext2, useContext as useContext2, useMemo, useReducer } from "react";
|
|
295
|
-
import { jsx as
|
|
886
|
+
import { createContext as createContext2, useContext as useContext2, useMemo as useMemo2, useReducer } from "react";
|
|
887
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
296
888
|
function createInitialState(config = {}) {
|
|
297
889
|
return {
|
|
298
890
|
search: "",
|
|
@@ -347,8 +939,8 @@ function ListingProvider({
|
|
|
347
939
|
config
|
|
348
940
|
}) {
|
|
349
941
|
const [state, dispatch] = useReducer(listingQueryReducer, config, createInitialState);
|
|
350
|
-
const value =
|
|
351
|
-
return /* @__PURE__ */
|
|
942
|
+
const value = useMemo2(() => ({ state, dispatch }), [state]);
|
|
943
|
+
return /* @__PURE__ */ jsx12(ListingStateContext.Provider, { value, children });
|
|
352
944
|
}
|
|
353
945
|
function useListingState() {
|
|
354
946
|
const context = useContext2(ListingStateContext);
|
|
@@ -359,10 +951,10 @@ function useListingState() {
|
|
|
359
951
|
}
|
|
360
952
|
|
|
361
953
|
// src/BrowseSelection.client.ts
|
|
362
|
-
import { useState as
|
|
954
|
+
import { useState as useState3 } from "react";
|
|
363
955
|
function useGdsBrowseSelection(options = {}) {
|
|
364
956
|
const { defaultSelectedId = null, selectedId, onChange } = options;
|
|
365
|
-
const [internalSelectedId, setInternalSelectedId] =
|
|
957
|
+
const [internalSelectedId, setInternalSelectedId] = useState3(defaultSelectedId);
|
|
366
958
|
const isControlled = selectedId !== void 0;
|
|
367
959
|
const current = isControlled ? selectedId : internalSelectedId;
|
|
368
960
|
const commit = (next) => {
|
|
@@ -392,17 +984,17 @@ var gdsBreakpointByAlias = {
|
|
|
392
984
|
};
|
|
393
985
|
|
|
394
986
|
// src/DiscoveryShell.tsx
|
|
395
|
-
import { useGdsTranslation as
|
|
396
|
-
import { useEffect as useEffect2, useState as
|
|
397
|
-
import { AppShell as MantineAppShell, Box, Burger, Group as
|
|
987
|
+
import { useGdsTranslation as useGdsTranslation9 } from "@sovereignsquad/gds-theme";
|
|
988
|
+
import { useEffect as useEffect2, useState as useState4 } from "react";
|
|
989
|
+
import { AppShell as MantineAppShell, Box as Box5, Burger, Group as Group6, ScrollArea } from "@mantine/core";
|
|
398
990
|
import { useMediaQuery as useMediaQuery2 } from "@mantine/hooks";
|
|
399
|
-
import { jsx as
|
|
991
|
+
import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
400
992
|
function useDiscoveryShellState({
|
|
401
993
|
defaultSidebarOpen = false,
|
|
402
994
|
sidebarStorageKey,
|
|
403
995
|
onSidebarOpenedChange
|
|
404
996
|
} = {}) {
|
|
405
|
-
const [opened, setOpenedState] =
|
|
997
|
+
const [opened, setOpenedState] = useState4(defaultSidebarOpen);
|
|
406
998
|
useEffect2(() => {
|
|
407
999
|
if (!sidebarStorageKey || typeof window === "undefined") {
|
|
408
1000
|
return;
|
|
@@ -460,7 +1052,7 @@ function DiscoveryShell({
|
|
|
460
1052
|
collapseBreakpoint = "sm",
|
|
461
1053
|
closeMobileNavigationOnItemSelect = true
|
|
462
1054
|
}) {
|
|
463
|
-
const { t } =
|
|
1055
|
+
const { t } = useGdsTranslation9();
|
|
464
1056
|
const mobileNavigationLabel = mobileNavigationLabelProp ?? t("gds.discoveryShell.mobileNavigationLabel", "Toggle navigation");
|
|
465
1057
|
const desktopNavigationLabel = desktopNavigationLabelProp ?? t("gds.discoveryShell.desktopNavigationLabel", "Toggle sidebar");
|
|
466
1058
|
const isMobile = useMediaQuery2(`(max-width: ${gdsBreakpointByAlias[collapseBreakpoint]})`);
|
|
@@ -472,7 +1064,7 @@ function DiscoveryShell({
|
|
|
472
1064
|
"--app-shell-navbar-transform": "translateX(0)",
|
|
473
1065
|
"--app-shell-navbar-transform-rtl": "translateX(0)"
|
|
474
1066
|
} : void 0;
|
|
475
|
-
return /* @__PURE__ */
|
|
1067
|
+
return /* @__PURE__ */ jsxs8(
|
|
476
1068
|
MantineAppShell,
|
|
477
1069
|
{
|
|
478
1070
|
header: { height: headerHeight },
|
|
@@ -487,8 +1079,8 @@ function DiscoveryShell({
|
|
|
487
1079
|
},
|
|
488
1080
|
padding: shellPadding,
|
|
489
1081
|
children: [
|
|
490
|
-
/* @__PURE__ */
|
|
491
|
-
hideMobileNavigationToggle ? null : /* @__PURE__ */
|
|
1082
|
+
/* @__PURE__ */ jsx13(MantineAppShell.Header, { children: /* @__PURE__ */ jsxs8(Group6, { h: "100%", px: "md", gap: "sm", wrap: "nowrap", children: [
|
|
1083
|
+
hideMobileNavigationToggle ? null : /* @__PURE__ */ jsx13(
|
|
492
1084
|
Burger,
|
|
493
1085
|
{
|
|
494
1086
|
opened,
|
|
@@ -498,7 +1090,7 @@ function DiscoveryShell({
|
|
|
498
1090
|
"aria-label": mobileNavigationLabel
|
|
499
1091
|
}
|
|
500
1092
|
),
|
|
501
|
-
desktopCollapsible ? /* @__PURE__ */
|
|
1093
|
+
desktopCollapsible ? /* @__PURE__ */ jsx13(
|
|
502
1094
|
Burger,
|
|
503
1095
|
{
|
|
504
1096
|
opened,
|
|
@@ -508,9 +1100,9 @@ function DiscoveryShell({
|
|
|
508
1100
|
"aria-label": desktopNavigationLabel
|
|
509
1101
|
}
|
|
510
1102
|
) : null,
|
|
511
|
-
/* @__PURE__ */
|
|
1103
|
+
/* @__PURE__ */ jsx13(Box5, { style: { flex: 1, minWidth: 0 }, children: header })
|
|
512
1104
|
] }) }),
|
|
513
|
-
/* @__PURE__ */
|
|
1105
|
+
/* @__PURE__ */ jsx13(
|
|
514
1106
|
MantineAppShell.Navbar,
|
|
515
1107
|
{
|
|
516
1108
|
p: "md",
|
|
@@ -521,8 +1113,8 @@ function DiscoveryShell({
|
|
|
521
1113
|
close();
|
|
522
1114
|
}
|
|
523
1115
|
},
|
|
524
|
-
children: /* @__PURE__ */
|
|
525
|
-
|
|
1116
|
+
children: /* @__PURE__ */ jsx13(ScrollArea, { h: "100%", type: "auto", children: /* @__PURE__ */ jsx13(
|
|
1117
|
+
Box5,
|
|
526
1118
|
{
|
|
527
1119
|
h: "100%",
|
|
528
1120
|
style: stickySidebar ? {
|
|
@@ -534,8 +1126,8 @@ function DiscoveryShell({
|
|
|
534
1126
|
) })
|
|
535
1127
|
}
|
|
536
1128
|
),
|
|
537
|
-
footer ? /* @__PURE__ */
|
|
538
|
-
/* @__PURE__ */
|
|
1129
|
+
footer ? /* @__PURE__ */ jsx13(MantineAppShell.Footer, { children: /* @__PURE__ */ jsx13(Group6, { h: "100%", px: "md", justify: "space-around", wrap: "nowrap", children: footer }) }) : null,
|
|
1130
|
+
/* @__PURE__ */ jsx13(
|
|
539
1131
|
MantineAppShell.Main,
|
|
540
1132
|
{
|
|
541
1133
|
onClick: () => {
|
|
@@ -552,25 +1144,25 @@ function DiscoveryShell({
|
|
|
552
1144
|
}
|
|
553
1145
|
|
|
554
1146
|
// src/DocsShell.tsx
|
|
555
|
-
import { useState as
|
|
556
|
-
import { Box as
|
|
557
|
-
import { useGdsTranslation as
|
|
558
|
-
import { Fragment as
|
|
1147
|
+
import { useState as useState5 } from "react";
|
|
1148
|
+
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";
|
|
1149
|
+
import { useGdsTranslation as useGdsTranslation10 } from "@sovereignsquad/gds-theme";
|
|
1150
|
+
import { Fragment as Fragment3, jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
559
1151
|
var navigationActivationSelector2 = 'a[href], button, [role="menuitem"], [data-gds-nav-close]';
|
|
560
1152
|
function isNavigationActivationTarget2(target) {
|
|
561
1153
|
return target instanceof HTMLElement && Boolean(target.closest(navigationActivationSelector2));
|
|
562
1154
|
}
|
|
563
1155
|
function DocsShellSidebar({ primaryNavigation, secondaryNavigation }) {
|
|
564
|
-
const { t } =
|
|
565
|
-
return /* @__PURE__ */
|
|
566
|
-
primaryNavigation ? /* @__PURE__ */
|
|
567
|
-
/* @__PURE__ */
|
|
1156
|
+
const { t } = useGdsTranslation10();
|
|
1157
|
+
return /* @__PURE__ */ jsxs9(Stack3, { gap: "md", h: "100%", children: [
|
|
1158
|
+
primaryNavigation ? /* @__PURE__ */ jsxs9(Stack3, { gap: "xs", children: [
|
|
1159
|
+
/* @__PURE__ */ jsx14(Text8, { size: "xs", fw: 700, c: "dimmed", children: t("gds.navigation.primary", "Primary") }),
|
|
568
1160
|
primaryNavigation
|
|
569
1161
|
] }) : null,
|
|
570
|
-
secondaryNavigation ? /* @__PURE__ */
|
|
571
|
-
/* @__PURE__ */
|
|
572
|
-
/* @__PURE__ */
|
|
573
|
-
/* @__PURE__ */
|
|
1162
|
+
secondaryNavigation ? /* @__PURE__ */ jsxs9(Fragment3, { children: [
|
|
1163
|
+
/* @__PURE__ */ jsx14(Divider2, {}),
|
|
1164
|
+
/* @__PURE__ */ jsxs9(Stack3, { gap: "xs", children: [
|
|
1165
|
+
/* @__PURE__ */ jsx14(Text8, { size: "xs", fw: 700, c: "dimmed", children: t("gds.navigation.more", "More") }),
|
|
574
1166
|
secondaryNavigation
|
|
575
1167
|
] })
|
|
576
1168
|
] }) : null
|
|
@@ -589,7 +1181,7 @@ function DocsHeaderActionSelect({
|
|
|
589
1181
|
onChange,
|
|
590
1182
|
...props
|
|
591
1183
|
}) {
|
|
592
|
-
return /* @__PURE__ */
|
|
1184
|
+
return /* @__PURE__ */ jsx14(
|
|
593
1185
|
NativeSelect,
|
|
594
1186
|
{
|
|
595
1187
|
"aria-label": label,
|
|
@@ -618,13 +1210,13 @@ function DocsShell({
|
|
|
618
1210
|
children,
|
|
619
1211
|
contentWidth = "full"
|
|
620
1212
|
}) {
|
|
621
|
-
const [mobileNavOpen, setMobileNavOpen] =
|
|
622
|
-
const { t } =
|
|
623
|
-
return /* @__PURE__ */
|
|
1213
|
+
const [mobileNavOpen, setMobileNavOpen] = useState5(false);
|
|
1214
|
+
const { t } = useGdsTranslation10();
|
|
1215
|
+
return /* @__PURE__ */ jsx14(
|
|
624
1216
|
DiscoveryShell,
|
|
625
1217
|
{
|
|
626
|
-
header: /* @__PURE__ */
|
|
627
|
-
|
|
1218
|
+
header: /* @__PURE__ */ jsxs9(
|
|
1219
|
+
Box6,
|
|
628
1220
|
{
|
|
629
1221
|
"data-gds-docs-shell-header": true,
|
|
630
1222
|
h: "100%",
|
|
@@ -638,8 +1230,8 @@ function DocsShell({
|
|
|
638
1230
|
overflow: "hidden"
|
|
639
1231
|
},
|
|
640
1232
|
children: [
|
|
641
|
-
/* @__PURE__ */
|
|
642
|
-
|
|
1233
|
+
/* @__PURE__ */ jsxs9(
|
|
1234
|
+
Group7,
|
|
643
1235
|
{
|
|
644
1236
|
"data-gds-docs-shell-brand-row": true,
|
|
645
1237
|
gap: "sm",
|
|
@@ -648,8 +1240,8 @@ function DocsShell({
|
|
|
648
1240
|
miw: 0,
|
|
649
1241
|
style: { overflow: "hidden" },
|
|
650
1242
|
children: [
|
|
651
|
-
mobileNavigationMode === "inline-collapse" && mobileNavigation ? /* @__PURE__ */
|
|
652
|
-
/* @__PURE__ */
|
|
1243
|
+
mobileNavigationMode === "inline-collapse" && mobileNavigation ? /* @__PURE__ */ jsxs9(Fragment3, { children: [
|
|
1244
|
+
/* @__PURE__ */ jsx14(
|
|
653
1245
|
Burger2,
|
|
654
1246
|
{
|
|
655
1247
|
opened: mobileNavOpen,
|
|
@@ -659,8 +1251,8 @@ function DocsShell({
|
|
|
659
1251
|
"aria-label": t("gds.navigation.openMobile", "Open docs navigation")
|
|
660
1252
|
}
|
|
661
1253
|
),
|
|
662
|
-
/* @__PURE__ */
|
|
663
|
-
|
|
1254
|
+
/* @__PURE__ */ jsx14(Transition, { mounted: mobileNavOpen, transition: "pop", duration: 120, children: (styles) => /* @__PURE__ */ jsx14(Box6, { style: styles, children: /* @__PURE__ */ jsx14(
|
|
1255
|
+
Paper4,
|
|
664
1256
|
{
|
|
665
1257
|
mt: "xs",
|
|
666
1258
|
p: "sm",
|
|
@@ -675,8 +1267,8 @@ function DocsShell({
|
|
|
675
1267
|
}
|
|
676
1268
|
) }) })
|
|
677
1269
|
] }) : null,
|
|
678
|
-
/* @__PURE__ */
|
|
679
|
-
|
|
1270
|
+
/* @__PURE__ */ jsx14(
|
|
1271
|
+
Box6,
|
|
680
1272
|
{
|
|
681
1273
|
"data-gds-docs-shell-brand": true,
|
|
682
1274
|
flex: "1 1 auto",
|
|
@@ -691,12 +1283,12 @@ function DocsShell({
|
|
|
691
1283
|
children: brand
|
|
692
1284
|
}
|
|
693
1285
|
),
|
|
694
|
-
headerContext ? /* @__PURE__ */
|
|
1286
|
+
headerContext ? /* @__PURE__ */ jsx14(Text8, { visibleFrom: "sm", size: "sm", c: "dimmed", lineClamp: 1, miw: 0, flex: "0 1 auto", children: headerContext }) : null
|
|
695
1287
|
]
|
|
696
1288
|
}
|
|
697
1289
|
),
|
|
698
|
-
/* @__PURE__ */
|
|
699
|
-
|
|
1290
|
+
/* @__PURE__ */ jsx14(
|
|
1291
|
+
Group7,
|
|
700
1292
|
{
|
|
701
1293
|
"data-gds-docs-shell-actions": true,
|
|
702
1294
|
gap: "xs",
|
|
@@ -711,7 +1303,7 @@ function DocsShell({
|
|
|
711
1303
|
]
|
|
712
1304
|
}
|
|
713
1305
|
),
|
|
714
|
-
sidebar: /* @__PURE__ */
|
|
1306
|
+
sidebar: /* @__PURE__ */ jsx14(
|
|
715
1307
|
DocsShellSidebar,
|
|
716
1308
|
{
|
|
717
1309
|
primaryNavigation,
|
|
@@ -722,25 +1314,26 @@ function DocsShell({
|
|
|
722
1314
|
mobileNavigationLabel: t("gds.navigation.openMobile", "Open docs navigation"),
|
|
723
1315
|
hideMobileNavigationToggle: mobileNavigationMode === "inline-collapse" && Boolean(mobileNavigation),
|
|
724
1316
|
headerHeight: 72,
|
|
725
|
-
children: /* @__PURE__ */
|
|
1317
|
+
children: /* @__PURE__ */ jsx14(Container, { size: resolveContentContainerSize(contentWidth), px: { base: 0, sm: "md" }, py: "lg", w: "100%", children })
|
|
726
1318
|
}
|
|
727
1319
|
);
|
|
728
1320
|
}
|
|
729
1321
|
|
|
730
1322
|
// src/SidebarNav.tsx
|
|
731
1323
|
import { forwardRef } from "react";
|
|
732
|
-
import { Box as
|
|
733
|
-
import {
|
|
734
|
-
import {
|
|
1324
|
+
import { Box as Box7, NavLink, Stack as Stack4, Text as Text9, createPolymorphicComponent } from "@mantine/core";
|
|
1325
|
+
import { useUncontrolled as useUncontrolled2 } from "@mantine/hooks";
|
|
1326
|
+
import { useGdsTranslation as useGdsTranslation11 } from "@sovereignsquad/gds-theme";
|
|
1327
|
+
import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
735
1328
|
function SidebarNav({ children, ariaLabel: ariaLabelProp, gap = "md" }) {
|
|
736
|
-
const { t } =
|
|
1329
|
+
const { t } = useGdsTranslation11();
|
|
737
1330
|
const ariaLabel = ariaLabelProp ?? t("gds.sidebarNav.ariaLabel", "Primary navigation");
|
|
738
|
-
return /* @__PURE__ */
|
|
1331
|
+
return /* @__PURE__ */ jsx15(Stack4, { component: "nav", "aria-label": ariaLabel, gap, h: "100%", children });
|
|
739
1332
|
}
|
|
740
1333
|
function SidebarNavSection({ label, children, pushToBottom = false }) {
|
|
741
|
-
return /* @__PURE__ */
|
|
742
|
-
label ? /* @__PURE__ */
|
|
743
|
-
/* @__PURE__ */
|
|
1334
|
+
return /* @__PURE__ */ jsxs10(Stack4, { gap: "xs", mt: pushToBottom ? "auto" : void 0, children: [
|
|
1335
|
+
label ? /* @__PURE__ */ jsx15(Text9, { size: "xs", fw: 700, c: "dimmed", children: label }) : null,
|
|
1336
|
+
/* @__PURE__ */ jsx15(Stack4, { gap: 4, children })
|
|
744
1337
|
] });
|
|
745
1338
|
}
|
|
746
1339
|
var _SidebarNavItem = forwardRef(
|
|
@@ -753,23 +1346,34 @@ var _SidebarNavItem = forwardRef(
|
|
|
753
1346
|
"aria-label": ariaLabel,
|
|
754
1347
|
"aria-current": ariaCurrent,
|
|
755
1348
|
vocabularyPacks = [],
|
|
1349
|
+
children,
|
|
1350
|
+
opened: openedProp,
|
|
1351
|
+
defaultOpened,
|
|
1352
|
+
onChange,
|
|
1353
|
+
childrenOffset = "var(--gds-space-md)",
|
|
756
1354
|
...props
|
|
757
1355
|
}, ref) => {
|
|
758
|
-
const { t } =
|
|
1356
|
+
const { t } = useGdsTranslation11();
|
|
1357
|
+
const hasChildren = Boolean(children);
|
|
1358
|
+
const [opened, setOpened] = useUncontrolled2({ value: openedProp, defaultValue: defaultOpened, finalValue: false, onChange });
|
|
1359
|
+
const disclosureProps = hasChildren ? { component: "button", type: "button", "aria-expanded": opened, opened, onChange: setOpened } : {};
|
|
759
1360
|
const config = action ? resolveSemanticActionConfig(action, vocabularyPacks) : null;
|
|
760
1361
|
const Icon = config?.icon;
|
|
761
1362
|
const resolvedLabel = label ?? (action ? getSemanticActionLabel(action, t, vocabularyPacks) : void 0);
|
|
762
|
-
return /* @__PURE__ */
|
|
1363
|
+
return /* @__PURE__ */ jsx15(
|
|
763
1364
|
NavLink,
|
|
764
1365
|
{
|
|
765
1366
|
ref,
|
|
766
1367
|
label: resolvedLabel,
|
|
767
1368
|
description,
|
|
768
|
-
leftSection: icon ?? (Icon ? /* @__PURE__ */
|
|
769
|
-
rightSection: badge ? /* @__PURE__ */
|
|
1369
|
+
leftSection: icon ?? (Icon ? /* @__PURE__ */ jsx15(Icon, { size: "1rem", stroke: 1.5 }) : void 0),
|
|
1370
|
+
rightSection: badge ? /* @__PURE__ */ jsx15(Box7, { children: badge }) : props.rightSection,
|
|
770
1371
|
"aria-label": ariaLabel ?? (typeof resolvedLabel === "string" ? resolvedLabel : void 0),
|
|
771
1372
|
"aria-current": props.active ? "page" : ariaCurrent,
|
|
772
|
-
|
|
1373
|
+
childrenOffset,
|
|
1374
|
+
...disclosureProps,
|
|
1375
|
+
...props,
|
|
1376
|
+
children
|
|
773
1377
|
}
|
|
774
1378
|
);
|
|
775
1379
|
}
|
|
@@ -777,11 +1381,13 @@ var _SidebarNavItem = forwardRef(
|
|
|
777
1381
|
var SidebarNavItem = createPolymorphicComponent(_SidebarNavItem);
|
|
778
1382
|
|
|
779
1383
|
// src/DocsCodeBlock.tsx
|
|
780
|
-
import { useState as
|
|
781
|
-
import { ActionIcon, Code, Group as
|
|
782
|
-
import {
|
|
1384
|
+
import { useState as useState6 } from "react";
|
|
1385
|
+
import { ActionIcon, Code, Group as Group8, Paper as Paper5, Stack as Stack5, Text as Text10 } from "@mantine/core";
|
|
1386
|
+
import { useGdsTranslation as useGdsTranslation12 } from "@sovereignsquad/gds-theme";
|
|
1387
|
+
import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
783
1388
|
function DocsCodeBlock({ code, language, title, withCopy = true }) {
|
|
784
|
-
const
|
|
1389
|
+
const { t } = useGdsTranslation12();
|
|
1390
|
+
const [copied, setCopied] = useState6(false);
|
|
785
1391
|
const handleCopy = async () => {
|
|
786
1392
|
if (!navigator?.clipboard) {
|
|
787
1393
|
return;
|
|
@@ -790,35 +1396,195 @@ function DocsCodeBlock({ code, language, title, withCopy = true }) {
|
|
|
790
1396
|
setCopied(true);
|
|
791
1397
|
window.setTimeout(() => setCopied(false), 1200);
|
|
792
1398
|
};
|
|
793
|
-
return /* @__PURE__ */
|
|
794
|
-
title || withCopy ? /* @__PURE__ */
|
|
795
|
-
/* @__PURE__ */
|
|
796
|
-
title ? /* @__PURE__ */
|
|
797
|
-
language ? /* @__PURE__ */
|
|
1399
|
+
return /* @__PURE__ */ jsx16(Paper5, { withBorder: true, radius: "lg", p: "md", children: /* @__PURE__ */ jsxs11(Stack5, { gap: "sm", children: [
|
|
1400
|
+
title || withCopy ? /* @__PURE__ */ jsxs11(Group8, { justify: "space-between", align: "center", children: [
|
|
1401
|
+
/* @__PURE__ */ jsxs11(Stack5, { gap: 0, children: [
|
|
1402
|
+
title ? /* @__PURE__ */ jsx16(Text10, { fw: 600, children: title }) : null,
|
|
1403
|
+
language ? /* @__PURE__ */ jsx16(Text10, { size: "xs", c: "dimmed", children: language }) : null
|
|
798
1404
|
] }),
|
|
799
|
-
withCopy ? /* @__PURE__ */
|
|
1405
|
+
withCopy ? /* @__PURE__ */ jsx16(
|
|
800
1406
|
ActionIcon,
|
|
801
1407
|
{
|
|
802
1408
|
"data-gds-copy-action": true,
|
|
803
1409
|
variant: "default",
|
|
804
1410
|
size: "xl",
|
|
805
|
-
"aria-label": copied ? "Copied code block" : "Copy code block",
|
|
1411
|
+
"aria-label": copied ? t("gds.docsCodeBlock.copied", "Copied code block") : t("gds.docsCodeBlock.copy", "Copy code block"),
|
|
806
1412
|
onClick: () => {
|
|
807
1413
|
void handleCopy();
|
|
808
1414
|
},
|
|
809
|
-
children: /* @__PURE__ */
|
|
1415
|
+
children: /* @__PURE__ */ jsx16(GdsIcons.Copy, { size: "1rem" })
|
|
810
1416
|
}
|
|
811
1417
|
) : null
|
|
812
1418
|
] }) : null,
|
|
813
|
-
/* @__PURE__ */
|
|
1419
|
+
/* @__PURE__ */ jsx16(Code, { block: true, tabIndex: 0, role: "group", "aria-label": title ?? t("gds.docsCodeBlock.region", "Code"), children: code })
|
|
814
1420
|
] }) });
|
|
815
1421
|
}
|
|
816
1422
|
|
|
1423
|
+
// src/DocsCodeDisclosure.tsx
|
|
1424
|
+
import { useCallback as useCallback3, useEffect as useEffect3, useRef as useRef3, useState as useState7 } from "react";
|
|
1425
|
+
import { Accordion } from "@mantine/core";
|
|
1426
|
+
import { useGdsTranslation as useGdsTranslation13 } from "@sovereignsquad/gds-theme";
|
|
1427
|
+
import { jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1428
|
+
function DocsCodeDisclosure({ code, loadCode, language, label, defaultOpened = false }) {
|
|
1429
|
+
const { t } = useGdsTranslation13();
|
|
1430
|
+
const [opened, setOpened] = useState7(defaultOpened);
|
|
1431
|
+
const [state, setState] = useState7(code !== void 0 ? { status: "ready", code } : { status: "idle" });
|
|
1432
|
+
const load = useCallback3(() => {
|
|
1433
|
+
if (!loadCode) return;
|
|
1434
|
+
setState({ status: "loading" });
|
|
1435
|
+
loadCode().then((loaded) => setState({ status: "ready", code: loaded })).catch(() => setState({ status: "error" }));
|
|
1436
|
+
}, [loadCode]);
|
|
1437
|
+
const setOpen = (next) => {
|
|
1438
|
+
setOpened(next);
|
|
1439
|
+
if (next && code === void 0 && (state.status === "idle" || state.status === "error")) load();
|
|
1440
|
+
};
|
|
1441
|
+
const loadedOnMount = useRef3(false);
|
|
1442
|
+
useEffect3(() => {
|
|
1443
|
+
if (defaultOpened && code === void 0 && !loadedOnMount.current) {
|
|
1444
|
+
loadedOnMount.current = true;
|
|
1445
|
+
load();
|
|
1446
|
+
}
|
|
1447
|
+
}, [defaultOpened, code, load]);
|
|
1448
|
+
const shown = code !== void 0 ? code : state.status === "ready" ? state.code : void 0;
|
|
1449
|
+
return /* @__PURE__ */ jsx17(
|
|
1450
|
+
Accordion,
|
|
1451
|
+
{
|
|
1452
|
+
variant: "contained",
|
|
1453
|
+
radius: "lg",
|
|
1454
|
+
value: opened ? "code" : null,
|
|
1455
|
+
onChange: (value) => setOpen(value === "code"),
|
|
1456
|
+
"data-gds-code-disclosure": "",
|
|
1457
|
+
children: /* @__PURE__ */ jsxs12(Accordion.Item, { value: "code", children: [
|
|
1458
|
+
/* @__PURE__ */ jsx17(Accordion.Control, { children: label ?? t("gds.docsCodeDisclosure.show", "Show code") }),
|
|
1459
|
+
/* @__PURE__ */ jsxs12(Accordion.Panel, { children: [
|
|
1460
|
+
shown !== void 0 ? /* @__PURE__ */ jsx17(DocsCodeBlock, { code: shown, language }) : null,
|
|
1461
|
+
shown === void 0 && state.status === "loading" ? /* @__PURE__ */ jsx17(MetadataText, { role: "status", children: t("gds.docsCodeDisclosure.loading", "Loading code\u2026") }) : null,
|
|
1462
|
+
shown === void 0 && state.status === "error" ? /* @__PURE__ */ jsx17(MetadataText, { role: "alert", children: t("gds.docsCodeDisclosure.error", "The code could not be loaded. Close and reopen to try again.") }) : null
|
|
1463
|
+
] })
|
|
1464
|
+
] })
|
|
1465
|
+
}
|
|
1466
|
+
);
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
// src/GdsTableScrollContainer.tsx
|
|
1470
|
+
import { Table } from "@mantine/core";
|
|
1471
|
+
import { useGdsTranslation as useGdsTranslation14 } from "@sovereignsquad/gds-theme";
|
|
1472
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1473
|
+
function GdsTableScrollContainer({ children, label, minWidth = 0 }) {
|
|
1474
|
+
const { t } = useGdsTranslation14();
|
|
1475
|
+
return /* @__PURE__ */ jsx18(
|
|
1476
|
+
Table.ScrollContainer,
|
|
1477
|
+
{
|
|
1478
|
+
minWidth,
|
|
1479
|
+
type: "native",
|
|
1480
|
+
tabIndex: 0,
|
|
1481
|
+
role: "group",
|
|
1482
|
+
"aria-label": label ?? t("gds.tableScroll.region", "Table"),
|
|
1483
|
+
"data-gds-table-scroll": "",
|
|
1484
|
+
children
|
|
1485
|
+
}
|
|
1486
|
+
);
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
// src/GdsReleaseNotes.client.tsx
|
|
1490
|
+
import { Fragment as Fragment4 } from "react";
|
|
1491
|
+
import { Table as Table2 } from "@mantine/core";
|
|
1492
|
+
import { Fragment as Fragment5, jsx as jsx19, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1493
|
+
var ISSUE_REFERENCE = /#(\d+)/g;
|
|
1494
|
+
function withSlashBreaks(text, key) {
|
|
1495
|
+
if (!text.includes("/")) return text;
|
|
1496
|
+
const pieces = text.split("/");
|
|
1497
|
+
return pieces.map((piece, index) => /* @__PURE__ */ jsxs13(Fragment4, { children: [
|
|
1498
|
+
piece,
|
|
1499
|
+
index < pieces.length - 1 ? /* @__PURE__ */ jsxs13(Fragment5, { children: [
|
|
1500
|
+
"/",
|
|
1501
|
+
/* @__PURE__ */ jsx19("wbr", {})
|
|
1502
|
+
] }) : null
|
|
1503
|
+
] }, `${key}-s${index}`));
|
|
1504
|
+
}
|
|
1505
|
+
function renderText(text, issueHref, key) {
|
|
1506
|
+
if (!issueHref) return withSlashBreaks(text, key);
|
|
1507
|
+
const parts = [];
|
|
1508
|
+
let last = 0;
|
|
1509
|
+
for (const match of text.matchAll(ISSUE_REFERENCE)) {
|
|
1510
|
+
const index = match.index ?? 0;
|
|
1511
|
+
if (index > last) parts.push(/* @__PURE__ */ jsx19(Fragment4, { children: withSlashBreaks(text.slice(last, index), `${key}-t${last}`) }, `${key}-t${last}`));
|
|
1512
|
+
parts.push(/* @__PURE__ */ jsx19(GdsInlineLink, { href: issueHref(Number(match[1])), children: match[0] }, `${key}-${index}`));
|
|
1513
|
+
last = index + match[0].length;
|
|
1514
|
+
}
|
|
1515
|
+
if (last < text.length) parts.push(/* @__PURE__ */ jsx19(Fragment4, { children: withSlashBreaks(text.slice(last), `${key}-t${last}`) }, `${key}-t${last}`));
|
|
1516
|
+
return parts;
|
|
1517
|
+
}
|
|
1518
|
+
function renderInline(content, issueHref, key) {
|
|
1519
|
+
return content.map((part, index) => {
|
|
1520
|
+
const partKey = `${key}-${index}`;
|
|
1521
|
+
switch (part.kind) {
|
|
1522
|
+
case "text":
|
|
1523
|
+
return /* @__PURE__ */ jsx19(Fragment4, { children: renderText(part.text, issueHref, partKey) }, partKey);
|
|
1524
|
+
case "code":
|
|
1525
|
+
return /* @__PURE__ */ jsx19(InlineText, { component: "code", children: part.text }, partKey);
|
|
1526
|
+
case "strong":
|
|
1527
|
+
return /* @__PURE__ */ jsx19(InlineEmphasis, { children: renderInline(part.children, issueHref, partKey) }, partKey);
|
|
1528
|
+
case "link":
|
|
1529
|
+
return /* @__PURE__ */ jsx19(GdsInlineLink, { href: part.href, external: /^https?:/.test(part.href), children: renderInline(part.children, issueHref, partKey) }, partKey);
|
|
1530
|
+
}
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
function renderBlocks(blocks, issueHref, key) {
|
|
1534
|
+
return blocks.map((block, index) => {
|
|
1535
|
+
const blockKey = `${key}-${index}`;
|
|
1536
|
+
switch (block.kind) {
|
|
1537
|
+
case "paragraph":
|
|
1538
|
+
return /* @__PURE__ */ jsx19(BodyText, { children: renderInline(block.content, issueHref, blockKey) }, blockKey);
|
|
1539
|
+
case "list":
|
|
1540
|
+
return /* @__PURE__ */ jsx19(GdsStack, { role: "list", gap: "xs", "data-gds-release-list": block.ordered ? "ordered" : "unordered", children: block.items.map((item, itemIndex) => /* @__PURE__ */ jsxs13(GdsStack, { role: "listitem", gap: "xs", children: [
|
|
1541
|
+
/* @__PURE__ */ jsxs13(BodyText, { children: [
|
|
1542
|
+
/* @__PURE__ */ jsx19("span", { "aria-hidden": "true", "data-gds-release-marker": "", children: block.ordered ? `${itemIndex + 1}. ` : "\u2022 " }),
|
|
1543
|
+
renderInline(item.content, issueHref, `${blockKey}-${itemIndex}`)
|
|
1544
|
+
] }),
|
|
1545
|
+
item.children?.length ? /* @__PURE__ */ jsx19(GdsBox, { padding: { base: "md" }, "data-gds-release-nested": "", children: renderBlocks(item.children, issueHref, `${blockKey}-${itemIndex}-c`) }) : null
|
|
1546
|
+
] }, `${blockKey}-${itemIndex}`)) }, blockKey);
|
|
1547
|
+
case "code":
|
|
1548
|
+
return /* @__PURE__ */ jsx19(DocsCodeBlock, { code: block.code, language: block.language, withCopy: false }, blockKey);
|
|
1549
|
+
case "table":
|
|
1550
|
+
return /* @__PURE__ */ jsx19(GdsTableScrollContainer, { children: /* @__PURE__ */ jsxs13(Table2, { withTableBorder: true, children: [
|
|
1551
|
+
/* @__PURE__ */ jsx19(Table2.Thead, { children: /* @__PURE__ */ jsx19(Table2.Tr, { children: block.header.map((cell, c) => /* @__PURE__ */ jsx19(Table2.Th, { children: renderInline(cell, issueHref, `${blockKey}-h${c}`) }, c)) }) }),
|
|
1552
|
+
/* @__PURE__ */ jsx19(Table2.Tbody, { children: block.rows.map((row, r) => /* @__PURE__ */ jsx19(Table2.Tr, { children: row.map((cell, c) => /* @__PURE__ */ jsx19(Table2.Td, { children: renderInline(cell, issueHref, `${blockKey}-${r}-${c}`) }, c)) }, r)) })
|
|
1553
|
+
] }) }, blockKey);
|
|
1554
|
+
}
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
function releaseAnchor(releases, index) {
|
|
1558
|
+
const base = `release-${releases[index].version.replace(/[^a-z0-9]+/gi, "-").toLowerCase()}`;
|
|
1559
|
+
const earlier = releases.slice(0, index).filter((release) => release.version === releases[index].version).length;
|
|
1560
|
+
return earlier === 0 ? base : `${base}-${earlier + 1}`;
|
|
1561
|
+
}
|
|
1562
|
+
function GdsReleaseNotes({ releases, issueHref, headingLevel = 2 }) {
|
|
1563
|
+
const sectionLevel = headingLevel + 1;
|
|
1564
|
+
return /* @__PURE__ */ jsx19(GdsStack, { gap: "lg", "data-gds-release-notes": "", children: releases.map((release, index) => /* @__PURE__ */ jsx19(
|
|
1565
|
+
SectionPanel,
|
|
1566
|
+
{
|
|
1567
|
+
id: releaseAnchor(releases, index),
|
|
1568
|
+
titleOrder: headingLevel,
|
|
1569
|
+
title: release.title ? `${release.version} \u2014 ${release.title}` : release.version,
|
|
1570
|
+
description: release.date ? /* @__PURE__ */ jsx19(MetadataText, { children: release.date }) : void 0,
|
|
1571
|
+
children: /* @__PURE__ */ jsxs13(GdsStack, { gap: "md", children: [
|
|
1572
|
+
release.intro?.length ? renderBlocks(release.intro, issueHref, `${release.version}-intro`) : null,
|
|
1573
|
+
release.sections.map((section, index2) => /* @__PURE__ */ jsxs13(GdsStack, { gap: "sm", component: "section", children: [
|
|
1574
|
+
/* @__PURE__ */ jsx19(CardTitle, { order: sectionLevel, children: renderInline(section.heading, issueHref, `${release.version}-${index2}-h`) }),
|
|
1575
|
+
renderBlocks(section.blocks, issueHref, `${release.version}-${index2}`)
|
|
1576
|
+
] }, `${release.version}-${index2}`))
|
|
1577
|
+
] })
|
|
1578
|
+
},
|
|
1579
|
+
`${release.version}-${index}`
|
|
1580
|
+
)) });
|
|
1581
|
+
}
|
|
1582
|
+
|
|
817
1583
|
// src/ShareButtonGroup.tsx
|
|
818
|
-
import { useGdsTranslation as
|
|
819
|
-
import { useState as
|
|
820
|
-
import { ActionIcon as ActionIcon2, Button as
|
|
821
|
-
import { jsx as
|
|
1584
|
+
import { useGdsTranslation as useGdsTranslation15 } from "@sovereignsquad/gds-theme";
|
|
1585
|
+
import { useState as useState8 } from "react";
|
|
1586
|
+
import { ActionIcon as ActionIcon2, Button as Button5, Group as Group9, Stack as Stack6, Text as Text11 } from "@mantine/core";
|
|
1587
|
+
import { jsx as jsx20, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
822
1588
|
var channelLabels = {
|
|
823
1589
|
native: "Share",
|
|
824
1590
|
copy: "Copy link",
|
|
@@ -853,9 +1619,9 @@ function ShareAction({
|
|
|
853
1619
|
const label = channelLabels[channel];
|
|
854
1620
|
const Icon = channel === "copy" ? GdsIcons.Copy : channel === "mail" ? GdsIcons.Mail : channel === "message" ? GdsIcons.Message : GdsIcons.Refer;
|
|
855
1621
|
if (compact) {
|
|
856
|
-
return href ? /* @__PURE__ */
|
|
1622
|
+
return href ? /* @__PURE__ */ jsx20(ActionIcon2, { component: "a", href, target: "_blank", rel: "noreferrer", variant: "subtle", size: "lg", "aria-label": label, children: /* @__PURE__ */ jsx20(Icon, { size: "1rem", stroke: 1.75 }) }) : /* @__PURE__ */ jsx20(ActionIcon2, { variant: "subtle", size: "lg", "aria-label": label, onClick, children: /* @__PURE__ */ jsx20(Icon, { size: "1rem", stroke: 1.75 }) });
|
|
857
1623
|
}
|
|
858
|
-
return href ? /* @__PURE__ */
|
|
1624
|
+
return href ? /* @__PURE__ */ jsx20(Button5, { component: "a", href, target: "_blank", rel: "noreferrer", variant: "default", leftSection: /* @__PURE__ */ jsx20(Icon, { size: "1rem", stroke: 1.75 }), children: label }) : /* @__PURE__ */ jsx20(Button5, { variant: "default", leftSection: /* @__PURE__ */ jsx20(Icon, { size: "1rem", stroke: 1.75 }), onClick, children: label });
|
|
859
1625
|
}
|
|
860
1626
|
function ShareButtonGroup({
|
|
861
1627
|
url,
|
|
@@ -866,10 +1632,10 @@ function ShareButtonGroup({
|
|
|
866
1632
|
label: labelProp,
|
|
867
1633
|
description
|
|
868
1634
|
}) {
|
|
869
|
-
const { t } =
|
|
1635
|
+
const { t } = useGdsTranslation15();
|
|
870
1636
|
const label = labelProp ?? t("gds.shareButtonGroup.label", "Share this");
|
|
871
|
-
const [copied, setCopied] =
|
|
872
|
-
const [shared, setShared] =
|
|
1637
|
+
const [copied, setCopied] = useState8(false);
|
|
1638
|
+
const [shared, setShared] = useState8(false);
|
|
873
1639
|
const hrefs = encodeShare(url, title, text);
|
|
874
1640
|
async function handleCopy() {
|
|
875
1641
|
await navigator.clipboard?.writeText?.(url);
|
|
@@ -885,30 +1651,30 @@ function ShareButtonGroup({
|
|
|
885
1651
|
}
|
|
886
1652
|
await handleCopy();
|
|
887
1653
|
}
|
|
888
|
-
return /* @__PURE__ */
|
|
889
|
-
/* @__PURE__ */
|
|
890
|
-
/* @__PURE__ */
|
|
891
|
-
description ? /* @__PURE__ */
|
|
1654
|
+
return /* @__PURE__ */ jsxs14(Stack6, { gap: "sm", children: [
|
|
1655
|
+
/* @__PURE__ */ jsxs14(Stack6, { gap: 2, children: [
|
|
1656
|
+
/* @__PURE__ */ jsx20(Text11, { fw: 600, children: label }),
|
|
1657
|
+
description ? /* @__PURE__ */ jsx20(Text11, { size: "sm", c: "dimmed", children: description }) : null
|
|
892
1658
|
] }),
|
|
893
|
-
/* @__PURE__ */
|
|
1659
|
+
/* @__PURE__ */ jsx20(Group9, { gap: "sm", wrap: "wrap", children: channels.map((channel) => {
|
|
894
1660
|
if (channel === "copy") {
|
|
895
|
-
return /* @__PURE__ */
|
|
1661
|
+
return /* @__PURE__ */ jsx20(ShareAction, { channel, compact, onClick: () => void handleCopy() }, channel);
|
|
896
1662
|
}
|
|
897
1663
|
if (channel === "native") {
|
|
898
|
-
return /* @__PURE__ */
|
|
1664
|
+
return /* @__PURE__ */ jsx20(ShareAction, { channel, compact, onClick: () => void handleNativeShare() }, channel);
|
|
899
1665
|
}
|
|
900
|
-
return /* @__PURE__ */
|
|
1666
|
+
return /* @__PURE__ */ jsx20(ShareAction, { channel, compact, href: hrefs[channel] }, channel);
|
|
901
1667
|
}) }),
|
|
902
|
-
copied ? /* @__PURE__ */
|
|
903
|
-
shared ? /* @__PURE__ */
|
|
1668
|
+
copied ? /* @__PURE__ */ jsx20(Text11, { size: "sm", c: "teal", children: "Link copied." }) : null,
|
|
1669
|
+
shared ? /* @__PURE__ */ jsx20(Text11, { size: "sm", c: "teal", children: "Share sheet opened." }) : null
|
|
904
1670
|
] });
|
|
905
1671
|
}
|
|
906
1672
|
|
|
907
1673
|
// src/UploadDropzone.tsx
|
|
908
|
-
import { useGdsTranslation as
|
|
909
|
-
import { useRef, useState as
|
|
910
|
-
import { Badge, Box as
|
|
911
|
-
import { jsx as
|
|
1674
|
+
import { useGdsTranslation as useGdsTranslation16 } from "@sovereignsquad/gds-theme";
|
|
1675
|
+
import { useRef as useRef4, useState as useState9 } from "react";
|
|
1676
|
+
import { Badge, Box as Box8, Button as Button6, Group as Group10, Progress, Stack as Stack7, Text as Text12 } from "@mantine/core";
|
|
1677
|
+
import { jsx as jsx21, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
912
1678
|
function UploadDropzone({
|
|
913
1679
|
title,
|
|
914
1680
|
description,
|
|
@@ -932,10 +1698,10 @@ function UploadDropzone({
|
|
|
932
1698
|
removeAction,
|
|
933
1699
|
readonly = false
|
|
934
1700
|
}) {
|
|
935
|
-
const { t } =
|
|
1701
|
+
const { t } = useGdsTranslation16();
|
|
936
1702
|
const actionLabel = actionLabelProp ?? t("gds.uploadDropzone.actionLabel", "Choose files");
|
|
937
|
-
const inputRef =
|
|
938
|
-
const [dragging, setDragging] =
|
|
1703
|
+
const inputRef = useRef4(null);
|
|
1704
|
+
const [dragging, setDragging] = useState9(false);
|
|
939
1705
|
const UploadIcon = GdsIcons.Upload;
|
|
940
1706
|
const effectiveState = readonly ? "readonly" : dragging ? "drag-active" : state;
|
|
941
1707
|
const isDisabled = readonly || effectiveState === "upload-pending";
|
|
@@ -947,8 +1713,8 @@ function UploadDropzone({
|
|
|
947
1713
|
}
|
|
948
1714
|
onFilesSelected(Array.from(files));
|
|
949
1715
|
};
|
|
950
|
-
return /* @__PURE__ */
|
|
951
|
-
|
|
1716
|
+
return /* @__PURE__ */ jsxs15(
|
|
1717
|
+
Box8,
|
|
952
1718
|
{
|
|
953
1719
|
onDragOver: (event) => {
|
|
954
1720
|
event.preventDefault();
|
|
@@ -971,7 +1737,7 @@ function UploadDropzone({
|
|
|
971
1737
|
},
|
|
972
1738
|
"aria-invalid": isError || void 0,
|
|
973
1739
|
children: [
|
|
974
|
-
/* @__PURE__ */
|
|
1740
|
+
/* @__PURE__ */ jsx21(
|
|
975
1741
|
"input",
|
|
976
1742
|
{
|
|
977
1743
|
id: inputId,
|
|
@@ -988,30 +1754,30 @@ function UploadDropzone({
|
|
|
988
1754
|
onChange: (event) => forwardFiles(event.currentTarget.files)
|
|
989
1755
|
}
|
|
990
1756
|
),
|
|
991
|
-
/* @__PURE__ */
|
|
992
|
-
/* @__PURE__ */
|
|
993
|
-
/* @__PURE__ */
|
|
994
|
-
/* @__PURE__ */
|
|
995
|
-
description ? /* @__PURE__ */
|
|
996
|
-
acceptedTypesLabel || maxSizeLabel ? /* @__PURE__ */
|
|
997
|
-
acceptedTypesLabel ? /* @__PURE__ */
|
|
998
|
-
maxSizeLabel ? /* @__PURE__ */
|
|
1757
|
+
/* @__PURE__ */ jsxs15(Stack7, { align: mode === "inline" ? "flex-start" : "center", ta: mode === "inline" ? "left" : "center", gap: "sm", children: [
|
|
1758
|
+
/* @__PURE__ */ jsx21(UploadIcon, { size: "1.5rem" }),
|
|
1759
|
+
/* @__PURE__ */ jsx21(Badge, { variant: "light", color: isError ? "red" : effectiveState === "selected" ? "blue" : effectiveState === "upload-pending" ? "violet" : "gray", children: effectiveState.replace("-", " ") }),
|
|
1760
|
+
/* @__PURE__ */ jsx21(Text12, { fw: 600, children: title }),
|
|
1761
|
+
description ? /* @__PURE__ */ jsx21(Text12, { size: "sm", c: "dimmed", children: description }) : null,
|
|
1762
|
+
acceptedTypesLabel || maxSizeLabel ? /* @__PURE__ */ jsxs15(Group10, { gap: "xs", justify: mode === "inline" ? "flex-start" : "center", children: [
|
|
1763
|
+
acceptedTypesLabel ? /* @__PURE__ */ jsx21(Badge, { variant: "outline", color: "gray", children: acceptedTypesLabel }) : null,
|
|
1764
|
+
maxSizeLabel ? /* @__PURE__ */ jsx21(Badge, { variant: "outline", color: "gray", children: maxSizeLabel }) : null
|
|
999
1765
|
] }) : null,
|
|
1000
|
-
selectedFiles.length ? /* @__PURE__ */
|
|
1766
|
+
selectedFiles.length ? /* @__PURE__ */ jsxs15(Text12, { size: "sm", children: [
|
|
1001
1767
|
"Selected: ",
|
|
1002
1768
|
selectedFiles.join(", ")
|
|
1003
1769
|
] }) : null,
|
|
1004
|
-
effectiveState === "upload-pending" && normalizedProgress !== void 0 ? /* @__PURE__ */
|
|
1005
|
-
/* @__PURE__ */
|
|
1006
|
-
/* @__PURE__ */
|
|
1770
|
+
effectiveState === "upload-pending" && normalizedProgress !== void 0 ? /* @__PURE__ */ jsxs15(Box8, { w: "100%", maw: 360, children: [
|
|
1771
|
+
/* @__PURE__ */ jsx21(Progress, { value: normalizedProgress, "aria-label": `${title} upload progress` }),
|
|
1772
|
+
/* @__PURE__ */ jsxs15(Text12, { size: "xs", c: "dimmed", mt: 4, children: [
|
|
1007
1773
|
Math.round(normalizedProgress),
|
|
1008
1774
|
"% uploaded"
|
|
1009
1775
|
] })
|
|
1010
1776
|
] }) : null,
|
|
1011
|
-
policyText ? /* @__PURE__ */
|
|
1012
|
-
error ? /* @__PURE__ */
|
|
1013
|
-
/* @__PURE__ */
|
|
1014
|
-
/* @__PURE__ */
|
|
1777
|
+
policyText ? /* @__PURE__ */ jsx21(Text12, { size: "sm", c: isError ? "red.7" : "dimmed", children: policyText }) : null,
|
|
1778
|
+
error ? /* @__PURE__ */ jsx21(Text12, { size: "sm", c: "red.7", role: "alert", children: error }) : null,
|
|
1779
|
+
/* @__PURE__ */ jsxs15(Group10, { children: [
|
|
1780
|
+
/* @__PURE__ */ jsx21(Button6, { variant: "light", onClick: () => inputRef.current?.click(), disabled: isDisabled, children: actionLabel }),
|
|
1015
1781
|
retryAction,
|
|
1016
1782
|
removeAction
|
|
1017
1783
|
] })
|
|
@@ -1022,9 +1788,9 @@ function UploadDropzone({
|
|
|
1022
1788
|
}
|
|
1023
1789
|
|
|
1024
1790
|
// src/GdsAssetManager.client.tsx
|
|
1025
|
-
import { useCallback, useMemo as
|
|
1026
|
-
import { Button as
|
|
1027
|
-
import { jsx as
|
|
1791
|
+
import { useCallback as useCallback4, useMemo as useMemo3, useState as useState10 } from "react";
|
|
1792
|
+
import { Button as Button7, Group as Group11, Stack as Stack8, Text as Text13, TextInput } from "@mantine/core";
|
|
1793
|
+
import { jsx as jsx22, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1028
1794
|
function emitAssetEvent(onEvent, type, message) {
|
|
1029
1795
|
onEvent?.({ type, message, timestamp: Date.now(), privacy: "metadata-only" });
|
|
1030
1796
|
}
|
|
@@ -1067,8 +1833,8 @@ function useGdsAssetUploadQueue({
|
|
|
1067
1833
|
onEvent,
|
|
1068
1834
|
timeoutMs = 1e4
|
|
1069
1835
|
}) {
|
|
1070
|
-
const [items, setItems] =
|
|
1071
|
-
const uploadItem =
|
|
1836
|
+
const [items, setItems] = useState10([]);
|
|
1837
|
+
const uploadItem = useCallback4(async (item) => {
|
|
1072
1838
|
if (!item.file) return;
|
|
1073
1839
|
const controller = new AbortController();
|
|
1074
1840
|
const timer = window.setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -1091,7 +1857,7 @@ function useGdsAssetUploadQueue({
|
|
|
1091
1857
|
window.clearTimeout(timer);
|
|
1092
1858
|
}
|
|
1093
1859
|
}, [adapter, onEvent, policy, timeoutMs]);
|
|
1094
|
-
const selectFiles =
|
|
1860
|
+
const selectFiles = useCallback4(async (files) => {
|
|
1095
1861
|
for (const file of files) {
|
|
1096
1862
|
const id = assetIdFromFile(file);
|
|
1097
1863
|
emitAssetEvent(onEvent, "asset_selected");
|
|
@@ -1105,16 +1871,16 @@ function useGdsAssetUploadQueue({
|
|
|
1105
1871
|
}
|
|
1106
1872
|
}
|
|
1107
1873
|
}, [onEvent, policy, uploadItem]);
|
|
1108
|
-
const retry =
|
|
1874
|
+
const retry = useCallback4(async (itemId) => {
|
|
1109
1875
|
const item = items.find((entry) => entry.id === itemId);
|
|
1110
1876
|
if (item) await uploadItem(item);
|
|
1111
1877
|
}, [items, uploadItem]);
|
|
1112
|
-
const remove =
|
|
1878
|
+
const remove = useCallback4(async (itemId) => {
|
|
1113
1879
|
const item = items.find((entry) => entry.id === itemId);
|
|
1114
1880
|
if (item?.asset) await adapter.remove?.(item.asset.id);
|
|
1115
1881
|
setItems((current) => current.filter((entry) => entry.id !== itemId));
|
|
1116
1882
|
}, [adapter, items]);
|
|
1117
|
-
const saveMetadata =
|
|
1883
|
+
const saveMetadata = useCallback4((itemId, metadata) => {
|
|
1118
1884
|
setItems((current) => current.map((entry) => {
|
|
1119
1885
|
if (entry.id !== itemId || !entry.asset) return entry;
|
|
1120
1886
|
const asset = { ...entry.asset, ...metadata };
|
|
@@ -1126,7 +1892,7 @@ function useGdsAssetUploadQueue({
|
|
|
1126
1892
|
return { items, selectFiles, retry, remove, saveMetadata };
|
|
1127
1893
|
}
|
|
1128
1894
|
function GdsAssetPreviewCard({ asset, aspectRatio = "1:1" }) {
|
|
1129
|
-
return /* @__PURE__ */
|
|
1895
|
+
return /* @__PURE__ */ jsx22(
|
|
1130
1896
|
MediaPreviewCard,
|
|
1131
1897
|
{
|
|
1132
1898
|
title: asset.fileName,
|
|
@@ -1156,9 +1922,9 @@ function GdsAssetManager({
|
|
|
1156
1922
|
displayMode = "cover"
|
|
1157
1923
|
}) {
|
|
1158
1924
|
const queue = useGdsAssetUploadQueue({ adapter, policy, onEvent, timeoutMs });
|
|
1159
|
-
const accept =
|
|
1160
|
-
return /* @__PURE__ */
|
|
1161
|
-
/* @__PURE__ */
|
|
1925
|
+
const accept = useMemo3(() => policy?.acceptedTypes?.join(",") ?? void 0, [policy]);
|
|
1926
|
+
return /* @__PURE__ */ jsxs16(Stack8, { gap: "md", children: [
|
|
1927
|
+
/* @__PURE__ */ jsx22(
|
|
1162
1928
|
UploadDropzone,
|
|
1163
1929
|
{
|
|
1164
1930
|
title,
|
|
@@ -1174,28 +1940,28 @@ function GdsAssetManager({
|
|
|
1174
1940
|
selectedFiles: queue.items.map((item) => item.fileName)
|
|
1175
1941
|
}
|
|
1176
1942
|
),
|
|
1177
|
-
!queue.items.length ? /* @__PURE__ */
|
|
1178
|
-
queue.items.map((item) => /* @__PURE__ */
|
|
1179
|
-
item.asset ? /* @__PURE__ */
|
|
1180
|
-
item.status === "failed" ? /* @__PURE__ */
|
|
1943
|
+
!queue.items.length ? /* @__PURE__ */ jsx22(StateBlock, { variant: "empty", title: "No assets selected", description: "Choose files to start the governed upload queue.", compact: true }) : null,
|
|
1944
|
+
queue.items.map((item) => /* @__PURE__ */ jsxs16(Stack8, { gap: "xs", children: [
|
|
1945
|
+
item.asset ? /* @__PURE__ */ jsx22(GdsAssetPreviewCard, { asset: { ...item.asset, displayMode } }) : /* @__PURE__ */ jsx22(StateBlock, { variant: item.status === "failed" ? "error" : "loading", title: item.fileName, description: item.error ?? `${item.status} ${item.progress}%`, compact: true }),
|
|
1946
|
+
item.status === "failed" ? /* @__PURE__ */ jsx22(Button7, { onClick: () => {
|
|
1181
1947
|
void queue.retry(item.id);
|
|
1182
1948
|
}, children: "Retry upload" }) : null,
|
|
1183
|
-
item.asset ? /* @__PURE__ */
|
|
1184
|
-
/* @__PURE__ */
|
|
1185
|
-
/* @__PURE__ */
|
|
1186
|
-
/* @__PURE__ */
|
|
1949
|
+
item.asset ? /* @__PURE__ */ jsxs16(Group11, { align: "end", children: [
|
|
1950
|
+
/* @__PURE__ */ jsx22(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 }) }),
|
|
1951
|
+
/* @__PURE__ */ jsx22(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 }) }),
|
|
1952
|
+
/* @__PURE__ */ jsx22(Button7, { variant: "light", color: "red", onClick: () => {
|
|
1187
1953
|
void queue.remove(item.id);
|
|
1188
1954
|
}, children: "Remove" })
|
|
1189
1955
|
] }) : null,
|
|
1190
|
-
item.status === "metadata-incomplete" ? /* @__PURE__ */
|
|
1956
|
+
item.status === "metadata-incomplete" ? /* @__PURE__ */ jsx22(Text13, { role: "alert", size: "sm", c: "red.7", children: "Metadata incomplete. Alt text or caption is required before publish." }) : null
|
|
1191
1957
|
] }, item.id))
|
|
1192
1958
|
] });
|
|
1193
1959
|
}
|
|
1194
1960
|
|
|
1195
1961
|
// src/AccessRecoveryPanel.tsx
|
|
1196
|
-
import { Group as
|
|
1197
|
-
import { useGdsTranslation as
|
|
1198
|
-
import { jsx as
|
|
1962
|
+
import { Group as Group12 } from "@mantine/core";
|
|
1963
|
+
import { useGdsTranslation as useGdsTranslation17 } from "@sovereignsquad/gds-theme";
|
|
1964
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
1199
1965
|
var stateBlockVariantByState = {
|
|
1200
1966
|
unauthenticated: "permission",
|
|
1201
1967
|
"expired-session": "info",
|
|
@@ -1275,7 +2041,7 @@ function ActionGroup({
|
|
|
1275
2041
|
if (actions.length === 0) {
|
|
1276
2042
|
return null;
|
|
1277
2043
|
}
|
|
1278
|
-
return /* @__PURE__ */
|
|
2044
|
+
return /* @__PURE__ */ jsx23(Group12, { gap: "sm", justify: "center", wrap: "wrap", children: actions.map((actionConfig, index) => /* @__PURE__ */ jsx23(
|
|
1279
2045
|
SemanticButton,
|
|
1280
2046
|
{
|
|
1281
2047
|
action: actionConfig.action,
|
|
@@ -1301,7 +2067,7 @@ function AccessRecoveryPanel({
|
|
|
1301
2067
|
supportAction,
|
|
1302
2068
|
compact = false
|
|
1303
2069
|
}) {
|
|
1304
|
-
const { t } =
|
|
2070
|
+
const { t } = useGdsTranslation17();
|
|
1305
2071
|
const defaultCopy = defaultCopyByState[state];
|
|
1306
2072
|
const defaults = defaultActionsForState(state, {
|
|
1307
2073
|
onRetry,
|
|
@@ -1309,14 +2075,14 @@ function AccessRecoveryPanel({
|
|
|
1309
2075
|
onBack,
|
|
1310
2076
|
supportAction
|
|
1311
2077
|
});
|
|
1312
|
-
return /* @__PURE__ */
|
|
2078
|
+
return /* @__PURE__ */ jsx23(
|
|
1313
2079
|
StateBlock,
|
|
1314
2080
|
{
|
|
1315
2081
|
variant: stateBlockVariantByState[state],
|
|
1316
2082
|
compact,
|
|
1317
2083
|
title: title ?? t(`gds.accessRecovery.${state}.title`, defaultCopy.title),
|
|
1318
2084
|
description: description ?? t(`gds.accessRecovery.${state}.description`, defaultCopy.description),
|
|
1319
|
-
action: /* @__PURE__ */
|
|
2085
|
+
action: /* @__PURE__ */ jsx23(
|
|
1320
2086
|
ActionGroup,
|
|
1321
2087
|
{
|
|
1322
2088
|
primaryAction: primaryAction ?? defaults.primary,
|
|
@@ -1329,10 +2095,10 @@ function AccessRecoveryPanel({
|
|
|
1329
2095
|
}
|
|
1330
2096
|
|
|
1331
2097
|
// src/GdsAccessGate.tsx
|
|
1332
|
-
import { useEffect as
|
|
1333
|
-
import { Badge as Badge2, Box as
|
|
1334
|
-
import { gdsDevWarnOnce, useGdsTranslation as
|
|
1335
|
-
import { jsx as
|
|
2098
|
+
import { useEffect as useEffect4, useId } from "react";
|
|
2099
|
+
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";
|
|
2100
|
+
import { gdsDevWarnOnce as gdsDevWarnOnce2, useGdsTranslation as useGdsTranslation18 } from "@sovereignsquad/gds-theme";
|
|
2101
|
+
import { jsx as jsx24, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1336
2102
|
var defaultReasonByState = {
|
|
1337
2103
|
locked: "login-required",
|
|
1338
2104
|
"permission-denied": "role-required",
|
|
@@ -1405,7 +2171,7 @@ function GdsAccessGate({
|
|
|
1405
2171
|
onAction,
|
|
1406
2172
|
onEvent
|
|
1407
2173
|
}) {
|
|
1408
|
-
const { t } =
|
|
2174
|
+
const { t } = useGdsTranslation18();
|
|
1409
2175
|
const teaserLabel = teaserLabelProp ?? t("gds.gdsAccessGate.teaserLabel", "Preview");
|
|
1410
2176
|
const headingId = useId();
|
|
1411
2177
|
const sortedActions = sortGdsAccessGateActions(actions);
|
|
@@ -1424,13 +2190,13 @@ function GdsAccessGate({
|
|
|
1424
2190
|
protectedContentPolicy
|
|
1425
2191
|
});
|
|
1426
2192
|
if (validation.length > 0) {
|
|
1427
|
-
|
|
2193
|
+
gdsDevWarnOnce2(
|
|
1428
2194
|
`GdsAccessGate:contract:${validation.join("|")}`,
|
|
1429
2195
|
`GdsAccessGate received an invalid contract: ${validation.join("; ")} Fix the state/reason/action combination \u2014 the gate may render an inconsistent state.`
|
|
1430
2196
|
);
|
|
1431
2197
|
}
|
|
1432
2198
|
const emit = (event) => onEvent?.(event);
|
|
1433
|
-
|
|
2199
|
+
useEffect4(() => {
|
|
1434
2200
|
if (validation.length > 0) {
|
|
1435
2201
|
onEvent?.(createGdsAccessGateEvent("gds.access_gate.error", { id, state: "error", reason: "unknown-error" }, { validationFailures: validation.length }));
|
|
1436
2202
|
return;
|
|
@@ -1442,7 +2208,7 @@ function GdsAccessGate({
|
|
|
1442
2208
|
void action.onClick?.();
|
|
1443
2209
|
void onAction?.(action);
|
|
1444
2210
|
};
|
|
1445
|
-
return /* @__PURE__ */
|
|
2211
|
+
return /* @__PURE__ */ jsx24(
|
|
1446
2212
|
Card,
|
|
1447
2213
|
{
|
|
1448
2214
|
component: "section",
|
|
@@ -1452,17 +2218,17 @@ function GdsAccessGate({
|
|
|
1452
2218
|
p: "lg",
|
|
1453
2219
|
"data-gds-access-gate": id,
|
|
1454
2220
|
"data-gds-access-state": state,
|
|
1455
|
-
children: /* @__PURE__ */
|
|
1456
|
-
/* @__PURE__ */
|
|
1457
|
-
/* @__PURE__ */
|
|
1458
|
-
/* @__PURE__ */
|
|
1459
|
-
/* @__PURE__ */
|
|
1460
|
-
/* @__PURE__ */
|
|
2221
|
+
children: /* @__PURE__ */ jsxs17(Stack9, { gap: "lg", children: [
|
|
2222
|
+
/* @__PURE__ */ jsxs17(Group13, { justify: "space-between", gap: "md", align: "flex-start", wrap: "wrap", children: [
|
|
2223
|
+
/* @__PURE__ */ jsxs17(Stack9, { gap: 4, children: [
|
|
2224
|
+
/* @__PURE__ */ jsx24(Badge2, { variant: "light", children: teaserLabel }),
|
|
2225
|
+
/* @__PURE__ */ jsx24(Title, { id: headingId, order: 3, children: title }),
|
|
2226
|
+
/* @__PURE__ */ jsx24(Text14, { c: "dimmed", children: description })
|
|
1461
2227
|
] }),
|
|
1462
|
-
entitlementLabel ? /* @__PURE__ */
|
|
2228
|
+
entitlementLabel ? /* @__PURE__ */ jsx24(Badge2, { variant: unlocked ? "filled" : "outline", children: entitlementLabel }) : null
|
|
1463
2229
|
] }),
|
|
1464
|
-
/* @__PURE__ */
|
|
1465
|
-
loading ? /* @__PURE__ */
|
|
2230
|
+
/* @__PURE__ */ jsx24(Box9, { "data-gds-access-preview": true, children: preview }),
|
|
2231
|
+
loading ? /* @__PURE__ */ jsx24(
|
|
1466
2232
|
StateBlock,
|
|
1467
2233
|
{
|
|
1468
2234
|
variant: "loading",
|
|
@@ -1471,11 +2237,11 @@ function GdsAccessGate({
|
|
|
1471
2237
|
compact: true
|
|
1472
2238
|
}
|
|
1473
2239
|
) : null,
|
|
1474
|
-
unlocked ? /* @__PURE__ */
|
|
1475
|
-
!unlocked && softGate && !loading ? /* @__PURE__ */
|
|
1476
|
-
!unlocked && !loading ? /* @__PURE__ */
|
|
1477
|
-
/* @__PURE__ */
|
|
1478
|
-
/* @__PURE__ */
|
|
2240
|
+
unlocked ? /* @__PURE__ */ jsx24(Box9, { "data-gds-access-protected": true, children: renderProtectedContent(protectedContent) }) : null,
|
|
2241
|
+
!unlocked && softGate && !loading ? /* @__PURE__ */ jsx24(Box9, { "data-gds-access-degraded": true, "aria-hidden": !unlocked, inert: !unlocked || void 0, children: renderProtectedContent(protectedContent) }) : null,
|
|
2242
|
+
!unlocked && !loading ? /* @__PURE__ */ jsxs17(Stack9, { gap: "md", "data-gds-access-locked": true, children: [
|
|
2243
|
+
/* @__PURE__ */ jsx24(Box9, { "aria-hidden": "true", children: lockedPlaceholder ?? /* @__PURE__ */ jsx24(Skeleton, { height: 96, radius: "lg" }) }),
|
|
2244
|
+
/* @__PURE__ */ jsx24(
|
|
1479
2245
|
AccessRecoveryPanel,
|
|
1480
2246
|
{
|
|
1481
2247
|
state: recoveryStateForGate(state, reason),
|
|
@@ -1504,8 +2270,8 @@ function GdsAccessGate({
|
|
|
1504
2270
|
} : null
|
|
1505
2271
|
}
|
|
1506
2272
|
),
|
|
1507
|
-
sortedActions.some((action) => action.label) ? /* @__PURE__ */
|
|
1508
|
-
|
|
2273
|
+
sortedActions.some((action) => action.label) ? /* @__PURE__ */ jsx24(Group13, { gap: "xs", wrap: "wrap", children: sortedActions.filter((action) => action.label).map((action) => /* @__PURE__ */ jsx24(
|
|
2274
|
+
Button8,
|
|
1509
2275
|
{
|
|
1510
2276
|
variant: "subtle",
|
|
1511
2277
|
size: "xs",
|
|
@@ -1524,8 +2290,8 @@ function GdsAccessGate({
|
|
|
1524
2290
|
|
|
1525
2291
|
// src/GdsDateInput.client.tsx
|
|
1526
2292
|
import { DateInput, DatePickerInput, DateTimePicker } from "@mantine/dates";
|
|
1527
|
-
import { gdsDevWarnOnce as
|
|
1528
|
-
import { jsx as
|
|
2293
|
+
import { gdsDevWarnOnce as gdsDevWarnOnce3 } from "@sovereignsquad/gds-theme";
|
|
2294
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
1529
2295
|
function resolveDateValue(value) {
|
|
1530
2296
|
if (value instanceof Date) return value;
|
|
1531
2297
|
if (typeof value === "string" && value.length > 0) return new Date(value);
|
|
@@ -1543,7 +2309,7 @@ function warnOnDateBounds(component, minDate, maxDate, values) {
|
|
|
1543
2309
|
const min = resolveBoundDate(minDate);
|
|
1544
2310
|
const max = resolveBoundDate(maxDate);
|
|
1545
2311
|
if (min && max && !Number.isNaN(min.getTime()) && !Number.isNaN(max.getTime()) && min.getTime() > max.getTime()) {
|
|
1546
|
-
|
|
2312
|
+
gdsDevWarnOnce3(
|
|
1547
2313
|
`${component}:min-after-max`,
|
|
1548
2314
|
`${component}: minDate (${isoDay(min)}) is after maxDate (${isoDay(max)}), so no date is selectable. Swap the two bounds.`
|
|
1549
2315
|
);
|
|
@@ -1551,13 +2317,13 @@ function warnOnDateBounds(component, minDate, maxDate, values) {
|
|
|
1551
2317
|
for (const value of values) {
|
|
1552
2318
|
if (!value || Number.isNaN(value.getTime())) continue;
|
|
1553
2319
|
if (min && !Number.isNaN(min.getTime()) && value.getTime() < min.getTime()) {
|
|
1554
|
-
|
|
2320
|
+
gdsDevWarnOnce3(
|
|
1555
2321
|
`${component}:value-before-min`,
|
|
1556
2322
|
`${component}: value (${isoDay(value)}) is before minDate (${isoDay(min)}); it will not be selectable through the calendar.`
|
|
1557
2323
|
);
|
|
1558
2324
|
}
|
|
1559
2325
|
if (max && !Number.isNaN(max.getTime()) && value.getTime() > max.getTime()) {
|
|
1560
|
-
|
|
2326
|
+
gdsDevWarnOnce3(
|
|
1561
2327
|
`${component}:value-after-max`,
|
|
1562
2328
|
`${component}: value (${isoDay(value)}) is after maxDate (${isoDay(max)}); it will not be selectable through the calendar.`
|
|
1563
2329
|
);
|
|
@@ -1566,7 +2332,7 @@ function warnOnDateBounds(component, minDate, maxDate, values) {
|
|
|
1566
2332
|
}
|
|
1567
2333
|
function GdsDateInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
1568
2334
|
warnOnDateBounds("GdsDateInput", minDate, maxDate, [resolveDateValue(value)]);
|
|
1569
|
-
return /* @__PURE__ */
|
|
2335
|
+
return /* @__PURE__ */ jsx25(
|
|
1570
2336
|
DateInput,
|
|
1571
2337
|
{
|
|
1572
2338
|
value: resolveDateValue(value),
|
|
@@ -1580,7 +2346,7 @@ function GdsDateInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
|
1580
2346
|
}
|
|
1581
2347
|
function GdsDateTimeInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
1582
2348
|
warnOnDateBounds("GdsDateTimeInput", minDate, maxDate, [resolveDateValue(value)]);
|
|
1583
|
-
return /* @__PURE__ */
|
|
2349
|
+
return /* @__PURE__ */ jsx25(
|
|
1584
2350
|
DateTimePicker,
|
|
1585
2351
|
{
|
|
1586
2352
|
value: resolveDateValue(value),
|
|
@@ -1594,7 +2360,7 @@ function GdsDateTimeInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
|
1594
2360
|
}
|
|
1595
2361
|
function GdsDateRangeInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
1596
2362
|
warnOnDateBounds("GdsDateRangeInput", minDate, maxDate, value ?? [null, null]);
|
|
1597
|
-
return /* @__PURE__ */
|
|
2363
|
+
return /* @__PURE__ */ jsx25(
|
|
1598
2364
|
DatePickerInput,
|
|
1599
2365
|
{
|
|
1600
2366
|
type: "range",
|
|
@@ -1609,10 +2375,10 @@ function GdsDateRangeInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
|
1609
2375
|
}
|
|
1610
2376
|
|
|
1611
2377
|
// 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
|
|
2378
|
+
import { useGdsTranslation as useGdsTranslation19 } from "@sovereignsquad/gds-theme";
|
|
2379
|
+
import { createContext as createContext3, useCallback as useCallback5, useContext as useContext3, useMemo as useMemo4, useReducer as useReducer2, useRef as useRef5, useState as useState11 } from "react";
|
|
2380
|
+
import { Alert, Anchor, Stack as Stack10, Text as Text15 } from "@mantine/core";
|
|
2381
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
1616
2382
|
function createFieldState(value) {
|
|
1617
2383
|
return { value, touched: false, dirty: false };
|
|
1618
2384
|
}
|
|
@@ -1727,7 +2493,7 @@ function useGdsForm({
|
|
|
1727
2493
|
return false;
|
|
1728
2494
|
}
|
|
1729
2495
|
};
|
|
1730
|
-
return
|
|
2496
|
+
return useMemo4(
|
|
1731
2497
|
() => ({
|
|
1732
2498
|
snapshot,
|
|
1733
2499
|
setFieldValue: (field, value) => dispatch({ type: "set-field", field, value }),
|
|
@@ -1750,13 +2516,13 @@ function useGdsFormOrchestration({
|
|
|
1750
2516
|
onEvent
|
|
1751
2517
|
}) {
|
|
1752
2518
|
const [snapshot, dispatch] = useReducer2(gdsFormReducer, initialValues, createSnapshot);
|
|
1753
|
-
const submitAttempt =
|
|
1754
|
-
const [lastSubmitFailed, setLastSubmitFailed] =
|
|
1755
|
-
const setFieldValue =
|
|
2519
|
+
const submitAttempt = useRef5(0);
|
|
2520
|
+
const [lastSubmitFailed, setLastSubmitFailed] = useState11(false);
|
|
2521
|
+
const setFieldValue = useCallback5((field, value) => {
|
|
1756
2522
|
dispatch({ type: "set-field", field, value });
|
|
1757
2523
|
emitFormEvent(onEvent, "dirty_changed", "idle");
|
|
1758
2524
|
}, [onEvent]);
|
|
1759
|
-
const validateSnapshot =
|
|
2525
|
+
const validateSnapshot = useCallback5(async () => {
|
|
1760
2526
|
dispatch({ type: "set-submit-state", submitState: "validating" });
|
|
1761
2527
|
const syncIssues = sortIssues(validate ? validate(snapshot) : []);
|
|
1762
2528
|
const asyncIssues = syncIssues.some((issue) => issue.severity === "blocking") || !validateAsync ? [] : sortIssues(await validateAsync(snapshot));
|
|
@@ -1769,7 +2535,7 @@ function useGdsFormOrchestration({
|
|
|
1769
2535
|
}
|
|
1770
2536
|
return true;
|
|
1771
2537
|
}, [onEvent, snapshot, validate, validateAsync]);
|
|
1772
|
-
const autosaveDraft =
|
|
2538
|
+
const autosaveDraft = useCallback5(async () => {
|
|
1773
2539
|
if (!draftAdapter) return false;
|
|
1774
2540
|
dispatch({ type: "set-submit-state", submitState: "autosaving" });
|
|
1775
2541
|
await draftAdapter.save(snapshotValues(snapshot));
|
|
@@ -1777,7 +2543,7 @@ function useGdsFormOrchestration({
|
|
|
1777
2543
|
emitFormEvent(onEvent, "autosave_succeeded", "saved");
|
|
1778
2544
|
return true;
|
|
1779
2545
|
}, [draftAdapter, onEvent, snapshot]);
|
|
1780
|
-
const submit =
|
|
2546
|
+
const submit = useCallback5(async () => {
|
|
1781
2547
|
const attempt = submitAttempt.current + 1;
|
|
1782
2548
|
submitAttempt.current = attempt;
|
|
1783
2549
|
const valid = await validateSnapshot();
|
|
@@ -1813,7 +2579,7 @@ function useGdsFormOrchestration({
|
|
|
1813
2579
|
return false;
|
|
1814
2580
|
}
|
|
1815
2581
|
}, [autosave, autosaveDraft, draftAdapter, lastSubmitFailed, mapServerErrors, onEvent, onSubmit, optimisticSubmit, snapshot, validateSnapshot]);
|
|
1816
|
-
const restoreDraft =
|
|
2582
|
+
const restoreDraft = useCallback5(async () => {
|
|
1817
2583
|
const draft = await draftAdapter?.load();
|
|
1818
2584
|
if (!draft) return false;
|
|
1819
2585
|
dispatch({ type: "reset", values: draft });
|
|
@@ -1821,10 +2587,10 @@ function useGdsFormOrchestration({
|
|
|
1821
2587
|
emitFormEvent(onEvent, "draft_restored", "restored");
|
|
1822
2588
|
return true;
|
|
1823
2589
|
}, [draftAdapter, onEvent]);
|
|
1824
|
-
const discardDraft =
|
|
2590
|
+
const discardDraft = useCallback5(async () => {
|
|
1825
2591
|
await draftAdapter?.clear();
|
|
1826
2592
|
}, [draftAdapter]);
|
|
1827
|
-
return
|
|
2593
|
+
return useMemo4(
|
|
1828
2594
|
() => ({
|
|
1829
2595
|
snapshot,
|
|
1830
2596
|
setFieldValue,
|
|
@@ -1840,7 +2606,7 @@ function useGdsFormOrchestration({
|
|
|
1840
2606
|
}
|
|
1841
2607
|
var GdsFormContext = createContext3(null);
|
|
1842
2608
|
function GdsFormProvider({ snapshot, children }) {
|
|
1843
|
-
return /* @__PURE__ */
|
|
2609
|
+
return /* @__PURE__ */ jsx26(GdsFormContext.Provider, { value: { snapshot }, children });
|
|
1844
2610
|
}
|
|
1845
2611
|
function useGdsFormSnapshot() {
|
|
1846
2612
|
const context = useContext3(GdsFormContext);
|
|
@@ -1850,14 +2616,14 @@ function useGdsFormSnapshot() {
|
|
|
1850
2616
|
return context.snapshot;
|
|
1851
2617
|
}
|
|
1852
2618
|
function FormErrorSummary({ title: titleProp }) {
|
|
1853
|
-
const { t } =
|
|
2619
|
+
const { t } = useGdsTranslation19();
|
|
1854
2620
|
const title = titleProp ?? t("gds.gdsForm.title", "Please review the following issues.");
|
|
1855
2621
|
const snapshot = useGdsFormSnapshot();
|
|
1856
2622
|
const blocking = snapshot.issues.filter((issue) => issue.severity === "blocking");
|
|
1857
2623
|
if (blocking.length === 0) {
|
|
1858
2624
|
return null;
|
|
1859
2625
|
}
|
|
1860
|
-
return /* @__PURE__ */
|
|
2626
|
+
return /* @__PURE__ */ jsx26(Alert, { color: "red", title, children: /* @__PURE__ */ jsx26(Stack10, { gap: 4, children: blocking.map((issue) => /* @__PURE__ */ jsx26(Anchor, { href: `#${issue.field}`, children: issue.message }, `${issue.field}-${issue.message}`)) }) });
|
|
1861
2627
|
}
|
|
1862
2628
|
var GdsValidationSummary = FormErrorSummary;
|
|
1863
2629
|
function ValidatedFieldMessage({ field }) {
|
|
@@ -1866,14 +2632,14 @@ function ValidatedFieldMessage({ field }) {
|
|
|
1866
2632
|
if (!issue) {
|
|
1867
2633
|
return null;
|
|
1868
2634
|
}
|
|
1869
|
-
return /* @__PURE__ */
|
|
2635
|
+
return /* @__PURE__ */ jsx26(Text15, { size: "xs", c: "red.7", id: `${field}-error`, children: issue.message });
|
|
1870
2636
|
}
|
|
1871
2637
|
|
|
1872
2638
|
// src/GdsSchemaForm.client.tsx
|
|
1873
|
-
import { useCallback as
|
|
1874
|
-
import { Button as
|
|
1875
|
-
import { useGdsTranslation as
|
|
1876
|
-
import { jsx as
|
|
2639
|
+
import { useCallback as useCallback6, useEffect as useEffect5, useMemo as useMemo5, useRef as useRef6, useState as useState12 } from "react";
|
|
2640
|
+
import { Button as Button9, Checkbox, Group as Group14, Paper as Paper6, Stack as Stack11, Text as Text16, Title as Title2 } from "@mantine/core";
|
|
2641
|
+
import { useGdsTranslation as useGdsTranslation20 } from "@sovereignsquad/gds-theme";
|
|
2642
|
+
import { jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1877
2643
|
function toIsoDateString(date) {
|
|
1878
2644
|
const year = date.getFullYear();
|
|
1879
2645
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
@@ -2127,23 +2893,23 @@ function FileUploadField({
|
|
|
2127
2893
|
onUploadEvent,
|
|
2128
2894
|
onChange
|
|
2129
2895
|
}) {
|
|
2130
|
-
const abortRef =
|
|
2131
|
-
const lastFilesRef =
|
|
2132
|
-
const [adapterState, setAdapterState] =
|
|
2133
|
-
const [adapterProgress, setAdapterProgress] =
|
|
2134
|
-
const [adapterError, setAdapterError] =
|
|
2896
|
+
const abortRef = useRef6(null);
|
|
2897
|
+
const lastFilesRef = useRef6([]);
|
|
2898
|
+
const [adapterState, setAdapterState] = useState12();
|
|
2899
|
+
const [adapterProgress, setAdapterProgress] = useState12();
|
|
2900
|
+
const [adapterError, setAdapterError] = useState12();
|
|
2135
2901
|
const selectedFiles = getUploadFileNames(value);
|
|
2136
2902
|
const oversize = Array.isArray(value) && maxFileSizeBytes ? value.some((file) => isFileValue(file) && file.size > maxFileSizeBytes) : false;
|
|
2137
2903
|
const effectiveState = adapterState ?? state ?? (oversize ? "too-large" : selectedFiles.length > 0 ? "selected" : "idle");
|
|
2138
2904
|
const effectivePolicyText = oversize ? `One or more files exceed ${maxFileSizeLabel ?? `${maxFileSizeBytes} bytes`}.` : policyText;
|
|
2139
2905
|
const effectiveProgressValue = adapterProgress ?? progressValue;
|
|
2140
|
-
const emitUploadEvent =
|
|
2906
|
+
const emitUploadEvent = useCallback6((type, message) => {
|
|
2141
2907
|
onUploadEvent?.(createSchemaEvent(type, message, field?.name ?? id));
|
|
2142
2908
|
}, [field?.name, id, onUploadEvent]);
|
|
2143
|
-
|
|
2909
|
+
useEffect5(() => () => {
|
|
2144
2910
|
abortRef.current?.abort();
|
|
2145
2911
|
}, []);
|
|
2146
|
-
const uploadFiles =
|
|
2912
|
+
const uploadFiles = useCallback6((files) => {
|
|
2147
2913
|
const selectedOversize = Boolean(maxFileSizeBytes && files.some((file) => file.size > maxFileSizeBytes));
|
|
2148
2914
|
if (!uploadAdapter || !field || selectedOversize) {
|
|
2149
2915
|
onChange?.(files);
|
|
@@ -2235,7 +3001,7 @@ function FileUploadField({
|
|
|
2235
3001
|
emitUploadEvent("upload_failed", error instanceof Error ? error.message : void 0);
|
|
2236
3002
|
});
|
|
2237
3003
|
};
|
|
2238
|
-
return /* @__PURE__ */
|
|
3004
|
+
return /* @__PURE__ */ jsx27(Stack11, { gap: 4, children: /* @__PURE__ */ jsx27(
|
|
2239
3005
|
UploadDropzone,
|
|
2240
3006
|
{
|
|
2241
3007
|
title: label,
|
|
@@ -2254,8 +3020,8 @@ function FileUploadField({
|
|
|
2254
3020
|
progressValue: effectiveProgressValue,
|
|
2255
3021
|
error: adapterError,
|
|
2256
3022
|
mode: "inline",
|
|
2257
|
-
retryAction: effectiveState === "upload-failed" && uploadAdapter ? /* @__PURE__ */
|
|
2258
|
-
removeAction: effectiveState === "upload-pending" && uploadAdapter ? /* @__PURE__ */
|
|
3023
|
+
retryAction: effectiveState === "upload-failed" && uploadAdapter ? /* @__PURE__ */ jsx27(Button9, { size: "xs", variant: "light", onClick: retryUpload, children: "Retry upload" }) : void 0,
|
|
3024
|
+
removeAction: effectiveState === "upload-pending" && uploadAdapter ? /* @__PURE__ */ jsx27(Button9, { size: "xs", variant: "subtle", onClick: cancelUpload, children: "Cancel upload" }) : selectedFiles.length > 0 ? /* @__PURE__ */ jsx27(Button9, { size: "xs", variant: "subtle", onClick: removeUpload, children: "Remove" }) : void 0,
|
|
2259
3025
|
onFilesSelected: handleFilesSelected
|
|
2260
3026
|
}
|
|
2261
3027
|
) });
|
|
@@ -2276,7 +3042,7 @@ function CheckboxGroupField({ field, value, setValue, describedBy, invalid }) {
|
|
|
2276
3042
|
const toggle = (optionValue, checked) => {
|
|
2277
3043
|
setValue(checked ? [...selected, optionValue] : selected.filter((entry) => entry !== optionValue));
|
|
2278
3044
|
};
|
|
2279
|
-
return /* @__PURE__ */
|
|
3045
|
+
return /* @__PURE__ */ jsxs18(
|
|
2280
3046
|
"fieldset",
|
|
2281
3047
|
{
|
|
2282
3048
|
"data-gds-checkbox-group": field.name,
|
|
@@ -2284,11 +3050,11 @@ function CheckboxGroupField({ field, value, setValue, describedBy, invalid }) {
|
|
|
2284
3050
|
"aria-invalid": invalid || void 0,
|
|
2285
3051
|
style: { border: 0, margin: 0, padding: 0, minInlineSize: "auto" },
|
|
2286
3052
|
children: [
|
|
2287
|
-
/* @__PURE__ */
|
|
2288
|
-
/* @__PURE__ */
|
|
3053
|
+
/* @__PURE__ */ jsx27("legend", { style: visuallyHidden, children: field.label }),
|
|
3054
|
+
/* @__PURE__ */ jsx27(Stack11, { gap: 6, children: (field.options ?? []).map((option) => (
|
|
2289
3055
|
// Mantine Checkbox (not a raw native input) so the control inherits the GDS
|
|
2290
3056
|
// theme styling and the governed forced-colors remap like every other control.
|
|
2291
|
-
/* @__PURE__ */
|
|
3057
|
+
/* @__PURE__ */ jsx27(
|
|
2292
3058
|
Checkbox,
|
|
2293
3059
|
{
|
|
2294
3060
|
value: option.value,
|
|
@@ -2305,7 +3071,7 @@ function CheckboxGroupField({ field, value, setValue, describedBy, invalid }) {
|
|
|
2305
3071
|
);
|
|
2306
3072
|
}
|
|
2307
3073
|
function RepeatableField({ field, value, setValue, describedBy, invalid, renderers, uploadAdapter, onEvent }) {
|
|
2308
|
-
const { t } =
|
|
3074
|
+
const { t } = useGdsTranslation20();
|
|
2309
3075
|
const rows = Array.isArray(value) ? value : [];
|
|
2310
3076
|
const subFields = field.fields ?? [];
|
|
2311
3077
|
const minRows = field.minRows ?? 0;
|
|
@@ -2314,11 +3080,11 @@ function RepeatableField({ field, value, setValue, describedBy, invalid, rendere
|
|
|
2314
3080
|
const addLabel = field.addRowLabel ?? t("gds.schemaForm.addRow", "Add row");
|
|
2315
3081
|
const removeLabel = field.removeRowLabel ?? t("gds.schemaForm.removeRow", "Remove");
|
|
2316
3082
|
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] =
|
|
2321
|
-
|
|
3083
|
+
const containerRef = useRef6(null);
|
|
3084
|
+
const addButtonRef = useRef6(null);
|
|
3085
|
+
const pendingFocus = useRef6(null);
|
|
3086
|
+
const [announcement, setAnnouncement] = useState12("");
|
|
3087
|
+
useEffect5(() => {
|
|
2322
3088
|
if (pendingFocus.current === "add") {
|
|
2323
3089
|
const lastRow = containerRef.current?.querySelector(`[data-gds-repeatable-row="${rows.length - 1}"]`);
|
|
2324
3090
|
lastRow?.querySelector("input, select, textarea, button")?.focus();
|
|
@@ -2342,12 +3108,12 @@ function RepeatableField({ field, value, setValue, describedBy, invalid, rendere
|
|
|
2342
3108
|
const setRowFieldValue = (index, name, next) => {
|
|
2343
3109
|
setValue(rows.map((row, rowIndex) => rowIndex === index ? { ...row, [name]: next } : row));
|
|
2344
3110
|
};
|
|
2345
|
-
return /* @__PURE__ */
|
|
2346
|
-
rows.map((row, index) => /* @__PURE__ */
|
|
2347
|
-
/* @__PURE__ */
|
|
2348
|
-
/* @__PURE__ */
|
|
2349
|
-
/* @__PURE__ */
|
|
2350
|
-
|
|
3111
|
+
return /* @__PURE__ */ jsxs18(Stack11, { gap: "sm", ref: containerRef, "data-gds-repeatable": field.name, "aria-describedby": describedBy, "aria-invalid": invalid || void 0, children: [
|
|
3112
|
+
rows.map((row, index) => /* @__PURE__ */ jsx27(Paper6, { withBorder: true, radius: "md", p: "sm", "data-gds-repeatable-row": index, children: /* @__PURE__ */ jsxs18(Stack11, { gap: "xs", children: [
|
|
3113
|
+
/* @__PURE__ */ jsxs18(Group14, { justify: "space-between", align: "center", wrap: "nowrap", children: [
|
|
3114
|
+
/* @__PURE__ */ jsx27(Text16, { size: "xs", fw: 600, c: "dimmed", children: `${field.label} ${index + 1}` }),
|
|
3115
|
+
/* @__PURE__ */ jsx27(
|
|
3116
|
+
Button9,
|
|
2351
3117
|
{
|
|
2352
3118
|
type: "button",
|
|
2353
3119
|
size: "xs",
|
|
@@ -2369,11 +3135,11 @@ function RepeatableField({ field, value, setValue, describedBy, invalid, rendere
|
|
|
2369
3135
|
invalid: false
|
|
2370
3136
|
};
|
|
2371
3137
|
const subRenderer = renderers[sub.name] ?? renderers[sub.type];
|
|
2372
|
-
return /* @__PURE__ */
|
|
3138
|
+
return /* @__PURE__ */ jsx27(FormField, { label: `${sub.label}${sub.required ? ` ${t("gds.schemaForm.requiredMarker", "(required)")}` : ""}`, children: subRenderer ? subRenderer(subContext) : renderDefaultField(subContext, { uploadAdapter, onEvent, renderers }) }, sub.name);
|
|
2373
3139
|
})
|
|
2374
3140
|
] }) }, index)),
|
|
2375
|
-
/* @__PURE__ */
|
|
2376
|
-
/* @__PURE__ */
|
|
3141
|
+
/* @__PURE__ */ jsx27(Group14, { children: /* @__PURE__ */ jsx27(Button9, { ref: addButtonRef, type: "button", size: "xs", variant: "light", disabled: !canAdd, onClick: addRow, children: addLabel }) }),
|
|
3142
|
+
/* @__PURE__ */ jsx27("div", { "aria-live": "polite", style: visuallyHidden, children: announcement })
|
|
2377
3143
|
] });
|
|
2378
3144
|
}
|
|
2379
3145
|
function renderDefaultField({ field, value, setValue, describedBy, invalid }, options = {}) {
|
|
@@ -2385,7 +3151,7 @@ function renderDefaultField({ field, value, setValue, describedBy, invalid }, op
|
|
|
2385
3151
|
required: field.required
|
|
2386
3152
|
};
|
|
2387
3153
|
if (field.type === "file-upload") {
|
|
2388
|
-
return /* @__PURE__ */
|
|
3154
|
+
return /* @__PURE__ */ jsx27(
|
|
2389
3155
|
FileUploadField,
|
|
2390
3156
|
{
|
|
2391
3157
|
...common,
|
|
@@ -2407,10 +3173,10 @@ function renderDefaultField({ field, value, setValue, describedBy, invalid }, op
|
|
|
2407
3173
|
);
|
|
2408
3174
|
}
|
|
2409
3175
|
if (field.type === "checkbox-group") {
|
|
2410
|
-
return /* @__PURE__ */
|
|
3176
|
+
return /* @__PURE__ */ jsx27(CheckboxGroupField, { field, value, setValue, describedBy, invalid });
|
|
2411
3177
|
}
|
|
2412
3178
|
if (field.type === "repeatable") {
|
|
2413
|
-
return /* @__PURE__ */
|
|
3179
|
+
return /* @__PURE__ */ jsx27(
|
|
2414
3180
|
RepeatableField,
|
|
2415
3181
|
{
|
|
2416
3182
|
field,
|
|
@@ -2425,17 +3191,17 @@ function renderDefaultField({ field, value, setValue, describedBy, invalid }, op
|
|
|
2425
3191
|
);
|
|
2426
3192
|
}
|
|
2427
3193
|
const textEntryStyle = { fontSize: "max(1rem, 1em)" };
|
|
2428
|
-
if (field.type === "boolean") return /* @__PURE__ */
|
|
2429
|
-
if (field.type === "number") return /* @__PURE__ */
|
|
3194
|
+
if (field.type === "boolean") return /* @__PURE__ */ jsx27("input", { ...common, type: "checkbox", checked: Boolean(value), onChange: (event) => setValue(event.currentTarget.checked) });
|
|
3195
|
+
if (field.type === "number") return /* @__PURE__ */ jsx27("input", { ...common, style: textEntryStyle, type: "number", value: String(value ?? ""), onChange: (event) => setValue(event.currentTarget.value === "" ? "" : Number(event.currentTarget.value)) });
|
|
2430
3196
|
if (field.type === "select") {
|
|
2431
|
-
return /* @__PURE__ */
|
|
2432
|
-
/* @__PURE__ */
|
|
2433
|
-
(field.options ?? []).map((option) => /* @__PURE__ */
|
|
3197
|
+
return /* @__PURE__ */ jsxs18("select", { ...common, style: textEntryStyle, value: String(value ?? ""), onChange: (event) => setValue(event.currentTarget.value), children: [
|
|
3198
|
+
/* @__PURE__ */ jsx27("option", { value: "", children: "Select..." }),
|
|
3199
|
+
(field.options ?? []).map((option) => /* @__PURE__ */ jsx27("option", { value: option.value, children: option.label }, option.value))
|
|
2434
3200
|
] });
|
|
2435
3201
|
}
|
|
2436
|
-
if (field.type === "textarea") return /* @__PURE__ */
|
|
3202
|
+
if (field.type === "textarea") return /* @__PURE__ */ jsx27("textarea", { ...common, style: textEntryStyle, value: String(value ?? ""), onChange: (event) => setValue(event.currentTarget.value) });
|
|
2437
3203
|
if (field.type === "date") {
|
|
2438
|
-
return /* @__PURE__ */
|
|
3204
|
+
return /* @__PURE__ */ jsx27(
|
|
2439
3205
|
GdsDateInput,
|
|
2440
3206
|
{
|
|
2441
3207
|
...common,
|
|
@@ -2444,7 +3210,7 @@ function renderDefaultField({ field, value, setValue, describedBy, invalid }, op
|
|
|
2444
3210
|
}
|
|
2445
3211
|
);
|
|
2446
3212
|
}
|
|
2447
|
-
return /* @__PURE__ */
|
|
3213
|
+
return /* @__PURE__ */ jsx27("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
3214
|
}
|
|
2449
3215
|
function GdsSchemaForm({
|
|
2450
3216
|
schema,
|
|
@@ -2454,9 +3220,9 @@ function GdsSchemaForm({
|
|
|
2454
3220
|
onEvent,
|
|
2455
3221
|
submitLabel: submitLabelProp
|
|
2456
3222
|
}) {
|
|
2457
|
-
const { t } =
|
|
3223
|
+
const { t } = useGdsTranslation20();
|
|
2458
3224
|
const submitLabel = submitLabelProp ?? t("gds.gdsSchemaForm.submitLabel", "Submit");
|
|
2459
|
-
const initialValues =
|
|
3225
|
+
const initialValues = useMemo5(() => getInitialValues(schema), [schema]);
|
|
2460
3226
|
const form = useGdsFormOrchestration({
|
|
2461
3227
|
initialValues,
|
|
2462
3228
|
validate: (snapshot) => validateSchemaValues(schema, Object.fromEntries(Object.entries(snapshot.fields).map(([name, field]) => [name, field.value])), renderers, { uploadAdapter, t }),
|
|
@@ -2470,15 +3236,15 @@ function GdsSchemaForm({
|
|
|
2470
3236
|
},
|
|
2471
3237
|
onEvent
|
|
2472
3238
|
});
|
|
2473
|
-
return /* @__PURE__ */
|
|
2474
|
-
schema.title ? /* @__PURE__ */
|
|
2475
|
-
schema.description ? /* @__PURE__ */
|
|
2476
|
-
/* @__PURE__ */
|
|
3239
|
+
return /* @__PURE__ */ jsx27(GdsFormProvider, { snapshot: form.snapshot, children: /* @__PURE__ */ jsxs18(Stack11, { gap: "md", children: [
|
|
3240
|
+
schema.title ? /* @__PURE__ */ jsx27(Title2, { order: 4, children: schema.title }) : null,
|
|
3241
|
+
schema.description ? /* @__PURE__ */ jsx27(Text16, { size: "sm", c: "dimmed", children: schema.description }) : null,
|
|
3242
|
+
/* @__PURE__ */ jsx27(GdsValidationSummary, {}),
|
|
2477
3243
|
schema.fields.map((field) => {
|
|
2478
3244
|
if (field.hidden || field.type === "hidden") return null;
|
|
2479
3245
|
const issue = form.snapshot.issues.find((item) => item.field === field.name && item.severity === "blocking");
|
|
2480
3246
|
if (field.type === "unsupported" && !renderers[field.name] && !renderers[field.type]) {
|
|
2481
|
-
return /* @__PURE__ */
|
|
3247
|
+
return /* @__PURE__ */ jsx27(StateBlock, { variant: "error", title: `Unsupported field: ${field.label}`, description: field.unsupportedReason ?? "Provide a renderer override for this field.", compact: true }, field.name);
|
|
2482
3248
|
}
|
|
2483
3249
|
const context = {
|
|
2484
3250
|
field,
|
|
@@ -2488,29 +3254,29 @@ function GdsSchemaForm({
|
|
|
2488
3254
|
invalid: Boolean(issue)
|
|
2489
3255
|
};
|
|
2490
3256
|
const renderer = renderers[field.name] ?? renderers[field.type];
|
|
2491
|
-
return /* @__PURE__ */
|
|
3257
|
+
return /* @__PURE__ */ jsxs18(
|
|
2492
3258
|
FormField,
|
|
2493
3259
|
{
|
|
2494
3260
|
label: `${field.label}${field.required ? ` ${t("gds.schemaForm.requiredMarker", "(required)")}` : ""}`,
|
|
2495
|
-
description: field.description ? /* @__PURE__ */
|
|
3261
|
+
description: field.description ? /* @__PURE__ */ jsx27(Text16, { id: `${field.name}-description`, size: "xs", c: "dimmed", children: field.description }) : void 0,
|
|
2496
3262
|
children: [
|
|
2497
3263
|
renderer ? renderer(context) : renderDefaultField(context, { uploadAdapter, onEvent, renderers }),
|
|
2498
|
-
/* @__PURE__ */
|
|
3264
|
+
/* @__PURE__ */ jsx27("span", { id: `${field.name}-error`, children: /* @__PURE__ */ jsx27(ValidatedFieldMessage, { field: field.name }) })
|
|
2499
3265
|
]
|
|
2500
3266
|
},
|
|
2501
3267
|
field.name
|
|
2502
3268
|
);
|
|
2503
3269
|
}),
|
|
2504
|
-
/* @__PURE__ */
|
|
3270
|
+
/* @__PURE__ */ jsx27(Button9, { type: "button", onClick: () => {
|
|
2505
3271
|
void form.submit();
|
|
2506
3272
|
}, loading: form.snapshot.submitState === "validating" || form.snapshot.submitState === "submitting" || form.snapshot.submitState === "optimistic", children: submitLabel })
|
|
2507
3273
|
] }) });
|
|
2508
3274
|
}
|
|
2509
3275
|
|
|
2510
3276
|
// src/AdvancedDataTable.client.tsx
|
|
2511
|
-
import { useMemo as
|
|
2512
|
-
import { Checkbox as Checkbox2, Group as
|
|
2513
|
-
import { jsx as
|
|
3277
|
+
import { useMemo as useMemo6, useState as useState13 } from "react";
|
|
3278
|
+
import { Checkbox as Checkbox2, Group as Group15, ScrollArea as ScrollArea2, SegmentedControl as SegmentedControl2, Stack as Stack12, Table as Table3, Text as Text17 } from "@mantine/core";
|
|
3279
|
+
import { jsx as jsx28, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2514
3280
|
function compareValues(a, b) {
|
|
2515
3281
|
if (typeof a === "number" && typeof b === "number") {
|
|
2516
3282
|
return a - b;
|
|
@@ -2533,14 +3299,14 @@ function AdvancedDataTable({
|
|
|
2533
3299
|
onSortChange,
|
|
2534
3300
|
responsiveFallback = "stacked-cards"
|
|
2535
3301
|
}) {
|
|
2536
|
-
const [densityState, setDensityState] =
|
|
2537
|
-
const [sortState, setSortState] =
|
|
2538
|
-
const [selectionState, setSelectionState] =
|
|
3302
|
+
const [densityState, setDensityState] = useState13(densityProp ?? "comfortable");
|
|
3303
|
+
const [sortState, setSortState] = useState13({ key: sortByProp ?? null, direction: sortDirectionProp ?? "asc" });
|
|
3304
|
+
const [selectionState, setSelectionState] = useState13([]);
|
|
2539
3305
|
const density = densityProp ?? densityState;
|
|
2540
3306
|
const sortBy = sortByProp ?? sortState.key;
|
|
2541
3307
|
const sortDirection = sortDirectionProp ?? sortState.direction;
|
|
2542
3308
|
const selection = selectedRowIds ?? selectionState;
|
|
2543
|
-
const sortedRows =
|
|
3309
|
+
const sortedRows = useMemo6(() => {
|
|
2544
3310
|
if (!sortBy) {
|
|
2545
3311
|
return rows;
|
|
2546
3312
|
}
|
|
@@ -2556,16 +3322,16 @@ function AdvancedDataTable({
|
|
|
2556
3322
|
});
|
|
2557
3323
|
return next;
|
|
2558
3324
|
}, [rows, columns, sortBy, sortDirection]);
|
|
2559
|
-
const allIds =
|
|
3325
|
+
const allIds = useMemo6(() => sortedRows.map((row, index) => rowId(row, index)), [sortedRows, rowId]);
|
|
2560
3326
|
const allSelected = allIds.length > 0 && allIds.every((id) => selection.includes(id));
|
|
2561
3327
|
if (error) {
|
|
2562
|
-
return /* @__PURE__ */
|
|
3328
|
+
return /* @__PURE__ */ jsx28(StateBlock, { variant: "error", title: "Unable to load table", description: error, compact: true });
|
|
2563
3329
|
}
|
|
2564
3330
|
if (loading) {
|
|
2565
|
-
return /* @__PURE__ */
|
|
3331
|
+
return /* @__PURE__ */ jsx28(StateBlock, { variant: "loading", title: "Loading table", description: "Preparing enterprise data grid.", compact: true });
|
|
2566
3332
|
}
|
|
2567
3333
|
if (!rows.length) {
|
|
2568
|
-
return /* @__PURE__ */
|
|
3334
|
+
return /* @__PURE__ */ jsx28(
|
|
2569
3335
|
StateBlock,
|
|
2570
3336
|
{
|
|
2571
3337
|
variant: "empty",
|
|
@@ -2575,16 +3341,16 @@ function AdvancedDataTable({
|
|
|
2575
3341
|
}
|
|
2576
3342
|
);
|
|
2577
3343
|
}
|
|
2578
|
-
const horizontalSpacing = density === "compact" ? "xs" : "
|
|
3344
|
+
const horizontalSpacing = density === "compact" ? "xs" : "sm";
|
|
2579
3345
|
const verticalSpacing = density === "compact" ? 6 : 10;
|
|
2580
|
-
return /* @__PURE__ */
|
|
2581
|
-
/* @__PURE__ */
|
|
2582
|
-
/* @__PURE__ */
|
|
3346
|
+
return /* @__PURE__ */ jsxs19(Stack12, { gap: "sm", children: [
|
|
3347
|
+
/* @__PURE__ */ jsxs19(Group15, { justify: "space-between", align: "center", children: [
|
|
3348
|
+
/* @__PURE__ */ jsxs19(Text17, { size: "sm", fw: 600, children: [
|
|
2583
3349
|
rows.length,
|
|
2584
3350
|
" rows"
|
|
2585
3351
|
] }),
|
|
2586
|
-
/* @__PURE__ */
|
|
2587
|
-
|
|
3352
|
+
/* @__PURE__ */ jsx28(
|
|
3353
|
+
SegmentedControl2,
|
|
2588
3354
|
{
|
|
2589
3355
|
size: "xs",
|
|
2590
3356
|
value: density,
|
|
@@ -2596,8 +3362,8 @@ function AdvancedDataTable({
|
|
|
2596
3362
|
}
|
|
2597
3363
|
)
|
|
2598
3364
|
] }),
|
|
2599
|
-
/* @__PURE__ */
|
|
2600
|
-
|
|
3365
|
+
/* @__PURE__ */ jsx28(ScrollArea2, { children: /* @__PURE__ */ jsxs19(
|
|
3366
|
+
Table3,
|
|
2601
3367
|
{
|
|
2602
3368
|
stickyHeader,
|
|
2603
3369
|
stickyHeaderOffset,
|
|
@@ -2607,8 +3373,8 @@ function AdvancedDataTable({
|
|
|
2607
3373
|
horizontalSpacing,
|
|
2608
3374
|
verticalSpacing,
|
|
2609
3375
|
children: [
|
|
2610
|
-
/* @__PURE__ */
|
|
2611
|
-
/* @__PURE__ */
|
|
3376
|
+
/* @__PURE__ */ jsx28(Table3.Thead, { children: /* @__PURE__ */ jsxs19(Table3.Tr, { children: [
|
|
3377
|
+
/* @__PURE__ */ jsx28(Table3.Th, { children: /* @__PURE__ */ jsx28(
|
|
2612
3378
|
Checkbox2,
|
|
2613
3379
|
{
|
|
2614
3380
|
className: "gds-touch-target-pad-checkbox",
|
|
@@ -2626,7 +3392,7 @@ function AdvancedDataTable({
|
|
|
2626
3392
|
}
|
|
2627
3393
|
}
|
|
2628
3394
|
) }),
|
|
2629
|
-
columns.map((column) => /* @__PURE__ */
|
|
3395
|
+
columns.map((column) => /* @__PURE__ */ jsx28(Table3.Th, { style: column.width ? { width: column.width } : void 0, children: column.sortable ? /* @__PURE__ */ jsx28(
|
|
2630
3396
|
"button",
|
|
2631
3397
|
{
|
|
2632
3398
|
type: "button",
|
|
@@ -2643,11 +3409,11 @@ function AdvancedDataTable({
|
|
|
2643
3409
|
}
|
|
2644
3410
|
) : column.label }, column.key))
|
|
2645
3411
|
] }) }),
|
|
2646
|
-
/* @__PURE__ */
|
|
3412
|
+
/* @__PURE__ */ jsx28(Table3.Tbody, { children: sortedRows.map((row, index) => {
|
|
2647
3413
|
const id = rowId(row, index);
|
|
2648
3414
|
const checked = selection.includes(id);
|
|
2649
|
-
return /* @__PURE__ */
|
|
2650
|
-
/* @__PURE__ */
|
|
3415
|
+
return /* @__PURE__ */ jsxs19(Table3.Tr, { children: [
|
|
3416
|
+
/* @__PURE__ */ jsx28(Table3.Td, { children: /* @__PURE__ */ jsx28(
|
|
2651
3417
|
Checkbox2,
|
|
2652
3418
|
{
|
|
2653
3419
|
"aria-label": `Select row ${id}`,
|
|
@@ -2662,15 +3428,15 @@ function AdvancedDataTable({
|
|
|
2662
3428
|
}
|
|
2663
3429
|
}
|
|
2664
3430
|
) }),
|
|
2665
|
-
columns.map((column) => /* @__PURE__ */
|
|
3431
|
+
columns.map((column) => /* @__PURE__ */ jsx28(Table3.Td, { children: column.render ? column.render(row) : String(row[column.key] ?? "") }, column.key))
|
|
2666
3432
|
] }, id);
|
|
2667
3433
|
}) })
|
|
2668
3434
|
]
|
|
2669
3435
|
}
|
|
2670
3436
|
) }),
|
|
2671
|
-
responsiveFallback === "stacked-cards" ? /* @__PURE__ */
|
|
3437
|
+
responsiveFallback === "stacked-cards" ? /* @__PURE__ */ jsx28(Stack12, { gap: "xs", children: sortedRows.slice(0, 3).map((row, index) => {
|
|
2672
3438
|
const id = rowId(row, index);
|
|
2673
|
-
return /* @__PURE__ */
|
|
3439
|
+
return /* @__PURE__ */ jsx28(
|
|
2674
3440
|
StateBlock,
|
|
2675
3441
|
{
|
|
2676
3442
|
variant: "info",
|
|
@@ -2685,10 +3451,10 @@ function AdvancedDataTable({
|
|
|
2685
3451
|
}
|
|
2686
3452
|
|
|
2687
3453
|
// src/GdsDataTable.client.tsx
|
|
2688
|
-
import { useGdsTranslation as
|
|
2689
|
-
import { useCallback as
|
|
2690
|
-
import { Button as
|
|
2691
|
-
import { jsx as
|
|
3454
|
+
import { useGdsTranslation as useGdsTranslation21 } from "@sovereignsquad/gds-theme";
|
|
3455
|
+
import { useCallback as useCallback7, useEffect as useEffect6, useMemo as useMemo7, useRef as useRef7, useState as useState14 } from "react";
|
|
3456
|
+
import { Button as Button10, Checkbox as Checkbox3, Group as Group16, Pagination, ScrollArea as ScrollArea3, Stack as Stack13, Table as Table4, Text as Text18, TextInput as TextInput2, VisuallyHidden as VisuallyHidden5 } from "@mantine/core";
|
|
3457
|
+
import { jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2692
3458
|
function emitTableEvent(onEvent, type, message) {
|
|
2693
3459
|
onEvent?.({ type, message, timestamp: Date.now(), privacy: "metadata-only" });
|
|
2694
3460
|
}
|
|
@@ -2751,14 +3517,14 @@ function useGdsDataTable({
|
|
|
2751
3517
|
timeoutMs = 8e3,
|
|
2752
3518
|
virtualizedRowLimit
|
|
2753
3519
|
}) {
|
|
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] =
|
|
2761
|
-
|
|
3520
|
+
const [query, setQuery] = useState14(() => createDefaultQuery(initialQuery));
|
|
3521
|
+
const [rows, setRows] = useState14([]);
|
|
3522
|
+
const [total, setTotal] = useState14(0);
|
|
3523
|
+
const [status, setStatus] = useState14("idle");
|
|
3524
|
+
const [error, setError] = useState14();
|
|
3525
|
+
const [selectedRowIds, setSelectedRowIds] = useState14([]);
|
|
3526
|
+
const [reloadKey, setReloadKey] = useState14(0);
|
|
3527
|
+
useEffect6(() => {
|
|
2762
3528
|
const controller = new AbortController();
|
|
2763
3529
|
const timer = window.setTimeout(() => controller.abort(), timeoutMs);
|
|
2764
3530
|
setStatus((current) => current === "ready" || current === "partial" ? "refreshing" : "loading");
|
|
@@ -2784,12 +3550,12 @@ function useGdsDataTable({
|
|
|
2784
3550
|
window.clearTimeout(timer);
|
|
2785
3551
|
};
|
|
2786
3552
|
}, [adapter, onEvent, query, reloadKey, rowId, timeoutMs]);
|
|
2787
|
-
const setSearch =
|
|
3553
|
+
const setSearch = useCallback7((value) => {
|
|
2788
3554
|
setQuery((current) => ({ ...current, search: value, page: 1 }));
|
|
2789
3555
|
setSelectedRowIds([]);
|
|
2790
3556
|
emitTableEvent(onEvent, "filter_changed");
|
|
2791
3557
|
}, [onEvent]);
|
|
2792
|
-
const setSort =
|
|
3558
|
+
const setSort = useCallback7((columnKey) => {
|
|
2793
3559
|
setQuery((current) => ({
|
|
2794
3560
|
...current,
|
|
2795
3561
|
sortBy: columnKey,
|
|
@@ -2799,23 +3565,23 @@ function useGdsDataTable({
|
|
|
2799
3565
|
setSelectedRowIds([]);
|
|
2800
3566
|
emitTableEvent(onEvent, "sort_changed");
|
|
2801
3567
|
}, [onEvent]);
|
|
2802
|
-
const setPage =
|
|
2803
|
-
const setPageSize =
|
|
2804
|
-
const setFilter =
|
|
3568
|
+
const setPage = useCallback7((page) => setQuery((current) => ({ ...current, page: Math.max(1, Math.floor(page)) })), []);
|
|
3569
|
+
const setPageSize = useCallback7((pageSize) => setQuery((current) => ({ ...current, page: 1, pageSize: Math.max(1, Math.floor(pageSize)) })), []);
|
|
3570
|
+
const setFilter = useCallback7((columnKey, value) => {
|
|
2805
3571
|
setQuery((current) => ({ ...current, filters: { ...current.filters, [columnKey]: value }, page: 1 }));
|
|
2806
3572
|
setSelectedRowIds([]);
|
|
2807
3573
|
emitTableEvent(onEvent, "filter_changed");
|
|
2808
3574
|
}, [onEvent]);
|
|
2809
|
-
const visibleRows =
|
|
2810
|
-
const visibleIds =
|
|
2811
|
-
const toggleRow =
|
|
3575
|
+
const visibleRows = useMemo7(() => rows.slice(0, virtualizedRowLimit ?? rows.length), [rows, virtualizedRowLimit]);
|
|
3576
|
+
const visibleIds = useMemo7(() => visibleRows.map((row, index) => rowId(row, index)), [rowId, visibleRows]);
|
|
3577
|
+
const toggleRow = useCallback7((id) => {
|
|
2812
3578
|
setSelectedRowIds((current) => {
|
|
2813
3579
|
const next = current.includes(id) ? current.filter((item) => item !== id) : [...current, id];
|
|
2814
3580
|
emitTableEvent(onEvent, "selection_changed");
|
|
2815
3581
|
return next;
|
|
2816
3582
|
});
|
|
2817
3583
|
}, [onEvent]);
|
|
2818
|
-
const toggleAllVisible =
|
|
3584
|
+
const toggleAllVisible = useCallback7(() => {
|
|
2819
3585
|
setSelectedRowIds((current) => {
|
|
2820
3586
|
const allSelected = visibleIds.length > 0 && visibleIds.every((id) => current.includes(id));
|
|
2821
3587
|
const next = allSelected ? current.filter((id) => !visibleIds.includes(id)) : [.../* @__PURE__ */ new Set([...current, ...visibleIds])];
|
|
@@ -2823,7 +3589,7 @@ function useGdsDataTable({
|
|
|
2823
3589
|
return next;
|
|
2824
3590
|
});
|
|
2825
3591
|
}, [onEvent, visibleIds]);
|
|
2826
|
-
const exportRows =
|
|
3592
|
+
const exportRows = useCallback7(async () => {
|
|
2827
3593
|
setStatus("exporting");
|
|
2828
3594
|
emitTableEvent(onEvent, "export_requested");
|
|
2829
3595
|
await onExport?.({ query, rows, selectedRowIds });
|
|
@@ -2862,9 +3628,9 @@ function getInteractiveCellElements(cell) {
|
|
|
2862
3628
|
return Array.from(cell.querySelectorAll(interactiveCellSelector)).filter((element) => !element.hasAttribute("hidden") && element.getAttribute("aria-hidden") !== "true");
|
|
2863
3629
|
}
|
|
2864
3630
|
function useGdsTableKeyNav(rowCount, columnCount) {
|
|
2865
|
-
const tbodyRef =
|
|
2866
|
-
const [focusedCell, setFocusedCell] =
|
|
2867
|
-
const focusCell =
|
|
3631
|
+
const tbodyRef = useRef7(null);
|
|
3632
|
+
const [focusedCell, setFocusedCell] = useState14(rowCount > 0 && columnCount > 0 ? { rowIndex: 0, columnIndex: 0 } : null);
|
|
3633
|
+
const focusCell = useCallback7((rowIndex, columnIndex) => {
|
|
2868
3634
|
const rows = tbodyRef.current?.querySelectorAll("tr[data-gds-row]") ?? [];
|
|
2869
3635
|
const nextRowIndex = Math.max(0, Math.min(rowIndex, rows.length - 1));
|
|
2870
3636
|
const cells = rows[nextRowIndex]?.querySelectorAll("[data-gds-cell]") ?? [];
|
|
@@ -2873,7 +3639,7 @@ function useGdsTableKeyNav(rowCount, columnCount) {
|
|
|
2873
3639
|
setFocusedCell({ rowIndex: nextRowIndex, columnIndex: nextColumnIndex });
|
|
2874
3640
|
cells[nextColumnIndex]?.focus();
|
|
2875
3641
|
}, []);
|
|
2876
|
-
const handleKeyDown =
|
|
3642
|
+
const handleKeyDown = useCallback7((event) => {
|
|
2877
3643
|
const rows = tbodyRef.current?.querySelectorAll("tr[data-gds-row]") ?? [];
|
|
2878
3644
|
if (rows.length === 0 || columnCount === 0) return;
|
|
2879
3645
|
const target = event.target instanceof HTMLElement ? event.target : null;
|
|
@@ -2917,7 +3683,7 @@ function useGdsTableKeyNav(rowCount, columnCount) {
|
|
|
2917
3683
|
focusCell(event.ctrlKey || event.metaKey ? lastRow : current.rowIndex, lastColumn);
|
|
2918
3684
|
}
|
|
2919
3685
|
}, [columnCount, focusCell, focusedCell]);
|
|
2920
|
-
|
|
3686
|
+
useEffect6(() => {
|
|
2921
3687
|
setFocusedCell(rowCount > 0 && columnCount > 0 ? { rowIndex: 0, columnIndex: 0 } : null);
|
|
2922
3688
|
}, [columnCount, rowCount]);
|
|
2923
3689
|
return { tbodyRef, handleKeyDown, focusedCell, setFocusedCell };
|
|
@@ -2937,7 +3703,7 @@ function GdsDataTable({
|
|
|
2937
3703
|
retryLabel: retryLabelProp,
|
|
2938
3704
|
mobileCards = true
|
|
2939
3705
|
}) {
|
|
2940
|
-
const { t } =
|
|
3706
|
+
const { t } = useGdsTranslation21();
|
|
2941
3707
|
const caption = captionProp ?? t("gds.gdsDataTable.caption", "Data table");
|
|
2942
3708
|
const exportLabel = exportLabelProp ?? t("gds.gdsDataTable.exportLabel", "Export");
|
|
2943
3709
|
const retryLabel = retryLabelProp ?? t("gds.gdsDataTable.retryLabel", "Retry");
|
|
@@ -2947,50 +3713,50 @@ function GdsDataTable({
|
|
|
2947
3713
|
const gridColumnCount = visibleColumns.length + 1;
|
|
2948
3714
|
const { tbodyRef, handleKeyDown, focusedCell, setFocusedCell } = useGdsTableKeyNav(table.visibleRows.length, gridColumnCount);
|
|
2949
3715
|
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__ */
|
|
3716
|
+
if (table.status === "loading") return /* @__PURE__ */ jsx29(StateBlock, { variant: "loading", title: "Loading table", description: "Preparing governed data rows.", compact: true });
|
|
3717
|
+
if (table.status === "error") return /* @__PURE__ */ jsx29(StateBlock, { variant: "error", title: "Unable to load table", description: table.error ?? "The data adapter failed.", action: /* @__PURE__ */ jsx29(Button10, { onClick: table.retry, children: retryLabel }), compact: true });
|
|
3718
|
+
if (table.status === "empty") return /* @__PURE__ */ jsx29(StateBlock, { variant: "empty", title: "No rows available", description: "There is no data for this table yet.", compact: true });
|
|
3719
|
+
if (table.status === "filtered-empty") return /* @__PURE__ */ jsx29(StateBlock, { variant: "empty", title: "No matching rows", description: "Adjust search or filters to broaden the result set.", compact: true });
|
|
3720
|
+
return /* @__PURE__ */ jsxs20(Stack13, { gap: "sm", children: [
|
|
3721
|
+
/* @__PURE__ */ jsxs20(Group16, { justify: "space-between", align: "end", children: [
|
|
3722
|
+
/* @__PURE__ */ jsxs20(Stack13, { gap: 2, children: [
|
|
3723
|
+
/* @__PURE__ */ jsx29(Text18, { size: "sm", fw: 700, children: caption }),
|
|
3724
|
+
summary ? /* @__PURE__ */ jsx29(Text18, { size: "xs", c: "dimmed", children: summary }) : null,
|
|
3725
|
+
/* @__PURE__ */ jsxs20(Text18, { size: "xs", c: "dimmed", children: [
|
|
2960
3726
|
table.total,
|
|
2961
3727
|
" rows",
|
|
2962
3728
|
table.status === "partial" ? " (partial data)" : ""
|
|
2963
3729
|
] })
|
|
2964
3730
|
] }),
|
|
2965
|
-
/* @__PURE__ */
|
|
2966
|
-
/* @__PURE__ */
|
|
2967
|
-
/* @__PURE__ */
|
|
3731
|
+
/* @__PURE__ */ jsxs20(Group16, { gap: "xs", children: [
|
|
3732
|
+
/* @__PURE__ */ jsx29(TextInput2, { "aria-label": "Search rows", placeholder: "Search rows", value: table.query.search, onChange: (event) => table.setSearch(event.currentTarget.value) }),
|
|
3733
|
+
/* @__PURE__ */ jsx29(Button10, { variant: "light", onClick: () => {
|
|
2968
3734
|
void table.exportRows();
|
|
2969
3735
|
}, loading: table.status === "exporting", children: exportLabel })
|
|
2970
3736
|
] })
|
|
2971
3737
|
] }),
|
|
2972
|
-
/* @__PURE__ */
|
|
2973
|
-
/* @__PURE__ */
|
|
2974
|
-
/* @__PURE__ */
|
|
2975
|
-
/* @__PURE__ */
|
|
2976
|
-
visibleColumns.map((column) => /* @__PURE__ */
|
|
3738
|
+
/* @__PURE__ */ jsx29(ScrollArea3, { children: /* @__PURE__ */ jsxs20(Table4, { withTableBorder: true, striped: true, highlightOnHover: true, role: "grid", "aria-label": caption, "aria-rowcount": table.total, children: [
|
|
3739
|
+
/* @__PURE__ */ jsx29("caption", { children: caption }),
|
|
3740
|
+
/* @__PURE__ */ jsx29(Table4.Thead, { children: /* @__PURE__ */ jsxs20(Table4.Tr, { children: [
|
|
3741
|
+
/* @__PURE__ */ jsx29(Table4.Th, { scope: "col", children: /* @__PURE__ */ jsx29(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 }) }),
|
|
3742
|
+
visibleColumns.map((column) => /* @__PURE__ */ jsx29(Table4.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__ */ jsx29("button", { type: "button", onClick: () => table.setSort(column.key), children: column.label }) : column.label }, column.key))
|
|
2977
3743
|
] }) }),
|
|
2978
|
-
/* @__PURE__ */
|
|
2979
|
-
|
|
3744
|
+
/* @__PURE__ */ jsx29(
|
|
3745
|
+
Table4.Tbody,
|
|
2980
3746
|
{
|
|
2981
3747
|
ref: tbodyRef,
|
|
2982
3748
|
onKeyDown: handleKeyDown,
|
|
2983
3749
|
children: table.visibleRows.map((row, rowIndex) => {
|
|
2984
3750
|
const id = rowId(row, rowIndex);
|
|
2985
|
-
return /* @__PURE__ */
|
|
2986
|
-
|
|
3751
|
+
return /* @__PURE__ */ jsxs20(
|
|
3752
|
+
Table4.Tr,
|
|
2987
3753
|
{
|
|
2988
3754
|
"data-gds-row": true,
|
|
2989
3755
|
"aria-selected": table.selectedRowIds.includes(id),
|
|
2990
3756
|
"aria-rowindex": (table.query.page - 1) * table.query.pageSize + rowIndex + 2,
|
|
2991
3757
|
children: [
|
|
2992
|
-
/* @__PURE__ */
|
|
2993
|
-
|
|
3758
|
+
/* @__PURE__ */ jsx29(
|
|
3759
|
+
Table4.Td,
|
|
2994
3760
|
{
|
|
2995
3761
|
role: "gridcell",
|
|
2996
3762
|
"data-gds-cell": true,
|
|
@@ -3000,14 +3766,14 @@ function GdsDataTable({
|
|
|
3000
3766
|
"aria-colindex": 1,
|
|
3001
3767
|
onFocus: () => setFocusedCell({ rowIndex, columnIndex: 0 }),
|
|
3002
3768
|
style: focusedCell?.rowIndex === rowIndex && focusedCell.columnIndex === 0 ? { outline: "2px solid var(--mantine-color-blue-5)", outlineOffset: "-2px" } : void 0,
|
|
3003
|
-
children: /* @__PURE__ */
|
|
3769
|
+
children: /* @__PURE__ */ jsx29(Checkbox3, { "aria-label": `Select row ${id}`, checked: table.selectedRowIds.includes(id), onChange: () => table.toggleRow(id), tabIndex: -1 })
|
|
3004
3770
|
}
|
|
3005
3771
|
),
|
|
3006
3772
|
visibleColumns.map((column, columnIndex) => {
|
|
3007
3773
|
const gridColumnIndex = columnIndex + 1;
|
|
3008
3774
|
const isCellFocused = focusedCell?.rowIndex === rowIndex && focusedCell.columnIndex === gridColumnIndex;
|
|
3009
|
-
return /* @__PURE__ */
|
|
3010
|
-
|
|
3775
|
+
return /* @__PURE__ */ jsx29(
|
|
3776
|
+
Table4.Td,
|
|
3011
3777
|
{
|
|
3012
3778
|
role: "gridcell",
|
|
3013
3779
|
"data-gds-cell": true,
|
|
@@ -3032,24 +3798,24 @@ function GdsDataTable({
|
|
|
3032
3798
|
}
|
|
3033
3799
|
)
|
|
3034
3800
|
] }) }),
|
|
3035
|
-
/* @__PURE__ */
|
|
3036
|
-
virtualizedRowLimit && table.rows.length > table.visibleRows.length ? /* @__PURE__ */
|
|
3801
|
+
/* @__PURE__ */ jsx29(VisuallyHidden5, { "aria-live": "polite", "aria-atomic": "true", children: focusedCell ? `Row ${focusedCell.rowIndex + 1} of ${table.visibleRows.length}, ${focusedColumnLabel ?? `column ${focusedCell.columnIndex + 1}`} column` : "" }),
|
|
3802
|
+
virtualizedRowLimit && table.rows.length > table.visibleRows.length ? /* @__PURE__ */ jsxs20(Text18, { size: "xs", c: "dimmed", children: [
|
|
3037
3803
|
table.visibleRows.length,
|
|
3038
3804
|
" of ",
|
|
3039
3805
|
table.rows.length,
|
|
3040
3806
|
" rows rendered in the virtualized window."
|
|
3041
3807
|
] }) : null,
|
|
3042
|
-
/* @__PURE__ */
|
|
3043
|
-
/* @__PURE__ */
|
|
3808
|
+
/* @__PURE__ */ jsxs20(Group16, { justify: "space-between", children: [
|
|
3809
|
+
/* @__PURE__ */ jsxs20(Text18, { size: "xs", c: "dimmed", children: [
|
|
3044
3810
|
table.selectedRowIds.length,
|
|
3045
3811
|
" selected"
|
|
3046
3812
|
] }),
|
|
3047
|
-
/* @__PURE__ */
|
|
3813
|
+
/* @__PURE__ */ jsx29(Pagination, { total: pageCount, value: table.query.page, onChange: table.setPage, size: "sm" })
|
|
3048
3814
|
] }),
|
|
3049
|
-
mobileCards ? /* @__PURE__ */
|
|
3815
|
+
mobileCards ? /* @__PURE__ */ jsx29(Stack13, { gap: "xs", "aria-label": "Mobile row cards", children: table.visibleRows.slice(0, 6).map((row, index) => {
|
|
3050
3816
|
const ordered = [...visibleColumns].sort((left, right) => (left.mobilePriority ?? 99) - (right.mobilePriority ?? 99));
|
|
3051
3817
|
const id = rowId(row, index);
|
|
3052
|
-
return /* @__PURE__ */
|
|
3818
|
+
return /* @__PURE__ */ jsx29(
|
|
3053
3819
|
StateBlock,
|
|
3054
3820
|
{
|
|
3055
3821
|
variant: "info",
|
|
@@ -3064,10 +3830,10 @@ function GdsDataTable({
|
|
|
3064
3830
|
}
|
|
3065
3831
|
|
|
3066
3832
|
// src/GdsResourceManager.client.tsx
|
|
3067
|
-
import { useGdsTranslation as
|
|
3068
|
-
import { useCallback as
|
|
3069
|
-
import { Button as
|
|
3070
|
-
import { jsx as
|
|
3833
|
+
import { useGdsTranslation as useGdsTranslation22 } from "@sovereignsquad/gds-theme";
|
|
3834
|
+
import { useCallback as useCallback8, useEffect as useEffect7, useMemo as useMemo8, useState as useState15 } from "react";
|
|
3835
|
+
import { Button as Button11, Group as Group17, Stack as Stack14, Text as Text19 } from "@mantine/core";
|
|
3836
|
+
import { jsx as jsx30, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
3071
3837
|
function emitResourceEvent(onEvent, event) {
|
|
3072
3838
|
onEvent?.({ ...event, timestamp: Date.now(), privacy: "metadata-only" });
|
|
3073
3839
|
}
|
|
@@ -3129,12 +3895,12 @@ function useGdsResourceManager({
|
|
|
3129
3895
|
timeoutMs = 8e3,
|
|
3130
3896
|
confirmAction
|
|
3131
3897
|
}) {
|
|
3132
|
-
const [resources, setResources] =
|
|
3133
|
-
const [selectedResource, setSelectedResource] =
|
|
3134
|
-
const [state, setState] =
|
|
3135
|
-
const [error, setError] =
|
|
3136
|
-
const [reloadKey, setReloadKey] =
|
|
3137
|
-
|
|
3898
|
+
const [resources, setResources] = useState15([]);
|
|
3899
|
+
const [selectedResource, setSelectedResource] = useState15(null);
|
|
3900
|
+
const [state, setState] = useState15("loading-list");
|
|
3901
|
+
const [error, setError] = useState15();
|
|
3902
|
+
const [reloadKey, setReloadKey] = useState15(0);
|
|
3903
|
+
useEffect7(() => {
|
|
3138
3904
|
const controller = new AbortController();
|
|
3139
3905
|
const timer = window.setTimeout(() => controller.abort(), timeoutMs);
|
|
3140
3906
|
setState("loading-list");
|
|
@@ -3154,12 +3920,12 @@ function useGdsResourceManager({
|
|
|
3154
3920
|
window.clearTimeout(timer);
|
|
3155
3921
|
};
|
|
3156
3922
|
}, [adapter, onEvent, reloadKey, timeoutMs]);
|
|
3157
|
-
const loadList =
|
|
3158
|
-
const permissions =
|
|
3159
|
-
const canRunAction =
|
|
3923
|
+
const loadList = useCallback8(() => setReloadKey((value) => value + 1), []);
|
|
3924
|
+
const permissions = useMemo8(() => adapter.getPermissions?.(selectedResource) ?? defaultPermissions(selectedResource), [adapter, selectedResource]);
|
|
3925
|
+
const canRunAction = useCallback8((action, resource = selectedResource) => {
|
|
3160
3926
|
return (adapter.getPermissions?.(resource) ?? defaultPermissions(resource)).find((permission) => permission.action === action) ?? { action, allowed: false, reason: "Action is not available." };
|
|
3161
3927
|
}, [adapter, selectedResource]);
|
|
3162
|
-
const openDetail =
|
|
3928
|
+
const openDetail = useCallback8(async (id) => {
|
|
3163
3929
|
setState("detail-loading");
|
|
3164
3930
|
try {
|
|
3165
3931
|
const resource = adapter.detail ? await adapter.detail(id) : resources.find((item) => item.id === id) ?? null;
|
|
@@ -3180,7 +3946,7 @@ function useGdsResourceManager({
|
|
|
3180
3946
|
return null;
|
|
3181
3947
|
}
|
|
3182
3948
|
}, [adapter, onEvent, resources]);
|
|
3183
|
-
const runAction =
|
|
3949
|
+
const runAction = useCallback8(async (action, resource, values = {}) => {
|
|
3184
3950
|
const permission = canRunAction(action, resource);
|
|
3185
3951
|
if (!permission.allowed) {
|
|
3186
3952
|
setState("permission-denied");
|
|
@@ -3246,30 +4012,30 @@ function GdsResourceManager({
|
|
|
3246
4012
|
timeoutMs,
|
|
3247
4013
|
confirmAction
|
|
3248
4014
|
}) {
|
|
3249
|
-
const { t } =
|
|
4015
|
+
const { t } = useGdsTranslation22();
|
|
3250
4016
|
const emptyLabel = emptyLabelProp ?? t("gds.gdsResourceManager.emptyLabel", "No resources available");
|
|
3251
4017
|
const manager = useGdsResourceManager({ adapter, onEvent, timeoutMs, confirmAction });
|
|
3252
|
-
const tableColumns =
|
|
4018
|
+
const tableColumns = useMemo8(() => columns ?? [
|
|
3253
4019
|
{ key: "title", label: "Title", sortable: true, filterable: true, mobilePriority: 1 },
|
|
3254
4020
|
{ key: "status", label: "Status", sortable: true, filterable: true, mobilePriority: 2 },
|
|
3255
4021
|
{ key: "updatedAt", label: "Updated", sortable: true, mobilePriority: 3 }
|
|
3256
4022
|
], [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__ */
|
|
4023
|
+
const tableAdapter = useMemo8(() => createGdsTableAdapter(manager.resources, tableColumns), [manager.resources, tableColumns]);
|
|
4024
|
+
if (manager.state === "loading-list") return /* @__PURE__ */ jsx30(StateBlock, { variant: "loading", title: "Loading resources", description: "Preparing the governed resource list.", compact: true });
|
|
4025
|
+
if (manager.state === "error") return /* @__PURE__ */ jsx30(StateBlock, { variant: "error", title: "Resource workflow failed", description: manager.error ?? "The resource manager could not recover.", action: /* @__PURE__ */ jsx30(Button11, { onClick: manager.loadList, children: "Retry" }), compact: true });
|
|
4026
|
+
if (manager.state === "empty") return /* @__PURE__ */ jsx30(StateBlock, { variant: "empty", title: emptyLabel, description: "Create or import a resource to continue.", compact: true });
|
|
4027
|
+
return /* @__PURE__ */ jsxs21(Stack14, { gap: "md", children: [
|
|
4028
|
+
/* @__PURE__ */ jsxs21(Group17, { justify: "space-between", align: "start", children: [
|
|
4029
|
+
/* @__PURE__ */ jsxs21(Stack14, { gap: 2, children: [
|
|
4030
|
+
/* @__PURE__ */ jsx30(Text19, { fw: 700, children: title }),
|
|
4031
|
+
description ? /* @__PURE__ */ jsx30(Text19, { size: "sm", c: "dimmed", children: description }) : null,
|
|
4032
|
+
manager.error ? /* @__PURE__ */ jsx30(Text19, { role: "alert", size: "sm", c: "red.7", children: manager.error }) : null
|
|
3267
4033
|
] }),
|
|
3268
|
-
/* @__PURE__ */
|
|
4034
|
+
/* @__PURE__ */ jsx30(Button11, { onClick: () => {
|
|
3269
4035
|
void manager.runAction("create", null, { title: "Untitled resource" });
|
|
3270
4036
|
}, children: "Create" })
|
|
3271
4037
|
] }),
|
|
3272
|
-
/* @__PURE__ */
|
|
4038
|
+
/* @__PURE__ */ jsx30(
|
|
3273
4039
|
GdsDataTable,
|
|
3274
4040
|
{
|
|
3275
4041
|
caption: `${title} resources`,
|
|
@@ -3278,17 +4044,17 @@ function GdsResourceManager({
|
|
|
3278
4044
|
{
|
|
3279
4045
|
key: "id",
|
|
3280
4046
|
label: "Actions",
|
|
3281
|
-
render: (row) => /* @__PURE__ */
|
|
3282
|
-
/* @__PURE__ */
|
|
4047
|
+
render: (row) => /* @__PURE__ */ jsxs21(Group17, { gap: "xs", children: [
|
|
4048
|
+
/* @__PURE__ */ jsx30(Button11, { size: "xs", variant: "light", onClick: () => {
|
|
3283
4049
|
void manager.openDetail(row.id);
|
|
3284
4050
|
}, children: "Details" }),
|
|
3285
|
-
/* @__PURE__ */
|
|
4051
|
+
/* @__PURE__ */ jsx30(Button11, { size: "xs", variant: "light", onClick: () => {
|
|
3286
4052
|
void manager.runAction("activate", row);
|
|
3287
4053
|
}, disabled: !manager.canRunAction("activate", row).allowed, children: "Activate" }),
|
|
3288
|
-
/* @__PURE__ */
|
|
4054
|
+
/* @__PURE__ */ jsx30(Button11, { size: "xs", variant: "light", color: "red", onClick: () => {
|
|
3289
4055
|
void manager.runAction("delete", row);
|
|
3290
4056
|
}, disabled: !manager.canRunAction("delete", row).allowed, children: "Delete" }),
|
|
3291
|
-
/* @__PURE__ */
|
|
4057
|
+
/* @__PURE__ */ jsx30(Button11, { size: "xs", variant: "subtle", onClick: () => {
|
|
3292
4058
|
void manager.runAction("copy-preview", row);
|
|
3293
4059
|
}, disabled: !manager.canRunAction("copy-preview", row).allowed, children: "Copy preview" })
|
|
3294
4060
|
] })
|
|
@@ -3299,7 +4065,7 @@ function GdsResourceManager({
|
|
|
3299
4065
|
onEvent: (event) => onEvent?.({ type: event.type === "load_failed" ? "action_failed" : "resource_loaded", timestamp: event.timestamp, privacy: "metadata-only", message: event.message })
|
|
3300
4066
|
}
|
|
3301
4067
|
),
|
|
3302
|
-
manager.selectedResource ? /* @__PURE__ */
|
|
4068
|
+
manager.selectedResource ? /* @__PURE__ */ jsx30("section", { "aria-label": `${manager.selectedResource.title} detail`, children: renderDetail ? renderDetail(manager.selectedResource, manager) : /* @__PURE__ */ jsx30(
|
|
3303
4069
|
StateBlock,
|
|
3304
4070
|
{
|
|
3305
4071
|
variant: "info",
|
|
@@ -3312,10 +4078,10 @@ function GdsResourceManager({
|
|
|
3312
4078
|
}
|
|
3313
4079
|
|
|
3314
4080
|
// src/OverlayManager.client.tsx
|
|
3315
|
-
import { createContext as createContext4, useCallback as
|
|
4081
|
+
import { createContext as createContext4, useCallback as useCallback9, useContext as useContext4, useEffect as useEffect8, useMemo as useMemo9, useRef as useRef8, useState as useState16 } from "react";
|
|
3316
4082
|
import { Drawer, Modal as Modal2 } from "@mantine/core";
|
|
3317
|
-
import { getGdsMotionPreset, useGdsTranslation as
|
|
3318
|
-
import { jsx as
|
|
4083
|
+
import { getGdsMotionPreset, gdsDevWarnOnce as gdsDevWarnOnce4, useGdsTranslation as useGdsTranslation23 } from "@sovereignsquad/gds-theme";
|
|
4084
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
3319
4085
|
var defaultOverlayPolicy = {
|
|
3320
4086
|
closeOnEscape: true,
|
|
3321
4087
|
closeOnOutsideClick: true,
|
|
@@ -3357,13 +4123,13 @@ function OverlayManagerProvider({
|
|
|
3357
4123
|
routeKey,
|
|
3358
4124
|
onOverlayEvent
|
|
3359
4125
|
}) {
|
|
3360
|
-
const [stack, setStack] =
|
|
3361
|
-
const focusReturnTargets =
|
|
3362
|
-
const previousRouteKey =
|
|
3363
|
-
const emit =
|
|
4126
|
+
const [stack, setStack] = useState16([]);
|
|
4127
|
+
const focusReturnTargets = useRef8(/* @__PURE__ */ new Map());
|
|
4128
|
+
const previousRouteKey = useRef8(routeKey);
|
|
4129
|
+
const emit = useCallback9((type, item, reason) => {
|
|
3364
4130
|
onOverlayEvent?.(createOverlayEvent(type, item, reason));
|
|
3365
4131
|
}, [onOverlayEvent]);
|
|
3366
|
-
const registerOverlay =
|
|
4132
|
+
const registerOverlay = useCallback9((overlay) => {
|
|
3367
4133
|
const policy = normalizePolicy(defaultPolicy, overlay.policy);
|
|
3368
4134
|
const focusTarget = getFocusableElement(overlay.invokerId);
|
|
3369
4135
|
if (policy.returnFocus && focusTarget) {
|
|
@@ -3383,7 +4149,7 @@ function OverlayManagerProvider({
|
|
|
3383
4149
|
return [...base, item];
|
|
3384
4150
|
});
|
|
3385
4151
|
}, [defaultPolicy, emit, singleOverlayMode]);
|
|
3386
|
-
const unregisterOverlay =
|
|
4152
|
+
const unregisterOverlay = useCallback9((id, reason = "programmatic") => {
|
|
3387
4153
|
setStack((current) => {
|
|
3388
4154
|
const target = current.find((item) => item.id === id);
|
|
3389
4155
|
if (target) {
|
|
@@ -3397,8 +4163,8 @@ function OverlayManagerProvider({
|
|
|
3397
4163
|
focusReturnTargets.current.delete(id);
|
|
3398
4164
|
}
|
|
3399
4165
|
}, [emit]);
|
|
3400
|
-
const isTopMost =
|
|
3401
|
-
const requestClose =
|
|
4166
|
+
const isTopMost = useCallback9((id) => stack.length > 0 && stack[stack.length - 1]?.id === id, [stack]);
|
|
4167
|
+
const requestClose = useCallback9((id, reason) => {
|
|
3402
4168
|
const target = stack.find((item) => item.id === id);
|
|
3403
4169
|
if (!target || !isTopMost(id)) {
|
|
3404
4170
|
if (target) emit("blocked_close", { ...target, status: "blocked-close" }, reason);
|
|
@@ -3415,13 +4181,13 @@ function OverlayManagerProvider({
|
|
|
3415
4181
|
}
|
|
3416
4182
|
return reason;
|
|
3417
4183
|
}, [defaultPolicy, emit, isTopMost, stack]);
|
|
3418
|
-
const closeOverlay =
|
|
4184
|
+
const closeOverlay = useCallback9((id, reason = "programmatic") => {
|
|
3419
4185
|
const acceptedReason = requestClose(id, reason);
|
|
3420
4186
|
if (!acceptedReason) return false;
|
|
3421
4187
|
unregisterOverlay(id, acceptedReason);
|
|
3422
4188
|
return true;
|
|
3423
4189
|
}, [requestClose, unregisterOverlay]);
|
|
3424
|
-
|
|
4190
|
+
useEffect8(() => {
|
|
3425
4191
|
if (previousRouteKey.current === routeKey) return;
|
|
3426
4192
|
previousRouteKey.current = routeKey;
|
|
3427
4193
|
setStack((current) => {
|
|
@@ -3438,7 +4204,7 @@ function OverlayManagerProvider({
|
|
|
3438
4204
|
return preserved;
|
|
3439
4205
|
});
|
|
3440
4206
|
}, [defaultPolicy, emit, routeKey]);
|
|
3441
|
-
const value =
|
|
4207
|
+
const value = useMemo9(() => ({
|
|
3442
4208
|
stack,
|
|
3443
4209
|
registerOverlay,
|
|
3444
4210
|
unregisterOverlay,
|
|
@@ -3448,7 +4214,7 @@ function OverlayManagerProvider({
|
|
|
3448
4214
|
getOverlay: (id) => stack.find((item) => item.id === id),
|
|
3449
4215
|
requestClose
|
|
3450
4216
|
}), [closeOverlay, isTopMost, registerOverlay, requestClose, stack, unregisterOverlay]);
|
|
3451
|
-
return /* @__PURE__ */
|
|
4217
|
+
return /* @__PURE__ */ jsx31(OverlayManagerContext.Provider, { value, children });
|
|
3452
4218
|
}
|
|
3453
4219
|
function useOverlayManager() {
|
|
3454
4220
|
const context = useContext4(OverlayManagerContext);
|
|
@@ -3468,17 +4234,26 @@ function useOverlaySurface({
|
|
|
3468
4234
|
onClose,
|
|
3469
4235
|
onBlockedClose
|
|
3470
4236
|
}) {
|
|
3471
|
-
const
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
4237
|
+
const manager = useContext4(OverlayManagerContext);
|
|
4238
|
+
if (!manager) {
|
|
4239
|
+
gdsDevWarnOnce4(
|
|
4240
|
+
"OverlayManager:missing-provider",
|
|
4241
|
+
"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."
|
|
4242
|
+
);
|
|
4243
|
+
}
|
|
4244
|
+
const registerOverlay = manager?.registerOverlay;
|
|
4245
|
+
const unregisterOverlay = manager?.unregisterOverlay;
|
|
4246
|
+
const requestOverlayClose = manager?.requestClose;
|
|
4247
|
+
useEffect8(() => {
|
|
4248
|
+
if (!registerOverlay || !unregisterOverlay || !opened) return void 0;
|
|
3478
4249
|
registerOverlay({ id, kind, title, description, invokerId, policy });
|
|
3479
4250
|
return () => unregisterOverlay(id);
|
|
3480
4251
|
}, [description, id, invokerId, kind, opened, policy, registerOverlay, title, unregisterOverlay]);
|
|
3481
|
-
const requestClose =
|
|
4252
|
+
const requestClose = useCallback9((reason) => {
|
|
4253
|
+
if (!requestOverlayClose || !unregisterOverlay) {
|
|
4254
|
+
onClose();
|
|
4255
|
+
return;
|
|
4256
|
+
}
|
|
3482
4257
|
const acceptedReason = requestOverlayClose(id, reason);
|
|
3483
4258
|
if (!acceptedReason) {
|
|
3484
4259
|
onBlockedClose?.(reason);
|
|
@@ -3503,8 +4278,8 @@ function GdsModal({
|
|
|
3503
4278
|
}) {
|
|
3504
4279
|
const requestClose = useOverlaySurface({ id, opened, kind: "modal", title, description, children, invokerId, policy, onClose, onBlockedClose });
|
|
3505
4280
|
const motion = getGdsMotionPreset("overlay");
|
|
3506
|
-
const { t } =
|
|
3507
|
-
return /* @__PURE__ */
|
|
4281
|
+
const { t } = useGdsTranslation23();
|
|
4282
|
+
return /* @__PURE__ */ jsx31(
|
|
3508
4283
|
Modal2,
|
|
3509
4284
|
{
|
|
3510
4285
|
...modalProps,
|
|
@@ -3535,8 +4310,8 @@ function GdsDrawer({
|
|
|
3535
4310
|
}) {
|
|
3536
4311
|
const requestClose = useOverlaySurface({ id, opened, kind: "drawer", title, description, children, invokerId, policy, onClose, onBlockedClose });
|
|
3537
4312
|
const motion = getGdsMotionPreset("drawer");
|
|
3538
|
-
const { t } =
|
|
3539
|
-
return /* @__PURE__ */
|
|
4313
|
+
const { t } = useGdsTranslation23();
|
|
4314
|
+
return /* @__PURE__ */ jsx31(
|
|
3540
4315
|
Drawer,
|
|
3541
4316
|
{
|
|
3542
4317
|
...drawerProps,
|
|
@@ -3555,19 +4330,20 @@ function GdsDrawer({
|
|
|
3555
4330
|
);
|
|
3556
4331
|
}
|
|
3557
4332
|
function GdsSheet(props) {
|
|
3558
|
-
return /* @__PURE__ */
|
|
4333
|
+
return /* @__PURE__ */ jsx31(GdsDrawer, { ...props, position: props.position ?? "bottom", policy: { mobileFullscreen: true, ...props.policy } });
|
|
3559
4334
|
}
|
|
3560
4335
|
function GdsDialog(props) {
|
|
3561
|
-
return /* @__PURE__ */
|
|
4336
|
+
return /* @__PURE__ */ jsx31(GdsModal, { ...props });
|
|
3562
4337
|
}
|
|
3563
4338
|
function GdsSidePanel(props) {
|
|
3564
|
-
return /* @__PURE__ */
|
|
4339
|
+
return /* @__PURE__ */ jsx31(GdsDrawer, { ...props, position: props.position ?? "right" });
|
|
3565
4340
|
}
|
|
3566
4341
|
|
|
3567
4342
|
// src/Notifications.client.tsx
|
|
3568
|
-
import { useGdsTranslation as
|
|
3569
|
-
import {
|
|
3570
|
-
import {
|
|
4343
|
+
import { gdsSafeAreaInset, gdsZIndexToken, useGdsTranslation as useGdsTranslation24 } from "@sovereignsquad/gds-theme";
|
|
4344
|
+
import { Box as Box10, Button as Button12, Group as Group18, Text as Text20 } from "@mantine/core";
|
|
4345
|
+
import { createContext as createContext5, useCallback as useCallback10, useContext as useContext5, useMemo as useMemo10, useRef as useRef9, useState as useState17 } from "react";
|
|
4346
|
+
import { jsx as jsx32, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
3571
4347
|
var GdsNotificationContext = createContext5(null);
|
|
3572
4348
|
function shouldAutoClose(message) {
|
|
3573
4349
|
if (message.autoCloseMs === false) return false;
|
|
@@ -3598,13 +4374,13 @@ function GdsNotificationProvider({
|
|
|
3598
4374
|
defaultPolicy,
|
|
3599
4375
|
onAuditEvent
|
|
3600
4376
|
}) {
|
|
3601
|
-
const [notifications, setNotifications] =
|
|
3602
|
-
const [announcement, setAnnouncement] =
|
|
3603
|
-
const timers =
|
|
3604
|
-
const audit =
|
|
4377
|
+
const [notifications, setNotifications] = useState17([]);
|
|
4378
|
+
const [announcement, setAnnouncement] = useState17(null);
|
|
4379
|
+
const timers = useRef9(/* @__PURE__ */ new Map());
|
|
4380
|
+
const audit = useCallback10((type, notification, metadata = {}) => {
|
|
3605
4381
|
onAuditEvent?.(createGdsNotificationAuditEvent(type, notification, metadata));
|
|
3606
4382
|
}, [onAuditEvent]);
|
|
3607
|
-
const scheduleAutoClose =
|
|
4383
|
+
const scheduleAutoClose = useCallback10((message) => {
|
|
3608
4384
|
const existingTimer = timers.current.get(message.id);
|
|
3609
4385
|
if (existingTimer) {
|
|
3610
4386
|
window.clearTimeout(existingTimer);
|
|
@@ -3621,7 +4397,7 @@ function GdsNotificationProvider({
|
|
|
3621
4397
|
}, message.autoCloseMs);
|
|
3622
4398
|
timers.current.set(message.id, timer);
|
|
3623
4399
|
}, [audit]);
|
|
3624
|
-
const updateNotification =
|
|
4400
|
+
const updateNotification = useCallback10((id, patch) => {
|
|
3625
4401
|
setNotifications((current) => current.map((item) => {
|
|
3626
4402
|
if (item.id !== id) return item;
|
|
3627
4403
|
const updated = normalizeNotification({ ...item, ...patch, id }, defaultPolicy);
|
|
@@ -3630,7 +4406,7 @@ function GdsNotificationProvider({
|
|
|
3630
4406
|
return updated;
|
|
3631
4407
|
}));
|
|
3632
4408
|
}, [audit, defaultPolicy, scheduleAutoClose]);
|
|
3633
|
-
const dismissNotification =
|
|
4409
|
+
const dismissNotification = useCallback10((id) => {
|
|
3634
4410
|
setNotifications((current) => {
|
|
3635
4411
|
const target = current.find((item) => item.id === id);
|
|
3636
4412
|
if (target) audit("dismissed", { ...target, status: "dismissed" });
|
|
@@ -3642,13 +4418,11 @@ function GdsNotificationProvider({
|
|
|
3642
4418
|
return current.filter((item) => item.id !== id);
|
|
3643
4419
|
});
|
|
3644
4420
|
}, [audit]);
|
|
3645
|
-
const notify =
|
|
4421
|
+
const notify = useCallback10((message, policy) => {
|
|
3646
4422
|
const mergedPolicy = { ...defaultPolicy, ...policy };
|
|
3647
4423
|
const next = normalizeNotification(message, mergedPolicy);
|
|
3648
4424
|
audit("shown", next);
|
|
3649
|
-
|
|
3650
|
-
setAnnouncement(next);
|
|
3651
|
-
}
|
|
4425
|
+
setAnnouncement(next);
|
|
3652
4426
|
if (disabled) return next.id;
|
|
3653
4427
|
const dedupe = mergedPolicy.dedupe ?? "replace";
|
|
3654
4428
|
setNotifications((current) => {
|
|
@@ -3659,7 +4433,7 @@ function GdsNotificationProvider({
|
|
|
3659
4433
|
scheduleAutoClose(next);
|
|
3660
4434
|
return next.id;
|
|
3661
4435
|
}, [audit, defaultPolicy, disabled, scheduleAutoClose]);
|
|
3662
|
-
const value =
|
|
4436
|
+
const value = useMemo10(() => ({
|
|
3663
4437
|
notifications,
|
|
3664
4438
|
notify,
|
|
3665
4439
|
updateNotification,
|
|
@@ -3715,9 +4489,9 @@ function GdsNotificationProvider({
|
|
|
3715
4489
|
}
|
|
3716
4490
|
}), [audit, dismissNotification, notifications, notify, updateNotification]);
|
|
3717
4491
|
const livePolicy = announcement ? getGdsNotificationLivePolicy(announcement) : "polite";
|
|
3718
|
-
return /* @__PURE__ */
|
|
4492
|
+
return /* @__PURE__ */ jsxs22(GdsNotificationContext.Provider, { value, children: [
|
|
3719
4493
|
children,
|
|
3720
|
-
/* @__PURE__ */
|
|
4494
|
+
/* @__PURE__ */ jsx32(
|
|
3721
4495
|
"span",
|
|
3722
4496
|
{
|
|
3723
4497
|
role: announcement?.severity === "error" ? "alert" : "status",
|
|
@@ -3750,7 +4524,7 @@ function NotificationCenter({
|
|
|
3750
4524
|
title: titleProp,
|
|
3751
4525
|
emptyMessage: emptyMessageProp
|
|
3752
4526
|
}) {
|
|
3753
|
-
const { t } =
|
|
4527
|
+
const { t } = useGdsTranslation24();
|
|
3754
4528
|
const title = titleProp ?? t("gds.notifications.title", "Notifications");
|
|
3755
4529
|
const emptyMessage = emptyMessageProp ?? t("gds.notifications.emptyMessage", "No active notifications.");
|
|
3756
4530
|
const {
|
|
@@ -3760,9 +4534,10 @@ function NotificationCenter({
|
|
|
3760
4534
|
runRetry,
|
|
3761
4535
|
runAction
|
|
3762
4536
|
} = useGdsNotifications();
|
|
3763
|
-
return /* @__PURE__ */
|
|
4537
|
+
return /* @__PURE__ */ jsx32(
|
|
3764
4538
|
NotificationCenterView,
|
|
3765
4539
|
{
|
|
4540
|
+
live: false,
|
|
3766
4541
|
title,
|
|
3767
4542
|
emptyMessage,
|
|
3768
4543
|
notifications,
|
|
@@ -3778,11 +4553,61 @@ function NotificationCenter({
|
|
|
3778
4553
|
);
|
|
3779
4554
|
}
|
|
3780
4555
|
var GdsNotificationCenter = NotificationCenter;
|
|
4556
|
+
function GdsToastViewport({ position = "bottom-end", maxVisible = 3 }) {
|
|
4557
|
+
const { t } = useGdsTranslation24();
|
|
4558
|
+
const { notifications, dismissNotification, runAction, runRetry } = useGdsNotifications();
|
|
4559
|
+
const visible = notifications.filter((item) => item.persistence !== "announcement-only" && !item.announcementOnly);
|
|
4560
|
+
if (visible.length === 0) return null;
|
|
4561
|
+
const shown = visible.slice(-Math.max(1, maxVisible));
|
|
4562
|
+
const hiddenCount = visible.length - shown.length;
|
|
4563
|
+
const [vertical, horizontal] = position.split("-");
|
|
4564
|
+
const sideInset = `calc(var(--gds-space-md) + max(${gdsSafeAreaInset.left}, ${gdsSafeAreaInset.right}))`;
|
|
4565
|
+
const edgeInset = `calc(var(--gds-space-md) + ${vertical === "top" ? gdsSafeAreaInset.top : gdsSafeAreaInset.bottom})`;
|
|
4566
|
+
return /* @__PURE__ */ jsx32(
|
|
4567
|
+
Box10,
|
|
4568
|
+
{
|
|
4569
|
+
component: "section",
|
|
4570
|
+
"aria-label": t("gds.toast.regionLabel", "Recent notifications"),
|
|
4571
|
+
"data-gds-toast-viewport": position,
|
|
4572
|
+
style: {
|
|
4573
|
+
position: "fixed",
|
|
4574
|
+
zIndex: gdsZIndexToken.max,
|
|
4575
|
+
[vertical]: edgeInset,
|
|
4576
|
+
insetInlineStart: horizontal === "start" ? sideInset : void 0,
|
|
4577
|
+
insetInlineEnd: horizontal === "end" ? sideInset : void 0,
|
|
4578
|
+
inlineSize: "calc(100% - 2 * var(--gds-space-md))",
|
|
4579
|
+
display: "flex",
|
|
4580
|
+
justifyContent: horizontal === "end" ? "flex-end" : "flex-start",
|
|
4581
|
+
pointerEvents: "none"
|
|
4582
|
+
},
|
|
4583
|
+
children: /* @__PURE__ */ jsxs22(GdsStack, { gap: "sm", maxWidth: "aside", style: { inlineSize: "100%", pointerEvents: "auto" }, children: [
|
|
4584
|
+
hiddenCount > 0 ? /* @__PURE__ */ jsx32(Text20, { size: "xs", c: "dimmed", children: t("gds.toast.more", "{count} more").replace("{count}", String(hiddenCount)) }) : null,
|
|
4585
|
+
shown.map((item) => /* @__PURE__ */ jsx32(
|
|
4586
|
+
InlineAlert,
|
|
4587
|
+
{
|
|
4588
|
+
live: false,
|
|
4589
|
+
severity: item.severity,
|
|
4590
|
+
status: item.status,
|
|
4591
|
+
title: item.title,
|
|
4592
|
+
message: item.message,
|
|
4593
|
+
action: /* @__PURE__ */ jsxs22(Group18, { gap: "xs", children: [
|
|
4594
|
+
item.actions?.map((action) => /* @__PURE__ */ jsx32(Button12, { size: "xs", variant: "default", onClick: () => runAction(item.id, action.id), disabled: action.disabled, children: action.label }, action.id)),
|
|
4595
|
+
item.retry ? /* @__PURE__ */ jsx32(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,
|
|
4596
|
+
/* @__PURE__ */ jsx32(Button12, { size: "xs", variant: "subtle", onClick: () => dismissNotification(item.id), children: t("gds.notifications.dismiss", "Dismiss") })
|
|
4597
|
+
] })
|
|
4598
|
+
},
|
|
4599
|
+
item.id
|
|
4600
|
+
))
|
|
4601
|
+
] })
|
|
4602
|
+
}
|
|
4603
|
+
);
|
|
4604
|
+
}
|
|
3781
4605
|
|
|
3782
4606
|
// src/FeedbackRuntime.client.tsx
|
|
3783
|
-
import { createContext as createContext6, useCallback as
|
|
3784
|
-
import {
|
|
3785
|
-
import {
|
|
4607
|
+
import { createContext as createContext6, useCallback as useCallback11, useContext as useContext6, useMemo as useMemo11, useRef as useRef10, useState as useState18 } from "react";
|
|
4608
|
+
import { useGdsTranslation as useGdsTranslation25 } from "@sovereignsquad/gds-theme";
|
|
4609
|
+
import { Alert as Alert2, Button as Button13, Group as Group19, Paper as Paper7, Stack as Stack15, Text as Text21 } from "@mantine/core";
|
|
4610
|
+
import { Fragment as Fragment6, jsx as jsx33, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
3786
4611
|
var GdsConfirmContext = createContext6(null);
|
|
3787
4612
|
function createConfirmationEvent(type, request, status) {
|
|
3788
4613
|
return {
|
|
@@ -3804,20 +4629,21 @@ function GdsConfirmProvider({
|
|
|
3804
4629
|
defaultTimeoutMs = 1e4,
|
|
3805
4630
|
onConfirmationEvent
|
|
3806
4631
|
}) {
|
|
3807
|
-
const
|
|
3808
|
-
const [
|
|
3809
|
-
const
|
|
3810
|
-
const
|
|
3811
|
-
const
|
|
3812
|
-
const
|
|
4632
|
+
const { t } = useGdsTranslation25();
|
|
4633
|
+
const [activeRequest, setActiveRequest] = useState18(null);
|
|
4634
|
+
const [undoState, setUndoState] = useState18(null);
|
|
4635
|
+
const activeResolver = useRef10(null);
|
|
4636
|
+
const actionResolver = useRef10(null);
|
|
4637
|
+
const focusReturnTarget = useRef10(null);
|
|
4638
|
+
const emit = useCallback11((type, request, status) => {
|
|
3813
4639
|
onConfirmationEvent?.(createConfirmationEvent(type, request, status));
|
|
3814
4640
|
}, [onConfirmationEvent]);
|
|
3815
|
-
const restoreFocus =
|
|
4641
|
+
const restoreFocus = useCallback11(() => {
|
|
3816
4642
|
const target = focusReturnTarget.current;
|
|
3817
4643
|
focusReturnTarget.current = null;
|
|
3818
4644
|
if (target) window.setTimeout(() => target.focus(), 0);
|
|
3819
4645
|
}, []);
|
|
3820
|
-
const openConfirm =
|
|
4646
|
+
const openConfirm = useCallback11((request) => new Promise((resolve) => {
|
|
3821
4647
|
if (activeResolver.current) {
|
|
3822
4648
|
activeResolver.current(false);
|
|
3823
4649
|
}
|
|
@@ -3826,7 +4652,7 @@ function GdsConfirmProvider({
|
|
|
3826
4652
|
emit("opened", request, "open");
|
|
3827
4653
|
setActiveRequest({ ...request, mode: "boolean", status: "open", resolve });
|
|
3828
4654
|
}), [emit]);
|
|
3829
|
-
const openActionConfirm =
|
|
4655
|
+
const openActionConfirm = useCallback11((request) => new Promise((resolve) => {
|
|
3830
4656
|
if (actionResolver.current) {
|
|
3831
4657
|
actionResolver.current({ status: "cancelled" });
|
|
3832
4658
|
}
|
|
@@ -3844,7 +4670,7 @@ function GdsConfirmProvider({
|
|
|
3844
4670
|
resolve: resolver
|
|
3845
4671
|
});
|
|
3846
4672
|
}), [emit]);
|
|
3847
|
-
const resolveActive =
|
|
4673
|
+
const resolveActive = useCallback11((confirmed) => {
|
|
3848
4674
|
if (activeRequest?.mode === "boolean") {
|
|
3849
4675
|
emit(confirmed ? "confirmed" : "cancelled", activeRequest, confirmed ? "succeeded" : "cancelled");
|
|
3850
4676
|
}
|
|
@@ -3853,7 +4679,7 @@ function GdsConfirmProvider({
|
|
|
3853
4679
|
setActiveRequest(null);
|
|
3854
4680
|
restoreFocus();
|
|
3855
4681
|
}, [activeRequest, emit, restoreFocus]);
|
|
3856
|
-
const cancelAction =
|
|
4682
|
+
const cancelAction = useCallback11(() => {
|
|
3857
4683
|
if (activeRequest?.mode === "action") {
|
|
3858
4684
|
emit("cancelled", activeRequest, "cancelled");
|
|
3859
4685
|
actionResolver.current?.({ status: "cancelled", payload: activeRequest.payload });
|
|
@@ -3862,7 +4688,7 @@ function GdsConfirmProvider({
|
|
|
3862
4688
|
setActiveRequest(null);
|
|
3863
4689
|
restoreFocus();
|
|
3864
4690
|
}, [activeRequest, emit, restoreFocus]);
|
|
3865
|
-
const runAction =
|
|
4691
|
+
const runAction = useCallback11(async (retry = false) => {
|
|
3866
4692
|
if (!activeRequest || activeRequest.mode !== "action") return;
|
|
3867
4693
|
const request = activeRequest;
|
|
3868
4694
|
if (retry) emit("retry", request, "executing");
|
|
@@ -3887,7 +4713,7 @@ function GdsConfirmProvider({
|
|
|
3887
4713
|
const undoPolicy = request.undo;
|
|
3888
4714
|
setUndoState({
|
|
3889
4715
|
id: request.id ?? "confirmation-undo",
|
|
3890
|
-
label: undoPolicy.label
|
|
4716
|
+
label: undoPolicy.label,
|
|
3891
4717
|
expiresAt,
|
|
3892
4718
|
onUndo: async () => {
|
|
3893
4719
|
emit("undo_started", request, "undoable");
|
|
@@ -3907,28 +4733,28 @@ function GdsConfirmProvider({
|
|
|
3907
4733
|
setActiveRequest(null);
|
|
3908
4734
|
restoreFocus();
|
|
3909
4735
|
} catch (error) {
|
|
3910
|
-
const message = error instanceof Error ? error.message :
|
|
4736
|
+
const message = error instanceof Error ? error.message : void 0;
|
|
3911
4737
|
emit("failed", request, "failed");
|
|
3912
4738
|
setActiveRequest({ ...request, status: "failed", error: message });
|
|
3913
4739
|
}
|
|
3914
4740
|
}, [activeRequest, defaultTimeoutMs, emit, restoreFocus]);
|
|
3915
|
-
const value =
|
|
4741
|
+
const value = useMemo11(() => ({
|
|
3916
4742
|
confirm: openConfirm,
|
|
3917
4743
|
confirmDestructive: (request) => openConfirm({ ...request, danger: true, confirmAction: request.confirmAction ?? "delete" }),
|
|
3918
4744
|
confirmAction: openActionConfirm
|
|
3919
4745
|
}), [openActionConfirm, openConfirm]);
|
|
3920
|
-
return /* @__PURE__ */
|
|
4746
|
+
return /* @__PURE__ */ jsxs23(GdsConfirmContext.Provider, { value, children: [
|
|
3921
4747
|
children,
|
|
3922
|
-
undoState ? /* @__PURE__ */
|
|
3923
|
-
/* @__PURE__ */
|
|
3924
|
-
/* @__PURE__ */
|
|
3925
|
-
/* @__PURE__ */
|
|
4748
|
+
undoState ? /* @__PURE__ */ jsx33(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__ */ jsxs23(Group19, { justify: "space-between", children: [
|
|
4749
|
+
/* @__PURE__ */ jsxs23(Stack15, { gap: 2, children: [
|
|
4750
|
+
/* @__PURE__ */ jsx33(Text21, { fw: 700, size: "sm", children: t("gds.confirm.undoTitle", "Action can be undone") }),
|
|
4751
|
+
/* @__PURE__ */ jsx33(Text21, { size: "sm", children: t("gds.confirm.undoDescription", "Undo is available until the recovery window expires.") })
|
|
3926
4752
|
] }),
|
|
3927
|
-
/* @__PURE__ */
|
|
4753
|
+
/* @__PURE__ */ jsx33(Button13, { size: "xs", variant: "default", onClick: () => {
|
|
3928
4754
|
void undoState.onUndo();
|
|
3929
|
-
}, children: undoState.label })
|
|
4755
|
+
}, children: undoState.label ?? t("gds.confirm.undo", "Undo") })
|
|
3930
4756
|
] }) }) : null,
|
|
3931
|
-
/* @__PURE__ */
|
|
4757
|
+
/* @__PURE__ */ jsx33(
|
|
3932
4758
|
ConfirmDialog,
|
|
3933
4759
|
{
|
|
3934
4760
|
opened: Boolean(activeRequest),
|
|
@@ -3939,18 +4765,18 @@ function GdsConfirmProvider({
|
|
|
3939
4765
|
cancelAction: activeRequest?.cancelAction ?? "cancel",
|
|
3940
4766
|
isDanger: activeRequest?.danger ?? false,
|
|
3941
4767
|
loading: activeRequest?.status === "executing" || activeRequest?.status === "validating",
|
|
3942
|
-
children: /* @__PURE__ */
|
|
3943
|
-
activeRequest?.targetName ? /* @__PURE__ */
|
|
3944
|
-
activeRequest?.targetName ? /* @__PURE__ */
|
|
4768
|
+
children: /* @__PURE__ */ jsxs23(Stack15, { gap: "xs", children: [
|
|
4769
|
+
activeRequest?.targetName ? /* @__PURE__ */ jsx33("strong", { children: activeRequest.targetName }) : null,
|
|
4770
|
+
activeRequest?.targetName ? /* @__PURE__ */ jsx33("br", {}) : null,
|
|
3945
4771
|
activeRequest?.message,
|
|
3946
|
-
activeRequest?.consequence ? /* @__PURE__ */
|
|
3947
|
-
/* @__PURE__ */
|
|
4772
|
+
activeRequest?.consequence ? /* @__PURE__ */ jsxs23(Fragment6, { children: [
|
|
4773
|
+
/* @__PURE__ */ jsx33("br", {}),
|
|
3948
4774
|
activeRequest.consequence
|
|
3949
4775
|
] }) : null,
|
|
3950
|
-
activeRequest?.mode === "action" && activeRequest.preview ? /* @__PURE__ */
|
|
3951
|
-
activeRequest?.mode === "action" && activeRequest.status === "failed" ? /* @__PURE__ */
|
|
3952
|
-
/* @__PURE__ */
|
|
3953
|
-
activeRequest.retryable ? /* @__PURE__ */
|
|
4776
|
+
activeRequest?.mode === "action" && activeRequest.preview ? /* @__PURE__ */ jsx33("div", { children: activeRequest.preview }) : null,
|
|
4777
|
+
activeRequest?.mode === "action" && activeRequest.status === "failed" ? /* @__PURE__ */ jsxs23(Alert2, { color: "red", title: t("gds.confirm.failedTitle", "Action failed"), role: "alert", children: [
|
|
4778
|
+
/* @__PURE__ */ jsx33(Text21, { size: "sm", children: activeRequest.error ?? t("gds.confirm.failedDescription", "The action did not complete.") }),
|
|
4779
|
+
activeRequest.retryable ? /* @__PURE__ */ jsx33(Text21, { size: "xs", children: t("gds.confirm.retryHint", "Use the primary action to retry.") }) : null
|
|
3954
4780
|
] }) : null
|
|
3955
4781
|
] })
|
|
3956
4782
|
}
|
|
@@ -3968,12 +4794,15 @@ var GdsToastContext = createContext6(null);
|
|
|
3968
4794
|
function createToastId(prefix) {
|
|
3969
4795
|
return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
3970
4796
|
}
|
|
3971
|
-
function GdsToastProvider({ children }) {
|
|
3972
|
-
return /* @__PURE__ */
|
|
4797
|
+
function GdsToastProvider({ children, viewport = true }) {
|
|
4798
|
+
return /* @__PURE__ */ jsxs23(GdsNotificationProvider, { children: [
|
|
4799
|
+
/* @__PURE__ */ jsx33(GdsToastProviderInner, { children }),
|
|
4800
|
+
viewport ? /* @__PURE__ */ jsx33(GdsToastViewport, { ...viewport === true ? {} : viewport }) : null
|
|
4801
|
+
] });
|
|
3973
4802
|
}
|
|
3974
4803
|
function GdsToastProviderInner({ children }) {
|
|
3975
4804
|
const { notify } = useGdsNotifications();
|
|
3976
|
-
const value =
|
|
4805
|
+
const value = useMemo11(() => ({
|
|
3977
4806
|
notifySuccess: (message) => notify({
|
|
3978
4807
|
...message,
|
|
3979
4808
|
id: message.id ?? createToastId("success"),
|
|
@@ -3985,7 +4814,7 @@ function GdsToastProviderInner({ children }) {
|
|
|
3985
4814
|
id: message.id ?? createToastId("error"),
|
|
3986
4815
|
severity: "error",
|
|
3987
4816
|
autoCloseMs: message.autoCloseMs ?? false,
|
|
3988
|
-
retry: message.retry ? { onRetry: message.retry, maxAttempts: 3
|
|
4817
|
+
retry: message.retry ? { onRetry: message.retry, maxAttempts: 3 } : void 0
|
|
3989
4818
|
}),
|
|
3990
4819
|
notifyActionComplete: (message) => notify({
|
|
3991
4820
|
...message,
|
|
@@ -3994,7 +4823,7 @@ function GdsToastProviderInner({ children }) {
|
|
|
3994
4823
|
autoCloseMs: message.autoCloseMs ?? 3e3
|
|
3995
4824
|
})
|
|
3996
4825
|
}), [notify]);
|
|
3997
|
-
return /* @__PURE__ */
|
|
4826
|
+
return /* @__PURE__ */ jsx33(GdsToastContext.Provider, { value, children });
|
|
3998
4827
|
}
|
|
3999
4828
|
function useGdsToasts() {
|
|
4000
4829
|
const context = useContext6(GdsToastContext);
|
|
@@ -4005,9 +4834,9 @@ function useGdsToasts() {
|
|
|
4005
4834
|
}
|
|
4006
4835
|
|
|
4007
4836
|
// src/CommandPalette.client.tsx
|
|
4008
|
-
import { createContext as createContext7, useContext as useContext7, useEffect as
|
|
4009
|
-
import { ActionIcon as ActionIcon3, Group as
|
|
4010
|
-
import { jsx as
|
|
4837
|
+
import { createContext as createContext7, useContext as useContext7, useEffect as useEffect9, useMemo as useMemo12, useState as useState19 } from "react";
|
|
4838
|
+
import { ActionIcon as ActionIcon3, Group as Group20, Modal as Modal3, Stack as Stack16, Text as Text22, TextInput as TextInput3 } from "@mantine/core";
|
|
4839
|
+
import { jsx as jsx34, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
4011
4840
|
var CommandPaletteContext = createContext7(null);
|
|
4012
4841
|
function normalize(text) {
|
|
4013
4842
|
return text.trim().toLowerCase();
|
|
@@ -4025,17 +4854,17 @@ function scoreCommand(command, query, recentUse) {
|
|
|
4025
4854
|
return 0.6 * prefix + 0.3 * keyword + 0.1 * recent;
|
|
4026
4855
|
}
|
|
4027
4856
|
function CommandRegistryProvider({ children }) {
|
|
4028
|
-
const [commands, setCommands] =
|
|
4029
|
-
const [opened, setOpened] =
|
|
4030
|
-
const value =
|
|
4857
|
+
const [commands, setCommands] = useState19([]);
|
|
4858
|
+
const [opened, setOpened] = useState19(false);
|
|
4859
|
+
const value = useMemo12(() => ({
|
|
4031
4860
|
commands,
|
|
4032
4861
|
registerCommands: (next) => setCommands(next),
|
|
4033
4862
|
open: () => setOpened(true),
|
|
4034
4863
|
close: () => setOpened(false)
|
|
4035
4864
|
}), [commands]);
|
|
4036
|
-
return /* @__PURE__ */
|
|
4865
|
+
return /* @__PURE__ */ jsxs24(CommandPaletteContext.Provider, { value, children: [
|
|
4037
4866
|
children,
|
|
4038
|
-
/* @__PURE__ */
|
|
4867
|
+
/* @__PURE__ */ jsx34(CommandPalette, { opened, onClose: () => setOpened(false) })
|
|
4039
4868
|
] });
|
|
4040
4869
|
}
|
|
4041
4870
|
function useCommandLauncher() {
|
|
@@ -4055,11 +4884,11 @@ function CommandPalette({ opened, onClose }) {
|
|
|
4055
4884
|
throw new Error("CommandPalette must be used within CommandRegistryProvider.");
|
|
4056
4885
|
}
|
|
4057
4886
|
const registry = contextValue;
|
|
4058
|
-
const [query, setQuery] =
|
|
4059
|
-
const [recentUse, setRecentUse] =
|
|
4887
|
+
const [query, setQuery] = useState19("");
|
|
4888
|
+
const [recentUse, setRecentUse] = useState19({});
|
|
4060
4889
|
const enabledCommands = registry.commands.filter((command) => command.enabledWhen ? command.enabledWhen() : true);
|
|
4061
4890
|
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
|
-
|
|
4891
|
+
useEffect9(() => {
|
|
4063
4892
|
function onKeyDown(event) {
|
|
4064
4893
|
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
|
|
4065
4894
|
event.preventDefault();
|
|
@@ -4072,8 +4901,8 @@ function CommandPalette({ opened, onClose }) {
|
|
|
4072
4901
|
window.addEventListener("keydown", onKeyDown);
|
|
4073
4902
|
return () => window.removeEventListener("keydown", onKeyDown);
|
|
4074
4903
|
}, [registry, opened, onClose]);
|
|
4075
|
-
return /* @__PURE__ */
|
|
4076
|
-
/* @__PURE__ */
|
|
4904
|
+
return /* @__PURE__ */ jsx34(Modal3, { opened, onClose, title: "Quick actions", centered: true, children: /* @__PURE__ */ jsxs24(Stack16, { gap: "sm", children: [
|
|
4905
|
+
/* @__PURE__ */ jsx34(
|
|
4077
4906
|
TextInput3,
|
|
4078
4907
|
{
|
|
4079
4908
|
"aria-label": "Command search",
|
|
@@ -4082,8 +4911,8 @@ function CommandPalette({ opened, onClose }) {
|
|
|
4082
4911
|
onChange: (event) => setQuery(event.currentTarget.value)
|
|
4083
4912
|
}
|
|
4084
4913
|
),
|
|
4085
|
-
filteredCommands.length === 0 ? /* @__PURE__ */
|
|
4086
|
-
/* @__PURE__ */
|
|
4914
|
+
filteredCommands.length === 0 ? /* @__PURE__ */ jsx34(Text22, { size: "sm", c: "dimmed", children: "No matching commands." }) : filteredCommands.map((command) => /* @__PURE__ */ jsxs24(Group20, { justify: "space-between", wrap: "nowrap", children: [
|
|
4915
|
+
/* @__PURE__ */ jsx34(
|
|
4087
4916
|
"button",
|
|
4088
4917
|
{
|
|
4089
4918
|
type: "button",
|
|
@@ -4096,26 +4925,26 @@ function CommandPalette({ opened, onClose }) {
|
|
|
4096
4925
|
children: command.label
|
|
4097
4926
|
}
|
|
4098
4927
|
),
|
|
4099
|
-
command.shortcut ? /* @__PURE__ */
|
|
4928
|
+
command.shortcut ? /* @__PURE__ */ jsx34(Text22, { size: "xs", c: "dimmed", children: command.shortcut }) : null
|
|
4100
4929
|
] }, command.id)),
|
|
4101
|
-
/* @__PURE__ */
|
|
4930
|
+
/* @__PURE__ */ jsx34(Group20, { justify: "flex-end", children: /* @__PURE__ */ jsx34(ActionIcon3, { variant: "subtle", "aria-label": "Close command palette", onClick: onClose, children: /* @__PURE__ */ jsx34(GdsIcons.Close, { size: "1rem" }) }) })
|
|
4102
4931
|
] }) });
|
|
4103
4932
|
}
|
|
4104
4933
|
|
|
4105
4934
|
// src/GdsTour.client.tsx
|
|
4106
4935
|
import {
|
|
4107
4936
|
createContext as createContext8,
|
|
4108
|
-
useCallback as
|
|
4937
|
+
useCallback as useCallback12,
|
|
4109
4938
|
useContext as useContext8,
|
|
4110
|
-
useEffect as
|
|
4939
|
+
useEffect as useEffect10,
|
|
4111
4940
|
useLayoutEffect,
|
|
4112
|
-
useMemo as
|
|
4113
|
-
useRef as
|
|
4114
|
-
useState as
|
|
4941
|
+
useMemo as useMemo13,
|
|
4942
|
+
useRef as useRef11,
|
|
4943
|
+
useState as useState20
|
|
4115
4944
|
} from "react";
|
|
4116
4945
|
import { createPortal } from "react-dom";
|
|
4117
|
-
import { useGdsTranslation as
|
|
4118
|
-
import { Fragment as
|
|
4946
|
+
import { useGdsTranslation as useGdsTranslation26 } from "@sovereignsquad/gds-theme";
|
|
4947
|
+
import { Fragment as Fragment7, jsx as jsx35, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
4119
4948
|
var GdsTourContext = createContext8(null);
|
|
4120
4949
|
var SEEN_KEY_PREFIX = "gds-tour-seen:";
|
|
4121
4950
|
function hasSeen(tourId) {
|
|
@@ -4134,8 +4963,8 @@ function markSeen(tourId) {
|
|
|
4134
4963
|
}
|
|
4135
4964
|
}
|
|
4136
4965
|
function useHasSeenTour(tourId) {
|
|
4137
|
-
const [seen, setSeen] =
|
|
4138
|
-
|
|
4966
|
+
const [seen, setSeen] = useState20(false);
|
|
4967
|
+
useEffect10(() => {
|
|
4139
4968
|
setSeen(hasSeen(tourId));
|
|
4140
4969
|
}, [tourId]);
|
|
4141
4970
|
return seen;
|
|
@@ -4190,29 +5019,29 @@ function computeCardPosition(hole, card, placement) {
|
|
|
4190
5019
|
}
|
|
4191
5020
|
var FOCUSABLE = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
4192
5021
|
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 =
|
|
4205
|
-
|
|
5022
|
+
const { t } = useGdsTranslation26();
|
|
5023
|
+
const [tourId, setTourId] = useState20(null);
|
|
5024
|
+
const [steps, setSteps] = useState20([]);
|
|
5025
|
+
const [index, setIndex] = useState20(0);
|
|
5026
|
+
const [status, setStatus] = useState20("idle");
|
|
5027
|
+
const [rect, setRect] = useState20(null);
|
|
5028
|
+
const [cardPos, setCardPos] = useState20(null);
|
|
5029
|
+
const [mounted, setMounted] = useState20(false);
|
|
5030
|
+
const optionsRef = useRef11({});
|
|
5031
|
+
const invokerRef = useRef11(null);
|
|
5032
|
+
const cardRef = useRef11(null);
|
|
5033
|
+
const targetElRef = useRef11(null);
|
|
5034
|
+
useEffect10(() => setMounted(true), []);
|
|
4206
5035
|
const running = status === "running";
|
|
4207
5036
|
const activeStep = running ? steps[index] ?? null : null;
|
|
4208
5037
|
const count = steps.length;
|
|
4209
|
-
const clearActiveTargetAttr =
|
|
5038
|
+
const clearActiveTargetAttr = useCallback12(() => {
|
|
4210
5039
|
if (targetElRef.current) {
|
|
4211
5040
|
targetElRef.current.removeAttribute("data-gds-tour-active-target");
|
|
4212
5041
|
targetElRef.current = null;
|
|
4213
5042
|
}
|
|
4214
5043
|
}, []);
|
|
4215
|
-
const finish =
|
|
5044
|
+
const finish = useCallback12(
|
|
4216
5045
|
(nextStatus, reason) => {
|
|
4217
5046
|
const opts = optionsRef.current;
|
|
4218
5047
|
const id = tourId;
|
|
@@ -4231,10 +5060,10 @@ function GdsTourProvider({ children }) {
|
|
|
4231
5060
|
},
|
|
4232
5061
|
[clearActiveTargetAttr, tourId]
|
|
4233
5062
|
);
|
|
4234
|
-
const stop =
|
|
5063
|
+
const stop = useCallback12((reason = "programmatic") => {
|
|
4235
5064
|
finish(reason === "finished" ? "finished" : "skipped", reason);
|
|
4236
5065
|
}, [finish]);
|
|
4237
|
-
const start =
|
|
5066
|
+
const start = useCallback12(
|
|
4238
5067
|
(id, tourSteps, options = {}) => {
|
|
4239
5068
|
if (!tourSteps.length) return;
|
|
4240
5069
|
optionsRef.current = options;
|
|
@@ -4246,7 +5075,7 @@ function GdsTourProvider({ children }) {
|
|
|
4246
5075
|
},
|
|
4247
5076
|
[]
|
|
4248
5077
|
);
|
|
4249
|
-
const goTo =
|
|
5078
|
+
const goTo = useCallback12(
|
|
4250
5079
|
(nextIndex) => {
|
|
4251
5080
|
setIndex((current) => {
|
|
4252
5081
|
const clamped = Math.max(0, Math.min(nextIndex, steps.length - 1));
|
|
@@ -4256,14 +5085,14 @@ function GdsTourProvider({ children }) {
|
|
|
4256
5085
|
},
|
|
4257
5086
|
[steps]
|
|
4258
5087
|
);
|
|
4259
|
-
const next =
|
|
5088
|
+
const next = useCallback12(() => {
|
|
4260
5089
|
if (index >= steps.length - 1) {
|
|
4261
5090
|
finish("finished", "finished");
|
|
4262
5091
|
} else {
|
|
4263
5092
|
goTo(index + 1);
|
|
4264
5093
|
}
|
|
4265
5094
|
}, [index, steps.length, finish, goTo]);
|
|
4266
|
-
const back =
|
|
5095
|
+
const back = useCallback12(() => {
|
|
4267
5096
|
if (index > 0) goTo(index - 1);
|
|
4268
5097
|
}, [index, goTo]);
|
|
4269
5098
|
useLayoutEffect(() => {
|
|
@@ -4309,7 +5138,7 @@ function GdsTourProvider({ children }) {
|
|
|
4309
5138
|
ro?.disconnect();
|
|
4310
5139
|
};
|
|
4311
5140
|
}, [running, activeStep, index, next]);
|
|
4312
|
-
|
|
5141
|
+
useEffect10(() => {
|
|
4313
5142
|
if (!running) return void 0;
|
|
4314
5143
|
const previousOverflow = document.body.style.overflow;
|
|
4315
5144
|
document.body.style.overflow = "hidden";
|
|
@@ -4324,7 +5153,7 @@ function GdsTourProvider({ children }) {
|
|
|
4324
5153
|
window.clearTimeout(focusCard);
|
|
4325
5154
|
};
|
|
4326
5155
|
}, [running, index]);
|
|
4327
|
-
|
|
5156
|
+
useEffect10(() => {
|
|
4328
5157
|
if (!running || !activeStep) return void 0;
|
|
4329
5158
|
const onKeyDown = (event) => {
|
|
4330
5159
|
if (event.key === "Escape") {
|
|
@@ -4366,20 +5195,20 @@ function GdsTourProvider({ children }) {
|
|
|
4366
5195
|
window.addEventListener("keydown", onKeyDown, true);
|
|
4367
5196
|
return () => window.removeEventListener("keydown", onKeyDown, true);
|
|
4368
5197
|
}, [running, activeStep, next, back, finish]);
|
|
4369
|
-
const value =
|
|
5198
|
+
const value = useMemo13(
|
|
4370
5199
|
() => ({ status, tourId, index, count, activeStep, start, next, back, goTo, stop }),
|
|
4371
5200
|
[status, tourId, index, count, activeStep, start, next, back, goTo, stop]
|
|
4372
5201
|
);
|
|
4373
5202
|
const overlay = mounted && running && activeStep && rect ? createPortal(
|
|
4374
|
-
/* @__PURE__ */
|
|
4375
|
-
/* @__PURE__ */
|
|
5203
|
+
/* @__PURE__ */ jsxs25(Fragment7, { children: [
|
|
5204
|
+
/* @__PURE__ */ jsxs25(
|
|
4376
5205
|
"div",
|
|
4377
5206
|
{
|
|
4378
5207
|
className: `gds-tour-spotlight${activeStep.interaction === "allow-target" ? " gds-tour-spotlight--interactive" : ""}`,
|
|
4379
5208
|
"data-gds-tour-overlay": "",
|
|
4380
5209
|
children: [
|
|
4381
|
-
activeStep.interaction !== "allow-target" ? /* @__PURE__ */
|
|
4382
|
-
/* @__PURE__ */
|
|
5210
|
+
activeStep.interaction !== "allow-target" ? /* @__PURE__ */ jsx35("div", { className: "gds-tour-spotlight__blocker", "aria-hidden": "true" }) : null,
|
|
5211
|
+
/* @__PURE__ */ jsx35(
|
|
4383
5212
|
"div",
|
|
4384
5213
|
{
|
|
4385
5214
|
className: "gds-tour-spotlight__hole",
|
|
@@ -4390,7 +5219,7 @@ function GdsTourProvider({ children }) {
|
|
|
4390
5219
|
]
|
|
4391
5220
|
}
|
|
4392
5221
|
),
|
|
4393
|
-
/* @__PURE__ */
|
|
5222
|
+
/* @__PURE__ */ jsxs25(
|
|
4394
5223
|
"div",
|
|
4395
5224
|
{
|
|
4396
5225
|
ref: cardRef,
|
|
@@ -4402,11 +5231,11 @@ function GdsTourProvider({ children }) {
|
|
|
4402
5231
|
tabIndex: -1,
|
|
4403
5232
|
style: cardPos ? { top: cardPos.top, left: cardPos.left } : { top: 16, left: 16, visibility: "hidden" },
|
|
4404
5233
|
children: [
|
|
4405
|
-
/* @__PURE__ */
|
|
4406
|
-
/* @__PURE__ */
|
|
4407
|
-
/* @__PURE__ */
|
|
4408
|
-
/* @__PURE__ */
|
|
4409
|
-
activeStep.canSkip !== false ? /* @__PURE__ */
|
|
5234
|
+
/* @__PURE__ */ jsx35("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)) }),
|
|
5235
|
+
/* @__PURE__ */ jsx35("h2", { id: "gds-tour-title", className: "gds-tour-card__title", children: activeStep.title }),
|
|
5236
|
+
/* @__PURE__ */ jsx35("div", { id: "gds-tour-body", className: "gds-tour-card__body", children: activeStep.body }),
|
|
5237
|
+
/* @__PURE__ */ jsxs25("div", { className: "gds-tour-card__actions", children: [
|
|
5238
|
+
activeStep.canSkip !== false ? /* @__PURE__ */ jsx35(
|
|
4410
5239
|
"button",
|
|
4411
5240
|
{
|
|
4412
5241
|
type: "button",
|
|
@@ -4414,10 +5243,10 @@ function GdsTourProvider({ children }) {
|
|
|
4414
5243
|
onClick: () => finish("skipped", "skipped"),
|
|
4415
5244
|
children: t("gds.tour.skip", "Skip")
|
|
4416
5245
|
}
|
|
4417
|
-
) : /* @__PURE__ */
|
|
4418
|
-
/* @__PURE__ */
|
|
4419
|
-
index > 0 ? /* @__PURE__ */
|
|
4420
|
-
/* @__PURE__ */
|
|
5246
|
+
) : /* @__PURE__ */ jsx35("span", {}),
|
|
5247
|
+
/* @__PURE__ */ jsxs25("div", { className: "gds-tour-card__nav", children: [
|
|
5248
|
+
index > 0 ? /* @__PURE__ */ jsx35("button", { type: "button", className: "gds-tour-btn gds-tour-btn--secondary", onClick: back, children: t("gds.tour.back", "Back") }) : null,
|
|
5249
|
+
/* @__PURE__ */ jsx35("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
5250
|
] })
|
|
4422
5251
|
] })
|
|
4423
5252
|
]
|
|
@@ -4426,7 +5255,7 @@ function GdsTourProvider({ children }) {
|
|
|
4426
5255
|
] }),
|
|
4427
5256
|
document.body
|
|
4428
5257
|
) : null;
|
|
4429
|
-
return /* @__PURE__ */
|
|
5258
|
+
return /* @__PURE__ */ jsxs25(GdsTourContext.Provider, { value, children: [
|
|
4430
5259
|
children,
|
|
4431
5260
|
overlay
|
|
4432
5261
|
] });
|
|
@@ -4440,8 +5269,8 @@ function useGdsTour() {
|
|
|
4440
5269
|
}
|
|
4441
5270
|
function GdsGuidedTour({ id, steps, open = false, defaultStep, ...options }) {
|
|
4442
5271
|
const { start, status } = useGdsTour();
|
|
4443
|
-
const startedRef =
|
|
4444
|
-
|
|
5272
|
+
const startedRef = useRef11(false);
|
|
5273
|
+
useEffect10(() => {
|
|
4445
5274
|
if (!open || startedRef.current || status === "running") return;
|
|
4446
5275
|
if (options.persist === "localStorage" && hasSeen(id)) return;
|
|
4447
5276
|
startedRef.current = true;
|
|
@@ -4463,8 +5292,8 @@ function GdsTourButton({
|
|
|
4463
5292
|
...buttonProps
|
|
4464
5293
|
}) {
|
|
4465
5294
|
const { start } = useGdsTour();
|
|
4466
|
-
const { t } =
|
|
4467
|
-
return /* @__PURE__ */
|
|
5295
|
+
const { t } = useGdsTranslation26();
|
|
5296
|
+
return /* @__PURE__ */ jsx35(
|
|
4468
5297
|
"button",
|
|
4469
5298
|
{
|
|
4470
5299
|
type: "button",
|
|
@@ -4477,10 +5306,10 @@ function GdsTourButton({
|
|
|
4477
5306
|
}
|
|
4478
5307
|
|
|
4479
5308
|
// src/LayoutTemplatePreview.client.tsx
|
|
4480
|
-
import { useGdsTranslation as
|
|
4481
|
-
import { useMemo as
|
|
4482
|
-
import { Alert as Alert3, Button as
|
|
4483
|
-
import { jsx as
|
|
5309
|
+
import { useGdsTranslation as useGdsTranslation27 } from "@sovereignsquad/gds-theme";
|
|
5310
|
+
import { useMemo as useMemo14, useState as useState21 } from "react";
|
|
5311
|
+
import { Alert as Alert3, Button as Button14, Group as Group21, NativeSelect as NativeSelect2, Stack as Stack17, Text as Text23, Textarea } from "@mantine/core";
|
|
5312
|
+
import { jsx as jsx36, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
4484
5313
|
function templateText(template) {
|
|
4485
5314
|
return JSON.stringify(template.schema, null, 2);
|
|
4486
5315
|
}
|
|
@@ -4493,24 +5322,24 @@ function GdsLayoutTemplatePreview({
|
|
|
4493
5322
|
title: titleProp,
|
|
4494
5323
|
description: descriptionProp
|
|
4495
5324
|
}) {
|
|
4496
|
-
const { t } =
|
|
5325
|
+
const { t } = useGdsTranslation27();
|
|
4497
5326
|
const title = titleProp ?? t("gds.layoutTemplatePreview.title", "Template cookbook");
|
|
4498
5327
|
const description = descriptionProp ?? t("gds.layoutTemplatePreview.description", "Pick a template, edit JSON, then apply to preview live diagnostics and rendered layout.");
|
|
4499
5328
|
const initialTemplate = templates.find((template) => template.id === initialTemplateId) ?? templates[0];
|
|
4500
5329
|
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] =
|
|
5330
|
+
const [selectedTemplateId, setSelectedTemplateId] = useState21(initialTemplate?.id ?? "");
|
|
5331
|
+
const [schemaText, setSchemaText] = useState21(initialText);
|
|
5332
|
+
const [appliedSchemaText, setAppliedSchemaText] = useState21(initialText);
|
|
5333
|
+
const [editorError, setEditorError] = useState21("");
|
|
5334
|
+
const [copyState, setCopyState] = useState21("idle");
|
|
4506
5335
|
const selectedTemplate = templates.find((template) => template.id === selectedTemplateId);
|
|
4507
|
-
const renderedTemplate =
|
|
5336
|
+
const renderedTemplate = useMemo14(() => {
|
|
4508
5337
|
try {
|
|
4509
5338
|
return renderGdsLayoutWithDiagnostics(parseSchema(appliedSchemaText));
|
|
4510
5339
|
} catch {
|
|
4511
5340
|
return {
|
|
4512
5341
|
issues: [{ blockId: "schema", message: "Unable to parse schema JSON. Make sure the payload is valid JSON." }],
|
|
4513
|
-
node: /* @__PURE__ */
|
|
5342
|
+
node: /* @__PURE__ */ jsx36(
|
|
4514
5343
|
StateBlock,
|
|
4515
5344
|
{
|
|
4516
5345
|
variant: "error",
|
|
@@ -4559,8 +5388,8 @@ function GdsLayoutTemplatePreview({
|
|
|
4559
5388
|
}
|
|
4560
5389
|
};
|
|
4561
5390
|
const issueCount = renderedTemplate.issues.length;
|
|
4562
|
-
return /* @__PURE__ */
|
|
4563
|
-
/* @__PURE__ */
|
|
5391
|
+
return /* @__PURE__ */ jsx36(SectionPanel, { title, description, children: /* @__PURE__ */ jsxs26(Stack17, { gap: "md", children: [
|
|
5392
|
+
/* @__PURE__ */ jsx36(
|
|
4564
5393
|
NativeSelect2,
|
|
4565
5394
|
{
|
|
4566
5395
|
label: "Template preset",
|
|
@@ -4570,7 +5399,7 @@ function GdsLayoutTemplatePreview({
|
|
|
4570
5399
|
data: templates.map((template) => ({ value: template.id, label: template.title }))
|
|
4571
5400
|
}
|
|
4572
5401
|
),
|
|
4573
|
-
/* @__PURE__ */
|
|
5402
|
+
/* @__PURE__ */ jsx36(
|
|
4574
5403
|
Textarea,
|
|
4575
5404
|
{
|
|
4576
5405
|
label: "Current template summary",
|
|
@@ -4581,7 +5410,7 @@ Use case: ${selectedTemplate.useCase}` : "",
|
|
|
4581
5410
|
minRows: 2
|
|
4582
5411
|
}
|
|
4583
5412
|
),
|
|
4584
|
-
/* @__PURE__ */
|
|
5413
|
+
/* @__PURE__ */ jsx36(
|
|
4585
5414
|
Textarea,
|
|
4586
5415
|
{
|
|
4587
5416
|
label: "Layout schema JSON",
|
|
@@ -4592,19 +5421,19 @@ Use case: ${selectedTemplate.useCase}` : "",
|
|
|
4592
5421
|
onChange: (event) => setSchemaText(event.currentTarget.value)
|
|
4593
5422
|
}
|
|
4594
5423
|
),
|
|
4595
|
-
/* @__PURE__ */
|
|
4596
|
-
/* @__PURE__ */
|
|
4597
|
-
/* @__PURE__ */
|
|
4598
|
-
/* @__PURE__ */
|
|
5424
|
+
/* @__PURE__ */ jsxs26(Group21, { gap: "sm", children: [
|
|
5425
|
+
/* @__PURE__ */ jsx36(Button14, { type: "button", onClick: applySchema, children: "Apply schema" }),
|
|
5426
|
+
/* @__PURE__ */ jsx36(Button14, { type: "button", variant: "default", onClick: resetTemplate, children: "Reset to template" }),
|
|
5427
|
+
/* @__PURE__ */ jsx36(Button14, { type: "button", variant: "light", onClick: () => void copySchema(), children: "Copy schema" })
|
|
4599
5428
|
] }),
|
|
4600
|
-
editorError ? /* @__PURE__ */
|
|
4601
|
-
copyState === "success" ? /* @__PURE__ */
|
|
4602
|
-
copyState === "error" ? /* @__PURE__ */
|
|
4603
|
-
/* @__PURE__ */
|
|
5429
|
+
editorError ? /* @__PURE__ */ jsx36(StateBlock, { variant: "error", title: "Invalid JSON", description: editorError }) : null,
|
|
5430
|
+
copyState === "success" ? /* @__PURE__ */ jsx36(Alert3, { color: "green", children: "Schema copied to clipboard." }) : null,
|
|
5431
|
+
copyState === "error" ? /* @__PURE__ */ jsx36(Alert3, { color: "yellow", children: "Clipboard copy is unavailable in this browser context." }) : null,
|
|
5432
|
+
/* @__PURE__ */ jsxs26(Text23, { "aria-live": "polite", children: [
|
|
4604
5433
|
"Diagnostic result: ",
|
|
4605
5434
|
issueCount === 0 ? "no issues" : `${issueCount} issue${issueCount === 1 ? "" : "s"}`
|
|
4606
5435
|
] }),
|
|
4607
|
-
/* @__PURE__ */
|
|
5436
|
+
/* @__PURE__ */ jsx36(
|
|
4608
5437
|
SectionPanel,
|
|
4609
5438
|
{
|
|
4610
5439
|
title: `Schema render preview (${selectedTemplate?.schema.version ?? "1"})`,
|
|
@@ -4612,7 +5441,7 @@ Use case: ${selectedTemplate.useCase}` : "",
|
|
|
4612
5441
|
children: renderedTemplate.node
|
|
4613
5442
|
}
|
|
4614
5443
|
),
|
|
4615
|
-
issueCount ? /* @__PURE__ */
|
|
5444
|
+
issueCount ? /* @__PURE__ */ jsx36(SectionPanel, { title: "Schema issues", description: "Fix these payload issues before using the template in production code.", children: /* @__PURE__ */ jsx36(Stack17, { component: "ul", gap: 4, children: renderedTemplate.issues.map((issue, index) => /* @__PURE__ */ jsxs26("li", { children: [
|
|
4616
5445
|
issue.blockId ? `${issue.blockId}: ` : "",
|
|
4617
5446
|
issue.message
|
|
4618
5447
|
] }, `${issue.blockId ?? "schema"}-${index}`)) }) }) : null
|
|
@@ -4620,8 +5449,8 @@ Use case: ${selectedTemplate.useCase}` : "",
|
|
|
4620
5449
|
}
|
|
4621
5450
|
|
|
4622
5451
|
// src/Telemetry.client.tsx
|
|
4623
|
-
import { createContext as createContext9, useContext as useContext9, useMemo as
|
|
4624
|
-
import { jsx as
|
|
5452
|
+
import { createContext as createContext9, useContext as useContext9, useMemo as useMemo15 } from "react";
|
|
5453
|
+
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
4625
5454
|
var gdsOperationalEventTypes = [
|
|
4626
5455
|
"submit",
|
|
4627
5456
|
"submit_success",
|
|
@@ -4840,11 +5669,11 @@ function GdsTelemetryProvider({
|
|
|
4840
5669
|
payloadPolicy,
|
|
4841
5670
|
onAdapterError
|
|
4842
5671
|
}) {
|
|
4843
|
-
const value =
|
|
5672
|
+
const value = useMemo15(() => ({
|
|
4844
5673
|
emit: (event) => emitGdsEvent({ adapter, sink, sampleRate, payloadPolicy, onAdapterError }, event),
|
|
4845
5674
|
emitGdsEvent: (event) => emitGdsEvent({ adapter, sink, sampleRate, payloadPolicy, onAdapterError }, event)
|
|
4846
5675
|
}), [adapter, onAdapterError, payloadPolicy, sampleRate, sink]);
|
|
4847
|
-
return /* @__PURE__ */
|
|
5676
|
+
return /* @__PURE__ */ jsx37(GdsTelemetryContext.Provider, { value, children });
|
|
4848
5677
|
}
|
|
4849
5678
|
function useGdsTelemetry() {
|
|
4850
5679
|
const context = useContext9(GdsTelemetryContext);
|
|
@@ -4855,8 +5684,8 @@ function useGdsTelemetry() {
|
|
|
4855
5684
|
}
|
|
4856
5685
|
|
|
4857
5686
|
// src/PublicCaptureFlow.tsx
|
|
4858
|
-
import { Stack as
|
|
4859
|
-
import { jsx as
|
|
5687
|
+
import { Stack as Stack18, Text as Text24 } from "@mantine/core";
|
|
5688
|
+
import { jsx as jsx38, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
4860
5689
|
var stageCopy = {
|
|
4861
5690
|
identify: { title: "Who are you?", description: "Enter the information required for this public flow." },
|
|
4862
5691
|
consent: { title: "Review consent", description: "Confirm the required consent before continuing." },
|
|
@@ -4875,10 +5704,10 @@ function toFlowStatus(state) {
|
|
|
4875
5704
|
}
|
|
4876
5705
|
function runtimeStateBody(state) {
|
|
4877
5706
|
if (state === "permission-denied") {
|
|
4878
|
-
return /* @__PURE__ */
|
|
5707
|
+
return /* @__PURE__ */ jsx38(StateBlock, { variant: "permission", title: "Permission required", description: "Allow access or use the provided recovery action to continue." });
|
|
4879
5708
|
}
|
|
4880
5709
|
if (state === "hardware-unavailable") {
|
|
4881
|
-
return /* @__PURE__ */
|
|
5710
|
+
return /* @__PURE__ */ jsx38(StateBlock, { variant: "error", title: "Capture unavailable", description: "The required hardware surface is not available on this device." });
|
|
4882
5711
|
}
|
|
4883
5712
|
return null;
|
|
4884
5713
|
}
|
|
@@ -4896,8 +5725,8 @@ function PublicCaptureFlow({
|
|
|
4896
5725
|
}) {
|
|
4897
5726
|
const copy = stageCopy[stage];
|
|
4898
5727
|
const runtimeBody = runtimeStateBody(state);
|
|
4899
|
-
const flowBody = runtimeBody ?? (stage === "share" && share ? /* @__PURE__ */
|
|
4900
|
-
return /* @__PURE__ */
|
|
5728
|
+
const flowBody = runtimeBody ?? (stage === "share" && share ? /* @__PURE__ */ jsx38(PublicShareOverlay, { ...share }) : body);
|
|
5729
|
+
return /* @__PURE__ */ jsx38(
|
|
4901
5730
|
PublicFlowShell,
|
|
4902
5731
|
{
|
|
4903
5732
|
exitAction,
|
|
@@ -4915,34 +5744,34 @@ function PublicCaptureFlow({
|
|
|
4915
5744
|
);
|
|
4916
5745
|
}
|
|
4917
5746
|
function PublicIdentityStep({ children }) {
|
|
4918
|
-
return /* @__PURE__ */
|
|
5747
|
+
return /* @__PURE__ */ jsx38(Stack18, { gap: "md", children });
|
|
4919
5748
|
}
|
|
4920
5749
|
function PublicConsentStep({ consentText, control }) {
|
|
4921
|
-
return /* @__PURE__ */
|
|
4922
|
-
/* @__PURE__ */
|
|
5750
|
+
return /* @__PURE__ */ jsxs27(Stack18, { gap: "md", children: [
|
|
5751
|
+
/* @__PURE__ */ jsx38(Text24, { children: consentText }),
|
|
4923
5752
|
control
|
|
4924
5753
|
] });
|
|
4925
5754
|
}
|
|
4926
5755
|
function PublicAcceptStep({ preview, actions }) {
|
|
4927
|
-
return /* @__PURE__ */
|
|
5756
|
+
return /* @__PURE__ */ jsxs27(Stack18, { gap: "md", children: [
|
|
4928
5757
|
preview,
|
|
4929
5758
|
actions
|
|
4930
5759
|
] });
|
|
4931
5760
|
}
|
|
4932
5761
|
function PublicCtaStep({ children }) {
|
|
4933
|
-
return /* @__PURE__ */
|
|
5762
|
+
return /* @__PURE__ */ jsx38(Stack18, { gap: "md", children });
|
|
4934
5763
|
}
|
|
4935
5764
|
function PublicRestartStep({ children }) {
|
|
4936
|
-
return /* @__PURE__ */
|
|
5765
|
+
return /* @__PURE__ */ jsx38(Stack18, { gap: "md", children });
|
|
4937
5766
|
}
|
|
4938
5767
|
function PublicShareOverlay(props) {
|
|
4939
|
-
return /* @__PURE__ */
|
|
5768
|
+
return /* @__PURE__ */ jsx38(ShareButtonGroup, { ...props });
|
|
4940
5769
|
}
|
|
4941
5770
|
|
|
4942
5771
|
// src/PlaybackControls.client.tsx
|
|
4943
|
-
import { useEffect as
|
|
4944
|
-
import { ActionIcon as ActionIcon4, Group as
|
|
4945
|
-
import { jsx as
|
|
5772
|
+
import { useEffect as useEffect11 } from "react";
|
|
5773
|
+
import { ActionIcon as ActionIcon4, Group as Group22, Text as Text25 } from "@mantine/core";
|
|
5774
|
+
import { jsx as jsx39, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
4946
5775
|
function isInteractiveTarget(target) {
|
|
4947
5776
|
if (!(target instanceof HTMLElement)) return false;
|
|
4948
5777
|
return ["INPUT", "TEXTAREA", "SELECT", "BUTTON", "A"].includes(target.tagName) || target.isContentEditable;
|
|
@@ -4954,7 +5783,7 @@ function usePlaybackKeyboardControls({
|
|
|
4954
5783
|
onPrevious,
|
|
4955
5784
|
onFullscreenToggle
|
|
4956
5785
|
}) {
|
|
4957
|
-
|
|
5786
|
+
useEffect11(() => {
|
|
4958
5787
|
if (!enabled) return void 0;
|
|
4959
5788
|
const handler = (event) => {
|
|
4960
5789
|
if (event.defaultPrevented || isInteractiveTarget(event.target)) return;
|
|
@@ -4986,33 +5815,127 @@ function PlaybackControls({
|
|
|
4986
5815
|
}) {
|
|
4987
5816
|
const playing = state === "playing";
|
|
4988
5817
|
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__ */
|
|
5818
|
+
return /* @__PURE__ */ jsxs28(Group22, { gap: "xs", wrap: "wrap", align: "center", children: [
|
|
5819
|
+
/* @__PURE__ */ jsx39(ActionIcon4, { variant: "default", size: "lg", "aria-label": "Previous", onClick: onPrevious, disabled: disabled || !canGoPrevious, children: /* @__PURE__ */ jsx39(GdsIcons.Back, { size: "1rem" }) }),
|
|
5820
|
+
/* @__PURE__ */ jsx39(ActionIcon4, { variant: "filled", size: "lg", "aria-label": playing ? "Pause" : "Play", onClick: onPlayPause, disabled, children: playing ? /* @__PURE__ */ jsx39(GdsIcons.Pause, { size: "1rem" }) : /* @__PURE__ */ jsx39(GdsIcons.Play, { size: "1rem" }) }),
|
|
5821
|
+
/* @__PURE__ */ jsx39(ActionIcon4, { variant: "default", size: "lg", "aria-label": "Next", onClick: onNext, disabled: disabled || !canGoNext, children: /* @__PURE__ */ jsx39(GdsIcons.Forward, { size: "1rem" }) }),
|
|
5822
|
+
onRestart ? /* @__PURE__ */ jsx39(ActionIcon4, { variant: "subtle", size: "lg", "aria-label": "Restart", onClick: onRestart, disabled: state === "loading", children: /* @__PURE__ */ jsx39(GdsIcons.Refresh, { size: "1rem" }) }) : null,
|
|
5823
|
+
onFullscreenChange ? /* @__PURE__ */ jsx39(ActionIcon4, { variant: "subtle", size: "lg", "aria-label": fullscreen ? "Exit fullscreen" : "Enter fullscreen", onClick: () => onFullscreenChange(!fullscreen), children: /* @__PURE__ */ jsx39(GdsIcons.Launch, { size: "1rem" }) }) : null,
|
|
5824
|
+
/* @__PURE__ */ jsx39(Text25, { size: "sm", c: "dimmed", "aria-live": "polite", children: state })
|
|
4996
5825
|
] });
|
|
4997
5826
|
}
|
|
4998
5827
|
function PlaybackOverlayControls(props) {
|
|
4999
|
-
return /* @__PURE__ */
|
|
5828
|
+
return /* @__PURE__ */ jsx39(PlaybackControls, { ...props });
|
|
5829
|
+
}
|
|
5830
|
+
|
|
5831
|
+
// src/GdsPageTemplates.client.tsx
|
|
5832
|
+
import { useEffect as useEffect12, useId as useId2, useRef as useRef12 } from "react";
|
|
5833
|
+
import { Box as Box11, Button as Button15, Grid, Title as Title3 } from "@mantine/core";
|
|
5834
|
+
import { useMediaQuery as useMediaQuery3, useUncontrolled as useUncontrolled3 } from "@mantine/hooks";
|
|
5835
|
+
import { useGdsTranslation as useGdsTranslation28 } from "@sovereignsquad/gds-theme";
|
|
5836
|
+
import { jsx as jsx40, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
5837
|
+
function GdsAssetManagerTemplate({
|
|
5838
|
+
state = "ready",
|
|
5839
|
+
tree,
|
|
5840
|
+
toolbar,
|
|
5841
|
+
bulkActions,
|
|
5842
|
+
table,
|
|
5843
|
+
grid,
|
|
5844
|
+
view: viewProp,
|
|
5845
|
+
defaultView = "table",
|
|
5846
|
+
onViewChange,
|
|
5847
|
+
upload,
|
|
5848
|
+
detail,
|
|
5849
|
+
shapeProfile = "operations",
|
|
5850
|
+
onRetry,
|
|
5851
|
+
retryLabel,
|
|
5852
|
+
...props
|
|
5853
|
+
}) {
|
|
5854
|
+
const { t } = useGdsTranslation28();
|
|
5855
|
+
const [view, setView] = useUncontrolled3({ value: viewProp, defaultValue: defaultView, finalValue: "table", onChange: onViewChange });
|
|
5856
|
+
const items = table && grid ? view === "grid" ? grid : table : table ?? grid;
|
|
5857
|
+
return /* @__PURE__ */ jsx40(GdsShapeScope, { profile: shapeProfile, children: /* @__PURE__ */ jsx40(PageTemplateFrame, { id: "asset-manager", state, ...props, children: /* @__PURE__ */ jsx40(
|
|
5858
|
+
TemplateStateGate,
|
|
5859
|
+
{
|
|
5860
|
+
state,
|
|
5861
|
+
onRetry,
|
|
5862
|
+
retryLabel,
|
|
5863
|
+
successContent: /* @__PURE__ */ jsxs29(Grid, { style: { gap: "var(--gds-space-md)" }, children: [
|
|
5864
|
+
tree ? /* @__PURE__ */ jsx40(Grid.Col, { span: { base: 12, md: 3 }, children: /* @__PURE__ */ jsx40(Box11, { component: "nav", "aria-label": t("gds.assetManagerTemplate.folders", "Folders"), "data-gds-asset-tree": "", children: tree }) }) : null,
|
|
5865
|
+
/* @__PURE__ */ jsx40(Grid.Col, { span: { base: 12, md: tree ? 9 : 12 }, children: /* @__PURE__ */ jsxs29(GdsStack, { gap: "md", children: [
|
|
5866
|
+
toolbar,
|
|
5867
|
+
bulkActions ? /* @__PURE__ */ jsx40(GdsBulkActionBar, { ...bulkActions }) : null,
|
|
5868
|
+
table && grid ? /* @__PURE__ */ jsx40(GdsViewToggle, { value: view, onChange: setView }) : null,
|
|
5869
|
+
items ?? /* @__PURE__ */ jsx40(StateBlock, { variant: "empty", compact: true, titleOrder: 2, title: t("gds.assetManagerTemplate.emptyTitle", "This folder is empty") }),
|
|
5870
|
+
upload,
|
|
5871
|
+
detail ? /* @__PURE__ */ jsx40(SectionPanel, { titleOrder: 2, title: t("gds.assetManagerTemplate.detailTitle", "Selected item"), children: detail }) : null
|
|
5872
|
+
] }) })
|
|
5873
|
+
] })
|
|
5874
|
+
}
|
|
5875
|
+
) }) });
|
|
5876
|
+
}
|
|
5877
|
+
function GdsWorkspaceInboxTemplate({
|
|
5878
|
+
state = "ready",
|
|
5879
|
+
navigation,
|
|
5880
|
+
threadList,
|
|
5881
|
+
detail,
|
|
5882
|
+
detailTitle,
|
|
5883
|
+
hasSelection = false,
|
|
5884
|
+
detailLoading = false,
|
|
5885
|
+
onBack,
|
|
5886
|
+
regionHeight,
|
|
5887
|
+
onRetry,
|
|
5888
|
+
retryLabel,
|
|
5889
|
+
...props
|
|
5890
|
+
}) {
|
|
5891
|
+
const { t } = useGdsTranslation28();
|
|
5892
|
+
const narrow = useMediaQuery3("(max-width: 48em)");
|
|
5893
|
+
const headingId = useId2();
|
|
5894
|
+
const headingRef = useRef12(null);
|
|
5895
|
+
useEffect12(() => {
|
|
5896
|
+
if (narrow && hasSelection) headingRef.current?.focus();
|
|
5897
|
+
}, [narrow, hasSelection]);
|
|
5898
|
+
const scroll = regionHeight ? { maxBlockSize: regionHeight, overflowY: "auto" } : void 0;
|
|
5899
|
+
const conversationsLabel = t("gds.workspaceInboxTemplate.conversations", "Conversations");
|
|
5900
|
+
const title = detailTitle ?? t("gds.workspaceInboxTemplate.conversation", "Conversation");
|
|
5901
|
+
const listRegion = /* @__PURE__ */ jsx40(Box11, { component: "section", "aria-label": conversationsLabel, style: scroll, "data-gds-inbox-list": "", children: threadList });
|
|
5902
|
+
const detailRegion = /* @__PURE__ */ jsx40(Box11, { component: "section", "aria-labelledby": headingId, style: scroll, "data-gds-inbox-detail": "", children: /* @__PURE__ */ jsxs29(GdsStack, { gap: "sm", children: [
|
|
5903
|
+
narrow && hasSelection && onBack ? /* @__PURE__ */ jsx40(Button15, { variant: "subtle", size: "xs", onClick: onBack, style: { alignSelf: "flex-start" }, children: t("gds.workspaceInboxTemplate.back", "Back to conversations") }) : null,
|
|
5904
|
+
/* @__PURE__ */ jsx40(Title3, { order: 2, size: "h4", id: headingId, ref: headingRef, tabIndex: -1, children: title }),
|
|
5905
|
+
detailLoading ? /* @__PURE__ */ jsx40(StateBlock, { variant: "loading", compact: true, titleOrder: 3, title: t("gds.workspaceInboxTemplate.loading", "Loading conversation") }) : hasSelection ? detail : /* @__PURE__ */ jsx40(StateBlock, { variant: "empty", compact: true, titleOrder: 3, title: t("gds.workspaceInboxTemplate.noSelection", "Select a conversation") })
|
|
5906
|
+
] }) });
|
|
5907
|
+
return /* @__PURE__ */ jsx40(PageTemplateFrame, { id: "workspace-inbox", state, ...props, children: /* @__PURE__ */ jsx40(
|
|
5908
|
+
TemplateStateGate,
|
|
5909
|
+
{
|
|
5910
|
+
state,
|
|
5911
|
+
onRetry,
|
|
5912
|
+
retryLabel,
|
|
5913
|
+
successContent: narrow ? hasSelection ? detailRegion : /* @__PURE__ */ jsxs29(GdsStack, { gap: "md", children: [
|
|
5914
|
+
navigation ? /* @__PURE__ */ jsx40(Box11, { component: "nav", "aria-label": t("gds.workspaceInboxTemplate.navigation", "Workspace"), children: navigation }) : null,
|
|
5915
|
+
listRegion
|
|
5916
|
+
] }) : /* @__PURE__ */ jsxs29(Grid, { style: { gap: "var(--gds-space-md)" }, children: [
|
|
5917
|
+
navigation ? /* @__PURE__ */ jsx40(Grid.Col, { span: { base: 12, md: 2 }, children: /* @__PURE__ */ jsx40(Box11, { component: "nav", "aria-label": t("gds.workspaceInboxTemplate.navigation", "Workspace"), style: scroll, children: navigation }) }) : null,
|
|
5918
|
+
/* @__PURE__ */ jsx40(Grid.Col, { span: { base: 12, md: navigation ? 4 : 5 }, children: listRegion }),
|
|
5919
|
+
/* @__PURE__ */ jsx40(Grid.Col, { span: { base: 12, md: navigation ? 6 : 7 }, children: detailRegion })
|
|
5920
|
+
] })
|
|
5921
|
+
}
|
|
5922
|
+
) });
|
|
5000
5923
|
}
|
|
5001
5924
|
|
|
5002
5925
|
// src/TrustLayer.client.tsx
|
|
5003
|
-
import { useRef as
|
|
5004
|
-
import { Button as
|
|
5005
|
-
import { useGdsTranslation as
|
|
5006
|
-
import { Fragment as
|
|
5926
|
+
import { useRef as useRef13, useState as useState22 } from "react";
|
|
5927
|
+
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";
|
|
5928
|
+
import { useGdsTranslation as useGdsTranslation29, GDS_MIN_TARGET_PX } from "@sovereignsquad/gds-theme";
|
|
5929
|
+
import { Fragment as Fragment8, jsx as jsx41, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
5007
5930
|
var ROLE_SUCCESS = "var(--gds-state-success, var(--mantine-color-green-7))";
|
|
5008
5931
|
var ROLE_WARNING = "var(--gds-state-warning, var(--mantine-color-yellow-8))";
|
|
5009
5932
|
var ROLE_META = "var(--gds-text-meta, var(--gds-vibe-muted, var(--mantine-color-gray-7)))";
|
|
5010
5933
|
var ROLE_WARNING_TINT_BG = "var(--gds-badge-soft-warning, var(--mantine-color-yellow-0))";
|
|
5011
5934
|
var ROLE_WARNING_TINT_FG = "var(--gds-badge-soft-warning-fg, var(--mantine-color-yellow-9))";
|
|
5012
5935
|
function ReportOutdatedLink({ onReport, label }) {
|
|
5013
|
-
const { t } =
|
|
5014
|
-
const [sent, setSent] =
|
|
5015
|
-
const sentRef =
|
|
5936
|
+
const { t } = useGdsTranslation29();
|
|
5937
|
+
const [sent, setSent] = useState22(false);
|
|
5938
|
+
const sentRef = useRef13(false);
|
|
5016
5939
|
const actionLabel = label ?? t("gds.trust.report.action", "Report outdated info");
|
|
5017
5940
|
const thanksText = t("gds.trust.report.thanks", "Thanks \u2014 we'll re-check this listing.");
|
|
5018
5941
|
const handleActivate = () => {
|
|
@@ -5021,25 +5944,25 @@ function ReportOutdatedLink({ onReport, label }) {
|
|
|
5021
5944
|
setSent(true);
|
|
5022
5945
|
onReport?.();
|
|
5023
5946
|
};
|
|
5024
|
-
return /* @__PURE__ */
|
|
5025
|
-
sent ? /* @__PURE__ */
|
|
5026
|
-
|
|
5947
|
+
return /* @__PURE__ */ jsxs30(Fragment8, { children: [
|
|
5948
|
+
sent ? /* @__PURE__ */ jsx41(Text26, { component: "span", size: "sm", fw: 600, c: ROLE_SUCCESS, children: thanksText }) : /* @__PURE__ */ jsx41(
|
|
5949
|
+
Button16,
|
|
5027
5950
|
{
|
|
5028
5951
|
type: "button",
|
|
5029
5952
|
variant: "subtle",
|
|
5030
5953
|
color: "gray",
|
|
5031
5954
|
size: "sm",
|
|
5032
|
-
leftSection: /* @__PURE__ */
|
|
5955
|
+
leftSection: /* @__PURE__ */ jsx41(GdsIcon, { icon: "Flag", size: "xs" }),
|
|
5033
5956
|
onClick: handleActivate,
|
|
5034
5957
|
styles: { root: { minHeight: `${GDS_MIN_TARGET_PX}px` } },
|
|
5035
5958
|
children: actionLabel
|
|
5036
5959
|
}
|
|
5037
5960
|
),
|
|
5038
|
-
/* @__PURE__ */
|
|
5961
|
+
/* @__PURE__ */ jsx41(VisuallyHidden6, { role: "status", "aria-live": "polite", "aria-atomic": "true", children: sent ? thanksText : "" })
|
|
5039
5962
|
] });
|
|
5040
5963
|
}
|
|
5041
5964
|
function useSourceRowStatusLabels() {
|
|
5042
|
-
const { t } =
|
|
5965
|
+
const { t } = useGdsTranslation29();
|
|
5043
5966
|
return {
|
|
5044
5967
|
estimate: t("gds.trust.source.statusEstimate", "Estimate"),
|
|
5045
5968
|
confirmed: t("gds.trust.source.statusConfirmed", "Confirmed"),
|
|
@@ -5050,8 +5973,8 @@ function sourceRowStatusRole(status) {
|
|
|
5050
5973
|
return status === "confirmed" ? ROLE_SUCCESS : ROLE_WARNING;
|
|
5051
5974
|
}
|
|
5052
5975
|
function SourceBlockRow({ label, children }) {
|
|
5053
|
-
return /* @__PURE__ */
|
|
5054
|
-
|
|
5976
|
+
return /* @__PURE__ */ jsxs30(
|
|
5977
|
+
Group23,
|
|
5055
5978
|
{
|
|
5056
5979
|
justify: "space-between",
|
|
5057
5980
|
align: "center",
|
|
@@ -5060,41 +5983,41 @@ function SourceBlockRow({ label, children }) {
|
|
|
5060
5983
|
py: 4,
|
|
5061
5984
|
style: { borderTop: "1px solid var(--gds-border-card, var(--mantine-color-gray-3))" },
|
|
5062
5985
|
children: [
|
|
5063
|
-
/* @__PURE__ */
|
|
5986
|
+
/* @__PURE__ */ jsx41(Text26, { size: "sm", fw: 500, c: ROLE_META, children: label }),
|
|
5064
5987
|
children
|
|
5065
5988
|
]
|
|
5066
5989
|
}
|
|
5067
5990
|
);
|
|
5068
5991
|
}
|
|
5069
5992
|
function SourceBlock({ sourceType, sourceUrl, lastChecked, priceStatus, scheduleStatus, onReport }) {
|
|
5070
|
-
const { t } =
|
|
5993
|
+
const { t } = useGdsTranslation29();
|
|
5071
5994
|
const statusLabels = useSourceRowStatusLabels();
|
|
5072
5995
|
const unknownValue = t("gds.trust.source.unknownValue", "Unknown \u2014 confirm with provider");
|
|
5073
5996
|
let sourceTypeContent;
|
|
5074
5997
|
if (sourceUrl) {
|
|
5075
|
-
sourceTypeContent = /* @__PURE__ */
|
|
5998
|
+
sourceTypeContent = /* @__PURE__ */ jsx41(GdsInlineLink, { href: sourceUrl, external: true, children: sourceType || unknownValue });
|
|
5076
5999
|
} else if (sourceType) {
|
|
5077
|
-
sourceTypeContent = /* @__PURE__ */
|
|
6000
|
+
sourceTypeContent = /* @__PURE__ */ jsx41(Text26, { size: "sm", children: sourceType });
|
|
5078
6001
|
} else {
|
|
5079
|
-
sourceTypeContent = /* @__PURE__ */
|
|
6002
|
+
sourceTypeContent = /* @__PURE__ */ jsx41(Text26, { size: "sm", c: ROLE_META, children: unknownValue });
|
|
5080
6003
|
}
|
|
5081
|
-
return /* @__PURE__ */
|
|
5082
|
-
/* @__PURE__ */
|
|
5083
|
-
/* @__PURE__ */
|
|
5084
|
-
/* @__PURE__ */
|
|
6004
|
+
return /* @__PURE__ */ jsx41(Paper8, { withBorder: true, radius: "lg", p: "md", "data-gds-source-block": "", children: /* @__PURE__ */ jsxs30(Stack19, { gap: "xs", children: [
|
|
6005
|
+
/* @__PURE__ */ jsxs30(Group23, { gap: "xs", children: [
|
|
6006
|
+
/* @__PURE__ */ jsx41(GdsIcon, { icon: "SourceInfo", size: "sm" }),
|
|
6007
|
+
/* @__PURE__ */ jsx41(Text26, { fw: 600, children: t("gds.trust.source.title", "Information source") })
|
|
5085
6008
|
] }),
|
|
5086
|
-
/* @__PURE__ */
|
|
5087
|
-
/* @__PURE__ */
|
|
5088
|
-
/* @__PURE__ */
|
|
5089
|
-
/* @__PURE__ */
|
|
5090
|
-
/* @__PURE__ */
|
|
6009
|
+
/* @__PURE__ */ jsxs30(Stack19, { gap: 0, children: [
|
|
6010
|
+
/* @__PURE__ */ jsx41(SourceBlockRow, { label: t("gds.trust.source.sourceType", "Source type"), children: sourceTypeContent }),
|
|
6011
|
+
/* @__PURE__ */ jsx41(SourceBlockRow, { label: t("gds.trust.source.lastChecked", "Last checked"), children: lastChecked !== void 0 ? /* @__PURE__ */ jsx41(LastCheckedLabel, { date: lastChecked }) : /* @__PURE__ */ jsx41(Text26, { size: "sm", c: ROLE_META, children: unknownValue }) }),
|
|
6012
|
+
/* @__PURE__ */ jsx41(SourceBlockRow, { label: t("gds.trust.source.priceStatus", "Price status"), children: priceStatus ? /* @__PURE__ */ jsx41(Text26, { size: "sm", c: sourceRowStatusRole(priceStatus), children: statusLabels[priceStatus] }) : /* @__PURE__ */ jsx41(Text26, { size: "sm", c: ROLE_META, children: unknownValue }) }),
|
|
6013
|
+
/* @__PURE__ */ jsx41(SourceBlockRow, { label: t("gds.trust.source.scheduleStatus", "Schedule status"), children: scheduleStatus ? /* @__PURE__ */ jsx41(Text26, { size: "sm", c: sourceRowStatusRole(scheduleStatus), children: statusLabels[scheduleStatus] }) : /* @__PURE__ */ jsx41(Text26, { size: "sm", c: ROLE_META, children: unknownValue }) })
|
|
5091
6014
|
] }),
|
|
5092
|
-
/* @__PURE__ */
|
|
5093
|
-
onReport ? /* @__PURE__ */
|
|
6015
|
+
/* @__PURE__ */ jsx41(Text26, { size: "xs", c: ROLE_META, children: t("gds.trust.source.confirmLine", "Always confirm final details directly with the provider before attending.") }),
|
|
6016
|
+
onReport ? /* @__PURE__ */ jsx41(ReportOutdatedLink, { onReport }) : null
|
|
5094
6017
|
] }) });
|
|
5095
6018
|
}
|
|
5096
6019
|
function ConfirmChecklist({ items, title }) {
|
|
5097
|
-
const { t } =
|
|
6020
|
+
const { t } = useGdsTranslation29();
|
|
5098
6021
|
const defaultItems = [
|
|
5099
6022
|
t("gds.trust.checklist.exactSchedule", "Exact schedule"),
|
|
5100
6023
|
t("gds.trust.checklist.currentPrice", "Current price"),
|
|
@@ -5105,36 +6028,36 @@ function ConfirmChecklist({ items, title }) {
|
|
|
5105
6028
|
];
|
|
5106
6029
|
const resolvedItems = items ?? defaultItems;
|
|
5107
6030
|
const resolvedTitle = title ?? t("gds.trust.checklist.title", "Check before booking");
|
|
5108
|
-
const [checked, setChecked] =
|
|
6031
|
+
const [checked, setChecked] = useState22({});
|
|
5109
6032
|
if (resolvedItems.length === 0) {
|
|
5110
6033
|
return null;
|
|
5111
6034
|
}
|
|
5112
6035
|
const toggle = (key) => {
|
|
5113
6036
|
setChecked((current) => ({ ...current, [key]: !current[key] }));
|
|
5114
6037
|
};
|
|
5115
|
-
return /* @__PURE__ */
|
|
5116
|
-
|
|
6038
|
+
return /* @__PURE__ */ jsx41(
|
|
6039
|
+
Paper8,
|
|
5117
6040
|
{
|
|
5118
6041
|
withBorder: true,
|
|
5119
6042
|
radius: "lg",
|
|
5120
6043
|
p: "md",
|
|
5121
6044
|
"data-gds-confirm-checklist": "",
|
|
5122
6045
|
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__ */
|
|
6046
|
+
children: /* @__PURE__ */ jsxs30("fieldset", { style: { border: 0, margin: 0, padding: 0, minInlineSize: "auto" }, children: [
|
|
6047
|
+
/* @__PURE__ */ jsxs30(Group23, { component: "legend", gap: "xs", wrap: "nowrap", style: { padding: 0, color: ROLE_WARNING_TINT_FG }, children: [
|
|
6048
|
+
/* @__PURE__ */ jsx41(GdsIcon, { icon: "Checklist", size: "sm" }),
|
|
6049
|
+
/* @__PURE__ */ jsx41(Text26, { fw: 600, c: "inherit", children: resolvedTitle })
|
|
5127
6050
|
] }),
|
|
5128
|
-
/* @__PURE__ */
|
|
6051
|
+
/* @__PURE__ */ jsx41(Stack19, { gap: "xs", mt: "sm", children: resolvedItems.map((item, index) => {
|
|
5129
6052
|
const key = `${index}:${item}`;
|
|
5130
6053
|
const isChecked = Boolean(checked[key]);
|
|
5131
|
-
return /* @__PURE__ */
|
|
6054
|
+
return /* @__PURE__ */ jsx41(Group23, { wrap: "nowrap", align: "center", gap: "xs", style: { minHeight: `${GDS_MIN_TARGET_PX}px` }, children: /* @__PURE__ */ jsx41(
|
|
5132
6055
|
Checkbox4,
|
|
5133
6056
|
{
|
|
5134
6057
|
checked: isChecked,
|
|
5135
6058
|
onChange: () => toggle(key),
|
|
5136
|
-
label: /* @__PURE__ */
|
|
5137
|
-
|
|
6059
|
+
label: /* @__PURE__ */ jsx41(
|
|
6060
|
+
Text26,
|
|
5138
6061
|
{
|
|
5139
6062
|
component: "span",
|
|
5140
6063
|
c: ROLE_WARNING_TINT_FG,
|
|
@@ -5151,10 +6074,10 @@ function ConfirmChecklist({ items, title }) {
|
|
|
5151
6074
|
}
|
|
5152
6075
|
|
|
5153
6076
|
// src/HeroSearchPanel.client.tsx
|
|
5154
|
-
import { useState as
|
|
5155
|
-
import { Box as
|
|
5156
|
-
import { useGdsTranslation as
|
|
5157
|
-
import { jsx as
|
|
6077
|
+
import { useState as useState23 } from "react";
|
|
6078
|
+
import { Box as Box12, Button as Button17, TextInput as TextInput4 } from "@mantine/core";
|
|
6079
|
+
import { useGdsTranslation as useGdsTranslation30, GDS_MIN_TARGET_PX as GDS_MIN_TARGET_PX2 } from "@sovereignsquad/gds-theme";
|
|
6080
|
+
import { jsx as jsx42, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
5158
6081
|
var GDS_HERO_SEARCH_FIELD_FLEX_BASIS_PX = 120;
|
|
5159
6082
|
var GDS_HERO_SEARCH_FIELD_MIN_WIDTH_PX = 110;
|
|
5160
6083
|
function dedupeHeroSearchFields(fields) {
|
|
@@ -5191,10 +6114,10 @@ function HeroSearchPanel({
|
|
|
5191
6114
|
ariaLabel: ariaLabelProp,
|
|
5192
6115
|
disabled = false
|
|
5193
6116
|
}) {
|
|
5194
|
-
const { t } =
|
|
6117
|
+
const { t } = useGdsTranslation30();
|
|
5195
6118
|
const ariaLabel = ariaLabelProp ?? t("gds.heroSearchPanel.ariaLabel", "Search");
|
|
5196
6119
|
const controlled = values !== void 0;
|
|
5197
|
-
const [internalValues, setInternalValues] =
|
|
6120
|
+
const [internalValues, setInternalValues] = useState23(defaultValues ?? {});
|
|
5198
6121
|
const currentValues = controlled ? values : internalValues;
|
|
5199
6122
|
const edit = (key, value) => {
|
|
5200
6123
|
const next = { ...currentValues, [key]: value };
|
|
@@ -5211,16 +6134,16 @@ function HeroSearchPanel({
|
|
|
5211
6134
|
const renderedFields = dedupeHeroSearchFields(fields);
|
|
5212
6135
|
const showSecondaryAction = Boolean(secondaryActionLabel && onSecondaryAction);
|
|
5213
6136
|
const primaryVocabularyPacks = primaryActionLabel ? [createGdsVocabularyPack("heroSearchPanel", { primary: { defaultMessage: primaryActionLabel, icon: GdsIcons.Search } })] : void 0;
|
|
5214
|
-
return /* @__PURE__ */
|
|
5215
|
-
renderedFields.length > 0 ? /* @__PURE__ */
|
|
5216
|
-
|
|
6137
|
+
return /* @__PURE__ */ jsx42("form", { role: "search", "aria-label": ariaLabel, onSubmit: submit, style: panelSurfaceStyle, children: /* @__PURE__ */ jsxs31(GdsStack, { gap: "sm", children: [
|
|
6138
|
+
renderedFields.length > 0 ? /* @__PURE__ */ jsx42(GdsInline, { gap: "sm", wrap: "wrap", align: "start", children: renderedFields.map((field) => /* @__PURE__ */ jsx42(
|
|
6139
|
+
Box12,
|
|
5217
6140
|
{
|
|
5218
6141
|
style: {
|
|
5219
6142
|
flex: `1 1 ${GDS_HERO_SEARCH_FIELD_FLEX_BASIS_PX}px`,
|
|
5220
6143
|
minWidth: `${GDS_HERO_SEARCH_FIELD_MIN_WIDTH_PX}px`,
|
|
5221
|
-
overflowWrap: "
|
|
6144
|
+
overflowWrap: "break-word"
|
|
5222
6145
|
},
|
|
5223
|
-
children: /* @__PURE__ */
|
|
6146
|
+
children: /* @__PURE__ */ jsx42(FormField, { label: field.label, children: /* @__PURE__ */ jsx42(
|
|
5224
6147
|
TextInput4,
|
|
5225
6148
|
{
|
|
5226
6149
|
value: currentValues[field.key] ?? "",
|
|
@@ -5233,8 +6156,8 @@ function HeroSearchPanel({
|
|
|
5233
6156
|
},
|
|
5234
6157
|
field.key
|
|
5235
6158
|
)) }) : null,
|
|
5236
|
-
/* @__PURE__ */
|
|
5237
|
-
/* @__PURE__ */
|
|
6159
|
+
/* @__PURE__ */ jsxs31(GdsInline, { gap: "sm", wrap: "wrap", children: [
|
|
6160
|
+
/* @__PURE__ */ jsx42(
|
|
5238
6161
|
SemanticButton,
|
|
5239
6162
|
{
|
|
5240
6163
|
action: primaryActionLabel ? "heroSearchPanel:primary" : "search",
|
|
@@ -5243,17 +6166,17 @@ function HeroSearchPanel({
|
|
|
5243
6166
|
vocabularyPacks: primaryVocabularyPacks
|
|
5244
6167
|
}
|
|
5245
6168
|
),
|
|
5246
|
-
showSecondaryAction ? /* @__PURE__ */
|
|
6169
|
+
showSecondaryAction ? /* @__PURE__ */ jsx42(Button17, { type: "button", variant: "default", disabled, onClick: onSecondaryAction, children: secondaryActionLabel }) : null
|
|
5247
6170
|
] }),
|
|
5248
|
-
trustLine ? /* @__PURE__ */
|
|
6171
|
+
trustLine ? /* @__PURE__ */ jsx42(MetadataText, { children: trustLine }) : null
|
|
5249
6172
|
] }) });
|
|
5250
6173
|
}
|
|
5251
6174
|
|
|
5252
6175
|
// 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
|
|
6176
|
+
import { useEffect as useEffect13, useId as useId3, useRef as useRef14, useState as useState24 } from "react";
|
|
6177
|
+
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";
|
|
6178
|
+
import { useMediaQuery as useMediaQuery4 } from "@mantine/hooks";
|
|
6179
|
+
import { useGdsTranslation as useGdsTranslation31 } from "@sovereignsquad/gds-theme";
|
|
5257
6180
|
import {
|
|
5258
6181
|
DndContext,
|
|
5259
6182
|
DragOverlay,
|
|
@@ -5266,21 +6189,21 @@ import {
|
|
|
5266
6189
|
} from "@dnd-kit/core";
|
|
5267
6190
|
import { SortableContext, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
5268
6191
|
import { CSS as CSS2 } from "@dnd-kit/utilities";
|
|
5269
|
-
import { Fragment as
|
|
6192
|
+
import { Fragment as Fragment9, jsx as jsx43, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
5270
6193
|
function useGdsKanbanOrientation({
|
|
5271
6194
|
stackedBreakpoint = "xs"
|
|
5272
6195
|
} = {}) {
|
|
5273
|
-
const isPortrait =
|
|
5274
|
-
const isNarrow =
|
|
6196
|
+
const isPortrait = useMediaQuery4("(orientation: portrait)");
|
|
6197
|
+
const isNarrow = useMediaQuery4(`(max-width: ${gdsBreakpointByAlias[stackedBreakpoint]})`);
|
|
5275
6198
|
return isPortrait && isNarrow ? "stacked" : "columns";
|
|
5276
6199
|
}
|
|
5277
6200
|
function DragGripGlyph() {
|
|
5278
|
-
return /* @__PURE__ */
|
|
5279
|
-
(x) => [2, 8, 14].map((y) => /* @__PURE__ */
|
|
6201
|
+
return /* @__PURE__ */ jsx43("svg", { width: "10", height: "16", viewBox: "0 0 10 16", "aria-hidden": "true", focusable: "false", children: [2, 8].flatMap(
|
|
6202
|
+
(x) => [2, 8, 14].map((y) => /* @__PURE__ */ jsx43("circle", { cx: x, cy: y, r: 1.4, fill: "currentColor" }, `${x}-${y}`))
|
|
5280
6203
|
) });
|
|
5281
6204
|
}
|
|
5282
6205
|
function ColumnDisclosureGlyph({ collapsed }) {
|
|
5283
|
-
return /* @__PURE__ */
|
|
6206
|
+
return /* @__PURE__ */ jsx43(
|
|
5284
6207
|
"svg",
|
|
5285
6208
|
{
|
|
5286
6209
|
width: "12",
|
|
@@ -5289,7 +6212,7 @@ function ColumnDisclosureGlyph({ collapsed }) {
|
|
|
5289
6212
|
"aria-hidden": "true",
|
|
5290
6213
|
focusable: "false",
|
|
5291
6214
|
style: { transform: collapsed ? "rotate(-90deg)" : "none", transition: "transform var(--gds-motion-duration-fast, 120ms) var(--gds-motion-ease-standard, ease)" },
|
|
5292
|
-
children: /* @__PURE__ */
|
|
6215
|
+
children: /* @__PURE__ */ jsx43("path", { d: "M2.5 4.5 L6 8 L9.5 4.5", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
5293
6216
|
}
|
|
5294
6217
|
);
|
|
5295
6218
|
}
|
|
@@ -5298,7 +6221,7 @@ function columnTitleText(column) {
|
|
|
5298
6221
|
return column.ariaLabel ?? (typeof column.title === "string" ? column.title : column.id);
|
|
5299
6222
|
}
|
|
5300
6223
|
function KanbanCard({ item, column, columns, onMoveItem, renderItem, enableDrag, moveMenuIcon, moveMenuLabel }) {
|
|
5301
|
-
const { t } =
|
|
6224
|
+
const { t } = useGdsTranslation31();
|
|
5302
6225
|
const moveTargets = columns.filter((candidate) => candidate.id !== column.id);
|
|
5303
6226
|
const accessibleName = item.ariaLabel ?? (typeof item.title === "string" ? item.title : void 0);
|
|
5304
6227
|
const moveVerb = moveMenuLabel ?? t("gds.kanban.moveItem", "Move");
|
|
@@ -5310,8 +6233,8 @@ function KanbanCard({ item, column, columns, onMoveItem, renderItem, enableDrag,
|
|
|
5310
6233
|
transition: sortable.transition,
|
|
5311
6234
|
opacity: sortable.isDragging ? 0.4 : 1
|
|
5312
6235
|
} : void 0;
|
|
5313
|
-
return /* @__PURE__ */
|
|
5314
|
-
|
|
6236
|
+
return /* @__PURE__ */ jsx43(
|
|
6237
|
+
Paper9,
|
|
5315
6238
|
{
|
|
5316
6239
|
withBorder: true,
|
|
5317
6240
|
radius: "md",
|
|
@@ -5319,9 +6242,9 @@ function KanbanCard({ item, column, columns, onMoveItem, renderItem, enableDrag,
|
|
|
5319
6242
|
"data-gds-kanban-card": item.id,
|
|
5320
6243
|
ref: enableDrag ? sortable.setNodeRef : void 0,
|
|
5321
6244
|
style: dragStyle,
|
|
5322
|
-
children: /* @__PURE__ */
|
|
5323
|
-
/* @__PURE__ */
|
|
5324
|
-
enableDrag ? /* @__PURE__ */
|
|
6245
|
+
children: /* @__PURE__ */ jsxs32(Stack20, { gap: 6, children: [
|
|
6246
|
+
/* @__PURE__ */ jsxs32(Group24, { justify: "space-between", align: "flex-start", gap: "xs", wrap: "nowrap", children: [
|
|
6247
|
+
enableDrag ? /* @__PURE__ */ jsx43(
|
|
5325
6248
|
ActionIcon5,
|
|
5326
6249
|
{
|
|
5327
6250
|
variant: "subtle",
|
|
@@ -5333,23 +6256,23 @@ function KanbanCard({ item, column, columns, onMoveItem, renderItem, enableDrag,
|
|
|
5333
6256
|
style: { cursor: "grab", touchAction: "none", flexShrink: 0 },
|
|
5334
6257
|
...sortable.listeners,
|
|
5335
6258
|
...sortable.attributes,
|
|
5336
|
-
children: /* @__PURE__ */
|
|
6259
|
+
children: /* @__PURE__ */ jsx43(DragGripGlyph, {})
|
|
5337
6260
|
}
|
|
5338
6261
|
) : null,
|
|
5339
|
-
/* @__PURE__ */
|
|
5340
|
-
typeof item.title === "string" ? /* @__PURE__ */
|
|
5341
|
-
item.description ? /* @__PURE__ */
|
|
6262
|
+
/* @__PURE__ */ jsx43(Box13, { style: { minWidth: 0, flex: 1 }, children: renderItem ? renderItem(item, column) : /* @__PURE__ */ jsxs32(Stack20, { gap: 2, children: [
|
|
6263
|
+
typeof item.title === "string" ? /* @__PURE__ */ jsx43(Text27, { fw: 600, size: "sm", children: item.title }) : item.title,
|
|
6264
|
+
item.description ? /* @__PURE__ */ jsx43(Text27, { size: "xs", c: "dimmed", children: item.description }) : null
|
|
5342
6265
|
] }) }),
|
|
5343
|
-
onMoveItem && moveTargets.length > 0 ? /* @__PURE__ */
|
|
5344
|
-
/* @__PURE__ */
|
|
5345
|
-
/* @__PURE__ */
|
|
6266
|
+
onMoveItem && moveTargets.length > 0 ? /* @__PURE__ */ jsxs32(Menu, { withinPortal: true, position: "bottom-end", shadow: "md", children: [
|
|
6267
|
+
/* @__PURE__ */ jsx43(Menu.Target, { children: /* @__PURE__ */ jsx43(ActionIcon5, { variant: "subtle", color: "gray", size: "sm", "data-gds-target-exception": "dense-toolbar", "aria-label": moveLabel, children: moveMenuIcon ?? /* @__PURE__ */ jsx43(GdsIcon, { icon: "More", decorative: true }) }) }),
|
|
6268
|
+
/* @__PURE__ */ jsx43(Menu.Dropdown, { children: moveTargets.map((target) => /* @__PURE__ */ jsxs32(Menu.Item, { onClick: () => onMoveItem(item.id, column.id, target.id), children: [
|
|
5346
6269
|
t("gds.kanban.moveTo", "Move to"),
|
|
5347
6270
|
" ",
|
|
5348
6271
|
target.title
|
|
5349
6272
|
] }, target.id)) })
|
|
5350
6273
|
] }) : null
|
|
5351
6274
|
] }),
|
|
5352
|
-
item.status ? /* @__PURE__ */
|
|
6275
|
+
item.status ? /* @__PURE__ */ jsx43(Badge3, { variant: "light", size: "sm", children: item.status }) : null
|
|
5353
6276
|
] })
|
|
5354
6277
|
}
|
|
5355
6278
|
);
|
|
@@ -5370,12 +6293,12 @@ function KanbanColumn({
|
|
|
5370
6293
|
collapsed,
|
|
5371
6294
|
onCollapsedChange
|
|
5372
6295
|
}) {
|
|
5373
|
-
const { t } =
|
|
6296
|
+
const { t } = useGdsTranslation31();
|
|
5374
6297
|
const droppable = useDroppable({ id: column.id, disabled: !enableDrag });
|
|
5375
6298
|
const isControlledCollapse = collapsed !== void 0;
|
|
5376
|
-
const [internalCollapsed, setInternalCollapsed] =
|
|
6299
|
+
const [internalCollapsed, setInternalCollapsed] = useState24(false);
|
|
5377
6300
|
const resolvedCollapsed = collapsible ? isControlledCollapse ? Boolean(collapsed) : internalCollapsed : false;
|
|
5378
|
-
const bodyId =
|
|
6301
|
+
const bodyId = useId3();
|
|
5379
6302
|
function handleToggleCollapsed() {
|
|
5380
6303
|
const next = !resolvedCollapsed;
|
|
5381
6304
|
if (!isControlledCollapse) {
|
|
@@ -5387,7 +6310,7 @@ function KanbanColumn({
|
|
|
5387
6310
|
const toggleVerb = resolvedCollapsed ? t("gds.kanban.expandColumn", "Expand column") : t("gds.kanban.collapseColumn", "Collapse column");
|
|
5388
6311
|
const toggleLabel = columnName ? `${toggleVerb}: ${columnName}` : toggleVerb;
|
|
5389
6312
|
const count = column.totalCount ?? column.items.length;
|
|
5390
|
-
const cards = column.items.length ? /* @__PURE__ */
|
|
6313
|
+
const cards = column.items.length ? /* @__PURE__ */ jsx43(Stack20, { gap: "xs", ref: enableDrag ? droppable.setNodeRef : void 0, "data-gds-kanban-drop-zone": column.id, children: column.items.map((item) => /* @__PURE__ */ jsx43(
|
|
5391
6314
|
KanbanCard,
|
|
5392
6315
|
{
|
|
5393
6316
|
item,
|
|
@@ -5400,8 +6323,8 @@ function KanbanColumn({
|
|
|
5400
6323
|
moveMenuLabel
|
|
5401
6324
|
},
|
|
5402
6325
|
item.id
|
|
5403
|
-
)) }) : /* @__PURE__ */
|
|
5404
|
-
|
|
6326
|
+
)) }) : /* @__PURE__ */ jsx43(
|
|
6327
|
+
Text27,
|
|
5405
6328
|
{
|
|
5406
6329
|
size: "xs",
|
|
5407
6330
|
c: "dimmed",
|
|
@@ -5411,12 +6334,12 @@ function KanbanColumn({
|
|
|
5411
6334
|
}
|
|
5412
6335
|
);
|
|
5413
6336
|
const footerNode = renderFooter ? renderFooter(column) : footer;
|
|
5414
|
-
const body = /* @__PURE__ */
|
|
5415
|
-
enableDrag ? /* @__PURE__ */
|
|
5416
|
-
footerNode != null && footerNode !== false ? /* @__PURE__ */
|
|
6337
|
+
const body = /* @__PURE__ */ jsxs32(Fragment9, { children: [
|
|
6338
|
+
enableDrag ? /* @__PURE__ */ jsx43(SortableContext, { items: column.items.map((item) => item.id), strategy: verticalListSortingStrategy, children: cards }) : cards,
|
|
6339
|
+
footerNode != null && footerNode !== false ? /* @__PURE__ */ jsx43(Box13, { "data-gds-kanban-footer": column.id, children: footerNode }) : null
|
|
5417
6340
|
] });
|
|
5418
|
-
return /* @__PURE__ */
|
|
5419
|
-
|
|
6341
|
+
return /* @__PURE__ */ jsx43(
|
|
6342
|
+
Paper9,
|
|
5420
6343
|
{
|
|
5421
6344
|
withBorder: true,
|
|
5422
6345
|
radius: "lg",
|
|
@@ -5424,10 +6347,10 @@ function KanbanColumn({
|
|
|
5424
6347
|
style: width ? { minWidth: width, flex: "0 0 auto" } : void 0,
|
|
5425
6348
|
"data-gds-kanban-column": column.id,
|
|
5426
6349
|
"data-gds-kanban-column-collapsed": collapsible && resolvedCollapsed ? "true" : void 0,
|
|
5427
|
-
children: /* @__PURE__ */
|
|
5428
|
-
/* @__PURE__ */
|
|
5429
|
-
/* @__PURE__ */
|
|
5430
|
-
collapsible ? /* @__PURE__ */
|
|
6350
|
+
children: /* @__PURE__ */ jsxs32(Stack20, { gap: "sm", children: [
|
|
6351
|
+
/* @__PURE__ */ jsxs32(Group24, { justify: "space-between", align: "center", wrap: "nowrap", "data-gds-kanban-column-header": column.id, children: [
|
|
6352
|
+
/* @__PURE__ */ jsxs32(Group24, { gap: "xs", wrap: "nowrap", style: { minWidth: 0 }, children: [
|
|
6353
|
+
collapsible ? /* @__PURE__ */ jsx43(
|
|
5431
6354
|
ActionIcon5,
|
|
5432
6355
|
{
|
|
5433
6356
|
variant: "subtle",
|
|
@@ -5439,14 +6362,14 @@ function KanbanColumn({
|
|
|
5439
6362
|
"aria-controls": bodyId,
|
|
5440
6363
|
onClick: handleToggleCollapsed,
|
|
5441
6364
|
style: { flexShrink: 0 },
|
|
5442
|
-
children: /* @__PURE__ */
|
|
6365
|
+
children: /* @__PURE__ */ jsx43(ColumnDisclosureGlyph, { collapsed: resolvedCollapsed })
|
|
5443
6366
|
}
|
|
5444
6367
|
) : null,
|
|
5445
|
-
/* @__PURE__ */
|
|
6368
|
+
/* @__PURE__ */ jsx43(Title4, { order: 4, children: column.title })
|
|
5446
6369
|
] }),
|
|
5447
|
-
/* @__PURE__ */
|
|
6370
|
+
/* @__PURE__ */ jsx43(Badge3, { variant: "light", children: count })
|
|
5448
6371
|
] }),
|
|
5449
|
-
collapsible ? /* @__PURE__ */
|
|
6372
|
+
collapsible ? /* @__PURE__ */ jsx43("div", { id: bodyId, hidden: resolvedCollapsed, "data-gds-kanban-column-body": column.id, children: resolvedCollapsed ? null : /* @__PURE__ */ jsx43(Stack20, { gap: "sm", children: body }) }) : body
|
|
5450
6373
|
] })
|
|
5451
6374
|
}
|
|
5452
6375
|
);
|
|
@@ -5476,16 +6399,16 @@ function KanbanBoard({
|
|
|
5476
6399
|
collapsedColumnIds,
|
|
5477
6400
|
onCollapsedChange
|
|
5478
6401
|
}) {
|
|
5479
|
-
const { t } =
|
|
6402
|
+
const { t } = useGdsTranslation31();
|
|
5480
6403
|
const autoOrientation = useGdsKanbanOrientation();
|
|
5481
6404
|
const resolvedOrientation = orientation === "auto" ? autoOrientation : orientation;
|
|
5482
6405
|
const regionLabel = boardLabel ?? (typeof title === "string" ? title : t("gds.kanban.boardLabel", "Kanban board"));
|
|
5483
|
-
const [activeItem, setActiveItem] =
|
|
5484
|
-
const [internalCollapsedIds, setInternalCollapsedIds] =
|
|
6406
|
+
const [activeItem, setActiveItem] = useState24(null);
|
|
6407
|
+
const [internalCollapsedIds, setInternalCollapsedIds] = useState24([]);
|
|
5485
6408
|
const isCollapseControlled = collapsedColumnIds !== void 0;
|
|
5486
6409
|
const collapsedIds = isCollapseControlled ? collapsedColumnIds : internalCollapsedIds;
|
|
5487
|
-
const viewportRef =
|
|
5488
|
-
|
|
6410
|
+
const viewportRef = useRef14(null);
|
|
6411
|
+
useEffect13(() => {
|
|
5489
6412
|
const viewport = viewportRef.current;
|
|
5490
6413
|
if (!viewport || columnPanZone !== "header" || resolvedOrientation === "stacked") {
|
|
5491
6414
|
return void 0;
|
|
@@ -5581,7 +6504,7 @@ function KanbanBoard({
|
|
|
5581
6504
|
"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
6505
|
)
|
|
5583
6506
|
};
|
|
5584
|
-
const columnList = (width) => columns.map((column) => /* @__PURE__ */
|
|
6507
|
+
const columnList = (width) => columns.map((column) => /* @__PURE__ */ jsx43(
|
|
5585
6508
|
KanbanColumn,
|
|
5586
6509
|
{
|
|
5587
6510
|
column,
|
|
@@ -5600,14 +6523,14 @@ function KanbanBoard({
|
|
|
5600
6523
|
},
|
|
5601
6524
|
column.id
|
|
5602
6525
|
));
|
|
5603
|
-
const board = /* @__PURE__ */
|
|
5604
|
-
title ? typeof title === "string" ? /* @__PURE__ */
|
|
5605
|
-
resolvedOrientation === "stacked" ? /* @__PURE__ */
|
|
6526
|
+
const board = /* @__PURE__ */ jsxs32(Stack20, { gap: "md", role: "region", "aria-label": regionLabel, "data-gds-kanban-orientation": resolvedOrientation, children: [
|
|
6527
|
+
title ? typeof title === "string" ? /* @__PURE__ */ jsx43(Title4, { order: 3, children: title }) : title : null,
|
|
6528
|
+
resolvedOrientation === "stacked" ? /* @__PURE__ */ jsx43(Stack20, { gap: "lg", children: columnList(void 0) }) : /* @__PURE__ */ jsx43(ScrollArea4, { type: "auto", scrollbarSize: 8, offsetScrollbars: true, viewportRef, children: /* @__PURE__ */ jsx43(Group24, { gap: "md", wrap: "nowrap", align: "flex-start", children: columnList(columnWidth) }) })
|
|
5606
6529
|
] });
|
|
5607
6530
|
if (!dragActive) {
|
|
5608
6531
|
return board;
|
|
5609
6532
|
}
|
|
5610
|
-
return /* @__PURE__ */
|
|
6533
|
+
return /* @__PURE__ */ jsxs32(
|
|
5611
6534
|
DndContext,
|
|
5612
6535
|
{
|
|
5613
6536
|
sensors,
|
|
@@ -5618,7 +6541,7 @@ function KanbanBoard({
|
|
|
5618
6541
|
onDragEnd: handleDragEnd,
|
|
5619
6542
|
children: [
|
|
5620
6543
|
board,
|
|
5621
|
-
/* @__PURE__ */
|
|
6544
|
+
/* @__PURE__ */ jsx43(DragOverlay, { children: activeItem ? /* @__PURE__ */ jsx43(Paper9, { withBorder: true, radius: "md", p: "sm", shadow: "md", children: /* @__PURE__ */ jsx43(Stack20, { gap: 2, children: typeof activeItem.item.title === "string" ? /* @__PURE__ */ jsx43(Text27, { fw: 600, size: "sm", children: activeItem.item.title }) : activeItem.item.title }) }) : null })
|
|
5622
6545
|
]
|
|
5623
6546
|
}
|
|
5624
6547
|
);
|
|
@@ -5626,6 +6549,9 @@ function KanbanBoard({
|
|
|
5626
6549
|
|
|
5627
6550
|
export {
|
|
5628
6551
|
GDS_BUTTON_FEEDBACK_DURATION_MS,
|
|
6552
|
+
GDS_BUTTON_PENDING_DELAY_MS,
|
|
6553
|
+
GDS_BUTTON_PENDING_MIN_MS,
|
|
6554
|
+
GDS_BUTTON_CONFIRM_WINDOW_MS,
|
|
5629
6555
|
GDS_BUTTON_GRADIENT_TEXT_FLOOR,
|
|
5630
6556
|
GDS_BUTTON_OUTLINE_ACCENT_STROKE_PX,
|
|
5631
6557
|
SemanticButton,
|
|
@@ -5634,6 +6560,13 @@ export {
|
|
|
5634
6560
|
GdsDensityProvider,
|
|
5635
6561
|
useGdsDensity,
|
|
5636
6562
|
useGdsCardContract,
|
|
6563
|
+
getGdsShapeScopeStyle,
|
|
6564
|
+
GdsShapeScope,
|
|
6565
|
+
GdsTreeView,
|
|
6566
|
+
GdsBulkActionBar,
|
|
6567
|
+
GdsThreadList,
|
|
6568
|
+
GdsMessageThread,
|
|
6569
|
+
GdsViewToggle,
|
|
5637
6570
|
ProviderCTA,
|
|
5638
6571
|
listingQueryReducer,
|
|
5639
6572
|
ListingProvider,
|
|
@@ -5648,6 +6581,9 @@ export {
|
|
|
5648
6581
|
SidebarNavSection,
|
|
5649
6582
|
SidebarNavItem,
|
|
5650
6583
|
DocsCodeBlock,
|
|
6584
|
+
DocsCodeDisclosure,
|
|
6585
|
+
GdsTableScrollContainer,
|
|
6586
|
+
GdsReleaseNotes,
|
|
5651
6587
|
ShareButtonGroup,
|
|
5652
6588
|
UploadDropzone,
|
|
5653
6589
|
createGdsAssetAdapter,
|
|
@@ -5694,6 +6630,7 @@ export {
|
|
|
5694
6630
|
useGdsNotifications,
|
|
5695
6631
|
NotificationCenter,
|
|
5696
6632
|
GdsNotificationCenter,
|
|
6633
|
+
GdsToastViewport,
|
|
5697
6634
|
GdsConfirmProvider,
|
|
5698
6635
|
useGdsConfirm,
|
|
5699
6636
|
GdsToastProvider,
|
|
@@ -5724,6 +6661,8 @@ export {
|
|
|
5724
6661
|
usePlaybackKeyboardControls,
|
|
5725
6662
|
PlaybackControls,
|
|
5726
6663
|
PlaybackOverlayControls,
|
|
6664
|
+
GdsAssetManagerTemplate,
|
|
6665
|
+
GdsWorkspaceInboxTemplate,
|
|
5727
6666
|
ReportOutdatedLink,
|
|
5728
6667
|
SourceBlock,
|
|
5729
6668
|
ConfirmChecklist,
|