@tft/crispr-forms 13.0.11 → 13.0.14
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/esm2020/lib/field-component-map.const.mjs +5 -2
- package/esm2020/lib/field.directive.mjs +17 -12
- package/esm2020/lib/form/form.component.mjs +4 -6
- package/esm2020/lib/form-group-list/form-group-list.component.mjs +10 -6
- package/fesm2015/tft-crispr-forms.mjs +29 -19
- package/fesm2015/tft-crispr-forms.mjs.map +1 -1
- package/fesm2020/tft-crispr-forms.mjs +29 -19
- package/fesm2020/tft-crispr-forms.mjs.map +1 -1
- package/lib/field-component-map.const.d.ts +4 -2
- package/lib/field.directive.d.ts +8 -4
- package/lib/form/form.component.d.ts +3 -3
- package/lib/form-group-list/form-group-list.component.d.ts +3 -2
- package/package.json +1 -1
- package/tft-crispr-forms-13.0.14.tgz +0 -0
- package/tft-crispr-forms-13.0.11.tgz +0 -0
|
@@ -1565,14 +1565,26 @@ const FIELD_COMPONENTS = {
|
|
|
1565
1565
|
unitConversion: Promise.resolve().then(function () { return index$2; }).then(({ UnitConversionFieldComponent }) => UnitConversionFieldComponent)
|
|
1566
1566
|
};
|
|
1567
1567
|
function isControlComponent(component) {
|
|
1568
|
-
return isControlConfig(component.config) || component.config.controlType === ControlType.BUTTON;
|
|
1568
|
+
return isControlConfig(component.config) && 'value' in component; // || component.config.controlType === ControlType.BUTTON;
|
|
1569
|
+
}
|
|
1570
|
+
function isControlOrButtonComponent(component) {
|
|
1571
|
+
return isControlComponent(component) || component.config.controlType === ControlType.BUTTON;
|
|
1569
1572
|
}
|
|
1570
1573
|
|
|
1571
1574
|
class CrisprFieldDirective {
|
|
1572
|
-
constructor(container, renderer
|
|
1575
|
+
constructor(container, renderer) {
|
|
1573
1576
|
this.container = container;
|
|
1574
1577
|
this.renderer = renderer;
|
|
1575
|
-
|
|
1578
|
+
}
|
|
1579
|
+
set value(value) {
|
|
1580
|
+
this._value = value;
|
|
1581
|
+
if (this.component && isControlComponent(this.component)) {
|
|
1582
|
+
this.component.value = value;
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
;
|
|
1586
|
+
get value() {
|
|
1587
|
+
return this._value;
|
|
1576
1588
|
}
|
|
1577
1589
|
async ngOnInit() {
|
|
1578
1590
|
/**
|
|
@@ -1582,13 +1594,9 @@ class CrisprFieldDirective {
|
|
|
1582
1594
|
const componentRef = this.container.createComponent(component);
|
|
1583
1595
|
this.component = componentRef.instance;
|
|
1584
1596
|
this.component.config = this.config;
|
|
1585
|
-
if (
|
|
1597
|
+
if (isControlOrButtonComponent(this.component)) {
|
|
1586
1598
|
this.component.group = this.group;
|
|
1587
|
-
if ('value' in this.component) {
|
|
1588
|
-
this.component.value = this.value;
|
|
1589
|
-
}
|
|
1590
1599
|
}
|
|
1591
|
-
this.cdr.detectChanges();
|
|
1592
1600
|
// adds any config classes to the dynamically generated component
|
|
1593
1601
|
// doing this here keeps us from having to extend a base component into each field component individually
|
|
1594
1602
|
if (!this.config.classes)
|
|
@@ -1604,14 +1612,14 @@ class CrisprFieldDirective {
|
|
|
1604
1612
|
});
|
|
1605
1613
|
}
|
|
1606
1614
|
}
|
|
1607
|
-
CrisprFieldDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFieldDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.Renderer2 }
|
|
1615
|
+
CrisprFieldDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFieldDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1608
1616
|
CrisprFieldDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.1", type: CrisprFieldDirective, selector: "[crisprField]", inputs: { config: "config", group: "group", value: "value" }, ngImport: i0 });
|
|
1609
1617
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFieldDirective, decorators: [{
|
|
1610
1618
|
type: Directive,
|
|
1611
1619
|
args: [{
|
|
1612
1620
|
selector: '[crisprField]'
|
|
1613
1621
|
}]
|
|
1614
|
-
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.Renderer2 }
|
|
1622
|
+
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.Renderer2 }]; }, propDecorators: { config: [{
|
|
1615
1623
|
type: Input
|
|
1616
1624
|
}], group: [{
|
|
1617
1625
|
type: Input
|
|
@@ -1667,11 +1675,9 @@ class CrisprFormComponent {
|
|
|
1667
1675
|
this.statusChanges = this.form.statusChanges;
|
|
1668
1676
|
this.subs = [];
|
|
1669
1677
|
}
|
|
1670
|
-
|
|
1678
|
+
ngOnInit() {
|
|
1671
1679
|
// build out the form, note that we pass in the form as the third argument and the function modifies it
|
|
1672
|
-
|
|
1673
|
-
buildFormGroupFromConfig(this.config, this.value, this.form);
|
|
1674
|
-
}
|
|
1680
|
+
buildFormGroupFromConfig(this.config, this.value, this.form);
|
|
1675
1681
|
}
|
|
1676
1682
|
handleSubmit() {
|
|
1677
1683
|
this.form.markAllAsTouched();
|
|
@@ -1682,7 +1688,7 @@ class CrisprFormComponent {
|
|
|
1682
1688
|
}
|
|
1683
1689
|
}
|
|
1684
1690
|
CrisprFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1685
|
-
CrisprFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: CrisprFormComponent, selector: "crispr-form", inputs: { config: "config", form: "form", value: "value" }, outputs: { submitted: "submitted", valueChanges: "valueChanges", statusChanges: "statusChanges" }, viewQueries: [{ propertyName: "submitTrigger", first: true, predicate: ["submitTrigger"], descendants: true }],
|
|
1691
|
+
CrisprFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: CrisprFormComponent, selector: "crispr-form", inputs: { config: "config", form: "form", value: "value" }, outputs: { submitted: "submitted", valueChanges: "valueChanges", statusChanges: "statusChanges" }, viewQueries: [{ propertyName: "submitTrigger", first: true, predicate: ["submitTrigger"], descendants: true }], ngImport: i0, template: "<form\n class=\"crispr-form\"\n [ngClass]=\"config.classes\"\n [formGroup]=\"form\"\n (ngSubmit)=\"handleSubmit()\"\n [autocomplete]=\"config.autocomplete || 'off'\"\n [errorDictionary]=\"config.errorDictionary\"\n #ngFormElement=\"ngForm\">\n\n <ng-container\n *ngFor=\"let field of config.fields;\"\n crisprField\n [value]=\"value | initialControlValue : field\"\n [config]=\"field\"\n [group]=\"form\">\n </ng-container>\n <!-- Hidden button, programmatically clicked when crispr form triggerSubmit function called.\n Uses a hidden button with type=\"submit\" because it will trigger both native form submit event\n (which the error handler has to listen for) and ngSubmit event -->\n <button #submitTrigger class=\"submit-trigger\" type=\"submit\">\n </button>\n</form>\n", styles: [".submit-trigger{display:none}\n"], directives: [{ type: i4$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i4$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i5.ControlErrorsFormDirective, selector: "form", inputs: ["errorDictionary"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i4$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.ControlErrorContainerDirective, selector: "[controlErrorContainer], [formGroup]" }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: CrisprFieldDirective, selector: "[crisprField]", inputs: ["config", "group", "value"] }], pipes: { "initialControlValue": InitialControlValuePipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
|
|
1686
1692
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFormComponent, decorators: [{
|
|
1687
1693
|
type: Component,
|
|
1688
1694
|
args: [{ selector: 'crispr-form', changeDetection: ChangeDetectionStrategy.OnPush, template: "<form\n class=\"crispr-form\"\n [ngClass]=\"config.classes\"\n [formGroup]=\"form\"\n (ngSubmit)=\"handleSubmit()\"\n [autocomplete]=\"config.autocomplete || 'off'\"\n [errorDictionary]=\"config.errorDictionary\"\n #ngFormElement=\"ngForm\">\n\n <ng-container\n *ngFor=\"let field of config.fields;\"\n crisprField\n [value]=\"value | initialControlValue : field\"\n [config]=\"field\"\n [group]=\"form\">\n </ng-container>\n <!-- Hidden button, programmatically clicked when crispr form triggerSubmit function called.\n Uses a hidden button with type=\"submit\" because it will trigger both native form submit event\n (which the error handler has to listen for) and ngSubmit event -->\n <button #submitTrigger class=\"submit-trigger\" type=\"submit\">\n </button>\n</form>\n", styles: [".submit-trigger{display:none}\n"] }]
|
|
@@ -1709,8 +1715,9 @@ const defaultConfig = {
|
|
|
1709
1715
|
};
|
|
1710
1716
|
const FormGroupListMixin = crisprControlMixin(CrisprFieldComponent);
|
|
1711
1717
|
class FormGroupListComponent extends FormGroupListMixin {
|
|
1712
|
-
constructor() {
|
|
1713
|
-
super(
|
|
1718
|
+
constructor(cdr) {
|
|
1719
|
+
super();
|
|
1720
|
+
this.cdr = cdr;
|
|
1714
1721
|
this.defaultConfig = defaultConfig;
|
|
1715
1722
|
}
|
|
1716
1723
|
ngOnInit() {
|
|
@@ -1722,6 +1729,9 @@ class FormGroupListComponent extends FormGroupListMixin {
|
|
|
1722
1729
|
if (this.control) {
|
|
1723
1730
|
if (values?.length > 0) {
|
|
1724
1731
|
values.forEach(value => this.addGroup(value));
|
|
1732
|
+
setTimeout(() => {
|
|
1733
|
+
this.cdr.detectChanges();
|
|
1734
|
+
});
|
|
1725
1735
|
}
|
|
1726
1736
|
else if (this.config.displayInitialItem) {
|
|
1727
1737
|
this.addGroup();
|
|
@@ -1735,12 +1745,12 @@ class FormGroupListComponent extends FormGroupListMixin {
|
|
|
1735
1745
|
this.control.removeAt(index);
|
|
1736
1746
|
}
|
|
1737
1747
|
}
|
|
1738
|
-
FormGroupListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FormGroupListComponent, deps:
|
|
1748
|
+
FormGroupListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FormGroupListComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
1739
1749
|
FormGroupListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.1", type: FormGroupListComponent, selector: "crispr-form-group-list", usesInheritance: true, ngImport: i0, template: "\n<crispr-field-container\n [config]=\"config\"\n [group]=\"group\"\n [formGroup]=\"group\">\n\n <div [formArrayName]=\"config.controlName\">\n <!-- TODO: add sortBy function -->\n <div *ngFor=\"let control of formArray?.controls; let i = index;\">\n <!-- TODO: use content projection to allow custom item label component -->\n <div class=\"item-header\">\n <span class=\"mat-h2\" *ngIf=\"config.itemLabelBuilder\"> {{ config.itemLabelBuilder(i) }} </span>\n <button\n mat-icon-button\n *ngIf=\"i + 1 > config.minListLength\">\n <mat-icon (click)=\"deleteGroup(i)\">delete</mat-icon>\n </button>\n </div>\n <div\n [formGroupName]=\"i\">\n <ng-container\n *ngFor=\"let field of config.itemConfig.fields;\"\n crisprField\n [config]=\"field\"\n [value]=\"value && value[i] | initialControlValue : field\"\n [group]=\"control\">\n </ng-container>\n </div>\n </div>\n </div>\n <div class=\"group-footer\">\n <button\n type=\"button\"\n class=\"add\"\n mat-raised-button\n [color]=\"config.addButtonColor\"\n (click)=\"addGroup()\">\n {{config.addItemLabel || config.addButtonLabel}}\n </button>\n </div>\n\n</crispr-field-container>\n", styles: [".item-header{display:flex;justify-content:space-between}.group-footer{display:flex;justify-content:flex-end}.group-footer button.add{margin-bottom:16px}\n"], components: [{ type: FieldContainerComponent, selector: "crispr-field-container", inputs: ["config", "group", "inlineField"] }, { type: i1.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i4$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.ControlErrorContainerDirective, selector: "[controlErrorContainer], [formGroup]" }, { type: i4$1.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4$1.FormGroupName, selector: "[formGroupName]", inputs: ["formGroupName"] }, { type: CrisprFieldDirective, selector: "[crisprField]", inputs: ["config", "group", "value"] }], pipes: { "initialControlValue": InitialControlValuePipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, preserveWhitespaces: true });
|
|
1740
1750
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FormGroupListComponent, decorators: [{
|
|
1741
1751
|
type: Component,
|
|
1742
1752
|
args: [{ selector: 'crispr-form-group-list', changeDetection: ChangeDetectionStrategy.OnPush, template: "\n<crispr-field-container\n [config]=\"config\"\n [group]=\"group\"\n [formGroup]=\"group\">\n\n <div [formArrayName]=\"config.controlName\">\n <!-- TODO: add sortBy function -->\n <div *ngFor=\"let control of formArray?.controls; let i = index;\">\n <!-- TODO: use content projection to allow custom item label component -->\n <div class=\"item-header\">\n <span class=\"mat-h2\" *ngIf=\"config.itemLabelBuilder\"> {{ config.itemLabelBuilder(i) }} </span>\n <button\n mat-icon-button\n *ngIf=\"i + 1 > config.minListLength\">\n <mat-icon (click)=\"deleteGroup(i)\">delete</mat-icon>\n </button>\n </div>\n <div\n [formGroupName]=\"i\">\n <ng-container\n *ngFor=\"let field of config.itemConfig.fields;\"\n crisprField\n [config]=\"field\"\n [value]=\"value && value[i] | initialControlValue : field\"\n [group]=\"control\">\n </ng-container>\n </div>\n </div>\n </div>\n <div class=\"group-footer\">\n <button\n type=\"button\"\n class=\"add\"\n mat-raised-button\n [color]=\"config.addButtonColor\"\n (click)=\"addGroup()\">\n {{config.addItemLabel || config.addButtonLabel}}\n </button>\n </div>\n\n</crispr-field-container>\n", styles: [".item-header{display:flex;justify-content:space-between}.group-footer{display:flex;justify-content:flex-end}.group-footer button.add{margin-bottom:16px}\n"] }]
|
|
1743
|
-
}] });
|
|
1753
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; } });
|
|
1744
1754
|
|
|
1745
1755
|
class CrisprPipesModule {
|
|
1746
1756
|
}
|