tom-select-rails 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) 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/tom-select.complete.js +168 -84
  4. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.complete.js.map +1 -1
  5. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.js +132 -59
  6. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.js.map +1 -1
  7. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.popular.js +140 -65
  8. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.popular.js.map +1 -1
  9. data/vendor/assets/javascripts/tom-select-rails/cjs/utils.js +1 -1
  10. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/caret_position/plugin.js +3 -3
  11. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/caret_position/plugin.js.map +1 -1
  12. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/change_listener/plugin.js +1 -1
  13. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/plugin.js +9 -7
  14. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/plugin.js.map +1 -1
  15. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/plugin.js +3 -3
  16. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/plugin.js.map +1 -1
  17. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/drag_drop/plugin.js +1 -1
  18. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.js +3 -3
  19. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.js.map +1 -1
  20. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.js +6 -4
  21. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.js.map +1 -1
  22. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.js +3 -7
  23. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.js.map +1 -1
  24. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_active_items/plugin.js +1 -1
  25. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_backspace_delete/plugin.js +1 -1
  26. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.js +4 -3
  27. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.js.map +1 -1
  28. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.js +8 -8
  29. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.js.map +1 -1
  30. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/restore_on_backspace/plugin.js +1 -1
  31. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.js +22 -12
  32. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.js.map +1 -1
  33. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.complete.js +168 -84
  34. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.complete.js.map +1 -1
  35. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.js +132 -59
  36. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.js.map +1 -1
  37. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.popular.js +140 -65
  38. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.popular.js.map +1 -1
  39. data/vendor/assets/javascripts/tom-select-rails/esm/utils.js +1 -1
  40. data/vendor/assets/javascripts/tom-select-rails/js/plugins/caret_position.js +3 -3
  41. data/vendor/assets/javascripts/tom-select-rails/js/plugins/caret_position.js.map +1 -1
  42. data/vendor/assets/javascripts/tom-select-rails/js/plugins/change_listener.js +1 -1
  43. data/vendor/assets/javascripts/tom-select-rails/js/plugins/checkbox_options.js +9 -7
  44. data/vendor/assets/javascripts/tom-select-rails/js/plugins/checkbox_options.js.map +1 -1
  45. data/vendor/assets/javascripts/tom-select-rails/js/plugins/clear_button.js +3 -3
  46. data/vendor/assets/javascripts/tom-select-rails/js/plugins/clear_button.js.map +1 -1
  47. data/vendor/assets/javascripts/tom-select-rails/js/plugins/drag_drop.js +1 -1
  48. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_header.js +3 -3
  49. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_header.js.map +1 -1
  50. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_input.js +6 -4
  51. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_input.js.map +1 -1
  52. data/vendor/assets/javascripts/tom-select-rails/js/plugins/input_autogrow.js +3 -7
  53. data/vendor/assets/javascripts/tom-select-rails/js/plugins/input_autogrow.js.map +1 -1
  54. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_active_items.js +1 -1
  55. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_backspace_delete.js +1 -1
  56. data/vendor/assets/javascripts/tom-select-rails/js/plugins/optgroup_columns.js +4 -3
  57. data/vendor/assets/javascripts/tom-select-rails/js/plugins/optgroup_columns.js.map +1 -1
  58. data/vendor/assets/javascripts/tom-select-rails/js/plugins/remove_button.js +8 -8
  59. data/vendor/assets/javascripts/tom-select-rails/js/plugins/remove_button.js.map +1 -1
  60. data/vendor/assets/javascripts/tom-select-rails/js/plugins/restore_on_backspace.js +1 -1
  61. data/vendor/assets/javascripts/tom-select-rails/js/plugins/virtual_scroll.js +22 -12
  62. data/vendor/assets/javascripts/tom-select-rails/js/plugins/virtual_scroll.js.map +1 -1
  63. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.js +132 -59
  64. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.js.map +1 -1
  65. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.min.js +142 -142
  66. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.min.js.map +1 -1
  67. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.js +168 -84
  68. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.js.map +1 -1
  69. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.min.js +157 -156
  70. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.min.js.map +1 -1
  71. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.js +140 -65
  72. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.js.map +1 -1
  73. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.min.js +142 -143
  74. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.min.js.map +1 -1
  75. data/vendor/assets/javascripts/tom-select-rails/types/tom-select.d.ts +20 -3
  76. data/vendor/assets/javascripts/tom-select-rails/types/types/core.d.ts +2 -1
  77. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.css +3 -7
  78. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.css.map +1 -1
  79. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.min.css +1 -1
  80. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.min.css.map +1 -1
  81. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.css +3 -7
  82. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.css.map +1 -1
  83. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.min.css +1 -1
  84. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.min.css.map +1 -1
  85. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.css +7 -11
  86. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.css.map +1 -1
  87. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.css +3 -7
  88. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.css.map +1 -1
  89. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.min.css +1 -1
  90. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.min.css.map +1 -1
  91. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.min.css +1 -1
  92. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.min.css.map +1 -1
  93. data/vendor/assets/stylesheets/tom-select-rails/scss/_dropdown.scss +0 -2
  94. data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.scss +4 -4
  95. metadata +3 -3
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.0.3
2
+ * Tom Select v2.1.0
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
@@ -9,13 +9,13 @@
9
9
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.virtual_scroll = factory());
10
10
  })(this, (function () { 'use strict';
11
11
 
12
- // https://github.com/andrewrk/node-diacritics/blob/master/index.js
12
+ // @ts-ignore TS2691 "An import path cannot end with a '.ts' extension"
13
13
  const latin_convert = {
14
14
  'æ': 'ae',
15
15
  'ⱥ': 'a',
16
16
  'ø': 'o'
17
17
  };
18
- new RegExp(Object.keys(latin_convert).join('|'), 'g');
18
+ new RegExp(Object.keys(latin_convert).join('|'), 'gu');
19
19
 
20
20
  // @ts-ignore TS2691 "An import path cannot end with a '.ts' extension"
21
21
  /**
@@ -109,10 +109,11 @@
109
109
  var dropdown_content;
110
110
  var loading_more = false;
111
111
  var load_more_opt;
112
+ var default_values = [];
112
113
 
113
114
  if (!self.settings.shouldLoadMore) {
114
115
  // return true if additional results should be loaded
115
- self.settings.shouldLoadMore = function () {
116
+ self.settings.shouldLoadMore = () => {
116
117
  const scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop);
117
118
 
118
119
  if (scroll_percent > 0.9) {
@@ -144,7 +145,7 @@
144
145
  field: '$score'
145
146
  }]; // can we load more results for given query?
146
147
 
147
- function canLoadMore(query) {
148
+ const canLoadMore = query => {
148
149
  if (typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions) {
149
150
  return false;
150
151
  }
@@ -154,15 +155,23 @@
154
155
  }
155
156
 
156
157
  return false;
157
- } // set the next url that will be
158
+ };
159
+
160
+ const clearFilter = (option, value) => {
161
+ if (self.items.indexOf(value) >= 0 || default_values.indexOf(value) >= 0) {
162
+ return true;
163
+ }
164
+
165
+ return false;
166
+ }; // set the next url that will be
158
167
 
159
168
 
160
- self.setNextUrl = function (value, next_url) {
169
+ self.setNextUrl = (value, next_url) => {
161
170
  pagination[value] = next_url;
162
171
  }; // getUrl() to be used in settings.load()
163
172
 
164
173
 
165
- self.getUrl = function (query) {
174
+ self.getUrl = query => {
166
175
  if (query in pagination) {
167
176
  const next_url = pagination[query];
168
177
  pagination[query] = false;
@@ -196,7 +205,7 @@
196
205
 
197
206
  self.hook('instead', 'loadCallback', (options, optgroups) => {
198
207
  if (!loading_more) {
199
- self.clearOptions();
208
+ self.clearOptions(clearFilter);
200
209
  } else if (load_more_opt && options.length > 0) {
201
210
  load_more_opt.dataset.value = options[0][self.settings.valueField];
202
211
  }
@@ -234,18 +243,19 @@
234
243
  }); // add scroll listener and default templates
235
244
 
236
245
  self.on('initialize', () => {
246
+ default_values = Object.keys(self.options);
237
247
  dropdown_content = self.dropdown_content; // default templates
238
248
 
239
249
  self.settings.render = Object.assign({}, {
240
- loading_more: function () {
250
+ loading_more: () => {
241
251
  return `<div class="loading-more-results">Loading more results ... </div>`;
242
252
  },
243
- no_more_results: function () {
253
+ no_more_results: () => {
244
254
  return `<div class="no-more-results">No more results</div>`;
245
255
  }
246
256
  }, self.settings.render); // watch dropdown content scroll position
247
257
 
248
- dropdown_content.addEventListener('scroll', function () {
258
+ dropdown_content.addEventListener('scroll', () => {
249
259
  if (!self.settings.shouldLoadMore.call(self)) {
250
260
  return;
251
261
  } // !important: this will get checked again in load() but we still need to check here otherwise loading_more will be set to true
@@ -1 +1 @@
1
- {"version":3,"file":"virtual_scroll.js","sources":["../../../node_modules/@orchidjs/sifter/lib/diacritics.ts","../../../node_modules/@orchidjs/sifter/lib/utils.ts","../../../src/vanilla.ts","../../../src/plugins/virtual_scroll/plugin.ts"],"sourcesContent":["\ntype TDiacraticList = {[key:string]:string};\n\n// https://github.com/andrewrk/node-diacritics/blob/master/index.js\n\nvar latin_pat:RegExp;\nconst accent_pat = '[\\u0300-\\u036F\\u{b7}\\u{2be}]'; // \\u{2bc}\nconst accent_reg = new RegExp(accent_pat,'g');\nvar diacritic_patterns:TDiacraticList;\n\nconst latin_convert:TDiacraticList = {\n\t'æ': 'ae',\n\t'ⱥ': 'a',\n\t'ø': 'o',\n};\n\nconst convert_pat = new RegExp(Object.keys(latin_convert).join('|'),'g');\n\n\nexport const DIACRITICS:TDiacraticList = {\n\t\" \":\" \",\n\t0:\"߀\",\n\tA:\"ⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ\",\n\tAA:\"Ꜳ\",\n\tAE:\"ÆǼǢ\",\n\tAO:\"Ꜵ\",\n\tAU:\"Ꜷ\",\n\tAV:\"ꜸꜺ\",\n\tAY:\"Ꜽ\",\n\tB:\"ⒷBḂḄḆɃƁ\",\n\tC:\"ⒸCꜾḈĆCĈĊČÇƇȻ\",\n\tD:\"ⒹDḊĎḌḐḒḎĐƊƉᴅꝹ\",\n\tDh:\"Ð\",\n\tDZ:\"DZDŽ\",\n\tDz:\"DzDž\",\n\tE:\"ɛⒺEÈÉÊỀẾỄỂẼĒḔḖĔĖËẺĚȄȆẸỆȨḜĘḘḚƐƎᴇ\",\n\tF:\"ꝼⒻFḞƑꝻ\",\n\tG:\"ⒼGǴĜḠĞĠǦĢǤƓꞠꝽꝾɢ\",\n\tH:\"ⒽHĤḢḦȞḤḨḪĦⱧⱵꞍ\",\n\tI:\"ⒾIÌÍÎĨĪĬİÏḮỈǏȈȊỊĮḬƗ\",\n\tJ:\"ⒿJĴɈȷ\",\n\tK:\"ⓀKḰǨḲĶḴƘⱩꝀꝂꝄꞢ\",\n\tL:\"ⓁLĿĹĽḶḸĻḼḺŁȽⱢⱠꝈꝆꞀ\",\n\tLJ:\"LJ\",\n\tLj:\"Lj\",\n\tM:\"ⓂMḾṀṂⱮƜϻ\",\n\tN:\"ꞤȠⓃNǸŃÑṄŇṆŅṊṈƝꞐᴎ\",\n\tNJ:\"NJ\",\n\tNj:\"Nj\",\n\tO:\"ⓄOÒÓÔỒỐỖỔÕṌȬṎŌṐṒŎȮȰÖȪỎŐǑȌȎƠỜỚỠỞỢỌỘǪǬØǾƆƟꝊꝌ\",\n\tOE:\"Œ\",\n\tOI:\"Ƣ\",\n\tOO:\"Ꝏ\",\n\tOU:\"Ȣ\",\n\tP:\"ⓅPṔṖƤⱣꝐꝒꝔ\",\n\tQ:\"ⓆQꝖꝘɊ\",\n\tR:\"ⓇRŔṘŘȐȒṚṜŖṞɌⱤꝚꞦꞂ\",\n\tS:\"ⓈSẞŚṤŜṠŠṦṢṨȘŞⱾꞨꞄ\",\n\tT:\"ⓉTṪŤṬȚŢṰṮŦƬƮȾꞆ\",\n\tTh:\"Þ\",\n\tTZ:\"Ꜩ\",\n\tU:\"ⓊUÙÚÛŨṸŪṺŬÜǛǗǕǙỦŮŰǓȔȖƯỪỨỮỬỰỤṲŲṶṴɄ\",\n\tV:\"ⓋVṼṾƲꝞɅ\",\n\tVY:\"Ꝡ\",\n\tW:\"ⓌWẀẂŴẆẄẈⱲ\",\n\tX:\"ⓍXẊẌ\",\n\tY:\"ⓎYỲÝŶỸȲẎŸỶỴƳɎỾ\",\n\tZ:\"ⓏZŹẐŻŽẒẔƵȤⱿⱫꝢ\",\n\ta:\"ⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑ\",\n\taa:\"ꜳ\",\n\tae:\"æǽǣ\",\n\tao:\"ꜵ\",\n\tau:\"ꜷ\",\n\tav:\"ꜹꜻ\",\n\tay:\"ꜽ\",\n\tb:\"ⓑbḃḅḇƀƃɓƂ\",\n\tc:\"cⓒćĉċčçḉƈȼꜿↄ\",\n\td:\"ⓓdḋďḍḑḓḏđƌɖɗƋᏧԁꞪ\",\n\tdh:\"ð\",\n\tdz:\"dzdž\",\n\te:\"ⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇǝ\",\n\tf:\"ⓕfḟƒ\",\n\tff:\"ff\",\n\tfi:\"fi\",\n\tfl:\"fl\",\n\tffi:\"ffi\",\n\tffl:\"ffl\",\n\tg:\"ⓖgǵĝḡğġǧģǥɠꞡꝿᵹ\",\n\th:\"ⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ\",\n\thv:\"ƕ\",\n\ti:\"ⓘiìíîĩīĭïḯỉǐȉȋịįḭɨı\",\n\tj:\"ⓙjĵǰɉ\",\n\tk:\"ⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ\",\n\tl:\"ⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇɭ\",\n\tlj:\"lj\",\n\tm:\"ⓜmḿṁṃɱɯ\",\n\tn:\"ⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥлԉ\",\n\tnj:\"nj\",\n\to:\"ⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿꝋꝍɵɔᴑ\",\n\toe:\"œ\",\n\toi:\"ƣ\",\n\too:\"ꝏ\",\n\tou:\"ȣ\",\n\tp:\"ⓟpṕṗƥᵽꝑꝓꝕρ\",\n\tq:\"ⓠqɋꝗꝙ\",\n\tr:\"ⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ\",\n\ts:\"ⓢsśṥŝṡšṧṣṩșşȿꞩꞅẛʂ\",\n\tss:\"ß\",\n\tt:\"ⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ\",\n\tth:\"þ\",\n\ttz:\"ꜩ\",\n\tu:\"ⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ\",\n\tv:\"ⓥvṽṿʋꝟʌ\",\n\tvy:\"ꝡ\",\n\tw:\"ⓦwẁẃŵẇẅẘẉⱳ\",\n\tx:\"ⓧxẋẍ\",\n\ty:\"ⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ\",\n\tz:\"ⓩzźẑżžẓẕƶȥɀⱬꝣ\"\n}\n\n/**\n * code points generated from toCodePoints();\n * removed 65339 to 65345\n */\nexport const code_points = [\n\t[ 67, 67 ],\n\t[ 160, 160 ],\n\t[ 192, 438 ],\n\t[ 452, 652 ],\n\t[ 961, 961 ],\n\t[ 1019, 1019 ],\n\t[ 1083, 1083 ],\n\t[ 1281, 1289 ],\n\t[ 1984, 1984 ],\n\t[ 5095, 5095 ],\n\t[ 7429, 7441 ],\n\t[ 7545, 7549 ],\n\t[ 7680, 7935 ],\n\t[ 8580, 8580 ],\n\t[ 9398, 9449 ],\n\t[ 11360, 11391 ],\n\t[ 42792, 42793 ],\n\t[ 42802, 42851 ],\n\t[ 42873, 42897 ],\n\t[ 42912, 42922 ],\n\t[ 64256, 64260 ],\n\t[ 65313, 65338 ],\n\t[ 65345, 65370 ]\n];\n\n/**\n * Remove accents\n * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703\n *\n */\nexport const asciifold = (str:string):string => {\n\treturn str\n\t\t.normalize('NFKD')\n\t\t.replace(accent_reg, '')\n\t\t.toLowerCase()\n\t\t.replace(convert_pat,function(foreignletter) {\n\t\t\treturn latin_convert[foreignletter];\n\t\t});\n};\n\n\n/**\n * Convert list of diacritics to array of code points\n *\n */\n// @ts-ignore\nfunction toCodePoints(tolerance=8){\n\tvar char_codes:number[] = [];\n\n\tfor( let letter in DIACRITICS ){\n\t\tlet _diacritics = DIACRITICS[letter];\n\t\tfor( let n = 0; n < _diacritics.length; n++ ){\n\t\t\tvar code_point = _diacritics.codePointAt(n);\n\t\t\tif( code_point ) char_codes.push( code_point );\n\t\t}\n\t}\n\n\t//https://stackoverflow.com/questions/40431572/is-there-a-simple-way-to-group-js-array-values-by-range\n\tchar_codes.sort((a, b) => a - b);\n\tvar accumulator: number[][] = [];\n\tchar_codes.reduce(function (accumulator, currentValue, index, source) {\n\n\t\tif( !index ){\n\t\t\taccumulator.push( [currentValue,currentValue] );\n\n\t\t}else if( currentValue - source[index - 1] > tolerance ){\n\t\t\taccumulator.push( [currentValue,currentValue] );\n\n\t\t}else{\n\n\t\t\tlet range = accumulator.pop();\n\t\t\tif( range ){\n\t\t\t\taccumulator.push( [range[0],currentValue]);\n\t\t\t}\n\t\t}\n\n\t\treturn accumulator;\n\t}, accumulator);\n\n}\n\n/**\n * Convert array of strings to a regular expression\n *\tex ['ab','a'] => (?:ab|a)\n * \tex ['a','b'] => [ab]\n *\n */\nexport const arrayToPattern = (chars:string[],glue:string='|'):string =>{\n\t\n\tif( chars.length == 1 ){\n\t\treturn chars[0];\n\t}\n\t\n\tvar longest = 1;\n\tchars.forEach((a)=>{longest = Math.max(longest,a.length)});\n\n\tif( longest == 1 ){\n\t\treturn '['+chars.join('')+']';\n\t}\n\n\treturn '(?:'+chars.join(glue)+')';\t\n};\n\n/**\n * Get all possible combinations of substrings that add up to the given string\n * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string\n *\n */\nexport const allSubstrings = (input:string):string[][] => {\n\n if( input.length === 1) return [[input]];\n\n var result:string[][] = [];\n allSubstrings(input.substring(1)).forEach(function(subresult) {\n var tmp = subresult.slice(0);\n tmp[0] = input.charAt(0) + tmp[0];\n result.push(tmp);\n\n tmp = subresult.slice(0);\n tmp.unshift(input.charAt(0));\n result.push(tmp);\n });\n \n return result;\n}\n\n/**\n * Generate a list of diacritics from the list of code points\n *\n */\nexport const generateDiacritics = ():TDiacraticList => {\t\n\n\tvar diacritics:{[key:string]:string[]} = {};\n\tcode_points.forEach((code_range)=>{\n\n\t\tfor(let i = code_range[0]; i <= code_range[1]; i++){\n\t\t\t\n\t\t\tlet diacritic\t= String.fromCharCode(i);\n\t\t\tlet\tlatin\t\t= asciifold(diacritic);\n\n\t\t\tif( latin == diacritic.toLowerCase() ){\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif( !(latin in diacritics) ){\n\t\t\t\tdiacritics[latin] = [latin];\n\t\t\t}\n\t\t\t\n\t\t\tvar patt = new RegExp( arrayToPattern(diacritics[latin]),'iu');\n\t\t\tif( diacritic.match(patt) ){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\n\t\t\tdiacritics[latin].push(diacritic);\n\t\t}\n\t});\n\t\t\n\tvar latin_chars = Object.keys(diacritics);\n\t\n\t\n\t// latin character pattern\n\t// match longer substrings first\n\tlatin_chars\t\t= latin_chars.sort((a, b) => b.length - a.length );\n\tlatin_pat\t\t= new RegExp('('+ arrayToPattern(latin_chars) + accent_pat + '*)','g');\n\t\n\t\n\t// build diacritic patterns\n\t// ae needs: \n\t//\t(?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))\n\tvar diacritic_patterns:TDiacraticList = {};\n\tlatin_chars.sort((a,b) => a.length -b.length).forEach((latin)=>{\n\t\t\n\t\tvar substrings\t= allSubstrings(latin);\n\t\tvar pattern = substrings.map((sub_pat)=>{\n\t\t\t\n\t\t\tsub_pat = sub_pat.map((l)=>{\n\t\t\t\tif( diacritics.hasOwnProperty(l) ){\n\t\t\t\t\treturn arrayToPattern(diacritics[l]);\n\t\t\t\t}\n\t\t\t\treturn l;\n\t\t\t});\n\t\t\t\n\t\t\treturn arrayToPattern(sub_pat,'');\n\t\t});\n\t\t\n\t\tdiacritic_patterns[latin] = arrayToPattern(pattern);\t\t\n\t});\n\t\t\t\n\treturn diacritic_patterns;\n}\n\n/**\n * Expand a regular expression pattern to include diacritics\n * \teg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ/\n *\n */\nexport const diacriticRegexPoints = (regex:string):string => {\n\n\tif( diacritic_patterns === undefined ){\n\t\tdiacritic_patterns = generateDiacritics();\n\t}\n\t\n\tconst decomposed\t\t= regex.normalize('NFKD').toLowerCase();\n\t\n\treturn decomposed.split(latin_pat).map((part:string)=>{\n\t\t\n\t\tif( part == '' ){\n\t\t\treturn '';\n\t\t}\n\t\t\n\t\t// \"ffl\" or \"ffl\"\n\t\tconst no_accent = asciifold(part);\t\t\t\t\n\t\tif( diacritic_patterns.hasOwnProperty(no_accent) ){\n\t\t\treturn diacritic_patterns[no_accent];\n\t\t}\n\t\t\n\t\t// 'أهلا' (\\u{623}\\u{647}\\u{644}\\u{627}) or 'أهلا' (\\u{627}\\u{654}\\u{647}\\u{644}\\u{627})\n\t\tconst composed_part = part.normalize('NFC');\n\t\tif( composed_part != part ){\n\t\t\treturn arrayToPattern([part,composed_part]);\n\t\t}\n\t\t\t\t\n\t\treturn part;\n\t}).join('');\n\t\n}\n","\n// @ts-ignore TS2691 \"An import path cannot end with a '.ts' extension\"\nimport { asciifold } from './diacritics.ts';\n\n// @ts-ignore TS2691 \"An import path cannot end with a '.ts' extension\"\nimport * as T from './types.ts';\n\n\n/**\n * A property getter resolving dot-notation\n * @param {Object} obj The root object to fetch property on\n * @param {String} name The optionally dotted property name to fetch\n * @return {Object} The resolved property value\n */\nexport const getAttr = (obj:{[key:string]:any}, name:string ) => {\n if (!obj ) return;\n return obj[name];\n};\n\n/**\n * A property getter resolving dot-notation\n * @param {Object} obj The root object to fetch property on\n * @param {String} name The optionally dotted property name to fetch\n * @return {Object} The resolved property value\n */\nexport const getAttrNesting = (obj:{[key:string]:any}, name:string ) => {\n if (!obj ) return;\n var part, names = name.split(\".\");\n\twhile( (part = names.shift()) && (obj = obj[part]));\n return obj;\n};\n\n/**\n * Calculates how close of a match the\n * given value is against a search token.\n *\n */\nexport const scoreValue = (value:string, token:T.Token, weight:number ):number => {\n\tvar score, pos;\n\n\tif (!value) return 0;\n\n\tvalue = value + '';\n\tpos = value.search(token.regex);\n\tif (pos === -1) return 0;\n\n\tscore = token.string.length / value.length;\n\tif (pos === 0) score += 0.5;\n\n\treturn score * weight;\n};\n\n/**\n *\n * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error\n */\nexport const escape_regex = (str:string):string => {\t\n\treturn (str + '').replace(/([\\$\\(\\)\\*\\+\\.\\?\\[\\]\\^\\{\\|\\}\\\\])/gu, '\\\\$1');\n};\n\n\n/**\n * Cast object property to an array if it exists and has a value\n *\n */\nexport const propToArray = (obj:{[key:string]:any}, key:string) => {\n\tvar value = obj[key];\n\t\n\tif( typeof value == 'function' ) return value;\n\t\n\tif( value && !Array.isArray(value) ){\n\t\tobj[key] = [value];\n\t}\n}\n\n\n/**\n * Iterates over arrays and hashes.\n *\n * ```\n * iterate(this.items, function(item, id) {\n * // invoked for each item\n * });\n * ```\n *\n */\nexport const iterate = (object:[]|{[key:string]:any}, callback:(value:any,key:number|string)=>any) => {\n\n\tif ( Array.isArray(object)) {\n\t\tobject.forEach(callback);\n\n\t}else{\n\n\t\tfor (var key in object) {\n\t\t\tif (object.hasOwnProperty(key)) {\n\t\t\t\tcallback(object[key], key);\n\t\t\t}\n\t\t}\n\t}\n};\n\n\n\nexport const cmp = (a:number|string, b:number|string) => {\n\tif (typeof a === 'number' && typeof b === 'number') {\n\t\treturn a > b ? 1 : (a < b ? -1 : 0);\n\t}\n\ta = asciifold(a + '').toLowerCase();\n\tb = asciifold(b + '').toLowerCase();\n\tif (a > b) return 1;\n\tif (b > a) return -1;\n\treturn 0;\n};\n","\nimport { iterate } from '@orchidjs/sifter/lib/utils';\n\n/**\n * Return a dom element from either a dom query string, jQuery object, a dom element or html string\n * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518\n *\n * param query should be {}\n */\nexport const getDom = ( query:any ):HTMLElement => {\n\n\tif( query.jquery ){\n\t\treturn query[0];\n\t}\n\n\tif( query instanceof HTMLElement ){\n\t\treturn query;\n\t}\n\n\tif( isHtmlString(query) ){\n\t\tlet div = document.createElement('div');\n\t\tdiv.innerHTML = query.trim(); // Never return a text node of whitespace as the result\n\t\treturn div.firstChild as HTMLElement;\n\t}\n\n\treturn document.querySelector(query);\n};\n\nexport const isHtmlString = (arg:any): boolean => {\n\tif( typeof arg === 'string' && arg.indexOf('<') > -1 ){\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nexport const escapeQuery = (query:string):string => {\n\treturn query.replace(/['\"\\\\]/g, '\\\\$&');\n}\n\n/**\n * Dispatch an event\n *\n */\nexport const triggerEvent = ( dom_el:HTMLElement, event_name:string ):void => {\n\tvar event = document.createEvent('HTMLEvents');\n\tevent.initEvent(event_name, true, false);\n\tdom_el.dispatchEvent(event)\n};\n\n/**\n * Apply CSS rules to a dom element\n *\n */\nexport const applyCSS = ( dom_el:HTMLElement, css:{ [key: string]: string|number }):void => {\n\tObject.assign(dom_el.style, css);\n}\n\n\n/**\n * Add css classes\n *\n */\nexport const addClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n\tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map( cls => {\n\t\t\tel.classList.add( cls );\n\t\t});\n\t});\n}\n\n/**\n * Remove css classes\n *\n */\n export const removeClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n \tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map(cls => {\n\t \t\tel.classList.remove( cls );\n\t\t});\n \t});\n }\n\n\n/**\n * Return arguments\n *\n */\nexport const classesArray = (args:string[]|string[][]):string[] => {\n\tvar classes:string[] = [];\n\titerate( args, (_classes) =>{\n\t\tif( typeof _classes === 'string' ){\n\t\t\t_classes = _classes.trim().split(/[\\11\\12\\14\\15\\40]/);\n\t\t}\n\t\tif( Array.isArray(_classes) ){\n\t\t\tclasses = classes.concat(_classes);\n\t\t}\n\t});\n\n\treturn classes.filter(Boolean);\n}\n\n\n/**\n * Create an array from arg if it's not already an array\n *\n */\nexport const castAsArray = (arg:any):Array<any> => {\n\tif( !Array.isArray(arg) ){\n \t\targ = [arg];\n \t}\n\treturn arg;\n}\n\n\n/**\n * Get the closest node to the evt.target matching the selector\n * Stops at wrapper\n *\n */\nexport const parentMatch = ( target:null|HTMLElement, selector:string, wrapper?:HTMLElement ):HTMLElement|void => {\n\n\tif( wrapper && !wrapper.contains(target) ){\n\t\treturn;\n\t}\n\n\twhile( target && target.matches ){\n\n\t\tif( target.matches(selector) ){\n\t\t\treturn target;\n\t\t}\n\n\t\ttarget = target.parentNode as HTMLElement;\n\t}\n}\n\n\n/**\n * Get the first or last item from an array\n *\n * > 0 - right (last)\n * <= 0 - left (first)\n *\n */\nexport const getTail = ( list:Array<any>|NodeList, direction:number=0 ):any => {\n\n\tif( direction > 0 ){\n\t\treturn list[list.length-1];\n\t}\n\n\treturn list[0];\n}\n\n/**\n * Return true if an object is empty\n *\n */\nexport const isEmptyObject = (obj:object):boolean => {\n\treturn (Object.keys(obj).length === 0);\n}\n\n\n/**\n * Get the index of an element amongst sibling nodes of the same type\n *\n */\nexport const nodeIndex = ( el:null|Element, amongst?:string ):number => {\n\tif (!el) return -1;\n\n\tamongst = amongst || el.nodeName;\n\n\tvar i = 0;\n\twhile( el = el.previousElementSibling ){\n\n\t\tif( el.matches(amongst) ){\n\t\t\ti++;\n\t\t}\n\t}\n\treturn i;\n}\n\n\n/**\n * Set attributes of an element\n *\n */\nexport const setAttr = (el:Element,attrs:{ [key: string]: null|string|number }) => {\n\titerate( attrs,(val,attr) => {\n\t\tif( val == null ){\n\t\t\tel.removeAttribute(attr as string);\n\t\t}else{\n\t\t\tel.setAttribute(attr as string, ''+val);\n\t\t}\n\t});\n}\n\n\n/**\n * Replace a node\n */\nexport const replaceNode = ( existing:Node, replacement:Node ) => {\n\tif( existing.parentNode ) existing.parentNode.replaceChild(replacement, existing);\n}\n","/**\n * Plugin: \"restore_on_backspace\" (Tom Select)\n * Copyright (c) contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this\n * file except in compliance with the License. You may obtain a copy of the License at:\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n * ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n *\n */\n\nimport TomSelect from '../../tom-select';\nimport { TomOption } from '../../types/index';\nimport { addClasses } from '../../vanilla';\n\nexport default function(this:TomSelect) {\n\tconst self\t\t\t\t\t\t\t= this;\n\tconst orig_canLoad\t\t\t\t\t= self.canLoad;\n\tconst orig_clearActiveOption\t\t= self.clearActiveOption;\n\tconst orig_loadCallback\t\t\t\t= self.loadCallback;\n\n\tvar pagination:{[key:string]:any}\t= {};\n\tvar dropdown_content:HTMLElement;\n\tvar loading_more\t\t\t\t\t= false;\n\tvar load_more_opt:HTMLElement;\n\n\n\tif( !self.settings.shouldLoadMore ){\n\n\t\t// return true if additional results should be loaded\n\t\tself.settings.shouldLoadMore = function():boolean{\n\n\t\t\tconst scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop);\n\t\t\tif( scroll_percent > 0.9 ){\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif( self.activeOption ){\n\t\t\t\tvar selectable\t= self.selectable();\n\t\t\t\tvar index\t\t= [...selectable].indexOf(self.activeOption);\n\t\t\t\tif( index >= (selectable.length-2) ){\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn false;\n\t\t}\n\t}\n\n\n\tif( !self.settings.firstUrl ){\n\t\tthrow 'virtual_scroll plugin requires a firstUrl() method';\n\t\treturn;\n\t}\n\n\n\t// in order for virtual scrolling to work,\n\t// options need to be ordered the same way they're returned from the remote data source\n\tself.settings.sortField\t\t\t= [{field:'$order'},{field:'$score'}];\n\n\n\t// can we load more results for given query?\n\tfunction canLoadMore(query:string):boolean{\n\n\t\tif( typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions ){\n\t\t\treturn false;\n\t\t}\n\n\t\tif( (query in pagination) && pagination[query] ){\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\n\t// set the next url that will be\n\tself.setNextUrl = function(value:string,next_url:any):void{\n\t\tpagination[value] = next_url;\n\t};\n\n\t// getUrl() to be used in settings.load()\n\tself.getUrl = function(query:string):any{\n\n\t\tif( query in pagination ){\n\t\t\tconst next_url = pagination[query];\n\t\t\tpagination[query] = false;\n\t\t\treturn next_url;\n\t\t}\n\n\t\t// if the user goes back to a previous query\n\t\t// we need to load the first page again\n\t\tpagination = {};\n\n\t\treturn self.settings.firstUrl.call(self,query);\n\t};\n\n\n\t// don't clear the active option (and cause unwanted dropdown scroll)\n\t// while loading more results\n\tself.hook('instead','clearActiveOption',()=>{\n\n\t\tif( loading_more ){\n\t\t\treturn;\n\t\t}\n\n\t\treturn orig_clearActiveOption.call(self);\n\t});\n\n\t// override the canLoad method\n\tself.hook('instead','canLoad',(query:string)=>{\n\n\t\t// first time the query has been seen\n\t\tif( !(query in pagination) ){\n\t\t\treturn orig_canLoad.call(self,query);\n\t\t}\n\n\t\treturn canLoadMore(query);\n\t});\n\n\n\t// wrap the load\n\tself.hook('instead','loadCallback',( options:TomOption[], optgroups:TomOption[])=>{\n\n\t\tif( !loading_more ){\n\t\t\tself.clearOptions();\n\t\t}else if( load_more_opt && options.length > 0 ){\n\t\t\tload_more_opt.dataset.value\t\t= options[0][self.settings.valueField];\n\t\t}\n\n\t\torig_loadCallback.call( self, options, optgroups);\n\n\t\tloading_more = false;\n\t});\n\n\n\t// add templates to dropdown\n\t//\tloading_more if we have another url in the queue\n\t//\tno_more_results if we don't have another url in the queue\n\tself.hook('after','refreshOptions',()=>{\n\n\t\tconst query\t\t= self.lastValue;\n\t\tvar option;\n\n\t\tif( canLoadMore(query) ){\n\t\t\toption = self.render('loading_more',{query:query});\n\t\t\tif( option ){\n\t\t\t\toption.setAttribute('data-selectable',''); // so that navigating dropdown with [down] keypresses can navigate to this node\n\t\t\t\tload_more_opt = option;\n\t\t\t}\n\n\t\t}else if( (query in pagination) && !dropdown_content.querySelector('.no-results') ){\n\t\t\toption = self.render('no_more_results',{query:query});\n\t\t}\n\n\t\tif( option ){\n\t\t\taddClasses(option,self.settings.optionClass);\n\t\t\tdropdown_content.append( option );\n\t\t}\n\n\t});\n\n\n\t// add scroll listener and default templates\n\tself.on('initialize',()=>{\n\t\tdropdown_content = self.dropdown_content;\n\n\t\t// default templates\n\t\tself.settings.render = Object.assign({}, {\n\t\t\tloading_more:function(){\n\t\t\t\treturn `<div class=\"loading-more-results\">Loading more results ... </div>`;\n\t\t\t},\n\t\t\tno_more_results:function(){\n\t\t\t\treturn `<div class=\"no-more-results\">No more results</div>`;\n\t\t\t}\n\t\t},self.settings.render);\n\n\n\t\t// watch dropdown content scroll position\n\t\tdropdown_content.addEventListener('scroll',function(){\n\n\t\t\tif( !self.settings.shouldLoadMore.call(self) ){\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// !important: this will get checked again in load() but we still need to check here otherwise loading_more will be set to true\n\t\t\tif( !canLoadMore(self.lastValue) ){\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// don't call load() too much\n\t\t\tif( loading_more ) return;\n\n\n\t\t\tloading_more = true;\n\t\t\tself.load.call(self,self.lastValue);\n\t\t});\n\t});\n\n};\n"],"names":["latin_convert","RegExp","Object","keys","join","iterate","object","callback","Array","isArray","forEach","key","hasOwnProperty","addClasses","elmts","classes","norm_classes","classesArray","castAsArray","map","el","cls","classList","add","args","_classes","trim","split","concat","filter","Boolean","arg","self","orig_canLoad","canLoad","orig_clearActiveOption","clearActiveOption","orig_loadCallback","loadCallback","pagination","dropdown_content","loading_more","load_more_opt","settings","shouldLoadMore","scroll_percent","clientHeight","scrollHeight","scrollTop","activeOption","selectable","index","indexOf","length","firstUrl","sortField","field","canLoadMore","query","maxOptions","children","setNextUrl","value","next_url","getUrl","call","hook","options","optgroups","clearOptions","dataset","valueField","lastValue","option","render","setAttribute","querySelector","optionClass","append","on","assign","no_more_results","addEventListener","load"],"mappings":";;;;;;;;;;;CAGA;CAOA,MAAMA,aAA4B,GAAG;CACpC,OAAK,IAD+B;CAEpC,OAAK,GAF+B;CAGpC,OAAK;CAH+B,CAArC;CAMoB,IAAIC,MAAJ,CAAWC,MAAM,CAACC,IAAP,CAAYH,aAAZ,EAA2BI,IAA3B,CAAgC,GAAhC,CAAX,EAAgD,GAAhD;;CCfpB;CA2EA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;CACO,MAAMC,OAAO,GAAG,CAACC,MAAD,EAA+BC,QAA/B,KAA+E;CAErG,MAAKC,KAAK,CAACC,OAAN,CAAcH,MAAd,CAAL,EAA4B;CAC3BA,IAAAA,MAAM,CAACI,OAAP,CAAeH,QAAf;CAEA,GAHD,MAGK;CAEJ,SAAK,IAAII,GAAT,IAAgBL,MAAhB,EAAwB;CACvB,UAAIA,MAAM,CAACM,cAAP,CAAsBD,GAAtB,CAAJ,EAAgC;CAC/BJ,QAAAA,QAAQ,CAACD,MAAM,CAACK,GAAD,CAAP,EAAcA,GAAd,CAAR;CACA;CACD;CACD;CACD,CAbM;;CC5BP;CACA;CACA;CACA;;CACO,MAAME,UAAU,GAAG,CAAEC,KAAF,EAAmC,GAAGC,OAAtC,KAAuE;CAEhG,MAAIC,YAAY,GAAIC,YAAY,CAACF,OAAD,CAAhC;CACAD,EAAAA,KAAK,GAAMI,WAAW,CAACJ,KAAD,CAAtB;CAEAA,EAAAA,KAAK,CAACK,GAAN,CAAWC,EAAE,IAAI;CAChBJ,IAAAA,YAAY,CAACG,GAAb,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,MAAI;CACxBvC,IAAAA,gBAAgB,GAAGR,IAAI,CAACQ,gBAAxB,CADwB;;CAIxBR,IAAAA,IAAI,CAACW,QAAL,CAAc+B,MAAd,GAAuBxE,MAAM,CAAC8E,MAAP,CAAc,EAAd,EAAkB;CACxCvC,MAAAA,YAAY,EAAC,YAAU;CACtB,eAAQ,mEAAR;CACA,OAHuC;CAIxCwC,MAAAA,eAAe,EAAC,YAAU;CACzB,eAAQ,oDAAR;CACA;CANuC,KAAlB,EAOrBjD,IAAI,CAACW,QAAL,CAAc+B,MAPO,CAAvB,CAJwB;;CAexBlC,IAAAA,gBAAgB,CAAC0C,gBAAjB,CAAkC,QAAlC,EAA2C,YAAU;CAEpD,UAAI,CAAClD,IAAI,CAACW,QAAL,CAAcC,cAAd,CAA6BqB,IAA7B,CAAkCjC,IAAlC,CAAL,EAA8C;CAC7C;CACA,OAJmD;;;CAOpD,UAAI,CAACyB,WAAW,CAACzB,IAAI,CAACwC,SAAN,CAAhB,EAAkC;CACjC;CACA,OATmD;;;CAYpD,UAAI/B,YAAJ,EAAmB;CAGnBA,MAAAA,YAAY,GAAG,IAAf;CACAT,MAAAA,IAAI,CAACmD,IAAL,CAAUlB,IAAV,CAAejC,IAAf,EAAoBA,IAAI,CAACwC,SAAzB;CACA,KAjBD;CAkBA,GAjCD;CAmCA;;;;;;;;"}
1
+ {"version":3,"file":"virtual_scroll.js","sources":["../../../node_modules/@orchidjs/sifter/lib/diacritics.ts","../../../node_modules/@orchidjs/sifter/lib/utils.ts","../../../src/vanilla.ts","../../../src/plugins/virtual_scroll/plugin.ts"],"sourcesContent":["\n// @ts-ignore TS2691 \"An import path cannot end with a '.ts' extension\"\nimport { escape_regex } from './utils.ts';\n\ntype TDiacraticList = {[key:string]:string};\n\n// https://github.com/andrewrk/node-diacritics/blob/master/index.js\n\nvar latin_pat:RegExp;\nconst accent_pat = '[\\u0300-\\u036F\\u{b7}\\u{2be}]'; // \\u{2bc}\nconst accent_reg = new RegExp(accent_pat,'gu');\nvar diacritic_patterns:TDiacraticList;\n\nconst latin_convert:TDiacraticList = {\n\t'æ': 'ae',\n\t'ⱥ': 'a',\n\t'ø': 'o',\n};\n\nconst convert_pat = new RegExp(Object.keys(latin_convert).join('|'),'gu');\n\nconst code_points:[[number,number]] = [[ 0, 65535 ]];\n\n/**\n * Remove accents\n * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703\n *\n */\nexport const asciifold = (str:string):string => {\n\treturn str\n\t\t.normalize('NFKD')\n\t\t.replace(accent_reg, '')\n\t\t.toLowerCase()\n\t\t.replace(convert_pat,function(foreignletter) {\n\t\t\treturn latin_convert[foreignletter];\n\t\t});\n};\n\n/**\n * Convert array of strings to a regular expression\n *\tex ['ab','a'] => (?:ab|a)\n * \tex ['a','b'] => [ab]\n *\n */\nexport const arrayToPattern = (chars:string[],glue:string='|'):string =>{\n\n\tif( chars.length == 1 ){\n\t\treturn chars[0];\n\t}\n\n\tvar longest = 1;\n\tchars.forEach((a)=>{longest = Math.max(longest,a.length)});\n\n\tif( longest == 1 ){\n\t\treturn '['+chars.join('')+']';\n\t}\n\n\treturn '(?:'+chars.join(glue)+')';\n};\n\nexport const escapeToPattern = (chars:string[]):string =>{\n\tconst escaped = chars.map((diacritic) => escape_regex(diacritic));\n\treturn arrayToPattern(escaped);\n};\n\n/**\n * Get all possible combinations of substrings that add up to the given string\n * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string\n *\n */\nexport const allSubstrings = (input:string):string[][] => {\n\n if( input.length === 1) return [[input]];\n\n var result:string[][] = [];\n allSubstrings(input.substring(1)).forEach(function(subresult) {\n var tmp = subresult.slice(0);\n tmp[0] = input.charAt(0) + tmp[0];\n result.push(tmp);\n\n tmp = subresult.slice(0);\n tmp.unshift(input.charAt(0));\n result.push(tmp);\n });\n\n return result;\n}\n\n/**\n * Generate a list of diacritics from the list of code points\n *\n */\nexport const generateDiacritics = (code_points:[[number,number]]):TDiacraticList => {\n\n\tvar diacritics:{[key:string]:string[]} = {};\n\tcode_points.forEach((code_range)=>{\n\n\t\tfor(let i = code_range[0]; i <= code_range[1]; i++){\n\n\t\t\tlet diacritic\t= String.fromCharCode(i);\n\t\t\tlet\tlatin\t\t= asciifold(diacritic);\n\n\t\t\tif( latin == diacritic.toLowerCase() ){\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// skip when latin is a string longer than 3 characters long\n\t\t\t// bc the resulting regex patterns will be long\n\t\t\t// eg:\n\t\t\t// latin صلى الله عليه وسلم length 18 code point 65018\n\t\t\t// latin جل جلاله length 8 code point 65019\n\t\t\tif( latin.length > 3 ){\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif( !(latin in diacritics) ){\n\t\t\t\tdiacritics[latin] = [latin];\n\t\t\t}\n\n\t\t\tvar patt = new RegExp( escapeToPattern(diacritics[latin]),'iu');\n\t\t\tif( diacritic.match(patt) ){\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tdiacritics[latin].push(diacritic);\n\t\t}\n\t});\n\n\t// filter out if there's only one character in the list\n\tlet latin_chars = Object.keys(diacritics);\n\tfor( let i = 0; i < latin_chars.length; i++){\n\t\tconst latin = latin_chars[i];\n\t\tif( diacritics[latin].length < 2 ){\n\t\t\tdelete diacritics[latin];\n\t\t}\n\t}\n\n\n\t// latin character pattern\n\t// match longer substrings first\n\tlatin_chars\t\t= Object.keys(diacritics).sort((a, b) => b.length - a.length );\n\tlatin_pat\t\t= new RegExp('('+ escapeToPattern(latin_chars) + accent_pat + '*)','gu');\n\n\n\t// build diacritic patterns\n\t// ae needs:\n\t//\t(?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))\n\tvar diacritic_patterns:TDiacraticList = {};\n\tlatin_chars.sort((a,b) => a.length -b.length).forEach((latin)=>{\n\n\t\tvar substrings\t= allSubstrings(latin);\n\t\tvar pattern = substrings.map((sub_pat)=>{\n\n\t\t\tsub_pat = sub_pat.map((l)=>{\n\t\t\t\tif( diacritics.hasOwnProperty(l) ){\n\t\t\t\t\treturn escapeToPattern(diacritics[l]);\n\t\t\t\t}\n\t\t\t\treturn l;\n\t\t\t});\n\n\t\t\treturn arrayToPattern(sub_pat,'');\n\t\t});\n\n\t\tdiacritic_patterns[latin] = arrayToPattern(pattern);\n\t});\n\n\n\treturn diacritic_patterns;\n}\n\n/**\n * Expand a regular expression pattern to include diacritics\n * \teg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ/\n *\n */\nexport const diacriticRegexPoints = (regex:string):string => {\n\n\tif( diacritic_patterns === undefined ){\n\t\tdiacritic_patterns = generateDiacritics(code_points);\n\t}\n\n\tconst decomposed\t\t= regex.normalize('NFKD').toLowerCase();\n\n\treturn decomposed.split(latin_pat).map((part:string)=>{\n\n\t\t// \"ffl\" or \"ffl\"\n\t\tconst no_accent = asciifold(part);\n\t\tif( no_accent == '' ){\n\t\t\treturn '';\n\t\t}\n\n\t\tif( diacritic_patterns.hasOwnProperty(no_accent) ){\n\t\t\treturn diacritic_patterns[no_accent];\n\t\t}\n\n\t\treturn part;\n\t}).join('');\n\n}\n","\n// @ts-ignore TS2691 \"An import path cannot end with a '.ts' extension\"\nimport { asciifold } from './diacritics.ts';\n\n// @ts-ignore TS2691 \"An import path cannot end with a '.ts' extension\"\nimport * as T from './types.ts';\n\n\n/**\n * A property getter resolving dot-notation\n * @param {Object} obj The root object to fetch property on\n * @param {String} name The optionally dotted property name to fetch\n * @return {Object} The resolved property value\n */\nexport const getAttr = (obj:{[key:string]:any}, name:string ) => {\n if (!obj ) return;\n return obj[name];\n};\n\n/**\n * A property getter resolving dot-notation\n * @param {Object} obj The root object to fetch property on\n * @param {String} name The optionally dotted property name to fetch\n * @return {Object} The resolved property value\n */\nexport const getAttrNesting = (obj:{[key:string]:any}, name:string ) => {\n if (!obj ) return;\n var part, names = name.split(\".\");\n\twhile( (part = names.shift()) && (obj = obj[part]));\n return obj;\n};\n\n/**\n * Calculates how close of a match the\n * given value is against a search token.\n *\n */\nexport const scoreValue = (value:string, token:T.Token, weight:number ):number => {\n\tvar score, pos;\n\n\tif (!value) return 0;\n\n\tvalue = value + '';\n\tpos = value.search(token.regex);\n\tif (pos === -1) return 0;\n\n\tscore = token.string.length / value.length;\n\tif (pos === 0) score += 0.5;\n\n\treturn score * weight;\n};\n\n/**\n *\n * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error\n */\nexport const escape_regex = (str:string):string => {\n\treturn (str + '').replace(/([\\$\\(\\)\\*\\+\\.\\?\\[\\]\\^\\{\\|\\}\\\\])/gu, '\\\\$1');\n};\n\n\n/**\n * Cast object property to an array if it exists and has a value\n *\n */\nexport const propToArray = (obj:{[key:string]:any}, key:string) => {\n\tvar value = obj[key];\n\n\tif( typeof value == 'function' ) return value;\n\n\tif( value && !Array.isArray(value) ){\n\t\tobj[key] = [value];\n\t}\n}\n\n\n/**\n * Iterates over arrays and hashes.\n *\n * ```\n * iterate(this.items, function(item, id) {\n * // invoked for each item\n * });\n * ```\n *\n */\nexport const iterate = (object:[]|{[key:string]:any}, callback:(value:any,key:number|string)=>any) => {\n\n\tif ( Array.isArray(object)) {\n\t\tobject.forEach(callback);\n\n\t}else{\n\n\t\tfor (var key in object) {\n\t\t\tif (object.hasOwnProperty(key)) {\n\t\t\t\tcallback(object[key], key);\n\t\t\t}\n\t\t}\n\t}\n};\n\n\n\nexport const cmp = (a:number|string, b:number|string) => {\n\tif (typeof a === 'number' && typeof b === 'number') {\n\t\treturn a > b ? 1 : (a < b ? -1 : 0);\n\t}\n\ta = asciifold(a + '').toLowerCase();\n\tb = asciifold(b + '').toLowerCase();\n\tif (a > b) return 1;\n\tif (b > a) return -1;\n\treturn 0;\n};\n","\nimport { iterate } from '@orchidjs/sifter/lib/utils';\n\n/**\n * Return a dom element from either a dom query string, jQuery object, a dom element or html string\n * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518\n *\n * param query should be {}\n */\nexport const getDom = ( query:any ):HTMLElement => {\n\n\tif( query.jquery ){\n\t\treturn query[0];\n\t}\n\n\tif( query instanceof HTMLElement ){\n\t\treturn query;\n\t}\n\n\tif( isHtmlString(query) ){\n\t\tlet div = document.createElement('div');\n\t\tdiv.innerHTML = query.trim(); // Never return a text node of whitespace as the result\n\t\treturn div.firstChild as HTMLElement;\n\t}\n\n\treturn document.querySelector(query);\n};\n\nexport const isHtmlString = (arg:any): boolean => {\n\tif( typeof arg === 'string' && arg.indexOf('<') > -1 ){\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nexport const escapeQuery = (query:string):string => {\n\treturn query.replace(/['\"\\\\]/g, '\\\\$&');\n}\n\n/**\n * Dispatch an event\n *\n */\nexport const triggerEvent = ( dom_el:HTMLElement, event_name:string ):void => {\n\tvar event = document.createEvent('HTMLEvents');\n\tevent.initEvent(event_name, true, false);\n\tdom_el.dispatchEvent(event)\n};\n\n/**\n * Apply CSS rules to a dom element\n *\n */\nexport const applyCSS = ( dom_el:HTMLElement, css:{ [key: string]: string|number }):void => {\n\tObject.assign(dom_el.style, css);\n}\n\n\n/**\n * Add css classes\n *\n */\nexport const addClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n\tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map( cls => {\n\t\t\tel.classList.add( cls );\n\t\t});\n\t});\n}\n\n/**\n * Remove css classes\n *\n */\n export const removeClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n \tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map(cls => {\n\t \t\tel.classList.remove( cls );\n\t\t});\n \t});\n }\n\n\n/**\n * Return arguments\n *\n */\nexport const classesArray = (args:string[]|string[][]):string[] => {\n\tvar classes:string[] = [];\n\titerate( args, (_classes) =>{\n\t\tif( typeof _classes === 'string' ){\n\t\t\t_classes = _classes.trim().split(/[\\11\\12\\14\\15\\40]/);\n\t\t}\n\t\tif( Array.isArray(_classes) ){\n\t\t\tclasses = classes.concat(_classes);\n\t\t}\n\t});\n\n\treturn classes.filter(Boolean);\n}\n\n\n/**\n * Create an array from arg if it's not already an array\n *\n */\nexport const castAsArray = (arg:any):Array<any> => {\n\tif( !Array.isArray(arg) ){\n \t\targ = [arg];\n \t}\n\treturn arg;\n}\n\n\n/**\n * Get the closest node to the evt.target matching the selector\n * Stops at wrapper\n *\n */\nexport const parentMatch = ( target:null|HTMLElement, selector:string, wrapper?:HTMLElement ):HTMLElement|void => {\n\n\tif( wrapper && !wrapper.contains(target) ){\n\t\treturn;\n\t}\n\n\twhile( target && target.matches ){\n\n\t\tif( target.matches(selector) ){\n\t\t\treturn target;\n\t\t}\n\n\t\ttarget = target.parentNode as HTMLElement;\n\t}\n}\n\n\n/**\n * Get the first or last item from an array\n *\n * > 0 - right (last)\n * <= 0 - left (first)\n *\n */\nexport const getTail = ( list:Array<any>|NodeList, direction:number=0 ):any => {\n\n\tif( direction > 0 ){\n\t\treturn list[list.length-1];\n\t}\n\n\treturn list[0];\n}\n\n/**\n * Return true if an object is empty\n *\n */\nexport const isEmptyObject = (obj:object):boolean => {\n\treturn (Object.keys(obj).length === 0);\n}\n\n\n/**\n * Get the index of an element amongst sibling nodes of the same type\n *\n */\nexport const nodeIndex = ( el:null|Element, amongst?:string ):number => {\n\tif (!el) return -1;\n\n\tamongst = amongst || el.nodeName;\n\n\tvar i = 0;\n\twhile( el = el.previousElementSibling ){\n\n\t\tif( el.matches(amongst) ){\n\t\t\ti++;\n\t\t}\n\t}\n\treturn i;\n}\n\n\n/**\n * Set attributes of an element\n *\n */\nexport const setAttr = (el:Element,attrs:{ [key: string]: null|string|number }) => {\n\titerate( attrs,(val,attr) => {\n\t\tif( val == null ){\n\t\t\tel.removeAttribute(attr as string);\n\t\t}else{\n\t\t\tel.setAttribute(attr as string, ''+val);\n\t\t}\n\t});\n}\n\n\n/**\n * Replace a node\n */\nexport const replaceNode = ( existing:Node, replacement:Node ) => {\n\tif( existing.parentNode ) existing.parentNode.replaceChild(replacement, existing);\n}\n","/**\n * Plugin: \"restore_on_backspace\" (Tom Select)\n * Copyright (c) contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this\n * file except in compliance with the License. You may obtain a copy of the License at:\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n * ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n *\n */\n\nimport TomSelect from '../../tom-select';\nimport { TomOption } from '../../types/index';\nimport { addClasses } from '../../vanilla';\n\nexport default function(this:TomSelect) {\n\tconst self\t\t\t\t\t\t\t= this;\n\tconst orig_canLoad\t\t\t\t\t= self.canLoad;\n\tconst orig_clearActiveOption\t\t= self.clearActiveOption;\n\tconst orig_loadCallback\t\t\t\t= self.loadCallback;\n\n\tvar pagination:{[key:string]:any}\t= {};\n\tvar dropdown_content:HTMLElement;\n\tvar loading_more\t\t\t\t\t= false;\n\tvar load_more_opt:HTMLElement;\n\tvar default_values: string[]\t\t= [];\n\n\tif( !self.settings.shouldLoadMore ){\n\n\t\t// return true if additional results should be loaded\n\t\tself.settings.shouldLoadMore = ():boolean=>{\n\n\t\t\tconst scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop);\n\t\t\tif( scroll_percent > 0.9 ){\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif( self.activeOption ){\n\t\t\t\tvar selectable\t= self.selectable();\n\t\t\t\tvar index\t\t= [...selectable].indexOf(self.activeOption);\n\t\t\t\tif( index >= (selectable.length-2) ){\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn false;\n\t\t}\n\t}\n\n\n\tif( !self.settings.firstUrl ){\n\t\tthrow 'virtual_scroll plugin requires a firstUrl() method';\n\t\treturn;\n\t}\n\n\n\t// in order for virtual scrolling to work,\n\t// options need to be ordered the same way they're returned from the remote data source\n\tself.settings.sortField\t\t\t= [{field:'$order'},{field:'$score'}];\n\n\n\t// can we load more results for given query?\n\tconst canLoadMore = (query:string):boolean => {\n\n\t\tif( typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions ){\n\t\t\treturn false;\n\t\t}\n\n\t\tif( (query in pagination) && pagination[query] ){\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t};\n\n\tconst clearFilter = (option:TomOption, value:string):boolean => {\n\t\tif( self.items.indexOf(value) >= 0 || default_values.indexOf(value) >= 0 ){\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t};\n\n\n\t// set the next url that will be\n\tself.setNextUrl = (value:string,next_url:any):void => {\n\t\tpagination[value] = next_url;\n\t};\n\n\t// getUrl() to be used in settings.load()\n\tself.getUrl = (query:string):any =>{\n\n\t\tif( query in pagination ){\n\t\t\tconst next_url = pagination[query];\n\t\t\tpagination[query] = false;\n\t\t\treturn next_url;\n\t\t}\n\n\t\t// if the user goes back to a previous query\n\t\t// we need to load the first page again\n\t\tpagination = {};\n\n\t\treturn self.settings.firstUrl.call(self,query);\n\t};\n\n\n\t// don't clear the active option (and cause unwanted dropdown scroll)\n\t// while loading more results\n\tself.hook('instead','clearActiveOption',()=>{\n\n\t\tif( loading_more ){\n\t\t\treturn;\n\t\t}\n\n\t\treturn orig_clearActiveOption.call(self);\n\t});\n\n\t// override the canLoad method\n\tself.hook('instead','canLoad',(query:string)=>{\n\n\t\t// first time the query has been seen\n\t\tif( !(query in pagination) ){\n\t\t\treturn orig_canLoad.call(self,query);\n\t\t}\n\n\t\treturn canLoadMore(query);\n\t});\n\n\n\t// wrap the load\n\tself.hook('instead','loadCallback',( options:TomOption[], optgroups:TomOption[])=>{\n\n\t\tif( !loading_more ){\n\t\t\tself.clearOptions(clearFilter);\n\t\t}else if( load_more_opt && options.length > 0 ){\n\t\t\tload_more_opt.dataset.value\t\t= options[0][self.settings.valueField];\n\t\t}\n\n\t\torig_loadCallback.call( self, options, optgroups);\n\n\t\tloading_more = false;\n\t});\n\n\n\t// add templates to dropdown\n\t//\tloading_more if we have another url in the queue\n\t//\tno_more_results if we don't have another url in the queue\n\tself.hook('after','refreshOptions',()=>{\n\n\t\tconst query\t\t= self.lastValue;\n\t\tvar option;\n\n\t\tif( canLoadMore(query) ){\n\n\t\t\toption = self.render('loading_more',{query:query});\n\t\t\tif( option ){\n\t\t\t\toption.setAttribute('data-selectable',''); // so that navigating dropdown with [down] keypresses can navigate to this node\n\t\t\t\tload_more_opt = option;\n\t\t\t}\n\n\t\t}else if( (query in pagination) && !dropdown_content.querySelector('.no-results') ){\n\t\t\toption = self.render('no_more_results',{query:query});\n\t\t}\n\n\t\tif( option ){\n\t\t\taddClasses(option,self.settings.optionClass);\n\t\t\tdropdown_content.append( option );\n\t\t}\n\n\t});\n\n\n\t// add scroll listener and default templates\n\tself.on('initialize',()=>{\n\t\tdefault_values = Object.keys(self.options);\n\t\tdropdown_content = self.dropdown_content;\n\n\t\t// default templates\n\t\tself.settings.render = Object.assign({}, {\n\t\t\tloading_more:() => {\n\t\t\t\treturn `<div class=\"loading-more-results\">Loading more results ... </div>`;\n\t\t\t},\n\t\t\tno_more_results:() =>{\n\t\t\t\treturn `<div class=\"no-more-results\">No more results</div>`;\n\t\t\t}\n\t\t},self.settings.render);\n\n\n\t\t// watch dropdown content scroll position\n\t\tdropdown_content.addEventListener('scroll',()=>{\n\n\t\t\tif( !self.settings.shouldLoadMore.call(self) ){\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// !important: this will get checked again in load() but we still need to check here otherwise loading_more will be set to true\n\t\t\tif( !canLoadMore(self.lastValue) ){\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// don't call load() too much\n\t\t\tif( loading_more ) return;\n\n\n\t\t\tloading_more = true;\n\t\t\tself.load.call(self,self.lastValue);\n\t\t});\n\t});\n\n};\n"],"names":["latin_convert","RegExp","Object","keys","join","iterate","object","callback","Array","isArray","forEach","key","hasOwnProperty","addClasses","elmts","classes","norm_classes","classesArray","castAsArray","map","el","cls","classList","add","args","_classes","trim","split","concat","filter","Boolean","arg","self","orig_canLoad","canLoad","orig_clearActiveOption","clearActiveOption","orig_loadCallback","loadCallback","pagination","dropdown_content","loading_more","load_more_opt","default_values","settings","shouldLoadMore","scroll_percent","clientHeight","scrollHeight","scrollTop","activeOption","selectable","index","indexOf","length","firstUrl","sortField","field","canLoadMore","query","maxOptions","children","clearFilter","option","value","items","setNextUrl","next_url","getUrl","call","hook","options","optgroups","clearOptions","dataset","valueField","lastValue","render","setAttribute","querySelector","optionClass","append","on","assign","no_more_results","addEventListener","load"],"mappings":";;;;;;;;;;;CACA;CAYA,MAAMA,aAA4B,GAAG;CACpC,OAAK,IAD+B;CAEpC,OAAK,GAF+B;CAGpC,OAAK;CAH+B,CAArC;CAMoB,IAAIC,MAAJ,CAAWC,MAAM,CAACC,IAAP,CAAYH,aAAZ,EAA2BI,IAA3B,CAAgC,GAAhC,CAAX,EAAgD,IAAhD;;CClBpB;CA2EA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;CACO,MAAMC,OAAO,GAAG,CAACC,MAAD,EAA+BC,QAA/B,KAA+E;CAErG,MAAKC,KAAK,CAACC,OAAN,CAAcH,MAAd,CAAL,EAA4B;CAC3BA,IAAAA,MAAM,CAACI,OAAP,CAAeH,QAAf;CAEA,GAHD,MAGK;CAEJ,SAAK,IAAII,GAAT,IAAgBL,MAAhB,EAAwB;CACvB,UAAIA,MAAM,CAACM,cAAP,CAAsBD,GAAtB,CAAJ,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Y,QAAL,CAAcC,cAAd,CAA6BwB,IAA7B,CAAkCrC,IAAlC,CAAL,EAA8C;CAC7C;CACA,OAJ6C;;;CAO9C,UAAI,CAAC0B,WAAW,CAAC1B,IAAI,CAAC4C,SAAN,CAAhB,EAAkC;CACjC;CACA,OAT6C;;;CAY9C,UAAInC,YAAJ,EAAmB;CAGnBA,MAAAA,YAAY,GAAG,IAAf;CACAT,MAAAA,IAAI,CAACsD,IAAL,CAAUjB,IAAV,CAAerC,IAAf,EAAoBA,IAAI,CAAC4C,SAAzB;CACA,KAjBD;CAkBA,GAlCD;CAoCA;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.0.3
2
+ * Tom Select v2.1.0
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
@@ -193,24 +193,20 @@
193
193
  };
194
194
  }
195
195
 
196
+ // @ts-ignore TS2691 "An import path cannot end with a '.ts' extension"
196
197
  // https://github.com/andrewrk/node-diacritics/blob/master/index.js
197
198
  var latin_pat;
198
199
  const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}]'; // \u{2bc}
