@fluidframework/tree 2.40.0 → 2.41.0-338186
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/api-report/tree.alpha.api.md +1 -1
- package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/schemaChecker.js +0 -7
- package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
- package/dist/feature-libraries/flex-tree/context.d.ts +16 -14
- package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/context.js +12 -18
- package/dist/feature-libraries/flex-tree/context.js.map +1 -1
- package/dist/feature-libraries/flex-tree/index.d.ts +1 -1
- package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/index.js +1 -2
- package/dist/feature-libraries/flex-tree/index.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts +1 -5
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +2 -16
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/flex-tree/utilities.d.ts +6 -6
- package/dist/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/utilities.js +6 -7
- package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +1 -1
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +1 -2
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/checkoutFlexTreeView.d.ts +7 -3
- package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
- package/dist/shared-tree/checkoutFlexTreeView.js +11 -2
- package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
- package/dist/shared-tree/schematizeTree.d.ts +1 -1
- package/dist/shared-tree/schematizeTree.js +1 -1
- package/dist/shared-tree/schematizeTree.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +3 -0
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +13 -7
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +1 -4
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +6 -1
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/simple-tree/api/create.d.ts +5 -1
- package/dist/simple-tree/api/create.d.ts.map +1 -1
- package/dist/simple-tree/api/create.js +10 -11
- package/dist/simple-tree/api/create.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +2 -2
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +2 -2
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts +1 -8
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +3 -14
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js +3 -9
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +4 -4
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +9 -5
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/index.d.ts +3 -2
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +6 -4
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/mapNode.js +17 -20
- package/dist/simple-tree/mapNode.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +2 -4
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/prepareForInsertion.d.ts +30 -0
- package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -0
- package/dist/simple-tree/prepareForInsertion.js +137 -0
- package/dist/simple-tree/prepareForInsertion.js.map +1 -0
- package/dist/simple-tree/proxies.d.ts +1 -12
- package/dist/simple-tree/proxies.d.ts.map +1 -1
- package/dist/simple-tree/proxies.js +10 -106
- package/dist/simple-tree/proxies.js.map +1 -1
- package/dist/simple-tree/toMapTree.d.ts +1 -1
- package/dist/simple-tree/toMapTree.js +1 -1
- package/dist/simple-tree/toMapTree.js.map +1 -1
- package/dist/tableSchema.d.ts +108 -59
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +93 -44
- package/dist/tableSchema.js.map +1 -1
- package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/schemaChecker.js +0 -7
- package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
- package/lib/feature-libraries/flex-tree/context.d.ts +16 -14
- package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/context.js +11 -16
- package/lib/feature-libraries/flex-tree/context.js.map +1 -1
- package/lib/feature-libraries/flex-tree/index.d.ts +1 -1
- package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/index.js +1 -1
- package/lib/feature-libraries/flex-tree/index.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts +1 -5
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +1 -14
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/flex-tree/utilities.d.ts +6 -6
- package/lib/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/utilities.js +6 -7
- package/lib/feature-libraries/flex-tree/utilities.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +1 -1
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +1 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/checkoutFlexTreeView.d.ts +7 -3
- package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
- package/lib/shared-tree/checkoutFlexTreeView.js +12 -3
- package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
- package/lib/shared-tree/schematizeTree.d.ts +1 -1
- package/lib/shared-tree/schematizeTree.js +1 -1
- package/lib/shared-tree/schematizeTree.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +3 -0
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +14 -8
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +1 -4
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +7 -2
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/simple-tree/api/create.d.ts +5 -1
- package/lib/simple-tree/api/create.d.ts.map +1 -1
- package/lib/simple-tree/api/create.js +8 -10
- package/lib/simple-tree/api/create.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +2 -2
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +2 -2
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts +1 -8
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +2 -12
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js +4 -10
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +4 -4
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +9 -5
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/index.d.ts +3 -2
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +3 -2
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/mapNode.js +3 -6
- package/lib/simple-tree/mapNode.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +4 -6
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/prepareForInsertion.d.ts +30 -0
- package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -0
- package/lib/simple-tree/prepareForInsertion.js +131 -0
- package/lib/simple-tree/prepareForInsertion.js.map +1 -0
- package/lib/simple-tree/proxies.d.ts +1 -12
- package/lib/simple-tree/proxies.d.ts.map +1 -1
- package/lib/simple-tree/proxies.js +1 -96
- package/lib/simple-tree/proxies.js.map +1 -1
- package/lib/simple-tree/toMapTree.d.ts +1 -1
- package/lib/simple-tree/toMapTree.js +1 -1
- package/lib/simple-tree/toMapTree.js.map +1 -1
- package/lib/tableSchema.d.ts +108 -59
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +94 -45
- package/lib/tableSchema.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/package.json +25 -25
- package/src/feature-libraries/default-schema/schemaChecker.ts +0 -8
- package/src/feature-libraries/flex-tree/context.ts +18 -20
- package/src/feature-libraries/flex-tree/index.ts +0 -1
- package/src/feature-libraries/flex-tree/lazyField.ts +2 -14
- package/src/feature-libraries/flex-tree/utilities.ts +8 -8
- package/src/feature-libraries/index.ts +0 -1
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/checkoutFlexTreeView.ts +10 -6
- package/src/shared-tree/schematizeTree.ts +1 -1
- package/src/shared-tree/schematizingTreeView.ts +14 -14
- package/src/shared-tree/treeAlpha.ts +21 -5
- package/src/simple-tree/api/create.ts +15 -15
- package/src/simple-tree/api/index.ts +6 -2
- package/src/simple-tree/api/storedSchema.ts +2 -19
- package/src/simple-tree/arrayNode.ts +9 -20
- package/src/simple-tree/core/unhydratedFlexTree.ts +10 -5
- package/src/simple-tree/index.ts +6 -5
- package/src/simple-tree/mapNode.ts +8 -12
- package/src/simple-tree/objectNode.ts +3 -12
- package/src/simple-tree/prepareForInsertion.ts +236 -0
- package/src/simple-tree/proxies.ts +2 -147
- package/src/simple-tree/toMapTree.ts +1 -1
- package/src/tableSchema.ts +310 -158
package/lib/tableSchema.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { oob } from "@fluidframework/core-utils/internal";
|
|
6
6
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
7
7
|
import { Tree } from "./shared-tree/index.js";
|
|
8
|
-
import { TreeArrayNode, SchemaFactory, } from "./simple-tree/index.js";
|
|
8
|
+
import { TreeArrayNode, SchemaFactory, isArrayNodeSchema, } from "./simple-tree/index.js";
|
|
9
9
|
// Future improvement TODOs:
|
|
10
10
|
// - Omit `cells` property from Row insertion type.
|
|
11
11
|
// - Record-like type parameters / input parameters?
|
|
@@ -16,6 +16,32 @@ import { TreeArrayNode, SchemaFactory, } from "./simple-tree/index.js";
|
|
|
16
16
|
* The sub-scope applied to user-provided {@link SchemaFactory}s by table schema factories.
|
|
17
17
|
*/
|
|
18
18
|
const tableSchemaFactorySubScope = "table";
|
|
19
|
+
/**
|
|
20
|
+
* Gets the table containing the provided row/column node, if the node is part of a table.
|
|
21
|
+
* @remarks Assumes that the table is the grandparent of the row/column node.
|
|
22
|
+
*/
|
|
23
|
+
function getParentTable(rowOrColumnNode) {
|
|
24
|
+
const rowListNode = Tree.parent(rowOrColumnNode);
|
|
25
|
+
if (rowListNode === undefined || !isArrayNodeSchema(Tree.schema(rowListNode))) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const tableNode = Tree.parent(rowListNode);
|
|
29
|
+
if (tableNode === undefined || !isTableNode(tableNode)) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
return tableNode;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A private symbol put on table schema to help identify them.
|
|
36
|
+
*/
|
|
37
|
+
const tableSchemaSymbol = Symbol("tableNode");
|
|
38
|
+
/**
|
|
39
|
+
* Type-guard to determine if a node is a table node.
|
|
40
|
+
* @remarks Uses {@link tableSchemaSymbol} to identify table nodes.
|
|
41
|
+
*/
|
|
42
|
+
function isTableNode(node) {
|
|
43
|
+
return tableSchemaSymbol in Tree.schema(node);
|
|
44
|
+
}
|
|
19
45
|
/**
|
|
20
46
|
* Not intended for use outside of this package.
|
|
21
47
|
*
|
|
@@ -29,11 +55,11 @@ const tableSchemaFactorySubScope = "table";
|
|
|
29
55
|
export var System_TableSchema;
|
|
30
56
|
(function (System_TableSchema) {
|
|
31
57
|
/**
|
|
32
|
-
* Factory for creating
|
|
58
|
+
* Factory for creating column schema.
|
|
33
59
|
* @system @internal
|
|
34
60
|
*/
|
|
35
61
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
|
|
36
|
-
function
|
|
62
|
+
function createColumnSchema(inputSchemaFactory, cellSchema, propsSchema) {
|
|
37
63
|
const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
|
|
38
64
|
// Note: `columnFields` is broken into two parts to work around a TypeScript bug
|
|
39
65
|
// that results in broken `.d.ts` output.
|
|
@@ -66,6 +92,23 @@ export var System_TableSchema;
|
|
|
66
92
|
// Will make it easier to evolve this schema in the future.
|
|
67
93
|
allowUnknownOptionalFields: true,
|
|
68
94
|
}) {
|
|
95
|
+
getCells() {
|
|
96
|
+
const tableNode = getParentTable(this);
|
|
97
|
+
if (tableNode === undefined) {
|
|
98
|
+
throw new UsageError(`Column with ID "${this.id}" is not contained in a table.`);
|
|
99
|
+
}
|
|
100
|
+
const result = [];
|
|
101
|
+
for (const row of tableNode.rows) {
|
|
102
|
+
const cell = row.getCell(this.id);
|
|
103
|
+
if (cell !== undefined) {
|
|
104
|
+
if (!Tree.is(cell, cellSchema)) {
|
|
105
|
+
throw new UsageError("Parent table contains a cell with incompatible with this column.");
|
|
106
|
+
}
|
|
107
|
+
result.push({ rowId: row.id, cell: cell });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
69
112
|
}
|
|
70
113
|
// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
|
|
71
114
|
// for the private brand field of TreeNode.
|
|
@@ -75,14 +118,13 @@ export var System_TableSchema;
|
|
|
75
118
|
const ColumnSchemaType = Column;
|
|
76
119
|
return ColumnSchemaType;
|
|
77
120
|
}
|
|
78
|
-
System_TableSchema.
|
|
121
|
+
System_TableSchema.createColumnSchema = createColumnSchema;
|
|
79
122
|
/**
|
|
80
|
-
* Factory for creating
|
|
81
|
-
*
|
|
123
|
+
* Factory for creating row schema.
|
|
82
124
|
* @sealed @internal
|
|
83
125
|
*/
|
|
84
126
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
|
|
85
|
-
function
|
|
127
|
+
function createRowSchema(inputSchemaFactory, cellSchema, propsSchema) {
|
|
86
128
|
const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
|
|
87
129
|
// Note: `rowFields` is broken into two parts to work around a TypeScript bug
|
|
88
130
|
// that results in broken `.d.ts` output.
|
|
@@ -136,6 +178,18 @@ export var System_TableSchema;
|
|
|
136
178
|
this.cells.delete(columnId);
|
|
137
179
|
return cell;
|
|
138
180
|
}
|
|
181
|
+
getCells() {
|
|
182
|
+
const result = [];
|
|
183
|
+
for (const [columnId, cell] of this.cells.entries()) {
|
|
184
|
+
if (cell !== undefined) {
|
|
185
|
+
result.push({
|
|
186
|
+
columnId,
|
|
187
|
+
cell,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return result;
|
|
192
|
+
}
|
|
139
193
|
}
|
|
140
194
|
// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
|
|
141
195
|
// for the private brand field of TreeNode.
|
|
@@ -145,13 +199,13 @@ export var System_TableSchema;
|
|
|
145
199
|
const RowSchemaType = Row;
|
|
146
200
|
return RowSchemaType;
|
|
147
201
|
}
|
|
148
|
-
System_TableSchema.
|
|
202
|
+
System_TableSchema.createRowSchema = createRowSchema;
|
|
149
203
|
/**
|
|
150
|
-
* Factory for creating
|
|
204
|
+
* Factory for creating table schema.
|
|
151
205
|
* @system @internal
|
|
152
206
|
*/
|
|
153
207
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
|
|
154
|
-
function
|
|
208
|
+
function createTableSchema(inputSchemaFactory, _cellSchema, columnSchema, rowSchema) {
|
|
155
209
|
const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
|
|
156
210
|
/**
|
|
157
211
|
* {@link Table} fields.
|
|
@@ -169,6 +223,9 @@ export var System_TableSchema;
|
|
|
169
223
|
// Will make it easier to evolve this schema in the future.
|
|
170
224
|
allowUnknownOptionalFields: true,
|
|
171
225
|
}) {
|
|
226
|
+
static empty() {
|
|
227
|
+
return new this({ columns: [], rows: [] });
|
|
228
|
+
}
|
|
172
229
|
getColumn(id) {
|
|
173
230
|
// TypeScript is unable to narrow the types correctly here, hence the casts.
|
|
174
231
|
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
@@ -199,21 +256,10 @@ export var System_TableSchema;
|
|
|
199
256
|
return inserted[0] ?? oob();
|
|
200
257
|
}
|
|
201
258
|
insertColumns({ columns, index, }) {
|
|
202
|
-
// #region Input validation
|
|
203
259
|
// Ensure index is valid
|
|
204
260
|
if (index !== undefined) {
|
|
205
261
|
Table.validateInsertionIndex(index, this.columns);
|
|
206
262
|
}
|
|
207
|
-
// Check all of the columns being inserted an ensure the table does not already contain any with the same ID.
|
|
208
|
-
for (const column of columns) {
|
|
209
|
-
// TypeScript is unable to narrow the type of the column type correctly here, hence the casts below.
|
|
210
|
-
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
211
|
-
const maybeId = column.id;
|
|
212
|
-
if (maybeId !== undefined && this.containsColumnWithId(maybeId)) {
|
|
213
|
-
throw new UsageError(`A column with ID "${column.id}" already exists in the table.`);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
// #endregion
|
|
217
263
|
// TypeScript is unable to narrow the column type correctly here, hence the casts below.
|
|
218
264
|
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
219
265
|
if (index === undefined) {
|
|
@@ -243,11 +289,6 @@ export var System_TableSchema;
|
|
|
243
289
|
// Note: TypeScript is unable to narrow the type of the row type correctly here, hence the casts below.
|
|
244
290
|
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
245
291
|
for (const newRow of rows) {
|
|
246
|
-
// Check all of the rows being inserted an ensure the table does not already contain any with the same ID.
|
|
247
|
-
const maybeId = newRow.id;
|
|
248
|
-
if (maybeId !== undefined && this.containsRowWithId(maybeId)) {
|
|
249
|
-
throw new UsageError(`A row with ID "${newRow.id}" already exists in the table.`);
|
|
250
|
-
}
|
|
251
292
|
// If the row contains cells, verify that the table contains the columns for those cells.
|
|
252
293
|
// Note: we intentionally hide `cells` on `IRow` to avoid leaking the internal data representation as much as possible, so we have to cast here.
|
|
253
294
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -398,13 +439,13 @@ export var System_TableSchema;
|
|
|
398
439
|
containsColumnWithId(columnId) {
|
|
399
440
|
// TypeScript is unable to narrow the types correctly here, hence the cast.
|
|
400
441
|
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
401
|
-
return (this.columns.find((column) => column.id === columnId) !==
|
|
402
|
-
undefined);
|
|
442
|
+
return (this.columns.find((column) => column.id === columnId) !== undefined);
|
|
403
443
|
}
|
|
404
444
|
containsRowWithId(rowId) {
|
|
405
445
|
// TypeScript is unable to narrow the types correctly here, hence the cast.
|
|
406
446
|
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
407
|
-
return this.rows.find((row) => row.id === rowId) !==
|
|
447
|
+
return (this.rows.find((row) => row.id === rowId) !==
|
|
448
|
+
undefined);
|
|
408
449
|
}
|
|
409
450
|
/**
|
|
410
451
|
* Ensure that the specified index is a valid location for item insertion in the destination list.
|
|
@@ -422,6 +463,12 @@ export var System_TableSchema;
|
|
|
422
463
|
}
|
|
423
464
|
}
|
|
424
465
|
}
|
|
466
|
+
// Set a private symbol on the schema class that marks it as having been generated by this factory.
|
|
467
|
+
// Column / Row functionality use this to validate that they are being used in a table.
|
|
468
|
+
// This is effectively a work-around that allows columns and rows to invoke table methods
|
|
469
|
+
// without having to pass the table as a parameter to their construction, which isn't possible.
|
|
470
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
471
|
+
Table[tableSchemaSymbol] = true;
|
|
425
472
|
// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
|
|
426
473
|
// for the private brand field of TreeNode.
|
|
427
474
|
// This numeric id doesn't seem to be stable over incremental builds, and thus causes diffs in the API extractor reports.
|
|
@@ -431,7 +478,7 @@ export var System_TableSchema;
|
|
|
431
478
|
// Return the table schema
|
|
432
479
|
return TableSchemaType;
|
|
433
480
|
}
|
|
434
|
-
System_TableSchema.
|
|
481
|
+
System_TableSchema.createTableSchema = createTableSchema;
|
|
435
482
|
// #endregion
|
|
436
483
|
})(System_TableSchema || (System_TableSchema = {}));
|
|
437
484
|
/**
|
|
@@ -465,7 +512,7 @@ export var System_TableSchema;
|
|
|
465
512
|
* value: schemaFactory.string,
|
|
466
513
|
* }) {}
|
|
467
514
|
*
|
|
468
|
-
* class Table extends TableSchema.
|
|
515
|
+
* class Table extends TableSchema.table({
|
|
469
516
|
* schemaFactory,
|
|
470
517
|
* cell: Cell,
|
|
471
518
|
* }) {}
|
|
@@ -490,17 +537,18 @@ export var System_TableSchema;
|
|
|
490
537
|
* dataType: schemaFactory.optional(schemaFactory.string),
|
|
491
538
|
* }) {}
|
|
492
539
|
*
|
|
493
|
-
* class Column extends TableSchema.
|
|
540
|
+
* class Column extends TableSchema.column({
|
|
494
541
|
* schemaFactory,
|
|
542
|
+
* cell: Cell,
|
|
495
543
|
* props: ColumnProps,
|
|
496
544
|
* }) {}
|
|
497
545
|
*
|
|
498
|
-
* class Row extends TableSchema.
|
|
546
|
+
* class Row extends TableSchema.row({
|
|
499
547
|
* schemaFactory,
|
|
500
548
|
* cell: Cell,
|
|
501
549
|
* }) {}
|
|
502
550
|
*
|
|
503
|
-
* class Table extends TableSchema.
|
|
551
|
+
* class Table extends TableSchema.table({
|
|
504
552
|
* schemaFactory,
|
|
505
553
|
* cell: Cell,
|
|
506
554
|
* column: Column,
|
|
@@ -529,29 +577,30 @@ export var TableSchema;
|
|
|
529
577
|
/**
|
|
530
578
|
* Overload implementation
|
|
531
579
|
*/
|
|
532
|
-
function
|
|
533
|
-
return System_TableSchema.
|
|
580
|
+
function column({ schemaFactory, cell, props = SchemaFactory.optional(SchemaFactory.null), }) {
|
|
581
|
+
return System_TableSchema.createColumnSchema(schemaFactory, cell, props);
|
|
534
582
|
}
|
|
535
|
-
TableSchema.
|
|
583
|
+
TableSchema.column = column;
|
|
536
584
|
/**
|
|
537
585
|
* Overload implementation
|
|
538
586
|
*/
|
|
539
|
-
function
|
|
540
|
-
return System_TableSchema.
|
|
587
|
+
function row({ schemaFactory, cell, props = SchemaFactory.optional(SchemaFactory.null), }) {
|
|
588
|
+
return System_TableSchema.createRowSchema(schemaFactory, cell, props);
|
|
541
589
|
}
|
|
542
|
-
TableSchema.
|
|
590
|
+
TableSchema.row = row;
|
|
543
591
|
/**
|
|
544
592
|
* Overload implementation
|
|
545
593
|
*/
|
|
546
|
-
function
|
|
594
|
+
function table({ schemaFactory, cell: cellSchema, column: columnSchema = column({
|
|
547
595
|
schemaFactory,
|
|
548
|
-
|
|
596
|
+
cell: cellSchema,
|
|
597
|
+
}), row: rowSchema = row({
|
|
549
598
|
schemaFactory,
|
|
550
|
-
cell,
|
|
599
|
+
cell: cellSchema,
|
|
551
600
|
}), }) {
|
|
552
|
-
return System_TableSchema.
|
|
601
|
+
return System_TableSchema.createTableSchema(schemaFactory, cellSchema, columnSchema, rowSchema);
|
|
553
602
|
}
|
|
554
|
-
TableSchema.
|
|
603
|
+
TableSchema.table = table;
|
|
555
604
|
// #endregion
|
|
556
605
|
})(TableSchema || (TableSchema = {}));
|
|
557
606
|
//# sourceMappingURL=tableSchema.js.map
|