@fluidattacks/design 3.1.12 → 3.1.13

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.
Files changed (172) hide show
  1. package/dist/components/@core/index.js +2 -2
  2. package/dist/components/accordion/accordion-content/index.js +18 -5
  3. package/dist/components/accordion/index.js +71 -14
  4. package/dist/components/alert/index.js +108 -57
  5. package/dist/components/button/index.js +64 -13
  6. package/dist/components/card/card-header/index.js +78 -9
  7. package/dist/components/card/card-with-image/index.js +88 -13
  8. package/dist/components/card/card-with-input/index.js +72 -23
  9. package/dist/components/card/card-with-selector/index.js +63 -8
  10. package/dist/components/card/card-with-switch/index.js +46 -8
  11. package/dist/components/carousel/index.js +54 -28
  12. package/dist/components/checkbox/index.js +66 -32
  13. package/dist/components/cloud-image/index.js +2 -2
  14. package/dist/components/code-snippet/index.js +64 -19
  15. package/dist/components/code-snippet/location-code/index.js +146 -100
  16. package/dist/components/colors/index.js +220 -5
  17. package/dist/components/confirm-dialog/index.js +41 -18
  18. package/dist/components/container/index.js +39 -15
  19. package/dist/components/content-card/category-tag/index.js +37 -8
  20. package/dist/components/content-card/event-date/index.js +53 -10
  21. package/dist/components/content-card/index.js +118 -13
  22. package/dist/components/content-card-carousel/index.js +87 -7
  23. package/dist/components/content-card-carousel/scroll-buttons/index.js +1 -1
  24. package/dist/components/divider/index.js +22 -7
  25. package/dist/components/empty-state/empty-button/index.js +4 -4
  26. package/dist/components/empty-state/index.js +52 -15
  27. package/dist/components/file-preview/index.js +28 -12
  28. package/dist/components/form/index.js +46 -9
  29. package/dist/components/grid-container/index.js +31 -11
  30. package/dist/components/group-selector/index.js +126 -17
  31. package/dist/components/group-selector/option-container/index.js +1 -1
  32. package/dist/components/icon/index.js +78 -18
  33. package/dist/components/icon-button/index.js +63 -14
  34. package/dist/components/indicator-card/index.js +70 -11
  35. package/dist/components/info-sidebar/index.js +107 -7
  36. package/dist/components/inputs/fields/combobox/index.js +141 -21
  37. package/dist/components/inputs/fields/combobox/option/index.js +1 -1
  38. package/dist/components/inputs/fields/date/calendar/cell/index.js +22 -11
  39. package/dist/components/inputs/fields/date/calendar/grid/index.js +21 -10
  40. package/dist/components/inputs/fields/date/calendar/header/index.js +35 -13
  41. package/dist/components/inputs/fields/date/calendar/index.js +26 -11
  42. package/dist/components/inputs/fields/date/index.js +65 -15
  43. package/dist/components/inputs/fields/date-range/calendar/index.js +29 -10
  44. package/dist/components/inputs/fields/date-range/index.js +98 -18
  45. package/dist/components/inputs/fields/date-time/calendar/index.js +44 -15
  46. package/dist/components/inputs/fields/date-time/index.js +65 -14
  47. package/dist/components/inputs/fields/editable/index.js +22 -10
  48. package/dist/components/inputs/fields/input/index.js +74 -10
  49. package/dist/components/inputs/fields/input-file/index.js +114 -21
  50. package/dist/components/inputs/fields/input-tags/index.js +60 -11
  51. package/dist/components/inputs/fields/number/index.js +54 -7
  52. package/dist/components/inputs/fields/number-range/index.js +46 -8
  53. package/dist/components/inputs/fields/phone/index.js +446 -286
  54. package/dist/components/inputs/fields/text-area/index.js +78 -10
  55. package/dist/components/inputs/label/index.js +34 -8
  56. package/dist/components/inputs/outline-container/index.js +98 -12
  57. package/dist/components/inputs/utils/action-button/index.js +28 -7
  58. package/dist/components/inputs/utils/calendar-button/index.js +34 -10
  59. package/dist/components/inputs/utils/date-selector/index.js +60 -6
  60. package/dist/components/inputs/utils/date-time-field/index.js +129 -28
  61. package/dist/components/inputs/utils/dialog/index.js +10 -7
  62. package/dist/components/inputs/utils/number-field/index.js +81 -8
  63. package/dist/components/inputs/utils/popover/index.js +41 -10
  64. package/dist/components/interactive-card/icon/index.js +1 -1
  65. package/dist/components/interactive-card/index.js +110 -7
  66. package/dist/components/language-selector/index.js +34 -10
  67. package/dist/components/language-selector/item-list/index.js +1 -1
  68. package/dist/components/link/index.js +71 -17
  69. package/dist/components/list-item/index.js +64 -13
  70. package/dist/components/little-flag/index.js +26 -9
  71. package/dist/components/loading/index.js +48 -21
  72. package/dist/components/logo/index.js +10 -4
  73. package/dist/components/logo-carousel/index.js +40 -5
  74. package/dist/components/lottie/index.js +12 -7
  75. package/dist/components/menu/index.js +53 -9
  76. package/dist/components/message-banner/index.js +79 -13
  77. package/dist/components/modal/index.js +59 -13
  78. package/dist/components/modal/modal-confirm/index.js +48 -7
  79. package/dist/components/modal/modal-footer/index.js +22 -13
  80. package/dist/components/modal/modal-header/index.js +45 -19
  81. package/dist/components/notification/index.js +65 -20
  82. package/dist/components/notification-sign/index.js +27 -10
  83. package/dist/components/number-input/index.js +58 -21
  84. package/dist/components/oauth-selector/index.js +97 -23
  85. package/dist/components/oauth-selector/option-container/index.js +68 -7
  86. package/dist/components/plan-card/index.js +99 -28
  87. package/dist/components/plan-card/recommended-tag/index.js +23 -2
  88. package/dist/components/pop-up/description/index.js +47 -9
  89. package/dist/components/pop-up/index.js +146 -17
  90. package/dist/components/premium-feature/index.js +56 -16
  91. package/dist/components/priority-score/index.js +24 -9
  92. package/dist/components/progress/index.js +30 -17
  93. package/dist/components/progress-bar/index.js +99 -41
  94. package/dist/components/radio-button/index.js +64 -27
  95. package/dist/components/scroll-button/index.js +33 -15
  96. package/dist/components/search/index.js +77 -35
  97. package/dist/components/search-bar/index.js +211 -24
  98. package/dist/components/search-bar/item-searching/index.js +1 -1
  99. package/dist/components/severity-badge/index.js +66 -6
  100. package/dist/components/severity-overview/badge/index.js +62 -11
  101. package/dist/components/severity-overview/index.js +15 -5
  102. package/dist/components/show-on-hover/index.js +16 -10
  103. package/dist/components/slide-out-menu/index.js +2611 -1164
  104. package/dist/components/slide-out-menu/menu-item/index.js +58 -6
  105. package/dist/components/slider/index.js +79 -48
  106. package/dist/components/slider/thumb/index.js +13 -6
  107. package/dist/components/step-lapse/index.js +81 -23
  108. package/dist/components/table-button/index.js +65 -24
  109. package/dist/components/tabs/fixed-tabs/index.js +24 -4
  110. package/dist/components/tabs/index.js +54 -11
  111. package/dist/components/tabs/tab/index.js +37 -6
  112. package/dist/components/tag/index.js +95 -27
  113. package/dist/components/timeline/card/index.js +1 -1
  114. package/dist/components/timeline/index.js +15 -5
  115. package/dist/components/toggle/index.js +65 -25
  116. package/dist/components/toggle-buttons/index.js +51 -22
  117. package/dist/components/tooltip/index.js +1 -1
  118. package/dist/components/tour/index.js +3897 -1829
  119. package/dist/components/typography/heading/index.js +43 -5
  120. package/dist/components/typography/span/index.js +38 -6
  121. package/dist/components/typography/text/index.js +44 -6
  122. package/dist/components/web-form/index.js +28 -19
  123. package/dist/hooks/index.js +5 -5
  124. package/dist/index-BMHVi812.mjs +234 -0
  125. package/dist/index-BzAniA2J.mjs +135 -0
  126. package/dist/index-C6LbClYh.mjs +146 -0
  127. package/dist/index-CAIe8hBv.mjs +130 -0
  128. package/dist/index-CUQBAqt_.mjs +75 -0
  129. package/dist/index-CWlrSlUk.mjs +68 -0
  130. package/dist/index-Ckmu1TfV.mjs +86 -0
  131. package/dist/index-DwznImvK.mjs +1678 -0
  132. package/dist/index-maWH3JYC.mjs +3561 -0
  133. package/dist/index.js +11 -11
  134. package/dist/styles-B2N0JLw1.mjs +114 -0
  135. package/dist/styles-B64DVBIF.mjs +115 -0
  136. package/dist/{styles-lSVV9kjn.mjs → styles-BXFVwnWT.mjs} +28 -28
  137. package/dist/styles-BZQOqe8p.mjs +141 -0
  138. package/dist/styles-Bdque9TT.mjs +65 -0
  139. package/dist/{styles-CI-I6joH.mjs → styles-BlHspTrz.mjs} +18 -18
  140. package/dist/{styles-Cx93EcVo.mjs → styles-CROOwXEH.mjs} +5 -5
  141. package/dist/styles-CplEd2kw.mjs +228 -0
  142. package/dist/styles-D1eTIklB.mjs +110 -0
  143. package/dist/styles-ePGii_9g.mjs +74 -0
  144. package/dist/use-carousel-CgAF78h3.mjs +23 -0
  145. package/dist/use-click-outside-BUll8Ag-.mjs +18 -0
  146. package/dist/use-cloudinary-image-BCxwj15o.mjs +1176 -0
  147. package/dist/use-modal-CtgexKnf.mjs +14 -0
  148. package/dist/use-search-Dj47QDw9.mjs +15 -0
  149. package/dist/utils-V0EumEPM.mjs +6 -0
  150. package/package.json +1 -3
  151. package/dist/index-38JqtnAI.mjs +0 -122
  152. package/dist/index-B5yoGFs6.mjs +0 -54
  153. package/dist/index-BLbKylyw.mjs +0 -209
  154. package/dist/index-Bu448Tz2.mjs +0 -106
  155. package/dist/index-BwFnfaRh.mjs +0 -2310
  156. package/dist/index-Co_k0WFk.mjs +0 -75
  157. package/dist/index-Cu7uUMlx.mjs +0 -82
  158. package/dist/index-D-lcuEHY.mjs +0 -1018
  159. package/dist/index-DrfjITyT.mjs +0 -61
  160. package/dist/styles-7_q7nHce.mjs +0 -110
  161. package/dist/styles-BA0WIQL-.mjs +0 -74
  162. package/dist/styles-C3cZmKVJ.mjs +0 -131
  163. package/dist/styles-D85YYIjM.mjs +0 -131
  164. package/dist/styles-EIbGRPlk.mjs +0 -106
  165. package/dist/styles-Q1VXuWI7.mjs +0 -65
  166. package/dist/styles-fH2c4cfc.mjs +0 -77
  167. package/dist/use-carousel-CvRxi2FI.mjs +0 -17
  168. package/dist/use-click-outside-BtZLIoU1.mjs +0 -18
  169. package/dist/use-cloudinary-image-fG7ODNgr.mjs +0 -611
  170. package/dist/use-modal-CkrZ-_-M.mjs +0 -14
  171. package/dist/use-search-DpLNvt7Q.mjs +0 -12
  172. package/dist/utils-CQvBF-wY.mjs +0 -4
@@ -1,309 +1,338 @@
1
- import { jsx as _, jsxs as U } from "react/jsx-runtime";
2
- import { u as oe, a as ie } from "../../../../index-D-lcuEHY.mjs";
3
- import I, { forwardRef as ae, useImperativeHandle as le, useRef as F, useCallback as R, useMemo as Y, useEffect as q, useState as G } from "react";
4
- import { createPortal as se } from "react-dom";
5
- import { styled as W, useTheme as de } from "styled-components";
6
- import { OutlineContainer as ue } from "../../outline-container/index.js";
7
- import { S as ce } from "../../../../styles-lSVV9kjn.mjs";
8
- import { Icon as X } from "../../../icon/index.js";
1
+ import { jsx as F, jsxs as H } from "react/jsx-runtime";
2
+ import { u as le, a as se } from "../../../../index-DwznImvK.mjs";
3
+ import S, { forwardRef as ae, useImperativeHandle as de, useRef as T, useCallback as O, useMemo as Y, useEffect as U, useState as G } from "react";
4
+ import { createPortal as ue } from "react-dom";
5
+ import { styled as W, useTheme as ce } from "styled-components";
6
+ import { OutlineContainer as fe } from "../../outline-container/index.js";
7
+ import { S as pe } from "../../../../styles-BXFVwnWT.mjs";
8
+ import { Icon as ee } from "../../../icon/index.js";
9
9
  import "../../../typography/heading/index.js";
