@digigov/form 0.13.2 → 1.0.0-6b93ebf2

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 (302) hide show
  1. package/Field/FieldBase.js +2 -2
  2. package/Field/FieldBaseContainer.js +8 -8
  3. package/Field/FieldConditional.js +2 -2
  4. package/Field/utils.js +6 -6
  5. package/FieldArray/__stories__/Default.js +2 -2
  6. package/FieldArray/__stories__/WithExactLength.js +2 -2
  7. package/FieldArray/index.js +3 -3
  8. package/FieldObject/index.d.ts +1 -1
  9. package/FieldObject/index.js +5 -5
  10. package/Fieldset/FieldsetWithContext.js +4 -4
  11. package/Fieldset/index.d.ts +1 -1
  12. package/Fieldset/index.js +2 -2
  13. package/Fieldset/types.d.ts +2 -2
  14. package/FormBuilder/FormBuilder.js +5 -5
  15. package/FormBuilder/FormBuilder.mdx +32 -45
  16. package/FormBuilder/__stories__/Default.js +2 -2
  17. package/MultiplicityField/MultiplicityField.mdx +277 -267
  18. package/MultiplicityField/__stories__/Default.js +2 -2
  19. package/MultiplicityField/__stories__/PreviewDisplay.js +8 -8
  20. package/MultiplicityField/__stories__/WithExactLength.js +2 -2
  21. package/MultiplicityField/__stories__/WithMaxLength.js +2 -2
  22. package/MultiplicityField/__stories__/WithMinAndMaxLength.js +2 -2
  23. package/MultiplicityField/__stories__/WithMinLength.js +2 -2
  24. package/MultiplicityField/add-objects.js +6 -6
  25. package/MultiplicityField/index.d.ts +2 -2
  26. package/MultiplicityField/index.js +7 -7
  27. package/Questions/Questions.js +2 -2
  28. package/Questions/Step/ReviewStep.js +8 -8
  29. package/Questions/Step/Step.js +2 -2
  30. package/Questions/Step/StepArrayReview.js +10 -10
  31. package/Questions/Step/StepDescription.js +2 -2
  32. package/Questions/Step/StepForm.d.ts +1 -1
  33. package/Questions/Step/StepForm.js +6 -6
  34. package/Questions/Step/StepTitle.js +5 -3
  35. package/Questions/Step/getAddMoreFields.d.ts +1 -1
  36. package/Questions/__snapshots__/index.spec.tsx.snap +9 -9
  37. package/Questions/__stories__/Default.js +6 -6
  38. package/Questions/index.mdx +41 -44
  39. package/Questions/index.spec.js +2 -2
  40. package/create-simple-form.mdx +258 -237
  41. package/es/Field/FieldBase.js +1 -1
  42. package/es/Field/FieldBaseContainer.js +6 -6
  43. package/es/Field/FieldConditional.js +1 -1
  44. package/es/Field/utils.js +5 -5
  45. package/es/FieldArray/__stories__/Default.js +1 -1
  46. package/es/FieldArray/__stories__/WithExactLength.js +1 -1
  47. package/es/FieldArray/index.js +2 -2
  48. package/es/FieldObject/index.js +3 -3
  49. package/es/Fieldset/FieldsetWithContext.js +2 -2
  50. package/es/Fieldset/index.js +1 -1
  51. package/es/FormBuilder/FormBuilder.js +3 -3
  52. package/es/FormBuilder/FormBuilder.mdx +32 -45
  53. package/es/FormBuilder/__stories__/Default.js +1 -1
  54. package/es/MultiplicityField/MultiplicityField.mdx +277 -267
  55. package/es/MultiplicityField/__stories__/Default.js +1 -1
  56. package/es/MultiplicityField/__stories__/PreviewDisplay.js +7 -7
  57. package/es/MultiplicityField/__stories__/WithExactLength.js +1 -1
  58. package/es/MultiplicityField/__stories__/WithMaxLength.js +1 -1
  59. package/es/MultiplicityField/__stories__/WithMinAndMaxLength.js +1 -1
  60. package/es/MultiplicityField/__stories__/WithMinLength.js +1 -1
  61. package/es/MultiplicityField/add-objects.js +3 -3
  62. package/es/MultiplicityField/index.js +5 -5
  63. package/es/Questions/Questions.js +1 -1
  64. package/es/Questions/Step/ReviewStep.js +5 -5
  65. package/es/Questions/Step/Step.js +1 -1
  66. package/es/Questions/Step/StepArrayReview.js +7 -7
  67. package/es/Questions/Step/StepDescription.js +1 -1
  68. package/es/Questions/Step/StepForm.js +5 -5
  69. package/es/Questions/Step/StepTitle.js +5 -4
  70. package/es/Questions/__snapshots__/index.spec.tsx.snap +9 -9
  71. package/es/Questions/__stories__/Default.js +4 -4
  72. package/es/Questions/index.mdx +41 -44
  73. package/es/Questions/index.spec.js +1 -1
  74. package/es/create-simple-form.mdx +258 -237
  75. package/es/index.mdx +13 -6
  76. package/es/inputs/AutoComplete/__stories__/Default.js +3 -3
  77. package/es/inputs/AutoComplete/index.js +1 -1
  78. package/es/inputs/Checkboxes/__stories__/Conditional.js +1 -1
  79. package/es/inputs/Checkboxes/__stories__/Default.js +1 -1
  80. package/es/inputs/Checkboxes/__stories__/WithDivider.js +2 -2
  81. package/es/inputs/Checkboxes/index.js +3 -3
  82. package/es/inputs/DateInput/__stories__/Default.js +1 -1
  83. package/es/inputs/DateInput/index.js +1 -1
  84. package/es/inputs/FileInput/__stories__/Default.js +1 -1
  85. package/es/inputs/FileInput/index.js +5 -5
  86. package/es/inputs/Input/__stories__/AFM.js +1 -1
  87. package/es/inputs/Input/__stories__/Boolean.js +1 -1
  88. package/es/inputs/Input/__stories__/Default.js +1 -1
  89. package/es/inputs/Input/__stories__/IBAN.js +1 -1
  90. package/es/inputs/Input/__stories__/Integer.js +1 -1
  91. package/es/inputs/Input/__stories__/MobilePhone.js +1 -1
  92. package/es/inputs/Input/__stories__/PhoneNumber.js +1 -1
  93. package/es/inputs/Input/__stories__/PostalCode.js +1 -1
  94. package/es/inputs/Input/__stories__/TextWithCharacterLimit.js +1 -1
  95. package/es/inputs/Input/index.js +1 -1
  96. package/es/inputs/Label/__stories__/Default.js +1 -1
  97. package/es/inputs/Label/index.js +3 -3
  98. package/es/inputs/OtpInput/__stories__/Default.js +1 -1
  99. package/es/inputs/OtpInput/index.js +1 -1
  100. package/es/inputs/Radio/__stories__/Conditional.js +1 -1
  101. package/es/inputs/Radio/__stories__/Default.js +1 -1
  102. package/es/inputs/Radio/__stories__/WithDivider.js +2 -2
  103. package/es/inputs/Radio/index.js +4 -4
  104. package/es/inputs/Select/__stories__/Default.js +1 -1
  105. package/es/installation.mdx +12 -16
  106. package/es/utils.js +1 -1
  107. package/es/validators/index.js +2 -2
  108. package/esm/Field/FieldBase.js +1 -1
  109. package/esm/Field/FieldBaseContainer.js +6 -6
  110. package/esm/Field/FieldConditional.js +1 -1
  111. package/esm/Field/utils.js +5 -5
  112. package/esm/FieldArray/__stories__/Default.js +1 -1
  113. package/esm/FieldArray/__stories__/WithExactLength.js +1 -1
  114. package/esm/FieldArray/index.js +2 -2
  115. package/esm/FieldObject/index.js +3 -3
  116. package/esm/Fieldset/FieldsetWithContext.js +2 -2
  117. package/esm/Fieldset/index.js +1 -1
  118. package/esm/FormBuilder/FormBuilder.js +3 -3
  119. package/esm/FormBuilder/FormBuilder.mdx +32 -45
  120. package/esm/FormBuilder/__stories__/Default.js +1 -1
  121. package/esm/MultiplicityField/MultiplicityField.mdx +277 -267
  122. package/esm/MultiplicityField/__stories__/Default.js +1 -1
  123. package/esm/MultiplicityField/__stories__/PreviewDisplay.js +7 -7
  124. package/esm/MultiplicityField/__stories__/WithExactLength.js +1 -1
  125. package/esm/MultiplicityField/__stories__/WithMaxLength.js +1 -1
  126. package/esm/MultiplicityField/__stories__/WithMinAndMaxLength.js +1 -1
  127. package/esm/MultiplicityField/__stories__/WithMinLength.js +1 -1
  128. package/esm/MultiplicityField/add-objects.js +3 -3
  129. package/esm/MultiplicityField/index.js +5 -5
  130. package/esm/Questions/Questions.js +1 -1
  131. package/esm/Questions/Step/ReviewStep.js +5 -5
  132. package/esm/Questions/Step/Step.js +1 -1
  133. package/esm/Questions/Step/StepArrayReview.js +7 -7
  134. package/esm/Questions/Step/StepDescription.js +1 -1
  135. package/esm/Questions/Step/StepForm.js +5 -5
  136. package/esm/Questions/Step/StepTitle.js +5 -4
  137. package/esm/Questions/__snapshots__/index.spec.tsx.snap +9 -9
  138. package/esm/Questions/__stories__/Default.js +4 -4
  139. package/esm/Questions/index.mdx +41 -44
  140. package/esm/Questions/index.spec.js +1 -1
  141. package/esm/create-simple-form.mdx +258 -237
  142. package/esm/index.js +1 -1
  143. package/esm/index.mdx +13 -6
  144. package/esm/inputs/AutoComplete/__stories__/Default.js +3 -3
  145. package/esm/inputs/AutoComplete/index.js +1 -1
  146. package/esm/inputs/Checkboxes/__stories__/Conditional.js +1 -1
  147. package/esm/inputs/Checkboxes/__stories__/Default.js +1 -1
  148. package/esm/inputs/Checkboxes/__stories__/WithDivider.js +2 -2
  149. package/esm/inputs/Checkboxes/index.js +3 -3
  150. package/esm/inputs/DateInput/__stories__/Default.js +1 -1
  151. package/esm/inputs/DateInput/index.js +1 -1
  152. package/esm/inputs/FileInput/__stories__/Default.js +1 -1
  153. package/esm/inputs/FileInput/index.js +5 -5
  154. package/esm/inputs/Input/__stories__/AFM.js +1 -1
  155. package/esm/inputs/Input/__stories__/Boolean.js +1 -1
  156. package/esm/inputs/Input/__stories__/Default.js +1 -1
  157. package/esm/inputs/Input/__stories__/IBAN.js +1 -1
  158. package/esm/inputs/Input/__stories__/Integer.js +1 -1
  159. package/esm/inputs/Input/__stories__/MobilePhone.js +1 -1
  160. package/esm/inputs/Input/__stories__/PhoneNumber.js +1 -1
  161. package/esm/inputs/Input/__stories__/PostalCode.js +1 -1
  162. package/esm/inputs/Input/__stories__/TextWithCharacterLimit.js +1 -1
  163. package/esm/inputs/Input/index.js +1 -1
  164. package/esm/inputs/Label/__stories__/Default.js +1 -1
  165. package/esm/inputs/Label/index.js +3 -3
  166. package/esm/inputs/OtpInput/__stories__/Default.js +1 -1
  167. package/esm/inputs/OtpInput/index.js +1 -1
  168. package/esm/inputs/Radio/__stories__/Conditional.js +1 -1
  169. package/esm/inputs/Radio/__stories__/Default.js +1 -1
  170. package/esm/inputs/Radio/__stories__/WithDivider.js +2 -2
  171. package/esm/inputs/Radio/index.js +4 -4
  172. package/esm/inputs/Select/__stories__/Default.js +1 -1
  173. package/esm/installation.mdx +12 -16
  174. package/esm/utils.js +1 -1
  175. package/esm/validators/index.js +2 -2
  176. package/index.mdx +13 -6
  177. package/inputs/AutoComplete/__stories__/Default.js +4 -4
  178. package/inputs/AutoComplete/index.d.ts +2 -2
  179. package/inputs/AutoComplete/index.js +2 -2
  180. package/inputs/Checkboxes/__stories__/Conditional.js +2 -2
  181. package/inputs/Checkboxes/__stories__/Default.js +2 -2
  182. package/inputs/Checkboxes/__stories__/WithDivider.js +3 -3
  183. package/inputs/Checkboxes/index.d.ts +1 -1
  184. package/inputs/Checkboxes/index.js +4 -4
  185. package/inputs/DateInput/__stories__/Default.js +2 -2
  186. package/inputs/DateInput/index.js +2 -2
  187. package/inputs/FileInput/__stories__/Default.js +2 -2
  188. package/inputs/FileInput/index.js +5 -5
  189. package/inputs/Input/__stories__/AFM.js +2 -2
  190. package/inputs/Input/__stories__/Boolean.js +2 -2
  191. package/inputs/Input/__stories__/Default.js +2 -2
  192. package/inputs/Input/__stories__/IBAN.js +2 -2
  193. package/inputs/Input/__stories__/Integer.js +2 -2
  194. package/inputs/Input/__stories__/MobilePhone.js +2 -2
  195. package/inputs/Input/__stories__/PhoneNumber.js +2 -2
  196. package/inputs/Input/__stories__/PostalCode.js +2 -2
  197. package/inputs/Input/__stories__/TextWithCharacterLimit.js +2 -2
  198. package/inputs/Input/index.js +1 -1
  199. package/inputs/Label/__stories__/Default.js +2 -2
  200. package/inputs/Label/index.js +4 -4
  201. package/inputs/OtpInput/__stories__/Default.js +2 -2
  202. package/inputs/OtpInput/index.js +1 -1
  203. package/inputs/Radio/__stories__/Conditional.js +2 -2
  204. package/inputs/Radio/__stories__/Default.js +2 -2
  205. package/inputs/Radio/__stories__/WithDivider.js +3 -3
  206. package/inputs/Radio/index.d.ts +1 -1
  207. package/inputs/Radio/index.js +7 -7
  208. package/inputs/Select/__stories__/Default.js +2 -2
  209. package/inputs/Select/index.d.ts +1 -1
  210. package/installation.mdx +12 -16
  211. package/package.json +5 -5
  212. package/src/Field/FieldBase.tsx +1 -1
  213. package/src/Field/FieldBaseContainer.tsx +7 -7
  214. package/src/Field/FieldConditional.tsx +1 -1
  215. package/src/Field/index.tsx +1 -1
  216. package/src/Field/utils.ts +7 -7
  217. package/src/FieldArray/FieldArray.stories.js +1 -1
  218. package/src/FieldArray/__stories__/Default.tsx +1 -1
  219. package/src/FieldArray/__stories__/WithExactLength.tsx +1 -1
  220. package/src/FieldArray/index.tsx +3 -3
  221. package/src/FieldObject/index.tsx +6 -6
  222. package/src/Fieldset/FieldsetWithContext.tsx +3 -3
  223. package/src/Fieldset/index.tsx +5 -5
  224. package/src/Fieldset/types.tsx +3 -3
  225. package/src/FormBuilder/FormBuilder.mdx +32 -45
  226. package/src/FormBuilder/FormBuilder.stories.js +1 -1
  227. package/src/FormBuilder/FormBuilder.tsx +4 -4
  228. package/src/FormBuilder/__stories__/Default.tsx +1 -1
  229. package/src/MultiplicityField/MultiplicityField.mdx +277 -267
  230. package/src/MultiplicityField/MultiplicityField.stories.js +1 -1
  231. package/src/MultiplicityField/__stories__/Default.tsx +1 -1
  232. package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +14 -14
  233. package/src/MultiplicityField/__stories__/WithExactLength.tsx +1 -1
  234. package/src/MultiplicityField/__stories__/WithMaxLength.tsx +1 -1
  235. package/src/MultiplicityField/__stories__/WithMinAndMaxLength.tsx +1 -1
  236. package/src/MultiplicityField/__stories__/WithMinLength.tsx +1 -1
  237. package/src/MultiplicityField/add-objects.tsx +3 -3
  238. package/src/MultiplicityField/index.tsx +9 -9
  239. package/src/Questions/Questions.stories.js +1 -1
  240. package/src/Questions/Questions.tsx +2 -2
  241. package/src/Questions/Step/ReviewStep.tsx +6 -6
  242. package/src/Questions/Step/Step.tsx +1 -1
  243. package/src/Questions/Step/StepArrayReview.tsx +11 -11
  244. package/src/Questions/Step/StepDescription.tsx +1 -1
  245. package/src/Questions/Step/StepForm.tsx +6 -6
  246. package/src/Questions/Step/StepTitle.tsx +16 -12
  247. package/src/Questions/Step/getAddMoreFields.tsx +1 -1
  248. package/src/Questions/__snapshots__/index.spec.tsx.snap +9 -9
  249. package/src/Questions/__stories__/Default.tsx +4 -4
  250. package/src/Questions/index.mdx +41 -44
  251. package/src/Questions/index.spec.tsx +1 -1
  252. package/src/create-simple-form.mdx +258 -237
  253. package/src/index.mdx +13 -6
  254. package/src/inputs/AutoComplete/__stories__/Default.tsx +3 -3
  255. package/src/inputs/AutoComplete/index.tsx +4 -4
  256. package/src/inputs/Checkboxes/Checkboxes.stories.js +1 -1
  257. package/src/inputs/Checkboxes/__stories__/Conditional.tsx +2 -2
  258. package/src/inputs/Checkboxes/__stories__/Default.tsx +1 -1
  259. package/src/inputs/Checkboxes/__stories__/WithDivider.tsx +2 -2
  260. package/src/inputs/Checkboxes/index.tsx +4 -4
  261. package/src/inputs/DateInput/DateInput.stories.js +1 -1
  262. package/src/inputs/DateInput/__stories__/Default.tsx +1 -1
  263. package/src/inputs/DateInput/index.tsx +2 -2
  264. package/src/inputs/FileInput/FileInput.stories.js +1 -1
  265. package/src/inputs/FileInput/__stories__/Default.tsx +1 -1
  266. package/src/inputs/FileInput/index.tsx +5 -5
  267. package/src/inputs/Input/__stories__/AFM.tsx +1 -1
  268. package/src/inputs/Input/__stories__/Boolean.tsx +1 -1
  269. package/src/inputs/Input/__stories__/Default.tsx +1 -1
  270. package/src/inputs/Input/__stories__/IBAN.tsx +1 -1
  271. package/src/inputs/Input/__stories__/Integer.tsx +1 -1
  272. package/src/inputs/Input/__stories__/MobilePhone.tsx +1 -1
  273. package/src/inputs/Input/__stories__/PhoneNumber.tsx +1 -1
  274. package/src/inputs/Input/__stories__/PostalCode.tsx +1 -1
  275. package/src/inputs/Input/__stories__/TextWithCharacterLimit.tsx +1 -1
  276. package/src/inputs/Input/index.tsx +3 -3
  277. package/src/inputs/Label/Label.stories.js +1 -1
  278. package/src/inputs/Label/__stories__/Default.tsx +1 -1
  279. package/src/inputs/Label/index.tsx +4 -4
  280. package/src/inputs/OtpInput/__stories__/Default.tsx +1 -1
  281. package/src/inputs/OtpInput/index.tsx +7 -3
  282. package/src/inputs/Radio/Radio.stories.js +1 -2
  283. package/src/inputs/Radio/__stories__/Conditional.tsx +3 -3
  284. package/src/inputs/Radio/__stories__/Default.tsx +1 -1
  285. package/src/inputs/Radio/__stories__/WithDivider.tsx +2 -2
  286. package/src/inputs/Radio/index.tsx +6 -6
  287. package/src/inputs/Select/Select.stories.js +1 -1
  288. package/src/inputs/Select/__stories__/Default.tsx +1 -1
  289. package/src/inputs/Select/index.tsx +2 -2
  290. package/src/installation.mdx +12 -16
  291. package/src/types.tsx +4 -2
  292. package/src/utils.ts +1 -1
  293. package/src/validators/index.ts +10 -10
  294. package/src/validators/utils/file.ts +1 -1
  295. package/src/validators/utils/phone.ts +1 -1
  296. package/src/validators/utils/postal_code.ts +1 -1
  297. package/types.d.ts +4 -2
  298. package/validators/index.d.ts +3 -3
  299. package/validators/index.js +4 -4
  300. package/validators/utils/file.d.ts +1 -1
  301. package/validators/utils/phone.d.ts +1 -1
  302. package/validators/utils/postal_code.d.ts +1 -1
