@primer/react 38.39.1-rc.99036c1d8 → 38.40.0-rc.37bd8a025

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.
@@ -8,10 +8,9 @@ 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(37);
11
+ const $ = c(38);
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"}`;
15
14
  let t1;
16
15
  if ($[0] !== headerId) {
17
16
  t1 = { headerId };
@@ -31,59 +30,65 @@ function TableGroup(t0) {
31
30
  $[4] = t3;
32
31
  } else t3 = $[4];
33
32
  let t4;
34
- if ($[5] !== accessibleName) {
35
- t4 = /*#__PURE__*/ jsx(VisuallyHidden, { children: accessibleName });
36
- $[5] = accessibleName;
37
- $[6] = t4;
38
- } else t4 = $[6];
39
33
  let t5;
40
- let t6;
41
- if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
42
- t5 = clsx("TableGroupHeaderContent", Table_module_css_default.TableGroupHeaderContent);
43
- t6 = clsx("TableGroupHeaderLabel", Table_module_css_default.TableGroupHeaderLabel);
44
- $[7] = t5;
45
- $[8] = t6;
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;
46
39
  } else {
47
- t5 = $[7];
48
- t6 = $[8];
40
+ t4 = $[5];
41
+ t5 = $[6];
49
42
  }
43
+ let t6;
44
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
45
+ t6 = /*#__PURE__*/ jsx(VisuallyHidden, { children: "," });
46
+ $[7] = t6;
47
+ } else t6 = $[7];
50
48
  let t7;
51
- if ($[9] !== label) {
52
- t7 = /*#__PURE__*/ jsx("span", {
53
- className: t6,
54
- children: label
49
+ if ($[8] !== label) {
50
+ t7 = /*#__PURE__*/ jsxs("span", {
51
+ className: t5,
52
+ children: [label, t6]
55
53
  });
56
- $[9] = label;
57
- $[10] = t7;
58
- } else t7 = $[10];
54
+ $[8] = label;
55
+ $[9] = t7;
56
+ } else t7 = $[9];
59
57
  let t8;
60
- if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
58
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
61
59
  t8 = clsx("TableGroupHeaderCount", Table_module_css_default.TableGroupHeaderCount);
62
- $[11] = t8;
63
- } else t8 = $[11];
64
- let t9;
65
- if ($[12] !== rowCount) {
66
- t9 = /*#__PURE__*/ jsx("span", {
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", {
67
72
  className: t8,
68
- children: rowCount
73
+ children: [rowCount, t10]
69
74
  });
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]
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]
79
84
  });
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", {
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", {
87
92
  id: headerId,
88
93
  className: t3,
89
94
  scope: "colgroup",
@@ -91,65 +96,64 @@ function TableGroup(t0) {
91
96
  role: "columnheader",
92
97
  "aria-label": ariaLabel,
93
98
  "data-component": "Table.Group.Header",
94
- children: [t4, t10]
99
+ children: t12
95
100
  }) });
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", {
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", {
106
110
  className: t2,
107
111
  role: "rowgroup",
108
112
  "data-component": "Table.Group",
109
113
  "data-group-id": id,
110
- children: t11
114
+ children: t13
111
115
  });
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, {
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, {
125
129
  value: contextValue,
126
130
  children
127
131
  });
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,
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,
136
140
  role: "rowgroup",
137
141
  "data-component": "Table.Group.Body",
138
142
  "data-group-id": id,
139
- children: t14
143
+ children: t16
140
144
  });
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;
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;
153
157
  }
154
158
  //#endregion
155
159
  export { TableGroup };
@@ -1,6 +1,6 @@
1
1
  import { SlotMarker } from "../utils/types/Slots.js";
2
2
  import { ObjectPaths } from "./utils.js";
3
- import { UniqueRow } from "./row.js";
3
+ import { DataTableData, DataTableRowGroup, 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 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 };
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 };
@@ -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";
2
3
  import { DataTable } from "./DataTable.js";
3
4
  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,5 +2,28 @@
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>>;
5
28
  //#endregion
