@drecchia/tom-select 2.5.2-virtual-scroll.0 → 2.5.2-virtual-scroll.1

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 (248) hide show
  1. package/dist/cjs/constants.js +16 -0
  2. package/dist/cjs/constants.js.map +1 -0
  3. package/dist/cjs/contrib/highlight.js +69 -0
  4. package/dist/cjs/contrib/highlight.js.map +1 -0
  5. package/dist/cjs/contrib/microevent.js +64 -0
  6. package/dist/cjs/contrib/microevent.js.map +1 -0
  7. package/dist/cjs/contrib/microplugin.js +112 -0
  8. package/dist/cjs/contrib/microplugin.js.map +1 -0
  9. package/dist/cjs/defaults.js +85 -0
  10. package/dist/cjs/defaults.js.map +1 -0
  11. package/dist/cjs/getSettings.js +146 -0
  12. package/dist/cjs/getSettings.js.map +1 -0
  13. package/dist/cjs/package.json +1 -0
  14. package/dist/cjs/plugins/caret_position/plugin.js +66 -0
  15. package/dist/cjs/plugins/caret_position/plugin.js.map +1 -0
  16. package/dist/cjs/plugins/change_listener/plugin.js +25 -0
  17. package/dist/cjs/plugins/change_listener/plugin.js.map +1 -0
  18. package/dist/cjs/plugins/checkbox_options/plugin.js +108 -0
  19. package/dist/cjs/plugins/checkbox_options/plugin.js.map +1 -0
  20. package/dist/cjs/plugins/checkbox_options/types.js +3 -0
  21. package/dist/cjs/plugins/checkbox_options/types.js.map +1 -0
  22. package/dist/cjs/plugins/clear_button/plugin.js +47 -0
  23. package/dist/cjs/plugins/clear_button/plugin.js.map +1 -0
  24. package/dist/cjs/plugins/clear_button/types.js +3 -0
  25. package/dist/cjs/plugins/clear_button/types.js.map +1 -0
  26. package/dist/cjs/plugins/drag_drop/plugin.js +117 -0
  27. package/dist/cjs/plugins/drag_drop/plugin.js.map +1 -0
  28. package/dist/cjs/plugins/dropdown_header/plugin.js +50 -0
  29. package/dist/cjs/plugins/dropdown_header/plugin.js.map +1 -0
  30. package/dist/cjs/plugins/dropdown_header/types.js +3 -0
  31. package/dist/cjs/plugins/dropdown_header/types.js.map +1 -0
  32. package/dist/cjs/plugins/dropdown_input/plugin.js +88 -0
  33. package/dist/cjs/plugins/dropdown_input/plugin.js.map +1 -0
  34. package/dist/cjs/plugins/input_autogrow/plugin.js +47 -0
  35. package/dist/cjs/plugins/input_autogrow/plugin.js.map +1 -0
  36. package/dist/cjs/plugins/local_virtual_scroll/plugin.js +293 -0
  37. package/dist/cjs/plugins/local_virtual_scroll/plugin.js.map +1 -0
  38. package/dist/cjs/plugins/local_virtual_scroll/types.js +3 -0
  39. package/dist/cjs/plugins/local_virtual_scroll/types.js.map +1 -0
  40. package/dist/cjs/plugins/no_active_items/plugin.js +22 -0
  41. package/dist/cjs/plugins/no_active_items/plugin.js.map +1 -0
  42. package/dist/cjs/plugins/no_backspace_delete/plugin.js +28 -0
  43. package/dist/cjs/plugins/no_backspace_delete/plugin.js.map +1 -0
  44. package/dist/cjs/plugins/optgroup_columns/plugin.js +51 -0
  45. package/dist/cjs/plugins/optgroup_columns/plugin.js.map +1 -0
  46. package/dist/cjs/plugins/remove_button/plugin.js +61 -0
  47. package/dist/cjs/plugins/remove_button/plugin.js.map +1 -0
  48. package/dist/cjs/plugins/remove_button/types.js +3 -0
  49. package/dist/cjs/plugins/remove_button/types.js.map +1 -0
  50. package/dist/cjs/plugins/restore_on_backspace/plugin.js +24 -0
  51. package/dist/cjs/plugins/restore_on_backspace/plugin.js.map +1 -0
  52. package/dist/cjs/plugins/virtual_scroll/plugin.js +170 -0
  53. package/dist/cjs/plugins/virtual_scroll/plugin.js.map +1 -0
  54. package/dist/cjs/tom-select.complete.js +35 -0
  55. package/dist/cjs/tom-select.complete.js.map +1 -0
  56. package/dist/cjs/tom-select.js +2303 -0
  57. package/dist/cjs/tom-select.js.map +1 -0
  58. package/dist/cjs/tom-select.popular.js +15 -0
  59. package/dist/cjs/tom-select.popular.js.map +1 -0
  60. package/dist/cjs/types/core.js +3 -0
  61. package/dist/cjs/types/core.js.map +1 -0
  62. package/dist/cjs/types/index.js +19 -0
  63. package/dist/cjs/types/index.js.map +1 -0
  64. package/dist/cjs/types/settings.js +3 -0
  65. package/dist/cjs/types/settings.js.map +1 -0
  66. package/dist/cjs/utils.js +212 -0
  67. package/dist/cjs/utils.js.map +1 -0
  68. package/dist/cjs/vanilla.js +190 -0
  69. package/dist/cjs/vanilla.js.map +1 -0
  70. package/dist/css/tom-select.bootstrap4.css +16 -4
  71. package/dist/css/tom-select.bootstrap4.css.map +1 -0
  72. package/dist/css/tom-select.bootstrap4.min.css +2 -0
  73. package/dist/css/tom-select.bootstrap4.min.css.map +1 -0
  74. package/dist/css/tom-select.bootstrap5.css +16 -4
  75. package/dist/css/tom-select.bootstrap5.css.map +1 -0
  76. package/dist/css/tom-select.bootstrap5.min.css +2 -0
  77. package/dist/css/tom-select.bootstrap5.min.css.map +1 -0
  78. package/dist/css/tom-select.css +12 -4
  79. package/dist/css/tom-select.css.map +1 -0
  80. package/dist/css/tom-select.default.css +11 -5
  81. package/dist/css/tom-select.default.css.map +1 -1
  82. package/dist/css/tom-select.default.min.css +2 -0
  83. package/dist/css/tom-select.default.min.css.map +1 -0
  84. package/dist/css/tom-select.min.css +2 -0
  85. package/dist/css/tom-select.min.css.map +1 -0
  86. package/dist/esm/constants.d.ts +12 -0
  87. package/dist/esm/constants.js +13 -0
  88. package/dist/esm/constants.js.map +1 -0
  89. package/dist/esm/contrib/highlight.d.ts +13 -0
  90. package/dist/esm/contrib/highlight.js +64 -0
  91. package/dist/esm/contrib/highlight.js.map +1 -0
  92. package/dist/esm/contrib/microevent.d.ts +20 -0
  93. package/dist/esm/contrib/microevent.js +61 -0
  94. package/dist/esm/contrib/microevent.js.map +1 -0
  95. package/dist/esm/contrib/microplugin.d.ts +71 -0
  96. package/dist/esm/contrib/microplugin.js +109 -0
  97. package/dist/esm/contrib/microplugin.js.map +1 -0
  98. package/dist/esm/defaults.d.ts +53 -0
  99. package/dist/esm/defaults.js +83 -0
  100. package/dist/esm/defaults.js.map +1 -0
  101. package/dist/esm/getSettings.d.ts +3 -0
  102. package/dist/esm/getSettings.js +143 -0
  103. package/dist/esm/getSettings.js.map +1 -0
  104. package/dist/esm/plugins/caret_position/plugin.d.ts +16 -0
  105. package/dist/esm/plugins/caret_position/plugin.js +1 -1
  106. package/dist/esm/plugins/change_listener/plugin.d.ts +16 -0
  107. package/dist/esm/plugins/change_listener/plugin.js +1 -1
  108. package/dist/esm/plugins/checkbox_options/plugin.d.ts +17 -0
  109. package/dist/esm/plugins/checkbox_options/plugin.js +1 -1
  110. package/dist/esm/plugins/checkbox_options/types.d.ts +14 -0
  111. package/dist/esm/plugins/checkbox_options/types.js +2 -0
  112. package/dist/esm/plugins/checkbox_options/types.js.map +1 -0
  113. package/dist/esm/plugins/clear_button/plugin.d.ts +17 -0
  114. package/dist/esm/plugins/clear_button/plugin.js +1 -1
  115. package/dist/esm/plugins/clear_button/types.d.ts +7 -0
  116. package/dist/esm/plugins/clear_button/types.js +2 -0
  117. package/dist/esm/plugins/clear_button/types.js.map +1 -0
  118. package/dist/esm/plugins/drag_drop/plugin.d.ts +16 -0
  119. package/dist/esm/plugins/drag_drop/plugin.js +1 -1
  120. package/dist/esm/plugins/dropdown_header/plugin.d.ts +17 -0
  121. package/dist/esm/plugins/dropdown_header/plugin.js +1 -1
  122. package/dist/esm/plugins/dropdown_header/types.d.ts +8 -0
  123. package/dist/esm/plugins/dropdown_header/types.js +2 -0
  124. package/dist/esm/plugins/dropdown_header/types.js.map +1 -0
  125. package/dist/esm/plugins/dropdown_input/plugin.d.ts +16 -0
  126. package/dist/esm/plugins/dropdown_input/plugin.js +1 -1
  127. package/dist/esm/plugins/input_autogrow/plugin.d.ts +15 -0
  128. package/dist/esm/plugins/input_autogrow/plugin.js +1 -1
  129. package/dist/esm/plugins/local_virtual_scroll/plugin.d.ts +19 -0
  130. package/dist/esm/plugins/local_virtual_scroll/plugin.js +92 -1
  131. package/dist/esm/plugins/local_virtual_scroll/plugin.js.map +1 -1
  132. package/dist/esm/plugins/local_virtual_scroll/types.d.ts +14 -0
  133. package/dist/esm/plugins/local_virtual_scroll/types.js +2 -0
  134. package/dist/esm/plugins/local_virtual_scroll/types.js.map +1 -0
  135. package/dist/esm/plugins/no_active_items/plugin.d.ts +15 -0
  136. package/dist/esm/plugins/no_active_items/plugin.js +1 -1
  137. package/dist/esm/plugins/no_backspace_delete/plugin.d.ts +15 -0
  138. package/dist/esm/plugins/no_backspace_delete/plugin.js +1 -1
  139. package/dist/esm/plugins/optgroup_columns/plugin.d.ts +16 -0
  140. package/dist/esm/plugins/optgroup_columns/plugin.js +1 -1
  141. package/dist/esm/plugins/remove_button/plugin.d.ts +17 -0
  142. package/dist/esm/plugins/remove_button/plugin.js +1 -1
  143. package/dist/esm/plugins/remove_button/types.d.ts +6 -0
  144. package/dist/esm/plugins/remove_button/types.js +2 -0
  145. package/dist/esm/plugins/remove_button/types.js.map +1 -0
  146. package/dist/esm/plugins/restore_on_backspace/plugin.d.ts +21 -0
  147. package/dist/esm/plugins/restore_on_backspace/plugin.js +1 -1
  148. package/dist/esm/plugins/virtual_scroll/plugin.d.ts +16 -0
  149. package/dist/esm/plugins/virtual_scroll/plugin.js +1 -1
  150. package/dist/esm/tom-select.complete.d.ts +2 -0
  151. package/dist/esm/tom-select.complete.js +33 -0
  152. package/dist/esm/tom-select.complete.js.map +1 -0
  153. package/dist/esm/tom-select.d.ts +594 -0
  154. package/dist/esm/tom-select.js +2300 -0
  155. package/dist/esm/tom-select.js.map +1 -0
  156. package/dist/esm/tom-select.popular.d.ts +2 -0
  157. package/dist/esm/tom-select.popular.js +13 -0
  158. package/dist/esm/tom-select.popular.js.map +1 -0
  159. package/dist/esm/types/core.d.ts +50 -0
  160. package/dist/esm/types/core.js +2 -0
  161. package/dist/esm/types/core.js.map +1 -0
  162. package/dist/esm/types/index.d.ts +2 -0
  163. package/dist/esm/types/index.js +3 -0
  164. package/dist/esm/types/index.js.map +1 -0
  165. package/dist/esm/types/settings.d.ts +81 -0
  166. package/dist/esm/types/settings.js +2 -0
  167. package/dist/esm/types/settings.js.map +1 -0
  168. package/dist/esm/utils.d.ts +95 -0
  169. package/dist/esm/utils.js +195 -0
  170. package/dist/esm/utils.js.map +1 -0
  171. package/dist/esm/vanilla.d.ts +76 -0
  172. package/dist/esm/vanilla.js +172 -0
  173. package/dist/esm/vanilla.js.map +1 -0
  174. package/dist/js/package.json +1 -0
  175. package/dist/js/plugins/caret_position.js +1 -1
  176. package/dist/js/plugins/change_listener.js +1 -1
  177. package/dist/js/plugins/checkbox_options.js +1 -1
  178. package/dist/js/plugins/clear_button.js +1 -1
  179. package/dist/js/plugins/drag_drop.js +1 -1
  180. package/dist/js/plugins/dropdown_header.js +1 -1
  181. package/dist/js/plugins/dropdown_input.js +1 -1
  182. package/dist/js/plugins/input_autogrow.js +1 -1
  183. package/dist/js/plugins/local_virtual_scroll.js +92 -1
  184. package/dist/js/plugins/local_virtual_scroll.js.map +1 -1
  185. package/dist/js/plugins/no_active_items.js +1 -1
  186. package/dist/js/plugins/no_backspace_delete.js +1 -1
  187. package/dist/js/plugins/optgroup_columns.js +1 -1
  188. package/dist/js/plugins/remove_button.js +1 -1
  189. package/dist/js/plugins/restore_on_backspace.js +1 -1
  190. package/dist/js/plugins/virtual_scroll.js +1 -1
  191. package/dist/js/tom-select.base.js +1 -1
  192. package/dist/js/tom-select.base.min.js +1 -1
  193. package/dist/js/tom-select.complete.js +19 -1
  194. package/dist/js/tom-select.complete.js.map +1 -1
  195. package/dist/js/tom-select.complete.min.js +51 -45
  196. package/dist/js/tom-select.complete.min.js.map +1 -1
  197. package/dist/js/tom-select.popular.js +1 -1
  198. package/dist/js/tom-select.popular.min.js +1 -1
  199. package/dist/scss/_dropdown.scss +99 -0
  200. package/dist/scss/_items.scss +114 -0
  201. package/dist/scss/plugins/checkbox_options.scss +11 -0
  202. package/dist/scss/plugins/clear_button.scss +33 -0
  203. package/dist/scss/plugins/drag_drop.scss +10 -0
  204. package/dist/scss/plugins/dropdown_header.scss +24 -0
  205. package/dist/scss/plugins/dropdown_input.scss +43 -0
  206. package/dist/scss/plugins/input_autogrow.scss +15 -0
  207. package/dist/scss/plugins/optgroup_columns.scss +25 -0
  208. package/dist/scss/plugins/remove_button.scss +70 -0
  209. package/dist/scss/tom-select.bootstrap4.scss +218 -0
  210. package/dist/scss/tom-select.bootstrap5.scss +270 -0
  211. package/dist/scss/tom-select.default.scss +89 -0
  212. package/dist/scss/tom-select.scss +179 -0
  213. package/package.json +2 -2
  214. package/src/plugins/local_virtual_scroll/plugin.ts +19 -0
  215. /package/dist/{types → cjs}/constants.d.ts +0 -0
  216. /package/dist/{types → cjs}/contrib/highlight.d.ts +0 -0
  217. /package/dist/{types → cjs}/contrib/microevent.d.ts +0 -0
  218. /package/dist/{types → cjs}/contrib/microplugin.d.ts +0 -0
  219. /package/dist/{types → cjs}/defaults.d.ts +0 -0
  220. /package/dist/{types → cjs}/getSettings.d.ts +0 -0
  221. /package/dist/{types → cjs}/plugins/caret_position/plugin.d.ts +0 -0
  222. /package/dist/{types → cjs}/plugins/change_listener/plugin.d.ts +0 -0
  223. /package/dist/{types → cjs}/plugins/checkbox_options/plugin.d.ts +0 -0
  224. /package/dist/{types → cjs}/plugins/checkbox_options/types.d.ts +0 -0
  225. /package/dist/{types → cjs}/plugins/clear_button/plugin.d.ts +0 -0
  226. /package/dist/{types → cjs}/plugins/clear_button/types.d.ts +0 -0
  227. /package/dist/{types → cjs}/plugins/drag_drop/plugin.d.ts +0 -0
  228. /package/dist/{types → cjs}/plugins/dropdown_header/plugin.d.ts +0 -0
  229. /package/dist/{types → cjs}/plugins/dropdown_header/types.d.ts +0 -0
  230. /package/dist/{types → cjs}/plugins/dropdown_input/plugin.d.ts +0 -0
  231. /package/dist/{types → cjs}/plugins/input_autogrow/plugin.d.ts +0 -0
  232. /package/dist/{types → cjs}/plugins/local_virtual_scroll/plugin.d.ts +0 -0
  233. /package/dist/{types → cjs}/plugins/local_virtual_scroll/types.d.ts +0 -0
  234. /package/dist/{types → cjs}/plugins/no_active_items/plugin.d.ts +0 -0
  235. /package/dist/{types → cjs}/plugins/no_backspace_delete/plugin.d.ts +0 -0
  236. /package/dist/{types → cjs}/plugins/optgroup_columns/plugin.d.ts +0 -0
  237. /package/dist/{types → cjs}/plugins/remove_button/plugin.d.ts +0 -0
  238. /package/dist/{types → cjs}/plugins/remove_button/types.d.ts +0 -0
  239. /package/dist/{types → cjs}/plugins/restore_on_backspace/plugin.d.ts +0 -0
  240. /package/dist/{types → cjs}/plugins/virtual_scroll/plugin.d.ts +0 -0
  241. /package/dist/{types → cjs}/tom-select.complete.d.ts +0 -0
  242. /package/dist/{types → cjs}/tom-select.d.ts +0 -0
  243. /package/dist/{types → cjs}/tom-select.popular.d.ts +0 -0
  244. /package/dist/{types → cjs}/types/core.d.ts +0 -0
  245. /package/dist/{types → cjs}/types/index.d.ts +0 -0
  246. /package/dist/{types → cjs}/types/settings.d.ts +0 -0
  247. /package/dist/{types → cjs}/utils.d.ts +0 -0
  248. /package/dist/{types → cjs}/vanilla.d.ts +0 -0
