@digigov/form 2.0.0-2445d5cb → 2.0.0-298cfc51

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.
Files changed (245) hide show
  1. package/Field/FieldBase/index.js +1 -0
  2. package/Field/FieldBase.js.map +2 -2
  3. package/Field/FieldBaseContainer/index.js +2 -2
  4. package/Field/FieldBaseContainer.js.map +2 -2
  5. package/Field/FieldConditional/index.js +7 -3
  6. package/Field/FieldConditional.js.map +2 -2
  7. package/Field/index.js +5 -2
  8. package/Field/index.js.map +2 -2
  9. package/Field/types.d.ts +5 -1
  10. package/Field/utils/index.d.ts +1 -0
  11. package/Field/utils/index.js +18 -1
  12. package/Field/utils/index.js.map +2 -2
  13. package/FieldArray/index.d.ts +1 -0
  14. package/FieldArray/index.js +7 -5
  15. package/FieldArray/index.js.map +2 -2
  16. package/FieldObject/index.d.ts +2 -0
  17. package/FieldObject/index.js +9 -5
  18. package/FieldObject/index.js.map +2 -2
  19. package/Fieldset/index.d.ts +1 -1
  20. package/Fieldset/index.js +5 -5
  21. package/Fieldset/index.js.map +2 -2
  22. package/Fieldset/types.d.ts +2 -3
  23. package/FormBuilder/index.d.ts +8 -2
  24. package/FormBuilder/index.js +150 -6
  25. package/FormBuilder/index.js.map +3 -3
  26. package/MultiplicityField/add-objects/index.js +7 -5
  27. package/MultiplicityField/add-objects.js.map +2 -2
  28. package/MultiplicityField/index.js +16 -12
  29. package/MultiplicityField/index.js.map +2 -2
  30. package/Questions/QuestionsContext.d.ts +0 -1
  31. package/Questions/Step/StepContext.d.ts +0 -1
  32. package/Questions/Step/StepTitle/index.js +4 -3
  33. package/Questions/Step/StepTitle.d.ts +1 -1
  34. package/Questions/Step/StepTitle.js.map +2 -2
  35. package/Questions/Step/types.d.ts +0 -1
  36. package/Questions/types.d.ts +0 -1
  37. package/cjs/Field/FieldBase/index.js +1 -0
  38. package/cjs/Field/FieldBase.js.map +2 -2
  39. package/cjs/Field/FieldBaseContainer/index.js +4 -4
  40. package/cjs/Field/FieldBaseContainer.js.map +3 -3
  41. package/cjs/Field/FieldConditional/index.js +7 -3
  42. package/cjs/Field/FieldConditional.js.map +2 -2
  43. package/cjs/Field/index.js +5 -2
  44. package/cjs/Field/index.js.map +2 -2
  45. package/cjs/Field/types.js.map +1 -1
  46. package/cjs/Field/utils/index.js +18 -0
  47. package/cjs/Field/utils/index.js.map +2 -2
  48. package/cjs/FieldArray/index.js +9 -7
  49. package/cjs/FieldArray/index.js.map +3 -3
  50. package/cjs/FieldObject/index.js +10 -6
  51. package/cjs/FieldObject/index.js.map +3 -3
  52. package/cjs/Fieldset/index.js +10 -10
  53. package/cjs/Fieldset/index.js.map +3 -3
  54. package/cjs/Fieldset/types.js.map +1 -1
  55. package/cjs/FormBuilder/index.js +165 -5
  56. package/cjs/FormBuilder/index.js.map +3 -3
  57. package/cjs/MultiplicityField/add-objects/index.js +11 -9
  58. package/cjs/MultiplicityField/add-objects.js.map +3 -3
  59. package/cjs/MultiplicityField/index.js +15 -16
  60. package/cjs/MultiplicityField/index.js.map +3 -3
  61. package/cjs/Questions/Step/StepTitle/index.js +5 -5
  62. package/cjs/Questions/Step/StepTitle.js.map +3 -3
  63. package/cjs/index.js +11 -155
  64. package/cjs/index.js.map +4 -4
  65. package/cjs/inputs/AutoCompleteInput/__stories__/Multiple/index.js +0 -1
  66. package/cjs/inputs/AutoCompleteInput/__stories__/Multiple.js.map +2 -2
  67. package/cjs/inputs/AutoCompleteInput/index.js +8 -6
  68. package/cjs/inputs/AutoCompleteInput/index.js.map +3 -3
  69. package/cjs/inputs/Checkboxes/index.js +7 -9
  70. package/cjs/inputs/Checkboxes/index.js.map +3 -3
  71. package/cjs/inputs/DateInput/index.js +3 -4
  72. package/cjs/inputs/DateInput/index.js.map +3 -3
  73. package/cjs/inputs/FileInput/index.js +7 -8
  74. package/cjs/inputs/FileInput/index.js.map +3 -3
  75. package/cjs/inputs/ImageInput/ImageInput.stories/index.js +4 -4
  76. package/cjs/inputs/ImageInput/ImageInput.stories.js.map +2 -2
  77. package/cjs/inputs/ImageInput/__stories__/MaxSize/index.js +69 -0
  78. package/cjs/inputs/ImageInput/__stories__/MaxSize.js.map +7 -0
  79. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +2 -1
  80. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +2 -2
  81. package/cjs/inputs/ImageInput/index.js +8 -8
  82. package/cjs/inputs/ImageInput/index.js.map +3 -3
  83. package/cjs/inputs/Input/__stories__/LandlineNumber/index.js +1 -0
  84. package/cjs/inputs/Input/__stories__/LandlineNumber.js.map +2 -2
  85. package/cjs/inputs/Input/__stories__/MobilePhone/index.js +1 -0
  86. package/cjs/inputs/Input/__stories__/MobilePhone.js.map +2 -2
  87. package/cjs/inputs/Input/__stories__/PhoneNumber/index.js +1 -0
  88. package/cjs/inputs/Input/__stories__/PhoneNumber.js.map +2 -2
  89. package/cjs/inputs/Input/__stories__/PostalCode/index.js +1 -0
  90. package/cjs/inputs/Input/__stories__/PostalCode.js.map +2 -2
  91. package/cjs/inputs/Input/index.js +20 -7
  92. package/cjs/inputs/Input/index.js.map +3 -3
  93. package/cjs/inputs/Label/index.js +3 -3
  94. package/cjs/inputs/Label/index.js.map +3 -3
  95. package/cjs/inputs/Radio/__stories__/Conditional.js.map +2 -2
  96. package/cjs/inputs/Radio/index.js +56 -10
  97. package/cjs/inputs/Radio/index.js.map +3 -3
  98. package/cjs/inputs/Select/index.js +3 -4
  99. package/cjs/inputs/Select/index.js.map +3 -3
  100. package/cjs/inputs/inputsScenarios/index.js +0 -1
  101. package/cjs/inputs/inputsScenarios.js.map +2 -2
  102. package/cjs/lazy/index.js +7 -2
  103. package/cjs/lazy.js.map +2 -2
  104. package/cjs/registry/index.js +2 -0
  105. package/cjs/registry.js.map +2 -2
  106. package/cjs/types.js.map +1 -1
  107. package/cjs/validators/index.js +16 -66
  108. package/cjs/validators/index.js.map +3 -3
  109. package/cjs/validators/utils/date/index.js +138 -0
  110. package/cjs/validators/utils/date.js.map +7 -0
  111. package/cjs/validators/utils/file/index.js +1 -1
  112. package/cjs/validators/utils/file.js.map +2 -2
  113. package/cjs/validators/utils/index.js +3 -1
  114. package/cjs/validators/utils/index.js.map +2 -2
  115. package/index.d.ts +5 -8
  116. package/index.js +9 -152
  117. package/index.js.map +4 -4
  118. package/inputs/AutoCompleteInput/__stories__/Multiple/index.js +0 -1
  119. package/inputs/AutoCompleteInput/__stories__/Multiple.js.map +2 -2
  120. package/inputs/AutoCompleteInput/index.js +10 -6
  121. package/inputs/AutoCompleteInput/index.js.map +2 -2
  122. package/inputs/Checkboxes/index.js +8 -6
  123. package/inputs/Checkboxes/index.js.map +2 -2
  124. package/inputs/DateInput/index.js +5 -3
  125. package/inputs/DateInput/index.js.map +2 -2
  126. package/inputs/FileInput/index.js +5 -6
  127. package/inputs/FileInput/index.js.map +2 -2
  128. package/inputs/ImageInput/ImageInput.stories/index.js +2 -2
  129. package/inputs/ImageInput/ImageInput.stories.d.ts +1 -1
  130. package/inputs/ImageInput/ImageInput.stories.js.map +2 -2
  131. package/inputs/ImageInput/__stories__/MaxSize/index.js +36 -0
  132. package/inputs/ImageInput/__stories__/MaxSize/package.json +6 -0
  133. package/inputs/ImageInput/__stories__/MaxSize.d.ts +3 -0
  134. package/inputs/ImageInput/__stories__/MaxSize.js.map +7 -0
  135. package/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +2 -1
  136. package/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +2 -2
  137. package/inputs/ImageInput/index.js +7 -7
  138. package/inputs/ImageInput/index.js.map +2 -2
  139. package/inputs/Input/__stories__/LandlineNumber/index.js +1 -0
  140. package/inputs/Input/__stories__/LandlineNumber.js.map +2 -2
  141. package/inputs/Input/__stories__/MobilePhone/index.js +1 -0
  142. package/inputs/Input/__stories__/MobilePhone.js.map +2 -2
  143. package/inputs/Input/__stories__/PhoneNumber/index.js +1 -0
  144. package/inputs/Input/__stories__/PhoneNumber.js.map +2 -2
  145. package/inputs/Input/__stories__/PostalCode/index.js +1 -0
  146. package/inputs/Input/__stories__/PostalCode.js.map +2 -2
  147. package/inputs/Input/index.js +18 -5
  148. package/inputs/Input/index.js.map +3 -3
  149. package/inputs/Label/index.js +2 -2
  150. package/inputs/Label/index.js.map +2 -2
  151. package/inputs/Radio/__stories__/Conditional.js.map +2 -2
  152. package/inputs/Radio/index.d.ts +4 -0
  153. package/inputs/Radio/index.js +57 -8
  154. package/inputs/Radio/index.js.map +2 -2
  155. package/inputs/Select/index.js +1 -2
  156. package/inputs/Select/index.js.map +2 -2
  157. package/inputs/inputsScenarios/index.js +0 -1
  158. package/inputs/inputsScenarios.d.ts +0 -42
  159. package/inputs/inputsScenarios.js.map +2 -2
  160. package/lazy/index.js +7 -2
  161. package/lazy.d.ts +16 -8
  162. package/lazy.js.map +2 -2
  163. package/package.json +4 -4
  164. package/registry/index.js +2 -0
  165. package/registry.d.ts +1 -0
  166. package/registry.js.map +2 -2
  167. package/src/Field/FieldBase.tsx +1 -0
  168. package/src/Field/FieldBaseContainer.tsx +2 -2
  169. package/src/Field/FieldConditional.tsx +4 -0
  170. package/src/Field/index.tsx +4 -1
  171. package/src/Field/types.tsx +24 -20
  172. package/src/Field/utils/index.ts +18 -1
  173. package/src/FieldArray/index.tsx +9 -5
  174. package/src/FieldObject/index.tsx +8 -2
  175. package/src/Fieldset/index.tsx +5 -5
  176. package/src/Fieldset/types.tsx +2 -2
  177. package/src/FormBuilder/{FormBuilder.mdx → doc.mdx} +20 -33
  178. package/src/FormBuilder/index.tsx +179 -7
  179. package/src/FormBuilder/scenarios.test.tsx +2 -2
  180. package/src/MultiplicityField/add-objects.tsx +6 -5
  181. package/src/MultiplicityField/{MultiplicityField.mdx → doc.mdx} +12 -16
  182. package/src/MultiplicityField/index.tsx +15 -12
  183. package/src/Questions/Step/StepTitle.tsx +4 -3
  184. package/src/Questions/__snapshots__/index.spec.tsx.snap +8 -4
  185. package/src/Questions/{index.mdx → doc.mdx} +9 -12
  186. package/src/create-simple-form.mdx +2 -6
  187. package/src/{index.mdx → doc.mdx} +4 -8
  188. package/src/index.ts +6 -0
  189. package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +0 -1
  190. package/src/inputs/AutoCompleteInput/{index.mdx → doc.mdx} +2 -13
  191. package/src/inputs/AutoCompleteInput/index.tsx +36 -29
  192. package/src/inputs/Checkboxes/{index.mdx → doc.mdx} +5 -15
  193. package/src/inputs/Checkboxes/index.test.tsx +16 -17
  194. package/src/inputs/Checkboxes/index.tsx +9 -7
  195. package/src/inputs/DateInput/{index.mdx → doc.mdx} +1 -8
  196. package/src/inputs/DateInput/index.tsx +5 -3
  197. package/src/inputs/FileInput/{index.mdx → doc.mdx} +1 -5
  198. package/src/inputs/FileInput/index.tsx +5 -6
  199. package/src/inputs/ImageInput/ImageInput.stories.js +2 -1
  200. package/src/inputs/ImageInput/__stories__/MaxSize.tsx +37 -0
  201. package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +2 -0
  202. package/src/inputs/ImageInput/doc.mdx +23 -0
  203. package/src/inputs/ImageInput/index.test.tsx +4 -0
  204. package/src/inputs/ImageInput/index.tsx +9 -11
  205. package/src/inputs/Input/__stories__/LandlineNumber.tsx +2 -1
  206. package/src/inputs/Input/__stories__/MobilePhone.tsx +1 -0
  207. package/src/inputs/Input/__stories__/PhoneNumber.tsx +1 -0
  208. package/src/inputs/Input/__stories__/PostalCode.tsx +1 -0
  209. package/src/inputs/Input/doc.mdx +56 -0
  210. package/src/inputs/Input/index.tsx +33 -30
  211. package/src/inputs/Label/doc.mdx +14 -0
  212. package/src/inputs/Label/index.tsx +2 -3
  213. package/src/inputs/OtpInput/{index.mdx → doc.mdx} +1 -8
  214. package/src/inputs/Radio/__stories__/Conditional.tsx +2 -1
  215. package/src/inputs/Radio/{index.mdx → doc.mdx} +5 -15
  216. package/src/inputs/Radio/index.tsx +75 -9
  217. package/src/inputs/Select/{index.mdx → doc.mdx} +1 -5
  218. package/src/inputs/Select/index.tsx +1 -2
  219. package/src/inputs/inputsScenarios.ts +147 -148
  220. package/src/installation.mdx +2 -5
  221. package/src/lazy.js +7 -2
  222. package/src/registry.js +2 -0
  223. package/src/types.tsx +1 -0
  224. package/src/validators/index.ts +33 -71
  225. package/src/validators/utils/date.ts +107 -0
  226. package/src/validators/utils/file.ts +1 -1
  227. package/src/validators/utils/index.ts +1 -0
  228. package/types.d.ts +1 -1
  229. package/types.js.map +1 -1
  230. package/validators/index.js +20 -67
  231. package/validators/index.js.map +2 -2
  232. package/validators/utils/date/index.js +103 -0
  233. package/validators/utils/date/package.json +6 -0
  234. package/validators/utils/date.d.ts +9 -0
  235. package/validators/utils/date.js.map +7 -0
  236. package/validators/utils/file/index.js +1 -1
  237. package/validators/utils/file.js.map +2 -2
  238. package/validators/utils/index.d.ts +1 -0
  239. package/validators/utils/index.js +1 -0
  240. package/validators/utils/index.js.map +2 -2
  241. package/src/index.tsx +0 -178
  242. package/src/inputs/ImageInput/index.mdx +0 -19
  243. package/src/inputs/Input/index.mdx +0 -95
  244. package/src/inputs/Label/index.mdx +0 -0
  245. /package/src/Field/{index.mdx → doc.mdx} +0 -0
