@coolon/angular-ui-powerups 12.3.0 → 12.4.0-alpha.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 (126) hide show
  1. package/bundles/coolon-angular-ui-powerups-cypress.umd.js +297 -93
  2. package/bundles/coolon-angular-ui-powerups-cypress.umd.js.map +1 -1
  3. package/bundles/coolon-angular-ui-powerups.umd.js +410 -290
  4. package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
  5. package/coolon-angular-ui-powerups.metadata.json +1 -1
  6. package/cypress/components/aup-command-face.d.ts +2 -5
  7. package/cypress/components/aup-command.d.ts +18 -4
  8. package/cypress/components/aup-navigation.d.ts +0 -1
  9. package/cypress/components/aup-popup-menu.d.ts +2 -0
  10. package/cypress/components/aup-table.d.ts +19 -0
  11. package/cypress/components/button-mixin.d.ts +17 -0
  12. package/cypress/components/button.d.ts +17 -3
  13. package/cypress/coolon-angular-ui-powerups-cypress.d.ts +1 -0
  14. package/cypress/coolon-angular-ui-powerups-cypress.metadata.json +1 -1
  15. package/cypress/exports.d.ts +3 -0
  16. package/cypress/page-element.d.ts +11 -2
  17. package/cypress/page.d.ts +16 -13
  18. package/cypress/path.d.ts +26 -0
  19. package/cypress/section.d.ts +8 -1
  20. package/esm2015/cypress/components/aup-command-face.js +20 -11
  21. package/esm2015/cypress/components/aup-command-face.js.map +1 -1
  22. package/esm2015/cypress/components/aup-command-face.metadata.json +1 -1
  23. package/esm2015/cypress/components/aup-command.js +10 -7
  24. package/esm2015/cypress/components/aup-command.js.map +1 -1
  25. package/esm2015/cypress/components/aup-command.metadata.json +1 -1
  26. package/esm2015/cypress/components/aup-more-menu.js +1 -2
  27. package/esm2015/cypress/components/aup-more-menu.js.map +1 -1
  28. package/esm2015/cypress/components/aup-more-menu.metadata.json +1 -1
  29. package/esm2015/cypress/components/aup-navigation.js +1 -5
  30. package/esm2015/cypress/components/aup-navigation.js.map +1 -1
  31. package/esm2015/cypress/components/aup-popup-menu.js +12 -3
  32. package/esm2015/cypress/components/aup-popup-menu.js.map +1 -1
  33. package/esm2015/cypress/components/aup-popup-menu.metadata.json +1 -1
  34. package/esm2015/cypress/components/aup-table.js +36 -0
  35. package/esm2015/cypress/components/aup-table.js.map +1 -0
  36. package/esm2015/cypress/components/aup-table.metadata.json +1 -0
  37. package/esm2015/cypress/components/button-mixin.js +15 -0
  38. package/esm2015/cypress/components/button-mixin.js.map +1 -0
  39. package/esm2015/cypress/components/button-mixin.metadata.json +1 -0
  40. package/esm2015/cypress/components/button.js +11 -7
  41. package/esm2015/cypress/components/button.js.map +1 -1
  42. package/esm2015/cypress/components/button.metadata.json +1 -1
  43. package/esm2015/cypress/coolon-angular-ui-powerups-cypress.js.map +1 -1
  44. package/esm2015/cypress/coolon-angular-ui-powerups-cypress.metadata.json +1 -1
  45. package/esm2015/cypress/exports.js +3 -0
  46. package/esm2015/cypress/exports.js.map +1 -1
  47. package/esm2015/cypress/exports.metadata.json +1 -1
  48. package/esm2015/cypress/page-element.js +21 -5
  49. package/esm2015/cypress/page-element.js.map +1 -1
  50. package/esm2015/cypress/page-element.metadata.json +1 -1
  51. package/esm2015/cypress/page.js +32 -22
  52. package/esm2015/cypress/page.js.map +1 -1
  53. package/esm2015/cypress/page.metadata.json +1 -1
  54. package/esm2015/cypress/path.js +61 -0
  55. package/esm2015/cypress/path.js.map +1 -0
  56. package/esm2015/cypress/path.metadata.json +1 -0
  57. package/esm2015/cypress/section.js +20 -10
  58. package/esm2015/cypress/section.js.map +1 -1
  59. package/esm2015/lib/components/switch-case/switch-case.component.js +7 -0
  60. package/esm2015/lib/components/switch-case/switch-case.component.js.map +1 -1
  61. package/esm2015/lib/components/switch-case/switch-case.component.metadata.json +1 -1
  62. package/esm2015/lib/components/tables/abstract-table.component.js +1 -1
  63. package/esm2015/lib/components/tables/abstract-table.component.js.map +1 -1
  64. package/esm2015/lib/components/tables/table/table.component.js +1 -1
  65. package/esm2015/lib/components/tables/table/table.component.js.map +1 -1
  66. package/esm2015/lib/components/tables/table/table.component.metadata.json +1 -1
  67. package/esm2015/lib/components/tables/tree-table/tree-table-component.js +1 -1
  68. package/esm2015/lib/components/tables/tree-table/tree-table-component.js.map +1 -1
  69. package/esm2015/lib/components/tables/tree-table/tree-table-component.metadata.json +1 -1
  70. package/esm2015/lib/interaction/components/activity-actions/activity-actions.component.js +1 -1
  71. package/esm2015/lib/interaction/components/activity-actions/activity-actions.component.metadata.json +1 -1
  72. package/esm2015/lib/place/components/place-outlet/place-outlet.component.js.map +1 -1
  73. package/esm2015/lib/place/components/place-outlet/place-outlet.component.metadata.json +1 -1
  74. package/esm2015/lib/place/guards/consolidated-param-map.js +7 -2
  75. package/esm2015/lib/place/guards/consolidated-param-map.js.map +1 -1
  76. package/esm2015/lib/place/guards/consolidated-param-map.metadata.json +1 -1
  77. package/esm2015/lib/place/guards/place.guard.js +1 -22
  78. package/esm2015/lib/place/guards/place.guard.js.map +1 -1
  79. package/esm2015/lib/place/navigation/place-component-deactivation-handler.js +24 -14
  80. package/esm2015/lib/place/navigation/place-component-deactivation-handler.js.map +1 -1
  81. package/esm2015/lib/place/navigation/place-component-deactivation-handler.metadata.json +1 -1
  82. package/esm2015/lib/place/navigation/session/interactions/synchronise-interaction-context-ids-with-route.js.map +1 -1
  83. package/esm2015/lib/place/navigation/session/interactions/synchronise-interaction-context-ids-with-route.metadata.json +1 -1
  84. package/esm2015/lib/place/place-component.js +67 -5
  85. package/esm2015/lib/place/place-component.js.map +1 -1
  86. package/esm2015/lib/place/place-component.metadata.json +1 -1
  87. package/esm2015/lib/place/place-definition.js +3 -3
  88. package/esm2015/lib/place/place-definition.js.map +1 -1
  89. package/esm2015/lib/place/place-router.js +9 -4
  90. package/esm2015/lib/place/place-router.js.map +1 -1
  91. package/esm2015/lib/place/place-router.metadata.json +1 -1
  92. package/esm2015/lib/place/route/parameter-decorators.js +13 -14
  93. package/esm2015/lib/place/route/parameter-decorators.js.map +1 -1
  94. package/esm2015/lib/place/route/parameter-decorators.metadata.json +1 -1
  95. package/esm2015/lib/place/route/parameter-definition.js +21 -3
  96. package/esm2015/lib/place/route/parameter-definition.js.map +1 -1
  97. package/esm2015/lib/place/route/parameter-definition.metadata.json +1 -1
  98. package/esm2015/lib/place/route/visit-sanitiser.js +1 -1
  99. package/esm2015/lib/place/route/visit-sanitiser.js.map +1 -1
  100. package/esm2015/lib/place/url-snapshot.js +30 -7
  101. package/esm2015/lib/place/url-snapshot.js.map +1 -1
  102. package/esm2015/lib/place/url-snapshot.metadata.json +1 -1
  103. package/esm2015/lib/place/visit.js +7 -7
  104. package/esm2015/lib/place/visit.js.map +1 -1
  105. package/esm2015/lib/place/visit.metadata.json +1 -1
  106. package/fesm2015/coolon-angular-ui-powerups-cypress.js +235 -74
  107. package/fesm2015/coolon-angular-ui-powerups-cypress.js.map +1 -1
  108. package/fesm2015/coolon-angular-ui-powerups.js +369 -269
  109. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  110. package/lib/components/switch-case/switch-case.component.d.ts +7 -0
  111. package/lib/place/guards/consolidated-param-map.d.ts +2 -2
  112. package/lib/place/navigation/place-component-deactivation-handler.d.ts +3 -1
  113. package/lib/place/place-component.d.ts +26 -3
  114. package/lib/place/route/parameter-definition.d.ts +8 -0
  115. package/lib/place/url-snapshot.d.ts +1 -0
  116. package/lib/place/visit.d.ts +4 -4
  117. package/package.json +1 -1
  118. package/schematics/activity/schema.json +1 -1
  119. package/schematics/activity/templates/component/__name@dasherize__.component.html.template +1 -1
  120. package/schematics/activity/templates/component/__name@dasherize__.component.ts.template +2 -2
  121. package/schematics/aup-i18n/schema.json +1 -1
  122. package/schematics/bootstrap-app/schema.json +1 -1
  123. package/schematics/component/schema.json +1 -1
  124. package/schematics/place-add/schema.json +1 -1
  125. package/schematics/place-bootstrap/schema.json +1 -1
  126. package/schematics/place-routes/schema.json +1 -1
