@coolon/angular-ui-powerups 12.4.0-alpha.0 → 12.4.0-alpha.10

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 (90) hide show
  1. package/assets/empty-state.scss +11 -0
  2. package/assets/styles.scss +1 -0
  3. package/bundles/coolon-angular-ui-powerups-cypress.umd.js +382 -263
  4. package/bundles/coolon-angular-ui-powerups-cypress.umd.js.map +1 -1
  5. package/bundles/coolon-angular-ui-powerups.umd.js +241 -251
  6. package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
  7. package/coolon-angular-ui-powerups.metadata.json +1 -1
  8. package/cypress/builder.d.ts +48 -0
  9. package/cypress/components/aup-abstract-activity.d.ts +8 -0
  10. package/cypress/components/aup-activity.d.ts +8 -0
  11. package/cypress/components/aup-alert.d.ts +8 -0
  12. package/cypress/components/aup-command-face.d.ts +7 -0
  13. package/cypress/components/aup-command.d.ts +6 -18
  14. package/cypress/components/aup-empty-state.d.ts +3 -0
  15. package/cypress/components/aup-input.d.ts +8 -8
  16. package/cypress/components/aup-modal-activity.d.ts +4 -0
  17. package/cypress/components/aup-modal-alert.d.ts +6 -0
  18. package/cypress/components/aup-table.d.ts +1 -2
  19. package/cypress/components/button-mixin.d.ts +3 -1
  20. package/cypress/components/button.d.ts +4 -2
  21. package/cypress/coolon-angular-ui-powerups-cypress.metadata.json +1 -1
  22. package/cypress/exports.d.ts +8 -1
  23. package/cypress/page-builder.d.ts +10 -0
  24. package/cypress/page-element.d.ts +5 -2
  25. package/cypress/page.d.ts +10 -32
  26. package/cypress/path.d.ts +1 -1
  27. package/esm2015/cypress/builder.js +80 -0
  28. package/esm2015/cypress/builder.js.map +1 -0
  29. package/esm2015/cypress/builder.metadata.json +1 -0
  30. package/esm2015/cypress/components/aup-abstract-activity.js +11 -0
  31. package/esm2015/cypress/components/aup-abstract-activity.js.map +1 -0
  32. package/esm2015/cypress/components/aup-abstract-activity.metadata.json +1 -0
  33. package/esm2015/cypress/components/aup-activity.js +13 -0
  34. package/esm2015/cypress/components/aup-activity.js.map +1 -0
  35. package/esm2015/cypress/components/aup-activity.metadata.json +1 -0
  36. package/esm2015/cypress/components/aup-alert.js +13 -0
  37. package/esm2015/cypress/components/aup-alert.js.map +1 -0
  38. package/esm2015/cypress/components/aup-alert.metadata.json +1 -0
  39. package/esm2015/cypress/components/aup-command-face.js +20 -18
  40. package/esm2015/cypress/components/aup-command-face.js.map +1 -1
  41. package/esm2015/cypress/components/aup-command-face.metadata.json +1 -1
  42. package/esm2015/cypress/components/aup-command.js +25 -9
  43. package/esm2015/cypress/components/aup-command.js.map +1 -1
  44. package/esm2015/cypress/components/aup-command.metadata.json +1 -1
  45. package/esm2015/cypress/components/aup-empty-state.js +4 -0
  46. package/esm2015/cypress/components/aup-empty-state.js.map +1 -0
  47. package/esm2015/cypress/components/aup-empty-state.metadata.json +1 -0
  48. package/esm2015/cypress/components/aup-input.js +7 -7
  49. package/esm2015/cypress/components/aup-input.js.map +1 -1
  50. package/esm2015/cypress/components/aup-modal-activity.js +7 -0
  51. package/esm2015/cypress/components/aup-modal-activity.js.map +1 -0
  52. package/esm2015/cypress/components/aup-modal-activity.metadata.json +1 -0
  53. package/esm2015/cypress/components/aup-modal-alert.js +12 -0
  54. package/esm2015/cypress/components/aup-modal-alert.js.map +1 -0
  55. package/esm2015/cypress/components/aup-modal-alert.metadata.json +1 -0
  56. package/esm2015/cypress/components/aup-table.js.map +1 -1
  57. package/esm2015/cypress/components/aup-table.metadata.json +1 -1
  58. package/esm2015/cypress/components/button.js.map +1 -1
  59. package/esm2015/cypress/components/button.metadata.json +1 -1
  60. package/esm2015/cypress/exports.js +8 -1
  61. package/esm2015/cypress/exports.js.map +1 -1
  62. package/esm2015/cypress/exports.metadata.json +1 -1
  63. package/esm2015/cypress/page-builder.js +20 -0
  64. package/esm2015/cypress/page-builder.js.map +1 -0
  65. package/esm2015/cypress/page-builder.metadata.json +1 -0
  66. package/esm2015/cypress/page-element.js +9 -3
  67. package/esm2015/cypress/page-element.js.map +1 -1
  68. package/esm2015/cypress/page-element.metadata.json +1 -1
  69. package/esm2015/cypress/page.js +13 -14
  70. package/esm2015/cypress/page.js.map +1 -1
  71. package/esm2015/cypress/page.metadata.json +1 -1
  72. package/esm2015/cypress/path.js +5 -3
  73. package/esm2015/cypress/path.js.map +1 -1
  74. package/esm2015/lib/components/empty-state/empty-state.component.js +1 -1
  75. package/esm2015/lib/components/empty-state/empty-state.component.metadata.json +1 -1
  76. package/esm2015/lib/place/navigation/place-component-deactivation-handler.js +3 -9
  77. package/esm2015/lib/place/navigation/place-component-deactivation-handler.js.map +1 -1
  78. package/esm2015/lib/place/navigation/place-component-deactivation-handler.metadata.json +1 -1
  79. package/esm2015/lib/place/url-snapshot.js +1 -7
  80. package/esm2015/lib/place/url-snapshot.js.map +1 -1
  81. package/esm2015/lib/place/url-snapshot.metadata.json +1 -1
  82. package/fesm2015/coolon-angular-ui-powerups-cypress.js +284 -169
  83. package/fesm2015/coolon-angular-ui-powerups-cypress.js.map +1 -1
  84. package/fesm2015/coolon-angular-ui-powerups.js +225 -235
  85. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  86. package/package.json +1 -1
  87. package/cypress/section.d.ts +0 -49
  88. package/esm2015/cypress/section.js +0 -58
  89. package/esm2015/cypress/section.js.map +0 -1
  90. package/esm2015/cypress/section.metadata.json +0 -1
