@dxos/react-ui-table 0.8.4-main.937b3ca → 0.8.4-main.9be5663bfe
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-BF54SSNL.mjs} +12 -18
- package/dist/lib/browser/chunk-BF54SSNL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-MNZKOFMA.mjs → chunk-F7Y374KL.mjs} +41 -36
- package/dist/lib/browser/chunk-F7Y374KL.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +205 -179
- 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 -6
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/{chunk-2ATAIIAO.mjs → chunk-CCJ4LOVM.mjs} +41 -36
- package/dist/lib/node-esm/chunk-CCJ4LOVM.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-WNZSKIRF.mjs → chunk-SIRDIPHZ.mjs} +12 -18
- package/dist/lib/node-esm/chunk-SIRDIPHZ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +205 -179
- 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 -6
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +5 -4
- 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 +81 -82
- package/dist/types/src/components/Table/Relations.stories.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 +83 -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/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/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 +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 +2 -1
- package/dist/types/src/playwright/TableManager.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 +6 -5
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.test.d.ts +2 -0
- package/dist/types/src/util/dynamic-table.test.d.ts.map +1 -0
- package/dist/types/src/util/query-ast.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +43 -43
- package/src/components/Table/ColumnActionsMenu.tsx +5 -5
- package/src/components/Table/ColumnSettings.tsx +3 -4
- package/src/components/Table/DynamicTable.stories.tsx +17 -17
- package/src/components/Table/DynamicTable.tsx +13 -20
- package/src/components/Table/Relations.stories.tsx +38 -30
- package/src/components/Table/Table.stories.tsx +69 -49
- package/src/components/Table/Table.tsx +41 -435
- package/src/components/Table/TableContent.tsx +421 -0
- package/src/components/{TableToolbar → Table}/TableToolbar.tsx +35 -42
- package/src/components/TableCellEditor/CellValidationMessage.tsx +4 -4
- package/src/components/TableCellEditor/FormCellEditor.tsx +12 -6
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +11 -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 +7 -8
- package/src/hooks/useTableModel.ts +1 -1
- package/src/model/table-model.test.ts +5 -6
- package/src/model/table-model.ts +15 -14
- package/src/model/table-presentation.test.ts +5 -6
- package/src/model/table-presentation.ts +12 -12
- package/src/playwright/TableManager.ts +10 -3
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/smoke.spec.ts +48 -5
- package/src/testing/useTestTableModel.ts +6 -6
- package/src/translations.ts +19 -21
- package/src/types/Table.ts +11 -22
- package/src/util/dynamic-table.test.ts +70 -0
- package/src/util/dynamic-table.ts +17 -16
- 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-MNZKOFMA.mjs.map +0 -7
- package/dist/lib/browser/chunk-OZBLY7XM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2ATAIIAO.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,10 +17,10 @@ import {
|
|
|
17
17
|
useAddRow,
|
|
18
18
|
useProjectionModel,
|
|
19
19
|
useTableModel
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-CCJ4LOVM.mjs";
|
|
21
21
|
import {
|
|
22
22
|
Table_exports
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-SIRDIPHZ.mjs";
|
|
24
24
|
|
|
25
25
|
// src/translations.ts
|
|
26
26
|
var translationKey = "@dxos/react-ui-table";
|
|
@@ -28,56 +28,59 @@ var translations = [
|
|
|
28
28
|
{
|
|
29
29
|
"en-US": {
|
|
30
30
|
[translationKey]: {
|
|
31
|
-
"object
|
|
32
|
-
"create
|
|
33
|
-
"table
|
|
34
|
-
"settings
|
|
35
|
-
"table
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"column
|
|
42
|
-
"column
|
|
43
|
-
"column
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"create new object label": "Create new object \u201C{{text}}\u201D",
|
|
51
|
-
"save view label": "Save changes to view"
|
|
31
|
+
"object.placeholder": "New table",
|
|
32
|
+
"create-object.label": "Create table",
|
|
33
|
+
"table-name.placeholder": "Table name",
|
|
34
|
+
"settings.title": "Table settings",
|
|
35
|
+
"table-schema.label": "Type",
|
|
36
|
+
"continue.label": "Continue",
|
|
37
|
+
"create-stack-section.label": "Create table",
|
|
38
|
+
"add-row.label": "Add row",
|
|
39
|
+
"column-action-sort-descending.menu": "Sort Descending",
|
|
40
|
+
"column-action-sort-ascending.menu": "Sort Ascending",
|
|
41
|
+
"column-action-clear-sorting.menu": "Clear Sorting",
|
|
42
|
+
"column-action-settings.menu": "Column Settings",
|
|
43
|
+
"column-action-delete.menu": "Delete Column",
|
|
44
|
+
"delete-row.label": "Delete row",
|
|
45
|
+
"bulk-delete-row.label": "Delete selected rows",
|
|
46
|
+
"column-deleted.label": "Column deleted",
|
|
47
|
+
"new-column-button.label": "Create column",
|
|
48
|
+
"create-new-object.label": "Create new object \u201C{{text}}\u201D",
|
|
49
|
+
"save-view.label": "Save changes to view"
|
|
52
50
|
}
|
|
53
51
|
}
|
|
54
52
|
}
|
|
55
53
|
];
|
|
56
54
|
|
|
57
55
|
// src/components/Table/Table.tsx
|
|
56
|
+
import { Atom as Atom4 } from "@effect-atom/atom-react";
|
|
57
|
+
import { createContext } from "@radix-ui/react-context";
|
|
58
|
+
import React9, { forwardRef, useImperativeHandle, useRef as useRef3 } from "react";
|
|
59
|
+
|
|
60
|
+
// src/components/Table/TableContent.tsx
|
|
58
61
|
import { Atom as Atom2, RegistryContext, useAtomValue as useAtomValue4 } from "@effect-atom/atom-react";
|
|
59
62
|
import * as String2 from "effect/String";
|
|
60
|
-
import React7, {
|
|
63
|
+
import React7, { useCallback as useCallback4, useContext, useEffect as useEffect3, useMemo as useMemo4, useState as useState4 } from "react";
|
|
61
64
|
import { log } from "@dxos/log";
|
|
62
65
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
63
66
|
import { Grid, closestCell, gridSeparatorBlockEnd, gridSeparatorInlineEnd } from "@dxos/react-ui-grid";
|
|
64
67
|
import { DxEditRequest } from "@dxos/react-ui-grid";
|
|
65
|
-
import { mx } from "@dxos/ui-theme";
|
|
68
|
+
import { composable, composableProps, mx } from "@dxos/ui-theme";
|
|
66
69
|
|
|
67
70
|
// src/util/dynamic-table.ts
|
|
68
|
-
import { Filter, Obj, Order, Query, Ref, Type } from "@dxos/echo";
|
|
69
|
-
import { ProjectionModel,
|
|
71
|
+
import { Filter, JsonSchema, Obj, Order, Query, Ref, Type } from "@dxos/echo";
|
|
72
|
+
import { ProjectionModel, ViewModel, createEchoChangeCallback as createEchoChangeCallback2, getSchemaFromPropertyDefinitions } from "@dxos/schema";
|
|
70
73
|
var getBaseSchema = ({ schema, typename, properties, jsonSchema }) => {
|
|
71
74
|
if (typename && properties) {
|
|
72
75
|
const schema2 = getSchemaFromPropertyDefinitions(typename, properties);
|
|
73
76
|
return {
|
|
74
77
|
typename: schema2.typename,
|
|
75
|
-
jsonSchema: schema2
|
|
78
|
+
jsonSchema: JsonSchema.toJsonSchema(schema2)
|
|
76
79
|
};
|
|
77
80
|
} else if (schema) {
|
|
78
81
|
return {
|
|
79
82
|
typename: Type.getTypename(schema),
|
|
80
|
-
jsonSchema:
|
|
83
|
+
jsonSchema: JsonSchema.toJsonSchema(schema)
|
|
81
84
|
};
|
|
82
85
|
} else if (typename && jsonSchema) {
|
|
83
86
|
return {
|
|
@@ -89,7 +92,7 @@ var getBaseSchema = ({ schema, typename, properties, jsonSchema }) => {
|
|
|
89
92
|
}
|
|
90
93
|
};
|
|
91
94
|
var makeDynamicTable = ({ registry, jsonSchema, properties }) => {
|
|
92
|
-
const view =
|
|
95
|
+
const view = ViewModel.make({
|
|
93
96
|
query: Query.select(Filter.everything()),
|
|
94
97
|
jsonSchema,
|
|
95
98
|
...properties && {
|
|
@@ -104,7 +107,7 @@ var makeDynamicTable = ({ registry, jsonSchema, properties }) => {
|
|
|
104
107
|
registry,
|
|
105
108
|
view,
|
|
106
109
|
baseSchema: jsonSchema,
|
|
107
|
-
change:
|
|
110
|
+
change: createEchoChangeCallback2(view, jsonSchema)
|
|
108
111
|
});
|
|
109
112
|
projection.normalizeView();
|
|
110
113
|
if (properties && projection.getFields()) {
|
|
@@ -120,8 +123,8 @@ var setProperties = (view, projection, table, properties) => {
|
|
|
120
123
|
const field = projection.getFields().find((field2) => field2.path === property.name);
|
|
121
124
|
if (field) {
|
|
122
125
|
if (property.size !== void 0) {
|
|
123
|
-
Obj.change(table, (
|
|
124
|
-
|
|
126
|
+
Obj.change(table, (table2) => {
|
|
127
|
+
table2.sizes[field.path] = property.size;
|
|
125
128
|
});
|
|
126
129
|
}
|
|
127
130
|
if (property.title !== void 0) {
|
|
@@ -137,8 +140,8 @@ var setProperties = (view, projection, table, properties) => {
|
|
|
137
140
|
if (property.sort) {
|
|
138
141
|
const currentQuery = Query.fromAst(Obj.getSnapshot(view).query.ast);
|
|
139
142
|
const newQuery = currentQuery.orderBy(Order.property(field.path, property.sort));
|
|
140
|
-
Obj.change(view, (
|
|
141
|
-
|
|
143
|
+
Obj.change(view, (view2) => {
|
|
144
|
+
view2.query.ast = newQuery.ast;
|
|
142
145
|
});
|
|
143
146
|
}
|
|
144
147
|
}
|
|
@@ -254,14 +257,14 @@ var CellValidationMessage = ({ __gridScope, validationError, variant = "error" }
|
|
|
254
257
|
if (!editing || !validationError) {
|
|
255
258
|
return null;
|
|
256
259
|
}
|
|
257
|
-
const bgClass = variant === "error" ? "bg-
|
|
258
|
-
const textClass = variant === "error" ? "text-
|
|
260
|
+
const bgClass = variant === "error" ? "bg-error-surface" : "bg-warning-surface";
|
|
261
|
+
const textClass = variant === "error" ? "text-error-surface-text" : "text-warning-surface-text";
|
|
259
262
|
return /* @__PURE__ */ React.createElement("div", {
|
|
260
263
|
role: "none",
|
|
261
|
-
className: `absolute ${bgClass} ${textClass} rounded-
|
|
264
|
+
className: `absolute ${bgClass} ${textClass} rounded-h-sm text-xs p-1`,
|
|
262
265
|
style: {
|
|
263
266
|
...{
|
|
264
|
-
"--dx-
|
|
267
|
+
"--dx-grid-cell-width": `${box?.inlineSize ?? 200}px`
|
|
265
268
|
},
|
|
266
269
|
zIndex: 10,
|
|
267
270
|
insetBlockEnd: `calc(100% - ${box.insetBlockStart}px)`,
|
|
@@ -282,7 +285,7 @@ import { parseCellIndex, useGridContext as useGridContext2 } from "@dxos/react-u
|
|
|
282
285
|
import { getDeep, isTruthy, setDeep } from "@dxos/util";
|
|
283
286
|
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx";
|
|
284
287
|
var createOptionLabel = [
|
|
285
|
-
"create
|
|
288
|
+
"create-new-object.label",
|
|
286
289
|
{
|
|
287
290
|
ns: translationKey
|
|
288
291
|
}
|
|
@@ -347,9 +350,13 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
347
350
|
model,
|
|
348
351
|
contextEditing
|
|
349
352
|
]);
|
|
350
|
-
const
|
|
353
|
+
const initialFormValues = useMemo(() => originalRow ? JSON.parse(JSON.stringify(originalRow)) : {}, [
|
|
351
354
|
originalRow
|
|
352
355
|
]);
|
|
356
|
+
const [formValues, setFormValues] = useState(initialFormValues);
|
|
357
|
+
const handleValuesChanged = useCallback((values) => {
|
|
358
|
+
setFormValues(values);
|
|
359
|
+
}, []);
|
|
353
360
|
const handleOpenChange = useCallback((nextOpen) => {
|
|
354
361
|
if (nextOpen === false) {
|
|
355
362
|
setEditing(null);
|
|
@@ -434,12 +441,14 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
434
441
|
virtualRef: anchorRef
|
|
435
442
|
}), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
|
|
436
443
|
tabIndex: -1,
|
|
437
|
-
classNames: "
|
|
444
|
+
classNames: "dx-card-popover-width dx-density-fine"
|
|
438
445
|
}, /* @__PURE__ */ React2.createElement(Popover.Arrow, null), /* @__PURE__ */ React2.createElement(Popover.Viewport, null, /* @__PURE__ */ React2.createElement(Form.Root, {
|
|
439
446
|
...formProps,
|
|
440
447
|
autoFocus: true,
|
|
441
448
|
schema: narrowedSchema,
|
|
442
449
|
values: formValues,
|
|
450
|
+
onValuesChanged: handleValuesChanged,
|
|
451
|
+
projection: model?.projection,
|
|
443
452
|
createInitialValuePath: fieldProjection.field.referencePath,
|
|
444
453
|
createOptionIcon: "ph--plus--regular",
|
|
445
454
|
createOptionLabel,
|
|
@@ -452,11 +461,6 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
452
461
|
|
|
453
462
|
// src/components/TableCellEditor/TableCellEditor.tsx
|
|
454
463
|
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
464
|
var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, onCreate }) => {
|
|
461
465
|
const { editing } = useGridContext3("TableValueEditor", __gridScope);
|
|
462
466
|
const fieldProjection = useMemo2(() => {
|
|
@@ -468,7 +472,7 @@ var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, o
|
|
|
468
472
|
const fieldProjection2 = model.projection.getFieldProjection(field.id);
|
|
469
473
|
invariant2(fieldProjection2, void 0, {
|
|
470
474
|
F: __dxlog_file2,
|
|
471
|
-
L:
|
|
475
|
+
L: 66,
|
|
472
476
|
S: void 0,
|
|
473
477
|
A: [
|
|
474
478
|
"fieldProjection",
|
|
@@ -513,7 +517,7 @@ var TableCellEditor = ({ __gridScope, model, modals, onFocus, onSave }) => {
|
|
|
513
517
|
const fieldProjection2 = model.projection.getFieldProjection(field.id);
|
|
514
518
|
invariant2(fieldProjection2, void 0, {
|
|
515
519
|
F: __dxlog_file2,
|
|
516
|
-
L:
|
|
520
|
+
L: 113,
|
|
517
521
|
S: void 0,
|
|
518
522
|
A: [
|
|
519
523
|
"fieldProjection",
|
|
@@ -653,9 +657,13 @@ var TableCellEditor = ({ __gridScope, model, modals, onFocus, onSave }) => {
|
|
|
653
657
|
__gridScope
|
|
654
658
|
}), /* @__PURE__ */ React3.createElement(GridCellEditor, {
|
|
655
659
|
extensions,
|
|
660
|
+
slots: {
|
|
661
|
+
content: {
|
|
662
|
+
className: "!py-(--dx-grid-cell-editor-padding-block)"
|
|
663
|
+
}
|
|
664
|
+
},
|
|
656
665
|
getCellContent,
|
|
657
|
-
onBlur: handleBlur
|
|
658
|
-
slots: editorSlots
|
|
666
|
+
onBlur: handleBlur
|
|
659
667
|
}));
|
|
660
668
|
};
|
|
661
669
|
var determineNavigationAxis = ({ key }) => {
|
|
@@ -704,19 +712,19 @@ var ColumnActionsMenu = ({ model, modals }) => {
|
|
|
704
712
|
}), /* @__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
713
|
"data-testid": "column-sort-descending",
|
|
706
714
|
onClick: () => model.setSort(state.fieldId, "desc")
|
|
707
|
-
}, t("column
|
|
715
|
+
}, t("column-action-sort-descending.menu")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
708
716
|
"data-testid": "column-sort-ascending",
|
|
709
717
|
onClick: () => model.setSort(state.fieldId, "asc")
|
|
710
|
-
}, t("column
|
|
718
|
+
}, t("column-action-sort-ascending.menu")), isCurrentColumnSorted && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
711
719
|
"data-testid": "column-clear-sort",
|
|
712
720
|
onClick: () => model.clearSort()
|
|
713
|
-
}, t("column
|
|
721
|
+
}, t("column-action-clear-sorting.menu")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
714
722
|
"data-testid": "column-delete",
|
|
715
723
|
onClick: () => model.deleteColumn(state.fieldId)
|
|
716
|
-
}, t("column
|
|
724
|
+
}, t("column-action-delete.menu")), model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
717
725
|
"data-testid": "column-settings",
|
|
718
726
|
onClick: () => modals.openColumnSettings()
|
|
719
|
-
}, t("column
|
|
727
|
+
}, t("column-action-settings.menu"))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))));
|
|
720
728
|
};
|
|
721
729
|
|
|
722
730
|
// src/components/Table/ColumnSettings.tsx
|
|
@@ -776,7 +784,7 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
|
|
|
776
784
|
}, /* @__PURE__ */ React5.createElement(Popover2.VirtualTrigger, {
|
|
777
785
|
virtualRef: modals.trigger
|
|
778
786
|
}), /* @__PURE__ */ React5.createElement(Popover2.Portal, null, /* @__PURE__ */ React5.createElement(Popover2.Content, {
|
|
779
|
-
classNames: "md:
|
|
787
|
+
classNames: "md:w-64"
|
|
780
788
|
}, /* @__PURE__ */ React5.createElement(Popover2.Viewport, null, /* @__PURE__ */ React5.createElement(FieldEditor, {
|
|
781
789
|
projection: model.projection,
|
|
782
790
|
field,
|
|
@@ -816,8 +824,8 @@ var RowActionsMenu = ({ model, modals }) => {
|
|
|
816
824
|
}, t(hasSelection ? "bulk delete row label" : "delete row label"))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Arrow, null)));
|
|
817
825
|
};
|
|
818
826
|
|
|
819
|
-
// src/components/Table/
|
|
820
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/Table/
|
|
827
|
+
// src/components/Table/TableContent.tsx
|
|
828
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/Table/TableContent.tsx";
|
|
821
829
|
var columnDefault = {
|
|
822
830
|
grid: {
|
|
823
831
|
minSize: 80,
|
|
@@ -833,22 +841,10 @@ var rowDefault = {
|
|
|
833
841
|
var emptyColumnMeta = Atom2.make({
|
|
834
842
|
grid: {}
|
|
835
843
|
});
|
|
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
844
|
var emptyRowsAtom = Atom2.make([]);
|
|
850
845
|
var emptyCellUpdateAtom = Atom2.make(0);
|
|
851
|
-
var
|
|
846
|
+
var TABLE_CONTENT_NAME = "Table.Content";
|
|
847
|
+
var TableContent = composable(({ schema, model, presentation, ignoreAttention, onCreate, onRowClick, testId, ...props }, forwardedRef) => {
|
|
852
848
|
const registry = useContext(RegistryContext);
|
|
853
849
|
const [dxGrid, setDxGrid] = useState4(null);
|
|
854
850
|
const { hasAttention } = useAttention(model?.id ?? "table");
|
|
@@ -1058,7 +1054,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1058
1054
|
} catch (error) {
|
|
1059
1055
|
log.catch(error, void 0, {
|
|
1060
1056
|
F: __dxlog_file3,
|
|
1061
|
-
L:
|
|
1057
|
+
L: 278,
|
|
1062
1058
|
S: void 0,
|
|
1063
1059
|
C: (f, a) => f(...a)
|
|
1064
1060
|
});
|
|
@@ -1136,7 +1132,8 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1136
1132
|
model,
|
|
1137
1133
|
dxGrid
|
|
1138
1134
|
]);
|
|
1139
|
-
|
|
1135
|
+
const { controllerRef } = useTableContext(TABLE_CONTENT_NAME);
|
|
1136
|
+
controllerRef.current = useMemo4(() => {
|
|
1140
1137
|
if (!dxGrid || !presentation) {
|
|
1141
1138
|
return {};
|
|
1142
1139
|
}
|
|
@@ -1159,10 +1156,15 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1159
1156
|
if (!model || !modals) {
|
|
1160
1157
|
return /* @__PURE__ */ React7.createElement("span", {
|
|
1161
1158
|
role: "none",
|
|
1162
|
-
className: "attention-surface"
|
|
1159
|
+
className: "dx-attention-surface"
|
|
1163
1160
|
});
|
|
1164
1161
|
}
|
|
1165
|
-
return /* @__PURE__ */ React7.createElement(
|
|
1162
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
1163
|
+
...composableProps(props, {
|
|
1164
|
+
classNames: "dx-container relative"
|
|
1165
|
+
}),
|
|
1166
|
+
ref: forwardedRef
|
|
1167
|
+
}, /* @__PURE__ */ React7.createElement(Grid.Root, {
|
|
1166
1168
|
id: model.id ?? "table-grid"
|
|
1167
1169
|
}, /* @__PURE__ */ React7.createElement(TableValueEditor, {
|
|
1168
1170
|
model,
|
|
@@ -1172,7 +1174,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1172
1174
|
onSave: handleSave,
|
|
1173
1175
|
onCreate
|
|
1174
1176
|
}), /* @__PURE__ */ React7.createElement(Grid.Content, {
|
|
1175
|
-
className: mx("[--dx-grid-base:var(--
|
|
1177
|
+
className: mx("[--dx-grid-base:var(--base-surface)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
|
|
1176
1178
|
frozen,
|
|
1177
1179
|
columns: columnMeta,
|
|
1178
1180
|
columnDefault,
|
|
@@ -1198,94 +1200,15 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1198
1200
|
model,
|
|
1199
1201
|
modals,
|
|
1200
1202
|
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
|
-
};
|
|
1203
|
+
})));
|
|
1204
|
+
});
|
|
1205
|
+
TableContent.displayName = TABLE_CONTENT_NAME;
|
|
1284
1206
|
|
|
1285
|
-
// src/components/
|
|
1286
|
-
import { Atom as Atom3, RegistryContext as
|
|
1287
|
-
import
|
|
1288
|
-
import {
|
|
1207
|
+
// src/components/Table/TableToolbar.tsx
|
|
1208
|
+
import { Atom as Atom3, RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
|
|
1209
|
+
import React8, { useContext as useContext2, useEffect as useEffect4, useMemo as useMemo5 } from "react";
|
|
1210
|
+
import { Menu, createGapSeparator, createMenuAction, useMenuActions } from "@dxos/react-ui-menu";
|
|
1211
|
+
import { composable as composable2, composableProps as composableProps2 } from "@dxos/ui-theme";
|
|
1289
1212
|
var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) => Atom3.make((get) => {
|
|
1290
1213
|
const nodes = [];
|
|
1291
1214
|
if (onAdd) {
|
|
@@ -1293,7 +1216,7 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
|
|
|
1293
1216
|
type: "add-row",
|
|
1294
1217
|
icon: "ph--plus--regular",
|
|
1295
1218
|
label: [
|
|
1296
|
-
"add
|
|
1219
|
+
"add-row.label",
|
|
1297
1220
|
{
|
|
1298
1221
|
ns: translationKey
|
|
1299
1222
|
}
|
|
@@ -1308,7 +1231,7 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
|
|
|
1308
1231
|
type: "save-view",
|
|
1309
1232
|
icon: "ph--floppy-disk--regular",
|
|
1310
1233
|
label: [
|
|
1311
|
-
"save
|
|
1234
|
+
"save-view.label",
|
|
1312
1235
|
{
|
|
1313
1236
|
ns: translationKey
|
|
1314
1237
|
}
|
|
@@ -1323,7 +1246,8 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
|
|
|
1323
1246
|
nodes.push(...gap.nodes);
|
|
1324
1247
|
const edges = nodes.map(({ id: target }) => ({
|
|
1325
1248
|
source: "root",
|
|
1326
|
-
target
|
|
1249
|
+
target,
|
|
1250
|
+
relation: "child"
|
|
1327
1251
|
}));
|
|
1328
1252
|
if (customActions) {
|
|
1329
1253
|
const custom = get(customActions);
|
|
@@ -1335,12 +1259,12 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
|
|
|
1335
1259
|
edges
|
|
1336
1260
|
};
|
|
1337
1261
|
});
|
|
1338
|
-
var TableToolbar = ({
|
|
1339
|
-
const registry =
|
|
1340
|
-
const stateAtom =
|
|
1262
|
+
var TableToolbar = composable2(({ attendableId, viewDirty, onAdd, onSave, customActions, ...props }, forwardedRef) => {
|
|
1263
|
+
const registry = useContext2(RegistryContext2);
|
|
1264
|
+
const stateAtom = useMemo5(() => Atom3.make({
|
|
1341
1265
|
viewDirty
|
|
1342
1266
|
}), []);
|
|
1343
|
-
|
|
1267
|
+
useEffect4(() => {
|
|
1344
1268
|
registry.set(stateAtom, {
|
|
1345
1269
|
viewDirty
|
|
1346
1270
|
});
|
|
@@ -1349,7 +1273,7 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, custom
|
|
|
1349
1273
|
stateAtom,
|
|
1350
1274
|
viewDirty
|
|
1351
1275
|
]);
|
|
1352
|
-
const actionsCreator =
|
|
1276
|
+
const actionsCreator = useMemo5(() => createTableToolbarActions({
|
|
1353
1277
|
stateAtom,
|
|
1354
1278
|
onAdd,
|
|
1355
1279
|
onSave,
|
|
@@ -1360,13 +1284,115 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, custom
|
|
|
1360
1284
|
onSave,
|
|
1361
1285
|
customActions
|
|
1362
1286
|
]);
|
|
1363
|
-
const
|
|
1364
|
-
return /* @__PURE__ */
|
|
1365
|
-
...
|
|
1287
|
+
const menuActions = useMenuActions(actionsCreator);
|
|
1288
|
+
return /* @__PURE__ */ React8.createElement(Menu.Root, {
|
|
1289
|
+
...menuActions,
|
|
1366
1290
|
attendableId
|
|
1367
|
-
}, /* @__PURE__ */
|
|
1368
|
-
|
|
1291
|
+
}, /* @__PURE__ */ React8.createElement(Menu.Toolbar, {
|
|
1292
|
+
...composableProps2(props),
|
|
1293
|
+
ref: forwardedRef
|
|
1294
|
+
}));
|
|
1295
|
+
});
|
|
1296
|
+
TableToolbar.displayName = "TableToolbar";
|
|
1297
|
+
|
|
1298
|
+
// src/components/Table/Table.tsx
|
|
1299
|
+
var emptyColumnMeta2 = Atom4.make({
|
|
1300
|
+
grid: {}
|
|
1301
|
+
});
|
|
1302
|
+
var [TableContextProvider, useTableContext] = createContext("Table");
|
|
1303
|
+
var TABLE_ROOT_NAME = "Table.Root";
|
|
1304
|
+
var TableRoot = /* @__PURE__ */ forwardRef(({ children }, forwardedRef) => {
|
|
1305
|
+
const controllerRef = useRef3({});
|
|
1306
|
+
useImperativeHandle(forwardedRef, () => ({
|
|
1307
|
+
update: (cell) => controllerRef.current?.update?.(cell),
|
|
1308
|
+
handleInsertRowResult: (result) => controllerRef.current?.handleInsertRowResult?.(result)
|
|
1309
|
+
}), []);
|
|
1310
|
+
return /* @__PURE__ */ React9.createElement(TableContextProvider, {
|
|
1311
|
+
controllerRef
|
|
1312
|
+
}, children);
|
|
1313
|
+
});
|
|
1314
|
+
TableRoot.displayName = TABLE_ROOT_NAME;
|
|
1315
|
+
var Table = {
|
|
1316
|
+
Root: TableRoot,
|
|
1317
|
+
Toolbar: TableToolbar,
|
|
1318
|
+
Content: TableContent
|
|
1319
|
+
};
|
|
1320
|
+
|
|
1321
|
+
// src/components/Table/DynamicTable.tsx
|
|
1322
|
+
import { RegistryContext as RegistryContext3 } from "@effect-atom/atom-react";
|
|
1323
|
+
import React10, { useCallback as useCallback5, useContext as useContext3, useEffect as useEffect5, useMemo as useMemo6, useRef as useRef4, useState as useState5 } from "react";
|
|
1324
|
+
import { useDefaultValue } from "@dxos/react-ui";
|
|
1325
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
1326
|
+
var DynamicTable = ({ classNames, schema, name = "com.example.dynamic-table", rows, properties, jsonSchema: jsonSchemaProp, rowActions, onRowClick, onRowAction, ...props }) => {
|
|
1327
|
+
const registry = useContext3(RegistryContext3);
|
|
1328
|
+
const [dynamicTable, setDynamicTable] = useState5();
|
|
1329
|
+
const { jsonSchema } = useMemo6(() => getBaseSchema({
|
|
1330
|
+
typename: name,
|
|
1331
|
+
properties,
|
|
1332
|
+
jsonSchema: jsonSchemaProp,
|
|
1333
|
+
schema
|
|
1334
|
+
}), [
|
|
1335
|
+
name,
|
|
1336
|
+
properties,
|
|
1337
|
+
jsonSchemaProp,
|
|
1338
|
+
schema
|
|
1339
|
+
]);
|
|
1340
|
+
useEffect5(() => {
|
|
1341
|
+
setDynamicTable(makeDynamicTable({
|
|
1342
|
+
registry,
|
|
1343
|
+
jsonSchema,
|
|
1344
|
+
properties
|
|
1345
|
+
}));
|
|
1346
|
+
}, [
|
|
1347
|
+
registry,
|
|
1348
|
+
jsonSchema,
|
|
1349
|
+
properties
|
|
1350
|
+
]);
|
|
1351
|
+
const tableRef = useRef4(null);
|
|
1352
|
+
const handleCellUpdate = useCallback5((cell) => {
|
|
1353
|
+
tableRef.current?.update?.(cell);
|
|
1354
|
+
}, []);
|
|
1355
|
+
const handleRowOrderChange = useCallback5(() => {
|
|
1356
|
+
tableRef.current?.update?.();
|
|
1357
|
+
}, []);
|
|
1358
|
+
const features = useDefaultValue(props.features, () => ({
|
|
1359
|
+
selection: {
|
|
1360
|
+
enabled: false
|
|
1361
|
+
},
|
|
1362
|
+
dataEditable: false
|
|
1369
1363
|
}));
|
|
1364
|
+
const model = useTableModel({
|
|
1365
|
+
rows,
|
|
1366
|
+
object: dynamicTable?.object,
|
|
1367
|
+
projection: dynamicTable?.projection,
|
|
1368
|
+
features,
|
|
1369
|
+
rowActions,
|
|
1370
|
+
onCellUpdate: handleCellUpdate,
|
|
1371
|
+
onRowOrderChange: handleRowOrderChange,
|
|
1372
|
+
onRowAction
|
|
1373
|
+
});
|
|
1374
|
+
const presentation = useMemo6(() => {
|
|
1375
|
+
if (model) {
|
|
1376
|
+
return new TablePresentation(registry, model);
|
|
1377
|
+
}
|
|
1378
|
+
}, [
|
|
1379
|
+
registry,
|
|
1380
|
+
model
|
|
1381
|
+
]);
|
|
1382
|
+
return /* @__PURE__ */ React10.createElement("div", {
|
|
1383
|
+
role: "none",
|
|
1384
|
+
className: mx2("dx-expander grid", classNames)
|
|
1385
|
+
}, /* @__PURE__ */ React10.createElement("div", {
|
|
1386
|
+
role: "none",
|
|
1387
|
+
className: "grid min-h-0 overflow-hidden"
|
|
1388
|
+
}, /* @__PURE__ */ React10.createElement(Table.Root, {
|
|
1389
|
+
ref: tableRef
|
|
1390
|
+
}, /* @__PURE__ */ React10.createElement(Table.Content, {
|
|
1391
|
+
model,
|
|
1392
|
+
presentation,
|
|
1393
|
+
ignoreAttention: true,
|
|
1394
|
+
onRowClick
|
|
1395
|
+
}))));
|
|
1370
1396
|
};
|
|
1371
1397
|
export {
|
|
1372
1398
|
BUTTON_IDENTIFIERS,
|
|
@@ -1378,7 +1404,6 @@ export {
|
|
|
1378
1404
|
Table,
|
|
1379
1405
|
TableModel,
|
|
1380
1406
|
TablePresentation,
|
|
1381
|
-
TableToolbar,
|
|
1382
1407
|
cellClassesForRowSelection,
|
|
1383
1408
|
compareValues,
|
|
1384
1409
|
createDirectChangeCallback,
|
|
@@ -1394,6 +1419,7 @@ export {
|
|
|
1394
1419
|
translations,
|
|
1395
1420
|
useAddRow,
|
|
1396
1421
|
useProjectionModel,
|
|
1422
|
+
useTableContext,
|
|
1397
1423
|
useTableModel
|
|
1398
1424
|
};
|
|
1399
1425
|
//# sourceMappingURL=index.mjs.map
|