@dxos/react-ui-table 0.8.4-main.5ea62a8 → 0.8.4-main.ae835ea
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-63UUF4IG.mjs → chunk-4K7JPALT.mjs} +5 -5
- package/dist/lib/browser/chunk-4K7JPALT.mjs.map +7 -0
- package/dist/lib/browser/{chunk-RQYXNWWN.mjs → chunk-G7MGPBSR.mjs} +444 -490
- package/dist/lib/browser/chunk-G7MGPBSR.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +132 -283
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +9 -6
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/{chunk-QNDUGIS7.mjs → chunk-LD5JEBA6.mjs} +444 -490
- package/dist/lib/node-esm/chunk-LD5JEBA6.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-K734DJB7.mjs → chunk-MK6OVUF6.mjs} +5 -5
- package/dist/lib/node-esm/chunk-MK6OVUF6.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +132 -283
- 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 +9 -6
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +2 -2
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +3 -3
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +71 -7
- package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +5 -2
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +5 -6
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +7 -5
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +5 -3
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +1 -2
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/index.d.ts +1 -0
- package/dist/types/src/components/TableCellEditor/index.d.ts.map +1 -1
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +3 -3
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useAddRow.d.ts +1 -1
- package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts +0 -7
- package/dist/types/src/model/modal-controller.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts +2 -2
- 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/model/table-sorting.d.ts +1 -2
- package/dist/types/src/model/table-sorting.d.ts.map +1 -1
- package/dist/types/src/testing/useTestTableModel.d.ts +3 -17
- package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +3 -3
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +4 -5
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/schema.d.ts +1 -1
- package/dist/types/src/util/schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +51 -51
- package/src/components/Table/DynamicTable.stories.tsx +8 -7
- package/src/components/Table/DynamicTable.tsx +4 -7
- package/src/components/Table/Relations.stories.tsx +119 -11
- package/src/components/Table/Table.stories.tsx +36 -35
- package/src/components/Table/Table.tsx +13 -9
- package/src/components/TableCellEditor/FormCellEditor.tsx +51 -41
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +17 -45
- package/src/components/TableCellEditor/TableCellEditor.tsx +17 -112
- package/src/components/TableCellEditor/index.ts +1 -0
- package/src/components/TableToolbar/TableToolbar.tsx +3 -0
- package/src/components/testing.ts +2 -2
- package/src/hooks/useAddRow.ts +1 -1
- package/src/hooks/useTableModel.ts +1 -1
- package/src/model/modal-controller.ts +0 -28
- package/src/model/table-model.test.ts +16 -6
- package/src/model/table-model.ts +10 -3
- package/src/model/table-presentation.test.ts +19 -17
- package/src/model/table-presentation.ts +4 -5
- package/src/model/table-sorting.ts +15 -6
- package/src/playwright/smoke.spec.ts +3 -3
- package/src/testing/useTestTableModel.ts +7 -4
- package/src/types/schema.ts +4 -4
- package/src/util/dynamic-table.ts +8 -8
- package/src/util/schema.ts +4 -4
- package/dist/lib/browser/chunk-63UUF4IG.mjs.map +0 -7
- package/dist/lib/browser/chunk-RQYXNWWN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-K734DJB7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QNDUGIS7.mjs.map +0 -7
- package/dist/types/src/components/Table/CreateRefPanel.d.ts +0 -9
- package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +0 -1
- package/src/components/Table/CreateRefPanel.tsx +0 -103
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
touch,
|
|
16
16
|
useAddRow,
|
|
17
17
|
useTableModel
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-G7MGPBSR.mjs";
|
|
19
|
+
import "./chunk-4K7JPALT.mjs";
|
|
20
20
|
|
|
21
21
|
// src/translations.ts
|
|
22
22
|
var translationKey = "react-ui-table";
|
|
@@ -51,8 +51,9 @@ var translations = [
|
|
|
51
51
|
];
|
|
52
52
|
|
|
53
53
|
// src/components/Table/Table.tsx
|
|
54
|
-
import { useSignals as
|
|
55
|
-
import
|
|
54
|
+
import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
|
|
55
|
+
import * as String2 from "effect/String";
|
|
56
|
+
import React7, { forwardRef, useCallback as useCallback4, useEffect as useEffect3, useImperativeHandle, useMemo as useMemo4, useState as useState4 } from "react";
|
|
56
57
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
57
58
|
import { Grid, closestCell, gridSeparatorBlockEnd, gridSeparatorInlineEnd } from "@dxos/react-ui-grid";
|
|
58
59
|
import { DxEditRequest } from "@dxos/react-ui-grid";
|
|
@@ -63,12 +64,9 @@ import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking"
|
|
|
63
64
|
import { EditorView } from "@codemirror/view";
|
|
64
65
|
import React3, { useCallback as useCallback2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
|
|
65
66
|
import { debounce } from "@dxos/async";
|
|
66
|
-
import { FormatEnum, TypeEnum } from "@dxos/echo
|
|
67
|
+
import { FormatEnum as FormatEnum2, TypeEnum } from "@dxos/echo/internal";
|
|
67
68
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
68
|
-
import { useThemeContext } from "@dxos/react-ui";
|
|
69
|
-
import { createMarkdownExtensions } from "@dxos/react-ui-editor";
|
|
70
69
|
import { GridCellEditor, editorKeys, parseCellIndex as parseCellIndex2, useGridContext as useGridContext3 } from "@dxos/react-ui-grid";
|
|
71
|
-
import { createLinks, tagPicker } from "@dxos/react-ui-tag-picker";
|
|
72
70
|
|
|
73
71
|
// src/components/TableCellEditor/CellValidationMessage.tsx
|
|
74
72
|
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
@@ -103,16 +101,17 @@ var CellValidationMessage = ({ validationError, variant = "error", __gridScope }
|
|
|
103
101
|
|
|
104
102
|
// src/components/TableCellEditor/FormCellEditor.tsx
|
|
105
103
|
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
104
|
+
import * as Schema from "effect/Schema";
|
|
106
105
|
import React2, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
107
106
|
import { Filter, Obj } from "@dxos/echo";
|
|
108
|
-
import { Ref, getValue } from "@dxos/echo
|
|
107
|
+
import { FormatEnum, Ref, getValue } from "@dxos/echo/internal";
|
|
109
108
|
import { invariant } from "@dxos/invariant";
|
|
110
109
|
import { getSnapshot } from "@dxos/live-object";
|
|
111
110
|
import { getSpace } from "@dxos/react-client/echo";
|
|
112
111
|
import { Popover } from "@dxos/react-ui";
|
|
113
112
|
import { Form } from "@dxos/react-ui-form";
|
|
114
|
-
import {
|
|
115
|
-
import { getDeep,
|
|
113
|
+
import { parseCellIndex, useGridContext as useGridContext2 } from "@dxos/react-ui-grid";
|
|
114
|
+
import { getDeep, isTruthy, setDeep } from "@dxos/util";
|
|
116
115
|
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx";
|
|
117
116
|
var createOptionLabel = [
|
|
118
117
|
"create new object label",
|
|
@@ -120,7 +119,7 @@ var createOptionLabel = [
|
|
|
120
119
|
ns: translationKey
|
|
121
120
|
}
|
|
122
121
|
];
|
|
123
|
-
var FormCellEditor = ({ fieldProjection, model, schema, onSave, client, modals, __gridScope, ...formProps }) => {
|
|
122
|
+
var FormCellEditor = ({ fieldProjection, model, schema, onSave, client, modals, onCreate, __gridScope, ...formProps }) => {
|
|
124
123
|
var _effect = _useSignals2();
|
|
125
124
|
try {
|
|
126
125
|
const { editing: contextEditing, setEditing, id: gridId } = useGridContext2("ArrayEditor", __gridScope);
|
|
@@ -130,7 +129,7 @@ var FormCellEditor = ({ fieldProjection, model, schema, onSave, client, modals,
|
|
|
130
129
|
const space = getSpace(model.view);
|
|
131
130
|
invariant(space, void 0, {
|
|
132
131
|
F: __dxlog_file,
|
|
133
|
-
L:
|
|
132
|
+
L: 57,
|
|
134
133
|
S: void 0,
|
|
135
134
|
A: [
|
|
136
135
|
"space",
|
|
@@ -161,7 +160,7 @@ var FormCellEditor = ({ fieldProjection, model, schema, onSave, client, modals,
|
|
|
161
160
|
dxn: Obj.getDXN(obj),
|
|
162
161
|
label: getValue(obj, fieldProjection.field.referencePath) || obj.id.toString()
|
|
163
162
|
};
|
|
164
|
-
}).filter(
|
|
163
|
+
}).filter(isTruthy);
|
|
165
164
|
}
|
|
166
165
|
return [];
|
|
167
166
|
}, [
|
|
@@ -175,7 +174,7 @@ var FormCellEditor = ({ fieldProjection, model, schema, onSave, client, modals,
|
|
|
175
174
|
const draftRow = model.draftRows.value[cell.row];
|
|
176
175
|
invariant(draftRow, void 0, {
|
|
177
176
|
F: __dxlog_file,
|
|
178
|
-
L:
|
|
177
|
+
L: 98,
|
|
179
178
|
S: void 0,
|
|
180
179
|
A: [
|
|
181
180
|
"draftRow",
|
|
@@ -187,7 +186,7 @@ var FormCellEditor = ({ fieldProjection, model, schema, onSave, client, modals,
|
|
|
187
186
|
const row = model.getRowAt(cell.row);
|
|
188
187
|
invariant(row, void 0, {
|
|
189
188
|
F: __dxlog_file,
|
|
190
|
-
L:
|
|
189
|
+
L: 102,
|
|
191
190
|
S: void 0,
|
|
192
191
|
A: [
|
|
193
192
|
"row",
|
|
@@ -220,38 +219,6 @@ var FormCellEditor = ({ fieldProjection, model, schema, onSave, client, modals,
|
|
|
220
219
|
contextEditing,
|
|
221
220
|
originalRow
|
|
222
221
|
]);
|
|
223
|
-
const handleCreate = useCallback((object) => {
|
|
224
|
-
const ref = Ref.make(object);
|
|
225
|
-
const path = fieldProjection.field.path;
|
|
226
|
-
setDeep(originalRow, [
|
|
227
|
-
path
|
|
228
|
-
], ref);
|
|
229
|
-
contextEditing?.cellElement?.focus();
|
|
230
|
-
setEditing(null);
|
|
231
|
-
setLocalEditing(false);
|
|
232
|
-
onSave?.();
|
|
233
|
-
}, [
|
|
234
|
-
fieldProjection.field.path,
|
|
235
|
-
onSave,
|
|
236
|
-
contextEditing,
|
|
237
|
-
originalRow
|
|
238
|
-
]);
|
|
239
|
-
const handleCreateFromQuery = useCallback(async (typeAnnotation, query) => {
|
|
240
|
-
if (model && modals && contextEditing?.index) {
|
|
241
|
-
setLocalEditing(false);
|
|
242
|
-
modals.openCreateRef(typeAnnotation.typename, document.querySelector(cellQuery(contextEditing.index, gridId)), {
|
|
243
|
-
[fieldProjection.field.referencePath]: query
|
|
244
|
-
}, handleCreate);
|
|
245
|
-
}
|
|
246
|
-
}, [
|
|
247
|
-
model,
|
|
248
|
-
modals,
|
|
249
|
-
client,
|
|
250
|
-
contextEditing?.index,
|
|
251
|
-
gridId,
|
|
252
|
-
fieldProjection,
|
|
253
|
-
handleSave
|
|
254
|
-
]);
|
|
255
222
|
useEffect(() => {
|
|
256
223
|
if (contextEditing && contextEditing.cellElement) {
|
|
257
224
|
anchorRef.current = contextEditing.cellElement.querySelector(".dx-grid__cell__content");
|
|
@@ -284,6 +251,46 @@ var FormCellEditor = ({ fieldProjection, model, schema, onSave, client, modals,
|
|
|
284
251
|
}
|
|
285
252
|
setLocalEditing(nextOpen);
|
|
286
253
|
}, []);
|
|
254
|
+
const createSchema = useMemo(() => {
|
|
255
|
+
if (fieldProjection.props.format === FormatEnum.Ref && fieldProjection.props.referenceSchema) {
|
|
256
|
+
const { schema: refSchema } = getSchema({
|
|
257
|
+
typename: fieldProjection.props.referenceSchema
|
|
258
|
+
});
|
|
259
|
+
if (!refSchema) {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
const omit2 = Schema.omit("id");
|
|
263
|
+
return omit2(refSchema);
|
|
264
|
+
}
|
|
265
|
+
return null;
|
|
266
|
+
}, [
|
|
267
|
+
fieldProjection.props.format,
|
|
268
|
+
fieldProjection.props.referenceSchema,
|
|
269
|
+
getSchema
|
|
270
|
+
]);
|
|
271
|
+
const handleCreate = useCallback((values) => {
|
|
272
|
+
if (schema && onCreate) {
|
|
273
|
+
const objectWithId = onCreate(schema, values);
|
|
274
|
+
if (objectWithId) {
|
|
275
|
+
const ref = Ref.make(objectWithId);
|
|
276
|
+
const path = fieldProjection.field.path;
|
|
277
|
+
setDeep(originalRow, [
|
|
278
|
+
path
|
|
279
|
+
], ref);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
contextEditing?.cellElement?.focus();
|
|
283
|
+
setEditing(null);
|
|
284
|
+
setLocalEditing(false);
|
|
285
|
+
onSave?.();
|
|
286
|
+
}, [
|
|
287
|
+
fieldProjection.field.path,
|
|
288
|
+
onSave,
|
|
289
|
+
contextEditing,
|
|
290
|
+
originalRow,
|
|
291
|
+
createSchema,
|
|
292
|
+
onCreate
|
|
293
|
+
]);
|
|
287
294
|
if (!editing) {
|
|
288
295
|
return null;
|
|
289
296
|
}
|
|
@@ -302,9 +309,13 @@ var FormCellEditor = ({ fieldProjection, model, schema, onSave, client, modals,
|
|
|
302
309
|
onSave: handleSave,
|
|
303
310
|
...formProps,
|
|
304
311
|
onQueryRefOptions: handleQueryRefOptions,
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
312
|
+
...createSchema && {
|
|
313
|
+
onCreate: handleCreate,
|
|
314
|
+
createSchema,
|
|
315
|
+
createInitialValuePath: fieldProjection.field.referencePath,
|
|
316
|
+
createOptionIcon: "ph--plus--regular",
|
|
317
|
+
createOptionLabel
|
|
318
|
+
}
|
|
308
319
|
})))));
|
|
309
320
|
} finally {
|
|
310
321
|
_effect.f();
|
|
@@ -314,7 +325,7 @@ var FormCellEditor = ({ fieldProjection, model, schema, onSave, client, modals,
|
|
|
314
325
|
// src/components/TableCellEditor/TableCellEditor.tsx
|
|
315
326
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
|
|
316
327
|
var adaptValidationMessage = (message) => message ? message.endsWith("is missing") ? "Can\u2019t be blank" : message : null;
|
|
317
|
-
var TableValueEditor = ({ model, modals, schema, onFocus, onSave, client, __gridScope }) => {
|
|
328
|
+
var TableValueEditor = ({ model, modals, schema, onFocus, onSave, onCreate, client, __gridScope }) => {
|
|
318
329
|
var _effect = _useSignals3();
|
|
319
330
|
try {
|
|
320
331
|
const { editing } = useGridContext3("TableValueEditor", __gridScope);
|
|
@@ -327,7 +338,7 @@ var TableValueEditor = ({ model, modals, schema, onFocus, onSave, client, __grid
|
|
|
327
338
|
const fieldProjection2 = model.projection.getFieldProjection(field.id);
|
|
328
339
|
invariant2(fieldProjection2, void 0, {
|
|
329
340
|
F: __dxlog_file2,
|
|
330
|
-
L:
|
|
341
|
+
L: 71,
|
|
331
342
|
S: void 0,
|
|
332
343
|
A: [
|
|
333
344
|
"fieldProjection",
|
|
@@ -339,13 +350,14 @@ var TableValueEditor = ({ model, modals, schema, onFocus, onSave, client, __grid
|
|
|
339
350
|
model,
|
|
340
351
|
editing
|
|
341
352
|
]);
|
|
342
|
-
if (fieldProjection?.props.type === TypeEnum.Array || fieldProjection?.props.format ===
|
|
353
|
+
if (fieldProjection?.props.type === TypeEnum.Array || fieldProjection?.props.format === FormatEnum2.SingleSelect || fieldProjection?.props.format === FormatEnum2.Ref) {
|
|
343
354
|
return /* @__PURE__ */ React3.createElement(FormCellEditor, {
|
|
344
355
|
fieldProjection,
|
|
345
356
|
model,
|
|
346
357
|
schema,
|
|
347
358
|
__gridScope,
|
|
348
359
|
onSave,
|
|
360
|
+
onCreate,
|
|
349
361
|
client,
|
|
350
362
|
modals
|
|
351
363
|
});
|
|
@@ -362,16 +374,15 @@ var TableValueEditor = ({ model, modals, schema, onFocus, onSave, client, __grid
|
|
|
362
374
|
}
|
|
363
375
|
};
|
|
364
376
|
var editorSlots = {
|
|
365
|
-
|
|
377
|
+
scroll: {
|
|
366
378
|
className: "!plb-[--dx-grid-cell-editor-padding-block]"
|
|
367
379
|
}
|
|
368
380
|
};
|
|
369
381
|
var TableCellEditor = ({ model, modals, onFocus, onSave, __gridScope }) => {
|
|
370
382
|
var _effect = _useSignals3();
|
|
371
383
|
try {
|
|
372
|
-
const {
|
|
384
|
+
const { editing, setEditing } = useGridContext3("TableCellEditor", __gridScope);
|
|
373
385
|
const suppressNextBlur = useRef2(false);
|
|
374
|
-
const { themeMode } = useThemeContext();
|
|
375
386
|
const [validationError, setValidationError] = useState2(null);
|
|
376
387
|
const [validationVariant, setValidationVariant] = useState2("error");
|
|
377
388
|
const fieldProjection = useMemo2(() => {
|
|
@@ -383,7 +394,7 @@ var TableCellEditor = ({ model, modals, onFocus, onSave, __gridScope }) => {
|
|
|
383
394
|
const fieldProjection2 = model.projection.getFieldProjection(field.id);
|
|
384
395
|
invariant2(fieldProjection2, void 0, {
|
|
385
396
|
F: __dxlog_file2,
|
|
386
|
-
L:
|
|
397
|
+
L: 121,
|
|
387
398
|
S: void 0,
|
|
388
399
|
A: [
|
|
389
400
|
"fieldProjection",
|
|
@@ -473,11 +484,11 @@ var TableCellEditor = ({ model, modals, onFocus, onSave, __gridScope }) => {
|
|
|
473
484
|
setEditing,
|
|
474
485
|
onSave
|
|
475
486
|
]);
|
|
476
|
-
const
|
|
487
|
+
const extensions = useMemo2(() => {
|
|
477
488
|
if (!fieldProjection) {
|
|
478
489
|
return [];
|
|
479
490
|
}
|
|
480
|
-
const
|
|
491
|
+
const extensions2 = [
|
|
481
492
|
editorKeys({
|
|
482
493
|
onClose: handleClose,
|
|
483
494
|
...editing?.initialContent && {
|
|
@@ -485,39 +496,8 @@ var TableCellEditor = ({ model, modals, onFocus, onSave, __gridScope }) => {
|
|
|
485
496
|
}
|
|
486
497
|
})
|
|
487
498
|
];
|
|
488
|
-
const format = fieldProjection.props.format;
|
|
489
|
-
if (format === FormatEnum.SingleSelect || format === FormatEnum.MultiSelect) {
|
|
490
|
-
extension2.push(createMarkdownExtensions({
|
|
491
|
-
themeMode
|
|
492
|
-
}));
|
|
493
|
-
const options = fieldProjection.props.options || [];
|
|
494
|
-
const mode = format === FormatEnum.SingleSelect ? "single-select" : "multi-select";
|
|
495
|
-
extension2.push(tagPicker({
|
|
496
|
-
mode,
|
|
497
|
-
keymap: false,
|
|
498
|
-
onSearch: (text, selectedIds) => {
|
|
499
|
-
return options.filter((option) => selectedIds.indexOf(option.id) === -1 && (text.length === 0 || option.title.toLowerCase().includes(text.toLowerCase()))).map((option) => ({
|
|
500
|
-
id: option.id,
|
|
501
|
-
label: option.title,
|
|
502
|
-
hue: option.color
|
|
503
|
-
}));
|
|
504
|
-
},
|
|
505
|
-
onUpdate: (ids) => {
|
|
506
|
-
if (model && editing) {
|
|
507
|
-
if (ids.length === 0) {
|
|
508
|
-
return;
|
|
509
|
-
}
|
|
510
|
-
if (mode === "single-select") {
|
|
511
|
-
void handleEnter(ids[0]);
|
|
512
|
-
} else {
|
|
513
|
-
void handleEnter(ids);
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
}));
|
|
518
|
-
}
|
|
519
499
|
if (model && editing) {
|
|
520
|
-
|
|
500
|
+
extensions2.push(EditorView.updateListener.of(debounce((update) => {
|
|
521
501
|
const content = update.state.doc.toString();
|
|
522
502
|
const cell = parseCellIndex2(editing.index);
|
|
523
503
|
void model.validateCellData(cell, content).then((result) => {
|
|
@@ -530,54 +510,17 @@ var TableCellEditor = ({ model, modals, onFocus, onSave, __gridScope }) => {
|
|
|
530
510
|
});
|
|
531
511
|
}, 10)));
|
|
532
512
|
}
|
|
533
|
-
return
|
|
513
|
+
return extensions2;
|
|
534
514
|
}, [
|
|
535
515
|
model,
|
|
536
516
|
modals,
|
|
537
517
|
editing,
|
|
538
518
|
fieldProjection,
|
|
539
|
-
handleClose
|
|
540
|
-
themeMode
|
|
519
|
+
handleClose
|
|
541
520
|
]);
|
|
542
521
|
const getCellContent = useCallback2(() => {
|
|
543
522
|
if (model && editing) {
|
|
544
523
|
const cell = parseCellIndex2(editing.index);
|
|
545
|
-
const { col } = cell;
|
|
546
|
-
const field = model.projection.fields[col];
|
|
547
|
-
const fieldProjection2 = model.projection.getFieldProjection(field.id);
|
|
548
|
-
if (fieldProjection2?.props.format === FormatEnum.SingleSelect || fieldProjection2?.props.format === FormatEnum.MultiSelect) {
|
|
549
|
-
const value2 = model.getCellData(cell);
|
|
550
|
-
if (value2 !== void 0) {
|
|
551
|
-
const options = fieldProjection2.props.options || [];
|
|
552
|
-
if (fieldProjection2.props.format === FormatEnum.MultiSelect) {
|
|
553
|
-
const tagItems = value2.split(",").map((id) => {
|
|
554
|
-
const option = options.find((o) => o.id === id);
|
|
555
|
-
if (option) {
|
|
556
|
-
return {
|
|
557
|
-
id,
|
|
558
|
-
label: option.title,
|
|
559
|
-
hue: option.color
|
|
560
|
-
};
|
|
561
|
-
}
|
|
562
|
-
return void 0;
|
|
563
|
-
}).filter((item) => item !== void 0);
|
|
564
|
-
return createLinks(tagItems);
|
|
565
|
-
} else {
|
|
566
|
-
const option = options.find((o) => o.id === value2);
|
|
567
|
-
if (option) {
|
|
568
|
-
const tagItem = {
|
|
569
|
-
id: value2,
|
|
570
|
-
label: option.title,
|
|
571
|
-
hue: option.color
|
|
572
|
-
};
|
|
573
|
-
return createLinks([
|
|
574
|
-
tagItem
|
|
575
|
-
]);
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
return "";
|
|
580
|
-
}
|
|
581
524
|
const value = model.getCellData(cell);
|
|
582
525
|
return value !== void 0 ? String(value) : "";
|
|
583
526
|
}
|
|
@@ -590,7 +533,7 @@ var TableCellEditor = ({ model, modals, onFocus, onSave, __gridScope }) => {
|
|
|
590
533
|
variant: validationVariant,
|
|
591
534
|
__gridScope
|
|
592
535
|
}), /* @__PURE__ */ React3.createElement(GridCellEditor, {
|
|
593
|
-
|
|
536
|
+
extensions,
|
|
594
537
|
getCellContent,
|
|
595
538
|
onBlur: handleBlur,
|
|
596
539
|
slots: editorSlots
|
|
@@ -737,106 +680,12 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
|
|
|
737
680
|
}
|
|
738
681
|
};
|
|
739
682
|
|
|
740
|
-
// src/components/Table/CreateRefPanel.tsx
|
|
741
|
-
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
742
|
-
import { Schema } from "effect";
|
|
743
|
-
import React6, { useCallback as useCallback4, useMemo as useMemo4 } from "react";
|
|
744
|
-
import { Type } from "@dxos/echo";
|
|
745
|
-
import { live } from "@dxos/live-object";
|
|
746
|
-
import { useClient } from "@dxos/react-client";
|
|
747
|
-
import { getSpace as getSpace2 } from "@dxos/react-client/echo";
|
|
748
|
-
import { Popover as Popover3 } from "@dxos/react-ui";
|
|
749
|
-
import { Form as Form2 } from "@dxos/react-ui-form";
|
|
750
|
-
import { useGridContext as useGridContext4 } from "@dxos/react-ui-grid";
|
|
751
|
-
var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
752
|
-
var _effect = _useSignals6();
|
|
753
|
-
try {
|
|
754
|
-
const { id: gridId } = useGridContext4("TableCellEditor", __gridScope);
|
|
755
|
-
const client = useClient();
|
|
756
|
-
const space = model && getSpace2(model?.view);
|
|
757
|
-
const state = modals.state.value;
|
|
758
|
-
const getSchema = useCallback4(() => {
|
|
759
|
-
if (!space || state?.type !== "createRefPanel") {
|
|
760
|
-
return;
|
|
761
|
-
}
|
|
762
|
-
const staticSchema = client.graph.schemaRegistry.schemas.find((schema3) => Type.getTypename(schema3) === state.typename);
|
|
763
|
-
if (staticSchema) {
|
|
764
|
-
return staticSchema;
|
|
765
|
-
}
|
|
766
|
-
const [schema2] = space.db.schemaRegistry.query({
|
|
767
|
-
typename: state.typename
|
|
768
|
-
}).runSync();
|
|
769
|
-
return schema2;
|
|
770
|
-
}, [
|
|
771
|
-
space,
|
|
772
|
-
state
|
|
773
|
-
]);
|
|
774
|
-
const schema = useMemo4(() => {
|
|
775
|
-
const schema2 = getSchema();
|
|
776
|
-
if (!schema2) {
|
|
777
|
-
return;
|
|
778
|
-
}
|
|
779
|
-
const omit = Schema.omit("id");
|
|
780
|
-
return omit(schema2);
|
|
781
|
-
}, [
|
|
782
|
-
getSchema
|
|
783
|
-
]);
|
|
784
|
-
const handleSave = useCallback4((values) => {
|
|
785
|
-
if (!model || !space || state?.type !== "createRefPanel") {
|
|
786
|
-
return;
|
|
787
|
-
}
|
|
788
|
-
const schema2 = getSchema();
|
|
789
|
-
if (schema2) {
|
|
790
|
-
const obj = space.db.add(live(schema2, values));
|
|
791
|
-
state.onCreate?.(obj);
|
|
792
|
-
}
|
|
793
|
-
void modals.close();
|
|
794
|
-
}, [
|
|
795
|
-
model,
|
|
796
|
-
modals,
|
|
797
|
-
space,
|
|
798
|
-
state
|
|
799
|
-
]);
|
|
800
|
-
const handleCancel = useCallback4(() => {
|
|
801
|
-
if (model) {
|
|
802
|
-
modals.close();
|
|
803
|
-
}
|
|
804
|
-
}, [
|
|
805
|
-
modals
|
|
806
|
-
]);
|
|
807
|
-
if (!model?.projection) {
|
|
808
|
-
return null;
|
|
809
|
-
}
|
|
810
|
-
return /* @__PURE__ */ React6.createElement(Popover3.Root, {
|
|
811
|
-
modal: false,
|
|
812
|
-
open: state?.type === "createRefPanel" && !!schema,
|
|
813
|
-
onOpenChange: (nextOpen) => {
|
|
814
|
-
if (model && !nextOpen) {
|
|
815
|
-
return modals.close();
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
}, /* @__PURE__ */ React6.createElement(Popover3.VirtualTrigger, {
|
|
819
|
-
virtualRef: modals.trigger
|
|
820
|
-
}), /* @__PURE__ */ React6.createElement(Popover3.Portal, null, /* @__PURE__ */ React6.createElement(Popover3.Content, {
|
|
821
|
-
classNames: "md:is-64",
|
|
822
|
-
"data-grid": gridId
|
|
823
|
-
}, /* @__PURE__ */ React6.createElement(Popover3.Viewport, null, state?.type === "createRefPanel" && schema && /* @__PURE__ */ React6.createElement(Form2, {
|
|
824
|
-
schema,
|
|
825
|
-
values: state.initialValues ?? {},
|
|
826
|
-
onSave: handleSave,
|
|
827
|
-
onCancel: handleCancel
|
|
828
|
-
})), /* @__PURE__ */ React6.createElement(Popover3.Arrow, null))));
|
|
829
|
-
} finally {
|
|
830
|
-
_effect.f();
|
|
831
|
-
}
|
|
832
|
-
};
|
|
833
|
-
|
|
834
683
|
// src/components/Table/RowActionsMenu.tsx
|
|
835
|
-
import { useSignals as
|
|
836
|
-
import
|
|
684
|
+
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
685
|
+
import React6 from "react";
|
|
837
686
|
import { DropdownMenu as DropdownMenu2, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
838
687
|
var RowActionsMenu = ({ model, modals }) => {
|
|
839
|
-
var _effect =
|
|
688
|
+
var _effect = _useSignals6();
|
|
840
689
|
try {
|
|
841
690
|
const { t } = useTranslation2(translationKey);
|
|
842
691
|
const hasSelection = model.selection.hasSelection.value;
|
|
@@ -844,23 +693,23 @@ var RowActionsMenu = ({ model, modals }) => {
|
|
|
844
693
|
if (state?.type !== "row") {
|
|
845
694
|
return null;
|
|
846
695
|
}
|
|
847
|
-
return /* @__PURE__ */
|
|
696
|
+
return /* @__PURE__ */ React6.createElement(DropdownMenu2.Root, {
|
|
848
697
|
modal: false,
|
|
849
698
|
open: true,
|
|
850
699
|
onOpenChange: modals.close
|
|
851
|
-
}, /* @__PURE__ */
|
|
700
|
+
}, /* @__PURE__ */ React6.createElement(DropdownMenu2.VirtualTrigger, {
|
|
852
701
|
virtualRef: modals.trigger
|
|
853
|
-
}), /* @__PURE__ */
|
|
702
|
+
}), /* @__PURE__ */ React6.createElement(DropdownMenu2.Content, null, /* @__PURE__ */ React6.createElement(DropdownMenu2.Viewport, null, model.features.dataEditable !== false && /* @__PURE__ */ React6.createElement(DropdownMenu2.Item, {
|
|
854
703
|
"data-testid": "row-menu-delete",
|
|
855
704
|
onClick: () => model.deleteRow(state.rowIndex)
|
|
856
|
-
}, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */
|
|
705
|
+
}, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */ React6.createElement(DropdownMenu2.Item, {
|
|
857
706
|
key: action.id,
|
|
858
707
|
"data-testid": `row-action-${action.id}`,
|
|
859
708
|
onClick: () => {
|
|
860
709
|
modals.close();
|
|
861
710
|
model.handleRowAction(action.id, state.rowIndex);
|
|
862
711
|
}
|
|
863
|
-
}, toLocalizedString(action.label, t)))), /* @__PURE__ */
|
|
712
|
+
}, toLocalizedString(action.label, t)))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Arrow, null)));
|
|
864
713
|
} finally {
|
|
865
714
|
_effect.f();
|
|
866
715
|
}
|
|
@@ -880,9 +729,9 @@ var rowDefault = {
|
|
|
880
729
|
}
|
|
881
730
|
};
|
|
882
731
|
var TableRoot = ({ children, role = "article" }) => {
|
|
883
|
-
var _effect =
|
|
732
|
+
var _effect = _useSignals7();
|
|
884
733
|
try {
|
|
885
|
-
return /* @__PURE__ */
|
|
734
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
886
735
|
role: "none",
|
|
887
736
|
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]", [
|
|
888
737
|
"card--popover",
|
|
@@ -897,20 +746,20 @@ var TableRoot = ({ children, role = "article" }) => {
|
|
|
897
746
|
_effect.f();
|
|
898
747
|
}
|
|
899
748
|
};
|
|
900
|
-
var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttention, schema, client, onRowClick }, forwardedRef) => {
|
|
901
|
-
var _effect =
|
|
749
|
+
var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttention, schema, client, onCreate, onRowClick, testId }, forwardedRef) => {
|
|
750
|
+
var _effect = _useSignals7();
|
|
902
751
|
try {
|
|
903
752
|
const [dxGrid, setDxGrid] = useState4(null);
|
|
904
753
|
const { hasAttention } = useAttention(model?.id ?? "table");
|
|
905
|
-
const modals =
|
|
754
|
+
const modals = useMemo4(() => new ModalController(), []);
|
|
906
755
|
const draftRowCount = model?.getDraftRowCount() ?? 0;
|
|
907
|
-
const handleSave =
|
|
756
|
+
const handleSave = useCallback4(() => {
|
|
908
757
|
dxGrid?.updateCells(true);
|
|
909
758
|
dxGrid?.requestUpdate();
|
|
910
759
|
}, [
|
|
911
760
|
dxGrid
|
|
912
761
|
]);
|
|
913
|
-
const frozen =
|
|
762
|
+
const frozen = useMemo4(() => {
|
|
914
763
|
const noActionColumn = model?.features.dataEditable === false && model?.features.schemaEditable === false && model.rowActions.length === 0;
|
|
915
764
|
return {
|
|
916
765
|
frozenRowsStart: 1,
|
|
@@ -922,7 +771,7 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
922
771
|
model,
|
|
923
772
|
draftRowCount
|
|
924
773
|
]);
|
|
925
|
-
const getCells =
|
|
774
|
+
const getCells = useCallback4((range, plane) => presentation?.getCells(range, plane) ?? {}, [
|
|
926
775
|
presentation
|
|
927
776
|
]);
|
|
928
777
|
useEffect3(() => {
|
|
@@ -935,7 +784,7 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
935
784
|
dxGrid,
|
|
936
785
|
getCells
|
|
937
786
|
]);
|
|
938
|
-
const handleInsertRowResult =
|
|
787
|
+
const handleInsertRowResult = useCallback4((insertResult) => {
|
|
939
788
|
if (insertResult === "draft") {
|
|
940
789
|
requestAnimationFrame(() => {
|
|
941
790
|
dxGrid?.setFocus({
|
|
@@ -979,7 +828,7 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
979
828
|
dxGrid,
|
|
980
829
|
model
|
|
981
830
|
]);
|
|
982
|
-
const handleSaveDraftRow =
|
|
831
|
+
const handleSaveDraftRow = useCallback4((rowIndex = 0) => {
|
|
983
832
|
if (model && dxGrid) {
|
|
984
833
|
const didCommitSuccessfully = model.commitDraftRow(rowIndex);
|
|
985
834
|
if (didCommitSuccessfully) {
|
|
@@ -992,7 +841,7 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
992
841
|
model,
|
|
993
842
|
dxGrid
|
|
994
843
|
]);
|
|
995
|
-
const handleGridClick =
|
|
844
|
+
const handleGridClick = useCallback4((event) => {
|
|
996
845
|
const cell = closestCell(event.target);
|
|
997
846
|
if (cell) {
|
|
998
847
|
const { row: rowIndex, plane } = cell;
|
|
@@ -1077,9 +926,9 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
1077
926
|
modals,
|
|
1078
927
|
dxGrid
|
|
1079
928
|
]);
|
|
1080
|
-
const handleFocus =
|
|
929
|
+
const handleFocus = useCallback4((increment, delta, cell) => {
|
|
1081
930
|
if (dxGrid && model) {
|
|
1082
|
-
if (cell?.plane === "grid" && cell?.row >= model.getRowCount() - 1) {
|
|
931
|
+
if (cell?.plane === "grid" && cell?.row >= model.getRowCount() - 1 && increment !== "col") {
|
|
1083
932
|
handleInsertRowResult(draftRowCount < 1 ? model.insertRow() : "final");
|
|
1084
933
|
} else if (cell?.plane === "frozenRowsEnd" && increment === "row") {
|
|
1085
934
|
handleSaveDraftRow(cell.row);
|
|
@@ -1092,7 +941,7 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
1092
941
|
dxGrid,
|
|
1093
942
|
model
|
|
1094
943
|
]);
|
|
1095
|
-
const handleKeyDown =
|
|
944
|
+
const handleKeyDown = useCallback4((event) => {
|
|
1096
945
|
if (!model?.features.dataEditable) {
|
|
1097
946
|
return;
|
|
1098
947
|
}
|
|
@@ -1117,7 +966,7 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
1117
966
|
event.preventDefault();
|
|
1118
967
|
void navigator.clipboard.readText().then((clipboardText) => {
|
|
1119
968
|
try {
|
|
1120
|
-
model.setCellData(cell, clipboardText);
|
|
969
|
+
model.setCellData(cell, String2.trim(clipboardText).replace(/[\n\r]+/, " "));
|
|
1121
970
|
handleSave();
|
|
1122
971
|
} catch {
|
|
1123
972
|
const cellElement = event.target.closest('[data-dx-grid-action="cell"]');
|
|
@@ -1148,6 +997,7 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
1148
997
|
try {
|
|
1149
998
|
model.setCellData(cell, void 0);
|
|
1150
999
|
event.preventDefault();
|
|
1000
|
+
handleSave();
|
|
1151
1001
|
} catch {
|
|
1152
1002
|
}
|
|
1153
1003
|
break;
|
|
@@ -1158,7 +1008,7 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
1158
1008
|
dxGrid,
|
|
1159
1009
|
handleSave
|
|
1160
1010
|
]);
|
|
1161
|
-
const handleAxisResize =
|
|
1011
|
+
const handleAxisResize = useCallback4((event) => {
|
|
1162
1012
|
if (event.axis === "col") {
|
|
1163
1013
|
const columnIndex = parseInt(event.index, 10);
|
|
1164
1014
|
model?.setColumnWidth(columnIndex, event.size);
|
|
@@ -1166,7 +1016,7 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
1166
1016
|
}, [
|
|
1167
1017
|
model
|
|
1168
1018
|
]);
|
|
1169
|
-
const handleWheel =
|
|
1019
|
+
const handleWheel = useCallback4((event) => {
|
|
1170
1020
|
if (!ignoreAttention && !hasAttention) {
|
|
1171
1021
|
event.stopPropagation();
|
|
1172
1022
|
}
|
|
@@ -1174,7 +1024,7 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
1174
1024
|
hasAttention,
|
|
1175
1025
|
ignoreAttention
|
|
1176
1026
|
]);
|
|
1177
|
-
const handleNewColumn =
|
|
1027
|
+
const handleNewColumn = useCallback4(() => {
|
|
1178
1028
|
const columns = model?.getColumnCount();
|
|
1179
1029
|
if (dxGrid && columns) {
|
|
1180
1030
|
dxGrid.scrollToColumn(columns - 1);
|
|
@@ -1184,21 +1034,22 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
1184
1034
|
dxGrid
|
|
1185
1035
|
]);
|
|
1186
1036
|
if (!model || !modals) {
|
|
1187
|
-
return /* @__PURE__ */
|
|
1037
|
+
return /* @__PURE__ */ React7.createElement("span", {
|
|
1188
1038
|
role: "none",
|
|
1189
1039
|
className: "attention-surface"
|
|
1190
1040
|
});
|
|
1191
1041
|
}
|
|
1192
|
-
return /* @__PURE__ */
|
|
1042
|
+
return /* @__PURE__ */ React7.createElement(Grid.Root, {
|
|
1193
1043
|
id: model.id ?? "table-grid"
|
|
1194
|
-
}, /* @__PURE__ */
|
|
1044
|
+
}, /* @__PURE__ */ React7.createElement(TableValueEditor, {
|
|
1195
1045
|
model,
|
|
1196
1046
|
modals,
|
|
1197
1047
|
schema,
|
|
1198
1048
|
onFocus: handleFocus,
|
|
1199
1049
|
onSave: handleSave,
|
|
1050
|
+
onCreate,
|
|
1200
1051
|
client
|
|
1201
|
-
}), /* @__PURE__ */
|
|
1052
|
+
}), /* @__PURE__ */ React7.createElement(Grid.Content, {
|
|
1202
1053
|
className: mx("[--dx-grid-base:var(--baseSurface)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
|
|
1203
1054
|
frozen,
|
|
1204
1055
|
columns: model.columnMeta.value,
|
|
@@ -1211,20 +1062,20 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
1211
1062
|
onClick: handleGridClick,
|
|
1212
1063
|
onKeyDownCapture: handleKeyDown,
|
|
1213
1064
|
onWheelCapture: handleWheel,
|
|
1065
|
+
...testId && {
|
|
1066
|
+
"data-testid": testId
|
|
1067
|
+
},
|
|
1214
1068
|
ref: setDxGrid
|
|
1215
|
-
}), /* @__PURE__ */
|
|
1069
|
+
}), /* @__PURE__ */ React7.createElement(RowActionsMenu, {
|
|
1216
1070
|
model,
|
|
1217
1071
|
modals
|
|
1218
|
-
}), /* @__PURE__ */
|
|
1072
|
+
}), /* @__PURE__ */ React7.createElement(ColumnActionsMenu, {
|
|
1219
1073
|
model,
|
|
1220
1074
|
modals
|
|
1221
|
-
}), /* @__PURE__ */
|
|
1075
|
+
}), /* @__PURE__ */ React7.createElement(ColumnSettings, {
|
|
1222
1076
|
model,
|
|
1223
1077
|
modals,
|
|
1224
1078
|
onNewColumn: handleNewColumn
|
|
1225
|
-
}), /* @__PURE__ */ React8.createElement(CreateRefPanel, {
|
|
1226
|
-
model,
|
|
1227
|
-
modals
|
|
1228
1079
|
}));
|
|
1229
1080
|
} finally {
|
|
1230
1081
|
_effect.f();
|
|
@@ -1236,14 +1087,14 @@ var Table = {
|
|
|
1236
1087
|
};
|
|
1237
1088
|
|
|
1238
1089
|
// src/components/Table/DynamicTable.tsx
|
|
1239
|
-
import { useSignals as
|
|
1240
|
-
import
|
|
1090
|
+
import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
|
|
1091
|
+
import React8, { useCallback as useCallback5, useMemo as useMemo5, useRef as useRef3 } from "react";
|
|
1241
1092
|
import { useDefaultValue } from "@dxos/react-ui";
|
|
1242
1093
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
1243
1094
|
var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, properties, jsonSchema: _jsonSchema, schema, rowActions, onRowClick, onRowAction, ...props }) => {
|
|
1244
|
-
var _effect =
|
|
1095
|
+
var _effect = _useSignals8();
|
|
1245
1096
|
try {
|
|
1246
|
-
const {
|
|
1097
|
+
const { jsonSchema } = useMemo5(() => getBaseSchema({
|
|
1247
1098
|
typename: name,
|
|
1248
1099
|
properties,
|
|
1249
1100
|
jsonSchema: _jsonSchema,
|
|
@@ -1254,20 +1105,18 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
|
|
|
1254
1105
|
_jsonSchema,
|
|
1255
1106
|
schema
|
|
1256
1107
|
]);
|
|
1257
|
-
const { projection, view } =
|
|
1258
|
-
typename,
|
|
1108
|
+
const { projection, view } = useMemo5(() => makeDynamicTable({
|
|
1259
1109
|
jsonSchema,
|
|
1260
1110
|
properties
|
|
1261
1111
|
}), [
|
|
1262
|
-
typename,
|
|
1263
1112
|
jsonSchema,
|
|
1264
1113
|
properties
|
|
1265
1114
|
]);
|
|
1266
1115
|
const tableRef = useRef3(null);
|
|
1267
|
-
const handleCellUpdate =
|
|
1116
|
+
const handleCellUpdate = useCallback5((cell) => {
|
|
1268
1117
|
tableRef.current?.update?.(cell);
|
|
1269
1118
|
}, []);
|
|
1270
|
-
const handleRowOrderChange =
|
|
1119
|
+
const handleRowOrderChange = useCallback5(() => {
|
|
1271
1120
|
tableRef.current?.update?.();
|
|
1272
1121
|
}, []);
|
|
1273
1122
|
const features = useDefaultValue(props.features, () => ({
|
|
@@ -1287,20 +1136,20 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
|
|
|
1287
1136
|
onRowOrderChange: handleRowOrderChange,
|
|
1288
1137
|
onRowAction
|
|
1289
1138
|
});
|
|
1290
|
-
const presentation =
|
|
1139
|
+
const presentation = useMemo5(() => {
|
|
1291
1140
|
if (model) {
|
|
1292
1141
|
return new TablePresentation(model);
|
|
1293
1142
|
}
|
|
1294
1143
|
}, [
|
|
1295
1144
|
model
|
|
1296
1145
|
]);
|
|
1297
|
-
return /* @__PURE__ */
|
|
1146
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
1298
1147
|
role: "none",
|
|
1299
1148
|
className: mx2("is-full bs-full grow grid", classNames)
|
|
1300
|
-
}, /* @__PURE__ */
|
|
1149
|
+
}, /* @__PURE__ */ React8.createElement("div", {
|
|
1301
1150
|
role: "none",
|
|
1302
1151
|
className: "grid min-bs-0 overflow-hidden"
|
|
1303
|
-
}, /* @__PURE__ */
|
|
1152
|
+
}, /* @__PURE__ */ React8.createElement(Table.Root, null, /* @__PURE__ */ React8.createElement(Table.Main, {
|
|
1304
1153
|
ref: tableRef,
|
|
1305
1154
|
model,
|
|
1306
1155
|
presentation,
|
|
@@ -1313,10 +1162,10 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
|
|
|
1313
1162
|
};
|
|
1314
1163
|
|
|
1315
1164
|
// src/components/TableToolbar/TableToolbar.tsx
|
|
1316
|
-
import { useSignals as
|
|
1165
|
+
import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
|
|
1317
1166
|
import { Rx } from "@effect-rx/rx-react";
|
|
1318
|
-
import
|
|
1319
|
-
import { live
|
|
1167
|
+
import React9, { useMemo as useMemo6 } from "react";
|
|
1168
|
+
import { live } from "@dxos/live-object";
|
|
1320
1169
|
import { MenuProvider, ToolbarMenu, createGapSeparator, createMenuAction, useMenuActions } from "@dxos/react-ui-menu";
|
|
1321
1170
|
import { rxFromSignal } from "@dxos/react-ui-menu";
|
|
1322
1171
|
var createTableToolbarActions = ({ state, onAdd, onSave, customActions }) => Rx.make((get) => {
|
|
@@ -1365,12 +1214,12 @@ var createTableToolbarActions = ({ state, onAdd, onSave, customActions }) => Rx.
|
|
|
1365
1214
|
};
|
|
1366
1215
|
});
|
|
1367
1216
|
var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, customActions }) => {
|
|
1368
|
-
var _effect =
|
|
1217
|
+
var _effect = _useSignals9();
|
|
1369
1218
|
try {
|
|
1370
|
-
const state =
|
|
1219
|
+
const state = useMemo6(() => live({
|
|
1371
1220
|
viewDirty
|
|
1372
1221
|
}), []);
|
|
1373
|
-
const actionsCreator =
|
|
1222
|
+
const actionsCreator = useMemo6(() => createTableToolbarActions({
|
|
1374
1223
|
state,
|
|
1375
1224
|
onAdd,
|
|
1376
1225
|
onSave,
|
|
@@ -1382,10 +1231,10 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, custom
|
|
|
1382
1231
|
customActions
|
|
1383
1232
|
]);
|
|
1384
1233
|
const menu = useMenuActions(actionsCreator);
|
|
1385
|
-
return /* @__PURE__ */
|
|
1234
|
+
return /* @__PURE__ */ React9.createElement(MenuProvider, {
|
|
1386
1235
|
...menu,
|
|
1387
1236
|
attendableId
|
|
1388
|
-
}, /* @__PURE__ */
|
|
1237
|
+
}, /* @__PURE__ */ React9.createElement(ToolbarMenu, {
|
|
1389
1238
|
classNames
|
|
1390
1239
|
}));
|
|
1391
1240
|
} finally {
|