@coolon/angular-ui-powerups 0.0.24 → 0.0.26

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/CHANGELOG.md +7 -0
  2. package/jest.config.js +9 -0
  3. package/ng-package.json +13 -0
  4. package/package.json +12 -14
  5. package/schematics/ng-add/index.ts +10 -0
  6. package/schematics/place-routes/index.ts +152 -0
  7. package/schematics/place-routes/place-def.ts +93 -0
  8. package/schematics/place-routes/scanner.ts +145 -0
  9. package/schematics/place-routes/schema.ts +7 -0
  10. package/src/lib/angular-ui-powerups.module.spec.ts +14 -0
  11. package/src/lib/angular-ui-powerups.module.ts +49 -0
  12. package/{lib/animations/index.d.ts → src/lib/animations/index.ts} +1 -0
  13. package/src/lib/animations/slideDownAndUpAnimation.ts +39 -0
  14. package/src/lib/components/disposable-component.ts +9 -0
  15. package/src/lib/components/forms/abstract-input.component.ts +108 -0
  16. package/src/lib/components/forms/number-input/number-input.component.html +15 -0
  17. package/src/lib/components/forms/number-input/number-input.component.scss +3 -0
  18. package/src/lib/components/forms/number-input/number-input.component.spec.ts +25 -0
  19. package/src/lib/components/forms/number-input/number-input.component.ts +19 -0
  20. package/src/lib/components/forms/password-input/password-input.component.html +16 -0
  21. package/src/lib/components/forms/password-input/password-input.component.scss +3 -0
  22. package/src/lib/components/forms/password-input/password-input.component.spec.ts +25 -0
  23. package/src/lib/components/forms/password-input/password-input.component.ts +18 -0
  24. package/src/lib/components/forms/scss/mixins.scss +16 -0
  25. package/src/lib/components/forms/select-input/select-input.component.html +16 -0
  26. package/src/lib/components/forms/select-input/select-input.component.scss +7 -0
  27. package/src/lib/components/forms/select-input/select-input.component.spec.ts +25 -0
  28. package/src/lib/components/forms/select-input/select-input.component.ts +31 -0
  29. package/src/lib/components/forms/string-input/string-input.component.html +15 -0
  30. package/src/lib/components/forms/string-input/string-input.component.scss +3 -0
  31. package/src/lib/components/forms/string-input/string-input.component.spec.ts +25 -0
  32. package/src/lib/components/forms/string-input/string-input.component.ts +18 -0
  33. package/{lib/components/index.d.ts → src/lib/components/index.ts} +1 -0
  34. package/src/lib/components/resize-aware.component.ts +52 -0
  35. package/src/lib/components/types/bounds.class.ts +25 -0
  36. package/src/lib/components/types/dimension.class.ts +3 -0
  37. package/src/lib/components/types/point.class.ts +13 -0
  38. package/src/lib/directives/command.directive.spec.ts +73 -0
  39. package/src/lib/directives/command.directive.ts +81 -0
  40. package/src/lib/directives/focus-binding.directive.spec.ts +8 -0
  41. package/src/lib/directives/focus-binding.directive.ts +108 -0
  42. package/{lib/directives/index.d.ts → src/lib/directives/index.ts} +1 -0
  43. package/src/lib/interaction/abstract-activity.ts +57 -0
  44. package/src/lib/interaction/activity.ts +17 -0
  45. package/src/lib/interaction/alert.ts +6 -0
  46. package/src/lib/interaction/components/activity-container/activity-container.component.html +8 -0
  47. package/src/lib/interaction/components/activity-container/activity-container.component.scss +3 -0
  48. package/src/lib/interaction/components/activity-container/activity-container.component.spec.ts +25 -0
  49. package/src/lib/interaction/components/activity-container/activity-container.component.ts +93 -0
  50. package/{lib/interaction/components/activity-outlet/activity-outlet-context.d.ts → src/lib/interaction/components/activity-outlet/activity-outlet-context.ts} +7 -5
  51. package/src/lib/interaction/components/activity-outlet/activity-outlet.component.scss +3 -0
  52. package/src/lib/interaction/components/activity-outlet/activity-outlet.component.spec.ts +25 -0
  53. package/src/lib/interaction/components/activity-outlet/activity-outlet.component.ts +96 -0
  54. package/src/lib/interaction/components/alert-dialog/alert-dialog.component.html +7 -0
  55. package/src/lib/interaction/components/alert-dialog/alert-dialog.component.scss +7 -0
  56. package/src/lib/interaction/components/alert-dialog/alert-dialog.component.spec.ts +25 -0
  57. package/src/lib/interaction/components/alert-dialog/alert-dialog.component.ts +20 -0
  58. package/src/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.html +9 -0
  59. package/src/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.scss +8 -0
  60. package/src/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.spec.ts +25 -0
  61. package/src/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.ts +26 -0
  62. package/{lib/interaction/confirm.d.ts → src/lib/interaction/confirm.ts} +3 -2
  63. package/{lib/interaction/index.d.ts → src/lib/interaction/index.ts} +1 -0
  64. package/src/lib/interaction/interaction-context.ts +16 -0
  65. package/src/lib/interaction/interaction.module.ts +35 -0
  66. package/src/lib/interaction/result.ts +16 -0
  67. package/src/lib/interaction/services/dialog-interaction.service.scss +11 -0
  68. package/src/lib/interaction/services/dialog-interaction.service.spec.ts +12 -0
  69. package/src/lib/interaction/services/dialog-interaction.service.ts +63 -0
  70. package/src/lib/place/abstract-place-component.ts +33 -0
  71. package/src/lib/place/components/busy-overlay/busy-overlay.component.html +4 -0
  72. package/src/lib/place/components/busy-overlay/busy-overlay.component.scss +27 -0
  73. package/src/lib/place/components/busy-overlay/busy-overlay.component.spec.ts +25 -0
  74. package/src/lib/place/components/busy-overlay/busy-overlay.component.ts +23 -0
  75. package/src/lib/place/components/empty-state/empty-state.component.scss +15 -0
  76. package/src/lib/place/components/empty-state/empty-state.component.spec.ts +25 -0
  77. package/src/lib/place/components/empty-state/empty-state.component.ts +19 -0
  78. package/src/lib/place/components/place-outlet/place-outlet.component.html +7 -0
  79. package/src/lib/place/components/place-outlet/place-outlet.component.scss +12 -0
  80. package/src/lib/place/components/place-outlet/place-outlet.component.spec.ts +25 -0
  81. package/src/lib/place/components/place-outlet/place-outlet.component.ts +37 -0
  82. package/src/lib/place/components/place-outlet/route-animations.ts +30 -0
  83. package/src/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.html +7 -0
  84. package/src/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.scss +100 -0
  85. package/src/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.spec.ts +25 -0
  86. package/src/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.ts +30 -0
  87. package/src/lib/place/guards/leave-place.guard.spec.ts +15 -0
  88. package/src/lib/place/guards/leave-place.guard.ts +18 -0
  89. package/src/lib/place/guards/place-route.guard.ts +37 -0
  90. package/{lib/place/index.d.ts → src/lib/place/index.ts} +1 -0
  91. package/src/lib/place/place-component.ts +6 -0
  92. package/src/lib/place/place.decorator.ts +40 -0
  93. package/src/lib/place/place.module.ts +44 -0
  94. package/src/lib/place/place.service.spec.ts +12 -0
  95. package/src/lib/place/place.service.ts +29 -0
  96. package/src/lib/place/route/json-types.ts +5 -0
  97. package/src/lib/place/route/parameter-decorators.ts +99 -0
  98. package/src/lib/place/route/parameter-definition.class.ts +12 -0
  99. package/{lib/place/route/parameter-sanitiser.d.ts → src/lib/place/route/parameter-sanitiser.ts} +1 -1
  100. package/src/lib/place/route/parameter-type.ts +31 -0
  101. package/src/lib/place/route/route-parameter-bindings.ts +140 -0
  102. package/src/lib/place/route/route-parameter-sanitiser.ts +135 -0
  103. package/src/test-setup.ts +1 -0
  104. package/tsconfig.json +7 -0
  105. package/tsconfig.lib.json +20 -0
  106. package/tsconfig.schematics.json +35 -0
  107. package/tsconfig.spec.json +10 -0
  108. package/tslint.json +7 -0
  109. package/bundles/coolon-angular-ui-powerups.umd.js +0 -3926
  110. package/bundles/coolon-angular-ui-powerups.umd.js.map +0 -1
  111. package/bundles/coolon-angular-ui-powerups.umd.min.js +0 -2
  112. package/bundles/coolon-angular-ui-powerups.umd.min.js.map +0 -1
  113. package/coolon-angular-ui-powerups.d.ts +0 -30
  114. package/coolon-angular-ui-powerups.metadata.json +0 -1
  115. package/esm2015/coolon-angular-ui-powerups.js +0 -33
  116. package/esm2015/index.js +0 -6
  117. package/esm2015/lib/angular-ui-powerups.module.js +0 -54
  118. package/esm2015/lib/animations/index.js +0 -9
  119. package/esm2015/lib/animations/slideDownAndUpAnimation.js +0 -30
  120. package/esm2015/lib/components/disposable-component.js +0 -14
  121. package/esm2015/lib/components/forms/abstract-input.component.js +0 -183
  122. package/esm2015/lib/components/forms/number-input/number-input.component.js +0 -26
  123. package/esm2015/lib/components/forms/password-input/password-input.component.js +0 -26
  124. package/esm2015/lib/components/forms/select-input/select-input.component.js +0 -60
  125. package/esm2015/lib/components/forms/string-input/string-input.component.js +0 -26
  126. package/esm2015/lib/components/index.js +0 -18
  127. package/esm2015/lib/components/resize-aware.component.js +0 -96
  128. package/esm2015/lib/components/types/bounds.class.js +0 -56
  129. package/esm2015/lib/components/types/dimension.class.js +0 -21
  130. package/esm2015/lib/components/types/point.class.js +0 -36
  131. package/esm2015/lib/directives/command.directive.js +0 -135
  132. package/esm2015/lib/directives/focus-binding.directive.js +0 -179
  133. package/esm2015/lib/directives/index.js +0 -10
  134. package/esm2015/lib/interaction/abstract-activity.js +0 -129
  135. package/esm2015/lib/interaction/activity.js +0 -27
  136. package/esm2015/lib/interaction/alert.js +0 -23
  137. package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +0 -144
  138. package/esm2015/lib/interaction/components/activity-outlet/activity-outlet-context.js +0 -22
  139. package/esm2015/lib/interaction/components/activity-outlet/activity-outlet.component.js +0 -169
  140. package/esm2015/lib/interaction/components/alert-dialog/alert-dialog.component.js +0 -37
  141. package/esm2015/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.js +0 -46
  142. package/esm2015/lib/interaction/confirm.js +0 -17
  143. package/esm2015/lib/interaction/index.js +0 -21
  144. package/esm2015/lib/interaction/interaction-context.js +0 -35
  145. package/esm2015/lib/interaction/interaction.module.js +0 -41
  146. package/esm2015/lib/interaction/result.js +0 -24
  147. package/esm2015/lib/interaction/services/dialog-interaction.service.js +0 -114
  148. package/esm2015/lib/place/abstract-place-component.js +0 -59
  149. package/esm2015/lib/place/components/busy-overlay/busy-overlay.component.js +0 -44
  150. package/esm2015/lib/place/components/empty-state/empty-state.component.js +0 -28
  151. package/esm2015/lib/place/components/place-outlet/place-outlet.component.js +0 -67
  152. package/esm2015/lib/place/components/place-outlet/route-animations.js +0 -35
  153. package/esm2015/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.js +0 -50
  154. package/esm2015/lib/place/guards/leave-place.guard.js +0 -52
  155. package/esm2015/lib/place/guards/place-route.guard.js +0 -74
  156. package/esm2015/lib/place/index.js +0 -27
  157. package/esm2015/lib/place/place-component.js +0 -17
  158. package/esm2015/lib/place/place.decorator.js +0 -72
  159. package/esm2015/lib/place/place.module.js +0 -49
  160. package/esm2015/lib/place/place.service.js +0 -61
  161. package/esm2015/lib/place/route/json-types.js +0 -13
  162. package/esm2015/lib/place/route/parameter-decorators.js +0 -178
  163. package/esm2015/lib/place/route/parameter-definition.class.js +0 -24
  164. package/esm2015/lib/place/route/parameter-sanitiser.js +0 -17
  165. package/esm2015/lib/place/route/parameter-type.js +0 -43
  166. package/esm2015/lib/place/route/route-parameter-bindings.js +0 -294
  167. package/esm2015/lib/place/route/route-parameter-sanitiser.js +0 -280
  168. package/esm2015/public_api.js +0 -11
  169. package/esm5/coolon-angular-ui-powerups.js +0 -33
  170. package/esm5/index.js +0 -6
  171. package/esm5/lib/angular-ui-powerups.module.js +0 -58
  172. package/esm5/lib/animations/index.js +0 -9
  173. package/esm5/lib/animations/slideDownAndUpAnimation.js +0 -30
  174. package/esm5/lib/components/disposable-component.js +0 -24
  175. package/esm5/lib/components/forms/abstract-input.component.js +0 -232
  176. package/esm5/lib/components/forms/number-input/number-input.component.js +0 -33
  177. package/esm5/lib/components/forms/password-input/password-input.component.js +0 -33
  178. package/esm5/lib/components/forms/select-input/select-input.component.js +0 -67
  179. package/esm5/lib/components/forms/string-input/string-input.component.js +0 -33
  180. package/esm5/lib/components/index.js +0 -18
  181. package/esm5/lib/components/resize-aware.component.js +0 -124
  182. package/esm5/lib/components/types/bounds.class.js +0 -59
  183. package/esm5/lib/components/types/dimension.class.js +0 -19
  184. package/esm5/lib/components/types/point.class.js +0 -43
  185. package/esm5/lib/directives/command.directive.js +0 -155
  186. package/esm5/lib/directives/focus-binding.directive.js +0 -231
  187. package/esm5/lib/directives/index.js +0 -10
  188. package/esm5/lib/interaction/abstract-activity.js +0 -173
  189. package/esm5/lib/interaction/activity.js +0 -27
  190. package/esm5/lib/interaction/alert.js +0 -23
  191. package/esm5/lib/interaction/components/activity-container/activity-container.component.js +0 -181
  192. package/esm5/lib/interaction/components/activity-outlet/activity-outlet-context.js +0 -22
  193. package/esm5/lib/interaction/components/activity-outlet/activity-outlet.component.js +0 -206
  194. package/esm5/lib/interaction/components/alert-dialog/alert-dialog.component.js +0 -42
  195. package/esm5/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.js +0 -54
  196. package/esm5/lib/interaction/confirm.js +0 -17
  197. package/esm5/lib/interaction/index.js +0 -21
  198. package/esm5/lib/interaction/interaction-context.js +0 -45
  199. package/esm5/lib/interaction/interaction.module.js +0 -45
  200. package/esm5/lib/interaction/result.js +0 -24
  201. package/esm5/lib/interaction/services/dialog-interaction.service.js +0 -140
  202. package/esm5/lib/place/abstract-place-component.js +0 -66
  203. package/esm5/lib/place/components/busy-overlay/busy-overlay.component.js +0 -49
  204. package/esm5/lib/place/components/empty-state/empty-state.component.js +0 -29
  205. package/esm5/lib/place/components/place-outlet/place-outlet.component.js +0 -81
  206. package/esm5/lib/place/components/place-outlet/route-animations.js +0 -35
  207. package/esm5/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.js +0 -57
  208. package/esm5/lib/place/guards/leave-place.guard.js +0 -57
  209. package/esm5/lib/place/guards/place-route.guard.js +0 -78
  210. package/esm5/lib/place/index.js +0 -27
  211. package/esm5/lib/place/place-component.js +0 -17
  212. package/esm5/lib/place/place.decorator.js +0 -69
  213. package/esm5/lib/place/place.module.js +0 -53
  214. package/esm5/lib/place/place.service.js +0 -75
  215. package/esm5/lib/place/route/json-types.js +0 -13
  216. package/esm5/lib/place/route/parameter-decorators.js +0 -178
  217. package/esm5/lib/place/route/parameter-definition.class.js +0 -24
  218. package/esm5/lib/place/route/parameter-sanitiser.js +0 -17
  219. package/esm5/lib/place/route/parameter-type.js +0 -65
  220. package/esm5/lib/place/route/route-parameter-bindings.js +0 -339
  221. package/esm5/lib/place/route/route-parameter-sanitiser.js +0 -395
  222. package/esm5/public_api.js +0 -11
  223. package/fesm2015/coolon-angular-ui-powerups.js +0 -3145
  224. package/fesm2015/coolon-angular-ui-powerups.js.map +0 -1
  225. package/fesm5/coolon-angular-ui-powerups.js +0 -3699
  226. package/fesm5/coolon-angular-ui-powerups.js.map +0 -1
  227. package/lib/angular-ui-powerups.module.d.ts +0 -2
  228. package/lib/animations/slideDownAndUpAnimation.d.ts +0 -5
  229. package/lib/components/disposable-component.d.ts +0 -5
  230. package/lib/components/forms/abstract-input.component.d.ts +0 -35
  231. package/lib/components/forms/number-input/number-input.component.d.ts +0 -6
  232. package/lib/components/forms/password-input/password-input.component.d.ts +0 -6
  233. package/lib/components/forms/select-input/select-input.component.d.ts +0 -11
  234. package/lib/components/forms/string-input/string-input.component.d.ts +0 -6
  235. package/lib/components/resize-aware.component.d.ts +0 -22
  236. package/lib/components/types/bounds.class.d.ts +0 -16
  237. package/lib/components/types/dimension.class.d.ts +0 -5
  238. package/lib/components/types/point.class.d.ts +0 -10
  239. package/lib/directives/command.directive.d.ts +0 -14
  240. package/lib/directives/focus-binding.directive.d.ts +0 -22
  241. package/lib/interaction/abstract-activity.d.ts +0 -17
  242. package/lib/interaction/activity.d.ts +0 -11
  243. package/lib/interaction/alert.d.ts +0 -5
  244. package/lib/interaction/components/activity-container/activity-container.component.d.ts +0 -32
  245. package/lib/interaction/components/activity-outlet/activity-outlet.component.d.ts +0 -30
  246. package/lib/interaction/components/alert-dialog/alert-dialog.component.d.ts +0 -8
  247. package/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.d.ts +0 -9
  248. package/lib/interaction/interaction-context.d.ts +0 -11
  249. package/lib/interaction/interaction.module.d.ts +0 -2
  250. package/lib/interaction/result.d.ts +0 -8
  251. package/lib/interaction/services/dialog-interaction.service.d.ts +0 -14
  252. package/lib/place/abstract-place-component.d.ts +0 -13
  253. package/lib/place/components/busy-overlay/busy-overlay.component.d.ts +0 -8
  254. package/lib/place/components/empty-state/empty-state.component.d.ts +0 -5
  255. package/lib/place/components/place-outlet/place-outlet.component.d.ts +0 -13
  256. package/lib/place/components/place-outlet/route-animations.d.ts +0 -1
  257. package/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.d.ts +0 -11
  258. package/lib/place/guards/leave-place.guard.d.ts +0 -10
  259. package/lib/place/guards/place-route.guard.d.ts +0 -9
  260. package/lib/place/place-component.d.ts +0 -5
  261. package/lib/place/place.decorator.d.ts +0 -20
  262. package/lib/place/place.module.d.ts +0 -2
  263. package/lib/place/place.service.d.ts +0 -8
  264. package/lib/place/route/json-types.d.ts +0 -7
  265. package/lib/place/route/parameter-decorators.d.ts +0 -26
  266. package/lib/place/route/parameter-definition.class.d.ts +0 -11
  267. package/lib/place/route/parameter-type.d.ts +0 -16
  268. package/lib/place/route/route-parameter-bindings.d.ts +0 -18
  269. package/lib/place/route/route-parameter-sanitiser.d.ts +0 -42
  270. package/schematics/ng-add/index.d.ts +0 -2
  271. package/schematics/ng-add/index.js +0 -12
  272. package/schematics/ng-add/index.js.map +0 -1
  273. package/schematics/place-routes/index.d.ts +0 -3
  274. package/schematics/place-routes/index.js +0 -114
  275. package/schematics/place-routes/index.js.map +0 -1
  276. package/schematics/place-routes/place-def.d.ts +0 -34
  277. package/schematics/place-routes/place-def.js +0 -84
  278. package/schematics/place-routes/place-def.js.map +0 -1
  279. package/schematics/place-routes/scanner.d.ts +0 -26
  280. package/schematics/place-routes/scanner.js +0 -125
  281. package/schematics/place-routes/scanner.js.map +0 -1
  282. package/schematics/place-routes/schema.d.ts +0 -7
  283. package/schematics/place-routes/schema.js +0 -3
  284. package/schematics/place-routes/schema.js.map +0 -1
  285. /package/{index.d.ts → src/index.ts} +0 -0
  286. /package/{public_api.d.ts → src/public_api.ts} +0 -0