@@ -4,21 +4,23 @@ title: Create a simple Digigov Form
4
4
  sidebar_label: Creating simple forms
5
5
  ---
6
6
 
7
- import LeadText from "@site/src/components/LeadText";
7
+ import LeadText from '@site/src/components/LeadText';
8
8
 
9
- <LeadText>This guide walks through building a simple form page, complete with
10
- validation and data serialisation.</LeadText>
9
+ <LeadText>
10
+ This guide walks through building a simple form page, complete with validation
11
+ and data serialisation.
12
+ </LeadText>
11
13
 
12
14
  ## What we are building
13
15
 
14
16
  Before we start diving into more advanced usecases, let's first create a form
15
17
  asking users for their personal information.
16
18
 
17
- * First name
18
- * Last name
19
- * AFM (Greek tax number)
20
- * Telephone number
21
- * Marital status
19
+ - First name
20
+ - Last name
21
+ - AFM (Greek tax number)
22
+ - Telephone number
23
+ - Marital status
22
24
 
23
25
  As you can see, this form is pretty basic. But even for a basic form like this
24
26
  we want to implement features that will help our users submit their data. We
@@ -39,13 +41,15 @@ primitive elements.
39
41
  import React from 'react';
40
42
 
41
43
  export default function SimpleForm() {
42
- return <form>
43
- <label>
44
- Name:
45
- <input type="text" name="name" />
46
- </label>
47
- <input type="submit" value="Submit" />
48
- </form>
44
+ return (
45
+ <form>
46
+ <label>
47
+ Name:
48
+ <input type="text" name="name" />
49
+ </label>
50
+ <input type="submit" value="Submit" />
51
+ </form>
52
+ );
49
53
  }
