@coolon/angular-ui-powerups 0.0.44 → 0.0.46

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 (51) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +545 -218
  2. package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
  3. package/bundles/coolon-angular-ui-powerups.umd.min.js +1 -1
  4. package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
  5. package/coolon-angular-ui-powerups.metadata.json +1 -1
  6. package/esm2015/coolon-angular-ui-powerups.js +2 -2
  7. package/esm2015/index.js +2 -2
  8. package/esm2015/lib/place/components/place-outlet/place-outlet.component.js +17 -12
  9. package/esm2015/lib/place/guards/place-route.guard.js +4 -4
  10. package/esm2015/lib/place/index.js +1 -2
  11. package/esm2015/lib/place/place-component.js +2 -2
  12. package/esm2015/lib/place/place-history.js +29 -6
  13. package/esm2015/lib/place/place-router.js +38 -23
  14. package/esm2015/lib/place/route/parameter-decorators.js +1 -1
  15. package/esm2015/lib/place/route/parameter-definition.class.js +92 -9
  16. package/esm2015/lib/place/route/parameter-sanitiser.js +4 -3
  17. package/esm2015/lib/place/route/parameter-snapshot.js +221 -23
  18. package/esm2015/lib/place/route/route-parameter-sanitiser.js +2 -2
  19. package/esm2015/lib/place/visit.js +3 -3
  20. package/esm2015/public_api.js +2 -2
  21. package/esm5/coolon-angular-ui-powerups.js +2 -2
  22. package/esm5/index.js +2 -2
  23. package/esm5/lib/place/components/place-outlet/place-outlet.component.js +17 -12
  24. package/esm5/lib/place/guards/place-route.guard.js +4 -4
  25. package/esm5/lib/place/index.js +1 -2
  26. package/esm5/lib/place/place-component.js +2 -2
  27. package/esm5/lib/place/place-history.js +39 -6
  28. package/esm5/lib/place/place-router.js +45 -28
  29. package/esm5/lib/place/route/parameter-decorators.js +1 -1
  30. package/esm5/lib/place/route/parameter-definition.class.js +104 -9
  31. package/esm5/lib/place/route/parameter-sanitiser.js +4 -3
  32. package/esm5/lib/place/route/parameter-snapshot.js +276 -23
  33. package/esm5/lib/place/route/route-parameter-sanitiser.js +2 -2
  34. package/esm5/lib/place/visit.js +3 -3
  35. package/esm5/public_api.js +2 -2
  36. package/fesm2015/coolon-angular-ui-powerups.js +453 -198
  37. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  38. package/fesm5/coolon-angular-ui-powerups.js +547 -219
  39. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  40. package/lib/place/components/place-outlet/place-outlet.component.d.ts +0 -1
  41. package/lib/place/index.d.ts +0 -1
  42. package/lib/place/place-history.d.ts +3 -0
  43. package/lib/place/place-router.d.ts +4 -3
  44. package/lib/place/route/parameter-definition.class.d.ts +12 -2
  45. package/lib/place/route/parameter-sanitiser.d.ts +3 -2
  46. package/lib/place/route/parameter-snapshot.d.ts +11 -8
  47. package/lib/place/visit.d.ts +2 -2
  48. package/package.json +1 -1
  49. package/esm2015/lib/place/route/default-parameter-sanitiser.js +0 -66
  50. package/esm5/lib/place/route/default-parameter-sanitiser.js +0 -73
  51. package/lib/place/route/default-parameter-sanitiser.d.ts +0 -11
@@ -13,7 +13,7 @@ import { MatDialog as MatDialog$1 } from '@angular/material/dialog';
13
13
  import { MatIconModule } from '@angular/material/icon';
14
14
  import { MatListModule } from '@angular/material/list';
15
15
  import { MatTooltipModule } from '@angular/material/tooltip';
16
- import { Router, RouterModule } from '@angular/router';
16
+ import { Router, ActivatedRouteSnapshot, UrlTree, RouterModule } from '@angular/router';
17
17
  import { Memoize as Memoize$1 } from '@typescript-plus/fast-memoize-decorator/dist/src';
18
18
  import { Memoize } from '@typescript-plus/fast-memoize-decorator';
19
19
  import 'reflect-metadata';
@@ -1578,7 +1578,7 @@ class PlaceComponent extends DisposableComponent {
1578
1578
  * @return {?}
1579
1579
  */
1580
1580
  toRight(parameters) {
1581
- return parameters.getResolvedParameterValue(parameterDef);
1581
+ return parameters.getValueOf(parameterDef);
1582
1582
  },
1583
1583
  /**
1584
1584
  * @param {?} value
@@ -1790,7 +1790,7 @@ class PlaceHistory {
1790
1790
  */
1791
1791
  constructor(router) {
1792
1792
  this.router = router;
1793
- this._history = [];
1793
+ this._history = new Map();
1794
1794
  }
1795
1795
  /**
1796
1796
  * @param {?} state
@@ -1798,12 +1798,35 @@ class PlaceHistory {
1798
1798
  */
1799
1799
  add(state) {
1800
1800
  /** @type {?} */
1801
- const previousState = ___default.last(this._history);
1801
+ const history = this.getHistory(state.placeDefinition);
1802
+ /** @type {?} */
1803
+ const previousState = ___default.last(history);
1802
1804
  if (!previousState || state.hasChanged(previousState)) {
1803
- this._history.push(state);
1804
- // limit our history to 100 visits
1805
- this._history = this._history.slice(-100);
1805
+ history.unshift(state); // LIFO
1806
+ this.setHistory(state.placeDefinition, history.slice(-3)); // limit our history to 3 visits
1807
+ }
1808
+ }
1809
+ /**
1810
+ * @param {?} placeDef
1811
+ * @return {?}
1812
+ */
1813
+ getHistory(placeDef) {
1814
+ /** @type {?} */
1815
+ let history = this._history.get(placeDef);
1816
+ if (!history) {
1817
+ history = [];
1818
+ this.setHistory(placeDef, history);
1806
1819
  }
1820
+ return history;
1821
+ }
1822
+ /**
1823
+ * @private
1824
+ * @param {?} placeDef
1825
+ * @param {?} history
1826
+ * @return {?}
1827
+ */
1828
+ setHistory(placeDef, history) {
1829
+ this._history.set(placeDef, history);
1807
1830
  }
1808
1831
  }
