@doneisbetter/gds-core 2.6.1 → 2.6.4

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/server.mjs CHANGED
@@ -4,95 +4,123 @@ import {
4
4
  ArticleShell,
5
5
  AuthShell,
6
6
  BrowseSurface,
7
+ ChoiceChip,
7
8
  ConsumerDashboardGrid,
8
9
  ConsumerSection,
9
10
  CtaButtonGroup,
10
11
  DataToolbar,
12
+ DetailProfileShell,
11
13
  DocsPageShell,
12
14
  EditorialCard,
13
15
  EditorialHero,
14
16
  EmptyState,
15
17
  FeatureBand,
16
18
  FilterDrawer,
19
+ FoodMenuSection,
17
20
  FormField,
18
21
  GdsIcons,
19
22
  GdsVocabulary,
23
+ ListingCard,
24
+ MapPanel,
20
25
  MediaCard,
21
26
  MediaField,
22
27
  MetricCard,
23
28
  PageHeader,
24
29
  PlaceholderPanel,
30
+ PlaybackSurface,
25
31
  ProductCard,
26
32
  ProgressCard,
27
33
  PublicBrandFooter,
34
+ PublicFlowShell,
35
+ PublicFoodCard,
28
36
  PublicNav,
29
37
  PublicProductCard,
30
38
  PublicShell,
31
39
  PublicSiteFooter,
32
40
  SectionPanel,
33
41
  SimpleDataTable,
42
+ SocialAuthButtons,
34
43
  StateBlock,
35
44
  StatsSection,
36
45
  StatusBadge,
37
46
  ar,
47
+ createGdsVocabularyPack,
38
48
  de,
39
49
  en,
40
50
  es,
41
51
  fr,
42
52
  gdsLocales,
43
53
  getGdsMessages,
54
+ getSemanticActionConfig,
55
+ getSemanticActionLabel,
44
56
  he,
45
57
  hu,
46
58
  it,
59
+ mergeGdsVocabularyPacks,
47
60
  resolveAccentPanelStyles,
61
+ resolveSemanticActionConfig,
48
62
  ru
49
- } from "./chunk-6B42ANK7.mjs";
63
+ } from "./chunk-BAS4ZGKL.mjs";
50
64
  export {
51
65
  AccentPanel,
52
66
  AccessSummary,
53
67
  ArticleShell,
54
68
  AuthShell,
55
69
  BrowseSurface,
70
+ ChoiceChip,
56
71
  ConsumerDashboardGrid,
57
72
  ConsumerSection,
58
73
  CtaButtonGroup,
59
74
  DataToolbar,
75
+ DetailProfileShell,
60
76
  DocsPageShell,
61
77
  EditorialCard,
62
78
  EditorialHero,
63
79
  EmptyState,
64
80
  FeatureBand,
65
81
  FilterDrawer,
82
+ FoodMenuSection,
66
83
  FormField,
67
84
  GdsIcons,
68
85
  GdsVocabulary,
86
+ ListingCard,
87
+ MapPanel,
69
88
  MediaCard,
70
89
  MediaField,
71
90
  MetricCard,
72
91
  PageHeader,
73
92
  PlaceholderPanel,
93
+ PlaybackSurface,
74
94
  ProductCard,
75
95
  ProgressCard,
76
96
  PublicBrandFooter,
97
+ PublicFlowShell,
98
+ PublicFoodCard,
77
99
  PublicNav,
78
100
  PublicProductCard,
79
101
  PublicShell,
80
102
  PublicSiteFooter,
81
103
  SectionPanel,
82
104
  SimpleDataTable,
105
+ SocialAuthButtons,
83
106
  StateBlock,
84
107
  StatsSection,
85
108
  StatusBadge,
86
109
  ar,
110
+ createGdsVocabularyPack,
87
111
  de,
88
112
  en,
89
113
  es,
90
114
  fr,
91
115
  gdsLocales,
92
116
  getGdsMessages,
117
+ getSemanticActionConfig,
118
+ getSemanticActionLabel,
93
119
  he,
94
120
  hu,
95
121
  it,
122
+ mergeGdsVocabularyPacks,
96
123
  resolveAccentPanelStyles,
124
+ resolveSemanticActionConfig,
97
125
  ru
98
126
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doneisbetter/gds-core",
3
- "version": "2.6.1",
3
+ "version": "2.6.4",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -38,9 +38,9 @@
38
38
  "dev": "tsup --watch"
39
39
  },
