@dxos/react-ui-table 0.8.0 → 0.8.1-main.81238a8
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/{chunk-3FR6NHPD.mjs → chunk-5MKYB7NF.mjs} +5 -7
- package/dist/lib/browser/chunk-5MKYB7NF.mjs.map +7 -0
- package/dist/lib/browser/{_deprecated → deprecated}/index.mjs +26 -26
- package/dist/lib/{node-esm/_deprecated → browser/deprecated}/index.mjs.map +4 -4
- package/dist/lib/browser/index.mjs +289 -123
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node/{chunk-NB3SFHGA.cjs → chunk-NRFKBRPV.cjs} +7 -9
- package/dist/lib/node/chunk-NRFKBRPV.cjs.map +7 -0
- package/dist/lib/node/{_deprecated → deprecated}/index.cjs +5 -5
- package/dist/lib/node/{_deprecated → deprecated}/index.cjs.map +4 -4
- package/dist/lib/node/index.cjs +282 -120
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types/index.cjs +3 -3
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/{chunk-RLVVOZW5.mjs → chunk-SU4D55KI.mjs} +5 -7
- package/dist/lib/node-esm/chunk-SU4D55KI.mjs.map +7 -0
- package/dist/lib/node-esm/{_deprecated → deprecated}/index.mjs +26 -26
- package/dist/lib/node-esm/deprecated/index.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +289 -123
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts +2 -1
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts +2 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/CreateRefPanel.d.ts +2 -1
- package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +19 -0
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -0
- package/dist/types/src/components/Table/RefPanel.d.ts +2 -1
- package/dist/types/src/components/Table/RefPanel.d.ts.map +1 -1
- package/dist/types/src/components/Table/RowActionsMenu.d.ts +2 -1
- package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +6 -1
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +2 -1
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/index.d.ts +1 -0
- package/dist/types/src/components/Table/index.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +2 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +2 -1
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +14 -7
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/{_deprecated → deprecated}/components/Cell/Cell.d.ts +2 -2
- package/dist/types/src/deprecated/components/Cell/Cell.d.ts.map +1 -0
- package/dist/types/src/{_deprecated → deprecated}/components/Cell/CellCombobox.d.ts +2 -1
- 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 → deprecated}/components/ColumnMenu/ColumnMenu.d.ts +3 -2
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnMenu.d.ts.map +1 -0
- package/dist/types/src/{_deprecated → deprecated}/components/ColumnMenu/ColumnMenu.stories.d.ts +3 -2
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnMenu.stories.d.ts.map +1 -0
- package/dist/types/src/{_deprecated → deprecated}/components/ColumnMenu/ColumnSettings.d.ts +2 -1
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnSettings.d.ts.map +1 -0
- package/dist/types/src/{_deprecated → deprecated}/components/ColumnMenu/ColumnSettings.stories.d.ts +3 -2
- 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 → deprecated}/components/Table/Table.d.ts +5 -5
- package/dist/types/src/deprecated/components/Table/Table.d.ts.map +1 -0
- package/dist/types/src/{_deprecated → deprecated}/components/Table/Table.stories.d.ts +8 -7
- package/dist/types/src/deprecated/components/Table/Table.stories.d.ts.map +1 -0
- package/dist/types/src/{_deprecated → deprecated}/components/Table/TableBody.d.ts +2 -1
- package/dist/types/src/deprecated/components/Table/TableBody.d.ts.map +1 -0
- package/dist/types/src/{_deprecated → deprecated}/components/Table/TableContext.d.ts +1 -1
- package/dist/types/src/deprecated/components/Table/TableContext.d.ts.map +1 -0
- package/dist/types/src/{_deprecated → deprecated}/components/Table/TableHead.d.ts +2 -1
- 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.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.map +1 -0
- package/dist/types/src/deprecated/helpers.d.ts.map +1 -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/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.map +1 -0
- package/dist/types/src/{_deprecated → deprecated}/schema/Schema.stories.d.ts +2 -1
- package/dist/types/src/deprecated/schema/Schema.stories.d.ts.map +1 -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/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.map +1 -0
- package/dist/types/src/deprecated/types.d.ts.map +1 -0
- package/dist/types/src/hooks/useTableModel.d.ts +5 -2
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts +26 -7
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-sorting.d.ts.map +1 -1
- package/dist/types/src/types/table.d.ts +16 -21
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +40 -0
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -0
- package/dist/types/src/util/index.d.ts +1 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/package.json +35 -35
- package/src/components/Table/ColumnSettings.tsx +5 -6
- package/src/components/Table/CreateRefPanel.tsx +3 -3
- package/src/components/Table/DynamicTable.tsx +86 -0
- package/src/components/Table/RefPanel.tsx +3 -3
- package/src/components/Table/RowActionsMenu.tsx +13 -0
- package/src/components/Table/Table.stories.tsx +27 -2
- package/src/components/Table/Table.tsx +29 -10
- package/src/components/Table/index.ts +1 -0
- package/src/components/testing.ts +1 -0
- package/src/{_deprecated → deprecated}/components/Cell/Cell.tsx +2 -2
- package/src/{_deprecated → deprecated}/components/Table/TableBody.tsx +2 -2
- package/src/{_deprecated → deprecated}/helpers.tsx +2 -2
- package/src/{_deprecated → deprecated}/schema/Schema.stories.tsx +1 -1
- package/src/hooks/useTableModel.ts +22 -6
- package/src/model/table-model.test.ts +1 -1
- package/src/model/table-model.ts +76 -21
- package/src/model/table-presentation.test.ts +1 -1
- package/src/model/table-presentation.ts +3 -3
- package/src/model/table-sorting.ts +1 -0
- package/src/types/table.ts +5 -7
- package/src/util/dynamic-table.ts +71 -0
- package/src/util/index.ts +1 -0
- package/dist/lib/browser/_deprecated/index.mjs.map +0 -7
- package/dist/lib/browser/chunk-3FR6NHPD.mjs.map +0 -7
- package/dist/lib/node/chunk-NB3SFHGA.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-RLVVOZW5.mjs.map +0 -7
- package/dist/types/src/_deprecated/components/Cell/Cell.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Cell/CellCombobox.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Cell/index.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnMenu.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnMenu.stories.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnSettings.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnSettings.stories.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/ColumnMenu/index.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Table/Table.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Table/Table.stories.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Table/TableBody.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Table/TableContext.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Table/TableHead.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Table/TableRootContext.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Table/index.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Table/props.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/index.d.ts.map +0 -1
- package/dist/types/src/_deprecated/helpers.d.ts.map +0 -1
- package/dist/types/src/_deprecated/hooks/index.d.ts.map +0 -1
- package/dist/types/src/_deprecated/hooks/useColumnSizing.d.ts.map +0 -1
- package/dist/types/src/_deprecated/hooks/useColumnSorting.d.ts.map +0 -1
- package/dist/types/src/_deprecated/hooks/usePinLastRow.d.ts.map +0 -1
- package/dist/types/src/_deprecated/hooks/useRowSelection.d.ts.map +0 -1
- package/dist/types/src/_deprecated/index.d.ts.map +0 -1
- package/dist/types/src/_deprecated/schema/Schema.stories.d.ts.map +0 -1
- package/dist/types/src/_deprecated/schema/column-utils.d.ts.map +0 -1
- package/dist/types/src/_deprecated/schema/index.d.ts.map +0 -1
- package/dist/types/src/_deprecated/schema/types.d.ts.map +0 -1
- package/dist/types/src/_deprecated/theme.d.ts.map +0 -1
- package/dist/types/src/_deprecated/translations.d.ts.map +0 -1
- package/dist/types/src/_deprecated/types.d.ts.map +0 -1
- /package/dist/types/src/{_deprecated → deprecated}/components/Cell/index.d.ts +0 -0
- /package/dist/types/src/{_deprecated → deprecated}/components/ColumnMenu/index.d.ts +0 -0
- /package/dist/types/src/{_deprecated → deprecated}/components/Table/TableRootContext.d.ts +0 -0
- /package/dist/types/src/{_deprecated → deprecated}/components/Table/index.d.ts +0 -0
- /package/dist/types/src/{_deprecated → deprecated}/components/Table/props.d.ts +0 -0
- /package/dist/types/src/{_deprecated → deprecated}/components/index.d.ts +0 -0
- /package/dist/types/src/{_deprecated → deprecated}/helpers.d.ts +0 -0
- /package/dist/types/src/{_deprecated → deprecated}/hooks/index.d.ts +0 -0
- /package/dist/types/src/{_deprecated → deprecated}/hooks/useColumnSizing.d.ts +0 -0
- /package/dist/types/src/{_deprecated → deprecated}/hooks/useColumnSorting.d.ts +0 -0
- /package/dist/types/src/{_deprecated → deprecated}/hooks/usePinLastRow.d.ts +0 -0
- /package/dist/types/src/{_deprecated → deprecated}/hooks/useRowSelection.d.ts +0 -0
- /package/dist/types/src/{_deprecated → deprecated}/index.d.ts +0 -0
- /package/dist/types/src/{_deprecated → deprecated}/schema/column-utils.d.ts +0 -0
- /package/dist/types/src/{_deprecated → deprecated}/schema/index.d.ts +0 -0
- /package/dist/types/src/{_deprecated → deprecated}/schema/types.d.ts +0 -0
- /package/dist/types/src/{_deprecated → deprecated}/theme.d.ts +0 -0
- /package/dist/types/src/{_deprecated → deprecated}/translations.d.ts +0 -0
- /package/dist/types/src/{_deprecated → deprecated}/types.d.ts +0 -0
- /package/src/{_deprecated → deprecated}/components/Cell/CellCombobox.tsx +0 -0
- /package/src/{_deprecated → deprecated}/components/Cell/index.ts +0 -0
- /package/src/{_deprecated → deprecated}/components/ColumnMenu/ColumnMenu.stories.tsx +0 -0
- /package/src/{_deprecated → deprecated}/components/ColumnMenu/ColumnMenu.tsx +0 -0
- /package/src/{_deprecated → deprecated}/components/ColumnMenu/ColumnSettings.stories.tsx +0 -0
- /package/src/{_deprecated → deprecated}/components/ColumnMenu/ColumnSettings.tsx +0 -0
- /package/src/{_deprecated → deprecated}/components/ColumnMenu/index.ts +0 -0
- /package/src/{_deprecated → deprecated}/components/Table/Table.stories.tsx +0 -0
- /package/src/{_deprecated → deprecated}/components/Table/Table.tsx +0 -0
- /package/src/{_deprecated → deprecated}/components/Table/TableContext.tsx +0 -0
- /package/src/{_deprecated → deprecated}/components/Table/TableHead.tsx +0 -0
- /package/src/{_deprecated → deprecated}/components/Table/TableRootContext.ts +0 -0
- /package/src/{_deprecated → deprecated}/components/Table/index.ts +0 -0
- /package/src/{_deprecated → deprecated}/components/Table/props.ts +0 -0
- /package/src/{_deprecated → deprecated}/components/index.ts +0 -0
- /package/src/{_deprecated → deprecated}/hooks/index.ts +0 -0
- /package/src/{_deprecated → deprecated}/hooks/useColumnSizing.ts +0 -0
- /package/src/{_deprecated → deprecated}/hooks/useColumnSorting.ts +0 -0
- /package/src/{_deprecated → deprecated}/hooks/usePinLastRow.ts +0 -0
- /package/src/{_deprecated → deprecated}/hooks/useRowSelection.ts +0 -0
- /package/src/{_deprecated → deprecated}/index.ts +0 -0
- /package/src/{_deprecated → deprecated}/schema/column-utils.ts +0 -0
- /package/src/{_deprecated → deprecated}/schema/index.ts +0 -0
- /package/src/{_deprecated → deprecated}/schema/types.ts +0 -0
- /package/src/{_deprecated → deprecated}/theme.ts +0 -0
- /package/src/{_deprecated → deprecated}/translations.ts +0 -0
- /package/src/{_deprecated → deprecated}/types.ts +0 -0
package/dist/lib/node/index.cjs
CHANGED
|
@@ -30,14 +30,16 @@ var node_exports = {};
|
|
|
30
30
|
__export(node_exports, {
|
|
31
31
|
BUTTON_IDENTIFIERS: () => BUTTON_IDENTIFIERS,
|
|
32
32
|
CONTROL_IDENTIFIERS: () => CONTROL_IDENTIFIERS,
|
|
33
|
+
DynamicTable: () => DynamicTable,
|
|
33
34
|
ModalController: () => ModalController,
|
|
34
35
|
Table: () => Table,
|
|
35
36
|
TableModel: () => TableModel,
|
|
36
37
|
TablePresentation: () => TablePresentation,
|
|
37
|
-
TableSchema: () =>
|
|
38
|
+
TableSchema: () => import_chunk_NRFKBRPV.TableSchema,
|
|
38
39
|
TableToolbar: () => TableToolbar,
|
|
39
|
-
TableType: () =>
|
|
40
|
+
TableType: () => import_chunk_NRFKBRPV.TableType,
|
|
40
41
|
initializeTable: () => initializeTable,
|
|
42
|
+
makeDynamicTable: () => makeDynamicTable,
|
|
41
43
|
renderCheckbox: () => renderCheckbox,
|
|
42
44
|
renderSwitch: () => renderSwitch,
|
|
43
45
|
tableButtons: () => tableButtons,
|
|
@@ -47,7 +49,7 @@ __export(node_exports, {
|
|
|
47
49
|
useTableModel: () => useTableModel
|
|
48
50
|
});
|
|
49
51
|
module.exports = __toCommonJS(node_exports);
|
|
50
|
-
var
|
|
52
|
+
var import_chunk_NRFKBRPV = require("./chunk-NRFKBRPV.cjs");
|
|
51
53
|
var import_react = __toESM(require("react"));
|
|
52
54
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
53
55
|
var import_invariant = require("@dxos/invariant");
|
|
@@ -60,17 +62,15 @@ var import_util = require("@dxos/util");
|
|
|
60
62
|
var import_react2 = __toESM(require("react"));
|
|
61
63
|
var import_react_ui2 = require("@dxos/react-ui");
|
|
62
64
|
var import_react3 = __toESM(require("react"));
|
|
63
|
-
var import_echo2 = require("@dxos/react-client/echo");
|
|
64
65
|
var import_react_ui3 = require("@dxos/react-ui");
|
|
65
66
|
var import_react_ui_form = require("@dxos/react-ui-form");
|
|
66
67
|
var import_react4 = __toESM(require("react"));
|
|
67
68
|
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
68
|
-
var
|
|
69
|
+
var import_echo2 = require("@dxos/react-client/echo");
|
|
69
70
|
var import_react_ui4 = require("@dxos/react-ui");
|
|
70
71
|
var import_react_ui_form2 = require("@dxos/react-ui-form");
|
|
71
72
|
var import_react_ui_grid2 = require("@dxos/react-ui-grid");
|
|
72
73
|
var import_react5 = __toESM(require("react"));
|
|
73
|
-
var import_echo4 = require("@dxos/react-client/echo");
|
|
74
74
|
var import_react_ui5 = require("@dxos/react-ui");
|
|
75
75
|
var import_react_ui_form3 = require("@dxos/react-ui-form");
|
|
76
76
|
var import_react6 = __toESM(require("react"));
|
|
@@ -80,14 +80,15 @@ var import_context = require("@dxos/context");
|
|
|
80
80
|
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
81
81
|
var import_invariant2 = require("@dxos/invariant");
|
|
82
82
|
var import_live_object = require("@dxos/live-object");
|
|
83
|
-
var import_react_client = require("@dxos/react-client");
|
|
84
83
|
var import_react_ui_form4 = require("@dxos/react-ui-form");
|
|
85
84
|
var import_signals_core2 = require("@preact/signals-core");
|
|
86
85
|
var import_context2 = require("@dxos/context");
|
|
87
|
-
var
|
|
88
|
-
var import_react_client2 = require("@dxos/react-client");
|
|
89
|
-
var import_echo5 = require("@dxos/react-client/echo");
|
|
86
|
+
var import_live_object2 = require("@dxos/live-object");
|
|
90
87
|
var import_schema = require("@dxos/schema");
|
|
88
|
+
var import_echo_schema4 = require("@dxos/echo-schema");
|
|
89
|
+
var import_react_client = require("@dxos/react-client");
|
|
90
|
+
var import_echo3 = require("@dxos/react-client/echo");
|
|
91
|
+
var import_schema2 = require("@dxos/schema");
|
|
91
92
|
var import_signals_core3 = require("@preact/signals-core");
|
|
92
93
|
var import_lodash = __toESM(require("lodash.orderby"));
|
|
93
94
|
var import_echo_schema5 = require("@dxos/echo-schema");
|
|
@@ -99,7 +100,7 @@ var import_echo_schema6 = require("@dxos/echo-schema");
|
|
|
99
100
|
var import_react_ui_form6 = require("@dxos/react-ui-form");
|
|
100
101
|
var import_react_ui_grid3 = require("@dxos/react-ui-grid");
|
|
101
102
|
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
102
|
-
var
|
|
103
|
+
var import_schema3 = require("@dxos/schema");
|
|
103
104
|
var import_react7 = __toESM(require("react"));
|
|
104
105
|
var import_echo_schema7 = require("@dxos/echo-schema");
|
|
105
106
|
var import_invariant3 = require("@dxos/invariant");
|
|
@@ -107,12 +108,15 @@ var import_react_ui_grid4 = require("@dxos/react-ui-grid");
|
|
|
107
108
|
var import_autocomplete = require("@codemirror/autocomplete");
|
|
108
109
|
var import_view = require("@codemirror/view");
|
|
109
110
|
var import_react8 = __toESM(require("react"));
|
|
110
|
-
var
|
|
111
|
-
var import_react_ui_menu = require("@dxos/react-ui-menu");
|
|
111
|
+
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
112
112
|
var import_signals_core6 = require("@preact/signals-core");
|
|
113
113
|
var import_react9 = require("react");
|
|
114
|
+
var import_echo4 = require("@dxos/react-client/echo");
|
|
114
115
|
var import_react_ui_attention2 = require("@dxos/react-ui-attention");
|
|
115
116
|
var import_util2 = require("@dxos/util");
|
|
117
|
+
var import_react10 = __toESM(require("react"));
|
|
118
|
+
var import_live_object3 = require("@dxos/live-object");
|
|
119
|
+
var import_react_ui_menu = require("@dxos/react-ui-menu");
|
|
116
120
|
var translationKey = "table";
|
|
117
121
|
var translations_default = [
|
|
118
122
|
{
|
|
@@ -177,7 +181,7 @@ var ColumnActionsMenu = ({ model, modals }) => {
|
|
|
177
181
|
var ColumnSettings = ({ model, modals, onNewColumn }) => {
|
|
178
182
|
const [newField, setNewField] = (0, import_react3.useState)();
|
|
179
183
|
const state = modals.state.value;
|
|
180
|
-
const space =
|
|
184
|
+
const space = model?.space;
|
|
181
185
|
(0, import_react3.useEffect)(() => {
|
|
182
186
|
if (state?.type === "columnSettings" && state.mode.type === "create" && model?.projection) {
|
|
183
187
|
setNewField(model.projection.createFieldProjection());
|
|
@@ -195,12 +199,12 @@ var ColumnSettings = ({ model, modals, onNewColumn }) => {
|
|
|
195
199
|
if (state?.type === "columnSettings") {
|
|
196
200
|
const { mode } = state;
|
|
197
201
|
if (mode.type === "edit") {
|
|
198
|
-
return model?.
|
|
202
|
+
return model?.view?.fields.find((f) => f.id === mode.fieldId);
|
|
199
203
|
}
|
|
200
204
|
}
|
|
201
205
|
return void 0;
|
|
202
206
|
}, [
|
|
203
|
-
model?.
|
|
207
|
+
model?.view?.fields,
|
|
204
208
|
state
|
|
205
209
|
]);
|
|
206
210
|
const field = existingField ?? newField;
|
|
@@ -218,7 +222,7 @@ var ColumnSettings = ({ model, modals, onNewColumn }) => {
|
|
|
218
222
|
state,
|
|
219
223
|
newField
|
|
220
224
|
]);
|
|
221
|
-
if (!model?.
|
|
225
|
+
if (!model?.view || !model.projection || !field) {
|
|
222
226
|
return null;
|
|
223
227
|
}
|
|
224
228
|
return /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Root, {
|
|
@@ -229,7 +233,7 @@ var ColumnSettings = ({ model, modals, onNewColumn }) => {
|
|
|
229
233
|
}), /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Portal, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Content, {
|
|
230
234
|
classNames: "md:is-64"
|
|
231
235
|
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Viewport, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui_form.FieldEditor, {
|
|
232
|
-
view: model.
|
|
236
|
+
view: model.view,
|
|
233
237
|
projection: model.projection,
|
|
234
238
|
field,
|
|
235
239
|
registry: space?.db.schemaRegistry,
|
|
@@ -239,7 +243,7 @@ var ColumnSettings = ({ model, modals, onNewColumn }) => {
|
|
|
239
243
|
};
|
|
240
244
|
var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
241
245
|
const { id: gridId } = (0, import_react_ui_grid2.useGridContext)("TableCellEditor", __gridScope);
|
|
242
|
-
const space =
|
|
246
|
+
const space = model?.space;
|
|
243
247
|
const state = modals.state.value;
|
|
244
248
|
const schema = (0, import_react4.useMemo)(() => {
|
|
245
249
|
if (!space || state?.type !== "createRefPanel") {
|
|
@@ -264,7 +268,7 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
|
264
268
|
typename: state.typename
|
|
265
269
|
}).runSync();
|
|
266
270
|
if (schema2) {
|
|
267
|
-
const obj = space.db.add((0,
|
|
271
|
+
const obj = space.db.add((0, import_echo2.create)(schema2, values));
|
|
268
272
|
state.onCreate?.(obj);
|
|
269
273
|
}
|
|
270
274
|
void modals.close();
|
|
@@ -280,7 +284,7 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
|
280
284
|
}, [
|
|
281
285
|
modals
|
|
282
286
|
]);
|
|
283
|
-
if (!model?.
|
|
287
|
+
if (!model?.view || !model.projection) {
|
|
284
288
|
return null;
|
|
285
289
|
}
|
|
286
290
|
return /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Root, {
|
|
@@ -312,10 +316,10 @@ var getRefTargetObj = (space, id) => {
|
|
|
312
316
|
};
|
|
313
317
|
var RefPanel = ({ model, modals }) => {
|
|
314
318
|
const state = modals.state.value;
|
|
315
|
-
const space =
|
|
319
|
+
const space = model?.space;
|
|
316
320
|
const targetObj = getRefTargetObj(space, state?.type === "refPanel" ? state.targetId : void 0);
|
|
317
321
|
const schema = space && state?.type === "refPanel" ? space.db.schemaRegistry.getSchema(state.typename) : void 0;
|
|
318
|
-
if (!model.
|
|
322
|
+
if (!model.view || !model.projection) {
|
|
319
323
|
return null;
|
|
320
324
|
}
|
|
321
325
|
return /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Popover.Root, {
|
|
@@ -352,7 +356,65 @@ var RowActionsMenu = ({ model, modals }) => {
|
|
|
352
356
|
}), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Content, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Viewport, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Item, {
|
|
353
357
|
"data-testid": "row-menu-delete",
|
|
354
358
|
onClick: () => model.deleteRow(state.rowIndex)
|
|
355
|
-
}, t(hasSelection ? "bulk delete row label" : "delete row label"))
|
|
359
|
+
}, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Item, {
|
|
360
|
+
key: action.id,
|
|
361
|
+
"data-testid": `row-action-${action.id}`,
|
|
362
|
+
onClick: () => {
|
|
363
|
+
modals.close();
|
|
364
|
+
model.handleRowAction(action.id, state.rowIndex);
|
|
365
|
+
}
|
|
366
|
+
}, t(action.translationKey)))), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Arrow, null)));
|
|
367
|
+
};
|
|
368
|
+
var makeDynamicTable = (typename, properties) => {
|
|
369
|
+
const table = (0, import_live_object2.create)(import_chunk_NRFKBRPV.TableType, {
|
|
370
|
+
name: "dynamic-table"
|
|
371
|
+
});
|
|
372
|
+
const echoSchema = (0, import_schema.echoSchemaFromPropertyDefinitions)(typename, properties);
|
|
373
|
+
const propertyNames = properties.map((property) => property.name);
|
|
374
|
+
const view = (0, import_schema.createView)({
|
|
375
|
+
name: "dynamic-table",
|
|
376
|
+
typename: echoSchema.typename,
|
|
377
|
+
jsonSchema: echoSchema.jsonSchema,
|
|
378
|
+
fields: propertyNames
|
|
379
|
+
});
|
|
380
|
+
table.view = (0, import_live_object2.makeRef)(view);
|
|
381
|
+
const viewProjection = new import_schema.ViewProjection(echoSchema, view);
|
|
382
|
+
for (const property of properties) {
|
|
383
|
+
if (!view.fields) {
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
const field = view.fields.find((field2) => field2.path === property.name);
|
|
387
|
+
if (field) {
|
|
388
|
+
if (property.size !== void 0) {
|
|
389
|
+
field.size = property.size;
|
|
390
|
+
}
|
|
391
|
+
if (property.title !== void 0) {
|
|
392
|
+
const fieldProjection = viewProjection.getFieldProjection(field.id);
|
|
393
|
+
viewProjection.setFieldProjection({
|
|
394
|
+
...fieldProjection,
|
|
395
|
+
props: {
|
|
396
|
+
...fieldProjection.props,
|
|
397
|
+
title: property.title
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
if (property.sort) {
|
|
402
|
+
const fieldId = field.id;
|
|
403
|
+
view.query.sort = [
|
|
404
|
+
{
|
|
405
|
+
fieldId,
|
|
406
|
+
direction: property.sort
|
|
407
|
+
}
|
|
408
|
+
];
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return {
|
|
413
|
+
table,
|
|
414
|
+
schema: echoSchema,
|
|
415
|
+
view,
|
|
416
|
+
viewProjection
|
|
417
|
+
};
|
|
356
418
|
};
|
|
357
419
|
var touch = (value) => value;
|
|
358
420
|
var initializeTable = async ({ space, table, initialRow = true, initialSchema }) => {
|
|
@@ -363,8 +425,8 @@ var initializeTable = async ({ space, table, initialRow = true, initialSchema })
|
|
|
363
425
|
if (!schema) {
|
|
364
426
|
throw new Error(`Schema not found: ${initialSchema}`);
|
|
365
427
|
}
|
|
366
|
-
const fields = (0,
|
|
367
|
-
table.view = (0,
|
|
428
|
+
const fields = (0, import_schema2.getSchemaProperties)(schema.ast).filter((prop) => prop.format !== import_echo_schema4.FormatEnum.Ref).map((prop) => prop.name);
|
|
429
|
+
table.view = (0, import_echo3.makeRef)((0, import_schema2.createView)({
|
|
368
430
|
// TODO(ZaymonFC): Don't hardcode name?
|
|
369
431
|
name: "View",
|
|
370
432
|
typename: schema.typename,
|
|
@@ -374,7 +436,7 @@ var initializeTable = async ({ space, table, initialRow = true, initialSchema })
|
|
|
374
436
|
return schema;
|
|
375
437
|
} else {
|
|
376
438
|
const ContactSchema = (0, import_echo_schema4.TypedObject)({
|
|
377
|
-
typename: `example.com/type/${
|
|
439
|
+
typename: `example.com/type/${import_react_client.PublicKey.random().truncate()}`,
|
|
378
440
|
version: "0.1.0"
|
|
379
441
|
})({
|
|
380
442
|
name: import_echo_schema4.S.optional(import_echo_schema4.S.String).annotations({
|
|
@@ -389,7 +451,7 @@ var initializeTable = async ({ space, table, initialRow = true, initialSchema })
|
|
|
389
451
|
const [contactSchema] = await space.db.schemaRegistry.register([
|
|
390
452
|
ContactSchema
|
|
391
453
|
]);
|
|
392
|
-
table.view = (0,
|
|
454
|
+
table.view = (0, import_echo3.makeRef)((0, import_schema2.createView)({
|
|
393
455
|
name: "View",
|
|
394
456
|
typename: contactSchema.typename,
|
|
395
457
|
jsonSchema: contactSchema.jsonSchema,
|
|
@@ -400,7 +462,7 @@ var initializeTable = async ({ space, table, initialRow = true, initialSchema })
|
|
|
400
462
|
"active"
|
|
401
463
|
]
|
|
402
464
|
}));
|
|
403
|
-
const projection = new
|
|
465
|
+
const projection = new import_schema2.ViewProjection(contactSchema, table.view.target);
|
|
404
466
|
projection.setFieldProjection({
|
|
405
467
|
field: {
|
|
406
468
|
id: table.view.target.fields.find((f) => f.path === "salary").id,
|
|
@@ -417,7 +479,7 @@ var initializeTable = async ({ space, table, initialRow = true, initialSchema })
|
|
|
417
479
|
});
|
|
418
480
|
projection.setFieldProjection({
|
|
419
481
|
field: {
|
|
420
|
-
id: (0,
|
|
482
|
+
id: (0, import_schema2.createFieldId)(),
|
|
421
483
|
path: "manager",
|
|
422
484
|
referencePath: "name"
|
|
423
485
|
},
|
|
@@ -430,7 +492,7 @@ var initializeTable = async ({ space, table, initialRow = true, initialSchema })
|
|
|
430
492
|
}
|
|
431
493
|
});
|
|
432
494
|
if (initialRow) {
|
|
433
|
-
space.db.add((0,
|
|
495
|
+
space.db.add((0, import_echo3.create)(contactSchema, {}));
|
|
434
496
|
}
|
|
435
497
|
return contactSchema;
|
|
436
498
|
}
|
|
@@ -840,12 +902,11 @@ var TableSorting = class {
|
|
|
840
902
|
};
|
|
841
903
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/model/table-model.ts";
|
|
842
904
|
var TableModel = class extends import_context.Resource {
|
|
843
|
-
constructor({
|
|
905
|
+
constructor({ id, space, view, projection, sorting = [], pinnedRows = {
|
|
844
906
|
top: [],
|
|
845
907
|
bottom: []
|
|
846
|
-
}, onCellUpdate, onDeleteColumn, onDeleteRows, onInsertRow, onRowOrderChanged }) {
|
|
908
|
+
}, onCellUpdate, onDeleteColumn, onDeleteRows, onInsertRow, onRowOrderChanged, rowActions = [], onRowAction }) {
|
|
847
909
|
super();
|
|
848
|
-
this.id = `table-model-${import_react_client.PublicKey.random().truncate()}`;
|
|
849
910
|
this._visibleRange = (0, import_signals_core.signal)({
|
|
850
911
|
start: {
|
|
851
912
|
row: 0,
|
|
@@ -861,7 +922,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
861
922
|
this._rows.value = obj;
|
|
862
923
|
};
|
|
863
924
|
this.getRowCount = () => this._rows.value.length;
|
|
864
|
-
this.getColumnCount = () => this.
|
|
925
|
+
this.getColumnCount = () => this._view?.fields.length ?? 0;
|
|
865
926
|
this.insertRow = (rowIndex) => {
|
|
866
927
|
const row = rowIndex !== void 0 ? this._sorting.getDataIndex(rowIndex) : this._rows.value.length;
|
|
867
928
|
this._onInsertRow?.(row);
|
|
@@ -878,8 +939,18 @@ var TableModel = class extends import_context.Resource {
|
|
|
878
939
|
}
|
|
879
940
|
this._onDeleteRows?.(row, objectsToDelete);
|
|
880
941
|
};
|
|
942
|
+
this.handleRowAction = (actionId, rowIndex) => {
|
|
943
|
+
if (!this._onRowAction) {
|
|
944
|
+
return;
|
|
945
|
+
}
|
|
946
|
+
const row = this._sorting.getDataIndex(rowIndex);
|
|
947
|
+
const data = this._rows.value[row];
|
|
948
|
+
if (data) {
|
|
949
|
+
this._onRowAction(actionId, data);
|
|
950
|
+
}
|
|
951
|
+
};
|
|
881
952
|
this.getCellData = ({ col, row }) => {
|
|
882
|
-
const fields = this.
|
|
953
|
+
const fields = this._view?.fields ?? [];
|
|
883
954
|
if (col < 0 || col >= fields.length) {
|
|
884
955
|
return void 0;
|
|
885
956
|
}
|
|
@@ -908,7 +979,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
908
979
|
};
|
|
909
980
|
this.setCellData = ({ col, row }, value) => {
|
|
910
981
|
const rowIdx = this._sorting.getDataIndex(row);
|
|
911
|
-
const fields = this.
|
|
982
|
+
const fields = this._view?.fields ?? [];
|
|
912
983
|
if (col < 0 || col >= fields.length) {
|
|
913
984
|
return;
|
|
914
985
|
}
|
|
@@ -931,9 +1002,11 @@ var TableModel = class extends import_context.Resource {
|
|
|
931
1002
|
}
|
|
932
1003
|
}
|
|
933
1004
|
};
|
|
934
|
-
this.
|
|
1005
|
+
this._id = id;
|
|
1006
|
+
this._space = space;
|
|
1007
|
+
this._view = view;
|
|
935
1008
|
this._projection = projection;
|
|
936
|
-
this._sorting = new TableSorting(this._rows,
|
|
1009
|
+
this._sorting = new TableSorting(this._rows, this._view, projection);
|
|
937
1010
|
if (sorting.length > 0) {
|
|
938
1011
|
const [sort] = sorting;
|
|
939
1012
|
this._sorting.setSort(sort.fieldId, sort.direction);
|
|
@@ -944,9 +1017,17 @@ var TableModel = class extends import_context.Resource {
|
|
|
944
1017
|
this._onDeleteColumn = onDeleteColumn;
|
|
945
1018
|
this._onCellUpdate = onCellUpdate;
|
|
946
1019
|
this._onRowOrderChanged = onRowOrderChanged;
|
|
1020
|
+
this._rowActions = rowActions;
|
|
1021
|
+
this._onRowAction = onRowAction;
|
|
1022
|
+
}
|
|
1023
|
+
get id() {
|
|
1024
|
+
return this._id;
|
|
1025
|
+
}
|
|
1026
|
+
get space() {
|
|
1027
|
+
return this._space;
|
|
947
1028
|
}
|
|
948
|
-
get
|
|
949
|
-
return this.
|
|
1029
|
+
get view() {
|
|
1030
|
+
return this._view;
|
|
950
1031
|
}
|
|
951
1032
|
get projection() {
|
|
952
1033
|
return this._projection;
|
|
@@ -960,13 +1041,22 @@ var TableModel = class extends import_context.Resource {
|
|
|
960
1041
|
get sorting() {
|
|
961
1042
|
return this._sorting;
|
|
962
1043
|
}
|
|
1044
|
+
/**
|
|
1045
|
+
* Gets the row data at the specified display index.
|
|
1046
|
+
*/
|
|
1047
|
+
getRowAt(displayIndex) {
|
|
1048
|
+
if (displayIndex < 0 || displayIndex >= this._sorting.sortedRows.value.length) {
|
|
1049
|
+
return void 0;
|
|
1050
|
+
}
|
|
1051
|
+
return this._sorting.sortedRows.value[displayIndex];
|
|
1052
|
+
}
|
|
963
1053
|
get pinnedRows() {
|
|
964
1054
|
return this._pinnedRows;
|
|
965
1055
|
}
|
|
966
1056
|
get columnMeta() {
|
|
967
1057
|
(0, import_invariant2.invariant)(this._columnMeta, void 0, {
|
|
968
1058
|
F: __dxlog_file,
|
|
969
|
-
L:
|
|
1059
|
+
L: 155,
|
|
970
1060
|
S: this,
|
|
971
1061
|
A: [
|
|
972
1062
|
"this._columnMeta",
|
|
@@ -982,6 +1072,9 @@ var TableModel = class extends import_context.Resource {
|
|
|
982
1072
|
get isViewDirty() {
|
|
983
1073
|
return this._sorting.isDirty;
|
|
984
1074
|
}
|
|
1075
|
+
get rowActions() {
|
|
1076
|
+
return this._rowActions;
|
|
1077
|
+
}
|
|
985
1078
|
//
|
|
986
1079
|
// Initialisation
|
|
987
1080
|
//
|
|
@@ -993,7 +1086,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
993
1086
|
}
|
|
994
1087
|
initializeColumnMeta() {
|
|
995
1088
|
this._columnMeta = (0, import_signals_core.computed)(() => {
|
|
996
|
-
const fields = this.
|
|
1089
|
+
const fields = this._view?.fields ?? [];
|
|
997
1090
|
const meta = Object.fromEntries(fields.map((field, index) => [
|
|
998
1091
|
index,
|
|
999
1092
|
{
|
|
@@ -1030,7 +1123,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
1030
1123
|
for (let row = start.row; row <= end.row; row++) {
|
|
1031
1124
|
rowEffects.push((0, import_signals_core.effect)(() => {
|
|
1032
1125
|
const obj = this._sorting.sortedRows.value[row];
|
|
1033
|
-
this?.
|
|
1126
|
+
this._view?.fields.forEach((field) => touch((0, import_echo_schema3.getValue)(obj, field.path)));
|
|
1034
1127
|
this._onCellUpdate?.({
|
|
1035
1128
|
row,
|
|
1036
1129
|
col: start.col,
|
|
@@ -1049,7 +1142,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
1049
1142
|
*/
|
|
1050
1143
|
updateCellData({ col, row }, update) {
|
|
1051
1144
|
const dataRow = this._sorting.getDataIndex(row);
|
|
1052
|
-
const fields = this.
|
|
1145
|
+
const fields = this._view?.fields ?? [];
|
|
1053
1146
|
const field = fields[col];
|
|
1054
1147
|
const value = (0, import_echo_schema3.getValue)(this._rows.value[dataRow], field.path);
|
|
1055
1148
|
const updatedValue = update(value);
|
|
@@ -1059,10 +1152,10 @@ var TableModel = class extends import_context.Resource {
|
|
|
1059
1152
|
// Column Operations
|
|
1060
1153
|
//
|
|
1061
1154
|
deleteColumn(fieldId) {
|
|
1062
|
-
if (!this.
|
|
1155
|
+
if (!this._view) {
|
|
1063
1156
|
return;
|
|
1064
1157
|
}
|
|
1065
|
-
const field = this.
|
|
1158
|
+
const field = this._view?.fields.find((field2) => field2.id === fieldId);
|
|
1066
1159
|
if (field && this._onDeleteColumn) {
|
|
1067
1160
|
this._onDeleteColumn(field.id);
|
|
1068
1161
|
}
|
|
@@ -1071,7 +1164,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
1071
1164
|
// Resize
|
|
1072
1165
|
//
|
|
1073
1166
|
setColumnWidth(columnIndex, width) {
|
|
1074
|
-
const fields = this.
|
|
1167
|
+
const fields = this._view?.fields ?? [];
|
|
1075
1168
|
if (columnIndex < fields.length) {
|
|
1076
1169
|
const newWidth = Math.max(0, width);
|
|
1077
1170
|
const field = fields[columnIndex];
|
|
@@ -1217,7 +1310,7 @@ var TablePresentation = class {
|
|
|
1217
1310
|
}
|
|
1218
1311
|
getMainGridCells(range) {
|
|
1219
1312
|
const cells = {};
|
|
1220
|
-
const fields = this.model.
|
|
1313
|
+
const fields = this.model.view?.fields ?? [];
|
|
1221
1314
|
const addCell = (obj, field, colIndex, displayIndex) => {
|
|
1222
1315
|
const { props } = this.model.projection.getFieldProjection(field.id);
|
|
1223
1316
|
const cell = {
|
|
@@ -1309,7 +1402,7 @@ var TablePresentation = class {
|
|
|
1309
1402
|
}
|
|
1310
1403
|
getHeaderCells(range) {
|
|
1311
1404
|
const cells = {};
|
|
1312
|
-
const fields = this.model.
|
|
1405
|
+
const fields = this.model.view?.fields ?? [];
|
|
1313
1406
|
for (let col = range.start.col; col <= range.end.col && col < fields.length; col++) {
|
|
1314
1407
|
const { field, props } = this.model.projection.getFieldProjection(fields[col].id);
|
|
1315
1408
|
const sorting = this.model.sorting?.sorting;
|
|
@@ -1399,7 +1492,7 @@ var TablePresentation = class {
|
|
|
1399
1492
|
row: 0
|
|
1400
1493
|
})]: {
|
|
1401
1494
|
accessoryHtml: tableButtons.addColumn.render({
|
|
1402
|
-
disabled: (this.model.
|
|
1495
|
+
disabled: (this.model.view?.fields?.length ?? 0) >= import_schema3.VIEW_FIELD_LIMIT
|
|
1403
1496
|
}),
|
|
1404
1497
|
className: "!bg-gridHeader",
|
|
1405
1498
|
readonly: true,
|
|
@@ -1612,22 +1705,27 @@ var determineNavigationDelta = ({ key, shift }) => {
|
|
|
1612
1705
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
|
|
1613
1706
|
var inlineEndLine = "[&>.dx-grid]:relative [&>.dx-grid]:after:absolute [&>.dx-grid]:after:inset-block-0 [&>.dx-grid]:after:-inline-end-px [&>.dx-grid]:after:is-px [&>.dx-grid]:after:bg-separator";
|
|
1614
1707
|
var blockEndLine = "[&>.dx-grid]:before:absolute [&>.dx-grid]:before:inset-inline-0 [&>.dx-grid]:before:-block-end-px [&>.dx-grid]:before:bs-px [&>.dx-grid]:before:bg-separator";
|
|
1615
|
-
var frozen = {
|
|
1616
|
-
frozenRowsStart: 1,
|
|
1617
|
-
frozenColsStart: 1,
|
|
1618
|
-
frozenColsEnd: 1
|
|
1619
|
-
};
|
|
1620
1708
|
var TableRoot = ({ children, role }) => {
|
|
1621
1709
|
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
1622
1710
|
role: "none",
|
|
1623
1711
|
className: (0, import_react_ui_theme.mx)("relative border-bs !border-separator", role === "section" ? "attention-surface overflow-hidden [&_.dx-grid]:max-is-[--dx-grid-content-inline-size]" : "flex flex-col [&_.dx-grid]:grow [&_.dx-grid]:max-is-[--dx-grid-content-inline-size] [&_.dx-grid]:bs-0 [&_.dx-grid]:max-bs-[--dx-grid-content-block-size]")
|
|
1624
1712
|
}, children);
|
|
1625
1713
|
};
|
|
1626
|
-
var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentation, ignoreAttention }, forwardedRef) => {
|
|
1714
|
+
var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentation, ignoreAttention, onRowClicked, features }, forwardedRef) => {
|
|
1627
1715
|
const [dxGrid, setDxGrid] = (0, import_react.useState)(null);
|
|
1628
|
-
const { hasAttention } = (0, import_react_ui_attention.useAttention)(model?.
|
|
1716
|
+
const { hasAttention } = (0, import_react_ui_attention.useAttention)(model?.id ?? "table");
|
|
1629
1717
|
const { t } = (0, import_react_ui.useTranslation)(translationKey);
|
|
1630
1718
|
const modals = (0, import_react.useMemo)(() => new ModalController(), []);
|
|
1719
|
+
const { selection } = (0, import_react_ui.useDefaultValue)(features, () => ({
|
|
1720
|
+
selection: true
|
|
1721
|
+
}));
|
|
1722
|
+
const frozen = (0, import_react.useMemo)(() => ({
|
|
1723
|
+
frozenRowsStart: 1,
|
|
1724
|
+
frozenColsStart: selection ? 1 : 0,
|
|
1725
|
+
frozenColsEnd: 1
|
|
1726
|
+
}), [
|
|
1727
|
+
selection
|
|
1728
|
+
]);
|
|
1631
1729
|
(0, import_react.useImperativeHandle)(forwardedRef, () => {
|
|
1632
1730
|
if (!presentation || !dxGrid) {
|
|
1633
1731
|
return {};
|
|
@@ -1648,6 +1746,13 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
1648
1746
|
dxGrid
|
|
1649
1747
|
]);
|
|
1650
1748
|
const handleGridClick = (0, import_react.useCallback)((event) => {
|
|
1749
|
+
if (onRowClicked) {
|
|
1750
|
+
const rowIndex = (0, import_util.safeParseInt)(event.target.ariaRowIndex ?? "");
|
|
1751
|
+
if (rowIndex != null) {
|
|
1752
|
+
const row = model?.getRowAt(rowIndex);
|
|
1753
|
+
row && onRowClicked(row);
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1651
1756
|
if (!modals) {
|
|
1652
1757
|
return;
|
|
1653
1758
|
}
|
|
@@ -1779,10 +1884,10 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
1779
1884
|
]);
|
|
1780
1885
|
const handleQuery = (0, import_react.useCallback)(async ({ field, props }, text) => {
|
|
1781
1886
|
if (model && props.referenceSchema && field.referencePath) {
|
|
1782
|
-
const space =
|
|
1887
|
+
const space = model.space;
|
|
1783
1888
|
(0, import_invariant.invariant)(space, void 0, {
|
|
1784
1889
|
F: __dxlog_file4,
|
|
1785
|
-
L:
|
|
1890
|
+
L: 283,
|
|
1786
1891
|
S: void 0,
|
|
1787
1892
|
A: [
|
|
1788
1893
|
"space",
|
|
@@ -1824,7 +1929,7 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
1824
1929
|
});
|
|
1825
1930
|
}
|
|
1826
1931
|
return /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Root, {
|
|
1827
|
-
id: model.
|
|
1932
|
+
id: model.id ?? "table-grid"
|
|
1828
1933
|
}, /* @__PURE__ */ import_react.default.createElement(TableCellEditor, {
|
|
1829
1934
|
model,
|
|
1830
1935
|
modals,
|
|
@@ -1837,7 +1942,7 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
1837
1942
|
frozen,
|
|
1838
1943
|
columns: model.columnMeta.value,
|
|
1839
1944
|
limitRows: model.getRowCount() ?? 0,
|
|
1840
|
-
limitColumns: model.
|
|
1945
|
+
limitColumns: model.view?.fields?.length ?? 0,
|
|
1841
1946
|
onAxisResize: handleAxisResize,
|
|
1842
1947
|
onClick: handleGridClick,
|
|
1843
1948
|
onKeyDown: handleKeyDown,
|
|
@@ -1865,6 +1970,115 @@ var Table = {
|
|
|
1865
1970
|
Root: TableRoot,
|
|
1866
1971
|
Main: TableMain
|
|
1867
1972
|
};
|
|
1973
|
+
var useTableModel = ({ objects, table, projection, onSelectionChanged, rowActions, onRowAction, ...props }) => {
|
|
1974
|
+
const [model, setModel] = (0, import_react9.useState)();
|
|
1975
|
+
(0, import_react9.useEffect)(() => {
|
|
1976
|
+
if (!table || !projection) {
|
|
1977
|
+
return;
|
|
1978
|
+
}
|
|
1979
|
+
let model2;
|
|
1980
|
+
const t = setTimeout(async () => {
|
|
1981
|
+
model2 = new TableModel({
|
|
1982
|
+
id: (0, import_echo4.fullyQualifiedId)(table),
|
|
1983
|
+
space: (0, import_echo4.getSpace)(table),
|
|
1984
|
+
view: table.view?.target,
|
|
1985
|
+
projection,
|
|
1986
|
+
rowActions,
|
|
1987
|
+
onRowAction,
|
|
1988
|
+
...props
|
|
1989
|
+
});
|
|
1990
|
+
await model2.open();
|
|
1991
|
+
setModel(model2);
|
|
1992
|
+
});
|
|
1993
|
+
return () => {
|
|
1994
|
+
clearTimeout(t);
|
|
1995
|
+
void model2?.close();
|
|
1996
|
+
};
|
|
1997
|
+
}, [
|
|
1998
|
+
table,
|
|
1999
|
+
projection,
|
|
2000
|
+
table?.view?.target,
|
|
2001
|
+
rowActions
|
|
2002
|
+
]);
|
|
2003
|
+
(0, import_react9.useEffect)(() => {
|
|
2004
|
+
if (objects) {
|
|
2005
|
+
model?.setRows(objects);
|
|
2006
|
+
}
|
|
2007
|
+
}, [
|
|
2008
|
+
model,
|
|
2009
|
+
objects
|
|
2010
|
+
]);
|
|
2011
|
+
const { select, clear } = (0, import_react_ui_attention2.useSelectionActions)([
|
|
2012
|
+
table?.id,
|
|
2013
|
+
table?.view?.target?.query.typename
|
|
2014
|
+
].filter(import_util2.isNonNullable));
|
|
2015
|
+
(0, import_react9.useEffect)(() => {
|
|
2016
|
+
if (!model) {
|
|
2017
|
+
return;
|
|
2018
|
+
}
|
|
2019
|
+
const unsubscribe = (0, import_signals_core6.effect)(() => {
|
|
2020
|
+
const selectedItems = [
|
|
2021
|
+
...model.selection.selection.value
|
|
2022
|
+
];
|
|
2023
|
+
select(selectedItems);
|
|
2024
|
+
onSelectionChanged?.(selectedItems);
|
|
2025
|
+
});
|
|
2026
|
+
return () => {
|
|
2027
|
+
clear();
|
|
2028
|
+
unsubscribe();
|
|
2029
|
+
};
|
|
2030
|
+
}, [
|
|
2031
|
+
model,
|
|
2032
|
+
onSelectionChanged
|
|
2033
|
+
]);
|
|
2034
|
+
return model;
|
|
2035
|
+
};
|
|
2036
|
+
var DynamicTable = ({ data, properties, classNames, tableName = "com.example/dynamic_table", onRowClicked, rowActions, onRowAction }) => {
|
|
2037
|
+
const { table, viewProjection } = (0, import_react8.useMemo)(() => {
|
|
2038
|
+
return makeDynamicTable(tableName, properties);
|
|
2039
|
+
}, [
|
|
2040
|
+
tableName,
|
|
2041
|
+
properties
|
|
2042
|
+
]);
|
|
2043
|
+
const tableRef = (0, import_react8.useRef)(null);
|
|
2044
|
+
const handleCellUpdate = (0, import_react8.useCallback)((cell) => {
|
|
2045
|
+
tableRef.current?.update?.(cell);
|
|
2046
|
+
}, []);
|
|
2047
|
+
const handleRowOrderChanged = (0, import_react8.useCallback)(() => {
|
|
2048
|
+
tableRef.current?.update?.();
|
|
2049
|
+
}, []);
|
|
2050
|
+
const model = useTableModel({
|
|
2051
|
+
table,
|
|
2052
|
+
objects: data,
|
|
2053
|
+
projection: viewProjection,
|
|
2054
|
+
onCellUpdate: handleCellUpdate,
|
|
2055
|
+
onRowOrderChanged: handleRowOrderChanged,
|
|
2056
|
+
rowActions,
|
|
2057
|
+
onRowAction
|
|
2058
|
+
});
|
|
2059
|
+
const presentation = (0, import_react8.useMemo)(() => {
|
|
2060
|
+
if (model) {
|
|
2061
|
+
return new TablePresentation(model);
|
|
2062
|
+
}
|
|
2063
|
+
}, [
|
|
2064
|
+
model
|
|
2065
|
+
]);
|
|
2066
|
+
const features = (0, import_react8.useMemo)(() => ({
|
|
2067
|
+
selection: false
|
|
2068
|
+
}), []);
|
|
2069
|
+
return /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
2070
|
+
className: (0, import_react_ui_theme3.mx)("is-full bs-full grow grid", classNames)
|
|
2071
|
+
}, /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
2072
|
+
className: "grid min-bs-0 overflow-hidden"
|
|
2073
|
+
}, /* @__PURE__ */ import_react8.default.createElement(Table.Root, null, /* @__PURE__ */ import_react8.default.createElement(Table.Main, {
|
|
2074
|
+
ref: tableRef,
|
|
2075
|
+
model,
|
|
2076
|
+
presentation,
|
|
2077
|
+
features,
|
|
2078
|
+
onRowClicked,
|
|
2079
|
+
ignoreAttention: true
|
|
2080
|
+
}))));
|
|
2081
|
+
};
|
|
1868
2082
|
var createTableToolbarActions = (state) => {
|
|
1869
2083
|
const add = (0, import_react_ui_menu.createMenuAction)("add-row", {
|
|
1870
2084
|
type: "add-row",
|
|
@@ -1917,79 +2131,26 @@ var createTableToolbarActions = (state) => {
|
|
|
1917
2131
|
};
|
|
1918
2132
|
};
|
|
1919
2133
|
var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
|
|
1920
|
-
const state = (0,
|
|
2134
|
+
const state = (0, import_react10.useMemo)(() => (0, import_live_object3.create)({
|
|
1921
2135
|
viewDirty
|
|
1922
2136
|
}), []);
|
|
1923
|
-
const actionsCreator = (0,
|
|
2137
|
+
const actionsCreator = (0, import_react10.useCallback)(() => createTableToolbarActions(state), [
|
|
1924
2138
|
state
|
|
1925
2139
|
]);
|
|
1926
2140
|
const menu = (0, import_react_ui_menu.useMenuActions)(actionsCreator);
|
|
1927
|
-
return /* @__PURE__ */
|
|
2141
|
+
return /* @__PURE__ */ import_react10.default.createElement(import_react_ui_menu.MenuProvider, {
|
|
1928
2142
|
...menu,
|
|
1929
2143
|
attendableId,
|
|
1930
2144
|
onAction
|
|
1931
|
-
}, /* @__PURE__ */
|
|
2145
|
+
}, /* @__PURE__ */ import_react10.default.createElement(import_react_ui_menu.ToolbarMenu, {
|
|
1932
2146
|
classNames
|
|
1933
2147
|
}));
|
|
1934
2148
|
};
|
|
1935
|
-
var useTableModel = ({ objects, table, projection, ...props }) => {
|
|
1936
|
-
const [model, setModel] = (0, import_react9.useState)();
|
|
1937
|
-
(0, import_react9.useEffect)(() => {
|
|
1938
|
-
if (!table || !projection) {
|
|
1939
|
-
return;
|
|
1940
|
-
}
|
|
1941
|
-
let model2;
|
|
1942
|
-
const t = setTimeout(async () => {
|
|
1943
|
-
model2 = new TableModel({
|
|
1944
|
-
table,
|
|
1945
|
-
projection,
|
|
1946
|
-
...props
|
|
1947
|
-
});
|
|
1948
|
-
await model2.open();
|
|
1949
|
-
setModel(model2);
|
|
1950
|
-
});
|
|
1951
|
-
return () => {
|
|
1952
|
-
clearTimeout(t);
|
|
1953
|
-
void model2?.close();
|
|
1954
|
-
};
|
|
1955
|
-
}, [
|
|
1956
|
-
table,
|
|
1957
|
-
projection
|
|
1958
|
-
]);
|
|
1959
|
-
(0, import_react9.useEffect)(() => {
|
|
1960
|
-
if (objects) {
|
|
1961
|
-
model?.setRows(objects);
|
|
1962
|
-
}
|
|
1963
|
-
}, [
|
|
1964
|
-
model,
|
|
1965
|
-
objects
|
|
1966
|
-
]);
|
|
1967
|
-
const { select, clear } = (0, import_react_ui_attention2.useSelectionActions)([
|
|
1968
|
-
table?.id,
|
|
1969
|
-
table?.view?.target?.query.typename
|
|
1970
|
-
].filter(import_util2.isNonNullable));
|
|
1971
|
-
(0, import_react9.useEffect)(() => {
|
|
1972
|
-
if (!model) {
|
|
1973
|
-
return;
|
|
1974
|
-
}
|
|
1975
|
-
const unsubscribe = (0, import_signals_core6.effect)(() => {
|
|
1976
|
-
select([
|
|
1977
|
-
...model.selection.selection.value
|
|
1978
|
-
]);
|
|
1979
|
-
});
|
|
1980
|
-
return () => {
|
|
1981
|
-
clear();
|
|
1982
|
-
unsubscribe();
|
|
1983
|
-
};
|
|
1984
|
-
}, [
|
|
1985
|
-
model
|
|
1986
|
-
]);
|
|
1987
|
-
return model;
|
|
1988
|
-
};
|
|
1989
2149
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1990
2150
|
0 && (module.exports = {
|
|
1991
2151
|
BUTTON_IDENTIFIERS,
|
|
1992
2152
|
CONTROL_IDENTIFIERS,
|
|
2153
|
+
DynamicTable,
|
|
1993
2154
|
ModalController,
|
|
1994
2155
|
Table,
|
|
1995
2156
|
TableModel,
|
|
@@ -1998,6 +2159,7 @@ var useTableModel = ({ objects, table, projection, ...props }) => {
|
|
|
1998
2159
|
TableToolbar,
|
|
1999
2160
|
TableType,
|
|
2000
2161
|
initializeTable,
|
|
2162
|
+
makeDynamicTable,
|
|
2001
2163
|
renderCheckbox,
|
|
2002
2164
|
renderSwitch,
|
|
2003
2165
|
tableButtons,
|