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,189 @@
|
|
|
1
|
+
import { IInputSettings } from '@lib/components/special-input/special-input.interface';
|
|
2
|
+
import { EControlTypes } from '@lib/core/aux-data/control-types.enum';
|
|
3
|
+
import {
|
|
4
|
+
IFormStructure,
|
|
5
|
+
TSpecialFields,
|
|
6
|
+
} from '@lib/core/interfaces/form.interfaces';
|
|
7
|
+
import { Masks } from '@lib/core/masks/maks.enum';
|
|
8
|
+
import { numberMask } from '@lib/core/masks/number.mask';
|
|
9
|
+
import { EnumToArray } from '@lib/core/utils/enum-to-array.util';
|
|
10
|
+
import { InputmaskOptions } from '@ngneat/input-mask';
|
|
11
|
+
import { of } from 'rxjs';
|
|
12
|
+
import { CommonFormClass } from './common.form';
|
|
13
|
+
import { AllControlSettings, CommonFormCreator } from './common.form.interface';
|
|
14
|
+
|
|
15
|
+
interface IFieldFormData {
|
|
16
|
+
type: any;
|
|
17
|
+
placeholder: string;
|
|
18
|
+
label: string;
|
|
19
|
+
name: string;
|
|
20
|
+
tooltip: string;
|
|
21
|
+
icon: { name: string };
|
|
22
|
+
length: number;
|
|
23
|
+
required: boolean;
|
|
24
|
+
readOnly: boolean;
|
|
25
|
+
hidden: boolean;
|
|
26
|
+
disabled: boolean;
|
|
27
|
+
errorMessages: { key: string; value: string }[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class FieldFormClass extends CommonFormClass {
|
|
31
|
+
public fields(): IFormStructure {
|
|
32
|
+
return {
|
|
33
|
+
type: {
|
|
34
|
+
placeholder: 'Selecciona el tipo de control',
|
|
35
|
+
label: 'Tipo de control',
|
|
36
|
+
styleClasses: 'px-2 box-border md:w-2/4',
|
|
37
|
+
required: true,
|
|
38
|
+
type: EControlTypes.dropdown,
|
|
39
|
+
settings: {
|
|
40
|
+
fieldId: 'value',
|
|
41
|
+
fieldName: 'value',
|
|
42
|
+
source: of(
|
|
43
|
+
EnumToArray(EControlTypes).filter(
|
|
44
|
+
(type) =>
|
|
45
|
+
![
|
|
46
|
+
EControlTypes.array,
|
|
47
|
+
EControlTypes.form,
|
|
48
|
+
EControlTypes.default,
|
|
49
|
+
EControlTypes.pkey,
|
|
50
|
+
EControlTypes.time,
|
|
51
|
+
].includes(type.value)
|
|
52
|
+
)
|
|
53
|
+
),
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
placeholder: {
|
|
57
|
+
placeholder: '',
|
|
58
|
+
label: 'Placeholder',
|
|
59
|
+
styleClasses: 'px-2 box-border md:w-2/4',
|
|
60
|
+
type: EControlTypes.input,
|
|
61
|
+
settings: {},
|
|
62
|
+
},
|
|
63
|
+
label: {
|
|
64
|
+
placeholder: '',
|
|
65
|
+
label: 'Etiqueta',
|
|
66
|
+
styleClasses: 'px-2 box-border md:w-2/4',
|
|
67
|
+
type: EControlTypes.input,
|
|
68
|
+
settings: {},
|
|
69
|
+
},
|
|
70
|
+
name: {
|
|
71
|
+
placeholder: '',
|
|
72
|
+
label: 'Nombre del campo',
|
|
73
|
+
styleClasses: 'px-2 box-border md:w-2/4',
|
|
74
|
+
required: true,
|
|
75
|
+
type: EControlTypes.input,
|
|
76
|
+
settings: {},
|
|
77
|
+
},
|
|
78
|
+
tooltip: {
|
|
79
|
+
placeholder: '',
|
|
80
|
+
label: 'Mensaje de ayuda',
|
|
81
|
+
styleClasses: 'px-2 box-border md:w-2/4',
|
|
82
|
+
type: EControlTypes.input,
|
|
83
|
+
settings: {},
|
|
84
|
+
},
|
|
85
|
+
length: {
|
|
86
|
+
placeholder: '',
|
|
87
|
+
label: 'Largo permitido',
|
|
88
|
+
styleClasses: 'px-2 box-border md:w-2/4',
|
|
89
|
+
type: EControlTypes.input,
|
|
90
|
+
settings: {
|
|
91
|
+
mask: numberMask(),
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
icon: this.iconField('Icono'),
|
|
95
|
+
required: {
|
|
96
|
+
label: 'Campo requerido',
|
|
97
|
+
styleClasses: 'px-2 box-border md:w-1/4',
|
|
98
|
+
type: EControlTypes.checkbox,
|
|
99
|
+
icon: 'task_alt',
|
|
100
|
+
defaultValue: false,
|
|
101
|
+
settings: {},
|
|
102
|
+
},
|
|
103
|
+
readOnly: {
|
|
104
|
+
label: 'Campo de solo lectura',
|
|
105
|
+
styleClasses: 'px-2 box-border md:w-1/4',
|
|
106
|
+
type: EControlTypes.checkbox,
|
|
107
|
+
icon: 'edit_off',
|
|
108
|
+
defaultValue: false,
|
|
109
|
+
settings: {},
|
|
110
|
+
},
|
|
111
|
+
hidden: {
|
|
112
|
+
label: 'Campo escondido',
|
|
113
|
+
icon: 'visibility_off',
|
|
114
|
+
styleClasses: 'px-2 box-border md:w-1/4',
|
|
115
|
+
type: EControlTypes.checkbox,
|
|
116
|
+
defaultValue: false,
|
|
117
|
+
settings: {},
|
|
118
|
+
},
|
|
119
|
+
disabled: {
|
|
120
|
+
label: 'Campo desactivado',
|
|
121
|
+
styleClasses: 'px-2 box-border md:w-1/4',
|
|
122
|
+
type: EControlTypes.checkbox,
|
|
123
|
+
icon: 'block',
|
|
124
|
+
defaultValue: false,
|
|
125
|
+
settings: {},
|
|
126
|
+
},
|
|
127
|
+
errorMessages: {
|
|
128
|
+
type: EControlTypes.array,
|
|
129
|
+
label: 'Mensajes de error',
|
|
130
|
+
settings: {
|
|
131
|
+
withFormHeader: true,
|
|
132
|
+
withActionButtons: true,
|
|
133
|
+
formFields: {
|
|
134
|
+
key: {
|
|
135
|
+
type: EControlTypes.input,
|
|
136
|
+
label: 'Key',
|
|
137
|
+
styleClasses: 'col-span-12 md:col-span-6',
|
|
138
|
+
required: true,
|
|
139
|
+
},
|
|
140
|
+
value: {
|
|
141
|
+
type: EControlTypes.input,
|
|
142
|
+
label: 'value',
|
|
143
|
+
styleClasses: 'col-span-12 md:col-span-6',
|
|
144
|
+
required: true,
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
public getField(
|
|
153
|
+
{
|
|
154
|
+
disabled,
|
|
155
|
+
errorMessages,
|
|
156
|
+
hidden,
|
|
157
|
+
icon,
|
|
158
|
+
label,
|
|
159
|
+
length,
|
|
160
|
+
name,
|
|
161
|
+
placeholder,
|
|
162
|
+
readOnly,
|
|
163
|
+
required,
|
|
164
|
+
tooltip,
|
|
165
|
+
type,
|
|
166
|
+
}: IFieldFormData,
|
|
167
|
+
settings: AllControlSettings
|
|
168
|
+
): IFormStructure {
|
|
169
|
+
return {
|
|
170
|
+
[name || 'default']: {
|
|
171
|
+
type,
|
|
172
|
+
settings,
|
|
173
|
+
disabled,
|
|
174
|
+
hidden,
|
|
175
|
+
icon: icon?.name,
|
|
176
|
+
label,
|
|
177
|
+
length,
|
|
178
|
+
placeholder,
|
|
179
|
+
readOnly,
|
|
180
|
+
required,
|
|
181
|
+
tooltip,
|
|
182
|
+
errorMessages: errorMessages.reduce(
|
|
183
|
+
(prev, curr) => ({ ...prev, [curr.key]: curr.value }),
|
|
184
|
+
{}
|
|
185
|
+
),
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { IInputSettings } from '@lib/components/special-input/special-input.interface';
|
|
2
|
+
import { EControlTypes } from '@lib/core/aux-data/control-types.enum';
|
|
3
|
+
import { InputTypes } from '@lib/core/aux-data/input-types';
|
|
4
|
+
import { IFormStructure } from '@lib/core/interfaces/form.interfaces';
|
|
5
|
+
import { Masks } from '@lib/core/masks/maks.enum';
|
|
6
|
+
import { InputmaskOptions } from '@ngneat/input-mask';
|
|
7
|
+
import { of } from 'rxjs';
|
|
8
|
+
import { CommonFormClass } from './common.form';
|
|
9
|
+
import { CommonFormCreator } from './common.form.interface';
|
|
10
|
+
|
|
11
|
+
interface IInputSettingsFormData {
|
|
12
|
+
type: string;
|
|
13
|
+
mask: InputmaskOptions<any>;
|
|
14
|
+
icon: { name: string };
|
|
15
|
+
}
|
|
16
|
+
export class InputFormClass
|
|
17
|
+
extends CommonFormClass
|
|
18
|
+
implements CommonFormCreator
|
|
19
|
+
{
|
|
20
|
+
public settingsFields(): IFormStructure {
|
|
21
|
+
return {
|
|
22
|
+
type: {
|
|
23
|
+
placeholder: 'Tipo de control',
|
|
24
|
+
label: 'Tipo de control',
|
|
25
|
+
styleClasses: 'px-2 box-border md:w-2/4',
|
|
26
|
+
type: EControlTypes.dropdown,
|
|
27
|
+
settings: {
|
|
28
|
+
fieldId: 'value',
|
|
29
|
+
fieldName: 'value',
|
|
30
|
+
source: of(InputTypes.map((type) => ({ value: type }))),
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
mask: {
|
|
34
|
+
placeholder: 'Máscara',
|
|
35
|
+
label: 'Tipo de máscara',
|
|
36
|
+
styleClasses: 'px-2 box-border md:w-2/4',
|
|
37
|
+
type: EControlTypes.dropdown,
|
|
38
|
+
settings: {
|
|
39
|
+
fieldId: 'value',
|
|
40
|
+
fieldName: 'key',
|
|
41
|
+
notSelectedText: 'Sin máscara',
|
|
42
|
+
source: of(
|
|
43
|
+
Object.entries(Masks).map(([key, value]) => ({ key, value }))
|
|
44
|
+
),
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
icon: this.iconField('Icono derecho'),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public getSettings({
|
|
52
|
+
icon,
|
|
53
|
+
mask,
|
|
54
|
+
type,
|
|
55
|
+
}: IInputSettingsFormData): IInputSettings {
|
|
56
|
+
return {
|
|
57
|
+
mask,
|
|
58
|
+
onBlur: (value) => {
|
|
59
|
+
console.log('ON BLUR ' + value);
|
|
60
|
+
},
|
|
61
|
+
onEnter: (value) => {
|
|
62
|
+
console.log('ON ENTER ' + value);
|
|
63
|
+
},
|
|
64
|
+
icon: icon?.name,
|
|
65
|
+
iconAction: (value) => {
|
|
66
|
+
console.log('ICON ACTION ' + value);
|
|
67
|
+
},
|
|
68
|
+
type,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { IDropdownSettings } from '@lib/components/special-dropdown/special-dropdown.interface';
|
|
2
|
+
import { ILabelSettings } from '@lib/components/special-label/special-label.interface';
|
|
3
|
+
import { EControlTypes } from '@lib/core/aux-data/control-types.enum';
|
|
4
|
+
import { IFormStructure } from '@lib/core/interfaces/form.interfaces';
|
|
5
|
+
import { of } from 'rxjs';
|
|
6
|
+
|
|
7
|
+
import { CommonFormClass } from './common.form';
|
|
8
|
+
import { CommonFormCreator } from './common.form.interface';
|
|
9
|
+
|
|
10
|
+
export class LabelFormClass
|
|
11
|
+
extends CommonFormClass
|
|
12
|
+
implements CommonFormCreator
|
|
13
|
+
{
|
|
14
|
+
public settingsFields(): IFormStructure {
|
|
15
|
+
return {
|
|
16
|
+
isLink: {
|
|
17
|
+
label: 'Ideterminado',
|
|
18
|
+
type: EControlTypes.checkbox,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public getSettings({ isLink }: { isLink: boolean }): ILabelSettings {
|
|
24
|
+
return {
|
|
25
|
+
isLink,
|
|
26
|
+
onClickLink: () => {
|
|
27
|
+
console.log('LINK');
|
|
28
|
+
},
|
|
29
|
+
pipe: () => 'value',
|
|
30
|
+
stylesPipe: () => '',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ITextAreaSettings } from '@lib/components/special-text-area/special-text-area.interface';
|
|
2
|
+
import { IFormStructure } from '@lib/core/interfaces/form.interfaces';
|
|
3
|
+
import { CommonFormClass } from './common.form';
|
|
4
|
+
import { CommonFormCreator } from './common.form.interface';
|
|
5
|
+
|
|
6
|
+
export class TextAreaFormClass
|
|
7
|
+
extends CommonFormClass
|
|
8
|
+
implements CommonFormCreator
|
|
9
|
+
{
|
|
10
|
+
public settingsFields(): IFormStructure {
|
|
11
|
+
return {};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public getSettings({}): ITextAreaSettings {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IUploadSettings } from '@lib/components/special-upload/special-upload.interface';
|
|
2
|
+
import { EControlTypes } from '@lib/core/aux-data/control-types.enum';
|
|
3
|
+
import { IFormStructure } from '@lib/core/interfaces/form.interfaces';
|
|
4
|
+
import { CommonFormClass } from './common.form';
|
|
5
|
+
import { CommonFormCreator } from './common.form.interface';
|
|
6
|
+
|
|
7
|
+
export class UploadFormClass
|
|
8
|
+
extends CommonFormClass
|
|
9
|
+
implements CommonFormCreator
|
|
10
|
+
{
|
|
11
|
+
public settingsFields(): IFormStructure {
|
|
12
|
+
return {
|
|
13
|
+
accept: {
|
|
14
|
+
label: 'Documentos aceptados',
|
|
15
|
+
styleClasses: 'px-2 box-border md:w-2/4',
|
|
16
|
+
type: EControlTypes.input,
|
|
17
|
+
settings: {},
|
|
18
|
+
},
|
|
19
|
+
multiple: {
|
|
20
|
+
label: 'Multiple',
|
|
21
|
+
type: EControlTypes.checkbox,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public getSettings({
|
|
27
|
+
accept,
|
|
28
|
+
multiple,
|
|
29
|
+
}: IUploadSettings): IUploadSettings {
|
|
30
|
+
return {
|
|
31
|
+
accept,
|
|
32
|
+
multiple
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<div class="{{ theme }}">
|
|
2
|
+
<div class="p-5">
|
|
3
|
+
<button mat-stroked-button color="primary" (click)="addControl()">
|
|
4
|
+
Agregar control
|
|
5
|
+
</button>
|
|
6
|
+
</div>
|
|
7
|
+
<div>
|
|
8
|
+
<div
|
|
9
|
+
*ngIf="formGroup$ | async as formGroup"
|
|
10
|
+
cdkDropList
|
|
11
|
+
(cdkDropListDropped)="drop($event)"
|
|
12
|
+
class="w-full flex flex-wrap"
|
|
13
|
+
>
|
|
14
|
+
<div
|
|
15
|
+
cdkDrag
|
|
16
|
+
class="control-wrapper {{ control.styleClasses }}"
|
|
17
|
+
*ngFor="
|
|
18
|
+
let control of formGroup.controls | controlsList;
|
|
19
|
+
trackBy: trackByFn;
|
|
20
|
+
"
|
|
21
|
+
>
|
|
22
|
+
<button mat-button (click)="close(control.name)" class="close" color="warn">
|
|
23
|
+
Delete
|
|
24
|
+
</button>
|
|
25
|
+
<div class="control">
|
|
26
|
+
<ng-template controlRender [control]="control"></ng-template>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<div class="p-5">
|
|
33
|
+
<button mat-stroked-button color="primary" (click)="generate()">
|
|
34
|
+
Generar
|
|
35
|
+
</button>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
@import "../../assets/styles.scss";
|
|
2
|
+
|
|
3
|
+
.dark-theme {
|
|
4
|
+
background: linear-gradient(
|
|
5
|
+
93deg,
|
|
6
|
+
rgba(0, 0, 0, 1) 0%,
|
|
7
|
+
rgba(29, 43, 69, 1) 0%,
|
|
8
|
+
rgba(27, 15, 46, 1) 100%
|
|
9
|
+
);
|
|
10
|
+
.text {
|
|
11
|
+
color: rgb(200, 200, 200);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.light-theme {
|
|
16
|
+
background-color: white;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.control-wrapper {
|
|
20
|
+
display: grid;
|
|
21
|
+
grid-template-columns: 1fr 1fr 1fr;
|
|
22
|
+
grid-template-rows: auto 1rem auto;
|
|
23
|
+
padding: 1rem 1rem 0;
|
|
24
|
+
border: 2px solid rgb(20 83 45);
|
|
25
|
+
color: rgb(200, 200, 200);
|
|
26
|
+
|
|
27
|
+
.close {
|
|
28
|
+
grid-column: 3 / span 1;
|
|
29
|
+
grid-row: 1 / span 1;
|
|
30
|
+
justify-self: end;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.control {
|
|
34
|
+
grid-column: 1 / span 3;
|
|
35
|
+
grid-row: 3 / span 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&:hover {
|
|
39
|
+
cursor: move;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { FormGroupViewerComponent } from './form-group-viewer.component';
|
|
3
|
+
|
|
4
|
+
describe('FormGroupViewerComponent', () => {
|
|
5
|
+
let component: FormGroupViewerComponent;
|
|
6
|
+
let fixture: ComponentFixture<FormGroupViewerComponent>;
|
|
7
|
+
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
await TestBed.configureTestingModule({
|
|
10
|
+
declarations: [ FormGroupViewerComponent ]
|
|
11
|
+
})
|
|
12
|
+
.compileComponents();
|
|
13
|
+
|
|
14
|
+
fixture = TestBed.createComponent(FormGroupViewerComponent);
|
|
15
|
+
component = fixture.componentInstance;
|
|
16
|
+
fixture.detectChanges();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should create', () => {
|
|
20
|
+
expect(component).toBeTruthy();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
|
|
2
|
+
import {
|
|
3
|
+
Component,
|
|
4
|
+
EventEmitter,
|
|
5
|
+
Input,
|
|
6
|
+
OnInit,
|
|
7
|
+
Output,
|
|
8
|
+
ViewEncapsulation,
|
|
9
|
+
} from '@angular/core';
|
|
10
|
+
import { AbstractControl } from '@angular/forms';
|
|
11
|
+
import { MatDialog } from '@angular/material/dialog';
|
|
12
|
+
import { BehaviorSubject, filter, map, Subject } from 'rxjs';
|
|
13
|
+
import { EControlTypes } from '../../core/aux-data/control-types.enum';
|
|
14
|
+
import { SpecialFormGroup } from '../../core/forms/special-forms';
|
|
15
|
+
import { IFormStructure } from '../../core/interfaces/form.interfaces';
|
|
16
|
+
import { SpecialFormBuilderService } from '../../core/services';
|
|
17
|
+
import { ControlDialogComponent } from './components/control-dialog.component';
|
|
18
|
+
|
|
19
|
+
@Component({
|
|
20
|
+
selector: 'spf-form-group-viewer',
|
|
21
|
+
templateUrl: './form-group-viewer.component.html',
|
|
22
|
+
styleUrls: ['./form-group-viewer.component.scss'],
|
|
23
|
+
encapsulation: ViewEncapsulation.None,
|
|
24
|
+
})
|
|
25
|
+
export class FormGroupViewerComponent implements OnInit {
|
|
26
|
+
private fieldsSub: BehaviorSubject<IFormStructure> = new BehaviorSubject({});
|
|
27
|
+
formGroup$ = this.fieldsSub
|
|
28
|
+
.asObservable()
|
|
29
|
+
.pipe(map((fields) => this.specialFormBuilderService.group(fields)));
|
|
30
|
+
|
|
31
|
+
@Input('fields') set fieldSetter(fields: IFormStructure) {}
|
|
32
|
+
|
|
33
|
+
@Input() theme;
|
|
34
|
+
|
|
35
|
+
@Output() getData: EventEmitter<string> = new EventEmitter();
|
|
36
|
+
|
|
37
|
+
formGroup: SpecialFormGroup;
|
|
38
|
+
|
|
39
|
+
constructor(
|
|
40
|
+
private specialFormBuilderService: SpecialFormBuilderService,
|
|
41
|
+
public dialog: MatDialog
|
|
42
|
+
) {}
|
|
43
|
+
|
|
44
|
+
get controlTypes(): typeof EControlTypes {
|
|
45
|
+
return EControlTypes;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
ngOnInit(): void {}
|
|
49
|
+
|
|
50
|
+
addControl() {
|
|
51
|
+
const dialogRef = this.dialog.open(ControlDialogComponent, {
|
|
52
|
+
width: '80%',
|
|
53
|
+
maxWidth: '1440px',
|
|
54
|
+
maxHeight: '90vh',
|
|
55
|
+
panelClass: 'dialog-panel-no-padding',
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
dialogRef.afterClosed().subscribe((field: IFormStructure) => {
|
|
59
|
+
if (field) {
|
|
60
|
+
this.fieldsSub.next({
|
|
61
|
+
...this.fieldsSub.value,
|
|
62
|
+
...field,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
trackByFn(
|
|
69
|
+
_index: number,
|
|
70
|
+
{ name }: { name: string; control: AbstractControl }
|
|
71
|
+
) {
|
|
72
|
+
return name;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
drop(event: CdkDragDrop<string[]>) {
|
|
76
|
+
const currentFields = Object.entries(this.fieldsSub.value).map(
|
|
77
|
+
([key, value]) => ({ [key]: value })
|
|
78
|
+
);
|
|
79
|
+
moveItemInArray(currentFields, event.previousIndex, event.currentIndex);
|
|
80
|
+
const fields = currentFields.reduce((prev, curr) => {
|
|
81
|
+
return { ...prev, ...curr };
|
|
82
|
+
}, {});
|
|
83
|
+
this.fieldsSub.next(fields);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
close(name: string) {
|
|
87
|
+
const nextFields = { ...this.fieldsSub.value };
|
|
88
|
+
delete nextFields[name];
|
|
89
|
+
this.fieldsSub.next(nextFields);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
generate() {
|
|
93
|
+
console.log(JSON.stringify(this.fieldsSub.value));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { FormGroupViewerComponent } from './form-group-viewer.component';
|
|
4
|
+
import { SpecialFormBuilderService } from '../../core/services';
|
|
5
|
+
import { SpecialFormModule } from '../../components/special-form/special-form.module';
|
|
6
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
7
|
+
import { MatDialogModule } from '@angular/material/dialog';
|
|
8
|
+
import { ControlDialogComponent } from './components/control-dialog.component';
|
|
9
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
10
|
+
import { FormControlSelectorModule } from '../form-control-selector/form-control-selector.module';
|
|
11
|
+
import { FormControlsListPipeModule } from '@lib/pipes/controls-list-pipe/controls-list.pipe.module';
|
|
12
|
+
import { ControlsRenderDirectiveModule } from '@lib/core/directives/control-render.module';
|
|
13
|
+
import { DragDropModule } from '@angular/cdk/drag-drop';
|
|
14
|
+
|
|
15
|
+
@NgModule({
|
|
16
|
+
declarations: [FormGroupViewerComponent, ControlDialogComponent],
|
|
17
|
+
imports: [
|
|
18
|
+
ControlsRenderDirectiveModule,
|
|
19
|
+
FormControlsListPipeModule,
|
|
20
|
+
DragDropModule,
|
|
21
|
+
CommonModule,
|
|
22
|
+
SpecialFormModule,
|
|
23
|
+
MatButtonModule,
|
|
24
|
+
MatDialogModule,
|
|
25
|
+
MatButtonModule,
|
|
26
|
+
MatIconModule,
|
|
27
|
+
FormControlSelectorModule,
|
|
28
|
+
],
|
|
29
|
+
exports: [FormGroupViewerComponent],
|
|
30
|
+
providers: [SpecialFormBuilderService],
|
|
31
|
+
})
|
|
32
|
+
export class FormGroupViewerModule {}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { EControlTypes } from '@lib/core/aux-data/control-types.enum';
|
|
2
|
+
|
|
3
|
+
import { SpecialInputModule } from './special-input/special-input.module';
|
|
4
|
+
import { SpecialInputComponent } from './special-input/special-input.component';
|
|
5
|
+
|
|
6
|
+
import { SpecialDropdownModule } from './special-dropdown/special-dropdown.module';
|
|
7
|
+
import { SpecialDropdownComponent } from './special-dropdown/special-dropdown.component';
|
|
8
|
+
|
|
9
|
+
import { SpecialAutocompleteModule } from './special-autocomplete/special-autocomplete.module';
|
|
10
|
+
import { SpecialAutocompleteComponent } from './special-autocomplete/special-autocomplete.component';
|
|
11
|
+
|
|
12
|
+
import { SpecialDatepickerModule } from './special-datepicker/special-datepicker.module';
|
|
13
|
+
import { SpecialDatepickerComponent } from './special-datepicker/special-datepicker.component';
|
|
14
|
+
|
|
15
|
+
import { SpecialMultipleAutocompleteModule } from './special-multiple-autocomplete/special-multiple-autocomplete.module';
|
|
16
|
+
import { SpecialMultipleAutocompleteComponent } from './special-multiple-autocomplete/special-multiple-autocomplete.component';
|
|
17
|
+
|
|
18
|
+
import { SpecialCheckboxModule } from './special-checkbox/special-checkbox.module';
|
|
19
|
+
import { SpecialCheckboxComponent } from './special-checkbox/special-checkbox.component';
|
|
20
|
+
|
|
21
|
+
import { SpecialTextAreaModule } from './special-text-area/special-text-area.module';
|
|
22
|
+
import { SpecialTextAreaComponent } from './special-text-area/special-text-area.component';
|
|
23
|
+
|
|
24
|
+
import { SpecialUploadModule } from './special-upload/special-upload.module';
|
|
25
|
+
import { SpecialUploadComponent } from './special-upload/special-upload.component';
|
|
26
|
+
|
|
27
|
+
import { SpecialArrayModule } from './special-form/special-form-array.module';
|
|
28
|
+
|
|
29
|
+
import { SpecialLabelModule } from './special-label/special-label.module';
|
|
30
|
+
import { SpecialLabelComponent } from './special-label/special-label.component';
|
|
31
|
+
|
|
32
|
+
import { SpecialFormModule } from './special-form/special-form.module';
|
|
33
|
+
import {
|
|
34
|
+
SpecialFormComponent,
|
|
35
|
+
SpecialArrayComponent,
|
|
36
|
+
} from './special-form/special-form.component';
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
SpecialDatepickerComponent,
|
|
40
|
+
SpecialDatepickerModule,
|
|
41
|
+
SpecialAutocompleteComponent,
|
|
42
|
+
SpecialAutocompleteModule,
|
|
43
|
+
SpecialDropdownModule,
|
|
44
|
+
SpecialDropdownComponent,
|
|
45
|
+
SpecialMultipleAutocompleteModule,
|
|
46
|
+
SpecialMultipleAutocompleteComponent,
|
|
47
|
+
SpecialCheckboxModule,
|
|
48
|
+
SpecialCheckboxComponent,
|
|
49
|
+
SpecialTextAreaModule,
|
|
50
|
+
SpecialTextAreaComponent,
|
|
51
|
+
SpecialUploadModule,
|
|
52
|
+
SpecialUploadComponent,
|
|
53
|
+
SpecialArrayModule,
|
|
54
|
+
SpecialArrayComponent,
|
|
55
|
+
SpecialLabelComponent,
|
|
56
|
+
SpecialLabelModule,
|
|
57
|
+
SpecialFormComponent,
|
|
58
|
+
SpecialInputModule,
|
|
59
|
+
SpecialFormModule,
|
|
60
|
+
SpecialInputComponent,
|
|
61
|
+
};
|