@coolon/angular-ui-powerups 0.0.44 → 0.0.47

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 (53) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +489 -167
  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/interaction/abstract-activity.js +3 -9
  9. package/esm2015/lib/place/components/place-outlet/place-outlet.component.js +17 -12
  10. package/esm2015/lib/place/guards/place-route.guard.js +4 -4
  11. package/esm2015/lib/place/index.js +1 -2
  12. package/esm2015/lib/place/place-component.js +2 -2
  13. package/esm2015/lib/place/place-history.js +29 -6
  14. package/esm2015/lib/place/place-router.js +29 -22
  15. package/esm2015/lib/place/route/parameter-decorators.js +1 -1
  16. package/esm2015/lib/place/route/parameter-definition.class.js +92 -9
  17. package/esm2015/lib/place/route/parameter-sanitiser.js +4 -3
  18. package/esm2015/lib/place/route/parameter-snapshot.js +214 -23
  19. package/esm2015/lib/place/route/route-parameter-sanitiser.js +4 -9
  20. package/esm2015/lib/place/visit.js +3 -3
  21. package/esm2015/public_api.js +2 -2
  22. package/esm5/coolon-angular-ui-powerups.js +2 -2
  23. package/esm5/index.js +2 -2
  24. package/esm5/lib/interaction/abstract-activity.js +14 -10
  25. package/esm5/lib/place/components/place-outlet/place-outlet.component.js +17 -12
  26. package/esm5/lib/place/guards/place-route.guard.js +4 -4
  27. package/esm5/lib/place/index.js +1 -2
  28. package/esm5/lib/place/place-component.js +2 -2
  29. package/esm5/lib/place/place-history.js +39 -6
  30. package/esm5/lib/place/place-router.js +39 -27
  31. package/esm5/lib/place/route/parameter-decorators.js +1 -1
  32. package/esm5/lib/place/route/parameter-definition.class.js +104 -9
  33. package/esm5/lib/place/route/parameter-sanitiser.js +4 -3
  34. package/esm5/lib/place/route/parameter-snapshot.js +273 -24
  35. package/esm5/lib/place/route/route-parameter-sanitiser.js +8 -10
  36. package/esm5/lib/place/visit.js +3 -3
  37. package/esm5/public_api.js +2 -2
  38. package/fesm2015/coolon-angular-ui-powerups.js +388 -153
  39. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  40. package/fesm5/coolon-angular-ui-powerups.js +491 -168
  41. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  42. package/lib/place/components/place-outlet/place-outlet.component.d.ts +0 -1
  43. package/lib/place/index.d.ts +0 -1
  44. package/lib/place/place-history.d.ts +3 -0
  45. package/lib/place/place-router.d.ts +4 -3
  46. package/lib/place/route/parameter-definition.class.d.ts +12 -2
  47. package/lib/place/route/parameter-sanitiser.d.ts +3 -2
  48. package/lib/place/route/parameter-snapshot.d.ts +11 -8
  49. package/lib/place/visit.d.ts +2 -2
  50. package/package.json +1 -1
  51. package/esm2015/lib/place/route/default-parameter-sanitiser.js +0 -66
  52. package/esm5/lib/place/route/default-parameter-sanitiser.js +0 -73
  53. package/lib/place/route/default-parameter-sanitiser.d.ts +0 -11
@@ -5,7 +5,7 @@ import { MatDialog, MatButtonModule, MatDialogModule, MatTabsModule, MatProgress
5
5
  import { MatTabsModule as MatTabsModule$1 } from '@angular/material/tabs';
6
6
  import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7
7
  import { __decorate, __metadata, __awaiter } from 'tslib';
8
- import { GarbageCollector, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, assert, UnaryCommand, lang, Dsl, Logger, EventListenerList, DelegatingValueModel, Trace, MutableListModel, StoreInValueModel, Binding, Guard, MutableValueModel, OptionsHelper, ValueHolder } from '@coolon/pectin';
8
+ import { GarbageCollector, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, assert, UnaryCommand, lang, Dsl, Logger, EventListenerList, DelegatingValueModel, MutableListModel, StoreInValueModel, Binding, Guard, MutableValueModel, OptionsHelper, ValueHolder } from '@coolon/pectin';
9
9
  import { PortalModule } from '@angular/cdk/portal';
10
10
  import { Deferred } from '@coolon/pectin/lib/promise/deferred.class';
11
11
  import { assert as assert$1, Klass, Opts } from '@coolon/typescript-utilities';
@@ -947,6 +947,7 @@ class AbstractActivity extends DisposableComponent {
947
947
  */
948
948
  () => this.finalizeAndDispose()));
949
949
  }
950
+ // @Trace()
950
951
  /**
951
952
  * @return {?}
952
953
  */
