@covalent/dynamic-forms 11.0.0-beta.1 → 11.0.0-beta.3
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Component, Injectable, Optional, SkipSelf, Directive, Input, Type, HostBinding, ViewChild, ChangeDetectionStrategy, ContentChildren, NgModule } from '@angular/core';
|
|
2
|
+
import { Component, inject, ChangeDetectorRef, Injectable, Optional, SkipSelf, TemplateRef, ViewContainerRef, Directive, Input, Injector, Type, HostBinding, ViewChild, ChangeDetectionStrategy, ContentChildren, NgModule } from '@angular/core';
|
|
3
3
|
import * as i2 from '@angular/forms';
|
|
4
|
-
import { ReactiveFormsModule, UntypedFormControl, Validators, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
|
+
import { ReactiveFormsModule, UntypedFormControl, Validators, NG_VALUE_ACCESSOR, UntypedFormBuilder } from '@angular/forms';
|
|
5
5
|
import * as i1 from '@angular/common';
|
|
6
6
|
import { CommonModule } from '@angular/common';
|
|
7
7
|
import * as i3$1 from '@angular/material/form-field';
|
|
@@ -239,7 +239,7 @@ function TdDynamicSliderComponent_span_4_Template(rf, ctx) { if (rf & 1) {
|
|
|
239
239
|
i0.ɵɵelementEnd();
|
|
240
240
|
} }
|
|
241
241
|
class TdDynamicSliderComponent {
|
|
242
|
-
_changeDetectorRef;
|
|
242
|
+
_changeDetectorRef = inject(ChangeDetectorRef);
|
|
243
243
|
control;
|
|
244
244
|
label = '';
|
|
245
245
|
required = false;
|
|
@@ -247,15 +247,12 @@ class TdDynamicSliderComponent {
|
|
|
247
247
|
hint = '';
|
|
248
248
|
min;
|
|
249
249
|
max;
|
|
250
|
-
constructor(_changeDetectorRef) {
|
|
251
|
-
this._changeDetectorRef = _changeDetectorRef;
|
|
252
|
-
}
|
|
253
250
|
_handleBlur() {
|
|
254
251
|
setTimeout(() => {
|
|
255
252
|
this._changeDetectorRef.markForCheck();
|
|
256
253
|
});
|
|
257
254
|
}
|
|
258
|
-
static ɵfac = function TdDynamicSliderComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TdDynamicSliderComponent)(
|
|
255
|
+
static ɵfac = function TdDynamicSliderComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TdDynamicSliderComponent)(); };
|
|
259
256
|
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TdDynamicSliderComponent, selectors: [["td-dynamic-slider"]], decls: 11, vars: 8, consts: [["slider", ""], [1, "td-dynamic-slider-wrapper", "mat-form-field", "mat-form-field-can-float", "mat-form-field-should-float"], [1, "mat-form-field-label-wrapper"], [1, "mat-form-field-label", "mat-primary", "td-slider-label"], ["class", "mat-form-field-required-marker", 4, "ngIf"], [1, "td-dynamic-slider-field"], ["thumbLabel", "", "tickInterval", "auto", 1, "td-dynamic-slider", 3, "blur"], ["matSliderThumb", "", 3, "min", "max", "formControl", "required"], [1, "mat-hint", "td-dynamic-element-hint"], [1, "mat-form-field-required-marker"]], template: function TdDynamicSliderComponent_Template(rf, ctx) { if (rf & 1) {
|
|
260
257
|
const _r1 = i0.ɵɵgetCurrentView();
|
|
261
258
|
i0.ɵɵelementStart(0, "div", 1)(1, "span", 2)(2, "label", 3);
|
|
@@ -284,7 +281,7 @@ class TdDynamicSliderComponent {
|
|
|
284
281
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdDynamicSliderComponent, [{
|
|
285
282
|
type: Component,
|
|
286
283
|
args: [{ selector: 'td-dynamic-slider', imports: [CommonModule, ReactiveFormsModule, MatSlider, MatSliderThumb], template: "<div\n class=\"td-dynamic-slider-wrapper mat-form-field mat-form-field-can-float mat-form-field-should-float\"\n>\n <span class=\"mat-form-field-label-wrapper\">\n <label class=\"mat-form-field-label mat-primary td-slider-label\">\n {{ label }}\n <span\n *ngIf=\"required && !control?.disabled\"\n class=\"mat-form-field-required-marker\"\n >*</span\n >\n </label>\n </span>\n <div class=\"td-dynamic-slider-field\">\n <mat-slider\n #slider\n class=\"td-dynamic-slider\"\n thumbLabel\n tickInterval=\"auto\"\n (blur)=\"_handleBlur()\"\n >\n <input\n [attr.name]=\"name\"\n [min]=\"min\"\n [max]=\"max\"\n [formControl]=\"control\"\n [required]=\"required\"\n matSliderThumb\n />\n </mat-slider>\n </div>\n <span class=\"mat-hint td-dynamic-element-hint\">{{ hint }}</span>\n</div>\n", styles: [":host .td-dynamic-slider-wrapper{display:block}.td-dynamic-slider-field{position:relative;flex-direction:row;display:flex;box-sizing:border-box}.td-dynamic-slider-field .td-dynamic-slider{flex:1}\n"] }]
|
|
287
|
-
}],
|
|
284
|
+
}], null, null); })();
|
|
288
285
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(TdDynamicSliderComponent, { className: "TdDynamicSliderComponent", filePath: "lib/dynamic-elements/dynamic-slider/dynamic-slider.component.ts", lineNumber: 12 }); })();
|
|
289
286
|
|
|
290
287
|
const _c0$2 = (a0, a1) => ({ control: a0, errors: a1 });
|
|
@@ -536,25 +533,24 @@ const _TdDynamicElementMixinBase = mixinControlValueAccessor(TdDynamicElementBas
|
|
|
536
533
|
class TdDynamicFormsErrorTemplateDirective extends CdkPortal {
|
|
537
534
|
templateRef;
|
|
538
535
|
tdDynamicFormsError;
|
|
539
|
-
constructor(
|
|
536
|
+
constructor() {
|
|
537
|
+
const templateRef = inject(TemplateRef);
|
|
538
|
+
const viewContainerRef = inject(ViewContainerRef);
|
|
540
539
|
super(templateRef, viewContainerRef);
|
|
541
540
|
this.templateRef = templateRef;
|
|
542
541
|
}
|
|
543
|
-
static ɵfac = function TdDynamicFormsErrorTemplateDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TdDynamicFormsErrorTemplateDirective)(
|
|
542
|
+
static ɵfac = function TdDynamicFormsErrorTemplateDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TdDynamicFormsErrorTemplateDirective)(); };
|
|
544
543
|
static ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: TdDynamicFormsErrorTemplateDirective, selectors: [["ng-template", "tdDynamicFormsError", ""]], inputs: { tdDynamicFormsError: "tdDynamicFormsError" }, features: [i0.ɵɵInheritDefinitionFeature] });
|
|
545
544
|
}
|
|
546
545
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdDynamicFormsErrorTemplateDirective, [{
|
|
547
546
|
type: Directive,
|
|
548
547
|
args: [{ selector: '[tdDynamicFormsError]ng-template' }]
|
|
549
|
-
}], () => [
|
|
548
|
+
}], () => [], { tdDynamicFormsError: [{
|
|
550
549
|
type: Input
|
|
551
550
|
}] }); })();
|
|
552
551
|
class TdDynamicElementDirective {
|
|
553
|
-
viewContainer;
|
|
554
|
-
|
|
555
|
-
this.viewContainer = viewContainer;
|
|
556
|
-
}
|
|
557
|
-
static ɵfac = function TdDynamicElementDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TdDynamicElementDirective)(i0.ɵɵdirectiveInject(i0.ViewContainerRef)); };
|
|
552
|
+
viewContainer = inject(ViewContainerRef);
|
|
553
|
+
static ɵfac = function TdDynamicElementDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TdDynamicElementDirective)(); };
|
|
558
554
|
static ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: TdDynamicElementDirective, selectors: [["", "tdDynamicContainer", ""]] });
|
|
559
555
|
}
|
|
560
556
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdDynamicElementDirective, [{
|
|
@@ -562,10 +558,10 @@ class TdDynamicElementDirective {
|
|
|
562
558
|
args: [{
|
|
563
559
|
selector: '[tdDynamicContainer]',
|
|
564
560
|
}]
|
|
565
|
-
}],
|
|
561
|
+
}], null, null); })();
|
|
566
562
|
class TdDynamicElementComponent extends _TdDynamicElementMixinBase {
|
|
567
|
-
_injector;
|
|
568
|
-
_dynamicFormsService;
|
|
563
|
+
_injector = inject(Injector);
|
|
564
|
+
_dynamicFormsService = inject(TdDynamicFormsService);
|
|
569
565
|
_instance;
|
|
570
566
|
/**
|
|
571
567
|
* Sets form control of the element.
|
|
@@ -635,10 +631,9 @@ class TdDynamicElementComponent extends _TdDynamicElementMixinBase {
|
|
|
635
631
|
get minAttr() {
|
|
636
632
|
return this.min;
|
|
637
633
|
}
|
|
638
|
-
constructor(
|
|
634
|
+
constructor() {
|
|
635
|
+
const _changeDetectorRef = inject(ChangeDetectorRef);
|
|
639
636
|
super(_changeDetectorRef);
|
|
640
|
-
this._injector = _injector;
|
|
641
|
-
this._dynamicFormsService = _dynamicFormsService;
|
|
642
637
|
}
|
|
643
638
|
ngOnInit() {
|
|
644
639
|
const component = this.type instanceof Type
|
|
@@ -681,7 +676,7 @@ class TdDynamicElementComponent extends _TdDynamicElementMixinBase {
|
|
|
681
676
|
}
|
|
682
677
|
}
|
|
683
678
|
}
|
|
684
|
-
static ɵfac = function TdDynamicElementComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TdDynamicElementComponent)(
|
|
679
|
+
static ɵfac = function TdDynamicElementComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TdDynamicElementComponent)(); };
|
|
685
680
|
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TdDynamicElementComponent, selectors: [["td-dynamic-element"]], viewQuery: function TdDynamicElementComponent_Query(rf, ctx) { if (rf & 1) {
|
|
686
681
|
i0.ɵɵviewQuery(TdDynamicElementDirective, 7);
|
|
687
682
|
} if (rf & 2) {
|
|
@@ -715,7 +710,7 @@ class TdDynamicElementComponent extends _TdDynamicElementMixinBase {
|
|
|
715
710
|
template: '<div tdDynamicContainer></div>',
|
|
716
711
|
imports: [TdDynamicElementDirective],
|
|
717
712
|
}]
|
|
718
|
-
}], () => [
|
|
713
|
+
}], () => [], { dynamicControl: [{
|
|
719
714
|
type: Input
|
|
720
715
|
}], label: [{
|
|
721
716
|
type: Input
|
|
@@ -755,7 +750,7 @@ class TdDynamicElementComponent extends _TdDynamicElementMixinBase {
|
|
|
755
750
|
type: HostBinding,
|
|
756
751
|
args: ['attr.min']
|
|
757
752
|
}] }); })();
|
|
758
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(TdDynamicElementComponent, { className: "TdDynamicElementComponent", filePath: "lib/dynamic-element.component.ts", lineNumber:
|
|
753
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(TdDynamicElementComponent, { className: "TdDynamicElementComponent", filePath: "lib/dynamic-element.component.ts", lineNumber: 74 }); })();
|
|
759
754
|
|
|
760
755
|
const _c0 = ["*"];
|
|
761
756
|
function TdDynamicFormsComponent_ng_template_2_td_dynamic_element_1_Template(rf, ctx) { if (rf & 1) {
|
|
@@ -777,9 +772,9 @@ function TdDynamicFormsComponent_ng_template_2_Template(rf, ctx) { if (rf & 1) {
|
|
|
777
772
|
i0.ɵɵproperty("ngIf", ctx_r1.dynamicForm.controls[element_r1.name]);
|
|
778
773
|
} }
|
|
779
774
|
class TdDynamicFormsComponent {
|
|
780
|
-
_formBuilder;
|
|
781
|
-
_dynamicFormsService;
|
|
782
|
-
_changeDetectorRef;
|
|
775
|
+
_formBuilder = inject(UntypedFormBuilder);
|
|
776
|
+
_dynamicFormsService = inject(TdDynamicFormsService);
|
|
777
|
+
_changeDetectorRef = inject(ChangeDetectorRef);
|
|
783
778
|
_renderedElements = [];
|
|
784
779
|
_elements;
|
|
785
780
|
_templateMap = new Map();
|
|
@@ -850,10 +845,7 @@ class TdDynamicFormsComponent {
|
|
|
850
845
|
}
|
|
851
846
|
return {};
|
|
852
847
|
}
|
|
853
|
-
constructor(
|
|
854
|
-
this._formBuilder = _formBuilder;
|
|
855
|
-
this._dynamicFormsService = _dynamicFormsService;
|
|
856
|
-
this._changeDetectorRef = _changeDetectorRef;
|
|
848
|
+
constructor() {
|
|
857
849
|
this.dynamicForm = this._formBuilder.group({});
|
|
858
850
|
}
|
|
859
851
|
ngAfterContentInit() {
|
|
@@ -943,7 +935,7 @@ class TdDynamicFormsComponent {
|
|
|
943
935
|
this._changeDetectorRef.markForCheck();
|
|
944
936
|
});
|
|
945
937
|
}
|
|
946
|
-
static ɵfac = function TdDynamicFormsComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TdDynamicFormsComponent)(
|
|
938
|
+
static ɵfac = function TdDynamicFormsComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TdDynamicFormsComponent)(); };
|
|
947
939
|
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TdDynamicFormsComponent, selectors: [["td-dynamic-forms"]], contentQueries: function TdDynamicFormsComponent_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) {
|
|
948
940
|
i0.ɵɵcontentQuery(dirIndex, TdDynamicFormsErrorTemplateDirective, 5);
|
|
949
941
|
} if (rf & 2) {
|
|
@@ -965,13 +957,13 @@ class TdDynamicFormsComponent {
|
|
|
965
957
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdDynamicFormsComponent, [{
|
|
966
958
|
type: Component,
|
|
967
959
|
args: [{ selector: 'td-dynamic-forms', imports: [CommonModule, TdDynamicElementComponent, ReactiveFormsModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<form [formGroup]=\"dynamicForm\" novalidate>\n <div class=\"td-dynamic-form-wrapper\">\n <ng-template let-element ngFor [ngForOf]=\"elements\">\n <div\n class=\"td-dynamic-element-wrapper\"\n [style.max-width.%]=\"element.flex ? element.flex : 100\"\n [style.flex]=\"'1 1 ' + (element.flex ? element.flex : 100) + '%'\"\n [style.-ms-flex]=\"'1 1 ' + (element.flex ? element.flex : 100) + '%'\"\n [style.-webkit-box-flex]=\"1\"\n >\n <td-dynamic-element\n #dynamicElement\n *ngIf=\"dynamicForm.controls[element.name]\"\n [formControlName]=\"element.name\"\n [dynamicControl]=\"dynamicForm.controls[element.name]\"\n [id]=\"element.name\"\n [name]=\"element.name\"\n [label]=\"element.label || element.name\"\n [hint]=\"element.hint\"\n [type]=\"element.type\"\n [required]=\"element.required ?? false\"\n [min]=\"element.min\"\n [max]=\"element.max\"\n [minLength]=\"element.minLength\"\n [maxLength]=\"element.maxLength\"\n [selections]=\"element.selections\"\n [multiple]=\"element.multiple\"\n [customConfig]=\"element.customConfig\"\n [errorMessageTemplate]=\"getErrorTemplateRef(element.name)\"\n [placeholder]=\"element.placeholder\"\n ></td-dynamic-element>\n </div>\n </ng-template>\n </div>\n <ng-content></ng-content>\n</form>\n", styles: [".td-dynamic-form-wrapper{flex-flow:row wrap;box-sizing:border-box;display:flex;align-items:center;align-content:center;max-width:100%;justify-content:flex-start}.td-dynamic-form-wrapper ::ng-deep .mat-form-field-infix{width:auto}.td-dynamic-form-wrapper ::ng-deep .td-dynamic-element-hint{font-size:75%;display:block}.td-dynamic-form-wrapper .td-dynamic-element-wrapper{max-height:100%;box-sizing:border-box;position:relative;padding:4px 4px 8px}\n"] }]
|
|
968
|
-
}], () => [
|
|
960
|
+
}], () => [], { _errorTemplates: [{
|
|
969
961
|
type: ContentChildren,
|
|
970
962
|
args: [TdDynamicFormsErrorTemplateDirective, { descendants: true }]
|
|
971
963
|
}], elements: [{
|
|
972
964
|
type: Input
|
|
973
965
|
}] }); })();
|
|
974
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(TdDynamicFormsComponent, { className: "TdDynamicFormsComponent", filePath: "lib/dynamic-forms.component.ts", lineNumber:
|
|
966
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(TdDynamicFormsComponent, { className: "TdDynamicFormsComponent", filePath: "lib/dynamic-forms.component.ts", lineNumber: 40 }); })();
|
|
975
967
|
|
|
976
968
|
const TD_DYNAMIC_FORMS = [
|
|
977
969
|
TdDynamicFormsComponent,
|