@acceliance/twenty-click-to-call 0.1.0 → 0.1.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.
@@ -1,36 +1,36 @@
1
- // Twenty PHONES field: number and calling code are stored separately
2
- // (e.g. primaryPhoneNumber "6 12 34 56 78", primaryPhoneCallingCode "+33").
3
- export type TwentyPhones = {
4
- primaryPhoneNumber?: string | null;
5
- primaryPhoneCallingCode?: string | null;
6
- primaryPhoneCountryCode?: string | null;
7
- };
8
-
9
- const DEFAULT_CALLING_CODE = '+33';
10
-
11
- // Returns an E.164-like number (+33612345678), or null when there is no usable number.
12
- export const buildE164 = (phones: TwentyPhones | null | undefined): string | null => {
13
- const raw = phones?.primaryPhoneNumber?.trim();
14
- if (!raw) return null;
15
-
16
- // Already international: keep "+" and digits only
17
- if (raw.startsWith('+') || raw.startsWith('00')) {
18
- const digits = raw.replace(/\D/g, '').replace(/^00/, '');
19
- return digits.length >= 6 ? `+${digits}` : null;
20
- }
21
-
22
- const callingCode = (phones?.primaryPhoneCallingCode?.trim() || DEFAULT_CALLING_CODE).replace(
23
- /[^\d+]/g,
24
- '',
25
- );
26
- const national = raw.replace(/\D/g, '').replace(/^0+/, ''); // drop national trunk prefix "0"
27
- if (national.length < 4) return null;
28
-
29
- return `${callingCode.startsWith('+') ? callingCode : `+${callingCode}`}${national}`;
30
- };
31
-
32
- // Readable form for the notification text: +33 6 12 34 56 78
33
- export const formatForDisplay = (e164: string): string => {
34
- const match = /^\+33(\d)(\d{2})(\d{2})(\d{2})(\d{2})$/.exec(e164);
35
- return match ? `+33 ${match.slice(1).join(' ')}` : e164;
36
- };
1
+ // Twenty PHONES field: number and calling code are stored separately
2
+ // (e.g. primaryPhoneNumber "6 12 34 56 78", primaryPhoneCallingCode "+33").
3
+ export type TwentyPhones = {
4
+ primaryPhoneNumber?: string | null;
5
+ primaryPhoneCallingCode?: string | null;
6
+ primaryPhoneCountryCode?: string | null;
7
+ };
8
+
9
+ const DEFAULT_CALLING_CODE = '+33';
10
+
11
+ // Returns an E.164-like number (+33612345678), or null when there is no usable number.
12
+ export const buildE164 = (phones: TwentyPhones | null | undefined): string | null => {
13
+ const raw = phones?.primaryPhoneNumber?.trim();
14
+ if (!raw) return null;
15
+
16
+ // Already international: keep "+" and digits only
17
+ if (raw.startsWith('+') || raw.startsWith('00')) {
18
+ const digits = raw.replace(/\D/g, '').replace(/^00/, '');
19
+ return digits.length >= 6 ? `+${digits}` : null;
20
+ }
21
+
22
+ const callingCode = (phones?.primaryPhoneCallingCode?.trim() || DEFAULT_CALLING_CODE).replace(
23
+ /[^\d+]/g,
24
+ '',
25
+ );
26
+ const national = raw.replace(/\D/g, '').replace(/^0+/, ''); // drop national trunk prefix "0"
27
+ if (national.length < 4) return null;
28
+
29
+ return `${callingCode.startsWith('+') ? callingCode : `+${callingCode}`}${national}`;
30
+ };
31
+
32
+ // Readable form for the notification text: +33 6 12 34 56 78
33
+ export const formatForDisplay = (e164: string): string => {
34
+ const match = /^\+33(\d)(\d{2})(\d{2})(\d{2})(\d{2})$/.exec(e164);
35
+ return match ? `+33 ${match.slice(1).join(' ')}` : e164;
36
+ };
File without changes
package/tsconfig.json CHANGED
@@ -1,37 +1,37 @@
1
- {
2
- "compileOnSave": false,
3
- "compilerOptions": {
4
- "sourceMap": true,
5
- "declaration": true,
6
- "outDir": "./dist",
7
- "rootDir": ".",
8
- "jsx": "react-jsx",
9
- "moduleResolution": "bundler",
10
- "allowSyntheticDefaultImports": true,
11
- "emitDecoratorMetadata": true,
12
- "experimentalDecorators": true,
13
- "importHelpers": true,
14
- "allowUnreachableCode": false,
15
- "strict": true,
16
- "alwaysStrict": true,
17
- "noImplicitAny": true,
18
- "strictBindCallApply": false,
19
- "target": "es2020",
20
- "module": "esnext",
21
- "lib": ["es2020", "dom"],
22
- "skipLibCheck": true,
23
- "skipDefaultLibCheck": true,
24
- "resolveJsonModule": true,
25
- "paths": {
26
- "src/*": ["./src/*"],
27
- "~/*": ["./*"]
28
- }
29
- },
30
- "exclude": [
31
- "node_modules",
32
- "dist",
33
- "**/*.test.ts",
34
- "**/*.spec.ts",
35
- "**/*.integration-test.ts"
36
- ]
37
- }
1
+ {
2
+ "compileOnSave": false,
3
+ "compilerOptions": {
4
+ "sourceMap": true,
5
+ "declaration": true,
6
+ "outDir": "./dist",
7
+ "rootDir": ".",
8
+ "jsx": "react-jsx",
9
+ "moduleResolution": "bundler",
10
+ "allowSyntheticDefaultImports": true,
11
+ "emitDecoratorMetadata": true,
12
+ "experimentalDecorators": true,
13
+ "importHelpers": true,
14
+ "allowUnreachableCode": false,
15
+ "strict": true,
16
+ "alwaysStrict": true,
17
+ "noImplicitAny": true,
18
+ "strictBindCallApply": false,
19
+ "target": "es2020",
20
+ "module": "esnext",
21
+ "lib": ["es2020", "dom"],
22
+ "skipLibCheck": true,
23
+ "skipDefaultLibCheck": true,
24
+ "resolveJsonModule": true,
25
+ "paths": {
26
+ "src/*": ["./src/*"],
27
+ "~/*": ["./*"]
28
+ }
29
+ },
30
+ "exclude": [
31
+ "node_modules",
32
+ "dist",
33
+ "**/*.test.ts",
34
+ "**/*.spec.ts",
35
+ "**/*.integration-test.ts"
36
+ ]
37
+ }