@@ -995,12 +996,6 @@ class AbstractActivity extends DisposableComponent {
995
996
  return this._busyModel.value;
996
997
  }
997
998
  }
998
- __decorate([
999
- Trace(),
1000
- __metadata("design:type", Function),
1001
- __metadata("design:paramtypes", []),
1002
- __metadata("design:returntype", void 0)
1003
- ], AbstractActivity.prototype, "onActivityReady", null);
1004
999
  if (false) {
1005
1000
  /**
1006
1001
  * @type {?}
@@ -1578,7 +1573,7 @@ class PlaceComponent extends DisposableComponent {
1578
1573
  * @return {?}
1579
1574
  */
1580
1575
  toRight(parameters) {
1581
- return parameters.getResolvedParameterValue(parameterDef);
1576
+ return parameters.getValueOf(parameterDef);
1582
1577
  },
1583
1578
  /**
1584
1579
  * @param {?} value
@@ -1790,7 +1785,7 @@ class PlaceHistory {
1790
1785
  */
1791
1786
  constructor(router) {
1792
1787
  this.router = router;
1793
- this._history = [];
1788
+ this._history = new Map();
1794
1789
  }
1795
1790
  /**
1796
1791
  * @param {?} state
@@ -1798,12 +1793,35 @@ class PlaceHistory {
1798
1793
  */
1799
1794
  add(state) {
1800
1795
  /** @type {?} */
1801
- const previousState = ___default.last(this._history);
1796
+ const history = this.getHistory(state.placeDefinition);
1797
+ /** @type {?} */
1798
+ const previousState = ___default.last(history);
1802
1799
  if (!previousState || state.hasChanged(previousState)) {
1803
- this._history.push(state);
1804
- // limit our history to 100 visits
1805
- this._history = this._history.slice(-100);
1800
+ history.unshift(state); // LIFO
1801
+ this.setHistory(state.placeDefinition, history.slice(-3)); // limit our history to 3 visits
1802
+ }
1803
+ }
1804
+ /**
1805
+ * @param {?} placeDef
1806
+ * @return {?}
1807
+ */
1808
+ getHistory(placeDef) {
1809
+ /** @type {?} */
1810
+ let history = this._history.get(placeDef);
1811
+ if (!history) {
1812
+ history = [];
1813
+ this.setHistory(placeDef, history);
1806
1814
  }
1815
+ return history;
1816
+ }
1817
+ /**
1818
+ * @private
1819
+ * @param {?} placeDef
1820
+ * @param {?} history
1821
+ * @return {?}
1822
+ */
1823
+ setHistory(placeDef, history) {
1824
+ this._history.set(placeDef, history);
1807
1825
  }
1808
1826
  }