1809
1832
  PlaceHistory.decorators = [
@@ -1829,84 +1852,6 @@ if (false) {
1829
1852
  PlaceHistory.prototype.router;
1830
1853
  }
1831
1854
 
1832
- /**
1833
- * @fileoverview added by tsickle
1834
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1835
- */
1836
- class PlaceRouter {
1837
- /**
1838
- * @param {?} router
1839
- */
1840
- constructor(router) {
1841
- this.router = router;
1842
- }
1843
- /**
1844
- * @param {?} activatedRoute
1845
- * @param {?} previous
1846
- * @param {?} next
1847
- * @return {?}
1848
- */
1849
- pushParameterChangesToRoute(activatedRoute, previous, next) {
1850
- this.router.navigate(this.redirect(activatedRoute.snapshot, previous, next), {
1851
- relativeTo: activatedRoute
1852
- });
1853
- }
1854
- /**
1855
- * @param {?} activatedRoute
1856
- * @param {?} sanitised
1857
- * @param {?} snapshot
1858
- * @return {?}
1859
- */
1860
- createUrlTree(activatedRoute, sanitised, snapshot) {
1861
- return this.router.createUrlTree(this.redirect(activatedRoute, snapshot, sanitised));
1862
- }
1863
- /**
1864
- * @protected
1865
- * @param {?} activatedRoute
1866
- * @param {?} previous
1867
- * @param {?} next
1868
- * @return {?}
1869
- */
1870
- redirect(activatedRoute, previous, next) {
1871
- /** @type {?} */
1872
- const childSegments = ___default.flatten(activatedRoute.children.map((/**
1873
- * @param {?} child
1874
- * @return {?}
1875
- */
1876
- child => child.url)));
1877
- /** @type {?} */
1878
- const relativePath = !!previous.hasRouteId() ? '..' : '.';
1879
- /** @type {?} */
1880
- const routeId = next.getFormattedRouteId();
1881
- /** @type {?} */
1882
- const path = routeId ?
1883
- [relativePath, routeId, next.getFormattedParameters()] :
1884
- [relativePath, next.getFormattedParameters()];
1885
- return path.concat(childSegments.map((/**
1886
- * @param {?} s
1887
- * @return {?}
1888
- */
1889
- s => s.path)));
1890
- }
1891
- }
1892
- PlaceRouter.decorators = [
1893
- { type: Injectable, args: [{
1894
- providedIn: 'root'
1895
- },] }
1896
- ];
1897
- /** @nocollapse */
1898
- PlaceRouter.ctorParameters = () => [
1899
- { type: Router }
1900
- ];
1901
- /** @nocollapse */ PlaceRouter.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(ɵɵinject(Router)); }, token: PlaceRouter, providedIn: "root" });
1902
- if (false) {
1903
- /**
1904
- * @type {?}
1905
- * @private
1906
- */
1907
- PlaceRouter.prototype.router;
1908
- }
1909
-
1910
1855
  /**
1911
1856
  * @fileoverview added by tsickle
1912
1857
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -1927,18 +1872,20 @@ class ParameterDefinition {
1927
1872
  /** @type {?} */
1928
1873
  const opts = Opts.get(options);
1929
1874
  this.name = opts.getOptional('as', propertyName);
1930
- // this.sanitiser = new DefaultParameterSanitiser(
1931
- // this,
1932
- // opts.getOptional('remember', false),
1933
- // opts.getOptional('defaultValue', null)
1934
- // );
1875
+ this.remember = opts.getOptional('remember', false);
1876
+ this.defaultValue = opts.getOptional('defaultValue', null);
1935
1877
  }
1936
1878
  /**
1937
1879
  * @param {?} injector
1938
1880
  * @return {?}
1939
1881
  */
1940
1882
  getSanitiser(injector) {
1941
- return this.sanitiser;
1883
+ if (this.remember || !___default.isNil(this.defaultValue)) {
1884
+ return new ParameterDefinition.DefaultParameterSanitiser(this.remember, this.defaultValue, injector.get(PlaceHistory));
1885
+ }
1886
+ else {
1887
+ return null;
1888
+ }
1942
1889
  }
1943
1890
  }
