@dxos/react-ui-table 0.8.4-main.bc674ce → 0.8.4-main.c351d160a8
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-I5IFW7UF.mjs → chunk-PTHMYAAM.mjs} +33 -28
- package/dist/lib/browser/chunk-PTHMYAAM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +178 -176
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +3 -3
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/{chunk-DDJKYJFY.mjs → chunk-GI72MQSG.mjs} +33 -28
- package/dist/lib/node-esm/chunk-GI72MQSG.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 +178 -176
- 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 +3 -3
- package/dist/lib/node-esm/testing/index.mjs.map +2 -2
- 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 +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +6 -6
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.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.map +1 -1
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +1 -1
- package/dist/types/src/components/TableToolbar/TableToolbar.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/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 +42 -42
- package/src/components/Table/ColumnSettings.tsx +3 -4
- package/src/components/Table/DynamicTable.stories.tsx +6 -5
- package/src/components/Table/DynamicTable.tsx +11 -10
- package/src/components/Table/Relations.stories.tsx +13 -10
- package/src/components/Table/Table.stories.tsx +54 -32
- package/src/components/Table/Table.tsx +51 -56
- package/src/components/TableCellEditor/CellValidationMessage.tsx +4 -4
- package/src/components/TableCellEditor/FormCellEditor.tsx +11 -5
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +4 -3
- package/src/components/TableCellEditor/TableCellEditor.tsx +3 -3
- package/src/components/TableToolbar/TableToolbar.tsx +6 -6
- package/src/components/testing.ts +1 -1
- package/src/hooks/useAddRow.ts +1 -1
- package/src/hooks/useProjectionModel.ts +3 -3
- package/src/hooks/useTableModel.ts +1 -1
- package/src/model/table-model.test.ts +5 -5
- package/src/model/table-model.ts +9 -8
- package/src/model/table-presentation.test.ts +5 -5
- package/src/model/table-presentation.ts +12 -11
- package/src/playwright/TableManager.ts +10 -3
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/smoke.spec.ts +45 -2
- package/src/testing/useTestTableModel.ts +3 -3
- package/src/types/Table.ts +11 -22
- package/src/util/dynamic-table.test.ts +70 -0
- package/src/util/dynamic-table.ts +13 -12
- 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-I5IFW7UF.mjs.map +0 -7
- package/dist/lib/browser/chunk-OZBLY7XM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DDJKYJFY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WNZSKIRF.mjs.map +0 -7
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
useAddRow,
|
|
18
18
|
useProjectionModel,
|
|
19
19
|
useTableModel
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-GI72MQSG.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";
|
|
@@ -55,29 +55,29 @@ var translations = [
|
|
|
55
55
|
];
|
|
56
56
|
|
|
57
57
|
// src/components/Table/Table.tsx
|
|
58
|
-
import { Atom as
|
|
58
|
+
import { Atom as Atom3, RegistryContext as RegistryContext2, useAtomValue as useAtomValue4 } from "@effect-atom/atom-react";
|
|
59
59
|
import * as String2 from "effect/String";
|
|
60
|
-
import
|
|
60
|
+
import React8, { forwardRef, useCallback as useCallback4, useContext as useContext2, useEffect as useEffect4, useImperativeHandle, useMemo as useMemo5, useState as useState4 } from "react";
|
|
61
61
|
import { log } from "@dxos/log";
|
|
62
62
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
63
63
|
import { Grid, closestCell, gridSeparatorBlockEnd, gridSeparatorInlineEnd } from "@dxos/react-ui-grid";
|
|
64
64
|
import { DxEditRequest } from "@dxos/react-ui-grid";
|
|
65
|
-
import { mx } from "@dxos/ui-theme";
|
|
65
|
+
import { composableProps, mx } from "@dxos/ui-theme";
|
|
66
66
|
|
|
67
67
|
// src/util/dynamic-table.ts
|
|
68
|
-
import { Filter, Obj, Order, Query, Ref, Type } from "@dxos/echo";
|
|
69
|
-
import { ProjectionModel,
|
|
68
|
+
import { Filter, JsonSchema, Obj, Order, Query, Ref, Type } from "@dxos/echo";
|
|
69
|
+
import { ProjectionModel, ViewModel, createEchoChangeCallback as createEchoChangeCallback2, getSchemaFromPropertyDefinitions } from "@dxos/schema";
|
|
70
70
|
var getBaseSchema = ({ schema, typename, properties, jsonSchema }) => {
|
|
71
71
|
if (typename && properties) {
|
|
72
72
|
const schema2 = getSchemaFromPropertyDefinitions(typename, properties);
|
|
73
73
|
return {
|
|
74
74
|
typename: schema2.typename,
|
|
75
|
-
jsonSchema: schema2
|
|
75
|
+
jsonSchema: JsonSchema.toJsonSchema(schema2)
|
|
76
76
|
};
|
|
77
77
|
} else if (schema) {
|
|
78
78
|
return {
|
|
79
79
|
typename: Type.getTypename(schema),
|
|
80
|
-
jsonSchema:
|
|
80
|
+
jsonSchema: JsonSchema.toJsonSchema(schema)
|
|
81
81
|
};
|
|
82
82
|
} else if (typename && jsonSchema) {
|
|
83
83
|
return {
|
|
@@ -89,7 +89,7 @@ var getBaseSchema = ({ schema, typename, properties, jsonSchema }) => {
|
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
91
|
var makeDynamicTable = ({ registry, jsonSchema, properties }) => {
|
|
92
|
-
const view =
|
|
92
|
+
const view = ViewModel.make({
|
|
93
93
|
query: Query.select(Filter.everything()),
|
|
94
94
|
jsonSchema,
|
|
95
95
|
...properties && {
|
|
@@ -104,7 +104,7 @@ var makeDynamicTable = ({ registry, jsonSchema, properties }) => {
|
|
|
104
104
|
registry,
|
|
105
105
|
view,
|
|
106
106
|
baseSchema: jsonSchema,
|
|
107
|
-
change:
|
|
107
|
+
change: createEchoChangeCallback2(view, jsonSchema)
|
|
108
108
|
});
|
|
109
109
|
projection.normalizeView();
|
|
110
110
|
if (properties && projection.getFields()) {
|
|
@@ -254,14 +254,14 @@ var CellValidationMessage = ({ __gridScope, validationError, variant = "error" }
|
|
|
254
254
|
if (!editing || !validationError) {
|
|
255
255
|
return null;
|
|
256
256
|
}
|
|
257
|
-
const bgClass = variant === "error" ? "bg-
|
|
258
|
-
const textClass = variant === "error" ? "text-
|
|
257
|
+
const bgClass = variant === "error" ? "bg-error-surface" : "bg-warning-surface";
|
|
258
|
+
const textClass = variant === "error" ? "text-error-surface-text" : "text-warning-surface-text";
|
|
259
259
|
return /* @__PURE__ */ React.createElement("div", {
|
|
260
260
|
role: "none",
|
|
261
|
-
className: `absolute ${bgClass} ${textClass} rounded-
|
|
261
|
+
className: `absolute ${bgClass} ${textClass} rounded-h-sm text-xs p-1`,
|
|
262
262
|
style: {
|
|
263
263
|
...{
|
|
264
|
-
"--dx-
|
|
264
|
+
"--dx-grid-cell-width": `${box?.inlineSize ?? 200}px`
|
|
265
265
|
},
|
|
266
266
|
zIndex: 10,
|
|
267
267
|
insetBlockEnd: `calc(100% - ${box.insetBlockStart}px)`,
|
|
@@ -347,9 +347,13 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
347
347
|
model,
|
|
348
348
|
contextEditing
|
|
349
349
|
]);
|
|
350
|
-
const
|
|
350
|
+
const initialFormValues = useMemo(() => originalRow ? JSON.parse(JSON.stringify(originalRow)) : {}, [
|
|
351
351
|
originalRow
|
|
352
352
|
]);
|
|
353
|
+
const [formValues, setFormValues] = useState(initialFormValues);
|
|
354
|
+
const handleValuesChanged = useCallback((values) => {
|
|
355
|
+
setFormValues(values);
|
|
356
|
+
}, []);
|
|
353
357
|
const handleOpenChange = useCallback((nextOpen) => {
|
|
354
358
|
if (nextOpen === false) {
|
|
355
359
|
setEditing(null);
|
|
@@ -434,12 +438,14 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
434
438
|
virtualRef: anchorRef
|
|
435
439
|
}), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
|
|
436
440
|
tabIndex: -1,
|
|
437
|
-
classNames: "
|
|
441
|
+
classNames: "dx-card-popover-width dx-density-fine"
|
|
438
442
|
}, /* @__PURE__ */ React2.createElement(Popover.Arrow, null), /* @__PURE__ */ React2.createElement(Popover.Viewport, null, /* @__PURE__ */ React2.createElement(Form.Root, {
|
|
439
443
|
...formProps,
|
|
440
444
|
autoFocus: true,
|
|
441
445
|
schema: narrowedSchema,
|
|
442
446
|
values: formValues,
|
|
447
|
+
onValuesChanged: handleValuesChanged,
|
|
448
|
+
projection: model?.projection,
|
|
443
449
|
createInitialValuePath: fieldProjection.field.referencePath,
|
|
444
450
|
createOptionIcon: "ph--plus--regular",
|
|
445
451
|
createOptionLabel,
|
|
@@ -454,7 +460,7 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
454
460
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
|
|
455
461
|
var editorSlots = {
|
|
456
462
|
scroll: {
|
|
457
|
-
className: "!
|
|
463
|
+
className: "!py-(--dx-grid-cell-editor-padding-block)"
|
|
458
464
|
}
|
|
459
465
|
};
|
|
460
466
|
var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, onCreate }) => {
|
|
@@ -683,9 +689,98 @@ var determineNavigationDelta = ({ key, shift }) => {
|
|
|
683
689
|
return shift ? -1 : 1;
|
|
684
690
|
};
|
|
685
691
|
|
|
692
|
+
// src/components/TableToolbar/TableToolbar.tsx
|
|
693
|
+
import { Atom as Atom2, RegistryContext } from "@effect-atom/atom-react";
|
|
694
|
+
import React4, { useContext, useEffect as useEffect2, useMemo as useMemo3 } from "react";
|
|
695
|
+
import { Menu, createGapSeparator, createMenuAction, useMenuActions } from "@dxos/react-ui-menu";
|
|
696
|
+
var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) => Atom2.make((get) => {
|
|
697
|
+
const nodes = [];
|
|
698
|
+
if (onAdd) {
|
|
699
|
+
const add = createMenuAction("add-row", onAdd, {
|
|
700
|
+
type: "add-row",
|
|
701
|
+
icon: "ph--plus--regular",
|
|
702
|
+
label: [
|
|
703
|
+
"add row label",
|
|
704
|
+
{
|
|
705
|
+
ns: translationKey
|
|
706
|
+
}
|
|
707
|
+
],
|
|
708
|
+
testId: "table.toolbar.add-row"
|
|
709
|
+
});
|
|
710
|
+
nodes.push(add);
|
|
711
|
+
}
|
|
712
|
+
if (onSave) {
|
|
713
|
+
const state = get(stateAtom);
|
|
714
|
+
const save = createMenuAction("save-view", onSave, {
|
|
715
|
+
type: "save-view",
|
|
716
|
+
icon: "ph--floppy-disk--regular",
|
|
717
|
+
label: [
|
|
718
|
+
"save view label",
|
|
719
|
+
{
|
|
720
|
+
ns: translationKey
|
|
721
|
+
}
|
|
722
|
+
],
|
|
723
|
+
testId: "table.toolbar.save-view",
|
|
724
|
+
iconOnly: false,
|
|
725
|
+
hidden: !state.viewDirty
|
|
726
|
+
});
|
|
727
|
+
nodes.push(save);
|
|
728
|
+
}
|
|
729
|
+
const gap = createGapSeparator();
|
|
730
|
+
nodes.push(...gap.nodes);
|
|
731
|
+
const edges = nodes.map(({ id: target }) => ({
|
|
732
|
+
source: "root",
|
|
733
|
+
target,
|
|
734
|
+
relation: "child"
|
|
735
|
+
}));
|
|
736
|
+
if (customActions) {
|
|
737
|
+
const custom = get(customActions);
|
|
738
|
+
nodes.push(...custom.nodes);
|
|
739
|
+
edges.push(...custom.edges);
|
|
740
|
+
}
|
|
741
|
+
return {
|
|
742
|
+
nodes,
|
|
743
|
+
edges
|
|
744
|
+
};
|
|
745
|
+
});
|
|
746
|
+
var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, customActions, ...props }) => {
|
|
747
|
+
const registry = useContext(RegistryContext);
|
|
748
|
+
const stateAtom = useMemo3(() => Atom2.make({
|
|
749
|
+
viewDirty
|
|
750
|
+
}), []);
|
|
751
|
+
useEffect2(() => {
|
|
752
|
+
registry.set(stateAtom, {
|
|
753
|
+
viewDirty
|
|
754
|
+
});
|
|
755
|
+
}, [
|
|
756
|
+
registry,
|
|
757
|
+
stateAtom,
|
|
758
|
+
viewDirty
|
|
759
|
+
]);
|
|
760
|
+
const actionsCreator = useMemo3(() => createTableToolbarActions({
|
|
761
|
+
stateAtom,
|
|
762
|
+
onAdd,
|
|
763
|
+
onSave,
|
|
764
|
+
customActions
|
|
765
|
+
}), [
|
|
766
|
+
stateAtom,
|
|
767
|
+
onAdd,
|
|
768
|
+
onSave,
|
|
769
|
+
customActions
|
|
770
|
+
]);
|
|
771
|
+
const menu = useMenuActions(actionsCreator);
|
|
772
|
+
return /* @__PURE__ */ React4.createElement(Menu.Root, {
|
|
773
|
+
...menu,
|
|
774
|
+
attendableId
|
|
775
|
+
}, /* @__PURE__ */ React4.createElement(Menu.Toolbar, {
|
|
776
|
+
...props,
|
|
777
|
+
classNames
|
|
778
|
+
}));
|
|
779
|
+
};
|
|
780
|
+
|
|
686
781
|
// src/components/Table/ColumnActionsMenu.tsx
|
|
687
782
|
import { useAtomValue } from "@effect-atom/atom-react";
|
|
688
|
-
import
|
|
783
|
+
import React5 from "react";
|
|
689
784
|
import { DropdownMenu, useTranslation } from "@dxos/react-ui";
|
|
690
785
|
var ColumnActionsMenu = ({ model, modals }) => {
|
|
691
786
|
const { t } = useTranslation(translationKey);
|
|
@@ -695,39 +790,39 @@ var ColumnActionsMenu = ({ model, modals }) => {
|
|
|
695
790
|
}
|
|
696
791
|
const currentSort = model.getSorting();
|
|
697
792
|
const isCurrentColumnSorted = currentSort?.fieldId === state.fieldId;
|
|
698
|
-
return /* @__PURE__ */
|
|
793
|
+
return /* @__PURE__ */ React5.createElement(DropdownMenu.Root, {
|
|
699
794
|
modal: false,
|
|
700
795
|
open: true,
|
|
701
796
|
onOpenChange: modals.close
|
|
702
|
-
}, /* @__PURE__ */
|
|
797
|
+
}, /* @__PURE__ */ React5.createElement(DropdownMenu.VirtualTrigger, {
|
|
703
798
|
virtualRef: modals.trigger
|
|
704
|
-
}), /* @__PURE__ */
|
|
799
|
+
}), /* @__PURE__ */ React5.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React5.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React5.createElement(DropdownMenu.Viewport, null, (!isCurrentColumnSorted || currentSort?.direction === "asc") && /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
|
|
705
800
|
"data-testid": "column-sort-descending",
|
|
706
801
|
onClick: () => model.setSort(state.fieldId, "desc")
|
|
707
|
-
}, t("column action sort descending")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */
|
|
802
|
+
}, t("column action sort descending")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
|
|
708
803
|
"data-testid": "column-sort-ascending",
|
|
709
804
|
onClick: () => model.setSort(state.fieldId, "asc")
|
|
710
|
-
}, t("column action sort ascending")), isCurrentColumnSorted && /* @__PURE__ */
|
|
805
|
+
}, t("column action sort ascending")), isCurrentColumnSorted && /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
|
|
711
806
|
"data-testid": "column-clear-sort",
|
|
712
807
|
onClick: () => model.clearSort()
|
|
713
|
-
}, t("column action clear sorting")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */
|
|
808
|
+
}, t("column action clear sorting")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
|
|
714
809
|
"data-testid": "column-delete",
|
|
715
810
|
onClick: () => model.deleteColumn(state.fieldId)
|
|
716
|
-
}, t("column action delete")), model.features.schemaEditable && /* @__PURE__ */
|
|
811
|
+
}, t("column action delete")), model.features.schemaEditable && /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
|
|
717
812
|
"data-testid": "column-settings",
|
|
718
813
|
onClick: () => modals.openColumnSettings()
|
|
719
|
-
}, t("column action settings"))), /* @__PURE__ */
|
|
814
|
+
}, t("column action settings"))), /* @__PURE__ */ React5.createElement(DropdownMenu.Arrow, null))));
|
|
720
815
|
};
|
|
721
816
|
|
|
722
817
|
// src/components/Table/ColumnSettings.tsx
|
|
723
818
|
import { useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
|
|
724
|
-
import
|
|
819
|
+
import React6, { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo4, useState as useState3 } from "react";
|
|
725
820
|
import { Popover as Popover2 } from "@dxos/react-ui";
|
|
726
821
|
import { FieldEditor } from "@dxos/react-ui-form";
|
|
727
822
|
var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
|
|
728
823
|
const [newField, setNewField] = useState3();
|
|
729
824
|
const state = useAtomValue2(modals.state);
|
|
730
|
-
|
|
825
|
+
useEffect3(() => {
|
|
731
826
|
if (state?.type === "columnSettings" && state.mode.type === "create" && model?.projection) {
|
|
732
827
|
setNewField(model.projection.createFieldProjection());
|
|
733
828
|
requestAnimationFrame(() => {
|
|
@@ -740,7 +835,7 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
|
|
|
740
835
|
model?.projection,
|
|
741
836
|
state
|
|
742
837
|
]);
|
|
743
|
-
const existingField =
|
|
838
|
+
const existingField = useMemo4(() => {
|
|
744
839
|
if (state?.type === "columnSettings") {
|
|
745
840
|
const { mode } = state;
|
|
746
841
|
if (mode.type === "edit") {
|
|
@@ -770,25 +865,25 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
|
|
|
770
865
|
if (!model?.projection || !field) {
|
|
771
866
|
return null;
|
|
772
867
|
}
|
|
773
|
-
return /* @__PURE__ */
|
|
868
|
+
return /* @__PURE__ */ React6.createElement(Popover2.Root, {
|
|
774
869
|
modal: false,
|
|
775
870
|
open: state?.type === "columnSettings"
|
|
776
|
-
}, /* @__PURE__ */
|
|
871
|
+
}, /* @__PURE__ */ React6.createElement(Popover2.VirtualTrigger, {
|
|
777
872
|
virtualRef: modals.trigger
|
|
778
|
-
}), /* @__PURE__ */
|
|
779
|
-
classNames: "md:
|
|
780
|
-
}, /* @__PURE__ */
|
|
873
|
+
}), /* @__PURE__ */ React6.createElement(Popover2.Portal, null, /* @__PURE__ */ React6.createElement(Popover2.Content, {
|
|
874
|
+
classNames: "md:w-64"
|
|
875
|
+
}, /* @__PURE__ */ React6.createElement(Popover2.Viewport, null, /* @__PURE__ */ React6.createElement(FieldEditor, {
|
|
781
876
|
projection: model.projection,
|
|
782
877
|
field,
|
|
783
878
|
registry,
|
|
784
879
|
onSave: handleSave,
|
|
785
880
|
onCancel: handleCancel
|
|
786
|
-
})), /* @__PURE__ */
|
|
881
|
+
})), /* @__PURE__ */ React6.createElement(Popover2.Arrow, null))));
|
|
787
882
|
};
|
|
788
883
|
|
|
789
884
|
// src/components/Table/RowActionsMenu.tsx
|
|
790
885
|
import { useAtomValue as useAtomValue3 } from "@effect-atom/atom-react";
|
|
791
|
-
import
|
|
886
|
+
import React7 from "react";
|
|
792
887
|
import { DropdownMenu as DropdownMenu2, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
793
888
|
var RowActionsMenu = ({ model, modals }) => {
|
|
794
889
|
const { t } = useTranslation2(translationKey);
|
|
@@ -797,23 +892,23 @@ var RowActionsMenu = ({ model, modals }) => {
|
|
|
797
892
|
if (state?.type !== "row") {
|
|
798
893
|
return null;
|
|
799
894
|
}
|
|
800
|
-
return /* @__PURE__ */
|
|
895
|
+
return /* @__PURE__ */ React7.createElement(DropdownMenu2.Root, {
|
|
801
896
|
modal: false,
|
|
802
897
|
open: true,
|
|
803
898
|
onOpenChange: modals.close
|
|
804
|
-
}, /* @__PURE__ */
|
|
899
|
+
}, /* @__PURE__ */ React7.createElement(DropdownMenu2.VirtualTrigger, {
|
|
805
900
|
virtualRef: modals.trigger
|
|
806
|
-
}), /* @__PURE__ */
|
|
901
|
+
}), /* @__PURE__ */ React7.createElement(DropdownMenu2.Content, null, /* @__PURE__ */ React7.createElement(DropdownMenu2.Viewport, null, model.rowActions?.length > 0 && /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(DropdownMenu2.Group, null, model.rowActions?.map((action) => /* @__PURE__ */ React7.createElement(DropdownMenu2.Item, {
|
|
807
902
|
key: action.id,
|
|
808
903
|
"data-testid": `row-action-${action.id}`,
|
|
809
904
|
onClick: () => {
|
|
810
905
|
modals.close();
|
|
811
906
|
model.handleRowAction(action.id, state.rowIndex);
|
|
812
907
|
}
|
|
813
|
-
}, toLocalizedString(action.label, t)))), /* @__PURE__ */
|
|
908
|
+
}, toLocalizedString(action.label, t)))), /* @__PURE__ */ React7.createElement(DropdownMenu2.Separator, null)), model.features.dataEditable !== false && /* @__PURE__ */ React7.createElement(DropdownMenu2.Item, {
|
|
814
909
|
"data-testid": "row-menu-delete",
|
|
815
910
|
onClick: () => model.deleteRow(state.rowIndex)
|
|
816
|
-
}, t(hasSelection ? "bulk delete row label" : "delete row label"))), /* @__PURE__ */
|
|
911
|
+
}, t(hasSelection ? "bulk delete row label" : "delete row label"))), /* @__PURE__ */ React7.createElement(DropdownMenu2.Arrow, null)));
|
|
817
912
|
};
|
|
818
913
|
|
|
819
914
|
// src/components/Table/Table.tsx
|
|
@@ -830,29 +925,19 @@ var rowDefault = {
|
|
|
830
925
|
focusUnfurl: false
|
|
831
926
|
}
|
|
832
927
|
};
|
|
833
|
-
var emptyColumnMeta =
|
|
928
|
+
var emptyColumnMeta = Atom3.make({
|
|
834
929
|
grid: {}
|
|
835
930
|
});
|
|
836
|
-
var TableRoot = ({ children
|
|
837
|
-
return /* @__PURE__ */
|
|
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);
|
|
931
|
+
var TableRoot = ({ children }) => {
|
|
932
|
+
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, children);
|
|
848
933
|
};
|
|
849
|
-
var emptyRowsAtom =
|
|
850
|
-
var emptyCellUpdateAtom =
|
|
851
|
-
var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate, onRowClick, testId }, forwardedRef) => {
|
|
852
|
-
const registry =
|
|
934
|
+
var emptyRowsAtom = Atom3.make([]);
|
|
935
|
+
var emptyCellUpdateAtom = Atom3.make(0);
|
|
936
|
+
var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate, onRowClick, testId, ...props }, forwardedRef) => {
|
|
937
|
+
const registry = useContext2(RegistryContext2);
|
|
853
938
|
const [dxGrid, setDxGrid] = useState4(null);
|
|
854
939
|
const { hasAttention } = useAttention(model?.id ?? "table");
|
|
855
|
-
const modals =
|
|
940
|
+
const modals = useMemo5(() => new ModalController(registry), [
|
|
856
941
|
registry
|
|
857
942
|
]);
|
|
858
943
|
const columnMeta = useAtomValue4(model?.columnMeta ?? emptyColumnMeta);
|
|
@@ -860,7 +945,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
860
945
|
const cellUpdateCounter = useAtomValue4(model?.cellUpdate ?? emptyCellUpdateAtom);
|
|
861
946
|
const columnCount = Object.keys(columnMeta.grid).length || model?.projection.getFields().length || 0;
|
|
862
947
|
const draftRowCount = model?.getDraftRowCount() ?? 0;
|
|
863
|
-
const frozen =
|
|
948
|
+
const frozen = useMemo5(() => {
|
|
864
949
|
const noActionColumn = model?.features.dataEditable === false && model?.features.schemaEditable === false && model.rowActions.length === 0;
|
|
865
950
|
return {
|
|
866
951
|
frozenRowsStart: 1,
|
|
@@ -875,7 +960,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
875
960
|
const getCells = useCallback4((range, plane) => presentation?.getCells(range, plane) ?? {}, [
|
|
876
961
|
presentation
|
|
877
962
|
]);
|
|
878
|
-
|
|
963
|
+
useEffect4(() => {
|
|
879
964
|
if (!dxGrid || !presentation) {
|
|
880
965
|
return;
|
|
881
966
|
}
|
|
@@ -885,7 +970,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
885
970
|
presentation,
|
|
886
971
|
getCells
|
|
887
972
|
]);
|
|
888
|
-
|
|
973
|
+
useEffect4(() => {
|
|
889
974
|
if (!dxGrid) {
|
|
890
975
|
return;
|
|
891
976
|
}
|
|
@@ -1058,7 +1143,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1058
1143
|
} catch (error) {
|
|
1059
1144
|
log.catch(error, void 0, {
|
|
1060
1145
|
F: __dxlog_file3,
|
|
1061
|
-
L:
|
|
1146
|
+
L: 310,
|
|
1062
1147
|
S: void 0,
|
|
1063
1148
|
C: (f, a) => f(...a)
|
|
1064
1149
|
});
|
|
@@ -1157,22 +1242,25 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1157
1242
|
presentation
|
|
1158
1243
|
]);
|
|
1159
1244
|
if (!model || !modals) {
|
|
1160
|
-
return /* @__PURE__ */
|
|
1245
|
+
return /* @__PURE__ */ React8.createElement("span", {
|
|
1161
1246
|
role: "none",
|
|
1162
|
-
className: "attention-surface"
|
|
1247
|
+
className: "dx-attention-surface"
|
|
1163
1248
|
});
|
|
1164
1249
|
}
|
|
1165
|
-
return /* @__PURE__ */
|
|
1250
|
+
return /* @__PURE__ */ React8.createElement("div", composableProps(props, {
|
|
1251
|
+
role: "none",
|
|
1252
|
+
className: "dx-container relative"
|
|
1253
|
+
}), /* @__PURE__ */ React8.createElement(Grid.Root, {
|
|
1166
1254
|
id: model.id ?? "table-grid"
|
|
1167
|
-
}, /* @__PURE__ */
|
|
1255
|
+
}, /* @__PURE__ */ React8.createElement(TableValueEditor, {
|
|
1168
1256
|
model,
|
|
1169
1257
|
modals,
|
|
1170
1258
|
schema,
|
|
1171
1259
|
onFocus: handleFocus,
|
|
1172
1260
|
onSave: handleSave,
|
|
1173
1261
|
onCreate
|
|
1174
|
-
}), /* @__PURE__ */
|
|
1175
|
-
className: mx("[--dx-grid-base:var(--
|
|
1262
|
+
}), /* @__PURE__ */ React8.createElement(Grid.Content, {
|
|
1263
|
+
className: mx("[--dx-grid-base:var(--base-surface)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
|
|
1176
1264
|
frozen,
|
|
1177
1265
|
columns: columnMeta,
|
|
1178
1266
|
columnDefault,
|
|
@@ -1188,44 +1276,45 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1188
1276
|
"data-testid": testId
|
|
1189
1277
|
},
|
|
1190
1278
|
ref: setDxGrid
|
|
1191
|
-
}), /* @__PURE__ */
|
|
1279
|
+
}), /* @__PURE__ */ React8.createElement(RowActionsMenu, {
|
|
1192
1280
|
model,
|
|
1193
1281
|
modals
|
|
1194
|
-
}), /* @__PURE__ */
|
|
1282
|
+
}), /* @__PURE__ */ React8.createElement(ColumnActionsMenu, {
|
|
1195
1283
|
model,
|
|
1196
1284
|
modals
|
|
1197
|
-
}), /* @__PURE__ */
|
|
1285
|
+
}), /* @__PURE__ */ React8.createElement(ColumnSettings, {
|
|
1198
1286
|
model,
|
|
1199
1287
|
modals,
|
|
1200
1288
|
onNewColumn: handleNewColumn
|
|
1201
|
-
}));
|
|
1289
|
+
})));
|
|
1202
1290
|
};
|
|
1203
1291
|
var TableMain = /* @__PURE__ */ forwardRef(TableMainInner);
|
|
1204
1292
|
var Table = {
|
|
1205
1293
|
Root: TableRoot,
|
|
1206
|
-
Main: TableMain
|
|
1294
|
+
Main: TableMain,
|
|
1295
|
+
Toolbar: TableToolbar
|
|
1207
1296
|
};
|
|
1208
1297
|
|
|
1209
1298
|
// src/components/Table/DynamicTable.tsx
|
|
1210
|
-
import { RegistryContext as
|
|
1211
|
-
import
|
|
1299
|
+
import { RegistryContext as RegistryContext3 } from "@effect-atom/atom-react";
|
|
1300
|
+
import React9, { useCallback as useCallback5, useContext as useContext3, useEffect as useEffect5, useMemo as useMemo6, useRef as useRef3, useState as useState5 } from "react";
|
|
1212
1301
|
import { useDefaultValue } from "@dxos/react-ui";
|
|
1213
1302
|
import { mx as mx2 } from "@dxos/ui-theme";
|
|
1214
|
-
var DynamicTable = ({ classNames, schema, name = "example.
|
|
1215
|
-
const registry =
|
|
1303
|
+
var DynamicTable = ({ classNames, schema, name = "com.example.dynamic-table", rows, properties, jsonSchema: jsonSchemaProp, rowActions, onRowClick, onRowAction, ...props }) => {
|
|
1304
|
+
const registry = useContext3(RegistryContext3);
|
|
1216
1305
|
const [dynamicTable, setDynamicTable] = useState5();
|
|
1217
|
-
const { jsonSchema } =
|
|
1306
|
+
const { jsonSchema } = useMemo6(() => getBaseSchema({
|
|
1218
1307
|
typename: name,
|
|
1219
1308
|
properties,
|
|
1220
|
-
jsonSchema:
|
|
1309
|
+
jsonSchema: jsonSchemaProp,
|
|
1221
1310
|
schema
|
|
1222
1311
|
}), [
|
|
1223
1312
|
name,
|
|
1224
1313
|
properties,
|
|
1225
|
-
|
|
1314
|
+
jsonSchemaProp,
|
|
1226
1315
|
schema
|
|
1227
1316
|
]);
|
|
1228
|
-
|
|
1317
|
+
useEffect5(() => {
|
|
1229
1318
|
setDynamicTable(makeDynamicTable({
|
|
1230
1319
|
registry,
|
|
1231
1320
|
jsonSchema,
|
|
@@ -1259,7 +1348,7 @@ var DynamicTable = ({ classNames, schema, name = "example.com/dynamic-table", ro
|
|
|
1259
1348
|
onRowOrderChange: handleRowOrderChange,
|
|
1260
1349
|
onRowAction
|
|
1261
1350
|
});
|
|
1262
|
-
const presentation =
|
|
1351
|
+
const presentation = useMemo6(() => {
|
|
1263
1352
|
if (model) {
|
|
1264
1353
|
return new TablePresentation(registry, model);
|
|
1265
1354
|
}
|
|
@@ -1267,13 +1356,13 @@ var DynamicTable = ({ classNames, schema, name = "example.com/dynamic-table", ro
|
|
|
1267
1356
|
registry,
|
|
1268
1357
|
model
|
|
1269
1358
|
]);
|
|
1270
|
-
return /* @__PURE__ */
|
|
1359
|
+
return /* @__PURE__ */ React9.createElement("div", {
|
|
1271
1360
|
role: "none",
|
|
1272
|
-
className: mx2("
|
|
1273
|
-
}, /* @__PURE__ */
|
|
1361
|
+
className: mx2("w-full h-full grow grid", classNames)
|
|
1362
|
+
}, /* @__PURE__ */ React9.createElement("div", {
|
|
1274
1363
|
role: "none",
|
|
1275
|
-
className: "grid min-
|
|
1276
|
-
}, /* @__PURE__ */
|
|
1364
|
+
className: "grid min-h-0 overflow-hidden"
|
|
1365
|
+
}, /* @__PURE__ */ React9.createElement(Table.Root, null, /* @__PURE__ */ React9.createElement(Table.Main, {
|
|
1277
1366
|
ref: tableRef,
|
|
1278
1367
|
model,
|
|
1279
1368
|
presentation,
|
|
@@ -1281,93 +1370,6 @@ var DynamicTable = ({ classNames, schema, name = "example.com/dynamic-table", ro
|
|
|
1281
1370
|
onRowClick
|
|
1282
1371
|
}))));
|
|
1283
1372
|
};
|
|
1284
|
-
|
|
1285
|
-
// src/components/TableToolbar/TableToolbar.tsx
|
|
1286
|
-
import { Atom as Atom3, RegistryContext as RegistryContext3 } from "@effect-atom/atom-react";
|
|
1287
|
-
import React9, { useContext as useContext3, useEffect as useEffect5, useMemo as useMemo6 } from "react";
|
|
1288
|
-
import { MenuProvider, ToolbarMenu, createGapSeparator, createMenuAction, useMenuActions } from "@dxos/react-ui-menu";
|
|
1289
|
-
var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) => Atom3.make((get) => {
|
|
1290
|
-
const nodes = [];
|
|
1291
|
-
if (onAdd) {
|
|
1292
|
-
const add = createMenuAction("add-row", onAdd, {
|
|
1293
|
-
type: "add-row",
|
|
1294
|
-
icon: "ph--plus--regular",
|
|
1295
|
-
label: [
|
|
1296
|
-
"add row label",
|
|
1297
|
-
{
|
|
1298
|
-
ns: translationKey
|
|
1299
|
-
}
|
|
1300
|
-
],
|
|
1301
|
-
testId: "table.toolbar.add-row"
|
|
1302
|
-
});
|
|
1303
|
-
nodes.push(add);
|
|
1304
|
-
}
|
|
1305
|
-
if (onSave) {
|
|
1306
|
-
const state = get(stateAtom);
|
|
1307
|
-
const save = createMenuAction("save-view", onSave, {
|
|
1308
|
-
type: "save-view",
|
|
1309
|
-
icon: "ph--floppy-disk--regular",
|
|
1310
|
-
label: [
|
|
1311
|
-
"save view label",
|
|
1312
|
-
{
|
|
1313
|
-
ns: translationKey
|
|
1314
|
-
}
|
|
1315
|
-
],
|
|
1316
|
-
testId: "table.toolbar.save-view",
|
|
1317
|
-
iconOnly: false,
|
|
1318
|
-
hidden: !state.viewDirty
|
|
1319
|
-
});
|
|
1320
|
-
nodes.push(save);
|
|
1321
|
-
}
|
|
1322
|
-
const gap = createGapSeparator();
|
|
1323
|
-
nodes.push(...gap.nodes);
|
|
1324
|
-
const edges = nodes.map(({ id: target }) => ({
|
|
1325
|
-
source: "root",
|
|
1326
|
-
target
|
|
1327
|
-
}));
|
|
1328
|
-
if (customActions) {
|
|
1329
|
-
const custom = get(customActions);
|
|
1330
|
-
nodes.push(...custom.nodes);
|
|
1331
|
-
edges.push(...custom.edges);
|
|
1332
|
-
}
|
|
1333
|
-
return {
|
|
1334
|
-
nodes,
|
|
1335
|
-
edges
|
|
1336
|
-
};
|
|
1337
|
-
});
|
|
1338
|
-
var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, customActions }) => {
|
|
1339
|
-
const registry = useContext3(RegistryContext3);
|
|
1340
|
-
const stateAtom = useMemo6(() => Atom3.make({
|
|
1341
|
-
viewDirty
|
|
1342
|
-
}), []);
|
|
1343
|
-
useEffect5(() => {
|
|
1344
|
-
registry.set(stateAtom, {
|
|
1345
|
-
viewDirty
|
|
1346
|
-
});
|
|
1347
|
-
}, [
|
|
1348
|
-
registry,
|
|
1349
|
-
stateAtom,
|
|
1350
|
-
viewDirty
|
|
1351
|
-
]);
|
|
1352
|
-
const actionsCreator = useMemo6(() => createTableToolbarActions({
|
|
1353
|
-
stateAtom,
|
|
1354
|
-
onAdd,
|
|
1355
|
-
onSave,
|
|
1356
|
-
customActions
|
|
1357
|
-
}), [
|
|
1358
|
-
stateAtom,
|
|
1359
|
-
onAdd,
|
|
1360
|
-
onSave,
|
|
1361
|
-
customActions
|
|
1362
|
-
]);
|
|
1363
|
-
const menu = useMenuActions(actionsCreator);
|
|
1364
|
-
return /* @__PURE__ */ React9.createElement(MenuProvider, {
|
|
1365
|
-
...menu,
|
|
1366
|
-
attendableId
|
|
1367
|
-
}, /* @__PURE__ */ React9.createElement(ToolbarMenu, {
|
|
1368
|
-
classNames
|
|
1369
|
-
}));
|
|
1370
|
-
};
|
|
1371
1373
|
export {
|
|
1372
1374
|
BUTTON_IDENTIFIERS,
|
|
1373
1375
|
CONTROL_IDENTIFIERS,
|