@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.
Files changed (78) hide show
  1. package/dist/feature-libraries/flex-tree/context.d.ts +5 -0
  2. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  3. package/dist/feature-libraries/flex-tree/context.js +4 -0
  4. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  5. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
  6. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  7. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
  8. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  9. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
  10. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +29 -25
  11. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  12. package/dist/packageVersion.d.ts +1 -1
  13. package/dist/packageVersion.d.ts.map +1 -1
  14. package/dist/packageVersion.js +1 -1
  15. package/dist/packageVersion.js.map +1 -1
  16. package/dist/shared-tree/checkoutFlexTreeView.d.ts +1 -0
  17. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  18. package/dist/shared-tree/checkoutFlexTreeView.js +4 -0
  19. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
  20. package/dist/simple-tree/core/treeNodeKernel.d.ts +9 -2
  21. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  22. package/dist/simple-tree/core/treeNodeKernel.js +39 -24
  23. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  24. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  25. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  26. package/dist/simple-tree/core/unhydratedFlexTree.js +3 -0
  27. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  28. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  29. package/dist/simple-tree/objectNode.js +3 -0
  30. package/dist/simple-tree/objectNode.js.map +1 -1
  31. package/dist/tableSchema.d.ts +26 -12
  32. package/dist/tableSchema.d.ts.map +1 -1
  33. package/dist/tableSchema.js +17 -13
  34. package/dist/tableSchema.js.map +1 -1
  35. package/lib/feature-libraries/flex-tree/context.d.ts +5 -0
  36. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  37. package/lib/feature-libraries/flex-tree/context.js +5 -1
  38. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  39. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
  40. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  41. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
  42. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  43. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
  44. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +28 -24
  45. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  46. package/lib/packageVersion.d.ts +1 -1
  47. package/lib/packageVersion.d.ts.map +1 -1
  48. package/lib/packageVersion.js +1 -1
  49. package/lib/packageVersion.js.map +1 -1
  50. package/lib/shared-tree/checkoutFlexTreeView.d.ts +1 -0
  51. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  52. package/lib/shared-tree/checkoutFlexTreeView.js +4 -0
  53. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
  54. package/lib/simple-tree/core/treeNodeKernel.d.ts +9 -2
  55. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  56. package/lib/simple-tree/core/treeNodeKernel.js +40 -25
  57. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  58. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  59. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  60. package/lib/simple-tree/core/unhydratedFlexTree.js +3 -0
  61. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  62. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  63. package/lib/simple-tree/objectNode.js +4 -1
  64. package/lib/simple-tree/objectNode.js.map +1 -1
  65. package/lib/tableSchema.d.ts +26 -12
  66. package/lib/tableSchema.d.ts.map +1 -1
  67. package/lib/tableSchema.js +17 -13
  68. package/lib/tableSchema.js.map +1 -1
  69. package/package.json +20 -20
  70. package/src/feature-libraries/flex-tree/context.ts +11 -1
  71. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +8 -0
  72. package/src/feature-libraries/node-identifier/nodeIdentifierManager.ts +39 -38
  73. package/src/packageVersion.ts +1 -1
  74. package/src/shared-tree/checkoutFlexTreeView.ts +6 -0
  75. package/src/simple-tree/core/treeNodeKernel.ts +46 -28
  76. package/src/simple-tree/core/unhydratedFlexTree.ts +5 -1
  77. package/src/simple-tree/objectNode.ts +4 -2
  78. package/src/tableSchema.ts +80 -21
@@ -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 delete a cell, call {@link TableSchema.IRow.deleteCell} instead.
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
- * Deletes the cell in the specified column.
146
+ * Removes the cell in the specified column.
146
147
  * @privateRemarks TODO: add overload that takes column ID.
147
148
  */
148
- deleteCell(column: TreeNodeFromImplicitAllowedTypes<TColumnSchema>): void;
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 deleteCell(column: ColumnValueType): void {
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 delete a cell, call {@link TableSchema.ITable.deleteCell} instead.
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
- * Deletes 0 or more rows from the table.
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
- deleteRows: (rows: readonly TreeNodeFromImplicitAllowedTypes<TRowSchema>[]) => void;
385
+ removeRows: (rows: readonly TreeNodeFromImplicitAllowedTypes<TRowSchema>[]) => void;
385
386
 
386
387
  /**
387
- * Deletes all rows from the table.
388
+ * Removes all rows from the table.
388
389
  */
389
- deleteAllRows: () => void;
390
+ removeAllRows: () => void;
390
391
 
391
392
  /**
392
- * Deletes the cell at the specified location in the table.
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
- deleteCell: (key: CellKey) => void;
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 deleteRows(rows: readonly RowValueType[]): void {
536
- // If there are no rows to delete, do nothing
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 delete, delete it
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 delete, delete them in a transaction
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 delete them
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 deleteAllRows(): void {
617
+ public removeAllRows(): void {
559
618
  this.rows.removeRange();
560
619
  }
561
620
 
562
- public deleteCell(key: CellKey): void {
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.deleteCell(column);
627
+ row.removeCell(column);
569
628
  }
570
629
  }
571
630
  }