mis-crystal-design-system 3.1.18 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/mis-crystal-design-system-dynamic-form.umd.js +191 -53
- package/bundles/mis-crystal-design-system-dynamic-form.umd.js.map +1 -1
- package/bundles/mis-crystal-design-system-dynamic-form.umd.min.js +2 -2
- package/bundles/mis-crystal-design-system-dynamic-form.umd.min.js.map +1 -1
- package/bundles/mis-crystal-design-system-switch.umd.js +7 -7
- package/bundles/mis-crystal-design-system-switch.umd.js.map +1 -1
- package/bundles/mis-crystal-design-system-switch.umd.min.js +1 -1
- package/bundles/mis-crystal-design-system-switch.umd.min.js.map +1 -1
- package/dynamic-form/dynamic-form.component.d.ts +34 -12
- package/dynamic-form/dynamic-form.namespace.d.ts +15 -3
- package/dynamic-form/mis-crystal-design-system-dynamic-form.metadata.json +1 -1
- package/esm2015/dynamic-form/dynamic-form.component.js +165 -37
- package/esm2015/dynamic-form/dynamic-form.namespace.js +1 -1
- package/esm2015/switch/switch.component.js +8 -8
- package/fesm2015/mis-crystal-design-system-dynamic-form.js +164 -36
- package/fesm2015/mis-crystal-design-system-dynamic-form.js.map +1 -1
- package/fesm2015/mis-crystal-design-system-switch.js +7 -7
- package/fesm2015/mis-crystal-design-system-switch.js.map +1 -1
- package/package.json +1 -1
- package/switch/mis-crystal-design-system-switch.metadata.json +1 -1
- package/switch/switch.component.d.ts +1 -1
|
@@ -346,7 +346,6 @@
|
|
|
346
346
|
|
|
347
347
|
var DynamicFormComponent = /** @class */ (function () {
|
|
348
348
|
function DynamicFormComponent() {
|
|
349
|
-
var _this = this;
|
|
350
349
|
/**
|
|
351
350
|
* formFields: Dynamic fields recieved from the API metadata to build a dynamic form
|
|
352
351
|
* formValues: Holds the value of the dynamic form with "key" being dynamic field "title"
|
|
@@ -354,70 +353,121 @@
|
|
|
354
353
|
*/
|
|
355
354
|
this.formFields = [];
|
|
356
355
|
this.formValues = {};
|
|
356
|
+
// Need to deprecate these inputs and use constants.
|
|
357
357
|
this.activeBtnIconUrl = "";
|
|
358
358
|
this.calendarIconUrl = "";
|
|
359
359
|
/**
|
|
360
360
|
* formUpdated: Emits formValues Object whenever there is a change in the dynamic form.
|
|
361
361
|
*/
|
|
362
362
|
this.formUpdated = new core.EventEmitter();
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
formArray.push(control);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
375
|
-
finally {
|
|
376
|
-
try {
|
|
377
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
378
|
-
}
|
|
379
|
-
finally { if (e_1) throw e_1.error; }
|
|
380
|
-
}
|
|
381
|
-
_this.dynamicForm = new forms.FormGroup({
|
|
382
|
-
dynamicFields: formArray
|
|
383
|
-
});
|
|
384
|
-
};
|
|
363
|
+
/**
|
|
364
|
+
* formValid: Emits boolean depending on validity of the form
|
|
365
|
+
*/
|
|
366
|
+
this.formValid = new core.EventEmitter();
|
|
367
|
+
/**
|
|
368
|
+
* formInitialized: Emits dynamic form API on form initilization
|
|
369
|
+
*/
|
|
370
|
+
this.formInitialized = new core.EventEmitter();
|
|
385
371
|
}
|
|
386
372
|
DynamicFormComponent.prototype.ngOnInit = function () {
|
|
387
373
|
var _this = this;
|
|
388
374
|
// Building the form
|
|
389
|
-
this.
|
|
375
|
+
this.dynamicForm = this.generateDynamicForm(this.formFields, this.formValues);
|
|
390
376
|
// Subscribing to form changes and emiting values.
|
|
391
|
-
this.dynamicForm.valueChanges.subscribe(function (formValue) {
|
|
392
|
-
|
|
393
|
-
_this.formUpdated.emit(formValues);
|
|
377
|
+
this.valueChangesSubscription$ = this.dynamicForm.valueChanges.subscribe(function (formValue) {
|
|
378
|
+
_this.onFormValueChanges();
|
|
394
379
|
});
|
|
395
380
|
//api to expose functions
|
|
396
|
-
this.
|
|
381
|
+
this.dynamicFormAPI = {
|
|
397
382
|
defaultFormValues: function () {
|
|
398
383
|
return _this.generateDynamicFieldsValueObject(_this.dynamicForm.value.dynamicFields);
|
|
399
384
|
}
|
|
400
385
|
};
|
|
401
|
-
this.
|
|
386
|
+
this.formInitialized.emit(this.dynamicFormAPI);
|
|
387
|
+
};
|
|
388
|
+
DynamicFormComponent.prototype.ngOnDestroy = function () {
|
|
389
|
+
var _a;
|
|
390
|
+
(_a = this.valueChangesSubscription$) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
391
|
+
};
|
|
392
|
+
DynamicFormComponent.prototype.onFormValueChanges = function () {
|
|
393
|
+
var formValues = this.generateDynamicFieldsValueObject(this.dynamicForm.value.dynamicFields);
|
|
394
|
+
this.formValid.emit(this.dynamicForm.valid);
|
|
395
|
+
this.formUpdated.emit(formValues);
|
|
396
|
+
console.log(formValues);
|
|
402
397
|
};
|
|
403
398
|
DynamicFormComponent.prototype.generateDynamicFieldsValueObject = function (formValues) {
|
|
404
399
|
var _this = this;
|
|
405
400
|
var dynamicFieldsValue = {};
|
|
406
|
-
formValues.forEach(function (
|
|
407
|
-
|
|
401
|
+
formValues.forEach(function (fieldValue, index) {
|
|
402
|
+
var _a;
|
|
403
|
+
var formattedValue = _this.mapFormFieldToFormValue(_this.formFields[index], fieldValue.value);
|
|
404
|
+
if (((_a = fieldValue.subFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
405
|
+
var formattedSubFieldsValues_1 = {};
|
|
406
|
+
fieldValue.subFields.forEach(function (subFieldValue, subIndex) {
|
|
407
|
+
var subFormField = _this.formFields[index].subFields[subIndex];
|
|
408
|
+
formattedSubFieldsValues_1[subFormField.configName] = _this.mapFormFieldToFormValue(subFormField, subFieldValue);
|
|
409
|
+
});
|
|
410
|
+
dynamicFieldsValue[_this.formFields[index].configName] = {
|
|
411
|
+
value: formattedValue,
|
|
412
|
+
subFields: formattedSubFieldsValues_1
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
dynamicFieldsValue[_this.formFields[index].configName] = formattedValue;
|
|
417
|
+
}
|
|
408
418
|
});
|
|
409
419
|
return dynamicFieldsValue;
|
|
410
420
|
};
|
|
421
|
+
DynamicFormComponent.prototype.generateDynamicForm = function (formFields, formValues) {
|
|
422
|
+
var e_1, _b;
|
|
423
|
+
var _a;
|
|
424
|
+
var formArray = new forms.FormArray([]);
|
|
425
|
+
try {
|
|
426
|
+
for (var formFields_1 = __values(formFields), formFields_1_1 = formFields_1.next(); !formFields_1_1.done; formFields_1_1 = formFields_1.next()) {
|
|
427
|
+
var field = formFields_1_1.value;
|
|
428
|
+
var fieldValue = ((_a = formValues[field.configName]) === null || _a === void 0 ? void 0 : _a.value) ? formValues[field.configName].value : formValues[field.configName];
|
|
429
|
+
var fieldControl = this.mapFormValueToFormField(field, fieldValue);
|
|
430
|
+
var subFieldsControls = this.generateSubDynamicFields(formValues, field, fieldValue);
|
|
431
|
+
formArray.push(new forms.FormGroup({
|
|
432
|
+
value: fieldControl,
|
|
433
|
+
subFields: subFieldsControls
|
|
434
|
+
}));
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
438
|
+
finally {
|
|
439
|
+
try {
|
|
440
|
+
if (formFields_1_1 && !formFields_1_1.done && (_b = formFields_1.return)) _b.call(formFields_1);
|
|
441
|
+
}
|
|
442
|
+
finally { if (e_1) throw e_1.error; }
|
|
443
|
+
}
|
|
444
|
+
return new forms.FormGroup({
|
|
445
|
+
dynamicFields: formArray
|
|
446
|
+
});
|
|
447
|
+
};
|
|
411
448
|
DynamicFormComponent.prototype.getDynamicFieldsControls = function () {
|
|
412
449
|
return this.dynamicForm.get("dynamicFields");
|
|
413
450
|
};
|
|
414
|
-
DynamicFormComponent.prototype.
|
|
415
|
-
var
|
|
416
|
-
|
|
451
|
+
DynamicFormComponent.prototype.updateSubDynamicFields = function (field, formGroup, value) {
|
|
452
|
+
var _a;
|
|
453
|
+
if (((_a = field.subFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
454
|
+
var subFieldsControls = this.generateSubDynamicFields(this.formValues, field, value);
|
|
455
|
+
formGroup.removeControl('subFields');
|
|
456
|
+
formGroup.addControl('subFields', subFieldsControls);
|
|
457
|
+
}
|
|
417
458
|
};
|
|
418
|
-
DynamicFormComponent.prototype.
|
|
419
|
-
var
|
|
420
|
-
|
|
459
|
+
DynamicFormComponent.prototype.updateSelectedValueForSingleSelect = function (field, control, formGroup, value) {
|
|
460
|
+
var _a;
|
|
461
|
+
if (((_a = control.value) === null || _a === void 0 ? void 0 : _a.value) !== value.value) {
|
|
462
|
+
control.setValue(value);
|
|
463
|
+
}
|
|
464
|
+
else
|
|
465
|
+
control.setValue('');
|
|
466
|
+
this.updateSubDynamicFields(field, formGroup, value);
|
|
467
|
+
control.markAsTouched();
|
|
468
|
+
};
|
|
469
|
+
DynamicFormComponent.prototype.updateSelectedValueForMultiSelect = function (field, control, formGroup, values) {
|
|
470
|
+
var e_2, _b;
|
|
421
471
|
var selectedValues = control.value;
|
|
422
472
|
var _loop_1 = function (value) {
|
|
423
473
|
var itemIndex = selectedValues.findIndex(function (item) { return item.label === value.label; });
|
|
@@ -437,18 +487,51 @@
|
|
|
437
487
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
438
488
|
finally {
|
|
439
489
|
try {
|
|
440
|
-
if (values_1_1 && !values_1_1.done && (
|
|
490
|
+
if (values_1_1 && !values_1_1.done && (_b = values_1.return)) _b.call(values_1);
|
|
441
491
|
}
|
|
442
492
|
finally { if (e_2) throw e_2.error; }
|
|
443
493
|
}
|
|
444
494
|
control.setValue(selectedValues);
|
|
495
|
+
this.updateSubDynamicFields(field, formGroup, values);
|
|
496
|
+
control.markAsTouched();
|
|
445
497
|
};
|
|
446
498
|
DynamicFormComponent.prototype.isCheckBoxSelected = function (value, selectedValues) {
|
|
447
499
|
return selectedValues.findIndex(function (item) { return item.label === value; }) > -1;
|
|
448
500
|
};
|
|
501
|
+
DynamicFormComponent.prototype.generateSubDynamicFields = function (formValues, parentField, parentValue) {
|
|
502
|
+
var e_3, _b;
|
|
503
|
+
var _a;
|
|
504
|
+
var controls = new forms.FormArray([]);
|
|
505
|
+
var subFields = parentField.subFields;
|
|
506
|
+
var subFieldsValues = ((_a = formValues[parentField.configName]) === null || _a === void 0 ? void 0 : _a.subFields) ? formValues[parentField.configName].subFields : {};
|
|
507
|
+
if (parentField.fieldType === 'singleSelect') {
|
|
508
|
+
subFields = subFields.filter(function (subField) { var _a; return subField.parentConfigValue === ((_a = parentValue) === null || _a === void 0 ? void 0 : _a.value); });
|
|
509
|
+
}
|
|
510
|
+
else if (parentField.fieldType === 'multiSelect') {
|
|
511
|
+
var parentValues_1 = new Set(parentValue.map(function (value) { return value.value; }));
|
|
512
|
+
subFields = subFields.filter(function (subField) { return parentValues_1.has(subField.parentConfigValue); });
|
|
513
|
+
}
|
|
514
|
+
if ((subFields === null || subFields === void 0 ? void 0 : subFields.length) > 0) {
|
|
515
|
+
try {
|
|
516
|
+
for (var subFields_1 = __values(subFields), subFields_1_1 = subFields_1.next(); !subFields_1_1.done; subFields_1_1 = subFields_1.next()) {
|
|
517
|
+
var subField = subFields_1_1.value;
|
|
518
|
+
controls.push(this.mapFormValueToFormField(subField, subFieldsValues[subField.configName]));
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
522
|
+
finally {
|
|
523
|
+
try {
|
|
524
|
+
if (subFields_1_1 && !subFields_1_1.done && (_b = subFields_1.return)) _b.call(subFields_1);
|
|
525
|
+
}
|
|
526
|
+
finally { if (e_3) throw e_3.error; }
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
return controls;
|
|
530
|
+
};
|
|
449
531
|
DynamicFormComponent.prototype.mapFormValueToFormField = function (formField, formValue) {
|
|
450
|
-
var
|
|
451
|
-
var
|
|
532
|
+
var e_4, _b;
|
|
533
|
+
var validators = formField.validators ? [dynamicFieldValidator(formField.validators)] : [];
|
|
534
|
+
var control = new forms.FormControl(null, validators);
|
|
452
535
|
if (formField.fieldType === "input") {
|
|
453
536
|
if (formField.fieldInputType === "text" || formField.fieldInputType === "textarea")
|
|
454
537
|
control.setValue(formValue ? formValue : "");
|
|
@@ -464,14 +547,18 @@
|
|
|
464
547
|
}
|
|
465
548
|
}
|
|
466
549
|
else if (formField.fieldType === "singleSelect") {
|
|
550
|
+
var findSelectedValue = function () {
|
|
551
|
+
var index = formField.itemsList.findIndex(function (item) { return item.value === formValue; });
|
|
552
|
+
return index > 0 ? formField.itemsList[index] : "";
|
|
553
|
+
};
|
|
467
554
|
if (formField.fieldInputType === "dropdown") {
|
|
468
555
|
if (!formValue)
|
|
469
556
|
control.setValue(formField.itemsList[0]);
|
|
470
|
-
else
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
557
|
+
else
|
|
558
|
+
control.setValue(findSelectedValue());
|
|
559
|
+
}
|
|
560
|
+
else if (formField.fieldInputType === "radio") {
|
|
561
|
+
control.setValue(findSelectedValue());
|
|
475
562
|
}
|
|
476
563
|
}
|
|
477
564
|
else if (formField.fieldType === "multiSelect") {
|
|
@@ -488,12 +575,12 @@
|
|
|
488
575
|
_loop_2(value);
|
|
489
576
|
}
|
|
490
577
|
}
|
|
491
|
-
catch (
|
|
578
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
492
579
|
finally {
|
|
493
580
|
try {
|
|
494
|
-
if (formValue_1_1 && !formValue_1_1.done && (
|
|
581
|
+
if (formValue_1_1 && !formValue_1_1.done && (_b = formValue_1.return)) _b.call(formValue_1);
|
|
495
582
|
}
|
|
496
|
-
finally { if (
|
|
583
|
+
finally { if (e_4) throw e_4.error; }
|
|
497
584
|
}
|
|
498
585
|
control.setValue(selectedValues);
|
|
499
586
|
}
|
|
@@ -509,6 +596,7 @@
|
|
|
509
596
|
return control;
|
|
510
597
|
};
|
|
511
598
|
DynamicFormComponent.prototype.mapFormFieldToFormValue = function (formField, formValue) {
|
|
599
|
+
var _a;
|
|
512
600
|
if (formField.fieldType === "input") {
|
|
513
601
|
if (formField.fieldInputType === "text" || formField.fieldInputType === "textarea")
|
|
514
602
|
return formValue;
|
|
@@ -519,8 +607,7 @@
|
|
|
519
607
|
}
|
|
520
608
|
}
|
|
521
609
|
else if (formField.fieldType === "singleSelect") {
|
|
522
|
-
|
|
523
|
-
return formValue === null || formValue === void 0 ? void 0 : formValue.value;
|
|
610
|
+
return (_a = formValue === null || formValue === void 0 ? void 0 : formValue.value) !== null && _a !== void 0 ? _a : '';
|
|
524
611
|
}
|
|
525
612
|
else if (formField.fieldType === "multiSelect") {
|
|
526
613
|
return formValue === null || formValue === void 0 ? void 0 : formValue.map(function (item) { return item.value; });
|
|
@@ -536,8 +623,8 @@
|
|
|
536
623
|
DynamicFormComponent.decorators = [
|
|
537
624
|
{ type: core.Component, args: [{
|
|
538
625
|
selector: "mis-dynamic-form",
|
|
539
|
-
template: "<form [formGroup]=\"dynamicForm\">\n <ng-container formArrayName=\"dynamicFields\">\n <ng-container *ngFor=\"let fieldControl of getDynamicFieldsControls().controls; let i = index\">\n <div\n class=\"dynamic-field multi-line-field-container\"\n
|
|
540
|
-
styles: ["p{margin:0}::ng-deep .main-container{margin:0;max-width:100%}.dynamic-field ::ng-deep .container{height:32px!important}.single-line-field-container{justify-content:space-between;align-items:center}.multi-line-field-container,.single-line-field-container{display:flex;padding:28px 16px;border-bottom:1px solid var(--grey-seperators)}.multi-line-field-container{justify-content:flex-start;align-items:flex-start;flex-wrap:wrap}.field-title-sm{margin-bottom:8px}.input-field{width:100%;background-color:var(--grey-bg-1);border:1px solid var(--grey-seperators);border-radius:6px}.ip-text{height:44px;padding:8px 12px}.ip-textarea{max-height:94px;padding:8px}input:focus{outline:none}input::-moz-placeholder{color:var(--grey-seperators)}input:-ms-input-placeholder{color:var(--grey-seperators)}input::placeholder{color:var(--grey-seperators)}textarea:focus{outline:none}.date-picker-container{position:relative;width:140px}.date-picker-container .date-picker{cursor:pointer;height:32px;width:100%;font-size:14px;border-radius:6px;padding:0 12px;border:1px solid var(--grey-seperators);inset:10px auto auto 80px;background-color:var(--text-white)}.date-picker-container .date-picker:hover{background-color:var(--grey-hover)}.date-picker-container .date-picker-icon{position:absolute;top:50%;right:12px;transform:translateY(-50%);cursor:pointer}form .dynamic-field:last-child{border-bottom:none!important}#checkboxes-container{display:flex;justify-content:flex-start;align-items:center;flex-wrap:wrap}.radio-checkbox-common{display:flex;justify-content:center;align-items:center;cursor:pointer;margin-right:8px;margin-bottom:8px;background-color:var(--text-white);padding:12px 16px;border:1px solid var(--text-muted);border-radius:8px}.radio-checkbox-common p{color:var(--text-muted)}.radio-checkbox-common img{margin-right:8px}.checkbox-active{background-color:var(--pmry-500)}.checkbox-active p{color:var(--text-white)}"]
|
|
626
|
+
template: "<form [formGroup]=\"dynamicForm\">\n <ng-container formArrayName=\"dynamicFields\">\n <ng-container [formGroupName]=\"i\" *ngFor=\"let fieldControl of getDynamicFieldsControls().controls; let i = index\">\n <ng-container\n [ngTemplateOutlet]=\"dynamicField\"\n [ngTemplateOutletContext]=\"{\n $implicit: formFields[i],\n formGroup: fieldControl,\n control: fieldControl.controls.value\n }\"\n >\n <div class=\"sub-dynamic-form\" *ngIf=\"fieldControl.value && formFields[i]?.subFields?.length > 0\">\n <ng-container *ngFor=\"let subFieldControl of fieldControl.controls.subFields.controls; let j = index\">\n <ng-container\n [ngTemplateOutlet]=\"dynamicField\"\n [ngTemplateOutletContext]=\"{\n $implicit: formFields[i].subFields[j],\n control: subFieldControl\n }\">\n </ng-container>\n </ng-container>\n </div>\n </ng-container>\n </ng-container>\n </ng-container>\n</form>\n\n\n<ng-template #dynamicField let-field let-control=\"control\" let-formgroup=\"formGroup\">\n\n <!-- fieldType: 'input' fieldInputType: 'text' | 'number' -->\n <div class=\"dynamic-field multi-line-field-container\"\n *ngIf=\"field.fieldType === 'input' && (field.fieldInputType === 'text' || field.fieldInputType === 'number')\">\n <p class=\"h7 field-title-sm\">\n {{ field.title }}\n </p>\n <div style=\"flex-basis: 100%\"></div>\n <input class=\"input-field ip-text\" [type]=\"field.fieldInputType\" [formControl]=\"control\"\n (ngModelChange)=\"updateSubDynamicFields(field, formgroup, $event)\"\n [ngStyle]=\"{'border': control.touched && control.errors ? '1px solid #B00020': ''}\"\n [placeholder]=\"field.placeholderText ? field.placeholderText : 'Input Text'\" />\n <ng-container *ngIf=\"control.touched && control.errors\"\n [ngTemplateOutlet]=\"dynamicFieldErrors\" \n [ngTemplateOutletContext]=\"{ $implicit: control.errors }\"\n >\n </ng-container>\n </div>\n\n <!-- fieldType: 'input' fieldInputType: 'textarea' -->\n <div class=\"dynamic-field multi-line-field-container\"\n *ngIf=\"field.fieldType === 'input' && field.fieldInputType === 'textarea'\">\n <p class=\"h7 field-title-sm\">\n {{ field.title }}\n </p>\n <div style=\"flex-basis: 100%\"></div>\n <textarea class=\"input-field ip-textarea\" type=\"text\"\n [ngStyle]=\"{'border': control.touched && control.errors ? '1px solid #B00020': ''}\"\n [placeholder]=\"field.placeholderText ? field.placeholderText : 'Input Text'\" [formControl]=\"control\" (ngModelChange)=\"updateSubDynamicFields(field, formgroup, $event)\"></textarea>\n <ng-container *ngIf=\"control.touched && control.errors\" [ngTemplateOutlet]=\"dynamicFieldErrors\"\n [ngTemplateOutletContext]=\"{ $implicit: control.errors }\">\n </ng-container>\n </div>\n\n <!-- fieldType: 'input' fieldInputType: 'date' -->\n <div class=\"dynamic-field single-line-field-container\"\n *ngIf=\"field.fieldType === 'input' && field.fieldInputType === 'date'\">\n <p class=\"h6\">\n {{ field.title }}\n </p>\n <div class=\"date-picker-container\">\n <input class=\"date-picker\" readonly misTzDp [dpConfig]=\"field.fieldConfig\"\n (dateChange)=\"control.setValue($event)\" [selectedDate]=\"control.value\" [offsetY]=\"0\"\n [value]=\"control.value\" #dp />\n <img alt=\"data-picker\" *ngIf=\"calendarIconUrl\" class=\"date-picker-icon\" [src]=\"calendarIconUrl\"\n (click)=\"dp.click()\" />\n </div>\n <ng-container *ngIf=\"control.touched && control.errors\" [ngTemplateOutlet]=\"dynamicFieldErrors\"\n [ngTemplateOutletContext]=\"{ $implicit: control.errors }\">\n </ng-container>\n </div>\n\n <!-- fieldType: 'boolean' fieldInputType: 'toggle' -->\n <div class=\"dynamic-field single-line-field-container\"\n *ngIf=\"field.fieldType === 'boolean' && field.fieldInputType === 'toggle'\">\n <p class=\"h6\">\n {{ field.title }}\n </p>\n <mis-switch [control]=\"control\" (valueChanged)=\"updateSubDynamicFields(field, formgroup, $event)\"></mis-switch>\n <ng-container *ngIf=\"control.touched && control.errors\" [ngTemplateOutlet]=\"dynamicFieldErrors\"\n [ngTemplateOutletContext]=\"{ $implicit: control.errors }\">\n </ng-container>\n </div>\n\n <!-- fieldType: 'singleSelect' fieldInputType: 'dropdown' -->\n <div class=\"dynamic-field single-line-field-container\"\n *ngIf=\"field.fieldType === 'singleSelect' && field.fieldInputType === 'dropdown'\">\n <p class=\"h6\">\n {{ field.title }}\n </p>\n <mis-dropdown [searchEnabled]=\"false\" [width]=\"'140px'\" [data]=\"field.itemsList\" [selectedItem]=\"control.value\"\n (onChange)=\"updateSelectedValueForSingleSelect(field, control, formgroup, $event);\">\n </mis-dropdown>\n <ng-container *ngIf=\"control.touched && control.errors\" [ngTemplateOutlet]=\"dynamicFieldErrors\"\n [ngTemplateOutletContext]=\"{ $implicit: control.errors }\">\n </ng-container>\n </div>\n\n <!-- fieldType: 'singleSelect' fieldInputType: 'radio' -->\n <div class=\"dynamic-field multi-line-field-container\"\n *ngIf=\"field.fieldType === 'singleSelect' && field.fieldInputType === 'radio'\">\n <p class=\"h7 field-title-sm\">\n {{ field.title }}\n </p>\n <div style=\"flex-basis: 100%\"></div>\n <div id=\"checkboxes-container\">\n <div class=\"radio-checkbox-common\" *ngFor=\"let item of field.itemsList\"\n [ngClass]=\"{ 'checkbox-active': item.label === control.value?.label }\"\n (click)=\"updateSelectedValueForSingleSelect(field, control, formgroup, item);\">\n <img *ngIf=\"(item.label === control.value?.label) && activeBtnIconUrl\" [src]=\"activeBtnIconUrl\" alt=\"\" />\n <p class=\"h6\">{{ item.label }}</p>\n </div>\n </div>\n <ng-container *ngIf=\"control.touched && control.errors\" [ngTemplateOutlet]=\"dynamicFieldErrors\"\n [ngTemplateOutletContext]=\"{ $implicit: control.errors }\">\n </ng-container>\n </div>\n\n <!-- fieldType: 'multiSelect' fieldInputType: 'checkbox' -->\n <div class=\"dynamic-field multi-line-field-container\"\n *ngIf=\"field.fieldType === 'multiSelect' && field.fieldInputType === 'checkbox'\">\n <p class=\"h7 field-title-sm\">\n {{ field.title }}\n </p>\n <div style=\"flex-basis: 100%\"></div>\n <div id=\"checkboxes-container\">\n <div class=\"radio-checkbox-common\" *ngFor=\"let item of field.itemsList\"\n [ngClass]=\"{ 'checkbox-active': isCheckBoxSelected(item.label, control.value) }\"\n (click)=\"updateSelectedValueForMultiSelect(field, control, formgroup, [item])\">\n <img *ngIf=\"isCheckBoxSelected(item.label, control.value) && activeBtnIconUrl\" [src]=\"activeBtnIconUrl\"\n alt=\"\" />\n <p class=\"h6\">{{ item.label }}</p>\n </div>\n </div>\n <ng-container *ngIf=\"control.touched && control.errors\" [ngTemplateOutlet]=\"dynamicFieldErrors\"\n [ngTemplateOutletContext]=\"{ $implicit: control.errors }\">\n </ng-container>\n </div>\n\n <!-- fieldType: 'multiSelect' fieldInputType: 'dropdown' -->\n <div class=\"dynamic-field single-line-field-container\"\n *ngIf=\"field.fieldType === 'multiSelect' && field.fieldInputType === 'dropdown'\">\n <p class=\"h6\">\n {{ field.title }}\n </p>\n <mis-multi-select-dropdown [width]=\"'140px'\" [showSelectedCount]=\"true\" [dropdownListWidth]=\"'256px'\"\n [searchEnabled]=\"false\" [hideApplyButton]=\"true\" [data]=\"field.itemsList\"\n [selectedItems]=\"control.value\" (onChange)=\"updateSelectedValueForMultiSelect(field, control, formgroup, $event);\"></mis-multi-select-dropdown>\n <ng-container *ngIf=\"control.touched && control.errors\" [ngTemplateOutlet]=\"dynamicFieldErrors\"\n [ngTemplateOutletContext]=\"{ $implicit: control.errors }\">\n </ng-container>\n </div>\n\n</ng-template>\n\n<ng-template #dynamicFieldErrors let-errors>\n <div id=\"error-messages-container\">\n <ng-container *ngFor=\"let error of errors | keyvalue\">\n <p class=\"h8\">\n {{\" \u2022 \" + error.value}}\n </p>\n <div style=\"flex-basis: 100%; height: 0\"></div>\n </ng-container>\n </div>\n</ng-template>",
|
|
627
|
+
styles: ["p{margin:0;cursor:default}::ng-deep .main-container{margin:0;max-width:100%}.sub-dynamic-form{padding-left:24px}.dynamic-field ::ng-deep .container{height:32px!important}.single-line-field-container{justify-content:space-between;align-items:center}.multi-line-field-container,.single-line-field-container{display:flex;padding:28px 16px;border-bottom:1px solid var(--grey-seperators)}.multi-line-field-container{justify-content:flex-start;align-items:flex-start;flex-wrap:wrap}.field-title-sm{margin-bottom:8px;cursor:default}.input-field{width:100%;background-color:var(--grey-bg-1);border:1px solid var(--grey-seperators);border-radius:6px}.ip-text{height:44px;padding:8px 12px}.ip-textarea{max-height:94px;padding:8px}input:focus{outline:none}input::-moz-placeholder{color:var(--grey-seperators)}input:-ms-input-placeholder{color:var(--grey-seperators)}input::placeholder{color:var(--grey-seperators)}textarea:focus{outline:none}.date-picker-container{position:relative;width:140px}.date-picker-container .date-picker{cursor:pointer;height:32px;width:100%;font-size:14px;border-radius:6px;padding:0 12px;border:1px solid var(--grey-seperators);inset:10px auto auto 80px;background-color:var(--text-white)}.date-picker-container .date-picker:hover{background-color:var(--grey-hover)}.date-picker-container .date-picker-icon{position:absolute;top:50%;right:12px;transform:translateY(-50%);cursor:pointer}form .dynamic-field:last-child{border-bottom:none!important}#checkboxes-container{display:flex;justify-content:flex-start;align-items:center;flex-wrap:wrap}.radio-checkbox-common{display:flex;justify-content:center;align-items:center;cursor:pointer;margin-right:8px;margin-bottom:8px;background-color:var(--text-white);padding:12px 16px;border:1px solid var(--text-muted);border-radius:8px}.radio-checkbox-common p{color:var(--text-muted);cursor:pointer}.radio-checkbox-common img{margin-right:8px}.checkbox-active{background-color:var(--pmry-500)}.checkbox-active p{color:var(--text-white)}#error-messages-container{margin-top:4px;width:100%;display:flex;justify-content:flex-start;align-items:center;flex-wrap:wrap}#error-messages-container p{color:var(--sem-error)}"]
|
|
541
628
|
},] }
|
|
542
629
|
];
|
|
543
630
|
DynamicFormComponent.ctorParameters = function () { return []; };
|
|
@@ -547,7 +634,58 @@
|
|
|
547
634
|
activeBtnIconUrl: [{ type: core.Input }],
|
|
548
635
|
calendarIconUrl: [{ type: core.Input }],
|
|
549
636
|
formUpdated: [{ type: core.Output }],
|
|
550
|
-
|
|
637
|
+
formValid: [{ type: core.Output }],
|
|
638
|
+
formInitialized: [{ type: core.Output }]
|
|
639
|
+
};
|
|
640
|
+
var dynamicFieldValidator = function (validators) {
|
|
641
|
+
return function (control) {
|
|
642
|
+
var value = control.value;
|
|
643
|
+
if (Array.isArray(value)) {
|
|
644
|
+
return null;
|
|
645
|
+
}
|
|
646
|
+
else if (typeof value === 'object') {
|
|
647
|
+
value = (value === null || value === void 0 ? void 0 : value.value) ? value.value : '';
|
|
648
|
+
}
|
|
649
|
+
var errors = null;
|
|
650
|
+
validators.forEach(function (validator) {
|
|
651
|
+
var error = null;
|
|
652
|
+
var message = validator.message;
|
|
653
|
+
switch (validator.type) {
|
|
654
|
+
case "Required":
|
|
655
|
+
error = forms.Validators.required(control);
|
|
656
|
+
if (error)
|
|
657
|
+
error = { Required: message };
|
|
658
|
+
break;
|
|
659
|
+
case "MinLength":
|
|
660
|
+
error = forms.Validators.minLength(+validator.value)(control);
|
|
661
|
+
message = message.replace('${0}', error === null || error === void 0 ? void 0 : error.minlength.requiredLength);
|
|
662
|
+
if (error)
|
|
663
|
+
error = { MinLength: message };
|
|
664
|
+
break;
|
|
665
|
+
case "MaxLength":
|
|
666
|
+
error = forms.Validators.maxLength(+validator.value)(control);
|
|
667
|
+
message = message.replace('${0}', error === null || error === void 0 ? void 0 : error.actualLength);
|
|
668
|
+
if (error)
|
|
669
|
+
error = { MaxLength: message };
|
|
670
|
+
break;
|
|
671
|
+
case "Email":
|
|
672
|
+
error = forms.Validators.email(control);
|
|
673
|
+
if (error)
|
|
674
|
+
error = { Email: message };
|
|
675
|
+
break;
|
|
676
|
+
case "Custom":
|
|
677
|
+
error = forms.Validators.pattern("" + validator.value)(control);
|
|
678
|
+
if (error)
|
|
679
|
+
error = { Custom: message };
|
|
680
|
+
break;
|
|
681
|
+
default:
|
|
682
|
+
break;
|
|
683
|
+
}
|
|
684
|
+
if (error)
|
|
685
|
+
errors = Object.assign(Object.assign({}, errors), error);
|
|
686
|
+
});
|
|
687
|
+
return errors;
|
|
688
|
+
};
|
|
551
689
|
};
|
|
552
690
|
|
|
553
691
|
var DynamicFormModule = /** @class */ (function () {
|