@webority-technologies/mobile-core 0.0.10 → 0.0.12

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.
@@ -195,6 +195,12 @@ Object.defineProperty(exports, "isValidPhoneNumber", {
195
195
  return _phone.isValidPhoneNumber;
196
196
  }
197
197
  });
198
+ Object.defineProperty(exports, "maxNationalNumberLength", {
199
+ enumerable: true,
200
+ get: function () {
201
+ return _phone.maxNationalNumberLength;
202
+ }
203
+ });
198
204
  Object.defineProperty(exports, "normalizePhone", {
199
205
  enumerable: true,
200
206
  get: function () {
@@ -38,7 +38,7 @@ Object.defineProperty(exports, "isValidPhoneNumber", {
38
38
  return _max.isValidPhoneNumber;
39
39
  }
40
40
  });
41
- exports.normalizePhone = void 0;
41
+ exports.normalizePhone = exports.maxNationalNumberLength = void 0;
42
42
  Object.defineProperty(exports, "parsePhoneNumber", {
43
43
  enumerable: true,
44
44
  get: function () {
@@ -58,7 +58,10 @@ Object.defineProperty(exports, "validatePhoneNumberLength", {
58
58
  return _max.validatePhoneNumberLength;
59
59
  }
60
60
  });
61
+ var _core = require("libphonenumber-js/core");
61
62
  var _max = require("libphonenumber-js/max");
63
+ var _metadataMax = _interopRequireDefault(require("libphonenumber-js/metadata.max.json"));
64
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
62
65
  /**
63
66
  * The bare 'libphonenumber-js' entry point actually resolves to the library's
64
67
  * OWN slimmed-down min/ metadata internally, not its full data - './max' is
@@ -67,6 +70,10 @@ var _max = require("libphonenumber-js/max");
67
70
  * variant wins throughout this file, not just for validation.
68
71
  */
69
72
 
73
+ // `Metadata` comes from the core entry with the max data passed in by hand:
74
+ // the max entry exports it in its ESM build only, and the CommonJS build jest
75
+ // and node resolve has no `Metadata` at all (libphonenumber-js 1.13.12).
76
+
70
77
  /**
71
78
  * Re-exported under our own name rather than importing CountryCode directly
72
79
  * everywhere, so a future need to diverge (or re-narrow) has one place to do
@@ -230,8 +237,9 @@ const splitPhoneNumber = (input, defaultCountry) => {
230
237
  * allows, so a field stops accepting the impossible without a per-country
231
238
  * length table. This is the PLAN's ceiling, not a mobile number's: India runs
232
239
  * to 13 digits (toll-free 1800 numbers), the US to 10, Germany to 15. A field
233
- * that wants a hard stop at the mobile length sets its own `maxLength`. Digits
234
- * within range, including a number still too short, pass through untouched.
240
+ * that should stop where a subscriber's number ends asks
241
+ * `maxNationalNumberLength` instead. Digits within range, including a number
242
+ * still too short, pass through untouched.
235
243
  */
236
244
  exports.splitPhoneNumber = splitPhoneNumber;
237
245
  const clampNationalNumber = (nationalDigits, country) => {
@@ -242,6 +250,41 @@ const clampNationalNumber = (nationalDigits, country) => {
242
250
  return digits;
243
251
  };
244
252
 
253
+ // The number types a person types into a phone field. Toll-free, premium,
254
+ // shared-cost and pager ranges are what push a plan's ceiling past them.
255
+ exports.clampNationalNumber = clampNationalNumber;
256
+ const SUBSCRIBER_TYPES = {
257
+ any: ['MOBILE', 'FIXED_LINE'],
258
+ mobile: ['MOBILE']
259
+ };
260
+
261
+ // libphonenumber-js types `numberingPlan` without its per-type accessor; the
262
+ // runtime object has it, and a type with no lengths of its own answers with the
263
+ // plan's.
264
+
265
+ /**
266
+ * The most national digits a subscriber's number can have in a country, so a
267
+ * field can refuse the next digit as it is typed rather than trimming after.
268
+ * `'any'` (default) covers mobile and fixed lines, `'mobile'` mobiles only: India
269
+ * is 10 either way (its plan's 13 belongs to toll-free numbers), Germany is 15
270
+ * for `'any'` and 11 for `'mobile'`, the UAE 9. A country whose metadata lists
271
+ * no lengths by type falls back to the plan's longest number.
272
+ */
273
+ const maxNationalNumberLength = (country, kind = 'any') => {
274
+ const metadata = new _core.Metadata(_metadataMax.default);
275
+ metadata.selectNumberingPlan(country);
276
+ const plan = metadata.numberingPlan;
277
+ if (!plan) {
278
+ return E164_MAX_NATIONAL_DIGITS;
279
+ }
280
+ const byType = SUBSCRIBER_TYPES[kind].flatMap(type => plan.type(type)?.possibleLengths() ?? []);
281
+ return Math.max(...(byType.length > 0 ? byType : plan.possibleLengths()));
282
+ };
283
+
284
+ // E.164 allows 15 digits in total; a national number can never exceed it.
285
+ exports.maxNationalNumberLength = maxNationalNumberLength;
286
+ const E164_MAX_NATIONAL_DIGITS = 15;
287
+
245
288
  /**
246
289
  * National digits grouped the way the country writes them, updated on every
247
290
  * keystroke: `'98765'` for IN is `'98765'`, `'9876543210'` is `'98765 43210'`,
@@ -250,14 +293,25 @@ const clampNationalNumber = (nationalDigits, country) => {
250
293
  * number are dropped first, so an overflowing paste never formats as a longer
251
294
  * number; digits that fit no pattern come back ungrouped rather than forced
252
295
  * into a shape.
296
+ *
297
+ * Countries that write a leading 0 (the UAE, the UK, Australia, Saudi Arabia)
298
+ * only group in national mode when that 0 is typed, and a value never holds
299
+ * it. When national mode hands the digits back untouched, the grouping comes
300
+ * from the international form with the calling code removed: `'501234567'`
301
+ * for AE is `'50 123 4567'`. Countries that group nationally are unaffected.
253
302
  */
254
- exports.clampNationalNumber = clampNationalNumber;
255
303
  const formatPhoneAsTyped = (nationalDigits, country) => {
256
304
  const digits = clampNationalNumber(nationalDigits, country);
257
305
  if (!digits) {
258
306
  return '';
259
307
  }
260
- return new _max.AsYouType(country).input(digits);
308
+ const national = new _max.AsYouType(country).input(digits);
309
+ if (national !== digits) {
310
+ return national;
311
+ }
312
+ const prefix = `+${(0, _max.getCountryCallingCode)(country)}`;
313
+ const international = new _max.AsYouType().input(`${prefix}${digits}`);
314
+ return international.startsWith(prefix) ? international.slice(prefix.length).trimStart() || digits : digits;
261
315
  };
262
316
 
263
317
  /**
@@ -459,6 +459,12 @@ Object.defineProperty(exports, "maxLength", {
459
459
  return _index7.maxLength;
460
460
  }
461
461
  });
462
+ Object.defineProperty(exports, "maxNationalNumberLength", {
463
+ enumerable: true,
464
+ get: function () {
465
+ return _index3.maxNationalNumberLength;
466
+ }
467
+ });
462
468
  Object.defineProperty(exports, "minLength", {
463
469
  enumerable: true,
464
470
  get: function () {
@@ -5,5 +5,5 @@ export { formatDate, formatDateTime, formatRelativeTime, formatTime } from "./da
5
5
  export { addDays, diffMs, formatDateDDMMMYYYY, formatDateISO, formatDatePattern, formatTime12h, formatTimeInWindowsZone, formatTimeInZone, isDateAfter, isDateBefore, isSameDay, startOfDay } from "./dateMath.js";
6
6
  export { getInitials } from "./initials.js";
7
7
  export { formatCompactNumber, formatNumber, formatPercent } from "./number.js";
8
- export { AsYouType, clampNationalNumber, countryFlagEmoji, detectPhoneCountry, formatPhone, formatPhoneAsTyped, getCountries, getCountryCallingCode, getPhoneCountries, isSupportedCountry, isValidNationalNumber, isValidPhoneNumber, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, splitPhoneNumber, validatePhoneNumberLength } from "./phone.js";
8
+ export { AsYouType, clampNationalNumber, countryFlagEmoji, detectPhoneCountry, formatPhone, formatPhoneAsTyped, getCountries, getCountryCallingCode, getPhoneCountries, isSupportedCountry, isValidNationalNumber, isValidPhoneNumber, maxNationalNumberLength, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, splitPhoneNumber, validatePhoneNumberLength } from "./phone.js";
9
9
  //# sourceMappingURL=index.js.map
@@ -7,7 +7,12 @@
7
7
  * module exists is validation and formatting accuracy, the more accurate
8
8
  * variant wins throughout this file, not just for validation.
9
9
  */
10
+ import { Metadata } from 'libphonenumber-js/core';
10
11
  import { AsYouType, getCountries, getCountryCallingCode, parsePhoneNumberFromString, validatePhoneNumberLength } from 'libphonenumber-js/max';
12
+ // `Metadata` comes from the core entry with the max data passed in by hand:
13
+ // the max entry exports it in its ESM build only, and the CommonJS build jest
14
+ // and node resolve has no `Metadata` at all (libphonenumber-js 1.13.12).
15
+ import phoneMetadata from 'libphonenumber-js/metadata.max.json';
11
16
  export { AsYouType, getCountries, getCountryCallingCode, isSupportedCountry, isValidPhoneNumber, parsePhoneNumber, parsePhoneNumberFromString, validatePhoneNumberLength } from 'libphonenumber-js/max';
12
17
 
13
18
  /**
@@ -171,8 +176,9 @@ export const splitPhoneNumber = (input, defaultCountry) => {
171
176
  * allows, so a field stops accepting the impossible without a per-country
172
177
  * length table. This is the PLAN's ceiling, not a mobile number's: India runs
173
178
  * to 13 digits (toll-free 1800 numbers), the US to 10, Germany to 15. A field
174
- * that wants a hard stop at the mobile length sets its own `maxLength`. Digits
175
- * within range, including a number still too short, pass through untouched.
179
+ * that should stop where a subscriber's number ends asks
180
+ * `maxNationalNumberLength` instead. Digits within range, including a number
181
+ * still too short, pass through untouched.
176
182
  */
177
183
  export const clampNationalNumber = (nationalDigits, country) => {
178
184
  let digits = onlyDigits(nationalDigits);
@@ -182,6 +188,39 @@ export const clampNationalNumber = (nationalDigits, country) => {
182
188
  return digits;
183
189
  };
184
190
 
191
+ // The number types a person types into a phone field. Toll-free, premium,
192
+ // shared-cost and pager ranges are what push a plan's ceiling past them.
193
+ const SUBSCRIBER_TYPES = {
194
+ any: ['MOBILE', 'FIXED_LINE'],
195
+ mobile: ['MOBILE']
196
+ };
197
+
198
+ // libphonenumber-js types `numberingPlan` without its per-type accessor; the
199
+ // runtime object has it, and a type with no lengths of its own answers with the
200
+ // plan's.
201
+
202
+ /**
203
+ * The most national digits a subscriber's number can have in a country, so a
204
+ * field can refuse the next digit as it is typed rather than trimming after.
205
+ * `'any'` (default) covers mobile and fixed lines, `'mobile'` mobiles only: India
206
+ * is 10 either way (its plan's 13 belongs to toll-free numbers), Germany is 15
207
+ * for `'any'` and 11 for `'mobile'`, the UAE 9. A country whose metadata lists
208
+ * no lengths by type falls back to the plan's longest number.
209
+ */
210
+ export const maxNationalNumberLength = (country, kind = 'any') => {
211
+ const metadata = new Metadata(phoneMetadata);
212
+ metadata.selectNumberingPlan(country);
213
+ const plan = metadata.numberingPlan;
214
+ if (!plan) {
215
+ return E164_MAX_NATIONAL_DIGITS;
216
+ }
217
+ const byType = SUBSCRIBER_TYPES[kind].flatMap(type => plan.type(type)?.possibleLengths() ?? []);
218
+ return Math.max(...(byType.length > 0 ? byType : plan.possibleLengths()));
219
+ };
220
+
221
+ // E.164 allows 15 digits in total; a national number can never exceed it.
222
+ const E164_MAX_NATIONAL_DIGITS = 15;
223
+
185
224
  /**
186
225
  * National digits grouped the way the country writes them, updated on every
187
226
  * keystroke: `'98765'` for IN is `'98765'`, `'9876543210'` is `'98765 43210'`,
@@ -190,13 +229,25 @@ export const clampNationalNumber = (nationalDigits, country) => {
190
229
  * number are dropped first, so an overflowing paste never formats as a longer
191
230
  * number; digits that fit no pattern come back ungrouped rather than forced
192
231
  * into a shape.
232
+ *
233
+ * Countries that write a leading 0 (the UAE, the UK, Australia, Saudi Arabia)
234
+ * only group in national mode when that 0 is typed, and a value never holds
235
+ * it. When national mode hands the digits back untouched, the grouping comes
236
+ * from the international form with the calling code removed: `'501234567'`
237
+ * for AE is `'50 123 4567'`. Countries that group nationally are unaffected.
193
238
  */
194
239
  export const formatPhoneAsTyped = (nationalDigits, country) => {
195
240
  const digits = clampNationalNumber(nationalDigits, country);
196
241
  if (!digits) {
197
242
  return '';
198
243
  }
199
- return new AsYouType(country).input(digits);
244
+ const national = new AsYouType(country).input(digits);
245
+ if (national !== digits) {
246
+ return national;
247
+ }
248
+ const prefix = `+${getCountryCallingCode(country)}`;
249
+ const international = new AsYouType().input(`${prefix}${digits}`);
250
+ return international.startsWith(prefix) ? international.slice(prefix.length).trimStart() || digits : digits;
200
251
  };
201
252
 
202
253
  /**
@@ -34,7 +34,7 @@ export { getConfig, getConfigValue, resetConfig, setConfig } from "./config/inde
34
34
  // Deep links
35
35
  export { DeepLink, parseDeepLink, useDeepLink } from "./deepLink/index.js";
36
36
  // Formatters
37
- export { AsYouType, addDays, clampNationalNumber, countryFlagEmoji, detectPhoneCountry, diffMs, formatCompactNumber, formatCurrency, formatDate, formatDateDDMMMYYYY, formatDateISO, formatDatePattern, formatDateTime, formatNumber, formatPercent, formatPhone, formatPhoneAsTyped, formatRelativeTime, formatTime, formatTime12h, formatTimeInWindowsZone, formatTimeInZone, getCountries, getCountryCallingCode, getInitials, getPhoneCountries, isDateAfter, isDateBefore, isSameDay, isSupportedCountry, isValidNationalNumber, isValidPhoneNumber, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, splitPhoneNumber, startOfDay, validatePhoneNumberLength } from "./formatters/index.js";
37
+ export { AsYouType, addDays, clampNationalNumber, countryFlagEmoji, detectPhoneCountry, diffMs, formatCompactNumber, formatCurrency, formatDate, formatDateDDMMMYYYY, formatDateISO, formatDatePattern, formatDateTime, formatNumber, formatPercent, formatPhone, formatPhoneAsTyped, formatRelativeTime, formatTime, formatTime12h, formatTimeInWindowsZone, formatTimeInZone, getCountries, getCountryCallingCode, getInitials, getPhoneCountries, isDateAfter, isDateBefore, isSameDay, isSupportedCountry, isValidNationalNumber, isValidPhoneNumber, maxNationalNumberLength, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, splitPhoneNumber, startOfDay, validatePhoneNumberLength } from "./formatters/index.js";
38
38
  // Initialization
39
39
  export { initWebority } from "./initSDK.js";
40
40
  export { initUserAuth } from "./initUserAuth.js";
@@ -6,5 +6,5 @@ export { addDays, diffMs, formatDateDDMMMYYYY, formatDateISO, formatDatePattern,
6
6
  export { getInitials } from './initials';
7
7
  export { formatCompactNumber, formatNumber, formatPercent } from './number';
8
8
  export type { FormatPhoneOptions, PhoneCountry, PhoneCountryEntry, PhoneNumber, PhoneNumberType, PhoneParts, PhoneValidationKind } from './phone';
9
- export { AsYouType, clampNationalNumber, countryFlagEmoji, detectPhoneCountry, formatPhone, formatPhoneAsTyped, getCountries, getCountryCallingCode, getPhoneCountries, isSupportedCountry, isValidNationalNumber, isValidPhoneNumber, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, splitPhoneNumber, validatePhoneNumberLength } from './phone';
9
+ export { AsYouType, clampNationalNumber, countryFlagEmoji, detectPhoneCountry, formatPhone, formatPhoneAsTyped, getCountries, getCountryCallingCode, getPhoneCountries, isSupportedCountry, isValidNationalNumber, isValidPhoneNumber, maxNationalNumberLength, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, splitPhoneNumber, validatePhoneNumberLength } from './phone';
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1,10 +1,3 @@
1
- /**
2
- * The bare 'libphonenumber-js' entry point actually resolves to the library's
3
- * OWN slimmed-down min/ metadata internally, not its full data - './max' is
4
- * the variant with complete per-country metadata. Since the reason this
5
- * module exists is validation and formatting accuracy, the more accurate
6
- * variant wins throughout this file, not just for validation.
7
- */
8
1
  import { type CountryCode } from 'libphonenumber-js/max';
9
2
  export type { NumberType as PhoneNumberType, PhoneNumber } from 'libphonenumber-js/max';
10
3
  export { AsYouType, getCountries, getCountryCallingCode, isSupportedCountry, isValidPhoneNumber, parsePhoneNumber, parsePhoneNumberFromString, validatePhoneNumberLength } from 'libphonenumber-js/max';
@@ -79,10 +72,20 @@ export declare const splitPhoneNumber: (input: string, defaultCountry?: PhoneCou
79
72
  * allows, so a field stops accepting the impossible without a per-country
80
73
  * length table. This is the PLAN's ceiling, not a mobile number's: India runs
81
74
  * to 13 digits (toll-free 1800 numbers), the US to 10, Germany to 15. A field
82
- * that wants a hard stop at the mobile length sets its own `maxLength`. Digits
83
- * within range, including a number still too short, pass through untouched.
75
+ * that should stop where a subscriber's number ends asks
76
+ * `maxNationalNumberLength` instead. Digits within range, including a number
77
+ * still too short, pass through untouched.
84
78
  */
85
79
  export declare const clampNationalNumber: (nationalDigits: string, country: PhoneCountry) => string;
80
+ /**
81
+ * The most national digits a subscriber's number can have in a country, so a
82
+ * field can refuse the next digit as it is typed rather than trimming after.
83
+ * `'any'` (default) covers mobile and fixed lines, `'mobile'` mobiles only: India
84
+ * is 10 either way (its plan's 13 belongs to toll-free numbers), Germany is 15
85
+ * for `'any'` and 11 for `'mobile'`, the UAE 9. A country whose metadata lists
86
+ * no lengths by type falls back to the plan's longest number.
87
+ */
88
+ export declare const maxNationalNumberLength: (country: PhoneCountry, kind?: PhoneValidationKind) => number;
86
89
  /**
87
90
  * National digits grouped the way the country writes them, updated on every
88
91
  * keystroke: `'98765'` for IN is `'98765'`, `'9876543210'` is `'98765 43210'`,
@@ -91,6 +94,12 @@ export declare const clampNationalNumber: (nationalDigits: string, country: Phon
91
94
  * number are dropped first, so an overflowing paste never formats as a longer
92
95
  * number; digits that fit no pattern come back ungrouped rather than forced
93
96
  * into a shape.
97
+ *
98
+ * Countries that write a leading 0 (the UAE, the UK, Australia, Saudi Arabia)
99
+ * only group in national mode when that 0 is typed, and a value never holds
100
+ * it. When national mode hands the digits back untouched, the grouping comes
101
+ * from the international form with the calling code removed: `'501234567'`
102
+ * for AE is `'50 123 4567'`. Countries that group nationally are unaffected.
94
103
  */
95
104
  export declare const formatPhoneAsTyped: (nationalDigits: string, country: PhoneCountry) => string;
96
105
  /**
@@ -34,7 +34,7 @@ export { getConfig, getConfigValue, resetConfig, setConfig } from './config';
34
34
  export type { DeepLinkConfig, DeepLinkRoute, ParsedLink } from './deepLink';
35
35
  export { DeepLink, parseDeepLink, useDeepLink } from './deepLink';
36
36
  export type { DateInput, DateStyle, FormatCurrencyOptions, FormatPhoneOptions, PhoneCountry, PhoneCountryEntry, PhoneNumber, PhoneNumberType, PhoneParts, PhoneValidationKind, TimeStyle } from './formatters';
37
- export { AsYouType, addDays, clampNationalNumber, countryFlagEmoji, detectPhoneCountry, diffMs, formatCompactNumber, formatCurrency, formatDate, formatDateDDMMMYYYY, formatDateISO, formatDatePattern, formatDateTime, formatNumber, formatPercent, formatPhone, formatPhoneAsTyped, formatRelativeTime, formatTime, formatTime12h, formatTimeInWindowsZone, formatTimeInZone, getCountries, getCountryCallingCode, getInitials, getPhoneCountries, isDateAfter, isDateBefore, isSameDay, isSupportedCountry, isValidNationalNumber, isValidPhoneNumber, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, splitPhoneNumber, startOfDay, validatePhoneNumberLength } from './formatters';
37
+ export { AsYouType, addDays, clampNationalNumber, countryFlagEmoji, detectPhoneCountry, diffMs, formatCompactNumber, formatCurrency, formatDate, formatDateDDMMMYYYY, formatDateISO, formatDatePattern, formatDateTime, formatNumber, formatPercent, formatPhone, formatPhoneAsTyped, formatRelativeTime, formatTime, formatTime12h, formatTimeInWindowsZone, formatTimeInZone, getCountries, getCountryCallingCode, getInitials, getPhoneCountries, isDateAfter, isDateBefore, isSameDay, isSupportedCountry, isValidNationalNumber, isValidPhoneNumber, maxNationalNumberLength, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, splitPhoneNumber, startOfDay, validatePhoneNumberLength } from './formatters';
38
38
  export type { InitConfig } from './initSDK';
39
39
  export { initWebority } from './initSDK';
40
40
  export type { AuthActions } from './initUserAuth';
@@ -6,5 +6,5 @@ export { addDays, diffMs, formatDateDDMMMYYYY, formatDateISO, formatDatePattern,
6
6
  export { getInitials } from './initials.js';
7
7
  export { formatCompactNumber, formatNumber, formatPercent } from './number.js';
8
8
  export type { FormatPhoneOptions, PhoneCountry, PhoneCountryEntry, PhoneNumber, PhoneNumberType, PhoneParts, PhoneValidationKind } from './phone.js';
9
- export { AsYouType, clampNationalNumber, countryFlagEmoji, detectPhoneCountry, formatPhone, formatPhoneAsTyped, getCountries, getCountryCallingCode, getPhoneCountries, isSupportedCountry, isValidNationalNumber, isValidPhoneNumber, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, splitPhoneNumber, validatePhoneNumberLength } from './phone.js';
9
+ export { AsYouType, clampNationalNumber, countryFlagEmoji, detectPhoneCountry, formatPhone, formatPhoneAsTyped, getCountries, getCountryCallingCode, getPhoneCountries, isSupportedCountry, isValidNationalNumber, isValidPhoneNumber, maxNationalNumberLength, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, splitPhoneNumber, validatePhoneNumberLength } from './phone.js';
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1,10 +1,3 @@
1
- /**
2
- * The bare 'libphonenumber-js' entry point actually resolves to the library's
3
- * OWN slimmed-down min/ metadata internally, not its full data - './max' is
4
- * the variant with complete per-country metadata. Since the reason this
5
- * module exists is validation and formatting accuracy, the more accurate
6
- * variant wins throughout this file, not just for validation.
7
- */
8
1
  import { type CountryCode } from 'libphonenumber-js/max';
9
2
  export type { NumberType as PhoneNumberType, PhoneNumber } from 'libphonenumber-js/max';
10
3
  export { AsYouType, getCountries, getCountryCallingCode, isSupportedCountry, isValidPhoneNumber, parsePhoneNumber, parsePhoneNumberFromString, validatePhoneNumberLength } from 'libphonenumber-js/max';
@@ -79,10 +72,20 @@ export declare const splitPhoneNumber: (input: string, defaultCountry?: PhoneCou
79
72
  * allows, so a field stops accepting the impossible without a per-country
80
73
  * length table. This is the PLAN's ceiling, not a mobile number's: India runs
81
74
  * to 13 digits (toll-free 1800 numbers), the US to 10, Germany to 15. A field
82
- * that wants a hard stop at the mobile length sets its own `maxLength`. Digits
83
- * within range, including a number still too short, pass through untouched.
75
+ * that should stop where a subscriber's number ends asks
76
+ * `maxNationalNumberLength` instead. Digits within range, including a number
77
+ * still too short, pass through untouched.
84
78
  */
85
79
  export declare const clampNationalNumber: (nationalDigits: string, country: PhoneCountry) => string;
80
+ /**
81
+ * The most national digits a subscriber's number can have in a country, so a
82
+ * field can refuse the next digit as it is typed rather than trimming after.
83
+ * `'any'` (default) covers mobile and fixed lines, `'mobile'` mobiles only: India
84
+ * is 10 either way (its plan's 13 belongs to toll-free numbers), Germany is 15
85
+ * for `'any'` and 11 for `'mobile'`, the UAE 9. A country whose metadata lists
86
+ * no lengths by type falls back to the plan's longest number.
87
+ */
88
+ export declare const maxNationalNumberLength: (country: PhoneCountry, kind?: PhoneValidationKind) => number;
86
89
  /**
87
90
  * National digits grouped the way the country writes them, updated on every
88
91
  * keystroke: `'98765'` for IN is `'98765'`, `'9876543210'` is `'98765 43210'`,
@@ -91,6 +94,12 @@ export declare const clampNationalNumber: (nationalDigits: string, country: Phon
91
94
  * number are dropped first, so an overflowing paste never formats as a longer
92
95
  * number; digits that fit no pattern come back ungrouped rather than forced
93
96
  * into a shape.
97
+ *
98
+ * Countries that write a leading 0 (the UAE, the UK, Australia, Saudi Arabia)
99
+ * only group in national mode when that 0 is typed, and a value never holds
100
+ * it. When national mode hands the digits back untouched, the grouping comes
101
+ * from the international form with the calling code removed: `'501234567'`
102
+ * for AE is `'50 123 4567'`. Countries that group nationally are unaffected.
94
103
  */
95
104
  export declare const formatPhoneAsTyped: (nationalDigits: string, country: PhoneCountry) => string;
96
105
  /**
@@ -34,7 +34,7 @@ export { getConfig, getConfigValue, resetConfig, setConfig } from './config/inde
34
34
  export type { DeepLinkConfig, DeepLinkRoute, ParsedLink } from './deepLink/index.js';
35
35
  export { DeepLink, parseDeepLink, useDeepLink } from './deepLink/index.js';
36
36
  export type { DateInput, DateStyle, FormatCurrencyOptions, FormatPhoneOptions, PhoneCountry, PhoneCountryEntry, PhoneNumber, PhoneNumberType, PhoneParts, PhoneValidationKind, TimeStyle } from './formatters/index.js';
37
- export { AsYouType, addDays, clampNationalNumber, countryFlagEmoji, detectPhoneCountry, diffMs, formatCompactNumber, formatCurrency, formatDate, formatDateDDMMMYYYY, formatDateISO, formatDatePattern, formatDateTime, formatNumber, formatPercent, formatPhone, formatPhoneAsTyped, formatRelativeTime, formatTime, formatTime12h, formatTimeInWindowsZone, formatTimeInZone, getCountries, getCountryCallingCode, getInitials, getPhoneCountries, isDateAfter, isDateBefore, isSameDay, isSupportedCountry, isValidNationalNumber, isValidPhoneNumber, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, splitPhoneNumber, startOfDay, validatePhoneNumberLength } from './formatters/index.js';
37
+ export { AsYouType, addDays, clampNationalNumber, countryFlagEmoji, detectPhoneCountry, diffMs, formatCompactNumber, formatCurrency, formatDate, formatDateDDMMMYYYY, formatDateISO, formatDatePattern, formatDateTime, formatNumber, formatPercent, formatPhone, formatPhoneAsTyped, formatRelativeTime, formatTime, formatTime12h, formatTimeInWindowsZone, formatTimeInZone, getCountries, getCountryCallingCode, getInitials, getPhoneCountries, isDateAfter, isDateBefore, isSameDay, isSupportedCountry, isValidNationalNumber, isValidPhoneNumber, maxNationalNumberLength, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, splitPhoneNumber, startOfDay, validatePhoneNumberLength } from './formatters/index.js';
38
38
  export type { InitConfig } from './initSDK.js';
39
39
  export { initWebority } from './initSDK.js';
40
40
  export type { AuthActions } from './initUserAuth.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority-technologies/mobile-core",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "Platform layer for Webority React Native apps: HTTP clients, auth/token storage, config, logging, formatters, validators, network status, permissions, storage and version checks. No UI.",
5
5
  "keywords": [
6
6
  "react-native",