@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.
Files changed (303) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/actions/builtin.cjs +1 -1
  3. package/dist/actions/builtin.cjs.map +1 -1
  4. package/dist/actions/builtin.d.ts +0 -2
  5. package/dist/actions/builtin.js +1 -1
  6. package/dist/actions/builtin.js.map +1 -1
  7. package/dist/actions/clipboard.cjs +1 -1
  8. package/dist/actions/clipboard.cjs.map +1 -1
  9. package/dist/actions/clipboard.d.ts +3 -2
  10. package/dist/actions/clipboard.js +1 -1
  11. package/dist/actions/clipboard.js.map +1 -1
  12. package/dist/actions/column-controls.cjs +7 -196
  13. package/dist/actions/column-controls.cjs.map +1 -1
  14. package/dist/actions/column-controls.d.ts +1 -1
  15. package/dist/actions/column-controls.js +5 -194
  16. package/dist/actions/column-controls.js.map +1 -1
  17. package/dist/actions/column-filter.cjs +24 -73
  18. package/dist/actions/column-filter.cjs.map +1 -1
  19. package/dist/actions/column-filter.d.ts +6 -4
  20. package/dist/actions/column-filter.js +25 -74
  21. package/dist/actions/column-filter.js.map +1 -1
  22. package/dist/actions/context.cjs +147 -0
  23. package/dist/actions/context.cjs.map +1 -0
  24. package/dist/actions/context.d.ts +93 -0
  25. package/dist/actions/context.js +145 -0
  26. package/dist/actions/context.js.map +1 -0
  27. package/dist/actions/edit-actions.cjs.map +1 -1
  28. package/dist/actions/edit-actions.d.ts +3 -1
  29. package/dist/actions/edit-actions.js.map +1 -1
  30. package/dist/actions/index.d.ts +2 -3
  31. package/dist/actions/selection.cjs +70 -115
  32. package/dist/actions/selection.cjs.map +1 -1
  33. package/dist/actions/selection.d.ts +22 -12
  34. package/dist/actions/selection.js +71 -114
  35. package/dist/actions/selection.js.map +1 -1
  36. package/dist/actions/table-actions.cjs +41 -0
  37. package/dist/actions/table-actions.cjs.map +1 -0
  38. package/dist/actions/{table-controls.d.ts → table-actions.d.ts} +0 -4
  39. package/dist/actions/{table-controls.js → table-actions.js} +2 -23
  40. package/dist/actions/table-actions.js.map +1 -0
  41. package/dist/actions/types.d.ts +11 -89
  42. package/dist/components/cell-detail.cjs +6 -6
  43. package/dist/components/cell-detail.cjs.map +1 -1
  44. package/dist/components/cell-detail.js +1 -1
  45. package/dist/components/colors.cjs.map +1 -1
  46. package/dist/components/colors.js.map +1 -1
  47. package/dist/components/editor-popup.cjs +7 -7
  48. package/dist/components/editor-popup.cjs.map +1 -1
  49. package/dist/components/editor-popup.js +1 -1
  50. package/dist/components/index.d.ts +2 -1
  51. package/dist/components/indicators/filter-and-sort.cjs +378 -0
  52. package/dist/components/indicators/filter-and-sort.cjs.map +1 -0
  53. package/dist/components/indicators/filter-and-sort.d.ts +59 -0
  54. package/dist/components/indicators/filter-and-sort.js +376 -0
  55. package/dist/components/indicators/filter-and-sort.js.map +1 -0
  56. package/dist/components/indicators/filter-and-sort.module.sass.cjs +16 -0
  57. package/dist/components/indicators/filter-and-sort.module.sass.cjs.map +1 -0
  58. package/dist/components/indicators/filter-and-sort.module.sass.js +14 -0
  59. package/dist/components/indicators/filter-and-sort.module.sass.js.map +1 -0
  60. package/dist/components/indicators/index.d.ts +4 -0
  61. package/dist/components/indicators/selection.cjs +113 -0
  62. package/dist/components/indicators/selection.cjs.map +1 -0
  63. package/dist/components/indicators/selection.d.ts +3 -0
  64. package/dist/components/indicators/selection.js +111 -0
  65. package/dist/components/indicators/selection.js.map +1 -0
  66. package/dist/components/indicators/selection.module.sass.cjs +19 -0
  67. package/dist/components/indicators/selection.module.sass.cjs.map +1 -0
  68. package/dist/components/indicators/selection.module.sass.js +17 -0
  69. package/dist/components/indicators/selection.module.sass.js.map +1 -0
  70. package/dist/components/indicators/unified-filters.cjs +130 -0
  71. package/dist/components/indicators/unified-filters.cjs.map +1 -0
  72. package/dist/components/indicators/unified-filters.d.ts +10 -0
  73. package/dist/components/indicators/unified-filters.js +130 -0
  74. package/dist/components/indicators/unified-filters.js.map +1 -0
  75. package/dist/components/indicators/view-info.cjs +59 -0
  76. package/dist/components/indicators/view-info.cjs.map +1 -0
  77. package/dist/components/{view-info.d.ts → indicators/view-info.d.ts} +1 -0
  78. package/dist/components/{view-info.js → indicators/view-info.js} +17 -13
  79. package/dist/components/indicators/view-info.js.map +1 -0
  80. package/dist/components/text-areas.cjs +5 -5
  81. package/dist/components/text-areas.cjs.map +1 -1
  82. package/dist/components/text-areas.js +1 -1
  83. package/dist/components/toolbars/actions-toolbar.cjs +185 -0
  84. package/dist/components/toolbars/actions-toolbar.cjs.map +1 -0
  85. package/dist/{actions/toolbar.d.ts → components/toolbars/actions-toolbar.d.ts} +9 -5
  86. package/dist/{actions/toolbar.js → components/toolbars/actions-toolbar.js} +37 -112
  87. package/dist/components/toolbars/actions-toolbar.js.map +1 -0
  88. package/dist/components/toolbars/actions-toolbar.module.sass.cjs +29 -0
  89. package/dist/components/toolbars/actions-toolbar.module.sass.cjs.map +1 -0
  90. package/dist/components/toolbars/actions-toolbar.module.sass.js +27 -0
  91. package/dist/components/toolbars/actions-toolbar.module.sass.js.map +1 -0
  92. package/dist/components/toolbars/active-filters.cjs +120 -0
  93. package/dist/components/toolbars/active-filters.cjs.map +1 -0
  94. package/dist/{actions/filters.d.ts → components/toolbars/active-filters.d.ts} +3 -3
  95. package/dist/components/toolbars/active-filters.js +120 -0
  96. package/dist/components/toolbars/active-filters.js.map +1 -0
  97. package/dist/components/toolbars/index.d.ts +2 -0
  98. package/dist/data-panel.cjs +291 -0
  99. package/dist/data-panel.cjs.map +1 -0
  100. package/dist/data-panel.d.ts +110 -0
  101. package/dist/data-panel.js +289 -0
  102. package/dist/data-panel.js.map +1 -0
  103. package/dist/data-panel.module.sass.cjs +40 -0
  104. package/dist/data-panel.module.sass.cjs.map +1 -0
  105. package/dist/data-panel.module.sass.js +38 -0
  106. package/dist/data-panel.module.sass.js.map +1 -0
  107. package/dist/{core.cjs → data-sheet.cjs} +123 -190
  108. package/dist/data-sheet.cjs.map +1 -0
  109. package/dist/data-sheet.css +241 -13
  110. package/dist/data-sheet.d.ts +16 -0
  111. package/dist/{core.js → data-sheet.js} +92 -159
  112. package/dist/data-sheet.js.map +1 -0
  113. package/dist/data-view.cjs +47 -0
  114. package/dist/data-view.cjs.map +1 -0
  115. package/dist/data-view.d.ts +15 -0
  116. package/dist/data-view.js +45 -0
  117. package/dist/data-view.js.map +1 -0
  118. package/dist/filters/operators.cjs +19 -2
  119. package/dist/filters/operators.cjs.map +1 -1
  120. package/dist/filters/operators.d.ts +4 -3
  121. package/dist/filters/operators.js +19 -2
  122. package/dist/filters/operators.js.map +1 -1
  123. package/dist/index.cjs +106 -47
  124. package/dist/index.cjs.map +1 -1
  125. package/dist/index.d.ts +4 -3
  126. package/dist/index.js +76 -17
  127. package/dist/index.js.map +1 -1
  128. package/dist/notifications.cjs +4 -4
  129. package/dist/notifications.cjs.map +1 -1
  130. package/dist/notifications.js +1 -1
  131. package/dist/postgrest-table/data-loaders.cjs +128 -95
  132. package/dist/postgrest-table/data-loaders.cjs.map +1 -1
  133. package/dist/postgrest-table/data-loaders.d.ts +52 -82
  134. package/dist/postgrest-table/data-loaders.js +109 -76
  135. package/dist/postgrest-table/data-loaders.js.map +1 -1
  136. package/dist/postgrest-table/index.cjs +18 -17
  137. package/dist/postgrest-table/index.cjs.map +1 -1
  138. package/dist/postgrest-table/index.d.ts +4 -3
  139. package/dist/postgrest-table/index.js +9 -8
  140. package/dist/postgrest-table/index.js.map +1 -1
  141. package/dist/{utils → provider}/column-spec.cjs +23 -9
  142. package/dist/provider/column-spec.cjs.map +1 -0
  143. package/dist/{utils → provider}/column-spec.d.ts +73 -2
  144. package/dist/{utils → provider}/column-spec.js +24 -10
  145. package/dist/provider/column-spec.js.map +1 -0
  146. package/dist/provider/core.cjs +382 -0
  147. package/dist/provider/core.cjs.map +1 -0
  148. package/dist/provider/core.d.ts +74 -0
  149. package/dist/provider/core.js +380 -0
  150. package/dist/provider/core.js.map +1 -0
  151. package/dist/provider/index.d.ts +7 -0
  152. package/dist/provider/interactions.cjs +128 -0
  153. package/dist/provider/interactions.cjs.map +1 -0
  154. package/dist/provider/interactions.d.ts +39 -0
  155. package/dist/provider/interactions.js +128 -0
  156. package/dist/provider/interactions.js.map +1 -0
  157. package/dist/provider/selection.cjs +29 -0
  158. package/dist/provider/selection.cjs.map +1 -0
  159. package/dist/provider/selection.d.ts +9 -0
  160. package/dist/provider/selection.js +29 -0
  161. package/dist/provider/selection.js.map +1 -0
  162. package/dist/provider/table-data.cjs +92 -0
  163. package/dist/provider/table-data.cjs.map +1 -0
  164. package/dist/provider/table-data.d.ts +81 -0
  165. package/dist/provider/table-data.js +92 -0
  166. package/dist/provider/table-data.js.map +1 -0
  167. package/dist/provider/types.cjs +22 -0
  168. package/dist/provider/types.cjs.map +1 -0
  169. package/dist/provider/types.d.ts +256 -0
  170. package/dist/provider/types.js +22 -0
  171. package/dist/provider/types.js.map +1 -0
  172. package/dist/{zustand-store.cjs → provider/zustand-store.cjs} +36 -23
  173. package/dist/provider/zustand-store.cjs.map +1 -0
  174. package/dist/{zustand-store.js → provider/zustand-store.js} +21 -8
  175. package/dist/provider/zustand-store.js.map +1 -0
  176. package/dist/{cell-renderer.cjs → renderers/cell-renderer.cjs} +67 -34
  177. package/dist/renderers/cell-renderer.cjs.map +1 -0
  178. package/dist/{cell-renderer.d.ts → renderers/cell-renderer.d.ts} +1 -2
  179. package/dist/{cell-renderer.js → renderers/cell-renderer.js} +65 -32
  180. package/dist/renderers/cell-renderer.js.map +1 -0
  181. package/dist/renderers/column-header-cell.cjs +21 -13
  182. package/dist/renderers/column-header-cell.cjs.map +1 -1
  183. package/dist/renderers/column-header-cell.d.ts +3 -2
  184. package/dist/renderers/column-header-cell.js +20 -12
  185. package/dist/renderers/column-header-cell.js.map +1 -1
  186. package/dist/renderers/index.d.ts +1 -0
  187. package/dist/types.cjs +7 -19
  188. package/dist/types.cjs.map +1 -1
  189. package/dist/types.d.ts +117 -229
  190. package/dist/types.js +7 -19
  191. package/dist/types.js.map +1 -1
  192. package/dist/utils/atoms.cjs +24 -0
  193. package/dist/utils/atoms.cjs.map +1 -0
  194. package/dist/utils/atoms.d.ts +4 -0
  195. package/dist/utils/atoms.js +24 -0
  196. package/dist/utils/atoms.js.map +1 -0
  197. package/dist/utils/debug-overlay.cjs.map +1 -1
  198. package/dist/utils/debug-overlay.js.map +1 -1
  199. package/dist/utils/index.d.ts +2 -3
  200. package/dist/utils/key-handling.cjs +140 -139
  201. package/dist/utils/key-handling.cjs.map +1 -1
  202. package/dist/utils/key-handling.d.ts +4 -2
  203. package/dist/utils/key-handling.js +136 -135
  204. package/dist/utils/key-handling.js.map +1 -1
  205. package/dist/utils/validation.cjs +6 -1
  206. package/dist/utils/validation.cjs.map +1 -1
  207. package/dist/utils/validation.d.ts +1 -1
  208. package/dist/utils/validation.js +6 -1
  209. package/dist/utils/validation.js.map +1 -1
  210. package/package.json +4 -3
  211. package/src/actions/builtin.ts +1 -4
  212. package/src/actions/clipboard.ts +4 -3
  213. package/src/actions/column-controls.ts +12 -245
  214. package/src/actions/column-filter.ts +28 -92
  215. package/src/actions/context.ts +299 -0
  216. package/src/actions/edit-actions.ts +3 -1
  217. package/src/actions/index.ts +2 -3
  218. package/src/actions/selection.ts +109 -156
  219. package/src/actions/{table-controls.ts → table-actions.ts} +0 -24
  220. package/src/actions/types.ts +17 -101
  221. package/src/components/colors.ts +1 -1
  222. package/src/components/index.ts +2 -1
  223. package/src/components/indicators/filter-and-sort.module.sass +13 -0
  224. package/src/components/indicators/filter-and-sort.ts +478 -0
  225. package/src/components/indicators/index.ts +4 -0
  226. package/src/components/indicators/selection.module.sass +22 -0
  227. package/src/components/indicators/selection.ts +141 -0
  228. package/src/components/indicators/unified-filters.ts +161 -0
  229. package/src/components/{view-info.ts → indicators/view-info.ts} +16 -27
  230. package/src/{actions/toolbar.module.sass → components/toolbars/actions-toolbar.module.sass} +17 -4
  231. package/src/{actions/toolbar.ts → components/toolbars/actions-toolbar.ts} +49 -150
  232. package/src/components/toolbars/active-filters.ts +150 -0
  233. package/src/components/toolbars/index.ts +2 -0
  234. package/src/data-panel.module.sass +185 -0
  235. package/src/data-panel.ts +556 -0
  236. package/src/{core.ts → data-sheet.ts} +145 -330
  237. package/src/data-view.ts +70 -0
  238. package/src/filters/operators.ts +33 -3
  239. package/src/index.ts +4 -3
  240. package/src/postgrest-table/data-loaders.ts +244 -171
  241. package/src/postgrest-table/index.ts +10 -9
  242. package/src/{utils → provider}/column-spec.ts +30 -15
  243. package/src/provider/core.ts +585 -0
  244. package/src/provider/index.ts +7 -0
  245. package/src/provider/interactions.ts +161 -0
  246. package/src/provider/selection.ts +31 -0
  247. package/src/provider/table-data.ts +178 -0
  248. package/src/provider/types.ts +273 -0
  249. package/src/{zustand-store.ts → provider/zustand-store.ts} +35 -14
  250. package/src/{cell-renderer.ts → renderers/cell-renderer.ts} +140 -57
  251. package/src/renderers/column-header-cell.ts +21 -14
  252. package/src/renderers/index.ts +1 -0
  253. package/src/types.ts +137 -239
  254. package/src/utils/atoms.ts +28 -0
  255. package/src/utils/debug-overlay.ts +1 -1
  256. package/src/utils/index.ts +2 -8
  257. package/src/utils/key-handling.ts +170 -164
  258. package/src/utils/validation.ts +7 -2
  259. package/dist/actions/filters.cjs +0 -139
  260. package/dist/actions/filters.cjs.map +0 -1
  261. package/dist/actions/filters.js +0 -139
  262. package/dist/actions/filters.js.map +0 -1
  263. package/dist/actions/table-controls.cjs +0 -62
  264. package/dist/actions/table-controls.cjs.map +0 -1
  265. package/dist/actions/table-controls.js.map +0 -1
  266. package/dist/actions/toolbar.cjs +0 -260
  267. package/dist/actions/toolbar.cjs.map +0 -1
  268. package/dist/actions/toolbar.js.map +0 -1
  269. package/dist/actions/toolbar.module.sass.cjs +0 -27
  270. package/dist/actions/toolbar.module.sass.cjs.map +0 -1
  271. package/dist/actions/toolbar.module.sass.js +0 -25
  272. package/dist/actions/toolbar.module.sass.js.map +0 -1
  273. package/dist/cell-renderer.cjs.map +0 -1
  274. package/dist/cell-renderer.js.map +0 -1
  275. package/dist/components/view-info.cjs +0 -55
  276. package/dist/components/view-info.cjs.map +0 -1
  277. package/dist/components/view-info.js.map +0 -1
  278. package/dist/core.cjs.map +0 -1
  279. package/dist/core.d.ts +0 -117
  280. package/dist/core.js.map +0 -1
  281. package/dist/provider.cjs +0 -197
  282. package/dist/provider.cjs.map +0 -1
  283. package/dist/provider.d.ts +0 -26
  284. package/dist/provider.js +0 -195
  285. package/dist/provider.js.map +0 -1
  286. package/dist/table-updates/data-parameter.d.ts +0 -14
  287. package/dist/table-updates/filter.d.ts +0 -16
  288. package/dist/table-updates/index.d.ts +0 -19
  289. package/dist/utils/column-spec.cjs.map +0 -1
  290. package/dist/utils/column-spec.js.map +0 -1
  291. package/dist/utils/index.cjs +0 -9
  292. package/dist/utils/index.cjs.map +0 -1
  293. package/dist/utils/index.js +0 -9
  294. package/dist/utils/index.js.map +0 -1
  295. package/dist/zustand-store.cjs.map +0 -1
  296. package/dist/zustand-store.js.map +0 -1
  297. package/src/actions/filters.ts +0 -176
  298. package/src/components/actions.module.sass +0 -8
  299. package/src/provider.ts +0 -267
  300. package/src/table-updates/data-parameter.ts +0 -44
  301. package/src/table-updates/filter.ts +0 -124
  302. package/src/table-updates/index.ts +0 -239
  303. /package/dist/{zustand-store.d.ts → provider/zustand-store.d.ts} +0 -0
