@tft/crispr-forms 12.2.22 → 13.0.3

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 (339) hide show
  1. package/README.md +9 -69
  2. package/esm2020/index.mjs +2 -0
  3. package/esm2020/lib/abstracts/autocomplete-field.abstract.mjs +30 -0
  4. package/esm2020/lib/abstracts/crispr-control.mixin.mjs +27 -0
  5. package/esm2020/lib/abstracts/crispr-field.abstract.mjs +17 -0
  6. package/esm2020/lib/abstracts/index.mjs +4 -0
  7. package/esm2020/lib/crispr-forms.module.mjs +66 -0
  8. package/esm2020/lib/field-component-map.const.mjs +25 -0
  9. package/esm2020/lib/field-container/field-container.component.mjs +85 -0
  10. package/esm2020/lib/field-container/index.mjs +2 -0
  11. package/esm2020/lib/field.directive.mjs +77 -0
  12. package/esm2020/lib/form/form.component.mjs +54 -0
  13. package/esm2020/lib/form-group-list/form-group-list.component.mjs +51 -0
  14. package/esm2020/lib/form-group-list/form-group-list.module.mjs +54 -0
  15. package/esm2020/lib/form-group-list/index.mjs +3 -0
  16. package/esm2020/lib/form.helpers.mjs +185 -0
  17. package/esm2020/lib/form.operators.mjs +24 -0
  18. package/esm2020/lib/material/autocomplete-chiplist-field/autocomplete-chiplist-field.component.mjs +111 -0
  19. package/esm2020/lib/material/autocomplete-field/autocomplete-field.component.mjs +70 -0
  20. package/esm2020/lib/material/button/button.component.mjs +35 -0
  21. package/esm2020/lib/material/checkbox-field/checkbox-field.component.mjs +31 -0
  22. package/esm2020/lib/material/datepicker-field/datepicker-field.component.mjs +45 -0
  23. package/esm2020/lib/material/divider/divider.component.mjs +22 -0
  24. package/esm2020/lib/material/file-upload/file-dropzone.directive.mjs +39 -0
  25. package/esm2020/lib/material/file-upload/file-upload.component.mjs +145 -0
  26. package/esm2020/lib/material/file-upload/index.mjs +3 -0
  27. package/esm2020/lib/material/heading/heading.component.mjs +54 -0
  28. package/esm2020/lib/material/image-upload-field/image-compression.helpers.mjs +4 -0
  29. package/esm2020/lib/material/image-upload-field/image-upload-field.component.mjs +233 -0
  30. package/esm2020/lib/material/image-upload-field/index.mjs +2 -0
  31. package/esm2020/lib/material/index.mjs +18 -0
  32. package/esm2020/lib/material/info/info.component.mjs +46 -0
  33. package/esm2020/lib/material/input-field/input-field.component.mjs +27 -0
  34. package/esm2020/lib/material/material.module.mjs +200 -0
  35. package/esm2020/lib/material/option/index.mjs +2 -0
  36. package/esm2020/lib/material/option/option.component.mjs +14 -0
  37. package/esm2020/lib/material/radio-field/radio-field.component.mjs +29 -0
  38. package/esm2020/lib/material/select-field/select-field.component.mjs +58 -0
  39. package/esm2020/lib/material/selected-file/selected-file.component.mjs +47 -0
  40. package/esm2020/lib/material/slider-field/slider-field.component.mjs +30 -0
  41. package/esm2020/lib/material/textarea-field/textarea-field.component.mjs +28 -0
  42. package/esm2020/lib/material/unit-conversion-field/unit-conversion-field.component.mjs +69 -0
  43. package/esm2020/lib/models/autocomplete-chiplist-field.config.mjs +2 -0
  44. package/esm2020/lib/models/autocomplete-field.config.mjs +2 -0
  45. package/esm2020/lib/models/button.config.mjs +2 -0
  46. package/esm2020/lib/models/checkbox-field.config.mjs +2 -0
  47. package/esm2020/lib/models/crispr-field.config.mjs +23 -0
  48. package/esm2020/lib/models/datepicker-field.config.mjs +2 -0
  49. package/esm2020/lib/models/divider.config.mjs +2 -0
  50. package/esm2020/lib/models/file-upload-field.config.mjs +2 -0
  51. package/esm2020/lib/models/form-group-list.config.mjs +2 -0
  52. package/esm2020/lib/models/heading.config.mjs +3 -0
  53. package/esm2020/lib/models/image-upload-field.config.mjs +2 -0
  54. package/esm2020/lib/models/index.mjs +18 -0
  55. package/esm2020/lib/models/input-field.config.mjs +2 -0
  56. package/esm2020/lib/models/radio-field.config.mjs +2 -0
  57. package/esm2020/lib/models/select-field.config.mjs +2 -0
  58. package/esm2020/lib/models/slider-field.config.mjs +2 -0
  59. package/esm2020/lib/models/textarea-field.config.mjs +2 -0
  60. package/esm2020/lib/models/unit-conversion-field.config.mjs +2 -0
  61. package/esm2020/lib/pipes/crispr-pipes.module.mjs +26 -0
  62. package/esm2020/lib/pipes/initial-control-value.pipe.mjs +20 -0
  63. package/esm2020/lib/public_api.mjs +10 -0
  64. package/esm2020/lib/sub-group/index.mjs +3 -0
  65. package/esm2020/lib/sub-group/sub-group.component.mjs +20 -0
  66. package/esm2020/lib/sub-group/sub-group.module.mjs +45 -0
  67. package/esm2020/tft-crispr-forms.mjs +5 -0
  68. package/fesm2015/tft-crispr-forms.mjs +1904 -0
  69. package/fesm2015/tft-crispr-forms.mjs.map +1 -0
  70. package/fesm2020/tft-crispr-forms.mjs +1896 -0
  71. package/fesm2020/tft-crispr-forms.mjs.map +1 -0
  72. package/lib/abstracts/autocomplete-field.abstract.d.ts +4 -1
  73. package/lib/abstracts/crispr-control.mixin.d.ts +1 -1
  74. package/lib/abstracts/crispr-field.abstract.d.ts +4 -1
  75. package/lib/crispr-forms.module.d.ts +14 -0
  76. package/lib/field-component-map.const.d.ts +21 -20
  77. package/lib/field-container/field-container.component.d.ts +11 -1
  78. package/lib/field-container/index.d.ts +1 -0
  79. package/lib/field.directive.d.ts +14 -5
  80. package/lib/form/form.component.d.ts +6 -1
  81. package/lib/form-group-list/form-group-list.component.d.ts +4 -1
  82. package/lib/form-group-list/form-group-list.module.d.ts +15 -0
  83. package/lib/form-group-list/index.d.ts +2 -0
  84. package/lib/form.helpers.d.ts +1 -1
  85. package/lib/material/autocomplete-chiplist-field/autocomplete-chiplist-field.component.d.ts +3 -0
  86. package/lib/material/autocomplete-field/autocomplete-field.component.d.ts +3 -0
  87. package/lib/material/button/button.component.d.ts +3 -0
  88. package/lib/material/checkbox-field/checkbox-field.component.d.ts +3 -0
  89. package/lib/material/datepicker-field/datepicker-field.component.d.ts +3 -0
  90. package/lib/material/divider/divider.component.d.ts +3 -0
  91. package/lib/material/file-upload/file-dropzone.directive.d.ts +3 -0
  92. package/lib/material/file-upload/file-upload.component.d.ts +20 -2
  93. package/lib/material/file-upload/index.d.ts +2 -0
  94. package/lib/material/heading/heading.component.d.ts +12 -1
  95. package/lib/material/image-upload-field/image-compression.helpers.d.ts +1 -0
  96. package/lib/material/image-upload-field/image-upload-field.component.d.ts +64 -0
  97. package/lib/material/image-upload-field/index.d.ts +1 -0
  98. package/lib/material/index.d.ts +4 -1
  99. package/lib/material/info/info.component.d.ts +12 -1
  100. package/lib/material/input-field/input-field.component.d.ts +3 -0
  101. package/lib/material/material.module.d.ts +42 -0
  102. package/lib/material/option/index.d.ts +1 -0
  103. package/lib/material/option/option.component.d.ts +3 -0
  104. package/lib/material/radio-field/radio-field.component.d.ts +3 -0
  105. package/lib/material/select-field/select-field.component.d.ts +3 -0
  106. package/lib/material/selected-file/selected-file.component.d.ts +10 -0
  107. package/lib/material/slider-field/slider-field.component.d.ts +3 -0
  108. package/lib/material/textarea-field/textarea-field.component.d.ts +3 -0
  109. package/lib/material/unit-conversion-field/unit-conversion-field.component.d.ts +3 -0
  110. package/lib/models/button.config.d.ts +3 -2
  111. package/lib/models/crispr-field.config.d.ts +5 -6
  112. package/lib/models/file-upload-field.config.d.ts +4 -3
  113. package/lib/models/image-upload-field.config.d.ts +47 -0
  114. package/lib/models/index.d.ts +2 -0
  115. package/lib/models/radio-field.config.d.ts +1 -1
  116. package/lib/pipes/crispr-pipes.module.d.ts +8 -0
  117. package/lib/pipes/initial-control-value.pipe.d.ts +3 -0
  118. package/lib/public_api.d.ts +1 -0
  119. package/lib/sub-group/index.d.ts +2 -0
  120. package/lib/sub-group/sub-group.component.d.ts +3 -0
  121. package/lib/sub-group/sub-group.module.d.ts +12 -0
  122. package/package.json +30 -15
  123. package/tft-crispr-forms-13.0.3.tgz +0 -0
  124. package/tft-crispr-forms.d.ts +1 -25
  125. package/bundles/tft-crispr-forms.umd.js +0 -1722
  126. package/bundles/tft-crispr-forms.umd.js.map +0 -1
  127. package/esm2015/index.js +0 -2
  128. package/esm2015/index.js.map +0 -1
  129. package/esm2015/index.metadata.json +0 -1
  130. package/esm2015/lib/abstracts/autocomplete-field.abstract.js +0 -27
  131. package/esm2015/lib/abstracts/autocomplete-field.abstract.js.map +0 -1
  132. package/esm2015/lib/abstracts/autocomplete-field.abstract.metadata.json +0 -1
  133. package/esm2015/lib/abstracts/crispr-control.mixin.js +0 -27
  134. package/esm2015/lib/abstracts/crispr-control.mixin.js.map +0 -1
  135. package/esm2015/lib/abstracts/crispr-control.mixin.metadata.json +0 -1
  136. package/esm2015/lib/abstracts/crispr-field.abstract.js +0 -14
  137. package/esm2015/lib/abstracts/crispr-field.abstract.js.map +0 -1
  138. package/esm2015/lib/abstracts/crispr-field.abstract.metadata.json +0 -1
  139. package/esm2015/lib/abstracts/index.js +0 -4
  140. package/esm2015/lib/abstracts/index.js.map +0 -1
  141. package/esm2015/lib/abstracts/index.metadata.json +0 -1
  142. package/esm2015/lib/crispr-forms.module.js +0 -41
  143. package/esm2015/lib/crispr-forms.module.js.map +0 -1
  144. package/esm2015/lib/crispr-forms.module.metadata.json +0 -1
  145. package/esm2015/lib/crispr-forms.module.ngfactory.js.map +0 -1
  146. package/esm2015/lib/field-component-map.const.js +0 -28
  147. package/esm2015/lib/field-component-map.const.js.map +0 -1
  148. package/esm2015/lib/field-component-map.const.metadata.json +0 -1
  149. package/esm2015/lib/field-container/field-container.component.js +0 -57
  150. package/esm2015/lib/field-container/field-container.component.js.map +0 -1
  151. package/esm2015/lib/field-container/field-container.component.metadata.json +0 -1
  152. package/esm2015/lib/field-container/field-container.component.ngfactory.js.map +0 -1
  153. package/esm2015/lib/field-container/field-container.component.scss.shim.ngstyle.js.map +0 -1
  154. package/esm2015/lib/field.directive.js +0 -55
  155. package/esm2015/lib/field.directive.js.map +0 -1
  156. package/esm2015/lib/field.directive.metadata.json +0 -1
  157. package/esm2015/lib/field.directive.ngfactory.js.map +0 -1
  158. package/esm2015/lib/form/form.component.js +0 -40
  159. package/esm2015/lib/form/form.component.js.map +0 -1
  160. package/esm2015/lib/form/form.component.metadata.json +0 -1
  161. package/esm2015/lib/form/form.component.ngfactory.js.map +0 -1
  162. package/esm2015/lib/form/form.component.scss.shim.ngstyle.js.map +0 -1
  163. package/esm2015/lib/form-group-list/form-group-list.component.js +0 -44
  164. package/esm2015/lib/form-group-list/form-group-list.component.js.map +0 -1
  165. package/esm2015/lib/form-group-list/form-group-list.component.metadata.json +0 -1
  166. package/esm2015/lib/form-group-list/form-group-list.component.ngfactory.js.map +0 -1
  167. package/esm2015/lib/form-group-list/form-group-list.component.scss.shim.ngstyle.js.map +0 -1
  168. package/esm2015/lib/form.helpers.js +0 -186
  169. package/esm2015/lib/form.helpers.js.map +0 -1
  170. package/esm2015/lib/form.helpers.metadata.json +0 -1
  171. package/esm2015/lib/form.operators.js +0 -24
  172. package/esm2015/lib/form.operators.js.map +0 -1
  173. package/esm2015/lib/form.operators.metadata.json +0 -1
  174. package/esm2015/lib/material/autocomplete-chiplist-field/autocomplete-chiplist-field.component.js +0 -101
  175. package/esm2015/lib/material/autocomplete-chiplist-field/autocomplete-chiplist-field.component.js.map +0 -1
  176. package/esm2015/lib/material/autocomplete-chiplist-field/autocomplete-chiplist-field.component.metadata.json +0 -1
  177. package/esm2015/lib/material/autocomplete-chiplist-field/autocomplete-chiplist-field.component.ngfactory.js.map +0 -1
  178. package/esm2015/lib/material/autocomplete-chiplist-field/autocomplete-chiplist-field.component.scss.shim.ngstyle.js.map +0 -1
  179. package/esm2015/lib/material/autocomplete-field/autocomplete-field.component.js +0 -60
  180. package/esm2015/lib/material/autocomplete-field/autocomplete-field.component.js.map +0 -1
  181. package/esm2015/lib/material/autocomplete-field/autocomplete-field.component.metadata.json +0 -1
  182. package/esm2015/lib/material/autocomplete-field/autocomplete-field.component.ngfactory.js.map +0 -1
  183. package/esm2015/lib/material/autocomplete-field/autocomplete-field.component.scss.shim.ngstyle.js.map +0 -1
  184. package/esm2015/lib/material/button/button.component.js +0 -30
  185. package/esm2015/lib/material/button/button.component.js.map +0 -1
  186. package/esm2015/lib/material/button/button.component.metadata.json +0 -1
  187. package/esm2015/lib/material/button/button.component.ngfactory.js.map +0 -1
  188. package/esm2015/lib/material/button/button.component.scss.shim.ngstyle.js.map +0 -1
  189. package/esm2015/lib/material/checkbox-field/checkbox-field.component.js +0 -25
  190. package/esm2015/lib/material/checkbox-field/checkbox-field.component.js.map +0 -1
  191. package/esm2015/lib/material/checkbox-field/checkbox-field.component.metadata.json +0 -1
  192. package/esm2015/lib/material/checkbox-field/checkbox-field.component.ngfactory.js.map +0 -1
  193. package/esm2015/lib/material/checkbox-field/checkbox-field.component.scss.shim.ngstyle.js.map +0 -1
  194. package/esm2015/lib/material/datepicker-field/datepicker-field.component.js +0 -45
  195. package/esm2015/lib/material/datepicker-field/datepicker-field.component.js.map +0 -1
  196. package/esm2015/lib/material/datepicker-field/datepicker-field.component.metadata.json +0 -1
  197. package/esm2015/lib/material/datepicker-field/datepicker-field.component.ngfactory.js.map +0 -1
  198. package/esm2015/lib/material/datepicker-field/datepicker-field.component.scss.shim.ngstyle.js.map +0 -1
  199. package/esm2015/lib/material/divider/divider.component.js +0 -20
  200. package/esm2015/lib/material/divider/divider.component.js.map +0 -1
  201. package/esm2015/lib/material/divider/divider.component.metadata.json +0 -1
  202. package/esm2015/lib/material/divider/divider.component.ngfactory.js.map +0 -1
  203. package/esm2015/lib/material/divider/divider.component.scss.shim.ngstyle.js.map +0 -1
  204. package/esm2015/lib/material/file-upload/file-dropzone.directive.js +0 -31
  205. package/esm2015/lib/material/file-upload/file-dropzone.directive.js.map +0 -1
  206. package/esm2015/lib/material/file-upload/file-dropzone.directive.metadata.json +0 -1
  207. package/esm2015/lib/material/file-upload/file-dropzone.directive.ngfactory.js.map +0 -1
  208. package/esm2015/lib/material/file-upload/file-upload.component.js +0 -80
  209. package/esm2015/lib/material/file-upload/file-upload.component.js.map +0 -1
  210. package/esm2015/lib/material/file-upload/file-upload.component.metadata.json +0 -1
  211. package/esm2015/lib/material/file-upload/file-upload.component.ngfactory.js.map +0 -1
  212. package/esm2015/lib/material/file-upload/file-upload.component.scss.shim.ngstyle.js.map +0 -1
  213. package/esm2015/lib/material/heading/heading.component.js +0 -23
  214. package/esm2015/lib/material/heading/heading.component.js.map +0 -1
  215. package/esm2015/lib/material/heading/heading.component.metadata.json +0 -1
  216. package/esm2015/lib/material/heading/heading.component.ngfactory.js.map +0 -1
  217. package/esm2015/lib/material/heading/heading.component.scss.shim.ngstyle.js.map +0 -1
  218. package/esm2015/lib/material/index.js +0 -15
  219. package/esm2015/lib/material/index.js.map +0 -1
  220. package/esm2015/lib/material/index.metadata.json +0 -1
  221. package/esm2015/lib/material/info/info.component.js +0 -15
  222. package/esm2015/lib/material/info/info.component.js.map +0 -1
  223. package/esm2015/lib/material/info/info.component.metadata.json +0 -1
  224. package/esm2015/lib/material/info/info.component.ngfactory.js.map +0 -1
  225. package/esm2015/lib/material/info/info.component.scss.shim.ngstyle.js.map +0 -1
  226. package/esm2015/lib/material/input-field/input-field.component.js +0 -22
  227. package/esm2015/lib/material/input-field/input-field.component.js.map +0 -1
  228. package/esm2015/lib/material/input-field/input-field.component.metadata.json +0 -1
  229. package/esm2015/lib/material/input-field/input-field.component.ngfactory.js.map +0 -1
  230. package/esm2015/lib/material/input-field/input-field.component.scss.shim.ngstyle.js.map +0 -1
  231. package/esm2015/lib/material/material.module.js +0 -107
  232. package/esm2015/lib/material/material.module.js.map +0 -1
  233. package/esm2015/lib/material/material.module.metadata.json +0 -1
  234. package/esm2015/lib/material/material.module.ngfactory.js.map +0 -1
  235. package/esm2015/lib/material/option/option.component.js +0 -15
  236. package/esm2015/lib/material/option/option.component.js.map +0 -1
  237. package/esm2015/lib/material/option/option.component.metadata.json +0 -1
  238. package/esm2015/lib/material/option/option.component.ngfactory.js.map +0 -1
  239. package/esm2015/lib/material/option/option.component.scss.shim.ngstyle.js.map +0 -1
  240. package/esm2015/lib/material/radio-field/radio-field.component.js +0 -25
  241. package/esm2015/lib/material/radio-field/radio-field.component.js.map +0 -1
  242. package/esm2015/lib/material/radio-field/radio-field.component.metadata.json +0 -1
  243. package/esm2015/lib/material/radio-field/radio-field.component.ngfactory.js.map +0 -1
  244. package/esm2015/lib/material/radio-field/radio-field.component.scss.shim.ngstyle.js.map +0 -1
  245. package/esm2015/lib/material/select-field/select-field.component.js +0 -50
  246. package/esm2015/lib/material/select-field/select-field.component.js.map +0 -1
  247. package/esm2015/lib/material/select-field/select-field.component.metadata.json +0 -1
  248. package/esm2015/lib/material/select-field/select-field.component.ngfactory.js.map +0 -1
  249. package/esm2015/lib/material/select-field/select-field.component.scss.shim.ngstyle.js.map +0 -1
  250. package/esm2015/lib/material/selected-file/selected-file.component.js +0 -17
  251. package/esm2015/lib/material/selected-file/selected-file.component.js.map +0 -1
  252. package/esm2015/lib/material/selected-file/selected-file.component.metadata.json +0 -1
  253. package/esm2015/lib/material/selected-file/selected-file.component.ngfactory.js.map +0 -1
  254. package/esm2015/lib/material/selected-file/selected-file.component.scss.shim.ngstyle.js.map +0 -1
  255. package/esm2015/lib/material/slider-field/slider-field.component.js +0 -26
  256. package/esm2015/lib/material/slider-field/slider-field.component.js.map +0 -1
  257. package/esm2015/lib/material/slider-field/slider-field.component.metadata.json +0 -1
  258. package/esm2015/lib/material/slider-field/slider-field.component.ngfactory.js.map +0 -1
  259. package/esm2015/lib/material/slider-field/slider-field.component.scss.shim.ngstyle.js.map +0 -1
  260. package/esm2015/lib/material/textarea-field/textarea-field.component.js +0 -22
  261. package/esm2015/lib/material/textarea-field/textarea-field.component.js.map +0 -1
  262. package/esm2015/lib/material/textarea-field/textarea-field.component.metadata.json +0 -1
  263. package/esm2015/lib/material/textarea-field/textarea-field.component.ngfactory.js.map +0 -1
  264. package/esm2015/lib/material/textarea-field/textarea-field.component.scss.shim.ngstyle.js.map +0 -1
  265. package/esm2015/lib/material/unit-conversion-field/unit-conversion-field.component.js +0 -63
  266. package/esm2015/lib/material/unit-conversion-field/unit-conversion-field.component.js.map +0 -1
  267. package/esm2015/lib/material/unit-conversion-field/unit-conversion-field.component.metadata.json +0 -1
  268. package/esm2015/lib/material/unit-conversion-field/unit-conversion-field.component.ngfactory.js.map +0 -1
  269. package/esm2015/lib/material/unit-conversion-field/unit-conversion-field.component.scss.shim.ngstyle.js.map +0 -1
  270. package/esm2015/lib/models/autocomplete-chiplist-field.config.js +0 -2
  271. package/esm2015/lib/models/autocomplete-chiplist-field.config.js.map +0 -1
  272. package/esm2015/lib/models/autocomplete-chiplist-field.config.metadata.json +0 -1
  273. package/esm2015/lib/models/autocomplete-field.config.js +0 -2
  274. package/esm2015/lib/models/autocomplete-field.config.js.map +0 -1
  275. package/esm2015/lib/models/autocomplete-field.config.metadata.json +0 -1
  276. package/esm2015/lib/models/button.config.js +0 -2
  277. package/esm2015/lib/models/button.config.js.map +0 -1
  278. package/esm2015/lib/models/button.config.metadata.json +0 -1
  279. package/esm2015/lib/models/checkbox-field.config.js +0 -2
  280. package/esm2015/lib/models/checkbox-field.config.js.map +0 -1
  281. package/esm2015/lib/models/checkbox-field.config.metadata.json +0 -1
  282. package/esm2015/lib/models/crispr-field.config.js +0 -22
  283. package/esm2015/lib/models/crispr-field.config.js.map +0 -1
  284. package/esm2015/lib/models/crispr-field.config.metadata.json +0 -1
  285. package/esm2015/lib/models/datepicker-field.config.js +0 -2
  286. package/esm2015/lib/models/datepicker-field.config.js.map +0 -1
  287. package/esm2015/lib/models/datepicker-field.config.metadata.json +0 -1
  288. package/esm2015/lib/models/divider.config.js +0 -2
  289. package/esm2015/lib/models/divider.config.js.map +0 -1
  290. package/esm2015/lib/models/divider.config.metadata.json +0 -1
  291. package/esm2015/lib/models/file-upload-field.config.js +0 -2
  292. package/esm2015/lib/models/file-upload-field.config.js.map +0 -1
  293. package/esm2015/lib/models/file-upload-field.config.metadata.json +0 -1
  294. package/esm2015/lib/models/form-group-list.config.js +0 -2
  295. package/esm2015/lib/models/form-group-list.config.js.map +0 -1
  296. package/esm2015/lib/models/form-group-list.config.metadata.json +0 -1
  297. package/esm2015/lib/models/heading.config.js +0 -3
  298. package/esm2015/lib/models/heading.config.js.map +0 -1
  299. package/esm2015/lib/models/heading.config.metadata.json +0 -1
  300. package/esm2015/lib/models/index.js +0 -16
  301. package/esm2015/lib/models/index.js.map +0 -1
  302. package/esm2015/lib/models/index.metadata.json +0 -1
  303. package/esm2015/lib/models/input-field.config.js +0 -2
  304. package/esm2015/lib/models/input-field.config.js.map +0 -1
  305. package/esm2015/lib/models/input-field.config.metadata.json +0 -1
  306. package/esm2015/lib/models/radio-field.config.js +0 -2
  307. package/esm2015/lib/models/radio-field.config.js.map +0 -1
  308. package/esm2015/lib/models/radio-field.config.metadata.json +0 -1
  309. package/esm2015/lib/models/select-field.config.js +0 -2
  310. package/esm2015/lib/models/select-field.config.js.map +0 -1
  311. package/esm2015/lib/models/select-field.config.metadata.json +0 -1
  312. package/esm2015/lib/models/slider-field.config.js +0 -2
  313. package/esm2015/lib/models/slider-field.config.js.map +0 -1
  314. package/esm2015/lib/models/slider-field.config.metadata.json +0 -1
  315. package/esm2015/lib/models/textarea-field.config.js +0 -2
  316. package/esm2015/lib/models/textarea-field.config.js.map +0 -1
  317. package/esm2015/lib/models/textarea-field.config.metadata.json +0 -1
  318. package/esm2015/lib/models/unit-conversion-field.config.js +0 -2
  319. package/esm2015/lib/models/unit-conversion-field.config.js.map +0 -1
  320. package/esm2015/lib/models/unit-conversion-field.config.metadata.json +0 -1
  321. package/esm2015/lib/pipes/initial-control-value.pipe.js +0 -16
  322. package/esm2015/lib/pipes/initial-control-value.pipe.js.map +0 -1
  323. package/esm2015/lib/pipes/initial-control-value.pipe.metadata.json +0 -1
  324. package/esm2015/lib/pipes/initial-control-value.pipe.ngfactory.js.map +0 -1
  325. package/esm2015/lib/public_api.js +0 -9
  326. package/esm2015/lib/public_api.js.map +0 -1
  327. package/esm2015/lib/public_api.metadata.json +0 -1
  328. package/esm2015/lib/sub-group/sub-group.component.js +0 -17
  329. package/esm2015/lib/sub-group/sub-group.component.js.map +0 -1
  330. package/esm2015/lib/sub-group/sub-group.component.metadata.json +0 -1
  331. package/esm2015/lib/sub-group/sub-group.component.ngfactory.js.map +0 -1
  332. package/esm2015/lib/sub-group/sub-group.component.scss.shim.ngstyle.js.map +0 -1
  333. package/esm2015/tft-crispr-forms.js +0 -30
  334. package/esm2015/tft-crispr-forms.js.map +0 -1
  335. package/esm2015/tft-crispr-forms.metadata.json +0 -1
  336. package/fesm2015/tft-crispr-forms.js +0 -1266
  337. package/fesm2015/tft-crispr-forms.js.map +0 -1
  338. package/tft-crispr-forms-12.2.22.tgz +0 -0
  339. package/tft-crispr-forms.metadata.json +0 -1
