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