@dereekb/dbx-form 0.0.1

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 (217) hide show
  1. package/README.md +6 -0
  2. package/dereekb-dbx-form.d.ts +5 -0
  3. package/esm2020/dereekb-dbx-form.mjs +5 -0
  4. package/esm2020/index.mjs +2 -0
  5. package/esm2020/lib/form/action/form.action.directive.mjs +131 -0
  6. package/esm2020/lib/form/action/form.action.module.mjs +30 -0
  7. package/esm2020/lib/form/action/index.mjs +3 -0
  8. package/esm2020/lib/form/form.changes.directive.mjs +33 -0
  9. package/esm2020/lib/form/form.input.directive.mjs +49 -0
  10. package/esm2020/lib/form/form.mjs +20 -0
  11. package/esm2020/lib/form/form.module.mjs +36 -0
  12. package/esm2020/lib/form/index.mjs +7 -0
  13. package/esm2020/lib/form/loading/form.loading.directive.mjs +52 -0
  14. package/esm2020/lib/form/loading/index.mjs +2 -0
  15. package/esm2020/lib/formly/field/checklist/checklist.item.field.component.mjs +91 -0
  16. package/esm2020/lib/formly/field/checklist/checklist.item.field.content.default.component.mjs +38 -0
  17. package/esm2020/lib/formly/field/checklist/checklist.item.field.mjs +119 -0
  18. package/esm2020/lib/formly/field/checklist/checklist.item.field.module.mjs +81 -0
  19. package/esm2020/lib/formly/field/checklist/checklist.item.mjs +2 -0
  20. package/esm2020/lib/formly/field/checklist/index.mjs +6 -0
  21. package/esm2020/lib/formly/field/component/component.field.component.mjs +35 -0
  22. package/esm2020/lib/formly/field/component/component.field.mjs +7 -0
  23. package/esm2020/lib/formly/field/component/component.field.module.mjs +42 -0
  24. package/esm2020/lib/formly/field/component/index.mjs +4 -0
  25. package/esm2020/lib/formly/field/field.mjs +21 -0
  26. package/esm2020/lib/formly/field/index.mjs +7 -0
  27. package/esm2020/lib/formly/field/selection/index.mjs +4 -0
  28. package/esm2020/lib/formly/field/selection/pickable/index.mjs +6 -0
  29. package/esm2020/lib/formly/field/selection/pickable/pickable.chip.field.component.mjs +30 -0
  30. package/esm2020/lib/formly/field/selection/pickable/pickable.field.directive.mjs +244 -0
  31. package/esm2020/lib/formly/field/selection/pickable/pickable.field.module.mjs +96 -0
  32. package/esm2020/lib/formly/field/selection/pickable/pickable.list.field.component.mjs +30 -0
  33. package/esm2020/lib/formly/field/selection/pickable/pickable.mjs +2 -0
  34. package/esm2020/lib/formly/field/selection/searchable/index.mjs +9 -0
  35. package/esm2020/lib/formly/field/selection/searchable/searchable.chip.field.component.mjs +45 -0
  36. package/esm2020/lib/formly/field/selection/searchable/searchable.field.autocomplete.item.component.mjs +73 -0
  37. package/esm2020/lib/formly/field/selection/searchable/searchable.field.directive.mjs +237 -0
  38. package/esm2020/lib/formly/field/selection/searchable/searchable.field.mjs +45 -0
  39. package/esm2020/lib/formly/field/selection/searchable/searchable.field.module.mjs +107 -0
  40. package/esm2020/lib/formly/field/selection/searchable/searchable.mjs +2 -0
  41. package/esm2020/lib/formly/field/selection/searchable/searchable.text.field.component.mjs +31 -0
  42. package/esm2020/lib/formly/field/selection/searchable/text.chip.field.mjs +15 -0
  43. package/esm2020/lib/formly/field/selection/selection.mjs +2 -0
  44. package/esm2020/lib/formly/field/value/array/array.field.component.mjs +87 -0
  45. package/esm2020/lib/formly/field/value/array/array.field.module.mjs +52 -0
  46. package/esm2020/lib/formly/field/value/array/index.mjs +3 -0
  47. package/esm2020/lib/formly/field/value/boolean/boolean.field.mjs +50 -0
  48. package/esm2020/lib/formly/field/value/boolean/boolean.field.module.mjs +16 -0
  49. package/esm2020/lib/formly/field/value/boolean/index.mjs +3 -0
  50. package/esm2020/lib/formly/field/value/date/date.field.mjs +36 -0
  51. package/esm2020/lib/formly/field/value/date/date.field.module.mjs +87 -0
  52. package/esm2020/lib/formly/field/value/date/datetime.field.component.mjs +226 -0
  53. package/esm2020/lib/formly/field/value/date/index.mjs +4 -0
  54. package/esm2020/lib/formly/field/value/enum/enum.field.mjs +18 -0
  55. package/esm2020/lib/formly/field/value/enum/enum.mjs +2 -0
  56. package/esm2020/lib/formly/field/value/enum/index.mjs +4 -0
  57. package/esm2020/lib/formly/field/value/hidden.field.mjs +8 -0
  58. package/esm2020/lib/formly/field/value/index.mjs +8 -0
  59. package/esm2020/lib/formly/field/value/phone/index.mjs +4 -0
  60. package/esm2020/lib/formly/field/value/phone/phone.field.component.mjs +44 -0
  61. package/esm2020/lib/formly/field/value/phone/phone.field.mjs +64 -0
  62. package/esm2020/lib/formly/field/value/phone/phone.field.module.mjs +67 -0
  63. package/esm2020/lib/formly/field/value/text/index.mjs +4 -0
  64. package/esm2020/lib/formly/field/value/text/text.address.field.mjs +65 -0
  65. package/esm2020/lib/formly/field/value/text/text.field.mjs +125 -0
  66. package/esm2020/lib/formly/field/value/text/text.field.module.mjs +19 -0
  67. package/esm2020/lib/formly/field/wrapper/autotouch.wrapper.component.mjs +26 -0
  68. package/esm2020/lib/formly/field/wrapper/expandable.wrapper.component.mjs +83 -0
  69. package/esm2020/lib/formly/field/wrapper/flex.wrapper.component.mjs +22 -0
  70. package/esm2020/lib/formly/field/wrapper/flex.wrapper.layout.mjs +20 -0
  71. package/esm2020/lib/formly/field/wrapper/form.wrapper.module.mjs +84 -0
  72. package/esm2020/lib/formly/field/wrapper/index.mjs +11 -0
  73. package/esm2020/lib/formly/field/wrapper/info.wrapper.component.mjs +47 -0
  74. package/esm2020/lib/formly/field/wrapper/section.wrapper.component.mjs +35 -0
  75. package/esm2020/lib/formly/field/wrapper/subsection.wrapper.component.mjs +35 -0
  76. package/esm2020/lib/formly/field/wrapper/toggle.wrapper.component.mjs +58 -0
  77. package/esm2020/lib/formly/field/wrapper/toggle.wrapper.mjs +10 -0
  78. package/esm2020/lib/formly/formly.component.mjs +134 -0
  79. package/esm2020/lib/formly/formly.context.mjs +111 -0
  80. package/esm2020/lib/formly/formly.directive.mjs +101 -0
  81. package/esm2020/lib/formly/formly.module.mjs +59 -0
  82. package/esm2020/lib/formly/index.mjs +6 -0
  83. package/esm2020/lib/index.mjs +5 -0
  84. package/esm2020/lib/layout/form.layout.module.mjs +26 -0
  85. package/esm2020/lib/layout/form.spacer.component.mjs +17 -0
  86. package/esm2020/lib/layout/index.mjs +3 -0
  87. package/esm2020/lib/validator/boolean.mjs +12 -0
  88. package/esm2020/lib/validator/email.mjs +6 -0
  89. package/esm2020/lib/validator/index.mjs +4 -0
  90. package/esm2020/lib/validator/number.mjs +21 -0
  91. package/fesm2015/dereekb-dbx-form.mjs +3295 -0
  92. package/fesm2015/dereekb-dbx-form.mjs.map +1 -0
  93. package/fesm2020/dereekb-dbx-form.mjs +3289 -0
  94. package/fesm2020/dereekb-dbx-form.mjs.map +1 -0
  95. package/index.d.ts +1 -0
  96. package/lib/form/action/form.action.directive.d.ts +44 -0
  97. package/lib/form/action/form.action.module.d.ts +9 -0
  98. package/lib/form/action/index.d.ts +2 -0
  99. package/lib/form/form.changes.directive.d.ts +15 -0
  100. package/lib/form/form.d.ts +51 -0
  101. package/lib/form/form.input.directive.d.ts +18 -0
  102. package/lib/form/form.module.d.ts +10 -0
  103. package/lib/form/index.d.ts +6 -0
  104. package/lib/form/loading/form.loading.directive.d.ts +19 -0
  105. package/lib/form/loading/index.d.ts +1 -0
  106. package/lib/formly/field/checklist/checklist.item.d.ts +38 -0
  107. package/lib/formly/field/checklist/checklist.item.field.component.d.ts +48 -0
  108. package/lib/formly/field/checklist/checklist.item.field.content.default.component.d.ts +10 -0
  109. package/lib/formly/field/checklist/checklist.item.field.d.ts +50 -0
  110. package/lib/formly/field/checklist/checklist.item.field.module.d.ts +18 -0
  111. package/lib/formly/field/checklist/index.d.ts +5 -0
  112. package/lib/formly/field/component/component.field.component.d.ts +22 -0
  113. package/lib/formly/field/component/component.field.d.ts +6 -0
  114. package/lib/formly/field/component/component.field.module.d.ts +10 -0
  115. package/lib/formly/field/component/index.d.ts +3 -0
  116. package/lib/formly/field/field.d.ts +31 -0
  117. package/lib/formly/field/index.d.ts +6 -0
  118. package/lib/formly/field/selection/index.d.ts +3 -0
  119. package/lib/formly/field/selection/pickable/index.d.ts +5 -0
  120. package/lib/formly/field/selection/pickable/pickable.chip.field.component.d.ts +10 -0
  121. package/lib/formly/field/selection/pickable/pickable.d.ts +28 -0
  122. package/lib/formly/field/selection/pickable/pickable.field.directive.d.ts +155 -0
  123. package/lib/formly/field/selection/pickable/pickable.field.module.d.ts +20 -0
  124. package/lib/formly/field/selection/pickable/pickable.list.field.component.d.ts +11 -0
  125. package/lib/formly/field/selection/searchable/index.d.ts +8 -0
  126. package/lib/formly/field/selection/searchable/searchable.chip.field.component.d.ts +16 -0
  127. package/lib/formly/field/selection/searchable/searchable.d.ts +40 -0
  128. package/lib/formly/field/selection/searchable/searchable.field.autocomplete.item.component.d.ts +20 -0
  129. package/lib/formly/field/selection/searchable/searchable.field.d.ts +16 -0
  130. package/lib/formly/field/selection/searchable/searchable.field.directive.d.ts +131 -0
  131. package/lib/formly/field/selection/searchable/searchable.field.module.d.ts +21 -0
  132. package/lib/formly/field/selection/searchable/searchable.text.field.component.d.ts +15 -0
  133. package/lib/formly/field/selection/searchable/text.chip.field.d.ts +9 -0
  134. package/lib/formly/field/selection/selection.d.ts +25 -0
  135. package/lib/formly/field/value/array/array.field.component.d.ts +22 -0
  136. package/lib/formly/field/value/array/array.field.module.d.ts +13 -0
  137. package/lib/formly/field/value/array/index.d.ts +2 -0
  138. package/lib/formly/field/value/boolean/boolean.field.d.ts +8 -0
  139. package/lib/formly/field/value/boolean/boolean.field.module.d.ts +6 -0
  140. package/lib/formly/field/value/boolean/index.d.ts +2 -0
  141. package/lib/formly/field/value/date/date.field.d.ts +13 -0
  142. package/lib/formly/field/value/date/date.field.module.d.ts +21 -0
  143. package/lib/formly/field/value/date/datetime.field.component.d.ts +105 -0
  144. package/lib/formly/field/value/date/index.d.ts +3 -0
  145. package/lib/formly/field/value/enum/enum.d.ts +4 -0
  146. package/lib/formly/field/value/enum/enum.field.d.ts +14 -0
  147. package/lib/formly/field/value/enum/index.d.ts +2 -0
  148. package/lib/formly/field/value/hidden.field.d.ts +5 -0
  149. package/lib/formly/field/value/index.d.ts +7 -0
  150. package/lib/formly/field/value/phone/index.d.ts +3 -0
  151. package/lib/formly/field/value/phone/phone.field.component.d.ts +24 -0
  152. package/lib/formly/field/value/phone/phone.field.d.ts +26 -0
  153. package/lib/formly/field/value/phone/phone.field.module.d.ts +16 -0
  154. package/lib/formly/field/value/text/index.d.ts +3 -0
  155. package/lib/formly/field/value/text/text.address.field.d.ts +12 -0
  156. package/lib/formly/field/value/text/text.field.d.ts +42 -0
  157. package/lib/formly/field/value/text/text.field.module.d.ts +7 -0
  158. package/lib/formly/field/wrapper/autotouch.wrapper.component.d.ts +11 -0
  159. package/lib/formly/field/wrapper/expandable.wrapper.component.d.ts +43 -0
  160. package/lib/formly/field/wrapper/flex.wrapper.component.d.ts +6 -0
  161. package/lib/formly/field/wrapper/flex.wrapper.layout.d.ts +10 -0
  162. package/lib/formly/field/wrapper/form.wrapper.module.d.ts +19 -0
  163. package/lib/formly/field/wrapper/index.d.ts +10 -0
  164. package/lib/formly/field/wrapper/info.wrapper.component.d.ts +17 -0
  165. package/lib/formly/field/wrapper/section.wrapper.component.d.ts +8 -0
  166. package/lib/formly/field/wrapper/subsection.wrapper.component.d.ts +8 -0
  167. package/lib/formly/field/wrapper/toggle.wrapper.component.d.ts +24 -0
  168. package/lib/formly/field/wrapper/toggle.wrapper.d.ts +7 -0
  169. package/lib/formly/formly.component.d.ts +36 -0
  170. package/lib/formly/formly.context.d.ts +57 -0
  171. package/lib/formly/formly.directive.d.ts +50 -0
  172. package/lib/formly/formly.module.d.ts +11 -0
  173. package/lib/formly/index.d.ts +5 -0
  174. package/lib/index.d.ts +4 -0
  175. package/lib/layout/form.layout.module.d.ts +8 -0
  176. package/lib/layout/form.spacer.component.d.ts +8 -0
  177. package/lib/layout/index.d.ts +2 -0
  178. package/lib/validator/boolean.d.ts +2 -0
  179. package/lib/validator/email.d.ts +3 -0
  180. package/lib/validator/index.d.ts +3 -0
  181. package/lib/validator/number.d.ts +2 -0
  182. package/package.json +67 -0
  183. package/src/_index.scss +11 -0
  184. package/src/lib/form/_form.scss +26 -0
  185. package/src/lib/formly/_formly.scss +26 -0
  186. package/src/lib/formly/field/_field.scss +33 -0
  187. package/src/lib/formly/field/checklist/_checklist.scss +26 -0
  188. package/src/lib/formly/field/checklist/checklist.item_TODO.scss +57 -0
  189. package/src/lib/formly/field/component/_component.scss +26 -0
  190. package/src/lib/formly/field/fields_TODO.scss +4 -0
  191. package/src/lib/formly/field/selection/_selection.scss +17 -0
  192. package/src/lib/formly/field/selection/generic_TODO.scss +36 -0
  193. package/src/lib/formly/field/selection/pickable/_pickable.scss +26 -0
  194. package/src/lib/formly/field/selection/searchable/_searchable.scss +26 -0
  195. package/src/lib/formly/field/texteditor/_texteditor.scss +26 -0
  196. package/src/lib/formly/field/texteditor/texteditor_TODO.scss +32 -0
  197. package/src/lib/formly/field/value/_value.scss +33 -0
  198. package/src/lib/formly/field/value/array/_array.scss +26 -0
  199. package/src/lib/formly/field/value/boolean/_boolean.scss +26 -0
  200. package/src/lib/formly/field/value/date/_date.scss +26 -0
  201. package/src/lib/formly/field/value/date/date_TODO.scss +27 -0
  202. package/src/lib/formly/field/value/enum/_enum.scss +26 -0
  203. package/src/lib/formly/field/value/phone/_phone.scss +26 -0
  204. package/src/lib/formly/field/value/phone/phone_TODO.scss +10 -0
  205. package/src/lib/formly/field/value/text/_text.scss +26 -0
  206. package/src/lib/formly/field/wrapper/_wrapper.scss +26 -0
  207. package/src/lib/formly/field/wrapper/wrapper_TODO.scss +34 -0
  208. package/src/lib/formly/form_TODO.scss +153 -0
  209. package/src/lib/layout/_layout.scss +26 -0
  210. package/src/lib/style/_all-core.scss +12 -0
  211. package/src/lib/style/_all-theme.scss +12 -0
  212. package/src/lib/style/_all-typography.scss +12 -0
  213. package/src/lib/style/_config.scss +20 -0
  214. package/src/lib/style/_core.scss +9 -0
  215. package/src/lib/style/_mixin.scss +3 -0
  216. package/src/lib/style/_theming.scss +19 -0
  217. package/src/lib/style/_variables.scss +1 -0