50
54
  ```
51
55
 
@@ -65,9 +69,7 @@ import Form from '@digigov/form';
65
69
 
66
70
  export default function SimpleForm() {
67
71
  // highlight-start
68
- return <Form>
69
- {/* this is where the fields are going to be placed */}
70
- </Form>
72
+ return <Form>{/* this is where the fields are going to be placed */}</Form>;
71
73
  // highlight-end
72
74
  }
73
75
  ```
@@ -82,11 +84,11 @@ Let's go ahead and import the `Field` component and use it to render an input
82
84
  field and a label. This component creates and manages any necessary React
83
85
  components transparently. All you need to do is describe a few React props.
84
86
 
85
- * `key`
86
- * `name`
87
- * `type`
88
- * `label`
89
- * `required`
87
+ - `key`
88
+ - `name`
89
+ - `type`
90
+ - `label`
91
+ - `required`
90
92
 
91
93
  These props can be then passed down the `Field` component which will be rendered
92
94
  by `FormBuilder`.
@@ -100,21 +102,23 @@ import React from 'react';
100
102
  import Form, { Field } from '@digigov/form';
101
103
 
102
104
  export default function SimpleForm() {
103
- return <Form>
104
- // highlight-start
105
- <Field
106
- key="firstName"
107
- name="firstName"
108
- label={{ primary: "First name" }}
109
- type="string"
110
- required
111
- />
112
- // highlight-end
113
- </Form>
105
+ return (
106
+ <Form>
107
+ // highlight-start
108
+ <Field
109
+ key="firstName"
110
+ name="firstName"
111
+ label={{ primary: 'First name' }}
112
+ type="string"
113
+ required
114
+ />
115
+ // highlight-end
116
+ </Form>
117
+ );
114
118
  }
