envoc-form 2.0.1-1 → 2.0.1-13
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 +7 -7
- package/dist/css/envoc-form-styles.css +43 -5
- package/dist/css/envoc-form-styles.css.map +1 -1
- package/es/AddressInput/AddressInput.js +8 -7
- package/es/ConfirmBaseForm/ConfirmBaseForm.js +3 -2
- package/es/ConfirmDeleteForm/ConfirmDeleteForm.js +3 -2
- package/es/DatePickerInput/DatePickerInput.js +3 -2
- package/es/FileInput/DefaultFileList.js +36 -0
- package/es/FileInput/DropzoneFileInput.js +58 -0
- package/es/FileInput/FileInput.js +31 -9
- package/es/FileInput/index.js +2 -1
- package/es/Form/Form.js +11 -33
- package/es/Form/FormBasedPreventNavigation.js +1 -1
- package/es/FormGroupWrapper.js +2 -1
- package/es/FormInput/FormInput.js +29 -10
- package/es/FormInputArray/FormInputArray.js +39 -24
- package/es/IconInput.js +2 -1
- package/es/ReactSelectField/ReactSelectField.js +6 -3
- package/es/SubmitFormButton.js +2 -1
- package/es/__Tests__/FormTestBase.js +5 -2
- package/es/normalizers.js +10 -5
- package/es/useStandardFormInput.js +4 -2
- package/es/utils/index.js +3 -0
- package/es/utils/objectContainsNonSerializableProperty.js +16 -0
- package/es/utils/objectToFormData.js +65 -0
- package/es/utils/typeChecks.js +25 -0
- package/lib/AddressInput/AddressInput.js +15 -9
- package/lib/ConfirmBaseForm/ConfirmBaseForm.js +4 -2
- package/lib/ConfirmDeleteForm/ConfirmDeleteForm.js +6 -4
- package/lib/DatePickerInput/DatePickerInput.js +4 -2
- package/lib/FileInput/DefaultFileList.js +47 -0
- package/lib/FileInput/DropzoneFileInput.js +75 -0
- package/lib/FileInput/FileInput.js +39 -10
- package/lib/FileInput/index.js +13 -3
- package/lib/Form/Form.js +19 -39
- package/lib/Form/FormBasedPreventNavigation.js +7 -3
- package/lib/FormGroupWrapper.js +3 -1
- package/lib/FormInput/FormInput.js +31 -11
- package/lib/FormInputArray/FormInputArray.js +47 -26
- package/lib/FormSection.js +5 -1
- package/lib/IconInput.js +3 -1
- package/lib/ReactSelectField/ReactSelectField.js +13 -5
- package/lib/ReactSelectField/index.js +6 -2
- package/lib/SubmitFormButton.js +3 -1
- package/lib/__Tests__/FormTestBase.js +6 -2
- package/lib/index.js +7 -3
- package/lib/normalizers.js +10 -5
- package/lib/useStandardFormInput.js +5 -2
- package/lib/utils/index.js +23 -0
- package/lib/utils/objectContainsNonSerializableProperty.js +24 -0
- package/lib/utils/objectToFormData.js +73 -0
- package/lib/utils/typeChecks.js +58 -0
- package/lib/validators/index.js +5 -1
- package/package.json +99 -90
- package/src/AddressInput/AddesssInput.test.js +23 -23
- package/src/AddressInput/AddressInput.js +73 -73
- package/src/AddressInput/UsStates.js +53 -53
- package/src/AddressInput/__snapshots__/AddesssInput.test.js.snap +207 -207
- package/src/AddressInput/index.js +2 -2
- package/src/BoolInput/BoolInput.js +7 -7
- package/src/BoolInput/BoolInput.test.js +23 -23
- package/src/BoolInput/InlineBoolInput.js +7 -7
- package/src/BoolInput/__snapshots__/BoolInput.test.js.snap +89 -89
- package/src/BoolInput/boolOptions.js +6 -6
- package/src/BoolInput/index.js +4 -4
- package/src/ConfirmBaseForm/ConfirmBaseForm.js +37 -37
- package/src/ConfirmBaseForm/ConfirmBaseForm.test.js +14 -14
- package/src/ConfirmBaseForm/__snapshots__/ConfirmBaseForm.test.js.snap +23 -23
- package/src/ConfirmBaseForm/index.js +1 -1
- package/src/ConfirmDeleteForm/ConfirmDeleteForm.js +39 -39
- package/src/ConfirmDeleteForm/ConfirmDeleteForm.test.js +24 -24
- package/src/ConfirmDeleteForm/__snapshots__/ConfirmDeleteForm.test.js.snap +25 -25
- package/src/ConfirmDeleteForm/index.js +1 -1
- package/src/DatePickerInput/DatePickerInput.js +46 -46
- package/src/DatePickerInput/DatePickerInput.test.js +74 -74
- package/src/DatePickerInput/__snapshots__/DatePickerInput.test.js.snap +134 -131
- package/src/DatePickerInput/date-picker-input.scss +42 -42
- package/src/DatePickerInput/index.js +3 -3
- package/src/ErrorScrollTarget.js +6 -6
- package/src/FileInput/DefaultFileList.js +39 -0
- package/src/FileInput/DropzoneFileInput.js +56 -0
- package/src/FileInput/DropzoneFileInput.test.js +24 -0
- package/src/FileInput/FileInput.js +77 -49
- package/src/FileInput/FileInput.test.js +24 -15
- package/src/FileInput/__snapshots__/DropzoneFileInput.test.js.snap +57 -0
- package/src/FileInput/__snapshots__/FileInput.test.js.snap +58 -22
- package/src/FileInput/file-input.scss +58 -17
- package/src/FileInput/index.js +4 -3
- package/src/Form/FocusError.js +48 -48
- package/src/Form/Form.js +139 -161
- package/src/Form/Form.test.js +23 -23
- package/src/Form/FormBasedPreventNavigation.js +25 -25
- package/src/Form/ServerErrorContext.js +7 -7
- package/src/Form/__snapshots__/Form.test.js.snap +9 -9
- package/src/Form/index.js +3 -3
- package/src/FormGroup.js +30 -30
- package/src/FormGroupWrapper.js +28 -28
- package/src/FormInput/FormInput.js +144 -136
- package/src/FormInput/FormInput.test.js +66 -66
- package/src/FormInput/__snapshots__/FormInput.test.js.snap +323 -313
- package/src/FormInput/form-input.scss +9 -9
- package/src/FormInput/index.js +2 -2
- package/src/FormInputArray/FormInputArray.js +224 -210
- package/src/FormInputArray/FormInputArray.test.js +108 -59
- package/src/FormInputArray/__snapshots__/FormInputArray.test.js.snap +52 -40
- package/src/FormInputArray/form-input-array.scss +13 -8
- package/src/FormInputArray/index.js +2 -2
- package/src/FormSection.js +13 -13
- package/src/IconInput.js +31 -31
- package/src/InlineFormInput/InlineFormInput.js +6 -6
- package/src/InlineFormInput/InlineFormInput.test.js +23 -23
- package/src/InlineFormInput/__snapshots__/InlineFormInput.test.js.snap +26 -26
- package/src/InlineFormInput/index.js +3 -3
- package/src/InlineFormInput/inline-form-input.scss +3 -3
- package/src/MoneyInput/InlineMoneyInput.js +7 -7
- package/src/MoneyInput/MoneyInput.js +7 -7
- package/src/MoneyInput/MoneyInputs.test.js +43 -43
- package/src/MoneyInput/__snapshots__/MoneyInputs.test.js.snap +81 -81
- package/src/MoneyInput/index.js +4 -4
- package/src/MoneyInput/money-input.scss +3 -3
- package/src/MoneyInput/moneyInputProps.js +12 -12
- package/src/NestedFormFieldContext.js +6 -6
- package/src/ReactSelectField/ReactSelectField.js +122 -120
- package/src/ReactSelectField/index.js +6 -6
- package/src/ReactSelectField/react-select-field.scss +5 -5
- package/src/StandardFormActions.js +27 -27
- package/src/SubmitFormButton.js +28 -28
- package/src/__Tests__/FormTestBase.js +14 -11
- package/src/__Tests__/IconInput.test.js +23 -23
- package/src/__Tests__/StandardFormActions.test.js +23 -23
- package/src/__Tests__/SubmitFormButton.test.js +23 -23
- package/src/__Tests__/__snapshots__/IconInput.test.js.snap +38 -38
- package/src/__Tests__/__snapshots__/StandardFormActions.test.js.snap +25 -25
- package/src/__Tests__/__snapshots__/SubmitFormButton.test.js.snap +18 -18
- package/src/__Tests__/index.js +2 -2
- package/src/_variables.scss +11 -11
- package/src/index.js +33 -33
- package/src/normalizers.js +42 -32
- package/src/selectors.js +3 -3
- package/src/styles.scss +7 -7
- package/src/useStandardFormInput.js +118 -118
- package/src/utils/index.js +3 -0
- package/src/utils/objectContainsNonSerializableProperty.js +15 -0
- package/src/utils/objectContainsNonSerializableProperty.test.js +49 -0
- package/src/utils/objectToFormData.js +89 -0
- package/src/utils/objectToFormData.test.js +76 -0
- package/src/utils/typeChecks.js +18 -0
- package/src/validators/index.js +2 -2
- package/src/validators/validators.js +93 -93
- package/src/validators/validators.test.js +79 -79
- package/CHANGELOG.json +0 -95
- package/CHANGELOG.md +0 -58
- package/es/FormInput/utilities.js +0 -71
- package/lib/FormInput/utilities.js +0 -86
- package/src/FormInput/utilities.js +0 -26
@@ -1,40 +1,52 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`FormInputArray has matching snapshot 1`] = `
|
4
|
-
<DocumentFragment>
|
5
|
-
<form
|
6
|
-
action="#"
|
7
|
-
>
|
8
|
-
<div
|
9
|
-
class="field-array-card card"
|
10
|
-
>
|
11
|
-
<div
|
12
|
-
class="card-header card-action-header d-flex align-items-baseline
|
13
|
-
>
|
14
|
-
<strong
|
15
|
-
class="mr-auto
|
16
|
-
>
|
17
|
-
Names
|
18
|
-
</strong>
|
19
|
-
<div
|
20
|
-
class="card-action-header-actions
|
21
|
-
>
|
22
|
-
<button
|
23
|
-
class="add-array-item btn btn-link"
|
24
|
-
title="Add an additional item"
|
25
|
-
type="button"
|
26
|
-
>
|
27
|
-
<
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`FormInputArray has matching snapshot 1`] = `
|
4
|
+
<DocumentFragment>
|
5
|
+
<form
|
6
|
+
action="#"
|
7
|
+
>
|
8
|
+
<div
|
9
|
+
class="field-array-card card"
|
10
|
+
>
|
11
|
+
<div
|
12
|
+
class="card-header card-action-header d-flex align-items-baseline"
|
13
|
+
>
|
14
|
+
<strong
|
15
|
+
class="mr-auto"
|
16
|
+
>
|
17
|
+
Names
|
18
|
+
</strong>
|
19
|
+
<div
|
20
|
+
class="card-action-header-actions"
|
21
|
+
>
|
22
|
+
<button
|
23
|
+
class="add-array-item btn btn-link"
|
24
|
+
title="Add an additional item"
|
25
|
+
type="button"
|
26
|
+
>
|
27
|
+
<svg
|
28
|
+
aria-hidden="true"
|
29
|
+
class="svg-inline--fa fa-plus fa-w-14 "
|
30
|
+
data-icon="plus"
|
31
|
+
data-prefix="fas"
|
32
|
+
focusable="false"
|
33
|
+
role="img"
|
34
|
+
viewBox="0 0 448 512"
|
35
|
+
xmlns="http://www.w3.org/2000/svg"
|
36
|
+
>
|
37
|
+
<path
|
38
|
+
d="M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"
|
39
|
+
fill="currentColor"
|
40
|
+
/>
|
41
|
+
</svg>
|
42
|
+
Add New
|
43
|
+
</button>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
<div
|
47
|
+
class="card-body"
|
48
|
+
/>
|
49
|
+
</div>
|
50
|
+
</form>
|
51
|
+
</DocumentFragment>
|
52
|
+
`;
|
@@ -1,8 +1,13 @@
|
|
1
|
-
.
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
.field-array-card {
|
2
|
+
margin-bottom: 1rem;
|
3
|
+
|
4
|
+
.field-array-item {
|
5
|
+
&.removed {
|
6
|
+
display: none;
|
7
|
+
}
|
8
|
+
|
9
|
+
> .remove-array-item {
|
10
|
+
display: flex;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import FormInputArray from './FormInputArray';
|
2
|
-
export default FormInputArray;
|
1
|
+
import FormInputArray from './FormInputArray';
|
2
|
+
export default FormInputArray;
|
package/src/FormSection.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
import React, { useContext } from 'react';
|
2
|
-
import NestedFormFieldContext from './NestedFormFieldContext';
|
3
|
-
|
4
|
-
export default function FormSection({ children, name }) {
|
5
|
-
const parentContext = useContext(NestedFormFieldContext);
|
6
|
-
const effectiveValue = parentContext ? `${parentContext}.${name}` : name;
|
7
|
-
|
8
|
-
return (
|
9
|
-
<NestedFormFieldContext.Provider value={effectiveValue}>
|
10
|
-
{children}
|
11
|
-
</NestedFormFieldContext.Provider>
|
12
|
-
);
|
13
|
-
}
|
1
|
+
import React, { useContext } from 'react';
|
2
|
+
import NestedFormFieldContext from './NestedFormFieldContext';
|
3
|
+
|
4
|
+
export default function FormSection({ children, name }) {
|
5
|
+
const parentContext = useContext(NestedFormFieldContext);
|
6
|
+
const effectiveValue = parentContext ? `${parentContext}.${name}` : name;
|
7
|
+
|
8
|
+
return (
|
9
|
+
<NestedFormFieldContext.Provider value={effectiveValue}>
|
10
|
+
{children}
|
11
|
+
</NestedFormFieldContext.Provider>
|
12
|
+
);
|
13
|
+
}
|
package/src/IconInput.js
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import PropTypes from 'prop-types';
|
3
|
-
import {
|
4
|
-
InputGroup,
|
5
|
-
InputGroupAddon,
|
6
|
-
InputGroupText,
|
7
|
-
Input as BootstrapInput,
|
8
|
-
FormFeedback,
|
9
|
-
} from 'reactstrap';
|
10
|
-
import useStandardFormInput from './useStandardFormInput';
|
11
|
-
|
12
|
-
export default function IconInput({ className, icon, helpText, ...props }) {
|
13
|
-
const [input, meta] = useStandardFormInput(props);
|
14
|
-
return (
|
15
|
-
<InputGroup className={className}>
|
16
|
-
<InputGroupAddon addonType="prepend">
|
17
|
-
<InputGroupText>
|
18
|
-
<i className={icon} />
|
19
|
-
</InputGroupText>
|
20
|
-
</InputGroupAddon>
|
21
|
-
<BootstrapInput invalid={!!meta.error} {...input} />
|
22
|
-
{meta.error && <FormFeedback>{meta.error}</FormFeedback>}
|
23
|
-
{helpText && <FormFeedback>{helpText}</FormFeedback>}
|
24
|
-
</InputGroup>
|
25
|
-
);
|
26
|
-
}
|
27
|
-
|
28
|
-
IconInput.propTypes = {
|
29
|
-
icon: PropTypes.string,
|
30
|
-
className: PropTypes.string,
|
31
|
-
};
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import {
|
4
|
+
InputGroup,
|
5
|
+
InputGroupAddon,
|
6
|
+
InputGroupText,
|
7
|
+
Input as BootstrapInput,
|
8
|
+
FormFeedback,
|
9
|
+
} from 'reactstrap';
|
10
|
+
import useStandardFormInput from './useStandardFormInput';
|
11
|
+
|
12
|
+
export default function IconInput({ className, icon, helpText, ...props }) {
|
13
|
+
const [input, meta] = useStandardFormInput(props);
|
14
|
+
return (
|
15
|
+
<InputGroup className={className}>
|
16
|
+
<InputGroupAddon addonType="prepend">
|
17
|
+
<InputGroupText>
|
18
|
+
<i className={icon} />
|
19
|
+
</InputGroupText>
|
20
|
+
</InputGroupAddon>
|
21
|
+
<BootstrapInput invalid={!!meta.error} {...input} />
|
22
|
+
{meta.error && <FormFeedback>{meta.error}</FormFeedback>}
|
23
|
+
{helpText && <FormFeedback>{helpText}</FormFeedback>}
|
24
|
+
</InputGroup>
|
25
|
+
);
|
26
|
+
}
|
27
|
+
|
28
|
+
IconInput.propTypes = {
|
29
|
+
icon: PropTypes.string,
|
30
|
+
className: PropTypes.string,
|
31
|
+
};
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import FormInput from '../FormInput';
|
3
|
-
|
4
|
-
export default function InlineFormInput(props) {
|
5
|
-
return <FormInput className="inline-form-input col" {...props} />;
|
6
|
-
}
|
1
|
+
import React from 'react';
|
2
|
+
import FormInput from '../FormInput';
|
3
|
+
|
4
|
+
export default function InlineFormInput(props) {
|
5
|
+
return <FormInput className="inline-form-input col" {...props} />;
|
6
|
+
}
|
@@ -1,23 +1,23 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { render } from '@testing-library/react';
|
3
|
-
import { FormTestBase } from '../__Tests__';
|
4
|
-
import InlineFormInput from './InlineFormInput';
|
5
|
-
|
6
|
-
describe('MoneyInput', () => {
|
7
|
-
it('renders without crashing', () => {
|
8
|
-
render(
|
9
|
-
<FormTestBase>
|
10
|
-
<InlineFormInput name="test" />
|
11
|
-
</FormTestBase>
|
12
|
-
);
|
13
|
-
});
|
14
|
-
|
15
|
-
it('has matching snapshot', () => {
|
16
|
-
const renderResult = render(
|
17
|
-
<FormTestBase>
|
18
|
-
<InlineFormInput name="test" />
|
19
|
-
</FormTestBase>
|
20
|
-
);
|
21
|
-
expect(renderResult.asFragment()).toMatchSnapshot();
|
22
|
-
});
|
23
|
-
});
|
1
|
+
import React from 'react';
|
2
|
+
import { render } from '@testing-library/react';
|
3
|
+
import { FormTestBase } from '../__Tests__';
|
4
|
+
import InlineFormInput from './InlineFormInput';
|
5
|
+
|
6
|
+
describe('MoneyInput', () => {
|
7
|
+
it('renders without crashing', () => {
|
8
|
+
render(
|
9
|
+
<FormTestBase>
|
10
|
+
<InlineFormInput name="test" />
|
11
|
+
</FormTestBase>
|
12
|
+
);
|
13
|
+
});
|
14
|
+
|
15
|
+
it('has matching snapshot', () => {
|
16
|
+
const renderResult = render(
|
17
|
+
<FormTestBase>
|
18
|
+
<InlineFormInput name="test" />
|
19
|
+
</FormTestBase>
|
20
|
+
);
|
21
|
+
expect(renderResult.asFragment()).toMatchSnapshot();
|
22
|
+
});
|
23
|
+
});
|
@@ -1,26 +1,26 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`MoneyInput has matching snapshot 1`] = `
|
4
|
-
<DocumentFragment>
|
5
|
-
<form
|
6
|
-
action="#"
|
7
|
-
>
|
8
|
-
<div
|
9
|
-
class="inline-form-input col form-group"
|
10
|
-
>
|
11
|
-
<div
|
12
|
-
id="test-error-scroll-target"
|
13
|
-
style="display: none;"
|
14
|
-
/>
|
15
|
-
<input
|
16
|
-
aria-invalid="false"
|
17
|
-
class="inline-form-input col form-control"
|
18
|
-
id="test"
|
19
|
-
name="test"
|
20
|
-
type="text"
|
21
|
-
value=""
|
22
|
-
/>
|
23
|
-
</div>
|
24
|
-
</form>
|
25
|
-
</DocumentFragment>
|
26
|
-
`;
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`MoneyInput has matching snapshot 1`] = `
|
4
|
+
<DocumentFragment>
|
5
|
+
<form
|
6
|
+
action="#"
|
7
|
+
>
|
8
|
+
<div
|
9
|
+
class="inline-form-input col form-group"
|
10
|
+
>
|
11
|
+
<div
|
12
|
+
id="test-error-scroll-target"
|
13
|
+
style="display: none;"
|
14
|
+
/>
|
15
|
+
<input
|
16
|
+
aria-invalid="false"
|
17
|
+
class="inline-form-input col form-control"
|
18
|
+
id="test"
|
19
|
+
name="test"
|
20
|
+
type="text"
|
21
|
+
value=""
|
22
|
+
/>
|
23
|
+
</div>
|
24
|
+
</form>
|
25
|
+
</DocumentFragment>
|
26
|
+
`;
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import InlineFormInput from './InlineFormInput';
|
2
|
-
|
3
|
-
export default InlineFormInput;
|
1
|
+
import InlineFormInput from './InlineFormInput';
|
2
|
+
|
3
|
+
export default InlineFormInput;
|
@@ -1,3 +1,3 @@
|
|
1
|
-
.inline-form-input.form-group {
|
2
|
-
display: inline-block;
|
3
|
-
}
|
1
|
+
.inline-form-input.form-group {
|
2
|
+
display: inline-block;
|
3
|
+
}
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import InlineFormInput from '../InlineFormInput';
|
3
|
-
import moneyInputProps from './moneyInputProps';
|
4
|
-
|
5
|
-
export default function InlineMoneyInput(props) {
|
6
|
-
return <InlineFormInput {...moneyInputProps} {...props} />;
|
7
|
-
}
|
1
|
+
import React from 'react';
|
2
|
+
import InlineFormInput from '../InlineFormInput';
|
3
|
+
import moneyInputProps from './moneyInputProps';
|
4
|
+
|
5
|
+
export default function InlineMoneyInput(props) {
|
6
|
+
return <InlineFormInput {...moneyInputProps} {...props} />;
|
7
|
+
}
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import FormInput from '../FormInput';
|
3
|
-
import moneyInputProps from './moneyInputProps';
|
4
|
-
|
5
|
-
export default function MoneyInput(props) {
|
6
|
-
return <FormInput {...moneyInputProps} {...props} />;
|
7
|
-
}
|
1
|
+
import React from 'react';
|
2
|
+
import FormInput from '../FormInput';
|
3
|
+
import moneyInputProps from './moneyInputProps';
|
4
|
+
|
5
|
+
export default function MoneyInput(props) {
|
6
|
+
return <FormInput {...moneyInputProps} {...props} />;
|
7
|
+
}
|
@@ -1,43 +1,43 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { render } from '@testing-library/react';
|
3
|
-
import { FormTestBase } from '../__Tests__';
|
4
|
-
import MoneyInput from './MoneyInput';
|
5
|
-
import InlineMoneyInput from './InlineMoneyInput';
|
6
|
-
|
7
|
-
describe('MoneyInput', () => {
|
8
|
-
it('renders without crashing', () => {
|
9
|
-
render(
|
10
|
-
<FormTestBase>
|
11
|
-
<MoneyInput name="moneytest" />
|
12
|
-
</FormTestBase>
|
13
|
-
);
|
14
|
-
});
|
15
|
-
|
16
|
-
it('has matching snapshot', () => {
|
17
|
-
const renderResult = render(
|
18
|
-
<FormTestBase>
|
19
|
-
<MoneyInput name="moneytest" />
|
20
|
-
</FormTestBase>
|
21
|
-
);
|
22
|
-
expect(renderResult.asFragment()).toMatchSnapshot();
|
23
|
-
});
|
24
|
-
});
|
25
|
-
|
26
|
-
describe('InlineMoneyInput', () => {
|
27
|
-
it('renders without crashing', () => {
|
28
|
-
render(
|
29
|
-
<FormTestBase>
|
30
|
-
<InlineMoneyInput name="moneytest" />
|
31
|
-
</FormTestBase>
|
32
|
-
);
|
33
|
-
});
|
34
|
-
|
35
|
-
it('has matching snapshot', () => {
|
36
|
-
const renderResult = render(
|
37
|
-
<FormTestBase>
|
38
|
-
<InlineMoneyInput name="moneytest" />
|
39
|
-
</FormTestBase>
|
40
|
-
);
|
41
|
-
expect(renderResult.asFragment()).toMatchSnapshot();
|
42
|
-
});
|
43
|
-
});
|
1
|
+
import React from 'react';
|
2
|
+
import { render } from '@testing-library/react';
|
3
|
+
import { FormTestBase } from '../__Tests__';
|
4
|
+
import MoneyInput from './MoneyInput';
|
5
|
+
import InlineMoneyInput from './InlineMoneyInput';
|
6
|
+
|
7
|
+
describe('MoneyInput', () => {
|
8
|
+
it('renders without crashing', () => {
|
9
|
+
render(
|
10
|
+
<FormTestBase>
|
11
|
+
<MoneyInput name="moneytest" />
|
12
|
+
</FormTestBase>
|
13
|
+
);
|
14
|
+
});
|
15
|
+
|
16
|
+
it('has matching snapshot', () => {
|
17
|
+
const renderResult = render(
|
18
|
+
<FormTestBase>
|
19
|
+
<MoneyInput name="moneytest" />
|
20
|
+
</FormTestBase>
|
21
|
+
);
|
22
|
+
expect(renderResult.asFragment()).toMatchSnapshot();
|
23
|
+
});
|
24
|
+
});
|
25
|
+
|
26
|
+
describe('InlineMoneyInput', () => {
|
27
|
+
it('renders without crashing', () => {
|
28
|
+
render(
|
29
|
+
<FormTestBase>
|
30
|
+
<InlineMoneyInput name="moneytest" />
|
31
|
+
</FormTestBase>
|
32
|
+
);
|
33
|
+
});
|
34
|
+
|
35
|
+
it('has matching snapshot', () => {
|
36
|
+
const renderResult = render(
|
37
|
+
<FormTestBase>
|
38
|
+
<InlineMoneyInput name="moneytest" />
|
39
|
+
</FormTestBase>
|
40
|
+
);
|
41
|
+
expect(renderResult.asFragment()).toMatchSnapshot();
|
42
|
+
});
|
43
|
+
});
|
@@ -1,81 +1,81 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`InlineMoneyInput has matching snapshot 1`] = `
|
4
|
-
<DocumentFragment>
|
5
|
-
<form
|
6
|
-
action="#"
|
7
|
-
>
|
8
|
-
<div
|
9
|
-
class="money-input form-group"
|
10
|
-
>
|
11
|
-
<div
|
12
|
-
id="moneytest-error-scroll-target"
|
13
|
-
style="display: none;"
|
14
|
-
/>
|
15
|
-
<div
|
16
|
-
class="input-group"
|
17
|
-
>
|
18
|
-
<div
|
19
|
-
class="input-group-prepend"
|
20
|
-
>
|
21
|
-
<span
|
22
|
-
class="input-group-text"
|
23
|
-
>
|
24
|
-
$
|
25
|
-
</span>
|
26
|
-
</div>
|
27
|
-
<input
|
28
|
-
aria-invalid="false"
|
29
|
-
class="money-input form-control"
|
30
|
-
id="moneytest"
|
31
|
-
min="0"
|
32
|
-
name="moneytest"
|
33
|
-
step="0.01"
|
34
|
-
type="number"
|
35
|
-
value=""
|
36
|
-
/>
|
37
|
-
</div>
|
38
|
-
</div>
|
39
|
-
</form>
|
40
|
-
</DocumentFragment>
|
41
|
-
`;
|
42
|
-
|
43
|
-
exports[`MoneyInput has matching snapshot 1`] = `
|
44
|
-
<DocumentFragment>
|
45
|
-
<form
|
46
|
-
action="#"
|
47
|
-
>
|
48
|
-
<div
|
49
|
-
class="money-input form-group"
|
50
|
-
>
|
51
|
-
<div
|
52
|
-
id="moneytest-error-scroll-target"
|
53
|
-
style="display: none;"
|
54
|
-
/>
|
55
|
-
<div
|
56
|
-
class="input-group"
|
57
|
-
>
|
58
|
-
<div
|
59
|
-
class="input-group-prepend"
|
60
|
-
>
|
61
|
-
<span
|
62
|
-
class="input-group-text"
|
63
|
-
>
|
64
|
-
$
|
65
|
-
</span>
|
66
|
-
</div>
|
67
|
-
<input
|
68
|
-
aria-invalid="false"
|
69
|
-
class="money-input form-control"
|
70
|
-
id="moneytest"
|
71
|
-
min="0"
|
72
|
-
name="moneytest"
|
73
|
-
step="0.01"
|
74
|
-
type="number"
|
75
|
-
value=""
|
76
|
-
/>
|
77
|
-
</div>
|
78
|
-
</div>
|
79
|
-
</form>
|
80
|
-
</DocumentFragment>
|
81
|
-
`;
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`InlineMoneyInput has matching snapshot 1`] = `
|
4
|
+
<DocumentFragment>
|
5
|
+
<form
|
6
|
+
action="#"
|
7
|
+
>
|
8
|
+
<div
|
9
|
+
class="money-input form-group"
|
10
|
+
>
|
11
|
+
<div
|
12
|
+
id="moneytest-error-scroll-target"
|
13
|
+
style="display: none;"
|
14
|
+
/>
|
15
|
+
<div
|
16
|
+
class="input-group"
|
17
|
+
>
|
18
|
+
<div
|
19
|
+
class="input-group-prepend"
|
20
|
+
>
|
21
|
+
<span
|
22
|
+
class="input-group-text"
|
23
|
+
>
|
24
|
+
$
|
25
|
+
</span>
|
26
|
+
</div>
|
27
|
+
<input
|
28
|
+
aria-invalid="false"
|
29
|
+
class="money-input form-control"
|
30
|
+
id="moneytest"
|
31
|
+
min="0"
|
32
|
+
name="moneytest"
|
33
|
+
step="0.01"
|
34
|
+
type="number"
|
35
|
+
value=""
|
36
|
+
/>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
</form>
|
40
|
+
</DocumentFragment>
|
41
|
+
`;
|
42
|
+
|
43
|
+
exports[`MoneyInput has matching snapshot 1`] = `
|
44
|
+
<DocumentFragment>
|
45
|
+
<form
|
46
|
+
action="#"
|
47
|
+
>
|
48
|
+
<div
|
49
|
+
class="money-input form-group"
|
50
|
+
>
|
51
|
+
<div
|
52
|
+
id="moneytest-error-scroll-target"
|
53
|
+
style="display: none;"
|
54
|
+
/>
|
55
|
+
<div
|
56
|
+
class="input-group"
|
57
|
+
>
|
58
|
+
<div
|
59
|
+
class="input-group-prepend"
|
60
|
+
>
|
61
|
+
<span
|
62
|
+
class="input-group-text"
|
63
|
+
>
|
64
|
+
$
|
65
|
+
</span>
|
66
|
+
</div>
|
67
|
+
<input
|
68
|
+
aria-invalid="false"
|
69
|
+
class="money-input form-control"
|
70
|
+
id="moneytest"
|
71
|
+
min="0"
|
72
|
+
name="moneytest"
|
73
|
+
step="0.01"
|
74
|
+
type="number"
|
75
|
+
value=""
|
76
|
+
/>
|
77
|
+
</div>
|
78
|
+
</div>
|
79
|
+
</form>
|
80
|
+
</DocumentFragment>
|
81
|
+
`;
|
package/src/MoneyInput/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import MoneyInput from './MoneyInput';
|
2
|
-
import InlineMoneyInput from './InlineMoneyInput';
|
3
|
-
|
4
|
-
export { MoneyInput, InlineMoneyInput };
|
1
|
+
import MoneyInput from './MoneyInput';
|
2
|
+
import InlineMoneyInput from './InlineMoneyInput';
|
3
|
+
|
4
|
+
export { MoneyInput, InlineMoneyInput };
|
@@ -1,3 +1,3 @@
|
|
1
|
-
input.money-input {
|
2
|
-
text-align: right;
|
3
|
-
}
|
1
|
+
input.money-input {
|
2
|
+
text-align: right;
|
3
|
+
}
|