6
- export { UniqueRow };
29
+ export { DataTableData, DataTableRowGroup, UniqueRow };
@@ -1,10 +1,11 @@
1
1
  import { c } from "../utils/react-compiler-runtime.js";
2
2
  import { DEFAULT_SORT_DIRECTION, SortDirection, strategies, transition } from "./sorting.js";
3
- import { useState } from "react";
3
+ import { useId, useState } from "react";
4
4
  //#region src/DataTable/useTable.ts
5
5
  function useTable(t0) {
6
- const $ = c(21);
6
+ const $ = c(29);
7
7
  const { columns, data, initialSortColumn, initialSortDirection, externalSorting, getRowId } = t0;
8
+ const tableId = useId();
8
9
  const [rowOrder, setRowOrder] = useState(data);
9
10
  const [prevData, setPrevData] = useState(data);
10
11
  const [prevColumns, setPrevColumns] = useState(columns);
@@ -29,18 +30,26 @@ function useTable(t0) {
29
30
  }
30
31
  }
31
32
  let t2;
32
- let t3;
33
- let t4;
34
- if ($[4] !== columns || $[5] !== data || $[6] !== externalSorting || $[7] !== getRowId || $[8] !== prevData || $[9] !== rowOrder || $[10] !== sortByColumn) {
35
- let t5;
36
- if ($[14] !== sortByColumn) {
37
- t5 = (column_1) => {
33
+ if ($[4] !== rowOrder) {
34
+ t2 = rowOrder.some(isDataTableRowGroup);
35
+ $[4] = rowOrder;
36
+ $[5] = t2;
37
+ } else t2 = $[5];
38
+ const hasGroups = t2;
39
+ let bodies;
40
+ let headers;
41
+ let sortBy;
42
+ if ($[6] !== columns || $[7] !== data || $[8] !== externalSorting || $[9] !== getRowId || $[10] !== hasGroups || $[11] !== prevData || $[12] !== rowOrder || $[13] !== sortByColumn || $[14] !== tableId) {
43
+ let t3;
44
+ if ($[18] !== hasGroups || $[19] !== sortByColumn || $[20] !== tableId) {
45
+ t3 = (column_1, index) => {
38
46
  var _column_1$id;
39
47
  const id_0 = (_column_1$id = column_1.id) !== null && _column_1$id !== void 0 ? _column_1$id : column_1.field;
40
48
  if (id_0 === void 0) throw new Error("Expected either an `id` or `field` to be defined for a Column");
41
49
  const sortable = column_1.sortBy !== void 0 && column_1.sortBy !== false;
42
50
  return {
43
51
  id: id_0,
52
+ domId: hasGroups ? `${tableId}-column-${index}` : void 0,
44
53
  column: column_1,
45
54
  isSortable() {
46
55
  return sortable;
@@ -51,103 +60,171 @@ function useTable(t0) {
51
60
  }
52
61
  };
53
62
  };
54
- $[14] = sortByColumn;
55
- $[15] = t5;
56
- } else t5 = $[15];
57
- const headers = columns.map(t5);
63
+ $[18] = hasGroups;
64
+ $[19] = sortByColumn;
65
+ $[20] = tableId;
66
+ $[21] = t3;
67
+ } else t3 = $[21];
68
+ headers = columns.map(t3);
58
69
  if (data !== prevData) {
59
70
  setPrevData(data);
60
- setRowOrder(data);
61
- if (sortByColumn) sortRows(sortByColumn);
71
+ updateRowOrder(data, sortByColumn);
62
72
  }
63
- const sortBy = function sortBy(header) {
73
+ sortBy = function sortBy(header) {
64
74
  const sortState = {
65
75
  id: header.id,
66
76
  direction: sortByColumn && sortByColumn.id === header.id ? transition(sortByColumn.direction) : DEFAULT_SORT_DIRECTION
67
77
  };
68
78
  setSortByColumn(sortState);
69
- sortRows(sortState);
79
+ updateRowOrder(rowOrder, sortState);
70
80
  };
71
- function sortRows(state) {
72
- const header_1 = headers.find((header_0) => header_0.id === state.id);
73
- if (!header_1) throw new Error(`Unable to find header with id: ${state.id}`);
81
+ function updateRowOrder(rows, state) {
82
+ if (externalSorting || state === null) setRowOrder(rows);
83
+ else {
84
+ const sortedRows = getSortedRowOrder(rows, state);
85
+ setRowOrder(sortedRows);
86
+ }
87
+ }
88
+ function getSortedRowOrder(currentRowOrder, state_0) {
89
+ const header_1 = headers.find((header_0) => header_0.id === state_0.id);
90
+ if (!header_1) throw new Error(`Unable to find header with id: ${state_0.id}`);
74
91
  if (header_1.column.sortBy === false || header_1.column.sortBy === void 0) throw new Error("The column for this header is not sortable");
75
- if (externalSorting) return;
76
- const sortMethod = header_1.column.sortBy === true ? strategies.basic : typeof header_1.column.sortBy === "string" ? strategies[header_1.column.sortBy] : header_1.column.sortBy;
77
- setRowOrder((rowOrder_0) => rowOrder_0.slice().sort((a, b) => {
78
- if (header_1.column.field === void 0) return 0;
79
- if (typeof header_1.column.sortBy === "function") {
80
- if (state.direction === SortDirection.ASC) return sortMethod(a, b);
81
- return sortMethod(b, a);
82
- }
83
- const valueA = get(a, header_1.column.field);
84
- const valueB = get(b, header_1.column.field);
85
- const valueAIsBlank = isBlankValue(valueA);
86
- const valueBIsBlank = isBlankValue(valueB);
87
- if (!valueAIsBlank && !valueBIsBlank) {
88
- if (state.direction === SortDirection.ASC) return sortMethod(valueA, valueB);
89
- return sortMethod(valueB, valueA);
90
- }
91
- if (!valueAIsBlank) return -1;
92
- if (!valueBIsBlank) return 1;
93
- return 0;
94
- }));
92
+ const column_2 = header_1.column;
93
+ const sortMethod = column_2.sortBy === true ? strategies.basic : typeof column_2.sortBy === "string" ? strategies[column_2.sortBy] : column_2.sortBy;
94
+ const sortData = function sortData(rows_0) {
95
+ return rows_0.slice().sort((a, b) => {
96
+ if (column_2.field === void 0) return 0;
97
+ if (typeof column_2.sortBy === "function") {
98
+ if (state_0.direction === SortDirection.ASC) return sortMethod(a, b);
99
+ return sortMethod(b, a);
100
+ }
101
+ const valueA = get(a, column_2.field);
102
+ const valueB = get(b, column_2.field);
103
+ const valueAIsBlank = isBlankValue(valueA);
104
+ const valueBIsBlank = isBlankValue(valueB);
105
+ if (!valueAIsBlank && !valueBIsBlank) {
106
+ if (state_0.direction === SortDirection.ASC) return sortMethod(valueA, valueB);
107
+ return sortMethod(valueB, valueA);
108
+ }
109
+ if (!valueAIsBlank) return -1;
110
+ if (!valueBIsBlank) return 1;
111
+ return 0;
112
+ });
113
+ };
114
+ const sorted = [];
115
+ let ungroupedRows = [];
116
+ const appendUngroupedRows = function appendUngroupedRows() {
117
+ for (const row of sortData(ungroupedRows)) sorted.push(row);
118
+ ungroupedRows = [];
119
+ };
120
+ for (const item of currentRowOrder) if (isDataTableRowGroup(item)) {
121
+ appendUngroupedRows();
122
+ sorted.push({
123
+ ...item,
124
+ rows: sortData(item.rows)
125
+ });
126
+ } else ungroupedRows.push(item);
127
+ appendUngroupedRows();
128
+ return sorted;
95
129
  }
96
- t2 = headers;
97
- t3 = rowOrder.map((row) => {
98
- const rowId = getRowId(row);
130
+ const createRow = function createRow(row_0, rowIndex) {
131
+ const rowId = getRowId(row_0);
132
+ const rowHeaderIds = hasGroups ? headers.flatMap((header_2, index_0) => header_2.column.rowHeader ? [`${tableId}-row-${rowIndex}-header-${index_0}`] : []) : [];
99
133
  return {
134
+ type: "row",
100
135
  id: `${rowId}`,
101
136
  getValue() {
102
- return row;
137
+ return row_0;
103
138
  },
104
139
  getCells() {
105
- return headers.map((header_2) => {
106
- var _header_2$column$rowH;
140
+ return headers.map((header_3, index_1) => {
141
+ var _header_3$column$rowH;
142
+ const rowHeader = (_header_3$column$rowH = header_3.column.rowHeader) !== null && _header_3$column$rowH !== void 0 ? _header_3$column$rowH : false;
107
143
  return {
108
- id: `${rowId}:${header_2.id}`,
109
- column: header_2.column,
110
- rowHeader: (_header_2$column$rowH = header_2.column.rowHeader) !== null && _header_2$column$rowH !== void 0 ? _header_2$column$rowH : false,
144
+ id: `${rowId}:${header_3.id}`,
145
+ domId: hasGroups && rowHeader ? `${tableId}-row-${rowIndex}-header-${index_1}` : void 0,
146
+ headers: hasGroups ? (rowHeader ? [header_3.domId] : [...rowHeaderIds, header_3.domId]).join(" ") : void 0,
147
+ column: header_3.column,
148
+ rowHeader,
111
149
  getValue() {
112
- if (header_2.column.field !== void 0) return get(row, header_2.column.field);
113
- throw new Error(`Unable to get value for column header ${header_2.id}`);
150
+ if (header_3.column.field !== void 0) return get(row_0, header_3.column.field);
151
+ throw new Error(`Unable to get value for column header ${header_3.id}`);
114
152
  }
115
153
  };
116
154
  });
117
155
  }
118
156
  };
119
- });
120
- t4 = { sortBy };
121
- $[4] = columns;
122
- $[5] = data;
123
- $[6] = externalSorting;
124
- $[7] = getRowId;
125
- $[8] = prevData;
126
- $[9] = rowOrder;
127
- $[10] = sortByColumn;
128
- $[11] = t2;
129
- $[12] = t3;
130
- $[13] = t4;
157
+ };
158
+ bodies = [];
159
+ let rowIndex_0 = 0;
160
+ let body = {
161
+ type: "row-body",
162
+ key: "rows:start",
163
+ rows: []
164
+ };
165
+ for (const item_0 of rowOrder) if (isDataTableRowGroup(item_0)) {
166
+ if (body.rows.length > 0) bodies.push(body);
167
+ const groupStartIndex = rowIndex_0;
168
+ bodies.push({
169
+ type: "row-group",
170
+ key: `group:${item_0.groupId}`,
171
+ id: item_0.groupId,
172
+ label: item_0.label,
173
+ rows: item_0.rows.map((row_1, index_2) => createRow(row_1, groupStartIndex + index_2)),
174
+ "aria-label": item_0["aria-label"]
175
+ });
176
+ rowIndex_0 = rowIndex_0 + item_0.rows.length;
177
+ body = {
178
+ type: "row-body",
179
+ key: `rows:after:${item_0.groupId}`,
180
+ rows: []
181
+ };
182
+ } else {
183
+ body.rows.push(createRow(item_0, rowIndex_0));
184
+ rowIndex_0 = rowIndex_0 + 1;
185
+ }
186
+ if (body.rows.length > 0 || bodies.length === 0) bodies.push(body);
187
+ $[6] = columns;
188
+ $[7] = data;
189
+ $[8] = externalSorting;
190
+ $[9] = getRowId;
191
+ $[10] = hasGroups;
192
+ $[11] = prevData;
193
+ $[12] = rowOrder;
194
+ $[13] = sortByColumn;
195
+ $[14] = tableId;
196
+ $[15] = bodies;
197
+ $[16] = headers;
198
+ $[17] = sortBy;
131
199
  } else {
132
- t2 = $[11];
133
- t3 = $[12];
134
- t4 = $[13];
200
+ bodies = $[15];
201
+ headers = $[16];
202
+ sortBy = $[17];
135
203
  }
136
- let t5;
137
- if ($[16] !== gridTemplateColumns || $[17] !== t2 || $[18] !== t3 || $[19] !== t4) {
138
- t5 = {
139
- headers: t2,
140
- rows: t3,
141
- actions: t4,
142
- gridTemplateColumns
204
+ let t3;
205
+ if ($[22] !== sortBy) {
206
+ t3 = { sortBy };
207
+ $[22] = sortBy;
208
+ $[23] = t3;
209
+ } else t3 = $[23];
210
+ let t4;
211
+ if ($[24] !== bodies || $[25] !== gridTemplateColumns || $[26] !== headers || $[27] !== t3) {
212
+ t4 = {
213
+ headers,
214
+ actions: t3,
215
+ gridTemplateColumns,
216
+ bodies
143
217
  };
144
- $[16] = gridTemplateColumns;
145
- $[17] = t2;
146
- $[18] = t3;
147
- $[19] = t4;
148
- $[20] = t5;
149
- } else t5 = $[20];
150
- return t5;
218
+ $[24] = bodies;
219
+ $[25] = gridTemplateColumns;
220
+ $[26] = headers;
221
+ $[27] = t3;
222
+ $[28] = t4;
223
+ } else t4 = $[28];
224
+ return t4;
225
+ }
226
+ function isDataTableRowGroup(item) {
227
+ return "groupId" in item && "rows" in item && Array.isArray(item.rows);
151
228
  }
152
229
  function getInitialSortState(columns, initialSortColumn, initialSortDirection) {
153
230
  if (initialSortColumn !== void 0) {
@@ -1,4 +1,5 @@
1
1
  //#region src/DataTable/utils.d.ts
2
+ type IsAny<T> = 0 extends 1 & T ? true : false;
2
3
  type ArrayOfLength<Length extends number, SizedArray extends Array<unknown> = []> = SizedArray['length'] extends Length ? SizedArray : ArrayOfLength<Length, [...SizedArray, SizedArray['length']]>;
3
4
  type MaxLength = ArrayOfLength<10>[number];
4
5
  type ArrayIndex<A extends ReadonlyArray<any>, Keys extends number = never> = A extends readonly [] ? Keys : A extends readonly [infer _, ...infer Tail] ? ArrayIndex<Tail, Keys | Tail['length']> : Keys;
@@ -6,6 +7,7 @@ type ArrayWithinBounds<T> = T extends ReadonlyArray<any> & {
6
7
  length: infer Length;
7
8
  } ? Length extends MaxLength ? T : never : never;
8
9
  type ObjectPaths<T> = T extends readonly any[] & ArrayWithinBounds<T> ? `${ArrayIndex<T>}` | PrefixPath<T, ArrayIndex<T>> : T extends any[] ? never & 'Unable to determine keys of potentially boundless array' : T extends Date ? never : T extends object ? Extract<keyof T, string | number> | PrefixPath<T, Extract<keyof T, string | number>> : never;
9
- type PrefixPath<T, Prefix> = Prefix extends Extract<keyof T, number | string> ? `${Prefix}.${ObjectPaths<T[Prefix]>}` : never;
10
+ type PrefixPath<T, Prefix> = Prefix extends Extract<keyof T, number | string> ? `${Prefix}.${NestedObjectPaths<T[Prefix]>}` : never;
11
+ type NestedObjectPaths<T> = IsAny<T> extends true ? string : ObjectPaths<T>;
10
12
  //#endregion
11
- export { ObjectPaths };
13
+ export { IsAny, ObjectPaths };
@@ -12,7 +12,8 @@ import { Icon } from "@primer/octicons-react";
12
12
  //#region src/NavList/NavList.d.ts
13
13
  type NavListHeadingLevels = 'h2' | 'h3';
14
14
  type NavListProps = {
15
- children: React.ReactNode;
15
+ children: React.ReactNode; /** Disable the gap between items when the item gap feature is enabled. */
16
+ disableItemGap?: boolean;
16
17
  } & React.ComponentProps<'nav'>;
17
18
  type NavListHeadingProps = {
18
19
  /** Semantic heading level for the NavList. Also sets the default level for child group headings, which render one level deeper. */as?: NavListHeadingLevels; /** Visually hide the heading while keeping it available to assistive technology. */