@@ -2394,6 +2394,13 @@
2394
2394
  SwitchCaseDefaultDirective.ctorParameters = function () { return [
2395
2395
  { type: i0.TemplateRef }
2396
2396
  ]; };
2397
+ /**
2398
+ * @example
2399
+ * <aup-switch-case [switchModel]="booleanModel">
2400
+ * <div *aupSwitchCaseWhen="true"></div>
2401
+ * <div *aupSwitchCaseDefault>The default content</div>
2402
+ * </aup-switch-case>
2403
+ */
2397
2404
  var SwitchCaseComponent = /** @class */ (function (_super) {
2398
2405
  __extends(SwitchCaseComponent, _super);
2399
2406
  function SwitchCaseComponent(cdr) {
@@ -3275,7 +3282,7 @@
3275
3282
  return show ? _this.headerHeight.value : 0;
3276
3283
  }, { dependsOn: _this.headerHeight });
3277
3284
  _this.visibleRowCount = chain(_this.boundsModel).map(function (bounds) {
3278
- // TODO: this doesn't take into account any css styling adjustments etc. Will invistigate if it's an issue.
3285
+ // TODO: this doesn't take into account any css styling adjustments etc. Will investigate if it's an issue.
3279
3286
  var rawRowCount = (bounds.height - actualHeaderHeight.value) / _this.rowHeight.value;
3280
3287
  return rawRowCount < 1 ? 0 : Math.floor(rawRowCount);
3281
3288
  }, {
@@ -3886,7 +3893,7 @@
3886
3893
  TableComponent.decorators = [
3887
3894
  { type: i0.Component, args: [{
3888
3895
  selector: 'aup-table',
3889
- template: "<div class=\"scroll-container\">\n <table mat-table [dataSource]=\"getModel().dataSource.value\" [trackBy]=\"getModel().trackBy\">\n\n <ng-container *ngFor=\"let column of columns.value; index as index; first as first; last as last\"\n matColumnDef=\"{{column.columnId}}\">\n <th mat-header-cell *matHeaderCellDef [class.flex]=\"column.isFlex()\" [class.hide]=\"!column.isVisible()\">\n <aup-table-header-cell-renderer [column]=\"column\"\n [attr.column-index]=\"index\"\n [attr.column-id]=\"column.columnId\"\n [class]=\"getColumnClasses(column.columnId)\"\n ></aup-table-header-cell-renderer>\n </th>\n <td mat-cell *matCellDef=\"let row\" (click)=\"notifyCellClicked(column, row)\"\n [class.enable-cursor]=\"getModel().isCursorEnabled(column)\"\n [class.flex]=\"column.isFlex()\"\n [class.hide]=\"!column.isVisible()\"\n >\n <aup-table-cell-renderer [column]=\"column\"\n [row]=\"row\"\n [tableModel]=\"getModel()\"\n [editSession]=\"getModel().getEditSessionFor(row)\"\n [attr.column-index]=\"index\"\n [attr.column-id]=\"column.columnId\"\n [class]=\"getColumnClasses(column.columnId)\"\n ></aup-table-cell-renderer>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"columnIds.value\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: columnIds.value; let i = index\"\n [ngClass]=\"getModel().getRowClasses(row)\" [class.enable-hover]=\"getModel().isHoverEnabled()\"\n [attr.trackBy]=\"getModel().trackBy(i, row)\"\n ></tr>\n\n </table>\n</div>\n",
3896
+ template: "<div class=\"scroll-container\">\n <table mat-table [dataSource]=\"getModel().dataSource.value\" [trackBy]=\"getModel().trackBy\">\n\n <ng-container *ngFor=\"let column of columns.value; index as index; first as first; last as last\"\n matColumnDef=\"{{column.columnId}}\">\n <th mat-header-cell *matHeaderCellDef [class.flex]=\"column.isFlex()\" [class.hide]=\"!column.isVisible()\">\n <aup-table-header-cell-renderer [column]=\"column\"\n [attr.column-index]=\"index\"\n [attr.column-id]=\"column.columnId\"\n [class]=\"getColumnClasses(column.columnId)\"\n ></aup-table-header-cell-renderer>\n </th>\n <td mat-cell *matCellDef=\"let row\" (click)=\"notifyCellClicked(column, row)\"\n [class.enable-cursor]=\"getModel().isCursorEnabled(column)\"\n [class.flex]=\"column.isFlex()\"\n [class.hide]=\"!column.isVisible()\"\n >\n <aup-table-cell-renderer [column]=\"column\"\n [row]=\"row\"\n [tableModel]=\"getModel()\"\n [editSession]=\"getModel().getEditSessionFor(row)\"\n [attr.column-index]=\"index\"\n [attr.column-id]=\"column.columnId\"\n [class]=\"getColumnClasses(column.columnId)\"\n ></aup-table-cell-renderer>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"columnIds.value\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: columnIds.value; let i = index\"\n [ngClass]=\"getModel().getRowClasses(row)\" [class.enable-hover]=\"getModel().isHoverEnabled()\"\n [attr.aup-row-id]=\"getModel().trackBy(i, row)\"\n ></tr>\n\n </table>\n</div>\n",
3890
3897
  providers: [
3891
3898
  { provide: AbstractTableComponent, useExisting: TableComponent }
3892
3899
  ],
@@ -4538,7 +4545,7 @@
4538
4545
  TreeTableComponent.decorators = [
4539
4546
  { type: i0.Component, args: [{
4540
4547
  selector: 'aup-tree-table',
4541
- template: "<div class=\"scroll-container\">\n <table mat-table [dataSource]=\"getModel().dataSource.value\" [trackBy]=\"getModel().trackBy\">\n\n <ng-container *ngFor=\"let column of columns.value; index as index; first as first; last as last\"\n matColumnDef=\"{{column.columnId}}\">\n <th mat-header-cell *matHeaderCellDef [class.flex]=\"column.isFlex()\" [class.hide]=\"!column.isVisible()\">\n <aup-table-header-cell-renderer [column]=\"column\"\n [attr.column-index]=\"index\"\n [attr.column-id]=\"column.columnId\"\n [class]=\"getColumnClasses(column.columnId)\"\n ></aup-table-header-cell-renderer>\n </th>\n <td mat-cell *matCellDef=\"let row\" (click)=\"notifyCellClicked(column, row)\"\n [class.enable-cursor]=\"getModel().isCursorEnabled(column)\"\n [class.flex]=\"column.isFlex()\"\n [class.hide]=\"!column.isVisible()\"\n >\n <aup-table-cell-renderer [column]=\"column\"\n [row]=\"row\"\n [tableModel]=\"getModel()\"\n [editSession]=\"getModel().getEditSessionFor(row)\"\n [attr.column-index]=\"index\"\n [attr.column-id]=\"column.columnId\"\n [class]=\"getColumnClasses(column.columnId)\"\n ></aup-table-cell-renderer>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"columnIds.value\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: columnIds.value; let i = index\"\n [ngClass]=\"getModel().getRowClasses(row)\" [class.enable-hover]=\"getModel().isHoverEnabled()\"\n [attr.trackBy]=\"getModel().trackBy(i, row)\"\n ></tr>\n\n </table>\n</div>\n",
4548
+ template: "<div class=\"scroll-container\">\n <table mat-table [dataSource]=\"getModel().dataSource.value\" [trackBy]=\"getModel().trackBy\">\n\n <ng-container *ngFor=\"let column of columns.value; index as index; first as first; last as last\"\n matColumnDef=\"{{column.columnId}}\">\n <th mat-header-cell *matHeaderCellDef [class.flex]=\"column.isFlex()\" [class.hide]=\"!column.isVisible()\">\n <aup-table-header-cell-renderer [column]=\"column\"\n [attr.column-index]=\"index\"\n [attr.column-id]=\"column.columnId\"\n [class]=\"getColumnClasses(column.columnId)\"\n ></aup-table-header-cell-renderer>\n </th>\n <td mat-cell *matCellDef=\"let row\" (click)=\"notifyCellClicked(column, row)\"\n [class.enable-cursor]=\"getModel().isCursorEnabled(column)\"\n [class.flex]=\"column.isFlex()\"\n [class.hide]=\"!column.isVisible()\"\n >\n <aup-table-cell-renderer [column]=\"column\"\n [row]=\"row\"\n [tableModel]=\"getModel()\"\n [editSession]=\"getModel().getEditSessionFor(row)\"\n [attr.column-index]=\"index\"\n [attr.column-id]=\"column.columnId\"\n [class]=\"getColumnClasses(column.columnId)\"\n ></aup-table-cell-renderer>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"columnIds.value\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: columnIds.value; let i = index\"\n [ngClass]=\"getModel().getRowClasses(row)\" [class.enable-hover]=\"getModel().isHoverEnabled()\"\n [attr.aup-row-id]=\"getModel().trackBy(i, row)\"\n ></tr>\n\n </table>\n</div>\n",
4542
4549
  providers: [
4543
4550
  { provide: AbstractTableComponent, useExisting: TreeTableComponent }
4544
4551
  ],
@@ -4880,7 +4887,7 @@
4880
4887
  { type: i0.Component, args: [{
4881
4888
  selector: 'aup-activity-actions',
4882
4889
  template: "<div class=\"content\">\n <ng-content></ng-content>\n</div>\n<ng-container *ngIf=\"hasConfirmFace()\">\n <aup-command class=\"confirm\" [command]=\"confirmCommand\" [face]=\"confirmFace\" data-cy=\"confirm-command\"></aup-command>\n</ng-container>\n<ng-container *ngIf=\"hasCancelFace()\">\n <aup-command class=\"cancel\" [command]=\"cancelCommand\" [face]=\"cancelFace\" data-cy=\"cancel-command\"></aup-command>\n</ng-container>\n",
4883
- styles: [":host{display:grid;grid-template-areas:\"cancel confirm content\";grid-template-columns:auto auto 1fr;grid-template-rows:auto;align-items:center;justify-content:end}:host.align-end{grid-template-areas:\"content cancel confirm\";grid-template-columns:1fr auto auto}:host.align-stretch{grid-template-areas:\"cancel content confirm\";grid-template-columns:auto 1fr auto}.cancel{grid-area:cancel}.confirm{grid-area:confirm}.column{grid-area:content;text-align:left}"]
4890
+ styles: [":host{display:grid;grid-template-areas:\"cancel confirm content\";grid-template-columns:auto auto 1fr;grid-template-rows:auto;align-items:center;justify-content:end}:host.align-end{grid-template-areas:\"content cancel confirm\";grid-template-columns:1fr auto auto}:host.align-stretch{grid-template-areas:\"cancel content confirm\";grid-template-columns:auto 1fr auto}.cancel{grid-area:cancel}.confirm{grid-area:confirm}.content{grid-area:content;text-align:left}"]
4884
4891
  },] }
4885
4892
  ];
4886
4893
  ActivityActionsComponent.ctorParameters = function () { return [
@@ -6525,6 +6532,7 @@
6525
6532
  },] }
6526
6533
  ];
6527
6534
 
6535
+ var PARAMETER_DEFINITION_KEY = Symbol("parameterDefinition");
6528
6536
  exports.ParameterDefinition = /** @class */ (function () {
6529
6537
  function ParameterDefinition(propertyName, options, urlFormat) {
6530
6538
  this.propertyName = propertyName;
@@ -6548,6 +6556,11 @@
6548
6556
  enumerable: false,
6549
6557
  configurable: true
6550
6558
  });
6559
+ ParameterDefinition.prototype.createBackingModel = function () {
6560
+ var model = this.backingModelFactory();
6561
+ model[PARAMETER_DEFINITION_KEY] = this;
6562
+ return model;
6563
+ };
6551
6564
  ParameterDefinition.prototype.getOptionValue = function (key) {
6552
6565
  return this.options.getOptional(key, null);
6553
6566
  };
@@ -6561,7 +6574,7 @@
6561
6574
  if (returningFromSomewhereElse) {
6562
6575
  lastKnownVisit = placeHistory.getMostRecentVisitFor(visit.placeDefinition);
6563
6576
  if (this.remember && lastKnownVisit) {
6564
- value = lastKnownVisit.getParameter(this.name);
6577
+ value = lastKnownVisit.getParameterValue(this);
6565
6578
  }
6566
6579
  return [2 /*return*/, this.isEmptyValue(value) ? this.defaultValue : value];
6567
6580
  }
@@ -6572,7 +6585,7 @@
6572
6585
  });
6573
6586
  };
6574
6587
  ParameterDefinition.prototype.isMissingFrom = function (visit) {
6575
- return !visit.hasParameter(this.name);
6588
+ return !visit.hasParameter(this);
6576
6589
  };
6577
6590
  return ParameterDefinition;
6578
6591
  }());
@@ -6583,6 +6596,7 @@
6583
6596
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
6584
6597
  _this.isRouteId = true;
6585
6598
  _this.isArray = false;
6599
+ _this.backingModelFactory = function () { return new pectin.MutableValueModel(); };
6586
6600
  return _this;
6587
6601
  }
6588
6602
  RouteId.prototype.isEmptyValue = function (value) {
@@ -6600,6 +6614,7 @@
6600
6614
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
6601
6615
  _this.isRouteId = false;
6602
6616
  _this.isArray = false;
6617
+ _this.backingModelFactory = function () { return new pectin.MutableValueModel(); };
6603
6618
  return _this;
6604
6619
  }
6605
6620
  ValueParameter.prototype.isEmptyValue = function (value) {
@@ -6617,6 +6632,7 @@
6617
6632
  var _this = _super.call(this, parameterName, options, urlFormat) || this;
6618
6633
  _this.isRouteId = false;
6619
6634
  _this.isArray = true;
6635
+ _this.backingModelFactory = function () { return new pectin.MutableListModel(); };
6620
6636
  return _this;
6621
6637
  }
6622
6638
  ArrayParameter.prototype.isEmptyValue = function (value) {
@@ -6628,6 +6644,14 @@
6628
6644
  return ArrayParameter;
6629
6645
  }(ParameterDefinition));
6630
6646
  ParameterDefinition.ArrayParameter = ArrayParameter;
6647
+ function get(model) {
6648
+ var parameterDefinition = model[PARAMETER_DEFINITION_KEY];
6649
+ if (!parameterDefinition) {
6650
+ typescriptUtilities.lang.illegalArgument("model hasn't been annotated with @VisitParameter, @VisitParameterList or @RouteId");
6651
+ }
6652
+ return parameterDefinition;
6653
+ }
6654
+ ParameterDefinition.get = get;
6631
6655
  })(exports.ParameterDefinition || (exports.ParameterDefinition = {}));
