@digigov/form 1.2.0-dcbd7ded → 2.0.0-462194bf
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/MultiplicityField/__stories__/PreviewDisplay/index.js +8 -2
- package/cjs/Field/FieldBase/index.js +1 -0
- package/cjs/Field/utils/index.js +5 -10
- package/cjs/MultiplicityField/__stories__/PreviewDisplay/index.js +8 -2
- 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 +20 -6
- 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.js +1 -0
- 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.d.ts +1 -1
- package/inputs/AutoCompleteInput/index.js +20 -6
- 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.d.ts +8 -1
- package/inputs/OtpInput/index.js +1 -1
- 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/lazy.d.ts +1 -1
- package/package.json +4 -4
- package/src/Field/FieldBase.tsx +1 -0
- package/src/Field/utils.ts +4 -4
- package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +2 -2
- 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 +24 -14
- 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 +2 -2
- 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
|
@@ -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
|
+
/>
|
|
@@ -5,17 +5,17 @@ const DEFAULT_FILE_MAX_SIZE = 10000000;
|
|
|
5
5
|
|
|
6
6
|
export const FILE_MAX_SIZE_VALIDATOR = (field: FieldSpec): ValidatorSchema => ({
|
|
7
7
|
name: 'file-max-size-validator',
|
|
8
|
-
message:
|
|
8
|
+
message: {
|
|
9
|
+
key: 'form.error.file_size',
|
|
10
|
+
context: {
|
|
11
|
+
maxSizeToMb: (field?.extra?.limit.maxSize || DEFAULT_FILE_MAX_SIZE) / 1000000,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
9
14
|
test: (value: File[]): boolean => {
|
|
10
|
-
if (
|
|
11
|
-
for (const file of value) {
|
|
12
|
-
if (file.size >= field.extra.limit.maxSize) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
} else if (value) {
|
|
15
|
+
if (value) {
|
|
17
16
|
for (const file of value) {
|
|
18
|
-
|
|
17
|
+
const maxSize = field?.extra?.limit?.maxSize || DEFAULT_FILE_MAX_SIZE
|
|
18
|
+
if (file.size > maxSize) {
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -3,18 +3,25 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
3
3
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
4
4
|
var DEFAULT_FILE_MAX_SIZE = 10000000;
|
|
5
5
|
export var FILE_MAX_SIZE_VALIDATOR = function FILE_MAX_SIZE_VALIDATOR(field) {
|
|
6
|
+
var _field$extra;
|
|
6
7
|
return {
|
|
7
8
|
name: 'file-max-size-validator',
|
|
8
|
-
message:
|
|
9
|
+
message: {
|
|
10
|
+
key: 'form.error.file_size',
|
|
11
|
+
context: {
|
|
12
|
+
maxSizeToMb: ((field === null || field === void 0 ? void 0 : (_field$extra = field.extra) === null || _field$extra === void 0 ? void 0 : _field$extra.limit.maxSize) || DEFAULT_FILE_MAX_SIZE) / 1000000
|
|
13
|
+
}
|
|
14
|
+
},
|
|
9
15
|
test: function test(value) {
|
|
10
|
-
|
|
11
|
-
if (field !== null && field !== void 0 && (_field$extra = field.extra) !== null && _field$extra !== void 0 && _field$extra.limit && field !== null && field !== void 0 && (_field$extra2 = field.extra) !== null && _field$extra2 !== void 0 && _field$extra2.limit.maxSize && value) {
|
|
16
|
+
if (value) {
|
|
12
17
|
var _iterator = _createForOfIteratorHelper(value),
|
|
13
18
|
_step;
|
|
14
19
|
try {
|
|
15
20
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
21
|
+
var _field$extra2, _field$extra2$limit;
|
|
16
22
|
var file = _step.value;
|
|
17
|
-
|
|
23
|
+
var maxSize = (field === null || field === void 0 ? void 0 : (_field$extra2 = field.extra) === null || _field$extra2 === void 0 ? void 0 : (_field$extra2$limit = _field$extra2.limit) === null || _field$extra2$limit === void 0 ? void 0 : _field$extra2$limit.maxSize) || DEFAULT_FILE_MAX_SIZE;
|
|
24
|
+
if (file.size > maxSize) {
|
|
18
25
|
return false;
|
|
19
26
|
}
|
|
20
27
|
}
|
|
@@ -23,21 +30,6 @@ export var FILE_MAX_SIZE_VALIDATOR = function FILE_MAX_SIZE_VALIDATOR(field) {
|
|
|
23
30
|
} finally {
|
|
24
31
|
_iterator.f();
|
|
25
32
|
}
|
|
26
|
-
} else if (value) {
|
|
27
|
-
var _iterator2 = _createForOfIteratorHelper(value),
|
|
28
|
-
_step2;
|
|
29
|
-
try {
|
|
30
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
31
|
-
var _file = _step2.value;
|
|
32
|
-
if (_file.size >= DEFAULT_FILE_MAX_SIZE) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
} catch (err) {
|
|
37
|
-
_iterator2.e(err);
|
|
38
|
-
} finally {
|
|
39
|
-
_iterator2.f();
|
|
40
|
-
}
|
|
41
33
|
}
|
|
42
34
|
return true;
|
|
43
35
|
}
|