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