@macrostrat/data-sheet 3.1.0 → 4.0.0-dev2
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 +19 -0
- package/dist/actions/builtin.cjs +56 -0
- package/dist/actions/builtin.cjs.map +1 -0
- package/dist/actions/builtin.d.ts +15 -0
- package/dist/actions/builtin.js +56 -0
- package/dist/actions/builtin.js.map +1 -0
- package/dist/actions/clipboard.cjs +250 -0
- package/dist/actions/clipboard.cjs.map +1 -0
- package/dist/actions/clipboard.d.ts +42 -0
- package/dist/actions/clipboard.js +250 -0
- package/dist/actions/clipboard.js.map +1 -0
- package/dist/actions/filters.cjs +123 -0
- package/dist/actions/filters.cjs.map +1 -0
- package/dist/actions/filters.d.ts +6 -0
- package/dist/actions/filters.js +123 -0
- package/dist/actions/filters.js.map +1 -0
- package/dist/actions/index.d.ts +6 -0
- package/dist/actions/selection.cjs +194 -0
- package/dist/actions/selection.cjs.map +1 -0
- package/dist/actions/selection.d.ts +40 -0
- package/dist/actions/selection.js +192 -0
- package/dist/actions/selection.js.map +1 -0
- package/dist/actions/toolbar.cjs +171 -0
- package/dist/actions/toolbar.cjs.map +1 -0
- package/dist/actions/toolbar.d.ts +10 -0
- package/dist/actions/toolbar.js +171 -0
- package/dist/actions/toolbar.js.map +1 -0
- package/dist/actions/toolbar.module.sass.cjs +22 -0
- package/dist/actions/toolbar.module.sass.cjs.map +1 -0
- package/dist/actions/toolbar.module.sass.js +20 -0
- package/dist/actions/toolbar.module.sass.js.map +1 -0
- package/dist/actions/types.d.ts +143 -0
- package/dist/cell-renderer.cjs +44 -41
- package/dist/cell-renderer.cjs.map +1 -1
- package/dist/cell-renderer.d.ts +1 -6
- package/dist/cell-renderer.js +45 -42
- package/dist/cell-renderer.js.map +1 -1
- package/dist/components/actions.module.sass.cjs +3 -3
- package/dist/components/actions.module.sass.js +2 -2
- package/dist/components/colors.cjs +20 -16
- package/dist/components/colors.cjs.map +1 -1
- package/dist/components/colors.d.ts +3 -2
- package/dist/components/colors.js +20 -16
- package/dist/components/colors.js.map +1 -1
- package/dist/components/editor-popup.cjs +4 -3
- package/dist/components/editor-popup.cjs.map +1 -1
- package/dist/components/editor-popup.js +4 -3
- package/dist/components/editor-popup.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/main.module.sass.cjs +12 -12
- package/dist/components/main.module.sass.js +11 -11
- package/dist/components/text-areas.cjs +23 -18
- package/dist/components/text-areas.cjs.map +1 -1
- package/dist/components/text-areas.d.ts +8 -4
- package/dist/components/text-areas.js +20 -13
- package/dist/components/text-areas.js.map +1 -1
- package/dist/components/view-info.cjs +18 -0
- package/dist/components/view-info.cjs.map +1 -0
- package/dist/components/view-info.d.ts +1 -0
- package/dist/components/view-info.js +18 -0
- package/dist/components/view-info.js.map +1 -0
- package/dist/core.cjs +184 -156
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +14 -1
- package/dist/core.js +187 -157
- package/dist/core.js.map +1 -1
- package/dist/data-sheet.css +181 -43
- package/dist/index.cjs +43 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +43 -10
- package/dist/index.js.map +1 -1
- package/dist/main.module.sass.cjs +15 -14
- package/dist/main.module.sass.cjs.map +1 -1
- package/dist/main.module.sass.js +14 -13
- package/dist/main.module.sass.js.map +1 -1
- package/dist/notifications.cjs +19 -0
- package/dist/notifications.cjs.map +1 -0
- package/dist/notifications.d.ts +9 -0
- package/dist/notifications.js +19 -0
- package/dist/notifications.js.map +1 -0
- package/dist/postgrest-table/data-loaders.cjs +181 -104
- package/dist/postgrest-table/data-loaders.cjs.map +1 -1
- package/dist/postgrest-table/data-loaders.d.ts +52 -28
- package/dist/postgrest-table/data-loaders.js +181 -104
- package/dist/postgrest-table/data-loaders.js.map +1 -1
- package/dist/postgrest-table/index.cjs +205 -79
- package/dist/postgrest-table/index.cjs.map +1 -1
- package/dist/postgrest-table/index.d.ts +13 -16
- package/dist/postgrest-table/index.js +186 -58
- package/dist/postgrest-table/index.js.map +1 -1
- package/dist/postgrest-table/lazy-loader-table.cjs +18 -17
- package/dist/postgrest-table/lazy-loader-table.cjs.map +1 -1
- package/dist/postgrest-table/lazy-loader-table.d.ts +1 -1
- package/dist/postgrest-table/lazy-loader-table.js +17 -14
- package/dist/postgrest-table/lazy-loader-table.js.map +1 -1
- package/dist/postgrest-table/loading-utils.cjs +16 -0
- package/dist/postgrest-table/loading-utils.cjs.map +1 -0
- package/dist/postgrest-table/loading-utils.d.ts +13 -0
- package/dist/postgrest-table/loading-utils.js +16 -0
- package/dist/postgrest-table/loading-utils.js.map +1 -0
- package/dist/postgrest-table/main.module.sass.cjs +18 -13
- package/dist/postgrest-table/main.module.sass.cjs.map +1 -1
- package/dist/postgrest-table/main.module.sass.js +18 -13
- package/dist/postgrest-table/main.module.sass.js.map +1 -1
- package/dist/provider.cjs +58 -26
- package/dist/provider.cjs.map +1 -1
- package/dist/provider.js +57 -23
- package/dist/provider.js.map +1 -1
- package/dist/renderers/column-header-cell-postgrest.cjs +216 -0
- package/dist/renderers/column-header-cell-postgrest.cjs.map +1 -0
- package/dist/renderers/column-header-cell-postgrest.d.ts +13 -0
- package/dist/renderers/column-header-cell-postgrest.js +216 -0
- package/dist/renderers/column-header-cell-postgrest.js.map +1 -0
- package/dist/renderers/column-header-cell-postgrest.module.sass.cjs +23 -0
- package/dist/renderers/column-header-cell-postgrest.module.sass.cjs.map +1 -0
- package/dist/renderers/column-header-cell-postgrest.module.sass.js +22 -0
- package/dist/renderers/column-header-cell-postgrest.module.sass.js.map +1 -0
- package/dist/renderers/column-header-cell.cjs +103 -0
- package/dist/renderers/column-header-cell.cjs.map +1 -0
- package/dist/renderers/column-header-cell.d.ts +30 -0
- package/dist/renderers/column-header-cell.js +101 -0
- package/dist/renderers/column-header-cell.js.map +1 -0
- package/dist/renderers/index.d.ts +2 -0
- package/dist/table-updates/data-parameter.d.ts +14 -0
- package/dist/table-updates/filter.d.ts +16 -0
- package/dist/table-updates/index.d.ts +19 -0
- package/dist/types.cjs +9 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.ts +58 -4
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/column-spec.cjs +9 -1
- package/dist/utils/column-spec.cjs.map +1 -1
- package/dist/utils/column-spec.d.ts +21 -0
- package/dist/utils/column-spec.js +9 -1
- package/dist/utils/column-spec.js.map +1 -1
- package/dist/utils/key-handling.cjs +141 -52
- package/dist/utils/key-handling.cjs.map +1 -1
- package/dist/utils/key-handling.d.ts +2 -3
- package/dist/utils/key-handling.js +142 -53
- package/dist/utils/key-handling.js.map +1 -1
- package/dist/zustand-store.cjs +216 -51
- package/dist/zustand-store.cjs.map +1 -1
- package/dist/zustand-store.js +197 -32
- package/dist/zustand-store.js.map +1 -1
- package/package.json +5 -5
- package/src/actions/builtin.ts +65 -0
- package/src/actions/clipboard.ts +350 -0
- package/src/actions/filters.ts +150 -0
- package/src/actions/index.ts +6 -0
- package/src/actions/selection.ts +271 -0
- package/src/actions/toolbar.module.sass +30 -0
- package/src/actions/toolbar.ts +212 -0
- package/src/actions/types.ts +159 -0
- package/src/cell-renderer.ts +55 -51
- package/src/components/colors.ts +22 -19
- package/src/components/editor-popup.ts +3 -2
- package/src/components/index.ts +1 -0
- package/src/components/main.module.sass +1 -0
- package/src/components/text-areas.ts +34 -19
- package/src/components/view-info.ts +17 -0
- package/src/core.ts +243 -170
- package/src/index.ts +1 -0
- package/src/main.module.sass +14 -2
- package/src/notifications.ts +22 -0
- package/src/postgrest-table/data-loaders.ts +300 -201
- package/src/postgrest-table/index.ts +258 -84
- package/src/postgrest-table/lazy-loader-table.ts +18 -17
- package/src/postgrest-table/loading-utils.ts +49 -0
- package/src/postgrest-table/main.module.sass +16 -0
- package/src/provider.ts +63 -20
- package/src/renderers/column-header-cell-postgrest.module.sass +71 -0
- package/src/renderers/column-header-cell-postgrest.ts +282 -0
- package/src/renderers/column-header-cell.ts +388 -0
- package/src/renderers/index.ts +2 -0
- package/src/table-updates/data-parameter.ts +44 -0
- package/src/table-updates/filter.ts +124 -0
- package/src/table-updates/index.ts +239 -0
- package/src/types.ts +58 -3
- package/src/utils/column-spec.ts +47 -0
- package/src/utils/key-handling.ts +181 -72
- package/src/zustand-store.ts +241 -36
- package/dist/provider.d.ts +0 -15
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbar.cjs","sources":["../../src/actions/toolbar.ts"],"sourcesContent":["import { Button, ButtonGroup, PopoverNext } from \"@blueprintjs/core\";\nimport { useCallback, useMemo, useState } from \"react\";\nimport h from \"./toolbar.module.sass\";\nimport { useSelector, useStoreAPI } from \"../provider\";\nimport {\n buildActionContext,\n getApplicableActions,\n getSelectionCardinality,\n mergeColumnActions,\n} from \"./selection\";\nimport type { TableAction, TableActionContext } from \"./types\";\nimport { RegionCardinality } from \"@blueprintjs/table\";\nimport { useToaster } from \"../notifications.ts\";\nimport { DataSheetStore } from \"../types.ts\";\n\n/** Toolbar that renders applicable table actions based on the\n * current selection cardinality and edit mode.\n * Automatically merges column-specific actions from `ColumnSpec.actions`\n * when the corresponding columns are in the selection. */\nexport function ActionsToolbar<T>({ actions }: { actions: TableAction<T>[] }) {\n const selection = useSelector((state) => state.selection);\n const editable = useSelector((state) => state.editable);\n const columnSpec = useSelector((state) => state.columnSpec);\n\n const cardinality = useMemo(\n () => getSelectionCardinality(selection) ?? RegionCardinality.FULL_TABLE,\n [selection],\n );\n\n // Merge global actions with column-specific actions from the selection\n const allActions = useMemo(\n () => mergeColumnActions(actions, columnSpec, selection),\n [actions, columnSpec, selection],\n );\n\n const applicableActions = useMemo(\n () => getApplicableActions(allActions, cardinality, editable),\n [allActions, cardinality, editable],\n );\n\n if (applicableActions.length === 0) return null;\n\n return h(\n \"div.actions-toolbar\",\n h(\n ButtonGroup,\n { minimal: true },\n applicableActions.map((action) =>\n h(ActionButton, { key: action.id, action }),\n ),\n ),\n );\n}\n\nfunction getMessageForError(e: any) {\n if (e instanceof Error) return e.message;\n if (typeof e === \"string\") return e;\n if (e instanceof Object) return JSON.stringify(e);\n return null;\n}\n\nfunction isActionDisabled(action: TableAction, state: any): boolean {\n if (typeof action.disabled === \"boolean\") return action.disabled;\n if (typeof action.disabled === \"function\") {\n return action.disabled(state);\n }\n return false;\n}\n\nexport function runActionWrapper<T>(\n action: TableAction<T>,\n state: DataSheetStore<any>,\n setState: (state: Partial<DataSheetStore<any>>) => void,\n toaster: any,\n configState: any = undefined,\n) {\n const ctx = buildActionContext(state, setState) as TableActionContext<T>;\n if (action.disabled instanceof Function) {\n if (action.disabled(ctx)) {\n return;\n }\n } else if (action.disabled) {\n return;\n }\n try {\n const res = action.run(ctx, configState);\n if (res instanceof Promise) {\n res\n .then(() => {})\n .catch((e) => {\n displayErrorForAction(action, e, toaster);\n });\n }\n } catch (e) {\n displayErrorForAction(action, e, toaster);\n }\n}\n\n/** A single action button. Handles both simple actions (direct click)\n * and actions with a `detailsForm` (popover with config + run). */\nfunction ActionButton<T>({ action }: { action: TableAction<T> }) {\n const storeAPI = useStoreAPI();\n const toaster = useToaster();\n\n // Reactive disabled check — re-renders when relevant state changes\n const isDisabled = useSelector((state) => {\n return isActionDisabled(action, state);\n });\n\n const runAction = useCallback(\n (configState?: any) => {\n runActionWrapper(\n action,\n storeAPI.getState(),\n storeAPI.setState,\n toaster,\n configState,\n );\n },\n [storeAPI, action, toaster],\n );\n\n if (action.detailsForm != null) {\n return h(ActionButtonWithForm, { action, runAction, isDisabled });\n }\n\n return h(\n Button,\n {\n icon: action.icon,\n intent: action.intent,\n disabled: isDisabled,\n onClick() {\n runAction();\n },\n },\n action.name,\n );\n}\n\nfunction displayErrorForAction(action: TableAction, error: any, toaster: any) {\n const message =\n getMessageForError(error) ?? action.errorMessage ?? \"Action failed\";\n toaster.show({\n message,\n intent: \"danger\",\n });\n}\n\n/** Action button that opens a popover for pre-run configuration. */\nfunction ActionButtonWithForm<T, S>({\n action,\n runAction,\n isDisabled,\n}: {\n action: TableAction<T, S>;\n runAction: (configState?: S) => void;\n isDisabled: boolean;\n}) {\n const [configState, setConfigState] = useState<S>(\n action.defaultState ?? (null as S),\n );\n const [isOpen, setIsOpen] = useState(false);\n\n let ready = true;\n if (action.isReady != null) {\n ready = action.isReady(configState);\n }\n\n return h(\n PopoverNext,\n {\n isOpen,\n onClose: () => setIsOpen(false),\n content: h(\"div.action-popover-content\", [\n h.if(action.description != null)(\"p.description\", action.description),\n h(action.detailsForm, {\n state: configState,\n setState: setConfigState,\n }),\n h(\n Button,\n {\n className: \"run-button\",\n intent: action.intent ?? \"primary\",\n icon: \"play\",\n disabled: !ready,\n fill: true,\n onClick() {\n runAction(configState);\n setIsOpen(false);\n },\n },\n \"Run\",\n ),\n ]),\n placement: \"bottom-start\",\n enforceFocus: false,\n autoFocus: false,\n },\n h(\n Button,\n {\n icon: action.icon,\n intent: action.intent,\n disabled: isDisabled,\n onClick: () => setIsOpen(!isOpen),\n },\n action.name,\n ),\n );\n}\n"],"names":["selection","useSelector","useMemo","getSelectionCardinality","RegionCardinality","mergeColumnActions","getApplicableActions","h","ButtonGroup","buildActionContext","useStoreAPI","useToaster","useCallback","Button","useState","PopoverNext"],"mappings":";;;;;;;;;AAmBO,SAAS,eAAkB,EAAE,WAA0C;AAC5E,QAAMA,cAAYC,SAAAA,YAAY,CAAC,UAAU,MAAM,SAAS;AACxD,QAAM,WAAWA,SAAAA,YAAY,CAAC,UAAU,MAAM,QAAQ;AACtD,QAAM,aAAaA,SAAAA,YAAY,CAAC,UAAU,MAAM,UAAU;AAE1D,QAAM,cAAcC,MAAAA;AAAAA,IAClB,MAAMC,kCAAwBH,WAAS,KAAKI,MAAAA,kBAAkB;AAAA,IAC9D,CAACJ,WAAS;AAAA,EAAA;AAIZ,QAAM,aAAaE,MAAAA;AAAAA,IACjB,MAAMG,6BAAmB,SAAS,YAAYL,WAAS;AAAA,IACvD,CAAC,SAAS,YAAYA,WAAS;AAAA,EAA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,IACLQ,KAAAA;AAAAA,IACA;AAAA,MACE;AAAA,MACA,SAAS,MAAM,UAAU,KAAK;AAAA,MAC9B,SAASR,eAAAA,QAAE,8BAA8B;AAAA,QACvCA,uBAAE,GAAG,OAAO,eAAe,IAAI,EAAE,iBAAiB,OAAO,WAAW;AAAA,QACpEA,eAAAA,QAAE,OAAO,aAAa;AAAA,UACpB,OAAO;AAAA,UACP,UAAU;AAAA,QAAA,CACX;AAAA,QACDA,eAAAA;AAAAA,UACEM,KAAAA;AAAAA,UACA;AAAA,YACE,WAAW;AAAA,YACX,QAAQ,OAAO,UAAU;AAAA,YACzB,MAAM;AAAA,YACN,UAAU,CAAC;AAAA,YACX,MAAM;AAAA,YACN,UAAU;AACR,wBAAU,WAAW;AACrB,wBAAU,KAAK;AAAA,YACjB;AAAA,UAAA;AAAA,UAEF;AAAA,QAAA;AAAA,MACF,CACD;AAAA,MACD,WAAW;AAAA,MACX,cAAc;AAAA,MACd,WAAW;AAAA,IAAA;AAAA,IAEbN,eAAAA;AAAAA,MACEM,KAAAA;AAAAA,MACA;AAAA,QACE,MAAM,OAAO;AAAA,QACb,QAAQ,OAAO;AAAA,QACf,UAAU;AAAA,QACV,SAAS,MAAM,UAAU,CAAC,MAAM;AAAA,MAAA;AAAA,MAElC,OAAO;AAAA,IAAA;AAAA,EACT;AAEJ;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TableAction } from './types';
|
|
2
|
+
import { DataSheetStore } from '../types.ts';
|
|
3
|
+
/** Toolbar that renders applicable table actions based on the
|
|
4
|
+
* current selection cardinality and edit mode.
|
|
5
|
+
* Automatically merges column-specific actions from `ColumnSpec.actions`
|
|
6
|
+
* when the corresponding columns are in the selection. */
|
|
7
|
+
export declare function ActionsToolbar<T>({ actions }: {
|
|
8
|
+
actions: TableAction<T>[];
|
|
9
|
+
}): import('react').ReactElement<import('react').FunctionComponentElement<import('@blueprintjs/core').ButtonGroupProps>, string | import('react').JSXElementConstructor<any>> | null;
|
|
10
|
+
export declare function runActionWrapper<T>(action: TableAction<T>, state: DataSheetStore<any>, setState: (state: Partial<DataSheetStore<any>>) => void, toaster: any, configState?: any): void;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { ButtonGroup, Button, PopoverNext } from "@blueprintjs/core";
|
|
2
|
+
import { useMemo, useCallback, useState } from "react";
|
|
3
|
+
import h from "./toolbar.module.sass.js";
|
|
4
|
+
import { useSelector, useStoreAPI } from "../provider.js";
|
|
5
|
+
import { getSelectionCardinality, mergeColumnActions, getApplicableActions, buildActionContext } from "./selection.js";
|
|
6
|
+
import { RegionCardinality } from "@blueprintjs/table";
|
|
7
|
+
import { useToaster } from "../notifications.js";
|
|
8
|
+
function ActionsToolbar({ actions }) {
|
|
9
|
+
const selection = useSelector((state) => state.selection);
|
|
10
|
+
const editable = useSelector((state) => state.editable);
|
|
11
|
+
const columnSpec = useSelector((state) => state.columnSpec);
|
|
12
|
+
const cardinality = useMemo(
|
|
13
|
+
() => getSelectionCardinality(selection) ?? RegionCardinality.FULL_TABLE,
|
|
14
|
+
[selection]
|
|
15
|
+
);
|
|
16
|
+
const allActions = useMemo(
|
|
17
|
+
() => mergeColumnActions(actions, columnSpec, selection),
|
|
18
|
+
[actions, columnSpec, selection]
|
|
19
|
+
);
|
|
20
|
+
const applicableActions = useMemo(
|
|
21
|
+
() => getApplicableActions(allActions, cardinality, editable),
|
|
22
|
+
[allActions, cardinality, editable]
|
|
23
|
+
);
|
|
24
|
+
if (applicableActions.length === 0) return null;
|
|
25
|
+
return h(
|
|
26
|
+
"div.actions-toolbar",
|
|
27
|
+
h(
|
|
28
|
+
ButtonGroup,
|
|
29
|
+
{ minimal: true },
|
|
30
|
+
applicableActions.map(
|
|
31
|
+
(action) => h(ActionButton, { key: action.id, action })
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
function getMessageForError(e) {
|
|
37
|
+
if (e instanceof Error) return e.message;
|
|
38
|
+
if (typeof e === "string") return e;
|
|
39
|
+
if (e instanceof Object) return JSON.stringify(e);
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
function isActionDisabled(action, state) {
|
|
43
|
+
if (typeof action.disabled === "boolean") return action.disabled;
|
|
44
|
+
if (typeof action.disabled === "function") {
|
|
45
|
+
return action.disabled(state);
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
function runActionWrapper(action, state, setState, toaster, configState = void 0) {
|
|
50
|
+
const ctx = buildActionContext(state, setState);
|
|
51
|
+
if (action.disabled instanceof Function) {
|
|
52
|
+
if (action.disabled(ctx)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
} else if (action.disabled) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const res = action.run(ctx, configState);
|
|
60
|
+
if (res instanceof Promise) {
|
|
61
|
+
res.then(() => {
|
|
62
|
+
}).catch((e) => {
|
|
63
|
+
displayErrorForAction(action, e, toaster);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
} catch (e) {
|
|
67
|
+
displayErrorForAction(action, e, toaster);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function ActionButton({ action }) {
|
|
71
|
+
const storeAPI = useStoreAPI();
|
|
72
|
+
const toaster = useToaster();
|
|
73
|
+
const isDisabled = useSelector((state) => {
|
|
74
|
+
return isActionDisabled(action, state);
|
|
75
|
+
});
|
|
76
|
+
const runAction = useCallback(
|
|
77
|
+
(configState) => {
|
|
78
|
+
runActionWrapper(
|
|
79
|
+
action,
|
|
80
|
+
storeAPI.getState(),
|
|
81
|
+
storeAPI.setState,
|
|
82
|
+
toaster,
|
|
83
|
+
configState
|
|
84
|
+
);
|
|
85
|
+
},
|
|
86
|
+
[storeAPI, action, toaster]
|
|
87
|
+
);
|
|
88
|
+
if (action.detailsForm != null) {
|
|
89
|
+
return h(ActionButtonWithForm, { action, runAction, isDisabled });
|
|
90
|
+
}
|
|
91
|
+
return h(
|
|
92
|
+
Button,
|
|
93
|
+
{
|
|
94
|
+
icon: action.icon,
|
|
95
|
+
intent: action.intent,
|
|
96
|
+
disabled: isDisabled,
|
|
97
|
+
onClick() {
|
|
98
|
+
runAction();
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
action.name
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
function displayErrorForAction(action, error, toaster) {
|
|
105
|
+
const message = getMessageForError(error) ?? action.errorMessage ?? "Action failed";
|
|
106
|
+
toaster.show({
|
|
107
|
+
message,
|
|
108
|
+
intent: "danger"
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function ActionButtonWithForm({
|
|
112
|
+
action,
|
|
113
|
+
runAction,
|
|
114
|
+
isDisabled
|
|
115
|
+
}) {
|
|
116
|
+
const [configState, setConfigState] = useState(
|
|
117
|
+
action.defaultState ?? null
|
|
118
|
+
);
|
|
119
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
120
|
+
let ready = true;
|
|
121
|
+
if (action.isReady != null) {
|
|
122
|
+
ready = action.isReady(configState);
|
|
123
|
+
}
|
|
124
|
+
return h(
|
|
125
|
+
PopoverNext,
|
|
126
|
+
{
|
|
127
|
+
isOpen,
|
|
128
|
+
onClose: () => setIsOpen(false),
|
|
129
|
+
content: h("div.action-popover-content", [
|
|
130
|
+
h.if(action.description != null)("p.description", action.description),
|
|
131
|
+
h(action.detailsForm, {
|
|
132
|
+
state: configState,
|
|
133
|
+
setState: setConfigState
|
|
134
|
+
}),
|
|
135
|
+
h(
|
|
136
|
+
Button,
|
|
137
|
+
{
|
|
138
|
+
className: "run-button",
|
|
139
|
+
intent: action.intent ?? "primary",
|
|
140
|
+
icon: "play",
|
|
141
|
+
disabled: !ready,
|
|
142
|
+
fill: true,
|
|
143
|
+
onClick() {
|
|
144
|
+
runAction(configState);
|
|
145
|
+
setIsOpen(false);
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"Run"
|
|
149
|
+
)
|
|
150
|
+
]),
|
|
151
|
+
placement: "bottom-start",
|
|
152
|
+
enforceFocus: false,
|
|
153
|
+
autoFocus: false
|
|
154
|
+
},
|
|
155
|
+
h(
|
|
156
|
+
Button,
|
|
157
|
+
{
|
|
158
|
+
icon: action.icon,
|
|
159
|
+
intent: action.intent,
|
|
160
|
+
disabled: isDisabled,
|
|
161
|
+
onClick: () => setIsOpen(!isOpen)
|
|
162
|
+
},
|
|
163
|
+
action.name
|
|
164
|
+
)
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
export {
|
|
168
|
+
ActionsToolbar,
|
|
169
|
+
runActionWrapper
|
|
170
|
+
};
|
|
171
|
+
//# sourceMappingURL=toolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbar.js","sources":["../../src/actions/toolbar.ts"],"sourcesContent":["import { Button, ButtonGroup, PopoverNext } from \"@blueprintjs/core\";\nimport { useCallback, useMemo, useState } from \"react\";\nimport h from \"./toolbar.module.sass\";\nimport { useSelector, useStoreAPI } from \"../provider\";\nimport {\n buildActionContext,\n getApplicableActions,\n getSelectionCardinality,\n mergeColumnActions,\n} from \"./selection\";\nimport type { TableAction, TableActionContext } from \"./types\";\nimport { RegionCardinality } from \"@blueprintjs/table\";\nimport { useToaster } from \"../notifications.ts\";\nimport { DataSheetStore } from \"../types.ts\";\n\n/** Toolbar that renders applicable table actions based on the\n * current selection cardinality and edit mode.\n * Automatically merges column-specific actions from `ColumnSpec.actions`\n * when the corresponding columns are in the selection. */\nexport function ActionsToolbar<T>({ actions }: { actions: TableAction<T>[] }) {\n const selection = useSelector((state) => state.selection);\n const editable = useSelector((state) => state.editable);\n const columnSpec = useSelector((state) => state.columnSpec);\n\n const cardinality = useMemo(\n () => getSelectionCardinality(selection) ?? RegionCardinality.FULL_TABLE,\n [selection],\n );\n\n // Merge global actions with column-specific actions from the selection\n const allActions = useMemo(\n () => mergeColumnActions(actions, columnSpec, selection),\n [actions, columnSpec, selection],\n );\n\n const applicableActions = useMemo(\n () => getApplicableActions(allActions, cardinality, editable),\n [allActions, cardinality, editable],\n );\n\n if (applicableActions.length === 0) return null;\n\n return h(\n \"div.actions-toolbar\",\n h(\n ButtonGroup,\n { minimal: true },\n applicableActions.map((action) =>\n h(ActionButton, { key: action.id, action }),\n ),\n ),\n );\n}\n\nfunction getMessageForError(e: any) {\n if (e instanceof Error) return e.message;\n if (typeof e === \"string\") return e;\n if (e instanceof Object) return JSON.stringify(e);\n return null;\n}\n\nfunction isActionDisabled(action: TableAction, state: any): boolean {\n if (typeof action.disabled === \"boolean\") return action.disabled;\n if (typeof action.disabled === \"function\") {\n return action.disabled(state);\n }\n return false;\n}\n\nexport function runActionWrapper<T>(\n action: TableAction<T>,\n state: DataSheetStore<any>,\n setState: (state: Partial<DataSheetStore<any>>) => void,\n toaster: any,\n configState: any = undefined,\n) {\n const ctx = buildActionContext(state, setState) as TableActionContext<T>;\n if (action.disabled instanceof Function) {\n if (action.disabled(ctx)) {\n return;\n }\n } else if (action.disabled) {\n return;\n }\n try {\n const res = action.run(ctx, configState);\n if (res instanceof Promise) {\n res\n .then(() => {})\n .catch((e) => {\n displayErrorForAction(action, e, toaster);\n });\n }\n } catch (e) {\n displayErrorForAction(action, e, toaster);\n }\n}\n\n/** A single action button. Handles both simple actions (direct click)\n * and actions with a `detailsForm` (popover with config + run). */\nfunction ActionButton<T>({ action }: { action: TableAction<T> }) {\n const storeAPI = useStoreAPI();\n const toaster = useToaster();\n\n // Reactive disabled check — re-renders when relevant state changes\n const isDisabled = useSelector((state) => {\n return isActionDisabled(action, state);\n });\n\n const runAction = useCallback(\n (configState?: any) => {\n runActionWrapper(\n action,\n storeAPI.getState(),\n storeAPI.setState,\n toaster,\n configState,\n );\n },\n [storeAPI, action, toaster],\n );\n\n if (action.detailsForm != null) {\n return h(ActionButtonWithForm, { action, runAction, isDisabled });\n }\n\n return h(\n Button,\n {\n icon: action.icon,\n intent: action.intent,\n disabled: isDisabled,\n onClick() {\n runAction();\n },\n },\n action.name,\n );\n}\n\nfunction displayErrorForAction(action: TableAction, error: any, toaster: any) {\n const message =\n getMessageForError(error) ?? action.errorMessage ?? \"Action failed\";\n toaster.show({\n message,\n intent: \"danger\",\n });\n}\n\n/** Action button that opens a popover for pre-run configuration. */\nfunction ActionButtonWithForm<T, S>({\n action,\n runAction,\n isDisabled,\n}: {\n action: TableAction<T, S>;\n runAction: (configState?: S) => void;\n isDisabled: boolean;\n}) {\n const [configState, setConfigState] = useState<S>(\n action.defaultState ?? (null as S),\n );\n const [isOpen, setIsOpen] = useState(false);\n\n let ready = true;\n if (action.isReady != null) {\n ready = action.isReady(configState);\n }\n\n return h(\n PopoverNext,\n {\n isOpen,\n onClose: () => setIsOpen(false),\n content: h(\"div.action-popover-content\", [\n h.if(action.description != null)(\"p.description\", action.description),\n h(action.detailsForm, {\n state: configState,\n setState: setConfigState,\n }),\n h(\n Button,\n {\n className: \"run-button\",\n intent: action.intent ?? \"primary\",\n icon: \"play\",\n disabled: !ready,\n fill: true,\n onClick() {\n runAction(configState);\n setIsOpen(false);\n },\n },\n \"Run\",\n ),\n ]),\n placement: \"bottom-start\",\n enforceFocus: false,\n autoFocus: false,\n },\n h(\n Button,\n {\n icon: action.icon,\n intent: action.intent,\n disabled: isDisabled,\n onClick: () => setIsOpen(!isOpen),\n },\n action.name,\n ),\n );\n}\n"],"names":[],"mappings":";;;;;;;AAmBO,SAAS,eAAkB,EAAE,WAA0C;AAC5E,QAAM,YAAY,YAAY,CAAC,UAAU,MAAM,SAAS;AACxD,QAAM,WAAW,YAAY,CAAC,UAAU,MAAM,QAAQ;AACtD,QAAM,aAAa,YAAY,CAAC,UAAU,MAAM,UAAU;AAE1D,QAAM,cAAc;AAAA,IAClB,MAAM,wBAAwB,SAAS,KAAK,kBAAkB;AAAA,IAC9D,CAAC,SAAS;AAAA,EAAA;AAIZ,QAAM,aAAa;AAAA,IACjB,MAAM,mBAAmB,SAAS,YAAY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,8BAA8B;AAAA,QACvC,EAAE,GAAG,OAAO,eAAe,IAAI,EAAE,iBAAiB,OAAO,WAAW;AAAA,QACpE,EAAE,OAAO,aAAa;AAAA,UACpB,OAAO;AAAA,UACP,UAAU;AAAA,QAAA,CACX;AAAA,QACD;AAAA,UACE;AAAA,UACA;AAAA,YACE,WAAW;AAAA,YACX,QAAQ,OAAO,UAAU;AAAA,YACzB,MAAM;AAAA,YACN,UAAU,CAAC;AAAA,YACX,MAAM;AAAA,YACN,UAAU;AACR,wBAAU,WAAW;AACrB,wBAAU,KAAK;AAAA,YACjB;AAAA,UAAA;AAAA,UAEF;AAAA,QAAA;AAAA,MACF,CACD;AAAA,MACD,WAAW;AAAA,MACX,cAAc;AAAA,MACd,WAAW;AAAA,IAAA;AAAA,IAEb;AAAA,MACE;AAAA,MACA;AAAA,QACE,MAAM,OAAO;AAAA,QACb,QAAQ,OAAO;AAAA,QACf,UAAU;AAAA,QACV,SAAS,MAAM,UAAU,CAAC,MAAM;AAAA,MAAA;AAAA,MAElC,OAAO;AAAA,IAAA;AAAA,EACT;AAEJ;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const h$1 = require("@macrostrat/hyper");
|
|
4
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
5
|
+
const h__default = /* @__PURE__ */ _interopDefault(h$1);
|
|
6
|
+
const spacer = "_spacer_ja9qu_9";
|
|
7
|
+
const description = "_description_ja9qu_17";
|
|
8
|
+
const styles = {
|
|
9
|
+
"actions-toolbar": "_actions-toolbar_ja9qu_1",
|
|
10
|
+
spacer,
|
|
11
|
+
"action-popover-content": "_action-popover-content_ja9qu_13",
|
|
12
|
+
"filter-config": "_filter-config_ja9qu_13",
|
|
13
|
+
description,
|
|
14
|
+
"run-button": "_run-button_ja9qu_23",
|
|
15
|
+
"filter-bar": "_filter-bar_ja9qu_28"
|
|
16
|
+
};
|
|
17
|
+
let h = h__default.default.styled(styles);
|
|
18
|
+
Object.assign(h, styles);
|
|
19
|
+
exports.default = h;
|
|
20
|
+
exports.description = description;
|
|
21
|
+
exports.spacer = spacer;
|
|
22
|
+
//# sourceMappingURL=toolbar.module.sass.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbar.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import h$1 from "@macrostrat/hyper";
|
|
2
|
+
const spacer = "_spacer_ja9qu_9";
|
|
3
|
+
const description = "_description_ja9qu_17";
|
|
4
|
+
const styles = {
|
|
5
|
+
"actions-toolbar": "_actions-toolbar_ja9qu_1",
|
|
6
|
+
spacer,
|
|
7
|
+
"action-popover-content": "_action-popover-content_ja9qu_13",
|
|
8
|
+
"filter-config": "_filter-config_ja9qu_13",
|
|
9
|
+
description,
|
|
10
|
+
"run-button": "_run-button_ja9qu_23",
|
|
11
|
+
"filter-bar": "_filter-bar_ja9qu_28"
|
|
12
|
+
};
|
|
13
|
+
let h = h$1.styled(styles);
|
|
14
|
+
Object.assign(h, styles);
|
|
15
|
+
export {
|
|
16
|
+
h as default,
|
|
17
|
+
description,
|
|
18
|
+
spacer
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=toolbar.module.sass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbar.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { IconName, Intent } from '@blueprintjs/core';
|
|
2
|
+
import { Region, RegionCardinality } from '@blueprintjs/table';
|
|
3
|
+
import { ComponentType } from 'react';
|
|
4
|
+
import { ColumnSpec } from '../utils';
|
|
5
|
+
import { ClipboardProxy, TableElementStatus } from '../types.ts';
|
|
6
|
+
/** Selection cardinality including the case of no active selection */
|
|
7
|
+
export type SelectionCardinality = RegionCardinality | "none";
|
|
8
|
+
/** A single cell edit, used with `editCells` for batch updates. */
|
|
9
|
+
export interface CellEdit {
|
|
10
|
+
rowIndex: number;
|
|
11
|
+
columnKey: string;
|
|
12
|
+
value: any;
|
|
13
|
+
}
|
|
14
|
+
/** A column filter that can be activated to hide non-matching rows.
|
|
15
|
+
* Parallel to `TableAction` but with persistent state while active.
|
|
16
|
+
* Follows the same `{ state, setState }` form pattern.
|
|
17
|
+
*
|
|
18
|
+
* @typeParam T - Row data type
|
|
19
|
+
* @typeParam S - Filter configuration state type
|
|
20
|
+
*/
|
|
21
|
+
export interface TableFilter<T = any, S = any> {
|
|
22
|
+
/** Unique identifier */
|
|
23
|
+
id: string;
|
|
24
|
+
/** Display name */
|
|
25
|
+
name: string;
|
|
26
|
+
/** Blueprint icon */
|
|
27
|
+
icon?: IconName;
|
|
28
|
+
/** Description shown in the filter popover */
|
|
29
|
+
description?: string;
|
|
30
|
+
/** Column this filter targets. Automatically set when defined in a ColumnSpec. */
|
|
31
|
+
columnKey?: string;
|
|
32
|
+
/** Default filter configuration state */
|
|
33
|
+
defaultState?: S;
|
|
34
|
+
/** Component for configuring the filter value.
|
|
35
|
+
* Same `{ state, setState }` pattern as `TableAction.detailsForm`. */
|
|
36
|
+
filterForm?: ComponentType<{
|
|
37
|
+
state: S;
|
|
38
|
+
setState(state: S): void;
|
|
39
|
+
}>;
|
|
40
|
+
/** Row predicate: return `true` if the row should be visible.
|
|
41
|
+
* Receives the merged row (updatedData overlaid on data). */
|
|
42
|
+
predicate(row: T, state: S): boolean;
|
|
43
|
+
}
|
|
44
|
+
/** An active filter entry stored in the table state. */
|
|
45
|
+
export interface ActiveFilterEntry<T = any> {
|
|
46
|
+
filter: TableFilter<T>;
|
|
47
|
+
state: any;
|
|
48
|
+
}
|
|
49
|
+
export type { ColumnSort } from '../types.ts';
|
|
50
|
+
/** Context passed to an action's `run` function, providing both data access
|
|
51
|
+
* and store manipulation methods. Constructed fresh at action-run time
|
|
52
|
+
* to ensure current state. */
|
|
53
|
+
export interface TableActionContext<T = any> {
|
|
54
|
+
/** Current selection regions */
|
|
55
|
+
selection: Region[];
|
|
56
|
+
/** Derived cardinality of the current selection */
|
|
57
|
+
selectionCardinality: SelectionCardinality;
|
|
58
|
+
/** The table's base data */
|
|
59
|
+
data: T[];
|
|
60
|
+
/** Sparse overlay of edited data */
|
|
61
|
+
updatedData: T[];
|
|
62
|
+
/** Row status tracking added/deleted rows */
|
|
63
|
+
rowStatus: TableElementStatus[];
|
|
64
|
+
/** Column definitions */
|
|
65
|
+
columnSpec: ColumnSpec[];
|
|
66
|
+
/** Whether the table is in edit mode */
|
|
67
|
+
editable: boolean;
|
|
68
|
+
/** Row indices covered by the current selection */
|
|
69
|
+
getSelectedRowIndices(): number[];
|
|
70
|
+
/** Column keys covered by the current selection */
|
|
71
|
+
getSelectedColumnKeys(): string[];
|
|
72
|
+
onCellEdited(rowIndex: number, columnKey: string, value: any): void;
|
|
73
|
+
/** Edit multiple cells in a single batch update. Preferred over calling
|
|
74
|
+
* `onCellEdited` in a loop, which triggers separate store updates
|
|
75
|
+
* and may produce inconsistent intermediate states. */
|
|
76
|
+
editCells(edits: CellEdit[]): void;
|
|
77
|
+
deleteSelectedRows(): void;
|
|
78
|
+
addRow(row?: Partial<T>): void;
|
|
79
|
+
setUpdatedData(data: any): void;
|
|
80
|
+
resetChanges(region?: Region[]): void;
|
|
81
|
+
clearSelection(): void;
|
|
82
|
+
scrollToRow(rowIndex: number): void;
|
|
83
|
+
/** Direct store mutation for cases not covered by the convenience methods
|
|
84
|
+
* above (e.g., modifying `columnSpec` or `deletedRows`). */
|
|
85
|
+
setState(partial: Record<string, any>): void;
|
|
86
|
+
/** Active clipboard proxy from a prior copy, if any */
|
|
87
|
+
clipboardProxy: ClipboardProxy | null;
|
|
88
|
+
/** Store a clipboard proxy for potential backend-mediated paste */
|
|
89
|
+
setClipboardProxy(proxy: ClipboardProxy | null): void;
|
|
90
|
+
/** Row index mapping when filters are active. When non-null,
|
|
91
|
+
* visible row `i` maps to data row `filteredRowIndices[i]`. */
|
|
92
|
+
filteredRowIndices: number[] | null;
|
|
93
|
+
}
|
|
94
|
+
/** Definition of a table action. Follows the `ActionDef` pattern from
|
|
95
|
+
* `@macrostrat/form-components` with table-specific extensions.
|
|
96
|
+
*
|
|
97
|
+
* @typeParam T - Row data type
|
|
98
|
+
* @typeParam S - Configuration state type (for actions with a `detailsForm`)
|
|
99
|
+
*/
|
|
100
|
+
export interface TableAction<T = any, S = null> {
|
|
101
|
+
/** Unique identifier */
|
|
102
|
+
id: string;
|
|
103
|
+
/** Display name */
|
|
104
|
+
name: string;
|
|
105
|
+
/** Group name (for grouping actions together) */
|
|
106
|
+
group?: string;
|
|
107
|
+
/** Blueprint icon name */
|
|
108
|
+
icon?: IconName;
|
|
109
|
+
/** Visual intent (e.g., "danger" for destructive actions) */
|
|
110
|
+
intent?: Intent;
|
|
111
|
+
/** Description shown as tooltip or in the details panel */
|
|
112
|
+
description?: string;
|
|
113
|
+
/** Which selection cardinalities this action applies to.
|
|
114
|
+
* The action will appear in the toolbar when the current selection
|
|
115
|
+
* matches any of these cardinalities. Use `"none"` for actions that
|
|
116
|
+
* should be available even with no active selection. */
|
|
117
|
+
targets: SelectionCardinality[];
|
|
118
|
+
/** Whether this action requires the table to be in edit mode.
|
|
119
|
+
* Defaults to `true`. Set to `false` for read-only actions
|
|
120
|
+
* (e.g., "open URL", "copy to clipboard"). */
|
|
121
|
+
requiresEditable?: boolean;
|
|
122
|
+
/** Whether the action is currently disabled. Can be a static boolean
|
|
123
|
+
* or a function that receives the current context for dynamic checks. */
|
|
124
|
+
disabled?: boolean | ((context: TableActionContext<T>) => boolean);
|
|
125
|
+
/** Default configuration state for the action's preflight form */
|
|
126
|
+
defaultState?: S;
|
|
127
|
+
/** Component for pre-run configuration, rendered in a popover.
|
|
128
|
+
* Follows the same pattern as `ActionDef.detailsForm` from
|
|
129
|
+
* `@macrostrat/form-components`. */
|
|
130
|
+
detailsForm?: ComponentType<{
|
|
131
|
+
state: S;
|
|
132
|
+
setState(state: S): void;
|
|
133
|
+
}>;
|
|
134
|
+
/** Check if the action is ready to run given its configuration state */
|
|
135
|
+
isReady?: (state: S) => boolean;
|
|
136
|
+
/** Execute the action. May be synchronous (local state manipulation)
|
|
137
|
+
* or asynchronous (backend fulfillment). For lazy-loaded tables,
|
|
138
|
+
* async actions are required when targeting non-loaded cells. */
|
|
139
|
+
run(context: TableActionContext<T>, state?: S): void | Promise<void>;
|
|
140
|
+
successMessage?: string;
|
|
141
|
+
errorMessage?: string;
|
|
142
|
+
hotkey?: string;
|
|
143
|
+
}
|
package/dist/cell-renderer.cjs
CHANGED
|
@@ -1,41 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const types = require("./types.cjs");
|
|
3
4
|
const main_module = require("./main.module.sass.cjs");
|
|
5
|
+
const react = require("react");
|
|
4
6
|
const zustandStore = require("./zustand-store.cjs");
|
|
5
7
|
const table = require("@blueprintjs/table");
|
|
6
8
|
const provider = require("./provider.cjs");
|
|
7
9
|
const editorPopup = require("./components/editor-popup.cjs");
|
|
8
10
|
const keyHandling = require("./utils/key-handling.cjs");
|
|
9
|
-
function basicCellRenderer(rowIndex, colIndex, columnSpec, state, autoFocusEditor = true) {
|
|
11
|
+
function basicCellRenderer(rowIndex, colIndex, columnSpec, state, autoFocusEditor = true, filteredRowIndices) {
|
|
12
|
+
const dataRowIndex = filteredRowIndices != null ? filteredRowIndices[rowIndex] ?? rowIndex : rowIndex;
|
|
10
13
|
const data = state.data;
|
|
11
14
|
const updatedData = state.updatedData;
|
|
12
|
-
const isDeleted = state.
|
|
13
|
-
const row = data[
|
|
15
|
+
const isDeleted = state.rowStatus[dataRowIndex] == types.TableElementStatus.DELETED;
|
|
16
|
+
const row = data[dataRowIndex] ?? updatedData[dataRowIndex];
|
|
14
17
|
const loading = row == null;
|
|
15
18
|
const col = columnSpec;
|
|
16
19
|
const _topLeftCell = state.topLeftCell;
|
|
17
20
|
const onCellEdited = state.onCellEdited;
|
|
18
|
-
const value = updatedData[
|
|
19
|
-
const
|
|
21
|
+
const value = updatedData[dataRowIndex]?.[col.key] ?? data[dataRowIndex]?.[col.key];
|
|
22
|
+
const isEmpty = value == null || value === "";
|
|
23
|
+
const _renderedValue = isEmpty ? null : col.valueRenderer?.(value) ?? value;
|
|
20
24
|
let style = col.style ?? {};
|
|
21
25
|
if (isDeleted) {
|
|
22
|
-
style =
|
|
23
|
-
|
|
24
|
-
opacity: 0.5,
|
|
25
|
-
textDecoration: "line-through"
|
|
26
|
-
};
|
|
26
|
+
style.opacity = 0.5;
|
|
27
|
+
style.textDecoration = "line-through";
|
|
27
28
|
}
|
|
28
29
|
const editable = (col.editable ?? state.editable) && !isDeleted;
|
|
29
30
|
const topLeft = _topLeftCell?.col === colIndex && _topLeftCell?.row === rowIndex;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
const edited = updatedData[rowIndex]?.[col.key] != null;
|
|
31
|
+
const tableIsEditable = state.editable;
|
|
32
|
+
const edited = updatedData[dataRowIndex]?.[col.key] != null || state.rowStatus[dataRowIndex] === types.TableElementStatus.ADDED;
|
|
34
33
|
let intent = edited ? "success" : void 0;
|
|
35
34
|
if (isDeleted) {
|
|
36
35
|
intent = "danger";
|
|
37
36
|
}
|
|
38
|
-
const _Cell = col.cellComponent ??
|
|
37
|
+
const _Cell = col.cellComponent ?? table.Cell;
|
|
39
38
|
let inlineEditor = editable ? col.inlineEditor ?? true : false;
|
|
40
39
|
if (!topLeft) {
|
|
41
40
|
return main_module.default(
|
|
@@ -45,15 +44,12 @@ function basicCellRenderer(rowIndex, colIndex, columnSpec, state, autoFocusEdito
|
|
|
45
44
|
loading,
|
|
46
45
|
value,
|
|
47
46
|
style,
|
|
48
|
-
|
|
47
|
+
disabled: tableIsEditable && !editable,
|
|
48
|
+
interactive: false
|
|
49
49
|
},
|
|
50
50
|
_renderedValue
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
|
-
let hiddenInput = main_module.default(EditorInput, {
|
|
54
|
-
className: "hidden-input",
|
|
55
|
-
autoFocus: true
|
|
56
|
-
});
|
|
57
53
|
let cellContents = _renderedValue;
|
|
58
54
|
let _dataEditor = null;
|
|
59
55
|
let className = null;
|
|
@@ -68,9 +64,13 @@ function basicCellRenderer(rowIndex, colIndex, columnSpec, state, autoFocusEdito
|
|
|
68
64
|
main_module.default(col.dataEditor, {
|
|
69
65
|
value,
|
|
70
66
|
editable,
|
|
67
|
+
isEdited: edited,
|
|
71
68
|
onChange(value2) {
|
|
72
69
|
if (!editable) return;
|
|
73
70
|
state.onSelectionEdited(value2);
|
|
71
|
+
},
|
|
72
|
+
resetValue() {
|
|
73
|
+
state.resetChanges();
|
|
74
74
|
}
|
|
75
75
|
})
|
|
76
76
|
]
|
|
@@ -80,20 +80,23 @@ function basicCellRenderer(rowIndex, colIndex, columnSpec, state, autoFocusEdito
|
|
|
80
80
|
if (_dataEditor != null) {
|
|
81
81
|
cellContents = _dataEditor;
|
|
82
82
|
}
|
|
83
|
+
const className2 = "value-viewer-cell";
|
|
83
84
|
return main_module.default(
|
|
84
85
|
_Cell,
|
|
85
86
|
{
|
|
86
87
|
intent,
|
|
87
88
|
value,
|
|
88
|
-
style
|
|
89
|
+
style,
|
|
90
|
+
className: className2,
|
|
91
|
+
interactive: false
|
|
89
92
|
},
|
|
90
93
|
cellContents
|
|
91
94
|
);
|
|
92
95
|
}
|
|
93
96
|
const onChange = (e) => {
|
|
94
97
|
if (!editable) return;
|
|
95
|
-
if (
|
|
96
|
-
onCellEdited(
|
|
98
|
+
if (_renderedValue === e.target.value) return;
|
|
99
|
+
onCellEdited(dataRowIndex, col.key, e.target.value);
|
|
97
100
|
};
|
|
98
101
|
const isSingleCellSelection = zustandStore.singleFocusedCell(state.selection) != null;
|
|
99
102
|
let _inlineEditor = null;
|
|
@@ -111,14 +114,16 @@ function basicCellRenderer(rowIndex, colIndex, columnSpec, state, autoFocusEdito
|
|
|
111
114
|
} else {
|
|
112
115
|
_inlineEditor = inlineEditor;
|
|
113
116
|
}
|
|
117
|
+
main_module.default(EditorInput, {
|
|
118
|
+
className: "hidden-input",
|
|
119
|
+
autoFocus: true
|
|
120
|
+
});
|
|
114
121
|
if (_dataEditor != null) {
|
|
115
122
|
className = "editor-cell";
|
|
116
123
|
cellContents = _dataEditor;
|
|
117
|
-
hiddenInput = null;
|
|
118
124
|
} else if (_inlineEditor != null) {
|
|
119
125
|
cellContents = _inlineEditor;
|
|
120
126
|
className = "input-cell";
|
|
121
|
-
hiddenInput = null;
|
|
122
127
|
}
|
|
123
128
|
return main_module.default(
|
|
124
129
|
_Cell,
|
|
@@ -126,37 +131,35 @@ function basicCellRenderer(rowIndex, colIndex, columnSpec, state, autoFocusEdito
|
|
|
126
131
|
intent,
|
|
127
132
|
value,
|
|
128
133
|
className,
|
|
129
|
-
style
|
|
134
|
+
style,
|
|
135
|
+
interactive: true
|
|
130
136
|
//truncated: false,
|
|
131
137
|
},
|
|
132
138
|
[
|
|
133
139
|
cellContents,
|
|
134
|
-
main_module.default.if(editable && isSingleCellSelection)(DragHandle)
|
|
135
|
-
hiddenInput
|
|
140
|
+
main_module.default.if(editable && isSingleCellSelection)(DragHandle)
|
|
141
|
+
//hiddenInput,
|
|
136
142
|
]
|
|
137
143
|
);
|
|
138
144
|
}
|
|
139
145
|
function EditorInput(props) {
|
|
140
|
-
const
|
|
146
|
+
const { value, onChange, ...rest } = props;
|
|
147
|
+
const onKeyDown = provider.ctx.useValue(keyHandling.editorKeyHandlerAtom);
|
|
148
|
+
const [_value, setValue] = react.useState(value);
|
|
149
|
+
react.useEffect(() => {
|
|
150
|
+
setValue(value);
|
|
151
|
+
}, [value]);
|
|
141
152
|
return main_module.default("input", {
|
|
142
153
|
onKeyDown,
|
|
143
|
-
|
|
154
|
+
onBlur: onChange,
|
|
155
|
+
value: _value ?? value,
|
|
156
|
+
onChange: (e) => setValue(e.target.value),
|
|
157
|
+
...rest
|
|
144
158
|
});
|
|
145
159
|
}
|
|
146
160
|
function DragHandle() {
|
|
147
161
|
const onMouseDown = provider.useSelector((state) => state.onDragValue);
|
|
148
162
|
return main_module.default("div.corner-drag-handle", { onMouseDown });
|
|
149
163
|
}
|
|
150
|
-
function BaseCell({ children, value, ...rest }) {
|
|
151
|
-
return main_module.default(
|
|
152
|
-
table.Cell,
|
|
153
|
-
{
|
|
154
|
-
interactive: true,
|
|
155
|
-
...rest
|
|
156
|
-
},
|
|
157
|
-
children
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
exports.BaseCell = BaseCell;
|
|
161
164
|
exports.basicCellRenderer = basicCellRenderer;
|
|
162
165
|
//# sourceMappingURL=cell-renderer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell-renderer.cjs","sources":["../src/cell-renderer.ts"],"sourcesContent":["import { ColumnSpec, editorKeyHandlerAtom } from \"./utils\";\nimport { DataSheetStore } from \"./types.ts\";\nimport h from \"./main.module.sass\";\nimport { ReactNode } from \"react\";\nimport { EditorPopup } from \"./components\";\nimport { singleFocusedCell } from \"./zustand-store.ts\";\nimport { Cell } from \"@blueprintjs/table\";\nimport {
|
|
1
|
+
{"version":3,"file":"cell-renderer.cjs","sources":["../src/cell-renderer.ts"],"sourcesContent":["import { ColumnSpec, editorKeyHandlerAtom } from \"./utils\";\nimport { DataSheetStore, TableElementStatus } from \"./types.ts\";\nimport h from \"./main.module.sass\";\nimport { ReactNode, useEffect, useState } from \"react\";\nimport { EditorPopup } from \"./components\";\nimport { singleFocusedCell } from \"./zustand-store.ts\";\nimport { Cell } from \"@blueprintjs/table\";\nimport { ctx, useSelector } from \"./provider.ts\";\n\nexport function basicCellRenderer<T>(\n rowIndex: number,\n colIndex: number,\n columnSpec: ColumnSpec,\n state: DataSheetStore<T>,\n autoFocusEditor = true,\n filteredRowIndices?: number[] | null,\n): any {\n // When filters are active, `rowIndex` is the visible row position.\n // Map it to the actual data index for data access.\n const dataRowIndex =\n filteredRowIndices != null\n ? (filteredRowIndices[rowIndex] ?? rowIndex)\n : rowIndex;\n\n const data = state.data;\n const updatedData = state.updatedData;\n\n const isDeleted = state.rowStatus[dataRowIndex] == TableElementStatus.DELETED;\n\n const row = data[dataRowIndex] ?? updatedData[dataRowIndex];\n const loading = row == null;\n const col = columnSpec;\n\n const _topLeftCell = state.topLeftCell;\n const onCellEdited = state.onCellEdited;\n\n const value: T | undefined =\n updatedData[dataRowIndex]?.[col.key] ?? data[dataRowIndex]?.[col.key];\n const isEmpty = value == null || value === \"\";\n const _renderedValue = isEmpty ? null : (col.valueRenderer?.(value) ?? value);\n\n let style = col.style ?? {};\n\n if (isDeleted) {\n style.opacity = 0.5;\n style.textDecoration = \"line-through\";\n }\n\n const editable = (col.editable ?? state.editable) && !isDeleted;\n\n // topLeftCell stores visible row indices, so compare with the visible rowIndex\n const topLeft =\n _topLeftCell?.col === colIndex && _topLeftCell?.row === rowIndex;\n\n const tableIsEditable = state.editable;\n\n const edited =\n updatedData[dataRowIndex]?.[col.key] != null ||\n state.rowStatus[dataRowIndex] === TableElementStatus.ADDED;\n let intent = edited ? \"success\" : undefined;\n if (isDeleted) {\n intent = \"danger\";\n }\n\n const _Cell = col.cellComponent ?? Cell;\n\n let inlineEditor = editable ? (col.inlineEditor ?? true) : false;\n\n if (!topLeft) {\n return h(\n _Cell,\n {\n intent,\n loading,\n value,\n style,\n disabled: tableIsEditable && !editable,\n interactive: false,\n },\n _renderedValue,\n );\n }\n\n // The rest is for the top-left cell of a selection or the focused cell\n\n let cellContents: ReactNode = _renderedValue;\n\n let _dataEditor = null;\n let className = null;\n\n if (col.dataEditor != null) {\n _dataEditor = h(\n EditorPopup,\n {\n autoFocus: autoFocusEditor,\n valueViewer: _renderedValue,\n },\n [\n h(col.dataEditor, {\n value,\n editable,\n isEdited: edited,\n onChange(value) {\n if (!editable) return;\n state.onSelectionEdited(value);\n },\n resetValue() {\n state.resetChanges();\n },\n }),\n ],\n );\n }\n\n if (!editable) {\n if (_dataEditor != null) {\n cellContents = _dataEditor;\n }\n const className = \"value-viewer-cell\";\n\n return h(\n _Cell,\n {\n intent,\n value,\n style,\n className,\n interactive: false,\n },\n cellContents,\n );\n }\n\n /* The remaining logic covers cells that are focused and editable */\n\n const onChange = (e) => {\n if (!editable) return;\n if (_renderedValue === e.target.value) return;\n // Use dataRowIndex for the actual data mutation\n onCellEdited(dataRowIndex, col.key, e.target.value);\n };\n\n const isSingleCellSelection = singleFocusedCell(state.selection) != null;\n\n let _inlineEditor: ReactNode = null;\n if (typeof inlineEditor == \"boolean\") {\n let _value = value;\n if (\n typeof _renderedValue === \"string\" ||\n typeof _renderedValue === \"number\" ||\n _renderedValue == null\n ) {\n _value = _renderedValue;\n }\n _inlineEditor = h(EditorInput, {\n className: \"main-editor\",\n value: _value ?? \"\",\n autoFocus: autoFocusEditor,\n onChange,\n });\n } else {\n // If inlineEditor is a ReactNode, we use it directly\n _inlineEditor = inlineEditor as ReactNode;\n }\n\n let hiddenInput: React.ReactNode = h(EditorInput, {\n className: \"hidden-input\",\n autoFocus: true,\n });\n\n if (_dataEditor != null) {\n className = \"editor-cell\";\n cellContents = _dataEditor;\n hiddenInput = null;\n } else if (_inlineEditor != null) {\n cellContents = _inlineEditor;\n className = \"input-cell\";\n hiddenInput = null;\n }\n\n // Hidden html input\n return h(\n _Cell,\n {\n intent,\n value,\n className,\n style,\n interactive: true,\n //truncated: false,\n },\n [\n cellContents,\n h.if(editable && isSingleCellSelection)(DragHandle),\n //hiddenInput,\n ],\n );\n}\n\nfunction EditorInput(props) {\n const { value, onChange, ...rest } = props;\n const onKeyDown = ctx.useValue(editorKeyHandlerAtom);\n const [_value, setValue] = useState(value);\n useEffect(() => {\n setValue(value);\n }, [value]);\n return h(\"input\", {\n onKeyDown,\n onBlur: onChange,\n value: _value ?? value,\n onChange: (e) => setValue(e.target.value),\n ...rest,\n });\n}\n\nfunction DragHandle() {\n // TODO: we might want to drag multiple columns in some cases\n // This should be on the last cell of a selection\n const onMouseDown = useSelector((state) => state.onDragValue);\n return h(\"div.corner-drag-handle\", { onMouseDown });\n}\n"],"names":["TableElementStatus","Cell","h","EditorPopup","value","className","singleFocusedCell","ctx","editorKeyHandlerAtom","useState","useEffect","useSelector"],"mappings":";;;;;;;;;;AASO,SAAS,kBACd,UACA,UACA,YACA,OACA,kBAAkB,MAClB,oBACK;AAGL,QAAM,eACJ,sBAAsB,OACjB,mBAAmB,QAAQ,KAAK,WACjC;AAEN,QAAM,OAAO,MAAM;AACnB,QAAM,cAAc,MAAM;AAE1B,QAAM,YAAY,MAAM,UAAU,YAAY,KAAKA,MAAAA,mBAAmB;AAEtE,QAAM,MAAM,KAAK,YAAY,KAAK,YAAY,YAAY;AAC1D,QAAM,UAAU,OAAO;AACvB,QAAM,MAAM;AAEZ,QAAM,eAAe,MAAM;AAC3B,QAAM,eAAe,MAAM;AAE3B,QAAM,QACJ,YAAY,YAAY,IAAI,IAAI,GAAG,KAAK,KAAK,YAAY,IAAI,IAAI,GAAG;AACtE,QAAM,UAAU,SAAS,QAAQ,UAAU;AAC3C,QAAM,iBAAiB,UAAU,OAAQ,IAAI,gBAAgB,KAAK,KAAK;AAEvE,MAAI,QAAQ,IAAI,SAAS,CAAA;AAEzB,MAAI,WAAW;AACb,UAAM,UAAU;AAChB,UAAM,iBAAiB;AAAA,EACzB;AAEA,QAAM,YAAY,IAAI,YAAY,MAAM,aAAa,CAAC;AAGtD,QAAM,UACJ,cAAc,QAAQ,YAAY,cAAc,QAAQ;AAE1D,QAAM,kBAAkB,MAAM;AAE9B,QAAM,SACJ,YAAY,YAAY,IAAI,IAAI,GAAG,KAAK,QACxC,MAAM,UAAU,YAAY,MAAMA,MAAAA,mBAAmB;AACvD,MAAI,SAAS,SAAS,YAAY;AAClC,MAAI,WAAW;AACb,aA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