@coolon/angular-ui-powerups 0.0.25 → 0.0.27

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 (286) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +3926 -0
  2. package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -0
  3. package/bundles/coolon-angular-ui-powerups.umd.min.js +2 -0
  4. package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -0
  5. package/coolon-angular-ui-powerups.d.ts +30 -0
  6. package/coolon-angular-ui-powerups.metadata.json +1 -0
  7. package/esm2015/coolon-angular-ui-powerups.js +33 -0
  8. package/esm2015/index.js +6 -0
  9. package/esm2015/lib/angular-ui-powerups.module.js +54 -0
  10. package/esm2015/lib/animations/index.js +9 -0
  11. package/esm2015/lib/animations/slideDownAndUpAnimation.js +30 -0
  12. package/esm2015/lib/components/disposable-component.js +14 -0
  13. package/esm2015/lib/components/forms/abstract-input.component.js +183 -0
  14. package/esm2015/lib/components/forms/number-input/number-input.component.js +26 -0
  15. package/esm2015/lib/components/forms/password-input/password-input.component.js +26 -0
  16. package/esm2015/lib/components/forms/select-input/select-input.component.js +60 -0
  17. package/esm2015/lib/components/forms/string-input/string-input.component.js +26 -0
  18. package/esm2015/lib/components/index.js +18 -0
  19. package/esm2015/lib/components/resize-aware.component.js +96 -0
  20. package/esm2015/lib/components/types/bounds.class.js +56 -0
  21. package/esm2015/lib/components/types/dimension.class.js +21 -0
  22. package/esm2015/lib/components/types/point.class.js +36 -0
  23. package/esm2015/lib/directives/command.directive.js +135 -0
  24. package/esm2015/lib/directives/focus-binding.directive.js +179 -0
  25. package/esm2015/lib/directives/index.js +10 -0
  26. package/esm2015/lib/interaction/abstract-activity.js +129 -0
  27. package/esm2015/lib/interaction/activity.js +27 -0
  28. package/esm2015/lib/interaction/alert.js +23 -0
  29. package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +144 -0
  30. package/esm2015/lib/interaction/components/activity-outlet/activity-outlet-context.js +22 -0
  31. package/esm2015/lib/interaction/components/activity-outlet/activity-outlet.component.js +169 -0
  32. package/esm2015/lib/interaction/components/alert-dialog/alert-dialog.component.js +37 -0
  33. package/esm2015/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.js +46 -0
  34. package/esm2015/lib/interaction/confirm.js +17 -0
  35. package/esm2015/lib/interaction/index.js +21 -0
  36. package/esm2015/lib/interaction/interaction-context.js +35 -0
  37. package/esm2015/lib/interaction/interaction.module.js +41 -0
  38. package/esm2015/lib/interaction/result.js +24 -0
  39. package/esm2015/lib/interaction/services/dialog-interaction.service.js +114 -0
  40. package/esm2015/lib/place/abstract-place-component.js +59 -0
  41. package/esm2015/lib/place/components/busy-overlay/busy-overlay.component.js +44 -0
  42. package/esm2015/lib/place/components/empty-state/empty-state.component.js +28 -0
  43. package/esm2015/lib/place/components/place-outlet/place-outlet.component.js +67 -0
  44. package/esm2015/lib/place/components/place-outlet/route-animations.js +35 -0
  45. package/esm2015/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.js +50 -0
  46. package/esm2015/lib/place/guards/leave-place.guard.js +52 -0
  47. package/esm2015/lib/place/guards/place-route.guard.js +74 -0
  48. package/esm2015/lib/place/index.js +27 -0
  49. package/esm2015/lib/place/place-component.js +17 -0
  50. package/esm2015/lib/place/place.decorator.js +72 -0
  51. package/esm2015/lib/place/place.module.js +49 -0
  52. package/esm2015/lib/place/place.service.js +61 -0
  53. package/esm2015/lib/place/route/json-types.js +13 -0
  54. package/esm2015/lib/place/route/parameter-decorators.js +178 -0
  55. package/esm2015/lib/place/route/parameter-definition.class.js +24 -0
  56. package/esm2015/lib/place/route/parameter-sanitiser.js +17 -0
  57. package/esm2015/lib/place/route/parameter-type.js +43 -0
  58. package/esm2015/lib/place/route/route-parameter-bindings.js +294 -0
  59. package/esm2015/lib/place/route/route-parameter-sanitiser.js +280 -0
  60. package/esm2015/public_api.js +11 -0
  61. package/esm5/coolon-angular-ui-powerups.js +33 -0
  62. package/esm5/index.js +6 -0
  63. package/esm5/lib/angular-ui-powerups.module.js +58 -0
  64. package/esm5/lib/animations/index.js +9 -0
  65. package/esm5/lib/animations/slideDownAndUpAnimation.js +30 -0
  66. package/esm5/lib/components/disposable-component.js +24 -0
  67. package/esm5/lib/components/forms/abstract-input.component.js +232 -0
  68. package/esm5/lib/components/forms/number-input/number-input.component.js +33 -0
  69. package/esm5/lib/components/forms/password-input/password-input.component.js +33 -0
  70. package/esm5/lib/components/forms/select-input/select-input.component.js +67 -0
  71. package/esm5/lib/components/forms/string-input/string-input.component.js +33 -0
  72. package/esm5/lib/components/index.js +18 -0
  73. package/esm5/lib/components/resize-aware.component.js +124 -0
  74. package/esm5/lib/components/types/bounds.class.js +59 -0
  75. package/esm5/lib/components/types/dimension.class.js +19 -0
  76. package/esm5/lib/components/types/point.class.js +43 -0
  77. package/esm5/lib/directives/command.directive.js +155 -0
  78. package/esm5/lib/directives/focus-binding.directive.js +231 -0
  79. package/esm5/lib/directives/index.js +10 -0
  80. package/esm5/lib/interaction/abstract-activity.js +173 -0
  81. package/esm5/lib/interaction/activity.js +27 -0
  82. package/esm5/lib/interaction/alert.js +23 -0
  83. package/esm5/lib/interaction/components/activity-container/activity-container.component.js +181 -0
  84. package/esm5/lib/interaction/components/activity-outlet/activity-outlet-context.js +22 -0
  85. package/esm5/lib/interaction/components/activity-outlet/activity-outlet.component.js +206 -0
  86. package/esm5/lib/interaction/components/alert-dialog/alert-dialog.component.js +42 -0
  87. package/esm5/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.js +54 -0
  88. package/esm5/lib/interaction/confirm.js +17 -0
  89. package/esm5/lib/interaction/index.js +21 -0
  90. package/esm5/lib/interaction/interaction-context.js +45 -0
  91. package/esm5/lib/interaction/interaction.module.js +45 -0
  92. package/esm5/lib/interaction/result.js +24 -0
  93. package/esm5/lib/interaction/services/dialog-interaction.service.js +140 -0
  94. package/esm5/lib/place/abstract-place-component.js +66 -0
  95. package/esm5/lib/place/components/busy-overlay/busy-overlay.component.js +49 -0
  96. package/esm5/lib/place/components/empty-state/empty-state.component.js +29 -0
  97. package/esm5/lib/place/components/place-outlet/place-outlet.component.js +81 -0
  98. package/esm5/lib/place/components/place-outlet/route-animations.js +35 -0
  99. package/esm5/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.js +57 -0
  100. package/esm5/lib/place/guards/leave-place.guard.js +57 -0
  101. package/esm5/lib/place/guards/place-route.guard.js +78 -0
  102. package/esm5/lib/place/index.js +27 -0
  103. package/esm5/lib/place/place-component.js +17 -0
  104. package/esm5/lib/place/place.decorator.js +69 -0
  105. package/esm5/lib/place/place.module.js +53 -0
  106. package/esm5/lib/place/place.service.js +75 -0
  107. package/esm5/lib/place/route/json-types.js +13 -0
  108. package/esm5/lib/place/route/parameter-decorators.js +178 -0
  109. package/esm5/lib/place/route/parameter-definition.class.js +24 -0
  110. package/esm5/lib/place/route/parameter-sanitiser.js +17 -0
  111. package/esm5/lib/place/route/parameter-type.js +65 -0
  112. package/esm5/lib/place/route/route-parameter-bindings.js +339 -0
  113. package/esm5/lib/place/route/route-parameter-sanitiser.js +395 -0
  114. package/esm5/public_api.js +11 -0
  115. package/fesm2015/coolon-angular-ui-powerups.js +3145 -0
  116. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -0
  117. package/fesm5/coolon-angular-ui-powerups.js +3699 -0
  118. package/fesm5/coolon-angular-ui-powerups.js.map +1 -0
  119. package/lib/angular-ui-powerups.module.d.ts +2 -0
  120. package/{src/lib/animations/index.ts → lib/animations/index.d.ts} +0 -1
  121. package/lib/animations/slideDownAndUpAnimation.d.ts +5 -0
  122. package/lib/components/disposable-component.d.ts +5 -0
  123. package/lib/components/forms/abstract-input.component.d.ts +35 -0
  124. package/lib/components/forms/number-input/number-input.component.d.ts +6 -0
  125. package/lib/components/forms/password-input/password-input.component.d.ts +6 -0
  126. package/lib/components/forms/select-input/select-input.component.d.ts +11 -0
  127. package/lib/components/forms/string-input/string-input.component.d.ts +6 -0
  128. package/{src/lib/components/index.ts → lib/components/index.d.ts} +0 -1
  129. package/lib/components/resize-aware.component.d.ts +22 -0
  130. package/lib/components/types/bounds.class.d.ts +16 -0
  131. package/lib/components/types/dimension.class.d.ts +5 -0
  132. package/lib/components/types/point.class.d.ts +10 -0
  133. package/lib/directives/command.directive.d.ts +14 -0
  134. package/lib/directives/focus-binding.directive.d.ts +22 -0
  135. package/{src/lib/directives/index.ts → lib/directives/index.d.ts} +0 -1
  136. package/lib/interaction/abstract-activity.d.ts +17 -0
  137. package/lib/interaction/activity.d.ts +11 -0
  138. package/lib/interaction/alert.d.ts +5 -0
  139. package/lib/interaction/components/activity-container/activity-container.component.d.ts +32 -0
  140. package/{src/lib/interaction/components/activity-outlet/activity-outlet-context.ts → lib/interaction/components/activity-outlet/activity-outlet-context.d.ts} +5 -7
  141. package/lib/interaction/components/activity-outlet/activity-outlet.component.d.ts +30 -0
  142. package/lib/interaction/components/alert-dialog/alert-dialog.component.d.ts +8 -0
  143. package/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.d.ts +9 -0
  144. package/{src/lib/interaction/confirm.ts → lib/interaction/confirm.d.ts} +2 -3
  145. package/{src/lib/interaction/index.ts → lib/interaction/index.d.ts} +0 -1
  146. package/lib/interaction/interaction-context.d.ts +11 -0
  147. package/lib/interaction/interaction.module.d.ts +2 -0
  148. package/lib/interaction/result.d.ts +8 -0
  149. package/lib/interaction/services/dialog-interaction.service.d.ts +14 -0
  150. package/lib/place/abstract-place-component.d.ts +13 -0
  151. package/lib/place/components/busy-overlay/busy-overlay.component.d.ts +8 -0
  152. package/lib/place/components/empty-state/empty-state.component.d.ts +5 -0
  153. package/lib/place/components/place-outlet/place-outlet.component.d.ts +13 -0
  154. package/lib/place/components/place-outlet/route-animations.d.ts +1 -0
  155. package/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.d.ts +11 -0
  156. package/lib/place/guards/leave-place.guard.d.ts +10 -0
  157. package/lib/place/guards/place-route.guard.d.ts +9 -0
  158. package/{src/lib/place/index.ts → lib/place/index.d.ts} +0 -1
  159. package/lib/place/place-component.d.ts +5 -0
  160. package/lib/place/place.decorator.d.ts +20 -0
  161. package/lib/place/place.module.d.ts +2 -0
  162. package/lib/place/place.service.d.ts +8 -0
  163. package/lib/place/route/json-types.d.ts +7 -0
  164. package/lib/place/route/parameter-decorators.d.ts +26 -0
  165. package/lib/place/route/parameter-definition.class.d.ts +11 -0
  166. package/{src/lib/place/route/parameter-sanitiser.ts → lib/place/route/parameter-sanitiser.d.ts} +1 -1
  167. package/lib/place/route/parameter-type.d.ts +16 -0
  168. package/lib/place/route/route-parameter-bindings.d.ts +18 -0
  169. package/lib/place/route/route-parameter-sanitiser.d.ts +42 -0
  170. package/package.json +14 -12
  171. package/schematics/ng-add/index.d.ts +2 -0
  172. package/schematics/ng-add/index.js +12 -0
  173. package/schematics/ng-add/index.js.map +1 -0
  174. package/schematics/place-routes/index.d.ts +3 -0
  175. package/schematics/place-routes/index.js +114 -0
  176. package/schematics/place-routes/index.js.map +1 -0
  177. package/schematics/place-routes/place-def.d.ts +34 -0
  178. package/schematics/place-routes/place-def.js +84 -0
  179. package/schematics/place-routes/place-def.js.map +1 -0
  180. package/schematics/place-routes/scanner.d.ts +26 -0
  181. package/schematics/place-routes/scanner.js +125 -0
  182. package/schematics/place-routes/scanner.js.map +1 -0
  183. package/schematics/place-routes/schema.d.ts +7 -0
  184. package/schematics/place-routes/schema.js +3 -0
  185. package/schematics/place-routes/schema.js.map +1 -0
  186. package/CHANGELOG.md +0 -5
  187. package/jest.config.js +0 -9
  188. package/ng-package.json +0 -13
  189. package/schematics/ng-add/index.ts +0 -10
  190. package/schematics/place-routes/index.ts +0 -152
  191. package/schematics/place-routes/place-def.ts +0 -93
  192. package/schematics/place-routes/scanner.ts +0 -145
  193. package/schematics/place-routes/schema.ts +0 -7
  194. package/src/lib/angular-ui-powerups.module.spec.ts +0 -14
  195. package/src/lib/angular-ui-powerups.module.ts +0 -49
  196. package/src/lib/animations/slideDownAndUpAnimation.ts +0 -39
  197. package/src/lib/components/disposable-component.ts +0 -9
  198. package/src/lib/components/forms/abstract-input.component.ts +0 -108
  199. package/src/lib/components/forms/number-input/number-input.component.html +0 -15
  200. package/src/lib/components/forms/number-input/number-input.component.scss +0 -3
  201. package/src/lib/components/forms/number-input/number-input.component.spec.ts +0 -25
  202. package/src/lib/components/forms/number-input/number-input.component.ts +0 -19
  203. package/src/lib/components/forms/password-input/password-input.component.html +0 -16
  204. package/src/lib/components/forms/password-input/password-input.component.scss +0 -3
  205. package/src/lib/components/forms/password-input/password-input.component.spec.ts +0 -25
  206. package/src/lib/components/forms/password-input/password-input.component.ts +0 -18
  207. package/src/lib/components/forms/scss/mixins.scss +0 -16
  208. package/src/lib/components/forms/select-input/select-input.component.html +0 -16
  209. package/src/lib/components/forms/select-input/select-input.component.scss +0 -7
  210. package/src/lib/components/forms/select-input/select-input.component.spec.ts +0 -25
  211. package/src/lib/components/forms/select-input/select-input.component.ts +0 -31
  212. package/src/lib/components/forms/string-input/string-input.component.html +0 -15
  213. package/src/lib/components/forms/string-input/string-input.component.scss +0 -3
  214. package/src/lib/components/forms/string-input/string-input.component.spec.ts +0 -25
  215. package/src/lib/components/forms/string-input/string-input.component.ts +0 -18
  216. package/src/lib/components/resize-aware.component.ts +0 -52
  217. package/src/lib/components/types/bounds.class.ts +0 -25
  218. package/src/lib/components/types/dimension.class.ts +0 -3
  219. package/src/lib/components/types/point.class.ts +0 -13
  220. package/src/lib/directives/command.directive.spec.ts +0 -73
  221. package/src/lib/directives/command.directive.ts +0 -81
  222. package/src/lib/directives/focus-binding.directive.spec.ts +0 -8
  223. package/src/lib/directives/focus-binding.directive.ts +0 -108
  224. package/src/lib/interaction/abstract-activity.ts +0 -57
  225. package/src/lib/interaction/activity.ts +0 -17
  226. package/src/lib/interaction/alert.ts +0 -6
  227. package/src/lib/interaction/components/activity-container/activity-container.component.html +0 -8
  228. package/src/lib/interaction/components/activity-container/activity-container.component.scss +0 -3
  229. package/src/lib/interaction/components/activity-container/activity-container.component.spec.ts +0 -25
  230. package/src/lib/interaction/components/activity-container/activity-container.component.ts +0 -93
  231. package/src/lib/interaction/components/activity-outlet/activity-outlet.component.scss +0 -3
  232. package/src/lib/interaction/components/activity-outlet/activity-outlet.component.spec.ts +0 -25
  233. package/src/lib/interaction/components/activity-outlet/activity-outlet.component.ts +0 -96
  234. package/src/lib/interaction/components/alert-dialog/alert-dialog.component.html +0 -7
  235. package/src/lib/interaction/components/alert-dialog/alert-dialog.component.scss +0 -7
  236. package/src/lib/interaction/components/alert-dialog/alert-dialog.component.spec.ts +0 -25
  237. package/src/lib/interaction/components/alert-dialog/alert-dialog.component.ts +0 -20
  238. package/src/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.html +0 -9
  239. package/src/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.scss +0 -8
  240. package/src/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.spec.ts +0 -25
  241. package/src/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.ts +0 -26
  242. package/src/lib/interaction/interaction-context.ts +0 -16
  243. package/src/lib/interaction/interaction.module.ts +0 -35
  244. package/src/lib/interaction/result.ts +0 -16
  245. package/src/lib/interaction/services/dialog-interaction.service.scss +0 -11
  246. package/src/lib/interaction/services/dialog-interaction.service.spec.ts +0 -12
  247. package/src/lib/interaction/services/dialog-interaction.service.ts +0 -63
  248. package/src/lib/place/abstract-place-component.ts +0 -33
  249. package/src/lib/place/components/busy-overlay/busy-overlay.component.html +0 -4
  250. package/src/lib/place/components/busy-overlay/busy-overlay.component.scss +0 -27
  251. package/src/lib/place/components/busy-overlay/busy-overlay.component.spec.ts +0 -25
  252. package/src/lib/place/components/busy-overlay/busy-overlay.component.ts +0 -23
  253. package/src/lib/place/components/empty-state/empty-state.component.scss +0 -15
  254. package/src/lib/place/components/empty-state/empty-state.component.spec.ts +0 -25
  255. package/src/lib/place/components/empty-state/empty-state.component.ts +0 -19
  256. package/src/lib/place/components/place-outlet/place-outlet.component.html +0 -7
  257. package/src/lib/place/components/place-outlet/place-outlet.component.scss +0 -12
  258. package/src/lib/place/components/place-outlet/place-outlet.component.spec.ts +0 -25
  259. package/src/lib/place/components/place-outlet/place-outlet.component.ts +0 -37
  260. package/src/lib/place/components/place-outlet/route-animations.ts +0 -30
  261. package/src/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.html +0 -7
  262. package/src/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.scss +0 -100
  263. package/src/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.spec.ts +0 -25
  264. package/src/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.ts +0 -30
  265. package/src/lib/place/guards/leave-place.guard.spec.ts +0 -15
  266. package/src/lib/place/guards/leave-place.guard.ts +0 -18
  267. package/src/lib/place/guards/place-route.guard.ts +0 -37
  268. package/src/lib/place/place-component.ts +0 -6
  269. package/src/lib/place/place.decorator.ts +0 -40
  270. package/src/lib/place/place.module.ts +0 -44
  271. package/src/lib/place/place.service.spec.ts +0 -12
  272. package/src/lib/place/place.service.ts +0 -29
  273. package/src/lib/place/route/json-types.ts +0 -5
  274. package/src/lib/place/route/parameter-decorators.ts +0 -99
  275. package/src/lib/place/route/parameter-definition.class.ts +0 -12
  276. package/src/lib/place/route/parameter-type.ts +0 -31
  277. package/src/lib/place/route/route-parameter-bindings.ts +0 -140
  278. package/src/lib/place/route/route-parameter-sanitiser.ts +0 -135
  279. package/src/test-setup.ts +0 -1
  280. package/tsconfig.json +0 -7
  281. package/tsconfig.lib.json +0 -20
  282. package/tsconfig.schematics.json +0 -35
  283. package/tsconfig.spec.json +0 -10
  284. package/tslint.json +0 -7
  285. /package/{src/index.ts → index.d.ts} +0 -0
  286. /package/{src/public_api.ts → public_api.d.ts} +0 -0
