@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.
- package/CHANGELOG.md +11 -1
- package/dist/ActionList/List.js +83 -79
- package/dist/ActionList/index.d.ts +1 -0
- package/dist/ActionList/shared.d.ts +4 -0
- package/dist/DataTable/DataTable.d.ts +20 -20
- package/dist/DataTable/DataTable.js +41 -26
- package/dist/DataTable/TableGroup.js +95 -91
- package/dist/DataTable/index.d.ts +2 -2
- package/dist/DataTable/index.js +1 -1
- package/dist/DataTable/row.d.ts +24 -1
- package/dist/DataTable/useTable.js +156 -79
- package/dist/DataTable/utils.d.ts +4 -2
- package/dist/NavList/NavList.d.ts +2 -1
- package/dist/NavList/NavList.js +45 -38
- package/dist/TooltipV2/Tooltip.js +17 -7
- package/dist/experimental/index.d.ts +2 -2
- package/generated/components.json +27 -3
- package/package.json +1 -1
|
@@ -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(
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
t5 = clsx("
|
|
43
|
-
|
|
44
|
-
$[
|
|
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
|
-
|
|
48
|
-
|
|
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 ($[
|
|
52
|
-
t7 = /*#__PURE__*/
|
|
53
|
-
className:
|
|
54
|
-
children: label
|
|
49
|
+
if ($[8] !== label) {
|
|
50
|
+
t7 = /*#__PURE__*/ jsxs("span", {
|
|
51
|
+
className: t5,
|
|
52
|
+
children: [label, t6]
|
|
55
53
|
});
|
|
56
|
-
$[
|
|
57
|
-
$[
|
|
58
|
-
} else t7 = $[
|
|
54
|
+
$[8] = label;
|
|
55
|
+
$[9] = t7;
|
|
56
|
+
} else t7 = $[9];
|
|
59
57
|
let t8;
|
|
60
|
-
if ($[
|
|
58
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
61
59
|
t8 = clsx("TableGroupHeaderCount", Table_module_css_default.TableGroupHeaderCount);
|
|
62
|
-
$[
|
|
63
|
-
} else t8 = $[
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
$[
|
|
71
|
-
$[
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
className:
|
|
78
|
-
children: [t7,
|
|
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
|
-
$[
|
|
81
|
-
$[
|
|
82
|
-
$[
|
|
83
|
-
} else
|
|
84
|
-
let
|
|
85
|
-
if ($[
|
|
86
|
-
|
|
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:
|
|
99
|
+
children: t12
|
|
95
100
|
}) });
|
|
96
|
-
$[
|
|
97
|
-
$[
|
|
98
|
-
$[
|
|
99
|
-
$[
|
|
100
|
-
$[
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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:
|
|
114
|
+
children: t13
|
|
111
115
|
});
|
|
112
|
-
$[
|
|
113
|
-
$[
|
|
114
|
-
$[
|
|
115
|
-
$[
|
|
116
|
-
} else
|
|
117
|
-
let
|
|
118
|
-
if ($[
|
|
119
|
-
|
|
120
|
-
$[
|
|
121
|
-
} else
|
|
122
|
-
let
|
|
123
|
-
if ($[
|
|
124
|
-
|
|
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
|
-
$[
|
|
129
|
-
$[
|
|
130
|
-
$[
|
|
131
|
-
} else
|
|
132
|
-
let
|
|
133
|
-
if ($[
|
|
134
|
-
|
|
135
|
-
className:
|
|
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:
|
|
143
|
+
children: t16
|
|
140
144
|
});
|
|
141
|
-
$[
|
|
142
|
-
$[
|
|
143
|
-
$[
|
|
144
|
-
} else
|
|
145
|
-
let
|
|
146
|
-
if ($[
|
|
147
|
-
|
|
148
|
-
$[
|
|
149
|
-
$[
|
|
150
|
-
$[
|
|
151
|
-
} else
|
|
152
|
-
return
|
|
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 };
|
package/dist/DataTable/index.js
CHANGED
|
@@ -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
|
package/dist/DataTable/row.d.ts
CHANGED
|
@@ -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(
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
$[
|
|
55
|
-
$[
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
61
|
-
if (sortByColumn) sortRows(sortByColumn);
|
|
71
|
+
updateRowOrder(data, sortByColumn);
|
|
62
72
|
}
|
|
63
|
-
|
|
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
|
-
|
|
79
|
+
updateRowOrder(rowOrder, sortState);
|
|
70
80
|
};
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
76
|
-
const sortMethod =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
const
|
|
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
|
|
137
|
+
return row_0;
|
|
103
138
|
},
|
|
104
139
|
getCells() {
|
|
105
|
-
return headers.map((
|
|
106
|
-
var
|
|
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}:${
|
|
109
|
-
|
|
110
|
-
|
|
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 (
|
|
113
|
-
throw new Error(`Unable to get value for column header ${
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
|
|
133
|
-
|
|
134
|
-
|
|
200
|
+
bodies = $[15];
|
|
201
|
+
headers = $[16];
|
|
202
|
+
sortBy = $[17];
|
|
135
203
|
}
|
|
136
|
-
let
|
|
137
|
-
if ($[
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
$[
|
|
145
|
-
$[
|
|
146
|
-
$[
|
|
147
|
-
$[
|
|
148
|
-
$[
|
|
149
|
-
} else
|
|
150
|
-
return
|
|
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}.${
|
|
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. */
|