@tft/crispr-forms 12.2.11 → 12.2.15
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/bundles/tft-crispr-forms.umd.js +57 -50
- package/bundles/tft-crispr-forms.umd.js.map +1 -1
- package/esm2015/lib/abstracts/autocomplete-field.abstract.js +4 -4
- package/esm2015/lib/abstracts/autocomplete-field.abstract.js.map +1 -1
- package/esm2015/lib/crispr-forms.module.ngfactory.js.map +1 -1
- package/esm2015/lib/form-group-list/form-group-list.component.js +1 -1
- package/esm2015/lib/form-group-list/form-group-list.component.js.map +1 -1
- package/esm2015/lib/form-group-list/form-group-list.component.metadata.json +1 -1
- package/esm2015/lib/form.helpers.js +4 -9
- package/esm2015/lib/form.helpers.js.map +1 -1
- package/esm2015/lib/form.helpers.metadata.json +1 -1
- package/esm2015/lib/material/autocomplete-chiplist-field/autocomplete-chiplist-field.component.js +28 -10
- package/esm2015/lib/material/autocomplete-chiplist-field/autocomplete-chiplist-field.component.js.map +1 -1
- package/esm2015/lib/material/autocomplete-chiplist-field/autocomplete-chiplist-field.component.metadata.json +1 -1
- package/esm2015/lib/material/autocomplete-field/autocomplete-field.component.js +7 -17
- package/esm2015/lib/material/autocomplete-field/autocomplete-field.component.js.map +1 -1
- package/esm2015/lib/material/autocomplete-field/autocomplete-field.component.metadata.json +1 -1
- package/esm2015/lib/material/datepicker-field/datepicker-field.component.js +9 -3
- package/esm2015/lib/material/datepicker-field/datepicker-field.component.js.map +1 -1
- package/esm2015/lib/material/datepicker-field/datepicker-field.component.metadata.json +1 -1
- package/esm2015/lib/material/material.module.ngfactory.js.map +1 -1
- package/esm2015/lib/models/autocomplete-chiplist-field.config.js.map +1 -1
- package/esm2015/lib/models/datepicker-field.config.js.map +1 -1
- package/esm2015/lib/pipes/initial-control-value.pipe.js +2 -2
- package/esm2015/lib/pipes/initial-control-value.pipe.js.map +1 -1
- package/fesm2015/tft-crispr-forms.js +51 -44
- package/fesm2015/tft-crispr-forms.js.map +1 -1
- package/lib/form.helpers.d.ts +1 -1
- package/lib/material/autocomplete-chiplist-field/autocomplete-chiplist-field.component.d.ts +11 -4
- package/lib/material/autocomplete-field/autocomplete-field.component.d.ts +0 -6
- package/lib/models/autocomplete-chiplist-field.config.d.ts +9 -1
- package/lib/models/datepicker-field.config.d.ts +4 -1
- package/package.json +1 -1
- package/tft-crispr-forms-12.2.15.tgz +0 -0
- package/tft-crispr-forms.metadata.json +1 -1
- package/tft-crispr-forms-12.2.11.tgz +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Directive } from '@angular/core';
|
|
2
2
|
import { FormControl } from '@angular/forms';
|
|
3
|
-
import { debounceTime, distinctUntilChanged, map, switchMap } from 'rxjs/operators';
|
|
3
|
+
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
|
|
4
4
|
import { crisprControlMixin } from './crispr-control.mixin';
|
|
5
5
|
import { CrisprFieldComponent } from './crispr-field.abstract';
|
|
6
6
|
import { observablifyOptions } from '../form.helpers';
|
|
@@ -16,9 +16,9 @@ export class AbstractAutocompleteComponent extends AbstractAutocompleteFieldMixi
|
|
|
16
16
|
super.ngOnInit();
|
|
17
17
|
this.group.addControl(this.config.controlName, new FormControl());
|
|
18
18
|
// filter options by the search string using either the default filter function or one passed in through config
|
|
19
|
-
this.options$ = this.autocompleteInputControl.valueChanges.pipe(
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
this.options$ = this.autocompleteInputControl.valueChanges.pipe(
|
|
20
|
+
// this is needed to have the options panel to open on focus
|
|
21
|
+
startWith(''), debounceTime(this.config.typeDebounceTime), distinctUntilChanged(), map(searchText => searchText || ''), switchMap((searchText) => observablifyOptions(this.config.options, this.group, searchText)));
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
AbstractAutocompleteComponent.decorators = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete-field.abstract.js","sourceRoot":"","sources":["../../../../../../libs/crispr-forms/src/lib/abstracts/autocomplete-field.abstract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,SAAS,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,
|
|
1
|
+
{"version":3,"file":"autocomplete-field.abstract.js","sourceRoot":"","sources":["../../../../../../libs/crispr-forms/src/lib/abstracts/autocomplete-field.abstract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,SAAS,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAc,YAAY,EAAE,oBAAoB,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAO,MAAM,gBAAgB,CAAC;AAEhH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAItD,MAAM,8BAA8B,GAAG,kBAAkB,CAA0B,oBAAoB,CAAC,CAAC;AAGzG,kEAAkE;AAClE,MAAM,OAAO,6BACX,SAAQ,8BAA8B;IAHxC;;QAIE,oGAAoG;QACpG,6BAAwB,GAAG,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC;IAiBjD,CAAC;IAdC,QAAQ;QACN,KAAK,CAAC,QAAQ,EAAE,CAAC;QAEjB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,WAAW,EAAE,CAAC,CAAC;QAClE,+GAA+G;QAC/G,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,wBAAwB,CAAC,YAAY,CAAC,IAAI;QAC7D,4DAA4D;QAC5D,SAAS,CAAC,EAAE,CAAC,EACb,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAC1C,oBAAoB,EAAE,EACtB,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,IAAI,EAAE,CAAC,EACnC,SAAS,CAAC,CAAC,UAAkB,EAAE,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CACpG,CAAC;IACJ,CAAC;;;YArBF,SAAS","sourcesContent":["import { OnInit, Directive } from '@angular/core';\nimport { FormControl } from '@angular/forms';\nimport { Observable, of } from 'rxjs';\nimport { catchError, debounceTime, distinctUntilChanged, map, startWith, switchMap, tap } from 'rxjs/operators';\n\nimport { crisprControlMixin } from './crispr-control.mixin';\nimport { AutocompleteFieldConfig, AutocompleteChiplistFieldConfig, SelectOption } from '../models';\nimport { CrisprFieldComponent } from './crispr-field.abstract';\nimport { observablifyOptions } from '../form.helpers';\n\ntype AutocompleteConfigTypes = AutocompleteFieldConfig | AutocompleteChiplistFieldConfig;\n\nconst AbstractAutocompleteFieldMixin = crisprControlMixin<AutocompleteConfigTypes>(CrisprFieldComponent);\n\n@Directive()\n// eslint-disable-next-line @angular-eslint/directive-class-suffix\nexport class AbstractAutocompleteComponent<C>\n extends AbstractAutocompleteFieldMixin implements OnInit {\n // we need a separate control for the UI because of the way the material autocomplete chiplist works\n autocompleteInputControl = new FormControl('');\n options$: Observable<SelectOption[]>\n config: AutocompleteConfigTypes & C;\n ngOnInit() {\n super.ngOnInit();\n\n this.group.addControl(this.config.controlName, new FormControl());\n // filter options by the search string using either the default filter function or one passed in through config\n this.options$ = this.autocompleteInputControl.valueChanges.pipe(\n // this is needed to have the options panel to open on focus\n startWith(''),\n debounceTime(this.config.typeDebounceTime),\n distinctUntilChanged(),\n map(searchText => searchText || ''),\n switchMap((searchText: string) => observablifyOptions(this.config.options, this.group, searchText))\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crispr-forms.module.ngfactory.js","sourceRoot":"","sources":["../../../../../libs/crispr-forms/src/lib/crispr-forms.module.ngfactory.ts"],"names":[],"mappings":"","sourcesContent":["import * as i0 from '@angular/core';\nimport * as i1 from './crispr-forms.module';\nimport * as i2 from '@angular/common';\nimport * as i3 from '@angular/forms';\nimport * as i4 from '@tft/form-validation-handler';\nimport * as i5 from '@angular/cdk/bidi';\nimport * as i6 from '@angular/material/icon';\nimport * as i7 from '@angular/cdk/scrolling';\nimport * as i8 from '@angular/material/core';\nimport * as i9 from '@angular/material/autocomplete';\nimport * as i10 from '@angular/material/datepicker';\nimport * as i11 from '@angular/cdk/text-field';\nimport * as i12 from '@angular/material/form-field';\nimport * as i13 from '@angular/material/input';\nimport * as i14 from '@angular/material/radio';\nimport * as i15 from '@angular/material/select';\nimport * as i16 from '@angular/material/checkbox';\nimport * as i17 from '@angular/material/chips';\nimport * as i18 from '@angular/material/slider';\nimport * as i19 from '@angular/material/slide-toggle';\nimport * as i20 from '@angular/material/button';\nimport * as i21 from '@angular/material/button-toggle';\nimport * as i22 from '@angular/material/tooltip';\nimport * as i23 from '@angular/material/divider';\nimport * as i24 from '@angular/material/progress-bar';\nimport * as i25 from '@angular/cdk/portal';\nimport * as i26 from './field-container/field-container.component';\nimport * as i27 from './material/input-field/input-field.component';\nimport * as i28 from './material/select-field/select-field.component';\nimport * as i29 from './material/radio-field/radio-field.component';\nimport * as i30 from './material/autocomplete-field/autocomplete-field.component';\nimport * as i31 from './material/autocomplete-chiplist-field/autocomplete-chiplist-field.component';\nimport * as i32 from './material/checkbox-field/checkbox-field.component';\nimport * as i33 from './material/textarea-field/textarea-field.component';\nimport * as i34 from './material/datepicker-field/datepicker-field.component';\nimport * as i35 from './material/slider-field/slider-field.component';\nimport * as i36 from './material/button/button.component';\nimport * as i37 from './material/heading/heading.component';\nimport * as i38 from './material/divider/divider.component';\nimport * as i39 from './material/file-upload/file-upload.component';\nimport * as i40 from './material/unit-conversion-field/unit-conversion-field.component';\nimport * as i41 from './field.directive';\nimport * as i42 from './form/form.component';\nimport * as i43 from './form-group-list/form-group-list.component';\nimport * as i44 from './sub-group/sub-group.component';\nimport * as i45 from './pipes/initial-control-value.pipe';\nimport * as i46 from './material/material.module';\nexport const CrisprFormsModuleNgFactory:i0.NgModuleFactory<i1.CrisprFormsModule> = (null as any);\nvar _decl0_0:i2.NgClass = (<any>(null as any));\nvar _decl0_1:i2.NgComponentOutlet = (<any>(null as any));\nvar _decl0_2:i2.NgForOf<any,any> = (<any>(null as any));\nvar _decl0_3:i2.NgIf<any> = (<any>(null as any));\nvar _decl0_4:i2.NgTemplateOutlet = (<any>(null as any));\nvar _decl0_5:i2.NgStyle = (<any>(null as any));\nvar _decl0_6:i2.NgSwitch = (<any>(null as any));\nvar _decl0_7:i2.NgSwitchCase = (<any>(null as any));\nvar _decl0_8:i2.NgSwitchDefault = (<any>(null as any));\nvar _decl0_9:i2.NgPlural = (<any>(null as any));\nvar _decl0_10:i2.NgPluralCase = (<any>(null as any));\nvar _decl0_11:i3.ɵangular_packages_forms_forms_bb = (<any>(null as any));\nvar _decl0_12:i3.NgSelectOption = (<any>(null as any));\nvar _decl0_13:i3.ɵangular_packages_forms_forms_ba = (<any>(null as any));\nvar _decl0_14:i3.DefaultValueAccessor = (<any>(null as any));\nvar _decl0_15:i3.NumberValueAccessor = (<any>(null as any));\nvar _decl0_16:i3.RangeValueAccessor = (<any>(null as any));\nvar _decl0_17:i3.CheckboxControlValueAccessor = (<any>(null as any));\nvar _decl0_18:i3.SelectControlValueAccessor = (<any>(null as any));\nvar _decl0_19:i3.SelectMultipleControlValueAccessor = (<any>(null as any));\nvar _decl0_20:i3.RadioControlValueAccessor = (<any>(null as any));\nvar _decl0_21:i3.NgControlStatus = (<any>(null as any));\nvar _decl0_22:i3.NgControlStatusGroup = (<any>(null as any));\nvar _decl0_23:i3.RequiredValidator = (<any>(null as any));\nvar _decl0_24:i3.MinLengthValidator = (<any>(null as any));\nvar _decl0_25:i3.MaxLengthValidator = (<any>(null as any));\nvar _decl0_26:i3.PatternValidator = (<any>(null as any));\nvar _decl0_27:i3.CheckboxRequiredValidator = (<any>(null as any));\nvar _decl0_28:i3.EmailValidator = (<any>(null as any));\nvar _decl0_29:i3.MinValidator = (<any>(null as any));\nvar _decl0_30:i3.MaxValidator = (<any>(null as any));\nvar _decl0_31:i3.FormControlDirective = (<any>(null as any));\nvar _decl0_32:i3.FormGroupDirective = (<any>(null as any));\nvar _decl0_33:i3.FormControlName = (<any>(null as any));\nvar _decl0_34:i3.FormGroupName = (<any>(null as any));\nvar _decl0_35:i3.FormArrayName = (<any>(null as any));\nvar _decl0_36:i4.ɵa = (<any>(null as any));\nvar _decl0_37:i4.ɵd = (<any>(null as any));\nvar _decl0_38:i4.ɵb = (<any>(null as any));\nvar _decl0_39:i4.ɵc = (<any>(null as any));\nvar _decl0_40:i5.Dir = (<any>(null as any));\nvar _decl0_41:i6.MatIcon = (<any>(null as any));\nvar _decl0_42:i7.CdkScrollable = (<any>(null as any));\nvar _decl0_43:i8.MatOption = (<any>(null as any));\nvar _decl0_44:i8.MatOptgroup = (<any>(null as any));\nvar _decl0_45:i9.MatAutocomplete = (<any>(null as any));\nvar _decl0_46:i9.MatAutocompleteTrigger = (<any>(null as any));\nvar _decl0_47:i9.MatAutocompleteOrigin = (<any>(null as any));\nvar _decl0_48:i10.MatCalendar<any> = (<any>(null as any));\nvar _decl0_49:i10.MatCalendarBody = (<any>(null as any));\nvar _decl0_50:i10.MatDatepicker<any> = (<any>(null as any));\nvar _decl0_51:i10.MatDatepickerContent<any,any> = (<any>(null as any));\nvar _decl0_52:i10.MatDatepickerInput<any> = (<any>(null as any));\nvar _decl0_53:i10.MatDatepickerToggle<any> = (<any>(null as any));\nvar _decl0_54:i10.MatDatepickerToggleIcon = (<any>(null as any));\nvar _decl0_55:i10.MatMonthView<any> = (<any>(null as any));\nvar _decl0_56:i10.MatYearView<any> = (<any>(null as any));\nvar _decl0_57:i10.MatMultiYearView<any> = (<any>(null as any));\nvar _decl0_58:i10.MatCalendarHeader<any> = (<any>(null as any));\nvar _decl0_59:i10.MatDateRangeInput<any> = (<any>(null as any));\nvar _decl0_60:i10.MatStartDate<any> = (<any>(null as any));\nvar _decl0_61:i10.MatEndDate<any> = (<any>(null as any));\nvar _decl0_62:i10.MatDateRangePicker<any> = (<any>(null as any));\nvar _decl0_63:i10.MatDatepickerActions = (<any>(null as any));\nvar _decl0_64:i10.MatDatepickerCancel = (<any>(null as any));\nvar _decl0_65:i10.MatDatepickerApply = (<any>(null as any));\nvar _decl0_66:i11.CdkAutofill = (<any>(null as any));\nvar _decl0_67:i11.CdkTextareaAutosize = (<any>(null as any));\nvar _decl0_68:i12.MatError = (<any>(null as any));\nvar _decl0_69:i12.MatFormField = (<any>(null as any));\nvar _decl0_70:i12.MatHint = (<any>(null as any));\nvar _decl0_71:i12.MatLabel = (<any>(null as any));\nvar _decl0_72:i12.MatPlaceholder = (<any>(null as any));\nvar _decl0_73:i12.MatPrefix = (<any>(null as any));\nvar _decl0_74:i12.MatSuffix = (<any>(null as any));\nvar _decl0_75:i13.MatInput = (<any>(null as any));\nvar _decl0_76:i13.MatTextareaAutosize = (<any>(null as any));\nvar _decl0_77:i14.MatRadioGroup = (<any>(null as any));\nvar _decl0_78:i14.MatRadioButton = (<any>(null as any));\nvar _decl0_79:i15.MatSelect = (<any>(null as any));\nvar _decl0_80:i15.MatSelectTrigger = (<any>(null as any));\nvar _decl0_81:i16.MatCheckboxRequiredValidator = (<any>(null as any));\nvar _decl0_82:i16.MatCheckbox = (<any>(null as any));\nvar _decl0_83:i17.MatChipList = (<any>(null as any));\nvar _decl0_84:i17.MatChip = (<any>(null as any));\nvar _decl0_85:i17.MatChipInput = (<any>(null as any));\nvar _decl0_86:i17.MatChipRemove = (<any>(null as any));\nvar _decl0_87:i17.MatChipAvatar = (<any>(null as any));\nvar _decl0_88:i17.MatChipTrailingIcon = (<any>(null as any));\nvar _decl0_89:i18.MatSlider = (<any>(null as any));\nvar _decl0_90:i19.MatSlideToggleRequiredValidator = (<any>(null as any));\nvar _decl0_91:i19.MatSlideToggle = (<any>(null as any));\nvar _decl0_92:i20.MatButton = (<any>(null as any));\nvar _decl0_93:i20.MatAnchor = (<any>(null as any));\nvar _decl0_94:i21.MatButtonToggleGroup = (<any>(null as any));\nvar _decl0_95:i21.MatButtonToggle = (<any>(null as any));\nvar _decl0_96:i22.MatTooltip = (<any>(null as any));\nvar _decl0_97:i22.TooltipComponent = (<any>(null as any));\nvar _decl0_98:i23.MatDivider = (<any>(null as any));\nvar _decl0_99:i24.MatProgressBar = (<any>(null as any));\nvar _decl0_100:i25.CdkPortal = (<any>(null as any));\nvar _decl0_101:i25.CdkPortalOutlet = (<any>(null as any));\nvar _decl0_102:i25.TemplatePortalDirective = (<any>(null as any));\nvar _decl0_103:i25.PortalHostDirective = (<any>(null as any));\nvar _decl0_104:i26.FieldContainerComponent = (<any>(null as any));\nvar _decl0_105:i27.InputFieldComponent = (<any>(null as any));\nvar _decl0_106:i28.SelectFieldComponent = (<any>(null as any));\nvar _decl0_107:i29.RadioFieldComponent = (<any>(null as any));\nvar _decl0_108:i30.AutocompleteFieldComponent = (<any>(null as any));\nvar _decl0_109:i31.AutocompleteChiplistFieldComponent = (<any>(null as any));\nvar _decl0_110:i32.CheckboxFieldComponent = (<any>(null as any));\nvar _decl0_111:i33.TextareaFieldComponent = (<any>(null as any));\nvar _decl0_112:i34.DatepickerFieldComponent = (<any>(null as any));\nvar _decl0_113:i35.SliderFieldComponent = (<any>(null as any));\nvar _decl0_114:i36.ButtonComponent = (<any>(null as any));\nvar _decl0_115:i37.HeadingComponent = (<any>(null as any));\nvar _decl0_116:i38.DividerComponent = (<any>(null as any));\nvar _decl0_117:i39.FileUploadComponent = (<any>(null as any));\nvar _decl0_118:i40.UnitConversionFieldComponent = (<any>(null as any));\nvar _decl0_119:i41.CrisprFieldDirective = (<any>(null as any));\nvar _decl0_120:i42.CrisprFormComponent = (<any>(null as any));\nvar _decl0_121:i43.FormGroupListComponent = (<any>(null as any));\nvar _decl0_122:i44.SubGroupComponent = (<any>(null as any));\nvar _decl0_123:i2.AsyncPipe = (<any>(null as any));\nvar _decl0_124:i2.UpperCasePipe = (<any>(null as any));\nvar _decl0_125:i2.LowerCasePipe = (<any>(null as any));\nvar _decl0_126:i2.JsonPipe = (<any>(null as any));\nvar _decl0_127:i2.SlicePipe = (<any>(null as any));\nvar _decl0_128:i2.DecimalPipe = (<any>(null as any));\nvar _decl0_129:i2.PercentPipe = (<any>(null as any));\nvar _decl0_130:i2.TitleCasePipe = (<any>(null as any));\nvar _decl0_131:i2.CurrencyPipe = (<any>(null as any));\nvar _decl0_132:i2.DatePipe = (<any>(null as any));\nvar _decl0_133:i2.I18nPluralPipe = (<any>(null as any));\nvar _decl0_134:i2.I18nSelectPipe = (<any>(null as any));\nvar _decl0_135:i2.KeyValuePipe = (<any>(null as any));\nvar _decl0_137:i45.InitialControlValuePipe = (<any>(null as any));\nvar _decl0_138:i2.CommonModule = (<any>(null as any));\nvar _decl0_139:i3.ReactiveFormsModule = (<any>(null as any));\nvar _decl0_140:i4.FormValidationHandlerModule = (<any>(null as any));\nvar _decl0_142:i46.MaterialModule = (<any>(null as any));\nvar _decl0_143:i0.TemplateRef<any> = (<any>(null as any));\nvar _decl0_144:i0.ElementRef<any> = (<any>(null as any));\nfunction _View_CrisprFormComponent_Host_1_0():void {\n var _any:any = (null as any);\n}\nfunction _View_CrisprFormComponent_1_1():void {\n var _any:any = (null as any);\n const currVal_0:any = _any;\n currVal_0;\n const currVal_1:any = _decl0_120.form;\n currVal_1;\n const currVal_2:any = _decl0_137.transform(_decl0_120.value,_any);\n currVal_2;\n}\nfunction _View_CrisprFormComponent_1_0():void {\n var _any:any = (null as any);\n const currVal_0:any = 'crispr-form';\n currVal_0;\n const currVal_1:any = _decl0_120.config.classes;\n currVal_1;\n const currVal_2:any = _decl0_120.form;\n currVal_2;\n const currVal_3:any = _decl0_22.is('untouched');\n currVal_3;\n const currVal_4:any = _decl0_22.is('touched');\n currVal_4;\n const currVal_5:any = _decl0_22.is('pristine');\n currVal_5;\n const currVal_6:any = _decl0_22.is('dirty');\n currVal_6;\n const currVal_7:any = _decl0_22.is('valid');\n currVal_7;\n const currVal_8:any = _decl0_22.is('invalid');\n currVal_8;\n const currVal_9:any = _decl0_22.is('pending');\n currVal_9;\n const currVal_10:any = _decl0_120.config.errorDictionary;\n currVal_10;\n const currVal_11:any = (_decl0_120.config.autocomplete || 'off');\n currVal_11;\n const currVal_12:any = _decl0_120.config.fields;\n currVal_12;\n const pd_13:any = ((<any>_decl0_32.onSubmit(_any)) !== false);\n const pd_14:any = ((<any>_decl0_32.onReset()) !== false);\n const pd_15:any = ((<any>_decl0_120.handleSubmit()) !== false);\n}\nfunction _View_FormGroupListComponent_Host_2_0():void {\n var _any:any = (null as any);\n}\nfunction _View_FormGroupListComponent_2_2():void {\n if (_decl0_121.config.itemLabelBuilder) {\n var _any:any = (null as any);\n const currVal_0:any = _decl0_121.config.itemLabelBuilder(_any);\n currVal_0;\n }\n}\nfunction _View_FormGroupListComponent_2_3():void {\n if (((_any + 1) > _decl0_121.config.minListLength)) {\n var _any:any = (null as any);\n const currVal_0:any = (_decl0_92.disabled || null);\n currVal_0;\n const currVal_1:any = (_decl0_92._animationMode === 'NoopAnimations');\n currVal_1;\n const currVal_2:any = _decl0_92.disabled;\n currVal_2;\n const currVal_3:any = (_decl0_41._usingFontIcon()? 'font': 'svg');\n currVal_3;\n const currVal_4:any = (_decl0_41._svgName || _decl0_41.fontIcon);\n currVal_4;\n const currVal_5:any = (_decl0_41._svgNamespace || _decl0_41.fontSet);\n currVal_5;\n const currVal_6:any = _decl0_41.inline;\n currVal_6;\n const currVal_7:any = (((_decl0_41.color !== 'primary') && (_decl0_41.color !== 'accent')) && (_decl0_41.color !== 'warn'));\n currVal_7;\n const pd_8:any = ((<any>_decl0_121.deleteGroup(_any)) !== false);\n }\n}\nfunction _View_FormGroupListComponent_2_4():void {\n var _any:any = (null as any);\n const currVal_0:any = _any;\n currVal_0;\n const currVal_1:any = _any;\n currVal_1;\n const currVal_2:any = _decl0_137.transform(_decl0_121.value,_any);\n currVal_2;\n}\nfunction _View_FormGroupListComponent_2_1():void {\n var _any:any = (null as any);\n const currVal_0:any = _decl0_121.config.itemLabelBuilder;\n currVal_0;\n const currVal_1:any = ((_any + 1) > _decl0_121.config.minListLength);\n currVal_1;\n const currVal_2:any = _any;\n currVal_2;\n const currVal_3:any = _decl0_22.is('untouched');\n currVal_3;\n const currVal_4:any = _decl0_22.is('touched');\n currVal_4;\n const currVal_5:any = _decl0_22.is('pristine');\n currVal_5;\n const currVal_6:any = _decl0_22.is('dirty');\n currVal_6;\n const currVal_7:any = _decl0_22.is('valid');\n currVal_7;\n const currVal_8:any = _decl0_22.is('invalid');\n currVal_8;\n const currVal_9:any = _decl0_22.is('pending');\n currVal_9;\n const currVal_10:any = _decl0_121.config.itemConfig.fields;\n currVal_10;\n}\nfunction _View_FormGroupListComponent_2_0():void {\n var _any:any = (null as any);\n const currVal_0:any = _decl0_121.group;\n currVal_0;\n const currVal_1:any = _decl0_22.is('untouched');\n currVal_1;\n const currVal_2:any = _decl0_22.is('touched');\n currVal_2;\n const currVal_3:any = _decl0_22.is('pristine');\n currVal_3;\n const currVal_4:any = _decl0_22.is('dirty');\n currVal_4;\n const currVal_5:any = _decl0_22.is('valid');\n currVal_5;\n const currVal_6:any = _decl0_22.is('invalid');\n currVal_6;\n const currVal_7:any = _decl0_22.is('pending');\n currVal_7;\n const currVal_8:any = _decl0_121.config;\n currVal_8;\n const currVal_9:any = _decl0_121.group;\n currVal_9;\n const currVal_10:any = _decl0_121.config.controlName;\n currVal_10;\n const currVal_11:any = _decl0_22.is('untouched');\n currVal_11;\n const currVal_12:any = _decl0_22.is('touched');\n currVal_12;\n const currVal_13:any = _decl0_22.is('pristine');\n currVal_13;\n const currVal_14:any = _decl0_22.is('dirty');\n currVal_14;\n const currVal_15:any = _decl0_22.is('valid');\n currVal_15;\n const currVal_16:any = _decl0_22.is('invalid');\n currVal_16;\n const currVal_17:any = _decl0_22.is('pending');\n currVal_17;\n const currVal_18:any = ((_decl0_121.formArray == null)? (null as any): _decl0_121.formArray.controls);\n currVal_18;\n const currVal_19:any = (_decl0_92.disabled || null);\n currVal_19;\n const currVal_20:any = (_decl0_92._animationMode === 'NoopAnimations');\n currVal_20;\n const currVal_21:any = _decl0_92.disabled;\n currVal_21;\n const currVal_22:any = _decl0_121.config.addItemLabel;\n currVal_22;\n const pd_23:any = ((<any>_decl0_32.onSubmit(_any)) !== false);\n const pd_24:any = ((<any>_decl0_32.onReset()) !== false);\n const pd_25:any = ((<any>_decl0_121.addGroup()) !== false);\n}\nfunction _View_SubGroupComponent_Host_3_0():void {\n var _any:any = (null as any);\n}\nfunction _View_SubGroupComponent_3_1():void {\n var _any:any = (null as any);\n const currVal_0:any = _any;\n currVal_0;\n const currVal_1:any = _decl0_122.control;\n currVal_1;\n const currVal_2:any = _decl0_137.transform(_decl0_122.value,_any);\n currVal_2;\n}\nfunction _View_SubGroupComponent_3_0():void {\n var _any:any = (null as any);\n const currVal_0:any = _decl0_122.config;\n currVal_0;\n const currVal_1:any = _decl0_122.group;\n currVal_1;\n const currVal_2:any = _decl0_122.config.fields;\n currVal_2;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"crispr-forms.module.ngfactory.js","sourceRoot":"","sources":["../../../../../libs/crispr-forms/src/lib/crispr-forms.module.ngfactory.ts"],"names":[],"mappings":"","sourcesContent":["import * as i0 from '@angular/core';\nimport * as i1 from './crispr-forms.module';\nimport * as i2 from '@angular/common';\nimport * as i3 from '@angular/forms';\nimport * as i4 from '@tft/form-validation-handler';\nimport * as i5 from '@angular/cdk/bidi';\nimport * as i6 from '@angular/material/icon';\nimport * as i7 from '@angular/cdk/scrolling';\nimport * as i8 from '@angular/material/core';\nimport * as i9 from '@angular/material/autocomplete';\nimport * as i10 from '@angular/material/datepicker';\nimport * as i11 from '@angular/cdk/text-field';\nimport * as i12 from '@angular/material/form-field';\nimport * as i13 from '@angular/material/input';\nimport * as i14 from '@angular/material/radio';\nimport * as i15 from '@angular/material/select';\nimport * as i16 from '@angular/material/checkbox';\nimport * as i17 from '@angular/material/chips';\nimport * as i18 from '@angular/material/slider';\nimport * as i19 from '@angular/material/slide-toggle';\nimport * as i20 from '@angular/material/button';\nimport * as i21 from '@angular/material/button-toggle';\nimport * as i22 from '@angular/material/tooltip';\nimport * as i23 from '@angular/material/divider';\nimport * as i24 from '@angular/material/progress-bar';\nimport * as i25 from '@angular/cdk/portal';\nimport * as i26 from './field-container/field-container.component';\nimport * as i27 from './material/input-field/input-field.component';\nimport * as i28 from './material/select-field/select-field.component';\nimport * as i29 from './material/radio-field/radio-field.component';\nimport * as i30 from './material/autocomplete-field/autocomplete-field.component';\nimport * as i31 from './material/autocomplete-chiplist-field/autocomplete-chiplist-field.component';\nimport * as i32 from './material/checkbox-field/checkbox-field.component';\nimport * as i33 from './material/textarea-field/textarea-field.component';\nimport * as i34 from './material/datepicker-field/datepicker-field.component';\nimport * as i35 from './material/slider-field/slider-field.component';\nimport * as i36 from './material/button/button.component';\nimport * as i37 from './material/heading/heading.component';\nimport * as i38 from './material/divider/divider.component';\nimport * as i39 from './material/file-upload/file-upload.component';\nimport * as i40 from './material/unit-conversion-field/unit-conversion-field.component';\nimport * as i41 from './field.directive';\nimport * as i42 from './form/form.component';\nimport * as i43 from './form-group-list/form-group-list.component';\nimport * as i44 from './sub-group/sub-group.component';\nimport * as i45 from './pipes/initial-control-value.pipe';\nimport * as i46 from './material/material.module';\nexport const CrisprFormsModuleNgFactory:i0.NgModuleFactory<i1.CrisprFormsModule> = (null as any);\nvar _decl0_0:i2.NgClass = (<any>(null as any));\nvar _decl0_1:i2.NgComponentOutlet = (<any>(null as any));\nvar _decl0_2:i2.NgForOf<any,any> = (<any>(null as any));\nvar _decl0_3:i2.NgIf<any> = (<any>(null as any));\nvar _decl0_4:i2.NgTemplateOutlet = (<any>(null as any));\nvar _decl0_5:i2.NgStyle = (<any>(null as any));\nvar _decl0_6:i2.NgSwitch = (<any>(null as any));\nvar _decl0_7:i2.NgSwitchCase = (<any>(null as any));\nvar _decl0_8:i2.NgSwitchDefault = (<any>(null as any));\nvar _decl0_9:i2.NgPlural = (<any>(null as any));\nvar _decl0_10:i2.NgPluralCase = (<any>(null as any));\nvar _decl0_11:i3.ɵangular_packages_forms_forms_bb = (<any>(null as any));\nvar _decl0_12:i3.NgSelectOption = (<any>(null as any));\nvar _decl0_13:i3.ɵangular_packages_forms_forms_ba = (<any>(null as any));\nvar _decl0_14:i3.DefaultValueAccessor = (<any>(null as any));\nvar _decl0_15:i3.NumberValueAccessor = (<any>(null as any));\nvar _decl0_16:i3.RangeValueAccessor = (<any>(null as any));\nvar _decl0_17:i3.CheckboxControlValueAccessor = (<any>(null as any));\nvar _decl0_18:i3.SelectControlValueAccessor = (<any>(null as any));\nvar _decl0_19:i3.SelectMultipleControlValueAccessor = (<any>(null as any));\nvar _decl0_20:i3.RadioControlValueAccessor = (<any>(null as any));\nvar _decl0_21:i3.NgControlStatus = (<any>(null as any));\nvar _decl0_22:i3.NgControlStatusGroup = (<any>(null as any));\nvar _decl0_23:i3.RequiredValidator = (<any>(null as any));\nvar _decl0_24:i3.MinLengthValidator = (<any>(null as any));\nvar _decl0_25:i3.MaxLengthValidator = (<any>(null as any));\nvar _decl0_26:i3.PatternValidator = (<any>(null as any));\nvar _decl0_27:i3.CheckboxRequiredValidator = (<any>(null as any));\nvar _decl0_28:i3.EmailValidator = (<any>(null as any));\nvar _decl0_29:i3.MinValidator = (<any>(null as any));\nvar _decl0_30:i3.MaxValidator = (<any>(null as any));\nvar _decl0_31:i3.FormControlDirective = (<any>(null as any));\nvar _decl0_32:i3.FormGroupDirective = (<any>(null as any));\nvar _decl0_33:i3.FormControlName = (<any>(null as any));\nvar _decl0_34:i3.FormGroupName = (<any>(null as any));\nvar _decl0_35:i3.FormArrayName = (<any>(null as any));\nvar _decl0_36:i4.ɵa = (<any>(null as any));\nvar _decl0_37:i4.ɵd = (<any>(null as any));\nvar _decl0_38:i4.ɵb = (<any>(null as any));\nvar _decl0_39:i4.ɵc = (<any>(null as any));\nvar _decl0_40:i5.Dir = (<any>(null as any));\nvar _decl0_41:i6.MatIcon = (<any>(null as any));\nvar _decl0_42:i7.CdkScrollable = (<any>(null as any));\nvar _decl0_43:i8.MatOption = (<any>(null as any));\nvar _decl0_44:i8.MatOptgroup = (<any>(null as any));\nvar _decl0_45:i9.MatAutocomplete = (<any>(null as any));\nvar _decl0_46:i9.MatAutocompleteTrigger = (<any>(null as any));\nvar _decl0_47:i9.MatAutocompleteOrigin = (<any>(null as any));\nvar _decl0_48:i10.MatCalendar<any> = (<any>(null as any));\nvar _decl0_49:i10.MatCalendarBody = (<any>(null as any));\nvar _decl0_50:i10.MatDatepicker<any> = (<any>(null as any));\nvar _decl0_51:i10.MatDatepickerContent<any,any> = (<any>(null as any));\nvar _decl0_52:i10.MatDatepickerInput<any> = (<any>(null as any));\nvar _decl0_53:i10.MatDatepickerToggle<any> = (<any>(null as any));\nvar _decl0_54:i10.MatDatepickerToggleIcon = (<any>(null as any));\nvar _decl0_55:i10.MatMonthView<any> = (<any>(null as any));\nvar _decl0_56:i10.MatYearView<any> = (<any>(null as any));\nvar _decl0_57:i10.MatMultiYearView<any> = (<any>(null as any));\nvar _decl0_58:i10.MatCalendarHeader<any> = (<any>(null as any));\nvar _decl0_59:i10.MatDateRangeInput<any> = (<any>(null as any));\nvar _decl0_60:i10.MatStartDate<any> = (<any>(null as any));\nvar _decl0_61:i10.MatEndDate<any> = (<any>(null as any));\nvar _decl0_62:i10.MatDateRangePicker<any> = (<any>(null as any));\nvar _decl0_63:i10.MatDatepickerActions = (<any>(null as any));\nvar _decl0_64:i10.MatDatepickerCancel = (<any>(null as any));\nvar _decl0_65:i10.MatDatepickerApply = (<any>(null as any));\nvar _decl0_66:i11.CdkAutofill = (<any>(null as any));\nvar _decl0_67:i11.CdkTextareaAutosize = (<any>(null as any));\nvar _decl0_68:i12.MatError = (<any>(null as any));\nvar _decl0_69:i12.MatFormField = (<any>(null as any));\nvar _decl0_70:i12.MatHint = (<any>(null as any));\nvar _decl0_71:i12.MatLabel = (<any>(null as any));\nvar _decl0_72:i12.MatPlaceholder = (<any>(null as any));\nvar _decl0_73:i12.MatPrefix = (<any>(null as any));\nvar _decl0_74:i12.MatSuffix = (<any>(null as any));\nvar _decl0_75:i13.MatInput = (<any>(null as any));\nvar _decl0_76:i13.MatTextareaAutosize = (<any>(null as any));\nvar _decl0_77:i14.MatRadioGroup = (<any>(null as any));\nvar _decl0_78:i14.MatRadioButton = (<any>(null as any));\nvar _decl0_79:i15.MatSelect = (<any>(null as any));\nvar _decl0_80:i15.MatSelectTrigger = (<any>(null as any));\nvar _decl0_81:i16.MatCheckboxRequiredValidator = (<any>(null as any));\nvar _decl0_82:i16.MatCheckbox = (<any>(null as any));\nvar _decl0_83:i17.MatChipList = (<any>(null as any));\nvar _decl0_84:i17.MatChip = (<any>(null as any));\nvar _decl0_85:i17.MatChipInput = (<any>(null as any));\nvar _decl0_86:i17.MatChipRemove = (<any>(null as any));\nvar _decl0_87:i17.MatChipAvatar = (<any>(null as any));\nvar _decl0_88:i17.MatChipTrailingIcon = (<any>(null as any));\nvar _decl0_89:i18.MatSlider = (<any>(null as any));\nvar _decl0_90:i19.MatSlideToggleRequiredValidator = (<any>(null as any));\nvar _decl0_91:i19.MatSlideToggle = (<any>(null as any));\nvar _decl0_92:i20.MatButton = (<any>(null as any));\nvar _decl0_93:i20.MatAnchor = (<any>(null as any));\nvar _decl0_94:i21.MatButtonToggleGroup = (<any>(null as any));\nvar _decl0_95:i21.MatButtonToggle = (<any>(null as any));\nvar _decl0_96:i22.MatTooltip = (<any>(null as any));\nvar _decl0_97:i22.TooltipComponent = (<any>(null as any));\nvar _decl0_98:i23.MatDivider = (<any>(null as any));\nvar _decl0_99:i24.MatProgressBar = (<any>(null as any));\nvar _decl0_100:i25.CdkPortal = (<any>(null as any));\nvar _decl0_101:i25.CdkPortalOutlet = (<any>(null as any));\nvar _decl0_102:i25.TemplatePortalDirective = (<any>(null as any));\nvar _decl0_103:i25.PortalHostDirective = (<any>(null as any));\nvar _decl0_104:i26.FieldContainerComponent = (<any>(null as any));\nvar _decl0_105:i27.InputFieldComponent = (<any>(null as any));\nvar _decl0_106:i28.SelectFieldComponent = (<any>(null as any));\nvar _decl0_107:i29.RadioFieldComponent = (<any>(null as any));\nvar _decl0_108:i30.AutocompleteFieldComponent = (<any>(null as any));\nvar _decl0_109:i31.AutocompleteChiplistFieldComponent = (<any>(null as any));\nvar _decl0_110:i32.CheckboxFieldComponent = (<any>(null as any));\nvar _decl0_111:i33.TextareaFieldComponent = (<any>(null as any));\nvar _decl0_112:i34.DatepickerFieldComponent = (<any>(null as any));\nvar _decl0_113:i35.SliderFieldComponent = (<any>(null as any));\nvar _decl0_114:i36.ButtonComponent = (<any>(null as any));\nvar _decl0_115:i37.HeadingComponent = (<any>(null as any));\nvar _decl0_116:i38.DividerComponent = (<any>(null as any));\nvar _decl0_117:i39.FileUploadComponent = (<any>(null as any));\nvar _decl0_118:i40.UnitConversionFieldComponent = (<any>(null as any));\nvar _decl0_119:i41.CrisprFieldDirective = (<any>(null as any));\nvar _decl0_120:i42.CrisprFormComponent = (<any>(null as any));\nvar _decl0_121:i43.FormGroupListComponent = (<any>(null as any));\nvar _decl0_122:i44.SubGroupComponent = (<any>(null as any));\nvar _decl0_123:i2.AsyncPipe = (<any>(null as any));\nvar _decl0_124:i2.UpperCasePipe = (<any>(null as any));\nvar _decl0_125:i2.LowerCasePipe = (<any>(null as any));\nvar _decl0_126:i2.JsonPipe = (<any>(null as any));\nvar _decl0_127:i2.SlicePipe = (<any>(null as any));\nvar _decl0_128:i2.DecimalPipe = (<any>(null as any));\nvar _decl0_129:i2.PercentPipe = (<any>(null as any));\nvar _decl0_130:i2.TitleCasePipe = (<any>(null as any));\nvar _decl0_131:i2.CurrencyPipe = (<any>(null as any));\nvar _decl0_132:i2.DatePipe = (<any>(null as any));\nvar _decl0_133:i2.I18nPluralPipe = (<any>(null as any));\nvar _decl0_134:i2.I18nSelectPipe = (<any>(null as any));\nvar _decl0_135:i2.KeyValuePipe = (<any>(null as any));\nvar _decl0_137:i45.InitialControlValuePipe = (<any>(null as any));\nvar _decl0_138:i2.CommonModule = (<any>(null as any));\nvar _decl0_139:i3.ReactiveFormsModule = (<any>(null as any));\nvar _decl0_140:i4.FormValidationHandlerModule = (<any>(null as any));\nvar _decl0_142:i46.MaterialModule = (<any>(null as any));\nvar _decl0_143:i0.TemplateRef<any> = (<any>(null as any));\nvar _decl0_144:i0.ElementRef<any> = (<any>(null as any));\nfunction _View_CrisprFormComponent_Host_1_0():void {\n var _any:any = (null as any);\n}\nfunction _View_CrisprFormComponent_1_1():void {\n var _any:any = (null as any);\n const currVal_0:any = _any;\n currVal_0;\n const currVal_1:any = _decl0_120.form;\n currVal_1;\n const currVal_2:any = _decl0_137.transform(_decl0_120.value,_any);\n currVal_2;\n}\nfunction _View_CrisprFormComponent_1_0():void {\n var _any:any = (null as any);\n const currVal_0:any = 'crispr-form';\n currVal_0;\n const currVal_1:any = _decl0_120.config.classes;\n currVal_1;\n const currVal_2:any = _decl0_120.form;\n currVal_2;\n const currVal_3:any = _decl0_22.is('untouched');\n currVal_3;\n const currVal_4:any = _decl0_22.is('touched');\n currVal_4;\n const currVal_5:any = _decl0_22.is('pristine');\n currVal_5;\n const currVal_6:any = _decl0_22.is('dirty');\n currVal_6;\n const currVal_7:any = _decl0_22.is('valid');\n currVal_7;\n const currVal_8:any = _decl0_22.is('invalid');\n currVal_8;\n const currVal_9:any = _decl0_22.is('pending');\n currVal_9;\n const currVal_10:any = _decl0_120.config.errorDictionary;\n currVal_10;\n const currVal_11:any = (_decl0_120.config.autocomplete || 'off');\n currVal_11;\n const currVal_12:any = _decl0_120.config.fields;\n currVal_12;\n const pd_13:any = ((<any>_decl0_32.onSubmit(_any)) !== false);\n const pd_14:any = ((<any>_decl0_32.onReset()) !== false);\n const pd_15:any = ((<any>_decl0_120.handleSubmit()) !== false);\n}\nfunction _View_FormGroupListComponent_Host_2_0():void {\n var _any:any = (null as any);\n}\nfunction _View_FormGroupListComponent_2_2():void {\n if (_decl0_121.config.itemLabelBuilder) {\n var _any:any = (null as any);\n const currVal_0:any = _decl0_121.config.itemLabelBuilder(_any);\n currVal_0;\n }\n}\nfunction _View_FormGroupListComponent_2_3():void {\n if (((_any + 1) > _decl0_121.config.minListLength)) {\n var _any:any = (null as any);\n const currVal_0:any = (_decl0_92.disabled || null);\n currVal_0;\n const currVal_1:any = (_decl0_92._animationMode === 'NoopAnimations');\n currVal_1;\n const currVal_2:any = _decl0_92.disabled;\n currVal_2;\n const currVal_3:any = (_decl0_41._usingFontIcon()? 'font': 'svg');\n currVal_3;\n const currVal_4:any = (_decl0_41._svgName || _decl0_41.fontIcon);\n currVal_4;\n const currVal_5:any = (_decl0_41._svgNamespace || _decl0_41.fontSet);\n currVal_5;\n const currVal_6:any = _decl0_41.inline;\n currVal_6;\n const currVal_7:any = (((_decl0_41.color !== 'primary') && (_decl0_41.color !== 'accent')) && (_decl0_41.color !== 'warn'));\n currVal_7;\n const pd_8:any = ((<any>_decl0_121.deleteGroup(_any)) !== false);\n }\n}\nfunction _View_FormGroupListComponent_2_4():void {\n var _any:any = (null as any);\n const currVal_0:any = _any;\n currVal_0;\n const currVal_1:any = _any;\n currVal_1;\n const currVal_2:any = _decl0_137.transform(_decl0_121.value[_any],_any);\n currVal_2;\n}\nfunction _View_FormGroupListComponent_2_1():void {\n var _any:any = (null as any);\n const currVal_0:any = _decl0_121.config.itemLabelBuilder;\n currVal_0;\n const currVal_1:any = ((_any + 1) > _decl0_121.config.minListLength);\n currVal_1;\n const currVal_2:any = _any;\n currVal_2;\n const currVal_3:any = _decl0_22.is('untouched');\n currVal_3;\n const currVal_4:any = _decl0_22.is('touched');\n currVal_4;\n const currVal_5:any = _decl0_22.is('pristine');\n currVal_5;\n const currVal_6:any = _decl0_22.is('dirty');\n currVal_6;\n const currVal_7:any = _decl0_22.is('valid');\n currVal_7;\n const currVal_8:any = _decl0_22.is('invalid');\n currVal_8;\n const currVal_9:any = _decl0_22.is('pending');\n currVal_9;\n const currVal_10:any = _decl0_121.config.itemConfig.fields;\n currVal_10;\n}\nfunction _View_FormGroupListComponent_2_0():void {\n var _any:any = (null as any);\n const currVal_0:any = _decl0_121.group;\n currVal_0;\n const currVal_1:any = _decl0_22.is('untouched');\n currVal_1;\n const currVal_2:any = _decl0_22.is('touched');\n currVal_2;\n const currVal_3:any = _decl0_22.is('pristine');\n currVal_3;\n const currVal_4:any = _decl0_22.is('dirty');\n currVal_4;\n const currVal_5:any = _decl0_22.is('valid');\n currVal_5;\n const currVal_6:any = _decl0_22.is('invalid');\n currVal_6;\n const currVal_7:any = _decl0_22.is('pending');\n currVal_7;\n const currVal_8:any = _decl0_121.config;\n currVal_8;\n const currVal_9:any = _decl0_121.group;\n currVal_9;\n const currVal_10:any = _decl0_121.config.controlName;\n currVal_10;\n const currVal_11:any = _decl0_22.is('untouched');\n currVal_11;\n const currVal_12:any = _decl0_22.is('touched');\n currVal_12;\n const currVal_13:any = _decl0_22.is('pristine');\n currVal_13;\n const currVal_14:any = _decl0_22.is('dirty');\n currVal_14;\n const currVal_15:any = _decl0_22.is('valid');\n currVal_15;\n const currVal_16:any = _decl0_22.is('invalid');\n currVal_16;\n const currVal_17:any = _decl0_22.is('pending');\n currVal_17;\n const currVal_18:any = ((_decl0_121.formArray == null)? (null as any): _decl0_121.formArray.controls);\n currVal_18;\n const currVal_19:any = (_decl0_92.disabled || null);\n currVal_19;\n const currVal_20:any = (_decl0_92._animationMode === 'NoopAnimations');\n currVal_20;\n const currVal_21:any = _decl0_92.disabled;\n currVal_21;\n const currVal_22:any = _decl0_121.config.addItemLabel;\n currVal_22;\n const pd_23:any = ((<any>_decl0_32.onSubmit(_any)) !== false);\n const pd_24:any = ((<any>_decl0_32.onReset()) !== false);\n const pd_25:any = ((<any>_decl0_121.addGroup()) !== false);\n}\nfunction _View_SubGroupComponent_Host_3_0():void {\n var _any:any = (null as any);\n}\nfunction _View_SubGroupComponent_3_1():void {\n var _any:any = (null as any);\n const currVal_0:any = _any;\n currVal_0;\n const currVal_1:any = _decl0_122.control;\n currVal_1;\n const currVal_2:any = _decl0_137.transform(_decl0_122.value,_any);\n currVal_2;\n}\nfunction _View_SubGroupComponent_3_0():void {\n var _any:any = (null as any);\n const currVal_0:any = _decl0_122.config;\n currVal_0;\n const currVal_1:any = _decl0_122.group;\n currVal_1;\n const currVal_2:any = _decl0_122.config.fields;\n currVal_2;\n}\n"]}
|
|
@@ -34,7 +34,7 @@ export class FormGroupListComponent extends FormGroupListMixin {
|
|
|
34
34
|
FormGroupListComponent.decorators = [
|
|
35
35
|
{ type: Component, args: [{
|
|
36
36
|
selector: 'crispr-form-group-list',
|
|
37
|
-
template: "\n<crispr-field-container\n [config]=\"config\"\n [group]=\"group\"\n [formGroup]=\"group\">\n\n <div [formArrayName]=\"config.controlName\">\n <!-- TODO: add sortBy function -->\n <div *ngFor=\"let control of formArray?.controls; let i = index;\">\n <!-- TODO: use content projection to allow custom item label component -->\n <span class=\"mat-h3\" *ngIf=\"config.itemLabelBuilder\"> {{ config.itemLabelBuilder(i) }} </span>\n <button\n mat-icon-button\n *ngIf=\"i + 1 > config.minListLength\">\n <mat-icon (click)=\"deleteGroup(i)\">delete</mat-icon>\n </button>\n <div\n [formGroupName]=\"i\">\n <ng-container\n *ngFor=\"let field of config.itemConfig.fields;\"\n crisprField\n [config]=\"field\"\n [value]=\"value | initialControlValue : field\"\n [group]=\"control\">\n </ng-container>\n </div>\n </div>\n </div>\n\n <button\n type=\"button\"\n mat-raised-button\n (click)=\"addGroup()\">\n {{config.addItemLabel}}\n </button>\n\n</crispr-field-container>\n",
|
|
37
|
+
template: "\n<crispr-field-container\n [config]=\"config\"\n [group]=\"group\"\n [formGroup]=\"group\">\n\n <div [formArrayName]=\"config.controlName\">\n <!-- TODO: add sortBy function -->\n <div *ngFor=\"let control of formArray?.controls; let i = index;\">\n <!-- TODO: use content projection to allow custom item label component -->\n <span class=\"mat-h3\" *ngIf=\"config.itemLabelBuilder\"> {{ config.itemLabelBuilder(i) }} </span>\n <button\n mat-icon-button\n *ngIf=\"i + 1 > config.minListLength\">\n <mat-icon (click)=\"deleteGroup(i)\">delete</mat-icon>\n </button>\n <div\n [formGroupName]=\"i\">\n <ng-container\n *ngFor=\"let field of config.itemConfig.fields;\"\n crisprField\n [config]=\"field\"\n [value]=\"value[i] | initialControlValue : field\"\n [group]=\"control\">\n </ng-container>\n </div>\n </div>\n </div>\n\n <button\n type=\"button\"\n mat-raised-button\n (click)=\"addGroup()\">\n {{config.addItemLabel}}\n </button>\n\n</crispr-field-container>\n",
|
|
38
38
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
39
39
|
styles: [""]
|
|
40
40
|
},] }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-group-list.component.js","sourceRoot":"","sources":["../../../../../../libs/crispr-forms/src/lib/form-group-list/form-group-list.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAU,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAI3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAExE,MAAM,aAAa,GAAiC;IAClD,YAAY,EAAE,UAAU;IACxB,aAAa,EAAE,CAAC;CACjB,CAAC;AAEF,MAAM,kBAAkB,GAAG,kBAAkB,CAAsB,oBAAoB,CAAC,CAAC;AAOzF,MAAM,OAAO,sBAAuB,SAAQ,kBAAkB;IAN9D;;QAOE,kBAAa,GAAG,aAAa,CAAA;IA4B/B,CAAC;IArBC,QAAQ;QACN,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,gFAAgF;QAChF,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,OAAoB,CAAC;IAC7C,CAAC;IAED,eAAe,CAAC,MAAa;QAC3B,IAAG,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE;YACzB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;SAC/C;aAAM,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,CAAC,EAAE;YACxC,IAAI,CAAC,QAAQ,EAAE,CAAA;SAChB;IACH,CAAC;IAED,QAAQ,CAAC,KAAK,GAAG,IAAI;QACnB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;IACzE,CAAC;IAED,WAAW,CAAC,KAAa;QACvB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;;;YAlCF,SAAS,SAAC;gBACT,QAAQ,EAAE,wBAAwB;gBAClC,
|
|
1
|
+
{"version":3,"file":"form-group-list.component.js","sourceRoot":"","sources":["../../../../../../libs/crispr-forms/src/lib/form-group-list/form-group-list.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAU,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAI3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAExE,MAAM,aAAa,GAAiC;IAClD,YAAY,EAAE,UAAU;IACxB,aAAa,EAAE,CAAC;CACjB,CAAC;AAEF,MAAM,kBAAkB,GAAG,kBAAkB,CAAsB,oBAAoB,CAAC,CAAC;AAOzF,MAAM,OAAO,sBAAuB,SAAQ,kBAAkB;IAN9D;;QAOE,kBAAa,GAAG,aAAa,CAAA;IA4B/B,CAAC;IArBC,QAAQ;QACN,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,gFAAgF;QAChF,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,OAAoB,CAAC;IAC7C,CAAC;IAED,eAAe,CAAC,MAAa;QAC3B,IAAG,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE;YACzB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;SAC/C;aAAM,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,CAAC,EAAE;YACxC,IAAI,CAAC,QAAQ,EAAE,CAAA;SAChB;IACH,CAAC;IAED,QAAQ,CAAC,KAAK,GAAG,IAAI;QACnB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;IACzE,CAAC;IAED,WAAW,CAAC,KAAa;QACvB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;;;YAlCF,SAAS,SAAC;gBACT,QAAQ,EAAE,wBAAwB;gBAClC,omCAA+C;gBAE/C,eAAe,EAAE,uBAAuB,CAAC,MAAM;;aAChD","sourcesContent":["import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';\nimport { FormGroup, FormArray } from '@angular/forms';\n\nimport { FormGroupListConfig } from '../models';\nimport { createControlForType } from '../form.helpers';\nimport { CrisprFieldComponent, crisprControlMixin } from '../abstracts';\n\nconst defaultConfig: Partial<FormGroupListConfig> = {\n addItemLabel: 'ADD ITEM',\n minListLength: 1,\n};\n\nconst FormGroupListMixin = crisprControlMixin<FormGroupListConfig>(CrisprFieldComponent);\n@Component({\n selector: 'crispr-form-group-list',\n templateUrl: './form-group-list.component.html',\n styleUrls: ['./form-group-list.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class FormGroupListComponent extends FormGroupListMixin implements OnInit {\n defaultConfig = defaultConfig\n group: FormGroup;\n control: FormArray;\n _value: any[]\n // value: any[]; // TODO: not sure how to strongly type this yet\n formArray: FormArray;\n\n ngOnInit() {\n super.ngOnInit();\n // TODO: this is required to ngFor of controls in template, must be a better way\n this.formArray = this.control as FormArray;\n }\n\n setControlValue(values: any[]) {\n if(values && this.control) {\n values.forEach(value => this.addGroup(value));\n } else if (this.config.minListLength > 0) {\n this.addGroup()\n }\n }\n\n addGroup(value = null) {\n this.control.push(createControlForType(this.config.itemConfig, value));\n }\n\n deleteGroup(index: number) {\n this.control.removeAt(index);\n }\n}\n\n\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"FormGroupListComponent":{"__symbolic":"class","extends":{"__symbolic":"error","message":"Symbol reference expected","line":19,"character":44},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":13,"character":1},"arguments":[{"selector":"crispr-form-group-list","changeDetection":{"__symbolic":"select","expression":{"__symbolic":"reference","module":"@angular/core","name":"ChangeDetectionStrategy","line":17,"character":19},"member":"OnPush"},"template":"\n<crispr-field-container\n [config]=\"config\"\n [group]=\"group\"\n [formGroup]=\"group\">\n\n <div [formArrayName]=\"config.controlName\">\n <!-- TODO: add sortBy function -->\n <div *ngFor=\"let control of formArray?.controls; let i = index;\">\n <!-- TODO: use content projection to allow custom item label component -->\n <span class=\"mat-h3\" *ngIf=\"config.itemLabelBuilder\"> {{ config.itemLabelBuilder(i) }} </span>\n <button\n mat-icon-button\n *ngIf=\"i + 1 > config.minListLength\">\n <mat-icon (click)=\"deleteGroup(i)\">delete</mat-icon>\n </button>\n <div\n [formGroupName]=\"i\">\n <ng-container\n *ngFor=\"let field of config.itemConfig.fields;\"\n crisprField\n [config]=\"field\"\n [value]=\"value | initialControlValue : field\"\n [group]=\"control\">\n </ng-container>\n </div>\n </div>\n </div>\n\n <button\n type=\"button\"\n mat-raised-button\n (click)=\"addGroup()\">\n {{config.addItemLabel}}\n </button>\n\n</crispr-field-container>\n","styles":[""]}]}],"members":{"ngOnInit":[{"__symbolic":"method"}],"setControlValue":[{"__symbolic":"method"}],"addGroup":[{"__symbolic":"method"}],"deleteGroup":[{"__symbolic":"method"}]}}}}]
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"FormGroupListComponent":{"__symbolic":"class","extends":{"__symbolic":"error","message":"Symbol reference expected","line":19,"character":44},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":13,"character":1},"arguments":[{"selector":"crispr-form-group-list","changeDetection":{"__symbolic":"select","expression":{"__symbolic":"reference","module":"@angular/core","name":"ChangeDetectionStrategy","line":17,"character":19},"member":"OnPush"},"template":"\n<crispr-field-container\n [config]=\"config\"\n [group]=\"group\"\n [formGroup]=\"group\">\n\n <div [formArrayName]=\"config.controlName\">\n <!-- TODO: add sortBy function -->\n <div *ngFor=\"let control of formArray?.controls; let i = index;\">\n <!-- TODO: use content projection to allow custom item label component -->\n <span class=\"mat-h3\" *ngIf=\"config.itemLabelBuilder\"> {{ config.itemLabelBuilder(i) }} </span>\n <button\n mat-icon-button\n *ngIf=\"i + 1 > config.minListLength\">\n <mat-icon (click)=\"deleteGroup(i)\">delete</mat-icon>\n </button>\n <div\n [formGroupName]=\"i\">\n <ng-container\n *ngFor=\"let field of config.itemConfig.fields;\"\n crisprField\n [config]=\"field\"\n [value]=\"value[i] | initialControlValue : field\"\n [group]=\"control\">\n </ng-container>\n </div>\n </div>\n </div>\n\n <button\n type=\"button\"\n mat-raised-button\n (click)=\"addGroup()\">\n {{config.addItemLabel}}\n </button>\n\n</crispr-field-container>\n","styles":[""]}]}],"members":{"ngOnInit":[{"__symbolic":"method"}],"setControlValue":[{"__symbolic":"method"}],"addGroup":[{"__symbolic":"method"}],"deleteGroup":[{"__symbolic":"method"}]}}}}]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ControlType } from './models';
|
|
2
2
|
import { from, of, isObservable, combineLatest } from 'rxjs';
|
|
3
3
|
import { FormGroup, FormArray, FormControl } from '@angular/forms';
|
|
4
4
|
import { valueIn } from './form.operators';
|
|
@@ -114,7 +114,7 @@ export function callOptionsIfFunction(options, parentGroup, searchString) {
|
|
|
114
114
|
* @param options the options passed in from the config
|
|
115
115
|
* @param emptyMessageOption the message to display when the array is empty
|
|
116
116
|
*/
|
|
117
|
-
export function observablifyOptions(options, parentGroup, searchString
|
|
117
|
+
export function observablifyOptions(options, parentGroup, searchString) {
|
|
118
118
|
const calledOptions = callOptionsIfFunction(options, parentGroup, searchString);
|
|
119
119
|
// if options are a promise
|
|
120
120
|
return calledOptions instanceof Promise
|
|
@@ -128,13 +128,8 @@ export function observablifyOptions(options, parentGroup, searchString, emptyOpt
|
|
|
128
128
|
: isObservable(calledOptions)
|
|
129
129
|
// return it
|
|
130
130
|
? calledOptions
|
|
131
|
-
// else
|
|
132
|
-
: of([
|
|
133
|
-
{
|
|
134
|
-
label: emptyOptionsMessage || DEFAULT_EMPTY_OPTIONS_MESSAGE,
|
|
135
|
-
value: null
|
|
136
|
-
}
|
|
137
|
-
]);
|
|
131
|
+
// else an empty array
|
|
132
|
+
: of([]);
|
|
138
133
|
}
|
|
139
134
|
/**
|
|
140
135
|
* Determines if the field config is for a form control (not a divider, heading or other non-control field)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.helpers.js","sourceRoot":"","sources":["../../../../../libs/crispr-forms/src/lib/form.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,6BAA6B,EAG7B,WAAW,EAOZ,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,IAAI,EAEJ,EAAE,EACF,YAAY,EACZ,aAAa,EAEd,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAsBh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CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n SelectOption,\n DEFAULT_EMPTY_OPTIONS_MESSAGE,\n AnyFieldConfig,\n FormConfig,\n ControlType,\n FormGroupListConfig,\n CrisprControlConfig,\n OptionsType,\n AutocompleteOptionsCallback,\n CrisprFieldConfig,\n ControlValue\n} from './models';\nimport {\n from,\n Observable,\n of,\n isObservable,\n combineLatest,\n OperatorFunction\n} from 'rxjs';\nimport { FormGroup, FormArray, FormControl } from '@angular/forms';\nimport { valueIn } from './form.operators';\nimport { map, startWith } from 'rxjs/operators';\n\n/**\n * DYNAMIC FORM UTILS: a collection of pure/mostly pure functions that are useful both internally and for\n * developing the consuming app.\n *\n * They are sorted by use case: building out the form object; helper functions to use with the disabled$ function;\n * helper functions to use with the compute field function; and other logic shared between components\n */\n\n/**\n * Required configuration to use with checkControlForValues function\n */\nexport interface CheckControlConfig {\n // the control name to watch\n controlName: string;\n // the values to watch for\n values: string[];\n // the function to run on the boolean returned by the watcher\n evaluate?: (isValueInValues: boolean) => boolean;\n}\n\n/**\n* Watches a single control for a list of values, returns true when field value matches any value in list\n* unless an evaluate method is found on config, in which case that method is run on the returned boolean value\n* @param group the direct parent of the field we want to watch\n* @param config\n*/\nexport function checkControlForValues(group: FormGroup, config: CheckControlConfig): Observable<boolean> {\n // check that all the pieces we need are available\n if (config && config.controlName && Array.isArray(config.values)) {\n return getValueChanges(group, config.controlName).pipe(\n // return a boolean, true if value is in the values being watch for, otherwise false\n valueIn(config.values),\n map((isValueInValues: boolean) => {\n // since we can only check if the value is in the list of watched values, the evaluate function gives us\n // a chance to make other decisions based on if the boolean returned, e.g. return true if value not in watched values\n if ( config.evaluate && config.evaluate instanceof Function ) {\n return config.evaluate(isValueInValues);\n } else { return isValueInValues; }\n })\n );\n } else {\n //\n return of(true);\n }\n}\n\n/**\n * The required configuration for running the checkControlsForValues function.\n */\nexport interface CheckControlsConfig {\n // an array of controls to watch and the values to check for\n watchConfigs: CheckControlConfig[];\n // the function to run against the array of current field valueIn responses\n evaluate?: ( bools: boolean[] ) => boolean;\n}\n\n/**\n * Watches a list of fields for individual lists of values returning true when any field contains one\n * of the values being watched for, or optionally running a function on the array of resolved booleans\n * from the listed fields and returning a boolean\n * @param group the form group that has the fields to watch as direct descendants\n * @param config the configuration to use when calling the function\n */\nexport function checkControlsForValues(group: FormGroup, config: CheckControlsConfig): Observable<any> {\n // if no config is passed we just want to show the field, so we return an observable of true\n if (!config || !config.watchConfigs) { return of(true); }\n // we run checkControlForValues on every control in the list of WatchConfigs creating\n // an array of Observable watching fields for values\n const fieldTriggers = config.watchConfigs.map(watchConfig => {\n // resolves a boolean, true when field value matches a watched value, otherwise false\n return checkControlForValues(group, watchConfig);\n });\n\n return combineLatest(\n fieldTriggers\n ).pipe(\n startWith([true]),\n map((booleans: boolean[]) => {\n // if the user passed an evaluate function use it\n if (config.evaluate && config.evaluate instanceof Function) {\n return config.evaluate(booleans);\n } else { // otherwise we return true if any of the watched fields resolve to true\n return booleans.some(bool => bool);\n }\n })\n );\n}\n\n/**\n * The required configuration when running the computeValue function\n */\nexport interface ComputeFieldConfig<T = any, RT = any> {\n // array of control names who's values we want to watch\n controlNamesToWatch: string[];\n // the function we want to call on the array of watched values to compute the value of the control we\n computeCallback: (\n values: (T)[]\n ) => RT;\n}\n\n/**\n * Watches values on an array of fields, computing their values as they change\n * @param group the group to get the fields from, for now it can only be the parent of the computed field\n * @param computeFieldsConfig the configuration that drives the computation, holds the names to watch and the\n * computation function that get called against the array of values\n */\nexport function computeValueFromFields(group: FormGroup, computeFieldsConfig: ComputeFieldConfig): Observable<any> {\n // TODO: better checking\n const { controlNamesToWatch } = computeFieldsConfig;\n //creates an observable listener for each control in the controlNamesToWatch array\n return combineLatest(\n controlNamesToWatch.map(controlNameToWatch => getValueChanges(group, controlNameToWatch))\n ).pipe(\n // each time a watched field values changes a new array of the latest field values is pipe through to the\n // compute callback. Which runs the users logic on the values to compute this fields value\n map(valuesArray => computeFieldsConfig.computeCallback(valuesArray)),\n );\n}\n\n/**\n * A simple wrapper for doing error checking around getting the valueChanges observable from a control on a form group\n * @param group the form group we want to pull the observable from\n * @param controlName the name of the control who's value we want to subscribe to\n */\nfunction getValueChanges(group: FormGroup, controlName: string) {\n const control = group.get(controlName);\n if (!control) {\n throw new Error(`No control with controlName ${controlName}`, );\n }\n return control.valueChanges;\n}\n/**\n * TODO: move to utils library after library is built\n * Allows developer to pass an array of operators into the pipe of an Observable.\n * Useful for creating function with a variable amount of operators to be run\n * @param observable the observable to pass the operators to\n * @param operators array of operators to pipe\n */\nfunction pipeOperatorsIntoObservable(observable: Observable<any>, operators: OperatorFunction<any, any>[]) {\n try {\n return operators.reduce((obs: Observable<{}>, op: OperatorFunction<{}, {}>) => {\n return obs.pipe(op);\n }, observable);\n } catch {\n console.error('Unable to pipe operators into observable');\n return of(null);\n }\n}\n\n\nexport function callOptionsIfFunction(\n options: OptionsType | AutocompleteOptionsCallback,\n parentGroup?: FormGroup,\n searchString?: string\n): OptionsType {\n return options instanceof Function ? options(parentGroup, searchString) : options;\n}\n/**\n * The user can give us select options as an array, a function that resolves to a promise,\n * or an observable. This functions consumes any of those and returns an observable that\n * resolves an array of options\n *\n * @param options the options passed in from the config\n * @param emptyMessageOption the message to display when the array is empty\n */\nexport function observablifyOptions(\n options: OptionsType,\n parentGroup: FormGroup,\n searchString?: string,\n emptyOptionsMessage?: string,\n): Observable<SelectOption[]> {\n const calledOptions = callOptionsIfFunction(options, parentGroup, searchString);\n // if options are a promise\n return calledOptions instanceof Promise\n // convert to observable\n ? from(calledOptions)\n // if array that isn't empty\n : Array.isArray(calledOptions) && calledOptions.length\n // convert to observable\n ? of(calledOptions)\n // if observable\n : isObservable(calledOptions)\n // return it\n ? calledOptions\n // else return empty option\n : of([\n {\n label: emptyOptionsMessage || DEFAULT_EMPTY_OPTIONS_MESSAGE,\n value: null\n }\n ]);\n}\n\n/**\n * Determines if the field config is for a form control (not a divider, heading or other non-control field)\n * */\nexport function isControlConfig(fieldConfig: CrisprFieldConfig): fieldConfig is CrisprControlConfig {\n return 'controlName' in fieldConfig;\n}\n/**\n * builds out form group based on config\n * @param config a configuration for a form group\n * @param value an object of initial values to pass in\n * @param group the form group to modify and build out\n */\nexport function buildFormGroupFromConfig(config: FormConfig, value = null, group: FormGroup = new FormGroup({}) ) {\n config.fields.forEach( (controlConfig: AnyFieldConfig) => {\n if (isControlConfig(controlConfig)) {\n // then add a control to the group using the controlName from configuration\n const {controlName} = controlConfig;\n // if there's a value object and it has a non-null/undefined value for this field use it.\n // Otherwise, default to null\n const controlValue = (value && value[controlName]) ?? null;\n group.addControl(controlName, createControlForType(controlConfig, controlValue));\n }\n });\n group.setValidators(config.validators);\n return group;\n}\n\n/**\n * Analyze the config and build a form control to spec. Notice we don't use FormBuilder here\n * as we want to keep this function pure.\n * @param controlConfig the configuration object for the control to build\n * @param value an initial value to use if passed in\n */\nexport function createControlForType(controlConfig: AnyFieldConfig, value: ControlValue = null) {\n // build form control out based on the control type\n const control = controlConfig.controlType === ControlType.SUB_GROUP\n ? buildFormGroupFromConfig(controlConfig as FormConfig, value)\n : controlConfig.controlType === ControlType.GROUP_LIST\n ? new FormArray([], (controlConfig as FormGroupListConfig).validators)\n : new FormControl(\n value || null,\n (controlConfig as CrisprControlConfig).validators\n );\n\n return control;\n}\n\n/**\n * A basic filter function that filters the search string against the label of the options object\n * @param options the array of options to filter\n * @param searchString the string from the input\n */\nexport function filterOptionsByLabel(options: SelectOption[], searchString: string) {\n return options.filter(option => {\n return option.label && option.label.toLowerCase().includes(searchString.toLowerCase());\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"form.helpers.js","sourceRoot":"","sources":["../../../../../libs/crispr-forms/src/lib/form.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,WAAW,EAOZ,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,IAAI,EAEJ,EAAE,EACF,YAAY,EACZ,aAAa,EAEd,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,SAA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W,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC;IACzF,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n SelectOption,\n AnyFieldConfig,\n FormConfig,\n ControlType,\n FormGroupListConfig,\n CrisprControlConfig,\n OptionsType,\n AutocompleteOptionsCallback,\n CrisprFieldConfig,\n ControlValue\n} from './models';\nimport {\n from,\n Observable,\n of,\n isObservable,\n combineLatest,\n OperatorFunction\n} from 'rxjs';\nimport { FormGroup, FormArray, FormControl } from '@angular/forms';\nimport { valueIn } from './form.operators';\nimport { map, startWith } from 'rxjs/operators';\n\n/**\n * DYNAMIC FORM UTILS: a collection of pure/mostly pure functions that are useful both internally and for\n * developing the consuming app.\n *\n * They are sorted by use case: building out the form object; helper functions to use with the disabled$ function;\n * helper functions to use with the compute field function; and other logic shared between components\n */\n\n/**\n * Required configuration to use with checkControlForValues function\n */\nexport interface CheckControlConfig {\n // the control name to watch\n controlName: string;\n // the values to watch for\n values: string[];\n // the function to run on the boolean returned by the watcher\n evaluate?: (isValueInValues: boolean) => boolean;\n}\n\n/**\n* Watches a single control for a list of values, returns true when field value matches any value in list\n* unless an evaluate method is found on config, in which case that method is run on the returned boolean value\n* @param group the direct parent of the field we want to watch\n* @param config\n*/\nexport function checkControlForValues(group: FormGroup, config: CheckControlConfig): Observable<boolean> {\n // check that all the pieces we need are available\n if (config && config.controlName && Array.isArray(config.values)) {\n return getValueChanges(group, config.controlName).pipe(\n // return a boolean, true if value is in the values being watch for, otherwise false\n valueIn(config.values),\n map((isValueInValues: boolean) => {\n // since we can only check if the value is in the list of watched values, the evaluate function gives us\n // a chance to make other decisions based on if the boolean returned, e.g. return true if value not in watched values\n if ( config.evaluate && config.evaluate instanceof Function ) {\n return config.evaluate(isValueInValues);\n } else { return isValueInValues; }\n })\n );\n } else {\n //\n return of(true);\n }\n}\n\n/**\n * The required configuration for running the checkControlsForValues function.\n */\nexport interface CheckControlsConfig {\n // an array of controls to watch and the values to check for\n watchConfigs: CheckControlConfig[];\n // the function to run against the array of current field valueIn responses\n evaluate?: ( bools: boolean[] ) => boolean;\n}\n\n/**\n * Watches a list of fields for individual lists of values returning true when any field contains one\n * of the values being watched for, or optionally running a function on the array of resolved booleans\n * from the listed fields and returning a boolean\n * @param group the form group that has the fields to watch as direct descendants\n * @param config the configuration to use when calling the function\n */\nexport function checkControlsForValues(group: FormGroup, config: CheckControlsConfig): Observable<any> {\n // if no config is passed we just want to show the field, so we return an observable of true\n if (!config || !config.watchConfigs) { return of(true); }\n // we run checkControlForValues on every control in the list of WatchConfigs creating\n // an array of Observable watching fields for values\n const fieldTriggers = config.watchConfigs.map(watchConfig => {\n // resolves a boolean, true when field value matches a watched value, otherwise false\n return checkControlForValues(group, watchConfig);\n });\n\n return combineLatest(\n fieldTriggers\n ).pipe(\n startWith([true]),\n map((booleans: boolean[]) => {\n // if the user passed an evaluate function use it\n if (config.evaluate && config.evaluate instanceof Function) {\n return config.evaluate(booleans);\n } else { // otherwise we return true if any of the watched fields resolve to true\n return booleans.some(bool => bool);\n }\n })\n );\n}\n\n/**\n * The required configuration when running the computeValue function\n */\nexport interface ComputeFieldConfig<T = any, RT = any> {\n // array of control names who's values we want to watch\n controlNamesToWatch: string[];\n // the function we want to call on the array of watched values to compute the value of the control we\n computeCallback: (\n values: (T)[]\n ) => RT;\n}\n\n/**\n * Watches values on an array of fields, computing their values as they change\n * @param group the group to get the fields from, for now it can only be the parent of the computed field\n * @param computeFieldsConfig the configuration that drives the computation, holds the names to watch and the\n * computation function that get called against the array of values\n */\nexport function computeValueFromFields(group: FormGroup, computeFieldsConfig: ComputeFieldConfig): Observable<any> {\n // TODO: better checking\n const { controlNamesToWatch } = computeFieldsConfig;\n //creates an observable listener for each control in the controlNamesToWatch array\n return combineLatest(\n controlNamesToWatch.map(controlNameToWatch => getValueChanges(group, controlNameToWatch))\n ).pipe(\n // each time a watched field values changes a new array of the latest field values is pipe through to the\n // compute callback. Which runs the users logic on the values to compute this fields value\n map(valuesArray => computeFieldsConfig.computeCallback(valuesArray)),\n );\n}\n\n/**\n * A simple wrapper for doing error checking around getting the valueChanges observable from a control on a form group\n * @param group the form group we want to pull the observable from\n * @param controlName the name of the control who's value we want to subscribe to\n */\nfunction getValueChanges(group: FormGroup, controlName: string) {\n const control = group.get(controlName);\n if (!control) {\n throw new Error(`No control with controlName ${controlName}`, );\n }\n return control.valueChanges;\n}\n/**\n * TODO: move to utils library after library is built\n * Allows developer to pass an array of operators into the pipe of an Observable.\n * Useful for creating function with a variable amount of operators to be run\n * @param observable the observable to pass the operators to\n * @param operators array of operators to pipe\n */\nfunction pipeOperatorsIntoObservable(observable: Observable<any>, operators: OperatorFunction<any, any>[]) {\n try {\n return operators.reduce((obs: Observable<{}>, op: OperatorFunction<{}, {}>) => {\n return obs.pipe(op);\n }, observable);\n } catch {\n console.error('Unable to pipe operators into observable');\n return of(null);\n }\n}\n\n\nexport function callOptionsIfFunction(\n options: OptionsType | AutocompleteOptionsCallback,\n parentGroup?: FormGroup,\n searchString?: string\n): OptionsType {\n return options instanceof Function ? options(parentGroup, searchString) : options;\n}\n/**\n * The user can give us select options as an array, a function that resolves to a promise,\n * or an observable. This functions consumes any of those and returns an observable that\n * resolves an array of options\n *\n * @param options the options passed in from the config\n * @param emptyMessageOption the message to display when the array is empty\n */\nexport function observablifyOptions(\n options: OptionsType,\n parentGroup: FormGroup,\n searchString?: string,\n): Observable<SelectOption[]> {\n const calledOptions = callOptionsIfFunction(options, parentGroup, searchString);\n // if options are a promise\n return calledOptions instanceof Promise\n // convert to observable\n ? from(calledOptions)\n // if array that isn't empty\n : Array.isArray(calledOptions) && calledOptions.length\n // convert to observable\n ? of(calledOptions)\n // if observable\n : isObservable(calledOptions)\n // return it\n ? calledOptions\n // else an empty array\n : of([]);\n}\n\n/**\n * Determines if the field config is for a form control (not a divider, heading or other non-control field)\n * */\nexport function isControlConfig(fieldConfig: CrisprFieldConfig): fieldConfig is CrisprControlConfig {\n return 'controlName' in fieldConfig;\n}\n/**\n * builds out form group based on config\n * @param config a configuration for a form group\n * @param value an object of initial values to pass in\n * @param group the form group to modify and build out\n */\nexport function buildFormGroupFromConfig(config: FormConfig, value = null, group: FormGroup = new FormGroup({}) ) {\n config.fields.forEach( (controlConfig: AnyFieldConfig) => {\n if (isControlConfig(controlConfig)) {\n // then add a control to the group using the controlName from configuration\n const {controlName} = controlConfig;\n // if there's a value object and it has a non-null/undefined value for this field use it.\n // Otherwise, default to null\n const controlValue = (value && value[controlName]) ?? null;\n group.addControl(controlName, createControlForType(controlConfig, controlValue));\n }\n });\n group.setValidators(config.validators);\n return group;\n}\n\n/**\n * Analyze the config and build a form control to spec. Notice we don't use FormBuilder here\n * as we want to keep this function pure.\n * @param controlConfig the configuration object for the control to build\n * @param value an initial value to use if passed in\n */\nexport function createControlForType(controlConfig: AnyFieldConfig, value: ControlValue = null) {\n // build form control out based on the control type\n const control = controlConfig.controlType === ControlType.SUB_GROUP\n ? buildFormGroupFromConfig(controlConfig as FormConfig, value)\n : controlConfig.controlType === ControlType.GROUP_LIST\n ? new FormArray([], (controlConfig as FormGroupListConfig).validators)\n : new FormControl(\n value || null,\n (controlConfig as CrisprControlConfig).validators\n );\n\n return control;\n}\n\n/**\n * A basic filter function that filters the search string against the label of the options object\n * @param options the array of options to filter\n * @param searchString the string from the input\n */\nexport function filterOptionsByLabel(options: SelectOption[], searchString: string) {\n return options.filter(option => {\n return option.label && option.label.toLowerCase().includes(searchString.toLowerCase());\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"CheckControlConfig":{"__symbolic":"interface"},"checkControlForValues":{"__symbolic":"function"},"CheckControlsConfig":{"__symbolic":"interface"},"checkControlsForValues":{"__symbolic":"function"},"ComputeFieldConfig":{"__symbolic":"interface"},"computeValueFromFields":{"__symbolic":"function"},"callOptionsIfFunction":{"__symbolic":"function","parameters":["options","parentGroup","searchString"],"value":{"__symbolic":"if","condition":{"__symbolic":"binop","operator":"instanceof","left":{"__symbolic":"reference","name":"options"},"right":{"__symbolic":"reference","name":"Function"}},"thenExpression":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"options"},"arguments":[{"__symbolic":"reference","name":"parentGroup"},{"__symbolic":"reference","name":"searchString"}]},"elseExpression":{"__symbolic":"reference","name":"options"}}},"observablifyOptions":{"__symbolic":"function"},"isControlConfig":{"__symbolic":"function","parameters":["fieldConfig"],"value":{"__symbolic":"binop","operator":"in","left":"controlName","right":{"__symbolic":"reference","name":"fieldConfig"}}},"buildFormGroupFromConfig":{"__symbolic":"function"},"createControlForType":{"__symbolic":"function"},"filterOptionsByLabel":{"__symbolic":"function","parameters":["options","searchString"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"options"},"member":"filter"},"arguments":[{"__symbolic":"error","message":"Lambda not supported","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"CheckControlConfig":{"__symbolic":"interface"},"checkControlForValues":{"__symbolic":"function"},"CheckControlsConfig":{"__symbolic":"interface"},"checkControlsForValues":{"__symbolic":"function"},"ComputeFieldConfig":{"__symbolic":"interface"},"computeValueFromFields":{"__symbolic":"function"},"callOptionsIfFunction":{"__symbolic":"function","parameters":["options","parentGroup","searchString"],"value":{"__symbolic":"if","condition":{"__symbolic":"binop","operator":"instanceof","left":{"__symbolic":"reference","name":"options"},"right":{"__symbolic":"reference","name":"Function"}},"thenExpression":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"options"},"arguments":[{"__symbolic":"reference","name":"parentGroup"},{"__symbolic":"reference","name":"searchString"}]},"elseExpression":{"__symbolic":"reference","name":"options"}}},"observablifyOptions":{"__symbolic":"function"},"isControlConfig":{"__symbolic":"function","parameters":["fieldConfig"],"value":{"__symbolic":"binop","operator":"in","left":"controlName","right":{"__symbolic":"reference","name":"fieldConfig"}}},"buildFormGroupFromConfig":{"__symbolic":"function"},"createControlForType":{"__symbolic":"function"},"filterOptionsByLabel":{"__symbolic":"function","parameters":["options","searchString"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"options"},"member":"filter"},"arguments":[{"__symbolic":"error","message":"Lambda not supported","line":264,"character":24}]}}}}]
|
package/esm2015/lib/material/autocomplete-chiplist-field/autocomplete-chiplist-field.component.js
CHANGED
|
@@ -2,15 +2,19 @@ import { Component, ChangeDetectionStrategy, ViewChild, ElementRef } from '@angu
|
|
|
2
2
|
import { map, tap } from 'rxjs/operators';
|
|
3
3
|
import { MatAutocompleteTrigger } from '@angular/material/autocomplete';
|
|
4
4
|
import { BehaviorSubject, combineLatest } from 'rxjs';
|
|
5
|
+
import { ENTER } from '@angular/cdk/keycodes';
|
|
6
|
+
import { DEFAULT_EMPTY_OPTIONS_MESSAGE } from '../../models';
|
|
5
7
|
import { AbstractAutocompleteComponent } from '../../abstracts';
|
|
6
8
|
const defaultConfig = {
|
|
7
9
|
chipsSelectable: true,
|
|
8
10
|
areChipsRemovable: true,
|
|
9
|
-
|
|
10
|
-
autoActiveFirstOption:
|
|
11
|
+
tabToSelect: true,
|
|
12
|
+
autoActiveFirstOption: false,
|
|
11
13
|
imageUrlParam: 'image',
|
|
12
14
|
typeDebounceTime: 500,
|
|
13
|
-
allowDuplicates: false
|
|
15
|
+
allowDuplicates: false,
|
|
16
|
+
separatorKeyCodes: [ENTER],
|
|
17
|
+
emptyOptionsMessage: DEFAULT_EMPTY_OPTIONS_MESSAGE,
|
|
14
18
|
};
|
|
15
19
|
export class AutocompleteChiplistFieldComponent extends AbstractAutocompleteComponent {
|
|
16
20
|
constructor() {
|
|
@@ -29,7 +33,7 @@ export class AutocompleteChiplistFieldComponent extends AbstractAutocompleteComp
|
|
|
29
33
|
]).pipe(map(([chips, options]) => {
|
|
30
34
|
return this.config.allowDuplicates
|
|
31
35
|
? options
|
|
32
|
-
: options.filter(option => {
|
|
36
|
+
: options === null || options === void 0 ? void 0 : options.filter(option => {
|
|
33
37
|
return !chips.some(chip => chip.value === option.value);
|
|
34
38
|
});
|
|
35
39
|
}));
|
|
@@ -39,20 +43,37 @@ export class AutocompleteChiplistFieldComponent extends AbstractAutocompleteComp
|
|
|
39
43
|
this.chips$.next(value);
|
|
40
44
|
}
|
|
41
45
|
}
|
|
46
|
+
// handles mat selecting
|
|
42
47
|
handleSelect(event) {
|
|
43
48
|
const selectedOption = event.option.value;
|
|
44
49
|
this.chips$.next([...this.chips$.value, selectedOption]);
|
|
45
50
|
this.chipInputRef.nativeElement.value = '';
|
|
46
51
|
this.autocompleteInputControl.setValue('');
|
|
52
|
+
// setTimeout needed because the panel thinks it's still open at this point
|
|
53
|
+
setTimeout(() => this.chipInput.openPanel());
|
|
47
54
|
}
|
|
48
55
|
/**
|
|
49
56
|
* To follow ARIA standards we want to select the active option on blur.
|
|
50
|
-
*
|
|
57
|
+
* matChipInputAddOnBlur should do this but it causes buggy behaviour
|
|
58
|
+
* @param event blur event that triggers the handle blur
|
|
51
59
|
*/
|
|
52
60
|
handleTab(_event) {
|
|
61
|
+
if (this.chipInput.activeOption && (this.config.tabToSelect || this.config.addChipOnBlur)) {
|
|
62
|
+
const chip = this.chipInput.activeOption.value;
|
|
63
|
+
this.chips$.next([...this.chips$.value, chip]);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Handles selection via key tokens passed through separatorKeyCodes propert
|
|
68
|
+
* NOTE: If TAB is used focus does not move on to next component
|
|
69
|
+
* @param event
|
|
70
|
+
*/
|
|
71
|
+
handleTokenEnd(event) {
|
|
72
|
+
var _a;
|
|
53
73
|
if (this.chipInput.activeOption) {
|
|
54
74
|
this.chipInput.activeOption.select();
|
|
55
75
|
}
|
|
76
|
+
(_a = event.chipInput) === null || _a === void 0 ? void 0 : _a.clear();
|
|
56
77
|
}
|
|
57
78
|
mapToLabel(option) {
|
|
58
79
|
return option ? option.label : '';
|
|
@@ -61,16 +82,13 @@ export class AutocompleteChiplistFieldComponent extends AbstractAutocompleteComp
|
|
|
61
82
|
const remainingChips = this.chips$.value.filter(chip => chip !== removedChip);
|
|
62
83
|
this.chips$.next(remainingChips);
|
|
63
84
|
}
|
|
64
|
-
inputFilter(stringToCheck, searchString) {
|
|
65
|
-
return stringToCheck.toLowerCase().includes(searchString.trim().toLowerCase());
|
|
66
|
-
}
|
|
67
85
|
}
|
|
68
86
|
AutocompleteChiplistFieldComponent.decorators = [
|
|
69
87
|
{ type: Component, args: [{
|
|
70
88
|
selector: 'crispr-autocomplete-chiplist-field',
|
|
71
|
-
template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n\n <mat-form-field\n [color]=\"config.color\"\n [appearance]=\"config.appearance\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n\n <mat-chip-list\n #chipList>\n <mat-chip\n class=\"refinement-chip\"\n *ngFor=\"let chip of controlValue$ | async\"\n [selectable]=\"config.chipsSelectable\"\n [removable]=\"config.areChipsRemovable\"\n (removed)=\"removeChip(chip)\">\n {{chip.label}}\n <mat-icon\n matChipRemove\n *ngIf=\"config.areChipsRemovable\">\n cancel\n </mat-icon>\n </mat-chip>\n\n <input\n matInput\n [formControl]=\"autocompleteInputControl\"\n [placeholder]=\"config.placeholder\"\n [matChipInputFor]=\"chipList\"\n [matAutocomplete]=\"auto\"\n (keydown.tab)=\"handleTab($event)\"\n role=\"
|
|
89
|
+
template: "<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n\n <mat-form-field\n [color]=\"config.color\"\n [appearance]=\"config.appearance\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n\n <mat-chip-list\n #chipList>\n <mat-chip\n class=\"refinement-chip\"\n *ngFor=\"let chip of controlValue$ | async\"\n [selectable]=\"config.chipsSelectable\"\n [removable]=\"config.areChipsRemovable\"\n (removed)=\"removeChip(chip)\">\n <span *ngIf=\"chip.imageUrl as imageUrl\" class=\"image-container\">\n <img [src]=\"imageUrl\" alt=\"\">\n </span>\n {{chip.label}}\n <mat-icon\n matChipRemove\n *ngIf=\"config.areChipsRemovable\">\n cancel\n </mat-icon>\n </mat-chip>\n\n <input\n matInput\n [formControl]=\"autocompleteInputControl\"\n [placeholder]=\"config.placeholder\"\n [matChipInputFor]=\"chipList\"\n [matAutocomplete]=\"auto\"\n (keydown.tab)=\"handleTab($event)\"\n [matChipInputSeparatorKeyCodes]=\"config.separatorKeyCodes\"\n (matChipInputTokenEnd)=\"handleTokenEnd($event)\"\n role=\"searchbox\"\n type=\"text\"\n autocapitalize=\"off\"\n autocorrect=\"off\"\n spellcheck=\"false\"\n #autoInput/>\n <span *ngIf=\"config.fieldSuffix\" matSuffix>{{config.fieldSuffix}}</span>\n <crispr-info\n *ngIf=\"config.info\"\n matSuffix\n [info]=\"config.info \">\n </crispr-info>\n\n </mat-chip-list>\n <mat-autocomplete\n #auto=\"matAutocomplete\"\n [autoActiveFirstOption]=\"this.config.autoActiveFirstOption\"\n (optionSelected)=\"handleSelect($event)\"\n [displayWith]=\"mapToLabel\">\n <ng-container *ngIf=\"remainingOptions$ | async as remainingOptions; else emptyOption\">\n <ng-container *ngIf=\"remainingOptions.length > 0; else emptyOption\">\n <mat-option\n *ngFor=\"let option of remainingOptions$ | async\"\n [value]=\"option\">\n <crispr-option [option]=\"option\"></crispr-option>\n </mat-option>\n </ng-container>\n\n </ng-container>\n <ng-template #emptyOption>\n <mat-option disabled=\"true\">\n {{config.emptyOptionsMessage}}\n </mat-option>\n </ng-template>\n </mat-autocomplete>\n\n\n </mat-form-field>\n</crispr-field-container>\n",
|
|
72
90
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
73
|
-
styles: [""]
|
|
91
|
+
styles: [".refinement-chip .image-container{width:26px;height:26px;border-radius:50%;overflow:hidden;margin:-2px 4px -2px -8px}.refinement-chip .image-container img{width:100%;height:100%;-o-object-fit:cover;object-fit:cover}"]
|
|
74
92
|
},] }
|
|
75
93
|
];
|
|
76
94
|
AutocompleteChiplistFieldComponent.propDecorators = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete-chiplist-field.component.js","sourceRoot":"","sources":["../../../../../../../libs/crispr-forms/src/lib/material/autocomplete-chiplist-field/autocomplete-chiplist-field.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAU,uBAAuB,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAClG,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAgC,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACtG,OAAO,EAAc,eAAe,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"autocomplete-chiplist-field.component.js","sourceRoot":"","sources":["../../../../../../../libs/crispr-forms/src/lib/material/autocomplete-chiplist-field/autocomplete-chiplist-field.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAU,uBAAuB,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAClG,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAgC,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACtG,OAAO,EAAc,eAAe,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,OAAO,EAAmC,6BAA6B,EAAgB,MAAM,cAAc,CAAC;AAC5G,OAAO,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAGhE,MAAM,aAAa,GAA6C;IAC9D,eAAe,EAAE,IAAI;IACrB,iBAAiB,EAAE,IAAI;IACvB,WAAW,EAAE,IAAI;IACjB,qBAAqB,EAAE,KAAK;IAC5B,aAAa,EAAE,OAAO;IACtB,gBAAgB,EAAE,GAAG;IACrB,eAAe,EAAE,KAAK;IACtB,iBAAiB,EAAE,CAAC,KAAK,CAAC;IAC1B,m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,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC;;;YAzFF,SAAS,SAAC;gBACT,QAAQ,EAAE,oCAAoC;gBAC9C,u9EAA2D;gBAE3D,eAAe,EAAE,uBAAuB,CAAC,MAAM;;aAChD;;;wBAiBE,SAAS,SAAC,WAAW,EAAE,EAAE,IAAI,EAAE,sBAAsB,EAAE;2BACvD,SAAS,SAAC,WAAW","sourcesContent":["import { Component, OnInit, ChangeDetectionStrategy, ViewChild, ElementRef } from '@angular/core';\nimport { map, tap } from 'rxjs/operators';\nimport { MatAutocompleteSelectedEvent, MatAutocompleteTrigger } from '@angular/material/autocomplete';\nimport { Observable, BehaviorSubject, combineLatest } from 'rxjs';\nimport { ENTER } from '@angular/cdk/keycodes';\n\nimport { AutocompleteChiplistFieldConfig, DEFAULT_EMPTY_OPTIONS_MESSAGE, SelectOption } from '../../models';\nimport { AbstractAutocompleteComponent } from '../../abstracts';\nimport { MatChipInputEvent } from '@angular/material/chips';\n\nconst defaultConfig: Partial<AutocompleteChiplistFieldConfig> = {\n chipsSelectable: true,\n areChipsRemovable: true,\n tabToSelect: true,\n autoActiveFirstOption: false,\n imageUrlParam: 'image',\n typeDebounceTime: 500,\n allowDuplicates: false,\n separatorKeyCodes: [ENTER],\n emptyOptionsMessage: DEFAULT_EMPTY_OPTIONS_MESSAGE,\n}\n\n@Component({\n selector: 'crispr-autocomplete-chiplist-field',\n templateUrl: './autocomplete-chiplist-field.component.html',\n styleUrls: ['./autocomplete-chiplist-field.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class AutocompleteChiplistFieldComponent\n extends AbstractAutocompleteComponent<AutocompleteChiplistFieldConfig> implements OnInit {\n defaultConfig = defaultConfig;\n chips$ = new BehaviorSubject<SelectOption[]>([]);\n remainingOptions$: Observable<SelectOption[]>;\n\n controlValue$ = this.chips$.pipe(\n tap(chips => {\n this.control.setValue(chips.map(chip => chip.value))\n })\n );\n\n\n // We need use ViewChild twice on the same template ref to access as different types\n // - the MatAutocompleteTrigger is used to for selecting value on tab\n // - the ElementRef<HTMLInputElement> is used to clear the value from input element on selection\n @ViewChild('autoInput', { read: MatAutocompleteTrigger }) chipInput: MatAutocompleteTrigger;\n @ViewChild('autoInput') chipInputRef: ElementRef<HTMLInputElement>;\n\n\n ngOnInit() {\n super.ngOnInit();\n this.remainingOptions$ = combineLatest([\n this.chips$,\n this.options$\n ]).pipe(\n map(([chips, options]) => {\n return this.config.allowDuplicates\n ? options\n : options?.filter(option => {\n return !chips.some(chip => chip.value === option.value);\n })\n })\n )\n }\n\n setControlValue(value: SelectOption[]) {\n if (value) {\n this.chips$.next(value);\n }\n }\n\n // handles mat selecting\n handleSelect(event: MatAutocompleteSelectedEvent) {\n const selectedOption: SelectOption = event.option.value as SelectOption;\n this.chips$.next([...this.chips$.value, selectedOption]);\n this.chipInputRef.nativeElement.value = '';\n this.autocompleteInputControl.setValue('');\n // setTimeout needed because the panel thinks it's still open at this point\n setTimeout(() => this.chipInput.openPanel())\n }\n\n /**\n * To follow ARIA standards we want to select the active option on blur.\n * matChipInputAddOnBlur should do this but it causes buggy behaviour\n * @param event blur event that triggers the handle blur\n */\n handleTab(_event: FocusEvent) {\n if (this.chipInput.activeOption && (this.config.tabToSelect || this.config.addChipOnBlur)) {\n const chip = this.chipInput.activeOption.value;\n this.chips$.next([...this.chips$.value, chip]);\n }\n }\n\n /**\n * Handles selection via key tokens passed through separatorKeyCodes propert\n * NOTE: If TAB is used focus does not move on to next component\n * @param event\n */\n handleTokenEnd(event: MatChipInputEvent) {\n if (this.chipInput.activeOption) {\n this.chipInput.activeOption.select();\n }\n event.chipInput?.clear();\n }\n\n mapToLabel(option: SelectOption) {\n return option ? option.label : '';\n }\n\n removeChip(removedChip: SelectOption) {\n const remainingChips: SelectOption[] = this.chips$.value.filter(chip => chip !== removedChip);\n this.chips$.next(remainingChips);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"AutocompleteChiplistFieldComponent":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../../abstracts","name":"AbstractAutocompleteComponent","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"AutocompleteChiplistFieldComponent":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../../abstracts","name":"AbstractAutocompleteComponent","line":29,"character":10},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":22,"character":1},"arguments":[{"selector":"crispr-autocomplete-chiplist-field","changeDetection":{"__symbolic":"select","expression":{"__symbolic":"reference","module":"@angular/core","name":"ChangeDetectionStrategy","line":26,"character":19},"member":"OnPush"},"template":"<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n\n <mat-form-field\n [color]=\"config.color\"\n [appearance]=\"config.appearance\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n\n <mat-chip-list\n #chipList>\n <mat-chip\n class=\"refinement-chip\"\n *ngFor=\"let chip of controlValue$ | async\"\n [selectable]=\"config.chipsSelectable\"\n [removable]=\"config.areChipsRemovable\"\n (removed)=\"removeChip(chip)\">\n <span *ngIf=\"chip.imageUrl as imageUrl\" class=\"image-container\">\n <img [src]=\"imageUrl\" alt=\"\">\n </span>\n {{chip.label}}\n <mat-icon\n matChipRemove\n *ngIf=\"config.areChipsRemovable\">\n cancel\n </mat-icon>\n </mat-chip>\n\n <input\n matInput\n [formControl]=\"autocompleteInputControl\"\n [placeholder]=\"config.placeholder\"\n [matChipInputFor]=\"chipList\"\n [matAutocomplete]=\"auto\"\n (keydown.tab)=\"handleTab($event)\"\n [matChipInputSeparatorKeyCodes]=\"config.separatorKeyCodes\"\n (matChipInputTokenEnd)=\"handleTokenEnd($event)\"\n role=\"searchbox\"\n type=\"text\"\n autocapitalize=\"off\"\n autocorrect=\"off\"\n spellcheck=\"false\"\n #autoInput/>\n <span *ngIf=\"config.fieldSuffix\" matSuffix>{{config.fieldSuffix}}</span>\n <crispr-info\n *ngIf=\"config.info\"\n matSuffix\n [info]=\"config.info \">\n </crispr-info>\n\n </mat-chip-list>\n <mat-autocomplete\n #auto=\"matAutocomplete\"\n [autoActiveFirstOption]=\"this.config.autoActiveFirstOption\"\n (optionSelected)=\"handleSelect($event)\"\n [displayWith]=\"mapToLabel\">\n <ng-container *ngIf=\"remainingOptions$ | async as remainingOptions; else emptyOption\">\n <ng-container *ngIf=\"remainingOptions.length > 0; else emptyOption\">\n <mat-option\n *ngFor=\"let option of remainingOptions$ | async\"\n [value]=\"option\">\n <crispr-option [option]=\"option\"></crispr-option>\n </mat-option>\n </ng-container>\n\n </ng-container>\n <ng-template #emptyOption>\n <mat-option disabled=\"true\">\n {{config.emptyOptionsMessage}}\n </mat-option>\n </ng-template>\n </mat-autocomplete>\n\n\n </mat-form-field>\n</crispr-field-container>\n","styles":[".refinement-chip .image-container{width:26px;height:26px;border-radius:50%;overflow:hidden;margin:-2px 4px -2px -8px}.refinement-chip .image-container img{width:100%;height:100%;-o-object-fit:cover;object-fit:cover}"]}]}],"members":{"chipInput":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild","line":44,"character":3},"arguments":["autoInput",{"read":{"__symbolic":"reference","module":"@angular/material/autocomplete","name":"MatAutocompleteTrigger","line":44,"character":34}}]}]}],"chipInputRef":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild","line":45,"character":3},"arguments":["autoInput"]}]}],"ngOnInit":[{"__symbolic":"method"}],"setControlValue":[{"__symbolic":"method"}],"handleSelect":[{"__symbolic":"method"}],"handleTab":[{"__symbolic":"method"}],"handleTokenEnd":[{"__symbolic":"method"}],"mapToLabel":[{"__symbolic":"method"}],"removeChip":[{"__symbolic":"method"}]}}}}]
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Component, ViewChild, ChangeDetectionStrategy, ElementRef } from '@angular/core';
|
|
2
2
|
import { MatAutocompleteTrigger } from '@angular/material/autocomplete';
|
|
3
|
+
import { DEFAULT_EMPTY_OPTIONS_MESSAGE } from '../../models';
|
|
3
4
|
import { AbstractAutocompleteComponent } from '../../abstracts';
|
|
4
5
|
const defaultConfig = {
|
|
5
6
|
autoActiveFirstOption: true,
|
|
6
|
-
typeDebounceTime: 500
|
|
7
|
+
typeDebounceTime: 500,
|
|
8
|
+
emptyOptionsMessage: DEFAULT_EMPTY_OPTIONS_MESSAGE
|
|
7
9
|
};
|
|
8
10
|
export class AutocompleteFieldComponent extends AbstractAutocompleteComponent {
|
|
9
11
|
constructor() {
|
|
@@ -12,13 +14,12 @@ export class AutocompleteFieldComponent extends AbstractAutocompleteComponent {
|
|
|
12
14
|
}
|
|
13
15
|
ngOnInit() {
|
|
14
16
|
super.ngOnInit();
|
|
15
|
-
this.setControlValue(this.value);
|
|
16
17
|
}
|
|
17
18
|
setControlValue(value) {
|
|
18
|
-
if (
|
|
19
|
+
if (this.control && value) {
|
|
19
20
|
// sets the initial value on the control if one is passed
|
|
20
|
-
this.control.setValue(value.value
|
|
21
|
-
this.autocompleteInputControl.setValue(value.label);
|
|
21
|
+
this.control.setValue(value.value || '');
|
|
22
|
+
this.autocompleteInputControl.setValue(value.label || '');
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
@@ -40,22 +41,11 @@ export class AutocompleteFieldComponent extends AbstractAutocompleteComponent {
|
|
|
40
41
|
this.control.setValue(event.option.value);
|
|
41
42
|
this.autoInputRef.nativeElement.blur();
|
|
42
43
|
}
|
|
43
|
-
/**
|
|
44
|
-
* To follow ARIA standards we want to select the active option on blur.
|
|
45
|
-
* We do this by selecting the MatAutoCompleteTrigger, which triggers the select event
|
|
46
|
-
* @param event blur event that triggers the handle blur, TODO: remove this parameter if not used by 7/4/19
|
|
47
|
-
*/
|
|
48
|
-
handleTab(_event) {
|
|
49
|
-
if (this.autoInput.activeOption) {
|
|
50
|
-
this.autoInput.activeOption.select();
|
|
51
|
-
this.control.setValue(this.autoInput.activeOption.value);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
44
|
}
|
|
55
45
|
AutocompleteFieldComponent.decorators = [
|
|
56
46
|
{ type: Component, args: [{
|
|
57
47
|
selector: 'crispr-autocomplete-field',
|
|
58
|
-
template: "\n<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n\n <mat-form-field\n [color]=\"config.color\"\n [appearance]=\"config.appearance\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n <input\n matInput\n [formControl]=\"autocompleteInputControl\"\n [placeholder]=\"config.placeholder\"\n [matAutocomplete]=\"auto\"\n
|
|
48
|
+
template: "\n<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n\n <mat-form-field\n [color]=\"config.color\"\n [appearance]=\"config.appearance\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n <input\n matInput\n [formControl]=\"autocompleteInputControl\"\n [placeholder]=\"config.placeholder\"\n [matAutocomplete]=\"auto\"\n role=\"textbox\"\n type=\"textbox\"\n autocapitalize=\"off\"\n autocorrect=\"off\"\n spellcheck=\"false\"\n #autoInput>\n\n <span *ngIf=\"config.fieldSuffix\" matSuffix>{{config.fieldSuffix}}</span>\n <crispr-info\n *ngIf=\"config.info\"\n matSuffix\n [info]=\"config.info \">\n </crispr-info>\n\n <mat-autocomplete\n #auto=\"matAutocomplete\"\n [autoActiveFirstOption]=\"config.autoActiveFirstOption\"\n (optionSelected)=\"handleSelect($event)\"\n [displayWith]=\"displayLabel(options$ | async)\">\n\n <ng-container *ngIf=\"options$ | async as options; else emptyOption\">\n <ng-container *ngIf=\"options.length > 0; else emptyOption\">\n <mat-option\n *ngFor=\"let option of options$ | async\"\n [value]=\"option.value\">\n <crispr-option [option]=\"option\"></crispr-option>\n </mat-option>\n </ng-container>\n\n </ng-container>\n <ng-template #emptyOption>\n <mat-option disabled=\"true\">\n {{config.emptyOptionsMessage}}\n </mat-option>\n </ng-template>\n\n </mat-autocomplete>\n </mat-form-field>\n</crispr-field-container>\n",
|
|
59
49
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
60
50
|
styles: [""]
|
|
61
51
|
},] }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete-field.component.js","sourceRoot":"","sources":["../../../../../../../libs/crispr-forms/src/lib/material/autocomplete-field/autocomplete-field.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAU,SAAS,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAClG,OAAO,EAAE,sBAAsB,EAAgC,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"autocomplete-field.component.js","sourceRoot":"","sources":["../../../../../../../libs/crispr-forms/src/lib/material/autocomplete-field/autocomplete-field.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAU,SAAS,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAClG,OAAO,EAAE,sBAAsB,EAAgC,MAAM,gCAAgC,CAAC;AAEtG,OAAO,EAAyC,6BAA6B,EAAE,MAAM,cAAc,CAAC;AACpG,OAAO,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAEhE,MAAM,aAAa,GAAqC;IACtD,qBAAqB,EAAE,IAAI;IAC3B,gBAAgB,EAAE,GAAG;IACrB,mBAAmB,EAAE,6BAA6B;CACnD,CAAC;AAQF,MAAM,OAAO,0BACX,SAAQ,6BAAsD;IAPhE;;QAUE,kBAAa,GAAG,aAAa,CAAC;IAmChC,CAAC;IA/BC,QAAQ;QACN,KAAK,CAAC,QAAQ,EAAE,CAAC;IACnB,CAAC;IAED,eAAe,CAAC,KAAmB;QACjC,IAAG,IAAI,CAAC,OAAO,IAAI,KAAK,EAAE;YACxB,yDAAyD;YACzD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;YACzC,IAAI,CAAC,wBAAwB,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;SAC3D;IACH,CAAC;IAED;;;;;;OAMG;IACH,YAAY,CAAC,OAAuB;QAClC,OAAO,CAAC,KAAU,EAAE,EAAE;;YACpB,OAAO,CAAC,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;gBACxC,CAAC,CAAC,MAAA,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,KAAK,CAAC,0CAAE,KAAK;gBACvD,CAAC,CAAC,KAAK,CAAC;QACZ,CAAC,CAAC;IACJ,CAAC;IAED,YAAY,CAAC,KAAmC;QAC9C,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACzC,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IACzC,CAAC;;;YA5CF,SAAS,SAAC;gBACT,QAAQ,EAAE,2BAA2B;gBACrC,omDAAkD;gBAElD,eAAe,EAAE,uBAAuB,CAAC,MAAM;;aAChD;;;wBAME,SAAS,SAAC,WAAW,EAAE,EAAE,IAAI,EAAE,sBAAsB,EAAE;2BACvD,SAAS,SAAC,WAAW","sourcesContent":["import { Component, OnInit, ViewChild, ChangeDetectionStrategy, ElementRef } from '@angular/core';\nimport { MatAutocompleteTrigger, MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';\n\nimport { SelectOption, AutocompleteFieldConfig, DEFAULT_EMPTY_OPTIONS_MESSAGE } from '../../models';\nimport { AbstractAutocompleteComponent } from '../../abstracts';\n\nconst defaultConfig: Partial<AutocompleteFieldConfig> = {\n autoActiveFirstOption: true,\n typeDebounceTime: 500,\n emptyOptionsMessage: DEFAULT_EMPTY_OPTIONS_MESSAGE\n};\n\n@Component({\n selector: 'crispr-autocomplete-field',\n templateUrl: './autocomplete-field.component.html',\n styleUrls: ['./autocomplete-field.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class AutocompleteFieldComponent\n extends AbstractAutocompleteComponent<AutocompleteFieldConfig>\n implements OnInit {\n\n defaultConfig = defaultConfig;\n @ViewChild('autoInput', { read: MatAutocompleteTrigger }) autoInput: MatAutocompleteTrigger;\n @ViewChild('autoInput') autoInputRef: ElementRef<HTMLInputElement>;\n\n ngOnInit() {\n super.ngOnInit();\n }\n\n setControlValue(value: SelectOption) {\n if(this.control && value) {\n // sets the initial value on the control if one is passed\n this.control.setValue(value.value || '');\n this.autocompleteInputControl.setValue(value.label || '');\n }\n }\n\n /**\n * The material autocomplete defaults to displaying the options value instead of its label.\n * We only have the value from the selected option to work with, so we have to pass the options\n * through a function called in the template and return the function that the material displayWith\n * input is expecting.\n * @param options the array of options to search for option with corresponding value\n */\n displayLabel(options: SelectOption[]) {\n return (value: any) => {\n return !!options && Array.isArray(options)\n ? options.find(option => option.value === value)?.label\n : value;\n };\n }\n\n handleSelect(event: MatAutocompleteSelectedEvent) {\n this.control.setValue(event.option.value)\n this.autoInputRef.nativeElement.blur();\n }\n}\n\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"AutocompleteFieldComponent":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../../abstracts","name":"AbstractAutocompleteComponent","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"AutocompleteFieldComponent":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../../abstracts","name":"AbstractAutocompleteComponent","line":19,"character":10},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":12,"character":1},"arguments":[{"selector":"crispr-autocomplete-field","changeDetection":{"__symbolic":"select","expression":{"__symbolic":"reference","module":"@angular/core","name":"ChangeDetectionStrategy","line":16,"character":19},"member":"OnPush"},"template":"\n<crispr-field-container\n [config]=\"config\"\n [group]=\"group\">\n\n <mat-form-field\n [color]=\"config.color\"\n [appearance]=\"config.appearance\">\n <mat-label *ngIf=\"config.label\">\n {{config.label}}\n </mat-label>\n <input\n matInput\n [formControl]=\"autocompleteInputControl\"\n [placeholder]=\"config.placeholder\"\n [matAutocomplete]=\"auto\"\n role=\"textbox\"\n type=\"textbox\"\n autocapitalize=\"off\"\n autocorrect=\"off\"\n spellcheck=\"false\"\n #autoInput>\n\n <span *ngIf=\"config.fieldSuffix\" matSuffix>{{config.fieldSuffix}}</span>\n <crispr-info\n *ngIf=\"config.info\"\n matSuffix\n [info]=\"config.info \">\n </crispr-info>\n\n <mat-autocomplete\n #auto=\"matAutocomplete\"\n [autoActiveFirstOption]=\"config.autoActiveFirstOption\"\n (optionSelected)=\"handleSelect($event)\"\n [displayWith]=\"displayLabel(options$ | async)\">\n\n <ng-container *ngIf=\"options$ | async as options; else emptyOption\">\n <ng-container *ngIf=\"options.length > 0; else emptyOption\">\n <mat-option\n *ngFor=\"let option of options$ | async\"\n [value]=\"option.value\">\n <crispr-option [option]=\"option\"></crispr-option>\n </mat-option>\n </ng-container>\n\n </ng-container>\n <ng-template #emptyOption>\n <mat-option disabled=\"true\">\n {{config.emptyOptionsMessage}}\n </mat-option>\n </ng-template>\n\n </mat-autocomplete>\n </mat-form-field>\n</crispr-field-container>\n","styles":[""]}]}],"members":{"autoInput":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild","line":23,"character":3},"arguments":["autoInput",{"read":{"__symbolic":"reference","module":"@angular/material/autocomplete","name":"MatAutocompleteTrigger","line":23,"character":34}}]}]}],"autoInputRef":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild","line":24,"character":3},"arguments":["autoInput"]}]}],"ngOnInit":[{"__symbolic":"method"}],"setControlValue":[{"__symbolic":"method"}],"displayLabel":[{"__symbolic":"method"}],"handleSelect":[{"__symbolic":"method"}]}}}}]
|