@gntik-ai/blocks 0.10.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 (111) hide show
  1. package/dist/index.d.ts +301 -40
  2. package/dist/index.js +1441 -297
  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/builders/LogViewer/LogViewer.levels.test.tsx +49 -0
  32. package/src/builders/LogViewer/LogViewer.tsx +29 -8
  33. package/src/builders/LogViewer/LogViewer.wrap.test.tsx +181 -0
  34. package/src/builders/LogViewer/block.meta.ts +6 -1
  35. package/src/builders/LogViewer/examples/Wrap.tsx +62 -0
  36. package/src/builders/LogViewer/use-wrapped-log-rows.ts +42 -0
  37. package/src/data-display/DescriptionListCard/DescriptionListCard.options.test.tsx +64 -0
  38. package/src/data-display/DescriptionListCard/DescriptionListCard.tsx +38 -17
  39. package/src/data-display/DescriptionListCard/block.meta.ts +1 -1
  40. package/src/data-display/DescriptionListCard/examples/Spanish.tsx +7 -0
  41. package/src/feedback/EmptyStates/EmptyStates.tsx +32 -14
  42. package/src/feedback/EmptyStates/NoAccessEmpty.options.test.tsx +38 -0
  43. package/src/feedback/EmptyStates/block.meta.ts +1 -1
  44. package/src/feedback/EmptyStates/examples/Spanish.tsx +7 -0
  45. package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.labels.test.tsx +115 -0
  46. package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.tsx +63 -21
  47. package/src/forms/CreateApiKeyDialog/block.meta.ts +22 -1
  48. package/src/forms/CreateApiKeyDialog/examples/Labels.tsx +29 -0
  49. package/src/forms/CredentialDisclosureDialog/CredentialDisclosureDialog.labels.test.tsx +165 -0
  50. package/src/forms/CredentialDisclosureDialog/CredentialDisclosureDialog.tsx +31 -8
  51. package/src/forms/CredentialDisclosureDialog/SecretCopy.tsx +16 -8
  52. package/src/forms/CredentialDisclosureDialog/block.meta.ts +19 -1
  53. package/src/forms/CredentialDisclosureDialog/examples/Labels.tsx +38 -0
  54. package/src/forms/DangerZone/ConfirmDestructiveDialog.tsx +17 -3
  55. package/src/forms/DangerZone/DangerZone.labels.test.tsx +87 -0
  56. package/src/forms/DangerZone/DangerZone.tsx +20 -5
  57. package/src/forms/DangerZone/block.meta.ts +10 -1
  58. package/src/forms/DangerZone/examples/Labels.tsx +29 -0
  59. package/src/forms/DateRangeFilter/DateRangeFilter.labels.test.tsx +52 -0
  60. package/src/forms/DateRangeFilter/DateRangeFilter.tsx +11 -3
  61. package/src/forms/DateRangeFilter/block.meta.ts +8 -1
  62. package/src/forms/DateRangeFilter/examples/Labels.tsx +28 -0
  63. package/src/forms/DialogWizard/DialogWizard.labels.test.tsx +37 -0
  64. package/src/forms/DialogWizard/DialogWizard.tsx +13 -2
  65. package/src/forms/DialogWizard/block.meta.ts +7 -1
  66. package/src/forms/DialogWizard/examples/Labels.tsx +39 -0
  67. package/src/forms/FileUploadPanel/FileUploadPanel.labels.test.tsx +126 -0
  68. package/src/forms/FileUploadPanel/FileUploadPanel.tsx +81 -18
  69. package/src/forms/FileUploadPanel/block.meta.ts +22 -1
  70. package/src/forms/FileUploadPanel/examples/Labels.tsx +29 -0
  71. package/src/forms/FormSection/FormSection.labels.test.tsx +37 -0
  72. package/src/forms/FormSection/FormSection.tsx +14 -3
  73. package/src/forms/FormSection/block.meta.ts +7 -1
  74. package/src/forms/FormSection/examples/Labels.tsx +27 -0
  75. package/src/forms/InviteMembersDialog/InviteMembersDialog.labels.test.tsx +87 -0
  76. package/src/forms/InviteMembersDialog/InviteMembersDialog.tsx +51 -16
  77. package/src/forms/InviteMembersDialog/block.meta.ts +20 -1
  78. package/src/forms/InviteMembersDialog/examples/Labels.tsx +28 -0
  79. package/src/forms/SettingsRow/SettingsRow.labels.test.tsx +33 -0
  80. package/src/forms/SettingsRow/SettingsRow.tsx +14 -3
  81. package/src/forms/SettingsRow/block.meta.ts +7 -1
  82. package/src/forms/SettingsRow/examples/Labels.tsx +27 -0
  83. package/src/forms/ValidationSummary/ValidationSummary.labels.test.tsx +47 -0
  84. package/src/forms/ValidationSummary/ValidationSummary.tsx +9 -3
  85. package/src/forms/ValidationSummary/block.meta.ts +6 -1
  86. package/src/forms/ValidationSummary/examples/Labels.tsx +24 -0
  87. package/src/forms/index.ts +5 -1
  88. package/src/forms/translated-content.tsx +12 -0
  89. package/src/page-chrome/PageHeader/PageHeader.options.test.tsx +34 -0
  90. package/src/page-chrome/PageHeader/PageHeader.tsx +7 -1
  91. package/src/page-chrome/PageHeader/block.meta.ts +1 -1
  92. package/src/page-chrome/PageHeader/examples/Spanish.tsx +11 -0
  93. package/src/tables/DataTable/DataTable.cross-page-selection.test.tsx +322 -0
  94. package/src/tables/DataTable/DataTable.labels.test.tsx +74 -0
  95. package/src/tables/DataTable/DataTable.server-pagination.test.tsx +1 -1
  96. package/src/tables/DataTable/DataTable.single-select.test.tsx +47 -7
  97. package/src/tables/DataTable/DataTable.test.tsx +55 -0
  98. package/src/tables/DataTable/DataTable.tsx +134 -67
  99. package/src/tables/DataTable/block.meta.ts +21 -3
  100. package/src/tables/DataTable/data-table-props.ts +14 -5
  101. package/src/tables/DataTable/data-table-row.tsx +7 -3
  102. package/src/tables/DataTable/data-table-utils.ts +2 -0
  103. package/src/tables/DataTable/examples/client-selection.tsx +33 -0
  104. package/src/tables/DataTable/examples/paginated-single-selection.tsx +46 -0
  105. package/src/tables/DataTable/examples/server-pagination.tsx +55 -15
  106. package/src/tables/DataTable/labels.ts +4 -0
  107. package/src/tables/DataTable/selection-strip.tsx +31 -0
  108. package/src/tables/DataTable/single-selection.tsx +0 -7
  109. package/src/tables/DataTable/use-multiple-selection.ts +86 -0
  110. package/src/test/OptInDefaults.test.tsx +27 -0
  111. 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,34 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import userEvent from '@testing-library/user-event';
