@dxos/react-ui-table 0.8.1-staging.5be625a → 0.8.1-staging.97aedb1
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-5MKYB7NF.mjs → chunk-YWNRUF4J.mjs} +7 -3
- package/dist/lib/browser/{chunk-5MKYB7NF.mjs.map → chunk-YWNRUF4J.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +295 -97
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node/{chunk-NRFKBRPV.cjs → chunk-TGG6OZ54.cjs} +10 -6
- package/dist/lib/node/{chunk-NRFKBRPV.cjs.map → chunk-TGG6OZ54.cjs.map} +3 -3
- package/dist/lib/node/index.cjs +293 -93
- package/dist/lib/node/index.cjs.map +3 -3
- 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-SU4D55KI.mjs → chunk-KKLP54L3.mjs} +7 -3
- package/dist/lib/node-esm/{chunk-SU4D55KI.mjs.map → chunk-KKLP54L3.mjs.map} +3 -3
- package/dist/lib/node-esm/index.mjs +295 -97
- package/dist/lib/node-esm/index.mjs.map +3 -3
- 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/DynamicTable.d.ts +15 -10
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +10 -0
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -0
- package/dist/types/src/components/Table/Table.d.ts +1 -1
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +2 -3
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/relations.stories.d.ts +9 -0
- package/dist/types/src/components/Table/relations.stories.d.ts.map +1 -0
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts +6 -10
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/index.d.ts +1 -0
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/selection-model.d.ts +6 -3
- package/dist/types/src/model/selection-model.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts +13 -14
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts +4 -4
- package/dist/types/src/model/table-presentation.d.ts.map +1 -1
- package/dist/types/src/model/table-sorting.d.ts +2 -2
- package/dist/types/src/model/table-sorting.d.ts.map +1 -1
- package/dist/types/src/types/table.d.ts +2 -1
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +21 -30
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/table-controls.d.ts +2 -2
- package/dist/types/src/util/table-controls.d.ts.map +1 -1
- package/dist/types/src/util/table.d.ts.map +1 -1
- package/package.json +33 -32
- package/src/components/Table/DynamicTable.stories.tsx +155 -0
- package/src/components/Table/DynamicTable.tsx +46 -28
- package/src/components/Table/Table.stories.tsx +129 -125
- package/src/components/Table/Table.tsx +51 -26
- package/src/components/Table/relations.stories.tsx +113 -0
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +8 -3
- package/src/components/TableCellEditor/TableCellEditor.tsx +102 -4
- package/src/components/testing.ts +0 -1
- package/src/hooks/useTableModel.ts +11 -11
- package/src/model/index.ts +1 -0
- package/src/model/selection-model.ts +12 -2
- package/src/model/table-model.test.ts +1 -1
- package/src/model/table-model.ts +27 -18
- package/src/model/table-presentation.test.ts +1 -1
- package/src/model/table-presentation.ts +65 -11
- package/src/model/table-sorting.ts +2 -2
- package/src/playwright/smoke.spec.ts +2 -3
- package/src/types/table.ts +6 -5
- package/src/util/dynamic-table.ts +57 -25
- package/src/util/table-controls.ts +4 -4
- package/src/util/table.ts +2 -1
- package/dist/lib/browser/deprecated/index.mjs +0 -1483
- package/dist/lib/browser/deprecated/index.mjs.map +0 -7
- package/dist/lib/node/deprecated/index.cjs +0 -1511
- package/dist/lib/node/deprecated/index.cjs.map +0 -7
- package/dist/lib/node-esm/deprecated/index.mjs +0 -1485
- package/dist/lib/node-esm/deprecated/index.mjs.map +0 -7
- package/dist/types/src/deprecated/components/Cell/Cell.d.ts +0 -12
- package/dist/types/src/deprecated/components/Cell/Cell.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Cell/CellCombobox.d.ts +0 -13
- package/dist/types/src/deprecated/components/Cell/CellCombobox.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Cell/index.d.ts +0 -2
- package/dist/types/src/deprecated/components/Cell/index.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnMenu.d.ts +0 -23
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnMenu.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnMenu.stories.d.ts +0 -36
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnMenu.stories.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnSettings.d.ts +0 -15
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnSettings.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnSettings.stories.d.ts +0 -84
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnSettings.stories.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/ColumnMenu/index.d.ts +0 -3
- package/dist/types/src/deprecated/components/ColumnMenu/index.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Table/Table.d.ts +0 -20
- package/dist/types/src/deprecated/components/Table/Table.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Table/Table.stories.d.ts +0 -116
- package/dist/types/src/deprecated/components/Table/Table.stories.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Table/TableBody.d.ts +0 -12
- package/dist/types/src/deprecated/components/Table/TableBody.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Table/TableContext.d.ts +0 -13
- package/dist/types/src/deprecated/components/Table/TableContext.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Table/TableHead.d.ts +0 -9
- package/dist/types/src/deprecated/components/Table/TableHead.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Table/TableRootContext.d.ts +0 -17
- package/dist/types/src/deprecated/components/Table/TableRootContext.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Table/index.d.ts +0 -5
- package/dist/types/src/deprecated/components/Table/index.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Table/props.d.ts +0 -42
- package/dist/types/src/deprecated/components/Table/props.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/index.d.ts +0 -4
- package/dist/types/src/deprecated/components/index.d.ts.map +0 -1
- package/dist/types/src/deprecated/helpers.d.ts +0 -91
- package/dist/types/src/deprecated/helpers.d.ts.map +0 -1
- package/dist/types/src/deprecated/hooks/index.d.ts +0 -5
- package/dist/types/src/deprecated/hooks/index.d.ts.map +0 -1
- package/dist/types/src/deprecated/hooks/useColumnSizing.d.ts +0 -12
- package/dist/types/src/deprecated/hooks/useColumnSizing.d.ts.map +0 -1
- package/dist/types/src/deprecated/hooks/useColumnSorting.d.ts +0 -15
- package/dist/types/src/deprecated/hooks/useColumnSorting.d.ts.map +0 -1
- package/dist/types/src/deprecated/hooks/usePinLastRow.d.ts +0 -3
- package/dist/types/src/deprecated/hooks/usePinLastRow.d.ts.map +0 -1
- package/dist/types/src/deprecated/hooks/useRowSelection.d.ts +0 -7
- package/dist/types/src/deprecated/hooks/useRowSelection.d.ts.map +0 -1
- package/dist/types/src/deprecated/index.d.ts +0 -8
- package/dist/types/src/deprecated/index.d.ts.map +0 -1
- package/dist/types/src/deprecated/schema/Schema.stories.d.ts +0 -11
- package/dist/types/src/deprecated/schema/Schema.stories.d.ts.map +0 -1
- package/dist/types/src/deprecated/schema/column-utils.d.ts +0 -7
- package/dist/types/src/deprecated/schema/column-utils.d.ts.map +0 -1
- package/dist/types/src/deprecated/schema/index.d.ts +0 -3
- package/dist/types/src/deprecated/schema/index.d.ts.map +0 -1
- package/dist/types/src/deprecated/schema/types.d.ts +0 -27
- package/dist/types/src/deprecated/schema/types.d.ts.map +0 -1
- package/dist/types/src/deprecated/theme.d.ts +0 -29
- package/dist/types/src/deprecated/theme.d.ts.map +0 -1
- package/dist/types/src/deprecated/translations.d.ts +0 -21
- package/dist/types/src/deprecated/translations.d.ts.map +0 -1
- package/dist/types/src/deprecated/types.d.ts +0 -26
- package/dist/types/src/deprecated/types.d.ts.map +0 -1
- package/src/deprecated/components/Cell/Cell.tsx +0 -88
- package/src/deprecated/components/Cell/CellCombobox.tsx +0 -103
- package/src/deprecated/components/Cell/index.ts +0 -5
- package/src/deprecated/components/ColumnMenu/ColumnMenu.stories.tsx +0 -129
- package/src/deprecated/components/ColumnMenu/ColumnMenu.tsx +0 -182
- package/src/deprecated/components/ColumnMenu/ColumnSettings.stories.tsx +0 -108
- package/src/deprecated/components/ColumnMenu/ColumnSettings.tsx +0 -207
- package/src/deprecated/components/ColumnMenu/index.ts +0 -6
- package/src/deprecated/components/Table/Table.stories.tsx +0 -508
- package/src/deprecated/components/Table/Table.tsx +0 -301
- package/src/deprecated/components/Table/TableBody.tsx +0 -82
- package/src/deprecated/components/Table/TableContext.tsx +0 -34
- package/src/deprecated/components/Table/TableHead.tsx +0 -78
- package/src/deprecated/components/Table/TableRootContext.ts +0 -39
- package/src/deprecated/components/Table/index.ts +0 -8
- package/src/deprecated/components/Table/props.ts +0 -60
- package/src/deprecated/components/index.ts +0 -7
- package/src/deprecated/helpers.tsx +0 -526
- package/src/deprecated/hooks/index.ts +0 -8
- package/src/deprecated/hooks/useColumnSizing.ts +0 -46
- package/src/deprecated/hooks/useColumnSorting.ts +0 -64
- package/src/deprecated/hooks/usePinLastRow.ts +0 -47
- package/src/deprecated/hooks/useRowSelection.ts +0 -40
- package/src/deprecated/index.ts +0 -12
- package/src/deprecated/schema/Schema.stories.tsx +0 -59
- package/src/deprecated/schema/column-utils.ts +0 -54
- package/src/deprecated/schema/index.ts +0 -6
- package/src/deprecated/schema/types.ts +0 -40
- package/src/deprecated/theme.ts +0 -82
- package/src/deprecated/translations.ts +0 -26
- package/src/deprecated/types.ts +0 -38
package/dist/lib/node/index.cjs
CHANGED
|
@@ -30,18 +30,20 @@ var node_exports = {};
|
|
|
30
30
|
__export(node_exports, {
|
|
31
31
|
BUTTON_IDENTIFIERS: () => BUTTON_IDENTIFIERS,
|
|
32
32
|
CONTROL_IDENTIFIERS: () => CONTROL_IDENTIFIERS,
|
|
33
|
+
CheckboxStory: () => CheckboxStory,
|
|
33
34
|
DynamicTable: () => DynamicTable,
|
|
34
35
|
ModalController: () => ModalController,
|
|
36
|
+
SwitchStory: () => SwitchStory,
|
|
35
37
|
Table: () => Table,
|
|
36
38
|
TableModel: () => TableModel,
|
|
37
39
|
TablePresentation: () => TablePresentation,
|
|
38
|
-
TableSchema: () =>
|
|
40
|
+
TableSchema: () => import_chunk_TGG6OZ54.TableSchema,
|
|
39
41
|
TableToolbar: () => TableToolbar,
|
|
40
|
-
TableType: () =>
|
|
42
|
+
TableType: () => import_chunk_TGG6OZ54.TableType,
|
|
43
|
+
cellClassesForRowSelection: () => cellClassesForRowSelection,
|
|
44
|
+
getBaseSchems: () => getBaseSchems,
|
|
41
45
|
initializeTable: () => initializeTable,
|
|
42
46
|
makeDynamicTable: () => makeDynamicTable,
|
|
43
|
-
renderCheckbox: () => renderCheckbox,
|
|
44
|
-
renderSwitch: () => renderSwitch,
|
|
45
47
|
tableButtons: () => tableButtons,
|
|
46
48
|
tableControls: () => tableControls,
|
|
47
49
|
touch: () => touch,
|
|
@@ -49,7 +51,7 @@ __export(node_exports, {
|
|
|
49
51
|
useTableModel: () => useTableModel
|
|
50
52
|
});
|
|
51
53
|
module.exports = __toCommonJS(node_exports);
|
|
52
|
-
var
|
|
54
|
+
var import_chunk_TGG6OZ54 = require("./chunk-TGG6OZ54.cjs");
|
|
53
55
|
var import_react = __toESM(require("react"));
|
|
54
56
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
55
57
|
var import_invariant = require("@dxos/invariant");
|
|
@@ -104,10 +106,14 @@ var import_schema3 = require("@dxos/schema");
|
|
|
104
106
|
var import_react7 = __toESM(require("react"));
|
|
105
107
|
var import_echo_schema7 = require("@dxos/echo-schema");
|
|
106
108
|
var import_invariant3 = require("@dxos/invariant");
|
|
109
|
+
var import_react_ui7 = require("@dxos/react-ui");
|
|
110
|
+
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
107
111
|
var import_react_ui_grid4 = require("@dxos/react-ui-grid");
|
|
112
|
+
var import_react_ui_tag_picker = require("@dxos/react-ui-tag-picker");
|
|
108
113
|
var import_autocomplete = require("@codemirror/autocomplete");
|
|
109
114
|
var import_view = require("@codemirror/view");
|
|
110
115
|
var import_react8 = __toESM(require("react"));
|
|
116
|
+
var import_react_ui8 = require("@dxos/react-ui");
|
|
111
117
|
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
112
118
|
var import_signals_core6 = require("@preact/signals-core");
|
|
113
119
|
var import_react9 = require("react");
|
|
@@ -365,32 +371,59 @@ var RowActionsMenu = ({ model, modals }) => {
|
|
|
365
371
|
}
|
|
366
372
|
}, t(action.translationKey)))), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Arrow, null)));
|
|
367
373
|
};
|
|
368
|
-
var
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
+
var getBaseSchems = ({ typename, properties, jsonSchema, schema }) => {
|
|
375
|
+
if (typename && properties) {
|
|
376
|
+
const schema2 = (0, import_schema.getSchemaFromPropertyDefinitions)(typename, properties);
|
|
377
|
+
return {
|
|
378
|
+
typename: schema2.typename,
|
|
379
|
+
jsonSchema: schema2.jsonSchema
|
|
380
|
+
};
|
|
381
|
+
} else if (schema) {
|
|
382
|
+
return {
|
|
383
|
+
typename: schema.typename,
|
|
384
|
+
jsonSchema: schema.jsonSchema
|
|
385
|
+
};
|
|
386
|
+
} else if (typename && jsonSchema) {
|
|
387
|
+
return {
|
|
388
|
+
typename,
|
|
389
|
+
jsonSchema
|
|
390
|
+
};
|
|
391
|
+
} else {
|
|
392
|
+
throw new Error("invalid properties");
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
var makeDynamicTable = ({ typename, jsonSchema, properties }) => {
|
|
374
396
|
const view = (0, import_schema.createView)({
|
|
375
397
|
name: "dynamic-table",
|
|
376
|
-
typename
|
|
377
|
-
jsonSchema
|
|
378
|
-
|
|
398
|
+
typename,
|
|
399
|
+
jsonSchema,
|
|
400
|
+
...properties && {
|
|
401
|
+
fields: properties.map((property) => property.name)
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
const table = (0, import_live_object2.create)(import_chunk_TGG6OZ54.TableType, {
|
|
405
|
+
name: "dynamic-table",
|
|
406
|
+
view: (0, import_live_object2.makeRef)(view)
|
|
379
407
|
});
|
|
380
|
-
|
|
381
|
-
|
|
408
|
+
const projection = new import_schema.ViewProjection(jsonSchema, view);
|
|
409
|
+
if (properties && view.fields) {
|
|
410
|
+
setProperties(view, projection, properties);
|
|
411
|
+
}
|
|
412
|
+
return {
|
|
413
|
+
table,
|
|
414
|
+
projection
|
|
415
|
+
};
|
|
416
|
+
};
|
|
417
|
+
var setProperties = (view, projection, properties) => {
|
|
382
418
|
for (const property of properties) {
|
|
383
|
-
if (!view.fields) {
|
|
384
|
-
continue;
|
|
385
|
-
}
|
|
386
419
|
const field = view.fields.find((field2) => field2.path === property.name);
|
|
387
420
|
if (field) {
|
|
388
421
|
if (property.size !== void 0) {
|
|
389
422
|
field.size = property.size;
|
|
390
423
|
}
|
|
391
424
|
if (property.title !== void 0) {
|
|
392
|
-
const fieldProjection =
|
|
393
|
-
|
|
425
|
+
const fieldProjection = projection.getFieldProjection(field.id);
|
|
426
|
+
projection.setFieldProjection({
|
|
394
427
|
...fieldProjection,
|
|
395
428
|
props: {
|
|
396
429
|
...fieldProjection.props,
|
|
@@ -409,12 +442,6 @@ var makeDynamicTable = (typename, properties) => {
|
|
|
409
442
|
}
|
|
410
443
|
}
|
|
411
444
|
}
|
|
412
|
-
return {
|
|
413
|
-
table,
|
|
414
|
-
schema: echoSchema,
|
|
415
|
-
view,
|
|
416
|
-
viewProjection
|
|
417
|
-
};
|
|
418
445
|
};
|
|
419
446
|
var touch = (value) => value;
|
|
420
447
|
var initializeTable = async ({ client, space, table, typename, initialRow = true }) => {
|
|
@@ -470,7 +497,7 @@ var ContactFields = [
|
|
|
470
497
|
"active"
|
|
471
498
|
];
|
|
472
499
|
var createProjection = (schema, view) => {
|
|
473
|
-
const projection = new import_schema2.ViewProjection(schema, view);
|
|
500
|
+
const projection = new import_schema2.ViewProjection(schema.jsonSchema, view);
|
|
474
501
|
projection.setFieldProjection({
|
|
475
502
|
field: {
|
|
476
503
|
id: view.fields.find((f) => f.path === "salary").id,
|
|
@@ -629,7 +656,7 @@ var renderAttributes = (data) => {
|
|
|
629
656
|
var renderInput = (baseClass, attrs, checked = false, disabled = false, preventToggle = false, testId) => {
|
|
630
657
|
return `<input type="checkbox" class="${baseClass}" ${renderAttributes(attrs)} ${checked ? "checked" : ""} ${preventToggle ? 'onclick="return false"' : ""} ${disabled ? "disabled" : ""} data-testid="${testId}"/>`;
|
|
631
658
|
};
|
|
632
|
-
var
|
|
659
|
+
var CheckboxStory = ({ rowIndex, header = false, checked = false, disabled = false }) => {
|
|
633
660
|
const attrs = {
|
|
634
661
|
[CONTROL_IDENTIFIERS.checkbox]: "",
|
|
635
662
|
"data-row-index": rowIndex.toString(),
|
|
@@ -639,7 +666,7 @@ var renderCheckbox = ({ rowIndex, header = false, checked = false, disabled = fa
|
|
|
639
666
|
};
|
|
640
667
|
return renderInput(BASE_CLASSES.checkbox, attrs, checked, disabled, true, "table-selection");
|
|
641
668
|
};
|
|
642
|
-
var
|
|
669
|
+
var SwitchStory = ({ colIndex, rowIndex, checked = false, disabled = false }) => {
|
|
643
670
|
const attrs = {
|
|
644
671
|
[CONTROL_IDENTIFIERS.switch]: "",
|
|
645
672
|
"data-row-index": rowIndex.toString(),
|
|
@@ -650,7 +677,7 @@ var renderSwitch = ({ colIndex, rowIndex, checked = false, disabled = false }) =
|
|
|
650
677
|
var tableControls = {
|
|
651
678
|
checkbox: {
|
|
652
679
|
attr: CONTROL_IDENTIFIERS.checkbox,
|
|
653
|
-
render:
|
|
680
|
+
render: CheckboxStory,
|
|
654
681
|
getData: (el) => ({
|
|
655
682
|
type: "checkbox",
|
|
656
683
|
rowIndex: Number(el.getAttribute("data-row-index")),
|
|
@@ -659,7 +686,7 @@ var tableControls = {
|
|
|
659
686
|
},
|
|
660
687
|
switch: {
|
|
661
688
|
attr: CONTROL_IDENTIFIERS.switch,
|
|
662
|
-
render:
|
|
689
|
+
render: SwitchStory,
|
|
663
690
|
getData: (el) => ({
|
|
664
691
|
type: "switch",
|
|
665
692
|
rowIndex: Number(el.getAttribute("data-row-index")),
|
|
@@ -668,9 +695,10 @@ var tableControls = {
|
|
|
668
695
|
}
|
|
669
696
|
};
|
|
670
697
|
var SelectionModel = class extends import_context2.Resource {
|
|
671
|
-
constructor(_rows, _onSelectionChanged) {
|
|
698
|
+
constructor(_rows, _selectionMode, _onSelectionChanged) {
|
|
672
699
|
super();
|
|
673
700
|
this._rows = _rows;
|
|
701
|
+
this._selectionMode = _selectionMode;
|
|
674
702
|
this._onSelectionChanged = _onSelectionChanged;
|
|
675
703
|
this._selection = (0, import_signals_core2.signal)(/* @__PURE__ */ new Set());
|
|
676
704
|
this._validSelectedIds = (0, import_signals_core2.computed)(() => {
|
|
@@ -708,6 +736,9 @@ var SelectionModel = class extends import_context2.Resource {
|
|
|
708
736
|
if (newSelection.has(row.id)) {
|
|
709
737
|
newSelection.delete(row.id);
|
|
710
738
|
} else {
|
|
739
|
+
if (this._selectionMode === "single") {
|
|
740
|
+
newSelection.clear();
|
|
741
|
+
}
|
|
711
742
|
newSelection.add(row.id);
|
|
712
743
|
}
|
|
713
744
|
this._selection.value = newSelection;
|
|
@@ -744,6 +775,9 @@ var SelectionModel = class extends import_context2.Resource {
|
|
|
744
775
|
get allRowsSeleted() {
|
|
745
776
|
return this._allSelected;
|
|
746
777
|
}
|
|
778
|
+
get selectionMode() {
|
|
779
|
+
return this._selectionMode;
|
|
780
|
+
}
|
|
747
781
|
};
|
|
748
782
|
var TableSorting = class {
|
|
749
783
|
constructor(rows, _view, _projection) {
|
|
@@ -906,7 +940,10 @@ var TableSorting = class {
|
|
|
906
940
|
};
|
|
907
941
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/model/table-model.ts";
|
|
908
942
|
var defaultFeatures = {
|
|
909
|
-
selection:
|
|
943
|
+
selection: {
|
|
944
|
+
enabled: true,
|
|
945
|
+
mode: "multiple"
|
|
946
|
+
},
|
|
910
947
|
dataEditable: false,
|
|
911
948
|
schemaEditable: false
|
|
912
949
|
};
|
|
@@ -914,7 +951,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
914
951
|
constructor({ id, space, view, projection, features = {}, sorting = [], pinnedRows = {
|
|
915
952
|
top: [],
|
|
916
953
|
bottom: []
|
|
917
|
-
}, onCellUpdate, onDeleteColumn, onDeleteRows, onInsertRow,
|
|
954
|
+
}, rowActions = [], onCellUpdate, onDeleteColumn, onDeleteRows, onInsertRow, onRowOrderChange, onRowAction }) {
|
|
918
955
|
super();
|
|
919
956
|
this._visibleRange = (0, import_signals_core.signal)({
|
|
920
957
|
start: {
|
|
@@ -940,7 +977,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
940
977
|
const row = this._sorting.getDataIndex(rowIndex);
|
|
941
978
|
const obj = this._rows.value[row];
|
|
942
979
|
const objectsToDelete = [];
|
|
943
|
-
if (this._selection.hasSelection.value) {
|
|
980
|
+
if (this.features.selection.enabled && this._selection.hasSelection.value) {
|
|
944
981
|
const selectedRows = this._selection.getSelectedRows();
|
|
945
982
|
objectsToDelete.push(...selectedRows);
|
|
946
983
|
} else {
|
|
@@ -1019,18 +1056,27 @@ var TableModel = class extends import_context.Resource {
|
|
|
1019
1056
|
...defaultFeatures,
|
|
1020
1057
|
...features
|
|
1021
1058
|
};
|
|
1059
|
+
(0, import_invariant2.invariant)(!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === "single"), "Single selection is not compatible with editable tables.", {
|
|
1060
|
+
F: __dxlog_file,
|
|
1061
|
+
L: 114,
|
|
1062
|
+
S: this,
|
|
1063
|
+
A: [
|
|
1064
|
+
"!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === 'single')",
|
|
1065
|
+
"'Single selection is not compatible with editable tables.'"
|
|
1066
|
+
]
|
|
1067
|
+
});
|
|
1022
1068
|
this._sorting = new TableSorting(this._rows, this._view, projection);
|
|
1023
1069
|
if (sorting.length > 0) {
|
|
1024
1070
|
const [sort] = sorting;
|
|
1025
1071
|
this._sorting.setSort(sort.fieldId, sort.direction);
|
|
1026
1072
|
}
|
|
1027
1073
|
this._pinnedRows = pinnedRows;
|
|
1074
|
+
this._rowActions = rowActions;
|
|
1028
1075
|
this._onInsertRow = onInsertRow;
|
|
1029
1076
|
this._onDeleteRows = onDeleteRows;
|
|
1030
1077
|
this._onDeleteColumn = onDeleteColumn;
|
|
1031
1078
|
this._onCellUpdate = onCellUpdate;
|
|
1032
|
-
this.
|
|
1033
|
-
this._rowActions = rowActions;
|
|
1079
|
+
this._onRowOrderChange = onRowOrderChange;
|
|
1034
1080
|
this._onRowAction = onRowAction;
|
|
1035
1081
|
}
|
|
1036
1082
|
get id() {
|
|
@@ -1072,7 +1118,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
1072
1118
|
get columnMeta() {
|
|
1073
1119
|
(0, import_invariant2.invariant)(this._columnMeta, void 0, {
|
|
1074
1120
|
F: __dxlog_file,
|
|
1075
|
-
L:
|
|
1121
|
+
L: 183,
|
|
1076
1122
|
S: this,
|
|
1077
1123
|
A: [
|
|
1078
1124
|
"this._columnMeta",
|
|
@@ -1097,7 +1143,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
1097
1143
|
async _open() {
|
|
1098
1144
|
this.initializeColumnMeta();
|
|
1099
1145
|
this.initializeEffects();
|
|
1100
|
-
this._selection = new SelectionModel(this._sorting.sortedRows, () => this.
|
|
1146
|
+
this._selection = new SelectionModel(this._sorting.sortedRows, this._features.selection.mode ?? "multiple", () => this._onRowOrderChange?.());
|
|
1101
1147
|
await this._selection.open(this._ctx);
|
|
1102
1148
|
}
|
|
1103
1149
|
initializeColumnMeta() {
|
|
@@ -1130,7 +1176,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
1130
1176
|
initializeEffects() {
|
|
1131
1177
|
const rowOrderWatcher = (0, import_signals_core.effect)(() => {
|
|
1132
1178
|
touch(this._sorting.sortedRows.value);
|
|
1133
|
-
this.
|
|
1179
|
+
this._onRowOrderChange?.();
|
|
1134
1180
|
});
|
|
1135
1181
|
this._ctx.onDispose(rowOrderWatcher);
|
|
1136
1182
|
const rowEffectManager = (0, import_signals_core.effect)(() => {
|
|
@@ -1332,7 +1378,7 @@ var TablePresentation = class {
|
|
|
1332
1378
|
}
|
|
1333
1379
|
if (plane === "grid" && this.model.features.dataEditable === false) {
|
|
1334
1380
|
Object.values(cells).forEach((cell) => {
|
|
1335
|
-
cell.readonly =
|
|
1381
|
+
cell.readonly = "text-select";
|
|
1336
1382
|
});
|
|
1337
1383
|
}
|
|
1338
1384
|
return cells;
|
|
@@ -1350,7 +1396,8 @@ var TablePresentation = class {
|
|
|
1350
1396
|
}
|
|
1351
1397
|
switch (props.format) {
|
|
1352
1398
|
case import_echo_schema6.FormatEnum.Boolean:
|
|
1353
|
-
case import_echo_schema6.FormatEnum.SingleSelect:
|
|
1399
|
+
case import_echo_schema6.FormatEnum.SingleSelect:
|
|
1400
|
+
case import_echo_schema6.FormatEnum.MultiSelect: {
|
|
1354
1401
|
return "";
|
|
1355
1402
|
}
|
|
1356
1403
|
case import_echo_schema6.FormatEnum.Ref: {
|
|
@@ -1377,7 +1424,7 @@ var TablePresentation = class {
|
|
|
1377
1424
|
if (formatClasses) {
|
|
1378
1425
|
classes.push(formatClasses);
|
|
1379
1426
|
}
|
|
1380
|
-
const rowSelectionClasses =
|
|
1427
|
+
const rowSelectionClasses = cellClassesForRowSelection(this.model.selection.isObjectSelected(obj), this.model.selection.selectionMode);
|
|
1381
1428
|
if (rowSelectionClasses) {
|
|
1382
1429
|
classes.push(rowSelectionClasses);
|
|
1383
1430
|
}
|
|
@@ -1400,7 +1447,7 @@ var TablePresentation = class {
|
|
|
1400
1447
|
rowIndex: displayIndex,
|
|
1401
1448
|
checked: value ?? false
|
|
1402
1449
|
});
|
|
1403
|
-
cell.readonly =
|
|
1450
|
+
cell.readonly = "no-text-select";
|
|
1404
1451
|
}
|
|
1405
1452
|
if (props.format === import_echo_schema6.FormatEnum.SingleSelect) {
|
|
1406
1453
|
const value = (0, import_echo_schema6.getValue)(obj, field.path);
|
|
@@ -1412,6 +1459,22 @@ var TablePresentation = class {
|
|
|
1412
1459
|
}
|
|
1413
1460
|
}
|
|
1414
1461
|
}
|
|
1462
|
+
if (props.format === import_echo_schema6.FormatEnum.MultiSelect) {
|
|
1463
|
+
const values = (0, import_echo_schema6.getValue)(obj, field.path);
|
|
1464
|
+
const options = this.model.projection.getFieldProjection(field.id).props.options;
|
|
1465
|
+
if (options && values && values.length > 0) {
|
|
1466
|
+
const tags = values.map((value) => {
|
|
1467
|
+
const option = options.find((o) => o.id === value);
|
|
1468
|
+
if (option) {
|
|
1469
|
+
return `<span class="dx-tag" data-hue="${option.color}">${option.title}</span>`;
|
|
1470
|
+
}
|
|
1471
|
+
return null;
|
|
1472
|
+
}).filter(Boolean).join(" ");
|
|
1473
|
+
if (tags) {
|
|
1474
|
+
cell.accessoryHtml = tags;
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1415
1478
|
const idx = (0, import_react_ui_grid3.toPlaneCellIndex)({
|
|
1416
1479
|
col: colIndex,
|
|
1417
1480
|
row: displayIndex
|
|
@@ -1462,13 +1525,13 @@ var TablePresentation = class {
|
|
|
1462
1525
|
const cells = {};
|
|
1463
1526
|
for (let row = range.start.row; row <= range.end.row && row < this.model.getRowCount(); row++) {
|
|
1464
1527
|
const isSelected = this.model.selection.isRowIndexSelected(row);
|
|
1465
|
-
const classes = (
|
|
1528
|
+
const classes = cellClassesForRowSelection(isSelected, this.model.selection.selectionMode);
|
|
1466
1529
|
cells[(0, import_react_ui_grid3.toPlaneCellIndex)({
|
|
1467
1530
|
col: 0,
|
|
1468
1531
|
row
|
|
1469
1532
|
})] = {
|
|
1470
1533
|
value: "",
|
|
1471
|
-
readonly:
|
|
1534
|
+
readonly: "no-text-select",
|
|
1472
1535
|
className: classes ? (0, import_react_ui_theme2.mx)(classes) : void 0,
|
|
1473
1536
|
accessoryHtml: tableControls.checkbox.render({
|
|
1474
1537
|
rowIndex: row,
|
|
@@ -1482,7 +1545,7 @@ var TablePresentation = class {
|
|
|
1482
1545
|
const cells = {};
|
|
1483
1546
|
for (let row = range.start.row; row <= range.end.row && row < this.model.getRowCount(); row++) {
|
|
1484
1547
|
const isSelected = this.model.selection.isRowIndexSelected(row);
|
|
1485
|
-
const classes = (
|
|
1548
|
+
const classes = cellClassesForRowSelection(isSelected, this.model.selection.selectionMode);
|
|
1486
1549
|
cells[(0, import_react_ui_grid3.toPlaneCellIndex)({
|
|
1487
1550
|
col: 0,
|
|
1488
1551
|
row
|
|
@@ -1498,6 +1561,18 @@ var TablePresentation = class {
|
|
|
1498
1561
|
return cells;
|
|
1499
1562
|
}
|
|
1500
1563
|
getSelectAllCell() {
|
|
1564
|
+
if (!this.model.features.selection.enabled || this.model.selection.selectionMode === "single") {
|
|
1565
|
+
return {
|
|
1566
|
+
[(0, import_react_ui_grid3.toPlaneCellIndex)({
|
|
1567
|
+
col: 0,
|
|
1568
|
+
row: 0
|
|
1569
|
+
})]: {
|
|
1570
|
+
className: "!bg-gridHeader",
|
|
1571
|
+
readonly: true,
|
|
1572
|
+
value: ""
|
|
1573
|
+
}
|
|
1574
|
+
};
|
|
1575
|
+
}
|
|
1501
1576
|
return {
|
|
1502
1577
|
[(0, import_react_ui_grid3.toPlaneCellIndex)({
|
|
1503
1578
|
col: 0,
|
|
@@ -1530,6 +1605,28 @@ var TablePresentation = class {
|
|
|
1530
1605
|
};
|
|
1531
1606
|
}
|
|
1532
1607
|
};
|
|
1608
|
+
var cellClassesForRowSelection = (selected, selectionMode) => {
|
|
1609
|
+
if (!selected) {
|
|
1610
|
+
if (selectionMode === "single") {
|
|
1611
|
+
return [
|
|
1612
|
+
"!cursor-pointer"
|
|
1613
|
+
];
|
|
1614
|
+
} else {
|
|
1615
|
+
return void 0;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
switch (selectionMode) {
|
|
1619
|
+
case "single":
|
|
1620
|
+
return [
|
|
1621
|
+
"!bg-currentRelated hover:bg-hoverSurface",
|
|
1622
|
+
"!cursor-pointer"
|
|
1623
|
+
];
|
|
1624
|
+
case "multiple":
|
|
1625
|
+
return [
|
|
1626
|
+
"!bg-gridCellSelected"
|
|
1627
|
+
];
|
|
1628
|
+
}
|
|
1629
|
+
};
|
|
1533
1630
|
var completion = ({ debug, onQuery, onMatch }) => {
|
|
1534
1631
|
return [
|
|
1535
1632
|
import_view.EditorView.theme({
|
|
@@ -1575,6 +1672,7 @@ var isCreateOption = (data) => typeof data === "object" && data[newValue];
|
|
|
1575
1672
|
var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }) => {
|
|
1576
1673
|
const { id: gridId, editing, setEditing } = (0, import_react_ui_grid4.useGridContext)("TableCellEditor", __gridScope);
|
|
1577
1674
|
const suppressNextBlur = (0, import_react7.useRef)(false);
|
|
1675
|
+
const { themeMode } = (0, import_react_ui7.useThemeContext)();
|
|
1578
1676
|
const fieldProjection = (0, import_react7.useMemo)(() => {
|
|
1579
1677
|
if (!model || !editing) {
|
|
1580
1678
|
return;
|
|
@@ -1584,7 +1682,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1584
1682
|
const fieldProjection2 = model.projection.getFieldProjection(field.id);
|
|
1585
1683
|
(0, import_invariant3.invariant)(fieldProjection2, void 0, {
|
|
1586
1684
|
F: __dxlog_file3,
|
|
1587
|
-
L:
|
|
1685
|
+
L: 71,
|
|
1588
1686
|
S: void 0,
|
|
1589
1687
|
A: [
|
|
1590
1688
|
"fieldProjection",
|
|
@@ -1607,7 +1705,10 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1607
1705
|
setEditing(null);
|
|
1608
1706
|
}, [
|
|
1609
1707
|
model,
|
|
1610
|
-
editing
|
|
1708
|
+
editing,
|
|
1709
|
+
onEnter,
|
|
1710
|
+
onFocus,
|
|
1711
|
+
setEditing
|
|
1611
1712
|
]);
|
|
1612
1713
|
const handleBlur = (0, import_react7.useCallback)((value) => {
|
|
1613
1714
|
if (!model || !editing) {
|
|
@@ -1639,9 +1740,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1639
1740
|
editing,
|
|
1640
1741
|
onFocus,
|
|
1641
1742
|
onEnter,
|
|
1642
|
-
fieldProjection
|
|
1643
|
-
determineNavigationAxis,
|
|
1644
|
-
determineNavigationDelta
|
|
1743
|
+
fieldProjection
|
|
1645
1744
|
]);
|
|
1646
1745
|
const extension = (0, import_react7.useMemo)(() => {
|
|
1647
1746
|
if (!fieldProjection) {
|
|
@@ -1655,6 +1754,37 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1655
1754
|
}
|
|
1656
1755
|
})
|
|
1657
1756
|
];
|
|
1757
|
+
const format = fieldProjection.props.format;
|
|
1758
|
+
if (format === import_echo_schema7.FormatEnum.SingleSelect || format === import_echo_schema7.FormatEnum.MultiSelect) {
|
|
1759
|
+
extension2.push((0, import_react_ui_editor.createMarkdownExtensions)({
|
|
1760
|
+
themeMode
|
|
1761
|
+
}));
|
|
1762
|
+
const options = fieldProjection.props.options || [];
|
|
1763
|
+
const mode = format === import_echo_schema7.FormatEnum.SingleSelect ? "single-select" : "multi-select";
|
|
1764
|
+
extension2.push((0, import_react_ui_tag_picker.tagPickerExtension)({
|
|
1765
|
+
mode,
|
|
1766
|
+
inGrid: true,
|
|
1767
|
+
onSearch: (text, selectedIds) => {
|
|
1768
|
+
return options.filter((option) => selectedIds.indexOf(option.id) === -1 && (text.length === 0 || option.title.toLowerCase().includes(text.toLowerCase()))).map((option) => ({
|
|
1769
|
+
id: option.id,
|
|
1770
|
+
label: option.title,
|
|
1771
|
+
hue: option.color
|
|
1772
|
+
}));
|
|
1773
|
+
},
|
|
1774
|
+
onUpdate: (ids) => {
|
|
1775
|
+
if (model && editing) {
|
|
1776
|
+
if (ids.length === 0) {
|
|
1777
|
+
return;
|
|
1778
|
+
}
|
|
1779
|
+
if (mode === "single-select") {
|
|
1780
|
+
handleEnter(ids[0]);
|
|
1781
|
+
} else {
|
|
1782
|
+
handleEnter(ids);
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
}));
|
|
1787
|
+
}
|
|
1658
1788
|
if (onQuery) {
|
|
1659
1789
|
switch (fieldProjection.props.format) {
|
|
1660
1790
|
case import_echo_schema7.FormatEnum.Ref: {
|
|
@@ -1690,11 +1820,49 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1690
1820
|
modals,
|
|
1691
1821
|
editing,
|
|
1692
1822
|
fieldProjection,
|
|
1693
|
-
handleClose
|
|
1823
|
+
handleClose,
|
|
1824
|
+
themeMode
|
|
1694
1825
|
]);
|
|
1695
1826
|
const getCellContent = (0, import_react7.useCallback)(() => {
|
|
1696
1827
|
if (model && editing) {
|
|
1697
|
-
const
|
|
1828
|
+
const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
|
|
1829
|
+
const { col } = cell;
|
|
1830
|
+
const field = model.projection.view.fields[col];
|
|
1831
|
+
const fieldProjection2 = model.projection.getFieldProjection(field.id);
|
|
1832
|
+
if (fieldProjection2?.props.format === import_echo_schema7.FormatEnum.SingleSelect || fieldProjection2?.props.format === import_echo_schema7.FormatEnum.MultiSelect) {
|
|
1833
|
+
const value2 = model.getCellData(cell);
|
|
1834
|
+
if (value2 !== void 0) {
|
|
1835
|
+
const options = fieldProjection2.props.options || [];
|
|
1836
|
+
if (fieldProjection2.props.format === import_echo_schema7.FormatEnum.MultiSelect && Array.isArray(value2)) {
|
|
1837
|
+
const tagItems = value2.map((id) => {
|
|
1838
|
+
const option = options.find((o) => o.id === id);
|
|
1839
|
+
if (option) {
|
|
1840
|
+
return {
|
|
1841
|
+
id,
|
|
1842
|
+
label: option.title,
|
|
1843
|
+
hue: option.color
|
|
1844
|
+
};
|
|
1845
|
+
}
|
|
1846
|
+
return void 0;
|
|
1847
|
+
}).filter((item) => item !== void 0);
|
|
1848
|
+
return (0, import_react_ui_tag_picker.createLinks)(tagItems);
|
|
1849
|
+
} else {
|
|
1850
|
+
const option = options.find((o) => o.id === value2);
|
|
1851
|
+
if (option) {
|
|
1852
|
+
const tagItem = {
|
|
1853
|
+
id: value2,
|
|
1854
|
+
label: option.title,
|
|
1855
|
+
hue: option.color
|
|
1856
|
+
};
|
|
1857
|
+
return (0, import_react_ui_tag_picker.createLinks)([
|
|
1858
|
+
tagItem
|
|
1859
|
+
]);
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
return "";
|
|
1864
|
+
}
|
|
1865
|
+
const value = model.getCellData(cell);
|
|
1698
1866
|
return value !== void 0 ? String(value) : "";
|
|
1699
1867
|
}
|
|
1700
1868
|
}, [
|
|
@@ -1737,26 +1905,37 @@ var blockEndLine = "[&>.dx-grid]:before:absolute [&>.dx-grid]:before:inset-inlin
|
|
|
1737
1905
|
var TableRoot = ({ children, role }) => {
|
|
1738
1906
|
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
1739
1907
|
role: "none",
|
|
1740
|
-
className: (0, import_react_ui_theme.mx)("relative
|
|
1908
|
+
className: (0, import_react_ui_theme.mx)("relative !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]")
|
|
1741
1909
|
}, children);
|
|
1742
1910
|
};
|
|
1743
|
-
var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentation, ignoreAttention,
|
|
1911
|
+
var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentation, ignoreAttention, onRowClick }, forwardedRef) => {
|
|
1744
1912
|
const [dxGrid, setDxGrid] = (0, import_react.useState)(null);
|
|
1745
1913
|
const { hasAttention } = (0, import_react_ui_attention.useAttention)(model?.id ?? "table");
|
|
1746
1914
|
const { t } = (0, import_react_ui.useTranslation)(translationKey);
|
|
1747
1915
|
const modals = (0, import_react.useMemo)(() => new ModalController(), []);
|
|
1748
|
-
const frozen = (0, import_react.useMemo)(() =>
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1916
|
+
const frozen = (0, import_react.useMemo)(() => {
|
|
1917
|
+
const noActionColumn = model?.features.dataEditable === false && model?.features.schemaEditable === false && model.rowActions.length === 0;
|
|
1918
|
+
return {
|
|
1919
|
+
frozenRowsStart: 1,
|
|
1920
|
+
frozenColsStart: model?.features.selection.enabled ? 1 : 0,
|
|
1921
|
+
frozenColsEnd: noActionColumn ? 0 : 1
|
|
1922
|
+
};
|
|
1923
|
+
}, [
|
|
1753
1924
|
model
|
|
1754
1925
|
]);
|
|
1926
|
+
(0, import_react.useEffect)(() => {
|
|
1927
|
+
if (!presentation || !dxGrid) {
|
|
1928
|
+
return;
|
|
1929
|
+
}
|
|
1930
|
+
dxGrid.getCells = (range, plane) => presentation.getCells(range, plane);
|
|
1931
|
+
}, [
|
|
1932
|
+
presentation,
|
|
1933
|
+
dxGrid
|
|
1934
|
+
]);
|
|
1755
1935
|
(0, import_react.useImperativeHandle)(forwardedRef, () => {
|
|
1756
1936
|
if (!presentation || !dxGrid) {
|
|
1757
1937
|
return {};
|
|
1758
1938
|
}
|
|
1759
|
-
dxGrid.getCells = (range, plane) => presentation.getCells(range, plane);
|
|
1760
1939
|
return {
|
|
1761
1940
|
update: (cell) => {
|
|
1762
1941
|
if (cell) {
|
|
@@ -1772,11 +1951,14 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
1772
1951
|
dxGrid
|
|
1773
1952
|
]);
|
|
1774
1953
|
const handleGridClick = (0, import_react.useCallback)((event) => {
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
if (
|
|
1954
|
+
const rowIndex = (0, import_util.safeParseInt)(event.target.ariaRowIndex ?? "");
|
|
1955
|
+
if (rowIndex != null) {
|
|
1956
|
+
if (onRowClick) {
|
|
1778
1957
|
const row = model?.getRowAt(rowIndex);
|
|
1779
|
-
row &&
|
|
1958
|
+
row && onRowClick(row);
|
|
1959
|
+
}
|
|
1960
|
+
if (model?.features.selection.enabled && model?.selection.selectionMode === "single") {
|
|
1961
|
+
model.selection.toggleSelectionForRowIndex(rowIndex);
|
|
1780
1962
|
}
|
|
1781
1963
|
}
|
|
1782
1964
|
if (!modals) {
|
|
@@ -1919,7 +2101,7 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
1919
2101
|
const space = model.space;
|
|
1920
2102
|
(0, import_invariant.invariant)(space, void 0, {
|
|
1921
2103
|
F: __dxlog_file4,
|
|
1922
|
-
L:
|
|
2104
|
+
L: 312,
|
|
1923
2105
|
S: void 0,
|
|
1924
2106
|
A: [
|
|
1925
2107
|
"space",
|
|
@@ -1970,16 +2152,17 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
1970
2152
|
onFocus: handleFocus,
|
|
1971
2153
|
onQuery: handleQuery
|
|
1972
2154
|
}), /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Content, {
|
|
1973
|
-
onWheelCapture: handleWheel,
|
|
1974
2155
|
className: (0, import_react_ui_theme.mx)("[--dx-grid-base:var(--surface-bg)]", inlineEndLine, blockEndLine),
|
|
1975
2156
|
frozen,
|
|
2157
|
+
// getCells={getCells}
|
|
1976
2158
|
columns: model.columnMeta.value,
|
|
1977
2159
|
limitRows: model.getRowCount() ?? 0,
|
|
1978
2160
|
limitColumns: model.view?.fields?.length ?? 0,
|
|
2161
|
+
overscroll: "trap",
|
|
1979
2162
|
onAxisResize: handleAxisResize,
|
|
1980
2163
|
onClick: handleGridClick,
|
|
1981
2164
|
onKeyDown: handleKeyDown,
|
|
1982
|
-
|
|
2165
|
+
onWheelCapture: handleWheel,
|
|
1983
2166
|
ref: setDxGrid
|
|
1984
2167
|
}), /* @__PURE__ */ import_react.default.createElement(RowActionsMenu, {
|
|
1985
2168
|
model,
|
|
@@ -1991,10 +2174,10 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
1991
2174
|
model,
|
|
1992
2175
|
modals,
|
|
1993
2176
|
onNewColumn: handleNewColumn
|
|
1994
|
-
}), /* @__PURE__ */ import_react.default.createElement(
|
|
2177
|
+
}), /* @__PURE__ */ import_react.default.createElement(CreateRefPanel, {
|
|
1995
2178
|
model,
|
|
1996
2179
|
modals
|
|
1997
|
-
}), /* @__PURE__ */ import_react.default.createElement(
|
|
2180
|
+
}), /* @__PURE__ */ import_react.default.createElement(RefPanel, {
|
|
1998
2181
|
model,
|
|
1999
2182
|
modals
|
|
2000
2183
|
}));
|
|
@@ -2003,7 +2186,7 @@ var Table = {
|
|
|
2003
2186
|
Root: TableRoot,
|
|
2004
2187
|
Main: TableMain
|
|
2005
2188
|
};
|
|
2006
|
-
var useTableModel = ({
|
|
2189
|
+
var useTableModel = ({ table, projection, rows, rowActions, features, onSelectionChanged, onRowAction, ...props }) => {
|
|
2007
2190
|
const [model, setModel] = (0, import_react9.useState)();
|
|
2008
2191
|
(0, import_react9.useEffect)(() => {
|
|
2009
2192
|
if (!table || !projection) {
|
|
@@ -2036,12 +2219,12 @@ var useTableModel = ({ objects, table, projection, features, onSelectionChanged,
|
|
|
2036
2219
|
rowActions
|
|
2037
2220
|
]);
|
|
2038
2221
|
(0, import_react9.useEffect)(() => {
|
|
2039
|
-
if (
|
|
2040
|
-
model?.setRows(
|
|
2222
|
+
if (rows) {
|
|
2223
|
+
model?.setRows(rows);
|
|
2041
2224
|
}
|
|
2042
2225
|
}, [
|
|
2043
2226
|
model,
|
|
2044
|
-
|
|
2227
|
+
rows
|
|
2045
2228
|
]);
|
|
2046
2229
|
const { select, clear } = (0, import_react_ui_attention2.useSelectionActions)([
|
|
2047
2230
|
table?.id,
|
|
@@ -2068,32 +2251,45 @@ var useTableModel = ({ objects, table, projection, features, onSelectionChanged,
|
|
|
2068
2251
|
]);
|
|
2069
2252
|
return model;
|
|
2070
2253
|
};
|
|
2071
|
-
var DynamicTable = ({
|
|
2072
|
-
const { table,
|
|
2073
|
-
|
|
2254
|
+
var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, properties, jsonSchema, schema, rowActions, onRowClick, onRowAction, ...props }) => {
|
|
2255
|
+
const { table, projection } = (0, import_react8.useMemo)(() => {
|
|
2256
|
+
const props2 = getBaseSchems({
|
|
2257
|
+
typename: name,
|
|
2258
|
+
properties,
|
|
2259
|
+
jsonSchema,
|
|
2260
|
+
schema
|
|
2261
|
+
});
|
|
2262
|
+
return makeDynamicTable({
|
|
2263
|
+
...props2,
|
|
2264
|
+
properties
|
|
2265
|
+
});
|
|
2074
2266
|
}, [
|
|
2075
|
-
|
|
2076
|
-
properties
|
|
2267
|
+
name,
|
|
2268
|
+
properties,
|
|
2269
|
+
schema,
|
|
2270
|
+
jsonSchema
|
|
2077
2271
|
]);
|
|
2078
2272
|
const tableRef = (0, import_react8.useRef)(null);
|
|
2079
2273
|
const handleCellUpdate = (0, import_react8.useCallback)((cell) => {
|
|
2080
2274
|
tableRef.current?.update?.(cell);
|
|
2081
2275
|
}, []);
|
|
2082
|
-
const
|
|
2276
|
+
const handleRowOrderChange = (0, import_react8.useCallback)(() => {
|
|
2083
2277
|
tableRef.current?.update?.();
|
|
2084
2278
|
}, []);
|
|
2085
|
-
const features = (0,
|
|
2086
|
-
selection:
|
|
2279
|
+
const features = (0, import_react_ui8.useDefaultValue)(props.features, () => ({
|
|
2280
|
+
selection: {
|
|
2281
|
+
enabled: false
|
|
2282
|
+
},
|
|
2087
2283
|
dataEditable: false
|
|
2088
|
-
})
|
|
2284
|
+
}));
|
|
2089
2285
|
const model = useTableModel({
|
|
2090
2286
|
table,
|
|
2091
|
-
|
|
2092
|
-
projection
|
|
2287
|
+
rows,
|
|
2288
|
+
projection,
|
|
2093
2289
|
features,
|
|
2094
|
-
onCellUpdate: handleCellUpdate,
|
|
2095
|
-
onRowOrderChanged: handleRowOrderChanged,
|
|
2096
2290
|
rowActions,
|
|
2291
|
+
onCellUpdate: handleCellUpdate,
|
|
2292
|
+
onRowOrderChange: handleRowOrderChange,
|
|
2097
2293
|
onRowAction
|
|
2098
2294
|
});
|
|
2099
2295
|
const presentation = (0, import_react8.useMemo)(() => {
|
|
@@ -2104,15 +2300,17 @@ var DynamicTable = ({ data, properties, classNames, tableName = "com.example/dyn
|
|
|
2104
2300
|
model
|
|
2105
2301
|
]);
|
|
2106
2302
|
return /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
2303
|
+
role: "none",
|
|
2107
2304
|
className: (0, import_react_ui_theme3.mx)("is-full bs-full grow grid", classNames)
|
|
2108
2305
|
}, /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
2306
|
+
role: "none",
|
|
2109
2307
|
className: "grid min-bs-0 overflow-hidden"
|
|
2110
2308
|
}, /* @__PURE__ */ import_react8.default.createElement(Table.Root, null, /* @__PURE__ */ import_react8.default.createElement(Table.Main, {
|
|
2111
2309
|
ref: tableRef,
|
|
2112
2310
|
model,
|
|
2113
2311
|
presentation,
|
|
2114
|
-
|
|
2115
|
-
|
|
2312
|
+
ignoreAttention: true,
|
|
2313
|
+
onRowClick
|
|
2116
2314
|
}))));
|
|
2117
2315
|
};
|
|
2118
2316
|
var createTableToolbarActions = (state) => {
|
|
@@ -2186,18 +2384,20 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
|
|
|
2186
2384
|
0 && (module.exports = {
|
|
2187
2385
|
BUTTON_IDENTIFIERS,
|
|
2188
2386
|
CONTROL_IDENTIFIERS,
|
|
2387
|
+
CheckboxStory,
|
|
2189
2388
|
DynamicTable,
|
|
2190
2389
|
ModalController,
|
|
2390
|
+
SwitchStory,
|
|
2191
2391
|
Table,
|
|
2192
2392
|
TableModel,
|
|
2193
2393
|
TablePresentation,
|
|
2194
2394
|
TableSchema,
|
|
2195
2395
|
TableToolbar,
|
|
2196
2396
|
TableType,
|
|
2397
|
+
cellClassesForRowSelection,
|
|
2398
|
+
getBaseSchems,
|
|
2197
2399
|
initializeTable,
|
|
2198
2400
|
makeDynamicTable,
|
|
2199
|
-
renderCheckbox,
|
|
2200
|
-
renderSwitch,
|
|
2201
2401
|
tableButtons,
|
|
2202
2402
|
tableControls,
|
|
2203
2403
|
touch,
|