@rpcbase/ui 0.280.0 → 0.282.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/components/AddressAutocompleteInput/index.d.ts +1 -1
- package/dist/components/AddressAutocompleteInput/index.d.ts.map +1 -1
- package/dist/components/ApplePayButton/index.d.ts +1 -1
- package/dist/components/ApplePayButton/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.d.ts +1 -1
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/DayPickerField/index.d.ts +2 -2
- package/dist/components/DayPickerField/index.d.ts.map +1 -1
- package/dist/components/Dialog/index.d.ts +9 -9
- package/dist/components/Dialog/index.d.ts.map +1 -1
- package/dist/components/FilesUploadField/index.d.ts +1 -1
- package/dist/components/FilesUploadField/index.d.ts.map +1 -1
- package/dist/components/HourPickerField/index.d.ts +2 -2
- package/dist/components/HourPickerField/index.d.ts.map +1 -1
- package/dist/components/I18nField/index.d.ts +1 -1
- package/dist/components/I18nField/index.d.ts.map +1 -1
- package/dist/components/Image/index.d.ts +1 -1
- package/dist/components/Image/index.d.ts.map +1 -1
- package/dist/components/ImagesField/index.d.ts +1 -1
- package/dist/components/ImagesField/index.d.ts.map +1 -1
- package/dist/components/Input/index.d.ts +1 -1
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Notifications/NotificationsButton.d.ts +1 -1
- package/dist/components/Notifications/NotificationsButton.d.ts.map +1 -1
- package/dist/components/Notifications/NotificationsDrawer.d.ts +1 -1
- package/dist/components/Notifications/NotificationsDrawer.d.ts.map +1 -1
- package/dist/components/Notifications/NotificationsSettings.d.ts +1 -1
- package/dist/components/Notifications/NotificationsSettings.d.ts.map +1 -1
- package/dist/components/PhoneNumberInput/suggestions.d.ts +3 -3
- package/dist/components/PhoneNumberInput/suggestions.d.ts.map +1 -1
- package/dist/components/Select/index.d.ts +2 -2
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/header/MenuPopover/index.d.ts +1 -1
- package/dist/components/header/MenuPopover/index.d.ts.map +1 -1
- package/dist/index.js +12 -12
- package/dist/index10.js +6 -4
- package/dist/index10.js.map +1 -1
- package/dist/index12.js.map +1 -1
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +88 -88
- package/dist/index14.js.map +1 -1
- package/dist/index15.js.map +1 -1
- package/dist/index154.js +19 -7
- package/dist/index154.js.map +1 -1
- package/dist/index16.js +36 -45
- package/dist/index16.js.map +1 -1
- package/dist/index160.js +3 -3
- package/dist/index160.js.map +1 -1
- package/dist/index166.js +5 -5
- package/dist/index166.js.map +1 -1
- package/dist/index172.js +27 -25
- package/dist/index172.js.map +1 -1
- package/dist/index181.js +1 -1
- package/dist/index181.js.map +1 -1
- package/dist/index182.js +145 -162
- package/dist/index182.js.map +1 -1
- package/dist/index184.js +6 -8
- package/dist/index184.js.map +1 -1
- package/dist/index186.js +2 -8
- package/dist/index186.js.map +1 -1
- package/dist/index19.js +1 -1
- package/dist/index19.js.map +1 -1
- package/dist/index195.js +1 -1
- package/dist/index195.js.map +1 -1
- package/dist/index196.js +2 -2
- package/dist/index196.js.map +1 -1
- package/dist/index197.js +1 -1
- package/dist/index197.js.map +1 -1
- package/dist/index198.js +16 -15
- package/dist/index198.js.map +1 -1
- package/dist/index199.js +13 -17
- package/dist/index199.js.map +1 -1
- package/dist/index200.js +3 -2
- package/dist/index200.js.map +1 -1
- package/dist/index207.js +5 -90
- package/dist/index207.js.map +1 -1
- package/dist/index208.js +15 -3
- package/dist/index208.js.map +1 -1
- package/dist/index209.js +102 -22
- package/dist/index209.js.map +1 -1
- package/dist/index210.js +3 -28
- package/dist/index210.js.map +1 -1
- package/dist/index211.js +23 -19
- package/dist/index211.js.map +1 -1
- package/dist/index212.js +27 -6
- package/dist/index212.js.map +1 -1
- package/dist/index213.js +19 -14
- package/dist/index213.js.map +1 -1
- package/dist/index214.js +5 -6
- package/dist/index214.js.map +1 -1
- package/dist/index215.js +14 -26
- package/dist/index215.js.map +1 -1
- package/dist/index216.js +7 -22
- package/dist/index216.js.map +1 -1
- package/dist/index217.js +27 -6
- package/dist/index217.js.map +1 -1
- package/dist/index218.js +23 -5
- package/dist/index218.js.map +1 -1
- package/dist/index219.js +6 -4
- package/dist/index219.js.map +1 -1
- package/dist/index220.js +5 -4
- package/dist/index220.js.map +1 -1
- package/dist/index221.js +4 -24
- package/dist/index221.js.map +1 -1
- package/dist/index222.js +4 -3
- package/dist/index222.js.map +1 -1
- package/dist/index223.js +21 -21
- package/dist/index223.js.map +1 -1
- package/dist/index224.js +3 -23
- package/dist/index224.js.map +1 -1
- package/dist/index225.js +23 -6
- package/dist/index225.js.map +1 -1
- package/dist/index226.js +22 -9
- package/dist/index226.js.map +1 -1
- package/dist/index227.js +5 -17
- package/dist/index227.js.map +1 -1
- package/dist/index228.js +8 -49
- package/dist/index228.js.map +1 -1
- package/dist/index229.js +18 -5
- package/dist/index229.js.map +1 -1
- package/dist/index230.js +50 -19
- package/dist/index230.js.map +1 -1
- package/dist/index231.js +20 -28
- package/dist/index231.js.map +1 -1
- package/dist/index232.js +27 -104
- package/dist/index232.js.map +1 -1
- package/dist/index233.js +98 -33
- package/dist/index233.js.map +1 -1
- package/dist/index234.js +28 -113
- package/dist/index234.js.map +1 -1
- package/dist/index235.js +117 -11
- package/dist/index235.js.map +1 -1
- package/dist/index236.js +12 -4
- package/dist/index236.js.map +1 -1
- package/dist/index237.js +4 -15
- package/dist/index237.js.map +1 -1
- package/dist/index238.js +13 -62
- package/dist/index238.js.map +1 -1
- package/dist/index239.js +64 -9
- package/dist/index239.js.map +1 -1
- package/dist/index240.js +10 -106
- package/dist/index240.js.map +1 -1
- package/dist/index241.js +107 -13
- package/dist/index241.js.map +1 -1
- package/dist/index242.js +16 -13
- package/dist/index242.js.map +1 -1
- package/dist/index243.js +13 -5
- package/dist/index243.js.map +1 -1
- package/dist/index244.js +4 -316
- package/dist/index244.js.map +1 -1
- package/dist/index245.js +315 -58
- package/dist/index245.js.map +1 -1
- package/dist/index246.js +58 -223
- package/dist/index246.js.map +1 -1
- package/dist/index247.js +215 -318
- package/dist/index247.js.map +1 -1
- package/dist/index248.js +250 -306
- package/dist/index248.js.map +1 -1
- package/dist/index249.js +308 -173
- package/dist/index249.js.map +1 -1
- package/dist/index250.js +178 -7
- package/dist/index250.js.map +1 -1
- package/dist/index251.js +8 -15
- package/dist/index251.js.map +1 -1
- package/dist/index252.js +41 -5
- package/dist/index252.js.map +1 -1
- package/dist/index253.js +46 -38
- package/dist/index253.js.map +1 -1
- package/dist/index254.js +7 -50
- package/dist/index254.js.map +1 -1
- package/dist/index255.js +49 -6
- package/dist/index255.js.map +1 -1
- package/dist/index256.js +48 -46
- package/dist/index256.js.map +1 -1
- package/dist/index257.js +6 -51
- package/dist/index257.js.map +1 -1
- package/dist/index258.js +10 -9
- package/dist/index258.js.map +1 -1
- package/dist/index259.js +60 -8
- package/dist/index259.js.map +1 -1
- package/dist/index26.js.map +1 -1
- package/dist/index260.js +41 -60
- package/dist/index260.js.map +1 -1
- package/dist/index261.js +88 -34
- package/dist/index261.js.map +1 -1
- package/dist/index262.js +47 -94
- package/dist/index262.js.map +1 -1
- package/dist/index263.js +36 -49
- package/dist/index263.js.map +1 -1
- package/dist/index264.js +45 -32
- package/dist/index264.js.map +1 -1
- package/dist/index265.js +47 -46
- package/dist/index265.js.map +1 -1
- package/dist/index266.js +18 -48
- package/dist/index266.js.map +1 -1
- package/dist/index267.js +174 -15
- package/dist/index267.js.map +1 -1
- package/dist/index268.js +47 -169
- package/dist/index268.js.map +1 -1
- package/dist/index269.js +17 -34
- package/dist/index269.js.map +1 -1
- package/dist/index270.js +59 -10
- package/dist/index270.js.map +1 -1
- package/dist/index271.js +10 -66
- package/dist/index271.js.map +1 -1
- package/dist/index272.js +4 -4
- package/dist/index273.js +71 -69
- package/dist/index273.js.map +1 -1
- package/dist/index274.js +158 -152
- package/dist/index274.js.map +1 -1
- package/dist/index275.js +7 -13
- package/dist/index275.js.map +1 -1
- package/dist/index276.js +12 -5
- package/dist/index276.js.map +1 -1
- package/dist/index277.js +12 -6
- package/dist/index277.js.map +1 -1
- package/dist/index278.js +11 -12
- package/dist/index278.js.map +1 -1
- package/dist/index279.js +65 -9
- package/dist/index279.js.map +1 -1
- package/dist/index280.js +6 -74
- package/dist/index280.js.map +1 -1
- package/dist/index281.js +25 -6
- package/dist/index281.js.map +1 -1
- package/dist/index282.js +24 -24
- package/dist/index282.js.map +1 -1
- package/dist/index283.js +125 -24
- package/dist/index283.js.map +1 -1
- package/dist/index284.js +52 -115
- package/dist/index284.js.map +1 -1
- package/dist/index285.js +59 -55
- package/dist/index285.js.map +1 -1
- package/dist/index286.js +48 -61
- package/dist/index286.js.map +1 -1
- package/dist/index287.js +5 -48
- package/dist/index287.js.map +1 -1
- package/dist/index288.js +14 -8
- package/dist/index288.js.map +1 -1
- package/dist/index289.js +18 -14
- package/dist/index289.js.map +1 -1
- package/dist/index290.js +10 -17
- package/dist/index290.js.map +1 -1
- package/dist/index291.js +23 -11
- package/dist/index291.js.map +1 -1
- package/dist/index292.js +52 -25
- package/dist/index292.js.map +1 -1
- package/dist/index293.js +6 -52
- package/dist/index293.js.map +1 -1
- package/dist/index294.js +137 -5
- package/dist/index294.js.map +1 -1
- package/dist/index295.js +59 -149
- package/dist/index295.js.map +1 -1
- package/dist/index296.js +90 -49
- package/dist/index296.js.map +1 -1
- package/dist/index297.js +11 -117
- package/dist/index297.js.map +1 -1
- package/dist/index298.js +863 -11
- package/dist/index298.js.map +1 -1
- package/dist/index299.js +21 -865
- package/dist/index299.js.map +1 -1
- package/dist/index3.js.map +1 -1
- package/dist/index300.js +417 -27
- package/dist/index300.js.map +1 -1
- package/dist/index301.js +774 -483
- package/dist/index301.js.map +1 -1
- package/dist/index302.js +7436 -803
- package/dist/index302.js.map +1 -1
- package/dist/index303.js +7 -7429
- package/dist/index303.js.map +1 -1
- package/dist/index304.js +12 -6
- package/dist/index304.js.map +1 -1
- package/dist/index305.js +5 -12
- package/dist/index305.js.map +1 -1
- package/dist/index306.js +3 -3
- package/dist/index306.js.map +1 -1
- package/dist/index307.js +469 -5
- package/dist/index307.js.map +1 -1
- package/dist/index308.js +32 -464
- package/dist/index308.js.map +1 -1
- package/dist/index309.js +18 -36
- package/dist/index309.js.map +1 -1
- package/dist/index310.js +28 -17
- package/dist/index310.js.map +1 -1
- package/dist/index311.js +4 -30
- package/dist/index311.js.map +1 -1
- package/dist/index312.js +59 -4
- package/dist/index312.js.map +1 -1
- package/dist/index313.js +11 -59
- package/dist/index313.js.map +1 -1
- package/dist/index314.js +5 -9
- package/dist/index314.js.map +1 -1
- package/dist/index315.js +9 -5
- package/dist/index315.js.map +1 -1
- package/dist/index316.js +12 -9
- package/dist/index316.js.map +1 -1
- package/dist/index317.js +3 -13
- package/dist/index317.js.map +1 -1
- package/dist/index318.js +17 -3
- package/dist/index318.js.map +1 -1
- package/dist/index319.js +23 -14
- package/dist/index319.js.map +1 -1
- package/dist/index320.js +39 -23
- package/dist/index320.js.map +1 -1
- package/dist/index321.js +5 -41
- package/dist/index321.js.map +1 -1
- package/dist/index322.js +25 -5
- package/dist/index322.js.map +1 -1
- package/dist/index323.js +18 -24
- package/dist/index323.js.map +1 -1
- package/dist/index324.js +32 -17
- package/dist/index324.js.map +1 -1
- package/dist/index325.js +5 -34
- package/dist/index325.js.map +1 -1
- package/dist/index326.js +9 -5
- package/dist/index326.js.map +1 -1
- package/dist/index327.js +7 -8
- package/dist/index327.js.map +1 -1
- package/dist/index328.js +9 -8
- package/dist/index328.js.map +1 -1
- package/dist/index329.js +10 -9
- package/dist/index329.js.map +1 -1
- package/dist/index330.js +7 -10
- package/dist/index330.js.map +1 -1
- package/dist/index331.js +75 -7
- package/dist/index331.js.map +1 -1
- package/dist/index332.js +153 -66
- package/dist/index332.js.map +1 -1
- package/dist/index333.js +99 -147
- package/dist/index333.js.map +1 -1
- package/dist/index334.js +13 -113
- package/dist/index334.js.map +1 -1
- package/dist/index335.js +78 -12
- package/dist/index335.js.map +1 -1
- package/dist/index336.js +23 -57
- package/dist/index336.js.map +1 -1
- package/dist/index337.js +12 -45
- package/dist/index337.js.map +1 -1
- package/dist/index338.js +16 -13
- package/dist/index338.js.map +1 -1
- package/dist/index339.js +100 -15
- package/dist/index339.js.map +1 -1
- package/dist/index340.js +50 -95
- package/dist/index340.js.map +1 -1
- package/dist/index341.js +57 -5
- package/dist/index341.js.map +1 -1
- package/dist/index342.js +41 -78
- package/dist/index342.js.map +1 -1
- package/dist/index343.js +100 -58
- package/dist/index343.js.map +1 -1
- package/dist/index344.js +46 -104
- package/dist/index344.js.map +1 -1
- package/dist/index345.js +39 -51
- package/dist/index345.js.map +1 -1
- package/dist/index346.js +143 -42
- package/dist/index346.js.map +1 -1
- package/dist/index347.js +122 -123
- package/dist/index347.js.map +1 -1
- package/dist/index348.js +224 -108
- package/dist/index348.js.map +1 -1
- package/dist/index349.js +158 -174
- package/dist/index349.js.map +1 -1
- package/dist/index350.js +213 -144
- package/dist/index350.js.map +1 -1
- package/dist/index351.js +5 -309
- package/dist/index351.js.map +1 -1
- package/dist/index352.js +6 -5
- package/dist/index352.js.map +1 -1
- package/dist/index353.js +7 -6
- package/dist/index353.js.map +1 -1
- package/dist/index354.js +4 -5
- package/dist/index354.js.map +1 -1
- package/dist/index355.js +4 -4
- package/dist/index355.js.map +1 -1
- package/dist/index356.js +21 -6
- package/dist/index356.js.map +1 -1
- package/dist/index357.js +10 -21
- package/dist/index357.js.map +1 -1
- package/dist/index358.js +128 -10
- package/dist/index358.js.map +1 -1
- package/dist/index359.js +36 -122
- package/dist/index359.js.map +1 -1
- package/dist/index360.js +64 -38
- package/dist/index360.js.map +1 -1
- package/dist/index361.js +115 -66
- package/dist/index361.js.map +1 -1
- package/dist/index362.js +485 -112
- package/dist/index362.js.map +1 -1
- package/dist/index363.js +7 -490
- package/dist/index363.js.map +1 -1
- package/dist/index364.js +1 -1
- package/dist/index364.js.map +1 -1
- package/dist/index367.js +2 -9
- package/dist/index367.js.map +1 -1
- package/dist/index368.js +26 -5
- package/dist/index368.js.map +1 -1
- package/dist/index369.js +43 -27
- package/dist/index369.js.map +1 -1
- package/dist/index370.js +35 -46
- package/dist/index370.js.map +1 -1
- package/dist/index371.js +16 -27
- package/dist/index371.js.map +1 -1
- package/dist/index372.js +41 -16
- package/dist/index372.js.map +1 -1
- package/dist/index373.js +11 -42
- package/dist/index373.js.map +1 -1
- package/dist/index374.js +10 -14
- package/dist/index374.js.map +1 -1
- package/dist/index375.js +51 -9
- package/dist/index375.js.map +1 -1
- package/dist/index376.js +40 -53
- package/dist/index376.js.map +1 -1
- package/dist/index377.js +17 -43
- package/dist/index377.js.map +1 -1
- package/dist/index378.js +4 -15
- package/dist/index378.js.map +1 -1
- package/dist/index379.js +4 -4
- package/dist/index379.js.map +1 -1
- package/dist/index380.js +9 -4
- package/dist/index380.js.map +1 -1
- package/dist/index381.js +304 -9
- package/dist/index381.js.map +1 -1
- package/dist/index382.js +4 -339
- package/dist/index382.js.map +1 -1
- package/dist/index383.js +21 -5
- package/dist/index383.js.map +1 -1
- package/dist/index384.js +106 -16
- package/dist/index384.js.map +1 -1
- package/dist/index385.js +19 -109
- package/dist/index385.js.map +1 -1
- package/dist/index386.js +18 -18
- package/dist/index386.js.map +1 -1
- package/dist/index387.js +14 -19
- package/dist/index387.js.map +1 -1
- package/dist/index388.js +12 -4
- package/dist/index388.js.map +1 -1
- package/dist/index389.js +113 -20
- package/dist/index389.js.map +1 -1
- package/dist/index390.js +5 -11
- package/dist/index390.js.map +1 -1
- package/dist/index391.js +28 -85
- package/dist/index391.js.map +1 -1
- package/dist/index392.js +9 -9
- package/dist/index392.js.map +1 -1
- package/dist/index393.js +6 -29
- package/dist/index393.js.map +1 -1
- package/dist/index394.js +254 -10
- package/dist/index394.js.map +1 -1
- package/dist/index395.js +12 -6
- package/dist/index395.js.map +1 -1
- package/dist/index396.js +11 -252
- package/dist/index396.js.map +1 -1
- package/dist/index397.js +6 -11
- package/dist/index397.js.map +1 -1
- package/dist/index398.js +22 -10
- package/dist/index398.js.map +1 -1
- package/dist/index399.js +22 -6
- package/dist/index399.js.map +1 -1
- package/dist/index4.js.map +1 -1
- package/dist/index400.js +103 -21
- package/dist/index400.js.map +1 -1
- package/dist/index401.js +15 -23
- package/dist/index401.js.map +1 -1
- package/dist/index402.js +11 -108
- package/dist/index402.js.map +1 -1
- package/dist/index403.js +10 -15
- package/dist/index403.js.map +1 -1
- package/dist/index404.js +237 -10
- package/dist/index404.js.map +1 -1
- package/dist/index405.js +27 -9
- package/dist/index405.js.map +1 -1
- package/dist/index406.js +33 -238
- package/dist/index406.js.map +1 -1
- package/dist/index407.js +11 -30
- package/dist/index407.js.map +1 -1
- package/dist/index408.js +118 -48
- package/dist/index408.js.map +1 -1
- package/dist/index409.js +39 -11
- package/dist/index409.js.map +1 -1
- package/dist/index410.js +18 -121
- package/dist/index410.js.map +1 -1
- package/dist/index411.js +11 -39
- package/dist/index411.js.map +1 -1
- package/dist/index412.js +21 -24
- package/dist/index412.js.map +1 -1
- package/dist/index413.js +17 -11
- package/dist/index413.js.map +1 -1
- package/dist/index414.js +10 -20
- package/dist/index414.js.map +1 -1
- package/dist/index415.js +4 -17
- package/dist/index415.js.map +1 -1
- package/dist/index416.js +300 -14
- package/dist/index416.js.map +1 -1
- package/dist/index417.js +61 -323
- package/dist/index417.js.map +1 -1
- package/dist/index418.js +4 -63
- package/dist/index418.js.map +1 -1
- package/dist/index419.js +28 -4
- package/dist/index419.js.map +1 -1
- package/dist/index420.js +468 -25
- package/dist/index420.js.map +1 -1
- package/dist/index421.js +250 -452
- package/dist/index421.js.map +1 -1
- package/dist/index6.js.map +1 -1
- package/dist/index7.js +91 -133
- package/dist/index7.js.map +1 -1
- package/dist/index70.js +2 -2
- package/dist/index70.js.map +1 -1
- package/dist/index71.js +11 -4
- package/dist/index71.js.map +1 -1
- package/dist/index72.js +1 -3
- package/dist/index72.js.map +1 -1
- package/dist/index8.js.map +1 -1
- package/dist/index9.js +16 -19
- package/dist/index9.js.map +1 -1
- package/dist/test-only/TestCoverageTestBadge/index.d.ts +1 -1
- package/dist/test-only/TestCoverageTestBadge/index.d.ts.map +1 -1
- package/package.json +15 -15
- package/dist/index422.js +0 -272
- package/dist/index422.js.map +0 -1
package/dist/index358.js
CHANGED
|
@@ -1,14 +1,132 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
var t = /* @__PURE__ */ new Set(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { getCountryCallingCode as e } from "./index355.js";
|
|
2
|
+
import { getCountryList as t } from "./index357.js";
|
|
3
|
+
var n = t(), r = /* @__PURE__ */ new Map(), i = "__default_locale__", a = Array.from(new Set(n.map((t) => e(t)))).sort((e, t) => t.length - e.length);
|
|
4
|
+
a.reduce((e, t) => Math.max(e, t.length), 0);
|
|
5
|
+
var o = [
|
|
6
|
+
"0011",
|
|
7
|
+
"001",
|
|
8
|
+
"011",
|
|
9
|
+
"00",
|
|
10
|
+
"810"
|
|
11
|
+
];
|
|
12
|
+
function s(e) {
|
|
13
|
+
return e && n.includes(e) ? e : "US";
|
|
14
|
+
}
|
|
15
|
+
function c(e) {
|
|
16
|
+
if (typeof Intl > "u" || Intl.DisplayNames === void 0) return null;
|
|
17
|
+
try {
|
|
18
|
+
let t = Array.isArray(e) ? e : e ? [e] : void 0;
|
|
19
|
+
return new Intl.DisplayNames(t, { type: "region" });
|
|
20
|
+
} catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function l(t) {
|
|
25
|
+
let r = c(t), i = c("en");
|
|
26
|
+
return n.map((t) => {
|
|
27
|
+
let n = e(t), a = r?.of(t) ?? i?.of(t) ?? t, o = i?.of(t) ?? a, s = x(t), c = Array.from(new Set([
|
|
28
|
+
a,
|
|
29
|
+
o,
|
|
30
|
+
t.toUpperCase(),
|
|
31
|
+
t.toLowerCase(),
|
|
32
|
+
...s
|
|
33
|
+
].filter(Boolean)));
|
|
34
|
+
return {
|
|
35
|
+
value: t,
|
|
36
|
+
name: a,
|
|
37
|
+
dialCode: n,
|
|
38
|
+
label: `${a} (+${n})`,
|
|
39
|
+
flag: g(t),
|
|
40
|
+
searchableTokens: c,
|
|
41
|
+
normalizedSearchableTokens: c.map((e) => y(e))
|
|
42
|
+
};
|
|
43
|
+
}).sort((e, t) => {
|
|
44
|
+
let n = u(e.value), r = u(t.value);
|
|
45
|
+
return n === r ? e.name.localeCompare(t.name) : n - r;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function u(t) {
|
|
49
|
+
return t === "US" ? 0 : t === "CA" ? 1 : e(t) === "1" ? 2 : 3;
|
|
50
|
+
}
|
|
51
|
+
function d(e) {
|
|
52
|
+
return e ? Array.isArray(e) ? e.join("\0") : e : i;
|
|
53
|
+
}
|
|
54
|
+
function f(e) {
|
|
55
|
+
if (e !== i) {
|
|
56
|
+
if (e.includes("\0")) {
|
|
57
|
+
let t = e.split("\0").filter(Boolean);
|
|
58
|
+
return t.length === 0 ? void 0 : t.length === 1 ? t[0] ?? void 0 : t;
|
|
59
|
+
}
|
|
60
|
+
return e;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function p(e, t) {
|
|
64
|
+
let n = r.get(t);
|
|
65
|
+
if (n) return n;
|
|
66
|
+
let i = l(e);
|
|
67
|
+
return r.set(t, i), i;
|
|
68
|
+
}
|
|
69
|
+
function m(e) {
|
|
70
|
+
return {
|
|
71
|
+
code: e.value,
|
|
72
|
+
name: e.name,
|
|
73
|
+
dialCode: e.dialCode,
|
|
74
|
+
flag: e.flag
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function h(t) {
|
|
78
|
+
return {
|
|
79
|
+
code: t,
|
|
80
|
+
name: t,
|
|
81
|
+
dialCode: e(t),
|
|
82
|
+
flag: g(t)
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function g(e) {
|
|
86
|
+
let t = e?.toUpperCase();
|
|
87
|
+
if (!t || t.length !== 2 || /[^A-Z]/.test(t)) return "";
|
|
88
|
+
let n = 127397;
|
|
89
|
+
return String.fromCodePoint(t.charCodeAt(0) + n, t.charCodeAt(1) + n);
|
|
90
|
+
}
|
|
91
|
+
var _ = /[\u0300-\u036f]/g;
|
|
92
|
+
function v(e) {
|
|
93
|
+
return e.normalize("NFD").replace(_, "");
|
|
94
|
+
}
|
|
95
|
+
function y(e) {
|
|
96
|
+
return v(e).toLowerCase();
|
|
97
|
+
}
|
|
98
|
+
function b(e, t) {
|
|
99
|
+
let n = 2 ** 53 - 1;
|
|
100
|
+
for (let r of e) {
|
|
101
|
+
let e = r.indexOf(t);
|
|
102
|
+
e >= 0 && e < n && (n = e);
|
|
103
|
+
}
|
|
104
|
+
return n === 2 ** 53 - 1 ? 2 ** 53 - 1 : n;
|
|
105
|
+
}
|
|
106
|
+
function x(e) {
|
|
107
|
+
switch (e) {
|
|
108
|
+
case "US": return [
|
|
109
|
+
"USA",
|
|
110
|
+
"United States",
|
|
111
|
+
"America",
|
|
112
|
+
"United States of America"
|
|
113
|
+
];
|
|
114
|
+
case "GB": return [
|
|
115
|
+
"UK",
|
|
116
|
+
"United Kingdom",
|
|
117
|
+
"Great Britain",
|
|
118
|
+
"England"
|
|
119
|
+
];
|
|
120
|
+
case "AE": return ["UAE", "United Arab Emirates"];
|
|
121
|
+
case "KR": return ["South Korea", "Korea"];
|
|
122
|
+
case "CN": return ["China", "PRC"];
|
|
123
|
+
case "CD": return ["DRC", "Congo-Kinshasa"];
|
|
124
|
+
case "CG": return ["Congo-Brazzaville"];
|
|
125
|
+
case "BR": return ["Brazil"];
|
|
126
|
+
default: return [];
|
|
127
|
+
}
|
|
10
128
|
}
|
|
11
129
|
//#endregion
|
|
12
|
-
export {
|
|
130
|
+
export { o as COMMON_IDD_PREFIXES, a as COUNTRY_DIAL_CODES, h as buildFallbackSelectedCountry, p as getCachedCountryOptions, d as getLocaleCacheKey, s as getValidCountry, y as normalizeSearchValue, b as optionMatchIndex, f as parseLocaleCacheKey, m as toSelectedCountry };
|
|
13
131
|
|
|
14
132
|
//# sourceMappingURL=index358.js.map
|
package/dist/index358.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index358.js","names":[
|
|
1
|
+
{"version":3,"file":"index358.js","names":[],"sources":["../src/components/PhoneNumberInput/country-options.ts"],"sourcesContent":["import type { CountryCode } from \"libphonenumber-js\"\nimport { getCountryCallingCode } from \"libphonenumber-js\"\n\nimport type { CountryOption, PhoneNumberSelectedCountry } from \"./types\"\nimport { getCountryList } from \"./countries\"\n\n\nexport const DEFAULT_COUNTRY: CountryCode = \"US\"\nconst COUNTRY_OPTIONS = getCountryList()\n\nconst COUNTRY_OPTIONS_CACHE = new Map<string, CountryOption[]>()\nconst DEFAULT_LOCALE_CACHE_KEY = \"__default_locale__\"\nexport const COUNTRY_DIAL_CODES = Array.from(\n new Set(COUNTRY_OPTIONS.map((code) => getCountryCallingCode(code)))\n).sort((a, b) => b.length - a.length)\nexport const MAX_DIAL_CODE_LENGTH = COUNTRY_DIAL_CODES.reduce(\n (max, dial) => Math.max(max, dial.length),\n 0\n)\nexport const COMMON_IDD_PREFIXES = [\"0011\", \"001\", \"011\", \"00\", \"810\"]\n\nexport function getValidCountry(input: CountryCode | undefined) {\n if (!input) {\n return DEFAULT_COUNTRY\n }\n\n return COUNTRY_OPTIONS.includes(input) ? input : DEFAULT_COUNTRY\n}\n\nfunction createDisplayNames(locale?: string | string[]) {\n if (typeof Intl === \"undefined\" || typeof Intl.DisplayNames === \"undefined\") {\n return null\n }\n\n try {\n const locales = Array.isArray(locale) ? locale : locale ? [locale] : undefined\n return new Intl.DisplayNames(locales, { type: \"region\" })\n } catch {\n return null\n }\n}\n\nfunction buildCountryOptions(locale?: string | string[]) {\n const displayNames = createDisplayNames(locale)\n const englishDisplayNames = createDisplayNames(\"en\")\n\n return COUNTRY_OPTIONS\n .map((country) => {\n const dialCode = getCountryCallingCode(country)\n const localizedName = displayNames?.of(country) ?? englishDisplayNames?.of(country) ?? country\n const englishName = englishDisplayNames?.of(country) ?? localizedName\n const aliasTokens = getCountryAliases(country)\n const searchableTokens = Array.from(\n new Set(\n [localizedName, englishName, country.toUpperCase(), country.toLowerCase(), ...aliasTokens].filter(\n Boolean\n )\n )\n ) as string[]\n return {\n value: country,\n name: localizedName,\n dialCode,\n label: `${localizedName} (+${dialCode})`,\n flag: countryCodeToFlagEmoji(country),\n searchableTokens,\n normalizedSearchableTokens: searchableTokens.map((token) => normalizeSearchValue(token)),\n }\n })\n .sort((a, b) => {\n const priorityA = getCountryPriority(a.value)\n const priorityB = getCountryPriority(b.value)\n if (priorityA !== priorityB) {\n return priorityA - priorityB\n }\n return a.name.localeCompare(b.name)\n })\n}\n\nfunction getCountryPriority(code: CountryCode) {\n if (code === \"US\") return 0\n if (code === \"CA\") return 1\n if (getCountryCallingCode(code) === \"1\") return 2\n return 3\n}\n\nexport function getLocaleCacheKey(locale?: string | string[]) {\n if (!locale) {\n return DEFAULT_LOCALE_CACHE_KEY\n }\n if (Array.isArray(locale)) {\n return locale.join(\"\\u0000\")\n }\n return locale\n}\n\nexport function parseLocaleCacheKey(cacheKey: string): string | string[] | undefined {\n if (cacheKey === DEFAULT_LOCALE_CACHE_KEY) {\n return undefined\n }\n\n if (cacheKey.includes(\"\\u0000\")) {\n const parts = cacheKey.split(\"\\u0000\").filter(Boolean)\n if (parts.length === 0) {\n return undefined\n }\n if (parts.length === 1) {\n return parts[0] ?? undefined\n }\n return parts\n }\n\n return cacheKey\n}\n\nexport function getCachedCountryOptions(locale: string | string[] | undefined, cacheKey: string) {\n const cached = COUNTRY_OPTIONS_CACHE.get(cacheKey)\n if (cached) {\n return cached\n }\n const built = buildCountryOptions(locale)\n COUNTRY_OPTIONS_CACHE.set(cacheKey, built)\n return built\n}\n\nexport function toSelectedCountry(option: CountryOption): PhoneNumberSelectedCountry {\n return {\n code: option.value,\n name: option.name,\n dialCode: option.dialCode,\n flag: option.flag,\n }\n}\n\nexport function buildFallbackSelectedCountry(country: CountryCode): PhoneNumberSelectedCountry {\n return {\n code: country,\n name: country,\n dialCode: getCountryCallingCode(country),\n flag: countryCodeToFlagEmoji(country),\n }\n}\n\nfunction countryCodeToFlagEmoji(country: CountryCode) {\n const upper = country?.toUpperCase()\n\n if (!upper || upper.length !== 2 || /[^A-Z]/.test(upper)) {\n return \"\"\n }\n\n const base = 127397\n return String.fromCodePoint(\n upper.charCodeAt(0) + base,\n upper.charCodeAt(1) + base\n )\n}\n\nconst DIACRITICS_REGEX = /[\\u0300-\\u036f]/g\n\nfunction stripDiacritics(value: string) {\n return value.normalize(\"NFD\").replace(DIACRITICS_REGEX, \"\")\n}\n\nexport function normalizeSearchValue(value: string) {\n return stripDiacritics(value).toLowerCase()\n}\n\nexport function optionMatchIndex(tokens: string[], query: string) {\n let best = Number.MAX_SAFE_INTEGER\n for (const token of tokens) {\n const index = token.indexOf(query)\n if (index >= 0 && index < best) {\n best = index\n }\n }\n return best === Number.MAX_SAFE_INTEGER ? Number.MAX_SAFE_INTEGER : best\n}\n\nfunction getCountryAliases(code: CountryCode): string[] {\n switch (code) {\n case \"US\":\n return [\"USA\", \"United States\", \"America\", \"United States of America\"]\n case \"GB\":\n return [\"UK\", \"United Kingdom\", \"Great Britain\", \"England\"]\n case \"AE\":\n return [\"UAE\", \"United Arab Emirates\"]\n case \"KR\":\n return [\"South Korea\", \"Korea\"]\n case \"CN\":\n return [\"China\", \"PRC\"]\n case \"CD\":\n return [\"DRC\", \"Congo-Kinshasa\"]\n case \"CG\":\n return [\"Congo-Brazzaville\"]\n case \"BR\":\n return [\"Brazil\"]\n default:\n return []\n }\n}\n\n"],"mappings":";;AAQA,IAAM,IAAkB,EAAe,GAEjC,oBAAwB,IAAI,IAA6B,GACzD,IAA2B,sBACpB,IAAqB,MAAM,KACtC,IAAI,IAAI,EAAgB,KAAK,MAAS,EAAsB,CAAI,CAAC,CA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AS,EAAgB,GAAe;CACtC,OAAO,EAAM,UAAU,KAAK,CAAC,CAAC,QAAQ,GAAkB,EAAE;AAC5D;AAEA,SAAgB,EAAqB,GAAe;CAClD,OAAO,EAAgB,CAAK,CAAC,CAAC,YAAY;AAC5C;AAEA,SAAgB,EAAiB,GAAkB,GAAe;CAChE,IAAI;CACJ,KAAK,IAAM,KAAS,GAAQ;EAC1B,IAAM,IAAQ,EAAM,QAAQ,CAAK;EACjC,AAAI,KAAS,KAAK,IAAQ,MACxB,IAAO;CAEX;CACA,OAAO,kCAA6D;AACtE;AAEA,SAAS,EAAkB,GAA6B;CACtD,QAAQ,GAAR;EACA,KAAK,MACH,OAAO;GAAC;GAAO;GAAiB;GAAW;EAA0B;EACvE,KAAK,MACH,OAAO;GAAC;GAAM;GAAkB;GAAiB;EAAS;EAC5D,KAAK,MACH,OAAO,CAAC,OAAO,sBAAsB;EACvC,KAAK,MACH,OAAO,CAAC,eAAe,OAAO;EAChC,KAAK,MACH,OAAO,CAAC,SAAS,KAAK;EACxB,KAAK,MACH,OAAO,CAAC,OAAO,gBAAgB;EACjC,KAAK,MACH,OAAO,CAAC,mBAAmB;EAC7B,KAAK,MACH,OAAO,CAAC,QAAQ;EAClB,SACE,OAAO,CAAA;CACT;AACF"}
|
package/dist/index359.js
CHANGED
|
@@ -1,132 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
function
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function l(t) {
|
|
25
|
-
let r = c(t), i = c("en");
|
|
26
|
-
return n.map((t) => {
|
|
27
|
-
let n = e(t), a = r?.of(t) ?? i?.of(t) ?? t, o = i?.of(t) ?? a, s = x(t), c = Array.from(new Set([
|
|
28
|
-
a,
|
|
29
|
-
o,
|
|
30
|
-
t.toUpperCase(),
|
|
31
|
-
t.toLowerCase(),
|
|
32
|
-
...s
|
|
33
|
-
].filter(Boolean)));
|
|
34
|
-
return {
|
|
35
|
-
value: t,
|
|
36
|
-
name: a,
|
|
37
|
-
dialCode: n,
|
|
38
|
-
label: `${a} (+${n})`,
|
|
39
|
-
flag: g(t),
|
|
40
|
-
searchableTokens: c,
|
|
41
|
-
normalizedSearchableTokens: c.map((e) => y(e))
|
|
42
|
-
};
|
|
43
|
-
}).sort((e, t) => {
|
|
44
|
-
let n = u(e.value), r = u(t.value);
|
|
45
|
-
return n === r ? e.name.localeCompare(t.name) : n - r;
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
function u(t) {
|
|
49
|
-
return t === "US" ? 0 : t === "CA" ? 1 : e(t) === "1" ? 2 : 3;
|
|
50
|
-
}
|
|
51
|
-
function d(e) {
|
|
52
|
-
return e ? Array.isArray(e) ? e.join("\0") : e : i;
|
|
53
|
-
}
|
|
54
|
-
function f(e) {
|
|
55
|
-
if (e !== i) {
|
|
56
|
-
if (e.includes("\0")) {
|
|
57
|
-
let t = e.split("\0").filter(Boolean);
|
|
58
|
-
return t.length === 0 ? void 0 : t.length === 1 ? t[0] ?? void 0 : t;
|
|
59
|
-
}
|
|
60
|
-
return e;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function p(e, t) {
|
|
64
|
-
let n = r.get(t);
|
|
65
|
-
if (n) return n;
|
|
66
|
-
let i = l(e);
|
|
67
|
-
return r.set(t, i), i;
|
|
68
|
-
}
|
|
69
|
-
function m(e) {
|
|
70
|
-
return {
|
|
71
|
-
code: e.value,
|
|
72
|
-
name: e.name,
|
|
73
|
-
dialCode: e.dialCode,
|
|
74
|
-
flag: e.flag
|
|
1
|
+
import { validatePhoneNumberLength as e } from "./index352.js";
|
|
2
|
+
import { AsYouType as t } from "./index353.js";
|
|
3
|
+
//#region src/components/PhoneNumberInput/normalization.ts
|
|
4
|
+
function n(e) {
|
|
5
|
+
return e.replace(/\D/g, "");
|
|
6
|
+
}
|
|
7
|
+
var r = {
|
|
8
|
+
GG: "GB",
|
|
9
|
+
JE: "GB",
|
|
10
|
+
IM: "GB"
|
|
11
|
+
};
|
|
12
|
+
function i(e) {
|
|
13
|
+
if (e) return r[e] ?? e;
|
|
14
|
+
}
|
|
15
|
+
function a(e, r) {
|
|
16
|
+
if (e === "+") return {
|
|
17
|
+
international: "+",
|
|
18
|
+
national: "",
|
|
19
|
+
formatted: "+",
|
|
20
|
+
phoneNumber: null,
|
|
21
|
+
detectedCountry: void 0
|
|
75
22
|
};
|
|
76
|
-
|
|
77
|
-
function h(t) {
|
|
23
|
+
let a = r ? new t(r) : new t(), o = a.input(e), s = a.getNumber(), c = i(s?.country ?? a.country ?? void 0), l = s?.formatInternational() ?? o;
|
|
78
24
|
return {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
25
|
+
international: l,
|
|
26
|
+
national: s?.formatNational() ?? n(l),
|
|
27
|
+
formatted: o,
|
|
28
|
+
phoneNumber: s,
|
|
29
|
+
detectedCountry: c
|
|
83
30
|
};
|
|
84
31
|
}
|
|
85
|
-
function
|
|
86
|
-
|
|
87
|
-
if (!t || t.length !== 2 || /[^A-Z]/.test(t)) return "";
|
|
88
|
-
let n = 127397;
|
|
89
|
-
return String.fromCodePoint(t.charCodeAt(0) + n, t.charCodeAt(1) + n);
|
|
90
|
-
}
|
|
91
|
-
var _ = /[\u0300-\u036f]/g;
|
|
92
|
-
function v(e) {
|
|
93
|
-
return e.normalize("NFD").replace(_, "");
|
|
94
|
-
}
|
|
95
|
-
function y(e) {
|
|
96
|
-
return v(e).toLowerCase();
|
|
32
|
+
function o(e, t) {
|
|
33
|
+
return e.startsWith(t) ? e.slice(t.length) : e;
|
|
97
34
|
}
|
|
98
|
-
function
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return n === 2 ** 53 - 1 ? 2 ** 53 - 1 : n;
|
|
105
|
-
}
|
|
106
|
-
function x(e) {
|
|
107
|
-
switch (e) {
|
|
108
|
-
case "US": return [
|
|
109
|
-
"USA",
|
|
110
|
-
"United States",
|
|
111
|
-
"America",
|
|
112
|
-
"United States of America"
|
|
113
|
-
];
|
|
114
|
-
case "GB": return [
|
|
115
|
-
"UK",
|
|
116
|
-
"United Kingdom",
|
|
117
|
-
"Great Britain",
|
|
118
|
-
"England"
|
|
119
|
-
];
|
|
120
|
-
case "AE": return ["UAE", "United Arab Emirates"];
|
|
121
|
-
case "KR": return ["South Korea", "Korea"];
|
|
122
|
-
case "CN": return ["China", "PRC"];
|
|
123
|
-
case "CD": return ["DRC", "Congo-Kinshasa"];
|
|
124
|
-
case "CG": return ["Congo-Brazzaville"];
|
|
125
|
-
case "BR": return ["Brazil"];
|
|
126
|
-
default: return [];
|
|
35
|
+
function s(t, n) {
|
|
36
|
+
if (!n || !t) return null;
|
|
37
|
+
try {
|
|
38
|
+
return e(t, n) === "TOO_LONG" ? "TOO_LONG" : null;
|
|
39
|
+
} catch {
|
|
40
|
+
return null;
|
|
127
41
|
}
|
|
128
42
|
}
|
|
129
43
|
//#endregion
|
|
130
|
-
export {
|
|
44
|
+
export { a as formatWithAsYouType, s as getLengthIssue, n as sanitizeDigits, o as stripPrefix };
|
|
131
45
|
|
|
132
46
|
//# sourceMappingURL=index359.js.map
|
package/dist/index359.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index359.js","names":["CountryCode","getCountryCallingCode","CountryOption","PhoneNumberSelectedCountry","getCountryList","DEFAULT_COUNTRY","COUNTRY_OPTIONS","COUNTRY_OPTIONS_CACHE","Map","DEFAULT_LOCALE_CACHE_KEY","COUNTRY_DIAL_CODES","Array","from","Set","map","code","sort","a","b","length","MAX_DIAL_CODE_LENGTH","reduce","max","dial","Math","COMMON_IDD_PREFIXES","getValidCountry","input","includes","createDisplayNames","locale","Intl","DisplayNames","locales","isArray","undefined","type","buildCountryOptions","displayNames","englishDisplayNames","country","dialCode","localizedName","of","englishName","aliasTokens","getCountryAliases","searchableTokens","toUpperCase","toLowerCase","filter","Boolean","value","name","label","flag","countryCodeToFlagEmoji","normalizedSearchableTokens","token","normalizeSearchValue","priorityA","getCountryPriority","priorityB","localeCompare","getLocaleCacheKey","join","parseLocaleCacheKey","cacheKey","parts","split","getCachedCountryOptions","cached","get","built","set","toSelectedCountry","option","buildFallbackSelectedCountry","upper","test","base","String","fromCodePoint","charCodeAt","DIACRITICS_REGEX","stripDiacritics","normalize","replace","optionMatchIndex","tokens","query","best","Number","MAX_SAFE_INTEGER","index","indexOf"],"sources":["../src/components/PhoneNumberInput/country-options.ts"],"sourcesContent":["import type { CountryCode } from \"libphonenumber-js\"\nimport { getCountryCallingCode } from \"libphonenumber-js\"\n\nimport type { CountryOption, PhoneNumberSelectedCountry } from \"./types\"\nimport { getCountryList } from \"./countries\"\n\n\nexport const DEFAULT_COUNTRY: CountryCode = \"US\"\nconst COUNTRY_OPTIONS = getCountryList()\n\nconst COUNTRY_OPTIONS_CACHE = new Map<string, CountryOption[]>()\nconst DEFAULT_LOCALE_CACHE_KEY = \"__default_locale__\"\nexport const COUNTRY_DIAL_CODES = Array.from(\n new Set(COUNTRY_OPTIONS.map((code) => getCountryCallingCode(code)))\n).sort((a, b) => b.length - a.length)\nexport const MAX_DIAL_CODE_LENGTH = COUNTRY_DIAL_CODES.reduce(\n (max, dial) => Math.max(max, dial.length),\n 0\n)\nexport const COMMON_IDD_PREFIXES = [\"0011\", \"001\", \"011\", \"00\", \"810\"]\n\nexport function getValidCountry(input: CountryCode | undefined) {\n if (!input) {\n return DEFAULT_COUNTRY\n }\n\n return COUNTRY_OPTIONS.includes(input) ? input : DEFAULT_COUNTRY\n}\n\nfunction createDisplayNames(locale?: string | string[]) {\n if (typeof Intl === \"undefined\" || typeof Intl.DisplayNames === \"undefined\") {\n return null\n }\n\n try {\n const locales = Array.isArray(locale) ? locale : locale ? [locale] : undefined\n return new Intl.DisplayNames(locales, { type: \"region\" })\n } catch {\n return null\n }\n}\n\nfunction buildCountryOptions(locale?: string | string[]) {\n const displayNames = createDisplayNames(locale)\n const englishDisplayNames = createDisplayNames(\"en\")\n\n return COUNTRY_OPTIONS\n .map((country) => {\n const dialCode = getCountryCallingCode(country)\n const localizedName = displayNames?.of(country) ?? englishDisplayNames?.of(country) ?? country\n const englishName = englishDisplayNames?.of(country) ?? localizedName\n const aliasTokens = getCountryAliases(country)\n const searchableTokens = Array.from(\n new Set(\n [localizedName, englishName, country.toUpperCase(), country.toLowerCase(), ...aliasTokens].filter(\n Boolean\n )\n )\n ) as string[]\n return {\n value: country,\n name: localizedName,\n dialCode,\n label: `${localizedName} (+${dialCode})`,\n flag: countryCodeToFlagEmoji(country),\n searchableTokens,\n normalizedSearchableTokens: searchableTokens.map((token) => normalizeSearchValue(token)),\n }\n })\n .sort((a, b) => {\n const priorityA = getCountryPriority(a.value)\n const priorityB = getCountryPriority(b.value)\n if (priorityA !== priorityB) {\n return priorityA - priorityB\n }\n return a.name.localeCompare(b.name)\n })\n}\n\nfunction getCountryPriority(code: CountryCode) {\n if (code === \"US\") return 0\n if (code === \"CA\") return 1\n if (getCountryCallingCode(code) === \"1\") return 2\n return 3\n}\n\nexport function getLocaleCacheKey(locale?: string | string[]) {\n if (!locale) {\n return DEFAULT_LOCALE_CACHE_KEY\n }\n if (Array.isArray(locale)) {\n return locale.join(\"\\u0000\")\n }\n return locale\n}\n\nexport function parseLocaleCacheKey(cacheKey: string): string | string[] | undefined {\n if (cacheKey === DEFAULT_LOCALE_CACHE_KEY) {\n return undefined\n }\n\n if (cacheKey.includes(\"\\u0000\")) {\n const parts = cacheKey.split(\"\\u0000\").filter(Boolean)\n if (parts.length === 0) {\n return undefined\n }\n if (parts.length === 1) {\n return parts[0] ?? undefined\n }\n return parts\n }\n\n return cacheKey\n}\n\nexport function getCachedCountryOptions(locale: string | string[] | undefined, cacheKey: string) {\n const cached = COUNTRY_OPTIONS_CACHE.get(cacheKey)\n if (cached) {\n return cached\n }\n const built = buildCountryOptions(locale)\n COUNTRY_OPTIONS_CACHE.set(cacheKey, built)\n return built\n}\n\nexport function toSelectedCountry(option: CountryOption): PhoneNumberSelectedCountry {\n return {\n code: option.value,\n name: option.name,\n dialCode: option.dialCode,\n flag: option.flag,\n }\n}\n\nexport function buildFallbackSelectedCountry(country: CountryCode): PhoneNumberSelectedCountry {\n return {\n code: country,\n name: country,\n dialCode: getCountryCallingCode(country),\n flag: countryCodeToFlagEmoji(country),\n }\n}\n\nfunction countryCodeToFlagEmoji(country: CountryCode) {\n const upper = country?.toUpperCase()\n\n if (!upper || upper.length !== 2 || /[^A-Z]/.test(upper)) {\n return \"\"\n }\n\n const base = 127397\n return String.fromCodePoint(\n upper.charCodeAt(0) + base,\n upper.charCodeAt(1) + base\n )\n}\n\nconst DIACRITICS_REGEX = /[\\u0300-\\u036f]/g\n\nfunction stripDiacritics(value: string) {\n return value.normalize(\"NFD\").replace(DIACRITICS_REGEX, \"\")\n}\n\nexport function normalizeSearchValue(value: string) {\n return stripDiacritics(value).toLowerCase()\n}\n\nexport function optionMatchIndex(tokens: string[], query: string) {\n let best = Number.MAX_SAFE_INTEGER\n for (const token of tokens) {\n const index = token.indexOf(query)\n if (index >= 0 && index < best) {\n best = index\n }\n }\n return best === Number.MAX_SAFE_INTEGER ? Number.MAX_SAFE_INTEGER : best\n}\n\nfunction getCountryAliases(code: CountryCode): string[] {\n switch (code) {\n case \"US\":\n return [\"USA\", \"United States\", \"America\", \"United States of America\"]\n case \"GB\":\n return [\"UK\", \"United Kingdom\", \"Great Britain\", \"England\"]\n case \"AE\":\n return [\"UAE\", \"United Arab Emirates\"]\n case \"KR\":\n return [\"South Korea\", \"Korea\"]\n case \"CN\":\n return [\"China\", \"PRC\"]\n case \"CD\":\n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OAAO,CAAC,eAAe,OAAO;EAChC,KAAK,MACH,OAAO,CAAC,SAAS,KAAK;EACxB,KAAK,MACH,OAAO,CAAC,OAAO,gBAAgB;EACjC,KAAK,MACH,OAAO,CAAC,mBAAmB;EAC7B,KAAK,MACH,OAAO,CAAC,QAAQ;EAClB,SACE,OAAO,CAAA;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"index359.js","names":[],"sources":["../src/components/PhoneNumberInput/normalization.ts"],"sourcesContent":["import type { CountryCode } from \"libphonenumber-js\"\nimport { AsYouType, validatePhoneNumberLength } from \"libphonenumber-js\"\n\n\nexport type LengthIssue = \"TOO_LONG\"\n\nexport function sanitizeDigits(value: string) {\n return value.replace(/\\D/g, \"\")\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\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 }\n }\n\n const formatter = baseCountry ? new AsYouType(baseCountry) : new AsYouType()\n const formatted = formatter.input(value)\n const phoneNumber = formatter.getNumber()\n const detectedCountry = canonicalizeDetectedCountry(\n (phoneNumber?.country ?? formatter.country ?? undefined) as CountryCode | undefined\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 }\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"],"mappings":";;;AAMA,SAAgB,EAAe,GAAe;CAC5C,OAAO,EAAM,QAAQ,OAAO,EAAE;AAChC;AAEA,IAAM,IAAwE;CAC5E,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,SAAS,EAA4B,GAA6D;CAC3F,OAGL,OAAO,EAA2B,MAAc;AAClD;AAEA,SAAgB,EAAoB,GAAe,GAA2B;CAC5E,IAAI,MAAU,KACZ,OAAO;EACL,eAAe;EACf,UAAU;EACV,WAAW;EACX,aAAa;EACb,iBAAiB,KAAA;CACnB;CAGF,IAAM,IAAY,IAAc,IAAI,EAAU,CAAW,IAAI,IAAI,EAAU,GACrE,IAAY,EAAU,MAAM,CAAK,GACjC,IAAc,EAAU,UAAU,GAClC,IAAkB,EACrB,GAAa,WAAW,EAAU,WAAW,KAAA,CAChD,GACM,IAAgB,GAAa,oBAAoB,KAAK;CAG5D,OAAO;EACL;EACA,UAJe,GAAa,eAAe,KAAK,EAAe,CAAa;EAK5E;EACA;EACA;CACF;AACF;AAEA,SAAgB,EAAY,GAAe,GAAgB;CACzD,OAAO,EAAM,WAAW,CAAM,IAAI,EAAM,MAAM,EAAO,MAAM,IAAI;AACjE;AAEA,SAAgB,EAAe,GAAe,GAAsD;CAClG,IAAI,CAAC,KAAW,CAAC,GACf,OAAO;CAGT,IAAI;EAEF,OADe,EAA0B,GAAO,CACzC,MAAW,aAAa,aAAa;CAC9C,QAAQ;EACN,OAAO;CACT;AACF"}
|
package/dist/index360.js
CHANGED
|
@@ -1,46 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
function
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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 !== "+";
|
|
20
|
+
}
|
|
21
|
+
function i(e, t) {
|
|
22
|
+
let n = t;
|
|
23
|
+
for (; n > 0 && r(e[n - 1] ?? "");) --n;
|
|
24
|
+
return n;
|
|
25
|
+
}
|
|
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("+");
|
|
24
33
|
return {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
|
30
42
|
};
|
|
31
43
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
+
};
|
|
41
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
|
+
};
|
|
42
68
|
}
|
|
43
69
|
//#endregion
|
|
44
|
-
export {
|
|
70
|
+
export { o as captureSelectionSnapshot, s as resolveSelection, i as skipFormattingCharactersLeft, a as skipFormattingCharactersRight };
|
|
45
71
|
|
|
46
72
|
//# sourceMappingURL=index360.js.map
|
package/dist/index360.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index360.js","names":[
|
|
1
|
+
{"version":3,"file":"index360.js","names":[],"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,SAAS,EAAiB,GAAc;CACtC,IAAI,CAAC,GACH,OAAO;CAET,IAAM,IAAO,EAAK,WAAW,CAAC;CAC9B,OAAO,KAAQ,MAAM,KAAQ;AAC/B;AAEA,SAAS,EAAkB,GAAe,GAAe;CACvD,IAAI,IAAQ,GACN,IAAQ,KAAK,IAAI,GAAO,EAAM,MAAM;CAC1C,KAAK,IAAI,IAAW,GAAG,IAAW,GAAO,KAAY,GACnD,AAAI,EAAiB,EAAM,MAAa,EAAE,MACxC,KAAS;CAGb,OAAO;AACT;AAEA,SAAS,EAAuB,GAAe,GAAoB;CACjE,IAAI,KAAc,GAChB,OAAO,EAAM,WAAW,GAAG,IAAI,KAAK,IAAI,GAAG,EAAM,MAAM,IAAI;CAG7D,IAAI,IAAO;CAC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