6632
6656
 
6633
6657
  var PlaceDefinition = /** @class */ (function () {
@@ -6679,7 +6703,7 @@
6679
6703
  };
6680
6704
  PlaceDefinition.prototype.getRouteIdFrom = function (visit) {
6681
6705
  var routeIdParameterDef = this.getRouteIdParameterDef();
6682
- return routeIdParameterDef ? visit.getParameter(routeIdParameterDef.name) : null;
6706
+ return routeIdParameterDef ? visit.getParameterValue(routeIdParameterDef) : null;
6683
6707
  };
6684
6708
  PlaceDefinition.prototype.getFormattedRouteId = function (visit) {
6685
6709
  // Note: RouteIds are always present in the url and are just empty strings when not defined. This is
@@ -6695,7 +6719,7 @@
6695
6719
  includeRouteId: includeRouteId,
6696
6720
  includeRouteParameters: true
6697
6721
  }).forEach(function (def) {
6698
- var value = visit.getParameter(def.name);
6722
+ var value = visit.getParameterValue(def);
6699
6723
  if (!def.isEmptyValue(value)) {
6700
6724
  if (def.isArray) {
6701
6725
  pectin.assert.isArray(value);
@@ -6712,7 +6736,7 @@
6712
6736
  PlaceDefinition.prototype.getNonRouteParameters = function (visit) {
6713
6737
  var result = {};
6714
6738
  this.getVisitParameterDefs({ includeNonRouteParameters: true }).forEach(function (def) {
6715
- var value = visit.getParameter(def.name);
6739
+ var value = visit.getParameterValue(def);
6716
6740
  if (!def.isEmptyValue(value)) {
6717
6741
  result[def.name] = value;
6718
6742
  }
@@ -6777,15 +6801,29 @@
6777
6801
  var DEFINITION_META_DATA_KEY = 'PLACE_DEFINITION_OPTIONS';
6778
6802
  // this one seems ok.
6779
6803
  var ROUTE_PARAMETER_LIST_KEY = Symbol('place:route:parameters');
6804
+ var ParameterChangeInterceptor = /** @class */ (function () {
6805
+ function ParameterChangeInterceptor(parameterDef, model, callback, options) {
6806
+ }
6807
+ ParameterChangeInterceptor.prototype.canProceed = function (nextState, interactionContext) {
6808
+ return __awaiter(this, void 0, void 0, function () {
6809
+ return __generator(this, function (_a) {
6810
+ return [2 /*return*/, true];
6811
+ });
6812
+ });
6813
+ };
6814
+ return ParameterChangeInterceptor;
6815
+ }());
6780
6816
  exports.PlaceComponent = /** @class */ (function (_super) {
6781
6817
  __extends(PlaceComponent, _super);
6782
6818
  function PlaceComponent() {
6783
6819
  var _this = _super.call(this) || this;
6820
+ _this._placeReadyCallbacks = [];
6784
6821
  _this.visitModel = new pectin.MutableValueModel();
6785
6822
  _this._inVisitUpdate = new pectin.Guard();
6786
6823
  _this._active = new pectin.MutableValueModel(false);
6824
+ _this._parameterChangeInterceptors = [];
6787
6825
  var _a = pectin.Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
6788
- when(_this._active).becomesTruthy(function () { return _this.onPlaceReady(); });
6826
+ when(_this._active).becomesTruthy(function () { return _this._notifyPlaceReady(); });
6789
6827
  _this.childPlaces = _this.placeDefinition.children.map(function (d) { return d.component; });
6790
6828
  return _this;
6791
6829
  }
@@ -6818,7 +6856,7 @@
6818
6856
  pectin.DebugContext.tag(model, this.placeDefinition.component.name + "." + parameterDef.propertyName);
6819
6857
  var binding = this.registerDisposable(new pectin.Binding(this.visitModel, model, {
6820
6858
  toRight: function (visit) {
6821
- var value = visit.getParameter(parameterDef.name);
6859
+ var value = visit.getParameterValue(parameterDef);
6822
6860
  // console.log('push to component', { name: parameterDef.name, value, visit });
6823
6861
  return value;
6824
6862
  },
@@ -6831,7 +6869,11 @@
6831
6869
  };
6832
6870
  Object.defineProperty(PlaceComponent.prototype, "placeDefinition", {
6833
6871
  get: function () {
6834
- return PlaceComponent.getDefinition(this.constructor);
6872
+ var definition = PlaceComponent.getDefinition(this.constructor);
6873
+ if (!definition) {
6874
+ pectin.lang.illegalState(this.constructor.name + " extends PlaceComponent but doesn't have @Place({..}) decorator.");
6875
+ }
6876
+ return definition;
6835
6877
  },
6836
6878
  enumerable: false,
6837
6879
  configurable: true
@@ -6843,13 +6885,74 @@
6843
6885
  enumerable: false,
6844
6886
  configurable: true
6845
6887
  });
6888
+ /**
6889
+ * Called by the router to see if this component can deactivate. This isn't called for route parameter changes.
6890
+ * @param interactionContext
6891
+ */
6892
+ PlaceComponent.prototype._canLeavePlace = function (interactionContext) {
6893
+ return __awaiter(this, void 0, void 0, function () {
6894
+ return __generator(this, function (_a) {
6895
+ return [2 /*return*/, this.canDeactivate ? this.canDeactivate(interactionContext) : true];
6896
+ });
6897
+ });
6898
+ };
6899
+ /**
6900
+ * Called by the router to see if this component can deactivate. This isn't called for route parameter changes.
6901
+ * @param interactionContext
6902
+ * @param nextState
6903
+ */
6904
+ PlaceComponent.prototype._canChangeRouteParameters = function (interactionContext, nextState) {
6905
+ return __awaiter(this, void 0, void 0, function () {
6906
+ var visit, i, interceptor, keepGoing;
6907
+ return __generator(this, function (_a) {
6908
+ switch (_a.label) {
6909
+ case 0:
6910
+ if (!(this._parameterChangeInterceptors.length > 0)) return [3 /*break*/, 4];
6911
+ visit = nextState.createVisitFor(this.placeDefinition);
6912
+ i = 0;
6913
+ _a.label = 1;
6914
+ case 1:
6915
+ if (!(i < this._parameterChangeInterceptors.length)) return [3 /*break*/, 4];
6916
+ interceptor = this._parameterChangeInterceptors[i];
6917
+ return [4 /*yield*/, interceptor.canProceed(visit, interactionContext)];
6918
+ case 2:
6919
+ keepGoing = _a.sent();
6920
+ if (!keepGoing) {
6921
+ return [2 /*return*/, false];
6922
+ }
6923
+ _a.label = 3;
6924
+ case 3:
6925
+ i++;
6926
+ return [3 /*break*/, 1];
6927
+ case 4: return [2 /*return*/, true];
6928
+ }
6929
+ });
6930
+ });
6931
+ };
6846
6932
  /**
6847
6933
  * Called by the router when the place is ready to interact after any animations have run.
6848
6934
  */
6849
6935
  PlaceComponent.prototype._notifyActive = function (active) {
6850
6936
  this._active.value = active;
6851
6937
  };
6852
- PlaceComponent.prototype.onPlaceReady = function () {
6938
+ /**
6939
+ * Called by the router when the place is ready to interact after any animations have run.
6940
+ */
6941
+ PlaceComponent.prototype._notifyPlaceReady = function () {
6942
+ if (this.onPlaceReady.length === 1) {
6943
+ this._placeReadyCallbacks.forEach(function (callback) { return callback(); });
6944
+ }
6945
+ else {
6946
+ console.warn('Overriding PlaceComponent.onPlaceReady has been deprecated. Use PlaceComponent.onPlaceReady(() => {... do stuff...}) instead.');
6947
+ this.onPlaceReady(undefined);
6948
+ }
6949
+ };
6950
+ PlaceComponent.prototype.onPlaceReady = function (callback) {
6951
+ this._placeReadyCallbacks.push(callback);
6952
+ };
6953
+ PlaceComponent.prototype.interceptVisitParameterChange = function (model, callback, options) {
6954
+ var parameterDef = exports.ParameterDefinition.get(model);
6955
+ this._parameterChangeInterceptors.push(new ParameterChangeInterceptor(parameterDef, model, callback, options));
6853
6956
  };
6854
6957
  return PlaceComponent;
6855
6958
  }(DisposableComponent));
@@ -6890,6 +6993,250 @@
6890
6993
  PlaceComponent.injectDefinition = injectDefinition;
6891
6994
  })(exports.PlaceComponent || (exports.PlaceComponent = {}));
6892
6995
 
6996
+ /**
6997
+ * This a work around for the fact that an activated route with multiple segments doesn't
6998
+ * include the segment params in the paramMap as well as each segment returns an empty
6999
+ * param map even when `parameter`s has content.
7000
+ */
7001
+ var ConsolidatedParameterMap = /** @class */ (function () {
7002
+ function ConsolidatedParameterMap(urlSegments, paramMap) {
7003
+ this.paramMaps = [];
7004
+ // TODO: can we get all our params from teh url segments? If so we can drop the paramMap altogether.
7005
+ var segmentParams = (urlSegments || []).map(function (s) { return new ParamMapAdapter(s.parameters); });
7006
+ this.paramMaps = segmentParams
7007
+ .concat(paramMap)
7008
+ .filter(function (m) { return !!m; }); // the activated route param map can be null
7009
+ }
7010
+ ConsolidatedParameterMap.prototype.get = function (name) {
7011
+ var paramMap = this.paramMaps.find(function (m) { return m.has(name); });
7012
+ return paramMap.get(name);
7013
+ };
7014
+ ConsolidatedParameterMap.prototype.getAll = function (name) {
7015
+ var paramMap = this.paramMaps.find(function (m) { return m.has(name); });
7016
+ return paramMap.getAll(name);
7017
+ };
7018
+ ConsolidatedParameterMap.prototype.has = function (name) {
7019
+ return !!this.paramMaps.find(function (m) { return m.has(name); });
7020
+ };
7021
+ Object.defineProperty(ConsolidatedParameterMap.prototype, "keys", {
7022
+ get: function () {
7023
+ return this.paramMaps.reduce(function (result, params) { return result.concat(params.keys); }, []);
7024
+ },
7025
+ enumerable: false,
7026
+ configurable: true
7027
+ });
7028
+ return ConsolidatedParameterMap;
7029
+ }());
7030
+ __decorate([
7031
+ src.Memoize(),
7032
+ __metadata("design:type", Array),
7033
+ __metadata("design:paramtypes", [])
7034
+ ], ConsolidatedParameterMap.prototype, "keys", null);
7035
+ var ParamMapAdapter = /** @class */ (function () {
7036
+ function ParamMapAdapter(params) {
7037
+ this.params = params;
7038
+ }
7039
+ ParamMapAdapter.prototype.get = function (name) {
7040
+ return this.params[name];
7041
+ };
7042
+ ParamMapAdapter.prototype.getAll = function (name) {
7043
+ var value = this.get(name);
7044
+ return Array.isArray(value) ? value : [value];
7045
+ };
7046
+ ParamMapAdapter.prototype.has = function (name) {
7047
+ return this.keys.includes(name);
7048
+ };
7049
+ Object.defineProperty(ParamMapAdapter.prototype, "keys", {
7050
+ get: function () {
7051
+ return Object.keys(this.params);
7052
+ },
7053
+ enumerable: false,
7054
+ configurable: true
7055
+ });
7056
+ return ParamMapAdapter;
7057
+ }());
7058
+
7059
+ var Visit = /** @class */ (function () {
7060
+ function Visit(placeDefinition, visitParameters) {
7061
+ if (visitParameters === void 0) { visitParameters = {}; }
7062
+ this.placeDefinition = placeDefinition;
7063
+ this.visitParameters = visitParameters;
7064
+ }
7065
+ // @Trace()
7066
+ Visit.prototype.getRouteId = function () {
7067
+ return this.placeDefinition.getRouteIdFrom(this);
7068
+ };
7069
+ // @Trace()
7070
+ Visit.prototype.hasRouteId = function () {
7071
+ return !___namespace.isNil(this.getRouteId());
7072
+ };
7073
+ /**
7074
+ * Returns the value of the place parameter with the specified name. The parameter
7075
+ * name is taken from the `as` option, e.g. {as: 'aCustomName'} otherwise it is the
7076
+ * same as the the ValueModel property name.
7077
+ * @param parameterDef the visit parameter definition
7078
+ */
7079
+ Visit.prototype.getParameterValue = function (parameterDef) {
7080
+ return this.visitParameters[parameterDef.name];
7081
+ };
7082
+ // @Trace()
7083
+ Visit.prototype.hasParameter = function (parameterDef) {
7084
+ return Object.keys(this.visitParameters).includes(parameterDef.name);
7085
+ };
7086
+ Visit.prototype.replace = function (parameter, value) {
7087
+ var _a;
7088
+ return new Visit(this.placeDefinition, Object.assign(Object.assign({}, this.visitParameters), (_a = {}, _a[parameter.name] = value, _a)));
7089
+ };
7090
+ Visit.prototype.mergeRouteParameters = function (routeParams) {
7091
+ var _this = this;
7092
+ // todo: whitelist parameters.
7093
+ var routeParameterKeys = Object.keys(routeParams);
7094
+ var params = {};
7095
+ this.placeDefinition.getVisitParameterDefs().forEach(function (def) {
7096
+ if (def.isRouteId || def.isRouteParameter) {
7097
+ if (routeParameterKeys.includes(def.name)) {
7098
+ params[def.name] = routeParams[def.name];
7099
+ }
7100
+ }
7101
+ else {
7102
+ // copy non route params as is, but only if they already exist otherwise we'll inject nil values and break the
7103
+ // defaults and remember sanitisation process.
7104
+ var value = _this.getParameterValue(def);
7105
+ if (_this.hasParameter(def)) {
7106
+ params[def.name] = value;
7107
+ }
7108
+ }
7109
+ });
7110
+ return new Visit(this.placeDefinition, params);
7111
+ };
7112
+ Visit.prototype.hasRoutingChangedFrom = function (other) {
7113
+ var samePlace = other.placeDefinition === this.placeDefinition;
7114
+ var sameRouteParameters = ___namespace.isEqual(this.placeDefinition.getFormattedRouteParameters(this, true), this.placeDefinition.getFormattedRouteParameters(other, true));
7115
+ return !samePlace || !sameRouteParameters;
7116
+ };
7117
+ Visit.prototype.hasChangedFrom = function (other) {
7118
+ var sameNonRouteParameters = ___namespace.isEqual(this.placeDefinition.getNonRouteParameters(this), this.placeDefinition.getNonRouteParameters(other));
7119
+ return !sameNonRouteParameters || this.hasRoutingChangedFrom(other);
7120
+ };
7121
+ Visit.prototype.toDebugString = function () {
7122
+ var _this = this;
7123
+ return Object.keys(this.visitParameters).map(function (k) { return k + "=" + _this.visitParameters[k]; }).join(',');
7124
+ };
7125
+ return Visit;
7126
+ }());
7127
+
7128
+ function extractPrimarySegments(urlTree) {
7129
+ return urlTree.root.children.primary.segments;
7130
+ }
7131
+ exports.UrlSnapshot = /** @class */ (function () {
7132
+ // TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.
7133
+ function UrlSnapshot(urlSerializer, url) {
7134
+ this.urlSerializer = urlSerializer;
7135
+ this.url = url;
7136
+ this.urlTree = urlSerializer.parse(url);
7137
+ }
7138
+ UrlSnapshot.prototype.updateVisitSegments = function (visit) {
7139
+ var newUrlTree = this.urlSerializer.parse(this.url);
7140
+ // Ugly, but it works for now.
7141
+ var segments = __spreadArray([], __read(extractPrimarySegments(newUrlTree)));
7142
+ var visitSegments = this.getSegmentsFor(visit);
7143
+ var replaceAt = segments.findIndex(function (segment) { return segment.path === visitSegments[0].path; });
7144
+ // do not use the return value, it's the items that were removed!
7145
+ segments.splice.apply(segments, __spreadArray([replaceAt, visitSegments.length], __read(visitSegments)));
7146
+ newUrlTree.root.children.primary.segments = segments;
7147
+ return new UrlSnapshot(this.urlSerializer, newUrlTree.toString());
7148
+ };
7149
+ UrlSnapshot.prototype.getPrimarySegments = function () {
7150
+ return extractPrimarySegments(this.urlTree);
7151
+ };
7152
+ /**
7153
+ * Converts the visit into segments. Please not that these segments are not e
7154
+ * @param visit
7155
+ */
7156
+ UrlSnapshot.prototype.getSegmentsFor = function (visit) {
7157
+ return visit.placeDefinition.hasRouteId() ?
7158
+ [
7159
+ // NOTE:
7160
+ // It's important to attach the params to the root path and not the id. If we attach them
7161
+ // to an empty id then the angular router won't match the pattern.
7162
+ new i1$1.UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit)),
7163
+ new i1$1.UrlSegment(visit.placeDefinition.getFormattedRouteId(visit), {})
7164
+ ]
7165
+ :
7166
+ [
7167
+ new i1$1.UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit))
7168
+ ];
7169
+ };
7170
+ UrlSnapshot.prototype.includesPathOf = function (placeDef) {
7171
+ return this.getPrimarySegments().find(function (s) { return s.path === placeDef.path; });
7172
+ };
7173
+ UrlSnapshot.prototype.createVisitFor = function (placeDef) {
7174
+ return new Visit(placeDef, new ConsolidatedParameterMap(this.getPrimarySegments()));
7175
+ };
7176
+ UrlSnapshot.prototype.getInteractionIds = function () {
7177
+ var queryParam = this.urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM];
7178
+ if (queryParam) {
7179
+ return UrlSnapshot.parseInteractionIds(queryParam);
7180
+ }
7181
+ else {
7182
+ return [];
7183
+ }
7184
+ };
7185
+ UrlSnapshot.prototype.hasInteractions = function () {
7186
+ return this.getInteractionIds().length > 0;
7187
+ };
7188
+ UrlSnapshot.prototype.hasInteractionIds = function (ids) {
7189
+ return ___default['default'].isEqual(this.getInteractionIds(), ids);
7190
+ };
7191
+ // @Trace()
7192
+ UrlSnapshot.prototype.updateInteractionIds = function (ids) {
7193
+ if (ids.length === 0) {
7194
+ return this.removeInteractionIds();
7195
+ }
7196
+ else {
7197
+ var urlTree = this.urlSerializer.parse(this.url);
7198
+ urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM] = UrlSnapshot.createPathIdFor(ids);
7199
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString());
7200
+ }
7201
+ };
7202
+ // @Trace()
7203
+ UrlSnapshot.prototype.removeInteractionIds = function () {
7204
+ var urlTree = this.urlSerializer.parse(this.url);
7205
+ if (urlTree.queryParams && urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM]) {
7206
+ urlTree.queryParams = {}; //[UrlSnapshot.INTERACTION_ROUTER_OUTLET]
7207
+ }
7208
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString());
7209
+ };
7210
+ UrlSnapshot.prototype.toString = function () {
7211
+ return "UrlSnapshot(" + this.url + ")";
7212
+ };
7213
+ return UrlSnapshot;
7214
+ }());
7215
+ __decorate([
7216
+ pectin.Trace(),
7217
+ __metadata("design:type", Function),
7218
+ __metadata("design:paramtypes", [Visit]),
7219
+ __metadata("design:returntype", exports.UrlSnapshot)
7220
+ ], exports.UrlSnapshot.prototype, "updateVisitSegments", null);
7221
+ __decorate([
7222
+ src.Memoize(),
7223
+ __metadata("design:type", Function),
7224
+ __metadata("design:paramtypes", []),
7225
+ __metadata("design:returntype", Array)
7226
+ ], exports.UrlSnapshot.prototype, "getPrimarySegments", null);
7227
+ (function (UrlSnapshot) {
7228
+ UrlSnapshot.INTERACTION_QUERY_PARAM = 'aup-interactions';
7229
+ UrlSnapshot.INTERACTION_ID_SEPARATOR = '--';
7230
+ function parseInteractionIds(path) {
7231
+ return path.split(UrlSnapshot.INTERACTION_ID_SEPARATOR);
7232
+ }
7233
+ UrlSnapshot.parseInteractionIds = parseInteractionIds;
7234
+ function createPathIdFor(interactionIds) {
7235
+ return interactionIds.join(UrlSnapshot.INTERACTION_ID_SEPARATOR);
7236
+ }
7237
+ UrlSnapshot.createPathIdFor = createPathIdFor;
7238
+ })(exports.UrlSnapshot || (exports.UrlSnapshot = {}));
7239
+
6893
7240
  /**
6894
7241
  * This class handles the logic around canDeactivate for a given router state transition. It's core responsibilities are:
6895
7242
  * 1. Ensure we only ask the component to deactivate once on a given navigation cycle (since visit sanitisation can result in multiple round trips to through the router.)
@@ -6918,6 +7265,13 @@
6918
7265
  enumerable: false,
6919
7266
  configurable: true
6920
7267
  });
7268
+ Object.defineProperty(PlaceComponentDeactivationHandler.prototype, "placeDefinition", {
7269
+ get: function () {
7270
+ return this.component.placeDefinition;
7271
+ },
7272
+ enumerable: false,
7273
+ configurable: true
7274
+ });
6921
7275
  // @Trace()
6922
7276
  PlaceComponentDeactivationHandler.prototype.canDeactivate = function (currentUrl, nextState) {
6923
7277
  return __awaiter(this, void 0, void 0, function () {
@@ -6933,10 +7287,9 @@
6933
7287
  });
6934
7288
  });
6935
7289
  };
6936
- // @Trace()
6937
7290
  PlaceComponentDeactivationHandler.prototype.canDeactivateComponent = function (currentUrl, nextState) {
6938
7291
  return __awaiter(this, void 0, void 0, function () {
6939
- var routeIds, currentIds;
7292
+ var routeIds, currentIds, canLeave;
6940
7293
  return __generator(this, function (_a) {
6941
7294
  switch (_a.label) {
6942
7295
  case 0:
@@ -6957,27 +7310,26 @@
6957
7310
  _a.sent();
6958
7311
  return [2 /*return*/, false];
