asma-core-helpers 0.34.0 → 0.36.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/README.md +25 -0
- package/lib/helpers/generateEnvConfigsBindings.d.ts.map +1 -1
- package/lib/helpers/generateEnvConfigsBindings.js +29 -5
- package/lib/helpers/generateEnvConfigsBindings.js.map +1 -1
- package/lib/phone/index.d.ts +15 -0
- package/lib/phone/index.d.ts.map +1 -0
- package/lib/phone/index.js +15 -0
- package/lib/phone/index.js.map +1 -0
- package/lib/phone/phoneCountries.d.ts +44 -0
- package/lib/phone/phoneCountries.d.ts.map +1 -0
- package/lib/phone/phoneCountries.js +84 -0
- package/lib/phone/phoneCountries.js.map +1 -0
- package/lib/phone/phoneExample.d.ts +17 -0
- package/lib/phone/phoneExample.d.ts.map +1 -0
- package/lib/phone/phoneExample.js +21 -0
- package/lib/phone/phoneExample.js.map +1 -0
- package/lib/phone/phoneNumber.d.ts +101 -0
- package/lib/phone/phoneNumber.d.ts.map +1 -0
- package/lib/phone/phoneNumber.js +158 -0
- package/lib/phone/phoneNumber.js.map +1 -0
- package/package.json +6 -1
- package/src/helpers/generateEnvConfigsBindings.test.ts +67 -0
- package/src/helpers/generateEnvConfigsBindings.ts +37 -6
- package/src/phone/index.ts +38 -0
- package/src/phone/phoneCountries.test.ts +96 -0
- package/src/phone/phoneCountries.ts +118 -0
- package/src/phone/phoneExample.test.ts +17 -0
- package/src/phone/phoneExample.ts +24 -0
- package/src/phone/phoneNumber.test.ts +242 -0
- package/src/phone/phoneNumber.ts +203 -0
package/README.md
CHANGED
|
@@ -15,8 +15,32 @@ pnpm add asma-core-helpers
|
|
|
15
15
|
```typescript
|
|
16
16
|
import { history, isAdcuris, getParamByName } from 'asma-core-helpers/lib'
|
|
17
17
|
import { ActorTypes, ActivityStatuses } from 'asma-core-helpers'
|
|
18
|
+
import { parsePhoneNr, toE164, isValidPhone } from 'asma-core-helpers/phone'
|
|
18
19
|
```
|
|
19
20
|
|
|
21
|
+
### The `phone` subpath
|
|
22
|
+
|
|
23
|
+
Phone numbers live behind their own entry point and are **never** re-exported from the
|
|
24
|
+
root barrel. The subpath carries `libphonenumber-js` and its metadata, so exporting it
|
|
25
|
+
from the barrel would put that weight into every consumer that only wanted an enum.
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { parsePhoneNr, toE164, isValidPhone, phoneTelHref } from 'asma-core-helpers/phone'
|
|
29
|
+
|
|
30
|
+
// One canonicaliser for every writer and the backfill, so runtime and migration agree.
|
|
31
|
+
// The region is an explicit input, applied where a value enters the system and only
|
|
32
|
+
// when the input carries no `+` — never an implicit `+47` prefix.
|
|
33
|
+
const parsed = parsePhoneNr('45456565', 'NO')
|
|
34
|
+
// → { ok: true, e164: '+4745456565', country: 'NO', callingCode: '47' }
|
|
35
|
+
|
|
36
|
+
// A value that is not a real number under that region is reported, never rewritten
|
|
37
|
+
// into something plausible.
|
|
38
|
+
parsePhoneNr('12345678', 'NO') // → { ok: false, reason: 'INVALID', input: '12345678' }
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The stored form is bare E.164 (`+4748012345`). The `tel:` scheme belongs to the render of
|
|
42
|
+
a click-to-call link and is produced by `phoneTelHref`, never written to a field.
|
|
43
|
+
|
|
20
44
|
## Features
|
|
21
45
|
|
|
22
46
|
- **Environment utilities**: Environment detection, URL helpers, domain utilities
|
|
@@ -25,6 +49,7 @@ import { ActorTypes, ActivityStatuses } from 'asma-core-helpers'
|
|
|
25
49
|
- **Type definitions**: Shared TypeScript types and enums
|
|
26
50
|
- **State management**: MST (MobX State Tree) helpers
|
|
27
51
|
- **Data utilities**: Validation, formatting, and transformation helpers
|
|
52
|
+
- **Phone numbers** (`/phone`): country-aware parsing, validation and E.164 canonicalisation
|
|
28
53
|
|
|
29
54
|
## Development
|
|
30
55
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateEnvConfigsBindings.d.ts","sourceRoot":"","sources":["../../src/helpers/generateEnvConfigsBindings.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAGzD,UAAU,SAAS;IACf,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAE/B,2BAA2B,CAAC,EAAE,OAAO,CAAA;IACrC,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,0BAA0B,CAAC,EAAE,OAAO,CAAA;IACpC,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,4BAA4B,CAAC,EAAE,MAAM,EAAE,CAAA;CAC1C;AAED,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAE5D,MAAM,MAAM,mBAAmB,GAAG,MAAM,gBAAgB,CAAA;AAExD,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,CAAC,GAAG,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAA;AAE7E,KAAK,OAAO,CAAC,CAAC,IAAI;KACb,CAAC,IAAI,MAAM,CAAC,IAAI,UAAU,CAAC,CAAC,GAAG,MAAM,EAAE,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC,GAAG,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAC1F,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"generateEnvConfigsBindings.d.ts","sourceRoot":"","sources":["../../src/helpers/generateEnvConfigsBindings.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAGzD,UAAU,SAA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BAAmB,EAAE,gBAAgB,CAAC,CACnD,GACG,MAAM,EACV,CAAC,EACH,WAAW,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,EAAE,aAAa,EAAE,CAAC,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,kBAAkB,CAAC,EAAE,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsE3F"}
|
|
@@ -4,17 +4,36 @@ import { EnvironmentsUrls1 } from './EnvironmentsUrls.js';
|
|
|
4
4
|
import { uuid4 } from './generateUUID4.js';
|
|
5
5
|
//type ISrvKeysTransformToWs<T> = T extends `SRV_${infer K}` ? `SRV_${K}_WS` : never
|
|
6
6
|
//type IKeyEnvironmentUrlsWs = `${IKeyEnvironmentUrls}_WS`
|
|
7
|
-
const EnvConfigsFnInstanceId = uuid4();
|
|
8
7
|
/**
|
|
9
8
|
*
|
|
10
9
|
* For internal use only (inside asma-helpers)
|
|
11
10
|
*/
|
|
12
11
|
export function EnvConfigsFnInternal() {
|
|
13
|
-
const
|
|
14
|
-
if (!
|
|
12
|
+
const reg = realWindow.__GENERATE_ENV_CONFIGS_BINDINGS__?.EnvConfigsFnReg;
|
|
13
|
+
if (!reg || Object.keys(reg).length === 0) {
|
|
15
14
|
throw new Error('EnvConfigsFn is not defined! please make sure that generateEnvConfigsBindings is called before EnvConfigsFn');
|
|
16
15
|
}
|
|
17
|
-
|
|
16
|
+
// Several apps can share this module instance (kernel-external builds register every
|
|
17
|
+
// app's EnvConfigsFn under its own key). Merge them so every service any registered
|
|
18
|
+
// app needs stays resolvable regardless of mount order: union of all keys, first
|
|
19
|
+
// registration wins on conflict (the host app mounts first and keeps its own values).
|
|
20
|
+
const merged = {};
|
|
21
|
+
for (const key of Object.keys(reg)) {
|
|
22
|
+
const fn = reg[key];
|
|
23
|
+
if (!fn) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const config = fn();
|
|
27
|
+
if (!config || typeof config !== 'object') {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
for (const [configKey, value] of Object.entries(config)) {
|
|
31
|
+
if (!(configKey in merged)) {
|
|
32
|
+
merged[configKey] = value;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return merged;
|
|
18
37
|
}
|
|
19
38
|
export function generateEnvConfigsBindings(envs_import, required_envs, static_env, adcuris_subdomains) {
|
|
20
39
|
let env_vars = {};
|
|
@@ -61,7 +80,12 @@ export function generateEnvConfigsBindings(envs_import, required_envs, static_en
|
|
|
61
80
|
*/
|
|
62
81
|
fetchConfigsReg: {},
|
|
63
82
|
};
|
|
64
|
-
|
|
83
|
+
// Key by a per-call id (NOT a module-level id): on a shared module instance every
|
|
84
|
+
// app's generateEnvConfigsBindings() call must register its own EnvConfigsFn instead
|
|
85
|
+
// of overwriting the previous app's (last-write-wins), which made services that only
|
|
86
|
+
// one app requires (e.g. SRV_PROXY) disappear for everyone else.
|
|
87
|
+
const envConfigsFnInstanceId = uuid4();
|
|
88
|
+
realWindow.__GENERATE_ENV_CONFIGS_BINDINGS__.EnvConfigsFnReg[envConfigsFnInstanceId] = EnvConfigsFn;
|
|
65
89
|
return { EnvConfigsFn };
|
|
66
90
|
}
|
|
67
91
|
//# sourceMappingURL=generateEnvConfigsBindings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateEnvConfigsBindings.js","sourceRoot":"","sources":["../../src/helpers/generateEnvConfigsBindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AA6B1C,oFAAoF;AAEpF,0DAA0D;AAE1D,MAAM,
|
|
1
|
+
{"version":3,"file":"generateEnvConfig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J,OAAO,CAAC,IAAI,CAAC,oBAAoB,GAAG,EAAE,CAAC,CAAA;gBAC3C,CAAC;YACL,CAAC;YAED,OAAO,GAAG,CAAA;QACd,CAAC,EAAE,UAAU,CAAC,CAAA;QAEd,UAAU,GAAG,EAAE,GAAG,UAAU,EAAE,GAAG,UAAU,EAAE,CAAA;QAE7C,OAAO,UAAU,CAAA;IACrB,CAAC;IAED,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAA;IAE7B,QAAQ,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,IAAI,EAAE,CAAA;IAElC,UAAU,CAAC,iCAAiC,GAAG,UAAU,CAAC,iCAAiC,IAAI;QAC3F,eAAe,EAAE,EAAE;QACnB;;WAEG;QACH,eAAe,EAAE,EAAE;KACtB,CAAA;IAED,kFAAkF;IAClF,qFAAqF;IACrF,qFAAqF;IACrF,iEAAiE;IACjE,MAAM,sBAAsB,GAAG,KAAK,EAAE,CAAA;IAEtC,UAAU,CAAC,iCAAiC,CAAC,eAAe,CAAC,sBAAsB,CAAC,GAAG,YAAY,CAAA;IAEnG,OAAO,EAAE,YAAY,EAAE,CAAA;AAC3B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Country-aware phone primitives for ASMA forms (ASMA-7485).
|
|
3
|
+
*
|
|
4
|
+
* Published as `asma-core-helpers/phone` and deliberately **not** re-exported from
|
|
5
|
+
* the root barrel: the root entry is what the ESM kernel bundles and serves to all
|
|
6
|
+
* 17 fleet apps, and `libphonenumber-js` has no business in that shared unit. As a
|
|
7
|
+
* subpath it is absent from `KERNEL_EXTERNAL_SPECIFIERS`, so it bundles into the two
|
|
8
|
+
* apps that actually render a phone field instead.
|
|
9
|
+
*
|
|
10
|
+
* @see asma-modules/_docs/adr/adr-g-0017-frontend-form-state-and-validation-ownership.md:49 — DEC-001, why the rules live here and not in asma-ui-core
|
|
11
|
+
*/
|
|
12
|
+
export { DEFAULT_PHONE_COUNTRY, findCountryByDialCode, getPhoneDialCode, listPhoneCountries, matchesPhoneCountry, type PhoneCountry, type PhoneCountryOption, } from './phoneCountries.js';
|
|
13
|
+
export { formatNationalAsYouType, formatPhoneForDisplay, isValidPhone, isValidPhoneValue, parsePhoneNr, parsePhoneValue, phoneTelHref, PHONE_MAX_DIGITS, PHONE_MIN_DIGITS, toE164, type ParsedPhone, type PhoneNrParse, } from './phoneNumber.js';
|
|
14
|
+
export { phoneExample } from './phoneExample.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/phone/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACH,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,YAAY,EACjB,KAAK,kBAAkB,GAC1B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACH,uBAAuB,EACvB,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,EACN,KAAK,WAAW,EAChB,KAAK,YAAY,GACpB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Country-aware phone primitives for ASMA forms (ASMA-7485).
|
|
3
|
+
*
|
|
4
|
+
* Published as `asma-core-helpers/phone` and deliberately **not** re-exported from
|
|
5
|
+
* the root barrel: the root entry is what the ESM kernel bundles and serves to all
|
|
6
|
+
* 17 fleet apps, and `libphonenumber-js` has no business in that shared unit. As a
|
|
7
|
+
* subpath it is absent from `KERNEL_EXTERNAL_SPECIFIERS`, so it bundles into the two
|
|
8
|
+
* apps that actually render a phone field instead.
|
|
9
|
+
*
|
|
10
|
+
* @see asma-modules/_docs/adr/adr-g-0017-frontend-form-state-and-validation-ownership.md:49 — DEC-001, why the rules live here and not in asma-ui-core
|
|
11
|
+
*/
|
|
12
|
+
export { DEFAULT_PHONE_COUNTRY, findCountryByDialCode, getPhoneDialCode, listPhoneCountries, matchesPhoneCountry, } from './phoneCountries.js';
|
|
13
|
+
export { formatNationalAsYouType, formatPhoneForDisplay, isValidPhone, isValidPhoneValue, parsePhoneNr, parsePhoneValue, phoneTelHref, PHONE_MAX_DIGITS, PHONE_MIN_DIGITS, toE164, } from './phoneNumber.js';
|
|
14
|
+
export { phoneExample } from './phoneExample.js';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/phone/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACH,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,GAGtB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACH,uBAAuB,EACvB,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,GAGT,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Country dial-code catalogue for the ASMA phone field (ASMA-7485).
|
|
3
|
+
*
|
|
4
|
+
* Country names come from the platform's own `Intl.DisplayNames` rather than a
|
|
5
|
+
* checked-in translation table, so every locale the browser knows is covered
|
|
6
|
+
* without shipping (or maintaining) 245 names per language.
|
|
7
|
+
*/
|
|
8
|
+
import type { CountryCode } from 'libphonenumber-js';
|
|
9
|
+
/** ISO 3166-1 alpha-2 code, narrowed to what the phone metadata actually supports. */
|
|
10
|
+
export type PhoneCountry = CountryCode;
|
|
11
|
+
/** Pre-selected country for every ASMA phone field — see ASMA-7485. */
|
|
12
|
+
export declare const DEFAULT_PHONE_COUNTRY: PhoneCountry;
|
|
13
|
+
export interface PhoneCountryOption {
|
|
14
|
+
iso2: PhoneCountry;
|
|
15
|
+
/** Calling code without the leading `+`, e.g. `'47'`. */
|
|
16
|
+
dialCode: string;
|
|
17
|
+
/** Country name in the requested locale, e.g. `'Norge'` / `'Norway'`. */
|
|
18
|
+
name: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Every supported country, sorted by localized name.
|
|
22
|
+
*
|
|
23
|
+
* Ordering of the *rendered* list (pinning the selected country first) belongs to
|
|
24
|
+
* the UI; this returns the stable alphabetical catalogue. Memoized per locale
|
|
25
|
+
* because the underlying `Intl.DisplayNames` lookup runs once per country.
|
|
26
|
+
*/
|
|
27
|
+
export declare function listPhoneCountries(locale: string): readonly PhoneCountryOption[];
|
|
28
|
+
export declare function getPhoneDialCode(iso2: PhoneCountry): string;
|
|
29
|
+
/**
|
|
30
|
+
* Search predicate for the country picker: matches on localized name **or** on the
|
|
31
|
+
* calling code, so both `"Norway"` and `"47"` narrow the list to +47 (ASMA-7485).
|
|
32
|
+
*
|
|
33
|
+
* A leading `+` in the query is ignored so pasting `+47` works.
|
|
34
|
+
*/
|
|
35
|
+
export declare function matchesPhoneCountry(option: PhoneCountryOption, query: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* The country owning the longest calling-code prefix of `digits`.
|
|
38
|
+
*
|
|
39
|
+
* Longest-prefix rather than first-match because calling codes are not prefix-free
|
|
40
|
+
* (`+1` vs `+7`, `+47` vs `+473`), and main-country-wins because 25 countries share
|
|
41
|
+
* `+1` — a plain scan resolves every North-American number to Antigua.
|
|
42
|
+
*/
|
|
43
|
+
export declare function findCountryByDialCode(digits: string): PhoneCountry | undefined;
|
|
44
|
+
//# sourceMappingURL=phoneCountries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phoneCountries.d.ts","sourceRoot":"","sources":["../../src/phone/phoneCountries.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD,sFAAsF;AACtF,MAAM,MAAM,YAAY,GAAG,WAAW,CAAA;AAEtC,uEAAuE;AACvE,eAAO,MAAM,qBAAqB,EAAE,YAAmB,CAAA;AAEvD,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,YAAY,CAAA;IAClB,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAA;IAChB,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAA;CACf;AAUD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,kBAAkB,EAAE,CAiBhF;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAQtF;AA0BD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAO9E"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Country dial-code catalogue for the ASMA phone field (ASMA-7485).
|
|
3
|
+
*
|
|
4
|
+
* Country names come from the platform's own `Intl.DisplayNames` rather than a
|
|
5
|
+
* checked-in translation table, so every locale the browser knows is covered
|
|
6
|
+
* without shipping (or maintaining) 245 names per language.
|
|
7
|
+
*/
|
|
8
|
+
import { getCountries, getCountryCallingCode, isSupportedCountry, Metadata } from 'libphonenumber-js';
|
|
9
|
+
/** Pre-selected country for every ASMA phone field — see ASMA-7485. */
|
|
10
|
+
export const DEFAULT_PHONE_COUNTRY = 'NO';
|
|
11
|
+
const optionsByLocale = new Map();
|
|
12
|
+
function countryName(iso2, displayNames) {
|
|
13
|
+
// `of` returns undefined for codes the ICU data does not know; the code itself
|
|
14
|
+
// is a better fallback than an empty row.
|
|
15
|
+
return displayNames.of(iso2) ?? iso2;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Every supported country, sorted by localized name.
|
|
19
|
+
*
|
|
20
|
+
* Ordering of the *rendered* list (pinning the selected country first) belongs to
|
|
21
|
+
* the UI; this returns the stable alphabetical catalogue. Memoized per locale
|
|
22
|
+
* because the underlying `Intl.DisplayNames` lookup runs once per country.
|
|
23
|
+
*/
|
|
24
|
+
export function listPhoneCountries(locale) {
|
|
25
|
+
const cached = optionsByLocale.get(locale);
|
|
26
|
+
if (cached !== undefined)
|
|
27
|
+
return cached;
|
|
28
|
+
const displayNames = new Intl.DisplayNames([locale], { type: 'region' });
|
|
29
|
+
const collator = new Intl.Collator(locale);
|
|
30
|
+
const options = getCountries()
|
|
31
|
+
.map((iso2) => ({
|
|
32
|
+
iso2,
|
|
33
|
+
dialCode: getCountryCallingCode(iso2),
|
|
34
|
+
name: countryName(iso2, displayNames),
|
|
35
|
+
}))
|
|
36
|
+
.sort((left, right) => collator.compare(left.name, right.name));
|
|
37
|
+
optionsByLocale.set(locale, options);
|
|
38
|
+
return options;
|
|
39
|
+
}
|
|
40
|
+
export function getPhoneDialCode(iso2) {
|
|
41
|
+
return getCountryCallingCode(iso2);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Search predicate for the country picker: matches on localized name **or** on the
|
|
45
|
+
* calling code, so both `"Norway"` and `"47"` narrow the list to +47 (ASMA-7485).
|
|
46
|
+
*
|
|
47
|
+
* A leading `+` in the query is ignored so pasting `+47` works.
|
|
48
|
+
*/
|
|
49
|
+
export function matchesPhoneCountry(option, query) {
|
|
50
|
+
const trimmed = query.trim();
|
|
51
|
+
if (trimmed.length === 0)
|
|
52
|
+
return true;
|
|
53
|
+
if (option.name.toLocaleLowerCase().includes(trimmed.toLocaleLowerCase()))
|
|
54
|
+
return true;
|
|
55
|
+
const digits = trimmed.replace(/^\+/, '').replace(/\D/g, '');
|
|
56
|
+
return digits.length > 0 && option.dialCode.startsWith(digits);
|
|
57
|
+
}
|
|
58
|
+
/** Calling codes are at most three digits in the E.164 plan. */
|
|
59
|
+
const MAX_CALLING_CODE_LENGTH = 3;
|
|
60
|
+
/**
|
|
61
|
+
* The primary country for a calling code — `'1'` → `US`, not whichever NANP
|
|
62
|
+
* territory happens to sort first. The metadata index lists the main country first.
|
|
63
|
+
*/
|
|
64
|
+
function mainCountryForCallingCode(callingCode) {
|
|
65
|
+
const index = new Metadata();
|
|
66
|
+
const candidate = index.getCountryCodesForCallingCode?.(callingCode)?.[0];
|
|
67
|
+
return candidate !== undefined && isSupportedCountry(candidate) ? candidate : undefined;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The country owning the longest calling-code prefix of `digits`.
|
|
71
|
+
*
|
|
72
|
+
* Longest-prefix rather than first-match because calling codes are not prefix-free
|
|
73
|
+
* (`+1` vs `+7`, `+47` vs `+473`), and main-country-wins because 25 countries share
|
|
74
|
+
* `+1` — a plain scan resolves every North-American number to Antigua.
|
|
75
|
+
*/
|
|
76
|
+
export function findCountryByDialCode(digits) {
|
|
77
|
+
for (let length = Math.min(MAX_CALLING_CODE_LENGTH, digits.length); length >= 1; length -= 1) {
|
|
78
|
+
const country = mainCountryForCallingCode(digits.slice(0, length));
|
|
79
|
+
if (country !== undefined)
|
|
80
|
+
return country;
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=phoneCountries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phoneCountries.js","sourceRoot":"","sources":["../../src/phone/phoneCountries.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAA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O,KAAK,SAAS;YAAE,OAAO,OAAO,CAAA;IAC7C,CAAC;IAED,OAAO,SAAS,CAAA;AACpB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example numbers for the actionable half of a validation message (ADR-0017 REQ-003:
|
|
3
|
+
* "what's wrong — how to fix"), e.g. `errorWithHint(msgs.invalid_phone, phoneExample('NO'))`
|
|
4
|
+
* → `'Invalid phone — Ex: +47 40 61 23 45'`.
|
|
5
|
+
*
|
|
6
|
+
* Kept in its own module so consumers that only format or validate do not pull the
|
|
7
|
+
* example metadata (~1.4 kB gz) into their bundle.
|
|
8
|
+
*/
|
|
9
|
+
import type { PhoneCountry } from './phoneCountries.js';
|
|
10
|
+
/**
|
|
11
|
+
* A representative mobile number for the country, in international form.
|
|
12
|
+
*
|
|
13
|
+
* Falls back to the bare dial code for the handful of territories that have no
|
|
14
|
+
* example in the metadata, so the hint is never an empty string.
|
|
15
|
+
*/
|
|
16
|
+
export declare function phoneExample(iso2: PhoneCountry): string;
|
|
17
|
+
//# sourceMappingURL=phoneExample.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phoneExample.d.ts","sourceRoot":"","sources":["../../src/phone/phoneExample.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAEvD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example numbers for the actionable half of a validation message (ADR-0017 REQ-003:
|
|
3
|
+
* "what's wrong — how to fix"), e.g. `errorWithHint(msgs.invalid_phone, phoneExample('NO'))`
|
|
4
|
+
* → `'Invalid phone — Ex: +47 40 61 23 45'`.
|
|
5
|
+
*
|
|
6
|
+
* Kept in its own module so consumers that only format or validate do not pull the
|
|
7
|
+
* example metadata (~1.4 kB gz) into their bundle.
|
|
8
|
+
*/
|
|
9
|
+
import { getExampleNumber } from 'libphonenumber-js';
|
|
10
|
+
import examples from 'libphonenumber-js/examples.mobile.json';
|
|
11
|
+
import { getPhoneDialCode } from './phoneCountries.js';
|
|
12
|
+
/**
|
|
13
|
+
* A representative mobile number for the country, in international form.
|
|
14
|
+
*
|
|
15
|
+
* Falls back to the bare dial code for the handful of territories that have no
|
|
16
|
+
* example in the metadata, so the hint is never an empty string.
|
|
17
|
+
*/
|
|
18
|
+
export function phoneExample(iso2) {
|
|
19
|
+
return getExampleNumber(iso2, examples)?.formatInternational() ?? `+${getPhoneDialCode(iso2)}`;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=phoneExample.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phoneExample.js","sourceRoot":"","sources":["../../src/phone/phoneExample.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,QAAQ,MAAM,wCAAwC,CAAA;AAE7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAGtD;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAkB;IAC3C,OAAO,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,mBAAmB,EAAE,IAAI,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAA;AAClG,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phone-number formatting, parsing and validation for ASMA forms (ASMA-7485).
|
|
3
|
+
*
|
|
4
|
+
* The stored form is bare E.164 (`+4748012345`) — digits and a leading `+`, no
|
|
5
|
+
* spaces, no `tel:`. The `tel:` scheme belongs to the render of a click-to-call
|
|
6
|
+
* link and is produced by `phoneTelHref`, never written to a field.
|
|
7
|
+
*/
|
|
8
|
+
import type { PhoneCountry } from './phoneCountries.js';
|
|
9
|
+
/** Shortest and longest national significant number in the E.164 plan. */
|
|
10
|
+
export declare const PHONE_MIN_DIGITS = 4;
|
|
11
|
+
export declare const PHONE_MAX_DIGITS = 15;
|
|
12
|
+
export interface ParsedPhone {
|
|
13
|
+
iso2: PhoneCountry;
|
|
14
|
+
/** National significant number, digits only — no dial code, no separators. */
|
|
15
|
+
national: string;
|
|
16
|
+
}
|
|
17
|
+
export type PhoneNrParse = {
|
|
18
|
+
ok: true;
|
|
19
|
+
e164: string;
|
|
20
|
+
country: PhoneCountry | undefined;
|
|
21
|
+
callingCode: string;
|
|
22
|
+
} | {
|
|
23
|
+
ok: false;
|
|
24
|
+
reason: 'EMPTY' | 'INVALID';
|
|
25
|
+
input: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Canonicalise a value of unknown shape into E.164 — the one function every writer and
|
|
29
|
+
* the backfill share, so runtime and migration agree byte for byte.
|
|
30
|
+
*
|
|
31
|
+
* `defaultRegion` is required rather than defaulted on purpose. Guessing a region at
|
|
32
|
+
* *read* time, repeatedly and implicitly, is what left the fleet with several
|
|
33
|
+
* `+47`-assuming normalizers that disagree; the region is an explicit input applied
|
|
34
|
+
* once, where a value enters the system, and only when the input carries no `+`.
|
|
35
|
+
*
|
|
36
|
+
* Returns a result rather than throwing or coercing: a value that is not a real number
|
|
37
|
+
* under that region — junk like `'12345678'`, or a Swedish national number stored bare
|
|
38
|
+
* in a Norwegian tenant — is unrecoverable by any algorithm and must be reported to a
|
|
39
|
+
* human, never rewritten into something plausible.
|
|
40
|
+
*/
|
|
41
|
+
export declare function parsePhoneNr(input: string | null | undefined, defaultRegion: PhoneCountry): PhoneNrParse;
|
|
42
|
+
/**
|
|
43
|
+
* Split a stored value into the country and the national number the field edits.
|
|
44
|
+
*
|
|
45
|
+
* Three shapes reach this function:
|
|
46
|
+
* - E.164 (`'+4748012345'`) — the format this ticket introduces;
|
|
47
|
+
* - a bare national number (`'48012345'`) — every record written before it, which
|
|
48
|
+
* is why `fallbackIso2` exists rather than the value being rejected;
|
|
49
|
+
* - a partially typed `+47…`, which `parsePhoneNumberFromString` cannot parse yet
|
|
50
|
+
* and which therefore falls through to the longest-dial-code match.
|
|
51
|
+
*/
|
|
52
|
+
export declare function parsePhoneValue(value: string | null | undefined, fallbackIso2?: PhoneCountry): ParsedPhone;
|
|
53
|
+
/**
|
|
54
|
+
* Compose the stored value from the country and whatever the user typed.
|
|
55
|
+
*
|
|
56
|
+
* Two branches, and the split is the point. Once the input is a real number for the
|
|
57
|
+
* country, the stored value is the library's own E.164 rendering, which drops what a
|
|
58
|
+
* plain `+dialCode + digits` concatenation would double: a trunk prefix (`0701234567`
|
|
59
|
+
* for SE), a redundant country code (`4748012345` for NO) or an IDD prefix
|
|
60
|
+
* (`004748012345`). Concatenating those produced `+460701234567` and `+474748012345`.
|
|
61
|
+
*
|
|
62
|
+
* Until then it falls back to concatenation, because an in-progress number must still
|
|
63
|
+
* round-trip through the store for the field to show it back — so this deliberately
|
|
64
|
+
* does not reject anything. Use `isValidPhone` for the save gate. Returns `''` for an
|
|
65
|
+
* empty national part so an untouched field stores nothing rather than a bare `'+47'`.
|
|
66
|
+
*/
|
|
67
|
+
export declare function toE164(nationalInput: string, iso2: PhoneCountry): string;
|
|
68
|
+
/**
|
|
69
|
+
* Progressive per-country grouping for the input mask, e.g. `'48012345'` → `'48 01 23 45'`
|
|
70
|
+
* for NO, `'70 123 45 67'` for SE and `'213 373 4253'` for US.
|
|
71
|
+
*
|
|
72
|
+
* Groups by the country's **international** format rather than its national one, and
|
|
73
|
+
* the difference is not cosmetic: countries with a trunk prefix (SE, GB, DE, FR) define
|
|
74
|
+
* their national formats *with* the leading `0`, so feeding the bare national number to
|
|
75
|
+
* `AsYouType(iso2)` returns it unformatted. The field edits the national part while the
|
|
76
|
+
* selector carries the country code, which is exactly the international shape.
|
|
77
|
+
*
|
|
78
|
+
* Grouping therefore follows each country's official format — for Norwegian numbers
|
|
79
|
+
* `xx xx xx xx`, not the `### ## ###` the legacy `NORWEGIAN_PHONE_NUMBER` constant
|
|
80
|
+
* hardcoded for every Norwegian number regardless of its prefix.
|
|
81
|
+
*/
|
|
82
|
+
export declare function formatNationalAsYouType(nationalInput: string, iso2: PhoneCountry): string;
|
|
83
|
+
/**
|
|
84
|
+
* Whether the national number is a real, dialable number for the country —
|
|
85
|
+
* a per-country pattern check, not a digit count. `'00000000'` and `'12345678'`
|
|
86
|
+
* are both rejected for NO, `'48012345'` is accepted.
|
|
87
|
+
*/
|
|
88
|
+
export declare function isValidPhone(nationalInput: string, iso2: PhoneCountry): boolean;
|
|
89
|
+
/** Whether a stored value is a valid number, resolving its country from the value itself. */
|
|
90
|
+
export declare function isValidPhoneValue(value: string | null | undefined, fallbackIso2?: PhoneCountry): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Human-readable international form for read-only views, e.g. `'+47 48 01 23 45'`.
|
|
93
|
+
* Falls back to the raw value so an unparseable legacy record still renders.
|
|
94
|
+
*/
|
|
95
|
+
export declare function formatPhoneForDisplay(value: string | null | undefined, fallbackIso2?: PhoneCountry): string;
|
|
96
|
+
/**
|
|
97
|
+
* `tel:` URI for a click-to-call link — the single place the scheme is added (ASMA-7485).
|
|
98
|
+
* Returns `''` when there is nothing to dial, so callers can skip rendering the link.
|
|
99
|
+
*/
|
|
100
|
+
export declare function phoneTelHref(value: string | null | undefined, fallbackIso2?: PhoneCountry): string;
|
|
101
|
+
//# sourceMappingURL=phoneNumber.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phoneNumber.d.ts","sourceRoot":"","sources":["../../src/phone/phoneNumber.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,IAAI,CAAA;AACjC,eAAO,MAAM,gBAAgB,KAAK,CAAA;AAElC,MAAM,WAAW,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AAED;;;GAGG;AACH,wBAAgB,YAAY,CACxB,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,YAAY,GAAE,YAAoC,GACnD,MAAM,CAKR"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phone-number formatting, parsing and validation for ASMA forms (ASMA-7485).
|
|
3
|
+
*
|
|
4
|
+
* The stored form is bare E.164 (`+4748012345`) — digits and a leading `+`, no
|
|
5
|
+
* spaces, no `tel:`. The `tel:` scheme belongs to the render of a click-to-call
|
|
6
|
+
* link and is produced by `phoneTelHref`, never written to a field.
|
|
7
|
+
*/
|
|
8
|
+
import { AsYouType, isValidPhoneNumber, parsePhoneNumberFromString, parsePhoneNumberWithError, } from 'libphonenumber-js';
|
|
9
|
+
import { DEFAULT_PHONE_COUNTRY, findCountryByDialCode, getPhoneDialCode } from './phoneCountries.js';
|
|
10
|
+
/** Shortest and longest national significant number in the E.164 plan. */
|
|
11
|
+
export const PHONE_MIN_DIGITS = 4;
|
|
12
|
+
export const PHONE_MAX_DIGITS = 15;
|
|
13
|
+
const digitsOnly = (value) => value.replace(/\D/g, '');
|
|
14
|
+
/**
|
|
15
|
+
* Canonicalise a value of unknown shape into E.164 — the one function every writer and
|
|
16
|
+
* the backfill share, so runtime and migration agree byte for byte.
|
|
17
|
+
*
|
|
18
|
+
* `defaultRegion` is required rather than defaulted on purpose. Guessing a region at
|
|
19
|
+
* *read* time, repeatedly and implicitly, is what left the fleet with several
|
|
20
|
+
* `+47`-assuming normalizers that disagree; the region is an explicit input applied
|
|
21
|
+
* once, where a value enters the system, and only when the input carries no `+`.
|
|
22
|
+
*
|
|
23
|
+
* Returns a result rather than throwing or coercing: a value that is not a real number
|
|
24
|
+
* under that region — junk like `'12345678'`, or a Swedish national number stored bare
|
|
25
|
+
* in a Norwegian tenant — is unrecoverable by any algorithm and must be reported to a
|
|
26
|
+
* human, never rewritten into something plausible.
|
|
27
|
+
*/
|
|
28
|
+
export function parsePhoneNr(input, defaultRegion) {
|
|
29
|
+
const text = (input ?? '').trim();
|
|
30
|
+
if (text.length === 0)
|
|
31
|
+
return { ok: false, reason: 'EMPTY', input: text };
|
|
32
|
+
try {
|
|
33
|
+
const parsed = parsePhoneNumberWithError(text, defaultRegion);
|
|
34
|
+
if (!parsed.isValid())
|
|
35
|
+
return { ok: false, reason: 'INVALID', input: text };
|
|
36
|
+
return { ok: true, e164: parsed.number, country: parsed.country, callingCode: parsed.countryCallingCode };
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return { ok: false, reason: 'INVALID', input: text };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Split a stored value into the country and the national number the field edits.
|
|
44
|
+
*
|
|
45
|
+
* Three shapes reach this function:
|
|
46
|
+
* - E.164 (`'+4748012345'`) — the format this ticket introduces;
|
|
47
|
+
* - a bare national number (`'48012345'`) — every record written before it, which
|
|
48
|
+
* is why `fallbackIso2` exists rather than the value being rejected;
|
|
49
|
+
* - a partially typed `+47…`, which `parsePhoneNumberFromString` cannot parse yet
|
|
50
|
+
* and which therefore falls through to the longest-dial-code match.
|
|
51
|
+
*/
|
|
52
|
+
export function parsePhoneValue(value, fallbackIso2 = DEFAULT_PHONE_COUNTRY) {
|
|
53
|
+
const trimmed = (value ?? '').trim();
|
|
54
|
+
if (trimmed.length === 0)
|
|
55
|
+
return { iso2: fallbackIso2, national: '' };
|
|
56
|
+
if (!trimmed.startsWith('+')) {
|
|
57
|
+
return { iso2: fallbackIso2, national: digitsOnly(trimmed) };
|
|
58
|
+
}
|
|
59
|
+
const parsed = parsePhoneNumberFromString(trimmed);
|
|
60
|
+
if (parsed?.country !== undefined) {
|
|
61
|
+
return { iso2: parsed.country, national: parsed.nationalNumber };
|
|
62
|
+
}
|
|
63
|
+
const digits = digitsOnly(trimmed);
|
|
64
|
+
// Keep the country the caller already holds when the digits still agree with it,
|
|
65
|
+
// so typing `+47…` one character at a time never reassigns the user's selection
|
|
66
|
+
// to another country sharing the prefix.
|
|
67
|
+
const fallbackDialCode = getPhoneDialCode(fallbackIso2);
|
|
68
|
+
if (digits.startsWith(fallbackDialCode)) {
|
|
69
|
+
return { iso2: fallbackIso2, national: digits.slice(fallbackDialCode.length) };
|
|
70
|
+
}
|
|
71
|
+
const iso2 = findCountryByDialCode(digits);
|
|
72
|
+
if (iso2 === undefined)
|
|
73
|
+
return { iso2: fallbackIso2, national: digits };
|
|
74
|
+
return { iso2, national: digits.slice(getPhoneDialCode(iso2).length) };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Compose the stored value from the country and whatever the user typed.
|
|
78
|
+
*
|
|
79
|
+
* Two branches, and the split is the point. Once the input is a real number for the
|
|
80
|
+
* country, the stored value is the library's own E.164 rendering, which drops what a
|
|
81
|
+
* plain `+dialCode + digits` concatenation would double: a trunk prefix (`0701234567`
|
|
82
|
+
* for SE), a redundant country code (`4748012345` for NO) or an IDD prefix
|
|
83
|
+
* (`004748012345`). Concatenating those produced `+460701234567` and `+474748012345`.
|
|
84
|
+
*
|
|
85
|
+
* Until then it falls back to concatenation, because an in-progress number must still
|
|
86
|
+
* round-trip through the store for the field to show it back — so this deliberately
|
|
87
|
+
* does not reject anything. Use `isValidPhone` for the save gate. Returns `''` for an
|
|
88
|
+
* empty national part so an untouched field stores nothing rather than a bare `'+47'`.
|
|
89
|
+
*/
|
|
90
|
+
export function toE164(nationalInput, iso2) {
|
|
91
|
+
const digits = digitsOnly(nationalInput);
|
|
92
|
+
if (digits.length === 0)
|
|
93
|
+
return '';
|
|
94
|
+
const parsed = parsePhoneNumberFromString(digits, iso2);
|
|
95
|
+
if (parsed?.isValid() === true)
|
|
96
|
+
return parsed.number;
|
|
97
|
+
return `+${getPhoneDialCode(iso2)}${digits}`;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Progressive per-country grouping for the input mask, e.g. `'48012345'` → `'48 01 23 45'`
|
|
101
|
+
* for NO, `'70 123 45 67'` for SE and `'213 373 4253'` for US.
|
|
102
|
+
*
|
|
103
|
+
* Groups by the country's **international** format rather than its national one, and
|
|
104
|
+
* the difference is not cosmetic: countries with a trunk prefix (SE, GB, DE, FR) define
|
|
105
|
+
* their national formats *with* the leading `0`, so feeding the bare national number to
|
|
106
|
+
* `AsYouType(iso2)` returns it unformatted. The field edits the national part while the
|
|
107
|
+
* selector carries the country code, which is exactly the international shape.
|
|
108
|
+
*
|
|
109
|
+
* Grouping therefore follows each country's official format — for Norwegian numbers
|
|
110
|
+
* `xx xx xx xx`, not the `### ## ###` the legacy `NORWEGIAN_PHONE_NUMBER` constant
|
|
111
|
+
* hardcoded for every Norwegian number regardless of its prefix.
|
|
112
|
+
*/
|
|
113
|
+
export function formatNationalAsYouType(nationalInput, iso2) {
|
|
114
|
+
const digits = digitsOnly(nationalInput);
|
|
115
|
+
if (digits.length === 0)
|
|
116
|
+
return '';
|
|
117
|
+
const dialCode = `+${getPhoneDialCode(iso2)}`;
|
|
118
|
+
const formatted = new AsYouType().input(`${dialCode}${digits}`);
|
|
119
|
+
return formatted.startsWith(dialCode) ? formatted.slice(dialCode.length).trimStart() : formatted;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Whether the national number is a real, dialable number for the country —
|
|
123
|
+
* a per-country pattern check, not a digit count. `'00000000'` and `'12345678'`
|
|
124
|
+
* are both rejected for NO, `'48012345'` is accepted.
|
|
125
|
+
*/
|
|
126
|
+
export function isValidPhone(nationalInput, iso2) {
|
|
127
|
+
const digits = digitsOnly(nationalInput);
|
|
128
|
+
if (digits.length < PHONE_MIN_DIGITS || digits.length > PHONE_MAX_DIGITS)
|
|
129
|
+
return false;
|
|
130
|
+
return isValidPhoneNumber(digits, iso2);
|
|
131
|
+
}
|
|
132
|
+
/** Whether a stored value is a valid number, resolving its country from the value itself. */
|
|
133
|
+
export function isValidPhoneValue(value, fallbackIso2 = DEFAULT_PHONE_COUNTRY) {
|
|
134
|
+
const { iso2, national } = parsePhoneValue(value, fallbackIso2);
|
|
135
|
+
return isValidPhone(national, iso2);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Human-readable international form for read-only views, e.g. `'+47 48 01 23 45'`.
|
|
139
|
+
* Falls back to the raw value so an unparseable legacy record still renders.
|
|
140
|
+
*/
|
|
141
|
+
export function formatPhoneForDisplay(value, fallbackIso2 = DEFAULT_PHONE_COUNTRY) {
|
|
142
|
+
const trimmed = (value ?? '').trim();
|
|
143
|
+
if (trimmed.length === 0)
|
|
144
|
+
return '';
|
|
145
|
+
const { iso2, national } = parsePhoneValue(trimmed, fallbackIso2);
|
|
146
|
+
const parsed = parsePhoneNumberFromString(toE164(national, iso2));
|
|
147
|
+
return parsed?.formatInternational() ?? trimmed;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* `tel:` URI for a click-to-call link — the single place the scheme is added (ASMA-7485).
|
|
151
|
+
* Returns `''` when there is nothing to dial, so callers can skip rendering the link.
|
|
152
|
+
*/
|
|
153
|
+
export function phoneTelHref(value, fallbackIso2 = DEFAULT_PHONE_COUNTRY) {
|
|
154
|
+
const { iso2, national } = parsePhoneValue(value, fallbackIso2);
|
|
155
|
+
const e164 = toE164(national, iso2);
|
|
156
|
+
return e164.length === 0 ? '' : `tel:${e164}`;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=phoneNumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phoneNumber.js","sourceRoot":"","sources":["../../src/phone/phoneNumber.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACH,SAAS,EACT,kBAAkB,EAClB,0BAA0B,EAC1B,yBAAyB,GAC5B,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAGpG,0EAA0E;AAC1E,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAA;AACjC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