@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.
- package/Field/FieldBase/index.js +1 -0
- package/Field/FieldBase.js.map +2 -2
- package/Field/FieldBaseContainer/index.js +2 -2
- package/Field/FieldBaseContainer.js.map +2 -2
- package/Field/FieldConditional/index.js +7 -3
- package/Field/FieldConditional.js.map +2 -2
- package/Field/index.js +5 -2
- package/Field/index.js.map +2 -2
- package/Field/types.d.ts +10 -8
- package/Field/utils/index.d.ts +1 -0
- package/Field/utils/index.js +18 -1
- package/Field/utils/index.js.map +2 -2
- package/FieldArray/index.d.ts +1 -0
- package/FieldArray/index.js +7 -6
- package/FieldArray/index.js.map +2 -2
- package/FieldObject/index.d.ts +2 -0
- package/FieldObject/index.js +9 -5
- package/FieldObject/index.js.map +2 -2
- package/Fieldset/index.d.ts +1 -1
- package/Fieldset/index.js +5 -5
- package/Fieldset/index.js.map +2 -2
- package/Fieldset/types.d.ts +2 -3
- package/FormBuilder/index.d.ts +8 -2
- package/FormBuilder/index.js +150 -6
- package/FormBuilder/index.js.map +3 -3
- package/FormContext.js.map +2 -2
- package/MultiplicityField/add-objects/index.js +11 -7
- package/MultiplicityField/add-objects.js.map +2 -2
- package/MultiplicityField/index.js +16 -12
- package/MultiplicityField/index.js.map +2 -2
- package/MultiplicityField/types.d.ts +1 -2
- package/Questions/Questions/index.js +5 -4
- package/Questions/Questions.js.map +2 -2
- package/Questions/QuestionsContext.d.ts +0 -1
- package/Questions/Step/StepArrayReview.js.map +2 -2
- package/Questions/Step/StepContext.d.ts +0 -1
- package/Questions/Step/StepTitle/index.js +4 -3
- package/Questions/Step/StepTitle.d.ts +1 -1
- package/Questions/Step/StepTitle.js.map +2 -2
- package/Questions/Step/types.d.ts +0 -1
- package/Questions/types.d.ts +0 -1
- package/cjs/Field/FieldBase/index.js +1 -0
- package/cjs/Field/FieldBase.js.map +2 -2
- package/cjs/Field/FieldBaseContainer/index.js +4 -4
- package/cjs/Field/FieldBaseContainer.js.map +3 -3
- package/cjs/Field/FieldConditional/index.js +7 -3
- package/cjs/Field/FieldConditional.js.map +2 -2
- package/cjs/Field/index.js +5 -2
- package/cjs/Field/index.js.map +2 -2
- package/cjs/Field/types.js.map +1 -1
- package/cjs/Field/utils/index.js +18 -0
- package/cjs/Field/utils/index.js.map +2 -2
- package/cjs/FieldArray/index.js +8 -7
- package/cjs/FieldArray/index.js.map +3 -3
- package/cjs/FieldObject/index.js +10 -6
- package/cjs/FieldObject/index.js.map +3 -3
- package/cjs/Fieldset/index.js +10 -10
- package/cjs/Fieldset/index.js.map +3 -3
- package/cjs/Fieldset/types.js.map +1 -1
- package/cjs/FormBuilder/index.js +165 -5
- package/cjs/FormBuilder/index.js.map +3 -3
- package/cjs/FormContext/index.js +2 -2
- package/cjs/FormContext.js.map +3 -3
- package/cjs/MultiplicityField/add-objects/index.js +15 -11
- package/cjs/MultiplicityField/add-objects.js.map +3 -3
- package/cjs/MultiplicityField/index.js +15 -16
- package/cjs/MultiplicityField/index.js.map +3 -3
- package/cjs/MultiplicityField/types.js.map +1 -1
- package/cjs/Questions/Questions/index.js +5 -4
- package/cjs/Questions/Questions.js.map +2 -2
- package/cjs/Questions/Step/StepArrayReview.js.map +2 -2
- package/cjs/Questions/Step/StepTitle/index.js +5 -5
- package/cjs/Questions/Step/StepTitle.js.map +3 -3
- package/cjs/index.js +11 -155
- package/cjs/index.js.map +4 -4
- package/cjs/inputs/AutoCompleteInput/__stories__/Default/index.js +1 -7
- package/cjs/inputs/AutoCompleteInput/__stories__/Default.js.map +2 -2
- package/cjs/inputs/AutoCompleteInput/__stories__/Multiple/index.js +1 -8
- package/cjs/inputs/AutoCompleteInput/__stories__/Multiple.js.map +2 -2
- package/cjs/inputs/AutoCompleteInput/index.js +10 -8
- package/cjs/inputs/AutoCompleteInput/index.js.map +3 -3
- package/cjs/inputs/Checkboxes/index.js +7 -9
- package/cjs/inputs/Checkboxes/index.js.map +3 -3
- package/cjs/inputs/DateInput/__stories__/Default/index.js +3 -8
- package/cjs/inputs/DateInput/__stories__/Default.js.map +2 -2
- package/cjs/inputs/DateInput/index.js +4 -5
- package/cjs/inputs/DateInput/index.js.map +3 -3
- package/cjs/inputs/FileInput/index.js +8 -9
- package/cjs/inputs/FileInput/index.js.map +3 -3
- package/cjs/inputs/ImageInput/ImageInput.stories/index.js +4 -4
- package/cjs/inputs/ImageInput/ImageInput.stories.js.map +2 -2
- package/cjs/inputs/ImageInput/__stories__/MaxSize/index.js +69 -0
- package/cjs/inputs/ImageInput/__stories__/MaxSize.js.map +7 -0
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +2 -1
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +2 -2
- package/cjs/inputs/ImageInput/index.js +9 -9
- package/cjs/inputs/ImageInput/index.js.map +3 -3
- package/cjs/inputs/Input/__stories__/LandlineNumber/index.js +1 -0
- package/cjs/inputs/Input/__stories__/LandlineNumber.js.map +2 -2
- package/cjs/inputs/Input/__stories__/MobilePhone/index.js +1 -0
- package/cjs/inputs/Input/__stories__/MobilePhone.js.map +2 -2
- package/cjs/inputs/Input/__stories__/PhoneNumber/index.js +1 -0
- package/cjs/inputs/Input/__stories__/PhoneNumber.js.map +2 -2
- package/cjs/inputs/Input/__stories__/PostalCode/index.js +1 -0
- package/cjs/inputs/Input/__stories__/PostalCode.js.map +2 -2
- package/cjs/inputs/Input/index.js +19 -6
- package/cjs/inputs/Input/index.js.map +3 -3
- package/cjs/inputs/Input/inputsInputScenarios.js.map +2 -2
- package/cjs/inputs/Label/index.js +3 -3
- package/cjs/inputs/Label/index.js.map +3 -3
- package/cjs/inputs/OtpInput/index.js.map +2 -2
- package/cjs/inputs/Radio/__stories__/Conditional.js.map +2 -2
- package/cjs/inputs/Radio/index.js +56 -10
- package/cjs/inputs/Radio/index.js.map +3 -3
- package/cjs/inputs/Select/index.js +3 -4
- package/cjs/inputs/Select/index.js.map +3 -3
- package/cjs/inputs/inputsScenarios/index.js +4 -11
- package/cjs/inputs/inputsScenarios.js.map +2 -2
- package/cjs/lazy/index.js +320 -59
- package/cjs/lazy.js.map +2 -2
- package/cjs/locales/el.js.map +1 -1
- package/cjs/registry/index.js +118 -38
- package/cjs/registry.js.map +2 -2
- package/cjs/types.js.map +1 -1
- package/cjs/utils/index.js +2 -1
- package/cjs/utils.js.map +2 -2
- package/cjs/validators/index.js +16 -66
- package/cjs/validators/index.js.map +3 -3
- package/cjs/validators/utils/date/index.js +138 -0
- package/cjs/validators/utils/date.js.map +7 -0
- package/cjs/validators/utils/file/index.js +1 -1
- package/cjs/validators/utils/file.js.map +2 -2
- package/cjs/validators/utils/index.js +3 -1
- package/cjs/validators/utils/index.js.map +2 -2
- package/cjs/validators/utils/phone.js.map +2 -2
- package/cjs/validators/utils/postal_code.js.map +1 -1
- package/cjs/validators/utils/uuid4.js.map +2 -2
- package/index.d.ts +5 -8
- package/index.js +9 -152
- package/index.js.map +4 -4
- package/inputs/AutoCompleteInput/__stories__/Default/index.js +1 -7
- package/inputs/AutoCompleteInput/__stories__/Default.js.map +2 -2
- package/inputs/AutoCompleteInput/__stories__/Multiple/index.js +1 -8
- package/inputs/AutoCompleteInput/__stories__/Multiple.js.map +2 -2
- package/inputs/AutoCompleteInput/index.d.ts +1 -1
- package/inputs/AutoCompleteInput/index.js +12 -8
- package/inputs/AutoCompleteInput/index.js.map +2 -2
- package/inputs/Checkboxes/index.d.ts +1 -1
- package/inputs/Checkboxes/index.js +8 -6
- package/inputs/Checkboxes/index.js.map +2 -2
- package/inputs/DateInput/__stories__/Default/index.js +3 -8
- package/inputs/DateInput/__stories__/Default.js.map +2 -2
- package/inputs/DateInput/index.d.ts +1 -2
- package/inputs/DateInput/index.js +6 -4
- package/inputs/DateInput/index.js.map +2 -2
- package/inputs/FileInput/index.js +6 -7
- package/inputs/FileInput/index.js.map +2 -2
- package/inputs/ImageInput/ImageInput.stories/index.js +2 -2
- package/inputs/ImageInput/ImageInput.stories.d.ts +1 -1
- package/inputs/ImageInput/ImageInput.stories.js.map +2 -2
- package/inputs/ImageInput/__stories__/MaxSize/index.js +36 -0
- package/inputs/ImageInput/__stories__/MaxSize/package.json +6 -0
- package/inputs/ImageInput/__stories__/MaxSize.d.ts +3 -0
- package/inputs/ImageInput/__stories__/MaxSize.js.map +7 -0
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +2 -1
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +2 -2
- package/inputs/ImageInput/index.js +8 -8
- package/inputs/ImageInput/index.js.map +2 -2
- package/inputs/Input/__stories__/LandlineNumber/index.js +1 -0
- package/inputs/Input/__stories__/LandlineNumber.js.map +2 -2
- package/inputs/Input/__stories__/MobilePhone/index.js +1 -0
- package/inputs/Input/__stories__/MobilePhone.js.map +2 -2
- package/inputs/Input/__stories__/PhoneNumber/index.js +1 -0
- package/inputs/Input/__stories__/PhoneNumber.js.map +2 -2
- package/inputs/Input/__stories__/PostalCode/index.js +1 -0
- package/inputs/Input/__stories__/PostalCode.js.map +2 -2
- package/inputs/Input/index.js +17 -4
- package/inputs/Input/index.js.map +3 -3
- package/inputs/Input/inputsInputScenarios.js.map +2 -2
- package/inputs/Label/index.d.ts +0 -2
- package/inputs/Label/index.js +2 -2
- package/inputs/Label/index.js.map +2 -2
- package/inputs/OtpInput/index.js.map +2 -2
- package/inputs/Radio/__stories__/Conditional.js.map +2 -2
- package/inputs/Radio/index.d.ts +5 -1
- package/inputs/Radio/index.js +57 -8
- package/inputs/Radio/index.js.map +2 -2
- package/inputs/Select/index.d.ts +1 -1
- package/inputs/Select/index.js +4 -2
- package/inputs/Select/index.js.map +2 -2
- package/inputs/inputsScenarios/index.js +4 -11
- package/inputs/inputsScenarios.d.ts +0 -42
- package/inputs/inputsScenarios.js.map +2 -2
- package/lazy/index.js +320 -59
- package/lazy.d.ts +17 -10
- package/lazy.js.map +2 -2
- package/locales/el.js.map +1 -1
- package/package.json +4 -4
- package/registry/index.js +118 -38
- package/registry.d.ts +1 -0
- package/registry.js.map +2 -2
- package/src/Field/FieldBase.tsx +1 -0
- package/src/Field/FieldBaseContainer.tsx +2 -2
- package/src/Field/FieldConditional.tsx +4 -0
- package/src/Field/index.tsx +4 -1
- package/src/Field/types.tsx +10 -8
- package/src/Field/utils/index.ts +18 -1
- package/src/FieldArray/index.test.tsx +14 -13
- package/src/FieldArray/index.tsx +9 -6
- package/src/FieldObject/index.tsx +8 -2
- package/src/Fieldset/index.tsx +5 -5
- package/src/Fieldset/types.tsx +2 -2
- package/src/FormBuilder/{FormBuilder.mdx → doc.mdx} +20 -33
- package/src/FormBuilder/index.test.tsx +11 -10
- package/src/FormBuilder/index.tsx +178 -7
- package/src/FormBuilder/scenarios.test.tsx +2 -2
- package/src/FormContext.tsx +1 -2
- package/src/MultiplicityField/add-objects.tsx +10 -8
- package/src/MultiplicityField/{MultiplicityField.mdx → doc.mdx} +12 -16
- package/src/MultiplicityField/index.test.tsx +26 -25
- package/src/MultiplicityField/index.tsx +15 -12
- package/src/MultiplicityField/types.ts +1 -2
- package/src/Questions/Questions.tsx +4 -4
- package/src/Questions/Step/StepArrayReview.tsx +1 -1
- package/src/Questions/Step/StepTitle.tsx +4 -3
- package/src/Questions/__snapshots__/index.spec.tsx.snap +8 -4
- package/src/Questions/{index.mdx → doc.mdx} +9 -12
- package/src/Questions/index.spec.tsx +6 -2
- package/src/Questions/index.test.tsx +11 -10
- package/src/create-simple-form.mdx +2 -6
- package/src/{index.mdx → doc.mdx} +4 -8
- package/src/index.ts +6 -0
- package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +2 -10
- package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +1 -8
- package/src/inputs/AutoCompleteInput/{index.mdx → doc.mdx} +2 -13
- package/src/inputs/AutoCompleteInput/index.test.tsx +14 -13
- package/src/inputs/AutoCompleteInput/index.tsx +36 -31
- package/src/inputs/Checkboxes/{index.mdx → doc.mdx} +5 -15
- package/src/inputs/Checkboxes/index.test.tsx +17 -16
- package/src/inputs/Checkboxes/index.tsx +10 -8
- package/src/inputs/DateInput/__stories__/Default.tsx +7 -12
- package/src/inputs/DateInput/{index.mdx → doc.mdx} +1 -8
- package/src/inputs/DateInput/index.test.tsx +11 -10
- package/src/inputs/DateInput/index.tsx +6 -4
- package/src/inputs/FileInput/{index.mdx → doc.mdx} +1 -5
- package/src/inputs/FileInput/index.test.tsx +11 -10
- package/src/inputs/FileInput/index.tsx +7 -8
- package/src/inputs/ImageInput/ImageInput.stories.js +1 -1
- package/src/inputs/ImageInput/__stories__/MaxSize.tsx +37 -0
- package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +2 -0
- package/src/inputs/ImageInput/doc.mdx +23 -0
- package/src/inputs/ImageInput/index.test.tsx +21 -16
- package/src/inputs/ImageInput/index.tsx +10 -15
- package/src/inputs/Input/__stories__/LandlineNumber.tsx +2 -1
- package/src/inputs/Input/__stories__/MobilePhone.tsx +1 -0
- package/src/inputs/Input/__stories__/PhoneNumber.tsx +1 -0
- package/src/inputs/Input/__stories__/PostalCode.tsx +1 -0
- package/src/inputs/Input/doc.mdx +56 -0
- package/src/inputs/Input/index.test.tsx +38 -37
- package/src/inputs/Input/index.tsx +32 -29
- package/src/inputs/Input/inputsInputScenarios.ts +244 -245
- package/src/inputs/Label/doc.mdx +14 -0
- package/src/inputs/Label/index.test.tsx +11 -10
- package/src/inputs/Label/index.tsx +2 -6
- package/src/inputs/OtpInput/{index.mdx → doc.mdx} +1 -8
- package/src/inputs/OtpInput/index.test.tsx +11 -10
- package/src/inputs/OtpInput/index.tsx +2 -1
- package/src/inputs/Radio/__stories__/Conditional.tsx +2 -1
- package/src/inputs/Radio/{index.mdx → doc.mdx} +5 -15
- package/src/inputs/Radio/index.test.tsx +17 -16
- package/src/inputs/Radio/index.tsx +76 -10
- package/src/inputs/Select/{index.mdx → doc.mdx} +1 -5
- package/src/inputs/Select/index.test.tsx +11 -10
- package/src/inputs/Select/index.tsx +5 -3
- package/src/inputs/inputsScenarios.ts +174 -181
- package/src/installation.mdx +2 -5
- package/src/lazy.js +322 -62
- package/src/locales/el.ts +1 -1
- package/src/registry.js +121 -45
- package/src/types.tsx +3 -2
- package/src/utils.ts +2 -2
- package/src/validators/index.ts +33 -71
- package/src/validators/utils/date.ts +107 -0
- package/src/validators/utils/file.ts +5 -3
- package/src/validators/utils/index.ts +1 -0
- package/src/validators/utils/phone.ts +1 -1
- package/src/validators/utils/postal_code.ts +1 -1
- package/src/validators/utils/uuid4.ts +2 -1
- package/src/validators/validators.spec.ts +3 -3
- package/types.d.ts +3 -3
- package/types.js.map +1 -1
- package/utils/index.js +2 -1
- package/utils.js.map +2 -2
- package/validators/index.js +20 -67
- package/validators/index.js.map +2 -2
- package/validators/utils/date/index.js +103 -0
- package/validators/utils/date/package.json +6 -0
- package/validators/utils/date.d.ts +9 -0
- package/validators/utils/date.js.map +7 -0
- package/validators/utils/file/index.js +1 -1
- package/validators/utils/file.js.map +2 -2
- package/validators/utils/index.d.ts +1 -0
- package/validators/utils/index.js +1 -0
- package/validators/utils/index.js.map +2 -2
- package/validators/utils/phone.d.ts +1 -1
- package/validators/utils/phone.js.map +2 -2
- package/validators/utils/postal_code.d.ts +1 -1
- package/validators/utils/postal_code.js.map +1 -1
- package/validators/utils/uuid4.js.map +2 -2
- package/src/index.tsx +0 -178
- package/src/inputs/ImageInput/index.mdx +0 -19
- package/src/inputs/Input/index.mdx +0 -95
- package/src/inputs/Label/index.mdx +0 -0
- /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
|
|
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
|
|
25
|
-
import RadioConditional from '@digigov/
|
|
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
|
-
|
|
110
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
</
|
|
33
|
-
|
|
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({
|
|
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
|
|
4
|
-
|
|
5
|
-
import
|
|
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 {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
<
|
|
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
|
-
</
|
|
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
|
|
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
|
|
49
|
+
onChange(data);
|
|
50
50
|
}
|
|
51
51
|
setData(data);
|
|
52
52
|
const nextStep = getNextStep(currentStep, steps, data);
|
|
53
53
|
if (nextStep) {
|
|
54
|
-
onActiveStep
|
|
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:
|
|
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
|
|
4
|
-
|
|
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
|
-
//
|
|
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-
|
|
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-
|
|
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-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
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
|
|
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
|
|
6
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
</
|
|
13
|
-
|
|
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({
|
|
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
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
<
|
|
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
|
-
<
|
|
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" />
|