@coolon/angular-ui-powerups 1.10.0 → 1.11.0

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 (231) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/assets/styles.scss +7 -67
  3. package/bundles/coolon-angular-ui-powerups.umd.js +2649 -1623
  4. package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
  5. package/bundles/coolon-angular-ui-powerups.umd.min.js +2 -2
  6. package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
  7. package/coolon-angular-ui-powerups.d.ts +57 -44
  8. package/coolon-angular-ui-powerups.metadata.json +1 -1
  9. package/esm2015/coolon-angular-ui-powerups.js +55 -42
  10. package/esm2015/coolon-angular-ui-powerups.js.map +1 -1
  11. package/esm2015/coolon-angular-ui-powerups.metadata.json +1 -1
  12. package/esm2015/lib/angular-ui-powerups.module.ngfactory.js.map +1 -1
  13. package/esm2015/lib/components/card-container/card-container.component.js +1 -1
  14. package/esm2015/lib/components/card-container/card-container.component.metadata.json +1 -1
  15. package/esm2015/lib/components/components.module.js +37 -6
  16. package/esm2015/lib/components/components.module.js.map +1 -1
  17. package/esm2015/lib/components/components.module.metadata.json +1 -1
  18. package/esm2015/lib/components/components.module.ngfactory.js.map +1 -1
  19. package/esm2015/lib/components/forms/abstract-input-activity.js +47 -0
  20. package/esm2015/lib/components/forms/abstract-input-activity.js.map +1 -0
  21. package/esm2015/lib/components/forms/abstract-input-activity.metadata.json +1 -0
  22. package/esm2015/lib/components/forms/abstract-input-activity.ngfactory.js.map +1 -0
  23. package/esm2015/lib/components/forms/abstract-input.component.js +6 -1
  24. package/esm2015/lib/components/forms/abstract-input.component.js.map +1 -1
  25. package/esm2015/lib/components/forms/abstract-input.component.metadata.json +1 -1
  26. package/esm2015/lib/components/forms/number-input/number-input.component.js +1 -1
  27. package/esm2015/lib/components/forms/number-input/number-input.component.metadata.json +1 -1
  28. package/esm2015/lib/components/forms/password-input/password-input.component.js +1 -1
  29. package/esm2015/lib/components/forms/password-input/password-input.component.metadata.json +1 -1
  30. package/esm2015/lib/components/forms/string-input/string-input-activity.js +22 -0
  31. package/esm2015/lib/components/forms/string-input/string-input-activity.js.map +1 -0
  32. package/esm2015/lib/components/forms/string-input/string-input-activity.metadata.json +1 -0
  33. package/esm2015/lib/components/forms/string-input/string-input-activity.ngfactory.js.map +1 -0
  34. package/esm2015/lib/components/forms/string-input/string-input.component.js +1 -1
  35. package/esm2015/lib/components/forms/string-input/string-input.component.metadata.json +1 -1
  36. package/esm2015/lib/components/forms/text-input/text-input.component.js +1 -1
  37. package/esm2015/lib/components/forms/text-input/text-input.component.metadata.json +1 -1
  38. package/esm2015/lib/components/index.js +13 -0
  39. package/esm2015/lib/components/index.js.map +1 -1
  40. package/esm2015/lib/components/index.metadata.json +1 -1
  41. package/esm2015/lib/components/table/cell-editor.component.js +1 -0
  42. package/esm2015/lib/components/table/cell-editor.component.js.map +1 -0
  43. package/esm2015/lib/components/table/cell-editor.component.metadata.json +1 -0
  44. package/esm2015/lib/components/table/cell-renderer.js +1 -0
  45. package/esm2015/lib/components/table/cell-renderer.js.map +1 -0
  46. package/esm2015/lib/components/table/cell-renderer.metadata.json +1 -0
  47. package/esm2015/lib/components/table/column-model.js +160 -0
  48. package/esm2015/lib/components/table/column-model.js.map +1 -0
  49. package/esm2015/lib/components/table/column-model.metadata.json +1 -0
  50. package/esm2015/lib/components/table/column-template/column-template.directive.js +24 -0
  51. package/esm2015/lib/components/table/column-template/column-template.directive.js.map +1 -0
  52. package/esm2015/lib/components/table/column-template/column-template.directive.metadata.json +1 -0
  53. package/esm2015/lib/components/table/column-template/column-template.directive.ngfactory.js.map +1 -0
  54. package/esm2015/lib/components/table/column-text-properties.js +1 -0
  55. package/esm2015/lib/components/table/column-text-properties.js.map +1 -0
  56. package/esm2015/lib/components/table/column-text-properties.metadata.json +1 -0
  57. package/esm2015/lib/components/table/default-cell-renderer/default-cell-renderer.component.js +27 -0
  58. package/esm2015/lib/components/table/default-cell-renderer/default-cell-renderer.component.js.map +1 -0
  59. package/esm2015/lib/components/table/default-cell-renderer/default-cell-renderer.component.metadata.json +1 -0
  60. package/esm2015/lib/components/table/default-cell-renderer/default-cell-renderer.component.ngfactory.js.map +1 -0
  61. package/esm2015/lib/components/table/default-cell-renderer/default-cell-renderer.component.scss.shim.ngstyle.js.map +1 -0
  62. package/esm2015/lib/components/table/default-header-cell-renderer/default-header-cell-renderer.component.js +21 -0
  63. package/esm2015/lib/components/table/default-header-cell-renderer/default-header-cell-renderer.component.js.map +1 -0
  64. package/esm2015/lib/components/table/default-header-cell-renderer/default-header-cell-renderer.component.metadata.json +1 -0
  65. package/esm2015/lib/components/table/default-header-cell-renderer/default-header-cell-renderer.component.ngfactory.js.map +1 -0
  66. package/esm2015/lib/components/table/default-header-cell-renderer/default-header-cell-renderer.component.scss.shim.ngstyle.js.map +1 -0
  67. package/esm2015/lib/components/table/edit-row-controls/edit-row-controls.component.js +50 -0
  68. package/esm2015/lib/components/table/edit-row-controls/edit-row-controls.component.js.map +1 -0
  69. package/esm2015/lib/components/table/edit-row-controls/edit-row-controls.component.metadata.json +1 -0
  70. package/esm2015/lib/components/table/edit-row-controls/edit-row-controls.component.ngfactory.js.map +1 -0
  71. package/esm2015/lib/components/table/edit-row-controls/edit-row-controls.component.scss.shim.ngstyle.js.map +1 -0
  72. package/esm2015/lib/components/table/select-cell-renderer/select-cell-renderer.component.js +40 -0
  73. package/esm2015/lib/components/table/select-cell-renderer/select-cell-renderer.component.js.map +1 -0
  74. package/esm2015/lib/components/table/select-cell-renderer/select-cell-renderer.component.metadata.json +1 -0
  75. package/esm2015/lib/components/table/select-cell-renderer/select-cell-renderer.component.ngfactory.js.map +1 -0
  76. package/esm2015/lib/components/table/select-cell-renderer/select-cell-renderer.component.scss.shim.ngstyle.js.map +1 -0
  77. package/esm2015/lib/components/table/select-header-cell-renderer/select-header-cell-renderer.component.js +32 -0
  78. package/esm2015/lib/components/table/select-header-cell-renderer/select-header-cell-renderer.component.js.map +1 -0
  79. package/esm2015/lib/components/table/select-header-cell-renderer/select-header-cell-renderer.component.metadata.json +1 -0
  80. package/esm2015/lib/components/table/select-header-cell-renderer/select-header-cell-renderer.component.ngfactory.js.map +1 -0
  81. package/esm2015/lib/components/table/select-header-cell-renderer/select-header-cell-renderer.component.scss.shim.ngstyle.js.map +1 -0
  82. package/esm2015/lib/components/table/table-cell-renderer/table-cell-renderer.component.js +64 -0
  83. package/esm2015/lib/components/table/table-cell-renderer/table-cell-renderer.component.js.map +1 -0
  84. package/esm2015/lib/components/table/table-cell-renderer/table-cell-renderer.component.metadata.json +1 -0
  85. package/esm2015/lib/components/table/table-cell-renderer/table-cell-renderer.component.ngfactory.js.map +1 -0
  86. package/esm2015/lib/components/table/table-cell-renderer/table-cell-renderer.component.scss.shim.ngstyle.js.map +1 -0
  87. package/esm2015/lib/components/table/table-def.js +1 -0
  88. package/esm2015/lib/components/table/table-def.js.map +1 -0
  89. package/esm2015/lib/components/table/table-def.metadata.json +1 -0
  90. package/esm2015/lib/components/table/table-header-cell-renderer/table-header-cell-renderer.component.js +32 -0
  91. package/esm2015/lib/components/table/table-header-cell-renderer/table-header-cell-renderer.component.js.map +1 -0
  92. package/esm2015/lib/components/table/table-header-cell-renderer/table-header-cell-renderer.component.metadata.json +1 -0
  93. package/esm2015/lib/components/table/table-header-cell-renderer/table-header-cell-renderer.component.ngfactory.js.map +1 -0
  94. package/esm2015/lib/components/table/table-header-cell-renderer/table-header-cell-renderer.component.scss.shim.ngstyle.js.map +1 -0
  95. package/esm2015/lib/components/table/table-model.js +197 -0
  96. package/esm2015/lib/components/table/table-model.js.map +1 -0
  97. package/esm2015/lib/components/table/table-model.metadata.json +1 -0
  98. package/esm2015/lib/components/table/table.component.js +60 -0
  99. package/esm2015/lib/components/table/table.component.js.map +1 -0
  100. package/esm2015/lib/components/table/table.component.metadata.json +1 -0
  101. package/esm2015/lib/components/table/table.component.ngfactory.js.map +1 -0
  102. package/esm2015/lib/components/table/table.component.scss.shim.ngstyle.js.map +1 -0
  103. package/esm2015/lib/interaction/activity.js +7 -1
  104. package/esm2015/lib/interaction/activity.js.map +1 -1
  105. package/esm2015/lib/interaction/activity.metadata.json +1 -1
  106. package/esm2015/lib/interaction/components/popup-interaction-context/popup-interaction-context.component.js +87 -0
  107. package/esm2015/lib/interaction/components/popup-interaction-context/popup-interaction-context.component.js.map +1 -0
  108. package/esm2015/lib/interaction/components/popup-interaction-context/popup-interaction-context.component.metadata.json +1 -0
  109. package/esm2015/lib/interaction/components/popup-interaction-context/popup-interaction-context.component.ngfactory.js.map +1 -0
  110. package/esm2015/lib/interaction/components/popup-interaction-context/popup-interaction-context.component.scss.shim.ngstyle.js.map +1 -0
  111. package/esm2015/lib/interaction/directives/interaction-context-trigger-for.directive.js +86 -0
  112. package/esm2015/lib/interaction/directives/interaction-context-trigger-for.directive.js.map +1 -0
  113. package/esm2015/lib/interaction/directives/interaction-context-trigger-for.directive.metadata.json +1 -0
  114. package/esm2015/lib/interaction/directives/interaction-context-trigger-for.directive.ngfactory.js.map +1 -0
  115. package/esm2015/lib/interaction/index.js +2 -0
  116. package/esm2015/lib/interaction/index.js.map +1 -1
  117. package/esm2015/lib/interaction/index.metadata.json +1 -1
  118. package/esm2015/lib/interaction/interaction.module.js +12 -3
  119. package/esm2015/lib/interaction/interaction.module.js.map +1 -1
  120. package/esm2015/lib/interaction/interaction.module.metadata.json +1 -1
  121. package/esm2015/lib/interaction/interaction.module.ngfactory.js.map +1 -1
  122. package/esm5/coolon-angular-ui-powerups.js +55 -42
  123. package/esm5/coolon-angular-ui-powerups.js.map +1 -1
  124. package/esm5/lib/angular-ui-powerups.module.ngfactory.js.map +1 -1
  125. package/esm5/lib/components/card-container/card-container.component.js +1 -1
  126. package/esm5/lib/components/components.module.js +37 -6
  127. package/esm5/lib/components/components.module.js.map +1 -1
  128. package/esm5/lib/components/components.module.ngfactory.js.map +1 -1
  129. package/esm5/lib/components/forms/abstract-input-activity.js +50 -0
  130. package/esm5/lib/components/forms/abstract-input-activity.js.map +1 -0
  131. package/esm5/lib/components/forms/abstract-input-activity.ngfactory.js.map +1 -0
  132. package/esm5/lib/components/forms/abstract-input.component.js +6 -1
  133. package/esm5/lib/components/forms/abstract-input.component.js.map +1 -1
  134. package/esm5/lib/components/forms/number-input/number-input.component.js +1 -1
  135. package/esm5/lib/components/forms/password-input/password-input.component.js +1 -1
  136. package/esm5/lib/components/forms/string-input/string-input-activity.js +18 -0
  137. package/esm5/lib/components/forms/string-input/string-input-activity.js.map +1 -0
  138. package/esm5/lib/components/forms/string-input/string-input-activity.ngfactory.js.map +1 -0
  139. package/esm5/lib/components/forms/string-input/string-input.component.js +1 -1
  140. package/esm5/lib/components/forms/text-input/text-input.component.js +1 -1
  141. package/esm5/lib/components/index.js +13 -0
  142. package/esm5/lib/components/index.js.map +1 -1
  143. package/esm5/lib/components/table/cell-editor.component.js +1 -0
  144. package/esm5/lib/components/table/cell-editor.component.js.map +1 -0
  145. package/esm5/lib/components/table/cell-renderer.js +1 -0
  146. package/esm5/lib/components/table/cell-renderer.js.map +1 -0
  147. package/esm5/lib/components/table/column-model.js +196 -0
  148. package/esm5/lib/components/table/column-model.js.map +1 -0
  149. package/esm5/lib/components/table/column-template/column-template.directive.js +25 -0
  150. package/esm5/lib/components/table/column-template/column-template.directive.js.map +1 -0
  151. package/esm5/lib/components/table/column-template/column-template.directive.ngfactory.js.map +1 -0
  152. package/esm5/lib/components/table/column-text-properties.js +1 -0
  153. package/esm5/lib/components/table/column-text-properties.js.map +1 -0
  154. package/esm5/lib/components/table/default-cell-renderer/default-cell-renderer.component.js +32 -0
  155. package/esm5/lib/components/table/default-cell-renderer/default-cell-renderer.component.js.map +1 -0
  156. package/esm5/lib/components/table/default-cell-renderer/default-cell-renderer.component.ngfactory.js.map +1 -0
  157. package/esm5/lib/components/table/default-cell-renderer/default-cell-renderer.component.scss.shim.ngstyle.js.map +1 -0
  158. package/esm5/lib/components/table/default-header-cell-renderer/default-header-cell-renderer.component.js +22 -0
  159. package/esm5/lib/components/table/default-header-cell-renderer/default-header-cell-renderer.component.js.map +1 -0
  160. package/esm5/lib/components/table/default-header-cell-renderer/default-header-cell-renderer.component.ngfactory.js.map +1 -0
  161. package/esm5/lib/components/table/default-header-cell-renderer/default-header-cell-renderer.component.scss.shim.ngstyle.js.map +1 -0
  162. package/esm5/lib/components/table/edit-row-controls/edit-row-controls.component.js +57 -0
  163. package/esm5/lib/components/table/edit-row-controls/edit-row-controls.component.js.map +1 -0
  164. package/esm5/lib/components/table/edit-row-controls/edit-row-controls.component.ngfactory.js.map +1 -0
  165. package/esm5/lib/components/table/edit-row-controls/edit-row-controls.component.scss.shim.ngstyle.js.map +1 -0
  166. package/esm5/lib/components/table/select-cell-renderer/select-cell-renderer.component.js +47 -0
  167. package/esm5/lib/components/table/select-cell-renderer/select-cell-renderer.component.js.map +1 -0
  168. package/esm5/lib/components/table/select-cell-renderer/select-cell-renderer.component.ngfactory.js.map +1 -0
  169. package/esm5/lib/components/table/select-cell-renderer/select-cell-renderer.component.scss.shim.ngstyle.js.map +1 -0
  170. package/esm5/lib/components/table/select-header-cell-renderer/select-header-cell-renderer.component.js +35 -0
  171. package/esm5/lib/components/table/select-header-cell-renderer/select-header-cell-renderer.component.js.map +1 -0
  172. package/esm5/lib/components/table/select-header-cell-renderer/select-header-cell-renderer.component.ngfactory.js.map +1 -0
  173. package/esm5/lib/components/table/select-header-cell-renderer/select-header-cell-renderer.component.scss.shim.ngstyle.js.map +1 -0
  174. package/esm5/lib/components/table/table-cell-renderer/table-cell-renderer.component.js +66 -0
  175. package/esm5/lib/components/table/table-cell-renderer/table-cell-renderer.component.js.map +1 -0
  176. package/esm5/lib/components/table/table-cell-renderer/table-cell-renderer.component.ngfactory.js.map +1 -0
  177. package/esm5/lib/components/table/table-cell-renderer/table-cell-renderer.component.scss.shim.ngstyle.js.map +1 -0
  178. package/esm5/lib/components/table/table-def.js +1 -0
  179. package/esm5/lib/components/table/table-def.js.map +1 -0
  180. package/esm5/lib/components/table/table-header-cell-renderer/table-header-cell-renderer.component.js +33 -0
  181. package/esm5/lib/components/table/table-header-cell-renderer/table-header-cell-renderer.component.js.map +1 -0
  182. package/esm5/lib/components/table/table-header-cell-renderer/table-header-cell-renderer.component.ngfactory.js.map +1 -0
  183. package/esm5/lib/components/table/table-header-cell-renderer/table-header-cell-renderer.component.scss.shim.ngstyle.js.map +1 -0
  184. package/esm5/lib/components/table/table-model.js +213 -0
  185. package/esm5/lib/components/table/table-model.js.map +1 -0
  186. package/esm5/lib/components/table/table.component.js +62 -0
  187. package/esm5/lib/components/table/table.component.js.map +1 -0
  188. package/esm5/lib/components/table/table.component.ngfactory.js.map +1 -0
  189. package/esm5/lib/components/table/table.component.scss.shim.ngstyle.js.map +1 -0
  190. package/esm5/lib/interaction/activity.js +7 -2
  191. package/esm5/lib/interaction/activity.js.map +1 -1
  192. package/esm5/lib/interaction/components/popup-interaction-context/popup-interaction-context.component.js +95 -0
  193. package/esm5/lib/interaction/components/popup-interaction-context/popup-interaction-context.component.js.map +1 -0
  194. package/esm5/lib/interaction/components/popup-interaction-context/popup-interaction-context.component.ngfactory.js.map +1 -0
  195. package/esm5/lib/interaction/components/popup-interaction-context/popup-interaction-context.component.scss.shim.ngstyle.js.map +1 -0
  196. package/esm5/lib/interaction/directives/interaction-context-trigger-for.directive.js +90 -0
  197. package/esm5/lib/interaction/directives/interaction-context-trigger-for.directive.js.map +1 -0
  198. package/esm5/lib/interaction/directives/interaction-context-trigger-for.directive.ngfactory.js.map +1 -0
  199. package/esm5/lib/interaction/index.js +2 -0
  200. package/esm5/lib/interaction/index.js.map +1 -1
  201. package/esm5/lib/interaction/interaction.module.js +12 -3
  202. package/esm5/lib/interaction/interaction.module.js.map +1 -1
  203. package/esm5/lib/interaction/interaction.module.ngfactory.js.map +1 -1
  204. package/fesm2015/coolon-angular-ui-powerups.js +2280 -1372
  205. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  206. package/fesm5/coolon-angular-ui-powerups.js +2561 -1567
  207. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  208. package/lib/components/forms/abstract-input-activity.d.ts +18 -0
  209. package/lib/components/forms/abstract-input.component.d.ts +1 -0
  210. package/lib/components/forms/string-input/string-input-activity.d.ts +3 -0
  211. package/lib/components/index.d.ts +17 -0
  212. package/lib/components/table/cell-editor.component.d.ts +5 -0
  213. package/lib/components/table/cell-renderer.d.ts +3 -0
  214. package/lib/components/table/column-model.d.ts +84 -0
  215. package/lib/components/table/column-template/column-template.directive.d.ts +7 -0
  216. package/lib/components/table/column-text-properties.d.ts +3 -0
  217. package/lib/components/table/default-cell-renderer/default-cell-renderer.component.d.ts +6 -0
  218. package/lib/components/table/default-header-cell-renderer/default-header-cell-renderer.component.d.ts +5 -0
  219. package/lib/components/table/edit-row-controls/edit-row-controls.component.d.ts +14 -0
  220. package/lib/components/table/select-cell-renderer/select-cell-renderer.component.d.ts +11 -0
  221. package/lib/components/table/select-header-cell-renderer/select-header-cell-renderer.component.d.ts +9 -0
  222. package/lib/components/table/table-cell-renderer/table-cell-renderer.component.d.ts +18 -0
  223. package/lib/components/table/table-def.d.ts +7 -0
  224. package/lib/components/table/table-header-cell-renderer/table-header-cell-renderer.component.d.ts +8 -0
  225. package/lib/components/table/table-model.d.ts +114 -0
  226. package/lib/components/table/table.component.d.ts +40 -0
  227. package/lib/interaction/activity.d.ts +1 -0
  228. package/lib/interaction/components/popup-interaction-context/popup-interaction-context.component.d.ts +21 -0
  229. package/lib/interaction/directives/interaction-context-trigger-for.directive.d.ts +17 -0
  230. package/lib/interaction/index.d.ts +2 -0
  231. package/package.json +3 -2
@@ -1,27 +1,30 @@
1
1
  import { __decorate, __metadata, __param, __awaiter } from 'tslib';
2
2
  import { DOCUMENT, CommonModule, Location } from '@angular/common';
3
- import { ElementRef, Inject, Input, HostListener, Directive, NgZone, ɵɵdefineInjectable, ɵɵinject, Injectable, NgModule, Self, HostBinding, Component, EventEmitter, Output, ContentChild, TemplateRef, ChangeDetectorRef, ContentChildren, QueryList, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, Optional, SkipSelf } from '@angular/core';
3
+ import { ElementRef, Inject, Input, HostListener, Directive, NgZone, ɵɵdefineInjectable, ɵɵinject, Injectable, NgModule, HostBinding, Component, ContentChild, TemplateRef, Self, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, QueryList, Optional, EventEmitter, Output, ChangeDetectorRef, ContentChildren, SkipSelf } from '@angular/core';
4
4
  import { FormsModule } from '@angular/forms';
5
5
  import { MatFormFieldModule } from '@angular/material/form-field';
6
6
  import { MatInputModule } from '@angular/material/input';
7
7
  import { MatSelectModule } from '@angular/material/select';
8
8
  import { MatTabsModule, MatTabGroup, MAT_TABS_CONFIG } from '@angular/material/tabs';
9
9
  import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
10
+ import { ComponentPortal, PortalModule } from '@angular/cdk/portal';
10
11
  import { MatButtonModule } from '@angular/material/button';
11
12
  import { MatCheckboxModule } from '@angular/material/checkbox';
12
13
  import { MatIconModule } from '@angular/material/icon';
13
- import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, Command, FocusManager, DelegatingFormValueModel, TrackExternal, ListModel, StoreInListModel, ValueModel, StoreInValueModel, MutableValueModel, Deferred, Trace, MutableListModel, Guard, DebugContext, Binding, Functions } from '@coolon/pectin';
14
- import { PortalModule } from '@angular/cdk/portal';
14
+ import { MatTableModule } from '@angular/material/table';
15
+ import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, FocusManager, MutableValueModel, TrackExternal, Command, Deferred, Trace, MutableListModel, Form, DelegatingFormValueModel, ListModel, StoreInListModel, ValueModel, StoreInValueModel, MultipleSelectionModel, Guard, DebugContext, Binding, Functions } from '@coolon/pectin';
15
16
  import { FlexModule, GridModule } from '@angular/flex-layout';
16
17
  import { MatDialog, MatDialogConfig, MAT_DIALOG_DEFAULT_OPTIONS, MatDialogModule } from '@angular/material/dialog';
17
18
  import { RouterModule, UrlSegment, Router, UrlSerializer, NavigationStart, NavigationEnd, NavigationError, NavigationCancel, RouterOutlet } from '@angular/router';
18
19
  import ___default, { isEqual, isNil } from 'lodash';
19
20
  import ResizeObserver from 'resize-observer-polyfill';
20
21
  import { assert as assert$1, lang as lang$1, Opts, Klass } from '@coolon/typescript-utilities';
22
+ import { Overlay } from '@angular/cdk/overlay';
23
+ import { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';
24
+ import produce from 'immer';
21
25
  import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
22
26
  import { MatListModule } from '@angular/material/list';
23
27
  import { MatTooltipModule } from '@angular/material/tooltip';
24
- import { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';
25
28
  import { Memoize as Memoize$1 } from '@typescript-plus/fast-memoize-decorator';
26
29
  import 'reflect-metadata';
27
30
  import { style, query, group, animate, trigger, transition } from '@angular/animations';
@@ -325,42 +328,6 @@ DirectivesModule = __decorate([
325
328
  })
326
329
  ], DirectivesModule);
327
330
 
