@tft/crispr-forms 13.0.13 → 13.0.16
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.directive.mjs +12 -13
- package/esm2020/lib/form/form.component.mjs +4 -5
- package/esm2020/lib/form-group-list/form-group-list.component.mjs +22 -9
- package/fesm2015/tft-crispr-forms.mjs +32 -21
- package/fesm2015/tft-crispr-forms.mjs.map +1 -1
- package/fesm2020/tft-crispr-forms.mjs +32 -21
- package/fesm2020/tft-crispr-forms.mjs.map +1 -1
- package/lib/field.directive.d.ts +3 -3
- package/lib/form/form.component.d.ts +1 -2
- package/lib/form-group-list/form-group-list.component.d.ts +3 -3
- package/package.json +1 -1
- package/tft-crispr-forms-13.0.16.tgz +0 -0
- package/tft-crispr-forms-13.0.13.tgz +0 -0
|
@@ -1572,16 +1572,13 @@ function isControlOrButtonComponent(component) {
|
|
|
1572
1572
|
}
|
|
1573
1573
|
|
|
1574
1574
|
class CrisprFieldDirective {
|
|
1575
|
-
constructor(container, renderer
|
|
1575
|
+
constructor(container, renderer) {
|
|
1576
1576
|
this.container = container;
|
|
1577
1577
|
this.renderer = renderer;
|
|
1578
|
-
this.cdr = cdr;
|
|
1579
1578
|
}
|
|
1580
1579
|
set value(value) {
|
|
1581
1580
|
this._value = value;
|
|
1582
|
-
|
|
1583
|
-
this.component.value = value;
|
|
1584
|
-
}
|
|
1581
|
+
this.updateComponentValue(value);
|
|
1585
1582
|
}
|
|
1586
1583
|
;
|
|
1587
1584
|
get value() {
|
|
@@ -1598,10 +1595,7 @@ class CrisprFieldDirective {
|
|
|
1598
1595
|
if (isControlOrButtonComponent(this.component)) {
|
|
1599
1596
|
this.component.group = this.group;
|
|
1600
1597
|
}
|
|
1601
|
-
|
|
1602
|
-
this.component.value = this.value;
|
|
1603
|
-
}
|
|
1604
|
-
this.cdr.detectChanges();
|
|
1598
|
+
this.updateComponentValue(this.value);
|
|
1605
1599
|
// adds any config classes to the dynamically generated component
|
|
1606
1600
|
// doing this here keeps us from having to extend a base component into each field component individually
|
|
1607
1601
|
if (!this.config.classes)
|
|
@@ -1616,15 +1610,20 @@ class CrisprFieldDirective {
|
|
|
1616
1610
|
}
|
|
1617
1611
|
});
|
|
1618
1612
|
}
|
|
1613
|
+
updateComponentValue(value) {
|
|
1614
|
+
if (this.component && isControlComponent(this.component)) {
|
|
1615
|
+
this.component.value = value;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1619
1618
|
}
|
|
1620
|
-
CrisprFieldDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFieldDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.Renderer2 }
|
|
1619
|
+
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 });
|
|
1621
1620
|
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 });
|
|
1622
1621
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFieldDirective, decorators: [{
|
|
1623
1622
|
type: Directive,
|
|
1624
1623
|
args: [{
|
|
1625
1624
|
selector: '[crisprField]'
|
|
1626
1625
|
}]
|
|
1627
|
-
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.Renderer2 }
|
|
1626
|
+
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.Renderer2 }]; }, propDecorators: { config: [{
|
|
1628
1627
|
type: Input
|
|
1629
1628
|
}], group: [{
|
|
1630
1629
|
type: Input
|
|
@@ -1678,7 +1677,6 @@ class CrisprFormComponent {
|
|
|
1678
1677
|
// proxy value and status change events through to consuming component
|
|
1679
1678
|
this.valueChanges = this.form.valueChanges;
|
|
1680
1679
|
this.statusChanges = this.form.statusChanges;
|
|
1681
|
-
this.subs = [];
|
|
1682
1680
|
}
|
|
1683
1681
|
ngOnInit() {
|
|
1684
1682
|
// build out the form, note that we pass in the form as the third argument and the function modifies it
|
|
@@ -1693,10 +1691,10 @@ class CrisprFormComponent {
|
|
|
1693
1691
|
}
|
|
1694
1692
|
}
|
|
1695
1693
|
CrisprFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1696
|
-
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 },
|
|
1694
|
+
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 }, preserveWhitespaces: true });
|
|
1697
1695
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: CrisprFormComponent, decorators: [{
|
|
1698
1696
|
type: Component,
|
|
1699
|
-
args: [{ selector: 'crispr-form',
|
|
1697
|
+
args: [{ selector: 'crispr-form', 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"] }]
|
|
1700
1698
|
}], propDecorators: { config: [{
|
|
1701
1699
|
type: Input
|
|
1702
1700
|
}], form: [{
|
|
@@ -1720,38 +1718,51 @@ const defaultConfig = {
|
|
|
1720
1718
|
};
|
|
1721
1719
|
const FormGroupListMixin = crisprControlMixin(CrisprFieldComponent);
|
|
1722
1720
|
class FormGroupListComponent extends FormGroupListMixin {
|
|
1723
|
-
constructor() {
|
|
1724
|
-
super(
|
|
1721
|
+
constructor(cdr) {
|
|
1722
|
+
super();
|
|
1723
|
+
this.cdr = cdr;
|
|
1725
1724
|
this.defaultConfig = defaultConfig;
|
|
1726
1725
|
}
|
|
1727
1726
|
ngOnInit() {
|
|
1728
1727
|
super.ngOnInit();
|
|
1729
1728
|
// TODO: this is required to ngFor of controls in template, must be a better way
|
|
1730
|
-
this.formArray = this.control;
|
|
1731
1729
|
}
|
|
1732
1730
|
setControlValue(values) {
|
|
1733
1731
|
if (this.control) {
|
|
1734
1732
|
if (values?.length > 0) {
|
|
1733
|
+
// clear any existing values so that new values don't concatenate onto the old
|
|
1734
|
+
const currentValues = this.control.value;
|
|
1735
|
+
if (currentValues.length) {
|
|
1736
|
+
this.control.clear();
|
|
1737
|
+
}
|
|
1735
1738
|
values.forEach(value => this.addGroup(value));
|
|
1736
1739
|
}
|
|
1737
1740
|
else if (this.config.displayInitialItem) {
|
|
1738
1741
|
this.addGroup();
|
|
1739
1742
|
}
|
|
1743
|
+
// needed to ensure new array items render
|
|
1744
|
+
setTimeout(() => {
|
|
1745
|
+
this.cdr.detectChanges();
|
|
1746
|
+
});
|
|
1740
1747
|
}
|
|
1741
1748
|
}
|
|
1742
1749
|
addGroup(value = null) {
|
|
1743
1750
|
this.control.push(createControlForType(this.config.itemConfig, value));
|
|
1751
|
+
// needed to ensure new array items render
|
|
1752
|
+
setTimeout(() => {
|
|
1753
|
+
this.cdr.detectChanges();
|
|
1754
|
+
});
|
|
1744
1755
|
}
|
|
1745
1756
|
deleteGroup(index) {
|
|
1746
1757
|
this.control.removeAt(index);
|
|
1747
1758
|
}
|
|
1748
1759
|
}
|
|
1749
|
-
FormGroupListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FormGroupListComponent, deps:
|
|
1750
|
-
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 <!--
|
|
1760
|
+
FormGroupListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FormGroupListComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
1761
|
+
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 <!-- Don't add trackBy function, it confuses the state of the array -->\n <div *ngFor=\"let control of control?.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\"> {{ config.itemLabelBuilder ? config.itemLabelBuilder(i) : 'Item ' + (i + 1) }} </span>\n <button\n mat-icon-button\n type=\"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]=\"control.value | 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 });
|
|
1751
1762
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: FormGroupListComponent, decorators: [{
|
|
1752
1763
|
type: Component,
|
|
1753
|
-
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 <!--
|
|
1754
|
-
}] });
|
|
1764
|
+
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 <!-- Don't add trackBy function, it confuses the state of the array -->\n <div *ngFor=\"let control of control?.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\"> {{ config.itemLabelBuilder ? config.itemLabelBuilder(i) : 'Item ' + (i + 1) }} </span>\n <button\n mat-icon-button\n type=\"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]=\"control.value | 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"] }]
|
|
1765
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; } });
|
|
1755
1766
|
|
|
1756
1767
|
class CrisprPipesModule {
|
|
1757
1768
|
}
|