@@ -0,0 +1,108 @@
1
+ /* tslint:disable:no-input-rename */
2
+ import { EventEmitter, HostListener, Input, OnInit, Output } from '@angular/core';
3
+ import { FormControl, FormGroupDirective, NgForm } from '@angular/forms';
4
+ import { ErrorStateMatcher } from '@angular/material';
5
+ import { Command, DelegatingFormValueModel, ListModel, UseDelegate, ValueModel } from '@coolon/pectin';
6
+ import { DisposableComponent } from '../disposable-component';
7
+
8
+ export abstract class AbstractInputComponent<T> extends DisposableComponent implements OnInit {
9
+
10
+ readonly valueModel = new DelegatingFormValueModel<T>();
11
+
12
+ @Input('valueModel') @UseDelegate()
13
+ set userValueModel(model: ValueModel<T>) {
14
+ this.valueModel.setDelegate(model);
15
+ }
16
+
17
+ @Input() label: string;
18
+ @Input() floatLabel: 'auto' | 'always' | 'never';
19
+ @Input() hint: string;
20
+ @Input() placeholder: string;
21
+
22
+ @Input('command.focus') focusCommand: Command<any>;
23
+ @Input('command.blur') blurCommand: Command<any>;
24
+ @Input('command.enter') enterCommand: Command<any>;
25
+ @Input('command.escape') escapeCommand: Command<any>;
26
+ @Input('command.click') clickCommand: Command<any>;
27
+
28
+ // TODO: fix this.
29
+ // tslint:disable-next-line:no-output-native
30
+ @Output() focus = new EventEmitter();
31
+ // tslint:disable-next-line:no-output-native
32
+ @Output() blur = new EventEmitter();
33
+ // tslint:disable-next-line:no-output-native
34
+ @Output() enterKey = new EventEmitter();
35
+ // tslint:disable-next-line:no-output-native
36
+ @Output() escapeKey = new EventEmitter();
37
+
38
+ readonly errorStateMatcher: ErrorStateMatcher;
39
+
40
+ @HostListener('click')
41
+ notifyClick() {
42
+ this.safelyInvoke(this.clickCommand);
43
+ }
44
+
45
+ @HostListener('focusin')
46
+ notifyFocusIn() {
47
+ this.safelyInvoke(this.focusCommand);
48
+ this.focus.emit();
49
+ }
50
+
51
+ @HostListener('focusout')
52
+ notifyFocusOut() {
53
+ this.safelyInvoke(this.blurCommand);
54
+ this.blur.emit();
55
+ }
56
+
57
+
58
+ notifyEnterKey() {
59
+ this.safelyInvoke(this.enterCommand);
60
+ this.enterKey.emit();
61
+ }
62
+
63
+ notifyEscapeKey() {
64
+ this.safelyInvoke(this.escapeCommand);
65
+ this.escapeKey.emit();
66
+ }
67
+
68
+ protected safelyInvoke(command: Command<any>) {
69
+ if (command && command.enabled.value) {
70
+ command.execute();
71
+ }
72
+ }
73
+
74
+ constructor() {
75
+ super();
76
+ const self = this;
77
+ this.errorStateMatcher = {
78
+ isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
79
+ return self.hasErrors();
80
+ }
81
+ };
82
+ }
83
+
84
+ ngOnInit(): void {
85
+ }
86
+
87
+ isEnabled(): boolean {
88
+ return this.enabled.value;
89
+ }
90
+
91
+ get enabled(): ValueModel<boolean> {
92
+ return this.valueModel.enabled;
93
+ }
94
+
95
+ hasErrors(): boolean {
96
+ return !this.errorList.query().isEmpty();
97
+ }
98
+
99
+ get errorList(): ListModel<string> {
100
+ return this.valueModel.errorList;
101
+ }
102
+
103
+ get firstError() {
104
+ return this.hasErrors() ? this.errorList.value[0] : null;
105
+ }
106
+
107
+
108
+ }
@@ -0,0 +1,15 @@
1
+ <mat-form-field appearance="standard" [floatLabel]="floatLabel">
2
+ <mat-label *ngIf="label">{{label}}</mat-label>
3
+ <input type="number"
4
+ matInput
5
+ placeholder="{{placeholder}}"
6
+ [(ngModel)]="valueModel.value"
7
+ [disabled]="!enabled.value"
8
+ (keydown.enter)="notifyEnterKey()"
9
+ (keydown.escape)="notifyEscapeKey()"
10
+ [pectinFocusBinding]="valueModel"
11
+ [errorStateMatcher]="errorStateMatcher"
12
+ >
13
+ <mat-hint *ngIf="hint">{{hint}}</mat-hint>
14
+ <mat-error *ngIf="hasErrors">{{firstError}}</mat-error>
15
+ </mat-form-field>
@@ -0,0 +1,3 @@
1
+ @import "../scss/mixins";
2
+
3
+ @include mat-form-field-defaults;
@@ -0,0 +1,25 @@
1
+ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { NumberInputComponent } from './number-input.component';
4
+
5
+ describe('NumberInputComponent', () => {
6
+ let component: NumberInputComponent;
7
+ let fixture: ComponentFixture<NumberInputComponent>;
8
+
9
+ beforeEach(async(() => {
10
+ TestBed.configureTestingModule({
11
+ declarations: [ NumberInputComponent ]
12
+ })
13
+ .compileComponents();
14
+ }));
15
+
16
+ beforeEach(() => {
17
+ fixture = TestBed.createComponent(NumberInputComponent);
18
+ component = fixture.componentInstance;
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+ });
@@ -0,0 +1,19 @@
1
+ import { Component, OnInit } from '@angular/core';
2
+ import {AbstractInputComponent} from '../abstract-input.component';
3
+
4
+
5
+ @Component({
6
+ selector: 'angular-ui-powerups-number-input',
7
+ templateUrl: './number-input.component.html',
8
+ styleUrls: ['./number-input.component.scss']
9
+ })
10
+ export class NumberInputComponent extends AbstractInputComponent<string> implements OnInit {
11
+
12
+ constructor() {
13
+ super();
14
+ }
15
+
16
+ ngOnInit() {
17
+ }
18
+
19
+ }
@@ -0,0 +1,16 @@
1
+ <mat-form-field appearance="standard" [floatLabel]="floatLabel">
2
+ <mat-label *ngIf="label">{{label}}</mat-label>
3
+ <input type="password"
4
+ matInput
5
+ placeholder="{{placeholder}}"
6
+ [(ngModel)]="valueModel.value"
7
+ [disabled]="!enabled.value"
8
+ (keydown.enter)="notifyEnterKey()"
9
+ (keydown.escape)="notifyEscapeKey()"
10
+ [pectinFocusBinding]="valueModel"
11
+ [errorStateMatcher]="errorStateMatcher"
12
+ >
13
+ <mat-hint *ngIf="hint">{{hint}}</mat-hint>
14
+ <mat-error *ngIf="hasErrors">{{firstError}}</mat-error>
15
+ </mat-form-field>
16
+
@@ -0,0 +1,3 @@
1
+ @import "../scss/mixins";
2
+
3
+ @include mat-form-field-defaults;
@@ -0,0 +1,25 @@
1
+ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { PasswordInputComponent } from './password-input.component';
4
+
5
+ describe('PasswordInputComponent', () => {
6
+ let component: PasswordInputComponent;
7
+ let fixture: ComponentFixture<PasswordInputComponent>;
8
+
9
+ beforeEach(async(() => {
10
+ TestBed.configureTestingModule({
11
+ declarations: [ PasswordInputComponent ]
12
+ })
13
+ .compileComponents();
14
+ }));
15
+
16
+ beforeEach(() => {
17
+ fixture = TestBed.createComponent(PasswordInputComponent);
18
+ component = fixture.componentInstance;
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+ });
@@ -0,0 +1,18 @@
1
+ import {Component, OnInit} from '@angular/core';
2
+ import {AbstractInputComponent} from '../abstract-input.component';
3
+
4
+ @Component({
5
+ selector: 'angular-ui-powerups-password-input',
6
+ templateUrl: './password-input.component.html',
7
+ styleUrls: ['./password-input.component.scss']
8
+ })
9
+ export class PasswordInputComponent extends AbstractInputComponent<string> implements OnInit {
10
+
11
+ constructor() {
12
+ super();
13
+ }
14
+
15
+ ngOnInit() {
16
+ }
17
+
18
+ }
@@ -0,0 +1,16 @@
1
+ @import '../../../../../../../node_modules/@angular/material/theming';
2
+
3
+ @mixin mat-form-field-defaults {
4
+
5
+ :host {
6
+ display: block;
7
+ }
8
+
9
+ mat-form-field, input {
10
+ width: 100%;
11
+
12
+ mat-hint.faux-error {
13
+ color: mat-color(mat-palette($mat-red));
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,16 @@
1
+ <mat-form-field appearance="standard" [floatLabel]="floatLabel">
2
+ <mat-label *ngIf="label">{{label}}</mat-label>
3
+ <mat-select placeholder="{{placeholder}}"
4
+ [(ngModel)]="valueModel.value"
5
+ [disabled]="!enabled.value"
6
+ (keydown.enter)="notifyEnterKey()"
7
+ (keydown.escape)="notifyEscapeKey()"
8
+ [pectinFocusBinding]="valueModel"
9
+ [errorStateMatcher]="errorStateMatcher"
10
+ >
11
+ <mat-option *ngFor="let option of optionsModel.value" [value]="option">{{optionLabelFormat(option)}}
12
+ </mat-option>
13
+ </mat-select>
14
+ <mat-hint *ngIf="hint">{{hint}}</mat-hint>
15
+ <mat-error *ngIf="hasErrors">{{firstError}}</mat-error>
16
+ </mat-form-field>
@@ -0,0 +1,7 @@
1
+ :host {
2
+ display: inline-block;
3
+ }
4
+
5
+ mat-form-field {
6
+ width: 100%;
7
+ }
@@ -0,0 +1,25 @@
1
+ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { SelectInputComponent } from './select-input.component';
4
+
5
+ describe('SelectInputComponent', () => {
6
+ let component: SelectInputComponent;
7
+ let fixture: ComponentFixture<SelectInputComponent>;
8
+
9
+ beforeEach(async(() => {
10
+ TestBed.configureTestingModule({
11
+ declarations: [ SelectInputComponent ]
12
+ })
13
+ .compileComponents();
14
+ }));
15
+
16
+ beforeEach(() => {
17
+ fixture = TestBed.createComponent(SelectInputComponent);
18
+ component = fixture.componentInstance;
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+ });
@@ -0,0 +1,31 @@
1
+ import { Component, Input, OnInit } from '@angular/core';
2
+ import { ListModel, StoreInListModel, UseDelegate } from '@coolon/pectin';
3
+ import { AbstractInputComponent } from '../abstract-input.component';
4
+
5
+ @Component({
6
+ selector: 'angular-ui-powerups-select-input',
7
+ templateUrl: './select-input.component.html',
8
+ styleUrls: ['./select-input.component.scss']
9
+ })
10
+ export class SelectInputComponent<T = any> extends AbstractInputComponent<T> implements OnInit {
11
+
12
+ @Input() @UseDelegate()
13
+ optionsModel: ListModel<T>;
14
+
15
+ @Input() @StoreInListModel('optionsModel')
16
+ options: T[];
17
+
18
+ @Input()
19
+ optionLabel: keyof T;
20
+
21
+ @Input()
22
+ optionLabelFormat: (option: T) => any = (option) => (option && this.optionLabel) ? option[this.optionLabel] : option;
23
+
24
+ constructor() {
25
+ super();
26
+ }
27
+
28
+ ngOnInit() {
29
+ }
30
+
31
+ }
@@ -0,0 +1,15 @@
1
+ <mat-form-field appearance="standard" [floatLabel]="floatLabel">
2
+ <mat-label *ngIf="label">{{label}}</mat-label>
3
+ <input matInput
4
+ placeholder="{{placeholder}}"
5
+ [(ngModel)]="valueModel.value"
6
+ [disabled]="!enabled.value"
7
+ (keydown.enter)="notifyEnterKey()"
8
+ (keydown.escape)="notifyEscapeKey()"
9
+ [pectinFocusBinding]="valueModel"
10
+ [errorStateMatcher]="errorStateMatcher"
11
+ >
12
+ <mat-hint *ngIf="hint">{{hint}}</mat-hint>
13
+ <mat-error *ngIf="hasErrors">{{firstError}}</mat-error>
14
+ </mat-form-field>
15
+
@@ -0,0 +1,3 @@
1
+ @import "../scss/mixins";
2
+
3
+ @include mat-form-field-defaults;
@@ -0,0 +1,25 @@
1
+ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { StringInputComponent } from './string-input.component';
4
+
5
+ describe('StringInputComponent', () => {
6
+ let component: StringInputComponent;
7
+ let fixture: ComponentFixture<StringInputComponent>;
8
+
9
+ beforeEach(async(() => {
10
+ TestBed.configureTestingModule({
11
+ declarations: [ StringInputComponent ]
12
+ })
13
+ .compileComponents();
14
+ }));
15
+
16
+ beforeEach(() => {
17
+ fixture = TestBed.createComponent(StringInputComponent);
18
+ component = fixture.componentInstance;
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+ });
@@ -0,0 +1,18 @@
1
+ import {Component, OnInit} from '@angular/core';
2
+ import {AbstractInputComponent} from '../abstract-input.component';
3
+
4
+ @Component({
5
+ selector: 'angular-ui-powerups-string-input',
6
+ templateUrl: './string-input.component.html',
7
+ styleUrls: ['./string-input.component.scss']
8
+ })
9
+ export class StringInputComponent extends AbstractInputComponent<string> implements OnInit {
10
+
11
+ constructor() {
12
+ super();
13
+ }
14
+
15
+ ngOnInit() {
16
+ }
17
+
18
+ }
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @file Automatically generated by barrelsby.
3
3
  */
4
+
4
5
  export * from "./disposable-component";
5
6
  export * from "./resize-aware.component";
6
7
  export * from "./forms/abstract-input.component";
@@ -0,0 +1,52 @@
1
+ import {AfterViewInit, ElementRef, NgZone} from '@angular/core';
2
+ import {ValueHolder, ValueModel} from '@coolon/pectin';
3
+ import ResizeObserver from 'resize-observer-polyfill';
4
+ import {DisposableComponent} from './disposable-component';
5
+ import {Bounds} from './types/bounds.class';
6
+ import {Point} from './types/point.class';
7
+
8
+ export class ResizeAwareComponent extends DisposableComponent implements AfterViewInit {
9
+
10
+ private _boundsModel = new ValueHolder<Bounds>(new Bounds(0, 0, 0, 0));
11
+
12
+ constructor(protected readonly elementRef: ElementRef, protected readonly ngZone: NgZone) {
13
+ super();
14
+ }
15
+
16
+ ngAfterViewInit(): void {
17
+ this.updateBounds();
18
+ const element = this.elementRef.nativeElement;
19
+ const ro = new ResizeObserver((entries, observer) => {
20
+ this.ngZone.run(() => this.updateBounds());
21
+ });
22
+ ro.observe(element);
23
+ this.onDispose(() => ro.disconnect());
24
+ }
25
+
26
+ get boundsModel(): ValueModel<Bounds> {
27
+ return this._boundsModel.readonly;
28
+ }
29
+
30
+ get nativeElement() {
31
+ return this.elementRef.nativeElement;
32
+ }
33
+
34
+ // TODO: Make this handle body scroll
35
+ public relativePositionOf(point: { x: number, y: number } | MouseEvent): Point {
36
+ return this.bounds.relativePositionOf(point);
37
+ }
38
+
39
+ get bounds(): Bounds {
40
+ return this._boundsModel.value;
41
+ }
42
+
43
+ private updateBounds() {
44
+ this._boundsModel.value = Bounds.ofElement(this.nativeElement);
45
+ }
46
+
47
+
48
+ }
49
+
50
+ export namespace ResizeAwareComponent {
51
+
52
+ }
@@ -0,0 +1,25 @@
1
+ import { Dimension } from './dimension.class';
2
+ import { Point } from './point.class';
3
+
4
+ export class Bounds extends Dimension {
5
+
6
+ constructor(readonly top: number, readonly left: number, readonly width: number, readonly height: number) {
7
+ super(width, height);
8
+ }
9
+
10
+ relativePositionOf(point: { x: number, y: number } | MouseEvent) {
11
+ if (point instanceof MouseEvent) {
12
+ return new Point(point.clientX - this.left, point.clientY - this.top);
13
+ } else {
14
+ return new Point(point.x - this.left, point.y - this.top);
15
+ }
16
+ }
17
+ }
18
+
19
+ export namespace Bounds {
20
+ export function ofElement(element: HTMLElement): Bounds {
21
+ const rect = element.getBoundingClientRect();
22
+ return new Bounds(rect.top, rect.left, rect.width, rect.height);
23
+ }
24
+ }
25
+
@@ -0,0 +1,3 @@
1
+ export class Dimension {
2
+ constructor(readonly width: number, readonly height: number){}
3
+ }
@@ -0,0 +1,13 @@
1
+ export class Point {
2
+
3
+ static from(data: { x: number, y: number }) {
4
+ return new Point(data.x, data.y);
5
+ }
6
+
7
+ constructor(readonly x: number, readonly y: number) {
8
+ }
9
+
10
+ translate(x: number, y: number): Point {
11
+ return new Point(this.x + x, this.y + y);
12
+ }
13
+ }
@@ -0,0 +1,73 @@
1
+ import { Component } from '@angular/core';
2
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
3
+ import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
4
+ import { Command, UnaryCommand } from '@coolon/pectin';
5
+ import { CommandDirective } from './command.directive';
6
+
7
+ @Component({
8
+ template: `
9
+ <button [pectinCommand]="command" ]>Click</button>`
10
+ })
11
+ class UnaryCommandWithoutParameterErrorComponent {
12
+ command = UnaryCommand.create((value) => 'boo');
13
+ }
14
+
15
+ TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
16
+
17
+ describe('CommandDirective', () => {
18
+
19
+ describe('Command', () => {
20
+
21
+ describe('with command parameter', () => {
22
+ it('barfs', async () => {
23
+ @Component({
24
+ template: `
25
+ <button [pectinCommand]="command" [commandParameter]="'arg'">Click</button>`
26
+ })
27
+ class CommandWithParameterErrorComponent {
28
+ command = Command.create(() => 'boo');
29
+ }
30
+ await TestBed.configureTestingModule({
31
+ declarations: [
32
+ CommandDirective,
33
+ CommandWithParameterErrorComponent
34
+ ]
35
+ }).compileComponents();
36
+ expect(() => TestBed.createComponent(CommandWithParameterErrorComponent)).toThrow();
37
+ });
38
+ });
39
+
40
+ describe('with correct bindings', () => {
41
+ @Component({
42
+ template: `
43
+ <button [pectinCommand]="command">Click</button>`
44
+ })
45
+ class CommandTestComponent {
46
+ command = Command.create(() => 'boo');
47
+ }
48
+
49
+ let fixture: ComponentFixture<CommandTestComponent>;
50
+ let component: CommandTestComponent;
51
+
52
+ beforeEach(async () => {
53
+ await TestBed.configureTestingModule({
54
+ declarations: [
55
+ CommandDirective,
56
+ CommandTestComponent
57
+ ]
58
+ }).compileComponents();
59
+
60
+ fixture = TestBed.createComponent(CommandTestComponent);
61
+ component = fixture.componentInstance;
62
+ });
63
+
64
+ it('creates the component', () => {
65
+ expect(component).toBeDefined();
66
+ });
67
+ });
68
+
69
+
70
+ });
71
+
72
+
73
+ });
@@ -0,0 +1,81 @@
1
+ import { AfterViewInit, Directive, ElementRef, HostListener, Inject, Input, OnDestroy, OnInit } from '@angular/core';
2
+ import { assert, Command, Dsl, GarbageCollector, lang, UnaryCommand } from '@coolon/pectin';
3
+
4
+ @Directive({
5
+ // tslint:disable-next-line:directive-selector
6
+ selector: '[pectinCommand]'
7
+ })
8
+ export class CommandDirective<P = any> extends GarbageCollector implements OnInit, OnDestroy, AfterViewInit {
9
+
10
+ @Input()
11
+ pectinCommand: Command<any> | UnaryCommand<P>;
12
+
13
+ private _commandParameter:P;
14
+ private _commandParameterProvided = false;
15
+
16
+ @Input()
17
+ set commandParameter(value: P) {
18
+ this._commandParameterProvided = true;
19
+ this._commandParameter = value;
20
+ }
21
+
22
+ get commandParameter(): P {
23
+ return this._commandParameter;
24
+ }
25
+
26
+ constructor(@Inject(ElementRef) private elementRef: ElementRef) {
27
+ super();
28
+ }
29
+
30
+ ngOnInit(): void {
31
+ assert.notNil(this.pectinCommand);
32
+ if (this.pectinCommand instanceof UnaryCommand) {
33
+ if (!this._commandParameterProvided) {
34
+ lang.illegalState('UnaryCommands required the command parameter to be specified.');
35
+ }
36
+ } else {
37
+ if (this._commandParameterProvided) {
38
+ lang.illegalState('command parameters are only supported by UnaryCommands');
39
+ }
40
+ }
41
+ }
42
+
43
+ ngAfterViewInit(): void {
44
+ // for some reason mat-buttons kills the disabled host binding. It works on a regular button but for now
45
+ // we need to do this.
46
+ const { chain } = Dsl.disposeWith(this);
47
+ chain(this.pectinCommand.enabled).subscribe(enabled => {
48
+ if (enabled) {
49
+ this.elementRef.nativeElement.removeAttribute('disabled');
50
+ if (this.elementRef.nativeElement.tagName === 'A') {
51
+ this.elementRef.nativeElement.setAttribute('href', 'javascript:void');
52
+ }
53
+ } else {
54
+ this.elementRef.nativeElement.setAttribute('disabled', 'disabled');
55
+ if (this.elementRef.nativeElement.tagName === 'A') {
56
+ this.elementRef.nativeElement.removeAttribute('href');
57
+ }
58
+ }
59
+ });
60
+ }
61
+
62
+ ngOnDestroy(): void {
63
+ this.dispose();
64
+ }
65
+
66
+
67
+ @HostListener('click', ['$event'])
68
+ notifyClick($event: Event) {
69
+ $event.preventDefault();
70
+ $event.stopPropagation();
71
+ if (this.pectinCommand.enabled.value) {
72
+ if (this.pectinCommand instanceof UnaryCommand) {
73
+ this.pectinCommand.withContext({ event: $event }).execute(this.commandParameter);
74
+ } else {
75
+ this.pectinCommand.withContext({ event: $event }).execute();
76
+ }
77
+ } else {
78
+ console.warn('disabled command clicked, ignoring.');
79
+ }
80
+ }
81
+ }