115
119
  ```
116
120
 
117
- Hooray! 🎉
121
+ Hooray! 🎉
118
122
 
119
123
  It looks like the first two fields of our awesome form are working as
120
124
  expected. They are pretty basic, string inputs, accepting data input but they
@@ -125,22 +129,24 @@ import React from 'react';
125
129
  import Form, { Field } from '@digigov/form';
126
130
 
127
131
  export default function SimpleForm() {
128
- return <Form>
129
- <Field
130
- key="firstName"
131
- name="firstName"
132
- label={{ primary: "First name" }}
133
- type="string"
134
- required
135
- />
136
- <Field
137
- key="lastName"
138
- name="lastName"
139
- label={{ primary: "Last name" }}
140
- type="string"
141
- required
142
- />
143
- </Form>
132
+ return (
133
+ <Form>
134
+ <Field
135
+ key="firstName"
136
+ name="firstName"
137
+ label={{ primary: 'First name' }}
138
+ type="string"
139
+ required
140
+ />
141
+ <Field
142
+ key="lastName"
143
+ name="lastName"
144
+ label={{ primary: 'Last name' }}
145
+ type="string"
146
+ required
147
+ />
148
+ </Form>
149
+ );
144
150
  }
145
151
  ```
146
152
 
@@ -150,7 +156,7 @@ Before we proceed with adding the rest of the fields, we should first make sure
150
156
  that the form is working, validating and submitting data.
