@digigov/form 0.13.2 → 1.0.0-079f34f3d

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 (303) 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 +29 -44
  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 +9 -9
  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 +11 -11
  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.d.ts +2 -2
  35. package/Questions/Step/StepTitle.js +11 -5
  36. package/Questions/Step/getAddMoreFields.d.ts +1 -1
  37. package/Questions/__snapshots__/index.spec.tsx.snap +72 -359
  38. package/Questions/__stories__/Default.js +7 -7
  39. package/Questions/index.mdx +45 -48
  40. package/Questions/index.spec.js +2 -2
  41. package/create-simple-form.mdx +258 -237
  42. package/es/Field/FieldBase.js +1 -1
  43. package/es/Field/FieldBaseContainer.js +6 -6
  44. package/es/Field/FieldConditional.js +1 -1
  45. package/es/Field/utils.js +5 -5
  46. package/es/FieldArray/__stories__/Default.js +1 -1
  47. package/es/FieldArray/__stories__/WithExactLength.js +1 -1
  48. package/es/FieldArray/index.js +2 -2
  49. package/es/FieldObject/index.js +3 -3
  50. package/es/Fieldset/FieldsetWithContext.js +2 -2
  51. package/es/Fieldset/index.js +1 -1
  52. package/es/FormBuilder/FormBuilder.js +3 -3
  53. package/es/FormBuilder/FormBuilder.mdx +29 -44
  54. package/es/FormBuilder/__stories__/Default.js +1 -1
  55. package/es/MultiplicityField/MultiplicityField.mdx +277 -267
  56. package/es/MultiplicityField/__stories__/Default.js +1 -1
  57. package/es/MultiplicityField/__stories__/PreviewDisplay.js +8 -8
  58. package/es/MultiplicityField/__stories__/WithExactLength.js +1 -1
  59. package/es/MultiplicityField/__stories__/WithMaxLength.js +1 -1
  60. package/es/MultiplicityField/__stories__/WithMinAndMaxLength.js +1 -1
  61. package/es/MultiplicityField/__stories__/WithMinLength.js +1 -1
  62. package/es/MultiplicityField/add-objects.js +3 -3
  63. package/es/MultiplicityField/index.js +5 -5
  64. package/es/Questions/Questions.js +1 -1
  65. package/es/Questions/Step/ReviewStep.js +5 -5
  66. package/es/Questions/Step/Step.js +1 -1
  67. package/es/Questions/Step/StepArrayReview.js +7 -7
  68. package/es/Questions/Step/StepDescription.js +1 -1
  69. package/es/Questions/Step/StepForm.js +5 -5
  70. package/es/Questions/Step/StepTitle.js +9 -5
  71. package/es/Questions/__snapshots__/index.spec.tsx.snap +72 -359
  72. package/es/Questions/__stories__/Default.js +5 -5
  73. package/es/Questions/index.mdx +45 -48
  74. package/es/Questions/index.spec.js +1 -1
  75. package/es/create-simple-form.mdx +258 -237
  76. package/es/index.mdx +13 -6
  77. package/es/inputs/AutoComplete/__stories__/Default.js +3 -3
  78. package/es/inputs/AutoComplete/index.js +1 -1
  79. package/es/inputs/Checkboxes/__stories__/Conditional.js +1 -1
  80. package/es/inputs/Checkboxes/__stories__/Default.js +1 -1
  81. package/es/inputs/Checkboxes/__stories__/WithDivider.js +2 -2
  82. package/es/inputs/Checkboxes/index.js +3 -3
  83. package/es/inputs/DateInput/__stories__/Default.js +1 -1
  84. package/es/inputs/DateInput/index.js +1 -1
  85. package/es/inputs/FileInput/__stories__/Default.js +1 -1
  86. package/es/inputs/FileInput/index.js +6 -6
  87. package/es/inputs/Input/__stories__/AFM.js +1 -1
  88. package/es/inputs/Input/__stories__/Boolean.js +1 -1
  89. package/es/inputs/Input/__stories__/Default.js +1 -1
  90. package/es/inputs/Input/__stories__/IBAN.js +1 -1
  91. package/es/inputs/Input/__stories__/Integer.js +1 -1
  92. package/es/inputs/Input/__stories__/MobilePhone.js +1 -1
  93. package/es/inputs/Input/__stories__/PhoneNumber.js +1 -1
  94. package/es/inputs/Input/__stories__/PostalCode.js +1 -1
  95. package/es/inputs/Input/__stories__/TextWithCharacterLimit.js +1 -1
  96. package/es/inputs/Input/index.js +1 -1
  97. package/es/inputs/Label/__stories__/Default.js +1 -1
  98. package/es/inputs/Label/index.js +3 -3
  99. package/es/inputs/OtpInput/__stories__/Default.js +1 -1
  100. package/es/inputs/OtpInput/index.js +5 -5
  101. package/es/inputs/Radio/__stories__/Conditional.js +1 -1
  102. package/es/inputs/Radio/__stories__/Default.js +1 -1
  103. package/es/inputs/Radio/__stories__/WithDivider.js +2 -2
  104. package/es/inputs/Radio/index.js +4 -4
  105. package/es/inputs/Select/__stories__/Default.js +1 -1
  106. package/es/installation.mdx +12 -16
  107. package/es/utils.js +1 -1
  108. package/es/validators/index.js +2 -2
  109. package/esm/Field/FieldBase.js +1 -1
  110. package/esm/Field/FieldBaseContainer.js +6 -6
  111. package/esm/Field/FieldConditional.js +1 -1
  112. package/esm/Field/utils.js +5 -5
  113. package/esm/FieldArray/__stories__/Default.js +1 -1
  114. package/esm/FieldArray/__stories__/WithExactLength.js +1 -1
  115. package/esm/FieldArray/index.js +2 -2
  116. package/esm/FieldObject/index.js +3 -3
  117. package/esm/Fieldset/FieldsetWithContext.js +2 -2
  118. package/esm/Fieldset/index.js +1 -1
  119. package/esm/FormBuilder/FormBuilder.js +3 -3
  120. package/esm/FormBuilder/FormBuilder.mdx +29 -44
  121. package/esm/FormBuilder/__stories__/Default.js +1 -1
  122. package/esm/MultiplicityField/MultiplicityField.mdx +277 -267
  123. package/esm/MultiplicityField/__stories__/Default.js +1 -1
  124. package/esm/MultiplicityField/__stories__/PreviewDisplay.js +8 -8
  125. package/esm/MultiplicityField/__stories__/WithExactLength.js +1 -1
  126. package/esm/MultiplicityField/__stories__/WithMaxLength.js +1 -1
  127. package/esm/MultiplicityField/__stories__/WithMinAndMaxLength.js +1 -1
  128. package/esm/MultiplicityField/__stories__/WithMinLength.js +1 -1
  129. package/esm/MultiplicityField/add-objects.js +3 -3
  130. package/esm/MultiplicityField/index.js +5 -5
  131. package/esm/Questions/Questions.js +1 -1
  132. package/esm/Questions/Step/ReviewStep.js +5 -5
  133. package/esm/Questions/Step/Step.js +1 -1
  134. package/esm/Questions/Step/StepArrayReview.js +7 -7
  135. package/esm/Questions/Step/StepDescription.js +1 -1
  136. package/esm/Questions/Step/StepForm.js +5 -5
  137. package/esm/Questions/Step/StepTitle.js +9 -5
  138. package/esm/Questions/__snapshots__/index.spec.tsx.snap +72 -359
  139. package/esm/Questions/__stories__/Default.js +5 -5
  140. package/esm/Questions/index.mdx +45 -48
  141. package/esm/Questions/index.spec.js +1 -1
  142. package/esm/create-simple-form.mdx +258 -237
  143. package/esm/index.js +1 -1
  144. package/esm/index.mdx +13 -6
  145. package/esm/inputs/AutoComplete/__stories__/Default.js +3 -3
  146. package/esm/inputs/AutoComplete/index.js +1 -1
  147. package/esm/inputs/Checkboxes/__stories__/Conditional.js +1 -1
  148. package/esm/inputs/Checkboxes/__stories__/Default.js +1 -1
  149. package/esm/inputs/Checkboxes/__stories__/WithDivider.js +2 -2
  150. package/esm/inputs/Checkboxes/index.js +3 -3
  151. package/esm/inputs/DateInput/__stories__/Default.js +1 -1
  152. package/esm/inputs/DateInput/index.js +1 -1
  153. package/esm/inputs/FileInput/__stories__/Default.js +1 -1
  154. package/esm/inputs/FileInput/index.js +6 -6
  155. package/esm/inputs/Input/__stories__/AFM.js +1 -1
  156. package/esm/inputs/Input/__stories__/Boolean.js +1 -1
  157. package/esm/inputs/Input/__stories__/Default.js +1 -1
  158. package/esm/inputs/Input/__stories__/IBAN.js +1 -1
  159. package/esm/inputs/Input/__stories__/Integer.js +1 -1
  160. package/esm/inputs/Input/__stories__/MobilePhone.js +1 -1
  161. package/esm/inputs/Input/__stories__/PhoneNumber.js +1 -1
  162. package/esm/inputs/Input/__stories__/PostalCode.js +1 -1
  163. package/esm/inputs/Input/__stories__/TextWithCharacterLimit.js +1 -1
  164. package/esm/inputs/Input/index.js +1 -1
  165. package/esm/inputs/Label/__stories__/Default.js +1 -1
  166. package/esm/inputs/Label/index.js +3 -3
  167. package/esm/inputs/OtpInput/__stories__/Default.js +1 -1
  168. package/esm/inputs/OtpInput/index.js +5 -5
  169. package/esm/inputs/Radio/__stories__/Conditional.js +1 -1
  170. package/esm/inputs/Radio/__stories__/Default.js +1 -1
  171. package/esm/inputs/Radio/__stories__/WithDivider.js +2 -2
  172. package/esm/inputs/Radio/index.js +4 -4
  173. package/esm/inputs/Select/__stories__/Default.js +1 -1
  174. package/esm/installation.mdx +12 -16
  175. package/esm/utils.js +1 -1
  176. package/esm/validators/index.js +2 -2
  177. package/index.mdx +13 -6
  178. package/inputs/AutoComplete/__stories__/Default.js +4 -4
  179. package/inputs/AutoComplete/index.d.ts +2 -2
  180. package/inputs/AutoComplete/index.js +2 -2
  181. package/inputs/Checkboxes/__stories__/Conditional.js +2 -2
  182. package/inputs/Checkboxes/__stories__/Default.js +2 -2
  183. package/inputs/Checkboxes/__stories__/WithDivider.js +3 -3
  184. package/inputs/Checkboxes/index.d.ts +1 -1
  185. package/inputs/Checkboxes/index.js +4 -4
  186. package/inputs/DateInput/__stories__/Default.js +2 -2
  187. package/inputs/DateInput/index.js +2 -2
  188. package/inputs/FileInput/__stories__/Default.js +2 -2
  189. package/inputs/FileInput/index.js +6 -6
  190. package/inputs/Input/__stories__/AFM.js +2 -2
  191. package/inputs/Input/__stories__/Boolean.js +2 -2
  192. package/inputs/Input/__stories__/Default.js +2 -2
  193. package/inputs/Input/__stories__/IBAN.js +2 -2
  194. package/inputs/Input/__stories__/Integer.js +2 -2
  195. package/inputs/Input/__stories__/MobilePhone.js +2 -2
  196. package/inputs/Input/__stories__/PhoneNumber.js +2 -2
  197. package/inputs/Input/__stories__/PostalCode.js +2 -2
  198. package/inputs/Input/__stories__/TextWithCharacterLimit.js +2 -2
  199. package/inputs/Input/index.js +1 -1
  200. package/inputs/Label/__stories__/Default.js +2 -2
  201. package/inputs/Label/index.js +4 -4
  202. package/inputs/OtpInput/__stories__/Default.js +2 -2
  203. package/inputs/OtpInput/index.js +5 -5
  204. package/inputs/Radio/__stories__/Conditional.js +2 -2
  205. package/inputs/Radio/__stories__/Default.js +2 -2
  206. package/inputs/Radio/__stories__/WithDivider.js +3 -3
  207. package/inputs/Radio/index.d.ts +1 -1
  208. package/inputs/Radio/index.js +7 -7
  209. package/inputs/Select/__stories__/Default.js +2 -2
  210. package/inputs/Select/index.d.ts +1 -1
  211. package/installation.mdx +12 -16
  212. package/package.json +5 -5
  213. package/src/Field/FieldBase.tsx +1 -1
  214. package/src/Field/FieldBaseContainer.tsx +7 -7
  215. package/src/Field/FieldConditional.tsx +1 -1
  216. package/src/Field/index.tsx +1 -1
  217. package/src/Field/utils.ts +7 -7
  218. package/src/FieldArray/FieldArray.stories.js +1 -1
  219. package/src/FieldArray/__stories__/Default.tsx +1 -1
  220. package/src/FieldArray/__stories__/WithExactLength.tsx +1 -1
  221. package/src/FieldArray/index.tsx +3 -3
  222. package/src/FieldObject/index.tsx +6 -6
  223. package/src/Fieldset/FieldsetWithContext.tsx +3 -3
  224. package/src/Fieldset/index.tsx +5 -5
  225. package/src/Fieldset/types.tsx +3 -3
  226. package/src/FormBuilder/FormBuilder.mdx +29 -44
  227. package/src/FormBuilder/FormBuilder.stories.js +1 -1
  228. package/src/FormBuilder/FormBuilder.tsx +4 -4
  229. package/src/FormBuilder/__stories__/Default.tsx +1 -1
  230. package/src/MultiplicityField/MultiplicityField.mdx +277 -267
  231. package/src/MultiplicityField/MultiplicityField.stories.js +1 -1
  232. package/src/MultiplicityField/__stories__/Default.tsx +1 -1
  233. package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +18 -18
  234. package/src/MultiplicityField/__stories__/WithExactLength.tsx +1 -1
  235. package/src/MultiplicityField/__stories__/WithMaxLength.tsx +1 -1
  236. package/src/MultiplicityField/__stories__/WithMinAndMaxLength.tsx +1 -1
  237. package/src/MultiplicityField/__stories__/WithMinLength.tsx +1 -1
  238. package/src/MultiplicityField/add-objects.tsx +3 -3
  239. package/src/MultiplicityField/index.tsx +9 -9
  240. package/src/Questions/Questions.stories.js +1 -1
  241. package/src/Questions/Questions.tsx +2 -2
  242. package/src/Questions/Step/ReviewStep.tsx +6 -6
  243. package/src/Questions/Step/Step.tsx +1 -1
  244. package/src/Questions/Step/StepArrayReview.tsx +11 -11
  245. package/src/Questions/Step/StepDescription.tsx +1 -1
  246. package/src/Questions/Step/StepForm.tsx +6 -6
  247. package/src/Questions/Step/StepTitle.tsx +19 -17
  248. package/src/Questions/Step/getAddMoreFields.tsx +1 -1
  249. package/src/Questions/__snapshots__/index.spec.tsx.snap +72 -359
  250. package/src/Questions/__stories__/Default.tsx +8 -8
  251. package/src/Questions/index.mdx +45 -48
  252. package/src/Questions/index.spec.tsx +1 -1
  253. package/src/create-simple-form.mdx +258 -237
  254. package/src/index.mdx +13 -6
  255. package/src/inputs/AutoComplete/__stories__/Default.tsx +3 -3
  256. package/src/inputs/AutoComplete/index.tsx +4 -4
  257. package/src/inputs/Checkboxes/Checkboxes.stories.js +1 -1
  258. package/src/inputs/Checkboxes/__stories__/Conditional.tsx +2 -2
  259. package/src/inputs/Checkboxes/__stories__/Default.tsx +1 -1
  260. package/src/inputs/Checkboxes/__stories__/WithDivider.tsx +2 -2
  261. package/src/inputs/Checkboxes/index.tsx +4 -4
  262. package/src/inputs/DateInput/DateInput.stories.js +1 -1
  263. package/src/inputs/DateInput/__stories__/Default.tsx +1 -1
  264. package/src/inputs/DateInput/index.tsx +2 -2
  265. package/src/inputs/FileInput/FileInput.stories.js +1 -1
  266. package/src/inputs/FileInput/__stories__/Default.tsx +1 -1
  267. package/src/inputs/FileInput/index.tsx +6 -6
  268. package/src/inputs/Input/__stories__/AFM.tsx +1 -1
  269. package/src/inputs/Input/__stories__/Boolean.tsx +1 -1
  270. package/src/inputs/Input/__stories__/Default.tsx +1 -1
  271. package/src/inputs/Input/__stories__/IBAN.tsx +1 -1
  272. package/src/inputs/Input/__stories__/Integer.tsx +1 -1
  273. package/src/inputs/Input/__stories__/MobilePhone.tsx +1 -1
  274. package/src/inputs/Input/__stories__/PhoneNumber.tsx +1 -1
  275. package/src/inputs/Input/__stories__/PostalCode.tsx +1 -1
  276. package/src/inputs/Input/__stories__/TextWithCharacterLimit.tsx +1 -1
  277. package/src/inputs/Input/index.tsx +3 -3
  278. package/src/inputs/Label/Label.stories.js +1 -1
  279. package/src/inputs/Label/__stories__/Default.tsx +1 -1
  280. package/src/inputs/Label/index.tsx +4 -4
  281. package/src/inputs/OtpInput/__stories__/Default.tsx +1 -1
  282. package/src/inputs/OtpInput/index.tsx +14 -10
  283. package/src/inputs/Radio/Radio.stories.js +1 -2
  284. package/src/inputs/Radio/__stories__/Conditional.tsx +3 -3
  285. package/src/inputs/Radio/__stories__/Default.tsx +1 -1
  286. package/src/inputs/Radio/__stories__/WithDivider.tsx +2 -2
  287. package/src/inputs/Radio/index.tsx +6 -6
  288. package/src/inputs/Select/Select.stories.js +1 -1
  289. package/src/inputs/Select/__stories__/Default.tsx +1 -1
  290. package/src/inputs/Select/index.tsx +2 -2
  291. package/src/installation.mdx +12 -16
  292. package/src/types.tsx +4 -2
  293. package/src/utils.ts +1 -1
  294. package/src/validators/index.ts +10 -10
  295. package/src/validators/utils/file.ts +1 -1
  296. package/src/validators/utils/phone.ts +1 -1
  297. package/src/validators/utils/postal_code.ts +1 -1
  298. package/types.d.ts +4 -2
  299. package/validators/index.d.ts +3 -3
  300. package/validators/index.js +4 -4
  301. package/validators/utils/file.d.ts +1 -1
  302. package/validators/utils/phone.d.ts +1 -1
  303. package/validators/utils/postal_code.d.ts +1 -1
