@gntik-ai/blocks 0.8.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 (77) hide show
  1. package/dist/index.d.ts +138 -21
  2. package/dist/index.js +897 -376
  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.test.tsx +11 -0
  17. package/src/builders/LogViewer/LogViewer.tsx +70 -31
  18. package/src/builders/LogViewer/block.meta.ts +14 -1
  19. package/src/builders/LogViewer/examples/Spanish.tsx +30 -0
  20. package/src/data-display/ChartCard/ChartCard.locale.test.tsx +15 -0
  21. package/src/data-display/ChartCard/ChartCard.test.tsx +9 -0
  22. package/src/data-display/ChartCard/ChartCard.tsx +81 -67
  23. package/src/data-display/ChartCard/block.meta.ts +1 -1
  24. package/src/data-display/DescriptionListCard/DescriptionListCard.labels.test.tsx +73 -0
  25. package/src/data-display/DescriptionListCard/DescriptionListCard.tsx +37 -7
  26. package/src/data-display/DescriptionListCard/block.meta.ts +11 -1
  27. package/src/data-display/DescriptionListCard/examples/Spanish.tsx +22 -0
  28. package/src/feedback/EmptyStates/EmptyStates.labels.test.tsx +185 -0
  29. package/src/feedback/EmptyStates/EmptyStates.tsx +73 -20
  30. package/src/feedback/EmptyStates/block.meta.ts +73 -1
  31. package/src/feedback/EmptyStates/examples/Spanish.tsx +41 -0
  32. package/src/feedback/ErrorPanel/ErrorPanel.labels.test.tsx +99 -0
  33. package/src/feedback/ErrorPanel/ErrorPanel.tsx +38 -9
  34. package/src/feedback/ErrorPanel/block.meta.ts +19 -1
  35. package/src/feedback/ErrorPanel/examples/Spanish.tsx +30 -0
  36. package/src/feedback/InlineCallout/InlineCallout.labels.test.tsx +62 -0
  37. package/src/feedback/InlineCallout/InlineCallout.tsx +22 -9
  38. package/src/feedback/InlineCallout/block.meta.ts +9 -1
  39. package/src/feedback/InlineCallout/examples/Spanish.tsx +19 -0
  40. package/src/feedback/Skeletons/Skeletons.labels.test.tsx +24 -0
  41. package/src/forms/FileUploadPanel/FileUploadPanel.test.tsx +22 -1
  42. package/src/forms/FileUploadPanel/FileUploadPanel.tsx +4 -4
  43. package/src/forms/FileUploadPanel/fixtures.ts +0 -12
  44. package/src/forms/FileUploadPanel/format-bytes.test.ts +8 -0
  45. package/src/page-chrome/PageHeader/PageHeader.labels.test.tsx +56 -0
  46. package/src/page-chrome/PageHeader/PageHeader.test.tsx +18 -0
  47. package/src/page-chrome/PageHeader/PageHeader.tsx +21 -4
  48. package/src/page-chrome/PageHeader/block.meta.ts +8 -1
  49. package/src/page-chrome/PageHeader/examples/Labels.tsx +16 -0
  50. package/src/page-chrome/PageHeader/examples/Spanish.tsx +11 -0
  51. package/src/scheduling/AgendaList/AgendaList.test.tsx +25 -0
  52. package/src/scheduling/AgendaList/AgendaList.tsx +7 -2
  53. package/src/scheduling/AgendaList/AgendaListLocale.test.tsx +11 -0
  54. package/src/scheduling/AgendaList/block.meta.ts +1 -1
  55. package/src/scheduling/AgendaList/examples/Locale.tsx +29 -0
  56. package/src/scheduling/MonthCalendar/MonthCalendar.test.tsx +111 -1
  57. package/src/scheduling/MonthCalendar/MonthCalendar.tsx +19 -9
  58. package/src/scheduling/MonthCalendar/block.meta.ts +1 -1
  59. package/src/scheduling/MonthCalendar/examples/Locale.tsx +19 -0
  60. package/src/scheduling/WeekCalendar/WeekCalendar.test.tsx +73 -2
  61. package/src/scheduling/WeekCalendar/WeekCalendar.tsx +26 -12
  62. package/src/scheduling/WeekCalendar/block.meta.ts +1 -1
  63. package/src/scheduling/WeekCalendar/examples/Locale.tsx +19 -0
  64. package/src/scheduling/shared/dates.test.ts +75 -0
  65. package/src/scheduling/shared/dates.ts +46 -22
  66. package/src/scheduling/shared/useSchedulingClock.ts +13 -0
  67. package/src/shell/GlobalSearch/GlobalSearch.test.tsx +12 -0
  68. package/src/shell/GlobalSearch/fixtures.ts +2 -2
  69. package/src/tables/DataTable/DataTable.labels.test.tsx +2 -0
  70. package/src/tables/DataTable/DataTable.locale.test.tsx +153 -0
  71. package/src/tables/DataTable/DataTable.server-pagination.test.tsx +1 -1
  72. package/src/tables/DataTable/DataTable.test.tsx +16 -0
  73. package/src/tables/DataTable/block.meta.ts +2 -0
  74. package/src/tables/DataTable/data-table-row.tsx +18 -2
  75. package/src/tables/DataTable/data-table-utils.ts +18 -4
  76. package/src/tables/DataTable/labels.ts +2 -0
  77. package/src/tables/PaginationFooter/PaginationFooter.i18n.test.tsx +26 -0
