envoc-form 5.0.9 → 6.0.1-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 +4930 -1645
- package/dist/index.cjs +25531 -0
- package/dist/index.d.ts +624 -0
- package/dist/index.js +25461 -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 -88
- 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/DateTimePicker/DateTimePickerGroup.d.ts +0 -12
- package/es/DateTimePicker/DateTimePickerGroup.js +0 -87
- package/es/DateTimePicker/DateTimePickerHelper.d.ts +0 -3
- package/es/DateTimePicker/DateTimePickerHelper.js +0 -1
- package/es/DateTimePicker/StringDateTimePickerGroup.d.ts +0 -9
- package/es/DateTimePicker/StringDateTimePickerGroup.js +0 -53
- 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 -29
- package/es/Field/Field.js +0 -59
- 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 -29
- 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 -81
- package/es/index.js +0 -55
- 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 -96
- 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/DateTimePicker/DateTimePickerGroup.d.ts +0 -12
- package/lib/DateTimePicker/DateTimePickerGroup.js +0 -93
- package/lib/DateTimePicker/DateTimePickerHelper.d.ts +0 -3
- package/lib/DateTimePicker/DateTimePickerHelper.js +0 -2
- package/lib/DateTimePicker/StringDateTimePickerGroup.d.ts +0 -9
- package/lib/DateTimePicker/StringDateTimePickerGroup.js +0 -59
- 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 -29
- package/lib/Field/Field.js +0 -64
- 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 -29
- 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 -81
- package/lib/index.js +0 -126
- 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 -183
- 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 -115
- 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/DateTimePicker/DateTimePicker.test.tsx +0 -243
- package/src/DateTimePicker/DateTimePickerGroup.tsx +0 -116
- package/src/DateTimePicker/DateTimePickerHelper.ts +0 -4
- package/src/DateTimePicker/StringDateTimePickerGroup.tsx +0 -61
- package/src/DateTimePicker/__snapshots__/DateTimePicker.test.tsx.snap +0 -217
- package/src/Field/CustomFieldInputProps.ts +0 -10
- package/src/Field/CustomFieldMetaProps.ts +0 -5
- package/src/Field/Field.tsx +0 -127
- 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 -69
- 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 -132
- 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 -99
- package/src/Select/__tests__/__snapshots__/NumberSelectGroup.test.tsx.snap +0 -197
- package/src/Select/__tests__/__snapshots__/StringSelectGroup.test.tsx.snap +0 -197
- 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 -66
- 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 -163
- 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
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;
|
@@ -1,183 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`AddressInput has matching snapshot 1`] = `
|
4
|
-
<DocumentFragment>
|
5
|
-
<form
|
6
|
-
action="#"
|
7
|
-
class="envoc-form-form"
|
8
|
-
>
|
9
|
-
<div
|
10
|
-
class="envoc-form-string-group envoc-form-input-group envoc-form-group envoc-form-required"
|
11
|
-
>
|
12
|
-
<div
|
13
|
-
id="normaladdressinput.address1-error-scroll-target"
|
14
|
-
style="display: none;"
|
15
|
-
/>
|
16
|
-
<label
|
17
|
-
for="normalAddressInput.address1"
|
18
|
-
>
|
19
|
-
Address 1
|
20
|
-
</label>
|
21
|
-
<input
|
22
|
-
aria-invalid="false"
|
23
|
-
class="envoc-form-string-group envoc-form-input-group"
|
24
|
-
id="normalAddressInput.address1"
|
25
|
-
name="normalAddressInput.address1"
|
26
|
-
placeholder="Address, Line 1"
|
27
|
-
value=""
|
28
|
-
/>
|
29
|
-
</div>
|
30
|
-
<div
|
31
|
-
class="envoc-form-string-group envoc-form-input-group envoc-form-group"
|
32
|
-
>
|
33
|
-
<div
|
34
|
-
id="normaladdressinput.address2-error-scroll-target"
|
35
|
-
style="display: none;"
|
36
|
-
/>
|
37
|
-
<label
|
38
|
-
for="normalAddressInput.address2"
|
39
|
-
>
|
40
|
-
Address 2
|
41
|
-
</label>
|
42
|
-
<input
|
43
|
-
aria-invalid="false"
|
44
|
-
class="envoc-form-string-group envoc-form-input-group"
|
45
|
-
id="normalAddressInput.address2"
|
46
|
-
name="normalAddressInput.address2"
|
47
|
-
placeholder="Address, Line 2"
|
48
|
-
value=""
|
49
|
-
/>
|
50
|
-
</div>
|
51
|
-
<div
|
52
|
-
class="envoc-form-string-group envoc-form-input-group envoc-form-group envoc-form-required"
|
53
|
-
>
|
54
|
-
<div
|
55
|
-
id="normaladdressinput.city-error-scroll-target"
|
56
|
-
style="display: none;"
|
57
|
-
/>
|
58
|
-
<label
|
59
|
-
for="normalAddressInput.city"
|
60
|
-
>
|
61
|
-
City
|
62
|
-
</label>
|
63
|
-
<input
|
64
|
-
aria-invalid="false"
|
65
|
-
class="envoc-form-string-group envoc-form-input-group"
|
66
|
-
id="normalAddressInput.city"
|
67
|
-
name="normalAddressInput.city"
|
68
|
-
placeholder="City"
|
69
|
-
value=""
|
70
|
-
/>
|
71
|
-
</div>
|
72
|
-
<div
|
73
|
-
class="envoc-form-select-group envoc-form-group envoc-form-required"
|
74
|
-
>
|
75
|
-
<div
|
76
|
-
id="normaladdressinput.state-error-scroll-target"
|
77
|
-
style="display: none;"
|
78
|
-
/>
|
79
|
-
<label
|
80
|
-
for="normalAddressInput.state"
|
81
|
-
>
|
82
|
-
State
|
83
|
-
</label>
|
84
|
-
<div
|
85
|
-
class="envoc-form-select-group css-b62m3t-container"
|
86
|
-
id="normalAddressInput.state"
|
87
|
-
>
|
88
|
-
<span
|
89
|
-
class="css-1f43avz-a11yText-A11yText"
|
90
|
-
id="react-select-3-live-region"
|
91
|
-
/>
|
92
|
-
<span
|
93
|
-
aria-atomic="false"
|
94
|
-
aria-live="polite"
|
95
|
-
aria-relevant="additions text"
|
96
|
-
class="css-1f43avz-a11yText-A11yText"
|
97
|
-
/>
|
98
|
-
<div
|
99
|
-
class="react-select__control css-13cymwt-control"
|
100
|
-
>
|
101
|
-
<div
|
102
|
-
class="react-select__value-container css-16674sh-Component"
|
103
|
-
>
|
104
|
-
<div
|
105
|
-
class="react-select__placeholder css-1jqq78o-placeholder"
|
106
|
-
id="react-select-3-placeholder"
|
107
|
-
>
|
108
|
-
State
|
109
|
-
</div>
|
110
|
-
<div
|
111
|
-
class="react-select__input-container css-d9r47t-Component"
|
112
|
-
data-value=""
|
113
|
-
>
|
114
|
-
<input
|
115
|
-
aria-autocomplete="list"
|
116
|
-
aria-describedby="react-select-3-placeholder"
|
117
|
-
aria-expanded="false"
|
118
|
-
aria-haspopup="true"
|
119
|
-
autocapitalize="none"
|
120
|
-
autocomplete="off"
|
121
|
-
autocorrect="off"
|
122
|
-
class="react-select__input"
|
123
|
-
id="normalAddressInput.state"
|
124
|
-
role="combobox"
|
125
|
-
spellcheck="false"
|
126
|
-
style="opacity: 1; width: 100%; grid-area: 1 / 2; min-width: 2px; border: 0px; margin: 0px; outline: 0; padding: 0px;"
|
127
|
-
tabindex="0"
|
128
|
-
type="text"
|
129
|
-
value=""
|
130
|
-
/>
|
131
|
-
</div>
|
132
|
-
</div>
|
133
|
-
<div
|
134
|
-
class="react-select__indicators css-ny0e4k-Component"
|
135
|
-
>
|
136
|
-
<span
|
137
|
-
class="react-select__indicator-separator css-1u9des2-indicatorSeparator"
|
138
|
-
/>
|
139
|
-
<div
|
140
|
-
aria-hidden="true"
|
141
|
-
class="react-select__indicator react-select__dropdown-indicator css-1xc3v61-indicatorContainer"
|
142
|
-
>
|
143
|
-
<svg
|
144
|
-
aria-hidden="true"
|
145
|
-
class="css-tj5bde-Svg"
|
146
|
-
focusable="false"
|
147
|
-
height="20"
|
148
|
-
viewBox="0 0 20 20"
|
149
|
-
width="20"
|
150
|
-
>
|
151
|
-
<path
|
152
|
-
d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"
|
153
|
-
/>
|
154
|
-
</svg>
|
155
|
-
</div>
|
156
|
-
</div>
|
157
|
-
</div>
|
158
|
-
</div>
|
159
|
-
</div>
|
160
|
-
<div
|
161
|
-
class="envoc-form-string-group envoc-form-input-group envoc-form-group envoc-form-required"
|
162
|
-
>
|
163
|
-
<div
|
164
|
-
id="normaladdressinput.zipcode-error-scroll-target"
|
165
|
-
style="display: none;"
|
166
|
-
/>
|
167
|
-
<label
|
168
|
-
for="normalAddressInput.zipCode"
|
169
|
-
>
|
170
|
-
Zip
|
171
|
-
</label>
|
172
|
-
<input
|
173
|
-
aria-invalid="false"
|
174
|
-
class="envoc-form-string-group envoc-form-input-group"
|
175
|
-
id="normalAddressInput.zipCode"
|
176
|
-
name="normalAddressInput.zipCode"
|
177
|
-
placeholder="Zip"
|
178
|
-
value=""
|
179
|
-
/>
|
180
|
-
</div>
|
181
|
-
</form>
|
182
|
-
</DocumentFragment>
|
183
|
-
`;
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { render } from '@testing-library/react';
|
3
|
-
import { useAxiosRequestProps } from 'envoc-request';
|
4
|
-
import ConfirmBaseForm from './ConfirmBaseForm';
|
5
|
-
|
6
|
-
describe('ConfirmBaseForm', () => {
|
7
|
-
it('Renders without error', () => {
|
8
|
-
render(<ConfirmBaseForm request={confirmBaseFormRequest} />);
|
9
|
-
});
|
10
|
-
|
11
|
-
it('has matching snapshot', () => {
|
12
|
-
const renderResult = render(
|
13
|
-
<ConfirmBaseForm request={confirmBaseFormRequest} />
|
14
|
-
);
|
15
|
-
expect(renderResult.asFragment()).toMatchSnapshot();
|
16
|
-
});
|
17
|
-
});
|
18
|
-
|
19
|
-
const confirmBaseFormRequest = {
|
20
|
-
method: 'get',
|
21
|
-
url: `/boop`,
|
22
|
-
onComplete: () => {},
|
23
|
-
onError: () => {},
|
24
|
-
} as useAxiosRequestProps;
|
@@ -1,74 +0,0 @@
|
|
1
|
-
import React, { MouseEventHandler } from 'react';
|
2
|
-
import { clsx } from 'clsx';
|
3
|
-
import { useAxiosRequest, useAxiosRequestProps } from 'envoc-request';
|
4
|
-
import { FormDefaults } from '../FormDefaults';
|
5
|
-
|
6
|
-
// TODO: change the style prop type to Tailwind type (does this exist before Tailwind 3.1 ???), or
|
7
|
-
// should this just be type 'string'
|
8
|
-
export interface ConfirmBaseFormProps {
|
9
|
-
/** Function to run when cancel button is clicked. */
|
10
|
-
handleCancel?: MouseEventHandler<HTMLButtonElement>;
|
11
|
-
/** Axios request upon confirmation */
|
12
|
-
request: useAxiosRequestProps;
|
13
|
-
style?: React.CSSProperties;
|
14
|
-
/** `<h3/>` title text on top of the form. */
|
15
|
-
title?: string;
|
16
|
-
/** Custom confirm button text.
|
17
|
-
* @defaultValue `Confirm`
|
18
|
-
*/
|
19
|
-
confirmButtonText?: string;
|
20
|
-
/** CSS class for the buttons. */
|
21
|
-
confirmButtonClass?: string;
|
22
|
-
/** Any components to be rendered in between the title and the buttons. */
|
23
|
-
children?: React.ReactNode;
|
24
|
-
}
|
25
|
-
|
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
|
-
*/
|
33
|
-
export default function ConfirmBaseForm({
|
34
|
-
handleCancel,
|
35
|
-
request,
|
36
|
-
style,
|
37
|
-
title,
|
38
|
-
confirmButtonText,
|
39
|
-
confirmButtonClass,
|
40
|
-
children,
|
41
|
-
...props
|
42
|
-
}: ConfirmBaseFormProps) {
|
43
|
-
const webRequest = useAxiosRequest(
|
44
|
-
Object.assign({}, request, { autoExecute: false })
|
45
|
-
);
|
46
|
-
const onCancel = handleCancel ?? goBack;
|
47
|
-
|
48
|
-
return (
|
49
|
-
<div style={{ textAlign: 'center', ...style }} {...props}>
|
50
|
-
<h3>{title}</h3>
|
51
|
-
{children}
|
52
|
-
<button
|
53
|
-
className={clsx(
|
54
|
-
confirmButtonClass ??
|
55
|
-
FormDefaults.cssClassPrefix + 'confirm-base-form-confirm-button'
|
56
|
-
)}
|
57
|
-
type="button"
|
58
|
-
onClick={webRequest.submitRequest}>
|
59
|
-
{confirmButtonText ?? 'Confirm'}
|
60
|
-
</button>
|
61
|
-
<button
|
62
|
-
className={clsx(
|
63
|
-
FormDefaults.cssClassPrefix + 'confirm-base-form-cancel-button'
|
64
|
-
)}
|
65
|
-
type="button"
|
66
|
-
onClick={onCancel}>
|
67
|
-
Cancel
|
68
|
-
</button>
|
69
|
-
</div>
|
70
|
-
);
|
71
|
-
function goBack() {
|
72
|
-
window.history.back();
|
73
|
-
}
|
74
|
-
}
|
@@ -1,23 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`ConfirmBaseForm has matching snapshot 1`] = `
|
4
|
-
<DocumentFragment>
|
5
|
-
<div
|
6
|
-
style="text-align: center;"
|
7
|
-
>
|
8
|
-
<h3 />
|
9
|
-
<button
|
10
|
-
class="envoc-form-confirm-base-form-confirm-button"
|
11
|
-
type="button"
|
12
|
-
>
|
13
|
-
Confirm
|
14
|
-
</button>
|
15
|
-
<button
|
16
|
-
class="envoc-form-confirm-base-form-cancel-button"
|
17
|
-
type="button"
|
18
|
-
>
|
19
|
-
Cancel
|
20
|
-
</button>
|
21
|
-
</div>
|
22
|
-
</DocumentFragment>
|
23
|
-
`;
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { HashRouter } from 'react-router-dom';
|
3
|
-
import { render } from '@testing-library/react';
|
4
|
-
|
5
|
-
import ConfirmDeleteForm from './ConfirmDeleteForm';
|
6
|
-
|
7
|
-
describe('ConfirmDeleteForm', () => {
|
8
|
-
it('Renders without error', () => {
|
9
|
-
render(
|
10
|
-
<HashRouter>
|
11
|
-
<ConfirmDeleteForm form="foo" />
|
12
|
-
</HashRouter>
|
13
|
-
);
|
14
|
-
});
|
15
|
-
|
16
|
-
it('has matching snapshot', () => {
|
17
|
-
const renderResult = render(
|
18
|
-
<HashRouter>
|
19
|
-
<ConfirmDeleteForm form="foo" />
|
20
|
-
</HashRouter>
|
21
|
-
);
|
22
|
-
expect(renderResult.asFragment()).toMatchSnapshot();
|
23
|
-
});
|
24
|
-
});
|
@@ -1,87 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { useNavigate, useParams } from 'react-router-dom';
|
3
|
-
import { toast } from 'react-toastify';
|
4
|
-
import { useAxiosRequestProps } from 'envoc-request';
|
5
|
-
import ConfirmBaseForm, {
|
6
|
-
ConfirmBaseFormProps,
|
7
|
-
} from '../ConfirmBaseForm/ConfirmBaseForm';
|
8
|
-
import { FormDefaults } from '../FormDefaults';
|
9
|
-
|
10
|
-
export interface ConfirmDeleteFormProps
|
11
|
-
extends Pick<ConfirmBaseFormProps, 'style'> {
|
12
|
-
/** Url to navigate to on success. */
|
13
|
-
successUrl?: string;
|
14
|
-
/** Form name (key) to apply the confirmation on. */
|
15
|
-
form: string;
|
16
|
-
/** Custom message to display.
|
17
|
-
* @defaultValue `Are you sure you want to delete this?`
|
18
|
-
*/
|
19
|
-
title?: string;
|
20
|
-
/** Custom function when the axios request succeeds. */
|
21
|
-
handleComplete?: Function;
|
22
|
-
/** Custom function when the axios request fails. */
|
23
|
-
handleError?: Function;
|
24
|
-
/** Any components to be rendered in between the title and the buttons. */
|
25
|
-
children?: React.ReactNode;
|
26
|
-
}
|
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
|
-
*/
|
33
|
-
export default function ConfirmDeleteForm({
|
34
|
-
successUrl,
|
35
|
-
form,
|
36
|
-
title,
|
37
|
-
handleComplete,
|
38
|
-
handleError,
|
39
|
-
children,
|
40
|
-
...props
|
41
|
-
}: ConfirmDeleteFormProps) {
|
42
|
-
const navigate = useNavigate();
|
43
|
-
const { entityId } = useParams();
|
44
|
-
const onComplete =
|
45
|
-
handleComplete ??
|
46
|
-
function () {
|
47
|
-
toast.success('Deleted!');
|
48
|
-
goBack();
|
49
|
-
};
|
50
|
-
const onError =
|
51
|
-
handleError ??
|
52
|
-
function (error: any) {
|
53
|
-
toast.error(
|
54
|
-
error.response?.data?.validationFailures[0]?.errorMessage ??
|
55
|
-
'Something went wrong talking to the portal. Contact support if this continues.'
|
56
|
-
);
|
57
|
-
};
|
58
|
-
|
59
|
-
const request = {
|
60
|
-
method: 'delete',
|
61
|
-
url: `/api/${form}/${entityId}`,
|
62
|
-
onComplete: onComplete,
|
63
|
-
onError: onError,
|
64
|
-
} as useAxiosRequestProps;
|
65
|
-
|
66
|
-
return (
|
67
|
-
<ConfirmBaseForm
|
68
|
-
request={request}
|
69
|
-
handleCancel={goBack}
|
70
|
-
title={title ?? 'Are you sure you want to delete this?'}
|
71
|
-
confirmButtonText="Yes"
|
72
|
-
confirmButtonClass={
|
73
|
-
FormDefaults.cssClassPrefix + 'confirm-delete-form-yes-button'
|
74
|
-
}
|
75
|
-
{...props}>
|
76
|
-
{children}
|
77
|
-
</ConfirmBaseForm>
|
78
|
-
);
|
79
|
-
|
80
|
-
function goBack() {
|
81
|
-
if (successUrl) {
|
82
|
-
navigate(successUrl);
|
83
|
-
} else {
|
84
|
-
navigate(-1);
|
85
|
-
}
|
86
|
-
}
|
87
|
-
}
|
@@ -1,25 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`ConfirmDeleteForm has matching snapshot 1`] = `
|
4
|
-
<DocumentFragment>
|
5
|
-
<div
|
6
|
-
style="text-align: center;"
|
7
|
-
>
|
8
|
-
<h3>
|
9
|
-
Are you sure you want to delete this?
|
10
|
-
</h3>
|
11
|
-
<button
|
12
|
-
class="envoc-form-confirm-delete-form-yes-button"
|
13
|
-
type="button"
|
14
|
-
>
|
15
|
-
Yes
|
16
|
-
</button>
|
17
|
-
<button
|
18
|
-
class="envoc-form-confirm-base-form-cancel-button"
|
19
|
-
type="button"
|
20
|
-
>
|
21
|
-
Cancel
|
22
|
-
</button>
|
23
|
-
</div>
|
24
|
-
</DocumentFragment>
|
25
|
-
`;
|
@@ -1,48 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { render } from '@testing-library/react';
|
3
|
-
import StringDatePickerGroup from './StringDatePickerGroup';
|
4
|
-
import FormTestBase from '../__Tests__/FormTestBase';
|
5
|
-
|
6
|
-
//hack so the datepicker internals don't complain about this not existing in the context of jest
|
7
|
-
HTMLCanvasElement.prototype.getContext = () => null;
|
8
|
-
|
9
|
-
describe('IconInputGroup', () => {
|
10
|
-
it('renders without crashing', () => {
|
11
|
-
render(
|
12
|
-
<FormTestBase>
|
13
|
-
{({ Field }) => (
|
14
|
-
<Field
|
15
|
-
name="favoriteDate"
|
16
|
-
Component={StringDatePickerGroup}
|
17
|
-
label="Favorite Date"
|
18
|
-
monthPlaceholder="mm"
|
19
|
-
dayPlaceholder="dd"
|
20
|
-
yearPlaceholder="yyyy"
|
21
|
-
maxDate={new Date('9/23/2023')}
|
22
|
-
minDate={new Date('6/22/2022')}
|
23
|
-
/>
|
24
|
-
)}
|
25
|
-
</FormTestBase>
|
26
|
-
);
|
27
|
-
});
|
28
|
-
|
29
|
-
it('has matching snapshot', () => {
|
30
|
-
const renderResult = render(
|
31
|
-
<FormTestBase>
|
32
|
-
{({ Field }) => (
|
33
|
-
<Field
|
34
|
-
name="favoriteDate"
|
35
|
-
Component={StringDatePickerGroup}
|
36
|
-
label="Favorite Date"
|
37
|
-
monthPlaceholder="mm"
|
38
|
-
dayPlaceholder="dd"
|
39
|
-
yearPlaceholder="yyyy"
|
40
|
-
maxDate={new Date('9/23/2023')}
|
41
|
-
minDate={new Date('6/22/2022')}
|
42
|
-
/>
|
43
|
-
)}
|
44
|
-
</FormTestBase>
|
45
|
-
);
|
46
|
-
expect(renderResult.asFragment()).toMatchSnapshot();
|
47
|
-
});
|
48
|
-
});
|