@gntik-ai/blocks 0.9.0 → 0.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.
Files changed (162) hide show
  1. package/dist/index.d.ts +426 -55
  2. package/dist/index.js +2275 -639
  3. package/dist/index.js.map +1 -1
  4. package/package.json +6 -6
  5. package/src/auth/ForgotPasswordForm/ForgotPasswordForm.labels.test.tsx +179 -0
  6. package/src/auth/ForgotPasswordForm/ForgotPasswordForm.tsx +59 -24
  7. package/src/auth/ForgotPasswordForm/block.meta.ts +22 -1
  8. package/src/auth/ForgotPasswordForm/examples/Labels.tsx +29 -0
  9. package/src/auth/MfaChallenge/MfaChallenge.labels.test.tsx +139 -0
  10. package/src/auth/MfaChallenge/MfaChallenge.tsx +69 -23
  11. package/src/auth/MfaChallenge/block.meta.ts +29 -1
  12. package/src/auth/MfaChallenge/examples/Labels.tsx +28 -0
  13. package/src/auth/ResetPasswordForm/ResetPasswordForm.labels.test.tsx +104 -0
  14. package/src/auth/ResetPasswordForm/ResetPasswordForm.tsx +42 -15
  15. package/src/auth/ResetPasswordForm/block.meta.ts +17 -1
  16. package/src/auth/ResetPasswordForm/examples/Labels.tsx +28 -0
  17. package/src/auth/SignInForm/SignInForm.labels.test.tsx +137 -0
  18. package/src/auth/SignInForm/SignInForm.tsx +43 -16
  19. package/src/auth/SignInForm/block.meta.ts +22 -1
  20. package/src/auth/SignInForm/examples/Labels.tsx +29 -0
  21. package/src/auth/SignUpForm/SignUpForm.labels.test.tsx +217 -0
  22. package/src/auth/SignUpForm/SignUpForm.tsx +65 -26
  23. package/src/auth/SignUpForm/block.meta.ts +27 -1
  24. package/src/auth/SignUpForm/examples/Labels.tsx +29 -0
  25. package/src/auth/SsoButtons/SsoButtons.labels.test.tsx +30 -0
  26. package/src/auth/SsoButtons/SsoButtons.tsx +10 -2
  27. package/src/auth/SsoButtons/block.meta.ts +8 -1
  28. package/src/auth/SsoButtons/examples/Labels.tsx +24 -0
  29. package/src/auth/shared.i18n.test.tsx +71 -0
  30. package/src/auth/shared.tsx +48 -11
  31. package/src/billing/CostBreakdown/CostBreakdown.test.tsx +10 -0
  32. package/src/billing/CostBreakdown/CostBreakdown.tsx +50 -43
  33. package/src/billing/SpendVsBudget/SpendVsBudget.test.tsx +10 -0
  34. package/src/billing/SpendVsBudget/SpendVsBudget.tsx +35 -31
  35. package/src/builders/FlowBuilder/FlowBuilder.test.tsx +237 -2
  36. package/src/builders/FlowBuilder/FlowBuilder.tsx +101 -29
  37. package/src/builders/FlowBuilder/block.meta.ts +1 -1
  38. package/src/builders/FlowBuilder/connections.ts +30 -12
  39. package/src/builders/FlowBuilder/examples/ControlledGraph.tsx +8 -0
  40. package/src/builders/FlowBuilder/graph-state.ts +78 -0
  41. package/src/builders/LogViewer/LogViewer.labels.test.tsx +90 -0
  42. package/src/builders/LogViewer/LogViewer.levels.test.tsx +49 -0
  43. package/src/builders/LogViewer/LogViewer.tsx +72 -18
  44. package/src/builders/LogViewer/LogViewer.wrap.test.tsx +181 -0
  45. package/src/builders/LogViewer/block.meta.ts +19 -1
  46. package/src/builders/LogViewer/examples/Spanish.tsx +30 -0
  47. package/src/builders/LogViewer/examples/Wrap.tsx +62 -0
  48. package/src/builders/LogViewer/use-wrapped-log-rows.ts +42 -0
  49. package/src/data-display/ChartCard/ChartCard.locale.test.tsx +15 -0
  50. package/src/data-display/ChartCard/ChartCard.test.tsx +9 -0
  51. package/src/data-display/ChartCard/ChartCard.tsx +81 -67
  52. package/src/data-display/ChartCard/block.meta.ts +1 -1
  53. package/src/data-display/DescriptionListCard/DescriptionListCard.labels.test.tsx +73 -0
  54. package/src/data-display/DescriptionListCard/DescriptionListCard.options.test.tsx +64 -0
  55. package/src/data-display/DescriptionListCard/DescriptionListCard.tsx +74 -23
  56. package/src/data-display/DescriptionListCard/block.meta.ts +11 -1
  57. package/src/data-display/DescriptionListCard/examples/Spanish.tsx +29 -0
  58. package/src/feedback/EmptyStates/EmptyStates.labels.test.tsx +185 -0
  59. package/src/feedback/EmptyStates/EmptyStates.tsx +101 -30
  60. package/src/feedback/EmptyStates/NoAccessEmpty.options.test.tsx +38 -0
  61. package/src/feedback/EmptyStates/block.meta.ts +73 -1
  62. package/src/feedback/EmptyStates/examples/Spanish.tsx +48 -0
  63. package/src/feedback/ErrorPanel/ErrorPanel.labels.test.tsx +99 -0
  64. package/src/feedback/ErrorPanel/ErrorPanel.tsx +38 -9
  65. package/src/feedback/ErrorPanel/block.meta.ts +19 -1
  66. package/src/feedback/ErrorPanel/examples/Spanish.tsx +30 -0
  67. package/src/feedback/InlineCallout/InlineCallout.labels.test.tsx +62 -0
  68. package/src/feedback/InlineCallout/InlineCallout.tsx +22 -9
  69. package/src/feedback/InlineCallout/block.meta.ts +9 -1
  70. package/src/feedback/InlineCallout/examples/Spanish.tsx +19 -0
  71. package/src/feedback/Skeletons/Skeletons.labels.test.tsx +24 -0
  72. package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.labels.test.tsx +115 -0
  73. package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.tsx +63 -21
  74. package/src/forms/CreateApiKeyDialog/block.meta.ts +22 -1
  75. package/src/forms/CreateApiKeyDialog/examples/Labels.tsx +29 -0
  76. package/src/forms/CredentialDisclosureDialog/CredentialDisclosureDialog.labels.test.tsx +165 -0
  77. package/src/forms/CredentialDisclosureDialog/CredentialDisclosureDialog.tsx +31 -8
  78. package/src/forms/CredentialDisclosureDialog/SecretCopy.tsx +16 -8
  79. package/src/forms/CredentialDisclosureDialog/block.meta.ts +19 -1
  80. package/src/forms/CredentialDisclosureDialog/examples/Labels.tsx +38 -0
  81. package/src/forms/DangerZone/ConfirmDestructiveDialog.tsx +17 -3
  82. package/src/forms/DangerZone/DangerZone.labels.test.tsx +87 -0
  83. package/src/forms/DangerZone/DangerZone.tsx +20 -5
  84. package/src/forms/DangerZone/block.meta.ts +10 -1
  85. package/src/forms/DangerZone/examples/Labels.tsx +29 -0
  86. package/src/forms/DateRangeFilter/DateRangeFilter.labels.test.tsx +52 -0
  87. package/src/forms/DateRangeFilter/DateRangeFilter.tsx +11 -3
  88. package/src/forms/DateRangeFilter/block.meta.ts +8 -1
  89. package/src/forms/DateRangeFilter/examples/Labels.tsx +28 -0
  90. package/src/forms/DialogWizard/DialogWizard.labels.test.tsx +37 -0
  91. package/src/forms/DialogWizard/DialogWizard.tsx +13 -2
  92. package/src/forms/DialogWizard/block.meta.ts +7 -1
  93. package/src/forms/DialogWizard/examples/Labels.tsx +39 -0
  94. package/src/forms/FileUploadPanel/FileUploadPanel.labels.test.tsx +126 -0
  95. package/src/forms/FileUploadPanel/FileUploadPanel.test.tsx +22 -1
  96. package/src/forms/FileUploadPanel/FileUploadPanel.tsx +85 -22
  97. package/src/forms/FileUploadPanel/block.meta.ts +22 -1
  98. package/src/forms/FileUploadPanel/examples/Labels.tsx +29 -0
  99. package/src/forms/FileUploadPanel/fixtures.ts +0 -12
  100. package/src/forms/FileUploadPanel/format-bytes.test.ts +8 -0
  101. package/src/forms/FormSection/FormSection.labels.test.tsx +37 -0
  102. package/src/forms/FormSection/FormSection.tsx +14 -3
  103. package/src/forms/FormSection/block.meta.ts +7 -1
  104. package/src/forms/FormSection/examples/Labels.tsx +27 -0
  105. package/src/forms/InviteMembersDialog/InviteMembersDialog.labels.test.tsx +87 -0
  106. package/src/forms/InviteMembersDialog/InviteMembersDialog.tsx +51 -16
  107. package/src/forms/InviteMembersDialog/block.meta.ts +20 -1
  108. package/src/forms/InviteMembersDialog/examples/Labels.tsx +28 -0
  109. package/src/forms/SettingsRow/SettingsRow.labels.test.tsx +33 -0
  110. package/src/forms/SettingsRow/SettingsRow.tsx +14 -3
  111. package/src/forms/SettingsRow/block.meta.ts +7 -1
  112. package/src/forms/SettingsRow/examples/Labels.tsx +27 -0
  113. package/src/forms/ValidationSummary/ValidationSummary.labels.test.tsx +47 -0
  114. package/src/forms/ValidationSummary/ValidationSummary.tsx +9 -3
  115. package/src/forms/ValidationSummary/block.meta.ts +6 -1
  116. package/src/forms/ValidationSummary/examples/Labels.tsx +24 -0
  117. package/src/forms/index.ts +5 -1
  118. package/src/forms/translated-content.tsx +12 -0
  119. package/src/page-chrome/PageHeader/PageHeader.labels.test.tsx +56 -0
  120. package/src/page-chrome/PageHeader/PageHeader.options.test.tsx +34 -0
  121. package/src/page-chrome/PageHeader/PageHeader.tsx +26 -5
  122. package/src/page-chrome/PageHeader/block.meta.ts +8 -1
  123. package/src/page-chrome/PageHeader/examples/Labels.tsx +16 -0
  124. package/src/page-chrome/PageHeader/examples/Spanish.tsx +11 -0
  125. package/src/scheduling/AgendaList/AgendaList.test.tsx +25 -0
  126. package/src/scheduling/AgendaList/AgendaList.tsx +7 -2
  127. package/src/scheduling/AgendaList/AgendaListLocale.test.tsx +11 -0
  128. package/src/scheduling/AgendaList/block.meta.ts +1 -1
  129. package/src/scheduling/AgendaList/examples/Locale.tsx +29 -0
  130. package/src/scheduling/MonthCalendar/MonthCalendar.test.tsx +111 -1
  131. package/src/scheduling/MonthCalendar/MonthCalendar.tsx +19 -9
  132. package/src/scheduling/MonthCalendar/block.meta.ts +1 -1
  133. package/src/scheduling/MonthCalendar/examples/Locale.tsx +19 -0
  134. package/src/scheduling/WeekCalendar/WeekCalendar.test.tsx +73 -2
  135. package/src/scheduling/WeekCalendar/WeekCalendar.tsx +26 -12
  136. package/src/scheduling/WeekCalendar/block.meta.ts +1 -1
  137. package/src/scheduling/WeekCalendar/examples/Locale.tsx +19 -0
  138. package/src/scheduling/shared/dates.test.ts +75 -0
  139. package/src/scheduling/shared/dates.ts +46 -22
  140. package/src/scheduling/shared/useSchedulingClock.ts +13 -0
  141. package/src/shell/GlobalSearch/GlobalSearch.test.tsx +12 -0
  142. package/src/shell/GlobalSearch/fixtures.ts +2 -2
  143. package/src/tables/DataTable/DataTable.cross-page-selection.test.tsx +322 -0
  144. package/src/tables/DataTable/DataTable.labels.test.tsx +74 -0
  145. package/src/tables/DataTable/DataTable.server-pagination.test.tsx +1 -1
  146. package/src/tables/DataTable/DataTable.single-select.test.tsx +47 -7
  147. package/src/tables/DataTable/DataTable.test.tsx +55 -0
  148. package/src/tables/DataTable/DataTable.tsx +134 -67
  149. package/src/tables/DataTable/block.meta.ts +21 -3
  150. package/src/tables/DataTable/data-table-props.ts +14 -5
  151. package/src/tables/DataTable/data-table-row.tsx +7 -3
  152. package/src/tables/DataTable/data-table-utils.ts +2 -0
  153. package/src/tables/DataTable/examples/client-selection.tsx +33 -0
  154. package/src/tables/DataTable/examples/paginated-single-selection.tsx +46 -0
  155. package/src/tables/DataTable/examples/server-pagination.tsx +55 -15
  156. package/src/tables/DataTable/labels.ts +4 -0
  157. package/src/tables/DataTable/selection-strip.tsx +31 -0
  158. package/src/tables/DataTable/single-selection.tsx +0 -7
  159. package/src/tables/DataTable/use-multiple-selection.ts +86 -0
  160. package/src/tables/PaginationFooter/PaginationFooter.i18n.test.tsx +26 -0
  161. package/src/test/OptInDefaults.test.tsx +27 -0
  162. package/src/test/fixtures/opt-in-defaults.json +10 -0