151
157
 
152
158
  Let's modify the previous example and use a `@digigov/ui/form/Button` to submit
153
- data. First we should import the button component and use it right at the
159
+ data. First we should import the button component and use it right at the
154
160
  bottom of our form.
155
161
 
156
162
  It is important to note that you should make sure the Button has a
@@ -162,28 +168,30 @@ enter key) or using any other tools eg. screen readers.
162
168
  import React from 'react';
163
169
  import Form, { Field } from '@digigov/form';
164
170
  // highlight-next-line
165
- import Button from '@digigov/ui/core/Button';
171
+ import Button from '@digigov/ui/form/Button';
166
172
 
167
173
  export default function SimpleForm() {
168
- return <Form>
169
- {/* this is where the fields are going to be placed */}
170
- <Field
171
- key="firstName"
172
- name="firstName"
173
- label={{ primary: "First name" }}
174
- type="string"
175
- required
176
- />
177
- <Field
178
- key="lastName"
179
- name="lastName"
180
- label={{ primary: "Last name" }}
181
- type="string"
182
- required
183
- />
184
- // highlight-next-line
185
- <Button type="submit">Continue</Button>
186
- </Form>
174
+ return (
175
+ <Form>
176
+ {/* this is where the fields are going to be placed */}
177
+ <Field
178
+ key="firstName"
179
+ name="firstName"
180
+ label={{ primary: 'First name' }}
181
+ type="string"
182
+ required
183
+ />
184
+ <Field
185
+ key="lastName"
186
+ name="lastName"
187
+ label={{ primary: 'Last name' }}
188
+ type="string"
189
+ required
190
+ />
191
+ // highlight-next-line
192
+ <Button type="submit">Continue</Button>
193
+ </Form>
194
+ );
187
195
  }
