@seniorsistemas/angular-components 18.1.0-feature-sds-276-ea560ae6 → 18.1.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/checkbox/lib/checkbox/checkbox.component.d.ts +13 -3
- package/esm2022/checkbox/lib/checkbox/checkbox.component.mjs +21 -12
- package/esm2022/file-upload/lib/file-upload/file-upload.component.mjs +4 -4
- package/esm2022/file-upload/lib/file-upload/file-upload.module.mjs +13 -30
- package/esm2022/select/lib/select/components/select-option/select-option.component.mjs +1 -1
- package/esm2022/select/lib/select/select.component.mjs +2 -2
- package/fesm2022/seniorsistemas-angular-components-checkbox.mjs +20 -11
- package/fesm2022/seniorsistemas-angular-components-checkbox.mjs.map +1 -1
- package/fesm2022/seniorsistemas-angular-components-file-upload.mjs +7 -24
- package/fesm2022/seniorsistemas-angular-components-file-upload.mjs.map +1 -1
- package/fesm2022/seniorsistemas-angular-components-select.mjs +2 -2
- package/fesm2022/seniorsistemas-angular-components-select.mjs.map +1 -1
- package/file-upload/lib/file-upload/file-upload.module.d.ts +1 -1
- package/package.json +14 -26
- package/esm2022/form-dynamic/components/form-dynamic/form-dynamic.component.mjs +0 -53
- package/esm2022/form-dynamic/core/registry.mjs +0 -10
- package/esm2022/form-dynamic/fields-basic/boolean-field/boolean-field.component.mjs +0 -15
- package/esm2022/form-dynamic/fields-basic/string-field/string-field.component.mjs +0 -15
- package/esm2022/form-dynamic/optional-fields/editor/editor-field/editor-field.component.mjs +0 -30
- package/esm2022/form-dynamic/optional-fields/editor/editor-types.mjs +0 -2
- package/esm2022/form-dynamic/optional-fields/editor/public-api.mjs +0 -6
- package/esm2022/form-dynamic/optional-fields/editor/seniorsistemas-angular-components-form-dynamic-optional-fields-editor.mjs +0 -5
- package/esm2022/form-dynamic/public-api.mjs +0 -10
- package/esm2022/form-dynamic/schemas/field-dynamic.mjs +0 -2
- package/esm2022/form-dynamic/schemas/form-dynamic-schema.mjs +0 -2
- package/esm2022/form-dynamic/seniorsistemas-angular-components-form-dynamic.mjs +0 -5
- package/fesm2022/seniorsistemas-angular-components-form-dynamic-optional-fields-editor.mjs +0 -40
- package/fesm2022/seniorsistemas-angular-components-form-dynamic-optional-fields-editor.mjs.map +0 -1
- package/fesm2022/seniorsistemas-angular-components-form-dynamic.mjs +0 -94
- package/fesm2022/seniorsistemas-angular-components-form-dynamic.mjs.map +0 -1
- package/form-dynamic/components/form-dynamic/form-dynamic.component.d.ts +0 -15
- package/form-dynamic/core/registry.d.ts +0 -7
- package/form-dynamic/fields-basic/boolean-field/boolean-field.component.d.ts +0 -9
- package/form-dynamic/fields-basic/string-field/string-field.component.d.ts +0 -9
- package/form-dynamic/index.d.ts +0 -5
- package/form-dynamic/optional-fields/editor/editor-field/editor-field.component.d.ts +0 -15
- package/form-dynamic/optional-fields/editor/editor-types.d.ts +0 -8
- package/form-dynamic/optional-fields/editor/index.d.ts +0 -5
- package/form-dynamic/optional-fields/editor/public-api.d.ts +0 -8
- package/form-dynamic/public-api.d.ts +0 -4
- package/form-dynamic/schemas/field-dynamic.d.ts +0 -20
- package/form-dynamic/schemas/form-dynamic-schema.d.ts +0 -4
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generated bundle index. Do not edit.
|
|
3
|
-
*/
|
|
4
|
-
export * from './public-api';
|
|
5
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VuaW9yc2lzdGVtYXMtYW5ndWxhci1jb21wb25lbnRzLWZvcm0tZHluYW1pYy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3Byb2plY3RzL2FuZ3VsYXItY29tcG9uZW50cy9mb3JtLWR5bmFtaWMvbGliL3NlbmlvcnNpc3RlbWFzLWFuZ3VsYXItY29tcG9uZW50cy1mb3JtLWR5bmFtaWMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUc7QUFFSCxjQUFjLGNBQWMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogR2VuZXJhdGVkIGJ1bmRsZSBpbmRleC4gRG8gbm90IGVkaXQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9wdWJsaWMtYXBpJztcbiJdfQ==
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { FormDynamicRegistry } from '@seniorsistemas/angular-components/form-dynamic';
|
|
2
|
-
import * as i0 from '@angular/core';
|
|
3
|
-
import { input, viewChild, Component } from '@angular/core';
|
|
4
|
-
import Quill from 'quill';
|
|
5
|
-
|
|
6
|
-
class EditorFieldComponent {
|
|
7
|
-
id = crypto.randomUUID();
|
|
8
|
-
field = input.required();
|
|
9
|
-
control = input.required();
|
|
10
|
-
editorContainer = viewChild.required('editorContainer');
|
|
11
|
-
quill;
|
|
12
|
-
ngAfterViewInit() {
|
|
13
|
-
this.quill = new Quill(this.editorContainer().nativeElement, {
|
|
14
|
-
theme: this.field().theme ?? 'snow',
|
|
15
|
-
});
|
|
16
|
-
this.quill.on('text-change', () => {
|
|
17
|
-
const html = this.editorContainer().nativeElement.querySelector('.ql-editor')?.innerHTML;
|
|
18
|
-
this.control().setValue(html, { emitEvent: true });
|
|
19
|
-
});
|
|
20
|
-
const initial = this.control().value;
|
|
21
|
-
if (initial) {
|
|
22
|
-
this.quill.root.innerHTML = initial;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: EditorFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
26
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "18.2.14", type: EditorFieldComponent, isStandalone: true, selector: "s-editor-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: true, transformFunction: null }, control: { classPropertyName: "control", publicName: "control", isSignal: true, isRequired: true, transformFunction: null } }, viewQueries: [{ propertyName: "editorContainer", first: true, predicate: ["editorContainer"], descendants: true, isSignal: true }], ngImport: i0, template: " <label [for]=\"id\">{{ field().label }}</label>\n\n<div [id]=\"id\" #editorContainer class=\"quill-container\"></div>\n", styles: [""] });
|
|
27
|
-
}
|
|
28
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: EditorFieldComponent, decorators: [{
|
|
29
|
-
type: Component,
|
|
30
|
-
args: [{ selector: 's-editor-field', standalone: true, imports: [], template: " <label [for]=\"id\">{{ field().label }}</label>\n\n<div [id]=\"id\" #editorContainer class=\"quill-container\"></div>\n" }]
|
|
31
|
-
}] });
|
|
32
|
-
|
|
33
|
-
FormDynamicRegistry.registerField('editor', EditorFieldComponent);
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Generated bundle index. Do not edit.
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
export { EditorFieldComponent };
|
|
40
|
-
//# sourceMappingURL=seniorsistemas-angular-components-form-dynamic-optional-fields-editor.mjs.map
|
package/fesm2022/seniorsistemas-angular-components-form-dynamic-optional-fields-editor.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"seniorsistemas-angular-components-form-dynamic-optional-fields-editor.mjs","sources":["../../projects/angular-components/form-dynamic/optional-fields/editor/editor-field/editor-field.component.ts","../../projects/angular-components/form-dynamic/optional-fields/editor/editor-field/editor-field.component.html","../../projects/angular-components/form-dynamic/optional-fields/editor/public-api.ts","../../projects/angular-components/form-dynamic/optional-fields/editor/seniorsistemas-angular-components-form-dynamic-optional-fields-editor.ts"],"sourcesContent":["import { AfterViewInit, Component, ElementRef, input, viewChild } from '@angular/core';\nimport { EditorField } from '../editor-types';\nimport { FormControl } from '@angular/forms';\nimport Quill from 'quill';\n\n@Component({\n selector: 's-editor-field',\n standalone: true,\n imports: [],\n templateUrl: './editor-field.component.html',\n styleUrl: './editor-field.component.css',\n})\nexport class EditorFieldComponent implements AfterViewInit {\n id = crypto.randomUUID();\n\n field = input.required<EditorField>();\n control = input.required<FormControl>();\n\n editorContainer = viewChild.required<ElementRef<HTMLElement>>('editorContainer');\n\n quill!: Quill;\n\n ngAfterViewInit() {\n this.quill = new Quill(this.editorContainer().nativeElement, {\n theme: this.field().theme ?? 'snow',\n });\n\n this.quill.on('text-change', () => {\n const html = this.editorContainer().nativeElement.querySelector('.ql-editor')?.innerHTML;\n this.control().setValue(html, { emitEvent: true });\n });\n\n const initial = this.control().value;\n if (initial) {\n this.quill.root.innerHTML = initial;\n }\n }\n}\n\n"," <label [for]=\"id\">{{ field().label }}</label>\n\n<div [id]=\"id\" #editorContainer class=\"quill-container\"></div>\n","import { FormDynamicRegistry } from '@seniorsistemas/angular-components/form-dynamic';\nimport { EditorFieldComponent } from './editor-field/editor-field.component';\n\nFormDynamicRegistry.registerField('editor', EditorFieldComponent);\n\nexport * from './editor-types';\nexport { EditorFieldComponent } from './editor-field/editor-field.component';\n\n// Module augmentation to add 'editor' to FieldTypeMap\nimport { EditorField } from './editor-types';\ndeclare module '@seniorsistemas/angular-components/form-dynamic' {\n export interface FieldTypeMap {\n editor: EditorField;\n }\n}\n\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAYa,oBAAoB,CAAA;AAC7B,IAAA,EAAE,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;AAEzB,IAAA,KAAK,GAAG,KAAK,CAAC,QAAQ,EAAe,CAAC;AACtC,IAAA,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAe,CAAC;AAExC,IAAA,eAAe,GAAG,SAAS,CAAC,QAAQ,CAA0B,iBAAiB,CAAC,CAAC;AAEjF,IAAA,KAAK,CAAS;IAEd,eAAe,GAAA;AACX,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,aAAa,EAAE;YACzD,KAAK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@angular/forms';
|
|
4
|
-
import { ReactiveFormsModule, FormGroup, FormControl } from '@angular/forms';
|
|
5
|
-
|
|
6
|
-
class FormDynamicRegistry {
|
|
7
|
-
static fields = new Map();
|
|
8
|
-
static registerField(type, component) {
|
|
9
|
-
this.fields.set(type, component);
|
|
10
|
-
}
|
|
11
|
-
static resolveField(type) {
|
|
12
|
-
return this.fields.get(type);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
class BooleanFieldComponent {
|
|
17
|
-
field = input.required();
|
|
18
|
-
control = input.required();
|
|
19
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: BooleanFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
20
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.14", type: BooleanFieldComponent, isStandalone: true, selector: "s-boolean-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: true, transformFunction: null }, control: { classPropertyName: "control", publicName: "control", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<label>\n <input type=\"checkbox\" [formControl]=\"control()\" [name]=\"field().key\" />\n {{ field().label }}\n</label>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }] });
|
|
21
|
-
}
|
|
22
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: BooleanFieldComponent, decorators: [{
|
|
23
|
-
type: Component,
|
|
24
|
-
args: [{ selector: 's-boolean-field', standalone: true, imports: [ReactiveFormsModule], template: "<label>\n <input type=\"checkbox\" [formControl]=\"control()\" [name]=\"field().key\" />\n {{ field().label }}\n</label>\n" }]
|
|
25
|
-
}] });
|
|
26
|
-
|
|
27
|
-
class StringFieldComponent {
|
|
28
|
-
field = input.required();
|
|
29
|
-
control = input.required();
|
|
30
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: StringFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
31
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.14", type: StringFieldComponent, isStandalone: true, selector: "s-string-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: true, transformFunction: null }, control: { classPropertyName: "control", publicName: "control", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: " <label>{{ field().label }}</label>\n <input type=\"text\" [formControl]=\"control()\" [name]=\"field().key\" />\n", styles: [""], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }] });
|
|
32
|
-
}
|
|
33
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: StringFieldComponent, decorators: [{
|
|
34
|
-
type: Component,
|
|
35
|
-
args: [{ selector: 's-string-field', standalone: true, imports: [ReactiveFormsModule], template: " <label>{{ field().label }}</label>\n <input type=\"text\" [formControl]=\"control()\" [name]=\"field().key\" />\n" }]
|
|
36
|
-
}] });
|
|
37
|
-
|
|
38
|
-
class FormDynamicComponent {
|
|
39
|
-
form = new FormGroup({});
|
|
40
|
-
schema = input.required();
|
|
41
|
-
// @ViewChildren('host', { read: ViewContainerRef })
|
|
42
|
-
// hosts!: QueryList<ViewContainerRef>;
|
|
43
|
-
hosts = viewChildren('host', { read: ViewContainerRef });
|
|
44
|
-
schemaEffect = effect(() => {
|
|
45
|
-
this.buildForm();
|
|
46
|
-
});
|
|
47
|
-
hostsEffect = effect(() => {
|
|
48
|
-
this.buildFields();
|
|
49
|
-
});
|
|
50
|
-
buildForm() {
|
|
51
|
-
const schema = this.schema();
|
|
52
|
-
if (!schema || !schema.fields)
|
|
53
|
-
return;
|
|
54
|
-
const group = {};
|
|
55
|
-
schema.fields.forEach((field) => {
|
|
56
|
-
group[field.key] = new FormControl(null);
|
|
57
|
-
});
|
|
58
|
-
this.form = new FormGroup(group);
|
|
59
|
-
}
|
|
60
|
-
buildFields() {
|
|
61
|
-
const hosts = this.hosts();
|
|
62
|
-
if (!hosts?.length)
|
|
63
|
-
return;
|
|
64
|
-
this.schema().fields.forEach((field, index) => {
|
|
65
|
-
const container = hosts[index];
|
|
66
|
-
container.clear();
|
|
67
|
-
const component = FormDynamicRegistry.resolveField(field.type);
|
|
68
|
-
if (!component)
|
|
69
|
-
return;
|
|
70
|
-
const ref = container.createComponent(component);
|
|
71
|
-
ref.setInput('field', field);
|
|
72
|
-
ref.setInput('control', this.form.get(field.key));
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
emit() {
|
|
76
|
-
console.log('FORM ->', this.form.value);
|
|
77
|
-
}
|
|
78
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: FormDynamicComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
79
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: FormDynamicComponent, isStandalone: true, selector: "s-form-dynamic", inputs: { schema: { classPropertyName: "schema", publicName: "schema", isSignal: true, isRequired: true, transformFunction: null } }, viewQueries: [{ propertyName: "hosts", predicate: ["host"], descendants: true, read: ViewContainerRef, isSignal: true }], ngImport: i0, template: "<form [formGroup]=\"form\">\n\n @for (field of schema().fields; track field.key; let i = $index) {\n <ng-container #host></ng-container>\n }\n\n <button type=\"submit\" (click)=\"emit()\">Enviar</button>\n </form>\n", dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }] });
|
|
80
|
-
}
|
|
81
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: FormDynamicComponent, decorators: [{
|
|
82
|
-
type: Component,
|
|
83
|
-
args: [{ selector: 's-form-dynamic', standalone: true, imports: [ReactiveFormsModule], template: "<form [formGroup]=\"form\">\n\n @for (field of schema().fields; track field.key; let i = $index) {\n <ng-container #host></ng-container>\n }\n\n <button type=\"submit\" (click)=\"emit()\">Enviar</button>\n </form>\n" }]
|
|
84
|
-
}] });
|
|
85
|
-
|
|
86
|
-
FormDynamicRegistry.registerField('string', StringFieldComponent);
|
|
87
|
-
FormDynamicRegistry.registerField('boolean', BooleanFieldComponent);
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Generated bundle index. Do not edit.
|
|
91
|
-
*/
|
|
92
|
-
|
|
93
|
-
export { FormDynamicComponent, FormDynamicRegistry };
|
|
94
|
-
//# sourceMappingURL=seniorsistemas-angular-components-form-dynamic.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"seniorsistemas-angular-components-form-dynamic.mjs","sources":["../../projects/angular-components/form-dynamic/lib/core/registry.ts","../../projects/angular-components/form-dynamic/lib/fields-basic/boolean-field/boolean-field.component.ts","../../projects/angular-components/form-dynamic/lib/fields-basic/boolean-field/boolean-field.component.html","../../projects/angular-components/form-dynamic/lib/fields-basic/string-field/string-field.component.ts","../../projects/angular-components/form-dynamic/lib/fields-basic/string-field/string-field.component.html","../../projects/angular-components/form-dynamic/lib/components/form-dynamic/form-dynamic.component.ts","../../projects/angular-components/form-dynamic/lib/components/form-dynamic/form-dynamic.component.html","../../projects/angular-components/form-dynamic/lib/public-api.ts","../../projects/angular-components/form-dynamic/lib/seniorsistemas-angular-components-form-dynamic.ts"],"sourcesContent":["import { Type } from \"@angular/core\";\nimport { FieldType } from \"../schemas/field-dynamic\";\n\nexport class FormDynamicRegistry {\n private static fields = new Map<FieldType, Type<any>>();\n\n static registerField(type: FieldType, component: Type<any>) {\n this.fields.set(type, component);\n }\n\n static resolveField(type: FieldType) {\n return this.fields.get(type);\n }\n}\n","import { Component, input } from '@angular/core';\nimport { BooleanField } from '../../schemas/field-dynamic';\nimport { FormControl, ReactiveFormsModule } from '@angular/forms';\n\n@Component({\n selector: 's-boolean-field',\n standalone: true,\n imports: [ReactiveFormsModule],\n templateUrl: './boolean-field.component.html',\n styleUrl: './boolean-field.component.css',\n})\nexport class BooleanFieldComponent {\n field = input.required<BooleanField>();\n control = input.required<FormControl>();\n}\n\n","<label>\n <input type=\"checkbox\" [formControl]=\"control()\" [name]=\"field().key\" />\n {{ field().label }}\n</label>\n","import { Component, input } from '@angular/core';\nimport { FormControl, ReactiveFormsModule } from '@angular/forms';\nimport { StringField } from '../../schemas/field-dynamic';\n\n@Component({\n selector: 's-string-field',\n standalone: true,\n imports: [ReactiveFormsModule],\n templateUrl: './string-field.component.html',\n styleUrl: './string-field.component.css',\n})\nexport class StringFieldComponent {\n field = input.required<StringField>();\n control = input.required<FormControl>();\n}\n\n"," <label>{{ field().label }}</label>\n <input type=\"text\" [formControl]=\"control()\" [name]=\"field().key\" />\n","import { Component, effect, input, viewChildren, ViewContainerRef } from '@angular/core';\nimport { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';\nimport { FormDynamicRegistry } from '../../core/registry';\nimport { FormDynamicSchema } from '../../schemas/form-dynamic-schema';\n\n@Component({\n selector: 's-form-dynamic',\n standalone: true,\n imports: [ReactiveFormsModule],\n templateUrl: './form-dynamic.component.html',\n})\nexport class FormDynamicComponent {\n protected form = new FormGroup({});\n schema = input.required<FormDynamicSchema>();\n\n // @ViewChildren('host', { read: ViewContainerRef })\n // hosts!: QueryList<ViewContainerRef>;\n\n private readonly hosts = viewChildren('host', { read: ViewContainerRef });\n\n private readonly schemaEffect = effect(() => {\n this.buildForm();\n });\n\n private readonly hostsEffect = effect(() => {\n this.buildFields();\n });\n\n private buildForm() {\n const schema = this.schema();\n if (!schema || !schema.fields) return;\n\n const group: any = {};\n\n schema.fields.forEach((field) => {\n group[field.key] = new FormControl(null);\n });\n\n this.form = new FormGroup(group);\n }\n\n private buildFields() {\n const hosts = this.hosts();\n if (!hosts?.length) return;\n\n this.schema().fields.forEach((field, index) => {\n const container = hosts[index];\n container.clear();\n\n const component = FormDynamicRegistry.resolveField(field.type);\n if (!component) return;\n\n const ref = container.createComponent(component);\n\n ref.setInput('field', field);\n ref.setInput('control', this.form.get(field.key)!);\n });\n }\n\n emit() {\n console.log('FORM ->', this.form.value);\n }\n}\n\n","<form [formGroup]=\"form\">\n\n @for (field of schema().fields; track field.key; let i = $index) {\n <ng-container #host></ng-container>\n }\n\n <button type=\"submit\" (click)=\"emit()\">Enviar</button>\n </form>\n","import { FormDynamicRegistry } from './core/registry';\nexport { FormDynamicRegistry } from './core/registry';\nimport { BooleanFieldComponent } from './fields-basic/boolean-field/boolean-field.component';\nimport { StringFieldComponent } from './fields-basic/string-field/string-field.component';\n\nFormDynamicRegistry.registerField('string', StringFieldComponent);\nFormDynamicRegistry.registerField('boolean', BooleanFieldComponent);\n\n\nexport * from './schemas/field-dynamic';\nexport * from './schemas/form-dynamic-schema';\nexport { FormDynamicComponent } from './components/form-dynamic/form-dynamic.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAGa,mBAAmB,CAAA;AACpB,IAAA,OAAO,MAAM,GAAG,IAAI,GAAG,EAAwB,CAAC;AAExD,IAAA,OAAO,aAAa,CAAC,IAAe,EAAE,SAAoB,EAAA;QACtD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;KACpC;IAED,OAAO,YAAY,CAAC,IAAe,EAAA;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;KAChC;;;MCDQ,qBAAqB,CAAA;AAC9B,IAAA,KAAK,GAAG,KAAK,CAAC,QAAQ,EAAgB,CAAC;AACvC,IAAA,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAe,CAAC;wGAF/B,qBAAqB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;4FAArB,qBAAqB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,iBAAA,EAAA,MAAA,EAAA,EAAA,KAAA,EAAA,EAAA,iBAAA,EAAA,OAAA,EAAA,UAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,OAAA,EAAA,EAAA,iBAAA,EAAA,SAAA,EAAA,UAAA,EAAA,SAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,ECXlC,8HAIA,EAAA,MAAA,EAAA,CAAA,EAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EDGc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AA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA;;4FAGpB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBANhC,SAAS;AACI,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,gBAAgB,EACd,UAAA,EAAA,IAAI,EACP,OAAA,EAAA,CAAC,mBAAmB,CAAC,EAAA,QAAA,EAAA,kPAAA,EAAA,CAAA;;;AEHlC,mBAAmB,CAAC,aAAa,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;AAClE,mBAAmB,CAAC,aAAa,CAAC,SAAS,EAAE,qBAAqB,CAAC;;ACNnE;;AAEG;;;;"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { FormGroup } from '@angular/forms';
|
|
2
|
-
import { FormDynamicSchema } from '../../schemas/form-dynamic-schema';
|
|
3
|
-
import * as i0 from "@angular/core";
|
|
4
|
-
export declare class FormDynamicComponent {
|
|
5
|
-
protected form: FormGroup<{}>;
|
|
6
|
-
schema: import("@angular/core").InputSignal<FormDynamicSchema>;
|
|
7
|
-
private readonly hosts;
|
|
8
|
-
private readonly schemaEffect;
|
|
9
|
-
private readonly hostsEffect;
|
|
10
|
-
private buildForm;
|
|
11
|
-
private buildFields;
|
|
12
|
-
emit(): void;
|
|
13
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<FormDynamicComponent, never>;
|
|
14
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<FormDynamicComponent, "s-form-dynamic", never, { "schema": { "alias": "schema"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
15
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Type } from "@angular/core";
|
|
2
|
-
import { FieldType } from "../schemas/field-dynamic";
|
|
3
|
-
export declare class FormDynamicRegistry {
|
|
4
|
-
private static fields;
|
|
5
|
-
static registerField(type: FieldType, component: Type<any>): void;
|
|
6
|
-
static resolveField(type: FieldType): Type<any> | undefined;
|
|
7
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BooleanField } from '../../schemas/field-dynamic';
|
|
2
|
-
import { FormControl } from '@angular/forms';
|
|
3
|
-
import * as i0 from "@angular/core";
|
|
4
|
-
export declare class BooleanFieldComponent {
|
|
5
|
-
field: import("@angular/core").InputSignal<BooleanField>;
|
|
6
|
-
control: import("@angular/core").InputSignal<FormControl<any>>;
|
|
7
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<BooleanFieldComponent, never>;
|
|
8
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<BooleanFieldComponent, "s-boolean-field", never, { "field": { "alias": "field"; "required": true; "isSignal": true; }; "control": { "alias": "control"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { FormControl } from '@angular/forms';
|
|
2
|
-
import { StringField } from '../../schemas/field-dynamic';
|
|
3
|
-
import * as i0 from "@angular/core";
|
|
4
|
-
export declare class StringFieldComponent {
|
|
5
|
-
field: import("@angular/core").InputSignal<StringField>;
|
|
6
|
-
control: import("@angular/core").InputSignal<FormControl<any>>;
|
|
7
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<StringFieldComponent, never>;
|
|
8
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<StringFieldComponent, "s-string-field", never, { "field": { "alias": "field"; "required": true; "isSignal": true; }; "control": { "alias": "control"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
9
|
-
}
|
package/form-dynamic/index.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { AfterViewInit, ElementRef } from '@angular/core';
|
|
2
|
-
import { EditorField } from '../editor-types';
|
|
3
|
-
import { FormControl } from '@angular/forms';
|
|
4
|
-
import Quill from 'quill';
|
|
5
|
-
import * as i0 from "@angular/core";
|
|
6
|
-
export declare class EditorFieldComponent implements AfterViewInit {
|
|
7
|
-
id: `${string}-${string}-${string}-${string}-${string}`;
|
|
8
|
-
field: import("@angular/core").InputSignal<EditorField>;
|
|
9
|
-
control: import("@angular/core").InputSignal<FormControl<any>>;
|
|
10
|
-
editorContainer: import("@angular/core").Signal<ElementRef<HTMLElement>>;
|
|
11
|
-
quill: Quill;
|
|
12
|
-
ngAfterViewInit(): void;
|
|
13
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<EditorFieldComponent, never>;
|
|
14
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<EditorFieldComponent, "s-editor-field", never, { "field": { "alias": "field"; "required": true; "isSignal": true; }; "control": { "alias": "control"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
15
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from './editor-types';
|
|
2
|
-
export { EditorFieldComponent } from './editor-field/editor-field.component';
|
|
3
|
-
import { EditorField } from './editor-types';
|
|
4
|
-
declare module '@seniorsistemas/angular-components/form-dynamic' {
|
|
5
|
-
interface FieldTypeMap {
|
|
6
|
-
editor: EditorField;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export interface FieldDynamicBase {
|
|
2
|
-
type: string;
|
|
3
|
-
key: string;
|
|
4
|
-
label?: string;
|
|
5
|
-
required?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export interface StringField extends FieldDynamicBase {
|
|
8
|
-
type: 'string';
|
|
9
|
-
minLength?: number;
|
|
10
|
-
maxLength?: number;
|
|
11
|
-
}
|
|
12
|
-
export interface BooleanField extends FieldDynamicBase {
|
|
13
|
-
type: 'boolean';
|
|
14
|
-
}
|
|
15
|
-
export interface FieldTypeMap {
|
|
16
|
-
string: StringField;
|
|
17
|
-
boolean: BooleanField;
|
|
18
|
-
}
|
|
19
|
-
export type FieldType = keyof FieldTypeMap;
|
|
20
|
-
export type FieldDynamic = FieldTypeMap[keyof FieldTypeMap];
|