@rzl-zone/utils-js 3.10.0 → 3.11.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/README.md +131 -129
- package/dist/assertions/index.cjs +11 -11
- package/dist/assertions/index.d.ts +487 -215
- package/dist/assertions/index.js +5 -5
- package/dist/{chunk-SN5HAK3Y.js → chunk-22V4WP3H.js} +4 -4
- package/dist/{chunk-EJV5AF4L.js → chunk-2XSZ2ANI.js} +2 -2
- package/dist/{chunk-OSSFLQDD.js → chunk-3T6VSWYX.js} +2 -2
- package/dist/{chunk-3LE6NX57.js → chunk-5WIEDF2J.js} +4 -4
- package/dist/{chunk-WLEZ2KSG.cjs → chunk-6EDFZJZ5.cjs} +126 -126
- package/dist/{chunk-GHU356XQ.js → chunk-6LXWT2I5.js} +3 -3
- package/dist/{chunk-GKDSBOYE.js → chunk-6YGBRENU.js} +3 -3
- package/dist/{chunk-NAOVH4OH.cjs → chunk-7FGNVDEV.cjs} +7 -7
- package/dist/{chunk-X6ULJZ3X.js → chunk-AXDYWO67.js} +2 -2
- package/dist/{chunk-UV5BKAYW.cjs → chunk-B6PMNZ4M.cjs} +7 -7
- package/dist/chunk-BAV5T2E3.cjs +1 -1
- package/dist/{chunk-YHFRCVTN.js → chunk-BLF7SD66.js} +3 -3
- package/dist/{chunk-QZI5PVCI.cjs → chunk-BMZZXZJ2.cjs} +4 -4
- package/dist/{chunk-DXPM4NOU.js → chunk-BOYP3ARU.js} +4 -4
- package/dist/{chunk-UXT4XSUK.js → chunk-BPYW5YL7.js} +2 -2
- package/dist/{chunk-QGTFQ7RO.cjs → chunk-C2PV3VWC.cjs} +6 -6
- package/dist/{chunk-MZ3T6L7Z.js → chunk-CCJ2MSN7.js} +2 -2
- package/dist/{chunk-H44QVAZL.cjs → chunk-DAPAK2W3.cjs} +31 -31
- package/dist/{chunk-OYFUBKEG.cjs → chunk-DLS3G6WQ.cjs} +4 -4
- package/dist/{chunk-MS2KSKD7.js → chunk-DNMCR5JH.js} +9 -9
- package/dist/chunk-DVMHRLKP.cjs +1 -1
- package/dist/{chunk-IX6PF5ZP.cjs → chunk-EBYFYZW4.cjs} +4 -4
- package/dist/{chunk-5Y6JL47L.js → chunk-ENMRZ4BE.js} +3 -3
- package/dist/{chunk-7EIFPHV3.js → chunk-FJ4BQFVO.js} +8 -8
- package/dist/{chunk-TJ5OY6MC.cjs → chunk-GIKL4PUF.cjs} +10 -10
- package/dist/{chunk-M5QB2GM5.js → chunk-GOFINGT6.js} +2 -2
- package/dist/{chunk-J6VLFVIL.js → chunk-GXKQ3LHF.js} +3 -3
- package/dist/{chunk-5KDVIEVO.js → chunk-HNBRGN4R.js} +2 -2
- package/dist/{chunk-OCTHWEZK.cjs → chunk-HYN6FC5A.cjs} +34 -34
- package/dist/{chunk-MBFVTGYS.js → chunk-IZGVBYFN.js} +4 -4
- package/dist/{chunk-QXTJVDWE.js → chunk-JIE447J5.js} +3 -3
- package/dist/{chunk-UFYMRRJH.cjs → chunk-JXEIJM5M.cjs} +61 -61
- package/dist/{chunk-WB3FT62A.js → chunk-K47GZDBH.js} +3 -3
- package/dist/{chunk-KUVRZ2JW.cjs → chunk-K5536YHG.cjs} +50 -50
- package/dist/chunk-KHO2SBNA.cjs +1 -1
- package/dist/{chunk-NJ24M6ZH.cjs → chunk-KXJ7X325.cjs} +37 -37
- package/dist/chunk-L5RDAVVH.js +1 -1
- package/dist/{chunk-SRWL4YCP.js → chunk-LJHPTLWB.js} +7 -7
- package/dist/{chunk-6AMDHVS2.cjs → chunk-M7ELWZXM.cjs} +9 -9
- package/dist/chunk-MSUW5VHZ.js +1590 -0
- package/dist/{chunk-2XGQQZ6A.cjs → chunk-MUHRPRR7.cjs} +3 -3
- package/dist/{chunk-XYWC4EQ3.cjs → chunk-MV3TSQSH.cjs} +71 -71
- package/dist/{chunk-VCYXNIZ2.cjs → chunk-NLZLXWAU.cjs} +9 -9
- package/dist/{chunk-76ATVDCR.cjs → chunk-NVRZPF5M.cjs} +3 -3
- package/dist/chunk-ONZFBJVW.js +1 -1
- package/dist/{chunk-62FS7WMB.cjs → chunk-PGNL7JXO.cjs} +31 -31
- package/dist/{chunk-JI57K7D4.cjs → chunk-Q4GEQS7X.cjs} +161 -161
- package/dist/chunk-QNKGP5DY.js +1 -1
- package/dist/{chunk-ZTHJQJ5F.cjs → chunk-QYI2VJLS.cjs} +9 -9
- package/dist/{chunk-C7GC2PFX.js → chunk-RBWZII5I.js} +3 -3
- package/dist/{chunk-MMRHKYT6.cjs → chunk-RMP7VMPB.cjs} +12 -12
- package/dist/{chunk-TXOVQZPU.js → chunk-RZOGBYIS.js} +2 -2
- package/dist/{chunk-ALRISPTL.cjs → chunk-SU3UELUB.cjs} +3 -3
- package/dist/chunk-SYHPSOUU.cjs +1626 -0
- package/dist/{chunk-R2DR7SPJ.js → chunk-SZUNAEMR.js} +6 -6
- package/dist/{chunk-YVRUY4EW.cjs → chunk-TER22LO4.cjs} +8 -8
- package/dist/{chunk-WRGN6UBK.js → chunk-TJHGRQ4P.js} +2 -2
- package/dist/{chunk-I33PB44Q.cjs → chunk-U23I7JPB.cjs} +15 -15
- package/dist/{chunk-VBSLIIDB.js → chunk-U7HHN47R.js} +10 -10
- package/dist/chunk-UDA26MCU.cjs +1 -1
- package/dist/{chunk-44X74C26.js → chunk-UIAWUZ4H.js} +4 -4
- package/dist/{chunk-5O66AUEC.js → chunk-ULQPCIA2.js} +2 -2
- package/dist/chunk-VJDDGRIK.cjs +1 -1
- package/dist/{chunk-6WVOUVWD.js → chunk-WETQI6HM.js} +9 -9
- package/dist/{chunk-FWWPEL7J.cjs → chunk-WLOQQFDS.cjs} +3 -3
- package/dist/chunk-WVSPXFTY.js +1 -1
- package/dist/{chunk-WKM6UVMG.cjs → chunk-WXFTVXBF.cjs} +4 -4
- package/dist/{chunk-YQHJB7KR.cjs → chunk-XPVTIGU2.cjs} +26 -26
- package/dist/{chunk-PWKOFPAH.cjs → chunk-XX6RUGTM.cjs} +3 -3
- package/dist/chunk-YWHHVDT4.js +1 -1
- package/dist/{chunk-7NXFGJJE.cjs → chunk-ZPDMWDGZ.cjs} +14 -14
- package/dist/{chunk-JYOCB6OV.js → chunk-ZVWZEGQP.js} +2 -2
- package/dist/conversions/index.cjs +34 -34
- package/dist/conversions/index.d.ts +489 -333
- package/dist/conversions/index.js +15 -15
- package/dist/events/index.cjs +8 -8
- package/dist/events/index.d.ts +35 -29
- package/dist/events/index.js +4 -4
- package/dist/formatters/index.cjs +19 -19
- package/dist/formatters/index.d.ts +917 -873
- package/dist/formatters/index.js +9 -9
- package/dist/generators/index.cjs +9 -9
- package/dist/generators/index.d.ts +104 -86
- package/dist/generators/index.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/isPlainObject-0p3VveWr.d.ts +534 -0
- package/dist/next/index.cjs +37 -37
- package/dist/next/index.d.ts +36 -21
- package/dist/next/index.js +9 -9
- package/dist/next/server/index.cjs +4 -4
- package/dist/next/server/index.d.ts +6 -3
- package/dist/next/server/index.js +2 -2
- package/dist/operations/index.cjs +11 -11
- package/dist/operations/index.d.ts +14 -5
- package/dist/operations/index.js +8 -8
- package/dist/parsers/index.cjs +6 -6
- package/dist/parsers/index.d.ts +68 -65
- package/dist/parsers/index.js +5 -5
- package/dist/predicates/index.cjs +77 -77
- package/dist/predicates/index.d.ts +442 -258
- package/dist/predicates/index.js +14 -14
- package/dist/promises/index.cjs +6 -6
- package/dist/promises/index.d.ts +28 -16
- package/dist/promises/index.js +4 -4
- package/dist/rzl-utils.global.js +2 -2
- package/dist/strings/index.cjs +23 -23
- package/dist/strings/index.d.ts +82 -54
- package/dist/strings/index.js +7 -7
- package/dist/tailwind/index.cjs +13 -13
- package/dist/tailwind/index.d.ts +186 -169
- package/dist/tailwind/index.js +5 -5
- package/dist/urls/index.cjs +23 -23
- package/dist/urls/index.d.ts +252 -229
- package/dist/urls/index.js +16 -16
- package/package.json +6 -4
- package/dist/chunk-7C7TQC5J.cjs +0 -620
- package/dist/chunk-J4TT33ZX.js +0 -584
- package/dist/isPlainObject-BTPjv6zB.d.ts +0 -178
|
@@ -2,136 +2,148 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.11.1.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
|
-
import{NumberFormat,CountryCode}from'libphonenumber-js';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
style?:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
import { NumberFormat, CountryCode } from 'libphonenumber-js';
|
|
11
|
+
import { OverrideTypes, ExtractStrict, Prettify, OmitStrict, AnyString } from '@rzl-zone/ts-types-plus';
|
|
12
|
+
import { FormatOptions, Locale } from 'date-fns';
|
|
13
|
+
|
|
14
|
+
type NegativeFormatOptionCustom = {
|
|
15
|
+
/** Custom formatter function for the final formatted negative string.
|
|
16
|
+
* If provided, it ***OVERRIDES*** style & space entirely. */
|
|
17
|
+
custom: (formatted: string) => string;
|
|
18
|
+
style?: never;
|
|
19
|
+
space?: never;
|
|
20
|
+
};
|
|
21
|
+
type NegativeFormatOptionUnCustom = {
|
|
22
|
+
custom?: never;
|
|
23
|
+
/** Use style & optional spacing for negative numbers.
|
|
24
|
+
*
|
|
25
|
+
* @default "dash"
|
|
26
|
+
*/
|
|
27
|
+
style?: "dash" | "brackets" | "abs";
|
|
28
|
+
/** Whether to include space inside brackets or after dash.
|
|
29
|
+
*
|
|
30
|
+
* Default: false
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
space?: boolean;
|
|
34
|
+
};
|
|
25
35
|
/** ---------------------------------------------------------------------------
|
|
26
36
|
* * ***Type for negative number formatting options.***
|
|
27
37
|
* ---------------------------------------------------------------------------
|
|
28
38
|
*/
|
|
29
|
-
type NegativeFormatOption="dash"|"brackets"|"abs"|NegativeFormatOptionCustom|NegativeFormatOptionUnCustom;
|
|
39
|
+
type NegativeFormatOption = "dash" | "brackets" | "abs" | NegativeFormatOptionCustom | NegativeFormatOptionUnCustom;
|
|
30
40
|
/** ---------------------------------------------------------------------------
|
|
31
41
|
* * ***Type Options for {@link formatCurrency|`formatCurrency`}.***
|
|
32
42
|
* ---------------------------------------------------------------------------
|
|
33
43
|
*/
|
|
34
|
-
type FormatCurrencyOptions={
|
|
35
|
-
/** ---------------------------------------------------------------------------
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
suffixCurrency?:string;
|
|
45
|
-
/** ---------------------------------------------------------------------------
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
separator?:string;
|
|
53
|
-
/** ---------------------------------------------------------------------------
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
decimal?:boolean;
|
|
61
|
-
/** ---------------------------------------------------------------------------
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
totalDecimal?:number;
|
|
69
|
-
/** ---------------------------------------------------------------------------
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
endDecimal?:boolean;
|
|
76
|
-
/** ---------------------------------------------------------------------------
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
suffixDecimal?:string;
|
|
86
|
-
/** ---------------------------------------------------------------------------
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
roundedDecimal?:"round"|"ceil"|"floor"|false;
|
|
98
|
-
/** ---------------------------------------------------------------------------
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
separatorDecimals?:string;
|
|
106
|
-
/** ---------------------------------------------------------------------------
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
negativeFormat?:NegativeFormatOption;
|
|
125
|
-
/** ---------------------------------------------------------------------------
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
indianFormat?:boolean;
|
|
44
|
+
type FormatCurrencyOptions = {
|
|
45
|
+
/** ---------------------------------------------------------------------------
|
|
46
|
+
* * ***Prefix currency string.***
|
|
47
|
+
* ---------------------------------------------------------------------------
|
|
48
|
+
* **Does not auto-keep input symbols.**
|
|
49
|
+
* - ***DefaultValue:** `""`.*
|
|
50
|
+
* - **Example:** `"Rp "` ➔ `Rp 1.000`.
|
|
51
|
+
*
|
|
52
|
+
* @default ""
|
|
53
|
+
*/
|
|
54
|
+
suffixCurrency?: string;
|
|
55
|
+
/** ---------------------------------------------------------------------------
|
|
56
|
+
* * ***Thousands separator.***
|
|
57
|
+
* ---------------------------------------------------------------------------
|
|
58
|
+
* - ***DefaultValue:** `"."`.*
|
|
59
|
+
* - **Example:** `"."` ➔ `1.000.000`.
|
|
60
|
+
* @default "."
|
|
61
|
+
*/
|
|
62
|
+
separator?: string;
|
|
63
|
+
/** ---------------------------------------------------------------------------
|
|
64
|
+
* * ***Prefix currency string.***
|
|
65
|
+
* ---------------------------------------------------------------------------
|
|
66
|
+
* **Whether to show decimals, if `false`, decimals are truncated.**
|
|
67
|
+
* - ***DefaultValue:** `false`.*
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
70
|
+
decimal?: boolean;
|
|
71
|
+
/** ---------------------------------------------------------------------------
|
|
72
|
+
* * ***Total decimal digits.***
|
|
73
|
+
* ---------------------------------------------------------------------------
|
|
74
|
+
* **If `decimal: true` & `roundedDecimal: false`, simply cuts.**
|
|
75
|
+
* - ***DefaultValue:** `2`.*
|
|
76
|
+
* @default 2
|
|
77
|
+
*/
|
|
78
|
+
totalDecimal?: number;
|
|
79
|
+
/** ---------------------------------------------------------------------------
|
|
80
|
+
* * ***Actually append `suffixDecimal`.***
|
|
81
|
+
* ---------------------------------------------------------------------------
|
|
82
|
+
* - ***DefaultValue:** `true`.*
|
|
83
|
+
* @default true
|
|
84
|
+
*/
|
|
85
|
+
endDecimal?: boolean;
|
|
86
|
+
/** ---------------------------------------------------------------------------
|
|
87
|
+
* * ***Text appended after decimals.***
|
|
88
|
+
* ---------------------------------------------------------------------------
|
|
89
|
+
* - ***DefaultValue:** `""`.*
|
|
90
|
+
* - **Example:**
|
|
91
|
+
* - `".-"` ➔ `1.000,00.-`.
|
|
92
|
+
* - `" USD"` ➔ `1.000,00 USD`.
|
|
93
|
+
* @default ""
|
|
94
|
+
*/
|
|
95
|
+
suffixDecimal?: string;
|
|
96
|
+
/** ---------------------------------------------------------------------------
|
|
97
|
+
* * ***Rounding mode for decimals.***
|
|
98
|
+
* ---------------------------------------------------------------------------
|
|
99
|
+
* - **Behavior:**
|
|
100
|
+
* - `"round"` ➔ nearest.
|
|
101
|
+
* - `"ceil"` ➔ always up.
|
|
102
|
+
* - `"floor"` ➔ always down.
|
|
103
|
+
* - `false` ➔ truncate.
|
|
104
|
+
* - ***DefaultValue:** `"round"`.*
|
|
105
|
+
* @default "round"
|
|
106
|
+
*/
|
|
107
|
+
roundedDecimal?: "round" | "ceil" | "floor" | false;
|
|
108
|
+
/** ---------------------------------------------------------------------------
|
|
109
|
+
* * ***Decimal separator.***
|
|
110
|
+
* ---------------------------------------------------------------------------
|
|
111
|
+
* - ***DefaultValue:** `","`.*
|
|
112
|
+
* - **Example:** `","` ➔ `1.000,10`.
|
|
113
|
+
* @default ","
|
|
114
|
+
*/
|
|
115
|
+
separatorDecimals?: string;
|
|
116
|
+
/** ---------------------------------------------------------------------------
|
|
117
|
+
* * ***Negative formatting option.***
|
|
118
|
+
* ---------------------------------------------------------------------------
|
|
119
|
+
* **Can be string ("dash" | "brackets" | "abs") or object with custom formatter.**
|
|
120
|
+
* - **Behavior:**
|
|
121
|
+
* - `"dash"` ➔ `-15.000`.
|
|
122
|
+
* - `"brackets"` ➔ `(15.000)`.
|
|
123
|
+
* - `"abs"` ➔ `15.000` (always positive).
|
|
124
|
+
* - Or object:
|
|
125
|
+
* `{
|
|
126
|
+
* style: "dash"|"brackets"|"abs",
|
|
127
|
+
* space: true|false,
|
|
128
|
+
* custom: (formatted) => string
|
|
129
|
+
* }`.
|
|
130
|
+
* - ***DefaultValue:** `"dash"`.*
|
|
131
|
+
*
|
|
132
|
+
* @default "dash"
|
|
133
|
+
*/
|
|
134
|
+
negativeFormat?: NegativeFormatOption;
|
|
135
|
+
/** ---------------------------------------------------------------------------
|
|
136
|
+
* * ***Applies Indian Format.***
|
|
137
|
+
* ---------------------------------------------------------------------------
|
|
138
|
+
* - **Behavior:**
|
|
139
|
+
* - If `true`, formats as Indian: `12,34,567`.
|
|
140
|
+
* - Also forces `separator: ","`, `separatorDecimals: "."`.
|
|
141
|
+
* - ***DefaultValue:** `false`.*
|
|
142
|
+
* @default false
|
|
143
|
+
*/
|
|
144
|
+
indianFormat?: boolean;
|
|
145
|
+
};
|
|
146
|
+
|
|
135
147
|
/** -------------------------------------------------------
|
|
136
148
|
* * ***Utility: `formatCurrency`.***
|
|
137
149
|
* -------------------------------------------------------
|
|
@@ -359,7 +371,8 @@ indianFormat?:boolean;};
|
|
|
359
371
|
* });
|
|
360
372
|
* // ➔ "Rp 1.121.234,00"
|
|
361
373
|
*/
|
|
362
|
-
declare const formatCurrency:(value:string|number,options?:FormatCurrencyOptions)=>string;
|
|
374
|
+
declare const formatCurrency: (value: string | number, options?: FormatCurrencyOptions) => string;
|
|
375
|
+
|
|
363
376
|
/** ----------------------------------------------------------
|
|
364
377
|
* * ***Utility: `formatNumber`.***
|
|
365
378
|
* ----------------------------------------------------------
|
|
@@ -407,7 +420,8 @@ declare const formatCurrency:(value:string|number,options?:FormatCurrencyOptions
|
|
|
407
420
|
* formatNumber("1234,56", ",");
|
|
408
421
|
* // ➔ "1,234.56"
|
|
409
422
|
*/
|
|
410
|
-
declare const formatNumber:(value:string|number,separator?:string)=>string;
|
|
423
|
+
declare const formatNumber: (value: string | number, separator?: string) => string;
|
|
424
|
+
|
|
411
425
|
/** -------------------------------------------------------
|
|
412
426
|
* * ***Output format mode for {@link formatPhoneNumber|`formatPhoneNumber`}.***
|
|
413
427
|
* -------------------------------------------------------
|
|
@@ -416,7 +430,7 @@ declare const formatNumber:(value:string|number,separator?:string)=>string;
|
|
|
416
430
|
* - `'NATIONAL'` ➔ `0812 3456 7890`
|
|
417
431
|
* - `'INTERNATIONAL'` ➔ `+62 812 3456 7890`
|
|
418
432
|
*/
|
|
419
|
-
type OutputFormat=ExtractStrict<NumberFormat,"INTERNATIONAL"|"NATIONAL"|"RFC3966"|"E.164">;
|
|
433
|
+
type OutputFormat = ExtractStrict<NumberFormat, "INTERNATIONAL" | "NATIONAL" | "RFC3966" | "E.164">;
|
|
420
434
|
/** -------------------------------------------------------
|
|
421
435
|
* * ***Single input value for {@link formatPhoneNumber|`formatPhoneNumber`}.***
|
|
422
436
|
* -------------------------------------------------------
|
|
@@ -431,7 +445,7 @@ type OutputFormat=ExtractStrict<NumberFormat,"INTERNATIONAL"|"NATIONAL"|"RFC3966
|
|
|
431
445
|
* - Prefer using a `string` if the number may begin with `0`.
|
|
432
446
|
* - E.164 international standard allows **up to 15 digits** (not counting `+`).
|
|
433
447
|
*/
|
|
434
|
-
type ValueFormatPhoneNumber=string|number|null|undefined;
|
|
448
|
+
type ValueFormatPhoneNumber = string | number | null | undefined;
|
|
435
449
|
/** -------------------------------------------------------
|
|
436
450
|
* * ***Base option set for {@link formatPhoneNumber|`formatPhoneNumber`}.***
|
|
437
451
|
* -------------------------------------------------------
|
|
@@ -446,268 +460,269 @@ type ValueFormatPhoneNumber=string|number|null|undefined;
|
|
|
446
460
|
* the regex will still validate numbers without `+`
|
|
447
461
|
* as long as the digit count ≤ **15**.
|
|
448
462
|
*/
|
|
449
|
-
type FormatPhoneNumberMain={
|
|
450
|
-
/** -------------------------------------------------------
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
separator?:string;
|
|
475
|
-
/** -------------------------------------------------------
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
outputFormat?:OutputFormat;
|
|
505
|
-
/** -------------------------------------------------------
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
prependPlusCountryCode?:boolean;
|
|
549
|
-
/** -------------------------------------------------------
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
openingNumberCountry?:string;
|
|
580
|
-
/** -------------------------------------------------------
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
closingNumberCountry?:string;
|
|
611
|
-
/** -------------------------------------------------------
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
checkValidOnly?:boolean;
|
|
648
|
-
/** -------------------------------------------------------
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
takeNumberOnly?:boolean;
|
|
694
|
-
/** -------------------------------------------------------
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
defaultCountry?:CountryCode;
|
|
463
|
+
type FormatPhoneNumberMain = {
|
|
464
|
+
/** -------------------------------------------------------
|
|
465
|
+
* * ***Separator for formatted output.***
|
|
466
|
+
* -------------------------------------------------------
|
|
467
|
+
* **Defines the string used to separate groups of digits**
|
|
468
|
+
* in the formatted phone number.
|
|
469
|
+
* - **Default:** `" "`.
|
|
470
|
+
* - **Executed only when:**
|
|
471
|
+
* - Parameter options `checkValidOnly` and `takeNumberOnly` are both `false`.
|
|
472
|
+
* - (This option is ignored if either `checkValidOnly` or `takeNumberOnly` is `true`.)
|
|
473
|
+
* - **Behavior:**
|
|
474
|
+
* - The formatter inserts this separator between number blocks
|
|
475
|
+
* according to the selected `outputFormat`.
|
|
476
|
+
* @default " "
|
|
477
|
+
* @example
|
|
478
|
+
* ```ts
|
|
479
|
+
* // Using dash as separator
|
|
480
|
+
* formatPhoneNumber("081234567890", { defaultCountry: "ID", separator: "-" });
|
|
481
|
+
* // ➔ "+62 812-3456-7890"
|
|
482
|
+
*
|
|
483
|
+
* // Using space as separator
|
|
484
|
+
* formatPhoneNumber("(151) 2345-6789", { defaultCountry: "DE", separator: " " });
|
|
485
|
+
* // ➔ "+49 1512 3456789"
|
|
486
|
+
* ```
|
|
487
|
+
*/
|
|
488
|
+
separator?: string;
|
|
489
|
+
/** -------------------------------------------------------
|
|
490
|
+
* * ***Output format style for the returned phone number.***
|
|
491
|
+
* -------------------------------------------------------
|
|
492
|
+
* **Determines how the formatted phone number string is returned.**
|
|
493
|
+
*
|
|
494
|
+
* - **Default:** `"INTERNATIONAL"`.
|
|
495
|
+
* - **Applicable only when:**
|
|
496
|
+
* - Parameter options `checkValidOnly` and `takeNumberOnly`
|
|
497
|
+
* are both **`false`**.
|
|
498
|
+
* - (Ignored if either of those options is `true`.)
|
|
499
|
+
*
|
|
500
|
+
* - **Supported values (from {@link NumberFormat}):**
|
|
501
|
+
* - `"NATIONAL"` – Local/national format, e.g. `0812 3456 7890`.
|
|
502
|
+
* - `"INTERNATIONAL"` – International format with leading plus, e.g. `+62 812 3456 7890`.
|
|
503
|
+
* - `"E.164"` – Compact E.164 format, e.g. `+6281234567890`.
|
|
504
|
+
* - `"RFC3966"` – RFC 3966 URI format, e.g. `tel:+62-812-3456-7890`.
|
|
505
|
+
*
|
|
506
|
+
* @default "INTERNATIONAL"
|
|
507
|
+
* @example
|
|
508
|
+
* ```ts
|
|
509
|
+
* // Returns a national-format string
|
|
510
|
+
* formatPhoneNumber("+62 81234567890", { outputFormat: "NATIONAL" });
|
|
511
|
+
* // ➔ "0812 3456 7890"
|
|
512
|
+
*
|
|
513
|
+
* // Returns an E.164-format string
|
|
514
|
+
* formatPhoneNumber("+62 81234567890", { outputFormat: "E.164" });
|
|
515
|
+
* // ➔ "+6281234567890"
|
|
516
|
+
* ```
|
|
517
|
+
*/
|
|
518
|
+
outputFormat?: OutputFormat;
|
|
519
|
+
/** -------------------------------------------------------
|
|
520
|
+
* * ***Prepend a plus sign and country calling code.***
|
|
521
|
+
* -------------------------------------------------------
|
|
522
|
+
* **Forces the returned phone number to start with a leading `+`
|
|
523
|
+
* followed by the detected country calling code (e.g. `+63`, `+1`).**
|
|
524
|
+
* - **Default:** `true`.
|
|
525
|
+
* - **Executed only when:**
|
|
526
|
+
* - Parameter options `outputFormat` is set to `"INTERNATIONAL"`.
|
|
527
|
+
* - (This option is ignored for `"NATIONAL"`, `"E.164"` or `"RFC3966"` formats.).
|
|
528
|
+
* - **Applicable when:**
|
|
529
|
+
* - You want to guarantee that the result
|
|
530
|
+
* always contains a plus sign and country code, regardless of
|
|
531
|
+
* the selected `outputFormat`.
|
|
532
|
+
* - **Behavior:**
|
|
533
|
+
* - When `true`, the formatter ensures the output begins with
|
|
534
|
+
* a `+` and the correct country code.
|
|
535
|
+
* - When `false`, the output follows the chosen `outputFormat`
|
|
536
|
+
* without forcing a `+` prefix.
|
|
537
|
+
* @default true
|
|
538
|
+
* @example
|
|
539
|
+
* ```ts
|
|
540
|
+
* // Automatically adds +63 (default: `true`) even if input is local format
|
|
541
|
+
* formatPhoneNumber("09171234567", {
|
|
542
|
+
* country: "PH",
|
|
543
|
+
* prependPlusCountryCode: true
|
|
544
|
+
* });
|
|
545
|
+
* // ➔ "+63 917 123 4567"
|
|
546
|
+
*
|
|
547
|
+
* formatPhoneNumber("09171234567", {
|
|
548
|
+
* country: "PH",
|
|
549
|
+
* prependPlusCountryCode: false
|
|
550
|
+
* });
|
|
551
|
+
* // ➔ "63 917 123 4567"
|
|
552
|
+
*
|
|
553
|
+
* // Leaves number in national format (no plus sign)
|
|
554
|
+
* formatPhoneNumber("+63 9171234567", {
|
|
555
|
+
* country: "PH",
|
|
556
|
+
* prependPlusCountryCode: false,
|
|
557
|
+
* outputFormat: "NATIONAL"
|
|
558
|
+
* });
|
|
559
|
+
* // ➔ "0917 123 4567"
|
|
560
|
+
* ```
|
|
561
|
+
*/
|
|
562
|
+
prependPlusCountryCode?: boolean;
|
|
563
|
+
/** -------------------------------------------------------
|
|
564
|
+
* * ***Characters before the country code (e.g. `"("`).***
|
|
565
|
+
* -------------------------------------------------------
|
|
566
|
+
* **Adds a custom string that appears **immediately before** the
|
|
567
|
+
* international country calling code when formatting.**
|
|
568
|
+
* - **Default:** `""` (empty string).
|
|
569
|
+
* - **Behavior:**
|
|
570
|
+
* - **Active only when:**
|
|
571
|
+
* - `checkValidOnly` is **false**,
|
|
572
|
+
* - `takeNumberOnly` is **false**, **and**
|
|
573
|
+
* - `outputFormat` is `"INTERNATIONAL"`.
|
|
574
|
+
* - **Ignored if:**
|
|
575
|
+
* - The value is an empty string (after trimming),
|
|
576
|
+
* - `checkValidOnly` or `takeNumberOnly` is `true`,
|
|
577
|
+
* - `outputFormat` is not `"INTERNATIONAL"`,
|
|
578
|
+
* - `closingNumberCountry` is `undefined` or an empty string (after trimming).
|
|
579
|
+
* - **Invalid input:**
|
|
580
|
+
* - Returns no effect if the phone number is invalid or not compatible
|
|
581
|
+
* with the selected `defaultCountry`.
|
|
582
|
+
* @default ""
|
|
583
|
+
* @example
|
|
584
|
+
* ```ts
|
|
585
|
+
* formatPhoneNumber("+63 9171234567", {
|
|
586
|
+
* outputFormat: "INTERNATIONAL",
|
|
587
|
+
* openingNumberCountry: "(",
|
|
588
|
+
* closingNumberCountry: ")"
|
|
589
|
+
* });
|
|
590
|
+
* // ➔ "(+63) 917 123 4567"
|
|
591
|
+
* ```
|
|
592
|
+
*/
|
|
593
|
+
openingNumberCountry?: string;
|
|
594
|
+
/** -------------------------------------------------------
|
|
595
|
+
* * ***Characters after the country code (e.g. `")"`).***
|
|
596
|
+
* -------------------------------------------------------
|
|
597
|
+
* **Adds a custom string that appears **immediately after** the
|
|
598
|
+
* international country calling code when formatting.**
|
|
599
|
+
* - **Default:** `""` (empty string).
|
|
600
|
+
* - **Behavior:**
|
|
601
|
+
* - **Active only when:**
|
|
602
|
+
* - `checkValidOnly` is **false**,
|
|
603
|
+
* - `takeNumberOnly` is **false**, **and**
|
|
604
|
+
* - `outputFormat` is `"INTERNATIONAL"`.
|
|
605
|
+
* - **Ignored if:**
|
|
606
|
+
* - The value is an empty string (after trimming),
|
|
607
|
+
* - `checkValidOnly` or `takeNumberOnly` is `true`,
|
|
608
|
+
* - `outputFormat` is not `"INTERNATIONAL"`,
|
|
609
|
+
* - `openingNumberCountry` is `undefined` or an empty string (after trimming).
|
|
610
|
+
* - **Invalid input:**
|
|
611
|
+
* Returns no effect if the phone number is invalid or not compatible
|
|
612
|
+
* with the selected `defaultCountry`.
|
|
613
|
+
* @default ""
|
|
614
|
+
* @example
|
|
615
|
+
* ```ts
|
|
616
|
+
* formatPhoneNumber("+63 9171234567", {
|
|
617
|
+
* outputFormat: "INTERNATIONAL",
|
|
618
|
+
* openingNumberCountry: "(",
|
|
619
|
+
* closingNumberCountry: ")"
|
|
620
|
+
* });
|
|
621
|
+
* // ➔ "(+63) 917 123 4567"
|
|
622
|
+
* ```
|
|
623
|
+
*/
|
|
624
|
+
closingNumberCountry?: string;
|
|
625
|
+
/** -------------------------------------------------------
|
|
626
|
+
* * ***Return only a boolean validity flag.***
|
|
627
|
+
* -------------------------------------------------------
|
|
628
|
+
* - ***Behavior:***
|
|
629
|
+
* - **Exclusive mode:**
|
|
630
|
+
* - ⚠️ When `true`, all formatting options and `takeNumberOnly` must be omitted or are ignored.
|
|
631
|
+
* - Conflicts with `takeNumberOnly`:
|
|
632
|
+
* - ⚠️ When `checkValidOnly` is `true` and all formatting options and `takeNumberOnly` must be
|
|
633
|
+
* omitted or are ignored.
|
|
634
|
+
* - But if mistake passing props:
|
|
635
|
+
* - ⚠️ When `checkValidOnly` is `true` and other of formatting options was passing:
|
|
636
|
+
* - If `takeNumberOnly` is `true` or `false`:
|
|
637
|
+
* - Will return a `boolean` because `checkValidOnly` is prioritize first.
|
|
638
|
+
* - Output:
|
|
639
|
+
* - Boolean ➔ (`true` or `false`).
|
|
640
|
+
* - ***DefaultValue: false***
|
|
641
|
+
* @default false
|
|
642
|
+
* @example
|
|
643
|
+
* ```ts
|
|
644
|
+
* // Returns `true` if valid number and number with country code (no need `defaultCountry`)
|
|
645
|
+
* formatPhoneNumber("+63 912-123-4567", { checkValidOnly: true });
|
|
646
|
+
* // ➔ true
|
|
647
|
+
*
|
|
648
|
+
* // Returns `true` if valid number and number without country code but with `defaultCountry`
|
|
649
|
+
* formatPhoneNumber("213-373-4253", { defaultCountry: "US", checkValidOnly: true });
|
|
650
|
+
* // ➔ true
|
|
651
|
+
*
|
|
652
|
+
* // Returns `false` if without country code.
|
|
653
|
+
* formatPhoneNumber("213-373-4253", { checkValidOnly: true });
|
|
654
|
+
* // ➔ false
|
|
655
|
+
*
|
|
656
|
+
* // Returns `false` for invalid number.
|
|
657
|
+
* formatPhoneNumber("abcd", { checkValidOnly: true });
|
|
658
|
+
* // ➔ false
|
|
659
|
+
* ```
|
|
660
|
+
*/
|
|
661
|
+
checkValidOnly?: boolean;
|
|
662
|
+
/** -------------------------------------------------------
|
|
663
|
+
* * ***Return only the digits of the phone number (local number only).***
|
|
664
|
+
* -------------------------------------------------------
|
|
665
|
+
* **Returns a string containing only numeric characters** from the **local number**,
|
|
666
|
+
* ignoring any country code, spaces, plus signs, or separators.
|
|
667
|
+
* - **Default:** `false`
|
|
668
|
+
* - **Behavior:**
|
|
669
|
+
* - **Exclusive mode:**
|
|
670
|
+
* - ⚠️ When set to `true`, all formatting options
|
|
671
|
+
* (`outputFormat`, `prependPlusCountryCode`, etc.)
|
|
672
|
+
* and `checkValidOnly` **must be omitted** or will be **ignored**.
|
|
673
|
+
* - **Conflict handling with `checkValidOnly`:**
|
|
674
|
+
* - If both `takeNumberOnly` and `checkValidOnly` are `true`,
|
|
675
|
+
* `checkValidOnly` takes priority and the function
|
|
676
|
+
* returns a `boolean`.
|
|
677
|
+
* - If `checkValidOnly` is `false` (or not provided),
|
|
678
|
+
* and `takeNumberOnly` is `true`,
|
|
679
|
+
* the function returns a **numeric string of the local number**.
|
|
680
|
+
* - **Invalid input:**
|
|
681
|
+
* - If the input is invalid or cannot be parsed
|
|
682
|
+
* (e.g. not matching the `defaultCountry`),
|
|
683
|
+
* the function returns an **empty string** (`""`).
|
|
684
|
+
* - **Output example:**
|
|
685
|
+
* - Valid input ➔ `"81234567890"` // country code removed
|
|
686
|
+
* - Invalid input ➔ `""`
|
|
687
|
+
* @default false
|
|
688
|
+
* @example
|
|
689
|
+
* ```ts
|
|
690
|
+
* // Returns only digits of the local number with country code (no need `defaultCountry`)
|
|
691
|
+
* formatPhoneNumber("+63 912-123-4567", { takeNumberOnly: true });
|
|
692
|
+
* // ➔ "09121234567"
|
|
693
|
+
*
|
|
694
|
+
* // Returns only digits of the local number without country code but with `defaultCountry`
|
|
695
|
+
* formatPhoneNumber("213-373-4253", { defaultCountry: "US", takeNumberOnly: true });
|
|
696
|
+
* // ➔ "2133734253"
|
|
697
|
+
*
|
|
698
|
+
* // Returns empty string if without country code.
|
|
699
|
+
* formatPhoneNumber("213-373-4253", { takeNumberOnly: true });
|
|
700
|
+
* // ➔ ""
|
|
701
|
+
*
|
|
702
|
+
* // Returns empty string for invalid number.
|
|
703
|
+
* formatPhoneNumber("abcd", { takeNumberOnly: true });
|
|
704
|
+
* // ➔ ""
|
|
705
|
+
* ```
|
|
706
|
+
*/
|
|
707
|
+
takeNumberOnly?: boolean;
|
|
708
|
+
/** -------------------------------------------------------
|
|
709
|
+
* * ***A "country code" is a two-letter ISO ([`ISO-3166-1 alpha-2`](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements)) country code (like `"US"` | `"ID"` | `"DE"`).***
|
|
710
|
+
* -------------------------------------------------------
|
|
711
|
+
* **Used to interpret numbers without an explicit `+<countryCode>`.**
|
|
712
|
+
* - ***Behavior:***
|
|
713
|
+
* - Required if the input without country code (`+`).
|
|
714
|
+
* - Ignored if the input already starts with `+`.
|
|
715
|
+
* - ***Examples:***
|
|
716
|
+
* - `"ID"` ➔ Indonesian.
|
|
717
|
+
* - `"US"` ➔ United States.
|
|
718
|
+
* - `"GB"` ➔ United Kingdom.
|
|
719
|
+
* - ***DefaultValue: `undefined`***.
|
|
720
|
+
* @example
|
|
721
|
+
* formatPhoneNumber("081234567890", { defaultCountry: "ID" });
|
|
722
|
+
* @default undefined
|
|
723
|
+
*/
|
|
724
|
+
defaultCountry?: CountryCode;
|
|
725
|
+
};
|
|
711
726
|
/** -------------------------------------------------------
|
|
712
727
|
* * ***Specialized options for the `transformPhoneNumber` variant of {@link formatPhoneNumber|`formatPhoneNumber`}.***
|
|
713
728
|
* -------------------------------------------------------
|
|
@@ -719,106 +734,109 @@ defaultCountry?:CountryCode;};
|
|
|
719
734
|
*
|
|
720
735
|
* **Example Output:** `+62 812 3456 7890`
|
|
721
736
|
*/
|
|
722
|
-
type FormatPhoneNumberTransform=OverrideTypes<FormatPhoneNumberMain,{
|
|
723
|
-
/** -------------------------------------------------------
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
checkValidOnly?:never;
|
|
743
|
-
/** -------------------------------------------------------
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
takeNumberOnly?:never;
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
*
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
*
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
*
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
737
|
+
type FormatPhoneNumberTransform = OverrideTypes<FormatPhoneNumberMain, {
|
|
738
|
+
/** -------------------------------------------------------
|
|
739
|
+
* * ***Return only a boolean validity flag.***
|
|
740
|
+
* -------------------------------------------------------
|
|
741
|
+
* - ***Behavior:***
|
|
742
|
+
* - **Exclusive mode:**
|
|
743
|
+
* - ⚠️ When `true`, all formatting options and `takeNumberOnly` must be omitted or are ignored.
|
|
744
|
+
* - Conflicts with `takeNumberOnly`:
|
|
745
|
+
* - ⚠️ When `checkValidOnly` is `true` and all formatting options and `takeNumberOnly` must be
|
|
746
|
+
* omitted or are ignored.
|
|
747
|
+
* - But if mistake passing props:
|
|
748
|
+
* - ⚠️ When `checkValidOnly` is `true` and other of formatting options was passing:
|
|
749
|
+
* - If `takeNumberOnly` is `true` or `false`:
|
|
750
|
+
* - Will return a `boolean` because `checkValidOnly` is prioritize first.
|
|
751
|
+
* - Output:
|
|
752
|
+
* - Boolean ➔ (`true` or `false`).
|
|
753
|
+
* - ***DefaultValue: false***
|
|
754
|
+
* @default false
|
|
755
|
+
* @requires `false` or `undefined`
|
|
756
|
+
*/
|
|
757
|
+
checkValidOnly?: never;
|
|
758
|
+
/** -------------------------------------------------------
|
|
759
|
+
* * ***Return only the digits of the phone number (local number only).***
|
|
760
|
+
* -------------------------------------------------------
|
|
761
|
+
* **Returns a string containing only numeric characters** from the **local number**,
|
|
762
|
+
* ignoring any country code, spaces, plus signs, or separators.
|
|
763
|
+
* - **Default:** `false`
|
|
764
|
+
* - **Behavior:**
|
|
765
|
+
* - **Exclusive mode:**
|
|
766
|
+
* - ⚠️ When set to `true`, all formatting options
|
|
767
|
+
* (`outputFormat`, `prependPlusCountryCode`, etc.)
|
|
768
|
+
* and `checkValidOnly` **must be omitted** or will be **ignored**.
|
|
769
|
+
* - **Conflict handling with `checkValidOnly`:**
|
|
770
|
+
* - If both `takeNumberOnly` and `checkValidOnly` are `true`,
|
|
771
|
+
* `checkValidOnly` takes priority and the function
|
|
772
|
+
* returns a `boolean`.
|
|
773
|
+
* - If `checkValidOnly` is `false` (or not provided),
|
|
774
|
+
* and `takeNumberOnly` is `true`,
|
|
775
|
+
* the function returns a **numeric string of the local number**.
|
|
776
|
+
* - **Invalid input:**
|
|
777
|
+
* - If the input is invalid or cannot be parsed
|
|
778
|
+
* (e.g. not matching the `defaultCountry`),
|
|
779
|
+
* the function returns an **empty string** (`""`).
|
|
780
|
+
* - **Output example:**
|
|
781
|
+
* - Valid input ➔ `"81234567890"` // country code removed
|
|
782
|
+
* - Invalid input ➔ `""`
|
|
783
|
+
* @default false
|
|
784
|
+
* @requires `false` or `undefined`
|
|
785
|
+
*/
|
|
786
|
+
takeNumberOnly?: never;
|
|
787
|
+
}>;
|
|
788
|
+
type NeverForRestFormatPhoneNumberTransform = {
|
|
789
|
+
/** -------------------------------------------------------
|
|
790
|
+
* * ***Not used in this mode **`(Never allowed in this mode)`**.***
|
|
791
|
+
* -------------------------------------------------------
|
|
792
|
+
* - ***Behavior:***
|
|
793
|
+
* - **Exclusive mode:**
|
|
794
|
+
* - ⚠️ When `true`, all formatting options must be omitted or are ignored.
|
|
795
|
+
* - Conflicts with `takeNumberOnly` and `checkValidOnly`:
|
|
796
|
+
* - If both `takeNumberOnly` and `checkValidOnly` are `true`,
|
|
797
|
+
* `checkValidOnly` takes priority and the function
|
|
798
|
+
* returns a `boolean`.
|
|
799
|
+
* - If `checkValidOnly` is `false` (or not provided),
|
|
800
|
+
* and `takeNumberOnly` is `true`,
|
|
801
|
+
* the function returns a **numeric string of the local number**.
|
|
802
|
+
* @requires `undefined`
|
|
803
|
+
*/
|
|
804
|
+
separator?: never;
|
|
805
|
+
/** -------------------------------------------------------
|
|
806
|
+
* * ***Not used in this mode **`(Never allowed in this mode)`**.***
|
|
807
|
+
* -------------------------------------------------------
|
|
808
|
+
* - ***Behavior:***
|
|
809
|
+
* - **Exclusive mode:**
|
|
810
|
+
* - ⚠️ When `true`, all formatting options must be omitted or are ignored.
|
|
811
|
+
* - Conflicts with `takeNumberOnly` and `checkValidOnly`:
|
|
812
|
+
* - If both `takeNumberOnly` and `checkValidOnly` are `true`,
|
|
813
|
+
* `checkValidOnly` takes priority and the function
|
|
814
|
+
* returns a `boolean`.
|
|
815
|
+
* - If `checkValidOnly` is `false` (or not provided),
|
|
816
|
+
* and `takeNumberOnly` is `true`,
|
|
817
|
+
* the function returns a **numeric string of the local number**.
|
|
818
|
+
*
|
|
819
|
+
* @requires `undefined`
|
|
820
|
+
*/
|
|
821
|
+
openingNumberCountry?: never;
|
|
822
|
+
/** -------------------------------------------------------
|
|
823
|
+
* * ***Not used in this mode **`(Never allowed in this mode)`**.***
|
|
824
|
+
* -------------------------------------------------------
|
|
825
|
+
* - ***Behavior:***
|
|
826
|
+
* - **Exclusive mode:**
|
|
827
|
+
* - ⚠️ When `true`, all formatting options must be omitted or are ignored.
|
|
828
|
+
* - Conflicts with `takeNumberOnly` and `checkValidOnly`:
|
|
829
|
+
* - If both `takeNumberOnly` and `checkValidOnly` are `true`,
|
|
830
|
+
* `checkValidOnly` takes priority and the function
|
|
831
|
+
* returns a `boolean`.
|
|
832
|
+
* - If `checkValidOnly` is `false` (or not provided),
|
|
833
|
+
* and `takeNumberOnly` is `true`,
|
|
834
|
+
* the function returns a **numeric string of the local number**.
|
|
835
|
+
*
|
|
836
|
+
* @requires `undefined`
|
|
837
|
+
*/
|
|
838
|
+
closingNumberCountry?: never;
|
|
839
|
+
};
|
|
822
840
|
/** -------------------------------------------------------
|
|
823
841
|
* * ***Options subset for **validity-check mode** of
|
|
824
842
|
* {@link formatPhoneNumber|`formatPhoneNumber`}.***
|
|
@@ -832,55 +850,56 @@ closingNumberCountry?:never;};
|
|
|
832
850
|
* formatPhoneNumber("+6281234567890", { checkValidOnly: true }) // boolean
|
|
833
851
|
* ```
|
|
834
852
|
*/
|
|
835
|
-
type FormatPhoneNumberCheckValidOnly=Prettify<OverrideTypes<FormatPhoneNumberMain,{
|
|
836
|
-
/** -------------------------------------------------------
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
checkValidOnly:true;
|
|
855
|
-
/** -------------------------------------------------------
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
takeNumberOnly?:false;
|
|
853
|
+
type FormatPhoneNumberCheckValidOnly = Prettify<OverrideTypes<FormatPhoneNumberMain, {
|
|
854
|
+
/** -------------------------------------------------------
|
|
855
|
+
* * ***Return only a boolean validity flag.***
|
|
856
|
+
* -------------------------------------------------------
|
|
857
|
+
* - ***Behavior:***
|
|
858
|
+
* - **Exclusive mode:**
|
|
859
|
+
* - ⚠️ When `true`, all formatting options and `takeNumberOnly` must be omitted or are ignored.
|
|
860
|
+
* - Conflicts with `takeNumberOnly`:
|
|
861
|
+
* - ⚠️ When `checkValidOnly` is `true` and all formatting options and `takeNumberOnly` must be
|
|
862
|
+
* omitted or are ignored.
|
|
863
|
+
* - But if mistake passing props:
|
|
864
|
+
* - ⚠️ When `checkValidOnly` is `true` and other of formatting options was passing:
|
|
865
|
+
* - If `takeNumberOnly` is `true` or `false`:
|
|
866
|
+
* - Will return a `boolean` because `checkValidOnly` is prioritize first.
|
|
867
|
+
* - Output:
|
|
868
|
+
* - Boolean ➔ (`true` or `false`).
|
|
869
|
+
* - ***DefaultValue: false***
|
|
870
|
+
* @default false
|
|
871
|
+
*/
|
|
872
|
+
checkValidOnly: true;
|
|
873
|
+
/** -------------------------------------------------------
|
|
874
|
+
* * ***Return only the digits of the phone number (local number only).***
|
|
875
|
+
* -------------------------------------------------------
|
|
876
|
+
* **Returns a string containing only numeric characters** from the **local number**,
|
|
877
|
+
* ignoring any country code, spaces, plus signs, or separators.
|
|
878
|
+
* - **Default:** `false`
|
|
879
|
+
* - **Behavior:**
|
|
880
|
+
* - **Exclusive mode:**
|
|
881
|
+
* - ⚠️ When set to `true`, all formatting options
|
|
882
|
+
* (`outputFormat`, `prependPlusCountryCode`, etc.)
|
|
883
|
+
* and `checkValidOnly` **must be omitted** or will be **ignored**.
|
|
884
|
+
* - **Conflict handling with `checkValidOnly`:**
|
|
885
|
+
* - If both `takeNumberOnly` and `checkValidOnly` are `true`,
|
|
886
|
+
* `checkValidOnly` takes priority and the function
|
|
887
|
+
* returns a `boolean`.
|
|
888
|
+
* - If `checkValidOnly` is `false` (or not provided),
|
|
889
|
+
* and `takeNumberOnly` is `true`,
|
|
890
|
+
* the function returns a **numeric string of the local number**.
|
|
891
|
+
* - **Invalid input:**
|
|
892
|
+
* - If the input is invalid or cannot be parsed
|
|
893
|
+
* (e.g. not matching the `defaultCountry`),
|
|
894
|
+
* the function returns an **empty string** (`""`).
|
|
895
|
+
* - **Output example:**
|
|
896
|
+
* - Valid input ➔ `"81234567890"` // country code removed
|
|
897
|
+
* - Invalid input ➔ `""`
|
|
898
|
+
* @default false
|
|
899
|
+
* @requires `false` or `undefined`
|
|
900
|
+
*/
|
|
901
|
+
takeNumberOnly?: false;
|
|
902
|
+
} & NeverForRestFormatPhoneNumberTransform>>;
|
|
884
903
|
/** -------------------------------------------------------
|
|
885
904
|
* * ***Options subset for calling {@link formatPhoneNumber|`formatPhoneNumber`} in
|
|
886
905
|
* **digits-only mode**.***
|
|
@@ -893,214 +912,219 @@ takeNumberOnly?:false;}& NeverForRestFormatPhoneNumberTransform>>;
|
|
|
893
912
|
*
|
|
894
913
|
* **Example Output:** `"6281234567890"`
|
|
895
914
|
*/
|
|
896
|
-
type FormatPhoneNumberTakeNumberOnly=Prettify<OverrideTypes<FormatPhoneNumberMain,{
|
|
897
|
-
/** -------------------------------------------------------
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
checkValidOnly?:false;
|
|
917
|
-
/** -------------------------------------------------------
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
takeNumberOnly:true;
|
|
915
|
+
type FormatPhoneNumberTakeNumberOnly = Prettify<OverrideTypes<FormatPhoneNumberMain, {
|
|
916
|
+
/** -------------------------------------------------------
|
|
917
|
+
* * ***Return only a boolean validity flag.***
|
|
918
|
+
* -------------------------------------------------------
|
|
919
|
+
* - ***Behavior:***
|
|
920
|
+
* - **Exclusive mode:**
|
|
921
|
+
* - ⚠️ When `true`, all formatting options and `takeNumberOnly` must be omitted or are ignored.
|
|
922
|
+
* - Conflicts with `takeNumberOnly`:
|
|
923
|
+
* - ⚠️ When `checkValidOnly` is `true` and all formatting options and `takeNumberOnly` must be
|
|
924
|
+
* omitted or are ignored.
|
|
925
|
+
* - But if mistake passing props:
|
|
926
|
+
* - ⚠️ When `checkValidOnly` is `true` and other of formatting options was passing:
|
|
927
|
+
* - If `takeNumberOnly` is `true` or `false`:
|
|
928
|
+
* - Will return a `boolean` because `checkValidOnly` is prioritize first.
|
|
929
|
+
* - Output:
|
|
930
|
+
* - Boolean ➔ (`true` or `false`).
|
|
931
|
+
* - ***DefaultValue: false***
|
|
932
|
+
* @default false
|
|
933
|
+
* @requires `false` or `undefined`
|
|
934
|
+
*/
|
|
935
|
+
checkValidOnly?: false;
|
|
936
|
+
/** -------------------------------------------------------
|
|
937
|
+
* * ***Return only the digits of the phone number (local number only).***
|
|
938
|
+
* -------------------------------------------------------
|
|
939
|
+
* **Returns a string containing only numeric characters** from the **local number**,
|
|
940
|
+
* ignoring any country code, spaces, plus signs, or separators.
|
|
941
|
+
* - **Default:** `false`
|
|
942
|
+
* - **Behavior:**
|
|
943
|
+
* - **Exclusive mode:**
|
|
944
|
+
* - ⚠️ When set to `true`, all formatting options
|
|
945
|
+
* (`outputFormat`, `prependPlusCountryCode`, etc.)
|
|
946
|
+
* and `checkValidOnly` **must be omitted** or will be **ignored**.
|
|
947
|
+
* - **Conflict handling with `checkValidOnly`:**
|
|
948
|
+
* - If both `takeNumberOnly` and `checkValidOnly` are `true`,
|
|
949
|
+
* `checkValidOnly` takes priority and the function
|
|
950
|
+
* returns a `boolean`.
|
|
951
|
+
* - If `checkValidOnly` is `false` (or not provided),
|
|
952
|
+
* and `takeNumberOnly` is `true`,
|
|
953
|
+
* the function returns a **numeric string of the local number**.
|
|
954
|
+
* - **Invalid input:**
|
|
955
|
+
* - If the input is invalid or cannot be parsed
|
|
956
|
+
* (e.g. not matching the `defaultCountry`),
|
|
957
|
+
* the function returns an **empty string** (`""`).
|
|
958
|
+
* - **Output example:**
|
|
959
|
+
* - Valid input ➔ `"81234567890"` // country code removed
|
|
960
|
+
* - Invalid input ➔ `""`
|
|
961
|
+
* @default false
|
|
962
|
+
*/
|
|
963
|
+
takeNumberOnly: true;
|
|
964
|
+
} & NeverForRestFormatPhoneNumberTransform>>;
|
|
945
965
|
/** -------------------------------------------------------
|
|
946
966
|
* * ***Options subset for calling {@link formatPhoneNumber|`formatPhoneNumber`} force to **Validity-check Mode**.***
|
|
947
967
|
* -------------------------------------------------------
|
|
948
968
|
*/
|
|
949
|
-
type FormatPhoneNumberAllPassing=OverrideTypes<FormatPhoneNumberMain,{
|
|
950
|
-
/** -------------------------------------------------------
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
checkValidOnly:true;
|
|
969
|
-
/** -------------------------------------------------------
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
takeNumberOnly:true;
|
|
969
|
+
type FormatPhoneNumberAllPassing = OverrideTypes<FormatPhoneNumberMain, {
|
|
970
|
+
/** -------------------------------------------------------
|
|
971
|
+
* * ***Return only a boolean validity flag.***
|
|
972
|
+
* -------------------------------------------------------
|
|
973
|
+
* - ***Behavior:***
|
|
974
|
+
* - **Exclusive mode:**
|
|
975
|
+
* - ⚠️ When `true`, all formatting options and `takeNumberOnly` must be omitted or are ignored.
|
|
976
|
+
* - Conflicts with `takeNumberOnly`:
|
|
977
|
+
* - ⚠️ When `checkValidOnly` is `true` and all formatting options and `takeNumberOnly` must be
|
|
978
|
+
* omitted or are ignored.
|
|
979
|
+
* - But if mistake passing props:
|
|
980
|
+
* - ⚠️ When `checkValidOnly` is `true` and other of formatting options was passing:
|
|
981
|
+
* - If `takeNumberOnly` is `true` or `false`:
|
|
982
|
+
* - Will return a `boolean` because `checkValidOnly` is prioritize first.
|
|
983
|
+
* - Output:
|
|
984
|
+
* - Boolean ➔ (`true` or `false`).
|
|
985
|
+
* - ***DefaultValue: false***
|
|
986
|
+
* @default false
|
|
987
|
+
*/
|
|
988
|
+
checkValidOnly: true;
|
|
989
|
+
/** -------------------------------------------------------
|
|
990
|
+
* * ***Return only the digits of the phone number (local number only).***
|
|
991
|
+
* -------------------------------------------------------
|
|
992
|
+
* **Returns a string containing only numeric characters** from the **local number**,
|
|
993
|
+
* ignoring any country code, spaces, plus signs, or separators.
|
|
994
|
+
* - **Default:** `false`
|
|
995
|
+
* - **Behavior:**
|
|
996
|
+
* - **Exclusive mode:**
|
|
997
|
+
* - ⚠️ When set to `true`, all formatting options
|
|
998
|
+
* (`outputFormat`, `prependPlusCountryCode`, etc.)
|
|
999
|
+
* and `checkValidOnly` **must be omitted** or will be **ignored**.
|
|
1000
|
+
* - **Conflict handling with `checkValidOnly`:**
|
|
1001
|
+
* - If both `takeNumberOnly` and `checkValidOnly` are `true`,
|
|
1002
|
+
* `checkValidOnly` takes priority and the function
|
|
1003
|
+
* returns a `boolean`.
|
|
1004
|
+
* - If `checkValidOnly` is `false` (or not provided),
|
|
1005
|
+
* and `takeNumberOnly` is `true`,
|
|
1006
|
+
* the function returns a **numeric string of the local number**.
|
|
1007
|
+
* - **Invalid input:**
|
|
1008
|
+
* - If the input is invalid or cannot be parsed
|
|
1009
|
+
* (e.g. not matching the `defaultCountry`),
|
|
1010
|
+
* the function returns an **empty string** (`""`).
|
|
1011
|
+
* - **Output example:**
|
|
1012
|
+
* - Valid input ➔ `"81234567890"` // country code removed
|
|
1013
|
+
* - Invalid input ➔ `""`
|
|
1014
|
+
* @default false
|
|
1015
|
+
* @requires `false` or `undefined`
|
|
1016
|
+
*/
|
|
1017
|
+
takeNumberOnly: true;
|
|
1018
|
+
}>;
|
|
998
1019
|
/** -------------------------------------------------------
|
|
999
1020
|
* * ***Options subset for calling {@link formatPhoneNumber|`formatPhoneNumber`} force to **Validity-check Mode**.***
|
|
1000
1021
|
* -------------------------------------------------------
|
|
1001
1022
|
*/
|
|
1002
|
-
type FormatPhoneNumberAllPassingValidOnly=OverrideTypes<FormatPhoneNumberMain,{
|
|
1003
|
-
/** -------------------------------------------------------
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
checkValidOnly:true;
|
|
1022
|
-
/** -------------------------------------------------------
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
takeNumberOnly?:false;
|
|
1023
|
+
type FormatPhoneNumberAllPassingValidOnly = OverrideTypes<FormatPhoneNumberMain, {
|
|
1024
|
+
/** -------------------------------------------------------
|
|
1025
|
+
* * ***Return only a boolean validity flag.***
|
|
1026
|
+
* -------------------------------------------------------
|
|
1027
|
+
* - ***Behavior:***
|
|
1028
|
+
* - **Exclusive mode:**
|
|
1029
|
+
* - ⚠️ When `true`, all formatting options and `takeNumberOnly` must be omitted or are ignored.
|
|
1030
|
+
* - Conflicts with `takeNumberOnly`:
|
|
1031
|
+
* - ⚠️ When `checkValidOnly` is `true` and all formatting options and `takeNumberOnly` must be
|
|
1032
|
+
* omitted or are ignored.
|
|
1033
|
+
* - But if mistake passing props:
|
|
1034
|
+
* - ⚠️ When `checkValidOnly` is `true` and other of formatting options was passing:
|
|
1035
|
+
* - If `takeNumberOnly` is `true` or `false`:
|
|
1036
|
+
* - Will return a `boolean` because `checkValidOnly` is prioritize first.
|
|
1037
|
+
* - Output:
|
|
1038
|
+
* - Boolean ➔ (`true` or `false`).
|
|
1039
|
+
* - ***DefaultValue: false***
|
|
1040
|
+
* @default false
|
|
1041
|
+
*/
|
|
1042
|
+
checkValidOnly: true;
|
|
1043
|
+
/** -------------------------------------------------------
|
|
1044
|
+
* * ***Return only the digits of the phone number (local number only).***
|
|
1045
|
+
* -------------------------------------------------------
|
|
1046
|
+
* **Returns a string containing only numeric characters** from the **local number**,
|
|
1047
|
+
* ignoring any country code, spaces, plus signs, or separators.
|
|
1048
|
+
* - **Default:** `false`
|
|
1049
|
+
* - **Behavior:**
|
|
1050
|
+
* - **Exclusive mode:**
|
|
1051
|
+
* - ⚠️ When set to `true`, all formatting options
|
|
1052
|
+
* (`outputFormat`, `prependPlusCountryCode`, etc.)
|
|
1053
|
+
* and `checkValidOnly` **must be omitted** or will be **ignored**.
|
|
1054
|
+
* - **Conflict handling with `checkValidOnly`:**
|
|
1055
|
+
* - If both `takeNumberOnly` and `checkValidOnly` are `true`,
|
|
1056
|
+
* `checkValidOnly` takes priority and the function
|
|
1057
|
+
* returns a `boolean`.
|
|
1058
|
+
* - If `checkValidOnly` is `false` (or not provided),
|
|
1059
|
+
* and `takeNumberOnly` is `true`,
|
|
1060
|
+
* the function returns a **numeric string of the local number**.
|
|
1061
|
+
* - **Invalid input:**
|
|
1062
|
+
* - If the input is invalid or cannot be parsed
|
|
1063
|
+
* (e.g. not matching the `defaultCountry`),
|
|
1064
|
+
* the function returns an **empty string** (`""`).
|
|
1065
|
+
* - **Output example:**
|
|
1066
|
+
* - Valid input ➔ `"81234567890"` // country code removed
|
|
1067
|
+
* - Invalid input ➔ `""`
|
|
1068
|
+
* @default false
|
|
1069
|
+
* @requires `false` or `undefined`
|
|
1070
|
+
*/
|
|
1071
|
+
takeNumberOnly?: false;
|
|
1072
|
+
}>;
|
|
1051
1073
|
/** -------------------------------------------------------
|
|
1052
1074
|
* * ***Options subset for calling {@link formatPhoneNumber|`formatPhoneNumber`} force to **Digits-only Mode**.***
|
|
1053
1075
|
* -------------------------------------------------------
|
|
1054
1076
|
*/
|
|
1055
|
-
type FormatPhoneNumberAllPassingTakeOnly=OverrideTypes<FormatPhoneNumberMain,{
|
|
1056
|
-
/** -------------------------------------------------------
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
checkValidOnly?:false;
|
|
1076
|
-
/** -------------------------------------------------------
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
takeNumberOnly:true;
|
|
1077
|
+
type FormatPhoneNumberAllPassingTakeOnly = OverrideTypes<FormatPhoneNumberMain, {
|
|
1078
|
+
/** -------------------------------------------------------
|
|
1079
|
+
* * ***Return only a boolean validity flag.***
|
|
1080
|
+
* -------------------------------------------------------
|
|
1081
|
+
* - ***Behavior:***
|
|
1082
|
+
* - **Exclusive mode:**
|
|
1083
|
+
* - ⚠️ When `true`, all formatting options and `takeNumberOnly` must be omitted or are ignored.
|
|
1084
|
+
* - Conflicts with `takeNumberOnly`:
|
|
1085
|
+
* - ⚠️ When `checkValidOnly` is `true` and all formatting options and `takeNumberOnly` must be
|
|
1086
|
+
* omitted or are ignored.
|
|
1087
|
+
* - But if mistake passing props:
|
|
1088
|
+
* - ⚠️ When `checkValidOnly` is `true` and other of formatting options was passing:
|
|
1089
|
+
* - If `takeNumberOnly` is `true` or `false`:
|
|
1090
|
+
* - Will return a `boolean` because `checkValidOnly` is prioritize first.
|
|
1091
|
+
* - Output:
|
|
1092
|
+
* - Boolean ➔ (`true` or `false`).
|
|
1093
|
+
* - ***DefaultValue: false***
|
|
1094
|
+
* @default false
|
|
1095
|
+
* @requires `false` or `undefined`
|
|
1096
|
+
*/
|
|
1097
|
+
checkValidOnly?: false;
|
|
1098
|
+
/** -------------------------------------------------------
|
|
1099
|
+
* * ***Return only the digits of the phone number (local number only).***
|
|
1100
|
+
* -------------------------------------------------------
|
|
1101
|
+
* **Returns a string containing only numeric characters** from the **local number**,
|
|
1102
|
+
* ignoring any country code, spaces, plus signs, or separators.
|
|
1103
|
+
* - **Default:** `false`
|
|
1104
|
+
* - **Behavior:**
|
|
1105
|
+
* - **Exclusive mode:**
|
|
1106
|
+
* - ⚠️ When set to `true`, all formatting options
|
|
1107
|
+
* (`outputFormat`, `prependPlusCountryCode`, etc.)
|
|
1108
|
+
* and `checkValidOnly` **must be omitted** or will be **ignored**.
|
|
1109
|
+
* - **Conflict handling with `checkValidOnly`:**
|
|
1110
|
+
* - If both `takeNumberOnly` and `checkValidOnly` are `true`,
|
|
1111
|
+
* `checkValidOnly` takes priority and the function
|
|
1112
|
+
* returns a `boolean`.
|
|
1113
|
+
* - If `checkValidOnly` is `false` (or not provided),
|
|
1114
|
+
* and `takeNumberOnly` is `true`,
|
|
1115
|
+
* the function returns a **numeric string of the local number**.
|
|
1116
|
+
* - **Invalid input:**
|
|
1117
|
+
* - If the input is invalid or cannot be parsed
|
|
1118
|
+
* (e.g. not matching the `defaultCountry`),
|
|
1119
|
+
* the function returns an **empty string** (`""`).
|
|
1120
|
+
* - **Output example:**
|
|
1121
|
+
* - Valid input ➔ `"81234567890"` // country code removed
|
|
1122
|
+
* - Invalid input ➔ `""`
|
|
1123
|
+
* @default false
|
|
1124
|
+
*/
|
|
1125
|
+
takeNumberOnly: true;
|
|
1126
|
+
}>;
|
|
1127
|
+
|
|
1104
1128
|
/** -------------------------------------------------------
|
|
1105
1129
|
* * ***Utility: `formatPhoneNumber`.***
|
|
1106
1130
|
* -------------------------------------------------------
|
|
@@ -1224,7 +1248,7 @@ takeNumberOnly:true;}>;
|
|
|
1224
1248
|
* // ➔ false
|
|
1225
1249
|
* ```
|
|
1226
1250
|
*/
|
|
1227
|
-
declare function formatPhoneNumber(value:ValueFormatPhoneNumber,options?:FormatPhoneNumberTransform):string;
|
|
1251
|
+
declare function formatPhoneNumber(value: ValueFormatPhoneNumber, options?: FormatPhoneNumberTransform): string;
|
|
1228
1252
|
/** -------------------------------------------------------
|
|
1229
1253
|
* * ***Utility: `formatPhoneNumber`.***
|
|
1230
1254
|
* -------------------------------------------------------
|
|
@@ -1280,7 +1304,7 @@ declare function formatPhoneNumber(value:ValueFormatPhoneNumber,options?:FormatP
|
|
|
1280
1304
|
* // ➔ ""
|
|
1281
1305
|
* ```
|
|
1282
1306
|
*/
|
|
1283
|
-
declare function formatPhoneNumber(value:ValueFormatPhoneNumber,options?:FormatPhoneNumberTakeNumberOnly):string;
|
|
1307
|
+
declare function formatPhoneNumber(value: ValueFormatPhoneNumber, options?: FormatPhoneNumberTakeNumberOnly): string;
|
|
1284
1308
|
/** -------------------------------------------------------
|
|
1285
1309
|
* * ***Utility: `formatPhoneNumber`.***
|
|
1286
1310
|
* -------------------------------------------------------
|
|
@@ -1340,7 +1364,7 @@ declare function formatPhoneNumber(value:ValueFormatPhoneNumber,options?:FormatP
|
|
|
1340
1364
|
* // ➔ false
|
|
1341
1365
|
* ```
|
|
1342
1366
|
*/
|
|
1343
|
-
declare function formatPhoneNumber(value:ValueFormatPhoneNumber,options?:FormatPhoneNumberCheckValidOnly):boolean;
|
|
1367
|
+
declare function formatPhoneNumber(value: ValueFormatPhoneNumber, options?: FormatPhoneNumberCheckValidOnly): boolean;
|
|
1344
1368
|
/** -------------------------------------------------------
|
|
1345
1369
|
* * ***Utility: `formatPhoneNumber`.***
|
|
1346
1370
|
* -------------------------------------------------------
|
|
@@ -1456,7 +1480,7 @@ declare function formatPhoneNumber(value:ValueFormatPhoneNumber,options?:FormatP
|
|
|
1456
1480
|
* // ➔ false
|
|
1457
1481
|
* ```
|
|
1458
1482
|
*/
|
|
1459
|
-
declare function formatPhoneNumber(value:ValueFormatPhoneNumber,options?:FormatPhoneNumberAllPassingValidOnly):boolean;
|
|
1483
|
+
declare function formatPhoneNumber(value: ValueFormatPhoneNumber, options?: FormatPhoneNumberAllPassingValidOnly): boolean;
|
|
1460
1484
|
/** -------------------------------------------------------
|
|
1461
1485
|
* * ***Utility: `formatPhoneNumber`.***
|
|
1462
1486
|
* -------------------------------------------------------
|
|
@@ -1534,7 +1558,7 @@ declare function formatPhoneNumber(value:ValueFormatPhoneNumber,options?:FormatP
|
|
|
1534
1558
|
* // ➔ ""
|
|
1535
1559
|
* ```
|
|
1536
1560
|
*/
|
|
1537
|
-
declare function formatPhoneNumber(value:ValueFormatPhoneNumber,options?:FormatPhoneNumberAllPassingTakeOnly):string;
|
|
1561
|
+
declare function formatPhoneNumber(value: ValueFormatPhoneNumber, options?: FormatPhoneNumberAllPassingTakeOnly): string;
|
|
1538
1562
|
/** -------------------------------------------------------
|
|
1539
1563
|
* * ***Utility: `formatPhoneNumber`.***
|
|
1540
1564
|
* -------------------------------------------------------
|
|
@@ -1675,15 +1699,18 @@ declare function formatPhoneNumber(value:ValueFormatPhoneNumber,options?:FormatP
|
|
|
1675
1699
|
* // ➔ false
|
|
1676
1700
|
* ```
|
|
1677
1701
|
*/
|
|
1678
|
-
declare function formatPhoneNumber(value:ValueFormatPhoneNumber,options?:FormatPhoneNumberAllPassing):boolean;
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
*
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1702
|
+
declare function formatPhoneNumber(value: ValueFormatPhoneNumber, options?: FormatPhoneNumberAllPassing): boolean;
|
|
1703
|
+
|
|
1704
|
+
type CensorEmailOptions = {
|
|
1705
|
+
/** ----------------------------------------------------------
|
|
1706
|
+
* * ***Censorship Mode.***
|
|
1707
|
+
* ----------------------------------------------------------
|
|
1708
|
+
* - **Valid value:**
|
|
1709
|
+
* - `"fixed"` (default) – Deterministic censorship based on a hash of the email, same input always produces the same output.
|
|
1710
|
+
* - `"random"` – Each character is randomly replaced every time the function is called.
|
|
1711
|
+
*/
|
|
1712
|
+
mode?: "random" | "fixed";
|
|
1713
|
+
};
|
|
1687
1714
|
/** ----------------------------------------------------------
|
|
1688
1715
|
* * ***Utility: `censorEmail`.***
|
|
1689
1716
|
* ----------------------------------------------------------
|
|
@@ -1715,25 +1742,28 @@ mode?:"random"|"fixed";};
|
|
|
1715
1742
|
* censorEmail("invalid-email");
|
|
1716
1743
|
* // ➔ ""
|
|
1717
1744
|
*/
|
|
1718
|
-
declare const censorEmail:(email:string|null|undefined,options?:CensorEmailOptions)=>string;
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1745
|
+
declare const censorEmail: (email: string | null | undefined, options?: CensorEmailOptions) => string;
|
|
1746
|
+
|
|
1747
|
+
type ChunkStringOptions = {
|
|
1748
|
+
/** ***The separator string to insert between characters or words.***
|
|
1749
|
+
*
|
|
1750
|
+
* - Used when inserting separators every `limiter` characters.
|
|
1751
|
+
* - Default is a single space `" "`.
|
|
1752
|
+
*
|
|
1753
|
+
* @default " "
|
|
1754
|
+
*/
|
|
1755
|
+
separator?: string;
|
|
1756
|
+
/** ***Determines whether counting for `limiter` resets after each space.***
|
|
1757
|
+
*
|
|
1758
|
+
* - If `true`, the string is treated as words separated by spaces,
|
|
1759
|
+
* and separators are applied within words, then words are grouped.
|
|
1760
|
+
* - If `false` ***(default)***, counting is continuous across the whole string,
|
|
1761
|
+
* treating spaces as normal characters.
|
|
1762
|
+
*
|
|
1763
|
+
* @default false
|
|
1764
|
+
*/
|
|
1765
|
+
reCountAfterSpace?: boolean;
|
|
1766
|
+
};
|
|
1737
1767
|
/** ----------------------------------------------
|
|
1738
1768
|
* * ***Utility: `chunkString`.***
|
|
1739
1769
|
* ----------------------------------------------
|
|
@@ -1785,24 +1815,27 @@ reCountAfterSpace?:boolean;};
|
|
|
1785
1815
|
* // The word "JKL" forms its own group (as it's the last word and completes no other group).
|
|
1786
1816
|
* // The groups "ABC-DEF-GHI" and "JKL" are then joined by a space.
|
|
1787
1817
|
*/
|
|
1788
|
-
declare function chunkString(subject:string,limiter:number,options?:ChunkStringOptions):string;
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1818
|
+
declare function chunkString(subject: string, limiter: number, options?: ChunkStringOptions): string;
|
|
1819
|
+
|
|
1820
|
+
type TruncateStringOptions = {
|
|
1821
|
+
/** ***Maximum length of the truncated string **(default: `10`)**.***
|
|
1822
|
+
*
|
|
1823
|
+
* @default 10
|
|
1824
|
+
*/
|
|
1825
|
+
length?: number;
|
|
1826
|
+
/** ***String to append if truncation occurs.***
|
|
1827
|
+
*
|
|
1828
|
+
* - Will be trimmed first; defaults to `"..."` if empty.
|
|
1829
|
+
*
|
|
1830
|
+
* @default "..."
|
|
1831
|
+
*/
|
|
1832
|
+
ending?: string;
|
|
1833
|
+
/** ***Whether to trim the input string before truncation ***(default: `true`)***.***
|
|
1834
|
+
*
|
|
1835
|
+
* @default true
|
|
1836
|
+
*/
|
|
1837
|
+
trim?: boolean;
|
|
1838
|
+
};
|
|
1806
1839
|
/** ----------------------------------------------------------
|
|
1807
1840
|
* * ***Utility: `truncateString`.***
|
|
1808
1841
|
* ----------------------------------------------------------
|
|
@@ -1837,7 +1870,8 @@ trim?:boolean;};
|
|
|
1837
1870
|
* truncateString(null, { length: 5 });
|
|
1838
1871
|
* // ➔ ""
|
|
1839
1872
|
*/
|
|
1840
|
-
declare const truncateString:(text:string|null|undefined,options?:TruncateStringOptions)=>string;
|
|
1873
|
+
declare const truncateString: (text: string | null | undefined, options?: TruncateStringOptions) => string;
|
|
1874
|
+
|
|
1841
1875
|
/** ----------------------------------------------------------------------
|
|
1842
1876
|
* * ***Options for formatting dates with `date-fns/format`.***
|
|
1843
1877
|
* ----------------------------------------------------------------------
|
|
@@ -1847,71 +1881,73 @@ declare const truncateString:(text:string|null|undefined,options?:TruncateString
|
|
|
1847
1881
|
*
|
|
1848
1882
|
* @private ***types for {@link formatDateFns}.***
|
|
1849
1883
|
*/
|
|
1850
|
-
type FormatDateFnsOptions=Prettify<OmitStrict<FormatOptions,"locale",true,false
|
|
1851
|
-
/** ------------------------------------------------------------
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
format?:string;
|
|
1863
|
-
/** ------------------------------------------------------------
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
locale?:"id"|"en"|AnyString|Locale;
|
|
1882
|
-
/** ------------------------------------------------------------
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
inputLocale?:"id"|"en"|AnyString|Locale;
|
|
1903
|
-
/** ------------------------------------------------------------
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
inputFormat?:string;
|
|
1884
|
+
type FormatDateFnsOptions = Prettify<OmitStrict<FormatOptions, "locale", true, false> & {
|
|
1885
|
+
/** ------------------------------------------------------------
|
|
1886
|
+
* * ***Output format string passed to `date-fns/format`.***
|
|
1887
|
+
* ------------------------------------------------------------
|
|
1888
|
+
* - **Behavior:**
|
|
1889
|
+
* - Determines how the date will be rendered.
|
|
1890
|
+
* - Uses the full power of `date-fns` tokens.
|
|
1891
|
+
* - ***Default Value***: `"dd MMM yyyy - HH:mm:ss"`.
|
|
1892
|
+
* @example
|
|
1893
|
+
* "dd MMMM yyyy, HH:mm:ss" // ➔ "03 September 2025, 10:25:42"
|
|
1894
|
+
* @default "dd MMM yyyy - HH:mm:ss"
|
|
1895
|
+
*/
|
|
1896
|
+
format?: string;
|
|
1897
|
+
/** ------------------------------------------------------------
|
|
1898
|
+
* * ***Locale used for formatting.***
|
|
1899
|
+
* ------------------------------------------------------------
|
|
1900
|
+
* - **Behavior:**
|
|
1901
|
+
* - If `string`: only accepts `"id"` (Indonesian) or `"en"` (English) - **(default)**.
|
|
1902
|
+
* - If `Locale`: accepts a locale object from `date-fns/locale`.
|
|
1903
|
+
* - ***Default Value***: `"en"`.
|
|
1904
|
+
* ```ts
|
|
1905
|
+
* import { ar } from "date-fns/locale";
|
|
1906
|
+
*
|
|
1907
|
+
* formatDateFns(new Date(), {
|
|
1908
|
+
* locale: ar,
|
|
1909
|
+
* format: "dd MMMM yyyy"
|
|
1910
|
+
* });
|
|
1911
|
+
* // ➔ "03 سبتمبر 2025"
|
|
1912
|
+
* ```
|
|
1913
|
+
* @default "en"
|
|
1914
|
+
*/
|
|
1915
|
+
locale?: "id" | "en" | AnyString | Locale;
|
|
1916
|
+
/** ------------------------------------------------------------
|
|
1917
|
+
* * ***Input locale used when parsing non-standard string dates.***
|
|
1918
|
+
* ------------------------------------------------------------
|
|
1919
|
+
* - **Behavior:**
|
|
1920
|
+
* - Required if `date` is a **localized string**
|
|
1921
|
+
* (e.g. `"03 Mei 2025 10:25:42"` in Indonesian).
|
|
1922
|
+
* - Same accepted types as `locale` parameter.
|
|
1923
|
+
* - ***Default Value***: `"en"`.
|
|
1924
|
+
* ```ts
|
|
1925
|
+
* import { ar } from "date-fns/locale";
|
|
1926
|
+
*
|
|
1927
|
+
* formatDateFns("03 مايو 2025 10:25:42", {
|
|
1928
|
+
* inputFormat: "dd MMMM yyyy HH:mm:ss",
|
|
1929
|
+
* inputLocale: ar,
|
|
1930
|
+
* format: "PPpp"
|
|
1931
|
+
* });
|
|
1932
|
+
* // ➔ "May 3, 2025 at 10:25:42 AM"
|
|
1933
|
+
* ```
|
|
1934
|
+
* @default "en"
|
|
1935
|
+
*/
|
|
1936
|
+
inputLocale?: "id" | "en" | AnyString | Locale;
|
|
1937
|
+
/** ------------------------------------------------------------
|
|
1938
|
+
* * ***Input format string for parsing non-ISO string dates.***
|
|
1939
|
+
* ------------------------------------------------------------
|
|
1940
|
+
* - **Behavior:**
|
|
1941
|
+
* - Required if `date` is **not ISO-8601** and not a native `Date`.
|
|
1942
|
+
* - Works together with `inputLocale` parameter.
|
|
1943
|
+
* - ***Default Value***: `undefined`.
|
|
1944
|
+
* @default undefined
|
|
1945
|
+
* @example
|
|
1946
|
+
* "dd MMMM yyyy HH:mm:ss" // ➔ "03 May 2025 10:25:42"
|
|
1947
|
+
*/
|
|
1948
|
+
inputFormat?: string;
|
|
1949
|
+
}>;
|
|
1950
|
+
|
|
1915
1951
|
/** ----------------------------------------------------------
|
|
1916
1952
|
* * ***Utility: `formatDateFns`.***
|
|
1917
1953
|
* ----------------------------------------------------------
|
|
@@ -1962,7 +1998,8 @@ inputFormat?:string;}>;
|
|
|
1962
1998
|
* formatDateFns(null);
|
|
1963
1999
|
* // ➔ null
|
|
1964
2000
|
*/
|
|
1965
|
-
declare const formatDateFns:(date:string|Date|null|undefined,options?:FormatDateFnsOptions)=>string|null;
|
|
2001
|
+
declare const formatDateFns: (date: string | Date | null | undefined, options?: FormatDateFnsOptions) => string | null;
|
|
2002
|
+
|
|
1966
2003
|
/** -------------------------------------------------------------
|
|
1967
2004
|
* * ***Supported IETF BCP-47 locale codes for Intl API.***
|
|
1968
2005
|
* -------------------------------------------------------------
|
|
@@ -1977,7 +2014,8 @@ declare const formatDateFns:(date:string|Date|null|undefined,options?:FormatDate
|
|
|
1977
2014
|
* const locale: SupportedLocales = "fr-CA";
|
|
1978
2015
|
* new Intl.DateTimeFormat(locale).format(new Date());
|
|
1979
2016
|
*/
|
|
1980
|
-
type SupportedLocales="en-US"|"en-GB"|"en-AU"|"en-CA"|"en-NZ"|"en-ZA"|"en-IN"|"en-IE"|"en-SG"|"en-HK"|"en-PH"|"en-MY"|"en-PK"|"en-KE"|"en-TZ"|"en-NG"|"en-LK"|"en-BW"|"en-ZM"|"id-ID"|"ms-MY"|"th-TH"|"vi-VN"|"tl-PH"|"ms-BN"|"zh-CN"|"zh-HK"|"zh-TW"|"zh-SG"|"zh-MO"|"ja-JP"|"ko-KR"|"fr-FR"|"fr-CA"|"fr-BE"|"fr-CH"|"fr-LU"|"fr-MA"|"fr-SN"|"fr-CM"|"fr-CI"|"fr-HT"|"fr-DZ"|"fr-TN"|"fr-ML"|"fr-NC"|"fr-PF"|"fr-GP"|"fr-MQ"|"fr-GF"|"de-DE"|"de-AT"|"de-CH"|"de-LU"|"de-LI"|"es-ES"|"es-MX"|"es-AR"|"es-CL"|"es-CO"|"es-PE"|"es-UY"|"es-VE"|"es-CR"|"es-EC"|"es-GT"|"es-HN"|"es-NI"|"es-PA"|"es-PR"|"es-SV"|"es-BO"|"es-PY"|"es-DO"|"es-CU"|"es-GQ"|"pt-BR"|"pt-PT"|"pt-MZ"|"pt-AO"|"pt-GW"|"pt-CV"|"pt-ST"|"it-IT"|"it-CH"|"it-SM"|"it-VA"|"nl-NL"|"nl-BE"|"nl-SR"|"nl-AW"|"nl-CW"|"ru-RU"|"uk-UA"|"kk-KZ"|"uz-UZ"|"ky-KG"|"tt-RU"|"ba-RU"|"cv-RU"|"sah-RU"|"pl-PL"|"cs-CZ"|"sk-SK"|"hu-HU"|"sl-SI"|"sv-SE"|"da-DK"|"no-NO"|"fi-FI"|"is-IS"|"ro-RO"|"bg-BG"|"hr-HR"|"sr-RS"|"mk-MK"|"bs-BA"|"me-ME"|"sq-AL"|"sq-XK"|"el-GR"|"el-CY"|"tr-TR"|"tr-CY"|"he-IL"|"ar-SA"|"ar-AE"|"ar-EG"|"ar-MA"|"ar-JO"|"ar-LB"|"ar-QA"|"ar-KW"|"ar-OM"|"ar-BH"|"ar-IQ"|"ar-LY"|"ar-TN"|"ar-YE"|"ar-SY"|"ar-PS"|"ar-SD"|"ar-DZ"|"ar-MR"|"ar-DJ"|"ar-SO"|"lt-LT"|"lv-LV"|"et-EE"|"hi-IN"|"bn-BD"|"pa-IN"|"ta-IN"|"te-IN"|"ml-IN"|"gu-IN"|"kn-IN"|"mr-IN"|"or-IN"|"as-IN"|"ne-IN"|"fa-IR"|"ur-PK"|"ps-AF"|"dv-MV"|"sw-KE"|"sw-TZ"|"zu-ZA"|"af-ZA"|"xh-ZA"|"ss-SZ"|"ts-ZA"|"tn-BW"|"ny-MW"|"lo-LA"|"mt-MT"|"ga-IE"|"cy-GB"|"ne-NP"|"si-LK"|"am-ET"|"om-ET"|"ti-ER"|"km-KH"|"my-MM"|"mn-MN"|"tg-TJ"|"tk-TM"|"hy-AM"|"ka-GE"|"az-AZ"|"be-BY"|"mo-MD"|"ro-MD"|"ht-HT"|"jw-ID"|"su-ID"|"to-TO"|"sm-WS"|"mi-NZ"|"bi-VU"|"fj-FJ"|"ty-PF"|"pau-PW"|"niu-NU"|"ck-CK"|"rw-RW"|"ln-CD"|"kg-CD"|"ha-NE"|"yo-NG"|"ig-NG"|"ak-GH"|"lg-UG"|"bo-CN"|"dz-BT"|"iu-CA"|"kl-GL"|"cv-RU"|"pap-AW"|"chr-US"|"haw-US"|"gv-IM"|"gd-GB"|"br-FR"|"co-FR"|"rm-CH"|"wa-BE"|"lb-LU"|"fur-IT"|"sc-IT"|"vec-IT"|"nap-IT"|"gsw-CH"|"rha-CH"|({}& string);
|
|
2017
|
+
type SupportedLocales = "en-US" | "en-GB" | "en-AU" | "en-CA" | "en-NZ" | "en-ZA" | "en-IN" | "en-IE" | "en-SG" | "en-HK" | "en-PH" | "en-MY" | "en-PK" | "en-KE" | "en-TZ" | "en-NG" | "en-LK" | "en-BW" | "en-ZM" | "id-ID" | "ms-MY" | "th-TH" | "vi-VN" | "tl-PH" | "ms-BN" | "zh-CN" | "zh-HK" | "zh-TW" | "zh-SG" | "zh-MO" | "ja-JP" | "ko-KR" | "fr-FR" | "fr-CA" | "fr-BE" | "fr-CH" | "fr-LU" | "fr-MA" | "fr-SN" | "fr-CM" | "fr-CI" | "fr-HT" | "fr-DZ" | "fr-TN" | "fr-ML" | "fr-NC" | "fr-PF" | "fr-GP" | "fr-MQ" | "fr-GF" | "de-DE" | "de-AT" | "de-CH" | "de-LU" | "de-LI" | "es-ES" | "es-MX" | "es-AR" | "es-CL" | "es-CO" | "es-PE" | "es-UY" | "es-VE" | "es-CR" | "es-EC" | "es-GT" | "es-HN" | "es-NI" | "es-PA" | "es-PR" | "es-SV" | "es-BO" | "es-PY" | "es-DO" | "es-CU" | "es-GQ" | "pt-BR" | "pt-PT" | "pt-MZ" | "pt-AO" | "pt-GW" | "pt-CV" | "pt-ST" | "it-IT" | "it-CH" | "it-SM" | "it-VA" | "nl-NL" | "nl-BE" | "nl-SR" | "nl-AW" | "nl-CW" | "ru-RU" | "uk-UA" | "kk-KZ" | "uz-UZ" | "ky-KG" | "tt-RU" | "ba-RU" | "cv-RU" | "sah-RU" | "pl-PL" | "cs-CZ" | "sk-SK" | "hu-HU" | "sl-SI" | "sv-SE" | "da-DK" | "no-NO" | "fi-FI" | "is-IS" | "ro-RO" | "bg-BG" | "hr-HR" | "sr-RS" | "mk-MK" | "bs-BA" | "me-ME" | "sq-AL" | "sq-XK" | "el-GR" | "el-CY" | "tr-TR" | "tr-CY" | "he-IL" | "ar-SA" | "ar-AE" | "ar-EG" | "ar-MA" | "ar-JO" | "ar-LB" | "ar-QA" | "ar-KW" | "ar-OM" | "ar-BH" | "ar-IQ" | "ar-LY" | "ar-TN" | "ar-YE" | "ar-SY" | "ar-PS" | "ar-SD" | "ar-DZ" | "ar-MR" | "ar-DJ" | "ar-SO" | "lt-LT" | "lv-LV" | "et-EE" | "hi-IN" | "bn-BD" | "pa-IN" | "ta-IN" | "te-IN" | "ml-IN" | "gu-IN" | "kn-IN" | "mr-IN" | "or-IN" | "as-IN" | "ne-IN" | "fa-IR" | "ur-PK" | "ps-AF" | "dv-MV" | "sw-KE" | "sw-TZ" | "zu-ZA" | "af-ZA" | "xh-ZA" | "ss-SZ" | "ts-ZA" | "tn-BW" | "ny-MW" | "lo-LA" | "mt-MT" | "ga-IE" | "cy-GB" | "ne-NP" | "si-LK" | "am-ET" | "om-ET" | "ti-ER" | "km-KH" | "my-MM" | "mn-MN" | "tg-TJ" | "tk-TM" | "hy-AM" | "ka-GE" | "az-AZ" | "be-BY" | "mo-MD" | "ro-MD" | "ht-HT" | "jw-ID" | "su-ID" | "to-TO" | "sm-WS" | "mi-NZ" | "bi-VU" | "fj-FJ" | "ty-PF" | "pau-PW" | "niu-NU" | "ck-CK" | "rw-RW" | "ln-CD" | "kg-CD" | "ha-NE" | "yo-NG" | "ig-NG" | "ak-GH" | "lg-UG" | "bo-CN" | "dz-BT" | "iu-CA" | "kl-GL" | "cv-RU" | "pap-AW" | "chr-US" | "haw-US" | "gv-IM" | "gd-GB" | "br-FR" | "co-FR" | "rm-CH" | "wa-BE" | "lb-LU" | "fur-IT" | "sc-IT" | "vec-IT" | "nap-IT" | "gsw-CH" | "rha-CH" | ({} & string);
|
|
2018
|
+
|
|
1981
2019
|
/** ----------------------------------------------------------------
|
|
1982
2020
|
* * ***Options for formatting dates with `Intl.DateTimeFormat`.***
|
|
1983
2021
|
* ----------------------------------------------------------------
|
|
@@ -1986,28 +2024,30 @@ type SupportedLocales="en-US"|"en-GB"|"en-AU"|"en-CA"|"en-NZ"|"en-ZA"|"en-IN"|"e
|
|
|
1986
2024
|
* an additional `locale` property that is validated against **{@link SupportedLocales | `SupportedLocales`}**.**
|
|
1987
2025
|
* @private ***types for {@link formatDateIntl}.***
|
|
1988
2026
|
*/
|
|
1989
|
-
type FormatDateIntlOptions=Intl.DateTimeFormatOptions &{
|
|
1990
|
-
/** ------------------------------------------------------------
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
locale?:SupportedLocales;
|
|
2027
|
+
type FormatDateIntlOptions = Intl.DateTimeFormatOptions & {
|
|
2028
|
+
/** ------------------------------------------------------------
|
|
2029
|
+
* * ***Locale for date formatting.***
|
|
2030
|
+
* ------------------------------------------------------------
|
|
2031
|
+
* - **Behavior:**
|
|
2032
|
+
* - Must be a valid [***BCP-47 locale***](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument),
|
|
2033
|
+
* validated against {@link SupportedLocales | **`SupportedLocales`**}.
|
|
2034
|
+
* - If `locale` is `undefined` or an empty string (after trimming),
|
|
2035
|
+
* it will **default to `"en-US"`**.
|
|
2036
|
+
* @default "en-US"
|
|
2037
|
+
* @example
|
|
2038
|
+
* { year: "numeric", month: "long" }
|
|
2039
|
+
* // Unset locale, default locale ➔ "en-US"
|
|
2040
|
+
* { locale: "fr-FR", ...}
|
|
2041
|
+
* // Explicit locale
|
|
2042
|
+
* { locale: " ", ...}
|
|
2043
|
+
* // Empty string locale ➔ defaults to "en-US"
|
|
2044
|
+
* { locale: " en-GB ", ...}
|
|
2045
|
+
* // Value will trimming ➔ "en-GB"
|
|
2046
|
+
*
|
|
2047
|
+
*/
|
|
2048
|
+
locale?: SupportedLocales;
|
|
2049
|
+
};
|
|
2050
|
+
|
|
2011
2051
|
/** ----------------------------------------------------------
|
|
2012
2052
|
* * ***Utility: `formatDateIntl`.***
|
|
2013
2053
|
* ----------------------------------------------------------
|
|
@@ -2035,7 +2075,8 @@ locale?:SupportedLocales;};
|
|
|
2035
2075
|
* formatDateIntl(new Date(), { timeZone: "UTC", hour: "2-digit", minute: "2-digit" });
|
|
2036
2076
|
* // ➔ "01:30 AM"
|
|
2037
2077
|
*/
|
|
2038
|
-
declare const formatDateIntl:(date:string|Date|null|undefined,options?:FormatDateIntlOptions)=>string|null;
|
|
2078
|
+
declare const formatDateIntl: (date: string | Date | null | undefined, options?: FormatDateIntlOptions) => string | null;
|
|
2079
|
+
|
|
2039
2080
|
/** ----------------------------------------------------------
|
|
2040
2081
|
* * ***Utility: `formatDateTime`.***
|
|
2041
2082
|
* ----------------------------------------------------------
|
|
@@ -2076,7 +2117,8 @@ declare const formatDateIntl:(date:string|Date|null|undefined,options?:FormatDat
|
|
|
2076
2117
|
* formatDateTime(undefined);
|
|
2077
2118
|
* // ➔ null
|
|
2078
2119
|
*/
|
|
2079
|
-
declare const formatDateTime:(date:string|Date|null|undefined,format?:string)=>string|null;
|
|
2120
|
+
declare const formatDateTime: (date: string | Date | null | undefined, format?: string) => string | null;
|
|
2121
|
+
|
|
2080
2122
|
/** ----------------------------------------------------------
|
|
2081
2123
|
* * ***Utility: `getGMTOffset`.***
|
|
2082
2124
|
* ----------------------------------------------------------
|
|
@@ -2107,4 +2149,6 @@ declare const formatDateTime:(date:string|Date|null|undefined,format?:string)=>s
|
|
|
2107
2149
|
* getGMTOffset(123);
|
|
2108
2150
|
* // ➔ "0"
|
|
2109
2151
|
*/
|
|
2110
|
-
declare const getGMTOffset:(date?:string|Date|null)=>string;
|
|
2152
|
+
declare const getGMTOffset: (date?: string | Date | null) => string;
|
|
2153
|
+
|
|
2154
|
+
export { censorEmail, chunkString, formatCurrency, formatDateFns, formatDateIntl, formatDateTime, formatNumber, formatPhoneNumber, getGMTOffset, truncateString };
|