@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
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"EmptyStateComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":2,"character":1},"arguments":[{"selector":"aup-empty-state","template":"\n <div class=\"container\">\n <ng-content></ng-content>\n </div>\n ","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}"]}]}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"ngOnInit":[{"__symbolic":"method"}]}}}}]
1
+ [{"__symbolic":"module","version":4,"metadata":{"EmptyStateComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":2,"character":1},"arguments":[{"selector":"aup-empty-state","template":"\n <div class=\"container\">\n <ng-content></ng-content>\n </div>\n ","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}"]}]}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"ngOnInit":[{"__symbolic":"method"}]}}}}]
@@ -1,7 +1,6 @@
1
- import { __awaiter, __decorate, __metadata } from "tslib";
2
- import { Trace, assert } from '@coolon/pectin';
1
+ import { __awaiter } from "tslib";
2
+ import { assert } from '@coolon/pectin';
3
3
  import * as _ from 'lodash';
4
- import { UrlSnapshot } from '../url-snapshot';
5
4
  /**
6
5
  * This class handles the logic around canDeactivate for a given router state transition. It's core responsibilities are:
7
6
  * 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.)
@@ -38,6 +37,7 @@ export class PlaceComponentDeactivationHandler {
38
37
  return this.canDeactivatePromise;
39
38
  });
40
39
  }
40
+ // @Trace()
41
41
  canDeactivateComponent(currentUrl, nextState) {
42
42
  return __awaiter(this, void 0, void 0, function* () {
43
43
  // Automatically cancel any active activities if the navigation session was triggered by the back button.
@@ -85,10 +85,4 @@ export class PlaceComponentDeactivationHandler {
85
85
  return !nextState.includesPathOf(this.component.placeDefinition);
86
86
  }
87
87
  }
88
- __decorate([
89
- Trace(),
90
- __metadata("design:type", Function),
91
- __metadata("design:paramtypes", [UrlSnapshot, UrlSnapshot]),
92
- __metadata("design:returntype", Promise)
93
- ], PlaceComponentDeactivationHandler.prototype, "canDeactivateComponent", null);
94
88
  //# sourceMappingURL=place-component-deactivation-handler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"place-component-deactivation-handler.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/place/navigation/place-component-deactivation-handler.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C;;;;;;GAMG;AACH,MAAM,OAAO,iCAAiC;IAI5C,YAAqB,SAAyB,EAAW,iBAAoC,EAAW,kBAA2B;QAA9G,cAAS,GAAT,SAAS,CAAgB;QAAW,sBAAiB,GAAjB,iBAAiB,CAAmB;QAAW,uBAAkB,GAAlB,kBAAkB,CAAS;QACjI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;IAED,IAAI,wBAAwB;QAC1B,OAAO,IAAI,CAAC,iBAAiB,CAAC,yBAAyB,CAAC;IAC1D,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC;IAC3C,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC;IACxC,CAAC;IAED,WAAW;IACL,aAAa,CAAC,UAAuB,EAAE,SAAsB;;YACjE,2EAA2E;YAC3E,oFAAoF;YACpF,sBAAsB;YACtB,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE;gBAC9B,wFAAwF;gBACxF,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,sBAAsB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;aAChF;YACD,OAAO,IAAI,CAAC,oBAAoB,CAAC;QACnC,CAAC;KAAA;IAIe,sBAAsB,CAAC,UAAuB,EAAE,SAAsB;;YACpF,yGAAyG;YACzG,+IAA+I;YAC/I,IAAI,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE;gBAErC,IAAI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BAA+B,EAAE,SAAS,CAAC,CAAC;aAC1H;QACH,CAAC;KAAA;IAES,wBAAwB,CAAC,SAAsB;QACvD,qFAAqF;QACrF,gFAAgF;QAChF,0CAA0C;QAC1C,OAAO,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IACnE,CAAC;CACF;AA9CC;IADC,KAAK,EAAE;;qCAC2C,WAAW,EAAa,WAAW;;+EAsCrF","sourcesContent":["import { Trace, assert } from '@coolon/pectin';\nimport * as _ from 'lodash';\nimport { PlaceComponent } from '../place-component';\nimport { PlaceDefinition } from '../place-definition';\nimport { UrlSnapshot } from '../url-snapshot';\nimport { NavigationSession } from './session/navigation-session';\n\n/**\n * This class handles the logic around canDeactivate for a given router state transition. It's core responsibilities are:\n * 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.)\n * 2. Ensure only the primary place component is asked when there are nested places. The primary component is the one at the top\n * of the routing change tree.\n * 3. Automatically handle standard interaction scenarios on the components behalf.\n */\nexport class PlaceComponentDeactivationHandler {\n\n private canDeactivatePromise: Promise<boolean | UrlSnapshot>;\n\n constructor(readonly component: PlaceComponent, readonly navigationSession: NavigationSession, readonly isPrimaryComponent: boolean) {\n assert.notNil(component);\n }\n\n get routerInteractionAdapter() {\n return this.navigationSession.interactionServiceAdapter;\n }\n\n get urlService() {\n return this.navigationSession.urlService;\n }\n\n get placeDefinition():PlaceDefinition {\n return this.component.placeDefinition;\n }\n\n // @Trace()\n async canDeactivate(currentUrl: UrlSnapshot, nextState: UrlSnapshot): Promise<boolean | UrlSnapshot> {\n // We'll get called multiple times if there's any parameter sanitisation so\n // we always return true if we accepted promise from a previous cycle of the current\n // navigation session.\n if (!this.canDeactivatePromise) {\n // console.log(`creating deactivate promise for -> ${this.component.constructor.name}`);\n this.canDeactivatePromise = this.canDeactivateComponent(currentUrl, nextState);\n }\n return this.canDeactivatePromise;\n }\n\n\n @Trace()\n protected async canDeactivateComponent(currentUrl: UrlSnapshot, nextState: UrlSnapshot): Promise<UrlSnapshot | boolean> {\n // Automatically cancel any active activities if the navigation session was triggered by the back button.\n // If we handled more than just the pop state then it leads to the UI ignoring clicks and just cancelling things which is deeply disconcerting.\n if (this.navigationSession.isPopState) {\n\n if (this.isPrimaryComponent && this.routerInteractionAdapter.isModalActive()) {\n const routeIds = this.urlService.getActiveInteractionIdsFromUrl(nextState.url);\n const currentIds = this.routerInteractionAdapter.getActiveInteractionContextIds();\n if (!_.isEqual(currentIds, routeIds)) { // why am I checking this????\n await this.routerInteractionAdapter.cancelCurrentModalInteraction();\n return false;\n }\n } else {\n // check if the component has an in place interaction\n if (this.routerInteractionAdapter.isComponentInteracting(this.component)) {\n await this.routerInteractionAdapter.cancelComponentInteraction(this.component);\n return false;\n }\n }\n }\n\n // No interaction in progress, so ask the component .\n // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and\n // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.\n if (this.isGoingToADifferentPlace(nextState)) {\n const canLeave = await this.component._canLeavePlace(this.navigationSession.canDeactivateInteractionContext);\n // The component has an active interaction but no deactivation hook. Rather than guessing what to do\n // we'll just cancel the navigation and print a warning.\n if (canLeave && this.routerInteractionAdapter.isComponentInteracting(this.component)) {\n console.warn('Route changed while component has active interaction, cancelling navigation');\n return false;\n }\n\n return canLeave;\n } else {\n // either an interaction or visit parameter change.\n return await this.component._canChangeRouteParameters(this.navigationSession.canDeactivateInteractionContext, nextState);\n }\n }\n\n protected isGoingToADifferentPlace(nextState: UrlSnapshot) {\n // Because places with a route-id cover two route segments we get asked to deactivate\n // if the route id is added or removed. So if our path is still present the url\n // then we shouldn't deactivate the place.\n return !nextState.includesPathOf(this.component.placeDefinition);\n }\n}\n"]}
1
+ {"version":3,"file":"place-component-deactivation-handler.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/place/navigation/place-component-deactivation-handler.ts"],"names":[],"mappings":";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C,SAAS,CAAC,eAAe,CAAC,CAAC;IACnE,CAAC;CACF","sourcesContent":["import { Trace, assert } from '@coolon/pectin';\nimport * as _ from 'lodash';\nimport { PlaceComponent } from '../place-component';\nimport { PlaceDefinition } from '../place-definition';\nimport { UrlSnapshot } from '../url-snapshot';\nimport { NavigationSession } from './session/navigation-session';\n\n/**\n * This class handles the logic around canDeactivate for a given router state transition. It's core responsibilities are:\n * 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.)\n * 2. Ensure only the primary place component is asked when there are nested places. The primary component is the one at the top\n * of the routing change tree.\n * 3. Automatically handle standard interaction scenarios on the components behalf.\n */\nexport class PlaceComponentDeactivationHandler {\n\n private canDeactivatePromise: Promise<boolean | UrlSnapshot>;\n\n constructor(readonly component: PlaceComponent, readonly navigationSession: NavigationSession, readonly isPrimaryComponent: boolean) {\n assert.notNil(component);\n }\n\n get routerInteractionAdapter() {\n return this.navigationSession.interactionServiceAdapter;\n }\n\n get urlService() {\n return this.navigationSession.urlService;\n }\n\n get placeDefinition():PlaceDefinition {\n return this.component.placeDefinition;\n }\n\n // @Trace()\n async canDeactivate(currentUrl: UrlSnapshot, nextState: UrlSnapshot): Promise<boolean | UrlSnapshot> {\n // We'll get called multiple times if there's any parameter sanitisation so\n // we always return true if we accepted promise from a previous cycle of the current\n // navigation session.\n if (!this.canDeactivatePromise) {\n // console.log(`creating deactivate promise for -> ${this.component.constructor.name}`);\n this.canDeactivatePromise = this.canDeactivateComponent(currentUrl, nextState);\n }\n return this.canDeactivatePromise;\n }\n\n\n // @Trace()\n protected async canDeactivateComponent(currentUrl: UrlSnapshot, nextState: UrlSnapshot): Promise<UrlSnapshot | boolean> {\n // Automatically cancel any active activities if the navigation session was triggered by the back button.\n // If we handled more than just the pop state then it leads to the UI ignoring clicks and just cancelling things which is deeply disconcerting.\n if (this.navigationSession.isPopState) {\n\n if (this.isPrimaryComponent && this.routerInteractionAdapter.isModalActive()) {\n const routeIds = this.urlService.getActiveInteractionIdsFromUrl(nextState.url);\n const currentIds = this.routerInteractionAdapter.getActiveInteractionContextIds();\n if (!_.isEqual(currentIds, routeIds)) { // why am I checking this????\n await this.routerInteractionAdapter.cancelCurrentModalInteraction();\n return false;\n }\n } else {\n // check if the component has an in place interaction\n if (this.routerInteractionAdapter.isComponentInteracting(this.component)) {\n await this.routerInteractionAdapter.cancelComponentInteraction(this.component);\n return false;\n }\n }\n }\n\n // No interaction in progress, so ask the component .\n // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and\n // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.\n if (this.isGoingToADifferentPlace(nextState)) {\n const canLeave = await this.component._canLeavePlace(this.navigationSession.canDeactivateInteractionContext);\n // The component has an active interaction but no deactivation hook. Rather than guessing what to do\n // we'll just cancel the navigation and print a warning.\n if (canLeave && this.routerInteractionAdapter.isComponentInteracting(this.component)) {\n console.warn('Route changed while component has active interaction, cancelling navigation');\n return false;\n }\n\n return canLeave;\n } else {\n // either an interaction or visit parameter change.\n return await this.component._canChangeRouteParameters(this.navigationSession.canDeactivateInteractionContext, nextState);\n }\n }\n\n protected isGoingToADifferentPlace(nextState: UrlSnapshot) {\n // Because places with a route-id cover two route segments we get asked to deactivate\n // if the route id is added or removed. So if our path is still present the url\n // then we shouldn't deactivate the place.\n return !nextState.includesPathOf(this.component.placeDefinition);\n }\n}\n"]}
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"PlaceComponentDeactivationHandler":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../place-component","name":"PlaceComponent","line":18,"character":34},{"__symbolic":"reference","module":"./session/navigation-session","name":"NavigationSession","line":18,"character":78},{"__symbolic":"reference","name":"boolean"}]}],"canDeactivate":[{"__symbolic":"method"}],"canDeactivateComponent":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"Trace","line":47,"character":3}}]}],"isGoingToADifferentPlace":[{"__symbolic":"method"}]}}}}]
1
+ [{"__symbolic":"module","version":4,"metadata":{"PlaceComponentDeactivationHandler":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../place-component","name":"PlaceComponent","line":18,"character":34},{"__symbolic":"reference","module":"./session/navigation-session","name":"NavigationSession","line":18,"character":78},{"__symbolic":"reference","name":"boolean"}]}],"canDeactivate":[{"__symbolic":"method"}],"canDeactivateComponent":[{"__symbolic":"method"}],"isGoingToADifferentPlace":[{"__symbolic":"method"}]}}}}]
@@ -1,6 +1,5 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
2
  import { UrlSegment } from '@angular/router';
3
- import { Trace } from '@coolon/pectin';
4
3
  import { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';
5
4
  import _ from 'lodash';
6
5
  import { ConsolidatedParameterMap } from './guards/consolidated-param-map';
@@ -15,6 +14,7 @@ export class UrlSnapshot {
15
14
  this.url = url;
16
15
  this.urlTree = urlSerializer.parse(url);
17
16
  }
17
+ // @Trace()
18
18
  updateVisitSegments(visit) {
19
19
  const newUrlTree = this.urlSerializer.parse(this.url);
20
20
  // Ugly, but it works for now.
@@ -91,12 +91,6 @@ export class UrlSnapshot {
91
91
  return `UrlSnapshot(${this.url})`;
92
92
  }
93
93
  }
94
- __decorate([
95
- Trace(),
96
- __metadata("design:type", Function),
97
- __metadata("design:paramtypes", [Visit]),
98
- __metadata("design:returntype", UrlSnapshot)
99
- ], UrlSnapshot.prototype, "updateVisitSegments", null);
100
94
  __decorate([
101
95
  Memoize(),
102
96
  __metadata("design:type", Function),
@@ -1 +1 @@
1
- {"version":3,"file":"url-snapshot.js","sourceRoot":"","sources":["../../../../../../libs/angular-ui-powerups/src/lib/place/url-snapshot.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM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AG,IAAI,CAAC;IAE7C,SAAgB,mBAAmB,CAAC,IAAY;QAC9C,OAAO,IAAI,CAAC,KAAK,CAAC,YAAA,wBAAwB,CAAC,CAAC;IAC9C,CAAC;IAFe,+BAAmB,sBAElC,CAAA;IAED,SAAgB,eAAe,CAAC,cAAwB;QACtD,OAAO,cAAc,CAAC,IAAI,CAAC,YAAA,wBAAwB,CAAC,CAAC;IACvD,CAAC;IAFe,2BAAe,kBAE9B,CAAA;AAKH,CAAC,EAhBgB,WAAW,KAAX,WAAW,QAgB3B","sourcesContent":["import { UrlSegment, UrlSerializer, UrlTree } from '@angular/router';\nimport { Trace } from '@coolon/pectin';\nimport { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';\nimport _ from 'lodash';\nimport { ConsolidatedParameterMap } from './guards/consolidated-param-map';\nimport { PlaceDefinition } from './place-definition';\nimport { Visit } from './visit';\n\nfunction extractPrimarySegments(urlTree: UrlTree): UrlSegment[] {\n return urlTree.root.children.primary.segments;\n}\n\nexport class UrlSnapshot {\n\n readonly urlTree: UrlTree;\n\n // TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.\n constructor(readonly urlSerializer: UrlSerializer, readonly url: string) {\n this.urlTree = urlSerializer.parse(url);\n }\n\n @Trace()\n public updateVisitSegments(visit: Visit): UrlSnapshot {\n const newUrlTree = this.urlSerializer.parse(this.url);\n // Ugly, but it works for now.\n const segments = [...extractPrimarySegments(newUrlTree)];\n const visitSegments = this.getSegmentsFor(visit);\n const replaceAt = segments.findIndex(segment => segment.path === visitSegments[0].path);\n // do not use the return value, it's the items that were removed!\n segments.splice(replaceAt, visitSegments.length, ...visitSegments);\n newUrlTree.root.children.primary.segments = segments;\n return new UrlSnapshot(this.urlSerializer, newUrlTree.toString());\n }\n\n @Memoize()\n private getPrimarySegments(): UrlSegment[] {\n return extractPrimarySegments(this.urlTree);\n }\n\n /**\n * Converts the visit into segments. Please not that these segments are not e\n * @param visit\n */\n protected getSegmentsFor(visit: Visit): UrlSegment[] {\n return visit.placeDefinition.hasRouteId() ?\n [\n // NOTE:\n // It's important to attach the params to the root path and not the id. If we attach them\n // to an empty id then the angular router won't match the pattern.\n new UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit)),\n new UrlSegment(visit.placeDefinition.getFormattedRouteId(visit), {})]\n :\n [\n new UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit))\n ];\n }\n\n includesPathOf(placeDef: PlaceDefinition) {\n return this.getPrimarySegments().find(s => s.path === placeDef.path);\n }\n\n createVisitFor(placeDef: PlaceDefinition) {\n return new Visit(placeDef, new ConsolidatedParameterMap(this.getPrimarySegments()));\n }\n\n getInteractionIds() {\n const queryParam = this.urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM];\n if (queryParam) {\n return UrlSnapshot.parseInteractionIds(queryParam);\n } else {\n return [];\n }\n }\n\n hasInteractions() {\n return this.getInteractionIds().length > 0;\n }\n\n hasInteractionIds(ids: string[]): boolean {\n return _.isEqual(this.getInteractionIds(), ids);\n }\n\n // @Trace()\n updateInteractionIds(ids: string[]): UrlSnapshot {\n if (ids.length === 0) {\n return this.removeInteractionIds();\n } else {\n const urlTree = this.urlSerializer.parse(this.url);\n urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM] = UrlSnapshot.createPathIdFor(ids);\n return new UrlSnapshot(this.urlSerializer, urlTree.toString());\n }\n }\n\n // @Trace()\n removeInteractionIds(): UrlSnapshot {\n const urlTree = this.urlSerializer.parse(this.url);\n if (urlTree.queryParams && urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM]) {\n urlTree.queryParams = {};//[UrlSnapshot.INTERACTION_ROUTER_OUTLET]\n }\n return new UrlSnapshot(this.urlSerializer, urlTree.toString());\n }\n\n toString(): string {\n return `UrlSnapshot(${this.url})`;\n }\n\n // withOptions(options: NavigationExtras) {\n // return new UrlSnapshot(this.urlSerializer, this.url, options);\n // }\n //\n // @Trace()\n // getNavigationExtras(): NavigationExtras {\n // return this.options;\n // }\n\n}\n\nexport namespace UrlSnapshot {\n\n export const INTERACTION_QUERY_PARAM = 'aup-interactions';\n export const INTERACTION_ID_SEPARATOR = '--';\n\n export function parseInteractionIds(path: string) {\n return path.split(INTERACTION_ID_SEPARATOR);\n }\n\n export function createPathIdFor(interactionIds: string[]) {\n return interactionIds.join(INTERACTION_ID_SEPARATOR);\n }\n\n export interface NavigationOptions {\n replaceUrl?: boolean;\n }\n}\n"]}
1
+ {"version":3,"file":"url-snapshot.js","sourceRoot":"","sources":["../../../../../../libs/angular-ui-powerups/src/lib/place/url-snapshot.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAE,OAAO,EAAE,MAAM,kDAAkD,CAAC;AAC3E,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,SAAS,sBAAsB,CAAC,OAAgB;IAC9C,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC;AAChD,CAAC;AAED,MAAM,OAAO,WAAW;IAItB,iIAAiI;IACjI,YAAqB,aAA4B,EAAW,GAAW;QAAlD,kBAAa,GAAb,aAAa,CAAe;QAAW,QAAG,GAAH,GAAG,CAAQ;QACrE,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1C,CAAC;IAED,WAAW;IACJ,mBAAmB,CAAC,KAAY;QACrC,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtD,8BAA8B;QAC9B,MAAM,QAAQ,GAAG,CAAC,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC,CAAC;QACzD,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I,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,uBAAuB,CAAC,EAAE;YACnF,OAAO,CAAC,WAAW,GAAG,EAAE,CAAC,CAAA,yCAAyC;SACnE;QACD,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,QAAQ;QACN,OAAO,eAAe,IAAI,CAAC,GAAG,GAAG,CAAC;IACpC,CAAC;CAWF;AAhFC;IADC,OAAO,EAAE;;;;qDAGT;AAgFH,WAAiB,WAAW;IAEb,mCAAuB,GAAG,kBAAkB,CAAC;IAC7C,oCAAwB,GAAG,IAAI,CAAC;IAE7C,SAAgB,mBAAmB,CAAC,IAAY;QAC9C,OAAO,IAAI,CAAC,KAAK,CAAC,YAAA,wBAAwB,CAAC,CAAC;IAC9C,CAAC;IAFe,+BAAmB,sBAElC,CAAA;IAED,SAAgB,eAAe,CAAC,cAAwB;QACtD,OAAO,cAAc,CAAC,IAAI,CAAC,YAAA,wBAAwB,CAAC,CAAC;IACvD,CAAC;IAFe,2BAAe,kBAE9B,CAAA;AAKH,CAAC,EAhBgB,WAAW,KAAX,WAAW,QAgB3B","sourcesContent":["import { UrlSegment, UrlSerializer, UrlTree } from '@angular/router';\nimport { Trace } from '@coolon/pectin';\nimport { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';\nimport _ from 'lodash';\nimport { ConsolidatedParameterMap } from './guards/consolidated-param-map';\nimport { PlaceDefinition } from './place-definition';\nimport { Visit } from './visit';\n\nfunction extractPrimarySegments(urlTree: UrlTree): UrlSegment[] {\n return urlTree.root.children.primary.segments;\n}\n\nexport class UrlSnapshot {\n\n readonly urlTree: UrlTree;\n\n // TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.\n constructor(readonly urlSerializer: UrlSerializer, readonly url: string) {\n this.urlTree = urlSerializer.parse(url);\n }\n\n // @Trace()\n public updateVisitSegments(visit: Visit): UrlSnapshot {\n const newUrlTree = this.urlSerializer.parse(this.url);\n // Ugly, but it works for now.\n const segments = [...extractPrimarySegments(newUrlTree)];\n const visitSegments = this.getSegmentsFor(visit);\n const replaceAt = segments.findIndex(segment => segment.path === visitSegments[0].path);\n // do not use the return value, it's the items that were removed!\n segments.splice(replaceAt, visitSegments.length, ...visitSegments);\n newUrlTree.root.children.primary.segments = segments;\n return new UrlSnapshot(this.urlSerializer, newUrlTree.toString());\n }\n\n @Memoize()\n private getPrimarySegments(): UrlSegment[] {\n return extractPrimarySegments(this.urlTree);\n }\n\n /**\n * Converts the visit into segments. Please not that these segments are not e\n * @param visit\n */\n protected getSegmentsFor(visit: Visit): UrlSegment[] {\n return visit.placeDefinition.hasRouteId() ?\n [\n // NOTE:\n // It's important to attach the params to the root path and not the id. If we attach them\n // to an empty id then the angular router won't match the pattern.\n new UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit)),\n new UrlSegment(visit.placeDefinition.getFormattedRouteId(visit), {})]\n :\n [\n new UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit))\n ];\n }\n\n includesPathOf(placeDef: PlaceDefinition) {\n return this.getPrimarySegments().find(s => s.path === placeDef.path);\n }\n\n createVisitFor(placeDef: PlaceDefinition) {\n return new Visit(placeDef, new ConsolidatedParameterMap(this.getPrimarySegments()));\n }\n\n getInteractionIds() {\n const queryParam = this.urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM];\n if (queryParam) {\n return UrlSnapshot.parseInteractionIds(queryParam);\n } else {\n return [];\n }\n }\n\n hasInteractions() {\n return this.getInteractionIds().length > 0;\n }\n\n hasInteractionIds(ids: string[]): boolean {\n return _.isEqual(this.getInteractionIds(), ids);\n }\n\n // @Trace()\n updateInteractionIds(ids: string[]): UrlSnapshot {\n if (ids.length === 0) {\n return this.removeInteractionIds();\n } else {\n const urlTree = this.urlSerializer.parse(this.url);\n urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM] = UrlSnapshot.createPathIdFor(ids);\n return new UrlSnapshot(this.urlSerializer, urlTree.toString());\n }\n }\n\n // @Trace()\n removeInteractionIds(): UrlSnapshot {\n const urlTree = this.urlSerializer.parse(this.url);\n if (urlTree.queryParams && urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM]) {\n urlTree.queryParams = {};//[UrlSnapshot.INTERACTION_ROUTER_OUTLET]\n }\n return new UrlSnapshot(this.urlSerializer, urlTree.toString());\n }\n\n toString(): string {\n return `UrlSnapshot(${this.url})`;\n }\n\n // withOptions(options: NavigationExtras) {\n // return new UrlSnapshot(this.urlSerializer, this.url, options);\n // }\n //\n // @Trace()\n // getNavigationExtras(): NavigationExtras {\n // return this.options;\n // }\n\n}\n\nexport namespace UrlSnapshot {\n\n export const INTERACTION_QUERY_PARAM = 'aup-interactions';\n export const INTERACTION_ID_SEPARATOR = '--';\n\n export function parseInteractionIds(path: string) {\n return path.split(INTERACTION_ID_SEPARATOR);\n }\n\n export function createPathIdFor(interactionIds: string[]) {\n return interactionIds.join(INTERACTION_ID_SEPARATOR);\n }\n\n export interface NavigationOptions {\n replaceUrl?: boolean;\n }\n}\n"]}
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"UrlSnapshot":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/router","name":"UrlSerializer","line":17,"character":38},{"__symbolic":"reference","name":"string"}]}],"updateVisitSegments":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"Trace","line":21,"character":3}}]}],"getPrimarySegments":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@typescript-plus/fast-memoize-decorator/dist/src","name":"Memoize","line":34,"character":3}}]}],"getSegmentsFor":[{"__symbolic":"method"}],"includesPathOf":[{"__symbolic":"method"}],"createVisitFor":[{"__symbolic":"method"}],"getInteractionIds":[{"__symbolic":"method"}],"hasInteractions":[{"__symbolic":"method"}],"hasInteractionIds":[{"__symbolic":"method"}],"updateInteractionIds":[{"__symbolic":"method"}],"removeInteractionIds":[{"__symbolic":"method"}],"toString":[{"__symbolic":"method"}]}}}}]
1
+ [{"__symbolic":"module","version":4,"metadata":{"UrlSnapshot":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/router","name":"UrlSerializer","line":17,"character":38},{"__symbolic":"reference","name":"string"}]}],"updateVisitSegments":[{"__symbolic":"method"}],"getPrimarySegments":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@typescript-plus/fast-memoize-decorator/dist/src","name":"Memoize","line":34,"character":3}}]}],"getSegmentsFor":[{"__symbolic":"method"}],"includesPathOf":[{"__symbolic":"method"}],"createVisitFor":[{"__symbolic":"method"}],"getInteractionIds":[{"__symbolic":"method"}],"hasInteractions":[{"__symbolic":"method"}],"hasInteractionIds":[{"__symbolic":"method"}],"updateInteractionIds":[{"__symbolic":"method"}],"removeInteractionIds":[{"__symbolic":"method"}],"toString":[{"__symbolic":"method"}]}}}}]