matcha-components 19.98.0 → 19.99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/matcha-components.mjs +4219 -4
- package/fesm2022/matcha-components.mjs.map +1 -1
- package/lib/matcha-components.module.d.ts +21 -20
- package/lib/matcha-input-phone/all-countries.d.ts +8 -0
- package/lib/matcha-input-phone/input-phone.component.d.ts +69 -0
- package/lib/matcha-input-phone/input-phone.module.d.ts +11 -0
- package/lib/matcha-input-phone/lib/custom-keyboard-event.d.ts +1 -0
- package/lib/matcha-input-phone/lib/ngx-mask-applier.service.d.ts +55 -0
- package/lib/matcha-input-phone/lib/ngx-mask-expression.enum.d.ts +43 -0
- package/lib/matcha-input-phone/lib/ngx-mask.config.d.ts +40 -0
- package/lib/matcha-input-phone/lib/ngx-mask.directive.d.ts +78 -0
- package/lib/matcha-input-phone/lib/ngx-mask.module.d.ts +11 -0
- package/lib/matcha-input-phone/lib/ngx-mask.pipe.d.ts +13 -0
- package/lib/matcha-input-phone/lib/ngx-mask.service.d.ts +83 -0
- package/package.json +1 -1
- package/public-api.d.ts +2 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { EventEmitter, Output, Input, Component, ContentChildren, ElementRef, Renderer2, HostBinding, Inject, HostListener, ContentChild, Directive, forwardRef, ChangeDetectionStrategy, NgModule, createComponent,
|
|
2
|
+
import { EventEmitter, Output, Input, Component, ContentChildren, ElementRef, Renderer2, HostBinding, Inject, HostListener, ContentChild, Directive, forwardRef, ChangeDetectionStrategy, InjectionToken, inject, Injectable, input, output, signal, ViewChild, NgModule, createComponent, Pipe } from '@angular/core';
|
|
3
3
|
import { animation, style, animate, trigger, transition, useAnimation, state, query, stagger, animateChild, sequence, group } from '@angular/animations';
|
|
4
4
|
import { Subscription, Subject } from 'rxjs';
|
|
5
5
|
import { debounceTime } from 'rxjs/operators';
|
|
6
6
|
import * as i1 from '@angular/common';
|
|
7
|
-
import { CommonModule } from '@angular/common';
|
|
8
|
-
import
|
|
7
|
+
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
8
|
+
import * as i2 from '@angular/forms';
|
|
9
|
+
import { FormControlName, NG_VALUE_ACCESSOR, NG_VALIDATORS, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
9
10
|
|
|
10
11
|
const customAnimation = animation([
|
|
11
12
|
style({
|
|
@@ -2151,6 +2152,4030 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
2151
2152
|
args: ['keydown', ['$event']]
|
|
2152
2153
|
}] } });
|
|
2153
2154
|
|
|
2155
|
+
// Array of country objects for the flag dropdown.
|
|
2156
|
+
// Here is the criteria for the plugin to support a given country/territory
|
|
2157
|
+
// - It has an iso2 code: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
|
2158
|
+
// - It has it's own country calling code (it is not a sub-region of another country): https://en.wikipedia.org/wiki/List_of_country_calling_codes
|
|
2159
|
+
// - It has a flag in the region-flags project: https://github.com/behdad/region-flags/tree/gh-pages/png
|
|
2160
|
+
// - It is supported by libphonenumber (it must be listed on this page): https://github.com/googlei18n/libphonenumber/blob/master/resources/ShortNumberMetadata.xml
|
|
2161
|
+
// Each country array has the following information:
|
|
2162
|
+
// [
|
|
2163
|
+
// Country name,
|
|
2164
|
+
// iso2 code,
|
|
2165
|
+
// International dial code,
|
|
2166
|
+
// Order (if >1 country with same dial code),
|
|
2167
|
+
// Area codes
|
|
2168
|
+
// ]
|
|
2169
|
+
var allCountries = [
|
|
2170
|
+
[
|
|
2171
|
+
"Afghanistan (افغانستان)",
|
|
2172
|
+
"af",
|
|
2173
|
+
"93"
|
|
2174
|
+
],
|
|
2175
|
+
[
|
|
2176
|
+
"Albania (Shqipëri)",
|
|
2177
|
+
"al",
|
|
2178
|
+
"355"
|
|
2179
|
+
],
|
|
2180
|
+
[
|
|
2181
|
+
"Algeria (الجزائر)",
|
|
2182
|
+
"dz",
|
|
2183
|
+
"213"
|
|
2184
|
+
],
|
|
2185
|
+
[
|
|
2186
|
+
"American Samoa",
|
|
2187
|
+
"as",
|
|
2188
|
+
"1",
|
|
2189
|
+
5,
|
|
2190
|
+
["684"]
|
|
2191
|
+
],
|
|
2192
|
+
[
|
|
2193
|
+
"Andorra",
|
|
2194
|
+
"ad",
|
|
2195
|
+
"376"
|
|
2196
|
+
],
|
|
2197
|
+
[
|
|
2198
|
+
"Angola",
|
|
2199
|
+
"ao",
|
|
2200
|
+
"244"
|
|
2201
|
+
],
|
|
2202
|
+
[
|
|
2203
|
+
"Anguilla",
|
|
2204
|
+
"ai",
|
|
2205
|
+
"1",
|
|
2206
|
+
6,
|
|
2207
|
+
["264"]
|
|
2208
|
+
],
|
|
2209
|
+
[
|
|
2210
|
+
"Antigua and Barbuda",
|
|
2211
|
+
"ag",
|
|
2212
|
+
"1",
|
|
2213
|
+
7,
|
|
2214
|
+
["268"]
|
|
2215
|
+
],
|
|
2216
|
+
[
|
|
2217
|
+
"Argentina",
|
|
2218
|
+
"ar",
|
|
2219
|
+
"54",
|
|
2220
|
+
],
|
|
2221
|
+
[
|
|
2222
|
+
"Armenia (Հայաստան)",
|
|
2223
|
+
"am",
|
|
2224
|
+
"374"
|
|
2225
|
+
],
|
|
2226
|
+
[
|
|
2227
|
+
"Aruba",
|
|
2228
|
+
"aw",
|
|
2229
|
+
"297"
|
|
2230
|
+
],
|
|
2231
|
+
[
|
|
2232
|
+
"Australia",
|
|
2233
|
+
"au",
|
|
2234
|
+
"61",
|
|
2235
|
+
0
|
|
2236
|
+
],
|
|
2237
|
+
[
|
|
2238
|
+
"Austria (Österreich)",
|
|
2239
|
+
"at",
|
|
2240
|
+
"43"
|
|
2241
|
+
],
|
|
2242
|
+
[
|
|
2243
|
+
"Azerbaijan (Azərbaycan)",
|
|
2244
|
+
"az",
|
|
2245
|
+
"994"
|
|
2246
|
+
],
|
|
2247
|
+
[
|
|
2248
|
+
"Bahamas",
|
|
2249
|
+
"bs",
|
|
2250
|
+
"1",
|
|
2251
|
+
8,
|
|
2252
|
+
["242"]
|
|
2253
|
+
],
|
|
2254
|
+
[
|
|
2255
|
+
"Bahrain (البحرين)",
|
|
2256
|
+
"bh",
|
|
2257
|
+
"973"
|
|
2258
|
+
],
|
|
2259
|
+
[
|
|
2260
|
+
"Bangladesh (বাংলাদেশ)",
|
|
2261
|
+
"bd",
|
|
2262
|
+
"880"
|
|
2263
|
+
],
|
|
2264
|
+
[
|
|
2265
|
+
"Barbados",
|
|
2266
|
+
"bb",
|
|
2267
|
+
"1",
|
|
2268
|
+
9,
|
|
2269
|
+
["246"]
|
|
2270
|
+
],
|
|
2271
|
+
[
|
|
2272
|
+
"Belarus (Беларусь)",
|
|
2273
|
+
"by",
|
|
2274
|
+
"375"
|
|
2275
|
+
],
|
|
2276
|
+
[
|
|
2277
|
+
"Belgium (België)",
|
|
2278
|
+
"be",
|
|
2279
|
+
"32"
|
|
2280
|
+
],
|
|
2281
|
+
[
|
|
2282
|
+
"Belize",
|
|
2283
|
+
"bz",
|
|
2284
|
+
"501"
|
|
2285
|
+
],
|
|
2286
|
+
[
|
|
2287
|
+
"Benin (Bénin)",
|
|
2288
|
+
"bj",
|
|
2289
|
+
"229"
|
|
2290
|
+
],
|
|
2291
|
+
[
|
|
2292
|
+
"Bermuda",
|
|
2293
|
+
"bm",
|
|
2294
|
+
"1",
|
|
2295
|
+
10,
|
|
2296
|
+
["441"]
|
|
2297
|
+
],
|
|
2298
|
+
[
|
|
2299
|
+
"Bhutan (འབྲུག)",
|
|
2300
|
+
"bt",
|
|
2301
|
+
"975"
|
|
2302
|
+
],
|
|
2303
|
+
[
|
|
2304
|
+
"Bolivia",
|
|
2305
|
+
"bo",
|
|
2306
|
+
"591"
|
|
2307
|
+
],
|
|
2308
|
+
[
|
|
2309
|
+
"Bosnia and Herzegovina (Босна и Херцеговина)",
|
|
2310
|
+
"ba",
|
|
2311
|
+
"387"
|
|
2312
|
+
],
|
|
2313
|
+
[
|
|
2314
|
+
"Botswana",
|
|
2315
|
+
"bw",
|
|
2316
|
+
"267"
|
|
2317
|
+
],
|
|
2318
|
+
[
|
|
2319
|
+
"Brazil (Brasil)",
|
|
2320
|
+
"br",
|
|
2321
|
+
"55"
|
|
2322
|
+
],
|
|
2323
|
+
[
|
|
2324
|
+
"British Indian Ocean Territory",
|
|
2325
|
+
"io",
|
|
2326
|
+
"246"
|
|
2327
|
+
],
|
|
2328
|
+
[
|
|
2329
|
+
"British Virgin Islands",
|
|
2330
|
+
"vg",
|
|
2331
|
+
"1",
|
|
2332
|
+
11,
|
|
2333
|
+
["284"]
|
|
2334
|
+
],
|
|
2335
|
+
[
|
|
2336
|
+
"Brunei",
|
|
2337
|
+
"bn",
|
|
2338
|
+
"673"
|
|
2339
|
+
],
|
|
2340
|
+
[
|
|
2341
|
+
"Bulgaria (България)",
|
|
2342
|
+
"bg",
|
|
2343
|
+
"359"
|
|
2344
|
+
],
|
|
2345
|
+
[
|
|
2346
|
+
"Burkina Faso",
|
|
2347
|
+
"bf",
|
|
2348
|
+
"226"
|
|
2349
|
+
],
|
|
2350
|
+
[
|
|
2351
|
+
"Burundi (Uburundi)",
|
|
2352
|
+
"bi",
|
|
2353
|
+
"257"
|
|
2354
|
+
],
|
|
2355
|
+
[
|
|
2356
|
+
"Cambodia (កម្ពុជា)",
|
|
2357
|
+
"kh",
|
|
2358
|
+
"855"
|
|
2359
|
+
],
|
|
2360
|
+
[
|
|
2361
|
+
"Cameroon (Cameroun)",
|
|
2362
|
+
"cm",
|
|
2363
|
+
"237"
|
|
2364
|
+
],
|
|
2365
|
+
[
|
|
2366
|
+
"Canada",
|
|
2367
|
+
"ca",
|
|
2368
|
+
"1",
|
|
2369
|
+
1,
|
|
2370
|
+
["204", "226", "236", "249", "250", "289", "306", "343", "365", "387", "403", "416", "418", "431", "437", "438", "450", "506", "514", "519", "548", "579", "581", "587", "604", "613", "639", "647", "672", "705", "709", "742", "778", "780", "782", "807", "819", "825", "867", "873", "902", "905"]
|
|
2371
|
+
],
|
|
2372
|
+
[
|
|
2373
|
+
"Cape Verde (Kabu Verdi)",
|
|
2374
|
+
"cv",
|
|
2375
|
+
"238"
|
|
2376
|
+
],
|
|
2377
|
+
[
|
|
2378
|
+
"Caribbean Netherlands",
|
|
2379
|
+
"bq",
|
|
2380
|
+
"599",
|
|
2381
|
+
1,
|
|
2382
|
+
["3", "4", "7"]
|
|
2383
|
+
],
|
|
2384
|
+
[
|
|
2385
|
+
"Cayman Islands",
|
|
2386
|
+
"ky",
|
|
2387
|
+
"1",
|
|
2388
|
+
12,
|
|
2389
|
+
["345"]
|
|
2390
|
+
],
|
|
2391
|
+
[
|
|
2392
|
+
"Central African Republic (République centrafricaine)",
|
|
2393
|
+
"cf",
|
|
2394
|
+
"236"
|
|
2395
|
+
],
|
|
2396
|
+
[
|
|
2397
|
+
"Chad (Tchad)",
|
|
2398
|
+
"td",
|
|
2399
|
+
"235"
|
|
2400
|
+
],
|
|
2401
|
+
[
|
|
2402
|
+
"Chile",
|
|
2403
|
+
"cl",
|
|
2404
|
+
"56"
|
|
2405
|
+
],
|
|
2406
|
+
[
|
|
2407
|
+
"China (中国)",
|
|
2408
|
+
"cn",
|
|
2409
|
+
"86"
|
|
2410
|
+
],
|
|
2411
|
+
[
|
|
2412
|
+
"Christmas Island",
|
|
2413
|
+
"cx",
|
|
2414
|
+
"61",
|
|
2415
|
+
2
|
|
2416
|
+
],
|
|
2417
|
+
[
|
|
2418
|
+
"Cocos (Keeling) Islands",
|
|
2419
|
+
"cc",
|
|
2420
|
+
"61",
|
|
2421
|
+
1
|
|
2422
|
+
],
|
|
2423
|
+
[
|
|
2424
|
+
"Colombia",
|
|
2425
|
+
"co",
|
|
2426
|
+
"57"
|
|
2427
|
+
],
|
|
2428
|
+
[
|
|
2429
|
+
"Comoros (جزر القمر)",
|
|
2430
|
+
"km",
|
|
2431
|
+
"269"
|
|
2432
|
+
],
|
|
2433
|
+
[
|
|
2434
|
+
"Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
|
|
2435
|
+
"cd",
|
|
2436
|
+
"243"
|
|
2437
|
+
],
|
|
2438
|
+
[
|
|
2439
|
+
"Congo (Republic) (Congo-Brazzaville)",
|
|
2440
|
+
"cg",
|
|
2441
|
+
"242"
|
|
2442
|
+
],
|
|
2443
|
+
[
|
|
2444
|
+
"Cook Islands",
|
|
2445
|
+
"ck",
|
|
2446
|
+
"682"
|
|
2447
|
+
],
|
|
2448
|
+
[
|
|
2449
|
+
"Costa Rica",
|
|
2450
|
+
"cr",
|
|
2451
|
+
"506"
|
|
2452
|
+
],
|
|
2453
|
+
[
|
|
2454
|
+
"Côte d’Ivoire",
|
|
2455
|
+
"ci",
|
|
2456
|
+
"225"
|
|
2457
|
+
],
|
|
2458
|
+
[
|
|
2459
|
+
"Croatia (Hrvatska)",
|
|
2460
|
+
"hr",
|
|
2461
|
+
"385"
|
|
2462
|
+
],
|
|
2463
|
+
[
|
|
2464
|
+
"Cuba",
|
|
2465
|
+
"cu",
|
|
2466
|
+
"53"
|
|
2467
|
+
],
|
|
2468
|
+
[
|
|
2469
|
+
"Curaçao",
|
|
2470
|
+
"cw",
|
|
2471
|
+
"599",
|
|
2472
|
+
0
|
|
2473
|
+
],
|
|
2474
|
+
[
|
|
2475
|
+
"Cyprus (Κύπρος)",
|
|
2476
|
+
"cy",
|
|
2477
|
+
"357"
|
|
2478
|
+
],
|
|
2479
|
+
[
|
|
2480
|
+
"Czech Republic (Česká republika)",
|
|
2481
|
+
"cz",
|
|
2482
|
+
"420"
|
|
2483
|
+
],
|
|
2484
|
+
[
|
|
2485
|
+
"Denmark (Danmark)",
|
|
2486
|
+
"dk",
|
|
2487
|
+
"45"
|
|
2488
|
+
],
|
|
2489
|
+
[
|
|
2490
|
+
"Djibouti",
|
|
2491
|
+
"dj",
|
|
2492
|
+
"253"
|
|
2493
|
+
],
|
|
2494
|
+
[
|
|
2495
|
+
"Dominica",
|
|
2496
|
+
"dm",
|
|
2497
|
+
"1",
|
|
2498
|
+
13,
|
|
2499
|
+
["767"]
|
|
2500
|
+
],
|
|
2501
|
+
[
|
|
2502
|
+
"Dominican Republic (República Dominicana)",
|
|
2503
|
+
"do",
|
|
2504
|
+
"1",
|
|
2505
|
+
2,
|
|
2506
|
+
["809", "829", "849"]
|
|
2507
|
+
],
|
|
2508
|
+
[
|
|
2509
|
+
"Ecuador",
|
|
2510
|
+
"ec",
|
|
2511
|
+
"593"
|
|
2512
|
+
],
|
|
2513
|
+
[
|
|
2514
|
+
"Egypt (مصر)",
|
|
2515
|
+
"eg",
|
|
2516
|
+
"20"
|
|
2517
|
+
],
|
|
2518
|
+
[
|
|
2519
|
+
"El Salvador",
|
|
2520
|
+
"sv",
|
|
2521
|
+
"503"
|
|
2522
|
+
],
|
|
2523
|
+
[
|
|
2524
|
+
"Equatorial Guinea (Guinea Ecuatorial)",
|
|
2525
|
+
"gq",
|
|
2526
|
+
"240"
|
|
2527
|
+
],
|
|
2528
|
+
[
|
|
2529
|
+
"Eritrea",
|
|
2530
|
+
"er",
|
|
2531
|
+
"291"
|
|
2532
|
+
],
|
|
2533
|
+
[
|
|
2534
|
+
"Estonia (Eesti)",
|
|
2535
|
+
"ee",
|
|
2536
|
+
"372"
|
|
2537
|
+
],
|
|
2538
|
+
[
|
|
2539
|
+
"Ethiopia",
|
|
2540
|
+
"et",
|
|
2541
|
+
"251"
|
|
2542
|
+
],
|
|
2543
|
+
[
|
|
2544
|
+
"Falkland Islands (Islas Malvinas)",
|
|
2545
|
+
"fk",
|
|
2546
|
+
"500"
|
|
2547
|
+
],
|
|
2548
|
+
[
|
|
2549
|
+
"Faroe Islands (Føroyar)",
|
|
2550
|
+
"fo",
|
|
2551
|
+
"298"
|
|
2552
|
+
],
|
|
2553
|
+
[
|
|
2554
|
+
"Fiji",
|
|
2555
|
+
"fj",
|
|
2556
|
+
"679"
|
|
2557
|
+
],
|
|
2558
|
+
[
|
|
2559
|
+
"Finland (Suomi)",
|
|
2560
|
+
"fi",
|
|
2561
|
+
"358",
|
|
2562
|
+
0
|
|
2563
|
+
],
|
|
2564
|
+
[
|
|
2565
|
+
"France",
|
|
2566
|
+
"fr",
|
|
2567
|
+
"33"
|
|
2568
|
+
],
|
|
2569
|
+
[
|
|
2570
|
+
"French Guiana (Guyane française)",
|
|
2571
|
+
"gf",
|
|
2572
|
+
"594"
|
|
2573
|
+
],
|
|
2574
|
+
[
|
|
2575
|
+
"French Polynesia (Polynésie française)",
|
|
2576
|
+
"pf",
|
|
2577
|
+
"689"
|
|
2578
|
+
],
|
|
2579
|
+
[
|
|
2580
|
+
"Gabon",
|
|
2581
|
+
"ga",
|
|
2582
|
+
"241"
|
|
2583
|
+
],
|
|
2584
|
+
[
|
|
2585
|
+
"Gambia",
|
|
2586
|
+
"gm",
|
|
2587
|
+
"220"
|
|
2588
|
+
],
|
|
2589
|
+
[
|
|
2590
|
+
"Georgia (საქართველო)",
|
|
2591
|
+
"ge",
|
|
2592
|
+
"995"
|
|
2593
|
+
],
|
|
2594
|
+
[
|
|
2595
|
+
"Germany (Deutschland)",
|
|
2596
|
+
"de",
|
|
2597
|
+
"49"
|
|
2598
|
+
],
|
|
2599
|
+
[
|
|
2600
|
+
"Ghana (Gaana)",
|
|
2601
|
+
"gh",
|
|
2602
|
+
"233"
|
|
2603
|
+
],
|
|
2604
|
+
[
|
|
2605
|
+
"Gibraltar",
|
|
2606
|
+
"gi",
|
|
2607
|
+
"350"
|
|
2608
|
+
],
|
|
2609
|
+
[
|
|
2610
|
+
"Greece (Ελλάδα)",
|
|
2611
|
+
"gr",
|
|
2612
|
+
"30"
|
|
2613
|
+
],
|
|
2614
|
+
[
|
|
2615
|
+
"Greenland (Kalaallit Nunaat)",
|
|
2616
|
+
"gl",
|
|
2617
|
+
"299"
|
|
2618
|
+
],
|
|
2619
|
+
[
|
|
2620
|
+
"Grenada",
|
|
2621
|
+
"gd",
|
|
2622
|
+
"1",
|
|
2623
|
+
14,
|
|
2624
|
+
["473"]
|
|
2625
|
+
],
|
|
2626
|
+
[
|
|
2627
|
+
"Guadeloupe",
|
|
2628
|
+
"gp",
|
|
2629
|
+
"590",
|
|
2630
|
+
0
|
|
2631
|
+
],
|
|
2632
|
+
[
|
|
2633
|
+
"Guam",
|
|
2634
|
+
"gu",
|
|
2635
|
+
"1",
|
|
2636
|
+
15,
|
|
2637
|
+
["671"]
|
|
2638
|
+
],
|
|
2639
|
+
[
|
|
2640
|
+
"Guatemala",
|
|
2641
|
+
"gt",
|
|
2642
|
+
"502"
|
|
2643
|
+
],
|
|
2644
|
+
[
|
|
2645
|
+
"Guernsey",
|
|
2646
|
+
"gg",
|
|
2647
|
+
"44",
|
|
2648
|
+
1,
|
|
2649
|
+
["1481", "7781", "7839", "7911"]
|
|
2650
|
+
],
|
|
2651
|
+
[
|
|
2652
|
+
"Guinea (Guinée)",
|
|
2653
|
+
"gn",
|
|
2654
|
+
"224"
|
|
2655
|
+
],
|
|
2656
|
+
[
|
|
2657
|
+
"Guinea-Bissau (Guiné Bissau)",
|
|
2658
|
+
"gw",
|
|
2659
|
+
"245"
|
|
2660
|
+
],
|
|
2661
|
+
[
|
|
2662
|
+
"Guyana",
|
|
2663
|
+
"gy",
|
|
2664
|
+
"592"
|
|
2665
|
+
],
|
|
2666
|
+
[
|
|
2667
|
+
"Haiti",
|
|
2668
|
+
"ht",
|
|
2669
|
+
"509"
|
|
2670
|
+
],
|
|
2671
|
+
[
|
|
2672
|
+
"Honduras",
|
|
2673
|
+
"hn",
|
|
2674
|
+
"504"
|
|
2675
|
+
],
|
|
2676
|
+
[
|
|
2677
|
+
"Hong Kong (香港)",
|
|
2678
|
+
"hk",
|
|
2679
|
+
"852"
|
|
2680
|
+
],
|
|
2681
|
+
[
|
|
2682
|
+
"Hungary (Magyarország)",
|
|
2683
|
+
"hu",
|
|
2684
|
+
"36"
|
|
2685
|
+
],
|
|
2686
|
+
[
|
|
2687
|
+
"Iceland (Ísland)",
|
|
2688
|
+
"is",
|
|
2689
|
+
"354"
|
|
2690
|
+
],
|
|
2691
|
+
[
|
|
2692
|
+
"India (भारत)",
|
|
2693
|
+
"in",
|
|
2694
|
+
"91"
|
|
2695
|
+
],
|
|
2696
|
+
[
|
|
2697
|
+
"Indonesia",
|
|
2698
|
+
"id",
|
|
2699
|
+
"62"
|
|
2700
|
+
],
|
|
2701
|
+
[
|
|
2702
|
+
"Iran (ایران)",
|
|
2703
|
+
"ir",
|
|
2704
|
+
"98"
|
|
2705
|
+
],
|
|
2706
|
+
[
|
|
2707
|
+
"Iraq (العراق)",
|
|
2708
|
+
"iq",
|
|
2709
|
+
"964"
|
|
2710
|
+
],
|
|
2711
|
+
[
|
|
2712
|
+
"Ireland",
|
|
2713
|
+
"ie",
|
|
2714
|
+
"353"
|
|
2715
|
+
],
|
|
2716
|
+
[
|
|
2717
|
+
"Isle of Man",
|
|
2718
|
+
"im",
|
|
2719
|
+
"44",
|
|
2720
|
+
2,
|
|
2721
|
+
["1624", "74576", "7524", "7924", "7624"]
|
|
2722
|
+
],
|
|
2723
|
+
[
|
|
2724
|
+
"Israel (ישראל)",
|
|
2725
|
+
"il",
|
|
2726
|
+
"972"
|
|
2727
|
+
],
|
|
2728
|
+
[
|
|
2729
|
+
"Italy (Italia)",
|
|
2730
|
+
"it",
|
|
2731
|
+
"39",
|
|
2732
|
+
0
|
|
2733
|
+
],
|
|
2734
|
+
[
|
|
2735
|
+
"Jamaica",
|
|
2736
|
+
"jm",
|
|
2737
|
+
"1",
|
|
2738
|
+
4,
|
|
2739
|
+
["876", "658"]
|
|
2740
|
+
],
|
|
2741
|
+
[
|
|
2742
|
+
"Japan (日本)",
|
|
2743
|
+
"jp",
|
|
2744
|
+
"81"
|
|
2745
|
+
],
|
|
2746
|
+
[
|
|
2747
|
+
"Jersey",
|
|
2748
|
+
"je",
|
|
2749
|
+
"44",
|
|
2750
|
+
3,
|
|
2751
|
+
["1534", "7509", "7700", "7797", "7829", "7937"]
|
|
2752
|
+
],
|
|
2753
|
+
[
|
|
2754
|
+
"Jordan (الأردن)",
|
|
2755
|
+
"jo",
|
|
2756
|
+
"962"
|
|
2757
|
+
],
|
|
2758
|
+
[
|
|
2759
|
+
"Kazakhstan (Казахстан)",
|
|
2760
|
+
"kz",
|
|
2761
|
+
"7",
|
|
2762
|
+
1,
|
|
2763
|
+
["33", "7"]
|
|
2764
|
+
],
|
|
2765
|
+
[
|
|
2766
|
+
"Kenya",
|
|
2767
|
+
"ke",
|
|
2768
|
+
"254"
|
|
2769
|
+
],
|
|
2770
|
+
[
|
|
2771
|
+
"Kiribati",
|
|
2772
|
+
"ki",
|
|
2773
|
+
"686"
|
|
2774
|
+
],
|
|
2775
|
+
[
|
|
2776
|
+
"Kosovo",
|
|
2777
|
+
"xk",
|
|
2778
|
+
"383"
|
|
2779
|
+
],
|
|
2780
|
+
[
|
|
2781
|
+
"Kuwait (الكويت)",
|
|
2782
|
+
"kw",
|
|
2783
|
+
"965"
|
|
2784
|
+
],
|
|
2785
|
+
[
|
|
2786
|
+
"Kyrgyzstan (Кыргызстан)",
|
|
2787
|
+
"kg",
|
|
2788
|
+
"996"
|
|
2789
|
+
],
|
|
2790
|
+
[
|
|
2791
|
+
"Laos (ລາວ)",
|
|
2792
|
+
"la",
|
|
2793
|
+
"856"
|
|
2794
|
+
],
|
|
2795
|
+
[
|
|
2796
|
+
"Latvia (Latvija)",
|
|
2797
|
+
"lv",
|
|
2798
|
+
"371"
|
|
2799
|
+
],
|
|
2800
|
+
[
|
|
2801
|
+
"Lebanon (لبنان)",
|
|
2802
|
+
"lb",
|
|
2803
|
+
"961"
|
|
2804
|
+
],
|
|
2805
|
+
[
|
|
2806
|
+
"Lesotho",
|
|
2807
|
+
"ls",
|
|
2808
|
+
"266"
|
|
2809
|
+
],
|
|
2810
|
+
[
|
|
2811
|
+
"Liberia",
|
|
2812
|
+
"lr",
|
|
2813
|
+
"231"
|
|
2814
|
+
],
|
|
2815
|
+
[
|
|
2816
|
+
"Libya (ليبيا)",
|
|
2817
|
+
"ly",
|
|
2818
|
+
"218"
|
|
2819
|
+
],
|
|
2820
|
+
[
|
|
2821
|
+
"Liechtenstein",
|
|
2822
|
+
"li",
|
|
2823
|
+
"423"
|
|
2824
|
+
],
|
|
2825
|
+
[
|
|
2826
|
+
"Lithuania (Lietuva)",
|
|
2827
|
+
"lt",
|
|
2828
|
+
"370"
|
|
2829
|
+
],
|
|
2830
|
+
[
|
|
2831
|
+
"Luxembourg",
|
|
2832
|
+
"lu",
|
|
2833
|
+
"352"
|
|
2834
|
+
],
|
|
2835
|
+
[
|
|
2836
|
+
"Macau (澳門)",
|
|
2837
|
+
"mo",
|
|
2838
|
+
"853"
|
|
2839
|
+
],
|
|
2840
|
+
[
|
|
2841
|
+
"Macedonia (FYROM) (Македонија)",
|
|
2842
|
+
"mk",
|
|
2843
|
+
"389"
|
|
2844
|
+
],
|
|
2845
|
+
[
|
|
2846
|
+
"Madagascar (Madagasikara)",
|
|
2847
|
+
"mg",
|
|
2848
|
+
"261"
|
|
2849
|
+
],
|
|
2850
|
+
[
|
|
2851
|
+
"Malawi",
|
|
2852
|
+
"mw",
|
|
2853
|
+
"265"
|
|
2854
|
+
],
|
|
2855
|
+
[
|
|
2856
|
+
"Malaysia",
|
|
2857
|
+
"my",
|
|
2858
|
+
"60"
|
|
2859
|
+
],
|
|
2860
|
+
[
|
|
2861
|
+
"Maldives",
|
|
2862
|
+
"mv",
|
|
2863
|
+
"960"
|
|
2864
|
+
],
|
|
2865
|
+
[
|
|
2866
|
+
"Mali",
|
|
2867
|
+
"ml",
|
|
2868
|
+
"223"
|
|
2869
|
+
],
|
|
2870
|
+
[
|
|
2871
|
+
"Malta",
|
|
2872
|
+
"mt",
|
|
2873
|
+
"356"
|
|
2874
|
+
],
|
|
2875
|
+
[
|
|
2876
|
+
"Marshall Islands",
|
|
2877
|
+
"mh",
|
|
2878
|
+
"692"
|
|
2879
|
+
],
|
|
2880
|
+
[
|
|
2881
|
+
"Martinique",
|
|
2882
|
+
"mq",
|
|
2883
|
+
"596"
|
|
2884
|
+
],
|
|
2885
|
+
[
|
|
2886
|
+
"Mauritania (موريتانيا)",
|
|
2887
|
+
"mr",
|
|
2888
|
+
"222"
|
|
2889
|
+
],
|
|
2890
|
+
[
|
|
2891
|
+
"Mauritius (Moris)",
|
|
2892
|
+
"mu",
|
|
2893
|
+
"230"
|
|
2894
|
+
],
|
|
2895
|
+
[
|
|
2896
|
+
"Mayotte",
|
|
2897
|
+
"yt",
|
|
2898
|
+
"262",
|
|
2899
|
+
1,
|
|
2900
|
+
["269", "639"]
|
|
2901
|
+
],
|
|
2902
|
+
[
|
|
2903
|
+
"Mexico (México)",
|
|
2904
|
+
"mx",
|
|
2905
|
+
"52"
|
|
2906
|
+
],
|
|
2907
|
+
[
|
|
2908
|
+
"Micronesia",
|
|
2909
|
+
"fm",
|
|
2910
|
+
"691"
|
|
2911
|
+
],
|
|
2912
|
+
[
|
|
2913
|
+
"Moldova (Republica Moldova)",
|
|
2914
|
+
"md",
|
|
2915
|
+
"373"
|
|
2916
|
+
],
|
|
2917
|
+
[
|
|
2918
|
+
"Monaco",
|
|
2919
|
+
"mc",
|
|
2920
|
+
"377"
|
|
2921
|
+
],
|
|
2922
|
+
[
|
|
2923
|
+
"Mongolia (Монгол)",
|
|
2924
|
+
"mn",
|
|
2925
|
+
"976"
|
|
2926
|
+
],
|
|
2927
|
+
[
|
|
2928
|
+
"Montenegro (Crna Gora)",
|
|
2929
|
+
"me",
|
|
2930
|
+
"382"
|
|
2931
|
+
],
|
|
2932
|
+
[
|
|
2933
|
+
"Montserrat",
|
|
2934
|
+
"ms",
|
|
2935
|
+
"1",
|
|
2936
|
+
16,
|
|
2937
|
+
["664"]
|
|
2938
|
+
],
|
|
2939
|
+
[
|
|
2940
|
+
"Morocco (المغرب)",
|
|
2941
|
+
"ma",
|
|
2942
|
+
"212",
|
|
2943
|
+
0
|
|
2944
|
+
],
|
|
2945
|
+
[
|
|
2946
|
+
"Mozambique (Moçambique)",
|
|
2947
|
+
"mz",
|
|
2948
|
+
"258"
|
|
2949
|
+
],
|
|
2950
|
+
[
|
|
2951
|
+
"Myanmar (Burma) (မြန်မာ)",
|
|
2952
|
+
"mm",
|
|
2953
|
+
"95"
|
|
2954
|
+
],
|
|
2955
|
+
[
|
|
2956
|
+
"Namibia (Namibië)",
|
|
2957
|
+
"na",
|
|
2958
|
+
"264"
|
|
2959
|
+
],
|
|
2960
|
+
[
|
|
2961
|
+
"Nauru",
|
|
2962
|
+
"nr",
|
|
2963
|
+
"674"
|
|
2964
|
+
],
|
|
2965
|
+
[
|
|
2966
|
+
"Nepal (नेपाल)",
|
|
2967
|
+
"np",
|
|
2968
|
+
"977"
|
|
2969
|
+
],
|
|
2970
|
+
[
|
|
2971
|
+
"Netherlands (Nederland)",
|
|
2972
|
+
"nl",
|
|
2973
|
+
"31"
|
|
2974
|
+
],
|
|
2975
|
+
[
|
|
2976
|
+
"New Caledonia (Nouvelle-Calédonie)",
|
|
2977
|
+
"nc",
|
|
2978
|
+
"687"
|
|
2979
|
+
],
|
|
2980
|
+
[
|
|
2981
|
+
"New Zealand",
|
|
2982
|
+
"nz",
|
|
2983
|
+
"64"
|
|
2984
|
+
],
|
|
2985
|
+
[
|
|
2986
|
+
"Nicaragua",
|
|
2987
|
+
"ni",
|
|
2988
|
+
"505"
|
|
2989
|
+
],
|
|
2990
|
+
[
|
|
2991
|
+
"Niger (Nijar)",
|
|
2992
|
+
"ne",
|
|
2993
|
+
"227"
|
|
2994
|
+
],
|
|
2995
|
+
[
|
|
2996
|
+
"Nigeria",
|
|
2997
|
+
"ng",
|
|
2998
|
+
"234"
|
|
2999
|
+
],
|
|
3000
|
+
[
|
|
3001
|
+
"Niue",
|
|
3002
|
+
"nu",
|
|
3003
|
+
"683"
|
|
3004
|
+
],
|
|
3005
|
+
[
|
|
3006
|
+
"Norfolk Island",
|
|
3007
|
+
"nf",
|
|
3008
|
+
"672"
|
|
3009
|
+
],
|
|
3010
|
+
[
|
|
3011
|
+
"North Korea (조선 민주주의 인민 공화국)",
|
|
3012
|
+
"kp",
|
|
3013
|
+
"850"
|
|
3014
|
+
],
|
|
3015
|
+
[
|
|
3016
|
+
"Northern Mariana Islands",
|
|
3017
|
+
"mp",
|
|
3018
|
+
"1",
|
|
3019
|
+
17,
|
|
3020
|
+
["670"]
|
|
3021
|
+
],
|
|
3022
|
+
[
|
|
3023
|
+
"Norway (Norge)",
|
|
3024
|
+
"no",
|
|
3025
|
+
"47",
|
|
3026
|
+
0
|
|
3027
|
+
],
|
|
3028
|
+
[
|
|
3029
|
+
"Oman (عُمان)",
|
|
3030
|
+
"om",
|
|
3031
|
+
"968"
|
|
3032
|
+
],
|
|
3033
|
+
[
|
|
3034
|
+
"Pakistan (پاکستان)",
|
|
3035
|
+
"pk",
|
|
3036
|
+
"92"
|
|
3037
|
+
],
|
|
3038
|
+
[
|
|
3039
|
+
"Palau",
|
|
3040
|
+
"pw",
|
|
3041
|
+
"680"
|
|
3042
|
+
],
|
|
3043
|
+
[
|
|
3044
|
+
"Palestine (فلسطين)",
|
|
3045
|
+
"ps",
|
|
3046
|
+
"970"
|
|
3047
|
+
],
|
|
3048
|
+
[
|
|
3049
|
+
"Panama (Panamá)",
|
|
3050
|
+
"pa",
|
|
3051
|
+
"507"
|
|
3052
|
+
],
|
|
3053
|
+
[
|
|
3054
|
+
"Papua New Guinea",
|
|
3055
|
+
"pg",
|
|
3056
|
+
"675"
|
|
3057
|
+
],
|
|
3058
|
+
[
|
|
3059
|
+
"Paraguay",
|
|
3060
|
+
"py",
|
|
3061
|
+
"595"
|
|
3062
|
+
],
|
|
3063
|
+
[
|
|
3064
|
+
"Peru (Perú)",
|
|
3065
|
+
"pe",
|
|
3066
|
+
"51"
|
|
3067
|
+
],
|
|
3068
|
+
[
|
|
3069
|
+
"Philippines",
|
|
3070
|
+
"ph",
|
|
3071
|
+
"63"
|
|
3072
|
+
],
|
|
3073
|
+
[
|
|
3074
|
+
"Poland (Polska)",
|
|
3075
|
+
"pl",
|
|
3076
|
+
"48"
|
|
3077
|
+
],
|
|
3078
|
+
[
|
|
3079
|
+
"Portugal",
|
|
3080
|
+
"pt",
|
|
3081
|
+
"351"
|
|
3082
|
+
],
|
|
3083
|
+
[
|
|
3084
|
+
"Puerto Rico",
|
|
3085
|
+
"pr",
|
|
3086
|
+
"1",
|
|
3087
|
+
3,
|
|
3088
|
+
["787", "939"]
|
|
3089
|
+
],
|
|
3090
|
+
[
|
|
3091
|
+
"Qatar (قطر)",
|
|
3092
|
+
"qa",
|
|
3093
|
+
"974"
|
|
3094
|
+
],
|
|
3095
|
+
[
|
|
3096
|
+
"Réunion (La Réunion)",
|
|
3097
|
+
"re",
|
|
3098
|
+
"262",
|
|
3099
|
+
0
|
|
3100
|
+
],
|
|
3101
|
+
[
|
|
3102
|
+
"Romania (România)",
|
|
3103
|
+
"ro",
|
|
3104
|
+
"40"
|
|
3105
|
+
],
|
|
3106
|
+
[
|
|
3107
|
+
"Russia (Россия)",
|
|
3108
|
+
"ru",
|
|
3109
|
+
"7",
|
|
3110
|
+
0
|
|
3111
|
+
],
|
|
3112
|
+
[
|
|
3113
|
+
"Rwanda",
|
|
3114
|
+
"rw",
|
|
3115
|
+
"250"
|
|
3116
|
+
],
|
|
3117
|
+
[
|
|
3118
|
+
"Saint Barthélemy",
|
|
3119
|
+
"bl",
|
|
3120
|
+
"590",
|
|
3121
|
+
1
|
|
3122
|
+
],
|
|
3123
|
+
[
|
|
3124
|
+
"Saint Helena",
|
|
3125
|
+
"sh",
|
|
3126
|
+
"290"
|
|
3127
|
+
],
|
|
3128
|
+
[
|
|
3129
|
+
"Saint Kitts and Nevis",
|
|
3130
|
+
"kn",
|
|
3131
|
+
"1",
|
|
3132
|
+
18,
|
|
3133
|
+
["869"]
|
|
3134
|
+
],
|
|
3135
|
+
[
|
|
3136
|
+
"Saint Lucia",
|
|
3137
|
+
"lc",
|
|
3138
|
+
"1",
|
|
3139
|
+
19,
|
|
3140
|
+
["758"]
|
|
3141
|
+
],
|
|
3142
|
+
[
|
|
3143
|
+
"Saint Martin (Saint-Martin (partie française))",
|
|
3144
|
+
"mf",
|
|
3145
|
+
"590",
|
|
3146
|
+
2
|
|
3147
|
+
],
|
|
3148
|
+
[
|
|
3149
|
+
"Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
|
|
3150
|
+
"pm",
|
|
3151
|
+
"508"
|
|
3152
|
+
],
|
|
3153
|
+
[
|
|
3154
|
+
"Saint Vincent and the Grenadines",
|
|
3155
|
+
"vc",
|
|
3156
|
+
"1",
|
|
3157
|
+
20,
|
|
3158
|
+
["784"]
|
|
3159
|
+
],
|
|
3160
|
+
[
|
|
3161
|
+
"Samoa",
|
|
3162
|
+
"ws",
|
|
3163
|
+
"685"
|
|
3164
|
+
],
|
|
3165
|
+
[
|
|
3166
|
+
"San Marino",
|
|
3167
|
+
"sm",
|
|
3168
|
+
"378"
|
|
3169
|
+
],
|
|
3170
|
+
[
|
|
3171
|
+
"São Tomé and Príncipe (São Tomé e Príncipe)",
|
|
3172
|
+
"st",
|
|
3173
|
+
"239"
|
|
3174
|
+
],
|
|
3175
|
+
[
|
|
3176
|
+
"Saudi Arabia (المملكة العربية السعودية)",
|
|
3177
|
+
"sa",
|
|
3178
|
+
"966"
|
|
3179
|
+
],
|
|
3180
|
+
[
|
|
3181
|
+
"Senegal (Sénégal)",
|
|
3182
|
+
"sn",
|
|
3183
|
+
"221"
|
|
3184
|
+
],
|
|
3185
|
+
[
|
|
3186
|
+
"Serbia (Србија)",
|
|
3187
|
+
"rs",
|
|
3188
|
+
"381"
|
|
3189
|
+
],
|
|
3190
|
+
[
|
|
3191
|
+
"Seychelles",
|
|
3192
|
+
"sc",
|
|
3193
|
+
"248"
|
|
3194
|
+
],
|
|
3195
|
+
[
|
|
3196
|
+
"Sierra Leone",
|
|
3197
|
+
"sl",
|
|
3198
|
+
"232"
|
|
3199
|
+
],
|
|
3200
|
+
[
|
|
3201
|
+
"Singapore",
|
|
3202
|
+
"sg",
|
|
3203
|
+
"65"
|
|
3204
|
+
],
|
|
3205
|
+
[
|
|
3206
|
+
"Sint Maarten",
|
|
3207
|
+
"sx",
|
|
3208
|
+
"1",
|
|
3209
|
+
21,
|
|
3210
|
+
["721"]
|
|
3211
|
+
],
|
|
3212
|
+
[
|
|
3213
|
+
"Slovakia (Slovensko)",
|
|
3214
|
+
"sk",
|
|
3215
|
+
"421"
|
|
3216
|
+
],
|
|
3217
|
+
[
|
|
3218
|
+
"Slovenia (Slovenija)",
|
|
3219
|
+
"si",
|
|
3220
|
+
"386"
|
|
3221
|
+
],
|
|
3222
|
+
[
|
|
3223
|
+
"Solomon Islands",
|
|
3224
|
+
"sb",
|
|
3225
|
+
"677"
|
|
3226
|
+
],
|
|
3227
|
+
[
|
|
3228
|
+
"Somalia (Soomaaliya)",
|
|
3229
|
+
"so",
|
|
3230
|
+
"252"
|
|
3231
|
+
],
|
|
3232
|
+
[
|
|
3233
|
+
"South Africa",
|
|
3234
|
+
"za",
|
|
3235
|
+
"27"
|
|
3236
|
+
],
|
|
3237
|
+
[
|
|
3238
|
+
"South Korea (대한민국)",
|
|
3239
|
+
"kr",
|
|
3240
|
+
"82"
|
|
3241
|
+
],
|
|
3242
|
+
[
|
|
3243
|
+
"South Sudan (جنوب السودان)",
|
|
3244
|
+
"ss",
|
|
3245
|
+
"211"
|
|
3246
|
+
],
|
|
3247
|
+
[
|
|
3248
|
+
"Spain (España)",
|
|
3249
|
+
"es",
|
|
3250
|
+
"34"
|
|
3251
|
+
],
|
|
3252
|
+
[
|
|
3253
|
+
"Sri Lanka (ශ්රී ලංකාව)",
|
|
3254
|
+
"lk",
|
|
3255
|
+
"94"
|
|
3256
|
+
],
|
|
3257
|
+
[
|
|
3258
|
+
"Sudan (السودان)",
|
|
3259
|
+
"sd",
|
|
3260
|
+
"249"
|
|
3261
|
+
],
|
|
3262
|
+
[
|
|
3263
|
+
"Suriname",
|
|
3264
|
+
"sr",
|
|
3265
|
+
"597"
|
|
3266
|
+
],
|
|
3267
|
+
[
|
|
3268
|
+
"Svalbard and Jan Mayen",
|
|
3269
|
+
"sj",
|
|
3270
|
+
"47",
|
|
3271
|
+
1,
|
|
3272
|
+
["79"]
|
|
3273
|
+
],
|
|
3274
|
+
[
|
|
3275
|
+
"Swaziland",
|
|
3276
|
+
"sz",
|
|
3277
|
+
"268"
|
|
3278
|
+
],
|
|
3279
|
+
[
|
|
3280
|
+
"Sweden (Sverige)",
|
|
3281
|
+
"se",
|
|
3282
|
+
"46"
|
|
3283
|
+
],
|
|
3284
|
+
[
|
|
3285
|
+
"Switzerland (Schweiz)",
|
|
3286
|
+
"ch",
|
|
3287
|
+
"41"
|
|
3288
|
+
],
|
|
3289
|
+
[
|
|
3290
|
+
"Syria (سوريا)",
|
|
3291
|
+
"sy",
|
|
3292
|
+
"963"
|
|
3293
|
+
],
|
|
3294
|
+
[
|
|
3295
|
+
"Taiwan (台灣)",
|
|
3296
|
+
"tw",
|
|
3297
|
+
"886"
|
|
3298
|
+
],
|
|
3299
|
+
[
|
|
3300
|
+
"Tajikistan",
|
|
3301
|
+
"tj",
|
|
3302
|
+
"992"
|
|
3303
|
+
],
|
|
3304
|
+
[
|
|
3305
|
+
"Tanzania",
|
|
3306
|
+
"tz",
|
|
3307
|
+
"255"
|
|
3308
|
+
],
|
|
3309
|
+
[
|
|
3310
|
+
"Thailand (ไทย)",
|
|
3311
|
+
"th",
|
|
3312
|
+
"66"
|
|
3313
|
+
],
|
|
3314
|
+
[
|
|
3315
|
+
"Timor-Leste",
|
|
3316
|
+
"tl",
|
|
3317
|
+
"670"
|
|
3318
|
+
],
|
|
3319
|
+
[
|
|
3320
|
+
"Togo",
|
|
3321
|
+
"tg",
|
|
3322
|
+
"228"
|
|
3323
|
+
],
|
|
3324
|
+
[
|
|
3325
|
+
"Tokelau",
|
|
3326
|
+
"tk",
|
|
3327
|
+
"690"
|
|
3328
|
+
],
|
|
3329
|
+
[
|
|
3330
|
+
"Tonga",
|
|
3331
|
+
"to",
|
|
3332
|
+
"676"
|
|
3333
|
+
],
|
|
3334
|
+
[
|
|
3335
|
+
"Trinidad and Tobago",
|
|
3336
|
+
"tt",
|
|
3337
|
+
"1",
|
|
3338
|
+
22,
|
|
3339
|
+
["868"]
|
|
3340
|
+
],
|
|
3341
|
+
[
|
|
3342
|
+
"Tunisia (تونس)",
|
|
3343
|
+
"tn",
|
|
3344
|
+
"216"
|
|
3345
|
+
],
|
|
3346
|
+
[
|
|
3347
|
+
"Turkey (Türkiye)",
|
|
3348
|
+
"tr",
|
|
3349
|
+
"90"
|
|
3350
|
+
],
|
|
3351
|
+
[
|
|
3352
|
+
"Turkmenistan",
|
|
3353
|
+
"tm",
|
|
3354
|
+
"993"
|
|
3355
|
+
],
|
|
3356
|
+
[
|
|
3357
|
+
"Turks and Caicos Islands",
|
|
3358
|
+
"tc",
|
|
3359
|
+
"1",
|
|
3360
|
+
23,
|
|
3361
|
+
["649"]
|
|
3362
|
+
],
|
|
3363
|
+
[
|
|
3364
|
+
"Tuvalu",
|
|
3365
|
+
"tv",
|
|
3366
|
+
"688"
|
|
3367
|
+
],
|
|
3368
|
+
[
|
|
3369
|
+
"U.S. Virgin Islands",
|
|
3370
|
+
"vi",
|
|
3371
|
+
"1",
|
|
3372
|
+
24,
|
|
3373
|
+
["340"]
|
|
3374
|
+
],
|
|
3375
|
+
[
|
|
3376
|
+
"Uganda",
|
|
3377
|
+
"ug",
|
|
3378
|
+
"256"
|
|
3379
|
+
],
|
|
3380
|
+
[
|
|
3381
|
+
"Ukraine (Україна)",
|
|
3382
|
+
"ua",
|
|
3383
|
+
"380"
|
|
3384
|
+
],
|
|
3385
|
+
[
|
|
3386
|
+
"United Arab Emirates (الإمارات العربية المتحدة)",
|
|
3387
|
+
"ae",
|
|
3388
|
+
"971"
|
|
3389
|
+
],
|
|
3390
|
+
[
|
|
3391
|
+
"United Kingdom",
|
|
3392
|
+
"gb",
|
|
3393
|
+
"44",
|
|
3394
|
+
0
|
|
3395
|
+
],
|
|
3396
|
+
[
|
|
3397
|
+
"United States",
|
|
3398
|
+
"us",
|
|
3399
|
+
"1",
|
|
3400
|
+
0
|
|
3401
|
+
],
|
|
3402
|
+
[
|
|
3403
|
+
"Uruguay",
|
|
3404
|
+
"uy",
|
|
3405
|
+
"598"
|
|
3406
|
+
],
|
|
3407
|
+
[
|
|
3408
|
+
"Uzbekistan (Oʻzbekiston)",
|
|
3409
|
+
"uz",
|
|
3410
|
+
"998"
|
|
3411
|
+
],
|
|
3412
|
+
[
|
|
3413
|
+
"Vanuatu",
|
|
3414
|
+
"vu",
|
|
3415
|
+
"678"
|
|
3416
|
+
],
|
|
3417
|
+
[
|
|
3418
|
+
"Vatican City (Città del Vaticano)",
|
|
3419
|
+
"va",
|
|
3420
|
+
"39",
|
|
3421
|
+
1,
|
|
3422
|
+
["06698"]
|
|
3423
|
+
],
|
|
3424
|
+
[
|
|
3425
|
+
"Venezuela",
|
|
3426
|
+
"ve",
|
|
3427
|
+
"58"
|
|
3428
|
+
],
|
|
3429
|
+
[
|
|
3430
|
+
"Vietnam (Việt Nam)",
|
|
3431
|
+
"vn",
|
|
3432
|
+
"84"
|
|
3433
|
+
],
|
|
3434
|
+
[
|
|
3435
|
+
"Wallis and Futuna (Wallis-et-Futuna)",
|
|
3436
|
+
"wf",
|
|
3437
|
+
"681"
|
|
3438
|
+
],
|
|
3439
|
+
[
|
|
3440
|
+
"Western Sahara (الصحراء الغربية)",
|
|
3441
|
+
"eh",
|
|
3442
|
+
"212",
|
|
3443
|
+
1,
|
|
3444
|
+
["5288", "5289"]
|
|
3445
|
+
],
|
|
3446
|
+
[
|
|
3447
|
+
"Yemen (اليمن)",
|
|
3448
|
+
"ye",
|
|
3449
|
+
"967"
|
|
3450
|
+
],
|
|
3451
|
+
[
|
|
3452
|
+
"Zambia",
|
|
3453
|
+
"zm",
|
|
3454
|
+
"260"
|
|
3455
|
+
],
|
|
3456
|
+
[
|
|
3457
|
+
"Zimbabwe",
|
|
3458
|
+
"zw",
|
|
3459
|
+
"263"
|
|
3460
|
+
],
|
|
3461
|
+
[
|
|
3462
|
+
"Åland Islands",
|
|
3463
|
+
"ax",
|
|
3464
|
+
"358",
|
|
3465
|
+
1,
|
|
3466
|
+
["18"]
|
|
3467
|
+
]
|
|
3468
|
+
];
|
|
3469
|
+
// loop over all of the countries above, restructuring the data to be objects with named keys
|
|
3470
|
+
function getCountryISO2() {
|
|
3471
|
+
let countries = [];
|
|
3472
|
+
for (var i = 0; i < allCountries.length; i++) {
|
|
3473
|
+
var c = allCountries[i];
|
|
3474
|
+
// Garante que o array tenha pelo menos 3 elementos
|
|
3475
|
+
const safeCountry = [
|
|
3476
|
+
c[0],
|
|
3477
|
+
c[1],
|
|
3478
|
+
c[2],
|
|
3479
|
+
c[3] || 0,
|
|
3480
|
+
c[4] || null
|
|
3481
|
+
];
|
|
3482
|
+
countries[i] = {
|
|
3483
|
+
name: c[0],
|
|
3484
|
+
iso2: c[1],
|
|
3485
|
+
dialCode: c[2],
|
|
3486
|
+
priority: c[3] || 0,
|
|
3487
|
+
areaCodes: c[4] || null,
|
|
3488
|
+
mask: applyPhoneMask(safeCountry)
|
|
3489
|
+
};
|
|
3490
|
+
}
|
|
3491
|
+
return countries;
|
|
3492
|
+
}
|
|
3493
|
+
function applyPhoneMask(country) {
|
|
3494
|
+
const countryCode = country[2];
|
|
3495
|
+
const areaCodes = country[4] || [countryCode];
|
|
3496
|
+
const masks = areaCodes.map((areaCode) => {
|
|
3497
|
+
if (countryCode === "1") {
|
|
3498
|
+
// North American Numbering Plan (NANP)
|
|
3499
|
+
return `000 000 0000`;
|
|
3500
|
+
}
|
|
3501
|
+
else if (countryCode === "44" && areaCode.length === 4) {
|
|
3502
|
+
// UK
|
|
3503
|
+
return `000 0000 0000`;
|
|
3504
|
+
}
|
|
3505
|
+
else if (countryCode === "55") {
|
|
3506
|
+
// Brazil
|
|
3507
|
+
return `00 0000 0000`;
|
|
3508
|
+
}
|
|
3509
|
+
else {
|
|
3510
|
+
// General international format
|
|
3511
|
+
return `000 0000 0000`;
|
|
3512
|
+
}
|
|
3513
|
+
});
|
|
3514
|
+
return masks;
|
|
3515
|
+
}
|
|
3516
|
+
|
|
3517
|
+
const NGX_MASK_CONFIG = new InjectionToken('ngx-mask config');
|
|
3518
|
+
const NEW_CONFIG = new InjectionToken('new ngx-mask config');
|
|
3519
|
+
const INITIAL_CONFIG = new InjectionToken('initial ngx-mask config');
|
|
3520
|
+
const initialConfig = {
|
|
3521
|
+
suffix: '',
|
|
3522
|
+
prefix: '',
|
|
3523
|
+
thousandSeparator: ' ',
|
|
3524
|
+
decimalMarker: ['.', ','],
|
|
3525
|
+
clearIfNotMatch: false,
|
|
3526
|
+
showMaskTyped: false,
|
|
3527
|
+
instantPrefix: false,
|
|
3528
|
+
placeHolderCharacter: '_',
|
|
3529
|
+
dropSpecialCharacters: true,
|
|
3530
|
+
hiddenInput: false,
|
|
3531
|
+
shownMaskExpression: '',
|
|
3532
|
+
separatorLimit: '',
|
|
3533
|
+
allowNegativeNumbers: false,
|
|
3534
|
+
validation: true,
|
|
3535
|
+
specialCharacters: ['-', '/', '(', ')', '.', ':', ' ', '+', ',', '@', '[', ']', '"', "'"],
|
|
3536
|
+
leadZeroDateTime: false,
|
|
3537
|
+
apm: false,
|
|
3538
|
+
leadZero: false,
|
|
3539
|
+
keepCharacterPositions: false,
|
|
3540
|
+
triggerOnMaskChange: false,
|
|
3541
|
+
inputTransformFn: (value) => value,
|
|
3542
|
+
outputTransformFn: (value) => value,
|
|
3543
|
+
maskFilled: new EventEmitter(),
|
|
3544
|
+
patterns: {
|
|
3545
|
+
'0': {
|
|
3546
|
+
pattern: new RegExp('\\d'),
|
|
3547
|
+
},
|
|
3548
|
+
'9': {
|
|
3549
|
+
pattern: new RegExp('\\d'),
|
|
3550
|
+
optional: true,
|
|
3551
|
+
},
|
|
3552
|
+
X: {
|
|
3553
|
+
pattern: new RegExp('\\d'),
|
|
3554
|
+
symbol: '*',
|
|
3555
|
+
},
|
|
3556
|
+
A: {
|
|
3557
|
+
pattern: new RegExp('[a-zA-Z0-9]'),
|
|
3558
|
+
},
|
|
3559
|
+
S: {
|
|
3560
|
+
pattern: new RegExp('[a-zA-Z]'),
|
|
3561
|
+
},
|
|
3562
|
+
U: {
|
|
3563
|
+
pattern: new RegExp('[A-Z]'),
|
|
3564
|
+
},
|
|
3565
|
+
L: {
|
|
3566
|
+
pattern: new RegExp('[a-z]'),
|
|
3567
|
+
},
|
|
3568
|
+
d: {
|
|
3569
|
+
pattern: new RegExp('\\d'),
|
|
3570
|
+
},
|
|
3571
|
+
m: {
|
|
3572
|
+
pattern: new RegExp('\\d'),
|
|
3573
|
+
},
|
|
3574
|
+
M: {
|
|
3575
|
+
pattern: new RegExp('\\d'),
|
|
3576
|
+
},
|
|
3577
|
+
H: {
|
|
3578
|
+
pattern: new RegExp('\\d'),
|
|
3579
|
+
},
|
|
3580
|
+
h: {
|
|
3581
|
+
pattern: new RegExp('\\d'),
|
|
3582
|
+
},
|
|
3583
|
+
s: {
|
|
3584
|
+
pattern: new RegExp('\\d'),
|
|
3585
|
+
},
|
|
3586
|
+
},
|
|
3587
|
+
};
|
|
3588
|
+
const timeMasks = [
|
|
3589
|
+
"Hh:m0:s0" /* MaskExpression.HOURS_MINUTES_SECONDS */,
|
|
3590
|
+
"Hh:m0" /* MaskExpression.HOURS_MINUTES */,
|
|
3591
|
+
"m0:s0" /* MaskExpression.MINUTES_SECONDS */,
|
|
3592
|
+
];
|
|
3593
|
+
const withoutValidation = [
|
|
3594
|
+
"percent" /* MaskExpression.PERCENT */,
|
|
3595
|
+
"Hh" /* MaskExpression.HOURS_HOUR */,
|
|
3596
|
+
"s0" /* MaskExpression.SECONDS */,
|
|
3597
|
+
"m0" /* MaskExpression.MINUTES */,
|
|
3598
|
+
"separator" /* MaskExpression.SEPARATOR */,
|
|
3599
|
+
"d0/M0/0000" /* MaskExpression.DAYS_MONTHS_YEARS */,
|
|
3600
|
+
"d0/M0" /* MaskExpression.DAYS_MONTHS */,
|
|
3601
|
+
"d0" /* MaskExpression.DAYS */,
|
|
3602
|
+
"M0" /* MaskExpression.MONTHS */,
|
|
3603
|
+
];
|
|
3604
|
+
|
|
3605
|
+
class NgxMaskApplierService {
|
|
3606
|
+
constructor() {
|
|
3607
|
+
this._config = inject(NGX_MASK_CONFIG);
|
|
3608
|
+
this.dropSpecialCharacters = this._config.dropSpecialCharacters;
|
|
3609
|
+
this.hiddenInput = this._config.hiddenInput;
|
|
3610
|
+
this.clearIfNotMatch = this._config.clearIfNotMatch;
|
|
3611
|
+
this.specialCharacters = this._config.specialCharacters;
|
|
3612
|
+
this.patterns = this._config.patterns;
|
|
3613
|
+
this.prefix = this._config.prefix || '';
|
|
3614
|
+
this.suffix = this._config.suffix || '';
|
|
3615
|
+
this.thousandSeparator = this._config.thousandSeparator || '';
|
|
3616
|
+
this.decimalMarker = this._config.decimalMarker || '';
|
|
3617
|
+
this.showMaskTyped = this._config.showMaskTyped;
|
|
3618
|
+
this.placeHolderCharacter = this._config.placeHolderCharacter;
|
|
3619
|
+
this.validation = this._config.validation;
|
|
3620
|
+
this.separatorLimit = this._config.separatorLimit;
|
|
3621
|
+
this.allowNegativeNumbers = this._config.allowNegativeNumbers;
|
|
3622
|
+
this.leadZeroDateTime = this._config.leadZeroDateTime;
|
|
3623
|
+
this.leadZero = this._config.leadZero;
|
|
3624
|
+
this.apm = this._config.apm;
|
|
3625
|
+
this.inputTransformFn = this._config.inputTransformFn;
|
|
3626
|
+
this.outputTransformFn = this._config.outputTransformFn;
|
|
3627
|
+
this.keepCharacterPositions = this._config.keepCharacterPositions;
|
|
3628
|
+
this.instantPrefix = this._config.instantPrefix;
|
|
3629
|
+
this.triggerOnMaskChange = this._config.triggerOnMaskChange;
|
|
3630
|
+
this._shift = new Set();
|
|
3631
|
+
this.plusOnePosition = false;
|
|
3632
|
+
this.maskExpression = '';
|
|
3633
|
+
this.actualValue = '';
|
|
3634
|
+
this.showKeepCharacterExp = '';
|
|
3635
|
+
this.shownMaskExpression = this._config.shownMaskExpression;
|
|
3636
|
+
this.deletedSpecialCharacter = false;
|
|
3637
|
+
this._formatWithSeparators = (str, thousandSeparatorChar, decimalChars, precision) => {
|
|
3638
|
+
let x = [];
|
|
3639
|
+
let decimalChar = '';
|
|
3640
|
+
if (Array.isArray(decimalChars)) {
|
|
3641
|
+
const regExp = new RegExp(decimalChars.map((v) => ('[\\^$.|?*+()'.indexOf(v) >= 0 ? `\\${v}` : v)).join('|'));
|
|
3642
|
+
x = str.split(regExp);
|
|
3643
|
+
decimalChar = str.match(regExp)?.[0] ?? "" /* MaskExpression.EMPTY_STRING */;
|
|
3644
|
+
}
|
|
3645
|
+
else {
|
|
3646
|
+
x = str.split(decimalChars);
|
|
3647
|
+
decimalChar = decimalChars;
|
|
3648
|
+
}
|
|
3649
|
+
const decimals = x.length > 1 ? `${decimalChar}${x[1]}` : "" /* MaskExpression.EMPTY_STRING */;
|
|
3650
|
+
let res = x[0] ?? "" /* MaskExpression.EMPTY_STRING */;
|
|
3651
|
+
const separatorLimit = this.separatorLimit.replace(/\s/g, "" /* MaskExpression.EMPTY_STRING */);
|
|
3652
|
+
if (separatorLimit && +separatorLimit) {
|
|
3653
|
+
if (res[0] === "-" /* MaskExpression.MINUS */) {
|
|
3654
|
+
res = `-${res.slice(1, res.length).slice(0, separatorLimit.length)}`;
|
|
3655
|
+
}
|
|
3656
|
+
else {
|
|
3657
|
+
res = res.slice(0, separatorLimit.length);
|
|
3658
|
+
}
|
|
3659
|
+
}
|
|
3660
|
+
const rgx = /(\d+)(\d{3})/;
|
|
3661
|
+
while (thousandSeparatorChar && rgx.test(res)) {
|
|
3662
|
+
res = res.replace(rgx, '$1' + thousandSeparatorChar + '$2');
|
|
3663
|
+
}
|
|
3664
|
+
if (typeof precision === 'undefined') {
|
|
3665
|
+
return res + decimals;
|
|
3666
|
+
}
|
|
3667
|
+
else if (precision === 0) {
|
|
3668
|
+
return res;
|
|
3669
|
+
}
|
|
3670
|
+
return res + decimals.substring(0, precision + 1);
|
|
3671
|
+
};
|
|
3672
|
+
this.percentage = (str) => {
|
|
3673
|
+
const sanitizedStr = str.replace(',', '.');
|
|
3674
|
+
const value = Number(this.allowNegativeNumbers && str.includes("-" /* MaskExpression.MINUS */)
|
|
3675
|
+
? sanitizedStr.slice(1, str.length)
|
|
3676
|
+
: sanitizedStr);
|
|
3677
|
+
return !isNaN(value) && value >= 0 && value <= 100;
|
|
3678
|
+
};
|
|
3679
|
+
this.getPrecision = (maskExpression) => {
|
|
3680
|
+
const x = maskExpression.split("." /* MaskExpression.DOT */);
|
|
3681
|
+
if (x.length > 1) {
|
|
3682
|
+
return Number(x[x.length - 1]);
|
|
3683
|
+
}
|
|
3684
|
+
return Infinity;
|
|
3685
|
+
};
|
|
3686
|
+
this.checkAndRemoveSuffix = (inputValue) => {
|
|
3687
|
+
for (let i = this.suffix?.length - 1; i >= 0; i--) {
|
|
3688
|
+
const substr = this.suffix.substring(i, this.suffix?.length);
|
|
3689
|
+
if (inputValue.includes(substr) &&
|
|
3690
|
+
i !== this.suffix?.length - 1 &&
|
|
3691
|
+
(i - 1 < 0 ||
|
|
3692
|
+
!inputValue.includes(this.suffix.substring(i - 1, this.suffix?.length)))) {
|
|
3693
|
+
return inputValue.replace(substr, "" /* MaskExpression.EMPTY_STRING */);
|
|
3694
|
+
}
|
|
3695
|
+
}
|
|
3696
|
+
return inputValue;
|
|
3697
|
+
};
|
|
3698
|
+
this.checkInputPrecision = (inputValue, precision, decimalMarker) => {
|
|
3699
|
+
let processedInputValue = inputValue;
|
|
3700
|
+
let processedDecimalMarker = decimalMarker;
|
|
3701
|
+
if (precision < Infinity) {
|
|
3702
|
+
// TODO need think about decimalMarker
|
|
3703
|
+
if (Array.isArray(processedDecimalMarker)) {
|
|
3704
|
+
const marker = processedDecimalMarker.find((dm) => dm !== this.thousandSeparator);
|
|
3705
|
+
processedDecimalMarker = marker ? marker : processedDecimalMarker[0];
|
|
3706
|
+
}
|
|
3707
|
+
const precisionRegEx = new RegExp(this._charToRegExpExpression(processedDecimalMarker) + `\\d{${precision}}.*$`);
|
|
3708
|
+
const precisionMatch = processedInputValue.match(precisionRegEx);
|
|
3709
|
+
const precisionMatchLength = (precisionMatch && precisionMatch[0]?.length) ?? 0;
|
|
3710
|
+
if (precisionMatchLength - 1 > precision) {
|
|
3711
|
+
const diff = precisionMatchLength - 1 - precision;
|
|
3712
|
+
processedInputValue = processedInputValue.substring(0, processedInputValue.length - diff);
|
|
3713
|
+
}
|
|
3714
|
+
if (precision === 0 &&
|
|
3715
|
+
this._compareOrIncludes(processedInputValue[processedInputValue.length - 1], processedDecimalMarker, this.thousandSeparator)) {
|
|
3716
|
+
processedInputValue = processedInputValue.substring(0, processedInputValue.length - 1);
|
|
3717
|
+
}
|
|
3718
|
+
}
|
|
3719
|
+
return processedInputValue;
|
|
3720
|
+
};
|
|
3721
|
+
}
|
|
3722
|
+
applyMask(inputValue, maskExpression, position = 0, justPasted = false, backspaced = false,
|
|
3723
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3724
|
+
cb = () => { }) {
|
|
3725
|
+
if (!maskExpression || typeof inputValue !== 'string') {
|
|
3726
|
+
return "" /* MaskExpression.EMPTY_STRING */;
|
|
3727
|
+
}
|
|
3728
|
+
let cursor = 0;
|
|
3729
|
+
let result = '';
|
|
3730
|
+
let multi = false;
|
|
3731
|
+
let backspaceShift = false;
|
|
3732
|
+
let shift = 1;
|
|
3733
|
+
let stepBack = false;
|
|
3734
|
+
let processedValue = inputValue;
|
|
3735
|
+
let processedPosition = position;
|
|
3736
|
+
if (processedValue.slice(0, this.prefix.length) === this.prefix) {
|
|
3737
|
+
processedValue = processedValue.slice(this.prefix.length, processedValue.length);
|
|
3738
|
+
}
|
|
3739
|
+
if (!!this.suffix && processedValue.length > 0) {
|
|
3740
|
+
processedValue = this.checkAndRemoveSuffix(processedValue);
|
|
3741
|
+
}
|
|
3742
|
+
if (processedValue === '(' && this.prefix) {
|
|
3743
|
+
processedValue = '';
|
|
3744
|
+
}
|
|
3745
|
+
const inputArray = processedValue.toString().split("" /* MaskExpression.EMPTY_STRING */);
|
|
3746
|
+
if (this.allowNegativeNumbers &&
|
|
3747
|
+
processedValue.slice(cursor, cursor + 1) === "-" /* MaskExpression.MINUS */) {
|
|
3748
|
+
result += processedValue.slice(cursor, cursor + 1);
|
|
3749
|
+
}
|
|
3750
|
+
if (maskExpression === "IP" /* MaskExpression.IP */) {
|
|
3751
|
+
const valuesIP = processedValue.split("." /* MaskExpression.DOT */);
|
|
3752
|
+
this.ipError = this._validIP(valuesIP);
|
|
3753
|
+
// eslint-disable-next-line no-param-reassign
|
|
3754
|
+
maskExpression = '099.099.099.099';
|
|
3755
|
+
}
|
|
3756
|
+
const arr = [];
|
|
3757
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
3758
|
+
for (let i = 0; i < processedValue.length; i++) {
|
|
3759
|
+
if (processedValue[i]?.match('\\d')) {
|
|
3760
|
+
arr.push(processedValue[i] ?? "" /* MaskExpression.EMPTY_STRING */);
|
|
3761
|
+
}
|
|
3762
|
+
}
|
|
3763
|
+
if (maskExpression === "CPF_CNPJ" /* MaskExpression.CPF_CNPJ */) {
|
|
3764
|
+
this.cpfCnpjError = arr.length !== 11 && arr.length !== 14;
|
|
3765
|
+
if (arr.length > 11) {
|
|
3766
|
+
// eslint-disable-next-line no-param-reassign
|
|
3767
|
+
maskExpression = '00.000.000/0000-00';
|
|
3768
|
+
}
|
|
3769
|
+
else {
|
|
3770
|
+
// eslint-disable-next-line no-param-reassign
|
|
3771
|
+
maskExpression = '000.000.000-00';
|
|
3772
|
+
}
|
|
3773
|
+
}
|
|
3774
|
+
if (maskExpression.startsWith("percent" /* MaskExpression.PERCENT */)) {
|
|
3775
|
+
if (processedValue.match('[a-z]|[A-Z]') ||
|
|
3776
|
+
// eslint-disable-next-line no-useless-escape
|
|
3777
|
+
(processedValue.match(/[-!$%^&*()_+|~=`{}\[\]:";'<>?,\/.]/) && !backspaced)) {
|
|
3778
|
+
processedValue = this._stripToDecimal(processedValue);
|
|
3779
|
+
const precision = this.getPrecision(maskExpression);
|
|
3780
|
+
processedValue = this.checkInputPrecision(processedValue, precision, this.decimalMarker);
|
|
3781
|
+
}
|
|
3782
|
+
const decimalMarker = typeof this.decimalMarker === 'string' ? this.decimalMarker : "." /* MaskExpression.DOT */;
|
|
3783
|
+
if (processedValue.indexOf(decimalMarker) > 0 &&
|
|
3784
|
+
!this.percentage(processedValue.substring(0, processedValue.indexOf(decimalMarker)))) {
|
|
3785
|
+
let base = processedValue.substring(0, processedValue.indexOf(decimalMarker) - 1);
|
|
3786
|
+
if (this.allowNegativeNumbers &&
|
|
3787
|
+
processedValue.slice(cursor, cursor + 1) === "-" /* MaskExpression.MINUS */ &&
|
|
3788
|
+
!backspaced) {
|
|
3789
|
+
base = processedValue.substring(0, processedValue.indexOf(decimalMarker));
|
|
3790
|
+
}
|
|
3791
|
+
processedValue = `${base}${processedValue.substring(processedValue.indexOf(decimalMarker), processedValue.length)}`;
|
|
3792
|
+
}
|
|
3793
|
+
let value = '';
|
|
3794
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
3795
|
+
this.allowNegativeNumbers &&
|
|
3796
|
+
processedValue.slice(cursor, cursor + 1) === "-" /* MaskExpression.MINUS */
|
|
3797
|
+
? (value = `${"-" /* MaskExpression.MINUS */}${processedValue.slice(cursor + 1, cursor + processedValue.length)}`)
|
|
3798
|
+
: (value = processedValue);
|
|
3799
|
+
if (this.percentage(value)) {
|
|
3800
|
+
result = this._splitPercentZero(processedValue);
|
|
3801
|
+
}
|
|
3802
|
+
else {
|
|
3803
|
+
result = this._splitPercentZero(processedValue.substring(0, processedValue.length - 1));
|
|
3804
|
+
}
|
|
3805
|
+
}
|
|
3806
|
+
else if (maskExpression.startsWith("separator" /* MaskExpression.SEPARATOR */)) {
|
|
3807
|
+
if (processedValue.match('[wа-яА-Я]') ||
|
|
3808
|
+
processedValue.match('[ЁёА-я]') ||
|
|
3809
|
+
processedValue.match('[a-z]|[A-Z]') ||
|
|
3810
|
+
processedValue.match(/[-@#!$%\\^&*()_£¬'+|~=`{}\]:";<>.?/]/) ||
|
|
3811
|
+
processedValue.match('[^A-Za-z0-9,]')) {
|
|
3812
|
+
processedValue = this._stripToDecimal(processedValue);
|
|
3813
|
+
}
|
|
3814
|
+
const precision = this.getPrecision(maskExpression);
|
|
3815
|
+
let decimalMarker = this.decimalMarker;
|
|
3816
|
+
if (Array.isArray(this.decimalMarker)) {
|
|
3817
|
+
if (this.actualValue.includes(this.decimalMarker[0]) ||
|
|
3818
|
+
this.actualValue.includes(this.decimalMarker[1])) {
|
|
3819
|
+
decimalMarker = this.actualValue.includes(this.decimalMarker[0])
|
|
3820
|
+
? this.decimalMarker[0]
|
|
3821
|
+
: this.decimalMarker[1];
|
|
3822
|
+
}
|
|
3823
|
+
else {
|
|
3824
|
+
decimalMarker = this.decimalMarker.find((dm) => dm !== this.thousandSeparator);
|
|
3825
|
+
}
|
|
3826
|
+
}
|
|
3827
|
+
if (backspaced) {
|
|
3828
|
+
const { decimalMarkerIndex, nonZeroIndex } = this._findFirstNonZeroAndDecimalIndex(processedValue, decimalMarker);
|
|
3829
|
+
const zeroIndexMinus = processedValue[0] === "-" /* MaskExpression.MINUS */;
|
|
3830
|
+
const zeroIndexNumberZero = processedValue[0] === "0" /* MaskExpression.NUMBER_ZERO */;
|
|
3831
|
+
const zeroIndexDecimalMarker = processedValue[0] === decimalMarker;
|
|
3832
|
+
const firstIndexDecimalMarker = processedValue[1] === decimalMarker;
|
|
3833
|
+
if ((zeroIndexDecimalMarker && !nonZeroIndex) ||
|
|
3834
|
+
(zeroIndexMinus && firstIndexDecimalMarker && !nonZeroIndex) ||
|
|
3835
|
+
(zeroIndexNumberZero && !decimalMarkerIndex && !nonZeroIndex)) {
|
|
3836
|
+
processedValue = "0" /* MaskExpression.NUMBER_ZERO */;
|
|
3837
|
+
}
|
|
3838
|
+
if (decimalMarkerIndex &&
|
|
3839
|
+
nonZeroIndex &&
|
|
3840
|
+
zeroIndexMinus &&
|
|
3841
|
+
processedPosition === 1) {
|
|
3842
|
+
if (decimalMarkerIndex < nonZeroIndex || decimalMarkerIndex > nonZeroIndex) {
|
|
3843
|
+
processedValue = "-" /* MaskExpression.MINUS */ + processedValue.slice(nonZeroIndex);
|
|
3844
|
+
}
|
|
3845
|
+
}
|
|
3846
|
+
if (!decimalMarkerIndex && nonZeroIndex && processedValue.length > nonZeroIndex) {
|
|
3847
|
+
processedValue = zeroIndexMinus
|
|
3848
|
+
? "-" /* MaskExpression.MINUS */ + processedValue.slice(nonZeroIndex)
|
|
3849
|
+
: processedValue.slice(nonZeroIndex);
|
|
3850
|
+
}
|
|
3851
|
+
if (decimalMarkerIndex && nonZeroIndex && processedPosition === 0) {
|
|
3852
|
+
if (decimalMarkerIndex < nonZeroIndex) {
|
|
3853
|
+
processedValue = processedValue.slice(decimalMarkerIndex - 1);
|
|
3854
|
+
}
|
|
3855
|
+
if (decimalMarkerIndex > nonZeroIndex) {
|
|
3856
|
+
processedValue = processedValue.slice(nonZeroIndex);
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3859
|
+
}
|
|
3860
|
+
if (precision === 0) {
|
|
3861
|
+
processedValue = this.allowNegativeNumbers
|
|
3862
|
+
? processedValue.length > 2 &&
|
|
3863
|
+
processedValue[0] === "-" /* MaskExpression.MINUS */ &&
|
|
3864
|
+
processedValue[1] === "0" /* MaskExpression.NUMBER_ZERO */ &&
|
|
3865
|
+
processedValue[2] !== this.thousandSeparator &&
|
|
3866
|
+
processedValue[2] !== "," /* MaskExpression.COMMA */ &&
|
|
3867
|
+
processedValue[2] !== "." /* MaskExpression.DOT */
|
|
3868
|
+
? '-' + processedValue.slice(2, processedValue.length)
|
|
3869
|
+
: processedValue[0] === "0" /* MaskExpression.NUMBER_ZERO */ &&
|
|
3870
|
+
processedValue.length > 1 &&
|
|
3871
|
+
processedValue[1] !== this.thousandSeparator &&
|
|
3872
|
+
processedValue[1] !== "," /* MaskExpression.COMMA */ &&
|
|
3873
|
+
processedValue[1] !== "." /* MaskExpression.DOT */
|
|
3874
|
+
? processedValue.slice(1, processedValue.length)
|
|
3875
|
+
: processedValue
|
|
3876
|
+
: processedValue.length > 1 &&
|
|
3877
|
+
processedValue[0] === "0" /* MaskExpression.NUMBER_ZERO */ &&
|
|
3878
|
+
processedValue[1] !== this.thousandSeparator &&
|
|
3879
|
+
processedValue[1] !== "," /* MaskExpression.COMMA */ &&
|
|
3880
|
+
processedValue[1] !== "." /* MaskExpression.DOT */
|
|
3881
|
+
? processedValue.slice(1, processedValue.length)
|
|
3882
|
+
: processedValue;
|
|
3883
|
+
}
|
|
3884
|
+
else {
|
|
3885
|
+
if (processedValue[0] === decimalMarker &&
|
|
3886
|
+
processedValue.length > 1 &&
|
|
3887
|
+
!backspaced) {
|
|
3888
|
+
processedValue =
|
|
3889
|
+
"0" /* MaskExpression.NUMBER_ZERO */ +
|
|
3890
|
+
processedValue.slice(0, processedValue.length + 1);
|
|
3891
|
+
this.plusOnePosition = true;
|
|
3892
|
+
}
|
|
3893
|
+
if (processedValue[0] === "0" /* MaskExpression.NUMBER_ZERO */ &&
|
|
3894
|
+
processedValue[1] !== decimalMarker &&
|
|
3895
|
+
processedValue[1] !== this.thousandSeparator &&
|
|
3896
|
+
!backspaced) {
|
|
3897
|
+
processedValue =
|
|
3898
|
+
processedValue.length > 1
|
|
3899
|
+
? processedValue.slice(0, 1) +
|
|
3900
|
+
decimalMarker +
|
|
3901
|
+
processedValue.slice(1, processedValue.length + 1)
|
|
3902
|
+
: processedValue;
|
|
3903
|
+
this.plusOnePosition = true;
|
|
3904
|
+
}
|
|
3905
|
+
if (this.allowNegativeNumbers &&
|
|
3906
|
+
!backspaced &&
|
|
3907
|
+
processedValue[0] === "-" /* MaskExpression.MINUS */ &&
|
|
3908
|
+
(processedValue[1] === decimalMarker ||
|
|
3909
|
+
processedValue[1] === "0" /* MaskExpression.NUMBER_ZERO */)) {
|
|
3910
|
+
processedValue =
|
|
3911
|
+
processedValue[1] === decimalMarker && processedValue.length > 2
|
|
3912
|
+
? processedValue.slice(0, 1) +
|
|
3913
|
+
"0" /* MaskExpression.NUMBER_ZERO */ +
|
|
3914
|
+
processedValue.slice(1, processedValue.length)
|
|
3915
|
+
: processedValue[1] === "0" /* MaskExpression.NUMBER_ZERO */ &&
|
|
3916
|
+
processedValue.length > 2 &&
|
|
3917
|
+
processedValue[2] !== decimalMarker
|
|
3918
|
+
? processedValue.slice(0, 2) +
|
|
3919
|
+
decimalMarker +
|
|
3920
|
+
processedValue.slice(2, processedValue.length)
|
|
3921
|
+
: processedValue;
|
|
3922
|
+
this.plusOnePosition = true;
|
|
3923
|
+
}
|
|
3924
|
+
}
|
|
3925
|
+
// TODO: we had different rexexps here for the different cases... but tests dont seam to bother - check this
|
|
3926
|
+
// separator: no COMMA, dot-sep: no SPACE, COMMA OK, comma-sep: no SPACE, COMMA OK
|
|
3927
|
+
const thousandSeparatorCharEscaped = this._charToRegExpExpression(this.thousandSeparator);
|
|
3928
|
+
let invalidChars = '@#!$%^&*()_+|~=`{}\\[\\]:\\s,\\.";<>?\\/'.replace(thousandSeparatorCharEscaped, '');
|
|
3929
|
+
//.replace(decimalMarkerEscaped, '');
|
|
3930
|
+
if (Array.isArray(this.decimalMarker)) {
|
|
3931
|
+
for (const marker of this.decimalMarker) {
|
|
3932
|
+
invalidChars = invalidChars.replace(this._charToRegExpExpression(marker), "" /* MaskExpression.EMPTY_STRING */);
|
|
3933
|
+
}
|
|
3934
|
+
}
|
|
3935
|
+
else {
|
|
3936
|
+
invalidChars = invalidChars.replace(this._charToRegExpExpression(this.decimalMarker), '');
|
|
3937
|
+
}
|
|
3938
|
+
const invalidCharRegexp = new RegExp('[' + invalidChars + ']');
|
|
3939
|
+
if (processedValue.match(invalidCharRegexp)) {
|
|
3940
|
+
processedValue = processedValue.substring(0, processedValue.length - 1);
|
|
3941
|
+
}
|
|
3942
|
+
processedValue = this.checkInputPrecision(processedValue, precision, this.decimalMarker);
|
|
3943
|
+
const strForSep = processedValue.replace(new RegExp(thousandSeparatorCharEscaped, 'g'), '');
|
|
3944
|
+
result = this._formatWithSeparators(strForSep, this.thousandSeparator, this.decimalMarker, precision);
|
|
3945
|
+
const commaShift = result.indexOf("," /* MaskExpression.COMMA */) - processedValue.indexOf("," /* MaskExpression.COMMA */);
|
|
3946
|
+
const shiftStep = result.length - processedValue.length;
|
|
3947
|
+
const backspacedDecimalMarkerWithSeparatorLimit = backspaced && result.length < inputValue.length && this.separatorLimit;
|
|
3948
|
+
if ((result[processedPosition - 1] === this.thousandSeparator ||
|
|
3949
|
+
result[processedPosition - this.prefix.length]) &&
|
|
3950
|
+
this.prefix &&
|
|
3951
|
+
backspaced) {
|
|
3952
|
+
processedPosition = processedPosition - 1;
|
|
3953
|
+
}
|
|
3954
|
+
else if ((shiftStep > 0 && result[processedPosition] !== this.thousandSeparator) ||
|
|
3955
|
+
backspacedDecimalMarkerWithSeparatorLimit) {
|
|
3956
|
+
backspaceShift = true;
|
|
3957
|
+
let _shift = 0;
|
|
3958
|
+
do {
|
|
3959
|
+
this._shift.add(processedPosition + _shift);
|
|
3960
|
+
_shift++;
|
|
3961
|
+
} while (_shift < shiftStep);
|
|
3962
|
+
}
|
|
3963
|
+
else if (result[processedPosition - 1] === this.thousandSeparator ||
|
|
3964
|
+
shiftStep === -4 ||
|
|
3965
|
+
shiftStep === -3 ||
|
|
3966
|
+
result[processedPosition] === this.thousandSeparator) {
|
|
3967
|
+
this._shift.clear();
|
|
3968
|
+
this._shift.add(processedPosition - 1);
|
|
3969
|
+
}
|
|
3970
|
+
else if ((commaShift !== 0 &&
|
|
3971
|
+
processedPosition > 0 &&
|
|
3972
|
+
!(result.indexOf("," /* MaskExpression.COMMA */) >= processedPosition &&
|
|
3973
|
+
processedPosition > 3)) ||
|
|
3974
|
+
(!(result.indexOf("." /* MaskExpression.DOT */) >= processedPosition && processedPosition > 3) &&
|
|
3975
|
+
shiftStep <= 0)) {
|
|
3976
|
+
this._shift.clear();
|
|
3977
|
+
backspaceShift = true;
|
|
3978
|
+
shift = shiftStep;
|
|
3979
|
+
processedPosition += shiftStep;
|
|
3980
|
+
this._shift.add(processedPosition);
|
|
3981
|
+
}
|
|
3982
|
+
else {
|
|
3983
|
+
this._shift.clear();
|
|
3984
|
+
}
|
|
3985
|
+
}
|
|
3986
|
+
else {
|
|
3987
|
+
for (
|
|
3988
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
3989
|
+
let i = 0, inputSymbol = inputArray[0]; i < inputArray.length; i++, inputSymbol = inputArray[i] ?? "" /* MaskExpression.EMPTY_STRING */) {
|
|
3990
|
+
if (cursor === maskExpression.length) {
|
|
3991
|
+
break;
|
|
3992
|
+
}
|
|
3993
|
+
const symbolStarInPattern = "*" /* MaskExpression.SYMBOL_STAR */ in this.patterns;
|
|
3994
|
+
if (this._checkSymbolMask(inputSymbol, maskExpression[cursor] ?? "" /* MaskExpression.EMPTY_STRING */) &&
|
|
3995
|
+
maskExpression[cursor + 1] === "?" /* MaskExpression.SYMBOL_QUESTION */) {
|
|
3996
|
+
result += inputSymbol;
|
|
3997
|
+
cursor += 2;
|
|
3998
|
+
}
|
|
3999
|
+
else if (maskExpression[cursor + 1] === "*" /* MaskExpression.SYMBOL_STAR */ &&
|
|
4000
|
+
multi &&
|
|
4001
|
+
this._checkSymbolMask(inputSymbol, maskExpression[cursor + 2] ?? "" /* MaskExpression.EMPTY_STRING */)) {
|
|
4002
|
+
result += inputSymbol;
|
|
4003
|
+
cursor += 3;
|
|
4004
|
+
multi = false;
|
|
4005
|
+
}
|
|
4006
|
+
else if (this._checkSymbolMask(inputSymbol, maskExpression[cursor] ?? "" /* MaskExpression.EMPTY_STRING */) &&
|
|
4007
|
+
maskExpression[cursor + 1] === "*" /* MaskExpression.SYMBOL_STAR */ &&
|
|
4008
|
+
!symbolStarInPattern) {
|
|
4009
|
+
result += inputSymbol;
|
|
4010
|
+
multi = true;
|
|
4011
|
+
}
|
|
4012
|
+
else if (maskExpression[cursor + 1] === "?" /* MaskExpression.SYMBOL_QUESTION */ &&
|
|
4013
|
+
this._checkSymbolMask(inputSymbol, maskExpression[cursor + 2] ?? "" /* MaskExpression.EMPTY_STRING */)) {
|
|
4014
|
+
result += inputSymbol;
|
|
4015
|
+
cursor += 3;
|
|
4016
|
+
}
|
|
4017
|
+
else if (this._checkSymbolMask(inputSymbol, maskExpression[cursor] ?? "" /* MaskExpression.EMPTY_STRING */)) {
|
|
4018
|
+
if (maskExpression[cursor] === "H" /* MaskExpression.HOURS */) {
|
|
4019
|
+
if (this.apm ? Number(inputSymbol) > 9 : Number(inputSymbol) > 2) {
|
|
4020
|
+
processedPosition = !this.leadZeroDateTime
|
|
4021
|
+
? processedPosition + 1
|
|
4022
|
+
: processedPosition;
|
|
4023
|
+
cursor += 1;
|
|
4024
|
+
this._shiftStep(cursor);
|
|
4025
|
+
i--;
|
|
4026
|
+
if (this.leadZeroDateTime) {
|
|
4027
|
+
result += '0';
|
|
4028
|
+
}
|
|
4029
|
+
continue;
|
|
4030
|
+
}
|
|
4031
|
+
}
|
|
4032
|
+
if (maskExpression[cursor] === "h" /* MaskExpression.HOUR */) {
|
|
4033
|
+
if (this.apm
|
|
4034
|
+
? (result.length === 1 && Number(result) > 1) ||
|
|
4035
|
+
(result === '1' && Number(inputSymbol) > 2) ||
|
|
4036
|
+
(processedValue.slice(cursor - 1, cursor).length === 1 &&
|
|
4037
|
+
Number(processedValue.slice(cursor - 1, cursor)) > 2) ||
|
|
4038
|
+
(processedValue.slice(cursor - 1, cursor) === '1' &&
|
|
4039
|
+
Number(inputSymbol) > 2)
|
|
4040
|
+
: (result === '2' && Number(inputSymbol) > 3) ||
|
|
4041
|
+
((result.slice(cursor - 2, cursor) === '2' ||
|
|
4042
|
+
result.slice(cursor - 3, cursor) === '2' ||
|
|
4043
|
+
result.slice(cursor - 4, cursor) === '2' ||
|
|
4044
|
+
result.slice(cursor - 1, cursor) === '2') &&
|
|
4045
|
+
Number(inputSymbol) > 3 &&
|
|
4046
|
+
cursor > 10)) {
|
|
4047
|
+
processedPosition = processedPosition + 1;
|
|
4048
|
+
cursor += 1;
|
|
4049
|
+
i--;
|
|
4050
|
+
continue;
|
|
4051
|
+
}
|
|
4052
|
+
}
|
|
4053
|
+
if (maskExpression[cursor] === "m" /* MaskExpression.MINUTE */ ||
|
|
4054
|
+
maskExpression[cursor] === "s" /* MaskExpression.SECOND */) {
|
|
4055
|
+
if (Number(inputSymbol) > 5) {
|
|
4056
|
+
processedPosition = !this.leadZeroDateTime
|
|
4057
|
+
? processedPosition + 1
|
|
4058
|
+
: processedPosition;
|
|
4059
|
+
cursor += 1;
|
|
4060
|
+
this._shiftStep(cursor);
|
|
4061
|
+
i--;
|
|
4062
|
+
if (this.leadZeroDateTime) {
|
|
4063
|
+
result += '0';
|
|
4064
|
+
}
|
|
4065
|
+
continue;
|
|
4066
|
+
}
|
|
4067
|
+
}
|
|
4068
|
+
const daysCount = 31;
|
|
4069
|
+
const inputValueCursor = processedValue[cursor];
|
|
4070
|
+
const inputValueCursorPlusOne = processedValue[cursor + 1];
|
|
4071
|
+
const inputValueCursorPlusTwo = processedValue[cursor + 2];
|
|
4072
|
+
const inputValueCursorMinusOne = processedValue[cursor - 1];
|
|
4073
|
+
const inputValueCursorMinusTwo = processedValue[cursor - 2];
|
|
4074
|
+
const inputValueSliceMinusThreeMinusOne = processedValue.slice(cursor - 3, cursor - 1);
|
|
4075
|
+
const inputValueSliceMinusOnePlusOne = processedValue.slice(cursor - 1, cursor + 1);
|
|
4076
|
+
const inputValueSliceCursorPlusTwo = processedValue.slice(cursor, cursor + 2);
|
|
4077
|
+
const inputValueSliceMinusTwoCursor = processedValue.slice(cursor - 2, cursor);
|
|
4078
|
+
if (maskExpression[cursor] === "d" /* MaskExpression.DAY */) {
|
|
4079
|
+
const maskStartWithMonth = maskExpression.slice(0, 2) === "M0" /* MaskExpression.MONTHS */;
|
|
4080
|
+
const startWithMonthInput = maskExpression.slice(0, 2) === "M0" /* MaskExpression.MONTHS */ &&
|
|
4081
|
+
this.specialCharacters.includes(inputValueCursorMinusTwo);
|
|
4082
|
+
if ((Number(inputSymbol) > 3 && this.leadZeroDateTime) ||
|
|
4083
|
+
(!maskStartWithMonth &&
|
|
4084
|
+
(Number(inputValueSliceCursorPlusTwo) > daysCount ||
|
|
4085
|
+
Number(inputValueSliceMinusOnePlusOne) > daysCount ||
|
|
4086
|
+
this.specialCharacters.includes(inputValueCursorPlusOne))) ||
|
|
4087
|
+
(startWithMonthInput
|
|
4088
|
+
? Number(inputValueSliceMinusOnePlusOne) > daysCount ||
|
|
4089
|
+
(!this.specialCharacters.includes(inputValueCursor) &&
|
|
4090
|
+
this.specialCharacters.includes(inputValueCursorPlusTwo)) ||
|
|
4091
|
+
this.specialCharacters.includes(inputValueCursor)
|
|
4092
|
+
: Number(inputValueSliceCursorPlusTwo) > daysCount ||
|
|
4093
|
+
(this.specialCharacters.includes(inputValueCursorPlusOne) &&
|
|
4094
|
+
!backspaced))) {
|
|
4095
|
+
processedPosition = !this.leadZeroDateTime
|
|
4096
|
+
? processedPosition + 1
|
|
4097
|
+
: processedPosition;
|
|
4098
|
+
cursor += 1;
|
|
4099
|
+
this._shiftStep(cursor);
|
|
4100
|
+
i--;
|
|
4101
|
+
if (this.leadZeroDateTime) {
|
|
4102
|
+
result += '0';
|
|
4103
|
+
}
|
|
4104
|
+
continue;
|
|
4105
|
+
}
|
|
4106
|
+
}
|
|
4107
|
+
if (maskExpression[cursor] === "M" /* MaskExpression.MONTH */) {
|
|
4108
|
+
const monthsCount = 12;
|
|
4109
|
+
// mask without day
|
|
4110
|
+
const withoutDays = cursor === 0 &&
|
|
4111
|
+
(Number(inputSymbol) > 2 ||
|
|
4112
|
+
Number(inputValueSliceCursorPlusTwo) > monthsCount ||
|
|
4113
|
+
(this.specialCharacters.includes(inputValueCursorPlusOne) &&
|
|
4114
|
+
!backspaced));
|
|
4115
|
+
// day<10 && month<12 for input
|
|
4116
|
+
const specialChart = maskExpression.slice(cursor + 2, cursor + 3);
|
|
4117
|
+
const day1monthInput = inputValueSliceMinusThreeMinusOne.includes(specialChart) &&
|
|
4118
|
+
maskExpression.includes('d0') &&
|
|
4119
|
+
((this.specialCharacters.includes(inputValueCursorMinusTwo) &&
|
|
4120
|
+
Number(inputValueSliceMinusOnePlusOne) > monthsCount &&
|
|
4121
|
+
!this.specialCharacters.includes(inputValueCursor)) ||
|
|
4122
|
+
this.specialCharacters.includes(inputValueCursor));
|
|
4123
|
+
// month<12 && day<10 for input
|
|
4124
|
+
const day2monthInput = Number(inputValueSliceMinusThreeMinusOne) <= daysCount &&
|
|
4125
|
+
!this.specialCharacters.includes(inputValueSliceMinusThreeMinusOne) &&
|
|
4126
|
+
this.specialCharacters.includes(inputValueCursorMinusOne) &&
|
|
4127
|
+
(Number(inputValueSliceCursorPlusTwo) > monthsCount ||
|
|
4128
|
+
this.specialCharacters.includes(inputValueCursorPlusOne));
|
|
4129
|
+
// cursor === 5 && without days
|
|
4130
|
+
const day2monthInputDot = (Number(inputValueSliceCursorPlusTwo) > monthsCount && cursor === 5) ||
|
|
4131
|
+
(this.specialCharacters.includes(inputValueCursorPlusOne) &&
|
|
4132
|
+
cursor === 5);
|
|
4133
|
+
// // day<10 && month<12 for paste whole data
|
|
4134
|
+
const day1monthPaste = Number(inputValueSliceMinusThreeMinusOne) > daysCount &&
|
|
4135
|
+
!this.specialCharacters.includes(inputValueSliceMinusThreeMinusOne) &&
|
|
4136
|
+
!this.specialCharacters.includes(inputValueSliceMinusTwoCursor) &&
|
|
4137
|
+
Number(inputValueSliceMinusTwoCursor) > monthsCount &&
|
|
4138
|
+
maskExpression.includes('d0');
|
|
4139
|
+
// 10<day<31 && month<12 for paste whole data
|
|
4140
|
+
const day2monthPaste = Number(inputValueSliceMinusThreeMinusOne) <= daysCount &&
|
|
4141
|
+
!this.specialCharacters.includes(inputValueSliceMinusThreeMinusOne) &&
|
|
4142
|
+
!this.specialCharacters.includes(inputValueCursorMinusOne) &&
|
|
4143
|
+
Number(inputValueSliceMinusOnePlusOne) > monthsCount;
|
|
4144
|
+
if ((Number(inputSymbol) > 1 && this.leadZeroDateTime) ||
|
|
4145
|
+
withoutDays ||
|
|
4146
|
+
day1monthInput ||
|
|
4147
|
+
day2monthPaste ||
|
|
4148
|
+
day1monthPaste ||
|
|
4149
|
+
day2monthInput ||
|
|
4150
|
+
(day2monthInputDot && !this.leadZeroDateTime)) {
|
|
4151
|
+
processedPosition = !this.leadZeroDateTime
|
|
4152
|
+
? processedPosition + 1
|
|
4153
|
+
: processedPosition;
|
|
4154
|
+
cursor += 1;
|
|
4155
|
+
this._shiftStep(cursor);
|
|
4156
|
+
i--;
|
|
4157
|
+
if (this.leadZeroDateTime) {
|
|
4158
|
+
result += '0';
|
|
4159
|
+
}
|
|
4160
|
+
continue;
|
|
4161
|
+
}
|
|
4162
|
+
}
|
|
4163
|
+
result += inputSymbol;
|
|
4164
|
+
cursor++;
|
|
4165
|
+
}
|
|
4166
|
+
else if (this.specialCharacters.includes(inputSymbol) &&
|
|
4167
|
+
maskExpression[cursor] === inputSymbol) {
|
|
4168
|
+
result += inputSymbol;
|
|
4169
|
+
cursor++;
|
|
4170
|
+
}
|
|
4171
|
+
else if (this.specialCharacters.indexOf(maskExpression[cursor] ?? "" /* MaskExpression.EMPTY_STRING */) !== -1) {
|
|
4172
|
+
result += maskExpression[cursor];
|
|
4173
|
+
cursor++;
|
|
4174
|
+
this._shiftStep(cursor);
|
|
4175
|
+
i--;
|
|
4176
|
+
}
|
|
4177
|
+
else if (maskExpression[cursor] === "9" /* MaskExpression.NUMBER_NINE */ &&
|
|
4178
|
+
this.showMaskTyped) {
|
|
4179
|
+
this._shiftStep(cursor);
|
|
4180
|
+
}
|
|
4181
|
+
else if (this.patterns[maskExpression[cursor] ?? "" /* MaskExpression.EMPTY_STRING */] &&
|
|
4182
|
+
this.patterns[maskExpression[cursor] ?? "" /* MaskExpression.EMPTY_STRING */]?.optional) {
|
|
4183
|
+
if (!!inputArray[cursor] &&
|
|
4184
|
+
maskExpression !== '099.099.099.099' &&
|
|
4185
|
+
maskExpression !== '000.000.000-00' &&
|
|
4186
|
+
maskExpression !== '00.000.000/0000-00' &&
|
|
4187
|
+
!maskExpression.match(/^9+\.0+$/) &&
|
|
4188
|
+
!this.patterns[maskExpression[cursor] ?? "" /* MaskExpression.EMPTY_STRING */]
|
|
4189
|
+
?.optional) {
|
|
4190
|
+
result += inputArray[cursor];
|
|
4191
|
+
}
|
|
4192
|
+
if (maskExpression.includes("9" /* MaskExpression.NUMBER_NINE */ + "*" /* MaskExpression.SYMBOL_STAR */) &&
|
|
4193
|
+
maskExpression.includes("0" /* MaskExpression.NUMBER_ZERO */ + "*" /* MaskExpression.SYMBOL_STAR */)) {
|
|
4194
|
+
cursor++;
|
|
4195
|
+
}
|
|
4196
|
+
cursor++;
|
|
4197
|
+
i--;
|
|
4198
|
+
}
|
|
4199
|
+
else if (this.maskExpression[cursor + 1] === "*" /* MaskExpression.SYMBOL_STAR */ &&
|
|
4200
|
+
this._findSpecialChar(this.maskExpression[cursor + 2] ?? "" /* MaskExpression.EMPTY_STRING */) &&
|
|
4201
|
+
this._findSpecialChar(inputSymbol) === this.maskExpression[cursor + 2] &&
|
|
4202
|
+
multi) {
|
|
4203
|
+
cursor += 3;
|
|
4204
|
+
result += inputSymbol;
|
|
4205
|
+
}
|
|
4206
|
+
else if (this.maskExpression[cursor + 1] === "?" /* MaskExpression.SYMBOL_QUESTION */ &&
|
|
4207
|
+
this._findSpecialChar(this.maskExpression[cursor + 2] ?? "" /* MaskExpression.EMPTY_STRING */) &&
|
|
4208
|
+
this._findSpecialChar(inputSymbol) === this.maskExpression[cursor + 2] &&
|
|
4209
|
+
multi) {
|
|
4210
|
+
cursor += 3;
|
|
4211
|
+
result += inputSymbol;
|
|
4212
|
+
}
|
|
4213
|
+
else if (this.showMaskTyped &&
|
|
4214
|
+
this.specialCharacters.indexOf(inputSymbol) < 0 &&
|
|
4215
|
+
inputSymbol !== this.placeHolderCharacter &&
|
|
4216
|
+
this.placeHolderCharacter.length === 1) {
|
|
4217
|
+
stepBack = true;
|
|
4218
|
+
}
|
|
4219
|
+
}
|
|
4220
|
+
}
|
|
4221
|
+
if (result[processedPosition - 1] &&
|
|
4222
|
+
result.length + 1 === maskExpression.length &&
|
|
4223
|
+
this.specialCharacters.indexOf(maskExpression[maskExpression.length - 1] ?? "" /* MaskExpression.EMPTY_STRING */) !== -1) {
|
|
4224
|
+
result += maskExpression[maskExpression.length - 1];
|
|
4225
|
+
}
|
|
4226
|
+
let newPosition = processedPosition + 1;
|
|
4227
|
+
while (this._shift.has(newPosition)) {
|
|
4228
|
+
shift++;
|
|
4229
|
+
newPosition++;
|
|
4230
|
+
}
|
|
4231
|
+
let actualShift = justPasted && !maskExpression.startsWith("separator" /* MaskExpression.SEPARATOR */)
|
|
4232
|
+
? cursor
|
|
4233
|
+
: this._shift.has(processedPosition)
|
|
4234
|
+
? shift
|
|
4235
|
+
: 0;
|
|
4236
|
+
if (stepBack) {
|
|
4237
|
+
actualShift--;
|
|
4238
|
+
}
|
|
4239
|
+
cb(actualShift, backspaceShift);
|
|
4240
|
+
if (shift < 0) {
|
|
4241
|
+
this._shift.clear();
|
|
4242
|
+
}
|
|
4243
|
+
let onlySpecial = false;
|
|
4244
|
+
if (backspaced) {
|
|
4245
|
+
onlySpecial = inputArray.every((char) => this.specialCharacters.includes(char));
|
|
4246
|
+
}
|
|
4247
|
+
let res = `${this.prefix}${onlySpecial ? "" /* MaskExpression.EMPTY_STRING */ : result}${this.showMaskTyped ? '' : this.suffix}`;
|
|
4248
|
+
if (result.length === 0) {
|
|
4249
|
+
res = this.instantPrefix ? `${this.prefix}${result}` : `${result}`;
|
|
4250
|
+
}
|
|
4251
|
+
const isSpecialCharacterMaskFirstSymbol = processedValue.length === 1 &&
|
|
4252
|
+
this.specialCharacters.includes(maskExpression[0]) &&
|
|
4253
|
+
processedValue !== maskExpression[0];
|
|
4254
|
+
if (!this._checkSymbolMask(processedValue, maskExpression[1]) &&
|
|
4255
|
+
isSpecialCharacterMaskFirstSymbol) {
|
|
4256
|
+
return '';
|
|
4257
|
+
}
|
|
4258
|
+
if (result.includes("-" /* MaskExpression.MINUS */) && this.prefix && this.allowNegativeNumbers) {
|
|
4259
|
+
if (backspaced && result === "-" /* MaskExpression.MINUS */) {
|
|
4260
|
+
return '';
|
|
4261
|
+
}
|
|
4262
|
+
res = `${"-" /* MaskExpression.MINUS */}${this.prefix}${result
|
|
4263
|
+
.split("-" /* MaskExpression.MINUS */)
|
|
4264
|
+
.join("" /* MaskExpression.EMPTY_STRING */)}${this.suffix}`;
|
|
4265
|
+
}
|
|
4266
|
+
return res;
|
|
4267
|
+
}
|
|
4268
|
+
_findDropSpecialChar(inputSymbol) {
|
|
4269
|
+
if (Array.isArray(this.dropSpecialCharacters)) {
|
|
4270
|
+
return this.dropSpecialCharacters.find((val) => val === inputSymbol);
|
|
4271
|
+
}
|
|
4272
|
+
return this._findSpecialChar(inputSymbol);
|
|
4273
|
+
}
|
|
4274
|
+
_findSpecialChar(inputSymbol) {
|
|
4275
|
+
return this.specialCharacters.find((val) => val === inputSymbol);
|
|
4276
|
+
}
|
|
4277
|
+
_checkSymbolMask(inputSymbol, maskSymbol) {
|
|
4278
|
+
this.patterns = this.customPattern ? this.customPattern : this.patterns;
|
|
4279
|
+
return ((this.patterns?.[maskSymbol]?.pattern &&
|
|
4280
|
+
this.patterns?.[maskSymbol]?.pattern.test(inputSymbol)) ??
|
|
4281
|
+
false);
|
|
4282
|
+
}
|
|
4283
|
+
_stripToDecimal(str) {
|
|
4284
|
+
return str
|
|
4285
|
+
.split("" /* MaskExpression.EMPTY_STRING */)
|
|
4286
|
+
.filter((i, idx) => {
|
|
4287
|
+
const isDecimalMarker = typeof this.decimalMarker === 'string'
|
|
4288
|
+
? i === this.decimalMarker
|
|
4289
|
+
: // TODO (inepipenko) use utility type
|
|
4290
|
+
this.decimalMarker.includes(i);
|
|
4291
|
+
return (i.match('^-?\\d') ||
|
|
4292
|
+
i === this.thousandSeparator ||
|
|
4293
|
+
isDecimalMarker ||
|
|
4294
|
+
(i === "-" /* MaskExpression.MINUS */ && idx === 0 && this.allowNegativeNumbers));
|
|
4295
|
+
})
|
|
4296
|
+
.join("" /* MaskExpression.EMPTY_STRING */);
|
|
4297
|
+
}
|
|
4298
|
+
_charToRegExpExpression(char) {
|
|
4299
|
+
// if (Array.isArray(char)) {
|
|
4300
|
+
// return char.map((v) => ('[\\^$.|?*+()'.indexOf(v) >= 0 ? `\\${v}` : v)).join('|');
|
|
4301
|
+
// }
|
|
4302
|
+
if (char) {
|
|
4303
|
+
const charsToEscape = '[\\^$.|?*+()';
|
|
4304
|
+
return char === ' ' ? '\\s' : charsToEscape.indexOf(char) >= 0 ? `\\${char}` : char;
|
|
4305
|
+
}
|
|
4306
|
+
return char;
|
|
4307
|
+
}
|
|
4308
|
+
_shiftStep(cursor) {
|
|
4309
|
+
this._shift.add(cursor + this.prefix.length || 0);
|
|
4310
|
+
}
|
|
4311
|
+
_compareOrIncludes(value, comparedValue, excludedValue) {
|
|
4312
|
+
return Array.isArray(comparedValue)
|
|
4313
|
+
? comparedValue.filter((v) => v !== excludedValue).includes(value)
|
|
4314
|
+
: value === comparedValue;
|
|
4315
|
+
}
|
|
4316
|
+
_validIP(valuesIP) {
|
|
4317
|
+
return !(valuesIP.length === 4 &&
|
|
4318
|
+
!valuesIP.some((value, index) => {
|
|
4319
|
+
if (valuesIP.length !== index + 1) {
|
|
4320
|
+
return value === "" /* MaskExpression.EMPTY_STRING */ || Number(value) > 255;
|
|
4321
|
+
}
|
|
4322
|
+
return value === "" /* MaskExpression.EMPTY_STRING */ || Number(value.substring(0, 3)) > 255;
|
|
4323
|
+
}));
|
|
4324
|
+
}
|
|
4325
|
+
_splitPercentZero(value) {
|
|
4326
|
+
if (value === "-" /* MaskExpression.MINUS */ && this.allowNegativeNumbers) {
|
|
4327
|
+
return value;
|
|
4328
|
+
}
|
|
4329
|
+
const decimalIndex = typeof this.decimalMarker === 'string'
|
|
4330
|
+
? value.indexOf(this.decimalMarker)
|
|
4331
|
+
: value.indexOf("." /* MaskExpression.DOT */);
|
|
4332
|
+
const emptyOrMinus = this.allowNegativeNumbers && value.includes("-" /* MaskExpression.MINUS */) ? '-' : '';
|
|
4333
|
+
if (decimalIndex === -1) {
|
|
4334
|
+
const parsedValue = parseInt(emptyOrMinus ? value.slice(1, value.length) : value, 10);
|
|
4335
|
+
return isNaN(parsedValue)
|
|
4336
|
+
? "" /* MaskExpression.EMPTY_STRING */
|
|
4337
|
+
: `${emptyOrMinus}${parsedValue}`;
|
|
4338
|
+
}
|
|
4339
|
+
else {
|
|
4340
|
+
const integerPart = parseInt(value.replace('-', '').substring(0, decimalIndex), 10);
|
|
4341
|
+
const decimalPart = value.substring(decimalIndex + 1);
|
|
4342
|
+
const integerString = isNaN(integerPart) ? '' : integerPart.toString();
|
|
4343
|
+
const decimal = typeof this.decimalMarker === 'string' ? this.decimalMarker : "." /* MaskExpression.DOT */;
|
|
4344
|
+
return integerString === "" /* MaskExpression.EMPTY_STRING */
|
|
4345
|
+
? "" /* MaskExpression.EMPTY_STRING */
|
|
4346
|
+
: `${emptyOrMinus}${integerString}${decimal}${decimalPart}`;
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
4349
|
+
_findFirstNonZeroAndDecimalIndex(inputString, decimalMarker) {
|
|
4350
|
+
let decimalMarkerIndex = null;
|
|
4351
|
+
let nonZeroIndex = null;
|
|
4352
|
+
for (let i = 0; i < inputString.length; i++) {
|
|
4353
|
+
const char = inputString[i];
|
|
4354
|
+
if (char === decimalMarker && decimalMarkerIndex === null) {
|
|
4355
|
+
decimalMarkerIndex = i;
|
|
4356
|
+
}
|
|
4357
|
+
if (char && char >= '1' && char <= '9' && nonZeroIndex === null) {
|
|
4358
|
+
nonZeroIndex = i;
|
|
4359
|
+
}
|
|
4360
|
+
if (decimalMarkerIndex !== null && nonZeroIndex !== null) {
|
|
4361
|
+
break;
|
|
4362
|
+
}
|
|
4363
|
+
}
|
|
4364
|
+
return {
|
|
4365
|
+
decimalMarkerIndex,
|
|
4366
|
+
nonZeroIndex,
|
|
4367
|
+
};
|
|
4368
|
+
}
|
|
4369
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgxMaskApplierService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4370
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgxMaskApplierService }); }
|
|
4371
|
+
}
|
|
4372
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgxMaskApplierService, decorators: [{
|
|
4373
|
+
type: Injectable
|
|
4374
|
+
}] });
|
|
4375
|
+
|
|
4376
|
+
class NgxMaskService extends NgxMaskApplierService {
|
|
4377
|
+
constructor() {
|
|
4378
|
+
super(...arguments);
|
|
4379
|
+
this.isNumberValue = false;
|
|
4380
|
+
this.maskIsShown = '';
|
|
4381
|
+
this.selStart = null;
|
|
4382
|
+
this.selEnd = null;
|
|
4383
|
+
this.maskChanged = false;
|
|
4384
|
+
this.maskExpressionArray = [];
|
|
4385
|
+
this.previousValue = '';
|
|
4386
|
+
this.currentValue = '';
|
|
4387
|
+
/**
|
|
4388
|
+
* Whether we are currently in writeValue function, in this case when applying the mask we don't want to trigger onChange function,
|
|
4389
|
+
* since writeValue should be a one way only process of writing the DOM value based on the Angular model value.
|
|
4390
|
+
*/
|
|
4391
|
+
this.writingValue = false;
|
|
4392
|
+
this._emitValue = false;
|
|
4393
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
4394
|
+
this.onChange = (_) => { };
|
|
4395
|
+
this._elementRef = inject(ElementRef, { optional: true });
|
|
4396
|
+
this.document = inject(DOCUMENT);
|
|
4397
|
+
this._config = inject(NGX_MASK_CONFIG);
|
|
4398
|
+
this._renderer = inject(Renderer2, { optional: true });
|
|
4399
|
+
}
|
|
4400
|
+
/**
|
|
4401
|
+
* Applies the mask to the input value.
|
|
4402
|
+
* @param inputValue The input value to be masked.
|
|
4403
|
+
* @param maskExpression The mask expression to apply.
|
|
4404
|
+
* @param position The position in the input value.
|
|
4405
|
+
* @param justPasted Whether the value was just pasted.
|
|
4406
|
+
* @param backspaced Whether the value was backspaced.
|
|
4407
|
+
* @param cb Callback function.
|
|
4408
|
+
* @returns The masked value.
|
|
4409
|
+
*/
|
|
4410
|
+
applyMask(inputValue, maskExpression, position = 0, justPasted = false, backspaced = false,
|
|
4411
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
4412
|
+
cb = () => { }) {
|
|
4413
|
+
// If no mask expression, return the input value or the actual value
|
|
4414
|
+
if (!maskExpression) {
|
|
4415
|
+
return inputValue !== this.actualValue ? this.actualValue : inputValue;
|
|
4416
|
+
}
|
|
4417
|
+
// Show mask in input if required
|
|
4418
|
+
this.maskIsShown = this.showMaskTyped
|
|
4419
|
+
? this.showMaskInInput()
|
|
4420
|
+
: "" /* MaskExpression.EMPTY_STRING */;
|
|
4421
|
+
// Handle specific mask expressions
|
|
4422
|
+
if (this.maskExpression === "IP" /* MaskExpression.IP */ && this.showMaskTyped) {
|
|
4423
|
+
this.maskIsShown = this.showMaskInInput(inputValue || "#" /* MaskExpression.HASH */);
|
|
4424
|
+
}
|
|
4425
|
+
if (this.maskExpression === "CPF_CNPJ" /* MaskExpression.CPF_CNPJ */ && this.showMaskTyped) {
|
|
4426
|
+
this.maskIsShown = this.showMaskInInput(inputValue || "#" /* MaskExpression.HASH */);
|
|
4427
|
+
}
|
|
4428
|
+
// Handle empty input value with mask typed
|
|
4429
|
+
if (!inputValue && this.showMaskTyped) {
|
|
4430
|
+
this.formControlResult(this.prefix);
|
|
4431
|
+
return `${this.prefix}${this.maskIsShown}${this.suffix}`;
|
|
4432
|
+
}
|
|
4433
|
+
const getSymbol = !!inputValue && typeof this.selStart === 'number'
|
|
4434
|
+
? (inputValue[this.selStart] ?? "" /* MaskExpression.EMPTY_STRING */)
|
|
4435
|
+
: "" /* MaskExpression.EMPTY_STRING */;
|
|
4436
|
+
let newInputValue = '';
|
|
4437
|
+
let newPosition = position;
|
|
4438
|
+
// Handle hidden input or input with asterisk symbol
|
|
4439
|
+
if ((this.hiddenInput ||
|
|
4440
|
+
(inputValue && inputValue.indexOf("*" /* MaskExpression.SYMBOL_STAR */) >= 0)) &&
|
|
4441
|
+
!this.writingValue) {
|
|
4442
|
+
let actualResult = inputValue && inputValue.length === 1
|
|
4443
|
+
? inputValue.split("" /* MaskExpression.EMPTY_STRING */)
|
|
4444
|
+
: this.actualValue.split("" /* MaskExpression.EMPTY_STRING */);
|
|
4445
|
+
// Handle backspace
|
|
4446
|
+
if (backspaced) {
|
|
4447
|
+
actualResult = actualResult
|
|
4448
|
+
.slice(0, position)
|
|
4449
|
+
.concat(actualResult.slice(position + 1));
|
|
4450
|
+
}
|
|
4451
|
+
// Remove mask if showMaskTyped is true
|
|
4452
|
+
if (this.showMaskTyped) {
|
|
4453
|
+
// eslint-disable-next-line no-param-reassign
|
|
4454
|
+
inputValue = this.removeMask(inputValue);
|
|
4455
|
+
actualResult = this.removeMask(actualResult.join('')).split("" /* MaskExpression.EMPTY_STRING */);
|
|
4456
|
+
}
|
|
4457
|
+
// Handle selection start and end
|
|
4458
|
+
if (typeof this.selStart === 'object' && typeof this.selEnd === 'object') {
|
|
4459
|
+
this.selStart = Number(this.selStart);
|
|
4460
|
+
this.selEnd = Number(this.selEnd);
|
|
4461
|
+
}
|
|
4462
|
+
else {
|
|
4463
|
+
if (inputValue !== "" /* MaskExpression.EMPTY_STRING */ && actualResult.length) {
|
|
4464
|
+
if (typeof this.selStart === 'number' && typeof this.selEnd === 'number') {
|
|
4465
|
+
if (inputValue.length > actualResult.length) {
|
|
4466
|
+
actualResult.splice(this.selStart, 0, getSymbol);
|
|
4467
|
+
}
|
|
4468
|
+
else if (inputValue.length < actualResult.length) {
|
|
4469
|
+
if (actualResult.length - inputValue.length === 1) {
|
|
4470
|
+
if (backspaced) {
|
|
4471
|
+
actualResult.splice(this.selStart - 1, 1);
|
|
4472
|
+
}
|
|
4473
|
+
else {
|
|
4474
|
+
actualResult.splice(inputValue.length - 1, 1);
|
|
4475
|
+
}
|
|
4476
|
+
}
|
|
4477
|
+
else {
|
|
4478
|
+
actualResult.splice(this.selStart, this.selEnd - this.selStart);
|
|
4479
|
+
}
|
|
4480
|
+
}
|
|
4481
|
+
}
|
|
4482
|
+
}
|
|
4483
|
+
else {
|
|
4484
|
+
actualResult = [];
|
|
4485
|
+
}
|
|
4486
|
+
}
|
|
4487
|
+
// Remove mask if showMaskTyped is true and hiddenInput is false
|
|
4488
|
+
if (this.showMaskTyped && !this.hiddenInput) {
|
|
4489
|
+
newInputValue = this.removeMask(inputValue);
|
|
4490
|
+
}
|
|
4491
|
+
// Handle actual value length
|
|
4492
|
+
if (this.actualValue.length) {
|
|
4493
|
+
if (actualResult.length < inputValue.length) {
|
|
4494
|
+
newInputValue = this.shiftTypedSymbols(actualResult.join("" /* MaskExpression.EMPTY_STRING */));
|
|
4495
|
+
}
|
|
4496
|
+
else if (actualResult.length === inputValue.length) {
|
|
4497
|
+
newInputValue = actualResult.join("" /* MaskExpression.EMPTY_STRING */);
|
|
4498
|
+
}
|
|
4499
|
+
else {
|
|
4500
|
+
newInputValue = inputValue;
|
|
4501
|
+
}
|
|
4502
|
+
}
|
|
4503
|
+
else {
|
|
4504
|
+
newInputValue = inputValue;
|
|
4505
|
+
}
|
|
4506
|
+
}
|
|
4507
|
+
// Handle just pasted input
|
|
4508
|
+
if (justPasted && (this.hiddenInput || !this.hiddenInput)) {
|
|
4509
|
+
newInputValue = inputValue;
|
|
4510
|
+
}
|
|
4511
|
+
// Handle backspace with special characters
|
|
4512
|
+
if (backspaced &&
|
|
4513
|
+
this.specialCharacters.indexOf(this.maskExpression[newPosition] ?? "" /* MaskExpression.EMPTY_STRING */) !== -1 &&
|
|
4514
|
+
this.showMaskTyped &&
|
|
4515
|
+
!this.prefix) {
|
|
4516
|
+
newInputValue = this.currentValue;
|
|
4517
|
+
}
|
|
4518
|
+
// Handle deleted special character
|
|
4519
|
+
if (this.deletedSpecialCharacter && newPosition) {
|
|
4520
|
+
if (this.specialCharacters.includes(this.actualValue.slice(newPosition, newPosition + 1))) {
|
|
4521
|
+
newPosition = newPosition + 1;
|
|
4522
|
+
}
|
|
4523
|
+
else if (maskExpression.slice(newPosition - 1, newPosition + 1) !== "M0" /* MaskExpression.MONTHS */) {
|
|
4524
|
+
newPosition = newPosition - 2;
|
|
4525
|
+
}
|
|
4526
|
+
this.deletedSpecialCharacter = false;
|
|
4527
|
+
}
|
|
4528
|
+
// Remove mask if showMaskTyped is true and placeHolderCharacter length is 1
|
|
4529
|
+
if (this.showMaskTyped &&
|
|
4530
|
+
this.placeHolderCharacter.length === 1 &&
|
|
4531
|
+
!this.leadZeroDateTime) {
|
|
4532
|
+
newInputValue = this.removeMask(newInputValue);
|
|
4533
|
+
}
|
|
4534
|
+
// Handle mask changed
|
|
4535
|
+
if (this.maskChanged) {
|
|
4536
|
+
newInputValue = inputValue;
|
|
4537
|
+
}
|
|
4538
|
+
else {
|
|
4539
|
+
newInputValue =
|
|
4540
|
+
Boolean(newInputValue) && newInputValue.length ? newInputValue : inputValue;
|
|
4541
|
+
}
|
|
4542
|
+
// Handle showMaskTyped and keepCharacterPositions
|
|
4543
|
+
if (this.showMaskTyped &&
|
|
4544
|
+
this.keepCharacterPositions &&
|
|
4545
|
+
this.actualValue &&
|
|
4546
|
+
!justPasted &&
|
|
4547
|
+
!this.writingValue) {
|
|
4548
|
+
const value = this.dropSpecialCharacters
|
|
4549
|
+
? this.removeMask(this.actualValue)
|
|
4550
|
+
: this.actualValue;
|
|
4551
|
+
this.formControlResult(value);
|
|
4552
|
+
return this.actualValue
|
|
4553
|
+
? this.actualValue
|
|
4554
|
+
: `${this.prefix}${this.maskIsShown}${this.suffix}`;
|
|
4555
|
+
}
|
|
4556
|
+
// Apply the mask using the parent class method
|
|
4557
|
+
const result = super.applyMask(newInputValue, maskExpression, newPosition, justPasted, backspaced, cb);
|
|
4558
|
+
this.actualValue = this.getActualValue(result);
|
|
4559
|
+
// handle some separator implications:
|
|
4560
|
+
// a.) adjust decimalMarker default (. -> ,) if thousandSeparator is a dot
|
|
4561
|
+
if (this.thousandSeparator === "." /* MaskExpression.DOT */ &&
|
|
4562
|
+
this.decimalMarker === "." /* MaskExpression.DOT */) {
|
|
4563
|
+
this.decimalMarker = "," /* MaskExpression.COMMA */;
|
|
4564
|
+
}
|
|
4565
|
+
// b) remove decimal marker from list of special characters to mask
|
|
4566
|
+
if (this.maskExpression.startsWith("separator" /* MaskExpression.SEPARATOR */) &&
|
|
4567
|
+
this.dropSpecialCharacters === true) {
|
|
4568
|
+
this.specialCharacters = this.specialCharacters.filter((item) => !this._compareOrIncludes(item, this.decimalMarker, this.thousandSeparator) //item !== this.decimalMarker, // !
|
|
4569
|
+
);
|
|
4570
|
+
}
|
|
4571
|
+
// Update previous and current values
|
|
4572
|
+
if (result || result === '') {
|
|
4573
|
+
this.previousValue = this.currentValue;
|
|
4574
|
+
this.currentValue = result;
|
|
4575
|
+
this._emitValue =
|
|
4576
|
+
this.previousValue !== this.currentValue ||
|
|
4577
|
+
(newInputValue !== this.currentValue && this.writingValue) ||
|
|
4578
|
+
(this.previousValue === this.currentValue && justPasted);
|
|
4579
|
+
}
|
|
4580
|
+
// Propagate the input value back to the Angular model
|
|
4581
|
+
// eslint-disable-next-line no-unused-expressions,@typescript-eslint/no-unused-expressions
|
|
4582
|
+
this._emitValue ? this.formControlResult(result) : '';
|
|
4583
|
+
// Handle hidden input and showMaskTyped
|
|
4584
|
+
if (!this.showMaskTyped || (this.showMaskTyped && this.hiddenInput)) {
|
|
4585
|
+
if (this.hiddenInput) {
|
|
4586
|
+
return `${this.hideInput(result, this.maskExpression)}${this.maskIsShown.slice(result.length)}`;
|
|
4587
|
+
}
|
|
4588
|
+
return result;
|
|
4589
|
+
}
|
|
4590
|
+
const resLen = result.length;
|
|
4591
|
+
const prefNmask = `${this.prefix}${this.maskIsShown}${this.suffix}`;
|
|
4592
|
+
// Handle specific mask expressions
|
|
4593
|
+
if (this.maskExpression.includes("H" /* MaskExpression.HOURS */)) {
|
|
4594
|
+
const countSkipedSymbol = this._numberSkipedSymbols(result);
|
|
4595
|
+
return `${result}${prefNmask.slice(resLen + countSkipedSymbol)}`;
|
|
4596
|
+
}
|
|
4597
|
+
else if (this.maskExpression === "IP" /* MaskExpression.IP */ ||
|
|
4598
|
+
this.maskExpression === "CPF_CNPJ" /* MaskExpression.CPF_CNPJ */) {
|
|
4599
|
+
return `${result}${prefNmask}`;
|
|
4600
|
+
}
|
|
4601
|
+
return `${result}${prefNmask.slice(resLen)}`;
|
|
4602
|
+
}
|
|
4603
|
+
// get the number of characters that were shifted
|
|
4604
|
+
_numberSkipedSymbols(value) {
|
|
4605
|
+
const regex = /(^|\D)(\d\D)/g;
|
|
4606
|
+
let match = regex.exec(value);
|
|
4607
|
+
let countSkipedSymbol = 0;
|
|
4608
|
+
while (match != null) {
|
|
4609
|
+
countSkipedSymbol += 1;
|
|
4610
|
+
match = regex.exec(value);
|
|
4611
|
+
}
|
|
4612
|
+
return countSkipedSymbol;
|
|
4613
|
+
}
|
|
4614
|
+
applyValueChanges(position, justPasted, backspaced,
|
|
4615
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
4616
|
+
cb = () => { }) {
|
|
4617
|
+
const formElement = this._elementRef?.nativeElement;
|
|
4618
|
+
if (!formElement) {
|
|
4619
|
+
return;
|
|
4620
|
+
}
|
|
4621
|
+
formElement.value = this.applyMask(formElement.value, this.maskExpression, position, justPasted, backspaced, cb);
|
|
4622
|
+
if (formElement === this._getActiveElement()) {
|
|
4623
|
+
return;
|
|
4624
|
+
}
|
|
4625
|
+
this.clearIfNotMatchFn();
|
|
4626
|
+
}
|
|
4627
|
+
hideInput(inputValue, maskExpression) {
|
|
4628
|
+
return inputValue
|
|
4629
|
+
.split("" /* MaskExpression.EMPTY_STRING */)
|
|
4630
|
+
.map((curr, index) => {
|
|
4631
|
+
if (this.patterns &&
|
|
4632
|
+
this.patterns[maskExpression[index] ?? "" /* MaskExpression.EMPTY_STRING */] &&
|
|
4633
|
+
this.patterns[maskExpression[index] ?? "" /* MaskExpression.EMPTY_STRING */]?.symbol) {
|
|
4634
|
+
return this.patterns[maskExpression[index] ?? "" /* MaskExpression.EMPTY_STRING */]
|
|
4635
|
+
?.symbol;
|
|
4636
|
+
}
|
|
4637
|
+
return curr;
|
|
4638
|
+
})
|
|
4639
|
+
.join("" /* MaskExpression.EMPTY_STRING */);
|
|
4640
|
+
}
|
|
4641
|
+
// this function is not necessary, it checks result against maskExpression
|
|
4642
|
+
getActualValue(res) {
|
|
4643
|
+
const compare = res
|
|
4644
|
+
.split("" /* MaskExpression.EMPTY_STRING */)
|
|
4645
|
+
.filter((symbol, i) => {
|
|
4646
|
+
const maskChar = this.maskExpression[i] ?? "" /* MaskExpression.EMPTY_STRING */;
|
|
4647
|
+
return (this._checkSymbolMask(symbol, maskChar) ||
|
|
4648
|
+
(this.specialCharacters.includes(maskChar) && symbol === maskChar));
|
|
4649
|
+
});
|
|
4650
|
+
if (compare.join("" /* MaskExpression.EMPTY_STRING */) === res) {
|
|
4651
|
+
return compare.join("" /* MaskExpression.EMPTY_STRING */);
|
|
4652
|
+
}
|
|
4653
|
+
return res;
|
|
4654
|
+
}
|
|
4655
|
+
shiftTypedSymbols(inputValue) {
|
|
4656
|
+
let symbolToReplace = '';
|
|
4657
|
+
const newInputValue = (inputValue &&
|
|
4658
|
+
inputValue
|
|
4659
|
+
.split("" /* MaskExpression.EMPTY_STRING */)
|
|
4660
|
+
.map((currSymbol, index) => {
|
|
4661
|
+
if (this.specialCharacters.includes(inputValue[index + 1] ?? "" /* MaskExpression.EMPTY_STRING */) &&
|
|
4662
|
+
inputValue[index + 1] !== this.maskExpression[index + 1]) {
|
|
4663
|
+
symbolToReplace = currSymbol;
|
|
4664
|
+
return inputValue[index + 1];
|
|
4665
|
+
}
|
|
4666
|
+
if (symbolToReplace.length) {
|
|
4667
|
+
const replaceSymbol = symbolToReplace;
|
|
4668
|
+
symbolToReplace = "" /* MaskExpression.EMPTY_STRING */;
|
|
4669
|
+
return replaceSymbol;
|
|
4670
|
+
}
|
|
4671
|
+
return currSymbol;
|
|
4672
|
+
})) ||
|
|
4673
|
+
[];
|
|
4674
|
+
return newInputValue.join("" /* MaskExpression.EMPTY_STRING */);
|
|
4675
|
+
}
|
|
4676
|
+
/**
|
|
4677
|
+
* Convert number value to string
|
|
4678
|
+
* 3.1415 -> '3.1415'
|
|
4679
|
+
* 1e-7 -> '0.0000001'
|
|
4680
|
+
*/
|
|
4681
|
+
numberToString(value) {
|
|
4682
|
+
if ((!value && value !== 0) ||
|
|
4683
|
+
(this.maskExpression.startsWith("separator" /* MaskExpression.SEPARATOR */) &&
|
|
4684
|
+
(this.leadZero || !this.dropSpecialCharacters)) ||
|
|
4685
|
+
(this.maskExpression.startsWith("separator" /* MaskExpression.SEPARATOR */) &&
|
|
4686
|
+
this.separatorLimit.length > 14 &&
|
|
4687
|
+
String(value).length > 14)) {
|
|
4688
|
+
return String(value);
|
|
4689
|
+
}
|
|
4690
|
+
return Number(value)
|
|
4691
|
+
.toLocaleString('fullwide', {
|
|
4692
|
+
useGrouping: false,
|
|
4693
|
+
maximumFractionDigits: 20,
|
|
4694
|
+
})
|
|
4695
|
+
.replace(`/${"-" /* MaskExpression.MINUS */}/`, "-" /* MaskExpression.MINUS */);
|
|
4696
|
+
}
|
|
4697
|
+
showMaskInInput(inputVal) {
|
|
4698
|
+
if (this.showMaskTyped && !!this.shownMaskExpression) {
|
|
4699
|
+
if (this.maskExpression.length !== this.shownMaskExpression.length) {
|
|
4700
|
+
throw new Error('Mask expression must match mask placeholder length');
|
|
4701
|
+
}
|
|
4702
|
+
else {
|
|
4703
|
+
return this.shownMaskExpression;
|
|
4704
|
+
}
|
|
4705
|
+
}
|
|
4706
|
+
else if (this.showMaskTyped) {
|
|
4707
|
+
if (inputVal) {
|
|
4708
|
+
if (this.maskExpression === "IP" /* MaskExpression.IP */) {
|
|
4709
|
+
return this._checkForIp(inputVal);
|
|
4710
|
+
}
|
|
4711
|
+
if (this.maskExpression === "CPF_CNPJ" /* MaskExpression.CPF_CNPJ */) {
|
|
4712
|
+
return this._checkForCpfCnpj(inputVal);
|
|
4713
|
+
}
|
|
4714
|
+
}
|
|
4715
|
+
if (this.placeHolderCharacter.length === this.maskExpression.length) {
|
|
4716
|
+
return this.placeHolderCharacter;
|
|
4717
|
+
}
|
|
4718
|
+
return this.maskExpression.replace(/\w/g, this.placeHolderCharacter);
|
|
4719
|
+
}
|
|
4720
|
+
return '';
|
|
4721
|
+
}
|
|
4722
|
+
clearIfNotMatchFn() {
|
|
4723
|
+
const formElement = this._elementRef?.nativeElement;
|
|
4724
|
+
if (!formElement) {
|
|
4725
|
+
return;
|
|
4726
|
+
}
|
|
4727
|
+
if (this.clearIfNotMatch &&
|
|
4728
|
+
this.prefix.length + this.maskExpression.length + this.suffix.length !==
|
|
4729
|
+
formElement.value.replace(this.placeHolderCharacter, "" /* MaskExpression.EMPTY_STRING */)
|
|
4730
|
+
.length) {
|
|
4731
|
+
this.formElementProperty = ['value', "" /* MaskExpression.EMPTY_STRING */];
|
|
4732
|
+
this.applyMask('', this.maskExpression);
|
|
4733
|
+
}
|
|
4734
|
+
}
|
|
4735
|
+
set formElementProperty([name, value]) {
|
|
4736
|
+
if (!this._renderer || !this._elementRef) {
|
|
4737
|
+
return;
|
|
4738
|
+
}
|
|
4739
|
+
//[TODO]: andriikamaldinov1 find better solution
|
|
4740
|
+
Promise.resolve().then(() => this._renderer?.setProperty(this._elementRef?.nativeElement, name, value));
|
|
4741
|
+
}
|
|
4742
|
+
checkDropSpecialCharAmount(mask) {
|
|
4743
|
+
const chars = mask
|
|
4744
|
+
.split("" /* MaskExpression.EMPTY_STRING */)
|
|
4745
|
+
.filter((item) => this._findDropSpecialChar(item));
|
|
4746
|
+
return chars.length;
|
|
4747
|
+
}
|
|
4748
|
+
removeMask(inputValue) {
|
|
4749
|
+
return this._removeMask(this._removeSuffix(this._removePrefix(inputValue)), this.specialCharacters.concat('_').concat(this.placeHolderCharacter));
|
|
4750
|
+
}
|
|
4751
|
+
_checkForIp(inputVal) {
|
|
4752
|
+
if (inputVal === "#" /* MaskExpression.HASH */) {
|
|
4753
|
+
return `${this.placeHolderCharacter}.${this.placeHolderCharacter}.${this.placeHolderCharacter}.${this.placeHolderCharacter}`;
|
|
4754
|
+
}
|
|
4755
|
+
const arr = [];
|
|
4756
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
4757
|
+
for (let i = 0; i < inputVal.length; i++) {
|
|
4758
|
+
const value = inputVal[i] ?? "" /* MaskExpression.EMPTY_STRING */;
|
|
4759
|
+
if (!value) {
|
|
4760
|
+
continue;
|
|
4761
|
+
}
|
|
4762
|
+
if (value.match('\\d')) {
|
|
4763
|
+
arr.push(value);
|
|
4764
|
+
}
|
|
4765
|
+
}
|
|
4766
|
+
if (arr.length <= 3) {
|
|
4767
|
+
return `${this.placeHolderCharacter}.${this.placeHolderCharacter}.${this.placeHolderCharacter}`;
|
|
4768
|
+
}
|
|
4769
|
+
if (arr.length > 3 && arr.length <= 6) {
|
|
4770
|
+
return `${this.placeHolderCharacter}.${this.placeHolderCharacter}`;
|
|
4771
|
+
}
|
|
4772
|
+
if (arr.length > 6 && arr.length <= 9) {
|
|
4773
|
+
return this.placeHolderCharacter;
|
|
4774
|
+
}
|
|
4775
|
+
if (arr.length > 9 && arr.length <= 12) {
|
|
4776
|
+
return '';
|
|
4777
|
+
}
|
|
4778
|
+
return '';
|
|
4779
|
+
}
|
|
4780
|
+
_checkForCpfCnpj(inputVal) {
|
|
4781
|
+
const cpf = `${this.placeHolderCharacter}${this.placeHolderCharacter}${this.placeHolderCharacter}` +
|
|
4782
|
+
`.${this.placeHolderCharacter}${this.placeHolderCharacter}${this.placeHolderCharacter}` +
|
|
4783
|
+
`.${this.placeHolderCharacter}${this.placeHolderCharacter}${this.placeHolderCharacter}` +
|
|
4784
|
+
`-${this.placeHolderCharacter}${this.placeHolderCharacter}`;
|
|
4785
|
+
const cnpj = `${this.placeHolderCharacter}${this.placeHolderCharacter}` +
|
|
4786
|
+
`.${this.placeHolderCharacter}${this.placeHolderCharacter}${this.placeHolderCharacter}` +
|
|
4787
|
+
`.${this.placeHolderCharacter}${this.placeHolderCharacter}${this.placeHolderCharacter}` +
|
|
4788
|
+
`/${this.placeHolderCharacter}${this.placeHolderCharacter}${this.placeHolderCharacter}${this.placeHolderCharacter}` +
|
|
4789
|
+
`-${this.placeHolderCharacter}${this.placeHolderCharacter}`;
|
|
4790
|
+
if (inputVal === "#" /* MaskExpression.HASH */) {
|
|
4791
|
+
return cpf;
|
|
4792
|
+
}
|
|
4793
|
+
const arr = [];
|
|
4794
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
4795
|
+
for (let i = 0; i < inputVal.length; i++) {
|
|
4796
|
+
const value = inputVal[i] ?? "" /* MaskExpression.EMPTY_STRING */;
|
|
4797
|
+
if (!value) {
|
|
4798
|
+
continue;
|
|
4799
|
+
}
|
|
4800
|
+
if (value.match('\\d')) {
|
|
4801
|
+
arr.push(value);
|
|
4802
|
+
}
|
|
4803
|
+
}
|
|
4804
|
+
if (arr.length <= 3) {
|
|
4805
|
+
return cpf.slice(arr.length, cpf.length);
|
|
4806
|
+
}
|
|
4807
|
+
if (arr.length > 3 && arr.length <= 6) {
|
|
4808
|
+
return cpf.slice(arr.length + 1, cpf.length);
|
|
4809
|
+
}
|
|
4810
|
+
if (arr.length > 6 && arr.length <= 9) {
|
|
4811
|
+
return cpf.slice(arr.length + 2, cpf.length);
|
|
4812
|
+
}
|
|
4813
|
+
if (arr.length > 9 && arr.length < 11) {
|
|
4814
|
+
return cpf.slice(arr.length + 3, cpf.length);
|
|
4815
|
+
}
|
|
4816
|
+
if (arr.length === 11) {
|
|
4817
|
+
return '';
|
|
4818
|
+
}
|
|
4819
|
+
if (arr.length === 12) {
|
|
4820
|
+
if (inputVal.length === 17) {
|
|
4821
|
+
return cnpj.slice(16, cnpj.length);
|
|
4822
|
+
}
|
|
4823
|
+
return cnpj.slice(15, cnpj.length);
|
|
4824
|
+
}
|
|
4825
|
+
if (arr.length > 12 && arr.length <= 14) {
|
|
4826
|
+
return cnpj.slice(arr.length + 4, cnpj.length);
|
|
4827
|
+
}
|
|
4828
|
+
return '';
|
|
4829
|
+
}
|
|
4830
|
+
/**
|
|
4831
|
+
* Recursively determine the current active element by navigating the Shadow DOM until the Active Element is found.
|
|
4832
|
+
*/
|
|
4833
|
+
_getActiveElement(document = this.document) {
|
|
4834
|
+
const shadowRootEl = document?.activeElement?.shadowRoot;
|
|
4835
|
+
if (!shadowRootEl?.activeElement) {
|
|
4836
|
+
return document.activeElement;
|
|
4837
|
+
}
|
|
4838
|
+
else {
|
|
4839
|
+
return this._getActiveElement(shadowRootEl);
|
|
4840
|
+
}
|
|
4841
|
+
}
|
|
4842
|
+
/**
|
|
4843
|
+
* Propogates the input value back to the Angular model by triggering the onChange function. It won't do this if writingValue
|
|
4844
|
+
* is true. If that is true it means we are currently in the writeValue function, which is supposed to only update the actual
|
|
4845
|
+
* DOM element based on the Angular model value. It should be a one way process, i.e. writeValue should not be modifying the Angular
|
|
4846
|
+
* model value too. Therefore, we don't trigger onChange in this scenario.
|
|
4847
|
+
* @param inputValue the current form input value
|
|
4848
|
+
*/
|
|
4849
|
+
formControlResult(inputValue) {
|
|
4850
|
+
const outputTransformFn = this.outputTransformFn
|
|
4851
|
+
? this.outputTransformFn
|
|
4852
|
+
: (v) => v;
|
|
4853
|
+
this.writingValue = false;
|
|
4854
|
+
this.maskChanged = false;
|
|
4855
|
+
if (Array.isArray(this.dropSpecialCharacters)) {
|
|
4856
|
+
this.onChange(outputTransformFn(this._toNumber(this._checkSymbols(this._removeMask(this._removeSuffix(this._removePrefix(inputValue)), this.dropSpecialCharacters)))));
|
|
4857
|
+
}
|
|
4858
|
+
else if (this.dropSpecialCharacters ||
|
|
4859
|
+
(!this.dropSpecialCharacters && this.prefix === inputValue)) {
|
|
4860
|
+
this.onChange(outputTransformFn(this._toNumber(this._checkSymbols(this._removeSuffix(this._removePrefix(inputValue))))));
|
|
4861
|
+
}
|
|
4862
|
+
else {
|
|
4863
|
+
this.onChange(outputTransformFn(this._toNumber(inputValue)));
|
|
4864
|
+
}
|
|
4865
|
+
}
|
|
4866
|
+
_toNumber(value) {
|
|
4867
|
+
if (!this.isNumberValue || value === "" /* MaskExpression.EMPTY_STRING */) {
|
|
4868
|
+
return value;
|
|
4869
|
+
}
|
|
4870
|
+
if (this.maskExpression.startsWith("separator" /* MaskExpression.SEPARATOR */) &&
|
|
4871
|
+
(this.leadZero || !this.dropSpecialCharacters)) {
|
|
4872
|
+
return value;
|
|
4873
|
+
}
|
|
4874
|
+
if (String(value).length > 14 && this.maskExpression.startsWith("separator" /* MaskExpression.SEPARATOR */)) {
|
|
4875
|
+
return String(value);
|
|
4876
|
+
}
|
|
4877
|
+
const num = Number(value);
|
|
4878
|
+
if (this.maskExpression.startsWith("separator" /* MaskExpression.SEPARATOR */) && Number.isNaN(num)) {
|
|
4879
|
+
const val = String(value).replace(',', '.');
|
|
4880
|
+
return Number(val);
|
|
4881
|
+
}
|
|
4882
|
+
return Number.isNaN(num) ? value : num;
|
|
4883
|
+
}
|
|
4884
|
+
_removeMask(value, specialCharactersForRemove) {
|
|
4885
|
+
if (this.maskExpression.startsWith("percent" /* MaskExpression.PERCENT */) &&
|
|
4886
|
+
value.includes("." /* MaskExpression.DOT */)) {
|
|
4887
|
+
return value;
|
|
4888
|
+
}
|
|
4889
|
+
return value
|
|
4890
|
+
? value.replace(this._regExpForRemove(specialCharactersForRemove), "" /* MaskExpression.EMPTY_STRING */)
|
|
4891
|
+
: value;
|
|
4892
|
+
}
|
|
4893
|
+
_removePrefix(value) {
|
|
4894
|
+
if (!this.prefix) {
|
|
4895
|
+
return value;
|
|
4896
|
+
}
|
|
4897
|
+
return value ? value.replace(this.prefix, "" /* MaskExpression.EMPTY_STRING */) : value;
|
|
4898
|
+
}
|
|
4899
|
+
_removeSuffix(value) {
|
|
4900
|
+
if (!this.suffix) {
|
|
4901
|
+
return value;
|
|
4902
|
+
}
|
|
4903
|
+
return value ? value.replace(this.suffix, "" /* MaskExpression.EMPTY_STRING */) : value;
|
|
4904
|
+
}
|
|
4905
|
+
_retrieveSeparatorValue(result) {
|
|
4906
|
+
let specialCharacters = Array.isArray(this.dropSpecialCharacters)
|
|
4907
|
+
? this.specialCharacters.filter((v) => {
|
|
4908
|
+
return this.dropSpecialCharacters.includes(v);
|
|
4909
|
+
})
|
|
4910
|
+
: this.specialCharacters;
|
|
4911
|
+
if (!this.deletedSpecialCharacter &&
|
|
4912
|
+
this._checkPatternForSpace() &&
|
|
4913
|
+
result.includes(" " /* MaskExpression.WHITE_SPACE */) &&
|
|
4914
|
+
this.maskExpression.includes("*" /* MaskExpression.SYMBOL_STAR */)) {
|
|
4915
|
+
specialCharacters = specialCharacters.filter((char) => char !== " " /* MaskExpression.WHITE_SPACE */);
|
|
4916
|
+
}
|
|
4917
|
+
return this._removeMask(result, specialCharacters);
|
|
4918
|
+
}
|
|
4919
|
+
_regExpForRemove(specialCharactersForRemove) {
|
|
4920
|
+
return new RegExp(specialCharactersForRemove.map((item) => `\\${item}`).join('|'), 'gi');
|
|
4921
|
+
}
|
|
4922
|
+
_replaceDecimalMarkerToDot(value) {
|
|
4923
|
+
const markers = Array.isArray(this.decimalMarker)
|
|
4924
|
+
? this.decimalMarker
|
|
4925
|
+
: [this.decimalMarker];
|
|
4926
|
+
return value.replace(this._regExpForRemove(markers), "." /* MaskExpression.DOT */);
|
|
4927
|
+
}
|
|
4928
|
+
_checkSymbols(result) {
|
|
4929
|
+
let processedResult = result;
|
|
4930
|
+
if (processedResult === "" /* MaskExpression.EMPTY_STRING */) {
|
|
4931
|
+
return processedResult;
|
|
4932
|
+
}
|
|
4933
|
+
if (this.maskExpression.startsWith("percent" /* MaskExpression.PERCENT */) &&
|
|
4934
|
+
this.decimalMarker === "," /* MaskExpression.COMMA */) {
|
|
4935
|
+
processedResult = processedResult.replace("," /* MaskExpression.COMMA */, "." /* MaskExpression.DOT */);
|
|
4936
|
+
}
|
|
4937
|
+
const separatorPrecision = this._retrieveSeparatorPrecision(this.maskExpression);
|
|
4938
|
+
const separatorValue = this.specialCharacters.length === 0
|
|
4939
|
+
? this._retrieveSeparatorValue(processedResult)
|
|
4940
|
+
: this._replaceDecimalMarkerToDot(this._retrieveSeparatorValue(processedResult));
|
|
4941
|
+
if (!this.isNumberValue) {
|
|
4942
|
+
return separatorValue;
|
|
4943
|
+
}
|
|
4944
|
+
if (separatorPrecision) {
|
|
4945
|
+
if (processedResult === this.decimalMarker) {
|
|
4946
|
+
return null;
|
|
4947
|
+
}
|
|
4948
|
+
if (separatorValue.length > 14) {
|
|
4949
|
+
return String(separatorValue);
|
|
4950
|
+
}
|
|
4951
|
+
return this._checkPrecision(this.maskExpression, separatorValue);
|
|
4952
|
+
}
|
|
4953
|
+
else {
|
|
4954
|
+
return separatorValue;
|
|
4955
|
+
}
|
|
4956
|
+
}
|
|
4957
|
+
_checkPatternForSpace() {
|
|
4958
|
+
for (const key in this.patterns) {
|
|
4959
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
4960
|
+
if (this.patterns[key] && this.patterns[key]?.hasOwnProperty('pattern')) {
|
|
4961
|
+
const patternString = this.patterns[key]?.pattern.toString();
|
|
4962
|
+
const pattern = this.patterns[key]?.pattern;
|
|
4963
|
+
if (patternString?.includes(" " /* MaskExpression.WHITE_SPACE */) &&
|
|
4964
|
+
pattern?.test(this.maskExpression)) {
|
|
4965
|
+
return true;
|
|
4966
|
+
}
|
|
4967
|
+
}
|
|
4968
|
+
}
|
|
4969
|
+
return false;
|
|
4970
|
+
}
|
|
4971
|
+
// TODO should think about helpers or separting decimal precision to own property
|
|
4972
|
+
_retrieveSeparatorPrecision(maskExpretion) {
|
|
4973
|
+
const matcher = maskExpretion.match(new RegExp(`^separator\\.([^d]*)`));
|
|
4974
|
+
return matcher ? Number(matcher[1]) : null;
|
|
4975
|
+
}
|
|
4976
|
+
_checkPrecision(separatorExpression, separatorValue) {
|
|
4977
|
+
const separatorPrecision = this.getPrecision(separatorExpression);
|
|
4978
|
+
let value = separatorValue;
|
|
4979
|
+
if (separatorExpression.indexOf('2') > 0 ||
|
|
4980
|
+
(this.leadZero && Number(separatorPrecision) > 0)) {
|
|
4981
|
+
if (this.decimalMarker === "," /* MaskExpression.COMMA */ && this.leadZero) {
|
|
4982
|
+
value = value.replace(',', '.');
|
|
4983
|
+
}
|
|
4984
|
+
return this.leadZero
|
|
4985
|
+
? Number(value).toFixed(Number(separatorPrecision))
|
|
4986
|
+
: Number(value).toFixed(2);
|
|
4987
|
+
}
|
|
4988
|
+
return this.numberToString(value);
|
|
4989
|
+
}
|
|
4990
|
+
_repeatPatternSymbols(maskExp) {
|
|
4991
|
+
return ((maskExp.match(/{[0-9]+}/) &&
|
|
4992
|
+
maskExp
|
|
4993
|
+
.split("" /* MaskExpression.EMPTY_STRING */)
|
|
4994
|
+
.reduce((accum, currVal, index) => {
|
|
4995
|
+
this._start =
|
|
4996
|
+
currVal === "{" /* MaskExpression.CURLY_BRACKETS_LEFT */ ? index : this._start;
|
|
4997
|
+
if (currVal !== "}" /* MaskExpression.CURLY_BRACKETS_RIGHT */) {
|
|
4998
|
+
return this._findSpecialChar(currVal) ? accum + currVal : accum;
|
|
4999
|
+
}
|
|
5000
|
+
this._end = index;
|
|
5001
|
+
const repeatNumber = Number(maskExp.slice(this._start + 1, this._end));
|
|
5002
|
+
const replaceWith = new Array(repeatNumber + 1).join(maskExp[this._start - 1]);
|
|
5003
|
+
if (maskExp.slice(0, this._start).length > 1 &&
|
|
5004
|
+
maskExp.includes("S" /* MaskExpression.LETTER_S */)) {
|
|
5005
|
+
const symbols = maskExp.slice(0, this._start - 1);
|
|
5006
|
+
return symbols.includes("{" /* MaskExpression.CURLY_BRACKETS_LEFT */)
|
|
5007
|
+
? accum + replaceWith
|
|
5008
|
+
: symbols + accum + replaceWith;
|
|
5009
|
+
}
|
|
5010
|
+
else {
|
|
5011
|
+
return accum + replaceWith;
|
|
5012
|
+
}
|
|
5013
|
+
}, '')) ||
|
|
5014
|
+
maskExp);
|
|
5015
|
+
}
|
|
5016
|
+
currentLocaleDecimalMarker() {
|
|
5017
|
+
return (1.1).toLocaleString().substring(1, 2);
|
|
5018
|
+
}
|
|
5019
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgxMaskService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
5020
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgxMaskService }); }
|
|
5021
|
+
}
|
|
5022
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgxMaskService, decorators: [{
|
|
5023
|
+
type: Injectable
|
|
5024
|
+
}] });
|
|
5025
|
+
|
|
5026
|
+
class NgxMaskDirective {
|
|
5027
|
+
constructor() {
|
|
5028
|
+
this.mask = input('');
|
|
5029
|
+
this.specialCharacters = input([]);
|
|
5030
|
+
this.patterns = input({});
|
|
5031
|
+
this.prefix = input('');
|
|
5032
|
+
this.suffix = input('');
|
|
5033
|
+
this.thousandSeparator = input(' ');
|
|
5034
|
+
this.decimalMarker = input('.');
|
|
5035
|
+
this.dropSpecialCharacters = input(null);
|
|
5036
|
+
this.hiddenInput = input(null);
|
|
5037
|
+
this.showMaskTyped = input(null);
|
|
5038
|
+
this.placeHolderCharacter = input(null);
|
|
5039
|
+
this.shownMaskExpression = input(null);
|
|
5040
|
+
this.clearIfNotMatch = input(null);
|
|
5041
|
+
this.validation = input(null);
|
|
5042
|
+
this.separatorLimit = input('');
|
|
5043
|
+
this.allowNegativeNumbers = input(null);
|
|
5044
|
+
this.leadZeroDateTime = input(null);
|
|
5045
|
+
this.leadZero = input(null);
|
|
5046
|
+
this.triggerOnMaskChange = input(null);
|
|
5047
|
+
this.apm = input(null);
|
|
5048
|
+
this.inputTransformFn = input(null);
|
|
5049
|
+
this.outputTransformFn = input(null);
|
|
5050
|
+
this.keepCharacterPositions = input(null);
|
|
5051
|
+
this.instantPrefix = input(null);
|
|
5052
|
+
this.maskFilled = output();
|
|
5053
|
+
this._maskValue = signal('');
|
|
5054
|
+
this._inputValue = signal('');
|
|
5055
|
+
this._position = signal(null);
|
|
5056
|
+
this._code = signal('');
|
|
5057
|
+
this._maskExpressionArray = signal([]);
|
|
5058
|
+
this._justPasted = signal(false);
|
|
5059
|
+
this._isFocused = signal(false);
|
|
5060
|
+
/**For IME composition event */
|
|
5061
|
+
this._isComposing = signal(false);
|
|
5062
|
+
this._maskService = inject(NgxMaskService, { self: true });
|
|
5063
|
+
this.document = inject(DOCUMENT);
|
|
5064
|
+
this._config = inject(NGX_MASK_CONFIG);
|
|
5065
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
5066
|
+
this.onChange = (_) => { };
|
|
5067
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
5068
|
+
this.onTouch = () => { };
|
|
5069
|
+
}
|
|
5070
|
+
ngOnChanges(changes) {
|
|
5071
|
+
const { mask, specialCharacters, patterns, prefix, suffix, thousandSeparator, decimalMarker, dropSpecialCharacters, hiddenInput, showMaskTyped, placeHolderCharacter, shownMaskExpression, clearIfNotMatch, validation, separatorLimit, allowNegativeNumbers, leadZeroDateTime, leadZero, triggerOnMaskChange, apm, inputTransformFn, outputTransformFn, keepCharacterPositions, instantPrefix, } = changes;
|
|
5072
|
+
if (mask) {
|
|
5073
|
+
if (mask.currentValue !== mask.previousValue && !mask.firstChange) {
|
|
5074
|
+
this._maskService.maskChanged = true;
|
|
5075
|
+
}
|
|
5076
|
+
if (mask.currentValue && mask.currentValue.split("||" /* MaskExpression.OR */).length > 1) {
|
|
5077
|
+
this._maskExpressionArray.set(mask.currentValue.split("||" /* MaskExpression.OR */).sort((a, b) => {
|
|
5078
|
+
return a.length - b.length;
|
|
5079
|
+
}));
|
|
5080
|
+
this._setMask();
|
|
5081
|
+
}
|
|
5082
|
+
else {
|
|
5083
|
+
this._maskExpressionArray.set([]);
|
|
5084
|
+
this._maskValue.set(mask.currentValue || "" /* MaskExpression.EMPTY_STRING */);
|
|
5085
|
+
this._maskService.maskExpression = this._maskValue();
|
|
5086
|
+
}
|
|
5087
|
+
}
|
|
5088
|
+
if (specialCharacters) {
|
|
5089
|
+
if (!specialCharacters.currentValue || !Array.isArray(specialCharacters.currentValue)) {
|
|
5090
|
+
return;
|
|
5091
|
+
}
|
|
5092
|
+
else {
|
|
5093
|
+
this._maskService.specialCharacters = specialCharacters.currentValue || [];
|
|
5094
|
+
}
|
|
5095
|
+
}
|
|
5096
|
+
if (allowNegativeNumbers) {
|
|
5097
|
+
this._maskService.allowNegativeNumbers = allowNegativeNumbers.currentValue;
|
|
5098
|
+
if (this._maskService.allowNegativeNumbers) {
|
|
5099
|
+
this._maskService.specialCharacters = this._maskService.specialCharacters.filter((c) => c !== "-" /* MaskExpression.MINUS */);
|
|
5100
|
+
}
|
|
5101
|
+
}
|
|
5102
|
+
// Only overwrite the mask available patterns if a pattern has actually been passed in
|
|
5103
|
+
if (patterns && patterns.currentValue) {
|
|
5104
|
+
this._maskService.patterns = patterns.currentValue;
|
|
5105
|
+
}
|
|
5106
|
+
if (apm && apm.currentValue) {
|
|
5107
|
+
this._maskService.apm = apm.currentValue;
|
|
5108
|
+
}
|
|
5109
|
+
if (instantPrefix) {
|
|
5110
|
+
this._maskService.instantPrefix = instantPrefix.currentValue;
|
|
5111
|
+
}
|
|
5112
|
+
if (prefix) {
|
|
5113
|
+
this._maskService.prefix = prefix.currentValue;
|
|
5114
|
+
}
|
|
5115
|
+
if (suffix) {
|
|
5116
|
+
this._maskService.suffix = suffix.currentValue;
|
|
5117
|
+
}
|
|
5118
|
+
if (thousandSeparator) {
|
|
5119
|
+
this._maskService.thousandSeparator = thousandSeparator.currentValue;
|
|
5120
|
+
if (thousandSeparator.previousValue && thousandSeparator.currentValue) {
|
|
5121
|
+
const previousDecimalMarker = this._maskService.decimalMarker;
|
|
5122
|
+
if (thousandSeparator.currentValue === this._maskService.decimalMarker) {
|
|
5123
|
+
this._maskService.decimalMarker =
|
|
5124
|
+
thousandSeparator.currentValue === "," /* MaskExpression.COMMA */
|
|
5125
|
+
? "." /* MaskExpression.DOT */
|
|
5126
|
+
: "," /* MaskExpression.COMMA */;
|
|
5127
|
+
}
|
|
5128
|
+
if (this._maskService.dropSpecialCharacters === true) {
|
|
5129
|
+
this._maskService.specialCharacters = this._config.specialCharacters;
|
|
5130
|
+
}
|
|
5131
|
+
if (typeof previousDecimalMarker === 'string' &&
|
|
5132
|
+
typeof this._maskService.decimalMarker === 'string') {
|
|
5133
|
+
this._inputValue.set(this._inputValue()
|
|
5134
|
+
.split(thousandSeparator.previousValue)
|
|
5135
|
+
.join('')
|
|
5136
|
+
.replace(previousDecimalMarker, this._maskService.decimalMarker));
|
|
5137
|
+
this._maskService.actualValue = this._inputValue();
|
|
5138
|
+
}
|
|
5139
|
+
this._maskService.writingValue = true;
|
|
5140
|
+
}
|
|
5141
|
+
}
|
|
5142
|
+
if (decimalMarker) {
|
|
5143
|
+
this._maskService.decimalMarker = decimalMarker.currentValue;
|
|
5144
|
+
}
|
|
5145
|
+
if (dropSpecialCharacters) {
|
|
5146
|
+
this._maskService.dropSpecialCharacters = dropSpecialCharacters.currentValue;
|
|
5147
|
+
}
|
|
5148
|
+
if (hiddenInput) {
|
|
5149
|
+
this._maskService.hiddenInput = hiddenInput.currentValue;
|
|
5150
|
+
if (hiddenInput.previousValue === true && hiddenInput.currentValue === false) {
|
|
5151
|
+
this._inputValue.set(this._maskService.actualValue);
|
|
5152
|
+
}
|
|
5153
|
+
}
|
|
5154
|
+
if (showMaskTyped) {
|
|
5155
|
+
this._maskService.showMaskTyped = showMaskTyped.currentValue;
|
|
5156
|
+
if (showMaskTyped.previousValue === false &&
|
|
5157
|
+
showMaskTyped.currentValue === true &&
|
|
5158
|
+
this._isFocused()) {
|
|
5159
|
+
requestAnimationFrame(() => {
|
|
5160
|
+
this._maskService._elementRef?.nativeElement.click();
|
|
5161
|
+
});
|
|
5162
|
+
}
|
|
5163
|
+
}
|
|
5164
|
+
if (placeHolderCharacter) {
|
|
5165
|
+
this._maskService.placeHolderCharacter = placeHolderCharacter.currentValue;
|
|
5166
|
+
}
|
|
5167
|
+
if (shownMaskExpression) {
|
|
5168
|
+
this._maskService.shownMaskExpression = shownMaskExpression.currentValue;
|
|
5169
|
+
}
|
|
5170
|
+
if (clearIfNotMatch) {
|
|
5171
|
+
this._maskService.clearIfNotMatch = clearIfNotMatch.currentValue;
|
|
5172
|
+
}
|
|
5173
|
+
if (validation) {
|
|
5174
|
+
this._maskService.validation = validation.currentValue;
|
|
5175
|
+
}
|
|
5176
|
+
if (separatorLimit) {
|
|
5177
|
+
this._maskService.separatorLimit = separatorLimit.currentValue;
|
|
5178
|
+
}
|
|
5179
|
+
if (leadZeroDateTime) {
|
|
5180
|
+
this._maskService.leadZeroDateTime = leadZeroDateTime.currentValue;
|
|
5181
|
+
}
|
|
5182
|
+
if (leadZero) {
|
|
5183
|
+
this._maskService.leadZero = leadZero.currentValue;
|
|
5184
|
+
}
|
|
5185
|
+
if (triggerOnMaskChange) {
|
|
5186
|
+
this._maskService.triggerOnMaskChange = triggerOnMaskChange.currentValue;
|
|
5187
|
+
}
|
|
5188
|
+
if (inputTransformFn) {
|
|
5189
|
+
this._maskService.inputTransformFn = inputTransformFn.currentValue;
|
|
5190
|
+
}
|
|
5191
|
+
if (outputTransformFn) {
|
|
5192
|
+
this._maskService.outputTransformFn = outputTransformFn.currentValue;
|
|
5193
|
+
}
|
|
5194
|
+
if (keepCharacterPositions) {
|
|
5195
|
+
this._maskService.keepCharacterPositions = keepCharacterPositions.currentValue;
|
|
5196
|
+
}
|
|
5197
|
+
this._applyMask();
|
|
5198
|
+
}
|
|
5199
|
+
validate({ value }) {
|
|
5200
|
+
const processedValue = typeof value === 'number' ? String(value) : value;
|
|
5201
|
+
const maskValue = this._maskValue();
|
|
5202
|
+
if (!this._maskService.validation || !maskValue) {
|
|
5203
|
+
return null;
|
|
5204
|
+
}
|
|
5205
|
+
if (this._maskService.ipError) {
|
|
5206
|
+
return this._createValidationError(processedValue);
|
|
5207
|
+
}
|
|
5208
|
+
if (this._maskService.cpfCnpjError) {
|
|
5209
|
+
return this._createValidationError(processedValue);
|
|
5210
|
+
}
|
|
5211
|
+
if (maskValue.startsWith("separator" /* MaskExpression.SEPARATOR */)) {
|
|
5212
|
+
return null;
|
|
5213
|
+
}
|
|
5214
|
+
if (withoutValidation.includes(maskValue)) {
|
|
5215
|
+
return null;
|
|
5216
|
+
}
|
|
5217
|
+
if (this._maskService.clearIfNotMatch) {
|
|
5218
|
+
return null;
|
|
5219
|
+
}
|
|
5220
|
+
if (timeMasks.includes(maskValue)) {
|
|
5221
|
+
return this._validateTime(processedValue);
|
|
5222
|
+
}
|
|
5223
|
+
if (maskValue === "A*@A*.A*" /* MaskExpression.EMAIL_MASK */) {
|
|
5224
|
+
const emailPattern = /^[^@]+@[^@]+\.[^@]+$/;
|
|
5225
|
+
if (!emailPattern.test(processedValue) && processedValue) {
|
|
5226
|
+
return this._createValidationError(processedValue);
|
|
5227
|
+
}
|
|
5228
|
+
else {
|
|
5229
|
+
return null;
|
|
5230
|
+
}
|
|
5231
|
+
}
|
|
5232
|
+
if (processedValue && processedValue.length >= 1) {
|
|
5233
|
+
let counterOfOpt = 0;
|
|
5234
|
+
if (maskValue.includes("{" /* MaskExpression.CURLY_BRACKETS_LEFT */) &&
|
|
5235
|
+
maskValue.includes("}" /* MaskExpression.CURLY_BRACKETS_RIGHT */)) {
|
|
5236
|
+
const lengthInsideCurlyBrackets = maskValue.slice(maskValue.indexOf("{" /* MaskExpression.CURLY_BRACKETS_LEFT */) + 1, maskValue.indexOf("}" /* MaskExpression.CURLY_BRACKETS_RIGHT */));
|
|
5237
|
+
return lengthInsideCurlyBrackets === String(processedValue.length)
|
|
5238
|
+
? null
|
|
5239
|
+
: this._createValidationError(processedValue);
|
|
5240
|
+
}
|
|
5241
|
+
if (maskValue.startsWith("percent" /* MaskExpression.PERCENT */)) {
|
|
5242
|
+
return null;
|
|
5243
|
+
}
|
|
5244
|
+
for (const key in this._maskService.patterns) {
|
|
5245
|
+
if (this._maskService.patterns[key]?.optional) {
|
|
5246
|
+
if (maskValue.indexOf(key) !== maskValue.lastIndexOf(key)) {
|
|
5247
|
+
const opt = maskValue
|
|
5248
|
+
.split("" /* MaskExpression.EMPTY_STRING */)
|
|
5249
|
+
.filter((i) => i === key)
|
|
5250
|
+
.join("" /* MaskExpression.EMPTY_STRING */);
|
|
5251
|
+
counterOfOpt += opt.length;
|
|
5252
|
+
}
|
|
5253
|
+
else if (maskValue.indexOf(key) !== -1) {
|
|
5254
|
+
counterOfOpt++;
|
|
5255
|
+
}
|
|
5256
|
+
if (maskValue.indexOf(key) !== -1 &&
|
|
5257
|
+
processedValue.length >= maskValue.indexOf(key)) {
|
|
5258
|
+
return null;
|
|
5259
|
+
}
|
|
5260
|
+
if (counterOfOpt === maskValue.length) {
|
|
5261
|
+
return null;
|
|
5262
|
+
}
|
|
5263
|
+
}
|
|
5264
|
+
}
|
|
5265
|
+
if ((maskValue.indexOf("*" /* MaskExpression.SYMBOL_STAR */) > 1 &&
|
|
5266
|
+
processedValue.length < maskValue.indexOf("*" /* MaskExpression.SYMBOL_STAR */)) ||
|
|
5267
|
+
(maskValue.indexOf("?" /* MaskExpression.SYMBOL_QUESTION */) > 1 &&
|
|
5268
|
+
processedValue.length < maskValue.indexOf("?" /* MaskExpression.SYMBOL_QUESTION */))) {
|
|
5269
|
+
return this._createValidationError(processedValue);
|
|
5270
|
+
}
|
|
5271
|
+
if (maskValue.indexOf("*" /* MaskExpression.SYMBOL_STAR */) === -1 ||
|
|
5272
|
+
maskValue.indexOf("?" /* MaskExpression.SYMBOL_QUESTION */) === -1) {
|
|
5273
|
+
const array = maskValue.split('*');
|
|
5274
|
+
const length = this._maskService.dropSpecialCharacters
|
|
5275
|
+
? maskValue.length -
|
|
5276
|
+
this._maskService.checkDropSpecialCharAmount(maskValue) -
|
|
5277
|
+
counterOfOpt
|
|
5278
|
+
: this.prefix()
|
|
5279
|
+
? maskValue.length + this.prefix().length - counterOfOpt
|
|
5280
|
+
: maskValue.length - counterOfOpt;
|
|
5281
|
+
if (array.length === 1) {
|
|
5282
|
+
if (processedValue.length < length) {
|
|
5283
|
+
return this._createValidationError(processedValue);
|
|
5284
|
+
}
|
|
5285
|
+
}
|
|
5286
|
+
if (array.length > 1) {
|
|
5287
|
+
const lastIndexArray = array[array.length - 1];
|
|
5288
|
+
if (lastIndexArray &&
|
|
5289
|
+
this._maskService.specialCharacters.includes(lastIndexArray[0]) &&
|
|
5290
|
+
String(processedValue).includes(lastIndexArray[0] ?? '') &&
|
|
5291
|
+
!this.dropSpecialCharacters()) {
|
|
5292
|
+
const special = value.split(lastIndexArray[0]);
|
|
5293
|
+
return special[special.length - 1].length === lastIndexArray.length - 1
|
|
5294
|
+
? null
|
|
5295
|
+
: this._createValidationError(processedValue);
|
|
5296
|
+
}
|
|
5297
|
+
else if (((lastIndexArray &&
|
|
5298
|
+
!this._maskService.specialCharacters.includes(lastIndexArray[0])) ||
|
|
5299
|
+
!lastIndexArray ||
|
|
5300
|
+
this._maskService.dropSpecialCharacters) &&
|
|
5301
|
+
processedValue.length >= length - 1) {
|
|
5302
|
+
return null;
|
|
5303
|
+
}
|
|
5304
|
+
else {
|
|
5305
|
+
return this._createValidationError(processedValue);
|
|
5306
|
+
}
|
|
5307
|
+
}
|
|
5308
|
+
}
|
|
5309
|
+
if (maskValue.indexOf("*" /* MaskExpression.SYMBOL_STAR */) === 1 ||
|
|
5310
|
+
maskValue.indexOf("?" /* MaskExpression.SYMBOL_QUESTION */) === 1) {
|
|
5311
|
+
return null;
|
|
5312
|
+
}
|
|
5313
|
+
}
|
|
5314
|
+
if (value) {
|
|
5315
|
+
this.maskFilled.emit();
|
|
5316
|
+
return null;
|
|
5317
|
+
}
|
|
5318
|
+
return null;
|
|
5319
|
+
}
|
|
5320
|
+
onPaste() {
|
|
5321
|
+
this._justPasted.set(true);
|
|
5322
|
+
}
|
|
5323
|
+
onFocus() {
|
|
5324
|
+
this._isFocused.set(true);
|
|
5325
|
+
}
|
|
5326
|
+
onModelChange(value) {
|
|
5327
|
+
// on form reset we need to update the actualValue
|
|
5328
|
+
if ((value === "" /* MaskExpression.EMPTY_STRING */ ||
|
|
5329
|
+
value === null ||
|
|
5330
|
+
typeof value === 'undefined') &&
|
|
5331
|
+
this._maskService.actualValue) {
|
|
5332
|
+
this._maskService.actualValue = this._maskService.getActualValue("" /* MaskExpression.EMPTY_STRING */);
|
|
5333
|
+
}
|
|
5334
|
+
}
|
|
5335
|
+
onInput(e) {
|
|
5336
|
+
// If IME is composing text, we wait for the composed text.
|
|
5337
|
+
if (this._isComposing()) {
|
|
5338
|
+
return;
|
|
5339
|
+
}
|
|
5340
|
+
const el = e.target;
|
|
5341
|
+
const transformedValue = this._maskService.inputTransformFn
|
|
5342
|
+
? this._maskService.inputTransformFn(el.value)
|
|
5343
|
+
: el.value;
|
|
5344
|
+
if (el.type !== 'number') {
|
|
5345
|
+
if (typeof transformedValue === 'string' || typeof transformedValue === 'number') {
|
|
5346
|
+
el.value = transformedValue.toString();
|
|
5347
|
+
this._inputValue.set(el.value);
|
|
5348
|
+
this._setMask();
|
|
5349
|
+
if (!this._maskValue()) {
|
|
5350
|
+
this.onChange(el.value);
|
|
5351
|
+
return;
|
|
5352
|
+
}
|
|
5353
|
+
let position = el.selectionStart === 1
|
|
5354
|
+
? el.selectionStart + this._maskService.prefix.length
|
|
5355
|
+
: el.selectionStart;
|
|
5356
|
+
if (this.showMaskTyped() &&
|
|
5357
|
+
this.keepCharacterPositions() &&
|
|
5358
|
+
this._maskService.placeHolderCharacter.length === 1) {
|
|
5359
|
+
const suffix = this.suffix();
|
|
5360
|
+
const prefix = this.prefix();
|
|
5361
|
+
const inputSymbol = el.value.slice(position - 1, position);
|
|
5362
|
+
const prefixLength = prefix.length;
|
|
5363
|
+
const checkSymbols = this._maskService._checkSymbolMask(inputSymbol, this._maskService.maskExpression[position - 1 - prefixLength] ??
|
|
5364
|
+
"" /* MaskExpression.EMPTY_STRING */);
|
|
5365
|
+
const checkSpecialCharacter = this._maskService._checkSymbolMask(inputSymbol, this._maskService.maskExpression[position + 1 - prefixLength] ??
|
|
5366
|
+
"" /* MaskExpression.EMPTY_STRING */);
|
|
5367
|
+
const selectRangeBackspace = this._maskService.selStart === this._maskService.selEnd;
|
|
5368
|
+
const selStart = Number(this._maskService.selStart) - prefixLength;
|
|
5369
|
+
const selEnd = Number(this._maskService.selEnd) - prefixLength;
|
|
5370
|
+
const backspaceOrDelete = this._code() === "Backspace" /* MaskExpression.BACKSPACE */ ||
|
|
5371
|
+
this._code() === "Delete" /* MaskExpression.DELETE */;
|
|
5372
|
+
if (backspaceOrDelete) {
|
|
5373
|
+
if (!selectRangeBackspace) {
|
|
5374
|
+
if (this._maskService.selStart === prefixLength) {
|
|
5375
|
+
this._maskService.actualValue = `${prefix}${this._maskService.maskIsShown.slice(0, selEnd)}${this._inputValue().split(prefix).join('')}`;
|
|
5376
|
+
}
|
|
5377
|
+
else if (this._maskService.selStart ===
|
|
5378
|
+
this._maskService.maskIsShown.length + prefixLength) {
|
|
5379
|
+
this._maskService.actualValue = `${this._inputValue()}${this._maskService.maskIsShown.slice(selStart, selEnd)}`;
|
|
5380
|
+
}
|
|
5381
|
+
else {
|
|
5382
|
+
this._maskService.actualValue = `${prefix}${this._inputValue()
|
|
5383
|
+
.split(prefix)
|
|
5384
|
+
.join('')
|
|
5385
|
+
.slice(0, selStart)}${this._maskService.maskIsShown.slice(selStart, selEnd)}${this._maskService.actualValue.slice(selEnd + prefixLength, this._maskService.maskIsShown.length + prefixLength)}${suffix}`;
|
|
5386
|
+
}
|
|
5387
|
+
}
|
|
5388
|
+
else if (!this._maskService.specialCharacters.includes(this._maskService.maskExpression.slice(position - prefixLength, position + 1 - prefixLength)) &&
|
|
5389
|
+
selectRangeBackspace) {
|
|
5390
|
+
if (selStart === 1 && prefix) {
|
|
5391
|
+
this._maskService.actualValue = `${prefix}${this._maskService.placeHolderCharacter}${el.value
|
|
5392
|
+
.split(prefix)
|
|
5393
|
+
.join('')
|
|
5394
|
+
.split(suffix)
|
|
5395
|
+
.join('')}${suffix}`;
|
|
5396
|
+
position = position - 1;
|
|
5397
|
+
}
|
|
5398
|
+
else {
|
|
5399
|
+
const part1 = el.value.substring(0, position);
|
|
5400
|
+
const part2 = el.value.substring(position);
|
|
5401
|
+
this._maskService.actualValue = `${part1}${this._maskService.placeHolderCharacter}${part2}`;
|
|
5402
|
+
}
|
|
5403
|
+
}
|
|
5404
|
+
position = this._code() === "Delete" /* MaskExpression.DELETE */ ? position + 1 : position;
|
|
5405
|
+
}
|
|
5406
|
+
if (!backspaceOrDelete) {
|
|
5407
|
+
if (!checkSymbols && !checkSpecialCharacter && selectRangeBackspace) {
|
|
5408
|
+
position = Number(el.selectionStart) - 1;
|
|
5409
|
+
}
|
|
5410
|
+
else if (this._maskService.specialCharacters.includes(el.value.slice(position, position + 1)) &&
|
|
5411
|
+
checkSpecialCharacter &&
|
|
5412
|
+
!this._maskService.specialCharacters.includes(el.value.slice(position + 1, position + 2))) {
|
|
5413
|
+
this._maskService.actualValue = `${el.value.slice(0, position - 1)}${el.value.slice(position, position + 1)}${inputSymbol}${el.value.slice(position + 2)}`;
|
|
5414
|
+
position = position + 1;
|
|
5415
|
+
}
|
|
5416
|
+
else if (checkSymbols) {
|
|
5417
|
+
if (el.value.length === 1 && position === 1) {
|
|
5418
|
+
this._maskService.actualValue = `${prefix}${inputSymbol}${this._maskService.maskIsShown.slice(1, this._maskService.maskIsShown.length)}${suffix}`;
|
|
5419
|
+
}
|
|
5420
|
+
else {
|
|
5421
|
+
this._maskService.actualValue = `${el.value.slice(0, position - 1)}${inputSymbol}${el.value
|
|
5422
|
+
.slice(position + 1)
|
|
5423
|
+
.split(suffix)
|
|
5424
|
+
.join('')}${suffix}`;
|
|
5425
|
+
}
|
|
5426
|
+
}
|
|
5427
|
+
else if (prefix &&
|
|
5428
|
+
el.value.length === 1 &&
|
|
5429
|
+
position - prefixLength === 1 &&
|
|
5430
|
+
this._maskService._checkSymbolMask(el.value, this._maskService.maskExpression[position - 1 - prefixLength] ??
|
|
5431
|
+
"" /* MaskExpression.EMPTY_STRING */)) {
|
|
5432
|
+
this._maskService.actualValue = `${prefix}${el.value}${this._maskService.maskIsShown.slice(1, this._maskService.maskIsShown.length)}${suffix}`;
|
|
5433
|
+
}
|
|
5434
|
+
}
|
|
5435
|
+
}
|
|
5436
|
+
let caretShift = 0;
|
|
5437
|
+
let backspaceShift = false;
|
|
5438
|
+
if (this._code() === "Delete" /* MaskExpression.DELETE */ && "separator" /* MaskExpression.SEPARATOR */) {
|
|
5439
|
+
this._maskService.deletedSpecialCharacter = true;
|
|
5440
|
+
}
|
|
5441
|
+
if (this._inputValue().length >= this._maskService.maskExpression.length - 1 &&
|
|
5442
|
+
this._code() !== "Backspace" /* MaskExpression.BACKSPACE */ &&
|
|
5443
|
+
this._maskService.maskExpression === "d0/M0/0000" /* MaskExpression.DAYS_MONTHS_YEARS */ &&
|
|
5444
|
+
position < 10) {
|
|
5445
|
+
const inputSymbol = this._inputValue().slice(position - 1, position);
|
|
5446
|
+
el.value =
|
|
5447
|
+
this._inputValue().slice(0, position - 1) +
|
|
5448
|
+
inputSymbol +
|
|
5449
|
+
this._inputValue().slice(position + 1);
|
|
5450
|
+
}
|
|
5451
|
+
if (this._maskService.maskExpression === "d0/M0/0000" /* MaskExpression.DAYS_MONTHS_YEARS */ &&
|
|
5452
|
+
this.leadZeroDateTime()) {
|
|
5453
|
+
if ((position < 3 && Number(el.value) > 31 && Number(el.value) < 40) ||
|
|
5454
|
+
(position === 5 && Number(el.value.slice(3, 5)) > 12)) {
|
|
5455
|
+
position = position + 2;
|
|
5456
|
+
}
|
|
5457
|
+
}
|
|
5458
|
+
if (this._maskService.maskExpression === "Hh:m0:s0" /* MaskExpression.HOURS_MINUTES_SECONDS */ &&
|
|
5459
|
+
this.apm()) {
|
|
5460
|
+
if (this._justPasted() && el.value.slice(0, 2) === "00" /* MaskExpression.DOUBLE_ZERO */) {
|
|
5461
|
+
el.value = el.value.slice(1, 2) + el.value.slice(2, el.value.length);
|
|
5462
|
+
}
|
|
5463
|
+
el.value =
|
|
5464
|
+
el.value === "00" /* MaskExpression.DOUBLE_ZERO */
|
|
5465
|
+
? "0" /* MaskExpression.NUMBER_ZERO */
|
|
5466
|
+
: el.value;
|
|
5467
|
+
}
|
|
5468
|
+
this._maskService.applyValueChanges(position, this._justPasted(), this._code() === "Backspace" /* MaskExpression.BACKSPACE */ ||
|
|
5469
|
+
this._code() === "Delete" /* MaskExpression.DELETE */, (shift, _backspaceShift) => {
|
|
5470
|
+
this._justPasted.set(false);
|
|
5471
|
+
caretShift = shift;
|
|
5472
|
+
backspaceShift = _backspaceShift;
|
|
5473
|
+
});
|
|
5474
|
+
// only set the selection if the element is active
|
|
5475
|
+
if (this._getActiveElement() !== el) {
|
|
5476
|
+
return;
|
|
5477
|
+
}
|
|
5478
|
+
if (this._maskService.plusOnePosition) {
|
|
5479
|
+
position = position + 1;
|
|
5480
|
+
this._maskService.plusOnePosition = false;
|
|
5481
|
+
}
|
|
5482
|
+
// update position after applyValueChanges to prevent cursor on wrong position when it has an array of maskExpression
|
|
5483
|
+
if (this._maskExpressionArray().length) {
|
|
5484
|
+
if (this._code() === "Backspace" /* MaskExpression.BACKSPACE */) {
|
|
5485
|
+
const specialChartMinusOne = this.specialCharacters().includes(this._maskService.actualValue.slice(position - 1, position));
|
|
5486
|
+
const allowFewMaskChangeMask = this._maskService.removeMask(this._inputValue())?.length ===
|
|
5487
|
+
this._maskService.removeMask(this._maskService.maskExpression)?.length;
|
|
5488
|
+
const specialChartPlusOne = this.specialCharacters().includes(this._maskService.actualValue.slice(position, position + 1));
|
|
5489
|
+
if (allowFewMaskChangeMask && !specialChartPlusOne) {
|
|
5490
|
+
position = el.selectionStart + 1;
|
|
5491
|
+
}
|
|
5492
|
+
else {
|
|
5493
|
+
position = specialChartMinusOne ? position - 1 : position;
|
|
5494
|
+
}
|
|
5495
|
+
}
|
|
5496
|
+
else {
|
|
5497
|
+
position =
|
|
5498
|
+
el.selectionStart === 1
|
|
5499
|
+
? el.selectionStart + this._maskService.prefix.length
|
|
5500
|
+
: el.selectionStart;
|
|
5501
|
+
}
|
|
5502
|
+
}
|
|
5503
|
+
this._position.set(this._position() === 1 && this._inputValue().length === 1
|
|
5504
|
+
? null
|
|
5505
|
+
: this._position());
|
|
5506
|
+
let positionToApply = this._position()
|
|
5507
|
+
? this._inputValue().length + position + caretShift
|
|
5508
|
+
: position +
|
|
5509
|
+
(this._code() === "Backspace" /* MaskExpression.BACKSPACE */ && !backspaceShift
|
|
5510
|
+
? 0
|
|
5511
|
+
: caretShift);
|
|
5512
|
+
if (positionToApply > this._getActualInputLength()) {
|
|
5513
|
+
positionToApply =
|
|
5514
|
+
el.value === this._maskService.decimalMarker && el.value.length === 1
|
|
5515
|
+
? this._getActualInputLength() + 1
|
|
5516
|
+
: this._getActualInputLength();
|
|
5517
|
+
}
|
|
5518
|
+
if (positionToApply < 0) {
|
|
5519
|
+
positionToApply = 0;
|
|
5520
|
+
}
|
|
5521
|
+
el.setSelectionRange(positionToApply, positionToApply);
|
|
5522
|
+
this._position.set(null);
|
|
5523
|
+
}
|
|
5524
|
+
else {
|
|
5525
|
+
// eslint-disable-next-line no-console
|
|
5526
|
+
console.warn('Ngx-mask writeValue work with string | number, your current value:', typeof transformedValue);
|
|
5527
|
+
}
|
|
5528
|
+
}
|
|
5529
|
+
else {
|
|
5530
|
+
if (!this._maskValue()) {
|
|
5531
|
+
this.onChange(el.value);
|
|
5532
|
+
return;
|
|
5533
|
+
}
|
|
5534
|
+
this._maskService.applyValueChanges(el.value.length, this._justPasted(), this._code() === "Backspace" /* MaskExpression.BACKSPACE */ || this._code() === "Delete" /* MaskExpression.DELETE */);
|
|
5535
|
+
}
|
|
5536
|
+
}
|
|
5537
|
+
// IME starts
|
|
5538
|
+
onCompositionStart() {
|
|
5539
|
+
this._isComposing.set(true);
|
|
5540
|
+
}
|
|
5541
|
+
// IME completes
|
|
5542
|
+
onCompositionEnd(e) {
|
|
5543
|
+
this._isComposing.set(false);
|
|
5544
|
+
this._justPasted.set(true);
|
|
5545
|
+
this.onInput(e);
|
|
5546
|
+
}
|
|
5547
|
+
onBlur(e) {
|
|
5548
|
+
if (this._maskValue()) {
|
|
5549
|
+
const el = e.target;
|
|
5550
|
+
if (this._maskService.leadZero &&
|
|
5551
|
+
el.value.length > 0 &&
|
|
5552
|
+
typeof this._maskService.decimalMarker === 'string') {
|
|
5553
|
+
const maskExpression = this._maskService.maskExpression;
|
|
5554
|
+
const decimalMarker = this._maskService.decimalMarker;
|
|
5555
|
+
const suffix = this._maskService.suffix;
|
|
5556
|
+
const precision = Number(this._maskService.maskExpression.slice(maskExpression.length - 1, maskExpression.length));
|
|
5557
|
+
if (precision > 0) {
|
|
5558
|
+
el.value = suffix ? el.value.split(suffix).join('') : el.value;
|
|
5559
|
+
const decimalPart = el.value.split(decimalMarker)[1];
|
|
5560
|
+
el.value = el.value.includes(decimalMarker)
|
|
5561
|
+
? el.value +
|
|
5562
|
+
"0" /* MaskExpression.NUMBER_ZERO */.repeat(precision - decimalPart.length) +
|
|
5563
|
+
suffix
|
|
5564
|
+
: el.value +
|
|
5565
|
+
decimalMarker +
|
|
5566
|
+
"0" /* MaskExpression.NUMBER_ZERO */.repeat(precision) +
|
|
5567
|
+
suffix;
|
|
5568
|
+
this._maskService.actualValue = el.value;
|
|
5569
|
+
}
|
|
5570
|
+
}
|
|
5571
|
+
this._maskService.clearIfNotMatchFn();
|
|
5572
|
+
}
|
|
5573
|
+
this._isFocused.set(false);
|
|
5574
|
+
this.onTouch();
|
|
5575
|
+
}
|
|
5576
|
+
onClick(e) {
|
|
5577
|
+
if (!this._maskValue()) {
|
|
5578
|
+
return;
|
|
5579
|
+
}
|
|
5580
|
+
const el = e.target;
|
|
5581
|
+
const posStart = 0;
|
|
5582
|
+
const posEnd = 0;
|
|
5583
|
+
if (el !== null &&
|
|
5584
|
+
el.selectionStart !== null &&
|
|
5585
|
+
el.selectionStart === el.selectionEnd &&
|
|
5586
|
+
el.selectionStart > this._maskService.prefix.length &&
|
|
5587
|
+
e.keyCode !== 38) {
|
|
5588
|
+
if (this._maskService.showMaskTyped && !this.keepCharacterPositions()) {
|
|
5589
|
+
// We are showing the mask in the input
|
|
5590
|
+
this._maskService.maskIsShown = this._maskService.showMaskInInput();
|
|
5591
|
+
if (el.setSelectionRange &&
|
|
5592
|
+
this._maskService.prefix + this._maskService.maskIsShown === el.value) {
|
|
5593
|
+
// the input ONLY contains the mask, so position the cursor at the start
|
|
5594
|
+
el.focus();
|
|
5595
|
+
el.setSelectionRange(posStart, posEnd);
|
|
5596
|
+
}
|
|
5597
|
+
else {
|
|
5598
|
+
// the input contains some characters already
|
|
5599
|
+
if (el.selectionStart > this._maskService.actualValue.length) {
|
|
5600
|
+
// if the user clicked beyond our value's length, position the cursor at the end of our value
|
|
5601
|
+
el.setSelectionRange(this._maskService.actualValue.length, this._maskService.actualValue.length);
|
|
5602
|
+
}
|
|
5603
|
+
}
|
|
5604
|
+
}
|
|
5605
|
+
}
|
|
5606
|
+
const nextValue = el &&
|
|
5607
|
+
(el.value === this._maskService.prefix
|
|
5608
|
+
? this._maskService.prefix + this._maskService.maskIsShown
|
|
5609
|
+
: el.value);
|
|
5610
|
+
/** Fix of cursor position jumping to end in most browsers no matter where cursor is inserted onFocus */
|
|
5611
|
+
if (el && el.value !== nextValue) {
|
|
5612
|
+
el.value = nextValue;
|
|
5613
|
+
}
|
|
5614
|
+
/** fix of cursor position with prefix when mouse click occur */
|
|
5615
|
+
if (el &&
|
|
5616
|
+
el.type !== 'number' &&
|
|
5617
|
+
(el.selectionStart || el.selectionEnd) <=
|
|
5618
|
+
this._maskService.prefix.length) {
|
|
5619
|
+
const specialCharactersAtTheStart = this._maskService.maskExpression.match(new RegExp(`^[${this._maskService.specialCharacters.map((c) => `\\${c}`).join('')}]+`))?.[0].length || 0;
|
|
5620
|
+
el.selectionStart = this._maskService.prefix.length + specialCharactersAtTheStart;
|
|
5621
|
+
return;
|
|
5622
|
+
}
|
|
5623
|
+
/** select only inserted text */
|
|
5624
|
+
if (el && el.selectionEnd > this._getActualInputLength()) {
|
|
5625
|
+
el.selectionEnd = this._getActualInputLength();
|
|
5626
|
+
}
|
|
5627
|
+
}
|
|
5628
|
+
onKeyDown(e) {
|
|
5629
|
+
if (!this._maskValue()) {
|
|
5630
|
+
return;
|
|
5631
|
+
}
|
|
5632
|
+
if (this._isComposing()) {
|
|
5633
|
+
// User finalize their choice from IME composition, so trigger onInput() for the composed text.
|
|
5634
|
+
if (e.key === 'Enter') {
|
|
5635
|
+
this.onCompositionEnd(e);
|
|
5636
|
+
}
|
|
5637
|
+
return;
|
|
5638
|
+
}
|
|
5639
|
+
this._code.set(e.code ? e.code : e.key);
|
|
5640
|
+
const el = e.target;
|
|
5641
|
+
this._inputValue.set(el.value);
|
|
5642
|
+
this._setMask();
|
|
5643
|
+
if (el.type !== 'number') {
|
|
5644
|
+
if (e.key === "ArrowUp" /* MaskExpression.ARROW_UP */) {
|
|
5645
|
+
e.preventDefault();
|
|
5646
|
+
}
|
|
5647
|
+
if (e.key === "ArrowLeft" /* MaskExpression.ARROW_LEFT */ ||
|
|
5648
|
+
e.key === "Backspace" /* MaskExpression.BACKSPACE */ ||
|
|
5649
|
+
e.key === "Delete" /* MaskExpression.DELETE */) {
|
|
5650
|
+
if (e.key === "Backspace" /* MaskExpression.BACKSPACE */ && el.value.length === 0) {
|
|
5651
|
+
el.selectionStart = el.selectionEnd;
|
|
5652
|
+
}
|
|
5653
|
+
if (e.key === "Backspace" /* MaskExpression.BACKSPACE */ && el.selectionStart !== 0) {
|
|
5654
|
+
const prefixLength = this.prefix().length;
|
|
5655
|
+
// If specialChars is false, (shouldn't ever happen) then set to the defaults
|
|
5656
|
+
const specialCharacters = this.specialCharacters().length
|
|
5657
|
+
? this.specialCharacters()
|
|
5658
|
+
: this._config.specialCharacters;
|
|
5659
|
+
if (prefixLength > 1 && el.selectionStart <= prefixLength) {
|
|
5660
|
+
el.setSelectionRange(prefixLength, el.selectionEnd);
|
|
5661
|
+
}
|
|
5662
|
+
else {
|
|
5663
|
+
if (this._inputValue().length !== el.selectionStart &&
|
|
5664
|
+
el.selectionStart !== 1) {
|
|
5665
|
+
while (specialCharacters.includes((this._inputValue()[el.selectionStart - 1] ??
|
|
5666
|
+
"" /* MaskExpression.EMPTY_STRING */).toString()) &&
|
|
5667
|
+
((prefixLength >= 1 &&
|
|
5668
|
+
el.selectionStart > prefixLength) ||
|
|
5669
|
+
prefixLength === 0)) {
|
|
5670
|
+
el.setSelectionRange(el.selectionStart - 1, el.selectionEnd);
|
|
5671
|
+
}
|
|
5672
|
+
}
|
|
5673
|
+
}
|
|
5674
|
+
}
|
|
5675
|
+
this.checkSelectionOnDeletion(el);
|
|
5676
|
+
if (this._maskService.prefix.length &&
|
|
5677
|
+
el.selectionStart <= this._maskService.prefix.length &&
|
|
5678
|
+
el.selectionEnd <= this._maskService.prefix.length) {
|
|
5679
|
+
e.preventDefault();
|
|
5680
|
+
}
|
|
5681
|
+
const cursorStart = el.selectionStart;
|
|
5682
|
+
if (e.key === "Backspace" /* MaskExpression.BACKSPACE */ &&
|
|
5683
|
+
!el.readOnly &&
|
|
5684
|
+
cursorStart === 0 &&
|
|
5685
|
+
el.selectionEnd === el.value.length &&
|
|
5686
|
+
el.value.length !== 0) {
|
|
5687
|
+
this._position.set(this._maskService.prefix ? this._maskService.prefix.length : 0);
|
|
5688
|
+
this._maskService.applyMask(this._maskService.prefix, this._maskService.maskExpression, this._position());
|
|
5689
|
+
}
|
|
5690
|
+
}
|
|
5691
|
+
if (!!this.suffix() &&
|
|
5692
|
+
this.suffix().length > 1 &&
|
|
5693
|
+
this._inputValue().length - this.suffix().length < el.selectionStart) {
|
|
5694
|
+
el.setSelectionRange(this._inputValue().length - this.suffix().length, this._inputValue().length);
|
|
5695
|
+
}
|
|
5696
|
+
else if ((e.code === 'KeyA' && e.ctrlKey) ||
|
|
5697
|
+
(e.code === 'KeyA' && e.metaKey) // Cmd + A (Mac)
|
|
5698
|
+
) {
|
|
5699
|
+
el.setSelectionRange(0, this._getActualInputLength());
|
|
5700
|
+
e.preventDefault();
|
|
5701
|
+
}
|
|
5702
|
+
this._maskService.selStart = el.selectionStart;
|
|
5703
|
+
this._maskService.selEnd = el.selectionEnd;
|
|
5704
|
+
}
|
|
5705
|
+
}
|
|
5706
|
+
/** It writes the value in the input */
|
|
5707
|
+
async writeValue(controlValue) {
|
|
5708
|
+
let value = controlValue;
|
|
5709
|
+
const inputTransformFn = this._maskService.inputTransformFn;
|
|
5710
|
+
if (typeof value === 'object' && value !== null && 'value' in value) {
|
|
5711
|
+
if ('disable' in value) {
|
|
5712
|
+
this.setDisabledState(Boolean(value.disable));
|
|
5713
|
+
}
|
|
5714
|
+
value = value.value;
|
|
5715
|
+
}
|
|
5716
|
+
if (value !== null) {
|
|
5717
|
+
value = inputTransformFn ? inputTransformFn(value) : value;
|
|
5718
|
+
}
|
|
5719
|
+
if (typeof value === 'string' ||
|
|
5720
|
+
typeof value === 'number' ||
|
|
5721
|
+
value === null ||
|
|
5722
|
+
typeof value === 'undefined') {
|
|
5723
|
+
if (value === null || typeof value === 'undefined' || value === '') {
|
|
5724
|
+
this._maskService.currentValue = '';
|
|
5725
|
+
this._maskService.previousValue = '';
|
|
5726
|
+
}
|
|
5727
|
+
let inputValue = value;
|
|
5728
|
+
if (typeof inputValue === 'number' ||
|
|
5729
|
+
this._maskValue().startsWith("separator" /* MaskExpression.SEPARATOR */)) {
|
|
5730
|
+
inputValue = String(inputValue);
|
|
5731
|
+
const localeDecimalMarker = this._maskService.currentLocaleDecimalMarker();
|
|
5732
|
+
if (!Array.isArray(this._maskService.decimalMarker)) {
|
|
5733
|
+
inputValue =
|
|
5734
|
+
this._maskService.decimalMarker !== localeDecimalMarker
|
|
5735
|
+
? inputValue.replace(localeDecimalMarker, this._maskService.decimalMarker)
|
|
5736
|
+
: inputValue;
|
|
5737
|
+
}
|
|
5738
|
+
if (this._maskService.leadZero &&
|
|
5739
|
+
inputValue &&
|
|
5740
|
+
this.mask() &&
|
|
5741
|
+
this.dropSpecialCharacters() !== false) {
|
|
5742
|
+
inputValue = this._maskService._checkPrecision(this._maskService.maskExpression, inputValue);
|
|
5743
|
+
}
|
|
5744
|
+
if (this._maskService.decimalMarker === "," /* MaskExpression.COMMA */ ||
|
|
5745
|
+
(Array.isArray(this._maskService.decimalMarker) &&
|
|
5746
|
+
this._maskService.thousandSeparator === "." /* MaskExpression.DOT */)) {
|
|
5747
|
+
inputValue = inputValue
|
|
5748
|
+
.toString()
|
|
5749
|
+
.replace("." /* MaskExpression.DOT */, "," /* MaskExpression.COMMA */);
|
|
5750
|
+
}
|
|
5751
|
+
if (this.mask()?.startsWith("separator" /* MaskExpression.SEPARATOR */) && this.leadZero()) {
|
|
5752
|
+
requestAnimationFrame(() => {
|
|
5753
|
+
this._maskService.applyMask(inputValue?.toString() ?? '', this._maskService.maskExpression);
|
|
5754
|
+
});
|
|
5755
|
+
}
|
|
5756
|
+
this._maskService.isNumberValue = true;
|
|
5757
|
+
}
|
|
5758
|
+
if (typeof inputValue !== 'string' || value === null || typeof value === 'undefined') {
|
|
5759
|
+
inputValue = '';
|
|
5760
|
+
}
|
|
5761
|
+
this._inputValue.set(inputValue);
|
|
5762
|
+
this._setMask();
|
|
5763
|
+
if ((inputValue && this._maskService.maskExpression) ||
|
|
5764
|
+
(this._maskService.maskExpression &&
|
|
5765
|
+
(this._maskService.prefix || this._maskService.showMaskTyped))) {
|
|
5766
|
+
// Let the service we know we are writing value so that triggering onChange function won't happen during applyMask
|
|
5767
|
+
this._maskService.writingValue = true;
|
|
5768
|
+
this._maskService.formElementProperty = [
|
|
5769
|
+
'value',
|
|
5770
|
+
this._maskService.applyMask(inputValue, this._maskService.maskExpression),
|
|
5771
|
+
];
|
|
5772
|
+
// Let the service know we've finished writing value
|
|
5773
|
+
this._maskService.writingValue = false;
|
|
5774
|
+
}
|
|
5775
|
+
else {
|
|
5776
|
+
this._maskService.formElementProperty = ['value', inputValue];
|
|
5777
|
+
}
|
|
5778
|
+
this._inputValue.set(inputValue);
|
|
5779
|
+
}
|
|
5780
|
+
else {
|
|
5781
|
+
// eslint-disable-next-line no-console
|
|
5782
|
+
console.warn('Ngx-mask writeValue work with string | number, your current value:', typeof value);
|
|
5783
|
+
}
|
|
5784
|
+
}
|
|
5785
|
+
registerOnChange(fn) {
|
|
5786
|
+
this._maskService.onChange = this.onChange = fn;
|
|
5787
|
+
}
|
|
5788
|
+
registerOnTouched(fn) {
|
|
5789
|
+
this.onTouch = fn;
|
|
5790
|
+
}
|
|
5791
|
+
_getActiveElement(document = this.document) {
|
|
5792
|
+
const shadowRootEl = document?.activeElement?.shadowRoot;
|
|
5793
|
+
if (!shadowRootEl?.activeElement) {
|
|
5794
|
+
return document.activeElement;
|
|
5795
|
+
}
|
|
5796
|
+
else {
|
|
5797
|
+
return this._getActiveElement(shadowRootEl);
|
|
5798
|
+
}
|
|
5799
|
+
}
|
|
5800
|
+
checkSelectionOnDeletion(el) {
|
|
5801
|
+
const prefixLength = this.prefix().length;
|
|
5802
|
+
const suffixLength = this.suffix().length;
|
|
5803
|
+
const inputValueLength = this._inputValue().length;
|
|
5804
|
+
el.selectionStart = Math.min(Math.max(prefixLength, el.selectionStart), inputValueLength - suffixLength);
|
|
5805
|
+
el.selectionEnd = Math.min(Math.max(prefixLength, el.selectionEnd), inputValueLength - suffixLength);
|
|
5806
|
+
}
|
|
5807
|
+
/** It disables the input element */
|
|
5808
|
+
setDisabledState(isDisabled) {
|
|
5809
|
+
this._maskService.formElementProperty = ['disabled', isDisabled];
|
|
5810
|
+
}
|
|
5811
|
+
_applyMask() {
|
|
5812
|
+
this._maskService.maskExpression = this._maskService._repeatPatternSymbols(this._maskValue() || '');
|
|
5813
|
+
this._maskService.formElementProperty = [
|
|
5814
|
+
'value',
|
|
5815
|
+
this._maskService.applyMask(this._inputValue(), this._maskService.maskExpression),
|
|
5816
|
+
];
|
|
5817
|
+
}
|
|
5818
|
+
_validateTime(value) {
|
|
5819
|
+
const rowMaskLen = this._maskValue()
|
|
5820
|
+
.split("" /* MaskExpression.EMPTY_STRING */)
|
|
5821
|
+
.filter((s) => s !== ':').length;
|
|
5822
|
+
if (!value) {
|
|
5823
|
+
return null; // Don't validate empty values to allow for optional form control
|
|
5824
|
+
}
|
|
5825
|
+
if ((+(value[value.length - 1] ?? -1) === 0 && value.length < rowMaskLen) ||
|
|
5826
|
+
value.length <= rowMaskLen - 2) {
|
|
5827
|
+
return this._createValidationError(value);
|
|
5828
|
+
}
|
|
5829
|
+
return null;
|
|
5830
|
+
}
|
|
5831
|
+
_getActualInputLength() {
|
|
5832
|
+
return (this._maskService.actualValue.length ||
|
|
5833
|
+
this._maskService.actualValue.length + this._maskService.prefix.length);
|
|
5834
|
+
}
|
|
5835
|
+
_createValidationError(actualValue) {
|
|
5836
|
+
return {
|
|
5837
|
+
mask: {
|
|
5838
|
+
requiredMask: this._maskValue(),
|
|
5839
|
+
actualValue,
|
|
5840
|
+
},
|
|
5841
|
+
};
|
|
5842
|
+
}
|
|
5843
|
+
_setMask() {
|
|
5844
|
+
this._maskExpressionArray().some((mask) => {
|
|
5845
|
+
const specialChart = mask
|
|
5846
|
+
.split("" /* MaskExpression.EMPTY_STRING */)
|
|
5847
|
+
.some((char) => this._maskService.specialCharacters.includes(char));
|
|
5848
|
+
if ((specialChart &&
|
|
5849
|
+
this._inputValue() &&
|
|
5850
|
+
this._areAllCharactersInEachStringSame(this._maskExpressionArray())) ||
|
|
5851
|
+
mask.includes("{" /* MaskExpression.CURLY_BRACKETS_LEFT */)) {
|
|
5852
|
+
const test = this._maskService.removeMask(this._inputValue())?.length <=
|
|
5853
|
+
this._maskService.removeMask(mask)?.length;
|
|
5854
|
+
if (test) {
|
|
5855
|
+
const maskValue = mask.includes("{" /* MaskExpression.CURLY_BRACKETS_LEFT */)
|
|
5856
|
+
? this._maskService._repeatPatternSymbols(mask)
|
|
5857
|
+
: mask;
|
|
5858
|
+
this._maskValue.set(maskValue);
|
|
5859
|
+
this._maskService.maskExpression = maskValue;
|
|
5860
|
+
return test;
|
|
5861
|
+
}
|
|
5862
|
+
else {
|
|
5863
|
+
const expression = this._maskExpressionArray()[this._maskExpressionArray().length - 1] ??
|
|
5864
|
+
"" /* MaskExpression.EMPTY_STRING */;
|
|
5865
|
+
const maskValue = expression.includes("{" /* MaskExpression.CURLY_BRACKETS_LEFT */)
|
|
5866
|
+
? this._maskService._repeatPatternSymbols(expression)
|
|
5867
|
+
: expression;
|
|
5868
|
+
this._maskValue.set(maskValue);
|
|
5869
|
+
this._maskService.maskExpression = maskValue;
|
|
5870
|
+
}
|
|
5871
|
+
}
|
|
5872
|
+
else {
|
|
5873
|
+
const cleanMask = this._maskService.removeMask(mask);
|
|
5874
|
+
const check = this._maskService
|
|
5875
|
+
.removeMask(this._inputValue())
|
|
5876
|
+
?.split("" /* MaskExpression.EMPTY_STRING */)
|
|
5877
|
+
.every((character, index) => {
|
|
5878
|
+
const indexMask = cleanMask.charAt(index);
|
|
5879
|
+
return this._maskService._checkSymbolMask(character, indexMask);
|
|
5880
|
+
});
|
|
5881
|
+
if (check || this._justPasted()) {
|
|
5882
|
+
this._maskValue.set(mask);
|
|
5883
|
+
this._maskService.maskExpression = mask;
|
|
5884
|
+
return check;
|
|
5885
|
+
}
|
|
5886
|
+
}
|
|
5887
|
+
});
|
|
5888
|
+
}
|
|
5889
|
+
_areAllCharactersInEachStringSame(array) {
|
|
5890
|
+
const specialCharacters = this._maskService.specialCharacters;
|
|
5891
|
+
function removeSpecialCharacters(str) {
|
|
5892
|
+
const regex = new RegExp(`[${specialCharacters.map((ch) => `\\${ch}`).join('')}]`, 'g');
|
|
5893
|
+
return str.replace(regex, '');
|
|
5894
|
+
}
|
|
5895
|
+
const processedArr = array.map(removeSpecialCharacters);
|
|
5896
|
+
return processedArr.every((str) => {
|
|
5897
|
+
const uniqueCharacters = new Set(str);
|
|
5898
|
+
return uniqueCharacters.size === 1;
|
|
5899
|
+
});
|
|
5900
|
+
}
|
|
5901
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgxMaskDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
5902
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.8", type: NgxMaskDirective, isStandalone: true, selector: "input[mask], textarea[mask]", inputs: { mask: { classPropertyName: "mask", publicName: "mask", isSignal: true, isRequired: false, transformFunction: null }, specialCharacters: { classPropertyName: "specialCharacters", publicName: "specialCharacters", isSignal: true, isRequired: false, transformFunction: null }, patterns: { classPropertyName: "patterns", publicName: "patterns", isSignal: true, isRequired: false, transformFunction: null }, prefix: { classPropertyName: "prefix", publicName: "prefix", isSignal: true, isRequired: false, transformFunction: null }, suffix: { classPropertyName: "suffix", publicName: "suffix", isSignal: true, isRequired: false, transformFunction: null }, thousandSeparator: { classPropertyName: "thousandSeparator", publicName: "thousandSeparator", isSignal: true, isRequired: false, transformFunction: null }, decimalMarker: { classPropertyName: "decimalMarker", publicName: "decimalMarker", isSignal: true, isRequired: false, transformFunction: null }, dropSpecialCharacters: { classPropertyName: "dropSpecialCharacters", publicName: "dropSpecialCharacters", isSignal: true, isRequired: false, transformFunction: null }, hiddenInput: { classPropertyName: "hiddenInput", publicName: "hiddenInput", isSignal: true, isRequired: false, transformFunction: null }, showMaskTyped: { classPropertyName: "showMaskTyped", publicName: "showMaskTyped", isSignal: true, isRequired: false, transformFunction: null }, placeHolderCharacter: { classPropertyName: "placeHolderCharacter", publicName: "placeHolderCharacter", isSignal: true, isRequired: false, transformFunction: null }, shownMaskExpression: { classPropertyName: "shownMaskExpression", publicName: "shownMaskExpression", isSignal: true, isRequired: false, transformFunction: null }, clearIfNotMatch: { classPropertyName: "clearIfNotMatch", publicName: "clearIfNotMatch", isSignal: true, isRequired: false, transformFunction: null }, validation: { classPropertyName: "validation", publicName: "validation", isSignal: true, isRequired: false, transformFunction: null }, separatorLimit: { classPropertyName: "separatorLimit", publicName: "separatorLimit", isSignal: true, isRequired: false, transformFunction: null }, allowNegativeNumbers: { classPropertyName: "allowNegativeNumbers", publicName: "allowNegativeNumbers", isSignal: true, isRequired: false, transformFunction: null }, leadZeroDateTime: { classPropertyName: "leadZeroDateTime", publicName: "leadZeroDateTime", isSignal: true, isRequired: false, transformFunction: null }, leadZero: { classPropertyName: "leadZero", publicName: "leadZero", isSignal: true, isRequired: false, transformFunction: null }, triggerOnMaskChange: { classPropertyName: "triggerOnMaskChange", publicName: "triggerOnMaskChange", isSignal: true, isRequired: false, transformFunction: null }, apm: { classPropertyName: "apm", publicName: "apm", isSignal: true, isRequired: false, transformFunction: null }, inputTransformFn: { classPropertyName: "inputTransformFn", publicName: "inputTransformFn", isSignal: true, isRequired: false, transformFunction: null }, outputTransformFn: { classPropertyName: "outputTransformFn", publicName: "outputTransformFn", isSignal: true, isRequired: false, transformFunction: null }, keepCharacterPositions: { classPropertyName: "keepCharacterPositions", publicName: "keepCharacterPositions", isSignal: true, isRequired: false, transformFunction: null }, instantPrefix: { classPropertyName: "instantPrefix", publicName: "instantPrefix", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { maskFilled: "maskFilled" }, host: { listeners: { "paste": "onPaste()", "focus": "onFocus($event)", "ngModelChange": "onModelChange($event)", "input": "onInput($event)", "compositionstart": "onCompositionStart($event)", "compositionend": "onCompositionEnd($event)", "blur": "onBlur($event)", "click": "onClick($event)", "keydown": "onKeyDown($event)" } }, providers: [
|
|
5903
|
+
{
|
|
5904
|
+
provide: NG_VALUE_ACCESSOR,
|
|
5905
|
+
useExisting: forwardRef(() => NgxMaskDirective),
|
|
5906
|
+
multi: true,
|
|
5907
|
+
},
|
|
5908
|
+
{
|
|
5909
|
+
provide: NG_VALIDATORS,
|
|
5910
|
+
useExisting: forwardRef(() => NgxMaskDirective),
|
|
5911
|
+
multi: true,
|
|
5912
|
+
},
|
|
5913
|
+
NgxMaskService,
|
|
5914
|
+
], exportAs: ["mask", "ngxMask"], usesOnChanges: true, ngImport: i0 }); }
|
|
5915
|
+
}
|
|
5916
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgxMaskDirective, decorators: [{
|
|
5917
|
+
type: Directive,
|
|
5918
|
+
args: [{
|
|
5919
|
+
selector: 'input[mask], textarea[mask]',
|
|
5920
|
+
standalone: true,
|
|
5921
|
+
providers: [
|
|
5922
|
+
{
|
|
5923
|
+
provide: NG_VALUE_ACCESSOR,
|
|
5924
|
+
useExisting: forwardRef(() => NgxMaskDirective),
|
|
5925
|
+
multi: true,
|
|
5926
|
+
},
|
|
5927
|
+
{
|
|
5928
|
+
provide: NG_VALIDATORS,
|
|
5929
|
+
useExisting: forwardRef(() => NgxMaskDirective),
|
|
5930
|
+
multi: true,
|
|
5931
|
+
},
|
|
5932
|
+
NgxMaskService,
|
|
5933
|
+
],
|
|
5934
|
+
exportAs: 'mask,ngxMask',
|
|
5935
|
+
}]
|
|
5936
|
+
}], propDecorators: { onPaste: [{
|
|
5937
|
+
type: HostListener,
|
|
5938
|
+
args: ['paste']
|
|
5939
|
+
}], onFocus: [{
|
|
5940
|
+
type: HostListener,
|
|
5941
|
+
args: ['focus', ['$event']]
|
|
5942
|
+
}], onModelChange: [{
|
|
5943
|
+
type: HostListener,
|
|
5944
|
+
args: ['ngModelChange', ['$event']]
|
|
5945
|
+
}], onInput: [{
|
|
5946
|
+
type: HostListener,
|
|
5947
|
+
args: ['input', ['$event']]
|
|
5948
|
+
}], onCompositionStart: [{
|
|
5949
|
+
type: HostListener,
|
|
5950
|
+
args: ['compositionstart', ['$event']]
|
|
5951
|
+
}], onCompositionEnd: [{
|
|
5952
|
+
type: HostListener,
|
|
5953
|
+
args: ['compositionend', ['$event']]
|
|
5954
|
+
}], onBlur: [{
|
|
5955
|
+
type: HostListener,
|
|
5956
|
+
args: ['blur', ['$event']]
|
|
5957
|
+
}], onClick: [{
|
|
5958
|
+
type: HostListener,
|
|
5959
|
+
args: ['click', ['$event']]
|
|
5960
|
+
}], onKeyDown: [{
|
|
5961
|
+
type: HostListener,
|
|
5962
|
+
args: ['keydown', ['$event']]
|
|
5963
|
+
}] } });
|
|
5964
|
+
|
|
5965
|
+
/**
|
|
5966
|
+
* Componente MatchaInputPhone
|
|
5967
|
+
*
|
|
5968
|
+
* Componente Angular para entrada de telefone internacional com seleção de país, máscara dinâmica e exibição de bandeira.
|
|
5969
|
+
*
|
|
5970
|
+
* Funcionalidades:
|
|
5971
|
+
* - Seleção de país com dropdown e bandeira.
|
|
5972
|
+
* - Máscara dinâmica de acordo com o país e DDD digitado.
|
|
5973
|
+
* - Suporte a diferentes formatos de telefone (fixo/celular) para o Brasil.
|
|
5974
|
+
* - Emissão de evento ao alterar o valor do telefone.
|
|
5975
|
+
* - Inicialização automática pelo valor informado ou pelo idioma do navegador.
|
|
5976
|
+
*
|
|
5977
|
+
* Inputs:
|
|
5978
|
+
* - fallbackMask: string - Máscara padrão caso não seja encontrada uma específica.
|
|
5979
|
+
* - label: string - Rótulo do campo (padrão: 'Telefone').
|
|
5980
|
+
* - value: string - Valor inicial do telefone (com ou sem DDI).
|
|
5981
|
+
*
|
|
5982
|
+
* Outputs:
|
|
5983
|
+
* - onChange: EventEmitter<string> - Emite o valor do telefone completo (com DDI) ao alterar.
|
|
5984
|
+
*
|
|
5985
|
+
* ViewChild:
|
|
5986
|
+
* - inputSelector: ElementRef - Referência ao container do input (usado para fechar o dropdown).
|
|
5987
|
+
* - phoneRef: ElementRef - Referência ao input do telefone.
|
|
5988
|
+
*
|
|
5989
|
+
* Métodos principais:
|
|
5990
|
+
* - ngOnInit: Inicializa o componente pelo valor ou idioma.
|
|
5991
|
+
* - ngOnChanges: Atualiza o valor ao receber novo input externo.
|
|
5992
|
+
* - initCountryPhone: Inicializa país e máscara pelo valor do telefone.
|
|
5993
|
+
* - selectMaskForDialCode: Seleciona a máscara conforme país e DDD.
|
|
5994
|
+
* - selectCountry: Troca o país selecionado e atualiza máscara.
|
|
5995
|
+
* - onInput: Atualiza máscara e emite evento ao digitar.
|
|
5996
|
+
* - toggleDropdown: Abre/fecha o dropdown de países.
|
|
5997
|
+
*/
|
|
5998
|
+
class MatchaInputPhoneComponent {
|
|
5999
|
+
constructor(renderer, cdr) {
|
|
6000
|
+
this.renderer = renderer;
|
|
6001
|
+
this.cdr = cdr;
|
|
6002
|
+
this.fallbackMask = '00 0000 0000';
|
|
6003
|
+
this.onChange = new EventEmitter();
|
|
6004
|
+
this.typeMask = '';
|
|
6005
|
+
this.labelHover = 'su';
|
|
6006
|
+
this.allCountries = getCountryISO2();
|
|
6007
|
+
this.isOpen = false;
|
|
6008
|
+
this.inputValueModel = '';
|
|
6009
|
+
this.clickListener = null;
|
|
6010
|
+
this.isInitialized = false;
|
|
6011
|
+
}
|
|
6012
|
+
ngOnInit() {
|
|
6013
|
+
this.value ? this.initCountryPhone(this.value) : this.initCountrylanguageNavigator();
|
|
6014
|
+
this.cdr.detectChanges();
|
|
6015
|
+
this.isInitialized = true;
|
|
6016
|
+
}
|
|
6017
|
+
ngOnChanges(changes) {
|
|
6018
|
+
if (changes['value'] && !changes['value'].firstChange) {
|
|
6019
|
+
this.value = changes['value'].currentValue;
|
|
6020
|
+
if (!this.value) {
|
|
6021
|
+
this.inputValueModel = this.value ?? '';
|
|
6022
|
+
return;
|
|
6023
|
+
}
|
|
6024
|
+
this.initCountryPhone(this.value);
|
|
6025
|
+
this.cdr.detectChanges();
|
|
6026
|
+
}
|
|
6027
|
+
}
|
|
6028
|
+
initCountryPhone(phone) {
|
|
6029
|
+
if (!phone.startsWith('+')) {
|
|
6030
|
+
this.setCountryAndInputValue('br', phone);
|
|
6031
|
+
return;
|
|
6032
|
+
}
|
|
6033
|
+
const phoneWithoutPlus = phone.replace('+', '');
|
|
6034
|
+
const countryDialCode = this.selectedCountry?.dialCode;
|
|
6035
|
+
if (phoneWithoutPlus.startsWith(countryDialCode)) {
|
|
6036
|
+
this.setCountryAndInputValue(this.selectedCountry.iso2, phoneWithoutPlus.replace(countryDialCode, ''));
|
|
6037
|
+
this.inputValueModel = phoneWithoutPlus.replace(countryDialCode, '');
|
|
6038
|
+
}
|
|
6039
|
+
else {
|
|
6040
|
+
this.matchCountryAndSetInputValue(phoneWithoutPlus);
|
|
6041
|
+
}
|
|
6042
|
+
}
|
|
6043
|
+
setCountryAndInputValue(iso2, phone) {
|
|
6044
|
+
this.selectedCountry = this.allCountries.find((country) => country.iso2 === iso2);
|
|
6045
|
+
this.inputValueModel = phone.startsWith('0') ? phone.slice(1) : phone;
|
|
6046
|
+
this.selectMaskForDialCode(this.selectedCountry.areaCodes ? this.selectedCountry.areaCodes[0] : '000', this.inputValueModel);
|
|
6047
|
+
}
|
|
6048
|
+
matchCountryAndSetInputValue(phoneWithoutPlus) {
|
|
6049
|
+
const matchingCountry = this.getMatchingCountry(phoneWithoutPlus);
|
|
6050
|
+
if (matchingCountry.length === 1) {
|
|
6051
|
+
this.setCountryAndInputValue(matchingCountry[0].iso2, phoneWithoutPlus.replace(matchingCountry[0].dialCode, ''));
|
|
6052
|
+
}
|
|
6053
|
+
else {
|
|
6054
|
+
this.matchAreaCodeAndSetInputValue(phoneWithoutPlus, matchingCountry);
|
|
6055
|
+
}
|
|
6056
|
+
}
|
|
6057
|
+
getMatchingCountry(phoneWithoutPlus) {
|
|
6058
|
+
return this.allCountries.filter((country) => {
|
|
6059
|
+
const dialCode = country.dialCode;
|
|
6060
|
+
return phoneWithoutPlus.startsWith(dialCode);
|
|
6061
|
+
});
|
|
6062
|
+
}
|
|
6063
|
+
matchAreaCodeAndSetInputValue(phoneWithoutPlus, matchingCountry) {
|
|
6064
|
+
const phoneWithoutDialCode = phoneWithoutPlus.replace(matchingCountry[0].dialCode, '');
|
|
6065
|
+
const filterAreaCode = phoneWithoutDialCode.substring(0, 3);
|
|
6066
|
+
const matchingAreaCode = matchingCountry.filter((country) => {
|
|
6067
|
+
if (country.areaCodes) {
|
|
6068
|
+
return country.areaCodes.includes(filterAreaCode);
|
|
6069
|
+
}
|
|
6070
|
+
});
|
|
6071
|
+
if (matchingAreaCode.length === 1) {
|
|
6072
|
+
this.setCountryAndInputValue(matchingAreaCode[0].iso2, phoneWithoutDialCode);
|
|
6073
|
+
}
|
|
6074
|
+
else {
|
|
6075
|
+
const defaultCountry = matchingCountry.find((country) => country.priority === 0);
|
|
6076
|
+
this.setCountryAndInputValue(defaultCountry.iso2, phoneWithoutDialCode);
|
|
6077
|
+
}
|
|
6078
|
+
}
|
|
6079
|
+
selectMaskForDialCode(inputDigits, targetValuePhone) {
|
|
6080
|
+
const previousMask = this.typeMask;
|
|
6081
|
+
const maskArray = this.selectedCountry?.mask;
|
|
6082
|
+
const maskIndex = this.selectedCountry?.areaCodes
|
|
6083
|
+
? this.selectedCountry.areaCodes.findIndex((code) => inputDigits === code)
|
|
6084
|
+
: -1;
|
|
6085
|
+
if (this.selectedCountry?.iso2 === 'br' && (targetValuePhone && targetValuePhone.length > 2)) {
|
|
6086
|
+
const eventInput = targetValuePhone.substring(2);
|
|
6087
|
+
if (eventInput && eventInput[0] === '9') {
|
|
6088
|
+
this.typeMask = "00 0 0000 0000";
|
|
6089
|
+
this.cdr.detectChanges();
|
|
6090
|
+
return;
|
|
6091
|
+
}
|
|
6092
|
+
}
|
|
6093
|
+
if (Array.isArray(maskArray)) {
|
|
6094
|
+
if (maskIndex !== -1 && maskArray[maskIndex]) {
|
|
6095
|
+
this.typeMask = maskArray[maskIndex];
|
|
6096
|
+
}
|
|
6097
|
+
else if (maskArray[0]) {
|
|
6098
|
+
this.typeMask = maskArray[0];
|
|
6099
|
+
}
|
|
6100
|
+
else {
|
|
6101
|
+
this.typeMask = this.fallbackMask;
|
|
6102
|
+
}
|
|
6103
|
+
}
|
|
6104
|
+
else {
|
|
6105
|
+
this.typeMask = this.fallbackMask;
|
|
6106
|
+
}
|
|
6107
|
+
if (previousMask !== this.typeMask)
|
|
6108
|
+
this.inputValueModel = '';
|
|
6109
|
+
this.cdr.detectChanges();
|
|
6110
|
+
}
|
|
6111
|
+
initCountrylanguageNavigator() {
|
|
6112
|
+
let lang = navigator.language;
|
|
6113
|
+
if (lang.includes('-')) {
|
|
6114
|
+
const langParts = lang.split('-');
|
|
6115
|
+
lang = langParts[1];
|
|
6116
|
+
}
|
|
6117
|
+
this.selectedCountry = this.allCountries.find((country) => country.iso2 === lang.toLocaleLowerCase());
|
|
6118
|
+
this.selectMaskForDialCode(this.selectedCountry.areaCodes ? this.selectedCountry.areaCodes[0] : '000');
|
|
6119
|
+
}
|
|
6120
|
+
selectCountry(country) {
|
|
6121
|
+
this.selectedCountry = country;
|
|
6122
|
+
this.selectMaskForDialCode(this.selectedCountry.areaCodes ? this.selectedCountry.areaCodes[0] : '000');
|
|
6123
|
+
this.isOpen = false;
|
|
6124
|
+
this.onChange.emit('+' + this.selectedCountry.dialCode + this.inputValueModel);
|
|
6125
|
+
this.removeClickListener();
|
|
6126
|
+
this.cdr.detectChanges();
|
|
6127
|
+
}
|
|
6128
|
+
toggleDropdown() {
|
|
6129
|
+
this.isOpen = !this.isOpen;
|
|
6130
|
+
this.clickListener = this.renderer.listen('window', 'click', (event) => {
|
|
6131
|
+
if (this.isOpen && !this.inputSelector.nativeElement.contains(event.target)) {
|
|
6132
|
+
this.isOpen = false;
|
|
6133
|
+
this.removeClickListener();
|
|
6134
|
+
}
|
|
6135
|
+
});
|
|
6136
|
+
this.cdr.detectChanges();
|
|
6137
|
+
}
|
|
6138
|
+
removeClickListener() {
|
|
6139
|
+
if (this.clickListener) {
|
|
6140
|
+
this.clickListener();
|
|
6141
|
+
this.clickListener = null;
|
|
6142
|
+
}
|
|
6143
|
+
}
|
|
6144
|
+
onInput(event) {
|
|
6145
|
+
this.phoneRef.nativeElement.value = event.target.value.replace(/[^\d\s]/g, '');
|
|
6146
|
+
let targetValuePhone = event.target.value.replace(/\D/g, '');
|
|
6147
|
+
this.onChange.emit('+' + this.selectedCountry.dialCode + this.inputValueModel);
|
|
6148
|
+
const inputDigits = targetValuePhone.substring(0, 3);
|
|
6149
|
+
if (inputDigits) {
|
|
6150
|
+
this.selectMaskForDialCode(inputDigits, targetValuePhone);
|
|
6151
|
+
}
|
|
6152
|
+
this.cdr.detectChanges();
|
|
6153
|
+
}
|
|
6154
|
+
ngOnDestroy() {
|
|
6155
|
+
this.removeClickListener();
|
|
6156
|
+
}
|
|
6157
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: MatchaInputPhoneComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
6158
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.8", type: MatchaInputPhoneComponent, isStandalone: false, selector: "matcha-input-phone", inputs: { fallbackMask: "fallbackMask", value: "value" }, outputs: { onChange: "onChange" }, viewQueries: [{ propertyName: "inputSelector", first: true, predicate: ["inputSelector"], descendants: true }, { propertyName: "phoneRef", first: true, predicate: ["phoneRef"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "\n<div class=\"flex-row position-relative px-16 gap-8\" #inputSelector>\n <div class=\"min-h-24 radius-8 cursor-pointer d-flex gap-8 flex-align-center fs-16\" (click)=\"toggleDropdown()\">\n <div class=\"d-flex-row flex-align-center\">\n <img alt=\"\" [src]=\"'https://flagcdn.com/16x12/'+ selectedCountry?.iso2?.toLowerCase() + '.png'\"\n height=\"16\">\n </div>\n <span class=\"w-16 fs-16\"\n [ngClass]=\"isOpen ? 'i-matcha-action_arrow_up': 'i-matcha-action_arrow_down'\"></span>\n\n </div>\n <input *ngIf=\"isInitialized\" #phoneRef type=\"text\" placeholder=\"{{ typeMask }}\"\n [(ngModel)]=\"inputValueModel\"\n pattern=\"[0-9]*\" (keyup)=\"onInput($event)\" [mask]=\"typeMask\">\n\n <ng-container *ngIf=\"isOpen\">\n <div class=\"position-absolute z-index-10\">\n <div class=\"grid-1 gap-16 radius-8 z-index-10 p-8 w-300 position-absolute background-surface elevation-z-1\"\n style=\"top: calc(100% + 10px); overflow: hidden; height: 300px; overflow-y: auto;\">\n\n <label *ngFor=\"let country of allCountries; let i = index\"\n class=\"fs-16 lh-18 cursor-pointer d-flex-align-center p-8 ts-300-l\"\n [ngClass]=\"labelHover === i+'bg' ? 'background-bg' : 'background-surface'\"\n (mouseover)=\"labelHover = i+'bg'\" (mouseout)=\"labelHover = i+'su'\"\n (click)=\"selectCountry(country)\">\n <img alt=\"\" class=\"mr-8\"\n [src]=\"'https://flagcdn.com/16x12/'+ country?.iso2?.toLowerCase() + '.png'\" height=\"16\">\n {{country.name}}\n </label>\n </div>\n </div>\n </ng-container>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: NgxMaskDirective, selector: "input[mask], textarea[mask]", inputs: ["mask", "specialCharacters", "patterns", "prefix", "suffix", "thousandSeparator", "decimalMarker", "dropSpecialCharacters", "hiddenInput", "showMaskTyped", "placeHolderCharacter", "shownMaskExpression", "clearIfNotMatch", "validation", "separatorLimit", "allowNegativeNumbers", "leadZeroDateTime", "leadZero", "triggerOnMaskChange", "apm", "inputTransformFn", "outputTransformFn", "keepCharacterPositions", "instantPrefix"], outputs: ["maskFilled"], exportAs: ["mask", "ngxMask"] }] }); }
|
|
6159
|
+
}
|
|
6160
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: MatchaInputPhoneComponent, decorators: [{
|
|
6161
|
+
type: Component,
|
|
6162
|
+
args: [{ selector: 'matcha-input-phone', standalone: false, template: "\n<div class=\"flex-row position-relative px-16 gap-8\" #inputSelector>\n <div class=\"min-h-24 radius-8 cursor-pointer d-flex gap-8 flex-align-center fs-16\" (click)=\"toggleDropdown()\">\n <div class=\"d-flex-row flex-align-center\">\n <img alt=\"\" [src]=\"'https://flagcdn.com/16x12/'+ selectedCountry?.iso2?.toLowerCase() + '.png'\"\n height=\"16\">\n </div>\n <span class=\"w-16 fs-16\"\n [ngClass]=\"isOpen ? 'i-matcha-action_arrow_up': 'i-matcha-action_arrow_down'\"></span>\n\n </div>\n <input *ngIf=\"isInitialized\" #phoneRef type=\"text\" placeholder=\"{{ typeMask }}\"\n [(ngModel)]=\"inputValueModel\"\n pattern=\"[0-9]*\" (keyup)=\"onInput($event)\" [mask]=\"typeMask\">\n\n <ng-container *ngIf=\"isOpen\">\n <div class=\"position-absolute z-index-10\">\n <div class=\"grid-1 gap-16 radius-8 z-index-10 p-8 w-300 position-absolute background-surface elevation-z-1\"\n style=\"top: calc(100% + 10px); overflow: hidden; height: 300px; overflow-y: auto;\">\n\n <label *ngFor=\"let country of allCountries; let i = index\"\n class=\"fs-16 lh-18 cursor-pointer d-flex-align-center p-8 ts-300-l\"\n [ngClass]=\"labelHover === i+'bg' ? 'background-bg' : 'background-surface'\"\n (mouseover)=\"labelHover = i+'bg'\" (mouseout)=\"labelHover = i+'su'\"\n (click)=\"selectCountry(country)\">\n <img alt=\"\" class=\"mr-8\"\n [src]=\"'https://flagcdn.com/16x12/'+ country?.iso2?.toLowerCase() + '.png'\" height=\"16\">\n {{country.name}}\n </label>\n </div>\n </div>\n </ng-container>\n</div>\n" }]
|
|
6163
|
+
}], ctorParameters: () => [{ type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }], propDecorators: { inputSelector: [{
|
|
6164
|
+
type: ViewChild,
|
|
6165
|
+
args: ['inputSelector']
|
|
6166
|
+
}], phoneRef: [{
|
|
6167
|
+
type: ViewChild,
|
|
6168
|
+
args: ['phoneRef']
|
|
6169
|
+
}], fallbackMask: [{
|
|
6170
|
+
type: Input,
|
|
6171
|
+
args: ['fallbackMask']
|
|
6172
|
+
}], value: [{
|
|
6173
|
+
type: Input,
|
|
6174
|
+
args: ['value']
|
|
6175
|
+
}], onChange: [{
|
|
6176
|
+
type: Output
|
|
6177
|
+
}] } });
|
|
6178
|
+
|
|
2154
6179
|
class MatchaTooltipDirective {
|
|
2155
6180
|
constructor(el, renderer) {
|
|
2156
6181
|
this.el = el;
|
|
@@ -3582,6 +7607,190 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
3582
7607
|
}]
|
|
3583
7608
|
}] });
|
|
3584
7609
|
|
|
7610
|
+
class NgxMaskPipe {
|
|
7611
|
+
constructor() {
|
|
7612
|
+
this.defaultOptions = inject(NGX_MASK_CONFIG);
|
|
7613
|
+
this._maskService = inject(NgxMaskService);
|
|
7614
|
+
this._maskExpressionArray = [];
|
|
7615
|
+
this.mask = '';
|
|
7616
|
+
}
|
|
7617
|
+
transform(value, mask, { patterns, ...config } = {}) {
|
|
7618
|
+
let processedValue = value;
|
|
7619
|
+
const currentConfig = {
|
|
7620
|
+
maskExpression: mask,
|
|
7621
|
+
...this.defaultOptions,
|
|
7622
|
+
...config,
|
|
7623
|
+
patterns: {
|
|
7624
|
+
...this._maskService.patterns,
|
|
7625
|
+
...patterns,
|
|
7626
|
+
},
|
|
7627
|
+
};
|
|
7628
|
+
Object.entries(currentConfig).forEach(([key, val]) => {
|
|
7629
|
+
this._maskService[key] = val;
|
|
7630
|
+
});
|
|
7631
|
+
if (mask.includes('||')) {
|
|
7632
|
+
const maskParts = mask.split('||');
|
|
7633
|
+
if (maskParts.length > 1) {
|
|
7634
|
+
this._maskExpressionArray = maskParts.sort((a, b) => a.length - b.length);
|
|
7635
|
+
this._setMask(`${processedValue}`);
|
|
7636
|
+
return this._maskService.applyMask(`${processedValue}`, this.mask);
|
|
7637
|
+
}
|
|
7638
|
+
else {
|
|
7639
|
+
this._maskExpressionArray = [];
|
|
7640
|
+
return this._maskService.applyMask(`${processedValue}`, this.mask);
|
|
7641
|
+
}
|
|
7642
|
+
}
|
|
7643
|
+
if (mask.includes("{" /* MaskExpression.CURLY_BRACKETS_LEFT */)) {
|
|
7644
|
+
return this._maskService.applyMask(`${processedValue}`, this._maskService._repeatPatternSymbols(mask));
|
|
7645
|
+
}
|
|
7646
|
+
if (mask.startsWith("separator" /* MaskExpression.SEPARATOR */)) {
|
|
7647
|
+
if (config.decimalMarker) {
|
|
7648
|
+
this._maskService.decimalMarker = config.decimalMarker;
|
|
7649
|
+
}
|
|
7650
|
+
if (config.thousandSeparator) {
|
|
7651
|
+
this._maskService.thousandSeparator = config.thousandSeparator;
|
|
7652
|
+
}
|
|
7653
|
+
if (config.leadZero) {
|
|
7654
|
+
this._maskService.leadZero = config.leadZero;
|
|
7655
|
+
}
|
|
7656
|
+
processedValue = String(processedValue);
|
|
7657
|
+
const localeDecimalMarker = this._maskService.currentLocaleDecimalMarker();
|
|
7658
|
+
if (!Array.isArray(this._maskService.decimalMarker)) {
|
|
7659
|
+
processedValue =
|
|
7660
|
+
this._maskService.decimalMarker !== localeDecimalMarker
|
|
7661
|
+
? processedValue.replace(localeDecimalMarker, this._maskService.decimalMarker)
|
|
7662
|
+
: processedValue;
|
|
7663
|
+
}
|
|
7664
|
+
if (this._maskService.leadZero &&
|
|
7665
|
+
processedValue &&
|
|
7666
|
+
this._maskService.dropSpecialCharacters !== false) {
|
|
7667
|
+
processedValue = this._maskService._checkPrecision(mask, processedValue);
|
|
7668
|
+
}
|
|
7669
|
+
if (this._maskService.decimalMarker === "," /* MaskExpression.COMMA */) {
|
|
7670
|
+
processedValue = processedValue.replace("." /* MaskExpression.DOT */, "," /* MaskExpression.COMMA */);
|
|
7671
|
+
}
|
|
7672
|
+
this._maskService.isNumberValue = true;
|
|
7673
|
+
}
|
|
7674
|
+
if (processedValue === null || typeof processedValue === 'undefined') {
|
|
7675
|
+
return this._maskService.applyMask('', mask);
|
|
7676
|
+
}
|
|
7677
|
+
return this._maskService.applyMask(`${processedValue}`, mask);
|
|
7678
|
+
}
|
|
7679
|
+
_setMask(value) {
|
|
7680
|
+
if (this._maskExpressionArray.length > 0) {
|
|
7681
|
+
this._maskExpressionArray.some((mask) => {
|
|
7682
|
+
const test = this._maskService.removeMask(value)?.length <=
|
|
7683
|
+
this._maskService.removeMask(mask)?.length;
|
|
7684
|
+
if (value && test) {
|
|
7685
|
+
this.mask = mask;
|
|
7686
|
+
return test;
|
|
7687
|
+
}
|
|
7688
|
+
else {
|
|
7689
|
+
this.mask =
|
|
7690
|
+
this._maskExpressionArray[this._maskExpressionArray.length - 1] ??
|
|
7691
|
+
"" /* MaskExpression.EMPTY_STRING */;
|
|
7692
|
+
}
|
|
7693
|
+
});
|
|
7694
|
+
}
|
|
7695
|
+
}
|
|
7696
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgxMaskPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
7697
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.8", ngImport: i0, type: NgxMaskPipe, isStandalone: true, name: "mask" }); }
|
|
7698
|
+
}
|
|
7699
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgxMaskPipe, decorators: [{
|
|
7700
|
+
type: Pipe,
|
|
7701
|
+
args: [{
|
|
7702
|
+
name: 'mask',
|
|
7703
|
+
pure: true,
|
|
7704
|
+
standalone: true,
|
|
7705
|
+
}]
|
|
7706
|
+
}] });
|
|
7707
|
+
|
|
7708
|
+
const options = {
|
|
7709
|
+
specialCharacters: ['/', '(', ')', '.', ':', '-', ' ', '+', ',', '@', '[', ']', '"', "'", '*'],
|
|
7710
|
+
patterns: {
|
|
7711
|
+
'0': { pattern: /\d/ },
|
|
7712
|
+
'9': { pattern: /\d/, optional: true },
|
|
7713
|
+
'A': { pattern: /[a-zA-Z0-9]/ },
|
|
7714
|
+
'S': { pattern: /[a-zA-Z]/ }
|
|
7715
|
+
},
|
|
7716
|
+
prefix: '',
|
|
7717
|
+
suffix: '',
|
|
7718
|
+
thousandSeparator: '',
|
|
7719
|
+
decimalMarker: '.',
|
|
7720
|
+
clearIfNotMatch: false,
|
|
7721
|
+
showMaskTyped: false,
|
|
7722
|
+
placeHolderCharacter: '_',
|
|
7723
|
+
shownMaskExpression: '',
|
|
7724
|
+
dropSpecialCharacters: true,
|
|
7725
|
+
hiddenInput: false,
|
|
7726
|
+
validation: true,
|
|
7727
|
+
instantPrefix: false,
|
|
7728
|
+
separatorLimit: '',
|
|
7729
|
+
apm: false,
|
|
7730
|
+
allowNegativeNumbers: false,
|
|
7731
|
+
leadZeroDateTime: false,
|
|
7732
|
+
leadZero: false,
|
|
7733
|
+
triggerOnMaskChange: false,
|
|
7734
|
+
keepCharacterPositions: false,
|
|
7735
|
+
inputTransformFn: (v) => v,
|
|
7736
|
+
outputTransformFn: (v) => v,
|
|
7737
|
+
maskFilled: { emit: () => { } } // mock para EventEmitter
|
|
7738
|
+
};
|
|
7739
|
+
class NgxMaskModule {
|
|
7740
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgxMaskModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
7741
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.8", ngImport: i0, type: NgxMaskModule, imports: [CommonModule,
|
|
7742
|
+
NgxMaskDirective,
|
|
7743
|
+
NgxMaskPipe], exports: [NgxMaskDirective,
|
|
7744
|
+
NgxMaskPipe] }); }
|
|
7745
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgxMaskModule, providers: [
|
|
7746
|
+
NgxMaskService,
|
|
7747
|
+
{ provide: NGX_MASK_CONFIG, useValue: options }
|
|
7748
|
+
], imports: [CommonModule] }); }
|
|
7749
|
+
}
|
|
7750
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgxMaskModule, decorators: [{
|
|
7751
|
+
type: NgModule,
|
|
7752
|
+
args: [{
|
|
7753
|
+
imports: [
|
|
7754
|
+
CommonModule,
|
|
7755
|
+
NgxMaskDirective,
|
|
7756
|
+
NgxMaskPipe
|
|
7757
|
+
],
|
|
7758
|
+
exports: [
|
|
7759
|
+
NgxMaskDirective,
|
|
7760
|
+
NgxMaskPipe
|
|
7761
|
+
],
|
|
7762
|
+
providers: [
|
|
7763
|
+
NgxMaskService,
|
|
7764
|
+
{ provide: NGX_MASK_CONFIG, useValue: options }
|
|
7765
|
+
]
|
|
7766
|
+
}]
|
|
7767
|
+
}] });
|
|
7768
|
+
|
|
7769
|
+
class MatchaInputPhoneModule {
|
|
7770
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: MatchaInputPhoneModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
7771
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.8", ngImport: i0, type: MatchaInputPhoneModule, declarations: [MatchaInputPhoneComponent], imports: [CommonModule,
|
|
7772
|
+
MatchaFormFieldModule,
|
|
7773
|
+
FormsModule,
|
|
7774
|
+
NgxMaskModule], exports: [MatchaInputPhoneComponent] }); }
|
|
7775
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: MatchaInputPhoneModule, imports: [CommonModule,
|
|
7776
|
+
MatchaFormFieldModule,
|
|
7777
|
+
FormsModule,
|
|
7778
|
+
NgxMaskModule] }); }
|
|
7779
|
+
}
|
|
7780
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: MatchaInputPhoneModule, decorators: [{
|
|
7781
|
+
type: NgModule,
|
|
7782
|
+
args: [{
|
|
7783
|
+
declarations: [MatchaInputPhoneComponent],
|
|
7784
|
+
imports: [
|
|
7785
|
+
CommonModule,
|
|
7786
|
+
MatchaFormFieldModule,
|
|
7787
|
+
FormsModule,
|
|
7788
|
+
NgxMaskModule
|
|
7789
|
+
],
|
|
7790
|
+
exports: [MatchaInputPhoneComponent]
|
|
7791
|
+
}]
|
|
7792
|
+
}] });
|
|
7793
|
+
|
|
3585
7794
|
class MatchaComponentsModule {
|
|
3586
7795
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: MatchaComponentsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
3587
7796
|
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.8", ngImport: i0, type: MatchaComponentsModule, declarations: [MatchaOverflowDraggableComponent], imports: [CommonModule,
|
|
@@ -3603,6 +7812,7 @@ class MatchaComponentsModule {
|
|
|
3603
7812
|
MatchaIconModule,
|
|
3604
7813
|
MatchaInfiniteScrollModule,
|
|
3605
7814
|
MatchaInputModule,
|
|
7815
|
+
MatchaInputPhoneModule,
|
|
3606
7816
|
MatchaMasonryModule,
|
|
3607
7817
|
MatchaMenuModule,
|
|
3608
7818
|
MatchaModalModule,
|
|
@@ -3638,6 +7848,7 @@ class MatchaComponentsModule {
|
|
|
3638
7848
|
MatchaIconModule,
|
|
3639
7849
|
MatchaInfiniteScrollModule,
|
|
3640
7850
|
MatchaInputModule,
|
|
7851
|
+
MatchaInputPhoneModule,
|
|
3641
7852
|
MatchaMasonryModule,
|
|
3642
7853
|
MatchaMenuModule,
|
|
3643
7854
|
MatchaModalModule,
|
|
@@ -3677,6 +7888,7 @@ class MatchaComponentsModule {
|
|
|
3677
7888
|
MatchaIconModule,
|
|
3678
7889
|
MatchaInfiniteScrollModule,
|
|
3679
7890
|
MatchaInputModule,
|
|
7891
|
+
MatchaInputPhoneModule,
|
|
3680
7892
|
MatchaMasonryModule,
|
|
3681
7893
|
MatchaMenuModule,
|
|
3682
7894
|
MatchaModalModule,
|
|
@@ -3712,6 +7924,7 @@ class MatchaComponentsModule {
|
|
|
3712
7924
|
MatchaIconModule,
|
|
3713
7925
|
MatchaInfiniteScrollModule,
|
|
3714
7926
|
MatchaInputModule,
|
|
7927
|
+
MatchaInputPhoneModule,
|
|
3715
7928
|
MatchaMasonryModule,
|
|
3716
7929
|
MatchaMenuModule,
|
|
3717
7930
|
MatchaModalModule,
|
|
@@ -3757,6 +7970,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
3757
7970
|
MatchaIconModule,
|
|
3758
7971
|
MatchaInfiniteScrollModule,
|
|
3759
7972
|
MatchaInputModule,
|
|
7973
|
+
MatchaInputPhoneModule,
|
|
3760
7974
|
MatchaMasonryModule,
|
|
3761
7975
|
MatchaMenuModule,
|
|
3762
7976
|
MatchaModalModule,
|
|
@@ -3794,6 +8008,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
3794
8008
|
MatchaIconModule,
|
|
3795
8009
|
MatchaInfiniteScrollModule,
|
|
3796
8010
|
MatchaInputModule,
|
|
8011
|
+
MatchaInputPhoneModule,
|
|
3797
8012
|
MatchaMasonryModule,
|
|
3798
8013
|
MatchaMenuModule,
|
|
3799
8014
|
MatchaModalModule,
|
|
@@ -3837,5 +8052,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
3837
8052
|
* Generated bundle index. Do not edit.
|
|
3838
8053
|
*/
|
|
3839
8054
|
|
|
3840
|
-
export { MatchaAccordionComponent, MatchaAccordionContentComponent, MatchaAccordionHeaderComponent, MatchaAccordionItemComponent, MatchaAccordionModule, MatchaBadgeDirective, MatchaBadgeModule, MatchaButtonComponent, MatchaButtonModule, MatchaButtonToggleComponent, MatchaButtonToggleModule, MatchaCardComponent, MatchaCardModule, MatchaCheckboxComponent, MatchaCheckboxModule, MatchaChipsDirective, MatchaChipsModule, MatchaComponentsModule, MatchaDatepickerDirective, MatchaDatepickerModule, MatchaDividerComponent, MatchaDividerModule, MatchaElevationDirective, MatchaElevationModule, MatchaErrorComponent, MatchaFormFieldComponent, MatchaFormFieldModule, MatchaGridComponent, MatchaGridModule, MatchaHintTextComponent, MatchaHintTextModule, MatchaIconComponent, MatchaIconModule, MatchaInfiniteScrollComponent, MatchaInfiniteScrollDataComponent, MatchaInfiniteScrollModule, MatchaInputDirective, MatchaInputModule, MatchaLabelComponent, MatchaMasonryComponent, MatchaMasonryModule, MatchaMenuComponent, MatchaMenuModule, MatchaMenuTriggerForDirective, MatchaModalComponent, MatchaModalContentComponent, MatchaModalFooterComponent, MatchaModalHeaderComponent, MatchaModalModule, MatchaModalOptionsComponent, MatchaModalService, MatchaOverlayService, MatchaPaginatorDirective, MatchaPaginatorModule, MatchaProgressBarDirective, MatchaProgressBarModule, MatchaRadioButtonDirective, MatchaRadioButtonModule, MatchaRippleDirective, MatchaRippleModule, MatchaSelectDirective, MatchaSelectModule, MatchaSidenavDirective, MatchaSidenavModule, MatchaSlideToggleComponent, MatchaSlideToggleModule, MatchaSliderDirective, MatchaSliderModule, MatchaSnackBarDirective, MatchaSnackBarModule, MatchaSortHeaderDirective, MatchaSortHeaderModule, MatchaSpinComponent, MatchaSpinModule, MatchaTabItemComponent, MatchaTableDirective, MatchaTableModule, MatchaTabsComponent, MatchaTabsModule, MatchaTitleComponent, MatchaTitleModule, MatchaToolbarButtonComponent, MatchaToolbarComponent, MatchaToolbarContentComponent, MatchaToolbarCustomButtonComponent, MatchaToolbarMainButtonComponent, MatchaToolbarModule, MatchaTooltipDirective, MatchaTooltipModule, MatchaTreeDirective, MatchaTreeModule };
|
|
8055
|
+
export { MatchaAccordionComponent, MatchaAccordionContentComponent, MatchaAccordionHeaderComponent, MatchaAccordionItemComponent, MatchaAccordionModule, MatchaBadgeDirective, MatchaBadgeModule, MatchaButtonComponent, MatchaButtonModule, MatchaButtonToggleComponent, MatchaButtonToggleModule, MatchaCardComponent, MatchaCardModule, MatchaCheckboxComponent, MatchaCheckboxModule, MatchaChipsDirective, MatchaChipsModule, MatchaComponentsModule, MatchaDatepickerDirective, MatchaDatepickerModule, MatchaDividerComponent, MatchaDividerModule, MatchaElevationDirective, MatchaElevationModule, MatchaErrorComponent, MatchaFormFieldComponent, MatchaFormFieldModule, MatchaGridComponent, MatchaGridModule, MatchaHintTextComponent, MatchaHintTextModule, MatchaIconComponent, MatchaIconModule, MatchaInfiniteScrollComponent, MatchaInfiniteScrollDataComponent, MatchaInfiniteScrollModule, MatchaInputDirective, MatchaInputModule, MatchaInputPhoneComponent, MatchaInputPhoneModule, MatchaLabelComponent, MatchaMasonryComponent, MatchaMasonryModule, MatchaMenuComponent, MatchaMenuModule, MatchaMenuTriggerForDirective, MatchaModalComponent, MatchaModalContentComponent, MatchaModalFooterComponent, MatchaModalHeaderComponent, MatchaModalModule, MatchaModalOptionsComponent, MatchaModalService, MatchaOverlayService, MatchaPaginatorDirective, MatchaPaginatorModule, MatchaProgressBarDirective, MatchaProgressBarModule, MatchaRadioButtonDirective, MatchaRadioButtonModule, MatchaRippleDirective, MatchaRippleModule, MatchaSelectDirective, MatchaSelectModule, MatchaSidenavDirective, MatchaSidenavModule, MatchaSlideToggleComponent, MatchaSlideToggleModule, MatchaSliderDirective, MatchaSliderModule, MatchaSnackBarDirective, MatchaSnackBarModule, MatchaSortHeaderDirective, MatchaSortHeaderModule, MatchaSpinComponent, MatchaSpinModule, MatchaTabItemComponent, MatchaTableDirective, MatchaTableModule, MatchaTabsComponent, MatchaTabsModule, MatchaTitleComponent, MatchaTitleModule, MatchaToolbarButtonComponent, MatchaToolbarComponent, MatchaToolbarContentComponent, MatchaToolbarCustomButtonComponent, MatchaToolbarMainButtonComponent, MatchaToolbarModule, MatchaTooltipDirective, MatchaTooltipModule, MatchaTreeDirective, MatchaTreeModule };
|
|
3841
8056
|
//# sourceMappingURL=matcha-components.mjs.map
|