envoc-form 4.0.1-9 → 5.0.1
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 +5173 -12
- package/es/AddressInput/AddressInput.d.ts +24 -15
- package/es/AddressInput/AddressInput.js +20 -21
- package/es/AddressInput/UsStates.d.ts +3 -3
- package/es/AddressInput/UsStates.js +53 -53
- package/es/ConfirmBaseForm/ConfirmBaseForm.d.ts +26 -12
- package/es/ConfirmBaseForm/ConfirmBaseForm.js +42 -36
- package/es/ConfirmDeleteForm/ConfirmDeleteForm.d.ts +24 -11
- package/es/ConfirmDeleteForm/ConfirmDeleteForm.js +60 -55
- package/es/DatePicker/DatePickerGroup.d.ts +13 -9
- package/es/DatePicker/DatePickerGroup.js +87 -77
- package/es/DatePicker/DatePickerHelper.d.ts +3 -3
- package/es/DatePicker/DatePickerHelper.js +1 -1
- package/es/DatePicker/StringDateOnlyPickerGroup.d.ts +9 -5
- package/es/DatePicker/StringDateOnlyPickerGroup.js +29 -24
- package/es/DatePicker/StringDatePickerGroup.d.ts +9 -5
- package/es/DatePicker/StringDatePickerGroup.js +24 -19
- package/es/Field/CustomFieldInputProps.d.ts +7 -7
- package/es/Field/CustomFieldInputProps.js +1 -1
- package/es/Field/CustomFieldMetaProps.d.ts +4 -4
- package/es/Field/CustomFieldMetaProps.js +1 -1
- package/es/Field/Field.d.ts +28 -22
- package/es/Field/Field.js +51 -46
- package/es/Field/FieldErrorScrollTarget.d.ts +2 -2
- package/es/Field/FieldErrorScrollTarget.js +12 -11
- package/es/Field/FieldNameContext.d.ts +3 -3
- package/es/Field/FieldNameContext.js +3 -3
- package/es/Field/FieldSection.d.ts +7 -7
- package/es/Field/FieldSection.js +9 -20
- package/es/Field/InjectedFieldProps.d.ts +7 -7
- package/es/Field/InjectedFieldProps.js +1 -1
- package/es/Field/StandAloneInput.d.ts +13 -9
- package/es/Field/StandAloneInput.js +50 -49
- package/es/Field/useStandardField.d.ts +21 -15
- package/es/Field/useStandardField.js +92 -93
- package/es/FieldArray/FieldArray.d.ts +24 -15
- package/es/FieldArray/FieldArray.js +77 -83
- package/es/File/FileGroup.d.ts +10 -8
- package/es/File/FileGroup.js +53 -52
- package/es/File/FileList.d.ts +5 -6
- package/es/File/FileList.js +10 -21
- package/es/File/humanFileSize.d.ts +1 -1
- package/es/File/humanFileSize.js +6 -6
- package/es/Form/FocusError.d.ts +7 -5
- package/es/Form/FocusError.js +42 -41
- package/es/Form/Form.d.ts +33 -27
- package/es/Form/Form.js +141 -140
- package/es/Form/FormBasedPreventNavigation.d.ts +6 -5
- package/es/Form/FormBasedPreventNavigation.js +20 -53
- package/es/Form/LegacyFormBasedPreventNavigation.d.ts +17 -0
- package/es/Form/LegacyFormBasedPreventNavigation.js +69 -0
- package/es/Form/NewFormBasedPreventNavigation.d.ts +14 -0
- package/es/Form/NewFormBasedPreventNavigation.js +39 -0
- package/es/Form/ServerErrorContext.d.ts +11 -10
- package/es/Form/ServerErrorContext.js +9 -8
- package/es/FormActions.d.ts +12 -7
- package/es/FormActions.js +16 -26
- package/es/FormDefaults.d.ts +4 -3
- package/es/FormDefaults.js +2 -1
- package/es/Group.d.ts +16 -13
- package/es/Group.js +14 -24
- package/es/Input/IconInputGroup.d.ts +12 -9
- package/es/Input/IconInputGroup.js +43 -41
- package/es/Input/InputGroup.d.ts +12 -12
- package/es/Input/InputGroup.js +34 -34
- package/es/Input/MoneyInputGroup.d.ts +9 -7
- package/es/Input/MoneyInputGroup.js +43 -42
- package/es/Input/NumberInputGroup.d.ts +9 -7
- package/es/Input/NumberInputGroup.js +43 -42
- package/es/Input/StringInputGroup.d.ts +8 -7
- package/es/Input/StringInputGroup.js +43 -41
- package/es/Normalization/NormalizationFunction.d.ts +4 -4
- package/es/Normalization/NormalizationFunction.js +1 -1
- package/es/Normalization/normalizers.d.ts +4 -2
- package/es/Normalization/normalizers.js +32 -30
- package/es/Select/BooleanSelectGroup.d.ts +7 -7
- package/es/Select/BooleanSelectGroup.js +28 -27
- package/es/Select/NumberSelectGroup.d.ts +9 -8
- package/es/Select/NumberSelectGroup.js +21 -19
- package/es/Select/SelectGroup.d.ts +27 -22
- package/es/Select/SelectGroup.js +65 -64
- package/es/Select/SelectGroupPropsHelper.d.ts +3 -3
- package/es/Select/SelectGroupPropsHelper.js +1 -1
- package/es/Select/StringSelectGroup.d.ts +9 -8
- package/es/Select/StringSelectGroup.js +21 -19
- package/es/StandardFormActions.d.ts +11 -6
- package/es/StandardFormActions.js +14 -24
- package/es/SubmitFormButton.d.ts +10 -7
- package/es/SubmitFormButton.js +40 -39
- package/es/TextArea/TextAreaGroup.d.ts +9 -8
- package/es/TextArea/TextAreaGroup.js +35 -34
- package/es/Validation/ValidatedApiResult.d.ts +6 -6
- package/es/Validation/ValidatedApiResult.js +1 -1
- package/es/Validation/ValidationError.d.ts +5 -5
- package/es/Validation/ValidationError.js +1 -1
- package/es/Validation/ValidationFunction.d.ts +4 -4
- package/es/Validation/ValidationFunction.js +1 -1
- package/es/Validation/validators.d.ts +18 -15
- package/es/Validation/validators.js +77 -73
- package/es/index.d.ts +73 -73
- package/es/index.js +50 -50
- package/es/setupTests.d.ts +1 -0
- package/es/setupTests.js +1 -0
- package/es/utils/objectContainsNonSerializableProperty.d.ts +1 -1
- package/es/utils/objectContainsNonSerializableProperty.js +14 -14
- package/es/utils/objectToFormData.d.ts +10 -10
- package/es/utils/objectToFormData.js +77 -77
- package/es/utils/typeChecks.d.ts +8 -8
- package/es/utils/typeChecks.js +18 -18
- package/lib/AddressInput/AddressInput.d.ts +24 -15
- package/lib/AddressInput/AddressInput.js +26 -27
- package/lib/AddressInput/UsStates.d.ts +3 -3
- package/lib/AddressInput/UsStates.js +55 -55
- package/lib/ConfirmBaseForm/ConfirmBaseForm.d.ts +26 -12
- package/lib/ConfirmBaseForm/ConfirmBaseForm.js +48 -42
- package/lib/ConfirmDeleteForm/ConfirmDeleteForm.d.ts +24 -11
- package/lib/ConfirmDeleteForm/ConfirmDeleteForm.js +66 -61
- package/lib/DatePicker/DatePickerGroup.d.ts +13 -9
- package/lib/DatePicker/DatePickerGroup.js +95 -85
- package/lib/DatePicker/DatePickerHelper.d.ts +3 -3
- package/lib/DatePicker/DatePickerHelper.js +2 -2
- package/lib/DatePicker/StringDateOnlyPickerGroup.d.ts +9 -5
- package/lib/DatePicker/StringDateOnlyPickerGroup.js +35 -30
- package/lib/DatePicker/StringDatePickerGroup.d.ts +9 -5
- package/lib/DatePicker/StringDatePickerGroup.js +30 -25
- package/lib/Field/CustomFieldInputProps.d.ts +7 -7
- package/lib/Field/CustomFieldInputProps.js +2 -2
- package/lib/Field/CustomFieldMetaProps.d.ts +4 -4
- package/lib/Field/CustomFieldMetaProps.js +2 -2
- package/lib/Field/Field.d.ts +28 -22
- package/lib/Field/Field.js +56 -51
- package/lib/Field/FieldErrorScrollTarget.d.ts +2 -2
- package/lib/Field/FieldErrorScrollTarget.js +15 -14
- package/lib/Field/FieldNameContext.d.ts +3 -3
- package/lib/Field/FieldNameContext.js +9 -9
- package/lib/Field/FieldSection.d.ts +7 -7
- package/lib/Field/FieldSection.js +12 -23
- package/lib/Field/InjectedFieldProps.d.ts +7 -7
- package/lib/Field/InjectedFieldProps.js +2 -2
- package/lib/Field/StandAloneInput.d.ts +13 -9
- package/lib/Field/StandAloneInput.js +76 -75
- package/lib/Field/useStandardField.d.ts +21 -15
- package/lib/Field/useStandardField.js +95 -96
- package/lib/FieldArray/FieldArray.d.ts +24 -15
- package/lib/FieldArray/FieldArray.js +83 -89
- package/lib/File/FileGroup.d.ts +10 -8
- package/lib/File/FileGroup.js +58 -57
- package/lib/File/FileList.d.ts +5 -6
- package/lib/File/FileList.js +13 -24
- package/lib/File/humanFileSize.d.ts +1 -1
- package/lib/File/humanFileSize.js +10 -10
- package/lib/Form/FocusError.d.ts +7 -5
- package/lib/Form/FocusError.js +48 -47
- package/lib/Form/Form.d.ts +33 -27
- package/lib/Form/Form.js +147 -146
- package/lib/Form/FormBasedPreventNavigation.d.ts +6 -5
- package/lib/Form/FormBasedPreventNavigation.js +26 -56
- package/lib/Form/LegacyFormBasedPreventNavigation.d.ts +17 -0
- package/lib/Form/LegacyFormBasedPreventNavigation.js +72 -0
- package/lib/Form/NewFormBasedPreventNavigation.d.ts +14 -0
- package/lib/Form/NewFormBasedPreventNavigation.js +42 -0
- package/lib/Form/ServerErrorContext.d.ts +11 -10
- package/lib/Form/ServerErrorContext.js +15 -14
- package/lib/FormActions.d.ts +12 -7
- package/lib/FormActions.js +22 -32
- package/lib/FormDefaults.d.ts +4 -3
- package/lib/FormDefaults.js +5 -4
- package/lib/Group.d.ts +16 -13
- package/lib/Group.js +20 -30
- package/lib/Input/IconInputGroup.d.ts +12 -9
- package/lib/Input/IconInputGroup.js +48 -46
- package/lib/Input/InputGroup.d.ts +12 -12
- package/lib/Input/InputGroup.js +39 -39
- package/lib/Input/MoneyInputGroup.d.ts +9 -7
- package/lib/Input/MoneyInputGroup.js +48 -47
- package/lib/Input/NumberInputGroup.d.ts +9 -7
- package/lib/Input/NumberInputGroup.js +48 -47
- package/lib/Input/StringInputGroup.d.ts +8 -7
- package/lib/Input/StringInputGroup.js +48 -46
- package/lib/Normalization/NormalizationFunction.d.ts +4 -4
- package/lib/Normalization/NormalizationFunction.js +2 -2
- package/lib/Normalization/normalizers.d.ts +4 -2
- package/lib/Normalization/normalizers.js +37 -35
- package/lib/Select/BooleanSelectGroup.d.ts +7 -7
- package/lib/Select/BooleanSelectGroup.js +35 -34
- package/lib/Select/NumberSelectGroup.d.ts +9 -8
- package/lib/Select/NumberSelectGroup.js +29 -27
- package/lib/Select/SelectGroup.d.ts +27 -22
- package/lib/Select/SelectGroup.js +71 -70
- package/lib/Select/SelectGroupPropsHelper.d.ts +3 -3
- package/lib/Select/SelectGroupPropsHelper.js +2 -2
- package/lib/Select/StringSelectGroup.d.ts +9 -8
- package/lib/Select/StringSelectGroup.js +29 -27
- package/lib/StandardFormActions.d.ts +11 -6
- package/lib/StandardFormActions.js +20 -30
- package/lib/SubmitFormButton.d.ts +10 -7
- package/lib/SubmitFormButton.js +45 -44
- package/lib/TextArea/TextAreaGroup.d.ts +9 -8
- package/lib/TextArea/TextAreaGroup.js +40 -39
- package/lib/Validation/ValidatedApiResult.d.ts +6 -6
- package/lib/Validation/ValidatedApiResult.js +2 -2
- package/lib/Validation/ValidationError.d.ts +5 -5
- package/lib/Validation/ValidationError.js +2 -2
- package/lib/Validation/ValidationFunction.d.ts +4 -4
- package/lib/Validation/ValidationFunction.js +2 -2
- package/lib/Validation/validators.d.ts +18 -15
- package/lib/Validation/validators.js +90 -86
- package/lib/index.d.ts +73 -73
- package/lib/index.js +117 -117
- package/lib/setupTests.d.ts +1 -0
- package/lib/setupTests.js +3 -0
- package/lib/utils/objectContainsNonSerializableProperty.d.ts +1 -1
- package/lib/utils/objectContainsNonSerializableProperty.js +17 -17
- package/lib/utils/objectToFormData.d.ts +10 -10
- package/lib/utils/objectToFormData.js +79 -79
- package/lib/utils/typeChecks.d.ts +8 -8
- package/lib/utils/typeChecks.js +29 -29
- package/package.json +14 -11
- package/src/AddressInput/AddressInput.tsx +15 -5
- package/src/AddressInput/__snapshots__/AddressInput.test.tsx.snap +14 -12
- package/src/ConfirmBaseForm/ConfirmBaseForm.tsx +14 -0
- package/src/ConfirmDeleteForm/ConfirmDeleteForm.tsx +13 -0
- package/src/DatePicker/DatePicker.test.tsx +1 -1
- package/src/DatePicker/DatePickerGroup.tsx +18 -7
- package/src/DatePicker/StringDateOnlyPickerGroup.tsx +7 -2
- package/src/DatePicker/StringDatePickerGroup.tsx +7 -1
- package/src/Field/Field.tsx +20 -7
- package/src/Field/FieldErrorScrollTarget.tsx +1 -0
- package/src/Field/StandAloneInput.tsx +4 -0
- package/src/Field/useStandardField.ts +13 -9
- package/src/FieldArray/FieldArray.tsx +14 -5
- package/src/File/FileGroup.tsx +9 -3
- package/src/File/FileList.tsx +2 -2
- package/src/Form/FocusError.tsx +3 -0
- package/src/Form/Form.tsx +6 -0
- package/src/Form/FormBasedPreventNavigation.tsx +28 -46
- package/src/Form/LegacyFormBasedPreventNavigation.tsx +77 -0
- package/src/Form/NewFormBasedPreventNavigation.tsx +59 -0
- package/src/Form/ServerErrorContext.ts +1 -0
- package/src/FormActions.tsx +7 -0
- package/src/FormDefaults.ts +1 -0
- package/src/Group.tsx +12 -4
- package/src/Input/IconInputGroup.tsx +5 -2
- package/src/Input/InputGroup.tsx +13 -5
- package/src/Input/MoneyInputGroup.tsx +3 -1
- package/src/Input/NumberInputGroup.tsx +3 -1
- package/src/Input/StringInputGroup.tsx +3 -2
- package/src/Input/__Tests__/__snapshots__/IconInputGroup.test.tsx.snap +1 -0
- package/src/Input/__Tests__/__snapshots__/MoneyInputGroup.test.tsx.snap +1 -0
- package/src/Input/__Tests__/__snapshots__/NumberInputGroup.test.tsx.snap +1 -0
- package/src/Input/__Tests__/__snapshots__/StringInputGroup.test.tsx.snap +1 -0
- package/src/Normalization/normalizers.ts +4 -2
- package/src/Select/BooleanSelectGroup.tsx +2 -1
- package/src/Select/NumberSelectGroup.tsx +4 -2
- package/src/Select/SelectGroup.tsx +13 -2
- package/src/Select/StringSelectGroup.tsx +2 -0
- package/src/Select/__tests__/__snapshots__/BooleanSelectGroup.test.tsx.snap +6 -8
- package/src/Select/__tests__/__snapshots__/NumberSelectGroup.test.tsx.snap +12 -16
- package/src/Select/__tests__/__snapshots__/StringSelectGroup.test.tsx.snap +12 -16
- package/src/StandardFormActions.tsx +5 -0
- package/src/SubmitFormButton.tsx +5 -1
- package/src/TextArea/TextAreaGroup.tsx +6 -4
- package/src/Validation/validators.ts +19 -14
- package/src/__Tests__/FormTestBase.tsx +9 -8
- package/src/__Tests__/RealisticForm.test.tsx +82 -0
- package/src/index.ts +4 -4
- package/src/setupTests.ts +1 -0
- package/src/utils/objectToFormData.test.tsx +1 -1
- package/es/__Tests__/FormTestBase.d.ts +0 -27
- package/es/__Tests__/FormTestBase.js +0 -83
- package/es/__Tests__/index.d.ts +0 -2
- package/es/__Tests__/index.js +0 -2
- package/lib/__Tests__/FormTestBase.d.ts +0 -27
- package/lib/__Tests__/FormTestBase.js +0 -86
- package/lib/__Tests__/index.d.ts +0 -2
- package/lib/__Tests__/index.js +0 -8
@@ -16,13 +16,23 @@ export interface AddressInputProps {
|
|
16
16
|
}
|
17
17
|
|
18
18
|
interface AddressDto {
|
19
|
-
address1?: string;
|
20
|
-
address2?: string;
|
21
|
-
zipCode?: string;
|
22
|
-
city?: string;
|
23
|
-
state?: string;
|
19
|
+
address1?: string | null;
|
20
|
+
address2?: string | null;
|
21
|
+
zipCode?: string | null;
|
22
|
+
city?: string | null;
|
23
|
+
state?: string | null;
|
24
24
|
}
|
25
25
|
|
26
|
+
/**
|
27
|
+
* Collection of `<Field/>`s for inputting an address. Includes:
|
28
|
+
* ```txt
|
29
|
+
* Address 1
|
30
|
+
* Address 2
|
31
|
+
* City
|
32
|
+
* State
|
33
|
+
* Zip
|
34
|
+
* ```
|
35
|
+
*/
|
26
36
|
export default function AddressInput({
|
27
37
|
fieldBuilder: { Field },
|
28
38
|
name,
|
@@ -7,7 +7,7 @@ exports[`AddressInput has matching snapshot 1`] = `
|
|
7
7
|
class="envoc-form-form"
|
8
8
|
>
|
9
9
|
<div
|
10
|
-
class="envoc-form-string-group envoc-form-input-group envoc-form-group"
|
10
|
+
class="envoc-form-string-group envoc-form-input-group envoc-form-group envoc-form-required"
|
11
11
|
>
|
12
12
|
<div
|
13
13
|
id="normaladdressinput.address1-error-scroll-target"
|
@@ -19,6 +19,7 @@ exports[`AddressInput has matching snapshot 1`] = `
|
|
19
19
|
Address 1
|
20
20
|
</label>
|
21
21
|
<input
|
22
|
+
aria-invalid="false"
|
22
23
|
class="envoc-form-string-group envoc-form-input-group"
|
23
24
|
id="normalAddressInput.address1"
|
24
25
|
name="normalAddressInput.address1"
|
@@ -39,6 +40,7 @@ exports[`AddressInput has matching snapshot 1`] = `
|
|
39
40
|
Address 2
|
40
41
|
</label>
|
41
42
|
<input
|
43
|
+
aria-invalid="false"
|
42
44
|
class="envoc-form-string-group envoc-form-input-group"
|
43
45
|
id="normalAddressInput.address2"
|
44
46
|
name="normalAddressInput.address2"
|
@@ -47,7 +49,7 @@ exports[`AddressInput has matching snapshot 1`] = `
|
|
47
49
|
/>
|
48
50
|
</div>
|
49
51
|
<div
|
50
|
-
class="envoc-form-string-group envoc-form-input-group envoc-form-group"
|
52
|
+
class="envoc-form-string-group envoc-form-input-group envoc-form-group envoc-form-required"
|
51
53
|
>
|
52
54
|
<div
|
53
55
|
id="normaladdressinput.city-error-scroll-target"
|
@@ -59,6 +61,7 @@ exports[`AddressInput has matching snapshot 1`] = `
|
|
59
61
|
City
|
60
62
|
</label>
|
61
63
|
<input
|
64
|
+
aria-invalid="false"
|
62
65
|
class="envoc-form-string-group envoc-form-input-group"
|
63
66
|
id="normalAddressInput.city"
|
64
67
|
name="normalAddressInput.city"
|
@@ -67,7 +70,7 @@ exports[`AddressInput has matching snapshot 1`] = `
|
|
67
70
|
/>
|
68
71
|
</div>
|
69
72
|
<div
|
70
|
-
class="envoc-form-select-group envoc-form-group"
|
73
|
+
class="envoc-form-select-group envoc-form-group envoc-form-required"
|
71
74
|
>
|
72
75
|
<div
|
73
76
|
id="normaladdressinput.state-error-scroll-target"
|
@@ -92,28 +95,26 @@ exports[`AddressInput has matching snapshot 1`] = `
|
|
92
95
|
class="css-1f43avz-a11yText-A11yText"
|
93
96
|
/>
|
94
97
|
<div
|
95
|
-
class="react-select__control css-
|
98
|
+
class="react-select__control css-13cymwt-control"
|
96
99
|
>
|
97
100
|
<div
|
98
|
-
class="react-select__value-container css-
|
101
|
+
class="react-select__value-container css-16674sh-Component"
|
99
102
|
>
|
100
103
|
<div
|
101
|
-
class="react-select__placeholder css-
|
104
|
+
class="react-select__placeholder css-1jqq78o-placeholder"
|
102
105
|
id="react-select-3-placeholder"
|
103
106
|
>
|
104
107
|
State
|
105
108
|
</div>
|
106
109
|
<div
|
107
|
-
class="react-select__input-container css-
|
110
|
+
class="react-select__input-container css-d9r47t-Component"
|
108
111
|
data-value=""
|
109
112
|
>
|
110
113
|
<input
|
111
114
|
aria-autocomplete="list"
|
112
|
-
aria-controls="react-select-3-listbox"
|
113
115
|
aria-describedby="react-select-3-placeholder"
|
114
116
|
aria-expanded="false"
|
115
117
|
aria-haspopup="true"
|
116
|
-
aria-owns="react-select-3-listbox"
|
117
118
|
autocapitalize="none"
|
118
119
|
autocomplete="off"
|
119
120
|
autocorrect="off"
|
@@ -132,11 +133,11 @@ exports[`AddressInput has matching snapshot 1`] = `
|
|
132
133
|
class="react-select__indicators css-ny0e4k-Component"
|
133
134
|
>
|
134
135
|
<span
|
135
|
-
class="react-select__indicator-separator css-
|
136
|
+
class="react-select__indicator-separator css-1u9des2-indicatorSeparator"
|
136
137
|
/>
|
137
138
|
<div
|
138
139
|
aria-hidden="true"
|
139
|
-
class="react-select__indicator react-select__dropdown-indicator css-
|
140
|
+
class="react-select__indicator react-select__dropdown-indicator css-1xc3v61-indicatorContainer"
|
140
141
|
>
|
141
142
|
<svg
|
142
143
|
aria-hidden="true"
|
@@ -156,7 +157,7 @@ exports[`AddressInput has matching snapshot 1`] = `
|
|
156
157
|
</div>
|
157
158
|
</div>
|
158
159
|
<div
|
159
|
-
class="envoc-form-string-group envoc-form-input-group envoc-form-group"
|
160
|
+
class="envoc-form-string-group envoc-form-input-group envoc-form-group envoc-form-required"
|
160
161
|
>
|
161
162
|
<div
|
162
163
|
id="normaladdressinput.zipcode-error-scroll-target"
|
@@ -168,6 +169,7 @@ exports[`AddressInput has matching snapshot 1`] = `
|
|
168
169
|
Zip
|
169
170
|
</label>
|
170
171
|
<input
|
172
|
+
aria-invalid="false"
|
171
173
|
class="envoc-form-string-group envoc-form-input-group"
|
172
174
|
id="normalAddressInput.zipCode"
|
173
175
|
name="normalAddressInput.zipCode"
|
@@ -6,16 +6,30 @@ import { FormDefaults } from '../FormDefaults';
|
|
6
6
|
// TODO: change the style prop type to Tailwind type (does this exist before Tailwind 3.1 ???), or
|
7
7
|
// should this just be type 'string'
|
8
8
|
export interface ConfirmBaseFormProps {
|
9
|
+
/** Function to run when cancel button is clicked. */
|
9
10
|
handleCancel?: MouseEventHandler<HTMLButtonElement>;
|
11
|
+
/** Axios request upon confirmation */
|
10
12
|
request: useAxiosRequestProps;
|
11
13
|
style?: React.CSSProperties;
|
14
|
+
/** `<h3/>` title text on top of the form. */
|
12
15
|
title?: string;
|
16
|
+
/** Custom confirm button text.
|
17
|
+
* @defaultValue `Confirm`
|
18
|
+
*/
|
13
19
|
confirmButtonText?: string;
|
20
|
+
/** CSS class for the buttons. */
|
14
21
|
confirmButtonClass?: string;
|
22
|
+
/** Any components to be rendered in between the title and the buttons. */
|
15
23
|
children?: React.ReactNode;
|
16
24
|
}
|
17
25
|
|
18
26
|
// TODO: ask about how we should use 'children'
|
27
|
+
/**
|
28
|
+
* Confimation dialog. Navigates to a different route to allow the user to either confirm or cancel an action.
|
29
|
+
* Commonly used for confirming delete and archive.
|
30
|
+
*
|
31
|
+
* See `<ConfirmDeleteForm/>` if the confirmation is specifically for deletion.
|
32
|
+
*/
|
19
33
|
export default function ConfirmBaseForm({
|
20
34
|
handleCancel,
|
21
35
|
request,
|
@@ -9,14 +9,27 @@ import { FormDefaults } from '../FormDefaults';
|
|
9
9
|
|
10
10
|
export interface ConfirmDeleteFormProps
|
11
11
|
extends Pick<ConfirmBaseFormProps, 'style'> {
|
12
|
+
/** Url to navigate to on success. */
|
12
13
|
successUrl?: string;
|
14
|
+
/** Form name (key) to apply the confirmation on. */
|
13
15
|
form: string;
|
16
|
+
/** Custom message to display.
|
17
|
+
* @defaultValue `Are you sure you want to delete this?`
|
18
|
+
*/
|
14
19
|
title?: string;
|
20
|
+
/** Custom function when the axios request succeeds. */
|
15
21
|
handleComplete?: Function;
|
22
|
+
/** Custom function when the axios request fails. */
|
16
23
|
handleError?: Function;
|
24
|
+
/** Any components to be rendered in between the title and the buttons. */
|
17
25
|
children?: React.ReactNode;
|
18
26
|
}
|
19
27
|
|
28
|
+
/**
|
29
|
+
* Deletion confirmation. Navigates to a different route to allow the user to either confirm or cancel an action.
|
30
|
+
*
|
31
|
+
* Wraps `<ConfirmBaseForm/>`.
|
32
|
+
*/
|
20
33
|
export default function ConfirmDeleteForm({
|
21
34
|
successUrl,
|
22
35
|
form,
|
@@ -4,7 +4,7 @@ import StringDatePickerGroup from './StringDatePickerGroup';
|
|
4
4
|
import FormTestBase from '../__Tests__/FormTestBase';
|
5
5
|
|
6
6
|
//hack so the datepicker internals don't complain about this not existing in the context of jest
|
7
|
-
HTMLCanvasElement.prototype.getContext = () =>
|
7
|
+
HTMLCanvasElement.prototype.getContext = () => null;
|
8
8
|
|
9
9
|
describe('IconInputGroup', () => {
|
10
10
|
it('renders without crashing', () => {
|
@@ -1,15 +1,15 @@
|
|
1
1
|
import { useEffect, useState } from 'react';
|
2
|
-
import DatePicker, {
|
2
|
+
import DatePicker, {
|
3
|
+
DatePickerProps,
|
4
|
+
} from 'react-date-picker/dist/entry.nostyle';
|
3
5
|
import classnames from 'classnames';
|
4
6
|
import parseISO from 'date-fns/parseISO';
|
5
7
|
import { InjectedFieldProps } from '../Field/InjectedFieldProps';
|
6
8
|
import { FormDefaults } from '../FormDefaults';
|
7
9
|
import Group, { GroupProps } from '../Group';
|
8
10
|
|
9
|
-
// Docs for react-date-picker https://www.npmjs.com/package/react-date-picker
|
10
|
-
|
11
11
|
export interface DatePickerGroupProps<T>
|
12
|
-
extends InjectedFieldProps<T | undefined>,
|
12
|
+
extends InjectedFieldProps<T | undefined | null>,
|
13
13
|
Omit<
|
14
14
|
DatePickerProps,
|
15
15
|
keyof InjectedFieldProps<T> | 'name' | 'value' | 'className'
|
@@ -18,12 +18,18 @@ export interface DatePickerGroupProps<T>
|
|
18
18
|
convert: (arg: Date) => T;
|
19
19
|
}
|
20
20
|
|
21
|
+
/**
|
22
|
+
* Field for inputting dates. Uses `<Group/>` and `<DatePicker/>`.
|
23
|
+
*
|
24
|
+
* Uses [react-date-picker](https://www.npmjs.com/package/react-date-picker)
|
25
|
+
*/
|
21
26
|
export default function DatePickerGroup<T>({
|
22
27
|
input,
|
23
28
|
meta,
|
24
29
|
label,
|
25
30
|
helpText,
|
26
31
|
className,
|
32
|
+
required,
|
27
33
|
disabled,
|
28
34
|
convert,
|
29
35
|
...rest
|
@@ -31,10 +37,14 @@ export default function DatePickerGroup<T>({
|
|
31
37
|
const [displayDate, setDisplayDate] = useState<Date | null>(null);
|
32
38
|
|
33
39
|
useEffect(() => {
|
34
|
-
if (input.value
|
35
|
-
setDisplayDate(new Date(`${input.value}T00:00:00.000`));
|
36
|
-
} else {
|
40
|
+
if (!input.value) {
|
37
41
|
setDisplayDate(null);
|
42
|
+
} else if (typeof input.value === 'string') {
|
43
|
+
if (input.value.indexOf('T') === -1) {
|
44
|
+
setDisplayDate(new Date(`${input.value}T00:00:00.000`));
|
45
|
+
} else {
|
46
|
+
setDisplayDate(new Date(input.value));
|
47
|
+
}
|
38
48
|
}
|
39
49
|
}, [setDisplayDate, input.value]);
|
40
50
|
|
@@ -48,6 +58,7 @@ export default function DatePickerGroup<T>({
|
|
48
58
|
className,
|
49
59
|
FormDefaults.cssClassPrefix + 'date-picker'
|
50
60
|
)}
|
61
|
+
required={required}
|
51
62
|
disabled={disabled}>
|
52
63
|
<DatePicker
|
53
64
|
{...rest}
|
@@ -1,9 +1,14 @@
|
|
1
|
-
import { DatePickerHelper } from './DatePickerHelper';
|
2
1
|
import DatePickerGroup from './DatePickerGroup';
|
2
|
+
import { DatePickerHelper } from './DatePickerHelper';
|
3
3
|
|
4
4
|
export interface StringDateOnlyPickerGroupProps
|
5
|
-
extends DatePickerHelper<string | undefined> {}
|
5
|
+
extends DatePickerHelper<string | undefined | null> {}
|
6
6
|
|
7
|
+
/**
|
8
|
+
* Date picker input that consumes and outputs as a date only string in ISO format `YYYY-MM-DD`.
|
9
|
+
*
|
10
|
+
* Default display to the user is in `MM/DD/YYYY` format.
|
11
|
+
*/
|
7
12
|
export default function StringDatePickerGroup(
|
8
13
|
props: StringDateOnlyPickerGroupProps
|
9
14
|
) {
|
@@ -2,7 +2,13 @@ import DatePickerGroup from './DatePickerGroup';
|
|
2
2
|
import { DatePickerHelper } from './DatePickerHelper';
|
3
3
|
|
4
4
|
export interface StringDatePickerGroupProps
|
5
|
-
extends DatePickerHelper<string | undefined> {}
|
5
|
+
extends DatePickerHelper<string | undefined | null> {}
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Date picker input that consumes and outputs as a date only string in ISO format `YYYY-MM-DDTHH:mm:ss.sssZ` or `±YYYYYY-MM-DDTHH:mm:ss.sssZ`
|
9
|
+
*
|
10
|
+
* If you need `YYYY-MM-DD` format use `<StringDateOnlyPickerGroup/>`.
|
11
|
+
*/
|
6
12
|
export default function StringDatePickerGroup(
|
7
13
|
props: StringDatePickerGroupProps
|
8
14
|
) {
|
package/src/Field/Field.tsx
CHANGED
@@ -4,6 +4,7 @@ import { InjectedFieldProps } from './InjectedFieldProps';
|
|
4
4
|
import useStandardFormInput from './useStandardField';
|
5
5
|
import { NormalizationFunction } from '../Normalization/NormalizationFunction';
|
6
6
|
import { ValidationFunction } from '../Validation/ValidationFunction';
|
7
|
+
import { required as requiredValidator } from '../Validation/validators';
|
7
8
|
|
8
9
|
// we attempted to support generic components but failed
|
9
10
|
// so, we assume the actual TRenderComponent has no generic arguments
|
@@ -13,7 +14,7 @@ export type RenderComponent<
|
|
13
14
|
TValue,
|
14
15
|
TRenderComponent extends ElementType
|
15
16
|
> = Partial<ComponentProps<TRenderComponent>> extends Partial<
|
16
|
-
InjectedFieldProps<TValue | undefined>
|
17
|
+
InjectedFieldProps<TValue | undefined | null>
|
17
18
|
>
|
18
19
|
? TRenderComponent
|
19
20
|
: never;
|
@@ -22,7 +23,7 @@ export type RenderComponentProps<
|
|
22
23
|
TValue,
|
23
24
|
TRenderComponent extends ElementType
|
24
25
|
> = Partial<ComponentProps<TRenderComponent>> extends Partial<
|
25
|
-
InjectedFieldProps<TValue | undefined>
|
26
|
+
InjectedFieldProps<TValue | undefined | null>
|
26
27
|
>
|
27
28
|
? ComponentProps<TRenderComponent>
|
28
29
|
: never;
|
@@ -33,14 +34,19 @@ export type FieldProps<
|
|
33
34
|
TProp extends keyof TForm,
|
34
35
|
TRenderComponent extends ElementType
|
35
36
|
> = {
|
37
|
+
/** Name of the field. Used on submission. */
|
36
38
|
name: TProp; // somewhat duplicated from useStandardFormInputProps but better for autocomplete
|
39
|
+
/** Component to be rendered. Usually this is a type of input group e.g. `<StringInputGroup/>` */
|
37
40
|
Component: RenderComponent<TForm[TProp], TRenderComponent>;
|
38
|
-
|
41
|
+
/** Id of the field. */
|
39
42
|
id?: string;
|
43
|
+
/** Whether the field should be disabled. */
|
40
44
|
disabled?: boolean;
|
45
|
+
/** Client side validation functions */
|
41
46
|
validate?:
|
42
47
|
| ValidationFunction<TForm[TProp]>
|
43
48
|
| ValidationFunction<TForm[TProp]>[];
|
49
|
+
/** Function to modify the field value without making the form dirty. (e.g. phone number) */
|
44
50
|
normalize?: NormalizationFunction<TForm[TProp]>;
|
45
51
|
} & Omit<
|
46
52
|
RenderComponentProps<TForm[TProp], TRenderComponent>,
|
@@ -60,9 +66,9 @@ function Field<
|
|
60
66
|
name,
|
61
67
|
Component,
|
62
68
|
id,
|
63
|
-
normalize,
|
64
|
-
validate,
|
65
69
|
disabled,
|
70
|
+
validate,
|
71
|
+
normalize,
|
66
72
|
...rest
|
67
73
|
}: FieldProps<TForm, TProp, TRenderComponent>,
|
68
74
|
ref: LegacyRef<any>
|
@@ -70,11 +76,17 @@ function Field<
|
|
70
76
|
const [input, meta] = useStandardFormInput<TForm[TProp]>({
|
71
77
|
name: String(name),
|
72
78
|
id: id,
|
73
|
-
normalize: normalize,
|
74
|
-
validate: validate,
|
75
79
|
disabled: disabled,
|
80
|
+
validate: validate,
|
81
|
+
normalize: normalize,
|
76
82
|
});
|
77
83
|
|
84
|
+
const isRequired =
|
85
|
+
rest?.required !== undefined
|
86
|
+
? rest.required
|
87
|
+
: validate === requiredValidator ||
|
88
|
+
(Array.isArray(validate) && validate.includes(requiredValidator));
|
89
|
+
|
78
90
|
// a bit of a hack so JSX is happy with us
|
79
91
|
const Wrapped = Component as React.ComponentType<
|
80
92
|
InjectedFieldProps<TForm[TProp]>
|
@@ -88,6 +100,7 @@ function Field<
|
|
88
100
|
id={input.id}
|
89
101
|
input={input}
|
90
102
|
meta={meta}
|
103
|
+
required={isRequired}
|
91
104
|
disabled={disabled}
|
92
105
|
/>
|
93
106
|
</FieldNameContext.Provider>
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { useContext } from 'react';
|
2
2
|
import { FieldNameContext } from './FieldNameContext';
|
3
3
|
|
4
|
+
/** Hidden `<div/>` that acts as an anchor to scroll to when a form error occurs. */
|
4
5
|
export default function FieldErrorScrollTarget() {
|
5
6
|
const name = useContext(FieldNameContext);
|
6
7
|
if (!name) {
|
@@ -9,8 +9,11 @@ export type StandAloneInputProps<
|
|
9
9
|
TValue,
|
10
10
|
TRenderComponent extends ElementType
|
11
11
|
> = {
|
12
|
+
/** Component to render inside of the field. */
|
12
13
|
Component: RenderComponent<TValue, TRenderComponent>;
|
14
|
+
/** Value of the field. */
|
13
15
|
value: TValue;
|
16
|
+
/** Function to change the value of the field. */
|
14
17
|
onChange: (arg: TValue) => void;
|
15
18
|
} & Omit<
|
16
19
|
RenderComponentProps<TValue, TRenderComponent>,
|
@@ -21,6 +24,7 @@ export type StandAloneInputProps<
|
|
21
24
|
| 'validate'
|
22
25
|
>;
|
23
26
|
|
27
|
+
/** The stand alone version of `<Field/>`. Can use a type of input component outside of a `<Form/>`. */
|
24
28
|
export default function StandAloneInput<TValue, TComponent extends ElementType>(
|
25
29
|
props: StandAloneInputProps<TValue, TComponent>
|
26
30
|
) {
|
@@ -8,14 +8,19 @@ import { NormalizationFunction } from '../Normalization/NormalizationFunction';
|
|
8
8
|
import { ValidationFunction } from '../Validation/ValidationFunction';
|
9
9
|
|
10
10
|
export interface useStandardFieldProps<TValue> {
|
11
|
+
/** Id of the field. */
|
11
12
|
id?: string;
|
13
|
+
/** Name of the field. */
|
12
14
|
name: string;
|
15
|
+
/** Whether the field should be disabled. */
|
13
16
|
disabled?: boolean;
|
17
|
+
/** Function to validate the field. */
|
14
18
|
validate?: ValidationFunction<TValue> | ValidationFunction<TValue>[];
|
19
|
+
/** Function to modify the field value without making the form dirty. (e.g. phone number) */
|
15
20
|
normalize?: NormalizationFunction<TValue>;
|
16
21
|
}
|
17
22
|
|
18
|
-
|
23
|
+
/** Provides a consistent way to deal with all form fields (non array). */
|
19
24
|
export default function useStandardField<TValue>({
|
20
25
|
id: providedId,
|
21
26
|
name: providedName,
|
@@ -51,7 +56,7 @@ export default function useStandardField<TValue>({
|
|
51
56
|
disabled: disabled,
|
52
57
|
validate: callAllValidators,
|
53
58
|
});
|
54
|
-
const { setFieldValue, isSubmitting } = useFormikContext();
|
59
|
+
const { setFieldTouched, setFieldValue, isSubmitting } = useFormikContext();
|
55
60
|
|
56
61
|
const touched =
|
57
62
|
formikMeta.touched !== false && formikMeta.touched !== undefined;
|
@@ -59,14 +64,13 @@ export default function useStandardField<TValue>({
|
|
59
64
|
if (!touched && isSubmitting) {
|
60
65
|
// because we do not always register all fields up front.
|
61
66
|
// e.g. formik expects even a 'create' form to have all fields given, at least, blank values
|
62
|
-
//
|
63
|
-
//
|
64
|
-
//
|
65
|
-
//
|
66
|
-
|
67
|
-
handleBlur();
|
67
|
+
// It looks like this was going to be a thing: https://github.com/jaredpalmer/formik/issues/691
|
68
|
+
// Formik appears to not have an active maintainer: https://github.com/jaredpalmer/formik/discussions/3526
|
69
|
+
// We previously had a different fix in place using handleBlur, but it was causing an infinite update cycle.
|
70
|
+
// This was noted as existing, but there was a note about it not working for FieldArray (this does appear to work in my testing with FieldArray)
|
71
|
+
setFieldTouched(name);
|
68
72
|
}
|
69
|
-
});
|
73
|
+
}, [isSubmitting, name, setFieldTouched, touched]);
|
70
74
|
|
71
75
|
// these are the props we expect consumers of this hook to pass directly to the input (or other control)
|
72
76
|
const resultInput: CustomFieldInputProps<TValue> = {
|
@@ -3,17 +3,21 @@ import classNames from 'classnames';
|
|
3
3
|
import Field, { FieldProps } from '../Field/Field';
|
4
4
|
import { FieldNameContext } from '../Field/FieldNameContext';
|
5
5
|
import useStandardFormInput from '../Field/useStandardField';
|
6
|
-
import { ValidationFunction } from '../Validation/ValidationFunction';
|
7
6
|
import { FormDefaults } from '../FormDefaults';
|
7
|
+
import { ValidationFunction } from '../Validation/ValidationFunction';
|
8
8
|
|
9
9
|
export type FieldArrayProps<
|
10
10
|
TForm extends object,
|
11
11
|
TProp extends keyof TForm
|
12
|
-
> = TForm[TProp] extends Array<any> | undefined
|
12
|
+
> = TForm[TProp] extends Array<any> | undefined | null
|
13
13
|
? {
|
14
|
+
/** Name of the field, used on submission. If using codegen this must be the provided dto. */
|
14
15
|
name: TProp;
|
16
|
+
/** Label of the field. */
|
15
17
|
label?: string;
|
18
|
+
/** Whether the field should be disabled. */
|
16
19
|
disabled?: boolean;
|
20
|
+
/** Function to validate the value. */
|
17
21
|
validate?:
|
18
22
|
| ValidationFunction<TForm[TProp]>
|
19
23
|
| ValidationFunction<TForm[TProp]>[];
|
@@ -23,8 +27,8 @@ export type FieldArrayProps<
|
|
23
27
|
}
|
24
28
|
: never;
|
25
29
|
|
26
|
-
export type ArrayFormBuilderProp<TValue extends Array<any> | undefined> =
|
27
|
-
TValue extends Array<infer TForm> | undefined
|
30
|
+
export type ArrayFormBuilderProp<TValue extends Array<any> | undefined | null> =
|
31
|
+
TValue extends Array<infer TForm> | undefined | null
|
28
32
|
? TForm extends object
|
29
33
|
? {
|
30
34
|
Field: <
|
@@ -41,6 +45,11 @@ export type ArrayFormBuilderProp<TValue extends Array<any> | undefined> =
|
|
41
45
|
: never
|
42
46
|
: never;
|
43
47
|
|
48
|
+
/**
|
49
|
+
* An array of fields that allows the user to add multiple instances of the same field.
|
50
|
+
*
|
51
|
+
* Includes "Add Item" and "Remove Item" buttons to allow the user to speicify the number of fields.
|
52
|
+
*/
|
44
53
|
export default function FieldArray<
|
45
54
|
TForm extends object,
|
46
55
|
TProp extends keyof TForm
|
@@ -52,7 +61,7 @@ export default function FieldArray<
|
|
52
61
|
children,
|
53
62
|
...rest
|
54
63
|
}: FieldArrayProps<TForm, TProp>) {
|
55
|
-
const [input
|
64
|
+
const [input] = useStandardFormInput<TForm[TProp]>({
|
56
65
|
name: String(name),
|
57
66
|
validate: validate,
|
58
67
|
disabled: disabled,
|
package/src/File/FileGroup.tsx
CHANGED
@@ -2,17 +2,18 @@ import React, { ComponentType, LegacyRef } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
3
3
|
import FileList from './FileList';
|
4
4
|
import { InjectedFieldProps } from '../Field/InjectedFieldProps';
|
5
|
-
import Group, { GroupProps } from '../Group';
|
6
5
|
import { FormDefaults } from '../FormDefaults';
|
6
|
+
import Group, { GroupProps } from '../Group';
|
7
7
|
|
8
8
|
export interface FileGroupProps
|
9
9
|
// note: file props are of type "any" with the current type generation
|
10
|
-
extends InjectedFieldProps<any | undefined>,
|
10
|
+
extends InjectedFieldProps<any | undefined | null>,
|
11
11
|
Omit<GroupProps, keyof InjectedFieldProps<any> | 'children'>,
|
12
12
|
Omit<
|
13
13
|
React.HTMLProps<HTMLInputElement>,
|
14
14
|
keyof InjectedFieldProps<any> | 'children' | 'className' | 'label'
|
15
15
|
> {
|
16
|
+
/** Allow multiple files to be uploaded. */
|
16
17
|
multiple?: boolean | undefined;
|
17
18
|
}
|
18
19
|
|
@@ -23,6 +24,8 @@ function FileGroup(
|
|
23
24
|
label,
|
24
25
|
helpText,
|
25
26
|
className,
|
27
|
+
required,
|
28
|
+
disabled,
|
26
29
|
multiple,
|
27
30
|
...rest
|
28
31
|
}: FileGroupProps,
|
@@ -38,7 +41,9 @@ function FileGroup(
|
|
38
41
|
className,
|
39
42
|
{ [FormDefaults.cssClassPrefix + 'multiple']: multiple },
|
40
43
|
FormDefaults.cssClassPrefix + 'file-group'
|
41
|
-
)}
|
44
|
+
)}
|
45
|
+
required={required}
|
46
|
+
disabled={disabled}>
|
42
47
|
<input
|
43
48
|
{...input}
|
44
49
|
{...rest}
|
@@ -72,6 +77,7 @@ function FileGroup(
|
|
72
77
|
);
|
73
78
|
}
|
74
79
|
|
80
|
+
/** File upload input group. */
|
75
81
|
const FileGroupWithRef = React.forwardRef(
|
76
82
|
FileGroup
|
77
83
|
) as ComponentType<FileGroupProps>;
|
package/src/File/FileList.tsx
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { FormDefaults } from '../FormDefaults';
|
2
2
|
|
3
3
|
export interface FileListProps {
|
4
|
-
files?: File | File[] | undefined;
|
5
|
-
rejectedFiles?: File | File[] | undefined;
|
4
|
+
files?: File | File[] | undefined | null;
|
5
|
+
rejectedFiles?: File | File[] | undefined | null;
|
6
6
|
}
|
7
7
|
export default function FileList({ files, rejectedFiles }: FileListProps) {
|
8
8
|
return (
|
package/src/Form/FocusError.tsx
CHANGED
@@ -4,8 +4,11 @@ import smoothscroll from 'smoothscroll-polyfill';
|
|
4
4
|
import { ServerErrorContextProps } from './ServerErrorContext';
|
5
5
|
|
6
6
|
export interface FocusErrorProps {
|
7
|
+
/** Validation errors that have been received from the server. */
|
7
8
|
serverErrors: ServerErrorContextProps;
|
8
9
|
}
|
10
|
+
|
11
|
+
/** Function to scroll to the field that has an error. */
|
9
12
|
export default function FocusError(props: FocusErrorProps) {
|
10
13
|
const { errors, isSubmitting, isValidating } = useFormikContext();
|
11
14
|
smoothscroll.polyfill();
|
package/src/Form/Form.tsx
CHANGED
@@ -41,18 +41,23 @@ export type FormBuilderProp<TForm extends object> = {
|
|
41
41
|
};
|
42
42
|
|
43
43
|
export interface FullFormProps<TForm extends object> {
|
44
|
+
/** The `<Field/>` and `<FieldArray/>` components. */
|
44
45
|
children: (formBuilder: FormBuilderProp<TForm>) => JSX.Element;
|
46
|
+
/** Submission handler */
|
45
47
|
onSubmit: (
|
46
48
|
formValues: TForm,
|
47
49
|
formikBag: FormikHelpers<TForm>
|
48
50
|
) => Promise<ValidatedApiResult>;
|
51
|
+
/** Submission handler for forms that use [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData).*/
|
49
52
|
onFormDataSubmit: (
|
50
53
|
formValues: FormData,
|
51
54
|
formikBag: FormikHelpers<TForm>
|
52
55
|
) => Promise<ValidatedApiResult>;
|
53
56
|
className?: string;
|
54
57
|
style?: CSSProperties;
|
58
|
+
/** Prevent the user from leaving the form if they have edited any field. This is presented as a JS `alert()`. */
|
55
59
|
ignoreLostChanges?: boolean;
|
60
|
+
/** The intitial values of the form. */
|
56
61
|
initialValues?: TForm;
|
57
62
|
}
|
58
63
|
|
@@ -69,6 +74,7 @@ export type FormProps<TForm extends object> = RequireAtLeastOne<
|
|
69
74
|
'onSubmit' | 'onFormDataSubmit'
|
70
75
|
>;
|
71
76
|
|
77
|
+
/** Define a form. Uses [formik](https://formik.org/docs/overview). Usually contains many `<Field/>` components. */
|
72
78
|
export default function Form<TForm extends object>({
|
73
79
|
children,
|
74
80
|
className,
|