@@ -0,0 +1,1904 @@
1
+ import { of, combineLatest, from, isObservable, BehaviorSubject, Subject } from 'rxjs';
2
+ import * as i4$1 from '@angular/forms';
3
+ import { FormGroup, FormArray, FormControl, ReactiveFormsModule } from '@angular/forms';
4
+ import { map, startWith, debounceTime, distinctUntilChanged, switchMap, tap, shareReplay } from 'rxjs/operators';
5
+ import * as i0 from '@angular/core';
6
+ import { Directive, Component, ChangeDetectionStrategy, Input, NgModule, ViewChild, EventEmitter, Output, HostListener, Optional, Self, Pipe } from '@angular/core';
7
+ import * as i2 from '@angular/common';
8
+ import { CommonModule } from '@angular/common';
9
+ import * as i2$1 from '@angular/material/form-field';
10
+ import { MatFormFieldModule } from '@angular/material/form-field';
11
+ import * as i4 from '@angular/material/icon';
12
+ import { MatIconModule } from '@angular/material/icon';
13
+ import * as i3 from '@angular/material/tooltip';
14
+ import { MatTooltipModule } from '@angular/material/tooltip';
15
+ import * as i5 from '@tft/form-validation-handler';
16
+ import { FormValidationHandlerModule } from '@tft/form-validation-handler';
17
+ import * as i7 from '@angular/material/input';
18
+ import { MatInputModule } from '@angular/material/input';
19
+ import * as i3$1 from '@angular/material/select';
20
+ import { MatSelectModule } from '@angular/material/select';
21
+ import * as i4$2 from '@angular/material/checkbox';
22
+ import { MatCheckboxModule } from '@angular/material/checkbox';
23
+ import * as i5$1 from '@angular/material/core';
24
+ import * as i4$3 from '@angular/material/autocomplete';
25
+ import { MatAutocompleteTrigger, MatAutocompleteModule } from '@angular/material/autocomplete';
26
+ import { ENTER } from '@angular/cdk/keycodes';
27
+ import * as i3$2 from '@angular/material/chips';
28
+ import { MatChipsModule } from '@angular/material/chips';
29
+ import * as i3$3 from '@angular/material/slider';
30
+ import { MatSliderModule } from '@angular/material/slider';
31
+ import * as i1 from '@angular/material/button';
32
+ import { MatButtonModule } from '@angular/material/button';
33
+ import * as i8 from '@angular/cdk/portal';
34
+ import { ComponentPortal, PortalModule } from '@angular/cdk/portal';
35
+ import * as i3$4 from '@angular/material/datepicker';
36
+ import { MatDatepickerModule } from '@angular/material/datepicker';
37
+ import * as i1$1 from '@angular/material/divider';
38
+ import { MatDividerModule } from '@angular/material/divider';
39
+ import * as i2$2 from '@angular/material/radio';
40
+ import { MatRadioModule } from '@angular/material/radio';
41
+ import { __awaiter } from 'tslib';
42
+ import imageCompression from 'browser-image-compression';
43
+ import * as i1$2 from '@angular/material/progress-bar';
44
+ import { MatProgressBarModule } from '@angular/material/progress-bar';
45
+ import * as i2$3 from '@angular/platform-browser';
46
+ import { MatButtonToggleModule } from '@angular/material/button-toggle';
47
+ import { MatSlideToggleModule } from '@angular/material/slide-toggle';
48
+ import { MatMomentDateModule } from '@angular/material-moment-adapter';
49
+
50
+ const DEFAULT_EMPTY_OPTIONS_MESSAGE = 'No Items';
51
+
52
+ // export type ControlType = keyof typeof FIELD_COMPONENTS;
53
+ var ControlType;
54
+ (function (ControlType) {
55
+ ControlType["AUTOCOMPLETE"] = "autocomplete";
56
+ ControlType["AUTOCOMPLETE_CHIPLIST"] = "autocompleteChiplist";
57
+ ControlType["BUTTON"] = "button";
58
+ ControlType["CHECKBOX"] = "checkbox";
59
+ ControlType["CUSTOM"] = "custom";
60
+ ControlType["DATEPICKER"] = "datepicker";
61
+ ControlType["DIVIDER"] = "divider";
62
+ ControlType["FILE_UPLOAD"] = "fileUpload";
63
+ ControlType["HEADING"] = "heading";
64
+ ControlType["INPUT"] = "input";
65
+ ControlType["IMAGE_UPLOAD"] = "imageUpload";
66
+ ControlType["GROUP_LIST"] = "groupList";
67
+ ControlType["RADIO"] = "radio";
68
+ ControlType["SELECT"] = "select";
69
+ ControlType["SLIDER"] = "slider";
70
+ ControlType["SUB_GROUP"] = "subGroup";
71
+ ControlType["TEXTAREA"] = "textarea";
72
+ ControlType["UNIT_CONVERSION"] = "unitConversion";
73
+ })(ControlType || (ControlType = {}));
74
+
75
+ ;
76
+
77
+ function valueIn(values) {
78
+ return map((value) => {
79
+ if (value) {
80
+ return values.some(v => {
81
+ if (isRegex(v)) {
82
+ const trimmedStringForRegex = v.substr(1, v.length - 2);
83
+ const regex = new RegExp(trimmedStringForRegex);
84
+ return regex.test(value);
85
+ }
86
+ else {
87
+ return v === value;
88
+ }
89
+ });
90
+ }
91
+ else {
92
+ return false;
93
+ }
94
+ });
95
+ }
96
+ function isRegex(string) {
97
+ return string.startsWith('/') && string.endsWith('/');
98
+ }
99
+
100
+ /**
101
+ * Watches a single control for a list of values, returns true when field value matches any value in list
102
+ * unless an evaluate method is found on config, in which case that method is run on the returned boolean value
103
+ * @param group the direct parent of the field we want to watch
104
+ * @param config
105
+ */
106
+ function checkControlForValues(group, config) {
107
+ // check that all the pieces we need are available
108
+ if (config && config.controlName && Array.isArray(config.values)) {
109
+ return getValueChanges(group, config.controlName).pipe(
110
+ // return a boolean, true if value is in the values being watch for, otherwise false
111
+ valueIn(config.values), map((isValueInValues) => {
112
+ // since we can only check if the value is in the list of watched values, the evaluate function gives us
113
+ // a chance to make other decisions based on if the boolean returned, e.g. return true if value not in watched values
114
+ if (config.evaluate && config.evaluate instanceof Function) {
115
+ return config.evaluate(isValueInValues);
116
+ }
117
+ else {
118
+ return isValueInValues;
119
+ }
120
+ }));
121
+ }
122
+ else {
123
+ //
124
+ return of(true);
125
+ }
126
+ }
127
+ /**
128
+ * Watches a list of fields for individual lists of values returning true when any field contains one
129
+ * of the values being watched for, or optionally running a function on the array of resolved booleans
130
+ * from the listed fields and returning a boolean
131
+ * @param group the form group that has the fields to watch as direct descendants
132
+ * @param config the configuration to use when calling the function
133
+ */
134
+ function checkControlsForValues(group, config) {
135
+ // if no config is passed we just want to show the field, so we return an observable of true
136
+ if (!config || !config.watchConfigs) {
137
+ return of(true);
138
+ }
139
+ // we run checkControlForValues on every control in the list of WatchConfigs creating
140
+ // an array of Observable watching fields for values
141
+ const fieldTriggers = config.watchConfigs.map(watchConfig => {
142
+ // resolves a boolean, true when field value matches a watched value, otherwise false
143
+ return checkControlForValues(group, watchConfig);
144
+ });
145
+ return combineLatest(fieldTriggers).pipe(startWith([true]), map((booleans) => {
146
+ // if the user passed an evaluate function use it
147
+ if (config.evaluate && config.evaluate instanceof Function) {
148
+ return config.evaluate(booleans);
149
+ }
150
+ else { // otherwise we return true if any of the watched fields resolve to true
151
+ return booleans.some(bool => bool);
152
+ }
153
+ }));
154
+ }
155
+ /**
156
+ * Watches values on an array of fields, computing their values as they change
157
+ * @param group the group to get the fields from, for now it can only be the parent of the computed field
158
+ * @param computeFieldsConfig the configuration that drives the computation, holds the names to watch and the
159
+ * computation function that get called against the array of values
160
+ */
161
+ function computeValueFromFields(group, computeFieldsConfig) {
162
+ // TODO: better checking
163
+ const { controlNamesToWatch } = computeFieldsConfig;
164
+ //creates an observable listener for each control in the controlNamesToWatch array
165
+ return combineLatest(controlNamesToWatch.map(controlNameToWatch => getValueChanges(group, controlNameToWatch))).pipe(
166
+ // each time a watched field values changes a new array of the latest field values is pipe through to the
167
+ // compute callback. Which runs the users logic on the values to compute this fields value
168
+ map(valuesArray => computeFieldsConfig.computeCallback(valuesArray)));
169
+ }
170
+ /**
171
+ * A simple wrapper for doing error checking around getting the valueChanges observable from a control on a form group
172
+ * @param group the form group we want to pull the observable from
173
+ * @param controlName the name of the control who's value we want to subscribe to
174
+ */
175
+ function getValueChanges(group, controlName) {
176
+ const control = group.get(controlName);
177
+ if (!control) {
178
+ throw new Error(`No control with controlName ${controlName}`);
179
+ }
180
+ return control.valueChanges;
181
+ }
182
+ /**
183
+ * TODO: move to utils library after library is built
184
+ * Allows developer to pass an array of operators into the pipe of an Observable.
185
+ * Useful for creating function with a variable amount of operators to be run
186
+ * @param observable the observable to pass the operators to
187
+ * @param operators array of operators to pipe
188
+ */
189
+ function pipeOperatorsIntoObservable(observable, operators) {
190
+ try {
191
+ return operators.reduce((obs, op) => {
192
+ return obs.pipe(op);
193
+ }, observable);
194
+ }
195
+ catch (_a) {
196
+ console.error('Unable to pipe operators into observable');
197
+ return of(null);
198
+ }
199
+ }
200
+ function callOptionsIfFunction(options, parentGroup, searchString) {
201
+ return options instanceof Function ? options(parentGroup, searchString) : options;
202
+ }
203
+ /**
204
+ * The user can give us select options as an array, a function that resolves to a promise,
205
+ * or an observable. This functions consumes any of those and returns an observable that
206
+ * resolves an array of options
207
+ *
208
+ * @param options the options passed in from the config
209
+ * @param emptyMessageOption the message to display when the array is empty
210
+ */
211
+ function observablifyOptions(options, parentGroup, searchString) {
212
+ const calledOptions = callOptionsIfFunction(options, parentGroup, searchString);
213
+ // if options are a promise
214
+ return calledOptions instanceof Promise
215
+ // convert to observable
216
+ ? from(calledOptions)
217
+ // if array that isn't empty
218
+ : Array.isArray(calledOptions) && calledOptions.length
219
+ // convert to observable
220
+ ? of(calledOptions)
221
+ // if observable
222
+ : isObservable(calledOptions)
223
+ // return it
224
+ ? calledOptions
225
+ // else an empty array
226
+ : of([]);
227
+ }
228
+ /**
229
+ * Determines if the field config is for a form control (not a divider, heading or other non-control field)
230
+ * */
231
+ function isControlConfig(fieldConfig) {
232
+ return 'controlName' in fieldConfig;
233
+ }
234
+ /**
235
+ * builds out form group based on config
236
+ * @param config a configuration for a form group
237
+ * @param value an object of initial values to pass in
238
+ * @param group the form group to modify and build out
239
+ */
240
+ function buildFormGroupFromConfig(config, value = null, group = new FormGroup({})) {
241
+ config.fields.forEach((controlConfig) => {
242
+ var _a;
243
+ if (isControlConfig(controlConfig)) {
244
+ // then add a control to the group using the controlName from configuration
245
+ const { controlName } = controlConfig;
246
+ // if there's a value object and it has a non-null/undefined value for this field use it.
247
+ // Otherwise, default to null
248
+ const controlValue = (_a = (value && value[controlName])) !== null && _a !== void 0 ? _a : null;
249
+ group.addControl(controlName, createControlForType(controlConfig, controlValue));
250
+ }
251
+ });
252
+ group.setValidators(config.validators);
253
+ return group;
254
+ }
255
+ /**
256
+ * Analyze the config and build a form control to spec. Notice we don't use FormBuilder here
257
+ * as we want to keep this function pure.
258
+ * @param controlConfig the configuration object for the control to build
259
+ * @param value an initial value to use if passed in
260
+ */
261
+ function createControlForType(controlConfig, value = null) {
262
+ // build form control out based on the control type
263
+ const control = controlConfig.controlType === ControlType.SUB_GROUP
264
+ ? buildFormGroupFromConfig(controlConfig, value)
265
+ : controlConfig.controlType === ControlType.GROUP_LIST
266
+ ? new FormArray([], controlConfig.validators)
267
+ : new FormControl(value || null, controlConfig.validators);
268
+ return control;
269
+ }
270
+ /**
271
+ * A basic filter function that filters the search string against the label of the options object
272
+ * @param options the array of options to filter
273
+ * @param searchString the string from the input
274
+ */
275
+ function filterOptionsByLabel(options, searchString) {
276
+ return options.filter(option => {
277
+ return option.label && option.label.toLowerCase().includes(searchString.toLowerCase());
278
+ });
279
+ }
280
+
281
+ function crisprControlMixin(BaseClass) {
282
+ return class extends BaseClass {
283
+ set value(value) {
284
+ this.setControlValue(value);
285
+ this._value = value;
286
+ }
287
+ get value() {
288
+ return this._value;
289
+ }
290
+ ngOnInit() {
291
+ super.ngOnInit();
292
+ this.control = this.group.get(this.config.controlName);
293
+ this.setControlValue(this.value);
294
+ // setTimeouts are ugly but this seems to be the only way to get the computed field to compute initial values
295
+ setTimeout(() => {
296
+ this.control.updateValueAndValidity();
297
+ });
298
+ }
299
+ setControlValue(value) {
300
+ if (value && this.control && this.config.controlType !== ControlType.SUB_GROUP) {
301
+ this.control.setValue(value);
302
+ }
303
+ }
304
+ };
305
+ }
306
+
307
+ // eslint-disable-next-line @angular-eslint/directive-class-suffix
308
+ class CrisprFieldComponent {
309
+ ngOnInit() {
310
+ this.applyDefaultConfig();
311
+ }
312
+ applyDefaultConfig() {
313
+ this.config = this.defaultConfig ? Object.assign(Object.assign({}, this.defaultConfig), this.config) : this.config;
314
+ }
315
+ }
316
+ CrisprFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
317
+ CrisprFieldComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.1", type: CrisprFieldComponent, ngImport: i0 });
318
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFieldComponent, decorators: [{
319
+ type: Directive
320
+ }] });
321
+
322
+ const AbstractAutocompleteFieldMixin = crisprControlMixin(CrisprFieldComponent);
323
+ // eslint-disable-next-line @angular-eslint/directive-class-suffix
324
+ class AbstractAutocompleteComponent extends AbstractAutocompleteFieldMixin {
325
+ constructor() {
326
+ super(...arguments);
327
+ // we need a separate control for the UI because of the way the material autocomplete chiplist works
328
+ this.autocompleteInputControl = new FormControl('');
329
+ }
330
+ ngOnInit() {
331
+ super.ngOnInit();
332
+ this.group.addControl(this.config.controlName, new FormControl());
333
+ // filter options by the search string using either the default filter function or one passed in through config
334
+ this.options$ = this.autocompleteInputControl.valueChanges.pipe(
335
+ // this is needed to have the options panel to open on focus
336
+ startWith(''), debounceTime(this.config.typeDebounceTime), distinctUntilChanged(), map(searchText => searchText || ''), switchMap((searchText) => observablifyOptions(this.config.options, this.group, searchText)));
337
+ }
338
+ }
339
+ AbstractAutocompleteComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: AbstractAutocompleteComponent, deps: null, target: i0.ɵɵFactoryTarget.Directive });
340
+ AbstractAutocompleteComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.1", type: AbstractAutocompleteComponent, usesInheritance: true, ngImport: i0 });
341
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: AbstractAutocompleteComponent, decorators: [{
342
+ type: Directive
343
+ }] });
344
+
345
+ class InfoComponent {
346
+ }
347
+ InfoComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: InfoComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
348
+ InfoComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: InfoComponent, selector: "crispr-info", inputs: { info: "info" }, ngImport: i0, template: "<mat-icon\n *ngIf=\"info\"\n [matTooltip]=\"info.content\"\n [matTooltipPosition]=\"info.tooltipPosition || 'below'\"\n matSuffix>\n info\n</mat-icon>\n", styles: ["mat-icon{font-size:1.2em;width:1em;height:1em;opacity:.8}\n"], components: [{ type: i4.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
349
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: InfoComponent, decorators: [{
350
+ type: Component,
351
+ args: [{ selector: 'crispr-info', changeDetection: ChangeDetectionStrategy.OnPush, template: "<mat-icon\n *ngIf=\"info\"\n [matTooltip]=\"info.content\"\n [matTooltipPosition]=\"info.tooltipPosition || 'below'\"\n matSuffix>\n info\n</mat-icon>\n", styles: ["mat-icon{font-size:1.2em;width:1em;height:1em;opacity:.8}\n"] }]
352
+ }], propDecorators: { info: [{
353
+ type: Input
354
+ }] } });
355
+ class InfoModule {
356
+ }
357
+ InfoModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: InfoModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
358
+ InfoModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: InfoModule, declarations: [InfoComponent], imports: [CommonModule,
359
+ MatIconModule,
360
+ MatTooltipModule], exports: [InfoComponent] });
361
+ InfoModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: InfoModule, imports: [[
362
+ CommonModule,
363
+ MatIconModule,
364
+ MatTooltipModule
365
+ ]] });
366
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: InfoModule, decorators: [{
367
+ type: NgModule,
368
+ args: [{
369
+ imports: [
370
+ CommonModule,
371
+ MatIconModule,
372
+ MatTooltipModule
373
+ ],
374
+ exports: [
375
+ InfoComponent
376
+ ],
377
+ declarations: [
378
+ InfoComponent
379
+ ]
380
+ }]
381
+ }] });
382
+
383
+ const defaultConfig$8 = {
384
+ typographyClass: 'mat-h3'
385
+ };
386
+ class HeadingComponent extends CrisprFieldComponent {
387
+ constructor() {
388
+ super(...arguments);
389
+ this.defaultConfig = defaultConfig$8;
390
+ }
391
+ }
392
+ HeadingComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: HeadingComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
393
+ HeadingComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: HeadingComponent, selector: "crispr-heading", inputs: { config: "config" }, usesInheritance: true, ngImport: i0, template: " <label\n *ngIf=\"!!config?.label\"\n [ngClass]=\"config.typographyClass\">\n {{ config.label }}\n <crispr-info\n *ngIf=\"config.info\"\n matSuffix\n [info]=\"config.info\">\n </crispr-info>\n </label>\n", styles: [":host{display:block}\n"], components: [{ type: InfoComponent, selector: "crispr-info", inputs: ["info"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i2$1.MatSuffix, selector: "[matSuffix]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
394
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: HeadingComponent, decorators: [{
395
+ type: Component,
396
+ args: [{ selector: 'crispr-heading', changeDetection: ChangeDetectionStrategy.OnPush, template: " <label\n *ngIf=\"!!config?.label\"\n [ngClass]=\"config.typographyClass\">\n {{ config.label }}\n <crispr-info\n *ngIf=\"config.info\"\n matSuffix\n [info]=\"config.info\">\n </crispr-info>\n </label>\n", styles: [":host{display:block}\n"] }]
397
+ }], propDecorators: { config: [{
398
+ type: Input
399
+ }] } });
400
+ class HeadingModule {
401
+ }
402
+ HeadingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: HeadingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
403
+ HeadingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: HeadingModule, declarations: [HeadingComponent], imports: [CommonModule,
404
+ MatFormFieldModule,
405
+ InfoModule], exports: [HeadingComponent] });
406
+ HeadingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: HeadingModule, imports: [[
407
+ CommonModule,
408
+ MatFormFieldModule,
409
+ InfoModule
410
+ ]] });
411
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: HeadingModule, decorators: [{
412
+ type: NgModule,
413
+ args: [{
414
+ imports: [
415
+ CommonModule,
416
+ MatFormFieldModule,
417
+ InfoModule
418
+ ],
419
+ exports: [
420
+ HeadingComponent
421
+ ],
422
+ declarations: [
423
+ HeadingComponent
424
+ ]
425
+ }]
426
+ }] });
427
+
428
+ class FieldContainerComponent {
429
+ constructor() {
430
+ // boolean whether field-container is inline
431
+ this.inlineField = false;
432
+ this.subs = [];
433
+ }
434
+ ngOnInit() {
435
+ this.disabled$ = this.connectDisabledCallback(this.group, this.config);
436
+ // we tried moving this into afterViewChecked and afterContentChecked lifecycle hooks without any luck
437
+ if (this.config.computeValue) {
438
+ this.subs.push(this.config.computeValue(this.group).pipe(distinctUntilChanged(), tap(computedValue => this.group.get(this.config.controlName).setValue(computedValue))).subscribe());
439
+ }
440
+ else if (this.config.computeFieldConfig) {
441
+ console.warn(`computeFieldConfig property is deprecated, please use computeValue. Example here: https://stackblitz.com/github/nayfin/tft-documentation?file=src%2Fapp%2Fcrispr-forms-demo%2Ffeatures%2Fcomputed-field%2Fcomputed-field.component.ts`);
442
+ this.subs.push(computeValueFromFields(this.group, this.config.computeFieldConfig).pipe(distinctUntilChanged(), tap(computedValue => this.group.get(this.config.controlName).setValue(computedValue))).subscribe());
443
+ }
444
+ }
445
+ ngOnDestroy() {
446
+ this.subs.forEach(sub => sub.unsubscribe);
447
+ }
448
+ /**
449
+ * Connects user defined disabledCallback function to the the view, so that the control is enabled/disabled
450
+ * appropriately. It also keeps the form will hide disabled fields in the UI unless `hideDisabled` is set to
451
+ * false in the controls config
452
+ * @param group used to get valueChanges from control
453
+ * @param config configuration object used to
454
+ */
455
+ connectDisabledCallback(group, config = null) {
456
+ const control = group.get(config.controlName);
457
+ // If the disabled$ function exists on the field config then call it with the disabledCallbackConfig
458
+ // as a parameter otherwise return an observable of true.
459
+ return (config === null || config === void 0 ? void 0 : config.disabledCallback) && config.disabledCallback instanceof Function
460
+ ? config.disabledCallback(group, config.disabledCallbackConfig || null).pipe(
461
+ // This enables/disables when callback conditions are met
462
+ tap((shouldDisable) => shouldDisable ? control.disable() : control.enable()))
463
+ : of(false);
464
+ }
465
+ }
466
+ FieldContainerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FieldContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
467
+ FieldContainerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: FieldContainerComponent, selector: "crispr-field-container", inputs: { config: "config", group: "group", inlineField: "inlineField" }, ngImport: i0, template: "<div\n *ngIf=\"(disabled$ | async) ? !config.hideDisabled : true\"\n [ngClass]=\"config.classes\"\n [class.inline-field]=\"inlineField\"\n class=\"field-container\">\n\n <crispr-heading\n *ngIf=\"config.heading\"\n [config]=\"config.heading\">\n </crispr-heading>\n\n <ng-content>\n </ng-content>\n\n</div>\n", styles: ["::ng-deep mat-form-field.mat-form-field{display:block}.inline-field{display:inline-block}\n"], components: [{ type: HeadingComponent, selector: "crispr-heading", inputs: ["config"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], pipes: { "async": i2.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
468
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FieldContainerComponent, decorators: [{
469
+ type: Component,
470
+ args: [{ selector: 'crispr-field-container', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n *ngIf=\"(disabled$ | async) ? !config.hideDisabled : true\"\n [ngClass]=\"config.classes\"\n [class.inline-field]=\"inlineField\"\n class=\"field-container\">\n\n <crispr-heading\n *ngIf=\"config.heading\"\n [config]=\"config.heading\">\n </crispr-heading>\n\n <ng-content>\n </ng-content>\n\n</div>\n", styles: ["::ng-deep mat-form-field.mat-form-field{display:block}.inline-field{display:inline-block}\n"] }]
471
+ }], propDecorators: { config: [{
472
+ type: Input
473
+ }], group: [{
474
+ type: Input
475
+ }], inlineField: [{
476
+ type: Input
477
+ }] } });
478
+ class FieldContainerModule {
479
+ }
480
+ FieldContainerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FieldContainerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
481
+ FieldContainerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FieldContainerModule, declarations: [FieldContainerComponent], imports: [CommonModule,
482
+ HeadingModule], exports: [FieldContainerComponent] });
483
+ FieldContainerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FieldContainerModule, imports: [[
484
+ CommonModule,
485
+ HeadingModule,
486
+ ]] });
487
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FieldContainerModule, decorators: [{
488
+ type: NgModule,
489
+ args: [{
490
+ imports: [
491
+ CommonModule,
492
+ HeadingModule,
493
+ ],
494
+ exports: [
495
+ FieldContainerComponent
496
+ ],
497
+ declarations: [
498
+ FieldContainerComponent
499
+ ]
500
+ }]
501
+ }] });
502
+
503
+ const InputFieldMixin = crisprControlMixin(CrisprFieldComponent);
504
+ class InputFieldComponent extends InputFieldMixin {
505
+ constructor() {
506
+ super();
507
+ this.defaultConfig = { inputType: 'text' };
508
+ }
509
+ ngOnInit() {
510
+ super.ngOnInit();
511
+ }
512
+ }
513
+ InputFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: InputFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
514
+ InputFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: InputFieldComponent, selector: "crispr-input-field", usesInheritance: true, ngImport: i0, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n <mat-form-field\n [color]=\"config.color\"\n [appearance]=\"config.appearance\"\n [formGroup]=\"group\">\n <mat-label>\n {{config.label}}\n </mat-label>\n <input\n [type]=\"config.inputType\"\n matInput\n [placeholder]=\"config.placeholder\"\n [formControlName]=\"config.controlName\"\n [min]=\"config.min\"\n [max]=\"config.max\"\n [maxlength]=\"config.maxLength\"\n [step]=\"config.step\"\n [autofocus]=\"config.autofocus\"\n [pattern]=\"config.pattern\"\n [spellcheck]=\"config.spellcheck\"\n [autocomplete]=\"config.autoComplete\"\n [autocapitalize]=\"config.autoCapitalize\">\n <span *ngIf=\"config.fieldSuffix\" matSuffix>{{config.fieldSuffix}}</span>\n <crispr-info\n matSuffix\n *ngIf=\"config.info\"\n [info]=\"config.info\">\n </crispr-info>\n\n </mat-form-field>\n\n\n</crispr-field-container>\n", styles: [""], components: [{ type: FieldContainerComponent, selector: "crispr-field-container", inputs: ["config", "group", "inlineField"] }, { type: i2$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: InfoComponent, selector: "crispr-info", inputs: ["info"] }], directives: [{ type: i4$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.ControlErrorContainerDirective, selector: "[controlErrorContainer], [formGroup]" }, { type: i2$1.MatLabel, selector: "mat-label" }, { type: i7.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i4$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i4$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i5.ControlErrorsDirective, selector: "[formControl], [formControlName]" }, { type: i4$1.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { type: i4$1.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$1.MatSuffix, selector: "[matSuffix]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
515
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: InputFieldComponent, decorators: [{
516
+ type: Component,
517
+ args: [{ selector: 'crispr-input-field', changeDetection: ChangeDetectionStrategy.OnPush, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n <mat-form-field\n [color]=\"config.color\"\n [appearance]=\"config.appearance\"\n [formGroup]=\"group\">\n <mat-label>\n {{config.label}}\n </mat-label>\n <input\n [type]=\"config.inputType\"\n matInput\n [placeholder]=\"config.placeholder\"\n [formControlName]=\"config.controlName\"\n [min]=\"config.min\"\n [max]=\"config.max\"\n [maxlength]=\"config.maxLength\"\n [step]=\"config.step\"\n [autofocus]=\"config.autofocus\"\n [pattern]=\"config.pattern\"\n [spellcheck]=\"config.spellcheck\"\n [autocomplete]=\"config.autoComplete\"\n [autocapitalize]=\"config.autoCapitalize\">\n <span *ngIf=\"config.fieldSuffix\" matSuffix>{{config.fieldSuffix}}</span>\n <crispr-info\n matSuffix\n *ngIf=\"config.info\"\n [info]=\"config.info\">\n </crispr-info>\n\n </mat-form-field>\n\n\n</crispr-field-container>\n", styles: [""] }]
518
+ }], ctorParameters: function () { return []; } });
519
+
520
+ class OptionComponent {
521
+ }
522
+ OptionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: OptionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
523
+ OptionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: OptionComponent, selector: "crispr-option", inputs: { option: "option" }, ngImport: i0, template: "<img\n *ngIf=\"option.imageUrl\"\n [src]=\"option.imageUrl\"\n alt=\"image of {{option.label}}\"\n style=\"vertical-align:middle;\"\n aria-hidden\n height=\"25\"/>\n{{ option.label }}\n", styles: [""], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
524
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: OptionComponent, decorators: [{
525
+ type: Component,
526
+ args: [{ selector: 'crispr-option', changeDetection: ChangeDetectionStrategy.OnPush, template: "<img\n *ngIf=\"option.imageUrl\"\n [src]=\"option.imageUrl\"\n alt=\"image of {{option.label}}\"\n style=\"vertical-align:middle;\"\n aria-hidden\n height=\"25\"/>\n{{ option.label }}\n", styles: [""] }]
527
+ }], propDecorators: { option: [{
528
+ type: Input
529
+ }] } });
530
+
531
+ const SelectFieldMixin = crisprControlMixin(CrisprFieldComponent);
532
+ class SelectFieldComponent extends SelectFieldMixin {
533
+ constructor() {
534
+ super(...arguments);
535
+ this.defaultConfig = {
536
+ enableToggleAll: false,
537
+ color: 'primary'
538
+ };
539
+ this.allSelected = false;
540
+ }
541
+ ngOnInit() {
542
+ super.ngOnInit();
543
+ // options$ can be passed as an array, promise that resolves array, or observable that resolves array
544
+ // this functions accounts for all possibilities and converts to observable that resolves array
545
+ this.options$ = observablifyOptions(this.config.options, this.group);
546
+ }
547
+ ngAfterViewInit() {
548
+ var _a, _b;
549
+ if (this.config.multiple
550
+ && this.config.enableToggleAll
551
+ && ((_a = this.selectField.options) === null || _a === void 0 ? void 0 : _a.length) === ((_b = this.value) === null || _b === void 0 ? void 0 : _b.length)) {
552
+ this.allSelected = true;
553
+ }
554
+ }
555
+ toggleAll(isSelected) {
556
+ if (isSelected) {
557
+ this.selectField.options.forEach(option => option.deselect());
558
+ }
559
+ else {
560
+ this.selectField.options.forEach(option => option.select());
561
+ }
562
+ this.allSelected = !this.allSelected;
563
+ }
564
+ }
565
+ SelectFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: SelectFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
566
+ SelectFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: SelectFieldComponent, selector: "crispr-select-field", viewQueries: [{ propertyName: "selectField", first: true, predicate: ["selectField"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n\n <mat-form-field\n [color]=\"config.color\"\n [appearance]=\"config.appearance\"\n [formGroup]=\"group\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n <mat-select\n #selectField\n [formControlName]=\"config.controlName\"\n [placeholder]=\"config.placeholder\"\n [multiple]=\"config.multiple\">\n\n <mat-checkbox\n [color]=\"config.color\"\n [checked]=\"allSelected\"\n *ngIf=\"config?.multiple && config.enableToggleAll\"\n (click)=\"toggleAll(allSelected)\">\n Select All\n </mat-checkbox>\n <mat-option\n *ngFor=\"let option of options$ | async\"\n [value]=\"option.value\">\n <crispr-option [option]=\"option\">\n </crispr-option>\n </mat-option>\n\n </mat-select>\n\n <span *ngIf=\"config.fieldSuffix\" matSuffix>{{config.fieldSuffix}}</span>\n <crispr-info\n *ngIf=\"config.info\"\n matSuffix\n [info]=\"config.info\">\n </crispr-info>\n </mat-form-field>\n\n</crispr-field-container>\n", styles: ["mat-checkbox{display:block;padding:16px}\n"], components: [{ type: FieldContainerComponent, selector: "crispr-field-container", inputs: ["config", "group", "inlineField"] }, { type: i2$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i3$1.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i4$2.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex", "aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { type: i5$1.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: OptionComponent, selector: "crispr-option", inputs: ["option"] }, { type: InfoComponent, selector: "crispr-info", inputs: ["info"] }], directives: [{ type: i4$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.ControlErrorContainerDirective, selector: "[controlErrorContainer], [formGroup]" }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$1.MatLabel, selector: "mat-label" }, { type: i4$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i5.ControlErrorsDirective, selector: "[formControl], [formControlName]" }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2$1.MatSuffix, selector: "[matSuffix]" }], pipes: { "async": i2.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
567
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: SelectFieldComponent, decorators: [{
568
+ type: Component,
569
+ args: [{ selector: 'crispr-select-field', changeDetection: ChangeDetectionStrategy.OnPush, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n\n <mat-form-field\n [color]=\"config.color\"\n [appearance]=\"config.appearance\"\n [formGroup]=\"group\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n <mat-select\n #selectField\n [formControlName]=\"config.controlName\"\n [placeholder]=\"config.placeholder\"\n [multiple]=\"config.multiple\">\n\n <mat-checkbox\n [color]=\"config.color\"\n [checked]=\"allSelected\"\n *ngIf=\"config?.multiple && config.enableToggleAll\"\n (click)=\"toggleAll(allSelected)\">\n Select All\n </mat-checkbox>\n <mat-option\n *ngFor=\"let option of options$ | async\"\n [value]=\"option.value\">\n <crispr-option [option]=\"option\">\n </crispr-option>\n </mat-option>\n\n </mat-select>\n\n <span *ngIf=\"config.fieldSuffix\" matSuffix>{{config.fieldSuffix}}</span>\n <crispr-info\n *ngIf=\"config.info\"\n matSuffix\n [info]=\"config.info\">\n </crispr-info>\n </mat-form-field>\n\n</crispr-field-container>\n", styles: ["mat-checkbox{display:block;padding:16px}\n"] }]
570
+ }], propDecorators: { selectField: [{
571
+ type: ViewChild,
572
+ args: ['selectField']
573
+ }] } });
574
+
575
+ const defaultConfig$7 = {
576
+ autoActiveFirstOption: true,
577
+ typeDebounceTime: 500,
578
+ emptyOptionsMessage: DEFAULT_EMPTY_OPTIONS_MESSAGE
579
+ };
580
+ class AutocompleteFieldComponent extends AbstractAutocompleteComponent {
581
+ constructor() {
582
+ super(...arguments);
583
+ this.defaultConfig = defaultConfig$7;
584
+ }
585
+ ngOnInit() {
586
+ super.ngOnInit();
587
+ }
588
+ setControlValue(value) {
589
+ if (this.control && value) {
590
+ // sets the initial value on the control if one is passed
591
+ this.control.setValue(value.value || '');
592
+ this.autocompleteInputControl.setValue(value.label || '');
593
+ }
594
+ }
595
+ /**
596
+ * The material autocomplete defaults to displaying the options value instead of its label.
597
+ * We only have the value from the selected option to work with, so we have to pass the options
598
+ * through a function called in the template and return the function that the material displayWith
599
+ * input is expecting.
600
+ * @param options the array of options to search for option with corresponding value
601
+ */
602
+ displayLabel(options) {
603
+ if (this.config.displayWith) {
604
+ return this.config.displayWith(options);
605
+ }
606
+ return (value) => {
607
+ var _a;
608
+ const label = !!options && Array.isArray(options)
609
+ ? (_a = options.find((option) => JSON.stringify(option.value) === JSON.stringify(value))) === null || _a === void 0 ? void 0 : _a.label : value;
610
+ return label;
611
+ };
612
+ }
613
+ handleSelect(event) {
614
+ this.control.setValue(event.option.value);
615
+ this.autoInputRef.nativeElement.blur();
616
+ }
617
+ }
618
+ AutocompleteFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: AutocompleteFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
619
+ AutocompleteFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: AutocompleteFieldComponent, selector: "crispr-autocomplete-field", viewQueries: [{ propertyName: "autoInput", first: true, predicate: ["autoInput"], descendants: true, read: MatAutocompleteTrigger }, { propertyName: "autoInputRef", first: true, predicate: ["autoInput"], descendants: true }], usesInheritance: true, ngImport: i0, template: "\n<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n\n <mat-form-field\n [color]=\"config.color\"\n [appearance]=\"config.appearance\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n <input\n matInput\n [formControl]=\"autocompleteInputControl\"\n [placeholder]=\"config.placeholder\"\n [matAutocomplete]=\"auto\"\n role=\"textbox\"\n type=\"textbox\"\n autocapitalize=\"off\"\n autocorrect=\"off\"\n spellcheck=\"false\"\n #autoInput>\n\n <span *ngIf=\"config.fieldSuffix\" matSuffix>{{config.fieldSuffix}}</span>\n <crispr-info\n *ngIf=\"config.info\"\n matSuffix\n [info]=\"config.info \">\n </crispr-info>\n\n <mat-autocomplete\n #auto=\"matAutocomplete\"\n [autoActiveFirstOption]=\"config.autoActiveFirstOption\"\n (optionSelected)=\"handleSelect($event)\"\n [displayWith]=\"displayLabel(options$ | async)\">\n\n <ng-container *ngIf=\"options$ | async as options; else emptyOption\">\n <ng-container *ngIf=\"options.length > 0; else emptyOption\">\n <mat-option\n *ngFor=\"let option of options$ | async\"\n [value]=\"option.value\">\n <crispr-option [option]=\"option\"></crispr-option>\n </mat-option>\n </ng-container>\n\n </ng-container>\n <ng-template #emptyOption>\n <mat-option disabled=\"true\">\n {{config.emptyOptionsMessage}}\n </mat-option>\n </ng-template>\n\n </mat-autocomplete>\n </mat-form-field>\n</crispr-field-container>\n", styles: [""], components: [{ type: FieldContainerComponent, selector: "crispr-field-container", inputs: ["config", "group", "inlineField"] }, { type: i2$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: InfoComponent, selector: "crispr-info", inputs: ["info"] }, { type: i4$3.MatAutocomplete, selector: "mat-autocomplete", inputs: ["disableRipple"], exportAs: ["matAutocomplete"] }, { type: i5$1.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: OptionComponent, selector: "crispr-option", inputs: ["option"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$1.MatLabel, selector: "mat-label" }, { type: i7.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i4$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i4$3.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", exportAs: ["matAutocompleteTrigger"] }, { type: i4$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i5.ControlErrorsDirective, selector: "[formControl], [formControlName]" }, { type: i2$1.MatSuffix, selector: "[matSuffix]" }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i2.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
620
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: AutocompleteFieldComponent, decorators: [{
621
+ type: Component,
622
+ args: [{ selector: 'crispr-autocomplete-field', changeDetection: ChangeDetectionStrategy.OnPush, template: "\n<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n\n <mat-form-field\n [color]=\"config.color\"\n [appearance]=\"config.appearance\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n <input\n matInput\n [formControl]=\"autocompleteInputControl\"\n [placeholder]=\"config.placeholder\"\n [matAutocomplete]=\"auto\"\n role=\"textbox\"\n type=\"textbox\"\n autocapitalize=\"off\"\n autocorrect=\"off\"\n spellcheck=\"false\"\n #autoInput>\n\n <span *ngIf=\"config.fieldSuffix\" matSuffix>{{config.fieldSuffix}}</span>\n <crispr-info\n *ngIf=\"config.info\"\n matSuffix\n [info]=\"config.info \">\n </crispr-info>\n\n <mat-autocomplete\n #auto=\"matAutocomplete\"\n [autoActiveFirstOption]=\"config.autoActiveFirstOption\"\n (optionSelected)=\"handleSelect($event)\"\n [displayWith]=\"displayLabel(options$ | async)\">\n\n <ng-container *ngIf=\"options$ | async as options; else emptyOption\">\n <ng-container *ngIf=\"options.length > 0; else emptyOption\">\n <mat-option\n *ngFor=\"let option of options$ | async\"\n [value]=\"option.value\">\n <crispr-option [option]=\"option\"></crispr-option>\n </mat-option>\n </ng-container>\n\n </ng-container>\n <ng-template #emptyOption>\n <mat-option disabled=\"true\">\n {{config.emptyOptionsMessage}}\n </mat-option>\n </ng-template>\n\n </mat-autocomplete>\n </mat-form-field>\n</crispr-field-container>\n", styles: [""] }]
623
+ }], propDecorators: { autoInput: [{
624
+ type: ViewChild,
625
+ args: ['autoInput', { read: MatAutocompleteTrigger }]
626
+ }], autoInputRef: [{
627
+ type: ViewChild,
628
+ args: ['autoInput']
629
+ }] } });
630
+
631
+ const defaultConfig$6 = {
632
+ chipsSelectable: true,
633
+ areChipsRemovable: true,
634
+ tabToSelect: true,
635
+ autoActiveFirstOption: true,
636
+ imageUrlParam: 'image',
637
+ typeDebounceTime: 500,
638
+ allowDuplicates: false,
639
+ duplicateCompareFunction: (chip, option) => chip.value === option.value,
640
+ separatorKeyCodes: [ENTER],
641
+ emptyOptionsMessage: DEFAULT_EMPTY_OPTIONS_MESSAGE,
642
+ };
643
+ class AutocompleteChiplistFieldComponent extends AbstractAutocompleteComponent {
644
+ constructor() {
645
+ super(...arguments);
646
+ this.defaultConfig = defaultConfig$6;
647
+ this.chips$ = new BehaviorSubject([]);
648
+ this.controlValue$ = this.chips$.pipe(tap(chips => {
649
+ this.control.setValue(chips.map(chip => chip.value));
650
+ }));
651
+ }
652
+ ngOnInit() {
653
+ super.ngOnInit();
654
+ this.remainingOptions$ = combineLatest([
655
+ this.chips$,
656
+ this.options$
657
+ ]).pipe(map(([chips, options]) => {
658
+ return this.config.allowDuplicates
659
+ ? options
660
+ : options === null || options === void 0 ? void 0 : options.filter(option => {
661
+ return !chips.some(chip => this.config.duplicateCompareFunction(chip, option));
662
+ });
663
+ }));
664
+ }
665
+ setControlValue(value) {
666
+ if (value) {
667
+ this.chips$.next(value);
668
+ }
669
+ }
670
+ // handles mat selecting
671
+ handleSelect(event) {
672
+ const selectedOption = event.option.value;
673
+ this.chips$.next([...this.chips$.value, selectedOption]);
674
+ this.chipInputRef.nativeElement.value = '';
675
+ this.autocompleteInputControl.setValue('');
676
+ // setTimeout needed because the panel thinks it's still open at this point
677
+ setTimeout(() => this.chipInput.openPanel());
678
+ }
679
+ /**
680
+ * To follow ARIA standards we want to select the active option on blur.
681
+ * matChipInputAddOnBlur should do this but it causes buggy behaviour
682
+ * @param event blur event that triggers the handle blur
683
+ */
684
+ handleTab(_event) {
685
+ if (this.chipInput.activeOption && (this.config.tabToSelect || this.config.addChipOnBlur)) {
686
+ const chip = this.chipInput.activeOption.value;
687
+ this.chips$.next([...this.chips$.value, chip]);
688
+ }
689
+ }
690
+ /**
691
+ * Handles selection via key tokens passed through separatorKeyCodes propert
692
+ * NOTE: If TAB is used focus does not move on to next component
693
+ * @param event
694
+ */
695
+ handleTokenEnd(event) {
696
+ var _a;
697
+ if (this.chipInput.activeOption) {
698
+ this.chipInput.activeOption.select();
699
+ }
700
+ (_a = event.chipInput) === null || _a === void 0 ? void 0 : _a.clear();
701
+ }
702
+ mapToLabel(option) {
703
+ return option ? option.label : '';
704
+ }
705
+ removeChip(removedChip) {
706
+ const remainingChips = this.chips$.value.filter(chip => chip !== removedChip);
707
+ this.chips$.next(remainingChips);
708
+ }
709
+ }
710
+ AutocompleteChiplistFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: AutocompleteChiplistFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
711
+ AutocompleteChiplistFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: AutocompleteChiplistFieldComponent, selector: "crispr-autocomplete-chiplist-field", viewQueries: [{ propertyName: "chipInput", first: true, predicate: ["autoInput"], descendants: true, read: MatAutocompleteTrigger }, { propertyName: "chipInputRef", first: true, predicate: ["autoInput"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n\n <mat-form-field\n [color]=\"config.color\"\n [appearance]=\"config.appearance\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n\n <mat-chip-list\n #chipList>\n <mat-chip\n class=\"refinement-chip\"\n *ngFor=\"let chip of controlValue$ | async\"\n [selectable]=\"config.chipsSelectable\"\n [removable]=\"config.areChipsRemovable\"\n (removed)=\"removeChip(chip)\">\n <span *ngIf=\"chip.imageUrl as imageUrl\" class=\"image-container\">\n <img [src]=\"imageUrl\" alt=\"image of {{chip.label}}\">\n </span>\n {{chip.label}}\n <mat-icon\n matChipRemove\n *ngIf=\"config.areChipsRemovable\">\n cancel\n </mat-icon>\n </mat-chip>\n\n <input\n matInput\n [formControl]=\"autocompleteInputControl\"\n [placeholder]=\"config.placeholder\"\n [matChipInputFor]=\"chipList\"\n [matAutocomplete]=\"auto\"\n (keydown.tab)=\"handleTab($event)\"\n [matChipInputSeparatorKeyCodes]=\"config.separatorKeyCodes\"\n (matChipInputTokenEnd)=\"handleTokenEnd($event)\"\n role=\"searchbox\"\n type=\"text\"\n autocapitalize=\"off\"\n autocorrect=\"off\"\n spellcheck=\"false\"\n #autoInput/>\n <span *ngIf=\"config.fieldSuffix\" matSuffix>{{config.fieldSuffix}}</span>\n <crispr-info\n *ngIf=\"config.info\"\n matSuffix\n [info]=\"config.info \">\n </crispr-info>\n\n </mat-chip-list>\n <mat-autocomplete\n #auto=\"matAutocomplete\"\n [autoActiveFirstOption]=\"this.config.autoActiveFirstOption\"\n (optionSelected)=\"handleSelect($event)\"\n [displayWith]=\"mapToLabel\">\n <ng-container *ngIf=\"remainingOptions$ | async as remainingOptions; else emptyOption\">\n <ng-container *ngIf=\"remainingOptions.length > 0; else emptyOption\">\n <mat-option\n *ngFor=\"let option of remainingOptions$ | async\"\n [value]=\"option\">\n <crispr-option [option]=\"option\"></crispr-option>\n </mat-option>\n </ng-container>\n\n </ng-container>\n <ng-template #emptyOption>\n <mat-option disabled=\"true\">\n {{config.emptyOptionsMessage}}\n </mat-option>\n </ng-template>\n </mat-autocomplete>\n\n\n </mat-form-field>\n</crispr-field-container>\n", styles: [".refinement-chip .image-container{width:26px;height:26px;border-radius:50%;overflow:hidden;margin:-2px 4px -2px -8px}.refinement-chip .image-container img{width:100%;height:100%;object-fit:cover}\n"], components: [{ type: FieldContainerComponent, selector: "crispr-field-container", inputs: ["config", "group", "inlineField"] }, { type: i2$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i3$2.MatChipList, selector: "mat-chip-list", inputs: ["errorStateMatcher", "multiple", "compareWith", "value", "required", "placeholder", "disabled", "aria-orientation", "selectable", "tabIndex"], outputs: ["change", "valueChange"], exportAs: ["matChipList"] }, { type: i4.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: InfoComponent, selector: "crispr-info", inputs: ["info"] }, { type: i4$3.MatAutocomplete, selector: "mat-autocomplete", inputs: ["disableRipple"], exportAs: ["matAutocomplete"] }, { type: i5$1.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: OptionComponent, selector: "crispr-option", inputs: ["option"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$1.MatLabel, selector: "mat-label" }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3$2.MatChip, selector: "mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]", inputs: ["color", "disableRipple", "tabIndex", "selected", "value", "selectable", "disabled", "removable"], outputs: ["selectionChange", "destroyed", "removed"], exportAs: ["matChip"] }, { type: i3$2.MatChipRemove, selector: "[matChipRemove]" }, { type: i7.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i4$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i3$2.MatChipInput, selector: "input[matChipInputFor]", inputs: ["matChipInputFor", "matChipInputAddOnBlur", "matChipInputSeparatorKeyCodes", "placeholder", "id", "disabled"], outputs: ["matChipInputTokenEnd"], exportAs: ["matChipInput", "matChipInputFor"] }, { type: i4$3.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", exportAs: ["matAutocompleteTrigger"] }, { type: i4$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i5.ControlErrorsDirective, selector: "[formControl], [formControlName]" }, { type: i2$1.MatSuffix, selector: "[matSuffix]" }], pipes: { "async": i2.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
712
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: AutocompleteChiplistFieldComponent, decorators: [{
713
+ type: Component,
714
+ args: [{ selector: 'crispr-autocomplete-chiplist-field', changeDetection: ChangeDetectionStrategy.OnPush, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n\n <mat-form-field\n [color]=\"config.color\"\n [appearance]=\"config.appearance\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n\n <mat-chip-list\n #chipList>\n <mat-chip\n class=\"refinement-chip\"\n *ngFor=\"let chip of controlValue$ | async\"\n [selectable]=\"config.chipsSelectable\"\n [removable]=\"config.areChipsRemovable\"\n (removed)=\"removeChip(chip)\">\n <span *ngIf=\"chip.imageUrl as imageUrl\" class=\"image-container\">\n <img [src]=\"imageUrl\" alt=\"image of {{chip.label}}\">\n </span>\n {{chip.label}}\n <mat-icon\n matChipRemove\n *ngIf=\"config.areChipsRemovable\">\n cancel\n </mat-icon>\n </mat-chip>\n\n <input\n matInput\n [formControl]=\"autocompleteInputControl\"\n [placeholder]=\"config.placeholder\"\n [matChipInputFor]=\"chipList\"\n [matAutocomplete]=\"auto\"\n (keydown.tab)=\"handleTab($event)\"\n [matChipInputSeparatorKeyCodes]=\"config.separatorKeyCodes\"\n (matChipInputTokenEnd)=\"handleTokenEnd($event)\"\n role=\"searchbox\"\n type=\"text\"\n autocapitalize=\"off\"\n autocorrect=\"off\"\n spellcheck=\"false\"\n #autoInput/>\n <span *ngIf=\"config.fieldSuffix\" matSuffix>{{config.fieldSuffix}}</span>\n <crispr-info\n *ngIf=\"config.info\"\n matSuffix\n [info]=\"config.info \">\n </crispr-info>\n\n </mat-chip-list>\n <mat-autocomplete\n #auto=\"matAutocomplete\"\n [autoActiveFirstOption]=\"this.config.autoActiveFirstOption\"\n (optionSelected)=\"handleSelect($event)\"\n [displayWith]=\"mapToLabel\">\n <ng-container *ngIf=\"remainingOptions$ | async as remainingOptions; else emptyOption\">\n <ng-container *ngIf=\"remainingOptions.length > 0; else emptyOption\">\n <mat-option\n *ngFor=\"let option of remainingOptions$ | async\"\n [value]=\"option\">\n <crispr-option [option]=\"option\"></crispr-option>\n </mat-option>\n </ng-container>\n\n </ng-container>\n <ng-template #emptyOption>\n <mat-option disabled=\"true\">\n {{config.emptyOptionsMessage}}\n </mat-option>\n </ng-template>\n </mat-autocomplete>\n\n\n </mat-form-field>\n</crispr-field-container>\n", styles: [".refinement-chip .image-container{width:26px;height:26px;border-radius:50%;overflow:hidden;margin:-2px 4px -2px -8px}.refinement-chip .image-container img{width:100%;height:100%;object-fit:cover}\n"] }]
715
+ }], propDecorators: { chipInput: [{
716
+ type: ViewChild,
717
+ args: ['autoInput', { read: MatAutocompleteTrigger }]
718
+ }], chipInputRef: [{
719
+ type: ViewChild,
720
+ args: ['autoInput']
721
+ }] } });
722
+
723
+ const defaultConfig$5 = {
724
+ labelPosition: 'after',
725
+ inline: false
726
+ };
727
+ const CheckboxFieldMixin = crisprControlMixin(CrisprFieldComponent);
728
+ class CheckboxFieldComponent extends CheckboxFieldMixin {
729
+ constructor() {
730
+ super(...arguments);
731
+ this.defaultConfig = defaultConfig$5;
732
+ }
733
+ ngOnInit() {
734
+ super.ngOnInit();
735
+ }
736
+ }
737
+ CheckboxFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CheckboxFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
738
+ CheckboxFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: CheckboxFieldComponent, selector: "crispr-checkbox-field", usesInheritance: true, ngImport: i0, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\"\n [inlineField]=\"config.inline\">\n <div\n [formGroup]=\"group\">\n <mat-checkbox\n [color]=\"config.color\"\n [labelPosition]=\"config.labelPosition\"\n [formControlName]=\"config.controlName\">\n {{config.label}}\n <crispr-info\n matSuffix *ngIf=\"config.info\"\n [info]=\"config.info\">\n </crispr-info>\n </mat-checkbox>\n </div>\n</crispr-field-container>\n", styles: [""], components: [{ type: FieldContainerComponent, selector: "crispr-field-container", inputs: ["config", "group", "inlineField"] }, { type: i4$2.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex", "aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { type: InfoComponent, selector: "crispr-info", inputs: ["info"] }], directives: [{ type: i4$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.ControlErrorContainerDirective, selector: "[controlErrorContainer], [formGroup]" }, { type: i4$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i5.ControlErrorsDirective, selector: "[formControl], [formControlName]" }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$1.MatSuffix, selector: "[matSuffix]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
739
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CheckboxFieldComponent, decorators: [{
740
+ type: Component,
741
+ args: [{ selector: 'crispr-checkbox-field', changeDetection: ChangeDetectionStrategy.OnPush, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\"\n [inlineField]=\"config.inline\">\n <div\n [formGroup]=\"group\">\n <mat-checkbox\n [color]=\"config.color\"\n [labelPosition]=\"config.labelPosition\"\n [formControlName]=\"config.controlName\">\n {{config.label}}\n <crispr-info\n matSuffix *ngIf=\"config.info\"\n [info]=\"config.info\">\n </crispr-info>\n </mat-checkbox>\n </div>\n</crispr-field-container>\n", styles: [""] }]
742
+ }] });
743
+
744
+ const defaultConfig$4 = { rows: 5 };
745
+ const TextareaFieldMixin = crisprControlMixin(CrisprFieldComponent);
746
+ class TextareaFieldComponent extends TextareaFieldMixin {
747
+ constructor() {
748
+ super(...arguments);
749
+ this.defaultConfig = defaultConfig$4;
750
+ }
751
+ ngOnInit() {
752
+ super.ngOnInit();
753
+ }
754
+ }
755
+ TextareaFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: TextareaFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
756
+ TextareaFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: TextareaFieldComponent, selector: "crispr-textarea-field", usesInheritance: true, ngImport: i0, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n <mat-form-field\n [color]=\"config.color\"\n [appearance]=\"config.appearance\"\n [formGroup]=\"group\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n <textarea\n [rows]=\"config.rows\"\n matInput\n [placeholder]=\"config.placeholder\"\n [formControlName]=\"config.controlName\">\n </textarea>\n <span *ngIf=\"config.fieldSuffix\" matSuffix>{{config.fieldSuffix}}</span>\n <crispr-info\n *ngIf=\"config.info\"\n matSuffix\n [info]=\"config.info\">\n </crispr-info>\n </mat-form-field>\n\n</crispr-field-container>\n", styles: [""], components: [{ type: FieldContainerComponent, selector: "crispr-field-container", inputs: ["config", "group", "inlineField"] }, { type: i2$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: InfoComponent, selector: "crispr-info", inputs: ["info"] }], directives: [{ type: i4$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.ControlErrorContainerDirective, selector: "[controlErrorContainer], [formGroup]" }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$1.MatLabel, selector: "mat-label" }, { type: i7.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i4$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i4$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i5.ControlErrorsDirective, selector: "[formControl], [formControlName]" }, { type: i2$1.MatSuffix, selector: "[matSuffix]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
757
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: TextareaFieldComponent, decorators: [{
758
+ type: Component,
759
+ args: [{ selector: 'crispr-textarea-field', changeDetection: ChangeDetectionStrategy.OnPush, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n <mat-form-field\n [color]=\"config.color\"\n [appearance]=\"config.appearance\"\n [formGroup]=\"group\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n <textarea\n [rows]=\"config.rows\"\n matInput\n [placeholder]=\"config.placeholder\"\n [formControlName]=\"config.controlName\">\n </textarea>\n <span *ngIf=\"config.fieldSuffix\" matSuffix>{{config.fieldSuffix}}</span>\n <crispr-info\n *ngIf=\"config.info\"\n matSuffix\n [info]=\"config.info\">\n </crispr-info>\n </mat-form-field>\n\n</crispr-field-container>\n", styles: [""] }]
760
+ }] });
761
+
762
+ const defaultConfig$3 = { displayLimits: true };
763
+ const SliderFieldMixin = crisprControlMixin(CrisprFieldComponent);
764
+ class SliderFieldComponent extends SliderFieldMixin {
765
+ constructor() {
766
+ super();
767
+ this.defaultConfig = defaultConfig$3;
768
+ }
769
+ get flexDirection() {
770
+ return this.config.vertical ? 'column' : 'row';
771
+ }
772
+ ngOnInit() {
773
+ super.ngOnInit();
774
+ }
775
+ }
776
+ SliderFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: SliderFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
777
+ SliderFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: SliderFieldComponent, selector: "crispr-slider-field", usesInheritance: true, ngImport: i0, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n <div\n [formGroup]=\"group\">\n <label *ngIf=\"config.label\">\n {{config.label}}\n <crispr-info\n *ngIf=\"config.info\"\n [info]=\"config.info\">\n </crispr-info>\n </label>\n <div class=\"slider-container\"\n [ngStyle]=\"{'flex-direction': flexDirection}\">\n <span *ngIf=\"config.displayLimits\">\n {{config.min}}\n </span>\n <mat-slider\n class=\"example-margin\"\n [formControlName]=\"config.controlName\"\n [invert]=\"config.invert\"\n [max]=\"config.max\"\n [min]=\"config.min\"\n [step]=\"config.step\"\n [thumbLabel]=\"config.thumbLabel\"\n [tickInterval]=\"config.tickInterval\"\n [vertical]=\"config.vertical\">\n </mat-slider>\n <span *ngIf=\"config.displayLimits\">\n {{config.max}}\n </span>\n </div>\n\n </div>\n</crispr-field-container>\n\n", styles: [".slider-container{display:flex;align-items:center}.slider-container .mat-slider-horizontal{width:100%}\n"], components: [{ type: FieldContainerComponent, selector: "crispr-field-container", inputs: ["config", "group", "inlineField"] }, { type: InfoComponent, selector: "crispr-info", inputs: ["info"] }, { type: i3$3.MatSlider, selector: "mat-slider", inputs: ["disabled", "color", "tabIndex", "invert", "max", "min", "step", "thumbLabel", "tickInterval", "value", "displayWith", "valueText", "vertical"], outputs: ["change", "input", "valueChange"], exportAs: ["matSlider"] }], directives: [{ type: i4$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.ControlErrorContainerDirective, selector: "[controlErrorContainer], [formGroup]" }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i4$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i5.ControlErrorsDirective, selector: "[formControl], [formControlName]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
778
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: SliderFieldComponent, decorators: [{
779
+ type: Component,
780
+ args: [{ selector: 'crispr-slider-field', changeDetection: ChangeDetectionStrategy.OnPush, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n <div\n [formGroup]=\"group\">\n <label *ngIf=\"config.label\">\n {{config.label}}\n <crispr-info\n *ngIf=\"config.info\"\n [info]=\"config.info\">\n </crispr-info>\n </label>\n <div class=\"slider-container\"\n [ngStyle]=\"{'flex-direction': flexDirection}\">\n <span *ngIf=\"config.displayLimits\">\n {{config.min}}\n </span>\n <mat-slider\n class=\"example-margin\"\n [formControlName]=\"config.controlName\"\n [invert]=\"config.invert\"\n [max]=\"config.max\"\n [min]=\"config.min\"\n [step]=\"config.step\"\n [thumbLabel]=\"config.thumbLabel\"\n [tickInterval]=\"config.tickInterval\"\n [vertical]=\"config.vertical\">\n </mat-slider>\n <span *ngIf=\"config.displayLimits\">\n {{config.max}}\n </span>\n </div>\n\n </div>\n</crispr-field-container>\n\n", styles: [".slider-container{display:flex;align-items:center}.slider-container .mat-slider-horizontal{width:100%}\n"] }]
781
+ }], ctorParameters: function () { return []; } });
782
+
783
+ class ButtonComponent extends CrisprFieldComponent {
784
+ constructor() {
785
+ super(...arguments);
786
+ this.defaultConfig = { buttonType: 'raised', type: 'submit' };
787
+ }
788
+ get matButtonClass() {
789
+ return this.config.buttonType ? `mat-${this.config.buttonType}-button` : '';
790
+ }
791
+ ngOnInit() {
792
+ super.ngOnInit();
793
+ this.formValid$ = this.group.statusChanges.pipe(map(status => status === 'VALID'), startWith(this.group.valid));
794
+ }
795
+ handleClick(group, event) {
796
+ if (this.config.callback) {
797
+ this.config.callback(group, event);
798
+ }
799
+ }
800
+ }
801
+ ButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: ButtonComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
802
+ ButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: ButtonComponent, selector: "crispr-button", usesInheritance: true, ngImport: i0, template: "<button\n [formGroup]=\"group\"\n mat-button\n [ngClass]=\"matButtonClass\"\n [color]=\"config.color\"\n [disabled]=\"config.disabledOnInvalidForm && !(formValid$ | async)\"\n [type]=\"config.type\"\n (click)=\"handleClick(group, $event)\"\n [matTooltip]=\"config.info?.content\"\n [matTooltipPosition]=\"config.info?.tooltipPosition || 'below'\">\n {{ config.label }}\n <mat-icon *ngIf=\"config.icon\">\n {{ config.icon}}\n </mat-icon>\n</button>\n\n", styles: [""], components: [{ type: i1.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i4$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.ControlErrorContainerDirective, selector: "[controlErrorContainer], [formGroup]" }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i2.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
803
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: ButtonComponent, decorators: [{
804
+ type: Component,
805
+ args: [{ selector: 'crispr-button', changeDetection: ChangeDetectionStrategy.OnPush, template: "<button\n [formGroup]=\"group\"\n mat-button\n [ngClass]=\"matButtonClass\"\n [color]=\"config.color\"\n [disabled]=\"config.disabledOnInvalidForm && !(formValid$ | async)\"\n [type]=\"config.type\"\n (click)=\"handleClick(group, $event)\"\n [matTooltip]=\"config.info?.content\"\n [matTooltipPosition]=\"config.info?.tooltipPosition || 'below'\">\n {{ config.label }}\n <mat-icon *ngIf=\"config.icon\">\n {{ config.icon}}\n </mat-icon>\n</button>\n\n", styles: [""] }]
806
+ }] });
807
+
808
+ const defaultConfig$2 = {
809
+ startView: 'month',
810
+ };
811
+ const DatepickerFieldMixin = crisprControlMixin(CrisprFieldComponent);
812
+ class DatepickerFieldComponent extends DatepickerFieldMixin {
813
+ constructor() {
814
+ super(...arguments);
815
+ this.defaultConfig = defaultConfig$2;
816
+ }
817
+ ngOnInit() {
818
+ var _a, _b;
819
+ super.ngOnInit();
820
+ this.startAt$ = this.config.startAt instanceof Date
821
+ ? of(this.config.startAt)
822
+ : this.config.startAt instanceof Function
823
+ ? this.config.startAt(this.group)
824
+ : of(null);
825
+ this.dateClass = ((_a = this.config) === null || _a === void 0 ? void 0 : _a.cellClassFunction) || null;
826
+ this.dateClass$ = this.config.dateClass ? (_b = this.config) === null || _b === void 0 ? void 0 : _b.dateClass(this.group) : of(() => '');
827
+ }
828
+ ngAfterContentInit() {
829
+ if (this.config.datepickerActions) {
830
+ this.calendarFooterPortal = new ComponentPortal(this.config.datepickerActions);
831
+ }
832
+ }
833
+ }
834
+ DatepickerFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: DatepickerFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
835
+ DatepickerFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: DatepickerFieldComponent, selector: "crispr-datepicker-field", usesInheritance: true, ngImport: i0, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n <mat-form-field\n [color]=\"config.color\"\n [appearance]=\"config.appearance\"\n [formGroup]=\"group\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n <input\n matInput\n [formControlName]=\"config.controlName\"\n [min]=\"config.min\"\n [max]=\"config.max\"\n [matDatepicker]=\"picker\"\n [matDatepickerFilter]=\"config.datepickerFilter\">\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker\n [touchUi]=\"config.touchUi\"\n [startView]=\"config.startView\"\n [startAt]=\"startAt$ | async\"\n [dateClass]=\"dateClass || (dateClass$ | async)\"\n #picker>\n <mat-datepicker-actions *ngIf=\"calendarFooterPortal\">\n <ng-template [cdkPortalOutlet]=\"calendarFooterPortal\"></ng-template>\n </mat-datepicker-actions>\n </mat-datepicker>\n\n </mat-form-field>\n</crispr-field-container>\n\n", styles: [""], components: [{ type: FieldContainerComponent, selector: "crispr-field-container", inputs: ["config", "group", "inlineField"] }, { type: i2$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i3$4.MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }, { type: i3$4.MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { type: i3$4.MatDatepickerActions, selector: "mat-datepicker-actions, mat-date-range-picker-actions" }], directives: [{ type: i4$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.ControlErrorContainerDirective, selector: "[controlErrorContainer], [formGroup]" }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$1.MatLabel, selector: "mat-label" }, { type: i7.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i4$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i3$4.MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { type: i4$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i5.ControlErrorsDirective, selector: "[formControl], [formControlName]" }, { type: i2$1.MatSuffix, selector: "[matSuffix]" }, { type: i8.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }], pipes: { "async": i2.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
836
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: DatepickerFieldComponent, decorators: [{
837
+ type: Component,
838
+ args: [{ selector: 'crispr-datepicker-field', changeDetection: ChangeDetectionStrategy.OnPush, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n <mat-form-field\n [color]=\"config.color\"\n [appearance]=\"config.appearance\"\n [formGroup]=\"group\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n <input\n matInput\n [formControlName]=\"config.controlName\"\n [min]=\"config.min\"\n [max]=\"config.max\"\n [matDatepicker]=\"picker\"\n [matDatepickerFilter]=\"config.datepickerFilter\">\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker\n [touchUi]=\"config.touchUi\"\n [startView]=\"config.startView\"\n [startAt]=\"startAt$ | async\"\n [dateClass]=\"dateClass || (dateClass$ | async)\"\n #picker>\n <mat-datepicker-actions *ngIf=\"calendarFooterPortal\">\n <ng-template [cdkPortalOutlet]=\"calendarFooterPortal\"></ng-template>\n </mat-datepicker-actions>\n </mat-datepicker>\n\n </mat-form-field>\n</crispr-field-container>\n\n", styles: [""] }]
839
+ }] });
840
+
841
+ class DividerComponent extends CrisprFieldComponent {
842
+ constructor() {
843
+ super(...arguments);
844
+ // TODO: pull in type after configs are better organized
845
+ this.defaultConfig = {};
846
+ }
847
+ ngOnInit() {
848
+ super.ngOnInit();
849
+ }
850
+ }
851
+ DividerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: DividerComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
852
+ DividerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: DividerComponent, selector: "crispr-divider", usesInheritance: true, ngImport: i0, template: "<mat-divider [ngClass]=\"config.classes\"></mat-divider>", styles: [":host{display:block;padding:1em 0}::ng-deep .mat-divider.mat-divider-horizontal{position:relative}\n"], components: [{ type: i1$1.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }], directives: [{ type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], preserveWhitespaces: true });
853
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: DividerComponent, decorators: [{
854
+ type: Component,
855
+ args: [{ selector: 'crispr-divider', template: "<mat-divider [ngClass]=\"config.classes\"></mat-divider>", styles: [":host{display:block;padding:1em 0}::ng-deep .mat-divider.mat-divider-horizontal{position:relative}\n"] }]
856
+ }] });
857
+
858
+ const RadioFieldMixin = crisprControlMixin(CrisprFieldComponent);
859
+ class RadioFieldComponent extends RadioFieldMixin {
860
+ constructor() {
861
+ super(...arguments);
862
+ this.defaultConfig = {};
863
+ }
864
+ ngOnInit() {
865
+ super.ngOnInit();
866
+ // options$ can be passed as an array, promise that resolves array, or observable that resolves array
867
+ // this functions accounts for all possibilities and converts to observable that resolves array
868
+ this.options$ = observablifyOptions(this.config.options, this.group);
869
+ }
870
+ }
871
+ RadioFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: RadioFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
872
+ RadioFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: RadioFieldComponent, selector: "crispr-radio-field", usesInheritance: true, ngImport: i0, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n\n <mat-radio-group\n [formControl]=\"control\"\n [color]=\"config.color\">\n <mat-radio-button class=\"example-radio-button\" *ngFor=\"let option of options$ | async\" [value]=\"option.value\">\n {{option.label}}\n </mat-radio-button>\n </mat-radio-group>\n</crispr-field-container>\n", styles: ["mat-radio-button{padding:12px}\n"], components: [{ type: FieldContainerComponent, selector: "crispr-field-container", inputs: ["config", "group", "inlineField"] }, { type: i2$2.MatRadioButton, selector: "mat-radio-button", inputs: ["disableRipple", "tabIndex"], exportAs: ["matRadioButton"] }], directives: [{ type: i2$2.MatRadioGroup, selector: "mat-radio-group", exportAs: ["matRadioGroup"] }, { type: i4$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i5.ControlErrorsDirective, selector: "[formControl], [formControlName]" }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i2.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
873
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: RadioFieldComponent, decorators: [{
874
+ type: Component,
875
+ args: [{ selector: 'crispr-radio-field', changeDetection: ChangeDetectionStrategy.OnPush, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n\n <mat-radio-group\n [formControl]=\"control\"\n [color]=\"config.color\">\n <mat-radio-button class=\"example-radio-button\" *ngFor=\"let option of options$ | async\" [value]=\"option.value\">\n {{option.label}}\n </mat-radio-button>\n </mat-radio-group>\n</crispr-field-container>\n", styles: ["mat-radio-button{padding:12px}\n"] }]
876
+ }] });
877
+
878
+ const defaultConfig$1 = {};
879
+ const UnitConversionFieldMixin = crisprControlMixin(CrisprFieldComponent);
880
+ class UnitConversionFieldComponent extends UnitConversionFieldMixin {
881
+ constructor() {
882
+ super(...arguments);
883
+ this.defaultConfig = defaultConfig$1;
884
+ this.displayValueControl = new FormControl();
885
+ this.unitSelectControl = new FormControl();
886
+ }
887
+ ngOnInit() {
888
+ var _a, _b;
889
+ super.ngOnInit();
890
+ // TODO: Validators need work. validation is tricky because the input needs to be validated against but the validator will compare against the controls value
891
+ // this.displayValueControl.setValidators(this.config.validators);
892
+ const controlValuePipeline = [
893
+ this.displayValueControl.valueChanges.pipe(startWith(this.displayValueControl.value))
894
+ ];
895
+ // setup all required pieces when showing a field for selecting units
896
+ if (this.config.showUnitSelect) {
897
+ this.unitOptions$ = observablifyOptions(this.config.selectableUnits, this.group);
898
+ controlValuePipeline.push(this.unitSelectControl.valueChanges.pipe(startWith(((_a = this.config) === null || _a === void 0 ? void 0 : _a.initialDisplayUnit) || null)));
899
+ this.unitSelectControl.setValue(((_b = this.config) === null || _b === void 0 ? void 0 : _b.initialDisplayUnit) || null);
900
+ }
901
+ this.transformationSubscription = combineLatest(controlValuePipeline).subscribe(([displayValue, unitValue]) => {
902
+ const computedValue = this.config.storedValueConversion(displayValue, unitValue);
903
+ this.control.setValue(computedValue);
904
+ });
905
+ }
906
+ ngOnDestroy() {
907
+ this.transformationSubscription.unsubscribe();
908
+ }
909
+ setInitialDisplayValue(storedValue, unit) {
910
+ const initialDisplayValue = this.config.initialDisplayValueConversion(storedValue || null, unit);
911
+ this.displayValueControl.setValue(initialDisplayValue);
912
+ }
913
+ /**
914
+ * We override the 'setControlValue' we inherited from crisprControlMixin and add our custom logic,
915
+ * This function gets called onInit because were object oriented. it's so great, so great that I'm
916
+ * typing a paragraph to explain what the hell is going on...
917
+ * @param value the initial value for the control passed down from the form components input
918
+ */
919
+ setControlValue(value) {
920
+ var _a;
921
+ const initialUnitValue = this.config.showUnitSelect ? (_a = this.config) === null || _a === void 0 ? void 0 : _a.initialDisplayUnit : null;
922
+ this.setInitialDisplayValue(value, initialUnitValue);
923
+ }
924
+ }
925
+ UnitConversionFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: UnitConversionFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
926
+ UnitConversionFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: UnitConversionFieldComponent, selector: "crispr-unit-conversion-field", usesInheritance: true, ngImport: i0, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n <mat-form-field\n [style.width.%]=\"config.showUnitSelect ? 60 : 100\"\n class=\"number-field\"\n [color]=\"config.color\"\n [appearance]=\"config.appearance\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n <input\n type=\"number\"\n matInput\n [formControl]=\"displayValueControl\"\n [placeholder]=\"config.placeholder\"\n [min]=\"config.min\"\n [max]=\"config.max\"\n [step]=\"config.step\"\n [autofocus]=\"config.autofocus\">\n <span *ngIf=\"config.fieldSuffix\" matSuffix>{{config.fieldSuffix}}</span>\n <crispr-info\n matSuffix\n *ngIf=\"config.info\"\n [info]=\"config.info\">\n </crispr-info>\n </mat-form-field>\n\n <mat-form-field\n *ngIf=\"config.showUnitSelect\"\n [color]=\"config.color\"\n [appearance]=\"config.appearance\"\n [formGroup]=\"group\"\n class=\"unit-field\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n <mat-select\n #selectField\n [formControl]=\"unitSelectControl\">\n\n <mat-option\n *ngFor=\"let option of unitOptions$ | async\"\n [value]=\"option.value\">\n <crispr-option [option]=\"option\">\n </crispr-option>\n </mat-option>\n\n </mat-select>\n\n <!-- <span *ngIf=\"config.fieldSuffix\" matSuffix>{{config.fieldSuffix}}</span> -->\n <!-- <crispr-info\n *ngIf=\"config.info\"\n matSuffix\n [info]=\"config.info\">\n </crispr-info> -->\n </mat-form-field>\n\n\n</crispr-field-container>\n", styles: [".unit-field{width:40%;margin-left:16px}:host ::ng-deep .field-container{display:flex}\n"], components: [{ type: FieldContainerComponent, selector: "crispr-field-container", inputs: ["config", "group", "inlineField"] }, { type: i2$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: InfoComponent, selector: "crispr-info", inputs: ["info"] }, { type: i3$1.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i5$1.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: OptionComponent, selector: "crispr-option", inputs: ["option"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$1.MatLabel, selector: "mat-label" }, { type: i4$1.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { type: i4$1.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { type: i4$1.MaxValidator, selector: "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]", inputs: ["max"] }, { type: i7.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i4$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i4$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i5.ControlErrorsDirective, selector: "[formControl], [formControlName]" }, { type: i2$1.MatSuffix, selector: "[matSuffix]" }, { type: i4$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.ControlErrorContainerDirective, selector: "[controlErrorContainer], [formGroup]" }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i2.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
927
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: UnitConversionFieldComponent, decorators: [{
928
+ type: Component,
929
+ args: [{ selector: 'crispr-unit-conversion-field', changeDetection: ChangeDetectionStrategy.OnPush, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n <mat-form-field\n [style.width.%]=\"config.showUnitSelect ? 60 : 100\"\n class=\"number-field\"\n [color]=\"config.color\"\n [appearance]=\"config.appearance\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n <input\n type=\"number\"\n matInput\n [formControl]=\"displayValueControl\"\n [placeholder]=\"config.placeholder\"\n [min]=\"config.min\"\n [max]=\"config.max\"\n [step]=\"config.step\"\n [autofocus]=\"config.autofocus\">\n <span *ngIf=\"config.fieldSuffix\" matSuffix>{{config.fieldSuffix}}</span>\n <crispr-info\n matSuffix\n *ngIf=\"config.info\"\n [info]=\"config.info\">\n </crispr-info>\n </mat-form-field>\n\n <mat-form-field\n *ngIf=\"config.showUnitSelect\"\n [color]=\"config.color\"\n [appearance]=\"config.appearance\"\n [formGroup]=\"group\"\n class=\"unit-field\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n <mat-select\n #selectField\n [formControl]=\"unitSelectControl\">\n\n <mat-option\n *ngFor=\"let option of unitOptions$ | async\"\n [value]=\"option.value\">\n <crispr-option [option]=\"option\">\n </crispr-option>\n </mat-option>\n\n </mat-select>\n\n <!-- <span *ngIf=\"config.fieldSuffix\" matSuffix>{{config.fieldSuffix}}</span> -->\n <!-- <crispr-info\n *ngIf=\"config.info\"\n matSuffix\n [info]=\"config.info\">\n </crispr-info> -->\n </mat-form-field>\n\n\n</crispr-field-container>\n", styles: [".unit-field{width:40%;margin-left:16px}:host ::ng-deep .field-container{display:flex}\n"] }]
930
+ }] });
931
+
932
+ class FileDropzoneDirective {
933
+ constructor() {
934
+ this.fileDrop = new EventEmitter();
935
+ this.crisprFileDropzone = true;
936
+ }
937
+ onDrop($event) {
938
+ if (this.crisprFileDropzone) {
939
+ $event.preventDefault();
940
+ this.fileDrop.emit($event.dataTransfer.files);
941
+ }
942
+ }
943
+ // Prevents DOM from trying to open file in browser
944
+ onDragOver($event) {
945
+ if (this.crisprFileDropzone) {
946
+ $event.preventDefault();
947
+ }
948
+ }
949
+ }
950
+ FileDropzoneDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FileDropzoneDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
951
+ FileDropzoneDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.1", type: FileDropzoneDirective, selector: "[crisprFileDropzone]", inputs: { crisprFileDropzone: "crisprFileDropzone" }, outputs: { fileDrop: "fileDrop" }, host: { listeners: { "drop": "onDrop($event)", "dragover": "onDragOver($event)" } }, ngImport: i0 });
952
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FileDropzoneDirective, decorators: [{
953
+ type: Directive,
954
+ args: [{
955
+ selector: '[crisprFileDropzone]'
956
+ }]
957
+ }], propDecorators: { fileDrop: [{
958
+ type: Output
959
+ }], crisprFileDropzone: [{
960
+ type: Input
961
+ }], onDrop: [{
962
+ type: HostListener,
963
+ args: ['drop', ['$event']]
964
+ }], onDragOver: [{
965
+ type: HostListener,
966
+ args: ['dragover', ['$event']]
967
+ }] } });
968
+
969
+ class SelectedFileComponent {
970
+ }
971
+ SelectedFileComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: SelectedFileComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
972
+ SelectedFileComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: SelectedFileComponent, selector: "crispr-selected-file", inputs: { fileName: "fileName", progress: "progress", showProgress: "showProgress", color: "color" }, ngImport: i0, template: "<h3 class=\"mat-h3\">{{ fileName }}</h3>\n<mat-progress-bar\n *ngIf=\"showProgress\"\n mode=\"determinate\"\n [color]=\"color\"\n [value]=\"progress\">\n</mat-progress-bar>\n", styles: ["mat-progress-bar{margin-bottom:8px}\n"], components: [{ type: i1$2.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], preserveWhitespaces: true });
973
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: SelectedFileComponent, decorators: [{
974
+ type: Component,
975
+ args: [{ selector: 'crispr-selected-file', template: "<h3 class=\"mat-h3\">{{ fileName }}</h3>\n<mat-progress-bar\n *ngIf=\"showProgress\"\n mode=\"determinate\"\n [color]=\"color\"\n [value]=\"progress\">\n</mat-progress-bar>\n", styles: ["mat-progress-bar{margin-bottom:8px}\n"] }]
976
+ }], propDecorators: { fileName: [{
977
+ type: Input
978
+ }], progress: [{
979
+ type: Input
980
+ }], showProgress: [{
981
+ type: Input
982
+ }], color: [{
983
+ type: Input
984
+ }] } });
985
+ class SelectedFileModule {
986
+ }
987
+ SelectedFileModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: SelectedFileModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
988
+ SelectedFileModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: SelectedFileModule, declarations: [SelectedFileComponent], imports: [CommonModule,
989
+ MatProgressBarModule], exports: [SelectedFileComponent] });
990
+ SelectedFileModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: SelectedFileModule, imports: [[
991
+ CommonModule,
992
+ MatProgressBarModule
993
+ ]] });
994
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: SelectedFileModule, decorators: [{
995
+ type: NgModule,
996
+ args: [{
997
+ imports: [
998
+ CommonModule,
999
+ MatProgressBarModule
1000
+ ],
1001
+ exports: [
1002
+ SelectedFileComponent
1003
+ ],
1004
+ declarations: [
1005
+ SelectedFileComponent
1006
+ ]
1007
+ }]
1008
+ }] });
1009
+
1010
+ const FileUploadFieldMixin = crisprControlMixin(CrisprFieldComponent);
1011
+ class FileUploadFieldComponent extends FileUploadFieldMixin {
1012
+ // ngControl: NgControl = null;
1013
+ constructor(ngControl) {
1014
+ super();
1015
+ this.ngControl = ngControl;
1016
+ this.defaultConfig = {
1017
+ allowMultipleFiles: false,
1018
+ acceptedTypes: '*.*',
1019
+ dropZoneText: 'DROP FILE HERE',
1020
+ selectFilesButtonType: 'button',
1021
+ selectButtonText: 'SELECT',
1022
+ showClearFilesButton: true,
1023
+ clearFilesButtonText: 'CLEAR',
1024
+ uploadButtonText: 'UPLOAD',
1025
+ uploadButtonType: 'button',
1026
+ showUploadProgress: false,
1027
+ disableOnUpload: true
1028
+ };
1029
+ this.isUploaded = false;
1030
+ this.fileProgress = [];
1031
+ if (this.ngControl != null) {
1032
+ // Setting the value accessor directly (instead of using
1033
+ // the providers) to avoid running into a circular import.
1034
+ ngControl.valueAccessor = this;
1035
+ }
1036
+ }
1037
+ ngOnInit() {
1038
+ super.ngOnInit();
1039
+ this.disabled$ = this.config.disabledCallback
1040
+ ? this.config.disabledCallback(this.group, this.config)
1041
+ : of(false);
1042
+ }
1043
+ filesChanged(files) {
1044
+ if (files && files.length > 0) {
1045
+ this.selectedFiles = files;
1046
+ this.control.patchValue(files);
1047
+ }
1048
+ }
1049
+ uploadFiles() {
1050
+ if (this.selectedFiles && this.config.uploadFiles) {
1051
+ this.isUploaded = true;
1052
+ this.config.uploadFiles(this.group, this.selectedFiles, this);
1053
+ }
1054
+ }
1055
+ resetFileInput() {
1056
+ this.fileInputRef.nativeElement.value = '';
1057
+ this.control.patchValue(null);
1058
+ this.isUploaded = false;
1059
+ }
1060
+ writeValue(value) {
1061
+ // clear file input
1062
+ // this.host.nativeElement.value = '';
1063
+ // this.file = null;
1064
+ }
1065
+ registerOnChange(fn) {
1066
+ this.onChange = fn;
1067
+ }
1068
+ registerOnTouched(fn) {
1069
+ }
1070
+ }
1071
+ FileUploadFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FileUploadFieldComponent, deps: [{ token: i4$1.NgControl, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Component });
1072
+ FileUploadFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: FileUploadFieldComponent, selector: "crispr-file-upload-field", viewQueries: [{ propertyName: "fileInputRef", first: true, predicate: ["fileInput"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n <mat-form-field floatLabel=\"always\"\n [color]=\"config.color\"\n appearance=\"outline\"\n [crisprFileDropzone]=\"!(disabled$ | async) && !(config.disableOnUpload && isUploaded)\"\n [formGroup]=\"group\"\n (fileDrop)=\"filesChanged($event)\">\n\n <input [formControlName]=\"config.controlName\" matInput type=\"text\"/>\n <input\n #fileInput\n type=\"file\"\n style=\"display: none\"\n [accept]=\"config.acceptedTypes\"\n [multiple]=\"config.allowMultipleFiles\"\n (change)=\"filesChanged($event.target.files)\"/>\n <mat-label>{{config.label}}</mat-label>\n\n <div *ngIf=\"!(selectedFiles?.length > 0); else selectedFileList\" class=\"drop-info\">\n <mat-icon class=\"drop-icon\" inline=\"true\">cloud_upload</mat-icon>\n <h2 class=\"mat-h2\">{{config.dropZoneText}}</h2>\n or\n <button\n mat-raised-button\n type=\"button\"\n color=\"primary\"\n [disabled]=\"(disabled$ | async) || config.disableOnUpload && isUploaded\"\n (click)=\"fileInput.click()\"\n [attr.aria-label]=\"config.controlName\">\n {{config.selectButtonText}}\n </button>\n </div>\n <ng-template #selectedFileList>\n <div class=\"selected-files-container\">\n <div class=\"selected-files-list\">\n <crispr-selected-file\n *ngFor=\"let file of selectedFiles; let i = index;\"\n [color]=\"config.color === 'primary' ? 'accent' : 'primary'\"\n [fileName]=\"file.name\"\n [showProgress]=\"config.showUploadProgress\"\n [progress]=\"fileProgress && (fileProgress[i] | async)\">\n </crispr-selected-file>\n </div>\n\n </div>\n </ng-template>\n\n </mat-form-field>\n <div class=\"button-container\" *ngIf=\"selectedFiles?.length > 0\">\n\n <button\n mat-button\n (click)=\"resetFileInput()\"\n type=\"button\"\n [disabled]=\"(disabled$ | async) || (config.disableOnUpload && isUploaded)\"\n aria-label=\"Remove Selected File(s)\">\n {{config.clearFilesButtonText}}\n <mat-icon>delete</mat-icon>\n </button>\n\n <button\n *ngIf=\"!!config.uploadFiles\"\n mat-raised-button\n type=\"button\"\n color=\"accent\"\n class=\"file-input-button\"\n [disabled]=\"(disabled$ | async) || (config.disableOnUpload && isUploaded)\"\n (click)=\"uploadFiles()\"\n [attr.aria-label]=\"config.uploadButtonText\">\n {{ config.uploadButtonText }}\n </button>\n\n </div>\n</crispr-field-container>\n", styles: [":host ::ng-deep .mat-form-field .mat-form-field-infix{padding-top:0;display:flex;justify-content:center}:host .drop-info{display:flex;flex-direction:column;align-items:center}:host .drop-info .drop-icon{font-size:36px}:host .drop-info .mat-h2{margin:0}:host .button-container{display:flex;justify-content:flex-end;margin-top:-16px}:host .button-container button{margin-left:8px}:host .selected-files-container{width:100%}:host [matInput]{position:absolute;max-height:0;visibility:hidden}\n"], components: [{ type: i0.forwardRef(function () { return FieldContainerComponent; }), selector: "crispr-field-container", inputs: ["config", "group", "inlineField"] }, { type: i0.forwardRef(function () { return i2$1.MatFormField; }), selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i0.forwardRef(function () { return i4.MatIcon; }), selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i0.forwardRef(function () { return i1.MatButton; }), selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i0.forwardRef(function () { return SelectedFileComponent; }), selector: "crispr-selected-file", inputs: ["fileName", "progress", "showProgress", "color"] }], directives: [{ type: i0.forwardRef(function () { return FileDropzoneDirective; }), selector: "[crisprFileDropzone]", inputs: ["crisprFileDropzone"], outputs: ["fileDrop"] }, { type: i0.forwardRef(function () { return i4$1.NgControlStatusGroup; }), selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i0.forwardRef(function () { return i4$1.FormGroupDirective; }), selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i0.forwardRef(function () { return i5.ControlErrorContainerDirective; }), selector: "[controlErrorContainer], [formGroup]" }, { type: i0.forwardRef(function () { return i7.MatInput; }), selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i0.forwardRef(function () { return i4$1.DefaultValueAccessor; }), selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i0.forwardRef(function () { return i4$1.NgControlStatus; }), selector: "[formControlName],[ngModel],[formControl]" }, { type: i0.forwardRef(function () { return i4$1.FormControlName; }), selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i0.forwardRef(function () { return i5.ControlErrorsDirective; }), selector: "[formControl], [formControlName]" }, { type: i0.forwardRef(function () { return i2$1.MatLabel; }), selector: "mat-label" }, { type: i0.forwardRef(function () { return i2.NgIf; }), selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i0.forwardRef(function () { return i2.NgForOf; }), selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i0.forwardRef(function () { return i2.AsyncPipe; }) }, changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
1073
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FileUploadFieldComponent, decorators: [{
1074
+ type: Component,
1075
+ args: [{ selector: 'crispr-file-upload-field', changeDetection: ChangeDetectionStrategy.OnPush, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n <mat-form-field floatLabel=\"always\"\n [color]=\"config.color\"\n appearance=\"outline\"\n [crisprFileDropzone]=\"!(disabled$ | async) && !(config.disableOnUpload && isUploaded)\"\n [formGroup]=\"group\"\n (fileDrop)=\"filesChanged($event)\">\n\n <input [formControlName]=\"config.controlName\" matInput type=\"text\"/>\n <input\n #fileInput\n type=\"file\"\n style=\"display: none\"\n [accept]=\"config.acceptedTypes\"\n [multiple]=\"config.allowMultipleFiles\"\n (change)=\"filesChanged($event.target.files)\"/>\n <mat-label>{{config.label}}</mat-label>\n\n <div *ngIf=\"!(selectedFiles?.length > 0); else selectedFileList\" class=\"drop-info\">\n <mat-icon class=\"drop-icon\" inline=\"true\">cloud_upload</mat-icon>\n <h2 class=\"mat-h2\">{{config.dropZoneText}}</h2>\n or\n <button\n mat-raised-button\n type=\"button\"\n color=\"primary\"\n [disabled]=\"(disabled$ | async) || config.disableOnUpload && isUploaded\"\n (click)=\"fileInput.click()\"\n [attr.aria-label]=\"config.controlName\">\n {{config.selectButtonText}}\n </button>\n </div>\n <ng-template #selectedFileList>\n <div class=\"selected-files-container\">\n <div class=\"selected-files-list\">\n <crispr-selected-file\n *ngFor=\"let file of selectedFiles; let i = index;\"\n [color]=\"config.color === 'primary' ? 'accent' : 'primary'\"\n [fileName]=\"file.name\"\n [showProgress]=\"config.showUploadProgress\"\n [progress]=\"fileProgress && (fileProgress[i] | async)\">\n </crispr-selected-file>\n </div>\n\n </div>\n </ng-template>\n\n </mat-form-field>\n <div class=\"button-container\" *ngIf=\"selectedFiles?.length > 0\">\n\n <button\n mat-button\n (click)=\"resetFileInput()\"\n type=\"button\"\n [disabled]=\"(disabled$ | async) || (config.disableOnUpload && isUploaded)\"\n aria-label=\"Remove Selected File(s)\">\n {{config.clearFilesButtonText}}\n <mat-icon>delete</mat-icon>\n </button>\n\n <button\n *ngIf=\"!!config.uploadFiles\"\n mat-raised-button\n type=\"button\"\n color=\"accent\"\n class=\"file-input-button\"\n [disabled]=\"(disabled$ | async) || (config.disableOnUpload && isUploaded)\"\n (click)=\"uploadFiles()\"\n [attr.aria-label]=\"config.uploadButtonText\">\n {{ config.uploadButtonText }}\n </button>\n\n </div>\n</crispr-field-container>\n", styles: [":host ::ng-deep .mat-form-field .mat-form-field-infix{padding-top:0;display:flex;justify-content:center}:host .drop-info{display:flex;flex-direction:column;align-items:center}:host .drop-info .drop-icon{font-size:36px}:host .drop-info .mat-h2{margin:0}:host .button-container{display:flex;justify-content:flex-end;margin-top:-16px}:host .button-container button{margin-left:8px}:host .selected-files-container{width:100%}:host [matInput]{position:absolute;max-height:0;visibility:hidden}\n"] }]
1076
+ }], ctorParameters: function () {
1077
+ return [{ type: i4$1.NgControl, decorators: [{
1078
+ type: Optional
1079
+ }, {
1080
+ type: Self
1081
+ }] }];
1082
+ }, propDecorators: { fileInputRef: [{
1083
+ type: ViewChild,
1084
+ args: ['fileInput']
1085
+ }] } });
1086
+ class FileUploadFieldModule {
1087
+ }
1088
+ FileUploadFieldModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FileUploadFieldModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1089
+ FileUploadFieldModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FileUploadFieldModule, declarations: [FileUploadFieldComponent, FileDropzoneDirective], imports: [CommonModule,
1090
+ FieldContainerModule,
1091
+ ReactiveFormsModule,
1092
+ MatIconModule,
1093
+ MatButtonModule,
1094
+ MatFormFieldModule,
1095
+ MatInputModule,
1096
+ SelectedFileModule,
1097
+ FormValidationHandlerModule], exports: [FileUploadFieldComponent, FileDropzoneDirective] });
1098
+ FileUploadFieldModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FileUploadFieldModule, imports: [[
1099
+ CommonModule,
1100
+ FieldContainerModule,
1101
+ ReactiveFormsModule,
1102
+ MatIconModule,
1103
+ MatButtonModule,
1104
+ MatFormFieldModule,
1105
+ MatInputModule,
1106
+ SelectedFileModule,
1107
+ FormValidationHandlerModule,
1108
+ ]] });
1109
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FileUploadFieldModule, decorators: [{
1110
+ type: NgModule,
1111
+ args: [{
1112
+ imports: [
1113
+ CommonModule,
1114
+ FieldContainerModule,
1115
+ ReactiveFormsModule,
1116
+ MatIconModule,
1117
+ MatButtonModule,
1118
+ MatFormFieldModule,
1119
+ MatInputModule,
1120
+ SelectedFileModule,
1121
+ FormValidationHandlerModule,
1122
+ ],
1123
+ exports: [
1124
+ FileUploadFieldComponent,
1125
+ FileDropzoneDirective
1126
+ ],
1127
+ declarations: [
1128
+ FileUploadFieldComponent,
1129
+ FileDropzoneDirective
1130
+ ]
1131
+ }]
1132
+ }] });
1133
+
1134
+ function convertBytesToMb(bytes) {
1135
+ return bytes / 1048576;
1136
+ }
1137
+
1138
+ const ImageUploadFieldMixin = crisprControlMixin(CrisprFieldComponent);
1139
+ class ImageUploadFieldComponent extends ImageUploadFieldMixin {
1140
+ // ngControl: NgControl = null;
1141
+ constructor(ngControl, domSanitizer, cdr) {
1142
+ super();
1143
+ this.ngControl = ngControl;
1144
+ this.domSanitizer = domSanitizer;
1145
+ this.cdr = cdr;
1146
+ this.defaultConfig = {
1147
+ // allowMultipleFiles: false,
1148
+ acceptedTypes: 'image/*',
1149
+ dropZoneText: 'DROP FILE HERE',
1150
+ selectFilesButtonType: 'button',
1151
+ selectButtonText: 'SELECT',
1152
+ showClearFilesButton: true,
1153
+ clearFilesButtonText: 'CLEAR',
1154
+ resetFilesButtonText: 'RESET',
1155
+ imagePreviewHeight: '250px',
1156
+ compressImage: false,
1157
+ targetCompressedImageFileSizeMb: .4,
1158
+ minCompressionThresholdMb: .6,
1159
+ useWebWorker: true,
1160
+ };
1161
+ this.inputImageFileSubject = new Subject();
1162
+ this.inputImageFile$ = this.inputImageFileSubject.asObservable().pipe(shareReplay(1));
1163
+ this.compressedFile$ = this.inputImageFile$.pipe(switchMap((file) => __awaiter(this, void 0, void 0, function* () {
1164
+ if (!file)
1165
+ return null;
1166
+ if (typeof file === 'string')
1167
+ return file;
1168
+ const { compressImage, targetCompressedImageFileSizeMb, minCompressionThresholdMb, maxWidthOrHeight, useWebWorker } = this.config;
1169
+ const fileSizeMb = convertBytesToMb(file.size);
1170
+ const shouldCompress = compressImage && targetCompressedImageFileSizeMb < fileSizeMb && minCompressionThresholdMb < fileSizeMb;
1171
+ if (shouldCompress) {
1172
+ const options = Object.assign(Object.assign({}, (maxWidthOrHeight ? { maxWidthOrHeight } : { maxSizeMB: targetCompressedImageFileSizeMb })), { useWebWorker, maxIterations: 30, onProgress: (p) => {
1173
+ this.progress = p;
1174
+ this.cdr.detectChanges();
1175
+ } });
1176
+ return yield imageCompression(file, options);
1177
+ }
1178
+ else
1179
+ return file;
1180
+ })), map((compressedFileOrString) => {
1181
+ if (!compressedFileOrString || typeof compressedFileOrString === 'string')
1182
+ return compressedFileOrString;
1183
+ const { type, name, lastModified } = compressedFileOrString;
1184
+ return new File([compressedFileOrString], this.config.fileName || name, {
1185
+ type,
1186
+ lastModified
1187
+ });
1188
+ }), tap(file => {
1189
+ this.control.setValue(file);
1190
+ if (file || this.value) {
1191
+ this.control.markAsTouched();
1192
+ setTimeout(() => {
1193
+ this.cdr.detectChanges();
1194
+ }, 100);
1195
+ }
1196
+ }), map(file => typeof file === 'string' ? null : file), shareReplay(1));
1197
+ this.compressedImageUrlString$ = this.compressedFile$.pipe(switchMap((file) => __awaiter(this, void 0, void 0, function* () {
1198
+ if (!file)
1199
+ return null;
1200
+ const compressedStringImage = yield imageCompression.getDataUrlFromFile(file);
1201
+ return this.domSanitizer.bypassSecurityTrustResourceUrl(compressedStringImage);
1202
+ })), shareReplay(1));
1203
+ this.isUploaded = false;
1204
+ if (this.ngControl != null) {
1205
+ // Setting the value accessor directly (instead of using
1206
+ // the providers) to avoid running into a circular import.
1207
+ ngControl.valueAccessor = this;
1208
+ }
1209
+ }
1210
+ ngOnInit() {
1211
+ super.ngOnInit();
1212
+ this.imageSrcUrl$ = combineLatest([
1213
+ this.compressedImageUrlString$.pipe(startWith(null)),
1214
+ this.control.valueChanges.pipe(startWith(this.value))
1215
+ ]).pipe(map(([compressedImageUrlString, controlUrl]) => {
1216
+ return compressedImageUrlString || typeof controlUrl === 'string' && controlUrl || null;
1217
+ }));
1218
+ this.disabled$ = this.config.disabledCallback
1219
+ ? this.config.disabledCallback(this.group, this.config)
1220
+ : of(false);
1221
+ }
1222
+ filesChanged(files) {
1223
+ if (files && files.length > 0) {
1224
+ const imageFile = files[0];
1225
+ this.control.markAsTouched();
1226
+ this.inputImageFileSubject.next(imageFile);
1227
+ }
1228
+ }
1229
+ clearFileInput() {
1230
+ this.inputImageFileSubject.next(null);
1231
+ this.fileInputRef.nativeElement.value = '';
1232
+ this.control.patchValue(null);
1233
+ this.control.markAsTouched();
1234
+ this.isUploaded = false;
1235
+ }
1236
+ resetToInitialValue(initialValue) {
1237
+ this.inputImageFileSubject.next(initialValue);
1238
+ // this.fileInputRef.nativeElement.value = initialValue
1239
+ this.isUploaded = false;
1240
+ }
1241
+ writeValue(value) { }
1242
+ registerOnChange(fn) {
1243
+ this.onChange = fn;
1244
+ }
1245
+ registerOnTouched(fn) { }
1246
+ }
1247
+ ImageUploadFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: ImageUploadFieldComponent, deps: [{ token: i4$1.NgControl, optional: true, self: true }, { token: i2$3.DomSanitizer }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
1248
+ ImageUploadFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: ImageUploadFieldComponent, selector: "crispr-image-upload-field", viewQueries: [{ propertyName: "fileInputRef", first: true, predicate: ["fileInput"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n\n <mat-form-field floatLabel=\"always\"\n [color]=\"config.color\"\n [appearance]=\"config.appearance\"\n [formGroup]=\"group\">\n <mat-label>{{config.label}}</mat-label>\n <input [formControlName]=\"config.controlName\" matInput type=\"text\"/>\n <input\n #fileInput\n type=\"file\"\n [accept]=\"config.acceptedTypes\"\n (change)=\"filesChanged($event.target.files)\"/>\n <div class=\"ui-container\">\n\n <div class=\"image-preview\" [style.height]=\"config.imagePreviewHeight\">\n <crispr-selected-file\n *ngIf=\"(progress < 100) && inputImageFile$ | async as file; else dropzoneOrPreview\"\n [color]=\"config.color === 'primary' ? 'accent' : 'primary'\"\n [fileName]=\"'Compressing: ' + file.name\"\n [showProgress]=\"true\"\n [progress]=\"progress\">\n </crispr-selected-file>\n\n <ng-template #dropzoneOrPreview>\n <!-- <img *ngIf=\"(initialUrlString$ | async) as initialUrlString;\" [src]=\"initialUrlString\" alt=\"\"> -->\n <img *ngIf=\"imageSrcUrl$ | async as srcUrl; else noImage\" [src]=\"srcUrl\" alt=\"\">\n <ng-template #noImage>\n <div class=\"drop-container\"\n [crisprFileDropzone]=\"!(disabled$ | async)\"\n (fileDrop)=\"filesChanged($event)\">\n <mat-icon class=\"drop-icon\" inline=\"true\">cloud_upload</mat-icon>\n <h2 class=\"mat-h2\">{{config.dropZoneText}}</h2>\n </div>\n </ng-template>\n\n </ng-template>\n </div>\n\n\n\n <!-- </ng-template> -->\n <div class=\"button-container\" *ngIf=\"true\">\n\n <button\n mat-button\n (click)=\"clearFileInput()\"\n type=\"button\"\n [disabled]=\"(disabled$ | async)\"\n aria-label=\"Remove Selected File(s)\">\n <mat-icon>delete</mat-icon>\n {{config.clearFilesButtonText}}\n </button>\n\n <button\n *ngIf=\"value\"\n mat-button\n (click)=\"resetToInitialValue(value)\"\n type=\"button\"\n [disabled]=\"(disabled$ | async)\"\n aria-label=\"Remove Selected File(s)\">\n <mat-icon>replay</mat-icon>\n {{config.resetFilesButtonText}}\n </button>\n\n <button\n mat-button\n type=\"button\"\n color=\"primary\"\n [disabled]=\"(disabled$ | async)\"\n (click)=\"fileInput.click()\"\n [attr.aria-label]=\"config.controlName\">\n <mat-icon>\n camera\n </mat-icon>\n SELECT\n </button>\n </div>\n </div>\n\n </mat-form-field>\n\n</crispr-field-container>\n", styles: [":host ::ng-deep .mat-form-field .mat-form-field-infix{padding-top:0}:host ::ng-deep .mat-form-field .mat-button-wrapper{display:flex;flex-direction:column;align-items:center;padding-top:8px}:host .ui-container{display:flex;flex-direction:column}:host .ui-container .image-preview{display:flex;flex-direction:column;align-content:space-between;justify-content:center;align-items:center;margin:8px 0;flex-grow:1}:host .ui-container .image-preview crispr-selected-file{width:100%}:host .ui-container .image-preview .drop-container{display:flex;box-sizing:border-box;flex-direction:column;align-items:center;border:3px dashed gray;height:100%;width:100%;align-content:center;justify-content:center;border-radius:8px}:host .ui-container .image-preview .drop-container .drop-icon{height:32px;width:32px;font-size:36px}:host .ui-container .image-preview .drop-container .mat-h2{margin:0}:host .ui-container .image-preview img{height:inherit;max-width:100%}:host .ui-container .button-container{display:flex;flex-direction:var(--image-upload-button-container-direction);justify-content:flex-end}:host .ui-container .button-container button{margin-left:8px}:host input{position:absolute;max-height:0;visibility:hidden}\n"], components: [{ type: FieldContainerComponent, selector: "crispr-field-container", inputs: ["config", "group", "inlineField"] }, { type: i2$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: SelectedFileComponent, selector: "crispr-selected-file", inputs: ["fileName", "progress", "showProgress", "color"] }, { type: i4.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i1.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i4$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.ControlErrorContainerDirective, selector: "[controlErrorContainer], [formGroup]" }, { type: i2$1.MatLabel, selector: "mat-label" }, { type: i7.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i4$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i4$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i5.ControlErrorsDirective, selector: "[formControl], [formControlName]" }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: FileDropzoneDirective, selector: "[crisprFileDropzone]", inputs: ["crisprFileDropzone"], outputs: ["fileDrop"] }], pipes: { "async": i2.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
1249
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: ImageUploadFieldComponent, decorators: [{
1250
+ type: Component,
1251
+ args: [{ selector: 'crispr-image-upload-field', changeDetection: ChangeDetectionStrategy.OnPush, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n\n <mat-form-field floatLabel=\"always\"\n [color]=\"config.color\"\n [appearance]=\"config.appearance\"\n [formGroup]=\"group\">\n <mat-label>{{config.label}}</mat-label>\n <input [formControlName]=\"config.controlName\" matInput type=\"text\"/>\n <input\n #fileInput\n type=\"file\"\n [accept]=\"config.acceptedTypes\"\n (change)=\"filesChanged($event.target.files)\"/>\n <div class=\"ui-container\">\n\n <div class=\"image-preview\" [style.height]=\"config.imagePreviewHeight\">\n <crispr-selected-file\n *ngIf=\"(progress < 100) && inputImageFile$ | async as file; else dropzoneOrPreview\"\n [color]=\"config.color === 'primary' ? 'accent' : 'primary'\"\n [fileName]=\"'Compressing: ' + file.name\"\n [showProgress]=\"true\"\n [progress]=\"progress\">\n </crispr-selected-file>\n\n <ng-template #dropzoneOrPreview>\n <!-- <img *ngIf=\"(initialUrlString$ | async) as initialUrlString;\" [src]=\"initialUrlString\" alt=\"\"> -->\n <img *ngIf=\"imageSrcUrl$ | async as srcUrl; else noImage\" [src]=\"srcUrl\" alt=\"\">\n <ng-template #noImage>\n <div class=\"drop-container\"\n [crisprFileDropzone]=\"!(disabled$ | async)\"\n (fileDrop)=\"filesChanged($event)\">\n <mat-icon class=\"drop-icon\" inline=\"true\">cloud_upload</mat-icon>\n <h2 class=\"mat-h2\">{{config.dropZoneText}}</h2>\n </div>\n </ng-template>\n\n </ng-template>\n </div>\n\n\n\n <!-- </ng-template> -->\n <div class=\"button-container\" *ngIf=\"true\">\n\n <button\n mat-button\n (click)=\"clearFileInput()\"\n type=\"button\"\n [disabled]=\"(disabled$ | async)\"\n aria-label=\"Remove Selected File(s)\">\n <mat-icon>delete</mat-icon>\n {{config.clearFilesButtonText}}\n </button>\n\n <button\n *ngIf=\"value\"\n mat-button\n (click)=\"resetToInitialValue(value)\"\n type=\"button\"\n [disabled]=\"(disabled$ | async)\"\n aria-label=\"Remove Selected File(s)\">\n <mat-icon>replay</mat-icon>\n {{config.resetFilesButtonText}}\n </button>\n\n <button\n mat-button\n type=\"button\"\n color=\"primary\"\n [disabled]=\"(disabled$ | async)\"\n (click)=\"fileInput.click()\"\n [attr.aria-label]=\"config.controlName\">\n <mat-icon>\n camera\n </mat-icon>\n SELECT\n </button>\n </div>\n </div>\n\n </mat-form-field>\n\n</crispr-field-container>\n", styles: [":host ::ng-deep .mat-form-field .mat-form-field-infix{padding-top:0}:host ::ng-deep .mat-form-field .mat-button-wrapper{display:flex;flex-direction:column;align-items:center;padding-top:8px}:host .ui-container{display:flex;flex-direction:column}:host .ui-container .image-preview{display:flex;flex-direction:column;align-content:space-between;justify-content:center;align-items:center;margin:8px 0;flex-grow:1}:host .ui-container .image-preview crispr-selected-file{width:100%}:host .ui-container .image-preview .drop-container{display:flex;box-sizing:border-box;flex-direction:column;align-items:center;border:3px dashed gray;height:100%;width:100%;align-content:center;justify-content:center;border-radius:8px}:host .ui-container .image-preview .drop-container .drop-icon{height:32px;width:32px;font-size:36px}:host .ui-container .image-preview .drop-container .mat-h2{margin:0}:host .ui-container .image-preview img{height:inherit;max-width:100%}:host .ui-container .button-container{display:flex;flex-direction:var(--image-upload-button-container-direction);justify-content:flex-end}:host .ui-container .button-container button{margin-left:8px}:host input{position:absolute;max-height:0;visibility:hidden}\n"] }]
1252
+ }], ctorParameters: function () {
1253
+ return [{ type: i4$1.NgControl, decorators: [{
1254
+ type: Optional
1255
+ }, {
1256
+ type: Self
1257
+ }] }, { type: i2$3.DomSanitizer }, { type: i0.ChangeDetectorRef }];
1258
+ }, propDecorators: { fileInputRef: [{
1259
+ type: ViewChild,
1260
+ args: ['fileInput']
1261
+ }] } });
1262
+ class ImageUploadFieldModule {
1263
+ }
1264
+ ImageUploadFieldModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: ImageUploadFieldModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1265
+ ImageUploadFieldModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: ImageUploadFieldModule, declarations: [ImageUploadFieldComponent], imports: [CommonModule,
1266
+ FieldContainerModule,
1267
+ ReactiveFormsModule,
1268
+ MatIconModule,
1269
+ MatButtonModule,
1270
+ MatFormFieldModule,
1271
+ MatInputModule,
1272
+ SelectedFileModule,
1273
+ FileUploadFieldModule,
1274
+ FormValidationHandlerModule], exports: [ImageUploadFieldComponent] });
1275
+ ImageUploadFieldModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: ImageUploadFieldModule, imports: [[
1276
+ CommonModule,
1277
+ FieldContainerModule,
1278
+ ReactiveFormsModule,
1279
+ MatIconModule,
1280
+ MatButtonModule,
1281
+ MatFormFieldModule,
1282
+ MatInputModule,
1283
+ SelectedFileModule,
1284
+ FileUploadFieldModule,
1285
+ FormValidationHandlerModule
1286
+ ]] });
1287
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: ImageUploadFieldModule, decorators: [{
1288
+ type: NgModule,
1289
+ args: [{
1290
+ imports: [
1291
+ CommonModule,
1292
+ FieldContainerModule,
1293
+ ReactiveFormsModule,
1294
+ MatIconModule,
1295
+ MatButtonModule,
1296
+ MatFormFieldModule,
1297
+ MatInputModule,
1298
+ SelectedFileModule,
1299
+ FileUploadFieldModule,
1300
+ FormValidationHandlerModule
1301
+ ],
1302
+ exports: [
1303
+ ImageUploadFieldComponent
1304
+ ],
1305
+ declarations: [
1306
+ ImageUploadFieldComponent
1307
+ ]
1308
+ }]
1309
+ }] });
1310
+ function maxFileSizeValidator(maxFileSize) {
1311
+ return (control) => {
1312
+ const controlValue = control.value;
1313
+ if (!(controlValue instanceof File)) {
1314
+ return null;
1315
+ }
1316
+ const actualFileSize = +convertBytesToMb(controlValue.size).toPrecision(3);
1317
+ if (maxFileSize > actualFileSize)
1318
+ return null;
1319
+ // control.setErrors({maxFileSize: { maxFileSize, actualFileSize }} )
1320
+ return { maxFileSize: { maxFileSize, actualFileSize } };
1321
+ };
1322
+ }
1323
+ function allowedFileExtValidator(allowedFileExtensions, onlyAllowFiles = true) {
1324
+ return (control) => {
1325
+ const controlValue = control.value;
1326
+ const isFile = controlValue instanceof File;
1327
+ if (!onlyAllowFiles && !isFile)
1328
+ return null;
1329
+ const actualExtension = isFile ? controlValue.name.split('.').pop().toLocaleLowerCase() : 'Not a file';
1330
+ const isAllowedExtension = allowedFileExtensions.includes(actualExtension);
1331
+ if (isAllowedExtension) {
1332
+ return null;
1333
+ }
1334
+ return { allowedExtension: { allowedFileExtensions, actualExtension } };
1335
+ };
1336
+ }
1337
+
1338
+ // TODO: Should we import UI library?
1339
+ // Will the tree shaker shake the unused modules?
1340
+ const MAT_DESIGN_MODULES = [
1341
+ MatIconModule,
1342
+ MatAutocompleteModule,
1343
+ MatDatepickerModule,
1344
+ MatInputModule,
1345
+ MatRadioModule,
1346
+ MatSelectModule,
1347
+ MatCheckboxModule,
1348
+ MatChipsModule,
1349
+ MatSliderModule,
1350
+ MatSlideToggleModule,
1351
+ MatButtonModule,
1352
+ MatButtonToggleModule,
1353
+ MatChipsModule,
1354
+ MatTooltipModule,
1355
+ MatFormFieldModule,
1356
+ MatMomentDateModule,
1357
+ MatDividerModule,
1358
+ MatProgressBarModule,
1359
+ PortalModule
1360
+ ];
1361
+ const CRISPR_FIELDS = [
1362
+ InputFieldComponent,
1363
+ SelectFieldComponent,
1364
+ RadioFieldComponent,
1365
+ AutocompleteFieldComponent,
1366
+ AutocompleteChiplistFieldComponent,
1367
+ CheckboxFieldComponent,
1368
+ TextareaFieldComponent,
1369
+ DatepickerFieldComponent,
1370
+ SliderFieldComponent,
1371
+ ButtonComponent,
1372
+ DividerComponent,
1373
+ UnitConversionFieldComponent,
1374
+ OptionComponent,
1375
+ ];
1376
+ class MaterialModule {
1377
+ }
1378
+ MaterialModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: MaterialModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1379
+ MaterialModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: MaterialModule, declarations: [InputFieldComponent,
1380
+ SelectFieldComponent,
1381
+ RadioFieldComponent,
1382
+ AutocompleteFieldComponent,
1383
+ AutocompleteChiplistFieldComponent,
1384
+ CheckboxFieldComponent,
1385
+ TextareaFieldComponent,
1386
+ DatepickerFieldComponent,
1387
+ SliderFieldComponent,
1388
+ ButtonComponent,
1389
+ DividerComponent,
1390
+ UnitConversionFieldComponent,
1391
+ OptionComponent], imports: [CommonModule,
1392
+ ReactiveFormsModule,
1393
+ FormValidationHandlerModule,
1394
+ InfoModule,
1395
+ FileUploadFieldModule,
1396
+ HeadingModule,
1397
+ FieldContainerModule, MatIconModule,
1398
+ MatAutocompleteModule,
1399
+ MatDatepickerModule,
1400
+ MatInputModule,
1401
+ MatRadioModule,
1402
+ MatSelectModule,
1403
+ MatCheckboxModule,
1404
+ MatChipsModule,
1405
+ MatSliderModule,
1406
+ MatSlideToggleModule,
1407
+ MatButtonModule,
1408
+ MatButtonToggleModule,
1409
+ MatChipsModule,
1410
+ MatTooltipModule,
1411
+ MatFormFieldModule,
1412
+ MatMomentDateModule,
1413
+ MatDividerModule,
1414
+ MatProgressBarModule,
1415
+ PortalModule], exports: [MatIconModule,
1416
+ MatAutocompleteModule,
1417
+ MatDatepickerModule,
1418
+ MatInputModule,
1419
+ MatRadioModule,
1420
+ MatSelectModule,
1421
+ MatCheckboxModule,
1422
+ MatChipsModule,
1423
+ MatSliderModule,
1424
+ MatSlideToggleModule,
1425
+ MatButtonModule,
1426
+ MatButtonToggleModule,
1427
+ MatChipsModule,
1428
+ MatTooltipModule,
1429
+ MatFormFieldModule,
1430
+ MatMomentDateModule,
1431
+ MatDividerModule,
1432
+ MatProgressBarModule,
1433
+ PortalModule, InputFieldComponent,
1434
+ SelectFieldComponent,
1435
+ RadioFieldComponent,
1436
+ AutocompleteFieldComponent,
1437
+ AutocompleteChiplistFieldComponent,
1438
+ CheckboxFieldComponent,
1439
+ TextareaFieldComponent,
1440
+ DatepickerFieldComponent,
1441
+ SliderFieldComponent,
1442
+ ButtonComponent,
1443
+ DividerComponent,
1444
+ UnitConversionFieldComponent,
1445
+ OptionComponent] });
1446
+ MaterialModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: MaterialModule, imports: [[
1447
+ CommonModule,
1448
+ ReactiveFormsModule,
1449
+ FormValidationHandlerModule,
1450
+ InfoModule,
1451
+ FileUploadFieldModule,
1452
+ HeadingModule,
1453
+ FieldContainerModule,
1454
+ ...MAT_DESIGN_MODULES,
1455
+ ], MatIconModule,
1456
+ MatAutocompleteModule,
1457
+ MatDatepickerModule,
1458
+ MatInputModule,
1459
+ MatRadioModule,
1460
+ MatSelectModule,
1461
+ MatCheckboxModule,
1462
+ MatChipsModule,
1463
+ MatSliderModule,
1464
+ MatSlideToggleModule,
1465
+ MatButtonModule,
1466
+ MatButtonToggleModule,
1467
+ MatChipsModule,
1468
+ MatTooltipModule,
1469
+ MatFormFieldModule,
1470
+ MatMomentDateModule,
1471
+ MatDividerModule,
1472
+ MatProgressBarModule,
1473
+ PortalModule] });
1474
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: MaterialModule, decorators: [{
1475
+ type: NgModule,
1476
+ args: [{
1477
+ imports: [
1478
+ CommonModule,
1479
+ ReactiveFormsModule,
1480
+ FormValidationHandlerModule,
1481
+ InfoModule,
1482
+ FileUploadFieldModule,
1483
+ HeadingModule,
1484
+ FieldContainerModule,
1485
+ ...MAT_DESIGN_MODULES,
1486
+ ],
1487
+ exports: [
1488
+ ...MAT_DESIGN_MODULES,
1489
+ ...CRISPR_FIELDS
1490
+ ],
1491
+ declarations: [
1492
+ ...CRISPR_FIELDS,
1493
+ ]
1494
+ }]
1495
+ }] });
1496
+
1497
+ var index$2 = /*#__PURE__*/Object.freeze({
1498
+ __proto__: null,
1499
+ InputFieldComponent: InputFieldComponent,
1500
+ SelectFieldComponent: SelectFieldComponent,
1501
+ AutocompleteFieldComponent: AutocompleteFieldComponent,
1502
+ AutocompleteChiplistFieldComponent: AutocompleteChiplistFieldComponent,
1503
+ CheckboxFieldComponent: CheckboxFieldComponent,
1504
+ TextareaFieldComponent: TextareaFieldComponent,
1505
+ SliderFieldComponent: SliderFieldComponent,
1506
+ ButtonComponent: ButtonComponent,
1507
+ DatepickerFieldComponent: DatepickerFieldComponent,
1508
+ HeadingComponent: HeadingComponent,
1509
+ HeadingModule: HeadingModule,
1510
+ DividerComponent: DividerComponent,
1511
+ RadioFieldComponent: RadioFieldComponent,
1512
+ UnitConversionFieldComponent: UnitConversionFieldComponent,
1513
+ ImageUploadFieldComponent: ImageUploadFieldComponent,
1514
+ ImageUploadFieldModule: ImageUploadFieldModule,
1515
+ maxFileSizeValidator: maxFileSizeValidator,
1516
+ allowedFileExtValidator: allowedFileExtValidator,
1517
+ FileDropzoneDirective: FileDropzoneDirective,
1518
+ FileUploadFieldComponent: FileUploadFieldComponent,
1519
+ FileUploadFieldModule: FileUploadFieldModule,
1520
+ MaterialModule: MaterialModule,
1521
+ OptionComponent: OptionComponent
1522
+ });
1523
+
1524
+ const FIELD_COMPONENTS = {
1525
+ groupList: Promise.resolve().then(function () { return index$1; }).then(({ FormGroupListComponent }) => FormGroupListComponent),
1526
+ subGroup: Promise.resolve().then(function () { return index; }).then(({ SubGroupComponent }) => SubGroupComponent),
1527
+ button: Promise.resolve().then(function () { return index$2; }).then(({ ButtonComponent }) => ButtonComponent),
1528
+ input: Promise.resolve().then(function () { return index$2; }).then(({ InputFieldComponent }) => InputFieldComponent),
1529
+ select: Promise.resolve().then(function () { return index$2; }).then(({ SelectFieldComponent }) => SelectFieldComponent),
1530
+ radio: Promise.resolve().then(function () { return index$2; }).then(({ RadioFieldComponent }) => RadioFieldComponent),
1531
+ autocomplete: Promise.resolve().then(function () { return index$2; }).then(({ AutocompleteFieldComponent }) => AutocompleteFieldComponent),
1532
+ autocompleteChiplist: Promise.resolve().then(function () { return index$2; }).then(({ AutocompleteChiplistFieldComponent }) => AutocompleteChiplistFieldComponent),
1533
+ textarea: Promise.resolve().then(function () { return index$2; }).then(({ TextareaFieldComponent }) => TextareaFieldComponent),
1534
+ checkbox: Promise.resolve().then(function () { return index$2; }).then(({ CheckboxFieldComponent }) => CheckboxFieldComponent),
1535
+ slider: Promise.resolve().then(function () { return index$2; }).then(({ SliderFieldComponent }) => SliderFieldComponent),
1536
+ datepicker: Promise.resolve().then(function () { return index$2; }).then(({ DatepickerFieldComponent }) => DatepickerFieldComponent),
1537
+ fileUpload: Promise.resolve().then(function () { return index$2; }).then(({ FileUploadFieldComponent }) => FileUploadFieldComponent),
1538
+ imageUpload: Promise.resolve().then(function () { return index$2; }).then(({ ImageUploadFieldComponent }) => ImageUploadFieldComponent),
1539
+ heading: Promise.resolve().then(function () { return index$2; }).then(({ HeadingComponent }) => HeadingComponent),
1540
+ divider: Promise.resolve().then(function () { return index$2; }).then(({ DividerComponent }) => DividerComponent),
1541
+ unitConversion: Promise.resolve().then(function () { return index$2; }).then(({ UnitConversionFieldComponent }) => UnitConversionFieldComponent)
1542
+ };
1543
+ function isControlComponent(component) {
1544
+ return isControlConfig(component.config) || component.config.controlType === ControlType.BUTTON;
1545
+ }
1546
+
1547
+ class CrisprFieldDirective {
1548
+ constructor(container, renderer, cdr) {
1549
+ this.container = container;
1550
+ this.renderer = renderer;
1551
+ this.cdr = cdr;
1552
+ }
1553
+ ngOnInit() {
1554
+ return __awaiter(this, void 0, void 0, function* () {
1555
+ /**
1556
+ * create component and set values from config on its instance
1557
+ */
1558
+ const component = this.config.component || (yield FIELD_COMPONENTS[this.config.controlType]);
1559
+ const componentRef = this.container.createComponent(component);
1560
+ this.component = componentRef.instance;
1561
+ this.component.config = this.config;
1562
+ if (isControlComponent(this.component)) {
1563
+ this.component.group = this.group;
1564
+ if ('value' in this.component) {
1565
+ this.component.value = this.value;
1566
+ }
1567
+ }
1568
+ this.cdr.detectChanges();
1569
+ // adds any config classes to the dynamically generated component
1570
+ // doing this here keeps us from having to extend a base component into each field component individually
1571
+ if (!this.config.classes)
1572
+ return;
1573
+ this.config.classes.forEach((klass) => {
1574
+ // check for passing multiple classes in one array element
1575
+ if (klass.includes(' ')) {
1576
+ throw Error(`Improperly formatted class. '${klass}' cannot contain spaces.`);
1577
+ }
1578
+ else {
1579
+ this.renderer.addClass(componentRef.location.nativeElement, klass);
1580
+ }
1581
+ });
1582
+ });
1583
+ }
1584
+ }
1585
+ CrisprFieldDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFieldDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
1586
+ CrisprFieldDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.1", type: CrisprFieldDirective, selector: "[crisprField]", inputs: { config: "config", group: "group", value: "value" }, ngImport: i0 });
1587
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFieldDirective, decorators: [{
1588
+ type: Directive,
1589
+ args: [{
1590
+ selector: '[crisprField]'
1591
+ }]
1592
+ }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { config: [{
1593
+ type: Input
1594
+ }], group: [{
1595
+ type: Input
1596
+ }], value: [{
1597
+ type: Input
1598
+ }] } });
1599
+ class CrisprFieldModule {
1600
+ }
1601
+ CrisprFieldModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFieldModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1602
+ CrisprFieldModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFieldModule, declarations: [CrisprFieldDirective], imports: [CommonModule], exports: [CrisprFieldDirective] });
1603
+ CrisprFieldModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFieldModule, imports: [[
1604
+ CommonModule,
1605
+ ]] });
1606
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFieldModule, decorators: [{
1607
+ type: NgModule,
1608
+ args: [{
1609
+ imports: [
1610
+ CommonModule,
1611
+ ],
1612
+ exports: [
1613
+ CrisprFieldDirective
1614
+ ],
1615
+ declarations: [
1616
+ CrisprFieldDirective
1617
+ ]
1618
+ }]
1619
+ }] });
1620
+
1621
+ class InitialControlValuePipe {
1622
+ // TODO: does changing any to unknown break anything?
1623
+ transform(initialFormValue, fieldConfig) {
1624
+ return (initialFormValue && isControlConfig(fieldConfig))
1625
+ ? initialFormValue[fieldConfig.controlName] || null
1626
+ : null;
1627
+ }
1628
+ }
1629
+ InitialControlValuePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: InitialControlValuePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1630
+ InitialControlValuePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: InitialControlValuePipe, name: "initialControlValue" });
1631
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: InitialControlValuePipe, decorators: [{
1632
+ type: Pipe,
1633
+ args: [{
1634
+ name: 'initialControlValue'
1635
+ }]
1636
+ }] });
1637
+
1638
+ class CrisprFormComponent {
1639
+ constructor() {
1640
+ this.form = new FormGroup({});
1641
+ this.value = null;
1642
+ this.submitted = new EventEmitter();
1643
+ // proxy value and status change events through to consuming component
1644
+ this.valueChanges = this.form.valueChanges;
1645
+ this.statusChanges = this.form.statusChanges;
1646
+ this.subs = [];
1647
+ }
1648
+ ngOnInit() {
1649
+ // build out the form, note that we pass in the form as the third argument and the function modifies it
1650
+ buildFormGroupFromConfig(this.config, this.value, this.form);
1651
+ }
1652
+ handleSubmit() {
1653
+ this.form.markAllAsTouched();
1654
+ this.submitted.emit(this.form);
1655
+ }
1656
+ triggerSubmit() {
1657
+ this.submitTrigger.nativeElement.click();
1658
+ }
1659
+ }
1660
+ CrisprFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1661
+ CrisprFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: CrisprFormComponent, selector: "crispr-form", inputs: { config: "config", form: "form", value: "value" }, outputs: { submitted: "submitted", valueChanges: "valueChanges", statusChanges: "statusChanges" }, viewQueries: [{ propertyName: "submitTrigger", first: true, predicate: ["submitTrigger"], descendants: true }], ngImport: i0, template: "<form\n class=\"crispr-form\"\n [ngClass]=\"config.classes\"\n [formGroup]=\"form\"\n (ngSubmit)=\"handleSubmit()\"\n [autocomplete]=\"config.autocomplete || 'off'\"\n [errorDictionary]=\"config.errorDictionary\"\n #ngFormElement=\"ngForm\">\n\n <ng-container\n *ngFor=\"let field of config.fields;\"\n crisprField\n [value]=\"value | initialControlValue : field\"\n [config]=\"field\"\n [group]=\"form\">\n </ng-container>\n <!-- Hidden button, programmatically clicked when crispr form triggerSubmit function called.\n Uses a hidden button with type=\"submit\" because it will trigger both native form submit event\n (which the error handler has to listen for) and ngSubmit event -->\n <button #submitTrigger class=\"submit-trigger\" type=\"submit\">\n </button>\n</form>\n", styles: [".submit-trigger{display:none}\n"], directives: [{ type: i4$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i4$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i5.ControlErrorsFormDirective, selector: "form", inputs: ["errorDictionary"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i4$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.ControlErrorContainerDirective, selector: "[controlErrorContainer], [formGroup]" }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: CrisprFieldDirective, selector: "[crisprField]", inputs: ["config", "group", "value"] }], pipes: { "initialControlValue": InitialControlValuePipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
1662
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFormComponent, decorators: [{
1663
+ type: Component,
1664
+ args: [{ selector: 'crispr-form', changeDetection: ChangeDetectionStrategy.OnPush, template: "<form\n class=\"crispr-form\"\n [ngClass]=\"config.classes\"\n [formGroup]=\"form\"\n (ngSubmit)=\"handleSubmit()\"\n [autocomplete]=\"config.autocomplete || 'off'\"\n [errorDictionary]=\"config.errorDictionary\"\n #ngFormElement=\"ngForm\">\n\n <ng-container\n *ngFor=\"let field of config.fields;\"\n crisprField\n [value]=\"value | initialControlValue : field\"\n [config]=\"field\"\n [group]=\"form\">\n </ng-container>\n <!-- Hidden button, programmatically clicked when crispr form triggerSubmit function called.\n Uses a hidden button with type=\"submit\" because it will trigger both native form submit event\n (which the error handler has to listen for) and ngSubmit event -->\n <button #submitTrigger class=\"submit-trigger\" type=\"submit\">\n </button>\n</form>\n", styles: [".submit-trigger{display:none}\n"] }]
1665
+ }], propDecorators: { config: [{
1666
+ type: Input
1667
+ }], form: [{
1668
+ type: Input
1669
+ }], value: [{
1670
+ type: Input
1671
+ }], submitted: [{
1672
+ type: Output
1673
+ }], valueChanges: [{
1674
+ type: Output
1675
+ }], statusChanges: [{
1676
+ type: Output
1677
+ }], submitTrigger: [{
1678
+ type: ViewChild,
1679
+ args: ['submitTrigger']
1680
+ }] } });
1681
+
1682
+ const defaultConfig = {
1683
+ addButtonLabel: 'ADD ITEM',
1684
+ minListLength: 1,
1685
+ };
1686
+ const FormGroupListMixin = crisprControlMixin(CrisprFieldComponent);
1687
+ class FormGroupListComponent extends FormGroupListMixin {
1688
+ constructor() {
1689
+ super(...arguments);
1690
+ this.defaultConfig = defaultConfig;
1691
+ }
1692
+ ngOnInit() {
1693
+ super.ngOnInit();
1694
+ // TODO: this is required to ngFor of controls in template, must be a better way
1695
+ this.formArray = this.control;
1696
+ }
1697
+ setControlValue(values) {
1698
+ if (this.control) {
1699
+ if ((values === null || values === void 0 ? void 0 : values.length) > 0) {
1700
+ values.forEach(value => this.addGroup(value));
1701
+ }
1702
+ else if (this.config.displayInitialItem) {
1703
+ this.addGroup();
1704
+ }
1705
+ }
1706
+ }
1707
+ addGroup(value = null) {
1708
+ this.control.push(createControlForType(this.config.itemConfig, value));
1709
+ }
1710
+ deleteGroup(index) {
1711
+ this.control.removeAt(index);
1712
+ }
1713
+ }
1714
+ FormGroupListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FormGroupListComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1715
+ FormGroupListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: FormGroupListComponent, selector: "crispr-form-group-list", usesInheritance: true, ngImport: i0, template: "\n<crispr-field-container\n [config]=\"config\"\n [group]=\"group\"\n [formGroup]=\"group\">\n\n <div [formArrayName]=\"config.controlName\">\n <!-- TODO: add sortBy function -->\n <div *ngFor=\"let control of formArray?.controls; let i = index;\">\n <!-- TODO: use content projection to allow custom item label component -->\n <div class=\"item-header\">\n <span class=\"mat-h2\" *ngIf=\"config.itemLabelBuilder\"> {{ config.itemLabelBuilder(i) }} </span>\n <button\n mat-icon-button\n *ngIf=\"i + 1 > config.minListLength\">\n <mat-icon (click)=\"deleteGroup(i)\">delete</mat-icon>\n </button>\n </div>\n <div\n [formGroupName]=\"i\">\n <ng-container\n *ngFor=\"let field of config.itemConfig.fields;\"\n crisprField\n [config]=\"field\"\n [value]=\"value && value[i] | initialControlValue : field\"\n [group]=\"control\">\n </ng-container>\n </div>\n </div>\n </div>\n <div class=\"group-footer\">\n <button\n type=\"button\"\n class=\"add\"\n mat-raised-button\n [color]=\"config.addButtonColor\"\n (click)=\"addGroup()\">\n {{config.addItemLabel || config.addButtonLabel}}\n </button>\n </div>\n\n</crispr-field-container>\n", styles: [".item-header{display:flex;justify-content:space-between}.group-footer{display:flex;justify-content:flex-end}.group-footer button.add{margin-bottom:16px}\n"], components: [{ type: FieldContainerComponent, selector: "crispr-field-container", inputs: ["config", "group", "inlineField"] }, { type: i1.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i4$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.ControlErrorContainerDirective, selector: "[controlErrorContainer], [formGroup]" }, { type: i4$1.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4$1.FormGroupName, selector: "[formGroupName]", inputs: ["formGroupName"] }, { type: CrisprFieldDirective, selector: "[crisprField]", inputs: ["config", "group", "value"] }], pipes: { "initialControlValue": InitialControlValuePipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
1716
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FormGroupListComponent, decorators: [{
1717
+ type: Component,
1718
+ args: [{ selector: 'crispr-form-group-list', changeDetection: ChangeDetectionStrategy.OnPush, template: "\n<crispr-field-container\n [config]=\"config\"\n [group]=\"group\"\n [formGroup]=\"group\">\n\n <div [formArrayName]=\"config.controlName\">\n <!-- TODO: add sortBy function -->\n <div *ngFor=\"let control of formArray?.controls; let i = index;\">\n <!-- TODO: use content projection to allow custom item label component -->\n <div class=\"item-header\">\n <span class=\"mat-h2\" *ngIf=\"config.itemLabelBuilder\"> {{ config.itemLabelBuilder(i) }} </span>\n <button\n mat-icon-button\n *ngIf=\"i + 1 > config.minListLength\">\n <mat-icon (click)=\"deleteGroup(i)\">delete</mat-icon>\n </button>\n </div>\n <div\n [formGroupName]=\"i\">\n <ng-container\n *ngFor=\"let field of config.itemConfig.fields;\"\n crisprField\n [config]=\"field\"\n [value]=\"value && value[i] | initialControlValue : field\"\n [group]=\"control\">\n </ng-container>\n </div>\n </div>\n </div>\n <div class=\"group-footer\">\n <button\n type=\"button\"\n class=\"add\"\n mat-raised-button\n [color]=\"config.addButtonColor\"\n (click)=\"addGroup()\">\n {{config.addItemLabel || config.addButtonLabel}}\n </button>\n </div>\n\n</crispr-field-container>\n", styles: [".item-header{display:flex;justify-content:space-between}.group-footer{display:flex;justify-content:flex-end}.group-footer button.add{margin-bottom:16px}\n"] }]
1719
+ }] });
1720
+
1721
+ class CrisprPipesModule {
1722
+ }
1723
+ CrisprPipesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1724
+ CrisprPipesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprPipesModule, declarations: [InitialControlValuePipe], imports: [CommonModule], exports: [InitialControlValuePipe] });
1725
+ CrisprPipesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprPipesModule, imports: [[
1726
+ CommonModule
1727
+ ]] });
1728
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprPipesModule, decorators: [{
1729
+ type: NgModule,
1730
+ args: [{
1731
+ imports: [
1732
+ CommonModule
1733
+ ],
1734
+ exports: [
1735
+ InitialControlValuePipe
1736
+ ],
1737
+ declarations: [
1738
+ InitialControlValuePipe
1739
+ ]
1740
+ }]
1741
+ }] });
1742
+
1743
+ class FormGroupListModule {
1744
+ }
1745
+ FormGroupListModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FormGroupListModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1746
+ FormGroupListModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FormGroupListModule, declarations: [FormGroupListComponent], imports: [CommonModule,
1747
+ MatButtonModule,
1748
+ MatIconModule,
1749
+ FieldContainerModule,
1750
+ ReactiveFormsModule,
1751
+ CrisprFieldModule,
1752
+ CrisprPipesModule,
1753
+ FormValidationHandlerModule], exports: [FormGroupListComponent] });
1754
+ FormGroupListModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FormGroupListModule, imports: [[
1755
+ CommonModule,
1756
+ MatButtonModule,
1757
+ MatIconModule,
1758
+ FieldContainerModule,
1759
+ ReactiveFormsModule,
1760
+ CrisprFieldModule,
1761
+ CrisprPipesModule,
1762
+ FormValidationHandlerModule
1763
+ ]] });
1764
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FormGroupListModule, decorators: [{
1765
+ type: NgModule,
1766
+ args: [{
1767
+ imports: [
1768
+ CommonModule,
1769
+ MatButtonModule,
1770
+ MatIconModule,
1771
+ FieldContainerModule,
1772
+ ReactiveFormsModule,
1773
+ CrisprFieldModule,
1774
+ CrisprPipesModule,
1775
+ FormValidationHandlerModule
1776
+ ],
1777
+ exports: [
1778
+ FormGroupListComponent
1779
+ ],
1780
+ declarations: [
1781
+ FormGroupListComponent
1782
+ ]
1783
+ }]
1784
+ }] });
1785
+
1786
+ var index$1 = /*#__PURE__*/Object.freeze({
1787
+ __proto__: null,
1788
+ FormGroupListComponent: FormGroupListComponent,
1789
+ FormGroupListModule: FormGroupListModule
1790
+ });
1791
+
1792
+ const FormGroupMixin = crisprControlMixin(CrisprFieldComponent);
1793
+ class SubGroupComponent extends FormGroupMixin {
1794
+ ngOnInit() {
1795
+ super.ngOnInit();
1796
+ }
1797
+ }
1798
+ SubGroupComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: SubGroupComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1799
+ SubGroupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: SubGroupComponent, selector: "crispr-sub-group", usesInheritance: true, ngImport: i0, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n <ng-container\n *ngFor=\"let fieldConfig of config.fields;\"\n crisprField\n [value]=\"value | initialControlValue : fieldConfig\"\n [config]=\"fieldConfig\"\n [group]=\"control\">\n </ng-container>\n</crispr-field-container>\n\n", styles: [""], components: [{ type: FieldContainerComponent, selector: "crispr-field-container", inputs: ["config", "group", "inlineField"] }], directives: [{ type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: CrisprFieldDirective, selector: "[crisprField]", inputs: ["config", "group", "value"] }], pipes: { "initialControlValue": InitialControlValuePipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
1800
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: SubGroupComponent, decorators: [{
1801
+ type: Component,
1802
+ args: [{ selector: 'crispr-sub-group', changeDetection: ChangeDetectionStrategy.OnPush, template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n <ng-container\n *ngFor=\"let fieldConfig of config.fields;\"\n crisprField\n [value]=\"value | initialControlValue : fieldConfig\"\n [config]=\"fieldConfig\"\n [group]=\"control\">\n </ng-container>\n</crispr-field-container>\n\n", styles: [""] }]
1803
+ }] });
1804
+
1805
+ class SubGroupModule {
1806
+ }
1807
+ SubGroupModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: SubGroupModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1808
+ SubGroupModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: SubGroupModule, declarations: [SubGroupComponent], imports: [CommonModule,
1809
+ CrisprFieldModule,
1810
+ FieldContainerModule,
1811
+ CrisprPipesModule,
1812
+ // TODO: Does this need to be here?
1813
+ FormValidationHandlerModule], exports: [SubGroupComponent] });
1814
+ SubGroupModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: SubGroupModule, imports: [[
1815
+ CommonModule,
1816
+ CrisprFieldModule,
1817
+ FieldContainerModule,
1818
+ CrisprPipesModule,
1819
+ // TODO: Does this need to be here?
1820
+ FormValidationHandlerModule
1821
+ ]] });
1822
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: SubGroupModule, decorators: [{
1823
+ type: NgModule,
1824
+ args: [{
1825
+ imports: [
1826
+ CommonModule,
1827
+ CrisprFieldModule,
1828
+ FieldContainerModule,
1829
+ CrisprPipesModule,
1830
+ // TODO: Does this need to be here?
1831
+ FormValidationHandlerModule
1832
+ ],
1833
+ exports: [
1834
+ SubGroupComponent
1835
+ ],
1836
+ declarations: [
1837
+ SubGroupComponent
1838
+ ]
1839
+ }]
1840
+ }] });
1841
+
1842
+ var index = /*#__PURE__*/Object.freeze({
1843
+ __proto__: null,
1844
+ SubGroupComponent: SubGroupComponent,
1845
+ SubGroupModule: SubGroupModule
1846
+ });
1847
+
1848
+ class CrisprFormsModule {
1849
+ }
1850
+ CrisprFormsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFormsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1851
+ CrisprFormsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFormsModule, declarations: [CrisprFormComponent], imports: [CommonModule,
1852
+ ReactiveFormsModule,
1853
+ FormValidationHandlerModule,
1854
+ FormGroupListModule,
1855
+ FieldContainerModule,
1856
+ CrisprFieldModule,
1857
+ SubGroupModule,
1858
+ MaterialModule,
1859
+ CrisprPipesModule], exports: [CrisprFormComponent,
1860
+ FieldContainerModule,
1861
+ MaterialModule] });
1862
+ CrisprFormsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFormsModule, imports: [[
1863
+ CommonModule,
1864
+ ReactiveFormsModule,
1865
+ FormValidationHandlerModule,
1866
+ FormGroupListModule,
1867
+ FieldContainerModule,
1868
+ CrisprFieldModule,
1869
+ SubGroupModule,
1870
+ MaterialModule,
1871
+ CrisprPipesModule,
1872
+ ], FieldContainerModule,
1873
+ MaterialModule] });
1874
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFormsModule, decorators: [{
1875
+ type: NgModule,
1876
+ args: [{
1877
+ imports: [
1878
+ CommonModule,
1879
+ ReactiveFormsModule,
1880
+ FormValidationHandlerModule,
1881
+ FormGroupListModule,
1882
+ FieldContainerModule,
1883
+ CrisprFieldModule,
1884
+ SubGroupModule,
1885
+ MaterialModule,
1886
+ CrisprPipesModule,
1887
+ ],
1888
+ declarations: [
1889
+ CrisprFormComponent,
1890
+ ],
1891
+ exports: [
1892
+ CrisprFormComponent,
1893
+ FieldContainerModule,
1894
+ MaterialModule
1895
+ ]
1896
+ }]
1897
+ }] });
1898
+
1899
+ /**
1900
+ * Generated bundle index. Do not edit.
1901
+ */
1902
+
1903
+ export { AbstractAutocompleteComponent, AutocompleteChiplistFieldComponent, AutocompleteFieldComponent, ButtonComponent, CheckboxFieldComponent, ControlType, CrisprFieldComponent, CrisprFormComponent, CrisprFormsModule, DEFAULT_EMPTY_OPTIONS_MESSAGE, DatepickerFieldComponent, DividerComponent, FieldContainerComponent, FieldContainerModule, FileDropzoneDirective, FileUploadFieldComponent, FileUploadFieldModule, HeadingComponent, HeadingModule, ImageUploadFieldComponent, ImageUploadFieldModule, InputFieldComponent, MaterialModule, OptionComponent, RadioFieldComponent, SelectFieldComponent, SliderFieldComponent, TextareaFieldComponent, UnitConversionFieldComponent, allowedFileExtValidator, buildFormGroupFromConfig, callOptionsIfFunction, checkControlForValues, checkControlsForValues, computeValueFromFields, createControlForType, crisprControlMixin, filterOptionsByLabel, isControlConfig, maxFileSizeValidator, observablifyOptions };
1904
+ //# sourceMappingURL=tft-crispr-forms.mjs.map