@@ -1138,7 +1138,7 @@ EmptyStateComponent.decorators = [
1138
1138
  <ng-content></ng-content>
1139
1139
  </div>
1140
1140
  `,
1141
- styles: [":host{display:flex;flex-direction:column;justify-content:center;align-items:center}.container{padding:var(--aup-default-padding);border:2px dashed rgba(0,0,0,.2);border-radius:5px;font-size:14px;font-weight:300}"]
1141
+ styles: [":host{display:flex;flex-direction:column;justify-content:center;align-items:center}.container{display:flex;flex-direction:column;align-items:stretch;padding:var(--aup-default-padding);border:2px dashed rgba(0,0,0,.2);border-radius:5px;font-size:14px;font-weight:300}"]
1142
1142
  },] }
1143
1143
  ];
1144
1144
  EmptyStateComponent.ctorParameters = () => [];
@@ -5979,234 +5979,6 @@ __decorate([
5979
5979
  PlaceComponent.injectDefinition = injectDefinition;
5980
5980
  })(PlaceComponent || (PlaceComponent = {}));
5981
5981
 
5982
- /**
5983
- * This a work around for the fact that an activated route with multiple segments doesn't
5984
- * include the segment params in the paramMap as well as each segment returns an empty
5985
- * param map even when `parameter`s has content.
5986
- */
5987
- class ConsolidatedParameterMap {
5988
- constructor(urlSegments, paramMap) {
5989
- this.paramMaps = [];
5990
- // TODO: can we get all our params from teh url segments? If so we can drop the paramMap altogether.
5991
- const segmentParams = (urlSegments || []).map(s => new ParamMapAdapter(s.parameters));
5992
- this.paramMaps = segmentParams
5993
- .concat(paramMap)
5994
- .filter(m => !!m); // the activated route param map can be null
5995
- }
5996
- get(name) {
5997
- const paramMap = this.paramMaps.find(m => m.has(name));
5998
- return paramMap.get(name);
5999
- }
6000
- getAll(name) {
6001
- const paramMap = this.paramMaps.find(m => m.has(name));
6002
- return paramMap.getAll(name);
6003
- }
6004
- has(name) {
6005
- return !!this.paramMaps.find(m => m.has(name));
6006
- }
6007
- get keys() {
6008
- return this.paramMaps.reduce((result, params) => result.concat(params.keys), []);
6009
- }
6010
- }
6011
- __decorate([
6012
- Memoize(),
6013
- __metadata("design:type", Array),
6014
- __metadata("design:paramtypes", [])
6015
- ], ConsolidatedParameterMap.prototype, "keys", null);
6016
- class ParamMapAdapter {
6017
- constructor(params) {
6018
- this.params = params;
6019
- }
6020
- get(name) {
6021
- return this.params[name];
6022
- }
6023
- getAll(name) {
6024
- const value = this.get(name);
6025
- return Array.isArray(value) ? value : [value];
6026
- }
6027
- has(name) {
6028
- return this.keys.includes(name);
6029
- }
6030
- get keys() {
6031
- return Object.keys(this.params);
6032
- }
6033
- }
6034
-
6035
- class Visit {
6036
- constructor(placeDefinition, visitParameters = {}) {
6037
- this.placeDefinition = placeDefinition;
6038
- this.visitParameters = visitParameters;
6039
- }
6040
- // @Trace()
6041
- getRouteId() {
6042
- return this.placeDefinition.getRouteIdFrom(this);
6043
- }
6044
- // @Trace()
6045
- hasRouteId() {
6046
- return !_.isNil(this.getRouteId());
6047
- }
6048
- /**
6049
- * Returns the value of the place parameter with the specified name. The parameter
6050
- * name is taken from the `as` option, e.g. {as: 'aCustomName'} otherwise it is the
6051
- * same as the the ValueModel property name.
6052
- * @param parameterDef the visit parameter definition
6053
- */
6054
- getParameterValue(parameterDef) {
6055
- return this.visitParameters[parameterDef.name];
6056
- }
6057
- // @Trace()
6058
- hasParameter(parameterDef) {
6059
- return Object.keys(this.visitParameters).includes(parameterDef.name);
6060
- }
6061
- replace(parameter, value) {
6062
- return new Visit(this.placeDefinition, Object.assign(Object.assign({}, this.visitParameters), { [parameter.name]: value }));
6063
- }
6064
- mergeRouteParameters(routeParams) {
6065
- // todo: whitelist parameters.
6066
- const routeParameterKeys = Object.keys(routeParams);
6067
- const params = {};
6068
- this.placeDefinition.getVisitParameterDefs().forEach(def => {
6069
- if (def.isRouteId || def.isRouteParameter) {
6070
- if (routeParameterKeys.includes(def.name)) {
6071
- params[def.name] = routeParams[def.name];
6072
- }
6073
- }
6074
- else {
6075
- // copy non route params as is, but only if they already exist otherwise we'll inject nil values and break the
6076
- // defaults and remember sanitisation process.
6077
- const value = this.getParameterValue(def);
6078
- if (this.hasParameter(def)) {
6079
- params[def.name] = value;
6080
- }
6081
- }
6082
- });
6083
- return new Visit(this.placeDefinition, params);
6084
- }
6085
- hasRoutingChangedFrom(other) {
6086
- const samePlace = other.placeDefinition === this.placeDefinition;
6087
- const sameRouteParameters = _.isEqual(this.placeDefinition.getFormattedRouteParameters(this, true), this.placeDefinition.getFormattedRouteParameters(other, true));
6088
- return !samePlace || !sameRouteParameters;
6089
- }
6090
- hasChangedFrom(other) {
6091
- const sameNonRouteParameters = _.isEqual(this.placeDefinition.getNonRouteParameters(this), this.placeDefinition.getNonRouteParameters(other));
6092
- return !sameNonRouteParameters || this.hasRoutingChangedFrom(other);
6093
- }
6094
- toDebugString() {
6095
- return Object.keys(this.visitParameters).map(k => `${k}=${this.visitParameters[k]}`).join(',');
6096
- }
6097
- }
6098
-
6099
- function extractPrimarySegments(urlTree) {
6100
- return urlTree.root.children.primary.segments;
6101
- }
6102
- class UrlSnapshot {
6103
- // TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.
6104
- constructor(urlSerializer, url) {
6105
- this.urlSerializer = urlSerializer;
6106
- this.url = url;
6107
- this.urlTree = urlSerializer.parse(url);
6108
- }
6109
- updateVisitSegments(visit) {
6110
- const newUrlTree = this.urlSerializer.parse(this.url);
6111
- // Ugly, but it works for now.
6112
- const segments = [...extractPrimarySegments(newUrlTree)];
6113
- const visitSegments = this.getSegmentsFor(visit);
6114
- const replaceAt = segments.findIndex(segment => segment.path === visitSegments[0].path);
6115
- // do not use the return value, it's the items that were removed!
6116
- segments.splice(replaceAt, visitSegments.length, ...visitSegments);
6117
- newUrlTree.root.children.primary.segments = segments;
6118
- return new UrlSnapshot(this.urlSerializer, newUrlTree.toString());
6119
- }
6120
- getPrimarySegments() {
6121
- return extractPrimarySegments(this.urlTree);
6122
- }
6123
- /**
6124
- * Converts the visit into segments. Please not that these segments are not e
6125
- * @param visit
6126
- */
6127
- getSegmentsFor(visit) {
6128
- return visit.placeDefinition.hasRouteId() ?
6129
- [
6130
- // NOTE:
6131
- // It's important to attach the params to the root path and not the id. If we attach them
6132
- // to an empty id then the angular router won't match the pattern.
6133
- new UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit)),
6134
- new UrlSegment(visit.placeDefinition.getFormattedRouteId(visit), {})
6135
- ]
6136
- :
6137
- [
6138
- new UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit))
6139
- ];
6140
- }
6141
- includesPathOf(placeDef) {
6142
- return this.getPrimarySegments().find(s => s.path === placeDef.path);
6143
- }
6144
- createVisitFor(placeDef) {
6145
- return new Visit(placeDef, new ConsolidatedParameterMap(this.getPrimarySegments()));
6146
- }
6147
- getInteractionIds() {
6148
- const queryParam = this.urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM];
6149
- if (queryParam) {
6150
- return UrlSnapshot.parseInteractionIds(queryParam);
6151
- }
6152
- else {
6153
- return [];
6154
- }
6155
- }
6156
- hasInteractions() {
6157
- return this.getInteractionIds().length > 0;
6158
- }
6159
- hasInteractionIds(ids) {
6160
- return ___default.isEqual(this.getInteractionIds(), ids);
6161
- }
6162
- // @Trace()
6163
- updateInteractionIds(ids) {
6164
- if (ids.length === 0) {
6165
- return this.removeInteractionIds();
6166
- }
6167
- else {
6168
- const urlTree = this.urlSerializer.parse(this.url);
6169
- urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM] = UrlSnapshot.createPathIdFor(ids);
6170
- return new UrlSnapshot(this.urlSerializer, urlTree.toString());
6171
- }
6172
- }
6173
- // @Trace()
6174
- removeInteractionIds() {
6175
- const urlTree = this.urlSerializer.parse(this.url);
6176
- if (urlTree.queryParams && urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM]) {
6177
- urlTree.queryParams = {}; //[UrlSnapshot.INTERACTION_ROUTER_OUTLET]
6178
- }
6179
- return new UrlSnapshot(this.urlSerializer, urlTree.toString());
6180
- }
6181
- toString() {
6182
- return `UrlSnapshot(${this.url})`;
6183
- }
6184
- }
6185
- __decorate([
6186
- Trace(),
6187
- __metadata("design:type", Function),
6188
- __metadata("design:paramtypes", [Visit]),
6189
- __metadata("design:returntype", UrlSnapshot)
6190
- ], UrlSnapshot.prototype, "updateVisitSegments", null);
6191
- __decorate([
6192
- Memoize(),
6193
- __metadata("design:type", Function),
6194
- __metadata("design:paramtypes", []),
6195
- __metadata("design:returntype", Array)
6196
- ], UrlSnapshot.prototype, "getPrimarySegments", null);
6197
- (function (UrlSnapshot) {
6198
- UrlSnapshot.INTERACTION_QUERY_PARAM = 'aup-interactions';
6199
- UrlSnapshot.INTERACTION_ID_SEPARATOR = '--';
6200
- function parseInteractionIds(path) {
6201
- return path.split(UrlSnapshot.INTERACTION_ID_SEPARATOR);
6202
- }
6203
- UrlSnapshot.parseInteractionIds = parseInteractionIds;
6204
- function createPathIdFor(interactionIds) {
6205
- return interactionIds.join(UrlSnapshot.INTERACTION_ID_SEPARATOR);
6206
- }
6207
- UrlSnapshot.createPathIdFor = createPathIdFor;
6208
- })(UrlSnapshot || (UrlSnapshot = {}));
6209
-
6210
5982
  /**
6211
5983
  * This class handles the logic around canDeactivate for a given router state transition. It's core responsibilities are:
6212
5984
  * 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.)
@@ -6243,6 +6015,7 @@ class PlaceComponentDeactivationHandler {
6243
6015
  return this.canDeactivatePromise;
6244
6016
  });
6245
6017
  }
6018
+ // @Trace()
6246
6019
  canDeactivateComponent(currentUrl, nextState) {
6247
6020
  return __awaiter(this, void 0, void 0, function* () {
6248
6021
  // Automatically cancel any active activities if the navigation session was triggered by the back button.
@@ -6290,12 +6063,6 @@ class PlaceComponentDeactivationHandler {
6290
6063
  return !nextState.includesPathOf(this.component.placeDefinition);
6291
6064
  }
6292
6065
  }
6293
- __decorate([
6294
- Trace(),
6295
- __metadata("design:type", Function),
6296
- __metadata("design:paramtypes", [UrlSnapshot, UrlSnapshot]),
6297
- __metadata("design:returntype", Promise)
6298
- ], PlaceComponentDeactivationHandler.prototype, "canDeactivateComponent", null);
6299
6066
 
6300
6067
  /**
6301
6068
  * Transient states
@@ -7125,6 +6892,229 @@ PlaceHistory.ctorParameters = () => [];
7125
6892
  // }
7126
6893
  })(PlaceHistory || (PlaceHistory = {}));
7127
6894
 
6895
+ /**
6896
+ * This a work around for the fact that an activated route with multiple segments doesn't
6897
+ * include the segment params in the paramMap as well as each segment returns an empty
6898
+ * param map even when `parameter`s has content.
6899
+ */
6900
+ class ConsolidatedParameterMap {
6901
+ constructor(urlSegments, paramMap) {
6902
+ this.paramMaps = [];
6903
+ // TODO: can we get all our params from teh url segments? If so we can drop the paramMap altogether.
6904
+ const segmentParams = (urlSegments || []).map(s => new ParamMapAdapter(s.parameters));
6905
+ this.paramMaps = segmentParams
6906
+ .concat(paramMap)
6907
+ .filter(m => !!m); // the activated route param map can be null
6908
+ }
6909
+ get(name) {
6910
+ const paramMap = this.paramMaps.find(m => m.has(name));
6911
+ return paramMap.get(name);
6912
+ }
6913
+ getAll(name) {
6914
+ const paramMap = this.paramMaps.find(m => m.has(name));
6915
+ return paramMap.getAll(name);
6916
+ }
6917
+ has(name) {
6918
+ return !!this.paramMaps.find(m => m.has(name));
6919
+ }
6920
+ get keys() {
6921
+ return this.paramMaps.reduce((result, params) => result.concat(params.keys), []);
6922
+ }
6923
+ }
6924
+ __decorate([
6925
+ Memoize(),
6926
+ __metadata("design:type", Array),
6927
+ __metadata("design:paramtypes", [])
6928
+ ], ConsolidatedParameterMap.prototype, "keys", null);
6929
+ class ParamMapAdapter {
6930
+ constructor(params) {
6931
+ this.params = params;
6932
+ }
6933
+ get(name) {
6934
+ return this.params[name];
6935
+ }
6936
+ getAll(name) {
6937
+ const value = this.get(name);
6938
+ return Array.isArray(value) ? value : [value];
6939
+ }
6940
+ has(name) {
6941
+ return this.keys.includes(name);
6942
+ }
6943
+ get keys() {
6944
+ return Object.keys(this.params);
6945
+ }
6946
+ }
6947
+
6948
+ class Visit {
6949
+ constructor(placeDefinition, visitParameters = {}) {
6950
+ this.placeDefinition = placeDefinition;
6951
+ this.visitParameters = visitParameters;
6952
+ }
6953
+ // @Trace()
6954
+ getRouteId() {
6955
+ return this.placeDefinition.getRouteIdFrom(this);
6956
+ }
6957
+ // @Trace()
6958
+ hasRouteId() {
6959
+ return !_.isNil(this.getRouteId());
6960
+ }
6961
+ /**
6962
+ * Returns the value of the place parameter with the specified name. The parameter
6963
+ * name is taken from the `as` option, e.g. {as: 'aCustomName'} otherwise it is the
6964
+ * same as the the ValueModel property name.
6965
+ * @param parameterDef the visit parameter definition
6966
+ */
6967
+ getParameterValue(parameterDef) {
6968
+ return this.visitParameters[parameterDef.name];
6969
+ }
6970
+ // @Trace()
6971
+ hasParameter(parameterDef) {
6972
+ return Object.keys(this.visitParameters).includes(parameterDef.name);
6973
+ }
6974
+ replace(parameter, value) {
6975
+ return new Visit(this.placeDefinition, Object.assign(Object.assign({}, this.visitParameters), { [parameter.name]: value }));
6976
+ }
6977
+ mergeRouteParameters(routeParams) {
6978
+ // todo: whitelist parameters.
6979
+ const routeParameterKeys = Object.keys(routeParams);
6980
+ const params = {};
6981
+ this.placeDefinition.getVisitParameterDefs().forEach(def => {
6982
+ if (def.isRouteId || def.isRouteParameter) {
6983
+ if (routeParameterKeys.includes(def.name)) {
6984
+ params[def.name] = routeParams[def.name];
6985
+ }
6986
+ }
6987
+ else {
6988
+ // copy non route params as is, but only if they already exist otherwise we'll inject nil values and break the
6989
+ // defaults and remember sanitisation process.
6990
+ const value = this.getParameterValue(def);
6991
+ if (this.hasParameter(def)) {
6992
+ params[def.name] = value;
6993
+ }
6994
+ }
6995
+ });
6996
+ return new Visit(this.placeDefinition, params);
6997
+ }
6998
+ hasRoutingChangedFrom(other) {
6999
+ const samePlace = other.placeDefinition === this.placeDefinition;
7000
+ const sameRouteParameters = _.isEqual(this.placeDefinition.getFormattedRouteParameters(this, true), this.placeDefinition.getFormattedRouteParameters(other, true));
7001
+ return !samePlace || !sameRouteParameters;
7002
+ }
7003
+ hasChangedFrom(other) {
7004
+ const sameNonRouteParameters = _.isEqual(this.placeDefinition.getNonRouteParameters(this), this.placeDefinition.getNonRouteParameters(other));
7005
+ return !sameNonRouteParameters || this.hasRoutingChangedFrom(other);
7006
+ }
7007
+ toDebugString() {
7008
+ return Object.keys(this.visitParameters).map(k => `${k}=${this.visitParameters[k]}`).join(',');
7009
+ }
7010
+ }
7011
+
7012
+ function extractPrimarySegments(urlTree) {
7013
+ return urlTree.root.children.primary.segments;
7014
+ }
7015
+ class UrlSnapshot {
7016
+ // TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.
7017
+ constructor(urlSerializer, url) {
7018
+ this.urlSerializer = urlSerializer;
7019
+ this.url = url;
7020
+ this.urlTree = urlSerializer.parse(url);
7021
+ }
7022
+ // @Trace()
7023
+ updateVisitSegments(visit) {
7024
+ const newUrlTree = this.urlSerializer.parse(this.url);
7025
+ // Ugly, but it works for now.
7026
+ const segments = [...extractPrimarySegments(newUrlTree)];
7027
+ const visitSegments = this.getSegmentsFor(visit);
7028
+ const replaceAt = segments.findIndex(segment => segment.path === visitSegments[0].path);
7029
+ // do not use the return value, it's the items that were removed!
7030
+ segments.splice(replaceAt, visitSegments.length, ...visitSegments);
7031
+ newUrlTree.root.children.primary.segments = segments;
7032
+ return new UrlSnapshot(this.urlSerializer, newUrlTree.toString());
7033
+ }
7034
+ getPrimarySegments() {
7035
+ return extractPrimarySegments(this.urlTree);
7036
+ }
7037
+ /**
7038
+ * Converts the visit into segments. Please not that these segments are not e
7039
+ * @param visit
7040
+ */
7041
+ getSegmentsFor(visit) {
7042
+ return visit.placeDefinition.hasRouteId() ?
7043
+ [
7044
+ // NOTE:
7045
+ // It's important to attach the params to the root path and not the id. If we attach them
7046
+ // to an empty id then the angular router won't match the pattern.
7047
+ new UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit)),
7048
+ new UrlSegment(visit.placeDefinition.getFormattedRouteId(visit), {})
7049
+ ]
7050
+ :
7051
+ [
7052
+ new UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit))
7053
+ ];
7054
+ }
7055
+ includesPathOf(placeDef) {
7056
+ return this.getPrimarySegments().find(s => s.path === placeDef.path);
7057
+ }
7058
+ createVisitFor(placeDef) {
7059
+ return new Visit(placeDef, new ConsolidatedParameterMap(this.getPrimarySegments()));
7060
+ }
7061
+ getInteractionIds() {
7062
+ const queryParam = this.urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM];
7063
+ if (queryParam) {
7064
+ return UrlSnapshot.parseInteractionIds(queryParam);
7065
+ }
7066
+ else {
7067
+ return [];
7068
+ }
7069
+ }
7070
+ hasInteractions() {
7071
+ return this.getInteractionIds().length > 0;
7072
+ }
7073
+ hasInteractionIds(ids) {
7074
+ return ___default.isEqual(this.getInteractionIds(), ids);
7075
+ }
7076
+ // @Trace()
7077
+ updateInteractionIds(ids) {
7078
+ if (ids.length === 0) {
7079
+ return this.removeInteractionIds();
7080
+ }
7081
+ else {
7082
+ const urlTree = this.urlSerializer.parse(this.url);
7083
+ urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM] = UrlSnapshot.createPathIdFor(ids);
7084
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString());
7085
+ }
7086
+ }
7087
+ // @Trace()
7088
+ removeInteractionIds() {
7089
+ const urlTree = this.urlSerializer.parse(this.url);
7090
+ if (urlTree.queryParams && urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM]) {
7091
+ urlTree.queryParams = {}; //[UrlSnapshot.INTERACTION_ROUTER_OUTLET]
7092
+ }
7093
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString());
7094
+ }
7095
+ toString() {
7096
+ return `UrlSnapshot(${this.url})`;
7097
+ }
7098
+ }
7099
+ __decorate([
7100
+ Memoize(),
7101
+ __metadata("design:type", Function),
7102
+ __metadata("design:paramtypes", []),
7103
+ __metadata("design:returntype", Array)
7104
+ ], UrlSnapshot.prototype, "getPrimarySegments", null);
7105
+ (function (UrlSnapshot) {
7106
+ UrlSnapshot.INTERACTION_QUERY_PARAM = 'aup-interactions';
7107
+ UrlSnapshot.INTERACTION_ID_SEPARATOR = '--';
7108
+ function parseInteractionIds(path) {
7109
+ return path.split(UrlSnapshot.INTERACTION_ID_SEPARATOR);
7110
+ }
7111
+ UrlSnapshot.parseInteractionIds = parseInteractionIds;
7112
+ function createPathIdFor(interactionIds) {
7113
+ return interactionIds.join(UrlSnapshot.INTERACTION_ID_SEPARATOR);
7114
+ }
7115
+ UrlSnapshot.createPathIdFor = createPathIdFor;
7116
+ })(UrlSnapshot || (UrlSnapshot = {}));
7117
+
7128
7118
  class UrlService {
7129
7119
  constructor(angularRouter, angularLocation, urlSerializer) {
7130
7120
  this.angularRouter = angularRouter;