@calcifer-design/ui 0.7.0 → 0.9.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.
- package/dist/components/Alert/Alert.module.js +5 -5
- package/dist/components/Alert/Alert_module.css +14 -14
- package/dist/components/Avatar/Avatar.module.js +3 -3
- package/dist/components/Avatar/Avatar_module.css +15 -15
- package/dist/components/AvatarGroup/AvatarGroup.module.js +4 -4
- package/dist/components/AvatarGroup/AvatarGroup_module.css +10 -10
- package/dist/components/Breadcrumb/Breadcrumb.module.js +6 -6
- package/dist/components/Breadcrumb/Breadcrumb_module.css +7 -7
- package/dist/components/Button/Button.module.js +6 -6
- package/dist/components/Button/Button_module.css +32 -32
- package/dist/components/Card/Card.module.js +5 -5
- package/dist/components/Card/Card_module.css +7 -7
- package/dist/components/CardList/CardList.module.js +3 -3
- package/dist/components/CardList/CardList_module.css +3 -3
- package/dist/components/Checkbox/Checkbox.module.js +2 -2
- package/dist/components/Checkbox/Checkbox_module.css +3 -3
- package/dist/components/ChoiceCard/ChoiceCard.module.js +8 -8
- package/dist/components/ChoiceCard/ChoiceCard_module.css +25 -25
- package/dist/components/Collapsible/Collapsible.module.js +6 -6
- package/dist/components/Collapsible/Collapsible_module.css +11 -11
- package/dist/components/DataGrid/DataGrid.d.ts +1 -1
- package/dist/components/DataGrid/DataGrid.js +149 -64
- package/dist/components/DataGrid/DataGrid.module.js +45 -32
- package/dist/components/DataGrid/DataGrid_module.css +202 -70
- package/dist/components/DataGrid/GridCardHeader.d.ts +40 -4
- package/dist/components/DataGrid/GridCardHeader.js +79 -11
- package/dist/components/DataGrid/GridChoiceFilter.d.ts +21 -0
- package/dist/components/DataGrid/GridChoiceFilter.js +157 -0
- package/dist/components/DataGrid/GridFilterRow.d.ts +22 -0
- package/dist/components/DataGrid/GridFilterRow.js +66 -0
- package/dist/components/DataGrid/GridHeaderCell.d.ts +5 -2
- package/dist/components/DataGrid/GridHeaderCell.js +4 -3
- package/dist/components/DataGrid/GridHeaderRow.d.ts +3 -1
- package/dist/components/DataGrid/GridHeaderRow.js +2 -1
- package/dist/components/DataGrid/GridRow.d.ts +8 -4
- package/dist/components/DataGrid/GridRow.js +4 -4
- package/dist/components/DataGrid/GridSearch.d.ts +19 -0
- package/dist/components/DataGrid/GridSearch.js +32 -0
- package/dist/components/DataGrid/GridStateRows.d.ts +36 -9
- package/dist/components/DataGrid/GridStateRows.js +34 -18
- package/dist/components/DataGrid/GridTextFilter.d.ts +14 -0
- package/dist/components/DataGrid/GridTextFilter.js +21 -0
- package/dist/components/DataGrid/columns.d.ts +31 -8
- package/dist/components/DataGrid/labels.d.ts +24 -0
- package/dist/components/DataGrid/labels.js +14 -0
- package/dist/components/DataGrid/query.d.ts +40 -0
- package/dist/components/DataGrid/query.js +128 -0
- package/dist/components/DataGrid/types.d.ts +52 -7
- package/dist/components/DataGrid/useDebouncedDraft.d.ts +20 -0
- package/dist/components/DataGrid/useDebouncedDraft.js +71 -0
- package/dist/components/DataGrid/useGridEntries.d.ts +3 -2
- package/dist/components/DataGrid/useGridKeyboard.d.ts +17 -7
- package/dist/components/DataGrid/useGridKeyboard.js +18 -8
- package/dist/components/DataGrid/useGridMetrics.d.ts +4 -1
- package/dist/components/DataGrid/useGridMetrics.js +4 -0
- package/dist/components/DataGrid/useGridQuery.d.ts +48 -0
- package/dist/components/DataGrid/useGridQuery.js +71 -0
- package/dist/components/DataTable/DataTable.module.js +9 -9
- package/dist/components/DataTable/DataTable_module.css +19 -19
- package/dist/components/DatePicker/DatePicker.js +3 -0
- package/dist/components/DatePicker/DatePicker.module.js +10 -10
- package/dist/components/DatePicker/DatePicker_module.css +18 -18
- package/dist/components/Descriptions/Descriptions.module.js +4 -4
- package/dist/components/Descriptions/Descriptions_module.css +8 -8
- package/dist/components/Dialog/Dialog.js +1 -0
- package/dist/components/Dialog/Dialog.module.js +8 -8
- package/dist/components/Dialog/Dialog_module.css +15 -15
- package/dist/components/EmptyState/EmptyState.module.js +5 -5
- package/dist/components/EmptyState/EmptyState_module.css +10 -10
- package/dist/components/ErrorBoundary/ErrorBoundary.module.js +1 -1
- package/dist/components/ErrorBoundary/ErrorBoundary_module.css +1 -1
- package/dist/components/Field/PickerField.module.js +4 -4
- package/dist/components/Field/PickerField_module.css +7 -7
- package/dist/components/FilterBar/FilterBar.module.js +9 -9
- package/dist/components/FilterBar/FilterBar_module.css +13 -13
- package/dist/components/Form/Form.module.js +1 -1
- package/dist/components/Form/Form_module.css +1 -1
- package/dist/components/IconButton/IconButton.d.ts +12 -1
- package/dist/components/IconButton/IconButton.js +19 -9
- package/dist/components/IconButton/IconButton.module.js +3 -2
- package/dist/components/IconButton/IconButton_module.css +68 -14
- package/dist/components/Menu/Menu.module.js +2 -2
- package/dist/components/Menu/Menu_module.css +4 -4
- package/dist/components/NavMenu/NavMenu.module.js +6 -6
- package/dist/components/NavMenu/NavMenu_module.css +12 -12
- package/dist/components/PageHeading/PageHeading.module.js +3 -3
- package/dist/components/PageHeading/PageHeading_module.css +8 -8
- package/dist/components/PageShell/PageShell.module.js +5 -5
- package/dist/components/PageShell/PageShell_module.css +9 -9
- package/dist/components/Popover/Popover.module.js +2 -2
- package/dist/components/Popover/Popover_module.css +2 -2
- package/dist/components/ProgressBar/ProgressBar.module.js +8 -8
- package/dist/components/ProgressBar/ProgressBar_module.css +19 -19
- package/dist/components/RadioGroup/RadioGroup.module.js +2 -2
- package/dist/components/RadioGroup/RadioGroup_module.css +2 -2
- package/dist/components/SearchField/SearchField.module.js +4 -4
- package/dist/components/SearchField/SearchField_module.css +7 -7
- package/dist/components/Segmented/Segmented.module.js +4 -4
- package/dist/components/Segmented/Segmented_module.css +13 -13
- package/dist/components/Select/Select.module.js +5 -5
- package/dist/components/Select/Select_module.css +11 -11
- package/dist/components/Skeleton/Skeleton.module.js +3 -3
- package/dist/components/Skeleton/Skeleton_module.css +7 -7
- package/dist/components/SkipLink/SkipLink.module.js +1 -1
- package/dist/components/SkipLink/SkipLink_module.css +2 -2
- package/dist/components/Spinner/Spinner.module.js +3 -3
- package/dist/components/Spinner/Spinner_module.css +7 -7
- package/dist/components/StatusDot/StatusDot.module.js +5 -5
- package/dist/components/StatusDot/StatusDot_module.css +11 -11
- package/dist/components/Steps/Steps.module.js +6 -6
- package/dist/components/Steps/Steps_module.css +19 -19
- package/dist/components/Switch/Switch.module.js +2 -2
- package/dist/components/Switch/Switch_module.css +5 -5
- package/dist/components/TabBar/TabBar.module.js +7 -7
- package/dist/components/TabBar/TabBar_module.css +13 -13
- package/dist/components/Tabs/Tabs.module.js +4 -4
- package/dist/components/Tabs/Tabs_module.css +6 -6
- package/dist/components/Tag/Tag.module.js +1 -1
- package/dist/components/Tag/Tag_module.css +2 -2
- package/dist/components/TextArea/TextArea.module.js +1 -1
- package/dist/components/TextArea/TextArea_module.css +3 -3
- package/dist/components/ThemeScope/ThemeScope.module.js +2 -2
- package/dist/components/ThemeScope/ThemeScope_module.css +2 -2
- package/dist/components/Timeline/Timeline.module.js +8 -8
- package/dist/components/Timeline/Timeline_module.css +13 -13
- package/dist/components/ToastRegion/ToastRegion.module.js +6 -6
- package/dist/components/ToastRegion/ToastRegion_module.css +15 -15
- package/dist/components/ToggleChip/ToggleChip.module.js +5 -5
- package/dist/components/ToggleChip/ToggleChip_module.css +14 -14
- package/dist/components/Toolbar/Toolbar.module.js +3 -3
- package/dist/components/Toolbar/Toolbar_module.css +5 -5
- package/dist/components/Tree/Tree.module.js +8 -8
- package/dist/components/Tree/Tree_module.css +20 -20
- package/dist/components/TreeSelect/TreeSelect.module.js +3 -3
- package/dist/components/TreeSelect/TreeSelect_module.css +4 -4
- package/dist/components/Upload/Upload.module.js +8 -8
- package/dist/components/Upload/Upload_module.css +16 -16
- package/dist/components/ViewField/ViewField.module.js +2 -2
- package/dist/components/ViewField/ViewField_module.css +3 -3
- package/dist/icons/FilterIcon.d.ts +6 -0
- package/dist/icons/FilterIcon.js +17 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/styles/a11y.module.js +1 -1
- package/dist/styles/a11y_module.css +1 -1
- package/dist/styles/closeCircle.module.js +1 -1
- package/dist/styles/closeCircle_module.css +2 -2
- package/dist/styles/field.module.js +14 -14
- package/dist/styles/field_module.css +35 -35
- package/dist/styles/pair.module.js +2 -2
- package/dist/styles/pair_module.css +3 -3
- package/dist/styles/popup.module.js +5 -5
- package/dist/styles/popup_module.css +17 -17
- package/package.json +2 -2
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useTable } from "@tanstack/react-table";
|
|
3
3
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
4
|
-
import { useCallback, useId, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { useCallback, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { LiveRegion } from "../LiveRegion/LiveRegion.js";
|
|
6
6
|
import { dataGridFeatures, textValueOf } from "./columns.js";
|
|
7
7
|
import DataGrid_module from "./DataGrid.module.js";
|
|
8
8
|
import { GridCardHeader } from "./GridCardHeader.js";
|
|
9
|
+
import { GridFilterRow } from "./GridFilterRow.js";
|
|
9
10
|
import { GridHeaderRow } from "./GridHeaderRow.js";
|
|
10
11
|
import { GridDetailRow, GridRow, GridSpacerRow } from "./GridRow.js";
|
|
11
12
|
import { GridErrorRow, GridStateRow } from "./GridStateRows.js";
|
|
12
13
|
import { resolveDataGridLabels } from "./labels.js";
|
|
14
|
+
import { createQueryMatcher, isSameQuery } from "./query.js";
|
|
13
15
|
import { useGridEntries } from "./useGridEntries.js";
|
|
14
16
|
import { useGridHighlight } from "./useGridHighlight.js";
|
|
17
|
+
import { useGridQuery } from "./useGridQuery.js";
|
|
15
18
|
import { useGridMetrics } from "./useGridMetrics.js";
|
|
16
19
|
import { cellControlSelector, useGridKeyboard } from "./useGridKeyboard.js";
|
|
17
20
|
import { useLoadMore } from "./useLoadMore.js";
|
|
@@ -42,14 +45,57 @@ function formatCellValue(value) {
|
|
|
42
45
|
const text = 'string' == typeof value ? value : String(value);
|
|
43
46
|
return '' === text.trim() ? emptyCellText : text;
|
|
44
47
|
}
|
|
45
|
-
function DataGrid({ heading, headingLevel = 2, rows, columns, getRowId, getRowLabel, actions, mode = 'client', totalRowCount, hasMore = false, loadingMore = false, loadError, onLoadMore, onQueryChange, initialSorting =
|
|
48
|
+
function DataGrid({ heading, headingLevel = 2, rows, columns, getRowId, getRowLabel, actions, mode = 'client', totalRowCount, hasMore = false, loadingMore = false, loadError, onLoadMore, onQueryChange, initialQuery, query, initialSorting, enableSearch = false, enableSorting = true, multiSort = false, density = 'comfortable', maxHeight, fill = false, hideFooter = false, loading = false, emptyState, filteredEmptyState, onRefresh, refreshing = false, highlightOnClick = false, highlightedRowId, onHighlightChange, selectionMode = 'none', selectedRowIds, defaultSelectedRowIds, onSelectedRowIdsChange, isRowSelectable, onRowClick, onRowDoubleClick, onRowContextMenu, renderRowActions, rowActionsHeader, renderExpandedRow, isRowExpandable, expandedRowIds, defaultExpandedRowIds, onExpandedRowIdsChange, labels }) {
|
|
46
49
|
const serverMode = 'server' === mode;
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
50
|
+
const queryEnabled = !serverMode && void 0 === query || void 0 !== onQueryChange;
|
|
51
|
+
const sortingEnabled = enableSorting && queryEnabled;
|
|
52
|
+
const filtering = queryEnabled && columns.some((column)=>void 0 !== column.filter);
|
|
53
|
+
const [filtersOpen, setFiltersOpen] = useState(false);
|
|
54
|
+
const showsFilterStrip = filtering && filtersOpen;
|
|
55
|
+
const headRowCount = showsFilterStrip ? 2 : 1;
|
|
56
|
+
const [oldQueryRows, setOldQueryRows] = useState(null);
|
|
57
|
+
const gridQuery = useGridQuery({
|
|
58
|
+
columns,
|
|
59
|
+
initialQuery: queryEnabled ? initialQuery : {
|
|
60
|
+
...initialQuery,
|
|
61
|
+
filters: {},
|
|
62
|
+
search: ''
|
|
63
|
+
},
|
|
64
|
+
initialSorting,
|
|
65
|
+
query,
|
|
66
|
+
onQueryChange,
|
|
67
|
+
onChange: (_nextQuery, previousQuery)=>{
|
|
68
|
+
selection.clear();
|
|
69
|
+
virtualizer.scrollToOffset(0);
|
|
70
|
+
if (serverMode) {
|
|
71
|
+
const committedRows = committedRowsRef.current;
|
|
72
|
+
setOldQueryRows((current)=>current?.rows === committedRows ? current : {
|
|
73
|
+
rows: committedRows,
|
|
74
|
+
query: previousQuery
|
|
75
|
+
});
|
|
76
|
+
loadMore.reset();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const awaitingNewRows = null !== oldQueryRows && oldQueryRows.rows === rows && !isSameQuery(oldQueryRows.query, gridQuery.query);
|
|
81
|
+
const searching = enableSearch && queryEnabled;
|
|
82
|
+
const [searchOpen, setSearchOpen] = useState('' !== gridQuery.query.search);
|
|
83
|
+
const showsSearch = searching && (searchOpen || '' !== gridQuery.query.search);
|
|
84
|
+
const committedRowsRef = useRef(rows);
|
|
85
|
+
useLayoutEffect(()=>{
|
|
86
|
+
committedRowsRef.current = rows;
|
|
87
|
+
});
|
|
88
|
+
const shownRows = useMemo(()=>{
|
|
89
|
+
const matcher = serverMode ? null : createQueryMatcher(columns, gridQuery.query);
|
|
90
|
+
return matcher ? rows.filter(matcher) : rows;
|
|
91
|
+
}, [
|
|
92
|
+
serverMode,
|
|
52
93
|
rows,
|
|
94
|
+
columns,
|
|
95
|
+
gridQuery.query
|
|
96
|
+
]);
|
|
97
|
+
const { highlightedId, setHighlightedId } = useGridHighlight({
|
|
98
|
+
rows: shownRows,
|
|
53
99
|
getRowId,
|
|
54
100
|
loading,
|
|
55
101
|
highlightedRowId,
|
|
@@ -67,10 +113,10 @@ function DataGrid({ heading, headingLevel = 2, rows, columns, getRowId, getRowLa
|
|
|
67
113
|
const isExpandable = (row)=>expanding && (isRowExpandable?.(row) ?? true);
|
|
68
114
|
const selection = useRowSelection({
|
|
69
115
|
enabled: selecting,
|
|
70
|
-
rows,
|
|
116
|
+
rows: shownRows,
|
|
71
117
|
getRowId,
|
|
72
118
|
isRowSelectable,
|
|
73
|
-
loading,
|
|
119
|
+
loading: loading || gridQuery.pendingChange,
|
|
74
120
|
selectedRowIds,
|
|
75
121
|
defaultSelectedRowIds,
|
|
76
122
|
onSelectedRowIdsChange,
|
|
@@ -83,32 +129,17 @@ function DataGrid({ heading, headingLevel = 2, rows, columns, getRowId, getRowLa
|
|
|
83
129
|
const resolvedLabels = resolveDataGridLabels(labels);
|
|
84
130
|
const table = useTable({
|
|
85
131
|
features: dataGridFeatures,
|
|
86
|
-
data:
|
|
132
|
+
data: shownRows,
|
|
87
133
|
columns,
|
|
88
134
|
getRowId,
|
|
89
135
|
state: {
|
|
90
|
-
sorting,
|
|
136
|
+
sorting: gridQuery.query.sorting,
|
|
91
137
|
rowSelection: selection.rowSelection
|
|
92
138
|
},
|
|
93
139
|
manualSorting: serverMode,
|
|
94
|
-
onSortingChange: (updater)=>
|
|
95
|
-
const nextSorting = 'function' == typeof updater ? updater(sorting) : updater;
|
|
96
|
-
setSorting(nextSorting);
|
|
97
|
-
selection.clear();
|
|
98
|
-
if (serverMode) {
|
|
99
|
-
setRowsOfOldQuery(rows);
|
|
100
|
-
loadMore.reset();
|
|
101
|
-
virtualizer.scrollToOffset(0);
|
|
102
|
-
onQueryChange?.({
|
|
103
|
-
sorting: nextSorting,
|
|
104
|
-
filters: {},
|
|
105
|
-
matchMode: 'all',
|
|
106
|
-
search: ''
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
},
|
|
140
|
+
onSortingChange: (updater)=>gridQuery.setSorting('function' == typeof updater ? updater(gridQuery.query.sorting) : updater),
|
|
110
141
|
enableRowSelection: (row)=>isRowSelectable?.(row.original) ?? true,
|
|
111
|
-
enableSorting: sortingEnabled,
|
|
142
|
+
enableSorting: serverMode ? sortingEnabled : enableSorting,
|
|
112
143
|
enableMultiSort: multiSort,
|
|
113
144
|
defaultColumn: {
|
|
114
145
|
sortDescFirst: false,
|
|
@@ -130,7 +161,7 @@ function DataGrid({ heading, headingLevel = 2, rows, columns, getRowId, getRowLa
|
|
|
130
161
|
const showsLoadError = serverMode && void 0 !== loadError && !loading;
|
|
131
162
|
let stateKind = null;
|
|
132
163
|
if (loading) stateKind = 'loading';
|
|
133
|
-
else if (0 === entries.length && !showsLoadError) stateKind = 'empty';
|
|
164
|
+
else if (0 === entries.length && !showsLoadError) stateKind = gridQuery.activeCount > 0 ? 'filteredEmpty' : 'empty';
|
|
134
165
|
const rowHeight = estimatedRowHeight[density];
|
|
135
166
|
const rowsPerViewport = Math.max(1, Math.floor((viewportHeight - headerHeight) / rowHeight));
|
|
136
167
|
const rowsClickable = Boolean(onRowClick || highlightOnClick);
|
|
@@ -154,8 +185,8 @@ function DataGrid({ heading, headingLevel = 2, rows, columns, getRowId, getRowLa
|
|
|
154
185
|
return text ?? row.id;
|
|
155
186
|
};
|
|
156
187
|
const handleActivate = (rowIndex, columnIndex, event)=>{
|
|
157
|
-
if (rowIndex
|
|
158
|
-
const entry = entries[rowIndex -
|
|
188
|
+
if (rowIndex >= headRowCount && expanding && columnIndex === expandColumn) {
|
|
189
|
+
const entry = entries[rowIndex - headRowCount];
|
|
159
190
|
if (entry?.kind === 'row' && isExpandable(entry.row.original)) {
|
|
160
191
|
event.preventDefault();
|
|
161
192
|
expansion.toggleRow(entry.row.id);
|
|
@@ -170,7 +201,7 @@ function DataGrid({ heading, headingLevel = 2, rows, columns, getRowId, getRowLa
|
|
|
170
201
|
selection.toggleAll();
|
|
171
202
|
return;
|
|
172
203
|
}
|
|
173
|
-
const entry = entries[rowIndex -
|
|
204
|
+
const entry = entries[rowIndex - headRowCount];
|
|
174
205
|
if (entry?.kind !== 'row' || !selection.isSelectable(entry.row.id)) return;
|
|
175
206
|
event.preventDefault();
|
|
176
207
|
selection.toggleRow(entry.row.id, {
|
|
@@ -181,13 +212,13 @@ function DataGrid({ heading, headingLevel = 2, rows, columns, getRowId, getRowLa
|
|
|
181
212
|
if ('Enter' !== event.key) return;
|
|
182
213
|
if (0 === rowIndex) {
|
|
183
214
|
const column = leafHeaders[columnIndex - columnOffset]?.column;
|
|
184
|
-
if (column?.getCanSort()) {
|
|
215
|
+
if (sortingEnabled && column?.getCanSort()) {
|
|
185
216
|
event.preventDefault();
|
|
186
217
|
column.getToggleSortingHandler()?.(event);
|
|
187
218
|
}
|
|
188
219
|
return;
|
|
189
220
|
}
|
|
190
|
-
const entry = entries[rowIndex -
|
|
221
|
+
const entry = entries[rowIndex - headRowCount];
|
|
191
222
|
if (entry?.kind !== 'row' || event.currentTarget.querySelector(cellControlSelector)) return;
|
|
192
223
|
if (rowsClickable) {
|
|
193
224
|
event.preventDefault();
|
|
@@ -199,7 +230,7 @@ function DataGrid({ heading, headingLevel = 2, rows, columns, getRowId, getRowLa
|
|
|
199
230
|
keyboardContextMenuCellRef.current = null;
|
|
200
231
|
};
|
|
201
232
|
const handleContextMenuKey = (rowIndex, _columnIndex, event)=>{
|
|
202
|
-
const entry = entries[rowIndex -
|
|
233
|
+
const entry = entries[rowIndex - headRowCount];
|
|
203
234
|
if (entry?.kind !== 'row' || !onRowContextMenu) return;
|
|
204
235
|
event.preventDefault();
|
|
205
236
|
keyboardContextMenuCellRef.current = event.currentTarget;
|
|
@@ -213,7 +244,8 @@ function DataGrid({ heading, headingLevel = 2, rows, columns, getRowId, getRowLa
|
|
|
213
244
|
onRowContextMenu?.(row.original, event);
|
|
214
245
|
};
|
|
215
246
|
const keyboard = useGridKeyboard({
|
|
216
|
-
rowCount: stateKind ?
|
|
247
|
+
rowCount: stateKind ? headRowCount : entries.length + headRowCount + (showsLoadError ? 1 : 0),
|
|
248
|
+
headRowCount,
|
|
217
249
|
columnCount,
|
|
218
250
|
onActivate: handleActivate,
|
|
219
251
|
onContextMenu: handleContextMenuKey,
|
|
@@ -223,7 +255,7 @@ function DataGrid({ heading, headingLevel = 2, rows, columns, getRowId, getRowLa
|
|
|
223
255
|
return range ? Math.max(1, range.endIndex - range.startIndex + 1) : rowsPerViewport;
|
|
224
256
|
}
|
|
225
257
|
});
|
|
226
|
-
const focusedEntryIndex = keyboard.focusedCell.rowIndex -
|
|
258
|
+
const focusedEntryIndex = keyboard.focusedCell.rowIndex - headRowCount;
|
|
227
259
|
const pinnedIndexes = useMemo(()=>new Set(focusedEntryIndex >= 0 ? [
|
|
228
260
|
focusedEntryIndex
|
|
229
261
|
] : []), [
|
|
@@ -276,6 +308,7 @@ function DataGrid({ heading, headingLevel = 2, rows, columns, getRowId, getRowLa
|
|
|
276
308
|
if ('detail' === entry.kind) {
|
|
277
309
|
bodyRows.push(/*#__PURE__*/ jsx(GridDetailRow, {
|
|
278
310
|
entryIndex: virtualItem.index,
|
|
311
|
+
firstEntryRow: headRowCount,
|
|
279
312
|
measureRef: virtualizer.measureElement,
|
|
280
313
|
columnCount: columnCount,
|
|
281
314
|
panelId: panelIdOf(row),
|
|
@@ -287,6 +320,7 @@ function DataGrid({ heading, headingLevel = 2, rows, columns, getRowId, getRowLa
|
|
|
287
320
|
bodyRows.push(/*#__PURE__*/ jsx(GridRow, {
|
|
288
321
|
row: row,
|
|
289
322
|
entryIndex: virtualItem.index,
|
|
323
|
+
firstEntryRow: headRowCount,
|
|
290
324
|
measureRef: virtualizer.measureElement,
|
|
291
325
|
density: density,
|
|
292
326
|
columnOffset: columnOffset,
|
|
@@ -321,14 +355,25 @@ function DataGrid({ heading, headingLevel = 2, rows, columns, getRowId, getRowLa
|
|
|
321
355
|
maxHeight: maxHeight && !fill ? maxHeight : void 0,
|
|
322
356
|
scrollPaddingBlockStart: headerHeight || void 0
|
|
323
357
|
};
|
|
324
|
-
const errorRowIndex = entries.length +
|
|
325
|
-
const knownRowCount = serverMode && void 0 !== totalRowCount ? Math.max(totalRowCount, rows.length) :
|
|
326
|
-
let ariaRowCount = Math.max(knownRowCount + openPanelCount +
|
|
358
|
+
const errorRowIndex = entries.length + headRowCount + 1;
|
|
359
|
+
const knownRowCount = serverMode && void 0 !== totalRowCount ? Math.max(totalRowCount, rows.length) : shownRows.length;
|
|
360
|
+
let ariaRowCount = Math.max(knownRowCount + openPanelCount + headRowCount, showsLoadError ? errorRowIndex : 0);
|
|
327
361
|
if (serverMode && void 0 === totalRowCount && hasMore) ariaRowCount = -1;
|
|
328
|
-
if (stateKind) ariaRowCount =
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
362
|
+
if (stateKind) ariaRowCount = headRowCount + 1;
|
|
363
|
+
const stateLabel = stateKind ? resolvedLabels[stateKind] : '';
|
|
364
|
+
let stateReplacement;
|
|
365
|
+
let clearFiltersButton;
|
|
366
|
+
if ('empty' === stateKind) stateReplacement = emptyState;
|
|
367
|
+
if ('filteredEmpty' === stateKind) {
|
|
368
|
+
stateReplacement = filteredEmptyState?.(gridQuery.clearFilters);
|
|
369
|
+
if (queryEnabled) clearFiltersButton = {
|
|
370
|
+
label: resolvedLabels.clearFilters,
|
|
371
|
+
onClick: gridQuery.clearFilters
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
let rowCountText = resolvedLabels.rowCount(rows.length);
|
|
375
|
+
if (serverMode && void 0 !== totalRowCount) rowCountText = resolvedLabels.loadedRowCount(rows.length, totalRowCount);
|
|
376
|
+
else if (!serverMode && gridQuery.activeCount > 0) rowCountText = resolvedLabels.filteredRowCount(shownRows.length, rows.length);
|
|
332
377
|
return /*#__PURE__*/ jsxs("section", {
|
|
333
378
|
className: fill ? `${DataGrid_module.card} ${DataGrid_module.fill}` : DataGrid_module.card,
|
|
334
379
|
"aria-labelledby": headingId,
|
|
@@ -341,7 +386,31 @@ function DataGrid({ heading, headingLevel = 2, rows, columns, getRowId, getRowLa
|
|
|
341
386
|
onRefresh: onRefresh,
|
|
342
387
|
refreshing: refreshing,
|
|
343
388
|
toolbarLabel: resolvedLabels.toolbar,
|
|
344
|
-
refreshLabel: resolvedLabels.refresh
|
|
389
|
+
refreshLabel: resolvedLabels.refresh,
|
|
390
|
+
search: searching ? {
|
|
391
|
+
open: showsSearch,
|
|
392
|
+
value: gridQuery.query.search,
|
|
393
|
+
buttonLabel: resolvedLabels.search,
|
|
394
|
+
fieldLabel: resolvedLabels.searchField,
|
|
395
|
+
clearLabel: resolvedLabels.clearSearch,
|
|
396
|
+
onToggle: ()=>{
|
|
397
|
+
if (showsSearch) gridQuery.setSearch('');
|
|
398
|
+
setSearchOpen(!showsSearch);
|
|
399
|
+
},
|
|
400
|
+
onClose: ()=>setSearchOpen(false),
|
|
401
|
+
onSearchChange: gridQuery.setSearch,
|
|
402
|
+
onFieldFocus: ()=>setSearchOpen(true)
|
|
403
|
+
} : void 0,
|
|
404
|
+
onToggleFilters: filtering ? ()=>setFiltersOpen((open)=>!open) : void 0,
|
|
405
|
+
filtersOpen: filtersOpen,
|
|
406
|
+
filtersLabel: resolvedLabels.filters(gridQuery.activeCount),
|
|
407
|
+
filterCount: gridQuery.activeCount,
|
|
408
|
+
showMatchMode: filtering && (filtersOpen || Object.keys(gridQuery.query.filters).length > 0),
|
|
409
|
+
matchMode: gridQuery.query.matchMode,
|
|
410
|
+
onMatchModeChange: gridQuery.setMatchMode,
|
|
411
|
+
matchModeLabel: resolvedLabels.matchMode,
|
|
412
|
+
matchAllLabel: resolvedLabels.matchAll,
|
|
413
|
+
matchAnyLabel: resolvedLabels.matchAny
|
|
345
414
|
}),
|
|
346
415
|
/*#__PURE__*/ jsx(LiveRegion, {
|
|
347
416
|
message: stateLabel,
|
|
@@ -367,35 +436,50 @@ function DataGrid({ heading, headingLevel = 2, rows, columns, getRowId, getRowLa
|
|
|
367
436
|
onKeyDownCapture: forgetKeyboardContextMenu,
|
|
368
437
|
onBlur: forgetKeyboardContextMenu,
|
|
369
438
|
children: [
|
|
370
|
-
/*#__PURE__*/
|
|
439
|
+
/*#__PURE__*/ jsxs("thead", {
|
|
371
440
|
ref: headRef,
|
|
372
441
|
className: DataGrid_module.head,
|
|
373
|
-
children:
|
|
374
|
-
|
|
442
|
+
children: [
|
|
443
|
+
table.getHeaderGroups().map((headerGroup)=>/*#__PURE__*/ jsx(GridHeaderRow, {
|
|
444
|
+
headers: headerGroup.headers,
|
|
445
|
+
columnCount: columnCount,
|
|
446
|
+
columnOffset: columnOffset,
|
|
447
|
+
sortable: sortingEnabled,
|
|
448
|
+
selectAll: selecting ? {
|
|
449
|
+
label: resolvedLabels.selectAll,
|
|
450
|
+
checked: selection.allSelected,
|
|
451
|
+
indeterminate: selection.someSelected,
|
|
452
|
+
disabled: !selection.canSelectAny,
|
|
453
|
+
onCheckedChange: selection.toggleAll
|
|
454
|
+
} : void 0,
|
|
455
|
+
expandLabel: expanding ? resolvedLabels.expandColumn : void 0,
|
|
456
|
+
rowActions: renderRowActions ? {
|
|
457
|
+
header: rowActionsHeader,
|
|
458
|
+
label: resolvedLabels.rowActions
|
|
459
|
+
} : void 0,
|
|
460
|
+
getCellProps: keyboard.getCellProps
|
|
461
|
+
}, headerGroup.id)),
|
|
462
|
+
showsFilterStrip ? /*#__PURE__*/ jsx(GridFilterRow, {
|
|
463
|
+
headers: leafHeaders,
|
|
375
464
|
columnCount: columnCount,
|
|
376
465
|
columnOffset: columnOffset,
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
indeterminate: selection.someSelected,
|
|
381
|
-
disabled: !selection.canSelectAny,
|
|
382
|
-
onCheckedChange: selection.toggleAll
|
|
383
|
-
} : void 0,
|
|
384
|
-
expandLabel: expanding ? resolvedLabels.expandColumn : void 0,
|
|
385
|
-
rowActions: renderRowActions ? {
|
|
386
|
-
header: rowActionsHeader,
|
|
387
|
-
label: resolvedLabels.rowActions
|
|
388
|
-
} : void 0,
|
|
466
|
+
hasRowActions: void 0 !== renderRowActions,
|
|
467
|
+
query: gridQuery,
|
|
468
|
+
labels: resolvedLabels,
|
|
389
469
|
getCellProps: keyboard.getCellProps
|
|
390
|
-
}
|
|
470
|
+
}) : null
|
|
471
|
+
]
|
|
391
472
|
}),
|
|
392
473
|
/*#__PURE__*/ jsxs("tbody", {
|
|
393
474
|
children: [
|
|
394
475
|
stateKind ? /*#__PURE__*/ jsx(GridStateRow, {
|
|
395
476
|
kind: stateKind,
|
|
396
477
|
label: stateLabel,
|
|
397
|
-
|
|
398
|
-
|
|
478
|
+
replacement: stateReplacement,
|
|
479
|
+
clearFilters: clearFiltersButton,
|
|
480
|
+
headingLevel: 2 === headingLevel ? 3 : 4,
|
|
481
|
+
columnCount: columnCount,
|
|
482
|
+
firstEntryRow: headRowCount
|
|
399
483
|
}) : null,
|
|
400
484
|
bodyRows,
|
|
401
485
|
bottomSpacerHeight > 0 ? /*#__PURE__*/ jsx(GridSpacerRow, {
|
|
@@ -404,6 +488,7 @@ function DataGrid({ heading, headingLevel = 2, rows, columns, getRowId, getRowLa
|
|
|
404
488
|
}) : null,
|
|
405
489
|
showsLoadError ? /*#__PURE__*/ jsx(GridErrorRow, {
|
|
406
490
|
entryIndex: entries.length,
|
|
491
|
+
firstEntryRow: headRowCount,
|
|
407
492
|
columnCount: columnCount,
|
|
408
493
|
message: loadError,
|
|
409
494
|
retryLabel: resolvedLabels.retry,
|
|
@@ -426,7 +511,7 @@ function DataGrid({ heading, headingLevel = 2, rows, columns, getRowId, getRowLa
|
|
|
426
511
|
}) : null,
|
|
427
512
|
/*#__PURE__*/ jsx("span", {
|
|
428
513
|
className: DataGrid_module.rowCount,
|
|
429
|
-
children:
|
|
514
|
+
children: rowCountText
|
|
430
515
|
})
|
|
431
516
|
]
|
|
432
517
|
})
|
|
@@ -1,36 +1,49 @@
|
|
|
1
1
|
import "./DataGrid_module.css";
|
|
2
2
|
const DataGrid_module = {
|
|
3
|
-
card: "ui0-
|
|
4
|
-
header: "ui0-
|
|
5
|
-
heading: "ui0-
|
|
6
|
-
cluster: "ui0-
|
|
7
|
-
actions: "ui0-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
3
|
+
card: "ui0-9-0-card-sKuGs",
|
|
4
|
+
header: "ui0-9-0-header-FnSmG",
|
|
5
|
+
heading: "ui0-9-0-heading-cO1_Q",
|
|
6
|
+
cluster: "ui0-9-0-cluster-FC5NS",
|
|
7
|
+
actions: "ui0-9-0-actions-_1Hpt",
|
|
8
|
+
search: "ui0-9-0-search-OhcyT",
|
|
9
|
+
scroll: "ui0-9-0-scroll-FzUQa",
|
|
10
|
+
fill: "ui0-9-0-fill-gnSOL",
|
|
11
|
+
scrollFill: "ui0-9-0-scrollFill-ouKju",
|
|
12
|
+
table: "ui0-9-0-table-sZLxO",
|
|
13
|
+
head: "ui0-9-0-head-z5Rnq",
|
|
14
|
+
headerCell: "ui0-9-0-headerCell-CgaE0",
|
|
15
|
+
sortIcon: "ui0-9-0-sortIcon-aw3qW",
|
|
16
|
+
filterCell: "ui0-9-0-filterCell-mCVBO",
|
|
17
|
+
choiceFilter: "ui0-9-0-choiceFilter-PSMWn",
|
|
18
|
+
choiceInput: "ui0-9-0-choiceInput-Mpj81",
|
|
19
|
+
choiceTrigger: "ui0-9-0-choiceTrigger-Wg0R5",
|
|
20
|
+
choiceOption: "ui0-9-0-choiceOption-k2H9Y",
|
|
21
|
+
choiceIndicator: "ui0-9-0-choiceIndicator-vJ8iD",
|
|
22
|
+
choiceEmpty: "ui0-9-0-choiceEmpty-lUwuu",
|
|
23
|
+
row: "ui0-9-0-row-OLZkz",
|
|
24
|
+
cell: "ui0-9-0-cell-TYnuY",
|
|
25
|
+
pinnedHeader: "ui0-9-0-pinnedHeader-b7R5T",
|
|
26
|
+
pinnedFilter: "ui0-9-0-pinnedFilter-XpjIz",
|
|
27
|
+
pinnedCell: "ui0-9-0-pinnedCell-hktdQ",
|
|
28
|
+
selectHeader: "ui0-9-0-selectHeader-ysJFY",
|
|
29
|
+
selectCell: "ui0-9-0-selectCell-WkrzU",
|
|
30
|
+
expandHeader: "ui0-9-0-expandHeader-xZuaw",
|
|
31
|
+
expandCell: "ui0-9-0-expandCell-nB87K",
|
|
32
|
+
leadingFilter: "ui0-9-0-leadingFilter-eWybP",
|
|
33
|
+
expandButton: "ui0-9-0-expandButton-gnwRu",
|
|
34
|
+
actionsHeader: "ui0-9-0-actionsHeader-DXNJS",
|
|
35
|
+
actionsFilter: "ui0-9-0-actionsFilter-sxbdF",
|
|
36
|
+
actionsCell: "ui0-9-0-actionsCell-XmWDR",
|
|
37
|
+
detailRow: "ui0-9-0-detailRow-WsOl1",
|
|
38
|
+
detailCell: "ui0-9-0-detailCell-y4qyE",
|
|
39
|
+
errorCell: "ui0-9-0-errorCell-m9Gxy",
|
|
40
|
+
errorContent: "ui0-9-0-errorContent-_tmon",
|
|
41
|
+
stateCell: "ui0-9-0-stateCell-_44Lv",
|
|
42
|
+
inView: "ui0-9-0-inView-FMUxF",
|
|
43
|
+
state: "ui0-9-0-state-WLbKa",
|
|
44
|
+
filteredEmpty: "ui0-9-0-filteredEmpty-MXOmm",
|
|
45
|
+
spacerCell: "ui0-9-0-spacerCell-IoOYY",
|
|
46
|
+
footer: "ui0-9-0-footer-pI1Q7",
|
|
47
|
+
rowCount: "ui0-9-0-rowCount-M_Nba"
|
|
35
48
|
};
|
|
36
49
|
export default DataGrid_module;
|