@@ -1,41 +1,20 @@
1
- import { Button, ButtonGroup, PopoverNext, Tag } from "@blueprintjs/core";
2
- import { useCallback, useMemo, useState } from "react";
3
- import h from "./toolbar.module.sass";
4
- import { useSelector, useStoreAPI } from "../provider";
1
+ import { Button, ButtonGroup, PopoverNext } from "@blueprintjs/core";
2
+ import { type ReactNode, useCallback, useMemo, useState } from "react";
3
+ import h from "./actions-toolbar.module.sass";
4
+ import { ctx, selectionAtom, useSelector } from "../../provider";
5
5
  import {
6
- buildActionContext,
7
6
  getApplicableActions,
8
7
  getSelectionCardinality,
9
8
  mergeColumnActions,
10
- } from "./selection";
11
- import type { TableAction, TableActionContext } from "./types";
9
+ buildActionContext,
10
+ TableActionContext,
11
+ runActionWrapper,
12
+ type TableAction,
13
+ } from "../../actions";
12
14
  import { RegionCardinality } from "@blueprintjs/table";
13
- import { useToaster } from "../notifications.ts";
14
- import { DataSheetStore } from "../types.ts";
15
- import { ColumnSpec } from "../utils";
16
-
17
- /** A short title describing the current selection (its shape), shown as the
18
- * toolbar's leading label — no icon. */
19
- function selectionTitle<T>(ctx: TableActionContext<T>): string | null {
20
- const sh = ctx.selectionShape;
21
- switch (sh.cardinality) {
22
- case RegionCardinality.FULL_COLUMNS: {
23
- if (ctx.columnKey != null) {
24
- const col = ctx.columnSpec.find((c) => c.key === ctx.columnKey);
25
- return col?.name ?? "Column";
26
- }
27
- return `${sh.columns} columns`;
28
- }
29
- case RegionCardinality.FULL_ROWS:
30
- return ctx.rowIndex != null ? "1 row" : `${sh.rows} rows`;
31
- case RegionCardinality.CELLS:
32
- return ctx.cell != null ? "Cell" : `${sh.columns}×${sh.rows} cells`;
33
- case RegionCardinality.FULL_TABLE:
34
- return null;
35
- default:
36
- return null;
37
- }
38
- }
15
+ import { useToaster } from "../../notifications.ts";
16
+ import type { ColumnSpec } from "../../provider";
17
+ import { SelectionIndicator } from "../index.ts";
39
18
 
