@coolon/angular-ui-powerups 12.0.7 → 12.1.0

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 (50) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +300 -300
  2. package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
  3. package/coolon-angular-ui-powerups.metadata.json +1 -1
  4. package/esm2015/lib/components/exports.js +1 -1
  5. package/esm2015/lib/components/exports.js.map +1 -1
  6. package/esm2015/lib/components/exports.metadata.json +1 -1
  7. package/esm2015/lib/components/tables/abstract-table-model.js +11 -6
  8. package/esm2015/lib/components/tables/abstract-table-model.js.map +1 -1
  9. package/esm2015/lib/components/tables/abstract-table-model.metadata.json +1 -1
  10. package/esm2015/lib/components/tables/abstract-table.component.js.map +1 -1
  11. package/esm2015/lib/components/tables/table/table-model.js +18 -12
  12. package/esm2015/lib/components/tables/table/table-model.js.map +1 -1
  13. package/esm2015/lib/components/tables/table/table-model.metadata.json +1 -1
  14. package/esm2015/lib/components/tables/tree-table/decorated-tree-node.js +151 -146
  15. package/esm2015/lib/components/tables/tree-table/decorated-tree-node.js.map +1 -1
  16. package/esm2015/lib/components/tables/tree-table/decorated-tree-node.metadata.json +1 -1
  17. package/esm2015/lib/components/tables/tree-table/flattened-tree-list-model.js +29 -0
  18. package/esm2015/lib/components/tables/tree-table/flattened-tree-list-model.js.map +1 -0
  19. package/esm2015/lib/components/tables/tree-table/flattened-tree-list-model.metadata.json +1 -0
  20. package/esm2015/lib/components/tables/tree-table/tree-expansion-model.js +9 -8
  21. package/esm2015/lib/components/tables/tree-table/tree-expansion-model.js.map +1 -1
  22. package/esm2015/lib/components/tables/tree-table/tree-inheritance-icon/tree-inheritance-icon.component.js.map +1 -1
  23. package/esm2015/lib/components/tables/tree-table/tree-inheritance-icon/tree-inheritance-icon.component.metadata.json +1 -1
  24. package/esm2015/lib/components/tables/tree-table/tree-label-cell-renderer/tree-label-cell-renderer.component.js +9 -9
  25. package/esm2015/lib/components/tables/tree-table/tree-label-cell-renderer/tree-label-cell-renderer.component.js.map +1 -1
  26. package/esm2015/lib/components/tables/tree-table/tree-label-cell-renderer/tree-label-cell-renderer.component.metadata.json +1 -1
  27. package/esm2015/lib/components/tables/tree-table/tree-label-column-model.js.map +1 -1
  28. package/esm2015/lib/components/tables/tree-table/tree-label-column-model.metadata.json +1 -1
  29. package/esm2015/lib/components/tables/tree-table/tree-table-component.js.map +1 -1
  30. package/esm2015/lib/components/tables/tree-table/tree-table-component.metadata.json +1 -1
  31. package/esm2015/lib/components/tables/tree-table/tree-table-model.js +9 -20
  32. package/esm2015/lib/components/tables/tree-table/tree-table-model.js.map +1 -1
  33. package/esm2015/lib/components/tables/tree-table/tree-table-model.metadata.json +1 -1
  34. package/fesm2015/coolon-angular-ui-powerups.js +240 -228
  35. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  36. package/lib/components/exports.d.ts +1 -1
  37. package/lib/components/tables/abstract-table-model.d.ts +6 -5
  38. package/lib/components/tables/table/table-model.d.ts +12 -7
  39. package/lib/components/tables/tree-table/decorated-tree-node.d.ts +26 -40
  40. package/lib/components/tables/tree-table/{tree-to-list-model.d.ts → flattened-tree-list-model.d.ts} +4 -4
  41. package/lib/components/tables/tree-table/tree-expansion-model.d.ts +10 -11
  42. package/lib/components/tables/tree-table/tree-inheritance-icon/tree-inheritance-icon.component.d.ts +1 -2
  43. package/lib/components/tables/tree-table/tree-label-cell-renderer/tree-label-cell-renderer.component.d.ts +5 -5
  44. package/lib/components/tables/tree-table/tree-label-column-model.d.ts +4 -6
  45. package/lib/components/tables/tree-table/tree-table-component.d.ts +2 -3
  46. package/lib/components/tables/tree-table/tree-table-model.d.ts +9 -8
  47. package/package.json +1 -1
  48. package/esm2015/lib/components/tables/tree-table/tree-to-list-model.js +0 -25
  49. package/esm2015/lib/components/tables/tree-table/tree-to-list-model.js.map +0 -1
  50. package/esm2015/lib/components/tables/tree-table/tree-to-list-model.metadata.json +0 -1
@@ -28,7 +28,7 @@ import * as _ from 'lodash';
28
28
  import ___default from 'lodash';
29
29
  import { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';
30
30
  import { Enum } from 'typescript-string-enums';
31
- import { assert as assert$1, Stringy, lang as lang$1, Mixin, Opts, Klass } from '@coolon/typescript-utilities';
31
+ import { assert as assert$1, Stringy, lang as lang$1, Opts, Klass } from '@coolon/typescript-utilities';
32
32
  import ResizeObserver from 'resize-observer-polyfill';
33
33
  import produce from 'immer';
34
34
  import { FlexModule, GridModule } from '@angular/flex-layout';
@@ -2810,9 +2810,9 @@ class RowClass {
2810
2810
  }
2811
2811
  }
