@dxos/react-ui-table 0.8.4-main.3eb6e50203 → 0.8.4-main.3fbcb4aa9b
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 +195 -235
- 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 +195 -235
- 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 -5
- 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,13 @@ 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
|
-
|
|
260
|
-
className: `absolute ${bgClass} ${textClass} rounded-bs-sm text-xs p-1`,
|
|
233
|
+
className: `absolute ${bgClass} ${textClass} rounded-h-sm text-xs p-1`,
|
|
261
234
|
style: {
|
|
262
235
|
...{
|
|
263
|
-
"--dx-
|
|
236
|
+
"--dx-grid-cell-width": `${box?.inlineSize ?? 200}px`
|
|
264
237
|
},
|
|
265
238
|
zIndex: 10,
|
|
266
239
|
insetBlockEnd: `calc(100% - ${box.insetBlockStart}px)`,
|
|
@@ -279,9 +252,10 @@ import { Popover } from "@dxos/react-ui";
|
|
|
279
252
|
import { Form } from "@dxos/react-ui-form";
|
|
280
253
|
import { parseCellIndex, useGridContext as useGridContext2 } from "@dxos/react-ui-grid";
|
|
281
254
|
import { getDeep, isTruthy, setDeep } from "@dxos/util";
|
|
255
|
+
import { translationKey } from "#translations";
|
|
282
256
|
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx";
|
|
283
257
|
var createOptionLabel = [
|
|
284
|
-
"create
|
|
258
|
+
"create-new-object.label",
|
|
285
259
|
{
|
|
286
260
|
ns: translationKey
|
|
287
261
|
}
|
|
@@ -317,27 +291,11 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
317
291
|
const cell = parseCellIndex(contextEditing.index);
|
|
318
292
|
if (model.isDraftCell(cell)) {
|
|
319
293
|
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
|
-
});
|
|
294
|
+
invariant(draftRow, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 52, S: void 0, A: ["draftRow", ""] });
|
|
329
295
|
return draftRow.data;
|
|
330
296
|
} else {
|
|
331
297
|
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
|
-
});
|
|
298
|
+
invariant(row, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 56, S: void 0, A: ["row", ""] });
|
|
341
299
|
return row;
|
|
342
300
|
}
|
|
343
301
|
}
|
|
@@ -346,9 +304,13 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
346
304
|
model,
|
|
347
305
|
contextEditing
|
|
348
306
|
]);
|
|
349
|
-
const
|
|
307
|
+
const initialFormValues = useMemo(() => originalRow ? JSON.parse(JSON.stringify(originalRow)) : {}, [
|
|
350
308
|
originalRow
|
|
351
309
|
]);
|
|
310
|
+
const [formValues, setFormValues] = useState(initialFormValues);
|
|
311
|
+
const handleValuesChanged = useCallback((values) => {
|
|
312
|
+
setFormValues(values);
|
|
313
|
+
}, []);
|
|
352
314
|
const handleOpenChange = useCallback((nextOpen) => {
|
|
353
315
|
if (nextOpen === false) {
|
|
354
316
|
setEditing(null);
|
|
@@ -433,12 +395,14 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
433
395
|
virtualRef: anchorRef
|
|
434
396
|
}), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
|
|
435
397
|
tabIndex: -1,
|
|
436
|
-
classNames: "
|
|
398
|
+
classNames: "dx-card-popover-width dx-density-fine"
|
|
437
399
|
}, /* @__PURE__ */ React2.createElement(Popover.Arrow, null), /* @__PURE__ */ React2.createElement(Popover.Viewport, null, /* @__PURE__ */ React2.createElement(Form.Root, {
|
|
438
400
|
...formProps,
|
|
439
401
|
autoFocus: true,
|
|
440
402
|
schema: narrowedSchema,
|
|
441
403
|
values: formValues,
|
|
404
|
+
onValuesChanged: handleValuesChanged,
|
|
405
|
+
projection: model?.projection,
|
|
442
406
|
createInitialValuePath: fieldProjection.field.referencePath,
|
|
443
407
|
createOptionIcon: "ph--plus--regular",
|
|
444
408
|
createOptionLabel,
|
|
@@ -451,11 +415,6 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
451
415
|
|
|
452
416
|
// src/components/TableCellEditor/TableCellEditor.tsx
|
|
453
417
|
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
418
|
var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, onCreate }) => {
|
|
460
419
|
const { editing } = useGridContext3("TableValueEditor", __gridScope);
|
|
461
420
|
const fieldProjection = useMemo2(() => {
|
|
@@ -465,15 +424,7 @@ var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, o
|
|
|
465
424
|
const { col } = parseCellIndex2(editing.index);
|
|
466
425
|
const field = model.projection.getFields()[col];
|
|
467
426
|
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
|
-
});
|
|
427
|
+
invariant2(fieldProjection2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 21, S: void 0, A: ["fieldProjection", ""] });
|
|
477
428
|
return fieldProjection2;
|
|
478
429
|
}, [
|
|
479
430
|
model,
|
|
@@ -510,15 +461,7 @@ var TableCellEditor = ({ __gridScope, model, modals, onFocus, onSave }) => {
|
|
|
510
461
|
const { col } = parseCellIndex2(editing.index);
|
|
511
462
|
const field = model.projection.getFields()[col];
|
|
512
463
|
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
|
-
});
|
|
464
|
+
invariant2(fieldProjection2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 59, S: void 0, A: ["fieldProjection", ""] });
|
|
522
465
|
return fieldProjection2;
|
|
523
466
|
}, [
|
|
524
467
|
model,
|
|
@@ -652,9 +595,13 @@ var TableCellEditor = ({ __gridScope, model, modals, onFocus, onSave }) => {
|
|
|
652
595
|
__gridScope
|
|
653
596
|
}), /* @__PURE__ */ React3.createElement(GridCellEditor, {
|
|
654
597
|
extensions,
|
|
598
|
+
slots: {
|
|
599
|
+
content: {
|
|
600
|
+
className: "!py-(--dx-grid-cell-editor-padding-block)"
|
|
601
|
+
}
|
|
602
|
+
},
|
|
655
603
|
getCellContent,
|
|
656
|
-
onBlur: handleBlur
|
|
657
|
-
slots: editorSlots
|
|
604
|
+
onBlur: handleBlur
|
|
658
605
|
}));
|
|
659
606
|
};
|
|
660
607
|
var determineNavigationAxis = ({ key }) => {
|
|
@@ -686,8 +633,9 @@ var determineNavigationDelta = ({ key, shift }) => {
|
|
|
686
633
|
import { useAtomValue } from "@effect-atom/atom-react";
|
|
687
634
|
import React4 from "react";
|
|
688
635
|
import { DropdownMenu, useTranslation } from "@dxos/react-ui";
|
|
636
|
+
import { translationKey as translationKey2 } from "#translations";
|
|
689
637
|
var ColumnActionsMenu = ({ model, modals }) => {
|
|
690
|
-
const { t } = useTranslation(
|
|
638
|
+
const { t } = useTranslation(translationKey2);
|
|
691
639
|
const state = useAtomValue(modals.state);
|
|
692
640
|
if (state?.type !== "column") {
|
|
693
641
|
return null;
|
|
@@ -703,19 +651,19 @@ var ColumnActionsMenu = ({ model, modals }) => {
|
|
|
703
651
|
}), /* @__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
652
|
"data-testid": "column-sort-descending",
|
|
705
653
|
onClick: () => model.setSort(state.fieldId, "desc")
|
|
706
|
-
}, t("column
|
|
654
|
+
}, t("column-action-sort-descending.menu")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
707
655
|
"data-testid": "column-sort-ascending",
|
|
708
656
|
onClick: () => model.setSort(state.fieldId, "asc")
|
|
709
|
-
}, t("column
|
|
657
|
+
}, t("column-action-sort-ascending.menu")), isCurrentColumnSorted && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
710
658
|
"data-testid": "column-clear-sort",
|
|
711
659
|
onClick: () => model.clearSort()
|
|
712
|
-
}, t("column
|
|
660
|
+
}, t("column-action-clear-sorting.menu")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
713
661
|
"data-testid": "column-delete",
|
|
714
662
|
onClick: () => model.deleteColumn(state.fieldId)
|
|
715
|
-
}, t("column
|
|
663
|
+
}, t("column-action-delete.menu")), model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
716
664
|
"data-testid": "column-settings",
|
|
717
665
|
onClick: () => modals.openColumnSettings()
|
|
718
|
-
}, t("column
|
|
666
|
+
}, t("column-action-settings.menu"))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))));
|
|
719
667
|
};
|
|
720
668
|
|
|
721
669
|
// src/components/Table/ColumnSettings.tsx
|
|
@@ -775,7 +723,7 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
|
|
|
775
723
|
}, /* @__PURE__ */ React5.createElement(Popover2.VirtualTrigger, {
|
|
776
724
|
virtualRef: modals.trigger
|
|
777
725
|
}), /* @__PURE__ */ React5.createElement(Popover2.Portal, null, /* @__PURE__ */ React5.createElement(Popover2.Content, {
|
|
778
|
-
classNames: "md:
|
|
726
|
+
classNames: "md:w-64"
|
|
779
727
|
}, /* @__PURE__ */ React5.createElement(Popover2.Viewport, null, /* @__PURE__ */ React5.createElement(FieldEditor, {
|
|
780
728
|
projection: model.projection,
|
|
781
729
|
field,
|
|
@@ -789,8 +737,9 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
|
|
|
789
737
|
import { useAtomValue as useAtomValue3 } from "@effect-atom/atom-react";
|
|
790
738
|
import React6 from "react";
|
|
791
739
|
import { DropdownMenu as DropdownMenu2, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
740
|
+
import { translationKey as translationKey3 } from "#translations";
|
|
792
741
|
var RowActionsMenu = ({ model, modals }) => {
|
|
793
|
-
const { t } = useTranslation2(
|
|
742
|
+
const { t } = useTranslation2(translationKey3);
|
|
794
743
|
const hasSelection = model.selection.hasSelection;
|
|
795
744
|
const state = useAtomValue3(modals.state);
|
|
796
745
|
if (state?.type !== "row") {
|
|
@@ -812,11 +761,11 @@ var RowActionsMenu = ({ model, modals }) => {
|
|
|
812
761
|
}, toLocalizedString(action.label, t)))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Separator, null)), model.features.dataEditable !== false && /* @__PURE__ */ React6.createElement(DropdownMenu2.Item, {
|
|
813
762
|
"data-testid": "row-menu-delete",
|
|
814
763
|
onClick: () => model.deleteRow(state.rowIndex)
|
|
815
|
-
}, t(hasSelection ? "bulk
|
|
764
|
+
}, t(hasSelection ? "bulk-delete-row.label" : "delete-row.label"))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Arrow, null)));
|
|
816
765
|
};
|
|
817
766
|
|
|
818
|
-
// src/components/Table/
|
|
819
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/Table/
|
|
767
|
+
// src/components/Table/TableContent.tsx
|
|
768
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/Table/TableContent.tsx";
|
|
820
769
|
var columnDefault = {
|
|
821
770
|
grid: {
|
|
822
771
|
minSize: 80,
|
|
@@ -832,22 +781,10 @@ var rowDefault = {
|
|
|
832
781
|
var emptyColumnMeta = Atom2.make({
|
|
833
782
|
grid: {}
|
|
834
783
|
});
|
|
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
784
|
var emptyRowsAtom = Atom2.make([]);
|
|
849
785
|
var emptyCellUpdateAtom = Atom2.make(0);
|
|
850
|
-
var
|
|
786
|
+
var TABLE_CONTENT_NAME = "Table.Content";
|
|
787
|
+
var TableContent = composable(({ schema, model, presentation, ignoreAttention, onCreate, onRowClick, testId, ...props }, forwardedRef) => {
|
|
851
788
|
const registry = useContext(RegistryContext);
|
|
852
789
|
const [dxGrid, setDxGrid] = useState4(null);
|
|
853
790
|
const { hasAttention } = useAttention(model?.id ?? "table");
|
|
@@ -1055,12 +992,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1055
992
|
void navigator.clipboard.writeText(textContent);
|
|
1056
993
|
event.preventDefault();
|
|
1057
994
|
} 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
|
-
});
|
|
995
|
+
log.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 262, S: void 0 });
|
|
1064
996
|
}
|
|
1065
997
|
break;
|
|
1066
998
|
}
|
|
@@ -1135,7 +1067,8 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1135
1067
|
model,
|
|
1136
1068
|
dxGrid
|
|
1137
1069
|
]);
|
|
1138
|
-
|
|
1070
|
+
const { controllerRef } = useTableContext(TABLE_CONTENT_NAME);
|
|
1071
|
+
controllerRef.current = useMemo4(() => {
|
|
1139
1072
|
if (!dxGrid || !presentation) {
|
|
1140
1073
|
return {};
|
|
1141
1074
|
}
|
|
@@ -1158,10 +1091,15 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1158
1091
|
if (!model || !modals) {
|
|
1159
1092
|
return /* @__PURE__ */ React7.createElement("span", {
|
|
1160
1093
|
role: "none",
|
|
1161
|
-
className: "attention-surface"
|
|
1094
|
+
className: "dx-attention-surface"
|
|
1162
1095
|
});
|
|
1163
1096
|
}
|
|
1164
|
-
return /* @__PURE__ */ React7.createElement(
|
|
1097
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
1098
|
+
...composableProps(props, {
|
|
1099
|
+
classNames: "dx-container relative"
|
|
1100
|
+
}),
|
|
1101
|
+
ref: forwardedRef
|
|
1102
|
+
}, /* @__PURE__ */ React7.createElement(Grid.Root, {
|
|
1165
1103
|
id: model.id ?? "table-grid"
|
|
1166
1104
|
}, /* @__PURE__ */ React7.createElement(TableValueEditor, {
|
|
1167
1105
|
model,
|
|
@@ -1171,7 +1109,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1171
1109
|
onSave: handleSave,
|
|
1172
1110
|
onCreate
|
|
1173
1111
|
}), /* @__PURE__ */ React7.createElement(Grid.Content, {
|
|
1174
|
-
className: mx("[--dx-grid-base:var(--
|
|
1112
|
+
className: mx("[--dx-grid-base:var(--base-surface)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
|
|
1175
1113
|
frozen,
|
|
1176
1114
|
columns: columnMeta,
|
|
1177
1115
|
columnDefault,
|
|
@@ -1197,94 +1135,16 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1197
1135
|
model,
|
|
1198
1136
|
modals,
|
|
1199
1137
|
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
|
-
};
|
|
1138
|
+
})));
|
|
1139
|
+
});
|
|
1140
|
+
TableContent.displayName = TABLE_CONTENT_NAME;
|
|
1283
1141
|
|
|
1284
|
-
// src/components/
|
|
1285
|
-
import { Atom as Atom3, RegistryContext as
|
|
1286
|
-
import
|
|
1287
|
-
import {
|
|
1142
|
+
// src/components/Table/TableToolbar.tsx
|
|
1143
|
+
import { Atom as Atom3, RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
|
|
1144
|
+
import React8, { useContext as useContext2, useEffect as useEffect4, useMemo as useMemo5 } from "react";
|
|
1145
|
+
import { Menu, createGapSeparator, createMenuAction, useMenuActions } from "@dxos/react-ui-menu";
|
|
1146
|
+
import { composable as composable2, composableProps as composableProps2 } from "@dxos/ui-theme";
|
|
1147
|
+
import { translationKey as translationKey4 } from "#translations";
|
|
1288
1148
|
var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) => Atom3.make((get) => {
|
|
1289
1149
|
const nodes = [];
|
|
1290
1150
|
if (onAdd) {
|
|
@@ -1292,9 +1152,9 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
|
|
|
1292
1152
|
type: "add-row",
|
|
1293
1153
|
icon: "ph--plus--regular",
|
|
1294
1154
|
label: [
|
|
1295
|
-
"add
|
|
1155
|
+
"add-row.label",
|
|
1296
1156
|
{
|
|
1297
|
-
ns:
|
|
1157
|
+
ns: translationKey4
|
|
1298
1158
|
}
|
|
1299
1159
|
],
|
|
1300
1160
|
testId: "table.toolbar.add-row"
|
|
@@ -1307,9 +1167,9 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
|
|
|
1307
1167
|
type: "save-view",
|
|
1308
1168
|
icon: "ph--floppy-disk--regular",
|
|
1309
1169
|
label: [
|
|
1310
|
-
"save
|
|
1170
|
+
"save-view.label",
|
|
1311
1171
|
{
|
|
1312
|
-
ns:
|
|
1172
|
+
ns: translationKey4
|
|
1313
1173
|
}
|
|
1314
1174
|
],
|
|
1315
1175
|
testId: "table.toolbar.save-view",
|
|
@@ -1322,7 +1182,8 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
|
|
|
1322
1182
|
nodes.push(...gap.nodes);
|
|
1323
1183
|
const edges = nodes.map(({ id: target }) => ({
|
|
1324
1184
|
source: "root",
|
|
1325
|
-
target
|
|
1185
|
+
target,
|
|
1186
|
+
relation: "child"
|
|
1326
1187
|
}));
|
|
1327
1188
|
if (customActions) {
|
|
1328
1189
|
const custom = get(customActions);
|
|
@@ -1334,12 +1195,12 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
|
|
|
1334
1195
|
edges
|
|
1335
1196
|
};
|
|
1336
1197
|
});
|
|
1337
|
-
var TableToolbar = ({
|
|
1338
|
-
const registry =
|
|
1339
|
-
const stateAtom =
|
|
1198
|
+
var TableToolbar = composable2(({ attendableId, viewDirty, onAdd, onSave, customActions, ...props }, forwardedRef) => {
|
|
1199
|
+
const registry = useContext2(RegistryContext2);
|
|
1200
|
+
const stateAtom = useMemo5(() => Atom3.make({
|
|
1340
1201
|
viewDirty
|
|
1341
1202
|
}), []);
|
|
1342
|
-
|
|
1203
|
+
useEffect4(() => {
|
|
1343
1204
|
registry.set(stateAtom, {
|
|
1344
1205
|
viewDirty
|
|
1345
1206
|
});
|
|
@@ -1348,7 +1209,7 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, custom
|
|
|
1348
1209
|
stateAtom,
|
|
1349
1210
|
viewDirty
|
|
1350
1211
|
]);
|
|
1351
|
-
const actionsCreator =
|
|
1212
|
+
const actionsCreator = useMemo5(() => createTableToolbarActions({
|
|
1352
1213
|
stateAtom,
|
|
1353
1214
|
onAdd,
|
|
1354
1215
|
onSave,
|
|
@@ -1359,13 +1220,113 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, custom
|
|
|
1359
1220
|
onSave,
|
|
1360
1221
|
customActions
|
|
1361
1222
|
]);
|
|
1362
|
-
const
|
|
1363
|
-
return /* @__PURE__ */
|
|
1364
|
-
...
|
|
1223
|
+
const menuActions = useMenuActions(actionsCreator);
|
|
1224
|
+
return /* @__PURE__ */ React8.createElement(Menu.Root, {
|
|
1225
|
+
...menuActions,
|
|
1365
1226
|
attendableId
|
|
1366
|
-
}, /* @__PURE__ */
|
|
1367
|
-
|
|
1227
|
+
}, /* @__PURE__ */ React8.createElement(Menu.Toolbar, {
|
|
1228
|
+
...composableProps2(props),
|
|
1229
|
+
ref: forwardedRef
|
|
1230
|
+
}));
|
|
1231
|
+
});
|
|
1232
|
+
TableToolbar.displayName = "TableToolbar";
|
|
1233
|
+
|
|
1234
|
+
// src/components/Table/Table.tsx
|
|
1235
|
+
var emptyColumnMeta2 = Atom4.make({
|
|
1236
|
+
grid: {}
|
|
1237
|
+
});
|
|
1238
|
+
var [TableContextProvider, useTableContext] = createContext("Table");
|
|
1239
|
+
var TABLE_ROOT_NAME = "Table.Root";
|
|
1240
|
+
var TableRoot = /* @__PURE__ */ forwardRef(({ children }, forwardedRef) => {
|
|
1241
|
+
const controllerRef = useRef3({});
|
|
1242
|
+
useImperativeHandle(forwardedRef, () => ({
|
|
1243
|
+
update: (cell) => controllerRef.current?.update?.(cell),
|
|
1244
|
+
handleInsertRowResult: (result) => controllerRef.current?.handleInsertRowResult?.(result)
|
|
1245
|
+
}), []);
|
|
1246
|
+
return /* @__PURE__ */ React9.createElement(TableContextProvider, {
|
|
1247
|
+
controllerRef
|
|
1248
|
+
}, children);
|
|
1249
|
+
});
|
|
1250
|
+
TableRoot.displayName = TABLE_ROOT_NAME;
|
|
1251
|
+
var Table = {
|
|
1252
|
+
Root: TableRoot,
|
|
1253
|
+
Toolbar: TableToolbar,
|
|
1254
|
+
Content: TableContent
|
|
1255
|
+
};
|
|
1256
|
+
|
|
1257
|
+
// src/components/Table/DynamicTable.tsx
|
|
1258
|
+
import { RegistryContext as RegistryContext3 } from "@effect-atom/atom-react";
|
|
1259
|
+
import React10, { useCallback as useCallback5, useContext as useContext3, useEffect as useEffect5, useMemo as useMemo6, useRef as useRef4, useState as useState5 } from "react";
|
|
1260
|
+
import { useDefaultValue } from "@dxos/react-ui";
|
|
1261
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
1262
|
+
var DynamicTable = ({ classNames, schema, name = "com.example.dynamicTable", rows, properties, jsonSchema: jsonSchemaProp, rowActions, onRowClick, onRowAction, ...props }) => {
|
|
1263
|
+
const registry = useContext3(RegistryContext3);
|
|
1264
|
+
const [dynamicTable, setDynamicTable] = useState5();
|
|
1265
|
+
const { jsonSchema } = useMemo6(() => getBaseSchema({
|
|
1266
|
+
typename: name,
|
|
1267
|
+
properties,
|
|
1268
|
+
jsonSchema: jsonSchemaProp,
|
|
1269
|
+
schema
|
|
1270
|
+
}), [
|
|
1271
|
+
name,
|
|
1272
|
+
properties,
|
|
1273
|
+
jsonSchemaProp,
|
|
1274
|
+
schema
|
|
1275
|
+
]);
|
|
1276
|
+
useEffect5(() => {
|
|
1277
|
+
setDynamicTable(makeDynamicTable({
|
|
1278
|
+
registry,
|
|
1279
|
+
jsonSchema,
|
|
1280
|
+
properties
|
|
1281
|
+
}));
|
|
1282
|
+
}, [
|
|
1283
|
+
registry,
|
|
1284
|
+
jsonSchema,
|
|
1285
|
+
properties
|
|
1286
|
+
]);
|
|
1287
|
+
const tableRef = useRef4(null);
|
|
1288
|
+
const handleCellUpdate = useCallback5((cell) => {
|
|
1289
|
+
tableRef.current?.update?.(cell);
|
|
1290
|
+
}, []);
|
|
1291
|
+
const handleRowOrderChange = useCallback5(() => {
|
|
1292
|
+
tableRef.current?.update?.();
|
|
1293
|
+
}, []);
|
|
1294
|
+
const features = useDefaultValue(props.features, () => ({
|
|
1295
|
+
selection: {
|
|
1296
|
+
enabled: false
|
|
1297
|
+
},
|
|
1298
|
+
dataEditable: false
|
|
1368
1299
|
}));
|
|
1300
|
+
const model = useTableModel({
|
|
1301
|
+
rows,
|
|
1302
|
+
object: dynamicTable?.object,
|
|
1303
|
+
projection: dynamicTable?.projection,
|
|
1304
|
+
features,
|
|
1305
|
+
rowActions,
|
|
1306
|
+
onCellUpdate: handleCellUpdate,
|
|
1307
|
+
onRowOrderChange: handleRowOrderChange,
|
|
1308
|
+
onRowAction
|
|
1309
|
+
});
|
|
1310
|
+
const presentation = useMemo6(() => {
|
|
1311
|
+
if (model) {
|
|
1312
|
+
return new TablePresentation(registry, model);
|
|
1313
|
+
}
|
|
1314
|
+
}, [
|
|
1315
|
+
registry,
|
|
1316
|
+
model
|
|
1317
|
+
]);
|
|
1318
|
+
return /* @__PURE__ */ React10.createElement("div", {
|
|
1319
|
+
className: mx2("dx-expander grid", classNames)
|
|
1320
|
+
}, /* @__PURE__ */ React10.createElement("div", {
|
|
1321
|
+
className: "grid min-h-0 overflow-hidden"
|
|
1322
|
+
}, /* @__PURE__ */ React10.createElement(Table.Root, {
|
|
1323
|
+
ref: tableRef
|
|
1324
|
+
}, /* @__PURE__ */ React10.createElement(Table.Content, {
|
|
1325
|
+
model,
|
|
1326
|
+
presentation,
|
|
1327
|
+
ignoreAttention: true,
|
|
1328
|
+
onRowClick
|
|
1329
|
+
}))));
|
|
1369
1330
|
};
|
|
1370
1331
|
export {
|
|
1371
1332
|
BUTTON_IDENTIFIERS,
|
|
@@ -1377,7 +1338,6 @@ export {
|
|
|
1377
1338
|
Table,
|
|
1378
1339
|
TableModel,
|
|
1379
1340
|
TablePresentation,
|
|
1380
|
-
TableToolbar,
|
|
1381
1341
|
cellClassesForRowSelection,
|
|
1382
1342
|
compareValues,
|
|
1383
1343
|
createDirectChangeCallback,
|
|
@@ -1390,9 +1350,9 @@ export {
|
|
|
1390
1350
|
tableButtons,
|
|
1391
1351
|
tableControls,
|
|
1392
1352
|
touch,
|
|
1393
|
-
translations,
|
|
1394
1353
|
useAddRow,
|
|
1395
1354
|
useProjectionModel,
|
|
1355
|
+
useTableContext,
|
|
1396
1356
|
useTableModel
|
|
1397
1357
|
};
|
|
1398
1358
|
//# sourceMappingURL=index.mjs.map
|