@digigov/form 2.0.0-113e6661 → 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 (202) hide show
  1. package/Field/FieldBaseContainer/index.js +1 -1
  2. package/Field/FieldBaseContainer.js.map +2 -2
  3. package/Field/types.d.ts +1 -0
  4. package/FieldArray/index.js +4 -4
  5. package/FieldArray/index.js.map +2 -2
  6. package/FieldObject/index.js +2 -2
  7. package/FieldObject/index.js.map +2 -2
  8. package/Fieldset/index.d.ts +1 -1
  9. package/Fieldset/index.js +5 -5
  10. package/Fieldset/index.js.map +2 -2
  11. package/Fieldset/types.d.ts +2 -2
  12. package/FormBuilder/index.js +3 -3
  13. package/FormBuilder/index.js.map +2 -2
  14. package/MultiplicityField/add-objects/index.js +4 -4
  15. package/MultiplicityField/add-objects.js.map +2 -2
  16. package/MultiplicityField/index.js +12 -10
  17. package/MultiplicityField/index.js.map +2 -2
  18. package/Questions/Step/StepTitle/index.js +4 -3
  19. package/Questions/Step/StepTitle.d.ts +1 -1
  20. package/Questions/Step/StepTitle.js.map +2 -2
  21. package/cjs/Field/FieldBaseContainer/index.js +2 -2
  22. package/cjs/Field/FieldBaseContainer.js.map +3 -3
  23. package/cjs/Field/types.js.map +1 -1
  24. package/cjs/FieldArray/index.js +6 -6
  25. package/cjs/FieldArray/index.js.map +3 -3
  26. package/cjs/FieldObject/index.js +3 -3
  27. package/cjs/FieldObject/index.js.map +3 -3
  28. package/cjs/Fieldset/index.js +10 -10
  29. package/cjs/Fieldset/index.js.map +3 -3
  30. package/cjs/Fieldset/types.js.map +1 -1
  31. package/cjs/FormBuilder/index.js +5 -5
  32. package/cjs/FormBuilder/index.js.map +3 -3
  33. package/cjs/MultiplicityField/add-objects/index.js +8 -8
  34. package/cjs/MultiplicityField/add-objects.js.map +3 -3
  35. package/cjs/MultiplicityField/index.js +11 -14
  36. package/cjs/MultiplicityField/index.js.map +3 -3
  37. package/cjs/Questions/Step/StepTitle/index.js +5 -5
  38. package/cjs/Questions/Step/StepTitle.js.map +3 -3
  39. package/cjs/inputs/AutoCompleteInput/__stories__/Multiple/index.js +0 -1
  40. package/cjs/inputs/AutoCompleteInput/__stories__/Multiple.js.map +2 -2
  41. package/cjs/inputs/AutoCompleteInput/index.js +7 -6
  42. package/cjs/inputs/AutoCompleteInput/index.js.map +3 -3
  43. package/cjs/inputs/Checkboxes/index.js +6 -8
  44. package/cjs/inputs/Checkboxes/index.js.map +3 -3
  45. package/cjs/inputs/DateInput/index.js +3 -4
  46. package/cjs/inputs/DateInput/index.js.map +3 -3
  47. package/cjs/inputs/FileInput/index.js +7 -8
  48. package/cjs/inputs/FileInput/index.js.map +3 -3
  49. package/cjs/inputs/ImageInput/ImageInput.stories/index.js +4 -4
  50. package/cjs/inputs/ImageInput/ImageInput.stories.js.map +2 -2
  51. package/cjs/inputs/ImageInput/__stories__/MaxSize/index.js +69 -0
  52. package/cjs/inputs/ImageInput/__stories__/MaxSize.js.map +7 -0
  53. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +2 -1
  54. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +2 -2
  55. package/cjs/inputs/ImageInput/index.js +7 -8
  56. package/cjs/inputs/ImageInput/index.js.map +3 -3
  57. package/cjs/inputs/Input/__stories__/LandlineNumber/index.js +1 -0
  58. package/cjs/inputs/Input/__stories__/LandlineNumber.js.map +2 -2
  59. package/cjs/inputs/Input/__stories__/MobilePhone/index.js +1 -0
  60. package/cjs/inputs/Input/__stories__/MobilePhone.js.map +2 -2
  61. package/cjs/inputs/Input/__stories__/PhoneNumber/index.js +1 -0
  62. package/cjs/inputs/Input/__stories__/PhoneNumber.js.map +2 -2
  63. package/cjs/inputs/Input/__stories__/PostalCode/index.js +1 -0
  64. package/cjs/inputs/Input/__stories__/PostalCode.js.map +2 -2
  65. package/cjs/inputs/Input/index.js +4 -4
  66. package/cjs/inputs/Input/index.js.map +2 -2
  67. package/cjs/inputs/Label/index.js +3 -3
  68. package/cjs/inputs/Label/index.js.map +3 -3
  69. package/cjs/inputs/Radio/index.js +11 -13
  70. package/cjs/inputs/Radio/index.js.map +3 -3
  71. package/cjs/inputs/Select/index.js +3 -4
  72. package/cjs/inputs/Select/index.js.map +3 -3
  73. package/cjs/inputs/inputsScenarios/index.js +0 -1
  74. package/cjs/inputs/inputsScenarios.js.map +2 -2
  75. package/cjs/lazy/index.js +3 -0
  76. package/cjs/lazy.js.map +2 -2
  77. package/cjs/registry/index.js +2 -0
  78. package/cjs/registry.js.map +2 -2
  79. package/cjs/validators/index.js +16 -66
  80. package/cjs/validators/index.js.map +3 -3
  81. package/cjs/validators/utils/date/index.js +138 -0
  82. package/cjs/validators/utils/date.js.map +7 -0
  83. package/cjs/validators/utils/file/index.js +1 -1
  84. package/cjs/validators/utils/file.js.map +2 -2
  85. package/cjs/validators/utils/index.js +3 -1
  86. package/cjs/validators/utils/index.js.map +2 -2
  87. package/index.js +1 -1
  88. package/inputs/AutoCompleteInput/__stories__/Multiple/index.js +0 -1
  89. package/inputs/AutoCompleteInput/__stories__/Multiple.js.map +2 -2
  90. package/inputs/AutoCompleteInput/index.js +9 -6
  91. package/inputs/AutoCompleteInput/index.js.map +2 -2
  92. package/inputs/Checkboxes/index.js +7 -5
  93. package/inputs/Checkboxes/index.js.map +2 -2
  94. package/inputs/DateInput/index.js +5 -3
  95. package/inputs/DateInput/index.js.map +2 -2
  96. package/inputs/FileInput/index.js +5 -6
  97. package/inputs/FileInput/index.js.map +2 -2
  98. package/inputs/ImageInput/ImageInput.stories/index.js +2 -2
  99. package/inputs/ImageInput/ImageInput.stories.d.ts +1 -1
  100. package/inputs/ImageInput/ImageInput.stories.js.map +2 -2
  101. package/inputs/ImageInput/__stories__/MaxSize/index.js +36 -0
  102. package/inputs/ImageInput/__stories__/MaxSize/package.json +6 -0
  103. package/inputs/ImageInput/__stories__/MaxSize.d.ts +3 -0
  104. package/inputs/ImageInput/__stories__/MaxSize.js.map +7 -0
  105. package/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +2 -1
  106. package/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +2 -2
  107. package/inputs/ImageInput/index.js +6 -7
  108. package/inputs/ImageInput/index.js.map +2 -2
  109. package/inputs/Input/__stories__/LandlineNumber/index.js +1 -0
  110. package/inputs/Input/__stories__/LandlineNumber.js.map +2 -2
  111. package/inputs/Input/__stories__/MobilePhone/index.js +1 -0
  112. package/inputs/Input/__stories__/MobilePhone.js.map +2 -2
  113. package/inputs/Input/__stories__/PhoneNumber/index.js +1 -0
  114. package/inputs/Input/__stories__/PhoneNumber.js.map +2 -2
  115. package/inputs/Input/__stories__/PostalCode/index.js +1 -0
  116. package/inputs/Input/__stories__/PostalCode.js.map +2 -2
  117. package/inputs/Input/index.js +4 -4
  118. package/inputs/Input/index.js.map +2 -2
  119. package/inputs/Label/index.js +2 -2
  120. package/inputs/Label/index.js.map +2 -2
  121. package/inputs/Radio/index.js +7 -5
  122. package/inputs/Radio/index.js.map +2 -2
  123. package/inputs/Select/index.js +1 -2
  124. package/inputs/Select/index.js.map +2 -2
  125. package/inputs/inputsScenarios/index.js +0 -1
  126. package/inputs/inputsScenarios.d.ts +0 -42
  127. package/inputs/inputsScenarios.js.map +2 -2
  128. package/lazy/index.js +3 -0
  129. package/lazy.d.ts +3 -0
  130. package/lazy.js.map +2 -2
  131. package/package.json +4 -4
  132. package/registry/index.js +2 -0
  133. package/registry.d.ts +1 -0
  134. package/registry.js.map +2 -2
  135. package/src/Field/FieldBaseContainer.tsx +1 -1
  136. package/src/Field/types.tsx +1 -0
  137. package/src/FieldArray/index.tsx +9 -8
  138. package/src/FieldObject/index.tsx +2 -2
  139. package/src/Fieldset/index.tsx +5 -5
  140. package/src/Fieldset/types.tsx +2 -2
  141. package/src/FormBuilder/{FormBuilder.mdx → doc.mdx} +20 -33
  142. package/src/FormBuilder/index.tsx +3 -3
  143. package/src/FormBuilder/scenarios.test.tsx +2 -2
  144. package/src/MultiplicityField/add-objects.tsx +5 -6
  145. package/src/MultiplicityField/{MultiplicityField.mdx → doc.mdx} +12 -16
  146. package/src/MultiplicityField/index.tsx +13 -12
  147. package/src/Questions/Step/StepTitle.tsx +4 -3
  148. package/src/Questions/__snapshots__/index.spec.tsx.snap +8 -4
  149. package/src/Questions/{index.mdx → doc.mdx} +9 -12
  150. package/src/create-simple-form.mdx +2 -6
  151. package/src/{index.mdx → doc.mdx} +4 -8
  152. package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +0 -1
  153. package/src/inputs/AutoCompleteInput/{index.mdx → doc.mdx} +2 -13
  154. package/src/inputs/AutoCompleteInput/index.tsx +34 -28
  155. package/src/inputs/Checkboxes/{index.mdx → doc.mdx} +5 -15
  156. package/src/inputs/Checkboxes/index.tsx +29 -27
  157. package/src/inputs/DateInput/{index.mdx → doc.mdx} +1 -8
  158. package/src/inputs/DateInput/index.tsx +5 -3
  159. package/src/inputs/FileInput/{index.mdx → doc.mdx} +1 -5
  160. package/src/inputs/FileInput/index.tsx +5 -6
  161. package/src/inputs/ImageInput/ImageInput.stories.js +2 -1
  162. package/src/inputs/ImageInput/__stories__/MaxSize.tsx +37 -0
  163. package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +2 -0
  164. package/src/inputs/ImageInput/doc.mdx +23 -0
  165. package/src/inputs/ImageInput/index.test.tsx +4 -0
  166. package/src/inputs/ImageInput/index.tsx +9 -11
  167. package/src/inputs/Input/__stories__/LandlineNumber.tsx +2 -1
  168. package/src/inputs/Input/__stories__/MobilePhone.tsx +1 -0
  169. package/src/inputs/Input/__stories__/PhoneNumber.tsx +1 -0
  170. package/src/inputs/Input/__stories__/PostalCode.tsx +1 -0
  171. package/src/inputs/Input/doc.mdx +56 -0
  172. package/src/inputs/Input/index.tsx +19 -11
  173. package/src/inputs/Label/doc.mdx +14 -0
  174. package/src/inputs/Label/index.tsx +2 -3
  175. package/src/inputs/OtpInput/{index.mdx → doc.mdx} +1 -8
  176. package/src/inputs/Radio/{index.mdx → doc.mdx} +5 -15
  177. package/src/inputs/Radio/index.tsx +57 -55
  178. package/src/inputs/Select/{index.mdx → doc.mdx} +1 -5
  179. package/src/inputs/Select/index.tsx +1 -2
  180. package/src/inputs/inputsScenarios.ts +147 -148
  181. package/src/installation.mdx +2 -5
  182. package/src/lazy.js +3 -0
  183. package/src/registry.js +2 -0
  184. package/src/validators/index.ts +33 -71
  185. package/src/validators/utils/date.ts +107 -0
  186. package/src/validators/utils/file.ts +1 -1
  187. package/src/validators/utils/index.ts +1 -0
  188. package/validators/index.js +20 -67
  189. package/validators/index.js.map +2 -2
  190. package/validators/utils/date/index.js +103 -0
  191. package/validators/utils/date/package.json +6 -0
  192. package/validators/utils/date.d.ts +9 -0
  193. package/validators/utils/date.js.map +7 -0
  194. package/validators/utils/file/index.js +1 -1
  195. package/validators/utils/file.js.map +2 -2
  196. package/validators/utils/index.d.ts +1 -0
  197. package/validators/utils/index.js +1 -0
  198. package/validators/utils/index.js.map +2 -2
  199. package/src/inputs/ImageInput/index.mdx +0 -19
  200. package/src/inputs/Input/index.mdx +0 -95
  201. package/src/inputs/Label/index.mdx +0 -0
  202. /package/src/Field/{index.mdx → doc.mdx} +0 -0
