@macrostrat/data-sheet 4.10.0 → 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 +34 -0
- package/dist/components/data-editor.cjs +11 -3
- package/dist/components/data-editor.cjs.map +1 -1
- package/dist/components/data-editor.js +11 -3
- package/dist/components/data-editor.js.map +1 -1
- 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/data-editor.ts +17 -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
package/dist/data-sheet.css
CHANGED
|
@@ -1327,48 +1327,42 @@ span._sep_1r3aw_9:first-child, span._sep_1r3aw_9:last-child {
|
|
|
1327
1327
|
position: relative;
|
|
1328
1328
|
flex-grow: 1;
|
|
1329
1329
|
display: block;
|
|
1330
|
-
}._actions-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
padding: 0.2em;
|
|
1336
|
-
min-height: var(--panel-header-height, 40px);
|
|
1330
|
+
}._actions-toolbar_1fcib_1 > [role=toolbar] {
|
|
1331
|
+
--toolbar-gap: 8px;
|
|
1332
|
+
--toolbar-padding-x: 0.2em;
|
|
1333
|
+
--toolbar-padding-y: 0.2em;
|
|
1334
|
+
--toolbar-height: var(--panel-header-height, 40px);
|
|
1337
1335
|
}
|
|
1338
1336
|
|
|
1339
|
-
._toolbar-
|
|
1337
|
+
._toolbar-title_1fcib_8 {
|
|
1340
1338
|
font-weight: 600;
|
|
1341
1339
|
white-space: nowrap;
|
|
1342
1340
|
min-width: 100px;
|
|
1343
1341
|
}
|
|
1344
1342
|
|
|
1345
|
-
._toolbar-
|
|
1343
|
+
._toolbar-group_1fcib_14 {
|
|
1346
1344
|
display: flex;
|
|
1347
1345
|
flex-direction: row;
|
|
1348
1346
|
gap: 4px;
|
|
1349
1347
|
align-items: center;
|
|
1350
1348
|
}
|
|
1351
1349
|
|
|
1352
|
-
.
|
|
1353
|
-
flex-grow: 1;
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1356
|
-
._action-popover-content_3x53e_27, ._filter-config_3x53e_27 {
|
|
1350
|
+
._action-popover-content_1fcib_21, ._filter-config_1fcib_21 {
|
|
1357
1351
|
padding: 12px;
|
|
1358
1352
|
max-width: 300px;
|
|
1359
1353
|
}
|
|
1360
|
-
._action-popover-
|
|
1354
|
+
._action-popover-content_1fcib_21 p._description_1fcib_25, ._filter-config_1fcib_21 p._description_1fcib_25 {
|
|
1361
1355
|
margin: 0 0 8px 0;
|
|
1362
1356
|
color: var(--secondary-color);
|
|
1363
1357
|
font-size: 0.9em;
|
|
1364
1358
|
}
|
|
1365
1359
|
|
|
1366
|
-
._run-
|
|
1360
|
+
._run-button_1fcib_31 {
|
|
1367
1361
|
margin-top: 8px;
|
|
1368
1362
|
width: 100%;
|
|
1369
1363
|
}
|
|
1370
1364
|
|
|
1371
|
-
._filter-
|
|
1365
|
+
._filter-bar_1fcib_36 {
|
|
1372
1366
|
display: flex;
|
|
1373
1367
|
flex-direction: row;
|
|
1374
1368
|
flex-wrap: wrap;
|
|
@@ -1377,21 +1371,21 @@ span._sep_1r3aw_9:first-child, span._sep_1r3aw_9:last-child {
|
|
|
1377
1371
|
justify-content: flex-start;
|
|
1378
1372
|
height: var(--filter-bar-height, 24px);
|
|
1379
1373
|
}
|
|
1380
|
-
._filter-
|
|
1374
|
+
._filter-bar_1fcib_36 ._description_1fcib_25 {
|
|
1381
1375
|
margin: 0;
|
|
1382
1376
|
color: var(--secondary-color);
|
|
1383
1377
|
font-size: 0.9em;
|
|
1384
1378
|
}
|
|
1385
|
-
._filter-
|
|
1379
|
+
._filter-bar_1fcib_36 > ._group_1fcib_50 {
|
|
1386
1380
|
display: flex;
|
|
1387
1381
|
flex-direction: row;
|
|
1388
1382
|
gap: 4px;
|
|
1389
1383
|
}
|
|
1390
|
-
._filter-
|
|
1384
|
+
._filter-bar_1fcib_36 ._filter-tag_1fcib_55 {
|
|
1391
1385
|
display: flex;
|
|
1392
1386
|
}
|
|
1393
1387
|
|
|
1394
|
-
._filter-
|
|
1388
|
+
._filter-window_1fcib_59 {
|
|
1395
1389
|
opacity: 0.8;
|
|
1396
1390
|
font-variant-numeric: tabular-nums;
|
|
1397
1391
|
}._selection-indicator_1648m_1 {
|
package/dist/index.cjs
CHANGED
|
@@ -23,6 +23,7 @@ const textAreas = require("./components/text-areas.cjs");
|
|
|
23
23
|
const editorActions = require("./components/editor-actions.cjs");
|
|
24
24
|
const editorPopup = require("./components/editor-popup.cjs");
|
|
25
25
|
const viewInfo = require("./components/indicators/view-info.cjs");
|
|
26
|
+
const uiComponents = require("@macrostrat/ui-components");
|
|
26
27
|
const clipboard = require("./actions/clipboard.cjs");
|
|
27
28
|
const rowEditor = require("./components/row-editor.cjs");
|
|
28
29
|
const selection = require("./components/indicators/selection.cjs");
|
|
@@ -89,7 +90,6 @@ exports.ColumnSortMenu = filterAndSort.ColumnSortMenu;
|
|
|
89
90
|
exports.FilterIndicator = filterAndSort.FilterIndicator;
|
|
90
91
|
exports.InlineFilterControl = filterAndSort.InlineFilterControl;
|
|
91
92
|
exports.MenuDropdown = filterAndSort.MenuDropdown;
|
|
92
|
-
exports.MenuFormItem = filterAndSort.MenuFormItem;
|
|
93
93
|
exports.MenuInlineFilterItem = filterAndSort.MenuInlineFilterItem;
|
|
94
94
|
exports.resolveColumnFilter = filterAndSort.resolveColumnFilter;
|
|
95
95
|
exports.DEFAULT_ROW_STATUS_STYLES = types.DEFAULT_ROW_STATUS_STYLES;
|
|
@@ -138,6 +138,10 @@ exports.editorActionsFor = editorActions.editorActionsFor;
|
|
|
138
138
|
exports.EditorPopup = editorPopup.EditorPopup;
|
|
139
139
|
exports.LoadProgressIndicator = viewInfo.LoadProgressIndicator;
|
|
140
140
|
exports.LoadProgressLabel = viewInfo.LoadProgressLabel;
|
|
141
|
+
Object.defineProperty(exports, "MenuFormItem", {
|
|
142
|
+
enumerable: true,
|
|
143
|
+
get: () => uiComponents.MenuFormItem
|
|
144
|
+
});
|
|
141
145
|
exports.PasteShape = clipboard.PasteShape;
|
|
142
146
|
exports.clipboardActions = clipboard.clipboardActions;
|
|
143
147
|
exports.copyAction = clipboard.copyAction;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import { ActiveFiltersList } from "./components/toolbars/active-filters.js";
|
|
|
12
12
|
import { CellDetailModal } from "./components/cell-detail.js";
|
|
13
13
|
import { CellRendererDebugOverlay } from "./utils/debug-overlay.js";
|
|
14
14
|
import { ColorCell, ColorPicker, colorSwatchRenderer } from "./components/colors.js";
|
|
15
|
-
import { ColumnFilterControl, ColumnFilterForm, ColumnFilterMenu, ColumnFilterMenuItem, ColumnSortIndicator, ColumnSortMenu, FilterIndicator, InlineFilterControl, MenuDropdown,
|
|
15
|
+
import { ColumnFilterControl, ColumnFilterForm, ColumnFilterMenu, ColumnFilterMenuItem, ColumnSortIndicator, ColumnSortMenu, FilterIndicator, InlineFilterControl, MenuDropdown, MenuInlineFilterItem, resolveColumnFilter } from "./components/indicators/filter-and-sort.js";
|
|
16
16
|
import { DEFAULT_ROW_STATUS_STYLES, DS_ROW_ID, TableElementStatus } from "./provider/types.js";
|
|
17
17
|
import { DataEditor, DataEditorField, DataEditorFields, DataEditorFrame, FieldValue, MixedValues, sharedValue, valueToken } from "./components/data-editor.js";
|
|
18
18
|
import { DataSheetProvider, DataSheetProviderInner, capitalize, columnSpecAtom, ctx, dataProviderAtom, itemLabelAtom, pluralFormOf, pluralize, splitDataProviderProps, storeAPIAtom, storeAtom, tableActionsAtom, tableDataAtom, tableNameAtom, useItemCount, useResolvedProvider, useSelector, useStoreAPI } from "./provider/core.js";
|
|
@@ -21,6 +21,7 @@ import { EditableTextArea } from "./components/text-areas.js";
|
|
|
21
21
|
import { EditorActionButton, editorActionContext, editorActionsFor } from "./components/editor-actions.js";
|
|
22
22
|
import { EditorPopup } from "./components/editor-popup.js";
|
|
23
23
|
import { LoadProgressIndicator, LoadProgressLabel } from "./components/indicators/view-info.js";
|
|
24
|
+
import { MenuFormItem } from "@macrostrat/ui-components";
|
|
24
25
|
import { PasteShape, clipboardActions, copyAction, cutAction, pasteAction, serializeSelectionToTSV } from "./actions/clipboard.js";
|
|
25
26
|
import { RowEditor, RowEditorField, RowEditorFrame, SelectedDataEditor, SelectedRowEditor, ShowRowEditor, rowEditorOpenAtom, showRowEditorAction, useRowEditorOpen, useSelectedRow, useSelectedRows } from "./components/row-editor.js";
|
|
26
27
|
import { SelectionIndicator, toggleModalSelectionAtom } from "./components/indicators/selection.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@macrostrat/data-sheet",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.11.0",
|
|
4
4
|
"description": "Scalable data sheet with optional editing capabilities",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@macrostrat/data-components": "^1.8.0",
|
|
53
53
|
"@macrostrat/hyper": "^3.1.1",
|
|
54
54
|
"@macrostrat/scoped-store": "^1.1.0",
|
|
55
|
-
"@macrostrat/ui-components": "^5.
|
|
55
|
+
"@macrostrat/ui-components": "^5.3.0",
|
|
56
56
|
"@supabase/postgrest-js": "^1.17.7",
|
|
57
57
|
"@types/underscore": "^1.13.0",
|
|
58
58
|
"classnames": "^2.5.1",
|
|
@@ -648,8 +648,13 @@ function DefaultFieldEditor({ ctx }: { ctx: CellDetailContext }) {
|
|
|
648
648
|
className: "field-switch",
|
|
649
649
|
});
|
|
650
650
|
}
|
|
651
|
+
// A text field starts from the value as the column draws it, when that is
|
|
652
|
+
// text — as a grid cell's inline editor does — so a structured value the
|
|
653
|
+
// column shows as a string (a list written out, a record by name) is edited
|
|
654
|
+
// as that string, not as `[object Object]`
|
|
655
|
+
const text = editableText(ctx);
|
|
651
656
|
if (type === "text") {
|
|
652
|
-
return h(CommittedTextArea, { value, placeholder, onCommit: onChange });
|
|
657
|
+
return h(CommittedTextArea, { value: text, placeholder, onCommit: onChange });
|
|
653
658
|
}
|
|
654
659
|
if (type === "number" || type === "integer") {
|
|
655
660
|
return h(CommittedInput, {
|
|
@@ -665,7 +670,17 @@ function DefaultFieldEditor({ ctx }: { ctx: CellDetailContext }) {
|
|
|
665
670
|
// `cellDetail`. Show the value so the form is still complete.
|
|
666
671
|
return h(FieldValue, { ctx });
|
|
667
672
|
}
|
|
668
|
-
return h(CommittedInput, { value, placeholder, onCommit: onChange });
|
|
673
|
+
return h(CommittedInput, { value: text, placeholder, onCommit: onChange });
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/** The text a field's editor starts from: the column's rendering of the
|
|
677
|
+
* value when it renders to a string, else the value itself. */
|
|
678
|
+
function editableText(ctx: CellDetailContext): any {
|
|
679
|
+
const { value, column } = ctx;
|
|
680
|
+
if (value == null || column.valueRenderer == null) return value;
|
|
681
|
+
const rendered = column.valueRenderer(value, ctx);
|
|
682
|
+
if (typeof rendered === "string") return rendered;
|
|
683
|
+
return value;
|
|
669
684
|
}
|
|
670
685
|
|
|
671
686
|
function parseNumber(text: string, type: "number" | "integer") {
|
|
@@ -14,8 +14,12 @@ import {
|
|
|
14
14
|
MenuDivider,
|
|
15
15
|
MenuItem,
|
|
16
16
|
PopoverNext,
|
|
17
|
-
Tag,
|
|
18
17
|
} from "@blueprintjs/core";
|
|
18
|
+
import {
|
|
19
|
+
FilterTag,
|
|
20
|
+
MenuFormItem,
|
|
21
|
+
ToolbarDropdown,
|
|
22
|
+
} from "@macrostrat/ui-components";
|
|
19
23
|
import { FilterOperator, OPERATOR_LABELS } from "../../filters/operators";
|
|
20
24
|
import classNames from "classnames";
|
|
21
25
|
import { atom } from "jotai";
|
|
@@ -74,13 +78,7 @@ export function FilterIndicator({
|
|
|
74
78
|
showSubject: boolean;
|
|
75
79
|
}) {
|
|
76
80
|
const props = useFilterProps(filter);
|
|
77
|
-
|
|
78
|
-
const { valueText, filterForm, icon, intent, isActive, onRemove } = props;
|
|
79
|
-
|
|
80
|
-
let rightIcon: string | undefined = "caret-down";
|
|
81
|
-
if (isActive) {
|
|
82
|
-
rightIcon = undefined;
|
|
83
|
-
}
|
|
81
|
+
const { valueText, filterForm, icon, isActive, clear } = props;
|
|
84
82
|
|
|
85
83
|
const label = buildFilterTagLabel(filter, valueText, {
|
|
86
84
|
minimal,
|
|
@@ -88,69 +86,22 @@ export function FilterIndicator({
|
|
|
88
86
|
isActive,
|
|
89
87
|
});
|
|
90
88
|
|
|
89
|
+
// The shared bar look: caret while inactive, primary + ✕ once in effect.
|
|
91
90
|
return h(
|
|
92
|
-
|
|
93
|
-
{
|
|
94
|
-
|
|
95
|
-
},
|
|
96
|
-
h(
|
|
97
|
-
Tag,
|
|
98
|
-
{
|
|
99
|
-
minimal: true,
|
|
100
|
-
large,
|
|
101
|
-
icon,
|
|
102
|
-
rightIcon,
|
|
103
|
-
intent,
|
|
104
|
-
onRemove,
|
|
105
|
-
className: classNames("filter-tag", { active: isActive }),
|
|
106
|
-
},
|
|
107
|
-
h("span.filter-label", label),
|
|
108
|
-
),
|
|
91
|
+
FilterTag,
|
|
92
|
+
{ icon, large, active: isActive, onClear: clear, content: filterForm },
|
|
93
|
+
h("span.filter-label", label),
|
|
109
94
|
);
|
|
110
95
|
}
|
|
111
96
|
|
|
112
|
-
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
|
|
116
|
-
* and a control whose own typeahead renders in a separate portal (a
|
|
117
|
-
* `MultiSelect`, a date picker) has focus yanked back out of it by an enclosing
|
|
118
|
-
* trap — which is what makes a nested filter submenu feel unstable. Caller
|
|
119
|
-
* props are passed through (`placement`, `isOpen`, …).
|
|
120
|
-
*/
|
|
121
|
-
export function MenuDropdown({ children, content, ...props }: any) {
|
|
122
|
-
return h(
|
|
123
|
-
PopoverNext,
|
|
124
|
-
{
|
|
125
|
-
content,
|
|
126
|
-
placement: "bottom-start",
|
|
127
|
-
enforceFocus: false,
|
|
128
|
-
autoFocus: false,
|
|
129
|
-
arrow: false,
|
|
130
|
-
...props,
|
|
131
|
-
},
|
|
132
|
-
children,
|
|
133
|
-
);
|
|
134
|
-
}
|
|
97
|
+
/** A dropdown for a panel of controls (not just menu items), not focus-
|
|
98
|
+
* trapping. Now `ToolbarDropdown` in `@macrostrat/ui-components`; kept here
|
|
99
|
+
* under its old name. */
|
|
100
|
+
export const MenuDropdown = ToolbarDropdown;
|
|
135
101
|
|
|
136
|
-
/**
|
|
137
|
-
*
|
|
138
|
-
|
|
139
|
-
* popover to lose focus to. The building block behind `MenuInlineFilterItem`,
|
|
140
|
-
* exported so a custom control panel can use the same idiom.
|
|
141
|
-
*/
|
|
142
|
-
export function MenuFormItem({
|
|
143
|
-
title,
|
|
144
|
-
children,
|
|
145
|
-
}: {
|
|
146
|
-
title?: ReactNode;
|
|
147
|
-
children: ReactNode;
|
|
148
|
-
}) {
|
|
149
|
-
return h("li.menu-form-item", [
|
|
150
|
-
h.if(title != null)(MenuDivider, { title }),
|
|
151
|
-
h("div.menu-form-body", children),
|
|
152
|
-
]);
|
|
153
|
-
}
|
|
102
|
+
/** A titled form block inside a menu. Now in `@macrostrat/ui-components`;
|
|
103
|
+
* re-exported here under its old home. */
|
|
104
|
+
export { MenuFormItem };
|
|
154
105
|
|
|
155
106
|
function buildFilterTagLabel(
|
|
156
107
|
filter: TableFilter,
|
|
@@ -295,6 +246,7 @@ function useFilterProps(filter: TableFilter) {
|
|
|
295
246
|
nameText: filter.name,
|
|
296
247
|
valueText: summary,
|
|
297
248
|
onRemove: isActive ? onRemove : undefined,
|
|
249
|
+
clear: () => setState(null),
|
|
298
250
|
};
|
|
299
251
|
}
|
|
300
252
|
|
|
@@ -433,34 +385,20 @@ export function ColumnSortIndicator({
|
|
|
433
385
|
const { icon, label, intent } = displayParamsForSort(sort);
|
|
434
386
|
|
|
435
387
|
const columnLabel = showColumnKey ? `${columnKey}: ` : "";
|
|
436
|
-
let onRemove: any = undefined;
|
|
437
|
-
let rightIcon: string | undefined = "caret-down";
|
|
438
|
-
if (sort != null) {
|
|
439
|
-
rightIcon = undefined;
|
|
440
|
-
onRemove = () => setSort(null);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
388
|
let valLabel = label;
|
|
444
389
|
valLabel ??= showColumnKey ? columnKey : "Sort";
|
|
445
390
|
|
|
446
391
|
return h(
|
|
447
|
-
|
|
392
|
+
FilterTag,
|
|
448
393
|
{
|
|
394
|
+
small,
|
|
395
|
+
large: large ?? false,
|
|
396
|
+
icon,
|
|
397
|
+
active: sort != null,
|
|
398
|
+
onClear: () => setSort(null),
|
|
449
399
|
content: h(Menu, h(ColumnSortActions, { sort, setSort })),
|
|
450
400
|
},
|
|
451
|
-
h(
|
|
452
|
-
Tag,
|
|
453
|
-
{
|
|
454
|
-
small,
|
|
455
|
-
large,
|
|
456
|
-
minimal: true,
|
|
457
|
-
icon,
|
|
458
|
-
rightIcon,
|
|
459
|
-
intent,
|
|
460
|
-
onRemove,
|
|
461
|
-
},
|
|
462
|
-
h([columnLabel, valLabel]),
|
|
463
|
-
),
|
|
401
|
+
h([columnLabel, valLabel]),
|
|
464
402
|
);
|
|
465
403
|
}
|
|
466
404
|
|
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
} from "../../provider";
|
|
14
14
|
import { type ReactNode, useMemo } from "react";
|
|
15
15
|
import h from "../../data-panel.module.sass";
|
|
16
|
-
import { Button, Menu, MenuDivider
|
|
16
|
+
import { Button, Menu, MenuDivider } from "@blueprintjs/core";
|
|
17
|
+
import { FilterTag } from "@macrostrat/ui-components";
|
|
17
18
|
import {
|
|
18
19
|
ColumnFilterMenuItem,
|
|
19
20
|
ColumnSortMenu,
|
|
@@ -208,10 +209,8 @@ function useExitSelectionAction(): TableAction | null {
|
|
|
208
209
|
requiresEditable: false,
|
|
209
210
|
render: () =>
|
|
210
211
|
h(
|
|
211
|
-
|
|
212
|
+
FilterTag,
|
|
212
213
|
{
|
|
213
|
-
minimal: true,
|
|
214
|
-
large: true,
|
|
215
214
|
interactive: true,
|
|
216
215
|
icon: "filter",
|
|
217
216
|
title: "Filter and sort (leaves select mode)",
|
|
@@ -250,28 +249,12 @@ function useFilterSubsetState(entries: FilterEntry[]): [boolean, () => void] {
|
|
|
250
249
|
return [hasActive, clear as () => void];
|
|
251
250
|
}
|
|
252
251
|
|
|
253
|
-
function useDisplayIntent([hasActive, clearActive]: [boolean, () => void]) {
|
|
254
|
-
const intent = hasActive ? "primary" : "none";
|
|
255
|
-
|
|
256
|
-
let rightIcon: "caret-down" | undefined = "caret-down";
|
|
257
|
-
let onRemove: any = undefined;
|
|
258
|
-
if (hasActive) {
|
|
259
|
-
rightIcon = undefined;
|
|
260
|
-
onRemove = (evt) => {
|
|
261
|
-
clearActive();
|
|
262
|
-
evt.stopPropagation();
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
return { intent, rightIcon, onRemove, hasActive };
|
|
267
|
-
}
|
|
268
|
-
|
|
269
252
|
function useFilterMenuAction(entries: FilterEntry[]): TableAction | null {
|
|
270
253
|
// Scoped to the filters this menu actually holds. An `"inline"` filter has
|
|
271
254
|
// its own always-visible control, so it must not light up the Filter tag —
|
|
272
255
|
// nor be wiped by its clear button, which reads as "clear the filters in
|
|
273
256
|
// here".
|
|
274
|
-
const
|
|
257
|
+
const [hasActive, clearActive] = useFilterSubsetState(entries);
|
|
275
258
|
|
|
276
259
|
if (entries.length === 0) return null;
|
|
277
260
|
|
|
@@ -287,17 +270,6 @@ function useFilterMenuAction(entries: FilterEntry[]): TableAction | null {
|
|
|
287
270
|
}),
|
|
288
271
|
);
|
|
289
272
|
|
|
290
|
-
const filterIndicator = h(
|
|
291
|
-
Tag,
|
|
292
|
-
{
|
|
293
|
-
minimal: true,
|
|
294
|
-
large: true,
|
|
295
|
-
icon: "filter",
|
|
296
|
-
...rest,
|
|
297
|
-
},
|
|
298
|
-
"Filter",
|
|
299
|
-
);
|
|
300
|
-
|
|
301
273
|
return {
|
|
302
274
|
id: "filter",
|
|
303
275
|
name: "Filter",
|
|
@@ -305,14 +277,16 @@ function useFilterMenuAction(entries: FilterEntry[]): TableAction | null {
|
|
|
305
277
|
description: "Add a filter to the data panel.",
|
|
306
278
|
targets: ALL_CARDINALITIES,
|
|
307
279
|
requiresEditable: false,
|
|
308
|
-
render: (
|
|
280
|
+
render: () =>
|
|
309
281
|
h(
|
|
310
|
-
|
|
282
|
+
FilterTag,
|
|
311
283
|
{
|
|
284
|
+
icon: "filter",
|
|
285
|
+
active: hasActive,
|
|
286
|
+
onClear: clearActive,
|
|
312
287
|
content: filterMenu,
|
|
313
|
-
placement: "bottom-start",
|
|
314
288
|
},
|
|
315
|
-
|
|
289
|
+
"Filter",
|
|
316
290
|
),
|
|
317
291
|
};
|
|
318
292
|
}
|
|
@@ -320,7 +294,7 @@ function useFilterMenuAction(entries: FilterEntry[]): TableAction | null {
|
|
|
320
294
|
function useSortAction(): TableAction | null {
|
|
321
295
|
const columnSpec = useSelector((s) => s.columnSpec);
|
|
322
296
|
|
|
323
|
-
const
|
|
297
|
+
const [hasActive, clearSorts] = ctx.use(hasActiveSortsAtom);
|
|
324
298
|
|
|
325
299
|
const sortableCols = useMemo(
|
|
326
300
|
() => columnSpec.filter((c) => c.sortable),
|
|
@@ -344,19 +318,17 @@ function useSortAction(): TableAction | null {
|
|
|
344
318
|
description: "Add a sort to the data panel.",
|
|
345
319
|
targets: ALL_CARDINALITIES,
|
|
346
320
|
requiresEditable: false,
|
|
347
|
-
render: (
|
|
348
|
-
h(
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
),
|
|
359
|
-
]),
|
|
321
|
+
render: () =>
|
|
322
|
+
h(
|
|
323
|
+
FilterTag,
|
|
324
|
+
{
|
|
325
|
+
icon: "sort",
|
|
326
|
+
active: hasActive,
|
|
327
|
+
onClear: clearSorts as () => void,
|
|
328
|
+
content: sortMenu,
|
|
329
|
+
},
|
|
330
|
+
"Sort",
|
|
331
|
+
),
|
|
360
332
|
};
|
|
361
333
|
}
|
|
362
334
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
padding: 0.2em
|
|
7
|
-
|
|
1
|
+
// The shared `Toolbar` (ui-components) lays this out; these knobs keep the
|
|
2
|
+
// data panel's compact metrics. Set on the inner bar, which consumes them, so
|
|
3
|
+
// they outrank the toolbar's own defaults whatever the stylesheet order.
|
|
4
|
+
.actions-toolbar > [role="toolbar"]
|
|
5
|
+
--toolbar-gap: 8px
|
|
6
|
+
--toolbar-padding-x: 0.2em
|
|
7
|
+
--toolbar-padding-y: 0.2em
|
|
8
|
+
--toolbar-height: var(--panel-header-height, 40px)
|
|
8
9
|
|
|
9
10
|
// Leading label naming the current selection shape (no icon) — reads as the
|
|
10
11
|
// toolbar's title.
|
|
@@ -19,9 +20,6 @@
|
|
|
19
20
|
gap: 4px
|
|
20
21
|
align-items: center
|
|
21
22
|
|
|
22
|
-
.spacer
|
|
23
|
-
flex-grow: 1
|
|
24
|
-
|
|
25
23
|
.action-popover-content, .filter-config
|
|
26
24
|
padding: 12px
|
|
27
25
|
max-width: 300px
|
|
@@ -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
|
),
|