@calcifer-design/ui 0.8.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.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.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 +33 -33
- 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 +1 -1
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { type FocusEvent, type KeyboardEvent, type RefObject } from 'react';
|
|
2
2
|
export interface GridCellPosition {
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* 0 is the header row and 1 the filter strip while it shows; body entry `n` is row
|
|
5
|
+
* `n + headRowCount`.
|
|
6
|
+
*/
|
|
4
7
|
rowIndex: number;
|
|
5
8
|
/** Counts every rendered column. */
|
|
6
9
|
columnIndex: number;
|
|
7
10
|
}
|
|
8
11
|
export type GridCellKeyHandler = (rowIndex: number, columnIndex: number, event: KeyboardEvent<HTMLElement>) => void;
|
|
9
12
|
export interface UseGridKeyboardOptions {
|
|
10
|
-
/** The rows focus can reach, the
|
|
13
|
+
/** The rows focus can reach, the head rows included. */
|
|
11
14
|
rowCount: number;
|
|
15
|
+
/**
|
|
16
|
+
* The rows before the first body entry: 1 (the header), or 2 while the filter strip shows. Body
|
|
17
|
+
* entry `n` is keyboard row `n + headRowCount`. When it changes, a held position in the body moves
|
|
18
|
+
* with its row.
|
|
19
|
+
*/
|
|
20
|
+
headRowCount: number;
|
|
12
21
|
columnCount: number;
|
|
13
22
|
/** How many rows Page Up and Page Down move; called from key handlers only. */
|
|
14
23
|
getPageSize: () => number;
|
|
@@ -20,7 +29,7 @@ export interface UseGridKeyboardOptions {
|
|
|
20
29
|
onActivate: GridCellKeyHandler;
|
|
21
30
|
/** The context menu key or Shift+F10 on a focused cell. */
|
|
22
31
|
onContextMenu: GridCellKeyHandler;
|
|
23
|
-
/** Scrolls a body entry (`rowIndex -
|
|
32
|
+
/** Scrolls a body entry (`rowIndex - headRowCount`) into view, so that it renders. */
|
|
24
33
|
scrollToEntry: (entryIndex: number) => void;
|
|
25
34
|
}
|
|
26
35
|
export interface GridCellProps {
|
|
@@ -33,17 +42,18 @@ export interface GridCellProps {
|
|
|
33
42
|
/** The props of the cell at a position; a cell spanning several columns gives its `columnSpan`. */
|
|
34
43
|
export type GetCellProps = (rowIndex: number, columnIndex: number, columnSpan?: number) => GridCellProps;
|
|
35
44
|
/**
|
|
36
|
-
* What counts as a control inside a cell
|
|
37
|
-
*
|
|
45
|
+
* What counts as a control inside a cell: a click on one is not a click on its row. An element
|
|
46
|
+
* that is a button by its role alone, with no tabindex, takes no focus, and the grid gives it no
|
|
47
|
+
* tab stop: a combobox's visually hidden dismiss button is for a screen reader's cursor only.
|
|
38
48
|
*/
|
|
39
|
-
export declare const cellControlSelector = "button, a[href], input, select, textarea, [role=\"button\"]
|
|
49
|
+
export declare const cellControlSelector = "button, a[href], input, select, textarea, [tabindex], [role=\"button\"]";
|
|
40
50
|
/**
|
|
41
51
|
* Roving focus for a grid, per the WAI-ARIA data grid pattern: one cell is the tab stop, the arrow
|
|
42
52
|
* keys, Home, End and the page keys move it, and Enter or F2 moves into a cell's controls, from
|
|
43
53
|
* which Escape returns. The focused position is clamped to the grid's bounds on every render, so
|
|
44
54
|
* rows or columns going away leave focus at the same position.
|
|
45
55
|
*/
|
|
46
|
-
export declare function useGridKeyboard({ rowCount, columnCount, getPageSize, onActivate, onContextMenu, scrollToEntry, }: UseGridKeyboardOptions): {
|
|
56
|
+
export declare function useGridKeyboard({ rowCount, headRowCount, columnCount, getPageSize, onActivate, onContextMenu, scrollToEntry, }: UseGridKeyboardOptions): {
|
|
47
57
|
focusedCell: GridCellPosition;
|
|
48
58
|
getCellProps: GetCellProps;
|
|
49
59
|
gridRef: RefObject<HTMLTableElement | null>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useLayoutEffect, useRef, useState } from "react";
|
|
2
|
-
const
|
|
3
|
-
const
|
|
2
|
+
const focusableControlSelector = 'button, a[href], input, select, textarea, [tabindex]';
|
|
3
|
+
const cellControlSelector = `${focusableControlSelector}, [role="button"]`;
|
|
4
|
+
const navigableCellSelector = 'thead th, thead td, tbody tr[data-index] > td';
|
|
4
5
|
function isHiddenControl(control) {
|
|
5
6
|
return null !== control.closest('[aria-hidden="true"]');
|
|
6
7
|
}
|
|
@@ -17,7 +18,7 @@ function isUnfocusableControl(control) {
|
|
|
17
18
|
}
|
|
18
19
|
function controlsOf(grid, cell) {
|
|
19
20
|
return [
|
|
20
|
-
...cell.querySelectorAll(
|
|
21
|
+
...cell.querySelectorAll(focusableControlSelector)
|
|
21
22
|
].filter((control)=>control.closest('[role="grid"]') === grid ? !isUnfocusableControl(control) : 0 === control.tabIndex);
|
|
22
23
|
}
|
|
23
24
|
function isFromCell(event) {
|
|
@@ -46,7 +47,7 @@ function clamp(value, lowest, highest) {
|
|
|
46
47
|
return Math.min(Math.max(value, lowest), Math.max(highest, lowest));
|
|
47
48
|
}
|
|
48
49
|
function syncControlTabIndexes(grid, enteredCell) {
|
|
49
|
-
for (const control of grid.querySelectorAll(
|
|
50
|
+
for (const control of grid.querySelectorAll(focusableControlSelector)){
|
|
50
51
|
if (control.closest('[role="grid"]') !== grid) continue;
|
|
51
52
|
const cell = ownCellOf(grid, control);
|
|
52
53
|
if (null !== cell && cell !== control && isNavigableCell(grid, cell)) {
|
|
@@ -58,12 +59,13 @@ function syncControlTabIndexes(grid, enteredCell) {
|
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
|
-
function useGridKeyboard({ rowCount, columnCount, getPageSize, onActivate, onContextMenu, scrollToEntry }) {
|
|
62
|
+
function useGridKeyboard({ rowCount, headRowCount, columnCount, getPageSize, onActivate, onContextMenu, scrollToEntry }) {
|
|
62
63
|
const gridRef = useRef(null);
|
|
63
64
|
const [heldCell, setHeldCell] = useState({
|
|
64
65
|
rowIndex: 0,
|
|
65
66
|
columnIndex: 0
|
|
66
67
|
});
|
|
68
|
+
const [heldHeadRowCount, setHeldHeadRowCount] = useState(headRowCount);
|
|
67
69
|
const [inside, setInside] = useState(false);
|
|
68
70
|
const hasFocusRef = useRef(false);
|
|
69
71
|
const pendingFocusRef = useRef(false);
|
|
@@ -73,7 +75,15 @@ function useGridKeyboard({ rowCount, columnCount, getPageSize, onActivate, onCon
|
|
|
73
75
|
rowIndex: clamp(position.rowIndex, 0, lastRow),
|
|
74
76
|
columnIndex: clamp(position.columnIndex, 0, lastColumn)
|
|
75
77
|
});
|
|
76
|
-
|
|
78
|
+
let shiftedCell = heldCell;
|
|
79
|
+
if (headRowCount !== heldHeadRowCount) {
|
|
80
|
+
if (heldCell.rowIndex >= heldHeadRowCount) shiftedCell = {
|
|
81
|
+
...heldCell,
|
|
82
|
+
rowIndex: heldCell.rowIndex + headRowCount - heldHeadRowCount
|
|
83
|
+
};
|
|
84
|
+
setHeldHeadRowCount(headRowCount);
|
|
85
|
+
}
|
|
86
|
+
const focusedCell = clampToGrid(shiftedCell);
|
|
77
87
|
if (!isSamePosition(focusedCell, heldCell)) setHeldCell(focusedCell);
|
|
78
88
|
const enteredCell = inside ? focusedCell : null;
|
|
79
89
|
useLayoutEffect(()=>{
|
|
@@ -111,8 +121,8 @@ function useGridKeyboard({ rowCount, columnCount, getPageSize, onActivate, onCon
|
|
|
111
121
|
const moveTo = (target)=>{
|
|
112
122
|
const next = clampToGrid(target);
|
|
113
123
|
if (isSamePosition(next, focusedCell)) return;
|
|
114
|
-
if (next.rowIndex
|
|
115
|
-
else if (focusedCell.rowIndex
|
|
124
|
+
if (next.rowIndex >= headRowCount) scrollToEntry(next.rowIndex - headRowCount);
|
|
125
|
+
else if (focusedCell.rowIndex >= headRowCount) scrollToEntry(0);
|
|
116
126
|
pendingFocusRef.current = true;
|
|
117
127
|
setHeldCell(next);
|
|
118
128
|
};
|
|
@@ -9,5 +9,8 @@ export interface GridMetrics {
|
|
|
9
9
|
*/
|
|
10
10
|
rightToLeft: boolean;
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* The scroll area's height and the header band's height, kept current as either resizes, and the
|
|
14
|
+
* scroll area's width, kept current in `viewInlineSizeProperty`.
|
|
15
|
+
*/
|
|
13
16
|
export declare function useGridMetrics(scrollRef: RefObject<HTMLElement | null>, headRef: RefObject<HTMLElement | null>): GridMetrics;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useLayoutEffect, useState } from "react";
|
|
2
|
+
const viewInlineSizeProperty = '--data-grid-view-inline-size';
|
|
2
3
|
const initialMetrics = {
|
|
3
4
|
viewportHeight: 0,
|
|
4
5
|
headerHeight: 0,
|
|
@@ -12,8 +13,11 @@ function useGridMetrics(scrollRef, headRef) {
|
|
|
12
13
|
if (null === scrollElement || null === head) return;
|
|
13
14
|
const measure = ()=>{
|
|
14
15
|
const viewportHeight = scrollElement.clientHeight;
|
|
16
|
+
const viewportWidth = scrollElement.clientWidth;
|
|
15
17
|
const headerHeight = head.offsetHeight;
|
|
16
18
|
const rightToLeft = 'rtl' === getComputedStyle(scrollElement).direction;
|
|
19
|
+
if (viewportWidth > 0) scrollElement.style.setProperty(viewInlineSizeProperty, `${viewportWidth}px`);
|
|
20
|
+
else scrollElement.style.removeProperty(viewInlineSizeProperty);
|
|
17
21
|
setMetrics((current)=>current.viewportHeight === viewportHeight && current.headerHeight === headerHeight && current.rightToLeft === rightToLeft ? current : {
|
|
18
22
|
viewportHeight,
|
|
19
23
|
headerHeight,
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { RowData, SortingState } from '@tanstack/react-table';
|
|
2
|
+
import type { DataGridColumnDef } from './columns.js';
|
|
3
|
+
import type { DataGridFilterValue, DataGridQuery } from './types.js';
|
|
4
|
+
export interface UseGridQueryOptions<Row extends RowData> {
|
|
5
|
+
columns: readonly DataGridColumnDef<Row, unknown>[];
|
|
6
|
+
initialQuery?: Partial<DataGridQuery>;
|
|
7
|
+
initialSorting?: SortingState;
|
|
8
|
+
/** Makes the query controlled: it is shown, normalised, and the setters only report changes. */
|
|
9
|
+
query?: DataGridQuery;
|
|
10
|
+
/**
|
|
11
|
+
* The shown query changed. Called from the setter that changed it, in the same event, with the
|
|
12
|
+
* new query; for a controlled query, from a layout effect once the app passes a different one.
|
|
13
|
+
* `previousQuery` is the one it heard of before, the query the rows on screen were for.
|
|
14
|
+
*/
|
|
15
|
+
onChange: (query: DataGridQuery, previousQuery: DataGridQuery) => void;
|
|
16
|
+
/**
|
|
17
|
+
* A setter changed the query: called in the same event with the new query, after `onChange` when
|
|
18
|
+
* the query is the grid's own.
|
|
19
|
+
*/
|
|
20
|
+
onQueryChange?: (query: DataGridQuery) => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The shown query and its setters. The setters build on each other: one called after another in
|
|
24
|
+
* the same event starts from the query the earlier one made, not from the one this render shows.
|
|
25
|
+
*/
|
|
26
|
+
export interface GridQuery {
|
|
27
|
+
query: DataGridQuery;
|
|
28
|
+
/**
|
|
29
|
+
* The app has passed a controlled query that `onChange` has not heard of yet, as it will in this
|
|
30
|
+
* commit's layout effects. Until then the rows on screen answer a query the grid has not acted on.
|
|
31
|
+
*/
|
|
32
|
+
pendingChange: boolean;
|
|
33
|
+
/** `countActiveCriteria(query)`. */
|
|
34
|
+
activeCount: number;
|
|
35
|
+
setSorting: (sorting: SortingState) => void;
|
|
36
|
+
/** An empty value (after trimming) removes the filter. */
|
|
37
|
+
setFilter: (columnId: string, value: DataGridFilterValue | undefined) => void;
|
|
38
|
+
setMatchMode: (matchMode: DataGridQuery['matchMode']) => void;
|
|
39
|
+
setSearch: (term: string) => void;
|
|
40
|
+
/** Removes every filter and the search; keeps the sort and the match mode. */
|
|
41
|
+
clearFilters: () => void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The grid's query: its own, started from `initialQuery` and `initialSorting`, or the app's when
|
|
45
|
+
* `query` is given. Either way it is normalised against `columns`, so it holds only what can
|
|
46
|
+
* apply, and `onChange` hears of every change to it, whichever side made it.
|
|
47
|
+
*/
|
|
48
|
+
export declare function useGridQuery<Row extends RowData>({ columns, initialQuery, initialSorting, query, onChange, onQueryChange, }: UseGridQueryOptions<Row>): GridQuery;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
2
|
+
import { countActiveCriteria, isSameQuery, normaliseQuery } from "./query.js";
|
|
3
|
+
import { useLatest } from "./useLatest.js";
|
|
4
|
+
function useGridQuery({ columns, initialQuery, initialSorting = [], query, onChange, onQueryChange }) {
|
|
5
|
+
const [shownQuery, setShownQuery] = useState(()=>normaliseQuery(query ?? {
|
|
6
|
+
...initialQuery,
|
|
7
|
+
sorting: initialQuery?.sorting ?? initialSorting
|
|
8
|
+
}, columns));
|
|
9
|
+
const normalisedQuery = normaliseQuery(query ?? shownQuery, columns);
|
|
10
|
+
if (!isSameQuery(normalisedQuery, shownQuery)) setShownQuery(normalisedQuery);
|
|
11
|
+
const [actedOnQuery, setActedOnQuery] = useState(shownQuery);
|
|
12
|
+
const pendingChange = !isSameQuery(shownQuery, actedOnQuery);
|
|
13
|
+
const actedOnQueryRef = useRef(actedOnQuery);
|
|
14
|
+
const actOn = (nextQuery)=>{
|
|
15
|
+
const previousQuery = actedOnQueryRef.current;
|
|
16
|
+
actedOnQueryRef.current = nextQuery;
|
|
17
|
+
setActedOnQuery(nextQuery);
|
|
18
|
+
onChange(nextQuery, previousQuery);
|
|
19
|
+
};
|
|
20
|
+
const actOnRef = useLatest(actOn);
|
|
21
|
+
useLayoutEffect(()=>{
|
|
22
|
+
if (pendingChange) actOnRef.current(shownQuery);
|
|
23
|
+
}, [
|
|
24
|
+
pendingChange,
|
|
25
|
+
shownQuery,
|
|
26
|
+
actOnRef
|
|
27
|
+
]);
|
|
28
|
+
const latestQueryRef = useLatest(shownQuery);
|
|
29
|
+
const update = (change)=>{
|
|
30
|
+
const latestQuery = latestQueryRef.current;
|
|
31
|
+
const nextQuery = normaliseQuery({
|
|
32
|
+
...latestQuery,
|
|
33
|
+
...change
|
|
34
|
+
}, columns);
|
|
35
|
+
if (isSameQuery(nextQuery, latestQuery)) return;
|
|
36
|
+
latestQueryRef.current = nextQuery;
|
|
37
|
+
if (void 0 === query) {
|
|
38
|
+
setShownQuery(nextQuery);
|
|
39
|
+
actOn(nextQuery);
|
|
40
|
+
}
|
|
41
|
+
onQueryChange?.(nextQuery);
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
query: shownQuery,
|
|
45
|
+
pendingChange,
|
|
46
|
+
activeCount: countActiveCriteria(shownQuery),
|
|
47
|
+
setSorting: (sorting)=>update({
|
|
48
|
+
sorting
|
|
49
|
+
}),
|
|
50
|
+
setFilter: (columnId, value)=>{
|
|
51
|
+
const { [columnId]: _replaced, ...otherFilters } = latestQueryRef.current.filters;
|
|
52
|
+
update({
|
|
53
|
+
filters: void 0 === value ? otherFilters : {
|
|
54
|
+
...otherFilters,
|
|
55
|
+
[columnId]: value
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
setMatchMode: (matchMode)=>update({
|
|
60
|
+
matchMode
|
|
61
|
+
}),
|
|
62
|
+
setSearch: (term)=>update({
|
|
63
|
+
search: term
|
|
64
|
+
}),
|
|
65
|
+
clearFilters: ()=>update({
|
|
66
|
+
filters: {},
|
|
67
|
+
search: ''
|
|
68
|
+
})
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export { useGridQuery };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "./DataTable_module.css";
|
|
2
2
|
const DataTable_module = {
|
|
3
|
-
scroll: "ui0-
|
|
4
|
-
table: "ui0-
|
|
5
|
-
caption: "ui0-
|
|
6
|
-
head: "ui0-
|
|
7
|
-
headerCell: "ui0-
|
|
8
|
-
sortButton: "ui0-
|
|
9
|
-
sortIcon: "ui0-
|
|
10
|
-
row: "ui0-
|
|
11
|
-
cell: "ui0-
|
|
3
|
+
scroll: "ui0-9-0-scroll-vHFjf",
|
|
4
|
+
table: "ui0-9-0-table-H20Eb",
|
|
5
|
+
caption: "ui0-9-0-caption-glW7e",
|
|
6
|
+
head: "ui0-9-0-head-KQpiR",
|
|
7
|
+
headerCell: "ui0-9-0-headerCell-Bm5aB",
|
|
8
|
+
sortButton: "ui0-9-0-sortButton-b2Ze6",
|
|
9
|
+
sortIcon: "ui0-9-0-sortIcon-sc98J",
|
|
10
|
+
row: "ui0-9-0-row-oItIj",
|
|
11
|
+
cell: "ui0-9-0-cell-L4VgS"
|
|
12
12
|
};
|
|
13
13
|
export default DataTable_module;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
.ui0-
|
|
1
|
+
.ui0-9-0-scroll-vHFjf {
|
|
2
2
|
border: 1px solid var(--color-border);
|
|
3
3
|
border-radius: var(--radius-popup);
|
|
4
4
|
background: var(--color-surface-raised);
|
|
5
5
|
overflow-x: auto;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
.ui0-
|
|
8
|
+
.ui0-9-0-scroll-vHFjf[data-bare] {
|
|
9
9
|
background: none;
|
|
10
10
|
border: 0;
|
|
11
11
|
border-radius: 0;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
.ui0-
|
|
14
|
+
.ui0-9-0-table-H20Eb {
|
|
15
15
|
border-collapse: collapse;
|
|
16
16
|
width: 100%;
|
|
17
17
|
font-family: var(--font-body);
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
font-variant-numeric: tabular-nums;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
.ui0-
|
|
23
|
+
.ui0-9-0-caption-glW7e {
|
|
24
24
|
padding: var(--space-3) var(--space-5);
|
|
25
25
|
text-align: left;
|
|
26
26
|
font-family: var(--font-sans);
|
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
caption-side: top;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
.ui0-
|
|
32
|
+
.ui0-9-0-caption-glW7e[data-hidden] {
|
|
33
33
|
padding: 0;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
.ui0-
|
|
36
|
+
.ui0-9-0-head-KQpiR {
|
|
37
37
|
background: var(--color-surface-2);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
.ui0-
|
|
40
|
+
.ui0-9-0-headerCell-Bm5aB {
|
|
41
41
|
padding: var(--space-1) var(--space-3);
|
|
42
42
|
border-block: 1px solid var(--color-border);
|
|
43
43
|
text-align: left;
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
font-weight: 500;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
.ui0-
|
|
53
|
+
.ui0-9-0-sortButton-b2Ze6 {
|
|
54
54
|
align-items: center;
|
|
55
55
|
gap: var(--space-1);
|
|
56
56
|
min-height: var(--size-touch);
|
|
@@ -65,22 +65,22 @@
|
|
|
65
65
|
display: inline-flex;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
.ui0-
|
|
68
|
+
.ui0-9-0-sortIcon-sc98J:after {
|
|
69
69
|
content: "↕";
|
|
70
70
|
color: var(--color-text-subtle);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
.ui0-
|
|
73
|
+
.ui0-9-0-sortIcon-sc98J[data-direction="asc"]:after {
|
|
74
74
|
content: "↑";
|
|
75
75
|
color: var(--color-link);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
.ui0-
|
|
78
|
+
.ui0-9-0-sortIcon-sc98J[data-direction="desc"]:after {
|
|
79
79
|
content: "↓";
|
|
80
80
|
color: var(--color-link);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
.ui0-
|
|
83
|
+
.ui0-9-0-row-oItIj {
|
|
84
84
|
border-bottom: 1px solid var(--color-border);
|
|
85
85
|
transition-property: background-color;
|
|
86
86
|
transition-duration: var(--motion-duration-1);
|
|
@@ -88,33 +88,33 @@
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
@media (hover: hover) {
|
|
91
|
-
.ui0-
|
|
91
|
+
.ui0-9-0-row-oItIj:hover {
|
|
92
92
|
background: var(--color-surface-2);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
.ui0-
|
|
96
|
+
.ui0-9-0-cell-L4VgS {
|
|
97
97
|
height: 2.75rem;
|
|
98
98
|
padding: var(--space-2) var(--space-3);
|
|
99
99
|
vertical-align: middle;
|
|
100
100
|
white-space: nowrap;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
.ui0-
|
|
103
|
+
.ui0-9-0-headerCell-Bm5aB:first-child, .ui0-9-0-cell-L4VgS:first-child {
|
|
104
104
|
padding-inline-start: var(--space-5);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
.ui0-
|
|
107
|
+
.ui0-9-0-headerCell-Bm5aB:last-child, .ui0-9-0-cell-L4VgS:last-child {
|
|
108
108
|
padding-inline-end: var(--space-5);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
.ui0-
|
|
111
|
+
.ui0-9-0-table-H20Eb[data-stacked] .ui0-9-0-row-oItIj {
|
|
112
112
|
gap: var(--space-1);
|
|
113
113
|
padding: var(--space-3) var(--space-5);
|
|
114
114
|
display: grid;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
.ui0-
|
|
117
|
+
.ui0-9-0-table-H20Eb[data-stacked] .ui0-9-0-cell-L4VgS {
|
|
118
118
|
gap: var(--space-2);
|
|
119
119
|
white-space: normal;
|
|
120
120
|
overflow-wrap: anywhere;
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
display: grid;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
.ui0-
|
|
127
|
+
.ui0-9-0-table-H20Eb[data-stacked] .ui0-9-0-cell-L4VgS:before {
|
|
128
128
|
content: attr(data-label);
|
|
129
129
|
font-family: var(--font-mono);
|
|
130
130
|
font-size: var(--text-2xs);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import "./DatePicker_module.css";
|
|
2
2
|
const DatePicker_module = {
|
|
3
|
-
popup: "ui0-
|
|
4
|
-
header: "ui0-
|
|
5
|
-
month: "ui0-
|
|
6
|
-
previous: "ui0-
|
|
7
|
-
next: "ui0-
|
|
8
|
-
gridSlot: "ui0-
|
|
9
|
-
grid: "ui0-
|
|
10
|
-
weekday: "ui0-
|
|
11
|
-
day: "ui0-
|
|
12
|
-
footer: "ui0-
|
|
3
|
+
popup: "ui0-9-0-popup-KehYf",
|
|
4
|
+
header: "ui0-9-0-header-zwN0_",
|
|
5
|
+
month: "ui0-9-0-month-kmJCd",
|
|
6
|
+
previous: "ui0-9-0-previous-zWGPB",
|
|
7
|
+
next: "ui0-9-0-next-caCSG",
|
|
8
|
+
gridSlot: "ui0-9-0-gridSlot-XSqqc",
|
|
9
|
+
grid: "ui0-9-0-grid-OEI6m",
|
|
10
|
+
weekday: "ui0-9-0-weekday-BLI2K",
|
|
11
|
+
day: "ui0-9-0-day-DOQIC",
|
|
12
|
+
footer: "ui0-9-0-footer-rvxzg"
|
|
13
13
|
};
|
|
14
14
|
export default DatePicker_module;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
.ui0-
|
|
1
|
+
.ui0-9-0-popup-KehYf {
|
|
2
2
|
width: 22rem;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
.ui0-
|
|
5
|
+
.ui0-9-0-header-zwN0_ {
|
|
6
6
|
justify-content: space-between;
|
|
7
7
|
align-items: center;
|
|
8
8
|
gap: var(--space-2);
|
|
9
9
|
display: flex;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
.ui0-
|
|
12
|
+
.ui0-9-0-month-kmJCd {
|
|
13
13
|
color: var(--color-text);
|
|
14
14
|
font-family: var(--font-sans);
|
|
15
15
|
font-size: var(--text-md);
|
|
@@ -19,35 +19,35 @@
|
|
|
19
19
|
flex: 1;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
.ui0-
|
|
22
|
+
.ui0-9-0-previous-zWGPB svg {
|
|
23
23
|
transform: rotate(90deg);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
.ui0-
|
|
26
|
+
.ui0-9-0-next-caCSG svg, .ui0-9-0-header-zwN0_[data-direction="rtl"] .ui0-9-0-previous-zWGPB svg {
|
|
27
27
|
transform: rotate(-90deg);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
.ui0-
|
|
30
|
+
.ui0-9-0-header-zwN0_[data-direction="rtl"] .ui0-9-0-next-caCSG svg {
|
|
31
31
|
transform: rotate(90deg);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
.ui0-
|
|
34
|
+
.ui0-9-0-previous-zWGPB[aria-disabled="true"], .ui0-9-0-next-caCSG[aria-disabled="true"] {
|
|
35
35
|
cursor: not-allowed;
|
|
36
36
|
opacity: .45;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
.ui0-
|
|
39
|
+
.ui0-9-0-popup-KehYf[data-side="top"] .ui0-9-0-gridSlot-XSqqc {
|
|
40
40
|
min-height: calc(7 * var(--size-touch));
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
.ui0-
|
|
43
|
+
.ui0-9-0-grid-OEI6m {
|
|
44
44
|
border-collapse: separate;
|
|
45
45
|
border-spacing: 0;
|
|
46
46
|
table-layout: fixed;
|
|
47
47
|
width: 100%;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
.ui0-
|
|
50
|
+
.ui0-9-0-weekday-BLI2K {
|
|
51
51
|
height: var(--size-touch);
|
|
52
52
|
color: var(--color-text-muted);
|
|
53
53
|
font-size: var(--text-sm);
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
font-weight: 500;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
.ui0-
|
|
59
|
+
.ui0-9-0-day-DOQIC {
|
|
60
60
|
height: var(--size-touch);
|
|
61
61
|
border-radius: var(--radius-md);
|
|
62
62
|
color: var(--color-text);
|
|
@@ -71,42 +71,42 @@
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
@media (hover: hover) {
|
|
74
|
-
.ui0-
|
|
74
|
+
.ui0-9-0-day-DOQIC:hover:not([aria-disabled="true"], [aria-selected="true"]) {
|
|
75
75
|
background: var(--color-surface-2);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
.ui0-
|
|
79
|
+
.ui0-9-0-day-DOQIC[aria-current="date"] {
|
|
80
80
|
border: 1px solid var(--color-accent);
|
|
81
81
|
font-weight: 600;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
.ui0-
|
|
84
|
+
.ui0-9-0-day-DOQIC[aria-selected="true"] {
|
|
85
85
|
background: var(--color-selected);
|
|
86
86
|
color: var(--color-selected-text);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
.ui0-
|
|
89
|
+
.ui0-9-0-day-DOQIC[aria-disabled="true"] {
|
|
90
90
|
cursor: not-allowed;
|
|
91
91
|
opacity: .45;
|
|
92
92
|
text-decoration: line-through;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
@media (forced-colors: active) {
|
|
96
|
-
.ui0-
|
|
96
|
+
.ui0-9-0-day-DOQIC[aria-selected="true"] {
|
|
97
97
|
forced-color-adjust: none;
|
|
98
98
|
color: highlighttext;
|
|
99
99
|
background: highlight;
|
|
100
100
|
outline-color: canvastext;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
.ui0-
|
|
103
|
+
.ui0-9-0-day-DOQIC[aria-disabled="true"] {
|
|
104
104
|
opacity: 1;
|
|
105
105
|
color: graytext;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
.ui0-
|
|
109
|
+
.ui0-9-0-footer-rvxzg {
|
|
110
110
|
justify-content: flex-end;
|
|
111
111
|
display: flex;
|
|
112
112
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "./Descriptions_module.css";
|
|
2
2
|
const Descriptions_module = {
|
|
3
|
-
root: "ui0-
|
|
4
|
-
heading: "ui0-
|
|
5
|
-
list: "ui0-
|
|
6
|
-
group: "ui0-
|
|
3
|
+
root: "ui0-9-0-root-bQlQQ",
|
|
4
|
+
heading: "ui0-9-0-heading-aHnDT",
|
|
5
|
+
list: "ui0-9-0-list-Qwuyt",
|
|
6
|
+
group: "ui0-9-0-group-fd_ih"
|
|
7
7
|
};
|
|
8
8
|
export default Descriptions_module;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
.ui0-
|
|
1
|
+
.ui0-9-0-root-bQlQQ {
|
|
2
2
|
gap: var(--space-3);
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
display: flex;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
.ui0-
|
|
7
|
+
.ui0-9-0-heading-aHnDT {
|
|
8
8
|
color: var(--color-text);
|
|
9
9
|
font-size: var(--text-h3);
|
|
10
10
|
font-family: var(--font-display);
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
margin: 0;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
.ui0-
|
|
19
|
+
.ui0-9-0-list-Qwuyt {
|
|
20
20
|
gap: var(--space-4);
|
|
21
21
|
grid-template-columns: minmax(0, 1fr);
|
|
22
22
|
margin: 0;
|
|
23
23
|
display: grid;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
.ui0-
|
|
26
|
+
.ui0-9-0-group-fd_ih {
|
|
27
27
|
gap: var(--space-1);
|
|
28
28
|
overflow-wrap: anywhere;
|
|
29
29
|
flex-direction: column;
|
|
@@ -32,19 +32,19 @@
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
@media (width >= 40rem) {
|
|
35
|
-
.ui0-
|
|
35
|
+
.ui0-9-0-list-Qwuyt[data-columns="2"] {
|
|
36
36
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
.ui0-
|
|
39
|
+
.ui0-9-0-list-Qwuyt[data-columns="3"] {
|
|
40
40
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
.ui0-
|
|
43
|
+
.ui0-9-0-group-fd_ih[data-span="2"] {
|
|
44
44
|
grid-column: span 2;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
.ui0-
|
|
47
|
+
.ui0-9-0-group-fd_ih[data-span="3"] {
|
|
48
48
|
grid-column: span 3;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "./Dialog_module.css";
|
|
2
2
|
const Dialog_module = {
|
|
3
|
-
viewport: "ui0-
|
|
4
|
-
header: "ui0-
|
|
5
|
-
heading: "ui0-
|
|
6
|
-
headerEnd: "ui0-
|
|
7
|
-
handle: "ui0-
|
|
8
|
-
description: "ui0-
|
|
9
|
-
body: "ui0-
|
|
10
|
-
footer: "ui0-
|
|
3
|
+
viewport: "ui0-9-0-viewport-nOzLZ",
|
|
4
|
+
header: "ui0-9-0-header-KgP3n",
|
|
5
|
+
heading: "ui0-9-0-heading-EfBAx",
|
|
6
|
+
headerEnd: "ui0-9-0-headerEnd-sEInd",
|
|
7
|
+
handle: "ui0-9-0-handle-z1dbF",
|
|
8
|
+
description: "ui0-9-0-description-ZV1a4",
|
|
9
|
+
body: "ui0-9-0-body-mavCB",
|
|
10
|
+
footer: "ui0-9-0-footer-CAuV7"
|
|
11
11
|
};
|
|
12
12
|
export default Dialog_module;
|