envoc-form 3.3.2 → 3.3.3
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
CHANGED
@@ -5,4 +5,8 @@
|
|
5
5
|
Base form package for envoc projects.
|
6
6
|
|
7
7
|
[npm-badge]: https://img.shields.io/npm/v/envoc-form.png?style=flat
|
8
|
-
[npm]: https://www.npmjs.com/package/envoc-form
|
8
|
+
[npm]: https://www.npmjs.com/package/envoc-form
|
9
|
+
|
10
|
+
## Breaking Changes from v2
|
11
|
+
|
12
|
+
- Peer dependency for react-router-dom updated to v6
|
@@ -23,7 +23,6 @@ import { faPlus, faTrash } from '@fortawesome/free-solid-svg-icons';
|
|
23
23
|
import PropTypes from 'prop-types';
|
24
24
|
import useStandardFormInput from '../useStandardFormInput';
|
25
25
|
import NestedFormFieldContext from '../NestedFormFieldContext';
|
26
|
-
import classNames from 'classnames';
|
27
26
|
export default function FormInputArray(_ref) {
|
28
27
|
var id = _ref.id,
|
29
28
|
name = _ref.name,
|
@@ -67,7 +67,7 @@ export default function useStandardFormInput(_ref) {
|
|
67
67
|
// there is a "setFieldTouched" from useFormikContext but it doesn't appear to work on field arrays
|
68
68
|
handleBlur();
|
69
69
|
}
|
70
|
-
});
|
70
|
+
}, [meta.touched, isSubmitting]);
|
71
71
|
var resultMeta = Object.assign({}, meta, {
|
72
72
|
error: getServerError(name) || (meta.touched ? meta.error : null)
|
73
73
|
});
|
@@ -83,7 +83,7 @@ function useStandardFormInput(_ref) {
|
|
83
83
|
// there is a "setFieldTouched" from useFormikContext but it doesn't appear to work on field arrays
|
84
84
|
handleBlur();
|
85
85
|
}
|
86
|
-
});
|
86
|
+
}, [meta.touched, isSubmitting]);
|
87
87
|
var resultMeta = Object.assign({}, meta, {
|
88
88
|
error: getServerError(name) || (meta.touched ? meta.error : null)
|
89
89
|
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "envoc-form",
|
3
|
-
"version": "3.3.
|
3
|
+
"version": "3.3.3",
|
4
4
|
"description": "Envoc form components",
|
5
5
|
"keywords": [
|
6
6
|
"react-component",
|
@@ -26,7 +26,7 @@
|
|
26
26
|
"axios": "^0.21.1",
|
27
27
|
"classnames": "^2.3.1",
|
28
28
|
"date-fns": "^2.22.1",
|
29
|
-
"envoc-request": "^3.3.
|
29
|
+
"envoc-request": "^3.3.3",
|
30
30
|
"lodash": "^4.17.21",
|
31
31
|
"lru-cache": "^6.0.0",
|
32
32
|
"prop-types": "^15.7.2",
|
@@ -97,5 +97,5 @@
|
|
97
97
|
"test": "cross-env SKIP_PREFLIGHT_CHECK=true react-scripts test --watchAll=false",
|
98
98
|
"coverage": "yarn test --reporters=jest-junit --coverage --coverageReporters=cobertura"
|
99
99
|
},
|
100
|
-
"readme": "# envoc-form\r\n\r\n[![npm package][npm-badge]][npm]\r\n\r\nBase form package for envoc projects.\r\n\r\n[npm-badge]: https://img.shields.io/npm/v/envoc-form.png?style=flat\r\n[npm]: https://www.npmjs.com/package/envoc-form"
|
100
|
+
"readme": "# envoc-form\r\n\r\n[![npm package][npm-badge]][npm]\r\n\r\nBase form package for envoc projects.\r\n\r\n[npm-badge]: https://img.shields.io/npm/v/envoc-form.png?style=flat\r\n[npm]: https://www.npmjs.com/package/envoc-form\r\n\r\n## Breaking Changes from v2\r\n\r\n- Peer dependency for react-router-dom updated to v6\r\n"
|
101
101
|
}
|
@@ -2,12 +2,11 @@ import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { v4 as uuid } from 'uuid';
|
3
3
|
import classnames from 'classnames';
|
4
4
|
import { Col, Card, Button, CardBody, Row, Alert } from 'reactstrap';
|
5
|
-
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'
|
6
|
-
import {faPlus, faTrash} from '@fortawesome/free-solid-svg-icons'
|
5
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
6
|
+
import { faPlus, faTrash } from '@fortawesome/free-solid-svg-icons';
|
7
7
|
import PropTypes from 'prop-types';
|
8
8
|
import useStandardFormInput from '../useStandardFormInput';
|
9
9
|
import NestedFormFieldContext from '../NestedFormFieldContext';
|
10
|
-
import classNames from 'classnames';
|
11
10
|
|
12
11
|
export default function FormInputArray({
|
13
12
|
id,
|
@@ -32,7 +31,6 @@ export default function FormInputArray({
|
|
32
31
|
inputPropsRef.current = inputProps;
|
33
32
|
const values = inputProps.value || [];
|
34
33
|
const length = values.length;
|
35
|
-
|
36
34
|
useEffect(() => {
|
37
35
|
return () => {
|
38
36
|
setHasChangedLength(true);
|
@@ -94,12 +92,12 @@ export default function FormInputArray({
|
|
94
92
|
role="listitem">
|
95
93
|
<NestedFormFieldContext.Provider value={itemName}>
|
96
94
|
<div className="component">
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
95
|
+
<Component
|
96
|
+
value={value}
|
97
|
+
name={itemName}
|
98
|
+
disabled={disabled}
|
99
|
+
{...props}
|
100
|
+
/>
|
103
101
|
</div>
|
104
102
|
</NestedFormFieldContext.Provider>
|
105
103
|
{!disabled && (
|
@@ -108,7 +106,7 @@ export default function FormInputArray({
|
|
108
106
|
color="link"
|
109
107
|
onClick={() => removeItem(index)}
|
110
108
|
title="Remove Item">
|
111
|
-
|
109
|
+
<FontAwesomeIcon icon={faTrash} />
|
112
110
|
</Button>
|
113
111
|
</div>
|
114
112
|
)}
|
@@ -13,9 +13,8 @@ export default function useStandardFormInput({
|
|
13
13
|
...props
|
14
14
|
}) {
|
15
15
|
// because the formik errors are evaluated all at the same time we need to keep server errors separate
|
16
|
-
const { getError: getServerError, setError: setServerError } =
|
17
|
-
ServerErrorContext
|
18
|
-
);
|
16
|
+
const { getError: getServerError, setError: setServerError } =
|
17
|
+
useContext(ServerErrorContext);
|
19
18
|
|
20
19
|
// ensure that form section values are obeyed, e.g. homeAddress.zipCode
|
21
20
|
const parentFormFieldContext = useContext(NestedFormFieldContext);
|
@@ -65,7 +64,7 @@ export default function useStandardFormInput({
|
|
65
64
|
// there is a "setFieldTouched" from useFormikContext but it doesn't appear to work on field arrays
|
66
65
|
handleBlur();
|
67
66
|
}
|
68
|
-
});
|
67
|
+
}, [meta.touched, isSubmitting]);
|
69
68
|
|
70
69
|
const resultMeta = Object.assign({}, meta, {
|
71
70
|
error: getServerError(name) || (meta.touched ? meta.error : null),
|