@macrostrat/data-sheet 4.1.1 → 4.2.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/CHANGELOG.md +34 -0
- package/dist/actions/builtin.cjs +1 -1
- package/dist/actions/builtin.cjs.map +1 -1
- package/dist/actions/builtin.d.ts +0 -2
- package/dist/actions/builtin.js +1 -1
- package/dist/actions/builtin.js.map +1 -1
- package/dist/actions/clipboard.cjs +1 -1
- package/dist/actions/clipboard.cjs.map +1 -1
- package/dist/actions/clipboard.d.ts +3 -2
- package/dist/actions/clipboard.js +1 -1
- package/dist/actions/clipboard.js.map +1 -1
- package/dist/actions/column-controls.cjs +7 -196
- package/dist/actions/column-controls.cjs.map +1 -1
- package/dist/actions/column-controls.d.ts +1 -1
- package/dist/actions/column-controls.js +5 -194
- package/dist/actions/column-controls.js.map +1 -1
- package/dist/actions/column-filter.cjs +24 -73
- package/dist/actions/column-filter.cjs.map +1 -1
- package/dist/actions/column-filter.d.ts +6 -4
- package/dist/actions/column-filter.js +25 -74
- package/dist/actions/column-filter.js.map +1 -1
- package/dist/actions/context.cjs +147 -0
- package/dist/actions/context.cjs.map +1 -0
- package/dist/actions/context.d.ts +93 -0
- package/dist/actions/context.js +145 -0
- package/dist/actions/context.js.map +1 -0
- package/dist/actions/edit-actions.cjs.map +1 -1
- package/dist/actions/edit-actions.d.ts +3 -1
- package/dist/actions/edit-actions.js.map +1 -1
- package/dist/actions/index.d.ts +2 -3
- package/dist/actions/selection.cjs +70 -115
- package/dist/actions/selection.cjs.map +1 -1
- package/dist/actions/selection.d.ts +22 -12
- package/dist/actions/selection.js +71 -114
- package/dist/actions/selection.js.map +1 -1
- package/dist/actions/table-actions.cjs +41 -0
- package/dist/actions/table-actions.cjs.map +1 -0
- package/dist/actions/{table-controls.d.ts → table-actions.d.ts} +0 -4
- package/dist/actions/{table-controls.js → table-actions.js} +2 -23
- package/dist/actions/table-actions.js.map +1 -0
- package/dist/actions/types.d.ts +11 -89
- package/dist/components/cell-detail.cjs +6 -6
- package/dist/components/cell-detail.cjs.map +1 -1
- package/dist/components/cell-detail.js +1 -1
- package/dist/components/colors.cjs.map +1 -1
- package/dist/components/colors.js.map +1 -1
- package/dist/components/editor-popup.cjs +7 -7
- package/dist/components/editor-popup.cjs.map +1 -1
- package/dist/components/editor-popup.js +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/indicators/filter-and-sort.cjs +378 -0
- package/dist/components/indicators/filter-and-sort.cjs.map +1 -0
- package/dist/components/indicators/filter-and-sort.d.ts +59 -0
- package/dist/components/indicators/filter-and-sort.js +376 -0
- package/dist/components/indicators/filter-and-sort.js.map +1 -0
- package/dist/components/indicators/filter-and-sort.module.sass.cjs +16 -0
- package/dist/components/indicators/filter-and-sort.module.sass.cjs.map +1 -0
- package/dist/components/indicators/filter-and-sort.module.sass.js +14 -0
- package/dist/components/indicators/filter-and-sort.module.sass.js.map +1 -0
- package/dist/components/indicators/index.d.ts +4 -0
- package/dist/components/indicators/selection.cjs +113 -0
- package/dist/components/indicators/selection.cjs.map +1 -0
- package/dist/components/indicators/selection.d.ts +3 -0
- package/dist/components/indicators/selection.js +111 -0
- package/dist/components/indicators/selection.js.map +1 -0
- package/dist/components/indicators/selection.module.sass.cjs +19 -0
- package/dist/components/indicators/selection.module.sass.cjs.map +1 -0
- package/dist/components/indicators/selection.module.sass.js +17 -0
- package/dist/components/indicators/selection.module.sass.js.map +1 -0
- package/dist/components/indicators/unified-filters.cjs +130 -0
- package/dist/components/indicators/unified-filters.cjs.map +1 -0
- package/dist/components/indicators/unified-filters.d.ts +10 -0
- package/dist/components/indicators/unified-filters.js +130 -0
- package/dist/components/indicators/unified-filters.js.map +1 -0
- package/dist/components/indicators/view-info.cjs +59 -0
- package/dist/components/indicators/view-info.cjs.map +1 -0
- package/dist/components/{view-info.d.ts → indicators/view-info.d.ts} +1 -0
- package/dist/components/{view-info.js → indicators/view-info.js} +17 -13
- package/dist/components/indicators/view-info.js.map +1 -0
- package/dist/components/text-areas.cjs +5 -5
- package/dist/components/text-areas.cjs.map +1 -1
- package/dist/components/text-areas.js +1 -1
- package/dist/components/toolbars/actions-toolbar.cjs +185 -0
- package/dist/components/toolbars/actions-toolbar.cjs.map +1 -0
- package/dist/{actions/toolbar.d.ts → components/toolbars/actions-toolbar.d.ts} +9 -5
- package/dist/{actions/toolbar.js → components/toolbars/actions-toolbar.js} +37 -112
- package/dist/components/toolbars/actions-toolbar.js.map +1 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.cjs +29 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.cjs.map +1 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.js +27 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.js.map +1 -0
- package/dist/components/toolbars/active-filters.cjs +120 -0
- package/dist/components/toolbars/active-filters.cjs.map +1 -0
- package/dist/{actions/filters.d.ts → components/toolbars/active-filters.d.ts} +3 -3
- package/dist/components/toolbars/active-filters.js +120 -0
- package/dist/components/toolbars/active-filters.js.map +1 -0
- package/dist/components/toolbars/index.d.ts +2 -0
- package/dist/data-panel.cjs +291 -0
- package/dist/data-panel.cjs.map +1 -0
- package/dist/data-panel.d.ts +110 -0
- package/dist/data-panel.js +289 -0
- package/dist/data-panel.js.map +1 -0
- package/dist/data-panel.module.sass.cjs +40 -0
- package/dist/data-panel.module.sass.cjs.map +1 -0
- package/dist/data-panel.module.sass.js +38 -0
- package/dist/data-panel.module.sass.js.map +1 -0
- package/dist/{core.cjs → data-sheet.cjs} +123 -190
- package/dist/data-sheet.cjs.map +1 -0
- package/dist/data-sheet.css +241 -13
- package/dist/data-sheet.d.ts +16 -0
- package/dist/{core.js → data-sheet.js} +92 -159
- package/dist/data-sheet.js.map +1 -0
- package/dist/data-view.cjs +47 -0
- package/dist/data-view.cjs.map +1 -0
- package/dist/data-view.d.ts +15 -0
- package/dist/data-view.js +45 -0
- package/dist/data-view.js.map +1 -0
- package/dist/filters/operators.cjs +19 -2
- package/dist/filters/operators.cjs.map +1 -1
- package/dist/filters/operators.d.ts +4 -3
- package/dist/filters/operators.js +19 -2
- package/dist/filters/operators.js.map +1 -1
- package/dist/index.cjs +106 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +76 -17
- package/dist/index.js.map +1 -1
- package/dist/notifications.cjs +4 -4
- package/dist/notifications.cjs.map +1 -1
- package/dist/notifications.js +1 -1
- package/dist/postgrest-table/data-loaders.cjs +128 -95
- package/dist/postgrest-table/data-loaders.cjs.map +1 -1
- package/dist/postgrest-table/data-loaders.d.ts +52 -82
- package/dist/postgrest-table/data-loaders.js +109 -76
- package/dist/postgrest-table/data-loaders.js.map +1 -1
- package/dist/postgrest-table/index.cjs +18 -17
- package/dist/postgrest-table/index.cjs.map +1 -1
- package/dist/postgrest-table/index.d.ts +4 -3
- package/dist/postgrest-table/index.js +9 -8
- package/dist/postgrest-table/index.js.map +1 -1
- package/dist/{utils → provider}/column-spec.cjs +23 -9
- package/dist/provider/column-spec.cjs.map +1 -0
- package/dist/{utils → provider}/column-spec.d.ts +73 -2
- package/dist/{utils → provider}/column-spec.js +24 -10
- package/dist/provider/column-spec.js.map +1 -0
- package/dist/provider/core.cjs +382 -0
- package/dist/provider/core.cjs.map +1 -0
- package/dist/provider/core.d.ts +74 -0
- package/dist/provider/core.js +380 -0
- package/dist/provider/core.js.map +1 -0
- package/dist/provider/index.d.ts +7 -0
- package/dist/provider/interactions.cjs +128 -0
- package/dist/provider/interactions.cjs.map +1 -0
- package/dist/provider/interactions.d.ts +39 -0
- package/dist/provider/interactions.js +128 -0
- package/dist/provider/interactions.js.map +1 -0
- package/dist/provider/selection.cjs +29 -0
- package/dist/provider/selection.cjs.map +1 -0
- package/dist/provider/selection.d.ts +9 -0
- package/dist/provider/selection.js +29 -0
- package/dist/provider/selection.js.map +1 -0
- package/dist/provider/table-data.cjs +92 -0
- package/dist/provider/table-data.cjs.map +1 -0
- package/dist/provider/table-data.d.ts +81 -0
- package/dist/provider/table-data.js +92 -0
- package/dist/provider/table-data.js.map +1 -0
- package/dist/provider/types.cjs +22 -0
- package/dist/provider/types.cjs.map +1 -0
- package/dist/provider/types.d.ts +256 -0
- package/dist/provider/types.js +22 -0
- package/dist/provider/types.js.map +1 -0
- package/dist/{zustand-store.cjs → provider/zustand-store.cjs} +36 -23
- package/dist/provider/zustand-store.cjs.map +1 -0
- package/dist/{zustand-store.js → provider/zustand-store.js} +21 -8
- package/dist/provider/zustand-store.js.map +1 -0
- package/dist/{cell-renderer.cjs → renderers/cell-renderer.cjs} +67 -34
- package/dist/renderers/cell-renderer.cjs.map +1 -0
- package/dist/{cell-renderer.d.ts → renderers/cell-renderer.d.ts} +1 -2
- package/dist/{cell-renderer.js → renderers/cell-renderer.js} +65 -32
- package/dist/renderers/cell-renderer.js.map +1 -0
- package/dist/renderers/column-header-cell.cjs +21 -13
- package/dist/renderers/column-header-cell.cjs.map +1 -1
- package/dist/renderers/column-header-cell.d.ts +3 -2
- package/dist/renderers/column-header-cell.js +20 -12
- package/dist/renderers/column-header-cell.js.map +1 -1
- package/dist/renderers/index.d.ts +1 -0
- package/dist/types.cjs +7 -19
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +117 -229
- package/dist/types.js +7 -19
- package/dist/types.js.map +1 -1
- package/dist/utils/atoms.cjs +24 -0
- package/dist/utils/atoms.cjs.map +1 -0
- package/dist/utils/atoms.d.ts +4 -0
- package/dist/utils/atoms.js +24 -0
- package/dist/utils/atoms.js.map +1 -0
- package/dist/utils/debug-overlay.cjs.map +1 -1
- package/dist/utils/debug-overlay.js.map +1 -1
- package/dist/utils/index.d.ts +2 -3
- package/dist/utils/key-handling.cjs +140 -139
- package/dist/utils/key-handling.cjs.map +1 -1
- package/dist/utils/key-handling.d.ts +4 -2
- package/dist/utils/key-handling.js +136 -135
- package/dist/utils/key-handling.js.map +1 -1
- package/dist/utils/validation.cjs +6 -1
- package/dist/utils/validation.cjs.map +1 -1
- package/dist/utils/validation.d.ts +1 -1
- package/dist/utils/validation.js +6 -1
- package/dist/utils/validation.js.map +1 -1
- package/package.json +4 -3
- package/src/actions/builtin.ts +1 -4
- package/src/actions/clipboard.ts +4 -3
- package/src/actions/column-controls.ts +12 -245
- package/src/actions/column-filter.ts +28 -92
- package/src/actions/context.ts +299 -0
- package/src/actions/edit-actions.ts +3 -1
- package/src/actions/index.ts +2 -3
- package/src/actions/selection.ts +109 -156
- package/src/actions/{table-controls.ts → table-actions.ts} +0 -24
- package/src/actions/types.ts +17 -101
- package/src/components/colors.ts +1 -1
- package/src/components/index.ts +2 -1
- package/src/components/indicators/filter-and-sort.module.sass +13 -0
- package/src/components/indicators/filter-and-sort.ts +478 -0
- package/src/components/indicators/index.ts +4 -0
- package/src/components/indicators/selection.module.sass +22 -0
- package/src/components/indicators/selection.ts +141 -0
- package/src/components/indicators/unified-filters.ts +161 -0
- package/src/components/{view-info.ts → indicators/view-info.ts} +16 -27
- package/src/{actions/toolbar.module.sass → components/toolbars/actions-toolbar.module.sass} +17 -4
- package/src/{actions/toolbar.ts → components/toolbars/actions-toolbar.ts} +49 -150
- package/src/components/toolbars/active-filters.ts +150 -0
- package/src/components/toolbars/index.ts +2 -0
- package/src/data-panel.module.sass +185 -0
- package/src/data-panel.ts +556 -0
- package/src/{core.ts → data-sheet.ts} +145 -330
- package/src/data-view.ts +70 -0
- package/src/filters/operators.ts +33 -3
- package/src/index.ts +4 -3
- package/src/postgrest-table/data-loaders.ts +244 -171
- package/src/postgrest-table/index.ts +10 -9
- package/src/{utils → provider}/column-spec.ts +30 -15
- package/src/provider/core.ts +585 -0
- package/src/provider/index.ts +7 -0
- package/src/provider/interactions.ts +161 -0
- package/src/provider/selection.ts +31 -0
- package/src/provider/table-data.ts +178 -0
- package/src/provider/types.ts +273 -0
- package/src/{zustand-store.ts → provider/zustand-store.ts} +35 -14
- package/src/{cell-renderer.ts → renderers/cell-renderer.ts} +140 -57
- package/src/renderers/column-header-cell.ts +21 -14
- package/src/renderers/index.ts +1 -0
- package/src/types.ts +137 -239
- package/src/utils/atoms.ts +28 -0
- package/src/utils/debug-overlay.ts +1 -1
- package/src/utils/index.ts +2 -8
- package/src/utils/key-handling.ts +170 -164
- package/src/utils/validation.ts +7 -2
- package/dist/actions/filters.cjs +0 -139
- package/dist/actions/filters.cjs.map +0 -1
- package/dist/actions/filters.js +0 -139
- package/dist/actions/filters.js.map +0 -1
- package/dist/actions/table-controls.cjs +0 -62
- package/dist/actions/table-controls.cjs.map +0 -1
- package/dist/actions/table-controls.js.map +0 -1
- package/dist/actions/toolbar.cjs +0 -260
- package/dist/actions/toolbar.cjs.map +0 -1
- package/dist/actions/toolbar.js.map +0 -1
- package/dist/actions/toolbar.module.sass.cjs +0 -27
- package/dist/actions/toolbar.module.sass.cjs.map +0 -1
- package/dist/actions/toolbar.module.sass.js +0 -25
- package/dist/actions/toolbar.module.sass.js.map +0 -1
- package/dist/cell-renderer.cjs.map +0 -1
- package/dist/cell-renderer.js.map +0 -1
- package/dist/components/view-info.cjs +0 -55
- package/dist/components/view-info.cjs.map +0 -1
- package/dist/components/view-info.js.map +0 -1
- package/dist/core.cjs.map +0 -1
- package/dist/core.d.ts +0 -117
- package/dist/core.js.map +0 -1
- package/dist/provider.cjs +0 -197
- package/dist/provider.cjs.map +0 -1
- package/dist/provider.d.ts +0 -26
- package/dist/provider.js +0 -195
- package/dist/provider.js.map +0 -1
- package/dist/table-updates/data-parameter.d.ts +0 -14
- package/dist/table-updates/filter.d.ts +0 -16
- package/dist/table-updates/index.d.ts +0 -19
- package/dist/utils/column-spec.cjs.map +0 -1
- package/dist/utils/column-spec.js.map +0 -1
- package/dist/utils/index.cjs +0 -9
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.js +0 -9
- package/dist/utils/index.js.map +0 -1
- package/dist/zustand-store.cjs.map +0 -1
- package/dist/zustand-store.js.map +0 -1
- package/src/actions/filters.ts +0 -176
- package/src/components/actions.module.sass +0 -8
- package/src/provider.ts +0 -267
- package/src/table-updates/data-parameter.ts +0 -44
- package/src/table-updates/filter.ts +0 -124
- package/src/table-updates/index.ts +0 -239
- /package/dist/{zustand-store.d.ts → provider/zustand-store.d.ts} +0 -0
package/src/actions/types.ts
CHANGED
|
@@ -1,32 +1,7 @@
|
|
|
1
1
|
import type { IconName, Intent } from "@blueprintjs/core";
|
|
2
|
-
import type { Region, RegionCardinality } from "@blueprintjs/table";
|
|
3
2
|
import type { ComponentType, ReactNode } from "react";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
/** Selection cardinality including the case of no active selection */
|
|
8
|
-
export type SelectionCardinality = RegionCardinality | "none";
|
|
9
|
-
|
|
10
|
-
/** The concrete *shape* of the current selection — richer than cardinality
|
|
11
|
-
* alone. The "single X" cases are exposed as resolved identity fields on the
|
|
12
|
-
* action context (`columnKey`, `rowIndex`, `cell`); this carries the counts. */
|
|
13
|
-
export interface SelectionShape {
|
|
14
|
-
cardinality: SelectionCardinality;
|
|
15
|
-
/** Number of columns the selection spans (0 when not column-scoped). */
|
|
16
|
-
columns: number;
|
|
17
|
-
/** Number of rows the selection spans (0 when not row-scoped). */
|
|
18
|
-
rows: number;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** A single cell edit, used with `editCells` for batch updates. */
|
|
22
|
-
export interface CellEdit {
|
|
23
|
-
rowIndex: number;
|
|
24
|
-
column: string;
|
|
25
|
-
value: any;
|
|
26
|
-
/** The underlying row (base data). Populated on emitted `onEdit` events so a
|
|
27
|
-
* handler can address the row (identity) without reaching into the store. */
|
|
28
|
-
row?: any;
|
|
29
|
-
}
|
|
3
|
+
import { SelectionCardinality } from "./selection.ts";
|
|
4
|
+
import { TableActionContext } from "./context.ts";
|
|
30
5
|
|
|
31
6
|
/** A column filter that can be activated to hide non-matching rows.
|
|
32
7
|
* Parallel to `TableAction` but with persistent state while active.
|
|
@@ -54,91 +29,32 @@ export interface TableFilter<T = any, S = any> {
|
|
|
54
29
|
/** Summarize the current filter state for display on the active-filter tag
|
|
55
30
|
* (e.g. the range `0–250` or the search term). Keep it short — the tag also
|
|
56
31
|
* shows the filter name. Return `null` to show just the name. */
|
|
57
|
-
describeState?: (state: S) =>
|
|
32
|
+
describeState?: (state: S) => ReactNode;
|
|
33
|
+
/** The entity (e.g., a column) being described. */
|
|
34
|
+
subject?: string;
|
|
58
35
|
/** Row predicate: return `true` if the row should be visible.
|
|
59
36
|
* Receives the merged row (updatedData overlaid on data). */
|
|
60
37
|
predicate(row: T, state: S): boolean;
|
|
61
38
|
}
|
|
62
39
|
|
|
40
|
+
export interface ColumnFilter<T = any, S = any> extends Omit<
|
|
41
|
+
TableFilter<T, S>,
|
|
42
|
+
"columnKey"
|
|
43
|
+
> {
|
|
44
|
+
columnKey: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type ColumnFilterOptions<T = any, S = any> = Omit<
|
|
48
|
+
ColumnFilter<T, S>,
|
|
49
|
+
"columnKey" | "subject" | "name"
|
|
50
|
+
> & { name?: string };
|
|
51
|
+
|
|
63
52
|
/** An active filter entry stored in the table state. */
|
|
64
53
|
export interface ActiveFilterEntry<T = any> {
|
|
65
54
|
filter: TableFilter<T>;
|
|
66
55
|
state: any;
|
|
67
56
|
}
|
|
68
57
|
|
|
69
|
-
// Re-export ColumnSort from the main types module (defined there to
|
|
70
|
-
// avoid a circular import, since actions/types imports from types.ts).
|
|
71
|
-
export type { ColumnSort } from "../types.ts";
|
|
72
|
-
|
|
73
|
-
/** Context passed to an action's `run` function, providing both data access
|
|
74
|
-
* and store manipulation methods. Constructed fresh at action-run time
|
|
75
|
-
* to ensure current state. */
|
|
76
|
-
export interface TableActionContext<T = any> {
|
|
77
|
-
/** Current selection regions */
|
|
78
|
-
selection: Region[];
|
|
79
|
-
/** Derived cardinality of the current selection */
|
|
80
|
-
selectionCardinality: SelectionCardinality;
|
|
81
|
-
/** Concrete shape of the current selection (cardinality + column/row counts). */
|
|
82
|
-
selectionShape: SelectionShape;
|
|
83
|
-
/** The single selected column's key when exactly one column is scoped
|
|
84
|
-
* (a single full column, or cells within one column); otherwise `null`. */
|
|
85
|
-
columnKey: string | null;
|
|
86
|
-
/** The single selected data-row index when exactly one row is scoped;
|
|
87
|
-
* otherwise `null`. */
|
|
88
|
-
rowIndex: number | null;
|
|
89
|
-
/** The single selected cell (data-row index + column key) when exactly one
|
|
90
|
-
* cell is selected; otherwise `null`. Presence of these resolved fields is
|
|
91
|
-
* how actions discriminate selection shape — e.g. `appliesTo: ctx =>
|
|
92
|
-
* ctx.cell != null` for a single-cell control, or `ctx.columnKey != null`
|
|
93
|
-
* within a `FULL_COLUMNS` target for a single-column control. */
|
|
94
|
-
cell: { rowIndex: number; columnKey: string } | null;
|
|
95
|
-
/** The table's base data */
|
|
96
|
-
data: T[];
|
|
97
|
-
/** Sparse overlay of edited data */
|
|
98
|
-
updatedData: T[];
|
|
99
|
-
/** Row status tracking added/deleted rows */
|
|
100
|
-
rowStatus: TableElementStatus[];
|
|
101
|
-
/** Column definitions */
|
|
102
|
-
columnSpec: ColumnSpec[];
|
|
103
|
-
/** Whether the table is in edit mode */
|
|
104
|
-
editable: boolean;
|
|
105
|
-
/** Whether row deletion is available (false when the provider can't delete). */
|
|
106
|
-
canDeleteRows: boolean;
|
|
107
|
-
|
|
108
|
-
// Convenience methods (derived from selection)
|
|
109
|
-
/** Row indices covered by the current selection */
|
|
110
|
-
getSelectedRowIndices(): number[];
|
|
111
|
-
/** Column keys covered by the current selection */
|
|
112
|
-
getSelectedColumnKeys(): string[];
|
|
113
|
-
|
|
114
|
-
// Store manipulation methods
|
|
115
|
-
onCellEdited(rowIndex: number, columnKey: string, value: any): void;
|
|
116
|
-
/** Edit multiple cells in a single batch update. Preferred over calling
|
|
117
|
-
* `onCellEdited` in a loop, which triggers separate store updates
|
|
118
|
-
* and may produce inconsistent intermediate states. */
|
|
119
|
-
editCells(edits: CellEdit[]): void;
|
|
120
|
-
deleteSelectedRows(): void;
|
|
121
|
-
addRow(row?: Partial<T>): void;
|
|
122
|
-
setUpdatedData(data: any): void;
|
|
123
|
-
resetChanges(region?: Region[]): void;
|
|
124
|
-
clearSelection(): void;
|
|
125
|
-
scrollToRow(rowIndex: number): void;
|
|
126
|
-
/** Direct store mutation for cases not covered by the convenience methods
|
|
127
|
-
* above (e.g., modifying `columnSpec` or `deletedRows`). */
|
|
128
|
-
setState(partial: Record<string, any>): void;
|
|
129
|
-
|
|
130
|
-
// Clipboard proxy support
|
|
131
|
-
/** Active clipboard proxy from a prior copy, if any */
|
|
132
|
-
clipboardProxy: ClipboardProxy | null;
|
|
133
|
-
/** Store a clipboard proxy for potential backend-mediated paste */
|
|
134
|
-
setClipboardProxy(proxy: ClipboardProxy | null): void;
|
|
135
|
-
|
|
136
|
-
// Filter support
|
|
137
|
-
/** Row index mapping when filters are active. When non-null,
|
|
138
|
-
* visible row `i` maps to data row `filteredRowIndices[i]`. */
|
|
139
|
-
filteredRowIndices: number[] | null;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
58
|
/** Definition of a table action. Follows the `ActionDef` pattern from
|
|
143
59
|
* `@macrostrat/form-components` with table-specific extensions.
|
|
144
60
|
*
|
package/src/components/colors.ts
CHANGED
|
@@ -21,7 +21,7 @@ export function ColorCell({
|
|
|
21
21
|
const darkMode = useInDarkMode();
|
|
22
22
|
const _className = classNames(className, "color-cell");
|
|
23
23
|
const _style = useMemo(() => {
|
|
24
|
-
let mainColor = "var(--text-color)";
|
|
24
|
+
let mainColor: string | undefined = "var(--text-color)";
|
|
25
25
|
let backgroundColor = value;
|
|
26
26
|
|
|
27
27
|
if (adjustLuminance) {
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
import type { ColumnSpec } from "../../provider";
|
|
2
|
+
import { ReactNode, useCallback, useMemo, useState } from "react";
|
|
3
|
+
import {
|
|
4
|
+
buildMultiOperatorColumnFilter,
|
|
5
|
+
ColumnFilterState,
|
|
6
|
+
type TableFilter,
|
|
7
|
+
} from "../../actions";
|
|
8
|
+
import { ColumnSort, ctx, storeAtom } from "../../provider";
|
|
9
|
+
import {
|
|
10
|
+
Button,
|
|
11
|
+
HTMLSelect,
|
|
12
|
+
InputGroup,
|
|
13
|
+
Menu,
|
|
14
|
+
MenuItem,
|
|
15
|
+
PopoverNext,
|
|
16
|
+
Tag,
|
|
17
|
+
} from "@blueprintjs/core";
|
|
18
|
+
import { FilterOperator, OPERATOR_LABELS } from "../../filters/operators";
|
|
19
|
+
import classNames from "classnames";
|
|
20
|
+
import { atom } from "jotai";
|
|
21
|
+
import h from "./filter-and-sort.module.sass";
|
|
22
|
+
|
|
23
|
+
/** The filter for a column: its own rich `TableFilter` (from
|
|
24
|
+
* `col.filters`) when present — so the header matches the top bar and the rich
|
|
25
|
+
* filter is prioritized — else the built-in operator `columnFilter`. */
|
|
26
|
+
export function resolveColumnFilter(col: ColumnSpec): TableFilter {
|
|
27
|
+
const rich = (col.filters as TableFilter[] | undefined)?.find(
|
|
28
|
+
(f) => (f.columnKey ?? col.key) === col.key,
|
|
29
|
+
);
|
|
30
|
+
if (rich != null) return { ...rich, columnKey: rich.columnKey ?? col.key };
|
|
31
|
+
return buildMultiOperatorColumnFilter(col);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Shows an active column filter in the top menu */
|
|
35
|
+
export function ColumnFilterControl({ col }: { col: ColumnSpec }) {
|
|
36
|
+
// Same `TableFilter` the FilterBar and any provider consume, so the header,
|
|
37
|
+
// the bar, and the query stay in sync (rich filter prioritized).
|
|
38
|
+
const filter = useMemo(() => resolveColumnFilter(col), [col]);
|
|
39
|
+
return h(FilterIndicator, {
|
|
40
|
+
filter,
|
|
41
|
+
large: true,
|
|
42
|
+
minimal: true,
|
|
43
|
+
showSubject: false,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function FilterIndicator({
|
|
48
|
+
filter,
|
|
49
|
+
large,
|
|
50
|
+
minimal = false,
|
|
51
|
+
showSubject = true,
|
|
52
|
+
}: {
|
|
53
|
+
filter: TableFilter;
|
|
54
|
+
state: any;
|
|
55
|
+
large?: boolean;
|
|
56
|
+
minimal?: boolean;
|
|
57
|
+
showSubject: boolean;
|
|
58
|
+
}) {
|
|
59
|
+
const props = useFilterProps(filter);
|
|
60
|
+
|
|
61
|
+
const { valueText, filterForm, icon, intent, isActive, onRemove } = props;
|
|
62
|
+
|
|
63
|
+
let rightIcon: string | undefined = "caret-down";
|
|
64
|
+
if (isActive) {
|
|
65
|
+
rightIcon = undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const label = buildFilterTagLabel(filter, valueText, {
|
|
69
|
+
minimal,
|
|
70
|
+
showSubject,
|
|
71
|
+
isActive,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return h(
|
|
75
|
+
MenuDropdown,
|
|
76
|
+
{
|
|
77
|
+
content: filterForm,
|
|
78
|
+
},
|
|
79
|
+
h(
|
|
80
|
+
Tag,
|
|
81
|
+
{
|
|
82
|
+
minimal: true,
|
|
83
|
+
large,
|
|
84
|
+
icon,
|
|
85
|
+
rightIcon,
|
|
86
|
+
intent,
|
|
87
|
+
onRemove,
|
|
88
|
+
className: classNames("filter-tag", { active: isActive }),
|
|
89
|
+
},
|
|
90
|
+
h("span.filter-label", label),
|
|
91
|
+
),
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function MenuDropdown({ children, content, isOpen, ...props }: any) {
|
|
96
|
+
return h(
|
|
97
|
+
PopoverNext,
|
|
98
|
+
{
|
|
99
|
+
content,
|
|
100
|
+
placement: "bottom-start",
|
|
101
|
+
enforceFocus: true,
|
|
102
|
+
autoFocus: false,
|
|
103
|
+
arrow: false,
|
|
104
|
+
},
|
|
105
|
+
children,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function buildFilterTagLabel(
|
|
110
|
+
filter: TableFilter,
|
|
111
|
+
valueText: ReactNode | null,
|
|
112
|
+
{
|
|
113
|
+
minimal,
|
|
114
|
+
showSubject,
|
|
115
|
+
isActive,
|
|
116
|
+
}: { minimal: boolean; showSubject: boolean; isActive: boolean },
|
|
117
|
+
): ReactNode {
|
|
118
|
+
let name = filter.name;
|
|
119
|
+
if (!showSubject) {
|
|
120
|
+
name = "Filter";
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
let _showColumnKey = showSubject ?? !minimal;
|
|
124
|
+
let columnKeyEl: ReactNode = null;
|
|
125
|
+
const subj = filter.subject ?? filter.columnKey;
|
|
126
|
+
if (_showColumnKey && subj != null) {
|
|
127
|
+
columnKeyEl = h([h("span.subject", subj), h("span.sep", " ")]);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const showOperator = (!minimal || !isActive) && name != subj;
|
|
131
|
+
let operatorEl: ReactNode = null;
|
|
132
|
+
if (showOperator) {
|
|
133
|
+
operatorEl = h([h("span.operator", name), h("span.sep", ": ")]);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let filterWindow: ReactNode = null;
|
|
137
|
+
if (valueText != null && valueText != "") {
|
|
138
|
+
filterWindow = h("span.filter-value", valueText);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return h([columnKeyEl, operatorEl, filterWindow]);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Every filter applicable to a column: its rich `col.filters` (there may be
|
|
145
|
+
* several) plus the built-in operator `columnFilter` when the column is
|
|
146
|
+
* `filterable` and no rich filter already targets it. The menu lists all of
|
|
147
|
+
* them; the toolbar's `render` collapses to `resolveColumnFilter` (a single
|
|
148
|
+
* control). */
|
|
149
|
+
function applicableColumnFilters(col: ColumnSpec): TableFilter[] {
|
|
150
|
+
const result: TableFilter[] = [];
|
|
151
|
+
const rich = (col.filters as TableFilter[] | undefined) ?? [];
|
|
152
|
+
for (const f of rich) {
|
|
153
|
+
result.push({ ...f, columnKey: f.columnKey ?? col.key });
|
|
154
|
+
}
|
|
155
|
+
const hasOwnColumnFilter = result.some((r) => r.columnKey === col.key);
|
|
156
|
+
if (
|
|
157
|
+
(col.filterable === true || typeof col.filterable === "object") &&
|
|
158
|
+
!hasOwnColumnFilter
|
|
159
|
+
) {
|
|
160
|
+
result.push(buildMultiOperatorColumnFilter(col));
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** One filter, as a menu item whose submenu carries its edit form. Active
|
|
166
|
+
* filters get a warning intent and show their `describeState` summary. The
|
|
167
|
+
* displayed `label` may differ from `filter.name` (e.g. the built-in operator
|
|
168
|
+
* filter reads "Filter" in a column's own menu, where the column is implicit). */
|
|
169
|
+
export function ColumnFilterMenuItem({
|
|
170
|
+
filter,
|
|
171
|
+
label,
|
|
172
|
+
}: {
|
|
173
|
+
filter: TableFilter;
|
|
174
|
+
label: string;
|
|
175
|
+
}) {
|
|
176
|
+
const { filterForm, icon, intent, valueText } = useFilterProps(filter);
|
|
177
|
+
return h(
|
|
178
|
+
MenuItem,
|
|
179
|
+
{
|
|
180
|
+
icon,
|
|
181
|
+
text: label,
|
|
182
|
+
label: valueText,
|
|
183
|
+
intent,
|
|
184
|
+
shouldDismissPopover: false,
|
|
185
|
+
},
|
|
186
|
+
filterForm,
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function useFilterProps(filter: TableFilter) {
|
|
191
|
+
const [state, setState] = useFilterAtom(filter);
|
|
192
|
+
|
|
193
|
+
const onRemove = useCallback(
|
|
194
|
+
(event) => {
|
|
195
|
+
setState(null);
|
|
196
|
+
event.stopPropagation();
|
|
197
|
+
},
|
|
198
|
+
[setState],
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
const isActive = state != null;
|
|
202
|
+
let summary: ReactNode = null;
|
|
203
|
+
let label: ReactNode = filter.name ?? "Filter";
|
|
204
|
+
if (isActive) {
|
|
205
|
+
summary = filter.describeState?.(state);
|
|
206
|
+
label = summary ?? filter.name;
|
|
207
|
+
if (summary == "") summary = null;
|
|
208
|
+
if (summary != null) {
|
|
209
|
+
label = h([filter.name, h("span.filter-window", [": ", summary])]);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
let filterForm: ReactNode = null;
|
|
214
|
+
if (filter.filterForm != null) {
|
|
215
|
+
filterForm = h(
|
|
216
|
+
"div.filter-form-container",
|
|
217
|
+
h(filter.filterForm, {
|
|
218
|
+
state: state ?? filter.defaultState,
|
|
219
|
+
setState,
|
|
220
|
+
}),
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return {
|
|
225
|
+
filterForm,
|
|
226
|
+
label,
|
|
227
|
+
icon: filter.icon ?? "filter",
|
|
228
|
+
intent: isActive ? "primary" : "none",
|
|
229
|
+
isActive,
|
|
230
|
+
nameText: filter.name,
|
|
231
|
+
valueText: summary,
|
|
232
|
+
onRemove: isActive ? onRemove : undefined,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** Menu-native filter: one item per applicable filter, each opening its form
|
|
237
|
+
* in a submenu. */
|
|
238
|
+
export function ColumnFilterMenu({ col }: { col: ColumnSpec }) {
|
|
239
|
+
const filters = useMemo(() => applicableColumnFilters(col), [col]);
|
|
240
|
+
return h(
|
|
241
|
+
filters.map((f) =>
|
|
242
|
+
h(ColumnFilterMenuItem, {
|
|
243
|
+
key: f.id,
|
|
244
|
+
filter: f,
|
|
245
|
+
// The generic operator filter is just "Filter" in its own column's
|
|
246
|
+
// menu; rich (user-provided) filters keep their descriptive names.
|
|
247
|
+
label: f.columnKey === col.key ? "Filter" : f.name,
|
|
248
|
+
}),
|
|
249
|
+
),
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export function ColumnFilterForm({
|
|
254
|
+
operators,
|
|
255
|
+
state,
|
|
256
|
+
setState,
|
|
257
|
+
}: {
|
|
258
|
+
operators: FilterOperator[];
|
|
259
|
+
state: ColumnFilterState;
|
|
260
|
+
setState: (s: ColumnFilterState) => void;
|
|
261
|
+
}) {
|
|
262
|
+
// Operator and value are held locally, seeded once from the incoming state.
|
|
263
|
+
// The operator must be local: committing it with an empty value clears the
|
|
264
|
+
// filter (so the store round-trips back to the default state), which would
|
|
265
|
+
// otherwise snap the dropdown back to the default — the operator wouldn't
|
|
266
|
+
// "stick" until a value was typed. The value commits (triggering a server
|
|
267
|
+
// re-fetch) on blur / Enter, not on every keystroke.
|
|
268
|
+
const [op, setOp] = useState<FilterOperator>(state?.operator ?? operators[0]);
|
|
269
|
+
const [val, setVal] = useState<string>(state?.value ?? "");
|
|
270
|
+
|
|
271
|
+
const commit = (nextOp: FilterOperator, nextVal: string) =>
|
|
272
|
+
setState({ operator: nextOp, value: nextVal });
|
|
273
|
+
|
|
274
|
+
const clear = () => {
|
|
275
|
+
setVal("");
|
|
276
|
+
commit(op, "");
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
return h("div.column-filter-form", [
|
|
280
|
+
// Compact header: title + operator on one row (with a clear ✕ when set),
|
|
281
|
+
// value on the next — space-efficient and full-width for the value.
|
|
282
|
+
h("div", { style: { display: "flex", alignItems: "center", gap: "6px" } }, [
|
|
283
|
+
h("span", { style: { fontWeight: 600 } }, "Filter"),
|
|
284
|
+
h(HTMLSelect, {
|
|
285
|
+
small: true,
|
|
286
|
+
value: op,
|
|
287
|
+
options: operators.map((o) => ({
|
|
288
|
+
value: o,
|
|
289
|
+
label: OPERATOR_LABELS[o] ?? o,
|
|
290
|
+
})),
|
|
291
|
+
onChange: (e) => {
|
|
292
|
+
const nextOp = e.currentTarget.value as FilterOperator;
|
|
293
|
+
setOp(nextOp);
|
|
294
|
+
commit(nextOp, val);
|
|
295
|
+
},
|
|
296
|
+
}),
|
|
297
|
+
h("div", { style: { flex: 1 } }),
|
|
298
|
+
h.if(val !== "")(Button, {
|
|
299
|
+
small: true,
|
|
300
|
+
minimal: true,
|
|
301
|
+
icon: "cross",
|
|
302
|
+
"aria-label": "Clear filter",
|
|
303
|
+
onClick: clear,
|
|
304
|
+
}),
|
|
305
|
+
]),
|
|
306
|
+
h(InputGroup, {
|
|
307
|
+
small: true,
|
|
308
|
+
fill: true,
|
|
309
|
+
value: val,
|
|
310
|
+
placeholder: "value",
|
|
311
|
+
autoFocus: true,
|
|
312
|
+
onChange: (e) => setVal(e.target.value),
|
|
313
|
+
onBlur: () => commit(op, val),
|
|
314
|
+
onKeyDown: (e) => {
|
|
315
|
+
if (e.key === "Enter") commit(op, val);
|
|
316
|
+
},
|
|
317
|
+
}),
|
|
318
|
+
]);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function ColumnSortActions({ sort, setSort }) {
|
|
322
|
+
return h([
|
|
323
|
+
h(MenuItem, {
|
|
324
|
+
key: "asc",
|
|
325
|
+
text: "Ascending",
|
|
326
|
+
icon: "sort-asc",
|
|
327
|
+
active: sort?.ascending === true,
|
|
328
|
+
onClick: () => setSort(true),
|
|
329
|
+
shouldDismissPopover: false,
|
|
330
|
+
}),
|
|
331
|
+
h(MenuItem, {
|
|
332
|
+
key: "desc",
|
|
333
|
+
text: "Descending",
|
|
334
|
+
icon: "sort-desc",
|
|
335
|
+
active: sort?.ascending === false,
|
|
336
|
+
onClick: () => setSort(false),
|
|
337
|
+
shouldDismissPopover: false,
|
|
338
|
+
}),
|
|
339
|
+
]);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function displayParamsForSort(sort: ColumnSort | undefined) {
|
|
343
|
+
const icon =
|
|
344
|
+
sort == null ? "sort" : sort.ascending ? "sort-asc" : "sort-desc";
|
|
345
|
+
const label =
|
|
346
|
+
sort == null ? null : sort.ascending ? "Ascending" : "Descending";
|
|
347
|
+
|
|
348
|
+
let intent = "none";
|
|
349
|
+
if (sort != null) {
|
|
350
|
+
intent = "primary";
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return { icon, label, intent };
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export function ColumnSortIndicator({
|
|
357
|
+
columnKey,
|
|
358
|
+
showColumnKey,
|
|
359
|
+
small,
|
|
360
|
+
large,
|
|
361
|
+
}: {
|
|
362
|
+
showColumnKey: string;
|
|
363
|
+
columnKey: string;
|
|
364
|
+
small?: boolean;
|
|
365
|
+
large?: boolean;
|
|
366
|
+
}) {
|
|
367
|
+
const [sort, setSort] = useSortAtom(columnKey);
|
|
368
|
+
const { icon, label, intent } = displayParamsForSort(sort);
|
|
369
|
+
|
|
370
|
+
const columnLabel = showColumnKey ? `${columnKey}: ` : "";
|
|
371
|
+
let onRemove: any = undefined;
|
|
372
|
+
let rightIcon: string | undefined = "caret-down";
|
|
373
|
+
if (sort != null) {
|
|
374
|
+
rightIcon = undefined;
|
|
375
|
+
onRemove = () => setSort(null);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
let valLabel = label;
|
|
379
|
+
valLabel ??= showColumnKey ? columnKey : "Sort";
|
|
380
|
+
|
|
381
|
+
return h(
|
|
382
|
+
MenuDropdown,
|
|
383
|
+
{
|
|
384
|
+
content: h(Menu, h(ColumnSortActions, { sort, setSort })),
|
|
385
|
+
},
|
|
386
|
+
h(
|
|
387
|
+
Tag,
|
|
388
|
+
{
|
|
389
|
+
small,
|
|
390
|
+
large,
|
|
391
|
+
minimal: true,
|
|
392
|
+
icon,
|
|
393
|
+
rightIcon,
|
|
394
|
+
intent,
|
|
395
|
+
onRemove,
|
|
396
|
+
},
|
|
397
|
+
h([columnLabel, valLabel]),
|
|
398
|
+
),
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/** Menu-native sort: a "Sort" item whose submenu holds Ascending / Descending.
|
|
403
|
+
* Clicking the *active* direction again clears the sort (toggle off) — there's
|
|
404
|
+
* no explicit "Clear" item, since the active-filter/sort tag in the status bar
|
|
405
|
+
* already offers direct removal. `text` overrides the parent item's label (the
|
|
406
|
+
* `DataPanel` uses the column name, so its Sort menu lists one item per field). */
|
|
407
|
+
export function ColumnSortMenu({
|
|
408
|
+
columnKey,
|
|
409
|
+
defaultLabel,
|
|
410
|
+
}: {
|
|
411
|
+
columnKey: string;
|
|
412
|
+
text?: string;
|
|
413
|
+
defaultLabel?: string;
|
|
414
|
+
}) {
|
|
415
|
+
const [sort, setSort] = useSortAtom(columnKey);
|
|
416
|
+
const { icon, label, intent } = displayParamsForSort(sort);
|
|
417
|
+
return h(
|
|
418
|
+
MenuItem,
|
|
419
|
+
{ icon, text: label ?? defaultLabel ?? columnKey, intent },
|
|
420
|
+
h(ColumnSortActions, { sort, setSort }),
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
const setFilterAtom = atom(null, (get, set, filter: TableFilter, next: any) => {
|
|
425
|
+
const store = get(storeAtom);
|
|
426
|
+
if (store == null) return;
|
|
427
|
+
if (next == null || next.value === "") {
|
|
428
|
+
store.removeFilter(filter.id);
|
|
429
|
+
} else {
|
|
430
|
+
store.setFilter(filter.id, filter, next);
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
function useFilterAtom(filter: TableFilter) {
|
|
435
|
+
const filterStateAtom = useMemo(
|
|
436
|
+
() =>
|
|
437
|
+
atom(
|
|
438
|
+
(get) => {
|
|
439
|
+
const store = get(storeAtom);
|
|
440
|
+
return store?.activeFilters.get(filter.id)?.state;
|
|
441
|
+
},
|
|
442
|
+
(get, set, next: any) => {
|
|
443
|
+
set(setFilterAtom, filter, next);
|
|
444
|
+
},
|
|
445
|
+
),
|
|
446
|
+
[filter.id],
|
|
447
|
+
);
|
|
448
|
+
return ctx.use(filterStateAtom);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function useSortAtom(columnKey) {
|
|
452
|
+
const sortAtom = useMemo(
|
|
453
|
+
() =>
|
|
454
|
+
atom(
|
|
455
|
+
(get) => {
|
|
456
|
+
return get(storeAtom)?.columnSorts.find((x) => x.key === columnKey);
|
|
457
|
+
},
|
|
458
|
+
(get, set, ascending: boolean | null) => {
|
|
459
|
+
const store = get(storeAtom);
|
|
460
|
+
if (store == null) return;
|
|
461
|
+
const currentVal = store.columnSorts.find(
|
|
462
|
+
(x) => x.key === columnKey,
|
|
463
|
+
)?.ascending;
|
|
464
|
+
let nextVal = ascending;
|
|
465
|
+
if (currentVal != null) {
|
|
466
|
+
if (currentVal == nextVal) {
|
|
467
|
+
// Unset
|
|
468
|
+
nextVal = null;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
store.setColumnSort(columnKey, nextVal);
|
|
473
|
+
},
|
|
474
|
+
),
|
|
475
|
+
[columnKey],
|
|
476
|
+
);
|
|
477
|
+
return ctx.use(sortAtom);
|
|
478
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.selection-indicator
|
|
2
|
+
user-select: none
|
|
3
|
+
|
|
4
|
+
.selection-indicator-tag
|
|
5
|
+
display: flex
|
|
6
|
+
align-items: center
|
|
7
|
+
gap: 4px
|
|
8
|
+
:global(.bp6-icon)
|
|
9
|
+
color: var(--bp-typography-color-muted)
|
|
10
|
+
|
|
11
|
+
&.enabled
|
|
12
|
+
:global(.bp6-icon)
|
|
13
|
+
color: var(--intent-primary)
|
|
14
|
+
|
|
15
|
+
&.interactive
|
|
16
|
+
cursor: pointer
|
|
17
|
+
&:not(.enabled)
|
|
18
|
+
color: var(--bp-typography-color-muted) !important
|
|
19
|
+
|
|
20
|
+
&:not(.interactive)
|
|
21
|
+
background: transparent !important
|
|
22
|
+
|