199
200
 
200
- const accent_reg = new RegExp(accent_pat, 'g');
201
+ const accent_reg = new RegExp(accent_pat, 'gu');
201
202
  var diacritic_patterns;
202
203
  const latin_convert = {
203
204
  'æ': 'ae',
204
205
  'ⱥ': 'a',
205
206
  'ø': 'o'
206
207
  };
207
- const convert_pat = new RegExp(Object.keys(latin_convert).join('|'), 'g');
208
- /**
209
- * code points generated from toCodePoints();
210
- * removed 65339 to 65345
211
- */
212
-
213
- const code_points = [[67, 67], [160, 160], [192, 438], [452, 652], [961, 961], [1019, 1019], [1083, 1083], [1281, 1289], [1984, 1984], [5095, 5095], [7429, 7441], [7545, 7549], [7680, 7935], [8580, 8580], [9398, 9449], [11360, 11391], [42792, 42793], [42802, 42851], [42873, 42897], [42912, 42922], [64256, 64260], [65313, 65338], [65345, 65370]];
208
+ const convert_pat = new RegExp(Object.keys(latin_convert).join('|'), 'gu');
209
+ const code_points = [[0, 65535]];
214
210
  /**
215
211
  * Remove accents
216
212
  * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703
@@ -229,7 +225,6 @@
229
225
  *
230
226
  */
