@dxos/react-ui-table 0.6.14-staging.e15392e → 0.7.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/dist/lib/browser/_deprecated/index.mjs +1483 -0
- package/dist/lib/browser/_deprecated/index.mjs.map +7 -0
- package/dist/lib/browser/chunk-A5W4XWPD.mjs +18 -0
- package/dist/lib/browser/chunk-A5W4XWPD.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1275 -1356
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +7 -0
- package/dist/lib/browser/types/index.mjs.map +7 -0
- package/dist/lib/node/_deprecated/index.cjs +1511 -0
- package/dist/lib/node/_deprecated/index.cjs.map +7 -0
- package/dist/lib/node/chunk-32IGMRME.cjs +40 -0
- package/dist/lib/node/chunk-32IGMRME.cjs.map +7 -0
- package/dist/lib/node/index.cjs +1381 -0
- package/dist/lib/node/index.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -0
- package/dist/lib/node/types/index.cjs +29 -0
- package/dist/lib/node/types/index.cjs.map +7 -0
- package/dist/lib/node-esm/_deprecated/index.mjs +1485 -0
- package/dist/lib/node-esm/_deprecated/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-DWQ4KGLD.mjs +20 -0
- package/dist/lib/node-esm/chunk-DWQ4KGLD.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1400 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/types/index.mjs +8 -0
- package/dist/lib/node-esm/types/index.mjs.map +7 -0
- package/dist/types/src/_deprecated/components/Cell/Cell.d.ts.map +1 -0
- package/dist/types/src/_deprecated/components/Cell/CellCombobox.d.ts.map +1 -0
- package/dist/types/src/_deprecated/components/Cell/index.d.ts.map +1 -0
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnMenu.d.ts.map +1 -0
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnMenu.stories.d.ts.map +1 -0
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnSettings.d.ts.map +1 -0
- package/dist/types/src/{components → _deprecated/components}/ColumnMenu/ColumnSettings.stories.d.ts +4 -4
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnSettings.stories.d.ts.map +1 -0
- package/dist/types/src/_deprecated/components/ColumnMenu/index.d.ts.map +1 -0
- package/dist/types/src/_deprecated/components/Table/Table.d.ts +20 -0
- package/dist/types/src/_deprecated/components/Table/Table.d.ts.map +1 -0
- package/dist/types/src/_deprecated/components/Table/Table.stories.d.ts +116 -0
- package/dist/types/src/_deprecated/components/Table/Table.stories.d.ts.map +1 -0
- package/dist/types/src/_deprecated/components/Table/TableBody.d.ts.map +1 -0
- package/dist/types/src/_deprecated/components/Table/TableContext.d.ts.map +1 -0
- package/dist/types/src/_deprecated/components/Table/TableHead.d.ts.map +1 -0
- package/dist/types/src/_deprecated/components/Table/TableRootContext.d.ts.map +1 -0
- package/dist/types/src/_deprecated/components/Table/index.d.ts +5 -0
- package/dist/types/src/_deprecated/components/Table/index.d.ts.map +1 -0
- package/dist/types/src/_deprecated/components/Table/props.d.ts.map +1 -0
- package/dist/types/src/_deprecated/components/index.d.ts +4 -0
- package/dist/types/src/_deprecated/components/index.d.ts.map +1 -0
- package/dist/types/src/_deprecated/helpers.d.ts.map +1 -0
- package/dist/types/src/_deprecated/hooks/index.d.ts +5 -0
- package/dist/types/src/_deprecated/hooks/index.d.ts.map +1 -0
- package/dist/types/src/_deprecated/hooks/useColumnSizing.d.ts.map +1 -0
- package/dist/types/src/{hooks → _deprecated/hooks}/useColumnSorting.d.ts +1 -1
- package/dist/types/src/_deprecated/hooks/useColumnSorting.d.ts.map +1 -0
- package/dist/types/src/_deprecated/hooks/usePinLastRow.d.ts.map +1 -0
- package/dist/types/src/_deprecated/hooks/useRowSelection.d.ts.map +1 -0
- package/dist/types/src/_deprecated/index.d.ts +8 -0
- package/dist/types/src/_deprecated/index.d.ts.map +1 -0
- package/dist/types/src/_deprecated/schema/Schema.stories.d.ts.map +1 -0
- package/dist/types/src/{schema → _deprecated/schema}/column-utils.d.ts +3 -0
- package/dist/types/src/_deprecated/schema/column-utils.d.ts.map +1 -0
- package/dist/types/src/_deprecated/schema/index.d.ts.map +1 -0
- package/dist/types/src/{schema → _deprecated/schema}/types.d.ts +3 -2
- package/dist/types/src/_deprecated/schema/types.d.ts.map +1 -0
- package/dist/types/src/_deprecated/theme.d.ts.map +1 -0
- package/dist/types/src/_deprecated/translations.d.ts +21 -0
- package/dist/types/src/_deprecated/translations.d.ts.map +1 -0
- package/dist/types/src/_deprecated/types.d.ts.map +1 -0
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts +8 -0
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -0
- package/dist/types/src/components/Table/ColumnSettings.d.ts +8 -0
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -0
- package/dist/types/src/components/Table/RowActionsMenu.d.ts +8 -0
- package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -0
- package/dist/types/src/components/Table/Table.d.ts +11 -14
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +10 -113
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/index.d.ts +0 -3
- package/dist/types/src/components/Table/index.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +17 -0
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -0
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +11 -0
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/TableCellEditor/extension.d.ts +12 -0
- package/dist/types/src/components/TableCellEditor/extension.d.ts.map +1 -0
- package/dist/types/src/components/TableCellEditor/index.d.ts +2 -0
- package/dist/types/src/components/TableCellEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +21 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/common.d.ts +20 -0
- package/dist/types/src/components/Toolbar/common.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/index.d.ts +2 -0
- package/dist/types/src/components/Toolbar/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +97 -0
- package/dist/types/src/components/testing.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +1 -4
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts +15 -0
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -4
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/model/index.d.ts +3 -0
- package/dist/types/src/model/index.d.ts.map +1 -0
- package/dist/types/src/model/modal-controller.d.ts +29 -0
- package/dist/types/src/model/modal-controller.d.ts.map +1 -0
- package/dist/types/src/model/selection-model.d.ts +22 -0
- package/dist/types/src/model/selection-model.d.ts.map +1 -0
- package/dist/types/src/model/table-model.d.ts +93 -0
- package/dist/types/src/model/table-model.d.ts.map +1 -0
- package/dist/types/src/model/table-model.test.d.ts +2 -0
- package/dist/types/src/model/table-model.test.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +23 -16
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +2 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/table.d.ts +106 -0
- package/dist/types/src/types/table.d.ts.map +1 -0
- package/dist/types/src/util/grid.d.ts +14 -0
- package/dist/types/src/util/grid.d.ts.map +1 -0
- package/dist/types/src/util/index.d.ts +5 -0
- package/dist/types/src/util/index.d.ts.map +1 -0
- package/dist/types/src/util/signals.d.ts +6 -0
- package/dist/types/src/util/signals.d.ts.map +1 -0
- package/dist/types/src/util/table-buttons.d.ts +24 -0
- package/dist/types/src/util/table-buttons.d.ts.map +1 -0
- package/dist/types/src/util/table-controls.d.ts +21 -0
- package/dist/types/src/util/table-controls.d.ts.map +1 -0
- package/dist/types/src/util/table.d.ts +8 -0
- package/dist/types/src/util/table.d.ts.map +1 -0
- package/package.json +56 -22
- package/src/{components → _deprecated/components}/ColumnMenu/ColumnMenu.stories.tsx +4 -4
- package/src/{components → _deprecated/components}/ColumnMenu/ColumnSettings.stories.tsx +9 -9
- package/src/{components → _deprecated/components}/ColumnMenu/ColumnSettings.tsx +3 -3
- package/src/_deprecated/components/Table/Table.stories.tsx +508 -0
- package/src/_deprecated/components/Table/Table.tsx +301 -0
- package/src/{components → _deprecated/components}/Table/TableHead.tsx +3 -1
- package/src/_deprecated/components/Table/index.ts +8 -0
- package/src/_deprecated/components/index.ts +7 -0
- package/src/{helpers.tsx → _deprecated/helpers.tsx} +4 -3
- package/src/_deprecated/hooks/index.ts +8 -0
- package/src/_deprecated/index.ts +12 -0
- package/src/_deprecated/schema/column-utils.ts +54 -0
- package/src/{schema → _deprecated/schema}/types.ts +3 -2
- package/src/_deprecated/translations.ts +26 -0
- package/src/components/Table/ColumnActionsMenu.tsx +60 -0
- package/src/components/Table/ColumnSettings.tsx +76 -0
- package/src/components/Table/RowActionsMenu.tsx +36 -0
- package/src/components/Table/Table.stories.tsx +197 -467
- package/src/components/Table/Table.tsx +172 -256
- package/src/components/Table/index.ts +1 -4
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +114 -0
- package/src/components/TableCellEditor/TableCellEditor.tsx +155 -0
- package/src/components/TableCellEditor/extension.ts +62 -0
- package/src/components/TableCellEditor/index.ts +5 -0
- package/src/components/Toolbar/Toolbar.tsx +86 -0
- package/src/components/Toolbar/common.tsx +72 -0
- package/src/components/Toolbar/index.ts +5 -0
- package/src/components/index.ts +2 -3
- package/src/components/testing.ts +114 -0
- package/src/hooks/index.ts +1 -4
- package/src/hooks/useTableModel.ts +52 -0
- package/src/index.ts +5 -6
- package/src/model/index.ts +6 -0
- package/src/model/modal-controller.ts +83 -0
- package/src/model/selection-model.ts +99 -0
- package/src/model/table-model.test.ts +182 -0
- package/src/model/table-model.ts +565 -0
- package/src/translations.ts +20 -13
- package/src/types/index.ts +5 -0
- package/src/types/table.ts +13 -0
- package/src/util/grid.ts +23 -0
- package/src/util/index.ts +8 -0
- package/src/util/signals.ts +9 -0
- package/src/util/table-buttons.ts +48 -0
- package/src/util/table-controls.ts +27 -0
- package/src/util/table.ts +77 -0
- package/dist/types/src/components/Cell/Cell.d.ts.map +0 -1
- package/dist/types/src/components/Cell/CellCombobox.d.ts.map +0 -1
- package/dist/types/src/components/Cell/index.d.ts.map +0 -1
- package/dist/types/src/components/ColumnMenu/ColumnMenu.d.ts.map +0 -1
- package/dist/types/src/components/ColumnMenu/ColumnMenu.stories.d.ts.map +0 -1
- package/dist/types/src/components/ColumnMenu/ColumnSettings.d.ts.map +0 -1
- package/dist/types/src/components/ColumnMenu/ColumnSettings.stories.d.ts.map +0 -1
- package/dist/types/src/components/ColumnMenu/index.d.ts.map +0 -1
- package/dist/types/src/components/Table/TableBody.d.ts.map +0 -1
- package/dist/types/src/components/Table/TableContext.d.ts.map +0 -1
- package/dist/types/src/components/Table/TableHead.d.ts.map +0 -1
- package/dist/types/src/components/Table/TableRootContext.d.ts.map +0 -1
- package/dist/types/src/components/Table/props.d.ts.map +0 -1
- package/dist/types/src/helpers.d.ts.map +0 -1
- package/dist/types/src/hooks/useColumnSizing.d.ts.map +0 -1
- package/dist/types/src/hooks/useColumnSorting.d.ts.map +0 -1
- package/dist/types/src/hooks/usePinLastRow.d.ts.map +0 -1
- package/dist/types/src/hooks/useRowSelection.d.ts.map +0 -1
- package/dist/types/src/schema/Schema.stories.d.ts.map +0 -1
- package/dist/types/src/schema/column-utils.d.ts.map +0 -1
- package/dist/types/src/schema/index.d.ts.map +0 -1
- package/dist/types/src/schema/types.d.ts.map +0 -1
- package/dist/types/src/theme.d.ts.map +0 -1
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/schema/column-utils.ts +0 -48
- /package/dist/types/src/{components → _deprecated/components}/Cell/Cell.d.ts +0 -0
- /package/dist/types/src/{components → _deprecated/components}/Cell/CellCombobox.d.ts +0 -0
- /package/dist/types/src/{components → _deprecated/components}/Cell/index.d.ts +0 -0
- /package/dist/types/src/{components → _deprecated/components}/ColumnMenu/ColumnMenu.d.ts +0 -0
- /package/dist/types/src/{components → _deprecated/components}/ColumnMenu/ColumnMenu.stories.d.ts +0 -0
- /package/dist/types/src/{components → _deprecated/components}/ColumnMenu/ColumnSettings.d.ts +0 -0
- /package/dist/types/src/{components → _deprecated/components}/ColumnMenu/index.d.ts +0 -0
- /package/dist/types/src/{components → _deprecated/components}/Table/TableBody.d.ts +0 -0
- /package/dist/types/src/{components → _deprecated/components}/Table/TableContext.d.ts +0 -0
- /package/dist/types/src/{components → _deprecated/components}/Table/TableHead.d.ts +0 -0
- /package/dist/types/src/{components → _deprecated/components}/Table/TableRootContext.d.ts +0 -0
- /package/dist/types/src/{components → _deprecated/components}/Table/props.d.ts +0 -0
- /package/dist/types/src/{helpers.d.ts → _deprecated/helpers.d.ts} +0 -0
- /package/dist/types/src/{hooks → _deprecated/hooks}/useColumnSizing.d.ts +0 -0
- /package/dist/types/src/{hooks → _deprecated/hooks}/usePinLastRow.d.ts +0 -0
- /package/dist/types/src/{hooks → _deprecated/hooks}/useRowSelection.d.ts +0 -0
- /package/dist/types/src/{schema → _deprecated/schema}/Schema.stories.d.ts +0 -0
- /package/dist/types/src/{schema → _deprecated/schema}/index.d.ts +0 -0
- /package/dist/types/src/{theme.d.ts → _deprecated/theme.d.ts} +0 -0
- /package/dist/types/src/{types.d.ts → _deprecated/types.d.ts} +0 -0
- /package/src/{components → _deprecated/components}/Cell/Cell.tsx +0 -0
- /package/src/{components → _deprecated/components}/Cell/CellCombobox.tsx +0 -0
- /package/src/{components → _deprecated/components}/Cell/index.ts +0 -0
- /package/src/{components → _deprecated/components}/ColumnMenu/ColumnMenu.tsx +0 -0
- /package/src/{components → _deprecated/components}/ColumnMenu/index.ts +0 -0
- /package/src/{components → _deprecated/components}/Table/TableBody.tsx +0 -0
- /package/src/{components → _deprecated/components}/Table/TableContext.tsx +0 -0
- /package/src/{components → _deprecated/components}/Table/TableRootContext.ts +0 -0
- /package/src/{components → _deprecated/components}/Table/props.ts +0 -0
- /package/src/{hooks → _deprecated/hooks}/useColumnSizing.ts +0 -0
- /package/src/{hooks → _deprecated/hooks}/useColumnSorting.ts +0 -0
- /package/src/{hooks → _deprecated/hooks}/usePinLastRow.ts +0 -0
- /package/src/{hooks → _deprecated/hooks}/useRowSelection.ts +0 -0
- /package/src/{schema → _deprecated/schema}/Schema.stories.tsx +0 -0
- /package/src/{schema → _deprecated/schema}/index.ts +0 -0
- /package/src/{theme.ts → _deprecated/theme.ts} +0 -0
- /package/src/{types.ts → _deprecated/types.ts} +0 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback, useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { FormatEnum } from '@dxos/echo-schema';
|
|
8
|
+
import { invariant } from '@dxos/invariant';
|
|
9
|
+
import { type DxGrid } from '@dxos/lit-grid';
|
|
10
|
+
import {
|
|
11
|
+
editorKeys,
|
|
12
|
+
type EditorKeyEvent,
|
|
13
|
+
GridCellEditor,
|
|
14
|
+
type GridCellEditorProps,
|
|
15
|
+
type EditorKeyOrBlurHandler,
|
|
16
|
+
type EditorBlurHandler,
|
|
17
|
+
type GridScopedProps,
|
|
18
|
+
useGridContext,
|
|
19
|
+
} from '@dxos/react-ui-grid';
|
|
20
|
+
import { type FieldProjection } from '@dxos/schema';
|
|
21
|
+
|
|
22
|
+
import { completion } from './extension';
|
|
23
|
+
import { type TableModel } from '../../model';
|
|
24
|
+
import { type GridCell, toGridCell } from '../../util';
|
|
25
|
+
|
|
26
|
+
export type TableCellEditorProps = {
|
|
27
|
+
model?: TableModel;
|
|
28
|
+
onEnter?: (cell: GridCell) => void;
|
|
29
|
+
onFocus?: DxGrid['refocus'];
|
|
30
|
+
onQuery?: (field: FieldProjection, text: string) => Promise<{ label: string; data: any }[]>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const TableCellEditor = ({
|
|
34
|
+
model,
|
|
35
|
+
onEnter,
|
|
36
|
+
onFocus,
|
|
37
|
+
onQuery,
|
|
38
|
+
__gridScope,
|
|
39
|
+
}: GridScopedProps<TableCellEditorProps>) => {
|
|
40
|
+
const { editing } = useGridContext('TableCellEditor', __gridScope);
|
|
41
|
+
const fieldProjection = useMemo<FieldProjection | undefined>(() => {
|
|
42
|
+
if (!model || !editing) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const { col } = toGridCell(editing.index);
|
|
47
|
+
const field = model.projection.view.fields[col];
|
|
48
|
+
const fieldProjection = model.projection.getFieldProjection(field.id);
|
|
49
|
+
invariant(fieldProjection);
|
|
50
|
+
return fieldProjection;
|
|
51
|
+
}, [model, editing]);
|
|
52
|
+
|
|
53
|
+
const handleClose = useCallback<EditorKeyOrBlurHandler>(
|
|
54
|
+
(value, event) => {
|
|
55
|
+
if (!model || !editing || !fieldProjection) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const cell = toGridCell(editing.index);
|
|
60
|
+
onEnter?.(cell);
|
|
61
|
+
if (event && onFocus) {
|
|
62
|
+
onFocus(determineNavigationAxis(event), determineNavigationDelta(event));
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
[model, editing, onFocus, onEnter, fieldProjection, determineNavigationAxis, determineNavigationDelta],
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const handleBlur = useCallback<EditorBlurHandler>(
|
|
69
|
+
(value) => {
|
|
70
|
+
if (!model || !editing) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const cell = toGridCell(editing.index);
|
|
75
|
+
if (value !== undefined) {
|
|
76
|
+
model.setCellData(cell, value);
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
[model, editing],
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const extension = useMemo(() => {
|
|
83
|
+
if (!fieldProjection) {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const extension = [
|
|
88
|
+
editorKeys({
|
|
89
|
+
onClose: handleClose,
|
|
90
|
+
...(editing?.initialContent && { onNav: handleClose }),
|
|
91
|
+
}),
|
|
92
|
+
];
|
|
93
|
+
|
|
94
|
+
if (onQuery) {
|
|
95
|
+
switch (fieldProjection.props.format) {
|
|
96
|
+
case FormatEnum.Ref: {
|
|
97
|
+
extension.push([
|
|
98
|
+
completion({
|
|
99
|
+
onQuery: (text) => onQuery(fieldProjection, text),
|
|
100
|
+
onMatch: (data) => {
|
|
101
|
+
if (model && editing) {
|
|
102
|
+
const cell = toGridCell(editing.index);
|
|
103
|
+
model.setCellData(cell, data);
|
|
104
|
+
onEnter?.(cell);
|
|
105
|
+
onFocus?.();
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
}),
|
|
109
|
+
]);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return extension;
|
|
116
|
+
}, [model, editing, fieldProjection, handleClose]);
|
|
117
|
+
|
|
118
|
+
const getCellContent = useCallback<GridCellEditorProps['getCellContent']>(() => {
|
|
119
|
+
if (model && editing) {
|
|
120
|
+
const value = model.getCellData(toGridCell(editing.index));
|
|
121
|
+
return value !== undefined ? String(value) : '';
|
|
122
|
+
}
|
|
123
|
+
}, [model, editing]);
|
|
124
|
+
|
|
125
|
+
return <GridCellEditor extension={extension} getCellContent={getCellContent} onBlur={handleBlur} />;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const determineNavigationAxis = ({ key }: EditorKeyEvent): 'col' | 'row' | undefined => {
|
|
129
|
+
switch (key) {
|
|
130
|
+
case 'ArrowUp':
|
|
131
|
+
case 'ArrowDown':
|
|
132
|
+
case 'Enter': {
|
|
133
|
+
return 'row';
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
case 'ArrowLeft':
|
|
137
|
+
case 'ArrowRight':
|
|
138
|
+
case 'Tab':
|
|
139
|
+
return 'col';
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const determineNavigationDelta = ({ key, shift }: EditorKeyEvent): -1 | 1 => {
|
|
144
|
+
switch (key) {
|
|
145
|
+
case 'ArrowUp':
|
|
146
|
+
case 'ArrowLeft':
|
|
147
|
+
return -1;
|
|
148
|
+
|
|
149
|
+
case 'ArrowDown':
|
|
150
|
+
case 'ArrowRight':
|
|
151
|
+
return 1;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return shift ? -1 : 1;
|
|
155
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
autocompletion,
|
|
7
|
+
pickedCompletion,
|
|
8
|
+
type CompletionContext,
|
|
9
|
+
type CompletionResult,
|
|
10
|
+
} from '@codemirror/autocomplete';
|
|
11
|
+
import { type Extension } from '@codemirror/state';
|
|
12
|
+
import { EditorView } from '@codemirror/view';
|
|
13
|
+
|
|
14
|
+
export type CompletionOptions = {
|
|
15
|
+
onQuery: (text: string) => Promise<CompletionResult['options']>;
|
|
16
|
+
onMatch: (data: any) => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Autocomplete Codemirror extension.
|
|
21
|
+
* https://codemirror.net/docs/ref/#autocomplete.autocompletion
|
|
22
|
+
*/
|
|
23
|
+
export const completion = ({ onQuery, onMatch }: CompletionOptions): Extension => {
|
|
24
|
+
return [
|
|
25
|
+
EditorView.theme({
|
|
26
|
+
'.cm-completionDialog': {
|
|
27
|
+
width: 'var(--dx-gridCellWidth)',
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
|
|
31
|
+
autocompletion({
|
|
32
|
+
icons: false,
|
|
33
|
+
activateOnTyping: true,
|
|
34
|
+
override: [
|
|
35
|
+
async (context: CompletionContext): Promise<CompletionResult> => {
|
|
36
|
+
const text = context.state.doc.toString();
|
|
37
|
+
return {
|
|
38
|
+
from: 0,
|
|
39
|
+
options: await onQuery(text),
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
|
|
44
|
+
// TODO(burdon): Consts from grid (to line-up with grid).
|
|
45
|
+
tooltipClass: () => 'cm-completionDialog !mt-[8px] !-ml-[4px] [&>ul]:!max-h-[264px]',
|
|
46
|
+
optionClass: () => 'flex h-[33px] items-center',
|
|
47
|
+
|
|
48
|
+
// Uncomment to debug.
|
|
49
|
+
// closeOnBlur: true,
|
|
50
|
+
}),
|
|
51
|
+
|
|
52
|
+
// Check for accepted completion metadata in the transaction.
|
|
53
|
+
EditorView.updateListener.of((update) => {
|
|
54
|
+
update.transactions.forEach((tr) => {
|
|
55
|
+
const completion = tr.annotation(pickedCompletion);
|
|
56
|
+
if (completion) {
|
|
57
|
+
onMatch((completion as any).data);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}),
|
|
61
|
+
];
|
|
62
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { ChatText, RowsPlusBottom } from '@phosphor-icons/react';
|
|
6
|
+
import { createContext } from '@radix-ui/react-context';
|
|
7
|
+
import React, { type PropsWithChildren } from 'react';
|
|
8
|
+
|
|
9
|
+
import { Toolbar as NaturalToolbar, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
10
|
+
|
|
11
|
+
import { ToolbarButton, ToolbarSeparator } from './common';
|
|
12
|
+
import { translationKey } from '../../translations';
|
|
13
|
+
|
|
14
|
+
//
|
|
15
|
+
// Root
|
|
16
|
+
//
|
|
17
|
+
|
|
18
|
+
// TODO(Zan): This should become a union later.
|
|
19
|
+
export type ToolbarAction = { type: 'add-row' } | { type: 'comment' };
|
|
20
|
+
|
|
21
|
+
export type ToolbarActionType = ToolbarAction['type'];
|
|
22
|
+
|
|
23
|
+
export type ToolbarActionHandler = (action: ToolbarAction) => void;
|
|
24
|
+
|
|
25
|
+
export type ToolbarProps = ThemedClassName<
|
|
26
|
+
PropsWithChildren<{
|
|
27
|
+
onAction?: ToolbarActionHandler;
|
|
28
|
+
}>
|
|
29
|
+
>;
|
|
30
|
+
|
|
31
|
+
const [ToolbarContextProvider, useToolbarContext] = createContext<ToolbarProps>('Toolbar');
|
|
32
|
+
|
|
33
|
+
const ToolbarRoot = ({ classNames, children, onAction }: ToolbarProps) => {
|
|
34
|
+
return (
|
|
35
|
+
<ToolbarContextProvider onAction={onAction}>
|
|
36
|
+
<NaturalToolbar.Root classNames={['is-full shrink-0 overflow-x-auto overflow-y-hidden p-1', classNames]}>
|
|
37
|
+
{children}
|
|
38
|
+
</NaturalToolbar.Root>
|
|
39
|
+
</ToolbarContextProvider>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const Editing = () => {
|
|
44
|
+
const { onAction } = useToolbarContext('Editing');
|
|
45
|
+
const { t } = useTranslation(translationKey);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<>
|
|
49
|
+
<ToolbarButton
|
|
50
|
+
value='add-row'
|
|
51
|
+
Icon={RowsPlusBottom}
|
|
52
|
+
data-testid='table.toolbar.add-row'
|
|
53
|
+
onClick={() => onAction?.({ type: 'add-row' })}
|
|
54
|
+
>
|
|
55
|
+
{t('add row')}
|
|
56
|
+
</ToolbarButton>
|
|
57
|
+
</>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const Actions = () => {
|
|
62
|
+
const { onAction } = useToolbarContext('Actions');
|
|
63
|
+
const { t } = useTranslation(translationKey);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<>
|
|
67
|
+
<ToolbarButton
|
|
68
|
+
value='comment'
|
|
69
|
+
Icon={ChatText}
|
|
70
|
+
data-testid='table.toolbar.comment'
|
|
71
|
+
onClick={() => onAction?.({ type: 'comment' })}
|
|
72
|
+
>
|
|
73
|
+
{t('create comment')}
|
|
74
|
+
</ToolbarButton>
|
|
75
|
+
</>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const Toolbar = {
|
|
80
|
+
Root: ToolbarRoot,
|
|
81
|
+
Editing,
|
|
82
|
+
Actions,
|
|
83
|
+
Separator: ToolbarSeparator,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export { useToolbarContext };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Icon } from '@phosphor-icons/react';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
Toolbar as NaturalToolbar,
|
|
10
|
+
Tooltip,
|
|
11
|
+
type ToolbarButtonProps as NaturalToolbarButtonProps,
|
|
12
|
+
type ToolbarToggleGroupItemProps as NaturalToolbarToggleGroupItemProps,
|
|
13
|
+
} from '@dxos/react-ui';
|
|
14
|
+
import { getSize } from '@dxos/react-ui-theme';
|
|
15
|
+
|
|
16
|
+
// TODO(burdon): Factor out in common with react-ui-editor.
|
|
17
|
+
|
|
18
|
+
export const iconStyles = getSize(5);
|
|
19
|
+
export const buttonStyles = 'min-bs-0 p-2';
|
|
20
|
+
export const tooltipProps = { side: 'top' as const, classNames: 'z-10' };
|
|
21
|
+
|
|
22
|
+
export const ToolbarSeparator = () => <div role='separator' className='grow' />;
|
|
23
|
+
|
|
24
|
+
//
|
|
25
|
+
// ToolbarButton
|
|
26
|
+
//
|
|
27
|
+
|
|
28
|
+
type ToolbarButtonProps = NaturalToolbarButtonProps & { Icon: Icon };
|
|
29
|
+
|
|
30
|
+
export const ToolbarButton = ({ Icon, children, ...props }: ToolbarButtonProps) => {
|
|
31
|
+
return (
|
|
32
|
+
<Tooltip.Root>
|
|
33
|
+
<Tooltip.Trigger asChild>
|
|
34
|
+
<NaturalToolbar.Button variant='ghost' {...props} classNames={buttonStyles}>
|
|
35
|
+
<Icon className={iconStyles} />
|
|
36
|
+
<span className='sr-only'>{children}</span>
|
|
37
|
+
</NaturalToolbar.Button>
|
|
38
|
+
</Tooltip.Trigger>
|
|
39
|
+
<Tooltip.Portal>
|
|
40
|
+
<Tooltip.Content {...tooltipProps}>
|
|
41
|
+
{children}
|
|
42
|
+
<Tooltip.Arrow />
|
|
43
|
+
</Tooltip.Content>
|
|
44
|
+
</Tooltip.Portal>
|
|
45
|
+
</Tooltip.Root>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//
|
|
50
|
+
// ToolbarToggleButton
|
|
51
|
+
//
|
|
52
|
+
|
|
53
|
+
export type ToolbarToggleButtonProps = NaturalToolbarToggleGroupItemProps & { Icon: Icon };
|
|
54
|
+
|
|
55
|
+
export const ToolbarToggleButton = ({ Icon, children, ...props }: ToolbarToggleButtonProps) => {
|
|
56
|
+
return (
|
|
57
|
+
<Tooltip.Root>
|
|
58
|
+
<Tooltip.Trigger asChild>
|
|
59
|
+
<NaturalToolbar.ToggleGroupItem variant='ghost' {...props} classNames={buttonStyles}>
|
|
60
|
+
<Icon className={iconStyles} />
|
|
61
|
+
<span className='sr-only'>{children}</span>
|
|
62
|
+
</NaturalToolbar.ToggleGroupItem>
|
|
63
|
+
</Tooltip.Trigger>
|
|
64
|
+
<Tooltip.Portal>
|
|
65
|
+
<Tooltip.Content {...tooltipProps}>
|
|
66
|
+
{children}
|
|
67
|
+
<Tooltip.Arrow />
|
|
68
|
+
</Tooltip.Content>
|
|
69
|
+
</Tooltip.Portal>
|
|
70
|
+
</Tooltip.Root>
|
|
71
|
+
);
|
|
72
|
+
};
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useEffect } from 'react';
|
|
6
|
+
|
|
7
|
+
import { create, setValue, toJsonSchema, S, TypeEnum, TypedObject, FormatEnum } from '@dxos/echo-schema';
|
|
8
|
+
import { faker } from '@dxos/random';
|
|
9
|
+
import { createView, type ViewProjection } from '@dxos/schema';
|
|
10
|
+
import {} from '@dxos/schema';
|
|
11
|
+
|
|
12
|
+
import { TableType } from '../types';
|
|
13
|
+
|
|
14
|
+
export const TestSchema = TypedObject({ typename: 'example.com/type/Test', version: '0.1.0' })({
|
|
15
|
+
id: S.String,
|
|
16
|
+
name: S.optional(S.String),
|
|
17
|
+
age: S.optional(S.Number),
|
|
18
|
+
active: S.optional(S.Boolean),
|
|
19
|
+
netWorth: S.optional(S.Number),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const createTable = (schema = TestSchema) => {
|
|
23
|
+
return create(TableType, {
|
|
24
|
+
view: createView({
|
|
25
|
+
name: 'Test',
|
|
26
|
+
typename: schema.typename,
|
|
27
|
+
jsonSchema: toJsonSchema(schema),
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const createItems = (n: number) => {
|
|
33
|
+
const { data } = create({
|
|
34
|
+
data: Array.from({ length: n }, () => ({
|
|
35
|
+
name: faker.person.fullName(),
|
|
36
|
+
age: faker.number.int({ min: 20, max: 70 }),
|
|
37
|
+
active: faker.datatype.boolean(),
|
|
38
|
+
netWorth: faker.number.int(),
|
|
39
|
+
})),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return data;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type SimulatorProps = {
|
|
46
|
+
table: TableType;
|
|
47
|
+
items: any[];
|
|
48
|
+
insertInterval?: number;
|
|
49
|
+
updateInterval?: number;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const useSimulator = ({ items, table, insertInterval, updateInterval }: SimulatorProps) => {
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!insertInterval) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const i = setInterval(() => {
|
|
59
|
+
const [item] = createItems(1);
|
|
60
|
+
items.unshift(item);
|
|
61
|
+
}, insertInterval);
|
|
62
|
+
|
|
63
|
+
return () => clearInterval(i);
|
|
64
|
+
}, [items, insertInterval]);
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!updateInterval) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const i = setInterval(() => {
|
|
72
|
+
const rowIdx = Math.floor(Math.random() * items.length);
|
|
73
|
+
const fields = table.view?.fields ?? [];
|
|
74
|
+
const columnIdx = Math.floor(Math.random() * fields.length);
|
|
75
|
+
const projection: ViewProjection = (table as any)._projection;
|
|
76
|
+
const field = fields[columnIdx];
|
|
77
|
+
const item = items[rowIdx];
|
|
78
|
+
|
|
79
|
+
const {
|
|
80
|
+
props: { type, format },
|
|
81
|
+
} = projection.getFieldProjection(field.id);
|
|
82
|
+
|
|
83
|
+
if (field) {
|
|
84
|
+
const path = field.path;
|
|
85
|
+
// TODO(ZaymonFC): Restore this once I know how to derive the type from the schema.
|
|
86
|
+
switch (type) {
|
|
87
|
+
case TypeEnum.String: {
|
|
88
|
+
setValue(item, path, `Updated ${Date.now()}`);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case TypeEnum.Number: {
|
|
92
|
+
setValue(item, path, Math.floor(Math.random() * 100));
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
case TypeEnum.Boolean: {
|
|
96
|
+
setValue(item, path, !item[path]);
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (format) {
|
|
102
|
+
switch (format) {
|
|
103
|
+
case FormatEnum.Currency: {
|
|
104
|
+
item[path] = Math.floor(Math.random() * 1000);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, updateInterval);
|
|
111
|
+
|
|
112
|
+
return () => clearInterval(i);
|
|
113
|
+
}, [items, table.view?.fields, updateInterval]);
|
|
114
|
+
};
|
package/src/hooks/index.ts
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useEffect, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type ReactiveObject } from '@dxos/react-client/echo';
|
|
8
|
+
import { type ViewProjection } from '@dxos/schema';
|
|
9
|
+
|
|
10
|
+
import { type BaseTableRow, TableModel, type TableModelProps } from '../model';
|
|
11
|
+
import { type TableType } from '../types';
|
|
12
|
+
|
|
13
|
+
export type UseTableModelParams<T extends BaseTableRow = { id: string }> = {
|
|
14
|
+
table?: TableType;
|
|
15
|
+
projection?: ViewProjection;
|
|
16
|
+
objects?: ReactiveObject<T>[];
|
|
17
|
+
} & Pick<TableModelProps<T>, 'onInsertRow' | 'onDeleteRows' | 'onDeleteColumn' | 'onCellUpdate' | 'onRowOrderChanged'>;
|
|
18
|
+
|
|
19
|
+
export const useTableModel = <T extends BaseTableRow = { id: string }>({
|
|
20
|
+
objects,
|
|
21
|
+
table,
|
|
22
|
+
projection,
|
|
23
|
+
...props
|
|
24
|
+
}: UseTableModelParams<T>): TableModel<T> | undefined => {
|
|
25
|
+
const [model, setModel] = useState<TableModel<T>>();
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!table || !projection) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let model: TableModel<T> | undefined;
|
|
32
|
+
const t = setTimeout(async () => {
|
|
33
|
+
model = new TableModel<T>({ table, projection, ...props });
|
|
34
|
+
await model.open();
|
|
35
|
+
setModel(model);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return () => {
|
|
39
|
+
clearTimeout(t);
|
|
40
|
+
void model?.close();
|
|
41
|
+
};
|
|
42
|
+
}, [table, projection]); // TODO(burdon): Trigger if callbacks change?
|
|
43
|
+
|
|
44
|
+
// Update data.
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (objects) {
|
|
47
|
+
model?.setRows(objects);
|
|
48
|
+
}
|
|
49
|
+
}, [model, objects]);
|
|
50
|
+
|
|
51
|
+
return model;
|
|
52
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
|
-
|
|
5
|
-
export { default as translations } from './translations';
|
|
4
|
+
import translations from './translations';
|
|
6
5
|
|
|
7
6
|
export * from './components';
|
|
8
|
-
export * from './helpers';
|
|
9
7
|
export * from './hooks';
|
|
10
|
-
export * from './schema';
|
|
11
|
-
export * from './theme';
|
|
12
8
|
export * from './types';
|
|
9
|
+
export * from './util';
|
|
10
|
+
|
|
11
|
+
export { translations };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { signal } from '@preact/signals-core';
|
|
6
|
+
import { type RefObject, type MouseEvent, type MutableRefObject } from 'react';
|
|
7
|
+
|
|
8
|
+
import { tableButtons } from '../util';
|
|
9
|
+
|
|
10
|
+
export type ColumnSettingsMode = { type: 'create' } | { type: 'edit'; fieldId: string };
|
|
11
|
+
|
|
12
|
+
export type ModalState =
|
|
13
|
+
| { type: 'row'; rowIndex: number }
|
|
14
|
+
| { type: 'column'; fieldId: string }
|
|
15
|
+
| { type: 'columnSettings'; mode: ColumnSettingsMode }
|
|
16
|
+
| { type: 'closed' };
|
|
17
|
+
|
|
18
|
+
export class ModalController {
|
|
19
|
+
private readonly _state = signal<ModalState>({ type: 'closed' });
|
|
20
|
+
private readonly _triggerRef: MutableRefObject<HTMLElement> = { current: null as unknown as HTMLElement };
|
|
21
|
+
|
|
22
|
+
public get state() {
|
|
23
|
+
return this._state;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public get trigger() {
|
|
27
|
+
return this._triggerRef as RefObject<HTMLButtonElement>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public handleClick = (event: MouseEvent): boolean => {
|
|
31
|
+
const target = event.target as HTMLElement;
|
|
32
|
+
|
|
33
|
+
const rowButton = target.closest(`button[${tableButtons.rowMenu.attr}]`);
|
|
34
|
+
if (rowButton) {
|
|
35
|
+
this._triggerRef.current = rowButton as HTMLElement;
|
|
36
|
+
this._state.value = {
|
|
37
|
+
type: 'row',
|
|
38
|
+
rowIndex: Number(rowButton.getAttribute(tableButtons.rowMenu.attr)),
|
|
39
|
+
};
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const columnButton = target.closest(`button[${tableButtons.columnSettings.attr}]`);
|
|
44
|
+
if (columnButton) {
|
|
45
|
+
const fieldId = columnButton.getAttribute(tableButtons.columnSettings.attr)!;
|
|
46
|
+
this._triggerRef.current = columnButton as HTMLElement;
|
|
47
|
+
this._state.value = {
|
|
48
|
+
type: 'column',
|
|
49
|
+
fieldId,
|
|
50
|
+
};
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const addColumnButton = target.closest(`button[${tableButtons.addColumn.attr}]`);
|
|
55
|
+
if (addColumnButton) {
|
|
56
|
+
this._triggerRef.current = addColumnButton as HTMLElement;
|
|
57
|
+
this._state.value = {
|
|
58
|
+
type: 'columnSettings',
|
|
59
|
+
mode: { type: 'create' },
|
|
60
|
+
};
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return false;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
public openColumnSettings = () => {
|
|
68
|
+
if (this._state.value.type === 'column') {
|
|
69
|
+
const fieldId = this._state.value.fieldId;
|
|
70
|
+
// Queue next render to let the column action modal close completely.
|
|
71
|
+
requestAnimationFrame(() => {
|
|
72
|
+
this._state.value = {
|
|
73
|
+
type: 'columnSettings',
|
|
74
|
+
mode: { type: 'edit', fieldId },
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
public close = () => {
|
|
81
|
+
this._state.value = { type: 'closed' };
|
|
82
|
+
};
|
|
83
|
+
}
|