40
40
  "peerDependencies": {
41
- "@doneisbetter/gds-theme": "^2.6.1",
42
- "@mantine/core": "^7.9.0 || ^8.3.0",
43
- "@mantine/hooks": "^7.9.0 || ^8.3.0",
41
+ "@doneisbetter/gds-theme": "^2.6.4",
42
+ "@mantine/core": "^7.9.0 || ^8.3.0 || ^9.0.0",
43
+ "@mantine/hooks": "^7.9.0 || ^8.3.0 || ^9.0.0",
44
44
  "@tabler/icons-react": "^3.5.0",
45
45
  "react": "^18.2.0 || ^19.0.0",
46
46
  "react-dom": "^18.2.0 || ^19.0.0"
@@ -1,366 +0,0 @@
1
- import {
2
- GdsIcons,
3
- GdsVocabulary,
4
- StateBlock
5
- } from "./chunk-6B42ANK7.mjs";
6
-
7
- // src/SemanticButton.tsx
8
- import { useState, useEffect } from "react";
9
- import { Button } from "@mantine/core";
10
- import { useGdsTranslation } from "@doneisbetter/gds-theme";
11
- import { IconCheck, IconX } from "@tabler/icons-react";
12
- import { jsx } from "react/jsx-runtime";
13
- function SemanticButton({ action, loading, feedbackState, feedbackText, ...props }) {
14
- const { t } = useGdsTranslation();
15
- const config = GdsVocabulary[action];
16
- const [internalFeedback, setInternalFeedback] = useState(null);
17
- useEffect(() => {
18
- if (feedbackState) {
19
- setInternalFeedback(feedbackState);
20
- const timer = setTimeout(() => setInternalFeedback(null), 2e3);
21
- return () => clearTimeout(timer);
22
- }
23
- }, [feedbackState]);
24
- let Icon = config.icon;
25
- let label = t(config.id, config.defaultMessage);
26
- let color = props.color;
27
- if (internalFeedback === "success") {
28
- const defaultFeedback = "feedback" in config && config.feedback ? config.feedback : { icon: IconCheck, color: "teal", messageId: "gds.feedback.saved" };
29
- Icon = defaultFeedback.icon;
30
- label = feedbackText || t(defaultFeedback.messageId, "Success");
31
- color = defaultFeedback.color;
32
- } else if (internalFeedback === "error") {
33
- Icon = IconX;
34
- label = feedbackText || t("gds.feedback.error", "Something went wrong");
35
- color = "red";
36
- }
37
- return /* @__PURE__ */ jsx(
38
- Button,
39
- {
40
- leftSection: /* @__PURE__ */ jsx(Icon, { size: "1rem" }),
41
- loading,
42
- color,
43
- ...props,
44
- children: label
45
- }
46
- );
47
- }
48
-
49
- // src/ConfirmDialog.tsx
50
- import { Modal, Group, Text } from "@mantine/core";
51
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
52
- function ConfirmDialog({
53
- opened,
54
- onClose,
55
- onConfirm,
56
- title,
57
- children,
58
- confirmAction = "confirm",
59
- cancelAction = "cancel",
60
- isDanger = true,
61
- loading = false
62
- }) {
63
- return /* @__PURE__ */ jsxs(Modal, { opened, onClose, title, centered: true, trapFocus: true, children: [
64
- /* @__PURE__ */ jsx2(Text, { size: "sm", mb: "xl", children }),
65
- /* @__PURE__ */ jsxs(Group, { justify: "flex-end", children: [
66
- /* @__PURE__ */ jsx2(SemanticButton, { action: cancelAction, variant: "default", onClick: onClose, disabled: loading }),
67
- /* @__PURE__ */ jsx2(SemanticButton, { action: confirmAction, color: isDanger ? "red" : "violet", onClick: onConfirm, loading })
68
- ] })
69
- ] });
70
- }
71
-
72
- // src/ThemeToggle.tsx
73
- import { ActionIcon, useMantineColorScheme, useComputedColorScheme } from "@mantine/core";
74
- import { useGdsTranslation as useGdsTranslation2 } from "@doneisbetter/gds-theme";
75
- import { jsx as jsx3 } from "react/jsx-runtime";
76
- function ThemeToggle({ size = "md" }) {
77
- const { setColorScheme } = useMantineColorScheme();
78
- const computedColorScheme = useComputedColorScheme("light", { getInitialValueInEffect: true });
79
- const { t } = useGdsTranslation2();
80
- const toggleColorScheme = () => {
81
- setColorScheme(computedColorScheme === "dark" ? "light" : "dark");
82
- };
83
- const isDark = computedColorScheme === "dark";
84
- return /* @__PURE__ */ jsx3(
85
- ActionIcon,
86
- {
87
- onClick: toggleColorScheme,
88
- variant: "default",
89
- size,
90
- "aria-label": t("gds.aria.themeToggle", "Toggle color scheme"),
91
- children: isDark ? /* @__PURE__ */ jsx3(GdsIcons.Sun, { size: "1.2rem" }) : /* @__PURE__ */ jsx3(GdsIcons.Moon, { size: "1.2rem" })
92
- }
93
- );
94
- }
95
-
96
- // src/GameBoardTile.tsx
97
- import { Center, Paper, Text as Text2, UnstyledButton, useMantineTheme } from "@mantine/core";
98
- import { useMediaQuery } from "@mantine/hooks";
99
- import { jsx as jsx4 } from "react/jsx-runtime";
100
- function GameBoardTile({
101
- face,
102
- revealed,
103
- matched,
104
- disabled,
105
- onPress,
106
- highlightColor
107
- }) {
108
- const theme = useMantineTheme();
109
- const reduceMotion = useMediaQuery("(prefers-reduced-motion: reduce)");
110
- const highlighted = revealed && !matched;
111
- const revealBg = highlightColor ?? (typeof theme.primaryColor === "string" ? `${theme.primaryColor}.5` : "violet.5");
112
- return /* @__PURE__ */ jsx4(UnstyledButton, { w: "100%", disabled, onClick: onPress, "aria-pressed": revealed, children: /* @__PURE__ */ jsx4(
113
- Paper,
114
- {
115
- withBorder: true,
116
- radius: "md",
117
- p: "md",
118
- bg: revealed ? revealBg : "dark.6",
119
- styles: {
120
- root: {
121
- aspectRatio: "1",
122
- opacity: matched ? 0.55 : 1,
123
- cursor: disabled ? "not-allowed" : "pointer",
124
- transition: reduceMotion ? "opacity 0.2s ease" : "transform 0.25s ease, background-color 0.25s ease, opacity 0.25s ease",
125
- transform: reduceMotion || !highlighted ? "scale(1)" : "scale(1.02)"
126
- }
127
- },
128
- children: /* @__PURE__ */ jsx4(Center, { h: "100%", children: /* @__PURE__ */ jsx4(Text2, { size: "xl", fw: 700, children: face }) })
129
- }
130
- ) });
131
- }
132
-
133
- // src/DocsCodeBlock.tsx
134
- import { useState as useState2 } from "react";
135
- import { ActionIcon as ActionIcon2, Code, Group as Group2, Paper as Paper2, Stack, Text as Text3 } from "@mantine/core";
136
- import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
137
- function DocsCodeBlock({ code, language, title, withCopy = true }) {
138
- const [copied, setCopied] = useState2(false);
139
- const handleCopy = async () => {
140
- if (!navigator?.clipboard) {
141
- return;
142
- }
143
- await navigator.clipboard.writeText(code);
144
- setCopied(true);
145
- window.setTimeout(() => setCopied(false), 1200);
146
- };
147
- return /* @__PURE__ */ jsx5(Paper2, { withBorder: true, radius: "lg", p: "md", children: /* @__PURE__ */ jsxs2(Stack, { gap: "sm", children: [
148
- title || withCopy ? /* @__PURE__ */ jsxs2(Group2, { justify: "space-between", align: "center", children: [
149
- /* @__PURE__ */ jsxs2(Stack, { gap: 0, children: [
150
- title ? /* @__PURE__ */ jsx5(Text3, { fw: 600, children: title }) : null,
151
- language ? /* @__PURE__ */ jsx5(Text3, { size: "xs", c: "dimmed", children: language }) : null
152
- ] }),
153
- withCopy ? /* @__PURE__ */ jsx5(
154
- ActionIcon2,
155
- {
156
- variant: "subtle",
157
- "aria-label": copied ? "Copied code block" : "Copy code block",
158
- onClick: () => {
159
- void handleCopy();
160
- },
161
- children: /* @__PURE__ */ jsx5(GdsIcons.Copy, { size: "1rem" })
162
- }
163
- ) : null
164
- ] }) : null,
165
- /* @__PURE__ */ jsx5(Code, { block: true, children: code })
166
- ] }) });
167
- }
168
-
169
- // src/UploadDropzone.tsx
170
- import { useRef, useState as useState3 } from "react";
171
- import { Box, Button as Button2, Group as Group3, Stack as Stack2, Text as Text4 } from "@mantine/core";
172
- import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
173
- function UploadDropzone({
174
- title,
175
- description,
176
- onFilesSelected,
177
- accept,
178
- multiple = true,
179
- actionLabel = "Choose files",
180
- mode = "panel"
181
- }) {
182
- const inputRef = useRef(null);
183
- const [dragging, setDragging] = useState3(false);
184
- const UploadIcon = GdsIcons.Upload;
185
- const forwardFiles = (files) => {
186
- if (!files?.length || !onFilesSelected) {
187
- return;
188
- }
189
- onFilesSelected(Array.from(files));
190
- };
191
- return /* @__PURE__ */ jsxs3(
192
- Box,
193
- {
194
- onDragOver: (event) => {
195
- event.preventDefault();
196
- setDragging(true);
197
- },
198
- onDragLeave: () => setDragging(false),
199
- onDrop: (event) => {
200
- event.preventDefault();
201
- setDragging(false);
202
- forwardFiles(event.dataTransfer.files);
203
- },
204
- p: mode === "inline" ? "md" : "xl",
205
- style: {
206
- border: `1px dashed var(${dragging ? "--mantine-color-violet-6" : "--mantine-color-default-border"})`,
207
- borderRadius: "var(--mantine-radius-lg)",
208
- background: dragging ? "var(--mantine-color-violet-light)" : "transparent"
209
- },
210
- children: [
211
- /* @__PURE__ */ jsx6(
212
- "input",
213
- {
214
- ref: inputRef,
215
- type: "file",
216
- hidden: true,
217
- accept,
218
- multiple,
219
- onChange: (event) => forwardFiles(event.currentTarget.files)
220
- }
221
- ),
222
- /* @__PURE__ */ jsxs3(Stack2, { align: mode === "inline" ? "flex-start" : "center", ta: mode === "inline" ? "left" : "center", gap: "sm", children: [
223
- /* @__PURE__ */ jsx6(UploadIcon, { size: "1.5rem" }),
224
- /* @__PURE__ */ jsx6(Text4, { fw: 600, children: title }),
225
- description ? /* @__PURE__ */ jsx6(Text4, { size: "sm", c: "dimmed", children: description }) : null,
226
- /* @__PURE__ */ jsx6(Group3, { children: /* @__PURE__ */ jsx6(Button2, { variant: "light", onClick: () => inputRef.current?.click(), children: actionLabel }) })
227
- ] })
228
- ]
229
- }
230
- );
231
- }
232
-
233
- // src/AccessRecoveryPanel.tsx
234
- import { Group as Group4 } from "@mantine/core";
235
- import { useGdsTranslation as useGdsTranslation3 } from "@doneisbetter/gds-theme";
236
- import { jsx as jsx7 } from "react/jsx-runtime";
237
- var stateBlockVariantByState = {
238
- unauthenticated: "permission",
239
- "expired-session": "info",
240
- forbidden: "permission",
241
- missing: "error",
242
- unavailable: "error"
243
- };
244
- var defaultCopyByState = {
245
- unauthenticated: {
246
- title: "Sign in required",
247
- description: "Please sign in to continue to this content."
248
- },
249
- "expired-session": {
250
- title: "Session expired",
251
- description: "Sign in again or retry to continue where you left off."
252
- },
253
- forbidden: {
254
- title: "You do not have access",
255
- description: "This content is outside your current permissions or scope."
256
- },
257
- missing: {
258
- title: "Content not found",
259
- description: "The resource may have moved, been deleted, or never existed in this scope."
260
- },
261
- unavailable: {
262
- title: "Content is temporarily unavailable",
263
- description: "Try again in a moment or return to a safe destination."
264
- }
265
- };
266
- function defaultActionsForState(state, {
267
- onRetry,
268
- onSignIn,
269
- onBack,
270
- supportAction
271
- }) {
272
- const signInAction = onSignIn ? { action: "login", onClick: onSignIn } : null;
273
- const retryAction = onRetry ? { action: "refresh", onClick: onRetry, variant: "light" } : null;
274
- const backAction = onBack ? { action: "back", onClick: onBack, variant: "default" } : null;
275
- switch (state) {
276
- case "unauthenticated":
277
- return { primary: signInAction, secondary: backAction, tertiary: supportAction ?? null };
278
- case "expired-session":
279
- return {
280
- primary: signInAction ?? retryAction,
281
- secondary: retryAction && signInAction ? retryAction : backAction,
282
- tertiary: supportAction ?? null
283
- };
284
- case "forbidden":
285
- return { primary: backAction, secondary: supportAction ?? null, tertiary: null };
286
- case "missing":
287
- return { primary: backAction, secondary: supportAction ?? null, tertiary: null };
288
- case "unavailable":
289
- return {
290
- primary: retryAction ?? backAction,
291
- secondary: retryAction && backAction ? backAction : supportAction ?? null,
292
- tertiary: retryAction && backAction ? supportAction ?? null : null
293
- };
294
- }
295
- }
296
- function ActionGroup({
297
- primaryAction,
298
- secondaryAction,
299
- tertiaryAction
300
- }) {
301
- const actions = [primaryAction, secondaryAction, tertiaryAction].filter(Boolean);
302
- if (actions.length === 0) {
303
- return null;
304
- }
305
- return /* @__PURE__ */ jsx7(Group4, { gap: "sm", justify: "center", wrap: "wrap", children: actions.map((actionConfig, index) => /* @__PURE__ */ jsx7(
306
- SemanticButton,
307
- {
308
- action: actionConfig.action,
309
- onClick: actionConfig.onClick,
310
- loading: actionConfig.loading,
311
- disabled: actionConfig.disabled,
312
- color: actionConfig.color,
313
- variant: actionConfig.variant ?? (index === 0 ? "filled" : "default")
314
- },
315
- `${actionConfig.action}-${index}`
316
- )) });
317
- }
318
- function AccessRecoveryPanel({
319
- state,
320
- title,
321
- description,
322
- primaryAction,
323
- secondaryAction,
324
- tertiaryAction,
325
- onRetry,
326
- onSignIn,
327
- onBack,
328
- supportAction,
329
- compact = false
330
- }) {
331
- const { t } = useGdsTranslation3();
332
- const defaultCopy = defaultCopyByState[state];
333
- const defaults = defaultActionsForState(state, {
334
- onRetry,
335
- onSignIn,
336
- onBack,
337
- supportAction
338
- });
339
- return /* @__PURE__ */ jsx7(
340
- StateBlock,
341
- {
342
- variant: stateBlockVariantByState[state],
343
- compact,
344
- title: title ?? t(`gds.accessRecovery.${state}.title`, defaultCopy.title),
345
- description: description ?? t(`gds.accessRecovery.${state}.description`, defaultCopy.description),
346
- action: /* @__PURE__ */ jsx7(
347
- ActionGroup,
348
- {
349
- primaryAction: primaryAction ?? defaults.primary,
350
- secondaryAction: secondaryAction ?? defaults.secondary,
351
- tertiaryAction: tertiaryAction ?? defaults.tertiary
352
- }
353
- )
354
- }
355
- );
356
- }
357
-
358
- export {
359
- SemanticButton,
360
- ConfirmDialog,
361
- ThemeToggle,
362
- GameBoardTile,
363
- DocsCodeBlock,
364
- UploadDropzone,
365
- AccessRecoveryPanel
366
- };