@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
@@ -3631,9 +3631,9 @@
3631
3631
  }());
3632
3632
  var AbstractTableModel = /** @class */ (function (_super) {
3633
3633
  __extends(AbstractTableModel, _super);
3634
- function AbstractTableModel(sourceOfTruth) {
3634
+ function AbstractTableModel() {
3635
3635
  var _this = _super.call(this) || this;
3636
- _this.sourceOfTruth = sourceOfTruth;
3636
+ _this._dataSource = new pectin.DelegatingListModel();
3637
3637
  _this._columnList = _this.registerDisposable(new ColumnListModel());
3638
3638
  _this._editorSessions = new pectin.MutableListModel();
3639
3639
  _this.rowClassNamePredicates = [];
@@ -3642,20 +3642,25 @@
3642
3642
  _this.trackBy = function (index, item) {
3643
3643
  return _this.identityOf ? _this.identityOf(item) : index;
3644
3644
  };
3645
- _this.identityOf = sourceOfTruth.identityOf;
3646
3645
  var _b = pectin.Dsl.disposeWith(_this), chain = _b.chain, valueOf = _b.valueOf, before = _b.before, when = _b.when, after = _b.after, observe = _b.observe, switchOn = _b.switchOn;
3647
3646
  _this._rowsBeingEdited = new pectin.MutableListModel([], {
3648
- identifiedWith: _this.identityOf
3647
+ identifiedWith: function (row) { return _this.identityOf(row); }
3649
3648
  });
3650
3649
  _this._editorSessionByRowId = chain(_this._editorSessions).indexBy('rowId');
3651
3650
  _this.editing = chain(_this._editorSessions).count().isGreaterThan(0);
3652
- _this.dataSource = chain(_this.sourceOfTruth).replaceAll(_this.rowsBeingEdited);
3651
+ _this.dataSource = chain(_this._dataSource).replaceAll(_this.rowsBeingEdited);
3653
3652
  _this.firstEditableColumn = chain(_this.columns).select(function (c) { return c.hasEditorPortal(); }).first();
3654
3653
  _this.firstVisibleColumn = chain(_this._columnList).first();
3655
3654
  _this.lastVisibleColumn = chain(_this._columnList).last();
3656
3655
  _this.rowSelectionDisabledOnAllColumns = chain(_this._columnList).select(function (column) { return column.isRowSelectionEnabled(); }).count().equals(0);
3657
3656
  return _this;
3658
3657
  }
3658
+ AbstractTableModel.prototype.setDataSource = function (sourceOfTruth) {
3659
+ this._dataSource.setDelegate(sourceOfTruth);
3660
+ };
3661
+ AbstractTableModel.prototype.identityOf = function (row) {
3662
+ return this._dataSource.identityOf(row);
3663
+ };
3659
3664
  Object.defineProperty(AbstractTableModel.prototype, "rowsBeingEdited", {
3660
3665
  get: function () {
3661
3666
  return this._rowsBeingEdited.readonly;
@@ -3975,6 +3980,189 @@
3975
3980
  ];
3976
3981
  })(exports.TreeInheritanceIconComponent || (exports.TreeInheritanceIconComponent = {}));
3977
3982
 
3983
+ var treeNodeDecorator = Symbol('TreeDecorator');
3984
+ exports.DecoratedTreeNode = void 0;
3985
+ (function (DecoratedTreeNode) {
3986
+ function decorateRoot(node, extractChildren) {
3987
+ return new Decorator(undefined, node, extractChildren).decoratedNode;
3988
+ }
3989
+ DecoratedTreeNode.decorateRoot = decorateRoot;
3990
+ function getDecorator(node) {
3991
+ pectin.assert.notNil(node[treeNodeDecorator]);
3992
+ return node[treeNodeDecorator];
3993
+ }
3994
+ DecoratedTreeNode.getDecorator = getDecorator;
3995
+ var Decorator = /** @class */ (function () {
3996
+ function Decorator(parent, node, extractChildren) {
3997
+ this.parent = parent;
3998
+ this.node = node;
3999
+ this.extractChildren = extractChildren;
4000
+ node[treeNodeDecorator] = this; // inject our decorator.
4001
+ }
4002
+ Object.defineProperty(Decorator.prototype, "children", {
4003
+ get: function () {
4004
+ var _this = this;
4005
+ return this.extractChildren(this.node)
4006
+ .map(function (child) { var _a; return (_a = child[treeNodeDecorator]) !== null && _a !== void 0 ? _a : new Decorator(_this.decoratedNode, child, _this.extractChildren); })
4007
+ .map(function (d) { return d.decoratedNode; });
4008
+ },
4009
+ enumerable: false,
4010
+ configurable: true
4011
+ });
4012
+ Object.defineProperty(Decorator.prototype, "decoratedNode", {
4013
+ get: function () {
4014
+ return this.node;
4015
+ },
4016
+ enumerable: false,
4017
+ configurable: true
4018
+ });
4019
+ Decorator.prototype.siblingsBefore = function () {
4020
+ if (this.parent) {
4021
+ return this.parent[treeNodeDecorator].children.slice(0, this.myIndex());
4022
+ }
4023
+ else {
4024
+ return [];
4025
+ }
4026
+ };
4027
+ Decorator.prototype.siblingsAfter = function () {
4028
+ if (this.parent) {
4029
+ return this.parent[treeNodeDecorator].children.slice(1 + this.myIndex());
4030
+ }
4031
+ else {
4032
+ return [];
4033
+ }
4034
+ };
4035
+ Decorator.prototype.siblings = function () {
4036
+ return [].concat(this.siblingsBefore(), this.siblingsAfter());
4037
+ };
4038
+ Decorator.prototype.isFirstChild = function () {
4039
+ return this.parent ? this.myIndex() === 0 : false;
4040
+ };
4041
+ Decorator.prototype.myIndex = function () {
4042
+ var _this = this;
4043
+ var myIndex = this.parent[treeNodeDecorator].children.findIndex(function (child) { return _this.node === child; });
4044
+ pectin.assert.isTruthy(myIndex >= 0, 'illegal state, expected index to be >= 0');
4045
+ return myIndex;
4046
+ };
4047
+ Decorator.prototype.isLastChild = function () {
4048
+ return this.parent ? this.myIndex() === this.parent[treeNodeDecorator].children.length - 1 : false;
4049
+ };
4050
+ Decorator.prototype.hasSiblings = function () {
4051
+ return this.parent ? this.parent[treeNodeDecorator].children.length > 1 : false;
4052
+ };
4053
+ // find(predicate: Predicate<T>): T {
4054
+ // return _.find(this.descendants(), predicate);
4055
+ // }
4056
+ //
4057
+ // select(predicate: Predicate<T>): T[] {
4058
+ // return _.filter(this.descendants(), predicate);
4059
+ // }
4060
+ //
4061
+ // flattenInto(array: T[]): T[] {
4062
+ // this.visitSelfAndDescendants(child => array.push(child));
4063
+ // return array;
4064
+ // }
4065
+ Decorator.prototype.ancestors = function () {
4066
+ return this.parent ? this.parent[treeNodeDecorator].ancestors().concat([this.parent]) : [];
4067
+ };
4068
+ // ancestorsAndSelf(): T[] {
4069
+ // return this.memoize('ancestorsAndSelf', () => {
4070
+ // return this.ancestors().concat([(this.decoratedSelf)]);
4071
+ // });
4072
+ // }
4073
+ // pathToParent(parent: T): T[] {
4074
+ // if (this.node === parent.node) {
4075
+ // return [];
4076
+ // } else if (this.parent) {
4077
+ // const pathToParent = this.parent.pathToParent(parent);
4078
+ // return pathToParent.concat([this.parent]);
4079
+ // } else {
4080
+ // throw new Error('parent is not an ancestor');
4081
+ // }
4082
+ // }
4083
+ //
4084
+ // pathToParentAndSelf(parent): T[] {
4085
+ // return this.pathToParent(parent).concat([this.decoratedSelf]);
4086
+ // }
4087
+ Decorator.prototype.isRoot = function () {
4088
+ return !this.parent;
4089
+ };
4090
+ Object.defineProperty(Decorator.prototype, "depth", {
4091
+ get: function () {
4092
+ return this.isRoot() ? 0 : this.parent[treeNodeDecorator].depth + 1;
4093
+ },
4094
+ enumerable: false,
4095
+ configurable: true
4096
+ });
4097
+ Decorator.prototype.isLeaf = function () {
4098
+ return !this.isRoot() && this.children.length < 1;
4099
+ };
4100
+ Decorator.prototype.hasChildren = function () {
4101
+ return this.children.length > 0;
4102
+ };
4103
+ return Decorator;
4104
+ }());
4105
+ __decorate([
4106
+ src.Memoize(),
4107
+ __metadata("design:type", Array),
4108
+ __metadata("design:paramtypes", [])
4109
+ ], Decorator.prototype, "children", null);
4110
+ __decorate([
4111
+ src.Memoize(),
4112
+ __metadata("design:type", Function),
4113
+ __metadata("design:paramtypes", []),
4114
+ __metadata("design:returntype", Array)
4115
+ ], Decorator.prototype, "siblingsBefore", null);
4116
+ __decorate([
4117
+ src.Memoize(),
4118
+ __metadata("design:type", Function),
4119
+ __metadata("design:paramtypes", []),
4120
+ __metadata("design:returntype", Array)
4121
+ ], Decorator.prototype, "siblingsAfter", null);
4122
+ __decorate([
4123
+ src.Memoize(),
4124
+ __metadata("design:type", Function),
4125
+ __metadata("design:paramtypes", []),
4126
+ __metadata("design:returntype", Array)
4127
+ ], Decorator.prototype, "siblings", null);
4128
+ __decorate([
4129
+ src.Memoize(),
4130
+ __metadata("design:type", Function),
4131
+ __metadata("design:paramtypes", []),
4132
+ __metadata("design:returntype", Boolean)
4133
+ ], Decorator.prototype, "isFirstChild", null);
4134
+ __decorate([
4135
+ src.Memoize(),
4136
+ __metadata("design:type", Function),
4137
+ __metadata("design:paramtypes", []),
4138
+ __metadata("design:returntype", void 0)
4139
+ ], Decorator.prototype, "myIndex", null);
4140
+ __decorate([
4141
+ src.Memoize(),
4142
+ __metadata("design:type", Function),
4143
+ __metadata("design:paramtypes", []),
4144
+ __metadata("design:returntype", Boolean)
4145
+ ], Decorator.prototype, "isLastChild", null);
4146
+ __decorate([
4147
+ src.Memoize(),
4148
+ __metadata("design:type", Function),
4149
+ __metadata("design:paramtypes", []),
4150
+ __metadata("design:returntype", Boolean)
4151
+ ], Decorator.prototype, "hasSiblings", null);
4152
+ __decorate([
4153
+ src.Memoize(),
4154
+ __metadata("design:type", Function),
4155
+ __metadata("design:paramtypes", []),
4156
+ __metadata("design:returntype", Array)
4157
+ ], Decorator.prototype, "ancestors", null);
4158
+ __decorate([
4159
+ src.Memoize(),
4160
+ __metadata("design:type", Number),
4161
+ __metadata("design:paramtypes", [])
4162
+ ], Decorator.prototype, "depth", null);
4163
+ DecoratedTreeNode.Decorator = Decorator;
4164
+ })(exports.DecoratedTreeNode || (exports.DecoratedTreeNode = {}));
4165
+
3978
4166
  var TreeLabelCellRendererComponent = /** @class */ (function (_super) {
3979
4167
  __extends(TreeLabelCellRendererComponent, _super);
3980
4168
  function TreeLabelCellRendererComponent() {
@@ -3983,11 +4171,11 @@
3983
4171
  _this.nodeModel = new pectin.MutableValueModel();
3984
4172
  var chain = pectin.Dsl.disposeWith(_this).chain;
3985
4173
  _this.iconList = chain(_this.nodeModel).mapToList(function (node) {
3986
- var icons = node.ancestors().slice(1).map(function (ancestor) {
3987
- return ancestor.isLastChild() ? exports.TreeInheritanceIconComponent.Type.ICON_BLANK : exports.TreeInheritanceIconComponent.Type.ICON_THROUGH;
4174
+ var icons = exports.DecoratedTreeNode.getDecorator(node).ancestors().slice(1).map(function (ancestor) {
4175
+ return exports.DecoratedTreeNode.getDecorator(ancestor).isLastChild() ? exports.TreeInheritanceIconComponent.Type.ICON_BLANK : exports.TreeInheritanceIconComponent.Type.ICON_THROUGH;
3988
4176
  });
3989
- if (!node.isRoot()) {
3990
- icons.push(node.isLastChild() ? exports.TreeInheritanceIconComponent.Type.ICON_INHERITED_TERMINAL : exports.TreeInheritanceIconComponent.Type.ICON_INHERITED_THROUGH_TERMINAL);
4177
+ if (!exports.DecoratedTreeNode.getDecorator(node).isRoot()) {
4178
+ icons.push(exports.DecoratedTreeNode.getDecorator(node).isLastChild() ? exports.TreeInheritanceIconComponent.Type.ICON_INHERITED_TERMINAL : exports.TreeInheritanceIconComponent.Type.ICON_INHERITED_THROUGH_TERMINAL);
3991
4179
  }
3992
4180
  return icons;
3993
4181
  });
@@ -3997,25 +4185,25 @@
3997
4185
  var _this = this;
3998
4186
  var chain = pectin.Dsl.disposeWith(this).chain;
3999
4187
  this.canExpand = chain(this.nodeModel).map(function (node) {
4000
- return node.hasChildren() && _this.expansionModel.isCollapsed(node);
4188
+ return exports.DecoratedTreeNode.getDecorator(node).hasChildren() && _this.expansionModel.isCollapsed(node);
4001
4189
  }, { dependsOn: this.expansionModel.isExpandedPredicate });
4002
4190
  this.canCollapse = chain(this.nodeModel).map(function (node) {
4003
- return node.hasChildren() && !_this.expansionModel.isCollapsed(node);
4191
+ return exports.DecoratedTreeNode.getDecorator(node).hasChildren() && !_this.expansionModel.isCollapsed(node);
4004
4192
  }, { dependsOn: this.expansionModel.isExpandedPredicate });
4005
4193
  this.iconModel = chain(this.nodeModel).map(function (node) {
4006
- return _this.node.isLeaf() ? undefined : _this.iconFactory(node, _this.expansionModel.isExpanded(_this.node));
4194
+ return exports.DecoratedTreeNode.getDecorator(_this.node).isLeaf() ? undefined : _this.iconFactory(node, _this.expansionModel.isExpanded(_this.node));
4007
4195
  }, { dependsOn: this.expansionModel.isExpandedPredicate });
4008
4196
  };
4009
4197
  Object.defineProperty(TreeLabelCellRendererComponent.prototype, "isRoot", {
4010
4198
  get: function () {
4011
- return this.node.isRoot();
4199
+ return exports.DecoratedTreeNode.getDecorator(this.node).isRoot();
4012
4200
  },
4013
4201
  enumerable: false,
4014
4202
  configurable: true
4015
4203
  });
4016
4204
  Object.defineProperty(TreeLabelCellRendererComponent.prototype, "isLeaf", {
4017
4205
  get: function () {
4018
- return this.node.isLeaf();
4206
+ return exports.DecoratedTreeNode.getDecorator(this.node).isLeaf();
4019
4207
  },
4020
4208
  enumerable: false,
4021
4209
  configurable: true
@@ -4054,6 +4242,38 @@
4054
4242
  __metadata("design:type", Object)
4055
4243
  ], TreeLabelCellRendererComponent.prototype, "value", void 0);
4056
4244
 
4245
+ var FlattenedTreeListModel = /** @class */ (function (_super) {
4246
+ __extends(FlattenedTreeListModel, _super);
4247
+ function FlattenedTreeListModel(source, childRef, expansionModel) {
4248
+ var _this = _super.call(this, source) || this;
4249
+ _this.source = source;
4250
+ _this.childRef = childRef;
4251
+ _this.expansionModel = expansionModel;
4252
+ _this.trackSource(expansionModel.isExpandedPredicate);
4253
+ return _this;
4254
+ }
4255
+ FlattenedTreeListModel.prototype.getIdentityOf = function (item) {
4256
+ return this.source.identityOf(item);
4257
+ };
4258
+ FlattenedTreeListModel.prototype.compute = function (values) {
4259
+ var _this = this;
4260
+ var result = [];
4261
+ values.forEach(function (rootNode) {
4262
+ return _this.addNodeAndVisibleChildren(exports.DecoratedTreeNode.decorateRoot(rootNode, _this.childRef), result);
4263
+ });
4264
+ return result;
4265
+ };
4266
+ FlattenedTreeListModel.prototype.addNodeAndVisibleChildren = function (node, result) {
4267
+ var _this = this;
4268
+ result.push(node);
4269
+ var decorator = node[treeNodeDecorator];
4270
+ if (decorator.hasChildren() && !this.expansionModel.isCollapsed(node)) {
4271
+ decorator.children.forEach(function (child) { return _this.addNodeAndVisibleChildren(child, result); });
4272
+ }
4273
+ };
4274
+ return FlattenedTreeListModel;
4275
+ }(pectin.ComputedListModel));
4276
+
4057
4277
  var TreeExpansionModel = /** @class */ (function () {
4058
4278
  function TreeExpansionModel(identityOf) {
4059
4279
  this.identityOf = identityOf;
@@ -4071,39 +4291,39 @@
4071
4291
  // @Trace()
4072
4292
  TreeExpansionModel.prototype.expand = function (node) {
4073
4293
  if (this.isCollapsed(node)) {
4074
- this.collapsedIds.delete(this.identityOf(node.node));
4294
+ this.collapsedIds.delete(this.identityOf(node));
4075
4295
  this.updatePredicate();
4076
4296
  }
4077
4297
  };
4078
4298
  // @Trace()
4079
4299
  TreeExpansionModel.prototype.collapse = function (node) {
4080
4300
  if (!this.isCollapsed(node)) {
4081
- this.collapsedIds.add(this.identityOf(node.node));
4301
+ this.collapsedIds.add(this.identityOf(node));
4082
4302
  this.updatePredicate();
4083
4303
  }
4084
4304
  };
4085
4305
  TreeExpansionModel.prototype.canExpand = function (node) {
4086
- return node.hasChildren() && this.isCollapsed(node);
4306
+ return exports.DecoratedTreeNode.getDecorator(node).hasChildren() && this.isCollapsed(node);
4087
4307
  };
4088
4308
  TreeExpansionModel.prototype.canCollapse = function (node) {
4089
- return node.hasChildren() && !this.isCollapsed(node);
4309
+ return exports.DecoratedTreeNode.getDecorator(node).hasChildren() && !this.isCollapsed(node);
4090
4310
  };
4091
4311
  TreeExpansionModel.prototype.isCollapsed = function (node) {
4092
- return this.collapsedIds.has(this.identityOf(node.node));
4312
+ return this.collapsedIds.has(this.identityOf(node));
4093
4313
  };
4094
4314
  TreeExpansionModel.prototype.isExpanded = function (node) {
4095
4315
  return !this.isCollapsed(node);
4096
4316
  };
4097
4317
  TreeExpansionModel.prototype.ensureAncestorsAndSelfVisible = function (node) {
4098
4318
  var _this = this;
4099
- node.ancestors()
4100
- .map(function (a) { return _this.identityOf(node.node); })
4319
+ exports.DecoratedTreeNode.getDecorator(node).ancestors()
4320
+ .map(function (a) { return _this.identityOf(node); })
4101
4321
  .forEach(function (id) { return _this.collapsedIds.delete(id); });
4102
4322
  this.updatePredicate();
4103
4323
  };
4104
4324
  TreeExpansionModel.prototype.updatePredicate = function () {
4105
4325
  var _this = this;
4106
- this._isExpandedPredicate.value = function (node) { return !_this.collapsedIds.has(_this.identityOf(node.node)); };
4326
+ this._isExpandedPredicate.value = function (node) { return !_this.collapsedIds.has(_this.identityOf(node)); };
4107
4327
  };
4108
4328
  return TreeExpansionModel;
4109
4329
  }());
@@ -4141,253 +4361,6 @@
4141
4361
  return TreeLabelColumnModel;
4142
4362
  }(ColumnModel));
4143
4363
 
4144
- exports.SelfAndDescendantsVisitor = /** @class */ (function () {
4145
- function SelfAndDescendantsVisitor() {
4146
- }
4147
- SelfAndDescendantsVisitor.prototype.visit = function (it) {
4148
- this.onVisit(it);
4149
- if (this.shouldVisitChildrenOf(it)) {
4150
- it.visitChildren(this);
4151
- }
4152
- };
4153
- SelfAndDescendantsVisitor.prototype.shouldVisitChildrenOf = function (it) {
4154
- return true;
4155
- };
4156
- return SelfAndDescendantsVisitor;
4157
- }());
4158
- (function (SelfAndDescendantsVisitor) {
4159
- var Each = /** @class */ (function (_super) {
4160
- __extends(Each, _super);
4161
- function Each(callback) {
4162
- var _this = _super.call(this) || this;
4163
- _this.callback = callback;
4164
- return _this;
4165
- }
4166
- Each.prototype.onVisit = function (it) {
4167
- this.callback(it);
4168
- };
4169
- return Each;
4170
- }(SelfAndDescendantsVisitor));
4171
- SelfAndDescendantsVisitor.Each = Each;
4172
- })(exports.SelfAndDescendantsVisitor || (exports.SelfAndDescendantsVisitor = {}));
4173
-
4174
- var DecoratedTreeNodeMixin = /** @class */ (function () {
4175
- function DecoratedTreeNodeMixin(parent, node) {
4176
- this.parent = parent;
4177
- this.node = node;
4178
- }
4179
- Object.defineProperty(DecoratedTreeNodeMixin.prototype, "decoratedSelf", {
4180
- get: function () {
4181
- var _this = this;
4182
- return this.memoize('decoratedSelf', function () {
4183
- return _this.parent ? _this.parent.children.find(function (child) { return child.node === _this.node; }) : exports.DecoratedTreeNode.createRoot(_this.node);
4184
- });
4185
- },
4186
- enumerable: false,
4187
- configurable: true
4188
- });
4189
- Object.defineProperty(DecoratedTreeNodeMixin.prototype, "children", {
4190
- get: function () {
4191
- var _this = this;
4192
- return this.memoize('children', function () {
4193
- return _this.node.children ? _this.node.children.map(function (child) {
4194
- return typescriptUtilities.Mixin.createProxy(child, new DecoratedTreeNodeMixin(_this.decoratedSelf, child));
4195
- }) : [];
4196
- });
4197
- },
4198
- enumerable: false,
4199
- configurable: true
4200
- });
4201
- DecoratedTreeNodeMixin.prototype.descendants = function () {
4202
- var _this = this;
4203
- return this.memoize('descendants', function () {
4204
- var result = [];
4205
- _this.visitDescendants(function (child) { return result.push(child); });
4206
- return result;
4207
- });
4208
- };
4209
- DecoratedTreeNodeMixin.prototype.selfAndDescendants = function () {
4210
- var _this = this;
4211
- return this.memoize('selfAndDescendants', function () {
4212
- var result = [];
4213
- _this.visitSelfAndDescendants(function (child) { return result.push(child); });
4214
- return result;
4215
- });
4216
- };
4217
- DecoratedTreeNodeMixin.prototype.siblingsBefore = function () {
4218
- var _this = this;
4219
- return this.memoize('siblingsBefore', function () {
4220
- if (_this.parent) {
4221
- return _this.parent.children.slice(0, _this.myIndex());
4222
- }
4223
- else {
4224
- return [];
4225
- }
4226
- });
4227
- };
4228
- DecoratedTreeNodeMixin.prototype.siblingsAfter = function () {
4229
- var _this = this;
4230
- return this.memoize('siblingsAfter', function () {
4231
- if (_this.parent) {
4232
- return _this.parent.children.slice(1 + _this.myIndex());
4233
- }
4234
- else {
4235
- return [];
4236
- }
4237
- });
4238
- };
4239
- DecoratedTreeNodeMixin.prototype.siblings = function () {
4240
- var _this = this;
4241
- return this.memoize('siblings', function () { return [].concat(_this.siblingsBefore(), _this.siblingsAfter()); });
4242
- };
4243
- DecoratedTreeNodeMixin.prototype.isFirstChild = function () {
4244
- var _this = this;
4245
- return this.memoize('isFirstChild', function () { return _this.parent ? _this.myIndex() === 0 : false; });
4246
- };
4247
- DecoratedTreeNodeMixin.prototype.myIndex = function () {
4248
- var _this = this;
4249
- return this.memoize('myIndex', function () {
4250
- var myIndex = _this.parent.children.findIndex(function (child) { return child.node === _this.node; });
4251
- pectin.assert.isTruthy(myIndex >= 0, 'illegal state, expected index to be >= 0');
4252
- return myIndex;
4253
- });
4254
- };
4255
- DecoratedTreeNodeMixin.prototype.isLastChild = function () {
4256
- var _this = this;
4257
- return this.memoize('isLastChild', function () {
4258
- return _this.parent ? _this.myIndex() === _this.parent.children.length - 1 : false;
4259
- });
4260
- };
4261
- DecoratedTreeNodeMixin.prototype.hasSiblings = function () {
4262
- return this.parent ? this.node.children.length > 1 : false;
4263
- };
4264
- DecoratedTreeNodeMixin.prototype.find = function (predicate) {
4265
- return ___namespace.find(this.descendants(), predicate);
4266
- };
4267
- DecoratedTreeNodeMixin.prototype.select = function (predicate) {
4268
- return ___namespace.filter(this.descendants(), predicate);
4269
- };
4270
- DecoratedTreeNodeMixin.prototype.flattenInto = function (array) {
4271
- this.visitSelfAndDescendants(function (child) { return array.push(child); });
4272
- return array;
4273
- };
4274
- DecoratedTreeNodeMixin.prototype.ancestors = function () {
4275
- var _this = this;
4276
- return this.memoize('ancestors', function () {
4277
- return _this.parent ? _this.parent.ancestors().concat([_this.parent]) : [];
4278
- });
4279
- };
4280
- DecoratedTreeNodeMixin.prototype.ancestorsAndSelf = function () {
4281
- var _this = this;
4282
- return this.memoize('ancestorsAndSelf', function () {
4283
- return _this.ancestors().concat([(_this.decoratedSelf)]);
4284
- });
4285
- };
4286
- DecoratedTreeNodeMixin.prototype.pathToParent = function (parent) {
4287
- if (this.node === parent.node) {
4288
- return [];
4289
- }
4290
- else if (this.parent) {
4291
- var pathToParent = this.parent.pathToParent(parent);
4292
- return pathToParent.concat([this.parent]);
4293
- }
4294
- else {
4295
- throw new Error('parent is not an ancestor');
4296
- }
4297
- };
4298
- DecoratedTreeNodeMixin.prototype.pathToParentAndSelf = function (parent) {
4299
- return this.pathToParent(parent).concat([this.decoratedSelf]);
4300
- };
4301
- DecoratedTreeNodeMixin.prototype.isRoot = function () {
4302
- return !this.parent;
4303
- };
4304
- Object.defineProperty(DecoratedTreeNodeMixin.prototype, "depth", {
4305
- get: function () {
4306
- return this.isRoot() ? 0 : this.parent.depth + 1;
4307
- },
4308
- enumerable: false,
4309
- configurable: true
4310
- });
4311
- DecoratedTreeNodeMixin.prototype.isLeaf = function () {
4312
- return !this.isRoot() && this.node.children.length < 1;
4313
- };
4314
- DecoratedTreeNodeMixin.prototype.hasChildren = function () {
4315
- return this.node.children && this.node.children.length > 0;
4316
- };
4317
- DecoratedTreeNodeMixin.prototype.depthFromParent = function (parent) {
4318
- return this.pathToParent(parent).length;
4319
- };
4320
- DecoratedTreeNodeMixin.prototype.treeDepth = function () {
4321
- var _this = this;
4322
- return this.memoize('treeDepth', function () {
4323
- return 1 + _this.descendants().map(function (child) { return child.depthFromParent(_this); }).reduce(function (prev, current) { return Math.max(prev, current); });
4324
- });
4325
- };
4326
- DecoratedTreeNodeMixin.prototype.flatten = function () {
4327
- var _this = this;
4328
- return this.memoize('flatten', function () {
4329
- return _this.flattenInto([]);
4330
- });
4331
- };
4332
- DecoratedTreeNodeMixin.prototype.visit = function (visitor) {
4333
- visitor.visit(this);
4334
- return visitor;
4335
- };
4336
- DecoratedTreeNodeMixin.prototype.visitChildren = function (visitor) {
4337
- ___namespace.each(this.children, function (child) { return child.visit(visitor); });
4338
- return visitor;
4339
- };
4340
- DecoratedTreeNodeMixin.prototype.visitSelfAndDescendants = function (callback) {
4341
- this.visit(new exports.SelfAndDescendantsVisitor.Each(callback));
4342
- };
4343
- DecoratedTreeNodeMixin.prototype.visitDescendants = function (callback) {
4344
- this.visitChildren(new exports.SelfAndDescendantsVisitor.Each(callback));
4345
- };
4346
- DecoratedTreeNodeMixin.prototype.memoize = function (property, factory) {
4347
- var key = "__" + property;
4348
- if (___namespace.isNil(this[key])) {
4349
- this[key] = factory();
4350
- }
4351
- return this[key];
4352
- };
4353
- return DecoratedTreeNodeMixin;
4354
- }());
4355
- exports.DecoratedTreeNode = void 0;
4356
- (function (DecoratedTreeNode) {
4357
- function createRoot(node) {
4358
- return typescriptUtilities.Mixin.createProxy(node, new DecoratedTreeNodeMixin(undefined, node));
4359
- }
4360
- DecoratedTreeNode.createRoot = createRoot;
4361
- })(exports.DecoratedTreeNode || (exports.DecoratedTreeNode = {}));
4362
-
4363
- var TreeToListModel = /** @class */ (function (_super) {
4364
- __extends(TreeToListModel, _super);
4365
- function TreeToListModel(source, expansionModel) {
4366
- var _this = _super.call(this, source) || this;
4367
- _this.source = source;
4368
- _this.expansionModel = expansionModel;
4369
- _this.trackSource(_this.expansionModel.isExpandedPredicate);
4370
- return _this;
4371
- }
4372
- TreeToListModel.prototype.getIdentityOf = function (item) {
4373
- return this.source.identityOf(item.node);
4374
- };
4375
- TreeToListModel.prototype.compute = function (values) {
4376
- var _this = this;
4377
- var result = [];
4378
- values.forEach(function (value) { return _this.addNodeAndVisibleChildren(exports.DecoratedTreeNode.createRoot(value), result); });
4379
- return result;
4380
- };
4381
- TreeToListModel.prototype.addNodeAndVisibleChildren = function (node, result) {
4382
- var _this = this;
4383
- result.push(node);
4384
- if (node.hasChildren() && !this.expansionModel.isCollapsed(node)) {
4385
- node.children.forEach(function (child) { return _this.addNodeAndVisibleChildren(child, result); });
4386
- }
4387
- };
4388
- return TreeToListModel;
4389
- }(pectin.ComputedListModel));
4390
-
4391
4364
  // TODO:
4392
4365
  // Selection Models:
4393
4366
  // - as simple navigation tree
@@ -4400,24 +4373,16 @@
4400
4373
  //
4401
4374
  var TreeTableModel = /** @class */ (function (_super) {
4402
4375
  __extends(TreeTableModel, _super);
4403
- function TreeTableModel(source, treeExpansionModel) {
4404
- var _this = _super.call(this, source) || this;
4405
- _this.treeExpansionModel = treeExpansionModel;
4376
+ function TreeTableModel(source, childAccessor, builder) {
4377
+ var _this = _super.call(this) || this;
4378
+ _this.treeExpansionModel = new TreeExpansionModel(function (row) { return _this.identityOf(row); });
4379
+ if (builder)
4380
+ builder(_this);
4381
+ var childExtractor = ___namespace.isFunction(childAccessor) ? childAccessor : function (row) { return row[childAccessor]; };
4382
+ _this.flattenedDataSource = _this.registerDisposable(new FlattenedTreeListModel(source, childExtractor, _this.treeExpansionModel));
4383
+ _this.setDataSource(_this.flattenedDataSource);
4406
4384
  return _this;
4407
4385
  }
4408
- TreeTableModel.fromList = function (sourceOfTruth, builder) {
4409
- return TreeTableModel._create(TreeTableModel, sourceOfTruth, builder);
4410
- };
4411
- TreeTableModel._create = function (klass, sourceOfTruth, builder) {
4412
- var treeExpansionModel = new TreeExpansionModel(sourceOfTruth.identityOf);
4413
- var garbage = new pectin.GarbageCollector();
4414
- var nodes = garbage.registerDisposable(new TreeToListModel(sourceOfTruth, treeExpansionModel));
4415
- var model = new klass(nodes, treeExpansionModel);
4416
- model.registerDisposable(garbage);
4417
- if (builder)
4418
- builder(model);
4419
- return model;
4420
- };
4421
4386
  TreeTableModel.prototype.treeControlColumn = function (builder) {
4422
4387
  var _this = this;
4423
4388
  var columnId = 'tree-label';
@@ -6316,7 +6281,7 @@
6316
6281
  /**
6317
6282
  * Example:
6318
6283
  * @example
6319
- * const model = TableModel.fromList(heroList, table => {
6284
+ * const model = new TableModel(heroList, table => {
6320
6285
  * table.pluck("firstName");
6321
6286
  * table.pluck("lastName");
6322
6287
  * table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
@@ -6348,7 +6313,7 @@
6348
6313
  *
6349
6314
  * Selection models
6350
6315
  * @example
6351
- * const model = TableModel.fromList(heroList, table => {
6316
+ * const model = new TableModel(heroList, table => {
6352
6317
  * table.addSelectionColumn(selectionModel); // <- can be single or multiple selection model
6353
6318
  * table.pluck("firstName");
6354
6319
  * table.pluck("lastName");
@@ -6356,7 +6321,7 @@
6356
6321
  *
6357
6322
  * Custom cell renderers and editors
6358
6323
  * @example
6359
- * const model = TableModel.fromList(heroList, table => {
6324
+ * const model = new TableModel(heroList, table => {
6360
6325
  * table.pluck("favoriteColor")
6361
6326
  * .cellHeaderRenderer(CellHeaderRendererComponent, (component, column) => {
6362
6327
  * // configure your component with what ever you need.
@@ -6368,7 +6333,7 @@
6368
6333
  *
6369
6334
  * Template columns
6370
6335
  * @example
6371
- * const model = TableModel.fromList(heroList, table => {
6336
+ * const model = new TableModel(heroList, table => {
6372
6337
  * table.addSelectionColumn(selectionModel); // <- can be single or multiple selection model
6373
6338
  * table.addTemplateColumn("myTemplate");
6374
6339
  * });
@@ -6385,7 +6350,7 @@
6385
6350
  * fullName:
6386
6351
  * headerText: "Full Name"
6387
6352
  *
6388
- * const model = TableModel.fromList(heroList, table => {
6353
+ * const model = new TableModel(heroList, table => {
6389
6354
  * table.pluck("favoriteColor").cellRenderer(...).cellEditor(...);
6390
6355
  * table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
6391
6356
  *
@@ -6394,17 +6359,21 @@
6394
6359
  */
6395
6360
  var TableModel = /** @class */ (function (_super) {
6396
6361
  __extends(TableModel, _super);
6397
- function TableModel() {
6398
- return _super !== null && _super.apply(this, arguments) || this;
6362
+ function TableModel(sourceOfTruth, builder) {
6363
+ var _this = _super.call(this) || this;
6364
+ if (builder) {
6365
+ builder(_this);
6366
+ }
6367
+ _this.setDataSource(sourceOfTruth);
6368
+ return _this;
6399
6369
  }
6370
+ /**
6371
+ * @deprecated use new TableModel(sourceOfTruth, table => {...}); instead.
6372
+ * @param sourceOfTruth
6373
+ * @param builder
6374
+ */
6400
6375
  TableModel.fromList = function (sourceOfTruth, builder) {
6401
- return TableModel._create(TableModel, sourceOfTruth, builder);
6402
- };
6403
- TableModel._create = function (klass, sourceOfTruth, builder) {
6404
- var model = new klass(sourceOfTruth);
6405
- if (builder)
6406
- builder(model);
6407
- return model;
6376
+ return new TableModel(sourceOfTruth, builder);
6408
6377
  };
6409
6378
  TableModel.prototype.addSelectionColumn = function (selectionModel, showSelectionColumn) {
6410
6379
  return this._addSelectionColumn(selectionModel, showSelectionColumn);
@@ -6412,6 +6381,36 @@
6412
6381
  return TableModel;
6413
6382
  }(AbstractTableModel));
6414
6383
 
6384
+ exports.SelfAndDescendantsVisitor = /** @class */ (function () {
6385
+ function SelfAndDescendantsVisitor() {
6386
+ }
6387
+ SelfAndDescendantsVisitor.prototype.visit = function (it) {
6388
+ this.onVisit(it);
6389
+ if (this.shouldVisitChildrenOf(it)) {
6390
+ it.visitChildren(this);
6391
+ }
6392
+ };
6393
+ SelfAndDescendantsVisitor.prototype.shouldVisitChildrenOf = function (it) {
6394
+ return true;
6395
+ };
6396
+ return SelfAndDescendantsVisitor;
6397
+ }());
6398
+ (function (SelfAndDescendantsVisitor) {
6399
+ var Each = /** @class */ (function (_super) {
6400
+ __extends(Each, _super);
6401
+ function Each(callback) {
6402
+ var _this = _super.call(this) || this;
6403
+ _this.callback = callback;
6404
+ return _this;
6405
+ }
6406
+ Each.prototype.onVisit = function (it) {
6407
+ this.callback(it);
6408
+ };
6409
+ return Each;
6410
+ }(SelfAndDescendantsVisitor));
6411
+ SelfAndDescendantsVisitor.Each = Each;
6412
+ })(exports.SelfAndDescendantsVisitor || (exports.SelfAndDescendantsVisitor = {}));
6413
+
6415
6414
  /**
6416
6415
  * @file Automatically generated by barrelsby.
6417
6416
  */
@@ -9738,6 +9737,7 @@
9738
9737
  exports.EditorControlColumnModel = EditorControlColumnModel;
9739
9738
  exports.EmptyStateComponent = EmptyStateComponent;
9740
9739
  exports.EventCleanUpSession = EventCleanUpSession;
9740
+ exports.FlattenedTreeListModel = FlattenedTreeListModel;
9741
9741
  exports.FlexComponent = FlexComponent;
9742
9742
  exports.FocusBinding = FocusBinding;
9743
9743
  exports.FocusBindingDirective = FocusBindingDirective;
@@ -9821,7 +9821,6 @@
9821
9821
  exports.TreeLabelColumnModel = TreeLabelColumnModel;
9822
9822
  exports.TreeTableComponent = TreeTableComponent;
9823
9823
  exports.TreeTableModel = TreeTableModel;
9824
- exports.TreeToListModel = TreeToListModel;
9825
9824
  exports.UrlService = UrlService;
9826
9825
  exports.VerticalFocusContainerComponent = VerticalFocusContainerComponent;
9827
9826
  exports.VisibilityService = VisibilityService;
@@ -9835,6 +9834,7 @@
9835
9834
  exports.leftRightPlaceAnimation = leftRightPlaceAnimation;
9836
9835
  exports.slideDownOnEnterAnimation = slideDownOnEnterAnimation;
9837
9836
  exports.slideRightOnEnterAnimation = slideRightOnEnterAnimation;
9837
+ exports.treeNodeDecorator = treeNodeDecorator;
9838
9838
  exports.ɵ0 = ɵ0;
9839
9839
 
9840
9840
  Object.defineProperty(exports, '__esModule', { value: true });