@rpcbase/ui 0.207.0 → 0.209.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/dist/index.js +13 -13
- package/dist/index100.js +3 -3
- package/dist/index100.js.map +1 -1
- package/dist/index101.js +9 -3
- package/dist/index101.js.map +1 -1
- package/dist/index102.js +4 -9
- package/dist/index102.js.map +1 -1
- package/dist/index103.js +9 -4
- package/dist/index103.js.map +1 -1
- package/dist/index104.js +18 -12
- package/dist/index104.js.map +1 -1
- package/dist/index105.js +25 -18
- package/dist/index105.js.map +1 -1
- package/dist/index106.js +5 -24
- package/dist/index106.js.map +1 -1
- package/dist/index107.js +2 -2
- package/dist/index107.js.map +1 -1
- package/dist/index108.js +4 -3
- package/dist/index108.js.map +1 -1
- package/dist/index109.js +3 -3
- package/dist/index109.js.map +1 -1
- package/dist/index110.js +3 -4
- package/dist/index110.js.map +1 -1
- package/dist/index111.js +3 -3
- package/dist/index111.js.map +1 -1
- package/dist/index112.js +8 -5
- package/dist/index112.js.map +1 -1
- package/dist/index113.js +7 -8
- package/dist/index113.js.map +1 -1
- package/dist/index114.js +34 -7
- package/dist/index114.js.map +1 -1
- package/dist/index115.js +7 -34
- package/dist/index115.js.map +1 -1
- package/dist/index116.js +5 -7
- package/dist/index116.js.map +1 -1
- package/dist/index117.js +7 -5
- package/dist/index117.js.map +1 -1
- package/dist/index118.js +9 -7
- package/dist/index118.js.map +1 -1
- package/dist/index119.js +3 -7
- package/dist/index119.js.map +1 -1
- package/dist/index120.js +4 -3
- package/dist/index120.js.map +1 -1
- package/dist/index121.js +3 -4
- package/dist/index121.js.map +1 -1
- package/dist/index122.js +3 -3
- package/dist/index122.js.map +1 -1
- package/dist/index123.js +4 -3
- package/dist/index123.js.map +1 -1
- package/dist/index124.js +3 -4
- package/dist/index124.js.map +1 -1
- package/dist/index125.js +3 -3
- package/dist/index125.js.map +1 -1
- package/dist/index126.js +7 -5
- package/dist/index126.js.map +1 -1
- package/dist/index127.js +57 -8
- package/dist/index127.js.map +1 -1
- package/dist/index128.js +7 -57
- package/dist/index128.js.map +1 -1
- package/dist/index129.js +19 -6
- package/dist/index129.js.map +1 -1
- package/dist/index130.js +19 -19
- package/dist/index130.js.map +1 -1
- package/dist/index131.js +34 -19
- package/dist/index131.js.map +1 -1
- package/dist/index132.js +5 -34
- package/dist/index132.js.map +1 -1
- package/dist/index133.js +8 -5
- package/dist/index133.js.map +1 -1
- package/dist/index134.js +13 -7
- package/dist/index134.js.map +1 -1
- package/dist/index135.js +10 -14
- package/dist/index135.js.map +1 -1
- package/dist/index136.js +6 -10
- package/dist/index136.js.map +1 -1
- package/dist/index137.js +4 -5
- package/dist/index137.js.map +1 -1
- package/dist/index138.js +5 -5
- package/dist/index138.js.map +1 -1
- package/dist/index139.js +5 -5
- package/dist/index139.js.map +1 -1
- package/dist/index140.js +5 -5
- package/dist/index140.js.map +1 -1
- package/dist/index141.js +4 -5
- package/dist/index141.js.map +1 -1
- package/dist/index142.js +6 -4
- package/dist/index142.js.map +1 -1
- package/dist/index143.js +21 -7
- package/dist/index143.js.map +1 -1
- package/dist/index144.js +9 -21
- package/dist/index144.js.map +1 -1
- package/dist/index145.js +7 -8
- package/dist/index145.js.map +1 -1
- package/dist/index146.js +5 -6
- package/dist/index146.js.map +1 -1
- package/dist/index147.js +6 -6
- package/dist/index147.js.map +1 -1
- package/dist/index148.js +4 -6
- package/dist/index148.js.map +1 -1
- package/dist/index149.js +4 -4
- package/dist/index149.js.map +1 -1
- package/dist/index150.js +5 -4
- package/dist/index150.js.map +1 -1
- package/dist/index151.js +4 -5
- package/dist/index151.js.map +1 -1
- package/dist/index152.js +5 -4
- package/dist/index152.js.map +1 -1
- package/dist/index153.js +4 -5
- package/dist/index153.js.map +1 -1
- package/dist/index154.js +4 -4
- package/dist/index154.js.map +1 -1
- package/dist/index155.js +3 -3
- package/dist/index155.js.map +1 -1
- package/dist/index156.js +29 -5
- package/dist/index156.js.map +1 -1
- package/dist/index157.js +33 -29
- package/dist/index157.js.map +1 -1
- package/dist/index158.js +15 -32
- package/dist/index158.js.map +1 -1
- package/dist/index159.js +10 -14
- package/dist/index159.js.map +1 -1
- package/dist/index160.js +9 -11
- package/dist/index160.js.map +1 -1
- package/dist/index161.js +16 -9
- package/dist/index161.js.map +1 -1
- package/dist/index162.js +86 -16
- package/dist/index162.js.map +1 -1
- package/dist/index163.js +47 -86
- package/dist/index163.js.map +1 -1
- package/dist/index164.js +16 -46
- package/dist/index164.js.map +1 -1
- package/dist/index165.js +8 -17
- package/dist/index165.js.map +1 -1
- package/dist/index166.js +10 -8
- package/dist/index166.js.map +1 -1
- package/dist/index167.js +4 -9
- package/dist/index167.js.map +1 -1
- package/dist/index168.js +22 -5
- package/dist/index168.js.map +1 -1
- package/dist/index169.js +7 -22
- package/dist/index169.js.map +1 -1
- package/dist/index170.js +6 -7
- package/dist/index170.js.map +1 -1
- package/dist/index171.js +4 -4
- package/dist/index171.js.map +1 -1
- package/dist/index172.js +4 -6
- package/dist/index172.js.map +1 -1
- package/dist/index173.js +6 -4
- package/dist/index173.js.map +1 -1
- package/dist/index174.js +67 -6
- package/dist/index174.js.map +1 -1
- package/dist/index175.js +17 -67
- package/dist/index175.js.map +1 -1
- package/dist/index176.js +12 -17
- package/dist/index176.js.map +1 -1
- package/dist/index177.js +9 -12
- package/dist/index177.js.map +1 -1
- package/dist/index178.js +20 -9
- package/dist/index178.js.map +1 -1
- package/dist/index179.js +14 -17
- package/dist/index179.js.map +1 -1
- package/dist/index180.js +54 -16
- package/dist/index180.js.map +1 -1
- package/dist/index181.js +9 -54
- package/dist/index181.js.map +1 -1
- package/dist/index182.js +6 -10
- package/dist/index182.js.map +1 -1
- package/dist/index183.js +26 -6
- package/dist/index183.js.map +1 -1
- package/dist/index184.js +26 -26
- package/dist/index184.js.map +1 -1
- package/dist/index185.js +10 -23
- package/dist/index185.js.map +1 -1
- package/dist/index186.js +13 -13
- package/dist/index186.js.map +1 -1
- package/dist/index187.js +6 -13
- package/dist/index187.js.map +1 -1
- package/dist/index188.js +23 -6
- package/dist/index188.js.map +1 -1
- package/dist/index189.js +385 -23
- package/dist/index189.js.map +1 -1
- package/dist/index19.js +1 -1
- package/dist/index19.js.map +1 -1
- package/dist/index190.js +487 -377
- package/dist/index190.js.map +1 -1
- package/dist/index191.js +122 -487
- package/dist/index191.js.map +1 -1
- package/dist/index192.js +53 -131
- package/dist/index192.js.map +1 -1
- package/dist/index193.js +76 -51
- package/dist/index193.js.map +1 -1
- package/dist/index194.js +897 -75
- package/dist/index194.js.map +1 -1
- package/dist/index195.js +19 -899
- package/dist/index195.js.map +1 -1
- package/dist/index196.js +446 -17
- package/dist/index196.js.map +1 -1
- package/dist/index197.js +4 -448
- package/dist/index197.js.map +1 -1
- package/dist/index198.js +57 -4
- package/dist/index198.js.map +1 -1
- package/dist/index199.js +56 -52
- package/dist/index199.js.map +1 -1
- package/dist/index200.js +5 -5
- package/dist/index213.js +1 -1
- package/dist/index215.js +58 -40
- package/dist/index215.js.map +1 -1
- package/dist/index216.js +43 -9
- package/dist/index216.js.map +1 -1
- package/dist/index217.js +10 -25
- package/dist/index217.js.map +1 -1
- package/dist/index218.js +25 -45
- package/dist/index218.js.map +1 -1
- package/dist/index219.js +44 -17
- package/dist/index219.js.map +1 -1
- package/dist/index220.js +18 -3
- package/dist/index220.js.map +1 -1
- package/dist/index221.js +3 -5
- package/dist/index221.js.map +1 -1
- package/dist/index222.js +4 -20
- package/dist/index222.js.map +1 -1
- package/dist/index223.js +20 -24
- package/dist/index223.js.map +1 -1
- package/dist/index224.js +23 -66
- package/dist/index224.js.map +1 -1
- package/dist/index225.js +67 -14
- package/dist/index225.js.map +1 -1
- package/dist/index226.js +15 -4
- package/dist/index226.js.map +1 -1
- package/dist/index227.js +4 -51
- package/dist/index227.js.map +1 -1
- package/dist/index228.js +50 -5
- package/dist/index228.js.map +1 -1
- package/dist/index229.js +5 -26
- package/dist/index229.js.map +1 -1
- package/dist/index230.js +24 -11
- package/dist/index230.js.map +1 -1
- package/dist/index231.js +12 -8
- package/dist/index231.js.map +1 -1
- package/dist/index232.js +13 -3
- package/dist/index232.js.map +1 -0
- package/dist/index233.js +3 -29
- package/dist/index234.js +25 -68
- package/dist/index234.js.map +1 -1
- package/dist/index235.js +71 -2
- package/dist/index235.js.map +1 -0
- package/dist/index236.js +3 -15
- package/dist/index237.js +12 -51
- package/dist/index237.js.map +1 -1
- package/dist/index238.js +50 -114
- package/dist/index238.js.map +1 -1
- package/dist/index239.js +115 -6
- package/dist/index239.js.map +1 -1
- package/dist/index24.js +9 -0
- package/dist/index24.js.map +1 -1
- package/dist/index240.js +6 -13
- package/dist/index240.js.map +1 -1
- package/dist/index241.js +13 -687
- package/dist/index241.js.map +1 -1
- package/dist/index242.js +668 -234
- package/dist/index242.js.map +1 -1
- package/dist/index243.js +222 -670
- package/dist/index243.js.map +1 -1
- package/dist/index244.js +700 -7430
- package/dist/index244.js.map +1 -1
- package/dist/index245.js +7431 -7
- package/dist/index245.js.map +1 -1
- package/dist/index246.js +6 -12
- package/dist/index246.js.map +1 -1
- package/dist/index247.js +12 -5
- package/dist/index247.js.map +1 -1
- package/dist/index248.js +5 -459
- package/dist/index248.js.map +1 -1
- package/dist/index249.js +454 -32
- package/dist/index249.js.map +1 -1
- package/dist/index25.js +20 -8
- package/dist/index25.js.map +1 -1
- package/dist/index250.js +36 -18
- package/dist/index250.js.map +1 -1
- package/dist/index251.js +17 -25
- package/dist/index251.js.map +1 -1
- package/dist/index252.js +27 -4
- package/dist/index252.js.map +1 -1
- package/dist/index253.js +4 -58
- package/dist/index253.js.map +1 -1
- package/dist/index254.js +58 -7
- package/dist/index254.js.map +1 -1
- package/dist/index255.js +7 -12
- package/dist/index255.js.map +1 -1
- package/dist/index256.js +13 -3
- package/dist/index256.js.map +1 -1
- package/dist/index257.js +3 -17
- package/dist/index257.js.map +1 -1
- package/dist/index258.js +14 -23
- package/dist/index258.js.map +1 -1
- package/dist/index259.js +23 -41
- package/dist/index259.js.map +1 -1
- package/dist/index26.js +56 -18
- package/dist/index26.js.map +1 -1
- package/dist/index260.js +43 -13
- package/dist/index260.js.map +1 -1
- package/dist/index261.js +13 -25
- package/dist/index261.js.map +1 -1
- package/dist/index262.js +24 -16
- package/dist/index262.js.map +1 -1
- package/dist/index263.js +15 -33
- package/dist/index263.js.map +1 -1
- package/dist/index264.js +35 -5
- package/dist/index264.js.map +1 -1
- package/dist/index265.js +5 -9
- package/dist/index265.js.map +1 -1
- package/dist/index266.js +8 -7
- package/dist/index266.js.map +1 -1
- package/dist/index267.js +8 -9
- package/dist/index267.js.map +1 -1
- package/dist/index268.js +9 -10
- package/dist/index268.js.map +1 -1
- package/dist/index269.js +10 -7
- package/dist/index269.js.map +1 -1
- package/dist/index27.js +50 -53
- package/dist/index27.js.map +1 -1
- package/dist/index270.js +7 -73
- package/dist/index270.js.map +1 -1
- package/dist/index271.js +63 -161
- package/dist/index271.js.map +1 -1
- package/dist/index272.js +157 -100
- package/dist/index272.js.map +1 -1
- package/dist/index273.js +113 -13
- package/dist/index273.js.map +1 -1
- package/dist/index274.js +12 -78
- package/dist/index274.js.map +1 -1
- package/dist/index275.js +57 -23
- package/dist/index275.js.map +1 -1
- package/dist/index276.js +45 -12
- package/dist/index276.js.map +1 -1
- package/dist/index277.js +13 -16
- package/dist/index277.js.map +1 -1
- package/dist/index278.js +15 -98
- package/dist/index278.js.map +1 -1
- package/dist/index279.js +93 -50
- package/dist/index279.js.map +1 -1
- package/dist/index28.js +1 -59
- package/dist/index280.js +5 -57
- package/dist/index280.js.map +1 -1
- package/dist/index281.js +78 -41
- package/dist/index281.js.map +1 -1
- package/dist/index282.js +58 -100
- package/dist/index282.js.map +1 -1
- package/dist/index283.js +104 -46
- package/dist/index283.js.map +1 -1
- package/dist/index284.js +51 -39
- package/dist/index284.js.map +1 -1
- package/dist/index285.js +42 -141
- package/dist/index285.js.map +1 -1
- package/dist/index286.js +122 -119
- package/dist/index286.js.map +1 -1
- package/dist/index287.js +107 -222
- package/dist/index287.js.map +1 -1
- package/dist/index288.js +173 -159
- package/dist/index288.js.map +1 -1
- package/dist/index289.js +119 -177
- package/dist/index289.js.map +1 -1
- package/dist/index29.js +4 -0
- package/dist/index290.js +298 -5
- package/dist/index290.js.map +1 -1
- package/dist/index291.js +5 -6
- package/dist/index291.js.map +1 -1
- package/dist/index292.js +6 -7
- package/dist/index292.js.map +1 -1
- package/dist/index293.js +6 -5
- package/dist/index293.js.map +1 -1
- package/dist/index294.js +4 -4
- package/dist/index294.js.map +1 -1
- package/dist/index295.js +6 -21
- package/dist/index295.js.map +1 -1
- package/dist/index296.js +21 -10
- package/dist/index296.js.map +1 -1
- package/dist/index297.js +10 -126
- package/dist/index297.js.map +1 -1
- package/dist/index298.js +108 -146
- package/dist/index298.js.map +1 -1
- package/dist/index299.js +151 -55
- package/dist/index299.js.map +1 -1
- package/dist/index30.js +8 -6
- package/dist/index30.js.map +1 -0
- package/dist/index300.js +66 -107
- package/dist/index300.js.map +1 -1
- package/dist/index301.js +107 -489
- package/dist/index301.js.map +1 -1
- package/dist/index302.js +492 -63
- package/dist/index302.js.map +1 -1
- package/dist/index303.js +63 -4
- package/dist/index303.js.map +1 -1
- package/dist/index304.js +4 -28
- package/dist/index304.js.map +1 -1
- package/dist/index305.js +27 -65
- package/dist/index305.js.map +1 -1
- package/dist/index306.js +60 -147
- package/dist/index306.js.map +1 -1
- package/dist/index307.js +137 -546
- package/dist/index307.js.map +1 -1
- package/dist/index308.js +60 -209
- package/dist/index308.js.map +1 -1
- package/dist/index309.js +551 -321
- package/dist/index309.js.map +1 -1
- package/dist/index31.js +6 -5
- package/dist/index31.js.map +1 -1
- package/dist/index310.js +206 -264
- package/dist/index310.js.map +1 -1
- package/dist/index311.js +335 -0
- package/dist/index311.js.map +1 -0
- package/dist/index312.js +272 -0
- package/dist/index312.js.map +1 -0
- package/dist/index32.js +3 -3
- package/dist/index32.js.map +1 -1
- package/dist/index33.js +7 -5
- package/dist/index33.js.map +1 -1
- package/dist/index34.js +7 -4
- package/dist/index34.js.map +1 -1
- package/dist/index35.js +5 -10
- package/dist/index35.js.map +1 -1
- package/dist/index36.js +7 -5
- package/dist/index36.js.map +1 -1
- package/dist/index37.js +8 -7
- package/dist/index37.js.map +1 -1
- package/dist/index38.js +12 -8
- package/dist/index38.js.map +1 -1
- package/dist/index39.js +5 -11
- package/dist/index39.js.map +1 -1
- package/dist/index40.js +6 -6
- package/dist/index40.js.map +1 -1
- package/dist/index41.js +5 -5
- package/dist/index41.js.map +1 -1
- package/dist/index42.js +9 -6
- package/dist/index42.js.map +1 -1
- package/dist/index43.js +8 -9
- package/dist/index43.js.map +1 -1
- package/dist/index44.js +5 -8
- package/dist/index44.js.map +1 -1
- package/dist/index45.js +2 -2
- package/dist/index45.js.map +1 -1
- package/dist/index46.js +11 -5
- package/dist/index46.js.map +1 -1
- package/dist/index47.js +4 -4
- package/dist/index47.js.map +1 -1
- package/dist/index48.js +6 -10
- package/dist/index48.js.map +1 -1
- package/dist/index49.js +4 -7
- package/dist/index49.js.map +1 -1
- package/dist/index50.js +6 -4
- package/dist/index50.js.map +1 -1
- package/dist/index51.js +6 -6
- package/dist/index51.js.map +1 -1
- package/dist/index52.js +5 -5
- package/dist/index52.js.map +1 -1
- package/dist/index53.js +8 -5
- package/dist/index53.js.map +1 -1
- package/dist/index54.js +13 -9
- package/dist/index54.js.map +1 -1
- package/dist/index55.js +5 -12
- package/dist/index55.js.map +1 -1
- package/dist/index56.js +4 -4
- package/dist/index56.js.map +1 -1
- package/dist/index57.js +4 -4
- package/dist/index57.js.map +1 -1
- package/dist/index58.js +13 -6
- package/dist/index58.js.map +1 -1
- package/dist/index59.js +4 -10
- package/dist/index59.js.map +1 -1
- package/dist/index60.js +8 -7
- package/dist/index60.js.map +1 -1
- package/dist/index61.js +68 -9
- package/dist/index61.js.map +1 -1
- package/dist/index62.js +8 -68
- package/dist/index62.js.map +1 -1
- package/dist/index63.js +31 -8
- package/dist/index63.js.map +1 -1
- package/dist/index64.js +10 -31
- package/dist/index64.js.map +1 -1
- package/dist/index65.js +16 -10
- package/dist/index65.js.map +1 -1
- package/dist/index66.js +200 -15
- package/dist/index66.js.map +1 -1
- package/dist/index67.js +21 -201
- package/dist/index67.js.map +1 -1
- package/dist/index68.js +12 -16
- package/dist/index68.js.map +1 -1
- package/dist/index69.js +123 -17
- package/dist/index69.js.map +1 -1
- package/dist/index70.js +18 -122
- package/dist/index70.js.map +1 -1
- package/dist/index71.js +9 -19
- package/dist/index71.js.map +1 -1
- package/dist/index72.js +9 -8
- package/dist/index72.js.map +1 -1
- package/dist/index73.js +11 -7
- package/dist/index73.js.map +1 -1
- package/dist/index74.js +7 -11
- package/dist/index74.js.map +1 -1
- package/dist/index75.js +6 -6
- package/dist/index75.js.map +1 -1
- package/dist/index76.js +4 -9
- package/dist/index76.js.map +1 -1
- package/dist/index77.js +42 -5
- package/dist/index77.js.map +1 -1
- package/dist/index78.js +368 -29
- package/dist/index78.js.map +1 -1
- package/dist/index79.js +37 -379
- package/dist/index79.js.map +1 -1
- package/dist/index80.js +22 -39
- package/dist/index80.js.map +1 -1
- package/dist/index81.js +56 -20
- package/dist/index81.js.map +1 -1
- package/dist/index82.js +7 -57
- package/dist/index82.js.map +1 -1
- package/dist/index83.js +4 -6
- package/dist/index83.js.map +1 -1
- package/dist/index84.js +3 -3
- package/dist/index84.js.map +1 -1
- package/dist/index85.js +3 -3
- package/dist/index85.js.map +1 -1
- package/dist/index86.js +3 -3
- package/dist/index86.js.map +1 -1
- package/dist/index87.js +5 -4
- package/dist/index87.js.map +1 -1
- package/dist/index88.js +3 -3
- package/dist/index88.js.map +1 -1
- package/dist/index89.js +10 -6
- package/dist/index89.js.map +1 -1
- package/dist/index90.js +7 -10
- package/dist/index90.js.map +1 -1
- package/dist/index91.js +6 -7
- package/dist/index91.js.map +1 -1
- package/dist/index92.js +5 -6
- package/dist/index92.js.map +1 -1
- package/dist/index93.js +7 -5
- package/dist/index93.js.map +1 -1
- package/dist/index94.js +48 -8
- package/dist/index94.js.map +1 -1
- package/dist/index95.js +104 -46
- package/dist/index95.js.map +1 -1
- package/dist/index96.js +8 -103
- package/dist/index96.js.map +1 -1
- package/dist/index97.js +5 -9
- package/dist/index97.js.map +1 -1
- package/dist/index98.js +3 -3
- package/dist/index98.js.map +1 -1
- package/dist/index99.js +6 -7
- package/dist/index99.js.map +1 -1
- package/package.json +3 -3
- package/dist/index233.js.map +0 -1
- package/dist/index236.js.map +0 -1
- package/dist/index28.js.map +0 -1
package/dist/index299.js
CHANGED
|
@@ -1,72 +1,168 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { validatePhoneNumberLength as e } from "./index292.js";
|
|
2
|
+
import { AsYouType as t } from "./index293.js";
|
|
3
|
+
import { getCountryCallingCode as n } from "./index295.js";
|
|
4
|
+
import { COMMON_IDD_PREFIXES as r, COUNTRY_DIAL_CODES as i, MAX_DIAL_CODE_LENGTH as a } from "./index298.js";
|
|
5
|
+
//#region src/components/PhoneNumberInput/normalization.ts
|
|
6
|
+
function o(e) {
|
|
7
|
+
return e.replace(/\D/g, "");
|
|
6
8
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
for (let n = 0; n < i; n += 1) e(t[n] ?? "") && (r += 1);
|
|
10
|
-
return r;
|
|
9
|
+
function s(e) {
|
|
10
|
+
return e ? e.length > a ? !1 : i.some((t) => t.startsWith(e)) : !0;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
for (let i = 0; i < t.length; i += 1) if (e(t[i] ?? "") && (r += 1, r === n)) return i + 1;
|
|
16
|
-
return t.length;
|
|
12
|
+
var c = /[\u061C\u200B-\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g;
|
|
13
|
+
function l(e) {
|
|
14
|
+
return e.replace(c, "");
|
|
17
15
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
16
|
+
function u(e, t, n = {}) {
|
|
17
|
+
let { force: r = !1 } = n, i = `+${t}`;
|
|
18
|
+
if (!e.startsWith(i) || !r) return e;
|
|
19
|
+
let a = e.slice(i.length).trimStart();
|
|
20
|
+
if (a.startsWith("0")) return e;
|
|
21
|
+
if (!a) return `${i} 0`;
|
|
22
|
+
let [o, ...s] = a.split(" ");
|
|
23
|
+
return `${i} ${`0${o ?? ""}`}${s.length > 0 ? ` ${s.join(" ")}` : ""}`.replace(/\s\s+/g, " ").trimEnd();
|
|
20
24
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
var d = {
|
|
26
|
+
GG: "GB",
|
|
27
|
+
JE: "GB",
|
|
28
|
+
IM: "GB"
|
|
29
|
+
};
|
|
30
|
+
function f(e) {
|
|
31
|
+
if (e) return d[e] ?? e;
|
|
25
32
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return
|
|
33
|
+
function p(e, t, n) {
|
|
34
|
+
if (!e || !n || (e.nationalNumber ?? "").length < 4) return;
|
|
35
|
+
let r = e.countryCallingCode;
|
|
36
|
+
if (!r) return;
|
|
37
|
+
let i = e.getMetadata, a = (typeof i == "function" ? i() : null)?.country_calling_codes?.[r];
|
|
38
|
+
if (!a || a.length === 0) return;
|
|
39
|
+
let o = [];
|
|
40
|
+
for (let e of a) {
|
|
41
|
+
let t = f(e);
|
|
42
|
+
t && !o.includes(t) && o.push(t);
|
|
43
|
+
}
|
|
44
|
+
if (o.length !== 0) return t && o.includes(t) ? t : o.includes("US") ? "US" : o[0];
|
|
30
45
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
46
|
+
function m(e, t, n, r) {
|
|
47
|
+
return e ? r ? !n || !e.startsWith(n) || !e.slice(n.length).startsWith("0") ? !1 : e.slice(n.length + 1) === (t.startsWith(n) ? t.slice(n.length) : t) : e.startsWith("0") : !1;
|
|
48
|
+
}
|
|
49
|
+
function h(e) {
|
|
50
|
+
for (let t of r) if (e.startsWith(t)) return e.slice(t.length);
|
|
51
|
+
return e;
|
|
52
|
+
}
|
|
53
|
+
function g(e, t, r = {}) {
|
|
54
|
+
let { allowJustPlus: i = !1, removeNationalPrefix: s = !0, previousValue: c } = r, u = l(e).trim();
|
|
55
|
+
if (!u) return "";
|
|
56
|
+
if (u === "+") return i ? "+" : "";
|
|
57
|
+
if (u.startsWith("+")) {
|
|
58
|
+
let e = o(u);
|
|
59
|
+
if (!e) return i ? "+" : "";
|
|
60
|
+
let r = h(e);
|
|
61
|
+
if (r !== e) return r ? `+${r}` : i ? "+" : "";
|
|
62
|
+
if (s && t) {
|
|
63
|
+
let r = n(t);
|
|
64
|
+
if (e.startsWith(r) && e.slice(r.length).startsWith("0")) {
|
|
65
|
+
let t = e.slice(r.length + 1);
|
|
66
|
+
return t ? `+${r}${t}` : `+${r}`;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return `+${e}`;
|
|
70
|
+
}
|
|
71
|
+
let d = o(u);
|
|
72
|
+
if (!d) return "";
|
|
73
|
+
let f = h(d);
|
|
74
|
+
if (f !== d) return f ? `+${f}` : i ? "+" : "";
|
|
75
|
+
let p = typeof c == "string" ? c : "", m = p && p.startsWith("+") ? o(p) : "";
|
|
76
|
+
if (m && m.length > d.length && m.endsWith(d) && m.length - d.length <= a) return `+${d}`;
|
|
77
|
+
if (d === "0") return "0";
|
|
78
|
+
if (s && t && d.length > 1 && d.startsWith("0") && !d.startsWith("00")) {
|
|
79
|
+
let e = n(t), r = d.slice(1);
|
|
80
|
+
return r ? `+${e}${r}` : `+${e}`;
|
|
81
|
+
}
|
|
82
|
+
return t ? d.length <= 4 ? `+${d}` : `+${n(t)}${d}` : d;
|
|
83
|
+
}
|
|
84
|
+
function _(e, n) {
|
|
85
|
+
if (e === "+") return {
|
|
86
|
+
international: "+",
|
|
87
|
+
national: "",
|
|
88
|
+
formatted: "+",
|
|
89
|
+
phoneNumber: null,
|
|
90
|
+
detectedCountry: void 0,
|
|
91
|
+
inferredCountry: void 0,
|
|
92
|
+
hasExplicitInternationalPrefix: !0
|
|
93
|
+
};
|
|
94
|
+
let r = /^\s*\+/.test(e), i = n ? new t(n) : new t(), a = i.input(e), s = i.getNumber(), c = o(e), l = f(s?.country ?? i.country ?? void 0), u = l ?? !s ? void 0 : f(p(s, n, c)), d = s?.formatInternational() ?? a;
|
|
33
95
|
return {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
wasAtEnd: i === n.length
|
|
96
|
+
international: d,
|
|
97
|
+
national: s?.formatNational() ?? o(d),
|
|
98
|
+
formatted: a,
|
|
99
|
+
phoneNumber: s,
|
|
100
|
+
detectedCountry: l,
|
|
101
|
+
inferredCountry: u,
|
|
102
|
+
hasExplicitInternationalPrefix: r
|
|
42
103
|
};
|
|
43
104
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
105
|
+
function v(e, t) {
|
|
106
|
+
return e.startsWith(t) ? e.slice(t.length) : e;
|
|
107
|
+
}
|
|
108
|
+
function y(t, n) {
|
|
109
|
+
if (!n || !t) return null;
|
|
110
|
+
try {
|
|
111
|
+
return e(t, n) === "TOO_LONG" ? "TOO_LONG" : null;
|
|
112
|
+
} catch {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function b(e, t, r, i = {}) {
|
|
117
|
+
let { hasRemovedNationalPrefix: a = !1, detectedCountry: c, hasExplicitInternationalPrefix: l = !1 } = i;
|
|
118
|
+
if (!e) return {
|
|
119
|
+
shouldSuggest: !1,
|
|
120
|
+
query: ""
|
|
121
|
+
};
|
|
122
|
+
if (e === "+") return {
|
|
123
|
+
shouldSuggest: !0,
|
|
124
|
+
query: ""
|
|
125
|
+
};
|
|
126
|
+
let u = o(e);
|
|
127
|
+
if (!u) return {
|
|
128
|
+
shouldSuggest: !0,
|
|
129
|
+
query: ""
|
|
130
|
+
};
|
|
131
|
+
if (a) return {
|
|
132
|
+
shouldSuggest: !1,
|
|
133
|
+
query: ""
|
|
134
|
+
};
|
|
135
|
+
if (l && !c) return s(u) ? {
|
|
136
|
+
shouldSuggest: !0,
|
|
137
|
+
query: u
|
|
138
|
+
} : {
|
|
139
|
+
shouldSuggest: !1,
|
|
140
|
+
query: ""
|
|
141
|
+
};
|
|
142
|
+
let d = r?.countryCallingCode ?? null;
|
|
143
|
+
if (!d) {
|
|
144
|
+
if (t) {
|
|
145
|
+
let e = n(t);
|
|
146
|
+
u.startsWith(e) && (d = e);
|
|
147
|
+
} else if (!l) return {
|
|
148
|
+
shouldSuggest: !1,
|
|
149
|
+
query: ""
|
|
56
150
|
};
|
|
57
151
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return s > c ? {
|
|
62
|
-
start: c,
|
|
63
|
-
end: c
|
|
152
|
+
return !d || v(u, d).length === 0 ? {
|
|
153
|
+
shouldSuggest: !0,
|
|
154
|
+
query: u
|
|
64
155
|
} : {
|
|
65
|
-
|
|
66
|
-
|
|
156
|
+
shouldSuggest: !1,
|
|
157
|
+
query: ""
|
|
67
158
|
};
|
|
68
159
|
}
|
|
160
|
+
function x(e, t) {
|
|
161
|
+
if (e.shouldSuggest) return !1;
|
|
162
|
+
let { hasExplicitInternationalPrefix: n = !1, detectedCountry: r } = t;
|
|
163
|
+
return n ? !!r : !0;
|
|
164
|
+
}
|
|
69
165
|
//#endregion
|
|
70
|
-
export {
|
|
166
|
+
export { m as detectNationalPrefixForDisplay, _ as formatWithAsYouType, y as getLengthIssue, b as getSuggestionState, u as injectNationalPrefixDisplay, g as normalizeInputValue, o as sanitizeDigits, x as shouldDisplayExplicitCountrySelection, v as stripPrefix };
|
|
71
167
|
|
|
72
168
|
//# sourceMappingURL=index299.js.map
|
package/dist/index299.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index299.js","names":["isDigitCharacter","char","code","charCodeAt","countDigitsBefore","value","index","count","limit","Math","min","length","position","findIndexForDigitCount","digitCount","startsWith","seen","isFormattingCharacter","skipFormattingCharactersLeft","next","skipFormattingCharactersRight","SelectionSnapshot","selectionStart","selectionEnd","startDigits","endDigits","preserveStartIndex","preserveEndIndex","wasAtStart","wasAtEnd","captureSelectionSnapshot","input","HTMLInputElement","resolveSelection","snapshot","end","start","resolvedStart","resolvedEnd","clampedStart","max","clampedEnd"],"sources":["../src/components/PhoneNumberInput/selection.ts"],"sourcesContent":["function isDigitCharacter(char: string) {\n if (!char) {\n return false\n }\n const code = char.charCodeAt(0)\n return code >= 48 && code <= 57\n}\n\nfunction countDigitsBefore(value: string, index: number) {\n let count = 0\n const limit = Math.min(index, value.length)\n for (let position = 0; position < limit; position += 1) {\n if (isDigitCharacter(value[position] ?? \"\")) {\n count += 1\n }\n }\n return count\n}\n\nfunction findIndexForDigitCount(value: string, digitCount: number) {\n if (digitCount <= 0) {\n return value.startsWith(\"+\") ? Math.min(1, value.length) : 0\n }\n\n let seen = 0\n for (let index = 0; index < value.length; index += 1) {\n if (isDigitCharacter(value[index] ?? \"\")) {\n seen += 1\n if (seen === digitCount) {\n return index + 1\n }\n }\n }\n\n return value.length\n}\n\nfunction isFormattingCharacter(char: string) {\n if (!char) {\n return false\n }\n if (isDigitCharacter(char)) {\n return false\n }\n return char !== \"+\"\n}\n\nexport function skipFormattingCharactersLeft(value: string, index: number) {\n let position = index\n while (position > 0) {\n const next = value[position - 1] ?? \"\"\n if (!isFormattingCharacter(next)) {\n break\n }\n position -= 1\n }\n return position\n}\n\nexport function skipFormattingCharactersRight(value: string, index: number) {\n let position = index\n while (position < value.length) {\n const next = value[position] ?? \"\"\n if (!isFormattingCharacter(next)) {\n break\n }\n position += 1\n }\n return position\n}\n\ntype SelectionSnapshot = {\n selectionStart: number\n selectionEnd: number\n startDigits: number\n endDigits: number\n preserveStartIndex: boolean\n preserveEndIndex: boolean\n wasAtStart: boolean\n wasAtEnd: boolean\n}\n\nexport function captureSelectionSnapshot(input: HTMLInputElement): SelectionSnapshot {\n const { value } = input\n const selectionStart = input.selectionStart ?? value.length\n const selectionEnd = input.selectionEnd ?? selectionStart\n const preserveStartIndex = selectionStart <= 1 && value.startsWith(\"+\")\n const preserveEndIndex = selectionEnd <= 1 && value.startsWith(\"+\")\n\n return {\n selectionStart,\n selectionEnd,\n startDigits: countDigitsBefore(value, selectionStart),\n endDigits: countDigitsBefore(value, selectionEnd),\n preserveStartIndex,\n preserveEndIndex,\n wasAtStart: selectionStart === 0,\n wasAtEnd: selectionEnd === value.length,\n }\n}\n\nexport function resolveSelection(snapshot: SelectionSnapshot, value: string) {\n if (snapshot.selectionStart === snapshot.selectionEnd) {\n if (snapshot.wasAtEnd) {\n const end = value.length\n return { start: end, end }\n }\n if (snapshot.wasAtStart) {\n return { start: 0, end: 0 }\n }\n }\n\n const start = snapshot.preserveStartIndex\n ? Math.min(snapshot.selectionStart, value.length)\n : findIndexForDigitCount(value, snapshot.startDigits)\n const end = snapshot.preserveEndIndex\n ? Math.min(snapshot.selectionEnd, value.length)\n : findIndexForDigitCount(value, snapshot.endDigits)\n\n let resolvedStart = start\n let resolvedEnd = end\n\n if (snapshot.wasAtStart) {\n resolvedStart = 0\n }\n\n if (snapshot.wasAtEnd) {\n resolvedEnd = value.length\n }\n\n if (snapshot.selectionStart === snapshot.selectionEnd) {\n resolvedStart = resolvedEnd\n }\n\n const clampedStart = Math.min(Math.max(resolvedStart, 0), value.length)\n const clampedEnd = Math.min(Math.max(resolvedEnd, 0), value.length)\n\n if (clampedStart > clampedEnd) {\n return { start: clampedEnd, end: clampedEnd }\n }\n\n return { start: clampedStart, end: clampedEnd }\n}\n\n"],"mappings":";AAAA,SAASA,EAAiBC,GAAc;AACtC,KAAI,CAACA,EACH,QAAO;CAET,IAAMC,IAAOD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,QAAO;EACLO;EACAC;EACAC,aAAapB,EAAkBC,GAAOiB,EAAe;EACrDG,WAAWrB,EAAkBC,GAAOkB,EAAa;EACjDG;EACAC;EACAC,YAAYN,MAAmB;EAC/BO,UAAUN,MAAiBlB,EAAMM;EAClC;;AAGH,SAAgBsB,EAAiBC,GAA6B7B,GAAe;AAC3E,KAAI6B,EAASZ,mBAAmBY,EAASX,cAAc;AACrD,MAAIW,EAASL,UAAU;GACrB,IAAMM,IAAM9B,EAAMM;AAClB,UAAO;IAAEyB,OAAOD;IAAKA;IAAK;;AAE5B,MAAID,EAASN,WACX,QAAO;GAAEQ,OAAO;GAAGD,KAAK;GAAG;;CAI/B,IAAMC,IAAQF,EAASR,qBACnBjB,KAAKC,IAAIwB,EAASZ,gBAAgBjB,EAAMM,OAAO,GAC/CE,EAAuBR,GAAO6B,EAASV,YAAY,EACjDW,IAAMD,EAASP,mBACjBlB,KAAKC,IAAIwB,EAASX,cAAclB,EAAMM,OAAO,GAC7CE,EAAuBR,GAAO6B,EAAST,UAAU,EAEjDY,IAAgBD,GAChBE,IAAcH;AAUlB,CARID,EAASN,eACXS,IAAgB,IAGdH,EAASL,aACXS,IAAcjC,EAAMM,SAGlBuB,EAASZ,mBAAmBY,EAASX,iBACvCc,IAAgBC;CAGlB,IAAMC,IAAe9B,KAAKC,IAAID,KAAK+B,IAAIH,GAAe,EAAE,EAAEhC,EAAMM,OAAO,EACjE8B,IAAahC,KAAKC,IAAID,KAAK+B,IAAIF,GAAa,EAAE,EAAEjC,EAAMM,OAAO;AAMnE,QAJI4B,IAAeE,IACV;EAAEL,OAAOK;EAAYN,KAAKM;EAAY,GAGxC;EAAEL,OAAOG;EAAcJ,KAAKM;EAAY"}
|
|
1
|
+
{"version":3,"file":"index299.js","names":["CountryCode","AsYouType","getCountryCallingCode","validatePhoneNumberLength","COMMON_IDD_PREFIXES","COUNTRY_DIAL_CODES","DEFAULT_COUNTRY","MAX_DIAL_CODE_LENGTH","LengthIssue","sanitizeDigits","value","replace","isDialCodeProgress","digits","length","some","dial","startsWith","INVISIBLE_FORMATTING_CHARACTERS","stripInvisibleFormatting","injectNationalPrefixDisplay","international","dialCode","options","force","prefix","remainder","slice","trimStart","alreadyHasTrunk","firstGroup","restGroups","split","rebuiltFirstGroup","rebuiltRemainder","join","trimEnd","DETECTED_COUNTRY_OVERRIDES","Partial","Record","GG","JE","IM","canonicalizeDetectedCountry","candidate","undefined","AsYouTypeNumber","ReturnType","inferCountryFromDialCode","phoneNumber","baseCountry","normalizedDigits","nationalDigits","nationalNumber","countryCallingCode","metadataGetter","getMetadata","metadata","country_calling_codes","candidates","canonicalCandidates","canonical","includes","push","detectNationalPrefixForDisplay","rawDigits","internationalDigits","hasExplicitInternationalPrefix","rawAfterTrunk","internationalAfterDial","stripIddPrefix","normalizeInputValue","rawValue","country","allowJustPlus","removeNationalPrefix","previousValue","cleaned","trimmed","trim","digitsWithoutIdd","withoutPrefix","digitsOnly","previousNormalized","previousDigits","endsWith","removedPrefixLength","formatWithAsYouType","national","formatted","detectedCountry","inferredCountry","test","formatter","input","getNumber","formatInternational","formatNational","stripPrefix","getLengthIssue","result","SuggestionState","shouldSuggest","query","getSuggestionState","normalized","hasRemovedNationalPrefix","baseDial","shouldDisplayExplicitCountrySelection","suggestion","Boolean"],"sources":["../src/components/PhoneNumberInput/normalization.ts"],"sourcesContent":["import type { CountryCode } from \"libphonenumber-js\"\nimport { AsYouType, getCountryCallingCode, validatePhoneNumberLength } from \"libphonenumber-js\"\n\nimport {\n COMMON_IDD_PREFIXES,\n COUNTRY_DIAL_CODES,\n DEFAULT_COUNTRY,\n MAX_DIAL_CODE_LENGTH,\n} from \"./country-options\"\n\n\nexport type LengthIssue = \"TOO_LONG\"\n\nexport function sanitizeDigits(value: string) {\n return value.replace(/\\D/g, \"\")\n}\n\nfunction isDialCodeProgress(digits: string) {\n if (!digits) {\n return true\n }\n\n if (digits.length > MAX_DIAL_CODE_LENGTH) {\n return false\n }\n\n return COUNTRY_DIAL_CODES.some((dial) => dial.startsWith(digits))\n}\n\nconst INVISIBLE_FORMATTING_CHARACTERS =\n /[\\u061C\\u200B-\\u200F\\u202A-\\u202E\\u2066-\\u2069\\uFEFF]/g\n\nfunction stripInvisibleFormatting(value: string) {\n return value.replace(INVISIBLE_FORMATTING_CHARACTERS, \"\")\n}\n\nexport function injectNationalPrefixDisplay(\n international: string,\n dialCode: string,\n options: { force?: boolean } = {}\n) {\n // Preserve a user-typed national trunk (e.g. the French \"0\") purely for display\n // so validation can continue to use the canonical E.164 representation internally.\n const { force = false } = options\n const prefix = `+${dialCode}`\n\n if (!international.startsWith(prefix)) {\n return international\n }\n\n if (!force) {\n return international\n }\n\n const remainder = international.slice(prefix.length).trimStart()\n const alreadyHasTrunk = remainder.startsWith(\"0\")\n\n if (alreadyHasTrunk) {\n return international\n }\n\n if (!remainder) {\n return `${prefix} 0`\n }\n\n const [firstGroup, ...restGroups] = remainder.split(\" \")\n const rebuiltFirstGroup = `0${firstGroup ?? \"\"}`\n const rebuiltRemainder = restGroups.length > 0 ? ` ${restGroups.join(\" \")}` : \"\"\n\n return `${prefix} ${rebuiltFirstGroup}${rebuiltRemainder}`.replace(/\\s\\s+/g, \" \").trimEnd()\n}\n\nconst DETECTED_COUNTRY_OVERRIDES: Partial<Record<CountryCode, CountryCode>> = {\n GG: \"GB\",\n JE: \"GB\",\n IM: \"GB\",\n}\n\nfunction canonicalizeDetectedCountry(candidate: CountryCode | undefined): CountryCode | undefined {\n if (!candidate) {\n return undefined\n }\n return DETECTED_COUNTRY_OVERRIDES[candidate] ?? candidate\n}\n\ntype AsYouTypeNumber = ReturnType<AsYouType[\"getNumber\"]>\n\nfunction inferCountryFromDialCode(\n phoneNumber: AsYouTypeNumber,\n baseCountry: CountryCode | undefined,\n normalizedDigits: string\n): CountryCode | undefined {\n if (!phoneNumber) {\n return undefined\n }\n\n if (!normalizedDigits) {\n return undefined\n }\n\n const nationalDigits = phoneNumber.nationalNumber ?? \"\"\n if (nationalDigits.length < 4) {\n return undefined\n }\n\n const dial = phoneNumber.countryCallingCode\n if (!dial) {\n return undefined\n }\n\n const metadataGetter = (phoneNumber as unknown as { getMetadata?: () => unknown }).getMetadata\n const metadata =\n typeof metadataGetter === \"function\"\n ? (metadataGetter() as {\n country_calling_codes?: Record<string, string[]>\n } | null)\n : null\n\n const candidates = metadata?.country_calling_codes?.[dial]\n if (!candidates || candidates.length === 0) {\n return undefined\n }\n\n const canonicalCandidates: CountryCode[] = []\n for (const candidate of candidates) {\n const canonical = canonicalizeDetectedCountry(candidate as CountryCode)\n if (canonical && !canonicalCandidates.includes(canonical)) {\n canonicalCandidates.push(canonical)\n }\n }\n\n if (canonicalCandidates.length === 0) {\n return undefined\n }\n\n if (baseCountry && canonicalCandidates.includes(baseCountry)) {\n return baseCountry\n }\n\n if (canonicalCandidates.includes(DEFAULT_COUNTRY)) {\n return DEFAULT_COUNTRY\n }\n\n return canonicalCandidates[0]\n}\n\nexport function detectNationalPrefixForDisplay(\n rawDigits: string,\n internationalDigits: string,\n dialCode: string,\n hasExplicitInternationalPrefix: boolean\n) {\n if (!rawDigits) {\n return false\n }\n\n if (!hasExplicitInternationalPrefix) {\n return rawDigits.startsWith(\"0\")\n }\n\n if (!dialCode) {\n return false\n }\n\n if (!rawDigits.startsWith(dialCode)) {\n return false\n }\n\n if (!rawDigits.slice(dialCode.length).startsWith(\"0\")) {\n return false\n }\n\n const rawAfterTrunk = rawDigits.slice(dialCode.length + 1)\n const internationalAfterDial = internationalDigits.startsWith(dialCode)\n ? internationalDigits.slice(dialCode.length)\n : internationalDigits\n\n return rawAfterTrunk === internationalAfterDial\n}\n\nfunction stripIddPrefix(digits: string) {\n for (const prefix of COMMON_IDD_PREFIXES) {\n if (digits.startsWith(prefix)) {\n return digits.slice(prefix.length)\n }\n }\n return digits\n}\n\nexport function normalizeInputValue(\n rawValue: string,\n country: CountryCode | undefined,\n options: {\n allowJustPlus?: boolean\n removeNationalPrefix?: boolean\n previousValue?: string\n } = {}\n) {\n const { allowJustPlus = false, removeNationalPrefix = true, previousValue } = options\n const cleaned = stripInvisibleFormatting(rawValue)\n const trimmed = cleaned.trim()\n\n if (!trimmed) {\n return \"\"\n }\n\n if (trimmed === \"+\") {\n return allowJustPlus ? \"+\" : \"\"\n }\n\n if (trimmed.startsWith(\"+\")) {\n const digits = sanitizeDigits(trimmed)\n if (!digits) {\n return allowJustPlus ? \"+\" : \"\"\n }\n const digitsWithoutIdd = stripIddPrefix(digits)\n if (digitsWithoutIdd !== digits) {\n return digitsWithoutIdd ? `+${digitsWithoutIdd}` : allowJustPlus ? \"+\" : \"\"\n }\n if (removeNationalPrefix && country) {\n const dial = getCountryCallingCode(country)\n if (digits.startsWith(dial) && digits.slice(dial.length).startsWith(\"0\")) {\n const withoutPrefix = digits.slice(dial.length + 1)\n return withoutPrefix ? `+${dial}${withoutPrefix}` : `+${dial}`\n }\n }\n return `+${digits}`\n }\n\n const digitsOnly = sanitizeDigits(trimmed)\n if (!digitsOnly) {\n return \"\"\n }\n\n const digitsWithoutIdd = stripIddPrefix(digitsOnly)\n if (digitsWithoutIdd !== digitsOnly) {\n return digitsWithoutIdd ? `+${digitsWithoutIdd}` : allowJustPlus ? \"+\" : \"\"\n }\n\n const previousNormalized = typeof previousValue === \"string\" ? previousValue : \"\"\n const previousDigits =\n previousNormalized && previousNormalized.startsWith(\"+\")\n ? sanitizeDigits(previousNormalized)\n : \"\"\n\n if (previousDigits && previousDigits.length > digitsOnly.length) {\n if (previousDigits.endsWith(digitsOnly)) {\n const removedPrefixLength = previousDigits.length - digitsOnly.length\n if (removedPrefixLength <= MAX_DIAL_CODE_LENGTH) {\n return `+${digitsOnly}`\n }\n }\n }\n\n if (digitsOnly === \"0\") {\n return \"0\"\n }\n\n if (\n removeNationalPrefix &&\n country &&\n digitsOnly.length > 1 &&\n digitsOnly.startsWith(\"0\") &&\n !digitsOnly.startsWith(\"00\")\n ) {\n const dial = getCountryCallingCode(country)\n const withoutPrefix = digitsOnly.slice(1)\n return withoutPrefix ? `+${dial}${withoutPrefix}` : `+${dial}`\n }\n\n if (!country) {\n return digitsOnly\n }\n\n if (digitsOnly.length <= 4) {\n return `+${digitsOnly}`\n }\n\n const dial = getCountryCallingCode(country)\n return `+${dial}${digitsOnly}`\n}\n\nexport function formatWithAsYouType(value: string, baseCountry?: CountryCode) {\n if (value === \"+\") {\n return {\n international: \"+\",\n national: \"\",\n formatted: \"+\",\n phoneNumber: null,\n detectedCountry: undefined,\n inferredCountry: undefined,\n hasExplicitInternationalPrefix: true,\n }\n }\n\n const hasExplicitInternationalPrefix = /^\\s*\\+/.test(value)\n const formatter = baseCountry ? new AsYouType(baseCountry) : new AsYouType()\n const formatted = formatter.input(value)\n const phoneNumber = formatter.getNumber()\n const digits = sanitizeDigits(value)\n const detectedCountry = canonicalizeDetectedCountry(\n (phoneNumber?.country ?? formatter.country ?? undefined) as CountryCode | undefined\n )\n const inferredCountry =\n detectedCountry ?? !phoneNumber\n ? undefined\n : canonicalizeDetectedCountry(\n inferCountryFromDialCode(phoneNumber, baseCountry, digits)\n )\n\n const international = phoneNumber?.formatInternational() ?? formatted\n const national = phoneNumber?.formatNational() ?? sanitizeDigits(international)\n\n return {\n international,\n national,\n formatted,\n phoneNumber,\n detectedCountry,\n inferredCountry,\n hasExplicitInternationalPrefix,\n }\n}\n\nexport function stripPrefix(value: string, prefix: string) {\n return value.startsWith(prefix) ? value.slice(prefix.length) : value\n}\n\nexport function getLengthIssue(value: string, country: CountryCode | undefined): LengthIssue | null {\n if (!country || !value) {\n return null\n }\n\n try {\n const result = validatePhoneNumberLength(value, country)\n return result === \"TOO_LONG\" ? \"TOO_LONG\" : null\n } catch {\n return null\n }\n}\n\ntype SuggestionState = {\n shouldSuggest: boolean\n query: string\n}\n\nexport function getSuggestionState(\n normalized: string,\n baseCountry: CountryCode | undefined,\n phoneNumber: ReturnType<AsYouType[\"getNumber\"]>,\n options: {\n hasRemovedNationalPrefix?: boolean\n detectedCountry?: CountryCode\n hasExplicitInternationalPrefix?: boolean\n } = {}\n): SuggestionState {\n const {\n hasRemovedNationalPrefix = false,\n detectedCountry,\n hasExplicitInternationalPrefix = false,\n } = options\n\n if (!normalized) {\n return { shouldSuggest: false, query: \"\" }\n }\n\n if (normalized === \"+\") {\n return { shouldSuggest: true, query: \"\" }\n }\n\n const digits = sanitizeDigits(normalized)\n if (!digits) {\n return { shouldSuggest: true, query: \"\" }\n }\n\n if (hasRemovedNationalPrefix) {\n return { shouldSuggest: false, query: \"\" }\n }\n\n if (hasExplicitInternationalPrefix && !detectedCountry) {\n if (!isDialCodeProgress(digits)) {\n return { shouldSuggest: false, query: \"\" }\n }\n return { shouldSuggest: true, query: digits }\n }\n\n let dial = phoneNumber?.countryCallingCode ?? null\n if (!dial) {\n if (baseCountry) {\n const baseDial = getCountryCallingCode(baseCountry)\n if (digits.startsWith(baseDial)) {\n dial = baseDial\n }\n } else if (!hasExplicitInternationalPrefix) {\n return { shouldSuggest: false, query: \"\" }\n }\n }\n\n if (!dial) {\n return { shouldSuggest: true, query: digits }\n }\n\n const nationalDigits = stripPrefix(digits, dial)\n if (nationalDigits.length === 0) {\n return { shouldSuggest: true, query: digits }\n }\n\n return { shouldSuggest: false, query: \"\" }\n}\n\nexport function shouldDisplayExplicitCountrySelection(\n suggestion: SuggestionState,\n options: { detectedCountry?: CountryCode; hasExplicitInternationalPrefix?: boolean }\n) {\n if (suggestion.shouldSuggest) {\n return false\n }\n\n const { hasExplicitInternationalPrefix = false, detectedCountry } = options\n\n if (!hasExplicitInternationalPrefix) {\n return true\n }\n\n return Boolean(detectedCountry)\n}\n"],"mappings":";;;;;AAaA,SAAgBS,EAAeC,GAAe;AAC5C,QAAOA,EAAMC,QAAQ,OAAO,GAAG;;AAGjC,SAASC,EAAmBC,GAAgB;AAS1C,QARKA,IAIDA,EAAOC,SAASP,IACX,KAGFF,EAAmBU,MAAMC,MAASA,EAAKC,WAAWJ,EAAO,CAAC,GAPxD;;AAUX,IAAMK,IACJ;AAEF,SAAS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eAAe;EAAOC,OAAO;EAAI;CAK9C,IAAIvF,IAAOiC,GAAaK,sBAAsB;AAC9C,KAAI,CAACtC;MACCkC,GAAa;GACf,IAAMyD,IAAWzG,EAAsBgD,EAAY;AACnD,GAAIrC,EAAOI,WAAW0F,EAAS,KAC7B3F,IAAO2F;aAEA,CAACxC,EACV,QAAO;GAAEmC,eAAe;GAAOC,OAAO;GAAI;;AAa9C,QATI,CAACvF,KAIkBkF,EAAYrF,GAAQG,EAAK,CAC7BF,WAAW,IACrB;EAAEwF,eAAe;EAAMC,OAAO1F;EAAQ,GAGxC;EAAEyF,eAAe;EAAOC,OAAO;EAAI;;AAG5C,SAAgBK,EACdC,GACAtF,GACA;AACA,KAAIsF,EAAWP,cACb,QAAO;CAGT,IAAM,EAAEnC,oCAAiC,IAAOuB,uBAAoBnE;AAMpE,QAJK4C,IAIE2C,EAAQpB,IAHN"}
|
package/dist/index30.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
//#region ../../node_modules/date-fns/constants.js
|
|
2
|
+
var e = 365.2425, t = 6048e5, n = 864e5, r = 3600 * 24;
|
|
3
|
+
r * 7, r * e / 12 * 3;
|
|
4
|
+
var i = Symbol.for("constructDateFrom");
|
|
5
|
+
//#endregion
|
|
6
|
+
export { i as constructFromSymbol, n as millisecondsInDay, t as millisecondsInWeek };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=index30.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index30.js","names":[],"sources":["../../../node_modules/date-fns/constants.js"],"sourcesContent":["/**\n * @module constants\n * @summary Useful constants\n * @description\n * Collection of useful date constants.\n *\n * The constants could be imported from `date-fns/constants`:\n *\n * ```ts\n * import { maxTime, minTime } from \"./constants/date-fns/constants\";\n *\n * function isAllowedTime(time) {\n * return time <= maxTime && time >= minTime;\n * }\n * ```\n */\n\n/**\n * @constant\n * @name daysInWeek\n * @summary Days in 1 week.\n */\nexport const daysInWeek = 7;\n\n/**\n * @constant\n * @name daysInYear\n * @summary Days in 1 year.\n *\n * @description\n * How many days in a year.\n *\n * One years equals 365.2425 days according to the formula:\n *\n * > Leap year occurs every 4 years, except for years that are divisible by 100 and not divisible by 400.\n * > 1 mean year = (365+1/4-1/100+1/400) days = 365.2425 days\n */\nexport const daysInYear = 365.2425;\n\n/**\n * @constant\n * @name maxTime\n * @summary Maximum allowed time.\n *\n * @example\n * import { maxTime } from \"./constants/date-fns/constants\";\n *\n * const isValid = 8640000000000001 <= maxTime;\n * //=> false\n *\n * new Date(8640000000000001);\n * //=> Invalid Date\n */\nexport const maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1000;\n\n/**\n * @constant\n * @name minTime\n * @summary Minimum allowed time.\n *\n * @example\n * import { minTime } from \"./constants/date-fns/constants\";\n *\n * const isValid = -8640000000000001 >= minTime;\n * //=> false\n *\n * new Date(-8640000000000001)\n * //=> Invalid Date\n */\nexport const minTime = -maxTime;\n\n/**\n * @constant\n * @name millisecondsInWeek\n * @summary Milliseconds in 1 week.\n */\nexport const millisecondsInWeek = 604800000;\n\n/**\n * @constant\n * @name millisecondsInDay\n * @summary Milliseconds in 1 day.\n */\nexport const millisecondsInDay = 86400000;\n\n/**\n * @constant\n * @name millisecondsInMinute\n * @summary Milliseconds in 1 minute\n */\nexport const millisecondsInMinute = 60000;\n\n/**\n * @constant\n * @name millisecondsInHour\n * @summary Milliseconds in 1 hour\n */\nexport const millisecondsInHour = 3600000;\n\n/**\n * @constant\n * @name millisecondsInSecond\n * @summary Milliseconds in 1 second\n */\nexport const millisecondsInSecond = 1000;\n\n/**\n * @constant\n * @name minutesInYear\n * @summary Minutes in 1 year.\n */\nexport const minutesInYear = 525600;\n\n/**\n * @constant\n * @name minutesInMonth\n * @summary Minutes in 1 month.\n */\nexport const minutesInMonth = 43200;\n\n/**\n * @constant\n * @name minutesInDay\n * @summary Minutes in 1 day.\n */\nexport const minutesInDay = 1440;\n\n/**\n * @constant\n * @name minutesInHour\n * @summary Minutes in 1 hour.\n */\nexport const minutesInHour = 60;\n\n/**\n * @constant\n * @name monthsInQuarter\n * @summary Months in 1 quarter.\n */\nexport const monthsInQuarter = 3;\n\n/**\n * @constant\n * @name monthsInYear\n * @summary Months in 1 year.\n */\nexport const monthsInYear = 12;\n\n/**\n * @constant\n * @name quartersInYear\n * @summary Quarters in 1 year\n */\nexport const quartersInYear = 4;\n\n/**\n * @constant\n * @name secondsInHour\n * @summary Seconds in 1 hour.\n */\nexport const secondsInHour = 3600;\n\n/**\n * @constant\n * @name secondsInMinute\n * @summary Seconds in 1 minute.\n */\nexport const secondsInMinute = 60;\n\n/**\n * @constant\n * @name secondsInDay\n * @summary Seconds in 1 day.\n */\nexport const secondsInDay = secondsInHour * 24;\n\n/**\n * @constant\n * @name secondsInWeek\n * @summary Seconds in 1 week.\n */\nexport const secondsInWeek = secondsInDay * 7;\n\n/**\n * @constant\n * @name secondsInYear\n * @summary Seconds in 1 year.\n */\nexport const secondsInYear = secondsInDay * daysInYear;\n\n/**\n * @constant\n * @name secondsInMonth\n * @summary Seconds in 1 month\n */\nexport const secondsInMonth = secondsInYear / 12;\n\n/**\n * @constant\n * @name secondsInQuarter\n * @summary Seconds in 1 quarter.\n */\nexport const secondsInQuarter = secondsInMonth * 3;\n\n/**\n * @constant\n * @name constructFromSymbol\n * @summary Symbol enabling Date extensions to inherit properties from the reference date.\n *\n * The symbol is used to enable the `constructFrom` function to construct a date\n * using a reference date and a value. It allows to transfer extra properties\n * from the reference date to the new date. It's useful for extensions like\n * [`TZDate`](https://github.com/date-fns/tz) that accept a time zone as\n * a constructor argument.\n */\nexport const constructFromSymbol = Symbol.for(\"constructDateFrom\");\n"],"x_google_ignoreList":[0],"mappings":";AAqCA,IAAa,IAAa,UAuCb,IAAqB,QAOrB,IAAoB,OA2FpB,IAdgB,OAce;AAOf,IAAe,GAOf,IAAe,IAOE,KAOG;AAajD,IAAa,IAAsB,OAAO,IAAI,oBAAoB"}
|
package/dist/index300.js
CHANGED
|
@@ -1,113 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
//#region src/components/PhoneNumberInput/selection.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
if (!e) return !1;
|
|
4
|
+
let t = e.charCodeAt(0);
|
|
5
|
+
return t >= 48 && t <= 57;
|
|
6
|
+
}
|
|
7
|
+
function t(t, n) {
|
|
8
|
+
let r = 0, i = Math.min(n, t.length);
|
|
9
|
+
for (let n = 0; n < i; n += 1) e(t[n] ?? "") && (r += 1);
|
|
10
|
+
return r;
|
|
11
|
+
}
|
|
12
|
+
function n(t, n) {
|
|
13
|
+
if (n <= 0) return t.startsWith("+") ? Math.min(1, t.length) : 0;
|
|
14
|
+
let r = 0;
|
|
15
|
+
for (let i = 0; i < t.length; i += 1) if (e(t[i] ?? "") && (r += 1, r === n)) return i + 1;
|
|
16
|
+
return t.length;
|
|
17
|
+
}
|
|
18
|
+
function r(t) {
|
|
19
|
+
return !t || e(t) ? !1 : t !== "+";
|
|
13
20
|
}
|
|
14
|
-
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
a[4] === c?.renderOptionLabel ? m = a[5] : (m = c?.renderOptionLabel ?? p, a[4] = c?.renderOptionLabel, a[5] = m);
|
|
19
|
-
let h = m, g = n.useRef(null), { innerRef: _ } = r, v;
|
|
20
|
-
a[6] === _ ? v = a[7] : (v = (e) => {
|
|
21
|
-
g.current = e, s(_, e);
|
|
22
|
-
}, a[6] = _, a[7] = v);
|
|
23
|
-
let y = v, b;
|
|
24
|
-
a[8] !== c?.consumeScrollBehavior || a[9] !== l ? (b = () => {
|
|
25
|
-
if (!l) return;
|
|
26
|
-
let e = c?.consumeScrollBehavior, t = e ? e() : "smooth", n = g.current;
|
|
27
|
-
if (!n) return;
|
|
28
|
-
let r = n.parentElement;
|
|
29
|
-
if (!r) return;
|
|
30
|
-
let i = n.offsetTop, a = i + n.offsetHeight, o = r.scrollTop, s = o + r.clientHeight;
|
|
31
|
-
i >= o && a <= s || n.scrollIntoView({
|
|
32
|
-
block: "nearest",
|
|
33
|
-
behavior: t
|
|
34
|
-
});
|
|
35
|
-
}, a[8] = c?.consumeScrollBehavior, a[9] = l, a[10] = b) : b = a[10];
|
|
36
|
-
let x;
|
|
37
|
-
a[11] !== c || a[12] !== l ? (x = [c, l], a[11] = c, a[12] = l, a[13] = x) : x = a[13], n.useEffect(b, x);
|
|
38
|
-
let S;
|
|
39
|
-
a[14] !== c || a[15] !== u || a[16] !== r.data ? (S = (e) => {
|
|
40
|
-
u?.(e), c?.setHighlightedOption(r.data);
|
|
41
|
-
}, a[14] = c, a[15] = u, a[16] = r.data, a[17] = S) : S = a[17];
|
|
42
|
-
let C = S, w = l ? "bg-muted text-foreground" : "text-foreground hover:bg-muted", T;
|
|
43
|
-
a[18] !== d || a[19] !== w ? (T = e("flex cursor-pointer items-center justify-between gap-3 px-3 py-2 text-sm", d, w), a[18] = d, a[19] = w, a[20] = T) : T = a[20];
|
|
44
|
-
let E;
|
|
45
|
-
a[21] !== r.data || a[22] !== h ? (E = h(r.data), a[21] = r.data, a[22] = h, a[23] = E) : E = a[23];
|
|
46
|
-
let D;
|
|
47
|
-
return a[24] !== y || a[25] !== C || a[26] !== f || a[27] !== T || a[28] !== E ? (D = /* @__PURE__ */ i("div", {
|
|
48
|
-
ref: y,
|
|
49
|
-
...f,
|
|
50
|
-
onMouseMove: C,
|
|
51
|
-
className: T,
|
|
52
|
-
children: E
|
|
53
|
-
}), a[24] = y, a[25] = C, a[26] = f, a[27] = T, a[28] = E, a[29] = D) : D = a[29], D;
|
|
54
|
-
}, l = {
|
|
55
|
-
control: () => ({ display: "none" }),
|
|
56
|
-
menu: (e) => ({
|
|
57
|
-
...e,
|
|
58
|
-
marginTop: 4,
|
|
59
|
-
borderRadius: "var(--radius)",
|
|
60
|
-
boxShadow: "0 18px 36px rgba(15, 23, 42, 0.18)",
|
|
61
|
-
backgroundColor: "hsl(var(--popover))",
|
|
62
|
-
overflow: "hidden",
|
|
63
|
-
zIndex: 20
|
|
64
|
-
}),
|
|
65
|
-
menuList: (e) => ({
|
|
66
|
-
...e,
|
|
67
|
-
maxHeight: 240,
|
|
68
|
-
padding: 0
|
|
69
|
-
}),
|
|
70
|
-
option: (e, t) => ({
|
|
71
|
-
...e,
|
|
72
|
-
fontSize: "0.875rem",
|
|
73
|
-
backgroundColor: t.isFocused ? "hsl(var(--muted))" : t.isSelected ? "hsl(var(--accent))" : "transparent",
|
|
74
|
-
color: t.isSelected ? "hsl(var(--accent-foreground))" : "hsl(var(--foreground))",
|
|
75
|
-
cursor: "pointer"
|
|
76
|
-
}),
|
|
77
|
-
noOptionsMessage: (e) => ({
|
|
78
|
-
...e,
|
|
79
|
-
fontSize: "0.875rem",
|
|
80
|
-
color: "hsl(var(--muted-foreground))"
|
|
81
|
-
})
|
|
82
|
-
}, u = (e) => {
|
|
83
|
-
let n = t(3), r;
|
|
84
|
-
n[0] === Symbol.for("react.memo_cache_sentinel") ? (r = { display: "none" }, n[0] = r) : r = n[0];
|
|
85
|
-
let a;
|
|
86
|
-
return n[1] === e.children ? a = n[2] : (a = /* @__PURE__ */ i("div", {
|
|
87
|
-
style: r,
|
|
88
|
-
children: e.children
|
|
89
|
-
}), n[1] = e.children, n[2] = a), a;
|
|
90
|
-
}, d = () => null;
|
|
91
|
-
function f(e) {
|
|
92
|
-
return /* @__PURE__ */ a(r, { children: [/* @__PURE__ */ a("span", {
|
|
93
|
-
className: "flex min-w-0 items-center gap-2",
|
|
94
|
-
children: [e.flag ? /* @__PURE__ */ i("span", {
|
|
95
|
-
"aria-hidden": "true",
|
|
96
|
-
className: "text-lg leading-none",
|
|
97
|
-
children: e.flag
|
|
98
|
-
}) : null, /* @__PURE__ */ i("span", {
|
|
99
|
-
className: "truncate",
|
|
100
|
-
children: e.name
|
|
101
|
-
})]
|
|
102
|
-
}), /* @__PURE__ */ a("span", {
|
|
103
|
-
className: "text-xs text-muted-foreground",
|
|
104
|
-
children: ["+", e.dialCode]
|
|
105
|
-
})] });
|
|
21
|
+
function i(e, t) {
|
|
22
|
+
let n = t;
|
|
23
|
+
for (; n > 0 && r(e[n - 1] ?? "");) --n;
|
|
24
|
+
return n;
|
|
106
25
|
}
|
|
107
|
-
function
|
|
108
|
-
|
|
26
|
+
function a(e, t) {
|
|
27
|
+
let n = t;
|
|
28
|
+
for (; n < e.length && r(e[n] ?? "");) n += 1;
|
|
29
|
+
return n;
|
|
30
|
+
}
|
|
31
|
+
function o(e) {
|
|
32
|
+
let { value: n } = e, r = e.selectionStart ?? n.length, i = e.selectionEnd ?? r, a = r <= 1 && n.startsWith("+"), o = i <= 1 && n.startsWith("+");
|
|
33
|
+
return {
|
|
34
|
+
selectionStart: r,
|
|
35
|
+
selectionEnd: i,
|
|
36
|
+
startDigits: t(n, r),
|
|
37
|
+
endDigits: t(n, i),
|
|
38
|
+
preserveStartIndex: a,
|
|
39
|
+
preserveEndIndex: o,
|
|
40
|
+
wasAtStart: r === 0,
|
|
41
|
+
wasAtEnd: i === n.length
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function s(e, t) {
|
|
45
|
+
if (e.selectionStart === e.selectionEnd) {
|
|
46
|
+
if (e.wasAtEnd) {
|
|
47
|
+
let e = t.length;
|
|
48
|
+
return {
|
|
49
|
+
start: e,
|
|
50
|
+
end: e
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (e.wasAtStart) return {
|
|
54
|
+
start: 0,
|
|
55
|
+
end: 0
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
let r = e.preserveStartIndex ? Math.min(e.selectionStart, t.length) : n(t, e.startDigits), i = e.preserveEndIndex ? Math.min(e.selectionEnd, t.length) : n(t, e.endDigits), a = r, o = i;
|
|
59
|
+
e.wasAtStart && (a = 0), e.wasAtEnd && (o = t.length), e.selectionStart === e.selectionEnd && (a = o);
|
|
60
|
+
let s = Math.min(Math.max(a, 0), t.length), c = Math.min(Math.max(o, 0), t.length);
|
|
61
|
+
return s > c ? {
|
|
62
|
+
start: c,
|
|
63
|
+
end: c
|
|
64
|
+
} : {
|
|
65
|
+
start: s,
|
|
66
|
+
end: c
|
|
67
|
+
};
|
|
109
68
|
}
|
|
110
69
|
//#endregion
|
|
111
|
-
export {
|
|
70
|
+
export { o as captureSelectionSnapshot, s as resolveSelection, i as skipFormattingCharactersLeft, a as skipFormattingCharactersRight };
|
|
112
71
|
|
|
113
72
|
//# sourceMappingURL=index300.js.map
|
package/dist/index300.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index300.js","names":["
|
|
1
|
+
{"version":3,"file":"index300.js","names":["isDigitCharacter","char","code","charCodeAt","countDigitsBefore","value","index","count","limit","Math","min","length","position","findIndexForDigitCount","digitCount","startsWith","seen","isFormattingCharacter","skipFormattingCharactersLeft","next","skipFormattingCharactersRight","SelectionSnapshot","selectionStart","selectionEnd","startDigits","endDigits","preserveStartIndex","preserveEndIndex","wasAtStart","wasAtEnd","captureSelectionSnapshot","input","HTMLInputElement","resolveSelection","snapshot","end","start","resolvedStart","resolvedEnd","clampedStart","max","clampedEnd"],"sources":["../src/components/PhoneNumberInput/selection.ts"],"sourcesContent":["function isDigitCharacter(char: string) {\n if (!char) {\n return false\n }\n const code = char.charCodeAt(0)\n return code >= 48 && code <= 57\n}\n\nfunction countDigitsBefore(value: string, index: number) {\n let count = 0\n const limit = Math.min(index, value.length)\n for (let position = 0; position < limit; position += 1) {\n if (isDigitCharacter(value[position] ?? \"\")) {\n count += 1\n }\n }\n return count\n}\n\nfunction findIndexForDigitCount(value: string, digitCount: number) {\n if (digitCount <= 0) {\n return value.startsWith(\"+\") ? Math.min(1, value.length) : 0\n }\n\n let seen = 0\n for (let index = 0; index < value.length; index += 1) {\n if (isDigitCharacter(value[index] ?? \"\")) {\n seen += 1\n if (seen === digitCount) {\n return index + 1\n }\n }\n }\n\n return value.length\n}\n\nfunction isFormattingCharacter(char: string) {\n if (!char) {\n return false\n }\n if (isDigitCharacter(char)) {\n return false\n }\n return char !== \"+\"\n}\n\nexport function skipFormattingCharactersLeft(value: string, index: number) {\n let position = index\n while (position > 0) {\n const next = value[position - 1] ?? \"\"\n if (!isFormattingCharacter(next)) {\n break\n }\n position -= 1\n }\n return position\n}\n\nexport function skipFormattingCharactersRight(value: string, index: number) {\n let position = index\n while (position < value.length) {\n const next = value[position] ?? \"\"\n if (!isFormattingCharacter(next)) {\n break\n }\n position += 1\n }\n return position\n}\n\ntype SelectionSnapshot = {\n selectionStart: number\n selectionEnd: number\n startDigits: number\n endDigits: number\n preserveStartIndex: boolean\n preserveEndIndex: boolean\n wasAtStart: boolean\n wasAtEnd: boolean\n}\n\nexport function captureSelectionSnapshot(input: HTMLInputElement): SelectionSnapshot {\n const { value } = input\n const selectionStart = input.selectionStart ?? value.length\n const selectionEnd = input.selectionEnd ?? selectionStart\n const preserveStartIndex = selectionStart <= 1 && value.startsWith(\"+\")\n const preserveEndIndex = selectionEnd <= 1 && value.startsWith(\"+\")\n\n return {\n selectionStart,\n selectionEnd,\n startDigits: countDigitsBefore(value, selectionStart),\n endDigits: countDigitsBefore(value, selectionEnd),\n preserveStartIndex,\n preserveEndIndex,\n wasAtStart: selectionStart === 0,\n wasAtEnd: selectionEnd === value.length,\n }\n}\n\nexport function resolveSelection(snapshot: SelectionSnapshot, value: string) {\n if (snapshot.selectionStart === snapshot.selectionEnd) {\n if (snapshot.wasAtEnd) {\n const end = value.length\n return { start: end, end }\n }\n if (snapshot.wasAtStart) {\n return { start: 0, end: 0 }\n }\n }\n\n const start = snapshot.preserveStartIndex\n ? Math.min(snapshot.selectionStart, value.length)\n : findIndexForDigitCount(value, snapshot.startDigits)\n const end = snapshot.preserveEndIndex\n ? Math.min(snapshot.selectionEnd, value.length)\n : findIndexForDigitCount(value, snapshot.endDigits)\n\n let resolvedStart = start\n let resolvedEnd = end\n\n if (snapshot.wasAtStart) {\n resolvedStart = 0\n }\n\n if (snapshot.wasAtEnd) {\n resolvedEnd = value.length\n }\n\n if (snapshot.selectionStart === snapshot.selectionEnd) {\n resolvedStart = resolvedEnd\n }\n\n const clampedStart = Math.min(Math.max(resolvedStart, 0), value.length)\n const clampedEnd = Math.min(Math.max(resolvedEnd, 0), value.length)\n\n if (clampedStart > clampedEnd) {\n return { start: clampedEnd, end: clampedEnd }\n }\n\n return { start: clampedStart, end: clampedEnd }\n}\n\n"],"mappings":";AAAA,SAASA,EAAiBC,GAAc;AACtC,KAAI,CAACA,EACH,QAAO;CAET,IAAMC,IAAOD,EAAKE,WAAW,EAAE;AAC/B,QAAOD,KAAQ,MAAMA,KAAQ;;AAG/B,SAASE,EAAkBC,GAAeC,GAAe;CACvD,IAAIC,IAAQ,GACNC,IAAQC,KAAKC,IAAIJ,GAAOD,EAAMM,OAAO;AAC3C,MAAK,IAAIC,IAAW,GAAGA,IAAWJ,GAAOI,KAAY,EACnD,CAAIZ,EAAiBK,EAAMO,MAAa,GAAG,KACzCL,KAAS;AAGb,QAAOA;;AAGT,SAASM,EAAuBR,GAAeS,GAAoB;AACjE,KAAIA,KAAc,EAChB,QAAOT,EAAMU,WAAW,IAAI,GAAGN,KAAKC,IAAI,GAAGL,EAAMM,OAAO,GAAG;CAG7D,IAAIK,IAAO;AACX,MAAK,IAAIV,IAAQ,GAAGA,IAAQD,EAAMM,QAAQL,KAAS,EACjD,KAAIN,EAAiBK,EAAMC,MAAU,GAAG,KACtCU,KAAQ,GACJA,MAASF,GACX,QAAOR,IAAQ;AAKrB,QAAOD,EAAMM;;AAGf,SAASM,EAAsBhB,GAAc;AAO3C,QANI,CAACA,KAGDD,EAAiBC,EAAK,GACjB,KAEFA,MAAS;;AAGlB,SAAgBiB,EAA6Bb,GA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