form-dynamic-ajax 7.0.2

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/README.md ADDED
@@ -0,0 +1,423 @@
1
+ # FORM DYNAMIC ANGULAR
2
+
3
+ ![Version](https://img.shields.io/npm/v/form-dynamic-angular.svg )
4
+
5
+ ## Description
6
+ The form-dynamic is a solution whith objectve is minimize the coding in forms, so one json you can have mutch components in forms in primeng as: input (text and number), select, treeSelect, autocomplete, date, dateTime, textarea, checkbox, button, upload files, list e radioButton
7
+
8
+
9
+ | Lib version | Angular version
10
+ | :-------- | :-------
11
+ | `4.1.3` | `15.2.0`
12
+ | `5.0.6` | `17.0.0`
13
+
14
+ ## Basic Usage 📑
15
+ ```html
16
+
17
+ <form-dynamic-angular title="Exemple" [form]=formmExemple [control]=controlExemple></form-dynamic-angular>
18
+
19
+ ```
20
+
21
+ ```js
22
+ import { UntypedFormBuilder } from '@angular/forms';
23
+ import { IForm } from 'form-dynamic-angular';
24
+
25
+ export class AppComponent implements OnInit {
26
+
27
+ controlExemple: UntypedFormGroup
28
+ formmExemple: IForm[] = []
29
+
30
+ constructor(
31
+ private fb: UntypedFormBuilder
32
+ ) {}
33
+
34
+ ngOnInit() {
35
+ this.controlExemple = this.fb.group({
36
+ user: '',
37
+ password: ''
38
+ });
39
+
40
+ this.formmExemple = [
41
+ { label: 'User', col: 'lg:col-6', type: 'text', formControl: 'user' },
42
+ { label: 'Password', col: 'lg:col-6', type: 'text', formControl: 'password' }
43
+ ]
44
+ }
45
+ }
46
+
47
+ ```
48
+
49
+ ## Props 💬
50
+
51
+ | Prop | Type | Default | Description |
52
+ |:--------- | :---- | :---- |:---- |
53
+ | `title` | `string` | `''` | Title page
54
+ | `subTitle` | `string` | `''` | Sub title page
55
+ | `control` | `UntypedFormGroup` | `undefined` | Controls the form
56
+ | `form` | `IForm[]` | `[]` | Input list
57
+ | `files` | `File[]` | `[]` | Upload files
58
+ | `validateForm` | `boolean` | `false` | if inputs have validation
59
+ | `buttonsStandard` | `IButtonsStandard[]` | `[]` | Inputs standard (clean, filter, save, cancel)
60
+ | `buttonsOptional` | `IButtonsOptional[]` | `[]` | Inputs optional
61
+
62
+
63
+ ## Props Inputs 💬
64
+
65
+ | Prop | Type | Required |type input | Description |
66
+ |:--------- | :---- | :---- |:---- | :---- |
67
+ | `id` | `string or number` | `yes` | `all` | Id unic
68
+ | `label` | `string` | `no` | `all` | Label
69
+ | `type` | ` autocomplete or button or check-box or currency or check-box-multi or date or switch or list or likert or mask or multi or number or password or photo or radio-button or select or select-button or table or text or text-area or tree-select or upload-files` | `yes` | `all` | Type
70
+ | `disabled` | `boolean or null` | `no` | `button or upload-files` | Disabled
71
+ | `col` | `string` | `no` | `all` | Class grid primeflex
72
+ | `formControl` | ` string` | `no` | `all` | Controler input
73
+ | `required` | `boolean` | `no` | `all` | If input is required
74
+ | `placeholder` | `string` | `no` | `all` | Placeholder
75
+ | `onChange` | `Function` | `no` | `all` | Change
76
+ | `search` | `boolean` | `no` | `select` | If input search
77
+ | `options` | ` IOptions[]` | `no` | `select or autocomplete or list or multi or radio-button or checkbox-multiple or select-button` | Options view
78
+ | `treeSelectOptions` | ` ITreeSelectOptions[]` | `no` | `tree-select` | Options tree select
79
+ | `numberOfMonthsDate` | ` number` | `no` | `date` | Quantity months views, default 1
80
+ | `selectionMode` | ` multiple or range or single` | `no` | `date` | Mode selection dates
81
+ | `minDate` | `Date` | `no` | `date` | Min Date
82
+ | `maxDate` | `Date` | `no` | `date` | Max Date
83
+ | `viewDate` | `month or date` | `no` | `date` | View only month or date
84
+ | `dateFormat` | `string` | `no` | `date` | Format date
85
+ | `timeOnly` | `boolean` | `no` | `date` | View only time
86
+ | `showTime` | ` boolean` | `no` | `date` | if view time in date
87
+ | `rowsTextArea` | ` number` | `no` | `text-area` | Quantity rows in text-area
88
+ | `maxlength` | ` number` | `no` | `text-area` | Count words
89
+
90
+ | `colsTable` | ` ICols[]` | `no` | `table` | Cols table
91
+ | `forceSelection` | ` ICols[]` | `no` | `table` | Cols table
92
+ | `clean` | `Function` | `no` | `tree-select` | Function clear
93
+ | `onCLick` | `Function` | `no` | `button` | Function clear
94
+ | `icon` | `string` | `no` | `button` | Icon Button
95
+ | `textButton` | `string` | `no` | `button` | Text Button
96
+ | `onFocusDate` | `Function` | `no` | `date` | Functions focus
97
+ | `onFocusDate` | `Function` | `no` | `date` | Functions focus
98
+ | `selectionMode` | `multiple or range or single` | `no` | `date` | Amount month is view in date
99
+ | `acceptFiles` | `string` | `no` | `upload-files` | Formats accepts
100
+ | `msgAcceptFiles` | `string` | `no` | `upload-files` | Message accepts
101
+ | `mask` | `string` | `no` | `mask` | type mask
102
+ | `unmask` | `boolean` | `no` | `mask` | If control user mask or no
103
+
104
+
105
+ ## Usage Inputs
106
+
107
+ 1- Autocomplete | List | Radio-button | Select | Select-button | Multi
108
+
109
+ ```js
110
+
111
+ import {IOptions } from 'form-dynamic-angular';
112
+
113
+ controlAutocomplete: UntypedFormGroup
114
+ formmAutocomplete: IForm[] = []
115
+
116
+ options: IOptions[] = [
117
+ { id: 1, descricao: "Fortaleza" },
118
+ { id: 2, descricao: "Maracanaú" }
119
+ ]
120
+
121
+ this.controlAutocomplete = this.fb.group({
122
+ cities: '',
123
+ });
124
+
125
+ this.formmAutocomplete = [
126
+ { label: 'Cities', col: 'lg:col-6', type: 'autocomplete', formControl: 'cities', options: this.options },
127
+ { label: 'Cities', col: 'lg:col-6', type: 'list', formControl: 'cities', options: this.options },
128
+ { label: 'Cities', col: 'lg:col-6', type: 'radio-button', formControl: 'cities', options: this.options },
129
+ { label: 'Cities', col: 'lg:col-6', type: 'select', formControl: 'cities', options: this.options },
130
+ { label: 'Cities', col: 'lg:col-6', type: 'select-button', formControl: 'cities', options: this.options },
131
+ { label: 'Cities', col: 'lg:col-6', type: 'multi', formControl: 'cities', options: this.options },
132
+ ]
133
+
134
+ ```
135
+
136
+ 2- Button
137
+
138
+ ```js
139
+
140
+ controlAutocomplete: UntypedFormGroup
141
+ formmAutocomplete: IForm[] = []
142
+
143
+ this.controlAutocomplete = this.fb.group({});
144
+
145
+ this.formmAutocomplete = [
146
+ { textButton: 'Ver cidade', col: 'col-lg-4', type: 'button', onCLick: () => this.click(), icon: 'pi pi-plus', class: 'p-button-outlined' }
147
+ ]
148
+
149
+ click() {
150
+ console.log("click button")
151
+ }
152
+
153
+ ```
154
+
155
+ 2- Check-box
156
+
157
+ ```js
158
+
159
+ controlAutocomplete: UntypedFormGroup
160
+ formmAutocomplete: IForm[] = []
161
+
162
+ this.controlAutocomplete = this.fb.group({});
163
+
164
+ this.formmAutocomplete = [
165
+ { label: 'Ckeck', col: 'lg:col-6', type: 'check-box', formControl: 'ckech' },
166
+ ]
167
+
168
+ ```
169
+
170
+ 3- Date
171
+
172
+ ```js
173
+
174
+ controlAutocomplete: UntypedFormGroup
175
+ formmAutocomplete: IForm[] = []
176
+
177
+ this.controlAutocomplete = this.fb.group({
178
+ date: ''
179
+ });
180
+
181
+ this.formmAutocomplete = [
182
+ { label: 'Date', col: 'lg:col-6', type: 'date', formControl: 'date' },
183
+ ]
184
+
185
+ ```
186
+
187
+ 4- Switch | Text | Text-area | Number | Password | Currency
188
+
189
+ ```js
190
+
191
+ controlAutocomplete: UntypedFormGroup
192
+ formmAutocomplete: IForm[] = []
193
+
194
+ this.controlAutocomplete = this.fb.group({
195
+ switch: false,
196
+ text: '',
197
+ number: 0,
198
+ textArea: '',
199
+ password: '',
200
+ currency: 0
201
+ });
202
+
203
+ this.formmAutocomplete = [
204
+ { label: 'Switch', col: 'lg:col-6', type: 'switch', formControl: 'switch' },
205
+ { label: 'Text', col: 'lg:col-6', type: 'text', formControl: 'text' },
206
+ { label: 'Number', col: 'lg:col-6', type: 'number', formControl: 'number' },
207
+ { label: 'TextArea', col: 'lg:col-6', type: 'text-area', formControl: 'textArea' },
208
+ { label: 'Password', col: 'lg:col-6', type: 'password', formControl: 'password' },
209
+ { label: 'Currency', col: 'lg:col-6', type: 'currency', formControl: 'currency' }
210
+ ]
211
+
212
+ ```
213
+
214
+ 5- Tree-select
215
+
216
+ ```js
217
+
218
+ import { ITreeSelectOptions } from 'projects/form-dynamic-angular/src/public-api';
219
+
220
+ treeSelect: ITreeSelectOptions[] = [{
221
+ key: '0',
222
+ label: 'Documents',
223
+ icon: 'pi pi-fw pi-inbox',
224
+ children: [
225
+ {
226
+ key: '0-0',
227
+ label: 'Work',
228
+ icon: 'pi pi-fw pi-cog',
229
+ children: [
230
+ { key: '0-0-0', label: 'Expenses.doc', icon: 'pi pi-fw pi-file' },
231
+ { key: '0-0-1', label: 'Resume.doc', icon: 'pi pi-fw pi-file', }
232
+ ]
233
+ },
234
+ {
235
+ key: '0-1',
236
+ label: 'Home',
237
+ icon: 'pi pi-fw pi-home'
238
+ }
239
+ ]
240
+ }]
241
+
242
+ control: UntypedFormGroup
243
+ form: IForm[] = []
244
+
245
+ this.control = this.fb.group({
246
+ treeSelect: ""
247
+ });
248
+
249
+ this.form = [
250
+ { label: "Tree-select", col: 'lg:col-6', type: 'tree-select', formControl: 'installationLocation', treeSelectOptions: this.treeSelect },
251
+ ]
252
+
253
+ ```
254
+
255
+ 6- Table
256
+
257
+ ```js
258
+
259
+ import { ICols } from 'projects/form-dynamic-angular/src/public-api';
260
+
261
+ rowsTable: any = [{
262
+ id: 1,
263
+ c1: "teste c1",
264
+ c2: "teste c2",
265
+ button: { label: "as", icon: "a", onCLick: (id: number) => this.click(id), styleClass: "asd" }
266
+ },
267
+ {
268
+ id: 2,
269
+ c1: "asas",
270
+ c2: "ad",
271
+ button: { label: "ab", icon: "a", onCLick: (id: number) => this.click(id), styleClass: "asd" }
272
+ }]
273
+
274
+ cols: ICols[] = [
275
+ { field: 'c1', header: 'C1' },
276
+ { field: 'c2', header: 'C2' },
277
+ { field: 'button', header: 'Ação' },
278
+ ]
279
+
280
+ control: UntypedFormGroup
281
+ form: IForm[] = []
282
+
283
+ this.control = this.fb.group({
284
+ table: ""
285
+ });
286
+
287
+ this.form = [
288
+ { label: 'Cities', col: 'col-lg-12', type: 'table', formControl: 'table', rowsTable: this.rowsTable, colsTable: this.cols, class: 'p-datatable-gridlines' }
289
+ ]
290
+
291
+ ```
292
+
293
+ 7- Upload-files
294
+
295
+ ```js
296
+
297
+ control: UntypedFormGroup
298
+ form: IForm[] = []
299
+
300
+ this.control = this.fb.group({
301
+ table: ""
302
+ });
303
+
304
+ this.form = [
305
+ { type: 'upload-files', formControl: 'cities', acceptFiles: 'image/*, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/pdf, application/msword', msgAcceptFiles:"Arquivos suportados: PNG, TIF, JPG, PDF, WORD e EXCEL" }
306
+
307
+ ]
308
+
309
+ ```
310
+
311
+ 8- Mask
312
+
313
+ ```js
314
+
315
+ control: UntypedFormGroup
316
+ form: IForm[] = []
317
+
318
+ this.control = this.fb.group({
319
+ mask: 0
320
+ });
321
+
322
+ this.form = [
323
+ { label: 'Mask', col: 'col-md-12', type: 'mask', mask: "999-999-9999", formControl: 'mask' }
324
+ ]
325
+
326
+ ```
327
+ ## Required
328
+
329
+ ```js
330
+
331
+ control: UntypedFormGroup
332
+ form: IForm[] = []
333
+ validateForm: boolean = false
334
+
335
+ buttonsStandard: IButtonsStandard[] = [
336
+ { type: 'save', onCLick: () => this.save(), styleClass: 'p-button-outlined' }
337
+ ]
338
+
339
+ this.control = this.fb.group({
340
+ mask: new FormControl({ value: 0, validators: Validators.required}),
341
+ });
342
+
343
+ this.form = [
344
+ { label: 'Mask', col: 'col-md-12', type: 'mask', mask: "999-999-9999", formControl: 'mask', required: true }
345
+ ]
346
+
347
+ save() {
348
+ this.validateForm = true
349
+ }
350
+
351
+ ```
352
+ ```html
353
+
354
+ <form-dynamic-angular title="Exemple" [form]=form [control]=control [validateForm]=validateForm [buttonsStandard]=buttonsStandard></form-dynamic-angular>
355
+
356
+ ```
357
+ ## Translate
358
+
359
+ Created files
360
+
361
+ ```json
362
+ //src/assets/i18n/pt.json
363
+
364
+ {
365
+ "pageLogin": {
366
+ "userName": "Usuário",
367
+ "password": "Senha"
368
+ }
369
+ }
370
+
371
+ //src/assets/i18n/en.json
372
+
373
+ {
374
+ "pageLogin": {
375
+ "userName": "Username",
376
+ "password": "Password"
377
+ }
378
+ }
379
+
380
+ ```
381
+
382
+ Created input and form
383
+
384
+ ```html
385
+ <!--app.component.html-->
386
+
387
+ <form-dynamic-angular title="Login" [form]=formLogin [control]=controlLogin></form-dynamic-angular>
388
+
389
+ ```
390
+
391
+ Created function
392
+
393
+ ```js
394
+ //app.component.ts
395
+
396
+ import { UntypedFormBuilder } from '@angular/forms';
397
+ import { IForm } from 'form-dynamic-angular';
398
+
399
+
400
+ export class AppComponent implements OnInit {
401
+
402
+ controlLogin: UntypedFormGroup
403
+ formLogin: IForm[] = []
404
+
405
+ constructor(
406
+ private fb: UntypedFormBuilder
407
+ ) {}
408
+
409
+ ngOnInit() {
410
+ this.controlLogin = this.fb.group({
411
+ username: '',
412
+ password: ''
413
+ });
414
+
415
+ this.formLogin = [
416
+ { label: 'userName', col: 'lg:col-6', type: 'text', formControl: 'username' },
417
+ { label: 'password', col: 'lg:col-6', type: 'text', formControl: 'password' }
418
+ ]
419
+ }
420
+
421
+ }
422
+
423
+ ```
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/form-dynamic-angular",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ },
7
+ "allowedNonPeerDependencies": [
8
+ "moment"
9
+ ]
10
+ }
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "form-dynamic-ajax",
3
+ "version": "7.0.2",
4
+ "peerDependencies": {
5
+ "@angular/common": "^17.0.0",
6
+ "@angular/core": "^17.0.0",
7
+ "moment": "^2.29.4"
8
+ },
9
+ "dependencies": {
10
+ "moment": "^2.29.4",
11
+ "tslib": "^2.3.0"
12
+ },
13
+ "sideEffects": false
14
+ }
@@ -0,0 +1,132 @@
1
+ .div-title span {
2
+ font-size: 20px;
3
+ font-weight: 500;
4
+ }
5
+
6
+ .buttons-form {
7
+ display: flex;
8
+ gap: 10px;
9
+ justify-content: flex-end;
10
+ }
11
+
12
+ .danger-text {
13
+ color: #f18282;
14
+ }
15
+
16
+ .drag-image {
17
+ height: auto;
18
+ width: 100%;
19
+ border-radius: 10px;
20
+ font-weight: 400;
21
+ display: flex;
22
+ align-items: center;
23
+ flex-direction: column;
24
+ padding-bottom: 20px;
25
+ top: 20px;
26
+ max-height: 250px;
27
+ color: #000;
28
+ padding: 20px;
29
+ text-align: center;
30
+ overflow: auto;
31
+ }
32
+
33
+ .drag-image h6 {
34
+ font-size: 20px;
35
+ }
36
+
37
+ .drag-image .file-name {
38
+ font-size: 14px;
39
+ }
40
+
41
+ .drag-image i {
42
+ font-size: 3rem;
43
+ }
44
+
45
+ .subtitle span {
46
+ font-size: 14px;
47
+ margin-right: 5px;
48
+ }
49
+
50
+ .subtitle {
51
+ align-items: baseline;
52
+ }
53
+
54
+ .mh-75 {
55
+ min-height: 75px !important
56
+ }
57
+
58
+ input[type="file"] {
59
+ position: absolute;
60
+ width: 100%;
61
+ height: 100%;
62
+ top: 0;
63
+ left: 0;
64
+ right: 0;
65
+ bottom: 0;
66
+ opacity: 0;
67
+ cursor: pointer;
68
+ }
69
+
70
+ .preview-img {
71
+ align-items: center;
72
+ border-radius: 5px;
73
+ display: flex;
74
+ height: 140px;
75
+ justify-content: center;
76
+ margin: 10px;
77
+ max-width: 180px;
78
+ min-height: 140px;
79
+ min-width: 180px;
80
+ padding: 0px 20px;
81
+ position: relative;
82
+ }
83
+
84
+ .preview-img span {
85
+ position: absolute;
86
+ overflow-wrap: break-word;
87
+ }
88
+
89
+ .remove-file {
90
+ display: flex;
91
+ justify-content: center;
92
+ align-items: center;
93
+ height: 22px;
94
+ width: 22px;
95
+ top: 5px;
96
+ right: 5px;
97
+ border-radius: 50%;
98
+ background: #bbb;
99
+ color: #333;
100
+ cursor: pointer;
101
+ font-size: .8rem !important;
102
+ }
103
+
104
+ .preview-img img {
105
+ max-width: 100%;
106
+ opacity: .8;
107
+ }
108
+
109
+ .camera {
110
+ display: flex;
111
+ flex-direction: column;
112
+ align-items: center;
113
+ position: relative;
114
+
115
+ }
116
+
117
+ .foto {
118
+ max-width: 186px;
119
+ min-height: 140px;
120
+ min-width: 180px;
121
+ border: 1px dashed #000;
122
+ border-radius: 5px;
123
+ margin-bottom: 1em;
124
+ }
125
+
126
+ .preview-photo {
127
+ position: relative;
128
+ }
129
+
130
+ .h-0 {
131
+ height: 0;
132
+ }