@digigov/form 2.0.0-cbc56209 → 2.0.0-fec6f1f7
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/utils/index.js +5 -5
- package/cjs/Field/FieldBase/index.js +1 -0
- package/cjs/Field/utils/index.js +5 -10
- package/cjs/inputs/AutoCompleteInput/AutoComplete.stories/index.js +12 -0
- package/cjs/inputs/AutoCompleteInput/__stories__/Default/index.js +11 -16
- package/cjs/inputs/AutoCompleteInput/__stories__/Multiple/index.js +52 -0
- package/cjs/inputs/AutoCompleteInput/index.js +5 -2
- package/cjs/inputs/AutoCompleteInput/index.mdx +29 -0
- package/cjs/inputs/Checkboxes/__stories__/Conditional/index.js +3 -2
- package/cjs/inputs/Checkboxes/index.mdx +33 -0
- package/cjs/inputs/DateInput/index.mdx +23 -0
- package/cjs/inputs/FileInput/index.mdx +19 -0
- package/cjs/inputs/ImageInput/index.mdx +19 -0
- package/cjs/inputs/Input/index.mdx +90 -3
- package/cjs/inputs/OtpInput/index.mdx +23 -0
- package/cjs/inputs/Radio/__stories__/Conditional/index.js +3 -2
- package/cjs/inputs/Radio/index.mdx +33 -0
- package/cjs/inputs/Select/index.mdx +17 -0
- package/cjs/validators/utils/file/index.js +11 -19
- package/index.js +1 -1
- package/inputs/AutoCompleteInput/AutoComplete.stories/index.js +2 -1
- package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +1 -0
- package/inputs/AutoCompleteInput/__stories__/Default/index.js +9 -11
- package/inputs/AutoCompleteInput/__stories__/Default.d.ts +1 -0
- package/inputs/AutoCompleteInput/__stories__/Multiple/index.js +45 -0
- package/inputs/AutoCompleteInput/__stories__/Multiple/package.json +6 -0
- package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +3 -0
- package/inputs/AutoCompleteInput/index.js +5 -2
- package/inputs/AutoCompleteInput/index.mdx +29 -0
- package/inputs/Checkboxes/__stories__/Conditional/index.js +2 -1
- package/inputs/Checkboxes/__stories__/Conditional.d.ts +1 -0
- package/inputs/Checkboxes/index.mdx +33 -0
- package/inputs/DateInput/index.mdx +23 -0
- package/inputs/FileInput/index.mdx +19 -0
- package/inputs/ImageInput/index.mdx +19 -0
- package/inputs/Input/index.mdx +90 -3
- package/inputs/OtpInput/index.mdx +23 -0
- package/inputs/Radio/__stories__/Conditional/index.js +2 -1
- package/inputs/Radio/__stories__/Conditional.d.ts +1 -0
- package/inputs/Radio/index.mdx +33 -0
- package/inputs/Select/index.mdx +17 -0
- package/package.json +4 -4
- package/src/Field/FieldBase.tsx +1 -0
- package/src/Field/utils.ts +4 -4
- package/src/inputs/AutoCompleteInput/AutoComplete.stories.js +1 -0
- package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +27 -18
- package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +54 -0
- package/src/inputs/AutoCompleteInput/index.mdx +29 -0
- package/src/inputs/AutoCompleteInput/index.tsx +3 -2
- package/src/inputs/Checkboxes/__stories__/Conditional.tsx +2 -3
- package/src/inputs/Checkboxes/index.mdx +33 -0
- package/src/inputs/Checkboxes/index.tsx +2 -2
- package/src/inputs/DateInput/index.mdx +23 -0
- package/src/inputs/DateInput/index.tsx +1 -1
- package/src/inputs/FileInput/index.mdx +19 -0
- package/src/inputs/ImageInput/index.mdx +19 -0
- package/src/inputs/Input/index.mdx +90 -3
- package/src/inputs/OtpInput/index.mdx +23 -0
- package/src/inputs/OtpInput/index.tsx +1 -1
- package/src/inputs/Radio/__stories__/Conditional.tsx +2 -0
- package/src/inputs/Radio/index.mdx +33 -0
- package/src/inputs/Select/index.mdx +17 -0
- package/src/validators/utils/file.ts +9 -9
- package/validators/utils/file/index.js +11 -19
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { Field } from '@digigov/form/Field';
|
|
3
3
|
import FormBuilder from '@digigov/form/FormBuilder';
|
|
4
|
-
import { results } from '@digigov/ui/form/AutoComplete/utils';
|
|
5
4
|
import Button from '@digigov/ui/form/Button';
|
|
5
|
+
var results = ['Αμερική', 'Ασία', 'Αυστραλία', 'Αφρική', 'Ευρώπη'];
|
|
6
6
|
var fields = [{
|
|
7
7
|
key: 'autocomplete',
|
|
8
8
|
label: {
|
|
9
|
-
primary: '
|
|
9
|
+
primary: 'Επιλέξτε ήπειρο'
|
|
10
10
|
},
|
|
11
11
|
required: true,
|
|
12
12
|
type: 'choice:single',
|
|
@@ -16,7 +16,7 @@ var fields = [{
|
|
|
16
16
|
return {
|
|
17
17
|
label: {
|
|
18
18
|
primary: r,
|
|
19
|
-
secondary: "
|
|
19
|
+
secondary: "'\u0397\u03C0\u03B5\u03B9\u03C1\u03BF\u03C2: ".concat(r)
|
|
20
20
|
},
|
|
21
21
|
value: r.toLowerCase()
|
|
22
22
|
};
|
|
@@ -24,14 +24,11 @@ var fields = [{
|
|
|
24
24
|
}
|
|
25
25
|
}];
|
|
26
26
|
var initialValues = {};
|
|
27
|
-
var _ref = /*#__PURE__*/React.createElement(
|
|
28
|
-
var _ref2 = /*#__PURE__*/React.createElement(Button, {
|
|
27
|
+
var _ref = /*#__PURE__*/React.createElement(Button, {
|
|
29
28
|
type: "submit"
|
|
30
29
|
}, "Submit");
|
|
31
30
|
export var Default = function Default() {
|
|
32
|
-
return /*#__PURE__*/React.createElement(
|
|
33
|
-
fallback: _ref
|
|
34
|
-
}, /*#__PURE__*/React.createElement(FormBuilder, {
|
|
31
|
+
return /*#__PURE__*/React.createElement(FormBuilder, {
|
|
35
32
|
fields: fields,
|
|
36
33
|
onSubmit: function onSubmit(data) {
|
|
37
34
|
console.log(data);
|
|
@@ -42,5 +39,6 @@ export var Default = function Default() {
|
|
|
42
39
|
key: field.key,
|
|
43
40
|
name: field.key
|
|
44
41
|
});
|
|
45
|
-
}),
|
|
46
|
-
};
|
|
42
|
+
}), _ref);
|
|
43
|
+
};
|
|
44
|
+
export default Default;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Field } from '@digigov/form/Field';
|
|
3
|
+
import FormBuilder from '@digigov/form/FormBuilder';
|
|
4
|
+
import Button from '@digigov/ui/form/Button';
|
|
5
|
+
var results = ['Αμερική', 'Ασία', 'Αυστραλία', 'Αφρική', 'Ευρώπη'];
|
|
6
|
+
var fields = [{
|
|
7
|
+
key: 'autocomplete',
|
|
8
|
+
label: {
|
|
9
|
+
primary: 'Επιλέξτε ήπειρο'
|
|
10
|
+
},
|
|
11
|
+
required: true,
|
|
12
|
+
type: 'choice:single',
|
|
13
|
+
extra: {
|
|
14
|
+
component: 'AutoComplete',
|
|
15
|
+
multiple: true,
|
|
16
|
+
options: results.map(function (r) {
|
|
17
|
+
return {
|
|
18
|
+
label: {
|
|
19
|
+
primary: r,
|
|
20
|
+
secondary: "\u0389\u03C0\u03B5\u03B9\u03C1\u03BF\u03C2: ".concat(r)
|
|
21
|
+
},
|
|
22
|
+
value: r.toLowerCase()
|
|
23
|
+
};
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
}];
|
|
27
|
+
var initialValues = {};
|
|
28
|
+
var _ref = /*#__PURE__*/React.createElement(Button, {
|
|
29
|
+
type: "submit"
|
|
30
|
+
}, "Submit");
|
|
31
|
+
export var Multiple = function Multiple() {
|
|
32
|
+
return /*#__PURE__*/React.createElement(FormBuilder, {
|
|
33
|
+
fields: fields,
|
|
34
|
+
onSubmit: function onSubmit(data) {
|
|
35
|
+
console.log(data);
|
|
36
|
+
},
|
|
37
|
+
initial: initialValues
|
|
38
|
+
}, fields.map(function (field) {
|
|
39
|
+
return /*#__PURE__*/React.createElement(Field, {
|
|
40
|
+
key: field.key,
|
|
41
|
+
name: field.key
|
|
42
|
+
});
|
|
43
|
+
}), _ref);
|
|
44
|
+
};
|
|
45
|
+
export default Multiple;
|
|
@@ -6,7 +6,9 @@ import { Hint } from '@digigov/react-core/Hint';
|
|
|
6
6
|
import UIAutoComplete from '@digigov/ui/form/AutoComplete';
|
|
7
7
|
export var AutoCompleteInput = function AutoCompleteInput(_ref) {
|
|
8
8
|
var name = _ref.name,
|
|
9
|
-
|
|
9
|
+
_ref$extra = _ref.extra,
|
|
10
|
+
options = _ref$extra.options,
|
|
11
|
+
multiple = _ref$extra.multiple,
|
|
10
12
|
onChange = _ref.onChange,
|
|
11
13
|
value = _ref.value,
|
|
12
14
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -14,9 +16,10 @@ export var AutoCompleteInput = function AutoCompleteInput(_ref) {
|
|
|
14
16
|
syncResults(query ? options.filter(function (option) {
|
|
15
17
|
var _option$label, _option$label2;
|
|
16
18
|
return "".concat(option.value, " ").concat(((_option$label = option.label) === null || _option$label === void 0 ? void 0 : _option$label.primary) || '', " ").concat(((_option$label2 = option.label) === null || _option$label2 === void 0 ? void 0 : _option$label2.secondary) || '').toLowerCase().indexOf(query.toLowerCase()) !== -1;
|
|
17
|
-
}) :
|
|
19
|
+
}) : options);
|
|
18
20
|
}, []);
|
|
19
21
|
return /*#__PURE__*/React.createElement(UIAutoComplete, _extends({
|
|
22
|
+
multiple: multiple,
|
|
20
23
|
source: suggest,
|
|
21
24
|
onConfirm: function onConfirm(value) {
|
|
22
25
|
onChange(value.value);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: AutoComplete Input
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# AutoComplete input
|
|
6
|
+
|
|
7
|
+
AutoCompleteInput element is an enhanced version of text input that shows suggested
|
|
8
|
+
options as the users type and also let them select an option from the list.
|
|
9
|
+
|
|
10
|
+
## How to use
|
|
11
|
+
|
|
12
|
+
### Default
|
|
13
|
+
|
|
14
|
+
<Story
|
|
15
|
+
packageName="@digigov/form"
|
|
16
|
+
component="inputs/AutoCompleteInput"
|
|
17
|
+
story="Default.tsx"
|
|
18
|
+
/>
|
|
19
|
+
|
|
20
|
+
### Display multiple values
|
|
21
|
+
|
|
22
|
+
<Story
|
|
23
|
+
packageName="@digigov/form"
|
|
24
|
+
component="inputs/AutoCompleteInput"
|
|
25
|
+
story="Multiple.tsx"
|
|
26
|
+
/>
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Checkbox
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Checkboxes
|
|
6
|
+
Input element of type `checkbox` are rendered by default as boxes that are checked when activated.
|
|
7
|
+
Checkboxes are used to let a user select one or more options of a limited number of choices.
|
|
8
|
+
|
|
9
|
+
## How to use
|
|
10
|
+
|
|
11
|
+
### Default
|
|
12
|
+
|
|
13
|
+
<Story
|
|
14
|
+
packageName="@digigov/form"
|
|
15
|
+
component="inputs/Checkboxes"
|
|
16
|
+
story="Default.tsx"
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
### Conditional
|
|
20
|
+
|
|
21
|
+
<Story
|
|
22
|
+
packageName="@digigov/form"
|
|
23
|
+
component="inputs/Checkboxes"
|
|
24
|
+
story="Conditional.tsx"
|
|
25
|
+
/>
|
|
26
|
+
|
|
27
|
+
### With divider
|
|
28
|
+
|
|
29
|
+
<Story
|
|
30
|
+
packageName="@digigov/form"
|
|
31
|
+
component="inputs/Checkboxes"
|
|
32
|
+
story="WithDivider.tsx"
|
|
33
|
+
/>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Date Input
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Date input
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Input element of type `date` create input fields that let the user enter a date,
|
|
10
|
+
either with a textbox that validates the input or a special date picker interface.
|
|
11
|
+
|
|
12
|
+
## How to use
|
|
13
|
+
|
|
14
|
+
### Default
|
|
15
|
+
|
|
16
|
+
<Story
|
|
17
|
+
packageName="@digigov/form"
|
|
18
|
+
component="inputs/DateInput"
|
|
19
|
+
story="Default.tsx"
|
|
20
|
+
/>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: File Input
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# File input
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Input element of type `file` let the user choose one or more files from their device storage.
|
|
10
|
+
|
|
11
|
+
## How to use
|
|
12
|
+
|
|
13
|
+
### Default
|
|
14
|
+
|
|
15
|
+
<Story
|
|
16
|
+
packageName="@digigov/form"
|
|
17
|
+
component="inputs/FileInput"
|
|
18
|
+
story="Default.tsx"
|
|
19
|
+
/>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Image Input
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Image input
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Input element of type `image` defines an image as a submit button, i.e. submit buttons that take the form of an image rather than text.
|
|
10
|
+
|
|
11
|
+
## How to use
|
|
12
|
+
|
|
13
|
+
### Default
|
|
14
|
+
|
|
15
|
+
<Story
|
|
16
|
+
packageName="@digigov/form"
|
|
17
|
+
component="inputs/ImageInput"
|
|
18
|
+
story="Default.tsx"
|
|
19
|
+
/>
|
package/inputs/Input/index.mdx
CHANGED
|
@@ -1,8 +1,95 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Input
|
|
3
|
-
parent: docs/ui/components
|
|
4
3
|
---
|
|
4
|
+
|
|
5
|
+
# Input
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
The input element of type `string` is used to create interactive controls for web-based forms in order to accept data from the user;
|
|
10
|
+
a wide variety of types of input data and control widgets are available, depending on the device and user agent. The input element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.
|
|
11
|
+
|
|
12
|
+
## How to use
|
|
13
|
+
|
|
14
|
+
### Default
|
|
15
|
+
|
|
16
|
+
<Story
|
|
17
|
+
packageName="@digigov/form"
|
|
18
|
+
component="inputs/Input"
|
|
19
|
+
story="Default.tsx"
|
|
20
|
+
/>
|
|
21
|
+
|
|
22
|
+
### Boolean
|
|
23
|
+
|
|
24
|
+
<Story
|
|
25
|
+
packageName="@digigov/form"
|
|
26
|
+
component="inputs/Input"
|
|
27
|
+
story="Boolean.tsx"
|
|
28
|
+
/>
|
|
29
|
+
### AFM
|
|
30
|
+
|
|
31
|
+
<Story
|
|
32
|
+
packageName="@digigov/form"
|
|
33
|
+
component="inputs/Input"
|
|
34
|
+
story="AFM.tsx"
|
|
35
|
+
/>
|
|
36
|
+
|
|
37
|
+
### IBAN
|
|
38
|
+
|
|
39
|
+
<Story
|
|
40
|
+
packageName="@digigov/form"
|
|
41
|
+
component="inputs/Input"
|
|
42
|
+
story="IBAN.tsx"
|
|
43
|
+
/>
|
|
44
|
+
|
|
45
|
+
### Integer
|
|
46
|
+
|
|
47
|
+
<Story
|
|
48
|
+
packageName="@digigov/form"
|
|
49
|
+
component="inputs/Input"
|
|
50
|
+
story="Default.tsx"
|
|
51
|
+
/>
|
|
52
|
+
|
|
53
|
+
### Landline number
|
|
54
|
+
|
|
55
|
+
<Story
|
|
56
|
+
packageName="@digigov/form"
|
|
57
|
+
component="inputs/Input"
|
|
58
|
+
story="LandlineNumber.tsx"
|
|
59
|
+
/>
|
|
60
|
+
|
|
61
|
+
### Mobile phone
|
|
62
|
+
|
|
63
|
+
<Story
|
|
64
|
+
packageName="@digigov/form"
|
|
65
|
+
component="inputs/Input"
|
|
66
|
+
story="MobilePhone.tsx"
|
|
67
|
+
/>
|
|
68
|
+
|
|
69
|
+
### Phone number
|
|
70
|
+
|
|
71
|
+
<Story
|
|
72
|
+
packageName="@digigov/form"
|
|
73
|
+
component="inputs/Input"
|
|
74
|
+
story="PhoneNumber.tsx"
|
|
75
|
+
/>
|
|
76
|
+
|
|
77
|
+
### Postal code
|
|
78
|
+
|
|
79
|
+
<Story
|
|
80
|
+
packageName="@digigov/form"
|
|
81
|
+
component="inputs/Input"
|
|
82
|
+
story="PostalCode.tsx"
|
|
83
|
+
/>
|
|
84
|
+
|
|
85
|
+
### Text with character limit
|
|
86
|
+
|
|
87
|
+
<Story
|
|
88
|
+
packageName="@digigov/form"
|
|
89
|
+
component="inputs/Input"
|
|
90
|
+
story="TextWithCharacterLimit.tsx"
|
|
91
|
+
/>
|
|
92
|
+
|
|
93
|
+
|
|
5
94
|
|
|
6
|
-
## Example
|
|
7
95
|
|
|
8
|
-
<Input type="text" />
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: OTP Input
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# OTP input
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
A one-time password (OTP) input element of type `otp`, also known as a one-time PIN, one-time authorization code (OTAC) or dynamic password, is a password that is valid for only one login session or transaction,
|
|
10
|
+
on a computer system or other digital device.
|
|
11
|
+
|
|
12
|
+
## How to use
|
|
13
|
+
|
|
14
|
+
### Default
|
|
15
|
+
|
|
16
|
+
<Story
|
|
17
|
+
packageName="@digigov/form"
|
|
18
|
+
component="inputs/OtpInput"
|
|
19
|
+
story="Default.tsx"
|
|
20
|
+
/>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
package/inputs/Radio/index.mdx
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Radio
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Radio
|
|
6
|
+
Input element of type `radio` are generally used in radio groups—collections of radio buttons describing a set of related options.
|
|
7
|
+
Radios are used to let a user select one option of a limited number of choices.
|
|
8
|
+
|
|
9
|
+
## How to use
|
|
10
|
+
|
|
11
|
+
### Default
|
|
12
|
+
|
|
13
|
+
<Story
|
|
14
|
+
packageName="@digigov/form"
|
|
15
|
+
component="inputs/Radio"
|
|
16
|
+
story="Default.tsx"
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
### Conditional
|
|
20
|
+
|
|
21
|
+
<Story
|
|
22
|
+
packageName="@digigov/form"
|
|
23
|
+
component="inputs/Radio"
|
|
24
|
+
story="Conditional.tsx"
|
|
25
|
+
/>
|
|
26
|
+
|
|
27
|
+
### With divider
|
|
28
|
+
|
|
29
|
+
<Story
|
|
30
|
+
packageName="@digigov/form"
|
|
31
|
+
component="inputs/Radio"
|
|
32
|
+
story="WithDivider.tsx"
|
|
33
|
+
/>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Select
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Select
|
|
6
|
+
|
|
7
|
+
The select element represents a control that provides a menu of options.
|
|
8
|
+
|
|
9
|
+
## How to use
|
|
10
|
+
|
|
11
|
+
### Default
|
|
12
|
+
|
|
13
|
+
<Story
|
|
14
|
+
packageName="@digigov/form"
|
|
15
|
+
component="inputs/Select"
|
|
16
|
+
story="Default.tsx"
|
|
17
|
+
/>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digigov/form",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-fec6f1f7",
|
|
4
4
|
"description": "@digigov form builder",
|
|
5
5
|
"author": "GRNET Developers <devs@lists.grnet.gr>",
|
|
6
6
|
"license": "BSD-2-Clause",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"dayjs": "1.10.4",
|
|
16
16
|
"@hookform/resolvers": "2.9.6",
|
|
17
17
|
"publint": "0.1.8",
|
|
18
|
-
"@digigov/react-icons": "2.0.0-
|
|
18
|
+
"@digigov/react-icons": "2.0.0-fec6f1f7"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@digigov/ui": "2.0.0-
|
|
22
|
-
"@digigov/react-core": "2.0.0-
|
|
21
|
+
"@digigov/ui": "2.0.0-fec6f1f7",
|
|
22
|
+
"@digigov/react-core": "2.0.0-fec6f1f7",
|
|
23
23
|
"clsx": "1.1.1",
|
|
24
24
|
"react": "^16.8.0 || ^17.0.0",
|
|
25
25
|
"react-dom": "^16.8.0 || ^17.0.0"
|
package/src/Field/FieldBase.tsx
CHANGED
package/src/Field/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useContext, useMemo } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
CalculatedField,
|
|
4
4
|
FieldComponentRegistry,
|
|
@@ -15,11 +15,9 @@ import Input from '@digigov/form/inputs/Input';
|
|
|
15
15
|
import OtpInput from '@digigov/form/inputs/OtpInput';
|
|
16
16
|
import Radio from '@digigov/form/inputs/Radio';
|
|
17
17
|
import Select from '@digigov/form/inputs/Select';
|
|
18
|
+
import AutoCompleteInput from '@digigov/form/inputs/AutoCompleteInput';
|
|
18
19
|
import { FieldSpec } from '@digigov/form/types';
|
|
19
20
|
|
|
20
|
-
const AutoCompleteInput = lazy(() =>
|
|
21
|
-
import('@digigov/form/inputs/AutoCompleteInput')
|
|
22
|
-
);
|
|
23
21
|
|
|
24
22
|
const FIELD_COMPONENTS: FieldComponentRegistry = {
|
|
25
23
|
text: {
|
|
@@ -66,6 +64,7 @@ const ALTERNATIVE_COMPONENTS: FieldComponentRegistry = {
|
|
|
66
64
|
AutoComplete: {
|
|
67
65
|
component: AutoCompleteInput,
|
|
68
66
|
controlled: true,
|
|
67
|
+
wrapper: 'fieldset'
|
|
69
68
|
},
|
|
70
69
|
};
|
|
71
70
|
|
|
@@ -93,6 +92,7 @@ export function calculateField(
|
|
|
93
92
|
ALTERNATIVE_COMPONENTS[field.extra.component]?.controlled || false;
|
|
94
93
|
calculatedField.component =
|
|
95
94
|
ALTERNATIVE_COMPONENTS[field.extra.component].component;
|
|
95
|
+
calculatedField.wrapper = ALTERNATIVE_COMPONENTS[field.extra.component].wrapper;
|
|
96
96
|
} else if (
|
|
97
97
|
!field.component &&
|
|
98
98
|
field.type &&
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { Field } from '@digigov/form/Field';
|
|
3
3
|
import FormBuilder from '@digigov/form/FormBuilder';
|
|
4
4
|
import { FieldSpec } from '@digigov/form/types';
|
|
5
|
-
import { results } from '@digigov/ui/form/AutoComplete/utils';
|
|
6
5
|
import Button from '@digigov/ui/form/Button';
|
|
6
|
+
|
|
7
|
+
const results = [
|
|
8
|
+
'Αμερική',
|
|
9
|
+
'Ασία',
|
|
10
|
+
'Αυστραλία',
|
|
11
|
+
'Αφρική',
|
|
12
|
+
'Ευρώπη',
|
|
13
|
+
];
|
|
14
|
+
|
|
7
15
|
const fields: FieldSpec[] = [
|
|
8
16
|
{
|
|
9
17
|
key: 'autocomplete',
|
|
10
|
-
label: { primary: '
|
|
18
|
+
label: { primary: 'Επιλέξτε ήπειρο' },
|
|
11
19
|
required: true,
|
|
12
20
|
type: 'choice:single',
|
|
13
21
|
extra: {
|
|
@@ -16,7 +24,7 @@ const fields: FieldSpec[] = [
|
|
|
16
24
|
return {
|
|
17
25
|
label: {
|
|
18
26
|
primary: r,
|
|
19
|
-
secondary: `
|
|
27
|
+
secondary: `'Ηπειρος: ${r}`,
|
|
20
28
|
},
|
|
21
29
|
value: r.toLowerCase(),
|
|
22
30
|
};
|
|
@@ -28,18 +36,19 @@ const fields: FieldSpec[] = [
|
|
|
28
36
|
const initialValues = {};
|
|
29
37
|
|
|
30
38
|
export const Default = () => (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
|
|
40
|
+
<FormBuilder
|
|
41
|
+
fields={fields}
|
|
42
|
+
onSubmit={(data) => {
|
|
43
|
+
console.log(data);
|
|
44
|
+
}}
|
|
45
|
+
initial={initialValues}
|
|
46
|
+
>
|
|
47
|
+
{fields.map((field) => (
|
|
48
|
+
<Field key={field.key} name={field.key} />
|
|
49
|
+
))}
|
|
50
|
+
<Button type="submit">Submit</Button>
|
|
51
|
+
</FormBuilder>
|
|
52
|
+
|
|
45
53
|
);
|
|
54
|
+
export default Default;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Field } from '@digigov/form/Field';
|
|
3
|
+
import FormBuilder from '@digigov/form/FormBuilder';
|
|
4
|
+
import { FieldSpec } from '@digigov/form/types';
|
|
5
|
+
import Button from '@digigov/ui/form/Button';
|
|
6
|
+
|
|
7
|
+
const results = [
|
|
8
|
+
'Αμερική',
|
|
9
|
+
'Ασία',
|
|
10
|
+
'Αυστραλία',
|
|
11
|
+
'Αφρική',
|
|
12
|
+
'Ευρώπη',
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const fields: FieldSpec[] = [
|
|
16
|
+
{
|
|
17
|
+
key: 'autocomplete',
|
|
18
|
+
label: { primary: 'Επιλέξτε ήπειρο' },
|
|
19
|
+
required: true,
|
|
20
|
+
type: 'choice:single',
|
|
21
|
+
extra: {
|
|
22
|
+
component: 'AutoComplete',
|
|
23
|
+
multiple: true,
|
|
24
|
+
options: results.map((r) => {
|
|
25
|
+
return {
|
|
26
|
+
label: {
|
|
27
|
+
primary: r,
|
|
28
|
+
secondary: `Ήπειρος: ${r}`,
|
|
29
|
+
},
|
|
30
|
+
value: r.toLowerCase(),
|
|
31
|
+
};
|
|
32
|
+
}),
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
const initialValues = {};
|
|
38
|
+
|
|
39
|
+
export const Multiple = () => (
|
|
40
|
+
<FormBuilder
|
|
41
|
+
fields={fields}
|
|
42
|
+
onSubmit={(data) => {
|
|
43
|
+
console.log(data);
|
|
44
|
+
}}
|
|
45
|
+
initial={initialValues}
|
|
46
|
+
>
|
|
47
|
+
{fields.map((field) => (
|
|
48
|
+
<Field key={field.key} name={field.key} />
|
|
49
|
+
))}
|
|
50
|
+
<Button type="submit">Submit</Button>
|
|
51
|
+
</FormBuilder>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
export default Multiple;
|