@@ -10,24 +10,14 @@ Radios are used to let a user select one option of a limited number of choices.
10
10
 
11
11
  ### Default
12
12
 
13
- <Story
14
- packageName="@digigov/form"
15
- component="inputs/Radio"
16
- story="Default.tsx"
17
- />
13
+ <code src="@digigov/form/inputs/Radio/__stories__/Default.tsx" />
14
+
18
15
 
19
16
  ### Conditional
20
17
 
21
- <Story
22
- packageName="@digigov/form"
23
- component="inputs/Radio"
24
- story="Conditional.tsx"
25
- />
18
+ <code src="@digigov/form/inputs/Radio/__stories__/Conditional.tsx" />
19
+
26
20
 
27
21
  ### With divider
28
22
 
29
- <Story
30
- packageName="@digigov/form"
31
- component="inputs/Radio"
32
- story="WithDivider.tsx"
33
- />
23
+ <code src="@digigov/form/inputs/Radio/__stories__/WithDivider.tsx" />
@@ -2,12 +2,14 @@ import React from 'react';
2
2
  import { useWatch } from 'react-hook-form';
3
3
  import { UncontrolledFieldProps } from '@digigov/form/Field/types';
4
4
  import { FieldOptionProps } from '@digigov/form/inputs/Label';
