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