@dxos/react-ui-table 0.8.2-main.f11618f → 0.8.2-staging.7ac8446
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/index.mjs +116 -80
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +127 -91
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +116 -80
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Table/RefPanel.d.ts +9 -0
- package/dist/types/src/components/Table/RefPanel.d.ts.map +1 -0
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/relations.stories.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +1 -1
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts +2 -2
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts +3 -3
- package/dist/types/src/model/modal-controller.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts.map +1 -1
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/util/table-buttons.d.ts +14 -0
- package/dist/types/src/util/table-buttons.d.ts.map +1 -1
- package/dist/types/src/util/table.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/components/Table/CreateRefPanel.tsx +2 -2
- package/src/components/Table/DynamicTable.stories.tsx +2 -2
- package/src/components/Table/RefPanel.tsx +52 -0
- package/src/components/Table/Table.stories.tsx +9 -9
- package/src/components/Table/Table.tsx +24 -18
- package/src/components/Table/relations.stories.tsx +21 -30
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +3 -3
- package/src/components/TableToolbar/TableToolbar.tsx +2 -2
- package/src/components/testing.ts +3 -3
- package/src/hooks/useTableModel.ts +2 -2
- package/src/model/modal-controller.ts +3 -3
- package/src/model/table-model.test.ts +3 -3
- package/src/model/table-model.ts +2 -19
- package/src/model/table-presentation.test.ts +3 -3
- package/src/model/table-presentation.ts +5 -3
- package/src/util/dynamic-table.ts +2 -2
- package/src/util/table-buttons.ts +23 -0
- package/src/util/table.ts +7 -3
- package/dist/types/src/util/tag.d.ts +0 -11
- package/dist/types/src/util/tag.d.ts.map +0 -1
- package/src/util/tag.ts +0 -33
package/dist/lib/node/index.cjs
CHANGED
|
@@ -74,12 +74,15 @@ var import_react_ui_form2 = require("@dxos/react-ui-form");
|
|
|
74
74
|
var import_react_ui_grid2 = require("@dxos/react-ui-grid");
|
|
75
75
|
var import_react5 = __toESM(require("react"));
|
|
76
76
|
var import_react_ui5 = require("@dxos/react-ui");
|
|
77
|
+
var import_react_ui_form3 = require("@dxos/react-ui-form");
|
|
78
|
+
var import_react6 = __toESM(require("react"));
|
|
79
|
+
var import_react_ui6 = require("@dxos/react-ui");
|
|
77
80
|
var import_signals_core = require("@preact/signals-core");
|
|
78
81
|
var import_context = require("@dxos/context");
|
|
79
82
|
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
80
83
|
var import_invariant2 = require("@dxos/invariant");
|
|
81
84
|
var import_live_object = require("@dxos/live-object");
|
|
82
|
-
var
|
|
85
|
+
var import_react_ui_form4 = require("@dxos/react-ui-form");
|
|
83
86
|
var import_signals_core2 = require("@preact/signals-core");
|
|
84
87
|
var import_context2 = require("@dxos/context");
|
|
85
88
|
var import_live_object2 = require("@dxos/live-object");
|
|
@@ -91,33 +94,33 @@ var import_schema2 = require("@dxos/schema");
|
|
|
91
94
|
var import_signals_core3 = require("@preact/signals-core");
|
|
92
95
|
var import_lodash = __toESM(require("lodash.orderby"));
|
|
93
96
|
var import_echo_schema5 = require("@dxos/echo-schema");
|
|
94
|
-
var
|
|
97
|
+
var import_react_ui_form5 = require("@dxos/react-ui-form");
|
|
95
98
|
var import_signals_core4 = require("@preact/signals-core");
|
|
96
99
|
var import_log = require("@dxos/log");
|
|
97
100
|
var import_signals_core5 = require("@preact/signals-core");
|
|
98
101
|
var import_echo_schema6 = require("@dxos/echo-schema");
|
|
99
|
-
var
|
|
102
|
+
var import_react_ui_form6 = require("@dxos/react-ui-form");
|
|
100
103
|
var import_react_ui_grid3 = require("@dxos/react-ui-grid");
|
|
101
104
|
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
102
105
|
var import_schema3 = require("@dxos/schema");
|
|
103
|
-
var
|
|
106
|
+
var import_react7 = __toESM(require("react"));
|
|
104
107
|
var import_echo_schema7 = require("@dxos/echo-schema");
|
|
105
108
|
var import_invariant3 = require("@dxos/invariant");
|
|
106
|
-
var
|
|
109
|
+
var import_react_ui7 = require("@dxos/react-ui");
|
|
107
110
|
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
108
111
|
var import_react_ui_grid4 = require("@dxos/react-ui-grid");
|
|
109
112
|
var import_react_ui_tag_picker = require("@dxos/react-ui-tag-picker");
|
|
110
113
|
var import_autocomplete = require("@codemirror/autocomplete");
|
|
111
114
|
var import_view = require("@codemirror/view");
|
|
112
|
-
var
|
|
113
|
-
var
|
|
115
|
+
var import_react8 = __toESM(require("react"));
|
|
116
|
+
var import_react_ui8 = require("@dxos/react-ui");
|
|
114
117
|
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
115
118
|
var import_signals_core6 = require("@preact/signals-core");
|
|
116
|
-
var
|
|
119
|
+
var import_react9 = require("react");
|
|
117
120
|
var import_echo4 = require("@dxos/react-client/echo");
|
|
118
121
|
var import_react_ui_attention2 = require("@dxos/react-ui-attention");
|
|
119
122
|
var import_util2 = require("@dxos/util");
|
|
120
|
-
var
|
|
123
|
+
var import_react10 = __toESM(require("react"));
|
|
121
124
|
var import_live_object3 = require("@dxos/live-object");
|
|
122
125
|
var import_react_ui_menu = require("@dxos/react-ui-menu");
|
|
123
126
|
var translationKey = "table";
|
|
@@ -271,7 +274,7 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
|
271
274
|
typename: state.typename
|
|
272
275
|
}).runSync();
|
|
273
276
|
if (schema2) {
|
|
274
|
-
const obj = space.db.add((0, import_echo2.
|
|
277
|
+
const obj = space.db.add((0, import_echo2.create)(schema2, values));
|
|
275
278
|
state.onCreate?.(obj);
|
|
276
279
|
}
|
|
277
280
|
void modals.close();
|
|
@@ -310,30 +313,63 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
|
310
313
|
onCancel: handleCancel
|
|
311
314
|
}), /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Arrow, null))));
|
|
312
315
|
};
|
|
316
|
+
var getRefTargetObj = (space, id) => {
|
|
317
|
+
if (space && id) {
|
|
318
|
+
return space?.db.getObjectById(id);
|
|
319
|
+
} else {
|
|
320
|
+
return void 0;
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
var RefPanel = ({ model, modals }) => {
|
|
324
|
+
const state = modals.state.value;
|
|
325
|
+
const space = model?.space;
|
|
326
|
+
const targetObj = getRefTargetObj(space, state?.type === "refPanel" ? state.targetId : void 0);
|
|
327
|
+
const schema = space && state?.type === "refPanel" ? space.db.schemaRegistry.getSchema(state.typename) : void 0;
|
|
328
|
+
if (!model.view || !model.projection) {
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Popover.Root, {
|
|
332
|
+
modal: false,
|
|
333
|
+
open: state?.type === "refPanel" && !!targetObj && !!schema,
|
|
334
|
+
onOpenChange: (nextOpen) => {
|
|
335
|
+
if (!nextOpen) {
|
|
336
|
+
return modals.close();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Popover.VirtualTrigger, {
|
|
340
|
+
virtualRef: modals.trigger
|
|
341
|
+
}), /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Popover.Portal, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Popover.Content, {
|
|
342
|
+
classNames: "md:is-64"
|
|
343
|
+
}, targetObj && schema && /* @__PURE__ */ import_react5.default.createElement(import_react_ui_form3.Form, {
|
|
344
|
+
readonly: true,
|
|
345
|
+
values: targetObj,
|
|
346
|
+
schema
|
|
347
|
+
}), /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Popover.Arrow, null))));
|
|
348
|
+
};
|
|
313
349
|
var RowActionsMenu = ({ model, modals }) => {
|
|
314
|
-
const { t } = (0,
|
|
350
|
+
const { t } = (0, import_react_ui6.useTranslation)(translationKey);
|
|
315
351
|
const hasSelection = model.selection.hasSelection.value;
|
|
316
352
|
const state = modals.state.value;
|
|
317
353
|
if (state?.type !== "row") {
|
|
318
354
|
return null;
|
|
319
355
|
}
|
|
320
|
-
return /* @__PURE__ */
|
|
356
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Root, {
|
|
321
357
|
modal: false,
|
|
322
358
|
open: true,
|
|
323
359
|
onOpenChange: modals.close
|
|
324
|
-
}, /* @__PURE__ */
|
|
360
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.VirtualTrigger, {
|
|
325
361
|
virtualRef: modals.trigger
|
|
326
|
-
}), /* @__PURE__ */
|
|
362
|
+
}), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Content, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Viewport, null, model.features.dataEditable !== false && /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Item, {
|
|
327
363
|
"data-testid": "row-menu-delete",
|
|
328
364
|
onClick: () => model.deleteRow(state.rowIndex)
|
|
329
|
-
}, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */
|
|
365
|
+
}, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Item, {
|
|
330
366
|
key: action.id,
|
|
331
367
|
"data-testid": `row-action-${action.id}`,
|
|
332
368
|
onClick: () => {
|
|
333
369
|
modals.close();
|
|
334
370
|
model.handleRowAction(action.id, state.rowIndex);
|
|
335
371
|
}
|
|
336
|
-
}, t(action.translationKey)))), /* @__PURE__ */
|
|
372
|
+
}, t(action.translationKey)))), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Arrow, null)));
|
|
337
373
|
};
|
|
338
374
|
var getBaseSchems = ({ typename, properties, jsonSchema, schema }) => {
|
|
339
375
|
if (typename && properties) {
|
|
@@ -365,7 +401,7 @@ var makeDynamicTable = ({ typename, jsonSchema, properties }) => {
|
|
|
365
401
|
fields: properties.map((property) => property.name)
|
|
366
402
|
}
|
|
367
403
|
});
|
|
368
|
-
const table = (0, import_live_object2.
|
|
404
|
+
const table = (0, import_live_object2.create)(import_chunk_TGG6OZ54.TableType, {
|
|
369
405
|
name: "dynamic-table",
|
|
370
406
|
view: (0, import_live_object2.makeRef)(view)
|
|
371
407
|
});
|
|
@@ -414,7 +450,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
|
|
|
414
450
|
if (!schema) {
|
|
415
451
|
throw new Error(`Schema not found: ${typename}`);
|
|
416
452
|
}
|
|
417
|
-
const fields = (0, import_schema2.getSchemaProperties)(schema.ast).map((prop) => prop.name);
|
|
453
|
+
const fields = (0, import_schema2.getSchemaProperties)(schema.ast).filter((prop) => prop.format !== import_echo_schema4.FormatEnum.Ref).map((prop) => prop.name);
|
|
418
454
|
table.view = (0, import_echo3.makeRef)((0, import_schema2.createView)({
|
|
419
455
|
// TODO(ZaymonFC): Don't hardcode name?
|
|
420
456
|
name: "View",
|
|
@@ -436,7 +472,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
|
|
|
436
472
|
}));
|
|
437
473
|
createProjection(schema, table.view.target);
|
|
438
474
|
if (initialRow) {
|
|
439
|
-
space.db.add((0, import_echo3.
|
|
475
|
+
space.db.add((0, import_echo3.create)(schema, {}));
|
|
440
476
|
}
|
|
441
477
|
return schema;
|
|
442
478
|
}
|
|
@@ -538,6 +574,26 @@ var columnSettingsButton = {
|
|
|
538
574
|
fieldId: el.getAttribute("data-field-id")
|
|
539
575
|
})
|
|
540
576
|
};
|
|
577
|
+
var referencedCellButton = {
|
|
578
|
+
attr: BUTTON_IDENTIFIERS.referencedCell,
|
|
579
|
+
icon: "ph--link-simple-horizontal--regular",
|
|
580
|
+
render: ({ targetId, schemaId }) => {
|
|
581
|
+
return createButton({
|
|
582
|
+
attr: BUTTON_IDENTIFIERS.referencedCell,
|
|
583
|
+
icon: referencedCellButton.icon,
|
|
584
|
+
data: {
|
|
585
|
+
"data-target-id": targetId,
|
|
586
|
+
"data-schema-id": schemaId
|
|
587
|
+
},
|
|
588
|
+
testId: "table-ref-cell-button"
|
|
589
|
+
});
|
|
590
|
+
},
|
|
591
|
+
getData: (el) => ({
|
|
592
|
+
type: "referencedCell",
|
|
593
|
+
targetId: el.getAttribute("data-target-id"),
|
|
594
|
+
schemaId: el.getAttribute("data-schema-id")
|
|
595
|
+
})
|
|
596
|
+
};
|
|
541
597
|
var rowMenuButton = {
|
|
542
598
|
attr: BUTTON_IDENTIFIERS.rowMenu,
|
|
543
599
|
icon: "ph--dots-three--regular",
|
|
@@ -582,6 +638,7 @@ var sortButton = {
|
|
|
582
638
|
var tableButtons = {
|
|
583
639
|
addColumn: addColumnButton,
|
|
584
640
|
columnSettings: columnSettingsButton,
|
|
641
|
+
referencedCell: referencedCellButton,
|
|
585
642
|
rowMenu: rowMenuButton,
|
|
586
643
|
sort: sortButton
|
|
587
644
|
};
|
|
@@ -874,27 +931,13 @@ var TableSorting = class {
|
|
|
874
931
|
const refValue = (0, import_echo_schema5.getValue)(value.target, field.referencePath);
|
|
875
932
|
return refValue;
|
|
876
933
|
}
|
|
877
|
-
return (0,
|
|
934
|
+
return (0, import_react_ui_form5.formatForDisplay)({
|
|
878
935
|
type,
|
|
879
936
|
format,
|
|
880
937
|
value
|
|
881
938
|
});
|
|
882
939
|
}
|
|
883
940
|
};
|
|
884
|
-
var TAG_PATTERN_REGEX = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
885
|
-
var extractTagIds = (value) => {
|
|
886
|
-
if (typeof value !== "string") {
|
|
887
|
-
return void 0;
|
|
888
|
-
}
|
|
889
|
-
const ids = [];
|
|
890
|
-
let match;
|
|
891
|
-
while ((match = TAG_PATTERN_REGEX.exec(value)) !== null) {
|
|
892
|
-
if (match[2]) {
|
|
893
|
-
ids.push(match[2]);
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
return ids.length > 0 ? ids : void 0;
|
|
897
|
-
};
|
|
898
941
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/model/table-model.ts";
|
|
899
942
|
var defaultFeatures = {
|
|
900
943
|
selection: {
|
|
@@ -972,7 +1015,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
972
1015
|
return (0, import_echo_schema3.getValue)(value.target, field.referencePath);
|
|
973
1016
|
}
|
|
974
1017
|
default: {
|
|
975
|
-
return (0,
|
|
1018
|
+
return (0, import_react_ui_form4.formatForEditing)({
|
|
976
1019
|
type: props.type,
|
|
977
1020
|
format: props.format,
|
|
978
1021
|
value
|
|
@@ -990,27 +1033,13 @@ var TableModel = class extends import_context.Resource {
|
|
|
990
1033
|
const { props } = this._projection.getFieldProjection(field.id);
|
|
991
1034
|
switch (props.format) {
|
|
992
1035
|
case import_echo_schema3.FormatEnum.Ref: {
|
|
993
|
-
if ((0, import_live_object.
|
|
1036
|
+
if ((0, import_live_object.isReactiveObject)(value)) {
|
|
994
1037
|
(0, import_echo_schema3.setValue)(this._rows.value[rowIdx], field.path, (0, import_live_object.makeRef)(value));
|
|
995
1038
|
}
|
|
996
1039
|
break;
|
|
997
1040
|
}
|
|
998
|
-
case import_echo_schema3.FormatEnum.SingleSelect: {
|
|
999
|
-
const ids = extractTagIds(value);
|
|
1000
|
-
if (ids && ids.length > 0) {
|
|
1001
|
-
(0, import_echo_schema3.setValue)(this._rows.value[rowIdx], field.path, ids[0]);
|
|
1002
|
-
}
|
|
1003
|
-
break;
|
|
1004
|
-
}
|
|
1005
|
-
case import_echo_schema3.FormatEnum.MultiSelect: {
|
|
1006
|
-
const ids = extractTagIds(value);
|
|
1007
|
-
if (ids) {
|
|
1008
|
-
(0, import_echo_schema3.setValue)(this._rows.value[rowIdx], field.path, ids);
|
|
1009
|
-
}
|
|
1010
|
-
break;
|
|
1011
|
-
}
|
|
1012
1041
|
default: {
|
|
1013
|
-
(0, import_echo_schema3.setValue)(this._rows.value[rowIdx], field.path, (0,
|
|
1042
|
+
(0, import_echo_schema3.setValue)(this._rows.value[rowIdx], field.path, (0, import_react_ui_form4.parseValue)({
|
|
1014
1043
|
type: props.type,
|
|
1015
1044
|
format: props.format,
|
|
1016
1045
|
value
|
|
@@ -1029,7 +1058,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
1029
1058
|
};
|
|
1030
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.", {
|
|
1031
1060
|
F: __dxlog_file,
|
|
1032
|
-
L:
|
|
1061
|
+
L: 114,
|
|
1033
1062
|
S: this,
|
|
1034
1063
|
A: [
|
|
1035
1064
|
"!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === 'single')",
|
|
@@ -1089,7 +1118,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
1089
1118
|
get columnMeta() {
|
|
1090
1119
|
(0, import_invariant2.invariant)(this._columnMeta, void 0, {
|
|
1091
1120
|
F: __dxlog_file,
|
|
1092
|
-
L:
|
|
1121
|
+
L: 183,
|
|
1093
1122
|
S: this,
|
|
1094
1123
|
A: [
|
|
1095
1124
|
"this._columnMeta",
|
|
@@ -1378,7 +1407,7 @@ var TablePresentation = class {
|
|
|
1378
1407
|
return (0, import_echo_schema6.getValue)(value.target, field.referencePath);
|
|
1379
1408
|
}
|
|
1380
1409
|
default: {
|
|
1381
|
-
return (0,
|
|
1410
|
+
return (0, import_react_ui_form6.formatForDisplay)({
|
|
1382
1411
|
type: props.type,
|
|
1383
1412
|
format: props.format,
|
|
1384
1413
|
value
|
|
@@ -1388,7 +1417,7 @@ var TablePresentation = class {
|
|
|
1388
1417
|
}
|
|
1389
1418
|
};
|
|
1390
1419
|
const classes = [];
|
|
1391
|
-
const formatClasses = (0,
|
|
1420
|
+
const formatClasses = (0, import_react_ui_form6.cellClassesForFieldType)({
|
|
1392
1421
|
type: props.type,
|
|
1393
1422
|
format: props.format
|
|
1394
1423
|
});
|
|
@@ -1405,8 +1434,10 @@ var TablePresentation = class {
|
|
|
1405
1434
|
if (props.format === import_echo_schema6.FormatEnum.Ref && props.referenceSchema) {
|
|
1406
1435
|
const targetObj = (0, import_echo_schema6.getValue)(obj, field.path)?.target;
|
|
1407
1436
|
if (targetObj) {
|
|
1408
|
-
|
|
1409
|
-
|
|
1437
|
+
cell.accessoryHtml = tableButtons.referencedCell.render({
|
|
1438
|
+
targetId: targetObj.id,
|
|
1439
|
+
schemaId: props.referenceSchema
|
|
1440
|
+
});
|
|
1410
1441
|
}
|
|
1411
1442
|
}
|
|
1412
1443
|
if (props.format === import_echo_schema6.FormatEnum.Boolean) {
|
|
@@ -1640,9 +1671,9 @@ var createOption = (text) => ({
|
|
|
1640
1671
|
var isCreateOption = (data) => typeof data === "object" && data[newValue];
|
|
1641
1672
|
var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }) => {
|
|
1642
1673
|
const { id: gridId, editing, setEditing } = (0, import_react_ui_grid4.useGridContext)("TableCellEditor", __gridScope);
|
|
1643
|
-
const suppressNextBlur = (0,
|
|
1644
|
-
const { themeMode } = (0,
|
|
1645
|
-
const fieldProjection = (0,
|
|
1674
|
+
const suppressNextBlur = (0, import_react7.useRef)(false);
|
|
1675
|
+
const { themeMode } = (0, import_react_ui7.useThemeContext)();
|
|
1676
|
+
const fieldProjection = (0, import_react7.useMemo)(() => {
|
|
1646
1677
|
if (!model || !editing) {
|
|
1647
1678
|
return;
|
|
1648
1679
|
}
|
|
@@ -1663,7 +1694,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1663
1694
|
model,
|
|
1664
1695
|
editing
|
|
1665
1696
|
]);
|
|
1666
|
-
const handleEnter = (0,
|
|
1697
|
+
const handleEnter = (0, import_react7.useCallback)((value) => {
|
|
1667
1698
|
if (!model || !editing) {
|
|
1668
1699
|
return;
|
|
1669
1700
|
}
|
|
@@ -1679,7 +1710,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1679
1710
|
onFocus,
|
|
1680
1711
|
setEditing
|
|
1681
1712
|
]);
|
|
1682
|
-
const handleBlur = (0,
|
|
1713
|
+
const handleBlur = (0, import_react7.useCallback)((value) => {
|
|
1683
1714
|
if (!model || !editing) {
|
|
1684
1715
|
return;
|
|
1685
1716
|
}
|
|
@@ -1695,7 +1726,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1695
1726
|
model,
|
|
1696
1727
|
editing
|
|
1697
1728
|
]);
|
|
1698
|
-
const handleClose = (0,
|
|
1729
|
+
const handleClose = (0, import_react7.useCallback)((value, event) => {
|
|
1699
1730
|
if (!model || !editing || !fieldProjection) {
|
|
1700
1731
|
return;
|
|
1701
1732
|
}
|
|
@@ -1711,7 +1742,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1711
1742
|
onEnter,
|
|
1712
1743
|
fieldProjection
|
|
1713
1744
|
]);
|
|
1714
|
-
const extension = (0,
|
|
1745
|
+
const extension = (0, import_react7.useMemo)(() => {
|
|
1715
1746
|
if (!fieldProjection) {
|
|
1716
1747
|
return [];
|
|
1717
1748
|
}
|
|
@@ -1792,7 +1823,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1792
1823
|
handleClose,
|
|
1793
1824
|
themeMode
|
|
1794
1825
|
]);
|
|
1795
|
-
const getCellContent = (0,
|
|
1826
|
+
const getCellContent = (0, import_react7.useCallback)(() => {
|
|
1796
1827
|
if (model && editing) {
|
|
1797
1828
|
const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
|
|
1798
1829
|
const { col } = cell;
|
|
@@ -1838,7 +1869,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1838
1869
|
model,
|
|
1839
1870
|
editing
|
|
1840
1871
|
]);
|
|
1841
|
-
return /* @__PURE__ */
|
|
1872
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_react_ui_grid4.GridCellEditor, {
|
|
1842
1873
|
extension,
|
|
1843
1874
|
getCellContent,
|
|
1844
1875
|
onBlur: handleBlur
|
|
@@ -1869,6 +1900,8 @@ var determineNavigationDelta = ({ key, shift }) => {
|
|
|
1869
1900
|
return shift ? -1 : 1;
|
|
1870
1901
|
};
|
|
1871
1902
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
|
|
1903
|
+
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";
|
|
1904
|
+
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";
|
|
1872
1905
|
var TableRoot = ({ children, role }) => {
|
|
1873
1906
|
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
1874
1907
|
role: "none",
|
|
@@ -1890,18 +1923,14 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
1890
1923
|
}, [
|
|
1891
1924
|
model
|
|
1892
1925
|
]);
|
|
1893
|
-
const getCells = (0, import_react.useCallback)((range, plane) => presentation?.getCells(range, plane) ?? {}, [
|
|
1894
|
-
presentation
|
|
1895
|
-
]);
|
|
1896
1926
|
(0, import_react.useEffect)(() => {
|
|
1897
1927
|
if (!presentation || !dxGrid) {
|
|
1898
1928
|
return;
|
|
1899
1929
|
}
|
|
1900
|
-
dxGrid.getCells = getCells;
|
|
1930
|
+
dxGrid.getCells = (range, plane) => presentation.getCells(range, plane);
|
|
1901
1931
|
}, [
|
|
1902
1932
|
presentation,
|
|
1903
|
-
dxGrid
|
|
1904
|
-
getCells
|
|
1933
|
+
dxGrid
|
|
1905
1934
|
]);
|
|
1906
1935
|
(0, import_react.useImperativeHandle)(forwardedRef, () => {
|
|
1907
1936
|
if (!presentation || !dxGrid) {
|
|
@@ -1957,6 +1986,10 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
1957
1986
|
modals.showColumnCreator();
|
|
1958
1987
|
break;
|
|
1959
1988
|
}
|
|
1989
|
+
case "referencedCell": {
|
|
1990
|
+
modals.showReferencePanel(data.targetId, data.schemaId);
|
|
1991
|
+
break;
|
|
1992
|
+
}
|
|
1960
1993
|
case "sort": {
|
|
1961
1994
|
model?.sorting?.toggleSort(data.fieldId);
|
|
1962
1995
|
break;
|
|
@@ -2068,7 +2101,7 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
2068
2101
|
const space = model.space;
|
|
2069
2102
|
(0, import_invariant.invariant)(space, void 0, {
|
|
2070
2103
|
F: __dxlog_file4,
|
|
2071
|
-
L:
|
|
2104
|
+
L: 312,
|
|
2072
2105
|
S: void 0,
|
|
2073
2106
|
A: [
|
|
2074
2107
|
"space",
|
|
@@ -2119,7 +2152,7 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
2119
2152
|
onFocus: handleFocus,
|
|
2120
2153
|
onQuery: handleQuery
|
|
2121
2154
|
}), /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Content, {
|
|
2122
|
-
className: (0, import_react_ui_theme.mx)("[--dx-grid-base:var(--surface-bg)]",
|
|
2155
|
+
className: (0, import_react_ui_theme.mx)("[--dx-grid-base:var(--surface-bg)]", inlineEndLine, blockEndLine),
|
|
2123
2156
|
frozen,
|
|
2124
2157
|
// getCells={getCells}
|
|
2125
2158
|
columns: model.columnMeta.value,
|
|
@@ -2144,6 +2177,9 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
2144
2177
|
}), /* @__PURE__ */ import_react.default.createElement(CreateRefPanel, {
|
|
2145
2178
|
model,
|
|
2146
2179
|
modals
|
|
2180
|
+
}), /* @__PURE__ */ import_react.default.createElement(RefPanel, {
|
|
2181
|
+
model,
|
|
2182
|
+
modals
|
|
2147
2183
|
}));
|
|
2148
2184
|
});
|
|
2149
2185
|
var Table = {
|
|
@@ -2151,8 +2187,8 @@ var Table = {
|
|
|
2151
2187
|
Main: TableMain
|
|
2152
2188
|
};
|
|
2153
2189
|
var useTableModel = ({ table, projection, rows, rowActions, features, onSelectionChanged, onRowAction, ...props }) => {
|
|
2154
|
-
const [model, setModel] = (0,
|
|
2155
|
-
(0,
|
|
2190
|
+
const [model, setModel] = (0, import_react9.useState)();
|
|
2191
|
+
(0, import_react9.useEffect)(() => {
|
|
2156
2192
|
if (!table || !projection) {
|
|
2157
2193
|
return;
|
|
2158
2194
|
}
|
|
@@ -2182,7 +2218,7 @@ var useTableModel = ({ table, projection, rows, rowActions, features, onSelectio
|
|
|
2182
2218
|
features,
|
|
2183
2219
|
rowActions
|
|
2184
2220
|
]);
|
|
2185
|
-
(0,
|
|
2221
|
+
(0, import_react9.useEffect)(() => {
|
|
2186
2222
|
if (rows) {
|
|
2187
2223
|
model?.setRows(rows);
|
|
2188
2224
|
}
|
|
@@ -2194,7 +2230,7 @@ var useTableModel = ({ table, projection, rows, rowActions, features, onSelectio
|
|
|
2194
2230
|
table?.id,
|
|
2195
2231
|
table?.view?.target?.query.typename
|
|
2196
2232
|
].filter(import_util2.isNonNullable));
|
|
2197
|
-
(0,
|
|
2233
|
+
(0, import_react9.useEffect)(() => {
|
|
2198
2234
|
if (!model) {
|
|
2199
2235
|
return;
|
|
2200
2236
|
}
|
|
@@ -2216,7 +2252,7 @@ var useTableModel = ({ table, projection, rows, rowActions, features, onSelectio
|
|
|
2216
2252
|
return model;
|
|
2217
2253
|
};
|
|
2218
2254
|
var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, properties, jsonSchema, schema, rowActions, onRowClick, onRowAction, ...props }) => {
|
|
2219
|
-
const { table, projection } = (0,
|
|
2255
|
+
const { table, projection } = (0, import_react8.useMemo)(() => {
|
|
2220
2256
|
const props2 = getBaseSchems({
|
|
2221
2257
|
typename: name,
|
|
2222
2258
|
properties,
|
|
@@ -2233,14 +2269,14 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
|
|
|
2233
2269
|
schema,
|
|
2234
2270
|
jsonSchema
|
|
2235
2271
|
]);
|
|
2236
|
-
const tableRef = (0,
|
|
2237
|
-
const handleCellUpdate = (0,
|
|
2272
|
+
const tableRef = (0, import_react8.useRef)(null);
|
|
2273
|
+
const handleCellUpdate = (0, import_react8.useCallback)((cell) => {
|
|
2238
2274
|
tableRef.current?.update?.(cell);
|
|
2239
2275
|
}, []);
|
|
2240
|
-
const handleRowOrderChange = (0,
|
|
2276
|
+
const handleRowOrderChange = (0, import_react8.useCallback)(() => {
|
|
2241
2277
|
tableRef.current?.update?.();
|
|
2242
2278
|
}, []);
|
|
2243
|
-
const features = (0,
|
|
2279
|
+
const features = (0, import_react_ui8.useDefaultValue)(props.features, () => ({
|
|
2244
2280
|
selection: {
|
|
2245
2281
|
enabled: false
|
|
2246
2282
|
},
|
|
@@ -2256,20 +2292,20 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
|
|
|
2256
2292
|
onRowOrderChange: handleRowOrderChange,
|
|
2257
2293
|
onRowAction
|
|
2258
2294
|
});
|
|
2259
|
-
const presentation = (0,
|
|
2295
|
+
const presentation = (0, import_react8.useMemo)(() => {
|
|
2260
2296
|
if (model) {
|
|
2261
2297
|
return new TablePresentation(model);
|
|
2262
2298
|
}
|
|
2263
2299
|
}, [
|
|
2264
2300
|
model
|
|
2265
2301
|
]);
|
|
2266
|
-
return /* @__PURE__ */
|
|
2302
|
+
return /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
2267
2303
|
role: "none",
|
|
2268
2304
|
className: (0, import_react_ui_theme3.mx)("is-full bs-full grow grid", classNames)
|
|
2269
|
-
}, /* @__PURE__ */
|
|
2305
|
+
}, /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
2270
2306
|
role: "none",
|
|
2271
2307
|
className: "grid min-bs-0 overflow-hidden"
|
|
2272
|
-
}, /* @__PURE__ */
|
|
2308
|
+
}, /* @__PURE__ */ import_react8.default.createElement(Table.Root, null, /* @__PURE__ */ import_react8.default.createElement(Table.Main, {
|
|
2273
2309
|
ref: tableRef,
|
|
2274
2310
|
model,
|
|
2275
2311
|
presentation,
|
|
@@ -2329,18 +2365,18 @@ var createTableToolbarActions = (state) => {
|
|
|
2329
2365
|
};
|
|
2330
2366
|
};
|
|
2331
2367
|
var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
|
|
2332
|
-
const state = (0,
|
|
2368
|
+
const state = (0, import_react10.useMemo)(() => (0, import_live_object3.create)({
|
|
2333
2369
|
viewDirty
|
|
2334
2370
|
}), []);
|
|
2335
|
-
const actionsCreator = (0,
|
|
2371
|
+
const actionsCreator = (0, import_react10.useCallback)(() => createTableToolbarActions(state), [
|
|
2336
2372
|
state
|
|
2337
2373
|
]);
|
|
2338
2374
|
const menu = (0, import_react_ui_menu.useMenuActions)(actionsCreator);
|
|
2339
|
-
return /* @__PURE__ */
|
|
2375
|
+
return /* @__PURE__ */ import_react10.default.createElement(import_react_ui_menu.MenuProvider, {
|
|
2340
2376
|
...menu,
|
|
2341
2377
|
attendableId,
|
|
2342
2378
|
onAction
|
|
2343
|
-
}, /* @__PURE__ */
|
|
2379
|
+
}, /* @__PURE__ */ import_react10.default.createElement(import_react_ui_menu.ToolbarMenu, {
|
|
2344
2380
|
classNames
|
|
2345
2381
|
}));
|
|
2346
2382
|
};
|