tom-select-rails 2.3.1 → 2.4.5

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 (259) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tom-select-rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/tom-select-rails/cjs/constants.js +16 -0
  4. data/vendor/assets/javascripts/tom-select-rails/cjs/constants.js.map +1 -0
  5. data/vendor/assets/javascripts/tom-select-rails/cjs/contrib/highlight.js +69 -0
  6. data/vendor/assets/javascripts/tom-select-rails/cjs/contrib/highlight.js.map +1 -0
  7. data/vendor/assets/javascripts/tom-select-rails/cjs/contrib/microevent.js +64 -0
  8. data/vendor/assets/javascripts/tom-select-rails/cjs/contrib/microevent.js.map +1 -0
  9. data/vendor/assets/javascripts/tom-select-rails/cjs/contrib/microplugin.js +112 -0
  10. data/vendor/assets/javascripts/tom-select-rails/cjs/contrib/microplugin.js.map +1 -0
  11. data/vendor/assets/javascripts/tom-select-rails/cjs/defaults.js +84 -0
  12. data/vendor/assets/javascripts/tom-select-rails/cjs/defaults.js.map +1 -0
  13. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/getSettings.d.ts +2 -2
  14. data/vendor/assets/javascripts/tom-select-rails/cjs/getSettings.js +146 -0
  15. data/vendor/assets/javascripts/tom-select-rails/cjs/getSettings.js.map +1 -0
  16. data/vendor/assets/javascripts/tom-select-rails/cjs/package.json +1 -0
  17. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/plugins/caret_position/plugin.d.ts +1 -1
  18. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/caret_position/plugin.js +66 -0
  19. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/caret_position/plugin.js.map +1 -0
  20. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/plugins/change_listener/plugin.d.ts +1 -1
  21. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/change_listener/plugin.js +25 -0
  22. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/change_listener/plugin.js.map +1 -0
  23. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/plugins/checkbox_options/plugin.d.ts +2 -2
  24. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/checkbox_options/plugin.js +108 -0
  25. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/checkbox_options/plugin.js.map +1 -0
  26. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/checkbox_options/types.js +3 -0
  27. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/checkbox_options/types.js.map +1 -0
  28. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/plugins/clear_button/plugin.d.ts +2 -2
  29. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/clear_button/plugin.js +46 -0
  30. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/clear_button/plugin.js.map +1 -0
  31. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/plugins/clear_button/types.d.ts +2 -0
  32. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/clear_button/types.js +3 -0
  33. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/clear_button/types.js.map +1 -0
  34. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/plugins/drag_drop/plugin.d.ts +1 -1
  35. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/drag_drop/plugin.js +117 -0
  36. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/drag_drop/plugin.js.map +1 -0
  37. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/plugins/dropdown_header/plugin.d.ts +2 -2
  38. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/dropdown_header/plugin.js +50 -0
  39. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/dropdown_header/plugin.js.map +1 -0
  40. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/dropdown_header/types.js +3 -0
  41. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/dropdown_header/types.js.map +1 -0
  42. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/plugins/dropdown_input/plugin.d.ts +1 -1
  43. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/dropdown_input/plugin.js +77 -0
  44. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/dropdown_input/plugin.js.map +1 -0
  45. data/vendor/assets/javascripts/tom-select-rails/{types/plugins/no_backspace_delete → cjs/plugins/input_autogrow}/plugin.d.ts +1 -1
  46. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/input_autogrow/plugin.js +47 -0
  47. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/input_autogrow/plugin.js.map +1 -0
  48. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/plugins/no_active_items/plugin.d.ts +1 -1
  49. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/no_active_items/plugin.js +22 -0
  50. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/no_active_items/plugin.js.map +1 -0
  51. data/vendor/assets/javascripts/tom-select-rails/{types/plugins/input_autogrow → cjs/plugins/no_backspace_delete}/plugin.d.ts +1 -1
  52. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/no_backspace_delete/plugin.js +28 -0
  53. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/no_backspace_delete/plugin.js.map +1 -0
  54. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/plugins/optgroup_columns/plugin.d.ts +1 -1
  55. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/optgroup_columns/plugin.js +51 -0
  56. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/optgroup_columns/plugin.js.map +1 -0
  57. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/plugins/remove_button/plugin.d.ts +2 -2
  58. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/remove_button/plugin.js +61 -0
  59. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/remove_button/plugin.js.map +1 -0
  60. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/remove_button/types.js +3 -0
  61. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/remove_button/types.js.map +1 -0
  62. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/plugins/restore_on_backspace/plugin.d.ts +2 -2
  63. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/restore_on_backspace/plugin.js +24 -0
  64. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/restore_on_backspace/plugin.js.map +1 -0
  65. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/plugins/virtual_scroll/plugin.d.ts +1 -1
  66. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/virtual_scroll/plugin.js +170 -0
  67. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/virtual_scroll/plugin.js.map +1 -0
  68. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.complete.d.ts +2 -0
  69. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.complete.js +33 -5291
  70. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.complete.js.map +1 -1
  71. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/tom-select.d.ts +3 -3
  72. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.js +2128 -4255
  73. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.js.map +1 -1
  74. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.popular.d.ts +2 -0
  75. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.popular.js +15 -4665
  76. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.popular.js.map +1 -1
  77. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/types/core.d.ts +2 -2
  78. data/vendor/assets/javascripts/tom-select-rails/cjs/types/core.js +3 -0
  79. data/vendor/assets/javascripts/tom-select-rails/cjs/types/core.js.map +1 -0
  80. data/vendor/assets/javascripts/tom-select-rails/cjs/types/index.d.ts +2 -0
  81. data/vendor/assets/javascripts/tom-select-rails/cjs/types/index.js +19 -0
  82. data/vendor/assets/javascripts/tom-select-rails/cjs/types/index.js.map +1 -0
  83. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/types/settings.d.ts +4 -4
  84. data/vendor/assets/javascripts/tom-select-rails/cjs/types/settings.js +3 -0
  85. data/vendor/assets/javascripts/tom-select-rails/cjs/types/settings.js.map +1 -0
  86. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/utils.d.ts +16 -4
  87. data/vendor/assets/javascripts/tom-select-rails/cjs/utils.js +124 -112
  88. data/vendor/assets/javascripts/tom-select-rails/cjs/utils.js.map +1 -1
  89. data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/vanilla.d.ts +1 -1
  90. data/vendor/assets/javascripts/tom-select-rails/cjs/vanilla.js +190 -0
  91. data/vendor/assets/javascripts/tom-select-rails/cjs/vanilla.js.map +1 -0
  92. data/vendor/assets/javascripts/tom-select-rails/esm/constants.d.ts +12 -0
  93. data/vendor/assets/javascripts/tom-select-rails/esm/constants.js +13 -0
  94. data/vendor/assets/javascripts/tom-select-rails/esm/constants.js.map +1 -0
  95. data/vendor/assets/javascripts/tom-select-rails/esm/contrib/highlight.d.ts +13 -0
  96. data/vendor/assets/javascripts/tom-select-rails/esm/contrib/highlight.js +64 -0
  97. data/vendor/assets/javascripts/tom-select-rails/esm/contrib/highlight.js.map +1 -0
  98. data/vendor/assets/javascripts/tom-select-rails/esm/contrib/microevent.d.ts +20 -0
  99. data/vendor/assets/javascripts/tom-select-rails/esm/contrib/microevent.js +61 -0
  100. data/vendor/assets/javascripts/tom-select-rails/esm/contrib/microevent.js.map +1 -0
  101. data/vendor/assets/javascripts/tom-select-rails/esm/contrib/microplugin.d.ts +71 -0
  102. data/vendor/assets/javascripts/tom-select-rails/esm/contrib/microplugin.js +109 -0
  103. data/vendor/assets/javascripts/tom-select-rails/esm/contrib/microplugin.js.map +1 -0
  104. data/vendor/assets/javascripts/tom-select-rails/esm/defaults.d.ts +52 -0
  105. data/vendor/assets/javascripts/tom-select-rails/esm/defaults.js +82 -0
  106. data/vendor/assets/javascripts/tom-select-rails/esm/defaults.js.map +1 -0
  107. data/vendor/assets/javascripts/tom-select-rails/esm/getSettings.d.ts +3 -0
  108. data/vendor/assets/javascripts/tom-select-rails/esm/getSettings.js +143 -0
  109. data/vendor/assets/javascripts/tom-select-rails/esm/getSettings.js.map +1 -0
  110. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/caret_position/plugin.d.ts +16 -0
  111. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/caret_position/plugin.js +16 -63
  112. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/caret_position/plugin.js.map +1 -1
  113. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/change_listener/plugin.d.ts +16 -0
  114. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/change_listener/plugin.js +1 -1
  115. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/change_listener/plugin.js.map +1 -1
  116. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/plugin.d.ts +17 -0
  117. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/plugin.js +1 -63
  118. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/plugin.js.map +1 -1
  119. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/types.d.ts +14 -0
  120. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/types.js +2 -0
  121. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/types.js.map +1 -0
  122. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/plugin.d.ts +17 -0
  123. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/plugin.js +4 -64
  124. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/plugin.js.map +1 -1
  125. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/types.d.ts +7 -0
  126. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/types.js +2 -0
  127. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/types.js.map +1 -0
  128. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/drag_drop/plugin.d.ts +16 -0
  129. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/drag_drop/plugin.js +1 -63
  130. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/drag_drop/plugin.js.map +1 -1
  131. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.d.ts +17 -0
  132. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.js +26 -88
  133. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.js.map +1 -1
  134. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/types.d.ts +8 -0
  135. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/types.js +2 -0
  136. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/types.js.map +1 -0
  137. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.d.ts +16 -0
  138. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.js +34 -96
  139. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.js.map +1 -1
  140. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.d.ts +15 -0
  141. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.js +1 -1
  142. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.js.map +1 -1
  143. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_active_items/plugin.d.ts +15 -0
  144. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_active_items/plugin.js +1 -1
  145. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_active_items/plugin.js.map +1 -1
  146. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_backspace_delete/plugin.d.ts +15 -0
  147. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_backspace_delete/plugin.js +1 -1
  148. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_backspace_delete/plugin.js.map +1 -1
  149. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.d.ts +16 -0
  150. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.js +1 -66
  151. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.js.map +1 -1
  152. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.d.ts +17 -0
  153. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.js +28 -90
  154. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.js.map +1 -1
  155. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/types.d.ts +6 -0
  156. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/types.js +2 -0
  157. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/types.js.map +1 -0
  158. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/restore_on_backspace/plugin.d.ts +21 -0
  159. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/restore_on_backspace/plugin.js +1 -1
  160. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/restore_on_backspace/plugin.js.map +1 -1
  161. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.d.ts +16 -0
  162. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.js +16 -63
  163. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.js.map +1 -1
  164. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.complete.d.ts +2 -0
  165. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.complete.js +17 -5275
  166. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.complete.js.map +1 -1
  167. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.d.ts +594 -0
  168. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.js +2123 -4251
  169. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.js.map +1 -1
  170. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.popular.d.ts +2 -0
  171. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.popular.js +8 -4658
  172. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.popular.js.map +1 -1
  173. data/vendor/assets/javascripts/tom-select-rails/esm/types/core.d.ts +49 -0
  174. data/vendor/assets/javascripts/tom-select-rails/esm/types/core.js +2 -0
  175. data/vendor/assets/javascripts/tom-select-rails/esm/types/core.js.map +1 -0
  176. data/vendor/assets/javascripts/tom-select-rails/esm/types/index.d.ts +2 -0
  177. data/vendor/assets/javascripts/tom-select-rails/esm/types/index.js +3 -0
  178. data/vendor/assets/javascripts/tom-select-rails/esm/types/index.js.map +1 -0
  179. data/vendor/assets/javascripts/tom-select-rails/esm/types/settings.d.ts +79 -0
  180. data/vendor/assets/javascripts/tom-select-rails/esm/types/settings.js +2 -0
  181. data/vendor/assets/javascripts/tom-select-rails/esm/types/settings.js.map +1 -0
  182. data/vendor/assets/javascripts/tom-select-rails/esm/utils.d.ts +95 -0
  183. data/vendor/assets/javascripts/tom-select-rails/esm/utils.js +116 -107
  184. data/vendor/assets/javascripts/tom-select-rails/esm/utils.js.map +1 -1
  185. data/vendor/assets/javascripts/tom-select-rails/esm/vanilla.d.ts +76 -0
  186. data/vendor/assets/javascripts/tom-select-rails/esm/vanilla.js +172 -0
  187. data/vendor/assets/javascripts/tom-select-rails/esm/vanilla.js.map +1 -0
  188. data/vendor/assets/javascripts/tom-select-rails/js/package.json +1 -0
  189. data/vendor/assets/javascripts/tom-select-rails/js/plugins/caret_position.js +161 -208
  190. data/vendor/assets/javascripts/tom-select-rails/js/plugins/caret_position.js.map +1 -1
  191. data/vendor/assets/javascripts/tom-select-rails/js/plugins/change_listener.js +1 -1
  192. data/vendor/assets/javascripts/tom-select-rails/js/plugins/change_listener.js.map +1 -1
  193. data/vendor/assets/javascripts/tom-select-rails/js/plugins/checkbox_options.js +1 -63
  194. data/vendor/assets/javascripts/tom-select-rails/js/plugins/checkbox_options.js.map +1 -1
  195. data/vendor/assets/javascripts/tom-select-rails/js/plugins/clear_button.js +70 -130
  196. data/vendor/assets/javascripts/tom-select-rails/js/plugins/clear_button.js.map +1 -1
  197. data/vendor/assets/javascripts/tom-select-rails/js/plugins/drag_drop.js +1 -63
  198. data/vendor/assets/javascripts/tom-select-rails/js/plugins/drag_drop.js.map +1 -1
  199. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_header.js +95 -157
  200. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_header.js.map +1 -1
  201. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_input.js +212 -274
  202. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_input.js.map +1 -1
  203. data/vendor/assets/javascripts/tom-select-rails/js/plugins/input_autogrow.js +1 -1
  204. data/vendor/assets/javascripts/tom-select-rails/js/plugins/input_autogrow.js.map +1 -1
  205. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_active_items.js +1 -1
  206. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_active_items.js.map +1 -1
  207. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_backspace_delete.js +1 -1
  208. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_backspace_delete.js.map +1 -1
  209. data/vendor/assets/javascripts/tom-select-rails/js/plugins/optgroup_columns.js +79 -144
  210. data/vendor/assets/javascripts/tom-select-rails/js/plugins/optgroup_columns.js.map +1 -1
  211. data/vendor/assets/javascripts/tom-select-rails/js/plugins/remove_button.js +132 -194
  212. data/vendor/assets/javascripts/tom-select-rails/js/plugins/remove_button.js.map +1 -1
  213. data/vendor/assets/javascripts/tom-select-rails/js/plugins/restore_on_backspace.js +1 -1
  214. data/vendor/assets/javascripts/tom-select-rails/js/plugins/restore_on_backspace.js.map +1 -1
  215. data/vendor/assets/javascripts/tom-select-rails/js/plugins/virtual_scroll.js +248 -295
  216. data/vendor/assets/javascripts/tom-select-rails/js/plugins/virtual_scroll.js.map +1 -1
  217. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.js +835 -1106
  218. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.js.map +1 -1
  219. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.min.js +176 -173
  220. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.min.js.map +1 -1
  221. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.js +838 -1107
  222. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.js.map +1 -1
  223. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.min.js +357 -354
  224. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.min.js.map +1 -1
  225. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.js +835 -1106
  226. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.js.map +1 -1
  227. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.min.js +336 -333
  228. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.min.js.map +1 -1
  229. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.css +16 -13
  230. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.css.map +1 -1
  231. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.min.css +1 -1
  232. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.min.css.map +1 -1
  233. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.css +15 -12
  234. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.css.map +1 -1
  235. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.min.css +1 -1
  236. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.min.css.map +1 -1
  237. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.css +11 -10
  238. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.css.map +1 -1
  239. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.css +7 -6
  240. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.css.map +1 -1
  241. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.min.css +1 -1
  242. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.min.css.map +1 -1
  243. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.min.css +1 -1
  244. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.min.css.map +1 -1
  245. data/vendor/assets/stylesheets/tom-select-rails/scss/_items.scss +6 -4
  246. data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.default.scss +1 -1
  247. data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.scss +6 -6
  248. metadata +153 -39
  249. data/vendor/assets/javascripts/tom-select-rails/types/tom-select.complete.d.ts +0 -2
  250. data/vendor/assets/javascripts/tom-select-rails/types/tom-select.popular.d.ts +0 -2
  251. data/vendor/assets/javascripts/tom-select-rails/types/types/index.d.ts +0 -2
  252. /data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/constants.d.ts +0 -0
  253. /data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/contrib/highlight.d.ts +0 -0
  254. /data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/contrib/microevent.d.ts +0 -0
  255. /data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/contrib/microplugin.d.ts +0 -0
  256. /data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/defaults.d.ts +0 -0
  257. /data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/plugins/checkbox_options/types.d.ts +0 -0
  258. /data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/plugins/dropdown_header/types.d.ts +0 -0
  259. /data/vendor/assets/javascripts/tom-select-rails/{types → cjs}/plugins/remove_button/types.d.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.3.1
