@dxos/react-ui-table 0.8.4-main.fcfe5033a5 → 0.8.4-staging.60fe92afc8
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-F7Y374KL.mjs → chunk-4KOQTPFC.mjs} +62 -111
- package/dist/lib/browser/chunk-4KOQTPFC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BF54SSNL.mjs → chunk-62PYOJPY.mjs} +13 -16
- package/dist/lib/browser/chunk-62PYOJPY.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +57 -131
- 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 -8
- 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-7LMOZUTS.mjs} +13 -16
- package/dist/lib/node-esm/chunk-7LMOZUTS.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-CCJ4LOVM.mjs → chunk-KOSV2J5N.mjs} +62 -111
- package/dist/lib/node-esm/chunk-KOSV2J5N.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +57 -131
- 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 -8
- 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 -20
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +87 -81
- 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 +2 -2
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +88 -81
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableContent.d.ts +2 -1
- package/dist/types/src/components/Table/TableContent.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableToolbar.d.ts +1 -1
- package/dist/types/src/components/Table/TableToolbar.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +1 -2
- 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 +19 -19
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.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 +7 -7
- 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 -19
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Table.d.ts +12 -6
- 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 +53 -63
- package/src/components/Table/ColumnActionsMenu.tsx +2 -1
- package/src/components/Table/ColumnSettings.tsx +2 -2
- package/src/components/Table/DynamicTable.stories.tsx +9 -8
- package/src/components/Table/DynamicTable.tsx +11 -12
- package/src/components/Table/Relations.stories.tsx +46 -9
- package/src/components/Table/RowActionsMenu.tsx +3 -2
- package/src/components/Table/Table.stories.tsx +86 -33
- package/src/components/Table/TableContent.tsx +9 -4
- package/src/components/Table/TableToolbar.tsx +2 -2
- package/src/components/TableCellEditor/CellValidationMessage.tsx +1 -2
- package/src/components/TableCellEditor/FormCellEditor.tsx +8 -7
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +7 -4
- package/src/components/TableCellEditor/TableCellEditor.tsx +8 -6
- package/src/components/testing.ts +7 -12
- 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 -9
- package/src/model/table-model.ts +43 -36
- package/src/model/table-presentation.test.ts +4 -9
- package/src/model/table-presentation.ts +15 -15
- package/src/testing/useTestTableModel.ts +6 -7
- package/src/types/Table.ts +16 -15
- package/src/util/dynamic-table.test.ts +13 -20
- package/src/util/dynamic-table.ts +19 -18
- package/dist/lib/browser/chunk-BF54SSNL.mjs.map +0 -7
- package/dist/lib/browser/chunk-F7Y374KL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CCJ4LOVM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SIRDIPHZ.mjs.map +0 -7
package/LICENSE
CHANGED
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright (c) 2022 DXOS
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Abbreviation
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 DXOS
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
|
@@ -237,12 +237,12 @@ var tableControls = {
|
|
|
237
237
|
// src/model/table-model.ts
|
|
238
238
|
import { Atom as Atom2 } from "@effect-atom/atom-react";
|
|
239
239
|
import { Resource as Resource2 } from "@dxos/context";
|
|
240
|
-
import { Format as Format2, Obj, Order, Query, Ref } from "@dxos/echo";
|
|
241
|
-
import { toEffectSchema } from "@dxos/echo/
|
|
242
|
-
import { getSnapshot } from "@dxos/echo/
|
|
243
|
-
import {
|
|
240
|
+
import { Format as Format2, Obj, Order, Query, Ref, Type } from "@dxos/echo";
|
|
241
|
+
import { toEffectSchema } from "@dxos/echo/JsonSchema";
|
|
242
|
+
import { getSnapshot } from "@dxos/echo/Obj";
|
|
243
|
+
import { SchemaEx } from "@dxos/effect";
|
|
244
244
|
import { invariant } from "@dxos/invariant";
|
|
245
|
-
import {
|
|
245
|
+
import { EntityId } from "@dxos/keys";
|
|
246
246
|
import { formatForEditing, parseValue } from "@dxos/react-ui-form";
|
|
247
247
|
import { validateSchema } from "@dxos/schema";
|
|
248
248
|
|
|
@@ -383,10 +383,10 @@ var SelectionModel = class extends Resource {
|
|
|
383
383
|
// src/model/table-model.ts
|
|
384
384
|
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-table/src/model/table-model.ts";
|
|
385
385
|
var createEchoChangeCallback = (table) => ({
|
|
386
|
-
table: (mutate) => Obj.
|
|
386
|
+
table: (mutate) => Obj.update(table, (table2) => mutate(table2)),
|
|
387
387
|
row: (row, mutate) => {
|
|
388
388
|
if (Obj.isObject(row)) {
|
|
389
|
-
Obj.
|
|
389
|
+
Obj.update(row, (row2) => mutate(row2));
|
|
390
390
|
} else {
|
|
391
391
|
mutate(row);
|
|
392
392
|
}
|
|
@@ -451,15 +451,7 @@ var TableModel = class extends Resource2 {
|
|
|
451
451
|
...defaultFeatures,
|
|
452
452
|
...features
|
|
453
453
|
};
|
|
454
|
-
invariant(!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === "single"), "Single selection is not compatible with editable tables.", {
|
|
455
|
-
F: __dxlog_file,
|
|
456
|
-
L: 197,
|
|
457
|
-
S: this,
|
|
458
|
-
A: [
|
|
459
|
-
"!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === 'single')",
|
|
460
|
-
"'Single selection is not compatible with editable tables.'"
|
|
461
|
-
]
|
|
462
|
-
});
|
|
454
|
+
invariant(!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === "single"), "Single selection is not compatible with editable tables.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 94, S: this, A: ["!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === 'single')", "'Single selection is not compatible with editable tables.'"] });
|
|
463
455
|
this._visibleRange = Atom2.make({
|
|
464
456
|
start: {
|
|
465
457
|
row: 0,
|
|
@@ -474,8 +466,12 @@ var TableModel = class extends Resource2 {
|
|
|
474
466
|
this._draftRows = Atom2.make([]);
|
|
475
467
|
this._inMemorySort = Atom2.make(void 0);
|
|
476
468
|
this._cellUpdateCounter = Atom2.make(0);
|
|
477
|
-
this._persistedSort = Atom2.make((
|
|
478
|
-
const
|
|
469
|
+
this._persistedSort = Atom2.make((get) => {
|
|
470
|
+
const view = get(this._object.view.atom);
|
|
471
|
+
if (!view) {
|
|
472
|
+
return void 0;
|
|
473
|
+
}
|
|
474
|
+
const viewSnapshot = Obj.getSnapshot(view);
|
|
479
475
|
const ast = viewSnapshot.query.ast;
|
|
480
476
|
const orders = extractOrder(ast);
|
|
481
477
|
if (orders && orders.length > 0) {
|
|
@@ -510,8 +506,8 @@ var TableModel = class extends Resource2 {
|
|
|
510
506
|
const sorted = [
|
|
511
507
|
...rows
|
|
512
508
|
].sort((a, b) => {
|
|
513
|
-
const aValue = getValue(a, field.path);
|
|
514
|
-
const bValue = getValue(b, field.path);
|
|
509
|
+
const aValue = SchemaEx.getValue(a, field.path);
|
|
510
|
+
const bValue = SchemaEx.getValue(b, field.path);
|
|
515
511
|
return compareValues(aValue, bValue, fieldProjection.props.format, sort.direction);
|
|
516
512
|
});
|
|
517
513
|
return sorted;
|
|
@@ -538,19 +534,11 @@ var TableModel = class extends Resource2 {
|
|
|
538
534
|
this._onRowAction = onRowAction;
|
|
539
535
|
}
|
|
540
536
|
get id() {
|
|
541
|
-
return Obj.
|
|
537
|
+
return Obj.getURI(this._object);
|
|
542
538
|
}
|
|
543
539
|
get view() {
|
|
544
540
|
const view = this._object.view.target;
|
|
545
|
-
invariant(view, "Table model not initialized", {
|
|
546
|
-
F: __dxlog_file,
|
|
547
|
-
L: 308,
|
|
548
|
-
S: this,
|
|
549
|
-
A: [
|
|
550
|
-
"view",
|
|
551
|
-
"'Table model not initialized'"
|
|
552
|
-
]
|
|
553
|
-
});
|
|
541
|
+
invariant(view, "Table model not initialized", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 190, S: this, A: ["view", "'Table model not initialized'"] });
|
|
554
542
|
return view;
|
|
555
543
|
}
|
|
556
544
|
get table() {
|
|
@@ -610,15 +598,7 @@ var TableModel = class extends Resource2 {
|
|
|
610
598
|
return this._pinnedRows;
|
|
611
599
|
}
|
|
612
600
|
get columnMeta() {
|
|
613
|
-
invariant(this._columnMeta, void 0, {
|
|
614
|
-
F: __dxlog_file,
|
|
615
|
-
L: 381,
|
|
616
|
-
S: this,
|
|
617
|
-
A: [
|
|
618
|
-
"this._columnMeta",
|
|
619
|
-
""
|
|
620
|
-
]
|
|
621
|
-
});
|
|
601
|
+
invariant(this._columnMeta, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 244, S: this, A: ["this._columnMeta", ""] });
|
|
622
602
|
return this._columnMeta;
|
|
623
603
|
}
|
|
624
604
|
get selection() {
|
|
@@ -637,15 +617,7 @@ var TableModel = class extends Resource2 {
|
|
|
637
617
|
await this._selection.open(this._ctx);
|
|
638
618
|
}
|
|
639
619
|
initializeColumnMeta() {
|
|
640
|
-
invariant(this._object.view.target, "View must be loaded before initializing column meta", {
|
|
641
|
-
F: __dxlog_file,
|
|
642
|
-
L: 405,
|
|
643
|
-
S: this,
|
|
644
|
-
A: [
|
|
645
|
-
"this._object.view.target",
|
|
646
|
-
"'View must be loaded before initializing column meta'"
|
|
647
|
-
]
|
|
648
|
-
});
|
|
620
|
+
invariant(this._object.view.target, "View must be loaded before initializing column meta", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 263, S: this, A: ["this._object.view.target", "'View must be loaded before initializing column meta'"] });
|
|
649
621
|
this._columnMeta = Atom2.make((get) => {
|
|
650
622
|
const fields = get(this._projection.fields);
|
|
651
623
|
const meta = Object.fromEntries(fields.map((field, index) => [
|
|
@@ -756,7 +728,7 @@ var TableModel = class extends Resource2 {
|
|
|
756
728
|
return;
|
|
757
729
|
}
|
|
758
730
|
const draftData = {
|
|
759
|
-
id:
|
|
731
|
+
id: EntityId.random()
|
|
760
732
|
};
|
|
761
733
|
const validationErrors = this.validateDraftRowData(draftData);
|
|
762
734
|
const draftRow = {
|
|
@@ -839,13 +811,13 @@ var TableModel = class extends Resource2 {
|
|
|
839
811
|
let value;
|
|
840
812
|
if (plane === "frozenRowsEnd") {
|
|
841
813
|
if (row >= 0 && row < this._registry.get(this._draftRows).length) {
|
|
842
|
-
value = getValue(this._registry.get(this._draftRows)[row].data, field.path);
|
|
814
|
+
value = SchemaEx.getValue(this._registry.get(this._draftRows)[row].data, field.path);
|
|
843
815
|
} else {
|
|
844
816
|
return void 0;
|
|
845
817
|
}
|
|
846
818
|
} else {
|
|
847
819
|
const sortedRows = this._registry.get(this._sortedRows);
|
|
848
|
-
value = getValue(sortedRows[row], field.path);
|
|
820
|
+
value = SchemaEx.getValue(sortedRows[row], field.path);
|
|
849
821
|
}
|
|
850
822
|
if (value == null) {
|
|
851
823
|
return "";
|
|
@@ -856,7 +828,7 @@ var TableModel = class extends Resource2 {
|
|
|
856
828
|
if (!field.referencePath) {
|
|
857
829
|
return "";
|
|
858
830
|
}
|
|
859
|
-
return getValue(value.target, field.referencePath);
|
|
831
|
+
return SchemaEx.getValue(value.target, field.referencePath);
|
|
860
832
|
}
|
|
861
833
|
default: {
|
|
862
834
|
return formatForEditing({
|
|
@@ -891,7 +863,7 @@ var TableModel = class extends Resource2 {
|
|
|
891
863
|
const snapshot = {
|
|
892
864
|
...draftRow.data
|
|
893
865
|
};
|
|
894
|
-
setValue(snapshot, field.path, transformedValue);
|
|
866
|
+
SchemaEx.setValue(snapshot, field.path, transformedValue);
|
|
895
867
|
const validationErrors = this.validateDraftRowData(snapshot);
|
|
896
868
|
if (validationErrors.length > 0) {
|
|
897
869
|
const error = validationErrors.find((err) => err.path === field.path);
|
|
@@ -907,45 +879,23 @@ var TableModel = class extends Resource2 {
|
|
|
907
879
|
};
|
|
908
880
|
} else {
|
|
909
881
|
const currentRow = this._registry.get(this._rows)[row];
|
|
910
|
-
invariant(currentRow, "Invalid row index", {
|
|
911
|
-
F: __dxlog_file,
|
|
912
|
-
L: 693,
|
|
913
|
-
S: this,
|
|
914
|
-
A: [
|
|
915
|
-
"currentRow",
|
|
916
|
-
"'Invalid row index'"
|
|
917
|
-
]
|
|
918
|
-
});
|
|
882
|
+
invariant(currentRow, "Invalid row index", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 537, S: this, A: ["currentRow", "'Invalid row index'"] });
|
|
919
883
|
const snapshot = {
|
|
920
884
|
...getSnapshot(currentRow)
|
|
921
885
|
};
|
|
922
|
-
setValue(snapshot, field.path, transformedValue);
|
|
923
|
-
const
|
|
924
|
-
invariant(
|
|
925
|
-
|
|
926
|
-
L: 699,
|
|
927
|
-
S: this,
|
|
928
|
-
A: [
|
|
929
|
-
"schema",
|
|
930
|
-
""
|
|
931
|
-
]
|
|
932
|
-
});
|
|
886
|
+
SchemaEx.setValue(snapshot, field.path, transformedValue);
|
|
887
|
+
const type = Obj.getType(currentRow);
|
|
888
|
+
invariant(type, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 544, S: this, A: ["type", ""] });
|
|
889
|
+
const schema = Type.getSchema(type);
|
|
933
890
|
const validationResult = validateSchema(schema, snapshot);
|
|
934
891
|
if (validationResult && validationResult.length > 0) {
|
|
935
|
-
const error = validationResult
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
""
|
|
943
|
-
]
|
|
944
|
-
});
|
|
945
|
-
return {
|
|
946
|
-
valid: false,
|
|
947
|
-
error: error.message
|
|
948
|
-
};
|
|
892
|
+
const error = validationResult.find((err) => err.path === field.path);
|
|
893
|
+
if (error) {
|
|
894
|
+
return {
|
|
895
|
+
valid: false,
|
|
896
|
+
error: error.message
|
|
897
|
+
};
|
|
898
|
+
}
|
|
949
899
|
}
|
|
950
900
|
return {
|
|
951
901
|
valid: true
|
|
@@ -966,14 +916,14 @@ var TableModel = class extends Resource2 {
|
|
|
966
916
|
}
|
|
967
917
|
if (plane === "frozenRowsEnd") {
|
|
968
918
|
if (row >= 0 && row < this._registry.get(this._draftRows).length) {
|
|
969
|
-
setValue(this._registry.get(this._draftRows)[row].data, field.path, transformedValue);
|
|
919
|
+
SchemaEx.setValue(this._registry.get(this._draftRows)[row].data, field.path, transformedValue);
|
|
970
920
|
this.validateDraftRow(row);
|
|
971
921
|
}
|
|
972
922
|
} else {
|
|
973
923
|
const sortedRows = this._registry.get(this._sortedRows);
|
|
974
924
|
const rowData = sortedRows[row];
|
|
975
925
|
this._change.row(rowData, (mutableRow) => {
|
|
976
|
-
setValue(mutableRow, field.path, transformedValue);
|
|
926
|
+
SchemaEx.setValue(mutableRow, field.path, transformedValue);
|
|
977
927
|
});
|
|
978
928
|
}
|
|
979
929
|
};
|
|
@@ -987,10 +937,10 @@ var TableModel = class extends Resource2 {
|
|
|
987
937
|
const field = fields[col];
|
|
988
938
|
const sortedRows = this._registry.get(this._sortedRows);
|
|
989
939
|
const rowData = sortedRows[row];
|
|
990
|
-
const value = getValue(rowData, field.path);
|
|
940
|
+
const value = SchemaEx.getValue(rowData, field.path);
|
|
991
941
|
const updatedValue = update(value);
|
|
992
942
|
this._change.row(rowData, (mutableRow) => {
|
|
993
|
-
setValue(mutableRow, field.path, updatedValue);
|
|
943
|
+
SchemaEx.setValue(mutableRow, field.path, updatedValue);
|
|
994
944
|
});
|
|
995
945
|
}
|
|
996
946
|
/**
|
|
@@ -1105,12 +1055,12 @@ var TableModel = class extends Resource2 {
|
|
|
1105
1055
|
const field = this._projection.getFields().find((f) => f.id === inMemorySort.fieldId);
|
|
1106
1056
|
if (field) {
|
|
1107
1057
|
const newQuery = baseQuery.orderBy(Order.property(field.path, inMemorySort.direction));
|
|
1108
|
-
Obj.
|
|
1058
|
+
Obj.update(view, (view2) => {
|
|
1109
1059
|
view2.query.ast = newQuery.ast;
|
|
1110
1060
|
});
|
|
1111
1061
|
}
|
|
1112
1062
|
} else {
|
|
1113
|
-
Obj.
|
|
1063
|
+
Obj.update(view, (view2) => {
|
|
1114
1064
|
view2.query.ast = baseQuery.ast;
|
|
1115
1065
|
});
|
|
1116
1066
|
}
|
|
@@ -1168,7 +1118,8 @@ var editorTextToCellValue = (props, value) => {
|
|
|
1168
1118
|
import { Atom as Atom3 } from "@effect-atom/atom-react";
|
|
1169
1119
|
import * as Predicate from "effect/Predicate";
|
|
1170
1120
|
import { Obj as Obj2 } from "@dxos/echo";
|
|
1171
|
-
import { Format as Format3, TypeEnum
|
|
1121
|
+
import { Format as Format3, TypeEnum } from "@dxos/echo/Format";
|
|
1122
|
+
import { SchemaEx as SchemaEx2 } from "@dxos/effect";
|
|
1172
1123
|
import { cellClassesForFieldType, formatForDisplay } from "@dxos/react-ui-form";
|
|
1173
1124
|
import { toPlaneCellIndex } from "@dxos/react-ui-grid";
|
|
1174
1125
|
import { VIEW_FIELD_LIMIT } from "@dxos/schema";
|
|
@@ -1249,7 +1200,7 @@ var TablePresentation = class {
|
|
|
1249
1200
|
const { props } = this.getFieldProjection(field.id);
|
|
1250
1201
|
const cell = {
|
|
1251
1202
|
get value() {
|
|
1252
|
-
const value =
|
|
1203
|
+
const value = SchemaEx2.getValue(obj, field.path);
|
|
1253
1204
|
if (value == null) {
|
|
1254
1205
|
return "";
|
|
1255
1206
|
}
|
|
@@ -1266,7 +1217,7 @@ var TablePresentation = class {
|
|
|
1266
1217
|
if (!field.referencePath) {
|
|
1267
1218
|
return "";
|
|
1268
1219
|
}
|
|
1269
|
-
return
|
|
1220
|
+
return SchemaEx2.getValue(value.target, field.referencePath);
|
|
1270
1221
|
}
|
|
1271
1222
|
default: {
|
|
1272
1223
|
return formatForDisplay({
|
|
@@ -1289,7 +1240,7 @@ var TablePresentation = class {
|
|
|
1289
1240
|
}
|
|
1290
1241
|
cell.className = mx(classes);
|
|
1291
1242
|
if (props.type === TypeEnum.Array) {
|
|
1292
|
-
const targetArray =
|
|
1243
|
+
const targetArray = SchemaEx2.getValue(obj, field.path);
|
|
1293
1244
|
if (targetArray && Array.isArray(targetArray)) {
|
|
1294
1245
|
const getLabel = (value) => {
|
|
1295
1246
|
if (!value) {
|
|
@@ -1312,18 +1263,18 @@ var TablePresentation = class {
|
|
|
1312
1263
|
const tags = targetArray.map(getLabel).filter(Predicate.isNotNullable).map((title) => {
|
|
1313
1264
|
return `<span class="dx-tag" data-hue="neutral">${title}</span>`;
|
|
1314
1265
|
}).join("");
|
|
1315
|
-
cell.accessoryHtml = `<div
|
|
1266
|
+
cell.accessoryHtml = `<div class="flex flex-row gap-1 overflow-x-auto">${tags}</div>`;
|
|
1316
1267
|
}
|
|
1317
1268
|
}
|
|
1318
1269
|
if (props.format === Format3.TypeFormat.Ref && props.referenceSchema) {
|
|
1319
|
-
const targetObj =
|
|
1270
|
+
const targetObj = SchemaEx2.getValue(obj, field.path)?.target;
|
|
1320
1271
|
if (targetObj) {
|
|
1321
|
-
const
|
|
1322
|
-
cell.accessoryHtml = `<div role="none" class="absolute end-0 inset-y-0 p-(--dx-grid-cell-content-padding-block)"><dx-anchor
|
|
1272
|
+
const uri = Obj2.getURI(targetObj);
|
|
1273
|
+
cell.accessoryHtml = `<div role="none" class="absolute end-0 inset-y-0 p-(--dx-grid-cell-content-padding-block)"><dx-anchor uri=${uri} class="dx-button w-6 aspect-square min-h-0" data-dx-grid-action="accessory"><dx-icon icon="ph--link-simple--regular"/></dx-anchor></div>`;
|
|
1323
1274
|
}
|
|
1324
1275
|
}
|
|
1325
1276
|
if (props.format === Format3.TypeFormat.Boolean) {
|
|
1326
|
-
const value =
|
|
1277
|
+
const value = SchemaEx2.getValue(obj, field.path);
|
|
1327
1278
|
cell.accessoryHtml = tableControls.switch.render({
|
|
1328
1279
|
colIndex,
|
|
1329
1280
|
rowIndex: displayIndex,
|
|
@@ -1332,7 +1283,7 @@ var TablePresentation = class {
|
|
|
1332
1283
|
cell.readonly = "no-text-select";
|
|
1333
1284
|
}
|
|
1334
1285
|
if (props.format === Format3.TypeFormat.SingleSelect) {
|
|
1335
|
-
const value =
|
|
1286
|
+
const value = SchemaEx2.getValue(obj, field.path);
|
|
1336
1287
|
const options = this.model.projection.getFieldProjection(field.id).props.options;
|
|
1337
1288
|
if (options) {
|
|
1338
1289
|
const option = options.find((o) => o.id === value);
|
|
@@ -1342,7 +1293,7 @@ var TablePresentation = class {
|
|
|
1342
1293
|
}
|
|
1343
1294
|
}
|
|
1344
1295
|
if (props.format === Format3.TypeFormat.MultiSelect) {
|
|
1345
|
-
const values =
|
|
1296
|
+
const values = SchemaEx2.getValue(obj, field.path);
|
|
1346
1297
|
const options = this.model.projection.getFieldProjection(field.id).props.options;
|
|
1347
1298
|
if (options && values && values.length > 0) {
|
|
1348
1299
|
const tags = values.map((value) => {
|
|
@@ -1591,11 +1542,11 @@ var cellClassesForRowSelection = (selected, selectionMode) => {
|
|
|
1591
1542
|
switch (selectionMode) {
|
|
1592
1543
|
case "single":
|
|
1593
1544
|
return [
|
|
1594
|
-
"dx-grid__cell--no-focus-unfurl
|
|
1545
|
+
"dx-grid__cell--no-focus-unfurl bg-current-surface! hover:bg-hover-surface cursor-pointer!"
|
|
1595
1546
|
];
|
|
1596
1547
|
case "multiple":
|
|
1597
1548
|
return [
|
|
1598
|
-
"
|
|
1549
|
+
"bg-grid-cell-selected!"
|
|
1599
1550
|
];
|
|
1600
1551
|
}
|
|
1601
1552
|
};
|
|
@@ -1622,7 +1573,7 @@ var useAddRow = ({ db, schema }) => {
|
|
|
1622
1573
|
|
|
1623
1574
|
// src/hooks/useProjectionModel.ts
|
|
1624
1575
|
import { useState } from "react";
|
|
1625
|
-
import {
|
|
1576
|
+
import { Type as Type2 } from "@dxos/echo";
|
|
1626
1577
|
import { useAsyncEffect } from "@dxos/react-ui";
|
|
1627
1578
|
import { ProjectionModel, createEchoChangeCallback as createEchoChangeCallback2 } from "@dxos/schema";
|
|
1628
1579
|
var useProjectionModel = (schema, table, registry) => {
|
|
@@ -1630,8 +1581,8 @@ var useProjectionModel = (schema, table, registry) => {
|
|
|
1630
1581
|
useAsyncEffect(async () => {
|
|
1631
1582
|
if (schema && table) {
|
|
1632
1583
|
const view = await table.view.load();
|
|
1633
|
-
const jsonSchema =
|
|
1634
|
-
const change = createEchoChangeCallback2(view,
|
|
1584
|
+
const jsonSchema = schema.jsonSchema;
|
|
1585
|
+
const change = createEchoChangeCallback2(view, Type2.getDatabase(schema) != null ? schema : void 0);
|
|
1635
1586
|
const projection2 = new ProjectionModel({
|
|
1636
1587
|
registry,
|
|
1637
1588
|
view,
|
|
@@ -1657,7 +1608,7 @@ import { useSelected, useSelectionActions } from "@dxos/react-ui-attention";
|
|
|
1657
1608
|
import { isNonNullable } from "@dxos/util";
|
|
1658
1609
|
var useTableModel = ({ object, projection, db, rows, rowActions, features, onSelectionChanged, onRowAction, ...props }) => {
|
|
1659
1610
|
const registry = useContext(RegistryContext);
|
|
1660
|
-
const selected = useSelected(object && Obj4.
|
|
1611
|
+
const selected = useSelected(object && Obj4.getURI(object), "multi");
|
|
1661
1612
|
const initialSelection = useMemo(() => selected, [
|
|
1662
1613
|
object
|
|
1663
1614
|
]);
|
|
@@ -1748,4 +1699,4 @@ export {
|
|
|
1748
1699
|
useProjectionModel,
|
|
1749
1700
|
useTableModel
|
|
1750
1701
|
};
|
|
1751
|
-
//# sourceMappingURL=chunk-
|
|
1702
|
+
//# sourceMappingURL=chunk-4KOQTPFC.mjs.map
|