@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.
- package/Field/FieldBase.js +2 -2
- package/Field/FieldBaseContainer.js +8 -8
- package/Field/FieldConditional.js +2 -2
- package/Field/utils.js +6 -6
- package/FieldArray/__stories__/Default.js +2 -2
- package/FieldArray/__stories__/WithExactLength.js +2 -2
- package/FieldArray/index.js +3 -3
- package/FieldObject/index.d.ts +1 -1
- package/FieldObject/index.js +5 -5
- package/Fieldset/FieldsetWithContext.js +4 -4
- package/Fieldset/index.d.ts +1 -1
- package/Fieldset/index.js +2 -2
- package/Fieldset/types.d.ts +2 -2
- package/FormBuilder/FormBuilder.js +5 -5
- package/FormBuilder/FormBuilder.mdx +29 -44
- package/FormBuilder/__stories__/Default.js +2 -2
- package/MultiplicityField/MultiplicityField.mdx +277 -267
- package/MultiplicityField/__stories__/Default.js +2 -2
- package/MultiplicityField/__stories__/PreviewDisplay.js +9 -9
- package/MultiplicityField/__stories__/WithExactLength.js +2 -2
- package/MultiplicityField/__stories__/WithMaxLength.js +2 -2
- package/MultiplicityField/__stories__/WithMinAndMaxLength.js +2 -2
- package/MultiplicityField/__stories__/WithMinLength.js +2 -2
- package/MultiplicityField/add-objects.js +6 -6
- package/MultiplicityField/index.d.ts +2 -2
- package/MultiplicityField/index.js +7 -7
- package/Questions/Questions.js +2 -2
- package/Questions/Step/ReviewStep.js +8 -8
- package/Questions/Step/Step.js +2 -2
- package/Questions/Step/StepArrayReview.js +11 -11
- package/Questions/Step/StepDescription.js +2 -2
- package/Questions/Step/StepForm.d.ts +1 -1
- package/Questions/Step/StepForm.js +6 -6
- package/Questions/Step/StepTitle.d.ts +2 -2
- package/Questions/Step/StepTitle.js +11 -5
- package/Questions/Step/getAddMoreFields.d.ts +1 -1
- package/Questions/__snapshots__/index.spec.tsx.snap +72 -359
- package/Questions/__stories__/Default.js +7 -7
- package/Questions/index.mdx +45 -48
- package/Questions/index.spec.js +2 -2
- package/create-simple-form.mdx +258 -237
- package/es/Field/FieldBase.js +1 -1
- package/es/Field/FieldBaseContainer.js +6 -6
- package/es/Field/FieldConditional.js +1 -1
- package/es/Field/utils.js +5 -5
- package/es/FieldArray/__stories__/Default.js +1 -1
- package/es/FieldArray/__stories__/WithExactLength.js +1 -1
- package/es/FieldArray/index.js +2 -2
- package/es/FieldObject/index.js +3 -3
- package/es/Fieldset/FieldsetWithContext.js +2 -2
- package/es/Fieldset/index.js +1 -1
- package/es/FormBuilder/FormBuilder.js +3 -3
- package/es/FormBuilder/FormBuilder.mdx +29 -44
- package/es/FormBuilder/__stories__/Default.js +1 -1
- package/es/MultiplicityField/MultiplicityField.mdx +277 -267
- package/es/MultiplicityField/__stories__/Default.js +1 -1
- package/es/MultiplicityField/__stories__/PreviewDisplay.js +8 -8
- package/es/MultiplicityField/__stories__/WithExactLength.js +1 -1
- package/es/MultiplicityField/__stories__/WithMaxLength.js +1 -1
- package/es/MultiplicityField/__stories__/WithMinAndMaxLength.js +1 -1
- package/es/MultiplicityField/__stories__/WithMinLength.js +1 -1
- package/es/MultiplicityField/add-objects.js +3 -3
- package/es/MultiplicityField/index.js +5 -5
- package/es/Questions/Questions.js +1 -1
- package/es/Questions/Step/ReviewStep.js +5 -5
- package/es/Questions/Step/Step.js +1 -1
- package/es/Questions/Step/StepArrayReview.js +7 -7
- package/es/Questions/Step/StepDescription.js +1 -1
- package/es/Questions/Step/StepForm.js +5 -5
- package/es/Questions/Step/StepTitle.js +9 -5
- package/es/Questions/__snapshots__/index.spec.tsx.snap +72 -359
- package/es/Questions/__stories__/Default.js +5 -5
- package/es/Questions/index.mdx +45 -48
- package/es/Questions/index.spec.js +1 -1
- package/es/create-simple-form.mdx +258 -237
- package/es/index.mdx +13 -6
- package/es/inputs/AutoComplete/__stories__/Default.js +3 -3
- package/es/inputs/AutoComplete/index.js +1 -1
- package/es/inputs/Checkboxes/__stories__/Conditional.js +1 -1
- package/es/inputs/Checkboxes/__stories__/Default.js +1 -1
- package/es/inputs/Checkboxes/__stories__/WithDivider.js +2 -2
- package/es/inputs/Checkboxes/index.js +3 -3
- package/es/inputs/DateInput/__stories__/Default.js +1 -1
- package/es/inputs/DateInput/index.js +1 -1
- package/es/inputs/FileInput/__stories__/Default.js +1 -1
- package/es/inputs/FileInput/index.js +6 -6
- package/es/inputs/Input/__stories__/AFM.js +1 -1
- package/es/inputs/Input/__stories__/Boolean.js +1 -1
- package/es/inputs/Input/__stories__/Default.js +1 -1
- package/es/inputs/Input/__stories__/IBAN.js +1 -1
- package/es/inputs/Input/__stories__/Integer.js +1 -1
- package/es/inputs/Input/__stories__/MobilePhone.js +1 -1
- package/es/inputs/Input/__stories__/PhoneNumber.js +1 -1
- package/es/inputs/Input/__stories__/PostalCode.js +1 -1
- package/es/inputs/Input/__stories__/TextWithCharacterLimit.js +1 -1
- package/es/inputs/Input/index.js +1 -1
- package/es/inputs/Label/__stories__/Default.js +1 -1
- package/es/inputs/Label/index.js +3 -3
- package/es/inputs/OtpInput/__stories__/Default.js +1 -1
- package/es/inputs/OtpInput/index.js +5 -5
- package/es/inputs/Radio/__stories__/Conditional.js +1 -1
- package/es/inputs/Radio/__stories__/Default.js +1 -1
- package/es/inputs/Radio/__stories__/WithDivider.js +2 -2
- package/es/inputs/Radio/index.js +4 -4
- package/es/inputs/Select/__stories__/Default.js +1 -1
- package/es/installation.mdx +12 -16
- package/es/utils.js +1 -1
- package/es/validators/index.js +2 -2
- package/esm/Field/FieldBase.js +1 -1
- package/esm/Field/FieldBaseContainer.js +6 -6
- package/esm/Field/FieldConditional.js +1 -1
- package/esm/Field/utils.js +5 -5
- package/esm/FieldArray/__stories__/Default.js +1 -1
- package/esm/FieldArray/__stories__/WithExactLength.js +1 -1
- package/esm/FieldArray/index.js +2 -2
- package/esm/FieldObject/index.js +3 -3
- package/esm/Fieldset/FieldsetWithContext.js +2 -2
- package/esm/Fieldset/index.js +1 -1
- package/esm/FormBuilder/FormBuilder.js +3 -3
- package/esm/FormBuilder/FormBuilder.mdx +29 -44
- package/esm/FormBuilder/__stories__/Default.js +1 -1
- package/esm/MultiplicityField/MultiplicityField.mdx +277 -267
- package/esm/MultiplicityField/__stories__/Default.js +1 -1
- package/esm/MultiplicityField/__stories__/PreviewDisplay.js +8 -8
- package/esm/MultiplicityField/__stories__/WithExactLength.js +1 -1
- package/esm/MultiplicityField/__stories__/WithMaxLength.js +1 -1
- package/esm/MultiplicityField/__stories__/WithMinAndMaxLength.js +1 -1
- package/esm/MultiplicityField/__stories__/WithMinLength.js +1 -1
- package/esm/MultiplicityField/add-objects.js +3 -3
- package/esm/MultiplicityField/index.js +5 -5
- package/esm/Questions/Questions.js +1 -1
- package/esm/Questions/Step/ReviewStep.js +5 -5
- package/esm/Questions/Step/Step.js +1 -1
- package/esm/Questions/Step/StepArrayReview.js +7 -7
- package/esm/Questions/Step/StepDescription.js +1 -1
- package/esm/Questions/Step/StepForm.js +5 -5
- package/esm/Questions/Step/StepTitle.js +9 -5
- package/esm/Questions/__snapshots__/index.spec.tsx.snap +72 -359
- package/esm/Questions/__stories__/Default.js +5 -5
- package/esm/Questions/index.mdx +45 -48
- package/esm/Questions/index.spec.js +1 -1
- package/esm/create-simple-form.mdx +258 -237
- package/esm/index.js +1 -1
- package/esm/index.mdx +13 -6
- package/esm/inputs/AutoComplete/__stories__/Default.js +3 -3
- package/esm/inputs/AutoComplete/index.js +1 -1
- package/esm/inputs/Checkboxes/__stories__/Conditional.js +1 -1
- package/esm/inputs/Checkboxes/__stories__/Default.js +1 -1
- package/esm/inputs/Checkboxes/__stories__/WithDivider.js +2 -2
- package/esm/inputs/Checkboxes/index.js +3 -3
- package/esm/inputs/DateInput/__stories__/Default.js +1 -1
- package/esm/inputs/DateInput/index.js +1 -1
- package/esm/inputs/FileInput/__stories__/Default.js +1 -1
- package/esm/inputs/FileInput/index.js +6 -6
- package/esm/inputs/Input/__stories__/AFM.js +1 -1
- package/esm/inputs/Input/__stories__/Boolean.js +1 -1
- package/esm/inputs/Input/__stories__/Default.js +1 -1
- package/esm/inputs/Input/__stories__/IBAN.js +1 -1
- package/esm/inputs/Input/__stories__/Integer.js +1 -1
- package/esm/inputs/Input/__stories__/MobilePhone.js +1 -1
- package/esm/inputs/Input/__stories__/PhoneNumber.js +1 -1
- package/esm/inputs/Input/__stories__/PostalCode.js +1 -1
- package/esm/inputs/Input/__stories__/TextWithCharacterLimit.js +1 -1
- package/esm/inputs/Input/index.js +1 -1
- package/esm/inputs/Label/__stories__/Default.js +1 -1
- package/esm/inputs/Label/index.js +3 -3
- package/esm/inputs/OtpInput/__stories__/Default.js +1 -1
- package/esm/inputs/OtpInput/index.js +5 -5
- package/esm/inputs/Radio/__stories__/Conditional.js +1 -1
- package/esm/inputs/Radio/__stories__/Default.js +1 -1
- package/esm/inputs/Radio/__stories__/WithDivider.js +2 -2
- package/esm/inputs/Radio/index.js +4 -4
- package/esm/inputs/Select/__stories__/Default.js +1 -1
- package/esm/installation.mdx +12 -16
- package/esm/utils.js +1 -1
- package/esm/validators/index.js +2 -2
- package/index.mdx +13 -6
- package/inputs/AutoComplete/__stories__/Default.js +4 -4
- package/inputs/AutoComplete/index.d.ts +2 -2
- package/inputs/AutoComplete/index.js +2 -2
- package/inputs/Checkboxes/__stories__/Conditional.js +2 -2
- package/inputs/Checkboxes/__stories__/Default.js +2 -2
- package/inputs/Checkboxes/__stories__/WithDivider.js +3 -3
- package/inputs/Checkboxes/index.d.ts +1 -1
- package/inputs/Checkboxes/index.js +4 -4
- package/inputs/DateInput/__stories__/Default.js +2 -2
- package/inputs/DateInput/index.js +2 -2
- package/inputs/FileInput/__stories__/Default.js +2 -2
- package/inputs/FileInput/index.js +6 -6
- package/inputs/Input/__stories__/AFM.js +2 -2
- package/inputs/Input/__stories__/Boolean.js +2 -2
- package/inputs/Input/__stories__/Default.js +2 -2
- package/inputs/Input/__stories__/IBAN.js +2 -2
- package/inputs/Input/__stories__/Integer.js +2 -2
- package/inputs/Input/__stories__/MobilePhone.js +2 -2
- package/inputs/Input/__stories__/PhoneNumber.js +2 -2
- package/inputs/Input/__stories__/PostalCode.js +2 -2
- package/inputs/Input/__stories__/TextWithCharacterLimit.js +2 -2
- package/inputs/Input/index.js +1 -1
- package/inputs/Label/__stories__/Default.js +2 -2
- package/inputs/Label/index.js +4 -4
- package/inputs/OtpInput/__stories__/Default.js +2 -2
- package/inputs/OtpInput/index.js +5 -5
- package/inputs/Radio/__stories__/Conditional.js +2 -2
- package/inputs/Radio/__stories__/Default.js +2 -2
- package/inputs/Radio/__stories__/WithDivider.js +3 -3
- package/inputs/Radio/index.d.ts +1 -1
- package/inputs/Radio/index.js +7 -7
- package/inputs/Select/__stories__/Default.js +2 -2
- package/inputs/Select/index.d.ts +1 -1
- package/installation.mdx +12 -16
- package/package.json +5 -5
- package/src/Field/FieldBase.tsx +1 -1
- package/src/Field/FieldBaseContainer.tsx +7 -7
- package/src/Field/FieldConditional.tsx +1 -1
- package/src/Field/index.tsx +1 -1
- package/src/Field/utils.ts +7 -7
- package/src/FieldArray/FieldArray.stories.js +1 -1
- package/src/FieldArray/__stories__/Default.tsx +1 -1
- package/src/FieldArray/__stories__/WithExactLength.tsx +1 -1
- package/src/FieldArray/index.tsx +3 -3
- package/src/FieldObject/index.tsx +6 -6
- package/src/Fieldset/FieldsetWithContext.tsx +3 -3
- package/src/Fieldset/index.tsx +5 -5
- package/src/Fieldset/types.tsx +3 -3
- package/src/FormBuilder/FormBuilder.mdx +29 -44
- package/src/FormBuilder/FormBuilder.stories.js +1 -1
- package/src/FormBuilder/FormBuilder.tsx +4 -4
- package/src/FormBuilder/__stories__/Default.tsx +1 -1
- package/src/MultiplicityField/MultiplicityField.mdx +277 -267
- package/src/MultiplicityField/MultiplicityField.stories.js +1 -1
- package/src/MultiplicityField/__stories__/Default.tsx +1 -1
- package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +18 -18
- package/src/MultiplicityField/__stories__/WithExactLength.tsx +1 -1
- package/src/MultiplicityField/__stories__/WithMaxLength.tsx +1 -1
- package/src/MultiplicityField/__stories__/WithMinAndMaxLength.tsx +1 -1
- package/src/MultiplicityField/__stories__/WithMinLength.tsx +1 -1
- package/src/MultiplicityField/add-objects.tsx +3 -3
- package/src/MultiplicityField/index.tsx +9 -9
- package/src/Questions/Questions.stories.js +1 -1
- package/src/Questions/Questions.tsx +2 -2
- package/src/Questions/Step/ReviewStep.tsx +6 -6
- package/src/Questions/Step/Step.tsx +1 -1
- package/src/Questions/Step/StepArrayReview.tsx +11 -11
- package/src/Questions/Step/StepDescription.tsx +1 -1
- package/src/Questions/Step/StepForm.tsx +6 -6
- package/src/Questions/Step/StepTitle.tsx +19 -17
- package/src/Questions/Step/getAddMoreFields.tsx +1 -1
- package/src/Questions/__snapshots__/index.spec.tsx.snap +72 -359
- package/src/Questions/__stories__/Default.tsx +8 -8
- package/src/Questions/index.mdx +45 -48
- package/src/Questions/index.spec.tsx +1 -1
- package/src/create-simple-form.mdx +258 -237
- package/src/index.mdx +13 -6
- package/src/inputs/AutoComplete/__stories__/Default.tsx +3 -3
- package/src/inputs/AutoComplete/index.tsx +4 -4
- package/src/inputs/Checkboxes/Checkboxes.stories.js +1 -1
- package/src/inputs/Checkboxes/__stories__/Conditional.tsx +2 -2
- package/src/inputs/Checkboxes/__stories__/Default.tsx +1 -1
- package/src/inputs/Checkboxes/__stories__/WithDivider.tsx +2 -2
- package/src/inputs/Checkboxes/index.tsx +4 -4
- package/src/inputs/DateInput/DateInput.stories.js +1 -1
- package/src/inputs/DateInput/__stories__/Default.tsx +1 -1
- package/src/inputs/DateInput/index.tsx +2 -2
- package/src/inputs/FileInput/FileInput.stories.js +1 -1
- package/src/inputs/FileInput/__stories__/Default.tsx +1 -1
- package/src/inputs/FileInput/index.tsx +6 -6
- package/src/inputs/Input/__stories__/AFM.tsx +1 -1
- package/src/inputs/Input/__stories__/Boolean.tsx +1 -1
- package/src/inputs/Input/__stories__/Default.tsx +1 -1
- package/src/inputs/Input/__stories__/IBAN.tsx +1 -1
- package/src/inputs/Input/__stories__/Integer.tsx +1 -1
- package/src/inputs/Input/__stories__/MobilePhone.tsx +1 -1
- package/src/inputs/Input/__stories__/PhoneNumber.tsx +1 -1
- package/src/inputs/Input/__stories__/PostalCode.tsx +1 -1
- package/src/inputs/Input/__stories__/TextWithCharacterLimit.tsx +1 -1
- package/src/inputs/Input/index.tsx +3 -3
- package/src/inputs/Label/Label.stories.js +1 -1
- package/src/inputs/Label/__stories__/Default.tsx +1 -1
- package/src/inputs/Label/index.tsx +4 -4
- package/src/inputs/OtpInput/__stories__/Default.tsx +1 -1
- package/src/inputs/OtpInput/index.tsx +14 -10
- package/src/inputs/Radio/Radio.stories.js +1 -2
- package/src/inputs/Radio/__stories__/Conditional.tsx +3 -3
- package/src/inputs/Radio/__stories__/Default.tsx +1 -1
- package/src/inputs/Radio/__stories__/WithDivider.tsx +2 -2
- package/src/inputs/Radio/index.tsx +6 -6
- package/src/inputs/Select/Select.stories.js +1 -1
- package/src/inputs/Select/__stories__/Default.tsx +1 -1
- package/src/inputs/Select/index.tsx +2 -2
- package/src/installation.mdx +12 -16
- package/src/types.tsx +4 -2
- package/src/utils.ts +1 -1
- package/src/validators/index.ts +10 -10
- package/src/validators/utils/file.ts +1 -1
- package/src/validators/utils/phone.ts +1 -1
- package/src/validators/utils/postal_code.ts +1 -1
- package/types.d.ts +4 -2
- package/validators/index.d.ts +3 -3
- package/validators/index.js +4 -4
- package/validators/utils/file.d.ts +1 -1
- package/validators/utils/phone.d.ts +1 -1
- 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
|
|
6
|
+
import LeadText from '@site/src/components/LeadText';
|
|
7
7
|
|
|
8
|
-
<LeadText>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
length of instances
|
|
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
|
-
|
|
51
|
-
|
|
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/
|
|
114
|
+
import Button from '@digigov/ui/form/Button';
|
|
115
115
|
|
|
116
116
|
export default function SimpleForm() {
|
|
117
|
-
return
|
|
118
|
-
<
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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/
|
|
193
|
+
import Button from '@digigov/ui/form/Button';
|
|
192
194
|
|
|
193
195
|
export default function MultiplicityForm() {
|
|
194
|
-
return
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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:
|
|
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:
|
|
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/
|
|
311
|
+
import Button from '@digigov/ui/form/Button';
|
|
308
312
|
|
|
309
313
|
export default function SimpleForm() {
|
|
310
|
-
return
|
|
311
|
-
<
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
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
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
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/
|
|
415
|
+
import Button from '@digigov/ui/form/Button';
|
|
410
416
|
|
|
411
417
|
export default function SimpleForm() {
|
|
412
|
-
return
|
|
413
|
-
<
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
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
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
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
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
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
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
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
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
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/
|
|
517
|
+
import Button from '@digigov/ui/form/Button';
|
|
510
518
|
|
|
511
519
|
export default function SimpleForm() {
|
|
512
|
-
return
|
|
513
|
-
<
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
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
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
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
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
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
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
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
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
583
|
+
}}
|
|
584
|
+
required
|
|
585
|
+
/>
|
|
586
|
+
<Button type="submit">Submit</Button>
|
|
587
|
+
</Form>
|
|
588
|
+
);
|
|
579
589
|
}
|
|
580
590
|
```
|