@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
|
@@ -36,13 +36,13 @@ var translations_default = [
|
|
|
36
36
|
];
|
|
37
37
|
|
|
38
38
|
// packages/ui/react-ui-table/src/components/Table/Table.tsx
|
|
39
|
-
import
|
|
39
|
+
import React7, { forwardRef, useCallback as useCallback4, useImperativeHandle, useState as useState2, useMemo as useMemo4, useEffect as useEffect2 } from "react";
|
|
40
40
|
import { getValue as getValue4 } from "@dxos/echo-schema";
|
|
41
41
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
42
42
|
import { Filter } from "@dxos/react-client/echo";
|
|
43
43
|
import { useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
44
44
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
45
|
-
import { closestCell, Grid
|
|
45
|
+
import { closestCell, Grid } from "@dxos/react-ui-grid";
|
|
46
46
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
47
47
|
import { isNotFalsy, safeParseInt } from "@dxos/util";
|
|
48
48
|
|
|
@@ -152,7 +152,7 @@ var ColumnSettings = ({ model, modals, onNewColumn }) => {
|
|
|
152
152
|
// packages/ui/react-ui-table/src/components/Table/CreateRefPanel.tsx
|
|
153
153
|
import React3, { useCallback as useCallback2, useMemo as useMemo2 } from "react";
|
|
154
154
|
import { S } from "@dxos/echo-schema";
|
|
155
|
-
import {
|
|
155
|
+
import { create } from "@dxos/react-client/echo";
|
|
156
156
|
import { Popover } from "@dxos/react-ui";
|
|
157
157
|
import { Form } from "@dxos/react-ui-form";
|
|
158
158
|
import { useGridContext } from "@dxos/react-ui-grid";
|
|
@@ -183,7 +183,7 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
|
183
183
|
typename: state.typename
|
|
184
184
|
}).runSync();
|
|
185
185
|
if (schema2) {
|
|
186
|
-
const obj = space.db.add(
|
|
186
|
+
const obj = space.db.add(create(schema2, values));
|
|
187
187
|
state.onCreate?.(obj);
|
|
188
188
|
}
|
|
189
189
|
void modals.close();
|
|
@@ -223,8 +223,46 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
|
223
223
|
}), /* @__PURE__ */ React3.createElement(Popover.Arrow, null))));
|
|
224
224
|
};
|
|
225
225
|
|
|
226
|
-
// packages/ui/react-ui-table/src/components/Table/
|
|
226
|
+
// packages/ui/react-ui-table/src/components/Table/RefPanel.tsx
|
|
227
227
|
import React4 from "react";
|
|
228
|
+
import { Popover as Popover2 } from "@dxos/react-ui";
|
|
229
|
+
import { Form as Form2 } from "@dxos/react-ui-form";
|
|
230
|
+
var getRefTargetObj = (space, id) => {
|
|
231
|
+
if (space && id) {
|
|
232
|
+
return space?.db.getObjectById(id);
|
|
233
|
+
} else {
|
|
234
|
+
return void 0;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
var RefPanel = ({ model, modals }) => {
|
|
238
|
+
const state = modals.state.value;
|
|
239
|
+
const space = model?.space;
|
|
240
|
+
const targetObj = getRefTargetObj(space, state?.type === "refPanel" ? state.targetId : void 0);
|
|
241
|
+
const schema = space && state?.type === "refPanel" ? space.db.schemaRegistry.getSchema(state.typename) : void 0;
|
|
242
|
+
if (!model.view || !model.projection) {
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
return /* @__PURE__ */ React4.createElement(Popover2.Root, {
|
|
246
|
+
modal: false,
|
|
247
|
+
open: state?.type === "refPanel" && !!targetObj && !!schema,
|
|
248
|
+
onOpenChange: (nextOpen) => {
|
|
249
|
+
if (!nextOpen) {
|
|
250
|
+
return modals.close();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}, /* @__PURE__ */ React4.createElement(Popover2.VirtualTrigger, {
|
|
254
|
+
virtualRef: modals.trigger
|
|
255
|
+
}), /* @__PURE__ */ React4.createElement(Popover2.Portal, null, /* @__PURE__ */ React4.createElement(Popover2.Content, {
|
|
256
|
+
classNames: "md:is-64"
|
|
257
|
+
}, targetObj && schema && /* @__PURE__ */ React4.createElement(Form2, {
|
|
258
|
+
readonly: true,
|
|
259
|
+
values: targetObj,
|
|
260
|
+
schema
|
|
261
|
+
}), /* @__PURE__ */ React4.createElement(Popover2.Arrow, null))));
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
// packages/ui/react-ui-table/src/components/Table/RowActionsMenu.tsx
|
|
265
|
+
import React5 from "react";
|
|
228
266
|
import { DropdownMenu as DropdownMenu3, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
229
267
|
var RowActionsMenu = ({ model, modals }) => {
|
|
230
268
|
const { t } = useTranslation2(translationKey);
|
|
@@ -233,23 +271,23 @@ var RowActionsMenu = ({ model, modals }) => {
|
|
|
233
271
|
if (state?.type !== "row") {
|
|
234
272
|
return null;
|
|
235
273
|
}
|
|
236
|
-
return /* @__PURE__ */
|
|
274
|
+
return /* @__PURE__ */ React5.createElement(DropdownMenu3.Root, {
|
|
237
275
|
modal: false,
|
|
238
276
|
open: true,
|
|
239
277
|
onOpenChange: modals.close
|
|
240
|
-
}, /* @__PURE__ */
|
|
278
|
+
}, /* @__PURE__ */ React5.createElement(DropdownMenu3.VirtualTrigger, {
|
|
241
279
|
virtualRef: modals.trigger
|
|
242
|
-
}), /* @__PURE__ */
|
|
280
|
+
}), /* @__PURE__ */ React5.createElement(DropdownMenu3.Content, null, /* @__PURE__ */ React5.createElement(DropdownMenu3.Viewport, null, model.features.dataEditable !== false && /* @__PURE__ */ React5.createElement(DropdownMenu3.Item, {
|
|
243
281
|
"data-testid": "row-menu-delete",
|
|
244
282
|
onClick: () => model.deleteRow(state.rowIndex)
|
|
245
|
-
}, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */
|
|
283
|
+
}, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */ React5.createElement(DropdownMenu3.Item, {
|
|
246
284
|
key: action.id,
|
|
247
285
|
"data-testid": `row-action-${action.id}`,
|
|
248
286
|
onClick: () => {
|
|
249
287
|
modals.close();
|
|
250
288
|
model.handleRowAction(action.id, state.rowIndex);
|
|
251
289
|
}
|
|
252
|
-
}, t(action.translationKey)))), /* @__PURE__ */
|
|
290
|
+
}, t(action.translationKey)))), /* @__PURE__ */ React5.createElement(DropdownMenu3.Arrow, null)));
|
|
253
291
|
};
|
|
254
292
|
|
|
255
293
|
// packages/ui/react-ui-table/src/model/table-model.ts
|
|
@@ -257,7 +295,7 @@ import { computed as computed3, effect as effect2, signal as signal3 } from "@pr
|
|
|
257
295
|
import { Resource as Resource2 } from "@dxos/context";
|
|
258
296
|
import { FormatEnum as FormatEnum3, getValue as getValue2, setValue } from "@dxos/echo-schema";
|
|
259
297
|
import { invariant } from "@dxos/invariant";
|
|
260
|
-
import {
|
|
298
|
+
import { isReactiveObject, makeRef as makeRef3 } from "@dxos/live-object";
|
|
261
299
|
import { formatForEditing, parseValue } from "@dxos/react-ui-form";
|
|
262
300
|
|
|
263
301
|
// packages/ui/react-ui-table/src/model/selection-model.ts
|
|
@@ -265,7 +303,7 @@ import { computed, effect, signal } from "@preact/signals-core";
|
|
|
265
303
|
import { Resource } from "@dxos/context";
|
|
266
304
|
|
|
267
305
|
// packages/ui/react-ui-table/src/util/dynamic-table.ts
|
|
268
|
-
import {
|
|
306
|
+
import { create as create2, makeRef } from "@dxos/live-object";
|
|
269
307
|
import { createView, getSchemaFromPropertyDefinitions, ViewProjection } from "@dxos/schema";
|
|
270
308
|
var getBaseSchems = ({ typename, properties, jsonSchema, schema }) => {
|
|
271
309
|
if (typename && properties) {
|
|
@@ -297,7 +335,7 @@ var makeDynamicTable = ({ typename, jsonSchema, properties }) => {
|
|
|
297
335
|
fields: properties.map((property) => property.name)
|
|
298
336
|
}
|
|
299
337
|
});
|
|
300
|
-
const table =
|
|
338
|
+
const table = create2(TableType, {
|
|
301
339
|
name: "dynamic-table",
|
|
302
340
|
view: makeRef(view)
|
|
303
341
|
});
|
|
@@ -346,7 +384,7 @@ var touch = (value) => value;
|
|
|
346
384
|
// packages/ui/react-ui-table/src/util/table.ts
|
|
347
385
|
import { AST, Format, FormatEnum, S as S2, TypedObject, TypeEnum } from "@dxos/echo-schema";
|
|
348
386
|
import { PublicKey } from "@dxos/react-client";
|
|
349
|
-
import {
|
|
387
|
+
import { create as create3, makeRef as makeRef2 } from "@dxos/react-client/echo";
|
|
350
388
|
import { createFieldId, createView as createView2, getSchemaProperties, ViewProjection as ViewProjection2 } from "@dxos/schema";
|
|
351
389
|
var initializeTable = async ({ client, space, table, typename, initialRow = true }) => {
|
|
352
390
|
if (typename) {
|
|
@@ -354,7 +392,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
|
|
|
354
392
|
if (!schema) {
|
|
355
393
|
throw new Error(`Schema not found: ${typename}`);
|
|
356
394
|
}
|
|
357
|
-
const fields = getSchemaProperties(schema.ast).map((prop) => prop.name);
|
|
395
|
+
const fields = getSchemaProperties(schema.ast).filter((prop) => prop.format !== FormatEnum.Ref).map((prop) => prop.name);
|
|
358
396
|
table.view = makeRef2(createView2({
|
|
359
397
|
// TODO(ZaymonFC): Don't hardcode name?
|
|
360
398
|
name: "View",
|
|
@@ -376,7 +414,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
|
|
|
376
414
|
}));
|
|
377
415
|
createProjection(schema, table.view.target);
|
|
378
416
|
if (initialRow) {
|
|
379
|
-
space.db.add(
|
|
417
|
+
space.db.add(create3(schema, {}));
|
|
380
418
|
}
|
|
381
419
|
return schema;
|
|
382
420
|
}
|
|
@@ -480,6 +518,26 @@ var columnSettingsButton = {
|
|
|
480
518
|
fieldId: el.getAttribute("data-field-id")
|
|
481
519
|
})
|
|
482
520
|
};
|
|
521
|
+
var referencedCellButton = {
|
|
522
|
+
attr: BUTTON_IDENTIFIERS.referencedCell,
|
|
523
|
+
icon: "ph--link-simple-horizontal--regular",
|
|
524
|
+
render: ({ targetId, schemaId }) => {
|
|
525
|
+
return createButton({
|
|
526
|
+
attr: BUTTON_IDENTIFIERS.referencedCell,
|
|
527
|
+
icon: referencedCellButton.icon,
|
|
528
|
+
data: {
|
|
529
|
+
"data-target-id": targetId,
|
|
530
|
+
"data-schema-id": schemaId
|
|
531
|
+
},
|
|
532
|
+
testId: "table-ref-cell-button"
|
|
533
|
+
});
|
|
534
|
+
},
|
|
535
|
+
getData: (el) => ({
|
|
536
|
+
type: "referencedCell",
|
|
537
|
+
targetId: el.getAttribute("data-target-id"),
|
|
538
|
+
schemaId: el.getAttribute("data-schema-id")
|
|
539
|
+
})
|
|
540
|
+
};
|
|
483
541
|
var rowMenuButton = {
|
|
484
542
|
attr: BUTTON_IDENTIFIERS.rowMenu,
|
|
485
543
|
icon: "ph--dots-three--regular",
|
|
@@ -524,6 +582,7 @@ var sortButton = {
|
|
|
524
582
|
var tableButtons = {
|
|
525
583
|
addColumn: addColumnButton,
|
|
526
584
|
columnSettings: columnSettingsButton,
|
|
585
|
+
referencedCell: referencedCellButton,
|
|
527
586
|
rowMenu: rowMenuButton,
|
|
528
587
|
sort: sortButton
|
|
529
588
|
};
|
|
@@ -834,22 +893,6 @@ var TableSorting = class {
|
|
|
834
893
|
}
|
|
835
894
|
};
|
|
836
895
|
|
|
837
|
-
// packages/ui/react-ui-table/src/util/tag.ts
|
|
838
|
-
var TAG_PATTERN_REGEX = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
839
|
-
var extractTagIds = (value) => {
|
|
840
|
-
if (typeof value !== "string") {
|
|
841
|
-
return void 0;
|
|
842
|
-
}
|
|
843
|
-
const ids = [];
|
|
844
|
-
let match;
|
|
845
|
-
while ((match = TAG_PATTERN_REGEX.exec(value)) !== null) {
|
|
846
|
-
if (match[2]) {
|
|
847
|
-
ids.push(match[2]);
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
return ids.length > 0 ? ids : void 0;
|
|
851
|
-
};
|
|
852
|
-
|
|
853
896
|
// packages/ui/react-ui-table/src/model/table-model.ts
|
|
854
897
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/model/table-model.ts";
|
|
855
898
|
var defaultFeatures = {
|
|
@@ -949,25 +992,11 @@ var TableModel = class extends Resource2 {
|
|
|
949
992
|
const { props } = this._projection.getFieldProjection(field.id);
|
|
950
993
|
switch (props.format) {
|
|
951
994
|
case FormatEnum3.Ref: {
|
|
952
|
-
if (
|
|
995
|
+
if (isReactiveObject(value)) {
|
|
953
996
|
setValue(this._rows.value[rowIdx], field.path, makeRef3(value));
|
|
954
997
|
}
|
|
955
998
|
break;
|
|
956
999
|
}
|
|
957
|
-
case FormatEnum3.SingleSelect: {
|
|
958
|
-
const ids = extractTagIds(value);
|
|
959
|
-
if (ids && ids.length > 0) {
|
|
960
|
-
setValue(this._rows.value[rowIdx], field.path, ids[0]);
|
|
961
|
-
}
|
|
962
|
-
break;
|
|
963
|
-
}
|
|
964
|
-
case FormatEnum3.MultiSelect: {
|
|
965
|
-
const ids = extractTagIds(value);
|
|
966
|
-
if (ids) {
|
|
967
|
-
setValue(this._rows.value[rowIdx], field.path, ids);
|
|
968
|
-
}
|
|
969
|
-
break;
|
|
970
|
-
}
|
|
971
1000
|
default: {
|
|
972
1001
|
setValue(this._rows.value[rowIdx], field.path, parseValue({
|
|
973
1002
|
type: props.type,
|
|
@@ -988,7 +1017,7 @@ var TableModel = class extends Resource2 {
|
|
|
988
1017
|
};
|
|
989
1018
|
invariant(!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === "single"), "Single selection is not compatible with editable tables.", {
|
|
990
1019
|
F: __dxlog_file,
|
|
991
|
-
L:
|
|
1020
|
+
L: 114,
|
|
992
1021
|
S: this,
|
|
993
1022
|
A: [
|
|
994
1023
|
"!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === 'single')",
|
|
@@ -1048,7 +1077,7 @@ var TableModel = class extends Resource2 {
|
|
|
1048
1077
|
get columnMeta() {
|
|
1049
1078
|
invariant(this._columnMeta, void 0, {
|
|
1050
1079
|
F: __dxlog_file,
|
|
1051
|
-
L:
|
|
1080
|
+
L: 183,
|
|
1052
1081
|
S: this,
|
|
1053
1082
|
A: [
|
|
1054
1083
|
"this._columnMeta",
|
|
@@ -1274,7 +1303,7 @@ var ModalController = class {
|
|
|
1274
1303
|
|
|
1275
1304
|
// packages/ui/react-ui-table/src/model/table-presentation.ts
|
|
1276
1305
|
import { signal as signal5 } from "@preact/signals-core";
|
|
1277
|
-
import { FormatEnum as FormatEnum4,
|
|
1306
|
+
import { FormatEnum as FormatEnum4, getValue as getValue3 } from "@dxos/echo-schema";
|
|
1278
1307
|
import { cellClassesForFieldType, formatForDisplay as formatForDisplay2 } from "@dxos/react-ui-form";
|
|
1279
1308
|
import { toPlaneCellIndex } from "@dxos/react-ui-grid";
|
|
1280
1309
|
import { mx } from "@dxos/react-ui-theme";
|
|
@@ -1376,8 +1405,10 @@ var TablePresentation = class {
|
|
|
1376
1405
|
if (props.format === FormatEnum4.Ref && props.referenceSchema) {
|
|
1377
1406
|
const targetObj = getValue3(obj, field.path)?.target;
|
|
1378
1407
|
if (targetObj) {
|
|
1379
|
-
|
|
1380
|
-
|
|
1408
|
+
cell.accessoryHtml = tableButtons.referencedCell.render({
|
|
1409
|
+
targetId: targetObj.id,
|
|
1410
|
+
schemaId: props.referenceSchema
|
|
1411
|
+
});
|
|
1381
1412
|
}
|
|
1382
1413
|
}
|
|
1383
1414
|
if (props.format === FormatEnum4.Boolean) {
|
|
@@ -1569,7 +1600,7 @@ var cellClassesForRowSelection = (selected, selectionMode) => {
|
|
|
1569
1600
|
};
|
|
1570
1601
|
|
|
1571
1602
|
// packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx
|
|
1572
|
-
import
|
|
1603
|
+
import React6, { useCallback as useCallback3, useMemo as useMemo3, useRef } from "react";
|
|
1573
1604
|
import { FormatEnum as FormatEnum5 } from "@dxos/echo-schema";
|
|
1574
1605
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1575
1606
|
import { useThemeContext } from "@dxos/react-ui";
|
|
@@ -1824,7 +1855,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1824
1855
|
model,
|
|
1825
1856
|
editing
|
|
1826
1857
|
]);
|
|
1827
|
-
return /* @__PURE__ */
|
|
1858
|
+
return /* @__PURE__ */ React6.createElement(GridCellEditor, {
|
|
1828
1859
|
extension,
|
|
1829
1860
|
getCellContent,
|
|
1830
1861
|
onBlur: handleBlur
|
|
@@ -1857,8 +1888,10 @@ var determineNavigationDelta = ({ key, shift }) => {
|
|
|
1857
1888
|
|
|
1858
1889
|
// packages/ui/react-ui-table/src/components/Table/Table.tsx
|
|
1859
1890
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
|
|
1891
|
+
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";
|
|
1892
|
+
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";
|
|
1860
1893
|
var TableRoot = ({ children, role }) => {
|
|
1861
|
-
return /* @__PURE__ */
|
|
1894
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
1862
1895
|
role: "none",
|
|
1863
1896
|
className: mx2("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]")
|
|
1864
1897
|
}, children);
|
|
@@ -1878,18 +1911,14 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
1878
1911
|
}, [
|
|
1879
1912
|
model
|
|
1880
1913
|
]);
|
|
1881
|
-
const getCells = useCallback4((range, plane) => presentation?.getCells(range, plane) ?? {}, [
|
|
1882
|
-
presentation
|
|
1883
|
-
]);
|
|
1884
1914
|
useEffect2(() => {
|
|
1885
1915
|
if (!presentation || !dxGrid) {
|
|
1886
1916
|
return;
|
|
1887
1917
|
}
|
|
1888
|
-
dxGrid.getCells = getCells;
|
|
1918
|
+
dxGrid.getCells = (range, plane) => presentation.getCells(range, plane);
|
|
1889
1919
|
}, [
|
|
1890
1920
|
presentation,
|
|
1891
|
-
dxGrid
|
|
1892
|
-
getCells
|
|
1921
|
+
dxGrid
|
|
1893
1922
|
]);
|
|
1894
1923
|
useImperativeHandle(forwardedRef, () => {
|
|
1895
1924
|
if (!presentation || !dxGrid) {
|
|
@@ -1945,6 +1974,10 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
1945
1974
|
modals.showColumnCreator();
|
|
1946
1975
|
break;
|
|
1947
1976
|
}
|
|
1977
|
+
case "referencedCell": {
|
|
1978
|
+
modals.showReferencePanel(data.targetId, data.schemaId);
|
|
1979
|
+
break;
|
|
1980
|
+
}
|
|
1948
1981
|
case "sort": {
|
|
1949
1982
|
model?.sorting?.toggleSort(data.fieldId);
|
|
1950
1983
|
break;
|
|
@@ -2056,7 +2089,7 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
2056
2089
|
const space = model.space;
|
|
2057
2090
|
invariant3(space, void 0, {
|
|
2058
2091
|
F: __dxlog_file4,
|
|
2059
|
-
L:
|
|
2092
|
+
L: 312,
|
|
2060
2093
|
S: void 0,
|
|
2061
2094
|
A: [
|
|
2062
2095
|
"space",
|
|
@@ -2093,21 +2126,21 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
2093
2126
|
t
|
|
2094
2127
|
]);
|
|
2095
2128
|
if (!model || !modals) {
|
|
2096
|
-
return /* @__PURE__ */
|
|
2129
|
+
return /* @__PURE__ */ React7.createElement("span", {
|
|
2097
2130
|
role: "none",
|
|
2098
2131
|
className: "attention-surface"
|
|
2099
2132
|
});
|
|
2100
2133
|
}
|
|
2101
|
-
return /* @__PURE__ */
|
|
2134
|
+
return /* @__PURE__ */ React7.createElement(Grid.Root, {
|
|
2102
2135
|
id: model.id ?? "table-grid"
|
|
2103
|
-
}, /* @__PURE__ */
|
|
2136
|
+
}, /* @__PURE__ */ React7.createElement(TableCellEditor, {
|
|
2104
2137
|
model,
|
|
2105
2138
|
modals,
|
|
2106
2139
|
onEnter: handleEnter,
|
|
2107
2140
|
onFocus: handleFocus,
|
|
2108
2141
|
onQuery: handleQuery
|
|
2109
|
-
}), /* @__PURE__ */
|
|
2110
|
-
className: mx2("[--dx-grid-base:var(--surface-bg)]",
|
|
2142
|
+
}), /* @__PURE__ */ React7.createElement(Grid.Content, {
|
|
2143
|
+
className: mx2("[--dx-grid-base:var(--surface-bg)]", inlineEndLine, blockEndLine),
|
|
2111
2144
|
frozen,
|
|
2112
2145
|
// getCells={getCells}
|
|
2113
2146
|
columns: model.columnMeta.value,
|
|
@@ -2119,17 +2152,20 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
2119
2152
|
onKeyDown: handleKeyDown,
|
|
2120
2153
|
onWheelCapture: handleWheel,
|
|
2121
2154
|
ref: setDxGrid
|
|
2122
|
-
}), /* @__PURE__ */
|
|
2155
|
+
}), /* @__PURE__ */ React7.createElement(RowActionsMenu, {
|
|
2123
2156
|
model,
|
|
2124
2157
|
modals
|
|
2125
|
-
}), /* @__PURE__ */
|
|
2158
|
+
}), /* @__PURE__ */ React7.createElement(ColumnActionsMenu, {
|
|
2126
2159
|
model,
|
|
2127
2160
|
modals
|
|
2128
|
-
}), /* @__PURE__ */
|
|
2161
|
+
}), /* @__PURE__ */ React7.createElement(ColumnSettings, {
|
|
2129
2162
|
model,
|
|
2130
2163
|
modals,
|
|
2131
2164
|
onNewColumn: handleNewColumn
|
|
2132
|
-
}), /* @__PURE__ */
|
|
2165
|
+
}), /* @__PURE__ */ React7.createElement(CreateRefPanel, {
|
|
2166
|
+
model,
|
|
2167
|
+
modals
|
|
2168
|
+
}), /* @__PURE__ */ React7.createElement(RefPanel, {
|
|
2133
2169
|
model,
|
|
2134
2170
|
modals
|
|
2135
2171
|
}));
|
|
@@ -2140,7 +2176,7 @@ var Table = {
|
|
|
2140
2176
|
};
|
|
2141
2177
|
|
|
2142
2178
|
// packages/ui/react-ui-table/src/components/Table/DynamicTable.tsx
|
|
2143
|
-
import
|
|
2179
|
+
import React8, { useRef as useRef2, useMemo as useMemo5, useCallback as useCallback5 } from "react";
|
|
2144
2180
|
import { useDefaultValue } from "@dxos/react-ui";
|
|
2145
2181
|
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
2146
2182
|
|
|
@@ -2265,13 +2301,13 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
|
|
|
2265
2301
|
}, [
|
|
2266
2302
|
model
|
|
2267
2303
|
]);
|
|
2268
|
-
return /* @__PURE__ */
|
|
2304
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
2269
2305
|
role: "none",
|
|
2270
2306
|
className: mx3("is-full bs-full grow grid", classNames)
|
|
2271
|
-
}, /* @__PURE__ */
|
|
2307
|
+
}, /* @__PURE__ */ React8.createElement("div", {
|
|
2272
2308
|
role: "none",
|
|
2273
2309
|
className: "grid min-bs-0 overflow-hidden"
|
|
2274
|
-
}, /* @__PURE__ */
|
|
2310
|
+
}, /* @__PURE__ */ React8.createElement(Table.Root, null, /* @__PURE__ */ React8.createElement(Table.Main, {
|
|
2275
2311
|
ref: tableRef,
|
|
2276
2312
|
model,
|
|
2277
2313
|
presentation,
|
|
@@ -2281,8 +2317,8 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
|
|
|
2281
2317
|
};
|
|
2282
2318
|
|
|
2283
2319
|
// packages/ui/react-ui-table/src/components/TableToolbar/TableToolbar.tsx
|
|
2284
|
-
import
|
|
2285
|
-
import {
|
|
2320
|
+
import React9, { useCallback as useCallback6, useMemo as useMemo6 } from "react";
|
|
2321
|
+
import { create as create4 } from "@dxos/live-object";
|
|
2286
2322
|
import { createGapSeparator, createMenuAction, MenuProvider, ToolbarMenu, useMenuActions } from "@dxos/react-ui-menu";
|
|
2287
2323
|
var createTableToolbarActions = (state) => {
|
|
2288
2324
|
const add = createMenuAction("add-row", {
|
|
@@ -2336,18 +2372,18 @@ var createTableToolbarActions = (state) => {
|
|
|
2336
2372
|
};
|
|
2337
2373
|
};
|
|
2338
2374
|
var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
|
|
2339
|
-
const state = useMemo6(() =>
|
|
2375
|
+
const state = useMemo6(() => create4({
|
|
2340
2376
|
viewDirty
|
|
2341
2377
|
}), []);
|
|
2342
2378
|
const actionsCreator = useCallback6(() => createTableToolbarActions(state), [
|
|
2343
2379
|
state
|
|
2344
2380
|
]);
|
|
2345
2381
|
const menu = useMenuActions(actionsCreator);
|
|
2346
|
-
return /* @__PURE__ */
|
|
2382
|
+
return /* @__PURE__ */ React9.createElement(MenuProvider, {
|
|
2347
2383
|
...menu,
|
|
2348
2384
|
attendableId,
|
|
2349
2385
|
onAction
|
|
2350
|
-
}, /* @__PURE__ */
|
|
2386
|
+
}, /* @__PURE__ */ React9.createElement(ToolbarMenu, {
|
|
2351
2387
|
classNames
|
|
2352
2388
|
}));
|
|
2353
2389
|
};
|