6959
7312
  case 5:
6960
- // Ok, so now we're really leaving, so we ask the component if we should.;
6961
- if (this.isNotJustAChangeInRouteId(nextState)) {
6962
- if (this.component.canDeactivate) {
6963
- // No interaction in progress, so ask the component .
6964
- // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
6965
- // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
6966
- return [2 /*return*/, this.component.canDeactivate(this.navigationSession.canDeactivateInteractionContext)];
6967
- }
6968
- // The component has an active interaction but no deactivation hook. Rather than guessing what to do
6969
- // we'll just cancel the navigation and print a warning.
6970
- if (this.routerInteractionAdapter.isComponentInteracting(this.component)) {
6971
- console.warn('Route changed while component has active interaction, cancelling navigation');
6972
- return [2 /*return*/, false];
6973
- }
7313
+ if (!this.isGoingToADifferentPlace(nextState)) return [3 /*break*/, 7];
7314
+ return [4 /*yield*/, this.component._canLeavePlace(this.navigationSession.canDeactivateInteractionContext)];
7315
+ case 6:
7316
+ canLeave = _a.sent();
7317
+ // The component has an active interaction but no deactivation hook. Rather than guessing what to do
7318
+ // we'll just cancel the navigation and print a warning.
7319
+ if (canLeave && this.routerInteractionAdapter.isComponentInteracting(this.component)) {
7320
+ console.warn('Route changed while component has active interaction, cancelling navigation');
7321
+ return [2 /*return*/, false];
6974
7322
  }
6975
- return [2 /*return*/, true];
7323
+ return [2 /*return*/, canLeave];
7324
+ case 7: return [4 /*yield*/, this.component._canChangeRouteParameters(this.navigationSession.canDeactivateInteractionContext, nextState)];
7325
+ case 8:
7326
+ // either an interaction or visit parameter change.
7327
+ return [2 /*return*/, _a.sent()];
6976
7328
  }
