@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
@@ -0,0 +1,75 @@
1
+ import {
2
+ formatWeekRange,
3
+ weekendDays,
4
+ dayKey,
5
+ monthGrid,
6
+ startOfWeek,
7
+ weekDays,
8
+ formatTime,
9
+ formatRange,
10
+ formatHour,
11
+ } from './dates';
12
+ import type { WeekDay } from '@gntik-ai/ui';
13
+
14
+ it.each<[WeekDay, string]>([
15
+ [0, '2026-03-29'],
16
+ [1, '2026-03-30'],
17
+ [6, '2026-03-28'],
18
+ ])('starts April weeks on weekday %s', (weekStartsOn, expected) => {
19
+ const april = new Date(2026, 3, 1, 12);
20
+ expect(dayKey(startOfWeek(april, weekStartsOn))).toBe(expected);
21
+ expect(startOfWeek(april, weekStartsOn).getHours()).toBe(0);
22
+ expect(weekDays(april, weekStartsOn)).toHaveLength(7);
23
+ expect(weekDays(april, weekStartsOn)[0]).toEqual(new Date(`${expected}T00:00:00`));
24
+ const grid = monthGrid(april, weekStartsOn);
25
+ expect(grid).toHaveLength(6);
26
+ expect(grid.every((week) => week.length === 7)).toBe(true);
27
+ expect(grid[0]?.[0]).toEqual(new Date(`${expected}T00:00:00`));
28
+ });
29
+
30
+ it.each([
31
+ ['en-US', 'h12', '9:30 AM', '9:30 AM–10:00 AM', '9 AM', '12 PM'],
32
+ ['en-US', 'h23', '09:30', '09:30–10:00', '09:00', '12:00'],
33
+ ['es-ES', 'h23', '09:30', '09:30–10:00', '09:00', '12:00'],
34
+ ['es-ES', 'h12', '9:30 a. m.', '9:30 a. m.–10:00 a. m.', '9 a. m.', '12 p. m.'],
35
+ ] as const)('formats time and gutter labels in %s with %s', (locale, cycle, time, range, hour, noon) => {
36
+ const start = new Date(2026, 3, 15, 9, 30);
37
+ expect(formatTime(start, locale, cycle)).toBe(time);
38
+ expect(formatRange(start, new Date(2026, 3, 15, 10), locale, cycle)).toBe(range);
39
+ expect(formatHour(9, locale, cycle)).toBe(hour);
40
+ expect(formatHour(12, locale, cycle)).toBe(noon);
41
+ });
42
+
43
+ it('uses locale weekends and falls back to Saturday and Sunday without Intl week info', () => {
44
+ expect(weekendDays('en-US')).toEqual([6, 0]);
45
+ expect(weekendDays('ar-SA')).toEqual([5, 6]);
46
+ const original = Intl.Locale;
47
+ try {
48
+ vi.stubGlobal('Intl', Object.create(Intl, { Locale: { value: class {} } }));
49
+ expect(weekendDays('en-US')).toEqual([6, 0]);
50
+ } finally {
51
+ vi.unstubAllGlobals();
52
+ expect(Intl.Locale).toBe(original);
53
+ }
54
+ });
55
+
56
+ it('keeps English week labels independent of the host locale', () => {
57
+ const NativeFormatter = Intl.DateTimeFormat;
58
+ try {
59
+ vi.stubGlobal(
60
+ 'Intl',
61
+ Object.create(Intl, {
62
+ DateTimeFormat: {
63
+ value: class extends NativeFormatter {
64
+ constructor(locale?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) {
65
+ super(locale ?? 'es-ES', options);
66
+ }
67
+ },
68
+ },
69
+ }),
70
+ );
71
+ expect(formatWeekRange(weekDays(new Date(2026, 3, 15), 1), 'en-GB')).toBe('Apr 13 – 19, 2026');
72
+ } finally {
73
+ vi.unstubAllGlobals();
74
+ }
75
+ });
@@ -1,4 +1,5 @@
1
- /** Native-Date helpers for the scheduling blocks. Weeks start on Monday. */
1
+ /** Native-Date helpers for the scheduling blocks. Week starts are caller-supplied. */
2
+ import type { WeekDay } from '@gntik-ai/ui';
2
3
 
3
4
  const pad = (n: number) => String(n).padStart(2, '0');
4
5
 