188
196
  ```
189
197
 
@@ -198,33 +206,35 @@ affects the submit behaviour.
198
206
  ```jsx live
199
207
  import React from 'react';
200
208
  import Form, { Field } from '@digigov/form';
201
- import Button from '@digigov/ui/core/Button';
209
+ import Button from '@digigov/ui/form/Button';
202
210
 
203
211
  export default function SimpleForm() {
204
- return <Form>
205
- {/* this is where the fields are going to be placed */}
206
- <Field
207
- key="firstName"
208
- name="firstName"
209
- label={{ primary: "First name" }}
210
- type="string"
211
- required
212
- />
213
- <Field
214
- key="lastName"
215
- name="lastName"
216
- label={{ primary: "Last name" }}
217
- type="string"
218
- required
219
- />
220
- <Button type="submit">Continue</Button>
221
- </Form>
212
+ return (
213
+ <Form>
214
+ {/* this is where the fields are going to be placed */}
215
+ <Field
216
+ key="firstName"
217
+ name="firstName"
218
+ label={{ primary: 'First name' }}
219
+ type="string"
220
+ required
221
+ />
222
+ <Field
223
+ key="lastName"
224
+ name="lastName"
225
+ label={{ primary: 'Last name' }}
226
+ type="string"
227
+ required
228
+ />
229
+ <Button type="submit">Continue</Button>
230
+ </Form>
231
+ );
222
232
  }
223
233
  ```
224
234
 
225
235
  Straightaway, the form is actually doing something and it is validating our
226
236
  inputs with almost zero coding needed.
227
-
237
+
228
238
  That's good. But we have yet to gather data in our code when users submit the form.
229
239
 
230
240
  Note. We should note that behind the scenes the Digigov Form inherits a prop (from [React Hook Form](https://react-hook-form.com/api/useform/)) called `shouldFocusError`
@@ -252,43 +262,47 @@ information.
252
262
  // highlight-next-line
253
263
  import React, { useState } from 'react';
254
264
  import Form, { Field } from '@digigov/form';
255
- import Button from '@digigov/ui/core/Button';
265
+ import Button from '@digigov/ui/form/Button';
256
266
 
257
267
  export default function SimpleForm() {
258
268
  // highlight-start
259
- const [submittedData, setSubmittedData] = useState({})
269
+ const [submittedData, setSubmittedData] = useState({});
260
270
  const handleSubmit = (data) => {
261
271
  setSubmittedData(data);
262
- }
263
- return <>
264
- <Form onSubmit={handleSubmit}>
265
- // highlight-end
266
- {/* this is where the fields are going to be placed */}
267
- <Field
268
- key="firstName"
269
- name="firstName"
270
- label={{ primary: "First name" }}
271
- type="string"
272
- required
273
- />
274
- <Field
275
- key="lastName"
276
- name="lastName"
277
- label={{ primary: "Last name" }}
278
- type="string"
279
- required
280
- />
281
- <Button type="submit">Continue</Button>
282
- </Form>
283
- // highlight-start
284
- {<>
285
- You submitted the following values
286
- <pre><code>
287
- {JSON.stringify(submittedData)}
288
- </code></pre>
289
- </>}
290
- // highlight-end
291
- </>
272
+ };
273
+ return (
274
+ <>
275
+ <Form onSubmit={handleSubmit}>
276
+ // highlight-end
277
+ {/* this is where the fields are going to be placed */}
278
+ <Field
279
+ key="firstName"
280
+ name="firstName"
281
+ label={{ primary: 'First name' }}
282
+ type="string"
283
+ required
284
+ />
285
+ <Field
286
+ key="lastName"
287
+ name="lastName"
288
+ label={{ primary: 'Last name' }}
289
+ type="string"
290
+ required
291
+ />
292
+ <Button type="submit">Continue</Button>
293
+ </Form>
294
+ // highlight-start
295
+ {
296
+ <>
297
+ You submitted the following values
298
+ <pre>
299
+ <code>{JSON.stringify(submittedData)}</code>
300
+ </pre>
301
+ </>
302
+ }
303
+ // highlight-end
304
+ </>
305
+ );
292
306
  }
293
307
  ```