5
- import { Base } from '@digigov/react-core/Base';
6
- import Hint from '@digigov/react-core/Hint';
7
- import { RadioConditional } from '@digigov/react-core/RadioConditional';
8
- import RadioContainer from '@digigov/react-core/RadioContainer';
9
- import RadioItem from '@digigov/react-core/RadioItem';
5
+ import {
6
+ RadioContainer,
7
+ RadioItem,
8
+ RadioConditional,
9
+ } from '@digigov/ui/form/RadioContainer';
10
10
  import { useTranslation } from '@digigov/ui/i18n';
11
+ import { Hint } from '@digigov/ui/typography/Hint';
12
+ import { Base } from '@digigov/ui/utils/Base';
11
13
 
12
14
  export interface RadioButtonsGroupProps
13
15
  extends Omit<UncontrolledFieldProps, 'extra'> {
@@ -87,55 +89,55 @@ export const ControlledRadioButtonsGroup: React.FC<
87
89
  Field,
88
90
  ...props
89
91
  }) => {
90
- const currentValue: string | undefined = value;
91
- const { t } = useTranslation();
92
- return (
93
- <RadioContainer className={className} id={name}>
94
- {options.map(
95
- ({
96
- label,
97
- value: v,
98
- show,
99
- disabled: optionDisabled,
100
- selected,
101
- ...option
102
- }) => (
103
- <React.Fragment key={`${name}.${v}`}>
104
- <RadioItem
105
- onChange={(e) => {
106
- console.log(e);
107
- onChange(e);
108
- }}
109
- id={`${name}.${v}`}
110
- value={v}
111
- checked={currentValue === v}
112
- disabled={disabled || optionDisabled}
113
- {...option}
114
- {...{
115
- ...props,
116
- reset: undefined,
117
- required: undefined,
118
- error: undefined,
119
- 'aria-describedby': undefined,
120
- type: 'radio',
121
- }}
122
- >
123
- {(label && label.primary && t(label.primary)) || v}
124
- {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}
125
- </RadioItem>
126
- {selected && selected()}
127
- {currentValue === v && show && (
128
- <RadioConditional>
129
- {show.map((fieldName) => (
130
- <Field name={fieldName} key={fieldName} />
131
- ))}
132
- </RadioConditional>
133
- )}
134
- </React.Fragment>
135
- )
136
- )}
137
- </RadioContainer>
138
- );
139
- };
92
+ const currentValue: string | undefined = value;
93
+ const { t } = useTranslation();
94
+ return (
95
+ <RadioContainer className={className} id={name}>
96
+ {options.map(
97
+ ({
98
+ label,
99
+ value: v,
100
+ show,
101
+ disabled: optionDisabled,
102
+ selected,
103
+ ...option
104
+ }) => (
105
+ <React.Fragment key={`${name}.${v}`}>
106
+ <RadioItem
107
+ onChange={(e) => {
108
+ console.log(e);
109
+ onChange(e);
110
+ }}
111
+ id={`${name}.${v}`}
112
+ value={v}
113
+ checked={currentValue === v}
114
+ disabled={disabled || optionDisabled}
115
+ {...option}
116
+ {...{
117
+ ...props,
118
+ reset: undefined,
119
+ required: undefined,
120
+ error: undefined,
121
+ 'aria-describedby': undefined,
122
+ type: 'radio',
123
+ }}
124
+ >
125
+ {(label && label.primary && t(label.primary)) || v}
126
+ {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}
127
+ </RadioItem>
128
+ {selected && selected()}
129
+ {currentValue === v && show && (
130
+ <RadioConditional>
131
+ {show.map((fieldName) => (
132
+ <Field name={fieldName} key={fieldName} />
133
+ ))}
134
+ </RadioConditional>
135
+ )}
136
+ </React.Fragment>
137
+ )
138
+ )}
139
+ </RadioContainer>
140
+ );
141
+ };
140
142
 
