@sovereignsquad/gds-core 6.9.0 → 6.11.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-BhNYAGG3.d.ts} +1285 -90
- package/dist/{QuickStartCard-DnZMDjzb.d.mts → QuickStartCard-BztqkfQK.d.mts} +1285 -90
- package/dist/{chunk-OH5HH4G3.mjs → chunk-3UYDQTAZ.mjs} +30 -5
- package/dist/{chunk-3B5MK2PG.mjs → chunk-ADNXPSGK.mjs} +978 -632
- package/dist/{chunk-IMT3UTOT.mjs → chunk-CWMDWMYL.mjs} +28 -3
- package/dist/{chunk-BD5XQH5Z.mjs → chunk-D65VHUXK.mjs} +28 -3
- package/dist/{chunk-KEYBUMOR.mjs → chunk-EYRLICSG.mjs} +30 -5
- package/dist/{chunk-A32PWTD2.mjs → chunk-FPDTLFIB.mjs} +29 -4
- package/dist/{chunk-LERXSJHD.mjs → chunk-GAPCKZGX.mjs} +31 -6
- package/dist/{chunk-MKEWYVTJ.mjs → chunk-J4TSXITU.mjs} +30 -5
- package/dist/{chunk-5G3XZWSW.mjs → chunk-MQDFB3AS.mjs} +1039 -1605
- package/dist/{chunk-WI24JME4.mjs → chunk-PCG34VRY.mjs} +12 -1
- package/dist/{chunk-F76YTG3S.mjs → chunk-PLJT4I7B.mjs} +84 -59
- package/dist/{chunk-KLFTBWEG.mjs → chunk-RBXAJJB2.mjs} +29 -4
- package/dist/{chunk-EQ7Y2PUI.mjs → chunk-RMPMU4MB.mjs} +886 -260
- package/dist/{chunk-HJVDKPVW.mjs → chunk-RSA7INLU.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-DBJE4TRO.mjs → chunk-V6SP5O4D.mjs} +66 -41
- 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 +2641 -1937
- 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 +3988 -3146
- package/dist/index.mjs +204 -61
- package/dist/locales/lazy/all.js +442 -142
- package/dist/locales/lazy/all.mjs +13 -13
- package/dist/locales/lazy/ar.js +58 -8
- 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 +59 -9
- 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 +58 -8
- package/dist/locales/lazy/it.mjs +3 -3
- package/dist/locales/lazy/ja.js +57 -7
- 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 +1537 -605
- 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 +1340 -971
- 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-MQDFB3AS.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-RMPMU4MB.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,80 @@ 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, press, children }) {
|
|
118
|
+
return /* @__PURE__ */ jsx(
|
|
119
|
+
"span",
|
|
120
|
+
{
|
|
121
|
+
"data-gds-motion": motion || press ? "" : void 0,
|
|
122
|
+
"data-gds-button-motion": motion,
|
|
123
|
+
"data-gds-button-motion-after": after,
|
|
124
|
+
"data-gds-button-press": press,
|
|
125
|
+
children
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
function ButtonIcon({ phase, motion, Icon, SuccessIcon, fromRest, pressed }) {
|
|
130
|
+
let layers;
|
|
131
|
+
if (phase === "pending") {
|
|
132
|
+
const pending = motion?.pending ?? "spinner";
|
|
133
|
+
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 }) });
|
|
134
|
+
} else if (phase === "success") {
|
|
135
|
+
const success = motion?.success;
|
|
136
|
+
if ((success === "fly-off" || success === "turn") && fromRest) {
|
|
137
|
+
layers = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
138
|
+
/* @__PURE__ */ jsx(Layer, { motion: success === "fly-off" ? "fly-off" : "turn-out", children: /* @__PURE__ */ jsx(Icon, { size: ICON_SIZE }) }),
|
|
139
|
+
/* @__PURE__ */ jsx(Layer, { motion: "pop-in", after: "exit", children: /* @__PURE__ */ jsx(IconCheck, { size: ICON_SIZE }) })
|
|
140
|
+
] });
|
|
141
|
+
} else if (success === "fly-off" || success === "turn" || success === "check-pop") {
|
|
142
|
+
layers = /* @__PURE__ */ jsx(Layer, { motion: "pop-in", children: /* @__PURE__ */ jsx(IconCheck, { size: ICON_SIZE }) });
|
|
143
|
+
} else if (success === "check-draw") {
|
|
144
|
+
layers = /* @__PURE__ */ jsx(Layer, { motion: "draw", children: /* @__PURE__ */ jsx(IconCheck, { size: ICON_SIZE }) });
|
|
145
|
+
} else if (success === "draw") {
|
|
146
|
+
layers = /* @__PURE__ */ jsx(Layer, { motion: "draw", children: /* @__PURE__ */ jsx(SuccessIcon, { size: ICON_SIZE }) });
|
|
147
|
+
} else {
|
|
148
|
+
layers = /* @__PURE__ */ jsx(Layer, { motion: "pop", children: /* @__PURE__ */ jsx(SuccessIcon, { size: ICON_SIZE }) });
|
|
149
|
+
}
|
|
150
|
+
} else if (phase === "error") {
|
|
151
|
+
layers = /* @__PURE__ */ jsx(Layer, { children: /* @__PURE__ */ jsx(IconX, { size: ICON_SIZE }) });
|
|
152
|
+
} else {
|
|
153
|
+
layers = /* @__PURE__ */ jsx(Layer, { press: pressed ? motion?.press : void 0, children: /* @__PURE__ */ jsx(Icon, { size: ICON_SIZE }) });
|
|
154
|
+
}
|
|
155
|
+
return /* @__PURE__ */ jsx("span", { "data-gds-button-icon": "", children: layers });
|
|
156
|
+
}
|
|
82
157
|
function SemanticButton({
|
|
83
158
|
action,
|
|
84
159
|
brandVariant,
|
|
85
160
|
loading,
|
|
86
161
|
feedbackState,
|
|
87
162
|
feedbackText,
|
|
163
|
+
onAction,
|
|
88
164
|
prerenderLabelOnly = true,
|
|
89
165
|
vocabularyPacks = [],
|
|
90
166
|
label: labelOverride,
|
|
@@ -98,8 +174,39 @@ function SemanticButton({
|
|
|
98
174
|
}
|
|
99
175
|
const { t } = useGdsTranslation();
|
|
100
176
|
const config = resolveSemanticActionConfig(action, vocabularyPacks);
|
|
177
|
+
const motion = config.motion;
|
|
101
178
|
const [mounted, setMounted] = useState(!prerenderLabelOnly);
|
|
102
|
-
const [
|
|
179
|
+
const [phase, setPhaseState] = useState("idle");
|
|
180
|
+
const [cycle, setCycle] = useState(0);
|
|
181
|
+
const [fromRest, setFromRest] = useState(true);
|
|
182
|
+
const [presses, setPresses] = useState(0);
|
|
183
|
+
const [pressPhase, setPressPhase] = useState(null);
|
|
184
|
+
const phaseRef = useRef("idle");
|
|
185
|
+
const timers = useRef([]);
|
|
186
|
+
const alive = useRef(true);
|
|
187
|
+
const setPhase = useCallback((next) => {
|
|
188
|
+
phaseRef.current = next;
|
|
189
|
+
setPhaseState(next);
|
|
190
|
+
if (next !== "busy" && next !== "confirm") setPressPhase(null);
|
|
191
|
+
}, []);
|
|
192
|
+
const press = useCallback((during) => {
|
|
193
|
+
setPresses((n) => n + 1);
|
|
194
|
+
setPressPhase(during);
|
|
195
|
+
}, []);
|
|
196
|
+
const clearTimers = useCallback(() => {
|
|
197
|
+
for (const timer of timers.current) clearTimeout(timer);
|
|
198
|
+
timers.current = [];
|
|
199
|
+
}, []);
|
|
200
|
+
const later = useCallback((ms, fn) => {
|
|
201
|
+
timers.current.push(setTimeout(fn, ms));
|
|
202
|
+
}, []);
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
alive.current = true;
|
|
205
|
+
return () => {
|
|
206
|
+
alive.current = false;
|
|
207
|
+
clearTimers();
|
|
208
|
+
};
|
|
209
|
+
}, [clearTimers]);
|
|
103
210
|
useEffect(() => {
|
|
104
211
|
if (prerenderLabelOnly) {
|
|
105
212
|
setMounted(true);
|
|
@@ -107,48 +214,119 @@ function SemanticButton({
|
|
|
107
214
|
}, [prerenderLabelOnly]);
|
|
108
215
|
useEffect(() => {
|
|
109
216
|
if (feedbackState) {
|
|
110
|
-
|
|
111
|
-
|
|
217
|
+
setFromRest(true);
|
|
218
|
+
setCycle((n) => n + 1);
|
|
219
|
+
setPhase(feedbackState);
|
|
220
|
+
const timer = setTimeout(() => setPhase("idle"), GDS_BUTTON_FEEDBACK_DURATION_MS);
|
|
112
221
|
return () => clearTimeout(timer);
|
|
113
222
|
}
|
|
114
|
-
}, [feedbackState]);
|
|
115
|
-
|
|
116
|
-
|
|
223
|
+
}, [feedbackState, setPhase]);
|
|
224
|
+
const { onClick, ...buttonRest } = props;
|
|
225
|
+
const handleClick = useCallback(async (event) => {
|
|
226
|
+
if (!onAction) {
|
|
227
|
+
press("idle");
|
|
228
|
+
onClick?.(event);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const current = phaseRef.current;
|
|
232
|
+
if (current === "busy" || current === "pending") {
|
|
233
|
+
event.preventDefault();
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
clearTimers();
|
|
237
|
+
if (motion?.confirm && current !== "confirm") {
|
|
238
|
+
press("confirm");
|
|
239
|
+
setPhase("confirm");
|
|
240
|
+
later(GDS_BUTTON_CONFIRM_WINDOW_MS, () => setPhase("idle"));
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
onClick?.(event);
|
|
244
|
+
press("busy");
|
|
245
|
+
setCycle((n) => n + 1);
|
|
246
|
+
setPhase("busy");
|
|
247
|
+
let shownAt = 0;
|
|
248
|
+
later(GDS_BUTTON_PENDING_DELAY_MS, () => {
|
|
249
|
+
shownAt = Date.now();
|
|
250
|
+
setPhase("pending");
|
|
251
|
+
});
|
|
252
|
+
let ok = true;
|
|
253
|
+
try {
|
|
254
|
+
await onAction();
|
|
255
|
+
} catch {
|
|
256
|
+
ok = false;
|
|
257
|
+
}
|
|
258
|
+
clearTimers();
|
|
259
|
+
if (shownAt) {
|
|
260
|
+
const remaining = GDS_BUTTON_PENDING_MIN_MS - (Date.now() - shownAt);
|
|
261
|
+
if (remaining > 0) await new Promise((resolve) => setTimeout(resolve, remaining));
|
|
262
|
+
}
|
|
263
|
+
if (!alive.current) return;
|
|
264
|
+
setFromRest(!shownAt);
|
|
265
|
+
setCycle((n) => n + 1);
|
|
266
|
+
setPhase(ok ? "success" : "error");
|
|
267
|
+
later(GDS_BUTTON_FEEDBACK_DURATION_MS, () => setPhase("idle"));
|
|
268
|
+
}, [onAction, onClick, motion?.confirm, clearTimers, later, setPhase, press]);
|
|
269
|
+
const restLabel = labelOverride ?? getSemanticActionLabel(action, t, vocabularyPacks);
|
|
270
|
+
const feedbackConfig = config.feedback ?? { icon: IconCheck, color: "teal", messageId: "gds.feedback.saved" };
|
|
271
|
+
const successLabel = feedbackText || t(feedbackConfig.messageId, "Success");
|
|
272
|
+
const failedLabel = feedbackText || t("gds.feedback.failed", "Failed");
|
|
273
|
+
const errorAnnouncement = feedbackText || t("gds.feedback.error", "Something went wrong");
|
|
274
|
+
const confirmLabel = t("gds.feedback.confirmAgain", "Click again to confirm");
|
|
275
|
+
const workingLabel = pendingLabel(action, t);
|
|
276
|
+
const reservesWidth = Boolean(onAction) || feedbackState !== void 0;
|
|
117
277
|
let color = props.color;
|
|
118
278
|
const brandStyle = brandVariant ? brandButtonStyles[brandVariant] : void 0;
|
|
119
279
|
const disabled = props.disabled || brandVariant === "disabled";
|
|
280
|
+
const showingFeedback = phase === "success" || phase === "error";
|
|
120
281
|
const isStylesheetPaintedBrand = brandVariant === "outline-accent" || brandVariant === "gradient";
|
|
121
|
-
const brandButtonAttr = isStylesheetPaintedBrand &&
|
|
282
|
+
const brandButtonAttr = isStylesheetPaintedBrand && showingFeedback ? void 0 : brandVariant;
|
|
122
283
|
if (!mounted) {
|
|
123
|
-
const { leftSection, style, ...
|
|
124
|
-
return /* @__PURE__ */ jsx(Button, { ...
|
|
284
|
+
const { leftSection, style, ...prerenderProps } = buttonRest;
|
|
285
|
+
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
286
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
287
|
+
let visibleLabel = restLabel;
|
|
288
|
+
let announcement = "";
|
|
289
|
+
if (phase === "success") {
|
|
290
|
+
visibleLabel = successLabel;
|
|
291
|
+
announcement = successLabel;
|
|
292
|
+
color = feedbackConfig.color;
|
|
293
|
+
} else if (phase === "error") {
|
|
294
|
+
visibleLabel = failedLabel;
|
|
295
|
+
announcement = errorAnnouncement;
|
|
134
296
|
color = "red";
|
|
297
|
+
} else if (phase === "pending") {
|
|
298
|
+
visibleLabel = workingLabel;
|
|
299
|
+
announcement = workingLabel;
|
|
300
|
+
} else if (phase === "confirm") {
|
|
301
|
+
visibleLabel = confirmLabel;
|
|
302
|
+
announcement = confirmLabel;
|
|
135
303
|
}
|
|
304
|
+
const ghosts = [restLabel, successLabel, failedLabel];
|
|
305
|
+
if (onAction) ghosts.push(workingLabel);
|
|
306
|
+
if (onAction && motion?.confirm) ghosts.push(confirmLabel);
|
|
307
|
+
const busy = phase === "busy" || phase === "pending";
|
|
136
308
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
137
309
|
/* @__PURE__ */ jsx(
|
|
138
310
|
Button,
|
|
139
311
|
{
|
|
140
|
-
...
|
|
141
|
-
|
|
312
|
+
...buttonRest,
|
|
313
|
+
onClick: handleClick,
|
|
314
|
+
leftSection: /* @__PURE__ */ jsx(ButtonIcon, { phase, motion, Icon: config.icon, SuccessIcon: feedbackConfig.icon, fromRest, pressed: pressPhase === phase }, `${phase}-${cycle}-${pressPhase === phase ? presses : 0}`),
|
|
142
315
|
loading,
|
|
143
316
|
color,
|
|
144
317
|
"data-gds-brand-button": brandButtonAttr,
|
|
318
|
+
"data-gds-button-phase": phase === "idle" ? void 0 : phase,
|
|
145
319
|
disabled,
|
|
146
|
-
"aria-
|
|
320
|
+
"aria-disabled": busy ? true : void 0,
|
|
321
|
+
"aria-busy": loading || busy ? true : void 0,
|
|
147
322
|
style: { ...brandStyle, ...props.style },
|
|
148
|
-
children: label
|
|
323
|
+
children: reservesWidth ? /* @__PURE__ */ jsxs("span", { "data-gds-button-label-stack": "", children: [
|
|
324
|
+
ghosts.map((ghost, index) => /* @__PURE__ */ jsx("span", { "data-gds-button-label-ghost": "", "aria-hidden": "true", children: ghost }, index)),
|
|
325
|
+
/* @__PURE__ */ jsx("span", { "data-gds-button-label": "", children: visibleLabel })
|
|
326
|
+
] }) : visibleLabel
|
|
149
327
|
}
|
|
150
328
|
),
|
|
151
|
-
|
|
329
|
+
reservesWidth ? /* @__PURE__ */ jsx(VisuallyHidden, { role: "status", "aria-live": "polite", "aria-atomic": "true", children: announcement }) : null
|
|
152
330
|
] });
|
|
153
331
|
}
|
|
154
332
|
|
|
@@ -260,7 +438,7 @@ function GdsShapeScope({ profile, style, children, ...others }) {
|
|
|
260
438
|
}
|
|
261
439
|
|
|
262
440
|
// src/GdsTreeView.tsx
|
|
263
|
-
import { useCallback, useMemo, useRef, useState as useState2 } from "react";
|
|
441
|
+
import { useCallback as useCallback2, useMemo, useRef as useRef2, useState as useState2 } from "react";
|
|
264
442
|
import { Box as Box2, Button as Button2, Group as Group2, Loader, Paper as Paper2, Text as Text3 } from "@mantine/core";
|
|
265
443
|
import { useUncontrolled } from "@mantine/hooks";
|
|
266
444
|
import { useGdsTranslation as useGdsTranslation3 } from "@sovereignsquad/gds-theme";
|
|
@@ -281,8 +459,8 @@ function GdsTreeView({
|
|
|
281
459
|
const [selected, setSelected] = useUncontrolled({ value: selectedId, defaultValue: defaultSelectedId, finalValue: null });
|
|
282
460
|
const [loads, setLoads] = useState2({});
|
|
283
461
|
const [focusedId, setFocusedId] = useState2(null);
|
|
284
|
-
const itemRefs =
|
|
285
|
-
const childrenOf =
|
|
462
|
+
const itemRefs = useRef2(/* @__PURE__ */ new Map());
|
|
463
|
+
const childrenOf = useCallback2((node) => {
|
|
286
464
|
if (node.children) return node.children;
|
|
287
465
|
const load2 = loads[node.id];
|
|
288
466
|
return load2?.status === "loaded" ? load2.children : void 0;
|
|
@@ -1155,7 +1333,7 @@ function DocsShell({
|
|
|
1155
1333
|
mobileNavigationLabel: t("gds.navigation.openMobile", "Open docs navigation"),
|
|
1156
1334
|
hideMobileNavigationToggle: mobileNavigationMode === "inline-collapse" && Boolean(mobileNavigation),
|
|
1157
1335
|
headerHeight: 72,
|
|
1158
|
-
children: /* @__PURE__ */ jsx14(Container, { size: resolveContentContainerSize(contentWidth), px: "md", py: "lg", w: "100%", children })
|
|
1336
|
+
children: /* @__PURE__ */ jsx14(Container, { size: resolveContentContainerSize(contentWidth), px: { base: 0, sm: "md" }, py: "lg", w: "100%", children })
|
|
1159
1337
|
}
|
|
1160
1338
|
);
|
|
1161
1339
|
}
|
|
@@ -1224,8 +1402,10 @@ var SidebarNavItem = createPolymorphicComponent(_SidebarNavItem);
|
|
|
1224
1402
|
// src/DocsCodeBlock.tsx
|
|
1225
1403
|
import { useState as useState6 } from "react";
|
|
1226
1404
|
import { ActionIcon, Code, Group as Group8, Paper as Paper5, Stack as Stack5, Text as Text10 } from "@mantine/core";
|
|
1405
|
+
import { useGdsTranslation as useGdsTranslation12 } from "@sovereignsquad/gds-theme";
|
|
1227
1406
|
import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1228
1407
|
function DocsCodeBlock({ code, language, title, withCopy = true }) {
|
|
1408
|
+
const { t } = useGdsTranslation12();
|
|
1229
1409
|
const [copied, setCopied] = useState6(false);
|
|
1230
1410
|
const handleCopy = async () => {
|
|
1231
1411
|
if (!navigator?.clipboard) {
|
|
@@ -1247,7 +1427,7 @@ function DocsCodeBlock({ code, language, title, withCopy = true }) {
|
|
|
1247
1427
|
"data-gds-copy-action": true,
|
|
1248
1428
|
variant: "default",
|
|
1249
1429
|
size: "xl",
|
|
1250
|
-
"aria-label": copied ? "Copied code block" : "Copy code block",
|
|
1430
|
+
"aria-label": copied ? t("gds.docsCodeBlock.copied", "Copied code block") : t("gds.docsCodeBlock.copy", "Copy code block"),
|
|
1251
1431
|
onClick: () => {
|
|
1252
1432
|
void handleCopy();
|
|
1253
1433
|
},
|
|
@@ -1255,15 +1435,175 @@ function DocsCodeBlock({ code, language, title, withCopy = true }) {
|
|
|
1255
1435
|
}
|
|
1256
1436
|
) : null
|
|
1257
1437
|
] }) : null,
|
|
1258
|
-
/* @__PURE__ */ jsx16(Code, { block: true, children: code })
|
|
1438
|
+
/* @__PURE__ */ jsx16(Code, { block: true, tabIndex: 0, role: "group", "aria-label": title ?? t("gds.docsCodeBlock.region", "Code"), children: code })
|
|
1259
1439
|
] }) });
|
|
1260
1440
|
}
|
|
1261
1441
|
|
|
1442
|
+
// src/DocsCodeDisclosure.tsx
|
|
1443
|
+
import { useCallback as useCallback3, useEffect as useEffect3, useRef as useRef3, useState as useState7 } from "react";
|
|
1444
|
+
import { Accordion } from "@mantine/core";
|
|
1445
|
+
import { useGdsTranslation as useGdsTranslation13 } from "@sovereignsquad/gds-theme";
|
|
1446
|
+
import { jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1447
|
+
function DocsCodeDisclosure({ code, loadCode, language, label, defaultOpened = false }) {
|
|
1448
|
+
const { t } = useGdsTranslation13();
|
|
1449
|
+
const [opened, setOpened] = useState7(defaultOpened);
|
|
1450
|
+
const [state, setState] = useState7(code !== void 0 ? { status: "ready", code } : { status: "idle" });
|
|
1451
|
+
const load = useCallback3(() => {
|
|
1452
|
+
if (!loadCode) return;
|
|
1453
|
+
setState({ status: "loading" });
|
|
1454
|
+
loadCode().then((loaded) => setState({ status: "ready", code: loaded })).catch(() => setState({ status: "error" }));
|
|
1455
|
+
}, [loadCode]);
|
|
1456
|
+
const setOpen = (next) => {
|
|
1457
|
+
setOpened(next);
|
|
1458
|
+
if (next && code === void 0 && (state.status === "idle" || state.status === "error")) load();
|
|
1459
|
+
};
|
|
1460
|
+
const loadedOnMount = useRef3(false);
|
|
1461
|
+
useEffect3(() => {
|
|
1462
|
+
if (defaultOpened && code === void 0 && !loadedOnMount.current) {
|
|
1463
|
+
loadedOnMount.current = true;
|
|
1464
|
+
load();
|
|
1465
|
+
}
|
|
1466
|
+
}, [defaultOpened, code, load]);
|
|
1467
|
+
const shown = code !== void 0 ? code : state.status === "ready" ? state.code : void 0;
|
|
1468
|
+
return /* @__PURE__ */ jsx17(
|
|
1469
|
+
Accordion,
|
|
1470
|
+
{
|
|
1471
|
+
variant: "contained",
|
|
1472
|
+
radius: "lg",
|
|
1473
|
+
value: opened ? "code" : null,
|
|
1474
|
+
onChange: (value) => setOpen(value === "code"),
|
|
1475
|
+
"data-gds-code-disclosure": "",
|
|
1476
|
+
children: /* @__PURE__ */ jsxs12(Accordion.Item, { value: "code", children: [
|
|
1477
|
+
/* @__PURE__ */ jsx17(Accordion.Control, { children: label ?? t("gds.docsCodeDisclosure.show", "Show code") }),
|
|
1478
|
+
/* @__PURE__ */ jsxs12(Accordion.Panel, { children: [
|
|
1479
|
+
shown !== void 0 ? /* @__PURE__ */ jsx17(DocsCodeBlock, { code: shown, language }) : null,
|
|
1480
|
+
shown === void 0 && state.status === "loading" ? /* @__PURE__ */ jsx17(MetadataText, { role: "status", children: t("gds.docsCodeDisclosure.loading", "Loading code\u2026") }) : null,
|
|
1481
|
+
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
|
|
1482
|
+
] })
|
|
1483
|
+
] })
|
|
1484
|
+
}
|
|
1485
|
+
);
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
// src/GdsTableScrollContainer.tsx
|
|
1489
|
+
import { Table } from "@mantine/core";
|
|
1490
|
+
import { useGdsTranslation as useGdsTranslation14 } from "@sovereignsquad/gds-theme";
|
|
1491
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1492
|
+
function GdsTableScrollContainer({ children, label, minWidth = 0 }) {
|
|
1493
|
+
const { t } = useGdsTranslation14();
|
|
1494
|
+
return /* @__PURE__ */ jsx18(
|
|
1495
|
+
Table.ScrollContainer,
|
|
1496
|
+
{
|
|
1497
|
+
minWidth,
|
|
1498
|
+
type: "native",
|
|
1499
|
+
tabIndex: 0,
|
|
1500
|
+
role: "group",
|
|
1501
|
+
"aria-label": label ?? t("gds.tableScroll.region", "Table"),
|
|
1502
|
+
"data-gds-table-scroll": "",
|
|
1503
|
+
children
|
|
1504
|
+
}
|
|
1505
|
+
);
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
// src/GdsReleaseNotes.client.tsx
|
|
1509
|
+
import { Fragment as Fragment4 } from "react";
|
|
1510
|
+
import { Table as Table2 } from "@mantine/core";
|
|
1511
|
+
import { Fragment as Fragment5, jsx as jsx19, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1512
|
+
var ISSUE_REFERENCE = /#(\d+)/g;
|
|
1513
|
+
function withSlashBreaks(text, key) {
|
|
1514
|
+
if (!text.includes("/")) return text;
|
|
1515
|
+
const pieces = text.split("/");
|
|
1516
|
+
return pieces.map((piece, index) => /* @__PURE__ */ jsxs13(Fragment4, { children: [
|
|
1517
|
+
piece,
|
|
1518
|
+
index < pieces.length - 1 ? /* @__PURE__ */ jsxs13(Fragment5, { children: [
|
|
1519
|
+
"/",
|
|
1520
|
+
/* @__PURE__ */ jsx19("wbr", {})
|
|
1521
|
+
] }) : null
|
|
1522
|
+
] }, `${key}-s${index}`));
|
|
1523
|
+
}
|
|
1524
|
+
function renderText(text, issueHref, key) {
|
|
1525
|
+
if (!issueHref) return withSlashBreaks(text, key);
|
|
1526
|
+
const parts = [];
|
|
1527
|
+
let last = 0;
|
|
1528
|
+
for (const match of text.matchAll(ISSUE_REFERENCE)) {
|
|
1529
|
+
const index = match.index ?? 0;
|
|
1530
|
+
if (index > last) parts.push(/* @__PURE__ */ jsx19(Fragment4, { children: withSlashBreaks(text.slice(last, index), `${key}-t${last}`) }, `${key}-t${last}`));
|
|
1531
|
+
parts.push(/* @__PURE__ */ jsx19(GdsInlineLink, { href: issueHref(Number(match[1])), children: match[0] }, `${key}-${index}`));
|
|
1532
|
+
last = index + match[0].length;
|
|
1533
|
+
}
|
|
1534
|
+
if (last < text.length) parts.push(/* @__PURE__ */ jsx19(Fragment4, { children: withSlashBreaks(text.slice(last), `${key}-t${last}`) }, `${key}-t${last}`));
|
|
1535
|
+
return parts;
|
|
1536
|
+
}
|
|
1537
|
+
function renderInline(content, issueHref, key) {
|
|
1538
|
+
return content.map((part, index) => {
|
|
1539
|
+
const partKey = `${key}-${index}`;
|
|
1540
|
+
switch (part.kind) {
|
|
1541
|
+
case "text":
|
|
1542
|
+
return /* @__PURE__ */ jsx19(Fragment4, { children: renderText(part.text, issueHref, partKey) }, partKey);
|
|
1543
|
+
case "code":
|
|
1544
|
+
return /* @__PURE__ */ jsx19(InlineText, { component: "code", children: part.text }, partKey);
|
|
1545
|
+
case "strong":
|
|
1546
|
+
return /* @__PURE__ */ jsx19(InlineEmphasis, { children: renderInline(part.children, issueHref, partKey) }, partKey);
|
|
1547
|
+
case "link":
|
|
1548
|
+
return /* @__PURE__ */ jsx19(GdsInlineLink, { href: part.href, external: /^https?:/.test(part.href), children: renderInline(part.children, issueHref, partKey) }, partKey);
|
|
1549
|
+
}
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
function renderBlocks(blocks, issueHref, key) {
|
|
1553
|
+
return blocks.map((block, index) => {
|
|
1554
|
+
const blockKey = `${key}-${index}`;
|
|
1555
|
+
switch (block.kind) {
|
|
1556
|
+
case "paragraph":
|
|
1557
|
+
return /* @__PURE__ */ jsx19(BodyText, { children: renderInline(block.content, issueHref, blockKey) }, blockKey);
|
|
1558
|
+
case "list":
|
|
1559
|
+
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: [
|
|
1560
|
+
/* @__PURE__ */ jsxs13(BodyText, { children: [
|
|
1561
|
+
/* @__PURE__ */ jsx19("span", { "aria-hidden": "true", "data-gds-release-marker": "", children: block.ordered ? `${itemIndex + 1}. ` : "\u2022 " }),
|
|
1562
|
+
renderInline(item.content, issueHref, `${blockKey}-${itemIndex}`)
|
|
1563
|
+
] }),
|
|
1564
|
+
item.children?.length ? /* @__PURE__ */ jsx19(GdsBox, { padding: { base: "md" }, "data-gds-release-nested": "", children: renderBlocks(item.children, issueHref, `${blockKey}-${itemIndex}-c`) }) : null
|
|
1565
|
+
] }, `${blockKey}-${itemIndex}`)) }, blockKey);
|
|
1566
|
+
case "code":
|
|
1567
|
+
return /* @__PURE__ */ jsx19(DocsCodeBlock, { code: block.code, language: block.language, withCopy: false }, blockKey);
|
|
1568
|
+
case "table":
|
|
1569
|
+
return /* @__PURE__ */ jsx19(GdsTableScrollContainer, { children: /* @__PURE__ */ jsxs13(Table2, { withTableBorder: true, children: [
|
|
1570
|
+
/* @__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)) }) }),
|
|
1571
|
+
/* @__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)) })
|
|
1572
|
+
] }) }, blockKey);
|
|
1573
|
+
}
|
|
1574
|
+
});
|
|
1575
|
+
}
|
|
1576
|
+
function releaseAnchor(releases, index) {
|
|
1577
|
+
const base = `release-${releases[index].version.replace(/[^a-z0-9]+/gi, "-").toLowerCase()}`;
|
|
1578
|
+
const earlier = releases.slice(0, index).filter((release) => release.version === releases[index].version).length;
|
|
1579
|
+
return earlier === 0 ? base : `${base}-${earlier + 1}`;
|
|
1580
|
+
}
|
|
1581
|
+
function GdsReleaseNotes({ releases, issueHref, headingLevel = 2 }) {
|
|
1582
|
+
const sectionLevel = headingLevel + 1;
|
|
1583
|
+
return /* @__PURE__ */ jsx19(GdsStack, { gap: "lg", "data-gds-release-notes": "", children: releases.map((release, index) => /* @__PURE__ */ jsx19(
|
|
1584
|
+
SectionPanel,
|
|
1585
|
+
{
|
|
1586
|
+
id: releaseAnchor(releases, index),
|
|
1587
|
+
titleOrder: headingLevel,
|
|
1588
|
+
title: release.title ? `${release.version} \u2014 ${release.title}` : release.version,
|
|
1589
|
+
description: release.date ? /* @__PURE__ */ jsx19(MetadataText, { children: release.date }) : void 0,
|
|
1590
|
+
children: /* @__PURE__ */ jsxs13(GdsStack, { gap: "md", children: [
|
|
1591
|
+
release.intro?.length ? renderBlocks(release.intro, issueHref, `${release.version}-intro`) : null,
|
|
1592
|
+
release.sections.map((section, index2) => /* @__PURE__ */ jsxs13(GdsStack, { gap: "sm", component: "section", children: [
|
|
1593
|
+
/* @__PURE__ */ jsx19(CardTitle, { order: sectionLevel, children: renderInline(section.heading, issueHref, `${release.version}-${index2}-h`) }),
|
|
1594
|
+
renderBlocks(section.blocks, issueHref, `${release.version}-${index2}`)
|
|
1595
|
+
] }, `${release.version}-${index2}`))
|
|
1596
|
+
] })
|
|
1597
|
+
},
|
|
1598
|
+
`${release.version}-${index}`
|
|
1599
|
+
)) });
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1262
1602
|
// src/ShareButtonGroup.tsx
|
|
1263
|
-
import { useGdsTranslation as
|
|
1264
|
-
import { useState as
|
|
1603
|
+
import { useGdsTranslation as useGdsTranslation15 } from "@sovereignsquad/gds-theme";
|
|
1604
|
+
import { useState as useState8 } from "react";
|
|
1265
1605
|
import { ActionIcon as ActionIcon2, Button as Button5, Group as Group9, Stack as Stack6, Text as Text11 } from "@mantine/core";
|
|
1266
|
-
import { jsx as
|
|
1606
|
+
import { jsx as jsx20, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1267
1607
|
var channelLabels = {
|
|
1268
1608
|
native: "Share",
|
|
1269
1609
|
copy: "Copy link",
|
|
@@ -1298,9 +1638,9 @@ function ShareAction({
|
|
|
1298
1638
|
const label = channelLabels[channel];
|
|
1299
1639
|
const Icon = channel === "copy" ? GdsIcons.Copy : channel === "mail" ? GdsIcons.Mail : channel === "message" ? GdsIcons.Message : GdsIcons.Refer;
|
|
1300
1640
|
if (compact) {
|
|
1301
|
-
return href ? /* @__PURE__ */
|
|
1641
|
+
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
1642
|
}
|
|
1303
|
-
return href ? /* @__PURE__ */
|
|
1643
|
+
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
1644
|
}
|
|
1305
1645
|
function ShareButtonGroup({
|
|
1306
1646
|
url,
|
|
@@ -1311,10 +1651,10 @@ function ShareButtonGroup({
|
|
|
1311
1651
|
label: labelProp,
|
|
1312
1652
|
description
|
|
1313
1653
|
}) {
|
|
1314
|
-
const { t } =
|
|
1654
|
+
const { t } = useGdsTranslation15();
|
|
1315
1655
|
const label = labelProp ?? t("gds.shareButtonGroup.label", "Share this");
|
|
1316
|
-
const [copied, setCopied] =
|
|
1317
|
-
const [shared, setShared] =
|
|
1656
|
+
const [copied, setCopied] = useState8(false);
|
|
1657
|
+
const [shared, setShared] = useState8(false);
|
|
1318
1658
|
const hrefs = encodeShare(url, title, text);
|
|
1319
1659
|
async function handleCopy() {
|
|
1320
1660
|
await navigator.clipboard?.writeText?.(url);
|
|
@@ -1330,30 +1670,30 @@ function ShareButtonGroup({
|
|
|
1330
1670
|
}
|
|
1331
1671
|
await handleCopy();
|
|
1332
1672
|
}
|
|
1333
|
-
return /* @__PURE__ */
|
|
1334
|
-
/* @__PURE__ */
|
|
1335
|
-
/* @__PURE__ */
|
|
1336
|
-
description ? /* @__PURE__ */
|
|
1673
|
+
return /* @__PURE__ */ jsxs14(Stack6, { gap: "sm", children: [
|
|
1674
|
+
/* @__PURE__ */ jsxs14(Stack6, { gap: 2, children: [
|
|
1675
|
+
/* @__PURE__ */ jsx20(Text11, { fw: 600, children: label }),
|
|
1676
|
+
description ? /* @__PURE__ */ jsx20(Text11, { size: "sm", c: "dimmed", children: description }) : null
|
|
1337
1677
|
] }),
|
|
1338
|
-
/* @__PURE__ */
|
|
1678
|
+
/* @__PURE__ */ jsx20(Group9, { gap: "sm", wrap: "wrap", children: channels.map((channel) => {
|
|
1339
1679
|
if (channel === "copy") {
|
|
1340
|
-
return /* @__PURE__ */
|
|
1680
|
+
return /* @__PURE__ */ jsx20(ShareAction, { channel, compact, onClick: () => void handleCopy() }, channel);
|
|
1341
1681
|
}
|
|
1342
1682
|
if (channel === "native") {
|
|
1343
|
-
return /* @__PURE__ */
|
|
1683
|
+
return /* @__PURE__ */ jsx20(ShareAction, { channel, compact, onClick: () => void handleNativeShare() }, channel);
|
|
1344
1684
|
}
|
|
1345
|
-
return /* @__PURE__ */
|
|
1685
|
+
return /* @__PURE__ */ jsx20(ShareAction, { channel, compact, href: hrefs[channel] }, channel);
|
|
1346
1686
|
}) }),
|
|
1347
|
-
copied ? /* @__PURE__ */
|
|
1348
|
-
shared ? /* @__PURE__ */
|
|
1687
|
+
copied ? /* @__PURE__ */ jsx20(Text11, { size: "sm", c: "teal", children: "Link copied." }) : null,
|
|
1688
|
+
shared ? /* @__PURE__ */ jsx20(Text11, { size: "sm", c: "teal", children: "Share sheet opened." }) : null
|
|
1349
1689
|
] });
|
|
1350
1690
|
}
|
|
1351
1691
|
|
|
1352
1692
|
// src/UploadDropzone.tsx
|
|
1353
|
-
import { useGdsTranslation as
|
|
1354
|
-
import { useRef as
|
|
1693
|
+
import { useGdsTranslation as useGdsTranslation16 } from "@sovereignsquad/gds-theme";
|
|
1694
|
+
import { useRef as useRef4, useState as useState9 } from "react";
|
|
1355
1695
|
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
|
|
1696
|
+
import { jsx as jsx21, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1357
1697
|
function UploadDropzone({
|
|
1358
1698
|
title,
|
|
1359
1699
|
description,
|
|
@@ -1377,10 +1717,10 @@ function UploadDropzone({
|
|
|
1377
1717
|
removeAction,
|
|
1378
1718
|
readonly = false
|
|
1379
1719
|
}) {
|
|
1380
|
-
const { t } =
|
|
1720
|
+
const { t } = useGdsTranslation16();
|
|
1381
1721
|
const actionLabel = actionLabelProp ?? t("gds.uploadDropzone.actionLabel", "Choose files");
|
|
1382
|
-
const inputRef =
|
|
1383
|
-
const [dragging, setDragging] =
|
|
1722
|
+
const inputRef = useRef4(null);
|
|
1723
|
+
const [dragging, setDragging] = useState9(false);
|
|
1384
1724
|
const UploadIcon = GdsIcons.Upload;
|
|
1385
1725
|
const effectiveState = readonly ? "readonly" : dragging ? "drag-active" : state;
|
|
1386
1726
|
const isDisabled = readonly || effectiveState === "upload-pending";
|
|
@@ -1392,7 +1732,7 @@ function UploadDropzone({
|
|
|
1392
1732
|
}
|
|
1393
1733
|
onFilesSelected(Array.from(files));
|
|
1394
1734
|
};
|
|
1395
|
-
return /* @__PURE__ */
|
|
1735
|
+
return /* @__PURE__ */ jsxs15(
|
|
1396
1736
|
Box8,
|
|
1397
1737
|
{
|
|
1398
1738
|
onDragOver: (event) => {
|
|
@@ -1416,7 +1756,7 @@ function UploadDropzone({
|
|
|
1416
1756
|
},
|
|
1417
1757
|
"aria-invalid": isError || void 0,
|
|
1418
1758
|
children: [
|
|
1419
|
-
/* @__PURE__ */
|
|
1759
|
+
/* @__PURE__ */ jsx21(
|
|
1420
1760
|
"input",
|
|
1421
1761
|
{
|
|
1422
1762
|
id: inputId,
|
|
@@ -1433,30 +1773,30 @@ function UploadDropzone({
|
|
|
1433
1773
|
onChange: (event) => forwardFiles(event.currentTarget.files)
|
|
1434
1774
|
}
|
|
1435
1775
|
),
|
|
1436
|
-
/* @__PURE__ */
|
|
1437
|
-
/* @__PURE__ */
|
|
1438
|
-
/* @__PURE__ */
|
|
1439
|
-
/* @__PURE__ */
|
|
1440
|
-
description ? /* @__PURE__ */
|
|
1441
|
-
acceptedTypesLabel || maxSizeLabel ? /* @__PURE__ */
|
|
1442
|
-
acceptedTypesLabel ? /* @__PURE__ */
|
|
1443
|
-
maxSizeLabel ? /* @__PURE__ */
|
|
1776
|
+
/* @__PURE__ */ jsxs15(Stack7, { align: mode === "inline" ? "flex-start" : "center", ta: mode === "inline" ? "left" : "center", gap: "sm", children: [
|
|
1777
|
+
/* @__PURE__ */ jsx21(UploadIcon, { size: "1.5rem" }),
|
|
1778
|
+
/* @__PURE__ */ jsx21(Badge, { variant: "light", color: isError ? "red" : effectiveState === "selected" ? "blue" : effectiveState === "upload-pending" ? "violet" : "gray", children: effectiveState.replace("-", " ") }),
|
|
1779
|
+
/* @__PURE__ */ jsx21(Text12, { fw: 600, children: title }),
|
|
1780
|
+
description ? /* @__PURE__ */ jsx21(Text12, { size: "sm", c: "dimmed", children: description }) : null,
|
|
1781
|
+
acceptedTypesLabel || maxSizeLabel ? /* @__PURE__ */ jsxs15(Group10, { gap: "xs", justify: mode === "inline" ? "flex-start" : "center", children: [
|
|
1782
|
+
acceptedTypesLabel ? /* @__PURE__ */ jsx21(Badge, { variant: "outline", color: "gray", children: acceptedTypesLabel }) : null,
|
|
1783
|
+
maxSizeLabel ? /* @__PURE__ */ jsx21(Badge, { variant: "outline", color: "gray", children: maxSizeLabel }) : null
|
|
1444
1784
|
] }) : null,
|
|
1445
|
-
selectedFiles.length ? /* @__PURE__ */
|
|
1785
|
+
selectedFiles.length ? /* @__PURE__ */ jsxs15(Text12, { size: "sm", children: [
|
|
1446
1786
|
"Selected: ",
|
|
1447
1787
|
selectedFiles.join(", ")
|
|
1448
1788
|
] }) : null,
|
|
1449
|
-
effectiveState === "upload-pending" && normalizedProgress !== void 0 ? /* @__PURE__ */
|
|
1450
|
-
/* @__PURE__ */
|
|
1451
|
-
/* @__PURE__ */
|
|
1789
|
+
effectiveState === "upload-pending" && normalizedProgress !== void 0 ? /* @__PURE__ */ jsxs15(Box8, { w: "100%", maw: 360, children: [
|
|
1790
|
+
/* @__PURE__ */ jsx21(Progress, { value: normalizedProgress, "aria-label": `${title} upload progress` }),
|
|
1791
|
+
/* @__PURE__ */ jsxs15(Text12, { size: "xs", c: "dimmed", mt: 4, children: [
|
|
1452
1792
|
Math.round(normalizedProgress),
|
|
1453
1793
|
"% uploaded"
|
|
1454
1794
|
] })
|
|
1455
1795
|
] }) : null,
|
|
1456
|
-
policyText ? /* @__PURE__ */
|
|
1457
|
-
error ? /* @__PURE__ */
|
|
1458
|
-
/* @__PURE__ */
|
|
1459
|
-
/* @__PURE__ */
|
|
1796
|
+
policyText ? /* @__PURE__ */ jsx21(Text12, { size: "sm", c: isError ? "red.7" : "dimmed", children: policyText }) : null,
|
|
1797
|
+
error ? /* @__PURE__ */ jsx21(Text12, { size: "sm", c: "red.7", role: "alert", children: error }) : null,
|
|
1798
|
+
/* @__PURE__ */ jsxs15(Group10, { children: [
|
|
1799
|
+
/* @__PURE__ */ jsx21(Button6, { variant: "light", onClick: () => inputRef.current?.click(), disabled: isDisabled, children: actionLabel }),
|
|
1460
1800
|
retryAction,
|
|
1461
1801
|
removeAction
|
|
1462
1802
|
] })
|
|
@@ -1467,9 +1807,9 @@ function UploadDropzone({
|
|
|
1467
1807
|
}
|
|
1468
1808
|
|
|
1469
1809
|
// src/GdsAssetManager.client.tsx
|
|
1470
|
-
import { useCallback as
|
|
1810
|
+
import { useCallback as useCallback4, useMemo as useMemo3, useState as useState10 } from "react";
|
|
1471
1811
|
import { Button as Button7, Group as Group11, Stack as Stack8, Text as Text13, TextInput } from "@mantine/core";
|
|
1472
|
-
import { jsx as
|
|
1812
|
+
import { jsx as jsx22, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1473
1813
|
function emitAssetEvent(onEvent, type, message) {
|
|
1474
1814
|
onEvent?.({ type, message, timestamp: Date.now(), privacy: "metadata-only" });
|
|
1475
1815
|
}
|
|
@@ -1512,8 +1852,8 @@ function useGdsAssetUploadQueue({
|
|
|
1512
1852
|
onEvent,
|
|
1513
1853
|
timeoutMs = 1e4
|
|
1514
1854
|
}) {
|
|
1515
|
-
const [items, setItems] =
|
|
1516
|
-
const uploadItem =
|
|
1855
|
+
const [items, setItems] = useState10([]);
|
|
1856
|
+
const uploadItem = useCallback4(async (item) => {
|
|
1517
1857
|
if (!item.file) return;
|
|
1518
1858
|
const controller = new AbortController();
|
|
1519
1859
|
const timer = window.setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -1536,7 +1876,7 @@ function useGdsAssetUploadQueue({
|
|
|
1536
1876
|
window.clearTimeout(timer);
|
|
1537
1877
|
}
|
|
1538
1878
|
}, [adapter, onEvent, policy, timeoutMs]);
|
|
1539
|
-
const selectFiles =
|
|
1879
|
+
const selectFiles = useCallback4(async (files) => {
|
|
1540
1880
|
for (const file of files) {
|
|
1541
1881
|
const id = assetIdFromFile(file);
|
|
1542
1882
|
emitAssetEvent(onEvent, "asset_selected");
|
|
@@ -1550,16 +1890,16 @@ function useGdsAssetUploadQueue({
|
|
|
1550
1890
|
}
|
|
1551
1891
|
}
|
|
1552
1892
|
}, [onEvent, policy, uploadItem]);
|
|
1553
|
-
const retry =
|
|
1893
|
+
const retry = useCallback4(async (itemId) => {
|
|
1554
1894
|
const item = items.find((entry) => entry.id === itemId);
|
|
1555
1895
|
if (item) await uploadItem(item);
|
|
1556
1896
|
}, [items, uploadItem]);
|
|
1557
|
-
const remove =
|
|
1897
|
+
const remove = useCallback4(async (itemId) => {
|
|
1558
1898
|
const item = items.find((entry) => entry.id === itemId);
|
|
1559
1899
|
if (item?.asset) await adapter.remove?.(item.asset.id);
|
|
1560
1900
|
setItems((current) => current.filter((entry) => entry.id !== itemId));
|
|
1561
1901
|
}, [adapter, items]);
|
|
1562
|
-
const saveMetadata =
|
|
1902
|
+
const saveMetadata = useCallback4((itemId, metadata) => {
|
|
1563
1903
|
setItems((current) => current.map((entry) => {
|
|
1564
1904
|
if (entry.id !== itemId || !entry.asset) return entry;
|
|
1565
1905
|
const asset = { ...entry.asset, ...metadata };
|
|
@@ -1571,7 +1911,7 @@ function useGdsAssetUploadQueue({
|
|
|
1571
1911
|
return { items, selectFiles, retry, remove, saveMetadata };
|
|
1572
1912
|
}
|
|
1573
1913
|
function GdsAssetPreviewCard({ asset, aspectRatio = "1:1" }) {
|
|
1574
|
-
return /* @__PURE__ */
|
|
1914
|
+
return /* @__PURE__ */ jsx22(
|
|
1575
1915
|
MediaPreviewCard,
|
|
1576
1916
|
{
|
|
1577
1917
|
title: asset.fileName,
|
|
@@ -1602,8 +1942,8 @@ function GdsAssetManager({
|
|
|
1602
1942
|
}) {
|
|
1603
1943
|
const queue = useGdsAssetUploadQueue({ adapter, policy, onEvent, timeoutMs });
|
|
1604
1944
|
const accept = useMemo3(() => policy?.acceptedTypes?.join(",") ?? void 0, [policy]);
|
|
1605
|
-
return /* @__PURE__ */
|
|
1606
|
-
/* @__PURE__ */
|
|
1945
|
+
return /* @__PURE__ */ jsxs16(Stack8, { gap: "md", children: [
|
|
1946
|
+
/* @__PURE__ */ jsx22(
|
|
1607
1947
|
UploadDropzone,
|
|
1608
1948
|
{
|
|
1609
1949
|
title,
|
|
@@ -1619,28 +1959,28 @@ function GdsAssetManager({
|
|
|
1619
1959
|
selectedFiles: queue.items.map((item) => item.fileName)
|
|
1620
1960
|
}
|
|
1621
1961
|
),
|
|
1622
|
-
!queue.items.length ? /* @__PURE__ */
|
|
1623
|
-
queue.items.map((item) => /* @__PURE__ */
|
|
1624
|
-
item.asset ? /* @__PURE__ */
|
|
1625
|
-
item.status === "failed" ? /* @__PURE__ */
|
|
1962
|
+
!queue.items.length ? /* @__PURE__ */ jsx22(StateBlock, { variant: "empty", title: "No assets selected", description: "Choose files to start the governed upload queue.", compact: true }) : null,
|
|
1963
|
+
queue.items.map((item) => /* @__PURE__ */ jsxs16(Stack8, { gap: "xs", children: [
|
|
1964
|
+
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 }),
|
|
1965
|
+
item.status === "failed" ? /* @__PURE__ */ jsx22(Button7, { onClick: () => {
|
|
1626
1966
|
void queue.retry(item.id);
|
|
1627
1967
|
}, children: "Retry upload" }) : null,
|
|
1628
|
-
item.asset ? /* @__PURE__ */
|
|
1629
|
-
/* @__PURE__ */
|
|
1630
|
-
/* @__PURE__ */
|
|
1631
|
-
/* @__PURE__ */
|
|
1968
|
+
item.asset ? /* @__PURE__ */ jsxs16(Group11, { align: "end", children: [
|
|
1969
|
+
/* @__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 }) }),
|
|
1970
|
+
/* @__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 }) }),
|
|
1971
|
+
/* @__PURE__ */ jsx22(Button7, { variant: "light", color: "red", onClick: () => {
|
|
1632
1972
|
void queue.remove(item.id);
|
|
1633
1973
|
}, children: "Remove" })
|
|
1634
1974
|
] }) : null,
|
|
1635
|
-
item.status === "metadata-incomplete" ? /* @__PURE__ */
|
|
1975
|
+
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
1976
|
] }, item.id))
|
|
1637
1977
|
] });
|
|
1638
1978
|
}
|
|
1639
1979
|
|
|
1640
1980
|
// src/AccessRecoveryPanel.tsx
|
|
1641
1981
|
import { Group as Group12 } from "@mantine/core";
|
|
1642
|
-
import { useGdsTranslation as
|
|
1643
|
-
import { jsx as
|
|
1982
|
+
import { useGdsTranslation as useGdsTranslation17 } from "@sovereignsquad/gds-theme";
|
|
1983
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
1644
1984
|
var stateBlockVariantByState = {
|
|
1645
1985
|
unauthenticated: "permission",
|
|
1646
1986
|
"expired-session": "info",
|
|
@@ -1720,7 +2060,7 @@ function ActionGroup({
|
|
|
1720
2060
|
if (actions.length === 0) {
|
|
1721
2061
|
return null;
|
|
1722
2062
|
}
|
|
1723
|
-
return /* @__PURE__ */
|
|
2063
|
+
return /* @__PURE__ */ jsx23(Group12, { gap: "sm", justify: "center", wrap: "wrap", children: actions.map((actionConfig, index) => /* @__PURE__ */ jsx23(
|
|
1724
2064
|
SemanticButton,
|
|
1725
2065
|
{
|
|
1726
2066
|
action: actionConfig.action,
|
|
@@ -1746,7 +2086,7 @@ function AccessRecoveryPanel({
|
|
|
1746
2086
|
supportAction,
|
|
1747
2087
|
compact = false
|
|
1748
2088
|
}) {
|
|
1749
|
-
const { t } =
|
|
2089
|
+
const { t } = useGdsTranslation17();
|
|
1750
2090
|
const defaultCopy = defaultCopyByState[state];
|
|
1751
2091
|
const defaults = defaultActionsForState(state, {
|
|
1752
2092
|
onRetry,
|
|
@@ -1754,14 +2094,14 @@ function AccessRecoveryPanel({
|
|
|
1754
2094
|
onBack,
|
|
1755
2095
|
supportAction
|
|
1756
2096
|
});
|
|
1757
|
-
return /* @__PURE__ */
|
|
2097
|
+
return /* @__PURE__ */ jsx23(
|
|
1758
2098
|
StateBlock,
|
|
1759
2099
|
{
|
|
1760
2100
|
variant: stateBlockVariantByState[state],
|
|
1761
2101
|
compact,
|
|
1762
2102
|
title: title ?? t(`gds.accessRecovery.${state}.title`, defaultCopy.title),
|
|
1763
2103
|
description: description ?? t(`gds.accessRecovery.${state}.description`, defaultCopy.description),
|
|
1764
|
-
action: /* @__PURE__ */
|
|
2104
|
+
action: /* @__PURE__ */ jsx23(
|
|
1765
2105
|
ActionGroup,
|
|
1766
2106
|
{
|
|
1767
2107
|
primaryAction: primaryAction ?? defaults.primary,
|
|
@@ -1774,10 +2114,10 @@ function AccessRecoveryPanel({
|
|
|
1774
2114
|
}
|
|
1775
2115
|
|
|
1776
2116
|
// src/GdsAccessGate.tsx
|
|
1777
|
-
import { useEffect as
|
|
2117
|
+
import { useEffect as useEffect4, useId } from "react";
|
|
1778
2118
|
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
|
|
2119
|
+
import { gdsDevWarnOnce as gdsDevWarnOnce2, useGdsTranslation as useGdsTranslation18 } from "@sovereignsquad/gds-theme";
|
|
2120
|
+
import { jsx as jsx24, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1781
2121
|
var defaultReasonByState = {
|
|
1782
2122
|
locked: "login-required",
|
|
1783
2123
|
"permission-denied": "role-required",
|
|
@@ -1850,7 +2190,7 @@ function GdsAccessGate({
|
|
|
1850
2190
|
onAction,
|
|
1851
2191
|
onEvent
|
|
1852
2192
|
}) {
|
|
1853
|
-
const { t } =
|
|
2193
|
+
const { t } = useGdsTranslation18();
|
|
1854
2194
|
const teaserLabel = teaserLabelProp ?? t("gds.gdsAccessGate.teaserLabel", "Preview");
|
|
1855
2195
|
const headingId = useId();
|
|
1856
2196
|
const sortedActions = sortGdsAccessGateActions(actions);
|
|
@@ -1875,7 +2215,7 @@ function GdsAccessGate({
|
|
|
1875
2215
|
);
|
|
1876
2216
|
}
|
|
1877
2217
|
const emit = (event) => onEvent?.(event);
|
|
1878
|
-
|
|
2218
|
+
useEffect4(() => {
|
|
1879
2219
|
if (validation.length > 0) {
|
|
1880
2220
|
onEvent?.(createGdsAccessGateEvent("gds.access_gate.error", { id, state: "error", reason: "unknown-error" }, { validationFailures: validation.length }));
|
|
1881
2221
|
return;
|
|
@@ -1887,7 +2227,7 @@ function GdsAccessGate({
|
|
|
1887
2227
|
void action.onClick?.();
|
|
1888
2228
|
void onAction?.(action);
|
|
1889
2229
|
};
|
|
1890
|
-
return /* @__PURE__ */
|
|
2230
|
+
return /* @__PURE__ */ jsx24(
|
|
1891
2231
|
Card,
|
|
1892
2232
|
{
|
|
1893
2233
|
component: "section",
|
|
@@ -1897,17 +2237,17 @@ function GdsAccessGate({
|
|
|
1897
2237
|
p: "lg",
|
|
1898
2238
|
"data-gds-access-gate": id,
|
|
1899
2239
|
"data-gds-access-state": state,
|
|
1900
|
-
children: /* @__PURE__ */
|
|
1901
|
-
/* @__PURE__ */
|
|
1902
|
-
/* @__PURE__ */
|
|
1903
|
-
/* @__PURE__ */
|
|
1904
|
-
/* @__PURE__ */
|
|
1905
|
-
/* @__PURE__ */
|
|
2240
|
+
children: /* @__PURE__ */ jsxs17(Stack9, { gap: "lg", children: [
|
|
2241
|
+
/* @__PURE__ */ jsxs17(Group13, { justify: "space-between", gap: "md", align: "flex-start", wrap: "wrap", children: [
|
|
2242
|
+
/* @__PURE__ */ jsxs17(Stack9, { gap: 4, children: [
|
|
2243
|
+
/* @__PURE__ */ jsx24(Badge2, { variant: "light", children: teaserLabel }),
|
|
2244
|
+
/* @__PURE__ */ jsx24(Title, { id: headingId, order: 3, children: title }),
|
|
2245
|
+
/* @__PURE__ */ jsx24(Text14, { c: "dimmed", children: description })
|
|
1906
2246
|
] }),
|
|
1907
|
-
entitlementLabel ? /* @__PURE__ */
|
|
2247
|
+
entitlementLabel ? /* @__PURE__ */ jsx24(Badge2, { variant: unlocked ? "filled" : "outline", children: entitlementLabel }) : null
|
|
1908
2248
|
] }),
|
|
1909
|
-
/* @__PURE__ */
|
|
1910
|
-
loading ? /* @__PURE__ */
|
|
2249
|
+
/* @__PURE__ */ jsx24(Box9, { "data-gds-access-preview": true, children: preview }),
|
|
2250
|
+
loading ? /* @__PURE__ */ jsx24(
|
|
1911
2251
|
StateBlock,
|
|
1912
2252
|
{
|
|
1913
2253
|
variant: "loading",
|
|
@@ -1916,11 +2256,11 @@ function GdsAccessGate({
|
|
|
1916
2256
|
compact: true
|
|
1917
2257
|
}
|
|
1918
2258
|
) : null,
|
|
1919
|
-
unlocked ? /* @__PURE__ */
|
|
1920
|
-
!unlocked && softGate && !loading ? /* @__PURE__ */
|
|
1921
|
-
!unlocked && !loading ? /* @__PURE__ */
|
|
1922
|
-
/* @__PURE__ */
|
|
1923
|
-
/* @__PURE__ */
|
|
2259
|
+
unlocked ? /* @__PURE__ */ jsx24(Box9, { "data-gds-access-protected": true, children: renderProtectedContent(protectedContent) }) : null,
|
|
2260
|
+
!unlocked && softGate && !loading ? /* @__PURE__ */ jsx24(Box9, { "data-gds-access-degraded": true, "aria-hidden": !unlocked, inert: !unlocked || void 0, children: renderProtectedContent(protectedContent) }) : null,
|
|
2261
|
+
!unlocked && !loading ? /* @__PURE__ */ jsxs17(Stack9, { gap: "md", "data-gds-access-locked": true, children: [
|
|
2262
|
+
/* @__PURE__ */ jsx24(Box9, { "aria-hidden": "true", children: lockedPlaceholder ?? /* @__PURE__ */ jsx24(Skeleton, { height: 96, radius: "lg" }) }),
|
|
2263
|
+
/* @__PURE__ */ jsx24(
|
|
1924
2264
|
AccessRecoveryPanel,
|
|
1925
2265
|
{
|
|
1926
2266
|
state: recoveryStateForGate(state, reason),
|
|
@@ -1949,7 +2289,7 @@ function GdsAccessGate({
|
|
|
1949
2289
|
} : null
|
|
1950
2290
|
}
|
|
1951
2291
|
),
|
|
1952
|
-
sortedActions.some((action) => action.label) ? /* @__PURE__ */
|
|
2292
|
+
sortedActions.some((action) => action.label) ? /* @__PURE__ */ jsx24(Group13, { gap: "xs", wrap: "wrap", children: sortedActions.filter((action) => action.label).map((action) => /* @__PURE__ */ jsx24(
|
|
1953
2293
|
Button8,
|
|
1954
2294
|
{
|
|
1955
2295
|
variant: "subtle",
|
|
@@ -1970,7 +2310,7 @@ function GdsAccessGate({
|
|
|
1970
2310
|
// src/GdsDateInput.client.tsx
|
|
1971
2311
|
import { DateInput, DatePickerInput, DateTimePicker } from "@mantine/dates";
|
|
1972
2312
|
import { gdsDevWarnOnce as gdsDevWarnOnce3 } from "@sovereignsquad/gds-theme";
|
|
1973
|
-
import { jsx as
|
|
2313
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
1974
2314
|
function resolveDateValue(value) {
|
|
1975
2315
|
if (value instanceof Date) return value;
|
|
1976
2316
|
if (typeof value === "string" && value.length > 0) return new Date(value);
|
|
@@ -2011,7 +2351,7 @@ function warnOnDateBounds(component, minDate, maxDate, values) {
|
|
|
2011
2351
|
}
|
|
2012
2352
|
function GdsDateInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
2013
2353
|
warnOnDateBounds("GdsDateInput", minDate, maxDate, [resolveDateValue(value)]);
|
|
2014
|
-
return /* @__PURE__ */
|
|
2354
|
+
return /* @__PURE__ */ jsx25(
|
|
2015
2355
|
DateInput,
|
|
2016
2356
|
{
|
|
2017
2357
|
value: resolveDateValue(value),
|
|
@@ -2025,7 +2365,7 @@ function GdsDateInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
|
2025
2365
|
}
|
|
2026
2366
|
function GdsDateTimeInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
2027
2367
|
warnOnDateBounds("GdsDateTimeInput", minDate, maxDate, [resolveDateValue(value)]);
|
|
2028
|
-
return /* @__PURE__ */
|
|
2368
|
+
return /* @__PURE__ */ jsx25(
|
|
2029
2369
|
DateTimePicker,
|
|
2030
2370
|
{
|
|
2031
2371
|
value: resolveDateValue(value),
|
|
@@ -2039,7 +2379,7 @@ function GdsDateTimeInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
|
2039
2379
|
}
|
|
2040
2380
|
function GdsDateRangeInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
2041
2381
|
warnOnDateBounds("GdsDateRangeInput", minDate, maxDate, value ?? [null, null]);
|
|
2042
|
-
return /* @__PURE__ */
|
|
2382
|
+
return /* @__PURE__ */ jsx25(
|
|
2043
2383
|
DatePickerInput,
|
|
2044
2384
|
{
|
|
2045
2385
|
type: "range",
|
|
@@ -2054,10 +2394,10 @@ function GdsDateRangeInput({ value, onChange, minDate, maxDate, ...rest }) {
|
|
|
2054
2394
|
}
|
|
2055
2395
|
|
|
2056
2396
|
// src/GdsForm.client.tsx
|
|
2057
|
-
import { useGdsTranslation as
|
|
2058
|
-
import { createContext as createContext3, useCallback as
|
|
2397
|
+
import { useGdsTranslation as useGdsTranslation19 } from "@sovereignsquad/gds-theme";
|
|
2398
|
+
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
2399
|
import { Alert, Anchor, Stack as Stack10, Text as Text15 } from "@mantine/core";
|
|
2060
|
-
import { jsx as
|
|
2400
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
2061
2401
|
function createFieldState(value) {
|
|
2062
2402
|
return { value, touched: false, dirty: false };
|
|
2063
2403
|
}
|
|
@@ -2195,13 +2535,13 @@ function useGdsFormOrchestration({
|
|
|
2195
2535
|
onEvent
|
|
2196
2536
|
}) {
|
|
2197
2537
|
const [snapshot, dispatch] = useReducer2(gdsFormReducer, initialValues, createSnapshot);
|
|
2198
|
-
const submitAttempt =
|
|
2199
|
-
const [lastSubmitFailed, setLastSubmitFailed] =
|
|
2200
|
-
const setFieldValue =
|
|
2538
|
+
const submitAttempt = useRef5(0);
|
|
2539
|
+
const [lastSubmitFailed, setLastSubmitFailed] = useState11(false);
|
|
2540
|
+
const setFieldValue = useCallback5((field, value) => {
|
|
2201
2541
|
dispatch({ type: "set-field", field, value });
|
|
2202
2542
|
emitFormEvent(onEvent, "dirty_changed", "idle");
|
|
2203
2543
|
}, [onEvent]);
|
|
2204
|
-
const validateSnapshot =
|
|
2544
|
+
const validateSnapshot = useCallback5(async () => {
|
|
2205
2545
|
dispatch({ type: "set-submit-state", submitState: "validating" });
|
|
2206
2546
|
const syncIssues = sortIssues(validate ? validate(snapshot) : []);
|
|
2207
2547
|
const asyncIssues = syncIssues.some((issue) => issue.severity === "blocking") || !validateAsync ? [] : sortIssues(await validateAsync(snapshot));
|
|
@@ -2214,7 +2554,7 @@ function useGdsFormOrchestration({
|
|
|
2214
2554
|
}
|
|
2215
2555
|
return true;
|
|
2216
2556
|
}, [onEvent, snapshot, validate, validateAsync]);
|
|
2217
|
-
const autosaveDraft =
|
|
2557
|
+
const autosaveDraft = useCallback5(async () => {
|
|
2218
2558
|
if (!draftAdapter) return false;
|
|
2219
2559
|
dispatch({ type: "set-submit-state", submitState: "autosaving" });
|
|
2220
2560
|
await draftAdapter.save(snapshotValues(snapshot));
|
|
@@ -2222,7 +2562,7 @@ function useGdsFormOrchestration({
|
|
|
2222
2562
|
emitFormEvent(onEvent, "autosave_succeeded", "saved");
|
|
2223
2563
|
return true;
|
|
2224
2564
|
}, [draftAdapter, onEvent, snapshot]);
|
|
2225
|
-
const submit =
|
|
2565
|
+
const submit = useCallback5(async () => {
|
|
2226
2566
|
const attempt = submitAttempt.current + 1;
|
|
2227
2567
|
submitAttempt.current = attempt;
|
|
2228
2568
|
const valid = await validateSnapshot();
|
|
@@ -2258,7 +2598,7 @@ function useGdsFormOrchestration({
|
|
|
2258
2598
|
return false;
|
|
2259
2599
|
}
|
|
2260
2600
|
}, [autosave, autosaveDraft, draftAdapter, lastSubmitFailed, mapServerErrors, onEvent, onSubmit, optimisticSubmit, snapshot, validateSnapshot]);
|
|
2261
|
-
const restoreDraft =
|
|
2601
|
+
const restoreDraft = useCallback5(async () => {
|
|
2262
2602
|
const draft = await draftAdapter?.load();
|
|
2263
2603
|
if (!draft) return false;
|
|
2264
2604
|
dispatch({ type: "reset", values: draft });
|
|
@@ -2266,7 +2606,7 @@ function useGdsFormOrchestration({
|
|
|
2266
2606
|
emitFormEvent(onEvent, "draft_restored", "restored");
|
|
2267
2607
|
return true;
|
|
2268
2608
|
}, [draftAdapter, onEvent]);
|
|
2269
|
-
const discardDraft =
|
|
2609
|
+
const discardDraft = useCallback5(async () => {
|
|
2270
2610
|
await draftAdapter?.clear();
|
|
2271
2611
|
}, [draftAdapter]);
|
|
2272
2612
|
return useMemo4(
|
|
@@ -2285,7 +2625,7 @@ function useGdsFormOrchestration({
|
|
|
2285
2625
|
}
|
|
2286
2626
|
var GdsFormContext = createContext3(null);
|
|
2287
2627
|
function GdsFormProvider({ snapshot, children }) {
|
|
2288
|
-
return /* @__PURE__ */
|
|
2628
|
+
return /* @__PURE__ */ jsx26(GdsFormContext.Provider, { value: { snapshot }, children });
|
|
2289
2629
|
}
|
|
2290
2630
|
function useGdsFormSnapshot() {
|
|
2291
2631
|
const context = useContext3(GdsFormContext);
|
|
@@ -2295,14 +2635,14 @@ function useGdsFormSnapshot() {
|
|
|
2295
2635
|
return context.snapshot;
|
|
2296
2636
|
}
|
|
2297
2637
|
function FormErrorSummary({ title: titleProp }) {
|
|
2298
|
-
const { t } =
|
|
2638
|
+
const { t } = useGdsTranslation19();
|
|
2299
2639
|
const title = titleProp ?? t("gds.gdsForm.title", "Please review the following issues.");
|
|
2300
2640
|
const snapshot = useGdsFormSnapshot();
|
|
2301
2641
|
const blocking = snapshot.issues.filter((issue) => issue.severity === "blocking");
|
|
2302
2642
|
if (blocking.length === 0) {
|
|
2303
2643
|
return null;
|
|
2304
2644
|
}
|
|
2305
|
-
return /* @__PURE__ */
|
|
2645
|
+
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
2646
|
}
|
|
2307
2647
|
var GdsValidationSummary = FormErrorSummary;
|
|
2308
2648
|
function ValidatedFieldMessage({ field }) {
|
|
@@ -2311,14 +2651,14 @@ function ValidatedFieldMessage({ field }) {
|
|
|
2311
2651
|
if (!issue) {
|
|
2312
2652
|
return null;
|
|
2313
2653
|
}
|
|
2314
|
-
return /* @__PURE__ */
|
|
2654
|
+
return /* @__PURE__ */ jsx26(Text15, { size: "xs", c: "red.7", id: `${field}-error`, children: issue.message });
|
|
2315
2655
|
}
|
|
2316
2656
|
|
|
2317
2657
|
// src/GdsSchemaForm.client.tsx
|
|
2318
|
-
import { useCallback as
|
|
2658
|
+
import { useCallback as useCallback6, useEffect as useEffect5, useMemo as useMemo5, useRef as useRef6, useState as useState12 } from "react";
|
|
2319
2659
|
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
|
|
2660
|
+
import { useGdsTranslation as useGdsTranslation20 } from "@sovereignsquad/gds-theme";
|
|
2661
|
+
import { jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2322
2662
|
function toIsoDateString(date) {
|
|
2323
2663
|
const year = date.getFullYear();
|
|
2324
2664
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
@@ -2572,23 +2912,23 @@ function FileUploadField({
|
|
|
2572
2912
|
onUploadEvent,
|
|
2573
2913
|
onChange
|
|
2574
2914
|
}) {
|
|
2575
|
-
const abortRef =
|
|
2576
|
-
const lastFilesRef =
|
|
2577
|
-
const [adapterState, setAdapterState] =
|
|
2578
|
-
const [adapterProgress, setAdapterProgress] =
|
|
2579
|
-
const [adapterError, setAdapterError] =
|
|
2915
|
+
const abortRef = useRef6(null);
|
|
2916
|
+
const lastFilesRef = useRef6([]);
|
|
2917
|
+
const [adapterState, setAdapterState] = useState12();
|
|
2918
|
+
const [adapterProgress, setAdapterProgress] = useState12();
|
|
2919
|
+
const [adapterError, setAdapterError] = useState12();
|
|
2580
2920
|
const selectedFiles = getUploadFileNames(value);
|
|
2581
2921
|
const oversize = Array.isArray(value) && maxFileSizeBytes ? value.some((file) => isFileValue(file) && file.size > maxFileSizeBytes) : false;
|
|
2582
2922
|
const effectiveState = adapterState ?? state ?? (oversize ? "too-large" : selectedFiles.length > 0 ? "selected" : "idle");
|
|
2583
2923
|
const effectivePolicyText = oversize ? `One or more files exceed ${maxFileSizeLabel ?? `${maxFileSizeBytes} bytes`}.` : policyText;
|
|
2584
2924
|
const effectiveProgressValue = adapterProgress ?? progressValue;
|
|
2585
|
-
const emitUploadEvent =
|
|
2925
|
+
const emitUploadEvent = useCallback6((type, message) => {
|
|
2586
2926
|
onUploadEvent?.(createSchemaEvent(type, message, field?.name ?? id));
|
|
2587
2927
|
}, [field?.name, id, onUploadEvent]);
|
|
2588
|
-
|
|
2928
|
+
useEffect5(() => () => {
|
|
2589
2929
|
abortRef.current?.abort();
|
|
2590
2930
|
}, []);
|
|
2591
|
-
const uploadFiles =
|
|
2931
|
+
const uploadFiles = useCallback6((files) => {
|
|
2592
2932
|
const selectedOversize = Boolean(maxFileSizeBytes && files.some((file) => file.size > maxFileSizeBytes));
|
|
2593
2933
|
if (!uploadAdapter || !field || selectedOversize) {
|
|
2594
2934
|
onChange?.(files);
|
|
@@ -2680,7 +3020,7 @@ function FileUploadField({
|
|
|
2680
3020
|
emitUploadEvent("upload_failed", error instanceof Error ? error.message : void 0);
|
|
2681
3021
|
});
|
|
2682
3022
|
};
|
|
2683
|
-
return /* @__PURE__ */
|
|
3023
|
+
return /* @__PURE__ */ jsx27(Stack11, { gap: 4, children: /* @__PURE__ */ jsx27(
|
|
2684
3024
|
UploadDropzone,
|
|
2685
3025
|
{
|
|
2686
3026
|
title: label,
|
|
@@ -2699,8 +3039,8 @@ function FileUploadField({
|
|
|
2699
3039
|
progressValue: effectiveProgressValue,
|
|
2700
3040
|
error: adapterError,
|
|
2701
3041
|
mode: "inline",
|
|
2702
|
-
retryAction: effectiveState === "upload-failed" && uploadAdapter ? /* @__PURE__ */
|
|
2703
|
-
removeAction: effectiveState === "upload-pending" && uploadAdapter ? /* @__PURE__ */
|
|
3042
|
+
retryAction: effectiveState === "upload-failed" && uploadAdapter ? /* @__PURE__ */ jsx27(Button9, { size: "xs", variant: "light", onClick: retryUpload, children: "Retry upload" }) : void 0,
|
|
3043
|
+
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
3044
|
onFilesSelected: handleFilesSelected
|
|
2705
3045
|
}
|
|
2706
3046
|
) });
|
|
@@ -2721,7 +3061,7 @@ function CheckboxGroupField({ field, value, setValue, describedBy, invalid }) {
|
|
|
2721
3061
|
const toggle = (optionValue, checked) => {
|
|
2722
3062
|
setValue(checked ? [...selected, optionValue] : selected.filter((entry) => entry !== optionValue));
|
|
2723
3063
|
};
|
|
2724
|
-
return /* @__PURE__ */
|
|
3064
|
+
return /* @__PURE__ */ jsxs18(
|
|
2725
3065
|
"fieldset",
|
|
2726
3066
|
{
|
|
2727
3067
|
"data-gds-checkbox-group": field.name,
|
|
@@ -2729,11 +3069,11 @@ function CheckboxGroupField({ field, value, setValue, describedBy, invalid }) {
|
|
|
2729
3069
|
"aria-invalid": invalid || void 0,
|
|
2730
3070
|
style: { border: 0, margin: 0, padding: 0, minInlineSize: "auto" },
|
|
2731
3071
|
children: [
|
|
2732
|
-
/* @__PURE__ */
|
|
2733
|
-
/* @__PURE__ */
|
|
3072
|
+
/* @__PURE__ */ jsx27("legend", { style: visuallyHidden, children: field.label }),
|
|
3073
|
+
/* @__PURE__ */ jsx27(Stack11, { gap: 6, children: (field.options ?? []).map((option) => (
|
|
2734
3074
|
// Mantine Checkbox (not a raw native input) so the control inherits the GDS
|
|
2735
3075
|
// theme styling and the governed forced-colors remap like every other control.
|
|
2736
|
-
/* @__PURE__ */
|
|
3076
|
+
/* @__PURE__ */ jsx27(
|
|
2737
3077
|
Checkbox,
|
|
2738
3078
|
{
|
|
2739
3079
|
value: option.value,
|
|
@@ -2750,7 +3090,7 @@ function CheckboxGroupField({ field, value, setValue, describedBy, invalid }) {
|
|
|
2750
3090
|
);
|
|
2751
3091
|
}
|
|
2752
3092
|
function RepeatableField({ field, value, setValue, describedBy, invalid, renderers, uploadAdapter, onEvent }) {
|
|
2753
|
-
const { t } =
|
|
3093
|
+
const { t } = useGdsTranslation20();
|
|
2754
3094
|
const rows = Array.isArray(value) ? value : [];
|
|
2755
3095
|
const subFields = field.fields ?? [];
|
|
2756
3096
|
const minRows = field.minRows ?? 0;
|
|
@@ -2759,11 +3099,11 @@ function RepeatableField({ field, value, setValue, describedBy, invalid, rendere
|
|
|
2759
3099
|
const addLabel = field.addRowLabel ?? t("gds.schemaForm.addRow", "Add row");
|
|
2760
3100
|
const removeLabel = field.removeRowLabel ?? t("gds.schemaForm.removeRow", "Remove");
|
|
2761
3101
|
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
|
-
|
|
3102
|
+
const containerRef = useRef6(null);
|
|
3103
|
+
const addButtonRef = useRef6(null);
|
|
3104
|
+
const pendingFocus = useRef6(null);
|
|
3105
|
+
const [announcement, setAnnouncement] = useState12("");
|
|
3106
|
+
useEffect5(() => {
|
|
2767
3107
|
if (pendingFocus.current === "add") {
|
|
2768
3108
|
const lastRow = containerRef.current?.querySelector(`[data-gds-repeatable-row="${rows.length - 1}"]`);
|
|
2769
3109
|
lastRow?.querySelector("input, select, textarea, button")?.focus();
|
|
@@ -2787,11 +3127,11 @@ function RepeatableField({ field, value, setValue, describedBy, invalid, rendere
|
|
|
2787
3127
|
const setRowFieldValue = (index, name, next) => {
|
|
2788
3128
|
setValue(rows.map((row, rowIndex) => rowIndex === index ? { ...row, [name]: next } : row));
|
|
2789
3129
|
};
|
|
2790
|
-
return /* @__PURE__ */
|
|
2791
|
-
rows.map((row, index) => /* @__PURE__ */
|
|
2792
|
-
/* @__PURE__ */
|
|
2793
|
-
/* @__PURE__ */
|
|
2794
|
-
/* @__PURE__ */
|
|
3130
|
+
return /* @__PURE__ */ jsxs18(Stack11, { gap: "sm", ref: containerRef, "data-gds-repeatable": field.name, "aria-describedby": describedBy, "aria-invalid": invalid || void 0, children: [
|
|
3131
|
+
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: [
|
|
3132
|
+
/* @__PURE__ */ jsxs18(Group14, { justify: "space-between", align: "center", wrap: "nowrap", children: [
|
|
3133
|
+
/* @__PURE__ */ jsx27(Text16, { size: "xs", fw: 600, c: "dimmed", children: `${field.label} ${index + 1}` }),
|
|
3134
|
+
/* @__PURE__ */ jsx27(
|
|
2795
3135
|
Button9,
|
|
2796
3136
|
{
|
|
2797
3137
|
type: "button",
|
|
@@ -2814,11 +3154,11 @@ function RepeatableField({ field, value, setValue, describedBy, invalid, rendere
|
|
|
2814
3154
|
invalid: false
|
|
2815
3155
|
};
|
|
2816
3156
|
const subRenderer = renderers[sub.name] ?? renderers[sub.type];
|
|
2817
|
-
return /* @__PURE__ */
|
|
3157
|
+
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
3158
|
})
|
|
2819
3159
|
] }) }, index)),
|
|
2820
|
-
/* @__PURE__ */
|
|
2821
|
-
/* @__PURE__ */
|
|
3160
|
+
/* @__PURE__ */ jsx27(Group14, { children: /* @__PURE__ */ jsx27(Button9, { ref: addButtonRef, type: "button", size: "xs", variant: "light", disabled: !canAdd, onClick: addRow, children: addLabel }) }),
|
|
3161
|
+
/* @__PURE__ */ jsx27("div", { "aria-live": "polite", style: visuallyHidden, children: announcement })
|
|
2822
3162
|
] });
|
|
2823
3163
|
}
|
|
2824
3164
|
function renderDefaultField({ field, value, setValue, describedBy, invalid }, options = {}) {
|
|
@@ -2830,7 +3170,7 @@ function renderDefaultField({ field, value, setValue, describedBy, invalid }, op
|
|
|
2830
3170
|
required: field.required
|
|
2831
3171
|
};
|
|
2832
3172
|
if (field.type === "file-upload") {
|
|
2833
|
-
return /* @__PURE__ */
|
|
3173
|
+
return /* @__PURE__ */ jsx27(
|
|
2834
3174
|
FileUploadField,
|
|
2835
3175
|
{
|
|
2836
3176
|
...common,
|
|
@@ -2852,10 +3192,10 @@ function renderDefaultField({ field, value, setValue, describedBy, invalid }, op
|
|
|
2852
3192
|
);
|
|
2853
3193
|
}
|
|
2854
3194
|
if (field.type === "checkbox-group") {
|
|
2855
|
-
return /* @__PURE__ */
|
|
3195
|
+
return /* @__PURE__ */ jsx27(CheckboxGroupField, { field, value, setValue, describedBy, invalid });
|
|
2856
3196
|
}
|
|
2857
3197
|
if (field.type === "repeatable") {
|
|
2858
|
-
return /* @__PURE__ */
|
|
3198
|
+
return /* @__PURE__ */ jsx27(
|
|
2859
3199
|
RepeatableField,
|
|
2860
3200
|
{
|
|
2861
3201
|
field,
|
|
@@ -2870,17 +3210,17 @@ function renderDefaultField({ field, value, setValue, describedBy, invalid }, op
|
|
|
2870
3210
|
);
|
|
2871
3211
|
}
|
|
2872
3212
|
const textEntryStyle = { fontSize: "max(1rem, 1em)" };
|
|
2873
|
-
if (field.type === "boolean") return /* @__PURE__ */
|
|
2874
|
-
if (field.type === "number") return /* @__PURE__ */
|
|
3213
|
+
if (field.type === "boolean") return /* @__PURE__ */ jsx27("input", { ...common, type: "checkbox", checked: Boolean(value), onChange: (event) => setValue(event.currentTarget.checked) });
|
|
3214
|
+
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
3215
|
if (field.type === "select") {
|
|
2876
|
-
return /* @__PURE__ */
|
|
2877
|
-
/* @__PURE__ */
|
|
2878
|
-
(field.options ?? []).map((option) => /* @__PURE__ */
|
|
3216
|
+
return /* @__PURE__ */ jsxs18("select", { ...common, style: textEntryStyle, value: String(value ?? ""), onChange: (event) => setValue(event.currentTarget.value), children: [
|
|
3217
|
+
/* @__PURE__ */ jsx27("option", { value: "", children: "Select..." }),
|
|
3218
|
+
(field.options ?? []).map((option) => /* @__PURE__ */ jsx27("option", { value: option.value, children: option.label }, option.value))
|
|
2879
3219
|
] });
|
|
2880
3220
|
}
|
|
2881
|
-
if (field.type === "textarea") return /* @__PURE__ */
|
|
3221
|
+
if (field.type === "textarea") return /* @__PURE__ */ jsx27("textarea", { ...common, style: textEntryStyle, value: String(value ?? ""), onChange: (event) => setValue(event.currentTarget.value) });
|
|
2882
3222
|
if (field.type === "date") {
|
|
2883
|
-
return /* @__PURE__ */
|
|
3223
|
+
return /* @__PURE__ */ jsx27(
|
|
2884
3224
|
GdsDateInput,
|
|
2885
3225
|
{
|
|
2886
3226
|
...common,
|
|
@@ -2889,7 +3229,7 @@ function renderDefaultField({ field, value, setValue, describedBy, invalid }, op
|
|
|
2889
3229
|
}
|
|
2890
3230
|
);
|
|
2891
3231
|
}
|
|
2892
|
-
return /* @__PURE__ */
|
|
3232
|
+
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
3233
|
}
|
|
2894
3234
|
function GdsSchemaForm({
|
|
2895
3235
|
schema,
|
|
@@ -2899,7 +3239,7 @@ function GdsSchemaForm({
|
|
|
2899
3239
|
onEvent,
|
|
2900
3240
|
submitLabel: submitLabelProp
|
|
2901
3241
|
}) {
|
|
2902
|
-
const { t } =
|
|
3242
|
+
const { t } = useGdsTranslation20();
|
|
2903
3243
|
const submitLabel = submitLabelProp ?? t("gds.gdsSchemaForm.submitLabel", "Submit");
|
|
2904
3244
|
const initialValues = useMemo5(() => getInitialValues(schema), [schema]);
|
|
2905
3245
|
const form = useGdsFormOrchestration({
|
|
@@ -2915,15 +3255,15 @@ function GdsSchemaForm({
|
|
|
2915
3255
|
},
|
|
2916
3256
|
onEvent
|
|
2917
3257
|
});
|
|
2918
|
-
return /* @__PURE__ */
|
|
2919
|
-
schema.title ? /* @__PURE__ */
|
|
2920
|
-
schema.description ? /* @__PURE__ */
|
|
2921
|
-
/* @__PURE__ */
|
|
3258
|
+
return /* @__PURE__ */ jsx27(GdsFormProvider, { snapshot: form.snapshot, children: /* @__PURE__ */ jsxs18(Stack11, { gap: "md", children: [
|
|
3259
|
+
schema.title ? /* @__PURE__ */ jsx27(Title2, { order: 4, children: schema.title }) : null,
|
|
3260
|
+
schema.description ? /* @__PURE__ */ jsx27(Text16, { size: "sm", c: "dimmed", children: schema.description }) : null,
|
|
3261
|
+
/* @__PURE__ */ jsx27(GdsValidationSummary, {}),
|
|
2922
3262
|
schema.fields.map((field) => {
|
|
2923
3263
|
if (field.hidden || field.type === "hidden") return null;
|
|
2924
3264
|
const issue = form.snapshot.issues.find((item) => item.field === field.name && item.severity === "blocking");
|
|
2925
3265
|
if (field.type === "unsupported" && !renderers[field.name] && !renderers[field.type]) {
|
|
2926
|
-
return /* @__PURE__ */
|
|
3266
|
+
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
3267
|
}
|
|
2928
3268
|
const context = {
|
|
2929
3269
|
field,
|
|
@@ -2933,29 +3273,29 @@ function GdsSchemaForm({
|
|
|
2933
3273
|
invalid: Boolean(issue)
|
|
2934
3274
|
};
|
|
2935
3275
|
const renderer = renderers[field.name] ?? renderers[field.type];
|
|
2936
|
-
return /* @__PURE__ */
|
|
3276
|
+
return /* @__PURE__ */ jsxs18(
|
|
2937
3277
|
FormField,
|
|
2938
3278
|
{
|
|
2939
3279
|
label: `${field.label}${field.required ? ` ${t("gds.schemaForm.requiredMarker", "(required)")}` : ""}`,
|
|
2940
|
-
description: field.description ? /* @__PURE__ */
|
|
3280
|
+
description: field.description ? /* @__PURE__ */ jsx27(Text16, { id: `${field.name}-description`, size: "xs", c: "dimmed", children: field.description }) : void 0,
|
|
2941
3281
|
children: [
|
|
2942
3282
|
renderer ? renderer(context) : renderDefaultField(context, { uploadAdapter, onEvent, renderers }),
|
|
2943
|
-
/* @__PURE__ */
|
|
3283
|
+
/* @__PURE__ */ jsx27("span", { id: `${field.name}-error`, children: /* @__PURE__ */ jsx27(ValidatedFieldMessage, { field: field.name }) })
|
|
2944
3284
|
]
|
|
2945
3285
|
},
|
|
2946
3286
|
field.name
|
|
2947
3287
|
);
|
|
2948
3288
|
}),
|
|
2949
|
-
/* @__PURE__ */
|
|
3289
|
+
/* @__PURE__ */ jsx27(Button9, { type: "button", onClick: () => {
|
|
2950
3290
|
void form.submit();
|
|
2951
3291
|
}, loading: form.snapshot.submitState === "validating" || form.snapshot.submitState === "submitting" || form.snapshot.submitState === "optimistic", children: submitLabel })
|
|
2952
3292
|
] }) });
|
|
2953
3293
|
}
|
|
2954
3294
|
|
|
2955
3295
|
// 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
|
|
3296
|
+
import { useMemo as useMemo6, useState as useState13 } from "react";
|
|
3297
|
+
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";
|
|
3298
|
+
import { jsx as jsx28, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2959
3299
|
function compareValues(a, b) {
|
|
2960
3300
|
if (typeof a === "number" && typeof b === "number") {
|
|
2961
3301
|
return a - b;
|
|
@@ -2978,9 +3318,9 @@ function AdvancedDataTable({
|
|
|
2978
3318
|
onSortChange,
|
|
2979
3319
|
responsiveFallback = "stacked-cards"
|
|
2980
3320
|
}) {
|
|
2981
|
-
const [densityState, setDensityState] =
|
|
2982
|
-
const [sortState, setSortState] =
|
|
2983
|
-
const [selectionState, setSelectionState] =
|
|
3321
|
+
const [densityState, setDensityState] = useState13(densityProp ?? "comfortable");
|
|
3322
|
+
const [sortState, setSortState] = useState13({ key: sortByProp ?? null, direction: sortDirectionProp ?? "asc" });
|
|
3323
|
+
const [selectionState, setSelectionState] = useState13([]);
|
|
2984
3324
|
const density = densityProp ?? densityState;
|
|
2985
3325
|
const sortBy = sortByProp ?? sortState.key;
|
|
2986
3326
|
const sortDirection = sortDirectionProp ?? sortState.direction;
|
|
@@ -3004,13 +3344,13 @@ function AdvancedDataTable({
|
|
|
3004
3344
|
const allIds = useMemo6(() => sortedRows.map((row, index) => rowId(row, index)), [sortedRows, rowId]);
|
|
3005
3345
|
const allSelected = allIds.length > 0 && allIds.every((id) => selection.includes(id));
|
|
3006
3346
|
if (error) {
|
|
3007
|
-
return /* @__PURE__ */
|
|
3347
|
+
return /* @__PURE__ */ jsx28(StateBlock, { variant: "error", title: "Unable to load table", description: error, compact: true });
|
|
3008
3348
|
}
|
|
3009
3349
|
if (loading) {
|
|
3010
|
-
return /* @__PURE__ */
|
|
3350
|
+
return /* @__PURE__ */ jsx28(StateBlock, { variant: "loading", title: "Loading table", description: "Preparing enterprise data grid.", compact: true });
|
|
3011
3351
|
}
|
|
3012
3352
|
if (!rows.length) {
|
|
3013
|
-
return /* @__PURE__ */
|
|
3353
|
+
return /* @__PURE__ */ jsx28(
|
|
3014
3354
|
StateBlock,
|
|
3015
3355
|
{
|
|
3016
3356
|
variant: "empty",
|
|
@@ -3020,15 +3360,15 @@ function AdvancedDataTable({
|
|
|
3020
3360
|
}
|
|
3021
3361
|
);
|
|
3022
3362
|
}
|
|
3023
|
-
const horizontalSpacing = density === "compact" ? "xs" : "
|
|
3363
|
+
const horizontalSpacing = density === "compact" ? "xs" : "sm";
|
|
3024
3364
|
const verticalSpacing = density === "compact" ? 6 : 10;
|
|
3025
|
-
return /* @__PURE__ */
|
|
3026
|
-
/* @__PURE__ */
|
|
3027
|
-
/* @__PURE__ */
|
|
3365
|
+
return /* @__PURE__ */ jsxs19(Stack12, { gap: "sm", children: [
|
|
3366
|
+
/* @__PURE__ */ jsxs19(Group15, { justify: "space-between", align: "center", children: [
|
|
3367
|
+
/* @__PURE__ */ jsxs19(Text17, { size: "sm", fw: 600, children: [
|
|
3028
3368
|
rows.length,
|
|
3029
3369
|
" rows"
|
|
3030
3370
|
] }),
|
|
3031
|
-
/* @__PURE__ */
|
|
3371
|
+
/* @__PURE__ */ jsx28(
|
|
3032
3372
|
SegmentedControl2,
|
|
3033
3373
|
{
|
|
3034
3374
|
size: "xs",
|
|
@@ -3041,8 +3381,8 @@ function AdvancedDataTable({
|
|
|
3041
3381
|
}
|
|
3042
3382
|
)
|
|
3043
3383
|
] }),
|
|
3044
|
-
/* @__PURE__ */
|
|
3045
|
-
|
|
3384
|
+
/* @__PURE__ */ jsx28(ScrollArea2, { children: /* @__PURE__ */ jsxs19(
|
|
3385
|
+
Table3,
|
|
3046
3386
|
{
|
|
3047
3387
|
stickyHeader,
|
|
3048
3388
|
stickyHeaderOffset,
|
|
@@ -3052,8 +3392,8 @@ function AdvancedDataTable({
|
|
|
3052
3392
|
horizontalSpacing,
|
|
3053
3393
|
verticalSpacing,
|
|
3054
3394
|
children: [
|
|
3055
|
-
/* @__PURE__ */
|
|
3056
|
-
/* @__PURE__ */
|
|
3395
|
+
/* @__PURE__ */ jsx28(Table3.Thead, { children: /* @__PURE__ */ jsxs19(Table3.Tr, { children: [
|
|
3396
|
+
/* @__PURE__ */ jsx28(Table3.Th, { children: /* @__PURE__ */ jsx28(
|
|
3057
3397
|
Checkbox2,
|
|
3058
3398
|
{
|
|
3059
3399
|
className: "gds-touch-target-pad-checkbox",
|
|
@@ -3071,7 +3411,7 @@ function AdvancedDataTable({
|
|
|
3071
3411
|
}
|
|
3072
3412
|
}
|
|
3073
3413
|
) }),
|
|
3074
|
-
columns.map((column) => /* @__PURE__ */
|
|
3414
|
+
columns.map((column) => /* @__PURE__ */ jsx28(Table3.Th, { style: column.width ? { width: column.width } : void 0, children: column.sortable ? /* @__PURE__ */ jsx28(
|
|
3075
3415
|
"button",
|
|
3076
3416
|
{
|
|
3077
3417
|
type: "button",
|
|
@@ -3088,11 +3428,11 @@ function AdvancedDataTable({
|
|
|
3088
3428
|
}
|
|
3089
3429
|
) : column.label }, column.key))
|
|
3090
3430
|
] }) }),
|
|
3091
|
-
/* @__PURE__ */
|
|
3431
|
+
/* @__PURE__ */ jsx28(Table3.Tbody, { children: sortedRows.map((row, index) => {
|
|
3092
3432
|
const id = rowId(row, index);
|
|
3093
3433
|
const checked = selection.includes(id);
|
|
3094
|
-
return /* @__PURE__ */
|
|
3095
|
-
/* @__PURE__ */
|
|
3434
|
+
return /* @__PURE__ */ jsxs19(Table3.Tr, { children: [
|
|
3435
|
+
/* @__PURE__ */ jsx28(Table3.Td, { children: /* @__PURE__ */ jsx28(
|
|
3096
3436
|
Checkbox2,
|
|
3097
3437
|
{
|
|
3098
3438
|
"aria-label": `Select row ${id}`,
|
|
@@ -3107,15 +3447,15 @@ function AdvancedDataTable({
|
|
|
3107
3447
|
}
|
|
3108
3448
|
}
|
|
3109
3449
|
) }),
|
|
3110
|
-
columns.map((column) => /* @__PURE__ */
|
|
3450
|
+
columns.map((column) => /* @__PURE__ */ jsx28(Table3.Td, { children: column.render ? column.render(row) : String(row[column.key] ?? "") }, column.key))
|
|
3111
3451
|
] }, id);
|
|
3112
3452
|
}) })
|
|
3113
3453
|
]
|
|
3114
3454
|
}
|
|
3115
3455
|
) }),
|
|
3116
|
-
responsiveFallback === "stacked-cards" ? /* @__PURE__ */
|
|
3456
|
+
responsiveFallback === "stacked-cards" ? /* @__PURE__ */ jsx28(Stack12, { gap: "xs", children: sortedRows.slice(0, 3).map((row, index) => {
|
|
3117
3457
|
const id = rowId(row, index);
|
|
3118
|
-
return /* @__PURE__ */
|
|
3458
|
+
return /* @__PURE__ */ jsx28(
|
|
3119
3459
|
StateBlock,
|
|
3120
3460
|
{
|
|
3121
3461
|
variant: "info",
|
|
@@ -3130,10 +3470,10 @@ function AdvancedDataTable({
|
|
|
3130
3470
|
}
|
|
3131
3471
|
|
|
3132
3472
|
// 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
|
|
3473
|
+
import { useGdsTranslation as useGdsTranslation21 } from "@sovereignsquad/gds-theme";
|
|
3474
|
+
import { useCallback as useCallback7, useEffect as useEffect6, useMemo as useMemo7, useRef as useRef7, useState as useState14 } from "react";
|
|
3475
|
+
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";
|
|
3476
|
+
import { jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
3137
3477
|
function emitTableEvent(onEvent, type, message) {
|
|
3138
3478
|
onEvent?.({ type, message, timestamp: Date.now(), privacy: "metadata-only" });
|
|
3139
3479
|
}
|
|
@@ -3196,14 +3536,14 @@ function useGdsDataTable({
|
|
|
3196
3536
|
timeoutMs = 8e3,
|
|
3197
3537
|
virtualizedRowLimit
|
|
3198
3538
|
}) {
|
|
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
|
-
|
|
3539
|
+
const [query, setQuery] = useState14(() => createDefaultQuery(initialQuery));
|
|
3540
|
+
const [rows, setRows] = useState14([]);
|
|
3541
|
+
const [total, setTotal] = useState14(0);
|
|
3542
|
+
const [status, setStatus] = useState14("idle");
|
|
3543
|
+
const [error, setError] = useState14();
|
|
3544
|
+
const [selectedRowIds, setSelectedRowIds] = useState14([]);
|
|
3545
|
+
const [reloadKey, setReloadKey] = useState14(0);
|
|
3546
|
+
useEffect6(() => {
|
|
3207
3547
|
const controller = new AbortController();
|
|
3208
3548
|
const timer = window.setTimeout(() => controller.abort(), timeoutMs);
|
|
3209
3549
|
setStatus((current) => current === "ready" || current === "partial" ? "refreshing" : "loading");
|
|
@@ -3229,12 +3569,12 @@ function useGdsDataTable({
|
|
|
3229
3569
|
window.clearTimeout(timer);
|
|
3230
3570
|
};
|
|
3231
3571
|
}, [adapter, onEvent, query, reloadKey, rowId, timeoutMs]);
|
|
3232
|
-
const setSearch =
|
|
3572
|
+
const setSearch = useCallback7((value) => {
|
|
3233
3573
|
setQuery((current) => ({ ...current, search: value, page: 1 }));
|
|
3234
3574
|
setSelectedRowIds([]);
|
|
3235
3575
|
emitTableEvent(onEvent, "filter_changed");
|
|
3236
3576
|
}, [onEvent]);
|
|
3237
|
-
const setSort =
|
|
3577
|
+
const setSort = useCallback7((columnKey) => {
|
|
3238
3578
|
setQuery((current) => ({
|
|
3239
3579
|
...current,
|
|
3240
3580
|
sortBy: columnKey,
|
|
@@ -3244,23 +3584,23 @@ function useGdsDataTable({
|
|
|
3244
3584
|
setSelectedRowIds([]);
|
|
3245
3585
|
emitTableEvent(onEvent, "sort_changed");
|
|
3246
3586
|
}, [onEvent]);
|
|
3247
|
-
const setPage =
|
|
3248
|
-
const setPageSize =
|
|
3249
|
-
const setFilter =
|
|
3587
|
+
const setPage = useCallback7((page) => setQuery((current) => ({ ...current, page: Math.max(1, Math.floor(page)) })), []);
|
|
3588
|
+
const setPageSize = useCallback7((pageSize) => setQuery((current) => ({ ...current, page: 1, pageSize: Math.max(1, Math.floor(pageSize)) })), []);
|
|
3589
|
+
const setFilter = useCallback7((columnKey, value) => {
|
|
3250
3590
|
setQuery((current) => ({ ...current, filters: { ...current.filters, [columnKey]: value }, page: 1 }));
|
|
3251
3591
|
setSelectedRowIds([]);
|
|
3252
3592
|
emitTableEvent(onEvent, "filter_changed");
|
|
3253
3593
|
}, [onEvent]);
|
|
3254
3594
|
const visibleRows = useMemo7(() => rows.slice(0, virtualizedRowLimit ?? rows.length), [rows, virtualizedRowLimit]);
|
|
3255
3595
|
const visibleIds = useMemo7(() => visibleRows.map((row, index) => rowId(row, index)), [rowId, visibleRows]);
|
|
3256
|
-
const toggleRow =
|
|
3596
|
+
const toggleRow = useCallback7((id) => {
|
|
3257
3597
|
setSelectedRowIds((current) => {
|
|
3258
3598
|
const next = current.includes(id) ? current.filter((item) => item !== id) : [...current, id];
|
|
3259
3599
|
emitTableEvent(onEvent, "selection_changed");
|
|
3260
3600
|
return next;
|
|
3261
3601
|
});
|
|
3262
3602
|
}, [onEvent]);
|
|
3263
|
-
const toggleAllVisible =
|
|
3603
|
+
const toggleAllVisible = useCallback7(() => {
|
|
3264
3604
|
setSelectedRowIds((current) => {
|
|
3265
3605
|
const allSelected = visibleIds.length > 0 && visibleIds.every((id) => current.includes(id));
|
|
3266
3606
|
const next = allSelected ? current.filter((id) => !visibleIds.includes(id)) : [.../* @__PURE__ */ new Set([...current, ...visibleIds])];
|
|
@@ -3268,7 +3608,7 @@ function useGdsDataTable({
|
|
|
3268
3608
|
return next;
|
|
3269
3609
|
});
|
|
3270
3610
|
}, [onEvent, visibleIds]);
|
|
3271
|
-
const exportRows =
|
|
3611
|
+
const exportRows = useCallback7(async () => {
|
|
3272
3612
|
setStatus("exporting");
|
|
3273
3613
|
emitTableEvent(onEvent, "export_requested");
|
|
3274
3614
|
await onExport?.({ query, rows, selectedRowIds });
|
|
@@ -3307,9 +3647,9 @@ function getInteractiveCellElements(cell) {
|
|
|
3307
3647
|
return Array.from(cell.querySelectorAll(interactiveCellSelector)).filter((element) => !element.hasAttribute("hidden") && element.getAttribute("aria-hidden") !== "true");
|
|
3308
3648
|
}
|
|
3309
3649
|
function useGdsTableKeyNav(rowCount, columnCount) {
|
|
3310
|
-
const tbodyRef =
|
|
3311
|
-
const [focusedCell, setFocusedCell] =
|
|
3312
|
-
const focusCell =
|
|
3650
|
+
const tbodyRef = useRef7(null);
|
|
3651
|
+
const [focusedCell, setFocusedCell] = useState14(rowCount > 0 && columnCount > 0 ? { rowIndex: 0, columnIndex: 0 } : null);
|
|
3652
|
+
const focusCell = useCallback7((rowIndex, columnIndex) => {
|
|
3313
3653
|
const rows = tbodyRef.current?.querySelectorAll("tr[data-gds-row]") ?? [];
|
|
3314
3654
|
const nextRowIndex = Math.max(0, Math.min(rowIndex, rows.length - 1));
|
|
3315
3655
|
const cells = rows[nextRowIndex]?.querySelectorAll("[data-gds-cell]") ?? [];
|
|
@@ -3318,7 +3658,7 @@ function useGdsTableKeyNav(rowCount, columnCount) {
|
|
|
3318
3658
|
setFocusedCell({ rowIndex: nextRowIndex, columnIndex: nextColumnIndex });
|
|
3319
3659
|
cells[nextColumnIndex]?.focus();
|
|
3320
3660
|
}, []);
|
|
3321
|
-
const handleKeyDown =
|
|
3661
|
+
const handleKeyDown = useCallback7((event) => {
|
|
3322
3662
|
const rows = tbodyRef.current?.querySelectorAll("tr[data-gds-row]") ?? [];
|
|
3323
3663
|
if (rows.length === 0 || columnCount === 0) return;
|
|
3324
3664
|
const target = event.target instanceof HTMLElement ? event.target : null;
|
|
@@ -3362,7 +3702,7 @@ function useGdsTableKeyNav(rowCount, columnCount) {
|
|
|
3362
3702
|
focusCell(event.ctrlKey || event.metaKey ? lastRow : current.rowIndex, lastColumn);
|
|
3363
3703
|
}
|
|
3364
3704
|
}, [columnCount, focusCell, focusedCell]);
|
|
3365
|
-
|
|
3705
|
+
useEffect6(() => {
|
|
3366
3706
|
setFocusedCell(rowCount > 0 && columnCount > 0 ? { rowIndex: 0, columnIndex: 0 } : null);
|
|
3367
3707
|
}, [columnCount, rowCount]);
|
|
3368
3708
|
return { tbodyRef, handleKeyDown, focusedCell, setFocusedCell };
|
|
@@ -3382,7 +3722,7 @@ function GdsDataTable({
|
|
|
3382
3722
|
retryLabel: retryLabelProp,
|
|
3383
3723
|
mobileCards = true
|
|
3384
3724
|
}) {
|
|
3385
|
-
const { t } =
|
|
3725
|
+
const { t } = useGdsTranslation21();
|
|
3386
3726
|
const caption = captionProp ?? t("gds.gdsDataTable.caption", "Data table");
|
|
3387
3727
|
const exportLabel = exportLabelProp ?? t("gds.gdsDataTable.exportLabel", "Export");
|
|
3388
3728
|
const retryLabel = retryLabelProp ?? t("gds.gdsDataTable.retryLabel", "Retry");
|
|
@@ -3392,50 +3732,50 @@ function GdsDataTable({
|
|
|
3392
3732
|
const gridColumnCount = visibleColumns.length + 1;
|
|
3393
3733
|
const { tbodyRef, handleKeyDown, focusedCell, setFocusedCell } = useGdsTableKeyNav(table.visibleRows.length, gridColumnCount);
|
|
3394
3734
|
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__ */
|
|
3735
|
+
if (table.status === "loading") return /* @__PURE__ */ jsx29(StateBlock, { variant: "loading", title: "Loading table", description: "Preparing governed data rows.", compact: true });
|
|
3736
|
+
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 });
|
|
3737
|
+
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 });
|
|
3738
|
+
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 });
|
|
3739
|
+
return /* @__PURE__ */ jsxs20(Stack13, { gap: "sm", children: [
|
|
3740
|
+
/* @__PURE__ */ jsxs20(Group16, { justify: "space-between", align: "end", children: [
|
|
3741
|
+
/* @__PURE__ */ jsxs20(Stack13, { gap: 2, children: [
|
|
3742
|
+
/* @__PURE__ */ jsx29(Text18, { size: "sm", fw: 700, children: caption }),
|
|
3743
|
+
summary ? /* @__PURE__ */ jsx29(Text18, { size: "xs", c: "dimmed", children: summary }) : null,
|
|
3744
|
+
/* @__PURE__ */ jsxs20(Text18, { size: "xs", c: "dimmed", children: [
|
|
3405
3745
|
table.total,
|
|
3406
3746
|
" rows",
|
|
3407
3747
|
table.status === "partial" ? " (partial data)" : ""
|
|
3408
3748
|
] })
|
|
3409
3749
|
] }),
|
|
3410
|
-
/* @__PURE__ */
|
|
3411
|
-
/* @__PURE__ */
|
|
3412
|
-
/* @__PURE__ */
|
|
3750
|
+
/* @__PURE__ */ jsxs20(Group16, { gap: "xs", children: [
|
|
3751
|
+
/* @__PURE__ */ jsx29(TextInput2, { "aria-label": "Search rows", placeholder: "Search rows", value: table.query.search, onChange: (event) => table.setSearch(event.currentTarget.value) }),
|
|
3752
|
+
/* @__PURE__ */ jsx29(Button10, { variant: "light", onClick: () => {
|
|
3413
3753
|
void table.exportRows();
|
|
3414
3754
|
}, loading: table.status === "exporting", children: exportLabel })
|
|
3415
3755
|
] })
|
|
3416
3756
|
] }),
|
|
3417
|
-
/* @__PURE__ */
|
|
3418
|
-
/* @__PURE__ */
|
|
3419
|
-
/* @__PURE__ */
|
|
3420
|
-
/* @__PURE__ */
|
|
3421
|
-
visibleColumns.map((column) => /* @__PURE__ */
|
|
3757
|
+
/* @__PURE__ */ jsx29(ScrollArea3, { children: /* @__PURE__ */ jsxs20(Table4, { withTableBorder: true, striped: true, highlightOnHover: true, role: "grid", "aria-label": caption, "aria-rowcount": table.total, children: [
|
|
3758
|
+
/* @__PURE__ */ jsx29("caption", { children: caption }),
|
|
3759
|
+
/* @__PURE__ */ jsx29(Table4.Thead, { children: /* @__PURE__ */ jsxs20(Table4.Tr, { children: [
|
|
3760
|
+
/* @__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 }) }),
|
|
3761
|
+
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
3762
|
] }) }),
|
|
3423
|
-
/* @__PURE__ */
|
|
3424
|
-
|
|
3763
|
+
/* @__PURE__ */ jsx29(
|
|
3764
|
+
Table4.Tbody,
|
|
3425
3765
|
{
|
|
3426
3766
|
ref: tbodyRef,
|
|
3427
3767
|
onKeyDown: handleKeyDown,
|
|
3428
3768
|
children: table.visibleRows.map((row, rowIndex) => {
|
|
3429
3769
|
const id = rowId(row, rowIndex);
|
|
3430
|
-
return /* @__PURE__ */
|
|
3431
|
-
|
|
3770
|
+
return /* @__PURE__ */ jsxs20(
|
|
3771
|
+
Table4.Tr,
|
|
3432
3772
|
{
|
|
3433
3773
|
"data-gds-row": true,
|
|
3434
3774
|
"aria-selected": table.selectedRowIds.includes(id),
|
|
3435
3775
|
"aria-rowindex": (table.query.page - 1) * table.query.pageSize + rowIndex + 2,
|
|
3436
3776
|
children: [
|
|
3437
|
-
/* @__PURE__ */
|
|
3438
|
-
|
|
3777
|
+
/* @__PURE__ */ jsx29(
|
|
3778
|
+
Table4.Td,
|
|
3439
3779
|
{
|
|
3440
3780
|
role: "gridcell",
|
|
3441
3781
|
"data-gds-cell": true,
|
|
@@ -3445,14 +3785,14 @@ function GdsDataTable({
|
|
|
3445
3785
|
"aria-colindex": 1,
|
|
3446
3786
|
onFocus: () => setFocusedCell({ rowIndex, columnIndex: 0 }),
|
|
3447
3787
|
style: focusedCell?.rowIndex === rowIndex && focusedCell.columnIndex === 0 ? { outline: "2px solid var(--mantine-color-blue-5)", outlineOffset: "-2px" } : void 0,
|
|
3448
|
-
children: /* @__PURE__ */
|
|
3788
|
+
children: /* @__PURE__ */ jsx29(Checkbox3, { "aria-label": `Select row ${id}`, checked: table.selectedRowIds.includes(id), onChange: () => table.toggleRow(id), tabIndex: -1 })
|
|
3449
3789
|
}
|
|
3450
3790
|
),
|
|
3451
3791
|
visibleColumns.map((column, columnIndex) => {
|
|
3452
3792
|
const gridColumnIndex = columnIndex + 1;
|
|
3453
3793
|
const isCellFocused = focusedCell?.rowIndex === rowIndex && focusedCell.columnIndex === gridColumnIndex;
|
|
3454
|
-
return /* @__PURE__ */
|
|
3455
|
-
|
|
3794
|
+
return /* @__PURE__ */ jsx29(
|
|
3795
|
+
Table4.Td,
|
|
3456
3796
|
{
|
|
3457
3797
|
role: "gridcell",
|
|
3458
3798
|
"data-gds-cell": true,
|
|
@@ -3477,24 +3817,24 @@ function GdsDataTable({
|
|
|
3477
3817
|
}
|
|
3478
3818
|
)
|
|
3479
3819
|
] }) }),
|
|
3480
|
-
/* @__PURE__ */
|
|
3481
|
-
virtualizedRowLimit && table.rows.length > table.visibleRows.length ? /* @__PURE__ */
|
|
3820
|
+
/* @__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` : "" }),
|
|
3821
|
+
virtualizedRowLimit && table.rows.length > table.visibleRows.length ? /* @__PURE__ */ jsxs20(Text18, { size: "xs", c: "dimmed", children: [
|
|
3482
3822
|
table.visibleRows.length,
|
|
3483
3823
|
" of ",
|
|
3484
3824
|
table.rows.length,
|
|
3485
3825
|
" rows rendered in the virtualized window."
|
|
3486
3826
|
] }) : null,
|
|
3487
|
-
/* @__PURE__ */
|
|
3488
|
-
/* @__PURE__ */
|
|
3827
|
+
/* @__PURE__ */ jsxs20(Group16, { justify: "space-between", children: [
|
|
3828
|
+
/* @__PURE__ */ jsxs20(Text18, { size: "xs", c: "dimmed", children: [
|
|
3489
3829
|
table.selectedRowIds.length,
|
|
3490
3830
|
" selected"
|
|
3491
3831
|
] }),
|
|
3492
|
-
/* @__PURE__ */
|
|
3832
|
+
/* @__PURE__ */ jsx29(Pagination, { total: pageCount, value: table.query.page, onChange: table.setPage, size: "sm" })
|
|
3493
3833
|
] }),
|
|
3494
|
-
mobileCards ? /* @__PURE__ */
|
|
3834
|
+
mobileCards ? /* @__PURE__ */ jsx29(Stack13, { gap: "xs", "aria-label": "Mobile row cards", children: table.visibleRows.slice(0, 6).map((row, index) => {
|
|
3495
3835
|
const ordered = [...visibleColumns].sort((left, right) => (left.mobilePriority ?? 99) - (right.mobilePriority ?? 99));
|
|
3496
3836
|
const id = rowId(row, index);
|
|
3497
|
-
return /* @__PURE__ */
|
|
3837
|
+
return /* @__PURE__ */ jsx29(
|
|
3498
3838
|
StateBlock,
|
|
3499
3839
|
{
|
|
3500
3840
|
variant: "info",
|
|
@@ -3509,10 +3849,10 @@ function GdsDataTable({
|
|
|
3509
3849
|
}
|
|
3510
3850
|
|
|
3511
3851
|
// src/GdsResourceManager.client.tsx
|
|
3512
|
-
import { useGdsTranslation as
|
|
3513
|
-
import { useCallback as
|
|
3852
|
+
import { useGdsTranslation as useGdsTranslation22 } from "@sovereignsquad/gds-theme";
|
|
3853
|
+
import { useCallback as useCallback8, useEffect as useEffect7, useMemo as useMemo8, useState as useState15 } from "react";
|
|
3514
3854
|
import { Button as Button11, Group as Group17, Stack as Stack14, Text as Text19 } from "@mantine/core";
|
|
3515
|
-
import { jsx as
|
|
3855
|
+
import { jsx as jsx30, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
3516
3856
|
function emitResourceEvent(onEvent, event) {
|
|
3517
3857
|
onEvent?.({ ...event, timestamp: Date.now(), privacy: "metadata-only" });
|
|
3518
3858
|
}
|
|
@@ -3574,12 +3914,12 @@ function useGdsResourceManager({
|
|
|
3574
3914
|
timeoutMs = 8e3,
|
|
3575
3915
|
confirmAction
|
|
3576
3916
|
}) {
|
|
3577
|
-
const [resources, setResources] =
|
|
3578
|
-
const [selectedResource, setSelectedResource] =
|
|
3579
|
-
const [state, setState] =
|
|
3580
|
-
const [error, setError] =
|
|
3581
|
-
const [reloadKey, setReloadKey] =
|
|
3582
|
-
|
|
3917
|
+
const [resources, setResources] = useState15([]);
|
|
3918
|
+
const [selectedResource, setSelectedResource] = useState15(null);
|
|
3919
|
+
const [state, setState] = useState15("loading-list");
|
|
3920
|
+
const [error, setError] = useState15();
|
|
3921
|
+
const [reloadKey, setReloadKey] = useState15(0);
|
|
3922
|
+
useEffect7(() => {
|
|
3583
3923
|
const controller = new AbortController();
|
|
3584
3924
|
const timer = window.setTimeout(() => controller.abort(), timeoutMs);
|
|
3585
3925
|
setState("loading-list");
|
|
@@ -3599,12 +3939,12 @@ function useGdsResourceManager({
|
|
|
3599
3939
|
window.clearTimeout(timer);
|
|
3600
3940
|
};
|
|
3601
3941
|
}, [adapter, onEvent, reloadKey, timeoutMs]);
|
|
3602
|
-
const loadList =
|
|
3942
|
+
const loadList = useCallback8(() => setReloadKey((value) => value + 1), []);
|
|
3603
3943
|
const permissions = useMemo8(() => adapter.getPermissions?.(selectedResource) ?? defaultPermissions(selectedResource), [adapter, selectedResource]);
|
|
3604
|
-
const canRunAction =
|
|
3944
|
+
const canRunAction = useCallback8((action, resource = selectedResource) => {
|
|
3605
3945
|
return (adapter.getPermissions?.(resource) ?? defaultPermissions(resource)).find((permission) => permission.action === action) ?? { action, allowed: false, reason: "Action is not available." };
|
|
3606
3946
|
}, [adapter, selectedResource]);
|
|
3607
|
-
const openDetail =
|
|
3947
|
+
const openDetail = useCallback8(async (id) => {
|
|
3608
3948
|
setState("detail-loading");
|
|
3609
3949
|
try {
|
|
3610
3950
|
const resource = adapter.detail ? await adapter.detail(id) : resources.find((item) => item.id === id) ?? null;
|
|
@@ -3625,7 +3965,7 @@ function useGdsResourceManager({
|
|
|
3625
3965
|
return null;
|
|
3626
3966
|
}
|
|
3627
3967
|
}, [adapter, onEvent, resources]);
|
|
3628
|
-
const runAction =
|
|
3968
|
+
const runAction = useCallback8(async (action, resource, values = {}) => {
|
|
3629
3969
|
const permission = canRunAction(action, resource);
|
|
3630
3970
|
if (!permission.allowed) {
|
|
3631
3971
|
setState("permission-denied");
|
|
@@ -3691,7 +4031,7 @@ function GdsResourceManager({
|
|
|
3691
4031
|
timeoutMs,
|
|
3692
4032
|
confirmAction
|
|
3693
4033
|
}) {
|
|
3694
|
-
const { t } =
|
|
4034
|
+
const { t } = useGdsTranslation22();
|
|
3695
4035
|
const emptyLabel = emptyLabelProp ?? t("gds.gdsResourceManager.emptyLabel", "No resources available");
|
|
3696
4036
|
const manager = useGdsResourceManager({ adapter, onEvent, timeoutMs, confirmAction });
|
|
3697
4037
|
const tableColumns = useMemo8(() => columns ?? [
|
|
@@ -3700,21 +4040,21 @@ function GdsResourceManager({
|
|
|
3700
4040
|
{ key: "updatedAt", label: "Updated", sortable: true, mobilePriority: 3 }
|
|
3701
4041
|
], [columns]);
|
|
3702
4042
|
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__ */
|
|
4043
|
+
if (manager.state === "loading-list") return /* @__PURE__ */ jsx30(StateBlock, { variant: "loading", title: "Loading resources", description: "Preparing the governed resource list.", compact: true });
|
|
4044
|
+
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 });
|
|
4045
|
+
if (manager.state === "empty") return /* @__PURE__ */ jsx30(StateBlock, { variant: "empty", title: emptyLabel, description: "Create or import a resource to continue.", compact: true });
|
|
4046
|
+
return /* @__PURE__ */ jsxs21(Stack14, { gap: "md", children: [
|
|
4047
|
+
/* @__PURE__ */ jsxs21(Group17, { justify: "space-between", align: "start", children: [
|
|
4048
|
+
/* @__PURE__ */ jsxs21(Stack14, { gap: 2, children: [
|
|
4049
|
+
/* @__PURE__ */ jsx30(Text19, { fw: 700, children: title }),
|
|
4050
|
+
description ? /* @__PURE__ */ jsx30(Text19, { size: "sm", c: "dimmed", children: description }) : null,
|
|
4051
|
+
manager.error ? /* @__PURE__ */ jsx30(Text19, { role: "alert", size: "sm", c: "red.7", children: manager.error }) : null
|
|
3712
4052
|
] }),
|
|
3713
|
-
/* @__PURE__ */
|
|
4053
|
+
/* @__PURE__ */ jsx30(Button11, { onClick: () => {
|
|
3714
4054
|
void manager.runAction("create", null, { title: "Untitled resource" });
|
|
3715
4055
|
}, children: "Create" })
|
|
3716
4056
|
] }),
|
|
3717
|
-
/* @__PURE__ */
|
|
4057
|
+
/* @__PURE__ */ jsx30(
|
|
3718
4058
|
GdsDataTable,
|
|
3719
4059
|
{
|
|
3720
4060
|
caption: `${title} resources`,
|
|
@@ -3723,17 +4063,17 @@ function GdsResourceManager({
|
|
|
3723
4063
|
{
|
|
3724
4064
|
key: "id",
|
|
3725
4065
|
label: "Actions",
|
|
3726
|
-
render: (row) => /* @__PURE__ */
|
|
3727
|
-
/* @__PURE__ */
|
|
4066
|
+
render: (row) => /* @__PURE__ */ jsxs21(Group17, { gap: "xs", children: [
|
|
4067
|
+
/* @__PURE__ */ jsx30(Button11, { size: "xs", variant: "light", onClick: () => {
|
|
3728
4068
|
void manager.openDetail(row.id);
|
|
3729
4069
|
}, children: "Details" }),
|
|
3730
|
-
/* @__PURE__ */
|
|
4070
|
+
/* @__PURE__ */ jsx30(Button11, { size: "xs", variant: "light", onClick: () => {
|
|
3731
4071
|
void manager.runAction("activate", row);
|
|
3732
4072
|
}, disabled: !manager.canRunAction("activate", row).allowed, children: "Activate" }),
|
|
3733
|
-
/* @__PURE__ */
|
|
4073
|
+
/* @__PURE__ */ jsx30(Button11, { size: "xs", variant: "light", color: "red", onClick: () => {
|
|
3734
4074
|
void manager.runAction("delete", row);
|
|
3735
4075
|
}, disabled: !manager.canRunAction("delete", row).allowed, children: "Delete" }),
|
|
3736
|
-
/* @__PURE__ */
|
|
4076
|
+
/* @__PURE__ */ jsx30(Button11, { size: "xs", variant: "subtle", onClick: () => {
|
|
3737
4077
|
void manager.runAction("copy-preview", row);
|
|
3738
4078
|
}, disabled: !manager.canRunAction("copy-preview", row).allowed, children: "Copy preview" })
|
|
3739
4079
|
] })
|
|
@@ -3744,7 +4084,7 @@ function GdsResourceManager({
|
|
|
3744
4084
|
onEvent: (event) => onEvent?.({ type: event.type === "load_failed" ? "action_failed" : "resource_loaded", timestamp: event.timestamp, privacy: "metadata-only", message: event.message })
|
|
3745
4085
|
}
|
|
3746
4086
|
),
|
|
3747
|
-
manager.selectedResource ? /* @__PURE__ */
|
|
4087
|
+
manager.selectedResource ? /* @__PURE__ */ jsx30("section", { "aria-label": `${manager.selectedResource.title} detail`, children: renderDetail ? renderDetail(manager.selectedResource, manager) : /* @__PURE__ */ jsx30(
|
|
3748
4088
|
StateBlock,
|
|
3749
4089
|
{
|
|
3750
4090
|
variant: "info",
|
|
@@ -3757,10 +4097,10 @@ function GdsResourceManager({
|
|
|
3757
4097
|
}
|
|
3758
4098
|
|
|
3759
4099
|
// src/OverlayManager.client.tsx
|
|
3760
|
-
import { createContext as createContext4, useCallback as
|
|
4100
|
+
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
4101
|
import { Drawer, Modal as Modal2 } from "@mantine/core";
|
|
3762
|
-
import { getGdsMotionPreset, gdsDevWarnOnce as gdsDevWarnOnce4, useGdsTranslation as
|
|
3763
|
-
import { jsx as
|
|
4102
|
+
import { getGdsMotionPreset, gdsDevWarnOnce as gdsDevWarnOnce4, useGdsTranslation as useGdsTranslation23 } from "@sovereignsquad/gds-theme";
|
|
4103
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
3764
4104
|
var defaultOverlayPolicy = {
|
|
3765
4105
|
closeOnEscape: true,
|
|
3766
4106
|
closeOnOutsideClick: true,
|
|
@@ -3802,13 +4142,13 @@ function OverlayManagerProvider({
|
|
|
3802
4142
|
routeKey,
|
|
3803
4143
|
onOverlayEvent
|
|
3804
4144
|
}) {
|
|
3805
|
-
const [stack, setStack] =
|
|
3806
|
-
const focusReturnTargets =
|
|
3807
|
-
const previousRouteKey =
|
|
3808
|
-
const emit =
|
|
4145
|
+
const [stack, setStack] = useState16([]);
|
|
4146
|
+
const focusReturnTargets = useRef8(/* @__PURE__ */ new Map());
|
|
4147
|
+
const previousRouteKey = useRef8(routeKey);
|
|
4148
|
+
const emit = useCallback9((type, item, reason) => {
|
|
3809
4149
|
onOverlayEvent?.(createOverlayEvent(type, item, reason));
|
|
3810
4150
|
}, [onOverlayEvent]);
|
|
3811
|
-
const registerOverlay =
|
|
4151
|
+
const registerOverlay = useCallback9((overlay) => {
|
|
3812
4152
|
const policy = normalizePolicy(defaultPolicy, overlay.policy);
|
|
3813
4153
|
const focusTarget = getFocusableElement(overlay.invokerId);
|
|
3814
4154
|
if (policy.returnFocus && focusTarget) {
|
|
@@ -3828,7 +4168,7 @@ function OverlayManagerProvider({
|
|
|
3828
4168
|
return [...base, item];
|
|
3829
4169
|
});
|
|
3830
4170
|
}, [defaultPolicy, emit, singleOverlayMode]);
|
|
3831
|
-
const unregisterOverlay =
|
|
4171
|
+
const unregisterOverlay = useCallback9((id, reason = "programmatic") => {
|
|
3832
4172
|
setStack((current) => {
|
|
3833
4173
|
const target = current.find((item) => item.id === id);
|
|
3834
4174
|
if (target) {
|
|
@@ -3842,8 +4182,8 @@ function OverlayManagerProvider({
|
|
|
3842
4182
|
focusReturnTargets.current.delete(id);
|
|
3843
4183
|
}
|
|
3844
4184
|
}, [emit]);
|
|
3845
|
-
const isTopMost =
|
|
3846
|
-
const requestClose =
|
|
4185
|
+
const isTopMost = useCallback9((id) => stack.length > 0 && stack[stack.length - 1]?.id === id, [stack]);
|
|
4186
|
+
const requestClose = useCallback9((id, reason) => {
|
|
3847
4187
|
const target = stack.find((item) => item.id === id);
|
|
3848
4188
|
if (!target || !isTopMost(id)) {
|
|
3849
4189
|
if (target) emit("blocked_close", { ...target, status: "blocked-close" }, reason);
|
|
@@ -3860,13 +4200,13 @@ function OverlayManagerProvider({
|
|
|
3860
4200
|
}
|
|
3861
4201
|
return reason;
|
|
3862
4202
|
}, [defaultPolicy, emit, isTopMost, stack]);
|
|
3863
|
-
const closeOverlay =
|
|
4203
|
+
const closeOverlay = useCallback9((id, reason = "programmatic") => {
|
|
3864
4204
|
const acceptedReason = requestClose(id, reason);
|
|
3865
4205
|
if (!acceptedReason) return false;
|
|
3866
4206
|
unregisterOverlay(id, acceptedReason);
|
|
3867
4207
|
return true;
|
|
3868
4208
|
}, [requestClose, unregisterOverlay]);
|
|
3869
|
-
|
|
4209
|
+
useEffect8(() => {
|
|
3870
4210
|
if (previousRouteKey.current === routeKey) return;
|
|
3871
4211
|
previousRouteKey.current = routeKey;
|
|
3872
4212
|
setStack((current) => {
|
|
@@ -3893,7 +4233,7 @@ function OverlayManagerProvider({
|
|
|
3893
4233
|
getOverlay: (id) => stack.find((item) => item.id === id),
|
|
3894
4234
|
requestClose
|
|
3895
4235
|
}), [closeOverlay, isTopMost, registerOverlay, requestClose, stack, unregisterOverlay]);
|
|
3896
|
-
return /* @__PURE__ */
|
|
4236
|
+
return /* @__PURE__ */ jsx31(OverlayManagerContext.Provider, { value, children });
|
|
3897
4237
|
}
|
|
3898
4238
|
function useOverlayManager() {
|
|
3899
4239
|
const context = useContext4(OverlayManagerContext);
|
|
@@ -3923,12 +4263,12 @@ function useOverlaySurface({
|
|
|
3923
4263
|
const registerOverlay = manager?.registerOverlay;
|
|
3924
4264
|
const unregisterOverlay = manager?.unregisterOverlay;
|
|
3925
4265
|
const requestOverlayClose = manager?.requestClose;
|
|
3926
|
-
|
|
4266
|
+
useEffect8(() => {
|
|
3927
4267
|
if (!registerOverlay || !unregisterOverlay || !opened) return void 0;
|
|
3928
4268
|
registerOverlay({ id, kind, title, description, invokerId, policy });
|
|
3929
4269
|
return () => unregisterOverlay(id);
|
|
3930
4270
|
}, [description, id, invokerId, kind, opened, policy, registerOverlay, title, unregisterOverlay]);
|
|
3931
|
-
const requestClose =
|
|
4271
|
+
const requestClose = useCallback9((reason) => {
|
|
3932
4272
|
if (!requestOverlayClose || !unregisterOverlay) {
|
|
3933
4273
|
onClose();
|
|
3934
4274
|
return;
|
|
@@ -3957,8 +4297,8 @@ function GdsModal({
|
|
|
3957
4297
|
}) {
|
|
3958
4298
|
const requestClose = useOverlaySurface({ id, opened, kind: "modal", title, description, children, invokerId, policy, onClose, onBlockedClose });
|
|
3959
4299
|
const motion = getGdsMotionPreset("overlay");
|
|
3960
|
-
const { t } =
|
|
3961
|
-
return /* @__PURE__ */
|
|
4300
|
+
const { t } = useGdsTranslation23();
|
|
4301
|
+
return /* @__PURE__ */ jsx31(
|
|
3962
4302
|
Modal2,
|
|
3963
4303
|
{
|
|
3964
4304
|
...modalProps,
|
|
@@ -3989,8 +4329,8 @@ function GdsDrawer({
|
|
|
3989
4329
|
}) {
|
|
3990
4330
|
const requestClose = useOverlaySurface({ id, opened, kind: "drawer", title, description, children, invokerId, policy, onClose, onBlockedClose });
|
|
3991
4331
|
const motion = getGdsMotionPreset("drawer");
|
|
3992
|
-
const { t } =
|
|
3993
|
-
return /* @__PURE__ */
|
|
4332
|
+
const { t } = useGdsTranslation23();
|
|
4333
|
+
return /* @__PURE__ */ jsx31(
|
|
3994
4334
|
Drawer,
|
|
3995
4335
|
{
|
|
3996
4336
|
...drawerProps,
|
|
@@ -4009,20 +4349,20 @@ function GdsDrawer({
|
|
|
4009
4349
|
);
|
|
4010
4350
|
}
|
|
4011
4351
|
function GdsSheet(props) {
|
|
4012
|
-
return /* @__PURE__ */
|
|
4352
|
+
return /* @__PURE__ */ jsx31(GdsDrawer, { ...props, position: props.position ?? "bottom", policy: { mobileFullscreen: true, ...props.policy } });
|
|
4013
4353
|
}
|
|
4014
4354
|
function GdsDialog(props) {
|
|
4015
|
-
return /* @__PURE__ */
|
|
4355
|
+
return /* @__PURE__ */ jsx31(GdsModal, { ...props });
|
|
4016
4356
|
}
|
|
4017
4357
|
function GdsSidePanel(props) {
|
|
4018
|
-
return /* @__PURE__ */
|
|
4358
|
+
return /* @__PURE__ */ jsx31(GdsDrawer, { ...props, position: props.position ?? "right" });
|
|
4019
4359
|
}
|
|
4020
4360
|
|
|
4021
4361
|
// src/Notifications.client.tsx
|
|
4022
|
-
import { gdsSafeAreaInset, gdsZIndexToken, useGdsTranslation as
|
|
4362
|
+
import { gdsSafeAreaInset, gdsZIndexToken, useGdsTranslation as useGdsTranslation24 } from "@sovereignsquad/gds-theme";
|
|
4023
4363
|
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
|
|
4364
|
+
import { createContext as createContext5, useCallback as useCallback10, useContext as useContext5, useMemo as useMemo10, useRef as useRef9, useState as useState17 } from "react";
|
|
4365
|
+
import { jsx as jsx32, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
4026
4366
|
var GdsNotificationContext = createContext5(null);
|
|
4027
4367
|
function shouldAutoClose(message) {
|
|
4028
4368
|
if (message.autoCloseMs === false) return false;
|
|
@@ -4053,13 +4393,13 @@ function GdsNotificationProvider({
|
|
|
4053
4393
|
defaultPolicy,
|
|
4054
4394
|
onAuditEvent
|
|
4055
4395
|
}) {
|
|
4056
|
-
const [notifications, setNotifications] =
|
|
4057
|
-
const [announcement, setAnnouncement] =
|
|
4058
|
-
const timers =
|
|
4059
|
-
const audit =
|
|
4396
|
+
const [notifications, setNotifications] = useState17([]);
|
|
4397
|
+
const [announcement, setAnnouncement] = useState17(null);
|
|
4398
|
+
const timers = useRef9(/* @__PURE__ */ new Map());
|
|
4399
|
+
const audit = useCallback10((type, notification, metadata = {}) => {
|
|
4060
4400
|
onAuditEvent?.(createGdsNotificationAuditEvent(type, notification, metadata));
|
|
4061
4401
|
}, [onAuditEvent]);
|
|
4062
|
-
const scheduleAutoClose =
|
|
4402
|
+
const scheduleAutoClose = useCallback10((message) => {
|
|
4063
4403
|
const existingTimer = timers.current.get(message.id);
|
|
4064
4404
|
if (existingTimer) {
|
|
4065
4405
|
window.clearTimeout(existingTimer);
|
|
@@ -4076,7 +4416,7 @@ function GdsNotificationProvider({
|
|
|
4076
4416
|
}, message.autoCloseMs);
|
|
4077
4417
|
timers.current.set(message.id, timer);
|
|
4078
4418
|
}, [audit]);
|
|
4079
|
-
const updateNotification =
|
|
4419
|
+
const updateNotification = useCallback10((id, patch) => {
|
|
4080
4420
|
setNotifications((current) => current.map((item) => {
|
|
4081
4421
|
if (item.id !== id) return item;
|
|
4082
4422
|
const updated = normalizeNotification({ ...item, ...patch, id }, defaultPolicy);
|
|
@@ -4085,7 +4425,7 @@ function GdsNotificationProvider({
|
|
|
4085
4425
|
return updated;
|
|
4086
4426
|
}));
|
|
4087
4427
|
}, [audit, defaultPolicy, scheduleAutoClose]);
|
|
4088
|
-
const dismissNotification =
|
|
4428
|
+
const dismissNotification = useCallback10((id) => {
|
|
4089
4429
|
setNotifications((current) => {
|
|
4090
4430
|
const target = current.find((item) => item.id === id);
|
|
4091
4431
|
if (target) audit("dismissed", { ...target, status: "dismissed" });
|
|
@@ -4097,7 +4437,7 @@ function GdsNotificationProvider({
|
|
|
4097
4437
|
return current.filter((item) => item.id !== id);
|
|
4098
4438
|
});
|
|
4099
4439
|
}, [audit]);
|
|
4100
|
-
const notify =
|
|
4440
|
+
const notify = useCallback10((message, policy) => {
|
|
4101
4441
|
const mergedPolicy = { ...defaultPolicy, ...policy };
|
|
4102
4442
|
const next = normalizeNotification(message, mergedPolicy);
|
|
4103
4443
|
audit("shown", next);
|
|
@@ -4168,9 +4508,9 @@ function GdsNotificationProvider({
|
|
|
4168
4508
|
}
|
|
4169
4509
|
}), [audit, dismissNotification, notifications, notify, updateNotification]);
|
|
4170
4510
|
const livePolicy = announcement ? getGdsNotificationLivePolicy(announcement) : "polite";
|
|
4171
|
-
return /* @__PURE__ */
|
|
4511
|
+
return /* @__PURE__ */ jsxs22(GdsNotificationContext.Provider, { value, children: [
|
|
4172
4512
|
children,
|
|
4173
|
-
/* @__PURE__ */
|
|
4513
|
+
/* @__PURE__ */ jsx32(
|
|
4174
4514
|
"span",
|
|
4175
4515
|
{
|
|
4176
4516
|
role: announcement?.severity === "error" ? "alert" : "status",
|
|
@@ -4203,7 +4543,7 @@ function NotificationCenter({
|
|
|
4203
4543
|
title: titleProp,
|
|
4204
4544
|
emptyMessage: emptyMessageProp
|
|
4205
4545
|
}) {
|
|
4206
|
-
const { t } =
|
|
4546
|
+
const { t } = useGdsTranslation24();
|
|
4207
4547
|
const title = titleProp ?? t("gds.notifications.title", "Notifications");
|
|
4208
4548
|
const emptyMessage = emptyMessageProp ?? t("gds.notifications.emptyMessage", "No active notifications.");
|
|
4209
4549
|
const {
|
|
@@ -4213,7 +4553,7 @@ function NotificationCenter({
|
|
|
4213
4553
|
runRetry,
|
|
4214
4554
|
runAction
|
|
4215
4555
|
} = useGdsNotifications();
|
|
4216
|
-
return /* @__PURE__ */
|
|
4556
|
+
return /* @__PURE__ */ jsx32(
|
|
4217
4557
|
NotificationCenterView,
|
|
4218
4558
|
{
|
|
4219
4559
|
live: false,
|
|
@@ -4233,7 +4573,7 @@ function NotificationCenter({
|
|
|
4233
4573
|
}
|
|
4234
4574
|
var GdsNotificationCenter = NotificationCenter;
|
|
4235
4575
|
function GdsToastViewport({ position = "bottom-end", maxVisible = 3 }) {
|
|
4236
|
-
const { t } =
|
|
4576
|
+
const { t } = useGdsTranslation24();
|
|
4237
4577
|
const { notifications, dismissNotification, runAction, runRetry } = useGdsNotifications();
|
|
4238
4578
|
const visible = notifications.filter((item) => item.persistence !== "announcement-only" && !item.announcementOnly);
|
|
4239
4579
|
if (visible.length === 0) return null;
|
|
@@ -4242,7 +4582,7 @@ function GdsToastViewport({ position = "bottom-end", maxVisible = 3 }) {
|
|
|
4242
4582
|
const [vertical, horizontal] = position.split("-");
|
|
4243
4583
|
const sideInset = `calc(var(--gds-space-md) + max(${gdsSafeAreaInset.left}, ${gdsSafeAreaInset.right}))`;
|
|
4244
4584
|
const edgeInset = `calc(var(--gds-space-md) + ${vertical === "top" ? gdsSafeAreaInset.top : gdsSafeAreaInset.bottom})`;
|
|
4245
|
-
return /* @__PURE__ */
|
|
4585
|
+
return /* @__PURE__ */ jsx32(
|
|
4246
4586
|
Box10,
|
|
4247
4587
|
{
|
|
4248
4588
|
component: "section",
|
|
@@ -4259,9 +4599,9 @@ function GdsToastViewport({ position = "bottom-end", maxVisible = 3 }) {
|
|
|
4259
4599
|
justifyContent: horizontal === "end" ? "flex-end" : "flex-start",
|
|
4260
4600
|
pointerEvents: "none"
|
|
4261
4601
|
},
|
|
4262
|
-
children: /* @__PURE__ */
|
|
4263
|
-
hiddenCount > 0 ? /* @__PURE__ */
|
|
4264
|
-
shown.map((item) => /* @__PURE__ */
|
|
4602
|
+
children: /* @__PURE__ */ jsxs22(GdsStack, { gap: "sm", maxWidth: "aside", style: { inlineSize: "100%", pointerEvents: "auto" }, children: [
|
|
4603
|
+
hiddenCount > 0 ? /* @__PURE__ */ jsx32(Text20, { size: "xs", c: "dimmed", children: t("gds.toast.more", "{count} more").replace("{count}", String(hiddenCount)) }) : null,
|
|
4604
|
+
shown.map((item) => /* @__PURE__ */ jsx32(
|
|
4265
4605
|
InlineAlert,
|
|
4266
4606
|
{
|
|
4267
4607
|
live: false,
|
|
@@ -4269,10 +4609,10 @@ function GdsToastViewport({ position = "bottom-end", maxVisible = 3 }) {
|
|
|
4269
4609
|
status: item.status,
|
|
4270
4610
|
title: item.title,
|
|
4271
4611
|
message: item.message,
|
|
4272
|
-
action: /* @__PURE__ */
|
|
4273
|
-
item.actions?.map((action) => /* @__PURE__ */
|
|
4274
|
-
item.retry ? /* @__PURE__ */
|
|
4275
|
-
/* @__PURE__ */
|
|
4612
|
+
action: /* @__PURE__ */ jsxs22(Group18, { gap: "xs", children: [
|
|
4613
|
+
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)),
|
|
4614
|
+
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,
|
|
4615
|
+
/* @__PURE__ */ jsx32(Button12, { size: "xs", variant: "subtle", onClick: () => dismissNotification(item.id), children: t("gds.notifications.dismiss", "Dismiss") })
|
|
4276
4616
|
] })
|
|
4277
4617
|
},
|
|
4278
4618
|
item.id
|
|
@@ -4283,10 +4623,10 @@ function GdsToastViewport({ position = "bottom-end", maxVisible = 3 }) {
|
|
|
4283
4623
|
}
|
|
4284
4624
|
|
|
4285
4625
|
// src/FeedbackRuntime.client.tsx
|
|
4286
|
-
import { createContext as createContext6, useCallback as
|
|
4287
|
-
import { useGdsTranslation as
|
|
4626
|
+
import { createContext as createContext6, useCallback as useCallback11, useContext as useContext6, useMemo as useMemo11, useRef as useRef10, useState as useState18 } from "react";
|
|
4627
|
+
import { useGdsTranslation as useGdsTranslation25 } from "@sovereignsquad/gds-theme";
|
|
4288
4628
|
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
|
|
4629
|
+
import { Fragment as Fragment6, jsx as jsx33, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4290
4630
|
var GdsConfirmContext = createContext6(null);
|
|
4291
4631
|
function createConfirmationEvent(type, request, status) {
|
|
4292
4632
|
return {
|
|
@@ -4308,21 +4648,21 @@ function GdsConfirmProvider({
|
|
|
4308
4648
|
defaultTimeoutMs = 1e4,
|
|
4309
4649
|
onConfirmationEvent
|
|
4310
4650
|
}) {
|
|
4311
|
-
const { t } =
|
|
4312
|
-
const [activeRequest, setActiveRequest] =
|
|
4313
|
-
const [undoState, setUndoState] =
|
|
4314
|
-
const activeResolver =
|
|
4315
|
-
const actionResolver =
|
|
4316
|
-
const focusReturnTarget =
|
|
4317
|
-
const emit =
|
|
4651
|
+
const { t } = useGdsTranslation25();
|
|
4652
|
+
const [activeRequest, setActiveRequest] = useState18(null);
|
|
4653
|
+
const [undoState, setUndoState] = useState18(null);
|
|
4654
|
+
const activeResolver = useRef10(null);
|
|
4655
|
+
const actionResolver = useRef10(null);
|
|
4656
|
+
const focusReturnTarget = useRef10(null);
|
|
4657
|
+
const emit = useCallback11((type, request, status) => {
|
|
4318
4658
|
onConfirmationEvent?.(createConfirmationEvent(type, request, status));
|
|
4319
4659
|
}, [onConfirmationEvent]);
|
|
4320
|
-
const restoreFocus =
|
|
4660
|
+
const restoreFocus = useCallback11(() => {
|
|
4321
4661
|
const target = focusReturnTarget.current;
|
|
4322
4662
|
focusReturnTarget.current = null;
|
|
4323
4663
|
if (target) window.setTimeout(() => target.focus(), 0);
|
|
4324
4664
|
}, []);
|
|
4325
|
-
const openConfirm =
|
|
4665
|
+
const openConfirm = useCallback11((request) => new Promise((resolve) => {
|
|
4326
4666
|
if (activeResolver.current) {
|
|
4327
4667
|
activeResolver.current(false);
|
|
4328
4668
|
}
|
|
@@ -4331,7 +4671,7 @@ function GdsConfirmProvider({
|
|
|
4331
4671
|
emit("opened", request, "open");
|
|
4332
4672
|
setActiveRequest({ ...request, mode: "boolean", status: "open", resolve });
|
|
4333
4673
|
}), [emit]);
|
|
4334
|
-
const openActionConfirm =
|
|
4674
|
+
const openActionConfirm = useCallback11((request) => new Promise((resolve) => {
|
|
4335
4675
|
if (actionResolver.current) {
|
|
4336
4676
|
actionResolver.current({ status: "cancelled" });
|
|
4337
4677
|
}
|
|
@@ -4349,7 +4689,7 @@ function GdsConfirmProvider({
|
|
|
4349
4689
|
resolve: resolver
|
|
4350
4690
|
});
|
|
4351
4691
|
}), [emit]);
|
|
4352
|
-
const resolveActive =
|
|
4692
|
+
const resolveActive = useCallback11((confirmed) => {
|
|
4353
4693
|
if (activeRequest?.mode === "boolean") {
|
|
4354
4694
|
emit(confirmed ? "confirmed" : "cancelled", activeRequest, confirmed ? "succeeded" : "cancelled");
|
|
4355
4695
|
}
|
|
@@ -4358,7 +4698,7 @@ function GdsConfirmProvider({
|
|
|
4358
4698
|
setActiveRequest(null);
|
|
4359
4699
|
restoreFocus();
|
|
4360
4700
|
}, [activeRequest, emit, restoreFocus]);
|
|
4361
|
-
const cancelAction =
|
|
4701
|
+
const cancelAction = useCallback11(() => {
|
|
4362
4702
|
if (activeRequest?.mode === "action") {
|
|
4363
4703
|
emit("cancelled", activeRequest, "cancelled");
|
|
4364
4704
|
actionResolver.current?.({ status: "cancelled", payload: activeRequest.payload });
|
|
@@ -4367,7 +4707,7 @@ function GdsConfirmProvider({
|
|
|
4367
4707
|
setActiveRequest(null);
|
|
4368
4708
|
restoreFocus();
|
|
4369
4709
|
}, [activeRequest, emit, restoreFocus]);
|
|
4370
|
-
const runAction =
|
|
4710
|
+
const runAction = useCallback11(async (retry = false) => {
|
|
4371
4711
|
if (!activeRequest || activeRequest.mode !== "action") return;
|
|
4372
4712
|
const request = activeRequest;
|
|
4373
4713
|
if (retry) emit("retry", request, "executing");
|
|
@@ -4422,18 +4762,18 @@ function GdsConfirmProvider({
|
|
|
4422
4762
|
confirmDestructive: (request) => openConfirm({ ...request, danger: true, confirmAction: request.confirmAction ?? "delete" }),
|
|
4423
4763
|
confirmAction: openActionConfirm
|
|
4424
4764
|
}), [openActionConfirm, openConfirm]);
|
|
4425
|
-
return /* @__PURE__ */
|
|
4765
|
+
return /* @__PURE__ */ jsxs23(GdsConfirmContext.Provider, { value, children: [
|
|
4426
4766
|
children,
|
|
4427
|
-
undoState ? /* @__PURE__ */
|
|
4428
|
-
/* @__PURE__ */
|
|
4429
|
-
/* @__PURE__ */
|
|
4430
|
-
/* @__PURE__ */
|
|
4767
|
+
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: [
|
|
4768
|
+
/* @__PURE__ */ jsxs23(Stack15, { gap: 2, children: [
|
|
4769
|
+
/* @__PURE__ */ jsx33(Text21, { fw: 700, size: "sm", children: t("gds.confirm.undoTitle", "Action can be undone") }),
|
|
4770
|
+
/* @__PURE__ */ jsx33(Text21, { size: "sm", children: t("gds.confirm.undoDescription", "Undo is available until the recovery window expires.") })
|
|
4431
4771
|
] }),
|
|
4432
|
-
/* @__PURE__ */
|
|
4772
|
+
/* @__PURE__ */ jsx33(Button13, { size: "xs", variant: "default", onClick: () => {
|
|
4433
4773
|
void undoState.onUndo();
|
|
4434
4774
|
}, children: undoState.label ?? t("gds.confirm.undo", "Undo") })
|
|
4435
4775
|
] }) }) : null,
|
|
4436
|
-
/* @__PURE__ */
|
|
4776
|
+
/* @__PURE__ */ jsx33(
|
|
4437
4777
|
ConfirmDialog,
|
|
4438
4778
|
{
|
|
4439
4779
|
opened: Boolean(activeRequest),
|
|
@@ -4444,18 +4784,18 @@ function GdsConfirmProvider({
|
|
|
4444
4784
|
cancelAction: activeRequest?.cancelAction ?? "cancel",
|
|
4445
4785
|
isDanger: activeRequest?.danger ?? false,
|
|
4446
4786
|
loading: activeRequest?.status === "executing" || activeRequest?.status === "validating",
|
|
4447
|
-
children: /* @__PURE__ */
|
|
4448
|
-
activeRequest?.targetName ? /* @__PURE__ */
|
|
4449
|
-
activeRequest?.targetName ? /* @__PURE__ */
|
|
4787
|
+
children: /* @__PURE__ */ jsxs23(Stack15, { gap: "xs", children: [
|
|
4788
|
+
activeRequest?.targetName ? /* @__PURE__ */ jsx33("strong", { children: activeRequest.targetName }) : null,
|
|
4789
|
+
activeRequest?.targetName ? /* @__PURE__ */ jsx33("br", {}) : null,
|
|
4450
4790
|
activeRequest?.message,
|
|
4451
|
-
activeRequest?.consequence ? /* @__PURE__ */
|
|
4452
|
-
/* @__PURE__ */
|
|
4791
|
+
activeRequest?.consequence ? /* @__PURE__ */ jsxs23(Fragment6, { children: [
|
|
4792
|
+
/* @__PURE__ */ jsx33("br", {}),
|
|
4453
4793
|
activeRequest.consequence
|
|
4454
4794
|
] }) : null,
|
|
4455
|
-
activeRequest?.mode === "action" && activeRequest.preview ? /* @__PURE__ */
|
|
4456
|
-
activeRequest?.mode === "action" && activeRequest.status === "failed" ? /* @__PURE__ */
|
|
4457
|
-
/* @__PURE__ */
|
|
4458
|
-
activeRequest.retryable ? /* @__PURE__ */
|
|
4795
|
+
activeRequest?.mode === "action" && activeRequest.preview ? /* @__PURE__ */ jsx33("div", { children: activeRequest.preview }) : null,
|
|
4796
|
+
activeRequest?.mode === "action" && activeRequest.status === "failed" ? /* @__PURE__ */ jsxs23(Alert2, { color: "red", title: t("gds.confirm.failedTitle", "Action failed"), role: "alert", children: [
|
|
4797
|
+
/* @__PURE__ */ jsx33(Text21, { size: "sm", children: activeRequest.error ?? t("gds.confirm.failedDescription", "The action did not complete.") }),
|
|
4798
|
+
activeRequest.retryable ? /* @__PURE__ */ jsx33(Text21, { size: "xs", children: t("gds.confirm.retryHint", "Use the primary action to retry.") }) : null
|
|
4459
4799
|
] }) : null
|
|
4460
4800
|
] })
|
|
4461
4801
|
}
|
|
@@ -4474,9 +4814,9 @@ function createToastId(prefix) {
|
|
|
4474
4814
|
return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
4475
4815
|
}
|
|
4476
4816
|
function GdsToastProvider({ children, viewport = true }) {
|
|
4477
|
-
return /* @__PURE__ */
|
|
4478
|
-
/* @__PURE__ */
|
|
4479
|
-
viewport ? /* @__PURE__ */
|
|
4817
|
+
return /* @__PURE__ */ jsxs23(GdsNotificationProvider, { children: [
|
|
4818
|
+
/* @__PURE__ */ jsx33(GdsToastProviderInner, { children }),
|
|
4819
|
+
viewport ? /* @__PURE__ */ jsx33(GdsToastViewport, { ...viewport === true ? {} : viewport }) : null
|
|
4480
4820
|
] });
|
|
4481
4821
|
}
|
|
4482
4822
|
function GdsToastProviderInner({ children }) {
|
|
@@ -4502,7 +4842,7 @@ function GdsToastProviderInner({ children }) {
|
|
|
4502
4842
|
autoCloseMs: message.autoCloseMs ?? 3e3
|
|
4503
4843
|
})
|
|
4504
4844
|
}), [notify]);
|
|
4505
|
-
return /* @__PURE__ */
|
|
4845
|
+
return /* @__PURE__ */ jsx33(GdsToastContext.Provider, { value, children });
|
|
4506
4846
|
}
|
|
4507
4847
|
function useGdsToasts() {
|
|
4508
4848
|
const context = useContext6(GdsToastContext);
|
|
@@ -4513,9 +4853,9 @@ function useGdsToasts() {
|
|
|
4513
4853
|
}
|
|
4514
4854
|
|
|
4515
4855
|
// src/CommandPalette.client.tsx
|
|
4516
|
-
import { createContext as createContext7, useContext as useContext7, useEffect as
|
|
4856
|
+
import { createContext as createContext7, useContext as useContext7, useEffect as useEffect9, useMemo as useMemo12, useState as useState19 } from "react";
|
|
4517
4857
|
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
|
|
4858
|
+
import { jsx as jsx34, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
4519
4859
|
var CommandPaletteContext = createContext7(null);
|
|
4520
4860
|
function normalize(text) {
|
|
4521
4861
|
return text.trim().toLowerCase();
|
|
@@ -4533,17 +4873,17 @@ function scoreCommand(command, query, recentUse) {
|
|
|
4533
4873
|
return 0.6 * prefix + 0.3 * keyword + 0.1 * recent;
|
|
4534
4874
|
}
|
|
4535
4875
|
function CommandRegistryProvider({ children }) {
|
|
4536
|
-
const [commands, setCommands] =
|
|
4537
|
-
const [opened, setOpened] =
|
|
4876
|
+
const [commands, setCommands] = useState19([]);
|
|
4877
|
+
const [opened, setOpened] = useState19(false);
|
|
4538
4878
|
const value = useMemo12(() => ({
|
|
4539
4879
|
commands,
|
|
4540
4880
|
registerCommands: (next) => setCommands(next),
|
|
4541
4881
|
open: () => setOpened(true),
|
|
4542
4882
|
close: () => setOpened(false)
|
|
4543
4883
|
}), [commands]);
|
|
4544
|
-
return /* @__PURE__ */
|
|
4884
|
+
return /* @__PURE__ */ jsxs24(CommandPaletteContext.Provider, { value, children: [
|
|
4545
4885
|
children,
|
|
4546
|
-
/* @__PURE__ */
|
|
4886
|
+
/* @__PURE__ */ jsx34(CommandPalette, { opened, onClose: () => setOpened(false) })
|
|
4547
4887
|
] });
|
|
4548
4888
|
}
|
|
4549
4889
|
function useCommandLauncher() {
|
|
@@ -4563,11 +4903,11 @@ function CommandPalette({ opened, onClose }) {
|
|
|
4563
4903
|
throw new Error("CommandPalette must be used within CommandRegistryProvider.");
|
|
4564
4904
|
}
|
|
4565
4905
|
const registry = contextValue;
|
|
4566
|
-
const [query, setQuery] =
|
|
4567
|
-
const [recentUse, setRecentUse] =
|
|
4906
|
+
const [query, setQuery] = useState19("");
|
|
4907
|
+
const [recentUse, setRecentUse] = useState19({});
|
|
4568
4908
|
const enabledCommands = registry.commands.filter((command) => command.enabledWhen ? command.enabledWhen() : true);
|
|
4569
4909
|
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
|
-
|
|
4910
|
+
useEffect9(() => {
|
|
4571
4911
|
function onKeyDown(event) {
|
|
4572
4912
|
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
|
|
4573
4913
|
event.preventDefault();
|
|
@@ -4580,8 +4920,8 @@ function CommandPalette({ opened, onClose }) {
|
|
|
4580
4920
|
window.addEventListener("keydown", onKeyDown);
|
|
4581
4921
|
return () => window.removeEventListener("keydown", onKeyDown);
|
|
4582
4922
|
}, [registry, opened, onClose]);
|
|
4583
|
-
return /* @__PURE__ */
|
|
4584
|
-
/* @__PURE__ */
|
|
4923
|
+
return /* @__PURE__ */ jsx34(Modal3, { opened, onClose, title: "Quick actions", centered: true, children: /* @__PURE__ */ jsxs24(Stack16, { gap: "sm", children: [
|
|
4924
|
+
/* @__PURE__ */ jsx34(
|
|
4585
4925
|
TextInput3,
|
|
4586
4926
|
{
|
|
4587
4927
|
"aria-label": "Command search",
|
|
@@ -4590,8 +4930,8 @@ function CommandPalette({ opened, onClose }) {
|
|
|
4590
4930
|
onChange: (event) => setQuery(event.currentTarget.value)
|
|
4591
4931
|
}
|
|
4592
4932
|
),
|
|
4593
|
-
filteredCommands.length === 0 ? /* @__PURE__ */
|
|
4594
|
-
/* @__PURE__ */
|
|
4933
|
+
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: [
|
|
4934
|
+
/* @__PURE__ */ jsx34(
|
|
4595
4935
|
"button",
|
|
4596
4936
|
{
|
|
4597
4937
|
type: "button",
|
|
@@ -4604,26 +4944,26 @@ function CommandPalette({ opened, onClose }) {
|
|
|
4604
4944
|
children: command.label
|
|
4605
4945
|
}
|
|
4606
4946
|
),
|
|
4607
|
-
command.shortcut ? /* @__PURE__ */
|
|
4947
|
+
command.shortcut ? /* @__PURE__ */ jsx34(Text22, { size: "xs", c: "dimmed", children: command.shortcut }) : null
|
|
4608
4948
|
] }, command.id)),
|
|
4609
|
-
/* @__PURE__ */
|
|
4949
|
+
/* @__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
4950
|
] }) });
|
|
4611
4951
|
}
|
|
4612
4952
|
|
|
4613
4953
|
// src/GdsTour.client.tsx
|
|
4614
4954
|
import {
|
|
4615
4955
|
createContext as createContext8,
|
|
4616
|
-
useCallback as
|
|
4956
|
+
useCallback as useCallback12,
|
|
4617
4957
|
useContext as useContext8,
|
|
4618
|
-
useEffect as
|
|
4958
|
+
useEffect as useEffect10,
|
|
4619
4959
|
useLayoutEffect,
|
|
4620
4960
|
useMemo as useMemo13,
|
|
4621
|
-
useRef as
|
|
4622
|
-
useState as
|
|
4961
|
+
useRef as useRef11,
|
|
4962
|
+
useState as useState20
|
|
4623
4963
|
} from "react";
|
|
4624
4964
|
import { createPortal } from "react-dom";
|
|
4625
|
-
import { useGdsTranslation as
|
|
4626
|
-
import { Fragment as
|
|
4965
|
+
import { useGdsTranslation as useGdsTranslation26 } from "@sovereignsquad/gds-theme";
|
|
4966
|
+
import { Fragment as Fragment7, jsx as jsx35, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
4627
4967
|
var GdsTourContext = createContext8(null);
|
|
4628
4968
|
var SEEN_KEY_PREFIX = "gds-tour-seen:";
|
|
4629
4969
|
function hasSeen(tourId) {
|
|
@@ -4642,8 +4982,8 @@ function markSeen(tourId) {
|
|
|
4642
4982
|
}
|
|
4643
4983
|
}
|
|
4644
4984
|
function useHasSeenTour(tourId) {
|
|
4645
|
-
const [seen, setSeen] =
|
|
4646
|
-
|
|
4985
|
+
const [seen, setSeen] = useState20(false);
|
|
4986
|
+
useEffect10(() => {
|
|
4647
4987
|
setSeen(hasSeen(tourId));
|
|
4648
4988
|
}, [tourId]);
|
|
4649
4989
|
return seen;
|
|
@@ -4698,29 +5038,29 @@ function computeCardPosition(hole, card, placement) {
|
|
|
4698
5038
|
}
|
|
4699
5039
|
var FOCUSABLE = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
4700
5040
|
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
|
-
|
|
5041
|
+
const { t } = useGdsTranslation26();
|
|
5042
|
+
const [tourId, setTourId] = useState20(null);
|
|
5043
|
+
const [steps, setSteps] = useState20([]);
|
|
5044
|
+
const [index, setIndex] = useState20(0);
|
|
5045
|
+
const [status, setStatus] = useState20("idle");
|
|
5046
|
+
const [rect, setRect] = useState20(null);
|
|
5047
|
+
const [cardPos, setCardPos] = useState20(null);
|
|
5048
|
+
const [mounted, setMounted] = useState20(false);
|
|
5049
|
+
const optionsRef = useRef11({});
|
|
5050
|
+
const invokerRef = useRef11(null);
|
|
5051
|
+
const cardRef = useRef11(null);
|
|
5052
|
+
const targetElRef = useRef11(null);
|
|
5053
|
+
useEffect10(() => setMounted(true), []);
|
|
4714
5054
|
const running = status === "running";
|
|
4715
5055
|
const activeStep = running ? steps[index] ?? null : null;
|
|
4716
5056
|
const count = steps.length;
|
|
4717
|
-
const clearActiveTargetAttr =
|
|
5057
|
+
const clearActiveTargetAttr = useCallback12(() => {
|
|
4718
5058
|
if (targetElRef.current) {
|
|
4719
5059
|
targetElRef.current.removeAttribute("data-gds-tour-active-target");
|
|
4720
5060
|
targetElRef.current = null;
|
|
4721
5061
|
}
|
|
4722
5062
|
}, []);
|
|
4723
|
-
const finish =
|
|
5063
|
+
const finish = useCallback12(
|
|
4724
5064
|
(nextStatus, reason) => {
|
|
4725
5065
|
const opts = optionsRef.current;
|
|
4726
5066
|
const id = tourId;
|
|
@@ -4739,10 +5079,10 @@ function GdsTourProvider({ children }) {
|
|
|
4739
5079
|
},
|
|
4740
5080
|
[clearActiveTargetAttr, tourId]
|
|
4741
5081
|
);
|
|
4742
|
-
const stop =
|
|
5082
|
+
const stop = useCallback12((reason = "programmatic") => {
|
|
4743
5083
|
finish(reason === "finished" ? "finished" : "skipped", reason);
|
|
4744
5084
|
}, [finish]);
|
|
4745
|
-
const start =
|
|
5085
|
+
const start = useCallback12(
|
|
4746
5086
|
(id, tourSteps, options = {}) => {
|
|
4747
5087
|
if (!tourSteps.length) return;
|
|
4748
5088
|
optionsRef.current = options;
|
|
@@ -4754,7 +5094,7 @@ function GdsTourProvider({ children }) {
|
|
|
4754
5094
|
},
|
|
4755
5095
|
[]
|
|
4756
5096
|
);
|
|
4757
|
-
const goTo =
|
|
5097
|
+
const goTo = useCallback12(
|
|
4758
5098
|
(nextIndex) => {
|
|
4759
5099
|
setIndex((current) => {
|
|
4760
5100
|
const clamped = Math.max(0, Math.min(nextIndex, steps.length - 1));
|
|
@@ -4764,14 +5104,14 @@ function GdsTourProvider({ children }) {
|
|
|
4764
5104
|
},
|
|
4765
5105
|
[steps]
|
|
4766
5106
|
);
|
|
4767
|
-
const next =
|
|
5107
|
+
const next = useCallback12(() => {
|
|
4768
5108
|
if (index >= steps.length - 1) {
|
|
4769
5109
|
finish("finished", "finished");
|
|
4770
5110
|
} else {
|
|
4771
5111
|
goTo(index + 1);
|
|
4772
5112
|
}
|
|
4773
5113
|
}, [index, steps.length, finish, goTo]);
|
|
4774
|
-
const back =
|
|
5114
|
+
const back = useCallback12(() => {
|
|
4775
5115
|
if (index > 0) goTo(index - 1);
|
|
4776
5116
|
}, [index, goTo]);
|
|
4777
5117
|
useLayoutEffect(() => {
|
|
@@ -4817,7 +5157,7 @@ function GdsTourProvider({ children }) {
|
|
|
4817
5157
|
ro?.disconnect();
|
|
4818
5158
|
};
|
|
4819
5159
|
}, [running, activeStep, index, next]);
|
|
4820
|
-
|
|
5160
|
+
useEffect10(() => {
|
|
4821
5161
|
if (!running) return void 0;
|
|
4822
5162
|
const previousOverflow = document.body.style.overflow;
|
|
4823
5163
|
document.body.style.overflow = "hidden";
|
|
@@ -4832,7 +5172,7 @@ function GdsTourProvider({ children }) {
|
|
|
4832
5172
|
window.clearTimeout(focusCard);
|
|
4833
5173
|
};
|
|
4834
5174
|
}, [running, index]);
|
|
4835
|
-
|
|
5175
|
+
useEffect10(() => {
|
|
4836
5176
|
if (!running || !activeStep) return void 0;
|
|
4837
5177
|
const onKeyDown = (event) => {
|
|
4838
5178
|
if (event.key === "Escape") {
|
|
@@ -4879,15 +5219,15 @@ function GdsTourProvider({ children }) {
|
|
|
4879
5219
|
[status, tourId, index, count, activeStep, start, next, back, goTo, stop]
|
|
4880
5220
|
);
|
|
4881
5221
|
const overlay = mounted && running && activeStep && rect ? createPortal(
|
|
4882
|
-
/* @__PURE__ */
|
|
4883
|
-
/* @__PURE__ */
|
|
5222
|
+
/* @__PURE__ */ jsxs25(Fragment7, { children: [
|
|
5223
|
+
/* @__PURE__ */ jsxs25(
|
|
4884
5224
|
"div",
|
|
4885
5225
|
{
|
|
4886
5226
|
className: `gds-tour-spotlight${activeStep.interaction === "allow-target" ? " gds-tour-spotlight--interactive" : ""}`,
|
|
4887
5227
|
"data-gds-tour-overlay": "",
|
|
4888
5228
|
children: [
|
|
4889
|
-
activeStep.interaction !== "allow-target" ? /* @__PURE__ */
|
|
4890
|
-
/* @__PURE__ */
|
|
5229
|
+
activeStep.interaction !== "allow-target" ? /* @__PURE__ */ jsx35("div", { className: "gds-tour-spotlight__blocker", "aria-hidden": "true" }) : null,
|
|
5230
|
+
/* @__PURE__ */ jsx35(
|
|
4891
5231
|
"div",
|
|
4892
5232
|
{
|
|
4893
5233
|
className: "gds-tour-spotlight__hole",
|
|
@@ -4898,7 +5238,7 @@ function GdsTourProvider({ children }) {
|
|
|
4898
5238
|
]
|
|
4899
5239
|
}
|
|
4900
5240
|
),
|
|
4901
|
-
/* @__PURE__ */
|
|
5241
|
+
/* @__PURE__ */ jsxs25(
|
|
4902
5242
|
"div",
|
|
4903
5243
|
{
|
|
4904
5244
|
ref: cardRef,
|
|
@@ -4910,11 +5250,11 @@ function GdsTourProvider({ children }) {
|
|
|
4910
5250
|
tabIndex: -1,
|
|
4911
5251
|
style: cardPos ? { top: cardPos.top, left: cardPos.left } : { top: 16, left: 16, visibility: "hidden" },
|
|
4912
5252
|
children: [
|
|
4913
|
-
/* @__PURE__ */
|
|
4914
|
-
/* @__PURE__ */
|
|
4915
|
-
/* @__PURE__ */
|
|
4916
|
-
/* @__PURE__ */
|
|
4917
|
-
activeStep.canSkip !== false ? /* @__PURE__ */
|
|
5253
|
+
/* @__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)) }),
|
|
5254
|
+
/* @__PURE__ */ jsx35("h2", { id: "gds-tour-title", className: "gds-tour-card__title", children: activeStep.title }),
|
|
5255
|
+
/* @__PURE__ */ jsx35("div", { id: "gds-tour-body", className: "gds-tour-card__body", children: activeStep.body }),
|
|
5256
|
+
/* @__PURE__ */ jsxs25("div", { className: "gds-tour-card__actions", children: [
|
|
5257
|
+
activeStep.canSkip !== false ? /* @__PURE__ */ jsx35(
|
|
4918
5258
|
"button",
|
|
4919
5259
|
{
|
|
4920
5260
|
type: "button",
|
|
@@ -4922,10 +5262,10 @@ function GdsTourProvider({ children }) {
|
|
|
4922
5262
|
onClick: () => finish("skipped", "skipped"),
|
|
4923
5263
|
children: t("gds.tour.skip", "Skip")
|
|
4924
5264
|
}
|
|
4925
|
-
) : /* @__PURE__ */
|
|
4926
|
-
/* @__PURE__ */
|
|
4927
|
-
index > 0 ? /* @__PURE__ */
|
|
4928
|
-
/* @__PURE__ */
|
|
5265
|
+
) : /* @__PURE__ */ jsx35("span", {}),
|
|
5266
|
+
/* @__PURE__ */ jsxs25("div", { className: "gds-tour-card__nav", children: [
|
|
5267
|
+
index > 0 ? /* @__PURE__ */ jsx35("button", { type: "button", className: "gds-tour-btn gds-tour-btn--secondary", onClick: back, children: t("gds.tour.back", "Back") }) : null,
|
|
5268
|
+
/* @__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
5269
|
] })
|
|
4930
5270
|
] })
|
|
4931
5271
|
]
|
|
@@ -4934,7 +5274,7 @@ function GdsTourProvider({ children }) {
|
|
|
4934
5274
|
] }),
|
|
4935
5275
|
document.body
|
|
4936
5276
|
) : null;
|
|
4937
|
-
return /* @__PURE__ */
|
|
5277
|
+
return /* @__PURE__ */ jsxs25(GdsTourContext.Provider, { value, children: [
|
|
4938
5278
|
children,
|
|
4939
5279
|
overlay
|
|
4940
5280
|
] });
|
|
@@ -4948,8 +5288,8 @@ function useGdsTour() {
|
|
|
4948
5288
|
}
|
|
4949
5289
|
function GdsGuidedTour({ id, steps, open = false, defaultStep, ...options }) {
|
|
4950
5290
|
const { start, status } = useGdsTour();
|
|
4951
|
-
const startedRef =
|
|
4952
|
-
|
|
5291
|
+
const startedRef = useRef11(false);
|
|
5292
|
+
useEffect10(() => {
|
|
4953
5293
|
if (!open || startedRef.current || status === "running") return;
|
|
4954
5294
|
if (options.persist === "localStorage" && hasSeen(id)) return;
|
|
4955
5295
|
startedRef.current = true;
|
|
@@ -4971,8 +5311,8 @@ function GdsTourButton({
|
|
|
4971
5311
|
...buttonProps
|
|
4972
5312
|
}) {
|
|
4973
5313
|
const { start } = useGdsTour();
|
|
4974
|
-
const { t } =
|
|
4975
|
-
return /* @__PURE__ */
|
|
5314
|
+
const { t } = useGdsTranslation26();
|
|
5315
|
+
return /* @__PURE__ */ jsx35(
|
|
4976
5316
|
"button",
|
|
4977
5317
|
{
|
|
4978
5318
|
type: "button",
|
|
@@ -4985,10 +5325,10 @@ function GdsTourButton({
|
|
|
4985
5325
|
}
|
|
4986
5326
|
|
|
4987
5327
|
// src/LayoutTemplatePreview.client.tsx
|
|
4988
|
-
import { useGdsTranslation as
|
|
4989
|
-
import { useMemo as useMemo14, useState as
|
|
5328
|
+
import { useGdsTranslation as useGdsTranslation27 } from "@sovereignsquad/gds-theme";
|
|
5329
|
+
import { useMemo as useMemo14, useState as useState21 } from "react";
|
|
4990
5330
|
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
|
|
5331
|
+
import { jsx as jsx36, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
4992
5332
|
function templateText(template) {
|
|
4993
5333
|
return JSON.stringify(template.schema, null, 2);
|
|
4994
5334
|
}
|
|
@@ -5001,16 +5341,16 @@ function GdsLayoutTemplatePreview({
|
|
|
5001
5341
|
title: titleProp,
|
|
5002
5342
|
description: descriptionProp
|
|
5003
5343
|
}) {
|
|
5004
|
-
const { t } =
|
|
5344
|
+
const { t } = useGdsTranslation27();
|
|
5005
5345
|
const title = titleProp ?? t("gds.layoutTemplatePreview.title", "Template cookbook");
|
|
5006
5346
|
const description = descriptionProp ?? t("gds.layoutTemplatePreview.description", "Pick a template, edit JSON, then apply to preview live diagnostics and rendered layout.");
|
|
5007
5347
|
const initialTemplate = templates.find((template) => template.id === initialTemplateId) ?? templates[0];
|
|
5008
5348
|
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] =
|
|
5349
|
+
const [selectedTemplateId, setSelectedTemplateId] = useState21(initialTemplate?.id ?? "");
|
|
5350
|
+
const [schemaText, setSchemaText] = useState21(initialText);
|
|
5351
|
+
const [appliedSchemaText, setAppliedSchemaText] = useState21(initialText);
|
|
5352
|
+
const [editorError, setEditorError] = useState21("");
|
|
5353
|
+
const [copyState, setCopyState] = useState21("idle");
|
|
5014
5354
|
const selectedTemplate = templates.find((template) => template.id === selectedTemplateId);
|
|
5015
5355
|
const renderedTemplate = useMemo14(() => {
|
|
5016
5356
|
try {
|
|
@@ -5018,7 +5358,7 @@ function GdsLayoutTemplatePreview({
|
|
|
5018
5358
|
} catch {
|
|
5019
5359
|
return {
|
|
5020
5360
|
issues: [{ blockId: "schema", message: "Unable to parse schema JSON. Make sure the payload is valid JSON." }],
|
|
5021
|
-
node: /* @__PURE__ */
|
|
5361
|
+
node: /* @__PURE__ */ jsx36(
|
|
5022
5362
|
StateBlock,
|
|
5023
5363
|
{
|
|
5024
5364
|
variant: "error",
|
|
@@ -5067,8 +5407,8 @@ function GdsLayoutTemplatePreview({
|
|
|
5067
5407
|
}
|
|
5068
5408
|
};
|
|
5069
5409
|
const issueCount = renderedTemplate.issues.length;
|
|
5070
|
-
return /* @__PURE__ */
|
|
5071
|
-
/* @__PURE__ */
|
|
5410
|
+
return /* @__PURE__ */ jsx36(SectionPanel, { title, description, children: /* @__PURE__ */ jsxs26(Stack17, { gap: "md", children: [
|
|
5411
|
+
/* @__PURE__ */ jsx36(
|
|
5072
5412
|
NativeSelect2,
|
|
5073
5413
|
{
|
|
5074
5414
|
label: "Template preset",
|
|
@@ -5078,7 +5418,7 @@ function GdsLayoutTemplatePreview({
|
|
|
5078
5418
|
data: templates.map((template) => ({ value: template.id, label: template.title }))
|
|
5079
5419
|
}
|
|
5080
5420
|
),
|
|
5081
|
-
/* @__PURE__ */
|
|
5421
|
+
/* @__PURE__ */ jsx36(
|
|
5082
5422
|
Textarea,
|
|
5083
5423
|
{
|
|
5084
5424
|
label: "Current template summary",
|
|
@@ -5089,7 +5429,7 @@ Use case: ${selectedTemplate.useCase}` : "",
|
|
|
5089
5429
|
minRows: 2
|
|
5090
5430
|
}
|
|
5091
5431
|
),
|
|
5092
|
-
/* @__PURE__ */
|
|
5432
|
+
/* @__PURE__ */ jsx36(
|
|
5093
5433
|
Textarea,
|
|
5094
5434
|
{
|
|
5095
5435
|
label: "Layout schema JSON",
|
|
@@ -5100,19 +5440,19 @@ Use case: ${selectedTemplate.useCase}` : "",
|
|
|
5100
5440
|
onChange: (event) => setSchemaText(event.currentTarget.value)
|
|
5101
5441
|
}
|
|
5102
5442
|
),
|
|
5103
|
-
/* @__PURE__ */
|
|
5104
|
-
/* @__PURE__ */
|
|
5105
|
-
/* @__PURE__ */
|
|
5106
|
-
/* @__PURE__ */
|
|
5443
|
+
/* @__PURE__ */ jsxs26(Group21, { gap: "sm", children: [
|
|
5444
|
+
/* @__PURE__ */ jsx36(Button14, { type: "button", onClick: applySchema, children: "Apply schema" }),
|
|
5445
|
+
/* @__PURE__ */ jsx36(Button14, { type: "button", variant: "default", onClick: resetTemplate, children: "Reset to template" }),
|
|
5446
|
+
/* @__PURE__ */ jsx36(Button14, { type: "button", variant: "light", onClick: () => void copySchema(), children: "Copy schema" })
|
|
5107
5447
|
] }),
|
|
5108
|
-
editorError ? /* @__PURE__ */
|
|
5109
|
-
copyState === "success" ? /* @__PURE__ */
|
|
5110
|
-
copyState === "error" ? /* @__PURE__ */
|
|
5111
|
-
/* @__PURE__ */
|
|
5448
|
+
editorError ? /* @__PURE__ */ jsx36(StateBlock, { variant: "error", title: "Invalid JSON", description: editorError }) : null,
|
|
5449
|
+
copyState === "success" ? /* @__PURE__ */ jsx36(Alert3, { color: "green", children: "Schema copied to clipboard." }) : null,
|
|
5450
|
+
copyState === "error" ? /* @__PURE__ */ jsx36(Alert3, { color: "yellow", children: "Clipboard copy is unavailable in this browser context." }) : null,
|
|
5451
|
+
/* @__PURE__ */ jsxs26(Text23, { "aria-live": "polite", children: [
|
|
5112
5452
|
"Diagnostic result: ",
|
|
5113
5453
|
issueCount === 0 ? "no issues" : `${issueCount} issue${issueCount === 1 ? "" : "s"}`
|
|
5114
5454
|
] }),
|
|
5115
|
-
/* @__PURE__ */
|
|
5455
|
+
/* @__PURE__ */ jsx36(
|
|
5116
5456
|
SectionPanel,
|
|
5117
5457
|
{
|
|
5118
5458
|
title: `Schema render preview (${selectedTemplate?.schema.version ?? "1"})`,
|
|
@@ -5120,7 +5460,7 @@ Use case: ${selectedTemplate.useCase}` : "",
|
|
|
5120
5460
|
children: renderedTemplate.node
|
|
5121
5461
|
}
|
|
5122
5462
|
),
|
|
5123
|
-
issueCount ? /* @__PURE__ */
|
|
5463
|
+
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
5464
|
issue.blockId ? `${issue.blockId}: ` : "",
|
|
5125
5465
|
issue.message
|
|
5126
5466
|
] }, `${issue.blockId ?? "schema"}-${index}`)) }) }) : null
|
|
@@ -5129,7 +5469,7 @@ Use case: ${selectedTemplate.useCase}` : "",
|
|
|
5129
5469
|
|
|
5130
5470
|
// src/Telemetry.client.tsx
|
|
5131
5471
|
import { createContext as createContext9, useContext as useContext9, useMemo as useMemo15 } from "react";
|
|
5132
|
-
import { jsx as
|
|
5472
|
+
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
5133
5473
|
var gdsOperationalEventTypes = [
|
|
5134
5474
|
"submit",
|
|
5135
5475
|
"submit_success",
|
|
@@ -5352,7 +5692,7 @@ function GdsTelemetryProvider({
|
|
|
5352
5692
|
emit: (event) => emitGdsEvent({ adapter, sink, sampleRate, payloadPolicy, onAdapterError }, event),
|
|
5353
5693
|
emitGdsEvent: (event) => emitGdsEvent({ adapter, sink, sampleRate, payloadPolicy, onAdapterError }, event)
|
|
5354
5694
|
}), [adapter, onAdapterError, payloadPolicy, sampleRate, sink]);
|
|
5355
|
-
return /* @__PURE__ */
|
|
5695
|
+
return /* @__PURE__ */ jsx37(GdsTelemetryContext.Provider, { value, children });
|
|
5356
5696
|
}
|
|
5357
5697
|
function useGdsTelemetry() {
|
|
5358
5698
|
const context = useContext9(GdsTelemetryContext);
|
|
@@ -5364,7 +5704,7 @@ function useGdsTelemetry() {
|
|
|
5364
5704
|
|
|
5365
5705
|
// src/PublicCaptureFlow.tsx
|
|
5366
5706
|
import { Stack as Stack18, Text as Text24 } from "@mantine/core";
|
|
5367
|
-
import { jsx as
|
|
5707
|
+
import { jsx as jsx38, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
5368
5708
|
var stageCopy = {
|
|
5369
5709
|
identify: { title: "Who are you?", description: "Enter the information required for this public flow." },
|
|
5370
5710
|
consent: { title: "Review consent", description: "Confirm the required consent before continuing." },
|
|
@@ -5383,10 +5723,10 @@ function toFlowStatus(state) {
|
|
|
5383
5723
|
}
|
|
5384
5724
|
function runtimeStateBody(state) {
|
|
5385
5725
|
if (state === "permission-denied") {
|
|
5386
|
-
return /* @__PURE__ */
|
|
5726
|
+
return /* @__PURE__ */ jsx38(StateBlock, { variant: "permission", title: "Permission required", description: "Allow access or use the provided recovery action to continue." });
|
|
5387
5727
|
}
|
|
5388
5728
|
if (state === "hardware-unavailable") {
|
|
5389
|
-
return /* @__PURE__ */
|
|
5729
|
+
return /* @__PURE__ */ jsx38(StateBlock, { variant: "error", title: "Capture unavailable", description: "The required hardware surface is not available on this device." });
|
|
5390
5730
|
}
|
|
5391
5731
|
return null;
|
|
5392
5732
|
}
|
|
@@ -5404,8 +5744,8 @@ function PublicCaptureFlow({
|
|
|
5404
5744
|
}) {
|
|
5405
5745
|
const copy = stageCopy[stage];
|
|
5406
5746
|
const runtimeBody = runtimeStateBody(state);
|
|
5407
|
-
const flowBody = runtimeBody ?? (stage === "share" && share ? /* @__PURE__ */
|
|
5408
|
-
return /* @__PURE__ */
|
|
5747
|
+
const flowBody = runtimeBody ?? (stage === "share" && share ? /* @__PURE__ */ jsx38(PublicShareOverlay, { ...share }) : body);
|
|
5748
|
+
return /* @__PURE__ */ jsx38(
|
|
5409
5749
|
PublicFlowShell,
|
|
5410
5750
|
{
|
|
5411
5751
|
exitAction,
|
|
@@ -5423,34 +5763,34 @@ function PublicCaptureFlow({
|
|
|
5423
5763
|
);
|
|
5424
5764
|
}
|
|
5425
5765
|
function PublicIdentityStep({ children }) {
|
|
5426
|
-
return /* @__PURE__ */
|
|
5766
|
+
return /* @__PURE__ */ jsx38(Stack18, { gap: "md", children });
|
|
5427
5767
|
}
|
|
5428
5768
|
function PublicConsentStep({ consentText, control }) {
|
|
5429
|
-
return /* @__PURE__ */
|
|
5430
|
-
/* @__PURE__ */
|
|
5769
|
+
return /* @__PURE__ */ jsxs27(Stack18, { gap: "md", children: [
|
|
5770
|
+
/* @__PURE__ */ jsx38(Text24, { children: consentText }),
|
|
5431
5771
|
control
|
|
5432
5772
|
] });
|
|
5433
5773
|
}
|
|
5434
5774
|
function PublicAcceptStep({ preview, actions }) {
|
|
5435
|
-
return /* @__PURE__ */
|
|
5775
|
+
return /* @__PURE__ */ jsxs27(Stack18, { gap: "md", children: [
|
|
5436
5776
|
preview,
|
|
5437
5777
|
actions
|
|
5438
5778
|
] });
|
|
5439
5779
|
}
|
|
5440
5780
|
function PublicCtaStep({ children }) {
|
|
5441
|
-
return /* @__PURE__ */
|
|
5781
|
+
return /* @__PURE__ */ jsx38(Stack18, { gap: "md", children });
|
|
5442
5782
|
}
|
|
5443
5783
|
function PublicRestartStep({ children }) {
|
|
5444
|
-
return /* @__PURE__ */
|
|
5784
|
+
return /* @__PURE__ */ jsx38(Stack18, { gap: "md", children });
|
|
5445
5785
|
}
|
|
5446
5786
|
function PublicShareOverlay(props) {
|
|
5447
|
-
return /* @__PURE__ */
|
|
5787
|
+
return /* @__PURE__ */ jsx38(ShareButtonGroup, { ...props });
|
|
5448
5788
|
}
|
|
5449
5789
|
|
|
5450
5790
|
// src/PlaybackControls.client.tsx
|
|
5451
|
-
import { useEffect as
|
|
5791
|
+
import { useEffect as useEffect11 } from "react";
|
|
5452
5792
|
import { ActionIcon as ActionIcon4, Group as Group22, Text as Text25 } from "@mantine/core";
|
|
5453
|
-
import { jsx as
|
|
5793
|
+
import { jsx as jsx39, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
5454
5794
|
function isInteractiveTarget(target) {
|
|
5455
5795
|
if (!(target instanceof HTMLElement)) return false;
|
|
5456
5796
|
return ["INPUT", "TEXTAREA", "SELECT", "BUTTON", "A"].includes(target.tagName) || target.isContentEditable;
|
|
@@ -5462,7 +5802,7 @@ function usePlaybackKeyboardControls({
|
|
|
5462
5802
|
onPrevious,
|
|
5463
5803
|
onFullscreenToggle
|
|
5464
5804
|
}) {
|
|
5465
|
-
|
|
5805
|
+
useEffect11(() => {
|
|
5466
5806
|
if (!enabled) return void 0;
|
|
5467
5807
|
const handler = (event) => {
|
|
5468
5808
|
if (event.defaultPrevented || isInteractiveTarget(event.target)) return;
|
|
@@ -5494,25 +5834,25 @@ function PlaybackControls({
|
|
|
5494
5834
|
}) {
|
|
5495
5835
|
const playing = state === "playing";
|
|
5496
5836
|
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__ */
|
|
5837
|
+
return /* @__PURE__ */ jsxs28(Group22, { gap: "xs", wrap: "wrap", align: "center", children: [
|
|
5838
|
+
/* @__PURE__ */ jsx39(ActionIcon4, { variant: "default", size: "lg", "aria-label": "Previous", onClick: onPrevious, disabled: disabled || !canGoPrevious, children: /* @__PURE__ */ jsx39(GdsIcons.Back, { size: "1rem" }) }),
|
|
5839
|
+
/* @__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" }) }),
|
|
5840
|
+
/* @__PURE__ */ jsx39(ActionIcon4, { variant: "default", size: "lg", "aria-label": "Next", onClick: onNext, disabled: disabled || !canGoNext, children: /* @__PURE__ */ jsx39(GdsIcons.Forward, { size: "1rem" }) }),
|
|
5841
|
+
onRestart ? /* @__PURE__ */ jsx39(ActionIcon4, { variant: "subtle", size: "lg", "aria-label": "Restart", onClick: onRestart, disabled: state === "loading", children: /* @__PURE__ */ jsx39(GdsIcons.Refresh, { size: "1rem" }) }) : null,
|
|
5842
|
+
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,
|
|
5843
|
+
/* @__PURE__ */ jsx39(Text25, { size: "sm", c: "dimmed", "aria-live": "polite", children: state })
|
|
5504
5844
|
] });
|
|
5505
5845
|
}
|
|
5506
5846
|
function PlaybackOverlayControls(props) {
|
|
5507
|
-
return /* @__PURE__ */
|
|
5847
|
+
return /* @__PURE__ */ jsx39(PlaybackControls, { ...props });
|
|
5508
5848
|
}
|
|
5509
5849
|
|
|
5510
5850
|
// src/GdsPageTemplates.client.tsx
|
|
5511
|
-
import { useEffect as
|
|
5851
|
+
import { useEffect as useEffect12, useId as useId2, useRef as useRef12 } from "react";
|
|
5512
5852
|
import { Box as Box11, Button as Button15, Grid, Title as Title3 } from "@mantine/core";
|
|
5513
5853
|
import { useMediaQuery as useMediaQuery3, useUncontrolled as useUncontrolled3 } from "@mantine/hooks";
|
|
5514
|
-
import { useGdsTranslation as
|
|
5515
|
-
import { jsx as
|
|
5854
|
+
import { useGdsTranslation as useGdsTranslation28 } from "@sovereignsquad/gds-theme";
|
|
5855
|
+
import { jsx as jsx40, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
5516
5856
|
function GdsAssetManagerTemplate({
|
|
5517
5857
|
state = "ready",
|
|
5518
5858
|
tree,
|
|
@@ -5530,24 +5870,24 @@ function GdsAssetManagerTemplate({
|
|
|
5530
5870
|
retryLabel,
|
|
5531
5871
|
...props
|
|
5532
5872
|
}) {
|
|
5533
|
-
const { t } =
|
|
5873
|
+
const { t } = useGdsTranslation28();
|
|
5534
5874
|
const [view, setView] = useUncontrolled3({ value: viewProp, defaultValue: defaultView, finalValue: "table", onChange: onViewChange });
|
|
5535
5875
|
const items = table && grid ? view === "grid" ? grid : table : table ?? grid;
|
|
5536
|
-
return /* @__PURE__ */
|
|
5876
|
+
return /* @__PURE__ */ jsx40(GdsShapeScope, { profile: shapeProfile, children: /* @__PURE__ */ jsx40(PageTemplateFrame, { id: "asset-manager", state, ...props, children: /* @__PURE__ */ jsx40(
|
|
5537
5877
|
TemplateStateGate,
|
|
5538
5878
|
{
|
|
5539
5879
|
state,
|
|
5540
5880
|
onRetry,
|
|
5541
5881
|
retryLabel,
|
|
5542
|
-
successContent: /* @__PURE__ */
|
|
5543
|
-
tree ? /* @__PURE__ */
|
|
5544
|
-
/* @__PURE__ */
|
|
5882
|
+
successContent: /* @__PURE__ */ jsxs29(Grid, { style: { gap: "var(--gds-space-md)" }, children: [
|
|
5883
|
+
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,
|
|
5884
|
+
/* @__PURE__ */ jsx40(Grid.Col, { span: { base: 12, md: tree ? 9 : 12 }, children: /* @__PURE__ */ jsxs29(GdsStack, { gap: "md", children: [
|
|
5545
5885
|
toolbar,
|
|
5546
|
-
bulkActions ? /* @__PURE__ */
|
|
5547
|
-
table && grid ? /* @__PURE__ */
|
|
5548
|
-
items ?? /* @__PURE__ */
|
|
5886
|
+
bulkActions ? /* @__PURE__ */ jsx40(GdsBulkActionBar, { ...bulkActions }) : null,
|
|
5887
|
+
table && grid ? /* @__PURE__ */ jsx40(GdsViewToggle, { value: view, onChange: setView }) : null,
|
|
5888
|
+
items ?? /* @__PURE__ */ jsx40(StateBlock, { variant: "empty", compact: true, titleOrder: 2, title: t("gds.assetManagerTemplate.emptyTitle", "This folder is empty") }),
|
|
5549
5889
|
upload,
|
|
5550
|
-
detail ? /* @__PURE__ */
|
|
5890
|
+
detail ? /* @__PURE__ */ jsx40(SectionPanel, { titleOrder: 2, title: t("gds.assetManagerTemplate.detailTitle", "Selected item"), children: detail }) : null
|
|
5551
5891
|
] }) })
|
|
5552
5892
|
] })
|
|
5553
5893
|
}
|
|
@@ -5567,54 +5907,54 @@ function GdsWorkspaceInboxTemplate({
|
|
|
5567
5907
|
retryLabel,
|
|
5568
5908
|
...props
|
|
5569
5909
|
}) {
|
|
5570
|
-
const { t } =
|
|
5910
|
+
const { t } = useGdsTranslation28();
|
|
5571
5911
|
const narrow = useMediaQuery3("(max-width: 48em)");
|
|
5572
5912
|
const headingId = useId2();
|
|
5573
|
-
const headingRef =
|
|
5574
|
-
|
|
5913
|
+
const headingRef = useRef12(null);
|
|
5914
|
+
useEffect12(() => {
|
|
5575
5915
|
if (narrow && hasSelection) headingRef.current?.focus();
|
|
5576
5916
|
}, [narrow, hasSelection]);
|
|
5577
5917
|
const scroll = regionHeight ? { maxBlockSize: regionHeight, overflowY: "auto" } : void 0;
|
|
5578
5918
|
const conversationsLabel = t("gds.workspaceInboxTemplate.conversations", "Conversations");
|
|
5579
5919
|
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__ */
|
|
5920
|
+
const listRegion = /* @__PURE__ */ jsx40(Box11, { component: "section", "aria-label": conversationsLabel, style: scroll, "data-gds-inbox-list": "", children: threadList });
|
|
5921
|
+
const detailRegion = /* @__PURE__ */ jsx40(Box11, { component: "section", "aria-labelledby": headingId, style: scroll, "data-gds-inbox-detail": "", children: /* @__PURE__ */ jsxs29(GdsStack, { gap: "sm", children: [
|
|
5922
|
+
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,
|
|
5923
|
+
/* @__PURE__ */ jsx40(Title3, { order: 2, size: "h4", id: headingId, ref: headingRef, tabIndex: -1, children: title }),
|
|
5924
|
+
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
5925
|
] }) });
|
|
5586
|
-
return /* @__PURE__ */
|
|
5926
|
+
return /* @__PURE__ */ jsx40(PageTemplateFrame, { id: "workspace-inbox", state, ...props, children: /* @__PURE__ */ jsx40(
|
|
5587
5927
|
TemplateStateGate,
|
|
5588
5928
|
{
|
|
5589
5929
|
state,
|
|
5590
5930
|
onRetry,
|
|
5591
5931
|
retryLabel,
|
|
5592
|
-
successContent: narrow ? hasSelection ? detailRegion : /* @__PURE__ */
|
|
5593
|
-
navigation ? /* @__PURE__ */
|
|
5932
|
+
successContent: narrow ? hasSelection ? detailRegion : /* @__PURE__ */ jsxs29(GdsStack, { gap: "md", children: [
|
|
5933
|
+
navigation ? /* @__PURE__ */ jsx40(Box11, { component: "nav", "aria-label": t("gds.workspaceInboxTemplate.navigation", "Workspace"), children: navigation }) : null,
|
|
5594
5934
|
listRegion
|
|
5595
|
-
] }) : /* @__PURE__ */
|
|
5596
|
-
navigation ? /* @__PURE__ */
|
|
5597
|
-
/* @__PURE__ */
|
|
5598
|
-
/* @__PURE__ */
|
|
5935
|
+
] }) : /* @__PURE__ */ jsxs29(Grid, { style: { gap: "var(--gds-space-md)" }, children: [
|
|
5936
|
+
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,
|
|
5937
|
+
/* @__PURE__ */ jsx40(Grid.Col, { span: { base: 12, md: navigation ? 4 : 5 }, children: listRegion }),
|
|
5938
|
+
/* @__PURE__ */ jsx40(Grid.Col, { span: { base: 12, md: navigation ? 6 : 7 }, children: detailRegion })
|
|
5599
5939
|
] })
|
|
5600
5940
|
}
|
|
5601
5941
|
) });
|
|
5602
5942
|
}
|
|
5603
5943
|
|
|
5604
5944
|
// src/TrustLayer.client.tsx
|
|
5605
|
-
import { useRef as
|
|
5945
|
+
import { useRef as useRef13, useState as useState22 } from "react";
|
|
5606
5946
|
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
|
|
5947
|
+
import { useGdsTranslation as useGdsTranslation29, GDS_MIN_TARGET_PX } from "@sovereignsquad/gds-theme";
|
|
5948
|
+
import { Fragment as Fragment8, jsx as jsx41, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
5609
5949
|
var ROLE_SUCCESS = "var(--gds-state-success, var(--mantine-color-green-7))";
|
|
5610
5950
|
var ROLE_WARNING = "var(--gds-state-warning, var(--mantine-color-yellow-8))";
|
|
5611
5951
|
var ROLE_META = "var(--gds-text-meta, var(--gds-vibe-muted, var(--mantine-color-gray-7)))";
|
|
5612
5952
|
var ROLE_WARNING_TINT_BG = "var(--gds-badge-soft-warning, var(--mantine-color-yellow-0))";
|
|
5613
5953
|
var ROLE_WARNING_TINT_FG = "var(--gds-badge-soft-warning-fg, var(--mantine-color-yellow-9))";
|
|
5614
5954
|
function ReportOutdatedLink({ onReport, label }) {
|
|
5615
|
-
const { t } =
|
|
5616
|
-
const [sent, setSent] =
|
|
5617
|
-
const sentRef =
|
|
5955
|
+
const { t } = useGdsTranslation29();
|
|
5956
|
+
const [sent, setSent] = useState22(false);
|
|
5957
|
+
const sentRef = useRef13(false);
|
|
5618
5958
|
const actionLabel = label ?? t("gds.trust.report.action", "Report outdated info");
|
|
5619
5959
|
const thanksText = t("gds.trust.report.thanks", "Thanks \u2014 we'll re-check this listing.");
|
|
5620
5960
|
const handleActivate = () => {
|
|
@@ -5623,25 +5963,25 @@ function ReportOutdatedLink({ onReport, label }) {
|
|
|
5623
5963
|
setSent(true);
|
|
5624
5964
|
onReport?.();
|
|
5625
5965
|
};
|
|
5626
|
-
return /* @__PURE__ */
|
|
5627
|
-
sent ? /* @__PURE__ */
|
|
5966
|
+
return /* @__PURE__ */ jsxs30(Fragment8, { children: [
|
|
5967
|
+
sent ? /* @__PURE__ */ jsx41(Text26, { component: "span", size: "sm", fw: 600, c: ROLE_SUCCESS, children: thanksText }) : /* @__PURE__ */ jsx41(
|
|
5628
5968
|
Button16,
|
|
5629
5969
|
{
|
|
5630
5970
|
type: "button",
|
|
5631
5971
|
variant: "subtle",
|
|
5632
5972
|
color: "gray",
|
|
5633
5973
|
size: "sm",
|
|
5634
|
-
leftSection: /* @__PURE__ */
|
|
5974
|
+
leftSection: /* @__PURE__ */ jsx41(GdsIcon, { icon: "Flag", size: "xs" }),
|
|
5635
5975
|
onClick: handleActivate,
|
|
5636
5976
|
styles: { root: { minHeight: `${GDS_MIN_TARGET_PX}px` } },
|
|
5637
5977
|
children: actionLabel
|
|
5638
5978
|
}
|
|
5639
5979
|
),
|
|
5640
|
-
/* @__PURE__ */
|
|
5980
|
+
/* @__PURE__ */ jsx41(VisuallyHidden6, { role: "status", "aria-live": "polite", "aria-atomic": "true", children: sent ? thanksText : "" })
|
|
5641
5981
|
] });
|
|
5642
5982
|
}
|
|
5643
5983
|
function useSourceRowStatusLabels() {
|
|
5644
|
-
const { t } =
|
|
5984
|
+
const { t } = useGdsTranslation29();
|
|
5645
5985
|
return {
|
|
5646
5986
|
estimate: t("gds.trust.source.statusEstimate", "Estimate"),
|
|
5647
5987
|
confirmed: t("gds.trust.source.statusConfirmed", "Confirmed"),
|
|
@@ -5652,7 +5992,7 @@ function sourceRowStatusRole(status) {
|
|
|
5652
5992
|
return status === "confirmed" ? ROLE_SUCCESS : ROLE_WARNING;
|
|
5653
5993
|
}
|
|
5654
5994
|
function SourceBlockRow({ label, children }) {
|
|
5655
|
-
return /* @__PURE__ */
|
|
5995
|
+
return /* @__PURE__ */ jsxs30(
|
|
5656
5996
|
Group23,
|
|
5657
5997
|
{
|
|
5658
5998
|
justify: "space-between",
|
|
@@ -5662,41 +6002,41 @@ function SourceBlockRow({ label, children }) {
|
|
|
5662
6002
|
py: 4,
|
|
5663
6003
|
style: { borderTop: "1px solid var(--gds-border-card, var(--mantine-color-gray-3))" },
|
|
5664
6004
|
children: [
|
|
5665
|
-
/* @__PURE__ */
|
|
6005
|
+
/* @__PURE__ */ jsx41(Text26, { size: "sm", fw: 500, c: ROLE_META, children: label }),
|
|
5666
6006
|
children
|
|
5667
6007
|
]
|
|
5668
6008
|
}
|
|
5669
6009
|
);
|
|
5670
6010
|
}
|
|
5671
6011
|
function SourceBlock({ sourceType, sourceUrl, lastChecked, priceStatus, scheduleStatus, onReport }) {
|
|
5672
|
-
const { t } =
|
|
6012
|
+
const { t } = useGdsTranslation29();
|
|
5673
6013
|
const statusLabels = useSourceRowStatusLabels();
|
|
5674
6014
|
const unknownValue = t("gds.trust.source.unknownValue", "Unknown \u2014 confirm with provider");
|
|
5675
6015
|
let sourceTypeContent;
|
|
5676
6016
|
if (sourceUrl) {
|
|
5677
|
-
sourceTypeContent = /* @__PURE__ */
|
|
6017
|
+
sourceTypeContent = /* @__PURE__ */ jsx41(GdsInlineLink, { href: sourceUrl, external: true, children: sourceType || unknownValue });
|
|
5678
6018
|
} else if (sourceType) {
|
|
5679
|
-
sourceTypeContent = /* @__PURE__ */
|
|
6019
|
+
sourceTypeContent = /* @__PURE__ */ jsx41(Text26, { size: "sm", children: sourceType });
|
|
5680
6020
|
} else {
|
|
5681
|
-
sourceTypeContent = /* @__PURE__ */
|
|
6021
|
+
sourceTypeContent = /* @__PURE__ */ jsx41(Text26, { size: "sm", c: ROLE_META, children: unknownValue });
|
|
5682
6022
|
}
|
|
5683
|
-
return /* @__PURE__ */
|
|
5684
|
-
/* @__PURE__ */
|
|
5685
|
-
/* @__PURE__ */
|
|
5686
|
-
/* @__PURE__ */
|
|
6023
|
+
return /* @__PURE__ */ jsx41(Paper8, { withBorder: true, radius: "lg", p: "md", "data-gds-source-block": "", children: /* @__PURE__ */ jsxs30(Stack19, { gap: "xs", children: [
|
|
6024
|
+
/* @__PURE__ */ jsxs30(Group23, { gap: "xs", children: [
|
|
6025
|
+
/* @__PURE__ */ jsx41(GdsIcon, { icon: "SourceInfo", size: "sm" }),
|
|
6026
|
+
/* @__PURE__ */ jsx41(Text26, { fw: 600, children: t("gds.trust.source.title", "Information source") })
|
|
5687
6027
|
] }),
|
|
5688
|
-
/* @__PURE__ */
|
|
5689
|
-
/* @__PURE__ */
|
|
5690
|
-
/* @__PURE__ */
|
|
5691
|
-
/* @__PURE__ */
|
|
5692
|
-
/* @__PURE__ */
|
|
6028
|
+
/* @__PURE__ */ jsxs30(Stack19, { gap: 0, children: [
|
|
6029
|
+
/* @__PURE__ */ jsx41(SourceBlockRow, { label: t("gds.trust.source.sourceType", "Source type"), children: sourceTypeContent }),
|
|
6030
|
+
/* @__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 }) }),
|
|
6031
|
+
/* @__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 }) }),
|
|
6032
|
+
/* @__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
6033
|
] }),
|
|
5694
|
-
/* @__PURE__ */
|
|
5695
|
-
onReport ? /* @__PURE__ */
|
|
6034
|
+
/* @__PURE__ */ jsx41(Text26, { size: "xs", c: ROLE_META, children: t("gds.trust.source.confirmLine", "Always confirm final details directly with the provider before attending.") }),
|
|
6035
|
+
onReport ? /* @__PURE__ */ jsx41(ReportOutdatedLink, { onReport }) : null
|
|
5696
6036
|
] }) });
|
|
5697
6037
|
}
|
|
5698
6038
|
function ConfirmChecklist({ items, title }) {
|
|
5699
|
-
const { t } =
|
|
6039
|
+
const { t } = useGdsTranslation29();
|
|
5700
6040
|
const defaultItems = [
|
|
5701
6041
|
t("gds.trust.checklist.exactSchedule", "Exact schedule"),
|
|
5702
6042
|
t("gds.trust.checklist.currentPrice", "Current price"),
|
|
@@ -5707,14 +6047,14 @@ function ConfirmChecklist({ items, title }) {
|
|
|
5707
6047
|
];
|
|
5708
6048
|
const resolvedItems = items ?? defaultItems;
|
|
5709
6049
|
const resolvedTitle = title ?? t("gds.trust.checklist.title", "Check before booking");
|
|
5710
|
-
const [checked, setChecked] =
|
|
6050
|
+
const [checked, setChecked] = useState22({});
|
|
5711
6051
|
if (resolvedItems.length === 0) {
|
|
5712
6052
|
return null;
|
|
5713
6053
|
}
|
|
5714
6054
|
const toggle = (key) => {
|
|
5715
6055
|
setChecked((current) => ({ ...current, [key]: !current[key] }));
|
|
5716
6056
|
};
|
|
5717
|
-
return /* @__PURE__ */
|
|
6057
|
+
return /* @__PURE__ */ jsx41(
|
|
5718
6058
|
Paper8,
|
|
5719
6059
|
{
|
|
5720
6060
|
withBorder: true,
|
|
@@ -5722,20 +6062,20 @@ function ConfirmChecklist({ items, title }) {
|
|
|
5722
6062
|
p: "md",
|
|
5723
6063
|
"data-gds-confirm-checklist": "",
|
|
5724
6064
|
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__ */
|
|
6065
|
+
children: /* @__PURE__ */ jsxs30("fieldset", { style: { border: 0, margin: 0, padding: 0, minInlineSize: "auto" }, children: [
|
|
6066
|
+
/* @__PURE__ */ jsxs30(Group23, { component: "legend", gap: "xs", wrap: "nowrap", style: { padding: 0, color: ROLE_WARNING_TINT_FG }, children: [
|
|
6067
|
+
/* @__PURE__ */ jsx41(GdsIcon, { icon: "Checklist", size: "sm" }),
|
|
6068
|
+
/* @__PURE__ */ jsx41(Text26, { fw: 600, c: "inherit", children: resolvedTitle })
|
|
5729
6069
|
] }),
|
|
5730
|
-
/* @__PURE__ */
|
|
6070
|
+
/* @__PURE__ */ jsx41(Stack19, { gap: "xs", mt: "sm", children: resolvedItems.map((item, index) => {
|
|
5731
6071
|
const key = `${index}:${item}`;
|
|
5732
6072
|
const isChecked = Boolean(checked[key]);
|
|
5733
|
-
return /* @__PURE__ */
|
|
6073
|
+
return /* @__PURE__ */ jsx41(Group23, { wrap: "nowrap", align: "center", gap: "xs", style: { minHeight: `${GDS_MIN_TARGET_PX}px` }, children: /* @__PURE__ */ jsx41(
|
|
5734
6074
|
Checkbox4,
|
|
5735
6075
|
{
|
|
5736
6076
|
checked: isChecked,
|
|
5737
6077
|
onChange: () => toggle(key),
|
|
5738
|
-
label: /* @__PURE__ */
|
|
6078
|
+
label: /* @__PURE__ */ jsx41(
|
|
5739
6079
|
Text26,
|
|
5740
6080
|
{
|
|
5741
6081
|
component: "span",
|
|
@@ -5753,10 +6093,10 @@ function ConfirmChecklist({ items, title }) {
|
|
|
5753
6093
|
}
|
|
5754
6094
|
|
|
5755
6095
|
// src/HeroSearchPanel.client.tsx
|
|
5756
|
-
import { useState as
|
|
6096
|
+
import { useState as useState23 } from "react";
|
|
5757
6097
|
import { Box as Box12, Button as Button17, TextInput as TextInput4 } from "@mantine/core";
|
|
5758
|
-
import { useGdsTranslation as
|
|
5759
|
-
import { jsx as
|
|
6098
|
+
import { useGdsTranslation as useGdsTranslation30, GDS_MIN_TARGET_PX as GDS_MIN_TARGET_PX2 } from "@sovereignsquad/gds-theme";
|
|
6099
|
+
import { jsx as jsx42, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
5760
6100
|
var GDS_HERO_SEARCH_FIELD_FLEX_BASIS_PX = 120;
|
|
5761
6101
|
var GDS_HERO_SEARCH_FIELD_MIN_WIDTH_PX = 110;
|
|
5762
6102
|
function dedupeHeroSearchFields(fields) {
|
|
@@ -5793,10 +6133,10 @@ function HeroSearchPanel({
|
|
|
5793
6133
|
ariaLabel: ariaLabelProp,
|
|
5794
6134
|
disabled = false
|
|
5795
6135
|
}) {
|
|
5796
|
-
const { t } =
|
|
6136
|
+
const { t } = useGdsTranslation30();
|
|
5797
6137
|
const ariaLabel = ariaLabelProp ?? t("gds.heroSearchPanel.ariaLabel", "Search");
|
|
5798
6138
|
const controlled = values !== void 0;
|
|
5799
|
-
const [internalValues, setInternalValues] =
|
|
6139
|
+
const [internalValues, setInternalValues] = useState23(defaultValues ?? {});
|
|
5800
6140
|
const currentValues = controlled ? values : internalValues;
|
|
5801
6141
|
const edit = (key, value) => {
|
|
5802
6142
|
const next = { ...currentValues, [key]: value };
|
|
@@ -5813,16 +6153,16 @@ function HeroSearchPanel({
|
|
|
5813
6153
|
const renderedFields = dedupeHeroSearchFields(fields);
|
|
5814
6154
|
const showSecondaryAction = Boolean(secondaryActionLabel && onSecondaryAction);
|
|
5815
6155
|
const primaryVocabularyPacks = primaryActionLabel ? [createGdsVocabularyPack("heroSearchPanel", { primary: { defaultMessage: primaryActionLabel, icon: GdsIcons.Search } })] : void 0;
|
|
5816
|
-
return /* @__PURE__ */
|
|
5817
|
-
renderedFields.length > 0 ? /* @__PURE__ */
|
|
6156
|
+
return /* @__PURE__ */ jsx42("form", { role: "search", "aria-label": ariaLabel, onSubmit: submit, style: panelSurfaceStyle, children: /* @__PURE__ */ jsxs31(GdsStack, { gap: "sm", children: [
|
|
6157
|
+
renderedFields.length > 0 ? /* @__PURE__ */ jsx42(GdsInline, { gap: "sm", wrap: "wrap", align: "start", children: renderedFields.map((field) => /* @__PURE__ */ jsx42(
|
|
5818
6158
|
Box12,
|
|
5819
6159
|
{
|
|
5820
6160
|
style: {
|
|
5821
6161
|
flex: `1 1 ${GDS_HERO_SEARCH_FIELD_FLEX_BASIS_PX}px`,
|
|
5822
6162
|
minWidth: `${GDS_HERO_SEARCH_FIELD_MIN_WIDTH_PX}px`,
|
|
5823
|
-
overflowWrap: "
|
|
6163
|
+
overflowWrap: "break-word"
|
|
5824
6164
|
},
|
|
5825
|
-
children: /* @__PURE__ */
|
|
6165
|
+
children: /* @__PURE__ */ jsx42(FormField, { label: field.label, children: /* @__PURE__ */ jsx42(
|
|
5826
6166
|
TextInput4,
|
|
5827
6167
|
{
|
|
5828
6168
|
value: currentValues[field.key] ?? "",
|
|
@@ -5835,8 +6175,8 @@ function HeroSearchPanel({
|
|
|
5835
6175
|
},
|
|
5836
6176
|
field.key
|
|
5837
6177
|
)) }) : null,
|
|
5838
|
-
/* @__PURE__ */
|
|
5839
|
-
/* @__PURE__ */
|
|
6178
|
+
/* @__PURE__ */ jsxs31(GdsInline, { gap: "sm", wrap: "wrap", children: [
|
|
6179
|
+
/* @__PURE__ */ jsx42(
|
|
5840
6180
|
SemanticButton,
|
|
5841
6181
|
{
|
|
5842
6182
|
action: primaryActionLabel ? "heroSearchPanel:primary" : "search",
|
|
@@ -5845,17 +6185,17 @@ function HeroSearchPanel({
|
|
|
5845
6185
|
vocabularyPacks: primaryVocabularyPacks
|
|
5846
6186
|
}
|
|
5847
6187
|
),
|
|
5848
|
-
showSecondaryAction ? /* @__PURE__ */
|
|
6188
|
+
showSecondaryAction ? /* @__PURE__ */ jsx42(Button17, { type: "button", variant: "default", disabled, onClick: onSecondaryAction, children: secondaryActionLabel }) : null
|
|
5849
6189
|
] }),
|
|
5850
|
-
trustLine ? /* @__PURE__ */
|
|
6190
|
+
trustLine ? /* @__PURE__ */ jsx42(MetadataText, { children: trustLine }) : null
|
|
5851
6191
|
] }) });
|
|
5852
6192
|
}
|
|
5853
6193
|
|
|
5854
6194
|
// src/KanbanBoard.client.tsx
|
|
5855
|
-
import { useEffect as
|
|
6195
|
+
import { useEffect as useEffect13, useId as useId3, useRef as useRef14, useState as useState24 } from "react";
|
|
5856
6196
|
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
6197
|
import { useMediaQuery as useMediaQuery4 } from "@mantine/hooks";
|
|
5858
|
-
import { useGdsTranslation as
|
|
6198
|
+
import { useGdsTranslation as useGdsTranslation31 } from "@sovereignsquad/gds-theme";
|
|
5859
6199
|
import {
|
|
5860
6200
|
DndContext,
|
|
5861
6201
|
DragOverlay,
|
|
@@ -5868,7 +6208,7 @@ import {
|
|
|
5868
6208
|
} from "@dnd-kit/core";
|
|
5869
6209
|
import { SortableContext, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
5870
6210
|
import { CSS as CSS2 } from "@dnd-kit/utilities";
|
|
5871
|
-
import { Fragment as
|
|
6211
|
+
import { Fragment as Fragment9, jsx as jsx43, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
5872
6212
|
function useGdsKanbanOrientation({
|
|
5873
6213
|
stackedBreakpoint = "xs"
|
|
5874
6214
|
} = {}) {
|
|
@@ -5877,12 +6217,12 @@ function useGdsKanbanOrientation({
|
|
|
5877
6217
|
return isPortrait && isNarrow ? "stacked" : "columns";
|
|
5878
6218
|
}
|
|
5879
6219
|
function DragGripGlyph() {
|
|
5880
|
-
return /* @__PURE__ */
|
|
5881
|
-
(x) => [2, 8, 14].map((y) => /* @__PURE__ */
|
|
6220
|
+
return /* @__PURE__ */ jsx43("svg", { width: "10", height: "16", viewBox: "0 0 10 16", "aria-hidden": "true", focusable: "false", children: [2, 8].flatMap(
|
|
6221
|
+
(x) => [2, 8, 14].map((y) => /* @__PURE__ */ jsx43("circle", { cx: x, cy: y, r: 1.4, fill: "currentColor" }, `${x}-${y}`))
|
|
5882
6222
|
) });
|
|
5883
6223
|
}
|
|
5884
6224
|
function ColumnDisclosureGlyph({ collapsed }) {
|
|
5885
|
-
return /* @__PURE__ */
|
|
6225
|
+
return /* @__PURE__ */ jsx43(
|
|
5886
6226
|
"svg",
|
|
5887
6227
|
{
|
|
5888
6228
|
width: "12",
|
|
@@ -5891,7 +6231,7 @@ function ColumnDisclosureGlyph({ collapsed }) {
|
|
|
5891
6231
|
"aria-hidden": "true",
|
|
5892
6232
|
focusable: "false",
|
|
5893
6233
|
style: { transform: collapsed ? "rotate(-90deg)" : "none", transition: "transform var(--gds-motion-duration-fast, 120ms) var(--gds-motion-ease-standard, ease)" },
|
|
5894
|
-
children: /* @__PURE__ */
|
|
6234
|
+
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
6235
|
}
|
|
5896
6236
|
);
|
|
5897
6237
|
}
|
|
@@ -5900,7 +6240,7 @@ function columnTitleText(column) {
|
|
|
5900
6240
|
return column.ariaLabel ?? (typeof column.title === "string" ? column.title : column.id);
|
|
5901
6241
|
}
|
|
5902
6242
|
function KanbanCard({ item, column, columns, onMoveItem, renderItem, enableDrag, moveMenuIcon, moveMenuLabel }) {
|
|
5903
|
-
const { t } =
|
|
6243
|
+
const { t } = useGdsTranslation31();
|
|
5904
6244
|
const moveTargets = columns.filter((candidate) => candidate.id !== column.id);
|
|
5905
6245
|
const accessibleName = item.ariaLabel ?? (typeof item.title === "string" ? item.title : void 0);
|
|
5906
6246
|
const moveVerb = moveMenuLabel ?? t("gds.kanban.moveItem", "Move");
|
|
@@ -5912,7 +6252,7 @@ function KanbanCard({ item, column, columns, onMoveItem, renderItem, enableDrag,
|
|
|
5912
6252
|
transition: sortable.transition,
|
|
5913
6253
|
opacity: sortable.isDragging ? 0.4 : 1
|
|
5914
6254
|
} : void 0;
|
|
5915
|
-
return /* @__PURE__ */
|
|
6255
|
+
return /* @__PURE__ */ jsx43(
|
|
5916
6256
|
Paper9,
|
|
5917
6257
|
{
|
|
5918
6258
|
withBorder: true,
|
|
@@ -5921,9 +6261,9 @@ function KanbanCard({ item, column, columns, onMoveItem, renderItem, enableDrag,
|
|
|
5921
6261
|
"data-gds-kanban-card": item.id,
|
|
5922
6262
|
ref: enableDrag ? sortable.setNodeRef : void 0,
|
|
5923
6263
|
style: dragStyle,
|
|
5924
|
-
children: /* @__PURE__ */
|
|
5925
|
-
/* @__PURE__ */
|
|
5926
|
-
enableDrag ? /* @__PURE__ */
|
|
6264
|
+
children: /* @__PURE__ */ jsxs32(Stack20, { gap: 6, children: [
|
|
6265
|
+
/* @__PURE__ */ jsxs32(Group24, { justify: "space-between", align: "flex-start", gap: "xs", wrap: "nowrap", children: [
|
|
6266
|
+
enableDrag ? /* @__PURE__ */ jsx43(
|
|
5927
6267
|
ActionIcon5,
|
|
5928
6268
|
{
|
|
5929
6269
|
variant: "subtle",
|
|
@@ -5935,23 +6275,23 @@ function KanbanCard({ item, column, columns, onMoveItem, renderItem, enableDrag,
|
|
|
5935
6275
|
style: { cursor: "grab", touchAction: "none", flexShrink: 0 },
|
|
5936
6276
|
...sortable.listeners,
|
|
5937
6277
|
...sortable.attributes,
|
|
5938
|
-
children: /* @__PURE__ */
|
|
6278
|
+
children: /* @__PURE__ */ jsx43(DragGripGlyph, {})
|
|
5939
6279
|
}
|
|
5940
6280
|
) : null,
|
|
5941
|
-
/* @__PURE__ */
|
|
5942
|
-
typeof item.title === "string" ? /* @__PURE__ */
|
|
5943
|
-
item.description ? /* @__PURE__ */
|
|
6281
|
+
/* @__PURE__ */ jsx43(Box13, { style: { minWidth: 0, flex: 1 }, children: renderItem ? renderItem(item, column) : /* @__PURE__ */ jsxs32(Stack20, { gap: 2, children: [
|
|
6282
|
+
typeof item.title === "string" ? /* @__PURE__ */ jsx43(Text27, { fw: 600, size: "sm", children: item.title }) : item.title,
|
|
6283
|
+
item.description ? /* @__PURE__ */ jsx43(Text27, { size: "xs", c: "dimmed", children: item.description }) : null
|
|
5944
6284
|
] }) }),
|
|
5945
|
-
onMoveItem && moveTargets.length > 0 ? /* @__PURE__ */
|
|
5946
|
-
/* @__PURE__ */
|
|
5947
|
-
/* @__PURE__ */
|
|
6285
|
+
onMoveItem && moveTargets.length > 0 ? /* @__PURE__ */ jsxs32(Menu, { withinPortal: true, position: "bottom-end", shadow: "md", children: [
|
|
6286
|
+
/* @__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 }) }) }),
|
|
6287
|
+
/* @__PURE__ */ jsx43(Menu.Dropdown, { children: moveTargets.map((target) => /* @__PURE__ */ jsxs32(Menu.Item, { onClick: () => onMoveItem(item.id, column.id, target.id), children: [
|
|
5948
6288
|
t("gds.kanban.moveTo", "Move to"),
|
|
5949
6289
|
" ",
|
|
5950
6290
|
target.title
|
|
5951
6291
|
] }, target.id)) })
|
|
5952
6292
|
] }) : null
|
|
5953
6293
|
] }),
|
|
5954
|
-
item.status ? /* @__PURE__ */
|
|
6294
|
+
item.status ? /* @__PURE__ */ jsx43(Badge3, { variant: "light", size: "sm", children: item.status }) : null
|
|
5955
6295
|
] })
|
|
5956
6296
|
}
|
|
5957
6297
|
);
|
|
@@ -5972,10 +6312,10 @@ function KanbanColumn({
|
|
|
5972
6312
|
collapsed,
|
|
5973
6313
|
onCollapsedChange
|
|
5974
6314
|
}) {
|
|
5975
|
-
const { t } =
|
|
6315
|
+
const { t } = useGdsTranslation31();
|
|
5976
6316
|
const droppable = useDroppable({ id: column.id, disabled: !enableDrag });
|
|
5977
6317
|
const isControlledCollapse = collapsed !== void 0;
|
|
5978
|
-
const [internalCollapsed, setInternalCollapsed] =
|
|
6318
|
+
const [internalCollapsed, setInternalCollapsed] = useState24(false);
|
|
5979
6319
|
const resolvedCollapsed = collapsible ? isControlledCollapse ? Boolean(collapsed) : internalCollapsed : false;
|
|
5980
6320
|
const bodyId = useId3();
|
|
5981
6321
|
function handleToggleCollapsed() {
|
|
@@ -5989,7 +6329,7 @@ function KanbanColumn({
|
|
|
5989
6329
|
const toggleVerb = resolvedCollapsed ? t("gds.kanban.expandColumn", "Expand column") : t("gds.kanban.collapseColumn", "Collapse column");
|
|
5990
6330
|
const toggleLabel = columnName ? `${toggleVerb}: ${columnName}` : toggleVerb;
|
|
5991
6331
|
const count = column.totalCount ?? column.items.length;
|
|
5992
|
-
const cards = column.items.length ? /* @__PURE__ */
|
|
6332
|
+
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
6333
|
KanbanCard,
|
|
5994
6334
|
{
|
|
5995
6335
|
item,
|
|
@@ -6002,7 +6342,7 @@ function KanbanColumn({
|
|
|
6002
6342
|
moveMenuLabel
|
|
6003
6343
|
},
|
|
6004
6344
|
item.id
|
|
6005
|
-
)) }) : /* @__PURE__ */
|
|
6345
|
+
)) }) : /* @__PURE__ */ jsx43(
|
|
6006
6346
|
Text27,
|
|
6007
6347
|
{
|
|
6008
6348
|
size: "xs",
|
|
@@ -6013,11 +6353,11 @@ function KanbanColumn({
|
|
|
6013
6353
|
}
|
|
6014
6354
|
);
|
|
6015
6355
|
const footerNode = renderFooter ? renderFooter(column) : footer;
|
|
6016
|
-
const body = /* @__PURE__ */
|
|
6017
|
-
enableDrag ? /* @__PURE__ */
|
|
6018
|
-
footerNode != null && footerNode !== false ? /* @__PURE__ */
|
|
6356
|
+
const body = /* @__PURE__ */ jsxs32(Fragment9, { children: [
|
|
6357
|
+
enableDrag ? /* @__PURE__ */ jsx43(SortableContext, { items: column.items.map((item) => item.id), strategy: verticalListSortingStrategy, children: cards }) : cards,
|
|
6358
|
+
footerNode != null && footerNode !== false ? /* @__PURE__ */ jsx43(Box13, { "data-gds-kanban-footer": column.id, children: footerNode }) : null
|
|
6019
6359
|
] });
|
|
6020
|
-
return /* @__PURE__ */
|
|
6360
|
+
return /* @__PURE__ */ jsx43(
|
|
6021
6361
|
Paper9,
|
|
6022
6362
|
{
|
|
6023
6363
|
withBorder: true,
|
|
@@ -6026,10 +6366,10 @@ function KanbanColumn({
|
|
|
6026
6366
|
style: width ? { minWidth: width, flex: "0 0 auto" } : void 0,
|
|
6027
6367
|
"data-gds-kanban-column": column.id,
|
|
6028
6368
|
"data-gds-kanban-column-collapsed": collapsible && resolvedCollapsed ? "true" : void 0,
|
|
6029
|
-
children: /* @__PURE__ */
|
|
6030
|
-
/* @__PURE__ */
|
|
6031
|
-
/* @__PURE__ */
|
|
6032
|
-
collapsible ? /* @__PURE__ */
|
|
6369
|
+
children: /* @__PURE__ */ jsxs32(Stack20, { gap: "sm", children: [
|
|
6370
|
+
/* @__PURE__ */ jsxs32(Group24, { justify: "space-between", align: "center", wrap: "nowrap", "data-gds-kanban-column-header": column.id, children: [
|
|
6371
|
+
/* @__PURE__ */ jsxs32(Group24, { gap: "xs", wrap: "nowrap", style: { minWidth: 0 }, children: [
|
|
6372
|
+
collapsible ? /* @__PURE__ */ jsx43(
|
|
6033
6373
|
ActionIcon5,
|
|
6034
6374
|
{
|
|
6035
6375
|
variant: "subtle",
|
|
@@ -6041,14 +6381,14 @@ function KanbanColumn({
|
|
|
6041
6381
|
"aria-controls": bodyId,
|
|
6042
6382
|
onClick: handleToggleCollapsed,
|
|
6043
6383
|
style: { flexShrink: 0 },
|
|
6044
|
-
children: /* @__PURE__ */
|
|
6384
|
+
children: /* @__PURE__ */ jsx43(ColumnDisclosureGlyph, { collapsed: resolvedCollapsed })
|
|
6045
6385
|
}
|
|
6046
6386
|
) : null,
|
|
6047
|
-
/* @__PURE__ */
|
|
6387
|
+
/* @__PURE__ */ jsx43(Title4, { order: 4, children: column.title })
|
|
6048
6388
|
] }),
|
|
6049
|
-
/* @__PURE__ */
|
|
6389
|
+
/* @__PURE__ */ jsx43(Badge3, { variant: "light", children: count })
|
|
6050
6390
|
] }),
|
|
6051
|
-
collapsible ? /* @__PURE__ */
|
|
6391
|
+
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
6392
|
] })
|
|
6053
6393
|
}
|
|
6054
6394
|
);
|
|
@@ -6078,16 +6418,16 @@ function KanbanBoard({
|
|
|
6078
6418
|
collapsedColumnIds,
|
|
6079
6419
|
onCollapsedChange
|
|
6080
6420
|
}) {
|
|
6081
|
-
const { t } =
|
|
6421
|
+
const { t } = useGdsTranslation31();
|
|
6082
6422
|
const autoOrientation = useGdsKanbanOrientation();
|
|
6083
6423
|
const resolvedOrientation = orientation === "auto" ? autoOrientation : orientation;
|
|
6084
6424
|
const regionLabel = boardLabel ?? (typeof title === "string" ? title : t("gds.kanban.boardLabel", "Kanban board"));
|
|
6085
|
-
const [activeItem, setActiveItem] =
|
|
6086
|
-
const [internalCollapsedIds, setInternalCollapsedIds] =
|
|
6425
|
+
const [activeItem, setActiveItem] = useState24(null);
|
|
6426
|
+
const [internalCollapsedIds, setInternalCollapsedIds] = useState24([]);
|
|
6087
6427
|
const isCollapseControlled = collapsedColumnIds !== void 0;
|
|
6088
6428
|
const collapsedIds = isCollapseControlled ? collapsedColumnIds : internalCollapsedIds;
|
|
6089
|
-
const viewportRef =
|
|
6090
|
-
|
|
6429
|
+
const viewportRef = useRef14(null);
|
|
6430
|
+
useEffect13(() => {
|
|
6091
6431
|
const viewport = viewportRef.current;
|
|
6092
6432
|
if (!viewport || columnPanZone !== "header" || resolvedOrientation === "stacked") {
|
|
6093
6433
|
return void 0;
|
|
@@ -6183,7 +6523,7 @@ function KanbanBoard({
|
|
|
6183
6523
|
"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
6524
|
)
|
|
6185
6525
|
};
|
|
6186
|
-
const columnList = (width) => columns.map((column) => /* @__PURE__ */
|
|
6526
|
+
const columnList = (width) => columns.map((column) => /* @__PURE__ */ jsx43(
|
|
6187
6527
|
KanbanColumn,
|
|
6188
6528
|
{
|
|
6189
6529
|
column,
|
|
@@ -6202,14 +6542,14 @@ function KanbanBoard({
|
|
|
6202
6542
|
},
|
|
6203
6543
|
column.id
|
|
6204
6544
|
));
|
|
6205
|
-
const board = /* @__PURE__ */
|
|
6206
|
-
title ? typeof title === "string" ? /* @__PURE__ */
|
|
6207
|
-
resolvedOrientation === "stacked" ? /* @__PURE__ */
|
|
6545
|
+
const board = /* @__PURE__ */ jsxs32(Stack20, { gap: "md", role: "region", "aria-label": regionLabel, "data-gds-kanban-orientation": resolvedOrientation, children: [
|
|
6546
|
+
title ? typeof title === "string" ? /* @__PURE__ */ jsx43(Title4, { order: 3, children: title }) : title : null,
|
|
6547
|
+
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
6548
|
] });
|
|
6209
6549
|
if (!dragActive) {
|
|
6210
6550
|
return board;
|
|
6211
6551
|
}
|
|
6212
|
-
return /* @__PURE__ */
|
|
6552
|
+
return /* @__PURE__ */ jsxs32(
|
|
6213
6553
|
DndContext,
|
|
6214
6554
|
{
|
|
6215
6555
|
sensors,
|
|
@@ -6220,7 +6560,7 @@ function KanbanBoard({
|
|
|
6220
6560
|
onDragEnd: handleDragEnd,
|
|
6221
6561
|
children: [
|
|
6222
6562
|
board,
|
|
6223
|
-
/* @__PURE__ */
|
|
6563
|
+
/* @__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
6564
|
]
|
|
6225
6565
|
}
|
|
6226
6566
|
);
|
|
@@ -6228,6 +6568,9 @@ function KanbanBoard({
|
|
|
6228
6568
|
|
|
6229
6569
|
export {
|
|
6230
6570
|
GDS_BUTTON_FEEDBACK_DURATION_MS,
|
|
6571
|
+
GDS_BUTTON_PENDING_DELAY_MS,
|
|
6572
|
+
GDS_BUTTON_PENDING_MIN_MS,
|
|
6573
|
+
GDS_BUTTON_CONFIRM_WINDOW_MS,
|
|
6231
6574
|
GDS_BUTTON_GRADIENT_TEXT_FLOOR,
|
|
6232
6575
|
GDS_BUTTON_OUTLINE_ACCENT_STROKE_PX,
|
|
6233
6576
|
SemanticButton,
|
|
@@ -6257,6 +6600,9 @@ export {
|
|
|
6257
6600
|
SidebarNavSection,
|
|
6258
6601
|
SidebarNavItem,
|
|
6259
6602
|
DocsCodeBlock,
|
|
6603
|
+
DocsCodeDisclosure,
|
|
6604
|
+
GdsTableScrollContainer,
|
|
6605
|
+
GdsReleaseNotes,
|
|
6260
6606
|
ShareButtonGroup,
|
|
6261
6607
|
UploadDropzone,
|
|
6262
6608
|
createGdsAssetAdapter,
|