@@ -3,12 +3,13 @@ id: ask-users-recursive
3
3
  title: Ask users for recursive data
4
4
  ---
5
5
 
6
- import LeadText from "@site/src/components/LeadText";
6
+ import LeadText from '@site/src/components/LeadText';
7
7
 
8
- <LeadText>Multiplicity & FieldArray fields allow users to input data described
9
- by a particular schema for an arbitrary number of times until they are
10
- done. It can be used to input a fixed, a minimum, and a maximum
11
- length of instances.</LeadText>
8
+ <LeadText>
9
+ Multiplicity & FieldArray fields allow users to input data described by a
10
+ particular schema for an arbitrary number of times until they are done. It can
11
+ be used to input a fixed, a minimum, and a maximum length of instances.
12
+ </LeadText>
12
13
 
13
14
  ## What we are trying to achieve
14
15
 
@@ -47,11 +48,11 @@ the reason we decided to design the flow to be as guided and recoverable as
47
48
  possible. Forms and fields should read like well-written pieces of text and
48
49
  make sense to the users. While validation fails, the system provides users with
49
50
  meaningful error messages and instructs them on how to fix the validation errors to
50
- proceed. Once the validation is successful, the flow can proceed with
51
- submmitting data. In any case, it is imperative to provide meaningful
51
+ proceed. Once the validation is successful, the flow can proceed with
52
+ submmitting data. In any case, it is imperative to provide meaningful
52
53
  information to the users at each step. Thus, we should avoid the use of 🌈
