@digigov/form 2.0.0-85c27c19 → 2.0.0-aefd0709

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 (314) hide show
  1. package/Field/FieldBase/index.js +1 -0
  2. package/Field/FieldBase.js.map +2 -2
  3. package/Field/FieldBaseContainer/index.js +2 -2
  4. package/Field/FieldBaseContainer.js.map +2 -2
  5. package/Field/FieldConditional/index.js +7 -3
  6. package/Field/FieldConditional.js.map +2 -2
  7. package/Field/index.js +5 -2
  8. package/Field/index.js.map +2 -2
  9. package/Field/types.d.ts +10 -8
  10. package/Field/utils/index.d.ts +1 -0
  11. package/Field/utils/index.js +18 -1
  12. package/Field/utils/index.js.map +2 -2
  13. package/FieldArray/index.d.ts +1 -0
  14. package/FieldArray/index.js +7 -6
  15. package/FieldArray/index.js.map +2 -2
  16. package/FieldObject/index.d.ts +2 -0
  17. package/FieldObject/index.js +9 -5
  18. package/FieldObject/index.js.map +2 -2
  19. package/Fieldset/index.d.ts +1 -1
  20. package/Fieldset/index.js +5 -5
  21. package/Fieldset/index.js.map +2 -2
  22. package/Fieldset/types.d.ts +2 -3
  23. package/FormBuilder/index.d.ts +8 -2
  24. package/FormBuilder/index.js +150 -6
  25. package/FormBuilder/index.js.map +3 -3
  26. package/FormContext.js.map +2 -2
  27. package/MultiplicityField/add-objects/index.js +11 -7
  28. package/MultiplicityField/add-objects.js.map +2 -2
  29. package/MultiplicityField/index.js +16 -12
  30. package/MultiplicityField/index.js.map +2 -2
  31. package/MultiplicityField/types.d.ts +1 -2
  32. package/Questions/Questions/index.js +5 -4
  33. package/Questions/Questions.js.map +2 -2
  34. package/Questions/QuestionsContext.d.ts +0 -1
  35. package/Questions/Step/StepArrayReview.js.map +2 -2
  36. package/Questions/Step/StepContext.d.ts +0 -1
  37. package/Questions/Step/StepTitle/index.js +4 -3
  38. package/Questions/Step/StepTitle.d.ts +1 -1
  39. package/Questions/Step/StepTitle.js.map +2 -2
  40. package/Questions/Step/types.d.ts +0 -1
  41. package/Questions/types.d.ts +0 -1
  42. package/cjs/Field/FieldBase/index.js +1 -0
  43. package/cjs/Field/FieldBase.js.map +2 -2
  44. package/cjs/Field/FieldBaseContainer/index.js +4 -4
  45. package/cjs/Field/FieldBaseContainer.js.map +3 -3
  46. package/cjs/Field/FieldConditional/index.js +7 -3
  47. package/cjs/Field/FieldConditional.js.map +2 -2
  48. package/cjs/Field/index.js +5 -2
  49. package/cjs/Field/index.js.map +2 -2
  50. package/cjs/Field/types.js.map +1 -1
  51. package/cjs/Field/utils/index.js +18 -0
  52. package/cjs/Field/utils/index.js.map +2 -2
  53. package/cjs/FieldArray/index.js +8 -7
  54. package/cjs/FieldArray/index.js.map +3 -3
  55. package/cjs/FieldObject/index.js +10 -6
  56. package/cjs/FieldObject/index.js.map +3 -3
  57. package/cjs/Fieldset/index.js +10 -10
  58. package/cjs/Fieldset/index.js.map +3 -3
  59. package/cjs/Fieldset/types.js.map +1 -1
  60. package/cjs/FormBuilder/index.js +165 -5
  61. package/cjs/FormBuilder/index.js.map +3 -3
  62. package/cjs/FormContext/index.js +2 -2
  63. package/cjs/FormContext.js.map +3 -3
  64. package/cjs/MultiplicityField/add-objects/index.js +15 -11
  65. package/cjs/MultiplicityField/add-objects.js.map +3 -3
  66. package/cjs/MultiplicityField/index.js +15 -16
  67. package/cjs/MultiplicityField/index.js.map +3 -3
  68. package/cjs/MultiplicityField/types.js.map +1 -1
  69. package/cjs/Questions/Questions/index.js +5 -4
  70. package/cjs/Questions/Questions.js.map +2 -2
  71. package/cjs/Questions/Step/StepArrayReview.js.map +2 -2
  72. package/cjs/Questions/Step/StepTitle/index.js +5 -5
  73. package/cjs/Questions/Step/StepTitle.js.map +3 -3
  74. package/cjs/index.js +11 -155
  75. package/cjs/index.js.map +4 -4
  76. package/cjs/inputs/AutoCompleteInput/__stories__/Default/index.js +1 -7
  77. package/cjs/inputs/AutoCompleteInput/__stories__/Default.js.map +2 -2
  78. package/cjs/inputs/AutoCompleteInput/__stories__/Multiple/index.js +1 -8
  79. package/cjs/inputs/AutoCompleteInput/__stories__/Multiple.js.map +2 -2
  80. package/cjs/inputs/AutoCompleteInput/index.js +10 -8
  81. package/cjs/inputs/AutoCompleteInput/index.js.map +3 -3
  82. package/cjs/inputs/Checkboxes/index.js +7 -9
  83. package/cjs/inputs/Checkboxes/index.js.map +3 -3
  84. package/cjs/inputs/DateInput/__stories__/Default/index.js +3 -8
  85. package/cjs/inputs/DateInput/__stories__/Default.js.map +2 -2
  86. package/cjs/inputs/DateInput/index.js +4 -5
  87. package/cjs/inputs/DateInput/index.js.map +3 -3
  88. package/cjs/inputs/FileInput/index.js +8 -9
  89. package/cjs/inputs/FileInput/index.js.map +3 -3
  90. package/cjs/inputs/ImageInput/ImageInput.stories/index.js +4 -4
  91. package/cjs/inputs/ImageInput/ImageInput.stories.js.map +2 -2
  92. package/cjs/inputs/ImageInput/__stories__/MaxSize/index.js +69 -0
  93. package/cjs/inputs/ImageInput/__stories__/MaxSize.js.map +7 -0
  94. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +2 -1
  95. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +2 -2
  96. package/cjs/inputs/ImageInput/index.js +9 -9
  97. package/cjs/inputs/ImageInput/index.js.map +3 -3
  98. package/cjs/inputs/Input/__stories__/LandlineNumber/index.js +1 -0
  99. package/cjs/inputs/Input/__stories__/LandlineNumber.js.map +2 -2
  100. package/cjs/inputs/Input/__stories__/MobilePhone/index.js +1 -0
  101. package/cjs/inputs/Input/__stories__/MobilePhone.js.map +2 -2
  102. package/cjs/inputs/Input/__stories__/PhoneNumber/index.js +1 -0
  103. package/cjs/inputs/Input/__stories__/PhoneNumber.js.map +2 -2
  104. package/cjs/inputs/Input/__stories__/PostalCode/index.js +1 -0
  105. package/cjs/inputs/Input/__stories__/PostalCode.js.map +2 -2
  106. package/cjs/inputs/Input/index.js +19 -6
  107. package/cjs/inputs/Input/index.js.map +3 -3
  108. package/cjs/inputs/Input/inputsInputScenarios.js.map +2 -2
  109. package/cjs/inputs/Label/index.js +3 -3
  110. package/cjs/inputs/Label/index.js.map +3 -3
  111. package/cjs/inputs/OtpInput/index.js.map +2 -2
  112. package/cjs/inputs/Radio/__stories__/Conditional.js.map +2 -2
  113. package/cjs/inputs/Radio/index.js +56 -10
  114. package/cjs/inputs/Radio/index.js.map +3 -3
  115. package/cjs/inputs/Select/index.js +3 -4
  116. package/cjs/inputs/Select/index.js.map +3 -3
  117. package/cjs/inputs/inputsScenarios/index.js +4 -11
  118. package/cjs/inputs/inputsScenarios.js.map +2 -2
  119. package/cjs/lazy/index.js +320 -59
  120. package/cjs/lazy.js.map +2 -2
  121. package/cjs/locales/el.js.map +1 -1
  122. package/cjs/registry/index.js +118 -38
  123. package/cjs/registry.js.map +2 -2
  124. package/cjs/types.js.map +1 -1
  125. package/cjs/utils/index.js +2 -1
  126. package/cjs/utils.js.map +2 -2
  127. package/cjs/validators/index.js +16 -66
  128. package/cjs/validators/index.js.map +3 -3
  129. package/cjs/validators/utils/date/index.js +138 -0
  130. package/cjs/validators/utils/date.js.map +7 -0
  131. package/cjs/validators/utils/file/index.js +1 -1
  132. package/cjs/validators/utils/file.js.map +2 -2
  133. package/cjs/validators/utils/index.js +3 -1
  134. package/cjs/validators/utils/index.js.map +2 -2
  135. package/cjs/validators/utils/phone.js.map +2 -2
  136. package/cjs/validators/utils/postal_code.js.map +1 -1
  137. package/cjs/validators/utils/uuid4.js.map +2 -2
  138. package/index.d.ts +5 -8
  139. package/index.js +9 -152
  140. package/index.js.map +4 -4
  141. package/inputs/AutoCompleteInput/__stories__/Default/index.js +1 -7
  142. package/inputs/AutoCompleteInput/__stories__/Default.js.map +2 -2
  143. package/inputs/AutoCompleteInput/__stories__/Multiple/index.js +1 -8
  144. package/inputs/AutoCompleteInput/__stories__/Multiple.js.map +2 -2
  145. package/inputs/AutoCompleteInput/index.d.ts +1 -1
  146. package/inputs/AutoCompleteInput/index.js +12 -8
  147. package/inputs/AutoCompleteInput/index.js.map +2 -2
  148. package/inputs/Checkboxes/index.d.ts +1 -1
  149. package/inputs/Checkboxes/index.js +8 -6
  150. package/inputs/Checkboxes/index.js.map +2 -2
  151. package/inputs/DateInput/__stories__/Default/index.js +3 -8
  152. package/inputs/DateInput/__stories__/Default.js.map +2 -2
  153. package/inputs/DateInput/index.d.ts +1 -2
  154. package/inputs/DateInput/index.js +6 -4
  155. package/inputs/DateInput/index.js.map +2 -2
  156. package/inputs/FileInput/index.js +6 -7
  157. package/inputs/FileInput/index.js.map +2 -2
  158. package/inputs/ImageInput/ImageInput.stories/index.js +2 -2
  159. package/inputs/ImageInput/ImageInput.stories.d.ts +1 -1
  160. package/inputs/ImageInput/ImageInput.stories.js.map +2 -2
  161. package/inputs/ImageInput/__stories__/MaxSize/index.js +36 -0
  162. package/inputs/ImageInput/__stories__/MaxSize/package.json +6 -0
  163. package/inputs/ImageInput/__stories__/MaxSize.d.ts +3 -0
  164. package/inputs/ImageInput/__stories__/MaxSize.js.map +7 -0
  165. package/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +2 -1
  166. package/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +2 -2
  167. package/inputs/ImageInput/index.js +8 -8
  168. package/inputs/ImageInput/index.js.map +2 -2
  169. package/inputs/Input/__stories__/LandlineNumber/index.js +1 -0
  170. package/inputs/Input/__stories__/LandlineNumber.js.map +2 -2
  171. package/inputs/Input/__stories__/MobilePhone/index.js +1 -0
  172. package/inputs/Input/__stories__/MobilePhone.js.map +2 -2
  173. package/inputs/Input/__stories__/PhoneNumber/index.js +1 -0
  174. package/inputs/Input/__stories__/PhoneNumber.js.map +2 -2
  175. package/inputs/Input/__stories__/PostalCode/index.js +1 -0
  176. package/inputs/Input/__stories__/PostalCode.js.map +2 -2
  177. package/inputs/Input/index.js +17 -4
  178. package/inputs/Input/index.js.map +3 -3
  179. package/inputs/Input/inputsInputScenarios.js.map +2 -2
  180. package/inputs/Label/index.d.ts +0 -2
  181. package/inputs/Label/index.js +2 -2
  182. package/inputs/Label/index.js.map +2 -2
  183. package/inputs/OtpInput/index.js.map +2 -2
  184. package/inputs/Radio/__stories__/Conditional.js.map +2 -2
  185. package/inputs/Radio/index.d.ts +5 -1
  186. package/inputs/Radio/index.js +57 -8
  187. package/inputs/Radio/index.js.map +2 -2
  188. package/inputs/Select/index.d.ts +1 -1
  189. package/inputs/Select/index.js +4 -2
  190. package/inputs/Select/index.js.map +2 -2
  191. package/inputs/inputsScenarios/index.js +4 -11
  192. package/inputs/inputsScenarios.d.ts +0 -42
  193. package/inputs/inputsScenarios.js.map +2 -2
  194. package/lazy/index.js +320 -59
  195. package/lazy.d.ts +17 -10
  196. package/lazy.js.map +2 -2
  197. package/locales/el.js.map +1 -1
  198. package/package.json +4 -4
  199. package/registry/index.js +118 -38
  200. package/registry.d.ts +1 -0
  201. package/registry.js.map +2 -2
  202. package/src/Field/FieldBase.tsx +1 -0
  203. package/src/Field/FieldBaseContainer.tsx +2 -2
  204. package/src/Field/FieldConditional.tsx +4 -0
  205. package/src/Field/index.tsx +4 -1
  206. package/src/Field/types.tsx +10 -8
  207. package/src/Field/utils/index.ts +18 -1
  208. package/src/FieldArray/index.test.tsx +14 -13
  209. package/src/FieldArray/index.tsx +9 -6
  210. package/src/FieldObject/index.tsx +8 -2
  211. package/src/Fieldset/index.tsx +5 -5
  212. package/src/Fieldset/types.tsx +2 -2
  213. package/src/FormBuilder/{FormBuilder.mdx → doc.mdx} +20 -33
  214. package/src/FormBuilder/index.test.tsx +11 -10
  215. package/src/FormBuilder/index.tsx +178 -7
  216. package/src/FormBuilder/scenarios.test.tsx +2 -2
  217. package/src/FormContext.tsx +1 -2
  218. package/src/MultiplicityField/add-objects.tsx +10 -8
  219. package/src/MultiplicityField/{MultiplicityField.mdx → doc.mdx} +12 -16
  220. package/src/MultiplicityField/index.test.tsx +26 -25
  221. package/src/MultiplicityField/index.tsx +15 -12
  222. package/src/MultiplicityField/types.ts +1 -2
  223. package/src/Questions/Questions.tsx +4 -4
  224. package/src/Questions/Step/StepArrayReview.tsx +1 -1
  225. package/src/Questions/Step/StepTitle.tsx +4 -3
  226. package/src/Questions/__snapshots__/index.spec.tsx.snap +8 -4
  227. package/src/Questions/{index.mdx → doc.mdx} +9 -12
  228. package/src/Questions/index.spec.tsx +6 -2
  229. package/src/Questions/index.test.tsx +11 -10
  230. package/src/create-simple-form.mdx +2 -6
  231. package/src/{index.mdx → doc.mdx} +4 -8
  232. package/src/index.ts +6 -0
  233. package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +2 -10
  234. package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +1 -8
  235. package/src/inputs/AutoCompleteInput/{index.mdx → doc.mdx} +2 -13
  236. package/src/inputs/AutoCompleteInput/index.test.tsx +14 -13
  237. package/src/inputs/AutoCompleteInput/index.tsx +36 -31
  238. package/src/inputs/Checkboxes/{index.mdx → doc.mdx} +5 -15
  239. package/src/inputs/Checkboxes/index.test.tsx +17 -16
  240. package/src/inputs/Checkboxes/index.tsx +10 -8
  241. package/src/inputs/DateInput/__stories__/Default.tsx +7 -12
  242. package/src/inputs/DateInput/{index.mdx → doc.mdx} +1 -8
  243. package/src/inputs/DateInput/index.test.tsx +11 -10
  244. package/src/inputs/DateInput/index.tsx +6 -4
  245. package/src/inputs/FileInput/{index.mdx → doc.mdx} +1 -5
  246. package/src/inputs/FileInput/index.test.tsx +11 -10
  247. package/src/inputs/FileInput/index.tsx +7 -8
  248. package/src/inputs/ImageInput/ImageInput.stories.js +1 -1
  249. package/src/inputs/ImageInput/__stories__/MaxSize.tsx +37 -0
  250. package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +2 -0
  251. package/src/inputs/ImageInput/doc.mdx +23 -0
  252. package/src/inputs/ImageInput/index.test.tsx +21 -16
  253. package/src/inputs/ImageInput/index.tsx +10 -15
  254. package/src/inputs/Input/__stories__/LandlineNumber.tsx +2 -1
  255. package/src/inputs/Input/__stories__/MobilePhone.tsx +1 -0
  256. package/src/inputs/Input/__stories__/PhoneNumber.tsx +1 -0
  257. package/src/inputs/Input/__stories__/PostalCode.tsx +1 -0
  258. package/src/inputs/Input/doc.mdx +56 -0
  259. package/src/inputs/Input/index.test.tsx +38 -37
  260. package/src/inputs/Input/index.tsx +32 -29
  261. package/src/inputs/Input/inputsInputScenarios.ts +244 -245
  262. package/src/inputs/Label/doc.mdx +14 -0
  263. package/src/inputs/Label/index.test.tsx +11 -10
  264. package/src/inputs/Label/index.tsx +2 -6
  265. package/src/inputs/OtpInput/{index.mdx → doc.mdx} +1 -8
  266. package/src/inputs/OtpInput/index.test.tsx +11 -10
  267. package/src/inputs/OtpInput/index.tsx +2 -1
  268. package/src/inputs/Radio/__stories__/Conditional.tsx +2 -1
  269. package/src/inputs/Radio/{index.mdx → doc.mdx} +5 -15
  270. package/src/inputs/Radio/index.test.tsx +17 -16
  271. package/src/inputs/Radio/index.tsx +76 -10
  272. package/src/inputs/Select/{index.mdx → doc.mdx} +1 -5
  273. package/src/inputs/Select/index.test.tsx +11 -10
  274. package/src/inputs/Select/index.tsx +5 -3
  275. package/src/inputs/inputsScenarios.ts +174 -181
  276. package/src/installation.mdx +2 -5
  277. package/src/lazy.js +322 -62
  278. package/src/locales/el.ts +1 -1
  279. package/src/registry.js +121 -45
  280. package/src/types.tsx +3 -2
  281. package/src/utils.ts +2 -2
  282. package/src/validators/index.ts +33 -71
  283. package/src/validators/utils/date.ts +107 -0
  284. package/src/validators/utils/file.ts +5 -3
  285. package/src/validators/utils/index.ts +1 -0
  286. package/src/validators/utils/phone.ts +1 -1
  287. package/src/validators/utils/postal_code.ts +1 -1
  288. package/src/validators/utils/uuid4.ts +2 -1
  289. package/src/validators/validators.spec.ts +3 -3
  290. package/types.d.ts +3 -3
  291. package/types.js.map +1 -1
  292. package/utils/index.js +2 -1
  293. package/utils.js.map +2 -2
  294. package/validators/index.js +20 -67
  295. package/validators/index.js.map +2 -2
  296. package/validators/utils/date/index.js +103 -0
  297. package/validators/utils/date/package.json +6 -0
  298. package/validators/utils/date.d.ts +9 -0
  299. package/validators/utils/date.js.map +7 -0
  300. package/validators/utils/file/index.js +1 -1
  301. package/validators/utils/file.js.map +2 -2
  302. package/validators/utils/index.d.ts +1 -0
  303. package/validators/utils/index.js +1 -0
  304. package/validators/utils/index.js.map +2 -2
  305. package/validators/utils/phone.d.ts +1 -1
  306. package/validators/utils/phone.js.map +2 -2
  307. package/validators/utils/postal_code.d.ts +1 -1
  308. package/validators/utils/postal_code.js.map +1 -1
  309. package/validators/utils/uuid4.js.map +2 -2
  310. package/src/index.tsx +0 -178
  311. package/src/inputs/ImageInput/index.mdx +0 -19
  312. package/src/inputs/Input/index.mdx +0 -95
  313. package/src/inputs/Label/index.mdx +0 -0
  314. /package/src/Field/{index.mdx → doc.mdx} +0 -0
