@coolon/angular-ui-powerups 12.4.0-alpha.87 → 12.4.0-alpha.89
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.
- package/bundles/coolon-angular-ui-powerups.umd.js +48 -17
- package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
- package/coolon-angular-ui-powerups.metadata.json +1 -1
- package/esm2015/lib/place/route/parameter-decorators.js.map +1 -1
- package/esm2015/lib/place/route/parameter-decorators.metadata.json +1 -1
- package/esm2015/lib/place/route/parameter-definition.js +36 -13
- package/esm2015/lib/place/route/parameter-definition.js.map +1 -1
- package/esm2015/lib/place/route/parameter-definition.metadata.json +1 -1
- package/esm2015/lib/place/route/parameter-sanitiser.js.map +1 -1
- package/esm2015/lib/place/visit.js +3 -3
- package/esm2015/lib/place/visit.js.map +1 -1
- package/fesm2015/coolon-angular-ui-powerups.js +39 -16
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/place/route/parameter-decorators.d.ts +5 -0
- package/lib/place/route/parameter-definition.d.ts +6 -1
- package/lib/place/route/parameter-sanitiser.d.ts +2 -3
- package/lib/place/visit.d.ts +2 -2
- package/package.json +1 -1
|
@@ -7488,7 +7488,7 @@
|
|
|
7488
7488
|
},] }
|
|
7489
7489
|
];
|
|
7490
7490
|
|
|
7491
|
-
var PARAMETER_DEFINITION_KEY = Symbol(
|
|
7491
|
+
var PARAMETER_DEFINITION_KEY = Symbol('parameterDefinition');
|
|
7492
7492
|
exports.ParameterDefinition = /** @class */ (function () {
|
|
7493
7493
|
function ParameterDefinition(propertyName, options, urlFormat) {
|
|
7494
7494
|
this.propertyName = propertyName;
|
|
@@ -7523,23 +7523,54 @@
|
|
|
7523
7523
|
// @Trace()
|
|
7524
7524
|
ParameterDefinition.prototype.sanitise = function (value, visit, placeHistory, injector, isPopState) {
|
|
7525
7525
|
return __awaiter(this, void 0, void 0, function () {
|
|
7526
|
-
var returningFromSomewhereElse, lastKnownVisit;
|
|
7527
7526
|
return __generator(this, function (_a) {
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7527
|
+
switch (_a.label) {
|
|
7528
|
+
case 0: return [4 /*yield*/, this.sanitiseMissing(visit, placeHistory, value)];
|
|
7529
|
+
case 1:
|
|
7530
|
+
// console.log(`sanitise(${this.propertyName})`)
|
|
7531
|
+
value = _a.sent();
|
|
7532
|
+
return [4 /*yield*/, this.runCustomSanitiser(value, visit, placeHistory, injector, isPopState)];
|
|
7533
|
+
case 2:
|
|
7534
|
+
value = _a.sent();
|
|
7535
|
+
return [2 /*return*/, value];
|
|
7537
7536
|
}
|
|
7538
|
-
// todo: add custom sanitiser
|
|
7539
|
-
return [2 /*return*/, value];
|
|
7540
7537
|
});
|
|
7541
7538
|
});
|
|
7542
7539
|
};
|
|
7540
|
+
ParameterDefinition.prototype.runCustomSanitiser = function (value, visit, placeHistory, injector, isPopState) {
|
|
7541
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7542
|
+
var customSanitiser;
|
|
7543
|
+
return __generator(this, function (_a) {
|
|
7544
|
+
customSanitiser = this.prepareCustomSanitiser(injector);
|
|
7545
|
+
return [2 /*return*/, customSanitiser ? customSanitiser.sanitise(value, visit, injector) : value];
|
|
7546
|
+
});
|
|
7547
|
+
});
|
|
7548
|
+
};
|
|
7549
|
+
ParameterDefinition.prototype.sanitiseMissing = function (visit, placeHistory, value) {
|
|
7550
|
+
if (this.isMissingFrom(visit)) {
|
|
7551
|
+
var returningFromSomewhereElse = !placeHistory.lastVisitIncluded(visit.placeDefinition);
|
|
7552
|
+
if (returningFromSomewhereElse) {
|
|
7553
|
+
var lastKnownVisit = placeHistory.getMostRecentVisitFor(visit.placeDefinition);
|
|
7554
|
+
if (this.remember && lastKnownVisit) {
|
|
7555
|
+
value = lastKnownVisit.getParameterValue(this);
|
|
7556
|
+
}
|
|
7557
|
+
value = this.isEmptyValue(value) ? this.defaultValue : value;
|
|
7558
|
+
}
|
|
7559
|
+
}
|
|
7560
|
+
return value;
|
|
7561
|
+
};
|
|
7562
|
+
ParameterDefinition.prototype.prepareCustomSanitiser = function (injector) {
|
|
7563
|
+
var customSanitiser = this.options.getOptional('sanitiser', null);
|
|
7564
|
+
if (___default["default"].isFunction(customSanitiser)) {
|
|
7565
|
+
return injector.get(customSanitiser);
|
|
7566
|
+
}
|
|
7567
|
+
if (___default["default"].isObject(customSanitiser)) {
|
|
7568
|
+
return ___default["default"].isFunction(customSanitiser['sanitise']) ?
|
|
7569
|
+
customSanitiser :
|
|
7570
|
+
typescriptUtilities.lang.illegalState("expected @VisitParameter({sanitiser: ...}) for " + this.propertyName + " to be a constructor or instance of ParameterSanitiser, got: " + customSanitiser);
|
|
7571
|
+
}
|
|
7572
|
+
return undefined;
|
|
7573
|
+
};
|
|
7543
7574
|
ParameterDefinition.prototype.isMissingFrom = function (visit) {
|
|
7544
7575
|
return !visit.hasParameter(this);
|
|
7545
7576
|
};
|
|
@@ -7603,7 +7634,7 @@
|
|
|
7603
7634
|
function get(model) {
|
|
7604
7635
|
var parameterDefinition = model[PARAMETER_DEFINITION_KEY];
|
|
7605
7636
|
if (!parameterDefinition) {
|
|
7606
|
-
typescriptUtilities.lang.illegalArgument(
|
|
7637
|
+
typescriptUtilities.lang.illegalArgument('model hasn\'t been annotated with @VisitParameter, @VisitParameterList or @RouteId');
|
|
7607
7638
|
}
|
|
7608
7639
|
return parameterDefinition;
|
|
7609
7640
|
}
|
|
@@ -9073,10 +9104,10 @@
|
|
|
9073
9104
|
* Returns the value of the place parameter with the specified name. The parameter
|
|
9074
9105
|
* name is taken from the `as` option, e.g. {as: 'aCustomName'} otherwise it is the
|
|
9075
9106
|
* same as the the ValueModel property name.
|
|
9076
|
-
* @param
|
|
9107
|
+
* @param parameter the visit parameter definition
|
|
9077
9108
|
*/
|
|
9078
|
-
Visit.prototype.getParameterValue = function (
|
|
9079
|
-
return this.visitParameters[
|
|
9109
|
+
Visit.prototype.getParameterValue = function (parameter) {
|
|
9110
|
+
return ___namespace.isString(parameter) ? this.visitParameters[parameter] : this.visitParameters[parameter.name];
|
|
9080
9111
|
};
|
|
9081
9112
|
// @Trace()
|
|
9082
9113
|
Visit.prototype.hasParameter = function (parameterDef) {
|