1809
1827
  PlaceHistory.decorators = [
@@ -1847,46 +1865,53 @@ class PlaceRouter {
1847
1865
  * @return {?}
1848
1866
  */
1849
1867
  pushParameterChangesToRoute(activatedRoute, previous, next) {
1850
- this.router.navigate(this.redirect(activatedRoute.snapshot, previous, next), {
1868
+ /** @type {?} */
1869
+ const relativePath = !!previous.hasRouteId() ? '..' : '.';
1870
+ this.router.navigate([relativePath].concat(this.createRouteParameters(next), this.getChildPath(activatedRoute.snapshot)), {
1851
1871
  relativeTo: activatedRoute
1852
1872
  });
1853
1873
  }
1874
+ // @Trace()
1854
1875
  /**
1855
1876
  * @param {?} activatedRoute
1856
1877
  * @param {?} sanitised
1857
- * @param {?} snapshot
1858
1878
  * @return {?}
1859
1879
  */
1860
- createUrlTree(activatedRoute, sanitised, snapshot) {
1861
- return this.router.createUrlTree(this.redirect(activatedRoute, snapshot, sanitised));
1880
+ getRedirectUrlTree(activatedRoute, sanitised) {
1881
+ /** @type {?} */
1882
+ const urlSegments = activatedRoute.url;
1883
+ /** @type {?} */
1884
+ const weHaveARouteId = sanitised.hasRouteId() && sanitised.getFormattedRouteId();
1885
+ /** @type {?} */
1886
+ const commands = (weHaveARouteId) ?
1887
+ [urlSegments[0].path, sanitised.getFormattedRouteId(), sanitised.getFormattedParameters()] :
1888
+ [urlSegments[0].path, sanitised.getFormattedParameters()];
1889
+ console.log("redirect path", commands);
1890
+ return this.router.createUrlTree(commands);
1862
1891
  }
1863
1892
  /**
1864
1893
  * @protected
1865
1894
  * @param {?} activatedRoute
1866
- * @param {?} previous
1867
- * @param {?} next
1868
1895
  * @return {?}
1869
1896
  */
1870
- redirect(activatedRoute, previous, next) {
1871
- /** @type {?} */
1872
- const childSegments = ___default.flatten(activatedRoute.children.map((/**
1897
+ getChildPath(activatedRoute) {
1898
+ return ___default.flatten(activatedRoute.children.map((/**
1873
1899
  * @param {?} child
1874
1900
  * @return {?}
1875
1901
  */
1876
1902
  child => child.url)));
1903
+ }
1904
+ /**
1905
+ * @protected
1906
+ * @param {?} parameters
1907
+ * @return {?}
1908
+ */
1909
+ createRouteParameters(parameters) {
1877
1910
  /** @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)));
1911
+ const routeId = parameters.getFormattedRouteId();
1912
+ return routeId ?
1913
+ [routeId, parameters.getFormattedParameters()] :
1914
+ [parameters.getFormattedParameters()];
1890
1915
  }
1891
1916
  }
1892
1917
  PlaceRouter.decorators = [
@@ -1927,18 +1952,20 @@ class ParameterDefinition {
1927
1952
  /** @type {?} */
1928
1953
  const opts = Opts.get(options);
1929
1954
  this.name = opts.getOptional('as', propertyName);
1930
- // this.sanitiser = new DefaultParameterSanitiser(
1931
- // this,
1932
- // opts.getOptional('remember', false),
1933
- // opts.getOptional('defaultValue', null)
1934
- // );
1955
+ this.remember = opts.getOptional('remember', false);
1956
+ this.defaultValue = opts.getOptional('defaultValue', null);
1935
1957
  }
1936
1958
  /**
1937
1959
  * @param {?} injector
1938
1960
  * @return {?}
1939
1961
  */
1940
1962
  getSanitiser(injector) {
1941
- return this.sanitiser;
1963
+ if (this.remember || !___default.isNil(this.defaultValue)) {
1964
+ return new ParameterDefinition.DefaultParameterSanitiser(this.remember, this.defaultValue, injector.get(PlaceHistory));
1965
+ }
1966
+ else {
1967
+ return null;
1968
+ }
1942
1969
  }
1943
1970
  }
1944
1971
  if (false) {
@@ -1948,8 +1975,16 @@ if (false) {
1948
1975
  ParameterDefinition.prototype.isArray;
1949
1976
  /** @type {?} */
1950
1977
  ParameterDefinition.prototype.name;
1951
- /** @type {?} */
1952
- ParameterDefinition.prototype.sanitiser;
1978
+ /**
1979
+ * @type {?}
1980
+ * @private
1981
+ */
1982
+ ParameterDefinition.prototype.remember;
1983
+ /**
1984
+ * @type {?}
1985
+ * @private
1986
+ */
1987
+ ParameterDefinition.prototype.defaultValue;
1953
1988
  /** @type {?} */
1954
1989
  ParameterDefinition.prototype.propertyName;
1955
1990
  /** @type {?} */
@@ -2023,6 +2058,77 @@ if (false) {
2023
2058
  /** @type {?} */
2024
2059
  ArrayParameter.prototype.isArray;
2025
2060
  }
2061
+ /**
2062
+ * @template T, S
2063
+ */
2064
+ class DefaultParameterSanitiser {
2065
+ /**
2066
+ * @param {?} remember
2067
+ * @param {?} defaultValue
2068
+ * @param {?} placeHistory
2069
+ */
2070
+ constructor(remember, defaultValue, placeHistory) {
2071
+ this.remember = remember;
2072
+ this.defaultValue = defaultValue;
2073
+ this.placeHistory = placeHistory;
2074
+ }
2075
+ /**
2076
+ * @param {?} parameterDef
2077
+ * @param {?} value
2078
+ * @param {?=} visit
2079
+ * @return {?}
2080
+ */
2081
+ sanitise(parameterDef, value, visit) {
2082
+ if (this.isBlank(parameterDef, value)) {
2083
+ if (this.remember) {
2084
+ /** @type {?} */
2085
+ const visits = this.placeHistory.getHistory(visit.placeDefinition);
2086
+ value = visits.map((/**
2087
+ * @param {?} v
2088
+ * @return {?}
2089
+ */
2090
+ v => v.getValueOf(parameterDef)))
2091
+ .filter((/**
2092
+ * @param {?} v
2093
+ * @return {?}
2094
+ */
2095
+ v => !___default.isNil(v)))
2096
+ .find((/**
2097
+ * @param {?} v
2098
+ * @return {?}
2099
+ */
2100
+ v => !this.isBlank(parameterDef, v)));
2101
+ }
2102
+ value = this.isBlank(parameterDef, value) ? this.defaultValue : value;
2103
+ console.log(`${parameterDef.name} is blank, returning: ${value}`);
2104
+ return value;
2105
+ }
2106
+ else {
2107
+ console.log(`${parameterDef.name} is not blank`);
2108
+ return value;
2109
+ }
2110
+ }
2111
+ /**
2112
+ * @private
2113
+ * @param {?} def
2114
+ * @param {?} value
2115
+ * @return {?}
2116
+ */
2117
+ isBlank(def, value) {
2118
+ /** @type {?} */
2119
+ const isNil = ___default.isNil(value);
2120
+ return isNil ? true : def.isArray ? value['length'] < 1 : false;
2121
+ }
2122
+ }
2123
+ ParameterDefinition.DefaultParameterSanitiser = DefaultParameterSanitiser;
2124
+ if (false) {
2125
+ /** @type {?} */
2126
+ DefaultParameterSanitiser.prototype.remember;
2127
+ /** @type {?} */
2128
+ DefaultParameterSanitiser.prototype.defaultValue;
2129
+ /** @type {?} */
2130
+ DefaultParameterSanitiser.prototype.placeHistory;
2131
+ }
2026
2132
  })(ParameterDefinition || (ParameterDefinition = {}));
2027
2133
 
2028
2134
  var _a;
@@ -2037,20 +2143,25 @@ class ParameterSnapshot {
2037
2143
  }
2038
2144
  /**
2039
2145
  * @param {?} other
2146
+ * @param {?=} debug
2040
2147
  * @return {?}
2041
2148
  */
2042
- hasChanged(other) {
2149
+ hasChanged(other, debug = false) {
2043
2150
  /** @type {?} */
2044
2151
  const changed = this.resolved.find((/**
2045
2152
  * @param {?} r
2046
2153
  * @return {?}
2047
2154
  */
2048
2155
  (r) => {
2049
- return !r.isSame(other.getResolvedParameterValue(r.parameterDef));
2156
+ return !r.isSame(other.getValueOf(r.parameterDef));
2050
2157
  }));
2051
- // if (changed) {
2052
- // console.log({ mine: changed, theirs: other.getResolvedParameter(changed.parameterDef) });
2053
- // }
2158
+ if (changed && debug) {
2159
+ console.log({
2160
+ name: changed.parameterDef.name,
2161
+ mine: changed.value,
2162
+ theirs: other.getValueOf(changed.parameterDef)
2163
+ });
2164
+ }
2054
2165
  return !!changed;
2055
2166
  }
2056
2167
  /**
@@ -2058,7 +2169,7 @@ class ParameterSnapshot {
2058
2169
  * @param {?} parameterDef
2059
2170
  * @return {?}
2060
2171
  */
2061
- getResolvedParameter(parameterDef) {
2172
+ getParameter(parameterDef) {
2062
2173
  return this.resolved.find((/**
2063
2174
  * @param {?} r
2064
2175
  * @return {?}
@@ -2070,22 +2181,22 @@ class ParameterSnapshot {
2070
2181
  * @param {?} parameterDef
2071
2182
  * @return {?}
2072
2183
  */
2073
- getResolvedParameterValue(parameterDef) {
2184
+ getValueOf(parameterDef) {
2074
2185
  /** @type {?} */
2075
- const resolvedParameter = this.getResolvedParameter(parameterDef);
2186
+ const resolvedParameter = this.getParameter(parameterDef);
2076
2187
  return resolvedParameter ? resolvedParameter.value : null;
2077
2188
  }
2078
2189
  /**
2079
2190
  * @return {?}
2080
2191
  */
2081
- getRouteId() {
2082
- return this.getResolvedRouteId() ? this.getResolvedRouteId().value : null;
2192
+ getRouteIdValue() {
2193
+ return this.getRouteIdParameter() ? this.getRouteIdParameter().value : null;
2083
2194
  }
2084
2195
  /**
2085
2196
  * @param {?} name
2086
2197
  * @return {?}
2087
2198
  */
2088
- getRouteParameter(name) {
2199
+ getParameterValue(name) {
2089
2200
  /** @type {?} */
2090
2201
  const resolvedParameter = this.resolved.find((/**
2091
2202
  * @param {?} r
@@ -2098,7 +2209,7 @@ class ParameterSnapshot {
2098
2209
  * @private
2099
2210
  * @return {?}
2100
2211
  */
2101
- getResolvedRouteId() {
2212
+ getRouteIdParameter() {
2102
2213
  // RouteId's are never arrays: see parameter-decorators.ts createDefinition methods. It would be nice to
2103
2214
  // capture this in the type system though
2104
2215
  return (/** @type {?} */ (this.resolved.find((/**
@@ -2107,18 +2218,29 @@ class ParameterSnapshot {
2107
2218
  */
2108
2219
  p => p.parameterDef.isRouteId))));
2109
2220
  }
2221
+ /**
2222
+ * @private
2223
+ * @return {?}
2224
+ */
2225
+ getRouteParameters() {
2226
+ return this.resolved.filter((/**
2227
+ * @param {?} r
2228
+ * @return {?}
2229
+ */
2230
+ r => !r.parameterDef.isRouteId));
2231
+ }
2110
2232
  /**
2111
2233
  * @return {?}
2112
2234
  */
2113
2235
  hasRouteId() {
2114
- return !!this.getResolvedRouteId();
2236
+ return !!this.getRouteIdParameter();
2115
2237
  }
2116
2238
  /**
2117
2239
  * @return {?}
2118
2240
  */
2119
2241
  getFormattedRouteId() {
2120
2242
  /** @type {?} */
2121
- const routeIdParam = this.getResolvedRouteId();
2243
+ const routeIdParam = this.getRouteIdParameter();
2122
2244
  return routeIdParam ? routeIdParam.formattedValue() : null;
2123
2245
  }
2124
2246
  /**
@@ -2141,6 +2263,22 @@ class ParameterSnapshot {
2141
2263
  }));
2142
2264
  return params;
2143
2265
  }
2266
+ /**
2267
+ * @return {?}
2268
+ */
2269
+ getAllFormattedParameters() {
2270
+ /** @type {?} */
2271
+ const params = {};
2272
+ /** @type {?} */
2273
+ const routeIdParam = this.resolved.forEach((/**
2274
+ * @param {?} p
2275
+ * @return {?}
2276
+ */
2277
+ p => {
2278
+ params[p.parameterDef.name] = p.formattedValue();
2279
+ }));
2280
+ return params;
2281
+ }
2144
2282
  /**
2145
2283
  * @template T, S
2146
2284
  * @param {?} parameter
@@ -2156,13 +2294,36 @@ class ParameterSnapshot {
2156
2294
  return p.parameterDef === parameter ? p.replace(value) : p;
2157
2295
  })));
2158
2296
  }
2297
+ // @Trace()
2159
2298
  /**
2160
2299
  * @param {?} injector
2161
2300
  * @return {?}
2162
2301
  */
2163
2302
  sanitise(injector) {
2164
2303
  return __awaiter(this, void 0, void 0, function* () {
2165
- return this;
2304
+ if (this.hasRouteId()) {
2305
+ /** @type {?} */
2306
+ const routeId = this.getRouteIdParameter();
2307
+ /** @type {?} */
2308
+ const sanitisedValue = yield routeId.sanitise(this, injector);
2309
+ if (!routeId.isSame(sanitisedValue)) {
2310
+ // if the route id has changed we redirect immediately as other
2311
+ // parameter sanitisers might use it.
2312
+ return this.replace(routeId.parameterDef, sanitisedValue);
2313
+ }
2314
+ }
2315
+ /** @type {?} */
2316
+ let result = this;
2317
+ /** @type {?} */
2318
+ const routeParameters = this.getRouteParameters();
2319
+ for (let i = 0; i < routeParameters.length; i++) {
2320
+ /** @type {?} */
2321
+ const sanitisedValue = yield routeParameters[i].sanitise(this, injector);
2322
+ if (!routeParameters[i].isSame(sanitisedValue)) {
2323
+ result = this.replace(routeParameters[i].parameterDef, sanitisedValue);
2324
+ }
2325
+ }
2326
+ return result;
2166
2327
  });
2167
2328
  }
2168
2329
  }
@@ -2171,25 +2332,31 @@ __decorate([
2171
2332
  __metadata("design:type", Function),
2172
2333
  __metadata("design:paramtypes", [ParameterDefinition]),
2173
2334
  __metadata("design:returntype", ParameterSnapshot.ResolvedParameter)
2174
- ], ParameterSnapshot.prototype, "getResolvedParameter", null);
2335
+ ], ParameterSnapshot.prototype, "getParameter", null);
2175
2336
  __decorate([
2176
2337
  Memoize$1(),
2177
2338
  __metadata("design:type", Function),
2178
2339
  __metadata("design:paramtypes", [ParameterDefinition]),
2179
2340
  __metadata("design:returntype", typeof (_a = typeof S !== "undefined" && S) === "function" ? _a : Object)
2180
- ], ParameterSnapshot.prototype, "getResolvedParameterValue", null);
2341
+ ], ParameterSnapshot.prototype, "getValueOf", null);
2181
2342
  __decorate([
2182
2343
  Memoize$1(),
2183
2344
  __metadata("design:type", Function),
2184
2345
  __metadata("design:paramtypes", [String]),
2185
2346
  __metadata("design:returntype", Object)
2186
- ], ParameterSnapshot.prototype, "getRouteParameter", null);
2347
+ ], ParameterSnapshot.prototype, "getParameterValue", null);
2187
2348
  __decorate([
2188
2349
  Memoize$1(),
2189
2350
  __metadata("design:type", Function),
2190
2351
  __metadata("design:paramtypes", []),
2191
2352
  __metadata("design:returntype", ParameterSnapshot.ResolvedValueParameter)
2192
- ], ParameterSnapshot.prototype, "getResolvedRouteId", null);
2353
+ ], ParameterSnapshot.prototype, "getRouteIdParameter", null);
2354
+ __decorate([
2355
+ Memoize$1(),
2356
+ __metadata("design:type", Function),
2357
+ __metadata("design:paramtypes", []),
2358
+ __metadata("design:returntype", Array)
2359
+ ], ParameterSnapshot.prototype, "getRouteParameters", null);
2193
2360
  if (false) {
2194
2361
  /** @type {?} */
2195
2362
  ParameterSnapshot.prototype.placeDefinition;
@@ -2202,10 +2369,13 @@ if (false) {
2202
2369
  (function (ParameterSnapshot) {
2203
2370
  /**
2204
2371
  * @param {?} placeDef
2205
- * @param {?} paramMap
2372
+ * @param {?} params
2373
+ * @param {?} urlSegments
2206
2374
  * @return {?}
2207
2375
  */
2208
- function create(placeDef, paramMap) {
2376
+ function create(placeDef, params, urlSegments) {
2377
+ /** @type {?} */
2378
+ const paramMap = new ConsolidatedParameterMap(params, urlSegments);
2209
2379
  /** @type {?} */
2210
2380
  const resolvedParameters = placeDef.getRouteParameters()
2211
2381
  .map((/**
@@ -2215,7 +2385,11 @@ if (false) {
2215
2385
  def => {
2216
2386
  if (def.isArray) {
2217
2387
  /** @type {?} */
2218
- const value = paramMap.has(def.name) ? paramMap.getAll(def.name).map((/**
2388
+ const value = paramMap.has(def.name) ? paramMap.getAll(def.name).filter((/**
2389
+ * @param {?} s
2390
+ * @return {?}
2391
+ */
2392
+ s => !___default.isEmpty(s))).map((/**
2219
2393
  * @param {?} raw
2220
2394
  * @return {?}
2221
2395
  */
@@ -2231,6 +2405,112 @@ if (false) {
2231
2405
  return new ParameterSnapshot(placeDef, resolvedParameters);
2232
2406
  }
2233
2407
  ParameterSnapshot.create = create;
2408
+ /**
2409
+ * This a work around for the fact that an activated route with multiple segments doesn't
2410
+ * include the segment params in the paramMap as well as each segment returns an empty
2411
+ * param map even when `parameter`s has content.
2412
+ */
2413
+ class ConsolidatedParameterMap {
2414
+ /**
2415
+ * @param {?} paramMap
2416
+ * @param {?} urlSegments
2417
+ */
2418
+ constructor(paramMap, urlSegments) {
2419
+ this.paramMaps = [paramMap].concat((urlSegments || []).map((/**
2420
+ * @param {?} s
2421
+ * @return {?}
2422
+ */
2423
+ s => new ParamMapAdapter(s.parameters)))).filter((/**
2424
+ * @param {?} m
2425
+ * @return {?}
2426
+ */
2427
+ m => !!m)); // the activated route param map can be null
2428
+ }
2429
+ /**
2430
+ * @param {?} name
2431
+ * @return {?}
2432
+ */
2433
+ get(name) {
2434
+ return this.paramMaps.find((/**
2435
+ * @param {?} m
2436
+ * @return {?}
2437
+ */
2438
+ m => m.has(name))).get(name);
2439
+ }
2440
+ /**
2441
+ * @param {?} name
2442
+ * @return {?}
2443
+ */
2444
+ getAll(name) {
2445
+ return this.paramMaps.find((/**
2446
+ * @param {?} m
2447
+ * @return {?}
2448
+ */
2449
+ m => m.has(name))).getAll(name);
2450
+ }
2451
+ /**
2452
+ * @param {?} name
2453
+ * @return {?}
2454
+ */
2455
+ has(name) {
2456
+ return !!this.paramMaps.find((/**
2457
+ * @param {?} m
2458
+ * @return {?}
2459
+ */
2460
+ m => m.has(name)));
2461
+ }
2462
+ }
2463
+ if (false) {
2464
+ /**
2465
+ * @type {?}
2466
+ * @private
2467
+ */
2468
+ ConsolidatedParameterMap.prototype.paramMaps;
2469
+ }
2470
+ class ParamMapAdapter {
2471
+ /**
2472
+ * @param {?} params
2473
+ */
2474
+ constructor(params) {
2475
+ this.params = params;
2476
+ }
2477
+ /**
2478
+ * @param {?} name
2479
+ * @return {?}
2480
+ */
2481
+ get(name) {
2482
+ return this.params[name];
2483
+ }
2484
+ /**
2485
+ * @param {?} name
2486
+ * @return {?}
2487
+ */
2488
+ getAll(name) {
2489
+ /** @type {?} */
2490
+ const value = this.get(name);
2491
+ return Array.isArray(value) ? value : [value];
2492
+ }
2493
+ /**
2494
+ * @param {?} name
2495
+ * @return {?}
2496
+ */
2497
+ has(name) {
2498
+ return this.keys.includes(name);
2499
+ }
2500
+ /**
2501
+ * @return {?}
2502
+ */
2503
+ get keys() {
2504
+ return Object.keys(this.params);
2505
+ }
2506
+ }
2507
+ if (false) {
2508
+ /**
2509
+ * @type {?}
2510
+ * @private
2511
+ */
2512
+ ParamMapAdapter.prototype.params;
2513
+ }
2234
2514
  /**
2235
2515
  * @abstract
2236
2516
  * @template T, S
@@ -2250,6 +2530,23 @@ if (false) {
2250
2530
  isRouteId() {
2251
2531
  return this.parameterDef.isRouteId;
2252
2532
  }
2533
+ /**
2534
+ * @param {?} visit
2535
+ * @param {?} injector
2536
+ * @return {?}
2537
+ */
2538
+ sanitise(visit, injector) {
2539
+ return __awaiter(this, void 0, void 0, function* () {
2540
+ /** @type {?} */
2541
+ const sanitiser = this.parameterDef.getSanitiser(injector);
2542
+ if (sanitiser) {
2543
+ return sanitiser.sanitise(this.parameterDef, this.value, visit);
2544
+ }
2545
+ else {
2546
+ return this.value;
2547
+ }
2548
+ });
2549
+ }
2253
2550
  }
2254
2551
  ParameterSnapshot.ResolvedParameter = ResolvedParameter;
2255
2552
  if (false) {
@@ -2447,19 +2744,25 @@ class PlaceOutletComponent extends DisposableComponent {
2447
2744
  this._placeDefinition = new MutableValueModel();
2448
2745
  this._resolvedParameters = new MutableValueModel();
2449
2746
  const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
2450
- this._paramMap = chain(this._activatedRouteModel).pullObservableValue((/**
2747
+ /** @type {?} */
2748
+ const paramMap = chain(this._activatedRouteModel).pullObservableValue((/**
2451
2749
  * @param {?} ar
2452
2750
  * @return {?}
2453
2751
  */
2454
2752
  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
2753
+ /** @type {?} */
2754
+ const urls = chain(this._activatedRouteModel).pullObservableValue((/**
2755
+ * @param {?} ar
2756
+ * @return {?}
2757
+ */
2758
+ ar => ar.url));
2759
+ this.placeConfigured = valueOf.all(chain(this._inOutletUpdate).isFalsey(), this._placeDefinition, paramMap, urls).areTruthy();
2760
+ when.anyOf(paramMap, urls).changes((/**
2458
2761
  * @return {?}
2459
2762
  */
2460
- (params) => {
2763
+ () => {
2461
2764
  /** @type {?} */
2462
- const snapshot = ParameterSnapshot.create(this._placeDefinition.value, params);
2765
+ const snapshot = ParameterSnapshot.create(this._placeDefinition.value, paramMap.value, urls.value);
2463
2766
  this._incomingRouteChange.whileTrue((/**
2464
2767
  * @return {?}
2465
2768
  */
@@ -2481,6 +2784,10 @@ class PlaceOutletComponent extends DisposableComponent {
2481
2784
  }), {
2482
2785
  unless: this.incomingRouteChange
2483
2786
  });
2787
+ // const txo = new TransactionObserver().onEvent(e => console.log(e.toString()));
2788
+ // txo.observe('paramMap', paramMap);
2789
+ // txo.observe('urls', urls);
2790
+ // txo.observe('this._resolvedParameters', this._resolvedParameters);
2484
2791
  }
2485
2792
  /**
2486
2793
  * @return {?}
@@ -2614,11 +2921,6 @@ if (false) {
2614
2921
  * @private
2615
2922
  */
2616
2923
  PlaceOutletComponent.prototype._placeDefinition;
2617
- /**
2618
- * @type {?}
2619
- * @private
2620
- */
2621
- PlaceOutletComponent.prototype._paramMap;
2622
2924
  /** @type {?} */
2623
2925
  PlaceOutletComponent.prototype._resolvedParameters;
2624
2926
  /**
@@ -3154,12 +3456,12 @@ if (false) {
3154
3456
  /**
3155
3457
  * @return {?}
3156
3458
  */
3157
- Visit.prototype.getRouteId = function () { };
3459
+ Visit.prototype.getRouteIdValue = function () { };
3158
3460
  /**
3159
3461
  * @param {?} name
3160
3462
  * @return {?}
3161
3463
  */
3162
- Visit.prototype.getRouteParameter = function (name) { };
3464
+ Visit.prototype.getParameterValue = function (name) { };
3163
3465
  }
3164
3466
 
3165
3467
  /**
@@ -3252,14 +3554,14 @@ class PlaceRouteGuard {
3252
3554
  /** @type {?} */
3253
3555
  const placeDefinition = PlaceComponent.getDefinition(activatedRoute.component);
3254
3556
  /** @type {?} */
3255
- const snapshot = ParameterSnapshot.create(placeDefinition, activatedRoute.paramMap);
3557
+ const snapshot = ParameterSnapshot.create(placeDefinition, activatedRoute.paramMap, activatedRoute.url);
3256
3558
  return snapshot.sanitise(this.injector).then((/**
3257
3559
  * @param {?} sanitised
3258
3560
  * @return {?}
3259
3561
  */
3260
3562
  sanitised => {
3261
- if (sanitised.hasChanged(snapshot)) {
3262
- return this.placeRouter.createUrlTree(activatedRoute, snapshot, sanitised);
3563
+ if (sanitised.hasChanged(snapshot, true)) {
3564
+ return this.placeRouter.getRedirectUrlTree(activatedRoute, sanitised);
3263
3565
  }
3264
3566
  else {
3265
3567
  return true;
@@ -3295,69 +3597,6 @@ if (false) {
3295
3597
  PlaceRouteGuard.prototype.injector;
3296
3598
  }
3297
3599
 
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
3600
  /**
3362
3601
  * @fileoverview added by tsickle
3363
3602
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -3469,16 +3708,17 @@ function RouteParameterList(elementType, options) {
3469
3708
  */
3470
3709
  /**
3471
3710
  * @record
3472
- * @template T
3711
+ * @template S
3473
3712
  */
3474
3713
  function ParameterSanitiser() { }
3475
3714
  if (false) {
3476
3715
  /**
3716
+ * @param {?} parameterDef
3477
3717
  * @param {?} value
3478
3718
  * @param {?=} visit
3479
3719
  * @return {?}
3480
3720
  */
3481
- ParameterSanitiser.prototype.sanitise = function (value, visit) { };
3721
+ ParameterSanitiser.prototype.sanitise = function (parameterDef, value, visit) { };
3482
3722
  }
3483
3723
 
3484
3724
  /**
@@ -3608,7 +3848,7 @@ class Sanitiser {
3608
3848
  return __awaiter(this, void 0, void 0, function* () {
3609
3849
  if (this.sanitiser) {
3610
3850
  this.initialValue = this.readFrom(this.snapshot);
3611
- this._sanitisedValue = yield this.sanitiser.sanitise(this.initialValue);
3851
+ this._sanitisedValue = yield this.sanitiser.sanitise(null, this.initialValue);
3612
3852
  if (this.initialValue !== this._sanitisedValue) {
3613
3853
  return false;
3614
3854
  }
@@ -3706,6 +3946,7 @@ class RouteParameterSanitiser {
3706
3946
  assert.isTruthy(this.parameterSanitisers.length !== 0);
3707
3947
  return this.routeIdSanitiser && this.routeIdSanitiser.valueChanged;
3708
3948
  }
3949
+ // @Trace()
3709
3950
  /**
3710
3951
  * @return {?}
3711
3952
  */
@@ -3740,12 +3981,6 @@ __decorate([
3740
3981
  __metadata("design:paramtypes", [ParameterDefinition]),
3741
3982
  __metadata("design:returntype", Object)
3742
3983
  ], RouteParameterSanitiser.prototype, "getSanitiser", null);
3743
- __decorate([
3744
- Trace(),
3745
- __metadata("design:type", Function),
3746
- __metadata("design:paramtypes", []),
3747
- __metadata("design:returntype", Array)
3748
- ], RouteParameterSanitiser.prototype, "getRedirectParams", null);
3749
3984
  if (false) {
3750
3985
  /**
3751
3986
  * @type {?}
@@ -3857,5 +4092,5 @@ if (false) {
3857
4092
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3858
4093
  */
3859
4094
 
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 };
4095
+ 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
4096
  //# sourceMappingURL=coolon-angular-ui-powerups.js.map