53
54
  “magic“ ✨ UX solutions that presume users have developed digital skills and
54
- most of the time are used for expert use cases.
55
+ most of the time are used for expert use cases.
55
56
 
56
57
  Initially, we used an add button that users clicked to explicitly create with
57
58
  their action a new item in the array, but in this way we cannot programmatically
@@ -78,7 +79,6 @@ be confused. If you choose to use it, please provide meaningful hints in the
78
79
 
79
80
  :::
80
81
 
81
-
82
82
  Users should fill in data as this schema dictates, and every time
83
83
  they add something, we should ask them if they want to continue adding or escape
84
84
  the loop. We could also add some limits to the number of items users create,
@@ -90,7 +90,7 @@ action that could lead to estranged users losing the intended path or their
90
90
  focus.
91
91
 
92
92
  Those are a lot of things to keep in mind, but luckily we've got you covered. How
93
- can we code this feature as part of a Digigov form, you ask?
93
+ can we code this feature as part of a Digigov form, you ask?
94
94
 
95
95
  ## Introducing the Multiplicity field
96
96
 
@@ -106,77 +106,79 @@ indexes will be an object with nested field values.
106
106
  This field is the most complex component we currently offer, and it uses the
107
107
  [useFieldArray](https://www.react-hook-form.com/api/usefieldarray) hook from
108
108
  react-hook-form under the hood. First, let's take a look at what it looks like, and then we can
109
- break down its functionality and how you can use it.
109
+ break down its functionality and how you can use it.
110
110
 
111
111
  ```jsx live
112
112
  import React from 'react';
113
113
  import Form, { Field } from '@digigov/form';
114
- import Button from '@digigov/ui/core/Button';
114
+ import Button from '@digigov/ui/form/Button';
115
115
 
116
116
  export default function SimpleForm() {
117
- return <Form>
118
- <Field
119
- key="vehicles"
120
- name="vehicles"
121
- label={{ primary: "Vehicles" }}
122
- type="array"
123
- extra={{
124
- border: true,
125
- label: {
126
- object: {
127
- title: 'Vehicle',
128
- title_added: 'The vehicles you have already added',
129
- add: 'Add',
130
- delete: 'Remove',
131
- },
132
- question: {
133
- title: 'Do you want to add more vehicles?',
134
- objectLabel: {
135
- primary: 'Add one more of your vehicles',
136
- secondary: 'Fill in the details below and then click “Add“.',
137
- },
138
- yes: 'Yes',
139
- no: 'No',
140
- },
141
- },
142
- of: {
143
- type: 'object',
117
+ return (
118
+ <Form>
119
+ <Field
120
+ key="vehicles"
121
+ name="vehicles"
122
+ label={{ primary: 'Vehicles' }}
123
+ type="array"
124
+ extra={{
125
+ border: true,
144
126
  label: {
145
- primary: 'Vehicle details',
146
- secondary: 'See and change the details of a vehicle',
147
- },
148
- extra: {
149
- fields: [
150
- {
151
- key: 'registration_date',
152
- type: 'date',
153
- required: true,
154
- label: { primary: 'Registration date' },
127
+ object: {
128
+ title: 'Vehicle',
129
+ title_added: 'The vehicles you have already added',
130
+ add: 'Add',
131
+ delete: 'Remove',
132
+ },
133
+ question: {
134
+ title: 'Do you want to add more vehicles?',
135
+ objectLabel: {
136
+ primary: 'Add one more of your vehicles',
137
+ secondary: 'Fill in the details below and then click “Add“.',
155
138
  },
156
- {
157
- key: 'make',
158
- type: 'string',
159
- required: true,
160
- label: {
161
- primary: 'Make',
139
+ yes: 'Yes',
140
+ no: 'No',
141
+ },
142
+ },
143
+ of: {
144
+ type: 'object',
145
+ label: {
146
+ primary: 'Vehicle details',
147
+ secondary: 'See and change the details of a vehicle',
148
+ },
149
+ extra: {
150
+ fields: [
151
+ {
152
+ key: 'registration_date',
153
+ type: 'date',
154
+ required: true,
155
+ label: { primary: 'Registration date' },
162
156
  },
163
- },
164
- {
165
- key: 'model',
166
- type: 'string',
167
- required: true,
168
- label: {
169
- primary: 'Model',
157
+ {
158
+ key: 'make',
159
+ type: 'string',
160
+ required: true,
161
+ label: {
162
+ primary: 'Make',
163
+ },
170
164
  },
171
- },
172
- ],
165
+ {
166
+ key: 'model',
167
+ type: 'string',
168
+ required: true,
169
+ label: {
170
+ primary: 'Model',
171
+ },
172
+ },
173
+ ],
174
+ },
173
175
  },
174
- },
175
- }}
176
- required
177
- />
178
- <Button type="submit">Submit</Button>
179
- </Form>
176
+ }}
177
+ required
178
+ />
179
+ <Button type="submit">Submit</Button>
180
+ </Form>
181
+ );
180
182
  }
181
183
  ```
182
184
 
@@ -188,13 +190,15 @@ and a submit `Button` that will trigger the `onSubmit` events in our React form.
188
190
  ```jsx
189
191
  import React from 'react';
190
192
  import Form from '@digigov/form';
191
- import Button from '@digigov/ui/core/Button';
193
+ import Button from '@digigov/ui/form/Button';
192
194
 
193
195
  export default function MultiplicityForm() {
194
- return <Form>
195
- {/* this is where all fields will eventually be rendered */}
196
- <Button type="submit">Submit</Button>
197
- </Form>
196
+ return (
197
+ <Form>
198
+ {/* this is where all fields will eventually be rendered */}
199
+ <Button type="submit">Submit</Button>
200
+ </Form>
201
+ );
198
202
  }
199
203
  ```
200
204
 
@@ -209,7 +213,7 @@ props.
209
213
  <Field
210
214
  key="vehicles"
211
215
  name="vehicles"
212
- label={{ primary: "Vehicles" }}
216
+ label={{ primary: 'Vehicles' }}
213
217
  type="array"
214
218
  required
215
219
  />
@@ -218,18 +222,18 @@ props.
218
222
  Although this code may seem enough at first glance, it will soon become clear
219
223
  that Multiplicity packs a lot of functionality. It needs context in the form of
220
224
  natural language, Greek, English, or any other language dictated by the user needs
221
- in order to carry meaning to the end users.
225
+ in order to carry meaning to the end users.
222
226
 
223
227
  It also needs the schema of the form fields to be filled for each iteration. To
224
228
  do so, inside the `extra` key we can add an `of` key. This `of` key will contain
225
229
  a key named `label` and a key name `type`, signifying the label text and the type of the
226
- inner form, respectively.
230
+ inner form, respectively.
227
231
 
228
232
  Inside the `of` key you can add an `extra` key that will then contain a `fields`
229
233
  key describing the field props for all inputs needed.
230
234
 
231
235
  ```js
232
- // this will be used as value for the `extra` prop
236
+ // this will be used as value for the `extra` prop
233
237
  {
234
238
  of: {
235
239
  type: 'object',
@@ -268,7 +272,7 @@ key describing the field props for all inputs needed.
268
272
  ```
269
273
 
270
274
  ## Introducing the FieldArray field
271
-
275
+
272
276
  As a simpler alternative to Multiplicity, we also offer the original
273
277
  implementation called `FieldArray` which may be used in dashboards or other apps
274
278
  used by expert users or administrators of any kind. FieldArray skips all the
@@ -290,7 +294,7 @@ React code.
290
294
  <Field
291
295
  key="vehicles"
292
296
  name="vehicles"
293
- label={{ primary: "Vehicles" }}
297
+ label={{ primary: 'Vehicles' }}
294
298
  type="array"
295
299
  // highlight-next-line
296
300
  multiplicity={false}
@@ -299,79 +303,81 @@ React code.
299
303
  ```
300
304
 
301
305
  The end result looks very different from Multiplicity at first glance, but you
302
- can achieve the same results with both of them.
306
+ can achieve the same results with both of them.
303
307
 
304
308
  ```jsx live
305
309
  import React from 'react';
306
310
  import Form, { Field } from '@digigov/form';
307
- import Button from '@digigov/ui/core/Button';
311
+ import Button from '@digigov/ui/form/Button';
308
312
 
309
313
  export default function SimpleForm() {
310
- return <Form>
311
- <Field
312
- key="vehicles"
313
- name="vehicles"
314
- label={{ primary: "Vehicles" }}
315
- type="array"
316
- multiplicity={false}
317
- extra={{
318
- border: true,
319
- label: {
320
- object: {
321
- title: 'Vehicle',
322
- title_added: 'The vehicles you have already added',
323
- nothing_added: 'You have not added any vehicles yet.',
324
- add: 'Add vehicle',
325
- delete: 'Remove',
326
- },
327
- question: {
328
- title: 'Do you want to add more vehicles?',
329
- objectLabel: {
330
- primary: 'Add one more of your vehicles',
331
- secondary: 'Fill in the details below and then click “Add“.',
332
- },
333
- yes: 'Yes',
334
- no: 'No',
335
- },
336
- },
337
- of: {
338
- type: 'object',
314
+ return (
315
+ <Form>
316
+ <Field
317
+ key="vehicles"
318
+ name="vehicles"
319
+ label={{ primary: 'Vehicles' }}
320
+ type="array"
321
+ multiplicity={false}
322
+ extra={{
323
+ border: true,
339
324
  label: {
340
- primary: 'Vehicle details',
341
- secondary: 'See and change the details of a vehicle',
342
- },
343
- extra: {
344
- fields: [
345
- {
346
- key: 'registration_date',
347
- type: 'date',
348
- required: true,
349
- label: { primary: 'Registration date' },
325
+ object: {
326
+ title: 'Vehicle',
327
+ title_added: 'The vehicles you have already added',
328
+ nothing_added: 'You have not added any vehicles yet.',
329
+ add: 'Add vehicle',
330
+ delete: 'Remove',
331
+ },
332
+ question: {
333
+ title: 'Do you want to add more vehicles?',
334
+ objectLabel: {
335
+ primary: 'Add one more of your vehicles',
336
+ secondary: 'Fill in the details below and then click “Add“.',
350
337
  },
351
- {
352
- key: 'make',
353
- type: 'string',
354
- required: true,
355
- label: {
356
- primary: 'Make',
338
+ yes: 'Yes',
339
+ no: 'No',
340
+ },
341
+ },
342
+ of: {
343
+ type: 'object',
344
+ label: {
345
+ primary: 'Vehicle details',
346
+ secondary: 'See and change the details of a vehicle',
347
+ },
348
+ extra: {
349
+ fields: [
350
+ {
351
+ key: 'registration_date',
352
+ type: 'date',
353
+ required: true,
354
+ label: { primary: 'Registration date' },
357
355
  },
358
- },
359
- {
360
- key: 'model',
361
- type: 'string',
362
- required: true,
363
- label: {
364
- primary: 'Model',
356
+ {
357
+ key: 'make',
358
+ type: 'string',
359
+ required: true,
360
+ label: {
361
+ primary: 'Make',
362
+ },
365
363
  },
366
- },
367
- ],
364
+ {
365
+ key: 'model',
366
+ type: 'string',
367
+ required: true,
368
+ label: {
369
+ primary: 'Model',
370
+ },
371
+ },
372
+ ],
373
+ },
368
374
  },
369
- },
370
- }}
371
- required
372
- />
373
- <Button type="submit">Submit</Button>
374
- </Form>
375
+ }}
376
+ required
377
+ />
378
+ <Button type="submit">Submit</Button>
379
+ </Form>
380
+ );
375
381
  }
376
382
  ```
377
383
 
@@ -406,74 +412,76 @@ to make sure that the users understand what is going wrong with the process.
406
412
  ```jsx live
407
413
  import React from 'react';
408
414
  import Form, { Field } from '@digigov/form';
409
- import Button from '@digigov/ui/core/Button';
415
+ import Button from '@digigov/ui/form/Button';
410
416
 
411
417
  export default function SimpleForm() {
412
- return <Form>
413
- <Field
414
- key="vehicles"
415
- name="vehicles"
416
- label={{ primary: "Vehicles" }}
417
- type="array"
418
- multiplicity={true}
419
- extra={{
420
- border: true,
421
- length: 3,
422
- label: {
423
- object: {
424
- title: 'Vehicle',
425
- title_added: 'The vehicles you have already added',
426
- add: 'Add',
427
- delete: 'Remove',
428
- },
429
- question: {
430
- title: 'Do you want to add more vehicles?',
431
- objectLabel: {
432
- primary: 'Add one more of your vehicles',
433
- secondary: 'Fill in the details below and then click “Add“.',
434
- },
435
- yes: 'Yes',
436
- no: 'No',
437
- },
438
- },
439
- of: {
440
- type: 'object',
418
+ return (
419
+ <Form>
420
+ <Field
421
+ key="vehicles"
422
+ name="vehicles"
423
+ label={{ primary: 'Vehicles' }}
424
+ type="array"
425
+ multiplicity={true}
426
+ extra={{
427
+ border: true,
428
+ length: 3,
441
429
  label: {
442
- primary: 'Vehicle details',
443
- secondary: 'See and change the details of a vehicle',
444
- },
445
- extra: {
446
- fields: [
447
- {
448
- key: 'registration_date',
449
- type: 'date',
450
- required: true,
451
- label: { primary: 'Registration date' },
430
+ object: {
431
+ title: 'Vehicle',
432
+ title_added: 'The vehicles you have already added',
433
+ add: 'Add',
434
+ delete: 'Remove',
435
+ },
436
+ question: {
437
+ title: 'Do you want to add more vehicles?',
438
+ objectLabel: {
439
+ primary: 'Add one more of your vehicles',
440
+ secondary: 'Fill in the details below and then click “Add“.',
452
441
  },
453
- {
454
- key: 'make',
455
- type: 'string',
456
- required: true,
457
- label: {
458
- primary: 'Make',
442
+ yes: 'Yes',
443
+ no: 'No',
444
+ },
445
+ },
446
+ of: {
447
+ type: 'object',
448
+ label: {
449
+ primary: 'Vehicle details',
450
+ secondary: 'See and change the details of a vehicle',
451
+ },
452
+ extra: {
453
+ fields: [
454
+ {
455
+ key: 'registration_date',
456
+ type: 'date',
457
+ required: true,
458
+ label: { primary: 'Registration date' },
459
459
  },
460
- },
461
- {
462
- key: 'model',
463
- type: 'string',
464
- required: true,
465
- label: {
466
- primary: 'Model',
460
+ {
461
+ key: 'make',
462
+ type: 'string',
463
+ required: true,
464
+ label: {
465
+ primary: 'Make',
466
+ },
467
467
  },
468
- },
469
- ],
468
+ {
469
+ key: 'model',
470
+ type: 'string',
471
+ required: true,
472
+ label: {
473
+ primary: 'Model',
474
+ },
475
+ },
476
+ ],
477
+ },
470
478
  },
471
- },
472
- }}
473
- required
474
- />
475
- <Button type="submit">Submit</Button>
476
- </Form>
479
+ }}
480
+ required
481
+ />
482
+ <Button type="submit">Submit</Button>
483
+ </Form>
484
+ );
477
485
  }
478
486
  ```
479
487
 
@@ -506,75 +514,77 @@ to make sure that the users understand what is going wrong with the process.
506
514
  ```jsx live
507
515
  import React from 'react';
508
516
  import Form, { Field } from '@digigov/form';
509
- import Button from '@digigov/ui/core/Button';
517
+ import Button from '@digigov/ui/form/Button';
510
518
 
511
519
  export default function SimpleForm() {
512
- return <Form>
513
- <Field
514
- key="vehicles"
515
- name="vehicles"
516
- label={{ primary: "Vehicles" }}
517
- type="array"
518
- multiplicity={true}
519
- extra={{
520
- border: true,
521
- min: 2,
522
- max: 5,
523
- label: {
524
- object: {
525
- title: 'Vehicle',
526
- title_added: 'The vehicles you have already added',
527
- nothing_added: 'You have not added any vehicles yet.',
528
- add: 'Add',
529
- delete: 'Remove',
530
- },
531
- question: {
532
- title: 'Do you want to add more vehicles?',
533
- objectLabel: {
534
- primary: 'Add one more of your vehicles',
535
- secondary: 'Fill in the details below and then click “Add“.',
536
- },
537
- yes: 'Yes',
538
- no: 'No',
539
- },
540
- },
541
- of: {
542
- type: 'object',
520
+ return (
521
+ <Form>
522
+ <Field
523
+ key="vehicles"
524
+ name="vehicles"
525
+ label={{ primary: 'Vehicles' }}
526
+ type="array"
527
+ multiplicity={true}
528
+ extra={{
529
+ border: true,
530
+ min: 2,
531
+ max: 5,
543
532
  label: {
544
- primary: 'Vehicle details',
545
- secondary: 'See and change the details of a vehicle',
546
- },
547
- extra: {
548
- fields: [
549
- {
550
- key: 'registration_date',
551
- type: 'date',
552
- required: true,
553
- label: { primary: 'Registration date' },
533
+ object: {
534
+ title: 'Vehicle',
535
+ title_added: 'The vehicles you have already added',
536
+ nothing_added: 'You have not added any vehicles yet.',
537
+ add: 'Add',
538
+ delete: 'Remove',
539
+ },
540
+ question: {
541
+ title: 'Do you want to add more vehicles?',
542
+ objectLabel: {
543
+ primary: 'Add one more of your vehicles',
544
+ secondary: 'Fill in the details below and then click “Add“.',
554
545
  },
555
- {
556
- key: 'make',
557
- type: 'string',
558
- required: true,
559
- label: {
560
- primary: 'Make',
546
+ yes: 'Yes',
547
+ no: 'No',
548
+ },
549
+ },
550
+ of: {
551
+ type: 'object',
552
+ label: {
553
+ primary: 'Vehicle details',
554
+ secondary: 'See and change the details of a vehicle',
555
+ },
556
+ extra: {
557
+ fields: [
558
+ {
559
+ key: 'registration_date',
560
+ type: 'date',
561
+ required: true,
562
+ label: { primary: 'Registration date' },
561
563
  },
562
- },
563
- {
564
- key: 'model',
565
- type: 'string',
566
- required: true,
567
- label: {
568
- primary: 'Model',
564
+ {
565
+ key: 'make',
566
+ type: 'string',
567
+ required: true,
568
+ label: {
569
+ primary: 'Make',
570
+ },
569
571
  },
570
- },
571
- ],
572
+ {
573
+ key: 'model',
574
+ type: 'string',
575
+ required: true,
576
+ label: {
577
+ primary: 'Model',
578
+ },
579
+ },
580
+ ],
581
+ },
572
582
  },
573
- },
574
- }}
575
- required
576
- />
577
- <Button type="submit">Submit</Button>
578
- </Form>
583
+ }}
584
+ required
585
+ />
586
+ <Button type="submit">Submit</Button>
587
+ </Form>
588
+ );
579
589
  }
580
590
  ```