@@ -1,160 +1,159 @@
1
1
  import el from '@digigov/form/locales/el';
2
2
 
3
3
  export const INPUTS_FIELDS = [
4
- {
5
- key: 'date-example',
6
- type: 'date',
7
- required: true,
8
- label: {
9
- primary: 'Ποιά είναι η ημερομηνία γέννησής σας;',
10
- secondary:
11
- 'Για παράδειγμα, 05 11 2020',
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
- key: 'radio',
71
- type: 'choice:single',
72
- required: true,
73
- label: { primary: 'Πώς αισθάνεστε αυτή τη στιγμή;' },
74
- extra: {
75
- options: [
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
- key: 'select',
93
- type: 'choice:single',
94
- required: true,
95
- label: { primary: 'Πώς αισθάνεστε αυτή τη στιγμή;' },
96
- extra: {
97
- component: 'Select',
98
- options: [
99
- {
100
- label: { primary: '' },
101
- value: '',
102
- },
103
- {
104
- label: { primary: 'Έχω συνάχι' },
105
- value: 'runny-nose',
106
- },
107
- {
108
- label: { primary: 'Έχω πυρετό' },
109
- value: 'fever',
110
- },
111
- {
112
- label: { primary: 'Αισθάνομαι κούραση' },
113
- value: 'fatigue',
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
- key: 'autocomplete_single',
120
- required: true,
121
- type: 'choice:single',
122
- label: { primary: 'Πώς αισθάνεστε αυτή τη στιγμή;' },
123
- extra: {
124
- component: 'AutoComplete',
125
- options: [
126
- {
127
- label: { primary: 'Έχω συνάχι' },
128
- value: 'runny-nose',
129
- },
130
- {
131
- label: { primary: 'Έχω πυρετό' },
132
- value: 'fever',
133
- },
134
- {
135
- label: { primary: 'Αισθάνομαι κούραση' },
136
- value: 'fatigue',
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
- key: 'image',
143
- type: 'image',
144
- required: true,
145
- label: {
146
- primary: 'Ανεβάστε τη φωτογραφία του προστίμου',
147
- },
139
+ },
140
+ {
141
+ key: 'image',
142
+ type: 'image',
143
+ required: true,
144
+ label: {
145
+ primary: 'Ανεβάστε τη φωτογραφία του προστίμου',
148
146
  },
149
- {
150
- key: 'file',
151
- type: 'file',
152
- label: {
153
- primary: 'Ανεβάστε το αρχείο της απόδειξης',
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
  {
@@ -7,12 +7,9 @@ sidebar_label: Installation
7
7
  import Tabs from '@theme/Tabs';
8
8
  import TabItem from '@theme/TabItem';
9
9
  import CodeBlock from '@theme/CodeBlock';
10
- import LeadText from '@site/src/components/LeadText';
11
10
 
12
- <LeadText>
13
- This page will help you install Digigov Form depending on the framework that
14
- you use and the application architecture.
15
- </LeadText>
11
+ This page will help you install Digigov Form depending on the framework that
12
+ you use and the application architecture.
16
13
 
17
14
  We assume that your stack uses some of the following tools.
18
15
 
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
- 'FormBuilder': lazy(() => import('@digigov/form').then((module)=> ({default: module['FormBuilder']}))),
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']}))),
@@ -48,6 +50,9 @@ export default {
48
50
  'Questions': lazy(() => import('@digigov/form/Questions/Questions').then((module)=> ({default: module['Questions']}))),
49
51
  'QuestionsContext': lazy(() => import('@digigov/form/Questions/QuestionsContext').then((module)=> ({default: module['QuestionsContext']}))),
50
52
  'AFM_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/afm').then((module)=> ({default: module['AFM_VALIDATOR']}))),
53
+ 'DATE_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/date').then((module)=> ({default: module['DATE_VALIDATOR']}))),
54
+ 'EARLIER_THAN_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/date').then((module)=> ({default: module['EARLIER_THAN_VALIDATOR']}))),
55
+ 'LATER_THAN_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/date').then((module)=> ({default: module['LATER_THAN_VALIDATOR']}))),
51
56
  'FILE_MAX_SIZE_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/file').then((module)=> ({default: module['FILE_MAX_SIZE_VALIDATOR']}))),
52
57
  'IBAN_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/iban').then((module)=> ({default: module['IBAN_VALIDATOR']}))),
53
58
  'IMAGE_DIMENSION_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/image').then((module)=> ({default: module['IMAGE_DIMENSION_VALIDATOR']}))),
package/src/registry.js CHANGED
@@ -55,6 +55,7 @@ import * as _digigov_form_utils from '@digigov/form/utils';
55
55
  import * as _digigov_form_validators from '@digigov/form/validators';
56
56
  import * as _digigov_form_validators_types from '@digigov/form/validators/types';
57
57
  import * as _digigov_form_validators_utils_afm from '@digigov/form/validators/utils/afm';
58
+ import * as _digigov_form_validators_utils_date from '@digigov/form/validators/utils/date';
58
59
  import * as _digigov_form_validators_utils_file from '@digigov/form/validators/utils/file';
59
60
  import * as _digigov_form_validators_utils_iban from '@digigov/form/validators/utils/iban';
60
61
  import * as _digigov_form_validators_utils_image from '@digigov/form/validators/utils/image';
@@ -142,6 +143,7 @@ export default {
142
143
  '@digigov/form/validators': lazyImport(_digigov_form_validators),
143
144
  '@digigov/form/validators/types': lazyImport(_digigov_form_validators_types),
144
145
  '@digigov/form/validators/utils/afm': lazyImport(_digigov_form_validators_utils_afm),
146
+ '@digigov/form/validators/utils/date': lazyImport(_digigov_form_validators_utils_date),
145
147
  '@digigov/form/validators/utils/file': lazyImport(_digigov_form_validators_utils_file),
146
148
  '@digigov/form/validators/utils/iban': lazyImport(_digigov_form_validators_utils_iban),
147
149
  '@digigov/form/validators/utils/image': lazyImport(_digigov_form_validators_utils_image),
package/src/types.tsx CHANGED
@@ -53,6 +53,7 @@ export interface FormBuilderProps {
53
53
  validatorRegistry?: Record<string, ValidatorSchema[]>;
54
54
  componentRegistry?: FieldComponentRegistry;
55
55
  grid?: boolean;
56
+ controlledFieldsOnly?: boolean;
56
57
  }
57
58
 
58
59
  export interface FormBaseProps
@@ -1,6 +1,4 @@
1
1
  import { MutableRefObject, useMemo } from 'react';
2
- import dayjs from 'dayjs';
3
- import customParseFormat from 'dayjs/plugin/customParseFormat';
4
2
  import * as yup from 'yup';
5
3
  import { AnyObjectSchema, StringSchema } from 'yup';
6
4
  import { RequiredArraySchema } from 'yup/lib/array';
@@ -22,16 +20,12 @@ import {
22
20
  POSTALCODE_VALIDATOR,
23
21
  UUID4_VALIDATOR,
24
22
  IMAGE_DIMENSION_VALIDATOR,
23
+ DATE_VALIDATOR,
24
+ LATER_THAN_VALIDATOR,
25
+ EARLIER_THAN_VALIDATOR,
25
26
  } from '@digigov/form/validators/utils';
26
27
  import { INT_VALIDATOR } from '@digigov/form/validators/utils/int';
27
28
  import { NUMBER_VALIDATOR } from '@digigov/form/validators/utils/number';
28
- dayjs.extend(customParseFormat);
29
-
30
- const VALID_DATE_FORMATS = ['DD/MM/YYYY'];
31
- const DATE_CACHE = {};
32
- const getDate = (v) => {
33
- return DATE_CACHE[v] ? DATE_CACHE[v] : dayjs(v, VALID_DATE_FORMATS, true);
34
- };
35
29
 
36
30
  export const getYUPTypeMap = (): Record<string, any> => {
37
31
  const yupTypeMap = {
@@ -48,7 +42,21 @@ export const getYUPTypeMap = (): Record<string, any> => {
48
42
  .test(FILE_MAX_SIZE_VALIDATOR(field));
49
43
  },
50
44
  string: yup.string,
51
- boolean: yup.boolean,
45
+ boolean: (): yup.BooleanSchema<
46
+ boolean | null | undefined,
47
+ AnyObject,
48
+ boolean | null | undefined
49
+ > => {
50
+ return yup
51
+ .boolean()
52
+ .nullable()
53
+ .transform((value) => {
54
+ if (value === '' || typeof value === 'string') return null;
55
+ if (typeof value === 'boolean') return value;
56
+ if (value === 0 || value === 1) return Boolean(value);
57
+ return value;
58
+ });
59
+ },
52
60
  object: (
53
61
  field
54
62
  ):
@@ -150,69 +158,23 @@ export const getYUPTypeMap = (): Record<string, any> => {
150
158
  AnyObject,
151
159
  string | null | undefined
152
160
  > => yup.string().nullable(),
153
- date: (field) => {
154
- let simpleDate = yup
155
- .string()
156
- .nullable(true)
157
- .test('date', 'form.error.date.invalid', function (value) {
158
- if (!value) return true;
159
- const date = getDate(value);
160
- return date.isValid();
161
- });
162
- const params = field.extra || {};
163
- if (params.max) {
164
- let maxDate;
165
- if (params.max === 'now') {
166
- const today = new Date();
167
- maxDate = new Date(today);
168
- } else {
169
- maxDate = getDate(params.max).toDate();
170
- }
171
- const maxNextDate = new Date(maxDate);
172
- maxNextDate.setDate(maxDate.getDate() + 1);
173
- simpleDate = simpleDate.test({
174
- name: 'earlier-than',
175
- message: {
176
- key: 'form.error.date.earlier_than',
177
- context: {
178
- maxDate: maxNextDate.toLocaleDateString(),
179
- },
180
- },
181
- test: function (value) {
182
- if (!value) return true;
183
- const date = getDate(value);
184
- const isValid = +date.toDate() < +maxDate;
185
- return isValid;
186
- },
187
- });
161
+ date: (
162
+ field
163
+ ): yup.StringSchema<
164
+ string | null | undefined,
165
+ AnyObject,
166
+ string | null | undefined
167
+ > => {
168
+ let schema = yup.string().nullable();
169
+ if (field?.extra?.min) {
170
+ schema = schema.test(LATER_THAN_VALIDATOR(field));
188
171
  }
189
- if (params.min) {
190
- let minDate;
191
- if (params.min === 'now') {
192
- const today = new Date();
193
- minDate = new Date(today);
194
- } else {
195
- minDate = getDate(params.min).toDate();
196
- }
197
- const minPreviousDate = new Date(minDate);
198
- minPreviousDate.setDate(minDate.getDate() - 1);
199
- simpleDate = simpleDate.test({
200
- name: 'later-than',
201
- message: {
202
- key: 'form.error.date.later_than',
203
- context: {
204
- minDate: minPreviousDate.toLocaleDateString(),
205
- },
206
- },
207
- test: function (value) {
208
- if (!value) return true;
209
- const date = getDate(value);
210
- const isValid = +date.toDate() > +minDate;
211
- return isValid;
212
- },
213
- });
172
+ if (field?.extra?.max) {
173
+ schema = schema.test(EARLIER_THAN_VALIDATOR(field));
174
+ } else {
175
+ schema = schema.test(DATE_VALIDATOR);
214
176
  }
215
- return simpleDate;
177
+ return schema;
216
178
  },
217
179
  };
218
180
  return yupTypeMap;
@@ -0,0 +1,107 @@
1
+ import dayjs from 'dayjs';
2
+ import customParseFormat from 'dayjs/plugin/customParseFormat';
3
+ import { FieldSpec } from '@digigov/form/types';
4
+ import { ValidatorSchema } from '@digigov/form/validators/types';
5
+
6
+ dayjs.extend(customParseFormat);
7
+
8
+ const VALID_DATE_FORMATS = ['DD/MM/YYYY'];
9
+ const DATE_CACHE = {};
10
+
11
+ const getDate = (v: string) => {
12
+ return DATE_CACHE[v] ? DATE_CACHE[v] : dayjs(v, VALID_DATE_FORMATS, true);
13
+ };
14
+
15
+ // Function to check partial date completion
16
+ const checkPartialDate = (value: string) => {
17
+ console.log("value.split('/')", value.split('/'));
18
+ const [day, month, year] = value.split('/');
19
+ if (day && !month && !year) {
20
+ return 'form.error.date.invalid_month_year';
21
+ }
22
+ if (!day && month && !year) {
23
+ return 'form.error.date.invalid_day_year';
24
+ }
25
+ if (!day && !month && year) {
26
+ return 'form.error.date.invalid_day_month';
27
+ }
28
+ if (day && month && !year) {
29
+ return 'form.error.date.invalid_year';
30
+ }
31
+ if (day && !month && year) {
32
+ return 'form.error.date.invalid_month';
33
+ }
34
+ if (!day && month && year) {
35
+ return 'form.error.date.invalid_day';
36
+ } else {
37
+ return 'form.error.date.invalid';
38
+ }
39
+ };
40
+
41
+ export const LATER_THAN_VALIDATOR = (field: FieldSpec): ValidatorSchema => {
42
+ let minDate;
43
+ const params = field.extra || {};
44
+ if (params.min === 'now') {
45
+ const today = new Date();
46
+ minDate = new Date(today);
47
+ } else {
48
+ minDate = getDate(params.min).toDate();
49
+ }
50
+ const minPreviousDate = new Date(minDate);
51
+ minPreviousDate.setDate(minDate.getDate() - 1);
52
+ return {
53
+ name: 'later-than',
54
+ message: {
55
+ key: 'form.error.date.later_than',
56
+ context: {
57
+ minDate: minPreviousDate.toLocaleDateString(),
58
+ },
59
+ },
60
+ test: function (value: string) {
61
+ if (!value) return true;
62
+ const date = getDate(value);
63
+ const isValid = +date.toDate() > +minDate;
64
+ return isValid;
65
+ },
66
+ };
67
+ };
68
+
69
+ export const EARLIER_THAN_VALIDATOR = (field: FieldSpec): ValidatorSchema => {
70
+ let maxDate;
71
+ const params = field.extra || {};
72
+ if (params.max === 'now') {
73
+ const today = new Date();
74
+ maxDate = new Date(today);
75
+ } else {
76
+ maxDate = getDate(params.max).toDate();
77
+ }
78
+ const maxNextDate = new Date(maxDate);
79
+ maxNextDate.setDate(maxDate.getDate() + 1);
80
+ return {
81
+ name: 'earlier-than',
82
+ message: {
83
+ key: 'form.error.date.earlier_than',
84
+ context: {
85
+ maxDate: maxNextDate.toLocaleDateString(),
86
+ },
87
+ },
88
+ test: function (value: string) {
89
+ if (!value) return true;
90
+ const date = getDate(value);
91
+ const isValid = +date.toDate() < +maxDate;
92
+ return isValid;
93
+ },
94
+ };
95
+ };
96
+
97
+ export const DATE_VALIDATOR = {
98
+ name: 'date-validator',
99
+ message: (v): string => {
100
+ return checkPartialDate(v.value);
101
+ },
102
+ test: function (value: string) {
103
+ if (!value) return true;
104
+ const date = getDate(value);
105
+ return date.isValid();
106
+ },
107
+ };
@@ -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
  },
@@ -11,6 +11,7 @@ export * from '@digigov/form/validators/utils/phone';
11
11
  export * from '@digigov/form/validators/utils/postal_code';
12
12
  export * from '@digigov/form/validators/utils/uuid4';
13
13
  export * from '@digigov/form/validators/utils/text_limit';
14
+ export * from '@digigov/form/validators/utils/date';
14
15
 
15
16
  export function getYupField(field: FieldSpec, yupTypeMap: Record<string, any>) {
16
17
  const yupField = yupTypeMap[field?.type || 'string'] || yupTypeMap['string'];
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>;