328
- let FocusContainerComponent = class FocusContainerComponent extends DisposableComponent {
329
- constructor(focusManager) {
330
- super();
331
- this.focusManager = focusManager;
332
- this.restoreFocusCommand = Command.create(() => {
333
- this.restoreFocus();
334
- });
335
- this.tabIndex = -1;
336
- }
337
- ngOnInit() {
338
- }
339
- // @Trace()
340
- restoreFocus() {
341
- this.focusManager.restoreFocus();
342
- }
343
- };
344
- FocusContainerComponent.ctorParameters = () => [
345
- { type: FocusManager, decorators: [{ type: Self }] }
346
- ];
347
- __decorate([
348
- HostBinding('attr.tabindex'),
349
- __metadata("design:type", Object)
350
- ], FocusContainerComponent.prototype, "tabIndex", void 0);
351
- FocusContainerComponent = __decorate([
352
- Component({
353
- selector: 'aup-focus-container',
354
- template: "<ng-content></ng-content>\n",
355
- providers: [
356
- { provide: FocusManager }
357
- ],
358
- styles: [":host{display:block}"]
359
- }),
360
- __param(0, Self()),
361
- __metadata("design:paramtypes", [FocusManager])
362
- ], FocusContainerComponent);
363
-
364
331
  let FocusableComponent = class FocusableComponent extends DisposableComponent {
365
332
  constructor(el, focusManager, focusBindingFactory) {
366
333
  super();
@@ -415,1647 +382,2506 @@ FocusableComponent = __decorate([
415
382
  __metadata("design:paramtypes", [ElementRef, FocusManager, FocusBindingFactory])
416
383
  ], FocusableComponent);
417
384
 
418
- let AbstractInputComponent = class AbstractInputComponent extends DisposableComponent {
419
- constructor() {
420
- super();
421
- /**
422
- * A backing model for all our @Input() valueModel properties which should be defined as follows.
423
- *
424
- * @Input() @TrackExternal({useExisting: "delegatingFormValueModel"})
425
- * valueModel: FormValueModel<string> | MutableValueModel<string>;
426
- *
427
- * This approach allows the input to accept plain or form models but all backed by a form
428
- * friendly delegate. We have to use an existing delegate for union types as pectin just
429
- * gets told it's an Object and can't scan for a base type annotated with @DelegateUsing(..).
430
- */
431
- // We have to register it as a disposable so it ditches any listeners when we're disposed.
432
- this.delegatingFormValueModel = this.registerDisposable(new DelegatingFormValueModel());
433
- // TODO: fix this.
434
- // tslint:disable-next-line:no-output-native
435
- this.focus = new EventEmitter();
436
- // tslint:disable-next-line:no-output-native
437
- this.blur = new EventEmitter();
438
- // tslint:disable-next-line:no-output-native
439
- this.enterKey = new EventEmitter();
440
- // tslint:disable-next-line:no-output-native
441
- this.escapeKey = new EventEmitter();
442
- const self = this;
443
- this.errorStateMatcher = {
444
- isErrorState(control, form) {
445
- return self.hasErrors();
446
- }
447
- };
448
- }
449
- notifyClick() {
450
- this.safelyInvoke(this.clickCommand);
385
+ class Dimension {
386
+ constructor(width, height) {
387
+ this.width = width;
388
+ this.height = height;
451
389
  }
452
- notifyFocusIn() {
453
- this.safelyInvoke(this.focusCommand);
454
- this.focus.emit();
390
+ }
391
+
392
+ class Point {
393
+ constructor(x, y) {
394
+ this.x = x;
395
+ this.y = y;
455
396
  }
456
- notifyFocusOut() {
457
- this.safelyInvoke(this.blurCommand);
458
- this.blur.emit();
397
+ static from(data) {
398
+ return new Point(data.x, data.y);
459
399
  }
460
- notifyEnterKey() {
461
- this.safelyInvoke(this.enterCommand);
462
- this.enterKey.emit();
400
+ translate(x, y) {
401
+ return new Point(this.x + x, this.y + y);
463
402
  }
464
- notifyEscapeKey() {
465
- this.safelyInvoke(this.escapeCommand);
466
- this.escapeKey.emit();
403
+ }
404
+
405
+ class Bounds extends Dimension {
406
+ constructor(top, left, width, height) {
407
+ super(width, height);
408
+ this.top = top;
409
+ this.left = left;
410
+ this.width = width;
411
+ this.height = height;
467
412
  }
468
- safelyInvoke(command) {
469
- if (command && command.enabled.value) {
470
- command.execute();
413
+ relativePositionOf(point) {
414
+ if (point instanceof MouseEvent) {
415
+ return new Point(point.clientX - this.left, point.clientY - this.top);
416
+ }
417
+ else {
418
+ return new Point(point.x - this.left, point.y - this.top);
471
419
  }
472
420
  }
473
- ngOnInit() {
421
+ }
422
+ (function (Bounds) {
423
+ function ofElement(element) {
424
+ const rect = element.getBoundingClientRect();
425
+ return new Bounds(rect.top, rect.left, rect.width, rect.height);
474
426
  }
475
- isEnabled() {
476
- return this.enabled.value;
427
+ Bounds.ofElement = ofElement;
428
+ })(Bounds || (Bounds = {}));
429
+
430
+ let ResizeAwareComponent = class ResizeAwareComponent extends DisposableComponent {
431
+ constructor(elementRef, ngZone) {
432
+ super();
433
+ this.elementRef = elementRef;
434
+ this.ngZone = ngZone;
435
+ this._boundsModel = new MutableValueModel(new Bounds(0, 0, 0, 0));
477
436
  }
478
- get enabled() {
479
- return this.delegatingFormValueModel.enabled;
437
+ ngAfterViewInit() {
438
+ this.updateBounds();
439
+ const element = this.elementRef.nativeElement;
440
+ const ro = new ResizeObserver((entries, observer) => {
441
+ this.ngZone.run(() => this.updateBounds());
442
+ });
443
+ ro.observe(element);
444
+ this.onDispose(() => ro.disconnect());
480
445
  }
481
- hasErrors() {
482
- return !this.errorList.query().isEmpty();
446
+ get boundsModel() {
447
+ return this._boundsModel.readonly;
483
448
  }
484
- get errorList() {
485
- return this.delegatingFormValueModel.errorList;
449
+ get nativeElement() {
450
+ return this.elementRef.nativeElement;
486
451
  }
487
- get firstError() {
488
- return this.hasErrors() ? this.errorList.value[0] : null;
452
+ // TODO: Make this handle body scroll
453
+ relativePositionOf(point) {
454
+ return this.bounds.relativePositionOf(point);
455
+ }
456
+ get bounds() {
457
+ return this._boundsModel.value;
458
+ }
459
+ updateBounds() {
460
+ this._boundsModel.value = Bounds.ofElement(this.nativeElement);
461
+ }
462
+ };
463
+ ResizeAwareComponent.ctorParameters = () => [
464
+ { type: ElementRef },
465
+ { type: NgZone }
466
+ ];
467
+ ResizeAwareComponent = __decorate([
468
+ Directive(),
469
+ __metadata("design:paramtypes", [ElementRef, NgZone])
470
+ ], ResizeAwareComponent);
471
+
472
+ /**
473
+ * @example
474
+ * // CSS Vars
475
+ * aup-card-container {
476
+ * --card-gap: var(--card-gap, 16px);
477
+ * --card-width: var(--card-width, 300px);
478
+ * --card-height: var(--card-height, auto);
479
+ * --card-min-height: var(--card-min-height, auto);
480
+ * --card-background: var(--card-background, #fcfcfb);
481
+ * }
482
+ *
483
+ * // Content Templates:
484
+ * #addCardTemplate
485
+ * <ng-template #addCardTemplate>
486
+ * This is a new card template, it will the the size of the other cards.
487
+ * </nav-template>
488
+ *
489
+ */
490
+ let CardContainerComponent = class CardContainerComponent extends DisposableComponent {
491
+ constructor() {
492
+ super();
493
+ }
494
+ ngOnInit() {
489
495
  }
490
496
  };
491
497
  __decorate([
492
498
  Input(),
493
- __metadata("design:type", String)
494
- ], AbstractInputComponent.prototype, "label", void 0);
495
- __decorate([
496
- Input(),
497
- __metadata("design:type", String)
498
- ], AbstractInputComponent.prototype, "floatLabel", void 0);
499
- __decorate([
500
- Input(),
501
- __metadata("design:type", String)
502
- ], AbstractInputComponent.prototype, "hint", void 0);
503
- __decorate([
504
- Input(),
505
- __metadata("design:type", String)
506
- ], AbstractInputComponent.prototype, "placeholder", void 0);
507
- __decorate([
508
- Input('command.focus'),
509
- __metadata("design:type", Command)
510
- ], AbstractInputComponent.prototype, "focusCommand", void 0);
511
- __decorate([
512
- Input('command.blur'),
513
- __metadata("design:type", Command)
514
- ], AbstractInputComponent.prototype, "blurCommand", void 0);
515
- __decorate([
516
- Input('command.enter'),
499
+ TrackExternal(),
517
500
  __metadata("design:type", Command)
518
- ], AbstractInputComponent.prototype, "enterCommand", void 0);
501
+ ], CardContainerComponent.prototype, "addCardCommand", void 0);
519
502
  __decorate([
520
- Input('command.escape'),
521
- __metadata("design:type", Command)
522
- ], AbstractInputComponent.prototype, "escapeCommand", void 0);
503
+ ContentChild("addCardTemplate"),
504
+ __metadata("design:type", TemplateRef)
505
+ ], CardContainerComponent.prototype, "addCardTemplate", void 0);
506
+ CardContainerComponent = __decorate([
507
+ Component({
508
+ selector: 'aup-card-container',
509
+ template: "<div class=\"card-container\">\n <ng-content></ng-content>\n\n <div class=\"add-card-container\" *ngIf=\"addCardCommand.enabled.value\" [pectinCommand]=\"addCardCommand\">\n <mat-icon>add</mat-icon>\n </div>\n\n <div class=\"add-card-template\" *ngIf=\"addCardTemplate\">\n <ng-container [ngTemplateOutlet]=\"addCardTemplate\"></ng-container>\n </div>\n\n</div>\n",
510
+ styles: [":root{--aup-default-padding:var(--default-padding, 18px);--aup-default-background:white}.router-outlet-container>*{position:absolute;top:0;left:0;bottom:0;right:0}[no-tab-header]>mat-tab-header{display:none}[full-height-tabs] .mat-tab-body-wrapper,mat-tab-group.full-height-tabs .mat-tab-body-wrapper{flex:1}[full-height-tabs] .mat-tab-body-wrapper .mat-tab-body-content,[full-height-tabs] .mat-tab-body-wrapper mat-tab-body,mat-tab-group.full-height-tabs .mat-tab-body-wrapper .mat-tab-body-content,mat-tab-group.full-height-tabs .mat-tab-body-wrapper mat-tab-body{display:flex;flex-direction:column;justify-content:stretch}.dialog-interaction-context{max-width:95vw!important;max-height:95vh!important}.dialog-interaction-context mat-dialog-container{max-width:95vw!important;max-height:95vh!important;padding:0}.aup-popup-interaction-panel{background:var(--aup-default-background,#fff);box-shadow:0 2px 1px -1px rgba(0,0,0,.2),0 1px 1px 0 rgba(0,0,0,.14),0 1px 3px 0 rgba(0,0,0,.12);transition:box-shadow 280ms cubic-bezier(.4,0,.2,1)}.aup-input-activity{padding:calc(var(--aup-default-padding)/2)}.aup-input-component{display:block}.aup-input-component input,.aup-input-component mat-form-field{width:100%}.aup-input-component input mat-hint.faux-error,.aup-input-component mat-form-field mat-hint.faux-error{color:#f44336}aup-table-cell-renderer>.aup-input-component .mat-form-field-flex{padding-top:0}aup-table-cell-renderer>.aup-input-component .mat-form-field-infix{width:0}aup-table-cell-renderer>.aup-input-component .mat-form-field-label-wrapper{display:none}aup-table{--default-column-gap:var(--column-gap, 24px)}aup-table aup-table-cell-renderer:not(.first-column),aup-table aup-table-header-cell-renderer:not(.first-column){padding-left:var(--default-column-gap)}:host{--resolved-card-gap:var(--card-gap, 16px);--resolved-card-width:var(--card-width, 300px);--resolved-card-height:var(--card-height, auto);--resolved-card-min-height:var(--card-min-height, auto);--resolved-card-background:var(--card-background, #fcfcfb);flex:1;display:block;background:var(--resolved-card-background)}.card-container{display:-ms-grid;display:grid;grid-template-columns:repeat(auto-fill,var(--resolved-card-width));grid-template-rows:repeat(auto-fit,minmax(0,var(--resolved-card-height)));grid-gap:var(--resolved-card-gap);box-sizing:border-box;padding:var(--resolved-card-gap);min-height:calc(var(--resolved-card-height) + 2 * var(--resolved-card-gap));min-width:calc(var(--resolved-card-width) + 2 * var(--resolved-card-gap));width:calc((var(--resolved-card-width) + var(--resolved-card-gap)) * 2 + var(--grid-gap));max-width:100%}.add-card-container{width:var(--resolved-card-width);height:var(--resolved-card-height);min-height:var(--resolved-card-min-height);display:flex;flex-direction:column;align-items:center;justify-content:center;box-sizing:border-box;border:2px dashed rgba(0,0,0,.1);border-radius:6px;font-weight:300;cursor:pointer;color:rgba(0,0,0,.54);background-color:rgba(255,255,255,.8);transition:280ms cubic-bezier(.4,0,.2,1)}.add-card-container mat-icon{font-size:200%}.add-card-container:hover{transition:280ms cubic-bezier(.4,0,.2,1);border-color:transparent;background-color:#fff;color:rgba(0,0,0,.54)}.add-card-container:hover:hover{box-shadow:0 2px 4px -1px rgba(0,0,0,.2),0 4px 5px 0 rgba(0,0,0,.14),0 1px 10px 0 rgba(0,0,0,.12)}.add-card-template-container{width:var(--resolved-card-width);height:var(--resolved-card-height);display:flex;flex-direction:column;align-items:stretch;justify-content:stretch}"]
511
+ }),
512
+ __metadata("design:paramtypes", [])
513
+ ], CardContainerComponent);
514
+
515
+ let FocusContainerComponent = class FocusContainerComponent extends DisposableComponent {
516
+ constructor(focusManager) {
517
+ super();
518
+ this.focusManager = focusManager;
519
+ this.restoreFocusCommand = Command.create(() => {
520
+ this.restoreFocus();
521
+ });
522
+ this.tabIndex = -1;
523
+ }
524
+ ngOnInit() {
525
+ }
526
+ // @Trace()
527
+ restoreFocus() {
528
+ this.focusManager.restoreFocus();
529
+ }
530
+ };
531
+ FocusContainerComponent.ctorParameters = () => [
532
+ { type: FocusManager, decorators: [{ type: Self }] }
533
+ ];
523
534
  __decorate([
524
- Input('command.click'),
525
- __metadata("design:type", Command)
526
- ], AbstractInputComponent.prototype, "clickCommand", void 0);
527
- __decorate([
528
- Output(),
529
- __metadata("design:type", Object)
530
- ], AbstractInputComponent.prototype, "focus", void 0);
531
- __decorate([
532
- Output(),
533
- __metadata("design:type", Object)
534
- ], AbstractInputComponent.prototype, "blur", void 0);
535
- __decorate([
536
- Output(),
537
- __metadata("design:type", Object)
538
- ], AbstractInputComponent.prototype, "enterKey", void 0);
539
- __decorate([
540
- Output(),
535
+ HostBinding('attr.tabindex'),
541
536
  __metadata("design:type", Object)
542
- ], AbstractInputComponent.prototype, "escapeKey", void 0);
543
- __decorate([
544
- HostListener('click'),
545
- __metadata("design:type", Function),
546
- __metadata("design:paramtypes", []),
547
- __metadata("design:returntype", void 0)
548
- ], AbstractInputComponent.prototype, "notifyClick", null);
549
- __decorate([
550
- HostListener('focusin'),
551
- __metadata("design:type", Function),
552
- __metadata("design:paramtypes", []),
553
- __metadata("design:returntype", void 0)
554
- ], AbstractInputComponent.prototype, "notifyFocusIn", null);
555
- __decorate([
556
- HostListener('focusout'),
557
- __metadata("design:type", Function),
558
- __metadata("design:paramtypes", []),
559
- __metadata("design:returntype", void 0)
560
- ], AbstractInputComponent.prototype, "notifyFocusOut", null);
561
- AbstractInputComponent = __decorate([
562
- Component({ template: '' }),
563
- __metadata("design:paramtypes", [])
564
- ], AbstractInputComponent);
537
+ ], FocusContainerComponent.prototype, "tabIndex", void 0);
538
+ FocusContainerComponent = __decorate([
539
+ Component({
540
+ selector: 'aup-focus-container',
541
+ template: "<ng-content></ng-content>\n",
542
+ providers: [
543
+ { provide: FocusManager }
544
+ ],
545
+ styles: [":host{display:block}"]
546
+ }),
547
+ __param(0, Self()),
548
+ __metadata("design:paramtypes", [FocusManager])
549
+ ], FocusContainerComponent);
565
550
 
566
- let CheckboxInputComponent = class CheckboxInputComponent extends AbstractInputComponent {
551
+ const ACTIVITY_DATA = new InjectionToken('InteractionActivityData');
552
+ class Activity extends DisposableComponent {
567
553
  constructor() {
568
- super();
569
- this.color = 'accent';
570
- this.labelPosition = 'after';
554
+ super(...arguments);
555
+ this._busyModel = new DelegatingValueModel().withDefault(false);
556
+ this.class = 'aup-activity';
571
557
  }
572
- ngOnInit() {
558
+ initialise(nestedInteractionContext, activityContext) {
559
+ assert$1.isNil(this._activityContext);
560
+ this._activityContext = activityContext;
561
+ this._interactionContext = nestedInteractionContext;
573
562
  }
574
- };
563
+ get interactionContext() {
564
+ assert$1.isTruthy(this.isInitialised());
565
+ return this._interactionContext;
566
+ }
567
+ done(result) {
568
+ return this._activityContext.onDone(result);
569
+ }
570
+ cancel(error) {
571
+ this._activityContext.onCancel(error);
572
+ }
573
+ // @Trace()
574
+ onActivityReady() {
575
+ }
576
+ get busy() {
577
+ return this._busyModel.readonly;
578
+ }
579
+ busyWhile(busyModel) {
580
+ this._busyModel.setDelegate(busyModel);
581
+ }
582
+ isBusy() {
583
+ return this._busyModel.value;
584
+ }
585
+ isInitialised() {
586
+ return !!this._activityContext;
587
+ }
588
+ }
575
589
  __decorate([
576
- Input(), TrackExternal({ delegateTo: 'delegatingFormValueModel' }),
590
+ HostBinding('class'),
577
591
  __metadata("design:type", Object)
578
- ], CheckboxInputComponent.prototype, "valueModel", void 0);
579
- __decorate([
580
- Input(),
581
- __metadata("design:type", String)
582
- ], CheckboxInputComponent.prototype, "color", void 0);
583
- __decorate([
584
- Input(),
585
- __metadata("design:type", String)
586
- ], CheckboxInputComponent.prototype, "labelPosition", void 0);
587
- CheckboxInputComponent = __decorate([
588
- Component({
589
- selector: 'aup-checkbox-input',
590
- template: "<!-- TODO: add focus binding -->\n<mat-checkbox\n [(ngModel)]=\"valueModel.value\"\n [color]=\"color\"\n [labelPosition]=\"labelPosition\"\n [disabled]=\"!isEnabled()\"\n>{{label}}</mat-checkbox>\n<mat-hint *ngIf=\"hint\">{{hint}}</mat-hint>\n<mat-error *ngIf=\"hasErrors\">{{firstError}}</mat-error>\n",
591
- styles: [":host{display:inline-flex;flex-direction:column;margin-top:24px;margin-bottom:16px}mat-error,mat-hint{margin-top:4px;margin-left:24px;font-size:12px;font-weight:400;line-height:13.5px}"]
592
- }),
593
- __metadata("design:paramtypes", [])
594
- ], CheckboxInputComponent);
592
+ ], Activity.prototype, "class", void 0);
595
593
 
596
- let NumberInputComponent = class NumberInputComponent extends AbstractInputComponent {
597
- constructor() {
594
+ let AlertDialogComponent = class AlertDialogComponent extends Activity {
595
+ constructor(alert) {
598
596
  super();
599
- this.min = Number.MIN_SAFE_INTEGER;
600
- this.max = Number.MAX_SAFE_INTEGER;
597
+ this.alert = alert;
601
598
  }
602
599
  ngOnInit() {
603
600
  }
604
601
  };
605
- __decorate([
606
- Input(), TrackExternal({ delegateTo: 'delegatingFormValueModel' }),
607
- __metadata("design:type", Object)
608
- ], NumberInputComponent.prototype, "valueModel", void 0);
609
- __decorate([
610
- Input(),
611
- __metadata("design:type", Object)
612
- ], NumberInputComponent.prototype, "min", void 0);
613
- __decorate([
614
- Input(),
615
- __metadata("design:type", Object)
616
- ], NumberInputComponent.prototype, "max", void 0);
617
- NumberInputComponent = __decorate([
602
+ AlertDialogComponent.ctorParameters = () => [
603
+ { type: undefined, decorators: [{ type: Inject, args: [ACTIVITY_DATA,] }] }
604
+ ];
605
+ AlertDialogComponent = __decorate([
618
606
  Component({
619
- selector: 'aup-number-input',
620
- template: "<mat-form-field appearance=\"standard\" [floatLabel]=\"floatLabel\">\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\n <input type=\"number\"\n matInput\n placeholder=\"{{placeholder}}\"\n [(ngModel)]=\"valueModel.value\"\n [disabled]=\"!enabled.value\"\n (keydown.enter)=\"notifyEnterKey()\"\n (keydown.escape)=\"notifyEscapeKey()\"\n [pectinFocusBinding]=\"delegatingFormValueModel?.focusContext\"\n [errorStateMatcher]=\"errorStateMatcher\"\n [min]=\"min\"\n [max]=\"max\"\n >\n <mat-hint *ngIf=\"hint\">{{hint}}</mat-hint>\n <mat-error *ngIf=\"hasErrors\">{{firstError}}</mat-error>\n</mat-form-field>\n",
621
- styles: [":host{display:block}input,mat-form-field{width:100%}input mat-hint.faux-error,mat-form-field mat-hint.faux-error{color:#f44336}"]
607
+ selector: 'aup-alert-dialog',
608
+ template: "<h3 matDialogTitle *ngIf=\"alert.title\">{{alert.title()}}</h3>\n<div matDialogContent>\n <p *ngFor=\"let line of alert.content()\">{{line}}</p>\n</div>\n<div matDialogActions>\n <button mat-raised-button color=\"primary\" (click)=\"done()\" data-cy=\"close-button\">{{alert.ok()}}</button>\n</div>\n",
609
+ styles: [":host{display:block;padding:var(--aup-default-padding)}.mat-dialog-content{margin:0;padding:0}.mat-dialog-actions{margin-bottom:0!important;padding:0;align-items:flex-end;justify-content:flex-end}"]
622
610
  }),
623
- __metadata("design:paramtypes", [])
624
- ], NumberInputComponent);
611
+ __param(0, Inject(ACTIVITY_DATA)),
612
+ __metadata("design:paramtypes", [Object])
613
+ ], AlertDialogComponent);
625
614
 
626
- let PasswordInputComponent = class PasswordInputComponent extends AbstractInputComponent {
627
- constructor() {
615
+ let ConfirmThenDialogComponent = class ConfirmThenDialogComponent extends Activity {
616
+ constructor(config) {
628
617
  super();
618
+ this.config = config;
619
+ assert.notNil(config);
629
620
  }
630
621
  ngOnInit() {
631
622
  }
623
+ get confirm() {
624
+ return this.config.confirm;
625
+ }
626
+ isDestructive() {
627
+ return this.confirm.destructive && this.confirm.destructive();
628
+ }
629
+ onConfirm() {
630
+ this.interactionContext.startActivity(this.config.activityType, this.config.data)
631
+ .then((result) => this.done(result))
632
+ .catch(error => this.cancel(error));
633
+ }
632
634
  };
633
- __decorate([
634
- Input(), TrackExternal({ delegateTo: "delegatingFormValueModel" }),
635
- __metadata("design:type", Object)
636
- ], PasswordInputComponent.prototype, "valueModel", void 0);
637
- PasswordInputComponent = __decorate([
635
+ ConfirmThenDialogComponent.ctorParameters = () => [
636
+ { type: undefined, decorators: [{ type: Inject, args: [ACTIVITY_DATA,] }] }
637
+ ];
638
+ ConfirmThenDialogComponent = __decorate([
638
639
  Component({
639
- selector: 'aup-password-input',
640
- template: "<mat-form-field appearance=\"standard\" [floatLabel]=\"floatLabel\">\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\n <input type=\"password\"\n matInput\n placeholder=\"{{placeholder}}\"\n [(ngModel)]=\"valueModel.value\"\n [disabled]=\"!enabled.value\"\n (keydown.enter)=\"notifyEnterKey()\"\n (keydown.escape)=\"notifyEscapeKey()\"\n [pectinFocusBinding]=\"delegatingFormValueModel.focusContext\"\n [errorStateMatcher]=\"errorStateMatcher\"\n >\n <mat-hint *ngIf=\"hint\">{{hint}}</mat-hint>\n <mat-error *ngIf=\"hasErrors\">{{firstError}}</mat-error>\n</mat-form-field>\n\n",
641
- styles: [":host{display:block}input,mat-form-field{width:100%}input mat-hint.faux-error,mat-form-field mat-hint.faux-error{color:#f44336}"]
640
+ selector: 'aup-confirmation-dialog',
641
+ template: "<h3 matDialogTitle *ngIf=\"confirm.title\">{{confirm.title()}}</h3>\n<div matDialogContent>\n <p *ngFor=\"let line of confirm.content()\">{{line}}</p>\n</div>\n<div matDialogActions>\n <button mat-button (click)=\"cancel()\" data-cy=\"cancel-button\">{{confirm.cancel()}}</button>\n <button mat-raised-button [color]=\"isDestructive() ? 'warn' : 'primary'\"\n (click)=\"onConfirm()\" data-cy=\"confirm-button\">{{confirm.ok()}}</button>\n</div>\n\n",
642
+ styles: [":host{display:block;padding:var(--aup-default-padding)}.mat-dialog-content{margin:0;padding:0}.mat-dialog-actions{margin-bottom:0!important;padding:0;align-items:flex-end;justify-content:flex-end}"]
642
643
  }),
643
- __metadata("design:paramtypes", [])
644
- ], PasswordInputComponent);
644
+ __param(0, Inject(ACTIVITY_DATA)),
645
+ __metadata("design:paramtypes", [Object])
646
+ ], ConfirmThenDialogComponent);
645
647
 
646
- let SelectInputComponent = class SelectInputComponent extends AbstractInputComponent {
647
- constructor() {
648
+ let ConfirmationDialogComponent = class ConfirmationDialogComponent extends Activity {
649
+ constructor(confirm) {
648
650
  super();
649
- this.optionLabelFormat = (option) => (option && this.optionLabel) ? option[this.optionLabel] : option;
651
+ this.confirm = confirm;
652
+ assert.notNil(confirm);
650
653
  }
651
654
  ngOnInit() {
652
655
  }
656
+ isDestructive() {
657
+ return this.confirm.destructive && this.confirm.destructive();
658
+ }
653
659
  };
654
- __decorate([
655
- Input(), TrackExternal({ delegateTo: "delegatingFormValueModel" }),
656
- __metadata("design:type", Object)
657
- ], SelectInputComponent.prototype, "valueModel", void 0);
658
- __decorate([
659
- Input(), TrackExternal(),
660
- __metadata("design:type", ListModel)
661
- ], SelectInputComponent.prototype, "optionsModel", void 0);
662
- __decorate([
663
- Input(), StoreInListModel('optionsModel'),
664
- __metadata("design:type", Array)
665
- ], SelectInputComponent.prototype, "options", void 0);
666
- __decorate([
667
- Input(),
668
- __metadata("design:type", Object)
669
- ], SelectInputComponent.prototype, "optionLabel", void 0);
670
- __decorate([
671
- Input(),
672
- __metadata("design:type", Boolean)
673
- ], SelectInputComponent.prototype, "allowNil", void 0);
674
- __decorate([
675
- ContentChild("optionTemplate"),
676
- __metadata("design:type", TemplateRef)
677
- ], SelectInputComponent.prototype, "optionTemplateRef", void 0);
678
- __decorate([
679
- ContentChild("nilOptionTemplate"),
680
- __metadata("design:type", TemplateRef)
681
- ], SelectInputComponent.prototype, "nilOptionTemplateRef", void 0);
682
- __decorate([
683
- Input(),
684
- __metadata("design:type", Function)
685
- ], SelectInputComponent.prototype, "optionLabelFormat", void 0);
686
- SelectInputComponent = __decorate([
660
+ ConfirmationDialogComponent.ctorParameters = () => [
661
+ { type: undefined, decorators: [{ type: Inject, args: [ACTIVITY_DATA,] }] }
662
+ ];
663
+ ConfirmationDialogComponent = __decorate([
687
664
  Component({
688
- selector: 'aup-select-input',
689
- template: "<mat-form-field appearance=\"standard\" [floatLabel]=\"floatLabel\">\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\n <mat-select placeholder=\"{{placeholder}}\"\n [(ngModel)]=\"valueModel.value\"\n [disabled]=\"!enabled.value\"\n (keydown.enter)=\"notifyEnterKey()\"\n (keydown.escape)=\"notifyEscapeKey()\"\n [pectinFocusBinding]=\"delegatingFormValueModel.focusContext\"\n [errorStateMatcher]=\"errorStateMatcher\"\n >\n <mat-option *ngIf=\"allowNil\">{{placeholder}}</mat-option>\n <mat-option *ngFor=\"let option of optionsModel.value; let i = index\" [value]=\"option\">\n <ng-container *ngIf=\"!optionTemplateRef\">{{optionLabelFormat(option)}}</ng-container>\n <ng-container *ngIf=\"optionTemplateRef\"\n [ngTemplateOutlet]=\"optionTemplateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: option, index: i }\"\n >\n </ng-container>\n </mat-option>\n </mat-select>\n <mat-hint *ngIf=\"hint\">{{hint}}</mat-hint>\n <mat-error *ngIf=\"hasErrors\">{{firstError}}</mat-error>\n</mat-form-field>\n",
690
- styles: [":host{display:inline-block}mat-form-field{width:100%}"]
665
+ selector: 'aup-confirmation-dialog',
666
+ template: "<h3 matDialogTitle *ngIf=\"confirm.title\">{{confirm.title()}}</h3>\n<div matDialogContent>\n <p *ngFor=\"let line of confirm.content()\">{{line}}</p>\n</div>\n<div matDialogActions>\n <button mat-button (click)=\"cancel()\" data-cy=\"cancel-button\">{{confirm.cancel()}}</button>\n <button mat-raised-button [color]=\"isDestructive() ? 'warn' : 'primary'\"\n (click)=\"done()\" data-cy=\"confirm-button\">{{confirm.ok()}}</button>\n</div>\n\n",
667
+ styles: [":host{display:block;padding:var(--aup-default-padding)}.mat-dialog-content{margin:0;padding:0}.mat-dialog-actions{margin-bottom:0!important;padding:0;align-items:flex-end;justify-content:flex-end}"]
691
668
  }),
692
- __metadata("design:paramtypes", [])
693
- ], SelectInputComponent);
669
+ __param(0, Inject(ACTIVITY_DATA)),
670
+ __metadata("design:paramtypes", [Object])
671
+ ], ConfirmationDialogComponent);
694
672
 
695
- let StringInputComponent = class StringInputComponent extends AbstractInputComponent {
696
- constructor() {
697
- super();
698
- const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
699
- this.clearCommand = Command.create(() => {
700
- this.valueModel.value = null;
701
- });
702
- this.clearCommand.disableWhile(chain.stringValue(this.valueModel).isBlank());
673
+ class AbstractInteractionContext {
674
+ startActivity(activityType, data) {
675
+ return this.createAndLaunchActivity(activityType, data, false);
703
676
  }
704
- ngOnInit() {
677
+ confirm(confirm) {
678
+ // Important: we have to implement confirmOrReject as the main entry point
679
+ // as the canDeactivation guards need to be able to cancel an interaction
680
+ // without caring about returning a value.
681
+ return this.confirmOrReject(confirm).then(() => true).catch(() => false);
705
682
  }
706
- };
707
- __decorate([
708
- Input(), TrackExternal({ delegateTo: 'delegatingFormValueModel' }),
709
- __metadata("design:type", Object)
710
- ], StringInputComponent.prototype, "valueModel", void 0);
711
- __decorate([
712
- Input(), TrackExternal({ defaultValue: false }),
713
- __metadata("design:type", ValueModel)
714
- ], StringInputComponent.prototype, "enableClearModel", void 0);
715
- __decorate([
716
- Input(), StoreInValueModel('enableClearModel'),
717
- __metadata("design:type", Boolean)
718
- ], StringInputComponent.prototype, "enableClear", void 0);
719
- StringInputComponent = __decorate([
720
- Component({
721
- selector: 'aup-string-input',
722
- template: "<mat-form-field appearance=\"standard\" [floatLabel]=\"floatLabel\">\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\n <input matInput\n placeholder=\"{{placeholder}}\"\n [(ngModel)]=\"valueModel.value\"\n [disabled]=\"!enabled.value\"\n (keydown.enter)=\"notifyEnterKey()\"\n (keydown.escape)=\"notifyEscapeKey()\"\n [pectinFocusBinding]=\"delegatingFormValueModel.focusContext\"\n [errorStateMatcher]=\"errorStateMatcher\"\n >\n <mat-hint *ngIf=\"hint\">{{hint}}</mat-hint>\n <mat-error *ngIf=\"hasErrors\">{{firstError}}</mat-error>\n <button mat-button mat-icon-button matSuffix *ngIf=\"enableClear\" [pectinCommand]=\"clearCommand\">\n <mat-icon>close</mat-icon>\n </button>\n</mat-form-field>\n\n",
723
- styles: [":host{display:block}input,mat-form-field{width:100%}input mat-hint.faux-error,mat-form-field mat-hint.faux-error{color:#f44336}button[disabled]{visibility:hidden}"]
724
- }),
725
- __metadata("design:paramtypes", [])
726
- ], StringInputComponent);
683
+ alert(alert) {
684
+ // TODO: Test disableClose === false
685
+ return this.createAndLaunchActivity(AlertDialogComponent, alert, false);
686
+ }
687
+ confirmOrReject(confirm) {
688
+ return this.createAndLaunchActivity(ConfirmationDialogComponent, confirm, true);
689
+ }
690
+ /**
691
+ * Presents the confirmation to the user and runs the activity only if the user confirms.
692
+ * @param confirm:Confirm the confirmation to display.
693
+ * @param activityType the activity to run if confirmed.
694
+ * @param data the activity data.
695
+ */
696
+ confirmThen(confirm, activityType, data) {
697
+ return this.createAndLaunchActivity(ConfirmThenDialogComponent, {
698
+ confirm,
699
+ activityType: activityType,
700
+ data: data
701
+ }, true);
702
+ }
703
+ }
727
704
 
728
- let TextInputComponent = class TextInputComponent extends AbstractInputComponent {
729
- constructor() {
730
- super();
731
- this.rows = 2;
732
- // const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
705
+ class ActivityRef {
706
+ constructor(activityClass, activityData, onComplete) {
707
+ this.activityClass = activityClass;
708
+ this.activityData = activityData;
709
+ this.onComplete = onComplete;
710
+ this._complete = false;
711
+ this.deferredResult = Deferred.defer();
712
+ }
713
+ isActivityRealised() {
714
+ return !!this._activity;
715
+ }
716
+ isComplete() {
717
+ return this._complete;
718
+ }
719
+ get activity() {
720
+ assert.isTruthy(this.isActivityRealised());
721
+ return this._activity;
722
+ }
723
+ notifyActivityCreated(activity, nestedInteractionContext) {
724
+ assert.isNil(this._activity);
725
+ this._activity = activity;
726
+ const self = this;
727
+ this._activity.initialise(nestedInteractionContext, {
728
+ onDone(result) {
729
+ self.finishActivity(deferred => deferred.resolve(result));
730
+ },
731
+ onCancel(error) {
732
+ self.finishActivity(deferred => deferred.reject(error));
733
+ }
734
+ });
735
+ }
736
+ finishActivity(resolveOrReject) {
737
+ assert.isFalsey(this.isComplete());
738
+ resolveOrReject(this.deferredResult);
739
+ this._complete = true;
740
+ this.onComplete(this);
741
+ }
742
+ cancel() {
743
+ this.activity.cancel();
744
+ }
745
+ get activityResult() {
746
+ return this.deferredResult.promise;
747
+ }
748
+ }
749
+
750
+ /**
751
+ * ActivityOutletComponent creates and displays an activity and delegates the interaction context functionality to an
752
+ * external service.
753
+ */
754
+ let ActivityOutletComponent = class ActivityOutletComponent {
755
+ constructor(componentFactoryResolver, viewContainerRef, injector) {
756
+ this.componentFactoryResolver = componentFactoryResolver;
757
+ this.viewContainerRef = viewContainerRef;
758
+ this.injector = injector;
759
+ }
760
+ set activityRef(activityRef) {
761
+ if (this.activityRef && !this.activityRef.isComplete()) {
762
+ lang$1.illegalState("changing activity before previous one has completed");
763
+ }
764
+ this._activityRef = activityRef;
765
+ this.loadActivity(activityRef);
766
+ }
767
+ ;
768
+ get activityRef() {
769
+ return this._activityRef;
733
770
  }
734
771
  ngOnInit() {
735
772
  }
773
+ loadActivity(activityRef) {
774
+ const injector = Injector.create({
775
+ providers: [
776
+ { provide: ACTIVITY_DATA, useValue: activityRef.activityData }
777
+ ],
778
+ parent: this.injector
779
+ });
780
+ const componentFactory = this.componentFactoryResolver.resolveComponentFactory(activityRef.activityClass);
781
+ this.viewContainerRef.clear();
782
+ // console.log(`creating component -> ${activityRef.activityClass.name}`);
783
+ this.activityComponentRef = this.viewContainerRef.createComponent(componentFactory, 0, injector);
784
+ this.activityRef.notifyActivityCreated(this.activityComponentRef.instance, this.nestedInteractionContext);
785
+ }
786
+ get component() {
787
+ return this.activityComponentRef.instance;
788
+ }
736
789
  };
737
- __decorate([
738
- Input(), TrackExternal({ delegateTo: 'delegatingFormValueModel' }),
739
- __metadata("design:type", Object)
740
- ], TextInputComponent.prototype, "valueModel", void 0);
790
+ ActivityOutletComponent.ctorParameters = () => [
791
+ { type: ComponentFactoryResolver },
792
+ { type: ViewContainerRef },
793
+ { type: Injector }
794
+ ];
741
795
  __decorate([
742
796
  Input(),
743
797
  __metadata("design:type", Object)
744
- ], TextInputComponent.prototype, "rows", void 0);
798
+ ], ActivityOutletComponent.prototype, "nestedInteractionContext", void 0);
745
799
  __decorate([
746
800
  Input(),
747
- __metadata("design:type", Number)
748
- ], TextInputComponent.prototype, "cols", void 0);
749
- TextInputComponent = __decorate([
801
+ __metadata("design:type", ActivityRef),
802
+ __metadata("design:paramtypes", [ActivityRef])
803
+ ], ActivityOutletComponent.prototype, "activityRef", null);
804
+ ActivityOutletComponent = __decorate([
750
805
  Component({
751
- selector: 'aup-text-input',
752
- template: "<mat-form-field appearance=\"standard\" [floatLabel]=\"floatLabel\">\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\n <textarea matInput\n placeholder=\"{{placeholder}}\"\n [(ngModel)]=\"valueModel.value\"\n [disabled]=\"!enabled.value\"\n (keydown.enter)=\"notifyEnterKey()\"\n (keydown.escape)=\"notifyEscapeKey()\"\n [pectinFocusBinding]=\"delegatingFormValueModel.focusContext\"\n [errorStateMatcher]=\"errorStateMatcher\"\n [rows]=\"rows\"\n [cols]=\"cols\"\n >\n </textarea>\n <mat-hint *ngIf=\"hint\">{{hint}}</mat-hint>\n <mat-error *ngIf=\"hasErrors\">{{firstError}}</mat-error>\n</mat-form-field>\n\n",
753
- styles: [":host{display:block}input,mat-form-field{width:100%}input mat-hint.faux-error,mat-form-field mat-hint.faux-error{color:#f44336}button[disabled]{visibility:hidden}textarea{overflow:auto}"]
806
+ selector: 'aup-activity-outlet',
807
+ template: '',
808
+ styles: [":host{display:block}"]
754
809
  }),
755
- __metadata("design:paramtypes", [])
756
- ], TextInputComponent);
810
+ __metadata("design:paramtypes", [ComponentFactoryResolver,
811
+ ViewContainerRef,
812
+ Injector])
813
+ ], ActivityOutletComponent);
757
814
 
758
- let NoopComponent = class NoopComponent {
815
+ let ActivityContainerComponent = class ActivityContainerComponent extends AbstractInteractionContext {
759
816
  constructor() {
817
+ super();
818
+ this.dynamicHeight = false;
819
+ this.activityTabs = [];
820
+ this.garbage = new GarbageCollector();
760
821
  }
761
- };
762
- NoopComponent = __decorate([
763
- Component({
764
- selector: 'aup-noop',
765
- template: "",
766
- styles: [":host{display:block}"]
767
- }),
768
- __metadata("design:paramtypes", [])
769
- ], NoopComponent);
770
-
771
- let ScrollContainerComponent = class ScrollContainerComponent {
772
- constructor() { }
773
822
  ngOnInit() {
774
823
  }
775
- };
776
- ScrollContainerComponent = __decorate([
777
- Component({
778
- selector: 'aup-scroll-container',
779
- template: "<div class=\"container\">\n <ng-content></ng-content>\n</div>\n",
780
- styles: [":host{display:flex;flex-direction:column;min-height:0;align-items:stretch}.container{display:flex;flex-direction:column;flex:1;flex-basis:0;overflow-y:scroll;align-items:stretch}"]
781
- }),
782
- __metadata("design:paramtypes", [])
783
- ], ScrollContainerComponent);
784
-
785
- var SwitchCaseWhenDirective_1, SwitchCaseDefaultDirective_1;
786
- class SwitchCaseOption {
787
- constructor(templateRef) {
788
- this.templateRef = templateRef;
824
+ ngAfterViewInit() {
825
+ const { chain, observe } = Dsl.disposeWith(this);
826
+ // using the component directly rather than (animationDone)=.. allows us
827
+ // to keep our callback private.
828
+ observe.valuesFrom(this.tabs.animationDone).subscribe(() => this.onAnimationFinished());
789
829
  }
790
- get name() {
791
- return this.constructor.name;
830
+ initialise(identifier, api) {
831
+ assert.isFalsey(this.isInitialised());
832
+ assert.notNil(identifier);
833
+ assert.notNil(api);
834
+ this._identifier = identifier;
835
+ this.interactionServiceApi = api;
792
836
  }
793
- }
794
- let SwitchCaseWhenDirective = SwitchCaseWhenDirective_1 = class SwitchCaseWhenDirective extends SwitchCaseOption {
795
- constructor(templateRef) {
796
- super(templateRef);
797
- this.isDefault = false;
837
+ get identifier() {
838
+ return this._identifier;
798
839
  }
799
- matches(value) {
800
- return this.aupSwitchCaseWhen === value;
840
+ isInitialised() {
841
+ return !!this.identifier;
801
842
  }
802
- };
803
- SwitchCaseWhenDirective.ctorParameters = () => [
804
- { type: TemplateRef }
805
- ];
806
- __decorate([
807
- Input(),
808
- __metadata("design:type", Object)
809
- ], SwitchCaseWhenDirective.prototype, "aupSwitchCaseWhen", void 0);
810
- SwitchCaseWhenDirective = SwitchCaseWhenDirective_1 = __decorate([
811
- Directive({
812
- selector: '[aupSwitchCaseWhen]',
813
- providers: [{ provide: SwitchCaseOption, useExisting: SwitchCaseWhenDirective_1 }]
814
- }),
815
- __metadata("design:paramtypes", [TemplateRef])
816
- ], SwitchCaseWhenDirective);
817
- let SwitchCaseDefaultDirective = SwitchCaseDefaultDirective_1 = class SwitchCaseDefaultDirective extends SwitchCaseOption {
818
- constructor(templateRef) {
819
- super(templateRef);
820
- this.isDefault = true;
843
+ /**
844
+ * Returns true if an activity is currently running.
845
+ */
846
+ isActive() {
847
+ return this.getActiveActivityCount() > 0;
821
848
  }
822
- matches(value) {
823
- return false;
849
+ registerDisposable(disposable) {
850
+ return this.garbage.registerDisposable(disposable);
824
851
  }
825
- };
826
- SwitchCaseDefaultDirective.ctorParameters = () => [
827
- { type: TemplateRef }
828
- ];
829
- SwitchCaseDefaultDirective = SwitchCaseDefaultDirective_1 = __decorate([
830
- Directive({
831
- selector: '[aupSwitchCaseDefault]',
832
- providers: [{ provide: SwitchCaseOption, useExisting: SwitchCaseDefaultDirective_1 }]
833
- }),
834
- __metadata("design:paramtypes", [TemplateRef])
835
- ], SwitchCaseDefaultDirective);
836
- let SwitchCaseComponent = class SwitchCaseComponent extends DisposableComponent {
837
- constructor(cdr) {
838
- super();
839
- this.cdr = cdr;
840
- this.selectedIndex = 0;
852
+ dispose() {
853
+ // TODO: think about auto cancelling any outstanding activity on dispose.
854
+ // See NavigationState.Navigating for a use-case.
855
+ assert.isFalsey(this.isActive());
856
+ this.garbage.dispose();
841
857
  }
842
- ngOnInit() {
858
+ getActiveActivityRef() {
859
+ if (!this.isActive()) {
860
+ lang$1.illegalState('no activity in progress');
861
+ }
862
+ return ___default.findLast(this.activityTabs, tab => !tab.isComplete());
843
863
  }
844
- ngAfterContentInit() {
845
- const subscription = this.switchCaseOptions.changes.subscribe(change => this.updateSelection());
846
- this.onDispose(() => subscription.unsubscribe());
847
- const { chain, when } = Dsl.disposeWith(this);
848
- when.valueOf(this.switchModel).changes(() => this.updateSelection(), { initialValue: 'triggerChange' });
849
- this.cdr.detectChanges();
864
+ /**
865
+ * Cancels the current activity and returns true the context is no longer active, false if
866
+ * there is still another activity running.
867
+ */
868
+ // @Trace()
869
+ cancelActiveActivity() {
870
+ return __awaiter(this, void 0, void 0, function* () {
871
+ const activity = this.getActiveActivityRef();
872
+ activity.cancel();
873
+ if (this.isCleaningUp()) {
874
+ return this.waitForInteractionContextCleanupToFinish();
875
+ }
876
+ else {
877
+ return !this.isActive();
878
+ }
879
+ });
850
880
  }
851
- updateSelection() {
852
- const matchingIndicies = [];
853
- this.switchCaseOptions.forEach((option, index) => {
854
- if (option.matches(this.switchModel.value)) {
855
- matchingIndicies.push(index);
881
+ // TODO: this handling of multiple nested activities is only used by the activity component and is not a general case.
882
+ // @Trace()
883
+ createAndLaunchActivity(activityType, data, disableClose) {
884
+ assert.isTruthy(this.isInitialised()); // make sure we've been initialised
885
+ const activityRef = new ActivityRef(activityType, data, () => {
886
+ const activeActivityCount = this.getActiveActivityCount() > 0;
887
+ if (activeActivityCount) {
888
+ this.triggerTabSynchronisation();
889
+ }
890
+ else {
891
+ this.finishAndStartCleanup();
856
892
  }
857
893
  });
858
- if (matchingIndicies.length > 1) {
859
- console.warn(`found ${matchingIndicies.length} matching case values, displaying the first.`);
894
+ this.launchActivity(activityRef);
895
+ // if this is the first activity let the interaction service know.
896
+ if (this.activityTabs.length === 1) {
897
+ // console.log('Now active!!!');
898
+ this.interactionServiceApi.notifyActive(this);
860
899
  }
861
- if (matchingIndicies.length === 0) {
862
- this.switchCaseOptions.forEach((option, index) => {
863
- matchingIndicies.push(index);
900
+ return activityRef.activityResult;
901
+ }
902
+ getActiveActivityCount() {
903
+ return this.activityTabs.filter(ref => !ref.isComplete()).length;
904
+ }
905
+ /**
906
+ * Checks if this interaction context has finished an is in the process of waiting
907
+ * for all the infrastructure (including route updates) to be completed.
908
+ */
909
+ isCleaningUp() {
910
+ return !!this._deferredCleanUp;
911
+ }
912
+ waitForInteractionContextCleanupToFinish() {
913
+ return __awaiter(this, void 0, void 0, function* () {
914
+ return this._deferredCleanUp ?
915
+ this._deferredCleanUp :
916
+ true;
917
+ });
918
+ }
919
+ // @Trace()
920
+ finishAndStartCleanup() {
921
+ if (!this._deferredCleanUp) {
922
+ // Important:
923
+ // Clear our tabs so the next activity triggers a tab change.
924
+ // Without this our animation done wasn't called when a single
925
+ // new activity followed a single tab activity (since we're tracking
926
+ // by activity index)
927
+ this.activityTabs = [];
928
+ const promise = this.interactionServiceApi.notifyFinished(this);
929
+ this._deferredCleanUp = promise
930
+ .finally(() => {
931
+ this._deferredCleanUp = null;
864
932
  });
865
- if (matchingIndicies.length > 1) {
866
- console.warn(`found ${matchingIndicies.length} default case values, displaying the first.`);
867
- }
868
933
  }
869
- if (matchingIndicies.length > 0) {
870
- this.selectedIndex = matchingIndicies[0];
934
+ }
935
+ // @Trace()
936
+ launchActivity(activityRef) {
937
+ const cleanedTabs = this.activityTabs.filter(tab => !tab.isComplete());
938
+ this.activityTabs = cleanedTabs.concat(activityRef);
939
+ this.synchroniseSelectedTabIndex();
940
+ }
941
+ activityIndex(index, activityRef) {
942
+ return index;
943
+ }
944
+ ;
945
+ onAnimationFinished() {
946
+ if (this.onAnimationFinishedJob) {
947
+ this.onAnimationFinishedJob();
948
+ this.onAnimationFinishedJob = undefined;
871
949
  }
872
- else {
873
- console.warn(`found no matching or default case values.`);
874
- this.selectedIndex = -1;
950
+ }
951
+ /**
952
+ * Synchronises the selected tab index.
953
+ */
954
+ synchroniseSelectedTabIndex() {
955
+ const previousIndex = this.tabs.selectedIndex;
956
+ const newIndex = this.getActiveActivityCount() - 1;
957
+ if (previousIndex !== newIndex) {
958
+ this.tabs.selectedIndex = newIndex;
959
+ this.onAnimationFinishedJob = () => {
960
+ this.getSelectedOutlet().component.onActivityReady();
961
+ this.activityTabs = this.activityTabs.filter(tab => !tab.isComplete());
962
+ };
963
+ }
964
+ }
965
+ getSelectedOutlet() {
966
+ return this.activityOutlets.toArray()[this.tabs.selectedIndex];
967
+ }
968
+ // @Trace()
969
+ triggerTabSynchronisation() {
970
+ if (this.syncSelectedTabTimeout) {
971
+ clearTimeout(this.syncSelectedTabTimeout);
875
972
  }
973
+ this.syncSelectedTabTimeout = setTimeout(() => {
974
+ this.syncSelectedTabTimeout = null;
975
+ this.synchroniseSelectedTabIndex();
976
+ }, 75);
876
977
  }
877
978
  };
878
- SwitchCaseComponent.ctorParameters = () => [
879
- { type: ChangeDetectorRef }
880
- ];
881
- __decorate([
882
- Input(), TrackExternal(),
883
- __metadata("design:type", ValueModel)
884
- ], SwitchCaseComponent.prototype, "switchModel", void 0);
885
979
  __decorate([
886
- Input(), StoreInValueModel('switchModel'),
980
+ Input(),
887
981
  __metadata("design:type", Object)
888
- ], SwitchCaseComponent.prototype, "switch", void 0);
982
+ ], ActivityContainerComponent.prototype, "dynamicHeight", void 0);
889
983
  __decorate([
890
- ContentChildren(SwitchCaseOption),
984
+ ViewChild('tabs', { static: true }),
985
+ __metadata("design:type", MatTabGroup)
986
+ ], ActivityContainerComponent.prototype, "tabs", void 0);
987
+ __decorate([
988
+ ViewChildren(ActivityOutletComponent),
891
989
  __metadata("design:type", QueryList)
892
- ], SwitchCaseComponent.prototype, "switchCaseOptions", void 0);
893
- SwitchCaseComponent = __decorate([
990
+ ], ActivityContainerComponent.prototype, "activityOutlets", void 0);
991
+ __decorate([
992
+ Trace(),
993
+ __metadata("design:type", Function),
994
+ __metadata("design:paramtypes", []),
995
+ __metadata("design:returntype", void 0)
996
+ ], ActivityContainerComponent.prototype, "dispose", null);
997
+ ActivityContainerComponent = __decorate([
894
998
  Component({
895
- selector: 'aup-switch-case',
896
- template: "<mat-tab-group class=\"content-wrapper\" no-tab-header full-height-tabs [selectedIndex]=\"selectedIndex\">\n <mat-tab *ngFor=\"let option of switchCaseOptions\">\n <ng-template [ngTemplateOutlet]=\"option.templateRef\"></ng-template>\n </mat-tab>\n</mat-tab-group>\n\n\n",
897
- styles: [":host{display:flex;flex-direction:column;align-items:stretch}mat-tab-group{flex:1}"]
999
+ selector: 'aup-activity-container',
1000
+ template: "<mat-tab-group #tabs no-tab-header\n [dynamicHeight]=\"dynamicHeight\"\n [class.full-height-tabs]=\"!dynamicHeight\">\n <mat-tab *ngFor=\"let tab of activityTabs; trackBy: activityIndex\" >\n <aup-activity-outlet [nestedInteractionContext]=\"this\" [activityRef]=\"tab\"></aup-activity-outlet>\n </mat-tab>\n</mat-tab-group>\n",
1001
+ styles: [":host{display:flex;flex-direction:column}mat-tab-group{flex:1}"]
898
1002
  }),
899
- __metadata("design:paramtypes", [ChangeDetectorRef])
900
- ], SwitchCaseComponent);
1003
+ __metadata("design:paramtypes", [])
1004
+ ], ActivityContainerComponent);
901
1005
 
902
- let VerticalFocusContainerComponent = class VerticalFocusContainerComponent extends FocusContainerComponent {
903
- constructor(focusManager) {
904
- super(focusManager);
905
- this.focusManager = focusManager;
906
- }
907
- arrowLeft(event) {
908
- if (this.leftArrowCommand.enabled.value) {
909
- event.preventDefault();
910
- event.stopPropagation();
911
- this.leftArrowCommand.execute();
912
- }
913
- }
914
- arrowRight(event) {
915
- if (this.rightArrowCommand.enabled.value) {
916
- event.preventDefault();
917
- event.stopPropagation();
918
- this.rightArrowCommand.execute();
919
- }
1006
+ let AddItemInteractionContextComponent = class AddItemInteractionContextComponent extends DisposableComponent {
1007
+ constructor() {
1008
+ super();
1009
+ this.tabindex = 0;
1010
+ this.clickCommand = Command.create((context) => {
1011
+ if (this.activityClass) {
1012
+ this.startActivity(this.activityClass, this.activityData).catch(e => {
1013
+ // don't care.
1014
+ });
1015
+ }
1016
+ else {
1017
+ this.addCommand.withContext(context).execute();
1018
+ }
1019
+ });
920
1020
  }
921
- arrowDown(event) {
922
- event.preventDefault();
923
- event.stopPropagation();
924
- this.focusManager.focusNext();
1021
+ get active() {
1022
+ return this.interactionContext ? this.interactionContext.isActive() : false;
925
1023
  }
926
- arrowUp(event) {
927
- event.preventDefault();
928
- event.stopPropagation();
929
- this.focusManager.focusPrevious();
1024
+ startActivity(activityType, data) {
1025
+ return this.interactionContext.startActivity(activityType, data);
930
1026
  }
931
1027
  ngOnInit() {
932
1028
  }
933
1029
  };
934
- VerticalFocusContainerComponent.ctorParameters = () => [
935
- { type: FocusManager, decorators: [{ type: Self }] }
936
- ];
937
1030
  __decorate([
938
- Input('command.arrowRight'),
939
- TrackExternal(),
940
- __metadata("design:type", Command)
941
- ], VerticalFocusContainerComponent.prototype, "rightArrowCommand", void 0);
1031
+ Input(),
1032
+ __metadata("design:type", String)
1033
+ ], AddItemInteractionContextComponent.prototype, "label", void 0);
942
1034
  __decorate([
943
- Input('command.arrowLeft'),
1035
+ Input(),
1036
+ __metadata("design:type", Object)
1037
+ ], AddItemInteractionContextComponent.prototype, "activityClass", void 0);
1038
+ __decorate([
1039
+ Input(),
1040
+ __metadata("design:type", Object)
1041
+ ], AddItemInteractionContextComponent.prototype, "activityData", void 0);
1042
+ __decorate([
1043
+ Input(),
944
1044
  TrackExternal(),
945
1045
  __metadata("design:type", Command)
946
- ], VerticalFocusContainerComponent.prototype, "leftArrowCommand", void 0);
1046
+ ], AddItemInteractionContextComponent.prototype, "addCommand", void 0);
947
1047
  __decorate([
948
- HostListener('keyup.arrowLeft', ['$event']),
949
- __metadata("design:type", Function),
950
- __metadata("design:paramtypes", [KeyboardEvent]),
951
- __metadata("design:returntype", void 0)
952
- ], VerticalFocusContainerComponent.prototype, "arrowLeft", null);
1048
+ ViewChild(InPlaceInteractionContextComponent),
1049
+ __metadata("design:type", InPlaceInteractionContextComponent)
1050
+ ], AddItemInteractionContextComponent.prototype, "interactionContext", void 0);
953
1051
  __decorate([
954
- HostListener('keyup.arrowRight', ['$event']),
955
- __metadata("design:type", Function),
956
- __metadata("design:paramtypes", [KeyboardEvent]),
957
- __metadata("design:returntype", void 0)
958
- ], VerticalFocusContainerComponent.prototype, "arrowRight", null);
959
- __decorate([
960
- HostListener('keyup.arrowDown', ['$event']),
961
- __metadata("design:type", Function),
962
- __metadata("design:paramtypes", [KeyboardEvent]),
963
- __metadata("design:returntype", void 0)
964
- ], VerticalFocusContainerComponent.prototype, "arrowDown", null);
1052
+ HostBinding('class.interaction-active'),
1053
+ __metadata("design:type", Boolean),
1054
+ __metadata("design:paramtypes", [])
1055
+ ], AddItemInteractionContextComponent.prototype, "active", null);
965
1056
  __decorate([
966
- HostListener('keyup.arrowUp', ['$event']),
967
- __metadata("design:type", Function),
968
- __metadata("design:paramtypes", [KeyboardEvent]),
969
- __metadata("design:returntype", void 0)
970
- ], VerticalFocusContainerComponent.prototype, "arrowUp", null);
971
- VerticalFocusContainerComponent = __decorate([
1057
+ HostBinding('tabindex'),
1058
+ __metadata("design:type", Object)
1059
+ ], AddItemInteractionContextComponent.prototype, "tabindex", void 0);
1060
+ AddItemInteractionContextComponent = __decorate([
972
1061
  Component({
973
- selector: 'aup-vertical-focus-container',
974
- template: "<ng-content></ng-content>\n",
975
- providers: [
976
- { provide: FocusManager }
977
- ],
978
- styles: [":host{display:block}"]
1062
+ selector: 'aup-add-item-interaction-context',
1063
+ template: "<aup-in-place-interaction-context #interactionContext [animateFirstActivity]=\"false\">\n <a part=\"link\" class=\"link\" [pectinCommand]=\"clickCommand\"><mat-icon>add</mat-icon> {{label}}</a>\n</aup-in-place-interaction-context>\n",
1064
+ styles: [":host{--def-link-color:var(--link-color, currentColor);--def-link-backgound:var(--link-background, rgba(0, 0, 0, 0.05));--def-link-border-radius:var(--link-border-radius, 4px);--def-link-padding:var(--link-padding, calc(var(--aup-default-padding) / 2));display:flex;flex-direction:column;border-radius:var(--def-link-border-radius);box-sizing:border-box;outline:0}:host:hover{--link-background:rgba(0,0,0,0.1)}aup-in-place-interaction-context{border-radius:var(--def-link-border-radius)}a.link{display:flex;flex-direction:row;align-items:center;border-radius:var(--def-link-border-radius);color:var(--def-link-color);background:var(--def-link-backgound);padding:var(--def-link-padding);cursor:pointer;text-decoration:none}a.link mat-icon{margin-right:8px}"]
979
1065
  }),
980
- __param(0, Self()),
981
- __metadata("design:paramtypes", [FocusManager])
982
- ], VerticalFocusContainerComponent);
1066
+ __metadata("design:paramtypes", [])
1067
+ ], AddItemInteractionContextComponent);
983
1068
 
984
- /**
985
- * @example
986
- * // CSS Vars
987
- * aup-card-container {
988
- * --card-gap: var(--card-gap, 16px);
989
- * --card-width: var(--card-width, 300px);
990
- * --card-height: var(--card-height, auto);
991
- * --card-min-height: var(--card-min-height, auto);
992
- * --card-background: var(--card-background, #fcfcfb);
993
- * }
994
- *
995
- * // Content Templates:
996
- * #addCardTemplate
997
- * <ng-template #addCardTemplate>
998
- * This is a new card template, it will the the size of the other cards.
999
- * </nav-template>
1000
- *
1001
- */
1002
- let CardContainerComponent = class CardContainerComponent extends DisposableComponent {
1003
- constructor() {
1069
+ class InteractionServiceRoutingAdapter {
1070
+ constructor(activeInteractionContextIds, activeModalContext, createExclusiveInteractionContext) {
1071
+ this.activeInteractionContextIds = activeInteractionContextIds;
1072
+ this.activeModalContext = activeModalContext;
1073
+ this.createExclusiveInteractionContext = createExclusiveInteractionContext;
1074
+ }
1075
+ isActive() {
1076
+ return this.getActiveInteractionContextIds().length > 0;
1077
+ }
1078
+ isModalActive() {
1079
+ return !!this.activeModalContext.value;
1080
+ }
1081
+ // @Trace()
1082
+ isComponentInteracting(component) {
1083
+ return component.interactionContext && component.interactionContext.isActive();
1084
+ }
1085
+ getActiveInteractionContextIds() {
1086
+ return this.activeInteractionContextIds.value;
1087
+ }
1088
+ // @Trace()
1089
+ cancelCurrentModalInteraction() {
1090
+ return this.activeModalContext.value.cancelActiveActivity();
1091
+ }
1092
+ // @Trace()
1093
+ cancelComponentInteraction(component) {
1094
+ return component.interactionContext.cancelActiveActivity();
1095
+ }
1096
+ }
1097
+
1098
+ class ModalInteractionContextFactory {
1099
+ }
1100
+
1101
+ var InteractionService_1;
1102
+ let inplaceMonitorCount = 0;
1103
+ let InteractionService = InteractionService_1 = class InteractionService {
1104
+ constructor(modelInteractionContextFactory) {
1105
+ this.modelInteractionContextFactory = modelInteractionContextFactory;
1106
+ this.garbage = new GarbageCollector();
1107
+ // private readonly _activeModalContext = new MutableValueModel<InteractionContext>();
1108
+ // private readonly _activeInlineContext = new MutableValueModel<InteractionContext>();
1109
+ // private readonly _activeContext: ValueModelChain<InteractionContext>;
1110
+ this._navigationInProgress = new DelegatingValueModel().withDefault(false);
1111
+ const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this.garbage);
1112
+ this.exclusiveInteractionRegistry = new InteractionService_1.ContextRegistry();
1113
+ this.modalInteractionRegistry = new InteractionService_1.ContextRegistry();
1114
+ this.inPlaceInteractionRegistry = new InteractionService_1.ContextRegistry();
1115
+ this.modalInteractionRegistry.disableWhen(valueOf.any(this.exclusiveInteractionRegistry.active, this.modalInteractionRegistry.active).areTruthy());
1116
+ this.inPlaceInteractionRegistry.disableWhen(valueOf.any(this.exclusiveInteractionRegistry.active, this.modalInteractionRegistry.active, this.inPlaceInteractionRegistry.active).areTruthy());
1117
+ this.active = valueOf.any(this.inPlaceInteractionRegistry.active, this.modalInteractionRegistry.active).areTruthy();
1118
+ // TODO: chain.concat(listOrValueModels) would be nice.
1119
+ this.activeInteractionContextIds = chain(this.inPlaceInteractionRegistry.interactionContextIds)
1120
+ .concat(this.modalInteractionRegistry.interactionContextIds);
1121
+ this.activeModalContext = chain(this.modalInteractionRegistry.interactionContexts).first();
1122
+ this.inModalInteraction = chain(this.activeModalContext).isNotNil();
1123
+ }
1124
+ isActive() {
1125
+ return this.active.value;
1126
+ }
1127
+ /**
1128
+ * @deprecated use #createModalInteractionContextDisposedWith instead.
1129
+ * @param disposable
1130
+ */
1131
+ createModalInteractionContextFor(disposable) {
1132
+ return this.createModalInteractionContextDisposedWith(disposable);
1133
+ }
1134
+ /**
1135
+ * Creates a new model interaction context that will be disposed along with the component.
1136
+ * @param disposable
1137
+ */
1138
+ createModalInteractionContextDisposedWith(disposable) {
1139
+ // TODO: look at making the registry the factory..
1140
+ return this.modelInteractionContextFactory.createInteractionContext('modal', new InteractionService_1.ApiAdapter(this.placeRouter, this.modalInteractionRegistry));
1141
+ }
1142
+ registerInplaceInteractionContext(interactionContext) {
1143
+ // TODO: look at making the registry the factory..
1144
+ // Todo: check for double registration.
1145
+ // Todo: allow multiple inplace interactions..
1146
+ interactionContext.initialise(`ip${++inplaceMonitorCount}`, new InteractionService_1.ApiAdapter(this.placeRouter, this.inPlaceInteractionRegistry));
1147
+ }
1148
+ /**
1149
+ * Creates an interaction context that will prevent any other contexts from starting an
1150
+ * activity until it is disposed. This is intended for use by the router for passing
1151
+ * to PlaceComponent.canDeactivate(interactionContext). This ensures components don't
1152
+ * try and interact in a way that we can't track and synchronise with the browser back
1153
+ * button.
1154
+ */
1155
+ registerPlaceRouter(router) {
1156
+ assert$1.isFalsey(this.placeRouter);
1157
+ this.placeRouter = router;
1158
+ this._navigationInProgress.setDelegate(this.placeRouter.navigationInProgress);
1159
+ const self = this;
1160
+ return new InteractionServiceRoutingAdapter(this.activeInteractionContextIds, this.activeModalContext, () => {
1161
+ return self.modelInteractionContextFactory.createInteractionContext('exclusive', new InteractionService_1.ApiAdapter(this.placeRouter, this.exclusiveInteractionRegistry));
1162
+ });
1163
+ }
1164
+ };
1165
+ InteractionService.ctorParameters = () => [
1166
+ { type: ModalInteractionContextFactory }
1167
+ ];
1168
+ InteractionService.ɵprov = ɵɵdefineInjectable({ factory: function InteractionService_Factory() { return new InteractionService(ɵɵinject(ModalInteractionContextFactory)); }, token: InteractionService, providedIn: "root" });
1169
+ InteractionService = InteractionService_1 = __decorate([
1170
+ Injectable({
1171
+ providedIn: 'root'
1172
+ }),
1173
+ __metadata("design:paramtypes", [ModalInteractionContextFactory])
1174
+ ], InteractionService);
1175
+ (function (InteractionService) {
1176
+ /**
1177
+ * Provides a mechanism for the service to keep track of what the API adapters are doing to
1178
+ * ensure the rules are followed, i.e. modal or in-place interaction aren't started while
1179
+ * an exclusive routing interaction is active.
1180
+ */
1181
+ class ContextRegistry extends GarbageCollector {
1182
+ constructor() {
1183
+ super();
1184
+ this._interactions = new MutableListModel();
1185
+ this._disabledDelegate = new DelegatingValueModel().withDefault(false);
1186
+ const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
1187
+ this.active = chain(this._interactions).isNotEmpty();
1188
+ this.interactionContextIds = chain(this._interactions).pluck("identifier");
1189
+ }
1190
+ get interactionContexts() {
1191
+ return this._interactions.readonly;
1192
+ }
1193
+ start(context) {
1194
+ this._interactions.push(context);
1195
+ }
1196
+ finish(context) {
1197
+ this._interactions.remove(context);
1198
+ }
1199
+ isActive() {
1200
+ return this.active.value;
1201
+ }
1202
+ disableWhen(disabled) {
1203
+ this._disabledDelegate.setDelegate(disabled);
1204
+ }
1205
+ }
1206
+ InteractionService.ContextRegistry = ContextRegistry;
1207
+ class ApiAdapter {
1208
+ constructor(placeRouter, contextRegistry) {
1209
+ this.placeRouter = placeRouter;
1210
+ this.contextRegistry = contextRegistry;
1211
+ }
1212
+ // @Trace()
1213
+ notifyActive(context) {
1214
+ assert$1.isTruthy(context.identifier);
1215
+ this.contextRegistry.start(context);
1216
+ return this.isNavigationInProgress() ? Promise.resolve() : this.placeRouter.syncInteractionContextIdsWithRouter();
1217
+ }
1218
+ // @Trace()
1219
+ isNavigationInProgress() {
1220
+ return this.placeRouter.navigationInProgress.value;
1221
+ }
1222
+ // @Trace()
1223
+ notifyFinished(context) {
1224
+ this.contextRegistry.finish(context);
1225
+ // :: Important ::
1226
+ // This method will be traversed by both the place router (during can canDeactivate guards) and user land code
1227
+ // (both when routing is idle and while it is active in PlaceComponent.canDeactivate()).
1228
+ // The result of pushInteractionIdsToRoute will not start until after the current route finishes, and the
1229
+ // current route won't finish until after this promise returns... Deadlock.
1230
+ // So in order to keep this logic out of the activities we perform the check here and ensure that
1231
+ // any interactions with the context while routing is active returns immediately.
1232
+ return this.isNavigationInProgress() ? Promise.resolve() : this.placeRouter.syncInteractionContextIdsWithRouter();
1233
+ }
1234
+ }
1235
+ InteractionService.ApiAdapter = ApiAdapter;
1236
+ })(InteractionService || (InteractionService = {}));
1237
+
1238
+ let InPlaceInteractionContextComponent = class InPlaceInteractionContextComponent extends DisposableComponent {
1239
+ constructor(interactionService, tabConfig) {
1004
1240
  super();
1241
+ this.interactionService = interactionService;
1242
+ this.tabConfig = tabConfig;
1243
+ /**
1244
+ * If true then the first startActivity call will slide the activity into view. If false
1245
+ * the activity will replace the existing content immediately.
1246
+ */
1247
+ this.animateFirstActivity = true;
1248
+ }
1249
+ get animationDuration() {
1250
+ var _a;
1251
+ return this.animateFirstActivity ? (((_a = this.tabConfig) === null || _a === void 0 ? void 0 : _a.animationDuration) || '500ms') : "0ms";
1252
+ }
1253
+ ngAfterViewInit() {
1254
+ this.interactionService.registerInplaceInteractionContext(this);
1255
+ }
1256
+ initialise(id, api) {
1257
+ this.activityContainerComponent.initialise(id, api);
1258
+ }
1259
+ get identifier() {
1260
+ return this.activityContainerComponent.identifier;
1261
+ }
1262
+ alert(alert) {
1263
+ return this.activityContainerComponent.alert(alert);
1264
+ }
1265
+ cancelActiveActivity() {
1266
+ return this.activityContainerComponent.cancelActiveActivity();
1267
+ }
1268
+ confirm(confirm) {
1269
+ return this.activityContainerComponent.confirm(confirm);
1270
+ }
1271
+ confirmOrReject(confirm) {
1272
+ return this.activityContainerComponent.confirmOrReject(confirm);
1273
+ }
1274
+ confirmThen(confirm, activityType, data) {
1275
+ return this.activityContainerComponent.confirmThen(confirm, activityType);
1276
+ }
1277
+ isActive() {
1278
+ return this.activityContainerComponent.isActive();
1005
1279
  }
1006
- ngOnInit() {
1280
+ startActivity(activityType, data) {
1281
+ return this.activityContainerComponent.startActivity(activityType, data);
1007
1282
  }
1008
1283
  };
1284
+ InPlaceInteractionContextComponent.ctorParameters = () => [
1285
+ { type: InteractionService },
1286
+ { type: undefined, decorators: [{ type: Inject, args: [MAT_TABS_CONFIG,] }, { type: Optional }] }
1287
+ ];
1009
1288
  __decorate([
1010
- Input(),
1011
- TrackExternal(),
1012
- __metadata("design:type", Command)
1013
- ], CardContainerComponent.prototype, "addCardCommand", void 0);
1289
+ ViewChild('activityContainer', { static: true }),
1290
+ __metadata("design:type", ActivityContainerComponent)
1291
+ ], InPlaceInteractionContextComponent.prototype, "activityContainerComponent", void 0);
1014
1292
  __decorate([
1015
- ContentChild("addCardTemplate"),
1016
- __metadata("design:type", TemplateRef)
1017
- ], CardContainerComponent.prototype, "addCardTemplate", void 0);
1018
- CardContainerComponent = __decorate([
1293
+ Input(),
1294
+ __metadata("design:type", Object)
1295
+ ], InPlaceInteractionContextComponent.prototype, "animateFirstActivity", void 0);
1296
+ InPlaceInteractionContextComponent = __decorate([
1019
1297
  Component({
1020
- selector: 'aup-card-container',
1021
- template: "<div class=\"card-container\">\n <ng-content></ng-content>\n\n <div class=\"add-card-container\" *ngIf=\"addCardCommand.enabled.value\" [pectinCommand]=\"addCardCommand\">\n <mat-icon>add</mat-icon>\n </div>\n\n <div class=\"add-card-template\" *ngIf=\"addCardTemplate\">\n <ng-container [ngTemplateOutlet]=\"addCardTemplate\"></ng-container>\n </div>\n\n</div>\n",
1022
- styles: [":root{--aup-default-padding:var(--default-padding, 18px)}.dialog-interaction-context{max-width:95vw!important;max-height:95vh!important}.dialog-interaction-context mat-dialog-container{max-width:95vw!important;max-height:95vh!important;padding:0}[no-tab-header]>mat-tab-header{display:none}[full-height-tabs] .mat-tab-body-wrapper,mat-tab-group.full-height-tabs .mat-tab-body-wrapper{flex:1}[full-height-tabs] .mat-tab-body-wrapper .mat-tab-body-content,[full-height-tabs] .mat-tab-body-wrapper mat-tab-body,mat-tab-group.full-height-tabs .mat-tab-body-wrapper .mat-tab-body-content,mat-tab-group.full-height-tabs .mat-tab-body-wrapper mat-tab-body{display:flex;flex-direction:column;justify-content:stretch}.router-outlet-container>*{position:absolute;top:0;left:0;bottom:0;right:0}:host{--resolved-card-gap:var(--card-gap, 16px);--resolved-card-width:var(--card-width, 300px);--resolved-card-height:var(--card-height, auto);--resolved-card-min-height:var(--card-min-height, auto);--resolved-card-background:var(--card-background, #fcfcfb);flex:1;display:block;background:var(--resolved-card-background)}.card-container{display:-ms-grid;display:grid;grid-template-columns:repeat(auto-fill,var(--resolved-card-width));grid-template-rows:repeat(auto-fit,minmax(0,var(--resolved-card-height)));grid-gap:var(--resolved-card-gap);box-sizing:border-box;padding:var(--resolved-card-gap);min-height:calc(var(--resolved-card-height) + 2 * var(--resolved-card-gap));min-width:calc(var(--resolved-card-width) + 2 * var(--resolved-card-gap));width:calc((var(--resolved-card-width) + var(--resolved-card-gap)) * 2 + var(--grid-gap));max-width:100%}.add-card-container{width:var(--resolved-card-width);height:var(--resolved-card-height);min-height:var(--resolved-card-min-height);display:flex;flex-direction:column;align-items:center;justify-content:center;box-sizing:border-box;border:2px dashed rgba(0,0,0,.1);border-radius:6px;font-weight:300;cursor:pointer;color:rgba(0,0,0,.54);background-color:rgba(255,255,255,.8);transition:280ms cubic-bezier(.4,0,.2,1)}.add-card-container mat-icon{font-size:200%}.add-card-container:hover{transition:280ms cubic-bezier(.4,0,.2,1);border-color:transparent;background-color:#fff;color:rgba(0,0,0,.54)}.add-card-container:hover:hover{box-shadow:0 2px 4px -1px rgba(0,0,0,.2),0 4px 5px 0 rgba(0,0,0,.14),0 1px 10px 0 rgba(0,0,0,.12)}.add-card-template-container{width:var(--resolved-card-width);height:var(--resolved-card-height);display:flex;flex-direction:column;align-items:stretch;justify-content:stretch}"]
1298
+ selector: 'aup-in-place-interaction-context',
1299
+ template: "<mat-tab-group no-tab-header [selectedIndex]=\"isActive() ? 1 : 0\" full-height-tabs [dynamicHeight]=\"false\" [animationDuration]=\"animationDuration\">\n <mat-tab>\n <ng-content></ng-content>\n </mat-tab>\n <mat-tab>\n <aup-activity-container #activityContainer [dynamicHeight]=\"false\"></aup-activity-container>\n </mat-tab>\n</mat-tab-group>\n\n",
1300
+ styles: [":host{display:flex;flex-direction:column}mat-tab-group{flex:1}"]
1023
1301
  }),
1024
- __metadata("design:paramtypes", [])
1025
- ], CardContainerComponent);
1026
-
1027
- let ComponentsModule = class ComponentsModule {
1028
- };
1029
- ComponentsModule = __decorate([
1030
- NgModule({
1031
- declarations: [
1032
- NumberInputComponent,
1033
- StringInputComponent,
1034
- TextInputComponent,
1035
- PasswordInputComponent,
1036
- SelectInputComponent,
1037
- CheckboxInputComponent,
1038
- ScrollContainerComponent,
1039
- NoopComponent,
1040
- AbstractInputComponent,
1041
- SwitchCaseComponent,
1042
- SwitchCaseWhenDirective,
1043
- SwitchCaseDefaultDirective,
1044
- FocusContainerComponent,
1045
- VerticalFocusContainerComponent,
1046
- FocusableComponent,
1047
- CardContainerComponent
1048
- ],
1049
- imports: [
1050
- CommonModule,
1051
- BrowserAnimationsModule,
1052
- FormsModule,
1053
- MatInputModule,
1054
- MatFormFieldModule,
1055
- MatSelectModule,
1056
- MatTabsModule,
1057
- DirectivesModule,
1058
- MatIconModule,
1059
- MatButtonModule,
1060
- MatCheckboxModule
1061
- ],
1062
- exports: [
1063
- NumberInputComponent,
1064
- StringInputComponent,
1065
- TextInputComponent,
1066
- PasswordInputComponent,
1067
- CheckboxInputComponent,
1068
- SelectInputComponent,
1069
- ScrollContainerComponent,
1070
- NoopComponent,
1071
- SwitchCaseComponent,
1072
- SwitchCaseWhenDirective,
1073
- SwitchCaseDefaultDirective,
1074
- FocusContainerComponent,
1075
- VerticalFocusContainerComponent,
1076
- FocusableComponent,
1077
- CardContainerComponent
1078
- ],
1079
- providers: [
1080
- FocusBindingFactory
1081
- ]
1082
- })
1083
- ], ComponentsModule);
1302
+ __param(1, Inject(MAT_TABS_CONFIG)), __param(1, Optional()),
1303
+ __metadata("design:paramtypes", [InteractionService, Object])
1304
+ ], InPlaceInteractionContextComponent);
1084
1305
 
1085
- class Dimension {
1086
- constructor(width, height) {
1087
- this.width = width;
1088
- this.height = height;
1306
+ let PopupInteractionContextComponent = class PopupInteractionContextComponent extends DisposableComponent {
1307
+ constructor(_element, _overlay) {
1308
+ super();
1309
+ this._element = _element;
1310
+ this._overlay = _overlay;
1311
+ this.outputPortal = new ComponentPortal(InPlaceInteractionContextComponent);
1312
+ this.anchorX = 'start';
1313
+ this.anchorY = 'bottom';
1089
1314
  }
1090
- }
1091
-
1092
- class Point {
1093
- constructor(x, y) {
1094
- this.x = x;
1095
- this.y = y;
1315
+ get active() {
1316
+ return this.isActive();
1096
1317
  }
1097
- static from(data) {
1098
- return new Point(data.x, data.y);
1318
+ startActivity(activityType, data) {
1319
+ const overlayRef = this._overlay.create({
1320
+ hasBackdrop: false,
1321
+ panelClass: 'aup-popup-interaction-panel',
1322
+ positionStrategy: this._overlay.position()
1323
+ .flexibleConnectedTo(this._element)
1324
+ .withPositions(this.computePositions())
1325
+ .withGrowAfterOpen(true)
1326
+ });
1327
+ const componentRef = overlayRef.attach(this.outputPortal);
1328
+ this.interactionContext = componentRef.instance;
1329
+ return new Promise((resolve, reject) => {
1330
+ // HACK: afterViewInit won't have been called yet. Need to add when.valueOf(interactionContext.ready).becomesTruthy(...)
1331
+ setTimeout(() => {
1332
+ this.interactionContext.startActivity(activityType, data)
1333
+ .then(resolve)
1334
+ .catch(reject)
1335
+ .finally(() => overlayRef.dispose());
1336
+ });
1337
+ });
1099
1338
  }
1100
- translate(x, y) {
1101
- return new Point(this.x + x, this.y + y);
1339
+ computePositions() {
1340
+ const overlayX = this.anchorX === 'start' ? 'start' : 'end';
1341
+ const overlayY = this.anchorY === 'top' ? 'bottom' : 'top';
1342
+ return [
1343
+ { originX: this.anchorX, originY: this.anchorY, overlayX: overlayX, overlayY: overlayY }
1344
+ // TODO: compute some meaningful alternatives.
1345
+ // { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },
1346
+ // { originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top' },
1347
+ // { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom' },
1348
+ // { originX: 'end', originY: 'top', overlayX: 'end', overlayY: 'bottom' }
1349
+ ];
1102
1350
  }
1103
- }
1351
+ cancelActiveActivity() {
1352
+ return this.interactionContext.cancelActiveActivity();
1353
+ }
1354
+ isActive() {
1355
+ return this.interactionContext && this.interactionContext.isActive();
1356
+ }
1357
+ ngOnInit() {
1358
+ }
1359
+ };
1360
+ PopupInteractionContextComponent.ctorParameters = () => [
1361
+ { type: ElementRef },
1362
+ { type: Overlay }
1363
+ ];
1364
+ __decorate([
1365
+ HostBinding('class.interaction-active'),
1366
+ __metadata("design:type", Boolean),
1367
+ __metadata("design:paramtypes", [])
1368
+ ], PopupInteractionContextComponent.prototype, "active", null);
1369
+ __decorate([
1370
+ Input(),
1371
+ __metadata("design:type", String)
1372
+ ], PopupInteractionContextComponent.prototype, "anchorX", void 0);
1373
+ __decorate([
1374
+ Input(),
1375
+ __metadata("design:type", String)
1376
+ ], PopupInteractionContextComponent.prototype, "anchorY", void 0);
1377
+ PopupInteractionContextComponent = __decorate([
1378
+ Component({
1379
+ selector: 'aup-popup-interaction-context',
1380
+ template: "<ng-content></ng-content>\n",
1381
+ styles: [":host{display:inline}:host.interaction-active{background:rgba(0,0,0,.05)}"]
1382
+ }),
1383
+ __metadata("design:paramtypes", [ElementRef, Overlay])
1384
+ ], PopupInteractionContextComponent);
1104
1385
 
1105
- class Bounds extends Dimension {
1106
- constructor(top, left, width, height) {
1107
- super(width, height);
1108
- this.top = top;
1109
- this.left = left;
1110
- this.width = width;
1111
- this.height = height;
1386
+ let InteractionContextTriggerFor = class InteractionContextTriggerFor extends GarbageCollector {
1387
+ constructor() {
1388
+ super();
1389
+ this.activityDone = new EventEmitter();
1390
+ this.activityCancelled = new EventEmitter();
1112
1391
  }
1113
- relativePositionOf(point) {
1114
- if (point instanceof MouseEvent) {
1115
- return new Point(point.clientX - this.left, point.clientY - this.top);
1392
+ onEnter(event) {
1393
+ if (!this.aupInteractionContextTriggerFor.isActive()) {
1394
+ this.startActivity();
1116
1395
  }
1117
1396
  else {
1118
- return new Point(point.x - this.left, point.y - this.top);
1397
+ this.aupInteractionContextTriggerFor.cancelActiveActivity();
1119
1398
  }
1120
1399
  }
1121
- }
1122
- (function (Bounds) {
1123
- function ofElement(element) {
1124
- const rect = element.getBoundingClientRect();
1125
- return new Bounds(rect.top, rect.left, rect.width, rect.height);
1400
+ onClick(event) {
1401
+ if (!this.aupInteractionContextTriggerFor.isActive()) {
1402
+ this.startActivity();
1403
+ }
1404
+ else {
1405
+ this.aupInteractionContextTriggerFor.cancelActiveActivity();
1406
+ }
1126
1407
  }
1127
- Bounds.ofElement = ofElement;
1128
- })(Bounds || (Bounds = {}));
1408
+ startActivity() {
1409
+ assert.isTruthy(this.aupInteractionContextTriggerFor);
1410
+ assert.isFalsey(this.aupInteractionContextTriggerFor.isActive());
1411
+ assert.isTruthy(this.activityClass);
1412
+ this.aupInteractionContextTriggerFor.startActivity(this.activityClass, this.activityData)
1413
+ .then(result => {
1414
+ this.activityDone.emit(result);
1415
+ })
1416
+ .catch(error => {
1417
+ this.activityCancelled.emit(error);
1418
+ });
1419
+ }
1420
+ prepareActivityData() {
1421
+ return ___default.isFunction(this.activityDataFactory()) ? this.activityDataFactory() : this.activityData;
1422
+ }
1423
+ };
1424
+ __decorate([
1425
+ Input(),
1426
+ __metadata("design:type", Object)
1427
+ ], InteractionContextTriggerFor.prototype, "aupInteractionContextTriggerFor", void 0);
1428
+ __decorate([
1429
+ Input(),
1430
+ __metadata("design:type", Object)
1431
+ ], InteractionContextTriggerFor.prototype, "activityClass", void 0);
1432
+ __decorate([
1433
+ Input(),
1434
+ __metadata("design:type", Object)
1435
+ ], InteractionContextTriggerFor.prototype, "activityData", void 0);
1436
+ __decorate([
1437
+ Input(),
1438
+ __metadata("design:type", Function)
1439
+ ], InteractionContextTriggerFor.prototype, "activityDataFactory", void 0);
1440
+ __decorate([
1441
+ Output(),
1442
+ __metadata("design:type", Object)
1443
+ ], InteractionContextTriggerFor.prototype, "activityDone", void 0);
1444
+ __decorate([
1445
+ Output(),
1446
+ __metadata("design:type", Object)
1447
+ ], InteractionContextTriggerFor.prototype, "activityCancelled", void 0);
1448
+ __decorate([
1449
+ HostListener('keyup.enter'),
1450
+ __metadata("design:type", Function),
1451
+ __metadata("design:paramtypes", [KeyboardEvent]),
1452
+ __metadata("design:returntype", void 0)
1453
+ ], InteractionContextTriggerFor.prototype, "onEnter", null);
1454
+ __decorate([
1455
+ HostListener('click'),
1456
+ __metadata("design:type", Function),
1457
+ __metadata("design:paramtypes", [MouseEvent]),
1458
+ __metadata("design:returntype", void 0)
1459
+ ], InteractionContextTriggerFor.prototype, "onClick", null);
1460
+ InteractionContextTriggerFor = __decorate([
1461
+ Directive({
1462
+ selector: '[aupInteractionContextTriggerFor]'
1463
+ }),
1464
+ __metadata("design:paramtypes", [])
1465
+ ], InteractionContextTriggerFor);
1129
1466
 
1130
- let ResizeAwareComponent = class ResizeAwareComponent extends DisposableComponent {
1131
- constructor(elementRef, ngZone) {
1467
+ class DialogInteractionContext extends AbstractInteractionContext {
1468
+ constructor(identifier, api, dialogService, config) {
1132
1469
  super();
1133
- this.elementRef = elementRef;
1134
- this.ngZone = ngZone;
1135
- this._boundsModel = new MutableValueModel(new Bounds(0, 0, 0, 0));
1470
+ this.identifier = identifier;
1471
+ this.api = api;
1472
+ this.dialogService = dialogService;
1473
+ this.config = config;
1474
+ this.garbage = new GarbageCollector();
1475
+ assert$1.notNil(dialogService);
1136
1476
  }
1137
- ngAfterViewInit() {
1138
- this.updateBounds();
1139
- const element = this.elementRef.nativeElement;
1140
- const ro = new ResizeObserver((entries, observer) => {
1141
- this.ngZone.run(() => this.updateBounds());
1142
- });
1143
- ro.observe(element);
1144
- this.onDispose(() => ro.disconnect());
1477
+ cancelActiveActivity() {
1478
+ return this.activityContainer.cancelActiveActivity();
1145
1479
  }
1146
- get boundsModel() {
1147
- return this._boundsModel.readonly;
1480
+ dispose() {
1481
+ if (this.isActive()) {
1482
+ lang.illegalState('Dispose called while active.');
1483
+ }
1484
+ this.garbage.dispose();
1148
1485
  }
1149
- get nativeElement() {
1150
- return this.elementRef.nativeElement;
1486
+ registerDisposable(disposable) {
1487
+ return this.garbage.registerDisposable(disposable);
1151
1488
  }
1152
- // TODO: Make this handle body scroll
1153
- relativePositionOf(point) {
1154
- return this.bounds.relativePositionOf(point);
1489
+ isActive() {
1490
+ return !!this.activityContainer && this.activityContainer.isActive();
1155
1491
  }
1156
- get bounds() {
1157
- return this._boundsModel.value;
1492
+ createAndLaunchActivity(activityType, data, disableClose) {
1493
+ assert$1.isNil(this._currentActivityRef);
1494
+ const config = Object.assign(Object.assign({}, this.config), {
1495
+ disableClose,
1496
+ panelClass: 'dialog-interaction-context'
1497
+ });
1498
+ const self = this;
1499
+ const matDialogRef = this.dialogService.open(ActivityContainerComponent, config);
1500
+ const activityContainer = this.activityContainer = matDialogRef.componentInstance;
1501
+ this.activityContainer.initialise(this.identifier, this.api);
1502
+ const activityResult = this.activityContainer.startActivity(activityType, data);
1503
+ activityResult.finally(() => matDialogRef.close());
1504
+ // we need to check if our onDone/onCancel methods above we called or if we were
1505
+ // closed by the user clicking the backdrop. If the later then we need to cancel our
1506
+ // activity.
1507
+ matDialogRef.afterClosed().subscribe(promiseAlreadyFinished => {
1508
+ if (activityContainer.isActive()) {
1509
+ activityContainer.cancelActiveActivity();
1510
+ }
1511
+ this.activityContainer = null;
1512
+ });
1513
+ matDialogRef.updateSize();
1514
+ matDialogRef.afterOpened().subscribe(promiseAlreadyFinished => {
1515
+ matDialogRef.updateSize();
1516
+ });
1517
+ return activityResult;
1518
+ }
1519
+ }
1520
+
1521
+ const DIALOG_INTERACTION_SERVICE_DEFAULTS = new InjectionToken('DIALOG_INTERACTION_SERVICE_DEFAULTS');
1522
+ let DialogInteractionContextFactory = class DialogInteractionContextFactory extends ModalInteractionContextFactory {
1523
+ constructor(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
1524
+ super();
1525
+ this.dialogService = dialogService;
1526
+ this.dialogServiceDefaults = dialogServiceDefaults;
1527
+ this.matDialogDefaultConfig = matDialogDefaultConfig;
1528
+ assert$1.notNil(dialogService);
1158
1529
  }
1159
- updateBounds() {
1160
- this._boundsModel.value = Bounds.ofElement(this.nativeElement);
1530
+ createInteractionContext(identifier, api) {
1531
+ const config = Object.assign(Object.assign({ autoFocus: false, hasBackdrop: true, closeOnNavigation: false }, this.matDialogDefaultConfig), this.dialogServiceDefaults);
1532
+ return new DialogInteractionContext(identifier, api, this.dialogService, config);
1161
1533
  }
1162
1534
  };
1163
- ResizeAwareComponent.ctorParameters = () => [
1164
- { type: ElementRef },
1165
- { type: NgZone }
1535
+ DialogInteractionContextFactory.ctorParameters = () => [
1536
+ { type: MatDialog },
1537
+ { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [DIALOG_INTERACTION_SERVICE_DEFAULTS,] }] },
1538
+ { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [MAT_DIALOG_DEFAULT_OPTIONS,] }] }
1166
1539
  ];
1167
- ResizeAwareComponent = __decorate([
1168
- Directive(),
1169
- __metadata("design:paramtypes", [ElementRef, NgZone])
1170
- ], ResizeAwareComponent);
1540
+ DialogInteractionContextFactory.ɵprov = ɵɵdefineInjectable({ factory: function DialogInteractionContextFactory_Factory() { return new DialogInteractionContextFactory(ɵɵinject(MatDialog), ɵɵinject(DIALOG_INTERACTION_SERVICE_DEFAULTS, 8), ɵɵinject(MAT_DIALOG_DEFAULT_OPTIONS, 8)); }, token: DialogInteractionContextFactory, providedIn: "root" });
1541
+ DialogInteractionContextFactory = __decorate([
1542
+ Injectable({
1543
+ providedIn: 'root'
1544
+ }),
1545
+ __param(1, Optional()), __param(1, Inject(DIALOG_INTERACTION_SERVICE_DEFAULTS)),
1546
+ __param(2, Optional()), __param(2, Inject(MAT_DIALOG_DEFAULT_OPTIONS)),
1547
+ __metadata("design:paramtypes", [MatDialog,
1548
+ MatDialogConfig,
1549
+ MatDialogConfig])
1550
+ ], DialogInteractionContextFactory);
1171
1551
 
1172
1552
  /**
1173
1553
  * @file Automatically generated by barrelsby.
1174
1554
  */
1175
1555
 
1176
- let ActivityActionsComponent = class ActivityActionsComponent extends DisposableComponent {
1556
+ let AbstractInputActivity = class AbstractInputActivity extends Activity {
1557
+ constructor(data) {
1558
+ super();
1559
+ this.data = data;
1560
+ this.class = 'aup-input-activity';
1561
+ const form = new Form();
1562
+ this.valueModel = form.valueModel(this.data.initialValue);
1563
+ this.valueModel.validateUsing(data.validators || []);
1564
+ this.confirmCommand = Command.create(() => {
1565
+ if (this.valueModel.validate()) {
1566
+ if (data.save) {
1567
+ return Promise.resolve(data.save(this.valueModel, this.interactionContext))
1568
+ .then(() => this.done());
1569
+ }
1570
+ else {
1571
+ this.done(this.valueModel.value);
1572
+ }
1573
+ }
1574
+ });
1575
+ this.cancelCommand = Command.create(() => {
1576
+ this.cancel();
1577
+ });
1578
+ }
1579
+ onActivityReady() {
1580
+ this.valueModel.focusContext.requestFocus();
1581
+ }
1582
+ };
1583
+ AbstractInputActivity.ctorParameters = () => [
1584
+ { type: undefined, decorators: [{ type: Inject, args: [ACTIVITY_DATA,] }] }
1585
+ ];
1586
+ __decorate([
1587
+ HostBinding('class'),
1588
+ __metadata("design:type", Object)
1589
+ ], AbstractInputActivity.prototype, "class", void 0);
1590
+ AbstractInputActivity = __decorate([
1591
+ Component({
1592
+ template: ``
1593
+ }),
1594
+ __param(0, Inject(ACTIVITY_DATA)),
1595
+ __metadata("design:paramtypes", [Object])
1596
+ ], AbstractInputActivity);
1597
+
1598
+ let AbstractInputComponent = class AbstractInputComponent extends DisposableComponent {
1177
1599
  constructor() {
1178
- super(...arguments);
1179
- this.align = 'start';
1600
+ super();
1601
+ /**
1602
+ * A backing model for all our @Input() valueModel properties which should be defined as follows.
1603
+ *
1604
+ * @Input() @TrackExternal({useExisting: "delegatingFormValueModel"})
1605
+ * valueModel: FormValueModel<string> | MutableValueModel<string>;
1606
+ *
1607
+ * This approach allows the input to accept plain or form models but all backed by a form
1608
+ * friendly delegate. We have to use an existing delegate for union types as pectin just
1609
+ * gets told it's an Object and can't scan for a base type annotated with @DelegateUsing(..).
1610
+ */
1611
+ // We have to register it as a disposable so it ditches any listeners when we're disposed.
1612
+ this.delegatingFormValueModel = this.registerDisposable(new DelegatingFormValueModel());
1613
+ // TODO: fix this.
1614
+ // tslint:disable-next-line:no-output-native
1615
+ this.focus = new EventEmitter();
1616
+ // tslint:disable-next-line:no-output-native
1617
+ this.blur = new EventEmitter();
1618
+ // tslint:disable-next-line:no-output-native
1619
+ this.enterKey = new EventEmitter();
1620
+ // tslint:disable-next-line:no-output-native
1621
+ this.escapeKey = new EventEmitter();
1622
+ this.baseClassName = 'aup-input-component';
1623
+ const self = this;
1624
+ this.errorStateMatcher = {
1625
+ isErrorState(control, form) {
1626
+ return self.hasErrors();
1627
+ }
1628
+ };
1180
1629
  }
1181
- get alignEnd() {
1182
- return this.align === 'end';
1630
+ notifyClick() {
1631
+ this.safelyInvoke(this.clickCommand);
1632
+ }
1633
+ notifyFocusIn() {
1634
+ this.safelyInvoke(this.focusCommand);
1635
+ this.focus.emit();
1636
+ }
1637
+ notifyFocusOut() {
1638
+ this.safelyInvoke(this.blurCommand);
1639
+ this.blur.emit();
1640
+ }
1641
+ notifyEnterKey() {
1642
+ this.safelyInvoke(this.enterCommand);
1643
+ this.enterKey.emit();
1644
+ }
1645
+ notifyEscapeKey() {
1646
+ this.safelyInvoke(this.escapeCommand);
1647
+ this.escapeKey.emit();
1648
+ }
1649
+ safelyInvoke(command) {
1650
+ if (command && command.enabled.value) {
1651
+ command.execute();
1652
+ }
1183
1653
  }
1184
1654
  ngOnInit() {
1185
1655
  }
1186
- hasConfirmText() {
1187
- return !___default.isEmpty(this.confirmText);
1656
+ isEnabled() {
1657
+ return this.enabled.value;
1658
+ }
1659
+ get enabled() {
1660
+ return this.delegatingFormValueModel.enabled;
1661
+ }
1662
+ hasErrors() {
1663
+ return !this.errorList.query().isEmpty();
1664
+ }
1665
+ get errorList() {
1666
+ return this.delegatingFormValueModel.errorList;
1667
+ }
1668
+ get firstError() {
1669
+ return this.hasErrors() ? this.errorList.value[0] : null;
1188
1670
  }
1189
1671
  };
1190
1672
  __decorate([
1191
1673
  Input(),
1192
- TrackExternal(),
1193
- __metadata("design:type", Command)
1194
- ], ActivityActionsComponent.prototype, "confirmCommand", void 0);
1674
+ __metadata("design:type", String)
1675
+ ], AbstractInputComponent.prototype, "label", void 0);
1195
1676
  __decorate([
1196
1677
  Input(),
1197
1678
  __metadata("design:type", String)
1198
- ], ActivityActionsComponent.prototype, "confirmText", void 0);
1679
+ ], AbstractInputComponent.prototype, "floatLabel", void 0);
1199
1680
  __decorate([
1200
1681
  Input(),
1201
- TrackExternal(),
1202
- __metadata("design:type", Command)
1203
- ], ActivityActionsComponent.prototype, "cancelCommand", void 0);
1682
+ __metadata("design:type", String)
1683
+ ], AbstractInputComponent.prototype, "hint", void 0);
1204
1684
  __decorate([
1205
1685
  Input(),
1206
1686
  __metadata("design:type", String)
1207
- ], ActivityActionsComponent.prototype, "align", void 0);
1687
+ ], AbstractInputComponent.prototype, "placeholder", void 0);
1208
1688
  __decorate([
1209
- HostBinding('class.align-end'),
1210
- __metadata("design:type", Boolean),
1689
+ Input('command.focus'),
1690
+ __metadata("design:type", Command)
1691
+ ], AbstractInputComponent.prototype, "focusCommand", void 0);
1692
+ __decorate([
1693
+ Input('command.blur'),
1694
+ __metadata("design:type", Command)
1695
+ ], AbstractInputComponent.prototype, "blurCommand", void 0);
1696
+ __decorate([
1697
+ Input('command.enter'),
1698
+ __metadata("design:type", Command)
1699
+ ], AbstractInputComponent.prototype, "enterCommand", void 0);
1700
+ __decorate([
1701
+ Input('command.escape'),
1702
+ __metadata("design:type", Command)
1703
+ ], AbstractInputComponent.prototype, "escapeCommand", void 0);
1704
+ __decorate([
1705
+ Input('command.click'),
1706
+ __metadata("design:type", Command)
1707
+ ], AbstractInputComponent.prototype, "clickCommand", void 0);
1708
+ __decorate([
1709
+ Output(),
1710
+ __metadata("design:type", Object)
1711
+ ], AbstractInputComponent.prototype, "focus", void 0);
1712
+ __decorate([
1713
+ Output(),
1714
+ __metadata("design:type", Object)
1715
+ ], AbstractInputComponent.prototype, "blur", void 0);
1716
+ __decorate([
1717
+ Output(),
1718
+ __metadata("design:type", Object)
1719
+ ], AbstractInputComponent.prototype, "enterKey", void 0);
1720
+ __decorate([
1721
+ Output(),
1722
+ __metadata("design:type", Object)
1723
+ ], AbstractInputComponent.prototype, "escapeKey", void 0);
1724
+ __decorate([
1725
+ HostBinding('class'),
1726
+ __metadata("design:type", Object)
1727
+ ], AbstractInputComponent.prototype, "baseClassName", void 0);
1728
+ __decorate([
1729
+ HostListener('click'),
1730
+ __metadata("design:type", Function),
1731
+ __metadata("design:paramtypes", []),
1732
+ __metadata("design:returntype", void 0)
1733
+ ], AbstractInputComponent.prototype, "notifyClick", null);
1734
+ __decorate([
1735
+ HostListener('focusin'),
1736
+ __metadata("design:type", Function),
1737
+ __metadata("design:paramtypes", []),
1738
+ __metadata("design:returntype", void 0)
1739
+ ], AbstractInputComponent.prototype, "notifyFocusIn", null);
1740
+ __decorate([
1741
+ HostListener('focusout'),
1742
+ __metadata("design:type", Function),
1743
+ __metadata("design:paramtypes", []),
1744
+ __metadata("design:returntype", void 0)
1745
+ ], AbstractInputComponent.prototype, "notifyFocusOut", null);
1746
+ AbstractInputComponent = __decorate([
1747
+ Component({ template: '' }),
1211
1748
  __metadata("design:paramtypes", [])
1212
- ], ActivityActionsComponent.prototype, "alignEnd", null);
1213
- ActivityActionsComponent = __decorate([
1214
- Component({
1215
- selector: 'aup-activity-actions',
1216
- template: "<button class=\"cancel\" mat-icon-button [pectinCommand]=\"cancelCommand\">\n <mat-icon>clear</mat-icon>\n</button>\n<button class=\"confirm\" *ngIf=\"!hasConfirmText()\" mat-icon-button [pectinCommand]=\"confirmCommand\">\n <mat-icon>done</mat-icon>\n</button>\n<button class=\"confirm\" *ngIf=\"hasConfirmText()\" mat-button [pectinCommand]=\"confirmCommand\">{{confirmText}}</button>\n<div class=\"content\">\n <ng-content></ng-content>\n</div>\n",
1217
- styles: [":host{display:-ms-grid;display:grid;grid-template-areas:\"cancel confirm content\";-ms-grid-columns:auto auto 1fr;grid-template-columns:auto auto 1fr;-ms-grid-rows:auto;grid-template-rows:auto;align-items:center;justify-content:end}:host.align-end{grid-template-areas:\"content cancel confirm\";-ms-grid-columns:1fr auto auto;grid-template-columns:1fr auto auto}.cancel{-ms-grid-row:1;-ms-grid-column:1;grid-area:cancel}:host.align-end>.cancel{-ms-grid-row:1;-ms-grid-column:2}.confirm{-ms-grid-row:1;-ms-grid-column:2;grid-area:confirm}:host.align-end>.confirm{-ms-grid-row:1;-ms-grid-column:3}.content{-ms-grid-row:1;-ms-grid-column:3;grid-area:content;text-align:left}:host.align-end>.content{-ms-grid-row:1;-ms-grid-column:1}"]
1218
- })
1219
- ], ActivityActionsComponent);
1749
+ ], AbstractInputComponent);
1220
1750
 
1221
- const ACTIVITY_DATA = new InjectionToken('InteractionActivityData');
1222
- class Activity extends DisposableComponent {
1751
+ let CheckboxInputComponent = class CheckboxInputComponent extends AbstractInputComponent {
1223
1752
  constructor() {
1224
- super(...arguments);
1225
- this._busyModel = new DelegatingValueModel().withDefault(false);
1226
- }
1227
- initialise(nestedInteractionContext, activityContext) {
1228
- assert$1.isNil(this._activityContext);
1229
- this._activityContext = activityContext;
1230
- this._interactionContext = nestedInteractionContext;
1231
- }
1232
- get interactionContext() {
1233
- assert$1.isTruthy(this.isInitialised());
1234
- return this._interactionContext;
1235
- }
1236
- done(result) {
1237
- return this._activityContext.onDone(result);
1238
- }
1239
- cancel(error) {
1240
- this._activityContext.onCancel(error);
1241
- }
1242
- // @Trace()
1243
- onActivityReady() {
1244
- }
1245
- get busy() {
1246
- return this._busyModel.readonly;
1247
- }
1248
- busyWhile(busyModel) {
1249
- this._busyModel.setDelegate(busyModel);
1250
- }
1251
- isBusy() {
1252
- return this._busyModel.value;
1753
+ super();
1754
+ this.color = 'accent';
1755
+ this.labelPosition = 'after';
1253
1756
  }
1254
- isInitialised() {
1255
- return !!this._activityContext;
1757
+ ngOnInit() {
1256
1758
  }
1257
- }
1759
+ };
1760
+ __decorate([
1761
+ Input(), TrackExternal({ delegateTo: 'delegatingFormValueModel' }),
1762
+ __metadata("design:type", Object)
1763
+ ], CheckboxInputComponent.prototype, "valueModel", void 0);
1764
+ __decorate([
1765
+ Input(),
1766
+ __metadata("design:type", String)
1767
+ ], CheckboxInputComponent.prototype, "color", void 0);
1768
+ __decorate([
1769
+ Input(),
1770
+ __metadata("design:type", String)
1771
+ ], CheckboxInputComponent.prototype, "labelPosition", void 0);
1772
+ CheckboxInputComponent = __decorate([
1773
+ Component({
1774
+ selector: 'aup-checkbox-input',
1775
+ template: "<!-- TODO: add focus binding -->\n<mat-checkbox\n [(ngModel)]=\"valueModel.value\"\n [color]=\"color\"\n [labelPosition]=\"labelPosition\"\n [disabled]=\"!isEnabled()\"\n>{{label}}</mat-checkbox>\n<mat-hint *ngIf=\"hint\">{{hint}}</mat-hint>\n<mat-error *ngIf=\"hasErrors\">{{firstError}}</mat-error>\n",
1776
+ styles: [":host{display:inline-flex;flex-direction:column;margin-top:24px;margin-bottom:16px}mat-error,mat-hint{margin-top:4px;margin-left:24px;font-size:12px;font-weight:400;line-height:13.5px}"]
1777
+ }),
1778
+ __metadata("design:paramtypes", [])
1779
+ ], CheckboxInputComponent);
1258
1780
 
1259
- let AlertDialogComponent = class AlertDialogComponent extends Activity {
1260
- constructor(alert) {
1781
+ let NumberInputComponent = class NumberInputComponent extends AbstractInputComponent {
1782
+ constructor() {
1261
1783
  super();
1262
- this.alert = alert;
1784
+ this.min = Number.MIN_SAFE_INTEGER;
1785
+ this.max = Number.MAX_SAFE_INTEGER;
1263
1786
  }
1264
1787
  ngOnInit() {
1265
1788
  }
1266
1789
  };
1267
- AlertDialogComponent.ctorParameters = () => [
1268
- { type: undefined, decorators: [{ type: Inject, args: [ACTIVITY_DATA,] }] }
1269
- ];
1270
- AlertDialogComponent = __decorate([
1790
+ __decorate([
1791
+ Input(), TrackExternal({ delegateTo: 'delegatingFormValueModel' }),
1792
+ __metadata("design:type", Object)
1793
+ ], NumberInputComponent.prototype, "valueModel", void 0);
1794
+ __decorate([
1795
+ Input(),
1796
+ __metadata("design:type", Object)
1797
+ ], NumberInputComponent.prototype, "min", void 0);
1798
+ __decorate([
1799
+ Input(),
1800
+ __metadata("design:type", Object)
1801
+ ], NumberInputComponent.prototype, "max", void 0);
1802
+ NumberInputComponent = __decorate([
1271
1803
  Component({
1272
- selector: 'aup-alert-dialog',
1273
- template: "<h3 matDialogTitle *ngIf=\"alert.title\">{{alert.title()}}</h3>\n<div matDialogContent>\n <p *ngFor=\"let line of alert.content()\">{{line}}</p>\n</div>\n<div matDialogActions>\n <button mat-raised-button color=\"primary\" (click)=\"done()\" data-cy=\"close-button\">{{alert.ok()}}</button>\n</div>\n",
1274
- styles: [":host{display:block;padding:var(--aup-default-padding)}.mat-dialog-content{margin:0;padding:0}.mat-dialog-actions{margin-bottom:0!important;padding:0;align-items:flex-end;justify-content:flex-end}"]
1804
+ selector: 'aup-number-input',
1805
+ template: "<mat-form-field appearance=\"standard\" [floatLabel]=\"floatLabel\">\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\n <input type=\"number\"\n matInput\n placeholder=\"{{placeholder}}\"\n [(ngModel)]=\"valueModel.value\"\n [disabled]=\"!enabled.value\"\n (keydown.enter)=\"notifyEnterKey()\"\n (keydown.escape)=\"notifyEscapeKey()\"\n [pectinFocusBinding]=\"delegatingFormValueModel?.focusContext\"\n [errorStateMatcher]=\"errorStateMatcher\"\n [min]=\"min\"\n [max]=\"max\"\n >\n <mat-hint *ngIf=\"hint\">{{hint}}</mat-hint>\n <mat-error *ngIf=\"hasErrors\">{{firstError}}</mat-error>\n</mat-form-field>\n",
1806
+ styles: [":host{display:block}input,mat-form-field{width:100%}input mat-hint.faux-error,mat-form-field mat-hint.faux-error{color:#f44336}:host-context(aup-table-cell-renderer) mat-form-field div.mat-form-field-infix{width:auto}"]
1275
1807
  }),
1276
- __param(0, Inject(ACTIVITY_DATA)),
1277
- __metadata("design:paramtypes", [Object])
1278
- ], AlertDialogComponent);
1808
+ __metadata("design:paramtypes", [])
1809
+ ], NumberInputComponent);
1279
1810
 
1280
- let ConfirmThenDialogComponent = class ConfirmThenDialogComponent extends Activity {
1281
- constructor(config) {
1811
+ let PasswordInputComponent = class PasswordInputComponent extends AbstractInputComponent {
1812
+ constructor() {
1282
1813
  super();
1283
- this.config = config;
1284
- assert.notNil(config);
1285
1814
  }
1286
1815
  ngOnInit() {
1287
1816
  }
1288
- get confirm() {
1289
- return this.config.confirm;
1290
- }
1291
- isDestructive() {
1292
- return this.confirm.destructive && this.confirm.destructive();
1293
- }
1294
- onConfirm() {
1295
- this.interactionContext.startActivity(this.config.activityType, this.config.data)
1296
- .then((result) => this.done(result))
1297
- .catch(error => this.cancel(error));
1298
- }
1299
1817
  };
1300
- ConfirmThenDialogComponent.ctorParameters = () => [
1301
- { type: undefined, decorators: [{ type: Inject, args: [ACTIVITY_DATA,] }] }
1302
- ];
1303
- ConfirmThenDialogComponent = __decorate([
1818
+ __decorate([
1819
+ Input(), TrackExternal({ delegateTo: "delegatingFormValueModel" }),
1820
+ __metadata("design:type", Object)
1821
+ ], PasswordInputComponent.prototype, "valueModel", void 0);
1822
+ PasswordInputComponent = __decorate([
1304
1823
  Component({
1305
- selector: 'aup-confirmation-dialog',
1306
- template: "<h3 matDialogTitle *ngIf=\"confirm.title\">{{confirm.title()}}</h3>\n<div matDialogContent>\n <p *ngFor=\"let line of confirm.content()\">{{line}}</p>\n</div>\n<div matDialogActions>\n <button mat-button (click)=\"cancel()\" data-cy=\"cancel-button\">{{confirm.cancel()}}</button>\n <button mat-raised-button [color]=\"isDestructive() ? 'warn' : 'primary'\"\n (click)=\"onConfirm()\" data-cy=\"confirm-button\">{{confirm.ok()}}</button>\n</div>\n\n",
1307
- styles: [":host{display:block;padding:var(--aup-default-padding)}.mat-dialog-content{margin:0;padding:0}.mat-dialog-actions{margin-bottom:0!important;padding:0;align-items:flex-end;justify-content:flex-end}"]
1824
+ selector: 'aup-password-input',
1825
+ template: "<mat-form-field appearance=\"standard\" [floatLabel]=\"floatLabel\">\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\n <input type=\"password\"\n matInput\n placeholder=\"{{placeholder}}\"\n [(ngModel)]=\"valueModel.value\"\n [disabled]=\"!enabled.value\"\n (keydown.enter)=\"notifyEnterKey()\"\n (keydown.escape)=\"notifyEscapeKey()\"\n [pectinFocusBinding]=\"delegatingFormValueModel.focusContext\"\n [errorStateMatcher]=\"errorStateMatcher\"\n >\n <mat-hint *ngIf=\"hint\">{{hint}}</mat-hint>\n <mat-error *ngIf=\"hasErrors\">{{firstError}}</mat-error>\n</mat-form-field>\n\n",
1826
+ styles: [":host{display:block}input,mat-form-field{width:100%}input mat-hint.faux-error,mat-form-field mat-hint.faux-error{color:#f44336}:host-context(aup-table-cell-renderer) mat-form-field div.mat-form-field-infix{width:auto}"]
1308
1827
  }),
1309
- __param(0, Inject(ACTIVITY_DATA)),
1310
- __metadata("design:paramtypes", [Object])
1311
- ], ConfirmThenDialogComponent);
1828
+ __metadata("design:paramtypes", [])
1829
+ ], PasswordInputComponent);
1312
1830
 
1313
- let ConfirmationDialogComponent = class ConfirmationDialogComponent extends Activity {
1314
- constructor(confirm) {
1831
+ let SelectInputComponent = class SelectInputComponent extends AbstractInputComponent {
1832
+ constructor() {
1315
1833
  super();
1316
- this.confirm = confirm;
1317
- assert.notNil(confirm);
1834
+ this.optionLabelFormat = (option) => (option && this.optionLabel) ? option[this.optionLabel] : option;
1318
1835
  }
1319
1836
  ngOnInit() {
1320
1837
  }
1321
- isDestructive() {
1322
- return this.confirm.destructive && this.confirm.destructive();
1323
- }
1324
1838
  };
1325
- ConfirmationDialogComponent.ctorParameters = () => [
1326
- { type: undefined, decorators: [{ type: Inject, args: [ACTIVITY_DATA,] }] }
1327
- ];
1328
- ConfirmationDialogComponent = __decorate([
1839
+ __decorate([
1840
+ Input(), TrackExternal({ delegateTo: "delegatingFormValueModel" }),
1841
+ __metadata("design:type", Object)
1842
+ ], SelectInputComponent.prototype, "valueModel", void 0);
1843
+ __decorate([
1844
+ Input(), TrackExternal(),
1845
+ __metadata("design:type", ListModel)
1846
+ ], SelectInputComponent.prototype, "optionsModel", void 0);
1847
+ __decorate([
1848
+ Input(), StoreInListModel('optionsModel'),
1849
+ __metadata("design:type", Array)
1850
+ ], SelectInputComponent.prototype, "options", void 0);
1851
+ __decorate([
1852
+ Input(),
1853
+ __metadata("design:type", Object)
1854
+ ], SelectInputComponent.prototype, "optionLabel", void 0);
1855
+ __decorate([
1856
+ Input(),
1857
+ __metadata("design:type", Boolean)
1858
+ ], SelectInputComponent.prototype, "allowNil", void 0);
1859
+ __decorate([
1860
+ ContentChild("optionTemplate"),
1861
+ __metadata("design:type", TemplateRef)
1862
+ ], SelectInputComponent.prototype, "optionTemplateRef", void 0);
1863
+ __decorate([
1864
+ ContentChild("nilOptionTemplate"),
1865
+ __metadata("design:type", TemplateRef)
1866
+ ], SelectInputComponent.prototype, "nilOptionTemplateRef", void 0);
1867
+ __decorate([
1868
+ Input(),
1869
+ __metadata("design:type", Function)
1870
+ ], SelectInputComponent.prototype, "optionLabelFormat", void 0);
1871
+ SelectInputComponent = __decorate([
1329
1872
  Component({
1330
- selector: 'aup-confirmation-dialog',
1331
- template: "<h3 matDialogTitle *ngIf=\"confirm.title\">{{confirm.title()}}</h3>\n<div matDialogContent>\n <p *ngFor=\"let line of confirm.content()\">{{line}}</p>\n</div>\n<div matDialogActions>\n <button mat-button (click)=\"cancel()\" data-cy=\"cancel-button\">{{confirm.cancel()}}</button>\n <button mat-raised-button [color]=\"isDestructive() ? 'warn' : 'primary'\"\n (click)=\"done()\" data-cy=\"confirm-button\">{{confirm.ok()}}</button>\n</div>\n\n",
1332
- styles: [":host{display:block;padding:var(--aup-default-padding)}.mat-dialog-content{margin:0;padding:0}.mat-dialog-actions{margin-bottom:0!important;padding:0;align-items:flex-end;justify-content:flex-end}"]
1873
+ selector: 'aup-select-input',
1874
+ template: "<mat-form-field appearance=\"standard\" [floatLabel]=\"floatLabel\">\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\n <mat-select placeholder=\"{{placeholder}}\"\n [(ngModel)]=\"valueModel.value\"\n [disabled]=\"!enabled.value\"\n (keydown.enter)=\"notifyEnterKey()\"\n (keydown.escape)=\"notifyEscapeKey()\"\n [pectinFocusBinding]=\"delegatingFormValueModel.focusContext\"\n [errorStateMatcher]=\"errorStateMatcher\"\n >\n <mat-option *ngIf=\"allowNil\">{{placeholder}}</mat-option>\n <mat-option *ngFor=\"let option of optionsModel.value; let i = index\" [value]=\"option\">\n <ng-container *ngIf=\"!optionTemplateRef\">{{optionLabelFormat(option)}}</ng-container>\n <ng-container *ngIf=\"optionTemplateRef\"\n [ngTemplateOutlet]=\"optionTemplateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: option, index: i }\"\n >\n </ng-container>\n </mat-option>\n </mat-select>\n <mat-hint *ngIf=\"hint\">{{hint}}</mat-hint>\n <mat-error *ngIf=\"hasErrors\">{{firstError}}</mat-error>\n</mat-form-field>\n",
1875
+ styles: [":host{display:inline-block}mat-form-field{width:100%}"]
1333
1876
  }),
1334
- __param(0, Inject(ACTIVITY_DATA)),
1335
- __metadata("design:paramtypes", [Object])
1336
- ], ConfirmationDialogComponent);
1337
-
1338
- class AbstractInteractionContext {
1339
- startActivity(activityType, data) {
1340
- return this.createAndLaunchActivity(activityType, data, false);
1341
- }
1342
- confirm(confirm) {
1343
- // Important: we have to implement confirmOrReject as the main entry point
1344
- // as the canDeactivation guards need to be able to cancel an interaction
1345
- // without caring about returning a value.
1346
- return this.confirmOrReject(confirm).then(() => true).catch(() => false);
1347
- }
1348
- alert(alert) {
1349
- // TODO: Test disableClose === false
1350
- return this.createAndLaunchActivity(AlertDialogComponent, alert, false);
1351
- }
1352
- confirmOrReject(confirm) {
1353
- return this.createAndLaunchActivity(ConfirmationDialogComponent, confirm, true);
1354
- }
1355
- /**
1356
- * Presents the confirmation to the user and runs the activity only if the user confirms.
1357
- * @param confirm:Confirm the confirmation to display.
1358
- * @param activityType the activity to run if confirmed.
1359
- * @param data the activity data.
1360
- */
1361
- confirmThen(confirm, activityType, data) {
1362
- return this.createAndLaunchActivity(ConfirmThenDialogComponent, {
1363
- confirm,
1364
- activityType: activityType,
1365
- data: data
1366
- }, true);
1367
- }
1368
- }
1877
+ __metadata("design:paramtypes", [])
1878
+ ], SelectInputComponent);
1369
1879
 
1370
- class ActivityRef {
1371
- constructor(activityClass, activityData, onComplete) {
1372
- this.activityClass = activityClass;
1373
- this.activityData = activityData;
1374
- this.onComplete = onComplete;
1375
- this._complete = false;
1376
- this.deferredResult = Deferred.defer();
1377
- }
1378
- isActivityRealised() {
1379
- return !!this._activity;
1380
- }
1381
- isComplete() {
1382
- return this._complete;
1383
- }
1384
- get activity() {
1385
- assert.isTruthy(this.isActivityRealised());
1386
- return this._activity;
1387
- }
1388
- notifyActivityCreated(activity, nestedInteractionContext) {
1389
- assert.isNil(this._activity);
1390
- this._activity = activity;
1391
- const self = this;
1392
- this._activity.initialise(nestedInteractionContext, {
1393
- onDone(result) {
1394
- self.finishActivity(deferred => deferred.resolve(result));
1395
- },
1396
- onCancel(error) {
1397
- self.finishActivity(deferred => deferred.reject(error));
1398
- }
1399
- });
1400
- }
1401
- finishActivity(resolveOrReject) {
1402
- assert.isFalsey(this.isComplete());
1403
- resolveOrReject(this.deferredResult);
1404
- this._complete = true;
1405
- this.onComplete(this);
1406
- }
1407
- cancel() {
1408
- this.activity.cancel();
1409
- }
1410
- get activityResult() {
1411
- return this.deferredResult.promise;
1412
- }
1413
- }
1880
+ let StringInputActivity = class StringInputActivity extends AbstractInputActivity {
1881
+ };
1882
+ StringInputActivity = __decorate([
1883
+ Component({
1884
+ selector: 'aup-string-input-activity',
1885
+ template: `
1886
+ <aup-string-input [valueModel]="valueModel"
1887
+ [label]="data.label"
1888
+ [placeholder]="data.placeholder"
1889
+ [command.enter]="confirmCommand"
1890
+ [command.escape]="cancelCommand"></aup-string-input>
1891
+ <aup-activity-actions align="end"
1892
+ [confirmCommand]="confirmCommand"
1893
+ [cancelCommand]="cancelCommand"></aup-activity-actions>
1894
+ `
1895
+ })
1896
+ ], StringInputActivity);
1414
1897
 
1415
- /**
1416
- * ActivityOutletComponent creates and displays an activity and delegates the interaction context functionality to an
1417
- * external service.
1418
- */
1419
- let ActivityOutletComponent = class ActivityOutletComponent {
1420
- constructor(componentFactoryResolver, viewContainerRef, injector) {
1421
- this.componentFactoryResolver = componentFactoryResolver;
1422
- this.viewContainerRef = viewContainerRef;
1423
- this.injector = injector;
1424
- }
1425
- set activityRef(activityRef) {
1426
- if (this.activityRef && !this.activityRef.isComplete()) {
1427
- lang$1.illegalState("changing activity before previous one has completed");
1428
- }
1429
- this._activityRef = activityRef;
1430
- this.loadActivity(activityRef);
1431
- }
1432
- ;
1433
- get activityRef() {
1434
- return this._activityRef;
1435
- }
1436
- ngOnInit() {
1437
- }
1438
- loadActivity(activityRef) {
1439
- const injector = Injector.create({
1440
- providers: [
1441
- { provide: ACTIVITY_DATA, useValue: activityRef.activityData }
1442
- ],
1443
- parent: this.injector
1898
+ let StringInputComponent = class StringInputComponent extends AbstractInputComponent {
1899
+ constructor() {
1900
+ super();
1901
+ const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
1902
+ this.clearCommand = Command.create(() => {
1903
+ this.valueModel.value = null;
1444
1904
  });
1445
- const componentFactory = this.componentFactoryResolver.resolveComponentFactory(activityRef.activityClass);
1446
- this.viewContainerRef.clear();
1447
- // console.log(`creating component -> ${activityRef.activityClass.name}`);
1448
- this.activityComponentRef = this.viewContainerRef.createComponent(componentFactory, 0, injector);
1449
- this.activityRef.notifyActivityCreated(this.activityComponentRef.instance, this.nestedInteractionContext);
1905
+ this.clearCommand.disableWhile(chain.stringValue(this.valueModel).isBlank());
1450
1906
  }
1451
- get component() {
1452
- return this.activityComponentRef.instance;
1907
+ ngOnInit() {
1453
1908
  }
1454
1909
  };
1455
- ActivityOutletComponent.ctorParameters = () => [
1456
- { type: ComponentFactoryResolver },
1457
- { type: ViewContainerRef },
1458
- { type: Injector }
1459
- ];
1460
1910
  __decorate([
1461
- Input(),
1911
+ Input(), TrackExternal({ delegateTo: 'delegatingFormValueModel' }),
1462
1912
  __metadata("design:type", Object)
1463
- ], ActivityOutletComponent.prototype, "nestedInteractionContext", void 0);
1913
+ ], StringInputComponent.prototype, "valueModel", void 0);
1464
1914
  __decorate([
1465
- Input(),
1466
- __metadata("design:type", ActivityRef),
1467
- __metadata("design:paramtypes", [ActivityRef])
1468
- ], ActivityOutletComponent.prototype, "activityRef", null);
1469
- ActivityOutletComponent = __decorate([
1915
+ Input(), TrackExternal({ defaultValue: false }),
1916
+ __metadata("design:type", ValueModel)
1917
+ ], StringInputComponent.prototype, "enableClearModel", void 0);
1918
+ __decorate([
1919
+ Input(), StoreInValueModel('enableClearModel'),
1920
+ __metadata("design:type", Boolean)
1921
+ ], StringInputComponent.prototype, "enableClear", void 0);
1922
+ StringInputComponent = __decorate([
1470
1923
  Component({
1471
- selector: 'aup-activity-outlet',
1472
- template: '',
1473
- styles: [":host{display:block}"]
1924
+ selector: 'aup-string-input',
1925
+ template: "<mat-form-field appearance=\"standard\" [floatLabel]=\"floatLabel\">\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\n <input matInput\n placeholder=\"{{placeholder}}\"\n [(ngModel)]=\"valueModel.value\"\n [disabled]=\"!enabled.value\"\n (keydown.enter)=\"notifyEnterKey()\"\n (keydown.escape)=\"notifyEscapeKey()\"\n [pectinFocusBinding]=\"delegatingFormValueModel.focusContext\"\n [errorStateMatcher]=\"errorStateMatcher\"\n >\n <mat-hint *ngIf=\"hint\">{{hint}}</mat-hint>\n <mat-error *ngIf=\"hasErrors\">{{firstError}}</mat-error>\n <button mat-button mat-icon-button matSuffix *ngIf=\"enableClear\" [pectinCommand]=\"clearCommand\">\n <mat-icon>close</mat-icon>\n </button>\n</mat-form-field>\n\n",
1926
+ styles: [":host{display:block}input,mat-form-field{width:100%}input mat-hint.faux-error,mat-form-field mat-hint.faux-error{color:#f44336}:host-context(aup-table-cell-renderer) mat-form-field div.mat-form-field-infix{width:auto}button[disabled]{visibility:hidden}"]
1474
1927
  }),
1475
- __metadata("design:paramtypes", [ComponentFactoryResolver,
1476
- ViewContainerRef,
1477
- Injector])
1478
- ], ActivityOutletComponent);
1928
+ __metadata("design:paramtypes", [])
1929
+ ], StringInputComponent);
1479
1930
 
1480
- let ActivityContainerComponent = class ActivityContainerComponent extends AbstractInteractionContext {
1931
+ let TextInputComponent = class TextInputComponent extends AbstractInputComponent {
1481
1932
  constructor() {
1482
1933
  super();
1483
- this.dynamicHeight = false;
1484
- this.activityTabs = [];
1485
- this.garbage = new GarbageCollector();
1934
+ this.rows = 2;
1935
+ // const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
1486
1936
  }
1487
1937
  ngOnInit() {
1488
1938
  }
1489
- ngAfterViewInit() {
1490
- const { chain, observe } = Dsl.disposeWith(this);
1491
- // using the component directly rather than (animationDone)=.. allows us
1492
- // to keep our callback private.
1493
- observe.valuesFrom(this.tabs.animationDone).subscribe(() => this.onAnimationFinished());
1494
- }
1495
- initialise(identifier, api) {
1496
- assert.isFalsey(this.isInitialised());
1497
- assert.notNil(identifier);
1498
- assert.notNil(api);
1499
- this._identifier = identifier;
1500
- this.interactionServiceApi = api;
1501
- }
1502
- get identifier() {
1503
- return this._identifier;
1504
- }
1505
- isInitialised() {
1506
- return !!this.identifier;
1507
- }
1508
- /**
1509
- * Returns true if an activity is currently running.
1510
- */
1511
- isActive() {
1512
- return this.getActiveActivityCount() > 0;
1513
- }
1514
- registerDisposable(disposable) {
1515
- return this.garbage.registerDisposable(disposable);
1939
+ };
1940
+ __decorate([
1941
+ Input(), TrackExternal({ delegateTo: 'delegatingFormValueModel' }),
1942
+ __metadata("design:type", Object)
1943
+ ], TextInputComponent.prototype, "valueModel", void 0);
1944
+ __decorate([
1945
+ Input(),
1946
+ __metadata("design:type", Object)
1947
+ ], TextInputComponent.prototype, "rows", void 0);
1948
+ __decorate([
1949
+ Input(),
1950
+ __metadata("design:type", Number)
1951
+ ], TextInputComponent.prototype, "cols", void 0);
1952
+ TextInputComponent = __decorate([
1953
+ Component({
1954
+ selector: 'aup-text-input',
1955
+ template: "<mat-form-field appearance=\"standard\" [floatLabel]=\"floatLabel\">\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\n <textarea matInput\n placeholder=\"{{placeholder}}\"\n [(ngModel)]=\"valueModel.value\"\n [disabled]=\"!enabled.value\"\n (keydown.enter)=\"notifyEnterKey()\"\n (keydown.escape)=\"notifyEscapeKey()\"\n [pectinFocusBinding]=\"delegatingFormValueModel.focusContext\"\n [errorStateMatcher]=\"errorStateMatcher\"\n [rows]=\"rows\"\n [cols]=\"cols\"\n >\n </textarea>\n <mat-hint *ngIf=\"hint\">{{hint}}</mat-hint>\n <mat-error *ngIf=\"hasErrors\">{{firstError}}</mat-error>\n</mat-form-field>\n\n",
1956
+ styles: [":host{display:block}input,mat-form-field{width:100%}input mat-hint.faux-error,mat-form-field mat-hint.faux-error{color:#f44336}:host-context(aup-table-cell-renderer) mat-form-field div.mat-form-field-infix{width:auto}button[disabled]{visibility:hidden}textarea{overflow:auto}"]
1957
+ }),
1958
+ __metadata("design:paramtypes", [])
1959
+ ], TextInputComponent);
1960
+
1961
+ let NoopComponent = class NoopComponent {
1962
+ constructor() {
1516
1963
  }
1517
- dispose() {
1518
- // TODO: think about auto cancelling any outstanding activity on dispose.
1519
- // See NavigationState.Navigating for a use-case.
1520
- assert.isFalsey(this.isActive());
1521
- this.garbage.dispose();
1964
+ };
1965
+ NoopComponent = __decorate([
1966
+ Component({
1967
+ selector: 'aup-noop',
1968
+ template: "",
1969
+ styles: [":host{display:block}"]
1970
+ }),
1971
+ __metadata("design:paramtypes", [])
1972
+ ], NoopComponent);
1973
+
1974
+ let ScrollContainerComponent = class ScrollContainerComponent {
1975
+ constructor() { }
1976
+ ngOnInit() {
1522
1977
  }
1523
- getActiveActivityRef() {
1524
- if (!this.isActive()) {
1525
- lang$1.illegalState('no activity in progress');
1526
- }
1527
- return ___default.findLast(this.activityTabs, tab => !tab.isComplete());
1978
+ };
1979
+ ScrollContainerComponent = __decorate([
1980
+ Component({
1981
+ selector: 'aup-scroll-container',
1982
+ template: "<div class=\"container\">\n <ng-content></ng-content>\n</div>\n",
1983
+ styles: [":host{display:flex;flex-direction:column;min-height:0;align-items:stretch}.container{display:flex;flex-direction:column;flex:1;flex-basis:0;overflow-y:scroll;align-items:stretch}"]
1984
+ }),
1985
+ __metadata("design:paramtypes", [])
1986
+ ], ScrollContainerComponent);
1987
+
1988
+ var SwitchCaseWhenDirective_1, SwitchCaseDefaultDirective_1;
1989
+ class SwitchCaseOption {
1990
+ constructor(templateRef) {
1991
+ this.templateRef = templateRef;
1528
1992
  }
1529
- /**
1530
- * Cancels the current activity and returns true the context is no longer active, false if
1531
- * there is still another activity running.
1532
- */
1533
- // @Trace()
1534
- cancelActiveActivity() {
1535
- return __awaiter(this, void 0, void 0, function* () {
1536
- const activity = this.getActiveActivityRef();
1537
- activity.cancel();
1538
- if (this.isCleaningUp()) {
1539
- return this.waitForInteractionContextCleanupToFinish();
1540
- }
1541
- else {
1542
- return !this.isActive();
1543
- }
1544
- });
1993
+ get name() {
1994
+ return this.constructor.name;
1545
1995
  }
1546
- // TODO: this handling of multiple nested activities is only used by the activity component and is not a general case.
1547
- // @Trace()
1548
- createAndLaunchActivity(activityType, data, disableClose) {
1549
- assert.isTruthy(this.isInitialised()); // make sure we've been initialised
1550
- const activityRef = new ActivityRef(activityType, data, () => {
1551
- const activeActivityCount = this.getActiveActivityCount() > 0;
1552
- if (activeActivityCount) {
1553
- this.triggerTabSynchronisation();
1554
- }
1555
- else {
1556
- this.finishAndStartCleanup();
1557
- }
1558
- });
1559
- this.launchActivity(activityRef);
1560
- // if this is the first activity let the interaction service know.
1561
- if (this.activityTabs.length === 1) {
1562
- // console.log('Now active!!!');
1563
- this.interactionServiceApi.notifyActive(this);
1564
- }
1565
- return activityRef.activityResult;
1996
+ }
1997
+ let SwitchCaseWhenDirective = SwitchCaseWhenDirective_1 = class SwitchCaseWhenDirective extends SwitchCaseOption {
1998
+ constructor(templateRef) {
1999
+ super(templateRef);
2000
+ this.isDefault = false;
1566
2001
  }
1567
- getActiveActivityCount() {
1568
- return this.activityTabs.filter(ref => !ref.isComplete()).length;
2002
+ matches(value) {
2003
+ return this.aupSwitchCaseWhen === value;
1569
2004
  }
1570
- /**
1571
- * Checks if this interaction context has finished an is in the process of waiting
1572
- * for all the infrastructure (including route updates) to be completed.
1573
- */
1574
- isCleaningUp() {
1575
- return !!this._deferredCleanUp;
2005
+ };
2006
+ SwitchCaseWhenDirective.ctorParameters = () => [
2007
+ { type: TemplateRef }
2008
+ ];
2009
+ __decorate([
2010
+ Input(),
2011
+ __metadata("design:type", Object)
2012
+ ], SwitchCaseWhenDirective.prototype, "aupSwitchCaseWhen", void 0);
2013
+ SwitchCaseWhenDirective = SwitchCaseWhenDirective_1 = __decorate([
2014
+ Directive({
2015
+ selector: '[aupSwitchCaseWhen]',
2016
+ providers: [{ provide: SwitchCaseOption, useExisting: SwitchCaseWhenDirective_1 }]
2017
+ }),
2018
+ __metadata("design:paramtypes", [TemplateRef])
2019
+ ], SwitchCaseWhenDirective);
2020
+ let SwitchCaseDefaultDirective = SwitchCaseDefaultDirective_1 = class SwitchCaseDefaultDirective extends SwitchCaseOption {
2021
+ constructor(templateRef) {
2022
+ super(templateRef);
2023
+ this.isDefault = true;
1576
2024
  }
1577
- waitForInteractionContextCleanupToFinish() {
1578
- return __awaiter(this, void 0, void 0, function* () {
1579
- return this._deferredCleanUp ?
1580
- this._deferredCleanUp :
1581
- true;
1582
- });
2025
+ matches(value) {
2026
+ return false;
1583
2027
  }
1584
- // @Trace()
1585
- finishAndStartCleanup() {
1586
- if (!this._deferredCleanUp) {
1587
- // Important:
1588
- // Clear our tabs so the next activity triggers a tab change.
1589
- // Without this our animation done wasn't called when a single
1590
- // new activity followed a single tab activity (since we're tracking
1591
- // by activity index)
1592
- this.activityTabs = [];
1593
- const promise = this.interactionServiceApi.notifyFinished(this);
1594
- this._deferredCleanUp = promise
1595
- .finally(() => {
1596
- this._deferredCleanUp = null;
1597
- });
1598
- }
2028
+ };
2029
+ SwitchCaseDefaultDirective.ctorParameters = () => [
2030
+ { type: TemplateRef }
2031
+ ];
2032
+ SwitchCaseDefaultDirective = SwitchCaseDefaultDirective_1 = __decorate([
2033
+ Directive({
2034
+ selector: '[aupSwitchCaseDefault]',
2035
+ providers: [{ provide: SwitchCaseOption, useExisting: SwitchCaseDefaultDirective_1 }]
2036
+ }),
2037
+ __metadata("design:paramtypes", [TemplateRef])
2038
+ ], SwitchCaseDefaultDirective);
2039
+ let SwitchCaseComponent = class SwitchCaseComponent extends DisposableComponent {
2040
+ constructor(cdr) {
2041
+ super();
2042
+ this.cdr = cdr;
2043
+ this.selectedIndex = 0;
1599
2044
  }
1600
- // @Trace()
1601
- launchActivity(activityRef) {
1602
- const cleanedTabs = this.activityTabs.filter(tab => !tab.isComplete());
1603
- this.activityTabs = cleanedTabs.concat(activityRef);
1604
- this.synchroniseSelectedTabIndex();
2045
+ ngOnInit() {
1605
2046
  }
1606
- activityIndex(index, activityRef) {
1607
- return index;
2047
+ ngAfterContentInit() {
2048
+ const subscription = this.switchCaseOptions.changes.subscribe(change => this.updateSelection());
2049
+ this.onDispose(() => subscription.unsubscribe());
2050
+ const { chain, when } = Dsl.disposeWith(this);
2051
+ when.valueOf(this.switchModel).changes(() => this.updateSelection(), { initialValue: 'triggerChange' });
2052
+ this.cdr.detectChanges();
1608
2053
  }
1609
- ;
1610
- onAnimationFinished() {
1611
- if (this.onAnimationFinishedJob) {
1612
- this.onAnimationFinishedJob();
1613
- this.onAnimationFinishedJob = undefined;
2054
+ updateSelection() {
2055
+ const matchingIndicies = [];
2056
+ this.switchCaseOptions.forEach((option, index) => {
2057
+ if (option.matches(this.switchModel.value)) {
2058
+ matchingIndicies.push(index);
2059
+ }
2060
+ });
2061
+ if (matchingIndicies.length > 1) {
2062
+ console.warn(`found ${matchingIndicies.length} matching case values, displaying the first.`);
1614
2063
  }
1615
- }
1616
- /**
1617
- * Synchronises the selected tab index.
1618
- */
1619
- synchroniseSelectedTabIndex() {
1620
- const previousIndex = this.tabs.selectedIndex;
1621
- const newIndex = this.getActiveActivityCount() - 1;
1622
- if (previousIndex !== newIndex) {
1623
- this.tabs.selectedIndex = newIndex;
1624
- this.onAnimationFinishedJob = () => {
1625
- this.getSelectedOutlet().component.onActivityReady();
1626
- this.activityTabs = this.activityTabs.filter(tab => !tab.isComplete());
1627
- };
2064
+ if (matchingIndicies.length === 0) {
2065
+ this.switchCaseOptions.forEach((option, index) => {
2066
+ matchingIndicies.push(index);
2067
+ });
2068
+ if (matchingIndicies.length > 1) {
2069
+ console.warn(`found ${matchingIndicies.length} default case values, displaying the first.`);
2070
+ }
1628
2071
  }
1629
- }
1630
- getSelectedOutlet() {
1631
- return this.activityOutlets.toArray()[this.tabs.selectedIndex];
1632
- }
1633
- // @Trace()
1634
- triggerTabSynchronisation() {
1635
- if (this.syncSelectedTabTimeout) {
1636
- clearTimeout(this.syncSelectedTabTimeout);
2072
+ if (matchingIndicies.length > 0) {
2073
+ this.selectedIndex = matchingIndicies[0];
2074
+ }
2075
+ else {
2076
+ console.warn(`found no matching or default case values.`);
2077
+ this.selectedIndex = -1;
1637
2078
  }
1638
- this.syncSelectedTabTimeout = setTimeout(() => {
1639
- this.syncSelectedTabTimeout = null;
1640
- this.synchroniseSelectedTabIndex();
1641
- }, 75);
1642
2079
  }
1643
2080
  };
2081
+ SwitchCaseComponent.ctorParameters = () => [
2082
+ { type: ChangeDetectorRef }
2083
+ ];
1644
2084
  __decorate([
1645
- Input(),
1646
- __metadata("design:type", Object)
1647
- ], ActivityContainerComponent.prototype, "dynamicHeight", void 0);
2085
+ Input(), TrackExternal(),
2086
+ __metadata("design:type", ValueModel)
2087
+ ], SwitchCaseComponent.prototype, "switchModel", void 0);
1648
2088
  __decorate([
1649
- ViewChild('tabs', { static: true }),
1650
- __metadata("design:type", MatTabGroup)
1651
- ], ActivityContainerComponent.prototype, "tabs", void 0);
2089
+ Input(), StoreInValueModel('switchModel'),
2090
+ __metadata("design:type", Object)
2091
+ ], SwitchCaseComponent.prototype, "switch", void 0);
1652
2092
  __decorate([
1653
- ViewChildren(ActivityOutletComponent),
2093
+ ContentChildren(SwitchCaseOption),
1654
2094
  __metadata("design:type", QueryList)
1655
- ], ActivityContainerComponent.prototype, "activityOutlets", void 0);
1656
- __decorate([
1657
- Trace(),
1658
- __metadata("design:type", Function),
1659
- __metadata("design:paramtypes", []),
1660
- __metadata("design:returntype", void 0)
1661
- ], ActivityContainerComponent.prototype, "dispose", null);
1662
- ActivityContainerComponent = __decorate([
2095
+ ], SwitchCaseComponent.prototype, "switchCaseOptions", void 0);
2096
+ SwitchCaseComponent = __decorate([
1663
2097
  Component({
1664
- selector: 'aup-activity-container',
1665
- template: "<mat-tab-group #tabs no-tab-header\n [dynamicHeight]=\"dynamicHeight\"\n [class.full-height-tabs]=\"!dynamicHeight\">\n <mat-tab *ngFor=\"let tab of activityTabs; trackBy: activityIndex\" >\n <aup-activity-outlet [nestedInteractionContext]=\"this\" [activityRef]=\"tab\"></aup-activity-outlet>\n </mat-tab>\n</mat-tab-group>\n",
1666
- styles: [":host{display:flex;flex-direction:column}mat-tab-group{flex:1}"]
2098
+ selector: 'aup-switch-case',
2099
+ template: "<mat-tab-group class=\"content-wrapper\" no-tab-header full-height-tabs [selectedIndex]=\"selectedIndex\">\n <mat-tab *ngFor=\"let option of switchCaseOptions\">\n <ng-template [ngTemplateOutlet]=\"option.templateRef\"></ng-template>\n </mat-tab>\n</mat-tab-group>\n\n\n",
2100
+ styles: [":host{display:flex;flex-direction:column;align-items:stretch}mat-tab-group{flex:1}"]
1667
2101
  }),
1668
- __metadata("design:paramtypes", [])
1669
- ], ActivityContainerComponent);
2102
+ __metadata("design:paramtypes", [ChangeDetectorRef])
2103
+ ], SwitchCaseComponent);
1670
2104
 
1671
- class InteractionServiceRoutingAdapter {
1672
- constructor(activeInteractionContextIds, activeModalContext, createExclusiveInteractionContext) {
1673
- this.activeInteractionContextIds = activeInteractionContextIds;
1674
- this.activeModalContext = activeModalContext;
1675
- this.createExclusiveInteractionContext = createExclusiveInteractionContext;
2105
+ let DefaultCellRendererComponent = class DefaultCellRendererComponent {
2106
+ constructor() {
1676
2107
  }
1677
- isActive() {
1678
- return this.getActiveInteractionContextIds().length > 0;
2108
+ set value(value) {
2109
+ this._value = value;
1679
2110
  }
1680
- isModalActive() {
1681
- return !!this.activeModalContext.value;
2111
+ get value() {
2112
+ return this._value;
1682
2113
  }
1683
- // @Trace()
1684
- isComponentInteracting(component) {
1685
- return component.interactionContext && component.interactionContext.isActive();
2114
+ };
2115
+ __decorate([
2116
+ Input(),
2117
+ __metadata("design:type", Object),
2118
+ __metadata("design:paramtypes", [Object])
2119
+ ], DefaultCellRendererComponent.prototype, "value", null);
2120
+ DefaultCellRendererComponent = __decorate([
2121
+ Component({
2122
+ selector: 'aup-default-cell-renderer',
2123
+ template: "{{value}}\n",
2124
+ styles: [""]
2125
+ }),
2126
+ __metadata("design:paramtypes", [])
2127
+ ], DefaultCellRendererComponent);
2128
+
2129
+ let DefaultHeaderCellRendererComponent = class DefaultHeaderCellRendererComponent {
2130
+ constructor() {
1686
2131
  }
1687
- getActiveInteractionContextIds() {
1688
- return this.activeInteractionContextIds.value;
2132
+ };
2133
+ __decorate([
2134
+ Input(),
2135
+ __metadata("design:type", ColumnModel)
2136
+ ], DefaultHeaderCellRendererComponent.prototype, "columnModel", void 0);
2137
+ DefaultHeaderCellRendererComponent = __decorate([
2138
+ Component({
2139
+ selector: 'aup-default-header-renderer',
2140
+ template: "{{columnModel.getHeaderText()}}\n",
2141
+ styles: [""]
2142
+ }),
2143
+ __metadata("design:paramtypes", [])
2144
+ ], DefaultHeaderCellRendererComponent);
2145
+
2146
+ var TableModel_1;
2147
+ // export type StringPropertiesOf<T> = { [K in keyof T]: T[K] extends string ? K : never }[keyof T];
2148
+ // export type NumberPropertiesOf<T> = { [K in keyof T]: T[K] extends number ? K : never }[keyof T];
2149
+ /**
2150
+ * Example:
2151
+ * @example
2152
+ * const model = TableModel.fromList(heroList, table => {
2153
+ * table.pluck("firstName");
2154
+ * table.pluck("lastName");
2155
+ * table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
2156
+ * });
2157
+ *
2158
+ * Editable tables
2159
+ * @example
2160
+ * const saveCommand = UnaryCommand.create((form: Form<Hero>) => {
2161
+ * if (form.validate()) {
2162
+ * // normal form save stuff
2163
+ * return true; // finish editing
2164
+ * }
2165
+ * return false; // continue editiing
2166
+ * }
2167
+ * const colorsNames: ListModel<string> = ...;
2168
+ * const model = TableModel.fromList(heroList, table => {
2169
+ * table.pluck("firstName").cellEditor(StringInputComponent); <-- interface CellEditor { valueModel: FormValueModel<string> | ValueModel<string>; }
2170
+ * table.pluck("lastName").cellEditor(StringInputComponent, {
2171
+ * validators: [Validator.present("We need a last name")]
2172
+ * });
2173
+ * table.pluck("age").cellEditor(NumberInputComponent);
2174
+ * table.pluck("favoriteColor").cellEditor(SelectInputComponent, {
2175
+ * initialiseComponent(component: SelectInputComponent) {
2176
+ * selectInput.optionsModel = colorsNames; // <- initialise our component
2177
+ * }
2178
+ * });
2179
+ * table.addEditControls(saveCommand); // <- required to enable editing
2180
+ * });
2181
+ *
2182
+ * Selection models
2183
+ * @example
2184
+ * const model = TableModel.fromList(heroList, table => {
2185
+ * table.addSelectionColumn(selectionModel); // <- can be single or multiple selection model
2186
+ * table.pluck("firstName");
2187
+ * table.pluck("lastName");
2188
+ * });
2189
+ *
2190
+ * Custom cell renderers and editors
2191
+ * @example
2192
+ * const model = TableModel.fromList(heroList, table => {
2193
+ * table.pluck("favoriteColor")
2194
+ * .cellHeaderRenderer(CellHeaderRendererComponent, (component, column) => {
2195
+ * // configure your component with what ever you need.
2196
+ * });
2197
+ * .cellRenderer(CellRendererComponent) // <-- interface CellEditor { value: string; }
2198
+ * .cellEditor(CellEditorComponent.); // <-- interface CellEditor { valueModel: FormValueModel<string> | ValueModel<string>; }
2199
+ * table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
2200
+ * });
2201
+ *
2202
+ * I18n
2203
+ * @example
2204
+ * [table.yml]
2205
+ * table:
2206
+ * columns(ColumnTextProperties[]):
2207
+ * firstName:
2208
+ * headerText: "First Name"
2209
+ * fullName:
2210
+ * headerText: "Full Name"
2211
+ *
2212
+ * const model = TableModel.fromList(heroList, table => {
2213
+ * table.pluck("favoriteColor").cellRenderer(...).cellEditor(...);
2214
+ * table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
2215
+ *
2216
+ * table.columnTextProperties(I18n.table.columns); // <- configures all columns
2217
+ * });
2218
+ */
2219
+ let TableModel = TableModel_1 = class TableModel {
2220
+ constructor(sourceOfTruth) {
2221
+ this.sourceOfTruth = sourceOfTruth;
2222
+ this._garbage = new GarbageCollector();
2223
+ this._columns = new MutableListModel();
2224
+ this._editorSessions = new MutableListModel();
2225
+ this.identityOf = sourceOfTruth.identityOf;
2226
+ const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this._garbage);
2227
+ this._columnsById = chain(this._columns).indexBy('columnId');
2228
+ this._rowsBeingEdited = new MutableListModel([], {
2229
+ identifiedWith: this.identityOf
2230
+ });
2231
+ this._editorSessionByRowId = chain(this._editorSessions).indexBy('rowId');
2232
+ this.editing = chain(this._editorSessions).count().isGreaterThan(0);
2233
+ this.dataSource = chain(this.sourceOfTruth).replaceAll(this.rowsBeingEdited);
1689
2234
  }
1690
- // @Trace()
1691
- cancelCurrentModalInteraction() {
1692
- return this.activeModalContext.value.cancelActiveActivity();
2235
+ static fromList(sourceOfTruth, builder) {
2236
+ const model = new TableModel_1(sourceOfTruth);
2237
+ builder(model);
2238
+ return model;
1693
2239
  }
1694
- // @Trace()
1695
- cancelComponentInteraction(component) {
1696
- return component.interactionContext.cancelActiveActivity();
2240
+ get rowsBeingEdited() {
2241
+ return this._rowsBeingEdited.readonly;
1697
2242
  }
1698
- }
1699
-
1700
- class ModalInteractionContextFactory {
1701
- }
1702
-
1703
- var InteractionService_1;
1704
- let inplaceMonitorCount = 0;
1705
- let InteractionService = InteractionService_1 = class InteractionService {
1706
- constructor(modelInteractionContextFactory) {
1707
- this.modelInteractionContextFactory = modelInteractionContextFactory;
1708
- this.garbage = new GarbageCollector();
1709
- // private readonly _activeModalContext = new MutableValueModel<InteractionContext>();
1710
- // private readonly _activeInlineContext = new MutableValueModel<InteractionContext>();
1711
- // private readonly _activeContext: ValueModelChain<InteractionContext>;
1712
- this._navigationInProgress = new DelegatingValueModel().withDefault(false);
1713
- const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this.garbage);
1714
- this.exclusiveInteractionRegistry = new InteractionService_1.ContextRegistry();
1715
- this.modalInteractionRegistry = new InteractionService_1.ContextRegistry();
1716
- this.inPlaceInteractionRegistry = new InteractionService_1.ContextRegistry();
1717
- this.modalInteractionRegistry.disableWhen(valueOf.any(this.exclusiveInteractionRegistry.active, this.modalInteractionRegistry.active).areTruthy());
1718
- this.inPlaceInteractionRegistry.disableWhen(valueOf.any(this.exclusiveInteractionRegistry.active, this.modalInteractionRegistry.active, this.inPlaceInteractionRegistry.active).areTruthy());
1719
- this.active = valueOf.any(this.inPlaceInteractionRegistry.active, this.modalInteractionRegistry.active).areTruthy();
1720
- // TODO: chain.concat(listOrValueModels) would be nice.
1721
- this.activeInteractionContextIds = chain(this.inPlaceInteractionRegistry.interactionContextIds)
1722
- .concat(this.modalInteractionRegistry.interactionContextIds);
1723
- this.activeModalContext = chain(this.modalInteractionRegistry.interactionContexts).first();
1724
- this.inModalInteraction = chain(this.activeModalContext).isNotNil();
2243
+ getTrackByFunction() {
2244
+ return (index, item) => {
2245
+ return this.identityOf ? this.identityOf(item) : index;
2246
+ };
1725
2247
  }
1726
- isActive() {
1727
- return this.active.value;
2248
+ get columns() {
2249
+ return this._columns.readonly;
1728
2250
  }
1729
- /**
1730
- * @deprecated use #createModalInteractionContextDisposedWith instead.
1731
- * @param disposable
1732
- */
1733
- createModalInteractionContextFor(disposable) {
1734
- return this.createModalInteractionContextDisposedWith(disposable);
2251
+ pluck(property) {
2252
+ return this.addColumn(new PropertyColumnModel(property, this));
1735
2253
  }
1736
- /**
1737
- * Creates a new model interaction context that will be disposed along with the component.
1738
- * @param disposable
1739
- */
1740
- createModalInteractionContextDisposedWith(disposable) {
1741
- // TODO: look at making the registry the factory..
1742
- return this.modelInteractionContextFactory.createInteractionContext('modal', new InteractionService_1.ApiAdapter(this.placeRouter, this.modalInteractionRegistry));
2254
+ addSelectionColumn(selectionModel) {
2255
+ return this.addColumn(new SelectionColumnModel('selection', this, selectionModel));
1743
2256
  }
1744
- registerInplaceInteractionContext(interactionContext) {
1745
- // TODO: look at making the registry the factory..
1746
- // Todo: check for double registration.
1747
- // Todo: allow multiple inplace interactions..
1748
- interactionContext.initialise(`ip${++inplaceMonitorCount}`, new InteractionService_1.ApiAdapter(this.placeRouter, this.inPlaceInteractionRegistry));
2257
+ addEditControls(saveCommand) {
2258
+ this.saveCommand = saveCommand;
2259
+ return this.addColumn(new EditorControlColumnModel('editControls', saveCommand, this));
1749
2260
  }
1750
- /**
1751
- * Creates an interaction context that will prevent any other contexts from starting an
1752
- * activity until it is disposed. This is intended for use by the router for passing
1753
- * to PlaceComponent.canDeactivate(interactionContext). This ensures components don't
1754
- * try and interact in a way that we can't track and synchronise with the browser back
1755
- * button.
1756
- */
1757
- registerPlaceRouter(router) {
1758
- assert$1.isFalsey(this.placeRouter);
1759
- this.placeRouter = router;
1760
- this._navigationInProgress.setDelegate(this.placeRouter.navigationInProgress);
1761
- const self = this;
1762
- return new InteractionServiceRoutingAdapter(this.activeInteractionContextIds, this.activeModalContext, () => {
1763
- return self.modelInteractionContextFactory.createInteractionContext('exclusive', new InteractionService_1.ApiAdapter(this.placeRouter, this.exclusiveInteractionRegistry));
1764
- });
2261
+ addCustomColumn(columnId, dataAccessor) {
2262
+ return this.addColumn(new CustomValueColumnModel(columnId, this, dataAccessor));
1765
2263
  }
1766
- };
1767
- InteractionService.ctorParameters = () => [
1768
- { type: ModalInteractionContextFactory }
1769
- ];
1770
- InteractionService.ɵprov = ɵɵdefineInjectable({ factory: function InteractionService_Factory() { return new InteractionService(ɵɵinject(ModalInteractionContextFactory)); }, token: InteractionService, providedIn: "root" });
1771
- InteractionService = InteractionService_1 = __decorate([
1772
- Injectable({
1773
- providedIn: 'root'
1774
- }),
1775
- __metadata("design:paramtypes", [ModalInteractionContextFactory])
1776
- ], InteractionService);
1777
- (function (InteractionService) {
1778
- /**
1779
- * Provides a mechanism for the service to keep track of what the API adapters are doing to
1780
- * ensure the rules are followed, i.e. modal or in-place interaction aren't started while
1781
- * an exclusive routing interaction is active.
1782
- */
1783
- class ContextRegistry extends GarbageCollector {
1784
- constructor() {
1785
- super();
1786
- this._interactions = new MutableListModel();
1787
- this._disabledDelegate = new DelegatingValueModel().withDefault(false);
1788
- const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
1789
- this.active = chain(this._interactions).isNotEmpty();
1790
- this.interactionContextIds = chain(this._interactions).pluck("identifier");
1791
- }
1792
- get interactionContexts() {
1793
- return this._interactions.readonly;
1794
- }
1795
- start(context) {
1796
- this._interactions.push(context);
1797
- }
1798
- finish(context) {
1799
- this._interactions.remove(context);
1800
- }
1801
- isActive() {
1802
- return this.active.value;
2264
+ addColumn(column) {
2265
+ if (this._columnsById.get(column.columnId)) {
2266
+ lang.illegalState(`Column with id=${column.columnId} already exists`);
1803
2267
  }
1804
- disableWhen(disabled) {
1805
- this._disabledDelegate.setDelegate(disabled);
2268
+ else {
2269
+ this._columns.push(column);
1806
2270
  }
2271
+ return column;
1807
2272
  }
1808
- InteractionService.ContextRegistry = ContextRegistry;
1809
- class ApiAdapter {
1810
- constructor(placeRouter, contextRegistry) {
1811
- this.placeRouter = placeRouter;
1812
- this.contextRegistry = contextRegistry;
1813
- }
1814
- // @Trace()
1815
- notifyActive(context) {
1816
- assert$1.isTruthy(context.identifier);
1817
- this.contextRegistry.start(context);
1818
- return this.isNavigationInProgress() ? Promise.resolve() : this.placeRouter.syncInteractionContextIdsWithRouter();
2273
+ columnTextProperties(columnTextProperties) {
2274
+ this._columnTextPropertiesLookup = columnTextProperties;
2275
+ }
2276
+ getColumnTextProperties(column) {
2277
+ const factory = this._columnTextPropertiesLookup[column.columnId];
2278
+ return factory ? factory() : undefined;
2279
+ }
2280
+ startEditSession(row) {
2281
+ const rowId = this.identityOf(row);
2282
+ if (this._rowsBeingEdited.query().indexOf(row) > -1) {
2283
+ return lang.illegalState(`Row with id=${rowId} already being edited`);
1819
2284
  }
1820
- // @Trace()
1821
- isNavigationInProgress() {
1822
- return this.placeRouter.navigationInProgress.value;
2285
+ else {
2286
+ const editSession = new TableModel_1.EditSession(rowId, row, this.saveCommand);
2287
+ const { when } = Dsl.disposeWith(editSession);
2288
+ when.valueOf(editSession.rowValueModel).changes((editedValue) => {
2289
+ this._rowsBeingEdited.replaceOrPush(editedValue);
2290
+ }, { initialValue: 'triggerChangeUnlessNil' });
2291
+ this._editorSessions.push(editSession);
2292
+ editSession.onDispose(() => {
2293
+ this._rowsBeingEdited.remove(editSession.rowValueModel.value);
2294
+ this._editorSessions.remove(editSession);
2295
+ });
2296
+ return editSession;
1823
2297
  }
1824
- // @Trace()
1825
- notifyFinished(context) {
1826
- this.contextRegistry.finish(context);
1827
- // :: Important ::
1828
- // This method will be traversed by both the place router (during can canDeactivate guards) and user land code
1829
- // (both when routing is idle and while it is active in PlaceComponent.canDeactivate()).
1830
- // The result of pushInteractionIdsToRoute will not start until after the current route finishes, and the
1831
- // current route won't finish until after this promise returns... Deadlock.
1832
- // So in order to keep this logic out of the activities we perform the check here and ensure that
1833
- // any interactions with the context while routing is active returns immediately.
1834
- return this.isNavigationInProgress() ? Promise.resolve() : this.placeRouter.syncInteractionContextIdsWithRouter();
2298
+ }
2299
+ getEditSessionFor(row) {
2300
+ return this._editorSessionByRowId.get(this.identityOf(row));
2301
+ }
2302
+ cancelAllEditorSessions() {
2303
+ this._editorSessions.runInTransaction((draft) => {
2304
+ this._rowsBeingEdited.runInTransaction(() => {
2305
+ draft.value.forEach(session => session.dispose());
2306
+ });
2307
+ });
2308
+ }
2309
+ };
2310
+ TableModel.ctorParameters = () => [
2311
+ { type: ListModel }
2312
+ ];
2313
+ TableModel = TableModel_1 = __decorate([
2314
+ TrackExternal.Strategy(new TrackExternal.OneTimeBinding()),
2315
+ __metadata("design:paramtypes", [ListModel])
2316
+ ], TableModel);
2317
+ (function (TableModel) {
2318
+ class EditSession extends GarbageCollector {
2319
+ constructor(rowId, row, saveCommand) {
2320
+ super();
2321
+ this.rowId = rowId;
2322
+ this.saveCommand = saveCommand;
2323
+ this._editorValue = new MutableValueModel();
2324
+ this.rowValueModel = this._editorValue.readonly;
2325
+ this.form = new Form();
2326
+ this.form.load(row);
2327
+ this._editorValue.value = row;
2328
+ this.form.onEdit(() => {
2329
+ this._editorValue.value = produce(this._editorValue.value, draft => {
2330
+ this.form.writeDirtyStateTo(draft);
2331
+ });
2332
+ });
1835
2333
  }
1836
2334
  }
1837
- InteractionService.ApiAdapter = ApiAdapter;
1838
- })(InteractionService || (InteractionService = {}));
2335
+ TableModel.EditSession = EditSession;
2336
+ })(TableModel || (TableModel = {}));
1839
2337
 
1840
- let InPlaceInteractionContextComponent = class InPlaceInteractionContextComponent extends DisposableComponent {
1841
- constructor(interactionService, tabConfig) {
2338
+ let EditRowControls = class EditRowControls extends DisposableComponent {
2339
+ constructor() {
1842
2340
  super();
1843
- this.interactionService = interactionService;
1844
- this.tabConfig = tabConfig;
1845
- /**
1846
- * If true then the first startActivity call will slide the activity into view. If false
1847
- * the activity will replace the existing content immediately.
1848
- */
1849
- this.animateFirstActivity = true;
2341
+ this.saveCommand = Command.create(() => {
2342
+ this.editSession.saveCommand.execute(this.editSession.form)
2343
+ .then((finished) => {
2344
+ if (finished) {
2345
+ this.editSession.dispose();
2346
+ }
2347
+ });
2348
+ });
2349
+ this.cancelCommand = Command.create(() => {
2350
+ this.editSession.dispose();
2351
+ });
1850
2352
  }
1851
- get animationDuration() {
2353
+ ngOnInit() {
2354
+ }
2355
+ get form() {
1852
2356
  var _a;
1853
- return this.animateFirstActivity ? (((_a = this.tabConfig) === null || _a === void 0 ? void 0 : _a.animationDuration) || '500ms') : "0ms";
2357
+ return (_a = this.editSession) === null || _a === void 0 ? void 0 : _a.form;
1854
2358
  }
1855
- ngAfterViewInit() {
1856
- this.interactionService.registerInplaceInteractionContext(this);
2359
+ };
2360
+ __decorate([
2361
+ Input(),
2362
+ __metadata("design:type", Object)
2363
+ ], EditRowControls.prototype, "row", void 0);
2364
+ __decorate([
2365
+ Input(),
2366
+ TrackExternal(),
2367
+ __metadata("design:type", Command)
2368
+ ], EditRowControls.prototype, "editRowCommand", void 0);
2369
+ __decorate([
2370
+ Input(),
2371
+ __metadata("design:type", TableModel.EditSession)
2372
+ ], EditRowControls.prototype, "editSession", void 0);
2373
+ EditRowControls = __decorate([
2374
+ Component({
2375
+ selector: 'aup-row-editor-controls',
2376
+ template: "<button *ngIf=\"!editSession\" mat-icon-button [pectinCommand]=\"editRowCommand\" class=\"edit-button\"><mat-icon>edit</mat-icon></button>\n<button *ngIf=\"editSession\" mat-icon-button [pectinCommand]=\"saveCommand\"><mat-icon>done</mat-icon></button>\n<button *ngIf=\"editSession\" mat-icon-button [pectinCommand]=\"cancelCommand\"><mat-icon>clear</mat-icon></button>\n",
2377
+ styles: [":host{display:block;width:80px}.edit-button{visibility:hidden}:host-context(tr:hover) .edit-button{visibility:visible}"]
2378
+ }),
2379
+ __metadata("design:paramtypes", [])
2380
+ ], EditRowControls);
2381
+
2382
+ let SelectCellRendererComponent = class SelectCellRendererComponent extends DisposableComponent {
2383
+ constructor() {
2384
+ super();
2385
+ this.selectCommand = Command.create(() => {
2386
+ this.selectionModel.selectCommand.execute(this.row);
2387
+ });
1857
2388
  }
1858
- initialise(id, api) {
1859
- this.activityContainerComponent.initialise(id, api);
2389
+ set row(value) {
2390
+ this._row = value;
1860
2391
  }
1861
- get identifier() {
1862
- return this.activityContainerComponent.identifier;
2392
+ get row() {
2393
+ return this._row;
1863
2394
  }
1864
- alert(alert) {
1865
- return this.activityContainerComponent.alert(alert);
2395
+ isSelected() {
2396
+ return this.selectionModel.isSelected(this.row);
1866
2397
  }
1867
- cancelActiveActivity() {
1868
- return this.activityContainerComponent.cancelActiveActivity();
2398
+ };
2399
+ __decorate([
2400
+ Input(),
2401
+ __metadata("design:type", Object),
2402
+ __metadata("design:paramtypes", [Object])
2403
+ ], SelectCellRendererComponent.prototype, "row", null);
2404
+ __decorate([
2405
+ Input(),
2406
+ __metadata("design:type", Object)
2407
+ ], SelectCellRendererComponent.prototype, "selectionModel", void 0);
2408
+ SelectCellRendererComponent = __decorate([
2409
+ Component({
2410
+ selector: 'aup-select-cell-renderer',
2411
+ template: "<mat-checkbox [pectinCommand]=\"selectCommand\" [checked]=\"isSelected()\"></mat-checkbox>\n",
2412
+ styles: [""]
2413
+ }),
2414
+ __metadata("design:paramtypes", [])
2415
+ ], SelectCellRendererComponent);
2416
+
2417
+ let SelectHeaderCellRendererComponent = class SelectHeaderCellRendererComponent extends DisposableComponent {
2418
+ constructor() {
2419
+ super();
2420
+ this.selectCommand = Command.create(() => {
2421
+ this.selectionModel.toggleAllCommand.execute();
2422
+ });
1869
2423
  }
1870
- confirm(confirm) {
1871
- return this.activityContainerComponent.confirm(confirm);
2424
+ isSelected() {
2425
+ return this.selectionModel.allSelected.value;
1872
2426
  }
1873
- confirmOrReject(confirm) {
1874
- return this.activityContainerComponent.confirmOrReject(confirm);
2427
+ isIntermediate() {
2428
+ return this.selectionModel.someSelected.value;
1875
2429
  }
1876
- confirmThen(confirm, activityType, data) {
1877
- return this.activityContainerComponent.confirmThen(confirm, activityType);
2430
+ };
2431
+ __decorate([
2432
+ Input(),
2433
+ __metadata("design:type", MultipleSelectionModel)
2434
+ ], SelectHeaderCellRendererComponent.prototype, "selectionModel", void 0);
2435
+ SelectHeaderCellRendererComponent = __decorate([
2436
+ Component({
2437
+ selector: 'aup-select-header-cell-renderer',
2438
+ template: "<mat-checkbox [pectinCommand]=\"selectCommand\" [checked]=\"isSelected()\" [indeterminate]=\"this.isIntermediate()\"></mat-checkbox>\n",
2439
+ styles: [""]
2440
+ }),
2441
+ __metadata("design:paramtypes", [])
2442
+ ], SelectHeaderCellRendererComponent);
2443
+
2444
+ class ColumnModel {
2445
+ constructor(columnId, defaults) {
2446
+ this.columnId = columnId;
2447
+ this.defaults = defaults;
2448
+ this.cellHeaderRenderer(DefaultHeaderCellRendererComponent, (component, column) => {
2449
+ component.columnModel = column;
2450
+ });
1878
2451
  }
1879
- isActive() {
1880
- return this.activityContainerComponent.isActive();
2452
+ getHeaderText() {
2453
+ var _a;
2454
+ return ((_a = this.getColumnTextProperties()) === null || _a === void 0 ? void 0 : _a.headerText()) || this.getDefaultHeaderText();
1881
2455
  }
1882
- startActivity(activityType, data) {
1883
- return this.activityContainerComponent.startActivity(activityType, data);
2456
+ getDefaultHeaderText() {
2457
+ return this.columnId;
2458
+ }
2459
+ getColumnTextProperties() {
2460
+ return this._columnTextProperties || this.defaults.getColumnTextProperties(this);
2461
+ }
2462
+ textProperties(columnTextProperties) {
2463
+ this._columnTextProperties = columnTextProperties;
2464
+ return this;
2465
+ }
2466
+ setCellRenderer(cellRenderer, initialiser) {
2467
+ this._cellRendererConfig = {
2468
+ portal: new ComponentPortal(cellRenderer),
2469
+ pushState: initialiser
2470
+ };
2471
+ }
2472
+ cellHeaderRenderer(cellRenderer, initialiser) {
2473
+ this._columnHeaderConfig = {
2474
+ portal: new ComponentPortal(cellRenderer),
2475
+ initialiseComponent: initialiser
2476
+ };
2477
+ }
2478
+ setCellEditor(cellEditor) {
2479
+ this._cellEditorConfig = cellEditor;
2480
+ }
2481
+ get cellRendererPortal() {
2482
+ return this._cellRendererConfig.portal;
2483
+ }
2484
+ get columnHeaderCellRendererPortal() {
2485
+ return this._columnHeaderConfig.portal;
2486
+ }
2487
+ get cellEditorPortal() {
2488
+ var _a;
2489
+ return (_a = this._cellEditorConfig) === null || _a === void 0 ? void 0 : _a.portal;
2490
+ }
2491
+ hasEditor() {
2492
+ return !!this._cellEditorConfig;
2493
+ }
2494
+ updateCellRenderer(component, row, editRowCommand, editSession) {
2495
+ this._cellRendererConfig.pushState(component, row, editRowCommand, editSession);
2496
+ }
2497
+ initialiseHeader(component) {
2498
+ this._columnHeaderConfig.initialiseComponent(component, this);
2499
+ }
2500
+ initialiseEditor(component, editSession) {
2501
+ this._cellEditorConfig.initialiseComponent(component, editSession);
2502
+ }
2503
+ }
2504
+ __decorate([
2505
+ Memoize(),
2506
+ __metadata("design:type", Function),
2507
+ __metadata("design:paramtypes", []),
2508
+ __metadata("design:returntype", String)
2509
+ ], ColumnModel.prototype, "getHeaderText", null);
2510
+ __decorate([
2511
+ Memoize(),
2512
+ __metadata("design:type", Function),
2513
+ __metadata("design:paramtypes", []),
2514
+ __metadata("design:returntype", Object)
2515
+ ], ColumnModel.prototype, "getColumnTextProperties", null);
2516
+ class PropertyColumnModel extends ColumnModel {
2517
+ constructor(property, defaults) {
2518
+ super(property.toString(), defaults);
2519
+ this.property = property;
2520
+ this.cellRenderer(DefaultCellRendererComponent);
2521
+ }
2522
+ cellRenderer(componentType) {
2523
+ this.setCellRenderer(componentType, (component, row) => {
2524
+ component.value = row[this.property];
2525
+ });
2526
+ }
2527
+ cellEditor(editor, options) {
2528
+ this.setCellEditor({
2529
+ portal: new ComponentPortal(editor),
2530
+ initialiseComponent: (component, editSession) => {
2531
+ const formValueModel = editSession.form.pluck(this.property);
2532
+ if (options === null || options === void 0 ? void 0 : options.validators) {
2533
+ formValueModel.validateUsing(options.validators);
2534
+ }
2535
+ component.valueModel = formValueModel;
2536
+ if (options === null || options === void 0 ? void 0 : options.initialiseComponent) {
2537
+ options.initialiseComponent(component);
2538
+ }
2539
+ }
2540
+ });
2541
+ return this;
2542
+ }
2543
+ }
2544
+ class CustomValueColumnModel extends ColumnModel {
2545
+ constructor(columnId, defaults, getValue) {
2546
+ super(columnId, defaults);
2547
+ this.getValue = getValue;
2548
+ this.cellRenderer(DefaultCellRendererComponent);
2549
+ }
2550
+ cellRenderer(componentType) {
2551
+ this.setCellRenderer(componentType, (component, row) => {
2552
+ component.value = this.getValue(row);
2553
+ });
2554
+ }
2555
+ }
2556
+ class EditorControlColumnModel extends ColumnModel {
2557
+ constructor(columnId, saveCommand, defaults) {
2558
+ super(columnId, defaults);
2559
+ this.cellRenderer(EditRowControls);
2560
+ }
2561
+ cellRenderer(componentType) {
2562
+ this.setCellRenderer(componentType, (component, row, editRowCommand, editSession) => {
2563
+ component.row = row;
2564
+ component.editSession = editSession;
2565
+ component.editRowCommand = editRowCommand;
2566
+ });
2567
+ }
2568
+ getDefaultHeaderText() {
2569
+ return '';
2570
+ }
2571
+ }
2572
+ class CustomTemplateColumnModel extends ColumnModel {
2573
+ constructor(columnId, defaults, component) {
2574
+ super(columnId, defaults);
2575
+ }
2576
+ }
2577
+ class SelectionColumnModel extends ColumnModel {
2578
+ constructor(columnId, defaults, selectionModel) {
2579
+ super(columnId, defaults);
2580
+ if (selectionModel instanceof MultipleSelectionModel) {
2581
+ this.cellHeaderRenderer(SelectHeaderCellRendererComponent, (component) => {
2582
+ component.selectionModel = selectionModel;
2583
+ });
2584
+ }
2585
+ this.setCellRenderer(SelectCellRendererComponent, (component, row, editRowCommand, editSession) => {
2586
+ component.row = row;
2587
+ component.selectionModel = selectionModel;
2588
+ });
2589
+ }
2590
+ getDefaultHeaderText() {
2591
+ return '';
2592
+ }
2593
+ }
2594
+
2595
+ /**
2596
+ * Create your model:
2597
+ * @example
2598
+ * this.heroTableModel = TableModel.fromList(heroList, table => {
2599
+ * table.pluck("firstName");
2600
+ * table.pluck("lastName");
2601
+ * table.addCustomColumn("fullName", hero => `${hero.firstName} ${hero.lastName}`);
2602
+ * });
2603
+ *
2604
+ * Create your table
2605
+ * @example
2606
+ * <aup-table [tableModel]="heroTableModel"></aup-table>
2607
+ *
2608
+ * Styling
2609
+ * @example
2610
+ * aup-table {
2611
+ * --column-gap: 10px; // defaults to 24px
2612
+ * aup-table-cell-renderer {
2613
+ * &:first-column {
2614
+ * // do stuff
2615
+ * }
2616
+ * &:last-column {
2617
+ * // do stuff
2618
+ * }
2619
+ * }
2620
+ * }
2621
+ */
2622
+ let TableComponent = class TableComponent extends DisposableComponent {
2623
+ constructor() {
2624
+ super();
2625
+ }
2626
+ ngOnInit() {
2627
+ const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
2628
+ this.columns = chain(this.tableModel.columns);
2629
+ this.columnIds = chain(this.columns).pluck('columnId');
2630
+ }
2631
+ isEditing(row) {
2632
+ return !!this.tableModel.getEditSessionFor(row);
1884
2633
  }
1885
2634
  };
1886
- InPlaceInteractionContextComponent.ctorParameters = () => [
1887
- { type: InteractionService },
1888
- { type: undefined, decorators: [{ type: Inject, args: [MAT_TABS_CONFIG,] }, { type: Optional }] }
2635
+ __decorate([
2636
+ Input(),
2637
+ TrackExternal(),
2638
+ __metadata("design:type", TableModel)
2639
+ ], TableComponent.prototype, "tableModel", void 0);
2640
+ TableComponent = __decorate([
2641
+ Component({
2642
+ selector: 'aup-table',
2643
+ template: "<table mat-table [dataSource]=\"tableModel.dataSource.value\" [trackBy]=\"tableModel.getTrackByFunction()\">\n\n <ng-container *ngFor=\"let column of columns.value; index as index; first as first; last as last\" matColumnDef=\"{{column.columnId}}\">\n <th mat-header-cell *matHeaderCellDef>\n <aup-table-header-cell-renderer [column]=\"column\"\n [attr.column-index]=\"index\"\n [class.first-column]=\"first\"\n [class.last-column]=\"last\"\n ></aup-table-header-cell-renderer>\n </th>\n <td mat-cell *matCellDef=\"let row\">\n <aup-table-cell-renderer [column]=\"column\"\n [row]=\"row\"\n [tableModel]=\"tableModel\"\n [editSession]=\"tableModel.getEditSessionFor(row)\"\n [attr.column-index]=\"index\"\n [class.first-column]=\"first\"\n [class.last-column]=\"last\"\n ></aup-table-cell-renderer>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"columnIds.value\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: columnIds.value;\"></tr>\n\n</table>\n",
2644
+ styles: [":host{display:flex;flex-direction:column;align-items:stretch}:host table{flex:1}"]
2645
+ }),
2646
+ __metadata("design:paramtypes", [])
2647
+ ], TableComponent);
2648
+
2649
+ let ColumnTemplateDirective = class ColumnTemplateDirective {
2650
+ constructor(host, templateRef, viewContainer) {
2651
+ this.templateRef = templateRef;
2652
+ this.viewContainer = viewContainer;
2653
+ }
2654
+ };
2655
+ ColumnTemplateDirective.ctorParameters = () => [
2656
+ { type: TableComponent },
2657
+ { type: TemplateRef },
2658
+ { type: ViewContainerRef }
1889
2659
  ];
2660
+ ColumnTemplateDirective = __decorate([
2661
+ Directive({
2662
+ selector: '[aupColumnTemplate]'
2663
+ }),
2664
+ __metadata("design:paramtypes", [TableComponent,
2665
+ TemplateRef,
2666
+ ViewContainerRef])
2667
+ ], ColumnTemplateDirective);
2668
+
2669
+ let TableCellRendererComponent = class TableCellRendererComponent {
2670
+ constructor() {
2671
+ this.defaultClassNames = "aup-header-cell-renderer";
2672
+ this.editRowCommand = Command.create(() => {
2673
+ this.tableModel.startEditSession(this.row);
2674
+ });
2675
+ }
2676
+ initialiseRenderer(instance) {
2677
+ if (this.renderer !== instance) {
2678
+ this.renderer = instance;
2679
+ this.column.updateCellRenderer(this.renderer, this.row, this.editRowCommand, this.editSession);
2680
+ }
2681
+ }
2682
+ initialiseEditor(instance) {
2683
+ if (this.editor !== instance) {
2684
+ this.editor = instance;
2685
+ this.column.initialiseEditor(this.editor, this.editSession);
2686
+ }
2687
+ }
2688
+ ngOnChanges(changes) {
2689
+ if (this.renderer) {
2690
+ this.column.updateCellRenderer(this.renderer, this.row, this.editRowCommand, this.editSession);
2691
+ this.renderer.editSession = this.editSession;
2692
+ }
2693
+ }
2694
+ hasActiveEditor() {
2695
+ return this.editSession && this.column.hasEditor();
2696
+ }
2697
+ };
1890
2698
  __decorate([
1891
- ViewChild('activityContainer', { static: true }),
1892
- __metadata("design:type", ActivityContainerComponent)
1893
- ], InPlaceInteractionContextComponent.prototype, "activityContainerComponent", void 0);
2699
+ Input(),
2700
+ __metadata("design:type", Object)
2701
+ ], TableCellRendererComponent.prototype, "row", void 0);
2702
+ __decorate([
2703
+ Input(),
2704
+ __metadata("design:type", ColumnModel)
2705
+ ], TableCellRendererComponent.prototype, "column", void 0);
2706
+ __decorate([
2707
+ Input(),
2708
+ __metadata("design:type", TableModel.EditSession)
2709
+ ], TableCellRendererComponent.prototype, "editSession", void 0);
1894
2710
  __decorate([
1895
2711
  Input(),
2712
+ __metadata("design:type", TableModel)
2713
+ ], TableCellRendererComponent.prototype, "tableModel", void 0);
2714
+ __decorate([
2715
+ HostBinding('class'),
1896
2716
  __metadata("design:type", Object)
1897
- ], InPlaceInteractionContextComponent.prototype, "animateFirstActivity", void 0);
1898
- InPlaceInteractionContextComponent = __decorate([
2717
+ ], TableCellRendererComponent.prototype, "defaultClassNames", void 0);
2718
+ TableCellRendererComponent = __decorate([
1899
2719
  Component({
1900
- selector: 'aup-in-place-interaction-context',
1901
- template: "<mat-tab-group no-tab-header [selectedIndex]=\"isActive() ? 1 : 0\" full-height-tabs [dynamicHeight]=\"false\" [animationDuration]=\"animationDuration\">\n <mat-tab>\n <ng-content></ng-content>\n </mat-tab>\n <mat-tab>\n <aup-activity-container #activityContainer [dynamicHeight]=\"false\"></aup-activity-container>\n </mat-tab>\n</mat-tab-group>\n\n",
1902
- styles: [":host{display:flex;flex-direction:column}mat-tab-group{flex:1}"]
2720
+ selector: 'aup-table-cell-renderer',
2721
+ template: "<ng-container *ngIf=\"!hasActiveEditor()\" [cdkPortalOutlet]=\"column.cellRendererPortal\" (attached)=\"initialiseRenderer($event.instance)\"></ng-container>\n<ng-container *ngIf=\"hasActiveEditor()\" [cdkPortalOutlet]=\"column.cellEditorPortal\" (attached)=\"initialiseEditor($event.instance)\"></ng-container>\n",
2722
+ styles: [":host{display:flex;flex-direction:column;align-items:stretch}"]
1903
2723
  }),
1904
- __param(1, Inject(MAT_TABS_CONFIG)), __param(1, Optional()),
1905
- __metadata("design:paramtypes", [InteractionService, Object])
1906
- ], InPlaceInteractionContextComponent);
2724
+ __metadata("design:paramtypes", [])
2725
+ ], TableCellRendererComponent);
1907
2726
 
1908
- class DialogInteractionContext extends AbstractInteractionContext {
1909
- constructor(identifier, api, dialogService, config) {
1910
- super();
1911
- this.identifier = identifier;
1912
- this.api = api;
1913
- this.dialogService = dialogService;
1914
- this.config = config;
1915
- this.garbage = new GarbageCollector();
1916
- assert$1.notNil(dialogService);
2727
+ let TableHeaderCellRendererComponent = class TableHeaderCellRendererComponent {
2728
+ constructor() {
2729
+ this.defaultClassNames = "aup-header-cell-renderer";
1917
2730
  }
1918
- cancelActiveActivity() {
1919
- return this.activityContainer.cancelActiveActivity();
2731
+ initialiseHeader(instance) {
2732
+ if (this.renderer !== instance) {
2733
+ this.renderer = instance;
2734
+ this.column.initialiseHeader(this.renderer);
2735
+ }
2736
+ }
2737
+ };
2738
+ __decorate([
2739
+ Input(),
2740
+ __metadata("design:type", ColumnModel)
2741
+ ], TableHeaderCellRendererComponent.prototype, "column", void 0);
2742
+ __decorate([
2743
+ HostBinding('class'),
2744
+ __metadata("design:type", Object)
2745
+ ], TableHeaderCellRendererComponent.prototype, "defaultClassNames", void 0);
2746
+ TableHeaderCellRendererComponent = __decorate([
2747
+ Component({
2748
+ selector: 'aup-table-header-cell-renderer',
2749
+ template: "<ng-container [cdkPortalOutlet]=\"column.columnHeaderCellRendererPortal\" (attached)=\"initialiseHeader($event.instance)\"></ng-container>\n",
2750
+ styles: [":host{display:flex;flex-direction:column;align-items:stretch}"]
2751
+ }),
2752
+ __metadata("design:paramtypes", [])
2753
+ ], TableHeaderCellRendererComponent);
2754
+
2755
+ let VerticalFocusContainerComponent = class VerticalFocusContainerComponent extends FocusContainerComponent {
2756
+ constructor(focusManager) {
2757
+ super(focusManager);
2758
+ this.focusManager = focusManager;
1920
2759
  }
1921
- dispose() {
1922
- if (this.isActive()) {
1923
- lang.illegalState('Dispose called while active.');
2760
+ arrowLeft(event) {
2761
+ if (this.leftArrowCommand.enabled.value) {
2762
+ event.preventDefault();
2763
+ event.stopPropagation();
2764
+ this.leftArrowCommand.execute();
1924
2765
  }
1925
- this.garbage.dispose();
1926
- }
1927
- registerDisposable(disposable) {
1928
- return this.garbage.registerDisposable(disposable);
1929
2766
  }
1930
- isActive() {
1931
- return !!this.activityContainer && this.activityContainer.isActive();
2767
+ arrowRight(event) {
2768
+ if (this.rightArrowCommand.enabled.value) {
2769
+ event.preventDefault();
2770
+ event.stopPropagation();
2771
+ this.rightArrowCommand.execute();
2772
+ }
1932
2773
  }
1933
- createAndLaunchActivity(activityType, data, disableClose) {
1934
- assert$1.isNil(this._currentActivityRef);
1935
- const config = Object.assign(Object.assign({}, this.config), {
1936
- disableClose,
1937
- panelClass: 'dialog-interaction-context'
1938
- });
1939
- const self = this;
1940
- const matDialogRef = this.dialogService.open(ActivityContainerComponent, config);
1941
- const activityContainer = this.activityContainer = matDialogRef.componentInstance;
1942
- this.activityContainer.initialise(this.identifier, this.api);
1943
- const activityResult = this.activityContainer.startActivity(activityType, data);
1944
- activityResult.finally(() => matDialogRef.close());
1945
- // we need to check if our onDone/onCancel methods above we called or if we were
1946
- // closed by the user clicking the backdrop. If the later then we need to cancel our
1947
- // activity.
1948
- matDialogRef.afterClosed().subscribe(promiseAlreadyFinished => {
1949
- if (activityContainer.isActive()) {
1950
- activityContainer.cancelActiveActivity();
1951
- }
1952
- this.activityContainer = null;
1953
- });
1954
- matDialogRef.updateSize();
1955
- matDialogRef.afterOpened().subscribe(promiseAlreadyFinished => {
1956
- matDialogRef.updateSize();
1957
- });
1958
- return activityResult;
2774
+ arrowDown(event) {
2775
+ event.preventDefault();
2776
+ event.stopPropagation();
2777
+ this.focusManager.focusNext();
1959
2778
  }
1960
- }
1961
-
1962
- const DIALOG_INTERACTION_SERVICE_DEFAULTS = new InjectionToken('DIALOG_INTERACTION_SERVICE_DEFAULTS');
1963
- let DialogInteractionContextFactory = class DialogInteractionContextFactory extends ModalInteractionContextFactory {
1964
- constructor(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
1965
- super();
1966
- this.dialogService = dialogService;
1967
- this.dialogServiceDefaults = dialogServiceDefaults;
1968
- this.matDialogDefaultConfig = matDialogDefaultConfig;
1969
- assert$1.notNil(dialogService);
2779
+ arrowUp(event) {
2780
+ event.preventDefault();
2781
+ event.stopPropagation();
2782
+ this.focusManager.focusPrevious();
1970
2783
  }
1971
- createInteractionContext(identifier, api) {
1972
- const config = Object.assign(Object.assign({ autoFocus: false, hasBackdrop: true, closeOnNavigation: false }, this.matDialogDefaultConfig), this.dialogServiceDefaults);
1973
- return new DialogInteractionContext(identifier, api, this.dialogService, config);
2784
+ ngOnInit() {
1974
2785
  }
1975
2786
  };
1976
- DialogInteractionContextFactory.ctorParameters = () => [
1977
- { type: MatDialog },
1978
- { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [DIALOG_INTERACTION_SERVICE_DEFAULTS,] }] },
1979
- { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [MAT_DIALOG_DEFAULT_OPTIONS,] }] }
2787
+ VerticalFocusContainerComponent.ctorParameters = () => [
2788
+ { type: FocusManager, decorators: [{ type: Self }] }
1980
2789
  ];
1981
- DialogInteractionContextFactory.ɵprov = ɵɵdefineInjectable({ factory: function DialogInteractionContextFactory_Factory() { return new DialogInteractionContextFactory(ɵɵinject(MatDialog), ɵɵinject(DIALOG_INTERACTION_SERVICE_DEFAULTS, 8), ɵɵinject(MAT_DIALOG_DEFAULT_OPTIONS, 8)); }, token: DialogInteractionContextFactory, providedIn: "root" });
1982
- DialogInteractionContextFactory = __decorate([
1983
- Injectable({
1984
- providedIn: 'root'
2790
+ __decorate([
2791
+ Input('command.arrowRight'),
2792
+ TrackExternal(),
2793
+ __metadata("design:type", Command)
2794
+ ], VerticalFocusContainerComponent.prototype, "rightArrowCommand", void 0);
2795
+ __decorate([
2796
+ Input('command.arrowLeft'),
2797
+ TrackExternal(),
2798
+ __metadata("design:type", Command)
2799
+ ], VerticalFocusContainerComponent.prototype, "leftArrowCommand", void 0);
2800
+ __decorate([
2801
+ HostListener('keyup.arrowLeft', ['$event']),
2802
+ __metadata("design:type", Function),
2803
+ __metadata("design:paramtypes", [KeyboardEvent]),
2804
+ __metadata("design:returntype", void 0)
2805
+ ], VerticalFocusContainerComponent.prototype, "arrowLeft", null);
2806
+ __decorate([
2807
+ HostListener('keyup.arrowRight', ['$event']),
2808
+ __metadata("design:type", Function),
2809
+ __metadata("design:paramtypes", [KeyboardEvent]),
2810
+ __metadata("design:returntype", void 0)
2811
+ ], VerticalFocusContainerComponent.prototype, "arrowRight", null);
2812
+ __decorate([
2813
+ HostListener('keyup.arrowDown', ['$event']),
2814
+ __metadata("design:type", Function),
2815
+ __metadata("design:paramtypes", [KeyboardEvent]),
2816
+ __metadata("design:returntype", void 0)
2817
+ ], VerticalFocusContainerComponent.prototype, "arrowDown", null);
2818
+ __decorate([
2819
+ HostListener('keyup.arrowUp', ['$event']),
2820
+ __metadata("design:type", Function),
2821
+ __metadata("design:paramtypes", [KeyboardEvent]),
2822
+ __metadata("design:returntype", void 0)
2823
+ ], VerticalFocusContainerComponent.prototype, "arrowUp", null);
2824
+ VerticalFocusContainerComponent = __decorate([
2825
+ Component({
2826
+ selector: 'aup-vertical-focus-container',
2827
+ template: "<ng-content></ng-content>\n",
2828
+ providers: [
2829
+ { provide: FocusManager }
2830
+ ],
2831
+ styles: [":host{display:block}"]
1985
2832
  }),
1986
- __param(1, Optional()), __param(1, Inject(DIALOG_INTERACTION_SERVICE_DEFAULTS)),
1987
- __param(2, Optional()), __param(2, Inject(MAT_DIALOG_DEFAULT_OPTIONS)),
1988
- __metadata("design:paramtypes", [MatDialog,
1989
- MatDialogConfig,
1990
- MatDialogConfig])
1991
- ], DialogInteractionContextFactory);
2833
+ __param(0, Self()),
2834
+ __metadata("design:paramtypes", [FocusManager])
2835
+ ], VerticalFocusContainerComponent);
1992
2836
 
1993
2837
  /**
1994
2838
  * @file Automatically generated by barrelsby.
1995
2839
  */
1996
2840
 
1997
- let AddItemInteractionContextComponent = class AddItemInteractionContextComponent extends DisposableComponent {
2841
+ let ActivityActionsComponent = class ActivityActionsComponent extends DisposableComponent {
1998
2842
  constructor() {
1999
- super();
2000
- this.tabindex = 0;
2001
- this.clickCommand = Command.create((context) => {
2002
- if (this.activityClass) {
2003
- this.startActivity(this.activityClass, this.activityData).catch(e => {
2004
- // don't care.
2005
- });
2006
- }
2007
- else {
2008
- this.addCommand.withContext(context).execute();
2009
- }
2010
- });
2011
- }
2012
- get active() {
2013
- return this.interactionContext ? this.interactionContext.isActive() : false;
2843
+ super(...arguments);
2844
+ this.align = 'start';
2014
2845
  }
2015
- startActivity(activityType, data) {
2016
- return this.interactionContext.startActivity(activityType, data);
2846
+ get alignEnd() {
2847
+ return this.align === 'end';
2017
2848
  }
2018
2849
  ngOnInit() {
2019
2850
  }
2851
+ hasConfirmText() {
2852
+ return !___default.isEmpty(this.confirmText);
2853
+ }
2020
2854
  };
2021
2855
  __decorate([
2022
2856
  Input(),
2023
- __metadata("design:type", String)
2024
- ], AddItemInteractionContextComponent.prototype, "label", void 0);
2025
- __decorate([
2026
- Input(),
2027
- __metadata("design:type", Object)
2028
- ], AddItemInteractionContextComponent.prototype, "activityClass", void 0);
2857
+ TrackExternal(),
2858
+ __metadata("design:type", Command)
2859
+ ], ActivityActionsComponent.prototype, "confirmCommand", void 0);
2029
2860
  __decorate([
2030
2861
  Input(),
2031
- __metadata("design:type", Object)
2032
- ], AddItemInteractionContextComponent.prototype, "activityData", void 0);
2862
+ __metadata("design:type", String)
2863
+ ], ActivityActionsComponent.prototype, "confirmText", void 0);
2033
2864
  __decorate([
2034
2865
  Input(),
2035
2866
  TrackExternal(),
2036
2867
  __metadata("design:type", Command)
2037
- ], AddItemInteractionContextComponent.prototype, "addCommand", void 0);
2868
+ ], ActivityActionsComponent.prototype, "cancelCommand", void 0);
2038
2869
  __decorate([
2039
- ViewChild(InPlaceInteractionContextComponent),
2040
- __metadata("design:type", InPlaceInteractionContextComponent)
2041
- ], AddItemInteractionContextComponent.prototype, "interactionContext", void 0);
2870
+ Input(),
2871
+ __metadata("design:type", String)
2872
+ ], ActivityActionsComponent.prototype, "align", void 0);
2042
2873
  __decorate([
2043
- HostBinding('class.interaction-active'),
2874
+ HostBinding('class.align-end'),
2044
2875
  __metadata("design:type", Boolean),
2045
2876
  __metadata("design:paramtypes", [])
2046
- ], AddItemInteractionContextComponent.prototype, "active", null);
2047
- __decorate([
2048
- HostBinding('tabindex'),
2049
- __metadata("design:type", Object)
2050
- ], AddItemInteractionContextComponent.prototype, "tabindex", void 0);
2051
- AddItemInteractionContextComponent = __decorate([
2877
+ ], ActivityActionsComponent.prototype, "alignEnd", null);
2878
+ ActivityActionsComponent = __decorate([
2052
2879
  Component({
2053
- selector: 'aup-add-item-interaction-context',
2054
- template: "<aup-in-place-interaction-context #interactionContext [animateFirstActivity]=\"false\">\n <a part=\"link\" class=\"link\" [pectinCommand]=\"clickCommand\"><mat-icon>add</mat-icon> {{label}}</a>\n</aup-in-place-interaction-context>\n",
2055
- styles: [":host{--def-link-color:var(--link-color, currentColor);--def-link-backgound:var(--link-background, rgba(0, 0, 0, 0.05));--def-link-border-radius:var(--link-border-radius, 4px);--def-link-padding:var(--link-padding, calc(var(--aup-default-padding) / 2));display:flex;flex-direction:column;border-radius:var(--def-link-border-radius);box-sizing:border-box;outline:0}:host:hover{--link-background:rgba(0,0,0,0.1)}aup-in-place-interaction-context{border-radius:var(--def-link-border-radius)}a.link{display:flex;flex-direction:row;align-items:center;border-radius:var(--def-link-border-radius);color:var(--def-link-color);background:var(--def-link-backgound);padding:var(--def-link-padding);cursor:pointer;text-decoration:none}a.link mat-icon{margin-right:8px}"]
2056
- }),
2057
- __metadata("design:paramtypes", [])
2058
- ], AddItemInteractionContextComponent);
2880
+ selector: 'aup-activity-actions',
2881
+ template: "<button class=\"cancel\" mat-icon-button [pectinCommand]=\"cancelCommand\">\n <mat-icon>clear</mat-icon>\n</button>\n<button class=\"confirm\" *ngIf=\"!hasConfirmText()\" mat-icon-button [pectinCommand]=\"confirmCommand\">\n <mat-icon>done</mat-icon>\n</button>\n<button class=\"confirm\" *ngIf=\"hasConfirmText()\" mat-button [pectinCommand]=\"confirmCommand\">{{confirmText}}</button>\n<div class=\"content\">\n <ng-content></ng-content>\n</div>\n",
2882
+ styles: [":host{display:-ms-grid;display:grid;grid-template-areas:\"cancel confirm content\";-ms-grid-columns:auto auto 1fr;grid-template-columns:auto auto 1fr;-ms-grid-rows:auto;grid-template-rows:auto;align-items:center;justify-content:end}:host.align-end{grid-template-areas:\"content cancel confirm\";-ms-grid-columns:1fr auto auto;grid-template-columns:1fr auto auto}.cancel{-ms-grid-row:1;-ms-grid-column:1;grid-area:cancel}:host.align-end>.cancel{-ms-grid-row:1;-ms-grid-column:2}.confirm{-ms-grid-row:1;-ms-grid-column:2;grid-area:confirm}:host.align-end>.confirm{-ms-grid-row:1;-ms-grid-column:3}.content{-ms-grid-row:1;-ms-grid-column:3;grid-area:content;text-align:left}:host.align-end>.content{-ms-grid-row:1;-ms-grid-column:1}"]
2883
+ })
2884
+ ], ActivityActionsComponent);
2059
2885
 
2060
2886
  let InteractionModule = class InteractionModule {
2061
2887
  };
@@ -2081,14 +2907,18 @@ InteractionModule = __decorate([
2081
2907
  ActivityOutletComponent,
2082
2908
  InPlaceInteractionContextComponent,
2083
2909
  AddItemInteractionContextComponent,
2084
- ActivityActionsComponent
2910
+ ActivityActionsComponent,
2911
+ PopupInteractionContextComponent,
2912
+ InteractionContextTriggerFor
2085
2913
  ],
2086
2914
  exports: [
2087
2915
  ActivityContainerComponent,
2088
2916
  ActivityOutletComponent,
2089
2917
  InPlaceInteractionContextComponent,
2090
2918
  AddItemInteractionContextComponent,
2091
- ActivityActionsComponent
2919
+ ActivityActionsComponent,
2920
+ PopupInteractionContextComponent,
2921
+ InteractionContextTriggerFor
2092
2922
  ],
2093
2923
  entryComponents: [
2094
2924
  ActivityContainerComponent,
@@ -2097,11 +2927,89 @@ InteractionModule = __decorate([
2097
2927
  AlertDialogComponent
2098
2928
  ],
2099
2929
  providers: [
2100
- InteractionService,
2930
+ InteractionService
2931
+ // {
2932
+ // provide: MAT_TABS_CONFIG, useValue: { animationDuration: "2s" }
2933
+ // }
2101
2934
  ]
2102
2935
  })
2103
2936
  ], InteractionModule);
2104
2937
 
2938
+ let ComponentsModule = class ComponentsModule {
2939
+ };
2940
+ ComponentsModule = __decorate([
2941
+ NgModule({
2942
+ declarations: [
2943
+ AbstractInputComponent,
2944
+ AbstractInputActivity,
2945
+ NumberInputComponent,
2946
+ StringInputComponent,
2947
+ StringInputActivity,
2948
+ TextInputComponent,
2949
+ PasswordInputComponent,
2950
+ SelectInputComponent,
2951
+ CheckboxInputComponent,
2952
+ ScrollContainerComponent,
2953
+ NoopComponent,
2954
+ SwitchCaseComponent,
2955
+ SwitchCaseWhenDirective,
2956
+ SwitchCaseDefaultDirective,
2957
+ FocusContainerComponent,
2958
+ VerticalFocusContainerComponent,
2959
+ FocusableComponent,
2960
+ CardContainerComponent,
2961
+ TableComponent,
2962
+ EditRowControls,
2963
+ ColumnTemplateDirective,
2964
+ DefaultCellRendererComponent,
2965
+ TableCellRendererComponent,
2966
+ SelectCellRendererComponent,
2967
+ SelectHeaderCellRendererComponent,
2968
+ DefaultHeaderCellRendererComponent,
2969
+ TableHeaderCellRendererComponent
2970
+ ],
2971
+ imports: [
2972
+ CommonModule,
2973
+ BrowserAnimationsModule,
2974
+ FormsModule,
2975
+ MatInputModule,
2976
+ MatFormFieldModule,
2977
+ MatSelectModule,
2978
+ MatTabsModule,
2979
+ DirectivesModule,
2980
+ MatIconModule,
2981
+ MatButtonModule,
2982
+ MatCheckboxModule,
2983
+ InteractionModule,
2984
+ MatTableModule,
2985
+ PortalModule
2986
+ ],
2987
+ exports: [
2988
+ NumberInputComponent,
2989
+ StringInputComponent,
2990
+ TextInputComponent,
2991
+ PasswordInputComponent,
2992
+ CheckboxInputComponent,
2993
+ SelectInputComponent,
2994
+ ScrollContainerComponent,
2995
+ NoopComponent,
2996
+ SwitchCaseComponent,
2997
+ SwitchCaseWhenDirective,
2998
+ SwitchCaseDefaultDirective,
2999
+ FocusContainerComponent,
3000
+ VerticalFocusContainerComponent,
3001
+ FocusableComponent,
3002
+ CardContainerComponent,
3003
+ TableComponent,
3004
+ EditRowControls,
3005
+ ColumnTemplateDirective
3006
+ ],
3007
+ providers: [
3008
+ FocusBindingFactory,
3009
+ ]
3010
+ })
3011
+ ], ComponentsModule);
3012
+
2105
3013
  class ParameterDefinition {
2106
3014
  constructor(propertyName, options, urlFormat) {
2107
3015
  this.propertyName = propertyName;
@@ -4575,5 +5483,5 @@ function VisitParameterList(options) {
4575
5483
  * Generated bundle index. Do not edit.
4576
5484
  */
4577
5485
 
4578
- export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractInputComponent, AbstractInteractionContext, AbstractPlaceNavigationComponent, AbstractPopStateNavigation, Activity, ActivityActionsComponent, ActivityContainerComponent, ActivityOutletComponent, ActivityRef, AddItemInteractionContextComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CardContainerComponent, CheckboxInputComponent, CommandDirective, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DialogInteractionContext, DialogInteractionContextFactory, Dimension, DirectivesModule, DisposableComponent, EmptyStateComponent, EventCleanUpSession, FocusBinding, FocusBindingDirective, FocusBindingFactory, FocusContainerComponent, FocusableComponent, Formatter, InPlaceInteractionContextComponent, InteractionModule, InteractionService, InteractionServiceRoutingAdapter, LEFT_RIGHT_PLACE_ANIMATION, ListPlaceNavComponent, ModalInteractionContextFactory, Navigating, NavigatingDuringInteraction, NavigationContext, NavigationSession, NoopAuthGuard, NoopComponent, NumberInputComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceGuard, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, PopStateDuringInteractionNavigation, PopStateNavigation, ROUTE_PARAMETER_LIST_KEY, RemoveLastInteractionFromUrlNavigationSession, ResizeAwareComponent, RouteId, ScrollContainerComponent, SelectInputComponent, SidePlaceNavigationComponent, StringInputComponent, SwitchCaseComponent, SwitchCaseDefaultDirective, SwitchCaseOption, SwitchCaseWhenDirective, SynchroniseInteractionContextIdsWithRoute, TabbedPlaceNavigationComponent, TextInputComponent, UrlService, UrlSnapshot, VerticalFocusContainerComponent, Visit, VisitParameter, VisitParameterList, VisitSanitiser, WaitUntilLeavingInteractionTransitionCancelled, WaitUntilLinkTriggeredNavigationInteractionCancellationEventsFinish, WaitUntilPopStateDuringCanDeactivateInteractionFinishes, leftRightPlaceAnimation, slideDownOnEnterAnimation, slideRightOnEnterAnimation, DirectivesModule as ɵa, CommandDirective as ɵb, PlaceOutletComponent as ɵba, leftRightPlaceAnimation as ɵbb, LEFT_RIGHT_PLACE_ANIMATION as ɵbc, AUP_PLACE_CONFIG as ɵbd, PlaceRouter as ɵbf, InteractionService as ɵbg, ModalInteractionContextFactory as ɵbh, UrlService as ɵbi, PlaceHistory as ɵbj, TabbedPlaceNavigationComponent as ɵbk, AbstractPlaceNavigationComponent as ɵbl, ListPlaceNavComponent as ɵbm, SidePlaceNavigationComponent as ɵbn, InteractionModule as ɵbo, ActivityContainerComponent as ɵbp, AbstractInteractionContext as ɵbq, ActivityOutletComponent as ɵbr, ConfirmationDialogComponent as ɵbs, ACTIVITY_DATA as ɵbt, Activity as ɵbu, ConfirmThenDialogComponent as ɵbw, AlertDialogComponent as ɵbx, InPlaceInteractionContextComponent as ɵbz, FocusBindingDirective as ɵc, AddItemInteractionContextComponent as ɵca, DisposableComponent as ɵcb, InPlaceInteractionContextComponent as ɵcc, ActivityActionsComponent as ɵcd, DisposableComponent as ɵd, FocusBindingFactory as ɵe, ComponentsModule as ɵf, NumberInputComponent as ɵg, AbstractInputComponent as ɵh, StringInputComponent as ɵi, TextInputComponent as ɵj, PasswordInputComponent as ɵk, SelectInputComponent as ɵl, CheckboxInputComponent as ɵm, ScrollContainerComponent as ɵn, NoopComponent as ɵo, SwitchCaseOption as ɵp, SwitchCaseWhenDirective as ɵq, SwitchCaseDefaultDirective as ɵr, SwitchCaseComponent as ɵs, FocusContainerComponent as ɵt, VerticalFocusContainerComponent as ɵu, FocusableComponent as ɵv, CardContainerComponent as ɵw, PlaceModule as ɵx, EmptyStateComponent as ɵy, BusyOverlayComponent as ɵz };
5486
+ export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractInputActivity, AbstractInputComponent, AbstractInteractionContext, AbstractPlaceNavigationComponent, AbstractPopStateNavigation, Activity, ActivityActionsComponent, ActivityContainerComponent, ActivityOutletComponent, ActivityRef, AddItemInteractionContextComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CardContainerComponent, CheckboxInputComponent, ColumnModel, ColumnTemplateDirective, CommandDirective, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, CustomTemplateColumnModel, CustomValueColumnModel, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DefaultCellRendererComponent, DefaultHeaderCellRendererComponent, DialogInteractionContext, DialogInteractionContextFactory, Dimension, DirectivesModule, DisposableComponent, EditRowControls, EditorControlColumnModel, EmptyStateComponent, EventCleanUpSession, FocusBinding, FocusBindingDirective, FocusBindingFactory, FocusContainerComponent, FocusableComponent, Formatter, InPlaceInteractionContextComponent, InteractionContextTriggerFor, InteractionModule, InteractionService, InteractionServiceRoutingAdapter, LEFT_RIGHT_PLACE_ANIMATION, ListPlaceNavComponent, ModalInteractionContextFactory, Navigating, NavigatingDuringInteraction, NavigationContext, NavigationSession, NoopAuthGuard, NoopComponent, NumberInputComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceGuard, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, PopStateDuringInteractionNavigation, PopStateNavigation, PopupInteractionContextComponent, PropertyColumnModel, ROUTE_PARAMETER_LIST_KEY, RemoveLastInteractionFromUrlNavigationSession, ResizeAwareComponent, RouteId, ScrollContainerComponent, SelectCellRendererComponent, SelectHeaderCellRendererComponent, SelectInputComponent, SelectionColumnModel, SidePlaceNavigationComponent, StringInputActivity, StringInputComponent, SwitchCaseComponent, SwitchCaseDefaultDirective, SwitchCaseOption, SwitchCaseWhenDirective, SynchroniseInteractionContextIdsWithRoute, TabbedPlaceNavigationComponent, TableCellRendererComponent, TableComponent, TableHeaderCellRendererComponent, TableModel, TextInputComponent, UrlService, UrlSnapshot, VerticalFocusContainerComponent, Visit, VisitParameter, VisitParameterList, VisitSanitiser, WaitUntilLeavingInteractionTransitionCancelled, WaitUntilLinkTriggeredNavigationInteractionCancellationEventsFinish, WaitUntilPopStateDuringCanDeactivateInteractionFinishes, leftRightPlaceAnimation, slideDownOnEnterAnimation, slideRightOnEnterAnimation, DirectivesModule as ɵa, CommandDirective as ɵb, CardContainerComponent as ɵba, TableComponent as ɵbb, EditRowControls as ɵbc, ColumnTemplateDirective as ɵbd, DefaultCellRendererComponent as ɵbe, TableCellRendererComponent as ɵbf, SelectCellRendererComponent as ɵbg, SelectHeaderCellRendererComponent as ɵbh, DefaultHeaderCellRendererComponent as ɵbi, TableHeaderCellRendererComponent as ɵbj, InteractionModule as ɵbk, ActivityContainerComponent as ɵbl, AbstractInteractionContext as ɵbm, ActivityOutletComponent as ɵbn, ConfirmationDialogComponent as ɵbo, ACTIVITY_DATA as ɵbp, Activity as ɵbq, ConfirmThenDialogComponent as ɵbs, AlertDialogComponent as ɵbt, InPlaceInteractionContextComponent as ɵbv, InteractionService as ɵbw, ModalInteractionContextFactory as ɵbx, AddItemInteractionContextComponent as ɵby, DisposableComponent as ɵbz, FocusBindingDirective as ɵc, InPlaceInteractionContextComponent as ɵca, ActivityActionsComponent as ɵcb, PopupInteractionContextComponent as ɵcc, InteractionContextTriggerFor as ɵcd, PlaceModule as ɵce, EmptyStateComponent as ɵcf, BusyOverlayComponent as ɵcg, PlaceOutletComponent as ɵch, leftRightPlaceAnimation as ɵci, LEFT_RIGHT_PLACE_ANIMATION as ɵcj, AUP_PLACE_CONFIG as ɵck, PlaceRouter as ɵcm, UrlService as ɵcn, PlaceHistory as ɵco, TabbedPlaceNavigationComponent as ɵcp, AbstractPlaceNavigationComponent as ɵcq, ListPlaceNavComponent as ɵcr, SidePlaceNavigationComponent as ɵcs, DisposableComponent as ɵd, FocusBindingFactory as ɵe, ComponentsModule as ɵf, AbstractInputComponent as ɵg, AbstractInputActivity as ɵh, Activity as ɵi, ACTIVITY_DATA as ɵj, NumberInputComponent as ɵk, StringInputComponent as ɵl, StringInputActivity as ɵm, TextInputComponent as ɵn, PasswordInputComponent as ɵo, SelectInputComponent as ɵp, CheckboxInputComponent as ɵq, ScrollContainerComponent as ɵr, NoopComponent as ɵs, SwitchCaseOption as ɵt, SwitchCaseWhenDirective as ɵu, SwitchCaseDefaultDirective as ɵv, SwitchCaseComponent as ɵw, FocusContainerComponent as ɵx, VerticalFocusContainerComponent as ɵy, FocusableComponent as ɵz };
4579
5487
  //# sourceMappingURL=coolon-angular-ui-powerups.js.map