envoc-form 5.0.6 → 6.0.1-0
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 +4636 -1236
- package/dist/index.cjs +21685 -0
- package/dist/index.d.ts +599 -0
- package/dist/index.js +21617 -0
- package/package.json +73 -77
- package/dist/css/envoc-form-styles.css +0 -3
- package/dist/css/envoc-form-styles.css.map +0 -1
- package/es/AddressInput/AddressInput.d.ts +0 -24
- package/es/AddressInput/AddressInput.js +0 -20
- package/es/AddressInput/UsStates.d.ts +0 -3
- package/es/AddressInput/UsStates.js +0 -53
- package/es/ConfirmBaseForm/ConfirmBaseForm.d.ts +0 -26
- package/es/ConfirmBaseForm/ConfirmBaseForm.js +0 -42
- package/es/ConfirmDeleteForm/ConfirmDeleteForm.d.ts +0 -24
- package/es/ConfirmDeleteForm/ConfirmDeleteForm.js +0 -60
- package/es/DatePicker/DatePickerGroup.d.ts +0 -13
- package/es/DatePicker/DatePickerGroup.js +0 -87
- package/es/DatePicker/DatePickerHelper.d.ts +0 -3
- package/es/DatePicker/DatePickerHelper.js +0 -1
- package/es/DatePicker/StringDateOnlyPickerGroup.d.ts +0 -9
- package/es/DatePicker/StringDateOnlyPickerGroup.js +0 -29
- package/es/DatePicker/StringDatePickerGroup.d.ts +0 -9
- package/es/DatePicker/StringDatePickerGroup.js +0 -24
- package/es/Field/CustomFieldInputProps.d.ts +0 -7
- package/es/Field/CustomFieldInputProps.js +0 -1
- package/es/Field/CustomFieldMetaProps.d.ts +0 -4
- package/es/Field/CustomFieldMetaProps.js +0 -1
- package/es/Field/Field.d.ts +0 -28
- package/es/Field/Field.js +0 -51
- package/es/Field/FieldErrorScrollTarget.d.ts +0 -2
- package/es/Field/FieldErrorScrollTarget.js +0 -12
- package/es/Field/FieldNameContext.d.ts +0 -3
- package/es/Field/FieldNameContext.js +0 -3
- package/es/Field/FieldSection.d.ts +0 -7
- package/es/Field/FieldSection.js +0 -9
- package/es/Field/InjectedFieldProps.d.ts +0 -7
- package/es/Field/InjectedFieldProps.js +0 -1
- package/es/Field/StandAloneInput.d.ts +0 -13
- package/es/Field/StandAloneInput.js +0 -50
- package/es/Field/useStandardField.d.ts +0 -21
- package/es/Field/useStandardField.js +0 -92
- package/es/FieldArray/FieldArray.d.ts +0 -24
- package/es/FieldArray/FieldArray.js +0 -77
- package/es/File/FileGroup.d.ts +0 -10
- package/es/File/FileGroup.js +0 -53
- package/es/File/FileList.d.ts +0 -5
- package/es/File/FileList.js +0 -10
- package/es/File/humanFileSize.d.ts +0 -1
- package/es/File/humanFileSize.js +0 -6
- package/es/Form/FocusError.d.ts +0 -7
- package/es/Form/FocusError.js +0 -42
- package/es/Form/Form.d.ts +0 -33
- package/es/Form/Form.js +0 -141
- package/es/Form/FormBasedPreventNavigation.d.ts +0 -6
- package/es/Form/FormBasedPreventNavigation.js +0 -20
- package/es/Form/LegacyFormBasedPreventNavigation.d.ts +0 -17
- package/es/Form/LegacyFormBasedPreventNavigation.js +0 -69
- package/es/Form/NewFormBasedPreventNavigation.d.ts +0 -14
- package/es/Form/NewFormBasedPreventNavigation.js +0 -39
- package/es/Form/ServerErrorContext.d.ts +0 -11
- package/es/Form/ServerErrorContext.js +0 -9
- package/es/FormActions.d.ts +0 -12
- package/es/FormActions.js +0 -16
- package/es/FormDefaults.d.ts +0 -4
- package/es/FormDefaults.js +0 -2
- package/es/Group.d.ts +0 -16
- package/es/Group.js +0 -14
- package/es/Input/CheckboxGroup.d.ts +0 -6
- package/es/Input/CheckboxGroup.js +0 -14
- package/es/Input/CheckboxInputGroup.d.ts +0 -13
- package/es/Input/CheckboxInputGroup.js +0 -41
- package/es/Input/IconInputGroup.d.ts +0 -12
- package/es/Input/IconInputGroup.js +0 -43
- package/es/Input/InputGroup.d.ts +0 -12
- package/es/Input/InputGroup.js +0 -34
- package/es/Input/MoneyInputGroup.d.ts +0 -9
- package/es/Input/MoneyInputGroup.js +0 -43
- package/es/Input/NumberInputGroup.d.ts +0 -9
- package/es/Input/NumberInputGroup.js +0 -43
- package/es/Input/PhoneNumberInputGroup.d.ts +0 -10
- package/es/Input/PhoneNumberInputGroup.js +0 -47
- package/es/Input/StringInputGroup.d.ts +0 -8
- package/es/Input/StringInputGroup.js +0 -43
- package/es/Normalization/NormalizationFunction.d.ts +0 -4
- package/es/Normalization/NormalizationFunction.js +0 -1
- package/es/Normalization/normalizers.d.ts +0 -4
- package/es/Normalization/normalizers.js +0 -32
- package/es/Select/BooleanSelectGroup.d.ts +0 -7
- package/es/Select/BooleanSelectGroup.js +0 -28
- package/es/Select/NumberSelectGroup.d.ts +0 -9
- package/es/Select/NumberSelectGroup.js +0 -21
- package/es/Select/SelectGroup.d.ts +0 -27
- package/es/Select/SelectGroup.js +0 -65
- package/es/Select/SelectGroupPropsHelper.d.ts +0 -3
- package/es/Select/SelectGroupPropsHelper.js +0 -1
- package/es/Select/StringSelectGroup.d.ts +0 -9
- package/es/Select/StringSelectGroup.js +0 -21
- package/es/StandardFormActions.d.ts +0 -11
- package/es/StandardFormActions.js +0 -14
- package/es/SubmitFormButton.d.ts +0 -10
- package/es/SubmitFormButton.js +0 -40
- package/es/TextArea/TextAreaGroup.d.ts +0 -9
- package/es/TextArea/TextAreaGroup.js +0 -35
- package/es/Validation/ValidatedApiResult.d.ts +0 -6
- package/es/Validation/ValidatedApiResult.js +0 -1
- package/es/Validation/ValidationError.d.ts +0 -5
- package/es/Validation/ValidationError.js +0 -1
- package/es/Validation/ValidationFunction.d.ts +0 -4
- package/es/Validation/ValidationFunction.js +0 -1
- package/es/Validation/validators.d.ts +0 -18
- package/es/Validation/validators.js +0 -77
- package/es/index.d.ts +0 -77
- package/es/index.js +0 -52
- package/es/setupTests.d.ts +0 -1
- package/es/setupTests.js +0 -1
- package/es/utils/objectContainsNonSerializableProperty.d.ts +0 -1
- package/es/utils/objectContainsNonSerializableProperty.js +0 -14
- package/es/utils/objectToFormData.d.ts +0 -10
- package/es/utils/objectToFormData.js +0 -77
- package/es/utils/typeChecks.d.ts +0 -8
- package/es/utils/typeChecks.js +0 -18
- package/lib/AddressInput/AddressInput.d.ts +0 -24
- package/lib/AddressInput/AddressInput.js +0 -26
- package/lib/AddressInput/UsStates.d.ts +0 -3
- package/lib/AddressInput/UsStates.js +0 -55
- package/lib/ConfirmBaseForm/ConfirmBaseForm.d.ts +0 -26
- package/lib/ConfirmBaseForm/ConfirmBaseForm.js +0 -45
- package/lib/ConfirmDeleteForm/ConfirmDeleteForm.d.ts +0 -24
- package/lib/ConfirmDeleteForm/ConfirmDeleteForm.js +0 -66
- package/lib/DatePicker/DatePickerGroup.d.ts +0 -13
- package/lib/DatePicker/DatePickerGroup.js +0 -95
- package/lib/DatePicker/DatePickerHelper.d.ts +0 -3
- package/lib/DatePicker/DatePickerHelper.js +0 -2
- package/lib/DatePicker/StringDateOnlyPickerGroup.d.ts +0 -9
- package/lib/DatePicker/StringDateOnlyPickerGroup.js +0 -35
- package/lib/DatePicker/StringDatePickerGroup.d.ts +0 -9
- package/lib/DatePicker/StringDatePickerGroup.js +0 -30
- package/lib/Field/CustomFieldInputProps.d.ts +0 -7
- package/lib/Field/CustomFieldInputProps.js +0 -2
- package/lib/Field/CustomFieldMetaProps.d.ts +0 -4
- package/lib/Field/CustomFieldMetaProps.js +0 -2
- package/lib/Field/Field.d.ts +0 -28
- package/lib/Field/Field.js +0 -56
- package/lib/Field/FieldErrorScrollTarget.d.ts +0 -2
- package/lib/Field/FieldErrorScrollTarget.js +0 -15
- package/lib/Field/FieldNameContext.d.ts +0 -3
- package/lib/Field/FieldNameContext.js +0 -9
- package/lib/Field/FieldSection.d.ts +0 -7
- package/lib/Field/FieldSection.js +0 -12
- package/lib/Field/InjectedFieldProps.d.ts +0 -7
- package/lib/Field/InjectedFieldProps.js +0 -2
- package/lib/Field/StandAloneInput.d.ts +0 -13
- package/lib/Field/StandAloneInput.js +0 -76
- package/lib/Field/useStandardField.d.ts +0 -21
- package/lib/Field/useStandardField.js +0 -95
- package/lib/FieldArray/FieldArray.d.ts +0 -24
- package/lib/FieldArray/FieldArray.js +0 -83
- package/lib/File/FileGroup.d.ts +0 -10
- package/lib/File/FileGroup.js +0 -58
- package/lib/File/FileList.d.ts +0 -5
- package/lib/File/FileList.js +0 -13
- package/lib/File/humanFileSize.d.ts +0 -1
- package/lib/File/humanFileSize.js +0 -10
- package/lib/Form/FocusError.d.ts +0 -7
- package/lib/Form/FocusError.js +0 -48
- package/lib/Form/Form.d.ts +0 -33
- package/lib/Form/Form.js +0 -147
- package/lib/Form/FormBasedPreventNavigation.d.ts +0 -6
- package/lib/Form/FormBasedPreventNavigation.js +0 -26
- package/lib/Form/LegacyFormBasedPreventNavigation.d.ts +0 -17
- package/lib/Form/LegacyFormBasedPreventNavigation.js +0 -72
- package/lib/Form/NewFormBasedPreventNavigation.d.ts +0 -14
- package/lib/Form/NewFormBasedPreventNavigation.js +0 -42
- package/lib/Form/ServerErrorContext.d.ts +0 -11
- package/lib/Form/ServerErrorContext.js +0 -15
- package/lib/FormActions.d.ts +0 -12
- package/lib/FormActions.js +0 -22
- package/lib/FormDefaults.d.ts +0 -4
- package/lib/FormDefaults.js +0 -5
- package/lib/Group.d.ts +0 -16
- package/lib/Group.js +0 -20
- package/lib/Input/CheckboxGroup.d.ts +0 -6
- package/lib/Input/CheckboxGroup.js +0 -20
- package/lib/Input/CheckboxInputGroup.d.ts +0 -13
- package/lib/Input/CheckboxInputGroup.js +0 -46
- package/lib/Input/IconInputGroup.d.ts +0 -12
- package/lib/Input/IconInputGroup.js +0 -48
- package/lib/Input/InputGroup.d.ts +0 -12
- package/lib/Input/InputGroup.js +0 -39
- package/lib/Input/MoneyInputGroup.d.ts +0 -9
- package/lib/Input/MoneyInputGroup.js +0 -48
- package/lib/Input/NumberInputGroup.d.ts +0 -9
- package/lib/Input/NumberInputGroup.js +0 -48
- package/lib/Input/PhoneNumberInputGroup.d.ts +0 -10
- package/lib/Input/PhoneNumberInputGroup.js +0 -52
- package/lib/Input/StringInputGroup.d.ts +0 -8
- package/lib/Input/StringInputGroup.js +0 -48
- package/lib/Normalization/NormalizationFunction.d.ts +0 -4
- package/lib/Normalization/NormalizationFunction.js +0 -2
- package/lib/Normalization/normalizers.d.ts +0 -4
- package/lib/Normalization/normalizers.js +0 -37
- package/lib/Select/BooleanSelectGroup.d.ts +0 -7
- package/lib/Select/BooleanSelectGroup.js +0 -35
- package/lib/Select/NumberSelectGroup.d.ts +0 -9
- package/lib/Select/NumberSelectGroup.js +0 -29
- package/lib/Select/SelectGroup.d.ts +0 -27
- package/lib/Select/SelectGroup.js +0 -71
- package/lib/Select/SelectGroupPropsHelper.d.ts +0 -3
- package/lib/Select/SelectGroupPropsHelper.js +0 -2
- package/lib/Select/StringSelectGroup.d.ts +0 -9
- package/lib/Select/StringSelectGroup.js +0 -29
- package/lib/StandardFormActions.d.ts +0 -11
- package/lib/StandardFormActions.js +0 -20
- package/lib/SubmitFormButton.d.ts +0 -10
- package/lib/SubmitFormButton.js +0 -45
- package/lib/TextArea/TextAreaGroup.d.ts +0 -9
- package/lib/TextArea/TextAreaGroup.js +0 -40
- package/lib/Validation/ValidatedApiResult.d.ts +0 -6
- package/lib/Validation/ValidatedApiResult.js +0 -2
- package/lib/Validation/ValidationError.d.ts +0 -5
- package/lib/Validation/ValidationError.js +0 -2
- package/lib/Validation/ValidationFunction.d.ts +0 -4
- package/lib/Validation/ValidationFunction.js +0 -2
- package/lib/Validation/validators.d.ts +0 -18
- package/lib/Validation/validators.js +0 -90
- package/lib/index.d.ts +0 -77
- package/lib/index.js +0 -121
- package/lib/setupTests.d.ts +0 -1
- package/lib/setupTests.js +0 -3
- package/lib/utils/objectContainsNonSerializableProperty.d.ts +0 -1
- package/lib/utils/objectContainsNonSerializableProperty.js +0 -17
- package/lib/utils/objectToFormData.d.ts +0 -10
- package/lib/utils/objectToFormData.js +0 -79
- package/lib/utils/typeChecks.d.ts +0 -8
- package/lib/utils/typeChecks.js +0 -29
- package/src/AddressInput/AddressInput.test.tsx +0 -27
- package/src/AddressInput/AddressInput.tsx +0 -82
- package/src/AddressInput/UsStates.ts +0 -55
- package/src/AddressInput/__snapshots__/AddressInput.test.tsx.snap +0 -182
- package/src/ConfirmBaseForm/ConfirmBaseForm.test.tsx +0 -24
- package/src/ConfirmBaseForm/ConfirmBaseForm.tsx +0 -74
- package/src/ConfirmBaseForm/__snapshots__/ConfirmBaseForm.test.tsx.snap +0 -23
- package/src/ConfirmDeleteForm/ConfirmDeleteForm.test.tsx +0 -24
- package/src/ConfirmDeleteForm/ConfirmDeleteForm.tsx +0 -87
- package/src/ConfirmDeleteForm/__snapshots__/ConfirmDeleteForm.test.tsx.snap +0 -25
- package/src/DatePicker/DatePicker.test.tsx +0 -48
- package/src/DatePicker/DatePickerGroup.tsx +0 -109
- package/src/DatePicker/DatePickerHelper.ts +0 -4
- package/src/DatePicker/StringDateOnlyPickerGroup.tsx +0 -28
- package/src/DatePicker/StringDatePickerGroup.tsx +0 -20
- package/src/DatePicker/__snapshots__/DatePicker.test.tsx.snap +0 -152
- package/src/Field/CustomFieldInputProps.ts +0 -10
- package/src/Field/CustomFieldMetaProps.ts +0 -5
- package/src/Field/Field.tsx +0 -113
- package/src/Field/FieldErrorScrollTarget.tsx +0 -12
- package/src/Field/FieldNameContext.ts +0 -6
- package/src/Field/FieldSection.tsx +0 -18
- package/src/Field/InjectedFieldProps.ts +0 -8
- package/src/Field/StandAloneInput.tsx +0 -55
- package/src/Field/useStandardField.ts +0 -125
- package/src/FieldArray/FieldArray.tsx +0 -154
- package/src/File/FileGroup.test.tsx +0 -35
- package/src/File/FileGroup.tsx +0 -82
- package/src/File/FileList.tsx +0 -21
- package/src/File/__snapshots__/FileGroup.test.tsx.snap +0 -34
- package/src/File/humanFileSize.ts +0 -8
- package/src/Form/FocusError.tsx +0 -55
- package/src/Form/Form.test.tsx +0 -14
- package/src/Form/Form.tsx +0 -234
- package/src/Form/FormBasedPreventNavigation.tsx +0 -56
- package/src/Form/LegacyFormBasedPreventNavigation.tsx +0 -77
- package/src/Form/NewFormBasedPreventNavigation.tsx +0 -59
- package/src/Form/ServerErrorContext.ts +0 -18
- package/src/Form/__snapshots__/Form.test.tsx.snap +0 -10
- package/src/FormActions.tsx +0 -47
- package/src/FormDefaults.ts +0 -2
- package/src/Group.tsx +0 -62
- package/src/Input/CheckboxGroup.tsx +0 -60
- package/src/Input/CheckboxInputGroup.tsx +0 -78
- package/src/Input/IconInputGroup.tsx +0 -54
- package/src/Input/InputGroup.tsx +0 -66
- package/src/Input/MoneyInputGroup.tsx +0 -47
- package/src/Input/NumberInputGroup.tsx +0 -45
- package/src/Input/PhoneNumberInputGroup.tsx +0 -45
- package/src/Input/StringInputGroup.tsx +0 -50
- package/src/Input/__Tests__/CheckboxInputGroup.test.tsx +0 -26
- package/src/Input/__Tests__/IconInputGroup.test.tsx +0 -35
- package/src/Input/__Tests__/MoneyInputGroup.test.tsx +0 -37
- package/src/Input/__Tests__/NumberInputGroup.test.tsx +0 -35
- package/src/Input/__Tests__/PhoneNumberInputGroup.test.tsx +0 -36
- package/src/Input/__Tests__/StringInputGroup.test.tsx +0 -27
- package/src/Input/__Tests__/__snapshots__/CheckboxInputGroup.test.tsx.snap +0 -33
- package/src/Input/__Tests__/__snapshots__/IconInputGroup.test.tsx.snap +0 -32
- package/src/Input/__Tests__/__snapshots__/MoneyInputGroup.test.tsx.snap +0 -34
- package/src/Input/__Tests__/__snapshots__/NumberInputGroup.test.tsx.snap +0 -32
- package/src/Input/__Tests__/__snapshots__/PhoneNumberInputGroup.test.tsx.snap +0 -33
- package/src/Input/__Tests__/__snapshots__/StringInputGroup.test.tsx.snap +0 -31
- package/src/Normalization/NormalizationFunction.ts +0 -4
- package/src/Normalization/normalizers.ts +0 -44
- package/src/Select/BooleanSelectGroup.tsx +0 -28
- package/src/Select/NumberSelectGroup.tsx +0 -16
- package/src/Select/SelectGroup.tsx +0 -124
- package/src/Select/SelectGroupPropsHelper.ts +0 -4
- package/src/Select/StringSelectGroup.tsx +0 -16
- package/src/Select/__tests__/BooleanSelectGroup.test.tsx +0 -35
- package/src/Select/__tests__/NumberSelectGroup.test.tsx +0 -87
- package/src/Select/__tests__/StringSelectGroup.test.tsx +0 -89
- package/src/Select/__tests__/__snapshots__/BooleanSelectGroup.test.tsx.snap +0 -98
- package/src/Select/__tests__/__snapshots__/NumberSelectGroup.test.tsx.snap +0 -195
- package/src/Select/__tests__/__snapshots__/StringSelectGroup.test.tsx.snap +0 -195
- package/src/StandardFormActions.tsx +0 -41
- package/src/SubmitFormButton.tsx +0 -54
- package/src/TextArea/TextAreaGroup.tsx +0 -64
- package/src/Validation/ValidatedApiResult.ts +0 -8
- package/src/Validation/ValidationError.ts +0 -6
- package/src/Validation/ValidationFunction.ts +0 -4
- package/src/Validation/validators.test.tsx +0 -81
- package/src/Validation/validators.ts +0 -97
- package/src/__Tests__/FormTestBase.tsx +0 -65
- package/src/__Tests__/RealisticForm.test.tsx +0 -82
- package/src/__Tests__/StandardFormActions.test.tsx +0 -17
- package/src/__Tests__/SubmitFormButton.test.tsx +0 -17
- package/src/__Tests__/__snapshots__/StandardFormActions.test.tsx.snap +0 -27
- package/src/__Tests__/__snapshots__/SubmitFormButton.test.tsx.snap +0 -20
- package/src/__Tests__/index.ts +0 -3
- package/src/_variables.scss +0 -11
- package/src/index.ts +0 -156
- package/src/react-app-env.d.ts +0 -1
- package/src/setupTests.ts +0 -1
- package/src/styles.scss +0 -0
- package/src/utils/objectContainsNonSerializableProperty.test.tsx +0 -49
- package/src/utils/objectContainsNonSerializableProperty.ts +0 -17
- package/src/utils/objectToFormData.test.tsx +0 -76
- package/src/utils/objectToFormData.ts +0 -105
- package/src/utils/typeChecks.ts +0 -18
@@ -1,90 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.any = exports.zipCode = exports.minValue = exports.maxValue = exports.minCount = exports.maxCount = exports.maxLength = exports.integer = exports.length = exports.required = void 0;
|
4
|
-
var required = function (value) {
|
5
|
-
return Array.isArray(value)
|
6
|
-
? value.length > 0
|
7
|
-
? undefined
|
8
|
-
: 'Required'
|
9
|
-
: value || value === false || value === 0
|
10
|
-
? undefined
|
11
|
-
: 'Required';
|
12
|
-
};
|
13
|
-
exports.required = required;
|
14
|
-
/** Asserts that the value is a certain number of characters. numbers are coerced to a string */
|
15
|
-
var length = function (len) { return function (value) {
|
16
|
-
var hasError = getLengthOfValue(value) !== len;
|
17
|
-
return !hasError ? undefined : "Length must be ".concat(len);
|
18
|
-
}; };
|
19
|
-
exports.length = length;
|
20
|
-
var integer = function (val) {
|
21
|
-
if (!val) {
|
22
|
-
return undefined;
|
23
|
-
}
|
24
|
-
if (!Number.isInteger(typeof val === 'number' ? val : parseFloat(val))) {
|
25
|
-
return 'Must be a whole number';
|
26
|
-
}
|
27
|
-
};
|
28
|
-
exports.integer = integer;
|
29
|
-
var maxLength = function (len) { return function (value) {
|
30
|
-
var hasError = getLengthOfValue(value) > len;
|
31
|
-
return !hasError ? undefined : "Maximum length ".concat(len, " exceeded");
|
32
|
-
}; };
|
33
|
-
exports.maxLength = maxLength;
|
34
|
-
var maxCount = function (count) { return function (value) {
|
35
|
-
var hasError = !!value && value.filter(function (x) { return !x.isDeleted; }).length > count;
|
36
|
-
return !hasError ? undefined : "Should not have more than ".concat(count);
|
37
|
-
}; };
|
38
|
-
exports.maxCount = maxCount;
|
39
|
-
var minCount = function (count) { return function (value) {
|
40
|
-
var hasError = !value || value.filter(function (x) { return !x.isDeleted; }).length < count;
|
41
|
-
return !hasError ? undefined : "Should have at least ".concat(count);
|
42
|
-
}; };
|
43
|
-
exports.minCount = minCount;
|
44
|
-
var maxValue = function (max) { return function (value) {
|
45
|
-
var hasError = !!value && value > max;
|
46
|
-
return !hasError ? undefined : "Maximum value ".concat(max, " exceeded");
|
47
|
-
}; };
|
48
|
-
exports.maxValue = maxValue;
|
49
|
-
var minValue = function (min) { return function (value) {
|
50
|
-
var hasError = !value || value < min;
|
51
|
-
return !hasError ? undefined : "Minimum value ".concat(min, " not met");
|
52
|
-
}; };
|
53
|
-
exports.minValue = minValue;
|
54
|
-
/** Validate for a ZIP Code. Accepts formats: ##### and #####-#### */
|
55
|
-
var zipCode = function (value) {
|
56
|
-
return value && !/^[0-9]{5}(?:-[0-9]{4})?$/.test(value)
|
57
|
-
? 'Invalid ZIP Code'
|
58
|
-
: undefined;
|
59
|
-
};
|
60
|
-
exports.zipCode = zipCode;
|
61
|
-
/** One of the validators provided must be true. */
|
62
|
-
var any = function (validatorList) {
|
63
|
-
return function (value) {
|
64
|
-
if (validatorList.length === 0 || !value) {
|
65
|
-
return;
|
66
|
-
}
|
67
|
-
return validatorList.reduce(function (isAnyTrue, x) { return (isAnyTrue ? isAnyTrue : x(value)); }, undefined);
|
68
|
-
};
|
69
|
-
};
|
70
|
-
exports.any = any;
|
71
|
-
function getLengthOfValue(value) {
|
72
|
-
if (value === null) {
|
73
|
-
return 0;
|
74
|
-
}
|
75
|
-
switch (typeof value) {
|
76
|
-
case 'undefined':
|
77
|
-
return 0;
|
78
|
-
case 'string':
|
79
|
-
return value.length;
|
80
|
-
case 'number':
|
81
|
-
// TODO: this seems iffy to me - what if the actual visible value is a fixed length or some special format (e.g. with commas?)
|
82
|
-
return value.toString().length;
|
83
|
-
default:
|
84
|
-
assertUnreachable(value);
|
85
|
-
return 0;
|
86
|
-
}
|
87
|
-
}
|
88
|
-
function assertUnreachable(x) {
|
89
|
-
return null;
|
90
|
-
}
|
package/lib/index.d.ts
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
export { default as AddressInput } from './AddressInput/AddressInput';
|
2
|
-
export type { AddressInputProps } from './AddressInput/AddressInput';
|
3
|
-
export { default as SubmitFormButton } from './SubmitFormButton';
|
4
|
-
export type { SubmitFormButtonProps } from './SubmitFormButton';
|
5
|
-
export { default as ConfirmBaseForm } from './ConfirmBaseForm/ConfirmBaseForm';
|
6
|
-
export type { ConfirmBaseFormProps } from './ConfirmBaseForm/ConfirmBaseForm';
|
7
|
-
export { default as ConfirmDeleteForm } from './ConfirmDeleteForm/ConfirmDeleteForm';
|
8
|
-
export type { ConfirmDeleteFormProps } from './ConfirmDeleteForm/ConfirmDeleteForm';
|
9
|
-
export { default as DatePickerGroup } from './DatePicker/DatePickerGroup';
|
10
|
-
export type { DatePickerGroupProps } from './DatePicker/DatePickerGroup';
|
11
|
-
export { convertToTimeZoneInsensitiveISOString } from './DatePicker/DatePickerGroup';
|
12
|
-
export type { DatePickerHelper } from './DatePicker/DatePickerHelper';
|
13
|
-
export { default as StringDatePickerGroup } from './DatePicker/StringDatePickerGroup';
|
14
|
-
export type { StringDatePickerGroupProps } from './DatePicker/StringDatePickerGroup';
|
15
|
-
export { default as StringDateOnlyPickerGroup } from './DatePicker/StringDateOnlyPickerGroup';
|
16
|
-
export type { StringDateOnlyPickerGroupProps } from './DatePicker/StringDateOnlyPickerGroup';
|
17
|
-
export { default as Field } from './Field/Field';
|
18
|
-
export type { FieldProps } from './Field/Field';
|
19
|
-
export type { RenderComponent } from './Field/Field';
|
20
|
-
export type { RenderComponentProps } from './Field/Field';
|
21
|
-
export { default as FieldErrorScrollTarget } from './Field/FieldErrorScrollTarget';
|
22
|
-
export { FieldNameContext } from './Field/FieldNameContext';
|
23
|
-
export type { InjectedFieldProps } from './Field/InjectedFieldProps';
|
24
|
-
export { default as StandAloneInput } from './Field/StandAloneInput';
|
25
|
-
export type { StandAloneInputProps } from './Field/StandAloneInput';
|
26
|
-
export { default as useStandardField } from './Field/useStandardField';
|
27
|
-
export type { useStandardFieldProps } from './Field/useStandardField';
|
28
|
-
export { default as FieldArray } from './FieldArray/FieldArray';
|
29
|
-
export type { FieldArrayProps, ArrayFormBuilderProp, } from './FieldArray/FieldArray';
|
30
|
-
export { default as FileGroup } from './File/FileGroup';
|
31
|
-
export type { FileGroupProps } from './File/FileGroup';
|
32
|
-
export { default as Form } from './Form/Form';
|
33
|
-
export type { FormBuilderProp, FormProps } from './Form/Form';
|
34
|
-
export { ServerErrorContext } from './Form/ServerErrorContext';
|
35
|
-
export type { ServerErrorContextProps, ServerErrors, } from './Form/ServerErrorContext';
|
36
|
-
export { default as FormActions } from './FormActions';
|
37
|
-
export type { FormActionsProps } from './FormActions';
|
38
|
-
export { default as StandardFormActions } from './StandardFormActions';
|
39
|
-
export type { StandardFormActionsProps } from './StandardFormActions';
|
40
|
-
export { FormDefaults } from './FormDefaults';
|
41
|
-
export { default as Group } from './Group';
|
42
|
-
export type { GroupProps } from './Group';
|
43
|
-
export { default as IconInputGroup } from './Input/IconInputGroup';
|
44
|
-
export type { IconInputGroupProps } from './Input/IconInputGroup';
|
45
|
-
export { default as InputGroup } from './Input/InputGroup';
|
46
|
-
export type { InputGroupProps } from './Input/InputGroup';
|
47
|
-
export { default as MoneyInputGroup } from './Input/MoneyInputGroup';
|
48
|
-
export type { MoneyInputGroupProps } from './Input/MoneyInputGroup';
|
49
|
-
export { default as NumberInputGroup } from './Input/NumberInputGroup';
|
50
|
-
export type { NumberInputGroupProps } from './Input/NumberInputGroup';
|
51
|
-
export { default as PhoneNumberInputGroup } from './Input/PhoneNumberInputGroup';
|
52
|
-
export type { PhoneNumberInputGroupProps } from './Input/PhoneNumberInputGroup';
|
53
|
-
export { default as StringInputGroup } from './Input/StringInputGroup';
|
54
|
-
export type { StringInputGroupProps } from './Input/StringInputGroup';
|
55
|
-
export type { NormalizationFunction } from './Normalization/NormalizationFunction';
|
56
|
-
export * as normalizers from './Normalization/normalizers';
|
57
|
-
export { default as SelectGroup } from './Select/SelectGroup';
|
58
|
-
export type { SelectGroupProps, SelectOption } from './Select/SelectGroup';
|
59
|
-
export { BooleanSelectGroup } from './Select/BooleanSelectGroup';
|
60
|
-
export type { BooleanSelectGroupProps } from './Select/BooleanSelectGroup';
|
61
|
-
export { default as CheckboxInputGroup } from './Input/CheckboxInputGroup';
|
62
|
-
export type { CheckboxInputGroupProps } from './Input/CheckboxInputGroup';
|
63
|
-
export { MultiNumberSelectGroup, SingleNumberSelectGroup, } from './Select/NumberSelectGroup';
|
64
|
-
export type { MultiNumberSelectGroupProps, SingleNumberSelectGroupProps, } from './Select/NumberSelectGroup';
|
65
|
-
export type { SelectGroupPropsHelper } from './Select/SelectGroupPropsHelper';
|
66
|
-
export { MultiStringSelectGroup, SingleStringSelectGroup, } from './Select/StringSelectGroup';
|
67
|
-
export type { MultiStringSelectGroupProps, SingleStringSelectGroupProps, } from './Select/StringSelectGroup';
|
68
|
-
export { default as TextAreaGroup } from './TextArea/TextAreaGroup';
|
69
|
-
export type { TextAreaGroupProps } from './TextArea/TextAreaGroup';
|
70
|
-
export { default as objectContainsNonSerializableProperty } from './utils/objectContainsNonSerializableProperty';
|
71
|
-
export { default as serialize } from './utils/objectToFormData';
|
72
|
-
export type { ObjectToFormDataCfgProps } from './utils/objectToFormData';
|
73
|
-
export * from './utils/typeChecks';
|
74
|
-
export type { ValidatedApiResult } from './Validation/ValidatedApiResult';
|
75
|
-
export type { ValidationError } from './Validation/ValidationError';
|
76
|
-
export type { ValidationFunction } from './Validation/ValidationFunction';
|
77
|
-
export * as validators from './Validation/validators';
|
package/lib/index.js
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
-
}) : function(o, v) {
|
16
|
-
o["default"] = v;
|
17
|
-
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
-
if (mod && mod.__esModule) return mod;
|
20
|
-
var result = {};
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
-
__setModuleDefault(result, mod);
|
23
|
-
return result;
|
24
|
-
};
|
25
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
26
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
27
|
-
};
|
28
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
29
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
30
|
-
};
|
31
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
32
|
-
exports.validators = exports.serialize = exports.objectContainsNonSerializableProperty = exports.TextAreaGroup = exports.SingleStringSelectGroup = exports.MultiStringSelectGroup = exports.SingleNumberSelectGroup = exports.MultiNumberSelectGroup = exports.CheckboxInputGroup = exports.BooleanSelectGroup = exports.SelectGroup = exports.normalizers = exports.StringInputGroup = exports.PhoneNumberInputGroup = exports.NumberInputGroup = exports.MoneyInputGroup = exports.InputGroup = exports.IconInputGroup = exports.Group = exports.FormDefaults = exports.StandardFormActions = exports.FormActions = exports.ServerErrorContext = exports.Form = exports.FileGroup = exports.FieldArray = exports.useStandardField = exports.StandAloneInput = exports.FieldNameContext = exports.FieldErrorScrollTarget = exports.Field = exports.StringDateOnlyPickerGroup = exports.StringDatePickerGroup = exports.convertToTimeZoneInsensitiveISOString = exports.DatePickerGroup = exports.ConfirmDeleteForm = exports.ConfirmBaseForm = exports.SubmitFormButton = exports.AddressInput = void 0;
|
33
|
-
// Address
|
34
|
-
var AddressInput_1 = require("./AddressInput/AddressInput");
|
35
|
-
Object.defineProperty(exports, "AddressInput", { enumerable: true, get: function () { return __importDefault(AddressInput_1).default; } });
|
36
|
-
// Button
|
37
|
-
var SubmitFormButton_1 = require("./SubmitFormButton");
|
38
|
-
Object.defineProperty(exports, "SubmitFormButton", { enumerable: true, get: function () { return __importDefault(SubmitFormButton_1).default; } });
|
39
|
-
// ConfirmBaseForm
|
40
|
-
var ConfirmBaseForm_1 = require("./ConfirmBaseForm/ConfirmBaseForm");
|
41
|
-
Object.defineProperty(exports, "ConfirmBaseForm", { enumerable: true, get: function () { return __importDefault(ConfirmBaseForm_1).default; } });
|
42
|
-
// ConfirmDeleteForm
|
43
|
-
var ConfirmDeleteForm_1 = require("./ConfirmDeleteForm/ConfirmDeleteForm");
|
44
|
-
Object.defineProperty(exports, "ConfirmDeleteForm", { enumerable: true, get: function () { return __importDefault(ConfirmDeleteForm_1).default; } });
|
45
|
-
// Date
|
46
|
-
var DatePickerGroup_1 = require("./DatePicker/DatePickerGroup");
|
47
|
-
Object.defineProperty(exports, "DatePickerGroup", { enumerable: true, get: function () { return __importDefault(DatePickerGroup_1).default; } });
|
48
|
-
var DatePickerGroup_2 = require("./DatePicker/DatePickerGroup");
|
49
|
-
Object.defineProperty(exports, "convertToTimeZoneInsensitiveISOString", { enumerable: true, get: function () { return DatePickerGroup_2.convertToTimeZoneInsensitiveISOString; } });
|
50
|
-
var StringDatePickerGroup_1 = require("./DatePicker/StringDatePickerGroup");
|
51
|
-
Object.defineProperty(exports, "StringDatePickerGroup", { enumerable: true, get: function () { return __importDefault(StringDatePickerGroup_1).default; } });
|
52
|
-
var StringDateOnlyPickerGroup_1 = require("./DatePicker/StringDateOnlyPickerGroup");
|
53
|
-
Object.defineProperty(exports, "StringDateOnlyPickerGroup", { enumerable: true, get: function () { return __importDefault(StringDateOnlyPickerGroup_1).default; } });
|
54
|
-
// Field
|
55
|
-
var Field_1 = require("./Field/Field");
|
56
|
-
Object.defineProperty(exports, "Field", { enumerable: true, get: function () { return __importDefault(Field_1).default; } });
|
57
|
-
var FieldErrorScrollTarget_1 = require("./Field/FieldErrorScrollTarget");
|
58
|
-
Object.defineProperty(exports, "FieldErrorScrollTarget", { enumerable: true, get: function () { return __importDefault(FieldErrorScrollTarget_1).default; } });
|
59
|
-
var FieldNameContext_1 = require("./Field/FieldNameContext");
|
60
|
-
Object.defineProperty(exports, "FieldNameContext", { enumerable: true, get: function () { return FieldNameContext_1.FieldNameContext; } });
|
61
|
-
var StandAloneInput_1 = require("./Field/StandAloneInput");
|
62
|
-
Object.defineProperty(exports, "StandAloneInput", { enumerable: true, get: function () { return __importDefault(StandAloneInput_1).default; } });
|
63
|
-
var useStandardField_1 = require("./Field/useStandardField");
|
64
|
-
Object.defineProperty(exports, "useStandardField", { enumerable: true, get: function () { return __importDefault(useStandardField_1).default; } });
|
65
|
-
// Field Array
|
66
|
-
var FieldArray_1 = require("./FieldArray/FieldArray");
|
67
|
-
Object.defineProperty(exports, "FieldArray", { enumerable: true, get: function () { return __importDefault(FieldArray_1).default; } });
|
68
|
-
// File
|
69
|
-
var FileGroup_1 = require("./File/FileGroup");
|
70
|
-
Object.defineProperty(exports, "FileGroup", { enumerable: true, get: function () { return __importDefault(FileGroup_1).default; } });
|
71
|
-
// Form
|
72
|
-
var Form_1 = require("./Form/Form");
|
73
|
-
Object.defineProperty(exports, "Form", { enumerable: true, get: function () { return __importDefault(Form_1).default; } });
|
74
|
-
var ServerErrorContext_1 = require("./Form/ServerErrorContext");
|
75
|
-
Object.defineProperty(exports, "ServerErrorContext", { enumerable: true, get: function () { return ServerErrorContext_1.ServerErrorContext; } });
|
76
|
-
var FormActions_1 = require("./FormActions");
|
77
|
-
Object.defineProperty(exports, "FormActions", { enumerable: true, get: function () { return __importDefault(FormActions_1).default; } });
|
78
|
-
var StandardFormActions_1 = require("./StandardFormActions");
|
79
|
-
Object.defineProperty(exports, "StandardFormActions", { enumerable: true, get: function () { return __importDefault(StandardFormActions_1).default; } });
|
80
|
-
// FormDefaults
|
81
|
-
var FormDefaults_1 = require("./FormDefaults");
|
82
|
-
Object.defineProperty(exports, "FormDefaults", { enumerable: true, get: function () { return FormDefaults_1.FormDefaults; } });
|
83
|
-
// Input
|
84
|
-
var Group_1 = require("./Group");
|
85
|
-
Object.defineProperty(exports, "Group", { enumerable: true, get: function () { return __importDefault(Group_1).default; } });
|
86
|
-
var IconInputGroup_1 = require("./Input/IconInputGroup");
|
87
|
-
Object.defineProperty(exports, "IconInputGroup", { enumerable: true, get: function () { return __importDefault(IconInputGroup_1).default; } });
|
88
|
-
var InputGroup_1 = require("./Input/InputGroup");
|
89
|
-
Object.defineProperty(exports, "InputGroup", { enumerable: true, get: function () { return __importDefault(InputGroup_1).default; } });
|
90
|
-
var MoneyInputGroup_1 = require("./Input/MoneyInputGroup");
|
91
|
-
Object.defineProperty(exports, "MoneyInputGroup", { enumerable: true, get: function () { return __importDefault(MoneyInputGroup_1).default; } });
|
92
|
-
var NumberInputGroup_1 = require("./Input/NumberInputGroup");
|
93
|
-
Object.defineProperty(exports, "NumberInputGroup", { enumerable: true, get: function () { return __importDefault(NumberInputGroup_1).default; } });
|
94
|
-
var PhoneNumberInputGroup_1 = require("./Input/PhoneNumberInputGroup");
|
95
|
-
Object.defineProperty(exports, "PhoneNumberInputGroup", { enumerable: true, get: function () { return __importDefault(PhoneNumberInputGroup_1).default; } });
|
96
|
-
var StringInputGroup_1 = require("./Input/StringInputGroup");
|
97
|
-
Object.defineProperty(exports, "StringInputGroup", { enumerable: true, get: function () { return __importDefault(StringInputGroup_1).default; } });
|
98
|
-
exports.normalizers = __importStar(require("./Normalization/normalizers"));
|
99
|
-
// Select
|
100
|
-
var SelectGroup_1 = require("./Select/SelectGroup");
|
101
|
-
Object.defineProperty(exports, "SelectGroup", { enumerable: true, get: function () { return __importDefault(SelectGroup_1).default; } });
|
102
|
-
var BooleanSelectGroup_1 = require("./Select/BooleanSelectGroup");
|
103
|
-
Object.defineProperty(exports, "BooleanSelectGroup", { enumerable: true, get: function () { return BooleanSelectGroup_1.BooleanSelectGroup; } });
|
104
|
-
var CheckboxInputGroup_1 = require("./Input/CheckboxInputGroup");
|
105
|
-
Object.defineProperty(exports, "CheckboxInputGroup", { enumerable: true, get: function () { return __importDefault(CheckboxInputGroup_1).default; } });
|
106
|
-
var NumberSelectGroup_1 = require("./Select/NumberSelectGroup");
|
107
|
-
Object.defineProperty(exports, "MultiNumberSelectGroup", { enumerable: true, get: function () { return NumberSelectGroup_1.MultiNumberSelectGroup; } });
|
108
|
-
Object.defineProperty(exports, "SingleNumberSelectGroup", { enumerable: true, get: function () { return NumberSelectGroup_1.SingleNumberSelectGroup; } });
|
109
|
-
var StringSelectGroup_1 = require("./Select/StringSelectGroup");
|
110
|
-
Object.defineProperty(exports, "MultiStringSelectGroup", { enumerable: true, get: function () { return StringSelectGroup_1.MultiStringSelectGroup; } });
|
111
|
-
Object.defineProperty(exports, "SingleStringSelectGroup", { enumerable: true, get: function () { return StringSelectGroup_1.SingleStringSelectGroup; } });
|
112
|
-
// Text Area
|
113
|
-
var TextAreaGroup_1 = require("./TextArea/TextAreaGroup");
|
114
|
-
Object.defineProperty(exports, "TextAreaGroup", { enumerable: true, get: function () { return __importDefault(TextAreaGroup_1).default; } });
|
115
|
-
// Utils
|
116
|
-
var objectContainsNonSerializableProperty_1 = require("./utils/objectContainsNonSerializableProperty");
|
117
|
-
Object.defineProperty(exports, "objectContainsNonSerializableProperty", { enumerable: true, get: function () { return __importDefault(objectContainsNonSerializableProperty_1).default; } });
|
118
|
-
var objectToFormData_1 = require("./utils/objectToFormData");
|
119
|
-
Object.defineProperty(exports, "serialize", { enumerable: true, get: function () { return __importDefault(objectToFormData_1).default; } });
|
120
|
-
__exportStar(require("./utils/typeChecks"), exports);
|
121
|
-
exports.validators = __importStar(require("./Validation/validators"));
|
package/lib/setupTests.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import '@testing-library/jest-dom/extend-expect';
|
package/lib/setupTests.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export default function objectContainsNonSerializableProperty(object: any): boolean;
|
@@ -1,17 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
var typeChecks_1 = require("./typeChecks");
|
4
|
-
function objectContainsNonSerializableProperty(object) {
|
5
|
-
return Object.entries(object).some(function (value) {
|
6
|
-
if (value) {
|
7
|
-
if ((0, typeChecks_1.isBlob)(value[1]) || (0, typeChecks_1.isFile)(value[1])) {
|
8
|
-
return true;
|
9
|
-
}
|
10
|
-
if ((0, typeChecks_1.isObject)(value[1])) {
|
11
|
-
return objectContainsNonSerializableProperty(value[1]);
|
12
|
-
}
|
13
|
-
}
|
14
|
-
return false;
|
15
|
-
});
|
16
|
-
}
|
17
|
-
exports.default = objectContainsNonSerializableProperty;
|
@@ -1,10 +0,0 @@
|
|
1
|
-
export interface ObjectToFormDataCfgProps {
|
2
|
-
indices: boolean;
|
3
|
-
dotNotation: boolean;
|
4
|
-
allowEmptyArrays: boolean;
|
5
|
-
noFileListBrackets: boolean;
|
6
|
-
nullsAsUndefineds?: boolean;
|
7
|
-
booleansAsIntegers?: boolean;
|
8
|
-
}
|
9
|
-
declare const serialize: (obj: any, cfg: ObjectToFormDataCfgProps, fd?: FormData, pre?: string) => FormData;
|
10
|
-
export default serialize;
|
@@ -1,79 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
// Original: https://github.com/therealparmesh/object-to-formdata/blob/master/src/index.js
|
4
|
-
// With Multiple Form File Fix: https://github.com/therealparmesh/object-to-formdata/pull/94/files
|
5
|
-
var typeChecks_1 = require("./typeChecks");
|
6
|
-
// 'pre' is not provided until this function recursively calls itself when 'obj' is an array or object
|
7
|
-
var serialize = function (obj, cfg, fd, pre) {
|
8
|
-
cfg = cfg || {};
|
9
|
-
cfg.indices = (0, typeChecks_1.isUndefined)(cfg.indices) ? false : cfg.indices;
|
10
|
-
cfg.nullsAsUndefineds = (0, typeChecks_1.isUndefined)(cfg.nullsAsUndefineds)
|
11
|
-
? false
|
12
|
-
: cfg.nullsAsUndefineds;
|
13
|
-
cfg.booleansAsIntegers = (0, typeChecks_1.isUndefined)(cfg.booleansAsIntegers)
|
14
|
-
? false
|
15
|
-
: cfg.booleansAsIntegers;
|
16
|
-
cfg.allowEmptyArrays = (0, typeChecks_1.isUndefined)(cfg.allowEmptyArrays)
|
17
|
-
? false
|
18
|
-
: cfg.allowEmptyArrays;
|
19
|
-
//reverse of normal because we want a different default
|
20
|
-
cfg.dotNotation = (0, typeChecks_1.isUndefined)(cfg.dotNotation) ? true : cfg.dotNotation;
|
21
|
-
fd = fd || new FormData();
|
22
|
-
if ((0, typeChecks_1.isUndefined)(obj)) {
|
23
|
-
return fd;
|
24
|
-
}
|
25
|
-
else if ((0, typeChecks_1.isNull)(obj) && !!pre) {
|
26
|
-
if (!cfg.nullsAsUndefineds) {
|
27
|
-
fd.append(pre, '');
|
28
|
-
}
|
29
|
-
}
|
30
|
-
else if ((0, typeChecks_1.isBoolean)(obj) && !!pre) {
|
31
|
-
if (cfg.booleansAsIntegers) {
|
32
|
-
fd.append(pre, obj ? '1' : '0');
|
33
|
-
}
|
34
|
-
else {
|
35
|
-
fd.append(pre, obj);
|
36
|
-
}
|
37
|
-
}
|
38
|
-
else if ((0, typeChecks_1.isDate)(obj) && !!pre) {
|
39
|
-
fd.append(pre, obj.toISOString());
|
40
|
-
}
|
41
|
-
else if ((0, typeChecks_1.isArray)(obj)) {
|
42
|
-
if (obj.length) {
|
43
|
-
obj.forEach(function (value, index) {
|
44
|
-
var key;
|
45
|
-
if (cfg.noFileListBrackets && (0, typeChecks_1.isFile)(value)) {
|
46
|
-
key = pre;
|
47
|
-
}
|
48
|
-
else {
|
49
|
-
key = pre + '[' + (cfg.indices ? index : '') + ']';
|
50
|
-
}
|
51
|
-
serialize(value, cfg, fd, key);
|
52
|
-
});
|
53
|
-
}
|
54
|
-
else if (cfg.allowEmptyArrays) {
|
55
|
-
fd.append(pre + '[]', '');
|
56
|
-
}
|
57
|
-
}
|
58
|
-
else if ((0, typeChecks_1.isObject)(obj) && !(0, typeChecks_1.isFile)(obj) && !(0, typeChecks_1.isBlob)(obj)) {
|
59
|
-
Object.keys(obj).forEach(function (prop) {
|
60
|
-
var value = obj[prop];
|
61
|
-
if ((0, typeChecks_1.isArray)(value)) {
|
62
|
-
while (prop.length > 2 && prop.lastIndexOf('[]') === prop.length - 2) {
|
63
|
-
prop = prop.substring(0, prop.length - 2);
|
64
|
-
}
|
65
|
-
}
|
66
|
-
var key = pre
|
67
|
-
? cfg.dotNotation
|
68
|
-
? pre + '.' + prop
|
69
|
-
: pre + '[' + prop + ']'
|
70
|
-
: prop;
|
71
|
-
serialize(value, cfg, fd, key);
|
72
|
-
});
|
73
|
-
}
|
74
|
-
else if (!!pre) {
|
75
|
-
fd.append(pre, obj);
|
76
|
-
}
|
77
|
-
return fd;
|
78
|
-
};
|
79
|
-
exports.default = serialize;
|
@@ -1,8 +0,0 @@
|
|
1
|
-
export declare const isUndefined: (value: any) => boolean;
|
2
|
-
export declare const isNull: (value: any) => boolean;
|
3
|
-
export declare const isBoolean: (value: any) => boolean;
|
4
|
-
export declare const isObject: (value: any) => boolean;
|
5
|
-
export declare const isArray: (value: any) => boolean;
|
6
|
-
export declare const isDate: (value: any) => boolean;
|
7
|
-
export declare const isBlob: (value: any) => any;
|
8
|
-
export declare const isFile: (value: any) => any;
|
package/lib/utils/typeChecks.js
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.isFile = exports.isBlob = exports.isDate = exports.isArray = exports.isObject = exports.isBoolean = exports.isNull = exports.isUndefined = void 0;
|
4
|
-
var isUndefined = function (value) { return value === undefined; };
|
5
|
-
exports.isUndefined = isUndefined;
|
6
|
-
var isNull = function (value) { return value === null; };
|
7
|
-
exports.isNull = isNull;
|
8
|
-
var isBoolean = function (value) { return typeof value === 'boolean'; };
|
9
|
-
exports.isBoolean = isBoolean;
|
10
|
-
var isObject = function (value) { return value === Object(value); };
|
11
|
-
exports.isObject = isObject;
|
12
|
-
var isArray = function (value) { return Array.isArray(value); };
|
13
|
-
exports.isArray = isArray;
|
14
|
-
var isDate = function (value) { return value instanceof Date; };
|
15
|
-
exports.isDate = isDate;
|
16
|
-
var isBlob = function (value) {
|
17
|
-
return value &&
|
18
|
-
typeof value.size === 'number' &&
|
19
|
-
typeof value.type === 'string' &&
|
20
|
-
typeof value.slice === 'function';
|
21
|
-
};
|
22
|
-
exports.isBlob = isBlob;
|
23
|
-
var isFile = function (value) {
|
24
|
-
return (0, exports.isBlob)(value) &&
|
25
|
-
typeof value.name === 'string' &&
|
26
|
-
(typeof value.lastModifiedDate === 'object' ||
|
27
|
-
typeof value.lastModified === 'number');
|
28
|
-
};
|
29
|
-
exports.isFile = isFile;
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { render } from '@testing-library/react';
|
3
|
-
import AddressInput from './AddressInput';
|
4
|
-
import FormTestBase from '../__Tests__/FormTestBase';
|
5
|
-
|
6
|
-
describe('AddressInput', () => {
|
7
|
-
it('renders without crashing', () => {
|
8
|
-
render(
|
9
|
-
<FormTestBase>
|
10
|
-
{({ Field }) => (
|
11
|
-
<AddressInput fieldBuilder={{ Field }} name="normalAddressInput" />
|
12
|
-
)}
|
13
|
-
</FormTestBase>
|
14
|
-
);
|
15
|
-
});
|
16
|
-
|
17
|
-
it('has matching snapshot', () => {
|
18
|
-
const renderResult = render(
|
19
|
-
<FormTestBase>
|
20
|
-
{({ Field }) => (
|
21
|
-
<AddressInput fieldBuilder={{ Field }} name="normalAddressInput" />
|
22
|
-
)}
|
23
|
-
</FormTestBase>
|
24
|
-
);
|
25
|
-
expect(renderResult.asFragment()).toMatchSnapshot();
|
26
|
-
});
|
27
|
-
});
|
@@ -1,82 +0,0 @@
|
|
1
|
-
import UsStates from './UsStates';
|
2
|
-
import { SingleStringSelectGroup, StringInputGroup } from '../';
|
3
|
-
import FieldSection from '../Field/FieldSection';
|
4
|
-
import { FormBuilderProp } from '../Form/Form';
|
5
|
-
import { zipCode as zipCodeNormalizer } from '../Normalization/normalizers';
|
6
|
-
import {
|
7
|
-
required,
|
8
|
-
zipCode as zipCodeValidator,
|
9
|
-
} from '../Validation/validators';
|
10
|
-
|
11
|
-
// TODO: find a permanent home for these interfaces
|
12
|
-
// TODO: but also, maybe they are comfortable here?
|
13
|
-
export interface AddressInputProps {
|
14
|
-
fieldBuilder: Pick<FormBuilderProp<AddressDto>, 'Field'>;
|
15
|
-
name: string;
|
16
|
-
}
|
17
|
-
|
18
|
-
interface AddressDto {
|
19
|
-
address1?: string | null;
|
20
|
-
address2?: string | null;
|
21
|
-
zipCode?: string | null;
|
22
|
-
city?: string | null;
|
23
|
-
state?: string | null;
|
24
|
-
}
|
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
|
-
*/
|
36
|
-
export default function AddressInput({
|
37
|
-
fieldBuilder: { Field },
|
38
|
-
name,
|
39
|
-
}: AddressInputProps) {
|
40
|
-
return (
|
41
|
-
<>
|
42
|
-
<FieldSection name={name}>
|
43
|
-
<Field
|
44
|
-
name="address1"
|
45
|
-
placeholder="Address, Line 1"
|
46
|
-
label="Address 1"
|
47
|
-
Component={StringInputGroup}
|
48
|
-
validate={required}
|
49
|
-
/>
|
50
|
-
<Field
|
51
|
-
name="address2"
|
52
|
-
placeholder="Address, Line 2"
|
53
|
-
label="Address 2"
|
54
|
-
Component={StringInputGroup}
|
55
|
-
/>
|
56
|
-
<Field
|
57
|
-
name="city"
|
58
|
-
placeholder="City"
|
59
|
-
label="City"
|
60
|
-
Component={StringInputGroup}
|
61
|
-
validate={required}
|
62
|
-
/>
|
63
|
-
<Field
|
64
|
-
name="state"
|
65
|
-
placeholder="State"
|
66
|
-
label="State"
|
67
|
-
Component={SingleStringSelectGroup}
|
68
|
-
options={UsStates}
|
69
|
-
validate={required}
|
70
|
-
/>
|
71
|
-
<Field
|
72
|
-
name="zipCode"
|
73
|
-
placeholder="Zip"
|
74
|
-
label="Zip"
|
75
|
-
Component={StringInputGroup}
|
76
|
-
normalize={zipCodeNormalizer}
|
77
|
-
validate={[required, zipCodeValidator]}
|
78
|
-
/>
|
79
|
-
</FieldSection>
|
80
|
-
</>
|
81
|
-
);
|
82
|
-
}
|
@@ -1,55 +0,0 @@
|
|
1
|
-
import { SelectOption } from '../Select/SelectGroup';
|
2
|
-
|
3
|
-
const states: SelectOption<string>[] = [
|
4
|
-
{ label: 'Alabama', value: 'AL' },
|
5
|
-
{ label: 'Alaska', value: 'AK' },
|
6
|
-
{ label: 'Arizona', value: 'AZ' },
|
7
|
-
{ label: 'Arkansas', value: 'AR' },
|
8
|
-
{ label: 'California', value: 'CA' },
|
9
|
-
{ label: 'Colorado', value: 'CO' },
|
10
|
-
{ label: 'Connecticut', value: 'CT' },
|
11
|
-
{ label: 'Delaware', value: 'DE' },
|
12
|
-
{ label: 'Florida', value: 'FL' },
|
13
|
-
{ label: 'Georgia', value: 'GA' },
|
14
|
-
{ label: 'Hawaii', value: 'HI' },
|
15
|
-
{ label: 'Idaho', value: 'ID' },
|
16
|
-
{ label: 'Illinois', value: 'IL' },
|
17
|
-
{ label: 'Indiana', value: 'IN' },
|
18
|
-
{ label: 'Iowa', value: 'IA' },
|
19
|
-
{ label: 'Kansas', value: 'KS' },
|
20
|
-
{ label: 'Kentucky', value: 'KY' },
|
21
|
-
{ label: 'Louisiana', value: 'LA' },
|
22
|
-
{ label: 'Maine', value: 'ME' },
|
23
|
-
{ label: 'Maryland', value: 'MD' },
|
24
|
-
{ label: 'Massachusetts', value: 'MA' },
|
25
|
-
{ label: 'Michigan', value: 'MI' },
|
26
|
-
{ label: 'Minnesota', value: 'MN' },
|
27
|
-
{ label: 'Mississippi', value: 'MS' },
|
28
|
-
{ label: 'Missouri', value: 'MO' },
|
29
|
-
{ label: 'Montana', value: 'MT' },
|
30
|
-
{ label: 'Nebraska', value: 'NE' },
|
31
|
-
{ label: 'Nevada', value: 'NV' },
|
32
|
-
{ label: 'New Hampshire', value: 'NH' },
|
33
|
-
{ label: 'New Jersey', value: 'NJ' },
|
34
|
-
{ label: 'New Mexico', value: 'NM' },
|
35
|
-
{ label: 'New York', value: 'NY' },
|
36
|
-
{ label: 'North Carolina', value: 'NC' },
|
37
|
-
{ label: 'North Dakota', value: 'ND' },
|
38
|
-
{ label: 'Ohio', value: 'OH' },
|
39
|
-
{ label: 'Oklahoma', value: 'OK' },
|
40
|
-
{ label: 'Oregon', value: 'OR' },
|
41
|
-
{ label: 'Pennsylvania', value: 'PA' },
|
42
|
-
{ label: 'Rhode Island', value: 'RI' },
|
43
|
-
{ label: 'South Carolina', value: 'SC' },
|
44
|
-
{ label: 'South Dakota', value: 'SD' },
|
45
|
-
{ label: 'Tennessee', value: 'TN' },
|
46
|
-
{ label: 'Texas', value: 'TX' },
|
47
|
-
{ label: 'Utah', value: 'UT' },
|
48
|
-
{ label: 'Vermont', value: 'VT' },
|
49
|
-
{ label: 'Virginia', value: 'VA' },
|
50
|
-
{ label: 'Washington', value: 'WA' },
|
51
|
-
{ label: 'West Virginia', value: 'WV' },
|
52
|
-
{ label: 'Wisconsin', value: 'WI' },
|
53
|
-
{ label: 'Wyoming', value: 'WY' },
|
54
|
-
];
|
55
|
-
export default states;
|