6977
7329
  });
6978
7330
  });
6979
7331
  };
6980
- PlaceComponentDeactivationHandler.prototype.isNotJustAChangeInRouteId = function (nextState) {
7332
+ PlaceComponentDeactivationHandler.prototype.isGoingToADifferentPlace = function (nextState) {
6981
7333
  // Because places with a route-id cover two route segments we get asked to deactivate
6982
7334
  // if the route id is added or removed. So if our path is still present the url
6983
7335
  // then we shouldn't deactivate the place.
@@ -6985,6 +7337,12 @@
6985
7337
  };
6986
7338
  return PlaceComponentDeactivationHandler;
6987
7339
  }());
7340
+ __decorate([
7341
+ pectin.Trace(),
7342
+ __metadata("design:type", Function),
7343
+ __metadata("design:paramtypes", [exports.UrlSnapshot, exports.UrlSnapshot]),
7344
+ __metadata("design:returntype", Promise)
7345
+ ], PlaceComponentDeactivationHandler.prototype, "canDeactivateComponent", null);
6988
7346
 
6989
7347
  /**
6990
7348
  * Transient states
@@ -7901,100 +8259,6 @@
7901
8259
  // }
7902
8260
  })(exports.PlaceHistory || (exports.PlaceHistory = {}));
7903
8261
 
7904
- exports.UrlSnapshot = /** @class */ (function () {
7905
- // TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.
7906
- function UrlSnapshot(urlSerializer, url) {
7907
- this.urlSerializer = urlSerializer;
7908
- this.url = url;
7909
- this.urlTree = urlSerializer.parse(url);
7910
- }
7911
- UrlSnapshot.prototype.updateVisitSegments = function (visit) {
7912
- var urlTree = this.urlSerializer.parse(this.url);
7913
- // Ugly, but it works for now.
7914
- var segments = __spreadArray([], __read(this.getPrimarySegments(urlTree)));
7915
- var visitSegments = this.getSegmentsFor(visit);
7916
- var replaceAt = segments.findIndex(function (segment) { return segment.path === visitSegments[0].path; });
7917
- // do not use the return value, it's the items that were removed!
7918
- segments.splice.apply(segments, __spreadArray([replaceAt, visitSegments.length], __read(visitSegments)));
7919
- urlTree.root.children.primary.segments = segments;
7920
- return new UrlSnapshot(this.urlSerializer, urlTree.toString());
7921
- };
7922
- UrlSnapshot.prototype.getPrimarySegments = function (urlTree) {
7923
- return this.urlTree.root.children.primary.segments;
7924
- };
7925
- /**
7926
- * Converts the visit into segments. Please not that these segments are not e
7927
- * @param visit
7928
- */
7929
- UrlSnapshot.prototype.getSegmentsFor = function (visit) {
7930
- return visit.placeDefinition.hasRouteId() ?
7931
- [
7932
- // NOTE:
7933
- // It's important to attach the params to the root path and not the id. If we attach them
7934
- // to an empty id then the angular router won't match the pattern.
7935
- new i1$1.UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit)),
7936
- new i1$1.UrlSegment(visit.placeDefinition.getFormattedRouteId(visit), {})
7937
- ]
7938
- :
7939
- [
7940
- new i1$1.UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit))
7941
- ];
7942
- };
7943
- UrlSnapshot.prototype.includesPathOf = function (placeDef) {
7944
- return this.getPrimarySegments(this.urlTree).find(function (s) { return s.path === placeDef.path; });
7945
- };
7946
- UrlSnapshot.prototype.getInteractionIds = function () {
7947
- var queryParam = this.urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM];
7948
- if (queryParam) {
7949
- return UrlSnapshot.parseInteractionIds(queryParam);
7950
- }
7951
- else {
7952
- return [];
7953
- }
7954
- };
7955
- UrlSnapshot.prototype.hasInteractions = function () {
7956
- return this.getInteractionIds().length > 0;
7957
- };
7958
- UrlSnapshot.prototype.hasInteractionIds = function (ids) {
7959
- return ___default['default'].isEqual(this.getInteractionIds(), ids);
7960
- };
7961
- // @Trace()
7962
- UrlSnapshot.prototype.updateInteractionIds = function (ids) {
7963
- if (ids.length === 0) {
7964
- return this.removeInteractionIds();
7965
- }
7966
- else {
7967
- var urlTree = this.urlSerializer.parse(this.url);
7968
- urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM] = UrlSnapshot.createPathIdFor(ids);
7969
- return new UrlSnapshot(this.urlSerializer, urlTree.toString());
7970
- }
7971
- };
7972
- // @Trace()
7973
- UrlSnapshot.prototype.removeInteractionIds = function () {
7974
- var urlTree = this.urlSerializer.parse(this.url);
7975
- if (urlTree.queryParams && urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM]) {
7976
- urlTree.queryParams = {}; //[UrlSnapshot.INTERACTION_ROUTER_OUTLET]
7977
- }
7978
- return new UrlSnapshot(this.urlSerializer, urlTree.toString());
7979
- };
7980
- UrlSnapshot.prototype.toString = function () {
7981
- return "UrlSnapshot(" + this.url + ")";
7982
- };
7983
- return UrlSnapshot;
7984
- }());
7985
- (function (UrlSnapshot) {
7986
- UrlSnapshot.INTERACTION_QUERY_PARAM = 'aup-interactions';
7987
- UrlSnapshot.INTERACTION_ID_SEPARATOR = '--';
7988
- function parseInteractionIds(path) {
7989
- return path.split(UrlSnapshot.INTERACTION_ID_SEPARATOR);
7990
- }
7991
- UrlSnapshot.parseInteractionIds = parseInteractionIds;
7992
- function createPathIdFor(interactionIds) {
7993
- return interactionIds.join(UrlSnapshot.INTERACTION_ID_SEPARATOR);
7994
- }
7995
- UrlSnapshot.createPathIdFor = createPathIdFor;
7996
- })(exports.UrlSnapshot || (exports.UrlSnapshot = {}));
7997
-
7998
8262
  var UrlService = /** @class */ (function () {
7999
8263
  function UrlService(angularRouter, angularLocation, urlSerializer) {
8000
8264
  this.angularRouter = angularRouter;
@@ -8292,7 +8556,7 @@
8292
8556
  });
8293
8557
  };