141
143
  export default RadioButtonsGroup;
@@ -10,8 +10,4 @@ The select element represents a control that provides a menu of options.
10
10
 
11
11
  ### Default
12
12
 
13
- <Story
14
- packageName="@digigov/form"
15
- component="inputs/Select"
16
- story="Default.tsx"
17
- />
13
+ <code src="@digigov/form/inputs/Select/__stories__/Default.tsx" />
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
2
  import { UncontrolledFieldProps } from '@digigov/form/Field/types';
3
3
  import { FieldOptionProps } from '@digigov/form/inputs/Label';
4
- import SelectContainer from '@digigov/react-core/SelectContainer';
5
- import SelectOption from '@digigov/react-core/SelectOption';
4
+ import { SelectContainer, SelectOption } from '@digigov/ui/form/SelectContainer';
6
5
 
7
6
  export interface SelectProps extends Omit<UncontrolledFieldProps, 'extra'> {
8
7
  extra: {
@@ -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
@@ -50,6 +50,9 @@ export default {
50
50
  'Questions': lazy(() => import('@digigov/form/Questions/Questions').then((module)=> ({default: module['Questions']}))),
51
51
  'QuestionsContext': lazy(() => import('@digigov/form/Questions/QuestionsContext').then((module)=> ({default: module['QuestionsContext']}))),
52
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']}))),
53
56
  'FILE_MAX_SIZE_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/file').then((module)=> ({default: module['FILE_MAX_SIZE_VALIDATOR']}))),
54
57
  'IBAN_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/iban').then((module)=> ({default: module['IBAN_VALIDATOR']}))),
55
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),
@@ -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;