2812
2812
  class AbstractTableModel extends GarbageCollector {
2813
- constructor(sourceOfTruth) {
2813
+ constructor() {
2814
2814
  super();
2815
- this.sourceOfTruth = sourceOfTruth;
2815
+ this._dataSource = new DelegatingListModel();
2816
2816
  this._columnList = this.registerDisposable(new ColumnListModel());
2817
2817
  this._editorSessions = new MutableListModel();
2818
2818
  this.rowClassNamePredicates = [];
@@ -2821,19 +2821,24 @@ class AbstractTableModel extends GarbageCollector {
2821
2821
  this.trackBy = (index, item) => {
2822
2822
  return this.identityOf ? this.identityOf(item) : index;
2823
2823
  };
2824
- this.identityOf = sourceOfTruth.identityOf;
2825
2824
  const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
2826
2825
  this._rowsBeingEdited = new MutableListModel([], {
2827
- identifiedWith: this.identityOf
2826
+ identifiedWith: row => this.identityOf(row)
2828
2827
  });
2829
2828
  this._editorSessionByRowId = chain(this._editorSessions).indexBy('rowId');
2830
2829
  this.editing = chain(this._editorSessions).count().isGreaterThan(0);
2831
- this.dataSource = chain(this.sourceOfTruth).replaceAll(this.rowsBeingEdited);
2830
+ this.dataSource = chain(this._dataSource).replaceAll(this.rowsBeingEdited);
2832
2831
  this.firstEditableColumn = chain(this.columns).select(c => c.hasEditorPortal()).first();
2833
2832
  this.firstVisibleColumn = chain(this._columnList).first();
2834
2833
  this.lastVisibleColumn = chain(this._columnList).last();
2835
2834
  this.rowSelectionDisabledOnAllColumns = chain(this._columnList).select(column => column.isRowSelectionEnabled()).count().equals(0);
2836
2835
  }
2836
+ setDataSource(sourceOfTruth) {
2837
+ this._dataSource.setDelegate(sourceOfTruth);
2838
+ }
2839
+ identityOf(row) {
2840
+ return this._dataSource.identityOf(row);
2841
+ }
2837
2842
  get rowsBeingEdited() {
2838
2843
  return this._rowsBeingEdited.readonly;
2839
2844
  }
@@ -3285,192 +3290,172 @@ TreeInheritanceIconComponent.propDecorators = {
3285
3290
  ];
3286
3291
  })(TreeInheritanceIconComponent || (TreeInheritanceIconComponent = {}));
3287
3292
 
3288
- class SelfAndDescendantsVisitor {
3289
- constructor() {
3290
- }
3291
- visit(it) {
3292
- this.onVisit(it);
3293
- if (this.shouldVisitChildrenOf(it)) {
3294
- it.visitChildren(this);
3295
- }
3296
- }
3297
- shouldVisitChildrenOf(it) {
3298
- return true;
3299
- }
3300
- }
3301
- (function (SelfAndDescendantsVisitor) {
3302
- class Each extends SelfAndDescendantsVisitor {
3303
- constructor(callback) {
3304
- super();
3305
- this.callback = callback;
3306
- }
3307
- onVisit(it) {
3308
- this.callback(it);
3309
- }
3310
- }
3311
- SelfAndDescendantsVisitor.Each = Each;
3312
- })(SelfAndDescendantsVisitor || (SelfAndDescendantsVisitor = {}));
3313
-
3314
- class DecoratedTreeNodeMixin {
3315
- constructor(parent, node) {
3316
- this.parent = parent;
3317
- this.node = node;
3318
- }
3319
- get decoratedSelf() {
3320
- return this.memoize('decoratedSelf', () => {
3321
- return this.parent ? this.parent.children.find(child => child.node === this.node) : DecoratedTreeNode.createRoot(this.node);
3322
- });
3323
- }
3324
- get children() {
3325
- return this.memoize('children', () => {
3326
- return this.node.children ? this.node.children.map(child => {
3327
- return Mixin.createProxy(child, new DecoratedTreeNodeMixin(this.decoratedSelf, child));
3328
- }) : [];
3329
- });
3330
- }
3331
- descendants() {
3332
- return this.memoize('descendants', () => {
3333
- const result = [];
3334
- this.visitDescendants(child => result.push(child));
3335
- return result;
3336
- });
3337
- }
3338
- selfAndDescendants() {
3339
- return this.memoize('selfAndDescendants', () => {
3340
- const result = [];
3341
- this.visitSelfAndDescendants(child => result.push(child));
3342
- return result;
3343
- });
3344
- }
3345
- siblingsBefore() {
3346
- return this.memoize('siblingsBefore', () => {
3293
+ const treeNodeDecorator = Symbol('TreeDecorator');
3294
+ var DecoratedTreeNode;
3295
+ (function (DecoratedTreeNode) {
3296
+ function decorateRoot(node, extractChildren) {
3297
+ return new Decorator(undefined, node, extractChildren).decoratedNode;
3298
+ }
3299
+ DecoratedTreeNode.decorateRoot = decorateRoot;
3300
+ function getDecorator(node) {
3301
+ assert.notNil(node[treeNodeDecorator]);
3302
+ return node[treeNodeDecorator];
3303
+ }
3304
+ DecoratedTreeNode.getDecorator = getDecorator;
3305
+ class Decorator {
3306
+ constructor(parent, node, extractChildren) {
3307
+ this.parent = parent;
3308
+ this.node = node;
3309
+ this.extractChildren = extractChildren;
3310
+ node[treeNodeDecorator] = this; // inject our decorator.
3311
+ }
3312
+ get children() {
3313
+ return this.extractChildren(this.node)
3314
+ .map(child => { var _a; return (_a = child[treeNodeDecorator]) !== null && _a !== void 0 ? _a : new Decorator(this.decoratedNode, child, this.extractChildren); })
3315
+ .map(d => d.decoratedNode);
3316
+ }
3317
+ get decoratedNode() {
3318
+ return this.node;
3319
+ }
3320
+ siblingsBefore() {
3347
3321
  if (this.parent) {
3348
- return this.parent.children.slice(0, this.myIndex());
3322
+ return this.parent[treeNodeDecorator].children.slice(0, this.myIndex());
3349
3323
  }
3350
3324
  else {
3351
3325
  return [];
3352
3326
  }
3353
- });
3354
- }
3355
- siblingsAfter() {
3356
- return this.memoize('siblingsAfter', () => {
3327
+ }
3328
+ siblingsAfter() {
3357
3329
  if (this.parent) {
3358
- return this.parent.children.slice(1 + this.myIndex());
3330
+ return this.parent[treeNodeDecorator].children.slice(1 + this.myIndex());
3359
3331
  }
3360
3332
  else {
3361
3333
  return [];
3362
3334
  }
3363
- });
3364
- }
3365
- siblings() {
3366
- return this.memoize('siblings', () => [].concat(this.siblingsBefore(), this.siblingsAfter()));
3367
- }
3368
- isFirstChild() {
3369
- return this.memoize('isFirstChild', () => this.parent ? this.myIndex() === 0 : false);
3370
- }
3371
- myIndex() {
3372
- return this.memoize('myIndex', () => {
3373
- const myIndex = this.parent.children.findIndex(child => child.node === this.node);
3335
+ }
3336
+ siblings() {
3337
+ return [].concat(this.siblingsBefore(), this.siblingsAfter());
3338
+ }
3339
+ isFirstChild() {
3340
+ return this.parent ? this.myIndex() === 0 : false;
3341
+ }
3342
+ myIndex() {
3343
+ const myIndex = this.parent[treeNodeDecorator].children.findIndex(child => this.node === child);
3374
3344
  assert.isTruthy(myIndex >= 0, 'illegal state, expected index to be >= 0');
3375
3345
  return myIndex;
3376
- });
3377
- }
3378
- isLastChild() {
3379
- return this.memoize('isLastChild', () => {
3380
- return this.parent ? this.myIndex() === this.parent.children.length - 1 : false;
3381
- });
3382
- }
3383
- hasSiblings() {
3384
- return this.parent ? this.node.children.length > 1 : false;
3385
- }
3386
- find(predicate) {
3387
- return _.find(this.descendants(), predicate);
3388
- }
3389
- select(predicate) {
3390
- return _.filter(this.descendants(), predicate);
3391
- }
3392
- flattenInto(array) {
3393
- this.visitSelfAndDescendants(child => array.push(child));
3394
- return array;
3395
- }
3396
- ancestors() {
3397
- return this.memoize('ancestors', () => {
3398
- return this.parent ? this.parent.ancestors().concat([this.parent]) : [];
3399
- });
3400
- }
3401
- ancestorsAndSelf() {
3402
- return this.memoize('ancestorsAndSelf', () => {
3403
- return this.ancestors().concat([(this.decoratedSelf)]);
3404
- });
3405
- }
3406
- pathToParent(parent) {
3407
- if (this.node === parent.node) {
3408
- return [];
3409
3346
  }
3410
- else if (this.parent) {
3411
- const pathToParent = this.parent.pathToParent(parent);
3412
- return pathToParent.concat([this.parent]);
3347
+ isLastChild() {
3348
+ return this.parent ? this.myIndex() === this.parent[treeNodeDecorator].children.length - 1 : false;
3413
3349
  }
3414
- else {
3415
- throw new Error('parent is not an ancestor');
3350
+ hasSiblings() {
3351
+ return this.parent ? this.parent[treeNodeDecorator].children.length > 1 : false;
3416
3352
  }
3417
- }
3418
- pathToParentAndSelf(parent) {
3419
- return this.pathToParent(parent).concat([this.decoratedSelf]);
3420
- }
3421
- isRoot() {
3422
- return !this.parent;
3423
- }
3424
- get depth() {
3425
- return this.isRoot() ? 0 : this.parent.depth + 1;
3426
- }
3427
- isLeaf() {
3428
- return !this.isRoot() && this.node.children.length < 1;
3429
- }
3430
- hasChildren() {
3431
- return this.node.children && this.node.children.length > 0;
3432
- }
3433
- depthFromParent(parent) {
3434
- return this.pathToParent(parent).length;
3435
- }
3436
- treeDepth() {
3437
- return this.memoize('treeDepth', () => {
3438
- return 1 + this.descendants().map(child => child.depthFromParent(this)).reduce((prev, current) => Math.max(prev, current));
3439
- });
3440
- }
3441
- flatten() {
3442
- return this.memoize('flatten', () => {
3443
- return this.flattenInto([]);
3444
- });
3445
- }
3446
- visit(visitor) {
3447
- visitor.visit(this);
3448
- return visitor;
3449
- }
3450
- visitChildren(visitor) {
3451
- _.each(this.children, child => child.visit(visitor));
3452
- return visitor;
3453
- }
3454
- visitSelfAndDescendants(callback) {
3455
- this.visit(new SelfAndDescendantsVisitor.Each(callback));
3456
- }
3457
- visitDescendants(callback) {
3458
- this.visitChildren(new SelfAndDescendantsVisitor.Each(callback));
3459
- }
3460
- memoize(property, factory) {
3461
- const key = `__${property}`;
3462
- if (_.isNil(this[key])) {
3463
- this[key] = factory();
3353
+ // find(predicate: Predicate<T>): T {
3354
+ // return _.find(this.descendants(), predicate);
3355
+ // }
3356
+ //
3357
+ // select(predicate: Predicate<T>): T[] {
3358
+ // return _.filter(this.descendants(), predicate);
3359
+ // }
3360
+ //
3361
+ // flattenInto(array: T[]): T[] {
3362
+ // this.visitSelfAndDescendants(child => array.push(child));
3363
+ // return array;
3364
+ // }
3365
+ ancestors() {
3366
+ return this.parent ? this.parent[treeNodeDecorator].ancestors().concat([this.parent]) : [];
3367
+ }
3368
+ // ancestorsAndSelf(): T[] {
3369
+ // return this.memoize('ancestorsAndSelf', () => {
3370
+ // return this.ancestors().concat([(this.decoratedSelf)]);
3371
+ // });
3372
+ // }
3373
+ // pathToParent(parent: T): T[] {
3374
+ // if (this.node === parent.node) {
3375
+ // return [];
3376
+ // } else if (this.parent) {
3377
+ // const pathToParent = this.parent.pathToParent(parent);
3378
+ // return pathToParent.concat([this.parent]);
3379
+ // } else {
3380
+ // throw new Error('parent is not an ancestor');
3381
+ // }
3382
+ // }
3383
+ //
3384
+ // pathToParentAndSelf(parent): T[] {
3385
+ // return this.pathToParent(parent).concat([this.decoratedSelf]);
3386
+ // }
3387
+ isRoot() {
3388
+ return !this.parent;
3389
+ }
3390
+ get depth() {
3391
+ return this.isRoot() ? 0 : this.parent[treeNodeDecorator].depth + 1;
3392
+ }
3393
+ isLeaf() {
3394
+ return !this.isRoot() && this.children.length < 1;
3395
+ }
3396
+ hasChildren() {
3397
+ return this.children.length > 0;
3464
3398
  }
3465
- return this[key];
3466
- }
3467
- }
3468
- var DecoratedTreeNode;
3469
- (function (DecoratedTreeNode) {
3470
- function createRoot(node) {
3471
- return Mixin.createProxy(node, new DecoratedTreeNodeMixin(undefined, node));
3472
3399
  }
3473
- DecoratedTreeNode.createRoot = createRoot;
3400
+ __decorate([
3401
+ Memoize(),
3402
+ __metadata("design:type", Array),
3403
+ __metadata("design:paramtypes", [])
3404
+ ], Decorator.prototype, "children", null);
3405
+ __decorate([
3406
+ Memoize(),
3407
+ __metadata("design:type", Function),
3408
+ __metadata("design:paramtypes", []),
3409
+ __metadata("design:returntype", Array)
3410
+ ], Decorator.prototype, "siblingsBefore", null);
3411
+ __decorate([
3412
+ Memoize(),
3413
+ __metadata("design:type", Function),
3414
+ __metadata("design:paramtypes", []),
3415
+ __metadata("design:returntype", Array)
3416
+ ], Decorator.prototype, "siblingsAfter", null);
3417
+ __decorate([
3418
+ Memoize(),
3419
+ __metadata("design:type", Function),
3420
+ __metadata("design:paramtypes", []),
3421
+ __metadata("design:returntype", Array)
3422
+ ], Decorator.prototype, "siblings", null);
3423
+ __decorate([
3424
+ Memoize(),
3425
+ __metadata("design:type", Function),
3426
+ __metadata("design:paramtypes", []),
3427
+ __metadata("design:returntype", Boolean)
3428
+ ], Decorator.prototype, "isFirstChild", null);
3429
+ __decorate([
3430
+ Memoize(),
3431
+ __metadata("design:type", Function),
3432
+ __metadata("design:paramtypes", []),
3433
+ __metadata("design:returntype", void 0)
3434
+ ], Decorator.prototype, "myIndex", null);
3435
+ __decorate([
3436
+ Memoize(),
3437
+ __metadata("design:type", Function),
3438
+ __metadata("design:paramtypes", []),
3439
+ __metadata("design:returntype", Boolean)
3440
+ ], Decorator.prototype, "isLastChild", null);
3441
+ __decorate([
3442
+ Memoize(),
3443
+ __metadata("design:type", Function),
3444
+ __metadata("design:paramtypes", []),
3445
+ __metadata("design:returntype", Boolean)
3446
+ ], Decorator.prototype, "hasSiblings", null);
3447
+ __decorate([
3448
+ Memoize(),
3449
+ __metadata("design:type", Function),
3450
+ __metadata("design:paramtypes", []),
3451
+ __metadata("design:returntype", Array)
3452
+ ], Decorator.prototype, "ancestors", null);
3453
+ __decorate([
3454
+ Memoize(),
3455
+ __metadata("design:type", Number),
3456
+ __metadata("design:paramtypes", [])
3457
+ ], Decorator.prototype, "depth", null);
3458
+ DecoratedTreeNode.Decorator = Decorator;
3474
3459
  })(DecoratedTreeNode || (DecoratedTreeNode = {}));
3475
3460
 
3476
3461
  class TreeExpansionModel {
@@ -3486,37 +3471,37 @@ class TreeExpansionModel {
3486
3471
  // @Trace()
3487
3472
  expand(node) {
3488
3473
  if (this.isCollapsed(node)) {
3489
- this.collapsedIds.delete(this.identityOf(node.node));
3474
+ this.collapsedIds.delete(this.identityOf(node));
3490
3475
  this.updatePredicate();
3491
3476
  }
3492
3477
  }
3493
3478
  // @Trace()
3494
3479
  collapse(node) {
3495
3480
  if (!this.isCollapsed(node)) {
3496
- this.collapsedIds.add(this.identityOf(node.node));
3481
+ this.collapsedIds.add(this.identityOf(node));
3497
3482
  this.updatePredicate();
3498
3483
  }
3499
3484
  }
3500
3485
  canExpand(node) {
3501
- return node.hasChildren() && this.isCollapsed(node);
3486
+ return DecoratedTreeNode.getDecorator(node).hasChildren() && this.isCollapsed(node);
3502
3487
  }
3503
3488
  canCollapse(node) {
3504
- return node.hasChildren() && !this.isCollapsed(node);
3489
+ return DecoratedTreeNode.getDecorator(node).hasChildren() && !this.isCollapsed(node);
3505
3490
  }
3506
3491
  isCollapsed(node) {
3507
- return this.collapsedIds.has(this.identityOf(node.node));
3492
+ return this.collapsedIds.has(this.identityOf(node));
3508
3493
  }
3509
3494
  isExpanded(node) {
3510
3495
  return !this.isCollapsed(node);
3511
3496
  }
3512
3497
  ensureAncestorsAndSelfVisible(node) {
3513
- node.ancestors()
3514
- .map(a => this.identityOf(node.node))
3498
+ DecoratedTreeNode.getDecorator(node).ancestors()
3499
+ .map(a => this.identityOf(node))
3515
3500
  .forEach(id => this.collapsedIds.delete(id));
3516
3501
  this.updatePredicate();
3517
3502
  }
3518
3503
  updatePredicate() {
3519
- this._isExpandedPredicate.value = (node) => !this.collapsedIds.has(this.identityOf(node.node));
3504
+ this._isExpandedPredicate.value = (node) => !this.collapsedIds.has(this.identityOf(node));
3520
3505
  }
3521
3506
  }
3522
3507
 
@@ -3556,11 +3541,11 @@ class TreeLabelCellRendererComponent extends DisposableComponent {
3556
3541
  this.nodeModel = new MutableValueModel();
3557
3542
  const { chain } = Dsl.disposeWith(this);
3558
3543
  this.iconList = chain(this.nodeModel).mapToList(node => {
3559
- const icons = node.ancestors().slice(1).map(ancestor => {
3560
- return ancestor.isLastChild() ? TreeInheritanceIconComponent.Type.ICON_BLANK : TreeInheritanceIconComponent.Type.ICON_THROUGH;
3544
+ const icons = DecoratedTreeNode.getDecorator(node).ancestors().slice(1).map(ancestor => {
3545
+ return DecoratedTreeNode.getDecorator(ancestor).isLastChild() ? TreeInheritanceIconComponent.Type.ICON_BLANK : TreeInheritanceIconComponent.Type.ICON_THROUGH;
3561
3546
  });
3562
- if (!node.isRoot()) {
3563
- icons.push(node.isLastChild() ? TreeInheritanceIconComponent.Type.ICON_INHERITED_TERMINAL : TreeInheritanceIconComponent.Type.ICON_INHERITED_THROUGH_TERMINAL);
3547
+ if (!DecoratedTreeNode.getDecorator(node).isRoot()) {
3548
+ icons.push(DecoratedTreeNode.getDecorator(node).isLastChild() ? TreeInheritanceIconComponent.Type.ICON_INHERITED_TERMINAL : TreeInheritanceIconComponent.Type.ICON_INHERITED_THROUGH_TERMINAL);
3564
3549
  }
3565
3550
  return icons;
3566
3551
  });
@@ -3568,20 +3553,20 @@ class TreeLabelCellRendererComponent extends DisposableComponent {
3568
3553
  ngOnInit() {
3569
3554
  const { chain } = Dsl.disposeWith(this);
3570
3555
  this.canExpand = chain(this.nodeModel).map(node => {
3571
- return node.hasChildren() && this.expansionModel.isCollapsed(node);
3556
+ return DecoratedTreeNode.getDecorator(node).hasChildren() && this.expansionModel.isCollapsed(node);
3572
3557
  }, { dependsOn: this.expansionModel.isExpandedPredicate });
3573
3558
  this.canCollapse = chain(this.nodeModel).map(node => {
3574
- return node.hasChildren() && !this.expansionModel.isCollapsed(node);
3559
+ return DecoratedTreeNode.getDecorator(node).hasChildren() && !this.expansionModel.isCollapsed(node);
3575
3560
  }, { dependsOn: this.expansionModel.isExpandedPredicate });
3576
3561
  this.iconModel = chain(this.nodeModel).map(node => {
3577
- return this.node.isLeaf() ? undefined : this.iconFactory(node, this.expansionModel.isExpanded(this.node));
3562
+ return DecoratedTreeNode.getDecorator(this.node).isLeaf() ? undefined : this.iconFactory(node, this.expansionModel.isExpanded(this.node));
3578
3563
  }, { dependsOn: this.expansionModel.isExpandedPredicate });
3579
3564
  }
3580
3565
  get isRoot() {
3581
- return this.node.isRoot();
3566
+ return DecoratedTreeNode.getDecorator(this.node).isRoot();
3582
3567
  }
3583
3568
  get isLeaf() {
3584
- return this.node.isLeaf();
3569
+ return DecoratedTreeNode.getDecorator(this.node).isLeaf();
3585
3570
  }
3586
3571
  get node() {
3587
3572
  return this.nodeModel.value;
@@ -3612,30 +3597,33 @@ __decorate([
3612
3597
  __metadata("design:type", Object)
3613
3598
  ], TreeLabelCellRendererComponent.prototype, "value", void 0);
3614
3599
 
3615
- class TreeToListModel extends ComputedListModel {
3616
- constructor(source, expansionModel) {
3600
+ class FlattenedTreeListModel extends ComputedListModel {
3601
+ constructor(source, childRef, expansionModel) {
3617
3602
  super(source);
3618
3603
  this.source = source;
3604
+ this.childRef = childRef;
3619
3605
  this.expansionModel = expansionModel;
3620
- this.trackSource(this.expansionModel.isExpandedPredicate);
3606
+ this.trackSource(expansionModel.isExpandedPredicate);
3621
3607
  }
3622
3608
  getIdentityOf(item) {
3623
- return this.source.identityOf(item.node);
3609
+ return this.source.identityOf(item);
3624
3610
  }
3625
3611
  compute(values) {
3626
3612
  const result = [];
3627
- values.forEach(value => this.addNodeAndVisibleChildren(DecoratedTreeNode.createRoot(value), result));
3613
+ values.forEach(rootNode => {
3614
+ return this.addNodeAndVisibleChildren(DecoratedTreeNode.decorateRoot(rootNode, this.childRef), result);
3615
+ });
3628
3616
  return result;
3629
3617
  }
3630
3618
  addNodeAndVisibleChildren(node, result) {
3631
3619
  result.push(node);
3632
- if (node.hasChildren() && !this.expansionModel.isCollapsed(node)) {
3633
- node.children.forEach(child => this.addNodeAndVisibleChildren(child, result));
3620
+ const decorator = node[treeNodeDecorator];
3621
+ if (decorator.hasChildren() && !this.expansionModel.isCollapsed(node)) {
3622
+ decorator.children.forEach(child => this.addNodeAndVisibleChildren(child, result));
3634
3623
  }
3635
3624
  }
3636
3625
  }
3637
3626
 
3638
- // import {T } from '@client/api/light-architect/model/area/area.class';
3639
3627
  // TODO:
3640
3628
  // Selection Models:
3641
3629
  // - as simple navigation tree
@@ -3647,22 +3635,14 @@ class TreeToListModel extends ComputedListModel {
3647
3635
  // - Add a predicate to check default expansion (i.e. has children of a certain type)
3648
3636
  //
3649
3637
  class TreeTableModel extends AbstractTableModel {
3650
- constructor(source, treeExpansionModel) {
3651
- super(source);
3652
- this.treeExpansionModel = treeExpansionModel;
3653
- }
3654
- static fromList(sourceOfTruth, builder) {
3655
- return TreeTableModel._create(TreeTableModel, sourceOfTruth, builder);
3656
- }
3657
- static _create(klass, sourceOfTruth, builder) {
3658
- const treeExpansionModel = new TreeExpansionModel(sourceOfTruth.identityOf);
3659
- const garbage = new GarbageCollector();
3660
- const nodes = garbage.registerDisposable(new TreeToListModel(sourceOfTruth, treeExpansionModel));
3661
- const model = new klass(nodes, treeExpansionModel);
3662
- model.registerDisposable(garbage);
3638
+ constructor(source, childAccessor, builder) {
3639
+ super();
3640
+ this.treeExpansionModel = new TreeExpansionModel(row => this.identityOf(row));
3663
3641
  if (builder)
3664
- builder(model);
3665
- return model;
3642
+ builder(this);
3643
+ const childExtractor = _.isFunction(childAccessor) ? childAccessor : row => row[childAccessor];
3644
+ this.flattenedDataSource = this.registerDisposable(new FlattenedTreeListModel(source, childExtractor, this.treeExpansionModel));
3645
+ this.setDataSource(this.flattenedDataSource);
3666
3646
  }
3667
3647
  treeControlColumn(builder) {
3668
3648
  const columnId = 'tree-label';
@@ -5357,7 +5337,7 @@ SelectInputActivity.decorators = [
5357
5337
  /**
5358
5338
  * Example:
5359
5339
  * @example
5360
- * const model = TableModel.fromList(heroList, table => {
5340
+ * const model = new TableModel(heroList, table => {
5361
5341
  * table.pluck("firstName");
5362
5342
  * table.pluck("lastName");
5363
5343
  * table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
@@ -5389,7 +5369,7 @@ SelectInputActivity.decorators = [
5389
5369
  *
5390
5370
  * Selection models
5391
5371
  * @example
5392
- * const model = TableModel.fromList(heroList, table => {
5372
+ * const model = new TableModel(heroList, table => {
5393
5373
  * table.addSelectionColumn(selectionModel); // <- can be single or multiple selection model
5394
5374
  * table.pluck("firstName");
5395
5375
  * table.pluck("lastName");
@@ -5397,7 +5377,7 @@ SelectInputActivity.decorators = [
5397
5377
  *
5398
5378
  * Custom cell renderers and editors
5399
5379
  * @example
5400
- * const model = TableModel.fromList(heroList, table => {
5380
+ * const model = new TableModel(heroList, table => {
5401
5381
  * table.pluck("favoriteColor")
5402
5382
  * .cellHeaderRenderer(CellHeaderRendererComponent, (component, column) => {
5403
5383
  * // configure your component with what ever you need.
@@ -5409,7 +5389,7 @@ SelectInputActivity.decorators = [
5409
5389
  *
5410
5390
  * Template columns
5411
5391
  * @example
5412
- * const model = TableModel.fromList(heroList, table => {
5392
+ * const model = new TableModel(heroList, table => {
5413
5393
  * table.addSelectionColumn(selectionModel); // <- can be single or multiple selection model
5414
5394
  * table.addTemplateColumn("myTemplate");
5415
5395
  * });
@@ -5426,7 +5406,7 @@ SelectInputActivity.decorators = [
5426
5406
  * fullName:
5427
5407
  * headerText: "Full Name"
5428
5408
  *
5429
- * const model = TableModel.fromList(heroList, table => {
5409
+ * const model = new TableModel(heroList, table => {
5430
5410
  * table.pluck("favoriteColor").cellRenderer(...).cellEditor(...);
5431
5411
  * table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
5432
5412
  *
@@ -5434,20 +5414,52 @@ SelectInputActivity.decorators = [
5434
5414
  * });
5435
5415
  */
5436
5416
  class TableModel extends AbstractTableModel {
5437
- static fromList(sourceOfTruth, builder) {
5438
- return TableModel._create(TableModel, sourceOfTruth, builder);
5417
+ constructor(sourceOfTruth, builder) {
5418
+ super();
5419
+ if (builder) {
5420
+ builder(this);
5421
+ }
5422
+ this.setDataSource(sourceOfTruth);
5439
5423
  }
5440
- static _create(klass, sourceOfTruth, builder) {
5441
- const model = new klass(sourceOfTruth);
5442
- if (builder)
5443
- builder(model);
5444
- return model;
5424
+ /**
5425
+ * @deprecated use new TableModel(sourceOfTruth, table => {...}); instead.
5426
+ * @param sourceOfTruth
5427
+ * @param builder
5428
+ */
5429
+ static fromList(sourceOfTruth, builder) {
5430
+ return new TableModel(sourceOfTruth, builder);
5445
5431
  }
5446
5432
  addSelectionColumn(selectionModel, showSelectionColumn) {
5447
5433
  return this._addSelectionColumn(selectionModel, showSelectionColumn);
5448
5434
  }
5449
5435
  }
5450
5436
 
5437
+ class SelfAndDescendantsVisitor {
5438
+ constructor() {
5439
+ }
5440
+ visit(it) {
5441
+ this.onVisit(it);
5442
+ if (this.shouldVisitChildrenOf(it)) {
5443
+ it.visitChildren(this);
5444
+ }
5445
+ }
5446
+ shouldVisitChildrenOf(it) {
5447
+ return true;
5448
+ }
5449
+ }
5450
+ (function (SelfAndDescendantsVisitor) {
5451
+ class Each extends SelfAndDescendantsVisitor {
5452
+ constructor(callback) {
5453
+ super();
5454
+ this.callback = callback;
5455
+ }
5456
+ onVisit(it) {
5457
+ this.callback(it);
5458
+ }
5459
+ }
5460
+ SelfAndDescendantsVisitor.Each = Each;
5461
+ })(SelfAndDescendantsVisitor || (SelfAndDescendantsVisitor = {}));
5462
+
5451
5463
  /**
5452
5464
  * @file Automatically generated by barrelsby.
5453
5465
  */
@@ -8386,5 +8398,5 @@ VisibilityService.ctorParameters = () => [
8386
8398
  * Generated bundle index. Do not edit.
8387
8399
  */
8388
8400
 
8389
- export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AUP_UNAUTHORISED_PLACE_NOTICE_COMPONENT, AbstractActivityTriggerComponent, AbstractInputActivity, AbstractInputComponent, AbstractInteractionContext, AbstractListInputComponent, AbstractPlaceNavigationComponent, AbstractPopStateNavigation, AbstractPopupMenuComponent, AbstractTableComponent, AbstractTableModel, AbstractValueInputComponent, Activity, ActivityActionsComponent, ActivityBodyComponent, ActivityContainerComponent, ActivityOutletComponent, ActivityRef, ActivityTitleComponent, AddItemInteractionContextComponent, AlertDialogComponent, AngularUiPowerupsModule, AutocompleteInputComponent, Bounds, BusyOverlayComponent, CELL_EDITOR_PORTAL, CELL_RENDERER_PORTAL, CardContainerComponent, CellEditorPortalRef, CellHeaderPortalRef, CellPortalRef, CellRendererPortalRef, CheckboxInputComponent, ColumnListModel, ColumnModel, ColumnTemplateDirective, CommandComponent, CommandContainer, CommandDirective, CommandFace, CommandFaceComponent, ComponentCellRendererPortalRef, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, CustomTemplateColumnModel, CustomValueColumnModel, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DecoratedTreeNode, DefaultCellRendererComponent, DefaultHeaderCellRendererComponent, DialogInteractionContext, DialogInteractionContextFactory, Dimension, DirectivesModule, DisposableComponent, EditRowControls, EditSession, EditorControlColumnModel, EmptyStateComponent, EventCleanUpSession, FlexComponent, FocusBinding, FocusBindingDirective, FocusBindingFactory, FocusContainerComponent, FocusableComponent, Formatter, HEADER_CELL_RENDERER_PORTAL, HighlightPipe, HighlightTextModelDirective, HorizontalAlignment, IconComponent, InPlaceInteractionContextComponent, InlineActivityTriggerComponent, InteractionContextTriggerFor, InteractionModule, InteractionService, InteractionServiceRoutingAdapter, LEFT_RIGHT_PLACE_ANIMATION, ListPlaceNavComponent, ListPropertyColumnModel, ModalActivityTriggerComponent, ModalInteractionContextFactory, MoreMenuComponent, MultipleSelectInputComponent, Navigating, NavigatingDuringInteraction, NavigationContext, NavigationSession, NoopAuthGuard, NoopComponent, NotAuthorisedNoticeComponent, NumberInputComponent, POPUP_CONTAINER, PORTAL_EDITOR_COMPONENT, PORTAL_RENDERER_COMPONENT, PaginatorComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceAccessGuard, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceGuard, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, PopStateDuringInteractionNavigation, PopStateNavigation, PopupActivityTriggerComponent, PopupAwareComponent, PopupInteractionContextComponent, PopupMenuComponent, PopupMenuRendererComponent, PropertyColumnModel, ROUTE_PARAMETER_LIST_KEY, RemoveLastInteractionFromUrlNavigationSession, ResizeAwareComponent, RouteId, ScrollContainerComponent, SectionHeaderComponent, SelectCellRendererComponent, SelectHeaderCellRendererComponent, SelectInputActivity, SelectInputComponent, SelectionColumnModel, SelfAndDescendantsVisitor, SeparatorComponent, SidePlaceNavigationComponent, StringInputActivity, StringInputComponent, SwitchCaseComponent, SwitchCaseDefaultDirective, SwitchCaseOption, SwitchCaseWhenDirective, SynchroniseInteractionContextIdsWithRoute, TabbedPlaceNavigationComponent, TableCellRendererComponent, TableComponent, TableHeaderCellRendererComponent, TableModel, TableRowMenuComponent, TemplateCellRendererPortalRef, TextInputComponent, ToolBarComponent, TrackBy, TreeExpansionModel, TreeInheritanceIconComponent, TreeLabelCellRendererComponent, TreeLabelColumnModel, TreeTableComponent, TreeTableModel, TreeToListModel, UrlService, UrlSnapshot, VerticalFocusContainerComponent, VisibilityService, Visit, VisitParameter, VisitParameterList, VisitSanitiser, WaitUntilLeavingInteractionTransitionCancelled, WaitUntilLinkTriggeredNavigationInteractionCancellationTypeDetermined, WaitUntilPopStateDuringCanDeactivateInteractionFinishes, leftRightPlaceAnimation, slideDownOnEnterAnimation, slideRightOnEnterAnimation, ɵ0 };
8401
+ export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AUP_UNAUTHORISED_PLACE_NOTICE_COMPONENT, AbstractActivityTriggerComponent, AbstractInputActivity, AbstractInputComponent, AbstractInteractionContext, AbstractListInputComponent, AbstractPlaceNavigationComponent, AbstractPopStateNavigation, AbstractPopupMenuComponent, AbstractTableComponent, AbstractTableModel, AbstractValueInputComponent, Activity, ActivityActionsComponent, ActivityBodyComponent, ActivityContainerComponent, ActivityOutletComponent, ActivityRef, ActivityTitleComponent, AddItemInteractionContextComponent, AlertDialogComponent, AngularUiPowerupsModule, AutocompleteInputComponent, Bounds, BusyOverlayComponent, CELL_EDITOR_PORTAL, CELL_RENDERER_PORTAL, CardContainerComponent, CellEditorPortalRef, CellHeaderPortalRef, CellPortalRef, CellRendererPortalRef, CheckboxInputComponent, ColumnListModel, ColumnModel, ColumnTemplateDirective, CommandComponent, CommandContainer, CommandDirective, CommandFace, CommandFaceComponent, ComponentCellRendererPortalRef, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, CustomTemplateColumnModel, CustomValueColumnModel, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DecoratedTreeNode, DefaultCellRendererComponent, DefaultHeaderCellRendererComponent, DialogInteractionContext, DialogInteractionContextFactory, Dimension, DirectivesModule, DisposableComponent, EditRowControls, EditSession, EditorControlColumnModel, EmptyStateComponent, EventCleanUpSession, FlattenedTreeListModel, FlexComponent, FocusBinding, FocusBindingDirective, FocusBindingFactory, FocusContainerComponent, FocusableComponent, Formatter, HEADER_CELL_RENDERER_PORTAL, HighlightPipe, HighlightTextModelDirective, HorizontalAlignment, IconComponent, InPlaceInteractionContextComponent, InlineActivityTriggerComponent, InteractionContextTriggerFor, InteractionModule, InteractionService, InteractionServiceRoutingAdapter, LEFT_RIGHT_PLACE_ANIMATION, ListPlaceNavComponent, ListPropertyColumnModel, ModalActivityTriggerComponent, ModalInteractionContextFactory, MoreMenuComponent, MultipleSelectInputComponent, Navigating, NavigatingDuringInteraction, NavigationContext, NavigationSession, NoopAuthGuard, NoopComponent, NotAuthorisedNoticeComponent, NumberInputComponent, POPUP_CONTAINER, PORTAL_EDITOR_COMPONENT, PORTAL_RENDERER_COMPONENT, PaginatorComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceAccessGuard, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceGuard, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, PopStateDuringInteractionNavigation, PopStateNavigation, PopupActivityTriggerComponent, PopupAwareComponent, PopupInteractionContextComponent, PopupMenuComponent, PopupMenuRendererComponent, PropertyColumnModel, ROUTE_PARAMETER_LIST_KEY, RemoveLastInteractionFromUrlNavigationSession, ResizeAwareComponent, RouteId, ScrollContainerComponent, SectionHeaderComponent, SelectCellRendererComponent, SelectHeaderCellRendererComponent, SelectInputActivity, SelectInputComponent, SelectionColumnModel, SelfAndDescendantsVisitor, SeparatorComponent, SidePlaceNavigationComponent, StringInputActivity, StringInputComponent, SwitchCaseComponent, SwitchCaseDefaultDirective, SwitchCaseOption, SwitchCaseWhenDirective, SynchroniseInteractionContextIdsWithRoute, TabbedPlaceNavigationComponent, TableCellRendererComponent, TableComponent, TableHeaderCellRendererComponent, TableModel, TableRowMenuComponent, TemplateCellRendererPortalRef, TextInputComponent, ToolBarComponent, TrackBy, TreeExpansionModel, TreeInheritanceIconComponent, TreeLabelCellRendererComponent, TreeLabelColumnModel, TreeTableComponent, TreeTableModel, UrlService, UrlSnapshot, VerticalFocusContainerComponent, VisibilityService, Visit, VisitParameter, VisitParameterList, VisitSanitiser, WaitUntilLeavingInteractionTransitionCancelled, WaitUntilLinkTriggeredNavigationInteractionCancellationTypeDetermined, WaitUntilPopStateDuringCanDeactivateInteractionFinishes, leftRightPlaceAnimation, slideDownOnEnterAnimation, slideRightOnEnterAnimation, treeNodeDecorator, ɵ0 };
8390
8402
  //# sourceMappingURL=coolon-angular-ui-powerups.js.map