@availity/phone 2.1.4 → 2.2.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/CHANGELOG.md +42 -0
- package/package.json +6 -6
- package/project.json +8 -6
- package/src/Phone.d.ts +1 -0
- package/src/Phone.js +21 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,48 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [2.2.1](https://github.com/Availity/availity-react/compare/@availity/phone@2.2.0...@availity/phone@2.2.1) (2024-08-22)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# 1.0.0 (2024-08-22)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **phone:** remove yup.number validation method, remove async from test ([b346896](https://github.com/Availity/availity-react/commit/b346896414fc71c208be4f39cf6ac77412c5fea0))
|
|
15
|
+
* **phone:** typings for PhoneProps and ExtensionProps should extend FieldProps ([cdd467b](https://github.com/Availity/availity-react/commit/cdd467b3158dead419c3bfa6f551e5badf6edf3c))
|
|
16
|
+
* **phone:** update types ([30c7fc8](https://github.com/Availity/availity-react/commit/30c7fc885b1b91b04a5153fbf796e8c136692be4))
|
|
17
|
+
* upgrade yup and update sb stories ([68aeafe](https://github.com/Availity/availity-react/commit/68aeafe4fd7d90d7c88dbb24636ba7770fe87aa3))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
* feat(phone)!: upgrade to yup 0.32.0 ([dadde41](https://github.com/Availity/availity-react/commit/dadde41e7535ee444a0737a7ba31d5467a34133f))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* **form:** add currency input ([fa9eea6](https://github.com/Availity/availity-react/commit/fa9eea6a3b3dd2ef741a0658c102e36c6db5288c))
|
|
26
|
+
* move storybook, stories, and fix hmr ([2f65f71](https://github.com/Availity/availity-react/commit/2f65f71769d2d981e22700b87a09516833588f64))
|
|
27
|
+
* **phone:** add types ([b5cf0e6](https://github.com/Availity/availity-react/commit/b5cf0e62871266cc2e5689258912b1ba533bceb5))
|
|
28
|
+
* **phone:** initial commit for phone package ([76b7227](https://github.com/Availity/availity-react/commit/76b7227adee750265daa4e65486606d102a1e5c2))
|
|
29
|
+
* **phone:** initial format value ([#1447](https://github.com/Availity/availity-react/issues/1447)) ([3398a65](https://github.com/Availity/availity-react/commit/3398a65973bc46152ccd302f14b458e0af4d59d1))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### BREAKING CHANGES
|
|
33
|
+
|
|
34
|
+
* must be using yup 0.32.0
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# [2.2.0](https://github.com/Availity/availity-react/compare/@availity/phone@2.1.4...@availity/phone@2.2.0) (2024-08-01)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Features
|
|
42
|
+
|
|
43
|
+
* **phone:** initial format value ([#1447](https://github.com/Availity/availity-react/issues/1447)) ([3398a65](https://github.com/Availity/availity-react/commit/3398a65973bc46152ccd302f14b458e0af4d59d1))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
5
47
|
## [2.1.4](https://github.com/Availity/availity-react/compare/@availity/phone@2.1.3...@availity/phone@2.1.4) (2023-10-30)
|
|
6
48
|
|
|
7
49
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@availity/phone",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Availity Phone component using Formik and Yup",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"availity",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"publish:canary": "yarn npm publish --access public --tag canary"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"libphonenumber-js": "^1.
|
|
28
|
+
"libphonenumber-js": "^1.11.5",
|
|
29
29
|
"prop-types": "^15.8.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@availity/form": "1.
|
|
33
|
-
"formik": "^2.4.
|
|
34
|
-
"react": "^18.
|
|
35
|
-
"react-dom": "^18.
|
|
32
|
+
"@availity/form": "1.9.2",
|
|
33
|
+
"formik": "^2.4.6",
|
|
34
|
+
"react": "^18.3.1",
|
|
35
|
+
"react-dom": "^18.3.1",
|
|
36
36
|
"reactstrap": "^8.10.1",
|
|
37
37
|
"yup": "^0.32.11"
|
|
38
38
|
},
|
package/project.json
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
2
|
+
"name": "@availity/phone",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
3
4
|
"projectType": "library",
|
|
4
5
|
"targets": {
|
|
5
6
|
"test": {
|
|
6
7
|
"executor": "@nx/jest:jest",
|
|
7
|
-
"outputs": ["coverage/phone"],
|
|
8
|
-
"options": {
|
|
8
|
+
"outputs": ["{workspaceRoot}/coverage/phone"],
|
|
9
|
+
"options": {
|
|
10
|
+
"jestConfig": "packages/phone/jest.config.js"
|
|
11
|
+
}
|
|
9
12
|
},
|
|
10
13
|
"version": {
|
|
11
14
|
"executor": "@jscutlery/semver:version",
|
|
12
15
|
"options": {
|
|
13
16
|
"preset": "angular",
|
|
14
17
|
"commitMessageFormat": "chore({projectName}): release version ${version} [skip ci]",
|
|
15
|
-
"tagPrefix": "
|
|
18
|
+
"tagPrefix": "{projectName}@",
|
|
16
19
|
"baseBranch": "master"
|
|
17
20
|
}
|
|
18
21
|
},
|
|
19
22
|
"lint": {
|
|
20
|
-
"executor": "@nx/
|
|
23
|
+
"executor": "@nx/eslint:lint",
|
|
21
24
|
"options": {
|
|
22
25
|
"eslintConfig": ".eslintrc.yaml",
|
|
23
|
-
"lintFilePatterns": ["packages/phone/**/*.{js,ts}"],
|
|
24
26
|
"silent": false,
|
|
25
27
|
"fix": false,
|
|
26
28
|
"cache": true,
|
package/src/Phone.d.ts
CHANGED
package/src/Phone.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { Field } from '@availity/form';
|
|
4
4
|
import { useFormikContext } from 'formik';
|
|
5
5
|
import { AsYouType } from 'libphonenumber-js';
|
|
6
6
|
import { Row, Col } from 'reactstrap';
|
|
7
7
|
|
|
8
|
-
const Phone = ({
|
|
9
|
-
|
|
8
|
+
const Phone = ({
|
|
9
|
+
name,
|
|
10
|
+
label,
|
|
11
|
+
country = 'US',
|
|
12
|
+
showExtension = false,
|
|
13
|
+
extProps,
|
|
14
|
+
phoneColProps,
|
|
15
|
+
formatInitialValue,
|
|
16
|
+
...restPhoneProps
|
|
17
|
+
}) => {
|
|
18
|
+
const { setFieldValue, setFieldTouched, values } = useFormikContext();
|
|
10
19
|
|
|
11
20
|
let ext = null;
|
|
12
21
|
if (showExtension) {
|
|
@@ -27,6 +36,13 @@ const Phone = ({ name, label, country = 'US', showExtension = false, extProps, p
|
|
|
27
36
|
return asYouType.formattedOutput;
|
|
28
37
|
};
|
|
29
38
|
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (formatInitialValue) {
|
|
41
|
+
setFieldValue(name, asYouFormat(values[name]), false);
|
|
42
|
+
}
|
|
43
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
44
|
+
}, []);
|
|
45
|
+
|
|
30
46
|
const formatPhoneOnBlur = ({ target: { value } }) => {
|
|
31
47
|
setFieldValue(name, asYouFormat(value), true);
|
|
32
48
|
setFieldTouched(name, true, true);
|
|
@@ -60,6 +76,8 @@ Phone.propTypes = {
|
|
|
60
76
|
country: PropTypes.string,
|
|
61
77
|
/** Used to control props on the `<Col />` for the phone field, if needed. The phone column defaults to xs: { size: 12 } when not rendering an extension field, and defaults to xs: { size: 10 } when rendering an extension field. */
|
|
62
78
|
phoneColProps: PropTypes.object,
|
|
79
|
+
/** When true, when the field is first rendered, it will trigger the formatter to update the value. */
|
|
80
|
+
formatInitialValue: PropTypes.bool,
|
|
63
81
|
};
|
|
64
82
|
|
|
65
83
|
export default Phone;
|