country-select-pro 5.6.6 → 6.1.4

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 (549) hide show
  1. package/README.md +5 -7
  2. package/dist/country-select.js +132 -36
  3. package/dist/country-select.min.js +1 -1
  4. package/dist/data.json +4333 -0
  5. package/dist/flags/1x1/ad.svg +148 -0
  6. package/dist/flags/1x1/ae.svg +6 -0
  7. package/dist/flags/1x1/af.svg +81 -0
  8. package/dist/flags/1x1/ag.svg +14 -0
  9. package/dist/flags/1x1/ai.svg +29 -0
  10. package/dist/flags/1x1/al.svg +5 -0
  11. package/dist/flags/1x1/am.svg +5 -0
  12. package/dist/flags/1x1/ao.svg +13 -0
  13. package/dist/flags/1x1/aq.svg +5 -0
  14. package/dist/flags/1x1/ar.svg +32 -0
  15. package/dist/flags/1x1/arab.svg +109 -0
  16. package/dist/flags/1x1/as.svg +73 -0
  17. package/dist/flags/1x1/asean.svg +13 -0
  18. package/dist/flags/1x1/at.svg +4 -0
  19. package/dist/flags/1x1/au.svg +8 -0
  20. package/dist/flags/1x1/aw.svg +186 -0
  21. package/dist/flags/1x1/ax.svg +18 -0
  22. package/dist/flags/1x1/az.svg +8 -0
  23. package/dist/flags/1x1/ba.svg +12 -0
  24. package/dist/flags/1x1/bb.svg +6 -0
  25. package/dist/flags/1x1/bd.svg +4 -0
  26. package/dist/flags/1x1/be.svg +7 -0
  27. package/dist/flags/1x1/bf.svg +7 -0
  28. package/dist/flags/1x1/bg.svg +5 -0
  29. package/dist/flags/1x1/bh.svg +4 -0
  30. package/dist/flags/1x1/bi.svg +15 -0
  31. package/dist/flags/1x1/bj.svg +14 -0
  32. package/dist/flags/1x1/bl.svg +7 -0
  33. package/dist/flags/1x1/bm.svg +97 -0
  34. package/dist/flags/1x1/bn.svg +36 -0
  35. package/dist/flags/1x1/bo.svg +674 -0
  36. package/dist/flags/1x1/bq.svg +5 -0
  37. package/dist/flags/1x1/br.svg +45 -0
  38. package/dist/flags/1x1/bs.svg +13 -0
  39. package/dist/flags/1x1/bt.svg +89 -0
  40. package/dist/flags/1x1/bv.svg +13 -0
  41. package/dist/flags/1x1/bw.svg +7 -0
  42. package/dist/flags/1x1/by.svg +18 -0
  43. package/dist/flags/1x1/bz.svg +145 -0
  44. package/dist/flags/1x1/ca.svg +4 -0
  45. package/dist/flags/1x1/cc.svg +19 -0
  46. package/dist/flags/1x1/cd.svg +12 -0
  47. package/dist/flags/1x1/cefta.svg +13 -0
  48. package/dist/flags/1x1/cf.svg +15 -0
  49. package/dist/flags/1x1/cg.svg +12 -0
  50. package/dist/flags/1x1/ch.svg +9 -0
  51. package/dist/flags/1x1/ci.svg +7 -0
  52. package/dist/flags/1x1/ck.svg +9 -0
  53. package/dist/flags/1x1/cl.svg +13 -0
  54. package/dist/flags/1x1/cm.svg +15 -0
  55. package/dist/flags/1x1/cn.svg +11 -0
  56. package/dist/flags/1x1/co.svg +7 -0
  57. package/dist/flags/1x1/cp.svg +7 -0
  58. package/dist/flags/1x1/cr.svg +7 -0
  59. package/dist/flags/1x1/cu.svg +13 -0
  60. package/dist/flags/1x1/cv.svg +13 -0
  61. package/dist/flags/1x1/cw.svg +14 -0
  62. package/dist/flags/1x1/cx.svg +15 -0
  63. package/dist/flags/1x1/cy.svg +6 -0
  64. package/dist/flags/1x1/cz.svg +5 -0
  65. package/dist/flags/1x1/de.svg +5 -0
  66. package/dist/flags/1x1/dg.svg +130 -0
  67. package/dist/flags/1x1/dj.svg +13 -0
  68. package/dist/flags/1x1/dk.svg +5 -0
  69. package/dist/flags/1x1/dm.svg +152 -0
  70. package/dist/flags/1x1/do.svg +122 -0
  71. package/dist/flags/1x1/dz.svg +5 -0
  72. package/dist/flags/1x1/eac.svg +48 -0
  73. package/dist/flags/1x1/ec.svg +138 -0
  74. package/dist/flags/1x1/ee.svg +5 -0
  75. package/dist/flags/1x1/eg.svg +38 -0
  76. package/dist/flags/1x1/eh.svg +11 -0
  77. package/dist/flags/1x1/er.svg +13 -0
  78. package/dist/flags/1x1/es-ct.svg +4 -0
  79. package/dist/flags/1x1/es-ga.svg +187 -0
  80. package/dist/flags/1x1/es-pv.svg +5 -0
  81. package/dist/flags/1x1/es.svg +547 -0
  82. package/dist/flags/1x1/et.svg +14 -0
  83. package/dist/flags/1x1/eu.svg +28 -0
  84. package/dist/flags/1x1/fi.svg +5 -0
  85. package/dist/flags/1x1/fj.svg +123 -0
  86. package/dist/flags/1x1/fk.svg +89 -0
  87. package/dist/flags/1x1/fm.svg +11 -0
  88. package/dist/flags/1x1/fo.svg +12 -0
  89. package/dist/flags/1x1/fr.svg +5 -0
  90. package/dist/flags/1x1/ga.svg +7 -0
  91. package/dist/flags/1x1/gb-eng.svg +5 -0
  92. package/dist/flags/1x1/gb-nir.svg +131 -0
  93. package/dist/flags/1x1/gb-sct.svg +4 -0
  94. package/dist/flags/1x1/gb-wls.svg +9 -0
  95. package/dist/flags/1x1/gb.svg +7 -0
  96. package/dist/flags/1x1/gd.svg +27 -0
  97. package/dist/flags/1x1/ge.svg +6 -0
  98. package/dist/flags/1x1/gf.svg +5 -0
  99. package/dist/flags/1x1/gg.svg +9 -0
  100. package/dist/flags/1x1/gh.svg +6 -0
  101. package/dist/flags/1x1/gi.svg +32 -0
  102. package/dist/flags/1x1/gl.svg +4 -0
  103. package/dist/flags/1x1/gm.svg +9 -0
  104. package/dist/flags/1x1/gn.svg +7 -0
  105. package/dist/flags/1x1/gp.svg +5 -0
  106. package/dist/flags/1x1/gq.svg +23 -0
  107. package/dist/flags/1x1/gr.svg +16 -0
  108. package/dist/flags/1x1/gs.svg +132 -0
  109. package/dist/flags/1x1/gt.svg +204 -0
  110. package/dist/flags/1x1/gu.svg +19 -0
  111. package/dist/flags/1x1/gw.svg +15 -0
  112. package/dist/flags/1x1/gy.svg +9 -0
  113. package/dist/flags/1x1/hk.svg +8 -0
  114. package/dist/flags/1x1/hm.svg +8 -0
  115. package/dist/flags/1x1/hn.svg +18 -0
  116. package/dist/flags/1x1/hr.svg +56 -0
  117. package/dist/flags/1x1/ht.svg +116 -0
  118. package/dist/flags/1x1/hu.svg +7 -0
  119. package/dist/flags/1x1/ic.svg +7 -0
  120. package/dist/flags/1x1/id.svg +4 -0
  121. package/dist/flags/1x1/ie.svg +7 -0
  122. package/dist/flags/1x1/il.svg +14 -0
  123. package/dist/flags/1x1/im.svg +36 -0
  124. package/dist/flags/1x1/in.svg +25 -0
  125. package/dist/flags/1x1/io.svg +130 -0
  126. package/dist/flags/1x1/iq.svg +10 -0
  127. package/dist/flags/1x1/ir.svg +219 -0
  128. package/dist/flags/1x1/is.svg +12 -0
  129. package/dist/flags/1x1/it.svg +7 -0
  130. package/dist/flags/1x1/je.svg +62 -0
  131. package/dist/flags/1x1/jm.svg +8 -0
  132. package/dist/flags/1x1/jo.svg +16 -0
  133. package/dist/flags/1x1/jp.svg +11 -0
  134. package/dist/flags/1x1/ke.svg +23 -0
  135. package/dist/flags/1x1/kg.svg +4 -0
  136. package/dist/flags/1x1/kh.svg +61 -0
  137. package/dist/flags/1x1/ki.svg +36 -0
  138. package/dist/flags/1x1/km.svg +16 -0
  139. package/dist/flags/1x1/kn.svg +14 -0
  140. package/dist/flags/1x1/kp.svg +15 -0
  141. package/dist/flags/1x1/kr.svg +17 -0
  142. package/dist/flags/1x1/kw.svg +13 -0
  143. package/dist/flags/1x1/ky.svg +103 -0
  144. package/dist/flags/1x1/kz.svg +36 -0
  145. package/dist/flags/1x1/la.svg +12 -0
  146. package/dist/flags/1x1/lb.svg +15 -0
  147. package/dist/flags/1x1/lc.svg +8 -0
  148. package/dist/flags/1x1/li.svg +43 -0
  149. package/dist/flags/1x1/lk.svg +22 -0
  150. package/dist/flags/1x1/lr.svg +14 -0
  151. package/dist/flags/1x1/ls.svg +8 -0
  152. package/dist/flags/1x1/lt.svg +7 -0
  153. package/dist/flags/1x1/lu.svg +5 -0
  154. package/dist/flags/1x1/lv.svg +6 -0
  155. package/dist/flags/1x1/ly.svg +13 -0
  156. package/dist/flags/1x1/ma.svg +4 -0
  157. package/dist/flags/1x1/mc.svg +6 -0
  158. package/dist/flags/1x1/md.svg +71 -0
  159. package/dist/flags/1x1/me.svg +118 -0
  160. package/dist/flags/1x1/mf.svg +5 -0
  161. package/dist/flags/1x1/mg.svg +7 -0
  162. package/dist/flags/1x1/mh.svg +8 -0
  163. package/dist/flags/1x1/mk.svg +5 -0
  164. package/dist/flags/1x1/ml.svg +7 -0
  165. package/dist/flags/1x1/mm.svg +10 -0
  166. package/dist/flags/1x1/mn.svg +14 -0
  167. package/dist/flags/1x1/mo.svg +9 -0
  168. package/dist/flags/1x1/mp.svg +86 -0
  169. package/dist/flags/1x1/mq.svg +5 -0
  170. package/dist/flags/1x1/mr.svg +6 -0
  171. package/dist/flags/1x1/ms.svg +25 -0
  172. package/dist/flags/1x1/mt.svg +56 -0
  173. package/dist/flags/1x1/mu.svg +8 -0
  174. package/dist/flags/1x1/mv.svg +6 -0
  175. package/dist/flags/1x1/mw.svg +15 -0
  176. package/dist/flags/1x1/mx.svg +377 -0
  177. package/dist/flags/1x1/my.svg +18 -0
  178. package/dist/flags/1x1/mz.svg +21 -0
  179. package/dist/flags/1x1/na.svg +16 -0
  180. package/dist/flags/1x1/nc.svg +12 -0
  181. package/dist/flags/1x1/ne.svg +6 -0
  182. package/dist/flags/1x1/nf.svg +11 -0
  183. package/dist/flags/1x1/ng.svg +6 -0
  184. package/dist/flags/1x1/ni.svg +129 -0
  185. package/dist/flags/1x1/nl.svg +5 -0
  186. package/dist/flags/1x1/no.svg +7 -0
  187. package/dist/flags/1x1/np.svg +18 -0
  188. package/dist/flags/1x1/nr.svg +12 -0
  189. package/dist/flags/1x1/nu.svg +10 -0
  190. package/dist/flags/1x1/null +1 -0
  191. package/dist/flags/1x1/nz.svg +36 -0
  192. package/dist/flags/1x1/om.svg +115 -0
  193. package/dist/flags/1x1/pa.svg +13 -0
  194. package/dist/flags/1x1/pc.svg +33 -0
  195. package/dist/flags/1x1/pe.svg +4 -0
  196. package/dist/flags/1x1/pf.svg +18 -0
  197. package/dist/flags/1x1/pg.svg +16 -0
  198. package/dist/flags/1x1/ph.svg +6 -0
  199. package/dist/flags/1x1/pk.svg +15 -0
  200. package/dist/flags/1x1/pl.svg +6 -0
  201. package/dist/flags/1x1/pm.svg +5 -0
  202. package/dist/flags/1x1/pn.svg +53 -0
  203. package/dist/flags/1x1/pr.svg +13 -0
  204. package/dist/flags/1x1/ps.svg +6 -0
  205. package/dist/flags/1x1/pt.svg +57 -0
  206. package/dist/flags/1x1/pw.svg +11 -0
  207. package/dist/flags/1x1/py.svg +156 -0
  208. package/dist/flags/1x1/qa.svg +4 -0
  209. package/dist/flags/1x1/re.svg +7 -0
  210. package/dist/flags/1x1/ro.svg +7 -0
  211. package/dist/flags/1x1/rs.svg +296 -0
  212. package/dist/flags/1x1/ru.svg +5 -0
  213. package/dist/flags/1x1/rw.svg +13 -0
  214. package/dist/flags/1x1/sa.svg +25 -0
  215. package/dist/flags/1x1/sb.svg +13 -0
  216. package/dist/flags/1x1/sc.svg +7 -0
  217. package/dist/flags/1x1/sd.svg +13 -0
  218. package/dist/flags/1x1/se.svg +4 -0
  219. package/dist/flags/1x1/sg.svg +13 -0
  220. package/dist/flags/1x1/sh-ac.svg +690 -0
  221. package/dist/flags/1x1/sh-hl.svg +164 -0
  222. package/dist/flags/1x1/sh-ta.svg +76 -0
  223. package/dist/flags/1x1/sh.svg +7 -0
  224. package/dist/flags/1x1/si.svg +18 -0
  225. package/dist/flags/1x1/sj.svg +7 -0
  226. package/dist/flags/1x1/sk.svg +9 -0
  227. package/dist/flags/1x1/sl.svg +12 -0
  228. package/dist/flags/1x1/sm.svg +73 -0
  229. package/dist/flags/1x1/sn.svg +8 -0
  230. package/dist/flags/1x1/so.svg +11 -0
  231. package/dist/flags/1x1/sr.svg +6 -0
  232. package/dist/flags/1x1/ss.svg +8 -0
  233. package/dist/flags/1x1/st.svg +16 -0
  234. package/dist/flags/1x1/sv.svg +593 -0
  235. package/dist/flags/1x1/sx.svg +56 -0
  236. package/dist/flags/1x1/sy.svg +6 -0
  237. package/dist/flags/1x1/sz.svg +34 -0
  238. package/dist/flags/1x1/tc.svg +50 -0
  239. package/dist/flags/1x1/td.svg +7 -0
  240. package/dist/flags/1x1/tf.svg +15 -0
  241. package/dist/flags/1x1/tg.svg +14 -0
  242. package/dist/flags/1x1/th.svg +7 -0
  243. package/dist/flags/1x1/tj.svg +26 -0
  244. package/dist/flags/1x1/tk.svg +5 -0
  245. package/dist/flags/1x1/tl.svg +13 -0
  246. package/dist/flags/1x1/tm.svg +205 -0
  247. package/dist/flags/1x1/tn.svg +4 -0
  248. package/dist/flags/1x1/to.svg +10 -0
  249. package/dist/flags/1x1/tr.svg +8 -0
  250. package/dist/flags/1x1/tt.svg +7 -0
  251. package/dist/flags/1x1/tv.svg +9 -0
  252. package/dist/flags/1x1/tw.svg +32 -0
  253. package/dist/flags/1x1/tz.svg +15 -0
  254. package/dist/flags/1x1/ua.svg +6 -0
  255. package/dist/flags/1x1/ug.svg +30 -0
  256. package/dist/flags/1x1/um.svg +9 -0
  257. package/dist/flags/1x1/un.svg +16 -0
  258. package/dist/flags/1x1/us.svg +9 -0
  259. package/dist/flags/1x1/uy.svg +28 -0
  260. package/dist/flags/1x1/uz.svg +30 -0
  261. package/dist/flags/1x1/va.svg +190 -0
  262. package/dist/flags/1x1/vc.svg +8 -0
  263. package/dist/flags/1x1/ve.svg +26 -0
  264. package/dist/flags/1x1/vg.svg +59 -0
  265. package/dist/flags/1x1/vi.svg +28 -0
  266. package/dist/flags/1x1/vn.svg +11 -0
  267. package/dist/flags/1x1/vu.svg +21 -0
  268. package/dist/flags/1x1/wf.svg +5 -0
  269. package/dist/flags/1x1/ws.svg +7 -0
  270. package/dist/flags/1x1/xk.svg +5 -0
  271. package/dist/flags/1x1/xx.svg +4 -0
  272. package/dist/flags/1x1/ye.svg +7 -0
  273. package/dist/flags/1x1/yt.svg +5 -0
  274. package/dist/flags/1x1/za.svg +17 -0
  275. package/dist/flags/1x1/zm.svg +27 -0
  276. package/dist/flags/1x1/zw.svg +21 -0
  277. package/dist/flags/4x3/ad.svg +150 -0
  278. package/dist/flags/4x3/ae.svg +6 -0
  279. package/dist/flags/4x3/af.svg +81 -0
  280. package/dist/flags/4x3/ag.svg +14 -0
  281. package/dist/flags/4x3/ai.svg +29 -0
  282. package/dist/flags/4x3/al.svg +5 -0
  283. package/dist/flags/4x3/am.svg +5 -0
  284. package/dist/flags/4x3/ao.svg +13 -0
  285. package/dist/flags/4x3/aq.svg +5 -0
  286. package/dist/flags/4x3/ar.svg +32 -0
  287. package/dist/flags/4x3/arab.svg +109 -0
  288. package/dist/flags/4x3/as.svg +72 -0
  289. package/dist/flags/4x3/asean.svg +13 -0
  290. package/dist/flags/4x3/at.svg +4 -0
  291. package/dist/flags/4x3/au.svg +8 -0
  292. package/dist/flags/4x3/aw.svg +186 -0
  293. package/dist/flags/4x3/ax.svg +18 -0
  294. package/dist/flags/4x3/az.svg +8 -0
  295. package/dist/flags/4x3/ba.svg +12 -0
  296. package/dist/flags/4x3/bb.svg +6 -0
  297. package/dist/flags/4x3/bd.svg +4 -0
  298. package/dist/flags/4x3/be.svg +7 -0
  299. package/dist/flags/4x3/bf.svg +7 -0
  300. package/dist/flags/4x3/bg.svg +5 -0
  301. package/dist/flags/4x3/bh.svg +4 -0
  302. package/dist/flags/4x3/bi.svg +15 -0
  303. package/dist/flags/4x3/bj.svg +14 -0
  304. package/dist/flags/4x3/bl.svg +5 -0
  305. package/dist/flags/4x3/bm.svg +97 -0
  306. package/dist/flags/4x3/bn.svg +36 -0
  307. package/dist/flags/4x3/bo.svg +673 -0
  308. package/dist/flags/4x3/bq.svg +5 -0
  309. package/dist/flags/4x3/br.svg +45 -0
  310. package/dist/flags/4x3/bs.svg +13 -0
  311. package/dist/flags/4x3/bt.svg +89 -0
  312. package/dist/flags/4x3/bv.svg +13 -0
  313. package/dist/flags/4x3/bw.svg +7 -0
  314. package/dist/flags/4x3/by.svg +18 -0
  315. package/dist/flags/4x3/bz.svg +145 -0
  316. package/dist/flags/4x3/ca.svg +4 -0
  317. package/dist/flags/4x3/cc.svg +19 -0
  318. package/dist/flags/4x3/cd.svg +5 -0
  319. package/dist/flags/4x3/cefta.svg +13 -0
  320. package/dist/flags/4x3/cf.svg +15 -0
  321. package/dist/flags/4x3/cg.svg +12 -0
  322. package/dist/flags/4x3/ch.svg +9 -0
  323. package/dist/flags/4x3/ci.svg +7 -0
  324. package/dist/flags/4x3/ck.svg +9 -0
  325. package/dist/flags/4x3/cl.svg +13 -0
  326. package/dist/flags/4x3/cm.svg +15 -0
  327. package/dist/flags/4x3/cn.svg +11 -0
  328. package/dist/flags/4x3/co.svg +7 -0
  329. package/dist/flags/4x3/cp.svg +7 -0
  330. package/dist/flags/4x3/cr.svg +7 -0
  331. package/dist/flags/4x3/cu.svg +13 -0
  332. package/dist/flags/4x3/cv.svg +13 -0
  333. package/dist/flags/4x3/cw.svg +14 -0
  334. package/dist/flags/4x3/cx.svg +15 -0
  335. package/dist/flags/4x3/cy.svg +6 -0
  336. package/dist/flags/4x3/cz.svg +5 -0
  337. package/dist/flags/4x3/de.svg +5 -0
  338. package/dist/flags/4x3/dg.svg +130 -0
  339. package/dist/flags/4x3/dj.svg +13 -0
  340. package/dist/flags/4x3/dk.svg +5 -0
  341. package/dist/flags/4x3/dm.svg +152 -0
  342. package/dist/flags/4x3/do.svg +121 -0
  343. package/dist/flags/4x3/dz.svg +5 -0
  344. package/dist/flags/4x3/eac.svg +48 -0
  345. package/dist/flags/4x3/ec.svg +138 -0
  346. package/dist/flags/4x3/ee.svg +5 -0
  347. package/dist/flags/4x3/eg.svg +38 -0
  348. package/dist/flags/4x3/eh.svg +16 -0
  349. package/dist/flags/4x3/er.svg +8 -0
  350. package/dist/flags/4x3/es-ct.svg +4 -0
  351. package/dist/flags/4x3/es-ga.svg +187 -0
  352. package/dist/flags/4x3/es-pv.svg +5 -0
  353. package/dist/flags/4x3/es.svg +544 -0
  354. package/dist/flags/4x3/et.svg +14 -0
  355. package/dist/flags/4x3/eu.svg +28 -0
  356. package/dist/flags/4x3/fi.svg +5 -0
  357. package/dist/flags/4x3/fj.svg +120 -0
  358. package/dist/flags/4x3/fk.svg +90 -0
  359. package/dist/flags/4x3/fm.svg +11 -0
  360. package/dist/flags/4x3/fo.svg +12 -0
  361. package/dist/flags/4x3/fr.svg +5 -0
  362. package/dist/flags/4x3/ga.svg +7 -0
  363. package/dist/flags/4x3/gb-eng.svg +5 -0
  364. package/dist/flags/4x3/gb-nir.svg +132 -0
  365. package/dist/flags/4x3/gb-sct.svg +4 -0
  366. package/dist/flags/4x3/gb-wls.svg +9 -0
  367. package/dist/flags/4x3/gb.svg +7 -0
  368. package/dist/flags/4x3/gd.svg +27 -0
  369. package/dist/flags/4x3/ge.svg +6 -0
  370. package/dist/flags/4x3/gf.svg +5 -0
  371. package/dist/flags/4x3/gg.svg +9 -0
  372. package/dist/flags/4x3/gh.svg +6 -0
  373. package/dist/flags/4x3/gi.svg +32 -0
  374. package/dist/flags/4x3/gl.svg +4 -0
  375. package/dist/flags/4x3/gm.svg +14 -0
  376. package/dist/flags/4x3/gn.svg +7 -0
  377. package/dist/flags/4x3/gp.svg +5 -0
  378. package/dist/flags/4x3/gq.svg +23 -0
  379. package/dist/flags/4x3/gr.svg +16 -0
  380. package/dist/flags/4x3/gs.svg +133 -0
  381. package/dist/flags/4x3/gt.svg +204 -0
  382. package/dist/flags/4x3/gu.svg +19 -0
  383. package/dist/flags/4x3/gw.svg +13 -0
  384. package/dist/flags/4x3/gy.svg +9 -0
  385. package/dist/flags/4x3/hk.svg +8 -0
  386. package/dist/flags/4x3/hm.svg +8 -0
  387. package/dist/flags/4x3/hn.svg +18 -0
  388. package/dist/flags/4x3/hr.svg +58 -0
  389. package/dist/flags/4x3/ht.svg +116 -0
  390. package/dist/flags/4x3/hu.svg +7 -0
  391. package/dist/flags/4x3/ic.svg +7 -0
  392. package/dist/flags/4x3/id.svg +4 -0
  393. package/dist/flags/4x3/ie.svg +7 -0
  394. package/dist/flags/4x3/il.svg +14 -0
  395. package/dist/flags/4x3/im.svg +36 -0
  396. package/dist/flags/4x3/in.svg +25 -0
  397. package/dist/flags/4x3/io.svg +130 -0
  398. package/dist/flags/4x3/iq.svg +10 -0
  399. package/dist/flags/4x3/ir.svg +219 -0
  400. package/dist/flags/4x3/is.svg +12 -0
  401. package/dist/flags/4x3/it.svg +7 -0
  402. package/dist/flags/4x3/je.svg +62 -0
  403. package/dist/flags/4x3/jm.svg +8 -0
  404. package/dist/flags/4x3/jo.svg +16 -0
  405. package/dist/flags/4x3/jp.svg +11 -0
  406. package/dist/flags/4x3/ke.svg +23 -0
  407. package/dist/flags/4x3/kg.svg +4 -0
  408. package/dist/flags/4x3/kh.svg +61 -0
  409. package/dist/flags/4x3/ki.svg +36 -0
  410. package/dist/flags/4x3/km.svg +16 -0
  411. package/dist/flags/4x3/kn.svg +14 -0
  412. package/dist/flags/4x3/kp.svg +15 -0
  413. package/dist/flags/4x3/kr.svg +24 -0
  414. package/dist/flags/4x3/kw.svg +13 -0
  415. package/dist/flags/4x3/ky.svg +103 -0
  416. package/dist/flags/4x3/kz.svg +36 -0
  417. package/dist/flags/4x3/la.svg +12 -0
  418. package/dist/flags/4x3/lb.svg +15 -0
  419. package/dist/flags/4x3/lc.svg +8 -0
  420. package/dist/flags/4x3/li.svg +43 -0
  421. package/dist/flags/4x3/lk.svg +22 -0
  422. package/dist/flags/4x3/lr.svg +14 -0
  423. package/dist/flags/4x3/ls.svg +8 -0
  424. package/dist/flags/4x3/lt.svg +7 -0
  425. package/dist/flags/4x3/lu.svg +5 -0
  426. package/dist/flags/4x3/lv.svg +7 -0
  427. package/dist/flags/4x3/ly.svg +13 -0
  428. package/dist/flags/4x3/ma.svg +4 -0
  429. package/dist/flags/4x3/mc.svg +6 -0
  430. package/dist/flags/4x3/md.svg +70 -0
  431. package/dist/flags/4x3/me.svg +116 -0
  432. package/dist/flags/4x3/mf.svg +5 -0
  433. package/dist/flags/4x3/mg.svg +7 -0
  434. package/dist/flags/4x3/mh.svg +7 -0
  435. package/dist/flags/4x3/mk.svg +5 -0
  436. package/dist/flags/4x3/ml.svg +7 -0
  437. package/dist/flags/4x3/mm.svg +12 -0
  438. package/dist/flags/4x3/mn.svg +14 -0
  439. package/dist/flags/4x3/mo.svg +9 -0
  440. package/dist/flags/4x3/mp.svg +86 -0
  441. package/dist/flags/4x3/mq.svg +5 -0
  442. package/dist/flags/4x3/mr.svg +6 -0
  443. package/dist/flags/4x3/ms.svg +29 -0
  444. package/dist/flags/4x3/mt.svg +58 -0
  445. package/dist/flags/4x3/mu.svg +8 -0
  446. package/dist/flags/4x3/mv.svg +6 -0
  447. package/dist/flags/4x3/mw.svg +10 -0
  448. package/dist/flags/4x3/mx.svg +382 -0
  449. package/dist/flags/4x3/my.svg +26 -0
  450. package/dist/flags/4x3/mz.svg +21 -0
  451. package/dist/flags/4x3/na.svg +16 -0
  452. package/dist/flags/4x3/nc.svg +13 -0
  453. package/dist/flags/4x3/ne.svg +6 -0
  454. package/dist/flags/4x3/nf.svg +9 -0
  455. package/dist/flags/4x3/ng.svg +6 -0
  456. package/dist/flags/4x3/ni.svg +129 -0
  457. package/dist/flags/4x3/nl.svg +5 -0
  458. package/dist/flags/4x3/no.svg +7 -0
  459. package/dist/flags/4x3/np.svg +13 -0
  460. package/dist/flags/4x3/nr.svg +12 -0
  461. package/dist/flags/4x3/nu.svg +10 -0
  462. package/dist/flags/4x3/null +1 -0
  463. package/dist/flags/4x3/nz.svg +36 -0
  464. package/dist/flags/4x3/om.svg +115 -0
  465. package/dist/flags/4x3/pa.svg +7 -0
  466. package/dist/flags/4x3/pc.svg +33 -0
  467. package/dist/flags/4x3/pe.svg +4 -0
  468. package/dist/flags/4x3/pf.svg +19 -0
  469. package/dist/flags/4x3/pg.svg +9 -0
  470. package/dist/flags/4x3/ph.svg +6 -0
  471. package/dist/flags/4x3/pk.svg +15 -0
  472. package/dist/flags/4x3/pl.svg +6 -0
  473. package/dist/flags/4x3/pm.svg +5 -0
  474. package/dist/flags/4x3/pn.svg +53 -0
  475. package/dist/flags/4x3/pr.svg +13 -0
  476. package/dist/flags/4x3/ps.svg +6 -0
  477. package/dist/flags/4x3/pt.svg +57 -0
  478. package/dist/flags/4x3/pw.svg +11 -0
  479. package/dist/flags/4x3/py.svg +157 -0
  480. package/dist/flags/4x3/qa.svg +4 -0
  481. package/dist/flags/4x3/re.svg +5 -0
  482. package/dist/flags/4x3/ro.svg +7 -0
  483. package/dist/flags/4x3/rs.svg +292 -0
  484. package/dist/flags/4x3/ru.svg +5 -0
  485. package/dist/flags/4x3/rw.svg +13 -0
  486. package/dist/flags/4x3/sa.svg +25 -0
  487. package/dist/flags/4x3/sb.svg +13 -0
  488. package/dist/flags/4x3/sc.svg +7 -0
  489. package/dist/flags/4x3/sd.svg +13 -0
  490. package/dist/flags/4x3/se.svg +4 -0
  491. package/dist/flags/4x3/sg.svg +13 -0
  492. package/dist/flags/4x3/sh-ac.svg +689 -0
  493. package/dist/flags/4x3/sh-hl.svg +164 -0
  494. package/dist/flags/4x3/sh-ta.svg +76 -0
  495. package/dist/flags/4x3/sh.svg +7 -0
  496. package/dist/flags/4x3/si.svg +18 -0
  497. package/dist/flags/4x3/sj.svg +7 -0
  498. package/dist/flags/4x3/sk.svg +9 -0
  499. package/dist/flags/4x3/sl.svg +7 -0
  500. package/dist/flags/4x3/sm.svg +75 -0
  501. package/dist/flags/4x3/sn.svg +8 -0
  502. package/dist/flags/4x3/so.svg +11 -0
  503. package/dist/flags/4x3/sr.svg +6 -0
  504. package/dist/flags/4x3/ss.svg +8 -0
  505. package/dist/flags/4x3/st.svg +16 -0
  506. package/dist/flags/4x3/sv.svg +593 -0
  507. package/dist/flags/4x3/sx.svg +56 -0
  508. package/dist/flags/4x3/sy.svg +6 -0
  509. package/dist/flags/4x3/sz.svg +34 -0
  510. package/dist/flags/4x3/tc.svg +50 -0
  511. package/dist/flags/4x3/td.svg +7 -0
  512. package/dist/flags/4x3/tf.svg +15 -0
  513. package/dist/flags/4x3/tg.svg +14 -0
  514. package/dist/flags/4x3/th.svg +7 -0
  515. package/dist/flags/4x3/tj.svg +22 -0
  516. package/dist/flags/4x3/tk.svg +5 -0
  517. package/dist/flags/4x3/tl.svg +13 -0
  518. package/dist/flags/4x3/tm.svg +204 -0
  519. package/dist/flags/4x3/tn.svg +4 -0
  520. package/dist/flags/4x3/to.svg +10 -0
  521. package/dist/flags/4x3/tr.svg +8 -0
  522. package/dist/flags/4x3/tt.svg +5 -0
  523. package/dist/flags/4x3/tv.svg +9 -0
  524. package/dist/flags/4x3/tw.svg +34 -0
  525. package/dist/flags/4x3/tz.svg +13 -0
  526. package/dist/flags/4x3/ua.svg +6 -0
  527. package/dist/flags/4x3/ug.svg +30 -0
  528. package/dist/flags/4x3/um.svg +9 -0
  529. package/dist/flags/4x3/un.svg +16 -0
  530. package/dist/flags/4x3/us.svg +9 -0
  531. package/dist/flags/4x3/uy.svg +28 -0
  532. package/dist/flags/4x3/uz.svg +30 -0
  533. package/dist/flags/4x3/va.svg +190 -0
  534. package/dist/flags/4x3/vc.svg +8 -0
  535. package/dist/flags/4x3/ve.svg +26 -0
  536. package/dist/flags/4x3/vg.svg +59 -0
  537. package/dist/flags/4x3/vi.svg +28 -0
  538. package/dist/flags/4x3/vn.svg +11 -0
  539. package/dist/flags/4x3/vu.svg +21 -0
  540. package/dist/flags/4x3/wf.svg +5 -0
  541. package/dist/flags/4x3/ws.svg +7 -0
  542. package/dist/flags/4x3/xk.svg +5 -0
  543. package/dist/flags/4x3/xx.svg +4 -0
  544. package/dist/flags/4x3/ye.svg +7 -0
  545. package/dist/flags/4x3/yt.svg +5 -0
  546. package/dist/flags/4x3/za.svg +17 -0
  547. package/dist/flags/4x3/zm.svg +27 -0
  548. package/dist/flags/4x3/zw.svg +21 -0
  549. package/package.json +5 -5
