@digigov/form 2.0.0-6c42d5eb → 2.0.0-6e3977bc
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/Field/FieldBase/index.js +1 -0
- package/Field/FieldBase.js.map +2 -2
- package/Field/FieldBaseContainer/index.js +1 -1
- package/Field/FieldBaseContainer.js.map +2 -2
- package/Field/FieldConditional/index.js +7 -3
- package/Field/FieldConditional.js.map +2 -2
- package/Field/index.js +5 -2
- package/Field/index.js.map +2 -2
- package/Field/types.d.ts +4 -1
- package/Field/utils/index.d.ts +1 -0
- package/Field/utils/index.js +18 -1
- package/Field/utils/index.js.map +2 -2
- package/FieldArray/index.d.ts +1 -0
- package/FieldArray/index.js +3 -1
- package/FieldArray/index.js.map +2 -2
- package/FieldObject/index.d.ts +2 -0
- package/FieldObject/index.js +7 -3
- package/FieldObject/index.js.map +2 -2
- package/Fieldset/types.d.ts +0 -1
- package/FormBuilder/index.d.ts +8 -2
- package/FormBuilder/index.js +150 -6
- package/FormBuilder/index.js.map +3 -3
- package/MultiplicityField/add-objects/index.js +3 -1
- package/MultiplicityField/add-objects.js.map +2 -2
- package/MultiplicityField/index.js +4 -2
- package/MultiplicityField/index.js.map +2 -2
- package/Questions/QuestionsContext.d.ts +0 -1
- package/Questions/Step/StepContext.d.ts +0 -1
- package/Questions/Step/types.d.ts +0 -1
- package/Questions/types.d.ts +0 -1
- package/cjs/Field/FieldBase/index.js +1 -0
- package/cjs/Field/FieldBase.js.map +2 -2
- package/cjs/Field/FieldBaseContainer/index.js +3 -3
- package/cjs/Field/FieldBaseContainer.js.map +3 -3
- package/cjs/Field/FieldConditional/index.js +7 -3
- package/cjs/Field/FieldConditional.js.map +2 -2
- package/cjs/Field/index.js +5 -2
- package/cjs/Field/index.js.map +2 -2
- package/cjs/Field/types.js.map +1 -1
- package/cjs/Field/utils/index.js +18 -0
- package/cjs/Field/utils/index.js.map +2 -2
- package/cjs/FieldArray/index.js +3 -1
- package/cjs/FieldArray/index.js.map +2 -2
- package/cjs/FieldObject/index.js +7 -3
- package/cjs/FieldObject/index.js.map +2 -2
- package/cjs/FormBuilder/index.js +165 -5
- package/cjs/FormBuilder/index.js.map +3 -3
- package/cjs/MultiplicityField/add-objects/index.js +3 -1
- package/cjs/MultiplicityField/add-objects.js.map +2 -2
- package/cjs/MultiplicityField/index.js +4 -2
- package/cjs/MultiplicityField/index.js.map +2 -2
- package/cjs/index.js +11 -155
- package/cjs/index.js.map +4 -4
- package/cjs/inputs/AutoCompleteInput/__stories__/Multiple/index.js +0 -1
- package/cjs/inputs/AutoCompleteInput/__stories__/Multiple.js.map +2 -2
- package/cjs/inputs/AutoCompleteInput/index.js +5 -3
- package/cjs/inputs/AutoCompleteInput/index.js.map +2 -2
- package/cjs/inputs/Checkboxes/index.js +1 -1
- package/cjs/inputs/Checkboxes/index.js.map +2 -2
- package/cjs/inputs/ImageInput/ImageInput.stories/index.js +4 -4
- package/cjs/inputs/ImageInput/ImageInput.stories.js.map +2 -2
- package/cjs/inputs/ImageInput/__stories__/MaxSize/index.js +69 -0
- package/cjs/inputs/ImageInput/__stories__/MaxSize.js.map +7 -0
- package/cjs/inputs/ImageInput/index.js +3 -2
- package/cjs/inputs/ImageInput/index.js.map +2 -2
- package/cjs/inputs/Input/index.js +18 -5
- package/cjs/inputs/Input/index.js.map +3 -3
- package/cjs/inputs/Radio/__stories__/Conditional.js.map +2 -2
- package/cjs/inputs/Radio/index.js +52 -4
- package/cjs/inputs/Radio/index.js.map +2 -2
- package/cjs/inputs/inputsScenarios/index.js +0 -1
- package/cjs/inputs/inputsScenarios.js.map +2 -2
- package/cjs/lazy/index.js +4 -2
- package/cjs/lazy.js.map +2 -2
- package/cjs/types.js.map +1 -1
- package/cjs/validators/utils/file/index.js +1 -1
- package/cjs/validators/utils/file.js.map +2 -2
- package/index.d.ts +5 -8
- package/index.js +9 -152
- package/index.js.map +4 -4
- package/inputs/AutoCompleteInput/__stories__/Multiple/index.js +0 -1
- package/inputs/AutoCompleteInput/__stories__/Multiple.js.map +2 -2
- package/inputs/AutoCompleteInput/index.js +5 -3
- package/inputs/AutoCompleteInput/index.js.map +2 -2
- package/inputs/Checkboxes/index.js +1 -1
- package/inputs/Checkboxes/index.js.map +2 -2
- package/inputs/ImageInput/ImageInput.stories/index.js +2 -2
- package/inputs/ImageInput/ImageInput.stories.d.ts +1 -1
- package/inputs/ImageInput/ImageInput.stories.js.map +2 -2
- package/inputs/ImageInput/__stories__/MaxSize/index.js +36 -0
- package/inputs/ImageInput/__stories__/MaxSize/package.json +6 -0
- package/inputs/ImageInput/__stories__/MaxSize.d.ts +3 -0
- package/inputs/ImageInput/__stories__/MaxSize.js.map +7 -0
- package/inputs/ImageInput/index.js +3 -2
- package/inputs/ImageInput/index.js.map +2 -2
- package/inputs/Input/index.js +16 -3
- package/inputs/Input/index.js.map +3 -3
- package/inputs/Radio/__stories__/Conditional.js.map +2 -2
- package/inputs/Radio/index.d.ts +4 -0
- package/inputs/Radio/index.js +51 -4
- package/inputs/Radio/index.js.map +2 -2
- package/inputs/inputsScenarios/index.js +0 -1
- package/inputs/inputsScenarios.d.ts +0 -42
- package/inputs/inputsScenarios.js.map +2 -2
- package/lazy/index.js +4 -2
- package/lazy.d.ts +13 -8
- package/lazy.js.map +2 -2
- package/package.json +4 -4
- package/src/Field/FieldBase.tsx +1 -0
- package/src/Field/FieldBaseContainer.tsx +1 -1
- package/src/Field/FieldConditional.tsx +4 -0
- package/src/Field/index.tsx +4 -1
- package/src/Field/types.tsx +23 -20
- package/src/Field/utils/index.ts +18 -1
- package/src/FieldArray/index.tsx +6 -3
- package/src/FieldObject/index.tsx +6 -0
- package/src/FormBuilder/index.tsx +179 -7
- package/src/FormBuilder/scenarios.test.tsx +2 -2
- package/src/MultiplicityField/add-objects.tsx +2 -0
- package/src/MultiplicityField/index.tsx +2 -0
- package/src/index.ts +6 -0
- package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +0 -1
- package/src/inputs/AutoCompleteInput/index.tsx +6 -4
- package/src/inputs/Checkboxes/index.tsx +22 -22
- package/src/inputs/ImageInput/ImageInput.stories.js +2 -1
- package/src/inputs/ImageInput/__stories__/MaxSize.tsx +37 -0
- package/src/inputs/ImageInput/index.test.tsx +4 -0
- package/src/inputs/ImageInput/index.tsx +3 -3
- package/src/inputs/Input/index.tsx +24 -29
- package/src/inputs/Radio/__stories__/Conditional.tsx +2 -1
- package/src/inputs/Radio/index.tsx +69 -5
- package/src/inputs/inputsScenarios.ts +147 -148
- package/src/lazy.js +4 -2
- package/src/types.tsx +1 -0
- package/src/validators/utils/file.ts +1 -1
- package/types.d.ts +1 -1
- package/types.js.map +1 -1
- package/validators/utils/file/index.js +1 -1
- package/validators/utils/file.js.map +2 -2
- package/src/index.tsx +0 -178
|
@@ -1,160 +1,159 @@
|
|
|
1
1
|
import el from '@digigov/form/locales/el';
|
|
2
2
|
|
|
3
3
|
export const INPUTS_FIELDS = [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
key: 'otp',
|
|
16
|
-
type: 'otp',
|
|
17
|
-
maxLength: 6,
|
|
18
|
-
label: {
|
|
19
|
-
primary: 'Συμπληρώστε τον κωδικό επιβεβαίωσης',
|
|
20
|
-
},
|
|
21
|
-
required: true,
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
key: 'checkbox',
|
|
25
|
-
type: 'choice:multiple',
|
|
26
|
-
required: true,
|
|
27
|
-
label: { primary: 'Πώς αισθάνεστε αυτή τη στιγμή;' },
|
|
28
|
-
extra: {
|
|
29
|
-
options: [
|
|
30
|
-
{
|
|
31
|
-
label: { primary: 'Έχω συνάχι' },
|
|
32
|
-
value: 'runny-nose',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
label: { primary: 'Έχω πυρετό' },
|
|
36
|
-
value: 'fever',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
label: { primary: 'Αισθάνομαι κούραση' },
|
|
40
|
-
value: 'fatigue',
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
key: 'autocomplete_multiple',
|
|
47
|
-
required: true,
|
|
48
|
-
type: 'choice:multiple',
|
|
49
|
-
label: { primary: 'Πώς αισθάνεστε αυτή τη στιγμή;' },
|
|
50
|
-
extra: {
|
|
51
|
-
component: 'AutoComplete',
|
|
52
|
-
multiple: true,
|
|
53
|
-
options: [
|
|
54
|
-
{
|
|
55
|
-
label: { primary: 'Έχω συνάχι' },
|
|
56
|
-
value: 'runny-nose',
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
label: { primary: 'Έχω πυρετό' },
|
|
60
|
-
value: 'fever',
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
label: { primary: 'Αισθάνομαι κούραση' },
|
|
64
|
-
value: 'fatigue',
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
},
|
|
4
|
+
{
|
|
5
|
+
key: 'date-example',
|
|
6
|
+
type: 'date',
|
|
7
|
+
required: true,
|
|
8
|
+
label: {
|
|
9
|
+
primary: 'Ποιά είναι η ημερομηνία γέννησής σας;',
|
|
10
|
+
secondary:
|
|
11
|
+
'Για παράδειγμα, 05 11 2020',
|
|
68
12
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
{
|
|
77
|
-
label: { primary: 'Έχω συνάχι' },
|
|
78
|
-
value: 'runny-nose',
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
label: { primary: 'Έχω πυρετό' },
|
|
82
|
-
value: 'fever',
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
label: { primary: 'Αισθάνομαι κούραση' },
|
|
86
|
-
value: 'fatigue',
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
}
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
key: 'otp',
|
|
16
|
+
type: 'otp',
|
|
17
|
+
maxLength: 6,
|
|
18
|
+
label: {
|
|
19
|
+
primary: 'Συμπληρώστε τον κωδικό επιβεβαίωσης',
|
|
90
20
|
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
key: 'checkbox',
|
|
25
|
+
type: 'choice:multiple',
|
|
26
|
+
required: true,
|
|
27
|
+
label: { primary: 'Πώς αισθάνεστε αυτή τη στιγμή;' },
|
|
28
|
+
extra: {
|
|
29
|
+
options: [
|
|
30
|
+
{
|
|
31
|
+
label: { primary: 'Έχω συνάχι' },
|
|
32
|
+
value: 'runny-nose',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: { primary: 'Έχω πυρετό' },
|
|
36
|
+
value: 'fever',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: { primary: 'Αισθάνομαι κούραση' },
|
|
40
|
+
value: 'fatigue',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
key: 'autocomplete_multiple',
|
|
47
|
+
required: true,
|
|
48
|
+
type: 'choice:multiple',
|
|
49
|
+
label: { primary: 'Πώς αισθάνεστε αυτή τη στιγμή;' },
|
|
50
|
+
extra: {
|
|
51
|
+
component: 'AutoComplete',
|
|
52
|
+
options: [
|
|
53
|
+
{
|
|
54
|
+
label: { primary: 'Έχω συνάχι' },
|
|
55
|
+
value: 'runny-nose',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
label: { primary: 'Έχω πυρετό' },
|
|
59
|
+
value: 'fever',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
label: { primary: 'Αισθάνομαι κούραση' },
|
|
63
|
+
value: 'fatigue',
|
|
64
|
+
},
|
|
65
|
+
],
|
|
117
66
|
},
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
key: 'radio',
|
|
70
|
+
type: 'choice:single',
|
|
71
|
+
required: true,
|
|
72
|
+
label: { primary: 'Πώς αισθάνεστε αυτή τη στιγμή;' },
|
|
73
|
+
extra: {
|
|
74
|
+
options: [
|
|
75
|
+
{
|
|
76
|
+
label: { primary: 'Έχω συνάχι' },
|
|
77
|
+
value: 'runny-nose',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
label: { primary: 'Έχω πυρετό' },
|
|
81
|
+
value: 'fever',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
label: { primary: 'Αισθάνομαι κούραση' },
|
|
85
|
+
value: 'fatigue',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
key: 'select',
|
|
92
|
+
type: 'choice:single',
|
|
93
|
+
required: true,
|
|
94
|
+
label: { primary: 'Πώς αισθάνεστε αυτή τη στιγμή;' },
|
|
95
|
+
extra: {
|
|
96
|
+
component: 'Select',
|
|
97
|
+
options: [
|
|
98
|
+
{
|
|
99
|
+
label: { primary: '' },
|
|
100
|
+
value: '',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
label: { primary: 'Έχω συνάχι' },
|
|
104
|
+
value: 'runny-nose',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
label: { primary: 'Έχω πυρετό' },
|
|
108
|
+
value: 'fever',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
label: { primary: 'Αισθάνομαι κούραση' },
|
|
112
|
+
value: 'fatigue',
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
key: 'autocomplete_single',
|
|
119
|
+
required: true,
|
|
120
|
+
type: 'choice:single',
|
|
121
|
+
label: { primary: 'Πώς αισθάνεστε αυτή τη στιγμή;' },
|
|
122
|
+
extra: {
|
|
123
|
+
component: 'AutoComplete',
|
|
124
|
+
options: [
|
|
125
|
+
{
|
|
126
|
+
label: { primary: 'Έχω συνάχι' },
|
|
127
|
+
value: 'runny-nose',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
label: { primary: 'Έχω πυρετό' },
|
|
131
|
+
value: 'fever',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
label: { primary: 'Αισθάνομαι κούραση' },
|
|
135
|
+
value: 'fatigue',
|
|
136
|
+
},
|
|
137
|
+
],
|
|
140
138
|
},
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
key: 'image',
|
|
142
|
+
type: 'image',
|
|
143
|
+
required: true,
|
|
144
|
+
label: {
|
|
145
|
+
primary: 'Ανεβάστε τη φωτογραφία του προστίμου',
|
|
148
146
|
},
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
required: true,
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
key: 'file',
|
|
150
|
+
type: 'file',
|
|
151
|
+
label: {
|
|
152
|
+
primary: 'Ανεβάστε το αρχείο της απόδειξης',
|
|
156
153
|
},
|
|
157
|
-
|
|
154
|
+
required: true,
|
|
155
|
+
},
|
|
156
|
+
]
|
|
158
157
|
|
|
159
158
|
export const scenarios = [
|
|
160
159
|
{
|
package/src/lazy.js
CHANGED
|
@@ -5,6 +5,7 @@ export default {
|
|
|
5
5
|
'FieldConditional': lazy(() => import('@digigov/form/Field/FieldConditional').then((module)=> ({default: module['FieldConditional']}))),
|
|
6
6
|
'Field': lazy(() => import('@digigov/form/internal').then((module)=> ({default: module['Field']}))),
|
|
7
7
|
'ALTERNATIVE_COMPONENTS': lazy(() => import('@digigov/form/Field/utils').then((module)=> ({default: module['ALTERNATIVE_COMPONENTS']}))),
|
|
8
|
+
'CONTROLLED_FIELD_COMPONENTS': lazy(() => import('@digigov/form/Field/utils').then((module)=> ({default: module['CONTROLLED_FIELD_COMPONENTS']}))),
|
|
8
9
|
'FIELD_COMPONENTS': lazy(() => import('@digigov/form/Field/utils').then((module)=> ({default: module['FIELD_COMPONENTS']}))),
|
|
9
10
|
'FieldArray': lazy(() => import('@digigov/form/FieldArray').then((module)=> ({default: module['FieldArray']}))),
|
|
10
11
|
'FieldObject': lazy(() => import('@digigov/form/FieldObject').then((module)=> ({default: module['FieldObject']}))),
|
|
@@ -13,9 +14,10 @@ export default {
|
|
|
13
14
|
'FieldsetBody': lazy(() => import('@digigov/form/Fieldset').then((module)=> ({default: module['FieldsetBody']}))),
|
|
14
15
|
'FieldsetCaption': lazy(() => import('@digigov/form/Fieldset').then((module)=> ({default: module['FieldsetCaption']}))),
|
|
15
16
|
'FieldsetLabel': lazy(() => import('@digigov/form/Fieldset').then((module)=> ({default: module['FieldsetLabel']}))),
|
|
17
|
+
'ControlledFormBuilder': lazy(() => import('@digigov/form/FormBuilder').then((module)=> ({default: module['ControlledFormBuilder']}))),
|
|
16
18
|
'FormBase': lazy(() => import('@digigov/form/FormBuilder').then((module)=> ({default: module['FormBase']}))),
|
|
17
19
|
'FormContext': lazy(() => import('@digigov/form/FormContext').then((module)=> ({default: module['FormContext']}))),
|
|
18
|
-
'
|
|
20
|
+
'Label': lazy(() => import('@digigov/form/inputs/Label').then((module)=> ({default: module['Label']}))),
|
|
19
21
|
'AutoCompleteInput': lazy(() => import('@digigov/form/inputs/AutoCompleteInput').then((module)=> ({default: module['AutoCompleteInput']}))),
|
|
20
22
|
'Checkboxes': lazy(() => import('@digigov/form/inputs/Checkboxes').then((module)=> ({default: module['Checkboxes']}))),
|
|
21
23
|
'DateInput': lazy(() => import('@digigov/form/inputs/DateInput').then((module)=> ({default: module['DateInput']}))),
|
|
@@ -23,13 +25,13 @@ export default {
|
|
|
23
25
|
'Image': lazy(() => import('@digigov/form/inputs/ImageInput').then((module)=> ({default: module['Image']}))),
|
|
24
26
|
'ImageInput': lazy(() => import('@digigov/form/inputs/ImageInput').then((module)=> ({default: module['ImageInput']}))),
|
|
25
27
|
'Input': lazy(() => import('@digigov/form/inputs/Input').then((module)=> ({default: module['Input']}))),
|
|
26
|
-
'Label': lazy(() => import('@digigov/form/inputs/Label').then((module)=> ({default: module['Label']}))),
|
|
27
28
|
'OtpInput': lazy(() => import('@digigov/form/inputs/OtpInput').then((module)=> ({default: module['OtpInput']}))),
|
|
28
29
|
'Radio': lazy(() => import('@digigov/form/inputs').then((module)=> ({default: module['Radio']}))),
|
|
29
30
|
'Select': lazy(() => import('@digigov/form/inputs/Select').then((module)=> ({default: module['Select']}))),
|
|
30
31
|
'INPUTS_FIELDS': lazy(() => import('@digigov/form/inputs/inputsScenarios').then((module)=> ({default: module['INPUTS_FIELDS']}))),
|
|
31
32
|
'REMOVE_SPACES': lazy(() => import('@digigov/form/inputs/OtpInput').then((module)=> ({default: module['REMOVE_SPACES']}))),
|
|
32
33
|
'RE_DIGIT': lazy(() => import('@digigov/form/inputs/OtpInput').then((module)=> ({default: module['RE_DIGIT']}))),
|
|
34
|
+
'ControlledRadioButtonsGroup': lazy(() => import('@digigov/form/inputs/Radio').then((module)=> ({default: module['ControlledRadioButtonsGroup']}))),
|
|
33
35
|
'RadioButtonsGroup': lazy(() => import('@digigov/form/inputs/Radio').then((module)=> ({default: module['RadioButtonsGroup']}))),
|
|
34
36
|
'AddObjects': lazy(() => import('@digigov/form/MultiplicityField/add-objects').then((module)=> ({default: module['AddObjects']}))),
|
|
35
37
|
'ListObject': lazy(() => import('@digigov/form/MultiplicityField').then((module)=> ({default: module['ListObject']}))),
|
package/src/types.tsx
CHANGED
|
@@ -6,7 +6,7 @@ const DEFAULT_FILE_MAX_SIZE = 10000000;
|
|
|
6
6
|
export const FILE_MAX_SIZE_VALIDATOR = (field: FieldSpec): ValidatorSchema => ({
|
|
7
7
|
name: 'file-max-size-validator',
|
|
8
8
|
message: {
|
|
9
|
-
key: 'form.error.file_size',
|
|
9
|
+
key: field.type === 'file' ? 'form.error.file_size' : 'form.error.image_size',
|
|
10
10
|
context: {
|
|
11
11
|
maxSizeToMb: (field?.extra?.limit.maxSize || DEFAULT_FILE_MAX_SIZE) / 1000000,
|
|
12
12
|
},
|
package/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { UseFormReturn, UseFormProps } from 'react-hook-form';
|
|
3
2
|
import { FieldComponentRegistry, FieldLabelProps, FieldSpec, FormData } from '@digigov/form/Field/types';
|
|
4
3
|
import { ValidatorSchema } from '@digigov/form/validators/types';
|
|
@@ -46,6 +45,7 @@ export interface FormBuilderProps {
|
|
|
46
45
|
validatorRegistry?: Record<string, ValidatorSchema[]>;
|
|
47
46
|
componentRegistry?: FieldComponentRegistry;
|
|
48
47
|
grid?: boolean;
|
|
48
|
+
controlledFieldsOnly?: boolean;
|
|
49
49
|
}
|
|
50
50
|
export interface FormBaseProps extends Omit<FormBuilderProps, 'fields' | 'fieldsets' | 'auto'> {
|
|
51
51
|
fieldsetsMap?: Record<string, FieldsetSpec>;
|
package/types.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/types.tsx"],
|
|
4
|
-
"sourcesContent": ["import { UseFormReturn, UseFormProps } from 'react-hook-form';\nimport {\n FieldComponentRegistry,\n FieldLabelProps,\n FieldSpec,\n FormData,\n} from '@digigov/form/Field/types';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\nexport * from '@digigov/form/Field/types';\nexport type FieldError = {\n message: string;\n};\n\nexport interface FieldsetSpec {\n key: string;\n fields: string[];\n label?: FieldLabelProps;\n body?: React.ReactNode;\n}\n\nexport interface FormContextProps {\n fieldsetsMap?: Record<string, FieldsetSpec>;\n fieldsMap: Record<string, FieldSpec>;\n control: UseFormReturn['control'];\n register: UseFormReturn['register'];\n trigger: UseFormReturn['trigger'];\n clearErrors: UseFormReturn['clearErrors'];\n watch: UseFormReturn['watch'];\n getFieldState: UseFormReturn['getFieldState'];\n setValue: UseFormReturn['setValue'];\n getValues: UseFormReturn['getValues'];\n unregister: UseFormReturn['unregister'];\n formState: UseFormReturn['formState'];\n reset: UseFormReturn['reset'];\n resetField: UseFormReturn['resetField'];\n registerField: (field: FieldSpec) => void;\n errors: UseFormReturn['formState']['errors'];\n componentRegistry?: FieldComponentRegistry;\n submit: () => Promise<void>;\n}\n\nexport interface FormBuilderProps {\n fields?: FieldSpec[];\n fieldsets?: FieldsetSpec[];\n initial?: FormData;\n onSubmit?: (data: FormData) => void | null | FieldError[];\n mode?: UseFormProps['mode'];\n reValidateMode?: UseFormProps['reValidateMode'];\n criteriaMode?: UseFormProps['criteriaMode'];\n children?: React.ReactNode;\n shouldFocusError?: boolean;\n auto?: boolean;\n validatorRegistry?: Record<string, ValidatorSchema[]>;\n componentRegistry?: FieldComponentRegistry;\n grid?: boolean;\n}\n\nexport interface FormBaseProps\n extends Omit<FormBuilderProps, 'fields' | 'fieldsets' | 'auto'> {\n fieldsetsMap?: Record<string, FieldsetSpec>;\n fieldsMap: Record<string, FieldSpec>;\n registerField: (field: FieldSpec) => void;\n resolver: any;\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { UseFormReturn, UseFormProps } from 'react-hook-form';\nimport {\n FieldComponentRegistry,\n FieldLabelProps,\n FieldSpec,\n FormData,\n} from '@digigov/form/Field/types';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\nexport * from '@digigov/form/Field/types';\nexport type FieldError = {\n message: string;\n};\n\nexport interface FieldsetSpec {\n key: string;\n fields: string[];\n label?: FieldLabelProps;\n body?: React.ReactNode;\n}\n\nexport interface FormContextProps {\n fieldsetsMap?: Record<string, FieldsetSpec>;\n fieldsMap: Record<string, FieldSpec>;\n control: UseFormReturn['control'];\n register: UseFormReturn['register'];\n trigger: UseFormReturn['trigger'];\n clearErrors: UseFormReturn['clearErrors'];\n watch: UseFormReturn['watch'];\n getFieldState: UseFormReturn['getFieldState'];\n setValue: UseFormReturn['setValue'];\n getValues: UseFormReturn['getValues'];\n unregister: UseFormReturn['unregister'];\n formState: UseFormReturn['formState'];\n reset: UseFormReturn['reset'];\n resetField: UseFormReturn['resetField'];\n registerField: (field: FieldSpec) => void;\n errors: UseFormReturn['formState']['errors'];\n componentRegistry?: FieldComponentRegistry;\n submit: () => Promise<void>;\n}\n\nexport interface FormBuilderProps {\n fields?: FieldSpec[];\n fieldsets?: FieldsetSpec[];\n initial?: FormData;\n onSubmit?: (data: FormData) => void | null | FieldError[];\n mode?: UseFormProps['mode'];\n reValidateMode?: UseFormProps['reValidateMode'];\n criteriaMode?: UseFormProps['criteriaMode'];\n children?: React.ReactNode;\n shouldFocusError?: boolean;\n auto?: boolean;\n validatorRegistry?: Record<string, ValidatorSchema[]>;\n componentRegistry?: FieldComponentRegistry;\n grid?: boolean;\n controlledFieldsOnly?: boolean;\n}\n\nexport interface FormBaseProps\n extends Omit<FormBuilderProps, 'fields' | 'fieldsets' | 'auto'> {\n fieldsetsMap?: Record<string, FieldsetSpec>;\n fieldsMap: Record<string, FieldSpec>;\n registerField: (field: FieldSpec) => void;\n resolver: any;\n}\n"],
|
|
5
5
|
"mappings": "AAQA,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,7 +2,7 @@ const DEFAULT_FILE_MAX_SIZE = 1e7;
|
|
|
2
2
|
const FILE_MAX_SIZE_VALIDATOR = (field) => ({
|
|
3
3
|
name: "file-max-size-validator",
|
|
4
4
|
message: {
|
|
5
|
-
key: "form.error.file_size",
|
|
5
|
+
key: field.type === "file" ? "form.error.file_size" : "form.error.image_size",
|
|
6
6
|
context: {
|
|
7
7
|
maxSizeToMb: (field?.extra?.limit.maxSize || DEFAULT_FILE_MAX_SIZE) / 1e6
|
|
8
8
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/validators/utils/file.ts"],
|
|
4
|
-
"sourcesContent": ["import { FieldSpec } from '@digigov/form/types';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\n\nconst DEFAULT_FILE_MAX_SIZE = 10000000;\n\nexport const FILE_MAX_SIZE_VALIDATOR = (field: FieldSpec): ValidatorSchema => ({\n name: 'file-max-size-validator',\n message: {\n key: 'form.error.file_size',\n context: {\n maxSizeToMb: (field?.extra?.limit.maxSize || DEFAULT_FILE_MAX_SIZE) / 1000000,\n },\n },\n test: (value: File[]): boolean => {\n if (value) {\n for (const file of value) {\n const maxSize = field?.extra?.limit?.maxSize || DEFAULT_FILE_MAX_SIZE\n if (file.size > maxSize) {\n return false;\n }\n }\n }\n return true;\n },\n});\n"],
|
|
5
|
-
"mappings": "AAGA,MAAM,wBAAwB;AAEvB,MAAM,0BAA0B,CAAC,WAAuC;AAAA,EAC7E,MAAM;AAAA,EACN,SAAS;AAAA,IACP,KAAK;AAAA,
|
|
4
|
+
"sourcesContent": ["import { FieldSpec } from '@digigov/form/types';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\n\nconst DEFAULT_FILE_MAX_SIZE = 10000000;\n\nexport const FILE_MAX_SIZE_VALIDATOR = (field: FieldSpec): ValidatorSchema => ({\n name: 'file-max-size-validator',\n message: {\n key: field.type === 'file' ? 'form.error.file_size' : 'form.error.image_size',\n context: {\n maxSizeToMb: (field?.extra?.limit.maxSize || DEFAULT_FILE_MAX_SIZE) / 1000000,\n },\n },\n test: (value: File[]): boolean => {\n if (value) {\n for (const file of value) {\n const maxSize = field?.extra?.limit?.maxSize || DEFAULT_FILE_MAX_SIZE\n if (file.size > maxSize) {\n return false;\n }\n }\n }\n return true;\n },\n});\n"],
|
|
5
|
+
"mappings": "AAGA,MAAM,wBAAwB;AAEvB,MAAM,0BAA0B,CAAC,WAAuC;AAAA,EAC7E,MAAM;AAAA,EACN,SAAS;AAAA,IACP,KAAK,MAAM,SAAS,SAAS,yBAAyB;AAAA,IACtD,SAAS;AAAA,MACP,cAAc,OAAO,OAAO,MAAM,WAAW,yBAAyB;AAAA,IACxE;AAAA,EACF;AAAA,EACA,MAAM,CAAC,UAA2B;AAChC,QAAI,OAAO;AACT,iBAAW,QAAQ,OAAO;AACxB,cAAM,UAAU,OAAO,OAAO,OAAO,WAAW;AAChD,YAAI,KAAK,OAAO,SAAS;AACvB,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/index.tsx
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import React, { useCallback, useContext, useRef } from 'react';
|
|
3
|
-
import { useForm } from 'react-hook-form';
|
|
4
|
-
import Field from '@digigov/form/Field';
|
|
5
|
-
import Fieldset from '@digigov/form/Fieldset';
|
|
6
|
-
import { FormContext } from '@digigov/form/FormContext';
|
|
7
|
-
import { FormBaseProps, FormData, FormBuilderProps } from '@digigov/form/types';
|
|
8
|
-
import { yupResolver } from '@digigov/form/utils';
|
|
9
|
-
import { useValidationSchema } from '@digigov/form/validators';
|
|
10
|
-
import { Form } from '@digigov/react-core/Form';
|
|
11
|
-
import { Button } from '@digigov/ui/form/Button';
|
|
12
|
-
|
|
13
|
-
const FormBase = React.forwardRef(function FormBase(
|
|
14
|
-
{
|
|
15
|
-
onSubmit,
|
|
16
|
-
children,
|
|
17
|
-
registerField,
|
|
18
|
-
fieldsMap,
|
|
19
|
-
fieldsetsMap,
|
|
20
|
-
resolver,
|
|
21
|
-
mode,
|
|
22
|
-
initial,
|
|
23
|
-
reValidateMode,
|
|
24
|
-
shouldFocusError,
|
|
25
|
-
criteriaMode,
|
|
26
|
-
componentRegistry,
|
|
27
|
-
grid,
|
|
28
|
-
...props
|
|
29
|
-
}: FormBaseProps,
|
|
30
|
-
ref: React.Ref<HTMLFormElement>
|
|
31
|
-
) {
|
|
32
|
-
const form = useForm({
|
|
33
|
-
resolver,
|
|
34
|
-
mode,
|
|
35
|
-
defaultValues: initial,
|
|
36
|
-
reValidateMode,
|
|
37
|
-
shouldFocusError,
|
|
38
|
-
criteriaMode,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const handleSubmit = useCallback(
|
|
42
|
-
(data: FormData): void => {
|
|
43
|
-
onSubmit && onSubmit(data);
|
|
44
|
-
},
|
|
45
|
-
[onSubmit]
|
|
46
|
-
);
|
|
47
|
-
const submit = form.handleSubmit(handleSubmit);
|
|
48
|
-
|
|
49
|
-
const ctx = {
|
|
50
|
-
fieldsMap,
|
|
51
|
-
fieldsetsMap,
|
|
52
|
-
control: form.control,
|
|
53
|
-
register: form.register,
|
|
54
|
-
watch: form.watch,
|
|
55
|
-
resetField: form.resetField,
|
|
56
|
-
registerField: registerField,
|
|
57
|
-
errors: form.formState.errors,
|
|
58
|
-
formState: form.formState,
|
|
59
|
-
reset: form.reset,
|
|
60
|
-
trigger: form.trigger,
|
|
61
|
-
getFieldState: form.getFieldState,
|
|
62
|
-
setValue: form.setValue,
|
|
63
|
-
clearErrors: form.clearErrors,
|
|
64
|
-
getValues: form.getValues,
|
|
65
|
-
unregister: form.unregister,
|
|
66
|
-
componentRegistry,
|
|
67
|
-
setError: form.setError,
|
|
68
|
-
formRef: ref,
|
|
69
|
-
submit,
|
|
70
|
-
};
|
|
71
|
-
return (
|
|
72
|
-
<FormContext.Provider value={ctx}>
|
|
73
|
-
<Form grid={grid} onSubmit={submit} ref={ref} {...props}>
|
|
74
|
-
{children}
|
|
75
|
-
</Form>
|
|
76
|
-
</FormContext.Provider>
|
|
77
|
-
);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const useFormContext = () => {
|
|
81
|
-
return useContext(FormContext);
|
|
82
|
-
};
|
|
83
|
-
const useFormValues = () => {
|
|
84
|
-
const ctx = useFormContext();
|
|
85
|
-
return ctx.getValues();
|
|
86
|
-
};
|
|
87
|
-
const FormBuilder = React.forwardRef(function FormBuilder(
|
|
88
|
-
{
|
|
89
|
-
fields = [],
|
|
90
|
-
fieldsets,
|
|
91
|
-
initial = {},
|
|
92
|
-
onSubmit,
|
|
93
|
-
children,
|
|
94
|
-
reValidateMode = 'onSubmit',
|
|
95
|
-
mode = 'onSubmit',
|
|
96
|
-
shouldFocusError = true,
|
|
97
|
-
criteriaMode = 'all',
|
|
98
|
-
auto = false,
|
|
99
|
-
validatorRegistry,
|
|
100
|
-
componentRegistry,
|
|
101
|
-
grid = false,
|
|
102
|
-
...props
|
|
103
|
-
}: FormBuilderProps,
|
|
104
|
-
ref: React.Ref<HTMLFormElement>
|
|
105
|
-
): React.ReactElement {
|
|
106
|
-
const fieldsState = useRef(fields);
|
|
107
|
-
const setFieldsState = useCallback((newFields) => {
|
|
108
|
-
fieldsState.current = newFields;
|
|
109
|
-
}, []);
|
|
110
|
-
const schema = useValidationSchema(fieldsState, validatorRegistry);
|
|
111
|
-
const registerField = useCallback((field) => {
|
|
112
|
-
const fieldIndex = fieldsState.current.findIndex(
|
|
113
|
-
(f) => f.key === field.key
|
|
114
|
-
);
|
|
115
|
-
if (fieldIndex > -1) {
|
|
116
|
-
fieldsState.current[fieldIndex] = field;
|
|
117
|
-
} else {
|
|
118
|
-
fieldsState.current.push(field);
|
|
119
|
-
}
|
|
120
|
-
setFieldsState(fieldsState.current);
|
|
121
|
-
}, []);
|
|
122
|
-
let resolver;
|
|
123
|
-
let fieldsMap;
|
|
124
|
-
let fieldsetsMap;
|
|
125
|
-
let fieldChildren;
|
|
126
|
-
if (schema) {
|
|
127
|
-
resolver = yupResolver(schema);
|
|
128
|
-
fieldsMap = fields
|
|
129
|
-
? fields.reduce((map, field) => ({ ...map, [field.key]: field }), {})
|
|
130
|
-
: {};
|
|
131
|
-
fieldsetsMap =
|
|
132
|
-
fieldsets &&
|
|
133
|
-
fieldsets.reduce(
|
|
134
|
-
(map, fieldset) => ({ ...map, [fieldset.key]: fieldset }),
|
|
135
|
-
{}
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
if (auto) {
|
|
139
|
-
if (fieldsets) {
|
|
140
|
-
fieldChildren = fieldsets.map((fieldset) => (
|
|
141
|
-
<Fieldset key={fieldset.key} />
|
|
142
|
-
));
|
|
143
|
-
} else if (fields) {
|
|
144
|
-
fieldChildren = fields.map((field) => (
|
|
145
|
-
<Field key={field.key} name={field.key} />
|
|
146
|
-
));
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return (
|
|
151
|
-
<FormBase
|
|
152
|
-
resolver={resolver}
|
|
153
|
-
fieldsetsMap={fieldsetsMap}
|
|
154
|
-
fieldsMap={fieldsMap}
|
|
155
|
-
registerField={registerField}
|
|
156
|
-
initial={initial}
|
|
157
|
-
reValidateMode={reValidateMode}
|
|
158
|
-
mode={mode}
|
|
159
|
-
shouldFocusError={shouldFocusError}
|
|
160
|
-
criteriaMode={criteriaMode}
|
|
161
|
-
onSubmit={onSubmit}
|
|
162
|
-
componentRegistry={componentRegistry}
|
|
163
|
-
ref={ref}
|
|
164
|
-
grid={grid}
|
|
165
|
-
{...props}
|
|
166
|
-
>
|
|
167
|
-
{fieldChildren}
|
|
168
|
-
{auto && <Button type="submit">Συνέχεια</Button>}
|
|
169
|
-
{children}
|
|
170
|
-
</FormBase>
|
|
171
|
-
);
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
export { FormBase, useFormContext, useFormValues, FormBuilder };
|
|
175
|
-
|
|
176
|
-
export * from '@digigov/form/internal';
|
|
177
|
-
|
|
178
|
-
export default FormBuilder;
|