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