package/README.md CHANGED
@@ -28,7 +28,7 @@ CountrySelect Pro provides a clean and fast country dropdown with **search, phon
28
28
 
29
29
  Try the interactive demo:
30
30
 
31
- https://nikmauro.github.io/country-select-pro/
31
+ https://nikmauro.github.io/country-select-pro/docs/
32
32
 
33
33
  ---
34
34
 
@@ -39,7 +39,7 @@ https://nikmauro.github.io/country-select-pro/
39
39
  Include the script via **jsDelivr**:
40
40
 
41
41
  ```html
42
- <script src="https://cdn.jsdelivr.net/gh/nikmauro/country-select-pro@4.8.2/dist/country-select.min.js"></script>
42
+ <script src="https://cdn.jsdelivr.net/npm/country-select-pro@6.1.4/dist/country-select.min.js"></script>
43
43
  ```
44
44
 
45
45
  ---
@@ -49,7 +49,7 @@ Include the script via **jsDelivr**:
49
49
  Download the repository and include:
50
50
 
51
51
  ```html
52
- <script src="dist/country-select.min.js"></script>
52
+ <script src="dist/country-select.js"></script>
53
53
  ```
54
54
 
55
55
  ---
@@ -128,8 +128,8 @@ country-select-pro
128
128
  │