2
+ * Tom Select v2.4.5
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
@@ -30,7 +30,6 @@
30
30
  }
31
31
  class MicroEvent {
32
32
  constructor() {
33
- this._events = void 0;
34
33
  this._events = {};
35
34
  }
36
35
  on(events, fct) {
@@ -179,390 +178,271 @@
179
178
  };
180
179
  }
181
180
 
182
- /*! @orchidjs/unicode-variants | https://github.com/orchidjs/unicode-variants | Apache License (v2) */
183
181
  /**
184
182
  * Convert array of strings to a regular expression
185
183
  * ex ['ab','a'] => (?:ab|a)
186
184
  * ex ['a','b'] => [ab]
187
- * @param {string[]} chars
188
- * @return {string}
189
185
  */
190
- const arrayToPattern = chars => {
191
- chars = chars.filter(Boolean);
192
-
193
- if (chars.length < 2) {
194
- return chars[0] || '';
195
- }
196
-
197
- return maxValueLength(chars) == 1 ? '[' + chars.join('') + ']' : '(?:' + chars.join('|') + ')';
198
- };
199
- /**
200
- * @param {string[]} array
201
- * @return {string}
202
- */
203
-
204
- const sequencePattern = array => {
205
- if (!hasDuplicates(array)) {
206
- return array.join('');
207
- }
208
-
209
- let pattern = '';
210
- let prev_char_count = 0;
211
-
212
- const prev_pattern = () => {
213
- if (prev_char_count > 1) {
214
- pattern += '{' + prev_char_count + '}';
215
- }
216
- };
217
-
218
- array.forEach((char, i) => {
219
- if (char === array[i - 1]) {
220
- prev_char_count++;
221
- return;
186
+ const arrayToPattern = (chars) => {
187
+ chars = chars.filter(Boolean);
188
+ if (chars.length < 2) {
189
+ return chars[0] || '';
222
190
  }
223
-
191
+ return (maxValueLength(chars) == 1) ? '[' + chars.join('') + ']' : '(?:' + chars.join('|') + ')';
192
+ };
193
+ const sequencePattern = (array) => {
194
+ if (!hasDuplicates(array)) {
195
+ return array.join('');
196
+ }
197
+ let pattern = '';
198
+ let prev_char_count = 0;
199
+ const prev_pattern = () => {
200
+ if (prev_char_count > 1) {
201
+ pattern += '{' + prev_char_count + '}';
202
+ }
203
+ };
204
+ array.forEach((char, i) => {
205
+ if (char === array[i - 1]) {
206
+ prev_char_count++;
207
+ return;
208
+ }
209
+ prev_pattern();
210
+ pattern += char;
211
+ prev_char_count = 1;
212
+ });
224
213
  prev_pattern();
225
- pattern += char;
226
- prev_char_count = 1;
227
- });
228
- prev_pattern();
229
- return pattern;
214
+ return pattern;
230
215
  };
231
216
  /**
232
217
  * Convert array of strings to a regular expression
233
218
  * ex ['ab','a'] => (?:ab|a)
234
219
  * ex ['a','b'] => [ab]
235
- * @param {Set<string>} chars
236
- * @return {string}
237
220
  */
238
-
239
- const setToPattern = chars => {
240
- let array = toArray(chars);
241
- return arrayToPattern(array);
221
+ const setToPattern = (chars) => {
222
+ let array = Array.from(chars);
223
+ return arrayToPattern(array);
242
224
  };
243
225
  /**
244
- *
245
226
  * https://stackoverflow.com/questions/7376598/in-javascript-how-do-i-check-if-an-array-has-duplicate-values
246
- * @param {any[]} array
247
227
  */
248
-
249
- const hasDuplicates = array => {
250
- return new Set(array).size !== array.length;
228
+ const hasDuplicates = (array) => {
229
+ return (new Set(array)).size !== array.length;
251
230
  };
252
231
  /**
253
232
  * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error
254
- * @param {string} str
255
- * @return {string}
256
233
  */
257
-
258
- const escape_regex = str => {
259
- return (str + '').replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, '\\$1');
234
+ const escape_regex = (str) => {
235
+ return (str + '').replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, '\\$1');
260
236
  };
261
237
  /**
262
238
  * Return the max length of array values
263
- * @param {string[]} array
264
- *
265
239
  */
266
-
267
- const maxValueLength = array => {
268
- return array.reduce((longest, value) => Math.max(longest, unicodeLength(value)), 0);
240
+ const maxValueLength = (array) => {
241
+ return array.reduce((longest, value) => Math.max(longest, unicodeLength(value)), 0);
269
242
  };
270
- /**
271
- * @param {string} str
272
- */
273
-
274
- const unicodeLength = str => {
275
- return toArray(str).length;
243
+ const unicodeLength = (str) => {
244
+ return Array.from(str).length;
276
245
  };
277
- /**
278
- * @param {any} p
279
- * @return {any[]}
280
- */
281
246
 
282
- const toArray = p => Array.from(p);
283
-
284
- /*! @orchidjs/unicode-variants | https://github.com/orchidjs/unicode-variants | Apache License (v2) */
285
247
  /**
286
248
  * Get all possible combinations of substrings that add up to the given string
287
249
  * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string
288
- * @param {string} input
289
- * @return {string[][]}
290
250
  */
291
- const allSubstrings = input => {
292
- if (input.length === 1) return [[input]];
293
- /** @type {string[][]} */
294
-
295
- let result = [];
296
- const start = input.substring(1);
297
- const suba = allSubstrings(start);
298
- suba.forEach(function (subresult) {
299
- let tmp = subresult.slice(0);
300
- tmp[0] = input.charAt(0) + tmp[0];
301
- result.push(tmp);
302
- tmp = subresult.slice(0);
303
- tmp.unshift(input.charAt(0));
304
- result.push(tmp);
305
- });
306
- return result;
251
+ const allSubstrings = (input) => {
252
+ if (input.length === 1)
253
+ return [[input]];
254
+ let result = [];
255
+ const start = input.substring(1);
256
+ const suba = allSubstrings(start);
257
+ suba.forEach(function (subresult) {
258
+ let tmp = subresult.slice(0);
259
+ tmp[0] = input.charAt(0) + tmp[0];
260
+ result.push(tmp);
261
+ tmp = subresult.slice(0);
262
+ tmp.unshift(input.charAt(0));
263
+ result.push(tmp);
264
+ });
265
+ return result;
307
266
  };
308
267
 
309
- /*! @orchidjs/unicode-variants | https://github.com/orchidjs/unicode-variants | Apache License (v2) */
310
-
311
- /**
312
- * @typedef {{[key:string]:string}} TUnicodeMap
313
- * @typedef {{[key:string]:Set<string>}} TUnicodeSets
314
- * @typedef {[[number,number]]} TCodePoints
315
- * @typedef {{folded:string,composed:string,code_point:number}} TCodePointObj
316
- * @typedef {{start:number,end:number,length:number,substr:string}} TSequencePart
317
- */
318
- /** @type {TCodePoints} */
319
-
320
268
  const code_points = [[0, 65535]];
321
269
  const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}\u{2bc}]';
322
- /** @type {TUnicodeMap} */
323
-
324
270
  let unicode_map;
325
- /** @type {RegExp} */
326
-
327
271
  let multi_char_reg;
328
272
  const max_char_length = 3;
329
- /** @type {TUnicodeMap} */
330
-
331
273
  const latin_convert = {};
332
- /** @type {TUnicodeMap} */
333
-
334
274
  const latin_condensed = {
335
- '/': '⁄∕',
336
- '0': '߀',
337
- "a": "ⱥɐɑ",
338
- "aa": "ꜳ",
339
- "ae": "æǽǣ",
340
- "ao": "ꜵ",
341
- "au": "ꜷ",
342
- "av": "ꜹꜻ",
343
- "ay": "ꜽ",
344
- "b": "ƀɓƃ",
345
- "c": "ꜿƈȼↄ",
346
- "d": "đɗɖᴅƌꮷԁɦ",
347
- "e": "ɛǝᴇɇ",
348
- "f": "ꝼƒ",
349
- "g": "ǥɠꞡᵹꝿɢ",
350
- "h": "ħⱨⱶɥ",
351
- "i": "ɨı",
352
- "j": "ɉȷ",
353
- "k": "ƙⱪꝁꝃꝅꞣ",
354
- "l": "łƚɫⱡꝉꝇꞁɭ",
355
- "m": "ɱɯϻ",
356
- "n": "ꞥƞɲꞑᴎлԉ",
357
- "o": "øǿɔɵꝋꝍᴑ",
358
- "oe": "œ",
359
- "oi": "ƣ",
360
- "oo": "ꝏ",
361
- "ou": "ȣ",
362
- "p": "ƥᵽꝑꝓꝕρ",
363
- "q": "ꝗꝙɋ",
364
- "r": "ɍɽꝛꞧꞃ",
365
- "s": "ßȿꞩꞅʂ",
366
- "t": "ŧƭʈⱦꞇ",
367
- "th": "þ",
368
- "tz": "ꜩ",
369
- "u": "ʉ",
370
- "v": "ʋꝟʌ",
371
- "vy": "ꝡ",
372
- "w": "ⱳ",
373
- "y": "ƴɏỿ",
374
- "z": "ƶȥɀⱬꝣ",
375
- "hv": "ƕ"
275
+ '/': '⁄∕',
276
+ '0': '߀',
277
+ "a": "ⱥɐɑ",
278
+ "aa": "ꜳ",
279
+ "ae": "æǽǣ",
280
+ "ao": "ꜵ",
281
+ "au": "ꜷ",
282
+ "av": "ꜹꜻ",
283
+ "ay": "ꜽ",
284
+ "b": "ƀɓƃ",
285
+ "c": "ꜿƈȼↄ",
286
+ "d": "đɗɖᴅƌꮷԁɦ",
287
+ "e": "ɛǝᴇɇ",
288
+ "f": "ꝼƒ",
289
+ "g": "ǥɠꞡᵹꝿɢ",
290
+ "h": "ħⱨⱶɥ",
291
+ "i": "ɨı",
292
+ "j": "ɉȷ",
293
+ "k": "ƙⱪꝁꝃꝅꞣ",
294
+ "l": "łƚɫⱡꝉꝇꞁɭ",
295
+ "m": "ɱɯϻ",
296
+ "n": "ꞥƞɲꞑᴎлԉ",
297
+ "o": "øǿɔɵꝋꝍᴑ",
298
+ "oe": "œ",
299
+ "oi": "ƣ",
300
+ "oo": "ꝏ",
301
+ "ou": "ȣ",
302
+ "p": "ƥᵽꝑꝓꝕρ",
303
+ "q": "ꝗꝙɋ",
304
+ "r": "ɍɽꝛꞧꞃ",
305
+ "s": "ßȿꞩꞅʂ",
306
+ "t": "ŧƭʈⱦꞇ",
307
+ "th": "þ",
308
+ "tz": "ꜩ",
309
+ "u": "ʉ",
310
+ "v": "ʋꝟʌ",
311
+ "vy": "ꝡ",
312
+ "w": "ⱳ",
313
+ "y": "ƴɏỿ",
314
+ "z": "ƶȥɀⱬꝣ",
315
+ "hv": "ƕ"
376
316
  };
377
-
378
317
  for (let latin in latin_condensed) {
379
- let unicode = latin_condensed[latin] || '';
380
-
381
- for (let i = 0; i < unicode.length; i++) {
382
- let char = unicode.substring(i, i + 1);
383
- latin_convert[char] = latin;
384
- }
318
+ let unicode = latin_condensed[latin] || '';
319
+ for (let i = 0; i < unicode.length; i++) {
320
+ let char = unicode.substring(i, i + 1);
321
+ latin_convert[char] = latin;
322
+ }
385
323
  }
386
-
387
324
  const convert_pat = new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');
388
325
  /**
389
326
  * Initialize the unicode_map from the give code point ranges
390
- *
391
- * @param {TCodePoints=} _code_points
392
327
  */
393
-
394
- const initialize = _code_points => {
395
- if (unicode_map !== undefined) return;
396
- unicode_map = generateMap(_code_points || code_points);
328
+ const initialize = (_code_points) => {
329
+ if (unicode_map !== undefined)
330
+ return;
331
+ unicode_map = generateMap(code_points);
397
332
  };
398
333
  /**
399
334
  * Helper method for normalize a string
400
335
  * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
401
- * @param {string} str
402
- * @param {string} form
403
336
  */
404
-
405
337
  const normalize = (str, form = 'NFKD') => str.normalize(form);
406
338
  /**
407
339
  * Remove accents without reordering string
408
340
  * calling str.normalize('NFKD') on \u{594}\u{595}\u{596} becomes \u{596}\u{594}\u{595}
409
341
  * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703
410
- * @param {string} str
411
- * @return {string}
412
342
  */
413
-
414
- const asciifold = str => {
415
- return toArray(str).reduce(
416
- /**
417
- * @param {string} result
418
- * @param {string} char
419
- */
420
- (result, char) => {
421
- return result + _asciifold(char);
422
- }, '');
343
+ const asciifold = (str) => {
344
+ return Array.from(str).reduce(
345
+ /**
346
+ * @param {string} result
347
+ * @param {string} char
348
+ */
349
+ (result, char) => {
350
+ return result + _asciifold(char);
351
+ }, '');
423
352
  };
424
- /**
425
- * @param {string} str
426
- * @return {string}
427
- */
428
-
429
- const _asciifold = str => {
430
- str = normalize(str).toLowerCase().replace(convert_pat, (
431
- /** @type {string} */
432
- char) => {
433
- return latin_convert[char] || '';
434
- }); //return str;
435
-
436
- return normalize(str, 'NFC');
353
+ const _asciifold = (str) => {
354
+ str = normalize(str)
355
+ .toLowerCase()
356
+ .replace(convert_pat, (/** @type {string} */ char) => {
357
+ return latin_convert[char] || '';
358
+ });
359
+ //return str;
360
+ return normalize(str, 'NFC');
437
361
  };
438
362
  /**
439
363
  * Generate a list of unicode variants from the list of code points
440
- * @param {TCodePoints} code_points
441
- * @yield {TCodePointObj}
442
364
  */
443
-
444
365
  function* generator(code_points) {
445
- for (const [code_point_min, code_point_max] of code_points) {
446
- for (let i = code_point_min; i <= code_point_max; i++) {
447
- let composed = String.fromCharCode(i);
448
- let folded = asciifold(composed);
449
-
450
- if (folded == composed.toLowerCase()) {
451
- continue;
452
- } // skip when folded is a string longer than 3 characters long
453
- // bc the resulting regex patterns will be long
454
- // eg:
455
- // folded صلى الله عليه وسلم length 18 code point 65018
456
- // folded جل جلاله length 8 code point 65019
457
-
458
-
459
- if (folded.length > max_char_length) {
460
- continue;
461
- }
462
-
463
- if (folded.length == 0) {
464
- continue;
465
- }
466
-
467
- yield {
468
- folded: folded,
469
- composed: composed,
470
- code_point: i
471
- };
366
+ for (const [code_point_min, code_point_max] of code_points) {
367
+ for (let i = code_point_min; i <= code_point_max; i++) {
368
+ let composed = String.fromCharCode(i);
369
+ let folded = asciifold(composed);
370
+ if (folded == composed.toLowerCase()) {
371
+ continue;
372
+ }
373
+ // skip when folded is a string longer than 3 characters long
374
+ // bc the resulting regex patterns will be long
375
+ // eg:
376
+ // folded صلى الله عليه وسلم length 18 code point 65018
377
+ // folded جل جلاله length 8 code point 65019
378
+ if (folded.length > max_char_length) {
379
+ continue;
380
+ }
381
+ if (folded.length == 0) {
382
+ continue;
383
+ }
384
+ yield { folded: folded, composed: composed, code_point: i };
385
+ }
472
386
  }
473
- }
474
387
  }
475
388
  /**
476
389
  * Generate a unicode map from the list of code points
477
- * @param {TCodePoints} code_points
478
- * @return {TUnicodeSets}
479
390
  */
480
-
481
- const generateSets = code_points => {
482
- /** @type {{[key:string]:Set<string>}} */
483
- const unicode_sets = {};
484
- /**
485
- * @param {string} folded
486
- * @param {string} to_add
487
- */
488
-
489
- const addMatching = (folded, to_add) => {
490
- /** @type {Set<string>} */
491
- const folded_set = unicode_sets[folded] || new Set();
492
- const patt = new RegExp('^' + setToPattern(folded_set) + '$', 'iu');
493
-
494
- if (to_add.match(patt)) {
495
- return;
391
+ const generateSets = (code_points) => {
392
+ const unicode_sets = {};
393
+ const addMatching = (folded, to_add) => {
394
+ /** @type {Set<string>} */
395
+ const folded_set = unicode_sets[folded] || new Set();
396
+ const patt = new RegExp('^' + setToPattern(folded_set) + '$', 'iu');
397
+ if (to_add.match(patt)) {
398
+ return;
399
+ }
400
+ folded_set.add(escape_regex(to_add));
401
+ unicode_sets[folded] = folded_set;
402
+ };
403
+ for (let value of generator(code_points)) {
404
+ addMatching(value.folded, value.folded);
405
+ addMatching(value.folded, value.composed);
496
406
  }
497
-
498
- folded_set.add(escape_regex(to_add));
499
- unicode_sets[folded] = folded_set;
500
- };
501
-
502
- for (let value of generator(code_points)) {
503
- addMatching(value.folded, value.folded);
504
- addMatching(value.folded, value.composed);
505
- }
506
-
507
- return unicode_sets;
407
+ return unicode_sets;
508
408
  };
509
409
  /**
510
410
  * Generate a unicode map from the list of code points
511
411
  * ae => (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))
512
- *
513
- * @param {TCodePoints} code_points
514
- * @return {TUnicodeMap}
515
412
  */
516
-
517
- const generateMap = code_points => {
518
- /** @type {TUnicodeSets} */
519
- const unicode_sets = generateSets(code_points);
520
- /** @type {TUnicodeMap} */
521
-
522
- const unicode_map = {};
523
- /** @type {string[]} */
524
-
525
- let multi_char = [];
526
-
527
- for (let folded in unicode_sets) {
528
- let set = unicode_sets[folded];
529
-
530
- if (set) {
531
- unicode_map[folded] = setToPattern(set);
532
- }
533
-
534
- if (folded.length > 1) {
535
- multi_char.push(escape_regex(folded));
413
+ const generateMap = (code_points) => {
414
+ const unicode_sets = generateSets(code_points);
415
+ const unicode_map = {};
416
+ let multi_char = [];
417
+ for (let folded in unicode_sets) {
418
+ let set = unicode_sets[folded];
419
+ if (set) {
420
+ unicode_map[folded] = setToPattern(set);
421
+ }
422
+ if (folded.length > 1) {
423
+ multi_char.push(escape_regex(folded));
424
+ }
536
425
  }
537
- }
538
-
539
- multi_char.sort((a, b) => b.length - a.length);
540
- const multi_char_patt = arrayToPattern(multi_char);
541
- multi_char_reg = new RegExp('^' + multi_char_patt, 'u');
542
- return unicode_map;
426
+ multi_char.sort((a, b) => b.length - a.length);
427
+ const multi_char_patt = arrayToPattern(multi_char);
428
+ multi_char_reg = new RegExp('^' + multi_char_patt, 'u');
429
+ return unicode_map;
543
430
  };
544
431
  /**
545
- * Map each element of an array from it's folded value to all possible unicode matches
546
- * @param {string[]} strings
547
- * @param {number} min_replacement
548
- * @return {string}
432
+ * Map each element of an array from its folded value to all possible unicode matches
549
433
  */
550
-
551
434
  const mapSequence = (strings, min_replacement = 1) => {
552
- let chars_replaced = 0;
553
- strings = strings.map(str => {
554
- if (unicode_map[str]) {
555
- chars_replaced += str.length;
435
+ let chars_replaced = 0;
436
+ strings = strings.map((str) => {
437
+ if (unicode_map[str]) {
438
+ chars_replaced += str.length;
439
+ }
440
+ return unicode_map[str] || str;
441
+ });
442
+ if (chars_replaced >= min_replacement) {
443
+ return sequencePattern(strings);
556
444
  }
557
-
558
- return unicode_map[str] || str;
559
- });
560
-
561
- if (chars_replaced >= min_replacement) {
562
- return sequencePattern(strings);
563
- }
564
-
565
- return '';
445
+ return '';
566
446
  };
567
447
  /**
568
448
  * Convert a short string and split it into all possible patterns
@@ -571,158 +451,107 @@
571
451
  * 'abc'
572
452
  * => [['abc'],['ab','c'],['a','bc'],['a','b','c']]
573
453
  * => ['abc-pattern','ab-c-pattern'...]
574
- *
575
- *
576
- * @param {string} str
577
- * @param {number} min_replacement
578
- * @return {string}
579
454
  */
580
-
581
455
  const substringsToPattern = (str, min_replacement = 1) => {
582
- min_replacement = Math.max(min_replacement, str.length - 1);
583
- return arrayToPattern(allSubstrings(str).map(sub_pat => {
584
- return mapSequence(sub_pat, min_replacement);
585
- }));
456
+ min_replacement = Math.max(min_replacement, str.length - 1);
457
+ return arrayToPattern(allSubstrings(str).map((sub_pat) => {
458
+ return mapSequence(sub_pat, min_replacement);
459
+ }));
586
460
  };
587
461
  /**
588
462
  * Convert an array of sequences into a pattern
589
463
  * [{start:0,end:3,length:3,substr:'iii'}...] => (?:iii...)
590
- *
591
- * @param {Sequence[]} sequences
592
- * @param {boolean} all
593
464
  */
594
-
595
465
  const sequencesToPattern = (sequences, all = true) => {
596
- let min_replacement = sequences.length > 1 ? 1 : 0;
597
- return arrayToPattern(sequences.map(sequence => {
598
- let seq = [];
599
- const len = all ? sequence.length() : sequence.length() - 1;
600
-
601
- for (let j = 0; j < len; j++) {
602
- seq.push(substringsToPattern(sequence.substrs[j] || '', min_replacement));
603
- }
604
-
605
- return sequencePattern(seq);
606
- }));
466
+ let min_replacement = sequences.length > 1 ? 1 : 0;
467
+ return arrayToPattern(sequences.map((sequence) => {
468
+ let seq = [];
469
+ const len = all ? sequence.length() : sequence.length() - 1;
470
+ for (let j = 0; j < len; j++) {
471
+ seq.push(substringsToPattern(sequence.substrs[j] || '', min_replacement));
472
+ }
473
+ return sequencePattern(seq);
474
+ }));
607
475
  };
608
476
  /**
609
477
  * Return true if the sequence is already in the sequences
610
- * @param {Sequence} needle_seq
611
- * @param {Sequence[]} sequences
612
478
  */
613
-
614
-
615
479
  const inSequences = (needle_seq, sequences) => {
616
- for (const seq of sequences) {
617
- if (seq.start != needle_seq.start || seq.end != needle_seq.end) {
618
- continue;
619
- }
620
-
621
- if (seq.substrs.join('') !== needle_seq.substrs.join('')) {
622
- continue;
623
- }
624
-
625
- let needle_parts = needle_seq.parts;
626
- /**
627
- * @param {TSequencePart} part
628
- */
629
-
630
- const filter = part => {
631
- for (const needle_part of needle_parts) {
632
- if (needle_part.start === part.start && needle_part.substr === part.substr) {
633
- return false;
480
+ for (const seq of sequences) {
481
+ if (seq.start != needle_seq.start || seq.end != needle_seq.end) {
482
+ continue;
634
483
  }
635
-
636
- if (part.length == 1 || needle_part.length == 1) {
637
- continue;
638
- } // check for overlapping parts
639
- // a = ['::=','==']
640
- // b = ['::','===']
641
- // a = ['r','sm']
642
- // b = ['rs','m']
643
-
644
-
645
- if (part.start < needle_part.start && part.end > needle_part.start) {
646
- return true;
484
+ if (seq.substrs.join('') !== needle_seq.substrs.join('')) {
485
+ continue;
647
486
  }
648
-
649
- if (needle_part.start < part.start && needle_part.end > part.start) {
650
- return true;
487
+ let needle_parts = needle_seq.parts;
488
+ const filter = (part) => {
489
+ for (const needle_part of needle_parts) {
490
+ if (needle_part.start === part.start && needle_part.substr === part.substr) {
491
+ return false;
492
+ }
493
+ if (part.length == 1 || needle_part.length == 1) {
494
+ continue;
495
+ }
496
+ // check for overlapping parts
497
+ // a = ['::=','==']
498
+ // b = ['::','===']
499
+ // a = ['r','sm']
500
+ // b = ['rs','m']
501
+ if (part.start < needle_part.start && part.end > needle_part.start) {
502
+ return true;
503
+ }
504
+ if (needle_part.start < part.start && needle_part.end > part.start) {
505
+ return true;
506
+ }
507
+ }
508
+ return false;
509
+ };
510
+ let filtered = seq.parts.filter(filter);
511
+ if (filtered.length > 0) {
512
+ continue;
651
513
  }
652
- }
653
-
654
- return false;
655
- };
656
-
657
- let filtered = seq.parts.filter(filter);
658
-
659
- if (filtered.length > 0) {
660
- continue;
514
+ return true;
661
515
  }
662
-
663
- return true;
664
- }
665
-
666
- return false;
516
+ return false;
667
517
  };
668
-
669
518
  class Sequence {
670
- constructor() {
671
- /** @type {TSequencePart[]} */
672
- this.parts = [];
673
- /** @type {string[]} */
674
-
675
- this.substrs = [];
676
- this.start = 0;
677
- this.end = 0;
678
- }
679
- /**
680
- * @param {TSequencePart|undefined} part
681
- */
682
-
683
-
684
- add(part) {
685
- if (part) {
686
- this.parts.push(part);
687
- this.substrs.push(part.substr);
688
- this.start = Math.min(part.start, this.start);
689
- this.end = Math.max(part.end, this.end);
519
+ parts;
520
+ substrs;
521
+ start;
522
+ end;
523
+ constructor() {
524
+ this.parts = [];
525
+ this.substrs = [];
526
+ this.start = 0;
527
+ this.end = 0;
528
+ }
529
+ add(part) {
530
+ if (part) {
531
+ this.parts.push(part);
532
+ this.substrs.push(part.substr);
533
+ this.start = Math.min(part.start, this.start);
534
+ this.end = Math.max(part.end, this.end);
535
+ }
690
536
  }
691
- }
692
-
693
- last() {
694
- return this.parts[this.parts.length - 1];
695
- }
696
-
697
- length() {
698
- return this.parts.length;
699
- }
700
- /**
701
- * @param {number} position
702
- * @param {TSequencePart} last_piece
703
- */
704
-
705
-
706
- clone(position, last_piece) {
707
- let clone = new Sequence();
708
- let parts = JSON.parse(JSON.stringify(this.parts));
709
- let last_part = parts.pop();
710
-
711
- for (const part of parts) {
712
- clone.add(part);
537
+ last() {
538
+ return this.parts[this.parts.length - 1];
539
+ }
540
+ length() {
541
+ return this.parts.length;
542
+ }
543
+ clone(position, last_piece) {
544
+ let clone = new Sequence();
545
+ let parts = JSON.parse(JSON.stringify(this.parts));
546
+ let last_part = parts.pop();
547
+ for (const part of parts) {
548
+ clone.add(part);
549
+ }
550
+ let last_substr = last_piece.substr.substring(0, position - last_part.start);
551
+ let clone_last_len = last_substr.length;
552
+ clone.add({ start: last_part.start, end: last_part.start + clone_last_len, length: clone_last_len, substr: last_substr });
553
+ return clone;
713
554
  }
714
-
715
- let last_substr = last_piece.substr.substring(0, position - last_part.start);
716
- let clone_last_len = last_substr.length;
717
- clone.add({
718
- start: last_part.start,
719
- end: last_part.start + clone_last_len,
720
- length: clone_last_len,
721
- substr: last_substr
722
- });
723
- return clone;
724
- }
725
-
726
555
  }
727
556
  /**
728
557
  * Expand a regular expression pattern to include unicode variants
@@ -735,110 +564,80 @@
735
564
  * İIJ = IIJ = ⅡJ
736
565
  *
737
566
  * 1/2/4
738
- *
739
- * @param {string} str
740
- * @return {string|undefined}
741
567
  */
742
-
743
-
744
- const getPattern = str => {
745
- initialize();
746
- str = asciifold(str);
747
- let pattern = '';
748
- let sequences = [new Sequence()];
749
-
750
- for (let i = 0; i < str.length; i++) {
751
- let substr = str.substring(i);
752
- let match = substr.match(multi_char_reg);
753
- const char = str.substring(i, i + 1);
754
- const match_str = match ? match[0] : null; // loop through sequences
755
- // add either the char or multi_match
756
-
757
- let overlapping = [];
758
- let added_types = new Set();
759
-
760
- for (const sequence of sequences) {
761
- const last_piece = sequence.last();
762
-
763
- if (!last_piece || last_piece.length == 1 || last_piece.end <= i) {
764
- // if we have a multi match
765
- if (match_str) {
766
- const len = match_str.length;
767
- sequence.add({
768
- start: i,
769
- end: i + len,
770
- length: len,
771
- substr: match_str
772
- });
773
- added_types.add('1');
774
- } else {
775
- sequence.add({
776
- start: i,
777
- end: i + 1,
778
- length: 1,
779
- substr: char
780
- });
781
- added_types.add('2');
568
+ const getPattern = (str) => {
569
+ initialize();
570
+ str = asciifold(str);
571
+ let pattern = '';
572
+ let sequences = [new Sequence()];
573
+ for (let i = 0; i < str.length; i++) {
574
+ let substr = str.substring(i);
575
+ let match = substr.match(multi_char_reg);
576
+ const char = str.substring(i, i + 1);
577
+ const match_str = match ? match[0] : null;
578
+ // loop through sequences
579
+ // add either the char or multi_match
580
+ let overlapping = [];
581
+ let added_types = new Set();
582
+ for (const sequence of sequences) {
583
+ const last_piece = sequence.last();
584
+ if (!last_piece || last_piece.length == 1 || last_piece.end <= i) {
585
+ // if we have a multi match
586
+ if (match_str) {
587
+ const len = match_str.length;
588
+ sequence.add({ start: i, end: i + len, length: len, substr: match_str });
589
+ added_types.add('1');
590
+ }
591
+ else {
592
+ sequence.add({ start: i, end: i + 1, length: 1, substr: char });
593
+ added_types.add('2');
594
+ }
595
+ }
596
+ else if (match_str) {
597
+ let clone = sequence.clone(i, last_piece);
598
+ const len = match_str.length;
599
+ clone.add({ start: i, end: i + len, length: len, substr: match_str });
600
+ overlapping.push(clone);
601
+ }
602
+ else {
603
+ // don't add char
604
+ // adding would create invalid patterns: 234 => [2,34,4]
605
+ added_types.add('3');
606
+ }
782
607
  }
783
- } else if (match_str) {
784
- let clone = sequence.clone(i, last_piece);
785
- const len = match_str.length;
786
- clone.add({
787
- start: i,
788
- end: i + len,
789
- length: len,
790
- substr: match_str
791
- });
792
- overlapping.push(clone);
793
- } else {
794
- // don't add char
795
- // adding would create invalid patterns: 234 => [2,34,4]
796
- added_types.add('3');
797
- }
798
- } // if we have overlapping
799
-
800
-
801
- if (overlapping.length > 0) {
802
- // ['ii','iii'] before ['i','i','iii']
803
- overlapping = overlapping.sort((a, b) => {
804
- return a.length() - b.length();
805
- });
806
-
807
- for (let clone of overlapping) {
808
- // don't add if we already have an equivalent sequence
809
- if (inSequences(clone, sequences)) {
810
- continue;
608
+ // if we have overlapping
609
+ if (overlapping.length > 0) {
610
+ // ['ii','iii'] before ['i','i','iii']
611
+ overlapping = overlapping.sort((a, b) => {
612
+ return a.length() - b.length();
613
+ });
614
+ for (let clone of overlapping) {
615
+ // don't add if we already have an equivalent sequence
616
+ if (inSequences(clone, sequences)) {
617
+ continue;
618
+ }
619
+ sequences.push(clone);
620
+ }
621
+ continue;
622
+ }
623
+ // if we haven't done anything unique
624
+ // clean up the patterns
625
+ // helps keep patterns smaller
626
+ // if str = 'r₨㎧aarss', pattern will be 446 instead of 655
627
+ if (i > 0 && added_types.size == 1 && !added_types.has('3')) {
628
+ pattern += sequencesToPattern(sequences, false);
629
+ let new_seq = new Sequence();
630
+ const old_seq = sequences[0];
631
+ if (old_seq) {
632
+ new_seq.add(old_seq.last());
633
+ }
634
+ sequences = [new_seq];
811
635
  }
812
-
813
- sequences.push(clone);
814
- }
815
-
816
- continue;
817
- } // if we haven't done anything unique
818
- // clean up the patterns
819
- // helps keep patterns smaller
820
- // if str = 'r₨㎧aarss', pattern will be 446 instead of 655
821
-
822
-
823
- if (i > 0 && added_types.size == 1 && !added_types.has('3')) {
824
- pattern += sequencesToPattern(sequences, false);
825
- let new_seq = new Sequence();
826
- const old_seq = sequences[0];
827
-
828
- if (old_seq) {
829
- new_seq.add(old_seq.last());
830
- }
831
-
832
- sequences = [new_seq];
833
636
  }
834
- }
835
-
836
- pattern += sequencesToPattern(sequences, true);
837
- return pattern;
637
+ pattern += sequencesToPattern(sequences, true);
638
+ return pattern;
838
639
  };
839
640
 
840
- /*! sifter.js | https://github.com/orchidjs/sifter.js | Apache License (v2) */
841
-
842
641
  /**
843
642
  * A property getter resolving dot-notation
844
643
  * @param {Object} obj The root object to fetch property on
@@ -846,8 +645,9 @@
846
645
  * @return {Object} The resolved property value
847
646
  */
848
647
  const getAttr = (obj, name) => {
849
- if (!obj) return;
850
- return obj[name];
648
+ if (!obj)
649
+ return;
650
+ return obj[name];
851
651
  };
852
652
  /**
853
653
  * A property getter resolving dot-notation
@@ -855,45 +655,45 @@
855
655
  * @param {String} name The optionally dotted property name to fetch
856
656
  * @return {Object} The resolved property value
857
657
  */
858
-
859
658
  const getAttrNesting = (obj, name) => {
860
- if (!obj) return;
861
- var part,
862
- names = name.split(".");
863
-
864
- while ((part = names.shift()) && (obj = obj[part]));
865
-
866
- return obj;
659
+ if (!obj)
660
+ return;
661
+ var part, names = name.split(".");
662
+ while ((part = names.shift()) && (obj = obj[part]))
663
+ ;
664
+ return obj;
867
665
  };
868
666
  /**
869
667
  * Calculates how close of a match the
870
668
  * given value is against a search token.
871
669
  *
872
670
  */
873
-
874
671
  const scoreValue = (value, token, weight) => {
875
- var score, pos;
876
- if (!value) return 0;
877
- value = value + '';
878
- if (token.regex == null) return 0;
879
- pos = value.search(token.regex);
880
- if (pos === -1) return 0;
881
- score = token.string.length / value.length;
882
- if (pos === 0) score += 0.5;
883
- return score * weight;
672
+ var score, pos;
673
+ if (!value)
674
+ return 0;
675
+ value = value + '';
676
+ if (token.regex == null)
677
+ return 0;
678
+ pos = value.search(token.regex);
679
+ if (pos === -1)
680
+ return 0;
681
+ score = token.string.length / value.length;
682
+ if (pos === 0)
683
+ score += 0.5;
684
+ return score * weight;
884
685
  };
885
686
  /**
886
687
  * Cast object property to an array if it exists and has a value
887
688
  *
888
689
  */
889
-
890
690
  const propToArray = (obj, key) => {
891
- var value = obj[key];
892
- if (typeof value == 'function') return value;
893
-
894
- if (value && !Array.isArray(value)) {
895
- obj[key] = [value];
896
- }
691
+ var value = obj[key];
692
+ if (typeof value == 'function')
693
+ return value;
694
+ if (value && !Array.isArray(value)) {
695
+ obj[key] = [value];
696
+ }
897
697
  };
898
698
  /**
899
699
  * Iterates over arrays and hashes.
@@ -905,32 +705,31 @@
905
705
  * ```
906
706
  *
907
707
  */
908
-
909
708
  const iterate$1 = (object, callback) => {
910
- if (Array.isArray(object)) {
911
- object.forEach(callback);
912
- } else {
913
- for (var key in object) {
914
- if (object.hasOwnProperty(key)) {
915
- callback(object[key], key);
916
- }
709
+ if (Array.isArray(object)) {
710
+ object.forEach(callback);
711
+ }
712
+ else {
713
+ for (var key in object) {
714
+ if (object.hasOwnProperty(key)) {
715
+ callback(object[key], key);
716
+ }
717
+ }
917
718
  }
918
- }
919
719
  };
920
720
  const cmp = (a, b) => {
921
- if (typeof a === 'number' && typeof b === 'number') {
922
- return a > b ? 1 : a < b ? -1 : 0;
923
- }
924
-
925
- a = asciifold(a + '').toLowerCase();
926
- b = asciifold(b + '').toLowerCase();
927
- if (a > b) return 1;
928
- if (b > a) return -1;
929
- return 0;
721
+ if (typeof a === 'number' && typeof b === 'number') {
722
+ return a > b ? 1 : (a < b ? -1 : 0);
723
+ }
724
+ a = asciifold(a + '').toLowerCase();
725
+ b = asciifold(b + '').toLowerCase();
726
+ if (a > b)
727
+ return 1;
728
+ if (b > a)
729
+ return -1;
730
+ return 0;
930
731
  };
931
732
 
932
- /*! sifter.js | https://github.com/orchidjs/sifter.js | Apache License (v2) */
933
-
934
733
  /**
935
734
  * sifter.js
936
735
  * Copyright (c) 2013–2020 Brian Reavis & contributors
@@ -946,349 +745,469 @@
946
745
  *
947
746
  * @author Brian Reavis <brian@thirdroute.com>
948
747
  */
949
-
950
748
  class Sifter {
951
- // []|{};
952
-
953
- /**
954
- * Textually searches arrays and hashes of objects
955
- * by property (or multiple properties). Designed
956
- * specifically for autocomplete.
957
- *
958
- */
959
- constructor(items, settings) {
960
- this.items = void 0;
961
- this.settings = void 0;
962
- this.items = items;
963
- this.settings = settings || {
964
- diacritics: true
965
- };
966
- }
967
-
968
- /**
969
- * Splits a search string into an array of individual
970
- * regexps to be used to match results.
971
- *
972
- */
973
- tokenize(query, respect_word_boundaries, weights) {
974
- if (!query || !query.length) return [];
975
- const tokens = [];
976
- const words = query.split(/\s+/);
977
- var field_regex;
978
-
979
- if (weights) {
980
- field_regex = new RegExp('^(' + Object.keys(weights).map(escape_regex).join('|') + ')\:(.*)$');
749
+ items; // []|{};
750
+ settings;
751
+ /**
752
+ * Textually searches arrays and hashes of objects
753
+ * by property (or multiple properties). Designed
754
+ * specifically for autocomplete.
755
+ *
756
+ */
757
+ constructor(items, settings) {
758
+ this.items = items;
759
+ this.settings = settings || { diacritics: true };
981
760
  }
982
-
983
- words.forEach(word => {
984
- let field_match;
985
- let field = null;
986
- let regex = null; // look for "field:query" tokens
987
-
988
- if (field_regex && (field_match = word.match(field_regex))) {
989
- field = field_match[1];
990
- word = field_match[2];
991
- }
992
-
993
- if (word.length > 0) {
994
- if (this.settings.diacritics) {
995
- regex = getPattern(word) || null;
996
- } else {
997
- regex = escape_regex(word);
761
+ ;
762
+ /**
763
+ * Splits a search string into an array of individual
764
+ * regexps to be used to match results.
765
+ *
766
+ */
767
+ tokenize(query, respect_word_boundaries, weights) {
768
+ if (!query || !query.length)
769
+ return [];
770
+ const tokens = [];
771
+ const words = query.split(/\s+/);
772
+ var field_regex;
773
+ if (weights) {
774
+ field_regex = new RegExp('^(' + Object.keys(weights).map(escape_regex).join('|') + ')\:(.*)$');
998
775
  }
999
-
1000
- if (regex && respect_word_boundaries) regex = "\\b" + regex;
1001
- }
1002
-
1003
- tokens.push({
1004
- string: word,
1005
- regex: regex ? new RegExp(regex, 'iu') : null,
1006
- field: field
1007
- });
1008
- });
1009
- return tokens;
1010
- }
1011
-
1012
- /**
1013
- * Returns a function to be used to score individual results.
1014
- *
1015
- * Good matches will have a higher score than poor matches.
1016
- * If an item is not a match, 0 will be returned by the function.
1017
- *
1018
- * @returns {T.ScoreFn}
1019
- */
1020
- getScoreFunction(query, options) {
1021
- var search = this.prepareSearch(query, options);
1022
- return this._getScoreFunction(search);
1023
- }
1024
- /**
1025
- * @returns {T.ScoreFn}
1026
- *
1027
- */
1028
-
1029
-
1030
- _getScoreFunction(search) {
1031
- const tokens = search.tokens,
1032
- token_count = tokens.length;
1033
-
1034
- if (!token_count) {
1035
- return function () {
1036
- return 0;
1037
- };
776
+ words.forEach((word) => {
777
+ let field_match;
778
+ let field = null;
779
+ let regex = null;
780
+ // look for "field:query" tokens
781
+ if (field_regex && (field_match = word.match(field_regex))) {
782
+ field = field_match[1];
783
+ word = field_match[2];
784
+ }
785
+ if (word.length > 0) {
786
+ if (this.settings.diacritics) {
787
+ regex = getPattern(word) || null;
788
+ }
789
+ else {
790
+ regex = escape_regex(word);
791
+ }
792
+ if (regex && respect_word_boundaries)
793
+ regex = "\\b" + regex;
794
+ }
795
+ tokens.push({
796
+ string: word,
797
+ regex: regex ? new RegExp(regex, 'iu') : null,
798
+ field: field,
799
+ });
800
+ });
801
+ return tokens;
1038
802
  }
1039
-
1040
- const fields = search.options.fields,
1041
- weights = search.weights,
1042
- field_count = fields.length,
1043
- getAttrFn = search.getAttrFn;
1044
-
1045
- if (!field_count) {
1046
- return function () {
1047
- return 1;
1048
- };
803
+ ;
804
+ /**
805
+ * Returns a function to be used to score individual results.
806
+ *
807
+ * Good matches will have a higher score than poor matches.
808
+ * If an item is not a match, 0 will be returned by the function.
809
+ *
810
+ * @returns {T.ScoreFn}
811
+ */
812
+ getScoreFunction(query, options) {
813
+ var search = this.prepareSearch(query, options);
814
+ return this._getScoreFunction(search);
1049
815
  }
1050
816
  /**
1051
- * Calculates the score of an object
1052
- * against the search query.
817
+ * @returns {T.ScoreFn}
1053
818
  *
1054
819
  */
1055
-
1056
-
1057
- const scoreObject = function () {
1058
- if (field_count === 1) {
1059
- return function (token, data) {
1060
- const field = fields[0].field;
1061
- return scoreValue(getAttrFn(data, field), token, weights[field] || 1);
1062
- };
1063
- }
1064
-
1065
- return function (token, data) {
1066
- var sum = 0; // is the token specific to a field?
1067
-
1068
- if (token.field) {
1069
- const value = getAttrFn(data, token.field);
1070
-
1071
- if (!token.regex && value) {
1072
- sum += 1 / field_count;
1073
- } else {
1074
- sum += scoreValue(value, token, 1);
1075
- }
1076
- } else {
1077
- iterate$1(weights, (weight, field) => {
1078
- sum += scoreValue(getAttrFn(data, field), token, weight);
1079
- });
820
+ _getScoreFunction(search) {
821
+ const tokens = search.tokens, token_count = tokens.length;
822
+ if (!token_count) {
823
+ return function () { return 0; };
824
+ }
825
+ const fields = search.options.fields, weights = search.weights, field_count = fields.length, getAttrFn = search.getAttrFn;
826
+ if (!field_count) {
827
+ return function () { return 1; };
828
+ }
829
+ /**
830
+ * Calculates the score of an object
831
+ * against the search query.
832
+ *
833
+ */
834
+ const scoreObject = (function () {
835
+ if (field_count === 1) {
836
+ return function (token, data) {
837
+ const field = fields[0].field;
838
+ return scoreValue(getAttrFn(data, field), token, weights[field] || 1);
839
+ };
840
+ }
841
+ return function (token, data) {
842
+ var sum = 0;
843
+ // is the token specific to a field?
844
+ if (token.field) {
845
+ const value = getAttrFn(data, token.field);
846
+ if (!token.regex && value) {
847
+ sum += (1 / field_count);
848
+ }
849
+ else {
850
+ sum += scoreValue(value, token, 1);
851
+ }
852
+ }
853
+ else {
854
+ iterate$1(weights, (weight, field) => {
855
+ sum += scoreValue(getAttrFn(data, field), token, weight);
856
+ });
857
+ }
858
+ return sum / field_count;
859
+ };
860
+ })();
861
+ if (token_count === 1) {
862
+ return function (data) {
863
+ return scoreObject(tokens[0], data);
864
+ };
865
+ }
866
+ if (search.options.conjunction === 'and') {
867
+ return function (data) {
868
+ var score, sum = 0;
869
+ for (let token of tokens) {
870
+ score = scoreObject(token, data);
871
+ if (score <= 0)
872
+ return 0;
873
+ sum += score;
874
+ }
875
+ return sum / token_count;
876
+ };
877
+ }
878
+ else {
879
+ return function (data) {
880
+ var sum = 0;
881
+ iterate$1(tokens, (token) => {
882
+ sum += scoreObject(token, data);
883
+ });
884
+ return sum / token_count;
885
+ };
1080
886
  }
1081
-
1082
- return sum / field_count;
1083
- };
1084
- }();
1085
-
1086
- if (token_count === 1) {
1087
- return function (data) {
1088
- return scoreObject(tokens[0], data);
1089
- };
1090
887
  }
1091
-
1092
- if (search.options.conjunction === 'and') {
1093
- return function (data) {
1094
- var score,
1095
- sum = 0;
1096
-
1097
- for (let token of tokens) {
1098
- score = scoreObject(token, data);
1099
- if (score <= 0) return 0;
1100
- sum += score;
888
+ ;
889
+ /**
890
+ * Returns a function that can be used to compare two
891
+ * results, for sorting purposes. If no sorting should
892
+ * be performed, `null` will be returned.
893
+ *
894
+ * @return function(a,b)
895
+ */
896
+ getSortFunction(query, options) {
897
+ var search = this.prepareSearch(query, options);
898
+ return this._getSortFunction(search);
899
+ }
900
+ _getSortFunction(search) {
901
+ var implicit_score, sort_flds = [];
902
+ const self = this, options = search.options, sort = (!search.query && options.sort_empty) ? options.sort_empty : options.sort;
903
+ if (typeof sort == 'function') {
904
+ return sort.bind(this);
1101
905
  }
1102
-
1103
- return sum / token_count;
1104
- };
1105
- } else {
1106
- return function (data) {
1107
- var sum = 0;
1108
- iterate$1(tokens, token => {
1109
- sum += scoreObject(token, data);
1110
- });
1111
- return sum / token_count;
1112
- };
906
+ /**
907
+ * Fetches the specified sort field value
908
+ * from a search result item.
909
+ *
910
+ */
911
+ const get_field = function (name, result) {
912
+ if (name === '$score')
913
+ return result.score;
914
+ return search.getAttrFn(self.items[result.id], name);
915
+ };
916
+ // parse options
917
+ if (sort) {
918
+ for (let s of sort) {
919
+ if (search.query || s.field !== '$score') {
920
+ sort_flds.push(s);
921
+ }
922
+ }
923
+ }
924
+ // the "$score" field is implied to be the primary
925
+ // sort field, unless it's manually specified
926
+ if (search.query) {
927
+ implicit_score = true;
928
+ for (let fld of sort_flds) {
929
+ if (fld.field === '$score') {
930
+ implicit_score = false;
931
+ break;
932
+ }
933
+ }
934
+ if (implicit_score) {
935
+ sort_flds.unshift({ field: '$score', direction: 'desc' });
936
+ }
937
+ // without a search.query, all items will have the same score
938
+ }
939
+ else {
940
+ sort_flds = sort_flds.filter((fld) => fld.field !== '$score');
941
+ }
942
+ // build function
943
+ const sort_flds_count = sort_flds.length;
944
+ if (!sort_flds_count) {
945
+ return null;
946
+ }
947
+ return function (a, b) {
948
+ var result, field;
949
+ for (let sort_fld of sort_flds) {
950
+ field = sort_fld.field;
951
+ let multiplier = sort_fld.direction === 'desc' ? -1 : 1;
952
+ result = multiplier * cmp(get_field(field, a), get_field(field, b));
953
+ if (result)
954
+ return result;
955
+ }
956
+ return 0;
957
+ };
1113
958
  }
1114
- }
1115
-
1116
- /**
1117
- * Returns a function that can be used to compare two
1118
- * results, for sorting purposes. If no sorting should
1119
- * be performed, `null` will be returned.
1120
- *
1121
- * @return function(a,b)
1122
- */
1123
- getSortFunction(query, options) {
1124
- var search = this.prepareSearch(query, options);
1125
- return this._getSortFunction(search);
1126
- }
1127
-
1128
- _getSortFunction(search) {
1129
- var implicit_score,
1130
- sort_flds = [];
1131
- const self = this,
1132
- options = search.options,
1133
- sort = !search.query && options.sort_empty ? options.sort_empty : options.sort;
1134
-
1135
- if (typeof sort == 'function') {
1136
- return sort.bind(this);
959
+ ;
960
+ /**
961
+ * Parses a search query and returns an object
962
+ * with tokens and fields ready to be populated
963
+ * with results.
964
+ *
965
+ */
966
+ prepareSearch(query, optsUser) {
967
+ const weights = {};
968
+ var options = Object.assign({}, optsUser);
969
+ propToArray(options, 'sort');
970
+ propToArray(options, 'sort_empty');
971
+ // convert fields to new format
972
+ if (options.fields) {
973
+ propToArray(options, 'fields');
974
+ const fields = [];
975
+ options.fields.forEach((field) => {
976
+ if (typeof field == 'string') {
977
+ field = { field: field, weight: 1 };
978
+ }
979
+ fields.push(field);
980
+ weights[field.field] = ('weight' in field) ? field.weight : 1;
981
+ });
982
+ options.fields = fields;
983
+ }
984
+ return {
985
+ options: options,
986
+ query: query.toLowerCase().trim(),
987
+ tokens: this.tokenize(query, options.respect_word_boundaries, weights),
988
+ total: 0,
989
+ items: [],
990
+ weights: weights,
991
+ getAttrFn: (options.nesting) ? getAttrNesting : getAttr,
992
+ };
1137
993
  }
994
+ ;
1138
995
  /**
1139
- * Fetches the specified sort field value
1140
- * from a search result item.
996
+ * Searches through all items and returns a sorted array of matches.
1141
997
  *
1142
998
  */
1143
-
1144
-
1145
- const get_field = function get_field(name, result) {
1146
- if (name === '$score') return result.score;
1147
- return search.getAttrFn(self.items[result.id], name);
1148
- }; // parse options
1149
-
1150
-
1151
- if (sort) {
1152
- for (let s of sort) {
1153
- if (search.query || s.field !== '$score') {
1154
- sort_flds.push(s);
999
+ search(query, options) {
1000
+ var self = this, score, search;
1001
+ search = this.prepareSearch(query, options);
1002
+ options = search.options;
1003
+ query = search.query;
1004
+ // generate result scoring function
1005
+ const fn_score = options.score || self._getScoreFunction(search);
1006
+ // perform search and sort
1007
+ if (query.length) {
1008
+ iterate$1(self.items, (item, id) => {
1009
+ score = fn_score(item);
1010
+ if (options.filter === false || score > 0) {
1011
+ search.items.push({ 'score': score, 'id': id });
1012
+ }
1013
+ });
1155
1014
  }
1156
- }
1157
- } // the "$score" field is implied to be the primary
1158
- // sort field, unless it's manually specified
1159
-
1160
-
1161
- if (search.query) {
1162
- implicit_score = true;
1163
-
1164
- for (let fld of sort_flds) {
1165
- if (fld.field === '$score') {
1166
- implicit_score = false;
1167
- break;
1015
+ else {
1016
+ iterate$1(self.items, (_, id) => {
1017
+ search.items.push({ 'score': 1, 'id': id });
1018
+ });
1168
1019
  }
1169
- }
1170
-
1171
- if (implicit_score) {
1172
- sort_flds.unshift({
1173
- field: '$score',
1174
- direction: 'desc'
1175
- });
1176
- } // without a search.query, all items will have the same score
1177
-
1178
- } else {
1179
- sort_flds = sort_flds.filter(fld => fld.field !== '$score');
1180
- } // build function
1181
-
1182
-
1183
- const sort_flds_count = sort_flds.length;
1184
-
1185
- if (!sort_flds_count) {
1186
- return null;
1020
+ const fn_sort = self._getSortFunction(search);
1021
+ if (fn_sort)
1022
+ search.items.sort(fn_sort);
1023
+ // apply limits
1024
+ search.total = search.items.length;
1025
+ if (typeof options.limit === 'number') {
1026
+ search.items = search.items.slice(0, options.limit);
1027
+ }
1028
+ return search;
1187
1029
  }
1030
+ ;
1031
+ }
1188
1032
 
1189
- return function (a, b) {
1190
- var result, field;
1033
+ /**
1034
+ * Converts a scalar to its best string representation
1035
+ * for hash keys and HTML attribute values.
1036
+ *
1037
+ * Transformations:
1038
+ * 'str' -> 'str'
1039
+ * null -> ''
1040
+ * undefined -> ''
1041
+ * true -> '1'
1042
+ * false -> '0'
1043
+ * 0 -> '0'
1044
+ * 1 -> '1'
1045
+ *
1046
+ */
1047
+ const hash_key = value => {
1048
+ if (typeof value === 'undefined' || value === null) return null;
1049
+ return get_hash(value);
1050
+ };
1051
+ const get_hash = value => {
1052
+ if (typeof value === 'boolean') return value ? '1' : '0';
1053
+ return value + '';
1054
+ };
1191
1055
 
1192
- for (let sort_fld of sort_flds) {
1193
- field = sort_fld.field;
1194
- let multiplier = sort_fld.direction === 'desc' ? -1 : 1;
1195
- result = multiplier * cmp(get_field(field, a), get_field(field, b));
1196
- if (result) return result;
1197
- }
1056
+ /**
1057
+ * Escapes a string for use within HTML.
1058
+ *
1059
+ */
1060
+ const escape_html = str => {
1061
+ return (str + '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
1062
+ };
1198
1063
 
1199
- return 0;
1200
- };
1064
+ /**
1065
+ * use setTimeout if timeout > 0
1066
+ */
1067
+ const timeout = (fn, timeout) => {
1068
+ if (timeout > 0) {
1069
+ return window.setTimeout(fn, timeout);
1201
1070
  }
1071
+ fn.call(null);
1072
+ return null;
1073
+ };
1202
1074
 
1203
- /**
1204
- * Parses a search query and returns an object
1205
- * with tokens and fields ready to be populated
1206
- * with results.
1207
- *
1208
- */
1209
- prepareSearch(query, optsUser) {
1210
- const weights = {};
1211
- var options = Object.assign({}, optsUser);
1212
- propToArray(options, 'sort');
1213
- propToArray(options, 'sort_empty'); // convert fields to new format
1214
-
1215
- if (options.fields) {
1216
- propToArray(options, 'fields');
1217
- const fields = [];
1218
- options.fields.forEach(field => {
1219
- if (typeof field == 'string') {
1220
- field = {
1221
- field: field,
1222
- weight: 1
1223
- };
1224
- }
1225
-
1226
- fields.push(field);
1227
- weights[field.field] = 'weight' in field ? field.weight : 1;
1228
- });
1229
- options.fields = fields;
1075
+ /**
1076
+ * Debounce the user provided load function
1077
+ *
1078
+ */
1079
+ const loadDebounce = (fn, delay) => {
1080
+ var timeout;
1081
+ return function (value, callback) {
1082
+ var self = this;
1083
+ if (timeout) {
1084
+ self.loading = Math.max(self.loading - 1, 0);
1085
+ clearTimeout(timeout);
1230
1086
  }
1087
+ timeout = setTimeout(function () {
1088
+ timeout = null;
1089
+ self.loadedSearches[value] = true;
1090
+ fn.call(self, value, callback);
1091
+ }, delay);
1092
+ };
1093
+ };
1231
1094
 
1232
- return {
1233
- options: options,
1234
- query: query.toLowerCase().trim(),
1235
- tokens: this.tokenize(query, options.respect_word_boundaries, weights),
1236
- total: 0,
1237
- items: [],
1238
- weights: weights,
1239
- getAttrFn: options.nesting ? getAttrNesting : getAttr
1240
- };
1241
- }
1095
+ /**
1096
+ * Debounce all fired events types listed in `types`
1097
+ * while executing the provided `fn`.
1098
+ *
1099
+ */
1100
+ const debounce_events = (self, types, fn) => {
1101
+ var type;
1102
+ var trigger = self.trigger;
1103
+ var event_args = {};
1242
1104
 
1243
- /**
1244
- * Searches through all items and returns a sorted array of matches.
1245
- *
1246
- */
1247
- search(query, options) {
1248
- var self = this,
1249
- score,
1250
- search;
1251
- search = this.prepareSearch(query, options);
1252
- options = search.options;
1253
- query = search.query; // generate result scoring function
1105
+ // override trigger method
1106
+ self.trigger = function () {
1107
+ var type = arguments[0];
1108
+ if (types.indexOf(type) !== -1) {
1109
+ event_args[type] = arguments;
1110
+ } else {
1111
+ return trigger.apply(self, arguments);
1112
+ }
1113
+ };
1254
1114
 
1255
- const fn_score = options.score || self._getScoreFunction(search); // perform search and sort
1115
+ // invoke provided function
1116
+ fn.apply(self, []);
1117
+ self.trigger = trigger;
1256
1118
 
1119
+ // trigger queued events
1120
+ for (type of types) {
1121
+ if (type in event_args) {
1122
+ trigger.apply(self, event_args[type]);
1123
+ }
1124
+ }
1125
+ };
1257
1126
 
1258
- if (query.length) {
1259
- iterate$1(self.items, (item, id) => {
1260
- score = fn_score(item);
1127
+ /**
1128
+ * Determines the current selection within a text input control.
1129
+ * Returns an object containing:
1130
+ * - start
1131
+ * - length
1132
+ *
1133
+ * Note: "selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password"
1134
+ * - https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
1135
+ */
1136
+ const getSelection = input => {
1137
+ return {
1138
+ start: input.selectionStart || 0,
1139
+ length: (input.selectionEnd || 0) - (input.selectionStart || 0)
1140
+ };
1141
+ };
1261
1142
 
1262
- if (options.filter === false || score > 0) {
1263
- search.items.push({
1264
- 'score': score,
1265
- 'id': id
1266
- });
1267
- }
1268
- });
1269
- } else {
1270
- iterate$1(self.items, (_, id) => {
1271
- search.items.push({
1272
- 'score': 1,
1273
- 'id': id
1274
- });
1275
- });
1143
+ /**
1144
+ * Prevent default
1145
+ *
1146
+ */
1147
+ const preventDefault = (evt, stop = false) => {
1148
+ if (evt) {
1149
+ evt.preventDefault();
1150
+ if (stop) {
1151
+ evt.stopPropagation();
1276
1152
  }
1153
+ }
1154
+ };
1277
1155
 
1278
- const fn_sort = self._getSortFunction(search);
1279
-
1280
- if (fn_sort) search.items.sort(fn_sort); // apply limits
1281
-
1282
- search.total = search.items.length;
1156
+ /**
1157
+ * Add event helper
1158
+ *
1159
+ */
1160
+ const addEvent = (target, type, callback, options) => {
1161
+ target.addEventListener(type, callback, options);
1162
+ };
1283
1163
 
1284
- if (typeof options.limit === 'number') {
1285
- search.items = search.items.slice(0, options.limit);
1286
- }
1164
+ /**
1165
+ * Return true if the requested key is down
1166
+ * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )
1167
+ * The current evt may not always set ( eg calling advanceSelection() )
1168
+ *
1169
+ */
1170
+ const isKeyDown = (key_name, evt) => {
1171
+ if (!evt) {
1172
+ return false;
1173
+ }
1174
+ if (!evt[key_name]) {
1175
+ return false;
1176
+ }
1177
+ var count = (evt.altKey ? 1 : 0) + (evt.ctrlKey ? 1 : 0) + (evt.shiftKey ? 1 : 0) + (evt.metaKey ? 1 : 0);
1178
+ if (count === 1) {
1179
+ return true;
1180
+ }
1181
+ return false;
1182
+ };
1287
1183
 
1288
- return search;
1184
+ /**
1185
+ * Get the id of an element
1186
+ * If the id attribute is not set, set the attribute with the given id
1187
+ *
1188
+ */
1189
+ const getId = (el, id) => {
1190
+ const existing_id = el.getAttribute('id');
1191
+ if (existing_id) {
1192
+ return existing_id;
1289
1193
  }
1194
+ el.setAttribute('id', id);
1195
+ return id;
1196
+ };
1290
1197
 
1291
- }
1198
+ /**
1199
+ * Returns a string with backslashes added before characters that need to be escaped.
1200
+ */
1201
+ const addSlashes = str => {
1202
+ return str.replace(/[\\"']/g, '\\$&');
1203
+ };
1204
+
1205
+ /**
1206
+ *
1207
+ */
1208
+ const append = (parent, node) => {
1209
+ if (node) parent.append(node);
1210
+ };
1292
1211
 
1293
1212
  /**
1294
1213
  * Iterates over arrays and hashes.
@@ -1396,7 +1315,7 @@
1396
1315
  var classes = [];
1397
1316
  iterate(args, _classes => {
1398
1317
  if (typeof _classes === 'string') {
1399
- _classes = _classes.trim().split(/[\11\12\14\15\40]/);
1318
+ _classes = _classes.trim().split(/[\t\n\f\r\s]/);
1400
1319
  }
1401
1320
  if (Array.isArray(_classes)) {
1402
1321
  classes = classes.concat(_classes);
@@ -1656,185 +1575,6 @@
1656
1575
  }
1657
1576
  };
1658
1577
 
1659
- /**
1660
- * Converts a scalar to its best string representation
1661
- * for hash keys and HTML attribute values.
1662
- *
1663
- * Transformations:
1664
- * 'str' -> 'str'
1665
- * null -> ''
1666
- * undefined -> ''
1667
- * true -> '1'
1668
- * false -> '0'
1669
- * 0 -> '0'
1670
- * 1 -> '1'
1671
- *
1672
- */
1673
- const hash_key = value => {
1674
- if (typeof value === 'undefined' || value === null) return null;
1675
- return get_hash(value);
1676
- };
1677
- const get_hash = value => {
1678
- if (typeof value === 'boolean') return value ? '1' : '0';
1679
- return value + '';
1680
- };
1681
-
1682
- /**
1683
- * Escapes a string for use within HTML.
1684
- *
1685
- */
1686
- const escape_html = str => {
1687
- return (str + '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
1688
- };
1689
-
1690
- /**
1691
- * use setTimeout if timeout > 0
1692
- */
1693
- const timeout = (fn, timeout) => {
1694
- if (timeout > 0) {
1695
- return setTimeout(fn, timeout);
1696
- }
1697
- fn.call(null);
1698
- return null;
1699
- };
1700
-
1701
- /**
1702
- * Debounce the user provided load function
1703
- *
1704
- */
1705
- const loadDebounce = (fn, delay) => {
1706
- var timeout;
1707
- return function (value, callback) {
1708
- var self = this;
1709
- if (timeout) {
1710
- self.loading = Math.max(self.loading - 1, 0);
1711
- clearTimeout(timeout);
1712
- }
1713
- timeout = setTimeout(function () {
1714
- timeout = null;
1715
- self.loadedSearches[value] = true;
1716
- fn.call(self, value, callback);
1717
- }, delay);
1718
- };
1719
- };
1720
-
1721
- /**
1722
- * Debounce all fired events types listed in `types`
1723
- * while executing the provided `fn`.
1724
- *
1725
- */
1726
- const debounce_events = (self, types, fn) => {
1727
- var type;
1728
- var trigger = self.trigger;
1729
- var event_args = {};
1730
-
1731
- // override trigger method
1732
- self.trigger = function () {
1733
- var type = arguments[0];
1734
- if (types.indexOf(type) !== -1) {
1735
- event_args[type] = arguments;
1736
- } else {
1737
- return trigger.apply(self, arguments);
1738
- }
1739
- };
1740
-
1741
- // invoke provided function
1742
- fn.apply(self, []);
1743
- self.trigger = trigger;
1744
-
1745
- // trigger queued events
1746
- for (type of types) {
1747
- if (type in event_args) {
1748
- trigger.apply(self, event_args[type]);
1749
- }
1750
- }
1751
- };
1752
-
1753
- /**
1754
- * Determines the current selection within a text input control.
1755
- * Returns an object containing:
1756
- * - start
1757
- * - length
1758
- *
1759
- * Note: "selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password"
1760
- * - https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
1761
- */
1762
- const getSelection = input => {
1763
- return {
1764
- start: input.selectionStart || 0,
1765
- length: (input.selectionEnd || 0) - (input.selectionStart || 0)
1766
- };
1767
- };
1768
-
1769
- /**
1770
- * Prevent default
1771
- *
1772
- */
1773
- const preventDefault = (evt, stop = false) => {
1774
- if (evt) {
1775
- evt.preventDefault();
1776
- if (stop) {
1777
- evt.stopPropagation();
1778
- }
1779
- }
1780
- };
1781
-
1782
- /**
1783
- * Add event helper
1784
- *
1785
- */
1786
- const addEvent = (target, type, callback, options) => {
1787
- target.addEventListener(type, callback, options);
1788
- };
1789
-
1790
- /**
1791
- * Return true if the requested key is down
1792
- * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )
1793
- * The current evt may not always set ( eg calling advanceSelection() )
1794
- *
1795
- */
1796
- const isKeyDown = (key_name, evt) => {
1797
- if (!evt) {
1798
- return false;
1799
- }
1800
- if (!evt[key_name]) {
1801
- return false;
1802
- }
1803
- var count = (evt.altKey ? 1 : 0) + (evt.ctrlKey ? 1 : 0) + (evt.shiftKey ? 1 : 0) + (evt.metaKey ? 1 : 0);
1804
- if (count === 1) {
1805
- return true;
1806
- }
1807
- return false;
1808
- };
1809
-
1810
- /**
1811
- * Get the id of an element
1812
- * If the id attribute is not set, set the attribute with the given id
1813
- *
1814
- */
1815
- const getId = (el, id) => {
1816
- const existing_id = el.getAttribute('id');
1817
- if (existing_id) {
1818
- return existing_id;
1819
- }
1820
- el.setAttribute('id', id);
1821
- return id;
1822
- };
1823
-
1824
- /**
1825
- * Returns a string with backslashes added before characters that need to be escaped.
1826
- */
1827
- const addSlashes = str => {
1828
- return str.replace(/[\\"']/g, '\\$&');
1829
- };
1830
-
1831
- /**
1832
- *
1833
- */
1834
- const append = (parent, node) => {
1835
- if (node) parent.append(node);
1836
- };
1837
-
1838
1578
  function getSettings(input, settings_user) {
1839
1579
  var settings = Object.assign({}, defaults, settings_user);
1840
1580
  var attr_data = settings.dataAttr;
@@ -1973,25 +1713,10 @@
1973
1713
  class TomSelect extends MicroPlugin(MicroEvent) {
1974
1714
  constructor(input_arg, user_settings) {
1975
1715
  super();
1976
- this.control_input = void 0;
1977
- this.wrapper = void 0;
1978
- this.dropdown = void 0;
1979
- this.control = void 0;
1980
- this.dropdown_content = void 0;
1981
- this.focus_node = void 0;
1982
1716
  this.order = 0;
1983
- this.settings = void 0;
1984
- this.input = void 0;
1985
- this.tabIndex = void 0;
1986
- this.is_select_tag = void 0;
1987
- this.rtl = void 0;
1988
- this.inputId = void 0;
1989
- this._destroy = void 0;
1990
- this.sifter = void 0;
1991
1717
  this.isOpen = false;
1992
1718
  this.isDisabled = false;
1993
1719
  this.isReadOnly = false;
1994
- this.isRequired = void 0;
1995
1720
  this.isInvalid = false;
1996
1721
  // @deprecated 1.8
1997
1722
  this.isValid = true;
@@ -2002,7 +1727,6 @@
2002
1727
  this.ignoreFocus = false;
2003
1728
  this.ignoreHover = false;
2004
1729
  this.hasOptions = false;
2005
- this.currentResults = void 0;
2006
1730
  this.lastValue = '';
2007
1731
  this.caretPos = 0;
2008
1732
  this.loading = 0;
@@ -2092,8 +1816,8 @@
2092
1816
  control_input = getDom(settings.controlInput);
2093
1817
 
2094
1818
  // set attributes
2095
- var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck'];
2096
- iterate$1(attrs, attr => {
1819
+ var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck', 'aria-label'];
1820
+ iterate(attrs, attr => {
2097
1821
  if (input.getAttribute(attr)) {
2098
1822
  setAttr(control_input, {
2099
1823
  [attr]: input.getAttribute(attr)
@@ -2261,10 +1985,19 @@
2261
1985
  self.positionDropdown();
2262
1986
  }
2263
1987
  };
1988
+ const input_invalid = () => {
1989
+ if (self.isValid) {
1990
+ self.isValid = false;
1991
+ self.isInvalid = true;
1992
+ self.refreshState();
1993
+ }
1994
+ };
1995
+ addEvent(input, 'invalid', input_invalid);
2264
1996
  addEvent(document, 'mousedown', doc_mousedown);
2265
1997
  addEvent(window, 'scroll', win_scroll, passive_event);
2266
1998
  addEvent(window, 'resize', win_scroll, passive_event);
2267
1999
  this._destroy = () => {
2000
+ input.removeEventListener('invalid', input_invalid);
2268
2001
  document.removeEventListener('mousedown', doc_mousedown);
2269
2002
  window.removeEventListener('scroll', win_scroll);
2270
2003
  window.removeEventListener('resize', win_scroll);
@@ -2283,14 +2016,6 @@
2283
2016
  settings.items = [];
2284
2017
  delete settings.optgroups;
2285
2018
  delete settings.options;
2286
- addEvent(input, 'invalid', () => {
2287
- if (self.isValid) {
2288
- self.isValid = false;
2289
- self.isInvalid = true;
2290
- self.refreshState();
2291
- }
2292
- });
2293
- self.updateOriginalInput();
2294
2019
  self.refreshItems();
2295
2020
  self.close(false);
2296
2021
  self.inputState();
@@ -2302,7 +2027,6 @@
2302
2027
  } else {
2303
2028
  self.enable(); //sets tabIndex
2304
2029
  }
2305
-
2306
2030
  self.on('change', this.onChange);
2307
2031
  addClasses(input, 'tomselected', 'ts-hidden-accessible');
2308
2032
  self.trigger('initialize');
@@ -2322,7 +2046,7 @@
2322
2046
  this.addOptions(options);
2323
2047
 
2324
2048
  // build optgroup table
2325
- iterate$1(optgroups, optgroup => {
2049
+ iterate(optgroups, optgroup => {
2326
2050
  this.registerOptionGroup(optgroup);
2327
2051
  });
2328
2052
  }
@@ -2473,7 +2197,7 @@
2473
2197
  return;
2474
2198
  }
2475
2199
  var splitInput = pastedText.trim().split(self.settings.splitOn);
2476
- iterate$1(splitInput, piece => {
2200
+ iterate(splitInput, piece => {
2477
2201
  const hash = hash_key(piece);
2478
2202
  if (hash) {
2479
2203
  if (this.options[piece]) {
@@ -2593,8 +2317,7 @@
2593
2317
  // prevent default [tab] behaviour of jump to the next field
2594
2318
  // if select isFull, then the dropdown won't be open and [tab] will work normally
2595
2319
  preventDefault(e);
2596
- }
2597
- if (self.settings.create && self.createItem()) {
2320
+ } else if (self.settings.create && self.createItem()) {
2598
2321
  preventDefault(e);
2599
2322
  }
2600
2323
  }
@@ -2629,7 +2352,7 @@
2629
2352
  return;
2630
2353
  }
2631
2354
  if (this.refreshTimeout) {
2632
- clearTimeout(this.refreshTimeout);
2355
+ window.clearTimeout(this.refreshTimeout);
2633
2356
  }
2634
2357
  this.refreshTimeout = timeout(() => {
2635
2358
  this.refreshTimeout = null;
@@ -3040,7 +2763,7 @@
3040
2763
  self.inputState();
3041
2764
  self.close();
3042
2765
  self.activeItems = activeItems;
3043
- iterate$1(activeItems, item => {
2766
+ iterate(activeItems, item => {
3044
2767
  self.setActiveItemClass(item);
3045
2768
  });
3046
2769
  }
@@ -3289,7 +3012,7 @@
3289
3012
 
3290
3013
  // render optgroup headers & join groups
3291
3014
  html = document.createDocumentFragment();
3292
- iterate$1(groups_order, group_order => {
3015
+ iterate(groups_order, group_order => {
3293
3016
  let group_fragment = group_order.fragment;
3294
3017
  let optgroup = group_order.optgroup;
3295
3018
  if (!group_fragment || !group_fragment.children.length) return;
@@ -3315,7 +3038,7 @@
3315
3038
  if (self.settings.highlight) {
3316
3039
  removeHighlight(dropdown_content);
3317
3040
  if (results.query.length && results.tokens.length) {
3318
- iterate$1(results.tokens, tok => {
3041
+ iterate(results.tokens, tok => {
3319
3042
  highlight(dropdown_content, tok.regex);
3320
3043
  });
3321
3044
  }
@@ -3430,7 +3153,7 @@
3430
3153
  *
3431
3154
  */
3432
3155
  addOptions(data, user_created = false) {
3433
- iterate$1(data, dat => {
3156
+ iterate(data, dat => {
3434
3157
  this.addOption(dat, user_created);
3435
3158
  });
3436
3159
  }
@@ -3568,7 +3291,7 @@
3568
3291
  this.userOptions = {};
3569
3292
  this.clearCache();
3570
3293
  const selected = {};
3571
- iterate$1(this.options, (option, key) => {
3294
+ iterate(this.options, (option, key) => {
3572
3295
  if (boundFilter(option, key)) {
3573
3296
  selected[key] = option;
3574
3297
  }
@@ -3790,6 +3513,12 @@
3790
3513
  var output;
3791
3514
  input = input || self.inputValue();
3792
3515
  if (!self.canCreate(input)) {
3516
+ const hash = hash_key(input);
3517
+ if (hash) {
3518
+ if (this.options[input]) {
3519
+ self.addItem(input);
3520
+ }
3521
+ }
3793
3522
  callback();
3794
3523
  return false;
3795
3524
  }
@@ -4032,7 +3761,7 @@
4032
3761
  var self = this;
4033
3762
  if (!self.items.length) return;
4034
3763
  var items = self.controlChildren();
4035
- iterate$1(items, item => {
3764
+ iterate(items, item => {
4036
3765
  self.removeItem(item, true);
4037
3766
  });
4038
3767
  self.inputState();
@@ -4071,7 +3800,7 @@
4071
3800
  if (direction > 0) {
4072
3801
  caret++;
4073
3802
  }
4074
- iterate$1(self.activeItems, item => rm_items.push(item));
3803
+ iterate(self.activeItems, item => rm_items.push(item));
4075
3804
  } else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) {
4076
3805
  const items = self.controlChildren();
4077
3806
  let rm_item;
@@ -4353,7 +4082,7 @@
4353
4082
  *
4354
4083
  */
4355
4084
  clearCache() {
4356
- iterate$1(this.options, option => {
4085
+ iterate(this.options, option => {
4357
4086
  if (option.$div) {
4358
4087
  option.$div.remove();
4359
4088
  delete option.$div;