@gntik-ai/blocks 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/index.d.ts +129 -19
  2. package/dist/index.js +846 -354
  3. package/dist/index.js.map +1 -1
  4. package/package.json +3 -3
  5. package/src/billing/CostBreakdown/CostBreakdown.test.tsx +10 -0
  6. package/src/billing/CostBreakdown/CostBreakdown.tsx +50 -43
  7. package/src/billing/SpendVsBudget/SpendVsBudget.test.tsx +10 -0
  8. package/src/billing/SpendVsBudget/SpendVsBudget.tsx +35 -31
  9. package/src/builders/FlowBuilder/FlowBuilder.test.tsx +237 -2
  10. package/src/builders/FlowBuilder/FlowBuilder.tsx +101 -29
  11. package/src/builders/FlowBuilder/block.meta.ts +1 -1
  12. package/src/builders/FlowBuilder/connections.ts +30 -12
  13. package/src/builders/FlowBuilder/examples/ControlledGraph.tsx +8 -0
  14. package/src/builders/FlowBuilder/graph-state.ts +78 -0
  15. package/src/builders/LogViewer/LogViewer.labels.test.tsx +90 -0
  16. package/src/builders/LogViewer/LogViewer.tsx +43 -10
  17. package/src/builders/LogViewer/block.meta.ts +14 -1
  18. package/src/builders/LogViewer/examples/Spanish.tsx +30 -0
  19. package/src/data-display/ChartCard/ChartCard.locale.test.tsx +15 -0
  20. package/src/data-display/ChartCard/ChartCard.test.tsx +9 -0
  21. package/src/data-display/ChartCard/ChartCard.tsx +81 -67
  22. package/src/data-display/ChartCard/block.meta.ts +1 -1
  23. package/src/data-display/DescriptionListCard/DescriptionListCard.labels.test.tsx +73 -0
  24. package/src/data-display/DescriptionListCard/DescriptionListCard.tsx +37 -7
  25. package/src/data-display/DescriptionListCard/block.meta.ts +11 -1
  26. package/src/data-display/DescriptionListCard/examples/Spanish.tsx +22 -0
  27. package/src/feedback/EmptyStates/EmptyStates.labels.test.tsx +185 -0
  28. package/src/feedback/EmptyStates/EmptyStates.tsx +73 -20
  29. package/src/feedback/EmptyStates/block.meta.ts +73 -1
  30. package/src/feedback/EmptyStates/examples/Spanish.tsx +41 -0
  31. package/src/feedback/ErrorPanel/ErrorPanel.labels.test.tsx +99 -0
  32. package/src/feedback/ErrorPanel/ErrorPanel.tsx +38 -9
  33. package/src/feedback/ErrorPanel/block.meta.ts +19 -1
  34. package/src/feedback/ErrorPanel/examples/Spanish.tsx +30 -0
  35. package/src/feedback/InlineCallout/InlineCallout.labels.test.tsx +62 -0
  36. package/src/feedback/InlineCallout/InlineCallout.tsx +22 -9
  37. package/src/feedback/InlineCallout/block.meta.ts +9 -1
  38. package/src/feedback/InlineCallout/examples/Spanish.tsx +19 -0
  39. package/src/feedback/Skeletons/Skeletons.labels.test.tsx +24 -0
  40. package/src/forms/FileUploadPanel/FileUploadPanel.test.tsx +22 -1
  41. package/src/forms/FileUploadPanel/FileUploadPanel.tsx +4 -4
  42. package/src/forms/FileUploadPanel/fixtures.ts +0 -12
  43. package/src/forms/FileUploadPanel/format-bytes.test.ts +8 -0
  44. package/src/page-chrome/PageHeader/PageHeader.labels.test.tsx +56 -0
  45. package/src/page-chrome/PageHeader/PageHeader.tsx +19 -4
  46. package/src/page-chrome/PageHeader/block.meta.ts +8 -1
  47. package/src/page-chrome/PageHeader/examples/Labels.tsx +16 -0
  48. package/src/scheduling/AgendaList/AgendaList.test.tsx +25 -0
  49. package/src/scheduling/AgendaList/AgendaList.tsx +7 -2
  50. package/src/scheduling/AgendaList/AgendaListLocale.test.tsx +11 -0
  51. package/src/scheduling/AgendaList/block.meta.ts +1 -1
  52. package/src/scheduling/AgendaList/examples/Locale.tsx +29 -0
  53. package/src/scheduling/MonthCalendar/MonthCalendar.test.tsx +111 -1
  54. package/src/scheduling/MonthCalendar/MonthCalendar.tsx +19 -9
  55. package/src/scheduling/MonthCalendar/block.meta.ts +1 -1
  56. package/src/scheduling/MonthCalendar/examples/Locale.tsx +19 -0
  57. package/src/scheduling/WeekCalendar/WeekCalendar.test.tsx +73 -2
  58. package/src/scheduling/WeekCalendar/WeekCalendar.tsx +26 -12
  59. package/src/scheduling/WeekCalendar/block.meta.ts +1 -1
  60. package/src/scheduling/WeekCalendar/examples/Locale.tsx +19 -0
  61. package/src/scheduling/shared/dates.test.ts +75 -0
  62. package/src/scheduling/shared/dates.ts +46 -22
  63. package/src/scheduling/shared/useSchedulingClock.ts +13 -0
  64. package/src/shell/GlobalSearch/GlobalSearch.test.tsx +12 -0
  65. package/src/shell/GlobalSearch/fixtures.ts +2 -2
  66. package/src/tables/PaginationFooter/PaginationFooter.i18n.test.tsx +26 -0