@@ -1,9 +1,19 @@
1
1
  import type { BlockMeta } from '../../meta';
2
+ import type { DescriptionListCardLabels } from './DescriptionListCard';
2
3
 
3
4
  export const meta: BlockMeta = {
4
5
  name: 'Description list card',
5
6
  family: 'data-display',
6
7
  status: 'beta',
7
- description: 'Key–value detail card with mono, status and rich values, copy-to-clipboard buttons and an Edit action.',
8
+ description:
9
+ 'Key–value detail card with mono, status and rich values, copy-to-clipboard buttons and an Edit action. Optional labels?: Partial<DescriptionListCardLabels> 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: 'Card heading; title prop wins' },
12
+ { key: 'description', type: 'string', state: 'Card description; description prop wins' },
13
+ { key: 'edit', type: 'string', state: 'Edit button; editLabel prop wins' },
14
+ { key: 'copy', type: '(label: string) => string', state: 'Copy button name; original item label' },
15
+ { key: 'copied', type: '(label: string) => string', state: 'Copy button name after copying; original item label' },
16
+ { key: 'copiedToClipboard', type: 'string', state: 'Polite copy announcement' },
17
+ ] satisfies Array<{ key: keyof DescriptionListCardLabels; type: string; state: string }>,
8
18
  uses: ['Card', 'Button', 'IconButton', 'StatusTag'],
9
19
  };