231
227
 
232
-
233
228
  const arrayToPattern = (chars, glue = '|') => {
234
229
  if (chars.length == 1) {
235
230
  return chars[0];
@@ -246,6 +241,10 @@
246
241
 
247
242
  return '(?:' + chars.join(glue) + ')';
248
243
  };
244
+ const escapeToPattern = chars => {
245
+ const escaped = chars.map(diacritic => escape_regex(diacritic));
246
+ return arrayToPattern(escaped);
247
+ };
249
248
  /**
250
249
  * Get all possible combinations of substrings that add up to the given string
251
250
  * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string
@@ -270,7 +269,7 @@
270
269
  *
271
270
  */
272
271
 
273
- const generateDiacritics = () => {
272
+ const generateDiacritics = code_points => {
274
273
  var diacritics = {};
275
274
  code_points.forEach(code_range => {
276
275
  for (let i = code_range[0]; i <= code_range[1]; i++) {
@@ -279,13 +278,22 @@
279
278
 
280
279
  if (latin == diacritic.toLowerCase()) {
281
280
  continue;
281
+ } // skip when latin is a string longer than 3 characters long
282
+ // bc the resulting regex patterns will be long
283
+ // eg:
284
+ // latin صلى الله عليه وسلم length 18 code point 65018
285
+ // latin جل جلاله length 8 code point 65019
286
+
287
+
288
+ if (latin.length > 3) {
289
+ continue;
282
290
  }
283
291
 
284
292
  if (!(latin in diacritics)) {
285
293
  diacritics[latin] = [latin];
286
294
  }
287
295
 
288
- var patt = new RegExp(arrayToPattern(diacritics[latin]), 'iu');
296
+ var patt = new RegExp(escapeToPattern(diacritics[latin]), 'iu');
289
297
 
290
298
  if (diacritic.match(patt)) {
291
299
  continue;
@@ -293,13 +301,23 @@
293
301
 
294
302
  diacritics[latin].push(diacritic);
295
303
  }
296
- });
297
- var latin_chars = Object.keys(diacritics); // latin character pattern
304
+ }); // filter out if there's only one character in the list
305
+
306
+ let latin_chars = Object.keys(diacritics);
307
+
308
+ for (let i = 0; i < latin_chars.length; i++) {
309
+ const latin = latin_chars[i];
310
+
311
+ if (diacritics[latin].length < 2) {
312
+ delete diacritics[latin];
313
+ }
314
+ } // latin character pattern
298
315
  // match longer substrings first
299
316
 
300
- latin_chars = latin_chars.sort((a, b) => b.length - a.length);
301
- latin_pat = new RegExp('(' + arrayToPattern(latin_chars) + accent_pat + '*)', 'g'); // build diacritic patterns
302
- // ae needs:
317
+
318
+ latin_chars = Object.keys(diacritics).sort((a, b) => b.length - a.length);
319
+ latin_pat = new RegExp('(' + escapeToPattern(latin_chars) + accent_pat + '*)', 'gu'); // build diacritic patterns
320
+ // ae needs:
303
321
  // (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))
304
322
 
305
323
  var diacritic_patterns = {};
@@ -308,7 +326,7 @@
308
326
  var pattern = substrings.map(sub_pat => {
309
327
  sub_pat = sub_pat.map(l => {
310
328
  if (diacritics.hasOwnProperty(l)) {
311
- return arrayToPattern(diacritics[l]);
329
+ return escapeToPattern(diacritics[l]);
312
330
  }
313
331
 
314
332
  return l;
@@ -327,27 +345,20 @@
327
345
 
328
346
  const diacriticRegexPoints = regex => {
329
347
  if (diacritic_patterns === undefined) {
330
- diacritic_patterns = generateDiacritics();
348
+ diacritic_patterns = generateDiacritics(code_points);
331
349
  }
332
350
 
333
351
  const decomposed = regex.normalize('NFKD').toLowerCase();
334
352
  return decomposed.split(latin_pat).map(part => {
335
- if (part == '') {
336
- return '';
337
- } // "ffl" or "ffl"
338
-
339
-
353
+ // "ffl" or "ffl"
340
354
  const no_accent = asciifold(part);
341
355
 
356
+ if (no_accent == '') {
357
+ return '';
358
+ }
359
+
342
360
  if (diacritic_patterns.hasOwnProperty(no_accent)) {
343
361
  return diacritic_patterns[no_accent];
344
- } // 'أهلا' (\u{623}\u{647}\u{644}\u{627}) or 'أهلا' (\u{627}\u{654}\u{647}\u{644}\u{627})
345
-
346
-
347
- const composed_part = part.normalize('NFC');
348
-
349
- if (composed_part != part) {
350
- return arrayToPattern([part, composed_part]);
351
362
  }
352
363
 
353
364
  return part;
@@ -513,10 +524,10 @@
513
524
  }
514
525
 
515
526
  if (word.length > 0) {
516
- regex = escape_regex(word);
517
-
518
527
  if (this.settings.diacritics) {
519
- regex = diacriticRegexPoints(regex);
528
+ regex = diacriticRegexPoints(word);
529
+ } else {
530
+ regex = escape_regex(word);
520
531
  }
521
532
 
522
533
  if (respect_word_boundaries) regex = "\\b" + regex;
@@ -1532,6 +1543,7 @@
1532
1543
  this.isInputHidden = false;
1533
1544
  this.isSetup = false;
1534
1545
  this.ignoreFocus = false;
1546
+ this.ignoreHover = false;
1535
1547
  this.hasOptions = false;
1536
1548
  this.currentResults = void 0;
1537
1549
  this.lastValue = '';
@@ -1730,7 +1742,13 @@
1730
1742
  settings.load = loadDebounce(settings.load, settings.loadThrottle);
1731
1743
  }
1732
1744
 
1733
- self.control_input.type = input.type; // clicking on an option should select it
1745
+ self.control_input.type = input.type;
1746
+ addEvent(dropdown, 'mouseenter', e => {
1747
+ var target_match = parentMatch(e.target, '[data-selectable]', dropdown);
1748
+ if (target_match) self.onOptionHover(e, target_match);
1749
+ }, {
1750
+ capture: true
1751
+ }); // clicking on an option should select it
1734
1752
 
1735
1753
  addEvent(dropdown, 'click', evt => {
1736
1754
  const option = parentMatch(evt.target, '[data-selectable]');
@@ -1764,7 +1782,7 @@
1764
1782
  addEvent(focus_node, 'resize', () => self.positionDropdown(), passive_event);
1765
1783
  addEvent(focus_node, 'blur', e => self.onBlur(e));
1766
1784
  addEvent(focus_node, 'focus', e => self.onFocus(e));
1767
- addEvent(focus_node, 'paste', e => self.onPaste(e));
1785
+ addEvent(control_input, 'paste', e => self.onPaste(e));
1768
1786
 
1769
1787
  const doc_mousedown = evt => {
1770
1788
  // blur if target is outside of this instance
@@ -1791,18 +1809,24 @@
1791
1809
  }
1792
1810
  };
1793
1811
 
1794
- var win_scroll = () => {
1812
+ const win_scroll = () => {
1795
1813
  if (self.isOpen) {
1796
1814
  self.positionDropdown();
1797
1815
  }
1798
1816
  };
1799
1817
 
1818
+ const win_hover = () => {
1819
+ self.ignoreHover = false;
1820
+ };
1821
+
1800
1822
  addEvent(document, 'mousedown', doc_mousedown);
1801
1823
  addEvent(window, 'scroll', win_scroll, passive_event);
1802
1824
  addEvent(window, 'resize', win_scroll, passive_event);
1825
+ addEvent(window, 'mousemove', win_hover, passive_event);
1803
1826
 
1804
1827
  this._destroy = () => {
1805
1828
  document.removeEventListener('mousedown', doc_mousedown);
1829
+ window.removeEventListener('mousemove', win_hover);
1806
1830
  window.removeEventListener('scroll', win_scroll);
1807
1831
  window.removeEventListener('resize', win_scroll);
1808
1832
  if (label) label.removeEventListener('click', label_click);
@@ -2008,21 +2032,29 @@
2008
2032
  // input and create Items for each separate value
2009
2033
 
2010
2034
 
2011
- if (self.settings.splitOn) {
2012
- // Wait for pasted text to be recognized in value
2013
- setTimeout(() => {
2014
- var pastedText = self.inputValue();
2035
+ if (!self.settings.splitOn) {
2036
+ return;
2037
+ } // Wait for pasted text to be recognized in value
2015
2038
 
2016
- if (!pastedText.match(self.settings.splitOn)) {
2017
- return;
2018
- }
2019
2039
 
2020
- var splitInput = pastedText.trim().split(self.settings.splitOn);
2021
- iterate(splitInput, piece => {
2040
+ setTimeout(() => {
2041
+ var pastedText = self.inputValue();
2042
+
2043
+ if (!pastedText.match(self.settings.splitOn)) {
2044
+ return;
2045
+ }
2046
+
2047
+ var splitInput = pastedText.trim().split(self.settings.splitOn);
2048
+ iterate(splitInput, piece => {
2049
+ piece = hash_key(piece);
2050
+
2051
+ if (this.options[piece]) {
2052
+ self.addItem(piece);
2053
+ } else {
2022
2054
  self.createItem(piece);
2023
- });
2024
- }, 0);
2025
- }
2055
+ }
2056
+ });
2057
+ }, 0);
2026
2058
  }
2027
2059
  /**
2028
2060
  * Triggered on <input> keypress.
@@ -2054,6 +2086,7 @@
2054
2086
 
2055
2087
  onKeyDown(e) {
2056
2088
  var self = this;
2089
+ self.ignoreHover = true;
2057
2090
 
2058
2091
  if (self.isLocked) {
2059
2092
  if (e.keyCode !== KEY_TAB) {
@@ -2114,6 +2147,8 @@
2114
2147
  self.onOptionSelect(e, self.activeOption);
2115
2148
  preventDefault(e); // if the option_create=null, the dropdown might be closed
2116
2149
  } else if (self.settings.create && self.createItem()) {
2150
+ preventDefault(e); // don't submit form when searching for a value
2151
+ } else if (document.activeElement == self.control_input && self.isOpen) {
2117
2152
  preventDefault(e);
2118
2153
  }
2119
2154
 
@@ -2184,6 +2219,17 @@
2184
2219
  self.trigger('type', value);
2185
2220
  }
2186
2221
  }
2222
+ /**
2223
+ * Triggered when the user rolls over
2224
+ * an option in the autocomplete dropdown menu.
2225
+ *
2226
+ */
2227
+
2228
+
2229
+ onOptionHover(evt, option) {
2230
+ if (this.ignoreHover) return;
2231
+ this.setActiveOption(option, false);
2232
+ }
2187
2233
  /**
2188
2234
  * Triggered on <input> focus.
2189
2235
  *
@@ -2538,7 +2584,7 @@
2538
2584
  */
2539
2585
 
2540
2586
 
2541
- setActiveOption(option) {
2587
+ setActiveOption(option, scroll = true) {
2542
2588
  if (option === this.activeOption) {
2543
2589
  return;
2544
2590
  }
@@ -2553,7 +2599,7 @@
2553
2599
  'aria-selected': 'true'
2554
2600
  });
2555
2601
  addClasses(option, 'active');
2556
- this.scrollToOption(option);
2602
+ if (scroll) this.scrollToOption(option);
2557
2603
  }
2558
2604
  /**
2559
2605
  * Sets the dropdown_content scrollTop to display the option
@@ -3186,13 +3232,14 @@
3186
3232
  */
3187
3233
 
3188
3234
 
3189
- clearOptions() {
3235
+ clearOptions(filter) {
3236
+ const boundFilter = (filter || this.clearFilter).bind(this);
3190
3237
  this.loadedSearches = {};
3191
3238
  this.userOptions = {};
3192
3239
  this.clearCache();
3193
- var selected = {};
3240
+ const selected = {};
3194
3241
  iterate(this.options, (option, key) => {
3195
- if (this.items.indexOf(key) >= 0) {
3242
+ if (boundFilter(option, key)) {
3196
3243
  selected[key] = this.options[key];
3197
3244
  }
3198
3245
  });
@@ -3200,6 +3247,20 @@
3200
3247
  this.lastQuery = null;
3201
3248
  this.trigger('option_clear');
3202
3249
  }
3250
+ /**
3251
+ * Used by clearOptions() to decide whether or not an option should be removed
3252
+ * Return true to keep an option, false to remove
3253
+ *
3254
+ */
3255
+
3256
+
3257
+ clearFilter(option, value) {
3258
+ if (this.items.indexOf(value) >= 0) {
3259
+ return true;
3260
+ }
3261
+
3262
+ return false;
3263
+ }
3203
3264
  /**
3204
3265
  * Returns the dom element of the option
3205
3266
  * matching the given value.
@@ -3519,11 +3580,11 @@
3519
3580
  refreshValidityState() {
3520
3581
  var self = this;
3521
3582
 
3522
- if (!self.input.checkValidity) {
3583
+ if (!self.input.validity) {
3523
3584
  return;
3524
3585
  }
3525
3586
 
3526
- self.isValid = self.input.checkValidity();
3587
+ self.isValid = self.input.validity.valid;
3527
3588
  self.isInvalid = !self.isValid;
3528
3589
  }
3529
3590
  /**
@@ -3750,9 +3811,7 @@
3750
3811
  }
3751
3812
  }
3752
3813
 
3753
- const values = rm_items.map(item => item.dataset.value); // allow the callback to abort
3754
-
3755
- if (!values.length || typeof self.settings.onDelete === 'function' && self.settings.onDelete.call(self, values, e) === false) {
3814
+ if (!self.shouldDelete(rm_items, e)) {
3756
3815
  return false;
3757
3816
  }
3758
3817
 
@@ -3771,6 +3830,20 @@
3771
3830
  self.refreshOptions(false);
3772
3831
  return true;
3773
3832
  }
3833
+ /**
3834
+ * Return true if the items should be deleted
3835
+ */
3836
+
3837
+
3838
+ shouldDelete(items, evt) {
3839
+ const values = items.map(item => item.dataset.value); // allow the callback to abort
3840
+
3841
+ if (!values.length || typeof this.settings.onDelete === 'function' && this.settings.onDelete(values, evt) === false) {
3842
+ return false;
3843
+ }
3844
+
3845
+ return true;
3846
+ }
3774
3847
  /**
3775
3848
  * Selects the previous / next item (depending on the `direction` argument).
3776
3849
  *