@dxos/react-ui-table 0.8.4-main.28f8d3d → 0.8.4-main.2c6827d
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-2PFAPQL4.mjs +66 -0
- package/dist/lib/browser/chunk-2PFAPQL4.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ZAOSIG3L.mjs → chunk-GS2UNGJK.mjs} +174 -213
- package/dist/lib/browser/chunk-GS2UNGJK.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +411 -515
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +12 -9
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/types/index.mjs +3 -3
- package/dist/lib/node-esm/chunk-6POOFFYF.mjs +67 -0
- package/dist/lib/node-esm/chunk-6POOFFYF.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ZOFFI3JJ.mjs → chunk-TRR3C5NX.mjs} +174 -213
- package/dist/lib/node-esm/chunk-TRR3C5NX.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +411 -515
- 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 +12 -9
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/types/index.mjs +3 -3
- 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 +51 -3
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +103 -5
- 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 +8 -5
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +41 -3
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +12 -6
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +8 -13
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +39 -4
- 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 +2 -2
- 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 +3 -2
- package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts +3 -3
- 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 +9 -8
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts +1 -1
- package/dist/types/src/model/table-presentation.d.ts.map +1 -1
- package/dist/types/src/model/table-sorting.d.ts +2 -3
- package/dist/types/src/model/table-sorting.d.ts.map +1 -1
- package/dist/types/src/testing/useTestTableModel.d.ts +3 -22
- package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +25 -5
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +5 -6
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +0 -1
- package/dist/types/src/util/index.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/src/util/table-buttons.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +53 -51
- package/src/components/Table/DynamicTable.stories.tsx +15 -12
- package/src/components/Table/DynamicTable.tsx +4 -7
- package/src/components/Table/Relations.stories.tsx +160 -42
- package/src/components/Table/RowActionsMenu.tsx +21 -13
- package/src/components/Table/Table.stories.tsx +63 -56
- package/src/components/Table/Table.tsx +109 -90
- package/src/components/TableCellEditor/FormCellEditor.tsx +153 -42
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +24 -64
- package/src/components/TableCellEditor/TableCellEditor.tsx +62 -208
- package/src/components/TableCellEditor/index.ts +1 -0
- package/src/components/TableToolbar/TableToolbar.tsx +32 -22
- package/src/components/testing.ts +2 -2
- package/src/hooks/useAddRow.ts +7 -5
- package/src/hooks/useTableModel.ts +5 -5
- package/src/model/modal-controller.ts +0 -28
- package/src/model/table-model.test.ts +19 -11
- package/src/model/table-model.ts +36 -24
- package/src/model/table-presentation.test.ts +22 -21
- package/src/model/table-presentation.ts +58 -39
- package/src/model/table-sorting.ts +16 -7
- package/src/playwright/TableManager.ts +1 -1
- package/src/playwright/smoke.spec.ts +51 -49
- package/src/testing/useTestTableModel.ts +10 -7
- package/src/types/index.ts +1 -1
- package/src/types/schema.ts +63 -6
- package/src/util/dynamic-table.ts +15 -16
- package/src/util/index.ts +0 -1
- package/src/util/schema.ts +4 -4
- package/src/util/table-buttons.ts +3 -3
- package/dist/lib/browser/chunk-L2LSB6KV.mjs +0 -18
- package/dist/lib/browser/chunk-L2LSB6KV.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZAOSIG3L.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NXZ4CJYX.mjs +0 -20
- package/dist/lib/node-esm/chunk-NXZ4CJYX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZOFFI3JJ.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/dist/types/src/components/TableCellEditor/extension.d.ts +0 -13
- package/dist/types/src/components/TableCellEditor/extension.d.ts.map +0 -1
- package/dist/types/src/util/table.d.ts +0 -12
- package/dist/types/src/util/table.d.ts.map +0 -1
- package/src/components/Table/CreateRefPanel.tsx +0 -86
- package/src/components/TableCellEditor/extension.ts +0 -61
- package/src/util/table.ts +0 -53
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
schema_exports
|
|
4
|
+
} from "./chunk-6POOFFYF.mjs";
|
|
5
5
|
|
|
6
6
|
// src/util/dynamic-table.ts
|
|
7
|
-
import { Obj } from "@dxos/echo";
|
|
8
|
-
import { getTypename, toJsonSchema } from "@dxos/echo
|
|
9
|
-
import { ProjectionModel,
|
|
7
|
+
import { Filter, Obj, Query } from "@dxos/echo";
|
|
8
|
+
import { getTypename, toJsonSchema } from "@dxos/echo/internal";
|
|
9
|
+
import { ProjectionModel, View, getSchemaFromPropertyDefinitions } from "@dxos/schema";
|
|
10
10
|
var getBaseSchema = ({ typename, properties, jsonSchema, schema }) => {
|
|
11
11
|
if (typename && properties) {
|
|
12
12
|
const schema2 = getSchemaFromPropertyDefinitions(typename, properties);
|
|
@@ -28,12 +28,12 @@ var getBaseSchema = ({ typename, properties, jsonSchema, schema }) => {
|
|
|
28
28
|
throw new Error("invalid properties");
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
var makeDynamicTable = ({
|
|
32
|
-
const table = Obj.make(
|
|
31
|
+
var makeDynamicTable = ({ jsonSchema, properties }) => {
|
|
32
|
+
const table = Obj.make(schema_exports.Table, {
|
|
33
33
|
sizes: {}
|
|
34
34
|
});
|
|
35
|
-
const view =
|
|
36
|
-
|
|
35
|
+
const view = View.make({
|
|
36
|
+
query: Query.select(Filter.everything()),
|
|
37
37
|
jsonSchema,
|
|
38
38
|
presentation: table,
|
|
39
39
|
...properties && {
|
|
@@ -41,6 +41,7 @@ var makeDynamicTable = ({ typename, jsonSchema, properties }) => {
|
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
const projection = new ProjectionModel(jsonSchema, view.projection);
|
|
44
|
+
projection.normalizeView();
|
|
44
45
|
if (properties && projection.fields) {
|
|
45
46
|
setProperties(view, projection, table, properties);
|
|
46
47
|
}
|
|
@@ -68,7 +69,7 @@ var setProperties = (view, projection, table, properties) => {
|
|
|
68
69
|
}
|
|
69
70
|
if (property.sort) {
|
|
70
71
|
const fieldId = field.id;
|
|
71
|
-
view.
|
|
72
|
+
view.sort = [
|
|
72
73
|
{
|
|
73
74
|
fieldId,
|
|
74
75
|
direction: property.sort
|
|
@@ -82,41 +83,6 @@ var setProperties = (view, projection, table, properties) => {
|
|
|
82
83
|
// src/util/signals.ts
|
|
83
84
|
var touch = (value) => value;
|
|
84
85
|
|
|
85
|
-
// src/util/table.ts
|
|
86
|
-
import { Match } from "effect";
|
|
87
|
-
import { Obj as Obj2 } from "@dxos/echo";
|
|
88
|
-
import { toEffectSchema } from "@dxos/echo-schema";
|
|
89
|
-
import { createViewFromSpace, getSchemaProperties } from "@dxos/schema";
|
|
90
|
-
var createTable = async ({ sizes, ...props }) => {
|
|
91
|
-
const table = Obj2.make(TableView, {
|
|
92
|
-
sizes: {}
|
|
93
|
-
});
|
|
94
|
-
const { jsonSchema, view } = await createViewFromSpace({
|
|
95
|
-
...props,
|
|
96
|
-
presentation: table
|
|
97
|
-
});
|
|
98
|
-
const schema = toEffectSchema(jsonSchema);
|
|
99
|
-
const shouldIncludeId = props.fields?.find((field) => field === "id") !== void 0;
|
|
100
|
-
const properties = getSchemaProperties(schema.ast, {}, shouldIncludeId);
|
|
101
|
-
for (const property of properties) {
|
|
102
|
-
if (sizes?.[property.name]) {
|
|
103
|
-
table.sizes[property.name] = sizes[property.name];
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
Match.type().pipe(Match.when("boolean", () => {
|
|
107
|
-
table.sizes[property.name] = 100;
|
|
108
|
-
}), Match.when("number", () => {
|
|
109
|
-
table.sizes[property.name] = 100;
|
|
110
|
-
}), Match.orElse(() => {
|
|
111
|
-
}))(property.type);
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
jsonSchema,
|
|
115
|
-
schema,
|
|
116
|
-
view
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
|
|
120
86
|
// src/util/table-buttons.ts
|
|
121
87
|
var BUTTON_IDENTIFIERS = {
|
|
122
88
|
columnSettings: "data-table-column-settings-button",
|
|
@@ -126,10 +92,9 @@ var BUTTON_IDENTIFIERS = {
|
|
|
126
92
|
saveDraftRow: "data-table-save-draft-row-button",
|
|
127
93
|
sort: "data-table-sort-button"
|
|
128
94
|
};
|
|
129
|
-
var createButton = ({ attr, data, disabled = false, icon, testId, type = "primary" }) => {
|
|
95
|
+
var createButton = ({ attr, data, disabled = false, icon, testId, type: _type = "primary" }) => {
|
|
130
96
|
const dataAttrs = Object.entries(data).map(([k, v]) => `${k}="${v}"`).join(" ");
|
|
131
|
-
|
|
132
|
-
return `<button ${attr} data-testid="${testId}" class="dx-button is-6 pli-0.5 min-bs-0 absolute inset-block-1 ${positionClass}" ${dataAttrs} ${disabled ? "disabled" : ""} data-dx-grid-action="accessory"><svg data-size="4"><use href="/icons.svg#${icon}"/></svg></button>`;
|
|
97
|
+
return `<button ${attr} data-testid="${testId}" class="dx-button is-6 aspect-square pli-0.5 min-bs-0" ${dataAttrs} ${disabled ? "disabled" : ""} data-dx-grid-action="accessory"><svg data-size="4"><use href="/icons.svg#${icon}"/></svg></button>`;
|
|
133
98
|
};
|
|
134
99
|
var addColumnButton = {
|
|
135
100
|
attr: BUTTON_IDENTIFIERS.newColumn,
|
|
@@ -155,7 +120,8 @@ var columnSettingsButton = {
|
|
|
155
120
|
attr: BUTTON_IDENTIFIERS.columnSettings,
|
|
156
121
|
icon: columnSettingsButton.icon,
|
|
157
122
|
data: {
|
|
158
|
-
"data-field-id": fieldId
|
|
123
|
+
"data-field-id": fieldId,
|
|
124
|
+
"data-variant": "ghost"
|
|
159
125
|
},
|
|
160
126
|
testId: "table-column-settings-button"
|
|
161
127
|
});
|
|
@@ -291,14 +257,14 @@ var tableControls = {
|
|
|
291
257
|
};
|
|
292
258
|
|
|
293
259
|
// src/util/schema.ts
|
|
294
|
-
import
|
|
295
|
-
import
|
|
260
|
+
import * as Schema from "effect/Schema";
|
|
261
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
296
262
|
var narrowSchema = (schema, paths) => {
|
|
297
263
|
const ast = schema?.ast;
|
|
298
|
-
if (isTypeLiteral(ast)) {
|
|
264
|
+
if (SchemaAST.isTypeLiteral(ast)) {
|
|
299
265
|
const propertySignatures = ast.propertySignatures.filter((signature) => paths.includes(signature.name.toString()));
|
|
300
266
|
if (propertySignatures.length > 0) {
|
|
301
|
-
const narrowType = new TypeLiteral(propertySignatures, []);
|
|
267
|
+
const narrowType = new SchemaAST.TypeLiteral(propertySignatures, []);
|
|
302
268
|
return Schema.make(narrowType);
|
|
303
269
|
}
|
|
304
270
|
}
|
|
@@ -308,12 +274,11 @@ var narrowSchema = (schema, paths) => {
|
|
|
308
274
|
// src/model/table-model.ts
|
|
309
275
|
import { computed as computed3, effect as effect2, signal as signal3 } from "@preact/signals-core";
|
|
310
276
|
import { Resource as Resource2 } from "@dxos/context";
|
|
311
|
-
import { Obj as
|
|
312
|
-
import { FormatEnum as FormatEnum2, getSchema,
|
|
277
|
+
import { Obj as Obj2, Ref } from "@dxos/echo";
|
|
278
|
+
import { FormatEnum as FormatEnum2, getSchema, getValue as getValue2, setValue, toEffectSchema } from "@dxos/echo/internal";
|
|
313
279
|
import { invariant } from "@dxos/invariant";
|
|
314
280
|
import { ObjectId } from "@dxos/keys";
|
|
315
|
-
import { isLiveObject } from "@dxos/live-object";
|
|
316
|
-
import { fullyQualifiedId } from "@dxos/react-client/echo";
|
|
281
|
+
import { getSnapshot, isLiveObject } from "@dxos/live-object";
|
|
317
282
|
import { formatForEditing, parseValue } from "@dxos/react-ui-form";
|
|
318
283
|
import { ProjectionModel as ProjectionModel2, validateSchema } from "@dxos/schema";
|
|
319
284
|
|
|
@@ -342,57 +307,26 @@ var SelectionModel = class extends Resource {
|
|
|
342
307
|
_initialSelection;
|
|
343
308
|
_onSelectionChanged;
|
|
344
309
|
_selection;
|
|
345
|
-
_validSelectedIds
|
|
346
|
-
|
|
347
|
-
|
|
310
|
+
_validSelectedIds = computed(() => {
|
|
311
|
+
const rows = this._rows.value;
|
|
312
|
+
if (!rows) {
|
|
313
|
+
return /* @__PURE__ */ new Set();
|
|
314
|
+
}
|
|
315
|
+
const validIds = new Set(rows.map((row) => row.id));
|
|
316
|
+
return new Set([
|
|
317
|
+
...this._selection.value
|
|
318
|
+
].filter((id) => validIds.has(id)));
|
|
319
|
+
});
|
|
320
|
+
_hasSelection = computed(() => this._validSelectedIds.value.size > 0);
|
|
321
|
+
_allSelected = computed(() => {
|
|
322
|
+
const rows = this._rows.value;
|
|
323
|
+
if (rows.length === 0) {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
return rows.every((row) => this._selection.value.has(row.id));
|
|
327
|
+
});
|
|
348
328
|
constructor(_rows, _selectionMode, _initialSelection, _onSelectionChanged) {
|
|
349
|
-
super(), this._rows = _rows, this._selectionMode = _selectionMode, this._initialSelection = _initialSelection, this._onSelectionChanged = _onSelectionChanged
|
|
350
|
-
const rows = this._rows.value;
|
|
351
|
-
if (!rows) {
|
|
352
|
-
return /* @__PURE__ */ new Set();
|
|
353
|
-
}
|
|
354
|
-
const validIds = new Set(rows.map((row) => row.id));
|
|
355
|
-
return new Set([
|
|
356
|
-
...this._selection.value
|
|
357
|
-
].filter((id) => validIds.has(id)));
|
|
358
|
-
}), this._hasSelection = computed(() => this._validSelectedIds.value.size > 0), this._allSelected = computed(() => {
|
|
359
|
-
const rows = this._rows.value;
|
|
360
|
-
if (rows.length === 0) {
|
|
361
|
-
return false;
|
|
362
|
-
}
|
|
363
|
-
return rows.every((row) => this._selection.value.has(row.id));
|
|
364
|
-
}), this.getSelectedRows = () => {
|
|
365
|
-
const selectedIds = this._validSelectedIds.value;
|
|
366
|
-
return this._rows.value.filter((row) => selectedIds.has(row.id));
|
|
367
|
-
}, this.isRowIndexSelected = (rowIndex) => {
|
|
368
|
-
const row = this._rows.value[rowIndex];
|
|
369
|
-
return this._selection.value.has(row.id);
|
|
370
|
-
}, this.isObjectSelected = (object) => {
|
|
371
|
-
return this._selection.value.has(object.id);
|
|
372
|
-
}, this.toggleSelectionForRowIndex = (rowIndex) => {
|
|
373
|
-
const row = this._rows.value[rowIndex];
|
|
374
|
-
const newSelection = new Set(this._selection.value);
|
|
375
|
-
if (newSelection.has(row.id)) {
|
|
376
|
-
newSelection.delete(row.id);
|
|
377
|
-
} else {
|
|
378
|
-
if (this._selectionMode === "single") {
|
|
379
|
-
newSelection.clear();
|
|
380
|
-
}
|
|
381
|
-
newSelection.add(row.id);
|
|
382
|
-
}
|
|
383
|
-
this._selection.value = newSelection;
|
|
384
|
-
}, this.setSelection = (mode) => {
|
|
385
|
-
switch (mode) {
|
|
386
|
-
case "all": {
|
|
387
|
-
this._selection.value = new Set(this._rows.value.map((row) => row.id));
|
|
388
|
-
break;
|
|
389
|
-
}
|
|
390
|
-
case "none": {
|
|
391
|
-
this._selection.value = /* @__PURE__ */ new Set();
|
|
392
|
-
break;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
};
|
|
329
|
+
super(), this._rows = _rows, this._selectionMode = _selectionMode, this._initialSelection = _initialSelection, this._onSelectionChanged = _onSelectionChanged;
|
|
396
330
|
this._selection = signal(new Set(this._initialSelection));
|
|
397
331
|
}
|
|
398
332
|
async _open() {
|
|
@@ -417,38 +351,67 @@ var SelectionModel = class extends Resource {
|
|
|
417
351
|
get selectionMode() {
|
|
418
352
|
return this._selectionMode;
|
|
419
353
|
}
|
|
420
|
-
getSelectedRows
|
|
421
|
-
|
|
422
|
-
|
|
354
|
+
getSelectedRows = () => {
|
|
355
|
+
const selectedIds = this._validSelectedIds.value;
|
|
356
|
+
return this._rows.value.filter((row) => selectedIds.has(row.id));
|
|
357
|
+
};
|
|
358
|
+
isRowIndexSelected = (rowIndex) => {
|
|
359
|
+
const row = this._rows.value[rowIndex];
|
|
360
|
+
return this._selection.value.has(row.id);
|
|
361
|
+
};
|
|
362
|
+
isObjectSelected = (object) => {
|
|
363
|
+
return this._selection.value.has(object.id);
|
|
364
|
+
};
|
|
423
365
|
//
|
|
424
366
|
// Manipulation
|
|
425
367
|
//
|
|
426
|
-
toggleSelectionForRowIndex
|
|
427
|
-
|
|
368
|
+
toggleSelectionForRowIndex = (rowIndex) => {
|
|
369
|
+
const row = this._rows.value[rowIndex];
|
|
370
|
+
const newSelection = new Set(this._selection.value);
|
|
371
|
+
if (newSelection.has(row.id)) {
|
|
372
|
+
newSelection.delete(row.id);
|
|
373
|
+
} else {
|
|
374
|
+
if (this._selectionMode === "single") {
|
|
375
|
+
newSelection.clear();
|
|
376
|
+
}
|
|
377
|
+
newSelection.add(row.id);
|
|
378
|
+
}
|
|
379
|
+
this._selection.value = newSelection;
|
|
380
|
+
};
|
|
381
|
+
setSelection = (mode) => {
|
|
382
|
+
switch (mode) {
|
|
383
|
+
case "all": {
|
|
384
|
+
this._selection.value = new Set(this._rows.value.map((row) => row.id));
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
case "none": {
|
|
388
|
+
this._selection.value = /* @__PURE__ */ new Set();
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
};
|
|
428
393
|
};
|
|
429
394
|
|
|
430
395
|
// src/model/table-sorting.ts
|
|
431
396
|
import { computed as computed2, signal as signal2 } from "@preact/signals-core";
|
|
432
397
|
import orderBy from "lodash.orderby";
|
|
433
|
-
import { FormatEnum, TypeEnum, getValue } from "@dxos/echo
|
|
398
|
+
import { FormatEnum, TypeEnum, getValue } from "@dxos/echo/internal";
|
|
434
399
|
import { formatForDisplay } from "@dxos/react-ui-form";
|
|
435
400
|
var TableSorting = class {
|
|
436
401
|
_view;
|
|
437
402
|
_projection;
|
|
438
|
-
_displayToDataIndex;
|
|
403
|
+
_displayToDataIndex = /* @__PURE__ */ new Map();
|
|
439
404
|
_rows;
|
|
440
|
-
_localSort;
|
|
405
|
+
_localSort = signal2(void 0);
|
|
441
406
|
_isDirty;
|
|
442
407
|
sortedRows;
|
|
443
408
|
constructor(rows, _view, _projection) {
|
|
444
409
|
this._view = _view;
|
|
445
410
|
this._projection = _projection;
|
|
446
|
-
this._displayToDataIndex = /* @__PURE__ */ new Map();
|
|
447
|
-
this._localSort = signal2(void 0);
|
|
448
411
|
this._rows = rows;
|
|
449
412
|
this._isDirty = computed2(() => {
|
|
450
413
|
const local = this._localSort.value;
|
|
451
|
-
const viewSort = this._view.
|
|
414
|
+
const viewSort = this._view.sort?.[0];
|
|
452
415
|
if (local?.type === "cleared") {
|
|
453
416
|
return viewSort !== void 0;
|
|
454
417
|
}
|
|
@@ -474,7 +437,7 @@ var TableSorting = class {
|
|
|
474
437
|
if (local?.type === "active") {
|
|
475
438
|
return local.sort;
|
|
476
439
|
}
|
|
477
|
-
return this._view.
|
|
440
|
+
return this._view.sort?.[0];
|
|
478
441
|
}
|
|
479
442
|
/**
|
|
480
443
|
* @reactive
|
|
@@ -518,11 +481,11 @@ var TableSorting = class {
|
|
|
518
481
|
save() {
|
|
519
482
|
if (this._localSort.value !== void 0) {
|
|
520
483
|
if (this._localSort.value.type === "active") {
|
|
521
|
-
this._view.
|
|
484
|
+
this._view.sort = [
|
|
522
485
|
this._localSort.value.sort
|
|
523
486
|
];
|
|
524
487
|
} else {
|
|
525
|
-
this._view.
|
|
488
|
+
this._view.sort = [];
|
|
526
489
|
}
|
|
527
490
|
this._localSort.value = void 0;
|
|
528
491
|
}
|
|
@@ -644,13 +607,14 @@ var TableModel = class extends Resource2 {
|
|
|
644
607
|
super();
|
|
645
608
|
this._view = view;
|
|
646
609
|
this._projection = projection ?? new ProjectionModel2(schema, view.projection);
|
|
610
|
+
this._projection.normalizeView();
|
|
647
611
|
this._features = {
|
|
648
612
|
...defaultFeatures,
|
|
649
613
|
...features
|
|
650
614
|
};
|
|
651
615
|
invariant(!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === "single"), "Single selection is not compatible with editable tables.", {
|
|
652
616
|
F: __dxlog_file,
|
|
653
|
-
L:
|
|
617
|
+
L: 148,
|
|
654
618
|
S: this,
|
|
655
619
|
A: [
|
|
656
620
|
"!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === 'single')",
|
|
@@ -673,7 +637,7 @@ var TableModel = class extends Resource2 {
|
|
|
673
637
|
this._onRowAction = onRowAction;
|
|
674
638
|
}
|
|
675
639
|
get id() {
|
|
676
|
-
return
|
|
640
|
+
return Obj2.getDXN(this._view).toString();
|
|
677
641
|
}
|
|
678
642
|
get view() {
|
|
679
643
|
return this._view;
|
|
@@ -681,7 +645,7 @@ var TableModel = class extends Resource2 {
|
|
|
681
645
|
get table() {
|
|
682
646
|
invariant(this._table, "Model not initialized", {
|
|
683
647
|
F: __dxlog_file,
|
|
684
|
-
L:
|
|
648
|
+
L: 186,
|
|
685
649
|
S: this,
|
|
686
650
|
A: [
|
|
687
651
|
"this._table",
|
|
@@ -720,7 +684,7 @@ var TableModel = class extends Resource2 {
|
|
|
720
684
|
get columnMeta() {
|
|
721
685
|
invariant(this._columnMeta, void 0, {
|
|
722
686
|
F: __dxlog_file,
|
|
723
|
-
L:
|
|
687
|
+
L: 225,
|
|
724
688
|
S: this,
|
|
725
689
|
A: [
|
|
726
690
|
"this._columnMeta",
|
|
@@ -744,12 +708,12 @@ var TableModel = class extends Resource2 {
|
|
|
744
708
|
//
|
|
745
709
|
async _open() {
|
|
746
710
|
const presentation = this._view.presentation.target ?? await this._view.presentation.load();
|
|
747
|
-
invariant(
|
|
711
|
+
invariant(Obj2.instanceOf(schema_exports.Table, presentation), void 0, {
|
|
748
712
|
F: __dxlog_file,
|
|
749
|
-
L:
|
|
713
|
+
L: 248,
|
|
750
714
|
S: this,
|
|
751
715
|
A: [
|
|
752
|
-
"Obj.instanceOf(
|
|
716
|
+
"Obj.instanceOf(Table.Table, presentation)",
|
|
753
717
|
""
|
|
754
718
|
]
|
|
755
719
|
});
|
|
@@ -778,7 +742,7 @@ var TableModel = class extends Resource2 {
|
|
|
778
742
|
},
|
|
779
743
|
frozenColsEnd: {
|
|
780
744
|
0: {
|
|
781
|
-
size:
|
|
745
|
+
size: 32,
|
|
782
746
|
resizeable: false
|
|
783
747
|
}
|
|
784
748
|
}
|
|
@@ -846,9 +810,10 @@ var TableModel = class extends Resource2 {
|
|
|
846
810
|
getColumnCount = () => this._projection?.fields.length ?? 0;
|
|
847
811
|
insertRow = () => {
|
|
848
812
|
const result = this._onInsertRow?.();
|
|
849
|
-
if (result ===
|
|
813
|
+
if (result === "draft" && this._draftRows.value.length === 0) {
|
|
850
814
|
this.createDraftRow();
|
|
851
815
|
}
|
|
816
|
+
return result ?? "final";
|
|
852
817
|
};
|
|
853
818
|
createDraftRow() {
|
|
854
819
|
if (!this._projection) {
|
|
@@ -886,7 +851,7 @@ var TableModel = class extends Resource2 {
|
|
|
886
851
|
this._draftRows.value = newDraftRows;
|
|
887
852
|
}
|
|
888
853
|
validateDraftRowData(data) {
|
|
889
|
-
const schema =
|
|
854
|
+
const schema = toEffectSchema(this._projection.baseSchema);
|
|
890
855
|
return validateSchema(schema, data) || [];
|
|
891
856
|
}
|
|
892
857
|
commitDraftRow = (draftRowIndex) => {
|
|
@@ -897,12 +862,12 @@ var TableModel = class extends Resource2 {
|
|
|
897
862
|
if (!draftRow.valid) {
|
|
898
863
|
return false;
|
|
899
864
|
}
|
|
900
|
-
const
|
|
901
|
-
if (
|
|
865
|
+
const insertRowResult = this._onInsertRow?.(draftRow.data);
|
|
866
|
+
if (insertRowResult === "final") {
|
|
902
867
|
const newDraftRows = this._draftRows.value.filter((_, index) => index !== draftRowIndex);
|
|
903
868
|
this._draftRows.value = newDraftRows;
|
|
904
869
|
}
|
|
905
|
-
return
|
|
870
|
+
return insertRowResult === "final";
|
|
906
871
|
};
|
|
907
872
|
deleteRow = (rowIndex) => {
|
|
908
873
|
const row = this._sorting.getDataIndex(rowIndex);
|
|
@@ -1007,7 +972,7 @@ var TableModel = class extends Resource2 {
|
|
|
1007
972
|
const currentRow = this._rows.value[rowIdx];
|
|
1008
973
|
invariant(currentRow, "Invalid row index", {
|
|
1009
974
|
F: __dxlog_file,
|
|
1010
|
-
L:
|
|
975
|
+
L: 525,
|
|
1011
976
|
S: this,
|
|
1012
977
|
A: [
|
|
1013
978
|
"currentRow",
|
|
@@ -1019,7 +984,7 @@ var TableModel = class extends Resource2 {
|
|
|
1019
984
|
const schema = getSchema(currentRow);
|
|
1020
985
|
invariant(schema, void 0, {
|
|
1021
986
|
F: __dxlog_file,
|
|
1022
|
-
L:
|
|
987
|
+
L: 531,
|
|
1023
988
|
S: this,
|
|
1024
989
|
A: [
|
|
1025
990
|
"schema",
|
|
@@ -1031,7 +996,7 @@ var TableModel = class extends Resource2 {
|
|
|
1031
996
|
const error = validationResult[0];
|
|
1032
997
|
invariant(error.path === field.path, void 0, {
|
|
1033
998
|
F: __dxlog_file,
|
|
1034
|
-
L:
|
|
999
|
+
L: 536,
|
|
1035
1000
|
S: this,
|
|
1036
1001
|
A: [
|
|
1037
1002
|
"error.path === field.path",
|
|
@@ -1184,8 +1149,6 @@ var editorTextToCellValue = (props, value) => {
|
|
|
1184
1149
|
|
|
1185
1150
|
// src/model/modal-controller.ts
|
|
1186
1151
|
import { signal as signal4 } from "@preact/signals-core";
|
|
1187
|
-
import { log } from "@dxos/log";
|
|
1188
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/model/modal-controller.ts";
|
|
1189
1152
|
var ModalController = class {
|
|
1190
1153
|
_state = signal4({
|
|
1191
1154
|
type: "closed"
|
|
@@ -1243,24 +1206,6 @@ var ModalController = class {
|
|
|
1243
1206
|
});
|
|
1244
1207
|
}
|
|
1245
1208
|
};
|
|
1246
|
-
openCreateRef = (typename, anchorCell, initialValues, onCreate) => {
|
|
1247
|
-
if (anchorCell) {
|
|
1248
|
-
this._triggerRef.current = anchorCell;
|
|
1249
|
-
this._state.value = {
|
|
1250
|
-
type: "createRefPanel",
|
|
1251
|
-
typename,
|
|
1252
|
-
initialValues,
|
|
1253
|
-
onCreate
|
|
1254
|
-
};
|
|
1255
|
-
} else {
|
|
1256
|
-
log.warn("anchor cell not found while creating new ref", void 0, {
|
|
1257
|
-
F: __dxlog_file2,
|
|
1258
|
-
L: 86,
|
|
1259
|
-
S: this,
|
|
1260
|
-
C: (f, a) => f(...a)
|
|
1261
|
-
});
|
|
1262
|
-
}
|
|
1263
|
-
};
|
|
1264
1209
|
close = () => {
|
|
1265
1210
|
this._state.value = {
|
|
1266
1211
|
type: "closed"
|
|
@@ -1270,9 +1215,9 @@ var ModalController = class {
|
|
|
1270
1215
|
|
|
1271
1216
|
// src/model/table-presentation.ts
|
|
1272
1217
|
import { signal as signal5 } from "@preact/signals-core";
|
|
1273
|
-
import
|
|
1274
|
-
import { Obj as
|
|
1275
|
-
import { FormatEnum as FormatEnum3, TypeEnum as TypeEnum2, getValue as getValue3 } from "@dxos/echo
|
|
1218
|
+
import * as Predicate from "effect/Predicate";
|
|
1219
|
+
import { Obj as Obj3 } from "@dxos/echo";
|
|
1220
|
+
import { FormatEnum as FormatEnum3, TypeEnum as TypeEnum2, getValue as getValue3 } from "@dxos/echo/internal";
|
|
1276
1221
|
import { cellClassesForFieldType, formatForDisplay as formatForDisplay2 } from "@dxos/react-ui-form";
|
|
1277
1222
|
import { toPlaneCellIndex } from "@dxos/react-ui-grid";
|
|
1278
1223
|
import { mx } from "@dxos/react-ui-theme";
|
|
@@ -1280,7 +1225,7 @@ import { VIEW_FIELD_LIMIT } from "@dxos/schema";
|
|
|
1280
1225
|
var TablePresentation = class {
|
|
1281
1226
|
model;
|
|
1282
1227
|
_visibleRange;
|
|
1283
|
-
fieldProjectionCache;
|
|
1228
|
+
fieldProjectionCache = /* @__PURE__ */ new Map();
|
|
1284
1229
|
constructor(model, _visibleRange = signal5({
|
|
1285
1230
|
start: {
|
|
1286
1231
|
row: 0,
|
|
@@ -1293,7 +1238,6 @@ var TablePresentation = class {
|
|
|
1293
1238
|
})) {
|
|
1294
1239
|
this.model = model;
|
|
1295
1240
|
this._visibleRange = _visibleRange;
|
|
1296
|
-
this.fieldProjectionCache = /* @__PURE__ */ new Map();
|
|
1297
1241
|
}
|
|
1298
1242
|
getCells(range, plane) {
|
|
1299
1243
|
this.fieldProjectionCache.clear();
|
|
@@ -1322,7 +1266,7 @@ var TablePresentation = class {
|
|
|
1322
1266
|
cells = this.getDraftRowCells(range);
|
|
1323
1267
|
break;
|
|
1324
1268
|
case "fixedEndStart":
|
|
1325
|
-
cells = this.
|
|
1269
|
+
cells = this.getDraftIconCells(range);
|
|
1326
1270
|
break;
|
|
1327
1271
|
case "fixedEndEnd":
|
|
1328
1272
|
cells = this.getDraftActionCells(range);
|
|
@@ -1382,10 +1326,7 @@ var TablePresentation = class {
|
|
|
1382
1326
|
}
|
|
1383
1327
|
};
|
|
1384
1328
|
const classes = [];
|
|
1385
|
-
const formatClasses = cellClassesForFieldType(
|
|
1386
|
-
type: props.type,
|
|
1387
|
-
format: props.format
|
|
1388
|
-
});
|
|
1329
|
+
const formatClasses = cellClassesForFieldType(props);
|
|
1389
1330
|
if (formatClasses) {
|
|
1390
1331
|
classes.push(formatClasses);
|
|
1391
1332
|
}
|
|
@@ -1393,9 +1334,7 @@ var TablePresentation = class {
|
|
|
1393
1334
|
if (rowSelectionClasses) {
|
|
1394
1335
|
classes.push(rowSelectionClasses);
|
|
1395
1336
|
}
|
|
1396
|
-
|
|
1397
|
-
cell.className = mx(classes.flat());
|
|
1398
|
-
}
|
|
1337
|
+
cell.className = mx(classes);
|
|
1399
1338
|
if (props.type === TypeEnum2.Array) {
|
|
1400
1339
|
const targetArray = getValue3(obj, field.path);
|
|
1401
1340
|
if (targetArray && Array.isArray(targetArray)) {
|
|
@@ -1417,7 +1356,7 @@ var TablePresentation = class {
|
|
|
1417
1356
|
}
|
|
1418
1357
|
return "Object";
|
|
1419
1358
|
};
|
|
1420
|
-
const tags = targetArray.map(getLabel).filter(isNotNullable).map((title) => {
|
|
1359
|
+
const tags = targetArray.map(getLabel).filter(Predicate.isNotNullable).map((title) => {
|
|
1421
1360
|
return `<span class="dx-tag" data-hue="neutral">${title}</span>`;
|
|
1422
1361
|
}).join("");
|
|
1423
1362
|
cell.accessoryHtml = `<div role='none' class="flex flex-row gap-1 overflow-x-auto">${tags}</div>`;
|
|
@@ -1426,8 +1365,8 @@ var TablePresentation = class {
|
|
|
1426
1365
|
if (props.format === FormatEnum3.Ref && props.referenceSchema) {
|
|
1427
1366
|
const targetObj = getValue3(obj, field.path)?.target;
|
|
1428
1367
|
if (targetObj) {
|
|
1429
|
-
const dxn =
|
|
1430
|
-
cell.accessoryHtml = `<dx-
|
|
1368
|
+
const dxn = Obj3.getDXN(targetObj)?.toString();
|
|
1369
|
+
cell.accessoryHtml = `<div role="none" class="absolute inline-end-0 inset-block-0 p-[--dx-grid-cell-content-padding-block]"><dx-anchor refId=${dxn} class="dx-button is-6 aspect-square min-bs-0" data-dx-grid-action="accessory"><dx-icon icon="ph--link-simple--regular"/></dx-anchor></div>`;
|
|
1431
1370
|
}
|
|
1432
1371
|
}
|
|
1433
1372
|
if (props.format === FormatEnum3.Boolean) {
|
|
@@ -1489,27 +1428,39 @@ var TablePresentation = class {
|
|
|
1489
1428
|
const cells = {};
|
|
1490
1429
|
const fields = this.model.projection?.fields ?? [];
|
|
1491
1430
|
const draftRows = this.model.draftRows.value;
|
|
1492
|
-
|
|
1493
|
-
const draftRow = draftRows[row];
|
|
1431
|
+
if (draftRows.length === 0) {
|
|
1494
1432
|
for (let col = range.start.col; col <= range.end.col && col < fields.length; col++) {
|
|
1495
|
-
|
|
1433
|
+
cells[toPlaneCellIndex({
|
|
1496
1434
|
col,
|
|
1497
|
-
row
|
|
1498
|
-
})
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1435
|
+
row: 0
|
|
1436
|
+
})] = {
|
|
1437
|
+
value: "",
|
|
1438
|
+
readonly: true,
|
|
1439
|
+
className: "dx-grid__row--cta__cell"
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1442
|
+
} else {
|
|
1443
|
+
for (let row = range.start.row; row <= range.end.row && row < draftRows.length; row++) {
|
|
1444
|
+
const draftRow = draftRows[row];
|
|
1445
|
+
for (let col = range.start.col; col <= range.end.col && col < fields.length; col++) {
|
|
1446
|
+
const cellIndex = toPlaneCellIndex({
|
|
1447
|
+
col,
|
|
1448
|
+
row
|
|
1449
|
+
});
|
|
1450
|
+
const field = fields[col];
|
|
1451
|
+
if (!field) {
|
|
1452
|
+
continue;
|
|
1453
|
+
}
|
|
1454
|
+
this.createDataCell(cells, draftRow.data, field, col, row);
|
|
1455
|
+
if (this.model.hasDraftRowValidationError(row, field.path)) {
|
|
1456
|
+
const cellValue = cells[cellIndex];
|
|
1457
|
+
if (cellValue) {
|
|
1458
|
+
const existingClasses = cellValue.className || "";
|
|
1459
|
+
const draftClasses = "dx-grid__cell--flagged";
|
|
1460
|
+
cellValue.className = existingClasses ? `${existingClasses} ${draftClasses}` : draftClasses;
|
|
1461
|
+
}
|
|
1510
1462
|
}
|
|
1511
1463
|
}
|
|
1512
|
-
cells[cellIndex].className += " !bg-toolbarSurface";
|
|
1513
1464
|
}
|
|
1514
1465
|
}
|
|
1515
1466
|
return cells;
|
|
@@ -1526,10 +1477,10 @@ var TablePresentation = class {
|
|
|
1526
1477
|
row: 0
|
|
1527
1478
|
})] = {
|
|
1528
1479
|
// TODO(burdon): Use same logic as form for fallback title.
|
|
1529
|
-
value:
|
|
1530
|
-
readonly: true,
|
|
1480
|
+
value: "",
|
|
1531
1481
|
resizeHandle: "col",
|
|
1532
1482
|
accessoryHtml: `
|
|
1483
|
+
<span class="grow min-is-0 truncate">${props.title ?? field.path}</span>
|
|
1533
1484
|
${direction !== void 0 ? tableButtons.sort.render({
|
|
1534
1485
|
fieldId: field.id,
|
|
1535
1486
|
direction
|
|
@@ -1538,7 +1489,7 @@ var TablePresentation = class {
|
|
|
1538
1489
|
fieldId: field.id
|
|
1539
1490
|
})}
|
|
1540
1491
|
`,
|
|
1541
|
-
className: "!bg-toolbarSurface"
|
|
1492
|
+
className: "!bg-toolbarSurface !text-description [&>div]:flex [&>div]:items-stretch"
|
|
1542
1493
|
};
|
|
1543
1494
|
}
|
|
1544
1495
|
return cells;
|
|
@@ -1629,35 +1580,46 @@ var TablePresentation = class {
|
|
|
1629
1580
|
getDraftActionCells(range) {
|
|
1630
1581
|
const cells = {};
|
|
1631
1582
|
const draftRows = this.model.draftRows.value;
|
|
1632
|
-
|
|
1633
|
-
const draftRow = draftRows[row];
|
|
1634
|
-
const disabled = !draftRow.valid;
|
|
1583
|
+
if (draftRows.length === 0) {
|
|
1635
1584
|
cells[toPlaneCellIndex({
|
|
1636
1585
|
col: 0,
|
|
1637
|
-
row
|
|
1586
|
+
row: 0
|
|
1638
1587
|
})] = {
|
|
1639
1588
|
value: "",
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
rowIndex: row,
|
|
1643
|
-
disabled
|
|
1644
|
-
}),
|
|
1645
|
-
className: "!bg-toolbarSurface"
|
|
1589
|
+
className: "dx-grid__row--cta__cell",
|
|
1590
|
+
readonly: true
|
|
1646
1591
|
};
|
|
1592
|
+
} else {
|
|
1593
|
+
for (let row = range.start.row; row <= range.end.row && row < draftRows.length; row++) {
|
|
1594
|
+
const draftRow = draftRows[row];
|
|
1595
|
+
const disabled = !draftRow.valid;
|
|
1596
|
+
cells[toPlaneCellIndex({
|
|
1597
|
+
col: 0,
|
|
1598
|
+
row
|
|
1599
|
+
})] = {
|
|
1600
|
+
value: "",
|
|
1601
|
+
readonly: true,
|
|
1602
|
+
accessoryHtml: tableButtons.saveDraftRow.render({
|
|
1603
|
+
rowIndex: row,
|
|
1604
|
+
disabled
|
|
1605
|
+
})
|
|
1606
|
+
};
|
|
1607
|
+
}
|
|
1647
1608
|
}
|
|
1648
1609
|
return cells;
|
|
1649
1610
|
}
|
|
1650
|
-
|
|
1611
|
+
getDraftIconCells(range) {
|
|
1651
1612
|
const cells = {};
|
|
1652
1613
|
const draftRows = this.model.draftRows.value;
|
|
1653
|
-
for (let row = range.start.row; row <= range.end.row
|
|
1614
|
+
for (let row = range.start.row; row <= range.end.row; row++) {
|
|
1654
1615
|
cells[toPlaneCellIndex({
|
|
1655
1616
|
col: 0,
|
|
1656
1617
|
row
|
|
1657
1618
|
})] = {
|
|
1658
1619
|
value: "",
|
|
1659
1620
|
readonly: true,
|
|
1660
|
-
|
|
1621
|
+
accessoryHtml: '<dx-icon icon="ph--plus--regular" class="contents"></dx-icon>',
|
|
1622
|
+
className: mx("[&>div]:grid [&>div]:place-content-center", draftRows.length < 1 && "dx-grid__row--cta__cell")
|
|
1661
1623
|
};
|
|
1662
1624
|
}
|
|
1663
1625
|
return cells;
|
|
@@ -1690,13 +1652,13 @@ import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
|
1690
1652
|
import { effect as effect3 } from "@preact/signals-core";
|
|
1691
1653
|
import orderBy2 from "lodash.orderby";
|
|
1692
1654
|
import { useEffect, useMemo, useState } from "react";
|
|
1693
|
-
import {
|
|
1655
|
+
import { Obj as Obj4 } from "@dxos/echo";
|
|
1694
1656
|
import { useSelected, useSelectionActions } from "@dxos/react-ui-attention";
|
|
1695
1657
|
import { isNonNullable } from "@dxos/util";
|
|
1696
1658
|
var useTableModel = ({ view, schema, projection, rows, rowActions, features, onSelectionChanged, onRowAction, ...props }) => {
|
|
1697
1659
|
var _effect = _useSignals();
|
|
1698
1660
|
try {
|
|
1699
|
-
const selected = useSelected(view &&
|
|
1661
|
+
const selected = useSelected(view && Obj4.getDXN(view).toString(), "multi");
|
|
1700
1662
|
const initialSelection = useMemo(() => selected, [
|
|
1701
1663
|
view
|
|
1702
1664
|
]);
|
|
@@ -1781,12 +1743,12 @@ var useAddRow = ({ space, schema }) => {
|
|
|
1781
1743
|
if (space && schema) {
|
|
1782
1744
|
try {
|
|
1783
1745
|
space.db.add(Obj5.make(schema, data ?? {}));
|
|
1784
|
-
return
|
|
1746
|
+
return "final";
|
|
1785
1747
|
} catch (error) {
|
|
1786
|
-
return
|
|
1748
|
+
return "draft";
|
|
1787
1749
|
}
|
|
1788
1750
|
}
|
|
1789
|
-
return
|
|
1751
|
+
return "final";
|
|
1790
1752
|
}, [
|
|
1791
1753
|
space,
|
|
1792
1754
|
schema
|
|
@@ -1797,7 +1759,6 @@ export {
|
|
|
1797
1759
|
getBaseSchema,
|
|
1798
1760
|
makeDynamicTable,
|
|
1799
1761
|
touch,
|
|
1800
|
-
createTable,
|
|
1801
1762
|
BUTTON_IDENTIFIERS,
|
|
1802
1763
|
tableButtons,
|
|
1803
1764
|
CONTROL_IDENTIFIERS,
|
|
@@ -1812,4 +1773,4 @@ export {
|
|
|
1812
1773
|
useTableModel,
|
|
1813
1774
|
useAddRow
|
|
1814
1775
|
};
|
|
1815
|
-
//# sourceMappingURL=chunk-
|
|
1776
|
+
//# sourceMappingURL=chunk-TRR3C5NX.mjs.map
|