1944
1891
  if (false) {
@@ -1948,8 +1895,16 @@ if (false) {
1948
1895
  ParameterDefinition.prototype.isArray;
1949
1896
  /** @type {?} */
1950
1897
  ParameterDefinition.prototype.name;
1951
- /** @type {?} */
1952
- ParameterDefinition.prototype.sanitiser;
1898
+ /**
1899
+ * @type {?}
1900
+ * @private
1901
+ */
1902
+ ParameterDefinition.prototype.remember;
1903
+ /**
1904
+ * @type {?}
1905
+ * @private
1906
+ */
1907
+ ParameterDefinition.prototype.defaultValue;
1953
1908
  /** @type {?} */
1954
1909
  ParameterDefinition.prototype.propertyName;
1955
1910
  /** @type {?} */
@@ -2023,6 +1978,77 @@ if (false) {
2023
1978
  /** @type {?} */
2024
1979
  ArrayParameter.prototype.isArray;
2025
1980
  }
1981
+ /**
1982
+ * @template T, S
1983
+ */
1984
+ class DefaultParameterSanitiser {
1985
+ /**
1986
+ * @param {?} remember
1987
+ * @param {?} defaultValue
1988
+ * @param {?} placeHistory
1989
+ */
1990
+ constructor(remember, defaultValue, placeHistory) {
1991
+ this.remember = remember;
1992
+ this.defaultValue = defaultValue;
1993
+ this.placeHistory = placeHistory;
1994
+ }
1995
+ /**
1996
+ * @param {?} parameterDef
1997
+ * @param {?} value
1998
+ * @param {?=} visit
1999
+ * @return {?}
2000
+ */
2001
+ sanitise(parameterDef, value, visit) {
2002
+ if (this.isBlank(parameterDef, value)) {
2003
+ if (this.remember) {
2004
+ /** @type {?} */
2005
+ const visits = this.placeHistory.getHistory(visit.placeDefinition);
2006
+ value = visits.map((/**
2007
+ * @param {?} v
2008
+ * @return {?}
2009
+ */
2010
+ v => v.getValueOf(parameterDef)))
2011
+ .filter((/**
2012
+ * @param {?} v
2013
+ * @return {?}
2014
+ */
2015
+ v => !___default.isNil(v)))
2016
+ .find((/**
2017
+ * @param {?} v
2018
+ * @return {?}
2019
+ */
2020
+ v => !this.isBlank(parameterDef, v)));
2021
+ }
2022
+ value = this.isBlank(parameterDef, value) ? this.defaultValue : value;
2023
+ console.log(`${parameterDef.name} is blank, returning: ${value}`);
2024
+ return value;
2025
+ }
2026
+ else {
2027
+ console.log(`${parameterDef.name} is not blank`);
2028
+ return value;
2029
+ }
2030
+ }
2031
+ /**
2032
+ * @private
2033
+ * @param {?} def
2034
+ * @param {?} value
2035
+ * @return {?}
2036
+ */
2037
+ isBlank(def, value) {
2038
+ /** @type {?} */
2039
+ const isNil = ___default.isNil(value);
2040
+ return isNil ? true : def.isArray ? value['length'] < 1 : false;
2041
+ }
2042
+ }
2043
+ ParameterDefinition.DefaultParameterSanitiser = DefaultParameterSanitiser;
2044
+ if (false) {
2045
+ /** @type {?} */
2046
+ DefaultParameterSanitiser.prototype.remember;
2047
+ /** @type {?} */
2048
+ DefaultParameterSanitiser.prototype.defaultValue;
2049
+ /** @type {?} */
2050
+ DefaultParameterSanitiser.prototype.placeHistory;
2051
+ }
2026
2052
  })(ParameterDefinition || (ParameterDefinition = {}));
2027
2053
 
2028
2054
  var _a;
@@ -2037,20 +2063,25 @@ class ParameterSnapshot {
2037
2063
  }
2038
2064
  /**
2039
2065
  * @param {?} other
2066
+ * @param {?=} debug
2040
2067
  * @return {?}
2041
2068
  */