@@ -31,19 +32,19 @@ export function sameMonth(a: Date, b: Date): boolean {
31
32
  return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth();
32
33
  }
33
34
 
34
- /** Monday of the week containing `d`. */
35
- export function startOfWeek(d: Date): Date {
36
- return addDays(startOfDay(d), -((d.getDay() + 6) % 7));
35
+ /** First day of the week containing `d`. */
36
+ export function startOfWeek(d: Date, weekStartsOn: WeekDay): Date {
37
+ return addDays(startOfDay(d), -((d.getDay() - weekStartsOn + 7) % 7));
37
38
  }
38
39
 
39
- export function weekDays(d: Date): Date[] {
40
- const mon = startOfWeek(d);
41
- return Array.from({ length: 7 }, (_, i) => addDays(mon, i));
40
+ export function weekDays(d: Date, weekStartsOn: WeekDay): Date[] {
41
+ const first = startOfWeek(d, weekStartsOn);
42
+ return Array.from({ length: 7 }, (_, i) => addDays(first, i));
42
43
  }
43
44
 
44
- /** Six Monday-first weeks covering the month of `d`. */
45
- export function monthGrid(d: Date): Date[][] {
46
- const start = startOfWeek(startOfMonth(d));
45
+ /** Six weeks covering the month of `d`, starting on `weekStartsOn`. */
46
+ export function monthGrid(d: Date, weekStartsOn: WeekDay): Date[][] {
47
+ const start = startOfWeek(startOfMonth(d), weekStartsOn);
47
48
  return Array.from({ length: 6 }, (_, w) => Array.from({ length: 7 }, (_, i) => addDays(start, w * 7 + i)));
48
49
  }
49
50
 
@@ -53,23 +54,33 @@ export function hourOf(d: Date): number {
53
54
  }
54
55
 
55
56
  const cache = new Map<string, Intl.DateTimeFormat>();
56
- /** Cached Intl formatter; `locale` defaults to en-US (pass `useI18n().locale` to localise). */
57
+ /** Cached Intl formatter; an omitted locale uses the runtime locale. */
57
58
  const fmt = (locale: string | undefined, opts: Intl.DateTimeFormatOptions) => {
58
- const key = `${locale ?? 'en-US'}|${JSON.stringify(opts)}`;
59
+ const key = `${locale ?? new Intl.DateTimeFormat().resolvedOptions().locale}|${JSON.stringify(opts)}`;
59
60
  let f = cache.get(key);
60
61
  if (!f) {
61
- f = new Intl.DateTimeFormat(locale ?? 'en-US', opts);
62
+ f = new Intl.DateTimeFormat(locale, opts);
62
63
  cache.set(key, f);
63
64
  }
64
65
  return f;
65
66
  };
66
67
 
67
- /** "09:30". */
68
- export const formatTime = (d: Date, locale?: string) =>
69
- fmt(locale, { hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }).format(d);
70
- /** "09:30–10:00". */
71
- export const formatRange = (start: Date, end: Date, locale?: string) =>
72
- `${formatTime(start, locale)}–${formatTime(end, locale)}`;
68
+ /** The clock options accepted by the scheduling blocks. */
69
+ export type HourCycle = 'h12' | 'h23';
70
+
71
+ /** "9:30 AM" or "09:30". */
72
+ export const formatTime = (d: Date, locale: string | undefined, hourCycle: HourCycle) =>
73
+ fmt(locale, { hour: hourCycle === 'h12' ? 'numeric' : '2-digit', minute: '2-digit', hourCycle }).format(d);
74
+ /** "9:30 AM–10:00 AM" or "09:30–10:00". */
75
+ export const formatRange = (start: Date, end: Date, locale: string | undefined, hourCycle: HourCycle) =>
76
+ `${formatTime(start, locale, hourCycle)}–${formatTime(end, locale, hourCycle)}`;
77
+ /** Compact gutter label: "9 AM" or "09:00". */
78
+ export const formatHour = (hour: number, locale: string | undefined, hourCycle: HourCycle) =>
79
+ fmt(locale, {
80
+ hour: hourCycle === 'h12' ? 'numeric' : '2-digit',
81
+ ...(hourCycle === 'h23' ? { minute: '2-digit' as const } : {}),
82
+ hourCycle,
83
+ }).format(new Date(2026, 0, 1, hour));
73
84
  /** "Wednesday, April 15, 2026". */
74
85
  export const formatFullDate = (d: Date, locale?: string) =>
75
86
  fmt(locale, { weekday: 'long', month: 'long', day: 'numeric', year: 'numeric' }).format(d);
@@ -91,8 +102,21 @@ export function formatWeekRange(days: readonly Date[], locale?: string): string
91
102
  if (!first || !last) return '';
92
103
  if (locale && !locale.toLowerCase().startsWith('en'))
93
104
  return fmt(locale, { month: 'short', day: 'numeric', year: 'numeric' }).formatRange(first, last);
94
- if (sameMonth(first, last)) return `${formatShort(first)} – ${last.getDate()}, ${last.getFullYear()}`;
105
+ if (sameMonth(first, last)) return `${formatShort(first, 'en-US')} – ${last.getDate()}, ${last.getFullYear()}`;
95
106
  if (first.getFullYear() === last.getFullYear())
96
- return `${formatShort(first)} – ${formatShort(last)}, ${last.getFullYear()}`;
97
- return `${formatShort(first)}, ${first.getFullYear()} – ${formatShort(last)}, ${last.getFullYear()}`;
107
+ return `${formatShort(first, 'en-US')} – ${formatShort(last, 'en-US')}, ${last.getFullYear()}`;
108
+ return `${formatShort(first, 'en-US')}, ${first.getFullYear()} – ${formatShort(last, 'en-US')}, ${last.getFullYear()}`;
109
+ }
110
+
111
+ /** Internal to blocks: Intl weekdays 1–7 become JS weekdays 0–6. */
112
+ export function weekendDays(locale?: string): WeekDay[] {
113
+ try {
114
+ const loc = new Intl.Locale(locale ?? new Intl.DateTimeFormat().resolvedOptions().locale) as Intl.Locale & {
115
+ getWeekInfo?: () => { weekend: number[] };
116
+ weekInfo?: { weekend: number[] };
117
+ };
118
+ const info = loc.getWeekInfo?.() ?? loc.weekInfo;
119
+ if (info) return info.weekend.map((day) => (day % 7) as WeekDay);
120
+ } catch {}
121
+ return [6, 0];
98
122
  }
@@ -0,0 +1,13 @@
1
+ import { localeHourCycle, useOptionalI18n } from '@gntik-ai/ui';
2
+ import type { HourCycle } from './dates';
3
+
4
+ /** Map the existing public numeric clock API to scheduling's Intl options. */
5
+ function resolveHourCycle(locale?: string): HourCycle {
6
+ return localeHourCycle(locale) === 12 ? 'h12' : 'h23';
7
+ }
8
+
9
+ /** Undefined outside a provider lets Intl use the runtime locale, as ui Calendar does. */
10
+ export function useSchedulingClock(override?: HourCycle) {
11
+ const locale = useOptionalI18n()?.locale;
12
+ return { locale, hourCycle: override ?? resolveHourCycle(locale) };
13
+ }
@@ -4,6 +4,18 @@ import { expectNoAxeViolations } from '../../test/a11y';
4
4
  import { GlobalSearch } from './GlobalSearch';
5
5
 
6
6
  describe('GlobalSearch', () => {
7
+ afterEach(() => vi.unstubAllGlobals());
8
+
9
+ it('shows Ctrl for the Create project shortcut on Linux', async () => {
10
+ vi.stubGlobal('navigator', { platform: 'Linux x86_64' });
11
+ const user = userEvent.setup();
12
+ render(<GlobalSearch />);
13
+ await user.click(screen.getByRole('button', { name: /Search/ }));
14
+ const item = await screen.findByRole('option', { name: /Create project/ });
15
+ expect(within(item).getByText('Ctrl')).toBeInTheDocument();
16
+ expect(within(item).queryByText('⌘')).not.toBeInTheDocument();
17
+ });
18
+
7
19
  it('renders the trigger with the shortcut hint', async () => {
8
20
  const { container } = render(<GlobalSearch />);
9
21
  expect(screen.getByRole('button', { name: /Search/ })).toBeInTheDocument();
@@ -19,7 +19,7 @@ export const globalSearchPages: CommandItem[] = [
19
19
  { id: 'page-analytics', label: 'Analytics', icon: BarChart3 },
20
20
  { id: 'page-members', label: 'Members', icon: Users, keywords: ['team', 'people'] },
21
21
  { id: 'page-billing', label: 'Billing', icon: CreditCard, keywords: ['invoices', 'plan'] },
22
- { id: 'page-settings', label: 'Settings', icon: Settings, shortcut: ['⌘', ','] },
22
+ { id: 'page-settings', label: 'Settings', icon: Settings, shortcut: ['mod', ','] },
23
23
  ];
24
24
 
25
25
  export const globalSearchRecords: CommandItem[] = [
@@ -48,7 +48,7 @@ export const globalSearchRecords: CommandItem[] = [
48
48
  ];
49
49
 
50
50
  export const globalSearchActions: CommandItem[] = [
51
- { id: 'action-new-project', label: 'Create project', icon: FolderPlus, shortcut: ['⌘', 'N'], keywords: ['new'] },
51
+ { id: 'action-new-project', label: 'Create project', icon: FolderPlus, shortcut: ['mod', 'N'], keywords: ['new'] },
52
52
  {
53
53
  id: 'action-deploy',
54
54
  label: 'Deploy to production',
@@ -233,6 +233,8 @@ it('replaces every pin option and the single-selection heading without translati
233
233
  const user = userEvent.setup({ pointerEventsCheck: 0 });
234
234
  const full: DataTableLabels = {
235
235
  ...labels,
236
+ booleanTrue: 'Sí',
237
+ booleanFalse: 'No',
236
238
  selectGroup: (group) => `Grupo ${group}`,
237
239
  groupRows: (count) => `${count} filas`,
238
240
  noGroup: 'Sin grupo',
@@ -0,0 +1,153 @@
1
+ import { I18nProvider } from '@gntik-ai/ui';
2
+ import { render, screen } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+ import { expectNoAxeViolations } from '../../test/a11y';
5
+ import { DataTable } from './DataTable';
6
+ import type { CellValue, DataTableColumn } from './data-table-utils';
7
+
8
+ type Row = { id: string; value: CellValue };
9
+ const columns: DataTableColumn<Row>[] = [
10
+ { id: 'value', header: 'Value', accessor: (row) => row.value, sortable: true },
11
+ ];
12
+ const rowsOf = (...values: CellValue[]): Row[] => values.map((value, i) => ({ id: String(i), value }));
13
+ const cellTexts = () => screen.getAllByRole('cell').map((cell) => cell.textContent);
14
+
15
+ describe('DataTable default cell locale', () => {
16
+ it('reads boolean labels from the Spanish catalog', () => {
17
+ render(
18
+ <I18nProvider locale="es">
19
+ <DataTable rows={rowsOf(true, false)} columns={columns} selectable={false} paginated={false} />
20
+ </I18nProvider>,
21
+ );
22
+ expect(cellTexts()).toEqual(['Sí', 'No']);
23
+ });
24
+
25
+ it.each(['es', 'en'])('prefers per-instance boolean labels under %s', (locale) => {
26
+ render(
27
+ <I18nProvider locale={locale}>
28
+ <DataTable
29
+ rows={rowsOf(true, false)}
30
+ columns={columns}
31
+ selectable={false}
32
+ paginated={false}
33
+ labels={{ booleanTrue: 'On', booleanFalse: 'Off' }}
34
+ />
35
+ </I18nProvider>,
36
+ );
37
+ expect(cellTexts()).toEqual(['On', 'Off']);
38
+ });
39
+
40
+ it.each([
41
+ ['es', '17/10/2026'],
42
+ ['en-US', '10/17/2026'],
43
+ ])('formats valid dates and handles invalid dates under %s', (locale, expected) => {
44
+ render(
45
+ <I18nProvider locale={locale}>
46
+ <DataTable
47
+ rows={rowsOf(new Date(2026, 9, 17), new Date('x'))}
48
+ columns={columns}
49
+ selectable={false}
50
+ paginated={false}
51
+ />
52
+ </I18nProvider>,
53
+ );
54
+ expect(cellTexts()).toEqual([expected, '—']);
55
+ });
56
+
57
+ it.each([
58
+ ['es', ['1234,5', '1234567', '0,30000000000000004', 'NaN', 'Infinity', '-Infinity']],
59
+ ['en', ['1234.5', '1234567', '0.30000000000000004', 'NaN', 'Infinity', '-Infinity']],
60
+ ] as const)('keeps number digits and only localizes the decimal separator under %s', (locale, expected) => {
61
+ render(
62
+ <I18nProvider locale={locale}>
63
+ <DataTable
64
+ rows={rowsOf(1234.5, 1234567, 0.30000000000000004, NaN, Infinity, -Infinity)}
65
+ columns={columns}
66
+ selectable={false}
67
+ paginated={false}
68
+ />
69
+ </I18nProvider>,
70
+ );
71
+ expect(cellTexts()).toEqual(expected);
72
+ });
73
+
74
+ it('keeps English boolean labels under an English provider', () => {
75
+ render(
76
+ <I18nProvider locale="en">
77
+ <DataTable rows={rowsOf(true, false)} columns={columns} selectable={false} paginated={false} />
78
+ </I18nProvider>,
79
+ );
80
+ expect(cellTexts()).toEqual(['Yes', 'No']);
81
+ });
82
+
83
+ it('uses provider catalog overrides with individual label fallbacks', () => {
84
+ render(
85
+ <I18nProvider locale="es" messages={{ 'common.yes': 'Affirmative', 'common.no': 'Negative' }}>
86
+ <DataTable
87
+ rows={rowsOf(true, false)}
88
+ columns={columns}
89
+ selectable={false}
90
+ paginated={false}
91
+ labels={{ booleanTrue: 'On' }}
92
+ />
93
+ </I18nProvider>,
94
+ );
95
+ expect(cellTexts()).toEqual(['On', 'Negative']);
96
+ });
97
+
98
+ it('keeps runtime defaults outside a provider', () => {
99
+ const date = new Date(2026, 9, 17);
100
+ render(
101
+ <DataTable
102
+ rows={rowsOf(true, false, date, 1234.5, 1234567, 0.30000000000000004)}
103
+ columns={columns}
104
+ selectable={false}
105
+ paginated={false}
106
+ />,
107
+ );
108
+ expect(cellTexts()).toEqual(['Yes', 'No', date.toLocaleDateString(), '1234.5', '1234567', '0.30000000000000004']);
109
+ });
110
+
111
+ it('sorts raw numeric accessor values while showing Spanish decimals', async () => {
112
+ const user = userEvent.setup();
113
+ render(
114
+ <I18nProvider locale="es">
115
+ <DataTable rows={rowsOf(10.1, 2.2, 2.11)} columns={columns} selectable={false} paginated={false} />
116
+ </I18nProvider>,
117
+ );
118
+ await user.click(screen.getByRole('button', { name: 'Value' }));
119
+ expect(cellTexts()).toEqual(['2,11', '2,2', '10,1']);
120
+ await user.click(screen.getByRole('button', { name: 'Value' }));
121
+ expect(cellTexts()).toEqual(['10,1', '2,2', '2,11']);
122
+ });
123
+
124
+ it('leaves custom cell renderers in control', () => {
125
+ render(
126
+ <I18nProvider locale="es">
127
+ <DataTable
128
+ rows={rowsOf(true, new Date('x'), 1234.5)}
129
+ columns={[{ ...columns[0]!, cell: () => 'Custom value' }]}
130
+ selectable={false}
131
+ paginated={false}
132
+ />
133
+ </I18nProvider>,
134
+ );
135
+ expect(cellTexts()).toEqual(['Custom value', 'Custom value', 'Custom value']);
136
+ });
137
+
138
+ it.each(['dark', 'light', 'high_contrast'])('has no structural axe violations in %s', async (theme) => {
139
+ document.documentElement.className = theme;
140
+ const { container } = render(
141
+ <I18nProvider locale="es">
142
+ <DataTable
143
+ rows={rowsOf(true, false, new Date(2026, 9, 17), new Date('x'), 1234.5)}
144
+ columns={columns}
145
+ caption="Values"
146
+ selectable={false}
147
+ paginated={false}
148
+ />
149
+ </I18nProvider>,
150
+ );
151
+ await expectNoAxeViolations(container);
152
+ });
153
+ });
@@ -97,7 +97,7 @@ describe('DataTable controlled server pagination', () => {
97
97
  const onPageSizeChange = vi.fn();
98
98
  render(<DataTable {...server} onPageChange={onPageChange} onPageSizeChange={onPageSizeChange} />);
99
99
  await user.click(screen.getByRole('combobox', { name: 'Rows per page' }));
100
- await user.click(screen.getByRole('option', { name: '50' }));
100
+ await user.click(await screen.findByRole('option', { name: '50' }));
101
101
  expect(onPageSizeChange.mock.calls).toEqual([[50]]);
102
102
  expect(onPageChange.mock.calls).toEqual([[1]]);
103
103
  expect(renderedIds()).toHaveLength(20);
@@ -5,6 +5,7 @@ import { expectNoAxeViolations } from '../../test/a11y';
5
5
  import { DataTable } from './DataTable';
6
6
  import {
7
7
  compareValues,
8
+ formatCell,
8
9
  groupRows,
9
10
  paginate,
10
11
  selectionState,
@@ -142,6 +143,21 @@ describe('DataTable', () => {
142
143
  });
143
144
 
144
145
  describe('data-table-utils', () => {
146
+ it('preserves one-argument default cell values', () => {
147
+ expect(formatCell(null)).toBe('—');
148
+ expect(formatCell(undefined)).toBe('—');
149
+ expect(formatCell(true)).toBe('Yes');
150
+ expect(formatCell(false)).toBe('No');
151
+ const date = new Date(2026, 9, 17);
152
+ expect(formatCell(date)).toBe(date.toLocaleDateString());
153
+ expect(formatCell(new Date('x'))).toBe('Invalid Date');
154
+ expect(formatCell(1234.5)).toBe(1234.5);
155
+ expect(formatCell(0.30000000000000004)).toBe(0.30000000000000004);
156
+ expect(formatCell(NaN)).toBeNaN();
157
+ expect(formatCell(Infinity)).toBe(Infinity);
158
+ expect(formatCell('Text')).toBe('Text');
159
+ });
160
+
145
161
  type Row = { id: string; n: number | null };
146
162
  const cols: DataTableColumn<Row>[] = [{ id: 'n', header: 'N', accessor: (r) => r.n }];
147
163
  const rows: Row[] = [
@@ -12,6 +12,8 @@ export const meta: BlockMeta = {
12
12
  'Opt-in paginationMode="server" accepts a controlled 1-based page, pageSize and required rowCount (known total), with onPageChange/onPageSizeChange requests. Supplied rows render in order without client sorting or slicing, and headers have no sort affordance. Single selection cannot use server mode. The footer stays visible for empty results, clamps stale pages for display without callbacks, and hides during loading. Page-size changes may also request a page to keep the first visible row on screen. The consumer owns fetching and reconciles stale pages. See examples/server-pagination.tsx for an items/total/page/pageSize envelope consumer that handles both callbacks.',
13
13
 
14
14
  labels: [
15
+ { key: 'booleanTrue', type: 'string', state: 'Default cell text for a true boolean value' },
16
+ { key: 'booleanFalse', type: 'string', state: 'Default cell text for a false boolean value' },
15
17
  {
16
18
  key: 'scrollRegion',
17
19
  type: 'string',
@@ -1,5 +1,15 @@
1
1
  import { ChevronRight } from '@gntik-ai/icons';
2
- import { Checkbox, cn, MoreMenu, TableCell, TableHead, TableRow, type MoreMenuAction, useI18n } from '@gntik-ai/ui';
2
+ import {
3
+ Checkbox,
4
+ cn,
5
+ MoreMenu,
6
+ TableCell,
7
+ TableHead,
8
+ TableRow,
9
+ type MoreMenuAction,
10
+ useI18n,
11
+ useOptionalI18n,
12
+ } from '@gntik-ai/ui';
3
13
  import type { CSSProperties, ReactNode } from 'react';
4
14
  import { stickyTint, type TableLayout } from './column-sizing';
5
15
  import {
@@ -68,6 +78,7 @@ export function DataTableRow<T>({
68
78
  style,
69
79
  }: DataTableRowProps<T>) {
70
80
  const { t } = useI18n();
81
+ const locale = useOptionalI18n()?.locale;
71
82
  const id = getRowId(row);
72
83
  const selectionColumn = selectable || singleSelection != null;
73
84
  const isSelected = singleSelection ? singleSelection.selectedId === id : selected.has(id);
@@ -95,7 +106,12 @@ export function DataTableRow<T>({
95
106
  )}
96
107
  {columns.map((c) => {
97
108
  const cl = layout?.columns.get(c.id);
98
- const content = c.cell ? c.cell(row) : formatCell(c.accessor?.(row));
109
+ const content = c.cell
110
+ ? c.cell(row)
111
+ : formatCell(c.accessor?.(row), {
112
+ locale,
113
+ booleanLabels: [labels?.booleanTrue ?? t('common.yes'), labels?.booleanFalse ?? t('common.no')],
114
+ });
99
115
  const editable = onCellEdit && editHintId && isCellEditable(c, row);
100
116
  return (
101
117
  <TableCell
@@ -147,11 +147,25 @@ export function toggleOne(id: string, selected: ReadonlySet<string>): Set<string
147
147
  return next;
148
148
  }
149
149
 
150
- /** Default cell text for a raw value. */
151
- export function formatCell(value: CellValue): ReactNode {
150
+ /** Optional locale and boolean text for default cells. */
151
+ export interface DataTableCellFormatOptions {
152
+ locale?: string;
153
+ booleanLabels?: [trueLabel: string, falseLabel: string];
154
+ }
155
+
156
+ /** Default cell text for a raw value. Omitting options preserves the legacy output. */
157
+ export function formatCell(value: CellValue, options?: DataTableCellFormatOptions): ReactNode {
152
158
  if (value == null) return '—';
153
- if (value instanceof Date) return value.toLocaleDateString();
154
- if (typeof value === 'boolean') return value ? 'Yes' : 'No';
159
+ if (value instanceof Date) {
160
+ if (!options) return value.toLocaleDateString();
161
+ if (Number.isNaN(value.getTime())) return '—';
162
+ return new Intl.DateTimeFormat(options.locale, { year: 'numeric', month: 'numeric', day: 'numeric' }).format(value);
163
+ }
164
+ if (typeof value === 'boolean') return (options?.booleanLabels ?? ['Yes', 'No'])[value ? 0 : 1];
165
+ if (typeof value === 'number' && Number.isFinite(value) && options?.locale !== undefined) {
166
+ const decimal = new Intl.NumberFormat(options.locale).formatToParts(1.1).find((part) => part.type === 'decimal');
167
+ return String(value).replace('.', decimal?.value ?? '.');
168
+ }
155
169
  return value;
156
170
  }
157
171
 
@@ -2,6 +2,8 @@ import type { PaginationFooterLabels } from '../PaginationFooter/PaginationFoote
2
2
 
3
3
  /** Per-instance table chrome, including the composed PaginationFooter. Caller data stays caller-owned. */
4
4
  export interface DataTableLabels extends PaginationFooterLabels {
5
+ booleanTrue: string;
6
+ booleanFalse: string;
5
7
  /** Non-virtual table overflow region; virtualized regions keep the caller caption. */
6
8
  scrollRegion: string;
7
9
  selectionCount: (count: number) => string;
@@ -0,0 +1,26 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { I18nProvider, es } from '@gntik-ai/ui';
3
+ import { PaginationFooter } from './PaginationFooter';
4
+
5
+ it('audits every pagination label in Spanish and preserves an explicit noun', () => {
6
+ const { container, rerender } = render(
7
+ <I18nProvider locale="es">
8
+ <PaginationFooter total={20} />
9
+ </I18nProvider>,
10
+ );
11
+ expect(screen.getByText(es['table.rowsPerPage'])).toBeVisible();
12
+ expect(screen.getByRole('combobox', { name: es['table.rowsPerPage'] })).toBeVisible();
13
+ expect(screen.getByRole('navigation', { name: 'Paginación: Filas' })).toBeVisible();
14
+ expect(screen.getByRole('button', { name: es['pagination.previous'] })).toBeVisible();
15
+ expect(screen.getByRole('button', { name: es['pagination.next'] })).toBeVisible();
16
+ expect(screen.getByRole('button', { name: 'Página 1' })).toBeVisible();
17
+ expect(screen.getByRole('button', { name: 'Página 2' })).toBeVisible();
18
+ expect(container.querySelector('[aria-live]')?.textContent).toBe('1–10 de 20');
19
+ expect(container.textContent).not.toContain('{');
20
+ rerender(
21
+ <I18nProvider locale="es">
22
+ <PaginationFooter noun="Caller rows" />
23
+ </I18nProvider>,
24
+ );
25
+ expect(screen.getByRole('navigation', { name: 'Paginación: Caller rows' })).toBeVisible();
26
+ });