@@ -0,0 +1,22 @@
1
+ import { I18nProvider, Stack } from '@gntik-ai/ui';
2
+ import { DescriptionListCard } from '../DescriptionListCard';
3
+ export default function Spanish() {
4
+ return (
5
+ <I18nProvider locale="es">
6
+ <Stack gap={6}>
7
+ <DescriptionListCard onEdit={() => {}} />
8
+ <DescriptionListCard
9
+ onEdit={() => {}}
10
+ labels={{
11
+ title: 'Resource details',
12
+ description: 'Current settings',
13
+ edit: 'Change',
14
+ copy: (label) => `Copy field ${label}`,
15
+ copied: (label) => `Copied field ${label}`,
16
+ copiedToClipboard: 'Field copied to clipboard',
17
+ }}
18
+ />
19
+ </Stack>
20
+ </I18nProvider>
21
+ );
22
+ }
@@ -0,0 +1,185 @@
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 {
5
+ FirstRunEmpty,
6
+ NoResultsEmpty,
7
+ NoAccessEmpty,
8
+ NotFoundEmpty,
9
+ type FirstRunEmptyLabels,
10
+ type NoResultsEmptyLabels,
11
+ type NoAccessEmptyLabels,
12
+ } from './EmptyStates';
13
+ import { firstRunSteps, notFoundSample } from './fixtures';
14
+
15
+ it('localizes first-run defaults and retains imported first-run and not-found fixtures', () => {
16
+ render(
17
+ <I18nProvider locale="es">
18
+ <FirstRunEmpty />
19
+ <NotFoundEmpty />
20
+ </I18nProvider>,
21
+ );
22
+ expect(screen.getByRole('heading', { name: es['emptyState.firstRun.title'] })).toHaveTextContent(
23
+ 'Crea tu primer proyecto',
24
+ );
25
+ expect(screen.getByText(es['emptyState.firstRun.description'])).toBeVisible();
26
+ expect(screen.getByRole('button', { name: es['emptyState.firstRun.action'] })).toBeVisible();
27
+ expect(screen.getByRole('link', { name: es['emptyState.firstRun.guide'] })).toHaveAttribute('href', '#guide');
28
+ for (const step of firstRunSteps) expect(screen.getByText(step)).toBeVisible();
29
+ expect(screen.getByRole('heading', { name: notFoundSample.title })).toBeVisible();
30
+ expect(screen.getByText(notFoundSample.description)).toBeVisible();
31
+ });
32
+
33
+ it('preserves first-run English and merges labels below explicit props', () => {
34
+ const { rerender } = render(<FirstRunEmpty />);
35
+ expect(screen.getByRole('heading', { name: 'Create your first project' })).toBeVisible();
36
+ expect(
37
+ screen.getByText(
38
+ 'Projects group your services, environments and deployments. Start one from a repository in a couple of minutes.',
39
+ ),
40
+ ).toBeVisible();
41
+ expect(screen.getByRole('button', { name: 'New project' })).toBeVisible();
42
+ expect(screen.getByRole('link', { name: 'Read the guide' })).toBeVisible();
43
+ const labels: FirstRunEmptyLabels = {
44
+ title: 'Title override',
45
+ description: 'Description override',
46
+ action: 'Action override',
47
+ guide: 'Guide override',
48
+ };
49
+ const view = (overrides: Partial<FirstRunEmptyLabels>, explicit = false) => (
50
+ <I18nProvider locale="es">
51
+ <FirstRunEmpty
52
+ labels={overrides}
53
+ title={explicit ? 'Explicit title' : undefined}
54
+ description={explicit ? 'Explicit description' : undefined}
55
+ actionLabel={explicit ? 'Explicit action' : undefined}
56
+ secondary={explicit ? { label: 'Explicit guide', href: '#explicit' } : undefined}
57
+ />
58
+ </I18nProvider>
59
+ );
60
+ rerender(view(labels));
61
+ expect(screen.getByRole('heading', { name: labels.title })).toBeVisible();
62
+ expect(screen.getByText(labels.description)).toBeVisible();
63
+ expect(screen.getByRole('button', { name: labels.action })).toBeVisible();
64
+ expect(screen.getByRole('link', { name: labels.guide })).toBeVisible();
65
+ rerender(view(labels, true));
66
+ expect(screen.getByRole('heading', { name: 'Explicit title' })).toBeVisible();
67
+ expect(screen.getByText('Explicit description')).toBeVisible();
68
+ expect(screen.getByRole('button', { name: 'Explicit action' })).toBeVisible();
69
+ expect(screen.getByRole('link', { name: 'Explicit guide' })).toHaveAttribute('href', '#explicit');
70
+ rerender(view({ action: 'Only action' }));
71
+ expect(screen.getByRole('heading', { name: es['emptyState.firstRun.title'] })).toBeVisible();
72
+ expect(screen.getByText(es['emptyState.firstRun.description'])).toBeVisible();
73
+ expect(screen.getByRole('link', { name: es['emptyState.firstRun.guide'] })).toBeVisible();
74
+ });
75
+
76
+ it.each([
77
+ [0, 'Revisa la ortografía o prueba una búsqueda más amplia.'],
78
+ [1, 'Revisa la ortografía o prueba una búsqueda más amplia con 1 filtro aplicado.'],
79
+ [2, 'Revisa la ortografía o prueba una búsqueda más amplia con 2 filtros aplicados.'],
80
+ ])('localizes no-results with %i filters and keeps the query in its mono span', (filterCount, description) => {
81
+ const { container, rerender } = render(
82
+ <I18nProvider locale="es">
83
+ <NoResultsEmpty filterCount={filterCount} />
84
+ </I18nProvider>,
85
+ );
86
+ const heading = screen.getByRole('heading', { name: 'No hay projects que coincidan con “billing-api”' });
87
+ expect(heading.querySelector('span.font-mono')).toHaveTextContent('billing-api');
88
+ expect(screen.getByText(description)).toBeVisible();
89
+ if (filterCount > 0)
90
+ expect(screen.getByRole('button', { name: es['emptyState.noResults.clearFilters'] })).toBeVisible();
91
+ expect(screen.getByRole('button', { name: es['emptyState.noResults.clearSearch'] })).toBeVisible();
92
+ expect(container.textContent).not.toContain('{');
93
+ rerender(
94
+ <I18nProvider locale="es">
95
+ <NoResultsEmpty query="" filterCount={filterCount} />
96
+ </I18nProvider>,
97
+ );
98
+ expect(screen.getByRole('heading', { name: 'No se encontraron projects' })).toBeVisible();
99
+ });
100
+
101
+ it('preserves English no-results markup and all per-key formatter overrides', () => {
102
+ const { rerender } = render(<NoResultsEmpty filterCount={1} />);
103
+ const heading = screen.getByRole('heading', { name: 'No projects match “billing-api”' });
104
+ expect(heading.innerHTML).toBe('No projects match “<span class="font-mono">billing-api</span>”');
105
+ expect(screen.getByText('Check the spelling or try a broader search with 1 filter applied.')).toBeVisible();
106
+ expect(screen.getByRole('button', { name: 'Clear filters' })).toBeVisible();
107
+ expect(screen.getByRole('button', { name: 'Clear search' })).toBeVisible();
108
+ rerender(<NoResultsEmpty query="" filterCount={2} />);
109
+ expect(screen.getByRole('heading', { name: 'No projects found' })).toBeVisible();
110
+ expect(screen.getByText('Check the spelling or try a broader search with 2 filters applied.')).toBeVisible();
111
+ const labels: NoResultsEmptyLabels = {
112
+ queryTitle: (entity, query) => `Query override ${entity}: ${query}`,
113
+ title: (entity) => `Title override ${entity}`,
114
+ description: (count) => `Description override ${count}`,
115
+ clearFilters: 'Filters override',
116
+ clearSearch: 'Search override',
117
+ };
118
+ const view = (overrides: Partial<NoResultsEmptyLabels>, query = 'billing-api') => (
119
+ <I18nProvider locale="es">
120
+ <NoResultsEmpty labels={overrides} query={query} />
121
+ </I18nProvider>
122
+ );
123
+ rerender(view(labels));
124
+ expect(screen.getByRole('heading', { name: 'Query override projects: billing-api' })).toBeVisible();
125
+ expect(screen.getByText('Description override 2')).toBeVisible();
126
+ expect(screen.getByRole('button', { name: labels.clearFilters })).toBeVisible();
127
+ expect(screen.getByRole('button', { name: labels.clearSearch })).toBeVisible();
128
+ rerender(view(labels, ''));
129
+ expect(screen.getByRole('heading', { name: 'Title override projects' })).toBeVisible();
130
+ rerender(view({ clearSearch: 'Only search' }));
131
+ expect(screen.getByRole('heading', { name: 'No hay projects que coincidan con “billing-api”' })).toBeVisible();
132
+ expect(
133
+ screen.getByText('Revisa la ortografía o prueba una búsqueda más amplia con 2 filtros aplicados.'),
134
+ ).toBeVisible();
135
+ expect(screen.getByRole('button', { name: es['emptyState.noResults.clearFilters'] })).toBeVisible();
136
+ });
137
+
138
+ it('localizes access messages around unchanged sample resource and owner, including requested state', async () => {
139
+ const user = userEvent.setup();
140
+ render(
141
+ <I18nProvider locale="es">
142
+ <NoAccessEmpty />
143
+ </I18nProvider>,
144
+ );
145
+ expect(screen.getByRole('heading', { name: 'No tienes acceso a Billing' })).toBeVisible();
146
+ expect(screen.getByText('Pide a an organization admin que te asigne un rol con permisos de billing.')).toBeVisible();
147
+ await user.click(screen.getByRole('button', { name: es['emptyState.noAccess.request'] }));
148
+ expect(screen.getByRole('button', { name: es['emptyState.noAccess.requested'] })).toBeDisabled();
149
+ expect(screen.getByRole('status')).toHaveTextContent(es['emptyState.noAccess.sent']);
150
+ expect(document.body.textContent).not.toContain('{');
151
+ });
152
+
153
+ it('keeps English access messages and renders each access override verbatim with catalog fallback', async () => {
154
+ const user = userEvent.setup();
155
+ const { rerender } = render(<NoAccessEmpty />);
156
+ expect(screen.getByRole('heading', { name: 'You don’t have access to Billing' })).toBeVisible();
157
+ expect(
158
+ screen.getByText('Ask an organization admin to grant you a role that includes billing permissions.'),
159
+ ).toBeVisible();
160
+ await user.click(screen.getByRole('button', { name: 'Request access' }));
161
+ expect(screen.getByRole('button', { name: 'Access requested' })).toBeDisabled();
162
+ expect(screen.getByRole('status')).toHaveTextContent('Access request sent');
163
+ const labels: NoAccessEmptyLabels = {
164
+ title: (resource) => `Title override ${resource}`,
165
+ description: (resource, owner) => `Description override ${resource}: ${owner}`,
166
+ request: 'Request override',
167
+ requested: 'Requested override',
168
+ sent: 'Sent override',
169
+ };
170
+ const view = (overrides: Partial<NoAccessEmptyLabels>) => (
171
+ <I18nProvider locale="es">
172
+ <NoAccessEmpty labels={overrides} />
173
+ </I18nProvider>
174
+ );
175
+ rerender(view(labels));
176
+ expect(screen.getByRole('heading', { name: 'Title override Billing' })).toBeVisible();
177
+ expect(screen.getByText('Description override Billing: an organization admin')).toBeVisible();
178
+ await user.click(screen.getByRole('button', { name: labels.request }));
179
+ expect(screen.getByRole('button', { name: labels.requested })).toBeDisabled();
180
+ expect(screen.getByRole('status')).toHaveTextContent(labels.sent);
181
+ rerender(view({ title: (resource) => `Only title ${resource}` }));
182
+ expect(screen.getByText('Pide a an organization admin que te asigne un rol con permisos de billing.')).toBeVisible();
183
+ expect(screen.getByRole('button', { name: es['emptyState.noAccess.requested'] })).toBeDisabled();
184
+ expect(screen.getByRole('status')).toHaveTextContent(es['emptyState.noAccess.sent']);
185
+ });
@@ -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
+ });