@dereekb/util 13.4.2 → 13.5.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/fetch/index.cjs.js +11 -36
- package/fetch/index.esm.js +11 -36
- package/fetch/package.json +2 -2
- package/index.cjs.js +255 -274
- package/index.esm.js +253 -275
- package/package.json +1 -1
- package/src/lib/contact/phone.d.ts +24 -3
- package/src/lib/string/html.d.ts +51 -0
- package/test/package.json +2 -2
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@ export type PhoneExtensionNumber = string;
|
|
|
24
24
|
export type E164PhoneNumber = `+${PhoneNumber}`;
|
|
25
25
|
/**
|
|
26
26
|
* Regular expression for validating E.164 phone numbers.
|
|
27
|
-
* Validates numbers that start with a + followed by
|
|
27
|
+
* Validates numbers that start with a + followed by 7-15 digits.
|
|
28
28
|
* The first digit after the + must be 1-9 (not 0).
|
|
29
29
|
*
|
|
30
30
|
* Requires the + to be provided.
|
|
@@ -50,7 +50,7 @@ export type E164PhoneNumberWithExtension = `+${PhoneNumber}#${PhoneExtensionNumb
|
|
|
50
50
|
export type E164PhoneNumberWithOptionalExtension = E164PhoneNumber | E164PhoneNumberWithExtension;
|
|
51
51
|
/**
|
|
52
52
|
* Regular expression for validating E.164 phone numbers with an optional extension.
|
|
53
|
-
* Validates numbers in the format +number or +number#extension.
|
|
53
|
+
* Validates numbers with 7-15 digits in the format +number or +number#extension.
|
|
54
54
|
* The extension part is 1-6 digits following a # character.
|
|
55
55
|
*
|
|
56
56
|
* Requires the + to be provided.
|
|
@@ -58,7 +58,7 @@ export type E164PhoneNumberWithOptionalExtension = E164PhoneNumber | E164PhoneNu
|
|
|
58
58
|
export declare const E164PHONE_NUMBER_WITH_OPTIONAL_EXTENSION_REGEX: RegExp;
|
|
59
59
|
/**
|
|
60
60
|
* Regular expression for validating E.164 phone numbers that must include an extension.
|
|
61
|
-
* Validates numbers strictly in the format +number#extension.
|
|
61
|
+
* Validates numbers with 7-15 digits strictly in the format +number#extension.
|
|
62
62
|
* The extension part is 1-6 digits following a # character.
|
|
63
63
|
*
|
|
64
64
|
* Requires the + to be provided and the extension part.
|
|
@@ -116,3 +116,24 @@ export declare function e164PhoneNumberExtensionPair(input: PhoneNumber | E164Ph
|
|
|
116
116
|
* @returns A formatted phone number string with optional extension
|
|
117
117
|
*/
|
|
118
118
|
export declare function e164PhoneNumberFromE164PhoneNumberExtensionPair(input: E164PhoneNumberExtensionPair): E164PhoneNumberWithOptionalExtension;
|
|
119
|
+
/**
|
|
120
|
+
* Attempts to convert a raw phone number string into a valid {@link E164PhoneNumber}.
|
|
121
|
+
*
|
|
122
|
+
* Strips common formatting characters (parentheses, hyphens, spaces, dots), then checks
|
|
123
|
+
* if the result is already valid E.164. If not, prepends the given country code and
|
|
124
|
+
* validates again.
|
|
125
|
+
*
|
|
126
|
+
* @param input - A raw phone number string, possibly with formatting (e.g. `'(720)6620850'`, `'720-662-0850'`)
|
|
127
|
+
* @param defaultCountryCode - The country calling code to prepend if the number lacks one (default: `'1'` for US/Canada)
|
|
128
|
+
* @returns The corrected {@link E164PhoneNumber}, or `undefined` if the input cannot be converted
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* tryConvertToE164PhoneNumber('(720)6620850'); // '+17206620850'
|
|
133
|
+
* tryConvertToE164PhoneNumber('720-662-0850'); // '+17206620850'
|
|
134
|
+
* tryConvertToE164PhoneNumber('+17206620850'); // '+17206620850'
|
|
135
|
+
* tryConvertToE164PhoneNumber('7206620850', '44'); // '+447206620850'
|
|
136
|
+
* tryConvertToE164PhoneNumber('abc'); // undefined
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export declare function tryConvertToE164PhoneNumber(input: string, defaultCountryCode?: string): Maybe<E164PhoneNumber>;
|
package/src/lib/string/html.d.ts
CHANGED
|
@@ -5,6 +5,57 @@ import { type PrimativeValue } from '../type';
|
|
|
5
5
|
* Represents a single CSS Class
|
|
6
6
|
*/
|
|
7
7
|
export type CssClass = string;
|
|
8
|
+
/**
|
|
9
|
+
* The name portion of a CSS token, without the leading `--` prefix.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const name: CssTokenName = 'dbx-primary-color';
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export type CssTokenName = string;
|
|
17
|
+
/**
|
|
18
|
+
* Represents a CSS custom property token (CSS variable).
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const token: CssToken = '--dbx-primary-color';
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export type CssToken<T extends CssTokenName = CssTokenName> = `--${T}`;
|
|
26
|
+
/**
|
|
27
|
+
* A CSS token wrapped in a var() call.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const tokenVar: CssTokenVar = 'var(--dbx-primary-color)';
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export type CssTokenVar<T extends CssToken = CssToken> = `var(${T})`;
|
|
35
|
+
/**
|
|
36
|
+
* Converts a CSS token into a var() string.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* cssTokenVar('--dbx-primary-color'); // 'var(--dbx-primary-color)'
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @param cssToken - the CSS token to convert
|
|
44
|
+
* @returns the var() string
|
|
45
|
+
*/
|
|
46
|
+
export declare function cssTokenVar<T extends CssToken>(cssToken: T): CssTokenVar<T>;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Use {@link CssToken} instead.
|
|
49
|
+
*/
|
|
50
|
+
export type CssVariable = CssToken;
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated Use {@link CssTokenVar} instead.
|
|
53
|
+
*/
|
|
54
|
+
export type CssVariableVar<T extends CssToken = CssToken> = CssTokenVar<T>;
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated Use {@link cssTokenVar} instead.
|
|
57
|
+
*/
|
|
58
|
+
export declare const cssVariableVar: typeof cssTokenVar;
|
|
8
59
|
/**
|
|
9
60
|
* Represents a single CSS Style
|
|
10
61
|
*/
|