@fluidframework/tree 2.32.0 → 2.33.0-333010
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/feature-libraries/flex-tree/context.d.ts +5 -0
- package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/context.js +4 -0
- package/dist/feature-libraries/flex-tree/context.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
- package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +29 -25
- package/dist/feature-libraries/node-identifier/nodeIdentifierManager.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 +1 -0
- package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
- package/dist/shared-tree/checkoutFlexTreeView.js +4 -0
- package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts +9 -2
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +39 -24
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +3 -0
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +3 -0
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/tableSchema.d.ts +26 -12
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +17 -13
- package/dist/tableSchema.js.map +1 -1
- package/lib/feature-libraries/flex-tree/context.d.ts +5 -0
- package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/context.js +5 -1
- package/lib/feature-libraries/flex-tree/context.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
- package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +28 -24
- package/lib/feature-libraries/node-identifier/nodeIdentifierManager.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 +1 -0
- package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
- package/lib/shared-tree/checkoutFlexTreeView.js +4 -0
- package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts +9 -2
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +40 -25
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +3 -0
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +4 -1
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/tableSchema.d.ts +26 -12
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +17 -13
- package/lib/tableSchema.js.map +1 -1
- package/package.json +20 -20
- package/src/feature-libraries/flex-tree/context.ts +11 -1
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +8 -0
- package/src/feature-libraries/node-identifier/nodeIdentifierManager.ts +39 -38
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/checkoutFlexTreeView.ts +6 -0
- package/src/simple-tree/core/treeNodeKernel.ts +46 -28
- package/src/simple-tree/core/unhydratedFlexTree.ts +5 -1
- package/src/simple-tree/objectNode.ts +4 -2
- package/src/tableSchema.ts +80 -21
package/src/tableSchema.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
TreeArrayNode,
|
|
18
18
|
type TreeNode,
|
|
19
19
|
type TreeNodeFromImplicitAllowedTypes,
|
|
20
|
+
type TreeNodeSchema,
|
|
20
21
|
type TreeNodeSchemaClass,
|
|
21
22
|
type WithType,
|
|
22
23
|
} from "./simple-tree/index.js";
|
|
@@ -133,7 +134,7 @@ export namespace TableSchema {
|
|
|
133
134
|
|
|
134
135
|
/**
|
|
135
136
|
* Sets the cell in the specified column.
|
|
136
|
-
* @remarks To
|
|
137
|
+
* @remarks To remove a cell, call {@link TableSchema.IRow.removeCell} instead.
|
|
137
138
|
* @privateRemarks TODO: add overload that takes column ID.
|
|
138
139
|
*/
|
|
139
140
|
setCell(
|
|
@@ -142,10 +143,10 @@ export namespace TableSchema {
|
|
|
142
143
|
): void;
|
|
143
144
|
|
|
144
145
|
/**
|
|
145
|
-
*
|
|
146
|
+
* Removes the cell in the specified column.
|
|
146
147
|
* @privateRemarks TODO: add overload that takes column ID.
|
|
147
148
|
*/
|
|
148
|
-
|
|
149
|
+
removeCell(column: TreeNodeFromImplicitAllowedTypes<TColumnSchema>): void;
|
|
149
150
|
}
|
|
150
151
|
|
|
151
152
|
/**
|
|
@@ -196,7 +197,7 @@ export namespace TableSchema {
|
|
|
196
197
|
this.cells.set(column.id, value);
|
|
197
198
|
}
|
|
198
199
|
|
|
199
|
-
public
|
|
200
|
+
public removeCell(column: ColumnValueType): void {
|
|
200
201
|
if (!this.cells.has(column.id)) return;
|
|
201
202
|
this.cells.delete(column.id);
|
|
202
203
|
}
|
|
@@ -360,7 +361,7 @@ export namespace TableSchema {
|
|
|
360
361
|
|
|
361
362
|
/**
|
|
362
363
|
* Sets the cell at the specified location in the table.
|
|
363
|
-
* @remarks To
|
|
364
|
+
* @remarks To remove a cell, call {@link TableSchema.ITable.removeCell} instead.
|
|
364
365
|
* @privateRemarks TODO: add overload that takes column/row nodes?
|
|
365
366
|
*/
|
|
366
367
|
setCell(
|
|
@@ -378,30 +379,88 @@ export namespace TableSchema {
|
|
|
378
379
|
removeColumn: (column: TreeNodeFromImplicitAllowedTypes<TColumnSchema>) => void;
|
|
379
380
|
|
|
380
381
|
/**
|
|
381
|
-
*
|
|
382
|
+
* Removes 0 or more rows from the table.
|
|
382
383
|
* @privateRemarks TODO: policy for when 1 or more rows are not in the table.
|
|
383
384
|
*/
|
|
384
|
-
|
|
385
|
+
removeRows: (rows: readonly TreeNodeFromImplicitAllowedTypes<TRowSchema>[]) => void;
|
|
385
386
|
|
|
386
387
|
/**
|
|
387
|
-
*
|
|
388
|
+
* Removes all rows from the table.
|
|
388
389
|
*/
|
|
389
|
-
|
|
390
|
+
removeAllRows: () => void;
|
|
390
391
|
|
|
391
392
|
/**
|
|
392
|
-
*
|
|
393
|
+
* Removes the cell at the specified location in the table.
|
|
393
394
|
* @privateRemarks TODO: add overload that takes column/row nodes?
|
|
394
395
|
*/
|
|
395
|
-
|
|
396
|
+
removeCell: (key: CellKey) => void;
|
|
396
397
|
}
|
|
397
398
|
|
|
399
|
+
/**
|
|
400
|
+
* Factory for creating new table schema without specifying row or column schema.
|
|
401
|
+
* @internal
|
|
402
|
+
*/
|
|
403
|
+
export function createTable<
|
|
404
|
+
const TInputScope extends string | undefined,
|
|
405
|
+
const TCell extends ImplicitAllowedTypes,
|
|
406
|
+
>(
|
|
407
|
+
inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
|
|
408
|
+
_cellSchema: TCell,
|
|
409
|
+
): ReturnType<typeof createTableInternal<TInputScope, TCell>>;
|
|
410
|
+
/**
|
|
411
|
+
* Factory for creating new table schema without specifyint row schema
|
|
412
|
+
* @internal
|
|
413
|
+
*/
|
|
414
|
+
export function createTable<
|
|
415
|
+
const TInputScope extends string | undefined,
|
|
416
|
+
const TCell extends ImplicitAllowedTypes,
|
|
417
|
+
const TColumn extends ColumnSchemaBase<TInputScope>,
|
|
418
|
+
>(
|
|
419
|
+
inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
|
|
420
|
+
_cellSchema: TCell,
|
|
421
|
+
columnSchema: TColumn,
|
|
422
|
+
): ReturnType<typeof createTableInternal<TInputScope, TCell, TColumn>>;
|
|
398
423
|
/**
|
|
399
424
|
* Factory for creating new table schema.
|
|
400
|
-
* @privateRemarks TODO: add overloads to make column/row schema optional.
|
|
401
425
|
* @internal
|
|
402
426
|
*/
|
|
403
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
|
|
404
427
|
export function createTable<
|
|
428
|
+
const TInputScope extends string | undefined,
|
|
429
|
+
const TCell extends ImplicitAllowedTypes,
|
|
430
|
+
const TColumn extends ColumnSchemaBase<TInputScope>,
|
|
431
|
+
const TRow extends RowSchemaBase<TInputScope, TCell, TColumn>,
|
|
432
|
+
>(
|
|
433
|
+
inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
|
|
434
|
+
_cellSchema: TCell,
|
|
435
|
+
columnSchema: TColumn,
|
|
436
|
+
rowSchema: TRow,
|
|
437
|
+
): ReturnType<typeof createTableInternal<TInputScope, TCell, TColumn, TRow>>;
|
|
438
|
+
export function createTable<
|
|
439
|
+
const TInputScope extends string | undefined,
|
|
440
|
+
const TCell extends ImplicitAllowedTypes,
|
|
441
|
+
const TColumn extends ColumnSchemaBase<TInputScope>,
|
|
442
|
+
const TRow extends RowSchemaBase<TInputScope, TCell, TColumn>,
|
|
443
|
+
>(
|
|
444
|
+
inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
|
|
445
|
+
_cellSchema: TCell,
|
|
446
|
+
columnSchema?: TColumn,
|
|
447
|
+
rowSchema?: TRow,
|
|
448
|
+
): TreeNodeSchema {
|
|
449
|
+
const column = columnSchema ?? createColumn(inputSchemaFactory);
|
|
450
|
+
return createTableInternal(
|
|
451
|
+
inputSchemaFactory,
|
|
452
|
+
_cellSchema,
|
|
453
|
+
column as TColumn,
|
|
454
|
+
rowSchema ?? (createRow(inputSchemaFactory, _cellSchema, column) as TRow),
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Factory for creating new table schema.
|
|
460
|
+
* @system @internal
|
|
461
|
+
*/
|
|
462
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
|
|
463
|
+
export function createTableInternal<
|
|
405
464
|
const TInputScope extends string | undefined,
|
|
406
465
|
const TCell extends ImplicitAllowedTypes,
|
|
407
466
|
const TColumn extends ColumnSchemaBase<TInputScope> = ColumnSchemaBase<TInputScope>,
|
|
@@ -532,22 +591,22 @@ export namespace TableSchema {
|
|
|
532
591
|
this.columns.removeAt(index);
|
|
533
592
|
}
|
|
534
593
|
|
|
535
|
-
public
|
|
536
|
-
// If there are no rows to
|
|
594
|
+
public removeRows(rows: readonly RowValueType[]): void {
|
|
595
|
+
// If there are no rows to remove, do nothing
|
|
537
596
|
if (rows.length === 0) {
|
|
538
597
|
return;
|
|
539
598
|
}
|
|
540
599
|
|
|
541
|
-
// If there is only one row to
|
|
600
|
+
// If there is only one row to remove, remove it
|
|
542
601
|
if (rows.length === 1) {
|
|
543
602
|
const index = this.rows.indexOf(rows[0] ?? oob());
|
|
544
603
|
this.rows.removeAt(index);
|
|
545
604
|
return;
|
|
546
605
|
}
|
|
547
|
-
// If there are multiple rows to
|
|
606
|
+
// If there are multiple rows to remove, remove them in a transaction
|
|
548
607
|
// This is to avoid the performance issues of deleting multiple rows at once
|
|
549
608
|
Tree.runTransaction(this, () => {
|
|
550
|
-
// Iterate over the rows and
|
|
609
|
+
// Iterate over the rows and remove them
|
|
551
610
|
for (const row of rows) {
|
|
552
611
|
const index = this.rows.indexOf(row);
|
|
553
612
|
this.rows.removeAt(index);
|
|
@@ -555,17 +614,17 @@ export namespace TableSchema {
|
|
|
555
614
|
});
|
|
556
615
|
}
|
|
557
616
|
|
|
558
|
-
public
|
|
617
|
+
public removeAllRows(): void {
|
|
559
618
|
this.rows.removeRange();
|
|
560
619
|
}
|
|
561
620
|
|
|
562
|
-
public
|
|
621
|
+
public removeCell(key: CellKey): void {
|
|
563
622
|
const { columnId, rowId } = key;
|
|
564
623
|
const row = this.getRow(rowId);
|
|
565
624
|
if (row !== undefined) {
|
|
566
625
|
const column = this.getColumn(columnId);
|
|
567
626
|
if (column !== undefined) {
|
|
568
|
-
row.
|
|
627
|
+
row.removeCell(column);
|
|
569
628
|
}
|
|
570
629
|
}
|
|
571
630
|
}
|