129
129
  ├─ dist
130
130
  │ ├─ country-select.js
131
- │ └─ country-select.min.js
132
- │
131
+ │ └─ data.json
132
+ ├─ flags
133
133
  ├─ demo
134
134
  ├─ src
135
135
  └─ README.md
@@ -173,8 +173,6 @@ Contributions are welcome.
173
173
  Developed by **Nikolaos Mavroeidis**
174
174
  GitHub: https://github.com/nikmauro
175
175
 
176
- With collaborative assistance from **Gemini (Google AI)**.
177
-
178
176
  ---
179
177
 
180
178
  # 📄 License
@@ -1,28 +1,29 @@
1
1
  /**
2
- * CountrySelect Pro v5.6.6
2
+ * CountrySelect Pro v6.1.4
3
3
  * ---------------------------------------------------------------------------
4
4
  * Features:
5
5
  * - SVG Arrow Down icon
6
6
  * - HTMX Auto-initialization
7
7
  * - Improved Validation UI
8
8
  * - Zero Dependencies
9
+ * - 4x3, 1x1 Flags
9
10
  * ---------------------------------------------------------------------------
10
11
  */
11
12
 
13
+
12
14
  class CountrySelect {
13
15
 
16
+
14
17
  constructor(element, options = {}) {
15
18
  this.input = element;
16
19
  if (!this.input) return;
17
20
 
18
- // προσθέτεις class
19
- if (!this.input.classList.contains('checkout-trigger')) {
20
- this.input.classList.add('checkout-trigger');
21
- }
22
-
23
- // μετά ελέγχεις αν έχει ήδη init
21
+ // 1. ΕΛΕΓΧΟΣ HTMX: Αν έχει ήδη γίνει init, σταμάτα αμέσως
24
22
  if (this.input.dataset.csInitialized === '1') return;
25
23
 
24
+ // 2. ΚΛΕΙΔΩΜΑ HTMX: Σημειώνουμε ότι έγινε init ΠΡΙΝ τρέξει το async _init()
25
+ this.input.dataset.csInitialized = '1';
26
+
26
27
  // Configuration
27
28
  this.schema = this.input.dataset.schema || "{img} {name}";
28
29
  this.schemaReturn = this.input.dataset.schemaReturn || this.schema;
@@ -46,6 +47,9 @@ class CountrySelect {
46
47
  this.activeIndex = -1;
47
48
  this.rowHeight = 44;
48
49
 
50
+ // Base URL για το JSON και τα SVG flags
51
+ this.baseUrl = 'https://cdn.jsdelivr.net/gh/nikmauro/country-select-pro@6.1.3/';
52
+
49
53
  this._init();
50
54
  }
51
55
 
@@ -58,6 +62,24 @@ class CountrySelect {
58
62
 
59
63
  _applyStyles() {
60
64
  const styles = `
65
+ .cs-no-results {
66
+ padding: 10px;
67
+ text-align: center;
68
+ color: #999;
69
+ cursor: default;
70
+ font-style: italic;
71
+ }
72
+
73
+ .cs-flag-img {
74
+ width: 22px !important;
75
+ height: 16px !important;
76
+ object-fit: cover; /* Ή contain, ανάλογα πώς φαίνεται καλύτερα */
77
+ vertical-align: middle;
78
+ margin-right: 8px;
79
+ border-radius: 2px;
80
+ display: inline-block;
81
+ }
82
+
61
83
  .cs-wrapper { position: relative; font-family: inherit; width: 100%; outline: none; }
62
84
  .cs-trigger {
63
85
  /* Bootstrap 5 Exact Specs */
@@ -90,6 +112,11 @@ class CountrySelect {
90
112
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
91
113
  }
92
114
 
115
+ .flag-emoji {
116
+ font-size: 1.2em; /* Για να φαίνεται πιο καθαρό το emoji */
117
+ margin-right: 8px;
118
+ }
119
+
93
120
  .cs-dropdown {
94
121
  position: absolute; left: 0; right: 0; background: #fff;
95
122
  border: 1px solid rgba(0,0,0,.15); border-radius: 0.375rem;
@@ -158,6 +185,19 @@ class CountrySelect {
158
185
  this.input.parentNode.insertBefore(this.wrapper, this.input.nextSibling);
159
186
  }
160
187
 
188
+ _updateActiveElement() {
189
+ const options = this.wrapper.querySelectorAll('.cs-option');
190
+ options.forEach((el, index) => {
191
+ if (index === this.activeIndex) {
192
+ el.classList.add('active');
193
+ // Bonus UX: Κάνει scroll αν το element είναι εκτός οθόνης
194
+ el.scrollIntoView({block: 'nearest'});
195
+ } else {
196
+ el.classList.remove('active');
197
+ }
198
+ });
199
+ }
200
+
161
201
  _updatePosition() {
162
202
  const rect = this.wrapper.getBoundingClientRect();
163
203
  const dropdownHeight = (this.rowLimit * this.rowHeight) + (this.hasSearch ? 60 : 0);
@@ -173,25 +213,34 @@ class CountrySelect {
173
213
 
174
214
  async _loadData() {
175
215
  try {
176
- const res = await fetch('https://restcountries.com/v3.1/all?fields=name,flags,cca2,idd');
177
- const data = await res.json();
178
-
179
- this.countries = data.map(c => ({
180
- name: c.name.common,
181
- code: c.cca2.toUpperCase(),
182
- flag: c.flags.svg,
183
- phone: c.idd.root + (c.idd.suffixes ? (c.idd.suffixes.length > 1 ? "" : c.idd.suffixes[0]) : ""),
184
- isPreferred: this.preferredCodes.includes(c.cca2.toUpperCase())
185
- })).sort((a, b) => a.name.localeCompare(b.name));
216
+ const jsonUrl = `${this.baseUrl}dist/data.json`; // Χρήση του baseUrl
217
+
218
+ const res = await fetch(jsonUrl);
219
+ const json = await res.json();
220
+ const data = json?.data?.objects || [];
221
+
222
+ this.countries = data.map(c => {
223
+ const code = c.codes?.alpha_2 ? c.codes.alpha_2.toUpperCase() : "";
224
+ return {
225
+ name: c.names?.common || "",
226
+ code: code,
227
+ // Δημιουργία path για το SVG με βάση το code
228
+ flag: code ? `${this.baseUrl}dist/flags/4x3/${code.toLowerCase()}.svg` : "",
229
+ phone: (c.calling_codes && c.calling_codes.length > 0) ? `+${c.calling_codes[0]}` : "",
230
+ isPreferred: code ? this.preferredCodes.includes(code) : false
231
+ };
232
+ }).filter(c => c.code !== "")
233
+ .sort((a, b) => a.name.localeCompare(b.name));
186
234
 
187
235
  this.filteredCountries = [...this.countries];
188
236
  this._renderOptions();
189
237
  this._syncInitialValue();
190
238
  } catch (e) {
191
- console.error("CountrySelect API Fail", e);
239
+ console.error("CountrySelect Load Fail:", e);
192
240
  }
193
241
  }
194
242
 
243
+
195
244
  _syncInitialValue() {
196
245
  const val = this.input.value;
197
246
  if (!val) {
@@ -202,16 +251,30 @@ class CountrySelect {
202
251
  if (current) this._updateUI(current);
203
252
  }
204
253
 
254
+
205
255
  _parseTemplate(template, country) {
206
- return template.replace('{img}', `<img src="${country.flag}">`).replace('{name}', `<span>${country.name}</span>`).replace('{code}', `<span>${country.code}</span>`).replace('{phone}', `<span>${country.phone}</span>`);
256
+ return template
257
+ .replace('{img}', `<img src="${country.flag}" class="cs-flag-img" loading="lazy" alt="${country.name}">`)
258
+ .replace('{name}', `<span>${country.name}</span>`)
259
+ .replace('{code}', `<span>${country.code}</span>`)
260
+ .replace('{phone}', `<span>${country.phone}</span>`);
207
261
  }
208
262
 
209
263
  _renderOptions() {
210
264
  const listContainer = this.wrapper.querySelector('.cs-list');
211
265
  if (!listContainer) return;
212
266
  listContainer.innerHTML = '';
213
- const searchVal = this.wrapper.querySelector('.cs-search-input')?.value || "";
214
267
 
268
+ // Έλεγχος αν η λίστα είναι άδεια
269
+ if (this.filteredCountries.length === 0) {
270
+ const noResults = document.createElement('div');
271
+ noResults.className = 'cs-no-results';
272
+ noResults.innerHTML = '<span class="cs-no-results-text">Not found</span>';
273
+ listContainer.appendChild(noResults);
274
+ return; // Σταματάμε εδώ
275
+ }
276
+
277
+ const searchVal = this.wrapper.querySelector('.cs-search-input')?.value || "";
215
278
  const preferred = this.filteredCountries.filter(c => c.isPreferred);
216
279
  const others = this.filteredCountries.filter(c => !c.isPreferred);
217
280
 
@@ -266,12 +329,17 @@ class CountrySelect {
266
329
  _toggle(force) {
267
330
  if (this.countries.length === 0) return;
268
331
  this.isOpen = force !== undefined ? force : !this.isOpen;
332
+
269
333
  if (this.isOpen) {
270
334
  this._updatePosition();
271
335
  document.dispatchEvent(new CustomEvent('cs-close-others', {detail: {opener: this.wrapper}}));
272
336
 
273
- this._renderOptions();
337
+ // ΑΛΛΑΓΗ: Έλεγχος αν η λίστα έχει ήδη στοιχεία
274
338
  const list = this.wrapper.querySelector('.cs-list');
339
+ if (list.children.length === 0) {
340
+ this._renderOptions();
341
+ }
342
+
275
343
  list.style.maxHeight = `${this.rowLimit * this.rowHeight}px`;
276
344
 
277
345
  const pref = this.filteredCountries.filter(c => c.isPreferred);
@@ -279,7 +347,10 @@ class CountrySelect {
279
347
  const fullList = [...pref, ...oth];
280
348
  this.activeIndex = fullList.findIndex(c => this.input.value.includes(c.code) || this.input.value.includes(c.phone));
281
349
 
282
- if (this.activeIndex > -1) setTimeout(() => this._scrollToActive(), 0);
350
+ // ΑΛΛΑΓΗ: Ενημέρωσε το active element αντί να κάνεις re-render όλη τη λίστα
351
+ this._updateActiveElement();
352
+
353
+ if (this.activeIndex > -1) setTimeout(() => this._scrollToActive(true), 0); // 6.1.4: από την αρχή, αν η επιλεγμένη φαίνεται εκεί
283
354
  if (this.hasSearch) setTimeout(() => this.wrapper.querySelector('.cs-search-input').focus(), 50);
284
355
  }
285
356
  this.wrapper.classList.toggle('open', this.isOpen);
@@ -290,26 +361,43 @@ class CountrySelect {
290
361
  e.stopPropagation();
291
362
  this._toggle();
292
363
  };
364
+
293
365
  this.wrapper.addEventListener('keydown', (e) => {
294
366
  if (!this.isOpen && (e.key === 'ArrowDown')) {
295
367
  e.preventDefault();
296
368
  this._toggle(true);
297
369
  return;
298
370
  }
371
+
299
372
  if (this.isOpen) {
300
373
  if (e.key === 'ArrowDown') {
301
374
  e.preventDefault();
302
- this.activeIndex++;
303
- this._renderOptions();
304
- this._scrollToActive();
375
+ // ΕΛΕΓΧΟΣ: Μπορούμε να πάμε παρακάτω;
376
+ if (this.activeIndex < this.filteredCountries.length - 1) {
377
+ this.activeIndex++;
378
+ this._updateActiveElement();
379
+ this._scrollToActive();
380
+ }
305
381
  } else if (e.key === 'ArrowUp') {
306
382
  e.preventDefault();
307
- this.activeIndex--;
308
- this._renderOptions();
309
- this._scrollToActive();
310
- } else if (e.key === 'Escape') this._toggle(false);
383
+ // ΕΛΕΓΧΟΣ: Μπορούμε να πάμε παραπάνω;
384
+ if (this.activeIndex > 0) {
385
+ this.activeIndex--;
386
+ this._updateActiveElement();
387
+ this._scrollToActive();
388
+ }
389
+ } else if (e.key === 'Escape') {
390
+ this._toggle(false);
391
+ } else if (e.key === 'Enter') {
392
+ e.preventDefault();
393
+ // Εδώ πρέπει να είμαστε σίγουροι ότι το activeIndex είναι έγκυρο
394
+ if (this.activeIndex >= 0 && this.activeIndex < this.filteredCountries.length) {
395
+ this._select(this.filteredCountries[this.activeIndex]);
396
+ }
397
+ }
311
398
  }
312
399
  });
400
+
313
401
  if (this.hasSearch) {
314
402
  this.wrapper.querySelector('.cs-search-input').oninput = (e) => {
315
403
  const term = e.target.value.toLowerCase();
@@ -329,14 +417,22 @@ class CountrySelect {
329
417
  });
330
418
  }
331
419
 
332
- _scrollToActive() {
420
+ /**
421
+ * Scroll της λίστας στην επιλεγμένη χώρα.
422
+ * 6.1.4: fromTop (άνοιγμα της λίστας) — αν η επιλεγμένη φαίνεται ήδη από την αρχή της λίστας, η λίστα ξεκινά από την αρχή
423
+ * (πριν: κεντράριζε ΠΑΝΤΑ → με επιλεγμένη την 3η χώρα, π.χ. Greece μετά από Bulgaria · Cyprus, κρυβόταν η 1η / οι προτιμώμενες).
424
+ * Θέση μέσα στη λίστα από τα getBoundingClientRect (το offsetTop μετρά από το .cs-dropdown — μαζί με το πεδίο αναζήτησης).
425
+ */
426
+ _scrollToActive(fromTop = false) {
333
427
  const list = this.wrapper.querySelector('.cs-list');
334
- const options = list.querySelectorAll('.cs-option');
335
- const activeItem = options[this.activeIndex];
336
- if (activeItem) {
337
- const scrollPos = activeItem.offsetTop - (list.offsetHeight / 2) + (this.rowHeight / 2);
338
- list.scrollTop = scrollPos;
428
+ const activeItem = list.querySelectorAll('.cs-option')[this.activeIndex];
429
+ if (!activeItem) return;
430
+ const top = activeItem.getBoundingClientRect().top - list.getBoundingClientRect().top + list.scrollTop;
431
+ if (fromTop && top + activeItem.offsetHeight <= list.clientHeight) {
432
+ list.scrollTop = 0;
433
+ return;
339
434
  }
435
+ list.scrollTop = top - (list.clientHeight / 2) + (activeItem.offsetHeight / 2);
340
436
  }
341
437
  }
342
438
 
@@ -380,4 +476,4 @@ if (document.readyState === 'loading') {
380
476
  document.addEventListener('DOMContentLoaded', setupListeners);
381
477
  } else {
382
478
  setupListeners();
383
- }
479
+ }
@@ -1 +1 @@
1
- class CountrySelect{constructor(e,t={}){if(this.input=e,!this.input)return;if(this.input.classList.contains("checkout-trigger")||this.input.classList.add("checkout-trigger"),"1"===this.input.dataset.csInitialized)return;this.schema=this.input.dataset.schema||"{img} {name}",this.schemaReturn=this.input.dataset.schemaReturn||this.schema,this.valueType=this.input.dataset.valueType||"code",this.rowLimit=parseInt(this.input.dataset.countryRowValues)||5,this.hasSearch="false"!==this.input.dataset.countrySearch,this.dropdownWidth=this.input.dataset.dropdownWidth||"auto";const i=this.input.dataset.preferred||"";this.preferredCodes=i?i.split(",").map(e=>e.trim().toUpperCase()):[],this.config={placeholder:this.input.dataset.placeholder||"Select",...t},this.countries=[],this.filteredCountries=[],this.isOpen=!1,this.activeIndex=-1,this.rowHeight=44,this._init()}async _init(){this._applyStyles(),this._setupDOM(),this._bindEvents(),await this._loadData()}_applyStyles(){const e="cs-v57-styles";if(!document.getElementById(e)){const t=document.createElement("style");t.id=e,t.textContent="\n .cs-wrapper { position: relative; font-family: inherit; width: 100%; outline: none; }\n .cs-trigger { \n /* Bootstrap 5 Exact Specs */\n padding: 0.375rem 2.25rem 0.375rem 0.75rem; \n font-size: 1rem;\n font-weight: 400;\n line-height: 1.5;\n color: #212529;\n background-color: #fff;\n background-clip: padding-box;\n border: 1px solid #ced4da;\n border-radius: 0.375rem;\n transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;\n display: flex; align-items: center; gap: 8px; cursor: pointer; \n min-height: calc(1.5em + 0.75rem + 2px); \n box-sizing: border-box; position: relative;\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E\");\n background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 16px 12px;\n }\n \n .input-group > .cs-wrapper { flex: 1 1 auto; width: 1%; }\n .cs-wrapper.is-invalid .cs-trigger { border-color: #dc3545 !important; }\n .cs-error-msg { display: none; color: #dc3545; font-size: 0.825em; margin-top: 4px; position: absolute; left: 0; top: 100%; width: 100%; z-index: 10; }\n .cs-wrapper.is-invalid .cs-error-msg { display: block; }\n\n /* Focus state Bootstrap 5 */\n .cs-wrapper:focus-within .cs-trigger {\n border-color: #86b7fe;\n outline: 0;\n box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);\n }\n\n .cs-dropdown { \n position: absolute; left: 0; right: 0; background: #fff; \n border: 1px solid rgba(0,0,0,.15); border-radius: 0.375rem;\n z-index: 2050; display: none; margin-top: 0.125rem;\n box-shadow: 0 0.5rem 1rem rgba(0,0,0,.175);\n overflow: hidden; max-width: 95vw;\n }\n \n .cs-wrapper.drop-up .cs-dropdown { \n bottom: calc(100% + 0.25rem); top: auto;\n box-shadow: 0 -0.5rem 1rem rgba(0,0,0,.175);\n }\n .cs-wrapper.open .cs-dropdown { display: block; }\n \n .cs-search-box { padding: 8px; border-bottom: 1px solid #dee2e6; background: #f8f9fa; }\n .cs-search-input { \n width: 100%; padding: 0.375rem 0.75rem; border: 1px solid #ced4da; \n border-radius: 0.25rem; outline: none; font-size: 0.875rem;\n }\n .cs-list { overflow-y: auto; scrollbar-width: thin; scroll-behavior: auto; min-height: 50px; padding: 0.375rem 0; }\n .cs-option { \n padding: 0.5rem 0.75rem; display: flex; align-items: center; gap: 10px; \n cursor: pointer; font-size: 0.9rem; transition: background 0.1s;\n }\n .cs-option:hover { background-color: #f8f9fa; }\n .cs-option.active { background-color: #0d6efd; color: #fff; }\n \n .cs-wrapper img { width: 20px !important; height: 14px !important; object-fit: cover; border-radius: 2px; flex-shrink: 0; }\n .cs-selected-content { display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; line-height: 1; }\n .cs-divider { height: 1px; background: #dee2e6; margin: 0.375rem 0; pointer-events: none; }\n .cs-hidden { display: none !important; }\n ",document.head.appendChild(t)}}_setupDOM(){Object.assign(this.input.style,{position:"absolute",opacity:"0",width:"1px",height:"1px",pointerEvents:"none"}),this.wrapper=document.createElement("div"),this.wrapper.className="cs-wrapper",this.wrapper.tabIndex=0;const e=this.input.value?"":this.config.placeholder;this.wrapper.innerHTML=`\n <div class="cs-trigger"><span class="cs-selected-content">${e}</span></div>\n <div class="cs-error-msg"></div>\n <div class="cs-dropdown">\n <div class="cs-search-box ${this.hasSearch?"":"cs-hidden"}">\n <input type="text" class="cs-search-input" placeholder="Search..." autocomplete="off" tabindex="-1">\n </div>\n <div class="cs-list"><div class="cs-loading" style="padding:15px; text-align:center;">Loading...</div></div>\n </div>\n `;this.wrapper.querySelector(".cs-dropdown").style.width="auto"===this.dropdownWidth?"100%":this.dropdownWidth,this.input.parentNode.insertBefore(this.wrapper,this.input.nextSibling)}_updatePosition(){const e=this.wrapper.getBoundingClientRect(),t=this.rowLimit*this.rowHeight+(this.hasSearch?60:0),i=window.innerHeight-e.bottom,s=e.top;i<t&&s>t?this.wrapper.classList.add("drop-up"):this.wrapper.classList.remove("drop-up")}async _loadData(){try{const e=await fetch("https://restcountries.com/v3.1/all?fields=name,flags,cca2,idd"),t=await e.json();this.countries=t.map(e=>({name:e.name.common,code:e.cca2.toUpperCase(),flag:e.flags.svg,phone:e.idd.root+(e.idd.suffixes?e.idd.suffixes.length>1?"":e.idd.suffixes[0]:""),isPreferred:this.preferredCodes.includes(e.cca2.toUpperCase())})).sort((e,t)=>e.name.localeCompare(t.name)),this.filteredCountries=[...this.countries],this._renderOptions(),this._syncInitialValue()}catch(e){console.error("CountrySelect API Fail",e)}}_syncInitialValue(){const e=this.input.value;if(!e)return void(this.wrapper.querySelector(".cs-selected-content").innerHTML=this.config.placeholder);const t=this.countries.find(t=>"phone"===this.valueType?t.phone===e:"name"===this.valueType?t.name===e:t.code===e);t&&this._updateUI(t)}_parseTemplate(e,t){return e.replace("{img}",`<img src="${t.flag}">`).replace("{name}",`<span>${t.name}</span>`).replace("{code}",`<span>${t.code}</span>`).replace("{phone}",`<span>${t.phone}</span>`)}_renderOptions(){const e=this.wrapper.querySelector(".cs-list");if(!e)return;e.innerHTML="";const t=this.wrapper.querySelector(".cs-search-input")?.value||"",i=this.filteredCountries.filter(e=>e.isPreferred),s=this.filteredCountries.filter(e=>!e.isPreferred),n=(e,t)=>{const i=document.createElement("div");return i.className="cs-option "+(t===this.activeIndex?"active":""),i.innerHTML=this._parseTemplate(this.schema,e),i.onclick=t=>{t.stopPropagation(),this._select(e)},i};if(i.forEach((t,i)=>e.appendChild(n(t,i))),i.length>0&&s.length>0&&!t){const t=document.createElement("div");t.className="cs-divider",e.appendChild(t)}s.forEach((t,s)=>e.appendChild(n(t,i.length+s)))}_select(e){this._updateUI(e),this.input.value="phone"===this.valueType?e.phone:"name"===this.valueType?e.name:e.code,this.input.setCustomValidity(""),this.wrapper.classList.remove("is-invalid"),this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.input.dispatchEvent(new Event("input",{bubbles:!0})),this.input.dispatchEvent(new Event("country-change",{bubbles:!0})),this._toggle(!1),this.wrapper.focus()}_updateUI(e){const t=this.wrapper.querySelector(".cs-selected-content");t&&(t.innerHTML=this._parseTemplate(this.schemaReturn,e))}_toggle(e){if(0!==this.countries.length){if(this.isOpen=void 0!==e?e:!this.isOpen,this.isOpen){this._updatePosition(),document.dispatchEvent(new CustomEvent("cs-close-others",{detail:{opener:this.wrapper}})),this._renderOptions();this.wrapper.querySelector(".cs-list").style.maxHeight=this.rowLimit*this.rowHeight+"px";const e=[...this.filteredCountries.filter(e=>e.isPreferred),...this.filteredCountries.filter(e=>!e.isPreferred)];this.activeIndex=e.findIndex(e=>this.input.value.includes(e.code)||this.input.value.includes(e.phone)),this.activeIndex>-1&&setTimeout(()=>this._scrollToActive(),0),this.hasSearch&&setTimeout(()=>this.wrapper.querySelector(".cs-search-input").focus(),50)}this.wrapper.classList.toggle("open",this.isOpen)}}_bindEvents(){this.wrapper.querySelector(".cs-trigger").onclick=e=>{e.stopPropagation(),this._toggle()},this.wrapper.addEventListener("keydown",e=>{if(!this.isOpen&&"ArrowDown"===e.key)return e.preventDefault(),void this._toggle(!0);this.isOpen&&("ArrowDown"===e.key?(e.preventDefault(),this.activeIndex++,this._renderOptions(),this._scrollToActive()):"ArrowUp"===e.key?(e.preventDefault(),this.activeIndex--,this._renderOptions(),this._scrollToActive()):"Escape"===e.key&&this._toggle(!1))}),this.hasSearch&&(this.wrapper.querySelector(".cs-search-input").oninput=e=>{const t=e.target.value.toLowerCase();this.filteredCountries=this.countries.filter(e=>e.name.toLowerCase().includes(t)||e.phone.includes(t)),this.activeIndex=0,this._renderOptions()}),document.addEventListener("click",e=>{this.wrapper.contains(e.target)||this._toggle(!1)}),document.addEventListener("cs-close-others",e=>{e.detail.opener!==this.wrapper&&(this.isOpen=!1,this.wrapper.classList.remove("open"))})}_scrollToActive(){const e=this.wrapper.querySelector(".cs-list"),t=e.querySelectorAll(".cs-option")[this.activeIndex];if(t){const i=t.offsetTop-e.offsetHeight/2+this.rowHeight/2;e.scrollTop=i}}}const initCS=e=>{const t=e&&e.querySelectorAll?e:document;t.matches?.(".country-select")&&"1"!==t.dataset.csInitialized&&new CountrySelect(t),t.querySelectorAll?.(".country-select").forEach(e=>{"1"!==e.dataset.csInitialized&&new CountrySelect(e)})},setupListeners=()=>{initCS(document),document.body.addEventListener("htmx:afterSettle",e=>{initCS(e.detail.target||e.target)}),new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{1===e.nodeType&&initCS(e)})})}).observe(document.body,{childList:!0,subtree:!0})};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",setupListeners):setupListeners();
1
+ class CountrySelect{constructor(e,t={}){if(this.input=e,!this.input)return;if("1"===this.input.dataset.csInitialized)return;this.input.dataset.csInitialized="1",this.schema=this.input.dataset.schema||"{img} {name}",this.schemaReturn=this.input.dataset.schemaReturn||this.schema,this.valueType=this.input.dataset.valueType||"code",this.rowLimit=parseInt(this.input.dataset.countryRowValues)||5,this.hasSearch="false"!==this.input.dataset.countrySearch,this.dropdownWidth=this.input.dataset.dropdownWidth||"auto";const i=this.input.dataset.preferred||"";this.preferredCodes=i?i.split(",").map(e=>e.trim().toUpperCase()):[],this.config={placeholder:this.input.dataset.placeholder||"Select",...t},this.countries=[],this.filteredCountries=[],this.isOpen=!1,this.activeIndex=-1,this.rowHeight=44,this.baseUrl="https://cdn.jsdelivr.net/gh/nikmauro/country-select-pro@6.1.3/",this._init()}async _init(){this._applyStyles(),this._setupDOM(),this._bindEvents(),await this._loadData()}_applyStyles(){const e="cs-v57-styles";if(!document.getElementById(e)){const t=document.createElement("style");t.id=e,t.textContent="\n.cs-no-results {\n padding: 10px;\n text-align: center;\n color: #999;\n cursor: default;\n font-style: italic;\n}\n\n.cs-flag-img {\n width: 22px !important; \n height: 16px !important; \n object-fit: cover; /* Ή contain, ανάλογα πώς φαίνεται καλύτερα */\n vertical-align: middle;\n margin-right: 8px;\n border-radius: 2px;\n display: inline-block;\n}\n \n .cs-wrapper { position: relative; font-family: inherit; width: 100%; outline: none; }\n .cs-trigger { \n /* Bootstrap 5 Exact Specs */\n padding: 0.375rem 2.25rem 0.375rem 0.75rem; \n font-size: 1rem;\n font-weight: 400;\n line-height: 1.5;\n color: #212529;\n background-color: #fff;\n background-clip: padding-box;\n border: 1px solid #ced4da;\n border-radius: 0.375rem;\n transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;\n display: flex; align-items: center; gap: 8px; cursor: pointer; \n min-height: calc(1.5em + 0.75rem + 2px); \n box-sizing: border-box; position: relative;\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E\");\n background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 16px 12px;\n }\n \n .input-group > .cs-wrapper { flex: 1 1 auto; width: 1%; }\n .cs-wrapper.is-invalid .cs-trigger { border-color: #dc3545 !important; }\n .cs-error-msg { display: none; color: #dc3545; font-size: 0.825em; margin-top: 4px; position: absolute; left: 0; top: 100%; width: 100%; z-index: 10; }\n .cs-wrapper.is-invalid .cs-error-msg { display: block; }\n\n /* Focus state Bootstrap 5 */\n .cs-wrapper:focus-within .cs-trigger {\n border-color: #86b7fe;\n outline: 0;\n box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);\n }\n\n .flag-emoji {\n font-size: 1.2em; /* Για να φαίνεται πιο καθαρό το emoji */\n margin-right: 8px;\n }\n\n .cs-dropdown { \n position: absolute; left: 0; right: 0; background: #fff; \n border: 1px solid rgba(0,0,0,.15); border-radius: 0.375rem;\n z-index: 2050; display: none; margin-top: 0.125rem;\n box-shadow: 0 0.5rem 1rem rgba(0,0,0,.175);\n overflow: hidden; max-width: 95vw;\n }\n \n .cs-wrapper.drop-up .cs-dropdown { \n bottom: calc(100% + 0.25rem); top: auto;\n box-shadow: 0 -0.5rem 1rem rgba(0,0,0,.175);\n }\n .cs-wrapper.open .cs-dropdown { display: block; }\n \n .cs-search-box { padding: 8px; border-bottom: 1px solid #dee2e6; background: #f8f9fa; }\n .cs-search-input { \n width: 100%; padding: 0.375rem 0.75rem; border: 1px solid #ced4da; \n border-radius: 0.25rem; outline: none; font-size: 0.875rem;\n }\n .cs-list { overflow-y: auto; scrollbar-width: thin; scroll-behavior: auto; min-height: 50px; padding: 0.375rem 0; }\n .cs-option { \n padding: 0.5rem 0.75rem; display: flex; align-items: center; gap: 10px; \n cursor: pointer; font-size: 0.9rem; transition: background 0.1s;\n }\n .cs-option:hover { background-color: #f8f9fa; }\n .cs-option.active { background-color: #0d6efd; color: #fff; }\n \n .cs-wrapper img { width: 20px !important; height: 14px !important; object-fit: cover; border-radius: 2px; flex-shrink: 0; }\n .cs-selected-content { display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; line-height: 1; }\n .cs-divider { height: 1px; background: #dee2e6; margin: 0.375rem 0; pointer-events: none; }\n .cs-hidden { display: none !important; }\n ",document.head.appendChild(t)}}_setupDOM(){Object.assign(this.input.style,{position:"absolute",opacity:"0",width:"1px",height:"1px",pointerEvents:"none"}),this.wrapper=document.createElement("div"),this.wrapper.className="cs-wrapper",this.wrapper.tabIndex=0;const e=this.input.value?"":this.config.placeholder;this.wrapper.innerHTML=`\n <div class="cs-trigger"><span class="cs-selected-content">${e}</span></div>\n <div class="cs-error-msg"></div>\n <div class="cs-dropdown">\n <div class="cs-search-box ${this.hasSearch?"":"cs-hidden"}">\n <input type="text" class="cs-search-input" placeholder="Search..." autocomplete="off" tabindex="-1">\n </div>\n <div class="cs-list"><div class="cs-loading" style="padding:15px; text-align:center;">Loading...</div></div>\n </div>\n `;this.wrapper.querySelector(".cs-dropdown").style.width="auto"===this.dropdownWidth?"100%":this.dropdownWidth,this.input.parentNode.insertBefore(this.wrapper,this.input.nextSibling)}_updateActiveElement(){this.wrapper.querySelectorAll(".cs-option").forEach((e,t)=>{t===this.activeIndex?(e.classList.add("active"),e.scrollIntoView({block:"nearest"})):e.classList.remove("active")})}_updatePosition(){const e=this.wrapper.getBoundingClientRect(),t=this.rowLimit*this.rowHeight+(this.hasSearch?60:0),i=window.innerHeight-e.bottom,n=e.top;i<t&&n>t?this.wrapper.classList.add("drop-up"):this.wrapper.classList.remove("drop-up")}async _loadData(){try{const e=`${this.baseUrl}dist/data.json`,t=await fetch(e),i=await t.json(),n=i?.data?.objects||[];this.countries=n.map(e=>{const t=e.codes?.alpha_2?e.codes.alpha_2.toUpperCase():"";return{name:e.names?.common||"",code:t,flag:t?`${this.baseUrl}dist/flags/4x3/${t.toLowerCase()}.svg`:"",phone:e.calling_codes&&e.calling_codes.length>0?`+${e.calling_codes[0]}`:"",isPreferred:!!t&&this.preferredCodes.includes(t)}}).filter(e=>""!==e.code).sort((e,t)=>e.name.localeCompare(t.name)),this.filteredCountries=[...this.countries],this._renderOptions(),this._syncInitialValue()}catch(e){console.error("CountrySelect Load Fail:",e)}}_syncInitialValue(){const e=this.input.value;if(!e)return void(this.wrapper.querySelector(".cs-selected-content").innerHTML=this.config.placeholder);const t=this.countries.find(t=>"phone"===this.valueType?t.phone===e:"name"===this.valueType?t.name===e:t.code===e);t&&this._updateUI(t)}_parseTemplate(e,t){return e.replace("{img}",`<img src="${t.flag}" class="cs-flag-img" loading="lazy" alt="${t.name}">`).replace("{name}",`<span>${t.name}</span>`).replace("{code}",`<span>${t.code}</span>`).replace("{phone}",`<span>${t.phone}</span>`)}_renderOptions(){const e=this.wrapper.querySelector(".cs-list");if(!e)return;if(e.innerHTML="",0===this.filteredCountries.length){const t=document.createElement("div");return t.className="cs-no-results",t.innerHTML='<span class="cs-no-results-text">Not found</span>',void e.appendChild(t)}const t=this.wrapper.querySelector(".cs-search-input")?.value||"",i=this.filteredCountries.filter(e=>e.isPreferred),n=this.filteredCountries.filter(e=>!e.isPreferred),s=(e,t)=>{const i=document.createElement("div");return i.className="cs-option "+(t===this.activeIndex?"active":""),i.innerHTML=this._parseTemplate(this.schema,e),i.onclick=t=>{t.stopPropagation(),this._select(e)},i};if(i.forEach((t,i)=>e.appendChild(s(t,i))),i.length>0&&n.length>0&&!t){const t=document.createElement("div");t.className="cs-divider",e.appendChild(t)}n.forEach((t,n)=>e.appendChild(s(t,i.length+n)))}_select(e){this._updateUI(e),this.input.value="phone"===this.valueType?e.phone:"name"===this.valueType?e.name:e.code,this.input.setCustomValidity(""),this.wrapper.classList.remove("is-invalid"),this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.input.dispatchEvent(new Event("input",{bubbles:!0})),this.input.dispatchEvent(new Event("country-change",{bubbles:!0})),this._toggle(!1),this.wrapper.focus()}_updateUI(e){const t=this.wrapper.querySelector(".cs-selected-content");t&&(t.innerHTML=this._parseTemplate(this.schemaReturn,e))}_toggle(e){if(0!==this.countries.length){if(this.isOpen=void 0!==e?e:!this.isOpen,this.isOpen){this._updatePosition(),document.dispatchEvent(new CustomEvent("cs-close-others",{detail:{opener:this.wrapper}}));const e=this.wrapper.querySelector(".cs-list");0===e.children.length&&this._renderOptions(),e.style.maxHeight=this.rowLimit*this.rowHeight+"px";const t=[...this.filteredCountries.filter(e=>e.isPreferred),...this.filteredCountries.filter(e=>!e.isPreferred)];this.activeIndex=t.findIndex(e=>this.input.value.includes(e.code)||this.input.value.includes(e.phone)),this._updateActiveElement(),this.activeIndex>-1&&setTimeout(()=>this._scrollToActive(!0),0),this.hasSearch&&setTimeout(()=>this.wrapper.querySelector(".cs-search-input").focus(),50)}this.wrapper.classList.toggle("open",this.isOpen)}}_bindEvents(){this.wrapper.querySelector(".cs-trigger").onclick=e=>{e.stopPropagation(),this._toggle()},this.wrapper.addEventListener("keydown",e=>{if(!this.isOpen&&"ArrowDown"===e.key)return e.preventDefault(),void this._toggle(!0);this.isOpen&&("ArrowDown"===e.key?(e.preventDefault(),this.activeIndex<this.filteredCountries.length-1&&(this.activeIndex++,this._updateActiveElement(),this._scrollToActive())):"ArrowUp"===e.key?(e.preventDefault(),this.activeIndex>0&&(this.activeIndex--,this._updateActiveElement(),this._scrollToActive())):"Escape"===e.key?this._toggle(!1):"Enter"===e.key&&(e.preventDefault(),this.activeIndex>=0&&this.activeIndex<this.filteredCountries.length&&this._select(this.filteredCountries[this.activeIndex])))}),this.hasSearch&&(this.wrapper.querySelector(".cs-search-input").oninput=e=>{const t=e.target.value.toLowerCase();this.filteredCountries=this.countries.filter(e=>e.name.toLowerCase().includes(t)||e.phone.includes(t)),this.activeIndex=0,this._renderOptions()}),document.addEventListener("click",e=>{this.wrapper.contains(e.target)||this._toggle(!1)}),document.addEventListener("cs-close-others",e=>{e.detail.opener!==this.wrapper&&(this.isOpen=!1,this.wrapper.classList.remove("open"))})}_scrollToActive(e=!1){const t=this.wrapper.querySelector(".cs-list"),i=t.querySelectorAll(".cs-option")[this.activeIndex];if(!i)return;const n=i.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop;e&&n+i.offsetHeight<=t.clientHeight?t.scrollTop=0:t.scrollTop=n-t.clientHeight/2+i.offsetHeight/2}}const initCS=e=>{const t=e&&e.querySelectorAll?e:document;t.matches?.(".country-select")&&"1"!==t.dataset.csInitialized&&new CountrySelect(t),t.querySelectorAll?.(".country-select").forEach(e=>{"1"!==e.dataset.csInitialized&&new CountrySelect(e)})},setupListeners=()=>{initCS(document),document.body.addEventListener("htmx:afterSettle",e=>{initCS(e.detail.target||e.target)}),new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{1===e.nodeType&&initCS(e)})})}).observe(document.body,{childList:!0,subtree:!0})};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",setupListeners):setupListeners();