@macrostrat/data-sheet 4.1.0 → 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 +40 -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 -184
- 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 -182
- package/dist/actions/column-controls.js.map +1 -1
- package/dist/actions/column-filter.cjs +24 -50
- 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 -51
- 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-controls.cjs → table-actions.cjs} +7 -24
- 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 -19
- 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} +36 -97
- 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 -181
- 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 -150
- 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 +21 -4
- package/dist/filters/operators.cjs.map +1 -1
- package/dist/filters/operators.d.ts +5 -4
- package/dist/filters/operators.js +21 -4
- 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 +129 -103
- 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 +110 -84
- 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 +77 -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} +37 -23
- package/dist/provider/zustand-store.cjs.map +1 -0
- package/dist/{zustand-store.js → provider/zustand-store.js} +22 -8
- package/dist/provider/zustand-store.js.map +1 -0
- package/dist/{cell-renderer.cjs → renderers/cell-renderer.cjs} +68 -35
- 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} +66 -33
- package/dist/renderers/cell-renderer.js.map +1 -0
- package/dist/renderers/column-header-cell.cjs +40 -17
- package/dist/renderers/column-header-cell.cjs.map +1 -1
- package/dist/renderers/column-header-cell.d.ts +2 -2
- package/dist/renderers/column-header-cell.js +40 -17
- 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 +123 -226
- 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 -228
- package/src/actions/column-filter.ts +28 -63
- 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 -20
- 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} +53 -126
- 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} +144 -306
- package/src/data-view.ts +70 -0
- package/src/filters/operators.ts +38 -6
- package/src/index.ts +4 -3
- package/src/postgrest-table/data-loaders.ts +250 -181
- package/src/postgrest-table/index.ts +10 -9
- package/src/{utils → provider}/column-spec.ts +34 -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} +36 -14
- package/src/{cell-renderer.ts → renderers/cell-renderer.ts} +146 -58
- package/src/renderers/column-header-cell.ts +51 -17
- package/src/renderers/index.ts +1 -0
- package/src/types.ts +143 -236
- 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.map +0 -1
- package/dist/actions/table-controls.js.map +0 -1
- package/dist/actions/toolbar.cjs +0 -246
- 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 -113
- package/dist/core.js.map +0 -1
- package/dist/provider.cjs +0 -191
- package/dist/provider.cjs.map +0 -1
- package/dist/provider.d.ts +0 -25
- package/dist/provider.js +0 -189
- 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 -250
- 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/data-view.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DataView — a single data source rendered as either the cell grid
|
|
3
|
+
* (`_DataSheet`) or the card list (`_DataPanel`), sharing **one** store.
|
|
4
|
+
*
|
|
5
|
+
* Both renderers are already "inner" components that read the shared jotai +
|
|
6
|
+
* zustand store rather than creating it; `DataView` mounts one
|
|
7
|
+
* `DataSheetProvider` and swaps which renderer sits inside it. Because the store
|
|
8
|
+
* (selection, sorts, filters, loaded data, edit overlay) persists across the
|
|
9
|
+
* swap, toggling `view` keeps the user's view state — the realized "one data +
|
|
10
|
+
* behavior definition, two presentations". The data source is resolved once via
|
|
11
|
+
* the shared `useResolvedProvider`, and the same `columnSpec` / `actions` /
|
|
12
|
+
* `filters` drive whichever renderer is mounted.
|
|
13
|
+
*/
|
|
14
|
+
import h from "@macrostrat/hyper";
|
|
15
|
+
import { ReactNode } from "react";
|
|
16
|
+
import {
|
|
17
|
+
DataSheetProvider,
|
|
18
|
+
DataViewRendererType,
|
|
19
|
+
splitDataProviderProps,
|
|
20
|
+
} from "./provider";
|
|
21
|
+
import { DataSheetRenderer } from "./data-sheet.ts";
|
|
22
|
+
import { DataPanelProps, DataPanelRenderer } from "./data-panel.ts";
|
|
23
|
+
|
|
24
|
+
export interface DataViewProps<T = any> extends DataPanelProps<T> {
|
|
25
|
+
/** Which renderer to show. `cards` needs `itemComponent`. */
|
|
26
|
+
viewType: DataViewRendererType;
|
|
27
|
+
/** Passed to the table renderer (ignored by cards). Defaults to `true`. */
|
|
28
|
+
editable?: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function DataView<T>(props: DataViewProps<T>) {
|
|
32
|
+
const [providerProps, rendererProps] = splitDataProviderProps(props);
|
|
33
|
+
const { viewType, editable } = providerProps;
|
|
34
|
+
|
|
35
|
+
const {
|
|
36
|
+
// `data` is only the source for the resolved provider (below); renderers
|
|
37
|
+
// read live rows from the store, so it's kept out of `common`.
|
|
38
|
+
// Card-only props — kept off the table renderer so they don't leak onto
|
|
39
|
+
// the Blueprint table.
|
|
40
|
+
itemComponent,
|
|
41
|
+
toolbar,
|
|
42
|
+
sidebar,
|
|
43
|
+
contentFooter,
|
|
44
|
+
autoLoadPages,
|
|
45
|
+
scrollBody,
|
|
46
|
+
// The rest (provider/fetchData/identity/actions/filters/pageSize/
|
|
47
|
+
// name/statusBar/refreshToken) is common to both renderers.
|
|
48
|
+
...common
|
|
49
|
+
} = rendererProps as DataPanelProps<T>;
|
|
50
|
+
|
|
51
|
+
let renderer: ReactNode;
|
|
52
|
+
if (viewType === "cards") {
|
|
53
|
+
renderer = h(DataPanelRenderer<any>, {
|
|
54
|
+
...common,
|
|
55
|
+
itemComponent,
|
|
56
|
+
toolbar,
|
|
57
|
+
sidebar,
|
|
58
|
+
contentFooter,
|
|
59
|
+
autoLoadPages,
|
|
60
|
+
scrollBody,
|
|
61
|
+
});
|
|
62
|
+
} else {
|
|
63
|
+
renderer = h(DataSheetRenderer<any>, {
|
|
64
|
+
...common,
|
|
65
|
+
editable,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return h(DataSheetProvider<T>, providerProps, renderer);
|
|
70
|
+
}
|
package/src/filters/operators.ts
CHANGED
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
* translates it to a query). Promoted to core from the PostgREST column header,
|
|
5
5
|
* so there is one operator model, not two.
|
|
6
6
|
*/
|
|
7
|
-
import type { ColumnSpec } from "../
|
|
7
|
+
import type { ColumnSpec } from "../provider";
|
|
8
8
|
|
|
9
9
|
/** Column-filter operators. A superset that covers both in-memory comparison
|
|
10
|
-
* and common backend query operators (PostgREST maps onto these names).
|
|
10
|
+
* and common backend query operators (PostgREST maps onto these names).
|
|
11
|
+
* `cs`/`ov` are the array-column operators (contains / overlaps). */
|
|
11
12
|
export type FilterOperator =
|
|
12
13
|
| "eq"
|
|
13
14
|
| "neq"
|
|
@@ -17,7 +18,9 @@ export type FilterOperator =
|
|
|
17
18
|
| "lt"
|
|
18
19
|
| "gte"
|
|
19
20
|
| "lte"
|
|
20
|
-
| "is"
|
|
21
|
+
| "is"
|
|
22
|
+
| "cs"
|
|
23
|
+
| "ov";
|
|
21
24
|
|
|
22
25
|
/** Human-readable operator labels for menus and active-filter tags. */
|
|
23
26
|
export const OPERATOR_LABELS: Record<FilterOperator, string> = {
|
|
@@ -30,9 +33,13 @@ export const OPERATOR_LABELS: Record<FilterOperator, string> = {
|
|
|
30
33
|
gte: "≥",
|
|
31
34
|
lte: "≤",
|
|
32
35
|
is: "is",
|
|
36
|
+
cs: "has",
|
|
37
|
+
ov: "has any of",
|
|
33
38
|
};
|
|
34
39
|
|
|
35
|
-
|
|
40
|
+
// "contains" (`ilike`) leads for text, so it's the default operator — the most
|
|
41
|
+
// common intent when filtering a string column.
|
|
42
|
+
const STRING_OPERATORS: FilterOperator[] = ["ilike", "eq", "neq"];
|
|
36
43
|
const NUMERIC_OPERATORS: FilterOperator[] = [
|
|
37
44
|
"eq",
|
|
38
45
|
"neq",
|
|
@@ -42,12 +49,15 @@ const NUMERIC_OPERATORS: FilterOperator[] = [
|
|
|
42
49
|
"lte",
|
|
43
50
|
];
|
|
44
51
|
const BOOLEAN_OPERATORS: FilterOperator[] = ["eq", "neq"];
|
|
52
|
+
// Array columns (e.g. a `text[]` of tags): "has" one value, or "has any of" a
|
|
53
|
+
// comma-separated set. `cs` leads — filtering to a single value is the norm.
|
|
54
|
+
const ARRAY_OPERATORS: FilterOperator[] = ["cs", "ov"];
|
|
45
55
|
|
|
46
|
-
/** Fallback when the column has no type information. */
|
|
56
|
+
/** Fallback when the column has no type information. Leads with "contains". */
|
|
47
57
|
export const DEFAULT_FILTER_OPERATORS: FilterOperator[] = [
|
|
58
|
+
"ilike",
|
|
48
59
|
"eq",
|
|
49
60
|
"neq",
|
|
50
|
-
"ilike",
|
|
51
61
|
"gt",
|
|
52
62
|
"lt",
|
|
53
63
|
"gte",
|
|
@@ -59,6 +69,7 @@ const OPERATORS_BY_TYPE: Record<string, FilterOperator[]> = {
|
|
|
59
69
|
number: NUMERIC_OPERATORS,
|
|
60
70
|
integer: NUMERIC_OPERATORS,
|
|
61
71
|
boolean: BOOLEAN_OPERATORS,
|
|
72
|
+
array: ARRAY_OPERATORS,
|
|
62
73
|
};
|
|
63
74
|
|
|
64
75
|
/** Resolve the operators offered for a column: explicit `filterable.operators`
|
|
@@ -121,7 +132,28 @@ export function testFilterOperator(
|
|
|
121
132
|
if (v === "false") return cellValue === false;
|
|
122
133
|
return looseEq(cellValue, filterValue);
|
|
123
134
|
}
|
|
135
|
+
case "cs": {
|
|
136
|
+
// Array column contains the value (all of them, if comma-separated).
|
|
137
|
+
if (!Array.isArray(cellValue)) return false;
|
|
138
|
+
const cell = cellValue.map((v) => String(v));
|
|
139
|
+
return splitList(filterValue).every((v) => cell.includes(v));
|
|
140
|
+
}
|
|
141
|
+
case "ov": {
|
|
142
|
+
// Array column overlaps the value set (has any of them).
|
|
143
|
+
if (!Array.isArray(cellValue)) return false;
|
|
144
|
+
const cell = cellValue.map((v) => String(v));
|
|
145
|
+
return splitList(filterValue).some((v) => cell.includes(v));
|
|
146
|
+
}
|
|
124
147
|
default:
|
|
125
148
|
return true;
|
|
126
149
|
}
|
|
127
150
|
}
|
|
151
|
+
|
|
152
|
+
/** Split a filter value into a list of trimmed, non-empty tokens (comma is the
|
|
153
|
+
* set separator for `cs`/`ov`); a single value yields a one-element list. */
|
|
154
|
+
function splitList(value: any): string[] {
|
|
155
|
+
return String(value)
|
|
156
|
+
.split(",")
|
|
157
|
+
.map((s) => s.trim())
|
|
158
|
+
.filter((s) => s !== "");
|
|
159
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./data-sheet.ts";
|
|
2
|
+
export * from "./data-panel.ts";
|
|
3
|
+
export * from "./data-view";
|
|
2
4
|
export * from "./postgrest-table";
|
|
3
5
|
export * from "./components";
|
|
4
6
|
export * from "./provider";
|
|
5
7
|
export * from "./utils";
|
|
6
|
-
export * from "./types";
|
|
7
8
|
export * from "./actions";
|
|
8
9
|
export * from "./filters/operators";
|
|
10
|
+
export * from "./types";
|
|
9
11
|
|
|
10
12
|
export { Cell } from "@blueprintjs/table";
|
|
11
|
-
export { CellRendererDebugOverlay } from "./utils";
|