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