8294
8558
  PlaceRouter.prototype.navigateByUrl = function (urlSnapshot, navigationExtras) {
8295
- // console.log(`### navigationByUrl -> ${urlSnapshot.urlTree.toString()}`);
8559
+ console.log("### navigationByUrl -> " + urlSnapshot.urlTree.toString());
8296
8560
  return this.angularRouter.navigateByUrl(urlSnapshot.urlTree, navigationExtras);
8297
8561
  };
8298
8562
  Object.defineProperty(PlaceRouter.prototype, "activeVisits", {
@@ -8366,7 +8630,6 @@
8366
8630
  * to be able to capture the back button on the first page. If we don't then the back click will exit
8367
8631
  * the app directly and we don't get to ask.
8368
8632
  */
8369
- // @Trace()
8370
8633
  PlaceRouter.prototype.syncInteractionContextIdsWithRouter = function () {
8371
8634
  var _this = this;
8372
8635
  if (this.navigationSession) {
@@ -8410,6 +8673,12 @@
8410
8673
  { type: UrlService },
8411
8674
  { type: exports.PlaceHistory }
8412
8675
  ]; };
8676
+ __decorate([
8677
+ pectin.Trace(),
8678
+ __metadata("design:type", Function),
8679
+ __metadata("design:paramtypes", []),
8680
+ __metadata("design:returntype", Promise)
8681
+ ], exports.PlaceRouter.prototype, "syncInteractionContextIdsWithRouter", null);
8413
8682
  (function (PlaceRouter) {
8414
8683
  var State = /** @class */ (function () {
8415
8684
  function State(activeVisits) {
@@ -8426,75 +8695,6 @@
8426
8695
  PlaceRouter.State = State;
8427
8696
  })(exports.PlaceRouter || (exports.PlaceRouter = {}));
8428
8697
 
8429
- var Visit = /** @class */ (function () {
8430
- function Visit(placeDefinition, visitParameters) {
8431
- if (visitParameters === void 0) { visitParameters = {}; }
8432
- this.placeDefinition = placeDefinition;
8433
- this.visitParameters = visitParameters;
8434
- }
8435
- // @Trace()
8436
- Visit.prototype.getRouteId = function () {
8437
- return this.placeDefinition.getRouteIdFrom(this);
8438
- };
8439
- // @Trace()
8440
- Visit.prototype.hasRouteId = function () {
8441
- return !___namespace.isNil(this.getRouteId());
8442
- };
8443
- /**
8444
- * Returns the value of the place parameter with the specified name. The parameter
8445
- * name is taken from the `as` option, e.g. {as: 'aCustomName'} otherwise it is the
8446
- * same as the the ValueModel property name.
8447
- * @param parameterName the field name of the property model or the `as` option if specified.
8448
- */
8449
- Visit.prototype.getParameter = function (parameterName) {
8450
- return this.visitParameters[parameterName];
8451
- };
8452
- // @Trace()
8453
- Visit.prototype.hasParameter = function (parameterName) {
8454
- return Object.keys(this.visitParameters).includes(parameterName);
8455
- };
8456
- Visit.prototype.replace = function (parameter, value) {
8457
- var _a;
8458
- return new Visit(this.placeDefinition, Object.assign(Object.assign({}, this.visitParameters), (_a = {}, _a[parameter.name] = value, _a)));
8459
- };
8460
- Visit.prototype.mergeRouteParameters = function (routeParams) {
8461
- var _this = this;
8462
- // todo: whitelist parameters.
8463
- var routeParameterKeys = Object.keys(routeParams);
8464
- var params = {};
8465
- this.placeDefinition.getVisitParameterDefs().forEach(function (def) {
8466
- if (def.isRouteId || def.isRouteParameter) {
8467
- if (routeParameterKeys.includes(def.name)) {
8468
- params[def.name] = routeParams[def.name];
8469
- }
8470
- }
8471
- else {
8472
- // copy non route params as is, but only if they already exist otherwise we'll inject nil values and break the
8473
- // defaults and remember sanitisation process.
8474
- var value = _this.getParameter(def.name);
8475
- if (_this.hasParameter(def.name)) {
8476
- params[def.name] = value;
8477
- }
8478
- }
8479
- });
8480
- return new Visit(this.placeDefinition, params);
8481
- };
8482
- Visit.prototype.hasRoutingChangedFrom = function (other) {
8483
- var samePlace = other.placeDefinition === this.placeDefinition;
8484
- var sameRouteParameters = ___namespace.isEqual(this.placeDefinition.getFormattedRouteParameters(this, true), this.placeDefinition.getFormattedRouteParameters(other, true));
8485
- return !samePlace || !sameRouteParameters;
8486
- };
8487
- Visit.prototype.hasChangedFrom = function (other) {
8488
- var sameNonRouteParameters = ___namespace.isEqual(this.placeDefinition.getNonRouteParameters(this), this.placeDefinition.getNonRouteParameters(other));
8489
- return !sameNonRouteParameters || this.hasRoutingChangedFrom(other);
8490
- };
8491
- Visit.prototype.toDebugString = function () {
8492
- var _this = this;
8493
- return Object.keys(this.visitParameters).map(function (k) { return k + "=" + _this.visitParameters[k]; }).join(',');
8494
- };
8495
- return Visit;
8496
- }());
8497
-
8498
8698
  var AUP_PLACE_CONFIG = new i0.InjectionToken('AUP_PLACE_CONFIG');
8499
8699
 
8500
8700
  var NotAuthorisedNoticeComponent = /** @class */ (function () {
@@ -9205,64 +9405,6 @@
9205
9405
  };
9206
9406
  }
9207
9407
 
9208
- /**
9209
- * This a work around for the fact that an activated route with multiple segments doesn't
9210
- * include the segment params in the paramMap as well as each segment returns an empty
9211
- * param map even when `parameter`s has content.
9212
- */
9213
- var ConsolidatedParameterMap = /** @class */ (function () {
9214
- function ConsolidatedParameterMap(paramMap, urlSegments) {
9215
- this.paramMaps = [paramMap].concat((urlSegments || []).map(function (s) { return new ParamMapAdapter(s.parameters); })).filter(function (m) { return !!m; }); // the activated route param map can be null
9216
- }
9217
- ConsolidatedParameterMap.prototype.get = function (name) {
9218
- var paramMap = this.paramMaps.find(function (m) { return m.has(name); });
9219
- return paramMap.get(name);
9220
- };
9221
- ConsolidatedParameterMap.prototype.getAll = function (name) {
9222
- var paramMap = this.paramMaps.find(function (m) { return m.has(name); });
9223
- return paramMap.getAll(name);
9224
- };
9225
- ConsolidatedParameterMap.prototype.has = function (name) {
9226
- return !!this.paramMaps.find(function (m) { return m.has(name); });
9227
- };
9228
- Object.defineProperty(ConsolidatedParameterMap.prototype, "keys", {
9229
- get: function () {
9230
- return this.paramMaps.reduce(function (result, params) { return result.concat(params.keys); }, []);
9231
- },
9232
- enumerable: false,
9233
- configurable: true
9234
- });
9235
- return ConsolidatedParameterMap;
9236
- }());
9237
- __decorate([
9238
- src.Memoize(),
9239
- __metadata("design:type", Array),
9240
- __metadata("design:paramtypes", [])
9241
- ], ConsolidatedParameterMap.prototype, "keys", null);
9242
- var ParamMapAdapter = /** @class */ (function () {
9243
- function ParamMapAdapter(params) {
9244
- this.params = params;
9245
- }
9246
- ParamMapAdapter.prototype.get = function (name) {
9247
- return this.params[name];
9248
- };
9249
- ParamMapAdapter.prototype.getAll = function (name) {
9250
- var value = this.get(name);
9251
- return Array.isArray(value) ? value : [value];
9252
- };
9253
- ParamMapAdapter.prototype.has = function (name) {
9254
- return this.keys.includes(name);
9255
- };
9256
- Object.defineProperty(ParamMapAdapter.prototype, "keys", {
9257
- get: function () {
9258
- return Object.keys(this.params);
9259
- },
9260
- enumerable: false,
9261
- configurable: true
9262
- });
9263
- return ParamMapAdapter;
9264
- }());
9265
-
9266
9408
  var NoopAuthGuard = /** @class */ (function () {
9267
9409
  function NoopAuthGuard() {
9268
9410
  }
@@ -9324,7 +9466,7 @@
9324
9466
  case 3:
9325
9467
  if (!(i < parameterDefs.length)) return [3 /*break*/, 6];
9326
9468
  def = parameterDefs[i];
9327
- value = visit.getParameter(def.name);
9469
+ value = visit.getParameterValue(def);
9328
9470
  return [4 /*yield*/, def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector, this.navigationSession.isPopState)];
9329
9471
  case 4:
9330
9472
  sanitisedValue = _a.sent();
@@ -9379,7 +9521,7 @@
9379
9521
  return __generator(this, function (_a) {
9380
9522
  switch (_a.label) {
9381
9523
  case 0:
9382
- params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
9524
+ params = new ConsolidatedParameterMap(activatedRoute.url, activatedRoute.paramMap);
9383
9525
  parsedParams = placeDefinition_1.parseRouteParams(params);
9384
9526
  navigationSession = this.placeRouter.navigationSession;
9385
9527
  initialVisit = navigationSession.getVisitFor(placeDefinition_1) || new Visit(placeDefinition_1, parsedParams);
@@ -9440,27 +9582,6 @@
9440
9582
  var visit = result instanceof Visit ? result : new Visit(exports.PlaceComponent.getDefinition(result), {});
9441
9583
  return this.urlService.createUrlSnapshot(visit).urlTree;
9442
9584
  };
9443
- // protected async ensureAuthenticatedThen(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot, next: (placeDefinition: PlaceDefinition) => Promise<boolean | UrlTree>): Promise<boolean | UrlTree> {
9444
- // const authoriseResult = placeDefinition.authenticate ? await this.isAuthorised(activatedRoute, state) : true;
9445
- // if (authoriseResult === true) {
9446
- // // we're authorised, now run the place guards.
9447
- // return next(placeDefinition);
9448
- // } else {
9449
- // console.log('not authorised result', authoriseResult);
9450
- // return authoriseResult;
9451
- // }
9452
- // }
9453
- //
9454
- // // @Trace()
9455
- // protected async ensureAuthorisedThen(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot, next: (placeDefinition: PlaceDefinition) => Promise<boolean | UrlTree>): Promise<boolean | UrlTree> {
9456
- //
9457
- // }
9458
- // @Trace()
9459
- // async isAuthorised(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean | UrlTree> {
9460
- // const authorised = this.getAuthGuard(this.injector).canActivate(activatedRoute, state);
9461
- // return (authorised instanceof Observable) ? authorised.toPromise() : authorised;
9462
- // }
9463
- // abstract getAuthGuard(injector: Injector): CanActivate;
9464
9585
  // @Trace()
9465
9586
  PlaceGuard.prototype.cleanInteractionState = function (route, state, next) {
9466
9587
  return __awaiter(this, void 0, void 0, function () {
@@ -9535,12 +9656,14 @@
9535
9656
  Formatter.BOOLEAN = new BooleanType();
9536
9657
  })(exports.Formatter || (exports.Formatter = {}));
9537
9658
 
9538
- function installMechanics(prototype, propertyKey, backingModelFactory, tagPrefix, isEmpty) {
9659
+ function installMechanics(parameterDef, prototype, propertyKey, tagPrefix) {
9660
+ typescriptUtilities.Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, parameterDef);
9539
9661
  function getMechanics(instance, propertyName) {
9540
9662
  var key = "__mechanics_" + propertyName.toString();
9541
9663
  if (!instance[key]) {
9664
+ var backingModel = parameterDef.createBackingModel();
9542
9665
  instance[key] = {
9543
- backingModel: backingModelFactory(),
9666
+ backingModel: backingModel,
9544
9667
  binding: null
9545
9668
  };
9546
9669
  var tag = tagPrefix + "(" + prototype.constructor.name + "." + propertyKey.toString() + ")";
@@ -9564,12 +9687,12 @@
9564
9687
  toLeft: pectin.Functions.identity,
9565
9688
  toRight: pectin.Functions.identity
9566
9689
  });
9567
- if (isEmpty(userModel)) {
9690
+ if (parameterDef.isEmptyValue(userModel.value)) {
9568
9691
  // console.log(`Push visit to model for ${tag}`, {value: mechanics.backingModel.value});
9569
9692
  mechanics.binding.writeRight(); // push the visit into the user model;
9570
9693
  }
9571
9694
  else {
9572
- if (!isEmpty(mechanics.backingModel)) {
9695
+ if (!parameterDef.isEmptyValue(mechanics.backingModel.value)) {
9573
9696
  console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');
9574
9697
  }
9575
9698
  mechanics.binding.writeLeft(); // push the user model into the visit
@@ -9580,25 +9703,22 @@
9580
9703
  }
9581
9704
  function RouteId(type, options) {
9582
9705
  return function (prototype, propertyKey) {
9583
- var param = new exports.ParameterDefinition.RouteId(propertyKey.toString(), options, type);
9584
- typescriptUtilities.Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
9585
- installMechanics(prototype, propertyKey, function () { return new pectin.MutableValueModel(); }, '@RouteId', function (m) { return m.query().isNil(); });
9706
+ var parameterDef = new exports.ParameterDefinition.RouteId(propertyKey.toString(), options, type);
9707
+ installMechanics(parameterDef, prototype, propertyKey, '@RouteId');
9586
9708
  };
9587
9709
  }
9588
9710
  function VisitParameter(options) {
9589
9711
  var opts = typescriptUtilities.Opts.get(options);
9590
9712
  return function (prototype, propertyKey) {
9591
- var param = new exports.ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
9592
- typescriptUtilities.Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
9593
- installMechanics(prototype, propertyKey, function () { return new pectin.MutableValueModel(); }, '@VisitParameter', function (m) { return m.query().isNil(); });
9713
+ var parameterDef = new exports.ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
9714
+ installMechanics(parameterDef, prototype, propertyKey, '@VisitParameter');
9594
9715
  };
9595
9716
  }
9596
9717
  function VisitParameterList(options) {
9597
9718
  var opts = typescriptUtilities.Opts.get(options);
9598
9719
  return function (prototype, propertyKey) {
9599
- var param = new exports.ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
9600
- typescriptUtilities.Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
9601
- installMechanics(prototype, propertyKey, function () { return new pectin.MutableListModel(); }, '@VisitParameterList', function (m) { return m.query().isEmpty(); });
9720
+ var parameterDef = new exports.ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
9721
+ installMechanics(parameterDef, prototype, propertyKey, '@VisitParameterList');
9602
9722
  };
9603
9723
  }
9604
9724