10
10
  import "../../../typography/span/index.js";
11
- import { Text as pe } from "../../../typography/text/index.js";
12
- import { u as fe } from "../../../../use-click-outside-BtZLIoU1.mjs";
13
- var T = [["Afghanistan", "af", "93"], ["Albania", "al", "355"], ["Algeria", "dz", "213"], ["Andorra", "ad", "376"], ["Angola", "ao", "244"], ["Antigua and Barbuda", "ag", "1268"], ["Argentina", "ar", "54", "(..) ........", 0], ["Armenia", "am", "374", ".. ......"], ["Aruba", "aw", "297"], ["Australia", "au", "61", { default: ". .... ....", "/^4/": "... ... ...", "/^5(?!50)/": "... ... ...", "/^1(3|8)00/": ".... ... ...", "/^13/": ".. .. ..", "/^180/": "... ...." }, 0, []], ["Austria", "at", "43"], ["Azerbaijan", "az", "994", "(..) ... .. .."], ["Bahamas", "bs", "1242"], ["Bahrain", "bh", "973"], ["Bangladesh", "bd", "880"], ["Barbados", "bb", "1246"], ["Belarus", "by", "375", "(..) ... .. .."], ["Belgium", "be", "32", "... .. .. .."], ["Belize", "bz", "501"], ["Benin", "bj", "229"], ["Bhutan", "bt", "975"], ["Bolivia", "bo", "591"], ["Bosnia and Herzegovina", "ba", "387"], ["Botswana", "bw", "267"], ["Brazil", "br", "55", "(..) ........."], ["British Indian Ocean Territory", "io", "246"], ["Brunei", "bn", "673"], ["Bulgaria", "bg", "359"], ["Burkina Faso", "bf", "226"], ["Burundi", "bi", "257"], ["Cambodia", "kh", "855"], ["Cameroon", "cm", "237"], ["Canada", "ca", "1", "(...) ...-....", 1, ["204", "226", "236", "249", "250", "289", "306", "343", "365", "387", "403", "416", "418", "431", "437", "438", "450", "506", "514", "519", "548", "579", "581", "587", "604", "613", "639", "647", "672", "705", "709", "742", "778", "780", "782", "807", "819", "825", "867", "873", "902", "905"]], ["Cape Verde", "cv", "238"], ["Caribbean Netherlands", "bq", "599", "", 1], ["Cayman Islands", "ky", "1", "... ... ....", 4, ["345"]], ["Central African Republic", "cf", "236"], ["Chad", "td", "235"], ["Chile", "cl", "56"], ["China", "cn", "86", "... .... ...."], ["Colombia", "co", "57", "... ... ...."], ["Comoros", "km", "269"], ["Congo", "cd", "243"], ["Congo", "cg", "242"], ["Costa Rica", "cr", "506", "....-...."], ["Côte d'Ivoire", "ci", "225", ".. .. .. .. .."], ["Croatia", "hr", "385"], ["Cuba", "cu", "53"], ["Curaçao", "cw", "599", "", 0], ["Cyprus", "cy", "357", ".. ......"], ["Czech Republic", "cz", "420", "... ... ..."], ["Denmark", "dk", "45", ".. .. .. .."], ["Djibouti", "dj", "253"], ["Dominica", "dm", "1767"], ["Dominican Republic", "do", "1", "(...) ...-....", 2, ["809", "829", "849"]], ["Ecuador", "ec", "593"], ["Egypt", "eg", "20"], ["El Salvador", "sv", "503", "....-...."], ["Equatorial Guinea", "gq", "240"], ["Eritrea", "er", "291"], ["Estonia", "ee", "372", ".... ......"], ["Ethiopia", "et", "251"], ["Fiji", "fj", "679"], ["Finland", "fi", "358", ".. ... .. .."], ["France", "fr", "33", ". .. .. .. .."], ["French Guiana", "gf", "594"], ["French Polynesia", "pf", "689"], ["Gabon", "ga", "241"], ["Gambia", "gm", "220"], ["Georgia", "ge", "995"], ["Germany", "de", "49", "... ........."], ["Ghana", "gh", "233"], ["Greece", "gr", "30"], ["Greenland", "gl", "299", ".. .. .."], ["Grenada", "gd", "1473"], ["Guadeloupe", "gp", "590", "", 0], ["Guam", "gu", "1671"], ["Guatemala", "gt", "502", "....-...."], ["Guinea", "gn", "224"], ["Guinea-Bissau", "gw", "245"], ["Guyana", "gy", "592"], ["Haiti", "ht", "509", "....-...."], ["Honduras", "hn", "504"], ["Hong Kong", "hk", "852", ".... ...."], ["Hungary", "hu", "36"], ["Iceland", "is", "354", "... ...."], ["India", "in", "91", ".....-....."], ["Indonesia", "id", "62"], ["Iran", "ir", "98", "... ... ...."], ["Iraq", "iq", "964"], ["Ireland", "ie", "353", ".. ......."], ["Israel", "il", "972", "... ... ...."], ["Italy", "it", "39", "... .......", 0], ["Jamaica", "jm", "1876"], ["Japan", "jp", "81", ".. .... ...."], ["Jordan", "jo", "962"], ["Kazakhstan", "kz", "7", "... ...-..-..", 0], ["Kenya", "ke", "254"], ["Kiribati", "ki", "686"], ["Kosovo", "xk", "383"], ["Kuwait", "kw", "965"], ["Kyrgyzstan", "kg", "996", "... ... ..."], ["Laos", "la", "856"], ["Latvia", "lv", "371", ".. ... ..."], ["Lebanon", "lb", "961"], ["Lesotho", "ls", "266"], ["Liberia", "lr", "231"], ["Libya", "ly", "218"], ["Liechtenstein", "li", "423"], ["Lithuania", "lt", "370"], ["Luxembourg", "lu", "352"], ["Macau", "mo", "853"], ["Macedonia", "mk", "389"], ["Madagascar", "mg", "261"], ["Malawi", "mw", "265"], ["Malaysia", "my", "60", "..-....-...."], ["Maldives", "mv", "960"], ["Mali", "ml", "223"], ["Malta", "mt", "356"], ["Marshall Islands", "mh", "692"], ["Martinique", "mq", "596"], ["Mauritania", "mr", "222"], ["Mauritius", "mu", "230"], ["Mexico", "mx", "52", "... ... ....", 0], ["Micronesia", "fm", "691"], ["Moldova", "md", "373", "(..) ..-..-.."], ["Monaco", "mc", "377"], ["Mongolia", "mn", "976"], ["Montenegro", "me", "382"], ["Morocco", "ma", "212"], ["Mozambique", "mz", "258"], ["Myanmar", "mm", "95"], ["Namibia", "na", "264"], ["Nauru", "nr", "674"], ["Nepal", "np", "977"], ["Netherlands", "nl", "31", { "/^06/": "(.). .........", "/^6/": ". .........", "/^0(10|13|14|15|20|23|24|26|30|33|35|36|38|40|43|44|45|46|50|53|55|58|70|71|72|73|74|75|76|77|78|79|82|84|85|87|88|91)/": "(.).. ........", "/^(10|13|14|15|20|23|24|26|30|33|35|36|38|40|43|44|45|46|50|53|55|58|70|71|72|73|74|75|76|77|78|79|82|84|85|87|88|91)/": ".. ........", "/^0/": "(.)... .......", default: "... ......." }], ["New Caledonia", "nc", "687"], ["New Zealand", "nz", "64", "...-...-...."], ["Nicaragua", "ni", "505"], ["Niger", "ne", "227"], ["Nigeria", "ng", "234"], ["North Korea", "kp", "850"], ["Norway", "no", "47", "... .. ..."], ["Oman", "om", "968"], ["Pakistan", "pk", "92", "...-......."], ["Palau", "pw", "680"], ["Palestine", "ps", "970"], ["Panama", "pa", "507"], ["Papua New Guinea", "pg", "675"], ["Paraguay", "py", "595"], ["Peru", "pe", "51"], ["Philippines", "ph", "63", "... ... ...."], ["Poland", "pl", "48", "...-...-..."], ["Portugal", "pt", "351"], ["Puerto Rico", "pr", "1", "(...) ...-....", 3, ["787", "939"]], ["Qatar", "qa", "974"], ["Réunion", "re", "262"], ["Romania", "ro", "40"], ["Russia", "ru", "7", "(...) ...-..-..", 1], ["Rwanda", "rw", "250"], ["Saint Kitts and Nevis", "kn", "1869"], ["Saint Lucia", "lc", "1758"], ["Saint Vincent and the Grenadines", "vc", "1784"], ["Samoa", "ws", "685"], ["San Marino", "sm", "378"], ["São Tomé and Príncipe", "st", "239"], ["Saudi Arabia", "sa", "966"], ["Senegal", "sn", "221"], ["Serbia", "rs", "381"], ["Seychelles", "sc", "248"], ["Sierra Leone", "sl", "232"], ["Singapore", "sg", "65", "....-...."], ["Slovakia", "sk", "421"], ["Slovenia", "si", "386"], ["Solomon Islands", "sb", "677"], ["Somalia", "so", "252"], ["South Africa", "za", "27"], ["South Korea", "kr", "82", "... .... ...."], ["South Sudan", "ss", "211"], ["Spain", "es", "34", "... ... ..."], ["Sri Lanka", "lk", "94"], ["Sudan", "sd", "249"], ["Suriname", "sr", "597"], ["Swaziland", "sz", "268"], ["Sweden", "se", "46", "... ... ..."], ["Switzerland", "ch", "41", ".. ... .. .."], ["Syria", "sy", "963"], ["Taiwan", "tw", "886"], ["Tajikistan", "tj", "992"], ["Tanzania", "tz", "255"], ["Thailand", "th", "66"], ["Timor-Leste", "tl", "670"], ["Togo", "tg", "228"], ["Tonga", "to", "676"], ["Trinidad and Tobago", "tt", "1868"], ["Tunisia", "tn", "216"], ["Turkey", "tr", "90", "... ... .. .."], ["Turkmenistan", "tm", "993"], ["Tuvalu", "tv", "688"], ["Uganda", "ug", "256"], ["Ukraine", "ua", "380", "(..) ... .. .."], ["United Arab Emirates", "ae", "971"], ["United Kingdom", "gb", "44", ".... ......"], ["United States", "us", "1", "(...) ...-....", 0], ["Uruguay", "uy", "598"], ["Uzbekistan", "uz", "998", ".. ... .. .."], ["Vanuatu", "vu", "678"], ["Vatican City", "va", "39", ".. .... ....", 1], ["Venezuela", "ve", "58"], ["Vietnam", "vn", "84"], ["Yemen", "ye", "967"], ["Zambia", "zm", "260"], ["Zimbabwe", "zw", "263"]], ee = (...e) => e.filter((t) => !!t).join(" ").trim(), B = ({ addPrefix: e, rawClassNames: t }) => ee(((...d) => ee(...d).split(" ").map((l) => `react-international-phone-${l}`).join(" "))(...e), ...t), O = (e) => !!e && /^\d+$/.test(e), Z = (e) => e.replace(/\D/g, ""), H = ({ phone: e, prefix: t }) => e ? `${t}${Z(e)}` : "";
14
- function Q({ value: e, country: t, insertDialCodeOnEmpty: d, trimNonDigitsEnd: l, countries: a, prefix: i, charAfterDialCode: b, forceDialCode: g, disableDialCodeAndPrefix: o, defaultMask: h, countryGuessingEnabled: f, disableFormatting: w }) {
15
- let n = e;
16
- o && (n = n.startsWith(`${i}`) ? n : `${i}${t.dialCode}${n}`);
17
- let c = f ? Ee({ phone: n, countries: a, currentCountryIso2: t == null ? void 0 : t.iso2 }) : void 0, y = (c == null ? void 0 : c.country) ?? t, S = ((D, r) => {
18
- let z = !r.disableDialCodeAndPrefix && r.forceDialCode, s = !r.disableDialCodeAndPrefix && r.insertDialCodeOnEmpty, u = D, p = (x) => r.trimNonDigitsEnd ? x.trim() : x;
19
- if (!u) return s && !u.length || z ? p(`${r.prefix}${r.dialCode}${r.charAfterDialCode}`) : p(u);
20
- if (u = Z(u), u === r.dialCode && !r.disableDialCodeAndPrefix) return p(`${r.prefix}${r.dialCode}${r.charAfterDialCode}`);
21
- if (r.dialCode.startsWith(u) && !r.disableDialCodeAndPrefix) return p(z ? `${r.prefix}${r.dialCode}${r.charAfterDialCode}` : `${r.prefix}${u}`);
22
- if (!u.startsWith(r.dialCode) && !r.disableDialCodeAndPrefix) {
23
- if (z) return p(`${r.prefix}${r.dialCode}${r.charAfterDialCode}`);
24
- if (u.length < r.dialCode.length) return p(`${r.prefix}${u}`);
25
- }
26
- let { phoneLeftSide: k, phoneRightSide: C } = (() => {
27
- let x = r.dialCode.length;
28
- return { phoneLeftSide: u.slice(0, x), phoneRightSide: u.slice(x) };
29
- })();
30
- return k = `${r.prefix}${k}${r.charAfterDialCode}`, C = (({ value: x, mask: v, maskSymbol: $, offset: m = 0, trimNonMaskCharsLeftover: A = !1 }) => {
31
- if (x.length < m) return x;
32
- let P = x.slice(0, m), E = x.slice(m), L = P, j = 0;
33
- for (let M of v.split("")) {
34
- if (j >= E.length) {
35
- if (!A && M !== $) {
36
- L += M;
37
- continue;
38
- }
39
- break;
40
- }
41
- M === $ ? (L += E[j], j += 1) : L += M;
11
+ import { Text as ye } from "../../../typography/text/index.js";
12
+ import { u as me } from "../../../../use-click-outside-BUll8Ag-.mjs";
13
+ var R = [["Afghanistan", "af", "93"], ["Albania", "al", "355"], ["Algeria", "dz", "213"], ["Andorra", "ad", "376"], ["Angola", "ao", "244"], ["Antigua and Barbuda", "ag", "1268"], ["Argentina", "ar", "54", "(..) ........", 0], ["Armenia", "am", "374", ".. ......"], ["Aruba", "aw", "297"], ["Australia", "au", "61", { default: ". .... ....", "/^4/": "... ... ...", "/^5(?!50)/": "... ... ...", "/^1(3|8)00/": ".... ... ...", "/^13/": ".. .. ..", "/^180/": "... ...." }, 0, []], ["Austria", "at", "43"], ["Azerbaijan", "az", "994", "(..) ... .. .."], ["Bahamas", "bs", "1242"], ["Bahrain", "bh", "973"], ["Bangladesh", "bd", "880"], ["Barbados", "bb", "1246"], ["Belarus", "by", "375", "(..) ... .. .."], ["Belgium", "be", "32", "... .. .. .."], ["Belize", "bz", "501"], ["Benin", "bj", "229"], ["Bhutan", "bt", "975"], ["Bolivia", "bo", "591"], ["Bosnia and Herzegovina", "ba", "387"], ["Botswana", "bw", "267"], ["Brazil", "br", "55", "(..) ........."], ["British Indian Ocean Territory", "io", "246"], ["Brunei", "bn", "673"], ["Bulgaria", "bg", "359"], ["Burkina Faso", "bf", "226"], ["Burundi", "bi", "257"], ["Cambodia", "kh", "855"], ["Cameroon", "cm", "237"], ["Canada", "ca", "1", "(...) ...-....", 1, ["204", "226", "236", "249", "250", "289", "306", "343", "365", "387", "403", "416", "418", "431", "437", "438", "450", "506", "514", "519", "548", "579", "581", "587", "604", "613", "639", "647", "672", "705", "709", "742", "778", "780", "782", "807", "819", "825", "867", "873", "902", "905"]], ["Cape Verde", "cv", "238"], ["Caribbean Netherlands", "bq", "599", "", 1], ["Cayman Islands", "ky", "1", "... ... ....", 4, ["345"]], ["Central African Republic", "cf", "236"], ["Chad", "td", "235"], ["Chile", "cl", "56"], ["China", "cn", "86", "... .... ...."], ["Colombia", "co", "57", "... ... ...."], ["Comoros", "km", "269"], ["Congo", "cd", "243"], ["Congo", "cg", "242"], ["Costa Rica", "cr", "506", "....-...."], ["Côte d'Ivoire", "ci", "225", ".. .. .. .. .."], ["Croatia", "hr", "385"], ["Cuba", "cu", "53"], ["Curaçao", "cw", "599", "", 0], ["Cyprus", "cy", "357", ".. ......"], ["Czech Republic", "cz", "420", "... ... ..."], ["Denmark", "dk", "45", ".. .. .. .."], ["Djibouti", "dj", "253"], ["Dominica", "dm", "1767"], ["Dominican Republic", "do", "1", "(...) ...-....", 2, ["809", "829", "849"]], ["Ecuador", "ec", "593"], ["Egypt", "eg", "20"], ["El Salvador", "sv", "503", "....-...."], ["Equatorial Guinea", "gq", "240"], ["Eritrea", "er", "291"], ["Estonia", "ee", "372", ".... ......"], ["Ethiopia", "et", "251"], ["Fiji", "fj", "679"], ["Finland", "fi", "358", ".. ... .. .."], ["France", "fr", "33", ". .. .. .. .."], ["French Guiana", "gf", "594"], ["French Polynesia", "pf", "689"], ["Gabon", "ga", "241"], ["Gambia", "gm", "220"], ["Georgia", "ge", "995"], ["Germany", "de", "49", "... ........."], ["Ghana", "gh", "233"], ["Greece", "gr", "30"], ["Greenland", "gl", "299", ".. .. .."], ["Grenada", "gd", "1473"], ["Guadeloupe", "gp", "590", "", 0], ["Guam", "gu", "1671"], ["Guatemala", "gt", "502", "....-...."], ["Guinea", "gn", "224"], ["Guinea-Bissau", "gw", "245"], ["Guyana", "gy", "592"], ["Haiti", "ht", "509", "....-...."], ["Honduras", "hn", "504"], ["Hong Kong", "hk", "852", ".... ...."], ["Hungary", "hu", "36"], ["Iceland", "is", "354", "... ...."], ["India", "in", "91", ".....-....."], ["Indonesia", "id", "62"], ["Iran", "ir", "98", "... ... ...."], ["Iraq", "iq", "964"], ["Ireland", "ie", "353", ".. ......."], ["Israel", "il", "972", "... ... ...."], ["Italy", "it", "39", "... .......", 0], ["Jamaica", "jm", "1876"], ["Japan", "jp", "81", ".. .... ...."], ["Jordan", "jo", "962"], ["Kazakhstan", "kz", "7", "... ...-..-..", 0], ["Kenya", "ke", "254"], ["Kiribati", "ki", "686"], ["Kosovo", "xk", "383"], ["Kuwait", "kw", "965"], ["Kyrgyzstan", "kg", "996", "... ... ..."], ["Laos", "la", "856"], ["Latvia", "lv", "371", ".. ... ..."], ["Lebanon", "lb", "961"], ["Lesotho", "ls", "266"], ["Liberia", "lr", "231"], ["Libya", "ly", "218"], ["Liechtenstein", "li", "423"], ["Lithuania", "lt", "370"], ["Luxembourg", "lu", "352"], ["Macau", "mo", "853"], ["Macedonia", "mk", "389"], ["Madagascar", "mg", "261"], ["Malawi", "mw", "265"], ["Malaysia", "my", "60", "..-....-...."], ["Maldives", "mv", "960"], ["Mali", "ml", "223"], ["Malta", "mt", "356"], ["Marshall Islands", "mh", "692"], ["Martinique", "mq", "596"], ["Mauritania", "mr", "222"], ["Mauritius", "mu", "230"], ["Mexico", "mx", "52", "... ... ....", 0], ["Micronesia", "fm", "691"], ["Moldova", "md", "373", "(..) ..-..-.."], ["Monaco", "mc", "377"], ["Mongolia", "mn", "976"], ["Montenegro", "me", "382"], ["Morocco", "ma", "212"], ["Mozambique", "mz", "258"], ["Myanmar", "mm", "95"], ["Namibia", "na", "264"], ["Nauru", "nr", "674"], ["Nepal", "np", "977"], ["Netherlands", "nl", "31", { "/^06/": "(.). .........", "/^6/": ". .........", "/^0(10|13|14|15|20|23|24|26|30|33|35|36|38|40|43|44|45|46|50|53|55|58|70|71|72|73|74|75|76|77|78|79|82|84|85|87|88|91)/": "(.).. ........", "/^(10|13|14|15|20|23|24|26|30|33|35|36|38|40|43|44|45|46|50|53|55|58|70|71|72|73|74|75|76|77|78|79|82|84|85|87|88|91)/": ".. ........", "/^0/": "(.)... .......", default: "... ......." }], ["New Caledonia", "nc", "687"], ["New Zealand", "nz", "64", "...-...-...."], ["Nicaragua", "ni", "505"], ["Niger", "ne", "227"], ["Nigeria", "ng", "234"], ["North Korea", "kp", "850"], ["Norway", "no", "47", "... .. ..."], ["Oman", "om", "968"], ["Pakistan", "pk", "92", "...-......."], ["Palau", "pw", "680"], ["Palestine", "ps", "970"], ["Panama", "pa", "507"], ["Papua New Guinea", "pg", "675"], ["Paraguay", "py", "595"], ["Peru", "pe", "51"], ["Philippines", "ph", "63", "... ... ...."], ["Poland", "pl", "48", "...-...-..."], ["Portugal", "pt", "351"], ["Puerto Rico", "pr", "1", "(...) ...-....", 3, ["787", "939"]], ["Qatar", "qa", "974"], ["Réunion", "re", "262"], ["Romania", "ro", "40"], ["Russia", "ru", "7", "(...) ...-..-..", 1], ["Rwanda", "rw", "250"], ["Saint Kitts and Nevis", "kn", "1869"], ["Saint Lucia", "lc", "1758"], ["Saint Vincent and the Grenadines", "vc", "1784"], ["Samoa", "ws", "685"], ["San Marino", "sm", "378"], ["São Tomé and Príncipe", "st", "239"], ["Saudi Arabia", "sa", "966"], ["Senegal", "sn", "221"], ["Serbia", "rs", "381"], ["Seychelles", "sc", "248"], ["Sierra Leone", "sl", "232"], ["Singapore", "sg", "65", "....-...."], ["Slovakia", "sk", "421"], ["Slovenia", "si", "386"], ["Solomon Islands", "sb", "677"], ["Somalia", "so", "252"], ["South Africa", "za", "27"], ["South Korea", "kr", "82", "... .... ...."], ["South Sudan", "ss", "211"], ["Spain", "es", "34", "... ... ..."], ["Sri Lanka", "lk", "94"], ["Sudan", "sd", "249"], ["Suriname", "sr", "597"], ["Swaziland", "sz", "268"], ["Sweden", "se", "46", "... ... ..."], ["Switzerland", "ch", "41", ".. ... .. .."], ["Syria", "sy", "963"], ["Taiwan", "tw", "886"], ["Tajikistan", "tj", "992"], ["Tanzania", "tz", "255"], ["Thailand", "th", "66"], ["Timor-Leste", "tl", "670"], ["Togo", "tg", "228"], ["Tonga", "to", "676"], ["Trinidad and Tobago", "tt", "1868"], ["Tunisia", "tn", "216"], ["Turkey", "tr", "90", "... ... .. .."], ["Turkmenistan", "tm", "993"], ["Tuvalu", "tv", "688"], ["Uganda", "ug", "256"], ["Ukraine", "ua", "380", "(..) ... .. .."], ["United Arab Emirates", "ae", "971"], ["United Kingdom", "gb", "44", ".... ......"], ["United States", "us", "1", "(...) ...-....", 0], ["Uruguay", "uy", "598"], ["Uzbekistan", "uz", "998", ".. ... .. .."], ["Vanuatu", "vu", "678"], ["Vatican City", "va", "39", ".. .... ....", 1], ["Venezuela", "ve", "58"], ["Vietnam", "vn", "84"], ["Yemen", "ye", "967"], ["Zambia", "zm", "260"], ["Zimbabwe", "zw", "263"]], he = "react-international-phone-", re = (...e) => e.filter((t) => !!t).join(" ").trim(), Ce = (...e) => re(...e).split(" ").map((t) => `${he}${t}`).join(" "), A = ({ addPrefix: e, rawClassNames: t }) => re(Ce(...e), ...t), ge = ({ value: e, mask: t, maskSymbol: r, offset: l = 0, trimNonMaskCharsLeftover: a = !1 }) => {
14
+ if (e.length < l) return e;
15
+ let n = e.slice(0, l), f = e.slice(l), u = n, o = 0;
16
+ for (let s of t.split("")) {
17
+ if (o >= f.length) {
18
+ if (!a && s !== r) {
19
+ u += s;
20
+ continue;
42
21
  }
43
- return L;
44
- })({ value: C, mask: r.mask, maskSymbol: r.maskChar, trimNonMaskCharsLeftover: r.trimNonDigitsEnd || r.disableDialCodeAndPrefix && C.length === 0 }), r.disableDialCodeAndPrefix && (k = ""), p(`${k}${C}`);
45
- })(n, { prefix: i, mask: Ae({ phone: n, country: y, defaultMask: h, disableFormatting: w }), maskChar: re, dialCode: y.dialCode, trimNonDigitsEnd: l, charAfterDialCode: b, forceDialCode: g, insertDialCodeOnEmpty: d, disableDialCodeAndPrefix: o }), N = f && !(c != null && c.fullDialCodeMatch) ? t : y;
46
- return { phone: H({ phone: o ? `${N.dialCode}${S}` : S, prefix: i }), inputValue: S, country: N };
47
- }
48
- var me = (e, { country: t, insertDialCodeOnEmpty: d, phoneBeforeInput: l, prefix: a, charAfterDialCode: i, forceDialCode: b, disableDialCodeAndPrefix: g, countryGuessingEnabled: o, defaultMask: h, disableFormatting: f, countries: w }) => {
49
- let n = e.nativeEvent, c = n.inputType, y = ((C) => {
50
- if (C != null && C.toLocaleLowerCase().includes("delete")) return C != null && C.toLocaleLowerCase().includes("forward") ? "forward" : "backward";
51
- })(c), S = !!(c != null && c.startsWith("insertFrom")), N = c === "insertText", D = (n == null ? void 0 : n.data) || void 0, r = e.target.value, z = e.target.selectionStart ?? 0;
52
- if (c != null && c.includes("history")) return { inputValue: l, phone: H({ phone: l, prefix: a }), cursorPosition: l.length, country: t };
53
- if (N && !O(D) && r !== a) return { inputValue: l, phone: H({ phone: g ? `${t.dialCode}${l}` : l, prefix: a }), cursorPosition: z - ((D == null ? void 0 : D.length) ?? 0), country: t };
54
- if (b && !r.startsWith(`${a}${t.dialCode}`) && !S) {
55
- let C = r ? l : `${a}${t.dialCode}${i}`;
56
- return { inputValue: C, phone: H({ phone: C, prefix: a }), cursorPosition: a.length + t.dialCode.length + i.length, country: t };
57
- }
58
- let { phone: s, inputValue: u, country: p } = Q({ value: r, country: t, trimNonDigitsEnd: y === "backward", insertDialCodeOnEmpty: d, countryGuessingEnabled: o, countries: w, prefix: a, charAfterDialCode: i, forceDialCode: b, disableDialCodeAndPrefix: g, disableFormatting: f, defaultMask: h }), k = (({ phoneBeforeInput: C, phoneAfterInput: x, phoneAfterFormatted: v, cursorPositionAfterInput: $, leftOffset: m = 0, deletion: A }) => {
59
- if ($ < m) return m;
60
- if (!C) return v.length;
61
- let P = null;
62
- for (let M = $ - 1; M >= 0; M -= 1) if (O(x[M])) {
63
- P = M;
64
22
  break;
65
23
  }
66
- if (P === null) {
67
- for (let M = 0; M < x.length; M += 1) if (O(v[M])) return M;
68
- return x.length;
69
- }
70
- let E = 0;
71
- for (let M = 0; M < P; M += 1) O(x[M]) && (E += 1);
72
- let L = 0, j = 0;
73
- for (let M = 0; M < v.length && (L += 1, O(v[M]) && (j += 1), !(j >= E + 1)); M += 1) ;
74
- if (A !== "backward") for (; !O(v[L]) && L < v.length; ) L += 1;
75
- return L;
76
- })({ cursorPositionAfterInput: z, phoneBeforeInput: l, phoneAfterInput: r, phoneAfterFormatted: u, leftOffset: b ? a.length + t.dialCode.length + i.length : 0, deletion: y });
77
- return { phone: s, inputValue: u, cursorPosition: k, country: p };
78
- }, he = { size: 20, overrideLastItemDebounceMS: -1 };
79
- function ye(e, t) {
80
- let { size: d, overrideLastItemDebounceMS: l, onChange: a } = { ...he, ...t }, [i, b] = G(e), [g, o] = G([i]), [h, f] = G(0), w = (() => {
81
- let n = F(), c = F(Date.now());
82
- return { check: () => {
83
- let y = Date.now(), S = n.current ? y - c.current : void 0;
84
- return n.current = c.current, c.current = y, S;
85
- } };
86
- })();
87
- return [i, (n, c) => {
88
- if (typeof n == "object" && typeof i == "object" && ((D, r) => {
89
- let z = Object.keys(D), s = Object.keys(r);
90
- if (z.length !== s.length) return !1;
91
- for (let u of z) if (D[u] !== r[u]) return !1;
92
- return !0;
93
- })(n, i) || n === i) return;
94
- let y = l > 0, S = w.check(), N = !y || S === void 0 || S > l;
95
- if ((c == null ? void 0 : c.overrideLastItem) !== void 0 ? c.overrideLastItem : !N) o((D) => [...D.slice(0, h), n]);
24
+ s === r ? (u += f[o], o += 1) : u += s;
25
+ }
26
+ return u;
27
+ }, K = (e) => e ? /^\d+$/.test(e) : !1, Q = (e) => e.replace(/\D/g, ""), be = (e, t) => {
28
+ let r = e.style.display;
29
+ r !== "block" && (e.style.display = "block");
30
+ let l = e.getBoundingClientRect(), a = t.getBoundingClientRect(), n = a.top - l.top, f = l.bottom - a.bottom;
31
+ n >= 0 && f >= 0 || (Math.abs(n) < Math.abs(f) ? e.scrollTop += n : e.scrollTop -= f), e.style.display = r;
32
+ }, we = () => typeof window > "u" ? !1 : window.navigator.userAgent.toLowerCase().includes("macintosh"), ve = (e, t) => {
33
+ let r = t.disableDialCodeAndPrefix ? !1 : t.forceDialCode, l = t.disableDialCodeAndPrefix ? !1 : t.insertDialCodeOnEmpty, a = e, n = (s) => t.trimNonDigitsEnd ? s.trim() : s;
34
+ if (!a) return l && !a.length || r ? n(`${t.prefix}${t.dialCode}${t.charAfterDialCode}`) : n(a);
35
+ if (a = Q(a), a === t.dialCode && !t.disableDialCodeAndPrefix) return n(`${t.prefix}${t.dialCode}${t.charAfterDialCode}`);
36
+ if (t.dialCode.startsWith(a) && !t.disableDialCodeAndPrefix) return n(r ? `${t.prefix}${t.dialCode}${t.charAfterDialCode}` : `${t.prefix}${a}`);
37
+ if (!a.startsWith(t.dialCode) && !t.disableDialCodeAndPrefix) {
38
+ if (r) return n(`${t.prefix}${t.dialCode}${t.charAfterDialCode}`);
39
+ if (a.length < t.dialCode.length) return n(`${t.prefix}${a}`);
40
+ }
41
+ let f = () => {
42
+ let s = t.dialCode.length, i = a.slice(0, s), y = a.slice(s);
43
+ return { phoneLeftSide: i, phoneRightSide: y };
44
+ }, { phoneLeftSide: u, phoneRightSide: o } = f();
45
+ return u = `${t.prefix}${u}${t.charAfterDialCode}`, o = ge({ value: o, mask: t.mask, maskSymbol: t.maskChar, trimNonMaskCharsLeftover: t.trimNonDigitsEnd || t.disableDialCodeAndPrefix && o.length === 0 }), t.disableDialCodeAndPrefix && (u = ""), n(`${u}${o}`);
46
+ }, xe = ({ phoneBeforeInput: e, phoneAfterInput: t, phoneAfterFormatted: r, cursorPositionAfterInput: l, leftOffset: a = 0, deletion: n }) => {
47
+ if (l < a) return a;
48
+ if (!e) return r.length;
49
+ let f = null;
50
+ for (let i = l - 1; i >= 0; i -= 1) if (K(t[i])) {
51
+ f = i;
52
+ break;
53
+ }
54
+ if (f === null) {
55
+ for (let i = 0; i < t.length; i += 1) if (K(r[i])) return i;
56
+ return t.length;
57
+ }
58
+ let u = 0;
59
+ for (let i = 0; i < f; i += 1) K(t[i]) && (u += 1);
60
+ let o = 0, s = 0;
61
+ for (let i = 0; i < r.length && (o += 1, K(r[i]) && (s += 1), !(s >= u + 1)); i += 1) ;
62
+ if (n !== "backward") for (; !K(r[o]) && o < r.length; ) o += 1;
63
+ return o;
64
+ }, J = ({ phone: e, prefix: t }) => e ? `${t}${Q(e)}` : "";
65
+ function X({ value: e, country: t, insertDialCodeOnEmpty: r, trimNonDigitsEnd: l, countries: a, prefix: n, charAfterDialCode: f, forceDialCode: u, disableDialCodeAndPrefix: o, defaultMask: s, countryGuessingEnabled: i, disableFormatting: y }) {
66
+ let d = e;
67
+ o && (d = d.startsWith(`${n}`) ? d : `${n}${t.dialCode}${d}`);
68
+ let p = i ? Ie({ phone: d, countries: a, currentCountryIso2: t == null ? void 0 : t.iso2 }) : void 0, v = (p == null ? void 0 : p.country) ?? t, m = ve(d, { prefix: n, mask: Ae({ phone: d, country: v, defaultMask: s, disableFormatting: y }), maskChar: ne, dialCode: v.dialCode, trimNonDigitsEnd: l, charAfterDialCode: f, forceDialCode: u, insertDialCodeOnEmpty: r, disableDialCodeAndPrefix: o }), g = i && !(p != null && p.fullDialCodeMatch) ? t : v;
69
+ return { phone: J({ phone: o ? `${g.dialCode}${m}` : m, prefix: n }), inputValue: m, country: g };
70
+ }
71
+ var De = (e) => {
72
+ if ((e == null ? void 0 : e.toLocaleLowerCase().includes("delete")) ?? !1) return e != null && e.toLocaleLowerCase().includes("forward") ? "forward" : "backward";
73
+ }, ke = (e, { country: t, insertDialCodeOnEmpty: r, phoneBeforeInput: l, prefix: a, charAfterDialCode: n, forceDialCode: f, disableDialCodeAndPrefix: u, countryGuessingEnabled: o, defaultMask: s, disableFormatting: i, countries: y }) => {
74
+ let d = e.nativeEvent, p = d.inputType, v = De(p), m = !!(p != null && p.startsWith("insertFrom")), g = p === "insertText", x = (d == null ? void 0 : d.data) || void 0, b = e.target.value, E = e.target.selectionStart ?? 0;
75
+ if (p != null && p.includes("history")) return { inputValue: l, phone: J({ phone: l, prefix: a }), cursorPosition: l.length, country: t };
76
+ if (g && !K(x) && b !== a) return { inputValue: l, phone: J({ phone: u ? `${t.dialCode}${l}` : l, prefix: a }), cursorPosition: E - ((x == null ? void 0 : x.length) ?? 0), country: t };
77
+ if (f && !b.startsWith(`${a}${t.dialCode}`) && !m) {
78
+ let h = b ? l : `${a}${t.dialCode}${n}`;
79
+ return { inputValue: h, phone: J({ phone: h, prefix: a }), cursorPosition: a.length + t.dialCode.length + n.length, country: t };
80
+ }
81
+ let { phone: V, inputValue: M, country: c } = X({ value: b, country: t, trimNonDigitsEnd: v === "backward", insertDialCodeOnEmpty: r, countryGuessingEnabled: o, countries: y, prefix: a, charAfterDialCode: n, forceDialCode: f, disableDialCodeAndPrefix: u, disableFormatting: i, defaultMask: s }), C = xe({ cursorPositionAfterInput: E, phoneBeforeInput: l, phoneAfterInput: b, phoneAfterFormatted: M, leftOffset: f ? a.length + t.dialCode.length + n.length : 0, deletion: v });
82
+ return { phone: V, inputValue: M, cursorPosition: C, country: c };
83
+ }, $e = (e, t) => {
84
+ let r = Object.keys(e), l = Object.keys(t);
85
+ if (r.length !== l.length) return !1;
86
+ for (let a of r) if (e[a] !== t[a]) return !1;
87
+ return !0;
88
+ }, Se = () => {
89
+ let e = T(), t = T(Date.now());
90
+ return { check: () => {
91
+ let r = Date.now(), l = e.current ? r - t.current : void 0;
92
+ return e.current = t.current, t.current = r, l;
93
+ } };
94
+ }, Ne = { size: 20, overrideLastItemDebounceMS: -1 };
95
+ function Pe(e, t) {
96
+ let { size: r, overrideLastItemDebounceMS: l, onChange: a } = { ...Ne, ...t }, [n, f] = G(e), [u, o] = G([n]), [s, i] = G(0), y = Se();
97
+ return [n, (d, p) => {
98
+ if (typeof d == "object" && typeof n == "object" && $e(d, n) || d === n) return;
99
+ let v = l > 0, m = y.check(), g = v && m !== void 0 ? m > l : !0;
100
+ if ((p == null ? void 0 : p.overrideLastItem) !== void 0 ? p.overrideLastItem : !g) o((x) => [...x.slice(0, s), d]);
96
101
  else {
97
- let D = g.length >= d;
98
- o((r) => [...r.slice(D ? 1 : 0, h + 1), n]), D || f((r) => r + 1);
102
+ let x = u.length >= r;
103
+ o((b) => [...b.slice(x ? 1 : 0, s + 1), d]), x || i((b) => b + 1);
99
104
  }
100
- b(n), a == null || a(n);
105
+ f(d), a == null || a(d);
101
106
  }, () => {
102
- if (h <= 0) return { success: !1 };
103
- let n = g[h - 1];
104
- return b(n), f((c) => c - 1), a == null || a(n), { success: !0, value: n };
107
+ if (s <= 0) return { success: !1 };
108
+ let d = u[s - 1];
109
+ return f(d), i((p) => p - 1), a == null || a(d), { success: !0, value: d };
105
110
  }, () => {
106
- if (h + 1 >= g.length) return { success: !1 };
107
- let n = g[h + 1];
108
- return b(n), f((c) => c + 1), a == null || a(n), { success: !0, value: n };
111
+ if (s + 1 >= u.length) return { success: !1 };
112
+ let d = u[s + 1];
113
+ return f(d), i((p) => p + 1), a == null || a(d), { success: !0, value: d };
109
114
  }];
110
115
  }
111
- var re = ".", ge = "us", Ce = "", be = "+", we = "............", ve = " ", xe = 200, $e = !1, De = !1, ke = !1, Ne = !1, Pe = !1, Se = T, ne = ({ defaultCountry: e = ge, value: t = Ce, countries: d = Se, prefix: l = be, defaultMask: a = we, charAfterDialCode: i = ve, historySaveDebounceMS: b = xe, disableCountryGuess: g = $e, disableDialCodePrefill: o = De, forceDialCode: h = ke, disableDialCodeAndPrefix: f = Ne, disableFormatting: w = Pe, onChange: n, inputRef: c }) => {
112
- let y = { countries: d, prefix: l, charAfterDialCode: i, forceDialCode: !f && h, disableDialCodeAndPrefix: f, defaultMask: a, countryGuessingEnabled: !g, disableFormatting: w }, S = F(null), N = c || S, D = (m) => {
116
+ var ne = ".", z = { defaultCountry: "us", value: "", prefix: "+", defaultMask: "............", charAfterDialCode: " ", historySaveDebounceMS: 200, disableCountryGuess: !1, disableDialCodePrefill: !1, forceDialCode: !1, disableDialCodeAndPrefix: !1, disableFormatting: !1, countries: R, preferredCountries: [] }, oe = ({ defaultCountry: e = z.defaultCountry, value: t = z.value, countries: r = z.countries, prefix: l = z.prefix, defaultMask: a = z.defaultMask, charAfterDialCode: n = z.charAfterDialCode, historySaveDebounceMS: f = z.historySaveDebounceMS, disableCountryGuess: u = z.disableCountryGuess, disableDialCodePrefill: o = z.disableDialCodePrefill, forceDialCode: s = z.forceDialCode, disableDialCodeAndPrefix: i = z.disableDialCodeAndPrefix, disableFormatting: y = z.disableFormatting, onChange: d, inputRef: p }) => {
117
+ let v = { countries: r, prefix: l, charAfterDialCode: n, forceDialCode: i ? !1 : s, disableDialCodeAndPrefix: i, defaultMask: a, countryGuessingEnabled: !u, disableFormatting: y }, m = T(null), g = p || m, x = (w) => {
113
118
  Promise.resolve().then(() => {
114
- var A;
115
- typeof window > "u" || N.current !== (document == null ? void 0 : document.activeElement) || ((A = N.current) == null || A.setSelectionRange(m, m));
119
+ var $;
120
+ typeof window > "u" || g.current !== (document == null ? void 0 : document.activeElement) || (($ = g.current) == null || $.setSelectionRange(w, w));
116
121
  });
117
- }, [{ phone: r, inputValue: z, country: s }, u, p, k] = ye(() => {
118
- let m = K({ value: e, field: "iso2", countries: d });
119
- m || console.error(`[react-international-phone]: can not find a country with "${e}" iso2 code`);
120
- let A = m || K({ value: "us", field: "iso2", countries: d }), { phone: P, inputValue: E, country: L } = Q({ value: t, country: A, insertDialCodeOnEmpty: !o, ...y });
121
- return D(E.length), { phone: P, inputValue: E, country: L.iso2 };
122
- }, { overrideLastItemDebounceMS: b, onChange: ({ inputValue: m, phone: A, country: P }) => {
123
- if (!n) return;
124
- let E = C(P);
125
- n({ phone: A, inputValue: m, country: E });
126
- } }), C = R((m) => K({ value: m, field: "iso2", countries: d }), [d]), x = Y(() => C(s), [s, C]);
127
- q(() => {
128
- let m = N.current;
129
- if (!m) return;
130
- let A = (P) => {
122
+ }, [{ phone: b, inputValue: E, country: V }, M, c, C] = Pe(() => {
123
+ let w = q({ value: e, field: "iso2", countries: r });
124
+ w || console.error(`[react-international-phone]: can not find a country with "${e}" iso2 code`);
125
+ let $ = w || q({ value: "us", field: "iso2", countries: r }), { phone: P, inputValue: B, country: j } = X({ value: t, country: $, insertDialCodeOnEmpty: !o, ...v });
126
+ return x(B.length), { phone: P, inputValue: B, country: j.iso2 };
127
+ }, { overrideLastItemDebounceMS: f, onChange: ({ inputValue: w, phone: $, country: P }) => {
128
+ if (!d) return;
129
+ let B = h(P);
130
+ d({ phone: $, inputValue: w, country: B });
131
+ } }), h = O((w) => q({ value: w, field: "iso2", countries: r }), [r]), D = Y(() => h(V), [V, h]);
132
+ U(() => {
133
+ let w = g.current;
134
+ if (!w) return;
135
+ let $ = (P) => {
131
136
  if (!P.key) return;
132
- let E = P.ctrlKey, L = P.metaKey, j = P.shiftKey;
137
+ let B = P.ctrlKey, j = P.metaKey, ie = P.shiftKey;
133
138
  if (P.key.toLowerCase() === "z") {
134
- if (typeof window > "u" || !window.navigator.userAgent.toLowerCase().includes("macintosh")) {
135
- if (!E) return;
136
- } else if (!L) return;
137
- j ? k() : p();
139
+ if (we()) {
140
+ if (!j) return;
141
+ } else if (!B) return;
142
+ ie ? C() : c();
138
143
  }
139
144
  };
140
- return m.addEventListener("keydown", A), () => {
141
- m.removeEventListener("keydown", A);
145
+ return w.addEventListener("keydown", $), () => {
146
+ w.removeEventListener("keydown", $);
142
147
  };
143
- }, [N, p, k]);
144
- let [v, $] = G(!1);
145
- return q(() => {
146
- if (!v) return $(!0), void (t !== r && (n == null ? void 0 : n({ inputValue: z, phone: r, country: x })));
147
- if (t === r) return;
148
- let { phone: m, inputValue: A, country: P } = Q({ value: t, country: x, insertDialCodeOnEmpty: !o, ...y });
149
- u({ phone: m, inputValue: A, country: P.iso2 });
150
- }, [t]), { phone: r, inputValue: z, country: x, setCountry: (m, A = { focusOnInput: !1 }) => {
151
- let P = K({ value: m, field: "iso2", countries: d });
152
- if (!P) return void console.error(`[react-international-phone]: can not find a country with "${m}" iso2 code`);
153
- let E = f ? "" : `${l}${P.dialCode}${i}`;
154
- u({ inputValue: E, phone: `${l}${P.dialCode}`, country: P.iso2 }), A.focusOnInput && Promise.resolve().then(() => {
155
- var L;
156
- (L = N.current) == null || L.focus();
148
+ }, [g, c, C]);
149
+ let N = (w) => {
150
+ w.preventDefault();
151
+ let { phone: $, inputValue: P, country: B, cursorPosition: j } = ke(w, { country: D, phoneBeforeInput: E, insertDialCodeOnEmpty: !1, ...v });
152
+ return M({ inputValue: P, phone: $, country: B.iso2 }), x(j), t;
153
+ }, k = (w, $ = { focusOnInput: !1 }) => {
154
+ let P = q({ value: w, field: "iso2", countries: r });
155
+ if (!P) {
156
+ console.error(`[react-international-phone]: can not find a country with "${w}" iso2 code`);
157
+ return;
158
+ }
159
+ let B = i ? "" : `${l}${P.dialCode}${n}`;
160
+ M({ inputValue: B, phone: `${l}${P.dialCode}`, country: P.iso2 }), $.focusOnInput && Promise.resolve().then(() => {
161
+ var j;
162
+ (j = g.current) == null || j.focus();
157
163
  });
158
- }, handlePhoneValueChange: (m) => {
159
- m.preventDefault();
160
- let { phone: A, inputValue: P, country: E, cursorPosition: L } = me(m, { country: x, phoneBeforeInput: z, insertDialCodeOnEmpty: !1, ...y });
161
- return u({ inputValue: P, phone: A, country: E.iso2 }), D(L), t;
162
- }, inputRef: N };
163
- }, Ae = ({ phone: e, country: t, defaultMask: d = "............", disableFormatting: l = !1 }) => {
164
- let a = t.format, i = (g) => l ? g.replace(new RegExp(`[^${re}]`, "g"), "") : g;
165
- if (!a) return i(d);
166
- if (typeof a == "string") return i(a);
167
- if (!a.default) return console.error(`[react-international-phone]: default mask for ${t.iso2} is not provided`), i(d);
168
- let b = Object.keys(a).find((g) => {
169
- if (g === "default") return !1;
170
- if (g.charAt(0) !== "/" || g.charAt(g.length - 1) !== "/") return console.error(`[react-international-phone]: format regex "${g}" for ${t.iso2} is not valid`), !1;
171
- let o = new RegExp(g.substring(1, g.length - 1)), h = e.replace(t.dialCode, "");
172
- return o.test(Z(h));
164
+ }, [I, L] = G(!1);
165
+ return U(() => {
166
+ if (!I) {
167
+ L(!0), t !== b && (d == null || d({ inputValue: E, phone: b, country: D }));
168
+ return;
169
+ }
170
+ if (t === b) return;
171
+ let { phone: w, inputValue: $, country: P } = X({ value: t, country: D, insertDialCodeOnEmpty: !o, ...v });
172
+ M({ phone: w, inputValue: $, country: P.iso2 });
173
+ }, [t]), { phone: b, inputValue: E, country: D, setCountry: k, handlePhoneValueChange: N, inputRef: g };
174
+ }, Ae = ({ phone: e, country: t, defaultMask: r = "............", disableFormatting: l = !1 }) => {
175
+ let a = t.format, n = (u) => l ? u.replace(new RegExp(`[^${ne}]`, "g"), "") : u;
176
+ if (!a) return n(r);
177
+ if (typeof a == "string") return n(a);
178
+ if (!a.default) return console.error(`[react-international-phone]: default mask for ${t.iso2} is not provided`), n(r);
179
+ let f = Object.keys(a).find((u) => {
180
+ if (u === "default") return !1;
181
+ if (!(u.charAt(0) === "/" && u.charAt(u.length - 1) === "/")) return console.error(`[react-international-phone]: format regex "${u}" for ${t.iso2} is not valid`), !1;
182
+ let o = new RegExp(u.substring(1, u.length - 1)), s = e.replace(t.dialCode, "");
183
+ return o.test(Q(s));
173
184
  });
174
- return i(b ? a[b] : a.default);
175
- }, V = (e) => {
176
- let [t, d, l, a, i, b] = e;
177
- return { name: t, iso2: d, dialCode: l, format: a, priority: i, areaCodes: b };
178
- }, K = ({ field: e, value: t, countries: d = T }) => {
179
- if (["priority"].includes(e)) throw new Error(((a) => `Field "${a}" is not supported`)(e));
180
- let l = d.find((a) => {
181
- let i = V(a);
182
- return t === i[e];
185
+ return n(f ? a[f] : a.default);
186
+ }, _ = (e) => {
187
+ let [t, r, l, a, n, f] = e;
188
+ return { name: t, iso2: r, dialCode: l, format: a, priority: n, areaCodes: f };
189
+ }, Ee = (e) => `Field "${e}" is not supported`, q = ({ field: e, value: t, countries: r = R }) => {
190
+ if (["priority"].includes(e)) throw new Error(Ee(e));
191
+ let l = r.find((a) => {
192
+ let n = _(a);
193
+ return t === n[e];
183
194
  });
184
- if (l) return V(l);
185
- }, Ee = ({ phone: e, countries: t = T, currentCountryIso2: d }) => {
186
- var g;
195
+ if (l) return _(l);
196
+ }, Ie = ({ phone: e, countries: t = R, currentCountryIso2: r }) => {
197
+ var u;
187
198
  let l = { country: void 0, fullDialCodeMatch: !1 };
188
199
  if (!e) return l;
189
- let a = Z(e);
200
+ let a = Q(e);
190
201
  if (!a) return l;
191
- let i = l, b = ({ country: o, fullDialCodeMatch: h }) => {
192
- var n, c;
193
- let f = o.dialCode === ((n = i.country) == null ? void 0 : n.dialCode), w = (o.priority ?? 0) < (((c = i.country) == null ? void 0 : c.priority) ?? 0);
194
- (!f || w) && (i = { country: o, fullDialCodeMatch: h });
202
+ let n = l, f = ({ country: o, fullDialCodeMatch: s }) => {
203
+ var d, p;
204
+ let i = o.dialCode === ((d = n.country) == null ? void 0 : d.dialCode), y = (o.priority ?? 0) < (((p = n.country) == null ? void 0 : p.priority) ?? 0);
205
+ (!i || y) && (n = { country: o, fullDialCodeMatch: s });
195
206
  };
196
207
  for (let o of t) {
197
- let h = V(o), { dialCode: f, areaCodes: w } = h;
198
- if (a.startsWith(f)) {
199
- let n = !i.country || Number(f) >= Number(i.country.dialCode);
200
- if (w) {
201
- let c = a.substring(f.length);
202
- for (let y of w) if (c.startsWith(y)) return { country: h, fullDialCodeMatch: !0 };
208
+ let s = _(o), { dialCode: i, areaCodes: y } = s;
209
+ if (a.startsWith(i)) {
210
+ let d = n.country ? Number(i) >= Number(n.country.dialCode) : !0;
211
+ if (y) {
212
+ let p = a.substring(i.length);
213
+ for (let v of y) if (p.startsWith(v)) return { country: s, fullDialCodeMatch: !0 };
203
214
  }
204
- (n || f === a || !i.fullDialCodeMatch) && b({ country: h, fullDialCodeMatch: !0 });
215
+ (d || i === a || !n.fullDialCodeMatch) && f({ country: s, fullDialCodeMatch: !0 });
205
216
  }
206
- i.fullDialCodeMatch || a.length < f.length && f.startsWith(a) && (!i.country || Number(f) <= Number(i.country.dialCode)) && b({ country: h, fullDialCodeMatch: !1 });
217
+ n.fullDialCodeMatch || a.length < i.length && i.startsWith(a) && (!n.country || Number(i) <= Number(n.country.dialCode)) && f({ country: s, fullDialCodeMatch: !1 });
207
218
  }
208
- if (d) {
209
- let o = K({ value: d, field: "iso2", countries: t });
210
- if (!o) return i;
211
- let h = !!o && ((f) => {
212
- if (!(f != null && f.areaCodes)) return !1;
213
- let w = a.substring(f.dialCode.length);
214
- return f.areaCodes.some((n) => n.startsWith(w));
215
- })(o);
216
- i && ((g = i.country) == null ? void 0 : g.dialCode) === o.dialCode && i.country !== o && i.fullDialCodeMatch && (!o.areaCodes || h) && (i = { country: o, fullDialCodeMatch: !0 });
219
+ if (r) {
220
+ let o = q({ value: r, field: "iso2", countries: t });
221
+ if (!o) return n;
222
+ let s = o ? ((i) => {
223
+ if (!(i != null && i.areaCodes)) return !1;
224
+ let y = a.substring(i.dialCode.length);
225
+ return i.areaCodes.some((d) => d.startsWith(y));
226
+ })(o) : !1;
227
+ n && ((u = n.country) == null ? void 0 : u.dialCode) === o.dialCode && n.country !== o && n.fullDialCodeMatch && (!o.areaCodes || s) && (n = { country: o, fullDialCodeMatch: !0 });
217
228
  }
218
- return i;
229
+ return n;
219
230
  }, Me = (e, t) => {
220
- let d = parseInt(e, 16);
221
- return Number(d + t).toString(16);
222
- }, te = "abcdefghijklmnopqrstuvwxyz".split("").reduce((e, t, d) => ({ ...e, [t]: Me("1f1e6", d) }), {}), J = ({ iso2: e, size: t, src: d, protocol: l = "https", disableLazyLoading: a, className: i, style: b, ...g }) => e ? I.createElement("img", { className: B({ addPrefix: ["flag-emoji"], rawClassNames: [i] }), src: (() => {
223
- if (d) return d;
224
- let o = ((h) => [te[h[0]], te[h[1]]].join("-"))(e);
225
- return `${l}://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/${o}.svg`;
226
- })(), width: t, height: t, draggable: !1, "data-country": e, loading: a ? void 0 : "lazy", style: { width: t, height: t, ...b }, alt: "", ...g }) : I.createElement("img", { className: B({ addPrefix: ["flag-emoji"], rawClassNames: [i] }), width: t, height: t, ...g }), Ie = ({ show: e, dialCodePrefix: t = "+", selectedCountry: d, countries: l = T, preferredCountries: a = [], flags: i, onSelect: b, onClose: g, ...o }) => {
227
- let h = F(null), f = F(), w = Y(() => {
231
+ let r = parseInt(e, 16);
232
+ return Number(r + t).toString(16);
233
+ }, Le = "abcdefghijklmnopqrstuvwxyz", ze = "1f1e6", te = Le.split("").reduce((e, t, r) => ({ ...e, [t]: Me(ze, r) }), {}), _e = (e) => [te[e[0]], te[e[1]]].join("-"), Z = ({ iso2: e, size: t, src: r, protocol: l = "https", disableLazyLoading: a, className: n, style: f, ...u }) => {
234
+ if (!e) return S.createElement("img", { className: A({ addPrefix: ["flag-emoji"], rawClassNames: [n] }), width: t, height: t, ...u });
235
+ let o = () => {
236
+ if (r) return r;
237
+ let s = _e(e);
238
+ return `${l}://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/${s}.svg`;
239
+ };
240
+ return S.createElement("img", { className: A({ addPrefix: ["flag-emoji"], rawClassNames: [n] }), src: o(), width: t, height: t, draggable: !1, "data-country": e, loading: a ? void 0 : "lazy", style: { width: t, height: t, ...f }, alt: "", ...u });
241
+ }, Ve = 1e3, Be = ({ show: e, dialCodePrefix: t = "+", selectedCountry: r, countries: l = R, preferredCountries: a = [], flags: n, onSelect: f, onClose: u, ...o }) => {
242
+ let s = T(null), i = T(), y = Y(() => {
228
243
  if (!a || !a.length) return l;
229
- let s = [], u = [...l];
230
- for (let p of a) {
231
- let k = u.findIndex((C) => V(C).iso2 === p);
232
- if (k !== -1) {
233
- let C = u.splice(k, 1)[0];
234
- s.push(C);
244
+ let c = [], C = [...l];
245
+ for (let h of a) {
246
+ let D = C.findIndex((N) => _(N).iso2 === h);
247
+ if (D !== -1) {
248
+ let N = C.splice(D, 1)[0];
249
+ c.push(N);
235
250
  }
236
251
  }
237
- return s.concat(u);
238
- }, [l, a]), n = F({ updatedAt: void 0, value: "" }), c = R((s) => w.findIndex((u) => V(u).iso2 === s), [w]), [y, S] = G(c(d)), N = () => {
239
- f.current !== d && S(c(d));
240
- }, D = R((s) => {
241
- S(c(s.iso2)), b == null || b(s);
242
- }, [b, c]), r = (s) => {
243
- let u = w.length - 1;
244
- S((p) => {
245
- let k = ((C) => s === "prev" ? C - 1 : s === "next" ? C + 1 : s === "last" ? u : 0)(p);
246
- return k < 0 ? 0 : k > u ? u : k;
252
+ return c.concat(C);
253
+ }, [l, a]), d = T({ updatedAt: void 0, value: "" }), p = (c) => {
254
+ let C = d.current.updatedAt && (/* @__PURE__ */ new Date()).getTime() - d.current.updatedAt.getTime() > Ve;
255
+ d.current = { value: C ? c : `${d.current.value}${c}`, updatedAt: /* @__PURE__ */ new Date() };
256
+ let h = y.findIndex((D) => _(D).name.toLowerCase().startsWith(d.current.value));
257
+ h !== -1 && g(h);
258
+ }, v = O((c) => y.findIndex((C) => _(C).iso2 === c), [y]), [m, g] = G(v(r)), x = () => {
259
+ i.current !== r && g(v(r));
260
+ }, b = O((c) => {
261
+ g(v(c.iso2)), f == null || f(c);
262
+ }, [f, v]), E = (c) => {
263
+ let C = y.length - 1, h = (D) => c === "prev" ? D - 1 : c === "next" ? D + 1 : c === "last" ? C : 0;
264
+ g((D) => {
265
+ let N = h(D);
266
+ return N < 0 ? 0 : N > C ? C : N;
247
267
  });
248
- }, z = R(() => {
249
- if (!h.current || y === void 0) return;
250
- let s = V(w[y]).iso2;
251
- if (s === f.current) return;
252
- let u = h.current.querySelector(`[data-country="${s}"]`);
253
- u && (((p, k) => {
254
- let C = p.style.display;
255
- C !== "block" && (p.style.display = "block");
256
- let x = p.getBoundingClientRect(), v = k.getBoundingClientRect(), $ = v.top - x.top, m = x.bottom - v.bottom;
257
- $ >= 0 && m >= 0 || (Math.abs($) < Math.abs(m) ? p.scrollTop += $ : p.scrollTop -= m), p.style.display = C;
258
- })(h.current, u), f.current = s);
259
- }, [y, w]);
260
- return q(() => {
261
- z();
262
- }, [y, z]), q(() => {
263
- h.current && (e ? h.current.focus() : N());
264
- }, [e]), q(() => {
265
- N();
266
- }, [d]), I.createElement("ul", { ref: h, role: "listbox", className: B({ addPrefix: ["country-selector-dropdown"], rawClassNames: [o.className] }), style: { display: e ? "block" : "none", ...o.style }, onKeyDown: (s) => {
267
- if (s.stopPropagation(), s.key !== "Enter") {
268
- if (s.key !== "Escape") return s.key === "ArrowUp" ? (s.preventDefault(), void r("prev")) : s.key === "ArrowDown" ? (s.preventDefault(), void r("next")) : s.key === "PageUp" ? (s.preventDefault(), void r("first")) : s.key === "PageDown" ? (s.preventDefault(), void r("last")) : (s.key === " " && s.preventDefault(), void (s.key.length === 1 && !s.altKey && !s.ctrlKey && !s.metaKey && ((u) => {
269
- let p = n.current.updatedAt && (/* @__PURE__ */ new Date()).getTime() - n.current.updatedAt.getTime() > 1e3;
270
- n.current = { value: p ? u : `${n.current.value}${u}`, updatedAt: /* @__PURE__ */ new Date() };
271
- let k = w.findIndex((C) => V(C).name.toLowerCase().startsWith(n.current.value));
272
- k !== -1 && S(k);
273
- })(s.key.toLocaleLowerCase())));
274
- g == null || g();
275
- } else {
276
- s.preventDefault();
277
- let u = V(w[y]);
278
- D(u);
268
+ }, V = (c) => {
269
+ if (c.stopPropagation(), c.key === "Enter") {
270
+ c.preventDefault();
271
+ let C = _(y[m]);
272
+ b(C);
273
+ return;
274
+ }
275
+ if (c.key === "Escape") {
276
+ u == null || u();
277
+ return;
278
+ }
279
+ if (c.key === "ArrowUp") {
280
+ c.preventDefault(), E("prev");
281
+ return;
279
282
  }
280
- }, onBlur: g, tabIndex: -1, "aria-activedescendant": `react-international-phone__${V(w[y]).iso2}-option` }, w.map((s, u) => {
281
- let p = V(s), k = p.iso2 === d, C = u === y, x = a.includes(p.iso2), v = u === a.length - 1, $ = i == null ? void 0 : i.find((m) => m.iso2 === p.iso2);
282
- return I.createElement(I.Fragment, { key: p.iso2 }, I.createElement("li", { "data-country": p.iso2, role: "option", "aria-selected": k, "aria-label": `${p.name} ${t}${p.dialCode}`, id: `react-international-phone__${p.iso2}-option`, className: B({ addPrefix: ["country-selector-dropdown__list-item", x && "country-selector-dropdown__list-item--preferred", k && "country-selector-dropdown__list-item--selected", C && "country-selector-dropdown__list-item--focused"], rawClassNames: [o.listItemClassName] }), onClick: () => D(p), style: o.listItemStyle, title: p.name }, I.createElement(J, { iso2: p.iso2, src: $ == null ? void 0 : $.src, className: B({ addPrefix: ["country-selector-dropdown__list-item-flag-emoji"], rawClassNames: [o.listItemFlagClassName] }), style: o.listItemFlagStyle }), I.createElement("span", { className: B({ addPrefix: ["country-selector-dropdown__list-item-country-name"], rawClassNames: [o.listItemCountryNameClassName] }), style: o.listItemCountryNameStyle }, p.name), I.createElement("span", { className: B({ addPrefix: ["country-selector-dropdown__list-item-dial-code"], rawClassNames: [o.listItemDialCodeClassName] }), style: o.listItemDialCodeStyle }, t, p.dialCode)), v ? I.createElement("hr", { className: B({ addPrefix: ["country-selector-dropdown__preferred-list-divider"], rawClassNames: [o.preferredListDividerClassName] }), style: o.preferredListDividerStyle }) : null);
283
+ if (c.key === "ArrowDown") {
284
+ c.preventDefault(), E("next");
285
+ return;
286
+ }
287
+ if (c.key === "PageUp") {
288
+ c.preventDefault(), E("first");
289
+ return;
290
+ }
291
+ if (c.key === "PageDown") {
292
+ c.preventDefault(), E("last");
293
+ return;
294
+ }
295
+ c.key === " " && c.preventDefault(), c.key.length === 1 && !c.altKey && !c.ctrlKey && !c.metaKey && p(c.key.toLocaleLowerCase());
296
+ }, M = O(() => {
297
+ if (!s.current || m === void 0) return;
298
+ let c = _(y[m]).iso2;
299
+ if (c === i.current) return;
300
+ let C = s.current.querySelector(`[data-country="${c}"]`);
301
+ C && (be(s.current, C), i.current = c);
302
+ }, [m, y]);
303
+ return U(() => {
304
+ M();
305
+ }, [m, M]), U(() => {
306
+ s.current && (e ? s.current.focus() : x());
307
+ }, [e]), U(() => {
308
+ x();
309
+ }, [r]), S.createElement("ul", { ref: s, role: "listbox", className: A({ addPrefix: ["country-selector-dropdown"], rawClassNames: [o.className] }), style: { display: e ? "block" : "none", ...o.style }, onKeyDown: V, onBlur: u, tabIndex: -1, "aria-activedescendant": `react-international-phone__${_(y[m]).iso2}-option` }, y.map((c, C) => {
310
+ let h = _(c), D = h.iso2 === r, N = C === m, k = a.includes(h.iso2), I = C === a.length - 1, L = n == null ? void 0 : n.find((w) => w.iso2 === h.iso2);
311
+ return S.createElement(S.Fragment, { key: h.iso2 }, S.createElement("li", { "data-country": h.iso2, role: "option", "aria-selected": D, "aria-label": `${h.name} ${t}${h.dialCode}`, id: `react-international-phone__${h.iso2}-option`, className: A({ addPrefix: ["country-selector-dropdown__list-item", k && "country-selector-dropdown__list-item--preferred", D && "country-selector-dropdown__list-item--selected", N && "country-selector-dropdown__list-item--focused"], rawClassNames: [o.listItemClassName] }), onClick: () => b(h), style: o.listItemStyle, title: h.name }, S.createElement(Z, { iso2: h.iso2, src: L == null ? void 0 : L.src, className: A({ addPrefix: ["country-selector-dropdown__list-item-flag-emoji"], rawClassNames: [o.listItemFlagClassName] }), style: o.listItemFlagStyle }), S.createElement("span", { className: A({ addPrefix: ["country-selector-dropdown__list-item-country-name"], rawClassNames: [o.listItemCountryNameClassName] }), style: o.listItemCountryNameStyle }, h.name), S.createElement("span", { className: A({ addPrefix: ["country-selector-dropdown__list-item-dial-code"], rawClassNames: [o.listItemDialCodeClassName] }), style: o.listItemDialCodeStyle }, t, h.dialCode)), I ? S.createElement("hr", { className: A({ addPrefix: ["country-selector-dropdown__preferred-list-divider"], rawClassNames: [o.preferredListDividerClassName] }), style: o.preferredListDividerStyle }) : null);
283
312
  }));
284
- }, ze = ({ selectedCountry: e, onSelect: t, disabled: d, hideDropdown: l, countries: a = T, preferredCountries: i = [], flags: b, renderButtonWrapper: g, ...o }) => {
285
- let [h, f] = G(!1), w = Y(() => {
286
- if (e) return K({ value: e, field: "iso2", countries: a });
287
- }, [a, e]), n = F(null), c = (y) => {
288
- y.key && ["ArrowUp", "ArrowDown"].includes(y.key) && (y.preventDefault(), f(!0));
313
+ }, Fe = ({ selectedCountry: e, onSelect: t, disabled: r, hideDropdown: l, countries: a = R, preferredCountries: n = [], flags: f, renderButtonWrapper: u, ...o }) => {
314
+ let [s, i] = G(!1), y = Y(() => {
315
+ if (e) return q({ value: e, field: "iso2", countries: a });
316
+ }, [a, e]), d = T(null), p = (m) => {
317
+ m.key && ["ArrowUp", "ArrowDown"].includes(m.key) && (m.preventDefault(), i(!0));
318
+ }, v = () => {
319
+ var x;
320
+ let m = { title: y == null ? void 0 : y.name, onClick: () => i((b) => !b), onMouseDown: (b) => b.preventDefault(), onKeyDown: p, disabled: l || r, role: "combobox", "aria-label": "Country selector", "aria-haspopup": "listbox", "aria-expanded": s }, g = S.createElement("div", { className: A({ addPrefix: ["country-selector-button__button-content"], rawClassNames: [o.buttonContentWrapperClassName] }), style: o.buttonContentWrapperStyle }, S.createElement(Z, { iso2: e, src: (x = f == null ? void 0 : f.find((b) => b.iso2 === e)) == null ? void 0 : x.src, className: A({ addPrefix: ["country-selector-button__flag-emoji", r && "country-selector-button__flag-emoji--disabled"], rawClassNames: [o.flagClassName] }), style: { visibility: e ? "visible" : "hidden", ...o.flagStyle } }), !l && S.createElement("div", { className: A({ addPrefix: ["country-selector-button__dropdown-arrow", r && "country-selector-button__dropdown-arrow--disabled", s && "country-selector-button__dropdown-arrow--active"], rawClassNames: [o.dropdownArrowClassName] }), style: o.dropdownArrowStyle }));
321
+ return u ? u({ children: g, rootProps: m }) : S.createElement("button", { ...m, type: "button", className: A({ addPrefix: ["country-selector-button", s && "country-selector-button--active", r && "country-selector-button--disabled", l && "country-selector-button--hide-dropdown"], rawClassNames: [o.buttonClassName] }), "data-country": e, style: o.buttonStyle }, g);
289
322
  };
290
- return I.createElement("div", { className: B({ addPrefix: ["country-selector"], rawClassNames: [o.className] }), style: o.style, ref: n }, (() => {
291
- var N;
292
- let y = { title: w == null ? void 0 : w.name, onClick: () => f((D) => !D), onMouseDown: (D) => D.preventDefault(), onKeyDown: c, disabled: l || d, role: "combobox", "aria-label": "Country selector", "aria-haspopup": "listbox", "aria-expanded": h }, S = I.createElement("div", { className: B({ addPrefix: ["country-selector-button__button-content"], rawClassNames: [o.buttonContentWrapperClassName] }), style: o.buttonContentWrapperStyle }, I.createElement(J, { iso2: e, src: (N = b == null ? void 0 : b.find((D) => D.iso2 === e)) == null ? void 0 : N.src, className: B({ addPrefix: ["country-selector-button__flag-emoji", d && "country-selector-button__flag-emoji--disabled"], rawClassNames: [o.flagClassName] }), style: { visibility: e ? "visible" : "hidden", ...o.flagStyle } }), !l && I.createElement("div", { className: B({ addPrefix: ["country-selector-button__dropdown-arrow", d && "country-selector-button__dropdown-arrow--disabled", h && "country-selector-button__dropdown-arrow--active"], rawClassNames: [o.dropdownArrowClassName] }), style: o.dropdownArrowStyle }));
293
- return g ? g({ children: S, rootProps: y }) : I.createElement("button", { ...y, type: "button", className: B({ addPrefix: ["country-selector-button", h && "country-selector-button--active", d && "country-selector-button--disabled", l && "country-selector-button--hide-dropdown"], rawClassNames: [o.buttonClassName] }), "data-country": e, style: o.buttonStyle }, S);
294
- })(), I.createElement(Ie, { show: h, countries: a, preferredCountries: i, flags: b, onSelect: (y) => {
295
- f(!1), t == null || t(y);
323
+ return S.createElement("div", { className: A({ addPrefix: ["country-selector"], rawClassNames: [o.className] }), style: o.style, ref: d }, v(), S.createElement(Be, { show: s, countries: a, preferredCountries: n, flags: f, onSelect: (m) => {
324
+ i(!1), t == null || t(m);
296
325
  }, selectedCountry: e, onClose: () => {
297
- f(!1);
326
+ i(!1);
298
327
  }, ...o.dropdownStyleProps }));
299
- }, Le = ({ dialCode: e, prefix: t, disabled: d, style: l, className: a }) => I.createElement("div", { className: B({ addPrefix: ["dial-code-preview", d && "dial-code-preview--disabled"], rawClassNames: [a] }), style: l }, `${t}${e}`);
300
- ae(({ value: e, onChange: t, countries: d = T, preferredCountries: l = [], hideDropdown: a, showDisabledDialCodeAndPrefix: i, disableFocusAfterCountrySelect: b, flags: g, style: o, className: h, inputStyle: f, inputClassName: w, countrySelectorStyleProps: n, dialCodePreviewStyleProps: c, inputProps: y, placeholder: S, disabled: N, name: D, onFocus: r, onBlur: z, required: s, autoFocus: u, ...p }, k) => {
301
- let { phone: C, inputValue: x, inputRef: v, country: $, setCountry: m, handlePhoneValueChange: A } = ne({ value: e, countries: d, ...p, onChange: (E) => {
302
- t == null || t(E.phone, { country: E.country, inputValue: E.inputValue });
303
- } }), P = p.disableDialCodeAndPrefix && i && ($ == null ? void 0 : $.dialCode);
304
- return le(k, () => v.current ? Object.assign(v.current, { setCountry: m, state: { phone: C, inputValue: x, country: $ } }) : null, [v, m, C, x, $]), I.createElement("div", { ref: k, className: B({ addPrefix: ["input-container"], rawClassNames: [h] }), style: o }, I.createElement(ze, { onSelect: (E) => m(E.iso2, { focusOnInput: !b }), flags: g, selectedCountry: $.iso2, countries: d, preferredCountries: l, disabled: N, hideDropdown: a, ...n }), P && I.createElement(Le, { dialCode: $.dialCode, prefix: p.prefix ?? "+", disabled: N, ...c }), I.createElement("input", { onChange: A, value: x, type: "tel", ref: v, className: B({ addPrefix: ["input", N && "input--disabled"], rawClassNames: [w] }), placeholder: S, disabled: N, style: f, name: D, onFocus: r, onBlur: z, autoFocus: u, required: s, ...y }));
328
+ }, je = ({ dialCode: e, prefix: t, disabled: r, style: l, className: a }) => S.createElement("div", { className: A({ addPrefix: ["dial-code-preview", r && "dial-code-preview--disabled"], rawClassNames: [a] }), style: l }, `${t}${e}`);
329
+ ae(({ value: e, onChange: t, countries: r = R, preferredCountries: l = [], hideDropdown: a, showDisabledDialCodeAndPrefix: n, disableFocusAfterCountrySelect: f, flags: u, style: o, className: s, inputStyle: i, inputClassName: y, countrySelectorStyleProps: d, dialCodePreviewStyleProps: p, inputProps: v, placeholder: m, disabled: g, name: x, onFocus: b, onBlur: E, required: V, autoFocus: M, ...c }, C) => {
330
+ let { phone: h, inputValue: D, inputRef: N, country: k, setCountry: I, handlePhoneValueChange: L } = oe({ value: e, countries: r, ...c, onChange: ($) => {
331
+ t == null || t($.phone, { country: $.country, inputValue: $.inputValue });
332
+ } }), w = c.disableDialCodeAndPrefix && n && (k == null ? void 0 : k.dialCode);
333
+ return de(C, () => N.current ? Object.assign(N.current, { setCountry: I, state: { phone: h, inputValue: D, country: k } }) : null, [N, I, h, D, k]), S.createElement("div", { ref: C, className: A({ addPrefix: ["input-container"], rawClassNames: [s] }), style: o }, S.createElement(Fe, { onSelect: ($) => I($.iso2, { focusOnInput: !f }), flags: u, selectedCountry: k.iso2, countries: r, preferredCountries: l, disabled: g, hideDropdown: a, ...d }), w && S.createElement(je, { dialCode: k.dialCode, prefix: c.prefix ?? "+", disabled: g, ...p }), S.createElement("input", { onChange: L, value: D, type: "tel", ref: N, className: A({ addPrefix: ["input", g && "input--disabled"], rawClassNames: [y] }), placeholder: m, disabled: g, style: i, name: x, onFocus: b, onBlur: E, autoFocus: M, required: V, ...v }));
305
334
  });
306
- const Be = W.div`
335
+ const Te = W.div`
307
336
  ${({ theme: e }) => `
308
337
  align-items: flex-start;
309
338
  align-self: stretch;
@@ -343,7 +372,7 @@ const Be = W.div`
343
372
  }
344
373
  }
345
374
  `}
346
- `, Ve = W.button`
375
+ `, Ge = W.button`
347
376
  ${({ theme: e }) => `
348
377
  align-items: center;
349
378
  background: inherit;
@@ -359,7 +388,7 @@ const Be = W.div`
359
388
  cursor: not-allowed;
360
389
  }
361
390
  `}
362
- `, _e = W.ul`
391
+ `, Re = W.ul`
363
392
  ${({ theme: e }) => `
364
393
  align-items: flex-start;
365
394
  box-shadow: ${e.shadows.md};
@@ -372,7 +401,7 @@ const Be = W.div`
372
401
  scrollbar-width: thin;
373
402
  width: max-content;
374
403
  `}
375
- `, je = W.li`
404
+ `, Oe = W.li`
376
405
  ${({ theme: e }) => `
377
406
  align-items: center;
378
407
  background: ${e.palette.white};
@@ -389,31 +418,162 @@ const Be = W.div`
389
418
  background: ${e.palette.gray[100]};
390
419
  }
391
420
  `}
392
- `, Fe = W.p`
421
+ `, Ke = W.p`
393
422
  color: ${({ theme: e }) => e.palette.gray[800]};
394
423
  font-size: inherit;
395
424
  min-width: 55%;
396
425
  overflow: hidden;
397
426
  text-overflow: ellipsis;
398
427
  white-space: nowrap;
399
- `, Ye = ae(function({ disabled: e, error: t, label: d, name: l, required: a, tooltip: i, value: b, weight: g, ...o }, h) {
400
- const f = de(), [w, n] = G(!1), [c, y] = G(""), S = F(null), { refs: N, floatingStyles: D } = oe({ placement: "bottom-start", whileElementsMounted: ie }), { inputValue: r, handlePhoneValueChange: z, country: s, setCountry: u } = ne({ countries: T, defaultCountry: "us", value: b ? String(b) : void 0 }), p = R(() => {
401
- n((v) => !v), w || y("");
402
- }, [w]), k = R((v) => () => {
403
- u(v), n(!1), y("");
404
- }, [u, n]), C = R((v) => {
405
- v.key.length === 1 ? y(($) => $ + v.key) : v.key === "Backspace" && y(($) => $.slice(0, -1));
406
- }, []), x = T.filter((v) => {
407
- const { name: $ } = V(v);
408
- return $.toLowerCase().includes(c.toLowerCase());
428
+ `, rt = ae(function({
429
+ disabled: t,
430
+ error: r,
431
+ label: l,
432
+ name: a,
433
+ required: n,
434
+ tooltip: f,
435
+ value: u,
436
+ weight: o,
437
+ ...s
438
+ }, i) {
439
+ const y = ce(), [d, p] = G(!1), [v, m] = G(""), g = T(null), { refs: x, floatingStyles: b } = le({
440
+ placement: "bottom-start",
441
+ whileElementsMounted: se
442
+ }), { inputValue: E, handlePhoneValueChange: V, country: M, setCountry: c } = oe({
443
+ countries: R,
444
+ defaultCountry: "us",
445
+ value: u ? String(u) : void 0
446
+ }), C = O(() => {
447
+ p((k) => !k), d || m("");
448
+ }, [d]), h = O(
449
+ (k) => () => {
450
+ c(k), p(!1), m("");
451
+ },
452
+ [c, p]
453
+ ), D = O(
454
+ (k) => {
455
+ k.key.length === 1 ? m((I) => I + k.key) : k.key === "Backspace" && m((I) => I.slice(0, -1));
456
+ },
457
+ []
458
+ ), N = R.filter((k) => {
459
+ const { name: I } = _(k);
460
+ return I.toLowerCase().includes(v.toLowerCase());
409
461
  });
410
- return fe(N.floating.current, () => {
411
- n(!1), y("");
412
- }, !0), _(ue, { error: t, htmlFor: l, label: d, required: a, tooltip: i, weight: g, children: U(Be, { className: `${e ? "disabled" : ""} ${t ? "error" : ""}`, ref: S, children: [U(Ve, { "aria-label": "country-selector", "data-testid": "country-selector", disabled: e, id: "country-selector", onClick: p, onKeyDown: C, ref: N.setReference, children: [_(J, { iso2: s.iso2, size: "16px" }), _(X, { icon: "angle-down", iconColor: f.palette.gray[400], iconSize: "xs", iconType: "fa-light" })] }), U(ce, { className: `${e ? "disabled" : ""} ${t ? "error" : ""}`, children: [_("input", { "aria-hidden": !1, "aria-invalid": t ? "true" : "false", "aria-label": l, "aria-required": a, autoComplete: "off", "data-testid": `${l}-input`, disabled: e, id: l, name: l, onChange: z, ref: h, type: "tel", value: r, ...o }), t ? _(X, { icon: "exclamation-circle", iconClass: "error-icon", iconColor: f.palette.error[500], iconSize: "xs" }) : void 0] }), w && se(_(_e, { ref: N.setFloating, style: D, children: x.map((v) => {
413
- const { dialCode: $, iso2: m, name: A } = V(v);
414
- return U(je, { onClick: k(m), value: m, children: [_(J, { iso2: m, size: "16px" }), _(Fe, { children: A }), _(pe, { color: f.palette.gray[400], size: "sm", sizeSm: "xs", textAlign: "end", children: "+" + $ })] }, m);
415
- }) }), document.getElementById("root") ?? document.body)] }) });
462
+ return me(
463
+ x.floating.current,
464
+ () => {
465
+ p(!1), m("");
466
+ },
467
+ !0
468
+ ), /* @__PURE__ */ F(
469
+ fe,
470
+ {
471
+ error: r,
472
+ htmlFor: a,
473
+ label: l,
474
+ required: n,
475
+ tooltip: f,
476
+ weight: o,
477
+ children: /* @__PURE__ */ H(
478
+ Te,
479
+ {
480
+ className: `${t ? "disabled" : ""} ${r ? "error" : ""}`,
481
+ ref: g,
482
+ children: [
483
+ /* @__PURE__ */ H(
484
+ Ge,
485
+ {
486
+ "aria-label": "country-selector",
487
+ "data-testid": "country-selector",
488
+ disabled: t,
489
+ id: "country-selector",
490
+ onClick: C,
491
+ onKeyDown: D,
492
+ ref: x.setReference,
493
+ children: [
494
+ /* @__PURE__ */ F(Z, { iso2: M.iso2, size: "16px" }),
495
+ /* @__PURE__ */ F(
496
+ ee,
497
+ {
498
+ icon: "angle-down",
499
+ iconColor: y.palette.gray[400],
500
+ iconSize: "xs",
501
+ iconType: "fa-light"
502
+ }
503
+ )
504
+ ]
505
+ }
506
+ ),
507
+ /* @__PURE__ */ H(
508
+ pe,
509
+ {
510
+ className: `${t ? "disabled" : ""} ${r ? "error" : ""}`,
511
+ children: [
512
+ /* @__PURE__ */ F(
513
+ "input",
514
+ {
515
+ "aria-hidden": !1,
516
+ "aria-invalid": r ? "true" : "false",
517
+ "aria-label": a,
518
+ "aria-required": n,
519
+ autoComplete: "off",
520
+ "data-testid": `${a}-input`,
521
+ disabled: t,
522
+ id: a,
523
+ name: a,
524
+ onChange: V,
525
+ ref: i,
526
+ type: "tel",
527
+ value: E,
528
+ ...s
529
+ }
530
+ ),
531
+ r ? /* @__PURE__ */ F(
532
+ ee,
533
+ {
534
+ icon: "exclamation-circle",
535
+ iconClass: "error-icon",
536
+ iconColor: y.palette.error[500],
537
+ iconSize: "xs"
538
+ }
539
+ ) : void 0
540
+ ]
541
+ }
542
+ ),
543
+ d && ue(
544
+ /* @__PURE__ */ F(Re, { ref: x.setFloating, style: b, children: N.map((k) => {
545
+ const { dialCode: I, iso2: L, name: w } = _(k);
546
+ return /* @__PURE__ */ H(
547
+ Oe,
548
+ {
549
+ onClick: h(L),
550
+ value: L,
551
+ children: [
552
+ /* @__PURE__ */ F(Z, { iso2: L, size: "16px" }),
553
+ /* @__PURE__ */ F(Ke, { children: w }),
554
+ /* @__PURE__ */ F(
555
+ ye,
556
+ {
557
+ color: y.palette.gray[400],
558
+ size: "sm",
559
+ sizeSm: "xs",
560
+ textAlign: "end",
561
+ children: "+" + I
562
+ }
563
+ )
564
+ ]
565
+ },
566
+ L
567
+ );
568
+ }) }),
569
+ document.getElementById("root") ?? document.body
570
+ )
571
+ ]
572
+ }
573
+ )
574
+ }
575
+ );
416
576
  });
417
577
  export {
418
- Ye as PhoneInput
578
+ rt as PhoneInput
419
579
  };