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