@dxos/react-ui-table 0.8.4-main.1068cf700f → 0.8.4-main.1c7ec43d41
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/{chunk-OZBLY7XM.mjs → chunk-FBURZBPH.mjs} +17 -23
- package/dist/lib/browser/chunk-FBURZBPH.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/{chunk-GTGYBRJA.mjs → chunk-YGC7LZJN.mjs} +31 -84
- package/dist/lib/browser/chunk-YGC7LZJN.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +197 -234
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +6 -5
- 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-WNZSKIRF.mjs → chunk-DKKMSVKP.mjs} +17 -23
- package/dist/lib/node-esm/chunk-DKKMSVKP.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-DPNSZHU5.mjs → chunk-GKIWDEZ7.mjs} +31 -84
- package/dist/lib/node-esm/chunk-GKIWDEZ7.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/index.mjs +197 -234
- 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 +6 -5
- 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.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +2 -2
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +20 -22
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +82 -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 +20 -21
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +84 -84
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableContent.d.ts +17 -0
- package/dist/types/src/components/Table/TableContent.d.ts.map +1 -0
- package/dist/types/src/components/Table/TableToolbar.d.ts +21 -0
- package/dist/types/src/components/Table/TableToolbar.d.ts.map +1 -0
- package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +3 -3
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +2 -2
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +22 -24
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useAddRow.d.ts +1 -1
- package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
- package/dist/types/src/hooks/useProjectionModel.d.ts +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 +5 -4
- 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 +2 -2
- package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +19 -21
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Table.d.ts +1 -6
- package/dist/types/src/types/Table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +2 -2
- 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 +50 -59
- package/src/components/Table/ColumnActionsMenu.tsx +7 -6
- package/src/components/Table/ColumnSettings.tsx +3 -4
- package/src/components/Table/DynamicTable.stories.tsx +15 -15
- package/src/components/Table/DynamicTable.tsx +10 -18
- package/src/components/Table/Relations.stories.tsx +77 -33
- package/src/components/Table/RowActionsMenu.tsx +3 -2
- package/src/components/Table/Table.stories.tsx +58 -51
- package/src/components/Table/Table.tsx +41 -435
- package/src/components/Table/TableContent.tsx +421 -0
- package/src/components/{TableToolbar → Table}/TableToolbar.tsx +36 -43
- package/src/components/TableCellEditor/CellValidationMessage.tsx +4 -4
- package/src/components/TableCellEditor/FormCellEditor.tsx +14 -7
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +12 -11
- package/src/components/TableCellEditor/TableCellEditor.tsx +12 -10
- package/src/components/index.ts +0 -1
- package/src/components/testing.ts +10 -10
- package/src/hooks/useAddRow.ts +1 -1
- package/src/hooks/useProjectionModel.ts +3 -3
- package/src/index.ts +0 -4
- package/src/model/table-model.test.ts +5 -6
- package/src/model/table-model.ts +11 -10
- package/src/model/table-presentation.test.ts +5 -6
- package/src/model/table-presentation.ts +12 -12
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/smoke.spec.ts +3 -3
- package/src/testing/useTestTableModel.ts +5 -5
- package/src/translations.ts +19 -21
- package/src/types/Table.ts +12 -23
- package/src/util/dynamic-table.test.ts +4 -4
- package/src/util/dynamic-table.ts +11 -10
- package/src/util/query-ast.ts +3 -0
- package/src/util/table-buttons.ts +1 -1
- package/src/util/table-controls.ts +2 -2
- package/dist/lib/browser/chunk-GTGYBRJA.mjs.map +0 -7
- package/dist/lib/browser/chunk-OZBLY7XM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DPNSZHU5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WNZSKIRF.mjs.map +0 -7
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +0 -21
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +0 -1
- package/dist/types/src/components/TableToolbar/index.d.ts +0 -2
- package/dist/types/src/components/TableToolbar/index.d.ts.map +0 -1
- package/src/components/TableToolbar/index.ts +0 -5
|
@@ -16,67 +16,41 @@ import {
|
|
|
16
16
|
useAddRow,
|
|
17
17
|
useProjectionModel,
|
|
18
18
|
useTableModel
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-YGC7LZJN.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
|
-
"new schema": "New type",
|
|
36
|
-
"continue label": "Continue",
|
|
37
|
-
"create stack section label": "Create table",
|
|
38
|
-
"add row label": "Add row",
|
|
39
|
-
"create comment": "Create thread",
|
|
40
|
-
"column action sort descending": "Sort Descending",
|
|
41
|
-
"column action sort ascending": "Sort Ascending",
|
|
42
|
-
"column action clear sorting": "Clear Sorting",
|
|
43
|
-
"column action settings": "Column Settings",
|
|
44
|
-
"column action delete": "Delete Column",
|
|
45
|
-
"delete row label": "Delete row",
|
|
46
|
-
"bulk delete row label": "Delete selected rows",
|
|
47
|
-
"column deleted label": "Column deleted",
|
|
48
|
-
"new column button label": "Create column",
|
|
49
|
-
"create new object label": "Create new object \u201C{{text}}\u201D",
|
|
50
|
-
"save view label": "Save changes to view"
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
];
|
|
22
|
+
} from "./chunk-FBURZBPH.mjs";
|
|
23
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
55
24
|
|
|
56
25
|
// src/components/Table/Table.tsx
|
|
26
|
+
import { Atom as Atom4 } from "@effect-atom/atom-react";
|
|
27
|
+
import { createContext } from "@radix-ui/react-context";
|
|
28
|
+
import React9, { forwardRef, useImperativeHandle, useRef as useRef3 } from "react";
|
|
29
|
+
|
|
30
|
+
// src/components/Table/TableContent.tsx
|
|
57
31
|
import { Atom as Atom2, RegistryContext, useAtomValue as useAtomValue4 } from "@effect-atom/atom-react";
|
|
58
32
|
import * as String2 from "effect/String";
|
|
59
|
-
import React7, {
|
|
33
|
+
import React7, { useCallback as useCallback4, useContext, useEffect as useEffect3, useMemo as useMemo4, useState as useState4 } from "react";
|
|
60
34
|
import { log } from "@dxos/log";
|
|
61
35
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
62
36
|
import { Grid, closestCell, gridSeparatorBlockEnd, gridSeparatorInlineEnd } from "@dxos/react-ui-grid";
|
|
63
37
|
import { DxEditRequest } from "@dxos/react-ui-grid";
|
|
64
|
-
import { mx } from "@dxos/ui-theme";
|
|
38
|
+
import { composable, composableProps, mx } from "@dxos/ui-theme";
|
|
65
39
|
|
|
66
40
|
// src/util/dynamic-table.ts
|
|
67
|
-
import { Filter, Obj, Order, Query, Ref, Type } from "@dxos/echo";
|
|
68
|
-
import { ProjectionModel,
|
|
41
|
+
import { Filter, JsonSchema, Obj, Order, Query, Ref, Type } from "@dxos/echo";
|
|
42
|
+
import { ProjectionModel, ViewModel, createEchoChangeCallback as createEchoChangeCallback2, getSchemaFromPropertyDefinitions } from "@dxos/schema";
|
|
69
43
|
var getBaseSchema = ({ schema, typename, properties, jsonSchema }) => {
|
|
70
44
|
if (typename && properties) {
|
|
71
45
|
const schema2 = getSchemaFromPropertyDefinitions(typename, properties);
|
|
72
46
|
return {
|
|
73
47
|
typename: schema2.typename,
|
|
74
|
-
jsonSchema:
|
|
48
|
+
jsonSchema: JsonSchema.toJsonSchema(schema2)
|
|
75
49
|
};
|
|
76
50
|
} else if (schema) {
|
|
77
51
|
return {
|
|
78
52
|
typename: Type.getTypename(schema),
|
|
79
|
-
jsonSchema:
|
|
53
|
+
jsonSchema: JsonSchema.toJsonSchema(schema)
|
|
80
54
|
};
|
|
81
55
|
} else if (typename && jsonSchema) {
|
|
82
56
|
return {
|
|
@@ -88,7 +62,7 @@ var getBaseSchema = ({ schema, typename, properties, jsonSchema }) => {
|
|
|
88
62
|
}
|
|
89
63
|
};
|
|
90
64
|
var makeDynamicTable = ({ registry, jsonSchema, properties }) => {
|
|
91
|
-
const view =
|
|
65
|
+
const view = ViewModel.make({
|
|
92
66
|
query: Query.select(Filter.everything()),
|
|
93
67
|
jsonSchema,
|
|
94
68
|
...properties && {
|
|
@@ -119,8 +93,8 @@ var setProperties = (view, projection, table, properties) => {
|
|
|
119
93
|
const field = projection.getFields().find((field2) => field2.path === property.name);
|
|
120
94
|
if (field) {
|
|
121
95
|
if (property.size !== void 0) {
|
|
122
|
-
Obj.
|
|
123
|
-
|
|
96
|
+
Obj.update(table, (table2) => {
|
|
97
|
+
table2.sizes[field.path] = property.size;
|
|
124
98
|
});
|
|
125
99
|
}
|
|
126
100
|
if (property.title !== void 0) {
|
|
@@ -136,8 +110,8 @@ var setProperties = (view, projection, table, properties) => {
|
|
|
136
110
|
if (property.sort) {
|
|
137
111
|
const currentQuery = Query.fromAst(Obj.getSnapshot(view).query.ast);
|
|
138
112
|
const newQuery = currentQuery.orderBy(Order.property(field.path, property.sort));
|
|
139
|
-
Obj.
|
|
140
|
-
|
|
113
|
+
Obj.update(view, (view2) => {
|
|
114
|
+
view2.query.ast = newQuery.ast;
|
|
141
115
|
});
|
|
142
116
|
}
|
|
143
117
|
}
|
|
@@ -253,14 +227,14 @@ var CellValidationMessage = ({ __gridScope, validationError, variant = "error" }
|
|
|
253
227
|
if (!editing || !validationError) {
|
|
254
228
|
return null;
|
|
255
229
|
}
|
|
256
|
-
const bgClass = variant === "error" ? "bg-
|
|
257
|
-
const textClass = variant === "error" ? "text-
|
|
230
|
+
const bgClass = variant === "error" ? "bg-error-surface" : "bg-warning-surface";
|
|
231
|
+
const textClass = variant === "error" ? "text-error-surface-text" : "text-warning-surface-text";
|
|
258
232
|
return /* @__PURE__ */ React.createElement("div", {
|
|
259
233
|
role: "none",
|
|
260
|
-
className: `absolute ${bgClass} ${textClass} rounded-
|
|
234
|
+
className: `absolute ${bgClass} ${textClass} rounded-h-sm text-xs p-1`,
|
|
261
235
|
style: {
|
|
262
236
|
...{
|
|
263
|
-
"--dx-
|
|
237
|
+
"--dx-grid-cell-width": `${box?.inlineSize ?? 200}px`
|
|
264
238
|
},
|
|
265
239
|
zIndex: 10,
|
|
266
240
|
insetBlockEnd: `calc(100% - ${box.insetBlockStart}px)`,
|
|
@@ -279,9 +253,10 @@ import { Popover } from "@dxos/react-ui";
|
|
|
279
253
|
import { Form } from "@dxos/react-ui-form";
|
|
280
254
|
import { parseCellIndex, useGridContext as useGridContext2 } from "@dxos/react-ui-grid";
|
|
281
255
|
import { getDeep, isTruthy, setDeep } from "@dxos/util";
|
|
256
|
+
import { translationKey } from "#translations";
|
|
282
257
|
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx";
|
|
283
258
|
var createOptionLabel = [
|
|
284
|
-
"create
|
|
259
|
+
"create-new-object.label",
|
|
285
260
|
{
|
|
286
261
|
ns: translationKey
|
|
287
262
|
}
|
|
@@ -317,27 +292,11 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
317
292
|
const cell = parseCellIndex(contextEditing.index);
|
|
318
293
|
if (model.isDraftCell(cell)) {
|
|
319
294
|
const draftRow = model.getDraftRows()[cell.row];
|
|
320
|
-
invariant(draftRow, void 0, {
|
|
321
|
-
F: __dxlog_file,
|
|
322
|
-
L: 74,
|
|
323
|
-
S: void 0,
|
|
324
|
-
A: [
|
|
325
|
-
"draftRow",
|
|
326
|
-
""
|
|
327
|
-
]
|
|
328
|
-
});
|
|
295
|
+
invariant(draftRow, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 52, S: void 0, A: ["draftRow", ""] });
|
|
329
296
|
return draftRow.data;
|
|
330
297
|
} else {
|
|
331
298
|
const row = model.getRowAt(cell.row);
|
|
332
|
-
invariant(row, void 0, {
|
|
333
|
-
F: __dxlog_file,
|
|
334
|
-
L: 78,
|
|
335
|
-
S: void 0,
|
|
336
|
-
A: [
|
|
337
|
-
"row",
|
|
338
|
-
""
|
|
339
|
-
]
|
|
340
|
-
});
|
|
299
|
+
invariant(row, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 56, S: void 0, A: ["row", ""] });
|
|
341
300
|
return row;
|
|
342
301
|
}
|
|
343
302
|
}
|
|
@@ -346,9 +305,13 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
346
305
|
model,
|
|
347
306
|
contextEditing
|
|
348
307
|
]);
|
|
349
|
-
const
|
|
308
|
+
const initialFormValues = useMemo(() => originalRow ? JSON.parse(JSON.stringify(originalRow)) : {}, [
|
|
350
309
|
originalRow
|
|
351
310
|
]);
|
|
311
|
+
const [formValues, setFormValues] = useState(initialFormValues);
|
|
312
|
+
const handleValuesChanged = useCallback((values) => {
|
|
313
|
+
setFormValues(values);
|
|
314
|
+
}, []);
|
|
352
315
|
const handleOpenChange = useCallback((nextOpen) => {
|
|
353
316
|
if (nextOpen === false) {
|
|
354
317
|
setEditing(null);
|
|
@@ -433,12 +396,14 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
433
396
|
virtualRef: anchorRef
|
|
434
397
|
}), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
|
|
435
398
|
tabIndex: -1,
|
|
436
|
-
classNames: "
|
|
399
|
+
classNames: "dx-card-popover-width dx-density-fine"
|
|
437
400
|
}, /* @__PURE__ */ React2.createElement(Popover.Arrow, null), /* @__PURE__ */ React2.createElement(Popover.Viewport, null, /* @__PURE__ */ React2.createElement(Form.Root, {
|
|
438
401
|
...formProps,
|
|
439
402
|
autoFocus: true,
|
|
440
403
|
schema: narrowedSchema,
|
|
441
404
|
values: formValues,
|
|
405
|
+
onValuesChanged: handleValuesChanged,
|
|
406
|
+
projection: model?.projection,
|
|
442
407
|
createInitialValuePath: fieldProjection.field.referencePath,
|
|
443
408
|
createOptionIcon: "ph--plus--regular",
|
|
444
409
|
createOptionLabel,
|
|
@@ -451,11 +416,6 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
451
416
|
|
|
452
417
|
// src/components/TableCellEditor/TableCellEditor.tsx
|
|
453
418
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
|
|
454
|
-
var editorSlots = {
|
|
455
|
-
scroll: {
|
|
456
|
-
className: "!plb-[--dx-grid-cell-editor-padding-block]"
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
419
|
var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, onCreate }) => {
|
|
460
420
|
const { editing } = useGridContext3("TableValueEditor", __gridScope);
|
|
461
421
|
const fieldProjection = useMemo2(() => {
|
|
@@ -465,15 +425,7 @@ var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, o
|
|
|
465
425
|
const { col } = parseCellIndex2(editing.index);
|
|
466
426
|
const field = model.projection.getFields()[col];
|
|
467
427
|
const fieldProjection2 = model.projection.getFieldProjection(field.id);
|
|
468
|
-
invariant2(fieldProjection2, void 0, {
|
|
469
|
-
F: __dxlog_file2,
|
|
470
|
-
L: 73,
|
|
471
|
-
S: void 0,
|
|
472
|
-
A: [
|
|
473
|
-
"fieldProjection",
|
|
474
|
-
""
|
|
475
|
-
]
|
|
476
|
-
});
|
|
428
|
+
invariant2(fieldProjection2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 21, S: void 0, A: ["fieldProjection", ""] });
|
|
477
429
|
return fieldProjection2;
|
|
478
430
|
}, [
|
|
479
431
|
model,
|
|
@@ -510,15 +462,7 @@ var TableCellEditor = ({ __gridScope, model, modals, onFocus, onSave }) => {
|
|
|
510
462
|
const { col } = parseCellIndex2(editing.index);
|
|
511
463
|
const field = model.projection.getFields()[col];
|
|
512
464
|
const fieldProjection2 = model.projection.getFieldProjection(field.id);
|
|
513
|
-
invariant2(fieldProjection2, void 0, {
|
|
514
|
-
F: __dxlog_file2,
|
|
515
|
-
L: 120,
|
|
516
|
-
S: void 0,
|
|
517
|
-
A: [
|
|
518
|
-
"fieldProjection",
|
|
519
|
-
""
|
|
520
|
-
]
|
|
521
|
-
});
|
|
465
|
+
invariant2(fieldProjection2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 59, S: void 0, A: ["fieldProjection", ""] });
|
|
522
466
|
return fieldProjection2;
|
|
523
467
|
}, [
|
|
524
468
|
model,
|
|
@@ -652,9 +596,13 @@ var TableCellEditor = ({ __gridScope, model, modals, onFocus, onSave }) => {
|
|
|
652
596
|
__gridScope
|
|
653
597
|
}), /* @__PURE__ */ React3.createElement(GridCellEditor, {
|
|
654
598
|
extensions,
|
|
599
|
+
slots: {
|
|
600
|
+
content: {
|
|
601
|
+
className: "!py-(--dx-grid-cell-editor-padding-block)"
|
|
602
|
+
}
|
|
603
|
+
},
|
|
655
604
|
getCellContent,
|
|
656
|
-
onBlur: handleBlur
|
|
657
|
-
slots: editorSlots
|
|
605
|
+
onBlur: handleBlur
|
|
658
606
|
}));
|
|
659
607
|
};
|
|
660
608
|
var determineNavigationAxis = ({ key }) => {
|
|
@@ -686,8 +634,9 @@ var determineNavigationDelta = ({ key, shift }) => {
|
|
|
686
634
|
import { useAtomValue } from "@effect-atom/atom-react";
|
|
687
635
|
import React4 from "react";
|
|
688
636
|
import { DropdownMenu, useTranslation } from "@dxos/react-ui";
|
|
637
|
+
import { translationKey as translationKey2 } from "#translations";
|
|
689
638
|
var ColumnActionsMenu = ({ model, modals }) => {
|
|
690
|
-
const { t } = useTranslation(
|
|
639
|
+
const { t } = useTranslation(translationKey2);
|
|
691
640
|
const state = useAtomValue(modals.state);
|
|
692
641
|
if (state?.type !== "column") {
|
|
693
642
|
return null;
|
|
@@ -703,19 +652,19 @@ var ColumnActionsMenu = ({ model, modals }) => {
|
|
|
703
652
|
}), /* @__PURE__ */ React4.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React4.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React4.createElement(DropdownMenu.Viewport, null, (!isCurrentColumnSorted || currentSort?.direction === "asc") && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
704
653
|
"data-testid": "column-sort-descending",
|
|
705
654
|
onClick: () => model.setSort(state.fieldId, "desc")
|
|
706
|
-
}, t("column
|
|
655
|
+
}, t("column-action-sort-descending.menu")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
707
656
|
"data-testid": "column-sort-ascending",
|
|
708
657
|
onClick: () => model.setSort(state.fieldId, "asc")
|
|
709
|
-
}, t("column
|
|
658
|
+
}, t("column-action-sort-ascending.menu")), isCurrentColumnSorted && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
710
659
|
"data-testid": "column-clear-sort",
|
|
711
660
|
onClick: () => model.clearSort()
|
|
712
|
-
}, t("column
|
|
661
|
+
}, t("column-action-clear-sorting.menu")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
713
662
|
"data-testid": "column-delete",
|
|
714
663
|
onClick: () => model.deleteColumn(state.fieldId)
|
|
715
|
-
}, t("column
|
|
664
|
+
}, t("column-action-delete.menu")), model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
716
665
|
"data-testid": "column-settings",
|
|
717
666
|
onClick: () => modals.openColumnSettings()
|
|
718
|
-
}, t("column
|
|
667
|
+
}, t("column-action-settings.menu"))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))));
|
|
719
668
|
};
|
|
720
669
|
|
|
721
670
|
// src/components/Table/ColumnSettings.tsx
|
|
@@ -775,7 +724,7 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
|
|
|
775
724
|
}, /* @__PURE__ */ React5.createElement(Popover2.VirtualTrigger, {
|
|
776
725
|
virtualRef: modals.trigger
|
|
777
726
|
}), /* @__PURE__ */ React5.createElement(Popover2.Portal, null, /* @__PURE__ */ React5.createElement(Popover2.Content, {
|
|
778
|
-
classNames: "md:
|
|
727
|
+
classNames: "md:w-64"
|
|
779
728
|
}, /* @__PURE__ */ React5.createElement(Popover2.Viewport, null, /* @__PURE__ */ React5.createElement(FieldEditor, {
|
|
780
729
|
projection: model.projection,
|
|
781
730
|
field,
|
|
@@ -789,8 +738,9 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
|
|
|
789
738
|
import { useAtomValue as useAtomValue3 } from "@effect-atom/atom-react";
|
|
790
739
|
import React6 from "react";
|
|
791
740
|
import { DropdownMenu as DropdownMenu2, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
741
|
+
import { translationKey as translationKey3 } from "#translations";
|
|
792
742
|
var RowActionsMenu = ({ model, modals }) => {
|
|
793
|
-
const { t } = useTranslation2(
|
|
743
|
+
const { t } = useTranslation2(translationKey3);
|
|
794
744
|
const hasSelection = model.selection.hasSelection;
|
|
795
745
|
const state = useAtomValue3(modals.state);
|
|
796
746
|
if (state?.type !== "row") {
|
|
@@ -812,11 +762,11 @@ var RowActionsMenu = ({ model, modals }) => {
|
|
|
812
762
|
}, toLocalizedString(action.label, t)))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Separator, null)), model.features.dataEditable !== false && /* @__PURE__ */ React6.createElement(DropdownMenu2.Item, {
|
|
813
763
|
"data-testid": "row-menu-delete",
|
|
814
764
|
onClick: () => model.deleteRow(state.rowIndex)
|
|
815
|
-
}, t(hasSelection ? "bulk
|
|
765
|
+
}, t(hasSelection ? "bulk-delete-row.label" : "delete-row.label"))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Arrow, null)));
|
|
816
766
|
};
|
|
817
767
|
|
|
818
|
-
// src/components/Table/
|
|
819
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/Table/
|
|
768
|
+
// src/components/Table/TableContent.tsx
|
|
769
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/Table/TableContent.tsx";
|
|
820
770
|
var columnDefault = {
|
|
821
771
|
grid: {
|
|
822
772
|
minSize: 80,
|
|
@@ -832,22 +782,10 @@ var rowDefault = {
|
|
|
832
782
|
var emptyColumnMeta = Atom2.make({
|
|
833
783
|
grid: {}
|
|
834
784
|
});
|
|
835
|
-
var TableRoot = ({ children, role = "article" }) => {
|
|
836
|
-
return /* @__PURE__ */ React7.createElement("div", {
|
|
837
|
-
role: "none",
|
|
838
|
-
className: mx("relative !border-separator [&_.dx-grid]:max-is-[--dx-grid-content-inline-size] [&_.dx-grid]:max-bs-[--dx-grid-content-block-size]", role === "card--popover" && "popover-card-height", role === "section" && "attention-surface", role === "card--intrinsic" && "[&_.dx-grid]:bs-[--dx-grid-content-block-size]", [
|
|
839
|
-
"card--popover",
|
|
840
|
-
"section",
|
|
841
|
-
"card--extrinsic"
|
|
842
|
-
].includes(role) && "overflow-hidden", [
|
|
843
|
-
"article",
|
|
844
|
-
"slide"
|
|
845
|
-
].includes(role) && "flex flex-col [&_.dx-grid]:grow [&_.dx-grid]:bs-0")
|
|
846
|
-
}, children);
|
|
847
|
-
};
|
|
848
785
|
var emptyRowsAtom = Atom2.make([]);
|
|
849
786
|
var emptyCellUpdateAtom = Atom2.make(0);
|
|
850
|
-
var
|
|
787
|
+
var TABLE_CONTENT_NAME = "Table.Content";
|
|
788
|
+
var TableContent = composable(({ schema, model, presentation, ignoreAttention, onCreate, onRowClick, testId, ...props }, forwardedRef) => {
|
|
851
789
|
const registry = useContext(RegistryContext);
|
|
852
790
|
const [dxGrid, setDxGrid] = useState4(null);
|
|
853
791
|
const { hasAttention } = useAttention(model?.id ?? "table");
|
|
@@ -1055,12 +993,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1055
993
|
void navigator.clipboard.writeText(textContent);
|
|
1056
994
|
event.preventDefault();
|
|
1057
995
|
} catch (error) {
|
|
1058
|
-
log.catch(error, void 0, {
|
|
1059
|
-
F: __dxlog_file3,
|
|
1060
|
-
L: 322,
|
|
1061
|
-
S: void 0,
|
|
1062
|
-
C: (f, a) => f(...a)
|
|
1063
|
-
});
|
|
996
|
+
log.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 262, S: void 0 });
|
|
1064
997
|
}
|
|
1065
998
|
break;
|
|
1066
999
|
}
|
|
@@ -1135,7 +1068,8 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1135
1068
|
model,
|
|
1136
1069
|
dxGrid
|
|
1137
1070
|
]);
|
|
1138
|
-
|
|
1071
|
+
const { controllerRef } = useTableContext(TABLE_CONTENT_NAME);
|
|
1072
|
+
controllerRef.current = useMemo4(() => {
|
|
1139
1073
|
if (!dxGrid || !presentation) {
|
|
1140
1074
|
return {};
|
|
1141
1075
|
}
|
|
@@ -1158,10 +1092,15 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1158
1092
|
if (!model || !modals) {
|
|
1159
1093
|
return /* @__PURE__ */ React7.createElement("span", {
|
|
1160
1094
|
role: "none",
|
|
1161
|
-
className: "attention-surface"
|
|
1095
|
+
className: "dx-attention-surface"
|
|
1162
1096
|
});
|
|
1163
1097
|
}
|
|
1164
|
-
return /* @__PURE__ */ React7.createElement(
|
|
1098
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
1099
|
+
...composableProps(props, {
|
|
1100
|
+
classNames: "dx-container relative"
|
|
1101
|
+
}),
|
|
1102
|
+
ref: forwardedRef
|
|
1103
|
+
}, /* @__PURE__ */ React7.createElement(Grid.Root, {
|
|
1165
1104
|
id: model.id ?? "table-grid"
|
|
1166
1105
|
}, /* @__PURE__ */ React7.createElement(TableValueEditor, {
|
|
1167
1106
|
model,
|
|
@@ -1171,7 +1110,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1171
1110
|
onSave: handleSave,
|
|
1172
1111
|
onCreate
|
|
1173
1112
|
}), /* @__PURE__ */ React7.createElement(Grid.Content, {
|
|
1174
|
-
className: mx("[--dx-grid-base:var(--
|
|
1113
|
+
className: mx("[--dx-grid-base:var(--base-surface)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
|
|
1175
1114
|
frozen,
|
|
1176
1115
|
columns: columnMeta,
|
|
1177
1116
|
columnDefault,
|
|
@@ -1197,94 +1136,16 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1197
1136
|
model,
|
|
1198
1137
|
modals,
|
|
1199
1138
|
onNewColumn: handleNewColumn
|
|
1200
|
-
}));
|
|
1201
|
-
};
|
|
1202
|
-
|
|
1203
|
-
var Table = {
|
|
1204
|
-
Root: TableRoot,
|
|
1205
|
-
Main: TableMain
|
|
1206
|
-
};
|
|
1207
|
-
|
|
1208
|
-
// src/components/Table/DynamicTable.tsx
|
|
1209
|
-
import { RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
|
|
1210
|
-
import React8, { useCallback as useCallback5, useContext as useContext2, useEffect as useEffect4, useMemo as useMemo5, useRef as useRef3, useState as useState5 } from "react";
|
|
1211
|
-
import { useDefaultValue } from "@dxos/react-ui";
|
|
1212
|
-
import { mx as mx2 } from "@dxos/ui-theme";
|
|
1213
|
-
var DynamicTable = ({ classNames, schema, name = "example.com/dynamic-table", rows, properties, jsonSchema: _jsonSchema, rowActions, onRowClick, onRowAction, ...props }) => {
|
|
1214
|
-
const registry = useContext2(RegistryContext2);
|
|
1215
|
-
const [dynamicTable, setDynamicTable] = useState5();
|
|
1216
|
-
const { jsonSchema } = useMemo5(() => getBaseSchema({
|
|
1217
|
-
typename: name,
|
|
1218
|
-
properties,
|
|
1219
|
-
jsonSchema: _jsonSchema,
|
|
1220
|
-
schema
|
|
1221
|
-
}), [
|
|
1222
|
-
name,
|
|
1223
|
-
properties,
|
|
1224
|
-
_jsonSchema,
|
|
1225
|
-
schema
|
|
1226
|
-
]);
|
|
1227
|
-
useEffect4(() => {
|
|
1228
|
-
setDynamicTable(makeDynamicTable({
|
|
1229
|
-
registry,
|
|
1230
|
-
jsonSchema,
|
|
1231
|
-
properties
|
|
1232
|
-
}));
|
|
1233
|
-
}, [
|
|
1234
|
-
registry,
|
|
1235
|
-
jsonSchema,
|
|
1236
|
-
properties
|
|
1237
|
-
]);
|
|
1238
|
-
const tableRef = useRef3(null);
|
|
1239
|
-
const handleCellUpdate = useCallback5((cell) => {
|
|
1240
|
-
tableRef.current?.update?.(cell);
|
|
1241
|
-
}, []);
|
|
1242
|
-
const handleRowOrderChange = useCallback5(() => {
|
|
1243
|
-
tableRef.current?.update?.();
|
|
1244
|
-
}, []);
|
|
1245
|
-
const features = useDefaultValue(props.features, () => ({
|
|
1246
|
-
selection: {
|
|
1247
|
-
enabled: false
|
|
1248
|
-
},
|
|
1249
|
-
dataEditable: false
|
|
1250
|
-
}));
|
|
1251
|
-
const model = useTableModel({
|
|
1252
|
-
rows,
|
|
1253
|
-
object: dynamicTable?.object,
|
|
1254
|
-
projection: dynamicTable?.projection,
|
|
1255
|
-
features,
|
|
1256
|
-
rowActions,
|
|
1257
|
-
onCellUpdate: handleCellUpdate,
|
|
1258
|
-
onRowOrderChange: handleRowOrderChange,
|
|
1259
|
-
onRowAction
|
|
1260
|
-
});
|
|
1261
|
-
const presentation = useMemo5(() => {
|
|
1262
|
-
if (model) {
|
|
1263
|
-
return new TablePresentation(registry, model);
|
|
1264
|
-
}
|
|
1265
|
-
}, [
|
|
1266
|
-
registry,
|
|
1267
|
-
model
|
|
1268
|
-
]);
|
|
1269
|
-
return /* @__PURE__ */ React8.createElement("div", {
|
|
1270
|
-
role: "none",
|
|
1271
|
-
className: mx2("is-full bs-full grow grid", classNames)
|
|
1272
|
-
}, /* @__PURE__ */ React8.createElement("div", {
|
|
1273
|
-
role: "none",
|
|
1274
|
-
className: "grid min-bs-0 overflow-hidden"
|
|
1275
|
-
}, /* @__PURE__ */ React8.createElement(Table.Root, null, /* @__PURE__ */ React8.createElement(Table.Main, {
|
|
1276
|
-
ref: tableRef,
|
|
1277
|
-
model,
|
|
1278
|
-
presentation,
|
|
1279
|
-
ignoreAttention: true,
|
|
1280
|
-
onRowClick
|
|
1281
|
-
}))));
|
|
1282
|
-
};
|
|
1139
|
+
})));
|
|
1140
|
+
});
|
|
1141
|
+
TableContent.displayName = TABLE_CONTENT_NAME;
|
|
1283
1142
|
|
|
1284
|
-
// src/components/
|
|
1285
|
-
import { Atom as Atom3, RegistryContext as
|
|
1286
|
-
import
|
|
1287
|
-
import {
|
|
1143
|
+
// src/components/Table/TableToolbar.tsx
|
|
1144
|
+
import { Atom as Atom3, RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
|
|
1145
|
+
import React8, { useContext as useContext2, useEffect as useEffect4, useMemo as useMemo5 } from "react";
|
|
1146
|
+
import { Menu, createGapSeparator, createMenuAction, useMenuActions } from "@dxos/react-ui-menu";
|
|
1147
|
+
import { composable as composable2, composableProps as composableProps2 } from "@dxos/ui-theme";
|
|
1148
|
+
import { translationKey as translationKey4 } from "#translations";
|
|
1288
1149
|
var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) => Atom3.make((get) => {
|
|
1289
1150
|
const nodes = [];
|
|
1290
1151
|
if (onAdd) {
|
|
@@ -1292,9 +1153,9 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
|
|
|
1292
1153
|
type: "add-row",
|
|
1293
1154
|
icon: "ph--plus--regular",
|
|
1294
1155
|
label: [
|
|
1295
|
-
"add
|
|
1156
|
+
"add-row.label",
|
|
1296
1157
|
{
|
|
1297
|
-
ns:
|
|
1158
|
+
ns: translationKey4
|
|
1298
1159
|
}
|
|
1299
1160
|
],
|
|
1300
1161
|
testId: "table.toolbar.add-row"
|
|
@@ -1307,9 +1168,9 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
|
|
|
1307
1168
|
type: "save-view",
|
|
1308
1169
|
icon: "ph--floppy-disk--regular",
|
|
1309
1170
|
label: [
|
|
1310
|
-
"save
|
|
1171
|
+
"save-view.label",
|
|
1311
1172
|
{
|
|
1312
|
-
ns:
|
|
1173
|
+
ns: translationKey4
|
|
1313
1174
|
}
|
|
1314
1175
|
],
|
|
1315
1176
|
testId: "table.toolbar.save-view",
|
|
@@ -1322,7 +1183,8 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
|
|
|
1322
1183
|
nodes.push(...gap.nodes);
|
|
1323
1184
|
const edges = nodes.map(({ id: target }) => ({
|
|
1324
1185
|
source: "root",
|
|
1325
|
-
target
|
|
1186
|
+
target,
|
|
1187
|
+
relation: "child"
|
|
1326
1188
|
}));
|
|
1327
1189
|
if (customActions) {
|
|
1328
1190
|
const custom = get(customActions);
|
|
@@ -1334,12 +1196,12 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
|
|
|
1334
1196
|
edges
|
|
1335
1197
|
};
|
|
1336
1198
|
});
|
|
1337
|
-
var TableToolbar = ({
|
|
1338
|
-
const registry =
|
|
1339
|
-
const stateAtom =
|
|
1199
|
+
var TableToolbar = composable2(({ attendableId, viewDirty, onAdd, onSave, customActions, ...props }, forwardedRef) => {
|
|
1200
|
+
const registry = useContext2(RegistryContext2);
|
|
1201
|
+
const stateAtom = useMemo5(() => Atom3.make({
|
|
1340
1202
|
viewDirty
|
|
1341
1203
|
}), []);
|
|
1342
|
-
|
|
1204
|
+
useEffect4(() => {
|
|
1343
1205
|
registry.set(stateAtom, {
|
|
1344
1206
|
viewDirty
|
|
1345
1207
|
});
|
|
@@ -1348,7 +1210,7 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, custom
|
|
|
1348
1210
|
stateAtom,
|
|
1349
1211
|
viewDirty
|
|
1350
1212
|
]);
|
|
1351
|
-
const actionsCreator =
|
|
1213
|
+
const actionsCreator = useMemo5(() => createTableToolbarActions({
|
|
1352
1214
|
stateAtom,
|
|
1353
1215
|
onAdd,
|
|
1354
1216
|
onSave,
|
|
@@ -1359,13 +1221,115 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, custom
|
|
|
1359
1221
|
onSave,
|
|
1360
1222
|
customActions
|
|
1361
1223
|
]);
|
|
1362
|
-
const
|
|
1363
|
-
return /* @__PURE__ */
|
|
1364
|
-
...
|
|
1224
|
+
const menuActions = useMenuActions(actionsCreator);
|
|
1225
|
+
return /* @__PURE__ */ React8.createElement(Menu.Root, {
|
|
1226
|
+
...menuActions,
|
|
1365
1227
|
attendableId
|
|
1366
|
-
}, /* @__PURE__ */
|
|
1367
|
-
|
|
1228
|
+
}, /* @__PURE__ */ React8.createElement(Menu.Toolbar, {
|
|
1229
|
+
...composableProps2(props),
|
|
1230
|
+
ref: forwardedRef
|
|
1368
1231
|
}));
|
|
1232
|
+
});
|
|
1233
|
+
TableToolbar.displayName = "TableToolbar";
|
|
1234
|
+
|
|
1235
|
+
// src/components/Table/Table.tsx
|
|
1236
|
+
var emptyColumnMeta2 = Atom4.make({
|
|
1237
|
+
grid: {}
|
|
1238
|
+
});
|
|
1239
|
+
var [TableContextProvider, useTableContext] = createContext("Table");
|
|
1240
|
+
var TABLE_ROOT_NAME = "Table.Root";
|
|
1241
|
+
var TableRoot = /* @__PURE__ */ forwardRef(({ children }, forwardedRef) => {
|
|
1242
|
+
const controllerRef = useRef3({});
|
|
1243
|
+
useImperativeHandle(forwardedRef, () => ({
|
|
1244
|
+
update: (cell) => controllerRef.current?.update?.(cell),
|
|
1245
|
+
handleInsertRowResult: (result) => controllerRef.current?.handleInsertRowResult?.(result)
|
|
1246
|
+
}), []);
|
|
1247
|
+
return /* @__PURE__ */ React9.createElement(TableContextProvider, {
|
|
1248
|
+
controllerRef
|
|
1249
|
+
}, children);
|
|
1250
|
+
});
|
|
1251
|
+
TableRoot.displayName = TABLE_ROOT_NAME;
|
|
1252
|
+
var Table = {
|
|
1253
|
+
Root: TableRoot,
|
|
1254
|
+
Toolbar: TableToolbar,
|
|
1255
|
+
Content: TableContent
|
|
1256
|
+
};
|
|
1257
|
+
|
|
1258
|
+
// src/components/Table/DynamicTable.tsx
|
|
1259
|
+
import { RegistryContext as RegistryContext3 } from "@effect-atom/atom-react";
|
|
1260
|
+
import React10, { useCallback as useCallback5, useContext as useContext3, useEffect as useEffect5, useMemo as useMemo6, useRef as useRef4, useState as useState5 } from "react";
|
|
1261
|
+
import { useDefaultValue } from "@dxos/react-ui";
|
|
1262
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
1263
|
+
var DynamicTable = ({ classNames, schema, name = "com.example.dynamicTable", rows, properties, jsonSchema: jsonSchemaProp, rowActions, onRowClick, onRowAction, ...props }) => {
|
|
1264
|
+
const registry = useContext3(RegistryContext3);
|
|
1265
|
+
const [dynamicTable, setDynamicTable] = useState5();
|
|
1266
|
+
const { jsonSchema } = useMemo6(() => getBaseSchema({
|
|
1267
|
+
typename: name,
|
|
1268
|
+
properties,
|
|
1269
|
+
jsonSchema: jsonSchemaProp,
|
|
1270
|
+
schema
|
|
1271
|
+
}), [
|
|
1272
|
+
name,
|
|
1273
|
+
properties,
|
|
1274
|
+
jsonSchemaProp,
|
|
1275
|
+
schema
|
|
1276
|
+
]);
|
|
1277
|
+
useEffect5(() => {
|
|
1278
|
+
setDynamicTable(makeDynamicTable({
|
|
1279
|
+
registry,
|
|
1280
|
+
jsonSchema,
|
|
1281
|
+
properties
|
|
1282
|
+
}));
|
|
1283
|
+
}, [
|
|
1284
|
+
registry,
|
|
1285
|
+
jsonSchema,
|
|
1286
|
+
properties
|
|
1287
|
+
]);
|
|
1288
|
+
const tableRef = useRef4(null);
|
|
1289
|
+
const handleCellUpdate = useCallback5((cell) => {
|
|
1290
|
+
tableRef.current?.update?.(cell);
|
|
1291
|
+
}, []);
|
|
1292
|
+
const handleRowOrderChange = useCallback5(() => {
|
|
1293
|
+
tableRef.current?.update?.();
|
|
1294
|
+
}, []);
|
|
1295
|
+
const features = useDefaultValue(props.features, () => ({
|
|
1296
|
+
selection: {
|
|
1297
|
+
enabled: false
|
|
1298
|
+
},
|
|
1299
|
+
dataEditable: false
|
|
1300
|
+
}));
|
|
1301
|
+
const model = useTableModel({
|
|
1302
|
+
rows,
|
|
1303
|
+
object: dynamicTable?.object,
|
|
1304
|
+
projection: dynamicTable?.projection,
|
|
1305
|
+
features,
|
|
1306
|
+
rowActions,
|
|
1307
|
+
onCellUpdate: handleCellUpdate,
|
|
1308
|
+
onRowOrderChange: handleRowOrderChange,
|
|
1309
|
+
onRowAction
|
|
1310
|
+
});
|
|
1311
|
+
const presentation = useMemo6(() => {
|
|
1312
|
+
if (model) {
|
|
1313
|
+
return new TablePresentation(registry, model);
|
|
1314
|
+
}
|
|
1315
|
+
}, [
|
|
1316
|
+
registry,
|
|
1317
|
+
model
|
|
1318
|
+
]);
|
|
1319
|
+
return /* @__PURE__ */ React10.createElement("div", {
|
|
1320
|
+
role: "none",
|
|
1321
|
+
className: mx2("dx-expander grid", classNames)
|
|
1322
|
+
}, /* @__PURE__ */ React10.createElement("div", {
|
|
1323
|
+
role: "none",
|
|
1324
|
+
className: "grid min-h-0 overflow-hidden"
|
|
1325
|
+
}, /* @__PURE__ */ React10.createElement(Table.Root, {
|
|
1326
|
+
ref: tableRef
|
|
1327
|
+
}, /* @__PURE__ */ React10.createElement(Table.Content, {
|
|
1328
|
+
model,
|
|
1329
|
+
presentation,
|
|
1330
|
+
ignoreAttention: true,
|
|
1331
|
+
onRowClick
|
|
1332
|
+
}))));
|
|
1369
1333
|
};
|
|
1370
1334
|
export {
|
|
1371
1335
|
BUTTON_IDENTIFIERS,
|
|
@@ -1377,7 +1341,6 @@ export {
|
|
|
1377
1341
|
Table,
|
|
1378
1342
|
TableModel,
|
|
1379
1343
|
TablePresentation,
|
|
1380
|
-
TableToolbar,
|
|
1381
1344
|
cellClassesForRowSelection,
|
|
1382
1345
|
compareValues,
|
|
1383
1346
|
createDirectChangeCallback,
|
|
@@ -1390,9 +1353,9 @@ export {
|
|
|
1390
1353
|
tableButtons,
|
|
1391
1354
|
tableControls,
|
|
1392
1355
|
touch,
|
|
1393
|
-
translations,
|
|
1394
1356
|
useAddRow,
|
|
1395
1357
|
useProjectionModel,
|
|
1358
|
+
useTableContext,
|
|
1396
1359
|
useTableModel
|
|
1397
1360
|
};
|
|
1398
1361
|
//# sourceMappingURL=index.mjs.map
|