tom-select-rails 0.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tom-select-rails/version.rb +1 -1
- data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.complete.js +761 -273
- data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.complete.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.js +756 -272
- data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.popular.js +753 -269
- data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.popular.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/cjs/utils.js +1 -1
- data/vendor/assets/javascripts/tom-select-rails/cjs/utils.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/caret_position/plugin.js +9 -5
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/caret_position/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/change_listener/plugin.js +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/change_listener/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/plugin.js +12 -7
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/plugin.js +13 -8
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/drag_drop/plugin.js +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/drag_drop/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.js +12 -7
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.js +12 -8
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.js +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_active_items/plugin.js +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_active_items/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_backspace_delete/plugin.js +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_backspace_delete/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.js +9 -4
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.js +12 -7
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/restore_on_backspace/plugin.js +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/restore_on_backspace/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.js +16 -8
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.complete.js +761 -273
- data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.complete.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.js +756 -272
- data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.popular.js +753 -269
- data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.popular.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/utils.js +1 -1
- data/vendor/assets/javascripts/tom-select-rails/esm/utils.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/caret_position.js +164 -160
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/caret_position.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/change_listener.js +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/change_listener.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/checkbox_options.js +12 -7
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/checkbox_options.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/clear_button.js +94 -89
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/clear_button.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/drag_drop.js +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/drag_drop.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_header.js +121 -116
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_header.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_input.js +234 -230
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_input.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/input_autogrow.js +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/input_autogrow.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_active_items.js +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_active_items.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_backspace_delete.js +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_backspace_delete.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/optgroup_columns.js +112 -107
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/optgroup_columns.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/remove_button.js +149 -144
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/remove_button.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/restore_on_backspace.js +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/restore_on_backspace.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/virtual_scroll.js +277 -269
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/virtual_scroll.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.js +756 -272
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.min.js +329 -272
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.min.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.js +761 -273
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.min.js +268 -209
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.min.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.js +753 -269
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.min.js +348 -291
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.min.js.map +1 -1
- data/vendor/assets/javascripts/tom-select-rails/types/tom-select.d.ts +6 -6
- data/vendor/assets/javascripts/tom-select-rails/types/types/settings.d.ts +19 -22
- data/vendor/assets/javascripts/tom-select-rails/types/utils.d.ts +5 -5
- data/vendor/assets/javascripts/tom-select-rails/types/vanilla.d.ts +2 -2
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.css +41 -19
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.css.map +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.min.css +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.min.css.map +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.css +61 -34
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.css.map +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.min.css +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.min.css.map +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.css +39 -17
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.css.map +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.css +41 -19
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.css.map +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.min.css +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.min.css.map +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.min.css +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.min.css.map +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/clear_button.scss +11 -10
- data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/remove_button.scss +34 -8
- data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.bootstrap4.scss +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.bootstrap5.scss +20 -10
- data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.default.scss +1 -1
- data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.scss +11 -2
- metadata +3 -3
@@ -1,240 +1,244 @@
|
|
1
1
|
/**
|
2
|
-
* Tom Select v2.1
|
2
|
+
* Tom Select v2.2.1
|
3
3
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
*/
|
5
5
|
|
6
6
|
(function (global, factory) {
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
8
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.dropdown_input = factory());
|
10
10
|
})(this, (function () { 'use strict';
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
12
|
+
const KEY_ESC = 27;
|
13
|
+
const KEY_TAB = 9;
|
14
|
+
typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);
|
15
|
+
// ctrl key or apple key for ma
|
16
|
+
|
17
|
+
/*! @orchidjs/unicode-variants | https://github.com/orchidjs/unicode-variants | Apache License (v2) */
|
18
|
+
const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}]'; // \u{2bc}
|
19
|
+
/** @type {TUnicodeMap} */
|
20
|
+
|
21
|
+
const latin_convert = {
|
22
|
+
'æ': 'ae',
|
23
|
+
'ⱥ': 'a',
|
24
|
+
'ø': 'o',
|
25
|
+
'⁄': '/',
|
26
|
+
'∕': '/'
|
27
|
+
};
|
28
|
+
new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Iterates over arrays and hashes.
|
32
|
+
*
|
33
|
+
* ```
|
34
|
+
* iterate(this.items, function(item, id) {
|
35
|
+
* // invoked for each item
|
36
|
+
* });
|
37
|
+
* ```
|
38
|
+
*
|
39
|
+
*/
|
40
|
+
|
41
|
+
const iterate = (object, callback) => {
|
42
|
+
if (Array.isArray(object)) {
|
43
|
+
object.forEach(callback);
|
44
|
+
} else {
|
45
|
+
for (var key in object) {
|
46
|
+
if (object.hasOwnProperty(key)) {
|
47
|
+
callback(object[key], key);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
};
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Return a dom element from either a dom query string, jQuery object, a dom element or html string
|
55
|
+
* https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
|
56
|
+
*
|
57
|
+
* param query should be {}
|
58
|
+
*/
|
59
|
+
|
60
|
+
const getDom = query => {
|
61
|
+
if (query.jquery) {
|
62
|
+
return query[0];
|
63
|
+
}
|
64
|
+
|
65
|
+
if (query instanceof HTMLElement) {
|
66
|
+
return query;
|
67
|
+
}
|
68
|
+
|
69
|
+
if (isHtmlString(query)) {
|
70
|
+
var tpl = document.createElement('template');
|
71
|
+
tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
|
72
|
+
|
73
|
+
return tpl.content.firstChild;
|
74
|
+
}
|
75
|
+
|
76
|
+
return document.querySelector(query);
|
77
|
+
};
|
78
|
+
const isHtmlString = arg => {
|
79
|
+
if (typeof arg === 'string' && arg.indexOf('<') > -1) {
|
80
|
+
return true;
|
81
|
+
}
|
82
|
+
|
83
|
+
return false;
|
84
|
+
};
|
85
|
+
/**
|
86
|
+
* Add css classes
|
87
|
+
*
|
88
|
+
*/
|
89
|
+
|
90
|
+
const addClasses = (elmts, ...classes) => {
|
91
|
+
var norm_classes = classesArray(classes);
|
92
|
+
elmts = castAsArray(elmts);
|
93
|
+
elmts.map(el => {
|
94
|
+
norm_classes.map(cls => {
|
95
|
+
el.classList.add(cls);
|
96
|
+
});
|
97
|
+
});
|
98
|
+
};
|
99
|
+
/**
|
100
|
+
* Return arguments
|
101
|
+
*
|
102
|
+
*/
|
103
|
+
|
104
|
+
const classesArray = args => {
|
105
|
+
var classes = [];
|
106
|
+
iterate(args, _classes => {
|
107
|
+
if (typeof _classes === 'string') {
|
108
|
+
_classes = _classes.trim().split(/[\11\12\14\15\40]/);
|
109
|
+
}
|
110
|
+
|
111
|
+
if (Array.isArray(_classes)) {
|
112
|
+
classes = classes.concat(_classes);
|
113
|
+
}
|
114
|
+
});
|
115
|
+
return classes.filter(Boolean);
|
116
|
+
};
|
117
|
+
/**
|
118
|
+
* Create an array from arg if it's not already an array
|
119
|
+
*
|
120
|
+
*/
|
121
|
+
|
122
|
+
const castAsArray = arg => {
|
123
|
+
if (!Array.isArray(arg)) {
|
124
|
+
arg = [arg];
|
125
|
+
}
|
126
|
+
|
127
|
+
return arg;
|
128
|
+
};
|
129
|
+
|
130
|
+
/**
|
131
|
+
* Converts a scalar to its best string representation
|
132
|
+
* for hash keys and HTML attribute values.
|
133
|
+
*
|
134
|
+
* Transformations:
|
135
|
+
* 'str' -> 'str'
|
136
|
+
* null -> ''
|
137
|
+
* undefined -> ''
|
138
|
+
* true -> '1'
|
139
|
+
* false -> '0'
|
140
|
+
* 0 -> '0'
|
141
|
+
* 1 -> '1'
|
142
|
+
*
|
143
|
+
*/
|
144
|
+
/**
|
145
|
+
* Prevent default
|
146
|
+
*
|
147
|
+
*/
|
148
|
+
|
149
|
+
const preventDefault = (evt, stop = false) => {
|
150
|
+
if (evt) {
|
151
|
+
evt.preventDefault();
|
152
|
+
|
153
|
+
if (stop) {
|
154
|
+
evt.stopPropagation();
|
155
|
+
}
|
156
|
+
}
|
157
|
+
};
|
158
|
+
/**
|
159
|
+
* Prevent default
|
160
|
+
*
|
161
|
+
*/
|
162
|
+
|
163
|
+
const addEvent = (target, type, callback, options) => {
|
164
|
+
target.addEventListener(type, callback, options);
|
165
|
+
};
|
166
|
+
|
167
|
+
/**
|
168
|
+
* Plugin: "dropdown_input" (Tom Select)
|
169
|
+
* Copyright (c) contributors
|
170
|
+
*
|
171
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
172
|
+
* file except in compliance with the License. You may obtain a copy of the License at:
|
173
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
174
|
+
*
|
175
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
176
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
177
|
+
* ANY KIND, either express or implied. See the License for the specific language
|
178
|
+
* governing permissions and limitations under the License.
|
179
|
+
*
|
180
|
+
*/
|
181
|
+
function plugin () {
|
182
|
+
const self = this;
|
183
|
+
self.settings.shouldOpen = true; // make sure the input is shown even if there are no options to display in the dropdown
|
184
|
+
|
185
|
+
self.hook('before', 'setup', () => {
|
186
|
+
self.focus_node = self.control;
|
187
|
+
addClasses(self.control_input, 'dropdown-input');
|
188
|
+
const div = getDom('<div class="dropdown-input-wrap">');
|
189
|
+
div.append(self.control_input);
|
190
|
+
self.dropdown.insertBefore(div, self.dropdown.firstChild); // set a placeholder in the select control
|
191
|
+
|
192
|
+
const placeholder = getDom('<input class="items-placeholder" tabindex="-1" />');
|
193
|
+
placeholder.placeholder = self.settings.placeholder || '';
|
194
|
+
self.control.append(placeholder);
|
195
|
+
});
|
196
|
+
self.on('initialize', () => {
|
197
|
+
// set tabIndex on control to -1, otherwise [shift+tab] will put focus right back on control_input
|
198
|
+
self.control_input.addEventListener('keydown', evt => {
|
199
|
+
//addEvent(self.control_input,'keydown' as const,(evt:KeyboardEvent) =>{
|
200
|
+
switch (evt.keyCode) {
|
201
|
+
case KEY_ESC:
|
202
|
+
if (self.isOpen) {
|
203
|
+
preventDefault(evt, true);
|
204
|
+
self.close();
|
205
|
+
}
|
206
|
+
|
207
|
+
self.clearActiveItems();
|
208
|
+
return;
|
209
|
+
|
210
|
+
case KEY_TAB:
|
211
|
+
self.focus_node.tabIndex = -1;
|
212
|
+
break;
|
213
|
+
}
|
214
|
+
|
215
|
+
return self.onKeyDown.call(self, evt);
|
216
|
+
});
|
217
|
+
self.on('blur', () => {
|
218
|
+
self.focus_node.tabIndex = self.isDisabled ? -1 : self.tabIndex;
|
219
|
+
}); // give the control_input focus when the dropdown is open
|
220
|
+
|
221
|
+
self.on('dropdown_open', () => {
|
222
|
+
self.control_input.focus();
|
223
|
+
}); // prevent onBlur from closing when focus is on the control_input
|
224
|
+
|
225
|
+
const orig_onBlur = self.onBlur;
|
226
|
+
self.hook('instead', 'onBlur', evt => {
|
227
|
+
if (evt && evt.relatedTarget == self.control_input) return;
|
228
|
+
return orig_onBlur.call(self);
|
229
|
+
});
|
230
|
+
addEvent(self.control_input, 'blur', () => self.onBlur()); // return focus to control to allow further keyboard input
|
231
|
+
|
232
|
+
self.hook('before', 'close', () => {
|
233
|
+
if (!self.isOpen) return;
|
234
|
+
self.focus_node.focus({
|
235
|
+
preventScroll: true
|
236
|
+
});
|
237
|
+
});
|
238
|
+
});
|
239
|
+
}
|
240
|
+
|
241
|
+
return plugin;
|
238
242
|
|
239
243
|
}));
|
240
244
|
//# sourceMappingURL=dropdown_input.js.map
|