@@ -0,0 +1,3295 @@
1
+ import { MatDialogModule } from '@angular/material/dialog';
2
+ import * as i0 from '@angular/core';
3
+ import { forwardRef, Directive, Host, Input, NgModule, EventEmitter, Output, Component, ViewContainerRef, ViewChild } from '@angular/core';
4
+ import * as i5 from '@angular/common';
5
+ import { CommonModule } from '@angular/common';
6
+ import { isPast, addSeconds, isSameMinute, isSameDay, startOfDay, addMinutes } from 'date-fns';
7
+ import { of, combineLatest, BehaviorSubject, mergeMap, shareReplay as shareReplay$1, switchMap as switchMap$1, startWith, map as map$1, debounceTime as debounceTime$1, distinctUntilChanged as distinctUntilChanged$1, filter as filter$1, first as first$1, Subject, interval, merge } from 'rxjs';
8
+ import { switchMap, first, catchError, filter, map, distinctUntilChanged, shareReplay, delay, startWith as startWith$1, debounceTime, mergeMap as mergeMap$1, tap, throttleTime } from 'rxjs/operators';
9
+ import { LockSet, SubscriptionObject, switchMapMaybeObs, filterMaybe, beginLoading, mapLoadingStateResults, successResult, LoadingStateContextInstance } from '@dereekb/rxjs';
10
+ import * as i2 from '@dereekb/dbx-core';
11
+ import { AbstractSubscriptionDirective, DbxInjectedComponentModule, DbxDatePipeModule } from '@dereekb/dbx-core';
12
+ import * as i1$4 from '@ngx-formly/core';
13
+ import { FieldType, FieldWrapper, FormlyModule, FieldArrayType } from '@ngx-formly/core';
14
+ import * as i1 from '@angular/material/checkbox';
15
+ import { MatCheckboxModule } from '@angular/material/checkbox';
16
+ import * as i1$1 from '@dereekb/dbx-web';
17
+ import { DbxTextModule, DbxAnchorModule, DbxLoadingModule, DbxButtonModule } from '@dereekb/dbx-web';
18
+ import * as i2$1 from '@angular/material/icon';
19
+ import { MatIconModule } from '@angular/material/icon';
20
+ import * as i3 from '@angular/forms';
21
+ import { FormsModule, ReactiveFormsModule, FormControl, Validators, FormGroup } from '@angular/forms';
22
+ import * as i2$2 from '@angular/material/core';
23
+ import { MatRippleModule, MatNativeDateModule } from '@angular/material/core';
24
+ import * as i1$2 from '@angular/material/button';
25
+ import { MatButtonModule } from '@angular/material/button';
26
+ import * as i3$1 from '@angular/flex-layout/flex';
27
+ import { FlexLayoutModule } from '@angular/flex-layout';
28
+ import { hasValueOrNotEmpty, addPlusPrefixToNumber, convertMaybeToArray, makeValuesGroupMap, findUnique, separateValues, arrayToMap, concatArraysUnique } from '@dereekb/util';
29
+ import * as i1$3 from '@angular/material/slide-toggle';
30
+ import { MatSlideToggleModule } from '@angular/material/slide-toggle';
31
+ import * as i5$1 from '@angular/material/chips';
32
+ import { MatChipsModule } from '@angular/material/chips';
33
+ import * as i4 from '@angular/material/form-field';
34
+ import { MatFormFieldModule } from '@angular/material/form-field';
35
+ import * as i6 from '@angular/material/input';
36
+ import { MatInputModule } from '@angular/material/input';
37
+ import * as i1$5 from '@angular/material/autocomplete';
38
+ import { MatAutocompleteModule } from '@angular/material/autocomplete';
39
+ import * as i2$3 from '@angular/material/list';
40
+ import { MatListModule } from '@angular/material/list';
41
+ import { camelCase } from 'change-case';
42
+ import { ENTER, COMMA } from '@angular/cdk/keycodes';
43
+ import * as i3$2 from '@angular/material/divider';
44
+ import { MatDividerModule } from '@angular/material/divider';
45
+ import { guessCurrentTimezone, toReadableTimeString, utcDayForDate, readableTimeStringToDate, DateTimeMinuteInstance } from '@dereekb/date';
46
+ import * as i4$1 from '@angular/material/datepicker';
47
+ import { MatDatepickerModule } from '@angular/material/datepicker';
48
+ import * as i5$2 from '@angular/material/menu';
49
+ import { MatMenuModule } from '@angular/material/menu';
50
+ import * as i2$4 from 'ngx-mat-intl-tel-input';
51
+ import { NgxMatIntlTelInputModule } from 'ngx-mat-intl-tel-input';
52
+ import { cloneDeep } from 'lodash';
53
+ import { FormlyMatToggleModule } from '@ngx-formly/material/toggle';
54
+
55
+ /**
56
+ * Current state of a DbxForm
57
+ */
58
+ var DbxFormState;
59
+ (function (DbxFormState) {
60
+ DbxFormState[DbxFormState["INITIALIZING"] = -1] = "INITIALIZING";
61
+ DbxFormState[DbxFormState["INCOMPLETE"] = 0] = "INCOMPLETE";
62
+ DbxFormState[DbxFormState["COMPLETE"] = 1] = "COMPLETE";
63
+ DbxFormState[DbxFormState["RESET"] = 2] = "RESET";
64
+ })(DbxFormState || (DbxFormState = {}));
65
+ /**
66
+ * Form that has an event stream, value, and state items.
67
+ */
68
+ class DbxForm {
69
+ }
70
+ function ProvideDbxForm(sourceType) {
71
+ return [{ provide: DbxForm, useExisting: forwardRef(() => sourceType) }];
72
+ }
73
+
74
+ const APP_ACTION_FORM_DISABLED_KEY = 'actionForm';
75
+ /**
76
+ * Used with an action to bind a form to an action as it's value source.
77
+ *
78
+ * If the form has errors when the action is trigger, it will reject the action.
79
+ *
80
+ * If the source is not considered modified, the trigger will be ignored.
81
+ */
82
+ class DbxActionFormDirective {
83
+ constructor(form, source) {
84
+ this.form = form;
85
+ this.source = source;
86
+ this.lockSet = new LockSet();
87
+ this._triggeredSub = new SubscriptionObject();
88
+ this._isCompleteSub = new SubscriptionObject();
89
+ if (form.lockSet) {
90
+ this.lockSet.addChildLockSet(form.lockSet, 'form');
91
+ }
92
+ this.lockSet.addChildLockSet(source.lockSet, 'source');
93
+ }
94
+ ngOnInit() {
95
+ // Pass data from the form to the source when triggered.
96
+ this._triggeredSub.subscription = this.source.triggered$.pipe(switchMap(() => {
97
+ const doNothing = {}; // nothing, form not complete
98
+ if (this.form.isComplete) {
99
+ const value = this.form.value;
100
+ return this.preCheckReadyValue(value).pipe(first(), switchMap((canContinue) => {
101
+ if (canContinue) {
102
+ return this.readyValue(value).pipe(first());
103
+ }
104
+ else {
105
+ return of(doNothing);
106
+ }
107
+ }), catchError((error) => of({ error })));
108
+ }
109
+ else {
110
+ return of(doNothing);
111
+ }
112
+ })).subscribe((result) => {
113
+ if (result.reject) {
114
+ this.source.reject(result.reject);
115
+ }
116
+ else if (result.value != null) {
117
+ this.source.readyValue(result.value);
118
+ }
119
+ else {
120
+ // value isn't ready
121
+ }
122
+ });
123
+ // Update the enabled/disabled state
124
+ this._isCompleteSub.subscription = this.form.stream$.pipe(filter((x) => x.state !== DbxFormState.INITIALIZING), switchMap((event) => {
125
+ var _a, _b;
126
+ // Use both changes count and whether or not something was in the past to guage whether or not the item has been touched.
127
+ // Angular Form's untouched is whether or not focus has been lost but we can still recieve value updates.
128
+ // More than a certain amount of updates implies that it is being typed into.
129
+ const isProbablyTouched = !event.untouched ||
130
+ (((_a = event.changesCount) !== null && _a !== void 0 ? _a : 0) > 3 && isPast(addSeconds((_b = event.lastResetAt) !== null && _b !== void 0 ? _b : new Date(), 2)));
131
+ // console.log('Event: ', event, isProbablyTouched);
132
+ const value = this.form.value;
133
+ let validatorObs;
134
+ const initialIsValidCheck = event.isComplete;
135
+ if (initialIsValidCheck) {
136
+ validatorObs = (this.appActionFormValidator) ? this.appActionFormValidator(value) : of(true);
137
+ }
138
+ else {
139
+ validatorObs = of(false);
140
+ }
141
+ let modifiedObs;
142
+ const isConsideredModified = (event.pristine === false && isProbablyTouched);
143
+ if (isConsideredModified) {
144
+ modifiedObs = (this.appActionFormModified) ? this.appActionFormModified(value) : of(true);
145
+ }
146
+ else {
147
+ modifiedObs = of(false);
148
+ }
149
+ return combineLatest([
150
+ validatorObs,
151
+ modifiedObs
152
+ ]).pipe(first(), map(([valid, modified]) => ({ valid, modified, event })));
153
+ })).subscribe(({ valid, modified, event }) => {
154
+ // Update Modified State
155
+ this.source.setIsModified(modified);
156
+ // Disable if the form is not yet complete/valid.
157
+ this.source.enable(APP_ACTION_FORM_DISABLED_KEY, valid);
158
+ });
159
+ // TODO: Watch the working state and stop allowing input on working..?
160
+ // TODO: Watch the disabled state for when another disabled key disables this form.
161
+ }
162
+ ngOnDestroy() {
163
+ this.source.enable(APP_ACTION_FORM_DISABLED_KEY);
164
+ this.lockSet.destroyOnNextUnlock(() => {
165
+ this._triggeredSub.destroy();
166
+ this._isCompleteSub.destroy();
167
+ });
168
+ }
169
+ preCheckReadyValue(value) {
170
+ let validatorObs = (this.appActionFormValidator) ? this.appActionFormValidator(value) : of(true);
171
+ let modifiedObs = (this.appActionFormModified) ? this.appActionFormModified(value) : of(true);
172
+ return combineLatest([
173
+ validatorObs,
174
+ modifiedObs
175
+ ]).pipe(first(), map(([valid, modified]) => valid && modified));
176
+ }
177
+ readyValue(value) {
178
+ return of({ value });
179
+ }
180
+ }
181
+ DbxActionFormDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxActionFormDirective, deps: [{ token: DbxForm, host: true }, { token: i2.ActionContextStoreSourceInstance }], target: i0.ɵɵFactoryTarget.Directive });
182
+ DbxActionFormDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbxActionFormDirective, selector: "[dbxActionForm]", inputs: { appActionFormValidator: "appActionFormValidator", appActionFormModified: "appActionFormModified" }, ngImport: i0 });
183
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxActionFormDirective, decorators: [{
184
+ type: Directive,
185
+ args: [{
186
+ selector: '[dbxActionForm]'
187
+ }]
188
+ }], ctorParameters: function () {
189
+ return [{ type: DbxForm, decorators: [{
190
+ type: Host
191
+ }] }, { type: i2.ActionContextStoreSourceInstance }];
192
+ }, propDecorators: { appActionFormValidator: [{
193
+ type: Input
194
+ }], appActionFormModified: [{
195
+ type: Input
196
+ }] } });
197
+
198
+ class DbxFormlyActionModule {
199
+ }
200
+ DbxFormlyActionModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormlyActionModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
201
+ DbxFormlyActionModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormlyActionModule, declarations: [DbxActionFormDirective], imports: [CommonModule,
202
+ MatDialogModule], exports: [DbxActionFormDirective] });
203
+ DbxFormlyActionModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormlyActionModule, imports: [[
204
+ CommonModule,
205
+ MatDialogModule
206
+ ]] });
207
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormlyActionModule, decorators: [{
208
+ type: NgModule,
209
+ args: [{
210
+ imports: [
211
+ CommonModule,
212
+ MatDialogModule
213
+ ],
214
+ declarations: [
215
+ DbxActionFormDirective
216
+ ],
217
+ exports: [
218
+ DbxActionFormDirective
219
+ ]
220
+ }]
221
+ }] });
222
+
223
+ /**
224
+ * Used with a FormComponent to set the value from a LoadingState when the value is available.
225
+ */
226
+ class DbxFormLoadingPairSourceDirective extends AbstractSubscriptionDirective {
227
+ constructor(form) {
228
+ super();
229
+ this.form = form;
230
+ }
231
+ /**
232
+ * Sets a LoadingContext that is watched for the loading state.
233
+ */
234
+ set obs(obs) {
235
+ this._setObs(obs);
236
+ }
237
+ _setObs(obs) {
238
+ let subscription;
239
+ if (obs) {
240
+ subscription = combineLatest([
241
+ // Emit the first time initializing isn't there.
242
+ this.form.stream$.pipe(filter((x) => x.state !== DbxFormState.INITIALIZING), first()),
243
+ obs
244
+ ]).pipe(map((x) => x[1]), filter((x) => Boolean(x)), distinctUntilChanged((x, y) => x.value === y.value)).subscribe((x) => {
245
+ if (!x.error && !x.loading) {
246
+ // console.log('Setting value: ', x.model);
247
+ this.form.setValue(x.value);
248
+ }
249
+ });
250
+ }
251
+ this.sub = subscription;
252
+ }
253
+ }
254
+ DbxFormLoadingPairSourceDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormLoadingPairSourceDirective, deps: [{ token: DbxForm, host: true }], target: i0.ɵɵFactoryTarget.Directive });
255
+ DbxFormLoadingPairSourceDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbxFormLoadingPairSourceDirective, selector: "[dbxFormLoadingPairSource]", inputs: { obs: ["dbxFormLoadingPairSource", "obs"] }, usesInheritance: true, ngImport: i0 });
256
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormLoadingPairSourceDirective, decorators: [{
257
+ type: Directive,
258
+ args: [{
259
+ selector: '[dbxFormLoadingPairSource]'
260
+ }]
261
+ }], ctorParameters: function () {
262
+ return [{ type: DbxForm, decorators: [{
263
+ type: Host
264
+ }] }];
265
+ }, propDecorators: { obs: [{
266
+ type: Input,
267
+ args: ['dbxFormLoadingPairSource']
268
+ }] } });
269
+
270
+ /**
271
+ * Used to see form value changes.
272
+ */
273
+ class DbxFormValueChangesDirective extends AbstractSubscriptionDirective {
274
+ constructor(form) {
275
+ super();
276
+ this.form = form;
277
+ this.dbxFormValueChange = new EventEmitter();
278
+ }
279
+ ngOnInit() {
280
+ this.sub = this.form.stream$.subscribe((x) => {
281
+ this.dbxFormValueChange.next(this.form.value);
282
+ });
283
+ }
284
+ }
285
+ DbxFormValueChangesDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormValueChangesDirective, deps: [{ token: DbxForm, host: true }], target: i0.ɵɵFactoryTarget.Directive });
286
+ DbxFormValueChangesDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbxFormValueChangesDirective, selector: "[dbxFormValueChange]", outputs: { dbxFormValueChange: "dbxFormValueChange" }, usesInheritance: true, ngImport: i0 });
287
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormValueChangesDirective, decorators: [{
288
+ type: Directive,
289
+ args: [{
290
+ selector: '[dbxFormValueChange]'
291
+ }]
292
+ }], ctorParameters: function () {
293
+ return [{ type: DbxForm, decorators: [{
294
+ type: Host
295
+ }] }];
296
+ }, propDecorators: { dbxFormValueChange: [{
297
+ type: Output
298
+ }] } });
299
+
300
+ /**
301
+ * Used with a FormComponent to set the value based on the input value.
302
+ */
303
+ class DbxFormSourceDirective extends AbstractSubscriptionDirective {
304
+ constructor(form) {
305
+ super();
306
+ this.form = form;
307
+ }
308
+ /**
309
+ * Sets a LoadingContext that is watched for the loading state.
310
+ */
311
+ set obs(obs) {
312
+ this._setObs(obs);
313
+ }
314
+ _setObs(obs) {
315
+ let subscription;
316
+ if (obs) {
317
+ subscription = combineLatest([
318
+ // Emit the first time initializing isn't there.
319
+ this.form.stream$.pipe(filter((x) => x.state !== DbxFormState.INITIALIZING), first()),
320
+ obs
321
+ ]).pipe(map((x) => x[1]), distinctUntilChanged((x, y) => x === y)).subscribe((x) => {
322
+ this.form.setValue(x);
323
+ });
324
+ }
325
+ this.sub = subscription;
326
+ }
327
+ }
328
+ DbxFormSourceDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormSourceDirective, deps: [{ token: DbxForm, host: true }], target: i0.ɵɵFactoryTarget.Directive });
329
+ DbxFormSourceDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: DbxFormSourceDirective, selector: "[dbxFormSource]", inputs: { obs: ["dbxFormSource", "obs"] }, usesInheritance: true, ngImport: i0 });
330
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormSourceDirective, decorators: [{
331
+ type: Directive,
332
+ args: [{
333
+ selector: '[dbxFormSource]'
334
+ }]
335
+ }], ctorParameters: function () {
336
+ return [{ type: DbxForm, decorators: [{
337
+ type: Host
338
+ }] }];
339
+ }, propDecorators: { obs: [{
340
+ type: Input,
341
+ args: ['dbxFormSource']
342
+ }] } });
343
+
344
+ class DbxFormModule {
345
+ }
346
+ DbxFormModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
347
+ DbxFormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormModule, declarations: [DbxFormSourceDirective,
348
+ DbxFormValueChangesDirective,
349
+ DbxFormLoadingPairSourceDirective], imports: [CommonModule], exports: [DbxFormSourceDirective,
350
+ DbxFormValueChangesDirective,
351
+ DbxFormLoadingPairSourceDirective] });
352
+ DbxFormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormModule, imports: [[
353
+ CommonModule
354
+ ]] });
355
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormModule, decorators: [{
356
+ type: NgModule,
357
+ args: [{
358
+ imports: [
359
+ CommonModule
360
+ ],
361
+ declarations: [
362
+ DbxFormSourceDirective,
363
+ DbxFormValueChangesDirective,
364
+ DbxFormLoadingPairSourceDirective
365
+ ],
366
+ exports: [
367
+ DbxFormSourceDirective,
368
+ DbxFormValueChangesDirective,
369
+ DbxFormLoadingPairSourceDirective
370
+ ]
371
+ }]
372
+ }] });
373
+
374
+ // MARK: Default
375
+ class DbxDefaultChecklistItemFieldDisplayComponent {
376
+ get label() {
377
+ var _a;
378
+ return (_a = this.displayContent) === null || _a === void 0 ? void 0 : _a.label;
379
+ }
380
+ get sublabel() {
381
+ var _a;
382
+ return (_a = this.displayContent) === null || _a === void 0 ? void 0 : _a.sublabel;
383
+ }
384
+ get description() {
385
+ var _a;
386
+ return (_a = this.displayContent) === null || _a === void 0 ? void 0 : _a.description;
387
+ }
388
+ }
389
+ DbxDefaultChecklistItemFieldDisplayComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxDefaultChecklistItemFieldDisplayComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
390
+ DbxDefaultChecklistItemFieldDisplayComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbxDefaultChecklistItemFieldDisplayComponent, selector: "ng-component", inputs: { displayContent: "displayContent" }, ngImport: i0, template: `
391
+ <div *ngIf="displayContent" class="dbx-default-checklist-item-field">
392
+ <div *ngIf="label" class="item-label">{{ label }}</div>
393
+ <div *ngIf="sublabel" class="item-sublabel">{{ sublabel }}</div>
394
+ <div *ngIf="description" class="dbx-hint item-description">{{ description }}</div>
395
+ </div>
396
+ `, isInline: true, directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
397
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxDefaultChecklistItemFieldDisplayComponent, decorators: [{
398
+ type: Component,
399
+ args: [{
400
+ template: `
401
+ <div *ngIf="displayContent" class="dbx-default-checklist-item-field">
402
+ <div *ngIf="label" class="item-label">{{ label }}</div>
403
+ <div *ngIf="sublabel" class="item-sublabel">{{ sublabel }}</div>
404
+ <div *ngIf="description" class="dbx-hint item-description">{{ description }}</div>
405
+ </div>
406
+ `
407
+ }]
408
+ }], propDecorators: { displayContent: [{
409
+ type: Input
410
+ }] } });
411
+
412
+ class DbxChecklistItemFieldComponent extends FieldType {
413
+ constructor() {
414
+ super(...arguments);
415
+ this._displayContent = new BehaviorSubject(undefined);
416
+ this.displayContent$ = this._displayContent.pipe(switchMapMaybeObs(), distinctUntilChanged(), shareReplay(1));
417
+ this.anchor$ = this.displayContent$.pipe(map(x => x.anchor), shareReplay(1));
418
+ this.rippleDisabled$ = this.displayContent$.pipe(map(x => x.ripple === false || (x.ripple !== true && !x.anchor)), distinctUntilChanged(), shareReplay(1));
419
+ }
420
+ get formGroup() {
421
+ return this.form;
422
+ }
423
+ get checkboxFieldKey() {
424
+ return this.key;
425
+ }
426
+ get label() {
427
+ var _a;
428
+ return (_a = this.field.templateOptions) === null || _a === void 0 ? void 0 : _a.label;
429
+ }
430
+ get description() {
431
+ var _a;
432
+ return (_a = this.field.templateOptions) === null || _a === void 0 ? void 0 : _a.description;
433
+ }
434
+ get required() {
435
+ var _a;
436
+ return (_a = this.field.templateOptions) === null || _a === void 0 ? void 0 : _a.required;
437
+ }
438
+ get errors() {
439
+ var _a;
440
+ return (_a = this.field.formControl) === null || _a === void 0 ? void 0 : _a.errors;
441
+ }
442
+ get componentClass() {
443
+ var _a;
444
+ return (_a = this.field.componentClass) !== null && _a !== void 0 ? _a : DbxDefaultChecklistItemFieldDisplayComponent;
445
+ }
446
+ ngOnInit() {
447
+ this._displayContent.next(this.field.displayContentObs);
448
+ }
449
+ ngOnDestroy() {
450
+ this._displayContent.complete();
451
+ }
452
+ }
453
+ DbxChecklistItemFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxChecklistItemFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
454
+ DbxChecklistItemFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbxChecklistItemFieldComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: "<div class=\"dbx-checklist-item-wrapper\" [formGroup]=\"formGroup\">\n <div *ngIf=\"label\" class=\"dbx-checklist-item-label\">{{ label }}</div>\n <div class=\"dbx-checklist-item\">\n <div class=\"dbx-checklist-item-check\">\n <mat-checkbox [formControlName]=\"checkboxFieldKey\"></mat-checkbox>\n </div>\n <div class=\"dbx-checklist-item-content-wrapper\">\n <dbx-anchor [block]=\"true\" [anchor]=\"anchor$ | async\">\n <div class=\"dbx-checklist-item-content\" matRipple [matRippleDisabled]=\"(rippleDisabled$ | async) ?? false\">\n <dbx-checklist-item-content-component></dbx-checklist-item-content-component>\n <span class=\"spacer\"></span>\n <mat-icon>navigate_next</mat-icon>\n </div>\n </dbx-anchor>\n </div>\n </div>\n <div *ngIf=\"description\" class=\"dbx-hint\">{{ description }}</div>\n</div>\n", components: [{ type: i0.forwardRef(function () { return i1.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: i0.forwardRef(function () { return i1$1.DbxAnchorComponent; }), selector: "dbx-anchor, [dbx-anchor]", inputs: ["block"] }, { type: i0.forwardRef(function () { return DbxChecklistItemContentComponent; }), selector: "dbx-checklist-item-content-component" }, { type: i0.forwardRef(function () { return i2$1.MatIcon; }), selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i0.forwardRef(function () { return i3.NgControlStatusGroup; }), selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i0.forwardRef(function () { return i3.FormGroupDirective; }), selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i0.forwardRef(function () { return i5.NgIf; }), selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i0.forwardRef(function () { return i3.NgControlStatus; }), selector: "[formControlName],[ngModel],[formControl]" }, { type: i0.forwardRef(function () { return i3.FormControlName; }), selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i0.forwardRef(function () { return i2$2.MatRipple; }), selector: "[mat-ripple], [matRipple]", inputs: ["matRippleColor", "matRippleUnbounded", "matRippleCentered", "matRippleRadius", "matRippleAnimation", "matRippleDisabled", "matRippleTrigger"], exportAs: ["matRipple"] }], pipes: { "async": i0.forwardRef(function () { return i5.AsyncPipe; }) } });
455
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxChecklistItemFieldComponent, decorators: [{
456
+ type: Component,
457
+ args: [{ template: "<div class=\"dbx-checklist-item-wrapper\" [formGroup]=\"formGroup\">\n <div *ngIf=\"label\" class=\"dbx-checklist-item-label\">{{ label }}</div>\n <div class=\"dbx-checklist-item\">\n <div class=\"dbx-checklist-item-check\">\n <mat-checkbox [formControlName]=\"checkboxFieldKey\"></mat-checkbox>\n </div>\n <div class=\"dbx-checklist-item-content-wrapper\">\n <dbx-anchor [block]=\"true\" [anchor]=\"anchor$ | async\">\n <div class=\"dbx-checklist-item-content\" matRipple [matRippleDisabled]=\"(rippleDisabled$ | async) ?? false\">\n <dbx-checklist-item-content-component></dbx-checklist-item-content-component>\n <span class=\"spacer\"></span>\n <mat-icon>navigate_next</mat-icon>\n </div>\n </dbx-anchor>\n </div>\n </div>\n <div *ngIf=\"description\" class=\"dbx-hint\">{{ description }}</div>\n</div>\n" }]
458
+ }] });
459
+ class DbxChecklistItemContentComponent extends AbstractSubscriptionDirective {
460
+ constructor(checklistItemFieldComponent, resolver, ngZone) {
461
+ super();
462
+ this.checklistItemFieldComponent = checklistItemFieldComponent;
463
+ this.resolver = resolver;
464
+ this.ngZone = ngZone;
465
+ this.displayContent$ = this.checklistItemFieldComponent.displayContent$;
466
+ this.isLoading$ = this.checklistItemFieldComponent.displayContent$;
467
+ }
468
+ ngOnInit() {
469
+ this.contentRef.clear();
470
+ const componentClass = this.checklistItemFieldComponent.componentClass;
471
+ const componentRef = this.contentRef.createComponent(componentClass);
472
+ this.sub = this.checklistItemFieldComponent.displayContent$.subscribe((x) => {
473
+ this.ngZone.run(() => componentRef.instance.displayContent = x);
474
+ });
475
+ }
476
+ }
477
+ DbxChecklistItemContentComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxChecklistItemContentComponent, deps: [{ token: DbxChecklistItemFieldComponent }, { token: i0.ComponentFactoryResolver }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
478
+ DbxChecklistItemContentComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbxChecklistItemContentComponent, selector: "dbx-checklist-item-content-component", viewQueries: [{ propertyName: "contentRef", first: true, predicate: ["content"], descendants: true, read: ViewContainerRef, static: true }], usesInheritance: true, ngImport: i0, template: `
479
+ <ng-template #content></ng-template>
480
+ `, isInline: true });
481
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxChecklistItemContentComponent, decorators: [{
482
+ type: Component,
483
+ args: [{
484
+ selector: 'dbx-checklist-item-content-component',
485
+ template: `
486
+ <ng-template #content></ng-template>
487
+ `
488
+ }]
489
+ }], ctorParameters: function () { return [{ type: DbxChecklistItemFieldComponent }, { type: i0.ComponentFactoryResolver }, { type: i0.NgZone }]; }, propDecorators: { contentRef: [{
490
+ type: ViewChild,
491
+ args: ['content', { static: true, read: ViewContainerRef }]
492
+ }] } });
493
+
494
+ class FormInfoSectionWrapperComponent extends FieldWrapper {
495
+ get infoSection() {
496
+ return this.to.infoSection;
497
+ }
498
+ onInfoClick() {
499
+ this.infoSection.onInfoClick();
500
+ }
501
+ }
502
+ FormInfoSectionWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: FormInfoSectionWrapperComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
503
+ FormInfoSectionWrapperComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: FormInfoSectionWrapperComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: `
504
+ <div class="form-info-section" fxLayout="row">
505
+ <div class="form-info-section-content" fxFlex="grow">
506
+ <ng-container #fieldComponent></ng-container>
507
+ </div>
508
+ <div class="form-info-section-info" fxFlex="noshrink" fxLayout="column" fxLayoutAlign="center center">
509
+ <button mat-icon-button [attr.aria-label]="'show info button for ' + to.label || 'section'"
510
+ (click)="onInfoClick()">
511
+ <mat-icon>info</mat-icon>
512
+ </button>
513
+ </div>
514
+ </div>
515
+ `, isInline: true, components: [{ type: i1$2.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: i2$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i3$1.DefaultLayoutDirective, selector: " [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md], [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md], [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm], [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { type: i3$1.DefaultFlexDirective, selector: " [fxFlex], [fxFlex.xs], [fxFlex.sm], [fxFlex.md], [fxFlex.lg], [fxFlex.xl], [fxFlex.lt-sm], [fxFlex.lt-md], [fxFlex.lt-lg], [fxFlex.lt-xl], [fxFlex.gt-xs], [fxFlex.gt-sm], [fxFlex.gt-md], [fxFlex.gt-lg]", inputs: ["fxFlex", "fxFlex.xs", "fxFlex.sm", "fxFlex.md", "fxFlex.lg", "fxFlex.xl", "fxFlex.lt-sm", "fxFlex.lt-md", "fxFlex.lt-lg", "fxFlex.lt-xl", "fxFlex.gt-xs", "fxFlex.gt-sm", "fxFlex.gt-md", "fxFlex.gt-lg"] }, { type: i3$1.DefaultLayoutAlignDirective, selector: " [fxLayoutAlign], [fxLayoutAlign.xs], [fxLayoutAlign.sm], [fxLayoutAlign.md], [fxLayoutAlign.lg], [fxLayoutAlign.xl], [fxLayoutAlign.lt-sm], [fxLayoutAlign.lt-md], [fxLayoutAlign.lt-lg], [fxLayoutAlign.lt-xl], [fxLayoutAlign.gt-xs], [fxLayoutAlign.gt-sm], [fxLayoutAlign.gt-md], [fxLayoutAlign.gt-lg]", inputs: ["fxLayoutAlign", "fxLayoutAlign.xs", "fxLayoutAlign.sm", "fxLayoutAlign.md", "fxLayoutAlign.lg", "fxLayoutAlign.xl", "fxLayoutAlign.lt-sm", "fxLayoutAlign.lt-md", "fxLayoutAlign.lt-lg", "fxLayoutAlign.lt-xl", "fxLayoutAlign.gt-xs", "fxLayoutAlign.gt-sm", "fxLayoutAlign.gt-md", "fxLayoutAlign.gt-lg"] }] });
516
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: FormInfoSectionWrapperComponent, decorators: [{
517
+ type: Component,
518
+ args: [{
519
+ template: `
520
+ <div class="form-info-section" fxLayout="row">
521
+ <div class="form-info-section-content" fxFlex="grow">
522
+ <ng-container #fieldComponent></ng-container>
523
+ </div>
524
+ <div class="form-info-section-info" fxFlex="noshrink" fxLayout="column" fxLayoutAlign="center center">
525
+ <button mat-icon-button [attr.aria-label]="'show info button for ' + to.label || 'section'"
526
+ (click)="onInfoClick()">
527
+ <mat-icon>info</mat-icon>
528
+ </button>
529
+ </div>
530
+ </div>
531
+ `
532
+ }]
533
+ }] });
534
+
535
+ class FormSectionWrapperComponent extends FieldWrapper {
536
+ get description() {
537
+ return this.to.description;
538
+ }
539
+ }
540
+ FormSectionWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: FormSectionWrapperComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
541
+ FormSectionWrapperComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: FormSectionWrapperComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: `
542
+ <div class="form-section">
543
+ <h3>{{ to.label }}</h3>
544
+ <div class="form-section-content">
545
+ <ng-container #fieldComponent></ng-container>
546
+ </div>
547
+ <dbx-hint *ngIf="description">{{ description }}</dbx-hint>
548
+ </div>
549
+ `, isInline: true, components: [{ type: i1$1.DbxHintComponent, selector: "dbx-hint" }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
550
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: FormSectionWrapperComponent, decorators: [{
551
+ type: Component,
552
+ args: [{
553
+ template: `
554
+ <div class="form-section">
555
+ <h3>{{ to.label }}</h3>
556
+ <div class="form-section-content">
557
+ <ng-container #fieldComponent></ng-container>
558
+ </div>
559
+ <dbx-hint *ngIf="description">{{ description }}</dbx-hint>
560
+ </div>
561
+ `
562
+ }]
563
+ }] });
564
+
565
+ class FormFlexWrapperComponent extends FieldWrapper {
566
+ }
567
+ FormFlexWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: FormFlexWrapperComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
568
+ FormFlexWrapperComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: FormFlexWrapperComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: `
569
+ <div class="form-flex-section">
570
+ <ng-container #fieldComponent></ng-container>
571
+ </div>
572
+ `, isInline: true });
573
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: FormFlexWrapperComponent, decorators: [{
574
+ type: Component,
575
+ args: [{
576
+ template: `
577
+ <div class="form-flex-section">
578
+ <ng-container #fieldComponent></ng-container>
579
+ </div>
580
+ `
581
+ }]
582
+ }] });
583
+
584
+ class FormSubsectionWrapperComponent extends FieldWrapper {
585
+ get description() {
586
+ return this.to.description;
587
+ }
588
+ }
589
+ FormSubsectionWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: FormSubsectionWrapperComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
590
+ FormSubsectionWrapperComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: FormSubsectionWrapperComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: `
591
+ <div class="form-section form-subsection">
592
+ <h4>{{ to.label }}</h4>
593
+ <div class="form-section-content">
594
+ <ng-container #fieldComponent></ng-container>
595
+ </div>
596
+ <dbx-hint *ngIf="description"><small>{{ description }}</small></dbx-hint>
597
+ </div>
598
+ `, isInline: true, components: [{ type: i1$1.DbxHintComponent, selector: "dbx-hint" }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
599
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: FormSubsectionWrapperComponent, decorators: [{
600
+ type: Component,
601
+ args: [{
602
+ template: `
603
+ <div class="form-section form-subsection">
604
+ <h4>{{ to.label }}</h4>
605
+ <div class="form-section-content">
606
+ <ng-container #fieldComponent></ng-container>
607
+ </div>
608
+ <dbx-hint *ngIf="description"><small>{{ description }}</small></dbx-hint>
609
+ </div>
610
+ `
611
+ }]
612
+ }] });
613
+
614
+ const DEFAULT_HAS_VALUE_FN = hasValueOrNotEmpty;
615
+ class AbstractFormExpandableSectionWrapperDirective extends FieldWrapper {
616
+ constructor() {
617
+ super(...arguments);
618
+ this._formControlObs = new BehaviorSubject(undefined);
619
+ this.formControl$ = this._formControlObs.pipe(filterMaybe());
620
+ this._toggleOpen = new BehaviorSubject(undefined);
621
+ this.show$ = this._toggleOpen.pipe(mergeMap((toggleOpen) => {
622
+ if (toggleOpen != null) {
623
+ return of(toggleOpen);
624
+ }
625
+ else {
626
+ return this.hasValue$;
627
+ }
628
+ }), shareReplay$1(1));
629
+ this.hasValue$ = this.formControl$.pipe(switchMap$1((x) => x.valueChanges.pipe(startWith(x.value), map$1((value) => {
630
+ return this.hasValueFn(value);
631
+ }), shareReplay$1(1))));
632
+ }
633
+ get expandableSection() {
634
+ return this.to.expandableSection;
635
+ }
636
+ get hasValueFn() {
637
+ var _a, _b;
638
+ return (_b = (_a = this.expandableSection) === null || _a === void 0 ? void 0 : _a.hasValueFn) !== null && _b !== void 0 ? _b : DEFAULT_HAS_VALUE_FN;
639
+ }
640
+ get expandLabel() {
641
+ var _a, _b, _c, _d, _e, _f;
642
+ return (_e = (_b = (_a = this.expandableSection) === null || _a === void 0 ? void 0 : _a.expandLabel) !== null && _b !== void 0 ? _b : (_d = (_c = this.field) === null || _c === void 0 ? void 0 : _c.templateOptions) === null || _d === void 0 ? void 0 : _d.label) !== null && _e !== void 0 ? _e : String((_f = this.field) === null || _f === void 0 ? void 0 : _f.key);
643
+ }
644
+ open() {
645
+ this._toggleOpen.next(true);
646
+ }
647
+ ngOnInit() {
648
+ this._formControlObs.next(this.formControl);
649
+ }
650
+ ngOnDestroy() {
651
+ this._toggleOpen.complete();
652
+ this._formControlObs.complete();
653
+ }
654
+ }
655
+ AbstractFormExpandableSectionWrapperDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractFormExpandableSectionWrapperDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
656
+ AbstractFormExpandableSectionWrapperDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: AbstractFormExpandableSectionWrapperDirective, usesInheritance: true, ngImport: i0 });
657
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractFormExpandableSectionWrapperDirective, decorators: [{
658
+ type: Directive
659
+ }] });
660
+ /**
661
+ * Section that is expandable by a button until a value is set, or the button is pressed.
662
+ */
663
+ class FormExpandableSectionWrapperComponent extends AbstractFormExpandableSectionWrapperDirective {
664
+ }
665
+ FormExpandableSectionWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: FormExpandableSectionWrapperComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
666
+ FormExpandableSectionWrapperComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: FormExpandableSectionWrapperComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: `
667
+ <ng-container [ngSwitch]="show$ | async">
668
+ <ng-container *ngSwitchCase="true">
669
+ <ng-container #fieldComponent></ng-container>
670
+ </ng-container>
671
+ <ng-container *ngSwitchCase="false">
672
+ <span class="form-expandable-section-button" (click)="open()">{{ expandLabel }}</span>
673
+ </ng-container>
674
+ </ng-container>
675
+ `, isInline: true, directives: [{ type: i5.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i5.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }], pipes: { "async": i5.AsyncPipe } });
676
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: FormExpandableSectionWrapperComponent, decorators: [{
677
+ type: Component,
678
+ args: [{
679
+ template: `
680
+ <ng-container [ngSwitch]="show$ | async">
681
+ <ng-container *ngSwitchCase="true">
682
+ <ng-container #fieldComponent></ng-container>
683
+ </ng-container>
684
+ <ng-container *ngSwitchCase="false">
685
+ <span class="form-expandable-section-button" (click)="open()">{{ expandLabel }}</span>
686
+ </ng-container>
687
+ </ng-container>
688
+ `
689
+ }]
690
+ }] });
691
+
692
+ /**
693
+ * Wrapper than sets the field to "touched" when the value changes and the field is not pristine.
694
+ */
695
+ class AutoTouchFieldWrapperComponent extends FieldWrapper {
696
+ ngOnInit() {
697
+ this.formControl.valueChanges.pipe(delay(200)).subscribe(() => {
698
+ if (!this.formControl.pristine && this.formControl.untouched) {
699
+ this.formControl.markAsTouched();
700
+ this.formControl.updateValueAndValidity();
701
+ }
702
+ });
703
+ }
704
+ }
705
+ AutoTouchFieldWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AutoTouchFieldWrapperComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
706
+ AutoTouchFieldWrapperComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: AutoTouchFieldWrapperComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: `<ng-container #fieldComponent></ng-container>`, isInline: true });
707
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AutoTouchFieldWrapperComponent, decorators: [{
708
+ type: Component,
709
+ args: [{
710
+ template: `<ng-container #fieldComponent></ng-container>`
711
+ }]
712
+ }] });
713
+
714
+ /**
715
+ * Section that is expandable by a button until a value is set, or the button is pressed.
716
+ */
717
+ class FormToggleSectionWrapperComponent extends AbstractFormExpandableSectionWrapperDirective {
718
+ constructor() {
719
+ super(...arguments);
720
+ this.$slideLabel = this._toggleOpen.pipe(switchMap(x => {
721
+ var _a, _b;
722
+ if ((_a = this.toggleSection) === null || _a === void 0 ? void 0 : _a.toggleLabelObs) {
723
+ return (_b = this.toggleSection) === null || _b === void 0 ? void 0 : _b.toggleLabelObs(x);
724
+ }
725
+ else {
726
+ return of(this.expandLabel);
727
+ }
728
+ }), shareReplay(1));
729
+ }
730
+ get toggleSection() {
731
+ return this.to.toggleSection;
732
+ }
733
+ onToggleChange() {
734
+ this.show$.pipe(first()).subscribe((show) => {
735
+ this._toggleOpen.next(!show);
736
+ });
737
+ }
738
+ }
739
+ FormToggleSectionWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: FormToggleSectionWrapperComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
740
+ FormToggleSectionWrapperComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: FormToggleSectionWrapperComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: `
741
+ <div class="form-toggle-wrapper" [ngSwitch]="show$ | async">
742
+ <div class="form-toggle-wrapper-toggle">
743
+ <mat-slide-toggle [checked]="show$ | async" (toggleChange)="onToggleChange()">{{ $slideLabel | async }}</mat-slide-toggle>
744
+ </div>
745
+ <ng-container *ngSwitchCase="true">
746
+ <ng-container #fieldComponent></ng-container>
747
+ </ng-container>
748
+ </div>
749
+ `, isInline: true, components: [{ type: i1$3.MatSlideToggle, selector: "mat-slide-toggle", inputs: ["disabled", "disableRipple", "color", "tabIndex", "name", "id", "labelPosition", "aria-label", "aria-labelledby", "aria-describedby", "required", "checked"], outputs: ["change", "toggleChange"], exportAs: ["matSlideToggle"] }], directives: [{ type: i5.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i5.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }], pipes: { "async": i5.AsyncPipe } });
750
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: FormToggleSectionWrapperComponent, decorators: [{
751
+ type: Component,
752
+ args: [{
753
+ template: `
754
+ <div class="form-toggle-wrapper" [ngSwitch]="show$ | async">
755
+ <div class="form-toggle-wrapper-toggle">
756
+ <mat-slide-toggle [checked]="show$ | async" (toggleChange)="onToggleChange()">{{ $slideLabel | async }}</mat-slide-toggle>
757
+ </div>
758
+ <ng-container *ngSwitchCase="true">
759
+ <ng-container #fieldComponent></ng-container>
760
+ </ng-container>
761
+ </div>
762
+ `
763
+ }]
764
+ }] });
765
+
766
+ class DbxFormFormlyWrapperModule {
767
+ }
768
+ DbxFormFormlyWrapperModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyWrapperModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
769
+ DbxFormFormlyWrapperModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyWrapperModule, declarations: [AutoTouchFieldWrapperComponent,
770
+ FormSectionWrapperComponent,
771
+ FormSubsectionWrapperComponent,
772
+ FormInfoSectionWrapperComponent,
773
+ FormExpandableSectionWrapperComponent,
774
+ FormToggleSectionWrapperComponent], imports: [CommonModule,
775
+ DbxTextModule,
776
+ MatButtonModule,
777
+ MatSlideToggleModule,
778
+ MatIconModule,
779
+ FlexLayoutModule, i1$4.FormlyModule] });
780
+ DbxFormFormlyWrapperModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyWrapperModule, imports: [[
781
+ CommonModule,
782
+ DbxTextModule,
783
+ MatButtonModule,
784
+ MatSlideToggleModule,
785
+ MatIconModule,
786
+ FlexLayoutModule,
787
+ FormlyModule.forChild({
788
+ wrappers: [
789
+ { name: 'autotouch', component: AutoTouchFieldWrapperComponent },
790
+ { name: 'expandable', component: FormExpandableSectionWrapperComponent },
791
+ { name: 'toggle', component: FormToggleSectionWrapperComponent },
792
+ { name: 'section', component: FormSectionWrapperComponent },
793
+ { name: 'subsection', component: FormSubsectionWrapperComponent },
794
+ { name: 'info', component: FormInfoSectionWrapperComponent },
795
+ { name: 'flex', component: FormFlexWrapperComponent }
796
+ ]
797
+ })
798
+ ]] });
799
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyWrapperModule, decorators: [{
800
+ type: NgModule,
801
+ args: [{
802
+ imports: [
803
+ CommonModule,
804
+ DbxTextModule,
805
+ MatButtonModule,
806
+ MatSlideToggleModule,
807
+ MatIconModule,
808
+ FlexLayoutModule,
809
+ FormlyModule.forChild({
810
+ wrappers: [
811
+ { name: 'autotouch', component: AutoTouchFieldWrapperComponent },
812
+ { name: 'expandable', component: FormExpandableSectionWrapperComponent },
813
+ { name: 'toggle', component: FormToggleSectionWrapperComponent },
814
+ { name: 'section', component: FormSectionWrapperComponent },
815
+ { name: 'subsection', component: FormSubsectionWrapperComponent },
816
+ { name: 'info', component: FormInfoSectionWrapperComponent },
817
+ { name: 'flex', component: FormFlexWrapperComponent }
818
+ ]
819
+ })
820
+ ],
821
+ declarations: [
822
+ AutoTouchFieldWrapperComponent,
823
+ FormSectionWrapperComponent,
824
+ FormSubsectionWrapperComponent,
825
+ FormInfoSectionWrapperComponent,
826
+ FormExpandableSectionWrapperComponent,
827
+ FormToggleSectionWrapperComponent
828
+ ],
829
+ exports: []
830
+ }]
831
+ }] });
832
+
833
+ class DbxFormFormlyChecklistItemFieldModule {
834
+ }
835
+ DbxFormFormlyChecklistItemFieldModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyChecklistItemFieldModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
836
+ DbxFormFormlyChecklistItemFieldModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyChecklistItemFieldModule, declarations: [DbxChecklistItemFieldComponent,
837
+ DbxChecklistItemContentComponent,
838
+ DbxDefaultChecklistItemFieldDisplayComponent], imports: [CommonModule,
839
+ DbxTextModule,
840
+ FormsModule,
841
+ ReactiveFormsModule,
842
+ MatRippleModule,
843
+ MatCheckboxModule,
844
+ MatButtonModule,
845
+ MatIconModule,
846
+ DbxAnchorModule,
847
+ DbxInjectedComponentModule,
848
+ DbxFormFormlyWrapperModule, i1$4.FormlyModule], exports: [DbxFormFormlyWrapperModule] });
849
+ DbxFormFormlyChecklistItemFieldModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyChecklistItemFieldModule, imports: [[
850
+ CommonModule,
851
+ DbxTextModule,
852
+ FormsModule,
853
+ ReactiveFormsModule,
854
+ MatRippleModule,
855
+ MatCheckboxModule,
856
+ MatButtonModule,
857
+ MatIconModule,
858
+ DbxAnchorModule,
859
+ DbxInjectedComponentModule,
860
+ DbxFormFormlyWrapperModule,
861
+ FormlyModule.forChild({
862
+ types: [
863
+ { name: 'checklistitem', component: DbxChecklistItemFieldComponent }
864
+ ]
865
+ })
866
+ ], DbxFormFormlyWrapperModule] });
867
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyChecklistItemFieldModule, decorators: [{
868
+ type: NgModule,
869
+ args: [{
870
+ imports: [
871
+ CommonModule,
872
+ DbxTextModule,
873
+ FormsModule,
874
+ ReactiveFormsModule,
875
+ MatRippleModule,
876
+ MatCheckboxModule,
877
+ MatButtonModule,
878
+ MatIconModule,
879
+ DbxAnchorModule,
880
+ DbxInjectedComponentModule,
881
+ DbxFormFormlyWrapperModule,
882
+ FormlyModule.forChild({
883
+ types: [
884
+ { name: 'checklistitem', component: DbxChecklistItemFieldComponent }
885
+ ]
886
+ })
887
+ ],
888
+ declarations: [
889
+ DbxChecklistItemFieldComponent,
890
+ DbxChecklistItemContentComponent,
891
+ DbxDefaultChecklistItemFieldDisplayComponent
892
+ ],
893
+ exports: [
894
+ DbxFormFormlyWrapperModule
895
+ ]
896
+ }]
897
+ }] });
898
+
899
+ /**
900
+ * Validates the configuration on the input field.
901
+ */
902
+ function formlyField(fieldConfig) {
903
+ if (!fieldConfig.key) {
904
+ console.error(fieldConfig);
905
+ throw new Error(`Field had a null key.`);
906
+ }
907
+ return fieldConfig;
908
+ }
909
+ /**
910
+ * Returns configuration for a formlyField that will disable autofill/autocomplete for a field.
911
+ */
912
+ function disableFormlyFieldAutofill() {
913
+ // https://stackoverflow.com/questions/15738259/disabling-chrome-autofill
914
+ return {
915
+ name: 'password',
916
+ autocomplete: 'off'
917
+ };
918
+ }
919
+
920
+ function checklistItemField({ key, label = '', placeholder = '', displayContentObs, componentClass, required = false }) {
921
+ const fieldConfig = formlyField({
922
+ key,
923
+ type: 'checklistitem',
924
+ templateOptions: {
925
+ label,
926
+ placeholder,
927
+ required
928
+ },
929
+ displayContentObs,
930
+ componentClass
931
+ });
932
+ return fieldConfig;
933
+ }
934
+ /**
935
+ * Used for building a set of configurations for a data-type object that has as second object that is used as a checklist.
936
+ */
937
+ class ChecklistItemFieldDataSetBuilder {
938
+ constructor(dataObs) {
939
+ this.dataObs = dataObs;
940
+ this._fields = new Map();
941
+ this.dataObs$ = this.dataObs;
942
+ }
943
+ /**
944
+ * Merges the input config with existing configuration.
945
+ *
946
+ * The displayContentObs, if provided, will merge with the existing observable and the two objects merged.
947
+ */
948
+ merge(key, config) {
949
+ const currentField = this._assertFieldExists(key).field;
950
+ const mergedConfig = Object.assign(Object.assign(Object.assign({}, currentField), config), { key });
951
+ if (currentField.displayContentObs && config.displayContentObs) {
952
+ mergedConfig.displayContentObs = combineLatest([
953
+ currentField.displayContentObs,
954
+ config.displayContentObs
955
+ ]).pipe(map(([a, b]) => {
956
+ const result = Object.assign(Object.assign({}, a), b);
957
+ // console.log('A and b: ', a, b, result);
958
+ return result;
959
+ }), shareReplay(1));
960
+ }
961
+ // console.log('Merged: ', mergedConfig);
962
+ this.field(mergedConfig);
963
+ }
964
+ override(key, config) {
965
+ const currentField = this._assertFieldExists(key);
966
+ this.field(Object.assign(Object.assign(Object.assign({}, currentField.field), config), { key }));
967
+ }
968
+ _assertFieldExists(key) {
969
+ const currentField = this._fields.get(key);
970
+ if (!currentField) {
971
+ throw new Error(`Expected field with key "${key}" for override() but was unavailable.`);
972
+ }
973
+ return currentField;
974
+ }
975
+ showValueFieldArrayCount(key, config) {
976
+ return this.field(Object.assign(Object.assign({ displayContentObs: this.contentWithDisplayValueFromData(key, (x) => addPlusPrefixToNumber(x === null || x === void 0 ? void 0 : x.length)) }, config), { key }));
977
+ }
978
+ showValueField(key, config, labelFn = (x) => x === null || x === void 0 ? void 0 : x.toString()) {
979
+ return this.field(Object.assign(Object.assign({ displayContentObs: this.contentWithDisplayValueFromData(key, labelFn) }, config), { key }));
980
+ }
981
+ field(config) {
982
+ const key = config.key;
983
+ this._fields.set(key, {
984
+ key,
985
+ field: config
986
+ });
987
+ }
988
+ // MARK: Build/Finish
989
+ build() {
990
+ return Array.from(this._fields.values()).map(({ field }) => {
991
+ return checklistItemField(field);
992
+ });
993
+ }
994
+ // MARK: Utility
995
+ customContentFromData(mapFn) {
996
+ return this.dataObs$.pipe(map(mapFn));
997
+ }
998
+ contentWithValueFromData(key, contentFn) {
999
+ return this.customContentFromData((data) => {
1000
+ const meta = data[key];
1001
+ const content = contentFn === null || contentFn === void 0 ? void 0 : contentFn(meta);
1002
+ return Object.assign({ meta }, content);
1003
+ });
1004
+ }
1005
+ contentWithDisplayValueFromData(key, labelFn = (x) => x === null || x === void 0 ? void 0 : x.toString()) {
1006
+ function sanitizeLabel(label) {
1007
+ return label !== null && label !== void 0 ? label : 'N/A';
1008
+ }
1009
+ return this.contentWithValueFromData(key, (value) => ({ label: sanitizeLabel(labelFn(value)) }));
1010
+ }
1011
+ }
1012
+
1013
+ class AbstractFormComponentFieldWrappedComponent {
1014
+ }
1015
+ class FormComponentFieldComponent extends FieldType {
1016
+ constructor() {
1017
+ super();
1018
+ }
1019
+ get config() {
1020
+ return this._config;
1021
+ }
1022
+ ngOnInit() {
1023
+ this._config = {
1024
+ componentClass: this.field.componentClass,
1025
+ init: (instance) => {
1026
+ instance.field = this;
1027
+ }
1028
+ };
1029
+ }
1030
+ }
1031
+ FormComponentFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: FormComponentFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1032
+ FormComponentFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: FormComponentFieldComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: `
1033
+ <div class="form-wrapped-component" dbx-injected-content [config]="config"></div>
1034
+ `, isInline: true, components: [{ type: i2.DbxInjectedComponent, selector: "dbx-injected-content, [dbx-injected-content]", inputs: ["config", "template"] }] });
1035
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: FormComponentFieldComponent, decorators: [{
1036
+ type: Component,
1037
+ args: [{
1038
+ template: `
1039
+ <div class="form-wrapped-component" dbx-injected-content [config]="config"></div>
1040
+ `
1041
+ }]
1042
+ }], ctorParameters: function () { return []; } });
1043
+
1044
+ class DbxFormFormlyComponentFieldModule {
1045
+ }
1046
+ DbxFormFormlyComponentFieldModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyComponentFieldModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1047
+ DbxFormFormlyComponentFieldModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyComponentFieldModule, declarations: [FormComponentFieldComponent], imports: [CommonModule,
1048
+ DbxInjectedComponentModule, i1$4.FormlyModule], exports: [FormComponentFieldComponent] });
1049
+ DbxFormFormlyComponentFieldModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyComponentFieldModule, imports: [[
1050
+ CommonModule,
1051
+ DbxInjectedComponentModule,
1052
+ FormlyModule.forChild({
1053
+ types: [
1054
+ { name: 'component', component: FormComponentFieldComponent }
1055
+ ]
1056
+ })
1057
+ ]] });
1058
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyComponentFieldModule, decorators: [{
1059
+ type: NgModule,
1060
+ args: [{
1061
+ imports: [
1062
+ CommonModule,
1063
+ DbxInjectedComponentModule,
1064
+ FormlyModule.forChild({
1065
+ types: [
1066
+ { name: 'component', component: FormComponentFieldComponent }
1067
+ ]
1068
+ })
1069
+ ],
1070
+ declarations: [
1071
+ FormComponentFieldComponent
1072
+ ],
1073
+ exports: [
1074
+ FormComponentFieldComponent
1075
+ ]
1076
+ }]
1077
+ }] });
1078
+
1079
+ function componentField({ componentClass }) {
1080
+ return {
1081
+ type: 'component',
1082
+ componentClass
1083
+ };
1084
+ }
1085
+
1086
+ /**
1087
+ * Used for picking pre-set values using items as the presentation.
1088
+ */
1089
+ class AbstractDbxPickableItemFieldDirective extends FieldType {
1090
+ constructor() {
1091
+ super(...arguments);
1092
+ this.inputCtrl = new FormControl('');
1093
+ this._formControlObs = new BehaviorSubject(undefined);
1094
+ this.formControl$ = this._formControlObs.pipe(filterMaybe());
1095
+ this._displayHashMap = new BehaviorSubject(new Map());
1096
+ this.filterInputValue$ = this.inputCtrl.valueChanges.pipe(startWith$1(undefined));
1097
+ this.filterInputValueString$ = this.filterInputValue$.pipe(debounceTime(200), distinctUntilChanged(), shareReplay(1));
1098
+ this.loadResultsDisplayValuesState$ = this.formControl$.pipe(first(), switchMap(() => this.loadValuesFn().pipe(switchMap((x) => this.loadDisplayValuesForFieldValues(x)), startWith$1(beginLoading()))), shareReplay(1));
1099
+ this._formControlValue = this.formControl$.pipe(switchMap(control => control.valueChanges.pipe(startWith$1(control.value), shareReplay(1))));
1100
+ this.loadResultsDisplayValues$ = this.loadResultsDisplayValuesState$.pipe(map(x => { var _a; return (_a = x === null || x === void 0 ? void 0 : x.value) !== null && _a !== void 0 ? _a : []; }));
1101
+ /**
1102
+ * Current values in the form control.
1103
+ */
1104
+ this.values$ = this._formControlValue.pipe(map(convertMaybeToArray), shareReplay(1));
1105
+ /**
1106
+ * Current values with their display value.
1107
+ */
1108
+ this.displayValuesState$ = combineLatest([this.loadResultsDisplayValues$, this.values$]).pipe(switchMap(([displayValues, currentValues]) => {
1109
+ const displayValuesMap = makeValuesGroupMap(displayValues, (x) => this.hashForValue(x.value));
1110
+ const valuesNotInDisplayMap = [];
1111
+ currentValues.forEach((x) => {
1112
+ var _a;
1113
+ const key = this.hashForValue(x);
1114
+ let displayValue = (_a = displayValuesMap.get(key)) === null || _a === void 0 ? void 0 : _a[0];
1115
+ if (!displayValue) {
1116
+ valuesNotInDisplayMap.push(x);
1117
+ }
1118
+ });
1119
+ if (valuesNotInDisplayMap.length) {
1120
+ return this.loadDisplayValuesForValues(valuesNotInDisplayMap).pipe(map(x => mapLoadingStateResults(x, {
1121
+ mapValue: (loadedValues) => {
1122
+ loadedValues.forEach(x => { var _a; return x.isUnknown = (_a = x.isUnknown) !== null && _a !== void 0 ? _a : true; }); // Assign unknown flag.
1123
+ return ([...displayValues, ...loadedValues]);
1124
+ }
1125
+ })));
1126
+ }
1127
+ else {
1128
+ return of(successResult(displayValues));
1129
+ }
1130
+ }));
1131
+ /**
1132
+ * Results to be displayed if filtered.
1133
+ */
1134
+ this.filteredSearchResultsState$ = this.loadResultsDisplayValues$.pipe(switchMap((values) => this.filterInputValueString$.pipe(switchMap(text => combineLatest([this._filterValues(text, values), this.displayValuesState$]).pipe(map(([values, displayState]) => mapLoadingStateResults(displayState, {
1135
+ mapValue: (displayValues) => {
1136
+ const valueHashSet = new Set(values.map(x => this.hashForValue(x)));
1137
+ return displayValues.filter(x => !x.isUnknown && valueHashSet.has(x._hash));
1138
+ }
1139
+ })))))), shareReplay(1));
1140
+ this.filteredSearchResults$ = this.filteredSearchResultsState$.pipe(map(x => x === null || x === void 0 ? void 0 : x.value), filterMaybe(), shareReplay(1));
1141
+ this.items$ = combineLatest([this.filteredSearchResults$, this.values$]).pipe(map(([displayValues, values]) => {
1142
+ const selectedHashValuesSet = new Set(values.map(x => this.hashForValue(x)));
1143
+ let items = displayValues.map((x) => ({ display: x, selected: selectedHashValuesSet.has(x._hash) }));
1144
+ if (this.sortItems) {
1145
+ items = this.sortItems(items);
1146
+ }
1147
+ return items;
1148
+ }), shareReplay(1));
1149
+ this.itemsLoadingState$ = this.loadResultsDisplayValues$.pipe(switchMap(x => this.items$.pipe(first(), map(x => successResult(x)), startWith$1(beginLoading()), shareReplay(1))));
1150
+ /**
1151
+ * Context used for managing the loading of items, or when the current results change.
1152
+ */
1153
+ this.context = new LoadingStateContextInstance({ obs: this.itemsLoadingState$, showLoadingOnNoValue: false });
1154
+ this.filterItemsLoadingState$ = this.items$.pipe(map(x => successResult(x)), startWith$1(beginLoading()), shareReplay(1));
1155
+ /**
1156
+ * Context used for searching/filtering.
1157
+ */
1158
+ this.filterResultsContext = new LoadingStateContextInstance({ obs: this.loadResultsDisplayValuesState$, showLoadingOnNoValue: true });
1159
+ }
1160
+ get multiSelect() {
1161
+ var _a;
1162
+ return (_a = this.field.multiSelect) !== null && _a !== void 0 ? _a : true;
1163
+ }
1164
+ get asArrayValue() {
1165
+ var _a;
1166
+ return (_a = this.field.asArrayValue) !== null && _a !== void 0 ? _a : true;
1167
+ }
1168
+ get filterLabel() {
1169
+ return this.field.filterLabel;
1170
+ }
1171
+ get readonly() {
1172
+ var _a;
1173
+ return (_a = this.field.templateOptions) === null || _a === void 0 ? void 0 : _a.readonly;
1174
+ }
1175
+ get required() {
1176
+ var _a;
1177
+ return (_a = this.field.templateOptions) === null || _a === void 0 ? void 0 : _a.required;
1178
+ }
1179
+ get placeholder() {
1180
+ var _a, _b;
1181
+ return (_b = (_a = this.field.templateOptions) === null || _a === void 0 ? void 0 : _a.placeholder) !== null && _b !== void 0 ? _b : '';
1182
+ }
1183
+ get description() {
1184
+ var _a;
1185
+ return (_a = this.field.templateOptions) === null || _a === void 0 ? void 0 : _a.description;
1186
+ }
1187
+ get sortItems() {
1188
+ return this.field.sortItems;
1189
+ }
1190
+ get hashForValue() {
1191
+ var _a;
1192
+ return (_a = this.field.hashForValue) !== null && _a !== void 0 ? _a : ((x) => x);
1193
+ }
1194
+ get displayForValue() {
1195
+ return this.field.displayForValue;
1196
+ }
1197
+ get showFilterInput() {
1198
+ return Boolean(this.field.filterValues);
1199
+ }
1200
+ get filterValuesFn() {
1201
+ var _a;
1202
+ return (_a = this.field.filterValues) !== null && _a !== void 0 ? _a : ((_, x) => of(x.map(y => y.value)));
1203
+ }
1204
+ get skipFilterFnOnEmpty() {
1205
+ var _a;
1206
+ return (_a = this.field.skipFilterFnOnEmpty) !== null && _a !== void 0 ? _a : true;
1207
+ }
1208
+ get _filterValues() {
1209
+ let fn;
1210
+ if (this.skipFilterFnOnEmpty) {
1211
+ fn = (filterText, values) => {
1212
+ let result;
1213
+ if (filterText) {
1214
+ result = this.filterValuesFn(filterText, values);
1215
+ }
1216
+ else {
1217
+ result = of(values.map(x => x.value));
1218
+ }
1219
+ return result;
1220
+ };
1221
+ }
1222
+ else {
1223
+ fn = this.filterValuesFn;
1224
+ }
1225
+ return fn;
1226
+ }
1227
+ get showTextFilter() {
1228
+ var _a;
1229
+ return (_a = this.field.showTextFilter) !== null && _a !== void 0 ? _a : Boolean(this.field.filterValues);
1230
+ }
1231
+ get loadValuesFn() {
1232
+ return this.field.loadValues;
1233
+ }
1234
+ get values() {
1235
+ var _a;
1236
+ return (_a = this._getValueOnFormControl(this.formControl.value)) !== null && _a !== void 0 ? _a : [];
1237
+ }
1238
+ get footerConfig() {
1239
+ return this.field.footerConfig;
1240
+ }
1241
+ loadDisplayValuesForValues(values) {
1242
+ return this.loadDisplayValuesForFieldValues(values.map((value) => ({ value })));
1243
+ }
1244
+ loadDisplayValuesForFieldValues(values) {
1245
+ return this.getDisplayValuesForFieldValues(values).pipe(map((displayValues) => ({ loading: false, model: displayValues })), startWith$1({ loading: true }), shareReplay(1));
1246
+ }
1247
+ getDisplayValuesForFieldValues(values) {
1248
+ return this._displayHashMap.pipe(mergeMap$1((displayMap) => {
1249
+ const mappingResult = values
1250
+ .map(x => [x, this.hashForValue(x.value)])
1251
+ .map(([x, hash], i) => [i, hash, x, displayMap.get(hash)]);
1252
+ const hasDisplay = mappingResult.filter(x => Boolean(x[3]));
1253
+ const needsDisplay = mappingResult.filter(x => !x[3]);
1254
+ if (needsDisplay.length > 0) {
1255
+ // Go get the display value.
1256
+ const displayValuesObs = this.displayForValue(needsDisplay.map(x => x[2]));
1257
+ return displayValuesObs.pipe(first(), map((displayResults) => {
1258
+ const displayResultsWithHash = displayResults.map((x) => {
1259
+ x._hash = this.hashForValue(x.value);
1260
+ return x;
1261
+ });
1262
+ // Create a map to re-join values later.
1263
+ const displayResultsMapping = displayResultsWithHash.map(x => [x, x._hash]);
1264
+ const valueIndexHashMap = new Map(displayResultsMapping.map(([x, hash]) => [hash, x]));
1265
+ // Update displayMap. No need to push an update notification.
1266
+ displayResultsMapping.forEach(([x, hash]) => displayMap.set(hash, x));
1267
+ // Zip values back together.
1268
+ const newDisplayValues = mappingResult.map(x => { var _a; return (_a = x[3]) !== null && _a !== void 0 ? _a : valueIndexHashMap.get(x[1]); });
1269
+ // Return display values.
1270
+ return newDisplayValues;
1271
+ }));
1272
+ }
1273
+ else {
1274
+ // If all display values are hashed return that.
1275
+ return of(hasDisplay.map(x => x[3]));
1276
+ }
1277
+ }));
1278
+ }
1279
+ ngOnInit() {
1280
+ this._formControlObs.next(this.formControl);
1281
+ // Focus after finished loading for the first time.
1282
+ this.context.loading$.pipe(delay(10), filter(x => x), first()).subscribe(() => {
1283
+ var _a;
1284
+ (_a = this.filterMatInput) === null || _a === void 0 ? void 0 : _a.focus();
1285
+ });
1286
+ }
1287
+ ngOnDestroy() {
1288
+ this._displayHashMap.complete();
1289
+ this._formControlObs.complete();
1290
+ this.filterResultsContext.destroy();
1291
+ }
1292
+ _getValueOnFormControl(valueOnFormControl) {
1293
+ const value = (valueOnFormControl != null) ? [].concat(valueOnFormControl) : []; // Always return an array.
1294
+ return value;
1295
+ }
1296
+ addValue(value) {
1297
+ this.setValues([...this.values, value]);
1298
+ }
1299
+ removeValue(value) {
1300
+ const hashToFilter = this.hashForValue(value);
1301
+ const values = this.values.filter(x => this.hashForValue(x) !== hashToFilter);
1302
+ this.setValues(values);
1303
+ }
1304
+ setValues(values) {
1305
+ // Use to filter non-unique values.
1306
+ if (this.hashForValue) {
1307
+ values = findUnique(values, this.hashForValue);
1308
+ }
1309
+ if (!this.multiSelect) {
1310
+ values = [values[0]].filter(x => x != null);
1311
+ }
1312
+ this._setValueOnFormControl(values);
1313
+ }
1314
+ // MARK: Internal
1315
+ _setValueOnFormControl(values) {
1316
+ let newValue = values;
1317
+ if (!this.asArrayValue) {
1318
+ newValue = [values[0]].filter(x => x != null)[0];
1319
+ }
1320
+ this.formControl.setValue(newValue);
1321
+ this.formControl.markAsTouched();
1322
+ this.formControl.markAsDirty();
1323
+ }
1324
+ }
1325
+ AbstractDbxPickableItemFieldDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractDbxPickableItemFieldDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1326
+ AbstractDbxPickableItemFieldDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: AbstractDbxPickableItemFieldDirective, viewQueries: [{ propertyName: "filterMatInput", first: true, predicate: ["filterMatInput"], descendants: true, static: true }], usesInheritance: true, ngImport: i0 });
1327
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractDbxPickableItemFieldDirective, decorators: [{
1328
+ type: Directive
1329
+ }], propDecorators: { filterMatInput: [{
1330
+ type: ViewChild,
1331
+ args: ['filterMatInput', { static: true }]
1332
+ }] } });
1333
+
1334
+ /**
1335
+ * Used for picking pre-set values using chips as the presentation.
1336
+ */
1337
+ class DbxPickableChipFieldComponent extends AbstractDbxPickableItemFieldDirective {
1338
+ itemClicked(item) {
1339
+ if (item.selected) {
1340
+ this.removeValue(item.display.value);
1341
+ }
1342
+ else {
1343
+ this.addValue(item.display.value);
1344
+ }
1345
+ }
1346
+ }
1347
+ DbxPickableChipFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxPickableChipFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1348
+ DbxPickableChipFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbxPickableChipFieldComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: "<div class=\"dbx-pickable-item-field\">\n <dbx-loading [context]=\"context\">\n <ng-container *ngIf=\"showFilterInput\">\n <ng-container *ngTemplateOutlet=\"filterTemplate\"></ng-container>\n </ng-container>\n <div class=\"dbx-pickable-item-field-chips\">\n <!-- TODO: Add back aria-label [attr.aria-label]=\"'email ' + emailParticipantsType\" -->\n <mat-chip-list [selectable]=\"!readonly\" [disabled]=\"readonly\" #chipList>\n <mat-chip *ngFor=\"let item of items$ | async\" (click)=\"itemClicked(item)\" [selected]=\"item.selected\">\n <span class=\"s-chip-label\">{{ item.display.label }}</span>\n </mat-chip>\n </mat-chip-list>\n <dbx-injected-content [config]=\"footerConfig\"></dbx-injected-content>\n </div>\n </dbx-loading>\n</div>\n\n<!-- Filter Input -->\n<ng-template #filterTemplate>\n <div class=\"dbx-pickable-item-field-filter\">\n <mat-form-field class=\"dbx-pickable-item-field-filter-field\" appearance=\"fill\">\n <mat-label>{{ filterLabel }}</mat-label>\n <input name=\"filter items\" #filterMatInput=\"matInput\" matInput [placeholder]=\"placeholder\"\n [formControl]=\"inputCtrl\">\n </mat-form-field>\n <div class=\"searchable-field-form-loading\">\n <dbx-loading [linear]=\"true\" [context]=\"filterResultsContext\"></dbx-loading>\n </div>\n </div>\n</ng-template>\n", components: [{ type: i1$1.DbxLoadingComponent, selector: "dbx-loading", inputs: ["show", "text", "mode", "color", "diameter", "linear", "context", "loading", "error"] }, { type: i5$1.MatChipList, selector: "mat-chip-list", inputs: ["errorStateMatcher", "multiple", "compareWith", "value", "required", "placeholder", "disabled", "aria-orientation", "selectable", "tabIndex"], outputs: ["change", "valueChange"], exportAs: ["matChipList"] }, { type: i2.DbxInjectedComponent, selector: "dbx-injected-content, [dbx-injected-content]", inputs: ["config", "template"] }, { type: i4.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5$1.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: i4.MatLabel, selector: "mat-label" }, { type: i6.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: i3.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.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }], pipes: { "async": i5.AsyncPipe } });
1349
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxPickableChipFieldComponent, decorators: [{
1350
+ type: Component,
1351
+ args: [{ template: "<div class=\"dbx-pickable-item-field\">\n <dbx-loading [context]=\"context\">\n <ng-container *ngIf=\"showFilterInput\">\n <ng-container *ngTemplateOutlet=\"filterTemplate\"></ng-container>\n </ng-container>\n <div class=\"dbx-pickable-item-field-chips\">\n <!-- TODO: Add back aria-label [attr.aria-label]=\"'email ' + emailParticipantsType\" -->\n <mat-chip-list [selectable]=\"!readonly\" [disabled]=\"readonly\" #chipList>\n <mat-chip *ngFor=\"let item of items$ | async\" (click)=\"itemClicked(item)\" [selected]=\"item.selected\">\n <span class=\"s-chip-label\">{{ item.display.label }}</span>\n </mat-chip>\n </mat-chip-list>\n <dbx-injected-content [config]=\"footerConfig\"></dbx-injected-content>\n </div>\n </dbx-loading>\n</div>\n\n<!-- Filter Input -->\n<ng-template #filterTemplate>\n <div class=\"dbx-pickable-item-field-filter\">\n <mat-form-field class=\"dbx-pickable-item-field-filter-field\" appearance=\"fill\">\n <mat-label>{{ filterLabel }}</mat-label>\n <input name=\"filter items\" #filterMatInput=\"matInput\" matInput [placeholder]=\"placeholder\"\n [formControl]=\"inputCtrl\">\n </mat-form-field>\n <div class=\"searchable-field-form-loading\">\n <dbx-loading [linear]=\"true\" [context]=\"filterResultsContext\"></dbx-loading>\n </div>\n </div>\n</ng-template>\n" }]
1352
+ }] });
1353
+
1354
+ /**
1355
+ * Used for picking pre-set values using a selection list as the presentation.
1356
+ */
1357
+ class DbxPickableListFieldComponent extends AbstractDbxPickableItemFieldDirective {
1358
+ matSelectionChanged(selection) {
1359
+ const options = selection.source.selectedOptions.selected;
1360
+ const items = options.map(x => {
1361
+ const { value, selected, disabled } = x;
1362
+ return ({ item: value, selected, disabled });
1363
+ });
1364
+ this.setValues(items.map(x => x.item.display.value));
1365
+ }
1366
+ }
1367
+ DbxPickableListFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxPickableListFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1368
+ DbxPickableListFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbxPickableListFieldComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: "<div class=\"dbx-pickable-item-field\">\n <dbx-loading [context]=\"context\">\n <ng-container *ngIf=\"showFilterInput\">\n <ng-container *ngTemplateOutlet=\"filterTemplate\"></ng-container>\n </ng-container>\n <div class=\"dbx-model-list dbx-pickable-item-field-list\">\n <mat-selection-list [multiple]=\"multiSelect\" (selectionChange)=\"matSelectionChanged($event)\">\n <mat-list-option *ngFor=\"let item of items$ | async\" [selected]=\"item.selected\" [value]=\"item\">\n <p>{{ item.display.label }}</p>\n </mat-list-option>\n </mat-selection-list>\n <dbx-injected-content [config]=\"footerConfig\"></dbx-injected-content>\n </div>\n </dbx-loading>\n</div>\n\n<!-- Filter Input -->\n<ng-template #filterTemplate>\n <div class=\"dbx-pickable-item-field-filter\">\n <mat-form-field class=\"dbx-pickable-item-field-filter-field\" appearance=\"fill\">\n <mat-label>{{ filterLabel }}</mat-label>\n <input name=\"filter items\" #filterMatInput=\"matInput\" matInput [placeholder]=\"placeholder\"\n [formControl]=\"inputCtrl\">\n </mat-form-field>\n <div class=\"searchable-field-form-loading\">\n <dbx-loading [linear]=\"true\" [context]=\"filterResultsContext\"></dbx-loading>\n </div>\n </div>\n</ng-template>\n", components: [{ type: i1$1.DbxLoadingComponent, selector: "dbx-loading", inputs: ["show", "text", "mode", "color", "diameter", "linear", "context", "loading", "error"] }, { type: i2$3.MatSelectionList, selector: "mat-selection-list", inputs: ["disableRipple", "tabIndex", "color", "compareWith", "disabled", "multiple"], outputs: ["selectionChange"], exportAs: ["matSelectionList"] }, { type: i2$3.MatListOption, selector: "mat-list-option", inputs: ["disableRipple", "checkboxPosition", "color", "value", "disabled", "selected"], outputs: ["selectedChange"], exportAs: ["matListOption"] }, { type: i2.DbxInjectedComponent, selector: "dbx-injected-content, [dbx-injected-content]", inputs: ["config", "template"] }, { type: i4.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i4.MatLabel, selector: "mat-label" }, { type: i6.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: i3.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.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }], pipes: { "async": i5.AsyncPipe } });
1369
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxPickableListFieldComponent, decorators: [{
1370
+ type: Component,
1371
+ args: [{ template: "<div class=\"dbx-pickable-item-field\">\n <dbx-loading [context]=\"context\">\n <ng-container *ngIf=\"showFilterInput\">\n <ng-container *ngTemplateOutlet=\"filterTemplate\"></ng-container>\n </ng-container>\n <div class=\"dbx-model-list dbx-pickable-item-field-list\">\n <mat-selection-list [multiple]=\"multiSelect\" (selectionChange)=\"matSelectionChanged($event)\">\n <mat-list-option *ngFor=\"let item of items$ | async\" [selected]=\"item.selected\" [value]=\"item\">\n <p>{{ item.display.label }}</p>\n </mat-list-option>\n </mat-selection-list>\n <dbx-injected-content [config]=\"footerConfig\"></dbx-injected-content>\n </div>\n </dbx-loading>\n</div>\n\n<!-- Filter Input -->\n<ng-template #filterTemplate>\n <div class=\"dbx-pickable-item-field-filter\">\n <mat-form-field class=\"dbx-pickable-item-field-filter-field\" appearance=\"fill\">\n <mat-label>{{ filterLabel }}</mat-label>\n <input name=\"filter items\" #filterMatInput=\"matInput\" matInput [placeholder]=\"placeholder\"\n [formControl]=\"inputCtrl\">\n </mat-form-field>\n <div class=\"searchable-field-form-loading\">\n <dbx-loading [linear]=\"true\" [context]=\"filterResultsContext\"></dbx-loading>\n </div>\n </div>\n</ng-template>\n" }]
1372
+ }] });
1373
+
1374
+ class DbxFormFormlyPickableFieldModule {
1375
+ }
1376
+ DbxFormFormlyPickableFieldModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyPickableFieldModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1377
+ DbxFormFormlyPickableFieldModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyPickableFieldModule, declarations: [DbxPickableChipFieldComponent,
1378
+ DbxPickableListFieldComponent], imports: [CommonModule,
1379
+ DbxTextModule,
1380
+ DbxLoadingModule,
1381
+ DbxButtonModule,
1382
+ FormsModule,
1383
+ MatButtonModule,
1384
+ MatInputModule,
1385
+ MatFormFieldModule,
1386
+ ReactiveFormsModule,
1387
+ MatAutocompleteModule,
1388
+ MatListModule,
1389
+ DbxDatePipeModule,
1390
+ DbxAnchorModule,
1391
+ MatChipsModule,
1392
+ MatIconModule,
1393
+ DbxInjectedComponentModule, i1$4.FormlyModule] });
1394
+ DbxFormFormlyPickableFieldModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyPickableFieldModule, imports: [[
1395
+ CommonModule,
1396
+ DbxTextModule,
1397
+ DbxLoadingModule,
1398
+ DbxButtonModule,
1399
+ FormsModule,
1400
+ MatButtonModule,
1401
+ MatInputModule,
1402
+ MatFormFieldModule,
1403
+ ReactiveFormsModule,
1404
+ MatAutocompleteModule,
1405
+ MatListModule,
1406
+ DbxDatePipeModule,
1407
+ DbxAnchorModule,
1408
+ MatChipsModule,
1409
+ MatIconModule,
1410
+ DbxInjectedComponentModule,
1411
+ FormlyModule.forChild({
1412
+ types: [
1413
+ { name: 'pickablechipfield', component: DbxPickableChipFieldComponent },
1414
+ { name: 'pickablelistfield', component: DbxPickableListFieldComponent },
1415
+ ]
1416
+ })
1417
+ ]] });
1418
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyPickableFieldModule, decorators: [{
1419
+ type: NgModule,
1420
+ args: [{
1421
+ imports: [
1422
+ CommonModule,
1423
+ DbxTextModule,
1424
+ DbxLoadingModule,
1425
+ DbxButtonModule,
1426
+ FormsModule,
1427
+ MatButtonModule,
1428
+ MatInputModule,
1429
+ MatFormFieldModule,
1430
+ ReactiveFormsModule,
1431
+ MatAutocompleteModule,
1432
+ MatListModule,
1433
+ DbxDatePipeModule,
1434
+ DbxAnchorModule,
1435
+ MatChipsModule,
1436
+ MatIconModule,
1437
+ DbxInjectedComponentModule,
1438
+ FormlyModule.forChild({
1439
+ types: [
1440
+ { name: 'pickablechipfield', component: DbxPickableChipFieldComponent },
1441
+ { name: 'pickablelistfield', component: DbxPickableListFieldComponent },
1442
+ ]
1443
+ })
1444
+ ],
1445
+ declarations: [
1446
+ DbxPickableChipFieldComponent,
1447
+ DbxPickableListFieldComponent
1448
+ ],
1449
+ exports: []
1450
+ }]
1451
+ }] });
1452
+
1453
+ class DbxSearchableFieldAutocompleteItemComponent {
1454
+ ngOnInit() {
1455
+ var _a;
1456
+ this.content.clear();
1457
+ const componentClass = (_a = this.displayValue) === null || _a === void 0 ? void 0 : _a.componentClass;
1458
+ if (componentClass) {
1459
+ const componentRef = this.content.createComponent(componentClass);
1460
+ componentRef.instance.displayValue = this.displayValue;
1461
+ }
1462
+ }
1463
+ }
1464
+ DbxSearchableFieldAutocompleteItemComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxSearchableFieldAutocompleteItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1465
+ DbxSearchableFieldAutocompleteItemComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbxSearchableFieldAutocompleteItemComponent, selector: "dbx-searchable-field-autocomplete-item", inputs: { displayValue: "displayValue" }, viewQueries: [{ propertyName: "content", first: true, predicate: ["content"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: `
1466
+ <ng-template #content></ng-template>
1467
+ `, isInline: true });
1468
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxSearchableFieldAutocompleteItemComponent, decorators: [{
1469
+ type: Component,
1470
+ args: [{
1471
+ selector: 'dbx-searchable-field-autocomplete-item',
1472
+ template: `
1473
+ <ng-template #content></ng-template>
1474
+ `
1475
+ }]
1476
+ }], propDecorators: { content: [{
1477
+ type: ViewChild,
1478
+ args: ['content', { static: true, read: ViewContainerRef }]
1479
+ }], displayValue: [{
1480
+ type: Input
1481
+ }] } });
1482
+ // MARK: Default
1483
+ class DbxDefaultSearchableFieldDisplayComponent {
1484
+ }
1485
+ DbxDefaultSearchableFieldDisplayComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxDefaultSearchableFieldDisplayComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1486
+ DbxDefaultSearchableFieldDisplayComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbxDefaultSearchableFieldDisplayComponent, selector: "dbx-default-searchable-field-display", inputs: { displayValue: "displayValue" }, ngImport: i0, template: `
1487
+ <span class="s-chip-label">{{ displayValue.label }}</span>
1488
+ <span class="s-chip-sublabel" *ngIf="displayValue.sublabel">({{ displayValue.sublabel }})</span>
1489
+ `, isInline: true, directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
1490
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxDefaultSearchableFieldDisplayComponent, decorators: [{
1491
+ type: Component,
1492
+ args: [{
1493
+ selector: 'dbx-default-searchable-field-display',
1494
+ template: `
1495
+ <span class="s-chip-label">{{ displayValue.label }}</span>
1496
+ <span class="s-chip-sublabel" *ngIf="displayValue.sublabel">({{ displayValue.sublabel }})</span>
1497
+ `
1498
+ }]
1499
+ }], propDecorators: { displayValue: [{
1500
+ type: Input
1501
+ }] } });
1502
+ class DbxDefaultSearchableAnchorFieldDisplayComponent {
1503
+ }
1504
+ DbxDefaultSearchableAnchorFieldDisplayComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxDefaultSearchableAnchorFieldDisplayComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1505
+ DbxDefaultSearchableAnchorFieldDisplayComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbxDefaultSearchableAnchorFieldDisplayComponent, selector: "ng-component", inputs: { displayValue: "displayValue" }, ngImport: i0, template: `
1506
+ <dbx-anchor [block]="true" [anchor]="displayValue?.anchor">
1507
+ <dbx-default-searchable-field-display [displayValue]="displayValue"></dbx-default-searchable-field-display>
1508
+ </dbx-anchor>
1509
+ `, isInline: true, components: [{ type: i1$1.DbxAnchorComponent, selector: "dbx-anchor, [dbx-anchor]", inputs: ["block"] }, { type: DbxDefaultSearchableFieldDisplayComponent, selector: "dbx-default-searchable-field-display", inputs: ["displayValue"] }] });
1510
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxDefaultSearchableAnchorFieldDisplayComponent, decorators: [{
1511
+ type: Component,
1512
+ args: [{
1513
+ template: `
1514
+ <dbx-anchor [block]="true" [anchor]="displayValue?.anchor">
1515
+ <dbx-default-searchable-field-display [displayValue]="displayValue"></dbx-default-searchable-field-display>
1516
+ </dbx-anchor>
1517
+ `
1518
+ }]
1519
+ }], propDecorators: { displayValue: [{
1520
+ type: Input
1521
+ }] } });
1522
+
1523
+ /**
1524
+ * Abstract searchable field that provides a feature for searching for values, and for displaying values using Observables.
1525
+ *
1526
+ * Display values are cached for performance.
1527
+ */
1528
+ class AbstractDbxSearchableValueFieldDirective extends FieldType {
1529
+ constructor() {
1530
+ super(...arguments);
1531
+ /**
1532
+ * Whether or not to set/get values as an array.
1533
+ */
1534
+ this.multiSelect = true;
1535
+ this.inputCtrl = new FormControl('');
1536
+ this._formControlObs = new BehaviorSubject(undefined);
1537
+ this.formControl$ = this._formControlObs.pipe(filterMaybe());
1538
+ this._displayHashMap = new BehaviorSubject(new Map());
1539
+ this.inputValue$ = this.inputCtrl.valueChanges.pipe();
1540
+ this.inputValueString$ = this.inputValue$.pipe(debounceTime$1(200), distinctUntilChanged$1());
1541
+ this.searchResultsState$ = this.inputValueString$.pipe(filter$1((text) => Boolean(text || this.searchOnEmptyText) && Boolean(this.search)),
1542
+ // TODO: Consider caching search text/results.
1543
+ switchMap$1((text) => this.search(text).pipe(switchMap$1((x) => this.loadDisplayValuesForFieldValues(x)),
1544
+ // Return begin loading to setup the loading state.
1545
+ startWith(beginLoading()))), shareReplay$1(1));
1546
+ this.singleValueSyncSubscription = new SubscriptionObject();
1547
+ this.searchContext = new LoadingStateContextInstance({ obs: this.searchResultsState$, showLoadingOnNoValue: true });
1548
+ this.searchResults$ = this.searchResultsState$.pipe(map$1(x => { var _a; return (_a = x === null || x === void 0 ? void 0 : x.value) !== null && _a !== void 0 ? _a : []; }));
1549
+ this._formControlValue = this.formControl$.pipe(switchMap$1(control => control.valueChanges.pipe(startWith(control.value), shareReplay$1(1))));
1550
+ this.values$ = this._formControlValue.pipe(map$1(convertMaybeToArray), shareReplay$1(1));
1551
+ this.displayValuesState$ = this.values$.pipe(distinctUntilChanged$1(), switchMap$1((values) => this.loadDisplayValuesForValues(values)), shareReplay$1(1));
1552
+ this.displayValues$ = this.displayValuesState$.pipe(map$1(x => { var _a; return (_a = x === null || x === void 0 ? void 0 : x.value) !== null && _a !== void 0 ? _a : []; }));
1553
+ }
1554
+ get name() {
1555
+ var _a, _b;
1556
+ return (_a = this.field.name) !== null && _a !== void 0 ? _a : (camelCase((_b = this.label) !== null && _b !== void 0 ? _b : this.key));
1557
+ }
1558
+ get label() {
1559
+ var _a;
1560
+ return (_a = this.field.templateOptions) === null || _a === void 0 ? void 0 : _a.label;
1561
+ }
1562
+ get readonly() {
1563
+ var _a;
1564
+ return (_a = this.field.templateOptions) === null || _a === void 0 ? void 0 : _a.readonly;
1565
+ }
1566
+ get searchOnEmptyText() {
1567
+ var _a;
1568
+ return (_a = this.field.searchOnEmptyText) !== null && _a !== void 0 ? _a : false;
1569
+ }
1570
+ get required() {
1571
+ var _a;
1572
+ return (_a = this.field.templateOptions) === null || _a === void 0 ? void 0 : _a.required;
1573
+ }
1574
+ get autocomplete() {
1575
+ var _a, _b, _c;
1576
+ return (_c = (_b = (_a = this.field.templateOptions) === null || _a === void 0 ? void 0 : _a.attributes) === null || _b === void 0 ? void 0 : _b['autocomplete']) !== null && _c !== void 0 ? _c : this.key;
1577
+ }
1578
+ get placeholder() {
1579
+ var _a, _b;
1580
+ return (_b = (_a = this.field.templateOptions) === null || _a === void 0 ? void 0 : _a.placeholder) !== null && _b !== void 0 ? _b : '';
1581
+ }
1582
+ get description() {
1583
+ var _a, _b;
1584
+ return (_a = this.field.description) !== null && _a !== void 0 ? _a : (_b = this.field.templateOptions) === null || _b === void 0 ? void 0 : _b.description;
1585
+ }
1586
+ get hashForValue() {
1587
+ var _a;
1588
+ return (_a = this.field.hashForValue) !== null && _a !== void 0 ? _a : ((x) => x);
1589
+ }
1590
+ get displayForValue() {
1591
+ return this.field.displayForValue;
1592
+ }
1593
+ get useAnchor() {
1594
+ return this.field.useAnchor;
1595
+ }
1596
+ get anchorForValue() {
1597
+ return this.field.anchorForValue;
1598
+ }
1599
+ get componentClass() {
1600
+ return this.field.componentClass;
1601
+ }
1602
+ get search() {
1603
+ return this.field.search;
1604
+ }
1605
+ get values() {
1606
+ var _a;
1607
+ return (_a = this._getValueOnFormControl(this.formControl.value)) !== null && _a !== void 0 ? _a : [];
1608
+ }
1609
+ get allowStringValues() {
1610
+ var _a;
1611
+ return (_a = this.allowStringValues) !== null && _a !== void 0 ? _a : Boolean(this.convertStringValue);
1612
+ }
1613
+ get convertStringValue() {
1614
+ return this.field.convertStringValue;
1615
+ }
1616
+ loadDisplayValuesForValues(values) {
1617
+ return this.loadDisplayValuesForFieldValues(values.map((value) => ({ value })));
1618
+ }
1619
+ loadDisplayValuesForFieldValues(values) {
1620
+ return this.getDisplayValuesForFieldValues(values).pipe(map$1((displayValues) => ({ loading: false, model: displayValues })), startWith({ loading: true }), shareReplay$1(1));
1621
+ }
1622
+ getDisplayValuesForFieldValues(values) {
1623
+ return this._displayHashMap.pipe(mergeMap((displayMap) => {
1624
+ var _a;
1625
+ const mappingResult = values
1626
+ .map(x => [x, this.hashForValue(x.value)])
1627
+ .map(([x, hash], i) => [i, hash, x, displayMap.get(hash)]);
1628
+ const hasDisplay = mappingResult.filter(x => Boolean(x[3]));
1629
+ const needsDisplay = mappingResult.filter(x => !x[3]);
1630
+ if (needsDisplay.length > 0) {
1631
+ // Go get the display value.
1632
+ const displayValuesObs = this.displayForValue(needsDisplay.map(x => x[2]));
1633
+ const componentClass = (_a = this.componentClass) !== null && _a !== void 0 ? _a : this.defaultComponentClass;
1634
+ const anchorForValue = this.useAnchor && this.anchorForValue;
1635
+ return displayValuesObs.pipe(first$1(), map$1((displayResults) => {
1636
+ // Assign the default component classes.
1637
+ displayResults.forEach(x => {
1638
+ if (!x.componentClass) {
1639
+ x.componentClass = componentClass;
1640
+ }
1641
+ if (!x.anchor && anchorForValue) {
1642
+ x.anchor = anchorForValue(x);
1643
+ }
1644
+ });
1645
+ // Create a map to re-join values later.
1646
+ const displayResultsMapping = displayResults.map(x => [x, this.hashForValue(x.value)]);
1647
+ const valueIndexHashMap = new Map(displayResultsMapping.map(([x, hash]) => [hash, x]));
1648
+ // Update displayMap. No need to push an update notification.
1649
+ displayResultsMapping.forEach(([x, hash]) => displayMap.set(hash, x));
1650
+ // Zip values back together.
1651
+ const newDisplayValues = mappingResult.map(x => { var _a; return (_a = x[3]) !== null && _a !== void 0 ? _a : valueIndexHashMap.get(x[1]); });
1652
+ // Return display values.
1653
+ return newDisplayValues;
1654
+ }));
1655
+ }
1656
+ else {
1657
+ // If all display values are hashed return that.
1658
+ return of(hasDisplay.map(x => x[3]));
1659
+ }
1660
+ }));
1661
+ }
1662
+ ngOnInit() {
1663
+ this._formControlObs.next(this.formControl);
1664
+ if (this.field.textInputValidator) {
1665
+ this.inputCtrl.setValidators(this.field.textInputValidator);
1666
+ }
1667
+ if (!this.defaultComponentClass) {
1668
+ if (this.useAnchor) {
1669
+ this.defaultComponentClass = DbxDefaultSearchableAnchorFieldDisplayComponent;
1670
+ }
1671
+ else {
1672
+ this.defaultComponentClass = DbxDefaultSearchableFieldDisplayComponent;
1673
+ }
1674
+ }
1675
+ if (this.multiSelect === false) {
1676
+ this.singleValueSyncSubscription.subscription = this.displayValues$.subscribe((x) => {
1677
+ if (x[0]) {
1678
+ this._syncSingleValue(x[0]);
1679
+ }
1680
+ });
1681
+ }
1682
+ }
1683
+ ngOnDestroy() {
1684
+ this._displayHashMap.complete();
1685
+ this._formControlObs.complete();
1686
+ this.searchContext.destroy();
1687
+ }
1688
+ /**
1689
+ * Used to sync the input control with the selected value.
1690
+ *
1691
+ * Only used when multiSelect is false.
1692
+ */
1693
+ _syncSingleValue(value) {
1694
+ this.inputCtrl.setValue(value.label);
1695
+ }
1696
+ _addWithTextValue(text) {
1697
+ if (!this.field.allowStringValues) {
1698
+ return;
1699
+ }
1700
+ if (text) {
1701
+ text = (text || '').trim();
1702
+ this.inputCtrl.setValue(text.trim());
1703
+ }
1704
+ // console.log('Add: ', text, this.inputCtrl.valid);
1705
+ if (!this.inputCtrl.valid) {
1706
+ return;
1707
+ }
1708
+ if (text) {
1709
+ const value = (this.convertStringValue) ? this.convertStringValue(text) : text;
1710
+ this.addValue(value);
1711
+ }
1712
+ }
1713
+ addWithDisplayValue(displayValue) {
1714
+ this.addValue(displayValue.value);
1715
+ }
1716
+ removeWithDisplayValue(displayValue) {
1717
+ this.removeValue(displayValue.value);
1718
+ }
1719
+ addValue(value) {
1720
+ this.textInput.nativeElement.value = '';
1721
+ this.inputCtrl.setValue(null);
1722
+ this.setValues([...this.values, value]);
1723
+ }
1724
+ removeValue(value) {
1725
+ let values;
1726
+ if (this.hashForValue) {
1727
+ const hashToFilter = this.hashForValue(value);
1728
+ values = this.values.filter(x => this.hashForValue(x) !== hashToFilter);
1729
+ }
1730
+ else {
1731
+ values = this.values.filter(x => x !== value);
1732
+ }
1733
+ this.setValues(values);
1734
+ }
1735
+ setValues(values) {
1736
+ // Use to filter non-unique values.
1737
+ if (this.hashForValue) {
1738
+ values = findUnique(values, this.hashForValue);
1739
+ }
1740
+ this._setValueOnFormControl(values);
1741
+ }
1742
+ // MARK: Internal
1743
+ _getValueOnFormControl(valueOnFormControl) {
1744
+ const value = (valueOnFormControl != null) ? [].concat(valueOnFormControl) : []; // Always return an array.
1745
+ return value;
1746
+ }
1747
+ _setValueOnFormControl(values) {
1748
+ const value = (this.multiSelect) ? values : values === null || values === void 0 ? void 0 : values[0];
1749
+ this.formControl.setValue(value);
1750
+ this.formControl.markAsDirty();
1751
+ this.formControl.markAsTouched();
1752
+ }
1753
+ }
1754
+ AbstractDbxSearchableValueFieldDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractDbxSearchableValueFieldDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1755
+ AbstractDbxSearchableValueFieldDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: AbstractDbxSearchableValueFieldDirective, viewQueries: [{ propertyName: "textInput", first: true, predicate: ["textInput"], descendants: true }], usesInheritance: true, ngImport: i0 });
1756
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractDbxSearchableValueFieldDirective, decorators: [{
1757
+ type: Directive
1758
+ }], propDecorators: { textInput: [{
1759
+ type: ViewChild,
1760
+ args: ['textInput']
1761
+ }] } });
1762
+
1763
+ class DbxSearchableChipFieldComponent extends AbstractDbxSearchableValueFieldDirective {
1764
+ constructor() {
1765
+ super(...arguments);
1766
+ this.separatorKeysCodes = [ENTER, COMMA];
1767
+ }
1768
+ selected(event) {
1769
+ this.addWithDisplayValue(event.option.value);
1770
+ }
1771
+ tabPressedOnInput(event) {
1772
+ var _a;
1773
+ if (((_a = event === null || event === void 0 ? void 0 : event.key) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'tab') {
1774
+ const value = this.inputCtrl.value;
1775
+ if ((value || '').trim()) {
1776
+ this._addWithTextValue(value);
1777
+ event.preventDefault();
1778
+ event.stopImmediatePropagation();
1779
+ return false;
1780
+ }
1781
+ }
1782
+ return true;
1783
+ }
1784
+ addChip(event) {
1785
+ var _a;
1786
+ const text = (_a = event.value) !== null && _a !== void 0 ? _a : this.inputCtrl.value;
1787
+ return this._addWithTextValue(text);
1788
+ }
1789
+ }
1790
+ DbxSearchableChipFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxSearchableChipFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1791
+ DbxSearchableChipFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbxSearchableChipFieldComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: "<div class=\"dbx-searchable-field\">\n <!-- Autocomplete -->\n <mat-autocomplete #auto=\"matAutocomplete\" (optionSelected)=\"selected($event)\">\n <mat-option *ngFor=\"let displayValue of (searchResults$ | async)\" [value]=\"displayValue\">\n <dbx-searchable-field-autocomplete-item [displayValue]=\"displayValue\">\n </dbx-searchable-field-autocomplete-item>\n </mat-option>\n </mat-autocomplete>\n <!-- Template -->\n <ng-template #content>\n <mat-form-field class=\"dbx-searchable-field-form-field\">\n <mat-label>{{ label }}</mat-label>\n <!-- TODO: Add back aria-label [attr.aria-label]=\"'email ' + emailParticipantsType\" -->\n <mat-chip-list [required]=\"required\" [disabled]=\"readonly\" #chipList>\n <mat-chip *ngFor=\"let displayValue of displayValues$ | async\" [removable]=\"true\"\n (removed)=\"removeWithDisplayValue(displayValue)\">\n <span class=\"s-chip-label\">{{ displayValue.label }}</span>\n <span class=\"s-chip-sublabel\" *ngIf=\"displayValue.sublabel\">({{ displayValue.sublabel }})</span>\n <mat-icon *ngIf=\"!readonly\" matChipRemove>cancel</mat-icon>\n </mat-chip>\n <input #textInput [name]=\"name\" [placeholder]=\"placeholder\" [formControl]=\"inputCtrl\" [matAutocomplete]=\"auto\"\n autocomplete=\"{{ autocomplete }}\" [matChipInputFor]=\"chipList\" (keydown)=\"tabPressedOnInput($event)\"\n [matChipInputSeparatorKeyCodes]=\"separatorKeysCodes\" (matChipInputTokenEnd)=\"addChip($event)\">\n </mat-chip-list>\n <mat-hint *ngIf=\"description\">{{ description }}</mat-hint>\n </mat-form-field>\n <div class=\"searchable-field-form-loading\">\n <dbx-loading [linear]=\"true\" [context]=\"searchContext\"></dbx-loading>\n </div>\n </ng-template>\n <!-- View -->\n <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n</div>\n", components: [{ type: i1$5.MatAutocomplete, selector: "mat-autocomplete", inputs: ["disableRipple"], exportAs: ["matAutocomplete"] }, { type: i2$2.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: DbxSearchableFieldAutocompleteItemComponent, selector: "dbx-searchable-field-autocomplete-item", inputs: ["displayValue"] }, { type: i4.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i5$1.MatChipList, selector: "mat-chip-list", inputs: ["errorStateMatcher", "multiple", "compareWith", "value", "required", "placeholder", "disabled", "aria-orientation", "selectable", "tabIndex"], outputs: ["change", "valueChange"], exportAs: ["matChipList"] }, { type: i2$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i1$1.DbxLoadingComponent, selector: "dbx-loading", inputs: ["show", "text", "mode", "color", "diameter", "linear", "context", "loading", "error"] }], directives: [{ type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i4.MatLabel, selector: "mat-label" }, { type: i5$1.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: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5$1.MatChipRemove, selector: "[matChipRemove]" }, { type: i3.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: i1$5.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", exportAs: ["matAutocompleteTrigger"] }, { type: i5$1.MatChipInput, selector: "input[matChipInputFor]", inputs: ["matChipInputFor", "matChipInputAddOnBlur", "matChipInputSeparatorKeyCodes", "placeholder", "id", "disabled"], outputs: ["matChipInputTokenEnd"], exportAs: ["matChipInput", "matChipInputFor"] }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i4.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], pipes: { "async": i5.AsyncPipe } });
1792
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxSearchableChipFieldComponent, decorators: [{
1793
+ type: Component,
1794
+ args: [{ template: "<div class=\"dbx-searchable-field\">\n <!-- Autocomplete -->\n <mat-autocomplete #auto=\"matAutocomplete\" (optionSelected)=\"selected($event)\">\n <mat-option *ngFor=\"let displayValue of (searchResults$ | async)\" [value]=\"displayValue\">\n <dbx-searchable-field-autocomplete-item [displayValue]=\"displayValue\">\n </dbx-searchable-field-autocomplete-item>\n </mat-option>\n </mat-autocomplete>\n <!-- Template -->\n <ng-template #content>\n <mat-form-field class=\"dbx-searchable-field-form-field\">\n <mat-label>{{ label }}</mat-label>\n <!-- TODO: Add back aria-label [attr.aria-label]=\"'email ' + emailParticipantsType\" -->\n <mat-chip-list [required]=\"required\" [disabled]=\"readonly\" #chipList>\n <mat-chip *ngFor=\"let displayValue of displayValues$ | async\" [removable]=\"true\"\n (removed)=\"removeWithDisplayValue(displayValue)\">\n <span class=\"s-chip-label\">{{ displayValue.label }}</span>\n <span class=\"s-chip-sublabel\" *ngIf=\"displayValue.sublabel\">({{ displayValue.sublabel }})</span>\n <mat-icon *ngIf=\"!readonly\" matChipRemove>cancel</mat-icon>\n </mat-chip>\n <input #textInput [name]=\"name\" [placeholder]=\"placeholder\" [formControl]=\"inputCtrl\" [matAutocomplete]=\"auto\"\n autocomplete=\"{{ autocomplete }}\" [matChipInputFor]=\"chipList\" (keydown)=\"tabPressedOnInput($event)\"\n [matChipInputSeparatorKeyCodes]=\"separatorKeysCodes\" (matChipInputTokenEnd)=\"addChip($event)\">\n </mat-chip-list>\n <mat-hint *ngIf=\"description\">{{ description }}</mat-hint>\n </mat-form-field>\n <div class=\"searchable-field-form-loading\">\n <dbx-loading [linear]=\"true\" [context]=\"searchContext\"></dbx-loading>\n </div>\n </ng-template>\n <!-- View -->\n <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n</div>\n" }]
1795
+ }] });
1796
+
1797
+ function makeMetaFilterSearchableFieldValueDisplayFn(loadMetaForValues, makeDisplayForValues) {
1798
+ return (values) => {
1799
+ const { included: loaded, excluded: needLoading } = separateValues(values, (x) => Boolean(x.meta));
1800
+ let allValues;
1801
+ if (needLoading.length > 0) {
1802
+ const loadingResult = loadMetaForValues(needLoading);
1803
+ allValues = loadingResult.pipe(map((result) => {
1804
+ const resultMap = arrayToMap(result, (x) => x.value);
1805
+ const mergedWithLoad = needLoading.map((x) => {
1806
+ var _a;
1807
+ const id = x.value;
1808
+ const loadedItem = resultMap.get(id);
1809
+ const anchor = (_a = x.anchor) !== null && _a !== void 0 ? _a : loadedItem === null || loadedItem === void 0 ? void 0 : loadedItem.anchor;
1810
+ const meta = loadedItem === null || loadedItem === void 0 ? void 0 : loadedItem.meta;
1811
+ return Object.assign(Object.assign({}, x), { anchor,
1812
+ meta });
1813
+ }).filter(x => !x.meta);
1814
+ return mergedWithLoad;
1815
+ }), map((result) => [...loaded, ...result]));
1816
+ }
1817
+ else {
1818
+ allValues = of(loaded);
1819
+ }
1820
+ return allValues.pipe(map((x) => makeDisplayForValues(x)));
1821
+ };
1822
+ }
1823
+ function searchableChipField(config) {
1824
+ return formlyField(Object.assign({ type: 'searchablechipfield' }, config));
1825
+ }
1826
+ function searchableTextField(config) {
1827
+ return formlyField(Object.assign({ type: 'searchabletextfield' }, config));
1828
+ }
1829
+
1830
+ /**
1831
+ * Display component for selecting a single item/value.
1832
+ */
1833
+ class DbxSearchableTextFieldComponent extends AbstractDbxSearchableValueFieldDirective {
1834
+ constructor() {
1835
+ super(...arguments);
1836
+ this.multiSelect = false;
1837
+ }
1838
+ selected(event) {
1839
+ const e = event;
1840
+ this.addWithDisplayValue(e.option.value);
1841
+ }
1842
+ }
1843
+ DbxSearchableTextFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxSearchableTextFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1844
+ DbxSearchableTextFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbxSearchableTextFieldComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: "<div class=\"dbx-searchable-text-field\">\n <!-- Autocomplete -->\n <mat-autocomplete #auto (optionSelected)=\"selected($event)\">\n <mat-option *ngFor=\"let displayValue of (searchResults$ | async)\" [value]=\"displayValue\">\n <dbx-searchable-field-autocomplete-item [displayValue]=\"displayValue\">\n </dbx-searchable-field-autocomplete-item>\n </mat-option>\n </mat-autocomplete>\n <!-- Template -->\n <ng-template #content>\n <mat-form-field class=\"dbx-searchable-field-form-field\">\n <mat-label>{{ label }}</mat-label>\n <input type=\"search\" [name]=\"name\" matInput #textInput [placeholder]=\"placeholder\" [formControl]=\"inputCtrl\" [matAutocomplete]=\"auto\"\n autocomplete=\"{{ autocomplete }}\">\n <mat-hint *ngIf=\"description\">{{ description }}</mat-hint>\n </mat-form-field>\n <div class=\"searchable-field-form-loading\">\n <dbx-loading [linear]=\"true\" [context]=\"searchContext\"></dbx-loading>\n </div>\n </ng-template>\n <!-- View -->\n <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n</div>\n", components: [{ type: i1$5.MatAutocomplete, selector: "mat-autocomplete", inputs: ["disableRipple"], exportAs: ["matAutocomplete"] }, { type: i2$2.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: DbxSearchableFieldAutocompleteItemComponent, selector: "dbx-searchable-field-autocomplete-item", inputs: ["displayValue"] }, { type: i4.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i1$1.DbxLoadingComponent, selector: "dbx-loading", inputs: ["show", "text", "mode", "color", "diameter", "linear", "context", "loading", "error"] }], directives: [{ type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i4.MatLabel, selector: "mat-label" }, { type: i6.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: i3.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: i1$5.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", exportAs: ["matAutocompleteTrigger"] }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], pipes: { "async": i5.AsyncPipe } });
1845
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxSearchableTextFieldComponent, decorators: [{
1846
+ type: Component,
1847
+ args: [{ template: "<div class=\"dbx-searchable-text-field\">\n <!-- Autocomplete -->\n <mat-autocomplete #auto (optionSelected)=\"selected($event)\">\n <mat-option *ngFor=\"let displayValue of (searchResults$ | async)\" [value]=\"displayValue\">\n <dbx-searchable-field-autocomplete-item [displayValue]=\"displayValue\">\n </dbx-searchable-field-autocomplete-item>\n </mat-option>\n </mat-autocomplete>\n <!-- Template -->\n <ng-template #content>\n <mat-form-field class=\"dbx-searchable-field-form-field\">\n <mat-label>{{ label }}</mat-label>\n <input type=\"search\" [name]=\"name\" matInput #textInput [placeholder]=\"placeholder\" [formControl]=\"inputCtrl\" [matAutocomplete]=\"auto\"\n autocomplete=\"{{ autocomplete }}\">\n <mat-hint *ngIf=\"description\">{{ description }}</mat-hint>\n </mat-form-field>\n <div class=\"searchable-field-form-loading\">\n <dbx-loading [linear]=\"true\" [context]=\"searchContext\"></dbx-loading>\n </div>\n </ng-template>\n <!-- View -->\n <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n</div>\n" }]
1848
+ }] });
1849
+
1850
+ class DbxFormFormlySearchableFieldModule {
1851
+ }
1852
+ DbxFormFormlySearchableFieldModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlySearchableFieldModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1853
+ DbxFormFormlySearchableFieldModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlySearchableFieldModule, declarations: [DbxSearchableChipFieldComponent,
1854
+ DbxSearchableTextFieldComponent,
1855
+ DbxSearchableFieldAutocompleteItemComponent,
1856
+ DbxDefaultSearchableFieldDisplayComponent,
1857
+ DbxDefaultSearchableAnchorFieldDisplayComponent], imports: [CommonModule,
1858
+ DbxTextModule,
1859
+ DbxLoadingModule,
1860
+ DbxButtonModule,
1861
+ FormsModule,
1862
+ MatButtonModule,
1863
+ MatInputModule,
1864
+ MatFormFieldModule,
1865
+ ReactiveFormsModule,
1866
+ MatAutocompleteModule,
1867
+ MatListModule,
1868
+ DbxDatePipeModule,
1869
+ DbxAnchorModule,
1870
+ MatChipsModule,
1871
+ MatIconModule,
1872
+ DbxInjectedComponentModule, i1$4.FormlyModule], exports: [DbxSearchableChipFieldComponent,
1873
+ DbxSearchableTextFieldComponent] });
1874
+ DbxFormFormlySearchableFieldModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlySearchableFieldModule, imports: [[
1875
+ CommonModule,
1876
+ DbxTextModule,
1877
+ DbxLoadingModule,
1878
+ DbxButtonModule,
1879
+ FormsModule,
1880
+ MatButtonModule,
1881
+ MatInputModule,
1882
+ MatFormFieldModule,
1883
+ ReactiveFormsModule,
1884
+ MatAutocompleteModule,
1885
+ MatListModule,
1886
+ DbxDatePipeModule,
1887
+ DbxAnchorModule,
1888
+ MatChipsModule,
1889
+ MatIconModule,
1890
+ DbxInjectedComponentModule,
1891
+ FormlyModule.forChild({
1892
+ types: [
1893
+ { name: 'searchablechipfield', component: DbxSearchableChipFieldComponent },
1894
+ { name: 'searchabletextfield', component: DbxSearchableTextFieldComponent }
1895
+ ]
1896
+ })
1897
+ ]] });
1898
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlySearchableFieldModule, decorators: [{
1899
+ type: NgModule,
1900
+ args: [{
1901
+ imports: [
1902
+ CommonModule,
1903
+ DbxTextModule,
1904
+ DbxLoadingModule,
1905
+ DbxButtonModule,
1906
+ FormsModule,
1907
+ MatButtonModule,
1908
+ MatInputModule,
1909
+ MatFormFieldModule,
1910
+ ReactiveFormsModule,
1911
+ MatAutocompleteModule,
1912
+ MatListModule,
1913
+ DbxDatePipeModule,
1914
+ DbxAnchorModule,
1915
+ MatChipsModule,
1916
+ MatIconModule,
1917
+ DbxInjectedComponentModule,
1918
+ FormlyModule.forChild({
1919
+ types: [
1920
+ { name: 'searchablechipfield', component: DbxSearchableChipFieldComponent },
1921
+ { name: 'searchabletextfield', component: DbxSearchableTextFieldComponent }
1922
+ ]
1923
+ })
1924
+ ],
1925
+ declarations: [
1926
+ DbxSearchableChipFieldComponent,
1927
+ DbxSearchableTextFieldComponent,
1928
+ DbxSearchableFieldAutocompleteItemComponent,
1929
+ DbxDefaultSearchableFieldDisplayComponent,
1930
+ DbxDefaultSearchableAnchorFieldDisplayComponent
1931
+ ],
1932
+ exports: [
1933
+ DbxSearchableChipFieldComponent,
1934
+ DbxSearchableTextFieldComponent
1935
+ ]
1936
+ }]
1937
+ }] });
1938
+
1939
+ function chipTextField(config) {
1940
+ const convertStringValue = (config.caseSensitive) ? ((x) => x) : ((x) => x === null || x === void 0 ? void 0 : x.toLowerCase());
1941
+ return formlyField(Object.assign(Object.assign({ type: 'searchablechipfield', allowStringValues: true, convertStringValue }, config), { displayForValue: (values) => {
1942
+ return of(values.map(x => (Object.assign(Object.assign({}, x), { label: x.value }))));
1943
+ } }));
1944
+ }
1945
+
1946
+ class DbxFormRepeatTypeComponent extends FieldArrayType {
1947
+ get repeatSection() {
1948
+ var _a;
1949
+ return (_a = this.to.repeatSection) !== null && _a !== void 0 ? _a : {};
1950
+ }
1951
+ get itemLabel() {
1952
+ var _a;
1953
+ return (_a = this.repeatSection.itemLabel) !== null && _a !== void 0 ? _a : '#';
1954
+ }
1955
+ get addText() {
1956
+ var _a;
1957
+ return (_a = this.repeatSection.addText) !== null && _a !== void 0 ? _a : 'Add';
1958
+ }
1959
+ get removeText() {
1960
+ var _a;
1961
+ return (_a = this.repeatSection.removeText) !== null && _a !== void 0 ? _a : 'Remove';
1962
+ }
1963
+ get max() {
1964
+ var _a;
1965
+ return (_a = this.field.templateOptions) === null || _a === void 0 ? void 0 : _a.maxLength;
1966
+ }
1967
+ get count() {
1968
+ var _a, _b;
1969
+ return (_b = (_a = this.field.fieldGroup) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
1970
+ }
1971
+ get canAdd() {
1972
+ const max = this.max;
1973
+ if (max == null) {
1974
+ return true;
1975
+ }
1976
+ else {
1977
+ return (this.count < max);
1978
+ }
1979
+ }
1980
+ }
1981
+ DbxFormRepeatTypeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormRepeatTypeComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1982
+ DbxFormRepeatTypeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbxFormRepeatTypeComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: `
1983
+ <div class="form-repeat-section">
1984
+ <!-- Fields -->
1985
+ <div class="form-repeat-section-fields">
1986
+ <ng-container *ngFor="let field of field.fieldGroup; let i = index; let last = last;">
1987
+ <div class="form-repeat-section-field">
1988
+ <div>
1989
+ <h4><span>{{ itemLabel }}</span><span>{{ i + 1 }}</span></h4>
1990
+ <dbx-button-spacer></dbx-button-spacer>
1991
+ <button mat-button color="warn" (click)="remove(i)">{{ removeText }}</button>
1992
+ </div>
1993
+ <formly-field [field]="field"></formly-field>
1994
+ </div>
1995
+ <mat-divider [inset]="true" *ngIf="!last"></mat-divider>
1996
+ </ng-container>
1997
+ </div>
1998
+ <!-- Add Button -->
1999
+ <div class="form-repeat-section-footer">
2000
+ <button *ngIf="canAdd" mat-button (click)="add()">{{ addText }}</button>
2001
+ </div>
2002
+ </div>
2003
+ `, isInline: true, components: [{ type: i1$1.DbxButtonSpacerComponent, selector: "dbx-button-spacer" }, { type: i1$4.FormlyField, selector: "formly-field", inputs: ["field"] }, { type: i3$2.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }], directives: [{ type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
2004
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormRepeatTypeComponent, decorators: [{
2005
+ type: Component,
2006
+ args: [{
2007
+ template: `
2008
+ <div class="form-repeat-section">
2009
+ <!-- Fields -->
2010
+ <div class="form-repeat-section-fields">
2011
+ <ng-container *ngFor="let field of field.fieldGroup; let i = index; let last = last;">
2012
+ <div class="form-repeat-section-field">
2013
+ <div>
2014
+ <h4><span>{{ itemLabel }}</span><span>{{ i + 1 }}</span></h4>
2015
+ <dbx-button-spacer></dbx-button-spacer>
2016
+ <button mat-button color="warn" (click)="remove(i)">{{ removeText }}</button>
2017
+ </div>
2018
+ <formly-field [field]="field"></formly-field>
2019
+ </div>
2020
+ <mat-divider [inset]="true" *ngIf="!last"></mat-divider>
2021
+ </ng-container>
2022
+ </div>
2023
+ <!-- Add Button -->
2024
+ <div class="form-repeat-section-footer">
2025
+ <button *ngIf="canAdd" mat-button (click)="add()">{{ addText }}</button>
2026
+ </div>
2027
+ </div>
2028
+ `
2029
+ }]
2030
+ }] });
2031
+
2032
+ class DbxFormFormlyArrayFieldModule {
2033
+ }
2034
+ DbxFormFormlyArrayFieldModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyArrayFieldModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2035
+ DbxFormFormlyArrayFieldModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyArrayFieldModule, declarations: [DbxFormRepeatTypeComponent], imports: [CommonModule,
2036
+ MatFormFieldModule,
2037
+ ReactiveFormsModule,
2038
+ MatDividerModule,
2039
+ DbxButtonModule, i1$4.FormlyModule] });
2040
+ DbxFormFormlyArrayFieldModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyArrayFieldModule, imports: [[
2041
+ CommonModule,
2042
+ MatFormFieldModule,
2043
+ ReactiveFormsModule,
2044
+ MatDividerModule,
2045
+ DbxButtonModule,
2046
+ FormlyModule.forChild({
2047
+ types: [
2048
+ { name: 'repeat', component: DbxFormRepeatTypeComponent }
2049
+ ]
2050
+ })
2051
+ ]] });
2052
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyArrayFieldModule, decorators: [{
2053
+ type: NgModule,
2054
+ args: [{
2055
+ imports: [
2056
+ CommonModule,
2057
+ MatFormFieldModule,
2058
+ ReactiveFormsModule,
2059
+ MatDividerModule,
2060
+ DbxButtonModule,
2061
+ FormlyModule.forChild({
2062
+ types: [
2063
+ { name: 'repeat', component: DbxFormRepeatTypeComponent }
2064
+ ]
2065
+ })
2066
+ ],
2067
+ declarations: [
2068
+ DbxFormRepeatTypeComponent
2069
+ ],
2070
+ exports: []
2071
+ }]
2072
+ }] });
2073
+
2074
+ class DbxFormFormlyBooleanFieldModule {
2075
+ }
2076
+ DbxFormFormlyBooleanFieldModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyBooleanFieldModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2077
+ DbxFormFormlyBooleanFieldModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyBooleanFieldModule });
2078
+ DbxFormFormlyBooleanFieldModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyBooleanFieldModule, imports: [[]] });
2079
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyBooleanFieldModule, decorators: [{
2080
+ type: NgModule,
2081
+ args: [{
2082
+ imports: [],
2083
+ declarations: [],
2084
+ exports: []
2085
+ }]
2086
+ }] });
2087
+
2088
+ function toggleField({ key, label, description, defaultValue, required, readonly }) {
2089
+ return formlyField({
2090
+ key,
2091
+ type: 'toggle',
2092
+ wrappers: ['autotouch', 'form-field'],
2093
+ defaultValue: defaultValue !== null && defaultValue !== void 0 ? defaultValue : false,
2094
+ templateOptions: {
2095
+ label,
2096
+ description,
2097
+ required,
2098
+ readonly
2099
+ }
2100
+ });
2101
+ }
2102
+ function checkboxField({ key, label = '', placeholder = '', defaultValue, required, readonly, autocomplete }) {
2103
+ return {
2104
+ key,
2105
+ type: 'checkbox',
2106
+ defaultValue,
2107
+ templateOptions: {
2108
+ label,
2109
+ placeholder,
2110
+ required,
2111
+ readonly,
2112
+ autocomplete
2113
+ },
2114
+ };
2115
+ }
2116
+ /*
2117
+ export function acceptTermsField({ key = 'accept', label = 'Accept Terms', description = 'In order to proceed, please accept terms', required = true }
2118
+ : Partial<FieldConfigWithDescription>): FormlyFieldConfig {
2119
+ return {
2120
+ key,
2121
+ type: 'checkbox',
2122
+ templateOptions: {
2123
+ label,
2124
+ description,
2125
+ pattern: 'true',
2126
+ required
2127
+ },
2128
+ validation: {
2129
+ messages: {
2130
+ pattern: 'Please accept the terms',
2131
+ },
2132
+ },
2133
+ } as FormlyFieldConfig;
2134
+ }
2135
+ */
2136
+
2137
+ var DateTimeFieldTimeMode;
2138
+ (function (DateTimeFieldTimeMode) {
2139
+ /**
2140
+ * Time is required.
2141
+ */
2142
+ DateTimeFieldTimeMode["REQUIRED"] = "required";
2143
+ /**
2144
+ * Time is optional.
2145
+ */
2146
+ DateTimeFieldTimeMode["OPTIONAL"] = "optional";
2147
+ /**
2148
+ * Time is permenantly off.
2149
+ */
2150
+ DateTimeFieldTimeMode["NONE"] = "none";
2151
+ })(DateTimeFieldTimeMode || (DateTimeFieldTimeMode = {}));
2152
+ class DbxDateTimeFieldComponent extends FieldType {
2153
+ constructor(cdRef) {
2154
+ super();
2155
+ this.cdRef = cdRef;
2156
+ this._sub = new SubscriptionObject();
2157
+ this._valueSub = new SubscriptionObject();
2158
+ this._fullDayControlObs = new BehaviorSubject(undefined);
2159
+ this.fullDayControl$ = this._fullDayControlObs.pipe(filterMaybe());
2160
+ this._offset = new BehaviorSubject(0);
2161
+ this._formControlObs = new BehaviorSubject(undefined);
2162
+ this.formControl$ = this._formControlObs.pipe(filterMaybe());
2163
+ this._updateTime = new Subject();
2164
+ this.value$ = this.formControl$.pipe(switchMap(control => control.valueChanges.pipe(startWith$1(control.value))), distinctUntilChanged((a, b) => isSameMinute(a, b)), shareReplay(1));
2165
+ /**
2166
+ * Used to trigger/display visual updates (specifically on timeDistance, etc.).
2167
+ */
2168
+ this.displayValue$ = interval(10 * 1000).pipe(startWith$1(0), map(_ => new Date().getMinutes()), distinctUntilChanged(), tap((_) => this.cdRef.markForCheck()), switchMap(_ => this.value$), shareReplay(1));
2169
+ this.timeString$ = this.value$.pipe(filter(x => Boolean(x)), map((x) => {
2170
+ const timezone = guessCurrentTimezone();
2171
+ const timeString = toReadableTimeString(x, timezone);
2172
+ return timeString;
2173
+ }));
2174
+ this.timeInputCtrl = new FormControl('', {
2175
+ validators: [
2176
+ Validators.pattern(/^([0-9]|(0[0-9])|(1[0-9])|(2[0-3]))(:)?([0-5][0-9])?(\s)?([apAP][Mm])?(\\s)*$/)
2177
+ ]
2178
+ });
2179
+ this._date = new BehaviorSubject(new Date());
2180
+ this._config = new BehaviorSubject(undefined);
2181
+ this.fullDay$ = this.fullDayControl$.pipe(switchMap(control => control.valueChanges.pipe(startWith$1(control.value))));
2182
+ this.showTimeInput$ = this.fullDay$.pipe(map(x => !x && this.timeMode !== DateTimeFieldTimeMode.NONE));
2183
+ this.showAddTime$ = this.showTimeInput$.pipe(map(x => !x && this.timeMode === DateTimeFieldTimeMode.OPTIONAL), shareReplay(1));
2184
+ this.date$ = this._date.pipe(distinctUntilChanged((a, b) => isSameDay(a, b)));
2185
+ this.dateValue$ = merge(this.value$.pipe(startWith$1(undefined)), this.date$).pipe(filterMaybe(), map((x) => startOfDay(x)), distinctUntilChanged((a, b) => isSameDay(a, b)), shareReplay(1));
2186
+ this.timeInput$ = this._updateTime.pipe(debounceTime(5), map(x => this.timeInputCtrl.value), distinctUntilChanged());
2187
+ this.config$ = this._config.pipe(switchMapMaybeObs(), shareReplay(1));
2188
+ this.rawDateTime$ = combineLatest([
2189
+ this.dateValue$.pipe(filterMaybe()),
2190
+ this.timeInput$.pipe(startWith$1(null)),
2191
+ this.fullDay$
2192
+ ]).pipe(map(([date, timeString, fullDay]) => {
2193
+ let result;
2194
+ if (fullDay) {
2195
+ if (this.field.fullDayInUTC) {
2196
+ result = utcDayForDate(date);
2197
+ }
2198
+ else {
2199
+ result = startOfDay(date);
2200
+ }
2201
+ }
2202
+ else if (timeString) {
2203
+ result = readableTimeStringToDate(timeString, {
2204
+ date,
2205
+ useSystemTimezone: true
2206
+ });
2207
+ }
2208
+ return result;
2209
+ }), filterMaybe(), distinctUntilChanged((a, b) => isSameMinute(a, b)), shareReplay(1));
2210
+ this.timeOutput$ = combineLatest([
2211
+ this.rawDateTime$,
2212
+ this._offset,
2213
+ this.config$.pipe(distinctUntilChanged()),
2214
+ ]).pipe(throttleTime(10, undefined, { leading: false, trailing: true }), distinctUntilChanged((current, next) => current[0] === next[0] && next[1] === 0), tap(([_, stepsOffset]) => (stepsOffset) ? this._offset.next(0) : 0), map(([date, stepsOffset, config]) => {
2215
+ const instance = new DateTimeMinuteInstance(Object.assign(Object.assign({ date }, config), { roundDownToMinute: true }));
2216
+ date = instance.limit(date);
2217
+ const minutes = stepsOffset * 5;
2218
+ date = addMinutes(date, minutes);
2219
+ return date;
2220
+ }), distinctUntilChanged((a, b) => a && b && isSameMinute(a, b)));
2221
+ }
2222
+ get timeOnly() {
2223
+ return this.field.timeOnly;
2224
+ }
2225
+ get showDateInput() {
2226
+ return !this.timeOnly;
2227
+ }
2228
+ get timeMode() {
2229
+ var _a;
2230
+ return (this.timeOnly) ? DateTimeFieldTimeMode.REQUIRED : ((_a = this.field.timeMode) !== null && _a !== void 0 ? _a : DateTimeFieldTimeMode.REQUIRED);
2231
+ }
2232
+ get description() {
2233
+ var _a;
2234
+ return (_a = this.field.templateOptions) === null || _a === void 0 ? void 0 : _a.description;
2235
+ }
2236
+ ngOnInit() {
2237
+ var _a, _b;
2238
+ this._formControlObs.next(this.formControl);
2239
+ this._config.next((_b = (_a = this.field).getConfigObs) === null || _b === void 0 ? void 0 : _b.call(_a));
2240
+ this._sub.subscription = this.timeOutput$.subscribe((value) => {
2241
+ this.formControl.setValue(value);
2242
+ this.formControl.markAsDirty();
2243
+ this.formControl.markAsTouched();
2244
+ });
2245
+ this._valueSub.subscription = this.timeString$.subscribe((x) => {
2246
+ this.timeInputCtrl.setValue(x);
2247
+ });
2248
+ const isFullDayField = this.field.fullDayFieldName;
2249
+ let fullDayFieldCtrl;
2250
+ if (isFullDayField) {
2251
+ fullDayFieldCtrl = this.form.get(isFullDayField);
2252
+ }
2253
+ if (!fullDayFieldCtrl) {
2254
+ this._fullDayInputCtrl = new FormControl(true);
2255
+ // Set the control in the form too if the name is defined.
2256
+ if (isFullDayField) {
2257
+ this.form.addControl(isFullDayField, this._fullDayInputCtrl);
2258
+ }
2259
+ fullDayFieldCtrl = this._fullDayInputCtrl;
2260
+ }
2261
+ this._fullDayControlObs.next(fullDayFieldCtrl);
2262
+ switch (this.field.timeMode) {
2263
+ case DateTimeFieldTimeMode.OPTIONAL:
2264
+ break;
2265
+ case DateTimeFieldTimeMode.NONE:
2266
+ this.removeTime();
2267
+ break;
2268
+ case DateTimeFieldTimeMode.REQUIRED:
2269
+ this.addTime();
2270
+ break;
2271
+ }
2272
+ }
2273
+ ngOnDestroy() {
2274
+ this._formControlObs.complete();
2275
+ this._date.complete();
2276
+ this._updateTime.complete();
2277
+ this._config.complete();
2278
+ this._sub.destroy();
2279
+ this._valueSub.destroy();
2280
+ }
2281
+ datePicked(event) {
2282
+ const date = event.value;
2283
+ if (date) {
2284
+ this._date.next(date);
2285
+ this._updateTime.next();
2286
+ }
2287
+ }
2288
+ setTime(time) {
2289
+ this.timeInputCtrl.setValue(time);
2290
+ this._offset.next(0);
2291
+ this._updateTime.next();
2292
+ }
2293
+ keydownOnInput(event) {
2294
+ var _a;
2295
+ let direction = 0;
2296
+ switch ((_a = event.key) === null || _a === void 0 ? void 0 : _a.toLowerCase()) {
2297
+ case 'arrowup':
2298
+ direction = 1;
2299
+ break;
2300
+ case 'arrowdown':
2301
+ direction = -1;
2302
+ break;
2303
+ }
2304
+ let offset = 1;
2305
+ if (event.altKey && event.shiftKey) {
2306
+ offset = 300;
2307
+ }
2308
+ else if (event.altKey) {
2309
+ offset = 60;
2310
+ }
2311
+ else if (event.shiftKey) {
2312
+ offset = 5;
2313
+ }
2314
+ if (direction !== 0) {
2315
+ this._offset.next(this._offset.value + (offset * direction));
2316
+ this._updateTime.next();
2317
+ }
2318
+ }
2319
+ focusTime() {
2320
+ }
2321
+ focusOutTime() {
2322
+ this._updateTime.next();
2323
+ }
2324
+ addTime() {
2325
+ this.setFullDay(false);
2326
+ }
2327
+ removeTime() {
2328
+ this.setFullDay(true);
2329
+ }
2330
+ setFullDay(fullDay) {
2331
+ this.fullDayControl$.pipe(first()).subscribe((x) => {
2332
+ x.setValue(fullDay);
2333
+ });
2334
+ }
2335
+ }
2336
+ DbxDateTimeFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxDateTimeFieldComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
2337
+ DbxDateTimeFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbxDateTimeFieldComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: "<div class=\"dbx-datetime-field\" fxLayout=\"row wrap\" fxLayout.xs=\"column wrap\" fxLayoutAlign=\"space-evenly stretch\">\n <!-- Date -->\n <div class=\"dbx-datetime-row\" fxFlex.lt-sm=\"100\" fxFlex=\"50\" *ngIf=\"showDateInput\">\n <ng-container *ngTemplateOutlet=\"dateInputTemplate\"></ng-container>\n </div>\n <!-- Time -->\n <div class=\"dbx-datetime-row\" fxFlex.lt-sm=\"100\" [fxFlex]=\"showDateInput ? 50 : 100\">\n <ng-container *ngIf=\"showTimeInput$ | async\">\n <ng-container *ngTemplateOutlet=\"timeMenuAndInputTemplate\"></ng-container>\n </ng-container>\n <div class=\"add-time-button-wrapper\" *ngIf=\"showAddTime$ | async\">\n <button mat-button class=\"add-time-button\" (click)=\"addTime()\">\n <mat-icon>timer</mat-icon> Add Time\n </button>\n </div>\n </div>\n <div class=\"dbx-datetime-row dbx-datetime-hint-row\" fxFlex=\"100\">\n <div class=\"dbx-hint\" [ngSwitch]=\"fullDay$ | async\">\n <small *ngSwitchCase=\"true\"><b class=\"dbx-ok\">All Day</b> {{ dateValue$ | async | date:'fullDate' }}\n ({{ dateValue$ | async | dateDistance }})</small>\n <small *ngSwitchCase=\"false\">\n <ng-container *ngIf=\"value$ | async\"><b class=\"dbx-ok\">At</b> {{ displayValue$ | async | date:'medium' }}\n ({{ displayValue$ | async | timeDistance }})</ng-container>\n </small>\n </div>\n <div class=\"dbx-small dbx-label\" *ngIf=\"description\">\n {{ description }}\n </div>\n </div>\n</div>\n\n<!-- Date Input Template -->\n<ng-template #dateInputTemplate>\n <button mat-icon-button (click)=\"picker.open()\">\n <mat-icon>calendar_today</mat-icon>\n </button>\n <mat-form-field class=\"dbx-datetime-row-field\">\n <mat-label>Date</mat-label>\n <input matInput [matDatepicker]=\"picker\" (dateChange)=\"datePicked($event)\" [value]=\"dateValue$ | async\">\n <mat-datepicker #picker></mat-datepicker>\n </mat-form-field>\n</ng-template>\n\n<!-- Time Menu/Input Template -->\n<ng-template #timeMenuAndInputTemplate>\n <button mat-icon-button [matMenuTriggerFor]=\"timemenu\" aria-label=\"opens the time menu\">\n <mat-icon>timer</mat-icon>\n </button>\n <mat-menu #timemenu=\"matMenu\">\n <ng-container *ngIf=\"timeMode === 'optional'\">\n <button mat-menu-item (click)=\"removeTime()\">\n <span>Remove Time</span>\n </button>\n <mat-divider></mat-divider>\n </ng-container>\n <button mat-menu-item (click)=\"setTime('12:00AM')\">\n <span>Midnight</span>\n </button>\n <button mat-menu-item (click)=\"setTime('6:00AM')\">\n <span>6:00AM</span>\n </button>\n <button mat-menu-item (click)=\"setTime('8:00AM')\">\n <span>8:00AM</span>\n </button>\n <button mat-menu-item (click)=\"setTime('10:00AM')\">\n <span>10:00AM</span>\n </button>\n <button mat-menu-item (click)=\"setTime('12:00PM')\">\n <span>Noon</span>\n </button>\n <button mat-menu-item (click)=\"setTime('2:00PM')\">\n <span>2:00PM</span>\n </button>\n <button mat-menu-item (click)=\"setTime('5:00PM')\">\n <span>5:00PM</span>\n </button>\n </mat-menu>\n <mat-form-field class=\"dbx-datetime-row-field\">\n <mat-label>Time</mat-label>\n <input #timeInput matInput [formControl]=\"timeInputCtrl\" (focus)=\"focusTime()\" (focusout)=\"focusOutTime()\"\n (keydown)=\"keydownOnInput($event)\">\n </mat-form-field>\n</ng-template>\n", components: [{ type: i1$2.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: i2$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i4.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i4$1.MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { type: i5$2.MatMenu, selector: "mat-menu", exportAs: ["matMenu"] }, { type: i5$2.MatMenuItem, selector: "[mat-menu-item]", inputs: ["disabled", "disableRipple", "role"], exportAs: ["matMenuItem"] }, { type: i3$2.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }], directives: [{ type: i3$1.DefaultLayoutDirective, selector: " [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md], [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md], [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm], [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { type: i3$1.DefaultLayoutAlignDirective, selector: " [fxLayoutAlign], [fxLayoutAlign.xs], [fxLayoutAlign.sm], [fxLayoutAlign.md], [fxLayoutAlign.lg], [fxLayoutAlign.xl], [fxLayoutAlign.lt-sm], [fxLayoutAlign.lt-md], [fxLayoutAlign.lt-lg], [fxLayoutAlign.lt-xl], [fxLayoutAlign.gt-xs], [fxLayoutAlign.gt-sm], [fxLayoutAlign.gt-md], [fxLayoutAlign.gt-lg]", inputs: ["fxLayoutAlign", "fxLayoutAlign.xs", "fxLayoutAlign.sm", "fxLayoutAlign.md", "fxLayoutAlign.lg", "fxLayoutAlign.xl", "fxLayoutAlign.lt-sm", "fxLayoutAlign.lt-md", "fxLayoutAlign.lt-lg", "fxLayoutAlign.lt-xl", "fxLayoutAlign.gt-xs", "fxLayoutAlign.gt-sm", "fxLayoutAlign.gt-md", "fxLayoutAlign.gt-lg"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3$1.DefaultFlexDirective, selector: " [fxFlex], [fxFlex.xs], [fxFlex.sm], [fxFlex.md], [fxFlex.lg], [fxFlex.xl], [fxFlex.lt-sm], [fxFlex.lt-md], [fxFlex.lt-lg], [fxFlex.lt-xl], [fxFlex.gt-xs], [fxFlex.gt-sm], [fxFlex.gt-md], [fxFlex.gt-lg]", inputs: ["fxFlex", "fxFlex.xs", "fxFlex.sm", "fxFlex.md", "fxFlex.lg", "fxFlex.xl", "fxFlex.lt-sm", "fxFlex.lt-md", "fxFlex.lt-lg", "fxFlex.lt-xl", "fxFlex.gt-xs", "fxFlex.gt-sm", "fxFlex.gt-md", "fxFlex.gt-lg"] }, { type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i5.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i5.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i4.MatLabel, selector: "mat-label" }, { type: i6.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.MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { type: i5$2.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", exportAs: ["matMenuTrigger"] }, { type: i3.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.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }], pipes: { "async": i5.AsyncPipe, "date": i5.DatePipe, "dateDistance": i2.DateDistancePipe, "timeDistance": i2.TimeDistancePipe } });
2338
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxDateTimeFieldComponent, decorators: [{
2339
+ type: Component,
2340
+ args: [{ template: "<div class=\"dbx-datetime-field\" fxLayout=\"row wrap\" fxLayout.xs=\"column wrap\" fxLayoutAlign=\"space-evenly stretch\">\n <!-- Date -->\n <div class=\"dbx-datetime-row\" fxFlex.lt-sm=\"100\" fxFlex=\"50\" *ngIf=\"showDateInput\">\n <ng-container *ngTemplateOutlet=\"dateInputTemplate\"></ng-container>\n </div>\n <!-- Time -->\n <div class=\"dbx-datetime-row\" fxFlex.lt-sm=\"100\" [fxFlex]=\"showDateInput ? 50 : 100\">\n <ng-container *ngIf=\"showTimeInput$ | async\">\n <ng-container *ngTemplateOutlet=\"timeMenuAndInputTemplate\"></ng-container>\n </ng-container>\n <div class=\"add-time-button-wrapper\" *ngIf=\"showAddTime$ | async\">\n <button mat-button class=\"add-time-button\" (click)=\"addTime()\">\n <mat-icon>timer</mat-icon> Add Time\n </button>\n </div>\n </div>\n <div class=\"dbx-datetime-row dbx-datetime-hint-row\" fxFlex=\"100\">\n <div class=\"dbx-hint\" [ngSwitch]=\"fullDay$ | async\">\n <small *ngSwitchCase=\"true\"><b class=\"dbx-ok\">All Day</b> {{ dateValue$ | async | date:'fullDate' }}\n ({{ dateValue$ | async | dateDistance }})</small>\n <small *ngSwitchCase=\"false\">\n <ng-container *ngIf=\"value$ | async\"><b class=\"dbx-ok\">At</b> {{ displayValue$ | async | date:'medium' }}\n ({{ displayValue$ | async | timeDistance }})</ng-container>\n </small>\n </div>\n <div class=\"dbx-small dbx-label\" *ngIf=\"description\">\n {{ description }}\n </div>\n </div>\n</div>\n\n<!-- Date Input Template -->\n<ng-template #dateInputTemplate>\n <button mat-icon-button (click)=\"picker.open()\">\n <mat-icon>calendar_today</mat-icon>\n </button>\n <mat-form-field class=\"dbx-datetime-row-field\">\n <mat-label>Date</mat-label>\n <input matInput [matDatepicker]=\"picker\" (dateChange)=\"datePicked($event)\" [value]=\"dateValue$ | async\">\n <mat-datepicker #picker></mat-datepicker>\n </mat-form-field>\n</ng-template>\n\n<!-- Time Menu/Input Template -->\n<ng-template #timeMenuAndInputTemplate>\n <button mat-icon-button [matMenuTriggerFor]=\"timemenu\" aria-label=\"opens the time menu\">\n <mat-icon>timer</mat-icon>\n </button>\n <mat-menu #timemenu=\"matMenu\">\n <ng-container *ngIf=\"timeMode === 'optional'\">\n <button mat-menu-item (click)=\"removeTime()\">\n <span>Remove Time</span>\n </button>\n <mat-divider></mat-divider>\n </ng-container>\n <button mat-menu-item (click)=\"setTime('12:00AM')\">\n <span>Midnight</span>\n </button>\n <button mat-menu-item (click)=\"setTime('6:00AM')\">\n <span>6:00AM</span>\n </button>\n <button mat-menu-item (click)=\"setTime('8:00AM')\">\n <span>8:00AM</span>\n </button>\n <button mat-menu-item (click)=\"setTime('10:00AM')\">\n <span>10:00AM</span>\n </button>\n <button mat-menu-item (click)=\"setTime('12:00PM')\">\n <span>Noon</span>\n </button>\n <button mat-menu-item (click)=\"setTime('2:00PM')\">\n <span>2:00PM</span>\n </button>\n <button mat-menu-item (click)=\"setTime('5:00PM')\">\n <span>5:00PM</span>\n </button>\n </mat-menu>\n <mat-form-field class=\"dbx-datetime-row-field\">\n <mat-label>Time</mat-label>\n <input #timeInput matInput [formControl]=\"timeInputCtrl\" (focus)=\"focusTime()\" (focusout)=\"focusOutTime()\"\n (keydown)=\"keydownOnInput($event)\">\n </mat-form-field>\n</ng-template>\n" }]
2341
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; } });
2342
+
2343
+ class DbxFormFormlyDateFieldModule {
2344
+ }
2345
+ DbxFormFormlyDateFieldModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyDateFieldModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2346
+ DbxFormFormlyDateFieldModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyDateFieldModule, declarations: [DbxDateTimeFieldComponent], imports: [CommonModule,
2347
+ FormsModule,
2348
+ MatInputModule,
2349
+ MatDividerModule,
2350
+ MatFormFieldModule,
2351
+ MatButtonModule,
2352
+ MatDatepickerModule,
2353
+ MatNativeDateModule,
2354
+ MatMenuModule,
2355
+ ReactiveFormsModule,
2356
+ DbxDatePipeModule,
2357
+ MatChipsModule,
2358
+ MatIconModule,
2359
+ FlexLayoutModule, i1$4.FormlyModule] });
2360
+ DbxFormFormlyDateFieldModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyDateFieldModule, imports: [[
2361
+ CommonModule,
2362
+ FormsModule,
2363
+ MatInputModule,
2364
+ MatDividerModule,
2365
+ MatFormFieldModule,
2366
+ MatButtonModule,
2367
+ MatDatepickerModule,
2368
+ MatNativeDateModule,
2369
+ MatMenuModule,
2370
+ ReactiveFormsModule,
2371
+ DbxDatePipeModule,
2372
+ MatChipsModule,
2373
+ MatIconModule,
2374
+ FlexLayoutModule,
2375
+ FormlyModule.forChild({
2376
+ types: [
2377
+ { name: 'datetime', component: DbxDateTimeFieldComponent }
2378
+ ]
2379
+ })
2380
+ ]] });
2381
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyDateFieldModule, decorators: [{
2382
+ type: NgModule,
2383
+ args: [{
2384
+ imports: [
2385
+ CommonModule,
2386
+ FormsModule,
2387
+ MatInputModule,
2388
+ MatDividerModule,
2389
+ MatFormFieldModule,
2390
+ MatButtonModule,
2391
+ MatDatepickerModule,
2392
+ MatNativeDateModule,
2393
+ MatMenuModule,
2394
+ ReactiveFormsModule,
2395
+ DbxDatePipeModule,
2396
+ MatChipsModule,
2397
+ MatIconModule,
2398
+ FlexLayoutModule,
2399
+ FormlyModule.forChild({
2400
+ types: [
2401
+ { name: 'datetime', component: DbxDateTimeFieldComponent }
2402
+ ]
2403
+ })
2404
+ ],
2405
+ declarations: [
2406
+ DbxDateTimeFieldComponent
2407
+ ],
2408
+ exports: []
2409
+ }]
2410
+ }] });
2411
+
2412
+ const TAKE_NEXT_UPCOMING_TIME_CONFIG_OBS = () => of({
2413
+ takeNextUpcomingTime: true,
2414
+ roundDownToMinute: true
2415
+ });
2416
+ /**
2417
+ * Same as DateTime field but with the Date input hidden by default.
2418
+ */
2419
+ function timeOnlyField(config) {
2420
+ return dateTimeField(Object.assign(Object.assign({}, config), { timeMode: DateTimeFieldTimeMode.REQUIRED, timeOnly: true }));
2421
+ }
2422
+ function dateTimeField({ key, label = '', placeholder = '', description = '', timeMode = DateTimeFieldTimeMode.REQUIRED, fullDayFieldName, getConfigObs, timeOnly = false, required = false }) {
2423
+ const fieldConfig = formlyField({
2424
+ key,
2425
+ type: 'datetime',
2426
+ timeMode: (timeOnly) ? DateTimeFieldTimeMode.REQUIRED : timeMode,
2427
+ fullDayFieldName,
2428
+ getConfigObs,
2429
+ timeOnly,
2430
+ templateOptions: {
2431
+ label,
2432
+ placeholder,
2433
+ required,
2434
+ description
2435
+ },
2436
+ });
2437
+ // TODO: Add configuration...
2438
+ return fieldConfig;
2439
+ }
2440
+
2441
+ function staticEnumField({ key, label = '', placeholder = '', description, multiple = false, required = false, options }) {
2442
+ const fieldConfig = formlyField({
2443
+ key,
2444
+ type: 'select',
2445
+ templateOptions: {
2446
+ label,
2447
+ description,
2448
+ placeholder,
2449
+ required,
2450
+ multiple,
2451
+ selectAllOption: 'Select All',
2452
+ options
2453
+ },
2454
+ });
2455
+ return fieldConfig;
2456
+ }
2457
+
2458
+ // TODO: Finish dynamic.enum before adding in
2459
+
2460
+ const DEFAULT_PREFERRED_COUNTRIES = ['us'];
2461
+ class DbxInternationalPhoneFieldComponent extends FieldType {
2462
+ get fieldInputKey() {
2463
+ return this.key;
2464
+ }
2465
+ get fieldFormGroup() {
2466
+ return this.form;
2467
+ }
2468
+ get label() {
2469
+ return this.field.templateOptions.label;
2470
+ }
2471
+ get placeholder() {
2472
+ return this.field.templateOptions.placeholder;
2473
+ }
2474
+ get description() {
2475
+ return this.field.templateOptions.description;
2476
+ }
2477
+ get preferredCountries() {
2478
+ var _a;
2479
+ return (_a = this.field.preferredCountries) !== null && _a !== void 0 ? _a : DEFAULT_PREFERRED_COUNTRIES;
2480
+ }
2481
+ get onlyCountries() {
2482
+ var _a;
2483
+ return (_a = this.field.onlyCountries) !== null && _a !== void 0 ? _a : [];
2484
+ }
2485
+ get required() {
2486
+ var _a;
2487
+ return (_a = this.field.templateOptions.required) !== null && _a !== void 0 ? _a : false;
2488
+ }
2489
+ get errors() {
2490
+ var _a;
2491
+ return (_a = this.field.formControl) === null || _a === void 0 ? void 0 : _a.errors;
2492
+ }
2493
+ }
2494
+ DbxInternationalPhoneFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxInternationalPhoneFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
2495
+ DbxInternationalPhoneFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbxInternationalPhoneFieldComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: "<div class=\"dbx-international-phone-field\" [formGroup]=\"fieldFormGroup\">\n <mat-form-field class=\"dbx-international-phone-form-field\">\n <ngx-mat-intl-tel-input [required]=\"required\" [preferredCountries]=\"preferredCountries\" [enablePlaceholder]=\"false\"\n name=\"phone\" [formControlName]=\"fieldInputKey\">\n </ngx-mat-intl-tel-input>\n <mat-error *ngIf=\"errors?.['required']\">Required Field</mat-error>\n <mat-error *ngIf=\"errors?.['validatePhoneNumber']\">Invalid Number</mat-error>\n <mat-hint>{{ description }}</mat-hint>\n </mat-form-field>\n</div>\n", components: [{ type: i4.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i2$4.NgxMatIntlTelInputComponent, selector: "ngx-mat-intl-tel-input", inputs: ["preferredCountries", "enablePlaceholder", "inputPlaceholder", "cssClass", "name", "onlyCountries", "errorStateMatcher", "enableSearch", "searchPlaceholder", "describedBy", "format", "placeholder", "required", "disabled"], outputs: ["countryChanged"] }], directives: [{ type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i3.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.MatError, selector: "mat-error", inputs: ["id"] }, { type: i4.MatHint, selector: "mat-hint", inputs: ["align", "id"] }] });
2496
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxInternationalPhoneFieldComponent, decorators: [{
2497
+ type: Component,
2498
+ args: [{ template: "<div class=\"dbx-international-phone-field\" [formGroup]=\"fieldFormGroup\">\n <mat-form-field class=\"dbx-international-phone-form-field\">\n <ngx-mat-intl-tel-input [required]=\"required\" [preferredCountries]=\"preferredCountries\" [enablePlaceholder]=\"false\"\n name=\"phone\" [formControlName]=\"fieldInputKey\">\n </ngx-mat-intl-tel-input>\n <mat-error *ngIf=\"errors?.['required']\">Required Field</mat-error>\n <mat-error *ngIf=\"errors?.['validatePhoneNumber']\">Invalid Number</mat-error>\n <mat-hint>{{ description }}</mat-hint>\n </mat-form-field>\n</div>\n" }]
2499
+ }] });
2500
+
2501
+ class DbxFormFormlyPhoneFieldModule {
2502
+ }
2503
+ DbxFormFormlyPhoneFieldModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyPhoneFieldModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2504
+ DbxFormFormlyPhoneFieldModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyPhoneFieldModule, declarations: [DbxInternationalPhoneFieldComponent], imports: [CommonModule,
2505
+ MatInputModule,
2506
+ FormsModule,
2507
+ NgxMatIntlTelInputModule,
2508
+ ReactiveFormsModule,
2509
+ MatAutocompleteModule,
2510
+ MatChipsModule,
2511
+ MatIconModule,
2512
+ FlexLayoutModule, i1$4.FormlyModule] });
2513
+ DbxFormFormlyPhoneFieldModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyPhoneFieldModule, imports: [[
2514
+ CommonModule,
2515
+ MatInputModule,
2516
+ FormsModule,
2517
+ NgxMatIntlTelInputModule,
2518
+ ReactiveFormsModule,
2519
+ MatAutocompleteModule,
2520
+ MatChipsModule,
2521
+ MatIconModule,
2522
+ FlexLayoutModule,
2523
+ FormlyModule.forChild({
2524
+ types: [
2525
+ { name: 'intphone', component: DbxInternationalPhoneFieldComponent }
2526
+ ]
2527
+ })
2528
+ ]] });
2529
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyPhoneFieldModule, decorators: [{
2530
+ type: NgModule,
2531
+ args: [{
2532
+ imports: [
2533
+ CommonModule,
2534
+ MatInputModule,
2535
+ FormsModule,
2536
+ NgxMatIntlTelInputModule,
2537
+ ReactiveFormsModule,
2538
+ MatAutocompleteModule,
2539
+ MatChipsModule,
2540
+ MatIconModule,
2541
+ FlexLayoutModule,
2542
+ FormlyModule.forChild({
2543
+ types: [
2544
+ { name: 'intphone', component: DbxInternationalPhoneFieldComponent }
2545
+ ]
2546
+ })
2547
+ ],
2548
+ declarations: [
2549
+ DbxInternationalPhoneFieldComponent
2550
+ ],
2551
+ exports: []
2552
+ }]
2553
+ }] });
2554
+
2555
+ const PHONE_LABEL_MAX_LENGTH = 100;
2556
+ const ADDRESS_COUNTRY_MAX_LENGTH = 80;
2557
+ const ADDRESS_CITY_MAX_LENGTH = 80;
2558
+ const ADDRESS_STATE_MAX_LENGTH = 80;
2559
+ const ADDRESS_ZIP_MAX_LENGTH = 20;
2560
+ const LABEL_STRING_MAX_LENGTH = 100;
2561
+ const SEARCH_STRING_MAX_LENGTH = 100;
2562
+ function textField({ key, label = '', placeholder = '', required = false, attributes, readonly, autocomplete, minLength, maxLength, pattern }) {
2563
+ return formlyField({
2564
+ key,
2565
+ type: 'input',
2566
+ templateOptions: {
2567
+ label,
2568
+ placeholder,
2569
+ required,
2570
+ minLength,
2571
+ maxLength,
2572
+ pattern,
2573
+ readonly,
2574
+ attributes: Object.assign(Object.assign({}, attributes), (autocomplete) ? { autocomplete } : undefined)
2575
+ }
2576
+ });
2577
+ }
2578
+ function textAreaField({ key, label = '', placeholder = '', rows = 3, required = false, minLength, maxLength = 1000, attributes }) {
2579
+ return formlyField({
2580
+ key,
2581
+ type: 'textarea',
2582
+ templateOptions: {
2583
+ label,
2584
+ placeholder,
2585
+ required,
2586
+ rows,
2587
+ minLength,
2588
+ maxLength,
2589
+ attributes
2590
+ }
2591
+ });
2592
+ }
2593
+ function nameField({ key = 'name', label = 'Name', placeholder = 'John Doe', required = false, minLength, maxLength, attributes } = {}) {
2594
+ return textField({
2595
+ key,
2596
+ label,
2597
+ placeholder,
2598
+ required,
2599
+ minLength,
2600
+ maxLength,
2601
+ attributes
2602
+ });
2603
+ }
2604
+ function emailField({ key = 'email', label = 'Email Address', placeholder = 'person@email.com', description = '', required = false, readonly = false }) {
2605
+ return formlyField({
2606
+ key,
2607
+ type: 'input',
2608
+ templateOptions: {
2609
+ label,
2610
+ placeholder,
2611
+ description,
2612
+ required,
2613
+ readonly
2614
+ },
2615
+ validation: {
2616
+ messages: {
2617
+ required: `Email is required.`
2618
+ }
2619
+ },
2620
+ validators: {
2621
+ email: {
2622
+ expression: (c) => !Validators.email(c),
2623
+ message: () => `Not a valid email address.`
2624
+ }
2625
+ },
2626
+ });
2627
+ }
2628
+ function cityField({ key = 'city', required = false }) {
2629
+ return textField({
2630
+ key,
2631
+ label: 'City',
2632
+ placeholder: '',
2633
+ required,
2634
+ autocomplete: 'city',
2635
+ maxLength: ADDRESS_CITY_MAX_LENGTH
2636
+ });
2637
+ }
2638
+ function stateField({ key = 'state', required = false }) {
2639
+ return textField({
2640
+ key,
2641
+ label: 'State',
2642
+ placeholder: '',
2643
+ required,
2644
+ attributes: {
2645
+ autocomplete: 'state'
2646
+ },
2647
+ maxLength: ADDRESS_STATE_MAX_LENGTH
2648
+ });
2649
+ }
2650
+ function countryField({ key = 'country', required = false }) {
2651
+ return textField({
2652
+ key,
2653
+ label: 'Country',
2654
+ placeholder: '',
2655
+ required,
2656
+ attributes: {
2657
+ autocomplete: 'country'
2658
+ },
2659
+ maxLength: ADDRESS_COUNTRY_MAX_LENGTH
2660
+ });
2661
+ }
2662
+ function zipCodeField({ key = 'zip', required = false }) {
2663
+ return textField({
2664
+ key,
2665
+ label: 'Zip Code',
2666
+ placeholder: '',
2667
+ required,
2668
+ attributes: {
2669
+ autocomplete: 'postal-code'
2670
+ },
2671
+ maxLength: ADDRESS_ZIP_MAX_LENGTH
2672
+ });
2673
+ }
2674
+
2675
+ function flexLayoutWrapper(fieldConfigs, { size: defaultSize = 2, retainSizeOnSmallScreen } = {}) {
2676
+ const defaultRetainSizeOnSmallScreen = retainSizeOnSmallScreen;
2677
+ return {
2678
+ wrappers: ['flex'],
2679
+ fieldGroupClassName: 'form-flex-section-group',
2680
+ // fieldGroupClassName: 'field-layout-group',
2681
+ fieldGroup: fieldConfigs.map((config) => {
2682
+ const { field, size = defaultSize, retainSizeOnSmallScreen = defaultRetainSizeOnSmallScreen } = config;
2683
+ let className = `form-flex-${size}`;
2684
+ if (retainSizeOnSmallScreen != false) {
2685
+ className = className + ' form-flex-responsive';
2686
+ }
2687
+ return Object.assign(Object.assign({}, field), { className });
2688
+ })
2689
+ };
2690
+ }
2691
+
2692
+ function internationalPhoneField({ key, label = '', placeholder = '', required = false }) {
2693
+ const fieldConfig = formlyField({
2694
+ key,
2695
+ type: 'intphone',
2696
+ templateOptions: {
2697
+ label,
2698
+ placeholder,
2699
+ required
2700
+ }
2701
+ });
2702
+ // TODO: Add configuration...
2703
+ return fieldConfig;
2704
+ }
2705
+ function phoneAndLabelFields({ phoneField: phone, labelField: label }) {
2706
+ return [
2707
+ flexLayoutWrapper([
2708
+ {
2709
+ field: internationalPhoneField(Object.assign({ key: 'phone' }, phone))
2710
+ },
2711
+ {
2712
+ field: textField(Object.assign({ key: 'label', label: 'Label', autocomplete: 'phone-label' }, label))
2713
+ }
2714
+ ])
2715
+ ];
2716
+ }
2717
+ function phoneAndLabelFieldGroup({ key = 'phone', label = 'Phone Number', required, phoneField, labelField }) {
2718
+ return {
2719
+ key,
2720
+ wrappers: ['section'],
2721
+ templateOptions: {
2722
+ label,
2723
+ required
2724
+ },
2725
+ fieldGroup: phoneAndLabelFields({ phoneField, labelField })
2726
+ };
2727
+ }
2728
+ function phoneListField({ key = 'phones', label = 'Phone Numbers', repeatSection, required = false, maxPhones = 6, phoneField, labelField }) {
2729
+ return {
2730
+ key,
2731
+ type: 'repeat',
2732
+ wrappers: ['section'],
2733
+ templateOptions: {
2734
+ label,
2735
+ required,
2736
+ repeatSection: repeatSection !== null && repeatSection !== void 0 ? repeatSection : {
2737
+ addText: 'Add Phone Number',
2738
+ removeText: 'Remove Phone Number'
2739
+ },
2740
+ maxLength: maxPhones
2741
+ },
2742
+ fieldArray: {
2743
+ fieldGroup: phoneAndLabelFields({ phoneField, labelField })
2744
+ }
2745
+ };
2746
+ }
2747
+
2748
+ const ADDRESS_LINE_MAX_LENGTH = 100;
2749
+ function addressFormlyFields() {
2750
+ return [
2751
+ textField({
2752
+ key: 'line1',
2753
+ label: 'Line 1',
2754
+ placeholder: '',
2755
+ required: false,
2756
+ autocomplete: 'address-line1',
2757
+ maxLength: ADDRESS_LINE_MAX_LENGTH
2758
+ }),
2759
+ textField({
2760
+ key: 'line2',
2761
+ label: 'Line 2',
2762
+ placeholder: '',
2763
+ required: false,
2764
+ autocomplete: 'address-line2',
2765
+ maxLength: ADDRESS_LINE_MAX_LENGTH
2766
+ }),
2767
+ flexLayoutWrapper([{
2768
+ field: cityField({})
2769
+ }, {
2770
+ field: stateField({})
2771
+ }, {
2772
+ field: zipCodeField({})
2773
+ }, {
2774
+ field: countryField({})
2775
+ }])
2776
+ ];
2777
+ }
2778
+ function addressField({ key = 'address', required = false }) {
2779
+ return {
2780
+ key,
2781
+ wrappers: ['section'],
2782
+ templateOptions: {
2783
+ label: 'Address',
2784
+ placeholder: '',
2785
+ required
2786
+ },
2787
+ fieldGroup: addressFormlyFields()
2788
+ };
2789
+ }
2790
+ function addressListField({ key = 'addresses', required = false, maxAddresses = 6 }) {
2791
+ return {
2792
+ key,
2793
+ type: 'repeat',
2794
+ wrappers: ['section'],
2795
+ templateOptions: {
2796
+ label: 'Addresses',
2797
+ placeholder: '',
2798
+ required,
2799
+ repeatSection: {
2800
+ addText: 'Add Address',
2801
+ removeText: 'Remove Address'
2802
+ },
2803
+ maxLength: maxAddresses
2804
+ },
2805
+ fieldArray: {
2806
+ fieldGroup: addressFormlyFields()
2807
+ }
2808
+ };
2809
+ }
2810
+
2811
+ class DbxFormFormlyTextFieldModule {
2812
+ }
2813
+ DbxFormFormlyTextFieldModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyTextFieldModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2814
+ DbxFormFormlyTextFieldModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyTextFieldModule, exports: [DbxFormFormlyWrapperModule] });
2815
+ DbxFormFormlyTextFieldModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyTextFieldModule, imports: [[], DbxFormFormlyWrapperModule] });
2816
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormFormlyTextFieldModule, decorators: [{
2817
+ type: NgModule,
2818
+ args: [{
2819
+ imports: [],
2820
+ declarations: [],
2821
+ exports: [
2822
+ DbxFormFormlyWrapperModule
2823
+ ]
2824
+ }]
2825
+ }] });
2826
+
2827
+ function hiddenField({ key, required = false }) {
2828
+ return formlyField({
2829
+ key,
2830
+ templateOptions: { required }
2831
+ });
2832
+ }
2833
+
2834
+ function addToggleWrapperToField({ fieldConfig, toggleSection = {} }) {
2835
+ fieldConfig.wrappers = concatArraysUnique(fieldConfig.wrappers, ['toggle']);
2836
+ fieldConfig.templateOptions = Object.assign(Object.assign({}, fieldConfig.templateOptions), { toggleSection });
2837
+ return fieldConfig;
2838
+ }
2839
+
2840
+ /**
2841
+ * Allows a directive to provide a formly context and form.
2842
+ */
2843
+ function ProvideFormlyContext() {
2844
+ return [{
2845
+ provide: DbxFormlyContext,
2846
+ useClass: DbxFormlyContext
2847
+ }, {
2848
+ provide: DbxForm,
2849
+ useExisting: DbxFormlyContext
2850
+ }];
2851
+ }
2852
+ /**
2853
+ * DbxForm Instance that registers a delegate and manages the state of that form/delegate.
2854
+ */
2855
+ class DbxFormlyContext {
2856
+ constructor() {
2857
+ this.lockSet = new LockSet();
2858
+ this._disabled = false;
2859
+ this._delegate = DbxFormlyContext.EMPTY_DELEGATE;
2860
+ this._streamSubject = new BehaviorSubject(of(DbxFormlyContext.INITIAL_STATE));
2861
+ this._stream$ = this._streamSubject.pipe(mergeMap$1((stream) => stream));
2862
+ }
2863
+ destroy() {
2864
+ this._streamSubject.complete();
2865
+ }
2866
+ get isDestroyed() {
2867
+ return this._streamSubject.isStopped;
2868
+ }
2869
+ setDelegate(delegate) {
2870
+ this._delegate = delegate !== null && delegate !== void 0 ? delegate : DbxFormlyContext.EMPTY_DELEGATE;
2871
+ this._streamSubject.next(this._delegate.stream$);
2872
+ this._delegate.setFields(this._fields);
2873
+ this._delegate.setValue(this._initialValue);
2874
+ this._delegate.setDisabled(this._disabled);
2875
+ }
2876
+ clearDelegate(delegate) {
2877
+ if (this._delegate === delegate && !this.isDestroyed) {
2878
+ this.setDelegate(undefined);
2879
+ }
2880
+ }
2881
+ get fields() {
2882
+ return this._fields;
2883
+ }
2884
+ set fields(fields) {
2885
+ this._fields = fields;
2886
+ this._delegate.setFields(this._fields);
2887
+ }
2888
+ // MARK: FormComponent
2889
+ get isComplete() {
2890
+ return this._delegate.isComplete;
2891
+ }
2892
+ get state() {
2893
+ return this._delegate.state;
2894
+ }
2895
+ get stream$() {
2896
+ return this._stream$;
2897
+ }
2898
+ get value() {
2899
+ return this._delegate.getValue();
2900
+ }
2901
+ setValue(value) {
2902
+ this._initialValue = value;
2903
+ this._delegate.setValue(value);
2904
+ }
2905
+ isDisabled() {
2906
+ return this._delegate.isDisabled();
2907
+ }
2908
+ setDisabled(disabled = true) {
2909
+ this._disabled = disabled;
2910
+ this._delegate.setDisabled(disabled);
2911
+ }
2912
+ resetForm() {
2913
+ this._delegate.resetForm();
2914
+ }
2915
+ forceFormUpdate() {
2916
+ this._delegate.forceFormUpdate();
2917
+ }
2918
+ }
2919
+ DbxFormlyContext.INITIAL_STATE = { isComplete: false, state: DbxFormState.INITIALIZING };
2920
+ DbxFormlyContext.EMPTY_DELEGATE = {
2921
+ isComplete: false,
2922
+ state: DbxFormState.INITIALIZING,
2923
+ stream$: of(DbxFormlyContext.INITIAL_STATE),
2924
+ setFields(fields) {
2925
+ // Do nothing.
2926
+ },
2927
+ getValue() {
2928
+ return undefined;
2929
+ },
2930
+ setValue(value) {
2931
+ // Do nothing.
2932
+ },
2933
+ resetForm() {
2934
+ // Do nothing.
2935
+ },
2936
+ forceFormUpdate() {
2937
+ // Do nothing.
2938
+ },
2939
+ isDisabled() {
2940
+ return false;
2941
+ },
2942
+ setDisabled(disabled) {
2943
+ // Do nothing.
2944
+ }
2945
+ };
2946
+
2947
+ /**
2948
+ * Abstract component for wrapping a form.
2949
+ */
2950
+ class AbstractFormlyFormDirective {
2951
+ constructor(context) {
2952
+ this.context = context;
2953
+ }
2954
+ get disabled() {
2955
+ return this.context.isDisabled();
2956
+ }
2957
+ set disabled(disabled) {
2958
+ this.context.setDisabled(disabled);
2959
+ }
2960
+ ngOnDestroy() {
2961
+ this.context.destroy();
2962
+ }
2963
+ // Utility Functions
2964
+ getValue() {
2965
+ return this.context.value;
2966
+ }
2967
+ setValue(value) {
2968
+ this.context.setValue(value);
2969
+ }
2970
+ clearValue() {
2971
+ this.setValue({});
2972
+ }
2973
+ }
2974
+ AbstractFormlyFormDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractFormlyFormDirective, deps: [{ token: DbxFormlyContext }], target: i0.ɵɵFactoryTarget.Directive });
2975
+ AbstractFormlyFormDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: AbstractFormlyFormDirective, inputs: { disabled: "disabled" }, ngImport: i0 });
2976
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractFormlyFormDirective, decorators: [{
2977
+ type: Directive
2978
+ }], ctorParameters: function () { return [{ type: DbxFormlyContext }]; }, propDecorators: { disabled: [{
2979
+ type: Input
2980
+ }] } });
2981
+ /**
2982
+ * Abstract component for wrapping a form.
2983
+ */
2984
+ class AbstractSyncFormlyFormDirective extends AbstractFormlyFormDirective {
2985
+ ngOnInit() {
2986
+ this.context.fields = this.fields;
2987
+ }
2988
+ }
2989
+ AbstractSyncFormlyFormDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractSyncFormlyFormDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2990
+ AbstractSyncFormlyFormDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: AbstractSyncFormlyFormDirective, usesInheritance: true, ngImport: i0 });
2991
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractSyncFormlyFormDirective, decorators: [{
2992
+ type: Directive
2993
+ }] });
2994
+ /**
2995
+ * Abstract component for wrapping an asyncrhronously-configured form.
2996
+ */
2997
+ class AbstractAsyncFormlyFormDirective extends AbstractFormlyFormDirective {
2998
+ constructor() {
2999
+ super(...arguments);
3000
+ this._fieldsSub = new SubscriptionObject();
3001
+ }
3002
+ ngOnInit() {
3003
+ this._fieldsSub.subscription = this.fields$.subscribe((fields) => {
3004
+ this.context.fields = fields;
3005
+ });
3006
+ }
3007
+ ngOnDestroy() {
3008
+ super.ngOnDestroy();
3009
+ this._fieldsSub.destroy();
3010
+ }
3011
+ }
3012
+ AbstractAsyncFormlyFormDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractAsyncFormlyFormDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
3013
+ AbstractAsyncFormlyFormDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: AbstractAsyncFormlyFormDirective, usesInheritance: true, ngImport: i0 });
3014
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractAsyncFormlyFormDirective, decorators: [{
3015
+ type: Directive
3016
+ }] });
3017
+ class AbstractConfigAsyncFormlyFormDirective extends AbstractAsyncFormlyFormDirective {
3018
+ constructor() {
3019
+ super(...arguments);
3020
+ this._config = new BehaviorSubject(undefined);
3021
+ this.config$ = this._config.asObservable();
3022
+ }
3023
+ get config() {
3024
+ return this._config.value;
3025
+ }
3026
+ set config(config) {
3027
+ this._config.next(config);
3028
+ }
3029
+ ngOnDestroy() {
3030
+ super.ngOnDestroy();
3031
+ this._config.complete();
3032
+ }
3033
+ }
3034
+ AbstractConfigAsyncFormlyFormDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractConfigAsyncFormlyFormDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
3035
+ AbstractConfigAsyncFormlyFormDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: AbstractConfigAsyncFormlyFormDirective, inputs: { config: "config" }, usesInheritance: true, ngImport: i0 });
3036
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: AbstractConfigAsyncFormlyFormDirective, decorators: [{
3037
+ type: Directive
3038
+ }], propDecorators: { config: [{
3039
+ type: Input
3040
+ }] } });
3041
+
3042
+ class DbxFormlyComponent extends AbstractSubscriptionDirective {
3043
+ constructor(context, ngZone) {
3044
+ super();
3045
+ this.context = context;
3046
+ this.ngZone = ngZone;
3047
+ this._changesCount = 0;
3048
+ this._fields = [];
3049
+ this._events = new BehaviorSubject({ isComplete: false, state: DbxFormState.INITIALIZING });
3050
+ this.form = new FormGroup({});
3051
+ this.model = {};
3052
+ this.options = {};
3053
+ }
3054
+ ngOnInit() {
3055
+ this.context.setDelegate(this);
3056
+ this.sub = this.form.valueChanges.pipe(startWith$1(this.form.value), distinctUntilChanged(), debounceTime(50)).subscribe((_) => this._updateForChange());
3057
+ }
3058
+ ngOnDestroy() {
3059
+ this.context.lockSet.onNextUnlock(() => {
3060
+ super.ngOnDestroy();
3061
+ this.context.clearDelegate(this);
3062
+ this._events.complete();
3063
+ });
3064
+ }
3065
+ get fields() {
3066
+ return this._fields;
3067
+ }
3068
+ // MARK: Delegate
3069
+ get isComplete() {
3070
+ return this._events.value.isComplete;
3071
+ }
3072
+ get state() {
3073
+ return this._events.value.state;
3074
+ }
3075
+ get stream$() {
3076
+ return this._events.asObservable();
3077
+ }
3078
+ setFields(fields) {
3079
+ this._fields = fields;
3080
+ }
3081
+ getValue() {
3082
+ return this.form.value; // this.model
3083
+ }
3084
+ setValue(value) {
3085
+ var _a, _b;
3086
+ /*
3087
+ if (value === this.model) {
3088
+ return; // Ignore the same value being set.
3089
+ }
3090
+ */
3091
+ this.model = cloneDeep(value);
3092
+ if (this.options.updateInitialValue) {
3093
+ this.options.updateInitialValue();
3094
+ (_b = (_a = this.options).resetModel) === null || _b === void 0 ? void 0 : _b.call(_a);
3095
+ }
3096
+ // Re-mark as untouched and pristine.
3097
+ this.form.markAsUntouched();
3098
+ this.form.markAsPristine();
3099
+ this._lastResetAt = new Date();
3100
+ this._changesCount = 0;
3101
+ // After updating the value, if the form is still untouched mark it as pristine again.
3102
+ // Sometimes the values get marked as changed and break pristine before a user has time to interact.
3103
+ setTimeout(() => {
3104
+ if (this.form.untouched) {
3105
+ this.form.markAsPristine();
3106
+ }
3107
+ }, 500);
3108
+ }
3109
+ resetForm() {
3110
+ if (this.options.resetModel) {
3111
+ this.options.resetModel();
3112
+ }
3113
+ }
3114
+ isDisabled() {
3115
+ return this.form.disabled;
3116
+ }
3117
+ setDisabled(disabled = true) {
3118
+ // console.log('setting disabled: ', disabled);
3119
+ if (disabled) {
3120
+ this.form.disable();
3121
+ }
3122
+ else {
3123
+ this.form.enable();
3124
+ }
3125
+ }
3126
+ // MARK: Update
3127
+ forceFormUpdate() {
3128
+ this._updateForChange();
3129
+ }
3130
+ _updateForChange() {
3131
+ const complete = this.form.valid;
3132
+ this._changesCount += 1;
3133
+ const nextState = {
3134
+ isComplete: complete,
3135
+ state: (complete) ? DbxFormState.COMPLETE : DbxFormState.INCOMPLETE,
3136
+ untouched: this.form.untouched,
3137
+ pristine: this.form.pristine,
3138
+ changesCount: this._changesCount,
3139
+ lastResetAt: this._lastResetAt
3140
+ };
3141
+ this._events.next(nextState);
3142
+ }
3143
+ }
3144
+ DbxFormlyComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormlyComponent, deps: [{ token: DbxFormlyContext }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
3145
+ DbxFormlyComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbxFormlyComponent, selector: "dbx-formly", exportAs: ["formly"], usesInheritance: true, ngImport: i0, template: `
3146
+ <form [formGroup]="form" class="dbx-formly">
3147
+ <formly-form [form]="form" [fields]="fields" [model]="model"></formly-form>
3148
+ </form>
3149
+ `, isInline: true, components: [{ type: i1$4.FormlyForm, selector: "formly-form", inputs: ["form", "model", "fields", "options"], outputs: ["modelChange"] }], directives: [{ type: i3.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i3.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }] });
3150
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormlyComponent, decorators: [{
3151
+ type: Component,
3152
+ args: [{
3153
+ selector: 'dbx-formly',
3154
+ exportAs: 'formly',
3155
+ template: `
3156
+ <form [formGroup]="form" class="dbx-formly">
3157
+ <formly-form [form]="form" [fields]="fields" [model]="model"></formly-form>
3158
+ </form>
3159
+ `,
3160
+ // TODO: styleUrls: ['./form.scss'],
3161
+ }]
3162
+ }], ctorParameters: function () { return [{ type: DbxFormlyContext }, { type: i0.NgZone }]; } });
3163
+
3164
+ class DbxFormlyModule {
3165
+ }
3166
+ DbxFormlyModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormlyModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3167
+ DbxFormlyModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormlyModule, declarations: [DbxFormlyComponent], imports: [CommonModule,
3168
+ FormsModule,
3169
+ ReactiveFormsModule,
3170
+ FormlyModule,
3171
+ FormlyMatToggleModule], exports: [
3172
+ // Modules (?)
3173
+ FormsModule,
3174
+ ReactiveFormsModule,
3175
+ // DbxFormWrapperModule, // todo!
3176
+ // Directives
3177
+ DbxFormlyComponent
3178
+ ] });
3179
+ DbxFormlyModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormlyModule, imports: [[
3180
+ CommonModule,
3181
+ FormsModule,
3182
+ ReactiveFormsModule,
3183
+ FormlyModule,
3184
+ FormlyMatToggleModule
3185
+ ],
3186
+ // Modules (?)
3187
+ FormsModule,
3188
+ ReactiveFormsModule] });
3189
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormlyModule, decorators: [{
3190
+ type: NgModule,
3191
+ args: [{
3192
+ imports: [
3193
+ CommonModule,
3194
+ FormsModule,
3195
+ ReactiveFormsModule,
3196
+ FormlyModule,
3197
+ FormlyMatToggleModule
3198
+ ],
3199
+ declarations: [
3200
+ DbxFormlyComponent,
3201
+ // FormComponentFieldComponent
3202
+ ],
3203
+ exports: [
3204
+ // Modules (?)
3205
+ FormsModule,
3206
+ ReactiveFormsModule,
3207
+ // DbxFormWrapperModule, // todo!
3208
+ // Directives
3209
+ DbxFormlyComponent,
3210
+ // FormComponentFieldComponent
3211
+ ]
3212
+ }]
3213
+ }] });
3214
+
3215
+ /**
3216
+ * Provides vertical spacing after a form.
3217
+ */
3218
+ class DbxFormSpacerComponent {
3219
+ }
3220
+ DbxFormSpacerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormSpacerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
3221
+ DbxFormSpacerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: DbxFormSpacerComponent, selector: "dbx-form-spacer", ngImport: i0, template: `<div class="dbx-form-spacer"></div>`, isInline: true });
3222
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormSpacerComponent, decorators: [{
3223
+ type: Component,
3224
+ args: [{
3225
+ selector: 'dbx-form-spacer',
3226
+ template: `<div class="dbx-form-spacer"></div>`,
3227
+ }]
3228
+ }] });
3229
+
3230
+ class DbxFormLayoutModule {
3231
+ }
3232
+ DbxFormLayoutModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormLayoutModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3233
+ DbxFormLayoutModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormLayoutModule, declarations: [DbxFormSpacerComponent], imports: [CommonModule], exports: [DbxFormSpacerComponent] });
3234
+ DbxFormLayoutModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormLayoutModule, imports: [[
3235
+ CommonModule
3236
+ ]] });
3237
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DbxFormLayoutModule, decorators: [{
3238
+ type: NgModule,
3239
+ args: [{
3240
+ imports: [
3241
+ CommonModule
3242
+ ],
3243
+ declarations: [
3244
+ DbxFormSpacerComponent
3245
+ ],
3246
+ exports: [
3247
+ DbxFormSpacerComponent
3248
+ ]
3249
+ }]
3250
+ }] });
3251
+
3252
+ function IsTruthy() {
3253
+ return (control) => {
3254
+ const value = control.value;
3255
+ if (!value) {
3256
+ return {
3257
+ isTruthy: value
3258
+ };
3259
+ }
3260
+ return {};
3261
+ };
3262
+ }
3263
+
3264
+ const DOMAIN_NAME_REGEX = /(.+)\.(.+)/;
3265
+ function IsDomain() {
3266
+ return Validators.pattern(DOMAIN_NAME_REGEX);
3267
+ }
3268
+
3269
+ function IsInRange(min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
3270
+ return (control) => {
3271
+ const numberString = control.value;
3272
+ const errors = {};
3273
+ if (numberString) {
3274
+ const value = Number(numberString);
3275
+ if (!isNaN(value)) {
3276
+ const bigEnough = value >= min;
3277
+ const smallEnough = value <= max;
3278
+ if (!bigEnough) {
3279
+ errors.min = value;
3280
+ }
3281
+ if (!smallEnough) {
3282
+ errors.max = value;
3283
+ }
3284
+ }
3285
+ }
3286
+ return errors;
3287
+ };
3288
+ }
3289
+
3290
+ /**
3291
+ * Generated bundle index. Do not edit.
3292
+ */
3293
+
3294
+ export { ADDRESS_CITY_MAX_LENGTH, ADDRESS_COUNTRY_MAX_LENGTH, ADDRESS_LINE_MAX_LENGTH, ADDRESS_STATE_MAX_LENGTH, ADDRESS_ZIP_MAX_LENGTH, APP_ACTION_FORM_DISABLED_KEY, AbstractAsyncFormlyFormDirective, AbstractConfigAsyncFormlyFormDirective, AbstractDbxPickableItemFieldDirective, AbstractDbxSearchableValueFieldDirective, AbstractFormComponentFieldWrappedComponent, AbstractFormExpandableSectionWrapperDirective, AbstractFormlyFormDirective, AbstractSyncFormlyFormDirective, AutoTouchFieldWrapperComponent, ChecklistItemFieldDataSetBuilder, DEFAULT_HAS_VALUE_FN, DEFAULT_PREFERRED_COUNTRIES, DOMAIN_NAME_REGEX, DateTimeFieldTimeMode, DbxActionFormDirective, DbxChecklistItemContentComponent, DbxChecklistItemFieldComponent, DbxDateTimeFieldComponent, DbxDefaultChecklistItemFieldDisplayComponent, DbxDefaultSearchableAnchorFieldDisplayComponent, DbxDefaultSearchableFieldDisplayComponent, DbxForm, DbxFormFormlyArrayFieldModule, DbxFormFormlyBooleanFieldModule, DbxFormFormlyChecklistItemFieldModule, DbxFormFormlyComponentFieldModule, DbxFormFormlyDateFieldModule, DbxFormFormlyPhoneFieldModule, DbxFormFormlyPickableFieldModule, DbxFormFormlySearchableFieldModule, DbxFormFormlyTextFieldModule, DbxFormFormlyWrapperModule, DbxFormLayoutModule, DbxFormLoadingPairSourceDirective, DbxFormModule, DbxFormRepeatTypeComponent, DbxFormSourceDirective, DbxFormSpacerComponent, DbxFormState, DbxFormValueChangesDirective, DbxFormlyActionModule, DbxFormlyComponent, DbxFormlyContext, DbxFormlyModule, DbxInternationalPhoneFieldComponent, DbxPickableChipFieldComponent, DbxPickableListFieldComponent, DbxSearchableChipFieldComponent, DbxSearchableFieldAutocompleteItemComponent, DbxSearchableTextFieldComponent, FormComponentFieldComponent, FormExpandableSectionWrapperComponent, FormFlexWrapperComponent, FormInfoSectionWrapperComponent, FormSectionWrapperComponent, FormSubsectionWrapperComponent, FormToggleSectionWrapperComponent, IsDomain, IsInRange, IsTruthy, LABEL_STRING_MAX_LENGTH, PHONE_LABEL_MAX_LENGTH, ProvideDbxForm, ProvideFormlyContext, SEARCH_STRING_MAX_LENGTH, TAKE_NEXT_UPCOMING_TIME_CONFIG_OBS, addToggleWrapperToField, addressField, addressFormlyFields, addressListField, checkboxField, checklistItemField, chipTextField, cityField, componentField, countryField, dateTimeField, disableFormlyFieldAutofill, emailField, flexLayoutWrapper, formlyField, hiddenField, internationalPhoneField, makeMetaFilterSearchableFieldValueDisplayFn, nameField, phoneAndLabelFieldGroup, phoneAndLabelFields, phoneListField, searchableChipField, searchableTextField, stateField, staticEnumField, textAreaField, textField, timeOnlyField, toggleField, zipCodeField };
3295
+ //# sourceMappingURL=dereekb-dbx-form.mjs.map