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.
- package/README.md +5 -7
- package/dist/country-select.js +132 -36
- package/dist/country-select.min.js +1 -1
- package/dist/data.json +4333 -0
- package/dist/flags/1x1/ad.svg +148 -0
- package/dist/flags/1x1/ae.svg +6 -0
- package/dist/flags/1x1/af.svg +81 -0
- package/dist/flags/1x1/ag.svg +14 -0
- package/dist/flags/1x1/ai.svg +29 -0
- package/dist/flags/1x1/al.svg +5 -0
- package/dist/flags/1x1/am.svg +5 -0
- package/dist/flags/1x1/ao.svg +13 -0
- package/dist/flags/1x1/aq.svg +5 -0
- package/dist/flags/1x1/ar.svg +32 -0
- package/dist/flags/1x1/arab.svg +109 -0
- package/dist/flags/1x1/as.svg +73 -0
- package/dist/flags/1x1/asean.svg +13 -0
- package/dist/flags/1x1/at.svg +4 -0
- package/dist/flags/1x1/au.svg +8 -0
- package/dist/flags/1x1/aw.svg +186 -0
- package/dist/flags/1x1/ax.svg +18 -0
- package/dist/flags/1x1/az.svg +8 -0
- package/dist/flags/1x1/ba.svg +12 -0
- package/dist/flags/1x1/bb.svg +6 -0
- package/dist/flags/1x1/bd.svg +4 -0
- package/dist/flags/1x1/be.svg +7 -0
- package/dist/flags/1x1/bf.svg +7 -0
- package/dist/flags/1x1/bg.svg +5 -0
- package/dist/flags/1x1/bh.svg +4 -0
- package/dist/flags/1x1/bi.svg +15 -0
- package/dist/flags/1x1/bj.svg +14 -0
- package/dist/flags/1x1/bl.svg +7 -0
- package/dist/flags/1x1/bm.svg +97 -0
- package/dist/flags/1x1/bn.svg +36 -0
- package/dist/flags/1x1/bo.svg +674 -0
- package/dist/flags/1x1/bq.svg +5 -0
- package/dist/flags/1x1/br.svg +45 -0
- package/dist/flags/1x1/bs.svg +13 -0
- package/dist/flags/1x1/bt.svg +89 -0
- package/dist/flags/1x1/bv.svg +13 -0
- package/dist/flags/1x1/bw.svg +7 -0
- package/dist/flags/1x1/by.svg +18 -0
- package/dist/flags/1x1/bz.svg +145 -0
- package/dist/flags/1x1/ca.svg +4 -0
- package/dist/flags/1x1/cc.svg +19 -0
- package/dist/flags/1x1/cd.svg +12 -0
- package/dist/flags/1x1/cefta.svg +13 -0
- package/dist/flags/1x1/cf.svg +15 -0
- package/dist/flags/1x1/cg.svg +12 -0
- package/dist/flags/1x1/ch.svg +9 -0
- package/dist/flags/1x1/ci.svg +7 -0
- package/dist/flags/1x1/ck.svg +9 -0
- package/dist/flags/1x1/cl.svg +13 -0
- package/dist/flags/1x1/cm.svg +15 -0
- package/dist/flags/1x1/cn.svg +11 -0
- package/dist/flags/1x1/co.svg +7 -0
- package/dist/flags/1x1/cp.svg +7 -0
- package/dist/flags/1x1/cr.svg +7 -0
- package/dist/flags/1x1/cu.svg +13 -0
- package/dist/flags/1x1/cv.svg +13 -0
- package/dist/flags/1x1/cw.svg +14 -0
- package/dist/flags/1x1/cx.svg +15 -0
- package/dist/flags/1x1/cy.svg +6 -0
- package/dist/flags/1x1/cz.svg +5 -0
- package/dist/flags/1x1/de.svg +5 -0
- package/dist/flags/1x1/dg.svg +130 -0
- package/dist/flags/1x1/dj.svg +13 -0
- package/dist/flags/1x1/dk.svg +5 -0
- package/dist/flags/1x1/dm.svg +152 -0
- package/dist/flags/1x1/do.svg +122 -0
- package/dist/flags/1x1/dz.svg +5 -0
- package/dist/flags/1x1/eac.svg +48 -0
- package/dist/flags/1x1/ec.svg +138 -0
- package/dist/flags/1x1/ee.svg +5 -0
- package/dist/flags/1x1/eg.svg +38 -0
- package/dist/flags/1x1/eh.svg +11 -0
- package/dist/flags/1x1/er.svg +13 -0
- package/dist/flags/1x1/es-ct.svg +4 -0
- package/dist/flags/1x1/es-ga.svg +187 -0
- package/dist/flags/1x1/es-pv.svg +5 -0
- package/dist/flags/1x1/es.svg +547 -0
- package/dist/flags/1x1/et.svg +14 -0
- package/dist/flags/1x1/eu.svg +28 -0
- package/dist/flags/1x1/fi.svg +5 -0
- package/dist/flags/1x1/fj.svg +123 -0
- package/dist/flags/1x1/fk.svg +89 -0
- package/dist/flags/1x1/fm.svg +11 -0
- package/dist/flags/1x1/fo.svg +12 -0
- package/dist/flags/1x1/fr.svg +5 -0
- package/dist/flags/1x1/ga.svg +7 -0
- package/dist/flags/1x1/gb-eng.svg +5 -0
- package/dist/flags/1x1/gb-nir.svg +131 -0
- package/dist/flags/1x1/gb-sct.svg +4 -0
- package/dist/flags/1x1/gb-wls.svg +9 -0
- package/dist/flags/1x1/gb.svg +7 -0
- package/dist/flags/1x1/gd.svg +27 -0
- package/dist/flags/1x1/ge.svg +6 -0
- package/dist/flags/1x1/gf.svg +5 -0
- package/dist/flags/1x1/gg.svg +9 -0
- package/dist/flags/1x1/gh.svg +6 -0
- package/dist/flags/1x1/gi.svg +32 -0
- package/dist/flags/1x1/gl.svg +4 -0
- package/dist/flags/1x1/gm.svg +9 -0
- package/dist/flags/1x1/gn.svg +7 -0
- package/dist/flags/1x1/gp.svg +5 -0
- package/dist/flags/1x1/gq.svg +23 -0
- package/dist/flags/1x1/gr.svg +16 -0
- package/dist/flags/1x1/gs.svg +132 -0
- package/dist/flags/1x1/gt.svg +204 -0
- package/dist/flags/1x1/gu.svg +19 -0
- package/dist/flags/1x1/gw.svg +15 -0
- package/dist/flags/1x1/gy.svg +9 -0
- package/dist/flags/1x1/hk.svg +8 -0
- package/dist/flags/1x1/hm.svg +8 -0
- package/dist/flags/1x1/hn.svg +18 -0
- package/dist/flags/1x1/hr.svg +56 -0
- package/dist/flags/1x1/ht.svg +116 -0
- package/dist/flags/1x1/hu.svg +7 -0
- package/dist/flags/1x1/ic.svg +7 -0
- package/dist/flags/1x1/id.svg +4 -0
- package/dist/flags/1x1/ie.svg +7 -0
- package/dist/flags/1x1/il.svg +14 -0
- package/dist/flags/1x1/im.svg +36 -0
- package/dist/flags/1x1/in.svg +25 -0
- package/dist/flags/1x1/io.svg +130 -0
- package/dist/flags/1x1/iq.svg +10 -0
- package/dist/flags/1x1/ir.svg +219 -0
- package/dist/flags/1x1/is.svg +12 -0
- package/dist/flags/1x1/it.svg +7 -0
- package/dist/flags/1x1/je.svg +62 -0
- package/dist/flags/1x1/jm.svg +8 -0
- package/dist/flags/1x1/jo.svg +16 -0
- package/dist/flags/1x1/jp.svg +11 -0
- package/dist/flags/1x1/ke.svg +23 -0
- package/dist/flags/1x1/kg.svg +4 -0
- package/dist/flags/1x1/kh.svg +61 -0
- package/dist/flags/1x1/ki.svg +36 -0
- package/dist/flags/1x1/km.svg +16 -0
- package/dist/flags/1x1/kn.svg +14 -0
- package/dist/flags/1x1/kp.svg +15 -0
- package/dist/flags/1x1/kr.svg +17 -0
- package/dist/flags/1x1/kw.svg +13 -0
- package/dist/flags/1x1/ky.svg +103 -0
- package/dist/flags/1x1/kz.svg +36 -0
- package/dist/flags/1x1/la.svg +12 -0
- package/dist/flags/1x1/lb.svg +15 -0
- package/dist/flags/1x1/lc.svg +8 -0
- package/dist/flags/1x1/li.svg +43 -0
- package/dist/flags/1x1/lk.svg +22 -0
- package/dist/flags/1x1/lr.svg +14 -0
- package/dist/flags/1x1/ls.svg +8 -0
- package/dist/flags/1x1/lt.svg +7 -0
- package/dist/flags/1x1/lu.svg +5 -0
- package/dist/flags/1x1/lv.svg +6 -0
- package/dist/flags/1x1/ly.svg +13 -0
- package/dist/flags/1x1/ma.svg +4 -0
- package/dist/flags/1x1/mc.svg +6 -0
- package/dist/flags/1x1/md.svg +71 -0
- package/dist/flags/1x1/me.svg +118 -0
- package/dist/flags/1x1/mf.svg +5 -0
- package/dist/flags/1x1/mg.svg +7 -0
- package/dist/flags/1x1/mh.svg +8 -0
- package/dist/flags/1x1/mk.svg +5 -0
- package/dist/flags/1x1/ml.svg +7 -0
- package/dist/flags/1x1/mm.svg +10 -0
- package/dist/flags/1x1/mn.svg +14 -0
- package/dist/flags/1x1/mo.svg +9 -0
- package/dist/flags/1x1/mp.svg +86 -0
- package/dist/flags/1x1/mq.svg +5 -0
- package/dist/flags/1x1/mr.svg +6 -0
- package/dist/flags/1x1/ms.svg +25 -0
- package/dist/flags/1x1/mt.svg +56 -0
- package/dist/flags/1x1/mu.svg +8 -0
- package/dist/flags/1x1/mv.svg +6 -0
- package/dist/flags/1x1/mw.svg +15 -0
- package/dist/flags/1x1/mx.svg +377 -0
- package/dist/flags/1x1/my.svg +18 -0
- package/dist/flags/1x1/mz.svg +21 -0
- package/dist/flags/1x1/na.svg +16 -0
- package/dist/flags/1x1/nc.svg +12 -0
- package/dist/flags/1x1/ne.svg +6 -0
- package/dist/flags/1x1/nf.svg +11 -0
- package/dist/flags/1x1/ng.svg +6 -0
- package/dist/flags/1x1/ni.svg +129 -0
- package/dist/flags/1x1/nl.svg +5 -0
- package/dist/flags/1x1/no.svg +7 -0
- package/dist/flags/1x1/np.svg +18 -0
- package/dist/flags/1x1/nr.svg +12 -0
- package/dist/flags/1x1/nu.svg +10 -0
- package/dist/flags/1x1/null +1 -0
- package/dist/flags/1x1/nz.svg +36 -0
- package/dist/flags/1x1/om.svg +115 -0
- package/dist/flags/1x1/pa.svg +13 -0
- package/dist/flags/1x1/pc.svg +33 -0
- package/dist/flags/1x1/pe.svg +4 -0
- package/dist/flags/1x1/pf.svg +18 -0
- package/dist/flags/1x1/pg.svg +16 -0
- package/dist/flags/1x1/ph.svg +6 -0
- package/dist/flags/1x1/pk.svg +15 -0
- package/dist/flags/1x1/pl.svg +6 -0
- package/dist/flags/1x1/pm.svg +5 -0
- package/dist/flags/1x1/pn.svg +53 -0
- package/dist/flags/1x1/pr.svg +13 -0
- package/dist/flags/1x1/ps.svg +6 -0
- package/dist/flags/1x1/pt.svg +57 -0
- package/dist/flags/1x1/pw.svg +11 -0
- package/dist/flags/1x1/py.svg +156 -0
- package/dist/flags/1x1/qa.svg +4 -0
- package/dist/flags/1x1/re.svg +7 -0
- package/dist/flags/1x1/ro.svg +7 -0
- package/dist/flags/1x1/rs.svg +296 -0
- package/dist/flags/1x1/ru.svg +5 -0
- package/dist/flags/1x1/rw.svg +13 -0
- package/dist/flags/1x1/sa.svg +25 -0
- package/dist/flags/1x1/sb.svg +13 -0
- package/dist/flags/1x1/sc.svg +7 -0
- package/dist/flags/1x1/sd.svg +13 -0
- package/dist/flags/1x1/se.svg +4 -0
- package/dist/flags/1x1/sg.svg +13 -0
- package/dist/flags/1x1/sh-ac.svg +690 -0
- package/dist/flags/1x1/sh-hl.svg +164 -0
- package/dist/flags/1x1/sh-ta.svg +76 -0
- package/dist/flags/1x1/sh.svg +7 -0
- package/dist/flags/1x1/si.svg +18 -0
- package/dist/flags/1x1/sj.svg +7 -0
- package/dist/flags/1x1/sk.svg +9 -0
- package/dist/flags/1x1/sl.svg +12 -0
- package/dist/flags/1x1/sm.svg +73 -0
- package/dist/flags/1x1/sn.svg +8 -0
- package/dist/flags/1x1/so.svg +11 -0
- package/dist/flags/1x1/sr.svg +6 -0
- package/dist/flags/1x1/ss.svg +8 -0
- package/dist/flags/1x1/st.svg +16 -0
- package/dist/flags/1x1/sv.svg +593 -0
- package/dist/flags/1x1/sx.svg +56 -0
- package/dist/flags/1x1/sy.svg +6 -0
- package/dist/flags/1x1/sz.svg +34 -0
- package/dist/flags/1x1/tc.svg +50 -0
- package/dist/flags/1x1/td.svg +7 -0
- package/dist/flags/1x1/tf.svg +15 -0
- package/dist/flags/1x1/tg.svg +14 -0
- package/dist/flags/1x1/th.svg +7 -0
- package/dist/flags/1x1/tj.svg +26 -0
- package/dist/flags/1x1/tk.svg +5 -0
- package/dist/flags/1x1/tl.svg +13 -0
- package/dist/flags/1x1/tm.svg +205 -0
- package/dist/flags/1x1/tn.svg +4 -0
- package/dist/flags/1x1/to.svg +10 -0
- package/dist/flags/1x1/tr.svg +8 -0
- package/dist/flags/1x1/tt.svg +7 -0
- package/dist/flags/1x1/tv.svg +9 -0
- package/dist/flags/1x1/tw.svg +32 -0
- package/dist/flags/1x1/tz.svg +15 -0
- package/dist/flags/1x1/ua.svg +6 -0
- package/dist/flags/1x1/ug.svg +30 -0
- package/dist/flags/1x1/um.svg +9 -0
- package/dist/flags/1x1/un.svg +16 -0
- package/dist/flags/1x1/us.svg +9 -0
- package/dist/flags/1x1/uy.svg +28 -0
- package/dist/flags/1x1/uz.svg +30 -0
- package/dist/flags/1x1/va.svg +190 -0
- package/dist/flags/1x1/vc.svg +8 -0
- package/dist/flags/1x1/ve.svg +26 -0
- package/dist/flags/1x1/vg.svg +59 -0
- package/dist/flags/1x1/vi.svg +28 -0
- package/dist/flags/1x1/vn.svg +11 -0
- package/dist/flags/1x1/vu.svg +21 -0
- package/dist/flags/1x1/wf.svg +5 -0
- package/dist/flags/1x1/ws.svg +7 -0
- package/dist/flags/1x1/xk.svg +5 -0
- package/dist/flags/1x1/xx.svg +4 -0
- package/dist/flags/1x1/ye.svg +7 -0
- package/dist/flags/1x1/yt.svg +5 -0
- package/dist/flags/1x1/za.svg +17 -0
- package/dist/flags/1x1/zm.svg +27 -0
- package/dist/flags/1x1/zw.svg +21 -0
- package/dist/flags/4x3/ad.svg +150 -0
- package/dist/flags/4x3/ae.svg +6 -0
- package/dist/flags/4x3/af.svg +81 -0
- package/dist/flags/4x3/ag.svg +14 -0
- package/dist/flags/4x3/ai.svg +29 -0
- package/dist/flags/4x3/al.svg +5 -0
- package/dist/flags/4x3/am.svg +5 -0
- package/dist/flags/4x3/ao.svg +13 -0
- package/dist/flags/4x3/aq.svg +5 -0
- package/dist/flags/4x3/ar.svg +32 -0
- package/dist/flags/4x3/arab.svg +109 -0
- package/dist/flags/4x3/as.svg +72 -0
- package/dist/flags/4x3/asean.svg +13 -0
- package/dist/flags/4x3/at.svg +4 -0
- package/dist/flags/4x3/au.svg +8 -0
- package/dist/flags/4x3/aw.svg +186 -0
- package/dist/flags/4x3/ax.svg +18 -0
- package/dist/flags/4x3/az.svg +8 -0
- package/dist/flags/4x3/ba.svg +12 -0
- package/dist/flags/4x3/bb.svg +6 -0
- package/dist/flags/4x3/bd.svg +4 -0
- package/dist/flags/4x3/be.svg +7 -0
- package/dist/flags/4x3/bf.svg +7 -0
- package/dist/flags/4x3/bg.svg +5 -0
- package/dist/flags/4x3/bh.svg +4 -0
- package/dist/flags/4x3/bi.svg +15 -0
- package/dist/flags/4x3/bj.svg +14 -0
- package/dist/flags/4x3/bl.svg +5 -0
- package/dist/flags/4x3/bm.svg +97 -0
- package/dist/flags/4x3/bn.svg +36 -0
- package/dist/flags/4x3/bo.svg +673 -0
- package/dist/flags/4x3/bq.svg +5 -0
- package/dist/flags/4x3/br.svg +45 -0
- package/dist/flags/4x3/bs.svg +13 -0
- package/dist/flags/4x3/bt.svg +89 -0
- package/dist/flags/4x3/bv.svg +13 -0
- package/dist/flags/4x3/bw.svg +7 -0
- package/dist/flags/4x3/by.svg +18 -0
- package/dist/flags/4x3/bz.svg +145 -0
- package/dist/flags/4x3/ca.svg +4 -0
- package/dist/flags/4x3/cc.svg +19 -0
- package/dist/flags/4x3/cd.svg +5 -0
- package/dist/flags/4x3/cefta.svg +13 -0
- package/dist/flags/4x3/cf.svg +15 -0
- package/dist/flags/4x3/cg.svg +12 -0
- package/dist/flags/4x3/ch.svg +9 -0
- package/dist/flags/4x3/ci.svg +7 -0
- package/dist/flags/4x3/ck.svg +9 -0
- package/dist/flags/4x3/cl.svg +13 -0
- package/dist/flags/4x3/cm.svg +15 -0
- package/dist/flags/4x3/cn.svg +11 -0
- package/dist/flags/4x3/co.svg +7 -0
- package/dist/flags/4x3/cp.svg +7 -0
- package/dist/flags/4x3/cr.svg +7 -0
- package/dist/flags/4x3/cu.svg +13 -0
- package/dist/flags/4x3/cv.svg +13 -0
- package/dist/flags/4x3/cw.svg +14 -0
- package/dist/flags/4x3/cx.svg +15 -0
- package/dist/flags/4x3/cy.svg +6 -0
- package/dist/flags/4x3/cz.svg +5 -0
- package/dist/flags/4x3/de.svg +5 -0
- package/dist/flags/4x3/dg.svg +130 -0
- package/dist/flags/4x3/dj.svg +13 -0
- package/dist/flags/4x3/dk.svg +5 -0
- package/dist/flags/4x3/dm.svg +152 -0
- package/dist/flags/4x3/do.svg +121 -0
- package/dist/flags/4x3/dz.svg +5 -0
- package/dist/flags/4x3/eac.svg +48 -0
- package/dist/flags/4x3/ec.svg +138 -0
- package/dist/flags/4x3/ee.svg +5 -0
- package/dist/flags/4x3/eg.svg +38 -0
- package/dist/flags/4x3/eh.svg +16 -0
- package/dist/flags/4x3/er.svg +8 -0
- package/dist/flags/4x3/es-ct.svg +4 -0
- package/dist/flags/4x3/es-ga.svg +187 -0
- package/dist/flags/4x3/es-pv.svg +5 -0
- package/dist/flags/4x3/es.svg +544 -0
- package/dist/flags/4x3/et.svg +14 -0
- package/dist/flags/4x3/eu.svg +28 -0
- package/dist/flags/4x3/fi.svg +5 -0
- package/dist/flags/4x3/fj.svg +120 -0
- package/dist/flags/4x3/fk.svg +90 -0
- package/dist/flags/4x3/fm.svg +11 -0
- package/dist/flags/4x3/fo.svg +12 -0
- package/dist/flags/4x3/fr.svg +5 -0
- package/dist/flags/4x3/ga.svg +7 -0
- package/dist/flags/4x3/gb-eng.svg +5 -0
- package/dist/flags/4x3/gb-nir.svg +132 -0
- package/dist/flags/4x3/gb-sct.svg +4 -0
- package/dist/flags/4x3/gb-wls.svg +9 -0
- package/dist/flags/4x3/gb.svg +7 -0
- package/dist/flags/4x3/gd.svg +27 -0
- package/dist/flags/4x3/ge.svg +6 -0
- package/dist/flags/4x3/gf.svg +5 -0
- package/dist/flags/4x3/gg.svg +9 -0
- package/dist/flags/4x3/gh.svg +6 -0
- package/dist/flags/4x3/gi.svg +32 -0
- package/dist/flags/4x3/gl.svg +4 -0
- package/dist/flags/4x3/gm.svg +14 -0
- package/dist/flags/4x3/gn.svg +7 -0
- package/dist/flags/4x3/gp.svg +5 -0
- package/dist/flags/4x3/gq.svg +23 -0
- package/dist/flags/4x3/gr.svg +16 -0
- package/dist/flags/4x3/gs.svg +133 -0
- package/dist/flags/4x3/gt.svg +204 -0
- package/dist/flags/4x3/gu.svg +19 -0
- package/dist/flags/4x3/gw.svg +13 -0
- package/dist/flags/4x3/gy.svg +9 -0
- package/dist/flags/4x3/hk.svg +8 -0
- package/dist/flags/4x3/hm.svg +8 -0
- package/dist/flags/4x3/hn.svg +18 -0
- package/dist/flags/4x3/hr.svg +58 -0
- package/dist/flags/4x3/ht.svg +116 -0
- package/dist/flags/4x3/hu.svg +7 -0
- package/dist/flags/4x3/ic.svg +7 -0
- package/dist/flags/4x3/id.svg +4 -0
- package/dist/flags/4x3/ie.svg +7 -0
- package/dist/flags/4x3/il.svg +14 -0
- package/dist/flags/4x3/im.svg +36 -0
- package/dist/flags/4x3/in.svg +25 -0
- package/dist/flags/4x3/io.svg +130 -0
- package/dist/flags/4x3/iq.svg +10 -0
- package/dist/flags/4x3/ir.svg +219 -0
- package/dist/flags/4x3/is.svg +12 -0
- package/dist/flags/4x3/it.svg +7 -0
- package/dist/flags/4x3/je.svg +62 -0
- package/dist/flags/4x3/jm.svg +8 -0
- package/dist/flags/4x3/jo.svg +16 -0
- package/dist/flags/4x3/jp.svg +11 -0
- package/dist/flags/4x3/ke.svg +23 -0
- package/dist/flags/4x3/kg.svg +4 -0
- package/dist/flags/4x3/kh.svg +61 -0
- package/dist/flags/4x3/ki.svg +36 -0
- package/dist/flags/4x3/km.svg +16 -0
- package/dist/flags/4x3/kn.svg +14 -0
- package/dist/flags/4x3/kp.svg +15 -0
- package/dist/flags/4x3/kr.svg +24 -0
- package/dist/flags/4x3/kw.svg +13 -0
- package/dist/flags/4x3/ky.svg +103 -0
- package/dist/flags/4x3/kz.svg +36 -0
- package/dist/flags/4x3/la.svg +12 -0
- package/dist/flags/4x3/lb.svg +15 -0
- package/dist/flags/4x3/lc.svg +8 -0
- package/dist/flags/4x3/li.svg +43 -0
- package/dist/flags/4x3/lk.svg +22 -0
- package/dist/flags/4x3/lr.svg +14 -0
- package/dist/flags/4x3/ls.svg +8 -0
- package/dist/flags/4x3/lt.svg +7 -0
- package/dist/flags/4x3/lu.svg +5 -0
- package/dist/flags/4x3/lv.svg +7 -0
- package/dist/flags/4x3/ly.svg +13 -0
- package/dist/flags/4x3/ma.svg +4 -0
- package/dist/flags/4x3/mc.svg +6 -0
- package/dist/flags/4x3/md.svg +70 -0
- package/dist/flags/4x3/me.svg +116 -0
- package/dist/flags/4x3/mf.svg +5 -0
- package/dist/flags/4x3/mg.svg +7 -0
- package/dist/flags/4x3/mh.svg +7 -0
- package/dist/flags/4x3/mk.svg +5 -0
- package/dist/flags/4x3/ml.svg +7 -0
- package/dist/flags/4x3/mm.svg +12 -0
- package/dist/flags/4x3/mn.svg +14 -0
- package/dist/flags/4x3/mo.svg +9 -0
- package/dist/flags/4x3/mp.svg +86 -0
- package/dist/flags/4x3/mq.svg +5 -0
- package/dist/flags/4x3/mr.svg +6 -0
- package/dist/flags/4x3/ms.svg +29 -0
- package/dist/flags/4x3/mt.svg +58 -0
- package/dist/flags/4x3/mu.svg +8 -0
- package/dist/flags/4x3/mv.svg +6 -0
- package/dist/flags/4x3/mw.svg +10 -0
- package/dist/flags/4x3/mx.svg +382 -0
- package/dist/flags/4x3/my.svg +26 -0
- package/dist/flags/4x3/mz.svg +21 -0
- package/dist/flags/4x3/na.svg +16 -0
- package/dist/flags/4x3/nc.svg +13 -0
- package/dist/flags/4x3/ne.svg +6 -0
- package/dist/flags/4x3/nf.svg +9 -0
- package/dist/flags/4x3/ng.svg +6 -0
- package/dist/flags/4x3/ni.svg +129 -0
- package/dist/flags/4x3/nl.svg +5 -0
- package/dist/flags/4x3/no.svg +7 -0
- package/dist/flags/4x3/np.svg +13 -0
- package/dist/flags/4x3/nr.svg +12 -0
- package/dist/flags/4x3/nu.svg +10 -0
- package/dist/flags/4x3/null +1 -0
- package/dist/flags/4x3/nz.svg +36 -0
- package/dist/flags/4x3/om.svg +115 -0
- package/dist/flags/4x3/pa.svg +7 -0
- package/dist/flags/4x3/pc.svg +33 -0
- package/dist/flags/4x3/pe.svg +4 -0
- package/dist/flags/4x3/pf.svg +19 -0
- package/dist/flags/4x3/pg.svg +9 -0
- package/dist/flags/4x3/ph.svg +6 -0
- package/dist/flags/4x3/pk.svg +15 -0
- package/dist/flags/4x3/pl.svg +6 -0
- package/dist/flags/4x3/pm.svg +5 -0
- package/dist/flags/4x3/pn.svg +53 -0
- package/dist/flags/4x3/pr.svg +13 -0
- package/dist/flags/4x3/ps.svg +6 -0
- package/dist/flags/4x3/pt.svg +57 -0
- package/dist/flags/4x3/pw.svg +11 -0
- package/dist/flags/4x3/py.svg +157 -0
- package/dist/flags/4x3/qa.svg +4 -0
- package/dist/flags/4x3/re.svg +5 -0
- package/dist/flags/4x3/ro.svg +7 -0
- package/dist/flags/4x3/rs.svg +292 -0
- package/dist/flags/4x3/ru.svg +5 -0
- package/dist/flags/4x3/rw.svg +13 -0
- package/dist/flags/4x3/sa.svg +25 -0
- package/dist/flags/4x3/sb.svg +13 -0
- package/dist/flags/4x3/sc.svg +7 -0
- package/dist/flags/4x3/sd.svg +13 -0
- package/dist/flags/4x3/se.svg +4 -0
- package/dist/flags/4x3/sg.svg +13 -0
- package/dist/flags/4x3/sh-ac.svg +689 -0
- package/dist/flags/4x3/sh-hl.svg +164 -0
- package/dist/flags/4x3/sh-ta.svg +76 -0
- package/dist/flags/4x3/sh.svg +7 -0
- package/dist/flags/4x3/si.svg +18 -0
- package/dist/flags/4x3/sj.svg +7 -0
- package/dist/flags/4x3/sk.svg +9 -0
- package/dist/flags/4x3/sl.svg +7 -0
- package/dist/flags/4x3/sm.svg +75 -0
- package/dist/flags/4x3/sn.svg +8 -0
- package/dist/flags/4x3/so.svg +11 -0
- package/dist/flags/4x3/sr.svg +6 -0
- package/dist/flags/4x3/ss.svg +8 -0
- package/dist/flags/4x3/st.svg +16 -0
- package/dist/flags/4x3/sv.svg +593 -0
- package/dist/flags/4x3/sx.svg +56 -0
- package/dist/flags/4x3/sy.svg +6 -0
- package/dist/flags/4x3/sz.svg +34 -0
- package/dist/flags/4x3/tc.svg +50 -0
- package/dist/flags/4x3/td.svg +7 -0
- package/dist/flags/4x3/tf.svg +15 -0
- package/dist/flags/4x3/tg.svg +14 -0
- package/dist/flags/4x3/th.svg +7 -0
- package/dist/flags/4x3/tj.svg +22 -0
- package/dist/flags/4x3/tk.svg +5 -0
- package/dist/flags/4x3/tl.svg +13 -0
- package/dist/flags/4x3/tm.svg +204 -0
- package/dist/flags/4x3/tn.svg +4 -0
- package/dist/flags/4x3/to.svg +10 -0
- package/dist/flags/4x3/tr.svg +8 -0
- package/dist/flags/4x3/tt.svg +5 -0
- package/dist/flags/4x3/tv.svg +9 -0
- package/dist/flags/4x3/tw.svg +34 -0
- package/dist/flags/4x3/tz.svg +13 -0
- package/dist/flags/4x3/ua.svg +6 -0
- package/dist/flags/4x3/ug.svg +30 -0
- package/dist/flags/4x3/um.svg +9 -0
- package/dist/flags/4x3/un.svg +16 -0
- package/dist/flags/4x3/us.svg +9 -0
- package/dist/flags/4x3/uy.svg +28 -0
- package/dist/flags/4x3/uz.svg +30 -0
- package/dist/flags/4x3/va.svg +190 -0
- package/dist/flags/4x3/vc.svg +8 -0
- package/dist/flags/4x3/ve.svg +26 -0
- package/dist/flags/4x3/vg.svg +59 -0
- package/dist/flags/4x3/vi.svg +28 -0
- package/dist/flags/4x3/vn.svg +11 -0
- package/dist/flags/4x3/vu.svg +21 -0
- package/dist/flags/4x3/wf.svg +5 -0
- package/dist/flags/4x3/ws.svg +7 -0
- package/dist/flags/4x3/xk.svg +5 -0
- package/dist/flags/4x3/xx.svg +4 -0
- package/dist/flags/4x3/ye.svg +7 -0
- package/dist/flags/4x3/yt.svg +5 -0
- package/dist/flags/4x3/za.svg +17 -0
- package/dist/flags/4x3/zm.svg +27 -0
- package/dist/flags/4x3/zw.svg +21 -0
- 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/
|
|
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.
|
|
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
|
-
│ └─
|
|
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
|
package/dist/country-select.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* CountrySelect Pro
|
|
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
|
-
//
|
|
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
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
303
|
-
this.
|
|
304
|
-
|
|
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
|
-
|
|
308
|
-
this.
|
|
309
|
-
|
|
310
|
-
|
|
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
|
-
|
|
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
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
list.scrollTop =
|
|
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();
|