typehead.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008
  1. const field = document.getElementById('typehead');
  2. const ac = new Autocomplete(field, {
  3. data: [{label: "I'm a label", value: 42}],
  4. maximumItems: 100,
  5. threshold: 1,
  6. onSelectItem: ({label, value}) => {
  7. console.log("user selected:", label, value);
  8. }
  9. });
  10. ac.setData([
  11. {
  12. "label": "Afghanistan",
  13. "value": "AF"
  14. },
  15. {
  16. "label": "Albania",
  17. "value": "AL"
  18. },
  19. {
  20. "label": "Algeria",
  21. "value": "DZ"
  22. },
  23. {
  24. "label": "American Samoa",
  25. "value": "AS"
  26. },
  27. {
  28. "label": "Andorra",
  29. "value": "AD"
  30. },
  31. {
  32. "label": "Angola",
  33. "value": "AO"
  34. },
  35. {
  36. "label": "Anguilla",
  37. "value": "AI"
  38. },
  39. {
  40. "label": "Antarctica",
  41. "value": "AQ"
  42. },
  43. {
  44. "label": "Antigua and Barbuda",
  45. "value": "AG"
  46. },
  47. {
  48. "label": "Argentina",
  49. "value": "AR"
  50. },
  51. {
  52. "label": "Armenia",
  53. "value": "AM"
  54. },
  55. {
  56. "label": "Aruba",
  57. "value": "AW"
  58. },
  59. {
  60. "label": "Australia",
  61. "value": "AU"
  62. },
  63. {
  64. "label": "Austria",
  65. "value": "AT"
  66. },
  67. {
  68. "label": "Azerbaijan",
  69. "value": "AZ"
  70. },
  71. {
  72. "label": "Bahamas (the)",
  73. "value": "BS"
  74. },
  75. {
  76. "label": "Bahrain",
  77. "value": "BH"
  78. },
  79. {
  80. "label": "Bangladesh",
  81. "value": "BD"
  82. },
  83. {
  84. "label": "Barbados",
  85. "value": "BB"
  86. },
  87. {
  88. "label": "Belarus",
  89. "value": "BY"
  90. },
  91. {
  92. "label": "Belgium",
  93. "value": "BE"
  94. },
  95. {
  96. "label": "Belize",
  97. "value": "BZ"
  98. },
  99. {
  100. "label": "Benin",
  101. "value": "BJ"
  102. },
  103. {
  104. "label": "Bermuda",
  105. "value": "BM"
  106. },
  107. {
  108. "label": "Bhutan",
  109. "value": "BT"
  110. },
  111. {
  112. "label": "Bolivia (Plurinational State of)",
  113. "value": "BO"
  114. },
  115. {
  116. "label": "Bonaire, Sint Eustatius and Saba",
  117. "value": "BQ"
  118. },
  119. {
  120. "label": "Bosnia and Herzegovina",
  121. "value": "BA"
  122. },
  123. {
  124. "label": "Botswana",
  125. "value": "BW"
  126. },
  127. {
  128. "label": "Bouvet Island",
  129. "value": "BV"
  130. },
  131. {
  132. "label": "Brazil",
  133. "value": "BR"
  134. },
  135. {
  136. "label": "British Indian Ocean Territory (the)",
  137. "value": "IO"
  138. },
  139. {
  140. "label": "Brunei Darussalam",
  141. "value": "BN"
  142. },
  143. {
  144. "label": "Bulgaria",
  145. "value": "BG"
  146. },
  147. {
  148. "label": "Burkina Faso",
  149. "value": "BF"
  150. },
  151. {
  152. "label": "Burundi",
  153. "value": "BI"
  154. },
  155. {
  156. "label": "Cabo Verde",
  157. "value": "CV"
  158. },
  159. {
  160. "label": "Cambodia",
  161. "value": "KH"
  162. },
  163. {
  164. "label": "Cameroon",
  165. "value": "CM"
  166. },
  167. {
  168. "label": "Canada",
  169. "value": "CA"
  170. },
  171. {
  172. "label": "Cayman Islands (the)",
  173. "value": "KY"
  174. },
  175. {
  176. "label": "Central African Republic (the)",
  177. "value": "CF"
  178. },
  179. {
  180. "label": "Chad",
  181. "value": "TD"
  182. },
  183. {
  184. "label": "Chile",
  185. "value": "CL"
  186. },
  187. {
  188. "label": "China",
  189. "value": "CN"
  190. },
  191. {
  192. "label": "Christmas Island",
  193. "value": "CX"
  194. },
  195. {
  196. "label": "Cocos (Keeling) Islands (the)",
  197. "value": "CC"
  198. },
  199. {
  200. "label": "Colombia",
  201. "value": "CO"
  202. },
  203. {
  204. "label": "Comoros (the)",
  205. "value": "KM"
  206. },
  207. {
  208. "label": "Congo (the Democratic Republic of the)",
  209. "value": "CD"
  210. },
  211. {
  212. "label": "Congo (the)",
  213. "value": "CG"
  214. },
  215. {
  216. "label": "Cook Islands (the)",
  217. "value": "CK"
  218. },
  219. {
  220. "label": "Costa Rica",
  221. "value": "CR"
  222. },
  223. {
  224. "label": "Croatia",
  225. "value": "HR"
  226. },
  227. {
  228. "label": "Cuba",
  229. "value": "CU"
  230. },
  231. {
  232. "label": "Curaçao",
  233. "value": "CW"
  234. },
  235. {
  236. "label": "Cyprus",
  237. "value": "CY"
  238. },
  239. {
  240. "label": "Czechia",
  241. "value": "CZ"
  242. },
  243. {
  244. "label": "Côte d'Ivoire",
  245. "value": "CI"
  246. },
  247. {
  248. "label": "Denmark",
  249. "value": "DK"
  250. },
  251. {
  252. "label": "Djibouti",
  253. "value": "DJ"
  254. },
  255. {
  256. "label": "Dominica",
  257. "value": "DM"
  258. },
  259. {
  260. "label": "Dominican Republic (the)",
  261. "value": "DO"
  262. },
  263. {
  264. "label": "Ecuador",
  265. "value": "EC"
  266. },
  267. {
  268. "label": "Egypt",
  269. "value": "EG"
  270. },
  271. {
  272. "label": "El Salvador",
  273. "value": "SV"
  274. },
  275. {
  276. "label": "Equatorial Guinea",
  277. "value": "GQ"
  278. },
  279. {
  280. "label": "Eritrea",
  281. "value": "ER"
  282. },
  283. {
  284. "label": "Estonia",
  285. "value": "EE"
  286. },
  287. {
  288. "label": "Eswatini",
  289. "value": "SZ"
  290. },
  291. {
  292. "label": "Ethiopia",
  293. "value": "ET"
  294. },
  295. {
  296. "label": "Falkland Islands (the) [Malvinas]",
  297. "value": "FK"
  298. },
  299. {
  300. "label": "Faroe Islands (the)",
  301. "value": "FO"
  302. },
  303. {
  304. "label": "Fiji",
  305. "value": "FJ"
  306. },
  307. {
  308. "label": "Finland",
  309. "value": "FI"
  310. },
  311. {
  312. "label": "France",
  313. "value": "FR"
  314. },
  315. {
  316. "label": "French Guiana",
  317. "value": "GF"
  318. },
  319. {
  320. "label": "French Polynesia",
  321. "value": "PF"
  322. },
  323. {
  324. "label": "French Southern Territories (the)",
  325. "value": "TF"
  326. },
  327. {
  328. "label": "Gabon",
  329. "value": "GA"
  330. },
  331. {
  332. "label": "Gambia (the)",
  333. "value": "GM"
  334. },
  335. {
  336. "label": "Georgia",
  337. "value": "GE"
  338. },
  339. {
  340. "label": "Germany",
  341. "value": "DE"
  342. },
  343. {
  344. "label": "Ghana",
  345. "value": "GH"
  346. },
  347. {
  348. "label": "Gibraltar",
  349. "value": "GI"
  350. },
  351. {
  352. "label": "Greece",
  353. "value": "GR"
  354. },
  355. {
  356. "label": "Greenland",
  357. "value": "GL"
  358. },
  359. {
  360. "label": "Grenada",
  361. "value": "GD"
  362. },
  363. {
  364. "label": "Guadeloupe",
  365. "value": "GP"
  366. },
  367. {
  368. "label": "Guam",
  369. "value": "GU"
  370. },
  371. {
  372. "label": "Guatemala",
  373. "value": "GT"
  374. },
  375. {
  376. "label": "Guernsey",
  377. "value": "GG"
  378. },
  379. {
  380. "label": "Guinea",
  381. "value": "GN"
  382. },
  383. {
  384. "label": "Guinea-Bissau",
  385. "value": "GW"
  386. },
  387. {
  388. "label": "Guyana",
  389. "value": "GY"
  390. },
  391. {
  392. "label": "Haiti",
  393. "value": "HT"
  394. },
  395. {
  396. "label": "Heard Island and McDonald Islands",
  397. "value": "HM"
  398. },
  399. {
  400. "label": "Holy See (the)",
  401. "value": "VA"
  402. },
  403. {
  404. "label": "Honduras",
  405. "value": "HN"
  406. },
  407. {
  408. "label": "Hong Kong",
  409. "value": "HK"
  410. },
  411. {
  412. "label": "Hungary",
  413. "value": "HU"
  414. },
  415. {
  416. "label": "Iceland",
  417. "value": "IS"
  418. },
  419. {
  420. "label": "India",
  421. "value": "IN"
  422. },
  423. {
  424. "label": "Indonesia",
  425. "value": "ID"
  426. },
  427. {
  428. "label": "Iran (Islamic Republic of)",
  429. "value": "IR"
  430. },
  431. {
  432. "label": "Iraq",
  433. "value": "IQ"
  434. },
  435. {
  436. "label": "Ireland",
  437. "value": "IE"
  438. },
  439. {
  440. "label": "Isle of Man",
  441. "value": "IM"
  442. },
  443. {
  444. "label": "Israel",
  445. "value": "IL"
  446. },
  447. {
  448. "label": "Italy",
  449. "value": "IT"
  450. },
  451. {
  452. "label": "Jamaica",
  453. "value": "JM"
  454. },
  455. {
  456. "label": "Japan",
  457. "value": "JP"
  458. },
  459. {
  460. "label": "Jersey",
  461. "value": "JE"
  462. },
  463. {
  464. "label": "Jordan",
  465. "value": "JO"
  466. },
  467. {
  468. "label": "Kazakhstan",
  469. "value": "KZ"
  470. },
  471. {
  472. "label": "Kenya",
  473. "value": "KE"
  474. },
  475. {
  476. "label": "Kiribati",
  477. "value": "KI"
  478. },
  479. {
  480. "label": "Korea (the Democratic People's Republic of)",
  481. "value": "KP"
  482. },
  483. {
  484. "label": "Korea (the Republic of)",
  485. "value": "KR"
  486. },
  487. {
  488. "label": "Kuwait",
  489. "value": "KW"
  490. },
  491. {
  492. "label": "Kyrgyzstan",
  493. "value": "KG"
  494. },
  495. {
  496. "label": "Lao People's Democratic Republic (the)",
  497. "value": "LA"
  498. },
  499. {
  500. "label": "Latvia",
  501. "value": "LV"
  502. },
  503. {
  504. "label": "Lebanon",
  505. "value": "LB"
  506. },
  507. {
  508. "label": "Lesotho",
  509. "value": "LS"
  510. },
  511. {
  512. "label": "Liberia",
  513. "value": "LR"
  514. },
  515. {
  516. "label": "Libya",
  517. "value": "LY"
  518. },
  519. {
  520. "label": "Liechtenstein",
  521. "value": "LI"
  522. },
  523. {
  524. "label": "Lithuania",
  525. "value": "LT"
  526. },
  527. {
  528. "label": "Luxembourg",
  529. "value": "LU"
  530. },
  531. {
  532. "label": "Macao",
  533. "value": "MO"
  534. },
  535. {
  536. "label": "Madagascar",
  537. "value": "MG"
  538. },
  539. {
  540. "label": "Malawi",
  541. "value": "MW"
  542. },
  543. {
  544. "label": "Malaysia",
  545. "value": "MY"
  546. },
  547. {
  548. "label": "Maldives",
  549. "value": "MV"
  550. },
  551. {
  552. "label": "Mali",
  553. "value": "ML"
  554. },
  555. {
  556. "label": "Malta",
  557. "value": "MT"
  558. },
  559. {
  560. "label": "Marshall Islands (the)",
  561. "value": "MH"
  562. },
  563. {
  564. "label": "Martinique",
  565. "value": "MQ"
  566. },
  567. {
  568. "label": "Mauritania",
  569. "value": "MR"
  570. },
  571. {
  572. "label": "Mauritius",
  573. "value": "MU"
  574. },
  575. {
  576. "label": "Mayotte",
  577. "value": "YT"
  578. },
  579. {
  580. "label": "Mexico",
  581. "value": "MX"
  582. },
  583. {
  584. "label": "Micronesia (Federated States of)",
  585. "value": "FM"
  586. },
  587. {
  588. "label": "Moldova (the Republic of)",
  589. "value": "MD"
  590. },
  591. {
  592. "label": "Monaco",
  593. "value": "MC"
  594. },
  595. {
  596. "label": "Mongolia",
  597. "value": "MN"
  598. },
  599. {
  600. "label": "Montenegro",
  601. "value": "ME"
  602. },
  603. {
  604. "label": "Montserrat",
  605. "value": "MS"
  606. },
  607. {
  608. "label": "Morocco",
  609. "value": "MA"
  610. },
  611. {
  612. "label": "Mozambique",
  613. "value": "MZ"
  614. },
  615. {
  616. "label": "Myanmar",
  617. "value": "MM"
  618. },
  619. {
  620. "label": "Namibia",
  621. "value": "NA"
  622. },
  623. {
  624. "label": "Nauru",
  625. "value": "NR"
  626. },
  627. {
  628. "label": "Nepal",
  629. "value": "NP"
  630. },
  631. {
  632. "label": "Netherlands (the)",
  633. "value": "NL"
  634. },
  635. {
  636. "label": "New Caledonia",
  637. "value": "NC"
  638. },
  639. {
  640. "label": "New Zealand",
  641. "value": "NZ"
  642. },
  643. {
  644. "label": "Nicaragua",
  645. "value": "NI"
  646. },
  647. {
  648. "label": "Niger (the)",
  649. "value": "NE"
  650. },
  651. {
  652. "label": "Nigeria",
  653. "value": "NG"
  654. },
  655. {
  656. "label": "Niue",
  657. "value": "NU"
  658. },
  659. {
  660. "label": "Norfolk Island",
  661. "value": "NF"
  662. },
  663. {
  664. "label": "Northern Mariana Islands (the)",
  665. "value": "MP"
  666. },
  667. {
  668. "label": "Norway",
  669. "value": "NO"
  670. },
  671. {
  672. "label": "Oman",
  673. "value": "OM"
  674. },
  675. {
  676. "label": "Pakistan",
  677. "value": "PK"
  678. },
  679. {
  680. "label": "Palau",
  681. "value": "PW"
  682. },
  683. {
  684. "label": "Palestine, State of",
  685. "value": "PS"
  686. },
  687. {
  688. "label": "Panama",
  689. "value": "PA"
  690. },
  691. {
  692. "label": "Papua New Guinea",
  693. "value": "PG"
  694. },
  695. {
  696. "label": "Paraguay",
  697. "value": "PY"
  698. },
  699. {
  700. "label": "Peru",
  701. "value": "PE"
  702. },
  703. {
  704. "label": "Philippines (the)",
  705. "value": "PH"
  706. },
  707. {
  708. "label": "Pitcairn",
  709. "value": "PN"
  710. },
  711. {
  712. "label": "Poland",
  713. "value": "PL"
  714. },
  715. {
  716. "label": "Portugal",
  717. "value": "PT"
  718. },
  719. {
  720. "label": "Puerto Rico",
  721. "value": "PR"
  722. },
  723. {
  724. "label": "Qatar",
  725. "value": "QA"
  726. },
  727. {
  728. "label": "Republic of North Macedonia",
  729. "value": "MK"
  730. },
  731. {
  732. "label": "Romania",
  733. "value": "RO"
  734. },
  735. {
  736. "label": "Russian Federation (the)",
  737. "value": "RU"
  738. },
  739. {
  740. "label": "Rwanda",
  741. "value": "RW"
  742. },
  743. {
  744. "label": "Réunion",
  745. "value": "RE"
  746. },
  747. {
  748. "label": "Saint Barthélemy",
  749. "value": "BL"
  750. },
  751. {
  752. "label": "Saint Helena, Ascension and Tristan da Cunha",
  753. "value": "SH"
  754. },
  755. {
  756. "label": "Saint Kitts and Nevis",
  757. "value": "KN"
  758. },
  759. {
  760. "label": "Saint Lucia",
  761. "value": "LC"
  762. },
  763. {
  764. "label": "Saint Martin (French part)",
  765. "value": "MF"
  766. },
  767. {
  768. "label": "Saint Pierre and Miquelon",
  769. "value": "PM"
  770. },
  771. {
  772. "label": "Saint Vincent and the Grenadines",
  773. "value": "VC"
  774. },
  775. {
  776. "label": "Samoa",
  777. "value": "WS"
  778. },
  779. {
  780. "label": "San Marino",
  781. "value": "SM"
  782. },
  783. {
  784. "label": "Sao Tome and Principe",
  785. "value": "ST"
  786. },
  787. {
  788. "label": "Saudi Arabia",
  789. "value": "SA"
  790. },
  791. {
  792. "label": "Senegal",
  793. "value": "SN"
  794. },
  795. {
  796. "label": "Serbia",
  797. "value": "RS"
  798. },
  799. {
  800. "label": "Seychelles",
  801. "value": "SC"
  802. },
  803. {
  804. "label": "Sierra Leone",
  805. "value": "SL"
  806. },
  807. {
  808. "label": "Singapore",
  809. "value": "SG"
  810. },
  811. {
  812. "label": "Sint Maarten (Dutch part)",
  813. "value": "SX"
  814. },
  815. {
  816. "label": "Slovakia",
  817. "value": "SK"
  818. },
  819. {
  820. "label": "Slovenia",
  821. "value": "SI"
  822. },
  823. {
  824. "label": "Solomon Islands",
  825. "value": "SB"
  826. },
  827. {
  828. "label": "Somalia",
  829. "value": "SO"
  830. },
  831. {
  832. "label": "South Africa",
  833. "value": "ZA"
  834. },
  835. {
  836. "label": "South Georgia and the South Sandwich Islands",
  837. "value": "GS"
  838. },
  839. {
  840. "label": "South Sudan",
  841. "value": "SS"
  842. },
  843. {
  844. "label": "Spain",
  845. "value": "ES"
  846. },
  847. {
  848. "label": "Sri Lanka",
  849. "value": "LK"
  850. },
  851. {
  852. "label": "Sudan (the)",
  853. "value": "SD"
  854. },
  855. {
  856. "label": "Suriname",
  857. "value": "SR"
  858. },
  859. {
  860. "label": "Svalbard and Jan Mayen",
  861. "value": "SJ"
  862. },
  863. {
  864. "label": "Sweden",
  865. "value": "SE"
  866. },
  867. {
  868. "label": "Switzerland",
  869. "value": "CH"
  870. },
  871. {
  872. "label": "Syrian Arab Republic",
  873. "value": "SY"
  874. },
  875. {
  876. "label": "Taiwan (Province of China)",
  877. "value": "TW"
  878. },
  879. {
  880. "label": "Tajikistan",
  881. "value": "TJ"
  882. },
  883. {
  884. "label": "Tanzania, United Republic of",
  885. "value": "TZ"
  886. },
  887. {
  888. "label": "Thailand",
  889. "value": "TH"
  890. },
  891. {
  892. "label": "Timor-Leste",
  893. "value": "TL"
  894. },
  895. {
  896. "label": "Togo",
  897. "value": "TG"
  898. },
  899. {
  900. "label": "Tokelau",
  901. "value": "TK"
  902. },
  903. {
  904. "label": "Tonga",
  905. "value": "TO"
  906. },
  907. {
  908. "label": "Trinidad and Tobago",
  909. "value": "TT"
  910. },
  911. {
  912. "label": "Tunisia",
  913. "value": "TN"
  914. },
  915. {
  916. "label": "Turkey",
  917. "value": "TR"
  918. },
  919. {
  920. "label": "Turkmenistan",
  921. "value": "TM"
  922. },
  923. {
  924. "label": "Turks and Caicos Islands (the)",
  925. "value": "TC"
  926. },
  927. {
  928. "label": "Tuvalu",
  929. "value": "TV"
  930. },
  931. {
  932. "label": "Uganda",
  933. "value": "UG"
  934. },
  935. {
  936. "label": "Ukraine",
  937. "value": "UA"
  938. },
  939. {
  940. "label": "United Arab Emirates (the)",
  941. "value": "AE"
  942. },
  943. {
  944. "label": "United Kingdom of Great Britain and Northern Ireland (the)",
  945. "value": "GB"
  946. },
  947. {
  948. "label": "United States Minor Outlying Islands (the)",
  949. "value": "UM"
  950. },
  951. {
  952. "label": "United States of America (the)",
  953. "value": "US"
  954. },
  955. {
  956. "label": "Uruguay",
  957. "value": "UY"
  958. },
  959. {
  960. "label": "Uzbekistan",
  961. "value": "UZ"
  962. },
  963. {
  964. "label": "Vanuatu",
  965. "value": "VU"
  966. },
  967. {
  968. "label": "Venezuela (Bolivarian Republic of)",
  969. "value": "VE"
  970. },
  971. {
  972. "label": "Viet Nam",
  973. "value": "VN"
  974. },
  975. {
  976. "label": "Virgin Islands (British)",
  977. "value": "VG"
  978. },
  979. {
  980. "label": "Virgin Islands (U.S.)",
  981. "value": "VI"
  982. },
  983. {
  984. "label": "Wallis and Futuna",
  985. "value": "WF"
  986. },
  987. {
  988. "label": "Western Sahara",
  989. "value": "EH"
  990. },
  991. {
  992. "label": "Yemen",
  993. "value": "YE"
  994. },
  995. {
  996. "label": "Zambia",
  997. "value": "ZM"
  998. },
  999. {
  1000. "label": "Zimbabwe",
  1001. "value": "ZW"
  1002. },
  1003. {
  1004. "label": "Åland Islands",
  1005. "value": "AX"
  1006. }
  1007. ]);