@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,4 +1,5 @@
1
1
  import { render, screen } from '@testing-library/react';
2
+ import { I18nProvider } from '@gntik-ai/ui';
2
3
  import userEvent from '@testing-library/user-event';
3
4
  import { expectNoAxeViolations } from '../../test/a11y';
4
5
  import { ChartCard } from './ChartCard';
@@ -6,6 +7,14 @@ import HeatmapChartCard from './examples/heatmap';
6
7
  import { TRAFFIC_BY_RANGE } from './fixtures';
7
8
 
8
9
  describe('ChartCard', () => {
10
+ it('uses the kit locale for the loading chart', () => {
11
+ render(
12
+ <I18nProvider locale="es">
13
+ <ChartCard state="loading" />
14
+ </I18nProvider>,
15
+ );
16
+ expect(screen.getByRole('status', { name: 'Cargando gráfico' })).toBeInTheDocument();
17
+ });
9
18
  it('renders title, legend and chart for the first range', async () => {
10
19
  const { container } = render(<ChartCard />);
11
20
  expect(screen.getByRole('heading', { name: 'Infrastructure cost' })).toBeInTheDocument();
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  AreaChart,
3
+ ChartLocaleProvider,
3
4
  BarChart,
4
5
  Heatmap,
5
6
  LineChart,
@@ -9,7 +10,17 @@ import {
9
10
  type HeatmapProps,
10
11
  type ValueFormatter,
11
12
  } from '@gntik-ai/charts';
12
- import { Card, CardAction, CardDescription, CardHeader, CardTitle, cn, Toggle, ToggleGroup } from '@gntik-ai/ui';
13
+ import {
14
+ Card,
15
+ CardAction,
16
+ CardDescription,
17
+ CardHeader,
18
+ CardTitle,
19
+ useI18n,
20
+ cn,
21
+ Toggle,
22
+ ToggleGroup,
23
+ } from '@gntik-ai/ui';
13
24
  import { useEffect, useRef, useState, type ReactNode } from 'react';
14
25
  import { TrendDelta, type KpiDelta } from '../shared/TrendDelta';
15
26
  import { COST_BY_RANGE, COST_RANGES, type CostPoint } from './fixtures';
@@ -146,73 +157,76 @@ export function ChartCard<T extends object = CostPoint>({
146
157
  'aria-label': chartLabel,
147
158
  ...states,
148
159
  };
160
+ const { locale } = useI18n();
149
161
  return (
150
- <Card className={className}>
151
- <CardHeader className="pb-2">
152
- <CardTitle as={titleAs}>{title}</CardTitle>
153
- {description && <CardDescription>{description}</CardDescription>}
154
- <CardAction className="flex items-center gap-2">
155
- {showRangeToggle && ranges.length > 1 && (
156
- <ToggleGroup
157
- aria-label={`${title} range`}
158
- size="sm"
159
- value={active ? [active.value] : []}
160
- onFocus={(event) => {
161
- // Tab enters at the pressed option; pointer and restored focus stay on their original option.
162
- if (!tabEntry.current) return;
163
- if (event.relatedTarget instanceof Node && event.currentTarget.contains(event.relatedTarget)) return;
164
- const selected = event.currentTarget.querySelector<HTMLButtonElement>('[aria-pressed="true"]');
165
- selected?.focus();
166
- }}
167
- onValueChange={(v) => {
168
- const next = v[0];
169
- if (!next) return;
170
- if (rangeProp === undefined) setInner(next);
171
- onRangeChange?.(next);
172
- }}
173
- >
174
- {ranges.map((r) => (
175
- <Toggle key={r.value} value={r.value} className="font-mono">
176
- {r.label}
177
- </Toggle>
178
- ))}
179
- </ToggleGroup>
180
- )}
181
- {action}
182
- </CardAction>
183
- </CardHeader>
184
- {active?.summary && (
185
- <p className="flex flex-wrap items-baseline gap-x-2 px-5" aria-live="polite">
186
- <span className="text-[24px] font-semibold tracking-tight text-foreground tabular-nums">
187
- {active.summary.value}
188
- </span>
189
- {active.summary.delta && <TrendDelta {...active.summary.delta} />}
190
- </p>
191
- )}
192
- <div className={cn('px-3 pb-4 pt-3 sm:px-4', !footer && 'pb-5')}>
193
- {kind === 'heatmap' ? (
194
- <Heatmap
195
- data={data}
196
- index={index}
197
- categories={categories}
198
- color={colors[0] ?? 'primary'}
199
- valueFormatter={valueFormatter}
200
- showScale={showLegend}
201
- height={height}
202
- aria-label={chartLabel}
203
- {...heatmap}
204
- {...states}
205
- dataTable={dataTable ?? true}
206
- />
207
- ) : kind === 'bar' ? (
208
- <BarChart {...common} stacked={stacked} />
209
- ) : kind === 'line' ? (
210
- <LineChart {...common} />
211
- ) : (
212
- <AreaChart {...common} stacked={stacked} />
162
+ <ChartLocaleProvider locale={locale}>
163
+ <Card className={className}>
164
+ <CardHeader className="pb-2">
165
+ <CardTitle as={titleAs}>{title}</CardTitle>
166
+ {description && <CardDescription>{description}</CardDescription>}
167
+ <CardAction className="flex items-center gap-2">
168
+ {showRangeToggle && ranges.length > 1 && (
169
+ <ToggleGroup
170
+ aria-label={`${title} range`}
171
+ size="sm"
172
+ value={active ? [active.value] : []}
173
+ onFocus={(event) => {
174
+ // Tab enters at the pressed option; pointer and restored focus stay on their original option.
175
+ if (!tabEntry.current) return;
176
+ if (event.relatedTarget instanceof Node && event.currentTarget.contains(event.relatedTarget)) return;
177
+ const selected = event.currentTarget.querySelector<HTMLButtonElement>('[aria-pressed="true"]');
178
+ selected?.focus();
179
+ }}
180
+ onValueChange={(v) => {
181
+ const next = v[0];
182
+ if (!next) return;
183
+ if (rangeProp === undefined) setInner(next);
184
+ onRangeChange?.(next);
185
+ }}
186
+ >
187
+ {ranges.map((r) => (
188
+ <Toggle key={r.value} value={r.value} className="font-mono">
189
+ {r.label}
190
+ </Toggle>
191
+ ))}
192
+ </ToggleGroup>
193
+ )}
194
+ {action}
195
+ </CardAction>
196
+ </CardHeader>
197
+ {active?.summary && (
198
+ <p className="flex flex-wrap items-baseline gap-x-2 px-5" aria-live="polite">
199
+ <span className="text-[24px] font-semibold tracking-tight text-foreground tabular-nums">
200
+ {active.summary.value}
201
+ </span>
202
+ {active.summary.delta && <TrendDelta {...active.summary.delta} />}
203
+ </p>
213
204
  )}
214
- </div>
215
- {footer && <div className="border-t border-border px-5 py-3 text-[12.5px] text-muted-foreground">{footer}</div>}
216
- </Card>
205
+ <div className={cn('px-3 pb-4 pt-3 sm:px-4', !footer && 'pb-5')}>
206
+ {kind === 'heatmap' ? (
207
+ <Heatmap
208
+ data={data}
209
+ index={index}
210
+ categories={categories}
211
+ color={colors[0] ?? 'primary'}
212
+ valueFormatter={valueFormatter}
213
+ showScale={showLegend}
214
+ height={height}
215
+ aria-label={chartLabel}
216
+ {...heatmap}
217
+ {...states}
218
+ dataTable={dataTable ?? true}
219
+ />
220
+ ) : kind === 'bar' ? (
221
+ <BarChart {...common} stacked={stacked} />
222
+ ) : kind === 'line' ? (
223
+ <LineChart {...common} />
224
+ ) : (
225
+ <AreaChart {...common} stacked={stacked} />
226
+ )}
227
+ </div>
228
+ {footer && <div className="border-t border-border px-5 py-3 text-[12.5px] text-muted-foreground">{footer}</div>}
229
+ </Card>
230
+ </ChartLocaleProvider>
217
231
  );
218
232
  }
@@ -5,6 +5,6 @@ export const meta: BlockMeta = {
5
5
  family: 'data-display',
6
6
  status: 'beta',
7
7
  description:
8
- 'A Card with chart and legend: default 7d/30d/90d or custom ranges via ranges, controlled range/onRangeChange, and showRangeToggle={false} when a toolbar owns the range (pass its window as range). Supports title, optional headline and delta, area/line/bar/heatmap charts, and loading, empty and error states. Supply matching dataByRange keys and use defaultRange for initial uncontrolled selection; the toolbar is the only range control when the toggle is hidden. Unknown range/defaultRange keys fall back to the first option for selection, data and label, with a development-only warning.',
8
+ 'A Card with chart and legend: default 7d/30d/90d or custom ranges via ranges, controlled range/onRangeChange, and showRangeToggle={false} when a toolbar owns the range (pass its window as range). Supports title, optional headline and delta, area/line/bar/heatmap charts, and loading, empty and error states. Supply matching dataByRange keys and use defaultRange for initial uncontrolled selection; the toolbar is the only range control when the toggle is hidden. Unknown range/defaultRange keys fall back to the first option for selection, data and label, with a development-only warning. Chart states follow the kit I18nProvider locale automatically through ChartLocaleProvider; standalone charts need their own ChartLocaleProvider (en/es, per-key labels overrides). Number/date formatting stays caller-controlled.',
9
9
  uses: ['Card', 'ToggleGroup', 'AreaChart', 'LineChart', 'BarChart', 'Heatmap', 'ChartLegend'],
10
10
  };
@@ -0,0 +1,73 @@
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 { DescriptionListCard, type DescriptionListCardLabels } from './DescriptionListCard';
5
+ import { DEPLOYMENT_DETAILS } from './fixtures';
6
+
7
+ it('localizes card defaults, copy names and announcements while retaining fixture fields', async () => {
8
+ const user = userEvent.setup();
9
+ render(
10
+ <I18nProvider locale="es">
11
+ <DescriptionListCard onEdit={() => {}} />
12
+ </I18nProvider>,
13
+ );
14
+ expect(screen.getByRole('heading', { name: es['descriptionList.title'] })).toHaveTextContent('Configuración');
15
+ expect(screen.getByText(es['descriptionList.description'])).toBeVisible();
16
+ expect(screen.getByRole('button', { name: es['descriptionList.edit'] })).toBeVisible();
17
+ for (const item of DEPLOYMENT_DETAILS) {
18
+ expect(screen.getByText(item.label)).toBeVisible();
19
+ if (item.value && !item.status && !item.render) expect(screen.getByText(item.value)).toBeVisible();
20
+ }
21
+ await user.click(screen.getByRole('button', { name: 'Copiar Deployment ID' }));
22
+ expect(screen.getByRole('button', { name: 'Deployment ID copiado' })).toBeVisible();
23
+ expect(screen.getByText(es['common.copiedToClipboard'])).toBeInTheDocument();
24
+ expect(await navigator.clipboard.readText()).toBe('dep_7f3c9a21');
25
+ expect(document.body.textContent).not.toContain('{');
26
+ });
27
+
28
+ it('keeps English defaults and lets explicit props win over every override', async () => {
29
+ const user = userEvent.setup();
30
+ const { rerender } = render(<DescriptionListCard onEdit={() => {}} />);
31
+ expect(screen.getByRole('heading', { name: 'Configuration' })).toBeVisible();
32
+ expect(screen.getByText('Settings of this deployment.')).toBeVisible();
33
+ expect(screen.getByRole('button', { name: 'Edit' })).toBeVisible();
34
+ await user.click(screen.getByRole('button', { name: 'Copy Deployment ID' }));
35
+ expect(screen.getByRole('button', { name: 'Deployment ID copied' })).toBeVisible();
36
+ expect(screen.getByText('Copied to clipboard')).toBeInTheDocument();
37
+ const labels: DescriptionListCardLabels = {
38
+ title: 'Title override',
39
+ description: 'Description override',
40
+ edit: 'Edit override',
41
+ copy: (label) => `Copy override ${label}`,
42
+ copied: (label) => `Copied override ${label}`,
43
+ copiedToClipboard: 'Announce override',
44
+ };
45
+ const view = (overrides: Partial<DescriptionListCardLabels>, explicit = false) => (
46
+ <I18nProvider locale="es">
47
+ <DescriptionListCard
48
+ labels={overrides}
49
+ onEdit={() => {}}
50
+ title={explicit ? 'Explicit title' : undefined}
51
+ description={explicit ? 'Explicit description' : undefined}
52
+ editLabel={explicit ? 'Explicit edit' : undefined}
53
+ />
54
+ </I18nProvider>
55
+ );
56
+ rerender(view(labels));
57
+ expect(screen.getByRole('heading', { name: labels.title })).toBeVisible();
58
+ expect(screen.getByText(labels.description)).toBeVisible();
59
+ expect(screen.getByRole('button', { name: labels.edit })).toBeVisible();
60
+ await user.click(screen.getByRole('button', { name: 'Copy override Deployment ID' }));
61
+ expect(screen.getByRole('button', { name: 'Copied override Deployment ID' })).toBeVisible();
62
+ expect(screen.getByText(labels.copiedToClipboard)).toBeInTheDocument();
63
+ await user.click(screen.getByRole('button', { name: 'Copy override Endpoint' }));
64
+ expect(screen.getByRole('button', { name: 'Copied override Endpoint' })).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 edit' })).toBeVisible();
69
+ rerender(view({ edit: 'Only edit' }));
70
+ expect(screen.getByRole('heading', { name: es['descriptionList.title'] })).toBeVisible();
71
+ expect(screen.getByText(es['descriptionList.description'])).toBeVisible();
72
+ expect(screen.getByRole('button', { name: 'Deployment ID copiado' })).toBeVisible();
73
+ });
@@ -9,6 +9,7 @@ import {
9
9
  cn,
10
10
  IconButton,
11
11
  StatusTag,
12
+ useI18n,
12
13
  } from '@gntik-ai/ui';
13
14
  import { useEffect, useRef, useState, type ReactNode } from 'react';
14
15
  import { DEPLOYMENT_DETAILS } from './fixtures';
@@ -29,7 +30,18 @@ export interface DescriptionItem {
29
30
  copyValue?: string;
30
31
  }
31
32
 
33
+ export interface DescriptionListCardLabels {
34
+ title: string;
35
+ description: string;
36
+ edit: string;
37
+ copy: (label: string) => string;
38
+ copied: (label: string) => string;
39
+ copiedToClipboard: string;
40
+ }
41
+
32
42
  export interface DescriptionListCardProps {
43
+ /** Per-key copy overrides; explicit props take precedence, then labels, then the active catalog. */
44
+ labels?: Partial<DescriptionListCardLabels>;
33
45
  title?: string;
34
46
  description?: string;
35
47
  items?: readonly DescriptionItem[];
@@ -43,7 +55,16 @@ export interface DescriptionListCardProps {
43
55
  className?: string;
44
56
  }
45
57
 
46
- function CopyButton({ item, onCopy }: { item: DescriptionItem; onCopy?: (item: DescriptionItem) => void }) {
58
+ function CopyButton({
59
+ item,
60
+ onCopy,
61
+ labels,
62
+ }: {
63
+ item: DescriptionItem;
64
+ onCopy?: (item: DescriptionItem) => void;
65
+ labels?: Partial<DescriptionListCardLabels>;
66
+ }) {
67
+ const { t } = useI18n();
47
68
  const [copied, setCopied] = useState(false);
48
69
  const timer = useRef<number | undefined>(undefined);
49
70
  useEffect(() => () => window.clearTimeout(timer.current), []);
@@ -61,14 +82,18 @@ function CopyButton({ item, onCopy }: { item: DescriptionItem; onCopy?: (item: D
61
82
  <>
62
83
  <IconButton
63
84
  icon={copied ? Check : Copy}
64
- label={copied ? `${item.label} copied` : `Copy ${item.label}`}
85
+ label={
86
+ copied
87
+ ? (labels?.copied?.(item.label) ?? t('descriptionList.copied', { label: item.label }))
88
+ : (labels?.copy?.(item.label) ?? t('descriptionList.copy', { label: item.label }))
89
+ }
65
90
  size="sm"
66
91
  variant="ghost"
67
92
  className={cn('size-7 shrink-0', copied && 'text-success-text')}
68
93
  onClick={copy}
69
94
  />
70
95
  <span className="sr-only" aria-live="polite">
71
- {copied ? 'Copied to clipboard' : ''}
96
+ {copied ? (labels?.copiedToClipboard ?? t('common.copiedToClipboard')) : ''}
72
97
  </span>
73
98
  </>
74
99
  );
@@ -76,15 +101,20 @@ function CopyButton({ item, onCopy }: { item: DescriptionItem; onCopy?: (item: D
76
101
 
77
102
  /** Key–value detail card: label column, values (mono, status or rich), copy buttons and an Edit action. */
78
103
  export function DescriptionListCard({
79
- title = 'Configuration',
80
- description = 'Settings of this deployment.',
104
+ title: titleProp,
105
+ labels,
106
+ description: descriptionProp,
81
107
  items = DEPLOYMENT_DETAILS,
82
108
  onEdit,
83
- editLabel = 'Edit',
109
+ editLabel: editLabelProp,
84
110
  onCopy,
85
111
  titleAs = 'h3',
86
112
  className,
87
113
  }: DescriptionListCardProps) {
114
+ const { t } = useI18n();
115
+ const title = titleProp ?? labels?.title ?? t('descriptionList.title');
116
+ const description = descriptionProp ?? labels?.description ?? t('descriptionList.description');
117
+ const editLabel = editLabelProp ?? labels?.edit ?? t('descriptionList.edit');
88
118
  return (
89
119
  <Card className={className}>
90
120
  <CardHeader divided>
@@ -110,7 +140,7 @@ export function DescriptionListCard({
110
140
  {item.render ?? item.value}
111
141
  </span>
112
142
  )}
113
- {item.copyable && <CopyButton item={item} onCopy={onCopy} />}
143
+ {item.copyable && <CopyButton item={item} onCopy={onCopy} labels={labels} />}
114
144
  </dd>
115
145
  </div>
116
146
  ))}
@@ -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
+ });