special-forms 1.0.0
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/.editorconfig +16 -0
- package/.storybook/db-theme.js +8 -0
- package/.storybook/main.js +15 -0
- package/.storybook/manager.js +7 -0
- package/.storybook/preview-head.html +16 -0
- package/.storybook/preview.js +20 -0
- package/.storybook/tsconfig.json +21 -0
- package/.storybook/typings.d.ts +4 -0
- package/.vscode/extensions.json +4 -0
- package/.vscode/launch.json +20 -0
- package/.vscode/tasks.json +42 -0
- package/README.md +27 -0
- package/angular.json +38 -0
- package/documentation.json +10829 -0
- package/package.json +65 -0
- package/projects/special-forms/README.md +24 -0
- package/projects/special-forms/karma.conf.js +44 -0
- package/projects/special-forms/ng-package.json +7 -0
- package/projects/special-forms/package.json +11 -0
- package/projects/special-forms/src/lib/assets/styles.scss +213 -0
- package/projects/special-forms/src/lib/assets/themes/dark.scss +80 -0
- package/projects/special-forms/src/lib/assets/themes/light.scss +78 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-selector/form-control-selector.component.html +5 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-selector/form-control-selector.component.scss +6 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-selector/form-control-selector.component.spec.ts +21 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-selector/form-control-selector.component.ts +21 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-selector/form-control-selector.module.ts +36 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-viewer/form-control-viewer.component.html +5 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-viewer/form-control-viewer.component.scss +18 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-viewer/form-control-viewer.component.spec.ts +23 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-viewer/form-control-viewer.component.ts +66 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-viewer/form-control-viewer.module.ts +16 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/control-dialog.component.html +31 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/control-dialog.component.scss +0 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/control-dialog.component.spec.ts +22 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/control-dialog.component.ts +102 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/autocomplete.form.ts +87 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/checkbox.form.ts +51 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/common.form.interface.ts +24 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/common.form.ts +31 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/datepicker.form.ts +56 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/dropdown.form.ts +80 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/field.form.ts +189 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/input.form.ts +71 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/label.form.ts +33 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/text-area.form.ts +17 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/upload.form.ts +35 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/form-group-viewer.component.html +37 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/form-group-viewer.component.scss +41 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/form-group-viewer.component.spec.ts +22 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/form-group-viewer.component.ts +95 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/form-group-viewer.module.ts +32 -0
- package/projects/special-forms/src/lib/components/index.ts +61 -0
- package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.component.html +62 -0
- package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.component.scss +3 -0
- package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.component.spec.ts +24 -0
- package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.component.ts +58 -0
- package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.interface.ts +20 -0
- package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.module.ts +25 -0
- package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.stories.ts +81 -0
- package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.component.html +17 -0
- package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.component.scss +3 -0
- package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.component.spec.ts +23 -0
- package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.component.ts +19 -0
- package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.interface.ts +12 -0
- package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.module.ts +25 -0
- package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.stories.ts +76 -0
- package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.component.html +26 -0
- package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.component.scss +3 -0
- package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.component.spec.ts +23 -0
- package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.component.ts +21 -0
- package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.interface.ts +13 -0
- package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.module.ts +26 -0
- package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.stories.ts +69 -0
- package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.component.html +41 -0
- package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.component.scss +15 -0
- package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.component.spec.ts +24 -0
- package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.component.ts +34 -0
- package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.interface.ts +18 -0
- package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.module.ts +22 -0
- package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.stories.ts +83 -0
- package/projects/special-forms/src/lib/components/special-form/special-form-array.component.html +208 -0
- package/projects/special-forms/src/lib/components/special-form/special-form-array.component.scss +70 -0
- package/projects/special-forms/src/lib/components/special-form/special-form-array.component.spec.ts +23 -0
- package/projects/special-forms/src/lib/components/special-form/special-form-array.module.ts +18 -0
- package/projects/special-forms/src/lib/components/special-form/special-form.component.html +20 -0
- package/projects/special-forms/src/lib/components/special-form/special-form.component.scss +3 -0
- package/projects/special-forms/src/lib/components/special-form/special-form.component.spec.ts +22 -0
- package/projects/special-forms/src/lib/components/special-form/special-form.component.ts +85 -0
- package/projects/special-forms/src/lib/components/special-form/special-form.module.ts +40 -0
- package/projects/special-forms/src/lib/components/special-form/special-form.stories.ts +45 -0
- package/projects/special-forms/src/lib/components/special-input/special-input.component.html +37 -0
- package/projects/special-forms/src/lib/components/special-input/special-input.component.scss +3 -0
- package/projects/special-forms/src/lib/components/special-input/special-input.component.spec.ts +23 -0
- package/projects/special-forms/src/lib/components/special-input/special-input.component.ts +39 -0
- package/projects/special-forms/src/lib/components/special-input/special-input.interface.ts +17 -0
- package/projects/special-forms/src/lib/components/special-input/special-input.module.ts +24 -0
- package/projects/special-forms/src/lib/components/special-input/special-input.stories.ts +91 -0
- package/projects/special-forms/src/lib/components/special-label/special-label.component.html +6 -0
- package/projects/special-forms/src/lib/components/special-label/special-label.component.scss +3 -0
- package/projects/special-forms/src/lib/components/special-label/special-label.component.spec.ts +23 -0
- package/projects/special-forms/src/lib/components/special-label/special-label.component.ts +27 -0
- package/projects/special-forms/src/lib/components/special-label/special-label.interface.ts +14 -0
- package/projects/special-forms/src/lib/components/special-label/special-label.module.ts +25 -0
- package/projects/special-forms/src/lib/components/special-label/special-label.stories.ts +99 -0
- package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.component.html +82 -0
- package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.component.scss +3 -0
- package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.component.spec.ts +23 -0
- package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.component.ts +86 -0
- package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.interface.ts +20 -0
- package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.module.ts +28 -0
- package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.stories.ts +81 -0
- package/projects/special-forms/src/lib/components/special-text-area/special-text-area.component.html +29 -0
- package/projects/special-forms/src/lib/components/special-text-area/special-text-area.component.scss +3 -0
- package/projects/special-forms/src/lib/components/special-text-area/special-text-area.component.spec.ts +23 -0
- package/projects/special-forms/src/lib/components/special-text-area/special-text-area.component.ts +20 -0
- package/projects/special-forms/src/lib/components/special-text-area/special-text-area.interface.ts +9 -0
- package/projects/special-forms/src/lib/components/special-text-area/special-text-area.module.ts +24 -0
- package/projects/special-forms/src/lib/components/special-text-area/special-text-area.stories.ts +69 -0
- package/projects/special-forms/src/lib/components/special-upload/special-upload.component.html +50 -0
- package/projects/special-forms/src/lib/components/special-upload/special-upload.component.scss +29 -0
- package/projects/special-forms/src/lib/components/special-upload/special-upload.component.spec.ts +23 -0
- package/projects/special-forms/src/lib/components/special-upload/special-upload.component.ts +79 -0
- package/projects/special-forms/src/lib/components/special-upload/special-upload.interface.ts +12 -0
- package/projects/special-forms/src/lib/components/special-upload/special-upload.module.ts +23 -0
- package/projects/special-forms/src/lib/components/special-upload/special-upload.stories.ts +81 -0
- package/projects/special-forms/src/lib/core/aux-data/all-icons.ts +99 -0
- package/projects/special-forms/src/lib/core/aux-data/control-types.enum.ts +16 -0
- package/projects/special-forms/src/lib/core/aux-data/countries.ts +247 -0
- package/projects/special-forms/src/lib/core/aux-data/field-basic-data.ts +14 -0
- package/projects/special-forms/src/lib/core/aux-data/input-types.ts +23 -0
- package/projects/special-forms/src/lib/core/controls/icons.control.ts +8 -0
- package/projects/special-forms/src/lib/core/controls/index.ts +2 -0
- package/projects/special-forms/src/lib/core/controls/theme.control.ts +1 -0
- package/projects/special-forms/src/lib/core/controls/types.control.ts +9 -0
- package/projects/special-forms/src/lib/core/directives/control-render.directive.ts +19 -0
- package/projects/special-forms/src/lib/core/directives/control-render.module.ts +10 -0
- package/projects/special-forms/src/lib/core/forms/special-forms.ts +395 -0
- package/projects/special-forms/src/lib/core/interfaces/field-basics.interfaces.ts +22 -0
- package/projects/special-forms/src/lib/core/interfaces/form.interfaces.ts +83 -0
- package/projects/special-forms/src/lib/core/interfaces/special-control.interface.ts +9 -0
- package/projects/special-forms/src/lib/core/masks/currency.mask.ts +11 -0
- package/projects/special-forms/src/lib/core/masks/maks.enum.ts +12 -0
- package/projects/special-forms/src/lib/core/masks/number.mask.ts +4 -0
- package/projects/special-forms/src/lib/core/services/index.ts +3 -0
- package/projects/special-forms/src/lib/core/services/special-form-builder/special-form-builder.service.spec.ts +16 -0
- package/projects/special-forms/src/lib/core/services/special-form-builder/special-form-builder.service.ts +220 -0
- package/projects/special-forms/src/lib/core/utils/enum-to-array.util.ts +6 -0
- package/projects/special-forms/src/lib/pipes/controls-list-pipe/controls-list.pipe.module.ts +10 -0
- package/projects/special-forms/src/lib/pipes/controls-list-pipe/controls-list.pipe.ts +17 -0
- package/projects/special-forms/src/lib/pipes/error-message-pipe/error.pipe.module.ts +13 -0
- package/projects/special-forms/src/lib/pipes/error-message-pipe/error.pipe.ts +21 -0
- package/projects/special-forms/src/lib/pipes/index.ts +3 -0
- package/projects/special-forms/src/lib/pipes/text-by-function/text-by-function.pipe.module.ts +13 -0
- package/projects/special-forms/src/lib/pipes/text-by-function/text-by-function.pipe.ts +14 -0
- package/projects/special-forms/src/public-api.ts +8 -0
- package/projects/special-forms/src/test.ts +27 -0
- package/projects/special-forms/tsconfig.lib.json +15 -0
- package/projects/special-forms/tsconfig.lib.prod.json +10 -0
- package/projects/special-forms/tsconfig.spec.json +17 -0
- package/scss-bundle.config.json +6 -0
- package/stories/Button.stories.ts +42 -0
- package/stories/Header.stories.ts +35 -0
- package/stories/Introduction.stories.mdx +211 -0
- package/stories/Page.stories.ts +36 -0
- package/stories/User.ts +2 -0
- package/stories/assets/code-brackets.svg +1 -0
- package/stories/assets/colors.svg +1 -0
- package/stories/assets/comments.svg +1 -0
- package/stories/assets/direction.svg +1 -0
- package/stories/assets/flow.svg +1 -0
- package/stories/assets/plugin.svg +1 -0
- package/stories/assets/repo.svg +1 -0
- package/stories/assets/stackalt.svg +1 -0
- package/stories/button.component.ts +53 -0
- package/stories/button.css +30 -0
- package/stories/header.component.ts +75 -0
- package/stories/header.css +32 -0
- package/stories/page.component.ts +77 -0
- package/stories/page.css +69 -0
- package/tailwind.config.js +30 -0
- package/tsconfig.json +39 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
EventEmitter,
|
|
4
|
+
HostBinding,
|
|
5
|
+
Input,
|
|
6
|
+
OnInit,
|
|
7
|
+
Output,
|
|
8
|
+
} from '@angular/core';
|
|
9
|
+
import { EControlTypes } from '../../core/aux-data/control-types.enum';
|
|
10
|
+
import { SpecialFormControl } from '../../core/forms/special-forms';
|
|
11
|
+
import {
|
|
12
|
+
TSpecialAutocomplete,
|
|
13
|
+
TSpecialDropdown,
|
|
14
|
+
} from '../../core/interfaces/form.interfaces';
|
|
15
|
+
import { Masks } from '../../core/masks/maks.enum';
|
|
16
|
+
import { SpecialFormBuilderService } from '../../core/services';
|
|
17
|
+
import { OverlayContainer } from '@angular/cdk/overlay';
|
|
18
|
+
|
|
19
|
+
@Component({
|
|
20
|
+
selector: 'spf-form-control-viewer',
|
|
21
|
+
templateUrl: './form-control-viewer.component.html',
|
|
22
|
+
styleUrls: ['./form-control-viewer.component.scss'],
|
|
23
|
+
})
|
|
24
|
+
export class FormControlViewerComponent implements OnInit {
|
|
25
|
+
@Input('field') set fieldSetter(field: any) {
|
|
26
|
+
this.control = this.specialFormBuilderService.control(field);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Input('input') set inputSetter(field: any) {
|
|
30
|
+
field.settings.mask = Masks[field.settings.mask];
|
|
31
|
+
this.control = this.specialFormBuilderService.control(field);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@Input('dropdown') set dropdownSetter(field: Partial<TSpecialDropdown>) {
|
|
35
|
+
this.control = this.specialFormBuilderService.control(field);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@Input('autocomplete') set autocompleteSetter(
|
|
39
|
+
field: Partial<TSpecialAutocomplete>
|
|
40
|
+
) {
|
|
41
|
+
field.settings.getData = () => this.getData.emit();
|
|
42
|
+
this.control = this.specialFormBuilderService.control(field);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@Input('theme') set themeSetter(theme: string) {
|
|
46
|
+
this.overlayContainer.getContainerElement().classList.add(theme);
|
|
47
|
+
this.theme = theme;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@Output() getData: EventEmitter<string> = new EventEmitter();
|
|
51
|
+
|
|
52
|
+
control: SpecialFormControl<any>;
|
|
53
|
+
|
|
54
|
+
theme
|
|
55
|
+
|
|
56
|
+
constructor(
|
|
57
|
+
private overlayContainer: OverlayContainer,
|
|
58
|
+
private specialFormBuilderService: SpecialFormBuilderService
|
|
59
|
+
) {}
|
|
60
|
+
|
|
61
|
+
get controlTypes(): typeof EControlTypes {
|
|
62
|
+
return EControlTypes;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
ngOnInit(): void {}
|
|
66
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { FormControlViewerComponent } from './form-control-viewer.component';
|
|
4
|
+
import { SpecialFormBuilderService } from '../../core/services';
|
|
5
|
+
import { FormControlSelectorModule } from '../form-control-selector/form-control-selector.module';
|
|
6
|
+
|
|
7
|
+
@NgModule({
|
|
8
|
+
declarations: [FormControlViewerComponent],
|
|
9
|
+
imports: [
|
|
10
|
+
CommonModule,
|
|
11
|
+
FormControlSelectorModule
|
|
12
|
+
],
|
|
13
|
+
exports: [FormControlViewerComponent],
|
|
14
|
+
providers: [SpecialFormBuilderService],
|
|
15
|
+
})
|
|
16
|
+
export class FormControlViewerModule {}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<div class="container divide-y divide-solid">
|
|
2
|
+
<h1 class="p-5 font-bold">Crear nuevo control</h1>
|
|
3
|
+
<div class="p-5 overflow-y-auto">
|
|
4
|
+
<sp-form *ngIf="reloadCheck" [control]="formGroup"></sp-form>
|
|
5
|
+
</div>
|
|
6
|
+
<!-- <div class="p-5 overflow-y-auto">
|
|
7
|
+
<h1 class="p-5 font-bold">Configuraciones del campo</h1>
|
|
8
|
+
<sp-form *ngIf="settingsForm" [control]="settingsForm"></sp-form>
|
|
9
|
+
</div> -->
|
|
10
|
+
<h1 class="p-5 font-bold">Campo generado</h1>
|
|
11
|
+
<div class="flex justifify-center p-5">
|
|
12
|
+
<sp-form *ngIf="control" [control]="control"></sp-form>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="flex justify-end p-5">
|
|
15
|
+
<div class="mx-1">
|
|
16
|
+
<button mat-stroked-button color="warn" (click)="cancel()">
|
|
17
|
+
Cancelar
|
|
18
|
+
</button>
|
|
19
|
+
</div>
|
|
20
|
+
<div class="mx-1">
|
|
21
|
+
<button
|
|
22
|
+
mat-stroked-button
|
|
23
|
+
color="primary"
|
|
24
|
+
[disabled]="formGroup.invalid"
|
|
25
|
+
(click)="addControl()"
|
|
26
|
+
>
|
|
27
|
+
Aceptar
|
|
28
|
+
</button>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { ControlDialogComponent } from './control-dialog.component';
|
|
3
|
+
|
|
4
|
+
describe('ControlDialogComponent', () => {
|
|
5
|
+
let component: ControlDialogComponent;
|
|
6
|
+
let fixture: ComponentFixture<ControlDialogComponent>;
|
|
7
|
+
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
await TestBed.configureTestingModule({
|
|
10
|
+
declarations: [ ControlDialogComponent ]
|
|
11
|
+
})
|
|
12
|
+
.compileComponents();
|
|
13
|
+
|
|
14
|
+
fixture = TestBed.createComponent(ControlDialogComponent);
|
|
15
|
+
component = fixture.componentInstance;
|
|
16
|
+
fixture.detectChanges();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should create', () => {
|
|
20
|
+
expect(component).toBeTruthy();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
|
2
|
+
import { MatDialogRef } from '@angular/material/dialog';
|
|
3
|
+
import { debounceTime, filter, map, Subscription, switchMap, tap } from 'rxjs';
|
|
4
|
+
import { EControlTypes } from '../../../core/aux-data/control-types.enum';
|
|
5
|
+
import { SpecialFormGroup } from '../../../core/forms/special-forms';
|
|
6
|
+
import { SpecialFormBuilderService } from '../../../core/services';
|
|
7
|
+
import { FieldFormClass } from './settings-strategy/field.form';
|
|
8
|
+
import { CommonFormCreator } from './settings-strategy/common.form.interface';
|
|
9
|
+
import { InputFormClass } from './settings-strategy/input.form';
|
|
10
|
+
import { DropDownFormClass } from './settings-strategy/dropdown.form';
|
|
11
|
+
import { AutocompleteFormClass } from './settings-strategy/autocomplete.form';
|
|
12
|
+
import { DatePickerFormClass } from './settings-strategy/datepicker.form';
|
|
13
|
+
import { CheckboxFormClass } from './settings-strategy/checkbox.form';
|
|
14
|
+
import { UploadFormClass } from './settings-strategy/upload.form';
|
|
15
|
+
import { TextAreaFormClass } from './settings-strategy/text-area.form';
|
|
16
|
+
import { IFormStructure } from '@lib/core/interfaces/form.interfaces';
|
|
17
|
+
|
|
18
|
+
@Component({
|
|
19
|
+
selector: 'spf-control-dialog',
|
|
20
|
+
templateUrl: './control-dialog.component.html',
|
|
21
|
+
styleUrls: ['./control-dialog.component.scss'],
|
|
22
|
+
encapsulation: ViewEncapsulation.None,
|
|
23
|
+
})
|
|
24
|
+
export class ControlDialogComponent implements OnInit {
|
|
25
|
+
private formField = new FieldFormClass();
|
|
26
|
+
private formGroup: SpecialFormGroup = this.formBuilder.group(
|
|
27
|
+
this.formField.fields()
|
|
28
|
+
);
|
|
29
|
+
reloadCheck = true;
|
|
30
|
+
sub = new Subscription();
|
|
31
|
+
settingsForm: SpecialFormGroup;
|
|
32
|
+
control: SpecialFormGroup;
|
|
33
|
+
field: IFormStructure;
|
|
34
|
+
|
|
35
|
+
constructor(
|
|
36
|
+
private formBuilder: SpecialFormBuilderService,
|
|
37
|
+
public dialogRef: MatDialogRef<ControlDialogComponent>
|
|
38
|
+
) {}
|
|
39
|
+
|
|
40
|
+
ngOnInit(): void {
|
|
41
|
+
let settingsCreator: CommonFormCreator;
|
|
42
|
+
this.formGroup
|
|
43
|
+
.get('type')
|
|
44
|
+
.valueChanges.pipe(
|
|
45
|
+
filter((type) => !!type),
|
|
46
|
+
tap((type) => (settingsCreator = this.settingsCreation(type))),
|
|
47
|
+
map(
|
|
48
|
+
() =>
|
|
49
|
+
this.formBuilder.group(settingsCreator.settingsFields(), {
|
|
50
|
+
label: 'Configuración',
|
|
51
|
+
}) as SpecialFormGroup
|
|
52
|
+
),
|
|
53
|
+
tap(() => (this.reloadCheck = false)),
|
|
54
|
+
debounceTime(20),
|
|
55
|
+
tap(() => (this.reloadCheck = true)),
|
|
56
|
+
switchMap((settingsForm) => {
|
|
57
|
+
this.formGroup.setControl('settings', settingsForm);
|
|
58
|
+
return this.formGroup.valueChanges;
|
|
59
|
+
}),
|
|
60
|
+
debounceTime(20)
|
|
61
|
+
)
|
|
62
|
+
.subscribe((rawField) => {
|
|
63
|
+
this.field = this.formField.getField(
|
|
64
|
+
rawField,
|
|
65
|
+
settingsCreator.getSettings(rawField.settings)
|
|
66
|
+
);
|
|
67
|
+
this.control = this.formBuilder.group(this.field);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
settingsCreation(type: EControlTypes): CommonFormCreator {
|
|
72
|
+
switch (type) {
|
|
73
|
+
case EControlTypes.input:
|
|
74
|
+
return new InputFormClass();
|
|
75
|
+
case EControlTypes.dropdown:
|
|
76
|
+
return new DropDownFormClass();
|
|
77
|
+
case EControlTypes.autocomplete:
|
|
78
|
+
case EControlTypes.multiple:
|
|
79
|
+
return new AutocompleteFormClass();
|
|
80
|
+
case EControlTypes.date:
|
|
81
|
+
return new DatePickerFormClass();
|
|
82
|
+
case EControlTypes.checkbox:
|
|
83
|
+
return new CheckboxFormClass();
|
|
84
|
+
case EControlTypes.upload:
|
|
85
|
+
return new UploadFormClass();
|
|
86
|
+
default:
|
|
87
|
+
return new TextAreaFormClass();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
addControl() {
|
|
92
|
+
this.dialogRef.close(this.field);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
cancel() {
|
|
96
|
+
this.dialogRef.close();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
ngOnDestroy() {
|
|
100
|
+
this.sub.unsubscribe();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { IAutocompleteSettings } from '@lib/components/special-autocomplete/special-autocomplete.interface';
|
|
2
|
+
import { EControlTypes } from '@lib/core/aux-data/control-types.enum';
|
|
3
|
+
import { IFormStructure } from '@lib/core/interfaces/form.interfaces';
|
|
4
|
+
import { Subject } from 'rxjs';
|
|
5
|
+
import { CommonFormClass } from './common.form';
|
|
6
|
+
import { CommonFormCreator } from './common.form.interface';
|
|
7
|
+
|
|
8
|
+
interface IAutocompleteSettingsFormData {
|
|
9
|
+
source: { id: string; name: string; image?: string }[];
|
|
10
|
+
icon: { name: string };
|
|
11
|
+
}
|
|
12
|
+
export class AutocompleteFormClass
|
|
13
|
+
extends CommonFormClass
|
|
14
|
+
implements CommonFormCreator
|
|
15
|
+
{
|
|
16
|
+
public settingsFields(): IFormStructure {
|
|
17
|
+
return {
|
|
18
|
+
source: {
|
|
19
|
+
label: 'Data del campo',
|
|
20
|
+
styleClasses: 'px-2 box-border md:w-2/4',
|
|
21
|
+
type: EControlTypes.array,
|
|
22
|
+
settings: {
|
|
23
|
+
withActionButtons: true,
|
|
24
|
+
withFormHeader: true,
|
|
25
|
+
formFields: {
|
|
26
|
+
id: {
|
|
27
|
+
type: EControlTypes.input,
|
|
28
|
+
label: 'id',
|
|
29
|
+
styleClasses: 'col-span-12 md:col-span-4',
|
|
30
|
+
required: true,
|
|
31
|
+
},
|
|
32
|
+
name: {
|
|
33
|
+
type: EControlTypes.input,
|
|
34
|
+
label: 'Nombre',
|
|
35
|
+
styleClasses: 'col-span-12 md:col-span-4',
|
|
36
|
+
required: true,
|
|
37
|
+
},
|
|
38
|
+
image: {
|
|
39
|
+
type: EControlTypes.input,
|
|
40
|
+
label: 'Imagen',
|
|
41
|
+
styleClasses: 'col-span-12 md:col-span-4',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
fieldId: {
|
|
47
|
+
type: EControlTypes.default,
|
|
48
|
+
defaultValue: 'id',
|
|
49
|
+
},
|
|
50
|
+
fieldName: {
|
|
51
|
+
type: EControlTypes.default,
|
|
52
|
+
defaultValue: 'name',
|
|
53
|
+
},
|
|
54
|
+
fieldImage: {
|
|
55
|
+
type: EControlTypes.default,
|
|
56
|
+
defaultValue: 'image',
|
|
57
|
+
},
|
|
58
|
+
icon: this.iconField('Icono derecho'),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
public getSettings({
|
|
62
|
+
icon,
|
|
63
|
+
source,
|
|
64
|
+
}: IAutocompleteSettingsFormData): IAutocompleteSettings {
|
|
65
|
+
const source$ = new Subject<any[]>();
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
source: source$.asObservable(),
|
|
69
|
+
getData: (query) => {
|
|
70
|
+
const filteredData = source
|
|
71
|
+
.filter((item) => item.name.includes(query))
|
|
72
|
+
.slice(0, 10);
|
|
73
|
+
|
|
74
|
+
source$.next(filteredData);
|
|
75
|
+
},
|
|
76
|
+
fieldId: 'id',
|
|
77
|
+
fieldName: 'name',
|
|
78
|
+
icon: icon?.name,
|
|
79
|
+
iconAction: (value) => {
|
|
80
|
+
console.log('ICON ACTION ' + value);
|
|
81
|
+
},
|
|
82
|
+
onSelect: (value) => {
|
|
83
|
+
console.log('ICON ACTION ' + value);
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ICheckboxSettings } from "@lib/components/special-checkbox/special-checkbox.interface";
|
|
2
|
+
import { EControlTypes } from "@lib/core/aux-data/control-types.enum";
|
|
3
|
+
import { IFormStructure } from "@lib/core/interfaces/form.interfaces";
|
|
4
|
+
import { of } from "rxjs";
|
|
5
|
+
import { CommonFormClass } from "./common.form";
|
|
6
|
+
import { CommonFormCreator } from "./common.form.interface";
|
|
7
|
+
|
|
8
|
+
interface ICheckboxSettingsFormData {
|
|
9
|
+
labelPosition?: 'before' | 'after';
|
|
10
|
+
indeterminate?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export class CheckboxFormClass
|
|
13
|
+
extends CommonFormClass
|
|
14
|
+
implements CommonFormCreator
|
|
15
|
+
{
|
|
16
|
+
public settingsFields(): IFormStructure {
|
|
17
|
+
return {
|
|
18
|
+
labelPosition: {
|
|
19
|
+
label: 'Data del campo',
|
|
20
|
+
styleClasses: 'px-2 box-border md:w-2/4',
|
|
21
|
+
type: EControlTypes.dropdown,
|
|
22
|
+
settings: {
|
|
23
|
+
source: of([
|
|
24
|
+
{
|
|
25
|
+
name: 'before',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'after',
|
|
29
|
+
},
|
|
30
|
+
]),
|
|
31
|
+
fieldId: 'name',
|
|
32
|
+
fieldName: 'name',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
indeterminate: {
|
|
36
|
+
label: 'Ideterminado',
|
|
37
|
+
type: EControlTypes.checkbox,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public getSettings({
|
|
43
|
+
indeterminate,
|
|
44
|
+
labelPosition,
|
|
45
|
+
}: ICheckboxSettingsFormData): ICheckboxSettings {
|
|
46
|
+
return {
|
|
47
|
+
indeterminate,
|
|
48
|
+
labelPosition,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IAutocompleteSettings } from '@lib/components/special-autocomplete/special-autocomplete.interface';
|
|
2
|
+
import { ICheckboxSettings } from '@lib/components/special-checkbox/special-checkbox.interface';
|
|
3
|
+
import { IDatePickerSettings } from '@lib/components/special-datepicker/special-datepicker.interface';
|
|
4
|
+
import { IDropdownSettings } from '@lib/components/special-dropdown/special-dropdown.interface';
|
|
5
|
+
import { IInputSettings } from '@lib/components/special-input/special-input.interface';
|
|
6
|
+
import { ILabelSettings } from '@lib/components/special-label/special-label.interface';
|
|
7
|
+
import { ITextAreaSettings } from '@lib/components/special-text-area/special-text-area.interface';
|
|
8
|
+
import { IUploadSettings } from '@lib/components/special-upload/special-upload.interface';
|
|
9
|
+
import { IFormStructure } from '@lib/core/interfaces/form.interfaces';
|
|
10
|
+
|
|
11
|
+
export type AllControlSettings =
|
|
12
|
+
| ICheckboxSettings
|
|
13
|
+
| IDropdownSettings
|
|
14
|
+
| IInputSettings
|
|
15
|
+
| IDatePickerSettings
|
|
16
|
+
| ILabelSettings
|
|
17
|
+
| IUploadSettings
|
|
18
|
+
| ITextAreaSettings
|
|
19
|
+
| IAutocompleteSettings;
|
|
20
|
+
|
|
21
|
+
export interface CommonFormCreator {
|
|
22
|
+
settingsFields?(): IFormStructure;
|
|
23
|
+
getSettings(data: any): AllControlSettings;
|
|
24
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ICON_NAMES } from '@lib/core/aux-data/all-icons';
|
|
2
|
+
import { EControlTypes } from '@lib/core/aux-data/control-types.enum';
|
|
3
|
+
import { TRawFields } from '@lib/core/interfaces/form.interfaces';
|
|
4
|
+
import { Subject } from 'rxjs';
|
|
5
|
+
|
|
6
|
+
export class CommonFormClass {
|
|
7
|
+
protected iconField(label:string): Partial<TRawFields> {
|
|
8
|
+
const iconSUb = new Subject<any[]>();
|
|
9
|
+
return {
|
|
10
|
+
placeholder: 'Buscar',
|
|
11
|
+
label,
|
|
12
|
+
tooltip: 'Selecciona una opción',
|
|
13
|
+
styleClasses: 'px-2 box-border md:w-2/4',
|
|
14
|
+
icon: 'format_italic',
|
|
15
|
+
type: EControlTypes.autocomplete,
|
|
16
|
+
settings: {
|
|
17
|
+
fieldId: 'name',
|
|
18
|
+
fieldName: 'name',
|
|
19
|
+
source: iconSUb.asObservable(),
|
|
20
|
+
getData: (query) => {
|
|
21
|
+
const filteredIcons = ICON_NAMES.filter((icon) =>
|
|
22
|
+
icon.includes(query)
|
|
23
|
+
)
|
|
24
|
+
.slice(0, 10)
|
|
25
|
+
.map((icon) => ({ name: icon }));
|
|
26
|
+
iconSUb.next(filteredIcons);
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
|
|
2
|
+
import { IDatePickerSettings } from '@lib/components/special-datepicker/special-datepicker.interface';
|
|
3
|
+
import { EControlTypes } from '@lib/core/aux-data/control-types.enum';
|
|
4
|
+
import { IFormStructure } from '@lib/core/interfaces/form.interfaces';
|
|
5
|
+
import { numberMask } from '@lib/core/masks/number.mask';
|
|
6
|
+
import { CommonFormClass } from './common.form';
|
|
7
|
+
import { CommonFormCreator } from './common.form.interface';
|
|
8
|
+
|
|
9
|
+
interface IDatePickerSettingsFormData {
|
|
10
|
+
lowerLimit: number;
|
|
11
|
+
upperLimit: number;
|
|
12
|
+
startAt: Date;
|
|
13
|
+
}
|
|
14
|
+
export class DatePickerFormClass
|
|
15
|
+
extends CommonFormClass
|
|
16
|
+
implements CommonFormCreator
|
|
17
|
+
{
|
|
18
|
+
public settingsFields(): IFormStructure {
|
|
19
|
+
return {
|
|
20
|
+
lowerLimit: {
|
|
21
|
+
label: 'Límite inferior',
|
|
22
|
+
styleClasses: 'px-2 box-border md:w-2/4',
|
|
23
|
+
type: EControlTypes.input,
|
|
24
|
+
settings: {
|
|
25
|
+
mask: numberMask(10000000000000),
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
upperLimit: {
|
|
29
|
+
label: 'Límite superior',
|
|
30
|
+
styleClasses: 'px-2 box-border md:w-2/4',
|
|
31
|
+
type: EControlTypes.input,
|
|
32
|
+
settings: {
|
|
33
|
+
mask: numberMask(10000000000000),
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
startAt: {
|
|
37
|
+
label: 'Empezar en',
|
|
38
|
+
styleClasses: 'px-2 box-border md:w-2/4',
|
|
39
|
+
type: EControlTypes.dropdown,
|
|
40
|
+
},
|
|
41
|
+
icon: this.iconField('Icono derecho'),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public getSettings({
|
|
46
|
+
lowerLimit,
|
|
47
|
+
startAt,
|
|
48
|
+
upperLimit,
|
|
49
|
+
}: IDatePickerSettingsFormData): IDatePickerSettings {
|
|
50
|
+
return {
|
|
51
|
+
lowerLimit,
|
|
52
|
+
startAt,
|
|
53
|
+
upperLimit,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { IDropdownSettings } from '@lib/components/special-dropdown/special-dropdown.interface';
|
|
2
|
+
import { EControlTypes } from '@lib/core/aux-data/control-types.enum';
|
|
3
|
+
import { IFormStructure } from '@lib/core/interfaces/form.interfaces';
|
|
4
|
+
import { of } from 'rxjs';
|
|
5
|
+
|
|
6
|
+
import { CommonFormClass } from './common.form';
|
|
7
|
+
import { CommonFormCreator } from './common.form.interface';
|
|
8
|
+
|
|
9
|
+
interface IDropdownSettingsFormData {
|
|
10
|
+
source: { id: string; name: string }[];
|
|
11
|
+
notSelectedText: string;
|
|
12
|
+
icon: { name: string };
|
|
13
|
+
}
|
|
14
|
+
export class DropDownFormClass
|
|
15
|
+
extends CommonFormClass
|
|
16
|
+
implements CommonFormCreator
|
|
17
|
+
{
|
|
18
|
+
public settingsFields(): IFormStructure {
|
|
19
|
+
return {
|
|
20
|
+
source: {
|
|
21
|
+
label: 'Data del campo',
|
|
22
|
+
styleClasses: 'px-2 box-border md:w-2/4',
|
|
23
|
+
type: EControlTypes.array,
|
|
24
|
+
settings: {
|
|
25
|
+
withActionButtons: true,
|
|
26
|
+
withFormHeader: true,
|
|
27
|
+
formFields: {
|
|
28
|
+
id: {
|
|
29
|
+
type: EControlTypes.input,
|
|
30
|
+
label: 'Id',
|
|
31
|
+
styleClasses: 'col-span-12 md:col-span-6',
|
|
32
|
+
required: true,
|
|
33
|
+
},
|
|
34
|
+
name: {
|
|
35
|
+
type: EControlTypes.input,
|
|
36
|
+
label: 'Nombre',
|
|
37
|
+
styleClasses: 'col-span-12 md:col-span-6',
|
|
38
|
+
required: true,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
fieldId: {
|
|
44
|
+
type: EControlTypes.default,
|
|
45
|
+
defaultValue: 'id',
|
|
46
|
+
},
|
|
47
|
+
fieldName: {
|
|
48
|
+
type: EControlTypes.default,
|
|
49
|
+
defaultValue: 'name',
|
|
50
|
+
},
|
|
51
|
+
notSelectedText: {
|
|
52
|
+
placeholder: '',
|
|
53
|
+
label: 'Label de no seleccion',
|
|
54
|
+
styleClasses: 'px-2 box-border md:w-2/4',
|
|
55
|
+
type: EControlTypes.input,
|
|
56
|
+
},
|
|
57
|
+
icon: this.iconField('Icono derecho'),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public getSettings({
|
|
62
|
+
icon,
|
|
63
|
+
notSelectedText,
|
|
64
|
+
source,
|
|
65
|
+
}: IDropdownSettingsFormData): IDropdownSettings {
|
|
66
|
+
return {
|
|
67
|
+
source: of(source),
|
|
68
|
+
fieldId: 'id',
|
|
69
|
+
fieldName: 'name',
|
|
70
|
+
notSelectedText,
|
|
71
|
+
icon: icon?.name,
|
|
72
|
+
iconAction: (value) => {
|
|
73
|
+
console.log('ICON ACTION ' + value);
|
|
74
|
+
},
|
|
75
|
+
onSelect: (value) => {
|
|
76
|
+
console.log('ICON ACTION ' + value);
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|