envoc-form 4.0.1-9 → 4.2.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 +9443 -12
- package/es/AddressInput/AddressInput.d.ts +15 -5
- package/es/AddressInput/AddressInput.js +10 -0
- package/es/ConfirmBaseForm/ConfirmBaseForm.d.ts +14 -0
- package/es/ConfirmBaseForm/ConfirmBaseForm.js +6 -0
- package/es/ConfirmDeleteForm/ConfirmDeleteForm.d.ts +13 -0
- package/es/ConfirmDeleteForm/ConfirmDeleteForm.js +5 -0
- package/es/DatePicker/DatePickerGroup.d.ts +7 -2
- package/es/DatePicker/DatePickerGroup.js +18 -7
- package/es/DatePicker/StringDateOnlyPickerGroup.d.ts +6 -1
- package/es/DatePicker/StringDateOnlyPickerGroup.js +5 -0
- package/es/DatePicker/StringDatePickerGroup.d.ts +6 -1
- package/es/DatePicker/StringDatePickerGroup.js +5 -0
- package/es/DateTimePicker/DateTimePickerGroup.d.ts +13 -0
- package/es/DateTimePicker/DateTimePickerGroup.js +87 -0
- package/es/DateTimePicker/DateTimePickerHelper.d.ts +3 -0
- package/es/DateTimePicker/DateTimePickerHelper.js +1 -0
- package/es/DateTimePicker/StringDateTimePickerGroup.d.ts +10 -0
- package/es/DateTimePicker/StringDateTimePickerGroup.js +53 -0
- package/es/Field/Field.d.ts +9 -3
- package/es/Field/Field.js +9 -4
- package/es/Field/FieldErrorScrollTarget.d.ts +1 -0
- package/es/Field/FieldErrorScrollTarget.js +1 -0
- package/es/Field/StandAloneInput.d.ts +4 -0
- package/es/Field/StandAloneInput.js +1 -0
- package/es/Field/useStandardField.d.ts +6 -0
- package/es/Field/useStandardField.js +8 -9
- package/es/FieldArray/FieldArray.d.ts +11 -2
- package/es/FieldArray/FieldArray.js +7 -2
- package/es/File/FileGroup.d.ts +3 -1
- package/es/File/FileGroup.js +4 -3
- package/es/File/FileList.d.ts +2 -2
- package/es/Form/FocusError.d.ts +2 -0
- package/es/Form/FocusError.js +1 -0
- package/es/Form/Form.d.ts +6 -0
- package/es/Form/Form.js +1 -0
- package/es/Form/FormBasedPreventNavigation.d.ts +3 -1
- package/es/Form/FormBasedPreventNavigation.js +12 -45
- 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 +1 -0
- package/es/Form/ServerErrorContext.js +1 -0
- package/es/FormActions.d.ts +6 -0
- package/es/FormActions.js +1 -0
- package/es/FormDefaults.d.ts +1 -0
- package/es/FormDefaults.js +1 -0
- package/es/Group.d.ts +7 -4
- package/es/Group.js +4 -3
- package/es/Input/IconInputGroup.d.ts +4 -1
- package/es/Input/IconInputGroup.js +3 -1
- package/es/Input/InputGroup.d.ts +4 -4
- package/es/Input/InputGroup.js +4 -4
- package/es/Input/MoneyInputGroup.d.ts +3 -1
- package/es/Input/MoneyInputGroup.js +1 -0
- package/es/Input/NumberInputGroup.d.ts +3 -1
- package/es/Input/NumberInputGroup.js +1 -0
- package/es/Input/PhoneNumberInputGroup.d.ts +10 -0
- package/es/Input/PhoneNumberInputGroup.js +47 -0
- package/es/Input/StringInputGroup.d.ts +2 -1
- package/es/Input/StringInputGroup.js +3 -1
- package/es/Normalization/normalizers.d.ts +4 -2
- package/es/Normalization/normalizers.js +2 -0
- package/es/Select/BooleanSelectGroup.d.ts +2 -1
- package/es/Select/BooleanSelectGroup.js +1 -0
- package/es/Select/NumberSelectGroup.d.ts +4 -2
- package/es/Select/NumberSelectGroup.js +2 -0
- package/es/Select/SelectGroup.d.ts +8 -2
- package/es/Select/SelectGroup.js +5 -4
- package/es/Select/StringSelectGroup.d.ts +2 -0
- package/es/Select/StringSelectGroup.js +2 -0
- package/es/StandardFormActions.d.ts +5 -0
- package/es/StandardFormActions.js +1 -0
- package/es/SubmitFormButton.d.ts +4 -1
- package/es/SubmitFormButton.js +1 -0
- package/es/TextArea/TextAreaGroup.d.ts +2 -1
- package/es/TextArea/TextAreaGroup.js +5 -4
- package/es/Validation/validators.d.ts +11 -8
- package/es/Validation/validators.js +6 -2
- package/es/hooks/index.d.ts +2 -0
- package/es/hooks/index.js +2 -0
- package/es/hooks/useFormValue.d.ts +2 -0
- package/es/hooks/useFormValue.js +7 -0
- package/es/index.d.ts +10 -4
- package/es/index.js +4 -0
- package/es/setupTests.d.ts +1 -0
- package/es/setupTests.js +1 -0
- package/lib/AddressInput/AddressInput.d.ts +15 -5
- package/lib/AddressInput/AddressInput.js +10 -0
- package/lib/ConfirmBaseForm/ConfirmBaseForm.d.ts +14 -0
- package/lib/ConfirmBaseForm/ConfirmBaseForm.js +6 -0
- package/lib/ConfirmDeleteForm/ConfirmDeleteForm.d.ts +13 -0
- package/lib/ConfirmDeleteForm/ConfirmDeleteForm.js +5 -0
- package/lib/DatePicker/DatePickerGroup.d.ts +7 -2
- package/lib/DatePicker/DatePickerGroup.js +18 -7
- package/lib/DatePicker/StringDateOnlyPickerGroup.d.ts +6 -1
- package/lib/DatePicker/StringDateOnlyPickerGroup.js +5 -0
- package/lib/DatePicker/StringDatePickerGroup.d.ts +6 -1
- package/lib/DatePicker/StringDatePickerGroup.js +5 -0
- package/lib/DateTimePicker/DateTimePickerGroup.d.ts +13 -0
- package/lib/DateTimePicker/DateTimePickerGroup.js +93 -0
- package/lib/DateTimePicker/DateTimePickerHelper.d.ts +3 -0
- package/lib/DateTimePicker/DateTimePickerHelper.js +2 -0
- package/lib/DateTimePicker/StringDateTimePickerGroup.d.ts +10 -0
- package/lib/DateTimePicker/StringDateTimePickerGroup.js +59 -0
- package/lib/Field/Field.d.ts +9 -3
- package/lib/Field/Field.js +9 -4
- package/lib/Field/FieldErrorScrollTarget.d.ts +1 -0
- package/lib/Field/FieldErrorScrollTarget.js +1 -0
- package/lib/Field/StandAloneInput.d.ts +4 -0
- package/lib/Field/StandAloneInput.js +1 -0
- package/lib/Field/useStandardField.d.ts +6 -0
- package/lib/Field/useStandardField.js +8 -9
- package/lib/FieldArray/FieldArray.d.ts +11 -2
- package/lib/FieldArray/FieldArray.js +7 -2
- package/lib/File/FileGroup.d.ts +3 -1
- package/lib/File/FileGroup.js +4 -3
- package/lib/File/FileList.d.ts +2 -2
- package/lib/Form/FocusError.d.ts +2 -0
- package/lib/Form/FocusError.js +1 -0
- package/lib/Form/Form.d.ts +6 -0
- package/lib/Form/Form.js +1 -0
- package/lib/Form/FormBasedPreventNavigation.d.ts +3 -1
- package/lib/Form/FormBasedPreventNavigation.js +13 -43
- 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 +1 -0
- package/lib/Form/ServerErrorContext.js +1 -0
- package/lib/FormActions.d.ts +6 -0
- package/lib/FormActions.js +1 -0
- package/lib/FormDefaults.d.ts +1 -0
- package/lib/FormDefaults.js +1 -0
- package/lib/Group.d.ts +7 -4
- package/lib/Group.js +4 -3
- package/lib/Input/IconInputGroup.d.ts +4 -1
- package/lib/Input/IconInputGroup.js +3 -1
- package/lib/Input/InputGroup.d.ts +4 -4
- package/lib/Input/InputGroup.js +4 -4
- package/lib/Input/MoneyInputGroup.d.ts +3 -1
- package/lib/Input/MoneyInputGroup.js +1 -0
- package/lib/Input/NumberInputGroup.d.ts +3 -1
- package/lib/Input/NumberInputGroup.js +1 -0
- package/lib/Input/PhoneNumberInputGroup.d.ts +10 -0
- package/lib/Input/PhoneNumberInputGroup.js +52 -0
- package/lib/Input/StringInputGroup.d.ts +2 -1
- package/lib/Input/StringInputGroup.js +3 -1
- package/lib/Normalization/normalizers.d.ts +4 -2
- package/lib/Normalization/normalizers.js +2 -0
- package/lib/Select/BooleanSelectGroup.d.ts +2 -1
- package/lib/Select/BooleanSelectGroup.js +1 -0
- package/lib/Select/NumberSelectGroup.d.ts +4 -2
- package/lib/Select/NumberSelectGroup.js +2 -0
- package/lib/Select/SelectGroup.d.ts +8 -2
- package/lib/Select/SelectGroup.js +5 -4
- package/lib/Select/StringSelectGroup.d.ts +2 -0
- package/lib/Select/StringSelectGroup.js +2 -0
- package/lib/StandardFormActions.d.ts +5 -0
- package/lib/StandardFormActions.js +1 -0
- package/lib/SubmitFormButton.d.ts +4 -1
- package/lib/SubmitFormButton.js +1 -0
- package/lib/TextArea/TextAreaGroup.d.ts +2 -1
- package/lib/TextArea/TextAreaGroup.js +5 -4
- package/lib/Validation/validators.d.ts +11 -8
- package/lib/Validation/validators.js +6 -2
- package/lib/hooks/index.d.ts +2 -0
- package/lib/{__Tests__ → hooks}/index.js +3 -3
- package/lib/hooks/useFormValue.d.ts +2 -0
- package/lib/hooks/useFormValue.js +10 -0
- package/lib/index.d.ts +10 -4
- package/lib/index.js +8 -1
- package/lib/setupTests.d.ts +1 -0
- package/lib/setupTests.js +3 -0
- package/package.json +12 -8
- package/src/AddressInput/AddressInput.tsx +15 -5
- package/src/AddressInput/__snapshots__/AddressInput.test.tsx.snap +8 -4
- 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 +23 -7
- package/src/DatePicker/StringDateOnlyPickerGroup.tsx +7 -2
- package/src/DatePicker/StringDatePickerGroup.tsx +7 -1
- package/src/DateTimePicker/DateTimePicker.test.tsx +243 -0
- package/src/DateTimePicker/DateTimePickerGroup.tsx +116 -0
- package/src/DateTimePicker/DateTimePickerHelper.ts +4 -0
- package/src/DateTimePicker/StringDateTimePickerGroup.tsx +61 -0
- package/src/DateTimePicker/__snapshots__/DateTimePicker.test.tsx.snap +216 -0
- 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/PhoneNumberInputGroup.tsx +49 -0
- package/src/Input/StringInputGroup.tsx +3 -2
- package/src/Input/__Tests__/PhoneNumberInputGroup.test.tsx +37 -0
- 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__/PhoneNumberInputGroup.test.tsx.snap +33 -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/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 +10 -8
- package/src/__Tests__/RealisticForm.test.tsx +82 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useFormValue.ts +16 -0
- package/src/index.ts +14 -4
- package/src/setupTests.ts +1 -0
- 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
@@ -2,7 +2,9 @@
|
|
2
2
|
import { InjectedFieldProps } from '../Field/InjectedFieldProps';
|
3
3
|
import { GroupProps } from '../Group';
|
4
4
|
export interface SelectOption<TValue> {
|
5
|
+
/** Value for the select. This will be sent to the API. */
|
5
6
|
value: (TValue extends Array<infer P> ? P : TValue) | undefined;
|
7
|
+
/** Label for the select. This is displayed to the user. */
|
6
8
|
label: string;
|
7
9
|
}
|
8
10
|
interface OptionsApiResult<TValue> {
|
@@ -13,10 +15,14 @@ interface OptionsUseServiceResult<TValue> {
|
|
13
15
|
resp?: Partial<SelectOption<TValue>>[] | OptionsApiResult<TValue> | null;
|
14
16
|
error?: any;
|
15
17
|
}
|
16
|
-
export interface SelectGroupProps<TValue> extends InjectedFieldProps<TValue | undefined>, Omit<GroupProps, 'input' | 'meta' | 'children'> {
|
18
|
+
export interface SelectGroupProps<TValue> extends InjectedFieldProps<TValue | undefined | null>, Omit<GroupProps, 'input' | 'meta' | 'children'> {
|
19
|
+
/** Options for the dropdown. Includes the label and value. */
|
17
20
|
options: SelectOption<TValue>[] | OptionsUseServiceResult<TValue>;
|
21
|
+
/** Whether the user should be able to have multiple values selected. */
|
18
22
|
multiple: TValue extends Array<any> ? true : false;
|
23
|
+
/** Text diplayed when no value is selected. */
|
19
24
|
placeholder?: string;
|
20
25
|
}
|
21
|
-
|
26
|
+
/** Generic select dropdown. Uses [react-select](https://react-select.com/home). */
|
27
|
+
export default function SelectGroup<TValue>({ input, meta, className, required, disabled, options, multiple, placeholder, ...rest }: SelectGroupProps<TValue>): JSX.Element;
|
22
28
|
export {};
|
@@ -28,12 +28,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
28
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
29
29
|
var react_select_1 = __importDefault(require("react-select"));
|
30
30
|
var classnames_1 = __importDefault(require("classnames"));
|
31
|
-
var Group_1 = __importDefault(require("../Group"));
|
32
31
|
var FormDefaults_1 = require("../FormDefaults");
|
32
|
+
var Group_1 = __importDefault(require("../Group"));
|
33
33
|
// TODO: we could also name this "ReactSelectGroup" or similar but the types are strongly defined now so kept the names consistent
|
34
|
+
/** Generic select dropdown. Uses [react-select](https://react-select.com/home). */
|
34
35
|
function SelectGroup(_a) {
|
35
36
|
var _b;
|
36
|
-
var input = _a.input, meta = _a.meta, className = _a.className, options = _a.options, multiple = _a.multiple, placeholder = _a.placeholder, rest = __rest(_a, ["input", "meta", "className", "options", "multiple", "placeholder"]);
|
37
|
+
var input = _a.input, meta = _a.meta, className = _a.className, required = _a.required, disabled = _a.disabled, options = _a.options, multiple = _a.multiple, placeholder = _a.placeholder, rest = __rest(_a, ["input", "meta", "className", "required", "disabled", "options", "multiple", "placeholder"]);
|
37
38
|
var effectiveOptions = !options
|
38
39
|
? []
|
39
40
|
: Array.isArray(options)
|
@@ -47,10 +48,10 @@ function SelectGroup(_a) {
|
|
47
48
|
? options.resp
|
48
49
|
: [];
|
49
50
|
var isLoading = (options && 'loading' in options && options.loading) || false;
|
50
|
-
return ((0, jsx_runtime_1.jsx)(Group_1.default, __assign({}, rest, { input: input, meta: meta, className: (0, classnames_1.default)(className, (_b = {},
|
51
|
+
return ((0, jsx_runtime_1.jsx)(Group_1.default, __assign({}, rest, { input: input, meta: meta, required: required, disabled: disabled, className: (0, classnames_1.default)(className, (_b = {},
|
51
52
|
_b[FormDefaults_1.FormDefaults.cssClassPrefix + 'multiple'] = multiple,
|
52
53
|
_b[FormDefaults_1.FormDefaults.cssClassPrefix + 'loading'] = isLoading,
|
53
|
-
_b), FormDefaults_1.FormDefaults.cssClassPrefix + 'select-group') }, { children: (0, jsx_runtime_1.jsx)(react_select_1.default, { inputId: input.id, isMulti: multiple, options: effectiveOptions, onBlur: input.onBlur, value: getValue(), onChange: function (e) {
|
54
|
+
_b), FormDefaults_1.FormDefaults.cssClassPrefix + 'select-group') }, { children: (0, jsx_runtime_1.jsx)(react_select_1.default, { inputId: input.id, isMulti: multiple, isDisabled: disabled, options: effectiveOptions, onBlur: input.onBlur, value: getValue(), onChange: function (e) {
|
54
55
|
if (multiple === true) {
|
55
56
|
input.onChange(e === null || e === void 0 ? void 0 : e.map(function (x) { return x.value; }));
|
56
57
|
}
|
@@ -2,7 +2,9 @@
|
|
2
2
|
import { SelectGroupPropsHelper } from './SelectGroupPropsHelper';
|
3
3
|
export interface MultiStringSelectGroupProps extends SelectGroupPropsHelper<string[]> {
|
4
4
|
}
|
5
|
+
/** A `<SelectGroup/>` dropdown with values as strings. Multiple options can be selected at a time. */
|
5
6
|
export declare function MultiStringSelectGroup(props: MultiStringSelectGroupProps): JSX.Element;
|
6
7
|
export interface SingleStringSelectGroupProps extends SelectGroupPropsHelper<string> {
|
7
8
|
}
|
9
|
+
/** A `<SelectGroup/>` dropdown with the value as a string. Only one option can be selected at a time. */
|
8
10
|
export declare function SingleStringSelectGroup(props: SingleStringSelectGroupProps): JSX.Element;
|
@@ -17,10 +17,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.SingleStringSelectGroup = exports.MultiStringSelectGroup = void 0;
|
18
18
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
19
19
|
var SelectGroup_1 = __importDefault(require("./SelectGroup"));
|
20
|
+
/** A `<SelectGroup/>` dropdown with values as strings. Multiple options can be selected at a time. */
|
20
21
|
function MultiStringSelectGroup(props) {
|
21
22
|
return (0, jsx_runtime_1.jsx)(SelectGroup_1.default, __assign({ multiple: true }, props));
|
22
23
|
}
|
23
24
|
exports.MultiStringSelectGroup = MultiStringSelectGroup;
|
25
|
+
/** A `<SelectGroup/>` dropdown with the value as a string. Only one option can be selected at a time. */
|
24
26
|
function SingleStringSelectGroup(props) {
|
25
27
|
return (0, jsx_runtime_1.jsx)(SelectGroup_1.default, __assign({ multiple: false }, props));
|
26
28
|
}
|
@@ -1,6 +1,11 @@
|
|
1
1
|
import { MouseEventHandler } from 'react';
|
2
2
|
export interface StandardFormActionsProps {
|
3
|
+
/** Allow the form to be submitted without any changes. By default this is not allowed. */
|
3
4
|
allowPristineSubmit?: boolean;
|
5
|
+
/** The cancel button's `onClick`.
|
6
|
+
* @defaultValue `window.history.back()`
|
7
|
+
*/
|
4
8
|
handleCancel?: MouseEventHandler<HTMLButtonElement>;
|
5
9
|
}
|
10
|
+
/** Standard submit and cancel buttons. */
|
6
11
|
export default function StandardFormActions({ allowPristineSubmit, handleCancel, }: StandardFormActionsProps): JSX.Element;
|
@@ -19,6 +19,7 @@ var classnames_1 = __importDefault(require("classnames"));
|
|
19
19
|
var formik_1 = require("formik");
|
20
20
|
var SubmitFormButton_1 = __importDefault(require("./SubmitFormButton"));
|
21
21
|
var FormDefaults_1 = require("./FormDefaults");
|
22
|
+
/** Standard submit and cancel buttons. */
|
22
23
|
function StandardFormActions(_a) {
|
23
24
|
var allowPristineSubmit = _a.allowPristineSubmit, handleCancel = _a.handleCancel;
|
24
25
|
var isSubmitting = (0, formik_1.useFormikContext)().isSubmitting;
|
@@ -1,7 +1,10 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
export interface SubmitFormButtonProps extends Omit<React.HTMLProps<HTMLButtonElement>, 'type'> {
|
3
|
+
/** Allow the form to be submitted without any changes. By default this is not allowed. */
|
3
4
|
allowPristineSubmit?: boolean;
|
5
|
+
/** Text to display on the button. Default text is 'Submit'. */
|
4
6
|
children?: React.ReactNode;
|
5
7
|
}
|
6
|
-
declare const _default: React.
|
8
|
+
declare const _default: React.FunctionComponent<SubmitFormButtonProps>;
|
9
|
+
/** Generic submit button for forms. */
|
7
10
|
export default _default;
|
package/lib/SubmitFormButton.js
CHANGED
@@ -41,4 +41,5 @@ function SubmitFormButton(_a, ref) {
|
|
41
41
|
? "You haven't made any changes"
|
42
42
|
: '', className: (0, classnames_1.default)(FormDefaults_1.FormDefaults.cssClassPrefix + 'submit-form-button', className) }, { children: children || 'Submit' })));
|
43
43
|
}
|
44
|
+
/** Generic submit button for forms. */
|
44
45
|
exports.default = react_1.default.forwardRef(SubmitFormButton);
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { InjectedFieldProps } from '../Field/InjectedFieldProps';
|
3
3
|
import { GroupProps } from '../Group';
|
4
|
-
export interface TextAreaGroupProps extends InjectedFieldProps<string | undefined>, Omit<React.HTMLProps<HTMLTextAreaElement>, keyof InjectedFieldProps<any> | 'children' | 'className' | 'label'>, Omit<GroupProps, keyof InjectedFieldProps<any> | 'children'> {
|
4
|
+
export interface TextAreaGroupProps extends InjectedFieldProps<string | undefined | null>, Omit<React.HTMLProps<HTMLTextAreaElement>, keyof InjectedFieldProps<any> | 'children' | 'className' | 'label'>, Omit<GroupProps, keyof InjectedFieldProps<any> | 'children'> {
|
5
5
|
icon?: React.ReactNode;
|
6
6
|
}
|
7
|
+
/** Generic controlled `<textarea/>` wrapped by a `<Group/>` */
|
7
8
|
declare const TextAreaGroupWithRef: React.ComponentType<TextAreaGroupProps>;
|
8
9
|
export default TextAreaGroupWithRef;
|
@@ -28,12 +28,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
28
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
29
29
|
var react_1 = __importDefault(require("react"));
|
30
30
|
var classnames_1 = __importDefault(require("classnames"));
|
31
|
-
var Group_1 = __importDefault(require("../Group"));
|
32
31
|
var FormDefaults_1 = require("../FormDefaults");
|
33
|
-
|
32
|
+
var Group_1 = __importDefault(require("../Group"));
|
34
33
|
function TextAreaGroup(_a, ref) {
|
35
|
-
var
|
36
|
-
|
34
|
+
var _b;
|
35
|
+
var input = _a.input, meta = _a.meta, label = _a.label, helpText = _a.helpText, className = _a.className, required = _a.required, disabled = _a.disabled, icon = _a.icon, rest = __rest(_a, ["input", "meta", "label", "helpText", "className", "required", "disabled", "icon"]);
|
36
|
+
return ((0, jsx_runtime_1.jsxs)(Group_1.default, __assign({ input: input, meta: meta, required: required, disabled: disabled, label: label, helpText: helpText, className: (0, classnames_1.default)(className, FormDefaults_1.FormDefaults.cssClassPrefix + 'text-area-group') }, { children: [icon, (0, jsx_runtime_1.jsx)("textarea", __assign({}, input, rest, { value: (_b = input.value) !== null && _b !== void 0 ? _b : '', onChange: function (val) { return input.onChange(val.target.value); }, ref: ref, className: (0, classnames_1.default)(className, FormDefaults_1.FormDefaults.cssClassPrefix + 'text-area-group') }))] })));
|
37
37
|
}
|
38
|
+
/** Generic controlled `<textarea/>` wrapped by a `<Group/>` */
|
38
39
|
var TextAreaGroupWithRef = react_1.default.forwardRef(TextAreaGroup);
|
39
40
|
exports.default = TextAreaGroupWithRef;
|
@@ -1,15 +1,18 @@
|
|
1
1
|
import { ValidationFunction } from './ValidationFunction';
|
2
2
|
export declare const required: (value: any) => "Required" | undefined;
|
3
|
-
|
4
|
-
export declare const
|
5
|
-
export declare const
|
3
|
+
/** Asserts that the value is a certain number of characters. numbers are coerced to a string */
|
4
|
+
export declare const length: (len: number) => (value: string | number | undefined | null) => string | undefined;
|
5
|
+
export declare const integer: (val: string | number | undefined | null) => "Must be a whole number" | undefined;
|
6
|
+
export declare const maxLength: (len: number) => (value: string | number | undefined | null) => string | undefined;
|
6
7
|
export declare const maxCount: (count: number) => (value: {
|
7
8
|
isDeleted?: boolean;
|
8
|
-
}[] | undefined) => string | undefined;
|
9
|
+
}[] | undefined | null) => string | undefined;
|
9
10
|
export declare const minCount: (count: number) => (value: {
|
10
11
|
isDeleted?: boolean;
|
11
|
-
}[] | undefined) => string | undefined;
|
12
|
-
export declare const maxValue: (max: number) => (value: number | undefined) => string | undefined;
|
13
|
-
export declare const minValue: (min: number) => (value: number | undefined) => string | undefined;
|
14
|
-
|
12
|
+
}[] | undefined | null) => string | undefined;
|
13
|
+
export declare const maxValue: (max: number) => (value: number | undefined | null) => string | undefined;
|
14
|
+
export declare const minValue: (min: number) => (value: number | undefined | null) => string | undefined;
|
15
|
+
/** Validate for a ZIP Code. Accepts formats: ##### and #####-#### */
|
16
|
+
export declare const zipCode: (value: string | undefined | null) => "Invalid ZIP Code" | undefined;
|
17
|
+
/** One of the validators provided must be true. */
|
15
18
|
export declare const any: <TValue>(validatorList: ValidationFunction<TValue>[]) => (value: TValue) => string | undefined;
|
@@ -11,7 +11,7 @@ var required = function (value) {
|
|
11
11
|
: 'Required';
|
12
12
|
};
|
13
13
|
exports.required = required;
|
14
|
-
|
14
|
+
/** Asserts that the value is a certain number of characters. numbers are coerced to a string */
|
15
15
|
var length = function (len) { return function (value) {
|
16
16
|
var hasError = getLengthOfValue(value) !== len;
|
17
17
|
return !hasError ? undefined : "Length must be ".concat(len);
|
@@ -51,13 +51,14 @@ var minValue = function (min) { return function (value) {
|
|
51
51
|
return !hasError ? undefined : "Minimum value ".concat(min, " not met");
|
52
52
|
}; };
|
53
53
|
exports.minValue = minValue;
|
54
|
+
/** Validate for a ZIP Code. Accepts formats: ##### and #####-#### */
|
54
55
|
var zipCode = function (value) {
|
55
56
|
return value && !/^[0-9]{5}(?:-[0-9]{4})?$/.test(value)
|
56
57
|
? 'Invalid ZIP Code'
|
57
58
|
: undefined;
|
58
59
|
};
|
59
60
|
exports.zipCode = zipCode;
|
60
|
-
|
61
|
+
/** One of the validators provided must be true. */
|
61
62
|
var any = function (validatorList) {
|
62
63
|
return function (value) {
|
63
64
|
if (validatorList.length === 0 || !value) {
|
@@ -68,6 +69,9 @@ var any = function (validatorList) {
|
|
68
69
|
};
|
69
70
|
exports.any = any;
|
70
71
|
function getLengthOfValue(value) {
|
72
|
+
if (value === null) {
|
73
|
+
return 0;
|
74
|
+
}
|
71
75
|
switch (typeof value) {
|
72
76
|
case 'undefined':
|
73
77
|
return 0;
|
@@ -3,6 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.
|
7
|
-
var
|
8
|
-
exports.
|
6
|
+
exports.useFormValue = void 0;
|
7
|
+
var useFormValue_1 = __importDefault(require("./useFormValue"));
|
8
|
+
exports.useFormValue = useFormValue_1.default;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
var react_1 = require("react");
|
4
|
+
var formik_1 = require("formik");
|
5
|
+
function useFormValue(formBuilder, fieldName) {
|
6
|
+
var _a = (0, formik_1.useFormikContext)(), values = _a.values, setFieldValue = _a.setFieldValue;
|
7
|
+
var setValue = (0, react_1.useCallback)(function (value) { return setFieldValue(fieldName, value); }, [fieldName, setFieldValue]);
|
8
|
+
return [values[fieldName], setValue];
|
9
|
+
}
|
10
|
+
exports.default = useFormValue;
|
package/lib/index.d.ts
CHANGED
@@ -7,13 +7,17 @@ export type { ConfirmBaseFormProps } from './ConfirmBaseForm/ConfirmBaseForm';
|
|
7
7
|
export { default as ConfirmDeleteForm } from './ConfirmDeleteForm/ConfirmDeleteForm';
|
8
8
|
export type { ConfirmDeleteFormProps } from './ConfirmDeleteForm/ConfirmDeleteForm';
|
9
9
|
export { default as DatePickerGroup } from './DatePicker/DatePickerGroup';
|
10
|
-
export type { DatePickerGroupProps
|
10
|
+
export type { DatePickerGroupProps } from './DatePicker/DatePickerGroup';
|
11
11
|
export { convertToTimeZoneInsensitiveISOString } from './DatePicker/DatePickerGroup';
|
12
12
|
export type { DatePickerHelper } from './DatePicker/DatePickerHelper';
|
13
13
|
export { default as StringDatePickerGroup } from './DatePicker/StringDatePickerGroup';
|
14
14
|
export type { StringDatePickerGroupProps } from './DatePicker/StringDatePickerGroup';
|
15
15
|
export { default as StringDateOnlyPickerGroup } from './DatePicker/StringDateOnlyPickerGroup';
|
16
16
|
export type { StringDateOnlyPickerGroupProps } from './DatePicker/StringDateOnlyPickerGroup';
|
17
|
+
export { default as DateTimePickerGroup } from './DateTimePicker/DateTimePickerGroup';
|
18
|
+
export type { DateTimePickerGroupProps } from './DateTimePicker/DateTimePickerGroup';
|
19
|
+
export { default as StringDateTimePickerGroup } from './DateTimePicker/StringDateTimePickerGroup';
|
20
|
+
export type { StringDateTimePickerGroupProps } from './DateTimePicker/StringDateTimePickerGroup';
|
17
21
|
export { default as Field } from './Field/Field';
|
18
22
|
export type { FieldProps } from './Field/Field';
|
19
23
|
export type { RenderComponent } from './Field/Field';
|
@@ -34,12 +38,12 @@ export type { FormBuilderProp, FormProps } from './Form/Form';
|
|
34
38
|
export { ServerErrorContext } from './Form/ServerErrorContext';
|
35
39
|
export type { ServerErrorContextProps, ServerErrors, } from './Form/ServerErrorContext';
|
36
40
|
export { default as FormActions } from './FormActions';
|
37
|
-
export type { FormActionsProps
|
41
|
+
export type { FormActionsProps } from './FormActions';
|
38
42
|
export { default as StandardFormActions } from './StandardFormActions';
|
39
|
-
export type { StandardFormActionsProps
|
43
|
+
export type { StandardFormActionsProps } from './StandardFormActions';
|
40
44
|
export { FormDefaults } from './FormDefaults';
|
41
45
|
export { default as Group } from './Group';
|
42
|
-
export type { GroupProps
|
46
|
+
export type { GroupProps } from './Group';
|
43
47
|
export { default as IconInputGroup } from './Input/IconInputGroup';
|
44
48
|
export type { IconInputGroupProps } from './Input/IconInputGroup';
|
45
49
|
export { default as InputGroup } from './Input/InputGroup';
|
@@ -48,6 +52,8 @@ export { default as MoneyInputGroup } from './Input/MoneyInputGroup';
|
|
48
52
|
export type { MoneyInputGroupProps } from './Input/MoneyInputGroup';
|
49
53
|
export { default as NumberInputGroup } from './Input/NumberInputGroup';
|
50
54
|
export type { NumberInputGroupProps } from './Input/NumberInputGroup';
|
55
|
+
export { default as PhoneNumberInputGroup } from './Input/PhoneNumberInputGroup';
|
56
|
+
export type { PhoneNumberInputGroupProps } from './Input/PhoneNumberInputGroup';
|
51
57
|
export { default as StringInputGroup } from './Input/StringInputGroup';
|
52
58
|
export type { StringInputGroupProps } from './Input/StringInputGroup';
|
53
59
|
export type { NormalizationFunction } from './Normalization/NormalizationFunction';
|
package/lib/index.js
CHANGED
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
30
30
|
};
|
31
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.BooleanSelectGroup = exports.SelectGroup = exports.normalizers = exports.StringInputGroup = 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;
|
32
|
+
exports.validators = exports.serialize = exports.objectContainsNonSerializableProperty = exports.TextAreaGroup = exports.SingleStringSelectGroup = exports.MultiStringSelectGroup = exports.SingleNumberSelectGroup = exports.MultiNumberSelectGroup = 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.StringDateTimePickerGroup = exports.DateTimePickerGroup = exports.StringDateOnlyPickerGroup = exports.StringDatePickerGroup = exports.convertToTimeZoneInsensitiveISOString = exports.DatePickerGroup = exports.ConfirmDeleteForm = exports.ConfirmBaseForm = exports.SubmitFormButton = exports.AddressInput = void 0;
|
33
33
|
// Address
|
34
34
|
var AddressInput_1 = require("./AddressInput/AddressInput");
|
35
35
|
Object.defineProperty(exports, "AddressInput", { enumerable: true, get: function () { return __importDefault(AddressInput_1).default; } });
|
@@ -51,6 +51,11 @@ var StringDatePickerGroup_1 = require("./DatePicker/StringDatePickerGroup");
|
|
51
51
|
Object.defineProperty(exports, "StringDatePickerGroup", { enumerable: true, get: function () { return __importDefault(StringDatePickerGroup_1).default; } });
|
52
52
|
var StringDateOnlyPickerGroup_1 = require("./DatePicker/StringDateOnlyPickerGroup");
|
53
53
|
Object.defineProperty(exports, "StringDateOnlyPickerGroup", { enumerable: true, get: function () { return __importDefault(StringDateOnlyPickerGroup_1).default; } });
|
54
|
+
// DateTime
|
55
|
+
var DateTimePickerGroup_1 = require("./DateTimePicker/DateTimePickerGroup");
|
56
|
+
Object.defineProperty(exports, "DateTimePickerGroup", { enumerable: true, get: function () { return __importDefault(DateTimePickerGroup_1).default; } });
|
57
|
+
var StringDateTimePickerGroup_1 = require("./DateTimePicker/StringDateTimePickerGroup");
|
58
|
+
Object.defineProperty(exports, "StringDateTimePickerGroup", { enumerable: true, get: function () { return __importDefault(StringDateTimePickerGroup_1).default; } });
|
54
59
|
// Field
|
55
60
|
var Field_1 = require("./Field/Field");
|
56
61
|
Object.defineProperty(exports, "Field", { enumerable: true, get: function () { return __importDefault(Field_1).default; } });
|
@@ -91,6 +96,8 @@ var MoneyInputGroup_1 = require("./Input/MoneyInputGroup");
|
|
91
96
|
Object.defineProperty(exports, "MoneyInputGroup", { enumerable: true, get: function () { return __importDefault(MoneyInputGroup_1).default; } });
|
92
97
|
var NumberInputGroup_1 = require("./Input/NumberInputGroup");
|
93
98
|
Object.defineProperty(exports, "NumberInputGroup", { enumerable: true, get: function () { return __importDefault(NumberInputGroup_1).default; } });
|
99
|
+
var PhoneNumberInputGroup_1 = require("./Input/PhoneNumberInputGroup");
|
100
|
+
Object.defineProperty(exports, "PhoneNumberInputGroup", { enumerable: true, get: function () { return __importDefault(PhoneNumberInputGroup_1).default; } });
|
94
101
|
var StringInputGroup_1 = require("./Input/StringInputGroup");
|
95
102
|
Object.defineProperty(exports, "StringInputGroup", { enumerable: true, get: function () { return __importDefault(StringInputGroup_1).default; } });
|
96
103
|
exports.normalizers = __importStar(require("./Normalization/normalizers"));
|
@@ -0,0 +1 @@
|
|
1
|
+
import '@testing-library/jest-dom/extend-expect';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "envoc-form",
|
3
|
-
"version": "4.0
|
3
|
+
"version": "4.2.0",
|
4
4
|
"description": "Envoc form components",
|
5
5
|
"keywords": [
|
6
6
|
"react-component",
|
@@ -23,11 +23,12 @@
|
|
23
23
|
"es"
|
24
24
|
],
|
25
25
|
"scripts": {
|
26
|
-
"build": "yarn verify-imports && yarn build:esm && yarn build:cjs && yarn build:css",
|
26
|
+
"build": "yarn verify-imports && yarn build:esm && yarn build:cjs && yarn build:css && yarn build:docs",
|
27
27
|
"rebuild": "rimraf ./{dist,es,lib} && yarn build",
|
28
28
|
"build:esm": "cross-env BABEL_ENV=esm-dir tsc -p tsconfig.esm.json",
|
29
29
|
"build:css": "sass src/styles.scss dist/css/envoc-form-styles.css",
|
30
30
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
31
|
+
"build:docs": "yarn rimraf README.md && yarn typedoc --options typedoc.json src/index.ts && npx concat-md --decrease-title-levels --dir-name-as-title docs > README.md && cls && yarn rimraf docs",
|
31
32
|
"verify-imports": "node ../../scripts/check-for-scss-imports.js envoc-form",
|
32
33
|
"start": "webpack serve --config ./webpack.demo.config.js",
|
33
34
|
"test": "cross-env SKIP_PREFLIGHT_CHECK=true react-scripts test --watchAll=false",
|
@@ -37,12 +38,12 @@
|
|
37
38
|
"axios": "^0.21.1",
|
38
39
|
"classnames": "^2.3.1",
|
39
40
|
"date-fns": "^2.22.1",
|
40
|
-
"envoc-request": "^4.0
|
41
|
+
"envoc-request": "^4.2.0",
|
41
42
|
"lru-cache": "^6.0.0",
|
42
43
|
"prop-types": "^15.7.2",
|
43
44
|
"react-date-picker": "^8.2.0",
|
44
45
|
"react-dropzone": "^11.3.4",
|
45
|
-
"react-router": "^6.
|
46
|
+
"react-router": "^6.14.1",
|
46
47
|
"react-select": "^5.2.2",
|
47
48
|
"react-textarea-autosize": "^8.3.3",
|
48
49
|
"react-toastify": "^7.0.4",
|
@@ -52,7 +53,8 @@
|
|
52
53
|
"uuid": "^8.3.2",
|
53
54
|
"@fortawesome/react-fontawesome": "~0.1.16",
|
54
55
|
"@fortawesome/free-solid-svg-icons": "~5.15.4",
|
55
|
-
"@fortawesome/fontawesome-svg-core": "~1.2.36"
|
56
|
+
"@fortawesome/fontawesome-svg-core": "~1.2.36",
|
57
|
+
"react-datetime-picker": "~5.6.0"
|
56
58
|
},
|
57
59
|
"devDependencies": {
|
58
60
|
"@babel/cli": "^7.14.5",
|
@@ -65,6 +67,7 @@
|
|
65
67
|
"@testing-library/user-event": "^12.7.1",
|
66
68
|
"@types/jest": "^26.0.24",
|
67
69
|
"@types/react": "^16.9.56",
|
70
|
+
"@types/testing-library__jest-dom": "5.14.5",
|
68
71
|
"@types/smoothscroll-polyfill": "^0.3.1",
|
69
72
|
"@types/uuid": "^8.3.2",
|
70
73
|
"babel-loader": "^8.2.2",
|
@@ -79,10 +82,10 @@
|
|
79
82
|
"jest-junit": "~12.2.0",
|
80
83
|
"react": "^17.0.1",
|
81
84
|
"react-dom": "^17.0.1",
|
82
|
-
"react-router-dom": "^6.
|
85
|
+
"react-router-dom": "^6.14.1",
|
83
86
|
"react-scripts": "^4.0.3",
|
84
87
|
"rimraf": "~3.0.2",
|
85
|
-
"sass": "^1.
|
88
|
+
"sass": "^1.75.0",
|
86
89
|
"sass-loader": "^11.0.1",
|
87
90
|
"style-loader": "^2.0.0",
|
88
91
|
"webpack": "^5.45.0",
|
@@ -91,7 +94,8 @@
|
|
91
94
|
"ts-loader": "^9.2.8",
|
92
95
|
"typescript": "^4.6.3",
|
93
96
|
"typedoc-plugin-markdown": "~3.10.3",
|
94
|
-
"typedoc": "~0.21.4"
|
97
|
+
"typedoc": "~0.21.4",
|
98
|
+
"concat-md": "~0.3.5"
|
95
99
|
},
|
96
100
|
"peerDependencies": {
|
97
101
|
"@babel/runtime": "^7.14.6",
|
@@ -16,13 +16,23 @@ export interface AddressInputProps {
|
|
16
16
|
}
|
17
17
|
|
18
18
|
interface AddressDto {
|
19
|
-
address1?: string;
|
20
|
-
address2?: string;
|
21
|
-
zipCode?: string;
|
22
|
-
city?: string;
|
23
|
-
state?: string;
|
19
|
+
address1?: string | null;
|
20
|
+
address2?: string | null;
|
21
|
+
zipCode?: string | null;
|
22
|
+
city?: string | null;
|
23
|
+
state?: string | null;
|
24
24
|
}
|
25
25
|
|
26
|
+
/**
|
27
|
+
* Collection of `<Field/>`s for inputting an address. Includes:
|
28
|
+
* ```txt
|
29
|
+
* Address 1
|
30
|
+
* Address 2
|
31
|
+
* City
|
32
|
+
* State
|
33
|
+
* Zip
|
34
|
+
* ```
|
35
|
+
*/
|
26
36
|
export default function AddressInput({
|
27
37
|
fieldBuilder: { Field },
|
28
38
|
name,
|
@@ -7,7 +7,7 @@ exports[`AddressInput has matching snapshot 1`] = `
|
|
7
7
|
class="envoc-form-form"
|
8
8
|
>
|
9
9
|
<div
|
10
|
-
class="envoc-form-string-group envoc-form-input-group envoc-form-group"
|
10
|
+
class="envoc-form-string-group envoc-form-input-group envoc-form-group envoc-form-required"
|
11
11
|
>
|
12
12
|
<div
|
13
13
|
id="normaladdressinput.address1-error-scroll-target"
|
@@ -19,6 +19,7 @@ exports[`AddressInput has matching snapshot 1`] = `
|
|
19
19
|
Address 1
|
20
20
|
</label>
|
21
21
|
<input
|
22
|
+
aria-invalid="false"
|
22
23
|
class="envoc-form-string-group envoc-form-input-group"
|
23
24
|
id="normalAddressInput.address1"
|
24
25
|
name="normalAddressInput.address1"
|
@@ -39,6 +40,7 @@ exports[`AddressInput has matching snapshot 1`] = `
|
|
39
40
|
Address 2
|
40
41
|
</label>
|
41
42
|
<input
|
43
|
+
aria-invalid="false"
|
42
44
|
class="envoc-form-string-group envoc-form-input-group"
|
43
45
|
id="normalAddressInput.address2"
|
44
46
|
name="normalAddressInput.address2"
|
@@ -47,7 +49,7 @@ exports[`AddressInput has matching snapshot 1`] = `
|
|
47
49
|
/>
|
48
50
|
</div>
|
49
51
|
<div
|
50
|
-
class="envoc-form-string-group envoc-form-input-group envoc-form-group"
|
52
|
+
class="envoc-form-string-group envoc-form-input-group envoc-form-group envoc-form-required"
|
51
53
|
>
|
52
54
|
<div
|
53
55
|
id="normaladdressinput.city-error-scroll-target"
|
@@ -59,6 +61,7 @@ exports[`AddressInput has matching snapshot 1`] = `
|
|
59
61
|
City
|
60
62
|
</label>
|
61
63
|
<input
|
64
|
+
aria-invalid="false"
|
62
65
|
class="envoc-form-string-group envoc-form-input-group"
|
63
66
|
id="normalAddressInput.city"
|
64
67
|
name="normalAddressInput.city"
|
@@ -67,7 +70,7 @@ exports[`AddressInput has matching snapshot 1`] = `
|
|
67
70
|
/>
|
68
71
|
</div>
|
69
72
|
<div
|
70
|
-
class="envoc-form-select-group envoc-form-group"
|
73
|
+
class="envoc-form-select-group envoc-form-group envoc-form-required"
|
71
74
|
>
|
72
75
|
<div
|
73
76
|
id="normaladdressinput.state-error-scroll-target"
|
@@ -156,7 +159,7 @@ exports[`AddressInput has matching snapshot 1`] = `
|
|
156
159
|
</div>
|
157
160
|
</div>
|
158
161
|
<div
|
159
|
-
class="envoc-form-string-group envoc-form-input-group envoc-form-group"
|
162
|
+
class="envoc-form-string-group envoc-form-input-group envoc-form-group envoc-form-required"
|
160
163
|
>
|
161
164
|
<div
|
162
165
|
id="normaladdressinput.zipcode-error-scroll-target"
|
@@ -168,6 +171,7 @@ exports[`AddressInput has matching snapshot 1`] = `
|
|
168
171
|
Zip
|
169
172
|
</label>
|
170
173
|
<input
|
174
|
+
aria-invalid="false"
|
171
175
|
class="envoc-form-string-group envoc-form-input-group"
|
172
176
|
id="normalAddressInput.zipCode"
|
173
177
|
name="normalAddressInput.zipCode"
|
@@ -6,16 +6,30 @@ import { FormDefaults } from '../FormDefaults';
|
|
6
6
|
// TODO: change the style prop type to Tailwind type (does this exist before Tailwind 3.1 ???), or
|
7
7
|
// should this just be type 'string'
|
8
8
|
export interface ConfirmBaseFormProps {
|
9
|
+
/** Function to run when cancel button is clicked. */
|
9
10
|
handleCancel?: MouseEventHandler<HTMLButtonElement>;
|
11
|
+
/** Axios request upon confirmation */
|
10
12
|
request: useAxiosRequestProps;
|
11
13
|
style?: React.CSSProperties;
|
14
|
+
/** `<h3/>` title text on top of the form. */
|
12
15
|
title?: string;
|
16
|
+
/** Custom confirm button text.
|
17
|
+
* @defaultValue `Confirm`
|
18
|
+
*/
|
13
19
|
confirmButtonText?: string;
|
20
|
+
/** CSS class for the buttons. */
|
14
21
|
confirmButtonClass?: string;
|
22
|
+
/** Any components to be rendered in between the title and the buttons. */
|
15
23
|
children?: React.ReactNode;
|
16
24
|
}
|
17
25
|
|
18
26
|
// TODO: ask about how we should use 'children'
|
27
|
+
/**
|
28
|
+
* Confimation dialog. Navigates to a different route to allow the user to either confirm or cancel an action.
|
29
|
+
* Commonly used for confirming delete and archive.
|
30
|
+
*
|
31
|
+
* See `<ConfirmDeleteForm/>` if the confirmation is specifically for deletion.
|
32
|
+
*/
|
19
33
|
export default function ConfirmBaseForm({
|
20
34
|
handleCancel,
|
21
35
|
request,
|
@@ -9,14 +9,27 @@ import { FormDefaults } from '../FormDefaults';
|
|
9
9
|
|
10
10
|
export interface ConfirmDeleteFormProps
|
11
11
|
extends Pick<ConfirmBaseFormProps, 'style'> {
|
12
|
+
/** Url to navigate to on success. */
|
12
13
|
successUrl?: string;
|
14
|
+
/** Form name (key) to apply the confirmation on. */
|
13
15
|
form: string;
|
16
|
+
/** Custom message to display.
|
17
|
+
* @defaultValue `Are you sure you want to delete this?`
|
18
|
+
*/
|
14
19
|
title?: string;
|
20
|
+
/** Custom function when the axios request succeeds. */
|
15
21
|
handleComplete?: Function;
|
22
|
+
/** Custom function when the axios request fails. */
|
16
23
|
handleError?: Function;
|
24
|
+
/** Any components to be rendered in between the title and the buttons. */
|
17
25
|
children?: React.ReactNode;
|
18
26
|
}
|
19
27
|
|
28
|
+
/**
|
29
|
+
* Deletion confirmation. Navigates to a different route to allow the user to either confirm or cancel an action.
|
30
|
+
*
|
31
|
+
* Wraps `<ConfirmBaseForm/>`.
|
32
|
+
*/
|
20
33
|
export default function ConfirmDeleteForm({
|
21
34
|
successUrl,
|
22
35
|
form,
|
@@ -4,7 +4,7 @@ import StringDatePickerGroup from './StringDatePickerGroup';
|
|
4
4
|
import FormTestBase from '../__Tests__/FormTestBase';
|
5
5
|
|
6
6
|
//hack so the datepicker internals don't complain about this not existing in the context of jest
|
7
|
-
HTMLCanvasElement.prototype.getContext = () =>
|
7
|
+
HTMLCanvasElement.prototype.getContext = () => null;
|
8
8
|
|
9
9
|
describe('IconInputGroup', () => {
|
10
10
|
it('renders without crashing', () => {
|