@coolon/angular-ui-powerups 0.0.26 → 0.0.28
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 +3930 -0
- package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -0
- package/bundles/coolon-angular-ui-powerups.umd.min.js +2 -0
- package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -0
- package/coolon-angular-ui-powerups.d.ts +30 -0
- package/coolon-angular-ui-powerups.metadata.json +1 -0
- package/esm2015/coolon-angular-ui-powerups.js +33 -0
- package/esm2015/index.js +6 -0
- package/esm2015/lib/angular-ui-powerups.module.js +54 -0
- package/esm2015/lib/animations/index.js +9 -0
- package/esm2015/lib/animations/slideDownAndUpAnimation.js +30 -0
- package/esm2015/lib/components/disposable-component.js +14 -0
- package/esm2015/lib/components/forms/abstract-input.component.js +183 -0
- package/esm2015/lib/components/forms/number-input/number-input.component.js +26 -0
- package/esm2015/lib/components/forms/password-input/password-input.component.js +26 -0
- package/esm2015/lib/components/forms/select-input/select-input.component.js +60 -0
- package/esm2015/lib/components/forms/string-input/string-input.component.js +26 -0
- package/esm2015/lib/components/index.js +18 -0
- package/esm2015/lib/components/resize-aware.component.js +96 -0
- package/esm2015/lib/components/types/bounds.class.js +56 -0
- package/esm2015/lib/components/types/dimension.class.js +21 -0
- package/esm2015/lib/components/types/point.class.js +36 -0
- package/esm2015/lib/directives/command.directive.js +135 -0
- package/esm2015/lib/directives/focus-binding.directive.js +179 -0
- package/esm2015/lib/directives/index.js +10 -0
- package/esm2015/lib/interaction/abstract-activity.js +129 -0
- package/esm2015/lib/interaction/activity.js +27 -0
- package/esm2015/lib/interaction/alert.js +23 -0
- package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +144 -0
- package/esm2015/lib/interaction/components/activity-outlet/activity-outlet-context.js +22 -0
- package/esm2015/lib/interaction/components/activity-outlet/activity-outlet.component.js +169 -0
- package/esm2015/lib/interaction/components/alert-dialog/alert-dialog.component.js +37 -0
- package/esm2015/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.js +46 -0
- package/esm2015/lib/interaction/confirm.js +17 -0
- package/esm2015/lib/interaction/index.js +21 -0
- package/esm2015/lib/interaction/interaction-context.js +35 -0
- package/esm2015/lib/interaction/interaction.module.js +41 -0
- package/esm2015/lib/interaction/result.js +24 -0
- package/esm2015/lib/interaction/services/dialog-interaction.service.js +114 -0
- package/esm2015/lib/place/abstract-place-component.js +59 -0
- package/esm2015/lib/place/components/busy-overlay/busy-overlay.component.js +44 -0
- package/esm2015/lib/place/components/empty-state/empty-state.component.js +28 -0
- package/esm2015/lib/place/components/place-outlet/place-outlet.component.js +67 -0
- package/esm2015/lib/place/components/place-outlet/route-animations.js +35 -0
- package/esm2015/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.js +50 -0
- package/esm2015/lib/place/guards/leave-place.guard.js +52 -0
- package/esm2015/lib/place/guards/place-route.guard.js +74 -0
- package/esm2015/lib/place/index.js +27 -0
- package/esm2015/lib/place/place-component.js +17 -0
- package/esm2015/lib/place/place.decorator.js +72 -0
- package/esm2015/lib/place/place.module.js +49 -0
- package/esm2015/lib/place/place.service.js +61 -0
- package/esm2015/lib/place/route/json-types.js +13 -0
- package/esm2015/lib/place/route/parameter-decorators.js +182 -0
- package/esm2015/lib/place/route/parameter-definition.class.js +24 -0
- package/esm2015/lib/place/route/parameter-sanitiser.js +17 -0
- package/esm2015/lib/place/route/parameter-type.js +43 -0
- package/esm2015/lib/place/route/route-parameter-bindings.js +294 -0
- package/esm2015/lib/place/route/route-parameter-sanitiser.js +280 -0
- package/esm2015/public_api.js +11 -0
- package/esm5/coolon-angular-ui-powerups.js +33 -0
- package/esm5/index.js +6 -0
- package/esm5/lib/angular-ui-powerups.module.js +58 -0
- package/esm5/lib/animations/index.js +9 -0
- package/esm5/lib/animations/slideDownAndUpAnimation.js +30 -0
- package/esm5/lib/components/disposable-component.js +24 -0
- package/esm5/lib/components/forms/abstract-input.component.js +232 -0
- package/esm5/lib/components/forms/number-input/number-input.component.js +33 -0
- package/esm5/lib/components/forms/password-input/password-input.component.js +33 -0
- package/esm5/lib/components/forms/select-input/select-input.component.js +67 -0
- package/esm5/lib/components/forms/string-input/string-input.component.js +33 -0
- package/esm5/lib/components/index.js +18 -0
- package/esm5/lib/components/resize-aware.component.js +124 -0
- package/esm5/lib/components/types/bounds.class.js +59 -0
- package/esm5/lib/components/types/dimension.class.js +19 -0
- package/esm5/lib/components/types/point.class.js +43 -0
- package/esm5/lib/directives/command.directive.js +155 -0
- package/esm5/lib/directives/focus-binding.directive.js +231 -0
- package/esm5/lib/directives/index.js +10 -0
- package/esm5/lib/interaction/abstract-activity.js +173 -0
- package/esm5/lib/interaction/activity.js +27 -0
- package/esm5/lib/interaction/alert.js +23 -0
- package/esm5/lib/interaction/components/activity-container/activity-container.component.js +181 -0
- package/esm5/lib/interaction/components/activity-outlet/activity-outlet-context.js +22 -0
- package/esm5/lib/interaction/components/activity-outlet/activity-outlet.component.js +206 -0
- package/esm5/lib/interaction/components/alert-dialog/alert-dialog.component.js +42 -0
- package/esm5/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.js +54 -0
- package/esm5/lib/interaction/confirm.js +17 -0
- package/esm5/lib/interaction/index.js +21 -0
- package/esm5/lib/interaction/interaction-context.js +45 -0
- package/esm5/lib/interaction/interaction.module.js +45 -0
- package/esm5/lib/interaction/result.js +24 -0
- package/esm5/lib/interaction/services/dialog-interaction.service.js +140 -0
- package/esm5/lib/place/abstract-place-component.js +66 -0
- package/esm5/lib/place/components/busy-overlay/busy-overlay.component.js +49 -0
- package/esm5/lib/place/components/empty-state/empty-state.component.js +29 -0
- package/esm5/lib/place/components/place-outlet/place-outlet.component.js +81 -0
- package/esm5/lib/place/components/place-outlet/route-animations.js +35 -0
- package/esm5/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.js +57 -0
- package/esm5/lib/place/guards/leave-place.guard.js +57 -0
- package/esm5/lib/place/guards/place-route.guard.js +78 -0
- package/esm5/lib/place/index.js +27 -0
- package/esm5/lib/place/place-component.js +17 -0
- package/esm5/lib/place/place.decorator.js +69 -0
- package/esm5/lib/place/place.module.js +53 -0
- package/esm5/lib/place/place.service.js +75 -0
- package/esm5/lib/place/route/json-types.js +13 -0
- package/esm5/lib/place/route/parameter-decorators.js +182 -0
- package/esm5/lib/place/route/parameter-definition.class.js +24 -0
- package/esm5/lib/place/route/parameter-sanitiser.js +17 -0
- package/esm5/lib/place/route/parameter-type.js +65 -0
- package/esm5/lib/place/route/route-parameter-bindings.js +339 -0
- package/esm5/lib/place/route/route-parameter-sanitiser.js +395 -0
- package/esm5/public_api.js +11 -0
- package/fesm2015/coolon-angular-ui-powerups.js +3149 -0
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -0
- package/fesm5/coolon-angular-ui-powerups.js +3703 -0
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -0
- package/lib/angular-ui-powerups.module.d.ts +2 -0
- package/{src/lib/animations/index.ts → lib/animations/index.d.ts} +0 -1
- package/lib/animations/slideDownAndUpAnimation.d.ts +5 -0
- package/lib/components/disposable-component.d.ts +5 -0
- package/lib/components/forms/abstract-input.component.d.ts +35 -0
- package/lib/components/forms/number-input/number-input.component.d.ts +6 -0
- package/lib/components/forms/password-input/password-input.component.d.ts +6 -0
- package/lib/components/forms/select-input/select-input.component.d.ts +11 -0
- package/lib/components/forms/string-input/string-input.component.d.ts +6 -0
- package/{src/lib/components/index.ts → lib/components/index.d.ts} +0 -1
- package/lib/components/resize-aware.component.d.ts +22 -0
- package/lib/components/types/bounds.class.d.ts +16 -0
- package/lib/components/types/dimension.class.d.ts +5 -0
- package/lib/components/types/point.class.d.ts +10 -0
- package/lib/directives/command.directive.d.ts +14 -0
- package/lib/directives/focus-binding.directive.d.ts +22 -0
- package/{src/lib/directives/index.ts → lib/directives/index.d.ts} +0 -1
- package/lib/interaction/abstract-activity.d.ts +17 -0
- package/lib/interaction/activity.d.ts +11 -0
- package/lib/interaction/alert.d.ts +5 -0
- package/lib/interaction/components/activity-container/activity-container.component.d.ts +32 -0
- package/{src/lib/interaction/components/activity-outlet/activity-outlet-context.ts → lib/interaction/components/activity-outlet/activity-outlet-context.d.ts} +5 -7
- package/lib/interaction/components/activity-outlet/activity-outlet.component.d.ts +30 -0
- package/lib/interaction/components/alert-dialog/alert-dialog.component.d.ts +8 -0
- package/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.d.ts +9 -0
- package/{src/lib/interaction/confirm.ts → lib/interaction/confirm.d.ts} +2 -3
- package/{src/lib/interaction/index.ts → lib/interaction/index.d.ts} +0 -1
- package/lib/interaction/interaction-context.d.ts +11 -0
- package/lib/interaction/interaction.module.d.ts +2 -0
- package/lib/interaction/result.d.ts +8 -0
- package/lib/interaction/services/dialog-interaction.service.d.ts +14 -0
- package/lib/place/abstract-place-component.d.ts +13 -0
- package/lib/place/components/busy-overlay/busy-overlay.component.d.ts +8 -0
- package/lib/place/components/empty-state/empty-state.component.d.ts +5 -0
- package/lib/place/components/place-outlet/place-outlet.component.d.ts +13 -0
- package/lib/place/components/place-outlet/route-animations.d.ts +1 -0
- package/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.d.ts +11 -0
- package/lib/place/guards/leave-place.guard.d.ts +10 -0
- package/lib/place/guards/place-route.guard.d.ts +9 -0
- package/{src/lib/place/index.ts → lib/place/index.d.ts} +0 -1
- package/lib/place/place-component.d.ts +5 -0
- package/lib/place/place.decorator.d.ts +20 -0
- package/lib/place/place.module.d.ts +2 -0
- package/lib/place/place.service.d.ts +8 -0
- package/lib/place/route/json-types.d.ts +7 -0
- package/lib/place/route/parameter-decorators.d.ts +28 -0
- package/lib/place/route/parameter-definition.class.d.ts +11 -0
- package/{src/lib/place/route/parameter-sanitiser.ts → lib/place/route/parameter-sanitiser.d.ts} +1 -1
- package/lib/place/route/parameter-type.d.ts +16 -0
- package/lib/place/route/route-parameter-bindings.d.ts +18 -0
- package/lib/place/route/route-parameter-sanitiser.d.ts +42 -0
- package/package.json +14 -12
- package/schematics/ng-add/index.d.ts +2 -0
- package/schematics/ng-add/index.js +12 -0
- package/schematics/ng-add/index.js.map +1 -0
- package/schematics/place-routes/index.d.ts +3 -0
- package/schematics/place-routes/index.js +114 -0
- package/schematics/place-routes/index.js.map +1 -0
- package/schematics/place-routes/place-def.d.ts +37 -0
- package/schematics/place-routes/place-def.js +108 -0
- package/schematics/place-routes/place-def.js.map +1 -0
- package/schematics/place-routes/scanner.d.ts +38 -0
- package/schematics/place-routes/scanner.js +169 -0
- package/schematics/place-routes/scanner.js.map +1 -0
- package/schematics/place-routes/schema.d.ts +7 -0
- package/schematics/place-routes/schema.js +3 -0
- package/schematics/place-routes/schema.js.map +1 -0
- package/schematics/place-routes/templates/{services/place-router.service.ts.template → place-router.ts.template} +13 -18
- package/CHANGELOG.md +0 -7
- package/jest.config.js +0 -9
- package/ng-package.json +0 -13
- package/schematics/ng-add/index.ts +0 -10
- package/schematics/place-routes/index.ts +0 -152
- package/schematics/place-routes/place-def.ts +0 -93
- package/schematics/place-routes/scanner.ts +0 -145
- package/schematics/place-routes/schema.ts +0 -7
- package/src/lib/angular-ui-powerups.module.spec.ts +0 -14
- package/src/lib/angular-ui-powerups.module.ts +0 -49
- package/src/lib/animations/slideDownAndUpAnimation.ts +0 -39
- package/src/lib/components/disposable-component.ts +0 -9
- package/src/lib/components/forms/abstract-input.component.ts +0 -108
- package/src/lib/components/forms/number-input/number-input.component.html +0 -15
- package/src/lib/components/forms/number-input/number-input.component.scss +0 -3
- package/src/lib/components/forms/number-input/number-input.component.spec.ts +0 -25
- package/src/lib/components/forms/number-input/number-input.component.ts +0 -19
- package/src/lib/components/forms/password-input/password-input.component.html +0 -16
- package/src/lib/components/forms/password-input/password-input.component.scss +0 -3
- package/src/lib/components/forms/password-input/password-input.component.spec.ts +0 -25
- package/src/lib/components/forms/password-input/password-input.component.ts +0 -18
- package/src/lib/components/forms/scss/mixins.scss +0 -16
- package/src/lib/components/forms/select-input/select-input.component.html +0 -16
- package/src/lib/components/forms/select-input/select-input.component.scss +0 -7
- package/src/lib/components/forms/select-input/select-input.component.spec.ts +0 -25
- package/src/lib/components/forms/select-input/select-input.component.ts +0 -31
- package/src/lib/components/forms/string-input/string-input.component.html +0 -15
- package/src/lib/components/forms/string-input/string-input.component.scss +0 -3
- package/src/lib/components/forms/string-input/string-input.component.spec.ts +0 -25
- package/src/lib/components/forms/string-input/string-input.component.ts +0 -18
- package/src/lib/components/resize-aware.component.ts +0 -52
- package/src/lib/components/types/bounds.class.ts +0 -25
- package/src/lib/components/types/dimension.class.ts +0 -3
- package/src/lib/components/types/point.class.ts +0 -13
- package/src/lib/directives/command.directive.spec.ts +0 -73
- package/src/lib/directives/command.directive.ts +0 -81
- package/src/lib/directives/focus-binding.directive.spec.ts +0 -8
- package/src/lib/directives/focus-binding.directive.ts +0 -108
- package/src/lib/interaction/abstract-activity.ts +0 -57
- package/src/lib/interaction/activity.ts +0 -17
- package/src/lib/interaction/alert.ts +0 -6
- package/src/lib/interaction/components/activity-container/activity-container.component.html +0 -8
- package/src/lib/interaction/components/activity-container/activity-container.component.scss +0 -3
- package/src/lib/interaction/components/activity-container/activity-container.component.spec.ts +0 -25
- package/src/lib/interaction/components/activity-container/activity-container.component.ts +0 -93
- package/src/lib/interaction/components/activity-outlet/activity-outlet.component.scss +0 -3
- package/src/lib/interaction/components/activity-outlet/activity-outlet.component.spec.ts +0 -25
- package/src/lib/interaction/components/activity-outlet/activity-outlet.component.ts +0 -96
- package/src/lib/interaction/components/alert-dialog/alert-dialog.component.html +0 -7
- package/src/lib/interaction/components/alert-dialog/alert-dialog.component.scss +0 -7
- package/src/lib/interaction/components/alert-dialog/alert-dialog.component.spec.ts +0 -25
- package/src/lib/interaction/components/alert-dialog/alert-dialog.component.ts +0 -20
- package/src/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.html +0 -9
- package/src/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.scss +0 -8
- package/src/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.spec.ts +0 -25
- package/src/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.ts +0 -26
- package/src/lib/interaction/interaction-context.ts +0 -16
- package/src/lib/interaction/interaction.module.ts +0 -35
- package/src/lib/interaction/result.ts +0 -16
- package/src/lib/interaction/services/dialog-interaction.service.scss +0 -11
- package/src/lib/interaction/services/dialog-interaction.service.spec.ts +0 -12
- package/src/lib/interaction/services/dialog-interaction.service.ts +0 -63
- package/src/lib/place/abstract-place-component.ts +0 -33
- package/src/lib/place/components/busy-overlay/busy-overlay.component.html +0 -4
- package/src/lib/place/components/busy-overlay/busy-overlay.component.scss +0 -27
- package/src/lib/place/components/busy-overlay/busy-overlay.component.spec.ts +0 -25
- package/src/lib/place/components/busy-overlay/busy-overlay.component.ts +0 -23
- package/src/lib/place/components/empty-state/empty-state.component.scss +0 -15
- package/src/lib/place/components/empty-state/empty-state.component.spec.ts +0 -25
- package/src/lib/place/components/empty-state/empty-state.component.ts +0 -19
- package/src/lib/place/components/place-outlet/place-outlet.component.html +0 -7
- package/src/lib/place/components/place-outlet/place-outlet.component.scss +0 -12
- package/src/lib/place/components/place-outlet/place-outlet.component.spec.ts +0 -25
- package/src/lib/place/components/place-outlet/place-outlet.component.ts +0 -37
- package/src/lib/place/components/place-outlet/route-animations.ts +0 -30
- package/src/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.html +0 -7
- package/src/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.scss +0 -100
- package/src/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.spec.ts +0 -25
- package/src/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.ts +0 -30
- package/src/lib/place/guards/leave-place.guard.spec.ts +0 -15
- package/src/lib/place/guards/leave-place.guard.ts +0 -18
- package/src/lib/place/guards/place-route.guard.ts +0 -37
- package/src/lib/place/place-component.ts +0 -6
- package/src/lib/place/place.decorator.ts +0 -40
- package/src/lib/place/place.module.ts +0 -44
- package/src/lib/place/place.service.spec.ts +0 -12
- package/src/lib/place/place.service.ts +0 -29
- package/src/lib/place/route/json-types.ts +0 -5
- package/src/lib/place/route/parameter-decorators.ts +0 -99
- package/src/lib/place/route/parameter-definition.class.ts +0 -12
- package/src/lib/place/route/parameter-type.ts +0 -31
- package/src/lib/place/route/route-parameter-bindings.ts +0 -140
- package/src/lib/place/route/route-parameter-sanitiser.ts +0 -135
- package/src/test-setup.ts +0 -1
- package/tsconfig.json +0 -7
- package/tsconfig.lib.json +0 -20
- package/tsconfig.schematics.json +0 -35
- package/tsconfig.spec.json +0 -10
- package/tslint.json +0 -7
- /package/{src/index.ts → index.d.ts} +0 -0
- /package/{src/public_api.ts → public_api.d.ts} +0 -0
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export interface ParameterType<T> {
|
|
2
|
-
format(value: T): string;
|
|
3
|
-
|
|
4
|
-
parse(value: string): T;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export namespace ParameterType {
|
|
8
|
-
|
|
9
|
-
class StringType implements ParameterType<string> {
|
|
10
|
-
format(value: string): string {
|
|
11
|
-
return value;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
parse(value: string): string {
|
|
15
|
-
return value;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
class NumberType implements ParameterType<number> {
|
|
20
|
-
format(value: number): string {
|
|
21
|
-
return `${value}`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
parse(value: string): number {
|
|
25
|
-
return +value;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const STRING = new StringType();
|
|
30
|
-
export const NUMBER = new NumberType();
|
|
31
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { ActivatedRoute, Router } from '@angular/router';
|
|
2
|
-
import {
|
|
3
|
-
Binding,
|
|
4
|
-
Dsl,
|
|
5
|
-
GarbageCollector, IMutableHasValue,
|
|
6
|
-
MutableValueModel,
|
|
7
|
-
Trace,
|
|
8
|
-
TransactionObserver
|
|
9
|
-
} from '@coolon/pectin';
|
|
10
|
-
import { Klass } from '@coolon/typescript-utilities';
|
|
11
|
-
import { ParameterDefinition } from './parameter-definition.class';
|
|
12
|
-
|
|
13
|
-
interface ResolvedParameter<T> {
|
|
14
|
-
parameterDef: ParameterDefinition<T>;
|
|
15
|
-
resolvedValue: T;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
class ResolvedParameters {
|
|
19
|
-
constructor(readonly parameters: ResolvedParameter<any>[]) {
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
get<T>(parameter: ParameterDefinition<T>): T {
|
|
23
|
-
const resolved = this.parameters.find(p => p.parameterDef === parameter);
|
|
24
|
-
return resolved ? resolved.resolvedValue : null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
replace<T>(parameter: ParameterDefinition<T>, value: T): ResolvedParameters {
|
|
28
|
-
return new ResolvedParameters(this.parameters.filter(p => p.parameterDef !== parameter).concat({
|
|
29
|
-
parameterDef: parameter,
|
|
30
|
-
resolvedValue: value
|
|
31
|
-
}));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@Trace()
|
|
35
|
-
protected getFormattedRouteId() {
|
|
36
|
-
const routeIdParam = this.getRouteIdParam();
|
|
37
|
-
return routeIdParam ? routeIdParam.parameterDef.type.format(routeIdParam.resolvedValue) : null;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
private getRouteIdParam() {
|
|
41
|
-
return this.parameters.find(p => p.parameterDef.isRouteId);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@Trace()
|
|
45
|
-
protected getFormattedParameters() {
|
|
46
|
-
const params = {};
|
|
47
|
-
const routeIdParam = this.parameters.filter(p => !p.parameterDef.isRouteId).forEach(p => {
|
|
48
|
-
params[p.parameterDef.name] = p.parameterDef.type.format(p.resolvedValue);
|
|
49
|
-
});
|
|
50
|
-
return params;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
hasRouteId() {
|
|
54
|
-
return !!this.getRouteIdParam();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
@Trace()
|
|
58
|
-
redirect(previous: ResolvedParameters, router: Router, activatedRoute: ActivatedRoute) {
|
|
59
|
-
const routeId = this.getFormattedRouteId();
|
|
60
|
-
const relativePath = !!previous.hasRouteId() ? '..' : '.';
|
|
61
|
-
const path = routeId ? [relativePath, routeId, this.getFormattedParameters()] : [relativePath, this.getFormattedParameters()];
|
|
62
|
-
router.navigate(path, {
|
|
63
|
-
relativeTo: activatedRoute
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export class RouteParameterBindings extends GarbageCollector {
|
|
69
|
-
|
|
70
|
-
public readonly _incomingRouteChange = new MutableValueModel<boolean>(false);
|
|
71
|
-
|
|
72
|
-
private txo: TransactionObserver;
|
|
73
|
-
|
|
74
|
-
private readonly resolvedParameters = new MutableValueModel<ResolvedParameters>();
|
|
75
|
-
|
|
76
|
-
constructor(private readonly component: any, private readonly router: Router, private readonly activatedRoute: ActivatedRoute) {
|
|
77
|
-
super();
|
|
78
|
-
const { chain, valueOf, before, when, after, observe } = Dsl.disposeWith(this);
|
|
79
|
-
this.txo = new TransactionObserver();//.onEvent(e => console.log(e.toString()));
|
|
80
|
-
|
|
81
|
-
const routeParameterDefs: ParameterDefinition<any>[] = Klass.get(component).getMetadataList(RouteParameterBindings.ROUTE_PARAMETER_LIST_KEY);
|
|
82
|
-
routeParameterDefs.forEach(parameter => this.installBinding(parameter));
|
|
83
|
-
|
|
84
|
-
const incomingResolvedRouteParameters = observe.valuesFrom(activatedRoute.paramMap)
|
|
85
|
-
.last()
|
|
86
|
-
.map(params => {
|
|
87
|
-
const result: ResolvedParameter<any>[] = [];
|
|
88
|
-
routeParameterDefs.forEach(parameterDef => {
|
|
89
|
-
let resolvedValue;
|
|
90
|
-
if (parameterDef.isArray) {
|
|
91
|
-
resolvedValue = params.getAll(parameterDef.name).map(v => parameterDef.type.parse(v));
|
|
92
|
-
} else {
|
|
93
|
-
resolvedValue = parameterDef.type.parse(params.get(parameterDef.name));
|
|
94
|
-
}
|
|
95
|
-
result.push({ parameterDef: parameterDef, resolvedValue: resolvedValue });
|
|
96
|
-
|
|
97
|
-
});
|
|
98
|
-
return new ResolvedParameters(result);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
incomingResolvedRouteParameters.subscribe(resolvedParameters => {
|
|
102
|
-
this._incomingRouteChange.value = true;
|
|
103
|
-
this.resolvedParameters.value = resolvedParameters;
|
|
104
|
-
this._incomingRouteChange.value = false;
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
when.valueOf(this.resolvedParameters).changes((params, previous) => {
|
|
108
|
-
params.redirect(previous, router, activatedRoute);
|
|
109
|
-
}, { unless: this.incomingRouteChange });
|
|
110
|
-
|
|
111
|
-
this.txo.observe('incomingResolvedRouteParameters', incomingResolvedRouteParameters);
|
|
112
|
-
this.txo.observe('this.routeIsChanging', this.incomingRouteChange);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
get incomingRouteChange() {
|
|
116
|
-
return this._incomingRouteChange.readonly;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
protected installBinding<T>(parameter: ParameterDefinition<T>) {
|
|
120
|
-
const model = this.getModelFor(parameter);
|
|
121
|
-
// this.txo.observe(parameter.propertyName, model);
|
|
122
|
-
this.registerDisposable(new Binding(this.resolvedParameters, model, {
|
|
123
|
-
toRight(parameters: ResolvedParameters): T {
|
|
124
|
-
return parameters.get(parameter);
|
|
125
|
-
},
|
|
126
|
-
toLeft(value: T, currentParameters?: ResolvedParameters): ResolvedParameters {
|
|
127
|
-
return currentParameters.replace(parameter, value);
|
|
128
|
-
}
|
|
129
|
-
}));
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
private getModelFor<T>(parameter: ParameterDefinition<T>): IMutableHasValue<T> {
|
|
134
|
-
return this.component[parameter.propertyName];
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export namespace RouteParameterBindings {
|
|
139
|
-
export const ROUTE_PARAMETER_LIST_KEY = Symbol('place:route:parameters');
|
|
140
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { Injector } from '@angular/core';
|
|
2
|
-
import { ActivatedRouteSnapshot, Router } from '@angular/router';
|
|
3
|
-
import { assert } from '@coolon/pectin';
|
|
4
|
-
import { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';
|
|
5
|
-
import { ParameterDefinition } from './parameter-definition.class';
|
|
6
|
-
import { ParameterSanitiser } from './parameter-sanitiser';
|
|
7
|
-
import * as _ from 'lodash';
|
|
8
|
-
|
|
9
|
-
export abstract class Sanitiser<T, S> {
|
|
10
|
-
|
|
11
|
-
private initialValue: S;
|
|
12
|
-
private _sanitisedValue: S;
|
|
13
|
-
|
|
14
|
-
constructor(readonly parameterDef: ParameterDefinition<T>, readonly snapshot:ActivatedRouteSnapshot, readonly sanitiser: ParameterSanitiser<S>) {
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
isRouteId(): boolean {
|
|
18
|
-
return this.parameterDef.isRouteId;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
get valueChanged():boolean {
|
|
22
|
-
return !_.isNil(this.initialValue) && this.hasChanged(this.initialValue, this.sanitisedValue);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
get sanitisedValue():S {
|
|
26
|
-
return this._sanitisedValue;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
protected abstract readFrom(snapshot: ActivatedRouteSnapshot): S;
|
|
30
|
-
protected abstract hasChanged(initialValue:S, sanitisedValue:S): boolean;
|
|
31
|
-
|
|
32
|
-
abstract injectRouteParam(dest: {});
|
|
33
|
-
|
|
34
|
-
async sanitize(): Promise<boolean> {
|
|
35
|
-
if (this.sanitiser) {
|
|
36
|
-
this.initialValue = this.readFrom(this.snapshot);
|
|
37
|
-
this._sanitisedValue = await this.sanitiser.sanitise(this.initialValue);
|
|
38
|
-
if (this.initialValue !== this._sanitisedValue) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
export class RouteParameterSanitiser {
|
|
48
|
-
|
|
49
|
-
private readonly routeIdSanitiser: Sanitiser<any, any>;
|
|
50
|
-
private readonly parameterSanitisers: Sanitiser<any, any>[] = [];
|
|
51
|
-
|
|
52
|
-
constructor(readonly parameterDefs: ParameterDefinition<any>[], readonly snapshot: ActivatedRouteSnapshot, readonly injector: Injector) {
|
|
53
|
-
const sanitisers = parameterDefs.map(def => {
|
|
54
|
-
return def.isArray ?
|
|
55
|
-
new Sanitiser.Array(def, snapshot, this.getSanitiser(def)) :
|
|
56
|
-
new Sanitiser.Value(def, snapshot, this.getSanitiser(def));
|
|
57
|
-
});
|
|
58
|
-
this.routeIdSanitiser = sanitisers.find(p => p.isRouteId());
|
|
59
|
-
this.parameterSanitisers = sanitisers.filter(p => !p.isRouteId());
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async sanitise(): Promise<boolean> {
|
|
63
|
-
if (this.routeIdSanitiser) {
|
|
64
|
-
await this.routeIdSanitiser.sanitize();
|
|
65
|
-
if (this.routeIdSanitiser.valueChanged) {
|
|
66
|
-
// if the route id isn't ok we redirect immediately as the query params may need to be sanitised in the
|
|
67
|
-
// context of the route id.
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
for (const sanitiser of this.parameterSanitisers) {
|
|
72
|
-
await sanitiser.sanitize();
|
|
73
|
-
}
|
|
74
|
-
return !this.parameterSanitisers.find(s => s.valueChanged);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
redirect(router: Router) {
|
|
78
|
-
assert.isTruthy(this.parameterSanitisers.length !== 0);
|
|
79
|
-
if (this.routeIdSanitiser.valueChanged) {
|
|
80
|
-
return router.navigate(['..', this.routeIdSanitiser.sanitisedValue]);
|
|
81
|
-
} else {
|
|
82
|
-
const routeParams = {};
|
|
83
|
-
this.parameterSanitisers.forEach(s => s.injectRouteParam(routeParams));
|
|
84
|
-
return router.navigate(['.', routeParams]);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
@Memoize()
|
|
89
|
-
private getSanitiser<T, S>(def: ParameterDefinition<T, S>): ParameterSanitiser<S> {
|
|
90
|
-
return def.sanitiser ? this.injector.get<ParameterSanitiser<S>>(def.sanitiser, new def.sanitiser()) : null;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export namespace Sanitiser {
|
|
95
|
-
|
|
96
|
-
export class Value<T> extends Sanitiser<T, T> {
|
|
97
|
-
|
|
98
|
-
readFrom(snapshot: ActivatedRouteSnapshot): T {
|
|
99
|
-
const rawValue = this.parameterDef.isRouteId ?
|
|
100
|
-
snapshot.paramMap.get(this.parameterDef.name) :
|
|
101
|
-
snapshot.queryParamMap.get(this.parameterDef.name);
|
|
102
|
-
|
|
103
|
-
return this.parameterDef.type.parse(rawValue);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
protected hasChanged(initialValue: T, sanitisedValue: T): boolean {
|
|
107
|
-
return initialValue !== sanitisedValue;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
injectRouteParam(dest: {}) {
|
|
111
|
-
dest[this.parameterDef.name] = this.parameterDef.type.format(this.sanitisedValue);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export class Array<T> extends Sanitiser<T, T[]> {
|
|
117
|
-
|
|
118
|
-
readFrom(snapshot: ActivatedRouteSnapshot): T[] {
|
|
119
|
-
const rawValues = snapshot.queryParamMap.getAll(this.parameterDef.name);
|
|
120
|
-
return rawValues.map(value => this.parameterDef.type.parse(value));
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
protected hasChanged(initialValue: T[], sanitisedValue: T[]): boolean {
|
|
124
|
-
return initialValue !== sanitisedValue;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
injectRouteParam(dest: {}) {
|
|
129
|
-
dest[this.parameterDef.name] = this.sanitisedValue.map(v => this.parameterDef.type.format(v));
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
}
|
package/src/test-setup.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import 'jest-preset-angular';
|
package/tsconfig.json
DELETED
package/tsconfig.lib.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../dist/out-tsc",
|
|
5
|
-
"target": "es2015",
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"inlineSources": true,
|
|
8
|
-
"types": [],
|
|
9
|
-
"lib": ["dom", "es2018"]
|
|
10
|
-
},
|
|
11
|
-
"angularCompilerOptions": {
|
|
12
|
-
"annotateForClosureCompiler": true,
|
|
13
|
-
"skipTemplateCodegen": true,
|
|
14
|
-
"strictMetadataEmit": true,
|
|
15
|
-
"fullTemplateTypeCheck": true,
|
|
16
|
-
"strictInjectionParameters": true,
|
|
17
|
-
"enableResourceInlining": true
|
|
18
|
-
},
|
|
19
|
-
"exclude": ["src/test.ts", "**/*.spec.ts"]
|
|
20
|
-
}
|
package/tsconfig.schematics.json
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"baseUrl": ".",
|
|
4
|
-
"lib": [
|
|
5
|
-
"es2018",
|
|
6
|
-
"dom"
|
|
7
|
-
],
|
|
8
|
-
"declaration": true,
|
|
9
|
-
"module": "commonjs",
|
|
10
|
-
"moduleResolution": "node",
|
|
11
|
-
"noEmitOnError": true,
|
|
12
|
-
"noFallthroughCasesInSwitch": true,
|
|
13
|
-
"noImplicitAny": true,
|
|
14
|
-
"noImplicitThis": true,
|
|
15
|
-
"noUnusedParameters": false,
|
|
16
|
-
"noUnusedLocals": false,
|
|
17
|
-
"rootDir": "schematics",
|
|
18
|
-
"outDir": "../../dist/libs/angular-ui-powerups/schematics",
|
|
19
|
-
"skipDefaultLibCheck": true,
|
|
20
|
-
"skipLibCheck": true,
|
|
21
|
-
"sourceMap": true,
|
|
22
|
-
"strictNullChecks": false,
|
|
23
|
-
"experimentalDecorators": true,
|
|
24
|
-
"target": "es6",
|
|
25
|
-
"types": [
|
|
26
|
-
"node"
|
|
27
|
-
]
|
|
28
|
-
},
|
|
29
|
-
"include": [
|
|
30
|
-
"schematics/**/*"
|
|
31
|
-
],
|
|
32
|
-
"exclude": [
|
|
33
|
-
"schematics/*/templates/**/*"
|
|
34
|
-
]
|
|
35
|
-
}
|
package/tsconfig.spec.json
DELETED
package/tslint.json
DELETED
|
File without changes
|
|
File without changes
|