@@ -1,4 +1,3 @@
1
- /* eslint-disable react/prop-types */
2
1
  import React, { useEffect, useMemo } from 'react';
3
2
  import {
4
3
  ErrorOption,
@@ -14,16 +13,15 @@ import {
14
13
  } from '@digigov/form/Field/utils';
15
14
  import { calculateField } from '@digigov/form/Field/utils/calculateField';
16
15
  import { useField } from '@digigov/form/Field/utils/useField';
17
-
18
- import FieldObject from '@digigov/form/FieldObject';
16
+ import { FieldObject } from '@digigov/form/FieldObject';
17
+ import { Fieldset } from '@digigov/form/Fieldset';
19
18
  import type {
20
19
  MultiplicityProps,
21
20
  StashedObject,
22
21
  } from '@digigov/form/MultiplicityField/types';
23
22
  import { FieldSpec } from '@digigov/form/types';
24
- import Fieldset from '@digigov/react-core/Fieldset';
25
- import RadioConditional from '@digigov/react-core/RadioConditional';
26
- import Button from '@digigov/ui/form/Button';
23
+ import { Button } from '@digigov/ui/form/Button';
24
+ import { RadioConditional } from '@digigov/ui/form/RadioContainer';
27
25
 
28
26
  export interface AddObjectsProps
29
27
  extends Omit<MultiplicityProps, 'key' | 'component'> {
@@ -51,6 +49,7 @@ export const AddObjects: React.FC<AddObjectsProps> = ({
51
49
  getValues,
52
50
  onStash,
53
51
  error,
52
+ Field,
54
53
  }) => {
55
54
  const currentIndex = fields.length > 0 ? fields.length - 1 : fields.length;
56
55
  const currentName = `${name}.${currentIndex}`;
@@ -106,8 +105,10 @@ export const AddObjects: React.FC<AddObjectsProps> = ({
106
105
  (f) => `${currentName}.${f.key}`
107
106
  );
108
107
  const result = await trigger(nestedFields);
109
- result && setValue('needs-more', '');
110
- result && onStash(getValues(currentName));
108
+ if (result) {
109
+ setValue('needs-more', '');
110
+ onStash(getValues(currentName));
111
+ }
111
112
  }}
112
113
  >
113
114
  {extra?.label.object.add}
@@ -186,6 +187,7 @@ export const AddObjects: React.FC<AddObjectsProps> = ({
186
187
  control={control}
187
188
  register={register}
188
189
  reset={reset}
190
+ Field={Field}
189
191
  error={
190
192
  extra?.max - stashedObjects.length === 0 ||
191
193
  extra?.length - stashedObjects.length === 0
@@ -3,13 +3,9 @@ id: ask-users-recursive
3
3
  title: Ask users for recursive data
4
4
  ---
5
5
 
6
- import LeadText from '@site/src/components/LeadText';
7
-
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>
6
+ Multiplicity & FieldArray fields allow users to input data described by a
7
+ particular schema for an arbitrary number of times until they are done. It can
8
+ be used to input a fixed, a minimum, and a maximum length of instances.
13
9
 
14
10
  ## What we are trying to achieve
15
11
 
@@ -108,7 +104,7 @@ This field is the most complex component we currently offer, and it uses the
108
104
  react-hook-form under the hood. First, let's take a look at what it looks like, and then we can
109
105
  break down its functionality and how you can use it.
110
106
 
111
- ```jsx live
107
+ ```jsx
112
108
  import React from 'react';
113
109
  import Form, { Field } from '@digigov/form';
114
110
  import Button from '@digigov/ui/form/Button';
@@ -209,7 +205,7 @@ are asking users for information about their vehicles, we can also fill in the `
209
205
  `label.primary`, as well as the `type` and `required`
210
206
  props.
211
207
 
212
- ```jsx
208
+ ```jsx pure
213
209
  <Field
214
210
  key="vehicles"
215
211
  name="vehicles"
@@ -232,7 +228,7 @@ inner form, respectively.
232
228
  Inside the `of` key you can add an `extra` key that will then contain a `fields`
233
229
  key describing the field props for all inputs needed.
234
230
 
235
- ```js
231
+ ```js pure
236
232
  // this will be used as value for the `extra` prop
237
233
  {
238
234
  of: {
@@ -290,7 +286,7 @@ As a result, if you learn how to use one, you can easily use the other, and
290
286
  naturally, you can also change their behaviour by changing a single prop in your
291
287
  React code.
292
288
 
293
- ```jsx
289
+ ```jsx pure
294
290
  <Field
295
291
  key="vehicles"
296
292
  name="vehicles"
@@ -305,7 +301,7 @@ React code.
305
301
  The end result looks very different from Multiplicity at first glance, but you
306
302
  can achieve the same results with both of them.
307
303
 
308
- ```jsx live
304
+ ```jsx
309
305
  import React from 'react';
310
306
  import Form, { Field } from '@digigov/form';
311
307
  import Button from '@digigov/ui/form/Button';
@@ -396,7 +392,7 @@ should expect to need some length validation sooner than later.
396
392
  You can easily validate the exact length of the items added to the multipliticy
397
393
  array, simply by using the `extra.length` prop.
398
394
 
399
- ```jsx
395
+ ```jsx pure
400
396
  <Field
401
397
  extra={{
402
398
  length: 2,
@@ -409,7 +405,7 @@ array, simply by using the `extra.length` prop.
409
405
  The example below will validate this and show all the error messages necessary
410
406
  to make sure that the users understand what is going wrong with the process.
411
407
 
412
- ```jsx live
408
+ ```jsx
413
409
  import React from 'react';
414
410
  import Form, { Field } from '@digigov/form';
415
411
  import Button from '@digigov/ui/form/Button';
@@ -497,7 +493,7 @@ Do not mix and match the exact `length` validation with the `min` or `max`.
497
493
 
498
494
  :::
499
495
 
500
- ```jsx
496
+ ```jsx pure
501
497
  <Field
502
498
  extra={{
503
499
  min: 2,
@@ -511,7 +507,7 @@ Do not mix and match the exact `length` validation with the `min` or `max`.
511
507
  The example below will validate this and show all the error messages necessary
512
508
  to make sure that the users understand what is going wrong with the process.
513
509
 
514
- ```jsx live
510
+ ```jsx
515
511
  import React from 'react';
516
512
  import Form, { Field } from '@digigov/form';
517
513
  import Button from '@digigov/ui/form/Button';
@@ -1,40 +1,41 @@
1
1
  import React from 'react';
2
2
  import { test, expect } from '@playwright/experimental-ct-react';
3
- import TestVariant from '@digigov/ui/utils/TestVariant'
4
3
  import { Default } from '@digigov/form/MultiplicityField/__stories__/Default';
5
4
  import { PreviewDisplay } from '@digigov/form/MultiplicityField/__stories__/PreviewDisplay';
6
5
  import { WithExactLength } from '@digigov/form/MultiplicityField/__stories__/WithExactLength';
7
6
  import { WithMaxLength } from '@digigov/form/MultiplicityField/__stories__/WithMaxLength';
8
7
  import { WithMinAndMaxLength } from '@digigov/form/MultiplicityField/__stories__/WithMinAndMaxLength';
9
8
  import { WithMinLength } from '@digigov/form/MultiplicityField/__stories__/WithMinLength';
9
+ import TestVariant from '@digigov/ui/utils/TestVariant';
10
10
 
11
11
  test('renders the All MultiplicityField variants', async ({ mount, page }) => {
12
12
  await mount(
13
-
14
- <div>
15
- <TestVariant title="Default">
16
- <Default />
17
- </TestVariant>
18
- <TestVariant title="PreviewDisplay">
19
- <PreviewDisplay />
20
- </TestVariant>
21
- <TestVariant title="WithExactLength">
22
- <WithExactLength />
23
- </TestVariant>
24
- <TestVariant title="WithMaxLength">
25
- <WithMaxLength />
26
- </TestVariant>
27
- <TestVariant title="WithMinAndMaxLength">
28
- <WithMinAndMaxLength />
29
- </TestVariant>
30
- <TestVariant title="WithMinLength">
31
- <WithMinLength />
32
- </TestVariant>
33
- </div>
34
- )
13
+ <div>
14
+ <TestVariant title="Default">
15
+ <Default />
16
+ </TestVariant>
17
+ <TestVariant title="PreviewDisplay">
18
+ <PreviewDisplay />
19
+ </TestVariant>
20
+ <TestVariant title="WithExactLength">
21
+ <WithExactLength />
22
+ </TestVariant>
23
+ <TestVariant title="WithMaxLength">
24
+ <WithMaxLength />
25
+ </TestVariant>
26
+ <TestVariant title="WithMinAndMaxLength">
27
+ <WithMinAndMaxLength />
28
+ </TestVariant>
29
+ <TestVariant title="WithMinLength">
30
+ <WithMinLength />
31
+ </TestVariant>
32
+ </div>
33
+ );
35
34
  await page.evaluate(() => document.fonts.ready);
36
35
 
37
- const screenshot = await page.screenshot({ fullPage: true, animations: 'disabled' });
36
+ const screenshot = await page.screenshot({
37
+ fullPage: true,
38
+ animations: 'disabled',
39
+ });
38
40
  expect(screenshot).toMatchSnapshot();
39
41
  });
40
-
@@ -1,19 +1,20 @@
1
1
  import React, { useState } from 'react';
2
2
  import { useFieldArray, UseFormReturn } from 'react-hook-form';
3
- import FieldContainer from '@digigov/form/Field/FieldBaseContainer';
4
-
5
- import FieldObject from '@digigov/form/FieldObject';
6
- import AddObjects from '@digigov/form/MultiplicityField/add-objects';
3
+ import { FieldBaseContainer } from '@digigov/form/Field/FieldBaseContainer';
4
+ import { FieldObject } from '@digigov/form/FieldObject';
5
+ import { AddObjects } from '@digigov/form/MultiplicityField/add-objects';
7
6
  import {
8
7
  MultiplicityProps,
9
8
  StashedObject,
10
9
  } from '@digigov/form/MultiplicityField/types';
11
- import { Button } from '@digigov/react-core/Button';
12
- import { Card } from '@digigov/react-core/Card';
13
- import { CardAction } from '@digigov/react-core/CardAction';
14
- import { CardContent } from '@digigov/react-core/CardContent';
15
- import { CardHeading } from '@digigov/react-core/CardHeading';
16
- import { Heading } from '@digigov/react-core/Heading';
10
+ import {
11
+ Card,
12
+ CardHeading,
13
+ CardContent,
14
+ CardAction,
15
+ } from '@digigov/ui/content/Card';
16
+ import { Button } from '@digigov/ui/form/Button';
17
+ import { Heading } from '@digigov/ui/typography/Heading';
17
18
 
18
19
  // epeidh einai forwardRef to ref mas to dinei xwrista apo ta props
19
20
  export const Multiplicity: React.FC<MultiplicityProps> = ({
@@ -30,6 +31,7 @@ export const Multiplicity: React.FC<MultiplicityProps> = ({
30
31
  setValue,
31
32
  getValues,
32
33
  unregister,
34
+ Field,
33
35
  }) => {
34
36
  const { fields, append, remove } = useFieldArray({
35
37
  control,
@@ -47,7 +49,7 @@ export const Multiplicity: React.FC<MultiplicityProps> = ({
47
49
  setStashedObjects(newStashedObjects);
48
50
  };
49
51
  return (
50
- <FieldContainer
52
+ <FieldBaseContainer
51
53
  label={label}
52
54
  layout={layout}
53
55
  error={
@@ -96,8 +98,9 @@ export const Multiplicity: React.FC<MultiplicityProps> = ({
96
98
  unregister={unregister}
97
99
  trigger={trigger}
98
100
  clearErrors={clearErrors}
101
+ Field={Field}
99
102
  />
100
- </FieldContainer>
103
+ </FieldBaseContainer>
101
104
  );
102
105
  };
103
106
 
@@ -1,6 +1,5 @@
1
1
  import { ErrorOption, UseFormReturn } from 'react-hook-form';
2
- import { FieldSpec } from '@digigov/form/Field/types';
3
- import { ControlledFieldProps } from '@digigov/form/Field/types';
2
+ import { FieldSpec, ControlledFieldProps } from '@digigov/form/Field/types';
4
3
 
5
4
  export interface MultiplicityProps
6
5
  extends Omit<ControlledFieldProps, 'value' | 'onChange' | 'error' | 'extra'> {
@@ -31,7 +31,7 @@ export const Questions: React.FC<QuestionsInterface> = ({
31
31
  useEffect(() => {
32
32
  if (forceStepName !== currentStep.name) {
33
33
  const forceStep = steps.find(({ name }) => name === forceStepName);
34
- forceStep && setCurrentStep(forceStep);
34
+ if (forceStep) setCurrentStep(forceStep);
35
35
  }
36
36
  }, [forceStepName]);
37
37
  const localData =
@@ -42,16 +42,16 @@ export const Questions: React.FC<QuestionsInterface> = ({
42
42
  const submitStep = (stepName, stepData): void => {
43
43
  data[stepName] = stepData;
44
44
  if (localDraft) {
45
- isBrowser &&
45
+ if (isBrowser)
46
46
  window.localStorage.setItem(`questions-${name}`, JSON.stringify(data));
47
47
  }
48
48
  if (onChange) {
49
- onChange && onChange(data);
49
+ onChange(data);
50
50
  }
51
51
  setData(data);
52
52
  const nextStep = getNextStep(currentStep, steps, data);
53
53
  if (nextStep) {
54
- onActiveStep && onActiveStep(nextStep);
54
+ if (onActiveStep) onActiveStep(nextStep);
55
55
  setCurrentStep(nextStep);
56
56
  } else {
57
57
  onSubmit(data);
@@ -37,7 +37,7 @@ export const StepArrayReview: React.FC<StepArrayReviewInterface> = (props) => {
37
37
  </PageTitleContainer>
38
38
  <SummaryList>
39
39
  {props.array.map(
40
- (item: { [x: string]: React.ReactNode }, idx: number) => (
40
+ (item: Record<string, React.ReactNode>, idx: number) => (
41
41
  <SummaryListItem key={idx}>
42
42
  <SummaryListItemKey>
43
43
  {t(primaryField.label.primary)}
@@ -1,12 +1,13 @@
1
1
  import React, { useContext } from 'react';
2
2
  import { StepContext } from '@digigov/form/Questions/Step/StepContext';
3
- import Heading, { HeadingProps } from '@digigov/react-core/Heading';
4
- import HeadingCaption from '@digigov/react-core/HeadingCaption';
5
- import PageTitleContainer, {
3
+ import {
4
+ PageTitleContainer,
6
5
  PageTitleCaption,
7
6
  } from '@digigov/ui/app/PageTitleContainer';
8
7
  import { useTranslation } from '@digigov/ui/i18n';
9
8
  import { BackLink } from '@digigov/ui/navigation/BackLink';
9
+ import { Heading, HeadingProps } from '@digigov/ui/typography/Heading';
10
+ import { HeadingCaption } from '@digigov/ui/typography/HeadingCaption';
10
11
 
11
12
  export interface StepTitleInterface {
12
13
  title?: string;
@@ -1,19 +1,22 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
3
  exports[`renders the Questions 1`] = `
4
4
  <body>
5
5
  <div>
6
6
  <a
7
- class="ds-back-link ds-print-hidden"
7
+ class="ds-print-hidden ds-back-link"
8
8
  tabindex="0"
9
9
  >
10
10
  <svg
11
11
  aria-hidden="true"
12
+ as="svg"
12
13
  class="ds-svg-icon--caret ds-svg-icon"
13
14
  focusable="false"
14
15
  viewBox="0 0 24 24"
15
16
  >
16
17
  <path
18
+ as="path"
19
+ class=""
17
20
  d="M18,22V2L6,12L18,22z"
18
21
  />
19
22
  </svg>
@@ -48,7 +51,7 @@ exports[`renders the Questions 1`] = `
48
51
  class="ds-label"
49
52
  >
50
53
  <span
51
- class="ds-heading-sm"
54
+ class="ds-label__title ds-label__title--sm"
52
55
  >
53
56
  name.field.primary
54
57
  </span>
@@ -60,13 +63,14 @@ exports[`renders the Questions 1`] = `
60
63
  <input
61
64
  aria-required="true"
62
65
  class="ds-input"
66
+ data-type="string"
63
67
  name="name"
64
68
  type="text"
65
69
  />
66
70
  </label>
67
71
  </div>
68
72
  <button
69
- class="ds-btn-primary ds-btn ds-print-hidden"
73
+ class="ds-print-hidden ds-btn ds-btn-primary"
70
74
  type="submit"
71
75
  >
72
76
  Συνέχεια
@@ -14,14 +14,11 @@ import {
14
14
  TableDataCell,
15
15
  } from '@digigov/react-core';
16
16
 
17
- import LeadText from '@site/src/components/LeadText';
18
17
 
19
- <LeadText>
20
- Question pages are used to ask users meaningful questions needed by your
21
- GOV.GR service, or even gather data about their persona or their application
22
- status. Use step questions to make bigger forms less scary and easier to fill
23
- out.
24
- </LeadText>
18
+ Question pages are used to ask users meaningful questions needed by your
19
+ GOV.GR service, or even gather data about their persona or their application
20
+ status. Use step questions to make bigger forms less scary and easier to fill
21
+ out.
25
22
 
26
23
  ## Introduction to Question pages
27
24
 
@@ -41,7 +38,7 @@ Even if users struggle through to the end of a form and answer honestly, if it
41
38
  more work than they expected, they’ll be annoyed about it. That's the exact
42
39
  opposite of our goals of making concise, easy-to-use services.
43
40
 
44
- ```jsx live
41
+ ```jsx
45
42
  import React from 'react';
46
43
  import Questions, { Step, StepForm, StepTitle } from '@digigov/form/Questions';
47
44
  import { Field } from '@digigov/form';
@@ -159,7 +156,7 @@ its subsequent subcomponents that you customise as needed, like the step title,
159
156
  description or form. You can also add components that are not form-specific,
160
157
  adding paragraphs or other custom components.
161
158
 
162
- ```jsx
159
+ ```jsx pure
163
160
  <Questions name="example" steps={steps} onSubmit={(data) => doSomething(data)}>
164
161
  {/* more steps could be rendered here ... */}
165
162
  <Step name="age">
@@ -184,7 +181,7 @@ object. The most basic properties are the following:
184
181
  - `fields` - an array that describes each input field that will be rendered in
185
182
  the `StepForm`. Each fields implements the `FieldSpec` interface as a JSON object.
186
183
 
187
- ```json title="step-name.json"
184
+ ```json pure title="step-name.json"
188
185
  {
189
186
  "name": "name",
190
187
  "title": "What is your name?",
@@ -209,7 +206,7 @@ basic branching between each step. The `nextStep` property will need to be a
209
206
  function that will take the form state as an argument and will return the key of
210
207
  the next `step`.
211
208
 
212
- ```json title="next-step.json"
209
+ ```json pure title="next-step.json"
213
210
  const steps = [
214
211
  {
215
212
  name: 'age',
@@ -263,7 +260,7 @@ For example, you may use a form to determine if citizens are adults or not, and
263
260
  we want to ask users different questions according to their persona. We can use
264
261
  a branch between the `age` step and the other two steps.
265
262
 
266
- ```jsx live
263
+ ```jsx
267
264
  import React from 'react';
268
265
  import GovGRFooter from '@digigov/ui/govgr/Footer';
269
266
  import Header from '@digigov/ui/app/Header';
@@ -2,8 +2,12 @@ import * as React from 'react';
2
2
  import { render } from '@testing-library/react';
3
3
 
4
4
  import { Field } from '@digigov/form';
5
- import { Step, StepForm, StepQuote, StepTitle } from '@digigov/form/Questions';
6
- import Questions from '@digigov/form/Questions';
5
+ import Questions, {
6
+ Step,
7
+ StepForm,
8
+ StepQuote,
9
+ StepTitle,
10
+ } from '@digigov/form/Questions';
7
11
 
8
12
  const steps = [
9
13
  {
@@ -1,20 +1,21 @@
1
1
  import React from 'react';
2
2
  import { test, expect } from '@playwright/experimental-ct-react';
3
- import TestVariant from '@digigov/ui/utils/TestVariant'
4
3
  import { Default } from '@digigov/form/Questions/__stories__/Default';
4
+ import TestVariant from '@digigov/ui/utils/TestVariant';
5
5
 
6
6
  test('renders the All Questions variants', async ({ mount, page }) => {
7
7
  await mount(
8
-
9
- <div>
10
- <TestVariant title="Default">
11
- <Default />
12
- </TestVariant>
13
- </div>
14
- )
8
+ <div>
9
+ <TestVariant title="Default">
10
+ <Default />
11
+ </TestVariant>
12
+ </div>
13
+ );
15
14
  await page.evaluate(() => document.fonts.ready);
16
15
 
17
- const screenshot = await page.screenshot({ fullPage: true, animations: 'disabled' });
16
+ const screenshot = await page.screenshot({
17
+ fullPage: true,
18
+ animations: 'disabled',
19
+ });
18
20
  expect(screenshot).toMatchSnapshot();
19
21
  });
20
-
@@ -4,12 +4,8 @@ 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';
8
-
9
- <LeadText>
10
- This guide walks through building a simple form page, complete with validation
11
- and data serialisation.
12
- </LeadText>
7
+ This guide walks through building a simple form page, complete with validation
8
+ and data serialisation.
13
9
 
14
10
  ## What we are building
15
11
 
@@ -4,14 +4,10 @@ title: Digigov Form
4
4
  sidebar_label: Introduction to Digigov Form
5
5
  ---
6
6
 
7
- import LeadText from '@site/src/components/LeadText';
8
-
9
- <LeadText>
10
- Digigov Form is an off-the-shelf solution for managing web forms using
11
- Reactjs. It supports flexible and multi-step forms and easy-to-use validation.
12
- This page will guide you through everything you need to create accessible and
13
- dynamic forms that can handle all sorts of user inputs.
14
- </LeadText>
7
+ Digigov Form is an off-the-shelf solution for managing web forms using
8
+ Reactjs. It supports flexible and multi-step forms and easy-to-use validation.
9
+ This page will guide you through everything you need to create accessible and
10
+ dynamic forms that can handle all sorts of user inputs.
15
11
 
16
12
  <img
17
13
  src="/img/form.svg"
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ export { default as Field } from '@digigov/form/Field';
2
+ export { default as Fieldset } from '@digigov/form/Fieldset';
3
+ export * from '@digigov/form/inputs/Label';
4
+ import FormBuilder from '@digigov/form/FormBuilder';
5
+ export * from '@digigov/form/types';
6
+ export default FormBuilder;
@@ -4,13 +4,7 @@ import FormBuilder from '@digigov/form/FormBuilder';
4
4
  import { FieldSpec } from '@digigov/form/types';
5
5
  import Button from '@digigov/ui/form/Button';
6
6
 
7
- const results = [
8
- 'Αμερική',
9
- 'Ασία',
10
- 'Αυστραλία',
11
- 'Αφρική',
12
- 'Ευρώπη',
13
- ];
7
+ const results = ['Αμερική', 'Ασία', 'Αυστραλία', 'Αφρική', 'Ευρώπη'];
14
8
 
15
9
  const fields: FieldSpec[] = [
16
10
  {
@@ -36,7 +30,6 @@ const fields: FieldSpec[] = [
36
30
  const initialValues = {};
37
31
 
38
32
  export const Default = () => (
39
-
40
33
  <FormBuilder
41
34
  fields={fields}
42
35
  onSubmit={(data) => {
@@ -49,6 +42,5 @@ export const Default = () => (
49
42
  ))}
50
43
  <Button type="submit">Submit</Button>
51
44
  </FormBuilder>
52
-
53
45
  );
54
- export default Default;
46
+ export default Default;
@@ -4,13 +4,7 @@ import FormBuilder from '@digigov/form/FormBuilder';
4
4
  import { FieldSpec } from '@digigov/form/types';
5
5
  import Button from '@digigov/ui/form/Button';
6
6
 
7
- const results = [
8
- 'Αμερική',
9
- 'Ασία',
10
- 'Αυστραλία',
11
- 'Αφρική',
12
- 'Ευρώπη',
13
- ];
7
+ const results = ['Αμερική', 'Ασία', 'Αυστραλία', 'Αφρική', 'Ευρώπη'];
14
8
 
15
9
  const fields: FieldSpec[] = [
16
10
  {
@@ -20,7 +14,6 @@ const fields: FieldSpec[] = [
20
14
  type: 'choice:multiple',
21
15
  extra: {
22
16
  component: 'AutoComplete',
23
- multiple: true,
24
17
  options: results.map((r) => {
25
18
  return {
26
19
  label: {
@@ -11,19 +11,8 @@ options as the users type and also let them select an option from the list.
11
11
 
12
12
  ### Default
13
13
 
14
- <Story
15
- packageName="@digigov/form"
16
- component="inputs/AutoCompleteInput"
17
- story="Default.tsx"
18
- />
14
+ <code src="@digigov/form/inputs/AutoCompleteInput/__stories__/Default.tsx" />
19
15
 
20
16
  ### Display multiple values
21
17
 
22
- <Story
23
- packageName="@digigov/form"
24
- component="inputs/AutoCompleteInput"
25
- story="Multiple.tsx"
26
- />
27
-
28
-
29
-
18
+ <code src="@digigov/form/inputs/AutoCompleteInput/__stories__/Multiple.tsx" />