@sovereignsquad/gds-core 6.9.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/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-Bgjdfs_t.d.ts → QuickStartCard-BqbYrKRY.d.ts} +1034 -90
- package/dist/{QuickStartCard-DnZMDjzb.d.mts → QuickStartCard-lE9kMqH8.d.mts} +1034 -90
- package/dist/{chunk-KEYBUMOR.mjs → chunk-7NNKXZFF.mjs} +29 -4
- package/dist/{chunk-IMT3UTOT.mjs → chunk-CWMDWMYL.mjs} +28 -3
- package/dist/{chunk-BD5XQH5Z.mjs → chunk-D65VHUXK.mjs} +28 -3
- package/dist/{chunk-MKEWYVTJ.mjs → chunk-J4TSXITU.mjs} +30 -5
- package/dist/{chunk-3B5MK2PG.mjs → chunk-LTNPECWV.mjs} +959 -632
- package/dist/{chunk-5G3XZWSW.mjs → chunk-MO5TLIIB.mjs} +1039 -1605
- package/dist/{chunk-WI24JME4.mjs → chunk-PCG34VRY.mjs} +12 -1
- package/dist/{chunk-EQ7Y2PUI.mjs → chunk-PJR3OJJD.mjs} +811 -185
- package/dist/{chunk-F76YTG3S.mjs → chunk-PLJT4I7B.mjs} +84 -59
- package/dist/{chunk-KLFTBWEG.mjs → chunk-RBXAJJB2.mjs} +29 -4
- package/dist/{chunk-HJVDKPVW.mjs → chunk-SV3VL3GG.mjs} +3 -2
- package/dist/{chunk-KNP35WAB.mjs → chunk-TD3JPMMO.mjs} +1 -1
- package/dist/{chunk-5GH7XD7X.mjs → chunk-TVGDH5O5.mjs} +29 -4
- package/dist/{chunk-OH5HH4G3.mjs → chunk-V5WUGRFL.mjs} +29 -4
- package/dist/{chunk-DBJE4TRO.mjs → chunk-V6SP5O4D.mjs} +66 -41
- package/dist/{chunk-A32PWTD2.mjs → chunk-XL7MGQJ4.mjs} +28 -3
- package/dist/{chunk-LERXSJHD.mjs → chunk-YASVRGKJ.mjs} +30 -5
- package/dist/{chunk-6WDH57MJ.mjs → chunk-Z6XXK57E.mjs} +28 -3
- package/dist/client.d.mts +123 -8
- package/dist/client.d.ts +123 -8
- package/dist/client.js +2495 -1810
- package/dist/client.mjs +41 -29
- package/dist/{en-D9CWSH3F.d.ts → en-CzuiMnTG.d.mts} +27 -2
- package/dist/{en-D9CWSH3F.d.mts → en-CzuiMnTG.d.ts} +27 -2
- package/dist/index.d.mts +24 -22
- package/dist/index.d.ts +24 -22
- package/dist/index.js +3867 -3066
- package/dist/index.mjs +182 -61
- package/dist/locales/lazy/all.js +438 -138
- package/dist/locales/lazy/all.mjs +13 -13
- package/dist/locales/lazy/ar.js +57 -7
- package/dist/locales/lazy/ar.mjs +3 -3
- package/dist/locales/lazy/de.js +57 -7
- package/dist/locales/lazy/de.mjs +3 -3
- package/dist/locales/lazy/es.js +58 -8
- package/dist/locales/lazy/es.mjs +3 -3
- package/dist/locales/lazy/fr.js +56 -6
- package/dist/locales/lazy/fr.mjs +3 -3
- package/dist/locales/lazy/he.js +58 -8
- package/dist/locales/lazy/he.mjs +3 -3
- package/dist/locales/lazy/hu.js +56 -6
- package/dist/locales/lazy/hu.mjs +3 -3
- package/dist/locales/lazy/index.d.mts +1 -1
- package/dist/locales/lazy/index.d.ts +1 -1
- package/dist/locales/lazy/index.js +28 -3
- package/dist/locales/lazy/index.mjs +2 -2
- package/dist/locales/lazy/it.js +57 -7
- package/dist/locales/lazy/it.mjs +3 -3
- package/dist/locales/lazy/ja.js +56 -6
- package/dist/locales/lazy/ja.mjs +3 -3
- package/dist/locales/lazy/ko.js +112 -62
- package/dist/locales/lazy/ko.mjs +3 -3
- package/dist/locales/lazy/ru.js +57 -7
- package/dist/locales/lazy/ru.mjs +3 -3
- package/dist/locales/lazy/zh.js +94 -44
- package/dist/locales/lazy/zh.mjs +3 -3
- package/dist/map.d.mts +1 -1
- package/dist/map.d.ts +1 -1
- package/dist/reference-theme-explorer.d.mts +3 -1
- package/dist/reference-theme-explorer.d.ts +3 -1
- package/dist/reference-theme-explorer.js +1458 -526
- package/dist/reference-theme-explorer.mjs +57 -37
- package/dist/server.d.mts +6 -6
- package/dist/server.d.ts +6 -6
- package/dist/server.js +1261 -892
- package/dist/server.mjs +31 -29
- package/package.json +4 -4
|
@@ -2,10 +2,12 @@ import {
|
|
|
2
2
|
GdsInlineLink
|
|
3
3
|
} from "./chunk-W5O2JSVK.mjs";
|
|
4
4
|
import {
|
|
5
|
+
BodyText,
|
|
6
|
+
CardTitle,
|
|
5
7
|
CtaButtonGroup,
|
|
6
|
-
GdsInline,
|
|
7
|
-
GdsStack,
|
|
8
8
|
InlineAlert,
|
|
9
|
+
InlineEmphasis,
|
|
10
|
+
InlineText,
|
|
9
11
|
LastCheckedLabel,
|
|
10
12
|
MediaPreviewCard,
|
|
11
13
|
MetadataText,
|
|
@@ -21,15 +23,18 @@ import {
|
|
|
21
23
|
renderGdsLayoutWithDiagnostics,
|
|
22
24
|
sortGdsAccessGateActions,
|
|
23
25
|
validateGdsAccessGateContract
|
|
24
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-MO5TLIIB.mjs";
|
|
25
27
|
import {
|
|
26
28
|
FormField,
|
|
29
|
+
GdsBox,
|
|
30
|
+
GdsInline,
|
|
31
|
+
GdsStack,
|
|
27
32
|
SectionPanel,
|
|
28
33
|
createGdsVocabularyPack,
|
|
29
34
|
getSemanticActionLabel,
|
|
30
35
|
resolveGdsCardContract,
|
|
31
36
|
resolveSemanticActionConfig
|
|
32
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-PJR3OJJD.mjs";
|
|
33
38
|
import {
|
|
34
39
|
StateBlock
|
|
35
40
|
} from "./chunk-SPPTDVJC.mjs";
|
|
@@ -39,12 +44,15 @@ import {
|
|
|
39
44
|
} from "./chunk-J66ITCXC.mjs";
|
|
40
45
|
|
|
41
46
|
// src/SemanticButton.tsx
|
|
42
|
-
import { useEffect, useState } from "react";
|
|
47
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
43
48
|
import { Button, VisuallyHidden } from "@mantine/core";
|
|
44
49
|
import { gdsDevWarnOnce, useGdsTranslation } from "@sovereignsquad/gds-theme";
|
|
45
|
-
import { IconCheck, IconX } from "@tabler/icons-react";
|
|
50
|
+
import { IconCheck, IconLoader2, IconX } from "@tabler/icons-react";
|
|
46
51
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
47
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;
|
|
48
56
|
var GDS_BUTTON_GRADIENT_TEXT_FLOOR = { fontSizePx: 14, fontWeight: 600 };
|
|
49
57
|
var GDS_BUTTON_OUTLINE_ACCENT_STROKE_PX = 1.5;
|
|
50
58
|
var brandButtonStyles = {
|
|
@@ -79,12 +87,71 @@ var brandButtonStyles = {
|
|
|
79
87
|
"outline-accent": {},
|
|
80
88
|
gradient: {}
|
|
81
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
|
+
}
|
|
82
148
|
function SemanticButton({
|
|
83
149
|
action,
|
|
84
150
|
brandVariant,
|
|
85
151
|
loading,
|
|
86
152
|
feedbackState,
|
|
87
153
|
feedbackText,
|
|
154
|
+
onAction,
|
|
88
155
|
prerenderLabelOnly = true,
|
|
89
156
|
vocabularyPacks = [],
|
|
90
157
|
label: labelOverride,
|
|
@@ -98,8 +165,32 @@ function SemanticButton({
|
|
|
98
165
|
}
|
|
99
166
|
const { t } = useGdsTranslation();
|
|
100
167
|
const config = resolveSemanticActionConfig(action, vocabularyPacks);
|
|
168
|
+
const motion = config.motion;
|
|
101
169
|
const [mounted, setMounted] = useState(!prerenderLabelOnly);
|
|
102
|
-
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]);
|
|
103
194
|
useEffect(() => {
|
|
104
195
|
if (prerenderLabelOnly) {
|
|
105
196
|
setMounted(true);
|
|
@@ -107,48 +198,116 @@ function SemanticButton({
|
|
|
107
198
|
}, [prerenderLabelOnly]);
|
|
108
199
|
useEffect(() => {
|
|
109
200
|
if (feedbackState) {
|
|
110
|
-
|
|
111
|
-
|
|
201
|
+
setFromRest(true);
|
|
202
|
+
setCycle((n) => n + 1);
|
|
203
|
+
setPhase(feedbackState);
|
|
204
|
+
const timer = setTimeout(() => setPhase("idle"), GDS_BUTTON_FEEDBACK_DURATION_MS);
|
|
112
205
|
return () => clearTimeout(timer);
|
|
113
206
|
}
|
|
114
|
-
}, [feedbackState]);
|
|
115
|
-
|
|
116
|
-
|
|
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;
|
|
117
258
|
let color = props.color;
|
|
118
259
|
const brandStyle = brandVariant ? brandButtonStyles[brandVariant] : void 0;
|
|
119
260
|
const disabled = props.disabled || brandVariant === "disabled";
|
|
261
|
+
const showingFeedback = phase === "success" || phase === "error";
|
|
120
262
|
const isStylesheetPaintedBrand = brandVariant === "outline-accent" || brandVariant === "gradient";
|
|
121
|
-
const brandButtonAttr = isStylesheetPaintedBrand &&
|
|
263
|
+
const brandButtonAttr = isStylesheetPaintedBrand && showingFeedback ? void 0 : brandVariant;
|
|
122
264
|
if (!mounted) {
|
|
123
|
-
const { leftSection, style, ...
|
|
124
|
-
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) });
|
|
125
267
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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;
|
|
134
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;
|
|
135
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";
|
|
136
289
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
137
290
|
/* @__PURE__ */ jsx(
|
|
138
291
|
Button,
|
|
139
292
|
{
|
|
140
|
-
...
|
|
141
|
-
|
|
293
|
+
...buttonRest,
|
|
294
|
+
onClick: handleClick,
|
|
295
|
+
leftSection: /* @__PURE__ */ jsx(ButtonIcon, { phase, motion, Icon: config.icon, SuccessIcon: feedbackConfig.icon, fromRest }, `${phase}-${cycle}`),
|
|
142
296
|
loading,
|
|
143
297
|
color,
|
|
144
298
|
"data-gds-brand-button": brandButtonAttr,
|
|
299
|
+
"data-gds-button-phase": phase === "idle" ? void 0 : phase,
|
|
145
300
|
disabled,
|
|
146
|
-
"aria-
|
|
301
|
+
"aria-disabled": busy ? true : void 0,
|
|
302
|
+
"aria-busy": loading || busy ? true : void 0,
|
|
147
303
|
style: { ...brandStyle, ...props.style },
|
|
148
|
-
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
|
|
149
308
|
}
|
|
150
309
|
),
|
|
151
|
-
|
|
310
|
+
reservesWidth ? /* @__PURE__ */ jsx(VisuallyHidden, { role: "status", "aria-live": "polite", "aria-atomic": "true", children: announcement }) : null
|
|
152
311
|
] });
|
|
153
312
|
}
|
|
154
313
|
|
|
@@ -260,7 +419,7 @@ function GdsShapeScope({ profile, style, children, ...others }) {
|
|
|
260
419
|
}
|
|
261
420
|
|
|
262
421
|
// src/GdsTreeView.tsx
|
|
263
|
-
import { useCallback, useMemo, useRef, useState as useState2 } from "react";
|
|
422
|
+
import { useCallback as useCallback2, useMemo, useRef as useRef2, useState as useState2 } from "react";
|
|
264
423
|
import { Box as Box2, Button as Button2, Group as Group2, Loader, Paper as Paper2, Text as Text3 } from "@mantine/core";
|
|
265
424
|
import { useUncontrolled } from "@mantine/hooks";
|
|
266
425
|
import { useGdsTranslation as useGdsTranslation3 } from "@sovereignsquad/gds-theme";
|
|
@@ -281,8 +440,8 @@ function GdsTreeView({
|
|
|
281
440
|
const [selected, setSelected] = useUncontrolled({ value: selectedId, defaultValue: defaultSelectedId, finalValue: null });
|
|
282
441
|
const [loads, setLoads] = useState2({});
|
|
283
442
|
const [focusedId, setFocusedId] = useState2(null);
|
|
284
|
-
const itemRefs =
|
|
285
|
-
const childrenOf =
|
|
443
|
+
const itemRefs = useRef2(/* @__PURE__ */ new Map());
|
|
444
|
+
const childrenOf = useCallback2((node) => {
|
|
286
445
|
if (node.children) return node.children;
|
|
287
446
|
const load2 = loads[node.id];
|
|
288
447
|
return load2?.status === "loaded" ? load2.children : void 0;
|
|
@@ -1155,7 +1314,7 @@ function DocsShell({
|
|
|
1155
1314
|
mobileNavigationLabel: t("gds.navigation.openMobile", "Open docs navigation"),
|
|
1156
1315
|
hideMobileNavigationToggle: mobileNavigationMode === "inline-collapse" && Boolean(mobileNavigation),
|
|
1157
1316
|
headerHeight: 72,
|
|
1158
|
-
children: /* @__PURE__ */ jsx14(Container, { size: resolveContentContainerSize(contentWidth), px: "md", py: "lg", w: "100%", children })
|
|
1317
|
+
children: /* @__PURE__ */ jsx14(Container, { size: resolveContentContainerSize(contentWidth), px: { base: 0, sm: "md" }, py: "lg", w: "100%", children })
|
|
1159
1318
|
}
|
|
1160
1319
|
);
|
|
1161
1320
|
}
|
|
@@ -1224,8 +1383,10 @@ var SidebarNavItem = createPolymorphicComponent(_SidebarNavItem);
|
|
|
1224
1383
|
// src/DocsCodeBlock.tsx
|
|
1225
1384
|
import { useState as useState6 } from "react";
|
|
1226
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";
|
|
1227
1387
|
import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1228
1388
|
function DocsCodeBlock({ code, language, title, withCopy = true }) {
|
|
1389
|
+
const { t } = useGdsTranslation12();
|
|
1229
1390
|
const [copied, setCopied] = useState6(false);
|
|
1230
1391
|
const handleCopy = async () => {
|
|
1231
1392
|
if (!navigator?.clipboard) {
|
|
@@ -1247,7 +1408,7 @@ function DocsCodeBlock({ code, language, title, withCopy = true }) {
|
|
|
1247
1408
|
"data-gds-copy-action": true,
|
|
1248
1409
|
variant: "default",
|
|
1249
1410
|
size: "xl",
|
|
1250
|
-
"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"),
|
|
1251
1412
|
onClick: () => {
|
|
1252
1413
|
void handleCopy();
|
|
1253
1414
|
},
|
|
@@ -1255,15 +1416,175 @@ function DocsCodeBlock({ code, language, title, withCopy = true }) {
|
|
|
1255
1416
|
}
|
|
1256
1417
|
) : null
|
|
1257
1418
|
] }) : null,
|
|
1258
|
-
/* @__PURE__ */ jsx16(Code, { block: true, children: code })
|
|
1419
|
+
/* @__PURE__ */ jsx16(Code, { block: true, tabIndex: 0, role: "group", "aria-label": title ?? t("gds.docsCodeBlock.region", "Code"), children: code })
|
|
1259
1420
|
] }) });
|
|
1260
1421
|
}
|
|
1261
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
|
+
|
|
1262
1583
|
// src/ShareButtonGroup.tsx
|
|
1263
|
-
import { useGdsTranslation as
|
|
1264
|
-
import { useState as
|
|
1584
|
+
import { useGdsTranslation as useGdsTranslation15 } from "@sovereignsquad/gds-theme";
|
|
1585
|
+
import { useState as useState8 } from "react";
|
|
1265
1586
|
import { ActionIcon as ActionIcon2, Button as Button5, Group as Group9, Stack as Stack6, Text as Text11 } from "@mantine/core";
|
|
1266
|
-
import { jsx as
|
|
1587
|
+
import { jsx as jsx20, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1267
1588
|
var channelLabels = {
|
|
1268
1589
|
native: "Share",
|
|
1269
1590
|
copy: "Copy link",
|
|
@@ -1298,9 +1619,9 @@ function ShareAction({
|
|
|
1298
1619
|
const label = channelLabels[channel];
|
|
1299
1620
|
const Icon = channel === "copy" ? GdsIcons.Copy : channel === "mail" ? GdsIcons.Mail : channel === "message" ? GdsIcons.Message : GdsIcons.Refer;
|
|
1300
1621
|
if (compact) {
|
|
1301
|
-
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 }) });
|
|
1302
1623
|
}
|
|
1303
|
-
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 });
|
|
1304
1625
|
}
|
|
1305
1626
|
function ShareButtonGroup({
|
|
1306
1627
|
url,
|
|
@@ -1311,10 +1632,10 @@ function ShareButtonGroup({
|
|
|
1311
1632
|
label: labelProp,
|
|
1312
1633
|
description
|
|
1313
1634
|
}) {
|
|
1314
|
-
const { t } =
|
|
1635
|
+
const { t } = useGdsTranslation15();
|
|
1315
1636
|
const label = labelProp ?? t("gds.shareButtonGroup.label", "Share this");
|
|
1316
|
-
const [copied, setCopied] =
|
|
1317
|
-
const [shared, setShared] =
|
|
1637
|
+
const [copied, setCopied] = useState8(false);
|
|
1638
|
+
const [shared, setShared] = useState8(false);
|
|
1318
1639
|
const hrefs = encodeShare(url, title, text);
|
|
1319
1640
|
async function handleCopy() {
|
|
1320
1641
|
await navigator.clipboard?.writeText?.(url);
|
|
@@ -1330,30 +1651,30 @@ function ShareButtonGroup({
|
|
|
1330
1651
|
}
|
|
1331
1652
|
await handleCopy();
|
|
1332
1653
|
}
|
|
1333
|
-
return /* @__PURE__ */
|
|
1334
|
-
/* @__PURE__ */
|
|
1335
|
-
/* @__PURE__ */
|
|
1336
|
-
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
|
|
1337
1658
|
] }),
|
|
1338
|
-
/* @__PURE__ */
|
|
1659
|
+
/* @__PURE__ */ jsx20(Group9, { gap: "sm", wrap: "wrap", children: channels.map((channel) => {
|
|
1339
1660
|
if (channel === "copy") {
|
|
1340
|
-
return /* @__PURE__ */
|
|
1661
|
+
return /* @__PURE__ */ jsx20(ShareAction, { channel, compact, onClick: () => void handleCopy() }, channel);
|
|
1341
1662
|
}
|
|
1342
1663
|
if (channel === "native") {
|
|
1343
|
-
return /* @__PURE__ */
|
|
1664
|
+
return /* @__PURE__ */ jsx20(ShareAction, { channel, compact, onClick: () => void handleNativeShare() }, channel);
|
|
1344
1665
|
}
|
|
1345
|
-
return /* @__PURE__ */
|
|
1666
|
+
return /* @__PURE__ */ jsx20(ShareAction, { channel, compact, href: hrefs[channel] }, channel);
|
|
1346
1667
|
}) }),
|
|
1347
|
-
copied ? /* @__PURE__ */
|
|
1348
|
-
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
|
|
1349
1670
|
] });
|
|
1350
1671
|
}
|
|
1351
1672
|
|
|
1352
1673
|
// src/UploadDropzone.tsx
|
|
1353
|
-
import { useGdsTranslation as
|
|
1354
|
-
import { useRef as
|
|
1674
|
+
import { useGdsTranslation as useGdsTranslation16 } from "@sovereignsquad/gds-theme";
|
|
1675
|
+
import { useRef as useRef4, useState as useState9 } from "react";
|
|
1355
1676
|
import { Badge, Box as Box8, Button as Button6, Group as Group10, Progress, Stack as Stack7, Text as Text12 } from "@mantine/core";
|
|
1356
|
-
import { jsx as
|
|
1677
|
+
import { jsx as jsx21, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1357
1678
|
function UploadDropzone({
|
|
1358
1679
|
title,
|
|
1359
1680
|
description,
|
|
@@ -1377,10 +1698,10 @@ function UploadDropzone({
|
|
|
1377
1698
|
removeAction,
|
|
1378
1699
|
readonly = false
|
|
1379
1700
|
}) {
|
|
1380
|
-
const { t } =
|
|
1701
|
+
const { t } = useGdsTranslation16();
|
|
1381
1702
|
const actionLabel = actionLabelProp ?? t("gds.uploadDropzone.actionLabel", "Choose files");
|
|
1382
|
-
const inputRef =
|
|
1383
|
-
const [dragging, setDragging] =
|
|
1703
|
+
const inputRef = useRef4(null);
|
|
1704
|
+
const [dragging, setDragging] = useState9(false);
|
|
1384
1705
|
const UploadIcon = GdsIcons.Upload;
|
|
1385
1706
|
const effectiveState = readonly ? "readonly" : dragging ? "drag-active" : state;
|
|
1386
1707
|
const isDisabled = readonly || effectiveState === "upload-pending";
|
|
@@ -1392,7 +1713,7 @@ function UploadDropzone({
|
|
|
1392
1713
|
}
|
|
1393
1714
|
onFilesSelected(Array.from(files));
|
|
1394
1715
|
};
|
|
1395
|
-
return /* @__PURE__ */
|
|
1716
|
+
return /* @__PURE__ */ jsxs15(
|
|
1396
1717
|
Box8,
|
|
1397
1718
|
{
|
|
1398
1719
|
onDragOver: (event) => {
|
|
@@ -1416,7 +1737,7 @@ function UploadDropzone({
|
|
|
1416
1737
|
},
|
|
1417
1738
|
"aria-invalid": isError || void 0,
|
|
1418
1739
|
children: [
|
|
1419
|
-
/* @__PURE__ */
|
|
1740
|
+
/* @__PURE__ */ jsx21(
|
|
1420
1741
|
"input",
|
|
1421
1742
|
{
|
|
1422
1743
|
id: inputId,
|
|
@@ -1433,30 +1754,30 @@ function UploadDropzone({
|
|
|
1433
1754
|
onChange: (event) => forwardFiles(event.currentTarget.files)
|
|
1434
1755
|
}
|
|
1435
1756
|
),
|
|
1436
|
-
/* @__PURE__ */
|
|
1437
|
-
/* @__PURE__ */
|
|
1438
|
-
/* @__PURE__ */
|
|
1439
|
-
/* @__PURE__ */
|
|
1440
|
-
description ? /* @__PURE__ */
|
|
1441
|
-
acceptedTypesLabel || maxSizeLabel ? /* @__PURE__ */
|
|
1442
|
-
acceptedTypesLabel ? /* @__PURE__ */
|
|
1443
|
-
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
|
|
1444
1765
|
] }) : null,
|
|
1445
|
-
selectedFiles.length ? /* @__PURE__ */
|
|
1766
|
+
selectedFiles.length ? /* @__PURE__ */ jsxs15(Text12, { size: "sm", children: [
|
|
1446
1767
|
"Selected: ",
|
|
1447
1768
|
selectedFiles.join(", ")
|
|
1448
1769
|
] }) : null,
|
|
1449
|
-
effectiveState === "upload-pending" && normalizedProgress !== void 0 ? /* @__PURE__ */
|
|
1450
|
-
/* @__PURE__ */
|
|
1451
|
-
/* @__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: [
|
|
1452
1773
|
Math.round(normalizedProgress),
|
|
1453
1774
|
"% uploaded"
|
|
1454
1775
|
] })
|
|
1455
1776
|
] }) : null,
|
|
1456
|
-
policyText ? /* @__PURE__ */
|
|
1457
|
-
error ? /* @__PURE__ */
|
|
1458
|
-
/* @__PURE__ */
|
|
1459
|
-
/* @__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 }),
|
|
1460
1781
|
retryAction,
|
|
1461
1782
|
removeAction
|
|
1462
1783
|
] })
|
|
@@ -1467,9 +1788,9 @@ function UploadDropzone({
|
|
|
1467
1788
|
}
|
|
1468
1789
|
|
|
1469
1790
|
// src/GdsAssetManager.client.tsx
|
|
1470
|
-
import { useCallback as
|
|
1791
|
+
import { useCallback as useCallback4, useMemo as useMemo3, useState as useState10 } from "react";
|
|
1471
1792
|
import { Button as Button7, Group as Group11, Stack as Stack8, Text as Text13, TextInput } from "@mantine/core";
|
|
1472
|
-
import { jsx as
|
|
1793
|
+
import { jsx as jsx22, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1473
1794
|
function emitAssetEvent(onEvent, type, message) {
|
|
1474
1795
|
onEvent?.({ type, message, timestamp: Date.now(), privacy: "metadata-only" });
|
|
1475
1796
|
}
|
|
@@ -1512,8 +1833,8 @@ function useGdsAssetUploadQueue({
|
|
|
1512
1833
|
onEvent,
|
|
1513
1834
|
timeoutMs = 1e4
|
|
1514
1835
|
}) {
|
|
1515
|
-
const [items, setItems] =
|
|
1516
|
-
const uploadItem =
|
|
1836
|
+
const [items, setItems] = useState10([]);
|
|
1837
|
+
const uploadItem = useCallback4(async (item) => {
|
|
1517
1838
|
if (!item.file) return;
|
|
1518
1839
|
const controller = new AbortController();
|
|
1519
1840
|
const timer = window.setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -1536,7 +1857,7 @@ function useGdsAssetUploadQueue({
|
|
|
1536
1857
|
window.clearTimeout(timer);
|
|
1537
1858
|
}
|
|
1538
1859
|
}, [adapter, onEvent, policy, timeoutMs]);
|
|
1539
|
-
const selectFiles =
|
|
1860
|
+
const selectFiles = useCallback4(async (files) => {
|
|
1540
1861
|
for (const file of files) {
|
|
1541
1862
|
const id = assetIdFromFile(file);
|
|
1542
1863
|
emitAssetEvent(onEvent, "asset_selected");
|
|
@@ -1550,16 +1871,16 @@ function useGdsAssetUploadQueue({
|
|
|
1550
1871
|
}
|
|
1551
1872
|
}
|
|
1552
1873
|
}, [onEvent, policy, uploadItem]);
|
|
1553
|
-
const retry =
|
|
1874
|
+
const retry = useCallback4(async (itemId) => {
|
|
1554
1875
|
const item = items.find((entry) => entry.id === itemId);
|
|
1555
1876
|
if (item) await uploadItem(item);
|
|
1556
1877
|
}, [items, uploadItem]);
|
|
1557
|
-
const remove =
|
|
1878
|
+
const remove = useCallback4(async (itemId) => {
|
|
1558
1879
|
const item = items.find((entry) => entry.id === itemId);
|
|
1559
1880
|
if (item?.asset) await adapter.remove?.(item.asset.id);
|
|
1560
1881
|
setItems((current) => current.filter((entry) => entry.id !== itemId));
|
|
1561
1882
|
}, [adapter, items]);
|
|
1562
|
-
const saveMetadata =
|
|
1883
|
+
const saveMetadata = useCallback4((itemId, metadata) => {
|
|
1563
1884
|
setItems((current) => current.map((entry) => {
|
|
1564
1885
|
if (entry.id !== itemId || !entry.asset) return entry;
|
|
1565
1886
|
const asset = { ...entry.asset, ...metadata };
|
|
@@ -1571,7 +1892,7 @@ function useGdsAssetUploadQueue({
|
|
|
1571
1892
|
return { items, selectFiles, retry, remove, saveMetadata };
|
|
1572
1893
|
}
|
|
1573
1894
|
function GdsAssetPreviewCard({ asset, aspectRatio = "1:1" }) {
|
|
1574
|
-
return /* @__PURE__ */
|
|
1895
|
+
return /* @__PURE__ */ jsx22(
|
|
1575
1896
|
MediaPreviewCard,
|
|
1576
1897
|
{
|
|
1577
1898
|
title: asset.fileName,
|
|
@@ -1602,8 +1923,8 @@ function GdsAssetManager({
|
|
|
1602
1923
|
}) {
|
|
1603
1924
|
const queue = useGdsAssetUploadQueue({ adapter, policy, onEvent, timeoutMs });
|
|
1604
1925
|
const accept = useMemo3(() => policy?.acceptedTypes?.join(",") ?? void 0, [policy]);
|
|
1605
|
-
return /* @__PURE__ */
|
|
1606
|
-
/* @__PURE__ */
|
|
1926
|
+
return /* @__PURE__ */ jsxs16(Stack8, { gap: "md", children: [
|
|
1927
|
+
/* @__PURE__ */ jsx22(
|
|
1607
1928
|
UploadDropzone,
|
|
1608
1929
|
{
|
|
1609
1930
|
title,
|
|
@@ -1619,28 +1940,28 @@ function GdsAssetManager({
|
|
|
1619
1940
|
selectedFiles: queue.items.map((item) => item.fileName)
|
|
1620
1941
|
}
|
|
1621
1942
|
),
|
|
1622
|
-
!queue.items.length ? /* @__PURE__ */
|
|
1623
|
-
queue.items.map((item) => /* @__PURE__ */
|
|
1624
|
-
item.asset ? /* @__PURE__ */
|
|
1625
|
-
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: () => {
|
|
1626
1947
|
void queue.retry(item.id);
|
|
1627
1948
|
}, children: "Retry upload" }) : null,
|
|
1628
|
-
item.asset ? /* @__PURE__ */
|
|
1629
|
-
/* @__PURE__ */
|
|
1630
|
-
/* @__PURE__ */
|
|
1631
|
-
/* @__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: () => {
|
|
1632
1953
|
void queue.remove(item.id);
|
|
1633
1954
|
}, children: "Remove" })
|
|
1634
1955
|
] }) : null,
|
|
1635
|
-
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
|
|
1636
1957
|
] }, item.id))
|
|
1637
1958
|
] });
|
|
1638
1959
|
}
|
|
1639
1960
|
|
|
1640
1961
|
// src/AccessRecoveryPanel.tsx
|
|
1641
1962
|
import { Group as Group12 } from "@mantine/core";
|
|
1642
|
-
import { useGdsTranslation as
|
|
1643
|
-
import { jsx as
|
|
1963
|
+
import { useGdsTranslation as useGdsTranslation17 } from "@sovereignsquad/gds-theme";
|
|
1964
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
1644
1965
|
var stateBlockVariantByState = {
|
|
1645
1966
|
unauthenticated: "permission",
|
|
1646
1967
|
"expired-session": "info",
|
|
@@ -1720,7 +2041,7 @@ function ActionGroup({
|
|
|
1720
2041
|
if (actions.length === 0) {
|
|
1721
2042
|
return null;
|
|
1722
2043
|
}
|
|
1723
|
-
return /* @__PURE__ */
|
|
2044
|
+
return /* @__PURE__ */ jsx23(Group12, { gap: "sm", justify: "center", wrap: "wrap", children: actions.map((actionConfig, index) => /* @__PURE__ */ jsx23(
|
|
1724
2045
|
SemanticButton,
|
|
1725
2046
|
{
|
|
1726
2047
|
action: actionConfig.action,
|
|
@@ -1746,7 +2067,7 @@ function AccessRecoveryPanel({
|
|
|
1746
2067
|
supportAction,
|
|
1747
2068
|
compact = false
|
|
1748
2069
|
}) {
|
|
1749
|
-
const { t } =
|
|
2070
|
+
const { t } = useGdsTranslation17();
|
|
1750
2071
|
const defaultCopy = defaultCopyByState[state];
|
|
1751
2072
|
const defaults = defaultActionsForState(state, {
|
|
1752
2073
|
onRetry,
|
|
@@ -1754,14 +2075,14 @@ function AccessRecoveryPanel({
|
|
|
1754
2075
|
onBack,
|
|
1755
2076
|
supportAction
|
|
1756
2077
|
});
|
|
1757
|
-
return /* @__PURE__ */
|
|
2078
|
+
return /* @__PURE__ */ jsx23(
|
|
1758
2079
|
StateBlock,
|
|
1759
2080
|
{
|
|
1760
2081
|
variant: stateBlockVariantByState[state],
|
|
1761
2082
|
compact,
|
|
1762
2083
|
title: title ?? t(`gds.accessRecovery.${state}.title`, defaultCopy.title),
|
|
1763
2084
|
description: description ?? t(`gds.accessRecovery.${state}.description`, defaultCopy.description),
|
|
1764
|
-
action: /* @__PURE__ */
|
|
2085
|
+
action: /* @__PURE__ */ jsx23(
|
|
1765
2086
|
ActionGroup,
|
|
1766
2087
|
{
|
|
1767
2088
|
primaryAction: primaryAction ?? defaults.primary,
|
|
@@ -1774,10 +2095,10 @@ function AccessRecoveryPanel({
|
|
|
1774
2095
|
}
|
|
1775
2096
|
|
|
1776
2097
|
// src/GdsAccessGate.tsx
|
|
1777
|
-
import { useEffect as
|
|
2098
|
+
import { useEffect as useEffect4, useId } from "react";
|
|
1778
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";
|
|
1779
|
-
import { gdsDevWarnOnce as gdsDevWarnOnce2, useGdsTranslation as
|
|
1780
|
-
import { jsx as
|
|
2100
|
+
import { gdsDevWarnOnce as gdsDevWarnOnce2, useGdsTranslation as useGdsTranslation18 } from "@sovereignsquad/gds-theme";
|
|
2101
|
+
import { jsx as jsx24, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1781
2102
|
var defaultReasonByState = {
|
|
1782
2103
|
locked: "login-required",
|
|
1783
2104
|
"permission-denied": "role-required",
|
|
@@ -1850,7 +2171,7 @@ function GdsAccessGate({
|
|
|
1850
2171
|
onAction,
|
|
1851
2172
|
onEvent
|
|
1852
2173
|
}) {
|
|
1853
|
-
const { t } =
|
|
2174
|
+
const { t } = useGdsTranslation18();
|
|
1854
2175
|
const teaserLabel = teaserLabelProp ?? t("gds.gdsAccessGate.teaserLabel", "Preview");
|
|
1855
2176
|
const headingId = useId();
|
|
1856
2177
|
const sortedActions = sortGdsAccessGateActions(actions);
|
|
@@ -1875,7 +2196,7 @@ function GdsAccessGate({
|
|
|
1875
2196
|
);
|
|
1876
2197
|
}
|
|
1877
2198
|
const emit = (event) => onEvent?.(event);
|
|
1878
|
-
|
|
2199
|
+
useEffect4(() => {
|
|
1879
2200
|
if (validation.length > 0) {
|
|
1880
2201
|
onEvent?.(createGdsAccessGateEvent("gds.access_gate.error", { id, state: "error", reason: "unknown-error" }, { validationFailures: validation.length }));
|
|
1881
2202
|
return;
|
|
@@ -1887,7 +2208,7 @@ function GdsAccessGate({
|
|
|
1887
2208
|
void action.onClick?.();
|
|
1888
2209
|
void onAction?.(action);
|
|
1889
2210
|
};
|
|
1890
|
-
return /* @__PURE__ */
|
|
2211
|
+
return /* @__PURE__ */ jsx24(
|
|
1891
2212
|
Card,
|
|
1892
2213
|
{
|
|
1893
2214
|
component: "section",
|
|
@@ -1897,17 +2218,17 @@ function GdsAccessGate({
|
|
|
1897
2218
|
p: "lg",
|
|
1898
2219
|
"data-gds-access-gate": id,
|
|
1899
2220
|
"data-gds-access-state": state,
|
|
1900
|
-
children: /* @__PURE__ */
|
|
1901
|
-
/* @__PURE__ */
|
|
1902
|
-
/* @__PURE__ */
|
|
1903
|
-
/* @__PURE__ */
|
|
1904
|
-
/* @__PURE__ */
|
|
1905
|
-
/* @__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 })
|
|
1906
2227
|
] }),
|
|
1907
|
-
entitlementLabel ? /* @__PURE__ */
|
|
2228
|
+
entitlementLabel ? /* @__PURE__ */ jsx24(Badge2, { variant: unlocked ? "filled" : "outline", children: entitlementLabel }) : null
|
|
1908
2229
|
] }),
|
|
1909
|
-
/* @__PURE__ */
|
|
1910
|
-
loading ? /* @__PURE__ */
|
|
2230
|
+
/* @__PURE__ */ jsx24(Box9, { "data-gds-access-preview": true, children: preview }),
|
|
2231
|
+
loading ? /* @__PURE__ */ jsx24(
|
|
1911
2232
|
StateBlock,
|
|
1912
2233
|
{
|
|
1913
2234
|
variant: "loading",
|
|
@@ -1916,11 +2237,11 @@ function GdsAccessGate({
|
|
|
1916
2237
|
compact: true
|
|
1917
2238
|
}
|
|
1918
2239
|
) : null,
|
|
1919
|
-
unlocked ? /* @__PURE__ */
|
|
1920
|
-
!unlocked && softGate && !loading ? /* @__PURE__ */
|
|
1921
|
-
!unlocked && !loading ? /* @__PURE__ */
|
|
1922
|
-
/* @__PURE__ */
|
|
1923
|
-
/* @__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(
|
|
1924
2245
|
AccessRecoveryPanel,
|
|
1925
2246
|
{
|
|
1926
2247
|
state: recoveryStateForGate(state, reason),
|
|
@@ -1949,7 +2270,7 @@ function GdsAccessGate({
|
|
|
1949
2270
|
} : null
|
|
1950
2271
|
}
|
|
1951
2272
|
),
|
|
1952
|
-
sortedActions.some((action) => action.label) ? /* @__PURE__ */
|
|
2273
|
+
sortedActions.some((action) => action.label) ? /* @__PURE__ */ jsx24(Group13, { gap: "xs", wrap: "wrap", children: sortedActions.filter((action) => action.label).map((action) => /* @__PURE__ */ jsx24(
|
|
1953
2274
|
Button8,
|
|
1954
2275
|
{
|
|
1955
2276
|
variant: "subtle",
|
|
@@ -1970,7 +2291,7 @@ function GdsAccessGate({
|
|
|
1970
2291
|
// src/GdsDateInput.client.tsx
|
|
1971
2292
|
import { DateInput, DatePickerInput, DateTimePicker } from "@mantine/dates";
|
|
1972
2293
|
import { gdsDevWarnOnce as gdsDevWarnOnce3 } from "@sovereignsquad/gds-theme";
|
|
1973
|
-
import { jsx as
|
|
2294
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
1974
2295
|
function resolveDateValue(value) {
|
|
1975
2296
|
if (value instanceof Date) return value;
|
|
1976
2297
|
if (typeof value === "string" && value.length > 0) return new Date(value);
|
|
@@ -2011,7 +2332,7 @@ function warnOnDateBounds(component, minDate, maxDate, values) {
|
|
|
2011
2332
|
}
|
|
2012
2333
|
function GdsDateInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
2013
2334
|
warnOnDateBounds("GdsDateInput", minDate, maxDate, [resolveDateValue(value)]);
|
|
2014
|
-
return /* @__PURE__ */
|
|
2335
|
+
return /* @__PURE__ */ jsx25(
|
|
2015
2336
|
DateInput,
|
|
2016
2337
|
{
|
|
2017
2338
|
value: resolveDateValue(value),
|
|
@@ -2025,7 +2346,7 @@ function GdsDateInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
|
2025
2346
|
}
|
|
2026
2347
|
function GdsDateTimeInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
2027
2348
|
warnOnDateBounds("GdsDateTimeInput", minDate, maxDate, [resolveDateValue(value)]);
|
|
2028
|
-
return /* @__PURE__ */
|
|
2349
|
+
return /* @__PURE__ */ jsx25(
|
|
2029
2350
|
DateTimePicker,
|
|
2030
2351
|
{
|
|
2031
2352
|
value: resolveDateValue(value),
|
|
@@ -2039,7 +2360,7 @@ function GdsDateTimeInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
|
2039
2360
|
}
|
|
2040
2361
|
function GdsDateRangeInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
2041
2362
|
warnOnDateBounds("GdsDateRangeInput", minDate, maxDate, value ?? [null, null]);
|
|
2042
|
-
return /* @__PURE__ */
|
|
2363
|
+
return /* @__PURE__ */ jsx25(
|
|
2043
2364
|
DatePickerInput,
|
|
2044
2365
|
{
|
|
2045
2366
|
type: "range",
|
|
@@ -2054,10 +2375,10 @@ function GdsDateRangeInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
|
2054
2375
|
}
|
|
2055
2376
|
|
|
2056
2377
|
// src/GdsForm.client.tsx
|
|
2057
|
-
import { useGdsTranslation as
|
|
2058
|
-
import { createContext as createContext3, useCallback 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";
|
|
2059
2380
|
import { Alert, Anchor, Stack as Stack10, Text as Text15 } from "@mantine/core";
|
|
2060
|
-
import { jsx as
|
|
2381
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
2061
2382
|
function createFieldState(value) {
|
|
2062
2383
|
return { value, touched: false, dirty: false };
|
|
2063
2384
|
}
|
|
@@ -2195,13 +2516,13 @@ function useGdsFormOrchestration({
|
|
|
2195
2516
|
onEvent
|
|
2196
2517
|
}) {
|
|
2197
2518
|
const [snapshot, dispatch] = useReducer2(gdsFormReducer, initialValues, createSnapshot);
|
|
2198
|
-
const submitAttempt =
|
|
2199
|
-
const [lastSubmitFailed, setLastSubmitFailed] =
|
|
2200
|
-
const setFieldValue =
|
|
2519
|
+
const submitAttempt = useRef5(0);
|
|
2520
|
+
const [lastSubmitFailed, setLastSubmitFailed] = useState11(false);
|
|
2521
|
+
const setFieldValue = useCallback5((field, value) => {
|
|
2201
2522
|
dispatch({ type: "set-field", field, value });
|
|
2202
2523
|
emitFormEvent(onEvent, "dirty_changed", "idle");
|
|
2203
2524
|
}, [onEvent]);
|
|
2204
|
-
const validateSnapshot =
|
|
2525
|
+
const validateSnapshot = useCallback5(async () => {
|
|
2205
2526
|
dispatch({ type: "set-submit-state", submitState: "validating" });
|
|
2206
2527
|
const syncIssues = sortIssues(validate ? validate(snapshot) : []);
|
|
2207
2528
|
const asyncIssues = syncIssues.some((issue) => issue.severity === "blocking") || !validateAsync ? [] : sortIssues(await validateAsync(snapshot));
|
|
@@ -2214,7 +2535,7 @@ function useGdsFormOrchestration({
|
|
|
2214
2535
|
}
|
|
2215
2536
|
return true;
|
|
2216
2537
|
}, [onEvent, snapshot, validate, validateAsync]);
|
|
2217
|
-
const autosaveDraft =
|
|
2538
|
+
const autosaveDraft = useCallback5(async () => {
|
|
2218
2539
|
if (!draftAdapter) return false;
|
|
2219
2540
|
dispatch({ type: "set-submit-state", submitState: "autosaving" });
|
|
2220
2541
|
await draftAdapter.save(snapshotValues(snapshot));
|
|
@@ -2222,7 +2543,7 @@ function useGdsFormOrchestration({
|
|
|
2222
2543
|
emitFormEvent(onEvent, "autosave_succeeded", "saved");
|
|
2223
2544
|
return true;
|
|
2224
2545
|
}, [draftAdapter, onEvent, snapshot]);
|
|
2225
|
-
const submit =
|
|
2546
|
+
const submit = useCallback5(async () => {
|
|
2226
2547
|
const attempt = submitAttempt.current + 1;
|
|
2227
2548
|
submitAttempt.current = attempt;
|
|
2228
2549
|
const valid = await validateSnapshot();
|
|
@@ -2258,7 +2579,7 @@ function useGdsFormOrchestration({
|
|
|
2258
2579
|
return false;
|
|
2259
2580
|
}
|
|
2260
2581
|
}, [autosave, autosaveDraft, draftAdapter, lastSubmitFailed, mapServerErrors, onEvent, onSubmit, optimisticSubmit, snapshot, validateSnapshot]);
|
|
2261
|
-
const restoreDraft =
|
|
2582
|
+
const restoreDraft = useCallback5(async () => {
|
|
2262
2583
|
const draft = await draftAdapter?.load();
|
|
2263
2584
|
if (!draft) return false;
|
|
2264
2585
|
dispatch({ type: "reset", values: draft });
|
|
@@ -2266,7 +2587,7 @@ function useGdsFormOrchestration({
|
|
|
2266
2587
|
emitFormEvent(onEvent, "draft_restored", "restored");
|
|
2267
2588
|
return true;
|
|
2268
2589
|
}, [draftAdapter, onEvent]);
|
|
2269
|
-
const discardDraft =
|
|
2590
|
+
const discardDraft = useCallback5(async () => {
|
|
2270
2591
|
await draftAdapter?.clear();
|
|
2271
2592
|
}, [draftAdapter]);
|
|
2272
2593
|
return useMemo4(
|
|
@@ -2285,7 +2606,7 @@ function useGdsFormOrchestration({
|
|
|
2285
2606
|
}
|
|
2286
2607
|
var GdsFormContext = createContext3(null);
|
|
2287
2608
|
function GdsFormProvider({ snapshot, children }) {
|
|
2288
|
-
return /* @__PURE__ */
|
|
2609
|
+
return /* @__PURE__ */ jsx26(GdsFormContext.Provider, { value: { snapshot }, children });
|
|
2289
2610
|
}
|
|
2290
2611
|
function useGdsFormSnapshot() {
|
|
2291
2612
|
const context = useContext3(GdsFormContext);
|
|
@@ -2295,14 +2616,14 @@ function useGdsFormSnapshot() {
|
|
|
2295
2616
|
return context.snapshot;
|
|
2296
2617
|
}
|
|
2297
2618
|
function FormErrorSummary({ title: titleProp }) {
|
|
2298
|
-
const { t } =
|
|
2619
|
+
const { t } = useGdsTranslation19();
|
|
2299
2620
|
const title = titleProp ?? t("gds.gdsForm.title", "Please review the following issues.");
|
|
2300
2621
|
const snapshot = useGdsFormSnapshot();
|
|
2301
2622
|
const blocking = snapshot.issues.filter((issue) => issue.severity === "blocking");
|
|
2302
2623
|
if (blocking.length === 0) {
|
|
2303
2624
|
return null;
|
|
2304
2625
|
}
|
|
2305
|
-
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}`)) }) });
|
|
2306
2627
|
}
|
|
2307
2628
|
var GdsValidationSummary = FormErrorSummary;
|
|
2308
2629
|
function ValidatedFieldMessage({ field }) {
|
|
@@ -2311,14 +2632,14 @@ function ValidatedFieldMessage({ field }) {
|
|
|
2311
2632
|
if (!issue) {
|
|
2312
2633
|
return null;
|
|
2313
2634
|
}
|
|
2314
|
-
return /* @__PURE__ */
|
|
2635
|
+
return /* @__PURE__ */ jsx26(Text15, { size: "xs", c: "red.7", id: `${field}-error`, children: issue.message });
|
|
2315
2636
|
}
|
|
2316
2637
|
|
|
2317
2638
|
// src/GdsSchemaForm.client.tsx
|
|
2318
|
-
import { useCallback as
|
|
2639
|
+
import { useCallback as useCallback6, useEffect as useEffect5, useMemo as useMemo5, useRef as useRef6, useState as useState12 } from "react";
|
|
2319
2640
|
import { Button as Button9, Checkbox, Group as Group14, Paper as Paper6, Stack as Stack11, Text as Text16, Title as Title2 } from "@mantine/core";
|
|
2320
|
-
import { useGdsTranslation as
|
|
2321
|
-
import { jsx as
|
|
2641
|
+
import { useGdsTranslation as useGdsTranslation20 } from "@sovereignsquad/gds-theme";
|
|
2642
|
+
import { jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2322
2643
|
function toIsoDateString(date) {
|
|
2323
2644
|
const year = date.getFullYear();
|
|
2324
2645
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
@@ -2572,23 +2893,23 @@ function FileUploadField({
|
|
|
2572
2893
|
onUploadEvent,
|
|
2573
2894
|
onChange
|
|
2574
2895
|
}) {
|
|
2575
|
-
const abortRef =
|
|
2576
|
-
const lastFilesRef =
|
|
2577
|
-
const [adapterState, setAdapterState] =
|
|
2578
|
-
const [adapterProgress, setAdapterProgress] =
|
|
2579
|
-
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();
|
|
2580
2901
|
const selectedFiles = getUploadFileNames(value);
|
|
2581
2902
|
const oversize = Array.isArray(value) && maxFileSizeBytes ? value.some((file) => isFileValue(file) && file.size > maxFileSizeBytes) : false;
|
|
2582
2903
|
const effectiveState = adapterState ?? state ?? (oversize ? "too-large" : selectedFiles.length > 0 ? "selected" : "idle");
|
|
2583
2904
|
const effectivePolicyText = oversize ? `One or more files exceed ${maxFileSizeLabel ?? `${maxFileSizeBytes} bytes`}.` : policyText;
|
|
2584
2905
|
const effectiveProgressValue = adapterProgress ?? progressValue;
|
|
2585
|
-
const emitUploadEvent =
|
|
2906
|
+
const emitUploadEvent = useCallback6((type, message) => {
|
|
2586
2907
|
onUploadEvent?.(createSchemaEvent(type, message, field?.name ?? id));
|
|
2587
2908
|
}, [field?.name, id, onUploadEvent]);
|
|
2588
|
-
|
|
2909
|
+
useEffect5(() => () => {
|
|
2589
2910
|
abortRef.current?.abort();
|
|
2590
2911
|
}, []);
|
|
2591
|
-
const uploadFiles =
|
|
2912
|
+
const uploadFiles = useCallback6((files) => {
|
|
2592
2913
|
const selectedOversize = Boolean(maxFileSizeBytes && files.some((file) => file.size > maxFileSizeBytes));
|
|
2593
2914
|
if (!uploadAdapter || !field || selectedOversize) {
|
|
2594
2915
|
onChange?.(files);
|
|
@@ -2680,7 +3001,7 @@ function FileUploadField({
|
|
|
2680
3001
|
emitUploadEvent("upload_failed", error instanceof Error ? error.message : void 0);
|
|
2681
3002
|
});
|
|
2682
3003
|
};
|
|
2683
|
-
return /* @__PURE__ */
|
|
3004
|
+
return /* @__PURE__ */ jsx27(Stack11, { gap: 4, children: /* @__PURE__ */ jsx27(
|
|
2684
3005
|
UploadDropzone,
|
|
2685
3006
|
{
|
|
2686
3007
|
title: label,
|
|
@@ -2699,8 +3020,8 @@ function FileUploadField({
|
|
|
2699
3020
|
progressValue: effectiveProgressValue,
|
|
2700
3021
|
error: adapterError,
|
|
2701
3022
|
mode: "inline",
|
|
2702
|
-
retryAction: effectiveState === "upload-failed" && uploadAdapter ? /* @__PURE__ */
|
|
2703
|
-
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,
|
|
2704
3025
|
onFilesSelected: handleFilesSelected
|
|
2705
3026
|
}
|
|
2706
3027
|
) });
|
|
@@ -2721,7 +3042,7 @@ function CheckboxGroupField({ field, value, setValue, describedBy, invalid }) {
|
|
|
2721
3042
|
const toggle = (optionValue, checked) => {
|
|
2722
3043
|
setValue(checked ? [...selected, optionValue] : selected.filter((entry) => entry !== optionValue));
|
|
2723
3044
|
};
|
|
2724
|
-
return /* @__PURE__ */
|
|
3045
|
+
return /* @__PURE__ */ jsxs18(
|
|
2725
3046
|
"fieldset",
|
|
2726
3047
|
{
|
|
2727
3048
|
"data-gds-checkbox-group": field.name,
|
|
@@ -2729,11 +3050,11 @@ function CheckboxGroupField({ field, value, setValue, describedBy, invalid }) {
|
|
|
2729
3050
|
"aria-invalid": invalid || void 0,
|
|
2730
3051
|
style: { border: 0, margin: 0, padding: 0, minInlineSize: "auto" },
|
|
2731
3052
|
children: [
|
|
2732
|
-
/* @__PURE__ */
|
|
2733
|
-
/* @__PURE__ */
|
|
3053
|
+
/* @__PURE__ */ jsx27("legend", { style: visuallyHidden, children: field.label }),
|
|
3054
|
+
/* @__PURE__ */ jsx27(Stack11, { gap: 6, children: (field.options ?? []).map((option) => (
|
|
2734
3055
|
// Mantine Checkbox (not a raw native input) so the control inherits the GDS
|
|
2735
3056
|
// theme styling and the governed forced-colors remap like every other control.
|
|
2736
|
-
/* @__PURE__ */
|
|
3057
|
+
/* @__PURE__ */ jsx27(
|
|
2737
3058
|
Checkbox,
|
|
2738
3059
|
{
|
|
2739
3060
|
value: option.value,
|
|
@@ -2750,7 +3071,7 @@ function CheckboxGroupField({ field, value, setValue, describedBy, invalid }) {
|
|
|
2750
3071
|
);
|
|
2751
3072
|
}
|
|
2752
3073
|
function RepeatableField({ field, value, setValue, describedBy, invalid, renderers, uploadAdapter, onEvent }) {
|
|
2753
|
-
const { t } =
|
|
3074
|
+
const { t } = useGdsTranslation20();
|
|
2754
3075
|
const rows = Array.isArray(value) ? value : [];
|
|
2755
3076
|
const subFields = field.fields ?? [];
|
|
2756
3077
|
const minRows = field.minRows ?? 0;
|
|
@@ -2759,11 +3080,11 @@ function RepeatableField({ field, value, setValue, describedBy, invalid, rendere
|
|
|
2759
3080
|
const addLabel = field.addRowLabel ?? t("gds.schemaForm.addRow", "Add row");
|
|
2760
3081
|
const removeLabel = field.removeRowLabel ?? t("gds.schemaForm.removeRow", "Remove");
|
|
2761
3082
|
const rowNoun = (count) => count === 1 ? t("gds.schemaForm.rowOne", "row") : t("gds.schemaForm.rowMany", "rows");
|
|
2762
|
-
const containerRef =
|
|
2763
|
-
const addButtonRef =
|
|
2764
|
-
const pendingFocus =
|
|
2765
|
-
const [announcement, setAnnouncement] =
|
|
2766
|
-
|
|
3083
|
+
const containerRef = useRef6(null);
|
|
3084
|
+
const addButtonRef = useRef6(null);
|
|
3085
|
+
const pendingFocus = useRef6(null);
|
|
3086
|
+
const [announcement, setAnnouncement] = useState12("");
|
|
3087
|
+
useEffect5(() => {
|
|
2767
3088
|
if (pendingFocus.current === "add") {
|
|
2768
3089
|
const lastRow = containerRef.current?.querySelector(`[data-gds-repeatable-row="${rows.length - 1}"]`);
|
|
2769
3090
|
lastRow?.querySelector("input, select, textarea, button")?.focus();
|
|
@@ -2787,11 +3108,11 @@ function RepeatableField({ field, value, setValue, describedBy, invalid, rendere
|
|
|
2787
3108
|
const setRowFieldValue = (index, name, next) => {
|
|
2788
3109
|
setValue(rows.map((row, rowIndex) => rowIndex === index ? { ...row, [name]: next } : row));
|
|
2789
3110
|
};
|
|
2790
|
-
return /* @__PURE__ */
|
|
2791
|
-
rows.map((row, index) => /* @__PURE__ */
|
|
2792
|
-
/* @__PURE__ */
|
|
2793
|
-
/* @__PURE__ */
|
|
2794
|
-
/* @__PURE__ */
|
|
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(
|
|
2795
3116
|
Button9,
|
|
2796
3117
|
{
|
|
2797
3118
|
type: "button",
|
|
@@ -2814,11 +3135,11 @@ function RepeatableField({ field, value, setValue, describedBy, invalid, rendere
|
|
|
2814
3135
|
invalid: false
|
|
2815
3136
|
};
|
|
2816
3137
|
const subRenderer = renderers[sub.name] ?? renderers[sub.type];
|
|
2817
|
-
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);
|
|
2818
3139
|
})
|
|
2819
3140
|
] }) }, index)),
|
|
2820
|
-
/* @__PURE__ */
|
|
2821
|
-
/* @__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 })
|
|
2822
3143
|
] });
|
|
2823
3144
|
}
|
|
2824
3145
|
function renderDefaultField({ field, value, setValue, describedBy, invalid }, options = {}) {
|
|
@@ -2830,7 +3151,7 @@ function renderDefaultField({ field, value, setValue, describedBy, invalid }, op
|
|
|
2830
3151
|
required: field.required
|
|
2831
3152
|
};
|
|
2832
3153
|
if (field.type === "file-upload") {
|
|
2833
|
-
return /* @__PURE__ */
|
|
3154
|
+
return /* @__PURE__ */ jsx27(
|
|
2834
3155
|
FileUploadField,
|
|
2835
3156
|
{
|
|
2836
3157
|
...common,
|
|
@@ -2852,10 +3173,10 @@ function renderDefaultField({ field, value, setValue, describedBy, invalid }, op
|
|
|
2852
3173
|
);
|
|
2853
3174
|
}
|
|
2854
3175
|
if (field.type === "checkbox-group") {
|
|
2855
|
-
return /* @__PURE__ */
|
|
3176
|
+
return /* @__PURE__ */ jsx27(CheckboxGroupField, { field, value, setValue, describedBy, invalid });
|
|
2856
3177
|
}
|
|
2857
3178
|
if (field.type === "repeatable") {
|
|
2858
|
-
return /* @__PURE__ */
|
|
3179
|
+
return /* @__PURE__ */ jsx27(
|
|
2859
3180
|
RepeatableField,
|
|
2860
3181
|
{
|
|
2861
3182
|
field,
|
|
@@ -2870,17 +3191,17 @@ function renderDefaultField({ field, value, setValue, describedBy, invalid }, op
|
|
|
2870
3191
|
);
|
|
2871
3192
|
}
|
|
2872
3193
|
const textEntryStyle = { fontSize: "max(1rem, 1em)" };
|
|
2873
|
-
if (field.type === "boolean") return /* @__PURE__ */
|
|
2874
|
-
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)) });
|
|
2875
3196
|
if (field.type === "select") {
|
|
2876
|
-
return /* @__PURE__ */
|
|
2877
|
-
/* @__PURE__ */
|
|
2878
|
-
(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))
|
|
2879
3200
|
] });
|
|
2880
3201
|
}
|
|
2881
|
-
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) });
|
|
2882
3203
|
if (field.type === "date") {
|
|
2883
|
-
return /* @__PURE__ */
|
|
3204
|
+
return /* @__PURE__ */ jsx27(
|
|
2884
3205
|
GdsDateInput,
|
|
2885
3206
|
{
|
|
2886
3207
|
...common,
|
|
@@ -2889,7 +3210,7 @@ function renderDefaultField({ field, value, setValue, describedBy, invalid }, op
|
|
|
2889
3210
|
}
|
|
2890
3211
|
);
|
|
2891
3212
|
}
|
|
2892
|
-
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) });
|
|
2893
3214
|
}
|
|
2894
3215
|
function GdsSchemaForm({
|
|
2895
3216
|
schema,
|
|
@@ -2899,7 +3220,7 @@ function GdsSchemaForm({
|
|
|
2899
3220
|
onEvent,
|
|
2900
3221
|
submitLabel: submitLabelProp
|
|
2901
3222
|
}) {
|
|
2902
|
-
const { t } =
|
|
3223
|
+
const { t } = useGdsTranslation20();
|
|
2903
3224
|
const submitLabel = submitLabelProp ?? t("gds.gdsSchemaForm.submitLabel", "Submit");
|
|
2904
3225
|
const initialValues = useMemo5(() => getInitialValues(schema), [schema]);
|
|
2905
3226
|
const form = useGdsFormOrchestration({
|
|
@@ -2915,15 +3236,15 @@ function GdsSchemaForm({
|
|
|
2915
3236
|
},
|
|
2916
3237
|
onEvent
|
|
2917
3238
|
});
|
|
2918
|
-
return /* @__PURE__ */
|
|
2919
|
-
schema.title ? /* @__PURE__ */
|
|
2920
|
-
schema.description ? /* @__PURE__ */
|
|
2921
|
-
/* @__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, {}),
|
|
2922
3243
|
schema.fields.map((field) => {
|
|
2923
3244
|
if (field.hidden || field.type === "hidden") return null;
|
|
2924
3245
|
const issue = form.snapshot.issues.find((item) => item.field === field.name && item.severity === "blocking");
|
|
2925
3246
|
if (field.type === "unsupported" && !renderers[field.name] && !renderers[field.type]) {
|
|
2926
|
-
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);
|
|
2927
3248
|
}
|
|
2928
3249
|
const context = {
|
|
2929
3250
|
field,
|
|
@@ -2933,29 +3254,29 @@ function GdsSchemaForm({
|
|
|
2933
3254
|
invalid: Boolean(issue)
|
|
2934
3255
|
};
|
|
2935
3256
|
const renderer = renderers[field.name] ?? renderers[field.type];
|
|
2936
|
-
return /* @__PURE__ */
|
|
3257
|
+
return /* @__PURE__ */ jsxs18(
|
|
2937
3258
|
FormField,
|
|
2938
3259
|
{
|
|
2939
3260
|
label: `${field.label}${field.required ? ` ${t("gds.schemaForm.requiredMarker", "(required)")}` : ""}`,
|
|
2940
|
-
description: field.description ? /* @__PURE__ */
|
|
3261
|
+
description: field.description ? /* @__PURE__ */ jsx27(Text16, { id: `${field.name}-description`, size: "xs", c: "dimmed", children: field.description }) : void 0,
|
|
2941
3262
|
children: [
|
|
2942
3263
|
renderer ? renderer(context) : renderDefaultField(context, { uploadAdapter, onEvent, renderers }),
|
|
2943
|
-
/* @__PURE__ */
|
|
3264
|
+
/* @__PURE__ */ jsx27("span", { id: `${field.name}-error`, children: /* @__PURE__ */ jsx27(ValidatedFieldMessage, { field: field.name }) })
|
|
2944
3265
|
]
|
|
2945
3266
|
},
|
|
2946
3267
|
field.name
|
|
2947
3268
|
);
|
|
2948
3269
|
}),
|
|
2949
|
-
/* @__PURE__ */
|
|
3270
|
+
/* @__PURE__ */ jsx27(Button9, { type: "button", onClick: () => {
|
|
2950
3271
|
void form.submit();
|
|
2951
3272
|
}, loading: form.snapshot.submitState === "validating" || form.snapshot.submitState === "submitting" || form.snapshot.submitState === "optimistic", children: submitLabel })
|
|
2952
3273
|
] }) });
|
|
2953
3274
|
}
|
|
2954
3275
|
|
|
2955
3276
|
// src/AdvancedDataTable.client.tsx
|
|
2956
|
-
import { useMemo as useMemo6, useState as
|
|
2957
|
-
import { Checkbox as Checkbox2, Group as Group15, ScrollArea as ScrollArea2, SegmentedControl as SegmentedControl2, Stack as Stack12, Table, Text as Text17 } from "@mantine/core";
|
|
2958
|
-
import { jsx as
|
|
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";
|
|
2959
3280
|
function compareValues(a, b) {
|
|
2960
3281
|
if (typeof a === "number" && typeof b === "number") {
|
|
2961
3282
|
return a - b;
|
|
@@ -2978,9 +3299,9 @@ function AdvancedDataTable({
|
|
|
2978
3299
|
onSortChange,
|
|
2979
3300
|
responsiveFallback = "stacked-cards"
|
|
2980
3301
|
}) {
|
|
2981
|
-
const [densityState, setDensityState] =
|
|
2982
|
-
const [sortState, setSortState] =
|
|
2983
|
-
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([]);
|
|
2984
3305
|
const density = densityProp ?? densityState;
|
|
2985
3306
|
const sortBy = sortByProp ?? sortState.key;
|
|
2986
3307
|
const sortDirection = sortDirectionProp ?? sortState.direction;
|
|
@@ -3004,13 +3325,13 @@ function AdvancedDataTable({
|
|
|
3004
3325
|
const allIds = useMemo6(() => sortedRows.map((row, index) => rowId(row, index)), [sortedRows, rowId]);
|
|
3005
3326
|
const allSelected = allIds.length > 0 && allIds.every((id) => selection.includes(id));
|
|
3006
3327
|
if (error) {
|
|
3007
|
-
return /* @__PURE__ */
|
|
3328
|
+
return /* @__PURE__ */ jsx28(StateBlock, { variant: "error", title: "Unable to load table", description: error, compact: true });
|
|
3008
3329
|
}
|
|
3009
3330
|
if (loading) {
|
|
3010
|
-
return /* @__PURE__ */
|
|
3331
|
+
return /* @__PURE__ */ jsx28(StateBlock, { variant: "loading", title: "Loading table", description: "Preparing enterprise data grid.", compact: true });
|
|
3011
3332
|
}
|
|
3012
3333
|
if (!rows.length) {
|
|
3013
|
-
return /* @__PURE__ */
|
|
3334
|
+
return /* @__PURE__ */ jsx28(
|
|
3014
3335
|
StateBlock,
|
|
3015
3336
|
{
|
|
3016
3337
|
variant: "empty",
|
|
@@ -3020,15 +3341,15 @@ function AdvancedDataTable({
|
|
|
3020
3341
|
}
|
|
3021
3342
|
);
|
|
3022
3343
|
}
|
|
3023
|
-
const horizontalSpacing = density === "compact" ? "xs" : "
|
|
3344
|
+
const horizontalSpacing = density === "compact" ? "xs" : "sm";
|
|
3024
3345
|
const verticalSpacing = density === "compact" ? 6 : 10;
|
|
3025
|
-
return /* @__PURE__ */
|
|
3026
|
-
/* @__PURE__ */
|
|
3027
|
-
/* @__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: [
|
|
3028
3349
|
rows.length,
|
|
3029
3350
|
" rows"
|
|
3030
3351
|
] }),
|
|
3031
|
-
/* @__PURE__ */
|
|
3352
|
+
/* @__PURE__ */ jsx28(
|
|
3032
3353
|
SegmentedControl2,
|
|
3033
3354
|
{
|
|
3034
3355
|
size: "xs",
|
|
@@ -3041,8 +3362,8 @@ function AdvancedDataTable({
|
|
|
3041
3362
|
}
|
|
3042
3363
|
)
|
|
3043
3364
|
] }),
|
|
3044
|
-
/* @__PURE__ */
|
|
3045
|
-
|
|
3365
|
+
/* @__PURE__ */ jsx28(ScrollArea2, { children: /* @__PURE__ */ jsxs19(
|
|
3366
|
+
Table3,
|
|
3046
3367
|
{
|
|
3047
3368
|
stickyHeader,
|
|
3048
3369
|
stickyHeaderOffset,
|
|
@@ -3052,8 +3373,8 @@ function AdvancedDataTable({
|
|
|
3052
3373
|
horizontalSpacing,
|
|
3053
3374
|
verticalSpacing,
|
|
3054
3375
|
children: [
|
|
3055
|
-
/* @__PURE__ */
|
|
3056
|
-
/* @__PURE__ */
|
|
3376
|
+
/* @__PURE__ */ jsx28(Table3.Thead, { children: /* @__PURE__ */ jsxs19(Table3.Tr, { children: [
|
|
3377
|
+
/* @__PURE__ */ jsx28(Table3.Th, { children: /* @__PURE__ */ jsx28(
|
|
3057
3378
|
Checkbox2,
|
|
3058
3379
|
{
|
|
3059
3380
|
className: "gds-touch-target-pad-checkbox",
|
|
@@ -3071,7 +3392,7 @@ function AdvancedDataTable({
|
|
|
3071
3392
|
}
|
|
3072
3393
|
}
|
|
3073
3394
|
) }),
|
|
3074
|
-
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(
|
|
3075
3396
|
"button",
|
|
3076
3397
|
{
|
|
3077
3398
|
type: "button",
|
|
@@ -3088,11 +3409,11 @@ function AdvancedDataTable({
|
|
|
3088
3409
|
}
|
|
3089
3410
|
) : column.label }, column.key))
|
|
3090
3411
|
] }) }),
|
|
3091
|
-
/* @__PURE__ */
|
|
3412
|
+
/* @__PURE__ */ jsx28(Table3.Tbody, { children: sortedRows.map((row, index) => {
|
|
3092
3413
|
const id = rowId(row, index);
|
|
3093
3414
|
const checked = selection.includes(id);
|
|
3094
|
-
return /* @__PURE__ */
|
|
3095
|
-
/* @__PURE__ */
|
|
3415
|
+
return /* @__PURE__ */ jsxs19(Table3.Tr, { children: [
|
|
3416
|
+
/* @__PURE__ */ jsx28(Table3.Td, { children: /* @__PURE__ */ jsx28(
|
|
3096
3417
|
Checkbox2,
|
|
3097
3418
|
{
|
|
3098
3419
|
"aria-label": `Select row ${id}`,
|
|
@@ -3107,15 +3428,15 @@ function AdvancedDataTable({
|
|
|
3107
3428
|
}
|
|
3108
3429
|
}
|
|
3109
3430
|
) }),
|
|
3110
|
-
columns.map((column) => /* @__PURE__ */
|
|
3431
|
+
columns.map((column) => /* @__PURE__ */ jsx28(Table3.Td, { children: column.render ? column.render(row) : String(row[column.key] ?? "") }, column.key))
|
|
3111
3432
|
] }, id);
|
|
3112
3433
|
}) })
|
|
3113
3434
|
]
|
|
3114
3435
|
}
|
|
3115
3436
|
) }),
|
|
3116
|
-
responsiveFallback === "stacked-cards" ? /* @__PURE__ */
|
|
3437
|
+
responsiveFallback === "stacked-cards" ? /* @__PURE__ */ jsx28(Stack12, { gap: "xs", children: sortedRows.slice(0, 3).map((row, index) => {
|
|
3117
3438
|
const id = rowId(row, index);
|
|
3118
|
-
return /* @__PURE__ */
|
|
3439
|
+
return /* @__PURE__ */ jsx28(
|
|
3119
3440
|
StateBlock,
|
|
3120
3441
|
{
|
|
3121
3442
|
variant: "info",
|
|
@@ -3130,10 +3451,10 @@ function AdvancedDataTable({
|
|
|
3130
3451
|
}
|
|
3131
3452
|
|
|
3132
3453
|
// src/GdsDataTable.client.tsx
|
|
3133
|
-
import { useGdsTranslation as
|
|
3134
|
-
import { useCallback as
|
|
3135
|
-
import { Button as Button10, Checkbox as Checkbox3, Group as Group16, Pagination, ScrollArea as ScrollArea3, Stack as Stack13, Table as
|
|
3136
|
-
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";
|
|
3137
3458
|
function emitTableEvent(onEvent, type, message) {
|
|
3138
3459
|
onEvent?.({ type, message, timestamp: Date.now(), privacy: "metadata-only" });
|
|
3139
3460
|
}
|
|
@@ -3196,14 +3517,14 @@ function useGdsDataTable({
|
|
|
3196
3517
|
timeoutMs = 8e3,
|
|
3197
3518
|
virtualizedRowLimit
|
|
3198
3519
|
}) {
|
|
3199
|
-
const [query, setQuery] =
|
|
3200
|
-
const [rows, setRows] =
|
|
3201
|
-
const [total, setTotal] =
|
|
3202
|
-
const [status, setStatus] =
|
|
3203
|
-
const [error, setError] =
|
|
3204
|
-
const [selectedRowIds, setSelectedRowIds] =
|
|
3205
|
-
const [reloadKey, setReloadKey] =
|
|
3206
|
-
|
|
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(() => {
|
|
3207
3528
|
const controller = new AbortController();
|
|
3208
3529
|
const timer = window.setTimeout(() => controller.abort(), timeoutMs);
|
|
3209
3530
|
setStatus((current) => current === "ready" || current === "partial" ? "refreshing" : "loading");
|
|
@@ -3229,12 +3550,12 @@ function useGdsDataTable({
|
|
|
3229
3550
|
window.clearTimeout(timer);
|
|
3230
3551
|
};
|
|
3231
3552
|
}, [adapter, onEvent, query, reloadKey, rowId, timeoutMs]);
|
|
3232
|
-
const setSearch =
|
|
3553
|
+
const setSearch = useCallback7((value) => {
|
|
3233
3554
|
setQuery((current) => ({ ...current, search: value, page: 1 }));
|
|
3234
3555
|
setSelectedRowIds([]);
|
|
3235
3556
|
emitTableEvent(onEvent, "filter_changed");
|
|
3236
3557
|
}, [onEvent]);
|
|
3237
|
-
const setSort =
|
|
3558
|
+
const setSort = useCallback7((columnKey) => {
|
|
3238
3559
|
setQuery((current) => ({
|
|
3239
3560
|
...current,
|
|
3240
3561
|
sortBy: columnKey,
|
|
@@ -3244,23 +3565,23 @@ function useGdsDataTable({
|
|
|
3244
3565
|
setSelectedRowIds([]);
|
|
3245
3566
|
emitTableEvent(onEvent, "sort_changed");
|
|
3246
3567
|
}, [onEvent]);
|
|
3247
|
-
const setPage =
|
|
3248
|
-
const setPageSize =
|
|
3249
|
-
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) => {
|
|
3250
3571
|
setQuery((current) => ({ ...current, filters: { ...current.filters, [columnKey]: value }, page: 1 }));
|
|
3251
3572
|
setSelectedRowIds([]);
|
|
3252
3573
|
emitTableEvent(onEvent, "filter_changed");
|
|
3253
3574
|
}, [onEvent]);
|
|
3254
3575
|
const visibleRows = useMemo7(() => rows.slice(0, virtualizedRowLimit ?? rows.length), [rows, virtualizedRowLimit]);
|
|
3255
3576
|
const visibleIds = useMemo7(() => visibleRows.map((row, index) => rowId(row, index)), [rowId, visibleRows]);
|
|
3256
|
-
const toggleRow =
|
|
3577
|
+
const toggleRow = useCallback7((id) => {
|
|
3257
3578
|
setSelectedRowIds((current) => {
|
|
3258
3579
|
const next = current.includes(id) ? current.filter((item) => item !== id) : [...current, id];
|
|
3259
3580
|
emitTableEvent(onEvent, "selection_changed");
|
|
3260
3581
|
return next;
|
|
3261
3582
|
});
|
|
3262
3583
|
}, [onEvent]);
|
|
3263
|
-
const toggleAllVisible =
|
|
3584
|
+
const toggleAllVisible = useCallback7(() => {
|
|
3264
3585
|
setSelectedRowIds((current) => {
|
|
3265
3586
|
const allSelected = visibleIds.length > 0 && visibleIds.every((id) => current.includes(id));
|
|
3266
3587
|
const next = allSelected ? current.filter((id) => !visibleIds.includes(id)) : [.../* @__PURE__ */ new Set([...current, ...visibleIds])];
|
|
@@ -3268,7 +3589,7 @@ function useGdsDataTable({
|
|
|
3268
3589
|
return next;
|
|
3269
3590
|
});
|
|
3270
3591
|
}, [onEvent, visibleIds]);
|
|
3271
|
-
const exportRows =
|
|
3592
|
+
const exportRows = useCallback7(async () => {
|
|
3272
3593
|
setStatus("exporting");
|
|
3273
3594
|
emitTableEvent(onEvent, "export_requested");
|
|
3274
3595
|
await onExport?.({ query, rows, selectedRowIds });
|
|
@@ -3307,9 +3628,9 @@ function getInteractiveCellElements(cell) {
|
|
|
3307
3628
|
return Array.from(cell.querySelectorAll(interactiveCellSelector)).filter((element) => !element.hasAttribute("hidden") && element.getAttribute("aria-hidden") !== "true");
|
|
3308
3629
|
}
|
|
3309
3630
|
function useGdsTableKeyNav(rowCount, columnCount) {
|
|
3310
|
-
const tbodyRef =
|
|
3311
|
-
const [focusedCell, setFocusedCell] =
|
|
3312
|
-
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) => {
|
|
3313
3634
|
const rows = tbodyRef.current?.querySelectorAll("tr[data-gds-row]") ?? [];
|
|
3314
3635
|
const nextRowIndex = Math.max(0, Math.min(rowIndex, rows.length - 1));
|
|
3315
3636
|
const cells = rows[nextRowIndex]?.querySelectorAll("[data-gds-cell]") ?? [];
|
|
@@ -3318,7 +3639,7 @@ function useGdsTableKeyNav(rowCount, columnCount) {
|
|
|
3318
3639
|
setFocusedCell({ rowIndex: nextRowIndex, columnIndex: nextColumnIndex });
|
|
3319
3640
|
cells[nextColumnIndex]?.focus();
|
|
3320
3641
|
}, []);
|
|
3321
|
-
const handleKeyDown =
|
|
3642
|
+
const handleKeyDown = useCallback7((event) => {
|
|
3322
3643
|
const rows = tbodyRef.current?.querySelectorAll("tr[data-gds-row]") ?? [];
|
|
3323
3644
|
if (rows.length === 0 || columnCount === 0) return;
|
|
3324
3645
|
const target = event.target instanceof HTMLElement ? event.target : null;
|
|
@@ -3362,7 +3683,7 @@ function useGdsTableKeyNav(rowCount, columnCount) {
|
|
|
3362
3683
|
focusCell(event.ctrlKey || event.metaKey ? lastRow : current.rowIndex, lastColumn);
|
|
3363
3684
|
}
|
|
3364
3685
|
}, [columnCount, focusCell, focusedCell]);
|
|
3365
|
-
|
|
3686
|
+
useEffect6(() => {
|
|
3366
3687
|
setFocusedCell(rowCount > 0 && columnCount > 0 ? { rowIndex: 0, columnIndex: 0 } : null);
|
|
3367
3688
|
}, [columnCount, rowCount]);
|
|
3368
3689
|
return { tbodyRef, handleKeyDown, focusedCell, setFocusedCell };
|
|
@@ -3382,7 +3703,7 @@ function GdsDataTable({
|
|
|
3382
3703
|
retryLabel: retryLabelProp,
|
|
3383
3704
|
mobileCards = true
|
|
3384
3705
|
}) {
|
|
3385
|
-
const { t } =
|
|
3706
|
+
const { t } = useGdsTranslation21();
|
|
3386
3707
|
const caption = captionProp ?? t("gds.gdsDataTable.caption", "Data table");
|
|
3387
3708
|
const exportLabel = exportLabelProp ?? t("gds.gdsDataTable.exportLabel", "Export");
|
|
3388
3709
|
const retryLabel = retryLabelProp ?? t("gds.gdsDataTable.retryLabel", "Retry");
|
|
@@ -3392,50 +3713,50 @@ function GdsDataTable({
|
|
|
3392
3713
|
const gridColumnCount = visibleColumns.length + 1;
|
|
3393
3714
|
const { tbodyRef, handleKeyDown, focusedCell, setFocusedCell } = useGdsTableKeyNav(table.visibleRows.length, gridColumnCount);
|
|
3394
3715
|
const focusedColumnLabel = focusedCell ? focusedCell.columnIndex === 0 ? "Selection" : visibleColumns[focusedCell.columnIndex - 1]?.label : void 0;
|
|
3395
|
-
if (table.status === "loading") return /* @__PURE__ */
|
|
3396
|
-
if (table.status === "error") return /* @__PURE__ */
|
|
3397
|
-
if (table.status === "empty") return /* @__PURE__ */
|
|
3398
|
-
if (table.status === "filtered-empty") return /* @__PURE__ */
|
|
3399
|
-
return /* @__PURE__ */
|
|
3400
|
-
/* @__PURE__ */
|
|
3401
|
-
/* @__PURE__ */
|
|
3402
|
-
/* @__PURE__ */
|
|
3403
|
-
summary ? /* @__PURE__ */
|
|
3404
|
-
/* @__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: [
|
|
3405
3726
|
table.total,
|
|
3406
3727
|
" rows",
|
|
3407
3728
|
table.status === "partial" ? " (partial data)" : ""
|
|
3408
3729
|
] })
|
|
3409
3730
|
] }),
|
|
3410
|
-
/* @__PURE__ */
|
|
3411
|
-
/* @__PURE__ */
|
|
3412
|
-
/* @__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: () => {
|
|
3413
3734
|
void table.exportRows();
|
|
3414
3735
|
}, loading: table.status === "exporting", children: exportLabel })
|
|
3415
3736
|
] })
|
|
3416
3737
|
] }),
|
|
3417
|
-
/* @__PURE__ */
|
|
3418
|
-
/* @__PURE__ */
|
|
3419
|
-
/* @__PURE__ */
|
|
3420
|
-
/* @__PURE__ */
|
|
3421
|
-
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))
|
|
3422
3743
|
] }) }),
|
|
3423
|
-
/* @__PURE__ */
|
|
3424
|
-
|
|
3744
|
+
/* @__PURE__ */ jsx29(
|
|
3745
|
+
Table4.Tbody,
|
|
3425
3746
|
{
|
|
3426
3747
|
ref: tbodyRef,
|
|
3427
3748
|
onKeyDown: handleKeyDown,
|
|
3428
3749
|
children: table.visibleRows.map((row, rowIndex) => {
|
|
3429
3750
|
const id = rowId(row, rowIndex);
|
|
3430
|
-
return /* @__PURE__ */
|
|
3431
|
-
|
|
3751
|
+
return /* @__PURE__ */ jsxs20(
|
|
3752
|
+
Table4.Tr,
|
|
3432
3753
|
{
|
|
3433
3754
|
"data-gds-row": true,
|
|
3434
3755
|
"aria-selected": table.selectedRowIds.includes(id),
|
|
3435
3756
|
"aria-rowindex": (table.query.page - 1) * table.query.pageSize + rowIndex + 2,
|
|
3436
3757
|
children: [
|
|
3437
|
-
/* @__PURE__ */
|
|
3438
|
-
|
|
3758
|
+
/* @__PURE__ */ jsx29(
|
|
3759
|
+
Table4.Td,
|
|
3439
3760
|
{
|
|
3440
3761
|
role: "gridcell",
|
|
3441
3762
|
"data-gds-cell": true,
|
|
@@ -3445,14 +3766,14 @@ function GdsDataTable({
|
|
|
3445
3766
|
"aria-colindex": 1,
|
|
3446
3767
|
onFocus: () => setFocusedCell({ rowIndex, columnIndex: 0 }),
|
|
3447
3768
|
style: focusedCell?.rowIndex === rowIndex && focusedCell.columnIndex === 0 ? { outline: "2px solid var(--mantine-color-blue-5)", outlineOffset: "-2px" } : void 0,
|
|
3448
|
-
children: /* @__PURE__ */
|
|
3769
|
+
children: /* @__PURE__ */ jsx29(Checkbox3, { "aria-label": `Select row ${id}`, checked: table.selectedRowIds.includes(id), onChange: () => table.toggleRow(id), tabIndex: -1 })
|
|
3449
3770
|
}
|
|
3450
3771
|
),
|
|
3451
3772
|
visibleColumns.map((column, columnIndex) => {
|
|
3452
3773
|
const gridColumnIndex = columnIndex + 1;
|
|
3453
3774
|
const isCellFocused = focusedCell?.rowIndex === rowIndex && focusedCell.columnIndex === gridColumnIndex;
|
|
3454
|
-
return /* @__PURE__ */
|
|
3455
|
-
|
|
3775
|
+
return /* @__PURE__ */ jsx29(
|
|
3776
|
+
Table4.Td,
|
|
3456
3777
|
{
|
|
3457
3778
|
role: "gridcell",
|
|
3458
3779
|
"data-gds-cell": true,
|
|
@@ -3477,24 +3798,24 @@ function GdsDataTable({
|
|
|
3477
3798
|
}
|
|
3478
3799
|
)
|
|
3479
3800
|
] }) }),
|
|
3480
|
-
/* @__PURE__ */
|
|
3481
|
-
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: [
|
|
3482
3803
|
table.visibleRows.length,
|
|
3483
3804
|
" of ",
|
|
3484
3805
|
table.rows.length,
|
|
3485
3806
|
" rows rendered in the virtualized window."
|
|
3486
3807
|
] }) : null,
|
|
3487
|
-
/* @__PURE__ */
|
|
3488
|
-
/* @__PURE__ */
|
|
3808
|
+
/* @__PURE__ */ jsxs20(Group16, { justify: "space-between", children: [
|
|
3809
|
+
/* @__PURE__ */ jsxs20(Text18, { size: "xs", c: "dimmed", children: [
|
|
3489
3810
|
table.selectedRowIds.length,
|
|
3490
3811
|
" selected"
|
|
3491
3812
|
] }),
|
|
3492
|
-
/* @__PURE__ */
|
|
3813
|
+
/* @__PURE__ */ jsx29(Pagination, { total: pageCount, value: table.query.page, onChange: table.setPage, size: "sm" })
|
|
3493
3814
|
] }),
|
|
3494
|
-
mobileCards ? /* @__PURE__ */
|
|
3815
|
+
mobileCards ? /* @__PURE__ */ jsx29(Stack13, { gap: "xs", "aria-label": "Mobile row cards", children: table.visibleRows.slice(0, 6).map((row, index) => {
|
|
3495
3816
|
const ordered = [...visibleColumns].sort((left, right) => (left.mobilePriority ?? 99) - (right.mobilePriority ?? 99));
|
|
3496
3817
|
const id = rowId(row, index);
|
|
3497
|
-
return /* @__PURE__ */
|
|
3818
|
+
return /* @__PURE__ */ jsx29(
|
|
3498
3819
|
StateBlock,
|
|
3499
3820
|
{
|
|
3500
3821
|
variant: "info",
|
|
@@ -3509,10 +3830,10 @@ function GdsDataTable({
|
|
|
3509
3830
|
}
|
|
3510
3831
|
|
|
3511
3832
|
// src/GdsResourceManager.client.tsx
|
|
3512
|
-
import { useGdsTranslation as
|
|
3513
|
-
import { useCallback 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";
|
|
3514
3835
|
import { Button as Button11, Group as Group17, Stack as Stack14, Text as Text19 } from "@mantine/core";
|
|
3515
|
-
import { jsx as
|
|
3836
|
+
import { jsx as jsx30, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
3516
3837
|
function emitResourceEvent(onEvent, event) {
|
|
3517
3838
|
onEvent?.({ ...event, timestamp: Date.now(), privacy: "metadata-only" });
|
|
3518
3839
|
}
|
|
@@ -3574,12 +3895,12 @@ function useGdsResourceManager({
|
|
|
3574
3895
|
timeoutMs = 8e3,
|
|
3575
3896
|
confirmAction
|
|
3576
3897
|
}) {
|
|
3577
|
-
const [resources, setResources] =
|
|
3578
|
-
const [selectedResource, setSelectedResource] =
|
|
3579
|
-
const [state, setState] =
|
|
3580
|
-
const [error, setError] =
|
|
3581
|
-
const [reloadKey, setReloadKey] =
|
|
3582
|
-
|
|
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(() => {
|
|
3583
3904
|
const controller = new AbortController();
|
|
3584
3905
|
const timer = window.setTimeout(() => controller.abort(), timeoutMs);
|
|
3585
3906
|
setState("loading-list");
|
|
@@ -3599,12 +3920,12 @@ function useGdsResourceManager({
|
|
|
3599
3920
|
window.clearTimeout(timer);
|
|
3600
3921
|
};
|
|
3601
3922
|
}, [adapter, onEvent, reloadKey, timeoutMs]);
|
|
3602
|
-
const loadList =
|
|
3923
|
+
const loadList = useCallback8(() => setReloadKey((value) => value + 1), []);
|
|
3603
3924
|
const permissions = useMemo8(() => adapter.getPermissions?.(selectedResource) ?? defaultPermissions(selectedResource), [adapter, selectedResource]);
|
|
3604
|
-
const canRunAction =
|
|
3925
|
+
const canRunAction = useCallback8((action, resource = selectedResource) => {
|
|
3605
3926
|
return (adapter.getPermissions?.(resource) ?? defaultPermissions(resource)).find((permission) => permission.action === action) ?? { action, allowed: false, reason: "Action is not available." };
|
|
3606
3927
|
}, [adapter, selectedResource]);
|
|
3607
|
-
const openDetail =
|
|
3928
|
+
const openDetail = useCallback8(async (id) => {
|
|
3608
3929
|
setState("detail-loading");
|
|
3609
3930
|
try {
|
|
3610
3931
|
const resource = adapter.detail ? await adapter.detail(id) : resources.find((item) => item.id === id) ?? null;
|
|
@@ -3625,7 +3946,7 @@ function useGdsResourceManager({
|
|
|
3625
3946
|
return null;
|
|
3626
3947
|
}
|
|
3627
3948
|
}, [adapter, onEvent, resources]);
|
|
3628
|
-
const runAction =
|
|
3949
|
+
const runAction = useCallback8(async (action, resource, values = {}) => {
|
|
3629
3950
|
const permission = canRunAction(action, resource);
|
|
3630
3951
|
if (!permission.allowed) {
|
|
3631
3952
|
setState("permission-denied");
|
|
@@ -3691,7 +4012,7 @@ function GdsResourceManager({
|
|
|
3691
4012
|
timeoutMs,
|
|
3692
4013
|
confirmAction
|
|
3693
4014
|
}) {
|
|
3694
|
-
const { t } =
|
|
4015
|
+
const { t } = useGdsTranslation22();
|
|
3695
4016
|
const emptyLabel = emptyLabelProp ?? t("gds.gdsResourceManager.emptyLabel", "No resources available");
|
|
3696
4017
|
const manager = useGdsResourceManager({ adapter, onEvent, timeoutMs, confirmAction });
|
|
3697
4018
|
const tableColumns = useMemo8(() => columns ?? [
|
|
@@ -3700,21 +4021,21 @@ function GdsResourceManager({
|
|
|
3700
4021
|
{ key: "updatedAt", label: "Updated", sortable: true, mobilePriority: 3 }
|
|
3701
4022
|
], [columns]);
|
|
3702
4023
|
const tableAdapter = useMemo8(() => createGdsTableAdapter(manager.resources, tableColumns), [manager.resources, tableColumns]);
|
|
3703
|
-
if (manager.state === "loading-list") return /* @__PURE__ */
|
|
3704
|
-
if (manager.state === "error") return /* @__PURE__ */
|
|
3705
|
-
if (manager.state === "empty") return /* @__PURE__ */
|
|
3706
|
-
return /* @__PURE__ */
|
|
3707
|
-
/* @__PURE__ */
|
|
3708
|
-
/* @__PURE__ */
|
|
3709
|
-
/* @__PURE__ */
|
|
3710
|
-
description ? /* @__PURE__ */
|
|
3711
|
-
manager.error ? /* @__PURE__ */
|
|
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
|
|
3712
4033
|
] }),
|
|
3713
|
-
/* @__PURE__ */
|
|
4034
|
+
/* @__PURE__ */ jsx30(Button11, { onClick: () => {
|
|
3714
4035
|
void manager.runAction("create", null, { title: "Untitled resource" });
|
|
3715
4036
|
}, children: "Create" })
|
|
3716
4037
|
] }),
|
|
3717
|
-
/* @__PURE__ */
|
|
4038
|
+
/* @__PURE__ */ jsx30(
|
|
3718
4039
|
GdsDataTable,
|
|
3719
4040
|
{
|
|
3720
4041
|
caption: `${title} resources`,
|
|
@@ -3723,17 +4044,17 @@ function GdsResourceManager({
|
|
|
3723
4044
|
{
|
|
3724
4045
|
key: "id",
|
|
3725
4046
|
label: "Actions",
|
|
3726
|
-
render: (row) => /* @__PURE__ */
|
|
3727
|
-
/* @__PURE__ */
|
|
4047
|
+
render: (row) => /* @__PURE__ */ jsxs21(Group17, { gap: "xs", children: [
|
|
4048
|
+
/* @__PURE__ */ jsx30(Button11, { size: "xs", variant: "light", onClick: () => {
|
|
3728
4049
|
void manager.openDetail(row.id);
|
|
3729
4050
|
}, children: "Details" }),
|
|
3730
|
-
/* @__PURE__ */
|
|
4051
|
+
/* @__PURE__ */ jsx30(Button11, { size: "xs", variant: "light", onClick: () => {
|
|
3731
4052
|
void manager.runAction("activate", row);
|
|
3732
4053
|
}, disabled: !manager.canRunAction("activate", row).allowed, children: "Activate" }),
|
|
3733
|
-
/* @__PURE__ */
|
|
4054
|
+
/* @__PURE__ */ jsx30(Button11, { size: "xs", variant: "light", color: "red", onClick: () => {
|
|
3734
4055
|
void manager.runAction("delete", row);
|
|
3735
4056
|
}, disabled: !manager.canRunAction("delete", row).allowed, children: "Delete" }),
|
|
3736
|
-
/* @__PURE__ */
|
|
4057
|
+
/* @__PURE__ */ jsx30(Button11, { size: "xs", variant: "subtle", onClick: () => {
|
|
3737
4058
|
void manager.runAction("copy-preview", row);
|
|
3738
4059
|
}, disabled: !manager.canRunAction("copy-preview", row).allowed, children: "Copy preview" })
|
|
3739
4060
|
] })
|
|
@@ -3744,7 +4065,7 @@ function GdsResourceManager({
|
|
|
3744
4065
|
onEvent: (event) => onEvent?.({ type: event.type === "load_failed" ? "action_failed" : "resource_loaded", timestamp: event.timestamp, privacy: "metadata-only", message: event.message })
|
|
3745
4066
|
}
|
|
3746
4067
|
),
|
|
3747
|
-
manager.selectedResource ? /* @__PURE__ */
|
|
4068
|
+
manager.selectedResource ? /* @__PURE__ */ jsx30("section", { "aria-label": `${manager.selectedResource.title} detail`, children: renderDetail ? renderDetail(manager.selectedResource, manager) : /* @__PURE__ */ jsx30(
|
|
3748
4069
|
StateBlock,
|
|
3749
4070
|
{
|
|
3750
4071
|
variant: "info",
|
|
@@ -3757,10 +4078,10 @@ function GdsResourceManager({
|
|
|
3757
4078
|
}
|
|
3758
4079
|
|
|
3759
4080
|
// src/OverlayManager.client.tsx
|
|
3760
|
-
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";
|
|
3761
4082
|
import { Drawer, Modal as Modal2 } from "@mantine/core";
|
|
3762
|
-
import { getGdsMotionPreset, gdsDevWarnOnce as gdsDevWarnOnce4, useGdsTranslation as
|
|
3763
|
-
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";
|
|
3764
4085
|
var defaultOverlayPolicy = {
|
|
3765
4086
|
closeOnEscape: true,
|
|
3766
4087
|
closeOnOutsideClick: true,
|
|
@@ -3802,13 +4123,13 @@ function OverlayManagerProvider({
|
|
|
3802
4123
|
routeKey,
|
|
3803
4124
|
onOverlayEvent
|
|
3804
4125
|
}) {
|
|
3805
|
-
const [stack, setStack] =
|
|
3806
|
-
const focusReturnTargets =
|
|
3807
|
-
const previousRouteKey =
|
|
3808
|
-
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) => {
|
|
3809
4130
|
onOverlayEvent?.(createOverlayEvent(type, item, reason));
|
|
3810
4131
|
}, [onOverlayEvent]);
|
|
3811
|
-
const registerOverlay =
|
|
4132
|
+
const registerOverlay = useCallback9((overlay) => {
|
|
3812
4133
|
const policy = normalizePolicy(defaultPolicy, overlay.policy);
|
|
3813
4134
|
const focusTarget = getFocusableElement(overlay.invokerId);
|
|
3814
4135
|
if (policy.returnFocus && focusTarget) {
|
|
@@ -3828,7 +4149,7 @@ function OverlayManagerProvider({
|
|
|
3828
4149
|
return [...base, item];
|
|
3829
4150
|
});
|
|
3830
4151
|
}, [defaultPolicy, emit, singleOverlayMode]);
|
|
3831
|
-
const unregisterOverlay =
|
|
4152
|
+
const unregisterOverlay = useCallback9((id, reason = "programmatic") => {
|
|
3832
4153
|
setStack((current) => {
|
|
3833
4154
|
const target = current.find((item) => item.id === id);
|
|
3834
4155
|
if (target) {
|
|
@@ -3842,8 +4163,8 @@ function OverlayManagerProvider({
|
|
|
3842
4163
|
focusReturnTargets.current.delete(id);
|
|
3843
4164
|
}
|
|
3844
4165
|
}, [emit]);
|
|
3845
|
-
const isTopMost =
|
|
3846
|
-
const requestClose =
|
|
4166
|
+
const isTopMost = useCallback9((id) => stack.length > 0 && stack[stack.length - 1]?.id === id, [stack]);
|
|
4167
|
+
const requestClose = useCallback9((id, reason) => {
|
|
3847
4168
|
const target = stack.find((item) => item.id === id);
|
|
3848
4169
|
if (!target || !isTopMost(id)) {
|
|
3849
4170
|
if (target) emit("blocked_close", { ...target, status: "blocked-close" }, reason);
|
|
@@ -3860,13 +4181,13 @@ function OverlayManagerProvider({
|
|
|
3860
4181
|
}
|
|
3861
4182
|
return reason;
|
|
3862
4183
|
}, [defaultPolicy, emit, isTopMost, stack]);
|
|
3863
|
-
const closeOverlay =
|
|
4184
|
+
const closeOverlay = useCallback9((id, reason = "programmatic") => {
|
|
3864
4185
|
const acceptedReason = requestClose(id, reason);
|
|
3865
4186
|
if (!acceptedReason) return false;
|
|
3866
4187
|
unregisterOverlay(id, acceptedReason);
|
|
3867
4188
|
return true;
|
|
3868
4189
|
}, [requestClose, unregisterOverlay]);
|
|
3869
|
-
|
|
4190
|
+
useEffect8(() => {
|
|
3870
4191
|
if (previousRouteKey.current === routeKey) return;
|
|
3871
4192
|
previousRouteKey.current = routeKey;
|
|
3872
4193
|
setStack((current) => {
|
|
@@ -3893,7 +4214,7 @@ function OverlayManagerProvider({
|
|
|
3893
4214
|
getOverlay: (id) => stack.find((item) => item.id === id),
|
|
3894
4215
|
requestClose
|
|
3895
4216
|
}), [closeOverlay, isTopMost, registerOverlay, requestClose, stack, unregisterOverlay]);
|
|
3896
|
-
return /* @__PURE__ */
|
|
4217
|
+
return /* @__PURE__ */ jsx31(OverlayManagerContext.Provider, { value, children });
|
|
3897
4218
|
}
|
|
3898
4219
|
function useOverlayManager() {
|
|
3899
4220
|
const context = useContext4(OverlayManagerContext);
|
|
@@ -3923,12 +4244,12 @@ function useOverlaySurface({
|
|
|
3923
4244
|
const registerOverlay = manager?.registerOverlay;
|
|
3924
4245
|
const unregisterOverlay = manager?.unregisterOverlay;
|
|
3925
4246
|
const requestOverlayClose = manager?.requestClose;
|
|
3926
|
-
|
|
4247
|
+
useEffect8(() => {
|
|
3927
4248
|
if (!registerOverlay || !unregisterOverlay || !opened) return void 0;
|
|
3928
4249
|
registerOverlay({ id, kind, title, description, invokerId, policy });
|
|
3929
4250
|
return () => unregisterOverlay(id);
|
|
3930
4251
|
}, [description, id, invokerId, kind, opened, policy, registerOverlay, title, unregisterOverlay]);
|
|
3931
|
-
const requestClose =
|
|
4252
|
+
const requestClose = useCallback9((reason) => {
|
|
3932
4253
|
if (!requestOverlayClose || !unregisterOverlay) {
|
|
3933
4254
|
onClose();
|
|
3934
4255
|
return;
|
|
@@ -3957,8 +4278,8 @@ function GdsModal({
|
|
|
3957
4278
|
}) {
|
|
3958
4279
|
const requestClose = useOverlaySurface({ id, opened, kind: "modal", title, description, children, invokerId, policy, onClose, onBlockedClose });
|
|
3959
4280
|
const motion = getGdsMotionPreset("overlay");
|
|
3960
|
-
const { t } =
|
|
3961
|
-
return /* @__PURE__ */
|
|
4281
|
+
const { t } = useGdsTranslation23();
|
|
4282
|
+
return /* @__PURE__ */ jsx31(
|
|
3962
4283
|
Modal2,
|
|
3963
4284
|
{
|
|
3964
4285
|
...modalProps,
|
|
@@ -3989,8 +4310,8 @@ function GdsDrawer({
|
|
|
3989
4310
|
}) {
|
|
3990
4311
|
const requestClose = useOverlaySurface({ id, opened, kind: "drawer", title, description, children, invokerId, policy, onClose, onBlockedClose });
|
|
3991
4312
|
const motion = getGdsMotionPreset("drawer");
|
|
3992
|
-
const { t } =
|
|
3993
|
-
return /* @__PURE__ */
|
|
4313
|
+
const { t } = useGdsTranslation23();
|
|
4314
|
+
return /* @__PURE__ */ jsx31(
|
|
3994
4315
|
Drawer,
|
|
3995
4316
|
{
|
|
3996
4317
|
...drawerProps,
|
|
@@ -4009,20 +4330,20 @@ function GdsDrawer({
|
|
|
4009
4330
|
);
|
|
4010
4331
|
}
|
|
4011
4332
|
function GdsSheet(props) {
|
|
4012
|
-
return /* @__PURE__ */
|
|
4333
|
+
return /* @__PURE__ */ jsx31(GdsDrawer, { ...props, position: props.position ?? "bottom", policy: { mobileFullscreen: true, ...props.policy } });
|
|
4013
4334
|
}
|
|
4014
4335
|
function GdsDialog(props) {
|
|
4015
|
-
return /* @__PURE__ */
|
|
4336
|
+
return /* @__PURE__ */ jsx31(GdsModal, { ...props });
|
|
4016
4337
|
}
|
|
4017
4338
|
function GdsSidePanel(props) {
|
|
4018
|
-
return /* @__PURE__ */
|
|
4339
|
+
return /* @__PURE__ */ jsx31(GdsDrawer, { ...props, position: props.position ?? "right" });
|
|
4019
4340
|
}
|
|
4020
4341
|
|
|
4021
4342
|
// src/Notifications.client.tsx
|
|
4022
|
-
import { gdsSafeAreaInset, gdsZIndexToken, useGdsTranslation as
|
|
4343
|
+
import { gdsSafeAreaInset, gdsZIndexToken, useGdsTranslation as useGdsTranslation24 } from "@sovereignsquad/gds-theme";
|
|
4023
4344
|
import { Box as Box10, Button as Button12, Group as Group18, Text as Text20 } from "@mantine/core";
|
|
4024
|
-
import { createContext as createContext5, useCallback as
|
|
4025
|
-
import { jsx as
|
|
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";
|
|
4026
4347
|
var GdsNotificationContext = createContext5(null);
|
|
4027
4348
|
function shouldAutoClose(message) {
|
|
4028
4349
|
if (message.autoCloseMs === false) return false;
|
|
@@ -4053,13 +4374,13 @@ function GdsNotificationProvider({
|
|
|
4053
4374
|
defaultPolicy,
|
|
4054
4375
|
onAuditEvent
|
|
4055
4376
|
}) {
|
|
4056
|
-
const [notifications, setNotifications] =
|
|
4057
|
-
const [announcement, setAnnouncement] =
|
|
4058
|
-
const timers =
|
|
4059
|
-
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 = {}) => {
|
|
4060
4381
|
onAuditEvent?.(createGdsNotificationAuditEvent(type, notification, metadata));
|
|
4061
4382
|
}, [onAuditEvent]);
|
|
4062
|
-
const scheduleAutoClose =
|
|
4383
|
+
const scheduleAutoClose = useCallback10((message) => {
|
|
4063
4384
|
const existingTimer = timers.current.get(message.id);
|
|
4064
4385
|
if (existingTimer) {
|
|
4065
4386
|
window.clearTimeout(existingTimer);
|
|
@@ -4076,7 +4397,7 @@ function GdsNotificationProvider({
|
|
|
4076
4397
|
}, message.autoCloseMs);
|
|
4077
4398
|
timers.current.set(message.id, timer);
|
|
4078
4399
|
}, [audit]);
|
|
4079
|
-
const updateNotification =
|
|
4400
|
+
const updateNotification = useCallback10((id, patch) => {
|
|
4080
4401
|
setNotifications((current) => current.map((item) => {
|
|
4081
4402
|
if (item.id !== id) return item;
|
|
4082
4403
|
const updated = normalizeNotification({ ...item, ...patch, id }, defaultPolicy);
|
|
@@ -4085,7 +4406,7 @@ function GdsNotificationProvider({
|
|
|
4085
4406
|
return updated;
|
|
4086
4407
|
}));
|
|
4087
4408
|
}, [audit, defaultPolicy, scheduleAutoClose]);
|
|
4088
|
-
const dismissNotification =
|
|
4409
|
+
const dismissNotification = useCallback10((id) => {
|
|
4089
4410
|
setNotifications((current) => {
|
|
4090
4411
|
const target = current.find((item) => item.id === id);
|
|
4091
4412
|
if (target) audit("dismissed", { ...target, status: "dismissed" });
|
|
@@ -4097,7 +4418,7 @@ function GdsNotificationProvider({
|
|
|
4097
4418
|
return current.filter((item) => item.id !== id);
|
|
4098
4419
|
});
|
|
4099
4420
|
}, [audit]);
|
|
4100
|
-
const notify =
|
|
4421
|
+
const notify = useCallback10((message, policy) => {
|
|
4101
4422
|
const mergedPolicy = { ...defaultPolicy, ...policy };
|
|
4102
4423
|
const next = normalizeNotification(message, mergedPolicy);
|
|
4103
4424
|
audit("shown", next);
|
|
@@ -4168,9 +4489,9 @@ function GdsNotificationProvider({
|
|
|
4168
4489
|
}
|
|
4169
4490
|
}), [audit, dismissNotification, notifications, notify, updateNotification]);
|
|
4170
4491
|
const livePolicy = announcement ? getGdsNotificationLivePolicy(announcement) : "polite";
|
|
4171
|
-
return /* @__PURE__ */
|
|
4492
|
+
return /* @__PURE__ */ jsxs22(GdsNotificationContext.Provider, { value, children: [
|
|
4172
4493
|
children,
|
|
4173
|
-
/* @__PURE__ */
|
|
4494
|
+
/* @__PURE__ */ jsx32(
|
|
4174
4495
|
"span",
|
|
4175
4496
|
{
|
|
4176
4497
|
role: announcement?.severity === "error" ? "alert" : "status",
|
|
@@ -4203,7 +4524,7 @@ function NotificationCenter({
|
|
|
4203
4524
|
title: titleProp,
|
|
4204
4525
|
emptyMessage: emptyMessageProp
|
|
4205
4526
|
}) {
|
|
4206
|
-
const { t } =
|
|
4527
|
+
const { t } = useGdsTranslation24();
|
|
4207
4528
|
const title = titleProp ?? t("gds.notifications.title", "Notifications");
|
|
4208
4529
|
const emptyMessage = emptyMessageProp ?? t("gds.notifications.emptyMessage", "No active notifications.");
|
|
4209
4530
|
const {
|
|
@@ -4213,7 +4534,7 @@ function NotificationCenter({
|
|
|
4213
4534
|
runRetry,
|
|
4214
4535
|
runAction
|
|
4215
4536
|
} = useGdsNotifications();
|
|
4216
|
-
return /* @__PURE__ */
|
|
4537
|
+
return /* @__PURE__ */ jsx32(
|
|
4217
4538
|
NotificationCenterView,
|
|
4218
4539
|
{
|
|
4219
4540
|
live: false,
|
|
@@ -4233,7 +4554,7 @@ function NotificationCenter({
|
|
|
4233
4554
|
}
|
|
4234
4555
|
var GdsNotificationCenter = NotificationCenter;
|
|
4235
4556
|
function GdsToastViewport({ position = "bottom-end", maxVisible = 3 }) {
|
|
4236
|
-
const { t } =
|
|
4557
|
+
const { t } = useGdsTranslation24();
|
|
4237
4558
|
const { notifications, dismissNotification, runAction, runRetry } = useGdsNotifications();
|
|
4238
4559
|
const visible = notifications.filter((item) => item.persistence !== "announcement-only" && !item.announcementOnly);
|
|
4239
4560
|
if (visible.length === 0) return null;
|
|
@@ -4242,7 +4563,7 @@ function GdsToastViewport({ position = "bottom-end", maxVisible = 3 }) {
|
|
|
4242
4563
|
const [vertical, horizontal] = position.split("-");
|
|
4243
4564
|
const sideInset = `calc(var(--gds-space-md) + max(${gdsSafeAreaInset.left}, ${gdsSafeAreaInset.right}))`;
|
|
4244
4565
|
const edgeInset = `calc(var(--gds-space-md) + ${vertical === "top" ? gdsSafeAreaInset.top : gdsSafeAreaInset.bottom})`;
|
|
4245
|
-
return /* @__PURE__ */
|
|
4566
|
+
return /* @__PURE__ */ jsx32(
|
|
4246
4567
|
Box10,
|
|
4247
4568
|
{
|
|
4248
4569
|
component: "section",
|
|
@@ -4259,9 +4580,9 @@ function GdsToastViewport({ position = "bottom-end", maxVisible = 3 }) {
|
|
|
4259
4580
|
justifyContent: horizontal === "end" ? "flex-end" : "flex-start",
|
|
4260
4581
|
pointerEvents: "none"
|
|
4261
4582
|
},
|
|
4262
|
-
children: /* @__PURE__ */
|
|
4263
|
-
hiddenCount > 0 ? /* @__PURE__ */
|
|
4264
|
-
shown.map((item) => /* @__PURE__ */
|
|
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(
|
|
4265
4586
|
InlineAlert,
|
|
4266
4587
|
{
|
|
4267
4588
|
live: false,
|
|
@@ -4269,10 +4590,10 @@ function GdsToastViewport({ position = "bottom-end", maxVisible = 3 }) {
|
|
|
4269
4590
|
status: item.status,
|
|
4270
4591
|
title: item.title,
|
|
4271
4592
|
message: item.message,
|
|
4272
|
-
action: /* @__PURE__ */
|
|
4273
|
-
item.actions?.map((action) => /* @__PURE__ */
|
|
4274
|
-
item.retry ? /* @__PURE__ */
|
|
4275
|
-
/* @__PURE__ */
|
|
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") })
|
|
4276
4597
|
] })
|
|
4277
4598
|
},
|
|
4278
4599
|
item.id
|
|
@@ -4283,10 +4604,10 @@ function GdsToastViewport({ position = "bottom-end", maxVisible = 3 }) {
|
|
|
4283
4604
|
}
|
|
4284
4605
|
|
|
4285
4606
|
// src/FeedbackRuntime.client.tsx
|
|
4286
|
-
import { createContext as createContext6, useCallback as
|
|
4287
|
-
import { useGdsTranslation as
|
|
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";
|
|
4288
4609
|
import { Alert as Alert2, Button as Button13, Group as Group19, Paper as Paper7, Stack as Stack15, Text as Text21 } from "@mantine/core";
|
|
4289
|
-
import { Fragment as
|
|
4610
|
+
import { Fragment as Fragment6, jsx as jsx33, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4290
4611
|
var GdsConfirmContext = createContext6(null);
|
|
4291
4612
|
function createConfirmationEvent(type, request, status) {
|
|
4292
4613
|
return {
|
|
@@ -4308,21 +4629,21 @@ function GdsConfirmProvider({
|
|
|
4308
4629
|
defaultTimeoutMs = 1e4,
|
|
4309
4630
|
onConfirmationEvent
|
|
4310
4631
|
}) {
|
|
4311
|
-
const { t } =
|
|
4312
|
-
const [activeRequest, setActiveRequest] =
|
|
4313
|
-
const [undoState, setUndoState] =
|
|
4314
|
-
const activeResolver =
|
|
4315
|
-
const actionResolver =
|
|
4316
|
-
const focusReturnTarget =
|
|
4317
|
-
const emit =
|
|
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) => {
|
|
4318
4639
|
onConfirmationEvent?.(createConfirmationEvent(type, request, status));
|
|
4319
4640
|
}, [onConfirmationEvent]);
|
|
4320
|
-
const restoreFocus =
|
|
4641
|
+
const restoreFocus = useCallback11(() => {
|
|
4321
4642
|
const target = focusReturnTarget.current;
|
|
4322
4643
|
focusReturnTarget.current = null;
|
|
4323
4644
|
if (target) window.setTimeout(() => target.focus(), 0);
|
|
4324
4645
|
}, []);
|
|
4325
|
-
const openConfirm =
|
|
4646
|
+
const openConfirm = useCallback11((request) => new Promise((resolve) => {
|
|
4326
4647
|
if (activeResolver.current) {
|
|
4327
4648
|
activeResolver.current(false);
|
|
4328
4649
|
}
|
|
@@ -4331,7 +4652,7 @@ function GdsConfirmProvider({
|
|
|
4331
4652
|
emit("opened", request, "open");
|
|
4332
4653
|
setActiveRequest({ ...request, mode: "boolean", status: "open", resolve });
|
|
4333
4654
|
}), [emit]);
|
|
4334
|
-
const openActionConfirm =
|
|
4655
|
+
const openActionConfirm = useCallback11((request) => new Promise((resolve) => {
|
|
4335
4656
|
if (actionResolver.current) {
|
|
4336
4657
|
actionResolver.current({ status: "cancelled" });
|
|
4337
4658
|
}
|
|
@@ -4349,7 +4670,7 @@ function GdsConfirmProvider({
|
|
|
4349
4670
|
resolve: resolver
|
|
4350
4671
|
});
|
|
4351
4672
|
}), [emit]);
|
|
4352
|
-
const resolveActive =
|
|
4673
|
+
const resolveActive = useCallback11((confirmed) => {
|
|
4353
4674
|
if (activeRequest?.mode === "boolean") {
|
|
4354
4675
|
emit(confirmed ? "confirmed" : "cancelled", activeRequest, confirmed ? "succeeded" : "cancelled");
|
|
4355
4676
|
}
|
|
@@ -4358,7 +4679,7 @@ function GdsConfirmProvider({
|
|
|
4358
4679
|
setActiveRequest(null);
|
|
4359
4680
|
restoreFocus();
|
|
4360
4681
|
}, [activeRequest, emit, restoreFocus]);
|
|
4361
|
-
const cancelAction =
|
|
4682
|
+
const cancelAction = useCallback11(() => {
|
|
4362
4683
|
if (activeRequest?.mode === "action") {
|
|
4363
4684
|
emit("cancelled", activeRequest, "cancelled");
|
|
4364
4685
|
actionResolver.current?.({ status: "cancelled", payload: activeRequest.payload });
|
|
@@ -4367,7 +4688,7 @@ function GdsConfirmProvider({
|
|
|
4367
4688
|
setActiveRequest(null);
|
|
4368
4689
|
restoreFocus();
|
|
4369
4690
|
}, [activeRequest, emit, restoreFocus]);
|
|
4370
|
-
const runAction =
|
|
4691
|
+
const runAction = useCallback11(async (retry = false) => {
|
|
4371
4692
|
if (!activeRequest || activeRequest.mode !== "action") return;
|
|
4372
4693
|
const request = activeRequest;
|
|
4373
4694
|
if (retry) emit("retry", request, "executing");
|
|
@@ -4422,18 +4743,18 @@ function GdsConfirmProvider({
|
|
|
4422
4743
|
confirmDestructive: (request) => openConfirm({ ...request, danger: true, confirmAction: request.confirmAction ?? "delete" }),
|
|
4423
4744
|
confirmAction: openActionConfirm
|
|
4424
4745
|
}), [openActionConfirm, openConfirm]);
|
|
4425
|
-
return /* @__PURE__ */
|
|
4746
|
+
return /* @__PURE__ */ jsxs23(GdsConfirmContext.Provider, { value, children: [
|
|
4426
4747
|
children,
|
|
4427
|
-
undoState ? /* @__PURE__ */
|
|
4428
|
-
/* @__PURE__ */
|
|
4429
|
-
/* @__PURE__ */
|
|
4430
|
-
/* @__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.") })
|
|
4431
4752
|
] }),
|
|
4432
|
-
/* @__PURE__ */
|
|
4753
|
+
/* @__PURE__ */ jsx33(Button13, { size: "xs", variant: "default", onClick: () => {
|
|
4433
4754
|
void undoState.onUndo();
|
|
4434
4755
|
}, children: undoState.label ?? t("gds.confirm.undo", "Undo") })
|
|
4435
4756
|
] }) }) : null,
|
|
4436
|
-
/* @__PURE__ */
|
|
4757
|
+
/* @__PURE__ */ jsx33(
|
|
4437
4758
|
ConfirmDialog,
|
|
4438
4759
|
{
|
|
4439
4760
|
opened: Boolean(activeRequest),
|
|
@@ -4444,18 +4765,18 @@ function GdsConfirmProvider({
|
|
|
4444
4765
|
cancelAction: activeRequest?.cancelAction ?? "cancel",
|
|
4445
4766
|
isDanger: activeRequest?.danger ?? false,
|
|
4446
4767
|
loading: activeRequest?.status === "executing" || activeRequest?.status === "validating",
|
|
4447
|
-
children: /* @__PURE__ */
|
|
4448
|
-
activeRequest?.targetName ? /* @__PURE__ */
|
|
4449
|
-
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,
|
|
4450
4771
|
activeRequest?.message,
|
|
4451
|
-
activeRequest?.consequence ? /* @__PURE__ */
|
|
4452
|
-
/* @__PURE__ */
|
|
4772
|
+
activeRequest?.consequence ? /* @__PURE__ */ jsxs23(Fragment6, { children: [
|
|
4773
|
+
/* @__PURE__ */ jsx33("br", {}),
|
|
4453
4774
|
activeRequest.consequence
|
|
4454
4775
|
] }) : null,
|
|
4455
|
-
activeRequest?.mode === "action" && activeRequest.preview ? /* @__PURE__ */
|
|
4456
|
-
activeRequest?.mode === "action" && activeRequest.status === "failed" ? /* @__PURE__ */
|
|
4457
|
-
/* @__PURE__ */
|
|
4458
|
-
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
|
|
4459
4780
|
] }) : null
|
|
4460
4781
|
] })
|
|
4461
4782
|
}
|
|
@@ -4474,9 +4795,9 @@ function createToastId(prefix) {
|
|
|
4474
4795
|
return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
4475
4796
|
}
|
|
4476
4797
|
function GdsToastProvider({ children, viewport = true }) {
|
|
4477
|
-
return /* @__PURE__ */
|
|
4478
|
-
/* @__PURE__ */
|
|
4479
|
-
viewport ? /* @__PURE__ */
|
|
4798
|
+
return /* @__PURE__ */ jsxs23(GdsNotificationProvider, { children: [
|
|
4799
|
+
/* @__PURE__ */ jsx33(GdsToastProviderInner, { children }),
|
|
4800
|
+
viewport ? /* @__PURE__ */ jsx33(GdsToastViewport, { ...viewport === true ? {} : viewport }) : null
|
|
4480
4801
|
] });
|
|
4481
4802
|
}
|
|
4482
4803
|
function GdsToastProviderInner({ children }) {
|
|
@@ -4502,7 +4823,7 @@ function GdsToastProviderInner({ children }) {
|
|
|
4502
4823
|
autoCloseMs: message.autoCloseMs ?? 3e3
|
|
4503
4824
|
})
|
|
4504
4825
|
}), [notify]);
|
|
4505
|
-
return /* @__PURE__ */
|
|
4826
|
+
return /* @__PURE__ */ jsx33(GdsToastContext.Provider, { value, children });
|
|
4506
4827
|
}
|
|
4507
4828
|
function useGdsToasts() {
|
|
4508
4829
|
const context = useContext6(GdsToastContext);
|
|
@@ -4513,9 +4834,9 @@ function useGdsToasts() {
|
|
|
4513
4834
|
}
|
|
4514
4835
|
|
|
4515
4836
|
// src/CommandPalette.client.tsx
|
|
4516
|
-
import { createContext as createContext7, useContext as useContext7, useEffect as
|
|
4837
|
+
import { createContext as createContext7, useContext as useContext7, useEffect as useEffect9, useMemo as useMemo12, useState as useState19 } from "react";
|
|
4517
4838
|
import { ActionIcon as ActionIcon3, Group as Group20, Modal as Modal3, Stack as Stack16, Text as Text22, TextInput as TextInput3 } from "@mantine/core";
|
|
4518
|
-
import { jsx as
|
|
4839
|
+
import { jsx as jsx34, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
4519
4840
|
var CommandPaletteContext = createContext7(null);
|
|
4520
4841
|
function normalize(text) {
|
|
4521
4842
|
return text.trim().toLowerCase();
|
|
@@ -4533,17 +4854,17 @@ function scoreCommand(command, query, recentUse) {
|
|
|
4533
4854
|
return 0.6 * prefix + 0.3 * keyword + 0.1 * recent;
|
|
4534
4855
|
}
|
|
4535
4856
|
function CommandRegistryProvider({ children }) {
|
|
4536
|
-
const [commands, setCommands] =
|
|
4537
|
-
const [opened, setOpened] =
|
|
4857
|
+
const [commands, setCommands] = useState19([]);
|
|
4858
|
+
const [opened, setOpened] = useState19(false);
|
|
4538
4859
|
const value = useMemo12(() => ({
|
|
4539
4860
|
commands,
|
|
4540
4861
|
registerCommands: (next) => setCommands(next),
|
|
4541
4862
|
open: () => setOpened(true),
|
|
4542
4863
|
close: () => setOpened(false)
|
|
4543
4864
|
}), [commands]);
|
|
4544
|
-
return /* @__PURE__ */
|
|
4865
|
+
return /* @__PURE__ */ jsxs24(CommandPaletteContext.Provider, { value, children: [
|
|
4545
4866
|
children,
|
|
4546
|
-
/* @__PURE__ */
|
|
4867
|
+
/* @__PURE__ */ jsx34(CommandPalette, { opened, onClose: () => setOpened(false) })
|
|
4547
4868
|
] });
|
|
4548
4869
|
}
|
|
4549
4870
|
function useCommandLauncher() {
|
|
@@ -4563,11 +4884,11 @@ function CommandPalette({ opened, onClose }) {
|
|
|
4563
4884
|
throw new Error("CommandPalette must be used within CommandRegistryProvider.");
|
|
4564
4885
|
}
|
|
4565
4886
|
const registry = contextValue;
|
|
4566
|
-
const [query, setQuery] =
|
|
4567
|
-
const [recentUse, setRecentUse] =
|
|
4887
|
+
const [query, setQuery] = useState19("");
|
|
4888
|
+
const [recentUse, setRecentUse] = useState19({});
|
|
4568
4889
|
const enabledCommands = registry.commands.filter((command) => command.enabledWhen ? command.enabledWhen() : true);
|
|
4569
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);
|
|
4570
|
-
|
|
4891
|
+
useEffect9(() => {
|
|
4571
4892
|
function onKeyDown(event) {
|
|
4572
4893
|
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
|
|
4573
4894
|
event.preventDefault();
|
|
@@ -4580,8 +4901,8 @@ function CommandPalette({ opened, onClose }) {
|
|
|
4580
4901
|
window.addEventListener("keydown", onKeyDown);
|
|
4581
4902
|
return () => window.removeEventListener("keydown", onKeyDown);
|
|
4582
4903
|
}, [registry, opened, onClose]);
|
|
4583
|
-
return /* @__PURE__ */
|
|
4584
|
-
/* @__PURE__ */
|
|
4904
|
+
return /* @__PURE__ */ jsx34(Modal3, { opened, onClose, title: "Quick actions", centered: true, children: /* @__PURE__ */ jsxs24(Stack16, { gap: "sm", children: [
|
|
4905
|
+
/* @__PURE__ */ jsx34(
|
|
4585
4906
|
TextInput3,
|
|
4586
4907
|
{
|
|
4587
4908
|
"aria-label": "Command search",
|
|
@@ -4590,8 +4911,8 @@ function CommandPalette({ opened, onClose }) {
|
|
|
4590
4911
|
onChange: (event) => setQuery(event.currentTarget.value)
|
|
4591
4912
|
}
|
|
4592
4913
|
),
|
|
4593
|
-
filteredCommands.length === 0 ? /* @__PURE__ */
|
|
4594
|
-
/* @__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(
|
|
4595
4916
|
"button",
|
|
4596
4917
|
{
|
|
4597
4918
|
type: "button",
|
|
@@ -4604,26 +4925,26 @@ function CommandPalette({ opened, onClose }) {
|
|
|
4604
4925
|
children: command.label
|
|
4605
4926
|
}
|
|
4606
4927
|
),
|
|
4607
|
-
command.shortcut ? /* @__PURE__ */
|
|
4928
|
+
command.shortcut ? /* @__PURE__ */ jsx34(Text22, { size: "xs", c: "dimmed", children: command.shortcut }) : null
|
|
4608
4929
|
] }, command.id)),
|
|
4609
|
-
/* @__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" }) }) })
|
|
4610
4931
|
] }) });
|
|
4611
4932
|
}
|
|
4612
4933
|
|
|
4613
4934
|
// src/GdsTour.client.tsx
|
|
4614
4935
|
import {
|
|
4615
4936
|
createContext as createContext8,
|
|
4616
|
-
useCallback as
|
|
4937
|
+
useCallback as useCallback12,
|
|
4617
4938
|
useContext as useContext8,
|
|
4618
|
-
useEffect as
|
|
4939
|
+
useEffect as useEffect10,
|
|
4619
4940
|
useLayoutEffect,
|
|
4620
4941
|
useMemo as useMemo13,
|
|
4621
|
-
useRef as
|
|
4622
|
-
useState as
|
|
4942
|
+
useRef as useRef11,
|
|
4943
|
+
useState as useState20
|
|
4623
4944
|
} from "react";
|
|
4624
4945
|
import { createPortal } from "react-dom";
|
|
4625
|
-
import { useGdsTranslation as
|
|
4626
|
-
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";
|
|
4627
4948
|
var GdsTourContext = createContext8(null);
|
|
4628
4949
|
var SEEN_KEY_PREFIX = "gds-tour-seen:";
|
|
4629
4950
|
function hasSeen(tourId) {
|
|
@@ -4642,8 +4963,8 @@ function markSeen(tourId) {
|
|
|
4642
4963
|
}
|
|
4643
4964
|
}
|
|
4644
4965
|
function useHasSeenTour(tourId) {
|
|
4645
|
-
const [seen, setSeen] =
|
|
4646
|
-
|
|
4966
|
+
const [seen, setSeen] = useState20(false);
|
|
4967
|
+
useEffect10(() => {
|
|
4647
4968
|
setSeen(hasSeen(tourId));
|
|
4648
4969
|
}, [tourId]);
|
|
4649
4970
|
return seen;
|
|
@@ -4698,29 +5019,29 @@ function computeCardPosition(hole, card, placement) {
|
|
|
4698
5019
|
}
|
|
4699
5020
|
var FOCUSABLE = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
4700
5021
|
function GdsTourProvider({ children }) {
|
|
4701
|
-
const { t } =
|
|
4702
|
-
const [tourId, setTourId] =
|
|
4703
|
-
const [steps, setSteps] =
|
|
4704
|
-
const [index, setIndex] =
|
|
4705
|
-
const [status, setStatus] =
|
|
4706
|
-
const [rect, setRect] =
|
|
4707
|
-
const [cardPos, setCardPos] =
|
|
4708
|
-
const [mounted, setMounted] =
|
|
4709
|
-
const optionsRef =
|
|
4710
|
-
const invokerRef =
|
|
4711
|
-
const cardRef =
|
|
4712
|
-
const targetElRef =
|
|
4713
|
-
|
|
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), []);
|
|
4714
5035
|
const running = status === "running";
|
|
4715
5036
|
const activeStep = running ? steps[index] ?? null : null;
|
|
4716
5037
|
const count = steps.length;
|
|
4717
|
-
const clearActiveTargetAttr =
|
|
5038
|
+
const clearActiveTargetAttr = useCallback12(() => {
|
|
4718
5039
|
if (targetElRef.current) {
|
|
4719
5040
|
targetElRef.current.removeAttribute("data-gds-tour-active-target");
|
|
4720
5041
|
targetElRef.current = null;
|
|
4721
5042
|
}
|
|
4722
5043
|
}, []);
|
|
4723
|
-
const finish =
|
|
5044
|
+
const finish = useCallback12(
|
|
4724
5045
|
(nextStatus, reason) => {
|
|
4725
5046
|
const opts = optionsRef.current;
|
|
4726
5047
|
const id = tourId;
|
|
@@ -4739,10 +5060,10 @@ function GdsTourProvider({ children }) {
|
|
|
4739
5060
|
},
|
|
4740
5061
|
[clearActiveTargetAttr, tourId]
|
|
4741
5062
|
);
|
|
4742
|
-
const stop =
|
|
5063
|
+
const stop = useCallback12((reason = "programmatic") => {
|
|
4743
5064
|
finish(reason === "finished" ? "finished" : "skipped", reason);
|
|
4744
5065
|
}, [finish]);
|
|
4745
|
-
const start =
|
|
5066
|
+
const start = useCallback12(
|
|
4746
5067
|
(id, tourSteps, options = {}) => {
|
|
4747
5068
|
if (!tourSteps.length) return;
|
|
4748
5069
|
optionsRef.current = options;
|
|
@@ -4754,7 +5075,7 @@ function GdsTourProvider({ children }) {
|
|
|
4754
5075
|
},
|
|
4755
5076
|
[]
|
|
4756
5077
|
);
|
|
4757
|
-
const goTo =
|
|
5078
|
+
const goTo = useCallback12(
|
|
4758
5079
|
(nextIndex) => {
|
|
4759
5080
|
setIndex((current) => {
|
|
4760
5081
|
const clamped = Math.max(0, Math.min(nextIndex, steps.length - 1));
|
|
@@ -4764,14 +5085,14 @@ function GdsTourProvider({ children }) {
|
|
|
4764
5085
|
},
|
|
4765
5086
|
[steps]
|
|
4766
5087
|
);
|
|
4767
|
-
const next =
|
|
5088
|
+
const next = useCallback12(() => {
|
|
4768
5089
|
if (index >= steps.length - 1) {
|
|
4769
5090
|
finish("finished", "finished");
|
|
4770
5091
|
} else {
|
|
4771
5092
|
goTo(index + 1);
|
|
4772
5093
|
}
|
|
4773
5094
|
}, [index, steps.length, finish, goTo]);
|
|
4774
|
-
const back =
|
|
5095
|
+
const back = useCallback12(() => {
|
|
4775
5096
|
if (index > 0) goTo(index - 1);
|
|
4776
5097
|
}, [index, goTo]);
|
|
4777
5098
|
useLayoutEffect(() => {
|
|
@@ -4817,7 +5138,7 @@ function GdsTourProvider({ children }) {
|
|
|
4817
5138
|
ro?.disconnect();
|
|
4818
5139
|
};
|
|
4819
5140
|
}, [running, activeStep, index, next]);
|
|
4820
|
-
|
|
5141
|
+
useEffect10(() => {
|
|
4821
5142
|
if (!running) return void 0;
|
|
4822
5143
|
const previousOverflow = document.body.style.overflow;
|
|
4823
5144
|
document.body.style.overflow = "hidden";
|
|
@@ -4832,7 +5153,7 @@ function GdsTourProvider({ children }) {
|
|
|
4832
5153
|
window.clearTimeout(focusCard);
|
|
4833
5154
|
};
|
|
4834
5155
|
}, [running, index]);
|
|
4835
|
-
|
|
5156
|
+
useEffect10(() => {
|
|
4836
5157
|
if (!running || !activeStep) return void 0;
|
|
4837
5158
|
const onKeyDown = (event) => {
|
|
4838
5159
|
if (event.key === "Escape") {
|
|
@@ -4879,15 +5200,15 @@ function GdsTourProvider({ children }) {
|
|
|
4879
5200
|
[status, tourId, index, count, activeStep, start, next, back, goTo, stop]
|
|
4880
5201
|
);
|
|
4881
5202
|
const overlay = mounted && running && activeStep && rect ? createPortal(
|
|
4882
|
-
/* @__PURE__ */
|
|
4883
|
-
/* @__PURE__ */
|
|
5203
|
+
/* @__PURE__ */ jsxs25(Fragment7, { children: [
|
|
5204
|
+
/* @__PURE__ */ jsxs25(
|
|
4884
5205
|
"div",
|
|
4885
5206
|
{
|
|
4886
5207
|
className: `gds-tour-spotlight${activeStep.interaction === "allow-target" ? " gds-tour-spotlight--interactive" : ""}`,
|
|
4887
5208
|
"data-gds-tour-overlay": "",
|
|
4888
5209
|
children: [
|
|
4889
|
-
activeStep.interaction !== "allow-target" ? /* @__PURE__ */
|
|
4890
|
-
/* @__PURE__ */
|
|
5210
|
+
activeStep.interaction !== "allow-target" ? /* @__PURE__ */ jsx35("div", { className: "gds-tour-spotlight__blocker", "aria-hidden": "true" }) : null,
|
|
5211
|
+
/* @__PURE__ */ jsx35(
|
|
4891
5212
|
"div",
|
|
4892
5213
|
{
|
|
4893
5214
|
className: "gds-tour-spotlight__hole",
|
|
@@ -4898,7 +5219,7 @@ function GdsTourProvider({ children }) {
|
|
|
4898
5219
|
]
|
|
4899
5220
|
}
|
|
4900
5221
|
),
|
|
4901
|
-
/* @__PURE__ */
|
|
5222
|
+
/* @__PURE__ */ jsxs25(
|
|
4902
5223
|
"div",
|
|
4903
5224
|
{
|
|
4904
5225
|
ref: cardRef,
|
|
@@ -4910,11 +5231,11 @@ function GdsTourProvider({ children }) {
|
|
|
4910
5231
|
tabIndex: -1,
|
|
4911
5232
|
style: cardPos ? { top: cardPos.top, left: cardPos.left } : { top: 16, left: 16, visibility: "hidden" },
|
|
4912
5233
|
children: [
|
|
4913
|
-
/* @__PURE__ */
|
|
4914
|
-
/* @__PURE__ */
|
|
4915
|
-
/* @__PURE__ */
|
|
4916
|
-
/* @__PURE__ */
|
|
4917
|
-
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(
|
|
4918
5239
|
"button",
|
|
4919
5240
|
{
|
|
4920
5241
|
type: "button",
|
|
@@ -4922,10 +5243,10 @@ function GdsTourProvider({ children }) {
|
|
|
4922
5243
|
onClick: () => finish("skipped", "skipped"),
|
|
4923
5244
|
children: t("gds.tour.skip", "Skip")
|
|
4924
5245
|
}
|
|
4925
|
-
) : /* @__PURE__ */
|
|
4926
|
-
/* @__PURE__ */
|
|
4927
|
-
index > 0 ? /* @__PURE__ */
|
|
4928
|
-
/* @__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") })
|
|
4929
5250
|
] })
|
|
4930
5251
|
] })
|
|
4931
5252
|
]
|
|
@@ -4934,7 +5255,7 @@ function GdsTourProvider({ children }) {
|
|
|
4934
5255
|
] }),
|
|
4935
5256
|
document.body
|
|
4936
5257
|
) : null;
|
|
4937
|
-
return /* @__PURE__ */
|
|
5258
|
+
return /* @__PURE__ */ jsxs25(GdsTourContext.Provider, { value, children: [
|
|
4938
5259
|
children,
|
|
4939
5260
|
overlay
|
|
4940
5261
|
] });
|
|
@@ -4948,8 +5269,8 @@ function useGdsTour() {
|
|
|
4948
5269
|
}
|
|
4949
5270
|
function GdsGuidedTour({ id, steps, open = false, defaultStep, ...options }) {
|
|
4950
5271
|
const { start, status } = useGdsTour();
|
|
4951
|
-
const startedRef =
|
|
4952
|
-
|
|
5272
|
+
const startedRef = useRef11(false);
|
|
5273
|
+
useEffect10(() => {
|
|
4953
5274
|
if (!open || startedRef.current || status === "running") return;
|
|
4954
5275
|
if (options.persist === "localStorage" && hasSeen(id)) return;
|
|
4955
5276
|
startedRef.current = true;
|
|
@@ -4971,8 +5292,8 @@ function GdsTourButton({
|
|
|
4971
5292
|
...buttonProps
|
|
4972
5293
|
}) {
|
|
4973
5294
|
const { start } = useGdsTour();
|
|
4974
|
-
const { t } =
|
|
4975
|
-
return /* @__PURE__ */
|
|
5295
|
+
const { t } = useGdsTranslation26();
|
|
5296
|
+
return /* @__PURE__ */ jsx35(
|
|
4976
5297
|
"button",
|
|
4977
5298
|
{
|
|
4978
5299
|
type: "button",
|
|
@@ -4985,10 +5306,10 @@ function GdsTourButton({
|
|
|
4985
5306
|
}
|
|
4986
5307
|
|
|
4987
5308
|
// src/LayoutTemplatePreview.client.tsx
|
|
4988
|
-
import { useGdsTranslation as
|
|
4989
|
-
import { useMemo as useMemo14, useState as
|
|
5309
|
+
import { useGdsTranslation as useGdsTranslation27 } from "@sovereignsquad/gds-theme";
|
|
5310
|
+
import { useMemo as useMemo14, useState as useState21 } from "react";
|
|
4990
5311
|
import { Alert as Alert3, Button as Button14, Group as Group21, NativeSelect as NativeSelect2, Stack as Stack17, Text as Text23, Textarea } from "@mantine/core";
|
|
4991
|
-
import { jsx as
|
|
5312
|
+
import { jsx as jsx36, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
4992
5313
|
function templateText(template) {
|
|
4993
5314
|
return JSON.stringify(template.schema, null, 2);
|
|
4994
5315
|
}
|
|
@@ -5001,16 +5322,16 @@ function GdsLayoutTemplatePreview({
|
|
|
5001
5322
|
title: titleProp,
|
|
5002
5323
|
description: descriptionProp
|
|
5003
5324
|
}) {
|
|
5004
|
-
const { t } =
|
|
5325
|
+
const { t } = useGdsTranslation27();
|
|
5005
5326
|
const title = titleProp ?? t("gds.layoutTemplatePreview.title", "Template cookbook");
|
|
5006
5327
|
const description = descriptionProp ?? t("gds.layoutTemplatePreview.description", "Pick a template, edit JSON, then apply to preview live diagnostics and rendered layout.");
|
|
5007
5328
|
const initialTemplate = templates.find((template) => template.id === initialTemplateId) ?? templates[0];
|
|
5008
5329
|
const initialText = initialTemplate ? templateText(initialTemplate) : '{\n "version": "1",\n "blocks": []\n}';
|
|
5009
|
-
const [selectedTemplateId, setSelectedTemplateId] =
|
|
5010
|
-
const [schemaText, setSchemaText] =
|
|
5011
|
-
const [appliedSchemaText, setAppliedSchemaText] =
|
|
5012
|
-
const [editorError, setEditorError] =
|
|
5013
|
-
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");
|
|
5014
5335
|
const selectedTemplate = templates.find((template) => template.id === selectedTemplateId);
|
|
5015
5336
|
const renderedTemplate = useMemo14(() => {
|
|
5016
5337
|
try {
|
|
@@ -5018,7 +5339,7 @@ function GdsLayoutTemplatePreview({
|
|
|
5018
5339
|
} catch {
|
|
5019
5340
|
return {
|
|
5020
5341
|
issues: [{ blockId: "schema", message: "Unable to parse schema JSON. Make sure the payload is valid JSON." }],
|
|
5021
|
-
node: /* @__PURE__ */
|
|
5342
|
+
node: /* @__PURE__ */ jsx36(
|
|
5022
5343
|
StateBlock,
|
|
5023
5344
|
{
|
|
5024
5345
|
variant: "error",
|
|
@@ -5067,8 +5388,8 @@ function GdsLayoutTemplatePreview({
|
|
|
5067
5388
|
}
|
|
5068
5389
|
};
|
|
5069
5390
|
const issueCount = renderedTemplate.issues.length;
|
|
5070
|
-
return /* @__PURE__ */
|
|
5071
|
-
/* @__PURE__ */
|
|
5391
|
+
return /* @__PURE__ */ jsx36(SectionPanel, { title, description, children: /* @__PURE__ */ jsxs26(Stack17, { gap: "md", children: [
|
|
5392
|
+
/* @__PURE__ */ jsx36(
|
|
5072
5393
|
NativeSelect2,
|
|
5073
5394
|
{
|
|
5074
5395
|
label: "Template preset",
|
|
@@ -5078,7 +5399,7 @@ function GdsLayoutTemplatePreview({
|
|
|
5078
5399
|
data: templates.map((template) => ({ value: template.id, label: template.title }))
|
|
5079
5400
|
}
|
|
5080
5401
|
),
|
|
5081
|
-
/* @__PURE__ */
|
|
5402
|
+
/* @__PURE__ */ jsx36(
|
|
5082
5403
|
Textarea,
|
|
5083
5404
|
{
|
|
5084
5405
|
label: "Current template summary",
|
|
@@ -5089,7 +5410,7 @@ Use case: ${selectedTemplate.useCase}` : "",
|
|
|
5089
5410
|
minRows: 2
|
|
5090
5411
|
}
|
|
5091
5412
|
),
|
|
5092
|
-
/* @__PURE__ */
|
|
5413
|
+
/* @__PURE__ */ jsx36(
|
|
5093
5414
|
Textarea,
|
|
5094
5415
|
{
|
|
5095
5416
|
label: "Layout schema JSON",
|
|
@@ -5100,19 +5421,19 @@ Use case: ${selectedTemplate.useCase}` : "",
|
|
|
5100
5421
|
onChange: (event) => setSchemaText(event.currentTarget.value)
|
|
5101
5422
|
}
|
|
5102
5423
|
),
|
|
5103
|
-
/* @__PURE__ */
|
|
5104
|
-
/* @__PURE__ */
|
|
5105
|
-
/* @__PURE__ */
|
|
5106
|
-
/* @__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" })
|
|
5107
5428
|
] }),
|
|
5108
|
-
editorError ? /* @__PURE__ */
|
|
5109
|
-
copyState === "success" ? /* @__PURE__ */
|
|
5110
|
-
copyState === "error" ? /* @__PURE__ */
|
|
5111
|
-
/* @__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: [
|
|
5112
5433
|
"Diagnostic result: ",
|
|
5113
5434
|
issueCount === 0 ? "no issues" : `${issueCount} issue${issueCount === 1 ? "" : "s"}`
|
|
5114
5435
|
] }),
|
|
5115
|
-
/* @__PURE__ */
|
|
5436
|
+
/* @__PURE__ */ jsx36(
|
|
5116
5437
|
SectionPanel,
|
|
5117
5438
|
{
|
|
5118
5439
|
title: `Schema render preview (${selectedTemplate?.schema.version ?? "1"})`,
|
|
@@ -5120,7 +5441,7 @@ Use case: ${selectedTemplate.useCase}` : "",
|
|
|
5120
5441
|
children: renderedTemplate.node
|
|
5121
5442
|
}
|
|
5122
5443
|
),
|
|
5123
|
-
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: [
|
|
5124
5445
|
issue.blockId ? `${issue.blockId}: ` : "",
|
|
5125
5446
|
issue.message
|
|
5126
5447
|
] }, `${issue.blockId ?? "schema"}-${index}`)) }) }) : null
|
|
@@ -5129,7 +5450,7 @@ Use case: ${selectedTemplate.useCase}` : "",
|
|
|
5129
5450
|
|
|
5130
5451
|
// src/Telemetry.client.tsx
|
|
5131
5452
|
import { createContext as createContext9, useContext as useContext9, useMemo as useMemo15 } from "react";
|
|
5132
|
-
import { jsx as
|
|
5453
|
+
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
5133
5454
|
var gdsOperationalEventTypes = [
|
|
5134
5455
|
"submit",
|
|
5135
5456
|
"submit_success",
|
|
@@ -5352,7 +5673,7 @@ function GdsTelemetryProvider({
|
|
|
5352
5673
|
emit: (event) => emitGdsEvent({ adapter, sink, sampleRate, payloadPolicy, onAdapterError }, event),
|
|
5353
5674
|
emitGdsEvent: (event) => emitGdsEvent({ adapter, sink, sampleRate, payloadPolicy, onAdapterError }, event)
|
|
5354
5675
|
}), [adapter, onAdapterError, payloadPolicy, sampleRate, sink]);
|
|
5355
|
-
return /* @__PURE__ */
|
|
5676
|
+
return /* @__PURE__ */ jsx37(GdsTelemetryContext.Provider, { value, children });
|
|
5356
5677
|
}
|
|
5357
5678
|
function useGdsTelemetry() {
|
|
5358
5679
|
const context = useContext9(GdsTelemetryContext);
|
|
@@ -5364,7 +5685,7 @@ function useGdsTelemetry() {
|
|
|
5364
5685
|
|
|
5365
5686
|
// src/PublicCaptureFlow.tsx
|
|
5366
5687
|
import { Stack as Stack18, Text as Text24 } from "@mantine/core";
|
|
5367
|
-
import { jsx as
|
|
5688
|
+
import { jsx as jsx38, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
5368
5689
|
var stageCopy = {
|
|
5369
5690
|
identify: { title: "Who are you?", description: "Enter the information required for this public flow." },
|
|
5370
5691
|
consent: { title: "Review consent", description: "Confirm the required consent before continuing." },
|
|
@@ -5383,10 +5704,10 @@ function toFlowStatus(state) {
|
|
|
5383
5704
|
}
|
|
5384
5705
|
function runtimeStateBody(state) {
|
|
5385
5706
|
if (state === "permission-denied") {
|
|
5386
|
-
return /* @__PURE__ */
|
|
5707
|
+
return /* @__PURE__ */ jsx38(StateBlock, { variant: "permission", title: "Permission required", description: "Allow access or use the provided recovery action to continue." });
|
|
5387
5708
|
}
|
|
5388
5709
|
if (state === "hardware-unavailable") {
|
|
5389
|
-
return /* @__PURE__ */
|
|
5710
|
+
return /* @__PURE__ */ jsx38(StateBlock, { variant: "error", title: "Capture unavailable", description: "The required hardware surface is not available on this device." });
|
|
5390
5711
|
}
|
|
5391
5712
|
return null;
|
|
5392
5713
|
}
|
|
@@ -5404,8 +5725,8 @@ function PublicCaptureFlow({
|
|
|
5404
5725
|
}) {
|
|
5405
5726
|
const copy = stageCopy[stage];
|
|
5406
5727
|
const runtimeBody = runtimeStateBody(state);
|
|
5407
|
-
const flowBody = runtimeBody ?? (stage === "share" && share ? /* @__PURE__ */
|
|
5408
|
-
return /* @__PURE__ */
|
|
5728
|
+
const flowBody = runtimeBody ?? (stage === "share" && share ? /* @__PURE__ */ jsx38(PublicShareOverlay, { ...share }) : body);
|
|
5729
|
+
return /* @__PURE__ */ jsx38(
|
|
5409
5730
|
PublicFlowShell,
|
|
5410
5731
|
{
|
|
5411
5732
|
exitAction,
|
|
@@ -5423,34 +5744,34 @@ function PublicCaptureFlow({
|
|
|
5423
5744
|
);
|
|
5424
5745
|
}
|
|
5425
5746
|
function PublicIdentityStep({ children }) {
|
|
5426
|
-
return /* @__PURE__ */
|
|
5747
|
+
return /* @__PURE__ */ jsx38(Stack18, { gap: "md", children });
|
|
5427
5748
|
}
|
|
5428
5749
|
function PublicConsentStep({ consentText, control }) {
|
|
5429
|
-
return /* @__PURE__ */
|
|
5430
|
-
/* @__PURE__ */
|
|
5750
|
+
return /* @__PURE__ */ jsxs27(Stack18, { gap: "md", children: [
|
|
5751
|
+
/* @__PURE__ */ jsx38(Text24, { children: consentText }),
|
|
5431
5752
|
control
|
|
5432
5753
|
] });
|
|
5433
5754
|
}
|
|
5434
5755
|
function PublicAcceptStep({ preview, actions }) {
|
|
5435
|
-
return /* @__PURE__ */
|
|
5756
|
+
return /* @__PURE__ */ jsxs27(Stack18, { gap: "md", children: [
|
|
5436
5757
|
preview,
|
|
5437
5758
|
actions
|
|
5438
5759
|
] });
|
|
5439
5760
|
}
|
|
5440
5761
|
function PublicCtaStep({ children }) {
|
|
5441
|
-
return /* @__PURE__ */
|
|
5762
|
+
return /* @__PURE__ */ jsx38(Stack18, { gap: "md", children });
|
|
5442
5763
|
}
|
|
5443
5764
|
function PublicRestartStep({ children }) {
|
|
5444
|
-
return /* @__PURE__ */
|
|
5765
|
+
return /* @__PURE__ */ jsx38(Stack18, { gap: "md", children });
|
|
5445
5766
|
}
|
|
5446
5767
|
function PublicShareOverlay(props) {
|
|
5447
|
-
return /* @__PURE__ */
|
|
5768
|
+
return /* @__PURE__ */ jsx38(ShareButtonGroup, { ...props });
|
|
5448
5769
|
}
|
|
5449
5770
|
|
|
5450
5771
|
// src/PlaybackControls.client.tsx
|
|
5451
|
-
import { useEffect as
|
|
5772
|
+
import { useEffect as useEffect11 } from "react";
|
|
5452
5773
|
import { ActionIcon as ActionIcon4, Group as Group22, Text as Text25 } from "@mantine/core";
|
|
5453
|
-
import { jsx as
|
|
5774
|
+
import { jsx as jsx39, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
5454
5775
|
function isInteractiveTarget(target) {
|
|
5455
5776
|
if (!(target instanceof HTMLElement)) return false;
|
|
5456
5777
|
return ["INPUT", "TEXTAREA", "SELECT", "BUTTON", "A"].includes(target.tagName) || target.isContentEditable;
|
|
@@ -5462,7 +5783,7 @@ function usePlaybackKeyboardControls({
|
|
|
5462
5783
|
onPrevious,
|
|
5463
5784
|
onFullscreenToggle
|
|
5464
5785
|
}) {
|
|
5465
|
-
|
|
5786
|
+
useEffect11(() => {
|
|
5466
5787
|
if (!enabled) return void 0;
|
|
5467
5788
|
const handler = (event) => {
|
|
5468
5789
|
if (event.defaultPrevented || isInteractiveTarget(event.target)) return;
|
|
@@ -5494,25 +5815,25 @@ function PlaybackControls({
|
|
|
5494
5815
|
}) {
|
|
5495
5816
|
const playing = state === "playing";
|
|
5496
5817
|
const disabled = state === "loading" || state === "empty" || state === "error";
|
|
5497
|
-
return /* @__PURE__ */
|
|
5498
|
-
/* @__PURE__ */
|
|
5499
|
-
/* @__PURE__ */
|
|
5500
|
-
/* @__PURE__ */
|
|
5501
|
-
onRestart ? /* @__PURE__ */
|
|
5502
|
-
onFullscreenChange ? /* @__PURE__ */
|
|
5503
|
-
/* @__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 })
|
|
5504
5825
|
] });
|
|
5505
5826
|
}
|
|
5506
5827
|
function PlaybackOverlayControls(props) {
|
|
5507
|
-
return /* @__PURE__ */
|
|
5828
|
+
return /* @__PURE__ */ jsx39(PlaybackControls, { ...props });
|
|
5508
5829
|
}
|
|
5509
5830
|
|
|
5510
5831
|
// src/GdsPageTemplates.client.tsx
|
|
5511
|
-
import { useEffect as
|
|
5832
|
+
import { useEffect as useEffect12, useId as useId2, useRef as useRef12 } from "react";
|
|
5512
5833
|
import { Box as Box11, Button as Button15, Grid, Title as Title3 } from "@mantine/core";
|
|
5513
5834
|
import { useMediaQuery as useMediaQuery3, useUncontrolled as useUncontrolled3 } from "@mantine/hooks";
|
|
5514
|
-
import { useGdsTranslation as
|
|
5515
|
-
import { jsx as
|
|
5835
|
+
import { useGdsTranslation as useGdsTranslation28 } from "@sovereignsquad/gds-theme";
|
|
5836
|
+
import { jsx as jsx40, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
5516
5837
|
function GdsAssetManagerTemplate({
|
|
5517
5838
|
state = "ready",
|
|
5518
5839
|
tree,
|
|
@@ -5530,24 +5851,24 @@ function GdsAssetManagerTemplate({
|
|
|
5530
5851
|
retryLabel,
|
|
5531
5852
|
...props
|
|
5532
5853
|
}) {
|
|
5533
|
-
const { t } =
|
|
5854
|
+
const { t } = useGdsTranslation28();
|
|
5534
5855
|
const [view, setView] = useUncontrolled3({ value: viewProp, defaultValue: defaultView, finalValue: "table", onChange: onViewChange });
|
|
5535
5856
|
const items = table && grid ? view === "grid" ? grid : table : table ?? grid;
|
|
5536
|
-
return /* @__PURE__ */
|
|
5857
|
+
return /* @__PURE__ */ jsx40(GdsShapeScope, { profile: shapeProfile, children: /* @__PURE__ */ jsx40(PageTemplateFrame, { id: "asset-manager", state, ...props, children: /* @__PURE__ */ jsx40(
|
|
5537
5858
|
TemplateStateGate,
|
|
5538
5859
|
{
|
|
5539
5860
|
state,
|
|
5540
5861
|
onRetry,
|
|
5541
5862
|
retryLabel,
|
|
5542
|
-
successContent: /* @__PURE__ */
|
|
5543
|
-
tree ? /* @__PURE__ */
|
|
5544
|
-
/* @__PURE__ */
|
|
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: [
|
|
5545
5866
|
toolbar,
|
|
5546
|
-
bulkActions ? /* @__PURE__ */
|
|
5547
|
-
table && grid ? /* @__PURE__ */
|
|
5548
|
-
items ?? /* @__PURE__ */
|
|
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") }),
|
|
5549
5870
|
upload,
|
|
5550
|
-
detail ? /* @__PURE__ */
|
|
5871
|
+
detail ? /* @__PURE__ */ jsx40(SectionPanel, { titleOrder: 2, title: t("gds.assetManagerTemplate.detailTitle", "Selected item"), children: detail }) : null
|
|
5551
5872
|
] }) })
|
|
5552
5873
|
] })
|
|
5553
5874
|
}
|
|
@@ -5567,54 +5888,54 @@ function GdsWorkspaceInboxTemplate({
|
|
|
5567
5888
|
retryLabel,
|
|
5568
5889
|
...props
|
|
5569
5890
|
}) {
|
|
5570
|
-
const { t } =
|
|
5891
|
+
const { t } = useGdsTranslation28();
|
|
5571
5892
|
const narrow = useMediaQuery3("(max-width: 48em)");
|
|
5572
5893
|
const headingId = useId2();
|
|
5573
|
-
const headingRef =
|
|
5574
|
-
|
|
5894
|
+
const headingRef = useRef12(null);
|
|
5895
|
+
useEffect12(() => {
|
|
5575
5896
|
if (narrow && hasSelection) headingRef.current?.focus();
|
|
5576
5897
|
}, [narrow, hasSelection]);
|
|
5577
5898
|
const scroll = regionHeight ? { maxBlockSize: regionHeight, overflowY: "auto" } : void 0;
|
|
5578
5899
|
const conversationsLabel = t("gds.workspaceInboxTemplate.conversations", "Conversations");
|
|
5579
5900
|
const title = detailTitle ?? t("gds.workspaceInboxTemplate.conversation", "Conversation");
|
|
5580
|
-
const listRegion = /* @__PURE__ */
|
|
5581
|
-
const detailRegion = /* @__PURE__ */
|
|
5582
|
-
narrow && hasSelection && onBack ? /* @__PURE__ */
|
|
5583
|
-
/* @__PURE__ */
|
|
5584
|
-
detailLoading ? /* @__PURE__ */
|
|
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") })
|
|
5585
5906
|
] }) });
|
|
5586
|
-
return /* @__PURE__ */
|
|
5907
|
+
return /* @__PURE__ */ jsx40(PageTemplateFrame, { id: "workspace-inbox", state, ...props, children: /* @__PURE__ */ jsx40(
|
|
5587
5908
|
TemplateStateGate,
|
|
5588
5909
|
{
|
|
5589
5910
|
state,
|
|
5590
5911
|
onRetry,
|
|
5591
5912
|
retryLabel,
|
|
5592
|
-
successContent: narrow ? hasSelection ? detailRegion : /* @__PURE__ */
|
|
5593
|
-
navigation ? /* @__PURE__ */
|
|
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,
|
|
5594
5915
|
listRegion
|
|
5595
|
-
] }) : /* @__PURE__ */
|
|
5596
|
-
navigation ? /* @__PURE__ */
|
|
5597
|
-
/* @__PURE__ */
|
|
5598
|
-
/* @__PURE__ */
|
|
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 })
|
|
5599
5920
|
] })
|
|
5600
5921
|
}
|
|
5601
5922
|
) });
|
|
5602
5923
|
}
|
|
5603
5924
|
|
|
5604
5925
|
// src/TrustLayer.client.tsx
|
|
5605
|
-
import { useRef as
|
|
5926
|
+
import { useRef as useRef13, useState as useState22 } from "react";
|
|
5606
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";
|
|
5607
|
-
import { useGdsTranslation as
|
|
5608
|
-
import { Fragment as
|
|
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";
|
|
5609
5930
|
var ROLE_SUCCESS = "var(--gds-state-success, var(--mantine-color-green-7))";
|
|
5610
5931
|
var ROLE_WARNING = "var(--gds-state-warning, var(--mantine-color-yellow-8))";
|
|
5611
5932
|
var ROLE_META = "var(--gds-text-meta, var(--gds-vibe-muted, var(--mantine-color-gray-7)))";
|
|
5612
5933
|
var ROLE_WARNING_TINT_BG = "var(--gds-badge-soft-warning, var(--mantine-color-yellow-0))";
|
|
5613
5934
|
var ROLE_WARNING_TINT_FG = "var(--gds-badge-soft-warning-fg, var(--mantine-color-yellow-9))";
|
|
5614
5935
|
function ReportOutdatedLink({ onReport, label }) {
|
|
5615
|
-
const { t } =
|
|
5616
|
-
const [sent, setSent] =
|
|
5617
|
-
const sentRef =
|
|
5936
|
+
const { t } = useGdsTranslation29();
|
|
5937
|
+
const [sent, setSent] = useState22(false);
|
|
5938
|
+
const sentRef = useRef13(false);
|
|
5618
5939
|
const actionLabel = label ?? t("gds.trust.report.action", "Report outdated info");
|
|
5619
5940
|
const thanksText = t("gds.trust.report.thanks", "Thanks \u2014 we'll re-check this listing.");
|
|
5620
5941
|
const handleActivate = () => {
|
|
@@ -5623,25 +5944,25 @@ function ReportOutdatedLink({ onReport, label }) {
|
|
|
5623
5944
|
setSent(true);
|
|
5624
5945
|
onReport?.();
|
|
5625
5946
|
};
|
|
5626
|
-
return /* @__PURE__ */
|
|
5627
|
-
sent ? /* @__PURE__ */
|
|
5947
|
+
return /* @__PURE__ */ jsxs30(Fragment8, { children: [
|
|
5948
|
+
sent ? /* @__PURE__ */ jsx41(Text26, { component: "span", size: "sm", fw: 600, c: ROLE_SUCCESS, children: thanksText }) : /* @__PURE__ */ jsx41(
|
|
5628
5949
|
Button16,
|
|
5629
5950
|
{
|
|
5630
5951
|
type: "button",
|
|
5631
5952
|
variant: "subtle",
|
|
5632
5953
|
color: "gray",
|
|
5633
5954
|
size: "sm",
|
|
5634
|
-
leftSection: /* @__PURE__ */
|
|
5955
|
+
leftSection: /* @__PURE__ */ jsx41(GdsIcon, { icon: "Flag", size: "xs" }),
|
|
5635
5956
|
onClick: handleActivate,
|
|
5636
5957
|
styles: { root: { minHeight: `${GDS_MIN_TARGET_PX}px` } },
|
|
5637
5958
|
children: actionLabel
|
|
5638
5959
|
}
|
|
5639
5960
|
),
|
|
5640
|
-
/* @__PURE__ */
|
|
5961
|
+
/* @__PURE__ */ jsx41(VisuallyHidden6, { role: "status", "aria-live": "polite", "aria-atomic": "true", children: sent ? thanksText : "" })
|
|
5641
5962
|
] });
|
|
5642
5963
|
}
|
|
5643
5964
|
function useSourceRowStatusLabels() {
|
|
5644
|
-
const { t } =
|
|
5965
|
+
const { t } = useGdsTranslation29();
|
|
5645
5966
|
return {
|
|
5646
5967
|
estimate: t("gds.trust.source.statusEstimate", "Estimate"),
|
|
5647
5968
|
confirmed: t("gds.trust.source.statusConfirmed", "Confirmed"),
|
|
@@ -5652,7 +5973,7 @@ function sourceRowStatusRole(status) {
|
|
|
5652
5973
|
return status === "confirmed" ? ROLE_SUCCESS : ROLE_WARNING;
|
|
5653
5974
|
}
|
|
5654
5975
|
function SourceBlockRow({ label, children }) {
|
|
5655
|
-
return /* @__PURE__ */
|
|
5976
|
+
return /* @__PURE__ */ jsxs30(
|
|
5656
5977
|
Group23,
|
|
5657
5978
|
{
|
|
5658
5979
|
justify: "space-between",
|
|
@@ -5662,41 +5983,41 @@ function SourceBlockRow({ label, children }) {
|
|
|
5662
5983
|
py: 4,
|
|
5663
5984
|
style: { borderTop: "1px solid var(--gds-border-card, var(--mantine-color-gray-3))" },
|
|
5664
5985
|
children: [
|
|
5665
|
-
/* @__PURE__ */
|
|
5986
|
+
/* @__PURE__ */ jsx41(Text26, { size: "sm", fw: 500, c: ROLE_META, children: label }),
|
|
5666
5987
|
children
|
|
5667
5988
|
]
|
|
5668
5989
|
}
|
|
5669
5990
|
);
|
|
5670
5991
|
}
|
|
5671
5992
|
function SourceBlock({ sourceType, sourceUrl, lastChecked, priceStatus, scheduleStatus, onReport }) {
|
|
5672
|
-
const { t } =
|
|
5993
|
+
const { t } = useGdsTranslation29();
|
|
5673
5994
|
const statusLabels = useSourceRowStatusLabels();
|
|
5674
5995
|
const unknownValue = t("gds.trust.source.unknownValue", "Unknown \u2014 confirm with provider");
|
|
5675
5996
|
let sourceTypeContent;
|
|
5676
5997
|
if (sourceUrl) {
|
|
5677
|
-
sourceTypeContent = /* @__PURE__ */
|
|
5998
|
+
sourceTypeContent = /* @__PURE__ */ jsx41(GdsInlineLink, { href: sourceUrl, external: true, children: sourceType || unknownValue });
|
|
5678
5999
|
} else if (sourceType) {
|
|
5679
|
-
sourceTypeContent = /* @__PURE__ */
|
|
6000
|
+
sourceTypeContent = /* @__PURE__ */ jsx41(Text26, { size: "sm", children: sourceType });
|
|
5680
6001
|
} else {
|
|
5681
|
-
sourceTypeContent = /* @__PURE__ */
|
|
6002
|
+
sourceTypeContent = /* @__PURE__ */ jsx41(Text26, { size: "sm", c: ROLE_META, children: unknownValue });
|
|
5682
6003
|
}
|
|
5683
|
-
return /* @__PURE__ */
|
|
5684
|
-
/* @__PURE__ */
|
|
5685
|
-
/* @__PURE__ */
|
|
5686
|
-
/* @__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") })
|
|
5687
6008
|
] }),
|
|
5688
|
-
/* @__PURE__ */
|
|
5689
|
-
/* @__PURE__ */
|
|
5690
|
-
/* @__PURE__ */
|
|
5691
|
-
/* @__PURE__ */
|
|
5692
|
-
/* @__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 }) })
|
|
5693
6014
|
] }),
|
|
5694
|
-
/* @__PURE__ */
|
|
5695
|
-
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
|
|
5696
6017
|
] }) });
|
|
5697
6018
|
}
|
|
5698
6019
|
function ConfirmChecklist({ items, title }) {
|
|
5699
|
-
const { t } =
|
|
6020
|
+
const { t } = useGdsTranslation29();
|
|
5700
6021
|
const defaultItems = [
|
|
5701
6022
|
t("gds.trust.checklist.exactSchedule", "Exact schedule"),
|
|
5702
6023
|
t("gds.trust.checklist.currentPrice", "Current price"),
|
|
@@ -5707,14 +6028,14 @@ function ConfirmChecklist({ items, title }) {
|
|
|
5707
6028
|
];
|
|
5708
6029
|
const resolvedItems = items ?? defaultItems;
|
|
5709
6030
|
const resolvedTitle = title ?? t("gds.trust.checklist.title", "Check before booking");
|
|
5710
|
-
const [checked, setChecked] =
|
|
6031
|
+
const [checked, setChecked] = useState22({});
|
|
5711
6032
|
if (resolvedItems.length === 0) {
|
|
5712
6033
|
return null;
|
|
5713
6034
|
}
|
|
5714
6035
|
const toggle = (key) => {
|
|
5715
6036
|
setChecked((current) => ({ ...current, [key]: !current[key] }));
|
|
5716
6037
|
};
|
|
5717
|
-
return /* @__PURE__ */
|
|
6038
|
+
return /* @__PURE__ */ jsx41(
|
|
5718
6039
|
Paper8,
|
|
5719
6040
|
{
|
|
5720
6041
|
withBorder: true,
|
|
@@ -5722,20 +6043,20 @@ function ConfirmChecklist({ items, title }) {
|
|
|
5722
6043
|
p: "md",
|
|
5723
6044
|
"data-gds-confirm-checklist": "",
|
|
5724
6045
|
style: { background: ROLE_WARNING_TINT_BG, borderColor: "var(--gds-state-warning, var(--mantine-color-yellow-6))" },
|
|
5725
|
-
children: /* @__PURE__ */
|
|
5726
|
-
/* @__PURE__ */
|
|
5727
|
-
/* @__PURE__ */
|
|
5728
|
-
/* @__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 })
|
|
5729
6050
|
] }),
|
|
5730
|
-
/* @__PURE__ */
|
|
6051
|
+
/* @__PURE__ */ jsx41(Stack19, { gap: "xs", mt: "sm", children: resolvedItems.map((item, index) => {
|
|
5731
6052
|
const key = `${index}:${item}`;
|
|
5732
6053
|
const isChecked = Boolean(checked[key]);
|
|
5733
|
-
return /* @__PURE__ */
|
|
6054
|
+
return /* @__PURE__ */ jsx41(Group23, { wrap: "nowrap", align: "center", gap: "xs", style: { minHeight: `${GDS_MIN_TARGET_PX}px` }, children: /* @__PURE__ */ jsx41(
|
|
5734
6055
|
Checkbox4,
|
|
5735
6056
|
{
|
|
5736
6057
|
checked: isChecked,
|
|
5737
6058
|
onChange: () => toggle(key),
|
|
5738
|
-
label: /* @__PURE__ */
|
|
6059
|
+
label: /* @__PURE__ */ jsx41(
|
|
5739
6060
|
Text26,
|
|
5740
6061
|
{
|
|
5741
6062
|
component: "span",
|
|
@@ -5753,10 +6074,10 @@ function ConfirmChecklist({ items, title }) {
|
|
|
5753
6074
|
}
|
|
5754
6075
|
|
|
5755
6076
|
// src/HeroSearchPanel.client.tsx
|
|
5756
|
-
import { useState as
|
|
6077
|
+
import { useState as useState23 } from "react";
|
|
5757
6078
|
import { Box as Box12, Button as Button17, TextInput as TextInput4 } from "@mantine/core";
|
|
5758
|
-
import { useGdsTranslation as
|
|
5759
|
-
import { jsx as
|
|
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";
|
|
5760
6081
|
var GDS_HERO_SEARCH_FIELD_FLEX_BASIS_PX = 120;
|
|
5761
6082
|
var GDS_HERO_SEARCH_FIELD_MIN_WIDTH_PX = 110;
|
|
5762
6083
|
function dedupeHeroSearchFields(fields) {
|
|
@@ -5793,10 +6114,10 @@ function HeroSearchPanel({
|
|
|
5793
6114
|
ariaLabel: ariaLabelProp,
|
|
5794
6115
|
disabled = false
|
|
5795
6116
|
}) {
|
|
5796
|
-
const { t } =
|
|
6117
|
+
const { t } = useGdsTranslation30();
|
|
5797
6118
|
const ariaLabel = ariaLabelProp ?? t("gds.heroSearchPanel.ariaLabel", "Search");
|
|
5798
6119
|
const controlled = values !== void 0;
|
|
5799
|
-
const [internalValues, setInternalValues] =
|
|
6120
|
+
const [internalValues, setInternalValues] = useState23(defaultValues ?? {});
|
|
5800
6121
|
const currentValues = controlled ? values : internalValues;
|
|
5801
6122
|
const edit = (key, value) => {
|
|
5802
6123
|
const next = { ...currentValues, [key]: value };
|
|
@@ -5813,16 +6134,16 @@ function HeroSearchPanel({
|
|
|
5813
6134
|
const renderedFields = dedupeHeroSearchFields(fields);
|
|
5814
6135
|
const showSecondaryAction = Boolean(secondaryActionLabel && onSecondaryAction);
|
|
5815
6136
|
const primaryVocabularyPacks = primaryActionLabel ? [createGdsVocabularyPack("heroSearchPanel", { primary: { defaultMessage: primaryActionLabel, icon: GdsIcons.Search } })] : void 0;
|
|
5816
|
-
return /* @__PURE__ */
|
|
5817
|
-
renderedFields.length > 0 ? /* @__PURE__ */
|
|
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(
|
|
5818
6139
|
Box12,
|
|
5819
6140
|
{
|
|
5820
6141
|
style: {
|
|
5821
6142
|
flex: `1 1 ${GDS_HERO_SEARCH_FIELD_FLEX_BASIS_PX}px`,
|
|
5822
6143
|
minWidth: `${GDS_HERO_SEARCH_FIELD_MIN_WIDTH_PX}px`,
|
|
5823
|
-
overflowWrap: "
|
|
6144
|
+
overflowWrap: "break-word"
|
|
5824
6145
|
},
|
|
5825
|
-
children: /* @__PURE__ */
|
|
6146
|
+
children: /* @__PURE__ */ jsx42(FormField, { label: field.label, children: /* @__PURE__ */ jsx42(
|
|
5826
6147
|
TextInput4,
|
|
5827
6148
|
{
|
|
5828
6149
|
value: currentValues[field.key] ?? "",
|
|
@@ -5835,8 +6156,8 @@ function HeroSearchPanel({
|
|
|
5835
6156
|
},
|
|
5836
6157
|
field.key
|
|
5837
6158
|
)) }) : null,
|
|
5838
|
-
/* @__PURE__ */
|
|
5839
|
-
/* @__PURE__ */
|
|
6159
|
+
/* @__PURE__ */ jsxs31(GdsInline, { gap: "sm", wrap: "wrap", children: [
|
|
6160
|
+
/* @__PURE__ */ jsx42(
|
|
5840
6161
|
SemanticButton,
|
|
5841
6162
|
{
|
|
5842
6163
|
action: primaryActionLabel ? "heroSearchPanel:primary" : "search",
|
|
@@ -5845,17 +6166,17 @@ function HeroSearchPanel({
|
|
|
5845
6166
|
vocabularyPacks: primaryVocabularyPacks
|
|
5846
6167
|
}
|
|
5847
6168
|
),
|
|
5848
|
-
showSecondaryAction ? /* @__PURE__ */
|
|
6169
|
+
showSecondaryAction ? /* @__PURE__ */ jsx42(Button17, { type: "button", variant: "default", disabled, onClick: onSecondaryAction, children: secondaryActionLabel }) : null
|
|
5849
6170
|
] }),
|
|
5850
|
-
trustLine ? /* @__PURE__ */
|
|
6171
|
+
trustLine ? /* @__PURE__ */ jsx42(MetadataText, { children: trustLine }) : null
|
|
5851
6172
|
] }) });
|
|
5852
6173
|
}
|
|
5853
6174
|
|
|
5854
6175
|
// src/KanbanBoard.client.tsx
|
|
5855
|
-
import { useEffect as
|
|
6176
|
+
import { useEffect as useEffect13, useId as useId3, useRef as useRef14, useState as useState24 } from "react";
|
|
5856
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";
|
|
5857
6178
|
import { useMediaQuery as useMediaQuery4 } from "@mantine/hooks";
|
|
5858
|
-
import { useGdsTranslation as
|
|
6179
|
+
import { useGdsTranslation as useGdsTranslation31 } from "@sovereignsquad/gds-theme";
|
|
5859
6180
|
import {
|
|
5860
6181
|
DndContext,
|
|
5861
6182
|
DragOverlay,
|
|
@@ -5868,7 +6189,7 @@ import {
|
|
|
5868
6189
|
} from "@dnd-kit/core";
|
|
5869
6190
|
import { SortableContext, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
5870
6191
|
import { CSS as CSS2 } from "@dnd-kit/utilities";
|
|
5871
|
-
import { Fragment as
|
|
6192
|
+
import { Fragment as Fragment9, jsx as jsx43, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
5872
6193
|
function useGdsKanbanOrientation({
|
|
5873
6194
|
stackedBreakpoint = "xs"
|
|
5874
6195
|
} = {}) {
|
|
@@ -5877,12 +6198,12 @@ function useGdsKanbanOrientation({
|
|
|
5877
6198
|
return isPortrait && isNarrow ? "stacked" : "columns";
|
|
5878
6199
|
}
|
|
5879
6200
|
function DragGripGlyph() {
|
|
5880
|
-
return /* @__PURE__ */
|
|
5881
|
-
(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}`))
|
|
5882
6203
|
) });
|
|
5883
6204
|
}
|
|
5884
6205
|
function ColumnDisclosureGlyph({ collapsed }) {
|
|
5885
|
-
return /* @__PURE__ */
|
|
6206
|
+
return /* @__PURE__ */ jsx43(
|
|
5886
6207
|
"svg",
|
|
5887
6208
|
{
|
|
5888
6209
|
width: "12",
|
|
@@ -5891,7 +6212,7 @@ function ColumnDisclosureGlyph({ collapsed }) {
|
|
|
5891
6212
|
"aria-hidden": "true",
|
|
5892
6213
|
focusable: "false",
|
|
5893
6214
|
style: { transform: collapsed ? "rotate(-90deg)" : "none", transition: "transform var(--gds-motion-duration-fast, 120ms) var(--gds-motion-ease-standard, ease)" },
|
|
5894
|
-
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" })
|
|
5895
6216
|
}
|
|
5896
6217
|
);
|
|
5897
6218
|
}
|
|
@@ -5900,7 +6221,7 @@ function columnTitleText(column) {
|
|
|
5900
6221
|
return column.ariaLabel ?? (typeof column.title === "string" ? column.title : column.id);
|
|
5901
6222
|
}
|
|
5902
6223
|
function KanbanCard({ item, column, columns, onMoveItem, renderItem, enableDrag, moveMenuIcon, moveMenuLabel }) {
|
|
5903
|
-
const { t } =
|
|
6224
|
+
const { t } = useGdsTranslation31();
|
|
5904
6225
|
const moveTargets = columns.filter((candidate) => candidate.id !== column.id);
|
|
5905
6226
|
const accessibleName = item.ariaLabel ?? (typeof item.title === "string" ? item.title : void 0);
|
|
5906
6227
|
const moveVerb = moveMenuLabel ?? t("gds.kanban.moveItem", "Move");
|
|
@@ -5912,7 +6233,7 @@ function KanbanCard({ item, column, columns, onMoveItem, renderItem, enableDrag,
|
|
|
5912
6233
|
transition: sortable.transition,
|
|
5913
6234
|
opacity: sortable.isDragging ? 0.4 : 1
|
|
5914
6235
|
} : void 0;
|
|
5915
|
-
return /* @__PURE__ */
|
|
6236
|
+
return /* @__PURE__ */ jsx43(
|
|
5916
6237
|
Paper9,
|
|
5917
6238
|
{
|
|
5918
6239
|
withBorder: true,
|
|
@@ -5921,9 +6242,9 @@ function KanbanCard({ item, column, columns, onMoveItem, renderItem, enableDrag,
|
|
|
5921
6242
|
"data-gds-kanban-card": item.id,
|
|
5922
6243
|
ref: enableDrag ? sortable.setNodeRef : void 0,
|
|
5923
6244
|
style: dragStyle,
|
|
5924
|
-
children: /* @__PURE__ */
|
|
5925
|
-
/* @__PURE__ */
|
|
5926
|
-
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(
|
|
5927
6248
|
ActionIcon5,
|
|
5928
6249
|
{
|
|
5929
6250
|
variant: "subtle",
|
|
@@ -5935,23 +6256,23 @@ function KanbanCard({ item, column, columns, onMoveItem, renderItem, enableDrag,
|
|
|
5935
6256
|
style: { cursor: "grab", touchAction: "none", flexShrink: 0 },
|
|
5936
6257
|
...sortable.listeners,
|
|
5937
6258
|
...sortable.attributes,
|
|
5938
|
-
children: /* @__PURE__ */
|
|
6259
|
+
children: /* @__PURE__ */ jsx43(DragGripGlyph, {})
|
|
5939
6260
|
}
|
|
5940
6261
|
) : null,
|
|
5941
|
-
/* @__PURE__ */
|
|
5942
|
-
typeof item.title === "string" ? /* @__PURE__ */
|
|
5943
|
-
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
|
|
5944
6265
|
] }) }),
|
|
5945
|
-
onMoveItem && moveTargets.length > 0 ? /* @__PURE__ */
|
|
5946
|
-
/* @__PURE__ */
|
|
5947
|
-
/* @__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: [
|
|
5948
6269
|
t("gds.kanban.moveTo", "Move to"),
|
|
5949
6270
|
" ",
|
|
5950
6271
|
target.title
|
|
5951
6272
|
] }, target.id)) })
|
|
5952
6273
|
] }) : null
|
|
5953
6274
|
] }),
|
|
5954
|
-
item.status ? /* @__PURE__ */
|
|
6275
|
+
item.status ? /* @__PURE__ */ jsx43(Badge3, { variant: "light", size: "sm", children: item.status }) : null
|
|
5955
6276
|
] })
|
|
5956
6277
|
}
|
|
5957
6278
|
);
|
|
@@ -5972,10 +6293,10 @@ function KanbanColumn({
|
|
|
5972
6293
|
collapsed,
|
|
5973
6294
|
onCollapsedChange
|
|
5974
6295
|
}) {
|
|
5975
|
-
const { t } =
|
|
6296
|
+
const { t } = useGdsTranslation31();
|
|
5976
6297
|
const droppable = useDroppable({ id: column.id, disabled: !enableDrag });
|
|
5977
6298
|
const isControlledCollapse = collapsed !== void 0;
|
|
5978
|
-
const [internalCollapsed, setInternalCollapsed] =
|
|
6299
|
+
const [internalCollapsed, setInternalCollapsed] = useState24(false);
|
|
5979
6300
|
const resolvedCollapsed = collapsible ? isControlledCollapse ? Boolean(collapsed) : internalCollapsed : false;
|
|
5980
6301
|
const bodyId = useId3();
|
|
5981
6302
|
function handleToggleCollapsed() {
|
|
@@ -5989,7 +6310,7 @@ function KanbanColumn({
|
|
|
5989
6310
|
const toggleVerb = resolvedCollapsed ? t("gds.kanban.expandColumn", "Expand column") : t("gds.kanban.collapseColumn", "Collapse column");
|
|
5990
6311
|
const toggleLabel = columnName ? `${toggleVerb}: ${columnName}` : toggleVerb;
|
|
5991
6312
|
const count = column.totalCount ?? column.items.length;
|
|
5992
|
-
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(
|
|
5993
6314
|
KanbanCard,
|
|
5994
6315
|
{
|
|
5995
6316
|
item,
|
|
@@ -6002,7 +6323,7 @@ function KanbanColumn({
|
|
|
6002
6323
|
moveMenuLabel
|
|
6003
6324
|
},
|
|
6004
6325
|
item.id
|
|
6005
|
-
)) }) : /* @__PURE__ */
|
|
6326
|
+
)) }) : /* @__PURE__ */ jsx43(
|
|
6006
6327
|
Text27,
|
|
6007
6328
|
{
|
|
6008
6329
|
size: "xs",
|
|
@@ -6013,11 +6334,11 @@ function KanbanColumn({
|
|
|
6013
6334
|
}
|
|
6014
6335
|
);
|
|
6015
6336
|
const footerNode = renderFooter ? renderFooter(column) : footer;
|
|
6016
|
-
const body = /* @__PURE__ */
|
|
6017
|
-
enableDrag ? /* @__PURE__ */
|
|
6018
|
-
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
|
|
6019
6340
|
] });
|
|
6020
|
-
return /* @__PURE__ */
|
|
6341
|
+
return /* @__PURE__ */ jsx43(
|
|
6021
6342
|
Paper9,
|
|
6022
6343
|
{
|
|
6023
6344
|
withBorder: true,
|
|
@@ -6026,10 +6347,10 @@ function KanbanColumn({
|
|
|
6026
6347
|
style: width ? { minWidth: width, flex: "0 0 auto" } : void 0,
|
|
6027
6348
|
"data-gds-kanban-column": column.id,
|
|
6028
6349
|
"data-gds-kanban-column-collapsed": collapsible && resolvedCollapsed ? "true" : void 0,
|
|
6029
|
-
children: /* @__PURE__ */
|
|
6030
|
-
/* @__PURE__ */
|
|
6031
|
-
/* @__PURE__ */
|
|
6032
|
-
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(
|
|
6033
6354
|
ActionIcon5,
|
|
6034
6355
|
{
|
|
6035
6356
|
variant: "subtle",
|
|
@@ -6041,14 +6362,14 @@ function KanbanColumn({
|
|
|
6041
6362
|
"aria-controls": bodyId,
|
|
6042
6363
|
onClick: handleToggleCollapsed,
|
|
6043
6364
|
style: { flexShrink: 0 },
|
|
6044
|
-
children: /* @__PURE__ */
|
|
6365
|
+
children: /* @__PURE__ */ jsx43(ColumnDisclosureGlyph, { collapsed: resolvedCollapsed })
|
|
6045
6366
|
}
|
|
6046
6367
|
) : null,
|
|
6047
|
-
/* @__PURE__ */
|
|
6368
|
+
/* @__PURE__ */ jsx43(Title4, { order: 4, children: column.title })
|
|
6048
6369
|
] }),
|
|
6049
|
-
/* @__PURE__ */
|
|
6370
|
+
/* @__PURE__ */ jsx43(Badge3, { variant: "light", children: count })
|
|
6050
6371
|
] }),
|
|
6051
|
-
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
|
|
6052
6373
|
] })
|
|
6053
6374
|
}
|
|
6054
6375
|
);
|
|
@@ -6078,16 +6399,16 @@ function KanbanBoard({
|
|
|
6078
6399
|
collapsedColumnIds,
|
|
6079
6400
|
onCollapsedChange
|
|
6080
6401
|
}) {
|
|
6081
|
-
const { t } =
|
|
6402
|
+
const { t } = useGdsTranslation31();
|
|
6082
6403
|
const autoOrientation = useGdsKanbanOrientation();
|
|
6083
6404
|
const resolvedOrientation = orientation === "auto" ? autoOrientation : orientation;
|
|
6084
6405
|
const regionLabel = boardLabel ?? (typeof title === "string" ? title : t("gds.kanban.boardLabel", "Kanban board"));
|
|
6085
|
-
const [activeItem, setActiveItem] =
|
|
6086
|
-
const [internalCollapsedIds, setInternalCollapsedIds] =
|
|
6406
|
+
const [activeItem, setActiveItem] = useState24(null);
|
|
6407
|
+
const [internalCollapsedIds, setInternalCollapsedIds] = useState24([]);
|
|
6087
6408
|
const isCollapseControlled = collapsedColumnIds !== void 0;
|
|
6088
6409
|
const collapsedIds = isCollapseControlled ? collapsedColumnIds : internalCollapsedIds;
|
|
6089
|
-
const viewportRef =
|
|
6090
|
-
|
|
6410
|
+
const viewportRef = useRef14(null);
|
|
6411
|
+
useEffect13(() => {
|
|
6091
6412
|
const viewport = viewportRef.current;
|
|
6092
6413
|
if (!viewport || columnPanZone !== "header" || resolvedOrientation === "stacked") {
|
|
6093
6414
|
return void 0;
|
|
@@ -6183,7 +6504,7 @@ function KanbanBoard({
|
|
|
6183
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."
|
|
6184
6505
|
)
|
|
6185
6506
|
};
|
|
6186
|
-
const columnList = (width) => columns.map((column) => /* @__PURE__ */
|
|
6507
|
+
const columnList = (width) => columns.map((column) => /* @__PURE__ */ jsx43(
|
|
6187
6508
|
KanbanColumn,
|
|
6188
6509
|
{
|
|
6189
6510
|
column,
|
|
@@ -6202,14 +6523,14 @@ function KanbanBoard({
|
|
|
6202
6523
|
},
|
|
6203
6524
|
column.id
|
|
6204
6525
|
));
|
|
6205
|
-
const board = /* @__PURE__ */
|
|
6206
|
-
title ? typeof title === "string" ? /* @__PURE__ */
|
|
6207
|
-
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) }) })
|
|
6208
6529
|
] });
|
|
6209
6530
|
if (!dragActive) {
|
|
6210
6531
|
return board;
|
|
6211
6532
|
}
|
|
6212
|
-
return /* @__PURE__ */
|
|
6533
|
+
return /* @__PURE__ */ jsxs32(
|
|
6213
6534
|
DndContext,
|
|
6214
6535
|
{
|
|
6215
6536
|
sensors,
|
|
@@ -6220,7 +6541,7 @@ function KanbanBoard({
|
|
|
6220
6541
|
onDragEnd: handleDragEnd,
|
|
6221
6542
|
children: [
|
|
6222
6543
|
board,
|
|
6223
|
-
/* @__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 })
|
|
6224
6545
|
]
|
|
6225
6546
|
}
|
|
6226
6547
|
);
|
|
@@ -6228,6 +6549,9 @@ function KanbanBoard({
|
|
|
6228
6549
|
|
|
6229
6550
|
export {
|
|
6230
6551
|
GDS_BUTTON_FEEDBACK_DURATION_MS,
|
|
6552
|
+
GDS_BUTTON_PENDING_DELAY_MS,
|
|
6553
|
+
GDS_BUTTON_PENDING_MIN_MS,
|
|
6554
|
+
GDS_BUTTON_CONFIRM_WINDOW_MS,
|
|
6231
6555
|
GDS_BUTTON_GRADIENT_TEXT_FLOOR,
|
|
6232
6556
|
GDS_BUTTON_OUTLINE_ACCENT_STROKE_PX,
|
|
6233
6557
|
SemanticButton,
|
|
@@ -6257,6 +6581,9 @@ export {
|
|
|
6257
6581
|
SidebarNavSection,
|
|
6258
6582
|
SidebarNavItem,
|
|
6259
6583
|
DocsCodeBlock,
|
|
6584
|
+
DocsCodeDisclosure,
|
|
6585
|
+
GdsTableScrollContainer,
|
|
6586
|
+
GdsReleaseNotes,
|
|
6260
6587
|
ShareButtonGroup,
|
|
6261
6588
|
UploadDropzone,
|
|
6262
6589
|
createGdsAssetAdapter,
|