@primer/react 0.0.0-20260915162741 → 0.0.0-20260915185318

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.
@@ -1,14 +1,13 @@
1
1
  import { c } from "../utils/react-compiler-runtime.js";
2
2
  import { useTable } from "./useTable.js";
3
3
  import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, TableSortHeader } from "./Table.js";
4
- import { TableGroup } from "./TableGroup.js";
5
4
  import { jsx, jsxs } from "react/jsx-runtime";
6
5
  //#region src/DataTable/DataTable.tsx
7
6
  function defaultGetRowId(row) {
8
7
  return row.id;
9
8
  }
10
- function DataTableImplementation(t0) {
11
- const $ = c(28);
9
+ function DataTable(t0) {
10
+ const $ = c(27);
12
11
  const { "aria-labelledby": labelledby, "aria-describedby": describedby, cellPadding, columns, data, initialSortColumn, initialSortDirection, externalSorting, getRowId: t1, onToggleSort } = t0;
13
12
  const getRowId = t1 === void 0 ? defaultGetRowId : t1;
14
13
  let t2;
@@ -29,15 +28,13 @@ function DataTableImplementation(t0) {
29
28
  $[5] = initialSortDirection;
30
29
  $[6] = t2;
31
30
  } else t2 = $[6];
32
- const { headers, bodies, actions, gridTemplateColumns } = useTable(t2);
33
- const renderRow = _temp;
31
+ const { headers, rows, actions, gridTemplateColumns } = useTable(t2);
34
32
  let t3;
35
33
  if ($[7] !== actions || $[8] !== headers || $[9] !== onToggleSort) {
36
34
  let t4;
37
35
  if ($[11] !== actions || $[12] !== onToggleSort) {
38
36
  t4 = (header) => {
39
37
  if (header.isSortable()) return /*#__PURE__*/ jsx(TableSortHeader, {
40
- id: header.domId,
41
38
  align: header.column.align,
42
39
  direction: header.getSortDirection(),
43
40
  onToggleSort: () => {
@@ -48,7 +45,6 @@ function DataTableImplementation(t0) {
48
45
  children: typeof header.column.header === "string" ? header.column.header : header.column.header()
49
46
  }, header.id);
50
47
  return /*#__PURE__*/ jsx(TableHeader, {
51
- id: header.domId,
52
48
  align: header.column.align,
53
49
  children: typeof header.column.header === "string" ? header.column.header : header.column.header()
54
50
  }, header.id);
@@ -70,54 +66,43 @@ function DataTableImplementation(t0) {
70
66
  $[15] = t4;
71
67
  } else t4 = $[15];
72
68
  let t5;
73
- if ($[16] !== bodies || $[17] !== headers.length) {
74
- let t6;
75
- if ($[19] !== headers.length) {
76
- t6 = (body) => body.type === "row-group" ? /*#__PURE__*/ jsx(TableGroup, {
77
- id: body.id,
78
- label: body.label,
79
- rowCount: body.rows.length,
80
- colSpan: headers.length,
81
- "aria-label": body["aria-label"],
82
- children: body.rows.map(renderRow)
83
- }, body.key) : /*#__PURE__*/ jsx(TableBody, { children: body.rows.map(renderRow) }, body.key);
84
- $[19] = headers.length;
85
- $[20] = t6;
86
- } else t6 = $[20];
87
- t5 = bodies.map(t6);
88
- $[16] = bodies;
89
- $[17] = headers.length;
90
- $[18] = t5;
91
- } else t5 = $[18];
69
+ if ($[16] !== rows) {
70
+ t5 = rows.map(_temp);
71
+ $[16] = rows;
72
+ $[17] = t5;
73
+ } else t5 = $[17];
92
74
  let t6;
93
- if ($[21] !== cellPadding || $[22] !== describedby || $[23] !== gridTemplateColumns || $[24] !== labelledby || $[25] !== t4 || $[26] !== t5) {
94
- t6 = /*#__PURE__*/ jsxs(Table, {
75
+ if ($[18] !== t5) {
76
+ t6 = /*#__PURE__*/ jsx(TableBody, { children: t5 });
77
+ $[18] = t5;
78
+ $[19] = t6;
79
+ } else t6 = $[19];
80
+ let t7;
81
+ if ($[20] !== cellPadding || $[21] !== describedby || $[22] !== gridTemplateColumns || $[23] !== labelledby || $[24] !== t4 || $[25] !== t6) {
82
+ t7 = /*#__PURE__*/ jsxs(Table, {
95
83
  "aria-labelledby": labelledby,
96
84
  "aria-describedby": describedby,
97
85
  cellPadding,
98
86
  gridTemplateColumns,
99
- children: [t4, t5]
87
+ children: [t4, t6]
100
88
  });
101
- $[21] = cellPadding;
102
- $[22] = describedby;
103
- $[23] = gridTemplateColumns;
104
- $[24] = labelledby;
105
- $[25] = t4;
106
- $[26] = t5;
107
- $[27] = t6;
108
- } else t6 = $[27];
109
- return t6;
89
+ $[20] = cellPadding;
90
+ $[21] = describedby;
91
+ $[22] = gridTemplateColumns;
92
+ $[23] = labelledby;
93
+ $[24] = t4;
94
+ $[25] = t6;
95
+ $[26] = t7;
96
+ } else t7 = $[26];
97
+ return t7;
110
98
  }
111
99
  function _temp(row) {
112
100
  return /*#__PURE__*/ jsx(TableRow, { children: row.getCells().map((cell) => /*#__PURE__*/ jsx(TableCell, {
113
- id: cell.domId,
114
101
  scope: cell.rowHeader ? "row" : void 0,
115
102
  align: cell.column.align,
116
- headers: cell.headers,
117
103
  children: cell.column.renderCell ? cell.column.renderCell(row.getValue()) : cell.getValue()
118
104
  }, cell.id)) }, row.id);
119
105
  }
120
106
  _temp.displayName = "_temp";
121
- const DataTable = DataTableImplementation;
122
107
  //#endregion
123
108
  export { DataTable };
@@ -8,9 +8,10 @@ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
8
  import { clsx } from "clsx";
9
9
  //#region src/DataTable/TableGroup.tsx
10
10
  function TableGroup(t0) {
11
- const $ = c(38);
11
+ const $ = c(37);
12
12
  const { className, id, label, rowCount, colSpan, children, "aria-label": ariaLabel } = t0;
13
13
  const headerId = useId();
14
+ const accessibleName = `${label}, ${rowCount} ${rowCount === 1 ? "row" : "rows"}`;
14
15
  let t1;
15
16
  if ($[0] !== headerId) {
16
17
  t1 = { headerId };
@@ -30,65 +31,59 @@ function TableGroup(t0) {
30
31
  $[4] = t3;
31
32
  } else t3 = $[4];
32
33
  let t4;
34
+ if ($[5] !== accessibleName) {
35
+ t4 = /*#__PURE__*/ jsx(VisuallyHidden, { children: accessibleName });
36
+ $[5] = accessibleName;
37
+ $[6] = t4;
38
+ } else t4 = $[6];
33
39
  let t5;
34
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
35
- t4 = clsx("TableGroupHeaderContent", Table_module_css_default.TableGroupHeaderContent);
36
- t5 = clsx("TableGroupHeaderLabel", Table_module_css_default.TableGroupHeaderLabel);
37
- $[5] = t4;
38
- $[6] = t5;
39
- } else {
40
- t4 = $[5];
41
- t5 = $[6];
42
- }
43
40
  let t6;
44
41
  if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
45
- t6 = /*#__PURE__*/ jsx(VisuallyHidden, { children: "," });
46
- $[7] = t6;
47
- } else t6 = $[7];
42
+ t5 = clsx("TableGroupHeaderContent", Table_module_css_default.TableGroupHeaderContent);
43
+ t6 = clsx("TableGroupHeaderLabel", Table_module_css_default.TableGroupHeaderLabel);
44
+ $[7] = t5;
45
+ $[8] = t6;
46
+ } else {
47
+ t5 = $[7];
48
+ t6 = $[8];
49
+ }
48
50
  let t7;
49
- if ($[8] !== label) {
50
- t7 = /*#__PURE__*/ jsxs("span", {
51
- className: t5,
52
- children: [label, t6]
51
+ if ($[9] !== label) {
52
+ t7 = /*#__PURE__*/ jsx("span", {
53
+ className: t6,
54
+ children: label
53
55
  });
54
- $[8] = label;
55
- $[9] = t7;
56
- } else t7 = $[9];
56
+ $[9] = label;
57
+ $[10] = t7;
58
+ } else t7 = $[10];
57
59
  let t8;
58
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
60
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
59
61
  t8 = clsx("TableGroupHeaderCount", Table_module_css_default.TableGroupHeaderCount);
60
- $[10] = t8;
61
- } else t8 = $[10];
62
- const t9 = rowCount === 1 ? " row" : " rows";
63
- let t10;
64
- if ($[11] !== t9) {
65
- t10 = /*#__PURE__*/ jsx(VisuallyHidden, { children: t9 });
66
- $[11] = t9;
67
- $[12] = t10;
68
- } else t10 = $[12];
69
- let t11;
70
- if ($[13] !== rowCount || $[14] !== t10) {
71
- t11 = /*#__PURE__*/ jsxs("span", {
62
+ $[11] = t8;
63
+ } else t8 = $[11];
64
+ let t9;
65
+ if ($[12] !== rowCount) {
66
+ t9 = /*#__PURE__*/ jsx("span", {
72
67
  className: t8,
73
- children: [rowCount, t10]
68
+ children: rowCount
74
69
  });
75
- $[13] = rowCount;
76
- $[14] = t10;
77
- $[15] = t11;
78
- } else t11 = $[15];
79
- let t12;
80
- if ($[16] !== t11 || $[17] !== t7) {
81
- t12 = /*#__PURE__*/ jsxs("span", {
82
- className: t4,
83
- children: [t7, t11]
70
+ $[12] = rowCount;
71
+ $[13] = t9;
72
+ } else t9 = $[13];
73
+ let t10;
74
+ if ($[14] !== t7 || $[15] !== t9) {
75
+ t10 = /*#__PURE__*/ jsxs("span", {
76
+ "aria-hidden": "true",
77
+ className: t5,
78
+ children: [t7, t9]
84
79
  });
85
- $[16] = t11;
86
- $[17] = t7;
87
- $[18] = t12;
88
- } else t12 = $[18];
89
- let t13;
90
- if ($[19] !== ariaLabel || $[20] !== colSpan || $[21] !== headerId || $[22] !== t12) {
91
- t13 = /*#__PURE__*/ jsx(TableRow, { children: /*#__PURE__*/ jsx("th", {
80
+ $[14] = t7;
81
+ $[15] = t9;
82
+ $[16] = t10;
83
+ } else t10 = $[16];
84
+ let t11;
85
+ if ($[17] !== ariaLabel || $[18] !== colSpan || $[19] !== headerId || $[20] !== t10 || $[21] !== t4) {
86
+ t11 = /*#__PURE__*/ jsx(TableRow, { children: /*#__PURE__*/ jsxs("th", {
92
87
  id: headerId,
93
88
  className: t3,
94
89
  scope: "colgroup",
@@ -96,64 +91,65 @@ function TableGroup(t0) {
96
91
  role: "columnheader",
97
92
  "aria-label": ariaLabel,
98
93
  "data-component": "Table.Group.Header",
99
- children: t12
94
+ children: [t4, t10]
100
95
  }) });
101
- $[19] = ariaLabel;
102
- $[20] = colSpan;
103
- $[21] = headerId;
104
- $[22] = t12;
105
- $[23] = t13;
106
- } else t13 = $[23];
107
- let t14;
108
- if ($[24] !== id || $[25] !== t13 || $[26] !== t2) {
109
- t14 = /*#__PURE__*/ jsx("tbody", {
96
+ $[17] = ariaLabel;
97
+ $[18] = colSpan;
98
+ $[19] = headerId;
99
+ $[20] = t10;
100
+ $[21] = t4;
101
+ $[22] = t11;
102
+ } else t11 = $[22];
103
+ let t12;
104
+ if ($[23] !== id || $[24] !== t11 || $[25] !== t2) {
105
+ t12 = /*#__PURE__*/ jsx("tbody", {
110
106
  className: t2,
111
107
  role: "rowgroup",
112
108
  "data-component": "Table.Group",
113
109
  "data-group-id": id,
114
- children: t13
110
+ children: t11
115
111
  });
116
- $[24] = id;
117
- $[25] = t13;
118
- $[26] = t2;
119
- $[27] = t14;
120
- } else t14 = $[27];
121
- let t15;
122
- if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
123
- t15 = clsx("TableBody", Table_module_css_default.TableBody);
124
- $[28] = t15;
125
- } else t15 = $[28];
126
- let t16;
127
- if ($[29] !== children || $[30] !== contextValue) {
128
- t16 = /*#__PURE__*/ jsx(TableGroupContext.Provider, {
112
+ $[23] = id;
113
+ $[24] = t11;
114
+ $[25] = t2;
115
+ $[26] = t12;
116
+ } else t12 = $[26];
117
+ let t13;
118
+ if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
119
+ t13 = clsx("TableBody", Table_module_css_default.TableBody);
120
+ $[27] = t13;
121
+ } else t13 = $[27];
122
+ let t14;
123
+ if ($[28] !== children || $[29] !== contextValue) {
124
+ t14 = /*#__PURE__*/ jsx(TableGroupContext.Provider, {
129
125
  value: contextValue,
130
126
  children
131
127
  });
132
- $[29] = children;
133
- $[30] = contextValue;
134
- $[31] = t16;
135
- } else t16 = $[31];
136
- let t17;
137
- if ($[32] !== id || $[33] !== t16) {
138
- t17 = /*#__PURE__*/ jsx("tbody", {
139
- className: t15,
128
+ $[28] = children;
129
+ $[29] = contextValue;
130
+ $[30] = t14;
131
+ } else t14 = $[30];
132
+ let t15;
133
+ if ($[31] !== id || $[32] !== t14) {
134
+ t15 = /*#__PURE__*/ jsx("tbody", {
135
+ className: t13,
140
136
  role: "rowgroup",
141
137
  "data-component": "Table.Group.Body",
142
138
  "data-group-id": id,
143
- children: t16
139
+ children: t14
144
140
  });
145
- $[32] = id;
146
- $[33] = t16;
147
- $[34] = t17;
148
- } else t17 = $[34];
149
- let t18;
150
- if ($[35] !== t14 || $[36] !== t17) {
151
- t18 = /*#__PURE__*/ jsxs(Fragment$1, { children: [t14, t17] });
152
- $[35] = t14;
153
- $[36] = t17;
154
- $[37] = t18;
155
- } else t18 = $[37];
156
- return t18;
141
+ $[31] = id;
142
+ $[32] = t14;
143
+ $[33] = t15;
144
+ } else t15 = $[33];
145
+ let t16;
146
+ if ($[34] !== t12 || $[35] !== t15) {
147
+ t16 = /*#__PURE__*/ jsxs(Fragment$1, { children: [t12, t15] });
148
+ $[34] = t12;
149
+ $[35] = t15;
150
+ $[36] = t16;
151
+ } else t16 = $[36];
152
+ return t16;
157
153
  }
158
154
  //#endregion
159
155
  export { TableGroup };
@@ -1,6 +1,6 @@
1
1
  import { SlotMarker } from "../utils/types/Slots.js";
2
2
  import { ObjectPaths } from "./utils.js";
3
- import { DataTableData, DataTableRowGroup, UniqueRow } from "./row.js";
3
+ import { UniqueRow } from "./row.js";
4
4
  import { CellAlignment, Column, ColumnWidth, createColumnHelper } from "./column.js";
5
5
  import { DataTable, DataTableProps } from "./DataTable.js";
6
6
  import { ErrorDialog } from "./ErrorDialog.js";
@@ -27,4 +27,4 @@ declare const Table: typeof Table$1 & SlotMarker & {
27
27
  ErrorDialog: typeof ErrorDialog;
28
28
  };
29
29
  //#endregion
30
- export { type CellAlignment, type Column, type ColumnWidth, DataTable, type DataTableData, type DataTableProps, type DataTableRowGroup, type ObjectPaths, Table, type TableActionsProps, type TableBodyProps, type TableCellProps, type TableContainerProps, type TableGroupProps, type TableHeadProps, type TableHeaderProps, type TableProps, type TableRowProps, type TableSubtitleProps, type TableTitleProps, type UniqueRow, createColumnHelper };
30
+ export { type CellAlignment, type Column, type ColumnWidth, DataTable, type DataTableProps, type ObjectPaths, Table, type TableActionsProps, type TableBodyProps, type TableCellProps, type TableContainerProps, type TableGroupProps, type TableHeadProps, type TableHeaderProps, type TableProps, type TableRowProps, type TableSubtitleProps, type TableTitleProps, type UniqueRow, createColumnHelper };
@@ -1,7 +1,7 @@
1
1
  import { Table as Table$1, TableActions, TableBody, TableCell, TableCellPlaceholder, TableContainer, TableDivider, TableHead, TableHeader, TableRow, TableSkeleton, TableSubtitle, TableTitle } from "./Table.js";
2
- import { TableGroup } from "./TableGroup.js";
3
2
  import { DataTable } from "./DataTable.js";
4
3
  import { ErrorDialog } from "./ErrorDialog.js";
4
+ import { TableGroup } from "./TableGroup.js";
5
5
  import { Pagination } from "./Pagination.js";
6
6
  import { createColumnHelper } from "./column.js";
7
7
  //#region src/DataTable/index.ts
@@ -2,28 +2,5 @@
2
2
  interface UniqueRow {
3
3
  id: string | number;
4
4
  }
5
- interface DataTableRowGroup<Data extends UniqueRow> {
6
- /**
7
- * Provide a stable identifier for the group.
8
- */
9
- groupId: string | number;
10
- /**
11
- * Provide a visible label for the group.
12
- */
13
- label: string;
14
- /**
15
- * Provide the rows that belong to the group.
16
- */
17
- rows: Array<Data>;
18
- /**
19
- * Provide an accessible name for the group header.
20
- */
21
- 'aria-label'?: string;
22
- }
23
- /**
24
- * Items with both `groupId` and an array-valued `rows` are treated as groups.
25
- * This combination is reserved and must not be used for standalone row data.
26
- */
27
- type DataTableData<Data extends UniqueRow> = Array<Data | DataTableRowGroup<Data>>;
28
5
  //#endregion
29
- export { DataTableData, DataTableRowGroup, UniqueRow };
6
+ export { UniqueRow };