3
+ import { createRef } from 'react';
4
+ import { expectNoAxeViolations } from '../../test/a11y';
5
+ import { PageHeader } from './PageHeader';
6
+
7
+ it('wraps long titles while preserving titleRef focus and the default class string', async () => {
8
+ const title = 'x'.repeat(120);
9
+ const titleRef = createRef<HTMLHeadingElement>();
10
+ const props = { title, titleRef, breadcrumbs: null, tabs: null, meta: [], actions: [] };
11
+ const { container, rerender } = render(
12
+ <>
13
+ <PageHeader {...props} wrapTitle />
14
+ <button>Continue</button>
15
+ </>,
16
+ );
17
+ const heading = screen.getByRole('heading', { level: 1 });
18
+ expect(heading).not.toHaveClass('truncate');
19
+ expect(heading).toHaveClass('min-w-0', 'wrap-anywhere');
20
+ expect(heading.textContent).toBe(title);
21
+ expect(titleRef.current).toBe(heading);
22
+ expect(heading).toHaveAttribute('tabindex', '-1');
23
+ await userEvent.setup().tab();
24
+ expect(screen.getByRole('button', { name: 'Continue' })).toHaveFocus();
25
+ titleRef.current?.focus();
26
+ expect(heading).toHaveFocus();
27
+ await expectNoAxeViolations(container);
28
+ rerender(<PageHeader {...props} />);
29
+ expect(screen.getByRole('heading', { level: 1 }).className).toBe(
30
+ 'min-w-0 truncate text-2xl font-bold tracking-tight text-foreground',
31
+ );
32
+ rerender(<PageHeader {...props} titleRef={undefined} wrapTitle />);
33
+ expect(screen.getByRole('heading', { level: 1 })).not.toHaveAttribute('tabindex');
34
+ });
@@ -46,6 +46,8 @@ export interface PageHeaderProps {
46
46
  /** Location trail above the title; `null` hides it. */
47
47
  breadcrumbs?: BreadcrumbItem[] | null;
48
48
  title?: ReactNode;
49
+ /** Wrap the title, including long unbroken words, instead of truncating (default false). */
50
+ wrapTitle?: boolean;
49
51
  /** h1 focus target: adds tabIndex=-1 for titleRef.current.focus(), outside the Tab order. */
50
52
  titleRef?: Ref<HTMLHeadingElement>;
51
53
  description?: ReactNode;
@@ -72,6 +74,7 @@ export function PageHeader({
72
74
  as: Root = 'header',
73
75
  breadcrumbs = pageHeaderBreadcrumbs,
74
76
  title: titleProp,
77
+ wrapTitle = false,
75
78
  labels,
76
79
  titleRef,
77
80
  description: descriptionProp,
@@ -115,7 +118,10 @@ export function PageHeader({
115
118
  <h1
116
119
  ref={titleRef}
117
120
  tabIndex={titleRef != null ? -1 : undefined}
118
- className="min-w-0 truncate text-2xl font-bold tracking-tight text-foreground"
121
+ className={cn(
122
+ wrapTitle ? 'min-w-0 wrap-anywhere' : 'min-w-0 truncate',
123
+ 'text-2xl font-bold tracking-tight text-foreground',
124
+ )}
119
125
  >
120
126
  {title}
121
127
  </h1>
@@ -6,7 +6,7 @@ export const meta: BlockMeta = {
6
6
  family: 'page-chrome',
7
7
  status: 'beta',
8
8
  description:
9
- 'Screen header with breadcrumb, title and status, description, meta row, actions that fold into a MoreMenu on small screens, and optional navigation tabs. titleRef targets the h1 for titleRef.current.focus(), adding tabIndex=-1 only when supplied so the title stays outside the Tab order. In a StatusLayout heading slot use as="div" and disable breadcrumb, meta, tabs, actions, status and description fixtures; the slot supplies the page’s only h1. The tablist name follows I18nProvider (en/es); the Spanish preview keeps caller content unchanged. Optional labels?: Partial<PageHeaderLabels> overrides each built-in label. Explicit content props win over labels, then I18nProvider (en/es); no provider keeps English. Imported fixtures and machine data stay unchanged. See the Catalog labels live preview.',
9
+ 'Screen header with breadcrumb, title and status, description, meta row, actions that fold into a MoreMenu on small screens, and optional navigation tabs. titleRef targets the h1 for titleRef.current.focus(), adding tabIndex=-1 only when supplied so the title stays outside the Tab order. In a StatusLayout heading slot use as="div" and disable breadcrumb, meta, tabs, actions, status and description fixtures; the slot supplies the page’s only h1. The tablist name follows I18nProvider (en/es); the Spanish preview keeps caller content unchanged. Optional labels?: Partial<PageHeaderLabels> overrides each built-in label. Explicit content props win over labels, then I18nProvider (en/es); no provider keeps English. Imported fixtures and machine data stay unchanged. See the Catalog labels live preview. wrapTitle?: boolean (default false) wraps the full title, including long words, while preserving titleRef focus behavior. The default title remains truncated. See the Spanish live preview for a wrapping title.',
10
10
  labels: [
11
11
  { key: 'title', type: 'string', state: 'Heading; explicit title prop wins, including null' },
12
12
  { key: 'description', type: 'string', state: 'Description; explicit description prop wins, including null' },