@@ -0,0 +1,26 @@
1
+ import { SchematicContext } from '@angular-devkit/schematics';
2
+ import { ClassDeclaration, Decorator, ObjectLiteralExpression, PropertyDeclaration } from 'ts-morph';
3
+ import { PlaceDef } from './place-def';
4
+ export declare class Scanner {
5
+ private readonly classDecl;
6
+ readonly context: SchematicContext;
7
+ private placeAnnotation;
8
+ constructor(classDecl: ClassDeclaration, context: SchematicContext);
9
+ isPlace(): boolean;
10
+ onMatch(callback: (scan: Scanner) => void): void;
11
+ createDefinition(moduleImportPath: string): PlaceDef;
12
+ protected getPlaceOptions(): PlaceDef.Options;
13
+ protected getRouteIdParameter(): PlaceDef.Parameter;
14
+ protected getQueryParameters(): PlaceDef.Parameter[];
15
+ protected getDecoratedProperties(annotation: string): {
16
+ decorator: Decorator;
17
+ property: PropertyDeclaration;
18
+ }[];
19
+ }
20
+ export declare namespace Scanner {
21
+ function getObjectLiteralArgument(annotation: Decorator, position: number): ObjectLiteralExpression;
22
+ function getOptionsArg<T extends {}>(annotation: Decorator, defaults: T, options?: {
23
+ position: number;
24
+ required: boolean;
25
+ }): T;
26
+ }
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ts_morph_1 = require("ts-morph");
4
+ const place_def_1 = require("./place-def");
5
+ function isDecoratorNode(node, name) {
6
+ return node.getKind() === ts_morph_1.SyntaxKind.Decorator && node.getText().startsWith(`${name}(`); // NOTE: I'm only supporting the @Decorator(...) style of usage (i.e. decorator factories).
7
+ }
8
+ class Scanner {
9
+ constructor(classDecl, context) {
10
+ this.classDecl = classDecl;
11
+ this.context = context;
12
+ classDecl.forEachChild((node) => {
13
+ if (isDecoratorNode(node, '@Place')) {
14
+ this.placeAnnotation = node;
15
+ // stop iterating when the node is a class declaration
16
+ return true;
17
+ }
18
+ });
19
+ }
20
+ isPlace() {
21
+ return !!this.placeAnnotation;
22
+ }
23
+ onMatch(callback) {
24
+ if (this.isPlace()) {
25
+ callback(this);
26
+ }
27
+ }
28
+ createDefinition(moduleImportPath) {
29
+ this.getRouteIdParameter();
30
+ return new place_def_1.PlaceDef(moduleImportPath, this.classDecl.getName(), this.getPlaceOptions(), this.getRouteIdParameter(), this.getQueryParameters());
31
+ }
32
+ getPlaceOptions() {
33
+ // const args = this.placeAnnotation.getArguments();
34
+ // if (args.length !== 1) {
35
+ // console.error('@Place() accepts a single Options argument. got', args);
36
+ // }
37
+ return Scanner.getOptionsArg(this.placeAnnotation, {
38
+ title: '',
39
+ path: '',
40
+ order: -1,
41
+ authenticate: 'true'
42
+ }, {
43
+ position: 0,
44
+ required: true
45
+ });
46
+ }
47
+ getRouteIdParameter() {
48
+ const routeProperties = this.getDecoratedProperties('@RouteId');
49
+ if (routeProperties.length === 1) {
50
+ const route = routeProperties[0];
51
+ const routeOptions = Scanner.getOptionsArg(route.decorator, { as: 'id' }, {
52
+ position: 1,
53
+ required: false
54
+ });
55
+ return {
56
+ modelName: route.property.getName(),
57
+ parameterName: routeOptions.as
58
+ };
59
+ }
60
+ else if (routeProperties.length > 1) {
61
+ this.context.logger.error(`There an only be one @RouteId(), got ${routeProperties.length}`);
62
+ }
63
+ return null;
64
+ }
65
+ getQueryParameters() {
66
+ return this.getDecoratedProperties('@QueryParameter')
67
+ .map(p => {
68
+ const options = Scanner.getOptionsArg(p.decorator, { as: p.property.getName() }, {
69
+ position: 1,
70
+ required: false
71
+ });
72
+ return {
73
+ modelName: p.property.getName(),
74
+ parameterName: options.as
75
+ };
76
+ });
77
+ }
78
+ getDecoratedProperties(annotation) {
79
+ return this.classDecl.getProperties().map(p => {
80
+ let result = null;
81
+ p.forEachChild((child) => {
82
+ if (isDecoratorNode(child, annotation)) {
83
+ result = {
84
+ decorator: child,
85
+ property: p
86
+ };
87
+ // stop traversal
88
+ return true;
89
+ }
90
+ });
91
+ return result;
92
+ }).filter(r => !!r);
93
+ }
94
+ }
95
+ exports.Scanner = Scanner;
96
+ (function (Scanner) {
97
+ function getObjectLiteralArgument(annotation, position) {
98
+ const args = annotation.getArguments();
99
+ if (args.length > position && args[position] instanceof ts_morph_1.ObjectLiteralExpression) {
100
+ return args[position];
101
+ }
102
+ return null;
103
+ }
104
+ Scanner.getObjectLiteralArgument = getObjectLiteralArgument;
105
+ function getOptionsArg(annotation, defaults, options = {
106
+ position: 0,
107
+ required: true
108
+ }) {
109
+ const objectLiteralArgument = getObjectLiteralArgument(annotation, options.position);
110
+ if (!objectLiteralArgument) {
111
+ if (options.required) {
112
+ console.error(`expected object literal arg at position ${options.position}`, { expectedType: defaults });
113
+ }
114
+ return defaults;
115
+ }
116
+ else {
117
+ return objectLiteralArgument.getProperties().reduce((result, p) => {
118
+ const structure = p.getStructure();
119
+ return Object.assign({}, result, { [structure.name]: structure.initializer });
120
+ }, Object.assign({}, defaults));
121
+ }
122
+ }
123
+ Scanner.getOptionsArg = getOptionsArg;
124
+ })(Scanner = exports.Scanner || (exports.Scanner = {}));
125
+ //# sourceMappingURL=scanner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanner.js","sourceRoot":"","sources":["../../../../../libs/angular-ui-powerups/schematics/place-routes/scanner.ts"],"names":[],"mappings":";;AACA,uCAQkB;AAClB,2CAAuC;AAEvC,SAAS,eAAe,CAAC,IAAU,EAAE,IAAY;IAC/C,OAAO,IAAI,CAAC,OAAO,EAAE,KAAK,qBAAU,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,2FAA2F;AACtL,CAAC;AAED,MAAa,OAAO;IAIlB,YAA6B,SAA2B,EAAW,OAAyB;QAA/D,cAAS,GAAT,SAAS,CAAkB;QAAW,YAAO,GAAP,OAAO,CAAkB;QAC1F,SAAS,CAAC,YAAY,CAAC,CAAC,IAAI,EAAE,EAAE;YAC9B,IAAI,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE;gBACnC,IAAI,CAAC,eAAe,GAAG,IAAiB,CAAC;gBACzC,sDAAsD;gBACtD,OAAO,IAAI,CAAC;aACb;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,OAAO,CAAC,CAAC,IAAI,CA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
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../libs/angular-ui-powerups/schematics/place-routes/schema.ts"],"names":[],"mappings":""}
package/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
-
5
- ### 0.0.25 (2019-09-09)
package/jest.config.js DELETED
@@ -1,9 +0,0 @@
1
- module.exports = {
2
- name: 'angular-ui-powerups',
3
- preset: '../../jest.config.js',
4
- coverageDirectory: '../../coverage/libs/angular-ui-powerups',
5
- snapshotSerializers: [
6
- 'jest-preset-angular/AngularSnapshotSerializer.js',
7
- 'jest-preset-angular/HTMLCommentSerializer.js'
8
- ]
9
- };
package/ng-package.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
- "dest": "../../dist/libs/angular-ui-powerups",
4
- "lib": {
5
- "entryFile": "src/index.ts"
6
- },
7
- "whitelistedNonPeerDependencies": [
8
- "ts-morph",
9
- "@typescript-plus/fast-memoize-decorator",
10
- "@coolon/typescript-utilities",
11
- "json5"
12
- ]
13
- }
@@ -1,10 +0,0 @@
1
- import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
2
- import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
3
-
4
- // Just return the tree
5
- export function ngAdd(_options: any): Rule {
6
- return (tree: Tree, _context: SchematicContext) => {
7
- _context.addTask(new NodePackageInstallTask());
8
- return tree;
9
- };
10
- }
@@ -1,152 +0,0 @@
1
- import { experimental, strings } from '@angular-devkit/core';
2
- import {
3
- apply,
4
- applyTemplates,
5
- FileEntry,
6
- forEach,
7
- mergeWith,
8
- Rule,
9
- SchematicContext,
10
- Tree,
11
- url,
12
- move
13
- } from '@angular-devkit/schematics';
14
- import { scanForRouteEntryPoints } from '@angular/compiler-cli/src/ngtsc/routing/src/lazy';
15
- import { fileExists } from '@nrwl/workspace/src/utils/fileutils';
16
- import * as JSON5 from 'json5';
17
- import { ClassDeclaration, Project } from 'ts-morph';
18
- import { PlaceDef } from './place-def';
19
- import { Schema } from './schema';
20
-
21
- const PLACE_ANNOTATION = /@Place\({([^})]*)}\)/m;
22
-
23
- export function generateRoutes(options: Schema): Rule {
24
-
25
- return (tree: Tree, context: SchematicContext) => {
26
-
27
- const workspaceConfig = tree.read('/angular.json');
28
- if (!workspaceConfig) {
29
- throw new Error('Could not find Angular workspace configuration');
30
- }
31
-
32
- // convert workspace to string
33
- const workspaceContent = workspaceConfig.toString();
34
-
35
- // parse workspace string into JSON object
36
- const workspace: experimental.workspace.WorkspaceSchema = JSON.parse(workspaceContent);
37
-
38
- if (!options.project) {
39
- options.project = workspace.defaultProject;
40
- }
41
-
42
- const projectName = options.project as string;
43
- const project = workspace.projects[projectName];
44
- const config = loadConfig(project, tree, context);
45
- const placeDefs = extractPlaces(project, options, tree, context);
46
- const projectType = project.projectType === 'application' ? 'app' : 'lib';
47
-
48
- const files = apply(
49
- url('./templates'),
50
- [
51
- applyTemplates({
52
- ...options,
53
- placeDefs,
54
- config,
55
- ...strings
56
- }),
57
- move(`${project.sourceRoot}/${projectType}`),
58
- // @see https://github.com/angular/angular-cli/issues/11337#issuecomment-448259549
59
- forEach((fileEntry: FileEntry) => {
60
- if (tree.exists(fileEntry.path)) {
61
- tree.overwrite(fileEntry.path, fileEntry.content);
62
- }
63
- return fileEntry;
64
- })
65
- ]);
66
-
67
- return mergeWith(files);
68
- };
69
-
70
- }
71
-
72
-
73
-
74
- // function applyWithOverwrite(source: Source, rules: Rule[]): Rule {
75
- // return (tree: Tree, _context: SchematicContext) => {
76
- // const rule = mergeWith(
77
- // apply(source, [
78
- // ...rules,
79
- // forEach((fileEntry) => {
80
- // if (tree.exists(fileEntry.path)) {
81
- // tree.overwrite(fileEntry.path, fileEntry.content);
82
- // return null;
83
- // }
84
- // return fileEntry;
85
- // })
86
- // ])
87
- // );
88
- //
89
- // return rule(tree, _context);
90
- // };
91
- // }
92
-
93
- function createProject(project: any, context: SchematicContext) {
94
- const tsConfigPath = project.architect.build.options.tsConfig;
95
- context.logger.info(`loading tsConfig from -> ${tsConfigPath}`);
96
- try {
97
- return new Project({
98
- tsConfigFilePath: `./${tsConfigPath}`
99
- });
100
- } catch (error) {
101
- context.logger.fatal(`Failed to load typescript project form: ${project.root} You probably need to specify the --project option?`);
102
- }
103
- }
104
-
105
- function loadConfig(project: any, tree: Tree, context: SchematicContext) {
106
- context.logger.info(`loading places config from -> ${project.root}/places.json (or places.json5)`);
107
- const fileEntry = tree.get(`${project.root}/places.json5`) || tree.get(`${project.root}/places.json5`);
108
- if (!fileEntry) {
109
- throw new Error(`Unable to find config file at '${project.root}/places.json' or '${project.root}/places.json5'`);
110
- }
111
- const config = JSON5.parse(fileEntry.content.toString('utf-8'));
112
- return config;
113
- }
114
-
115
- function extractPlaces(project: any, schema: Schema, tree: Tree, context: SchematicContext): PlaceDef[] {
116
- const projectType = project.projectType === 'application' ? 'app' : 'lib';
117
- const projectRoot = `${project.root}`;
118
- const sourceRoot = `${project.sourceRoot}/${projectType}`;
119
- const importPrefix = `./${sourceRoot}`;
120
- const tsProject = createProject(project, context);
121
- const placeDefs: PlaceDef[] = [];
122
- context.logger.info(`Scanning sources in -> ${sourceRoot}`);
123
- tree.getDir(sourceRoot).visit(filePath => {
124
- if (!filePath.endsWith('.ts')) {
125
- return;
126
- }
127
-
128
- const content = tree.read(filePath);
129
- if (!content) {
130
- return;
131
- }
132
- const sourceText = content.toString('utf-8');
133
-
134
- if (sourceText.match(PLACE_ANNOTATION)) {
135
-
136
- const sourceFile = tsProject.getSourceFileOrThrow(`./${filePath}`);
137
-
138
- sourceFile.getClasses().forEach((classDecl: ClassDeclaration) => {
139
-
140
- PlaceDef.scan(classDecl, context).onMatch(result => {
141
- // context.logger.info(`filePath=${filePath}`);
142
- const moduleImportPath = `./${filePath.substr(importPrefix.length, filePath.length - importPrefix.length - '.ts'.length)}`;
143
- const definition = result.createDefinition(moduleImportPath);
144
- context.logger.info(`${moduleImportPath} -> ${classDecl.getName()}(route: /${definition.fullPath})`);
145
- placeDefs.push(definition);
146
- });
147
- });
148
- }
149
- });
150
-
151
- return placeDefs;
152
- }
@@ -1,93 +0,0 @@
1
- import { SchematicContext } from '@angular-devkit/schematics';
2
- import { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';
3
- import { ClassDeclaration } from 'ts-morph';
4
- import { Scanner } from './scanner';
5
-
6
- export class PlaceDef {
7
-
8
-
9
- constructor(
10
- readonly importPath: string,
11
- readonly componentClass: string,
12
- readonly properties: PlaceDef.Options,
13
- readonly routeDef: PlaceDef.Parameter,
14
- readonly queryParameters: PlaceDef.Parameter[]
15
- ) {
16
- // console.log({ properties, routeDef });
17
- }
18
-
19
- @Memoize()
20
- get path() {
21
- return this.stripEnclosingQuotes(this.properties.path);
22
- }
23
-
24
- @Memoize()
25
- get routeIdentifier() {
26
- return this.routeDef ? this.stripEnclosingQuotes(this.routeDef.parameterName) : null;
27
- }
28
-
29
- get fullPath() {
30
- return !!this.routeIdentifier ?
31
- `${this.path}/:${this.routeIdentifier}` :
32
- this.path;
33
- }
34
-
35
- @Memoize()
36
- get placeName() {
37
- return this.componentClass.replace(/Component$/, "")
38
- }
39
-
40
- get order() {
41
- return this.properties.order
42
- }
43
-
44
- @Memoize()
45
- get activateGuardNames() {
46
- const activateGuards = [];
47
- if (this.authenticate) {
48
- activateGuards.push('AuthGuard');
49
- }
50
- if (this.requiresRouteGuard()) {
51
- activateGuards.push('PlaceRouteGuard');
52
- }
53
- return activateGuards;
54
- }
55
-
56
- private requiresRouteGuard() {
57
- return this.routeIdentifier || this.queryParameters.length > 0;
58
- }
59
-
60
- @Memoize()
61
- get routeModelName() {
62
- return this.routeDef ? this.stripEnclosingQuotes(this.routeDef.modelName) : null;
63
- }
64
-
65
- get authenticate() {
66
- return this.properties.authenticate === 'true';
67
- }
68
-
69
- stripEnclosingQuotes(value: string): string {
70
- const cooked = value.replace(/(^["'])|(["']$)/g, '');
71
- // console.log({ raw: value, cooked: cooked });
72
- return cooked;
73
- }
74
- }
75
-
76
- export namespace PlaceDef {
77
-
78
- export interface Options {
79
- title: string;
80
- path: string;
81
- order: number;
82
- authenticate: string;
83
- }
84
-
85
- export interface Parameter {
86
- parameterName: string;
87
- modelName: string;
88
- }
89
-
90
- export function scan(classDecl: ClassDeclaration, context: SchematicContext): Scanner {
91
- return new Scanner(classDecl, context);
92
- }
93
- }
@@ -1,145 +0,0 @@
1
- import { SchematicContext } from '@angular-devkit/schematics';
2
- import {
3
- ClassDeclaration,
4
- Decorator,
5
- Node,
6
- ObjectLiteralExpression,
7
- PropertyAssignmentStructure,
8
- PropertyDeclaration,
9
- SyntaxKind
10
- } from 'ts-morph';
11
- import { PlaceDef } from './place-def';
12
-
13
- function isDecoratorNode(node: Node, name: string): node is Decorator {
14
- return node.getKind() === SyntaxKind.Decorator && node.getText().startsWith(`${name}(`); // NOTE: I'm only supporting the @Decorator(...) style of usage (i.e. decorator factories).
15
- }
16
-
17
- export class Scanner {
18
-
19
- private placeAnnotation: Decorator;
20
-
21
- constructor(private readonly classDecl: ClassDeclaration, readonly context: SchematicContext) {
22
- classDecl.forEachChild((node) => {
23
- if (isDecoratorNode(node, '@Place')) {
24
- this.placeAnnotation = node as Decorator;
25
- // stop iterating when the node is a class declaration
26
- return true;
27
- }
28
- });
29
- }
30
-
31
- isPlace() {
32
- return !!this.placeAnnotation;
33
- }
34
-
35
- onMatch(callback: (scan: Scanner) => void) {
36
- if (this.isPlace()) {
37
- callback(this);
38
- }
39
- }
40
-
41
- createDefinition(moduleImportPath: string): PlaceDef {
42
- this.getRouteIdParameter();
43
- return new PlaceDef(moduleImportPath,
44
- this.classDecl.getName(),
45
- this.getPlaceOptions(),
46
- this.getRouteIdParameter(),
47
- this.getQueryParameters()
48
- );
49
- }
50
-
51
- protected getPlaceOptions(): PlaceDef.Options {
52
- // const args = this.placeAnnotation.getArguments();
53
- // if (args.length !== 1) {
54
- // console.error('@Place() accepts a single Options argument. got', args);
55
- // }
56
- return Scanner.getOptionsArg(this.placeAnnotation, {
57
- title: '',
58
- path: '',
59
- order: -1,
60
- authenticate: 'true'
61
- }, {
62
- position: 0,
63
- required: true
64
- });
65
- }
66
-
67
- protected getRouteIdParameter(): PlaceDef.Parameter {
68
- const routeProperties = this.getDecoratedProperties('@RouteId');
69
- if (routeProperties.length === 1) {
70
- const route = routeProperties[0];
71
- const routeOptions = Scanner.getOptionsArg(route.decorator, { as: 'id' }, {
72
- position: 1,
73
- required: false
74
- });
75
- return {
76
- modelName: route.property.getName(),
77
- parameterName: routeOptions.as
78
- };
79
- } else if (routeProperties.length > 1) {
80
- this.context.logger.error(`There an only be one @RouteId(), got ${routeProperties.length}`);
81
- }
82
- return null;
83
- }
84
-
85
- protected getQueryParameters(): PlaceDef.Parameter[] {
86
- return this.getDecoratedProperties('@QueryParameter')
87
- .map(p => {
88
- const options = Scanner.getOptionsArg(p.decorator, { as: p.property.getName() }, {
89
- position: 1,
90
- required: false
91
- });
92
- return {
93
- modelName: p.property.getName(),
94
- parameterName: options.as
95
- };
96
- });
97
- }
98
-
99
- protected getDecoratedProperties(annotation: string): { decorator: Decorator, property: PropertyDeclaration }[] {
100
- return this.classDecl.getProperties().map(p => {
101
- let result: { decorator: Decorator, property: PropertyDeclaration } = null;
102
- p.forEachChild((child) => {
103
- if (isDecoratorNode(child, annotation)) {
104
- result = {
105
- decorator: child,
106
- property: p
107
- };
108
- // stop traversal
109
- return true;
110
- }
111
- });
112
- return result;
113
- }).filter(r => !!r);
114
- }
115
-
116
- }
117
-
118
- export namespace Scanner {
119
-
120
- export function getObjectLiteralArgument(annotation: Decorator, position: number): ObjectLiteralExpression {
121
- const args = annotation.getArguments();
122
- if (args.length > position && args[position] instanceof ObjectLiteralExpression) {
123
- return args[position] as ObjectLiteralExpression;
124
- }
125
- return null;
126
- }
127
-
128
- export function getOptionsArg<T extends {}>(annotation: Decorator, defaults: T, options: { position: number, required: boolean } = {
129
- position: 0,
130
- required: true
131
- }): T {
132
- const objectLiteralArgument = getObjectLiteralArgument(annotation, options.position);
133
- if (!objectLiteralArgument) {
134
- if (options.required) {
135
- console.error(`expected object literal arg at position ${options.position}`, { expectedType: defaults });
136
- }
137
- return defaults;
138
- } else {
139
- return objectLiteralArgument.getProperties().reduce((result, p) => {
140
- const structure = p.getStructure() as PropertyAssignmentStructure;
141
- return { ...result, [structure.name]: structure.initializer as string };
142
- }, { ...defaults });
143
- }
144
- }
145
- }
@@ -1,7 +0,0 @@
1
- export interface Schema {
2
- project: string;
3
- authGuard: {
4
- className: string;
5
- moduleImport: string;
6
- }
7
- }
@@ -1,14 +0,0 @@
1
- import { async, TestBed } from '@angular/core/testing';
2
- import { AngularUiPowerupsModule } from './angular-ui-powerups.module';
3
-
4
- describe('AngularUiPowerupsModule', () => {
5
- beforeEach(async(() => {
6
- TestBed.configureTestingModule({
7
- imports: [AngularUiPowerupsModule]
8
- }).compileComponents();
9
- }));
10
-
11
- it('should create', () => {
12
- expect(AngularUiPowerupsModule).toBeDefined();
13
- });
14
- });
@@ -1,49 +0,0 @@
1
- import { CommonModule } from '@angular/common';
2
- import { NgModule } from '@angular/core';
3
- import { FormsModule } from '@angular/forms';
4
- import { MatFormFieldModule, MatInputModule, MatSelectModule } from '@angular/material';
5
- import { BrowserModule } from '@angular/platform-browser';
6
- import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7
- import { NumberInputComponent} from './components/forms/number-input/number-input.component';
8
- import { CommandDirective } from './directives/command.directive';
9
- import { FocusBindingDirective } from './directives/focus-binding.directive';
10
- import { StringInputComponent } from './components/forms/string-input/string-input.component';
11
- import { PasswordInputComponent } from './components/forms/password-input/password-input.component';
12
- import { SelectInputComponent } from './components/forms/select-input/select-input.component';
13
- import { InteractionModule } from './interaction/interaction.module';
14
- import { PlaceModule } from './place/place.module';
15
-
16
- @NgModule({
17
- declarations: [
18
- CommandDirective,
19
- FocusBindingDirective,
20
- NumberInputComponent,
21
- StringInputComponent,
22
- PasswordInputComponent,
23
- SelectInputComponent,
24
- ],
25
- imports: [
26
- CommonModule,
27
- BrowserModule,
28
- BrowserAnimationsModule,
29
- FormsModule,
30
- MatInputModule,
31
- MatFormFieldModule,
32
- MatSelectModule,
33
- PlaceModule,
34
- InteractionModule
35
- ],
36
- exports: [
37
- CommandDirective,
38
- FocusBindingDirective,
39
- NumberInputComponent,
40
- StringInputComponent,
41
- PasswordInputComponent,
42
- SelectInputComponent,
43
- InteractionModule,
44
- PlaceModule,
45
- ]
46
-
47
- })
48
- export class AngularUiPowerupsModule {
49
- }