@smartive/datocms-utils 1.5.0 → 1.6.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/CHANGELOG.md +2 -2
- package/README.md +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/links.d.ts +7 -0
- package/dist/links.js +15 -0
- package/dist/links.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/links.ts +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# [1.
|
|
1
|
+
# [1.6.0](https://github.com/smartive/datocms-utils/compare/v1.5.0...v1.6.0) (2025-02-07)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Features
|
|
5
5
|
|
|
6
|
-
* add
|
|
6
|
+
* add getTelLink utility ([#61](https://github.com/smartive/datocms-utils/issues/61)) ([31044d9](https://github.com/smartive/datocms-utils/commit/31044d91f9d47736a2ca254501eb5d11dc6998a8))
|
package/README.md
CHANGED
|
@@ -37,6 +37,7 @@ CREATE TABLE IF NOT EXISTS query_cache_tags (
|
|
|
37
37
|
### Other Utilities
|
|
38
38
|
|
|
39
39
|
- `classNames`: Cleans and joins an array of inputs with possible undefined or boolean values. Useful for tailwind classnames.
|
|
40
|
+
- `getTelLink`: Formats a phone number to a tel link.
|
|
40
41
|
|
|
41
42
|
### Types
|
|
42
43
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
package/dist/links.d.ts
ADDED
package/dist/links.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a phone number into a `tel:` link.
|
|
3
|
+
*
|
|
4
|
+
* @param phoneNumber Phone number
|
|
5
|
+
* @returns `tel:` link for the phone number
|
|
6
|
+
*/
|
|
7
|
+
export const getTelLink = (phoneNumber) => {
|
|
8
|
+
if (typeof phoneNumber !== 'string') {
|
|
9
|
+
throw new Error('Phone number must be a string.');
|
|
10
|
+
}
|
|
11
|
+
// Remove non-digit characters except for '+' which is used for international numbers
|
|
12
|
+
const cleanedPhoneNumber = phoneNumber.replace(/[^\d+]/g, '');
|
|
13
|
+
return `tel:${cleanedPhoneNumber}`;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=links.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.js","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,WAAmB,EAAU,EAAE;IACxD,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED,qFAAqF;IACrF,MAAM,kBAAkB,GAAG,WAAW,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAE9D,OAAO,OAAO,kBAAkB,EAAE,CAAC;AACrC,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/links.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a phone number into a `tel:` link.
|
|
3
|
+
*
|
|
4
|
+
* @param phoneNumber Phone number
|
|
5
|
+
* @returns `tel:` link for the phone number
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const getTelLink = (phoneNumber: string): string => {
|
|
9
|
+
if (typeof phoneNumber !== 'string') {
|
|
10
|
+
throw new Error('Phone number must be a string.');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Remove non-digit characters except for '+' which is used for international numbers
|
|
14
|
+
const cleanedPhoneNumber = phoneNumber.replace(/[^\d+]/g, '');
|
|
15
|
+
|
|
16
|
+
return `tel:${cleanedPhoneNumber}`;
|
|
17
|
+
};
|