@dxos/react-ui-table 0.8.4-main.d05673bc65 → 0.8.4-main.d9fc60f731
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/LICENSE +102 -5
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-PTHMYAAM.mjs → chunk-X7A7G6RR.mjs} +28 -83
- package/dist/lib/browser/chunk-X7A7G6RR.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BF54SSNL.mjs → chunk-YURROGGF.mjs} +12 -15
- package/dist/lib/browser/chunk-YURROGGF.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +230 -280
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +10 -9
- 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-SIRDIPHZ.mjs → chunk-DLAGRBKD.mjs} +12 -15
- package/dist/lib/node-esm/chunk-DLAGRBKD.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/{chunk-GI72MQSG.mjs → chunk-Q4HSBRJJ.mjs} +28 -83
- package/dist/lib/node-esm/chunk-Q4HSBRJJ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +230 -280
- 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 +10 -9
- 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 +2 -2
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +3 -4
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +21 -22
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +83 -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 +85 -84
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableContent.d.ts +18 -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 +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- 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.map +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 +4 -5
- 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 +1 -1
- 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 +11 -5
- package/dist/types/src/types/Table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +6 -6
- 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 +55 -64
- package/src/components/Table/ColumnActionsMenu.tsx +7 -6
- package/src/components/Table/ColumnSettings.tsx +2 -2
- package/src/components/Table/DynamicTable.stories.tsx +19 -19
- package/src/components/Table/DynamicTable.tsx +13 -22
- package/src/components/Table/Relations.stories.tsx +76 -34
- package/src/components/Table/RowActionsMenu.tsx +3 -2
- package/src/components/Table/Table.stories.tsx +46 -51
- package/src/components/Table/Table.tsx +37 -426
- package/src/components/Table/TableContent.tsx +426 -0
- package/src/components/{TableToolbar → Table}/TableToolbar.tsx +34 -41
- package/src/components/TableCellEditor/CellValidationMessage.tsx +1 -2
- package/src/components/TableCellEditor/FormCellEditor.tsx +7 -6
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +14 -12
- package/src/components/TableCellEditor/TableCellEditor.tsx +10 -8
- package/src/components/index.ts +0 -1
- package/src/components/testing.ts +11 -16
- package/src/hooks/useProjectionModel.ts +5 -6
- package/src/hooks/useTableModel.ts +1 -1
- package/src/index.ts +0 -4
- package/src/model/table-model.test.ts +4 -10
- package/src/model/table-model.ts +15 -15
- package/src/model/table-presentation.test.ts +4 -10
- package/src/model/table-presentation.ts +5 -7
- package/src/playwright/smoke.spec.ts +3 -3
- package/src/testing/useTestTableModel.ts +7 -8
- package/src/translations.ts +19 -21
- package/src/types/Table.ts +12 -13
- package/src/util/dynamic-table.test.ts +13 -20
- package/src/util/dynamic-table.ts +21 -20
- package/dist/lib/browser/chunk-BF54SSNL.mjs.map +0 -7
- package/dist/lib/browser/chunk-PTHMYAAM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GI72MQSG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SIRDIPHZ.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,81 +17,47 @@ import {
|
|
|
17
17
|
useAddRow,
|
|
18
18
|
useProjectionModel,
|
|
19
19
|
useTableModel
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-Q4HSBRJJ.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-DLAGRBKD.mjs";
|
|
24
|
+
import "./chunk-HSLMI22Q.mjs";
|
|
56
25
|
|
|
57
26
|
// src/components/Table/Table.tsx
|
|
58
|
-
import { Atom as
|
|
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
|
|
32
|
+
import { Atom as Atom2, RegistryContext, useAtomValue as useAtomValue4 } from "@effect-atom/atom-react";
|
|
59
33
|
import * as String2 from "effect/String";
|
|
60
|
-
import
|
|
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";
|
|
36
|
+
import { composable, composableProps } from "@dxos/react-ui";
|
|
62
37
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
63
38
|
import { Grid, closestCell, gridSeparatorBlockEnd, gridSeparatorInlineEnd } from "@dxos/react-ui-grid";
|
|
64
39
|
import { DxEditRequest } from "@dxos/react-ui-grid";
|
|
65
|
-
import {
|
|
40
|
+
import { mx } from "@dxos/ui-theme";
|
|
66
41
|
|
|
67
42
|
// src/util/dynamic-table.ts
|
|
68
|
-
import { Filter,
|
|
69
|
-
import { ProjectionModel, ViewModel, createEchoChangeCallback as createEchoChangeCallback2, getSchemaFromPropertyDefinitions } from "@dxos/schema";
|
|
70
|
-
var getBaseSchema = ({
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
typename: schema2.typename,
|
|
75
|
-
jsonSchema: JsonSchema.toJsonSchema(schema2)
|
|
76
|
-
};
|
|
77
|
-
} else if (schema) {
|
|
78
|
-
return {
|
|
79
|
-
typename: Type.getTypename(schema),
|
|
80
|
-
jsonSchema: JsonSchema.toJsonSchema(schema)
|
|
81
|
-
};
|
|
82
|
-
} else if (typename && jsonSchema) {
|
|
83
|
-
return {
|
|
84
|
-
typename,
|
|
85
|
-
jsonSchema
|
|
86
|
-
};
|
|
87
|
-
} else {
|
|
43
|
+
import { Filter, Obj, Order, Query, Ref, Type } from "@dxos/echo";
|
|
44
|
+
import { ProjectionModel, ViewModel, createEchoChangeCallback as createEchoChangeCallback2, getSchemaFromJsonSchema, getSchemaFromPropertyDefinitions } from "@dxos/schema";
|
|
45
|
+
var getBaseSchema = ({ type, typename, properties, jsonSchema }) => {
|
|
46
|
+
const resolved = typename && properties ? getSchemaFromPropertyDefinitions(typename, properties) : type ?? (jsonSchema ? getSchemaFromJsonSchema(jsonSchema, typename) : void 0);
|
|
47
|
+
if (!resolved) {
|
|
88
48
|
throw new Error("invalid properties");
|
|
89
49
|
}
|
|
50
|
+
return {
|
|
51
|
+
typename: Type.getTypename(resolved),
|
|
52
|
+
type: resolved
|
|
53
|
+
};
|
|
90
54
|
};
|
|
91
|
-
var makeDynamicTable = ({ registry,
|
|
55
|
+
var makeDynamicTable = ({ registry, type, properties }) => {
|
|
56
|
+
const jsonSchema = type.jsonSchema;
|
|
92
57
|
const view = ViewModel.make({
|
|
93
58
|
query: Query.select(Filter.everything()),
|
|
94
59
|
jsonSchema,
|
|
60
|
+
type,
|
|
95
61
|
...properties && {
|
|
96
62
|
fields: properties.map((property) => property.name)
|
|
97
63
|
}
|
|
@@ -104,7 +70,7 @@ var makeDynamicTable = ({ registry, jsonSchema, properties }) => {
|
|
|
104
70
|
registry,
|
|
105
71
|
view,
|
|
106
72
|
baseSchema: jsonSchema,
|
|
107
|
-
change: createEchoChangeCallback2(view,
|
|
73
|
+
change: createEchoChangeCallback2(view, type)
|
|
108
74
|
});
|
|
109
75
|
projection.normalizeView();
|
|
110
76
|
if (properties && projection.getFields()) {
|
|
@@ -120,8 +86,8 @@ var setProperties = (view, projection, table, properties) => {
|
|
|
120
86
|
const field = projection.getFields().find((field2) => field2.path === property.name);
|
|
121
87
|
if (field) {
|
|
122
88
|
if (property.size !== void 0) {
|
|
123
|
-
Obj.
|
|
124
|
-
|
|
89
|
+
Obj.update(table, (table2) => {
|
|
90
|
+
table2.sizes[field.path] = property.size;
|
|
125
91
|
});
|
|
126
92
|
}
|
|
127
93
|
if (property.title !== void 0) {
|
|
@@ -137,8 +103,8 @@ var setProperties = (view, projection, table, properties) => {
|
|
|
137
103
|
if (property.sort) {
|
|
138
104
|
const currentQuery = Query.fromAst(Obj.getSnapshot(view).query.ast);
|
|
139
105
|
const newQuery = currentQuery.orderBy(Order.property(field.path, property.sort));
|
|
140
|
-
Obj.
|
|
141
|
-
|
|
106
|
+
Obj.update(view, (view2) => {
|
|
107
|
+
view2.query.ast = newQuery.ast;
|
|
142
108
|
});
|
|
143
109
|
}
|
|
144
110
|
}
|
|
@@ -255,9 +221,8 @@ var CellValidationMessage = ({ __gridScope, validationError, variant = "error" }
|
|
|
255
221
|
return null;
|
|
256
222
|
}
|
|
257
223
|
const bgClass = variant === "error" ? "bg-error-surface" : "bg-warning-surface";
|
|
258
|
-
const textClass = variant === "error" ? "text-error-
|
|
224
|
+
const textClass = variant === "error" ? "text-error-fg" : "text-warning-fg";
|
|
259
225
|
return /* @__PURE__ */ React.createElement("div", {
|
|
260
|
-
role: "none",
|
|
261
226
|
className: `absolute ${bgClass} ${textClass} rounded-h-sm text-xs p-1`,
|
|
262
227
|
style: {
|
|
263
228
|
...{
|
|
@@ -273,16 +238,17 @@ var CellValidationMessage = ({ __gridScope, validationError, variant = "error" }
|
|
|
273
238
|
|
|
274
239
|
// src/components/TableCellEditor/FormCellEditor.tsx
|
|
275
240
|
import React2, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
276
|
-
import { Entity } from "@dxos/echo";
|
|
241
|
+
import { Entity, Type as Type2 } from "@dxos/echo";
|
|
277
242
|
import { Ref as Ref2, getValue } from "@dxos/echo/internal";
|
|
278
243
|
import { invariant } from "@dxos/invariant";
|
|
279
244
|
import { Popover } from "@dxos/react-ui";
|
|
280
245
|
import { Form } from "@dxos/react-ui-form";
|
|
281
246
|
import { parseCellIndex, useGridContext as useGridContext2 } from "@dxos/react-ui-grid";
|
|
282
247
|
import { getDeep, isTruthy, setDeep } from "@dxos/util";
|
|
248
|
+
import { translationKey } from "#translations";
|
|
283
249
|
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx";
|
|
284
250
|
var createOptionLabel = [
|
|
285
|
-
"create
|
|
251
|
+
"create-new-object.label",
|
|
286
252
|
{
|
|
287
253
|
ns: translationKey
|
|
288
254
|
}
|
|
@@ -306,7 +272,7 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
306
272
|
if (!schema) {
|
|
307
273
|
return void 0;
|
|
308
274
|
}
|
|
309
|
-
return narrowSchema(schema, [
|
|
275
|
+
return narrowSchema(Type2.getSchema(schema), [
|
|
310
276
|
fieldProjection.field.path
|
|
311
277
|
]);
|
|
312
278
|
}, [
|
|
@@ -318,27 +284,11 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
318
284
|
const cell = parseCellIndex(contextEditing.index);
|
|
319
285
|
if (model.isDraftCell(cell)) {
|
|
320
286
|
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
|
-
});
|
|
287
|
+
invariant(draftRow, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 52, S: void 0, A: ["draftRow", ""] });
|
|
330
288
|
return draftRow.data;
|
|
331
289
|
} else {
|
|
332
290
|
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
|
-
});
|
|
291
|
+
invariant(row, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 56, S: void 0, A: ["row", ""] });
|
|
342
292
|
return row;
|
|
343
293
|
}
|
|
344
294
|
}
|
|
@@ -422,7 +372,7 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
422
372
|
]);
|
|
423
373
|
const getOptions = useCallback((results) => results.map((obj) => {
|
|
424
374
|
return {
|
|
425
|
-
id: Entity.
|
|
375
|
+
id: Entity.getURI(obj),
|
|
426
376
|
label: getValue(obj, fieldProjection.field.referencePath) || obj.id.toString()
|
|
427
377
|
};
|
|
428
378
|
}).filter(isTruthy), [
|
|
@@ -438,7 +388,7 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
438
388
|
virtualRef: anchorRef
|
|
439
389
|
}), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
|
|
440
390
|
tabIndex: -1,
|
|
441
|
-
classNames: "dx-card-popover-width dx-density-
|
|
391
|
+
classNames: "dx-card-popover-width dx-density-md"
|
|
442
392
|
}, /* @__PURE__ */ React2.createElement(Popover.Arrow, null), /* @__PURE__ */ React2.createElement(Popover.Viewport, null, /* @__PURE__ */ React2.createElement(Form.Root, {
|
|
443
393
|
...formProps,
|
|
444
394
|
autoFocus: true,
|
|
@@ -458,11 +408,6 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
|
|
|
458
408
|
|
|
459
409
|
// src/components/TableCellEditor/TableCellEditor.tsx
|
|
460
410
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
|
|
461
|
-
var editorSlots = {
|
|
462
|
-
scroll: {
|
|
463
|
-
className: "!py-(--dx-grid-cell-editor-padding-block)"
|
|
464
|
-
}
|
|
465
|
-
};
|
|
466
411
|
var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, onCreate }) => {
|
|
467
412
|
const { editing } = useGridContext3("TableValueEditor", __gridScope);
|
|
468
413
|
const fieldProjection = useMemo2(() => {
|
|
@@ -472,15 +417,7 @@ var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, o
|
|
|
472
417
|
const { col } = parseCellIndex2(editing.index);
|
|
473
418
|
const field = model.projection.getFields()[col];
|
|
474
419
|
const fieldProjection2 = model.projection.getFieldProjection(field.id);
|
|
475
|
-
invariant2(fieldProjection2, void 0, {
|
|
476
|
-
F: __dxlog_file2,
|
|
477
|
-
L: 73,
|
|
478
|
-
S: void 0,
|
|
479
|
-
A: [
|
|
480
|
-
"fieldProjection",
|
|
481
|
-
""
|
|
482
|
-
]
|
|
483
|
-
});
|
|
420
|
+
invariant2(fieldProjection2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 21, S: void 0, A: ["fieldProjection", ""] });
|
|
484
421
|
return fieldProjection2;
|
|
485
422
|
}, [
|
|
486
423
|
model,
|
|
@@ -517,15 +454,7 @@ var TableCellEditor = ({ __gridScope, model, modals, onFocus, onSave }) => {
|
|
|
517
454
|
const { col } = parseCellIndex2(editing.index);
|
|
518
455
|
const field = model.projection.getFields()[col];
|
|
519
456
|
const fieldProjection2 = model.projection.getFieldProjection(field.id);
|
|
520
|
-
invariant2(fieldProjection2, void 0, {
|
|
521
|
-
F: __dxlog_file2,
|
|
522
|
-
L: 120,
|
|
523
|
-
S: void 0,
|
|
524
|
-
A: [
|
|
525
|
-
"fieldProjection",
|
|
526
|
-
""
|
|
527
|
-
]
|
|
528
|
-
});
|
|
457
|
+
invariant2(fieldProjection2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 59, S: void 0, A: ["fieldProjection", ""] });
|
|
529
458
|
return fieldProjection2;
|
|
530
459
|
}, [
|
|
531
460
|
model,
|
|
@@ -659,9 +588,13 @@ var TableCellEditor = ({ __gridScope, model, modals, onFocus, onSave }) => {
|
|
|
659
588
|
__gridScope
|
|
660
589
|
}), /* @__PURE__ */ React3.createElement(GridCellEditor, {
|
|
661
590
|
extensions,
|
|
591
|
+
slots: {
|
|
592
|
+
content: {
|
|
593
|
+
className: "!py-(--dx-grid-cell-editor-padding-block)"
|
|
594
|
+
}
|
|
595
|
+
},
|
|
662
596
|
getCellContent,
|
|
663
|
-
onBlur: handleBlur
|
|
664
|
-
slots: editorSlots
|
|
597
|
+
onBlur: handleBlur
|
|
665
598
|
}));
|
|
666
599
|
};
|
|
667
600
|
var determineNavigationAxis = ({ key }) => {
|
|
@@ -689,140 +622,52 @@ var determineNavigationDelta = ({ key, shift }) => {
|
|
|
689
622
|
return shift ? -1 : 1;
|
|
690
623
|
};
|
|
691
624
|
|
|
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
|
-
|
|
781
625
|
// src/components/Table/ColumnActionsMenu.tsx
|
|
782
626
|
import { useAtomValue } from "@effect-atom/atom-react";
|
|
783
|
-
import
|
|
627
|
+
import React4 from "react";
|
|
784
628
|
import { DropdownMenu, useTranslation } from "@dxos/react-ui";
|
|
629
|
+
import { translationKey as translationKey2 } from "#translations";
|
|
785
630
|
var ColumnActionsMenu = ({ model, modals }) => {
|
|
786
|
-
const { t } = useTranslation(
|
|
631
|
+
const { t } = useTranslation(translationKey2);
|
|
787
632
|
const state = useAtomValue(modals.state);
|
|
788
633
|
if (state?.type !== "column") {
|
|
789
634
|
return null;
|
|
790
635
|
}
|
|
791
636
|
const currentSort = model.getSorting();
|
|
792
637
|
const isCurrentColumnSorted = currentSort?.fieldId === state.fieldId;
|
|
793
|
-
return /* @__PURE__ */
|
|
638
|
+
return /* @__PURE__ */ React4.createElement(DropdownMenu.Root, {
|
|
794
639
|
modal: false,
|
|
795
640
|
open: true,
|
|
796
641
|
onOpenChange: modals.close
|
|
797
|
-
}, /* @__PURE__ */
|
|
642
|
+
}, /* @__PURE__ */ React4.createElement(DropdownMenu.VirtualTrigger, {
|
|
798
643
|
virtualRef: modals.trigger
|
|
799
|
-
}), /* @__PURE__ */
|
|
644
|
+
}), /* @__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, {
|
|
800
645
|
"data-testid": "column-sort-descending",
|
|
801
646
|
onClick: () => model.setSort(state.fieldId, "desc")
|
|
802
|
-
}, t("column
|
|
647
|
+
}, t("column-action-sort-descending.menu")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
803
648
|
"data-testid": "column-sort-ascending",
|
|
804
649
|
onClick: () => model.setSort(state.fieldId, "asc")
|
|
805
|
-
}, t("column
|
|
650
|
+
}, t("column-action-sort-ascending.menu")), isCurrentColumnSorted && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
806
651
|
"data-testid": "column-clear-sort",
|
|
807
652
|
onClick: () => model.clearSort()
|
|
808
|
-
}, t("column
|
|
653
|
+
}, t("column-action-clear-sorting.menu")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
809
654
|
"data-testid": "column-delete",
|
|
810
655
|
onClick: () => model.deleteColumn(state.fieldId)
|
|
811
|
-
}, t("column
|
|
656
|
+
}, t("column-action-delete.menu")), model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
812
657
|
"data-testid": "column-settings",
|
|
813
658
|
onClick: () => modals.openColumnSettings()
|
|
814
|
-
}, t("column
|
|
659
|
+
}, t("column-action-settings.menu"))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))));
|
|
815
660
|
};
|
|
816
661
|
|
|
817
662
|
// src/components/Table/ColumnSettings.tsx
|
|
818
663
|
import { useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
|
|
819
|
-
import
|
|
664
|
+
import React5, { useCallback as useCallback3, useEffect as useEffect2, useMemo as useMemo3, useState as useState3 } from "react";
|
|
820
665
|
import { Popover as Popover2 } from "@dxos/react-ui";
|
|
821
666
|
import { FieldEditor } from "@dxos/react-ui-form";
|
|
822
667
|
var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
|
|
823
668
|
const [newField, setNewField] = useState3();
|
|
824
669
|
const state = useAtomValue2(modals.state);
|
|
825
|
-
|
|
670
|
+
useEffect2(() => {
|
|
826
671
|
if (state?.type === "columnSettings" && state.mode.type === "create" && model?.projection) {
|
|
827
672
|
setNewField(model.projection.createFieldProjection());
|
|
828
673
|
requestAnimationFrame(() => {
|
|
@@ -835,7 +680,7 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
|
|
|
835
680
|
model?.projection,
|
|
836
681
|
state
|
|
837
682
|
]);
|
|
838
|
-
const existingField =
|
|
683
|
+
const existingField = useMemo3(() => {
|
|
839
684
|
if (state?.type === "columnSettings") {
|
|
840
685
|
const { mode } = state;
|
|
841
686
|
if (mode.type === "edit") {
|
|
@@ -865,54 +710,55 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
|
|
|
865
710
|
if (!model?.projection || !field) {
|
|
866
711
|
return null;
|
|
867
712
|
}
|
|
868
|
-
return /* @__PURE__ */
|
|
713
|
+
return /* @__PURE__ */ React5.createElement(Popover2.Root, {
|
|
869
714
|
modal: false,
|
|
870
715
|
open: state?.type === "columnSettings"
|
|
871
|
-
}, /* @__PURE__ */
|
|
716
|
+
}, /* @__PURE__ */ React5.createElement(Popover2.VirtualTrigger, {
|
|
872
717
|
virtualRef: modals.trigger
|
|
873
|
-
}), /* @__PURE__ */
|
|
718
|
+
}), /* @__PURE__ */ React5.createElement(Popover2.Portal, null, /* @__PURE__ */ React5.createElement(Popover2.Content, {
|
|
874
719
|
classNames: "md:w-64"
|
|
875
|
-
}, /* @__PURE__ */
|
|
720
|
+
}, /* @__PURE__ */ React5.createElement(Popover2.Viewport, null, /* @__PURE__ */ React5.createElement(FieldEditor, {
|
|
876
721
|
projection: model.projection,
|
|
877
722
|
field,
|
|
878
723
|
registry,
|
|
879
724
|
onSave: handleSave,
|
|
880
725
|
onCancel: handleCancel
|
|
881
|
-
})), /* @__PURE__ */
|
|
726
|
+
})), /* @__PURE__ */ React5.createElement(Popover2.Arrow, null))));
|
|
882
727
|
};
|
|
883
728
|
|
|
884
729
|
// src/components/Table/RowActionsMenu.tsx
|
|
885
730
|
import { useAtomValue as useAtomValue3 } from "@effect-atom/atom-react";
|
|
886
|
-
import
|
|
731
|
+
import React6 from "react";
|
|
887
732
|
import { DropdownMenu as DropdownMenu2, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
733
|
+
import { translationKey as translationKey3 } from "#translations";
|
|
888
734
|
var RowActionsMenu = ({ model, modals }) => {
|
|
889
|
-
const { t } = useTranslation2(
|
|
735
|
+
const { t } = useTranslation2(translationKey3);
|
|
890
736
|
const hasSelection = model.selection.hasSelection;
|
|
891
737
|
const state = useAtomValue3(modals.state);
|
|
892
738
|
if (state?.type !== "row") {
|
|
893
739
|
return null;
|
|
894
740
|
}
|
|
895
|
-
return /* @__PURE__ */
|
|
741
|
+
return /* @__PURE__ */ React6.createElement(DropdownMenu2.Root, {
|
|
896
742
|
modal: false,
|
|
897
743
|
open: true,
|
|
898
744
|
onOpenChange: modals.close
|
|
899
|
-
}, /* @__PURE__ */
|
|
745
|
+
}, /* @__PURE__ */ React6.createElement(DropdownMenu2.VirtualTrigger, {
|
|
900
746
|
virtualRef: modals.trigger
|
|
901
|
-
}), /* @__PURE__ */
|
|
747
|
+
}), /* @__PURE__ */ React6.createElement(DropdownMenu2.Content, null, /* @__PURE__ */ React6.createElement(DropdownMenu2.Viewport, null, model.rowActions?.length > 0 && /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(DropdownMenu2.Group, null, model.rowActions?.map((action) => /* @__PURE__ */ React6.createElement(DropdownMenu2.Item, {
|
|
902
748
|
key: action.id,
|
|
903
749
|
"data-testid": `row-action-${action.id}`,
|
|
904
750
|
onClick: () => {
|
|
905
751
|
modals.close();
|
|
906
752
|
model.handleRowAction(action.id, state.rowIndex);
|
|
907
753
|
}
|
|
908
|
-
}, toLocalizedString(action.label, t)))), /* @__PURE__ */
|
|
754
|
+
}, toLocalizedString(action.label, t)))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Separator, null)), model.features.dataEditable !== false && /* @__PURE__ */ React6.createElement(DropdownMenu2.Item, {
|
|
909
755
|
"data-testid": "row-menu-delete",
|
|
910
756
|
onClick: () => model.deleteRow(state.rowIndex)
|
|
911
|
-
}, t(hasSelection ? "bulk
|
|
757
|
+
}, t(hasSelection ? "bulk-delete-row.label" : "delete-row.label"))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Arrow, null)));
|
|
912
758
|
};
|
|
913
759
|
|
|
914
|
-
// src/components/Table/
|
|
915
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/Table/
|
|
760
|
+
// src/components/Table/TableContent.tsx
|
|
761
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/Table/TableContent.tsx";
|
|
916
762
|
var columnDefault = {
|
|
917
763
|
grid: {
|
|
918
764
|
minSize: 80,
|
|
@@ -925,19 +771,17 @@ var rowDefault = {
|
|
|
925
771
|
focusUnfurl: false
|
|
926
772
|
}
|
|
927
773
|
};
|
|
928
|
-
var emptyColumnMeta =
|
|
774
|
+
var emptyColumnMeta = Atom2.make({
|
|
929
775
|
grid: {}
|
|
930
776
|
});
|
|
931
|
-
var
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
var
|
|
935
|
-
|
|
936
|
-
var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate, onRowClick, testId, ...props }, forwardedRef) => {
|
|
937
|
-
const registry = useContext2(RegistryContext2);
|
|
777
|
+
var emptyRowsAtom = Atom2.make([]);
|
|
778
|
+
var emptyCellUpdateAtom = Atom2.make(0);
|
|
779
|
+
var TABLE_CONTENT_NAME = "Table.Content";
|
|
780
|
+
var TableContent = composable(({ schema, model, presentation, ignoreAttention, attendableId, onCreate, onRowClick, testId, ...props }, forwardedRef) => {
|
|
781
|
+
const registry = useContext(RegistryContext);
|
|
938
782
|
const [dxGrid, setDxGrid] = useState4(null);
|
|
939
|
-
const { hasAttention } = useAttention(model?.id ?? "table");
|
|
940
|
-
const modals =
|
|
783
|
+
const { hasAttention } = useAttention(attendableId ?? model?.id ?? "table");
|
|
784
|
+
const modals = useMemo4(() => new ModalController(registry), [
|
|
941
785
|
registry
|
|
942
786
|
]);
|
|
943
787
|
const columnMeta = useAtomValue4(model?.columnMeta ?? emptyColumnMeta);
|
|
@@ -945,7 +789,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
945
789
|
const cellUpdateCounter = useAtomValue4(model?.cellUpdate ?? emptyCellUpdateAtom);
|
|
946
790
|
const columnCount = Object.keys(columnMeta.grid).length || model?.projection.getFields().length || 0;
|
|
947
791
|
const draftRowCount = model?.getDraftRowCount() ?? 0;
|
|
948
|
-
const frozen =
|
|
792
|
+
const frozen = useMemo4(() => {
|
|
949
793
|
const noActionColumn = model?.features.dataEditable === false && model?.features.schemaEditable === false && model.rowActions.length === 0;
|
|
950
794
|
return {
|
|
951
795
|
frozenRowsStart: 1,
|
|
@@ -960,7 +804,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
960
804
|
const getCells = useCallback4((range, plane) => presentation?.getCells(range, plane) ?? {}, [
|
|
961
805
|
presentation
|
|
962
806
|
]);
|
|
963
|
-
|
|
807
|
+
useEffect3(() => {
|
|
964
808
|
if (!dxGrid || !presentation) {
|
|
965
809
|
return;
|
|
966
810
|
}
|
|
@@ -970,7 +814,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
970
814
|
presentation,
|
|
971
815
|
getCells
|
|
972
816
|
]);
|
|
973
|
-
|
|
817
|
+
useEffect3(() => {
|
|
974
818
|
if (!dxGrid) {
|
|
975
819
|
return;
|
|
976
820
|
}
|
|
@@ -1141,12 +985,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1141
985
|
void navigator.clipboard.writeText(textContent);
|
|
1142
986
|
event.preventDefault();
|
|
1143
987
|
} catch (error) {
|
|
1144
|
-
log.catch(error, void 0, {
|
|
1145
|
-
F: __dxlog_file3,
|
|
1146
|
-
L: 310,
|
|
1147
|
-
S: void 0,
|
|
1148
|
-
C: (f, a) => f(...a)
|
|
1149
|
-
});
|
|
988
|
+
log.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 263, S: void 0 });
|
|
1150
989
|
}
|
|
1151
990
|
break;
|
|
1152
991
|
}
|
|
@@ -1221,7 +1060,8 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1221
1060
|
model,
|
|
1222
1061
|
dxGrid
|
|
1223
1062
|
]);
|
|
1224
|
-
|
|
1063
|
+
const { controllerRef } = useTableContext(TABLE_CONTENT_NAME);
|
|
1064
|
+
controllerRef.current = useMemo4(() => {
|
|
1225
1065
|
if (!dxGrid || !presentation) {
|
|
1226
1066
|
return {};
|
|
1227
1067
|
}
|
|
@@ -1242,24 +1082,26 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1242
1082
|
presentation
|
|
1243
1083
|
]);
|
|
1244
1084
|
if (!model || !modals) {
|
|
1245
|
-
return /* @__PURE__ */
|
|
1085
|
+
return /* @__PURE__ */ React7.createElement("span", {
|
|
1246
1086
|
role: "none",
|
|
1247
1087
|
className: "dx-attention-surface"
|
|
1248
1088
|
});
|
|
1249
1089
|
}
|
|
1250
|
-
return /* @__PURE__ */
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1090
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
1091
|
+
...composableProps(props, {
|
|
1092
|
+
classNames: "dx-container relative"
|
|
1093
|
+
}),
|
|
1094
|
+
ref: forwardedRef
|
|
1095
|
+
}, /* @__PURE__ */ React7.createElement(Grid.Root, {
|
|
1254
1096
|
id: model.id ?? "table-grid"
|
|
1255
|
-
}, /* @__PURE__ */
|
|
1097
|
+
}, /* @__PURE__ */ React7.createElement(TableValueEditor, {
|
|
1256
1098
|
model,
|
|
1257
1099
|
modals,
|
|
1258
1100
|
schema,
|
|
1259
1101
|
onFocus: handleFocus,
|
|
1260
1102
|
onSave: handleSave,
|
|
1261
1103
|
onCreate
|
|
1262
|
-
}), /* @__PURE__ */
|
|
1104
|
+
}), /* @__PURE__ */ React7.createElement(Grid.Content, {
|
|
1263
1105
|
className: mx("[--dx-grid-base:var(--base-surface)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
|
|
1264
1106
|
frozen,
|
|
1265
1107
|
columns: columnMeta,
|
|
@@ -1276,56 +1118,166 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
|
|
|
1276
1118
|
"data-testid": testId
|
|
1277
1119
|
},
|
|
1278
1120
|
ref: setDxGrid
|
|
1279
|
-
}), /* @__PURE__ */
|
|
1121
|
+
}), /* @__PURE__ */ React7.createElement(RowActionsMenu, {
|
|
1280
1122
|
model,
|
|
1281
1123
|
modals
|
|
1282
|
-
}), /* @__PURE__ */
|
|
1124
|
+
}), /* @__PURE__ */ React7.createElement(ColumnActionsMenu, {
|
|
1283
1125
|
model,
|
|
1284
1126
|
modals
|
|
1285
|
-
}), /* @__PURE__ */
|
|
1127
|
+
}), /* @__PURE__ */ React7.createElement(ColumnSettings, {
|
|
1286
1128
|
model,
|
|
1287
1129
|
modals,
|
|
1288
1130
|
onNewColumn: handleNewColumn
|
|
1289
1131
|
})));
|
|
1290
|
-
};
|
|
1291
|
-
|
|
1132
|
+
});
|
|
1133
|
+
TableContent.displayName = TABLE_CONTENT_NAME;
|
|
1134
|
+
|
|
1135
|
+
// src/components/Table/TableToolbar.tsx
|
|
1136
|
+
import { Atom as Atom3, RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
|
|
1137
|
+
import React8, { useContext as useContext2, useEffect as useEffect4, useMemo as useMemo5 } from "react";
|
|
1138
|
+
import { composable as composable2, composableProps as composableProps2 } from "@dxos/react-ui";
|
|
1139
|
+
import { Menu, createGapSeparator, createMenuAction, useMenuActions } from "@dxos/react-ui-menu";
|
|
1140
|
+
import { translationKey as translationKey4 } from "#translations";
|
|
1141
|
+
var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) => Atom3.make((get) => {
|
|
1142
|
+
const nodes = [];
|
|
1143
|
+
if (onAdd) {
|
|
1144
|
+
const add = createMenuAction("add-row", onAdd, {
|
|
1145
|
+
type: "add-row",
|
|
1146
|
+
icon: "ph--plus--regular",
|
|
1147
|
+
label: [
|
|
1148
|
+
"add-row.label",
|
|
1149
|
+
{
|
|
1150
|
+
ns: translationKey4
|
|
1151
|
+
}
|
|
1152
|
+
],
|
|
1153
|
+
testId: "table.toolbar.add-row"
|
|
1154
|
+
});
|
|
1155
|
+
nodes.push(add);
|
|
1156
|
+
}
|
|
1157
|
+
if (onSave) {
|
|
1158
|
+
const state = get(stateAtom);
|
|
1159
|
+
const save = createMenuAction("save-view", onSave, {
|
|
1160
|
+
type: "save-view",
|
|
1161
|
+
icon: "ph--floppy-disk--regular",
|
|
1162
|
+
label: [
|
|
1163
|
+
"save-view.label",
|
|
1164
|
+
{
|
|
1165
|
+
ns: translationKey4
|
|
1166
|
+
}
|
|
1167
|
+
],
|
|
1168
|
+
testId: "table.toolbar.save-view",
|
|
1169
|
+
iconOnly: false,
|
|
1170
|
+
hidden: !state.viewDirty
|
|
1171
|
+
});
|
|
1172
|
+
nodes.push(save);
|
|
1173
|
+
}
|
|
1174
|
+
const gap = createGapSeparator();
|
|
1175
|
+
nodes.push(...gap.nodes);
|
|
1176
|
+
const edges = nodes.map(({ id: target }) => ({
|
|
1177
|
+
source: "root",
|
|
1178
|
+
target,
|
|
1179
|
+
relation: "child"
|
|
1180
|
+
}));
|
|
1181
|
+
if (customActions) {
|
|
1182
|
+
const custom = get(customActions);
|
|
1183
|
+
nodes.push(...custom.nodes);
|
|
1184
|
+
edges.push(...custom.edges);
|
|
1185
|
+
}
|
|
1186
|
+
return {
|
|
1187
|
+
nodes,
|
|
1188
|
+
edges
|
|
1189
|
+
};
|
|
1190
|
+
});
|
|
1191
|
+
var TableToolbar = composable2(({ attendableId, viewDirty, onAdd, onSave, customActions, ...props }, forwardedRef) => {
|
|
1192
|
+
const registry = useContext2(RegistryContext2);
|
|
1193
|
+
const stateAtom = useMemo5(() => Atom3.make({
|
|
1194
|
+
viewDirty
|
|
1195
|
+
}), []);
|
|
1196
|
+
useEffect4(() => {
|
|
1197
|
+
registry.set(stateAtom, {
|
|
1198
|
+
viewDirty
|
|
1199
|
+
});
|
|
1200
|
+
}, [
|
|
1201
|
+
registry,
|
|
1202
|
+
stateAtom,
|
|
1203
|
+
viewDirty
|
|
1204
|
+
]);
|
|
1205
|
+
const actionsCreator = useMemo5(() => createTableToolbarActions({
|
|
1206
|
+
stateAtom,
|
|
1207
|
+
onAdd,
|
|
1208
|
+
onSave,
|
|
1209
|
+
customActions
|
|
1210
|
+
}), [
|
|
1211
|
+
stateAtom,
|
|
1212
|
+
onAdd,
|
|
1213
|
+
onSave,
|
|
1214
|
+
customActions
|
|
1215
|
+
]);
|
|
1216
|
+
const menuActions = useMenuActions(actionsCreator);
|
|
1217
|
+
return /* @__PURE__ */ React8.createElement(Menu.Root, {
|
|
1218
|
+
...menuActions,
|
|
1219
|
+
attendableId
|
|
1220
|
+
}, /* @__PURE__ */ React8.createElement(Menu.Toolbar, {
|
|
1221
|
+
...composableProps2(props),
|
|
1222
|
+
ref: forwardedRef
|
|
1223
|
+
}));
|
|
1224
|
+
});
|
|
1225
|
+
TableToolbar.displayName = "TableToolbar";
|
|
1226
|
+
|
|
1227
|
+
// src/components/Table/Table.tsx
|
|
1228
|
+
var emptyColumnMeta2 = Atom4.make({
|
|
1229
|
+
grid: {}
|
|
1230
|
+
});
|
|
1231
|
+
var [TableContextProvider, useTableContext] = createContext("Table");
|
|
1232
|
+
var TABLE_ROOT_NAME = "Table.Root";
|
|
1233
|
+
var TableRoot = /* @__PURE__ */ forwardRef(({ children }, forwardedRef) => {
|
|
1234
|
+
const controllerRef = useRef3({});
|
|
1235
|
+
useImperativeHandle(forwardedRef, () => ({
|
|
1236
|
+
update: (cell) => controllerRef.current?.update?.(cell),
|
|
1237
|
+
handleInsertRowResult: (result) => controllerRef.current?.handleInsertRowResult?.(result)
|
|
1238
|
+
}), []);
|
|
1239
|
+
return /* @__PURE__ */ React9.createElement(TableContextProvider, {
|
|
1240
|
+
controllerRef
|
|
1241
|
+
}, children);
|
|
1242
|
+
});
|
|
1243
|
+
TableRoot.displayName = TABLE_ROOT_NAME;
|
|
1292
1244
|
var Table = {
|
|
1293
1245
|
Root: TableRoot,
|
|
1294
|
-
|
|
1295
|
-
|
|
1246
|
+
Toolbar: TableToolbar,
|
|
1247
|
+
Content: TableContent
|
|
1296
1248
|
};
|
|
1297
1249
|
|
|
1298
1250
|
// src/components/Table/DynamicTable.tsx
|
|
1299
1251
|
import { RegistryContext as RegistryContext3 } from "@effect-atom/atom-react";
|
|
1300
|
-
import
|
|
1252
|
+
import React10, { useCallback as useCallback5, useContext as useContext3, useEffect as useEffect5, useMemo as useMemo6, useRef as useRef4, useState as useState5 } from "react";
|
|
1301
1253
|
import { useDefaultValue } from "@dxos/react-ui";
|
|
1302
1254
|
import { mx as mx2 } from "@dxos/ui-theme";
|
|
1303
|
-
var DynamicTable = ({ classNames,
|
|
1255
|
+
var DynamicTable = ({ classNames, type: typeProp, name = "com.example.dynamicTable", rows, properties, jsonSchema: jsonSchemaProp, rowActions, onRowClick, onRowAction, ...props }) => {
|
|
1304
1256
|
const registry = useContext3(RegistryContext3);
|
|
1305
1257
|
const [dynamicTable, setDynamicTable] = useState5();
|
|
1306
|
-
const {
|
|
1258
|
+
const { type } = useMemo6(() => getBaseSchema({
|
|
1307
1259
|
typename: name,
|
|
1308
1260
|
properties,
|
|
1309
1261
|
jsonSchema: jsonSchemaProp,
|
|
1310
|
-
|
|
1262
|
+
type: typeProp
|
|
1311
1263
|
}), [
|
|
1312
1264
|
name,
|
|
1313
1265
|
properties,
|
|
1314
1266
|
jsonSchemaProp,
|
|
1315
|
-
|
|
1267
|
+
typeProp
|
|
1316
1268
|
]);
|
|
1317
1269
|
useEffect5(() => {
|
|
1318
1270
|
setDynamicTable(makeDynamicTable({
|
|
1319
1271
|
registry,
|
|
1320
|
-
|
|
1272
|
+
type,
|
|
1321
1273
|
properties
|
|
1322
1274
|
}));
|
|
1323
1275
|
}, [
|
|
1324
1276
|
registry,
|
|
1325
|
-
|
|
1277
|
+
type,
|
|
1326
1278
|
properties
|
|
1327
1279
|
]);
|
|
1328
|
-
const tableRef =
|
|
1280
|
+
const tableRef = useRef4(null);
|
|
1329
1281
|
const handleCellUpdate = useCallback5((cell) => {
|
|
1330
1282
|
tableRef.current?.update?.(cell);
|
|
1331
1283
|
}, []);
|
|
@@ -1356,14 +1308,13 @@ var DynamicTable = ({ classNames, schema, name = "com.example.dynamic-table", ro
|
|
|
1356
1308
|
registry,
|
|
1357
1309
|
model
|
|
1358
1310
|
]);
|
|
1359
|
-
return /* @__PURE__ */
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
}, /* @__PURE__ */ React9.createElement("div", {
|
|
1363
|
-
role: "none",
|
|
1311
|
+
return /* @__PURE__ */ React10.createElement("div", {
|
|
1312
|
+
className: mx2("dx-expander grid", classNames)
|
|
1313
|
+
}, /* @__PURE__ */ React10.createElement("div", {
|
|
1364
1314
|
className: "grid min-h-0 overflow-hidden"
|
|
1365
|
-
}, /* @__PURE__ */
|
|
1366
|
-
ref: tableRef
|
|
1315
|
+
}, /* @__PURE__ */ React10.createElement(Table.Root, {
|
|
1316
|
+
ref: tableRef
|
|
1317
|
+
}, /* @__PURE__ */ React10.createElement(Table.Content, {
|
|
1367
1318
|
model,
|
|
1368
1319
|
presentation,
|
|
1369
1320
|
ignoreAttention: true,
|
|
@@ -1380,7 +1331,6 @@ export {
|
|
|
1380
1331
|
Table,
|
|
1381
1332
|
TableModel,
|
|
1382
1333
|
TablePresentation,
|
|
1383
|
-
TableToolbar,
|
|
1384
1334
|
cellClassesForRowSelection,
|
|
1385
1335
|
compareValues,
|
|
1386
1336
|
createDirectChangeCallback,
|
|
@@ -1393,9 +1343,9 @@ export {
|
|
|
1393
1343
|
tableButtons,
|
|
1394
1344
|
tableControls,
|
|
1395
1345
|
touch,
|
|
1396
|
-
translations,
|
|
1397
1346
|
useAddRow,
|
|
1398
1347
|
useProjectionModel,
|
|
1348
|
+
useTableContext,
|
|
1399
1349
|
useTableModel
|
|
1400
1350
|
};
|
|
1401
1351
|
//# sourceMappingURL=index.mjs.map
|