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
@@ -1,25 +1,30 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
3
|
-
__assign = Object.assign || function(t) {
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
-
s = arguments[i];
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
-
t[p] = s[p];
|
8
|
-
}
|
9
|
-
return t;
|
10
|
-
};
|
11
|
-
return __assign.apply(this, arguments);
|
12
|
-
};
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
15
|
-
};
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
18
|
-
var DatePickerGroup_1 = __importDefault(require("./DatePickerGroup"));
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}
|
1
|
+
"use strict";
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
3
|
+
__assign = Object.assign || function(t) {
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
+
s = arguments[i];
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
+
t[p] = s[p];
|
8
|
+
}
|
9
|
+
return t;
|
10
|
+
};
|
11
|
+
return __assign.apply(this, arguments);
|
12
|
+
};
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
18
|
+
var DatePickerGroup_1 = __importDefault(require("./DatePickerGroup"));
|
19
|
+
/**
|
20
|
+
* 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`
|
21
|
+
*
|
22
|
+
* If you need `YYYY-MM-DD` format use `<StringDateOnlyPickerGroup/>`.
|
23
|
+
*/
|
24
|
+
function StringDatePickerGroup(props) {
|
25
|
+
return (0, jsx_runtime_1.jsx)(DatePickerGroup_1.default, __assign({}, props, { convert: convertToDateOnly }));
|
26
|
+
}
|
27
|
+
exports.default = StringDatePickerGroup;
|
28
|
+
function convertToDateOnly(arg) {
|
29
|
+
return arg.toISOString();
|
30
|
+
}
|
@@ -1,7 +1,7 @@
|
|
1
|
-
export interface CustomFieldInputProps<TValue> {
|
2
|
-
id: string;
|
3
|
-
name: string;
|
4
|
-
value: TValue;
|
5
|
-
onChange: (newValue: TValue) => void;
|
6
|
-
onBlur: () => void;
|
7
|
-
}
|
1
|
+
export interface CustomFieldInputProps<TValue> {
|
2
|
+
id: string;
|
3
|
+
name: string;
|
4
|
+
value: TValue;
|
5
|
+
onChange: (newValue: TValue) => void;
|
6
|
+
onBlur: () => void;
|
7
|
+
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { FieldMetaProps } from 'formik';
|
2
|
-
export interface CustomFieldMetaProps<TValue> extends FieldMetaProps<TValue> {
|
3
|
-
warning: string | undefined;
|
4
|
-
}
|
1
|
+
import { FieldMetaProps } from 'formik';
|
2
|
+
export interface CustomFieldMetaProps<TValue> extends FieldMetaProps<TValue> {
|
3
|
+
warning: string | undefined;
|
4
|
+
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/lib/Field/Field.d.ts
CHANGED
@@ -1,22 +1,28 @@
|
|
1
|
-
import { ComponentProps, ElementType, LegacyRef } from 'react';
|
2
|
-
import { InjectedFieldProps } from './InjectedFieldProps';
|
3
|
-
import { NormalizationFunction } from '../Normalization/NormalizationFunction';
|
4
|
-
import { ValidationFunction } from '../Validation/ValidationFunction';
|
5
|
-
export
|
6
|
-
export
|
7
|
-
/** A specific Field instance to be rendered by the given TRenderComponent or by whatever default is reasonable */
|
8
|
-
export
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
*/
|
20
|
-
|
21
|
-
|
22
|
-
|
1
|
+
import { ComponentProps, ElementType, LegacyRef } from 'react';
|
2
|
+
import { InjectedFieldProps } from './InjectedFieldProps';
|
3
|
+
import { NormalizationFunction } from '../Normalization/NormalizationFunction';
|
4
|
+
import { ValidationFunction } from '../Validation/ValidationFunction';
|
5
|
+
export type RenderComponent<TValue, TRenderComponent extends ElementType> = Partial<ComponentProps<TRenderComponent>> extends Partial<InjectedFieldProps<TValue | undefined | null>> ? TRenderComponent : never;
|
6
|
+
export type RenderComponentProps<TValue, TRenderComponent extends ElementType> = Partial<ComponentProps<TRenderComponent>> extends Partial<InjectedFieldProps<TValue | undefined | null>> ? ComponentProps<TRenderComponent> : never;
|
7
|
+
/** A specific Field instance to be rendered by the given TRenderComponent or by whatever default is reasonable */
|
8
|
+
export type FieldProps<TForm extends object, TProp extends keyof TForm, TRenderComponent extends ElementType> = {
|
9
|
+
/** Name of the field. Used on submission. */
|
10
|
+
name: TProp;
|
11
|
+
/** Component to be rendered. Usually this is a type of input group e.g. `<StringInputGroup/>` */
|
12
|
+
Component: RenderComponent<TForm[TProp], TRenderComponent>;
|
13
|
+
/** Id of the field. */
|
14
|
+
id?: string;
|
15
|
+
/** Whether the field should be disabled. */
|
16
|
+
disabled?: boolean;
|
17
|
+
/** Client side validation functions */
|
18
|
+
validate?: ValidationFunction<TForm[TProp]> | ValidationFunction<TForm[TProp]>[];
|
19
|
+
/** Function to modify the field value without making the form dirty. (e.g. phone number) */
|
20
|
+
normalize?: NormalizationFunction<TForm[TProp]>;
|
21
|
+
} & Omit<RenderComponentProps<TForm[TProp], TRenderComponent>, keyof InjectedFieldProps<TForm[TProp]>>;
|
22
|
+
/**
|
23
|
+
* Renders whatever Component is passed - injecting the formik values needed to finish wiring up that individual field.
|
24
|
+
* Should no Component be used then the default will be provided by the default lookup based on typeof(TForm[TProp])
|
25
|
+
*/
|
26
|
+
declare function Field<TForm extends object, TProp extends keyof TForm, TRenderComponent extends ElementType>({ name, Component, id, disabled, validate, normalize, ...rest }: FieldProps<TForm, TProp, TRenderComponent>, ref: LegacyRef<any>): import("react/jsx-runtime").JSX.Element;
|
27
|
+
declare const _default: typeof Field;
|
28
|
+
export default _default;
|
package/lib/Field/Field.js
CHANGED
@@ -1,51 +1,56 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
3
|
-
__assign = Object.assign || function(t) {
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
-
s = arguments[i];
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
-
t[p] = s[p];
|
8
|
-
}
|
9
|
-
return t;
|
10
|
-
};
|
11
|
-
return __assign.apply(this, arguments);
|
12
|
-
};
|
13
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
14
|
-
var t = {};
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
16
|
-
t[p] = s[p];
|
17
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
18
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
19
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
20
|
-
t[p[i]] = s[p[i]];
|
21
|
-
}
|
22
|
-
return t;
|
23
|
-
};
|
24
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
25
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
26
|
-
};
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
28
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
29
|
-
var react_1 = __importDefault(require("react"));
|
30
|
-
var FieldNameContext_1 = require("./FieldNameContext");
|
31
|
-
var useStandardField_1 = __importDefault(require("./useStandardField"));
|
32
|
-
|
33
|
-
|
34
|
-
*
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
var
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
var
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
1
|
+
"use strict";
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
3
|
+
__assign = Object.assign || function(t) {
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
+
s = arguments[i];
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
+
t[p] = s[p];
|
8
|
+
}
|
9
|
+
return t;
|
10
|
+
};
|
11
|
+
return __assign.apply(this, arguments);
|
12
|
+
};
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
14
|
+
var t = {};
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
16
|
+
t[p] = s[p];
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
20
|
+
t[p[i]] = s[p[i]];
|
21
|
+
}
|
22
|
+
return t;
|
23
|
+
};
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
26
|
+
};
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
28
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
29
|
+
var react_1 = __importDefault(require("react"));
|
30
|
+
var FieldNameContext_1 = require("./FieldNameContext");
|
31
|
+
var useStandardField_1 = __importDefault(require("./useStandardField"));
|
32
|
+
var validators_1 = require("../Validation/validators");
|
33
|
+
/**
|
34
|
+
* Renders whatever Component is passed - injecting the formik values needed to finish wiring up that individual field.
|
35
|
+
* Should no Component be used then the default will be provided by the default lookup based on typeof(TForm[TProp])
|
36
|
+
*/
|
37
|
+
function Field(_a, ref) {
|
38
|
+
var name = _a.name, Component = _a.Component, id = _a.id, disabled = _a.disabled, validate = _a.validate, normalize = _a.normalize, rest = __rest(_a, ["name", "Component", "id", "disabled", "validate", "normalize"]);
|
39
|
+
var _b = (0, useStandardField_1.default)({
|
40
|
+
name: String(name),
|
41
|
+
id: id,
|
42
|
+
disabled: disabled,
|
43
|
+
validate: validate,
|
44
|
+
normalize: normalize,
|
45
|
+
}), input = _b[0], meta = _b[1];
|
46
|
+
var isRequired = (rest === null || rest === void 0 ? void 0 : rest.required) !== undefined
|
47
|
+
? rest.required
|
48
|
+
: validate === validators_1.required ||
|
49
|
+
(Array.isArray(validate) && validate.includes(validators_1.required));
|
50
|
+
// a bit of a hack so JSX is happy with us
|
51
|
+
var Wrapped = Component;
|
52
|
+
return ((0, jsx_runtime_1.jsx)(FieldNameContext_1.FieldNameContext.Provider, { value: input.name, children: (0, jsx_runtime_1.jsx)(Wrapped, __assign({}, rest, { ref: ref, id: input.id, input: input, meta: meta, required: isRequired, disabled: disabled })) }));
|
53
|
+
}
|
54
|
+
// hack to get forwarded refs to work
|
55
|
+
var FieldWithRef = react_1.default.forwardRef(Field);
|
56
|
+
exports.default = FieldWithRef;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
export default function FieldErrorScrollTarget(): JSX.Element | null;
|
1
|
+
/** Hidden `<div/>` that acts as an anchor to scroll to when a form error occurs. */
|
2
|
+
export default function FieldErrorScrollTarget(): import("react/jsx-runtime").JSX.Element | null;
|
@@ -1,14 +1,15 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
4
|
-
var react_1 = require("react");
|
5
|
-
var FieldNameContext_1 = require("./FieldNameContext");
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
}
|
14
|
-
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
4
|
+
var react_1 = require("react");
|
5
|
+
var FieldNameContext_1 = require("./FieldNameContext");
|
6
|
+
/** Hidden `<div/>` that acts as an anchor to scroll to when a form error occurs. */
|
7
|
+
function FieldErrorScrollTarget() {
|
8
|
+
var name = (0, react_1.useContext)(FieldNameContext_1.FieldNameContext);
|
9
|
+
if (!name) {
|
10
|
+
return null;
|
11
|
+
}
|
12
|
+
var divId = "".concat(name.toLowerCase(), "-error-scroll-target");
|
13
|
+
return (0, jsx_runtime_1.jsx)("div", { id: divId, style: { display: 'none' } });
|
14
|
+
}
|
15
|
+
exports.default = FieldErrorScrollTarget;
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
/** provides the full, qualified name of the current field name - including nested fields, path/dot delimited */
|
3
|
-
export declare const FieldNameContext: React.Context<string | undefined>;
|
1
|
+
import React from 'react';
|
2
|
+
/** provides the full, qualified name of the current field name - including nested fields, path/dot delimited */
|
3
|
+
export declare const FieldNameContext: React.Context<string | undefined>;
|
@@ -1,9 +1,9 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.FieldNameContext = void 0;
|
7
|
-
var react_1 = __importDefault(require("react"));
|
8
|
-
/** provides the full, qualified name of the current field name - including nested fields, path/dot delimited */
|
9
|
-
exports.FieldNameContext = react_1.default.createContext(undefined);
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.FieldNameContext = void 0;
|
7
|
+
var react_1 = __importDefault(require("react"));
|
8
|
+
/** provides the full, qualified name of the current field name - including nested fields, path/dot delimited */
|
9
|
+
exports.FieldNameContext = react_1.default.createContext(undefined);
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
interface FieldSectionProps {
|
3
|
-
children: React.ReactNode;
|
4
|
-
name: string;
|
5
|
-
}
|
6
|
-
export default function FieldSection({ children, name }: FieldSectionProps): JSX.Element;
|
7
|
-
export {};
|
1
|
+
import React from 'react';
|
2
|
+
interface FieldSectionProps {
|
3
|
+
children: React.ReactNode;
|
4
|
+
name: string;
|
5
|
+
}
|
6
|
+
export default function FieldSection({ children, name }: FieldSectionProps): import("react/jsx-runtime").JSX.Element;
|
7
|
+
export {};
|
@@ -1,23 +1,12 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
};
|
11
|
-
|
12
|
-
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
14
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
15
|
-
var react_1 = require("react");
|
16
|
-
var FieldNameContext_1 = require("./FieldNameContext");
|
17
|
-
function FieldSection(_a) {
|
18
|
-
var children = _a.children, name = _a.name;
|
19
|
-
var parentContext = (0, react_1.useContext)(FieldNameContext_1.FieldNameContext);
|
20
|
-
var effectiveValue = parentContext ? "".concat(parentContext, ".").concat(name) : name;
|
21
|
-
return ((0, jsx_runtime_1.jsx)(FieldNameContext_1.FieldNameContext.Provider, __assign({ value: effectiveValue }, { children: children })));
|
22
|
-
}
|
23
|
-
exports.default = FieldSection;
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
4
|
+
var react_1 = require("react");
|
5
|
+
var FieldNameContext_1 = require("./FieldNameContext");
|
6
|
+
function FieldSection(_a) {
|
7
|
+
var children = _a.children, name = _a.name;
|
8
|
+
var parentContext = (0, react_1.useContext)(FieldNameContext_1.FieldNameContext);
|
9
|
+
var effectiveValue = parentContext ? "".concat(parentContext, ".").concat(name) : name;
|
10
|
+
return ((0, jsx_runtime_1.jsx)(FieldNameContext_1.FieldNameContext.Provider, { value: effectiveValue, children: children }));
|
11
|
+
}
|
12
|
+
exports.default = FieldSection;
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { CustomFieldInputProps } from './CustomFieldInputProps';
|
2
|
-
import { CustomFieldMetaProps } from './CustomFieldMetaProps';
|
3
|
-
/** Defines what is injected by a Field wrapper of some TRenderComponent */
|
4
|
-
export interface InjectedFieldProps<TValue> {
|
5
|
-
input: CustomFieldInputProps<TValue>;
|
6
|
-
meta: CustomFieldMetaProps<TValue>;
|
7
|
-
}
|
1
|
+
import { CustomFieldInputProps } from './CustomFieldInputProps';
|
2
|
+
import { CustomFieldMetaProps } from './CustomFieldMetaProps';
|
3
|
+
/** Defines what is injected by a Field wrapper of some TRenderComponent */
|
4
|
+
export interface InjectedFieldProps<TValue> {
|
5
|
+
input: CustomFieldInputProps<TValue>;
|
6
|
+
meta: CustomFieldMetaProps<TValue>;
|
7
|
+
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
@@ -1,9 +1,13 @@
|
|
1
|
-
import { ElementType } from 'react';
|
2
|
-
import { RenderComponent, RenderComponentProps } from './Field';
|
3
|
-
import { InjectedFieldProps } from './InjectedFieldProps';
|
4
|
-
export
|
5
|
-
Component
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
import { ElementType } from 'react';
|
2
|
+
import { RenderComponent, RenderComponentProps } from './Field';
|
3
|
+
import { InjectedFieldProps } from './InjectedFieldProps';
|
4
|
+
export type StandAloneInputProps<TValue, TRenderComponent extends ElementType> = {
|
5
|
+
/** Component to render inside of the field. */
|
6
|
+
Component: RenderComponent<TValue, TRenderComponent>;
|
7
|
+
/** Value of the field. */
|
8
|
+
value: TValue;
|
9
|
+
/** Function to change the value of the field. */
|
10
|
+
onChange: (arg: TValue) => void;
|
11
|
+
} & Omit<RenderComponentProps<TValue, TRenderComponent>, keyof InjectedFieldProps<TValue> | 'value' | 'onChange' | 'normalize' | 'validate'>;
|
12
|
+
/** The stand alone version of `<Field/>`. Can use a type of input component outside of a `<Form/>`. */
|
13
|
+
export default function StandAloneInput<TValue, TComponent extends ElementType>(props: StandAloneInputProps<TValue, TComponent>): import("react/jsx-runtime").JSX.Element;
|
@@ -1,75 +1,76 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
3
|
-
__assign = Object.assign || function(t) {
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
-
s = arguments[i];
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
-
t[p] = s[p];
|
8
|
-
}
|
9
|
-
return t;
|
10
|
-
};
|
11
|
-
return __assign.apply(this, arguments);
|
12
|
-
};
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
14
|
-
if (k2 === undefined) k2 = k;
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
18
|
-
}
|
19
|
-
Object.defineProperty(o, k2, desc);
|
20
|
-
}) : (function(o, m, k, k2) {
|
21
|
-
if (k2 === undefined) k2 = k;
|
22
|
-
o[k2] = m[k];
|
23
|
-
}));
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
26
|
-
}) : function(o, v) {
|
27
|
-
o["default"] = v;
|
28
|
-
});
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
30
|
-
if (mod && mod.__esModule) return mod;
|
31
|
-
var result = {};
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
33
|
-
__setModuleDefault(result, mod);
|
34
|
-
return result;
|
35
|
-
};
|
36
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
37
|
-
var t = {};
|
38
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
39
|
-
t[p] = s[p];
|
40
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
41
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
42
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
43
|
-
t[p[i]] = s[p[i]];
|
44
|
-
}
|
45
|
-
return t;
|
46
|
-
};
|
47
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
48
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
49
|
-
var react_1 = require("react");
|
50
|
-
var uuid = __importStar(require("uuid"));
|
51
|
-
|
52
|
-
|
53
|
-
var
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
var
|
60
|
-
var
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
}
|
75
|
-
|
1
|
+
"use strict";
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
3
|
+
__assign = Object.assign || function(t) {
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
+
s = arguments[i];
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
+
t[p] = s[p];
|
8
|
+
}
|
9
|
+
return t;
|
10
|
+
};
|
11
|
+
return __assign.apply(this, arguments);
|
12
|
+
};
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
14
|
+
if (k2 === undefined) k2 = k;
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
18
|
+
}
|
19
|
+
Object.defineProperty(o, k2, desc);
|
20
|
+
}) : (function(o, m, k, k2) {
|
21
|
+
if (k2 === undefined) k2 = k;
|
22
|
+
o[k2] = m[k];
|
23
|
+
}));
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
26
|
+
}) : function(o, v) {
|
27
|
+
o["default"] = v;
|
28
|
+
});
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
30
|
+
if (mod && mod.__esModule) return mod;
|
31
|
+
var result = {};
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
33
|
+
__setModuleDefault(result, mod);
|
34
|
+
return result;
|
35
|
+
};
|
36
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
37
|
+
var t = {};
|
38
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
39
|
+
t[p] = s[p];
|
40
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
41
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
42
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
43
|
+
t[p[i]] = s[p[i]];
|
44
|
+
}
|
45
|
+
return t;
|
46
|
+
};
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
48
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
49
|
+
var react_1 = require("react");
|
50
|
+
var uuid = __importStar(require("uuid"));
|
51
|
+
/** The stand alone version of `<Field/>`. Can use a type of input component outside of a `<Form/>`. */
|
52
|
+
function StandAloneInput(props) {
|
53
|
+
var Component = props.Component, value = props.value, onChange = props.onChange, disabled = props.disabled, rest = __rest(props, ["Component", "value", "onChange", "disabled"]);
|
54
|
+
var handleChange = function (arg) {
|
55
|
+
if (!disabled) {
|
56
|
+
onChange(arg);
|
57
|
+
}
|
58
|
+
};
|
59
|
+
var Wrapped = Component;
|
60
|
+
var idRef = (0, react_1.useRef)(uuid.v4());
|
61
|
+
var input = {
|
62
|
+
id: idRef.current,
|
63
|
+
name: idRef.current,
|
64
|
+
value: value,
|
65
|
+
onChange: handleChange,
|
66
|
+
onBlur: function () { },
|
67
|
+
};
|
68
|
+
var meta = {
|
69
|
+
warning: undefined,
|
70
|
+
value: value,
|
71
|
+
touched: false,
|
72
|
+
initialTouched: false,
|
73
|
+
};
|
74
|
+
return (0, jsx_runtime_1.jsx)(Wrapped, __assign({}, rest, { disabled: disabled, input: input, meta: meta }));
|
75
|
+
}
|
76
|
+
exports.default = StandAloneInput;
|
@@ -1,15 +1,21 @@
|
|
1
|
-
import { CustomFieldInputProps } from './CustomFieldInputProps';
|
2
|
-
import { CustomFieldMetaProps } from './CustomFieldMetaProps';
|
3
|
-
import { NormalizationFunction } from '../Normalization/NormalizationFunction';
|
4
|
-
import { ValidationFunction } from '../Validation/ValidationFunction';
|
5
|
-
export interface useStandardFieldProps<TValue> {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
import { CustomFieldInputProps } from './CustomFieldInputProps';
|
2
|
+
import { CustomFieldMetaProps } from './CustomFieldMetaProps';
|
3
|
+
import { NormalizationFunction } from '../Normalization/NormalizationFunction';
|
4
|
+
import { ValidationFunction } from '../Validation/ValidationFunction';
|
5
|
+
export interface useStandardFieldProps<TValue> {
|
6
|
+
/** Id of the field. */
|
7
|
+
id?: string;
|
8
|
+
/** Name of the field. */
|
9
|
+
name: string;
|
10
|
+
/** Whether the field should be disabled. */
|
11
|
+
disabled?: boolean;
|
12
|
+
/** Function to validate the field. */
|
13
|
+
validate?: ValidationFunction<TValue> | ValidationFunction<TValue>[];
|
14
|
+
/** Function to modify the field value without making the form dirty. (e.g. phone number) */
|
15
|
+
normalize?: NormalizationFunction<TValue>;
|
16
|
+
}
|
17
|
+
/** Provides a consistent way to deal with all form fields (non array). */
|
18
|
+
export default function useStandardField<TValue>({ id: providedId, name: providedName, disabled, validate, normalize, }: useStandardFieldProps<TValue>): [
|
19
|
+
CustomFieldInputProps<TValue>,
|
20
|
+
CustomFieldMetaProps<TValue>
|
21
|
+
];
|