294
308
 
@@ -302,40 +316,44 @@ button or press enter and see what happens.
302
316
  ```jsx live
303
317
  import React, { useState } from 'react';
304
318
  import Form, { Field } from '@digigov/form';
305
- import Button from '@digigov/ui/core/Button';
319
+ import Button from '@digigov/ui/form/Button';
306
320
  import Paragraph from '@digigov/ui/typography/Paragraph';
307
321
 
308
322
  export default function SimpleForm() {
309
- const [submittedData, setSubmittedData] = useState({})
323
+ const [submittedData, setSubmittedData] = useState({});
310
324
  const handleSubmit = (data) => {
311
325
  setSubmittedData(data);
312
- }
313
- return <>
314
- <Form onSubmit={handleSubmit}>
315
- {/* this is where the fields are going to be placed */}
316
- <Field
317
- key="firstName"
318
- name="firstName"
319
- label={{ primary: "First name" }}
320
- type="string"
321
- required
322
- />
323
- <Field
324
- key="lastName"
325
- name="lastName"
326
- label={{ primary: "Last name" }}
327
- type="string"
328
- required
329
- />
330
- <Button type="submit">Continue</Button>
331
- </Form>
332
- {<Paragraph>
333
- You have submitted the following values
334
- <pre><code>
335
- {JSON.stringify(submittedData)}
336
- </code></pre>
337
- </Paragraph>}
338
- </>
326
+ };
327
+ return (
328
+ <>
329
+ <Form onSubmit={handleSubmit}>
330
+ {/* this is where the fields are going to be placed */}
331
+ <Field
332
+ key="firstName"
333
+ name="firstName"
334
+ label={{ primary: 'First name' }}
335
+ type="string"
336
+ required
337
+ />
338
+ <Field
339
+ key="lastName"
340
+ name="lastName"
341
+ label={{ primary: 'Last name' }}
342
+ type="string"
343
+ required
344
+ />
345
+ <Button type="submit">Continue</Button>
346
+ </Form>
347
+ {
348
+ <Paragraph>
349
+ You have submitted the following values
350
+ <pre>
351
+ <code>{JSON.stringify(submittedData)}</code>
352
+ </pre>
353
+ </Paragraph>
354
+ }
355
+ </>
356
+ );
339
357
  }
340
358
  ```
341
359
 
@@ -370,8 +388,8 @@ the format of this tax number
370
388
  name="taxNumber"
371
389
  type="afm"
372
390
  label={{
373
- primary: "Tax number",
374
- secondary: "Tax number is your AFM number, given to you by AADE"
391
+ primary: 'Tax number',
392
+ secondary: 'Tax number is your AFM number, given to you by AADE',
375
393
  }}
376
394
  required
377
395
  />
@@ -386,8 +404,8 @@ A similar field can be used for the phone number. You can use the
386
404
  name="phoneNumber"
387
405
  type="phone_number"
388
406
  label={{
389
- primary: "Phone number",
390
- secondary: "You can enter any landline phone number."
407
+ primary: 'Phone number',
408
+ secondary: 'You can enter any landline phone number.',
391
409
  }}
392
410
  required
393
411
  />
@@ -398,29 +416,28 @@ A similar field can be used for the phone number. You can use the
398
416
  Last but not least, we should create a single choice field, which will be
399
417
  rendered as a radio group of answers.
400
418
 
401
-
402
419
  ```jsx
403
420
  <Field
404
421
  key="maritalStatus"
405
422
  name="maritalStatus"
406
423
  type="choice:single"
407
- label={{primary: "Marital status"}}
424
+ label={{ primary: 'Marital status' }}
408
425
  required
409
426
  extra={{
410
427
  options: [
411
428
  {
412
- label: {primary: "Married"},
429
+ label: { primary: 'Married' },
413
430
  value: 'married',
414
431
  },
415
432
  {
416
- label: {primary: "Cohabitation agreement"},
433
+ label: { primary: 'Cohabitation agreement' },
417
434
  value: 'cohabitation',
418
435
  },
419
436
  {
420
- label: {primary: "Prefer not to answer"},
437
+ label: { primary: 'Prefer not to answer' },
421
438
  value: 'wontanswer',
422
- }
423
- ]
439
+ },
440
+ ],
424
441
  }}
425
442
  />
426
443
  ```