@@ -0,0 +1,143 @@
1
+ import defaults from "./defaults.js";
2
+ import { hash_key, iterate } from "./utils.js";
3
+ export default function getSettings(input, settings_user) {
4
+ var settings = Object.assign({}, defaults, settings_user);
5
+ var attr_data = settings.dataAttr;
6
+ var field_label = settings.labelField;
7
+ var field_value = settings.valueField;
8
+ var field_disabled = settings.disabledField;
9
+ var field_optgroup = settings.optgroupField;
10
+ var field_optgroup_label = settings.optgroupLabelField;
11
+ var field_optgroup_value = settings.optgroupValueField;
12
+ var tag_name = input.tagName.toLowerCase();
13
+ var placeholder = input.getAttribute('placeholder') || input.getAttribute('data-placeholder');
14
+ if (!placeholder && !settings.allowEmptyOption) {
15
+ let option = input.querySelector('option[value=""]');
16
+ if (option) {
17
+ placeholder = option.textContent;
18
+ }
19
+ }
20
+ var settings_element = {
21
+ placeholder: placeholder,
22
+ options: [],
23
+ optgroups: [],
24
+ items: [],
25
+ maxItems: null,
26
+ };
27
+ /**
28
+ * Initialize from a <select> element.
29
+ *
30
+ */
31
+ var init_select = () => {
32
+ var tagName;
33
+ var options = settings_element.options;
34
+ var optionsMap = {};
35
+ var group_count = 1;
36
+ let $order = 0;
37
+ var readData = (el) => {
38
+ var data = Object.assign({}, el.dataset); // get plain object from DOMStringMap
39
+ var json = attr_data && data[attr_data];
40
+ if (typeof json === 'string' && json.length) {
41
+ data = Object.assign(data, JSON.parse(json));
42
+ }
43
+ return data;
44
+ };
45
+ var addOption = (option, group) => {
46
+ var value = hash_key(option.value);
47
+ if (value == null)
48
+ return;
49
+ if (!value && !settings.allowEmptyOption)
50
+ return;
51
+ // if the option already exists, it's probably been
52
+ // duplicated in another optgroup. in this case, push
53
+ // the current group to the "optgroup" property on the
54
+ // existing option so that it's rendered in both places.
55
+ if (optionsMap.hasOwnProperty(value)) {
56
+ if (group) {
57
+ var arr = optionsMap[value][field_optgroup];
58
+ if (!arr) {
59
+ optionsMap[value][field_optgroup] = group;
60
+ }
61
+ else if (!Array.isArray(arr)) {
62
+ optionsMap[value][field_optgroup] = [arr, group];
63
+ }
64
+ else {
65
+ arr.push(group);
66
+ }
67
+ }
68
+ }
69
+ else {
70
+ var option_data = readData(option);
71
+ option_data[field_label] = option_data[field_label] || option.textContent;
72
+ option_data[field_value] = option_data[field_value] || value;
73
+ option_data[field_disabled] = option_data[field_disabled] || option.disabled;
74
+ option_data[field_optgroup] = option_data[field_optgroup] || group;
75
+ option_data.$option = option;
76
+ option_data.$order = option_data.$order || ++$order;
77
+ optionsMap[value] = option_data;
78
+ options.push(option_data);
79
+ }
80
+ if (option.selected) {
81
+ settings_element.items.push(value);
82
+ }
83
+ };
84
+ var addGroup = (optgroup) => {
85
+ var id, optgroup_data;
86
+ optgroup_data = readData(optgroup);
87
+ optgroup_data[field_optgroup_label] = optgroup_data[field_optgroup_label] || optgroup.getAttribute('label') || '';
88
+ optgroup_data[field_optgroup_value] = optgroup_data[field_optgroup_value] || group_count++;
89
+ optgroup_data[field_disabled] = optgroup_data[field_disabled] || optgroup.disabled;
90
+ optgroup_data.$order = optgroup_data.$order || ++$order;
91
+ settings_element.optgroups.push(optgroup_data);
92
+ id = optgroup_data[field_optgroup_value];
93
+ iterate(optgroup.children, (option) => {
94
+ addOption(option, id);
95
+ });
96
+ };
97
+ settings_element.maxItems = input.hasAttribute('multiple') ? null : 1;
98
+ iterate(input.children, (child) => {
99
+ tagName = child.tagName.toLowerCase();
100
+ if (tagName === 'optgroup') {
101
+ addGroup(child);
102
+ }
103
+ else if (tagName === 'option') {
104
+ addOption(child);
105
+ }
106
+ });
107
+ };
108
+ /**
109
+ * Initialize from a <input type="text"> element.
110
+ *
111
+ */
112
+ var init_textbox = () => {
113
+ const data_raw = input.getAttribute(attr_data);
114
+ if (!data_raw) {
115
+ var value = input.value.trim() || '';
116
+ if (!settings.allowEmptyOption && !value.length)
117
+ return;
118
+ const values = value.split(settings.delimiter);
119
+ iterate(values, (value) => {
120
+ const option = {};
121
+ option[field_label] = value;
122
+ option[field_value] = value;
123
+ settings_element.options.push(option);
124
+ });
125
+ settings_element.items = values;
126
+ }
127
+ else {
128
+ settings_element.options = JSON.parse(data_raw);
129
+ iterate(settings_element.options, (opt) => {
130
+ settings_element.items.push(opt[field_value]);
131
+ });
132
+ }
133
+ };
134
+ if (tag_name === 'select') {
135
+ init_select();
136
+ }
137
+ else {
138
+ init_textbox();
139
+ }
140
+ return Object.assign({}, defaults, settings_element, settings_user);
141
+ }
142
+ ;
143
+ //# sourceMappingURL=getSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSettings.js","sourceRoot":"","sources":["../../src/getSettings.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAK/C,MAAM,CAAC,OAAO,UAAU,WAAW,CAAE,KAAc,EAAE,aAA2C;IAC/F,IAAI,QAAQ,GAAe,MAAM,C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,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YAE/C,OAAO,CAAE,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;gBAC1B,MAAM,MAAM,GAAa,EAAE,CAAC;gBAC5B,MAAM,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC;gBAC5B,MAAM,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC;gBAC5B,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACvC,CAAC,CAAC,CAAC;YACH,gBAAgB,CAAC,KAAK,GAAG,MAAM,CAAC;QACjC,CAAC;aAAM,CAAC;YACP,gBAAgB,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAChD,OAAO,CAAE,gBAAgB,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;gBAC1C,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;YAC/C,CAAC,CAAC,CAAC;QACJ,CAAC;IACF,CAAC,CAAC;IAGF,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC3B,WAAW,EAAE,CAAC;IACf,CAAC;SAAM,CAAC;QACP,YAAY,EAAE,CAAC;IAChB,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAE,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,CAAgB,CAAC;AACrF,CAAC;AAAA,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Plugin: "dropdown_input" (Tom Select)
3
+ * Copyright (c) contributors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
6
+ * file except in compliance with the License. You may obtain a copy of the License at:
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ * ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ *
14
+ */
15
+ import type TomSelect from '../../tom-select.ts';
16
+ export default function (this: TomSelect): void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.5.2
2
+ * Tom Select v2.5.2-virtual-scroll.1
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Plugin: "change_listener" (Tom Select)
3
+ * Copyright (c) contributors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
6
+ * file except in compliance with the License. You may obtain a copy of the License at:
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ * ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ *
14
+ */
15
+ import type TomSelect from '../../tom-select.ts';
16
+ export default function (this: TomSelect): void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.5.2
2
+ * Tom Select v2.5.2-virtual-scroll.1
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Plugin: "checkbox_options" (Tom Select)
3
+ * Copyright (c) contributors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
6
+ * file except in compliance with the License. You may obtain a copy of the License at:
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ * ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ *
14
+ */
15
+ import type TomSelect from '../../tom-select.ts';
16
+ import { CBOptions } from './types.ts';
17
+ export default function (this: TomSelect, userOptions: CBOptions): void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.5.2
2
+ * Tom Select v2.5.2-virtual-scroll.1
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
@@ -0,0 +1,14 @@
1
+ export type CBOptions = {
2
+ /**
3
+ * a unique class name for the checkbox to find the input
4
+ */
5
+ className?: string;
6
+ /**
7
+ * class name to add if checkbox is checked and remove otherwise
8
+ */
9
+ checkedClassNames?: string[];
10
+ /**
11
+ * class name to add if checkbox was not checked and remove otherwise
12
+ */
13
+ uncheckedClassNames?: string[];
14
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/plugins/checkbox_options/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Plugin: "dropdown_header" (Tom Select)
3
+ * Copyright (c) contributors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
6
+ * file except in compliance with the License. You may obtain a copy of the License at:
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ * ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ *
14
+ */
15
+ import type TomSelect from '../../tom-select.ts';
16
+ import { CBOptions } from './types.ts';
17
+ export default function (this: TomSelect, userOptions: CBOptions): void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.5.2
2
+ * Tom Select v2.5.2-virtual-scroll.1
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
@@ -0,0 +1,7 @@
1
+ export type CBOptions = {
2
+ className?: string;
3
+ title?: string;
4
+ role?: string;
5
+ tabindex?: number;
6
+ html?: (data: CBOptions) => string;
7
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/plugins/clear_button/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Plugin: "drag_drop" (Tom Select)
3
+ * Copyright (c) contributors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
6
+ * file except in compliance with the License. You may obtain a copy of the License at:
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ * ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ *
14
+ */
15
+ import type TomSelect from '../../tom-select.ts';
16
+ export default function (this: TomSelect): void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.5.2
2
+ * Tom Select v2.5.2-virtual-scroll.1
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Plugin: "dropdown_header" (Tom Select)
3
+ * Copyright (c) contributors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
6
+ * file except in compliance with the License. You may obtain a copy of the License at:
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ * ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ *
14
+ */
15
+ import type TomSelect from '../../tom-select.ts';
16
+ import { DHOptions } from './types.ts';
17
+ export default function (this: TomSelect, userOptions: DHOptions): void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.5.2
2
+ * Tom Select v2.5.2-virtual-scroll.1
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
@@ -0,0 +1,8 @@
1
+ export type DHOptions = {
2
+ title?: string;
3
+ headerClass?: string;
4
+ titleRowClass?: string;
5
+ labelClass?: string;
6
+ closeClass?: string;
7
+ html?: (data: DHOptions) => string;
8
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/plugins/dropdown_header/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Plugin: "dropdown_input" (Tom Select)
3
+ * Copyright (c) contributors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
6
+ * file except in compliance with the License. You may obtain a copy of the License at:
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ * ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ *
14
+ */
15
+ import type TomSelect from '../../tom-select.ts';
16
+ export default function (this: TomSelect): void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.5.2
2
+ * Tom Select v2.5.2-virtual-scroll.1
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Plugin: "input_autogrow" (Tom Select)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
5
+ * file except in compliance with the License. You may obtain a copy of the License at:
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ *
8
+ * Unless required by applicable law or agreed to in writing, software distributed under
9
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10
+ * ANY KIND, either express or implied. See the License for the specific language
11
+ * governing permissions and limitations under the License.
12
+ *
13
+ */
14
+ import type TomSelect from '../../tom-select.ts';
15
+ export default function (this: TomSelect): void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.5.2
2
+ * Tom Select v2.5.2-virtual-scroll.1
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Plugin: "local_virtual_scroll" (Tom Select)
3
+ * Copyright (c) contributors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
6
+ * file except in compliance with the License. You may obtain a copy of the License at:
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Virtual scroll for locally-loaded (non-AJAX) datasets.
10
+ * Maintains a sliding DOM window of pageSize * 3 items maximum.
11
+ * Supports optGroups via a flat list with interleaved headers.
12
+ *
13
+ * When the search query matches an optGroup label, all children of that
14
+ * group are included in the results — even if the individual options don't
15
+ * match the query text.
16
+ */
17
+ import type TomSelect from '../../tom-select.ts';
18
+ import type { LVSOptions } from './types.ts';
19
+ export default function (this: TomSelect, userOptions: LVSOptions): void;
@@ -1,8 +1,81 @@
1
1
  /**
2
- * Tom Select v2.5.2
2
+ * Tom Select v2.5.2-virtual-scroll.1
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
6
+ /**
7
+ * Replace a node
8
+ */
9
+ const replaceNode = (existing, replacement) => {
10
+ if (existing.parentNode) existing.parentNode.replaceChild(replacement, existing);
11
+ };
12
+
13
+ /**
14
+ * highlight v3 | MIT license | Johann Burkard <jb@eaio.com>
15
+ * Highlights arbitrary terms in a node.
16
+ *
17
+ * - Modified by Marshal <beatgates@gmail.com> 2011-6-24 (added regex)
18
+ * - Modified by Brian Reavis <brian@thirdroute.com> 2012-8-27 (cleanup)
19
+ */
20
+
21
+ const highlight = (element, regex) => {
22
+ if (regex === null) return;
23
+
24
+ // convet string to regex
25
+ if (typeof regex === 'string') {
26
+ if (!regex.length) return;
27
+ regex = new RegExp(regex, 'i');
28
+ }
29
+
30
+ // Wrap matching part of text node with highlighting <span>, e.g.
31
+ // Soccer -> <span class="highlight">Soc</span>cer for regex = /soc/i
32
+ const highlightText = node => {
33
+ var match = node.data.match(regex);
34
+ if (match && node.data.length > 0) {
35
+ var spannode = document.createElement('span');
36
+ spannode.className = 'highlight';
37
+ var middlebit = node.splitText(match.index);
38
+ middlebit.splitText(match[0].length);
39
+ var middleclone = middlebit.cloneNode(true);
40
+ spannode.appendChild(middleclone);
41
+ replaceNode(middlebit, spannode);
42
+ return 1;
43
+ }
44
+ return 0;
45
+ };
46
+
47
+ // Recurse element node, looking for child text nodes to highlight, unless element
48
+ // is childless, <script>, <style>, or already highlighted: <span class="hightlight">
49
+ const highlightChildren = node => {
50
+ if (node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName) && (node.className !== 'highlight' || node.tagName !== 'SPAN')) {
51
+ Array.from(node.childNodes).forEach(element => {
52
+ highlightRecursive(element);
53
+ });
54
+ }
55
+ };
56
+ const highlightRecursive = node => {
57
+ if (node.nodeType === 3) {
58
+ return highlightText(node);
59
+ }
60
+ highlightChildren(node);
61
+ return 0;
62
+ };
63
+ highlightRecursive(element);
64
+ };
65
+
66
+ /**
67
+ * removeHighlight fn copied from highlight v5 and
68
+ * edited to remove with(), pass js strict mode, and use without jquery
69
+ */
70
+ const removeHighlight = el => {
71
+ var elements = el.querySelectorAll("span.highlight");
72
+ Array.prototype.forEach.call(elements, function (el) {
73
+ var parent = el.parentNode;
74
+ parent.replaceChild(el.firstChild, el);
75
+ parent.normalize();
76
+ });
77
+ };
78
+
6
79
  /**
7
80
  * Plugin: "local_virtual_scroll" (Tom Select)
8
81
  * Copyright (c) contributors
@@ -136,6 +209,19 @@ function plugin (userOptions) {
136
209
  return self.getOption(item.id, true);
137
210
  };
138
211
 
212
+ // ─── Re-apply search highlights to an element ─────────────────────────
213
+
214
+ const applyHighlights = el => {
215
+ if (!self.settings.highlight) return;
216
+ removeHighlight(el);
217
+ const results = self.currentResults;
218
+ if (results && results.query.length && results.tokens.length) {
219
+ for (const tok of results.tokens) {
220
+ if (tok.regex) highlight(el, tok.regex);
221
+ }
222
+ }
223
+ };
224
+
139
225
  // ─── Helpers ─────────────────────────────────────────────────────────
140
226
 
141
227
  const measureHeight = elements => elements.reduce((h, el) => {
@@ -185,6 +271,7 @@ function plugin (userOptions) {
185
271
  const to = Math.min(flat_list.length, visible_end + page_size * pages);
186
272
  const new_els = renderRange(from, to);
187
273
  for (const el of new_els) dropdown_content.append(el);
274
+ for (const el of new_els) applyHighlights(el);
188
275
  visible_end = to;
189
276
 
190
277
  // Recycle items from top to stay within max_dom
@@ -213,6 +300,7 @@ function plugin (userOptions) {
213
300
  // Prepend before current first child
214
301
  const first_child = dropdown_content.firstChild;
215
302
  for (const el of new_els) dropdown_content.insertBefore(el, first_child);
303
+ for (const el of new_els) applyHighlights(el);
216
304
 
217
305
  // Compensate scrollTop so existing content stays in place
218
306
  setScrollTop(dropdown_content.scrollTop + measureHeight(new_els));
@@ -273,6 +361,9 @@ function plugin (userOptions) {
273
361
  dropdown_content.innerHTML = '';
274
362
  const first_page = renderRange(0, visible_end);
275
363
  for (const el of first_page) dropdown_content.append(el);
364
+ // Re-apply highlights: the core applied them before we cleared the DOM,
365
+ // and items from optgroup expansion never went through the core highlight pass.
366
+ applyHighlights(dropdown_content);
276
367
  }
277
368
  updateSentinel();
278
369
  });