envoc-form 4.0.1-1 → 4.0.1-11
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/README.md +2 -2
- package/es/AddressInput/AddressInput.d.ts +5 -5
- package/es/ConfirmBaseForm/ConfirmBaseForm.d.ts +3 -1
- package/es/ConfirmBaseForm/ConfirmBaseForm.js +3 -2
- package/es/ConfirmDeleteForm/ConfirmDeleteForm.js +2 -1
- package/es/DatePicker/DatePickerGroup.d.ts +3 -2
- package/es/DatePicker/DatePickerGroup.js +27 -5
- package/es/DatePicker/StringDateOnlyPickerGroup.d.ts +5 -0
- package/es/DatePicker/{DateOnlyDatePickerGroup.js → StringDateOnlyPickerGroup.js} +7 -6
- package/es/DatePicker/StringDatePickerGroup.d.ts +1 -1
- package/es/Field/Field.d.ts +3 -3
- package/es/Field/Field.js +9 -4
- package/es/FieldArray/FieldArray.d.ts +2 -2
- package/es/FieldArray/FieldArray.js +10 -7
- package/es/File/FileGroup.d.ts +1 -1
- package/es/File/FileGroup.js +5 -3
- package/es/File/FileList.d.ts +2 -2
- package/es/File/FileList.js +2 -1
- package/es/Form/Form.d.ts +8 -3
- package/es/Form/Form.js +32 -3
- package/es/Form/FormBasedPreventNavigation.js +31 -14
- package/es/FormActions.js +5 -1
- package/es/FormDefaults.d.ts +3 -0
- package/es/FormDefaults.js +1 -0
- package/es/Group.d.ts +2 -1
- package/es/Group.js +8 -5
- package/es/Input/IconInputGroup.d.ts +1 -1
- package/es/Input/IconInputGroup.js +3 -1
- package/es/Input/InputGroup.d.ts +3 -3
- package/es/Input/InputGroup.js +3 -2
- package/es/Input/MoneyInputGroup.d.ts +1 -1
- package/es/Input/MoneyInputGroup.js +2 -1
- package/es/Input/NumberInputGroup.d.ts +1 -1
- package/es/Input/NumberInputGroup.js +2 -1
- package/es/Input/StringInputGroup.d.ts +1 -1
- package/es/Input/StringInputGroup.js +3 -1
- package/es/Normalization/normalizers.d.ts +2 -2
- package/es/Select/BooleanSelectGroup.d.ts +1 -1
- package/es/Select/NumberSelectGroup.d.ts +2 -2
- package/es/Select/SelectGroup.d.ts +2 -2
- package/es/Select/SelectGroup.js +8 -3
- package/es/StandardFormActions.js +2 -1
- package/es/SubmitFormButton.d.ts +1 -1
- package/es/SubmitFormButton.js +4 -2
- package/es/TextArea/TextAreaGroup.d.ts +1 -1
- package/es/TextArea/TextAreaGroup.js +4 -2
- package/es/Validation/validators.d.ts +8 -8
- package/es/Validation/validators.js +3 -0
- package/es/__Tests__/FormTestBase.d.ts +3 -3
- package/es/__Tests__/FormTestBase.js +1 -1
- package/es/index.d.ts +8 -6
- package/es/index.js +4 -1
- package/lib/AddressInput/AddressInput.d.ts +5 -5
- package/lib/ConfirmBaseForm/ConfirmBaseForm.d.ts +3 -1
- package/lib/ConfirmBaseForm/ConfirmBaseForm.js +3 -2
- package/lib/ConfirmDeleteForm/ConfirmDeleteForm.js +2 -1
- package/lib/DatePicker/DatePickerGroup.d.ts +3 -2
- package/lib/DatePicker/DatePickerGroup.js +28 -4
- package/lib/DatePicker/StringDateOnlyPickerGroup.d.ts +5 -0
- package/lib/DatePicker/{DateOnlyDatePickerGroup.js → StringDateOnlyPickerGroup.js} +8 -7
- package/lib/DatePicker/StringDatePickerGroup.d.ts +1 -1
- package/lib/Field/Field.d.ts +3 -3
- package/lib/Field/Field.js +9 -4
- package/lib/FieldArray/FieldArray.d.ts +2 -2
- package/lib/FieldArray/FieldArray.js +10 -7
- package/lib/File/FileGroup.d.ts +1 -1
- package/lib/File/FileGroup.js +5 -3
- package/lib/File/FileList.d.ts +2 -2
- package/lib/File/FileList.js +2 -1
- package/lib/Form/Form.d.ts +8 -3
- package/lib/Form/Form.js +32 -3
- package/lib/Form/FormBasedPreventNavigation.js +31 -14
- package/lib/FormActions.js +5 -1
- package/lib/FormDefaults.d.ts +3 -0
- package/lib/FormDefaults.js +4 -0
- package/lib/Group.d.ts +2 -1
- package/lib/Group.js +8 -5
- package/lib/Input/IconInputGroup.d.ts +1 -1
- package/lib/Input/IconInputGroup.js +3 -1
- package/lib/Input/InputGroup.d.ts +3 -3
- package/lib/Input/InputGroup.js +3 -2
- package/lib/Input/MoneyInputGroup.d.ts +1 -1
- package/lib/Input/MoneyInputGroup.js +2 -1
- package/lib/Input/NumberInputGroup.d.ts +1 -1
- package/lib/Input/NumberInputGroup.js +2 -1
- package/lib/Input/StringInputGroup.d.ts +1 -1
- package/lib/Input/StringInputGroup.js +3 -1
- package/lib/Normalization/normalizers.d.ts +2 -2
- package/lib/Select/BooleanSelectGroup.d.ts +1 -1
- package/lib/Select/NumberSelectGroup.d.ts +2 -2
- package/lib/Select/SelectGroup.d.ts +2 -2
- package/lib/Select/SelectGroup.js +8 -3
- package/lib/StandardFormActions.js +2 -1
- package/lib/SubmitFormButton.d.ts +1 -1
- package/lib/SubmitFormButton.js +4 -2
- package/lib/TextArea/TextAreaGroup.d.ts +1 -1
- package/lib/TextArea/TextAreaGroup.js +4 -2
- package/lib/Validation/validators.d.ts +8 -8
- package/lib/Validation/validators.js +3 -0
- package/lib/__Tests__/FormTestBase.d.ts +3 -3
- package/lib/__Tests__/FormTestBase.js +2 -2
- package/lib/index.d.ts +8 -6
- package/lib/index.js +8 -3
- package/package.json +4 -2
- package/src/AddressInput/AddressInput.tsx +5 -5
- package/src/AddressInput/__snapshots__/AddressInput.test.tsx.snap +15 -10
- package/src/ConfirmBaseForm/ConfirmBaseForm.tsx +13 -3
- package/src/ConfirmBaseForm/__snapshots__/ConfirmBaseForm.test.tsx.snap +3 -3
- package/src/ConfirmDeleteForm/ConfirmDeleteForm.tsx +8 -1
- package/src/ConfirmDeleteForm/__snapshots__/ConfirmDeleteForm.test.tsx.snap +2 -2
- package/src/DatePicker/DatePicker.test.tsx +3 -3
- package/src/DatePicker/DatePickerGroup.tsx +45 -8
- package/src/DatePicker/StringDateOnlyPickerGroup.tsx +23 -0
- package/src/DatePicker/StringDatePickerGroup.tsx +1 -1
- package/src/DatePicker/__snapshots__/DatePicker.test.tsx.snap +3 -2
- package/src/Field/Field.tsx +22 -7
- package/src/FieldArray/FieldArray.tsx +25 -13
- package/src/File/FileGroup.tsx +15 -3
- package/src/File/FileList.tsx +5 -3
- package/src/File/__snapshots__/FileGroup.test.tsx.snap +5 -3
- package/src/Form/Form.tsx +56 -4
- package/src/Form/FormBasedPreventNavigation.tsx +34 -18
- package/src/Form/__snapshots__/Form.test.tsx.snap +1 -0
- package/src/FormActions.tsx +8 -2
- package/src/FormDefaults.ts +1 -0
- package/src/Group.tsx +21 -6
- package/src/Input/IconInputGroup.tsx +7 -4
- package/src/Input/InputGroup.tsx +18 -5
- package/src/Input/MoneyInputGroup.tsx +6 -2
- package/src/Input/NumberInputGroup.tsx +6 -2
- package/src/Input/StringInputGroup.tsx +7 -3
- package/src/Input/__Tests__/__snapshots__/IconInputGroup.test.tsx.snap +4 -2
- package/src/Input/__Tests__/__snapshots__/MoneyInputGroup.test.tsx.snap +4 -2
- package/src/Input/__Tests__/__snapshots__/NumberInputGroup.test.tsx.snap +4 -2
- package/src/Input/__Tests__/__snapshots__/StringInputGroup.test.tsx.snap +4 -2
- package/src/Normalization/normalizers.ts +2 -2
- package/src/Select/BooleanSelectGroup.tsx +1 -1
- package/src/Select/NumberSelectGroup.tsx +2 -2
- package/src/Select/SelectGroup.tsx +16 -4
- package/src/Select/__tests__/__snapshots__/BooleanSelectGroup.test.tsx.snap +3 -2
- package/src/Select/__tests__/__snapshots__/NumberSelectGroup.test.tsx.snap +6 -4
- package/src/Select/__tests__/__snapshots__/StringSelectGroup.test.tsx.snap +6 -4
- package/src/StandardFormActions.tsx +4 -1
- package/src/SubmitFormButton.tsx +9 -2
- package/src/TextArea/TextAreaGroup.tsx +13 -4
- package/src/Validation/validators.ts +16 -12
- package/src/__Tests__/FormTestBase.tsx +4 -4
- package/src/__Tests__/__snapshots__/StandardFormActions.test.tsx.snap +4 -2
- package/src/__Tests__/__snapshots__/SubmitFormButton.test.tsx.snap +3 -1
- package/src/index.ts +11 -10
- package/es/DatePicker/DateOnlyDatePickerGroup.d.ts +0 -10
- package/lib/DatePicker/DateOnlyDatePickerGroup.d.ts +0 -10
- package/src/DatePicker/DateOnlyDatePickerGroup.tsx +0 -24
@@ -1,10 +1,11 @@
|
|
1
1
|
import React, { LegacyRef } from 'react';
|
2
2
|
import classNames from 'classnames';
|
3
3
|
import InputGroup, { InputGroupProps } from './InputGroup';
|
4
|
+
import { FormDefaults } from '../FormDefaults';
|
4
5
|
|
5
6
|
export interface NumberInputGroupProps
|
6
7
|
extends Omit<
|
7
|
-
InputGroupProps<number | undefined>,
|
8
|
+
InputGroupProps<number | undefined | null>,
|
8
9
|
'onChange' | 'type' | 'value'
|
9
10
|
> {
|
10
11
|
parseFunc?: typeof parseInt | typeof parseFloat;
|
@@ -22,7 +23,10 @@ function NumberInputGroup(
|
|
22
23
|
ref={ref}
|
23
24
|
{...rest}
|
24
25
|
type="number"
|
25
|
-
className={classNames(
|
26
|
+
className={classNames(
|
27
|
+
className,
|
28
|
+
FormDefaults.cssClassPrefix + 'number-group'
|
29
|
+
)}
|
26
30
|
value={input.value || ''}
|
27
31
|
onChange={(e) => {
|
28
32
|
if (!e.target.value) {
|
@@ -1,10 +1,11 @@
|
|
1
1
|
import React, { LegacyRef } from 'react';
|
2
2
|
import classNames from 'classnames';
|
3
3
|
import InputGroup, { InputGroupProps } from './InputGroup';
|
4
|
+
import { FormDefaults } from '../FormDefaults';
|
4
5
|
|
5
6
|
export interface StringInputGroupProps
|
6
7
|
extends Omit<
|
7
|
-
InputGroupProps<string | undefined>,
|
8
|
+
InputGroupProps<string | undefined | null>,
|
8
9
|
'onChange' | 'type' | 'value'
|
9
10
|
> {
|
10
11
|
type?:
|
@@ -28,8 +29,11 @@ function StringInputGroup(
|
|
28
29
|
<InputGroup
|
29
30
|
ref={ref}
|
30
31
|
{...rest}
|
31
|
-
className={classNames(
|
32
|
-
|
32
|
+
className={classNames(
|
33
|
+
className,
|
34
|
+
FormDefaults.cssClassPrefix + 'string-group'
|
35
|
+
)}
|
36
|
+
value={input.value ?? ''}
|
33
37
|
onChange={(e) => {
|
34
38
|
if (!e.target.value) {
|
35
39
|
input.onChange(undefined);
|
@@ -4,9 +4,10 @@ exports[`IconInputGroup has matching snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
5
5
|
<form
|
6
6
|
action="#"
|
7
|
+
class="envoc-form-form"
|
7
8
|
>
|
8
9
|
<div
|
9
|
-
class="icon-input-group input-group group"
|
10
|
+
class="envoc-form-icon-input-group envoc-form-input-group envoc-form-group"
|
10
11
|
>
|
11
12
|
<div
|
12
13
|
id="namewithicon-error-scroll-target"
|
@@ -19,7 +20,8 @@ exports[`IconInputGroup has matching snapshot 1`] = `
|
|
19
20
|
Pretend this is an icon
|
20
21
|
</span>
|
21
22
|
<input
|
22
|
-
class="icon-input-group input-group"
|
23
|
+
class="envoc-form-icon-input-group envoc-form-input-group"
|
24
|
+
id="nameWithIcon"
|
23
25
|
name="nameWithIcon"
|
24
26
|
value=""
|
25
27
|
/>
|
@@ -4,9 +4,10 @@ exports[`MoneyInputGroup has matching snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
5
5
|
<form
|
6
6
|
action="#"
|
7
|
+
class="envoc-form-form"
|
7
8
|
>
|
8
9
|
<div
|
9
|
-
class="something-here money-group input-group group"
|
10
|
+
class="something-here envoc-form-money-group envoc-form-input-group envoc-form-group"
|
10
11
|
>
|
11
12
|
<div
|
12
13
|
id="yearlysalaryusd-error-scroll-target"
|
@@ -18,7 +19,8 @@ exports[`MoneyInputGroup has matching snapshot 1`] = `
|
|
18
19
|
Salary
|
19
20
|
</label>
|
20
21
|
<input
|
21
|
-
class="something-here money-group input-group"
|
22
|
+
class="something-here envoc-form-money-group envoc-form-input-group"
|
23
|
+
id="yearlySalaryUSD"
|
22
24
|
min="0"
|
23
25
|
name="yearlySalaryUSD"
|
24
26
|
step="0.01"
|
@@ -4,9 +4,10 @@ exports[`NumberInputGroup has matching snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
5
5
|
<form
|
6
6
|
action="#"
|
7
|
+
class="envoc-form-form"
|
7
8
|
>
|
8
9
|
<div
|
9
|
-
class="number-group input-group group"
|
10
|
+
class="envoc-form-number-group envoc-form-input-group envoc-form-group"
|
10
11
|
>
|
11
12
|
<div
|
12
13
|
id="numberofarms-error-scroll-target"
|
@@ -18,7 +19,8 @@ exports[`NumberInputGroup has matching snapshot 1`] = `
|
|
18
19
|
Arm Count
|
19
20
|
</label>
|
20
21
|
<input
|
21
|
-
class="number-group input-group"
|
22
|
+
class="envoc-form-number-group envoc-form-input-group"
|
23
|
+
id="numberOfArms"
|
22
24
|
name="numberOfArms"
|
23
25
|
type="number"
|
24
26
|
value=""
|
@@ -4,9 +4,10 @@ exports[`StringInputGroup has matching snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
5
5
|
<form
|
6
6
|
action="#"
|
7
|
+
class="envoc-form-form"
|
7
8
|
>
|
8
9
|
<div
|
9
|
-
class="string-group input-group group"
|
10
|
+
class="envoc-form-string-group envoc-form-input-group envoc-form-group"
|
10
11
|
>
|
11
12
|
<div
|
12
13
|
id="name-error-scroll-target"
|
@@ -18,7 +19,8 @@ exports[`StringInputGroup has matching snapshot 1`] = `
|
|
18
19
|
Name
|
19
20
|
</label>
|
20
21
|
<input
|
21
|
-
class="string-group input-group"
|
22
|
+
class="envoc-form-string-group envoc-form-input-group"
|
23
|
+
id="name"
|
22
24
|
name="name"
|
23
25
|
value=""
|
24
26
|
/>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export const phoneNumber = (value: string | undefined) => {
|
1
|
+
export const phoneNumber = (value: string | undefined | null) => {
|
2
2
|
if (!value) {
|
3
3
|
return undefined;
|
4
4
|
}
|
@@ -30,7 +30,7 @@ export const phoneNumber = (value: string | undefined) => {
|
|
30
30
|
return onlyNums;
|
31
31
|
};
|
32
32
|
|
33
|
-
export const zipCode = (value: string | undefined) => {
|
33
|
+
export const zipCode = (value: string | undefined | null) => {
|
34
34
|
if (!value) {
|
35
35
|
return undefined;
|
36
36
|
}
|
@@ -13,7 +13,7 @@ const booleanOptions: SelectOption<boolean>[] = [
|
|
13
13
|
];
|
14
14
|
|
15
15
|
export interface BooleanSelectGroupProps
|
16
|
-
extends Omit<SelectGroupPropsHelper<boolean>, 'options'> {
|
16
|
+
extends Omit<SelectGroupPropsHelper<boolean | undefined | null>, 'options'> {
|
17
17
|
options?: SelectOption<boolean>[];
|
18
18
|
}
|
19
19
|
export function BooleanSelectGroup(props: BooleanSelectGroupProps) {
|
@@ -2,13 +2,13 @@ import SelectGroup from './SelectGroup';
|
|
2
2
|
import { SelectGroupPropsHelper } from './SelectGroupPropsHelper';
|
3
3
|
|
4
4
|
export interface MultiNumberSelectGroupProps
|
5
|
-
extends SelectGroupPropsHelper<number[]> {}
|
5
|
+
extends SelectGroupPropsHelper<number[] | undefined | null> {}
|
6
6
|
export function MultiNumberSelectGroup(props: MultiNumberSelectGroupProps) {
|
7
7
|
return <SelectGroup multiple={true} {...props} />;
|
8
8
|
}
|
9
9
|
|
10
10
|
export interface SingleNumberSelectGroupProps
|
11
|
-
extends SelectGroupPropsHelper<number> {}
|
11
|
+
extends SelectGroupPropsHelper<number | undefined | null> {}
|
12
12
|
export function SingleNumberSelectGroup(props: SingleNumberSelectGroupProps) {
|
13
13
|
return <SelectGroup multiple={false} {...props} />;
|
14
14
|
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { default as ReactSelect } from 'react-select';
|
2
2
|
import classNames from 'classnames';
|
3
3
|
import { InjectedFieldProps } from '../Field/InjectedFieldProps';
|
4
|
+
import { FormDefaults } from '../FormDefaults';
|
4
5
|
import Group, { GroupProps } from '../Group';
|
5
6
|
|
6
7
|
export interface SelectOption<TValue> {
|
@@ -22,7 +23,7 @@ interface OptionsUseServiceResult<TValue> {
|
|
22
23
|
}
|
23
24
|
|
24
25
|
export interface SelectGroupProps<TValue>
|
25
|
-
extends InjectedFieldProps<TValue | undefined>,
|
26
|
+
extends InjectedFieldProps<TValue | undefined | null>,
|
26
27
|
Omit<GroupProps, 'input' | 'meta' | 'children'> {
|
27
28
|
// allows for "useService" or other handles to control the data - including cache
|
28
29
|
// TODO: do we still want a version of select that has a "url" or maybe a promise func or something?
|
@@ -37,6 +38,8 @@ export default function SelectGroup<TValue>({
|
|
37
38
|
input,
|
38
39
|
meta,
|
39
40
|
className,
|
41
|
+
required,
|
42
|
+
disabled,
|
40
43
|
options,
|
41
44
|
multiple,
|
42
45
|
placeholder,
|
@@ -63,10 +66,15 @@ export default function SelectGroup<TValue>({
|
|
63
66
|
{...rest}
|
64
67
|
input={input}
|
65
68
|
meta={meta}
|
69
|
+
required={required}
|
70
|
+
disabled={disabled}
|
66
71
|
className={classNames(
|
67
72
|
className,
|
68
|
-
{
|
69
|
-
|
73
|
+
{
|
74
|
+
[FormDefaults.cssClassPrefix + 'multiple']: multiple,
|
75
|
+
[FormDefaults.cssClassPrefix + 'loading']: isLoading,
|
76
|
+
},
|
77
|
+
FormDefaults.cssClassPrefix + 'select-group'
|
70
78
|
)}>
|
71
79
|
<ReactSelect<
|
72
80
|
Partial<SelectOption<TValue>>,
|
@@ -74,6 +82,7 @@ export default function SelectGroup<TValue>({
|
|
74
82
|
>
|
75
83
|
inputId={input.id}
|
76
84
|
isMulti={multiple}
|
85
|
+
isDisabled={disabled}
|
77
86
|
options={effectiveOptions}
|
78
87
|
onBlur={input.onBlur}
|
79
88
|
value={getValue()}
|
@@ -85,7 +94,10 @@ export default function SelectGroup<TValue>({
|
|
85
94
|
}
|
86
95
|
}}
|
87
96
|
getOptionLabel={(option) => option?.label ?? ''}
|
88
|
-
className={classNames(
|
97
|
+
className={classNames(
|
98
|
+
className,
|
99
|
+
FormDefaults.cssClassPrefix + 'select-group'
|
100
|
+
)}
|
89
101
|
classNamePrefix="react-select"
|
90
102
|
menuPortalTarget={document.body}
|
91
103
|
menuPlacement="auto"
|
@@ -4,9 +4,10 @@ exports[`BooleanSelectGroup has matching snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
5
5
|
<form
|
6
6
|
action="#"
|
7
|
+
class="envoc-form-form"
|
7
8
|
>
|
8
9
|
<div
|
9
|
-
class="select-group group"
|
10
|
+
class="envoc-form-select-group envoc-form-group"
|
10
11
|
>
|
11
12
|
<div
|
12
13
|
id="allowlogin-error-scroll-target"
|
@@ -18,7 +19,7 @@ exports[`BooleanSelectGroup has matching snapshot 1`] = `
|
|
18
19
|
Allow Login
|
19
20
|
</label>
|
20
21
|
<div
|
21
|
-
class="select-group css-b62m3t-container"
|
22
|
+
class="envoc-form-select-group css-b62m3t-container"
|
22
23
|
>
|
23
24
|
<span
|
24
25
|
class="css-1f43avz-a11yText-A11yText"
|
@@ -4,9 +4,10 @@ exports[`MultiNumberSelectGroup has matching snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
5
5
|
<form
|
6
6
|
action="#"
|
7
|
+
class="envoc-form-form"
|
7
8
|
>
|
8
9
|
<div
|
9
|
-
class="multiple select-group group"
|
10
|
+
class="envoc-form-multiple envoc-form-select-group envoc-form-group"
|
10
11
|
>
|
11
12
|
<div
|
12
13
|
id="userroles-error-scroll-target"
|
@@ -18,7 +19,7 @@ exports[`MultiNumberSelectGroup has matching snapshot 1`] = `
|
|
18
19
|
Favorite Number
|
19
20
|
</label>
|
20
21
|
<div
|
21
|
-
class="select-group css-b62m3t-container"
|
22
|
+
class="envoc-form-select-group css-b62m3t-container"
|
22
23
|
>
|
23
24
|
<span
|
24
25
|
class="css-1f43avz-a11yText-A11yText"
|
@@ -102,9 +103,10 @@ exports[`SingleNumberSelectGroup has matching snapshot 1`] = `
|
|
102
103
|
<DocumentFragment>
|
103
104
|
<form
|
104
105
|
action="#"
|
106
|
+
class="envoc-form-form"
|
105
107
|
>
|
106
108
|
<div
|
107
|
-
class="select-group group"
|
109
|
+
class="envoc-form-select-group envoc-form-group"
|
108
110
|
>
|
109
111
|
<div
|
110
112
|
id="favoritenumber-error-scroll-target"
|
@@ -116,7 +118,7 @@ exports[`SingleNumberSelectGroup has matching snapshot 1`] = `
|
|
116
118
|
Favorite Number
|
117
119
|
</label>
|
118
120
|
<div
|
119
|
-
class="select-group css-b62m3t-container"
|
121
|
+
class="envoc-form-select-group css-b62m3t-container"
|
120
122
|
>
|
121
123
|
<span
|
122
124
|
class="css-1f43avz-a11yText-A11yText"
|
@@ -4,9 +4,10 @@ exports[`MultiStringSelectGroup has matching snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
5
5
|
<form
|
6
6
|
action="#"
|
7
|
+
class="envoc-form-form"
|
7
8
|
>
|
8
9
|
<div
|
9
|
-
class="multiple select-group group"
|
10
|
+
class="envoc-form-multiple envoc-form-select-group envoc-form-group"
|
10
11
|
>
|
11
12
|
<div
|
12
13
|
id="favoritecolors-error-scroll-target"
|
@@ -18,7 +19,7 @@ exports[`MultiStringSelectGroup has matching snapshot 1`] = `
|
|
18
19
|
Favorite Color
|
19
20
|
</label>
|
20
21
|
<div
|
21
|
-
class="select-group css-b62m3t-container"
|
22
|
+
class="envoc-form-select-group css-b62m3t-container"
|
22
23
|
>
|
23
24
|
<span
|
24
25
|
class="css-1f43avz-a11yText-A11yText"
|
@@ -102,9 +103,10 @@ exports[`SingleStringSelectGroup has matching snapshot 1`] = `
|
|
102
103
|
<DocumentFragment>
|
103
104
|
<form
|
104
105
|
action="#"
|
106
|
+
class="envoc-form-form"
|
105
107
|
>
|
106
108
|
<div
|
107
|
-
class="select-group group"
|
109
|
+
class="envoc-form-select-group envoc-form-group"
|
108
110
|
>
|
109
111
|
<div
|
110
112
|
id="favoritecolor-error-scroll-target"
|
@@ -116,7 +118,7 @@ exports[`SingleStringSelectGroup has matching snapshot 1`] = `
|
|
116
118
|
Favorite Color
|
117
119
|
</label>
|
118
120
|
<div
|
119
|
-
class="select-group css-b62m3t-container"
|
121
|
+
class="envoc-form-select-group css-b62m3t-container"
|
120
122
|
>
|
121
123
|
<span
|
122
124
|
class="css-1f43avz-a11yText-A11yText"
|
@@ -2,6 +2,7 @@ import { MouseEventHandler } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
3
3
|
import { useFormikContext } from 'formik';
|
4
4
|
import SubmitFormButton from './SubmitFormButton';
|
5
|
+
import { FormDefaults } from './FormDefaults';
|
5
6
|
|
6
7
|
export interface StandardFormActionsProps {
|
7
8
|
allowPristineSubmit?: boolean;
|
@@ -19,7 +20,9 @@ export default function StandardFormActions({
|
|
19
20
|
<SubmitFormButton allowPristineSubmit={allowPristineSubmit} />
|
20
21
|
|
21
22
|
<button
|
22
|
-
className={classNames(
|
23
|
+
className={classNames(
|
24
|
+
FormDefaults.cssClassPrefix + 'standard-form-actions-cancel-button'
|
25
|
+
)}
|
23
26
|
type="button"
|
24
27
|
disabled={isSubmitting}
|
25
28
|
onClick={handleCancel || goBack}>
|
package/src/SubmitFormButton.tsx
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
import React, { LegacyRef } from 'react';
|
2
2
|
import classNames from 'classnames';
|
3
3
|
import { useFormikContext } from 'formik';
|
4
|
+
import { FormDefaults } from './FormDefaults';
|
4
5
|
|
5
6
|
export interface SubmitFormButtonProps
|
6
7
|
extends Omit<React.HTMLProps<HTMLButtonElement>, 'type'> {
|
7
8
|
allowPristineSubmit?: boolean;
|
8
9
|
children?: React.ReactNode;
|
9
10
|
}
|
11
|
+
|
10
12
|
function SubmitFormButton(
|
11
13
|
{
|
12
14
|
allowPristineSubmit,
|
@@ -20,12 +22,14 @@ function SubmitFormButton(
|
|
20
22
|
) {
|
21
23
|
const { isSubmitting, dirty } = useFormikContext();
|
22
24
|
const preventSubmit = (!dirty && !allowPristineSubmit) || isSubmitting;
|
25
|
+
const buttonName = typeof children === 'string' ? children : 'Submit';
|
23
26
|
return (
|
24
27
|
<button
|
25
28
|
{...props}
|
26
29
|
ref={ref}
|
27
30
|
type="submit"
|
28
31
|
disabled={preventSubmit || disabled}
|
32
|
+
aria-label={buttonName}
|
29
33
|
title={
|
30
34
|
title || isSubmitting
|
31
35
|
? 'Loading, please wait...'
|
@@ -33,7 +37,10 @@ function SubmitFormButton(
|
|
33
37
|
? "You haven't made any changes"
|
34
38
|
: ''
|
35
39
|
}
|
36
|
-
className={classNames(
|
40
|
+
className={classNames(
|
41
|
+
FormDefaults.cssClassPrefix + 'submit-form-button',
|
42
|
+
className
|
43
|
+
)}>
|
37
44
|
{children || 'Submit'}
|
38
45
|
</button>
|
39
46
|
);
|
@@ -41,4 +48,4 @@ function SubmitFormButton(
|
|
41
48
|
|
42
49
|
export default React.forwardRef(
|
43
50
|
SubmitFormButton
|
44
|
-
) as React.
|
51
|
+
) as React.FunctionComponent<SubmitFormButtonProps>;
|
@@ -1,10 +1,11 @@
|
|
1
1
|
import React, { LegacyRef } from 'react';
|
2
2
|
import classNames from 'classnames';
|
3
3
|
import { InjectedFieldProps } from '../Field/InjectedFieldProps';
|
4
|
+
import { FormDefaults } from '../FormDefaults';
|
4
5
|
import Group, { GroupProps } from '../Group';
|
5
6
|
|
6
7
|
export interface TextAreaGroupProps
|
7
|
-
extends InjectedFieldProps<string | undefined>,
|
8
|
+
extends InjectedFieldProps<string | undefined | null>,
|
8
9
|
Omit<
|
9
10
|
React.HTMLProps<HTMLTextAreaElement>,
|
10
11
|
keyof InjectedFieldProps<any> | 'children' | 'className' | 'label'
|
@@ -21,6 +22,7 @@ function TextAreaGroup(
|
|
21
22
|
label,
|
22
23
|
helpText,
|
23
24
|
className,
|
25
|
+
required,
|
24
26
|
disabled,
|
25
27
|
icon,
|
26
28
|
...rest
|
@@ -31,18 +33,25 @@ function TextAreaGroup(
|
|
31
33
|
<Group
|
32
34
|
input={input}
|
33
35
|
meta={meta}
|
36
|
+
required={required}
|
34
37
|
disabled={disabled}
|
35
38
|
label={label}
|
36
39
|
helpText={helpText}
|
37
|
-
className={classNames(
|
40
|
+
className={classNames(
|
41
|
+
className,
|
42
|
+
FormDefaults.cssClassPrefix + 'text-area-group'
|
43
|
+
)}>
|
38
44
|
{icon}
|
39
45
|
<textarea
|
40
46
|
{...input}
|
41
47
|
{...rest}
|
42
|
-
value={input.value}
|
48
|
+
value={input.value ?? ''}
|
43
49
|
onChange={(val) => input.onChange(val.target.value)}
|
44
50
|
ref={ref}
|
45
|
-
className={classNames(
|
51
|
+
className={classNames(
|
52
|
+
className,
|
53
|
+
FormDefaults.cssClassPrefix + 'text-area-group'
|
54
|
+
)}
|
46
55
|
/>
|
47
56
|
</Group>
|
48
57
|
);
|
@@ -10,12 +10,13 @@ export const required = (value: any) =>
|
|
10
10
|
: 'Required';
|
11
11
|
|
12
12
|
//asserts that the value is a certain number of characters. numbers are coerced to a string
|
13
|
-
export const length =
|
14
|
-
|
15
|
-
|
16
|
-
}
|
13
|
+
export const length =
|
14
|
+
(len: number) => (value: string | number | undefined | null) => {
|
15
|
+
const hasError = getLengthOfValue(value) !== len;
|
16
|
+
return !hasError ? undefined : `Length must be ${len}`;
|
17
|
+
};
|
17
18
|
|
18
|
-
export const integer = (val: string | number | undefined) => {
|
19
|
+
export const integer = (val: string | number | undefined | null) => {
|
19
20
|
if (!val) {
|
20
21
|
return undefined;
|
21
22
|
}
|
@@ -25,35 +26,35 @@ export const integer = (val: string | number | undefined) => {
|
|
25
26
|
};
|
26
27
|
|
27
28
|
export const maxLength =
|
28
|
-
(len: number) => (value: string | number | undefined) => {
|
29
|
+
(len: number) => (value: string | number | undefined | null) => {
|
29
30
|
const hasError = getLengthOfValue(value) > len;
|
30
31
|
return !hasError ? undefined : `Maximum length ${len} exceeded`;
|
31
32
|
};
|
32
33
|
|
33
34
|
export const maxCount =
|
34
|
-
(count: number) => (value: { isDeleted?: boolean }[] | undefined) => {
|
35
|
+
(count: number) => (value: { isDeleted?: boolean }[] | undefined | null) => {
|
35
36
|
const hasError =
|
36
37
|
!!value && value.filter((x) => !x.isDeleted).length > count;
|
37
38
|
return !hasError ? undefined : `Should not have more than ${count}`;
|
38
39
|
};
|
39
40
|
|
40
41
|
export const minCount =
|
41
|
-
(count: number) => (value: { isDeleted?: boolean }[] | undefined) => {
|
42
|
+
(count: number) => (value: { isDeleted?: boolean }[] | undefined | null) => {
|
42
43
|
const hasError = !value || value.filter((x) => !x.isDeleted).length < count;
|
43
44
|
return !hasError ? undefined : `Should have at least ${count}`;
|
44
45
|
};
|
45
46
|
|
46
|
-
export const maxValue = (max: number) => (value: number | undefined) => {
|
47
|
+
export const maxValue = (max: number) => (value: number | undefined | null) => {
|
47
48
|
const hasError = !!value && value > max;
|
48
49
|
return !hasError ? undefined : `Maximum value ${max} exceeded`;
|
49
50
|
};
|
50
51
|
|
51
|
-
export const minValue = (min: number) => (value: number | undefined) => {
|
52
|
+
export const minValue = (min: number) => (value: number | undefined | null) => {
|
52
53
|
const hasError = !value || value < min;
|
53
54
|
return !hasError ? undefined : `Minimum value ${min} not met`;
|
54
55
|
};
|
55
56
|
|
56
|
-
export const zipCode = (value: string | undefined) => {
|
57
|
+
export const zipCode = (value: string | undefined | null) => {
|
57
58
|
return value && !/^[0-9]{5}(?:-[0-9]{4})?$/.test(value)
|
58
59
|
? 'Invalid ZIP Code'
|
59
60
|
: undefined;
|
@@ -73,7 +74,10 @@ export const any =
|
|
73
74
|
);
|
74
75
|
};
|
75
76
|
|
76
|
-
function getLengthOfValue(value: string | number | undefined) {
|
77
|
+
function getLengthOfValue(value: string | number | undefined | null) {
|
78
|
+
if (value === null) {
|
79
|
+
return 0;
|
80
|
+
}
|
77
81
|
switch (typeof value) {
|
78
82
|
case 'undefined':
|
79
83
|
return 0;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import '@testing-library/jest-dom/extend-expect';
|
2
2
|
import { HashRouter } from 'react-router-dom';
|
3
|
-
import {
|
4
|
-
import {
|
3
|
+
import { Form, FormBuilderProp } from '../';
|
4
|
+
import { ValidatedApiResult } from '../Validation/ValidatedApiResult';
|
5
5
|
|
6
6
|
interface FormTestBaseProps<TForm extends object> {
|
7
7
|
children: (formBuilder: FormBuilderProp<TForm>) => JSX.Element;
|
@@ -50,8 +50,8 @@ interface PersonDto {
|
|
50
50
|
phoneNumber?: string;
|
51
51
|
yearlySalaryUSD?: number;
|
52
52
|
isCool?: boolean;
|
53
|
-
gradDate?:
|
54
|
-
favoriteDate?:
|
53
|
+
gradDate?: string;
|
54
|
+
favoriteDate?: string;
|
55
55
|
favoriteNumber?: number;
|
56
56
|
favoriteColor?: string;
|
57
57
|
favoriteColors?: string[];
|
@@ -4,9 +4,11 @@ exports[`StandardFormActions has matching snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
5
5
|
<form
|
6
6
|
action="#"
|
7
|
+
class="envoc-form-form"
|
7
8
|
>
|
8
9
|
<button
|
9
|
-
|
10
|
+
aria-label="Submit"
|
11
|
+
class="envoc-form-submit-form-button"
|
10
12
|
disabled=""
|
11
13
|
title="You haven't made any changes"
|
12
14
|
type="submit"
|
@@ -15,7 +17,7 @@ exports[`StandardFormActions has matching snapshot 1`] = `
|
|
15
17
|
</button>
|
16
18
|
|
17
19
|
<button
|
18
|
-
class="standard-form-actions-cancel-button"
|
20
|
+
class="envoc-form-standard-form-actions-cancel-button"
|
19
21
|
type="button"
|
20
22
|
>
|
21
23
|
Cancel
|
@@ -4,9 +4,11 @@ exports[`SubmitFormButton has matching snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
5
5
|
<form
|
6
6
|
action="#"
|
7
|
+
class="envoc-form-form"
|
7
8
|
>
|
8
9
|
<button
|
9
|
-
|
10
|
+
aria-label="Submit"
|
11
|
+
class="envoc-form-submit-form-button"
|
10
12
|
disabled=""
|
11
13
|
title="You haven't made any changes"
|
12
14
|
type="submit"
|
package/src/index.ts
CHANGED
@@ -16,19 +16,17 @@ export type { ConfirmDeleteFormProps } from './ConfirmDeleteForm/ConfirmDeleteFo
|
|
16
16
|
|
17
17
|
// Date
|
18
18
|
export { default as DatePickerGroup } from './DatePicker/DatePickerGroup';
|
19
|
-
export type { DatePickerGroupProps
|
19
|
+
export type { DatePickerGroupProps } from './DatePicker/DatePickerGroup';
|
20
|
+
export { convertToTimeZoneInsensitiveISOString } from './DatePicker/DatePickerGroup';
|
20
21
|
|
21
22
|
export type { DatePickerHelper } from './DatePicker/DatePickerHelper';
|
22
23
|
|
23
|
-
export { default as DateOnlyDatePickerGroup } from './DatePicker/DateOnlyDatePickerGroup';
|
24
|
-
export type {
|
25
|
-
DateOnly,
|
26
|
-
DateOnlyDatePickerGroupProps,
|
27
|
-
} from './DatePicker/DateOnlyDatePickerGroup';
|
28
|
-
|
29
24
|
export { default as StringDatePickerGroup } from './DatePicker/StringDatePickerGroup';
|
30
25
|
export type { StringDatePickerGroupProps } from './DatePicker/StringDatePickerGroup';
|
31
26
|
|
27
|
+
export { default as StringDateOnlyPickerGroup } from './DatePicker/StringDateOnlyPickerGroup';
|
28
|
+
export type { StringDateOnlyPickerGroupProps } from './DatePicker/StringDateOnlyPickerGroup';
|
29
|
+
|
32
30
|
// Field
|
33
31
|
export { default as Field } from './Field/Field';
|
34
32
|
export type { FieldProps } from './Field/Field';
|
@@ -70,14 +68,17 @@ export type {
|
|
70
68
|
} from './Form/ServerErrorContext';
|
71
69
|
|
72
70
|
export { default as FormActions } from './FormActions';
|
73
|
-
export type { FormActionsProps
|
71
|
+
export type { FormActionsProps } from './FormActions';
|
74
72
|
|
75
73
|
export { default as StandardFormActions } from './StandardFormActions';
|
76
|
-
export type { StandardFormActionsProps
|
74
|
+
export type { StandardFormActionsProps } from './StandardFormActions';
|
75
|
+
|
76
|
+
// FormDefaults
|
77
|
+
export { FormDefaults } from './FormDefaults';
|
77
78
|
|
78
79
|
// Input
|
79
80
|
export { default as Group } from './Group';
|
80
|
-
export type { GroupProps
|
81
|
+
export type { GroupProps } from './Group';
|
81
82
|
|
82
83
|
export { default as IconInputGroup } from './Input/IconInputGroup';
|
83
84
|
export type { IconInputGroupProps } from './Input/IconInputGroup';
|
@@ -1,10 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
import { DatePickerHelper } from './DatePickerHelper';
|
3
|
-
export interface DateOnly {
|
4
|
-
year?: number;
|
5
|
-
month?: number;
|
6
|
-
day?: number;
|
7
|
-
}
|
8
|
-
export interface DateOnlyDatePickerGroupProps extends DatePickerHelper<DateOnly | undefined> {
|
9
|
-
}
|
10
|
-
export default function DateOnlyDatePickerGroup(props: DateOnlyDatePickerGroupProps): JSX.Element;
|