@dxos/react-ui-table 0.8.4-main.422d1c7879 → 0.8.4-main.43cb759274
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/LICENSE +102 -5
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-G5EDJPD2.mjs → chunk-X7A7G6RR.mjs} +26 -81
- package/dist/lib/browser/chunk-X7A7G6RR.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BF54SSNL.mjs → chunk-YURROGGF.mjs} +12 -15
- package/dist/lib/browser/chunk-YURROGGF.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +48 -122
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +7 -6
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/translations.mjs +36 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -1
- package/dist/lib/node-esm/{chunk-SIRDIPHZ.mjs → chunk-DLAGRBKD.mjs} +12 -15
- package/dist/lib/node-esm/chunk-DLAGRBKD.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ZZ3SYTIL.mjs → chunk-Q4HSBRJJ.mjs} +26 -81
- package/dist/lib/node-esm/chunk-Q4HSBRJJ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +48 -122
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +7 -6
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/translations.mjs +37 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +2 -1
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts +2 -2
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +3 -4
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +21 -20
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +83 -82
- package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +2 -2
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +83 -82
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableContent.d.ts +2 -1
- package/dist/types/src/components/Table/TableContent.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableToolbar.d.ts +1 -1
- package/dist/types/src/components/Table/TableToolbar.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +19 -19
- 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/useAddRow.d.ts.map +1 -1
- package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts.map +1 -1
- package/dist/types/src/model/selection-model.d.ts +1 -1
- package/dist/types/src/model/selection-model.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts +4 -5
- 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/playwright/TableManager.d.ts.map +1 -1
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -1
- package/dist/types/src/testing/useTestTableModel.d.ts +1 -1
- package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +19 -19
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Table.d.ts +11 -5
- package/dist/types/src/types/Table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +6 -6
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/query-ast.d.ts.map +1 -1
- package/dist/types/src/util/schema.d.ts.map +1 -1
- package/dist/types/src/util/signals.d.ts.map +1 -1
- package/dist/types/src/util/sort.d.ts.map +1 -1
- package/dist/types/src/util/table-buttons.d.ts +20 -20
- package/dist/types/src/util/table-buttons.d.ts.map +1 -1
- package/dist/types/src/util/table-controls.d.ts +4 -4
- package/dist/types/src/util/table-controls.d.ts.map +1 -1
- package/dist/types/src/util/tag.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +54 -50
- package/src/components/Table/ColumnActionsMenu.tsx +2 -1
- package/src/components/Table/ColumnSettings.tsx +2 -2
- package/src/components/Table/DynamicTable.stories.tsx +8 -7
- package/src/components/Table/DynamicTable.tsx +10 -11
- package/src/components/Table/Relations.stories.tsx +8 -6
- package/src/components/Table/RowActionsMenu.tsx +3 -2
- package/src/components/Table/Table.stories.tsx +28 -29
- package/src/components/Table/TableContent.tsx +8 -3
- package/src/components/Table/TableToolbar.tsx +2 -2
- package/src/components/TableCellEditor/CellValidationMessage.tsx +1 -2
- package/src/components/TableCellEditor/FormCellEditor.tsx +6 -5
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +7 -4
- package/src/components/testing.ts +2 -7
- package/src/hooks/useProjectionModel.ts +5 -6
- package/src/hooks/useTableModel.ts +1 -1
- package/src/index.ts +0 -4
- package/src/model/table-model.test.ts +4 -9
- package/src/model/table-model.ts +13 -13
- package/src/model/table-presentation.test.ts +4 -9
- package/src/model/table-presentation.ts +5 -6
- package/src/testing/useTestTableModel.ts +4 -5
- package/src/types/Table.ts +12 -13
- package/src/util/dynamic-table.test.ts +12 -19
- package/src/util/dynamic-table.ts +19 -18
- package/dist/lib/browser/chunk-BF54SSNL.mjs.map +0 -7
- package/dist/lib/browser/chunk-G5EDJPD2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SIRDIPHZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZZ3SYTIL.mjs.map +0 -7
|
@@ -16,40 +16,11 @@ import {
|
|
|
16
16
|
useAddRow,
|
|
17
17
|
useProjectionModel,
|
|
18
18
|
useTableModel
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-X7A7G6RR.mjs";
|
|
20
20
|
import {
|
|
21
21
|
Table_exports
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
|
|
24
|
-
// src/translations.ts
|
|
25
|
-
var translationKey = "@dxos/react-ui-table";
|
|
26
|
-
var translations = [
|
|
27
|
-
{
|
|
28
|
-
"en-US": {
|
|
29
|
-
[translationKey]: {
|
|
30
|
-
"object.placeholder": "New table",
|
|
31
|
-
"create-object.label": "Create table",
|
|
32
|
-
"table-name.placeholder": "Table name",
|
|
33
|
-
"settings.title": "Table settings",
|
|
34
|
-
"table-schema.label": "Type",
|
|
35
|
-
"continue.label": "Continue",
|
|
36
|
-
"create-stack-section.label": "Create table",
|
|
37
|
-
"add-row.label": "Add row",
|
|
38
|
-
"column-action-sort-descending.menu": "Sort Descending",
|
|
39
|
-
"column-action-sort-ascending.menu": "Sort Ascending",
|
|
40
|
-
"column-action-clear-sorting.menu": "Clear Sorting",
|
|
41
|
-
"column-action-settings.menu": "Column Settings",
|
|
42
|
-
"column-action-delete.menu": "Delete Column",
|
|
43
|
-
"delete-row.label": "Delete row",
|
|
44
|
-
"bulk-delete-row.label": "Delete selected rows",
|
|
45
|
-
"column-deleted.label": "Column deleted",
|
|
46
|
-
"new-column-button.label": "Create column",
|
|
47
|
-
"create-new-object.label": "Create new object \u201C{{text}}\u201D",
|
|
48
|
-
"save-view.label": "Save changes to view"
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
];
|
|
22
|
+
} from "./chunk-YURROGGF.mjs";
|
|
23
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
53
24
|
|
|
54
25
|
// src/components/Table/Table.tsx
|
|
55
26
|
import { Atom as Atom4 } from "@effect-atom/atom-react";
|
|
@@ -61,39 +32,31 @@ import { Atom as Atom2, RegistryContext, useAtomValue as useAtomValue4 } from "@
|
|
|
61
32
|
import * as String2 from "effect/String";
|
|
62
33
|
import React7, { useCallback as useCallback4, useContext, useEffect as useEffect3, useMemo as useMemo4, useState as useState4 } from "react";
|
|
63
34
|
import { log } from "@dxos/log";
|
|
35
|
+
import { composable, composableProps } from "@dxos/react-ui";
|
|
64
36
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
65
37
|
import { Grid, closestCell, gridSeparatorBlockEnd, gridSeparatorInlineEnd } from "@dxos/react-ui-grid";
|
|
66
38
|
import { DxEditRequest } from "@dxos/react-ui-grid";
|
|
67
|
-
import {
|
|
39
|
+
import { mx } from "@dxos/ui-theme";
|
|
68
40
|
|
|
69
41
|
// src/util/dynamic-table.ts
|
|
70
|
-
import { Filter,
|
|
71
|
-
import { ProjectionModel, ViewModel, createEchoChangeCallback as createEchoChangeCallback2, getSchemaFromPropertyDefinitions } from "@dxos/schema";
|
|
72
|
-
var getBaseSchema = ({
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
typename: schema2.typename,
|
|
77
|
-
jsonSchema: JsonSchema.toJsonSchema(schema2)
|
|
78
|
-
};
|
|
79
|
-
} else if (schema) {
|
|
80
|
-
return {
|
|
81
|
-
typename: Type.getTypename(schema),
|
|
82
|
-
jsonSchema: JsonSchema.toJsonSchema(schema)
|
|
83
|
-
};
|
|
84
|
-
} else if (typename && jsonSchema) {
|
|
85
|
-
return {
|
|
86
|
-
typename,
|
|
87
|
-
jsonSchema
|
|
88
|
-
};
|
|
89
|
-
} else {
|
|
42
|
+
import { Filter, Obj, Order, Query, Ref, Type } from "@dxos/echo";
|
|
43
|
+
import { ProjectionModel, ViewModel, createEchoChangeCallback as createEchoChangeCallback2, getSchemaFromJsonSchema, getSchemaFromPropertyDefinitions } from "@dxos/schema";
|
|
44
|
+
var getBaseSchema = ({ type, typename, properties, jsonSchema }) => {
|
|
45
|
+
const resolved = typename && properties ? getSchemaFromPropertyDefinitions(typename, properties) : type ?? (jsonSchema ? getSchemaFromJsonSchema(jsonSchema, typename) : void 0);
|
|
46
|
+
if (!resolved) {
|
|
90
47
|
throw new Error("invalid properties");
|
|
91
48
|
}
|
|
49
|
+
return {
|
|
50
|
+
typename: Type.getTypename(resolved),
|
|
51
|
+
type: resolved
|
|
52
|
+
};
|
|
92
53
|
};
|
|
93
|
-
var makeDynamicTable = ({ registry,
|
|
54
|
+
var makeDynamicTable = ({ registry, type, properties }) => {
|
|
55
|
+
const jsonSchema = type.jsonSchema;
|
|
94
56
|
const view = ViewModel.make({
|
|
95
57
|
query: Query.select(Filter.everything()),
|
|
96
58
|
jsonSchema,
|
|
59
|
+
type,
|
|
97
60
|
...properties && {
|
|
98
61
|
fields: properties.map((property) => property.name)
|
|
99
62
|
}
|
|
@@ -106,7 +69,7 @@ var makeDynamicTable = ({ registry, jsonSchema, properties }) => {
|
|
|
106
69
|
registry,
|
|
107
70
|
view,
|
|
108
71
|
baseSchema: jsonSchema,
|
|
109
|
-
change: createEchoChangeCallback2(view,
|
|
72
|
+
change: createEchoChangeCallback2(view, type)
|
|
110
73
|
});
|
|
111
74
|
projection.normalizeView();
|
|
112
75
|
if (properties && projection.getFields()) {
|
|
@@ -122,7 +85,7 @@ var setProperties = (view, projection, table, properties) => {
|
|
|
122
85
|
const field = projection.getFields().find((field2) => field2.path === property.name);
|
|
123
86
|
if (field) {
|
|
124
87
|
if (property.size !== void 0) {
|
|
125
|
-
Obj.
|
|
88
|
+
Obj.update(table, (table2) => {
|
|
126
89
|
table2.sizes[field.path] = property.size;
|
|
127
90
|
});
|
|
128
91
|
}
|
|
@@ -139,7 +102,7 @@ var setProperties = (view, projection, table, properties) => {
|
|
|
139
102
|
if (property.sort) {
|
|
140
103
|
const currentQuery = Query.fromAst(Obj.getSnapshot(view).query.ast);
|
|
141
104
|
const newQuery = currentQuery.orderBy(Order.property(field.path, property.sort));
|
|
142
|
-
Obj.
|
|
105
|
+
Obj.update(view, (view2) => {
|
|
143
106
|
view2.query.ast = newQuery.ast;
|
|
144
107
|
});
|
|
145
108
|
}
|
|
@@ -257,9 +220,8 @@ var CellValidationMessage = ({ __gridScope, validationError, variant = "error" }
|
|
|
257
220
|
return null;
|
|
258
221
|
}
|
|
259
222
|
const bgClass = variant === "error" ? "bg-error-surface" : "bg-warning-surface";
|
|
260
|
-
const textClass = variant === "error" ? "text-error-
|
|
223
|
+
const textClass = variant === "error" ? "text-error-fg" : "text-warning-fg";
|
|
261
224
|
return /* @__PURE__ */ React.createElement("div", {
|
|
262
|
-
role: "none",
|
|
263
225
|
className: `absolute ${bgClass} ${textClass} rounded-h-sm text-xs p-1`,
|
|
264
226
|
style: {
|
|
265
227
|
...{
|
|
@@ -275,13 +237,14 @@ var CellValidationMessage = ({ __gridScope, validationError, variant = "error" }
|
|
|
275
237
|
|
|
276
238
|
// src/components/TableCellEditor/FormCellEditor.tsx
|
|
277
239
|
import React2, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
278
|
-
import { Entity } from "@dxos/echo";
|
|
240
|
+
import { Entity, Type as Type2 } from "@dxos/echo";
|
|
279
241
|
import { Ref as Ref2, getValue } from "@dxos/echo/internal";
|
|
280
242
|
import { invariant } from "@dxos/invariant";
|
|
281
243
|
import { Popover } from "@dxos/react-ui";
|
|
282
244
|
import { Form } from "@dxos/react-ui-form";
|
|
283
245
|
import { parseCellIndex, useGridContext as useGridContext2 } from "@dxos/react-ui-grid";
|
|
284
246
|
import { getDeep, isTruthy, setDeep } from "@dxos/util";
|
|
247
|
+
import { translationKey } from "#translations";
|
|
285
248
|
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx";
|
|
286
249
|
var createOptionLabel = [
|
|
287
250
|
"create-new-object.label",
|
|
@@ -308,7 +271,7 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
308
271
|
if (!schema) {
|
|
309
272
|
return void 0;
|
|
310
273
|
}
|
|
311
|
-
return narrowSchema(schema, [
|
|
274
|
+
return narrowSchema(Type2.getSchema(schema), [
|
|
312
275
|
fieldProjection.field.path
|
|
313
276
|
]);
|
|
314
277
|
}, [
|
|
@@ -320,27 +283,11 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
320
283
|
const cell = parseCellIndex(contextEditing.index);
|
|
321
284
|
if (model.isDraftCell(cell)) {
|
|
322
285
|
const draftRow = model.getDraftRows()[cell.row];
|
|
323
|
-
invariant(draftRow, void 0, {
|
|
324
|
-
F: __dxlog_file,
|
|
325
|
-
L: 74,
|
|
326
|
-
S: void 0,
|
|
327
|
-
A: [
|
|
328
|
-
"draftRow",
|
|
329
|
-
""
|
|
330
|
-
]
|
|
331
|
-
});
|
|
286
|
+
invariant(draftRow, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 52, S: void 0, A: ["draftRow", ""] });
|
|
332
287
|
return draftRow.data;
|
|
333
288
|
} else {
|
|
334
289
|
const row = model.getRowAt(cell.row);
|
|
335
|
-
invariant(row, void 0, {
|
|
336
|
-
F: __dxlog_file,
|
|
337
|
-
L: 78,
|
|
338
|
-
S: void 0,
|
|
339
|
-
A: [
|
|
340
|
-
"row",
|
|
341
|
-
""
|
|
342
|
-
]
|
|
343
|
-
});
|
|
290
|
+
invariant(row, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 56, S: void 0, A: ["row", ""] });
|
|
344
291
|
return row;
|
|
345
292
|
}
|
|
346
293
|
}
|
|
@@ -424,7 +371,7 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
424
371
|
]);
|
|
425
372
|
const getOptions = useCallback((results) => results.map((obj) => {
|
|
426
373
|
return {
|
|
427
|
-
id: Entity.
|
|
374
|
+
id: Entity.getURI(obj),
|
|
428
375
|
label: getValue(obj, fieldProjection.field.referencePath) || obj.id.toString()
|
|
429
376
|
};
|
|
430
377
|
}).filter(isTruthy), [
|
|
@@ -440,7 +387,7 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
440
387
|
virtualRef: anchorRef
|
|
441
388
|
}), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
|
|
442
389
|
tabIndex: -1,
|
|
443
|
-
classNames: "dx-card-popover-width dx-density-
|
|
390
|
+
classNames: "dx-card-popover-width dx-density-md"
|
|
444
391
|
}, /* @__PURE__ */ React2.createElement(Popover.Arrow, null), /* @__PURE__ */ React2.createElement(Popover.Viewport, null, /* @__PURE__ */ React2.createElement(Form.Root, {
|
|
445
392
|
...formProps,
|
|
446
393
|
autoFocus: true,
|
|
@@ -469,15 +416,7 @@ var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, o
|
|
|
469
416
|
const { col } = parseCellIndex2(editing.index);
|
|
470
417
|
const field = model.projection.getFields()[col];
|
|
471
418
|
const fieldProjection2 = model.projection.getFieldProjection(field.id);
|
|
472
|
-
invariant2(fieldProjection2, void 0, {
|
|
473
|
-
F: __dxlog_file2,
|
|
474
|
-
L: 66,
|
|
475
|
-
S: void 0,
|
|
476
|
-
A: [
|
|
477
|
-
"fieldProjection",
|
|
478
|
-
""
|
|
479
|
-
]
|
|
480
|
-
});
|
|
419
|
+
invariant2(fieldProjection2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 21, S: void 0, A: ["fieldProjection", ""] });
|
|
481
420
|
return fieldProjection2;
|
|
482
421
|
}, [
|
|
483
422
|
model,
|
|
@@ -514,15 +453,7 @@ var TableCellEditor = ({ __gridScope, model, modals, onFocus, onSave }) => {
|
|
|
514
453
|
const { col } = parseCellIndex2(editing.index);
|
|
515
454
|
const field = model.projection.getFields()[col];
|
|
516
455
|
const fieldProjection2 = model.projection.getFieldProjection(field.id);
|
|
517
|
-
invariant2(fieldProjection2, void 0, {
|
|
518
|
-
F: __dxlog_file2,
|
|
519
|
-
L: 113,
|
|
520
|
-
S: void 0,
|
|
521
|
-
A: [
|
|
522
|
-
"fieldProjection",
|
|
523
|
-
""
|
|
524
|
-
]
|
|
525
|
-
});
|
|
456
|
+
invariant2(fieldProjection2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 59, S: void 0, A: ["fieldProjection", ""] });
|
|
526
457
|
return fieldProjection2;
|
|
527
458
|
}, [
|
|
528
459
|
model,
|
|
@@ -694,8 +625,9 @@ var determineNavigationDelta = ({ key, shift }) => {
|
|
|
694
625
|
import { useAtomValue } from "@effect-atom/atom-react";
|
|
695
626
|
import React4 from "react";
|
|
696
627
|
import { DropdownMenu, useTranslation } from "@dxos/react-ui";
|
|
628
|
+
import { translationKey as translationKey2 } from "#translations";
|
|
697
629
|
var ColumnActionsMenu = ({ model, modals }) => {
|
|
698
|
-
const { t } = useTranslation(
|
|
630
|
+
const { t } = useTranslation(translationKey2);
|
|
699
631
|
const state = useAtomValue(modals.state);
|
|
700
632
|
if (state?.type !== "column") {
|
|
701
633
|
return null;
|
|
@@ -797,8 +729,9 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
|
|
|
797
729
|
import { useAtomValue as useAtomValue3 } from "@effect-atom/atom-react";
|
|
798
730
|
import React6 from "react";
|
|
799
731
|
import { DropdownMenu as DropdownMenu2, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
732
|
+
import { translationKey as translationKey3 } from "#translations";
|
|
800
733
|
var RowActionsMenu = ({ model, modals }) => {
|
|
801
|
-
const { t } = useTranslation2(
|
|
734
|
+
const { t } = useTranslation2(translationKey3);
|
|
802
735
|
const hasSelection = model.selection.hasSelection;
|
|
803
736
|
const state = useAtomValue3(modals.state);
|
|
804
737
|
if (state?.type !== "row") {
|
|
@@ -820,7 +753,7 @@ var RowActionsMenu = ({ model, modals }) => {
|
|
|
820
753
|
}, toLocalizedString(action.label, t)))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Separator, null)), model.features.dataEditable !== false && /* @__PURE__ */ React6.createElement(DropdownMenu2.Item, {
|
|
821
754
|
"data-testid": "row-menu-delete",
|
|
822
755
|
onClick: () => model.deleteRow(state.rowIndex)
|
|
823
|
-
}, t(hasSelection ? "bulk
|
|
756
|
+
}, t(hasSelection ? "bulk-delete-row.label" : "delete-row.label"))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Arrow, null)));
|
|
824
757
|
};
|
|
825
758
|
|
|
826
759
|
// src/components/Table/TableContent.tsx
|
|
@@ -843,10 +776,10 @@ var emptyColumnMeta = Atom2.make({
|
|
|
843
776
|
var emptyRowsAtom = Atom2.make([]);
|
|
844
777
|
var emptyCellUpdateAtom = Atom2.make(0);
|
|
845
778
|
var TABLE_CONTENT_NAME = "Table.Content";
|
|
846
|
-
var TableContent = composable(({ schema, model, presentation, ignoreAttention, onCreate, onRowClick, testId, ...props }, forwardedRef) => {
|
|
779
|
+
var TableContent = composable(({ schema, model, presentation, ignoreAttention, attendableId, onCreate, onRowClick, testId, ...props }, forwardedRef) => {
|
|
847
780
|
const registry = useContext(RegistryContext);
|
|
848
781
|
const [dxGrid, setDxGrid] = useState4(null);
|
|
849
|
-
const { hasAttention } = useAttention(model?.id ?? "table");
|
|
782
|
+
const { hasAttention } = useAttention(attendableId ?? model?.id ?? "table");
|
|
850
783
|
const modals = useMemo4(() => new ModalController(registry), [
|
|
851
784
|
registry
|
|
852
785
|
]);
|
|
@@ -1051,12 +984,7 @@ var TableContent = composable(({ schema, model, presentation, ignoreAttention, o
|
|
|
1051
984
|
void navigator.clipboard.writeText(textContent);
|
|
1052
985
|
event.preventDefault();
|
|
1053
986
|
} catch (error) {
|
|
1054
|
-
log.catch(error, void 0, {
|
|
1055
|
-
F: __dxlog_file3,
|
|
1056
|
-
L: 278,
|
|
1057
|
-
S: void 0,
|
|
1058
|
-
C: (f, a) => f(...a)
|
|
1059
|
-
});
|
|
987
|
+
log.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 263, S: void 0 });
|
|
1060
988
|
}
|
|
1061
989
|
break;
|
|
1062
990
|
}
|
|
@@ -1206,8 +1134,9 @@ TableContent.displayName = TABLE_CONTENT_NAME;
|
|
|
1206
1134
|
// src/components/Table/TableToolbar.tsx
|
|
1207
1135
|
import { Atom as Atom3, RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
|
|
1208
1136
|
import React8, { useContext as useContext2, useEffect as useEffect4, useMemo as useMemo5 } from "react";
|
|
1137
|
+
import { composable as composable2, composableProps as composableProps2 } from "@dxos/react-ui";
|
|
1209
1138
|
import { Menu, createGapSeparator, createMenuAction, useMenuActions } from "@dxos/react-ui-menu";
|
|
1210
|
-
import {
|
|
1139
|
+
import { translationKey as translationKey4 } from "#translations";
|
|
1211
1140
|
var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) => Atom3.make((get) => {
|
|
1212
1141
|
const nodes = [];
|
|
1213
1142
|
if (onAdd) {
|
|
@@ -1217,7 +1146,7 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
|
|
|
1217
1146
|
label: [
|
|
1218
1147
|
"add-row.label",
|
|
1219
1148
|
{
|
|
1220
|
-
ns:
|
|
1149
|
+
ns: translationKey4
|
|
1221
1150
|
}
|
|
1222
1151
|
],
|
|
1223
1152
|
testId: "table.toolbar.add-row"
|
|
@@ -1232,7 +1161,7 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
|
|
|
1232
1161
|
label: [
|
|
1233
1162
|
"save-view.label",
|
|
1234
1163
|
{
|
|
1235
|
-
ns:
|
|
1164
|
+
ns: translationKey4
|
|
1236
1165
|
}
|
|
1237
1166
|
],
|
|
1238
1167
|
testId: "table.toolbar.save-view",
|
|
@@ -1322,29 +1251,29 @@ import { RegistryContext as RegistryContext3 } from "@effect-atom/atom-react";
|
|
|
1322
1251
|
import React10, { useCallback as useCallback5, useContext as useContext3, useEffect as useEffect5, useMemo as useMemo6, useRef as useRef4, useState as useState5 } from "react";
|
|
1323
1252
|
import { useDefaultValue } from "@dxos/react-ui";
|
|
1324
1253
|
import { mx as mx2 } from "@dxos/ui-theme";
|
|
1325
|
-
var DynamicTable = ({ classNames,
|
|
1254
|
+
var DynamicTable = ({ classNames, type: typeProp, name = "com.example.dynamicTable", rows, properties, jsonSchema: jsonSchemaProp, rowActions, onRowClick, onRowAction, ...props }) => {
|
|
1326
1255
|
const registry = useContext3(RegistryContext3);
|
|
1327
1256
|
const [dynamicTable, setDynamicTable] = useState5();
|
|
1328
|
-
const {
|
|
1257
|
+
const { type } = useMemo6(() => getBaseSchema({
|
|
1329
1258
|
typename: name,
|
|
1330
1259
|
properties,
|
|
1331
1260
|
jsonSchema: jsonSchemaProp,
|
|
1332
|
-
|
|
1261
|
+
type: typeProp
|
|
1333
1262
|
}), [
|
|
1334
1263
|
name,
|
|
1335
1264
|
properties,
|
|
1336
1265
|
jsonSchemaProp,
|
|
1337
|
-
|
|
1266
|
+
typeProp
|
|
1338
1267
|
]);
|
|
1339
1268
|
useEffect5(() => {
|
|
1340
1269
|
setDynamicTable(makeDynamicTable({
|
|
1341
1270
|
registry,
|
|
1342
|
-
|
|
1271
|
+
type,
|
|
1343
1272
|
properties
|
|
1344
1273
|
}));
|
|
1345
1274
|
}, [
|
|
1346
1275
|
registry,
|
|
1347
|
-
|
|
1276
|
+
type,
|
|
1348
1277
|
properties
|
|
1349
1278
|
]);
|
|
1350
1279
|
const tableRef = useRef4(null);
|
|
@@ -1379,10 +1308,8 @@ var DynamicTable = ({ classNames, schema, name = "com.example.dynamicTable", row
|
|
|
1379
1308
|
model
|
|
1380
1309
|
]);
|
|
1381
1310
|
return /* @__PURE__ */ React10.createElement("div", {
|
|
1382
|
-
role: "none",
|
|
1383
1311
|
className: mx2("dx-expander grid", classNames)
|
|
1384
1312
|
}, /* @__PURE__ */ React10.createElement("div", {
|
|
1385
|
-
role: "none",
|
|
1386
1313
|
className: "grid min-h-0 overflow-hidden"
|
|
1387
1314
|
}, /* @__PURE__ */ React10.createElement(Table.Root, {
|
|
1388
1315
|
ref: tableRef
|
|
@@ -1415,7 +1342,6 @@ export {
|
|
|
1415
1342
|
tableButtons,
|
|
1416
1343
|
tableControls,
|
|
1417
1344
|
touch,
|
|
1418
|
-
translations,
|
|
1419
1345
|
useAddRow,
|
|
1420
1346
|
useProjectionModel,
|
|
1421
1347
|
useTableContext,
|