2042
- hasChanged(other) {
2069
+ hasChanged(other, debug = false) {
2043
2070
  /** @type {?} */
2044
2071
  const changed = this.resolved.find((/**
2045
2072
  * @param {?} r
2046
2073
  * @return {?}
2047
2074
  */
2048
2075
  (r) => {
2049
- return !r.isSame(other.getResolvedParameterValue(r.parameterDef));
2076
+ return !r.isSame(other.getValueOf(r.parameterDef));
2050
2077
  }));
2051
- // if (changed) {
2052
- // console.log({ mine: changed, theirs: other.getResolvedParameter(changed.parameterDef) });
2053
- // }
2078
+ if (changed && debug) {
2079
+ console.log({
2080
+ name: changed.parameterDef.name,
2081
+ mine: changed.value,
2082
+ theirs: other.getValueOf(changed.parameterDef)
2083
+ });
2084
+ }
2054
2085
  return !!changed;
2055
2086
  }
2056
2087
  /**
@@ -2058,7 +2089,7 @@ class ParameterSnapshot {
2058
2089
  * @param {?} parameterDef
2059
2090
  * @return {?}
2060
2091
  */
2061
- getResolvedParameter(parameterDef) {
2092
+ getParameter(parameterDef) {
2062
2093
  return this.resolved.find((/**
2063
2094
  * @param {?} r
2064
2095
  * @return {?}
@@ -2070,22 +2101,22 @@ class ParameterSnapshot {
2070
2101
  * @param {?} parameterDef
2071
2102
  * @return {?}
2072
2103
  */
2073
- getResolvedParameterValue(parameterDef) {
2104
+ getValueOf(parameterDef) {
2074
2105
  /** @type {?} */
2075
- const resolvedParameter = this.getResolvedParameter(parameterDef);
2106
+ const resolvedParameter = this.getParameter(parameterDef);
2076
2107
  return resolvedParameter ? resolvedParameter.value : null;
2077
2108
  }
2078
2109
  /**
2079
2110
  * @return {?}
2080
2111
  */
2081
- getRouteId() {
2082
- return this.getResolvedRouteId() ? this.getResolvedRouteId().value : null;
2112
+ getRouteIdValue() {
2113
+ return this.getRouteIdParameter() ? this.getRouteIdParameter().value : null;
2083
2114
  }
2084
2115
  /**
2085
2116
  * @param {?} name
2086
2117
  * @return {?}
2087
2118
  */
2088
- getRouteParameter(name) {
2119
+ getParameterValue(name) {
2089
2120
  /** @type {?} */
2090
2121
  const resolvedParameter = this.resolved.find((/**
2091
2122
  * @param {?} r
@@ -2098,7 +2129,7 @@ class ParameterSnapshot {
2098
2129
  * @private
2099
2130
  * @return {?}
2100
2131
  */
2101
- getResolvedRouteId() {
2132
+ getRouteIdParameter() {
2102
2133
  // RouteId's are never arrays: see parameter-decorators.ts createDefinition methods. It would be nice to
2103
2134
  // capture this in the type system though
2104
2135
  return (/** @type {?} */ (this.resolved.find((/**
@@ -2107,18 +2138,29 @@ class ParameterSnapshot {
2107
2138
  */
2108
2139
  p => p.parameterDef.isRouteId))));
2109
2140
  }
2141
+ /**
2142
+ * @private
2143
+ * @return {?}
2144
+ */
2145
+ getRouteParameters() {
2146
+ return this.resolved.filter((/**
2147
+ * @param {?} r
2148
+ * @return {?}
2149
+ */
2150
+ r => !r.parameterDef.isRouteId));
2151
+ }
2110
2152
  /**
2111
2153
  * @return {?}
2112
2154
  */
2113
2155
  hasRouteId() {
2114
- return !!this.getResolvedRouteId();
2156
+ return !!this.getRouteIdParameter();
2115
2157
  }
2116
2158
  /**
2117
2159
  * @return {?}
2118
2160
  */
2119
2161
  getFormattedRouteId() {
2120
2162
  /** @type {?} */
2121
- const routeIdParam = this.getResolvedRouteId();
2163
+ const routeIdParam = this.getRouteIdParameter();
2122
2164
  return routeIdParam ? routeIdParam.formattedValue() : null;
2123
2165
  }
2124
2166
  /**
@@ -2141,6 +2183,22 @@ class ParameterSnapshot {
2141
2183
  }));
2142
2184
  return params;
2143
2185
  }
2186
+ /**
2187
+ * @return {?}
2188
+ */
2189
+ getAllFormattedParameters() {
2190
+ /** @type {?} */
2191
+ const params = {};
2192
+ /** @type {?} */
2193
+ const routeIdParam = this.resolved.forEach((/**
2194
+ * @param {?} p
2195
+ * @return {?}
2196
+ */
2197
+ p => {
2198
+ params[p.parameterDef.name] = p.formattedValue();
2199
+ }));
2200
+ return params;
2201
+ }
2144
2202
  /**
2145
2203
  * @template T, S
2146
2204
  * @param {?} parameter
@@ -2162,7 +2220,29 @@ class ParameterSnapshot {
2162
2220
  */
2163
2221
  sanitise(injector) {
2164
2222
  return __awaiter(this, void 0, void 0, function* () {
2165
- return this;
2223
+ if (this.hasRouteId()) {
2224
+ /** @type {?} */
2225
+ const routeId = this.getRouteIdParameter();
2226
+ /** @type {?} */
2227
+ const sanitisedValue = yield routeId.sanitise(this, injector);
2228
+ if (!routeId.isSame(sanitisedValue)) {
2229
+ // if the route id has changed we redirect immediately as other
2230
+ // parameter sanitisers might use it.
2231
+ return this.replace(routeId.parameterDef, sanitisedValue);
2232
+ }
2233
+ }
2234
+ /** @type {?} */
2235
+ let result = this;
2236
+ /** @type {?} */
2237
+ const routeParameters = this.getRouteParameters();
2238
+ for (let i = 0; i < routeParameters.length; i++) {
2239
+ /** @type {?} */
2240
+ const sanitisedValue = yield routeParameters[i].sanitise(this, injector);
2241
+ if (!routeParameters[i].isSame(sanitisedValue)) {
2242
+ result = this.replace(routeParameters[i].parameterDef, sanitisedValue);
2243
+ }
2244
+ }
2245
+ return result;
2166
2246
  });
2167
2247
  }
2168
2248
  }
@@ -2171,25 +2251,37 @@ __decorate([
2171
2251
  __metadata("design:type", Function),
2172
2252
  __metadata("design:paramtypes", [ParameterDefinition]),
2173
2253
  __metadata("design:returntype", ParameterSnapshot.ResolvedParameter)
2174
- ], ParameterSnapshot.prototype, "getResolvedParameter", null);
2254
+ ], ParameterSnapshot.prototype, "getParameter", null);
2175
2255
  __decorate([
2176
2256
  Memoize$1(),
2177
2257
  __metadata("design:type", Function),
2178
2258
  __metadata("design:paramtypes", [ParameterDefinition]),
2179
2259
  __metadata("design:returntype", typeof (_a = typeof S !== "undefined" && S) === "function" ? _a : Object)
2180
- ], ParameterSnapshot.prototype, "getResolvedParameterValue", null);
2260
+ ], ParameterSnapshot.prototype, "getValueOf", null);
2181
2261
  __decorate([
2182
2262
  Memoize$1(),
2183
2263
  __metadata("design:type", Function),
2184
2264
  __metadata("design:paramtypes", [String]),
2185
2265
  __metadata("design:returntype", Object)
2186
- ], ParameterSnapshot.prototype, "getRouteParameter", null);
2266
+ ], ParameterSnapshot.prototype, "getParameterValue", null);
2187
2267
  __decorate([
2188
2268
  Memoize$1(),
2189
2269
  __metadata("design:type", Function),
2190
2270
  __metadata("design:paramtypes", []),
2191
2271
  __metadata("design:returntype", ParameterSnapshot.ResolvedValueParameter)
2192
- ], ParameterSnapshot.prototype, "getResolvedRouteId", null);
2272
+ ], ParameterSnapshot.prototype, "getRouteIdParameter", null);
2273
+ __decorate([
2274
+ Memoize$1(),
2275
+ __metadata("design:type", Function),
2276
+ __metadata("design:paramtypes", []),
2277
+ __metadata("design:returntype", Array)
2278
+ ], ParameterSnapshot.prototype, "getRouteParameters", null);
2279
+ __decorate([
2280
+ Trace(),
2281
+ __metadata("design:type", Function),
2282
+ __metadata("design:paramtypes", [Injector]),
2283
+ __metadata("design:returntype", Promise)
2284
+ ], ParameterSnapshot.prototype, "sanitise", null);
2193
2285
  if (false) {
2194
2286
  /** @type {?} */
2195
2287
  ParameterSnapshot.prototype.placeDefinition;
@@ -2202,10 +2294,13 @@ if (false) {
2202
2294
  (function (ParameterSnapshot) {
2203
2295
  /**
2204
2296
  * @param {?} placeDef
2205
- * @param {?} paramMap
2297
+ * @param {?} params
2298
+ * @param {?} urlSegments
2206
2299
  * @return {?}
2207
2300
  */
2208
- function create(placeDef, paramMap) {
2301
+ function create(placeDef, params, urlSegments) {
2302
+ /** @type {?} */
2303
+ const paramMap = new ConsolidatedParameterMap(params, urlSegments);
2209
2304
  /** @type {?} */
2210
2305
  const resolvedParameters = placeDef.getRouteParameters()
2211
2306
  .map((/**
@@ -2215,7 +2310,11 @@ if (false) {
2215
2310
  def => {
2216
2311
  if (def.isArray) {
2217
2312
  /** @type {?} */
2218
- const value = paramMap.has(def.name) ? paramMap.getAll(def.name).map((/**
2313
+ const value = paramMap.has(def.name) ? paramMap.getAll(def.name).filter((/**
2314
+ * @param {?} s
2315
+ * @return {?}
2316
+ */
2317
+ s => !___default.isEmpty(s))).map((/**
2219
2318
  * @param {?} raw
2220
2319
  * @return {?}
2221
2320
  */
@@ -2231,6 +2330,112 @@ if (false) {
2231
2330
  return new ParameterSnapshot(placeDef, resolvedParameters);
2232
2331
  }
2233
2332
  ParameterSnapshot.create = create;
2333
+ /**
2334
+ * This a work around for the fact that an activated route with multiple segments doesn't
2335
+ * include the segment params in the paramMap as well as each segment returns an empty
2336
+ * param map even when `parameter`s has content.
2337
+ */
2338
+ class ConsolidatedParameterMap {
2339
+ /**
2340
+ * @param {?} paramMap
2341
+ * @param {?} urlSegments
2342
+ */
2343
+ constructor(paramMap, urlSegments) {
2344
+ this.paramMaps = [paramMap].concat((urlSegments || []).map((/**
2345
+ * @param {?} s
2346
+ * @return {?}
2347
+ */
2348
+ s => new ParamMapAdapter(s.parameters)))).filter((/**
2349
+ * @param {?} m
2350
+ * @return {?}
2351
+ */
2352
+ m => !!m)); // the activated route param map can be null
2353
+ }
2354
+ /**
2355
+ * @param {?} name
2356
+ * @return {?}
2357
+ */
2358
+ get(name) {
2359
+ return this.paramMaps.find((/**
2360
+ * @param {?} m
2361
+ * @return {?}
2362
+ */
2363
+ m => m.has(name))).get(name);
2364
+ }
2365
+ /**
2366
+ * @param {?} name
2367
+ * @return {?}
2368
+ */
2369
+ getAll(name) {
2370
+ return this.paramMaps.find((/**
2371
+ * @param {?} m
2372
+ * @return {?}
2373
+ */
2374
+ m => m.has(name))).getAll(name);
2375
+ }
2376
+ /**
2377
+ * @param {?} name
2378
+ * @return {?}
2379
+ */
2380
+ has(name) {
2381
+ return !!this.paramMaps.find((/**
2382
+ * @param {?} m
2383
+ * @return {?}
2384
+ */
2385
+ m => m.has(name)));
2386
+ }
2387
+ }
2388
+ if (false) {
2389
+ /**
2390
+ * @type {?}
2391
+ * @private
2392
+ */
2393
+ ConsolidatedParameterMap.prototype.paramMaps;
2394
+ }
2395
+ class ParamMapAdapter {
2396
+ /**
2397
+ * @param {?} params
2398
+ */
2399
+ constructor(params) {
2400
+ this.params = params;
2401
+ }
2402
+ /**
2403
+ * @param {?} name
2404
+ * @return {?}
2405
+ */
2406
+ get(name) {
2407
+ return this.params[name];
2408
+ }
2409
+ /**
2410
+ * @param {?} name
2411
+ * @return {?}
2412
+ */
2413
+ getAll(name) {
2414
+ /** @type {?} */
2415
+ const value = this.get(name);
2416
+ return Array.isArray(value) ? value : [value];
2417
+ }
2418
+ /**
2419
+ * @param {?} name
2420
+ * @return {?}
2421
+ */
2422
+ has(name) {
2423
+ return this.keys.includes(name);
2424
+ }
2425
+ /**
2426
+ * @return {?}
2427
+ */
2428
+ get keys() {
2429
+ return Object.keys(this.params);
2430
+ }
2431
+ }
2432
+ if (false) {
2433
+ /**
2434
+ * @type {?}
2435
+ * @private
2436
+ */
2437
+ ParamMapAdapter.prototype.params;
2438
+ }
2234
2439
  /**
2235
2440
  * @abstract
2236
2441
  * @template T, S
@@ -2250,6 +2455,23 @@ if (false) {
2250
2455
  isRouteId() {
2251
2456
  return this.parameterDef.isRouteId;
2252
2457
  }
2458
+ /**
2459
+ * @param {?} visit
2460
+ * @param {?} injector
2461
+ * @return {?}
2462
+ */
2463
+ sanitise(visit, injector) {
2464
+ return __awaiter(this, void 0, void 0, function* () {
2465
+ /** @type {?} */
2466
+ const sanitiser = this.parameterDef.getSanitiser(injector);
2467
+ if (sanitiser) {
2468
+ return sanitiser.sanitise(this.parameterDef, this.value, visit);
2469
+ }
2470
+ else {
2471
+ return this.value;
2472
+ }
2473
+ });
2474
+ }
2253
2475
  }
2254
2476
  ParameterSnapshot.ResolvedParameter = ResolvedParameter;
2255
2477
  if (false) {
@@ -2357,6 +2579,96 @@ if (false) {
2357
2579
  ParameterSnapshot.ResolvedArrayParameter = ResolvedArrayParameter;
2358
2580
  })(ParameterSnapshot || (ParameterSnapshot = {}));
2359
2581
 
2582
+ /**
2583
+ * @fileoverview added by tsickle
2584
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2585
+ */
2586
+ class PlaceRouter {
2587
+ /**
2588
+ * @param {?} router
2589
+ */
2590
+ constructor(router) {
2591
+ this.router = router;
2592
+ }
2593
+ /**
2594
+ * @param {?} activatedRoute
2595
+ * @param {?} previous
2596
+ * @param {?} next
2597
+ * @return {?}
2598
+ */
2599
+ pushParameterChangesToRoute(activatedRoute, previous, next) {
2600
+ /** @type {?} */
2601
+ const relativePath = !!previous.hasRouteId() ? '..' : '.';
2602
+ this.router.navigate([relativePath].concat(this.createRouteParameters(next), this.getChildPath(activatedRoute.snapshot)), {
2603
+ relativeTo: activatedRoute
2604
+ });
2605
+ }
2606
+ /**
2607
+ * @param {?} activatedRoute
2608
+ * @param {?} sanitised
2609
+ * @return {?}
2610
+ */
2611
+ getRedirectUrlTree(activatedRoute, sanitised) {
2612
+ /** @type {?} */
2613
+ const urlSegments = activatedRoute.url;
2614
+ /** @type {?} */
2615
+ const weHaveARouteId = sanitised.hasRouteId() && sanitised.getFormattedRouteId();
2616
+ /** @type {?} */
2617
+ const commands = (weHaveARouteId) ?
2618
+ [urlSegments[0].path, sanitised.getFormattedRouteId(), sanitised.getFormattedParameters()] :
2619
+ [urlSegments[0].path, sanitised.getFormattedParameters()];
2620
+ console.log("redirect path", commands);
2621
+ return this.router.createUrlTree(commands);
2622
+ }
2623
+ /**
2624
+ * @protected
2625
+ * @param {?} activatedRoute
2626
+ * @return {?}
2627
+ */
2628
+ getChildPath(activatedRoute) {
2629
+ return ___default.flatten(activatedRoute.children.map((/**
2630
+ * @param {?} child
2631
+ * @return {?}
2632
+ */
2633
+ child => child.url)));
2634
+ }
2635
+ /**
2636
+ * @protected
2637
+ * @param {?} parameters
2638
+ * @return {?}
2639
+ */
2640
+ createRouteParameters(parameters) {
2641
+ /** @type {?} */
2642
+ const routeId = parameters.getFormattedRouteId();
2643
+ return routeId ?
2644
+ [routeId, parameters.getFormattedParameters()] :
2645
+ [parameters.getFormattedParameters()];
2646
+ }
2647
+ }
2648
+ PlaceRouter.decorators = [
2649
+ { type: Injectable, args: [{
2650
+ providedIn: 'root'
2651
+ },] }
2652
+ ];
2653
+ /** @nocollapse */
2654
+ PlaceRouter.ctorParameters = () => [
2655
+ { type: Router }
2656
+ ];
2657
+ /** @nocollapse */ PlaceRouter.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(ɵɵinject(Router)); }, token: PlaceRouter, providedIn: "root" });
2658
+ __decorate([
2659
+ Trace(),
2660
+ __metadata("design:type", Function),
2661
+ __metadata("design:paramtypes", [ActivatedRouteSnapshot, ParameterSnapshot]),
2662
+ __metadata("design:returntype", UrlTree)
2663
+ ], PlaceRouter.prototype, "getRedirectUrlTree", null);
2664
+ if (false) {
2665
+ /**
2666
+ * @type {?}
2667
+ * @private
2668
+ */
2669
+ PlaceRouter.prototype.router;
2670
+ }
2671
+
2360
2672
  /**
2361
2673
  * @fileoverview added by tsickle
2362
2674
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -2447,19 +2759,25 @@ class PlaceOutletComponent extends DisposableComponent {
2447
2759
  this._placeDefinition = new MutableValueModel();
2448
2760
  this._resolvedParameters = new MutableValueModel();
2449
2761
  const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
2450
- this._paramMap = chain(this._activatedRouteModel).pullObservableValue((/**
2762
+ /** @type {?} */
2763
+ const paramMap = chain(this._activatedRouteModel).pullObservableValue((/**
2451
2764
  * @param {?} ar
2452
2765
  * @return {?}
2453
2766
  */
2454
2767
  ar => ar.paramMap));
2455
- this.placeConfigured = valueOf.all(chain(this._inOutletUpdate).isFalsey(), this._placeDefinition, this._paramMap).areTruthy();
2456
- when.valueOf(this._paramMap).changes((/**
2457
- * @param {?} params
2768
+ /** @type {?} */
2769
+ const urls = chain(this._activatedRouteModel).pullObservableValue((/**
2770
+ * @param {?} ar
2458
2771
  * @return {?}
2459
2772
  */
2460
- (params) => {
2773
+ ar => ar.url));
2774
+ this.placeConfigured = valueOf.all(chain(this._inOutletUpdate).isFalsey(), this._placeDefinition, paramMap, urls).areTruthy();
2775
+ when.anyOf(paramMap, urls).changes((/**
2776
+ * @return {?}
2777
+ */
2778
+ () => {
2461
2779
  /** @type {?} */
2462
- const snapshot = ParameterSnapshot.create(this._placeDefinition.value, params);
2780
+ const snapshot = ParameterSnapshot.create(this._placeDefinition.value, paramMap.value, urls.value);
2463
2781
  this._incomingRouteChange.whileTrue((/**
2464
2782
  * @return {?}
2465
2783
  */
@@ -2481,6 +2799,10 @@ class PlaceOutletComponent extends DisposableComponent {
2481
2799
  }), {
2482
2800
  unless: this.incomingRouteChange
2483
2801
  });
2802
+ // const txo = new TransactionObserver().onEvent(e => console.log(e.toString()));
2803
+ // txo.observe('paramMap', paramMap);
2804
+ // txo.observe('urls', urls);
2805
+ // txo.observe('this._resolvedParameters', this._resolvedParameters);
2484
2806
  }
2485
2807
  /**
2486
2808
  * @return {?}
@@ -2614,11 +2936,6 @@ if (false) {
2614
2936
  * @private
2615
2937
  */
2616
2938
  PlaceOutletComponent.prototype._placeDefinition;
2617
- /**
2618
- * @type {?}
2619
- * @private
2620
- */
2621
- PlaceOutletComponent.prototype._paramMap;
2622
2939
  /** @type {?} */
2623
2940
  PlaceOutletComponent.prototype._resolvedParameters;
2624
2941
  /**
@@ -3154,12 +3471,12 @@ if (false) {
3154
3471
  /**
3155
3472
  * @return {?}
3156
3473
  */
3157
- Visit.prototype.getRouteId = function () { };
3474
+ Visit.prototype.getRouteIdValue = function () { };
3158
3475
  /**
3159
3476
  * @param {?} name
3160
3477
  * @return {?}
3161
3478
  */
3162
- Visit.prototype.getRouteParameter = function (name) { };
3479
+ Visit.prototype.getParameterValue = function (name) { };
3163
3480
  }
3164
3481
 
3165
3482
  /**
@@ -3252,14 +3569,14 @@ class PlaceRouteGuard {
3252
3569
  /** @type {?} */
3253
3570
  const placeDefinition = PlaceComponent.getDefinition(activatedRoute.component);
3254
3571
  /** @type {?} */
3255
- const snapshot = ParameterSnapshot.create(placeDefinition, activatedRoute.paramMap);
3572
+ const snapshot = ParameterSnapshot.create(placeDefinition, activatedRoute.paramMap, activatedRoute.url);
3256
3573
  return snapshot.sanitise(this.injector).then((/**
3257
3574
  * @param {?} sanitised
3258
3575
  * @return {?}
3259
3576
  */
3260
3577
  sanitised => {
3261
- if (sanitised.hasChanged(snapshot)) {
3262
- return this.placeRouter.createUrlTree(activatedRoute, snapshot, sanitised);
3578
+ if (sanitised.hasChanged(snapshot, true)) {
3579
+ return this.placeRouter.getRedirectUrlTree(activatedRoute, sanitised);
3263
3580
  }
3264
3581
  else {
3265
3582
  return true;
@@ -3295,69 +3612,6 @@ if (false) {
3295
3612
  PlaceRouteGuard.prototype.injector;
3296
3613
  }
3297
3614
 
3298
- /**
3299
- * @fileoverview added by tsickle
3300
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3301
- */
3302
- /**
3303
- * @template T, S
3304
- */
3305
- class DefaultParameterSanitiser {
3306
- /**
3307
- * @param {?} def
3308
- * @param {?} remember
3309
- * @param {?} defaultValue
3310
- */
3311
- constructor(def, remember, defaultValue) {
3312
- this.def = def;
3313
- this.remember = remember;
3314
- this.defaultValue = defaultValue;
3315
- }
3316
- /**
3317
- * @param {?} value
3318
- * @param {?} visit
3319
- * @return {?}
3320
- */
3321
- sanitise(value, visit) {
3322
- if (this.isBlank(value)) {
3323
- if (this.remember) {
3324
- // value = null;
3325
- }
3326
- return this.isBlank(value) && !___default.isNil(this.defaultValue) ? this.defaultValue : value;
3327
- }
3328
- else {
3329
- return value;
3330
- }
3331
- }
3332
- /**
3333
- * @private
3334
- * @param {?} value
3335
- * @return {?}
3336
- */
3337
- isBlank(value) {
3338
- /** @type {?} */
3339
- const isNil = ___default.isNil(value);
3340
- return this.def.isArray ? !isNil || value['length'] < 1 : isNil;
3341
- }
3342
- }
3343
- __decorate([
3344
- Trace(),
3345
- __metadata("design:type", Function),
3346
- __metadata("design:paramtypes", [Object, Object]),
3347
- __metadata("design:returntype", Object)
3348
- ], DefaultParameterSanitiser.prototype, "sanitise", null);
3349
- if (false) {
3350
- /**
3351
- * @type {?}
3352
- * @private
3353
- */
3354
- DefaultParameterSanitiser.prototype.def;
3355
- /** @type {?} */
3356
- DefaultParameterSanitiser.prototype.remember;
3357
- /** @type {?} */
3358
- DefaultParameterSanitiser.prototype.defaultValue;
3359
- }
3360
-
3361
3615
  /**
3362
3616
  * @fileoverview added by tsickle
3363
3617
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -3469,16 +3723,17 @@ function RouteParameterList(elementType, options) {
3469
3723
  */
3470
3724
  /**
3471
3725
  * @record
3472
- * @template T
3726
+ * @template S
3473
3727
  */
3474
3728
  function ParameterSanitiser() { }
3475
3729
  if (false) {
3476
3730
  /**
3731
+ * @param {?} parameterDef
3477
3732
  * @param {?} value
3478
3733
  * @param {?=} visit
3479
3734
  * @return {?}
3480
3735
  */
3481
- ParameterSanitiser.prototype.sanitise = function (value, visit) { };
3736
+ ParameterSanitiser.prototype.sanitise = function (parameterDef, value, visit) { };
3482
3737
  }
3483
3738
 
3484
3739
  /**
@@ -3608,7 +3863,7 @@ class Sanitiser {
3608
3863
  return __awaiter(this, void 0, void 0, function* () {
3609
3864
  if (this.sanitiser) {
3610
3865
  this.initialValue = this.readFrom(this.snapshot);
3611
- this._sanitisedValue = yield this.sanitiser.sanitise(this.initialValue);
3866
+ this._sanitisedValue = yield this.sanitiser.sanitise(null, this.initialValue);
3612
3867
  if (this.initialValue !== this._sanitisedValue) {
3613
3868
  return false;
3614
3869
  }
@@ -3857,5 +4112,5 @@ if (false) {
3857
4112
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3858
4113
  */
3859
4114
 
3860
- export { ACTIVITY_DATA, AbstractActivity, AbstractInputComponent, AbstractPlaceNavigationComponent, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CommandDirective, ConfirmationDialogComponent, DEFINITION_META_DATA_KEY, DefaultParameterSanitiser, DialogInteractionService, Dimension, DisposableComponent, EmptyStateComponent, FocusBindingDirective, INTERACTION_CONTEXT, InteractionContext, InteractionModule, LEFT_RIGHT_PLACE_ANIMATION, LeavePlaceGuard, ListPlaceNavComponent, NumberInputComponent, ParameterDefinition, ParameterSnapshot, ParameterType, PasswordInputComponent, Place, PlaceComponent, PlaceDefinition, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouteGuard, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, RouteParameter, RouteParameterList, RouteParameterSanitiser, Sanitiser, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, leftRightPlaceAnimation, slideDownAndUpAnimation, CommandDirective as ɵa, FocusBindingDirective as ɵb, AlertDialogComponent as ɵba, DialogInteractionService as ɵbc, InteractionContext as ɵbd, DisposableComponent as ɵc, NumberInputComponent as ɵd, AbstractInputComponent as ɵe, StringInputComponent as ɵf, PasswordInputComponent as ɵg, SelectInputComponent as ɵh, PlaceModule as ɵi, EmptyStateComponent as ɵj, BusyOverlayComponent as ɵk, PlaceOutletComponent as ɵl, leftRightPlaceAnimation as ɵm, LEFT_RIGHT_PLACE_ANIMATION as ɵn, PlaceRouter as ɵo, PlaceHistory as ɵp, TabbedPlaceNavigationComponent as ɵq, AbstractPlaceNavigationComponent as ɵr, ListPlaceNavComponent as ɵs, InteractionModule as ɵt, ActivityContainerComponent as ɵu, ActivityOutletComponent as ɵv, ConfirmationDialogComponent as ɵw, AbstractActivity as ɵx, ACTIVITY_DATA as ɵy };
4115
+ export { ACTIVITY_DATA, AbstractActivity, AbstractInputComponent, AbstractPlaceNavigationComponent, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CommandDirective, ConfirmationDialogComponent, DEFINITION_META_DATA_KEY, DialogInteractionService, Dimension, DisposableComponent, EmptyStateComponent, FocusBindingDirective, INTERACTION_CONTEXT, InteractionContext, InteractionModule, LEFT_RIGHT_PLACE_ANIMATION, LeavePlaceGuard, ListPlaceNavComponent, NumberInputComponent, ParameterDefinition, ParameterSnapshot, ParameterType, PasswordInputComponent, Place, PlaceComponent, PlaceDefinition, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouteGuard, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, RouteParameter, RouteParameterList, RouteParameterSanitiser, Sanitiser, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, leftRightPlaceAnimation, slideDownAndUpAnimation, CommandDirective as ɵa, FocusBindingDirective as ɵb, AlertDialogComponent as ɵba, DialogInteractionService as ɵbc, InteractionContext as ɵbd, DisposableComponent as ɵc, NumberInputComponent as ɵd, AbstractInputComponent as ɵe, StringInputComponent as ɵf, PasswordInputComponent as ɵg, SelectInputComponent as ɵh, PlaceModule as ɵi, EmptyStateComponent as ɵj, BusyOverlayComponent as ɵk, PlaceOutletComponent as ɵl, leftRightPlaceAnimation as ɵm, LEFT_RIGHT_PLACE_ANIMATION as ɵn, PlaceRouter as ɵo, PlaceHistory as ɵp, TabbedPlaceNavigationComponent as ɵq, AbstractPlaceNavigationComponent as ɵr, ListPlaceNavComponent as ɵs, InteractionModule as ɵt, ActivityContainerComponent as ɵu, ActivityOutletComponent as ɵv, ConfirmationDialogComponent as ɵw, AbstractActivity as ɵx, ACTIVITY_DATA as ɵy };
3861
4116
  //# sourceMappingURL=coolon-angular-ui-powerups.js.map