40
19
  /** Toolbar that renders the actions/controls applicable to the current
41
20
  * selection cardinality (modal by selection) and edit mode. Actions with a
@@ -44,16 +23,23 @@ function selectionTitle<T>(ctx: TableActionContext<T>): string | null {
44
23
  * are merged when their columns are selected. A capsule on the left shows the
45
24
  * current selection polarity. */
46
25
  export function ActionsToolbar<T>({
47
- actions,
48
- tableName,
26
+ actions: _actions,
27
+ children,
28
+ className,
29
+ compact = false,
49
30
  }: {
50
31
  actions: TableAction<T>[];
51
32
  tableName?: string;
33
+ children: ReactNode;
34
+ className?: string;
35
+ compact: boolean;
52
36
  }) {
53
- const selection = useSelector((state) => state.selection);
37
+ const selection = ctx.useValue(selectionAtom);
54
38
  const editable = useSelector((state) => state.editable);
55
39
  const columnSpec = useSelector((state) => state.columnSpec);
56
- const storeAPI = useStoreAPI();
40
+
41
+ const actionIDs = new Set(_actions.map((a) => a.id));
42
+ const actions = useMemo(() => _actions, [actionIDs]);
57
43
 
58
44
  const cardinality = useMemo(
59
45
  () => getSelectionCardinality(selection) ?? RegionCardinality.FULL_TABLE,
@@ -71,19 +57,21 @@ export function ActionsToolbar<T>({
71
57
  [allActions, cardinality, editable],
72
58
  );
73
59
 
60
+ const store = ctx.useStore();
74
61
  // Context for `render`-style controls (they subscribe to the store
75
62
  // themselves; this resolves the selected column/rows).
76
- const ctx = buildActionContext(
77
- storeAPI.getState(),
78
- storeAPI.setState,
79
- ) as TableActionContext<T>;
63
+ const actionContext = useMemo(() => {
64
+ return buildActionContext(store.get, store.set);
65
+ }, [allActions]);
80
66
 
81
67
  // The toolbar is for actions that AREN'T keyboard-accessible: any action
82
68
  // with a `hotkey` (copy/cut/paste, etc.) is reachable from the keyboard and
83
69
  // is omitted here (it still works via its shortcut). Then refine by selection
84
70
  // shape beyond cardinality (e.g. single column only).
85
71
  const shownActions = applicableActions.filter(
86
- (action) => action.hotkey == null && (action.appliesTo?.(ctx) ?? true),
72
+ (action: TableAction<T, any>) =>
73
+ action.hotkey == null &&
74
+ (action.appliesTo?.(actionContext as any) ?? true),
87
75
  );
88
76
 
89
77
  const toolbarIsShown = useMemo(
@@ -95,86 +83,41 @@ export function ActionsToolbar<T>({
95
83
  return null;
96
84
  }
97
85
 
98
- // The toolbar is always mounted if actions are available, so it can't flicker
99
- // in/out as the selection or action set changes — the container is stable;
100
- // only its contents (title + buttons) change. Avoids layout jank.
101
- //
102
- // The leading title doubles as the clear-selection affordance: with an active
103
- // selection it renders as a dismissible tag (its ✕ clears the selection),
104
- // which ties "clear" to the selection it acts on and frees toolbar space.
105
- // With no selection it's a plain label (table name).
106
- // Both states render as a `large` `Tag` so the title keeps a constant font
107
- // and height; only the selected one has a filled background + a ✕ (which
108
- // clears the selection). The unselected label is a transparent, non-removable
109
- // tag — visually a plain title, but the same box.
110
- const hasSelection = selection != null && selection.length > 0;
111
- const titleNode = h(
112
- Tag,
113
- {
114
- key: "title",
115
- minimal: true,
116
- large: true,
117
- onRemove: hasSelection
118
- ? () =>
119
- storeAPI.setState({
120
- selection: [],
121
- focusedCell: null,
122
- topLeftCell: null,
123
- })
124
- : undefined,
125
- style: hasSelection ? undefined : { background: "transparent" },
126
- },
127
- hasSelection
128
- ? (selectionTitle(ctx) ?? tableName ?? "Selection")
129
- : (tableName ?? "Table"),
130
- );
131
-
132
- // Order left→right by generality: actions applicable to the whole table (or
133
- // no selection) are "global" and sit after a spacer on the right (Save /
86
+ // Order left→right by generality: actions that require editing
87
+ // are "global" and sit after a spacer on the right (Save /
134
88
  // Reset); everything else is contextual and stays on the left. So the left
135
89
  // edge tracks the selection and the right edge is constant.
136
90
  const isGlobal = (a: TableAction<T>) =>
137
- a.targets.includes(RegionCardinality.FULL_TABLE) ||
138
- a.targets.includes("none" as any);
91
+ (a.targets.includes(RegionCardinality.FULL_TABLE) ||
92
+ a.targets.includes("none" as any)) &&
93
+ a.requiresEditable;
139
94
  const contextual = shownActions.filter((a) => !isGlobal(a));
140
95
  // Order the built-in global actions least→most impactful, left→right: reset
141
96
  // changes, then save. Any other global actions keep their natural order to
142
97
  // the left of these (stable sort, rank 0).
143
- const globalOrder: Record<string, number> = {
144
- "reset-changes": 1,
145
- "save-changes": 2,
146
- };
147
- const globalActions = shownActions
148
- .filter(isGlobal)
149
- .sort((a, b) => (globalOrder[a.id] ?? 0) - (globalOrder[b.id] ?? 0));
150
98
 
151
- return h("div.actions-toolbar", [
152
- titleNode,
99
+ const globalActions = shownActions.filter(isGlobal);
100
+
101
+ return h("div.actions-toolbar", { className }, [
102
+ h(SelectionIndicator, { minimal: compact }),
153
103
  h(
154
- ButtonGroup,
155
- { key: "contextual", minimal: true },
104
+ "div.toolbar-group.contextual",
156
105
  contextual.map((action) =>
157
- h(ActionButton, { key: action.id, action, ctx }),
106
+ h(ActionButton, { key: action.id, action, ctx: actionContext }),
158
107
  ),
159
108
  ),
160
- h("div.toolbar-spacer", { key: "spacer", style: { flex: 1 } }),
109
+ children,
110
+ h("div.toolbar-spacer", { style: { flex: 1 } }),
161
111
  h(
162
112
  ButtonGroup,
163
- { key: "global", minimal: true },
113
+ { minimal: true },
164
114
  globalActions.map((action) =>
165
- h(ActionButton, { key: action.id, action, ctx }),
115
+ h(ActionButton, { key: action.id, action, ctx: actionContext }),
166
116
  ),
167
117
  ),
168
118
  ]);
169
119
  }
170
120
 
171
- function getMessageForError(e: any) {
172
- if (e instanceof Error) return e.message;
173
- if (typeof e === "string") return e;
174
- if (e instanceof Object) return JSON.stringify(e);
175
- return null;
176
- }
177
-
178
121
  function isActionDisabled(action: TableAction, state: any): boolean {
179
122
  if (typeof action.disabled === "boolean") return action.disabled;
180
123
  if (typeof action.disabled === "function") {
@@ -183,35 +126,6 @@ function isActionDisabled(action: TableAction, state: any): boolean {
183
126
  return false;
184
127
  }
185
128
 
186
- export function runActionWrapper<T>(
187
- action: TableAction<T>,
188
- state: DataSheetStore<any>,
189
- setState: (state: Partial<DataSheetStore<any>>) => void,
190
- toaster: any,
191
- configState: any = undefined,
192
- ) {
193
- const ctx = buildActionContext(state, setState) as TableActionContext<T>;
194
- if (action.disabled instanceof Function) {
195
- if (action.disabled(ctx)) {
196
- return;
197
- }
198
- } else if (action.disabled) {
199
- return;
200
- }
201
- try {
202
- const res = action.run?.(ctx, configState);
203
- if (res instanceof Promise) {
204
- res
205
- .then(() => {})
206
- .catch((e) => {
207
- displayErrorForAction(action, e, toaster);
208
- });
209
- }
210
- } catch (e) {
211
- displayErrorForAction(action, e, toaster);
212
- }
213
- }
214
-
215
129
  /** Dispatcher: a live control (`action.render`) or a run/detailsForm button.
216
130
  * Kept hook-free so the two paths don't share a hook order. */
217
131
  function ActionButton<T>({
@@ -229,7 +143,7 @@ function ActionButton<T>({
229
143
 
230
144
  /** A run/detailsForm action rendered as a button. */
231
145
  function RunActionButton<T>({ action }: { action: TableAction<T> }) {
232
- const storeAPI = useStoreAPI();
146
+ const store = ctx.useStore();
233
147
  const toaster = useToaster();
234
148
 
235
149
  // Reactive disabled check — re-renders when relevant state changes
@@ -239,15 +153,9 @@ function RunActionButton<T>({ action }: { action: TableAction<T> }) {
239
153
 
240
154
  const runAction = useCallback(
241
155
  (configState?: any) => {
242
- runActionWrapper(
243
- action,
244
- storeAPI.getState(),
245
- storeAPI.setState,
246
- toaster,
247
- configState,
248
- );
156
+ runActionWrapper(action, store.get, store.set, toaster, configState);
249
157
  },
250
- [storeAPI, action, toaster],
158
+ [action, toaster],
251
159
  );
252
160
 
253
161
  if (action.detailsForm != null) {
@@ -268,15 +176,6 @@ function RunActionButton<T>({ action }: { action: TableAction<T> }) {
268
176
  );
269
177
  }
270
178
 
271
- function displayErrorForAction(action: TableAction, error: any, toaster: any) {
272
- const message =
273
- getMessageForError(error) ?? action.errorMessage ?? "Action failed";
274
- toaster.show({
275
- message,
276
- intent: "danger",
277
- });
278
- }
279
-
280
179
  /** Action button that opens a popover for pre-run configuration. */
281
180
  function ActionButtonWithForm<T, S>({
282
181
  action,
@@ -304,7 +203,7 @@ function ActionButtonWithForm<T, S>({
304
203
  onClose: () => setIsOpen(false),
305
204
  content: h("div.action-popover-content", [
306
205
  h.if(action.description != null)("p.description", action.description),
307
- h(action.detailsForm, {
206
+ h(action.detailsForm as any, {
308
207
  state: configState,
309
208
  setState: setConfigState,
310
209
  }),
@@ -0,0 +1,150 @@
1
+ import { Button, Menu, MenuItem, PopoverNext, Tag } from "@blueprintjs/core";
2
+ import { useMemo } from "react";
3
+ import { RegionCardinality } from "@blueprintjs/table";
4
+ import h from "./actions-toolbar.module.sass";
5
+ import { useSelector, useStoreAPI } from "../../provider";
6
+ import {
7
+ buildMultiOperatorColumnFilter,
8
+ getSelectionCardinality,
9
+ type TableFilter,
10
+ } from "../../actions";
11
+ import type { ColumnSpec } from "../../provider";
12
+ import { ColumnSortIndicator, FilterIndicator } from "../indicators";
13
+
14
+ /** Collect all available filters from global filters and column specs. */
15
+ function collectAllFilters<T>(
16
+ globalFilters: TableFilter<T>[],
17
+ columnSpec: ColumnSpec[],
18
+ ): TableFilter<T>[] {
19
+ const result: TableFilter<T>[] = [...globalFilters];
20
+ for (const col of columnSpec) {
21
+ if (col.filters != null) {
22
+ for (const f of col.filters as TableFilter<T>[]) {
23
+ const withKey: TableFilter<T> = {
24
+ ...f,
25
+ columnKey: f.columnKey ?? col.key,
26
+ };
27
+ if (!result.some((r) => r.id === withKey.id)) {
28
+ result.push(withKey);
29
+ }
30
+ }
31
+ }
32
+ // Auto-generate the built-in operator filter for a `filterable` column,
33
+ // unless the column already supplies an explicit filter.
34
+ if (col.filterable && !result.some((r) => r.columnKey === col.key)) {
35
+ result.push(buildMultiOperatorColumnFilter(col) as TableFilter<T>);
36
+ }
37
+ }
38
+ return result;
39
+ }
40
+
41
+ /** The single view-state bar: active **sorts** and **filters** shown as
42
+ * removable tags (filters reconfigurable in place via their `filterForm`). The
43
+ * "Add filter" button offers only **table-level** filters (no `columnKey`) and
44
+ * only when no column is selected — per-column filters are added/configured
45
+ * from the column header dropdown instead, so there's no redundancy. */
46
+ export function ActiveFiltersList<T>({
47
+ filters = [],
48
+ }: {
49
+ filters?: TableFilter<T>[];
50
+ }) {
51
+ const columnSpec = useSelector((state) => state.columnSpec);
52
+ const storeAPI = useStoreAPI();
53
+ const activeFilters = useSelector((state) => state.activeFilters);
54
+ const columnSorts = useSelector((state) => state.columnSorts);
55
+ const selection = useSelector((state) => state.selection);
56
+
57
+ const columnSelected =
58
+ getSelectionCardinality(selection) === RegionCardinality.FULL_COLUMNS;
59
+
60
+ const allFilters = useMemo(
61
+ () => collectAllFilters(filters, columnSpec),
62
+ [filters, columnSpec],
63
+ );
64
+
65
+ const activeIds = useMemo(
66
+ () => new Set(activeFilters.keys()),
67
+ [activeFilters],
68
+ );
69
+
70
+ // Only table-level filters are addable from the bar; column filters live in
71
+ // the column header dropdown.
72
+ const availableFilters = useMemo(
73
+ () => allFilters.filter((f) => f.columnKey == null && !activeIds.has(f.id)),
74
+ [allFilters, activeIds],
75
+ );
76
+
77
+ const showAdd = !columnSelected && availableFilters.length > 0;
78
+
79
+ const hasAnything =
80
+ columnSorts.length > 0 || activeFilters.size > 0 || showAdd;
81
+ if (!hasAnything)
82
+ return h(
83
+ "div.filter-bar.empty",
84
+ h("p.description", "No active filters or sorts"),
85
+ );
86
+
87
+ const filterArray = Array.from(activeFilters.entries()) as any[];
88
+
89
+ return h("div.filter-bar", [
90
+ h(
91
+ "div.group.filters",
92
+ filterArray.map(([id, entry]) =>
93
+ h(FilterIndicator, {
94
+ key: id,
95
+ ...entry,
96
+ large: false,
97
+ minimal: false,
98
+ showSubject: true,
99
+ }),
100
+ ),
101
+ ),
102
+ h(
103
+ "div.group.sorts",
104
+ columnSorts.map((s) => {
105
+ return h(ColumnSortIndicator, {
106
+ columnKey: s.key,
107
+ large: false,
108
+ showColumnKey: true,
109
+ });
110
+ }),
111
+ h.if(showAdd)(AddFilterPopover, {
112
+ filters: availableFilters,
113
+ }),
114
+ ),
115
+ ]);
116
+ }
117
+
118
+ /** Popover menu listing available (not-yet-active) filters. */
119
+ function AddFilterPopover<T>({ filters }: { filters: TableFilter<T>[] }) {
120
+ const storeAPI = useStoreAPI();
121
+
122
+ return h(
123
+ PopoverNext,
124
+ {
125
+ content: h(
126
+ Menu,
127
+ filters.map((f) =>
128
+ h(MenuItem, {
129
+ key: f.id,
130
+ text: f.name,
131
+ icon: f.icon ?? "filter",
132
+ onClick() {
133
+ storeAPI.getState().setFilter(f.id, f, f.defaultState);
134
+ },
135
+ }),
136
+ ),
137
+ ),
138
+ placement: "bottom-start",
139
+ },
140
+ h(
141
+ Button,
142
+ {
143
+ minimal: true,
144
+ small: true,
145
+ icon: "filter",
146
+ },
147
+ "Add filter",
148
+ ),
149
+ );
150
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./actions-toolbar";
2
+ export * from "./active-filters";
@@ -0,0 +1,185 @@
1
+ // Layout scaffolding for the DataPanel (card-list renderer). Card visuals are
2
+ // the consumer's `itemComponent`; the panel owns only the surrounding chrome.
3
+
4
+ :root
5
+ --data-panel-content-padding: 0px
6
+
7
+
8
+ .data-panel
9
+ display: flex
10
+ flex: 1 1 auto
11
+ min-height: 0
12
+ flex-direction: row
13
+ width: 100%
14
+ min-width: 0
15
+ --data-panel-content-padding: 12px
16
+ --data-panel-item-gap: 8px
17
+ --data-panel-content-width: 100%
18
+ --data-panel-selected-color: #2d72d2
19
+ --data-panel-selected-background: rgba(45, 114, 210, 0.1)
20
+
21
+ // Body + optional sidebar share a horizontal row, each scrolling on its own.
22
+ .data-panel-main
23
+ display: flex
24
+ flex-direction: column
25
+ flex: 1 1 auto
26
+
27
+ .data-panel-sidebar-container
28
+ flex: 0 0 auto
29
+ width: var(--data-panel-sidebar-width, 240px)
30
+ min-height: 0
31
+ overflow-y: auto
32
+ padding: var(--data-panel-content-padding)
33
+ border-left: 1px solid var(--panel-rule-color)
34
+
35
+ // The scroll container: owns overflow + holds the layout body and the sentinel.
36
+ // The scrollbar sits flush at the container's right edge (no reserved gutter);
37
+ // right padding keeps card content clear of it.
38
+ .data-panel-body
39
+ flex: 1 1 auto
40
+ min-height: 0
41
+ min-width: 0
42
+ overflow-y: auto
43
+ padding: var(--data-panel-content-padding)
44
+
45
+ .data-panel-main > *
46
+ display: flex
47
+ flex-direction: column
48
+ align-items: center
49
+ &>*
50
+ flex: 1
51
+ max-width: var(--data-panel-content-width, 100%)
52
+ width: var(--data-panel-content-width, 100%)
53
+ min-width: 0
54
+
55
+ // The inline end-of-scroll region (default spinner sentinel, or an inline
56
+ // footer). Sits in the scroll flow, so it's seen only at the bottom.
57
+ .content-footer-holder
58
+ flex: 0 0 auto
59
+
60
+ // Default layout body — a vertical list of cards. A custom `scrollBody`
61
+ // replaces this element (e.g. with a CSS grid) but keeps the same scroll
62
+ // container and sentinel around it.
63
+ .data-panel-list
64
+ display: flex
65
+ flex-direction: column
66
+ gap: var(--data-panel-item-gap, 8px)
67
+ flex-grow: 1
68
+
69
+ .data-panel-item
70
+ // Rows are click-selectable, so suppress native text selection — otherwise
71
+ // shift/cmd-click drags a text range as well as selecting the row (Finder /
72
+ // Gmail-style list behavior).
73
+ user-select: none
74
+ // Keep a card intact when a `scrollBody` uses a multi-column (masonry)
75
+ // layout; no effect in the default list/grid.
76
+ break-inside: avoid
77
+
78
+ .sentinel
79
+ display: flex
80
+ align-items: center
81
+ justify-content: center
82
+ gap: var(--data-panel-item-gap, 8px)
83
+ padding: 12px
84
+ color: var(--text-subtle, #738091)
85
+ font-size: 13px
86
+
87
+ .data-panel-toolbar-content
88
+ max-width: var(--data-panel-content-width)
89
+
90
+ .data-panel-footer
91
+ color: var(--text-subtle, #738091)
92
+
93
+ .data-panel-footer-content
94
+ gap: var(--data-panel-item-gap, 8px)
95
+ padding: 0.2em var(--data-panel-content-padding)
96
+ .spacer
97
+ flex: 1
98
+
99
+ // Default data panel footer
100
+ .data-panel-status-bar
101
+ display: flex
102
+ flex-direction: row
103
+ align-items: center
104
+
105
+ .data-card
106
+ display: flex
107
+ gap: var(--data-panel-item-gap, 1em)
108
+ padding: var(--data-panel-card-padding, 1em)
109
+ border: 1px solid rgba(128,128,128,0.25)
110
+ border-radius: 4px
111
+ background: var(--card-background-color)
112
+ cursor: pointer
113
+ &.selected
114
+ background: var(--data-panel-selected-background)
115
+ outline: 1.5px solid var(--data-panel-selected-color)
116
+ &:hover
117
+ background: var(--data-panel-selected-background)
118
+ border-color: var(--data-panel-selected-color)
119
+ outline-width: 2px
120
+
121
+ &.selectable:not(.selected)
122
+ &:hover
123
+ border-color: rgba(128,128,128,0.5)
124
+ background: rgba(128,128,128,0.08)
125
+
126
+ .data-panel
127
+ &.toolbar-style-bordered
128
+ .data-panel-toolbar, .data-panel-footer
129
+ background-color: var(--panel-secondary-background-color)
130
+
131
+ .data-panel-toolbar
132
+ border-bottom: 1px solid var(--panel-rule-color)
133
+
134
+ .data-panel-footer
135
+ border-top: 1px solid var(--panel-rule-color)
136
+
137
+ &.toolbar-style-floating
138
+ --data-panel-top-margin: calc(var(--data-panel-toolbar-height, 40px) + 2 * var(--data-panel-content-padding, 12px))
139
+
140
+ .data-panel-toolbar, .data-panel-footer
141
+ //background-color: var(--panel-secondary-background-color)
142
+ border-radius: 4px
143
+ //box-shadow: 0 0 0 1px var(--panel-rule-color)
144
+
145
+ .data-panel-footer, .data-panel-toolbar
146
+ z-index: 10
147
+ min-width: 0
148
+ max-width: fit-content
149
+ position: absolute
150
+ width: var(--data-panel-content-width, 100%)
151
+
152
+ &>*
153
+ max-width: unset
154
+ flex-grow: unset
155
+ width: unset
156
+
157
+ .data-panel-toolbar
158
+ left: 50%
159
+ transform: translateX(calc((var(--data-panel-content-width, 100%) / -2) - 4px))
160
+ top: var(--data-panel-content-padding, 12px)
161
+ background-color: var(--panel-secondary-background-color)
162
+ box-shadow: 0 0 0 1px var(--panel-rule-color)
163
+ .data-panel-toolbar-content
164
+ padding-left: 6px
165
+ padding-right: 6px
166
+ &>*:empty
167
+ display: none
168
+
169
+
170
+ .data-panel-footer
171
+ bottom: var(--data-panel-content-padding, 12px)
172
+ height: fit-content
173
+ right: var(--data-panel-content-padding, 12px)
174
+ background-color: var(--background-color)
175
+
176
+ .data-panel-body
177
+ padding-top: var(--data-panel-top-margin)
178
+ mask-image: linear-gradient(to bottom, transparent 4px, var(--background-color) var(--data-panel-top-margin))
179
+
180
+ &.toolbar-style-fade
181
+ // Fade content into the top edge as it slips under the toolbar — but only
182
+ // once scrolled, so the first item isn't clipped at rest.
183
+ .data-panel-body.is-scrolled
184
+ mask-image: linear-gradient(to bottom, transparent 0, var(--background-color) 20px)
185
+