@@ -0,0 +1,87 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import userEvent from '@testing-library/user-event';
3
+ import { I18nProvider, en, es } from '@gntik-ai/ui';
4
+ import { InviteMembersDialog, type InviteMembersDialogLabels } from './InviteMembersDialog';
5
+ import { expectNoAxeViolations } from '../../test/a11y';
6
+ it.each(['none', 'es'])('translates every default and validates through email chips under %s', async (locale) => {
7
+ const m = locale === 'es' ? es : en;
8
+ const block = <InviteMembersDialog onInvite={() => Promise.reject(null)} />;
9
+ render(locale === 'es' ? <I18nProvider locale="es">{block}</I18nProvider> : block);
10
+ await userEvent.click(screen.getByRole('button', { name: m['inviteMembers.title'] }));
11
+ const dialog = await screen.findByRole('dialog', { name: m['inviteMembers.title'] });
12
+ expect(dialog).toHaveAccessibleDescription(m['inviteMembers.description']);
13
+ const input = screen.getByPlaceholderText(m['inviteMembers.placeholder']);
14
+ expect(input).toHaveAccessibleName(m['inviteMembers.emails']);
15
+ for (const key of ['role', 'message'] as const) expect(screen.getByText(m[`inviteMembers.${key}`])).toBeVisible();
16
+ expect(screen.getByPlaceholderText(m['inviteMembers.messagePlaceholder'])).toBeVisible();
17
+ expect(screen.getByRole('button', { name: m['inviteMembers.cancel'] })).toBeVisible();
18
+ await userEvent.click(screen.getByRole('button', { name: m['inviteMembers.submit'] }));
19
+ expect(screen.getByText(m['inviteMembers.emailRequired'])).toBeVisible();
20
+ await userEvent.type(input, 'bad{Enter}');
21
+ await userEvent.click(screen.getByRole('button', { name: m['inviteMembers.submit'] }));
22
+ expect(screen.getByText(locale === 'es' ? 'Corrige 1 dirección no válida.' : 'Fix 1 invalid address.')).toBeVisible();
23
+ expect(screen.getByRole('list', { name: m['inviteMembers.listLabel'] })).toBeVisible();
24
+ expect(
25
+ screen.getByTitle(
26
+ locale === 'es' ? 'bad no es una dirección de correo válida' : 'bad is not a valid email address',
27
+ ),
28
+ ).toBeInTheDocument();
29
+ await userEvent.click(screen.getByRole('button', { name: locale === 'es' ? 'Quitar bad' : 'Remove bad' }));
30
+ await userEvent.type(input, 'a@example.com, b@example.com,');
31
+ await userEvent.click(
32
+ screen.getByRole('button', { name: locale === 'es' ? 'Enviar 2 invitaciones' : 'Send 2 invitations' }),
33
+ );
34
+ expect(await screen.findByText(m['inviteMembers.fallbackError'])).toBeVisible();
35
+ expect(screen.getByText(m['inviteMembers.errorTitle'])).toBeVisible();
36
+ if (locale === 'es') await expectNoAxeViolations(dialog);
37
+ });
38
+ it.each(['en', 'es'])('honours overrides below existing title and description props under %s', async (locale) => {
39
+ const labels: InviteMembersDialogLabels = {
40
+ title: 'Custom title',
41
+ description: 'Custom description',
42
+ emails: 'Custom emails',
43
+ placeholder: 'Custom placeholder',
44
+ listLabel: 'Custom listLabel',
45
+ role: 'Custom role',
46
+ message: 'Custom message',
47
+ messagePlaceholder: 'Custom messagePlaceholder',
48
+ emailRequired: 'Custom emailRequired',
49
+ errorTitle: 'Custom errorTitle',
50
+ fallbackError: 'Custom fallbackError',
51
+ cancel: 'Custom cancel',
52
+ submit: 'Custom submit',
53
+ emailInvalid: (email) => `Custom invalid ${email}`,
54
+ fixInvalid: (count) => `Custom fix ${count}`,
55
+ submitMany: (count) => `Custom send ${count}`,
56
+ };
57
+ const { rerender } = render(
58
+ <I18nProvider locale={locale}>
59
+ <InviteMembersDialog labels={labels} onInvite={() => Promise.reject(null)} />
60
+ </I18nProvider>,
61
+ );
62
+ await userEvent.click(screen.getByRole('button', { name: labels.title }));
63
+ expect(await screen.findByRole('dialog', { name: labels.title })).toHaveAccessibleDescription(labels.description);
64
+ const input = screen.getByPlaceholderText(labels.placeholder);
65
+ expect(input).toHaveAccessibleName(labels.emails);
66
+ for (const text of [labels.role, labels.message]) expect(screen.getByText(text)).toBeVisible();
67
+ expect(screen.getByPlaceholderText(labels.messagePlaceholder)).toBeVisible();
68
+ expect(screen.getByRole('button', { name: labels.cancel })).toBeVisible();
69
+ await userEvent.click(screen.getByRole('button', { name: labels.submit }));
70
+ expect(screen.getByText(labels.emailRequired)).toBeVisible();
71
+ await userEvent.type(input, 'bad{Enter}');
72
+ await userEvent.click(screen.getByRole('button', { name: labels.submit }));
73
+ expect(screen.getByText('Custom fix 1')).toBeVisible();
74
+ expect(screen.getByTitle('Custom invalid bad')).toBeInTheDocument();
75
+ expect(screen.getByRole('list', { name: labels.listLabel })).toBeVisible();
76
+ await userEvent.click(screen.getByRole('button', { name: locale === 'es' ? 'Quitar bad' : 'Remove bad' }));
77
+ await userEvent.type(input, 'a@example.com, b@example.com,');
78
+ await userEvent.click(screen.getByRole('button', { name: 'Custom send 2' }));
79
+ expect(await screen.findByText(labels.fallbackError)).toBeVisible();
80
+ expect(screen.getByText(labels.errorTitle)).toBeVisible();
81
+ rerender(
82
+ <I18nProvider locale={locale}>
83
+ <InviteMembersDialog labels={labels} title="Explicit title" description="Explicit description" />
84
+ </I18nProvider>,
85
+ );
86
+ expect(screen.getByRole('dialog', { name: 'Explicit title' })).toHaveAccessibleDescription('Explicit description');
87
+ });
@@ -1,4 +1,5 @@
1
1
  import {
2
+ useI18n,
2
3
  Alert,
3
4
  Button,
4
5
  Dialog,
@@ -33,7 +34,27 @@ export interface InvitePayload {
33
34
  message: string;
34
35
  }
35
36
 
37
+ export interface InviteMembersDialogLabels {
38
+ title: string;
39
+ description: string;
40
+ emails: string;
41
+ placeholder: string;
42
+ listLabel: string;
43
+ role: string;
44
+ message: string;
45
+ messagePlaceholder: string;
46
+ emailRequired: string;
47
+ emailInvalid: (email: string) => string;
48
+ fixInvalid: (count: number) => string;
49
+ errorTitle: string;
50
+ fallbackError: string;
51
+ cancel: string;
52
+ submit: string;
53
+ submitMany: (count: number) => string;
54
+ }
55
+
36
56
  export interface InviteMembersDialogProps {
57
+ labels?: Partial<InviteMembersDialogLabels>;
37
58
  roles?: RoleOption[];
38
59
  defaultRole?: string;
39
60
  /** Sends the invitations. A returned promise shows a loading state; a rejection shows its message. */
@@ -49,10 +70,9 @@ export interface InviteMembersDialogProps {
49
70
  description?: string;
50
71
  }
51
72
 
52
- const emailError = (t: string) => (EMAIL_RE.test(t) ? null : `${t} is not a valid email address`);
53
-
54
73
  /** Invite dialog: email chips with validation, a role and an optional message; submit with loading. */
55
74
  export function InviteMembersDialog({
75
+ labels,
56
76
  roles = memberRoles,
57
77
  defaultRole = 'member',
58
78
  onInvite,
@@ -61,9 +81,14 @@ export function InviteMembersDialog({
61
81
  defaultOpen = false,
62
82
  onOpenChange,
63
83
  trigger = <Button icon={UserPlus} />,
64
- title = 'Invite members',
65
- description = 'Invitations expire after 7 days. Separate addresses with commas or Enter.',
84
+ title: titleProp,
85
+ description: descriptionProp,
66
86
  }: InviteMembersDialogProps) {
87
+ const { t } = useI18n();
88
+ const title = titleProp ?? labels?.title ?? t('inviteMembers.title');
89
+ const description = descriptionProp ?? labels?.description ?? t('inviteMembers.description');
90
+ const emailError = (email: string) =>
91
+ EMAIL_RE.test(email) ? null : (labels?.emailInvalid?.(email) ?? t('inviteMembers.emailInvalid', { email }));
67
92
  const [innerOpen, setInnerOpen] = useState(defaultOpen);
68
93
  const [emails, setEmails] = useState<string[]>([]);
69
94
  const [role, setRole] = useState(defaultRole);
@@ -76,9 +101,9 @@ export function InviteMembersDialog({
76
101
  const invalidCount = emails.filter((e) => emailError(e)).length;
77
102
  const emailsProblem =
78
103
  emails.length === 0
79
- ? 'Add at least one email address.'
104
+ ? (labels?.emailRequired ?? t('inviteMembers.emailRequired'))
80
105
  : invalidCount > 0
81
- ? `Fix ${invalidCount} invalid ${invalidCount === 1 ? 'address' : 'addresses'}.`
106
+ ? (labels?.fixInvalid?.(invalidCount) ?? t('inviteMembers.fixInvalid', { count: invalidCount }))
82
107
  : null;
83
108
  const showEmailError = submitted && emailsProblem != null;
84
109
 
@@ -106,7 +131,7 @@ export function InviteMembersDialog({
106
131
  setOpen(false);
107
132
  } catch (e) {
108
133
  setLoading(false);
109
- setError(e instanceof Error ? e.message : 'The invitations could not be sent.');
134
+ setError(e instanceof Error ? e.message : (labels?.fallbackError ?? t('inviteMembers.fallbackError')));
110
135
  }
111
136
  };
112
137
 
@@ -129,20 +154,20 @@ export function InviteMembersDialog({
129
154
  >
130
155
  <DialogBody className="grid gap-5">
131
156
  <Field invalid={showEmailError}>
132
- <FieldLabel required>Email addresses</FieldLabel>
157
+ <FieldLabel required>{labels?.emails ?? t('inviteMembers.emails')}</FieldLabel>
133
158
  <TokenInput
134
159
  value={emails}
135
160
  onValueChange={setEmails}
136
161
  validate={emailError}
137
162
  maxItems={maxInvites}
138
- placeholder="name@company.com"
139
- listLabel="Invited addresses"
163
+ placeholder={labels?.placeholder ?? t('inviteMembers.placeholder')}
164
+ listLabel={labels?.listLabel ?? t('inviteMembers.listLabel')}
140
165
  invalid={showEmailError}
141
166
  />
142
167
  <FieldError match={showEmailError}>{emailsProblem}</FieldError>
143
168
  </Field>
144
169
  <Field>
145
- <FieldLabel>Role</FieldLabel>
170
+ <FieldLabel>{labels?.role ?? t('inviteMembers.role')}</FieldLabel>
146
171
  <Select
147
172
  value={role}
148
173
  onValueChange={(v) => v != null && setRole(v)}
@@ -160,20 +185,30 @@ export function InviteMembersDialog({
160
185
  {roleLabel && <FieldDescription>{roleLabel}</FieldDescription>}
161
186
  </Field>
162
187
  <Field>
163
- <FieldLabel>Message (optional)</FieldLabel>
188
+ <FieldLabel>{labels?.message ?? t('inviteMembers.message')}</FieldLabel>
164
189
  <Textarea
165
190
  rows={3}
166
191
  value={message}
167
192
  onValueChange={setMessage}
168
- placeholder="Join us on the billing-dashboard project."
193
+ placeholder={labels?.messagePlaceholder ?? t('inviteMembers.messagePlaceholder')}
169
194
  />
170
195
  </Field>
171
- {error && <Alert tone="destructive" title="Invitations not sent" description={error} />}
196
+ {error && (
197
+ <Alert
198
+ tone="destructive"
199
+ title={labels?.errorTitle ?? t('inviteMembers.errorTitle')}
200
+ description={error}
201
+ />
202
+ )}
172
203
  </DialogBody>
173
204
  <DialogFooter>
174
- <DialogClose render={<Button variant="ghost" disabled={loading} />}>Cancel</DialogClose>
205
+ <DialogClose render={<Button variant="ghost" disabled={loading} />}>
206
+ {labels?.cancel ?? t('inviteMembers.cancel')}
207
+ </DialogClose>
175
208
  <Button type="submit" loading={loading}>
176
- {emails.length > 1 ? `Send ${emails.length} invitations` : 'Send invitation'}
209
+ {emails.length > 1
210
+ ? (labels?.submitMany?.(emails.length) ?? t('inviteMembers.submitMany', { count: emails.length }))
211
+ : (labels?.submit ?? t('inviteMembers.submit'))}
177
212
  </Button>
178
213
  </DialogFooter>
179
214
  </form>
@@ -1,10 +1,29 @@
1
1
  import type { BlockMeta } from '../../meta';
2
+ import type { InviteMembersDialogLabels } from './InviteMembersDialog';
2
3
 
3
4
  export const meta: BlockMeta = {
4
5
  name: 'Invite members dialog',
5
6
  family: 'forms',
6
7
  status: 'stable',
7
8
  description:
8
- 'Dialog to invite people by email (validated chips) with a role and an optional message; submits with a loading state.',
9
+ 'Dialog to invite people by email (validated chips) with a role and an optional message; submits with a loading state. Optional labels?: Partial<InviteMembersDialogLabels> overrides built-in copy; explicit props and validation messages win, then labels, then I18nProvider (en/es). No provider preserves English; fixtures and caller content stay unchanged. Interactive preview: /preview.html?kind=block&id=invite-members-dialog--labels.',
10
+ labels: [
11
+ { key: 'title', type: 'string', state: 'Default content and accessible names' },
12
+ { key: 'description', type: 'string', state: 'Default content and accessible names' },
13
+ { key: 'emails', type: 'string', state: 'Default content and accessible names' },
14
+ { key: 'placeholder', type: 'string', state: 'Default content and accessible names' },
15
+ { key: 'listLabel', type: 'string', state: 'Default content and accessible names' },
16
+ { key: 'role', type: 'string', state: 'Default content and accessible names' },
17
+ { key: 'message', type: 'string', state: 'Default content and accessible names' },
18
+ { key: 'messagePlaceholder', type: 'string', state: 'Default content and accessible names' },
19
+ { key: 'emailRequired', type: 'string', state: 'Validation feedback' },
20
+ { key: 'emailInvalid', type: '(email: string) => string', state: 'Validation feedback' },
21
+ { key: 'fixInvalid', type: '(count: number) => string', state: 'Validation feedback' },
22
+ { key: 'errorTitle', type: 'string', state: 'Validation feedback' },
23
+ { key: 'fallbackError', type: 'string', state: 'Validation feedback' },
24
+ { key: 'cancel', type: 'string', state: 'Default content and accessible names' },
25
+ { key: 'submit', type: 'string', state: 'Default content and accessible names' },
26
+ { key: 'submitMany', type: '(count: number) => string', state: 'Default content and accessible names' },
27
+ ] satisfies Array<{ key: keyof InviteMembersDialogLabels; type: string; state: string }>,
9
28
  uses: ['Dialog', 'TokenInput', 'Select', 'Textarea', 'Field', 'Button', 'Alert'],
10
29
  };
@@ -0,0 +1,28 @@
1
+ import { Button, I18nProvider } from '@gntik-ai/ui';
2
+ import { useState } from 'react';
3
+ import { InviteMembersDialog, type InviteMembersDialogLabels } from '../InviteMembersDialog';
4
+
5
+ export default function Labels() {
6
+ const [spanish, setSpanish] = useState(false);
7
+ const [custom, setCustom] = useState(true);
8
+ const labels: Partial<InviteMembersDialogLabels> = {
9
+ title: 'Invite teammates',
10
+ submit: 'Invite teammate',
11
+ submitMany: (count) => `Invite ${count} teammates`,
12
+ };
13
+ return (
14
+ <div className="grid gap-4">
15
+ <div className="flex flex-wrap gap-2">
16
+ <Button variant="secondary" aria-pressed={spanish} onClick={() => setSpanish(!spanish)}>
17
+ Spanish catalog
18
+ </Button>
19
+ <Button variant="secondary" aria-pressed={custom} onClick={() => setCustom(!custom)}>
20
+ Custom labels
21
+ </Button>
22
+ </div>
23
+ <I18nProvider locale={spanish ? 'es' : 'en'}>
24
+ <InviteMembersDialog labels={custom ? labels : undefined} />
25
+ </I18nProvider>
26
+ </div>
27
+ );
28
+ }
@@ -0,0 +1,33 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { I18nProvider, es } from '@gntik-ai/ui';
3
+ import { SettingsRow } from './SettingsRow';
4
+ it('preserves English defaults and translates the label and description', () => {
5
+ const { rerender } = render(<SettingsRow />);
6
+ expect(screen.getByRole('switch', { name: 'Deployment notifications' })).toHaveAccessibleDescription(
7
+ 'Email the project owners when a deployment fails or is rolled back.',
8
+ );
9
+ rerender(
10
+ <I18nProvider locale="es">
11
+ <SettingsRow />
12
+ </I18nProvider>,
13
+ );
14
+ expect(screen.getByRole('switch', { name: 'Notificaciones de despliegue' })).toHaveAccessibleDescription(
15
+ es['settingsRow.description'],
16
+ );
17
+ expect(screen.getByText(es['settingsRow.label'])).toBeVisible();
18
+ });
19
+ it.each(['en', 'es'])('honours labels and explicit props under %s', (locale) => {
20
+ const labels = { label: 'Custom setting', description: 'Custom description' };
21
+ const { rerender } = render(
22
+ <I18nProvider locale={locale}>
23
+ <SettingsRow labels={labels} />
24
+ </I18nProvider>,
25
+ );
26
+ expect(screen.getByRole('switch', { name: labels.label })).toHaveAccessibleDescription(labels.description);
27
+ rerender(
28
+ <I18nProvider locale={locale}>
29
+ <SettingsRow labels={labels} label="Explicit setting" description="Explicit description" />
30
+ </I18nProvider>,
31
+ );
32
+ expect(screen.getByRole('switch', { name: 'Explicit setting' })).toHaveAccessibleDescription('Explicit description');
33
+ });
@@ -1,4 +1,4 @@
1
- import { Switch, cn } from '@gntik-ai/ui';
1
+ import { useI18n, Switch, cn } from '@gntik-ai/ui';
2
2
  import { useId, type ReactNode } from 'react';
3
3
 
4
4
  export interface SettingsRowControlIds {
@@ -8,7 +8,13 @@ export interface SettingsRowControlIds {
8
8
  descriptionId: string | undefined;
9
9
  }
10
10
 
11
+ export interface SettingsRowLabels {
12
+ label: string;
13
+ description: string;
14
+ }
15
+
11
16
  export interface SettingsRowProps {
17
+ labels?: Partial<SettingsRowLabels>;
12
18
  label?: ReactNode;
13
19
  description?: ReactNode;
14
20
  /**
@@ -27,8 +33,9 @@ export interface SettingsRowProps {
27
33
 
28
34
  /** One setting: label and description on the left, its control (a Switch by default) on the right. */
29
35
  export function SettingsRow({
30
- label = 'Deployment notifications',
31
- description = 'Email the project owners when a deployment fails or is rolled back.',
36
+ labels,
37
+ label: labelProp,
38
+ description: descriptionProp,
32
39
  control,
33
40
  checked,
34
41
  defaultChecked = true,
@@ -37,6 +44,10 @@ export function SettingsRow({
37
44
  children,
38
45
  className,
39
46
  }: SettingsRowProps) {
47
+ const { t } = useI18n();
48
+ const label = labelProp === undefined ? (labels?.label ?? t('settingsRow.label')) : labelProp;
49
+ const description =
50
+ descriptionProp === undefined ? (labels?.description ?? t('settingsRow.description')) : descriptionProp;
40
51
  const id = useId();
41
52
  const labelId = `${id}-label`;
42
53
  const descriptionId = description != null ? `${id}-desc` : undefined;
@@ -1,9 +1,15 @@
1
1
  import type { BlockMeta } from '../../meta';
2
+ import type { SettingsRowLabels } from './SettingsRow';
2
3
 
3
4
  export const meta: BlockMeta = {
4
5
  name: 'Settings row',
5
6
  family: 'forms',
6
7
  status: 'stable',
7
- description: 'A setting with its label and description on the left and a control (Switch by default) on the right.',
8
+ description:
9
+ 'A setting with its label and description on the left and a control (Switch by default) on the right. Optional labels?: Partial<SettingsRowLabels> overrides built-in copy; explicit props and validation messages win, then labels, then I18nProvider (en/es). No provider preserves English; fixtures and caller content stay unchanged. Interactive preview: /preview.html?kind=block&id=settings-row--labels.',
10
+ labels: [
11
+ { key: 'label', type: 'string', state: 'Default content and accessible names' },
12
+ { key: 'description', type: 'string', state: 'Default content and accessible names' },
13
+ ] satisfies Array<{ key: keyof SettingsRowLabels; type: string; state: string }>,
8
14
  uses: ['Switch'],
9
15
  };
@@ -0,0 +1,27 @@
1
+ import { Button, I18nProvider } from '@gntik-ai/ui';
2
+ import { useState } from 'react';
3
+ import { SettingsRow, type SettingsRowLabels } from '../SettingsRow';
4
+
5
+ export default function Labels() {
6
+ const [spanish, setSpanish] = useState(false);
7
+ const [custom, setCustom] = useState(true);
8
+ const labels: Partial<SettingsRowLabels> = {
9
+ label: 'Activity notifications',
10
+ description: 'Notify the workspace owners about new activity.',
11
+ };
12
+ return (
13
+ <div className="grid gap-4">
14
+ <div className="flex flex-wrap gap-2">
15
+ <Button variant="secondary" aria-pressed={spanish} onClick={() => setSpanish(!spanish)}>
16
+ Spanish catalog
17
+ </Button>
18
+ <Button variant="secondary" aria-pressed={custom} onClick={() => setCustom(!custom)}>
19
+ Custom labels
20
+ </Button>
21
+ </div>
22
+ <I18nProvider locale={spanish ? 'es' : 'en'}>
23
+ <SettingsRow labels={custom ? labels : undefined} />
24
+ </I18nProvider>
25
+ </div>
26
+ );
27
+ }
@@ -0,0 +1,47 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { I18nProvider } from '@gntik-ai/ui';
3
+ import { ValidationSummary } from './ValidationSummary';
4
+ const errors = [{ fieldId: 'email', label: 'Email', message: 'Consumer error' }];
5
+ it('preserves English and translates singular and plural counts', () => {
6
+ const { rerender } = render(<ValidationSummary errors={errors} />);
7
+ expect(screen.getByText('There is 1 problem with this form')).toBeVisible();
8
+ rerender(<ValidationSummary errors={[...errors, { fieldId: 'name', message: 'Another error' }]} />);
9
+ expect(screen.getByText('There are 2 problems with this form')).toBeVisible();
10
+ rerender(
11
+ <I18nProvider locale="es">
12
+ <ValidationSummary errors={errors} />
13
+ </I18nProvider>,
14
+ );
15
+ expect(screen.getByText('Hay 1 problema en este formulario')).toBeVisible();
16
+ rerender(
17
+ <I18nProvider locale="es">
18
+ <ValidationSummary errors={[...errors, { fieldId: 'name', message: 'Another error' }]} />
19
+ </I18nProvider>,
20
+ );
21
+ expect(screen.getByText('Hay 2 problemas en este formulario')).toBeVisible();
22
+ expect(screen.getByRole('link', { name: 'Email: Consumer error' })).toBeVisible();
23
+ });
24
+ it.each(['en', 'es'])('honours title prop before labels under %s', (locale) => {
25
+ const labels = { title: (count: number) => `Custom ${count} issues` };
26
+ const { rerender } = render(
27
+ <I18nProvider locale={locale}>
28
+ <ValidationSummary errors={errors} labels={labels} />
29
+ </I18nProvider>,
30
+ );
31
+ expect(screen.getByText('Custom 1 issues')).toBeVisible();
32
+ rerender(
33
+ <I18nProvider locale={locale}>
34
+ <ValidationSummary errors={errors} labels={labels} title="Explicit title" />
35
+ </I18nProvider>,
36
+ );
37
+ expect(screen.getByText('Explicit title')).toBeVisible();
38
+ });
39
+
40
+ it('keeps English counts byte-identical above the grouping threshold', () => {
41
+ render(
42
+ <ValidationSummary
43
+ errors={Array.from({ length: 1000 }, (_, i) => ({ fieldId: `field-${i}`, message: 'Consumer error' }))}
44
+ />,
45
+ );
46
+ expect(screen.getByText('There are 1000 problems with this form')).toBeVisible();
47
+ });
@@ -1,10 +1,15 @@
1
- import { Alert, Link, cn } from '@gntik-ai/ui';
1
+ import { useI18n, Alert, Link, cn } from '@gntik-ai/ui';
2
2
  import { useEffect, useRef, type ReactNode } from 'react';
3
3
  import { validationIssues, type ValidationIssue } from './fixtures';
4
4
 
5
5
  export type { ValidationIssue } from './fixtures';
6
6
 
7
+ export interface ValidationSummaryLabels {
8
+ title: (count: number) => string;
9
+ }
10
+
7
11
  export interface ValidationSummaryProps {
12
+ labels?: Partial<ValidationSummaryLabels>;
8
13
  errors?: ValidationIssue[];
9
14
  /** Increment on every submit attempt: the summary takes focus when there are errors. */
10
15
  submitCount?: number;
@@ -25,11 +30,13 @@ const focusField = (fieldId: string) => {
25
30
  * After a failed submit it takes focus, so screen readers announce it.
26
31
  */
27
32
  export function ValidationSummary({
33
+ labels,
28
34
  errors = validationIssues,
29
35
  submitCount = 0,
30
36
  title,
31
37
  className,
32
38
  }: ValidationSummaryProps) {
39
+ const { t } = useI18n();
33
40
  const ref = useRef<HTMLDivElement | null>(null);
34
41
  const hasErrors = errors.length > 0;
35
42
 
@@ -38,8 +45,7 @@ export function ValidationSummary({
38
45
  }, [submitCount, hasErrors]);
39
46
 
40
47
  if (!hasErrors) return null;
41
- const heading =
42
- title ?? `There ${errors.length === 1 ? 'is 1 problem' : `are ${errors.length} problems`} with this form`;
48
+ const heading = title ?? labels?.title?.(errors.length) ?? t('validationSummary.title', { count: errors.length });
43
49
  return (
44
50
  <Alert
45
51
  ref={ref}
@@ -1,9 +1,14 @@
1
1
  import type { BlockMeta } from '../../meta';
2
+ import type { ValidationSummaryLabels } from './ValidationSummary';
2
3
 
3
4
  export const meta: BlockMeta = {
4
5
  name: 'Validation summary',
5
6
  family: 'forms',
6
7
  status: 'stable',
7
- description: 'Error summary that lists every problem with a link to its field and takes focus after a failed submit.',
8
+ description:
9
+ 'Error summary that lists every problem with a link to its field and takes focus after a failed submit. Optional labels?: Partial<ValidationSummaryLabels> overrides built-in copy; explicit props and validation messages win, then labels, then I18nProvider (en/es). No provider preserves English; fixtures and caller content stay unchanged. Interactive preview: /preview.html?kind=block&id=validation-summary--labels.',
10
+ labels: [
11
+ { key: 'title', type: '(count: number) => string', state: 'Default content and accessible names' },
12
+ ] satisfies Array<{ key: keyof ValidationSummaryLabels; type: string; state: string }>,
8
13
  uses: ['Alert', 'Link'],
9
14
  };
@@ -0,0 +1,24 @@
1
+ import { Button, I18nProvider } from '@gntik-ai/ui';
2
+ import { useState } from 'react';
3
+ import { ValidationSummary, type ValidationSummaryLabels } from '../ValidationSummary';
4
+
5
+ export default function Labels() {
6
+ const [spanish, setSpanish] = useState(false);
7
+ const [custom, setCustom] = useState(true);
8
+ const labels: Partial<ValidationSummaryLabels> = { title: (count) => `Please resolve ${count} issues` };
9
+ return (
10
+ <div className="grid gap-4">
11
+ <div className="flex flex-wrap gap-2">
12
+ <Button variant="secondary" aria-pressed={spanish} onClick={() => setSpanish(!spanish)}>
13
+ Spanish catalog
14
+ </Button>
15
+ <Button variant="secondary" aria-pressed={custom} onClick={() => setCustom(!custom)}>
16
+ Custom labels
17
+ </Button>
18
+ </div>
19
+ <I18nProvider locale={spanish ? 'es' : 'en'}>
20
+ <ValidationSummary labels={custom ? labels : undefined} />
21
+ </I18nProvider>
22
+ </div>
23
+ );
24
+ }
@@ -19,7 +19,11 @@ export * from './DialogWizard/DialogWizard';
19
19
  export { meta as dialogWizardMeta } from './DialogWizard/block.meta';
20
20
  export { dialogWizardCopy, dialogWizardSteps } from './DialogWizard/fixtures';
21
21
  export { meta as validationSummaryMeta } from './ValidationSummary/block.meta';
22
- export { ConfirmDestructiveDialog, type ConfirmDestructiveDialogProps } from './DangerZone/ConfirmDestructiveDialog';
22
+ export {
23
+ ConfirmDestructiveDialog,
24
+ type ConfirmDestructiveDialogProps,
25
+ type ConfirmDestructiveDialogLabels,
26
+ } from './DangerZone/ConfirmDestructiveDialog';
23
27
  export { dangerZoneActions } from './DangerZone/fixtures';
24
28
  export { memberRoles } from './InviteMembersDialog/fixtures';
25
29
  export { apiKeyScopes, apiKeyExpiries, generateDemoSecret } from './CreateApiKeyDialog/fixtures';
@@ -0,0 +1,12 @@
1
+ import { Fragment, type ReactNode } from 'react';
2
+
3
+ /** Keep caller-owned rich content in place while the catalog controls sentence order. */
4
+ export function translatedContent(message: string, values: Record<string, ReactNode>): ReactNode {
5
+ return message
6
+ .split(/(\{\w+\})/)
7
+ .map((part, index) => (
8
+ <Fragment key={index}>
9
+ {part.startsWith('{') && part.endsWith('}') ? (values[part.slice(1, -1)] ?? part) : part}
10
+ </Fragment>
11
+ ));
12
+ }
@@ -0,0 +1,56 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { I18nProvider, es } from '@gntik-ai/ui';
3
+ import { PageHeader, type PageHeaderLabels } from './PageHeader';
4
+ import { pageHeaderMeta, pageHeaderTabs, pageHeaderActions } from './fixtures';
5
+
6
+ it('translates built-in header labels and leaves fixtures untouched', () => {
7
+ render(
8
+ <I18nProvider locale="es">
9
+ <PageHeader />
10
+ </I18nProvider>,
11
+ );
12
+ expect(screen.getByRole('heading', { name: es['pageHeader.title'] })).toHaveTextContent('Despliegues');
13
+ expect(screen.getByText(es['pageHeader.description'])).toBeVisible();
14
+ expect(screen.getByRole('button', { name: es['pageHeader.moreActions'] })).toBeVisible();
15
+ expect(screen.getByRole('tablist', { name: es['pageHeader.sections'] })).toBeVisible();
16
+ for (const item of pageHeaderMeta) expect(screen.getByText(String(item.value))).toBeVisible();
17
+ for (const tab of pageHeaderTabs) expect(screen.getByRole('tab', { name: new RegExp(tab.label) })).toBeVisible();
18
+ for (const action of pageHeaderActions)
19
+ expect(screen.getAllByRole('button', { name: action.label })[0]).toBeVisible();
20
+ });
21
+
22
+ it('preserves English and merges each override below explicit title and description props', () => {
23
+ const { rerender } = render(<PageHeader />);
24
+ expect(screen.getByRole('heading', { name: 'Deployments' })).toBeVisible();
25
+ expect(screen.getByText('Every build and release of this project across its environments.')).toBeVisible();
26
+ expect(screen.getByRole('button', { name: 'More actions' })).toBeVisible();
27
+ expect(screen.getByRole('tablist', { name: 'Page sections' })).toBeVisible();
28
+ const labels: PageHeaderLabels = {
29
+ title: 'Custom title',
30
+ description: 'Custom description',
31
+ moreActions: 'Custom actions',
32
+ sections: 'Custom sections',
33
+ };
34
+ const view = (overrides: Partial<PageHeaderLabels>, explicit = false) => (
35
+ <I18nProvider locale="es">
36
+ <PageHeader
37
+ labels={overrides}
38
+ title={explicit ? 'Explicit title' : undefined}
39
+ description={explicit ? 'Explicit description' : undefined}
40
+ />
41
+ </I18nProvider>
42
+ );
43
+ rerender(view(labels));
44
+ expect(screen.getByRole('heading', { name: labels.title })).toBeVisible();
45
+ expect(screen.getByText(labels.description)).toBeVisible();
46
+ expect(screen.getByRole('button', { name: labels.moreActions })).toBeVisible();
47
+ expect(screen.getByRole('tablist', { name: labels.sections })).toBeVisible();
48
+ rerender(view(labels, true));
49
+ expect(screen.getByRole('heading', { name: 'Explicit title' })).toBeVisible();
50
+ expect(screen.getByText('Explicit description')).toBeVisible();
51
+ rerender(view({ moreActions: '' }));
52
+ expect(screen.getByRole('heading', { name: es['pageHeader.title'] })).toBeVisible();
53
+ expect(screen.getByText(es['pageHeader.description'])).toBeVisible();
54
+ expect(screen.getByRole('tablist', { name: es['pageHeader.sections'] })).toBeVisible();
55
+ expect(screen.getByRole('button', { name: '' })).toBeVisible();
56
+ });