@macrostrat/data-sheet 4.10.1 → 4.11.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 +24 -0
- package/dist/components/indicators/filter-and-sort.cjs +20 -71
- package/dist/components/indicators/filter-and-sort.cjs.map +1 -1
- package/dist/components/indicators/filter-and-sort.d.ts +10 -23
- package/dist/components/indicators/filter-and-sort.js +18 -69
- package/dist/components/indicators/filter-and-sort.js.map +1 -1
- package/dist/components/indicators/unified-filters.cjs +22 -46
- package/dist/components/indicators/unified-filters.cjs.map +1 -1
- package/dist/components/indicators/unified-filters.js +23 -47
- package/dist/components/indicators/unified-filters.js.map +1 -1
- package/dist/components/toolbars/actions-toolbar.cjs +39 -18
- package/dist/components/toolbars/actions-toolbar.cjs.map +1 -1
- package/dist/components/toolbars/actions-toolbar.d.ts +7 -4
- package/dist/components/toolbars/actions-toolbar.js +37 -18
- package/dist/components/toolbars/actions-toolbar.js.map +1 -1
- package/dist/components/toolbars/actions-toolbar.module.sass.cjs +11 -14
- package/dist/components/toolbars/actions-toolbar.module.sass.cjs.map +1 -1
- package/dist/components/toolbars/actions-toolbar.module.sass.js +12 -15
- package/dist/components/toolbars/actions-toolbar.module.sass.js.map +1 -1
- package/dist/data-panel.cjs +3 -1
- package/dist/data-panel.cjs.map +1 -1
- package/dist/data-panel.d.ts +6 -1
- package/dist/data-panel.js +3 -1
- package/dist/data-panel.js.map +1 -1
- package/dist/data-sheet.css +15 -21
- package/dist/index.cjs +5 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/indicators/filter-and-sort.ts +25 -87
- package/src/components/indicators/unified-filters.ts +22 -50
- package/src/components/toolbars/actions-toolbar.module.sass +8 -10
- package/src/components/toolbars/actions-toolbar.ts +48 -17
- package/src/data-panel.ts +7 -0
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { Button, ButtonGroup, PopoverNext } from "@blueprintjs/core";
|
|
2
2
|
import { type ReactNode, useCallback, useMemo, useState } from "react";
|
|
3
|
+
import {
|
|
4
|
+
Toolbar,
|
|
5
|
+
type ToolbarCollapse,
|
|
6
|
+
type ToolbarItem,
|
|
7
|
+
} from "@macrostrat/ui-components";
|
|
8
|
+
import classNames from "classnames";
|
|
3
9
|
import h from "./actions-toolbar.module.sass";
|
|
4
10
|
import { ctx, selectionAtom, useSelector } from "../../provider";
|
|
5
11
|
import {
|
|
@@ -28,12 +34,17 @@ export function ActionsToolbar<T>({
|
|
|
28
34
|
children,
|
|
29
35
|
className,
|
|
30
36
|
compact = false,
|
|
37
|
+
collapse = "never",
|
|
31
38
|
}: {
|
|
32
39
|
actions: TableAction<T>[];
|
|
33
40
|
tableName?: string;
|
|
34
41
|
children: ReactNode;
|
|
35
42
|
className?: string;
|
|
36
43
|
compact: boolean;
|
|
44
|
+
/** How the bar sheds width (see `Toolbar`): contextual actions fold into a
|
|
45
|
+
* "more" popover when `narrow`; the selection title and the global actions
|
|
46
|
+
* stay. Default `never`. */
|
|
47
|
+
collapse?: ToolbarCollapse;
|
|
37
48
|
}) {
|
|
38
49
|
const selection = ctx.useValue(selectionAtom);
|
|
39
50
|
const editable = useSelector((state) => state.editable);
|
|
@@ -108,24 +119,44 @@ export function ActionsToolbar<T>({
|
|
|
108
119
|
|
|
109
120
|
const globalActions = shownActions.filter(isGlobal);
|
|
110
121
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
// Laid out by the shared `Toolbar`: the selection title, contextual actions
|
|
123
|
+
// and any custom chrome (`children`, at its natural width) lead; the global
|
|
124
|
+
// actions sit at the end as one group.
|
|
125
|
+
const start: ToolbarItem[] = [
|
|
126
|
+
{
|
|
127
|
+
id: "selection",
|
|
128
|
+
pinned: true,
|
|
129
|
+
content: h(SelectionIndicator, { minimal: compact }),
|
|
130
|
+
},
|
|
131
|
+
...contextual.map((action) => ({
|
|
132
|
+
id: action.id,
|
|
133
|
+
content: h(ActionButton, { action, ctx: actionContext }),
|
|
134
|
+
})),
|
|
135
|
+
];
|
|
136
|
+
if (children != null) {
|
|
137
|
+
start.push({ id: "toolbar-children", pinned: true, content: children });
|
|
138
|
+
}
|
|
139
|
+
const end: ToolbarItem[] = [];
|
|
140
|
+
if (globalActions.length > 0) {
|
|
141
|
+
end.push({
|
|
142
|
+
id: "global-actions",
|
|
143
|
+
pinned: true,
|
|
144
|
+
content: h(
|
|
145
|
+
ButtonGroup,
|
|
146
|
+
{ minimal: true },
|
|
147
|
+
globalActions.map((action) =>
|
|
148
|
+
h(ActionButton, { key: action.id, action, ctx: actionContext }),
|
|
149
|
+
),
|
|
126
150
|
),
|
|
127
|
-
)
|
|
128
|
-
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return h(Toolbar, {
|
|
155
|
+
className: classNames("actions-toolbar", className),
|
|
156
|
+
collapse,
|
|
157
|
+
start,
|
|
158
|
+
end,
|
|
159
|
+
});
|
|
129
160
|
}
|
|
130
161
|
|
|
131
162
|
function isActionDisabled(action: TableAction, state: any): boolean {
|
package/src/data-panel.ts
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
*
|
|
23
23
|
* See [[Data list editors]] in the Macrostrat workbench for the design.
|
|
24
24
|
*/
|
|
25
|
+
import type { ToolbarCollapse } from "@macrostrat/ui-components";
|
|
25
26
|
import h from "./data-panel.module.sass";
|
|
26
27
|
import {
|
|
27
28
|
ComponentType,
|
|
@@ -164,6 +165,10 @@ export interface DataPanelProps<T = any> extends DataViewSharedProps<T> {
|
|
|
164
165
|
* Ignored while a modal view is selecting: the toolbar then carries a single
|
|
165
166
|
* control that leaves select mode. */
|
|
166
167
|
viewControls?: ViewControlsPresentation;
|
|
168
|
+
/** How the toolbar sheds width (the shared `Toolbar`'s `collapse`): with
|
|
169
|
+
* `"narrow"`, button labels drop to icons and then contextual controls fold
|
|
170
|
+
* into a "more" popover as the panel narrows. Default `"never"`. */
|
|
171
|
+
toolbarCollapse?: ToolbarCollapse;
|
|
167
172
|
/** Arbitrary children rendered inside the provider, after the panel. */
|
|
168
173
|
children?: ReactNode;
|
|
169
174
|
}
|
|
@@ -216,6 +221,7 @@ export function DataPanelRenderer<T>({
|
|
|
216
221
|
className,
|
|
217
222
|
toolbarStyle = DataPanelToolbarStyle.BORDERED,
|
|
218
223
|
viewControls = "inline",
|
|
224
|
+
toolbarCollapse = "never",
|
|
219
225
|
children,
|
|
220
226
|
}: Omit<DataPanelProps<T>, "provider" | "fetchData" | "data" | "identity">) {
|
|
221
227
|
const {
|
|
@@ -487,6 +493,7 @@ export function DataPanelRenderer<T>({
|
|
|
487
493
|
// so only render it when modal selection is toggle-able (or a
|
|
488
494
|
// selection is active) — not as a bare label otherwise.
|
|
489
495
|
compact: true,
|
|
496
|
+
collapse: toolbarCollapse,
|
|
490
497
|
},
|
|
491
498
|
toolbar,
|
|
492
499
|
),
|