@@ -1,6 +1,6 @@
1
1
  import { Check, FolderPlus, Lock, SearchX } from '@gntik-ai/icons';
2
2
  import type { LucideIcon } from '@gntik-ai/icons';
3
- import { Button, EmptyState, Link, cn } from '@gntik-ai/ui';
3
+ import { Button, EmptyState, Link, cn, useI18n } from '@gntik-ai/ui';
4
4
  import { useState, type ReactNode } from 'react';
5
5
  import { firstRunSteps, noAccessSample, noResultsSample, notFoundSample } from './fixtures';
6
6
 
@@ -42,7 +42,16 @@ export function NotFoundEmpty({
42
42
  );
43
43
  }
44
44
 
45
+ export interface FirstRunEmptyLabels {
46
+ title: string;
47
+ description: string;
48
+ action: string;
49
+ guide: string;
50
+ }
51
+
45
52
  export interface FirstRunEmptyProps extends SharedEmptyProps {
53
+ /** Per-key copy overrides; explicit props take precedence over labels and catalog defaults. */
54
+ labels?: Partial<FirstRunEmptyLabels>;
46
55
  icon?: LucideIcon;
47
56
  title?: ReactNode;
48
57
  description?: ReactNode;
@@ -57,16 +66,26 @@ export interface FirstRunEmptyProps extends SharedEmptyProps {
57
66
  /** First-run state: nothing created yet; explains the value and offers the first action. */
58
67
  export function FirstRunEmpty({
59
68
  icon = FolderPlus,
60
- title = 'Create your first project',
61
- description = 'Projects group your services, environments and deployments. Start one from a repository in a couple of minutes.',
62
- actionLabel = 'New project',
69
+ title: titleProp,
70
+ labels,
71
+ description: descriptionProp,
72
+ actionLabel: actionLabelProp,
63
73
  onAction,
64
- secondary = { label: 'Read the guide', href: '#guide' },
74
+ secondary: secondaryProp,
65
75
  steps = firstRunSteps,
66
76
  titleAs,
67
77
  bordered = true,
68
78
  className,
69
79
  }: FirstRunEmptyProps) {
80
+ const { t } = useI18n();
81
+ const title = titleProp === undefined ? (labels?.title ?? t('emptyState.firstRun.title')) : titleProp;
82
+ const description =
83
+ descriptionProp === undefined ? (labels?.description ?? t('emptyState.firstRun.description')) : descriptionProp;
84
+ const actionLabel = actionLabelProp ?? labels?.action ?? t('emptyState.firstRun.action');
85
+ const secondary =
86
+ secondaryProp === undefined
87
+ ? { label: labels?.guide ?? t('emptyState.firstRun.guide'), href: '#guide' }
88
+ : secondaryProp;
70
89
  return (
71
90
  <EmptyState
72
91
  icon={icon}
@@ -104,7 +123,18 @@ export function FirstRunEmpty({
104
123
  );
105
124
  }
106
125
 
126
+ export interface NoResultsEmptyLabels {
127
+ /** Replaces the complete query heading; catalog defaults retain the query’s monospace span. */
128
+ queryTitle: (entity: string, query: string) => string;
129
+ title: (entity: string) => string;
130
+ description: (filterCount: number) => string;
131
+ clearFilters: string;
132
+ clearSearch: string;
133
+ }
134
+
107
135
  export interface NoResultsEmptyProps extends SharedEmptyProps {
136
+ /** Per-key overrides; formatter arguments are caller data and results render verbatim. */
137
+ labels?: Partial<NoResultsEmptyLabels>;
108
138
  /** The search text that matched nothing. */
109
139
  query?: string;
110
140
  /** Number of active filters (shows "Clear filters" when > 0). */
@@ -118,6 +148,7 @@ export interface NoResultsEmptyProps extends SharedEmptyProps {
118
148
  /** No-results state for a filtered list or table: echoes the query and offers ways out. */
119
149
  export function NoResultsEmpty({
120
150
  query = noResultsSample.query,
151
+ labels,
121
152
  filterCount = noResultsSample.filterCount,
122
153
  entity = noResultsSample.entity,
123
154
  onClearFilters,
@@ -126,7 +157,7 @@ export function NoResultsEmpty({
126
157
  bordered = false,
127
158
  className,
128
159
  }: NoResultsEmptyProps) {
129
- const filters = filterCount > 0 ? ` with ${filterCount} ${filterCount === 1 ? 'filter' : 'filters'} applied` : '';
160
+ const { t } = useI18n();
130
161
  return (
131
162
  <EmptyState
132
163
  icon={SearchX}
@@ -135,26 +166,31 @@ export function NoResultsEmpty({
135
166
  bordered={bordered}
136
167
  className={cn('mx-auto', className)}
137
168
  title={
138
- query ? (
139
- <>
140
- No {entity} match “<span className="font-mono">{query}</span>”
141
- </>
142
- ) : (
143
- `No ${entity} found`
144
- )
169
+ query
170
+ ? (labels?.queryTitle?.(entity, query) ?? (
171
+ <>
172
+ {t('emptyState.noResults.queryTitleBefore', { entity })}
173
+ <span className="font-mono">{query}</span>
174
+ {t('emptyState.noResults.queryTitleAfter')}
175
+ </>
176
+ ))
177
+ : (labels?.title?.(entity) ?? t('emptyState.noResults.title', { entity }))
178
+ }
179
+ description={
180
+ labels?.description?.(filterCount) ??
181
+ t('emptyState.noResults.description', { count: filterCount > 0 ? filterCount : 0 })
145
182
  }
146
- description={`Check the spelling or try a broader search${filters}.`}
147
183
  primaryAction={
148
184
  filterCount > 0 ? (
149
185
  <Button variant="secondary" size="sm" onClick={onClearFilters}>
150
- Clear filters
186
+ {labels?.clearFilters ?? t('emptyState.noResults.clearFilters')}
151
187
  </Button>
152
188
  ) : undefined
153
189
  }
154
190
  secondaryAction={
155
191
  query ? (
156
192
  <Button variant="ghost" size="sm" onClick={onClearSearch}>
157
- Clear search
193
+ {labels?.clearSearch ?? t('emptyState.noResults.clearSearch')}
158
194
  </Button>
159
195
  ) : undefined
160
196
  }
@@ -162,7 +198,17 @@ export function NoResultsEmpty({
162
198
  );
163
199
  }
164
200
 
201
+ export interface NoAccessEmptyLabels {
202
+ title: (resource: string) => string;
203
+ description: (resource: string, owner: string) => string;
204
+ request: string;
205
+ requested: string;
206
+ sent: string;
207
+ }
208
+
165
209
  export interface NoAccessEmptyProps extends SharedEmptyProps {
210
+ /** Per-key overrides; formatters receive the original resource and owner, without translation. */
211
+ labels?: Partial<NoAccessEmptyLabels>;
166
212
  /** What the viewer cannot see. */
167
213
  resource?: string;
168
214
  /** Who can grant access. */
@@ -176,6 +222,7 @@ export interface NoAccessEmptyProps extends SharedEmptyProps {
176
222
  /** Permission state: the viewer lacks access; explains who can grant it and lets them ask. */
177
223
  export function NoAccessEmpty({
178
224
  resource = noAccessSample.resource,
225
+ labels,
179
226
  owner = noAccessSample.owner,
180
227
  onRequestAccess,
181
228
  defaultRequested = false,
@@ -183,6 +230,7 @@ export function NoAccessEmpty({
183
230
  bordered = true,
184
231
  className,
185
232
  }: NoAccessEmptyProps) {
233
+ const { t } = useI18n();
186
234
  const [state, setState] = useState<'idle' | 'pending' | 'requested'>(defaultRequested ? 'requested' : 'idle');
187
235
  const request = async () => {
188
236
  setState('pending');
@@ -199,8 +247,11 @@ export function NoAccessEmpty({
199
247
  titleAs={titleAs}
200
248
  bordered={bordered}
201
249
  className={cn('mx-auto', className)}
202
- title={`You don’t have access to ${resource}`}
203
- description={`Ask ${owner} to grant you a role that includes ${resource.toLowerCase()} permissions.`}
250
+ title={labels?.title?.(resource) ?? t('emptyState.noAccess.title', { resource })}
251
+ description={
252
+ labels?.description?.(resource, owner) ??
253
+ t('emptyState.noAccess.description', { resource: resource.toLowerCase(), owner })
254
+ }
204
255
  primaryAction={
205
256
  <Button
206
257
  variant={state === 'requested' ? 'secondary' : 'primary'}
@@ -209,12 +260,14 @@ export function NoAccessEmpty({
209
260
  disabled={state === 'requested'}
210
261
  onClick={() => void request()}
211
262
  >
212
- {state === 'requested' ? 'Access requested' : 'Request access'}
263
+ {state === 'requested'
264
+ ? (labels?.requested ?? t('emptyState.noAccess.requested'))
265
+ : (labels?.request ?? t('emptyState.noAccess.request'))}
213
266
  </Button>
214
267
  }
215
268
  >
216
269
  <p role="status" className="sr-only">
217
- {state === 'requested' ? 'Access request sent' : ''}
270
+ {state === 'requested' ? (labels?.sent ?? t('emptyState.noAccess.sent')) : ''}
218
271
  </p>
219
272
  </EmptyState>
220
273
  );
@@ -5,6 +5,78 @@ export const meta: BlockMeta = {
5
5
  family: 'feedback',
6
6
  status: 'beta',
7
7
  description:
8
- 'Four canonical empty states: first run (with checklist), no results (clear filters/search), no access (request access) and not found (optional action).',
8
+ 'Four canonical empty states: first run (with checklist), no results (clear filters/search), no access (request access) and not found (optional action). FirstRunEmpty, NoResultsEmpty and NoAccessEmpty accept labels?: Partial<FirstRunEmptyLabels>, Partial<NoResultsEmptyLabels> and Partial<NoAccessEmptyLabels> respectively. Each type has its own keys below; explicit title, description, actionLabel and secondary props win. Defaults follow I18nProvider (en/es). NoResultsEmpty keeps the query in a mono span unless queryTitle replaces the heading. NotFoundEmpty and all imported fixtures stay English. See the Catalog labels live preview.',
9
+ labels: [
10
+ {
11
+ key: 'FirstRunEmpty.labels.title',
12
+ type: 'string',
13
+ state: 'FirstRunEmpty: per-key override; formatters receive original data. Explicit props win.',
14
+ },
15
+ {
16
+ key: 'FirstRunEmpty.labels.description',
17
+ type: 'string',
18
+ state: 'FirstRunEmpty: per-key override; formatters receive original data. Explicit props win.',
19
+ },
20
+ {
21
+ key: 'FirstRunEmpty.labels.action',
22
+ type: 'string',
23
+ state: 'FirstRunEmpty: per-key override; formatters receive original data. Explicit props win.',
24
+ },
25
+ {
26
+ key: 'FirstRunEmpty.labels.guide',
27
+ type: 'string',
28
+ state: 'FirstRunEmpty: per-key override; formatters receive original data. Explicit props win.',
29
+ },
30
+ {
31
+ key: 'NoResultsEmpty.labels.queryTitle',
32
+ type: '(entity: string, query: string) => string',
33
+ state: 'NoResultsEmpty: per-key override; formatters receive original data. Explicit props win.',
34
+ },
35
+ {
36
+ key: 'NoResultsEmpty.labels.title',
37
+ type: '(entity: string) => string',
38
+ state: 'NoResultsEmpty: per-key override; formatters receive original data. Explicit props win.',
39
+ },
40
+ {
41
+ key: 'NoResultsEmpty.labels.description',
42
+ type: '(filterCount: number) => string',
43
+ state: 'NoResultsEmpty: per-key override; formatters receive original data. Explicit props win.',
44
+ },
45
+ {
46
+ key: 'NoResultsEmpty.labels.clearFilters',
47
+ type: 'string',
48
+ state: 'NoResultsEmpty: per-key override; formatters receive original data. Explicit props win.',
49
+ },
50
+ {
51
+ key: 'NoResultsEmpty.labels.clearSearch',
52
+ type: 'string',
53
+ state: 'NoResultsEmpty: per-key override; formatters receive original data. Explicit props win.',
54
+ },
55
+ {
56
+ key: 'NoAccessEmpty.labels.title',
57
+ type: '(resource: string) => string',
58
+ state: 'NoAccessEmpty: per-key override; formatters receive original data. Explicit props win.',
59
+ },
60
+ {
61
+ key: 'NoAccessEmpty.labels.description',
62
+ type: '(resource: string, owner: string) => string',
63
+ state: 'NoAccessEmpty: per-key override; formatters receive original data. Explicit props win.',
64
+ },
65
+ {
66
+ key: 'NoAccessEmpty.labels.request',
67
+ type: 'string',
68
+ state: 'NoAccessEmpty: per-key override; formatters receive original data. Explicit props win.',
69
+ },
70
+ {
71
+ key: 'NoAccessEmpty.labels.requested',
72
+ type: 'string',
73
+ state: 'NoAccessEmpty: per-key override; formatters receive original data. Explicit props win.',
74
+ },
75
+ {
76
+ key: 'NoAccessEmpty.labels.sent',
77
+ type: 'string',
78
+ state: 'NoAccessEmpty: per-key override; formatters receive original data. Explicit props win.',
79
+ },
80
+ ],
9
81
  uses: ['EmptyState', 'Button', 'Link'],
10
82
  };
@@ -0,0 +1,41 @@
1
+ import { I18nProvider, Stack } from '@gntik-ai/ui';
2
+ import { FirstRunEmpty, NoResultsEmpty, NoAccessEmpty } from '../EmptyStates';
3
+ export default function Spanish() {
4
+ return (
5
+ <I18nProvider locale="es">
6
+ <Stack gap={6}>
7
+ <FirstRunEmpty />
8
+ <FirstRunEmpty
9
+ labels={{
10
+ title: 'Start a project',
11
+ description: 'Connect your repository.',
12
+ action: 'Create project',
13
+ guide: 'Open guide',
14
+ }}
15
+ />
16
+ <NoResultsEmpty filterCount={1} />
17
+ <NoResultsEmpty filterCount={2} />
18
+ <NoResultsEmpty
19
+ labels={{
20
+ queryTitle: (entity, query) => `No ${entity} for ${query}`,
21
+ title: (entity) => `No ${entity} yet`,
22
+ description: (count) => `Try removing ${count} filters.`,
23
+ clearFilters: 'Reset filters',
24
+ clearSearch: 'Reset search',
25
+ }}
26
+ />
27
+ <NoResultsEmpty query="" labels={{ title: (entity) => `No ${entity} yet` }} />
28
+ <NoAccessEmpty />
29
+ <NoAccessEmpty
30
+ labels={{
31
+ title: (resource) => `Access needed: ${resource}`,
32
+ description: (resource, owner) => `Contact ${owner} about ${resource}.`,
33
+ request: 'Ask for access',
34
+ requested: 'Request pending',
35
+ sent: 'Your request was sent',
36
+ }}
37
+ />
38
+ </Stack>
39
+ </I18nProvider>
40
+ );
41
+ }
@@ -0,0 +1,99 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import userEvent from '@testing-library/user-event';
3
+ import { I18nProvider, es } from '@gntik-ai/ui';
4
+ import { ErrorPanel, type ErrorPanelLabels } from './ErrorPanel';
5
+
6
+ it('translates error chrome and announcements without translating request data or technical details', async () => {
7
+ const user = userEvent.setup();
8
+ const view = (retrying = false) => (
9
+ <I18nProvider locale="es">
10
+ <ErrorPanel retrying={retrying} onRetry={() => {}} />
11
+ </I18nProvider>
12
+ );
13
+ const { rerender } = render(view());
14
+ expect(screen.getByRole('heading', { name: es['error.title'] })).toHaveTextContent(
15
+ 'No se pudieron cargar los despliegues',
16
+ );
17
+ expect(screen.getByText(es['error.message'])).toBeVisible();
18
+ expect(screen.getByText(es['error.requestId'])).toBeVisible();
19
+ expect(screen.getByText('req_8f2c41d07a9b')).toBeVisible();
20
+ expect(screen.getByText('503')).toBeVisible();
21
+ expect(screen.getByRole('button', { name: es['error.retry'] })).toBeVisible();
22
+ expect(screen.getByRole('button', { name: es['error.support'] })).toBeVisible();
23
+ await user.click(screen.getByRole('button', { name: es['error.copyRequestId'] }));
24
+ expect(screen.getByRole('button', { name: es['common.copied'] })).toBeVisible();
25
+ expect(screen.getByRole('status')).toHaveTextContent(es['error.requestIdCopied']);
26
+ expect(await navigator.clipboard.readText()).toBe('req_8f2c41d07a9b');
27
+ await user.click(screen.getByRole('button', { name: es['error.details'] }));
28
+ expect(screen.getByText(/503 Service Unavailable/).textContent).toBe(
29
+ 'GET /v1/projects/acme-web/deployments\n503 Service Unavailable\nupstream timed out after 30000 ms (pool: api-eu-west-1)',
30
+ );
31
+ rerender(view(true));
32
+ expect(screen.getByRole('button', { name: es['error.retrying'] })).toBeVisible();
33
+ expect(screen.getByRole('status')).toHaveTextContent(es['error.retryingStatus']);
34
+ });
35
+
36
+ it('keeps English defaults, renders all overrides and gives explicit props precedence', async () => {
37
+ const user = userEvent.setup();
38
+ const { rerender } = render(<ErrorPanel onRetry={() => {}} />);
39
+ expect(screen.getByRole('heading', { name: 'We couldn’t load deployments' })).toBeVisible();
40
+ expect(
41
+ screen.getByText('The service didn’t respond in time. Your data is safe; try again in a moment.'),
42
+ ).toBeVisible();
43
+ for (const name of ['Contact support', 'Copy request ID', 'Try again', 'Technical details'])
44
+ expect(screen.getByRole('button', { name })).toBeVisible();
45
+ expect(screen.getByText('Request ID')).toBeVisible();
46
+ await user.click(screen.getByRole('button', { name: 'Copy request ID' }));
47
+ expect(screen.getByRole('button', { name: 'Copied' })).toBeVisible();
48
+ expect(screen.getByRole('status')).toHaveTextContent('Request ID copied');
49
+ rerender(<ErrorPanel onRetry={() => {}} retrying />);
50
+ expect(screen.getByRole('button', { name: 'Retrying…' })).toBeVisible();
51
+ expect(screen.getByRole('status')).toHaveTextContent('Retrying');
52
+ const labels: ErrorPanelLabels = {
53
+ title: 'Title override',
54
+ message: 'Message override',
55
+ support: 'Support override',
56
+ retry: 'Retry override',
57
+ retrying: 'Busy override',
58
+ retryingStatus: 'Busy status override',
59
+ requestId: 'ID override',
60
+ copyRequestId: 'Copy override',
61
+ copied: 'Copied override',
62
+ requestIdCopied: 'Copied status override',
63
+ details: 'Details override',
64
+ };
65
+ const view = (overrides: Partial<ErrorPanelLabels>, retrying = false, explicit = false) => (
66
+ <I18nProvider locale="es">
67
+ <ErrorPanel
68
+ labels={overrides}
69
+ retrying={retrying}
70
+ onRetry={() => {}}
71
+ title={explicit ? 'Explicit title' : undefined}
72
+ message={explicit ? 'Explicit message' : undefined}
73
+ retryLabel={explicit ? 'Explicit retry' : undefined}
74
+ secondaryAction={explicit ? { label: 'Explicit support' } : undefined}
75
+ />
76
+ </I18nProvider>
77
+ );
78
+ rerender(view(labels));
79
+ expect(screen.getByRole('heading', { name: labels.title })).toBeVisible();
80
+ expect(screen.getByText(labels.message)).toBeVisible();
81
+ expect(screen.getByText(labels.requestId)).toBeVisible();
82
+ for (const name of [labels.support, labels.retry, labels.details])
83
+ expect(screen.getByRole('button', { name })).toBeVisible();
84
+ await user.click(screen.getByRole('button', { name: labels.copyRequestId }));
85
+ expect(screen.getByRole('button', { name: labels.copied })).toBeVisible();
86
+ expect(screen.getByRole('status')).toHaveTextContent(labels.requestIdCopied);
87
+ rerender(view(labels, true));
88
+ expect(screen.getByRole('button', { name: labels.retrying })).toBeVisible();
89
+ expect(screen.getByRole('status')).toHaveTextContent(labels.retryingStatus);
90
+ rerender(view(labels, false, true));
91
+ expect(screen.getByRole('heading', { name: 'Explicit title' })).toBeVisible();
92
+ expect(screen.getByText('Explicit message')).toBeVisible();
93
+ expect(screen.getByRole('button', { name: 'Explicit retry' })).toBeVisible();
94
+ expect(screen.getByRole('button', { name: 'Explicit support' })).toBeVisible();
95
+ rerender(view({ title: 'Only title' }));
96
+ expect(screen.getByText(es['error.message'])).toBeVisible();
97
+ for (const key of ['error.retry', 'error.support', 'error.details'] as const)
98
+ expect(screen.getByRole('button', { name: es[key] })).toBeVisible();
99
+ });
@@ -4,7 +4,23 @@ import { Button, Collapsible, CollapsiblePanel, CollapsibleTrigger, IconButton,
4
4
  import { useId, useRef, useState, type ReactNode } from 'react';
5
5
  import type { FeedbackAction } from '../types';
6
6
 
7
+ export interface ErrorPanelLabels {
8
+ title: string;
9
+ message: string;
10
+ support: string;
11
+ retry: string;
12
+ retrying: string;
13
+ retryingStatus: string;
14
+ requestId: string;
15
+ copyRequestId: string;
16
+ copied: string;
17
+ requestIdCopied: string;
18
+ details: string;
19
+ }
20
+
7
21
  export interface ErrorPanelProps {
22
+ /** Per-key copy overrides; explicit props take precedence, then labels, then the active catalog. */
23
+ labels?: Partial<ErrorPanelLabels>;
8
24
  icon?: LucideIcon;
9
25
  title?: ReactNode;
10
26
  /** Human summary of what failed and what to do. */
@@ -31,21 +47,28 @@ export interface ErrorPanelProps {
31
47
  /** Error summary for a failed load or action: what happened, request id, retry and technical details. */
32
48
  export function ErrorPanel({
33
49
  icon: Icon = ServerCrash,
34
- title = 'We couldn’t load deployments',
35
- message = 'The service didn’t respond in time. Your data is safe; try again in a moment.',
50
+ title: titleProp,
51
+ labels,
52
+ message: messageProp,
36
53
  code = 503,
37
54
  requestId = 'req_8f2c41d07a9b',
38
55
  details = 'GET /v1/projects/acme-web/deployments\n503 Service Unavailable\nupstream timed out after 30000 ms (pool: api-eu-west-1)',
39
56
  onRetry,
40
57
  retrying,
41
58
  retryLabel: retryLabelProp,
42
- secondaryAction = { label: 'Contact support', variant: 'ghost' },
59
+ secondaryAction: secondaryActionProp,
43
60
  titleAs: Heading = 'h3',
44
61
  className,
45
62
  announce = true,
46
63
  }: ErrorPanelProps) {
47
64
  const { t } = useI18n();
48
- const retryLabel = retryLabelProp ?? t('error.retry');
65
+ const title = titleProp === undefined ? (labels?.title ?? t('error.title')) : titleProp;
66
+ const message = messageProp === undefined ? (labels?.message ?? t('error.message')) : messageProp;
67
+ const secondaryAction =
68
+ secondaryActionProp === undefined
69
+ ? { label: labels?.support ?? t('error.support'), variant: 'ghost' as const }
70
+ : secondaryActionProp;
71
+ const retryLabel = retryLabelProp ?? labels?.retry ?? t('error.retry');
49
72
  const id = useId();
50
73
  const [innerRetrying, setInnerRetrying] = useState(false);
51
74
  const [copied, setCopied] = useState(false);
@@ -97,13 +120,15 @@ export function ErrorPanel({
97
120
  {message != null && <p className="mt-1.5 max-w-xl text-[13px] leading-6 text-muted-foreground">{message}</p>}
98
121
  {requestId && (
99
122
  <div className="mt-3 flex items-center gap-1.5 text-[12px] text-muted-foreground">
100
- <span>{t('error.requestId')}</span>
123
+ <span>{labels?.requestId ?? t('error.requestId')}</span>
101
124
  <code className="rounded bg-muted px-1.5 py-0.5 font-mono text-[11.5px] text-foreground">
102
125
  {requestId}
103
126
  </code>
104
127
  <IconButton
105
128
  icon={copied ? Check : Copy}
106
- label={copied ? t('common.copied') : t('error.copyRequestId')}
129
+ label={
130
+ copied ? (labels?.copied ?? t('common.copied')) : (labels?.copyRequestId ?? t('error.copyRequestId'))
131
+ }
107
132
  size="sm"
108
133
  variant="ghost"
109
134
  className="size-7"
@@ -114,7 +139,7 @@ export function ErrorPanel({
114
139
  <div className="mt-4 flex flex-wrap items-center gap-2">
115
140
  {onRetry && (
116
141
  <Button variant="secondary" size="sm" icon={RotateCw} loading={busy} onClick={() => void retry()}>
117
- {busy ? t('error.retrying') : retryLabel}
142
+ {busy ? (labels?.retrying ?? t('error.retrying')) : retryLabel}
118
143
  </Button>
119
144
  )}
120
145
  {secondaryAction && (
@@ -131,7 +156,7 @@ export function ErrorPanel({
131
156
  </div>
132
157
  {details && (
133
158
  <Collapsible className="mt-4">
134
- <CollapsibleTrigger className="text-[12.5px]">{t('error.details')}</CollapsibleTrigger>
159
+ <CollapsibleTrigger className="text-[12.5px]">{labels?.details ?? t('error.details')}</CollapsibleTrigger>
135
160
  <CollapsiblePanel>
136
161
  <pre className="mt-2 max-h-60 overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-[11.5px] leading-5 whitespace-pre-wrap text-foreground">
137
162
  {details}
@@ -141,7 +166,11 @@ export function ErrorPanel({
141
166
  )}
142
167
  {announce && (
143
168
  <p role="status" className="sr-only">
144
- {busy ? t('error.retryingStatus') : copied ? t('error.requestIdCopied') : ''}
169
+ {busy
170
+ ? (labels?.retryingStatus ?? t('error.retryingStatus'))
171
+ : copied
172
+ ? (labels?.requestIdCopied ?? t('error.requestIdCopied'))
173
+ : ''}
145
174
  </p>
146
175
  )}
147
176
  </div>
@@ -1,10 +1,28 @@
1
1
  import type { BlockMeta } from '../../meta';
2
+ import type { ErrorPanelLabels } from './ErrorPanel';
2
3
 
3
4
  export const meta: BlockMeta = {
4
5
  name: 'Error panel',
5
6
  family: 'feedback',
6
7
  status: 'beta',
7
8
  description:
8
- 'Error summary with status code, copyable request id, retry with loading state and a technical-details disclosure.',
9
+ 'Error summary with status code, copyable request id, retry with loading state and a technical-details disclosure. Optional labels?: Partial<ErrorPanelLabels> 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.',
10
+ labels: [
11
+ { key: 'title', type: 'string', state: 'Panel heading; explicit title prop wins, including null' },
12
+ { key: 'message', type: 'string', state: 'Summary; explicit message prop wins, including null' },
13
+ {
14
+ key: 'support',
15
+ type: 'string',
16
+ state: 'Default secondary action; explicit secondaryAction wins, including null',
17
+ },
18
+ { key: 'retry', type: 'string', state: 'Retry button; retryLabel prop wins' },
19
+ { key: 'retrying', type: 'string', state: 'Busy retry button' },
20
+ { key: 'retryingStatus', type: 'string', state: 'Busy status announcement' },
21
+ { key: 'requestId', type: 'string', state: 'Request ID caption' },
22
+ { key: 'copyRequestId', type: 'string', state: 'Copy request ID button' },
23
+ { key: 'copied', type: 'string', state: 'Copy button after copying' },
24
+ { key: 'requestIdCopied', type: 'string', state: 'Copied status announcement' },
25
+ { key: 'details', type: 'string', state: 'Technical details disclosure' },
26
+ ] satisfies Array<{ key: keyof ErrorPanelLabels; type: string; state: string }>,
9
27
  uses: ['Button', 'IconButton', 'Collapsible'],
10
28
  };
@@ -0,0 +1,30 @@
1
+ import { I18nProvider, Stack } from '@gntik-ai/ui';
2
+ import { useState } from 'react';
3
+ import { ErrorPanel } from '../ErrorPanel';
4
+ export default function Spanish() {
5
+ const [retrying, setRetrying] = useState(false);
6
+ return (
7
+ <I18nProvider locale="es">
8
+ <Stack gap={6}>
9
+ <ErrorPanel onRetry={() => {}} />
10
+ <ErrorPanel
11
+ retrying={retrying}
12
+ onRetry={() => setRetrying(true)}
13
+ labels={{
14
+ title: 'Resource unavailable',
15
+ message: 'Please try again.',
16
+ support: 'Get help',
17
+ retry: 'Try loading',
18
+ retrying: 'Loading…',
19
+ retryingStatus: 'Loading resource',
20
+ requestId: 'Reference',
21
+ copyRequestId: 'Copy reference',
22
+ copied: 'Reference copied',
23
+ requestIdCopied: 'Reference copied to clipboard',
24
+ details: 'Show diagnostics',
25
+ }}
26
+ />
27
+ </Stack>
28
+ </I18nProvider>
29
+ );
30
+ }
@@ -0,0 +1,62 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { I18nProvider, es } from '@gntik-ai/ui';
3
+ import { InlineCallout, type InlineCalloutLabels } from './InlineCallout';
4
+
5
+ it('localizes built-in callout content and action labels, leaving the href unchanged', () => {
6
+ render(
7
+ <I18nProvider locale="es">
8
+ <InlineCallout />
9
+ </I18nProvider>,
10
+ );
11
+ expect(screen.getByText(es['callout.title'])).toHaveTextContent('Has usado el 92% de tus minutos de compilación');
12
+ expect(screen.getByText(es['callout.description'])).toBeVisible();
13
+ expect(screen.getByRole('button', { name: es['callout.upgrade'] })).toBeVisible();
14
+ expect(screen.getByRole('link', { name: es['callout.viewUsage'] })).toHaveAttribute('href', '#usage');
15
+ });
16
+
17
+ it('preserves English, merges overrides per key and respects explicit content and actions', () => {
18
+ const { rerender } = render(<InlineCallout />);
19
+ expect(screen.getByText('You have used 92% of your build minutes')).toBeVisible();
20
+ expect(
21
+ screen.getByText(
22
+ 'Builds will queue once the monthly limit is reached. Upgrade the plan or reduce concurrent builds.',
23
+ ),
24
+ ).toBeVisible();
25
+ expect(screen.getByRole('button', { name: 'Upgrade plan' })).toBeVisible();
26
+ expect(screen.getByRole('link', { name: 'View usage' })).toBeVisible();
27
+ const labels: InlineCalloutLabels = {
28
+ title: 'Title override',
29
+ description: 'Description override',
30
+ upgrade: 'Upgrade override',
31
+ viewUsage: 'Usage override',
32
+ };
33
+ rerender(
34
+ <I18nProvider locale="es">
35
+ <InlineCallout labels={labels} />
36
+ </I18nProvider>,
37
+ );
38
+ expect(screen.getByText(labels.title)).toBeVisible();
39
+ expect(screen.getByText(labels.description)).toBeVisible();
40
+ expect(screen.getByRole('button', { name: labels.upgrade })).toBeVisible();
41
+ expect(screen.getByRole('link', { name: labels.viewUsage })).toBeVisible();
42
+ rerender(
43
+ <I18nProvider locale="es">
44
+ <InlineCallout labels={{ title: 'Only title' }} />
45
+ </I18nProvider>,
46
+ );
47
+ expect(screen.getByText('Only title')).toBeVisible();
48
+ expect(screen.getByText(es['callout.description'])).toBeVisible();
49
+ expect(screen.getByRole('button', { name: es['callout.upgrade'] })).toBeVisible();
50
+ expect(screen.getByRole('link', { name: es['callout.viewUsage'] })).toBeVisible();
51
+ rerender(
52
+ <InlineCallout
53
+ labels={labels}
54
+ title="Explicit title"
55
+ description="Explicit description"
56
+ actions={[{ label: 'Explicit action', href: '#explicit' }]}
57
+ />,
58
+ );
59
+ expect(screen.getByText('Explicit title')).toBeVisible();
60
+ expect(screen.getByText('Explicit description')).toBeVisible();
61
+ expect(screen.getByRole('link', { name: 'Explicit action' })).toHaveAttribute('href', '#explicit');
62
+ });