@@ -435,84 +452,88 @@ Feel free to fill the form in the example and submit it.
435
452
  ```jsx live
436
453
  import React, { useState } from 'react';
437
454
  import Form, { Field } from '@digigov/form';
438
- import Button from '@digigov/ui/core/Button';
455
+ import Button from '@digigov/ui/form/Button';
439
456
  import Paragraph from '@digigov/ui/typography/Paragraph';
440
457
 
441
458
  export default function SimpleForm() {
442
- const [submittedData, setSubmittedData] = useState({})
459
+ const [submittedData, setSubmittedData] = useState({});
443
460
  const handleSubmit = (data) => {
444
461
  setSubmittedData(data);
445
- }
446
- return <>
447
- <Form onSubmit={handleSubmit}>
448
- {/* this is where the fields are going to be placed */}
449
- <Field
450
- key="firstName"
451
- name="firstName"
452
- label={{ primary: "First name" }}
453
- type="string"
454
- required
455
- />
456
- <Field
457
- key="lastName"
458
- name="lastName"
459
- label={{ primary: "Last name" }}
460
- type="string"
461
- required
462
- />
463
- <Field
464
- key="taxNumber"
465
- name="taxNumber"
466
- type="afm"
467
- label={{
468
- primary: "Tax number",
469
- secondary: "Tax number is your AFM number, given to you by AADE"
470
- }}
471
- required
472
- />
473
- <Field
474
- key="phoneNumber"
475
- name="phoneNumber"
476
- type="phone_number"
477
- label={{
478
- primary: "Phone number",
479
- secondary: "You can enter any landline phone number."
480
- }}
481
- required
482
- />
483
- <Field
484
- key="maritalStatus"
485
- name="maritalStatus"
486
- type="choice:single"
487
- label={{primary: "Marital status"}}
488
- required
489
- extra={{
490
- options: [
491
- {
492
- label: {primary: "Married"},
493
- value: 'married',
494
- },
495
- {
496
- label: {primary: "Cohabitation agreement"},
497
- value: 'cohabitation',
498
- },
499
- {
500
- label: {primary: "Prefer not to answer"},
501
- value: 'wontanswer',
502
- }
503
- ]
504
- }}
505
- />
506
- <Button type="submit">Continue</Button>
507
- </Form>
508
- {<Paragraph>
509
- You have submitted the following values
510
- <pre><code>
511
- {JSON.stringify(submittedData)}
512
- </code></pre>
513
- </Paragraph>}
514
- </>
462
+ };
463
+ return (
464
+ <>
465
+ <Form onSubmit={handleSubmit}>
466
+ {/* this is where the fields are going to be placed */}
467
+ <Field
468
+ key="firstName"
469
+ name="firstName"
470
+ label={{ primary: 'First name' }}
471
+ type="string"
472
+ required
473
+ />
474
+ <Field
475
+ key="lastName"
476
+ name="lastName"
477
+ label={{ primary: 'Last name' }}
478
+ type="string"
479
+ required
480
+ />
481
+ <Field
482
+ key="taxNumber"
483
+ name="taxNumber"
484
+ type="afm"
485
+ label={{
486
+ primary: 'Tax number',
487
+ secondary: 'Tax number is your AFM number, given to you by AADE',
488
+ }}
489
+ required
490
+ />
491
+ <Field
492
+ key="phoneNumber"
493
+ name="phoneNumber"
494
+ type="phone_number"
495
+ label={{
496
+ primary: 'Phone number',
497
+ secondary: 'You can enter any landline phone number.',
498
+ }}
499
+ required
500
+ />
501
+ <Field
502
+ key="maritalStatus"
503
+ name="maritalStatus"
504
+ type="choice:single"
505
+ label={{ primary: 'Marital status' }}
506
+ required
507
+ extra={{
508
+ options: [
509
+ {
510
+ label: { primary: 'Married' },
511
+ value: 'married',
512
+ },
513
+ {
514
+ label: { primary: 'Cohabitation agreement' },
515
+ value: 'cohabitation',
516
+ },
517
+ {
518
+ label: { primary: 'Prefer not to answer' },
519
+ value: 'wontanswer',
520
+ },
521
+ ],
522
+ }}
523
+ />
524
+ <Button type="submit">Continue</Button>
525
+ </Form>
526
+ {
527
+ <Paragraph>
528
+ You have submitted the following values
529
+ <pre>
530
+ <code>{JSON.stringify(submittedData)}</code>
531
+ </pre>
532
+ </Paragraph>
533
+ }
534
+ </>
535
+ );
515
536
  }
516
537
  ```
517
538
 
518
- Perfect! We now have a finished form, complete with field validation.
539
+ Perfect! We now have a finished form, complete with field validation.