tom-select-rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +26 -0
- data/Rakefile +3 -0
- data/lib/tom-select-rails/engine.rb +8 -0
- data/lib/tom-select-rails/version.rb +5 -0
- data/lib/tom-select-rails.rb +7 -0
- data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.complete.js +4887 -0
- data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.complete.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.js +4085 -0
- data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.popular.js +4337 -0
- data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.popular.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/cjs/utils.js +196 -0
- data/vendor/assets/javascripts/tom-select-rails/cjs/utils.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/caret_position/plugin.js +162 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/caret_position/plugin.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/change_listener/plugin.js +50 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/change_listener/plugin.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/plugin.js +172 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/plugin.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/plugin.js +91 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/plugin.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/drag_drop/plugin.js +62 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/drag_drop/plugin.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.js +118 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.js +230 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.js +80 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_active_items/plugin.js +25 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_active_items/plugin.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_backspace_delete/plugin.js +32 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_backspace_delete/plugin.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.js +108 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.js +146 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/restore_on_backspace/plugin.js +43 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/restore_on_backspace/plugin.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.js +261 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.complete.js +4885 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.complete.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.js +4083 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.popular.js +4335 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.popular.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/utils.js +181 -0
- data/vendor/assets/javascripts/tom-select-rails/esm/utils.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/caret_position.js +170 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/caret_position.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/change_listener.js +58 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/change_listener.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/checkbox_options.js +180 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/checkbox_options.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/clear_button.js +99 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/clear_button.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/drag_drop.js +70 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/drag_drop.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_header.js +126 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_header.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_input.js +238 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_input.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/input_autogrow.js +88 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/input_autogrow.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_active_items.js +33 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_active_items.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_backspace_delete.js +40 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_backspace_delete.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/optgroup_columns.js +116 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/optgroup_columns.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/remove_button.js +154 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/remove_button.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/restore_on_backspace.js +51 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/restore_on_backspace.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/virtual_scroll.js +269 -0
- data/vendor/assets/javascripts/tom-select-rails/js/plugins/virtual_scroll.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.js +4092 -0
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.min.js +303 -0
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.min.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.js +4894 -0
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.min.js +362 -0
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.min.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.js +4344 -0
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.min.js +324 -0
- data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.min.js.map +1 -0
- data/vendor/assets/javascripts/tom-select-rails/types/constants.d.ts +12 -0
- data/vendor/assets/javascripts/tom-select-rails/types/contrib/highlight.d.ts +13 -0
- data/vendor/assets/javascripts/tom-select-rails/types/contrib/microevent.d.ts +20 -0
- data/vendor/assets/javascripts/tom-select-rails/types/contrib/microplugin.d.ts +71 -0
- data/vendor/assets/javascripts/tom-select-rails/types/defaults.d.ts +51 -0
- data/vendor/assets/javascripts/tom-select-rails/types/getSettings.d.ts +3 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/caret_position/plugin.d.ts +16 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/change_listener/plugin.d.ts +16 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/checkbox_options/plugin.d.ts +16 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/clear_button/plugin.d.ts +17 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/clear_button/types.d.ts +5 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/drag_drop/plugin.d.ts +16 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/dropdown_header/plugin.d.ts +17 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/dropdown_header/types.d.ts +8 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/dropdown_input/plugin.d.ts +16 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/input_autogrow/plugin.d.ts +15 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/no_active_items/plugin.d.ts +15 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/no_backspace_delete/plugin.d.ts +15 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/optgroup_columns/plugin.d.ts +16 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/remove_button/plugin.d.ts +17 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/remove_button/types.d.ts +6 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/restore_on_backspace/plugin.d.ts +21 -0
- data/vendor/assets/javascripts/tom-select-rails/types/plugins/virtual_scroll/plugin.d.ts +16 -0
- data/vendor/assets/javascripts/tom-select-rails/types/tom-select.complete.d.ts +2 -0
- data/vendor/assets/javascripts/tom-select-rails/types/tom-select.d.ts +579 -0
- data/vendor/assets/javascripts/tom-select-rails/types/tom-select.popular.d.ts +2 -0
- data/vendor/assets/javascripts/tom-select-rails/types/types/core.d.ts +44 -0
- data/vendor/assets/javascripts/tom-select-rails/types/types/index.d.ts +2 -0
- data/vendor/assets/javascripts/tom-select-rails/types/types/settings.d.ts +81 -0
- data/vendor/assets/javascripts/tom-select-rails/types/utils.d.ts +76 -0
- data/vendor/assets/javascripts/tom-select-rails/types/vanilla.d.ts +76 -0
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.css +548 -0
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.css.map +1 -0
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.min.css +2 -0
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.min.css.map +1 -0
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.css +592 -0
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.css.map +1 -0
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.min.css +2 -0
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.min.css.map +1 -0
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.css +391 -0
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.css.map +1 -0
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.css +476 -0
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.css.map +1 -0
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.min.css +2 -0
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.min.css.map +1 -0
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.min.css +2 -0
- data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.min.css.map +1 -0
- data/vendor/assets/stylesheets/tom-select-rails/scss/_dropdown.scss +104 -0
- data/vendor/assets/stylesheets/tom-select-rails/scss/_items.scss +115 -0
- data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/checkbox_options.scss +5 -0
- data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/clear_button.scss +30 -0
- data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/drag_drop.scss +16 -0
- data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/dropdown_header.scss +23 -0
- data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/dropdown_input.scss +47 -0
- data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/input_autogrow.scss +18 -0
- data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/optgroup_columns.scss +23 -0
- data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/remove_button.scss +44 -0
- data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.bootstrap4.scss +219 -0
- data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.bootstrap5.scss +274 -0
- data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.default.scss +87 -0
- data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.scss +175 -0
- metadata +195 -0
@@ -0,0 +1,196 @@
|
|
1
|
+
/**
|
2
|
+
* Tom Select v2.0.3
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
*/
|
5
|
+
|
6
|
+
'use strict';
|
7
|
+
|
8
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Converts a scalar to its best string representation
|
12
|
+
* for hash keys and HTML attribute values.
|
13
|
+
*
|
14
|
+
* Transformations:
|
15
|
+
* 'str' -> 'str'
|
16
|
+
* null -> ''
|
17
|
+
* undefined -> ''
|
18
|
+
* true -> '1'
|
19
|
+
* false -> '0'
|
20
|
+
* 0 -> '0'
|
21
|
+
* 1 -> '1'
|
22
|
+
*
|
23
|
+
*/
|
24
|
+
const hash_key = value => {
|
25
|
+
if (typeof value === 'undefined' || value === null) return null;
|
26
|
+
return get_hash(value);
|
27
|
+
};
|
28
|
+
const get_hash = value => {
|
29
|
+
if (typeof value === 'boolean') return value ? '1' : '0';
|
30
|
+
return value + '';
|
31
|
+
};
|
32
|
+
/**
|
33
|
+
* Escapes a string for use within HTML.
|
34
|
+
*
|
35
|
+
*/
|
36
|
+
|
37
|
+
const escape_html = str => {
|
38
|
+
return (str + '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
39
|
+
};
|
40
|
+
/**
|
41
|
+
* Debounce the user provided load function
|
42
|
+
*
|
43
|
+
*/
|
44
|
+
|
45
|
+
const loadDebounce = (fn, delay) => {
|
46
|
+
var timeout;
|
47
|
+
return function (value, callback) {
|
48
|
+
var self = this;
|
49
|
+
|
50
|
+
if (timeout) {
|
51
|
+
self.loading = Math.max(self.loading - 1, 0);
|
52
|
+
clearTimeout(timeout);
|
53
|
+
}
|
54
|
+
|
55
|
+
timeout = setTimeout(function () {
|
56
|
+
timeout = null;
|
57
|
+
self.loadedSearches[value] = true;
|
58
|
+
fn.call(self, value, callback);
|
59
|
+
}, delay);
|
60
|
+
};
|
61
|
+
};
|
62
|
+
/**
|
63
|
+
* Debounce all fired events types listed in `types`
|
64
|
+
* while executing the provided `fn`.
|
65
|
+
*
|
66
|
+
*/
|
67
|
+
|
68
|
+
const debounce_events = (self, types, fn) => {
|
69
|
+
var type;
|
70
|
+
var trigger = self.trigger;
|
71
|
+
var event_args = {}; // override trigger method
|
72
|
+
|
73
|
+
self.trigger = function () {
|
74
|
+
var type = arguments[0];
|
75
|
+
|
76
|
+
if (types.indexOf(type) !== -1) {
|
77
|
+
event_args[type] = arguments;
|
78
|
+
} else {
|
79
|
+
return trigger.apply(self, arguments);
|
80
|
+
}
|
81
|
+
}; // invoke provided function
|
82
|
+
|
83
|
+
|
84
|
+
fn.apply(self, []);
|
85
|
+
self.trigger = trigger; // trigger queued events
|
86
|
+
|
87
|
+
for (type of types) {
|
88
|
+
if (type in event_args) {
|
89
|
+
trigger.apply(self, event_args[type]);
|
90
|
+
}
|
91
|
+
}
|
92
|
+
};
|
93
|
+
/**
|
94
|
+
* Determines the current selection within a text input control.
|
95
|
+
* Returns an object containing:
|
96
|
+
* - start
|
97
|
+
* - length
|
98
|
+
*
|
99
|
+
*/
|
100
|
+
|
101
|
+
const getSelection = input => {
|
102
|
+
return {
|
103
|
+
start: input.selectionStart || 0,
|
104
|
+
length: (input.selectionEnd || 0) - (input.selectionStart || 0)
|
105
|
+
};
|
106
|
+
};
|
107
|
+
/**
|
108
|
+
* Prevent default
|
109
|
+
*
|
110
|
+
*/
|
111
|
+
|
112
|
+
const preventDefault = (evt, stop = false) => {
|
113
|
+
if (evt) {
|
114
|
+
evt.preventDefault();
|
115
|
+
|
116
|
+
if (stop) {
|
117
|
+
evt.stopPropagation();
|
118
|
+
}
|
119
|
+
}
|
120
|
+
};
|
121
|
+
/**
|
122
|
+
* Prevent default
|
123
|
+
*
|
124
|
+
*/
|
125
|
+
|
126
|
+
const addEvent = (target, type, callback, options) => {
|
127
|
+
target.addEventListener(type, callback, options);
|
128
|
+
};
|
129
|
+
/**
|
130
|
+
* Return true if the requested key is down
|
131
|
+
* Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )
|
132
|
+
* The current evt may not always set ( eg calling advanceSelection() )
|
133
|
+
*
|
134
|
+
*/
|
135
|
+
|
136
|
+
const isKeyDown = (key_name, evt) => {
|
137
|
+
if (!evt) {
|
138
|
+
return false;
|
139
|
+
}
|
140
|
+
|
141
|
+
if (!evt[key_name]) {
|
142
|
+
return false;
|
143
|
+
}
|
144
|
+
|
145
|
+
var count = (evt.altKey ? 1 : 0) + (evt.ctrlKey ? 1 : 0) + (evt.shiftKey ? 1 : 0) + (evt.metaKey ? 1 : 0);
|
146
|
+
|
147
|
+
if (count === 1) {
|
148
|
+
return true;
|
149
|
+
}
|
150
|
+
|
151
|
+
return false;
|
152
|
+
};
|
153
|
+
/**
|
154
|
+
* Get the id of an element
|
155
|
+
* If the id attribute is not set, set the attribute with the given id
|
156
|
+
*
|
157
|
+
*/
|
158
|
+
|
159
|
+
const getId = (el, id) => {
|
160
|
+
const existing_id = el.getAttribute('id');
|
161
|
+
|
162
|
+
if (existing_id) {
|
163
|
+
return existing_id;
|
164
|
+
}
|
165
|
+
|
166
|
+
el.setAttribute('id', id);
|
167
|
+
return id;
|
168
|
+
};
|
169
|
+
/**
|
170
|
+
* Returns a string with backslashes added before characters that need to be escaped.
|
171
|
+
*/
|
172
|
+
|
173
|
+
const addSlashes = str => {
|
174
|
+
return str.replace(/[\\"']/g, '\\$&');
|
175
|
+
};
|
176
|
+
/**
|
177
|
+
*
|
178
|
+
*/
|
179
|
+
|
180
|
+
const append = (parent, node) => {
|
181
|
+
if (node) parent.append(node);
|
182
|
+
};
|
183
|
+
|
184
|
+
exports.addEvent = addEvent;
|
185
|
+
exports.addSlashes = addSlashes;
|
186
|
+
exports.append = append;
|
187
|
+
exports.debounce_events = debounce_events;
|
188
|
+
exports.escape_html = escape_html;
|
189
|
+
exports.getId = getId;
|
190
|
+
exports.getSelection = getSelection;
|
191
|
+
exports.get_hash = get_hash;
|
192
|
+
exports.hash_key = hash_key;
|
193
|
+
exports.isKeyDown = isKeyDown;
|
194
|
+
exports.loadDebounce = loadDebounce;
|
195
|
+
exports.preventDefault = preventDefault;
|
196
|
+
//# sourceMappingURL=utils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../src/utils.ts"],"sourcesContent":["\nimport TomSelect from './tom-select';\nimport { TomLoadCallback } from './types/index';\n\n\n/**\n * Converts a scalar to its best string representation\n * for hash keys and HTML attribute values.\n *\n * Transformations:\n * 'str' -> 'str'\n * null -> ''\n * undefined -> ''\n * true -> '1'\n * false -> '0'\n * 0 -> '0'\n * 1 -> '1'\n *\n */\nexport const hash_key = (value:undefined|null|boolean|string):string|null => {\n\tif (typeof value === 'undefined' || value === null) return null;\n\treturn get_hash(value);\n};\n\nexport const get_hash = (value:boolean|string):string => {\n\tif (typeof value === 'boolean') return value ? '1' : '0';\n\treturn value + '';\n};\n\n/**\n * Escapes a string for use within HTML.\n *\n */\nexport const escape_html = (str:string):string => {\n\treturn (str + '')\n\t\t.replace(/&/g, '&')\n\t\t.replace(/</g, '<')\n\t\t.replace(/>/g, '>')\n\t\t.replace(/\"/g, '"');\n};\n\n\n/**\n * Debounce the user provided load function\n *\n */\nexport const loadDebounce = (fn:(value:string,callback:TomLoadCallback) => void,delay:number) => {\n\tvar timeout: null|ReturnType<typeof setTimeout>;\n\treturn function(this:TomSelect, value:string,callback:TomLoadCallback) {\n\t\tvar self = this;\n\n\t\tif( timeout ){\n\t\t\tself.loading = Math.max(self.loading - 1, 0);\n\t\t\tclearTimeout(timeout);\n\t\t}\n\t\ttimeout = setTimeout(function() {\n\t\t\ttimeout = null;\n\t\t\tself.loadedSearches[value] = true;\n\t\t\tfn.call(self, value, callback);\n\n\t\t}, delay);\n\t};\n};\n\n\n/**\n * Debounce all fired events types listed in `types`\n * while executing the provided `fn`.\n *\n */\nexport const debounce_events = ( self:TomSelect, types:string[], fn:() => void ) => {\n\tvar type:string;\n\tvar trigger = self.trigger;\n\tvar event_args:{ [key: string]: any } = {};\n\n\t// override trigger method\n\tself.trigger = function(){\n\t\tvar type = arguments[0];\n\t\tif (types.indexOf(type) !== -1) {\n\t\t\tevent_args[type] = arguments;\n\t\t} else {\n\t\t\treturn trigger.apply(self, arguments);\n\t\t}\n\t};\n\n\t// invoke provided function\n\tfn.apply(self, []);\n\tself.trigger = trigger;\n\n\t// trigger queued events\n\tfor( type of types ){\n\t\tif( type in event_args ){\n\t\t\ttrigger.apply(self, event_args[type]);\n\t\t}\n\t}\n};\n\n\n/**\n * Determines the current selection within a text input control.\n * Returns an object containing:\n * - start\n * - length\n *\n */\nexport const getSelection = (input:HTMLInputElement):{ start: number; length: number } => {\n\treturn {\n\t\tstart\t: input.selectionStart || 0,\n\t\tlength\t: (input.selectionEnd||0) - (input.selectionStart||0),\n\t};\n};\n\n\n/**\n * Prevent default\n *\n */\nexport const preventDefault = (evt?:Event, stop:boolean=false):void => {\n\tif( evt ){\n\t\tevt.preventDefault();\n\t\tif( stop ){\n\t\t\tevt.stopPropagation();\n\t\t}\n\t}\n}\n\n\n/**\n * Prevent default\n *\n */\nexport const addEvent = (target:EventTarget, type:string, callback:EventListenerOrEventListenerObject, options?:object):void => {\n\ttarget.addEventListener(type,callback,options);\n};\n\n\n/**\n * Return true if the requested key is down\n * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )\n * The current evt may not always set ( eg calling advanceSelection() )\n *\n */\nexport const isKeyDown = ( key_name:keyof (KeyboardEvent|MouseEvent), evt?:KeyboardEvent|MouseEvent ) => {\n\n\tif( !evt ){\n\t\treturn false;\n\t}\n\n\tif( !evt[key_name] ){\n\t\treturn false;\n\t}\n\n\tvar count = (evt.altKey?1:0) + (evt.ctrlKey?1:0) + (evt.shiftKey?1:0) + (evt.metaKey?1:0);\n\n\tif( count === 1 ){\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\n\n/**\n * Get the id of an element\n * If the id attribute is not set, set the attribute with the given id\n *\n */\nexport const getId = (el:Element,id:string) => {\n\tconst existing_id = el.getAttribute('id');\n\tif( existing_id ){\n\t\treturn existing_id;\n\t}\n\n\tel.setAttribute('id',id);\n\treturn id;\n};\n\n\n/**\n * Returns a string with backslashes added before characters that need to be escaped.\n */\nexport const addSlashes = (str:string):string => {\n\treturn str.replace(/[\\\\\"']/g, '\\\\$&');\n};\n\n/**\n *\n */\nexport const append = ( parent:Element|DocumentFragment, node: string|Node|null|undefined ):void =>{\n\tif( node ) parent.append(node);\n};\n"],"names":["hash_key","value","get_hash","escape_html","str","replace","loadDebounce","fn","delay","timeout","callback","self","loading","Math","max","clearTimeout","setTimeout","loadedSearches","call","debounce_events","types","type","trigger","event_args","arguments","indexOf","apply","getSelection","input","start","selectionStart","length","selectionEnd","preventDefault","evt","stop","stopPropagation","addEvent","target","options","addEventListener","isKeyDown","key_name","count","altKey","ctrlKey","shiftKey","metaKey","getId","el","id","existing_id","getAttribute","setAttribute","addSlashes","append","parent","node"],"m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CAAP;AACA;AAED;AACA;AACA;;MACakD,MAAM,GAAG,CAAEC,MAAF,EAAmCC,IAAnC,KAA6E;AAClG,MAAIA,IAAJ,EAAWD,MAAM,CAACD,MAAP,CAAcE,IAAd;AACX;;;;;;;;;;;;;;;"}
|
@@ -0,0 +1,162 @@
|
|
1
|
+
/**
|
2
|
+
* Tom Select v2.0.3
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
*/
|
5
|
+
|
6
|
+
// https://github.com/andrewrk/node-diacritics/blob/master/index.js
|
7
|
+
const latin_convert = {
|
8
|
+
'æ': 'ae',
|
9
|
+
'ⱥ': 'a',
|
10
|
+
'ø': 'o'
|
11
|
+
};
|
12
|
+
new RegExp(Object.keys(latin_convert).join('|'), 'g');
|
13
|
+
|
14
|
+
// @ts-ignore TS2691 "An import path cannot end with a '.ts' extension"
|
15
|
+
/**
|
16
|
+
* Iterates over arrays and hashes.
|
17
|
+
*
|
18
|
+
* ```
|
19
|
+
* iterate(this.items, function(item, id) {
|
20
|
+
* // invoked for each item
|
21
|
+
* });
|
22
|
+
* ```
|
23
|
+
*
|
24
|
+
*/
|
25
|
+
|
26
|
+
const iterate = (object, callback) => {
|
27
|
+
if (Array.isArray(object)) {
|
28
|
+
object.forEach(callback);
|
29
|
+
} else {
|
30
|
+
for (var key in object) {
|
31
|
+
if (object.hasOwnProperty(key)) {
|
32
|
+
callback(object[key], key);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
};
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Remove css classes
|
40
|
+
*
|
41
|
+
*/
|
42
|
+
|
43
|
+
const removeClasses = (elmts, ...classes) => {
|
44
|
+
var norm_classes = classesArray(classes);
|
45
|
+
elmts = castAsArray(elmts);
|
46
|
+
elmts.map(el => {
|
47
|
+
norm_classes.map(cls => {
|
48
|
+
el.classList.remove(cls);
|
49
|
+
});
|
50
|
+
});
|
51
|
+
};
|
52
|
+
/**
|
53
|
+
* Return arguments
|
54
|
+
*
|
55
|
+
*/
|
56
|
+
|
57
|
+
const classesArray = args => {
|
58
|
+
var classes = [];
|
59
|
+
iterate(args, _classes => {
|
60
|
+
if (typeof _classes === 'string') {
|
61
|
+
_classes = _classes.trim().split(/[\11\12\14\15\40]/);
|
62
|
+
}
|
63
|
+
|
64
|
+
if (Array.isArray(_classes)) {
|
65
|
+
classes = classes.concat(_classes);
|
66
|
+
}
|
67
|
+
});
|
68
|
+
return classes.filter(Boolean);
|
69
|
+
};
|
70
|
+
/**
|
71
|
+
* Create an array from arg if it's not already an array
|
72
|
+
*
|
73
|
+
*/
|
74
|
+
|
75
|
+
const castAsArray = arg => {
|
76
|
+
if (!Array.isArray(arg)) {
|
77
|
+
arg = [arg];
|
78
|
+
}
|
79
|
+
|
80
|
+
return arg;
|
81
|
+
};
|
82
|
+
/**
|
83
|
+
* Get the index of an element amongst sibling nodes of the same type
|
84
|
+
*
|
85
|
+
*/
|
86
|
+
|
87
|
+
const nodeIndex = (el, amongst) => {
|
88
|
+
if (!el) return -1;
|
89
|
+
amongst = amongst || el.nodeName;
|
90
|
+
var i = 0;
|
91
|
+
|
92
|
+
while (el = el.previousElementSibling) {
|
93
|
+
if (el.matches(amongst)) {
|
94
|
+
i++;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
return i;
|
99
|
+
};
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Plugin: "dropdown_input" (Tom Select)
|
103
|
+
* Copyright (c) contributors
|
104
|
+
*
|
105
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
106
|
+
* file except in compliance with the License. You may obtain a copy of the License at:
|
107
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
108
|
+
*
|
109
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
110
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
111
|
+
* ANY KIND, either express or implied. See the License for the specific language
|
112
|
+
* governing permissions and limitations under the License.
|
113
|
+
*
|
114
|
+
*/
|
115
|
+
function plugin () {
|
116
|
+
var self = this;
|
117
|
+
/**
|
118
|
+
* Moves the caret to the specified index.
|
119
|
+
*
|
120
|
+
* The input must be moved by leaving it in place and moving the
|
121
|
+
* siblings, due to the fact that focus cannot be restored once lost
|
122
|
+
* on mobile webkit devices
|
123
|
+
*
|
124
|
+
*/
|
125
|
+
|
126
|
+
self.hook('instead', 'setCaret', new_pos => {
|
127
|
+
if (self.settings.mode === 'single' || !self.control.contains(self.control_input)) {
|
128
|
+
new_pos = self.items.length;
|
129
|
+
} else {
|
130
|
+
new_pos = Math.max(0, Math.min(self.items.length, new_pos));
|
131
|
+
|
132
|
+
if (new_pos != self.caretPos && !self.isPending) {
|
133
|
+
self.controlChildren().forEach((child, j) => {
|
134
|
+
if (j < new_pos) {
|
135
|
+
self.control_input.insertAdjacentElement('beforebegin', child);
|
136
|
+
} else {
|
137
|
+
self.control.appendChild(child);
|
138
|
+
}
|
139
|
+
});
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
self.caretPos = new_pos;
|
144
|
+
});
|
145
|
+
self.hook('instead', 'moveCaret', direction => {
|
146
|
+
if (!self.isFocused) return; // move caret before or after selected items
|
147
|
+
|
148
|
+
const last_active = self.getLastActive(direction);
|
149
|
+
|
150
|
+
if (last_active) {
|
151
|
+
const idx = nodeIndex(last_active);
|
152
|
+
self.setCaret(direction > 0 ? idx + 1 : idx);
|
153
|
+
self.setActiveItem();
|
154
|
+
removeClasses(last_active, 'last-active'); // move caret left or right of current position
|
155
|
+
} else {
|
156
|
+
self.setCaret(self.caretPos + direction);
|
157
|
+
}
|
158
|
+
});
|
159
|
+
}
|
160
|
+
|
161
|
+
export { plugin as default };
|
162
|
+
//# sourceMappingURL=plugin.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["../../../../node_modules/@orchidjs/sifter/lib/diacritics.ts","../../../../node_modules/@orchidjs/sifter/lib/utils.ts","../../../../src/vanilla.ts","../../../../src/plugins/caret_position/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: \"dropdown_input\" (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 { nodeIndex, removeClasses } from '../../vanilla';\n\n\nexport default function(this:TomSelect) {\n\tvar self = this;\n\n\t/**\n\t * Moves the caret to the specified index.\n\t *\n\t * The input must be moved by leaving it in place and moving the\n\t * siblings, due to the fact that focus cannot be restored once lost\n\t * on mobile webkit devices\n\t *\n\t */\n\tself.hook('instead','setCaret',(new_pos:number) => {\n\n\t\tif( self.settings.mode === 'single' || !self.control.contains(self.control_input) ) {\n\t\t\tnew_pos = self.items.length;\n\t\t} else {\n\t\t\tnew_pos = Math.max(0, Math.min(self.items.length, new_pos));\n\n\t\t\tif( new_pos != self.caretPos && !self.isPending ){\n\n\t\t\t\tself.controlChildren().forEach((child,j) => {\n\t\t\t\t\tif( j < new_pos ){\n\t\t\t\t\t\tself.control_input.insertAdjacentElement('beforebegin', child );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tself.control.appendChild( child );\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tself.caretPos = new_pos;\n\t});\n\n\tself.hook('instead','moveCaret',(direction:number) => {\n\n\t\tif( !self.isFocused ) return;\n\n\t\t// move caret before or after selected items\n\t\tconst last_active\t\t= self.getLastActive(direction);\n\t\tif( last_active ){\n\t\t\tconst idx = nodeIndex(last_active);\n\t\t\tself.setCaret(direction > 0 ? idx + 1: idx);\n\t\t\tself.setActiveItem();\n\t\t\tremoveClasses(last_active as HTMLElement,'last-active');\n\n\t\t// move caret left or right of current position\n\t\t}else{\n\t\t\tself.setCaret(self.caretPos + direction);\n\n\t\t}\n\n\t});\n\n};\n"],"names":["latin_convert","RegExp","Object","keys","join","iterate","object","callback","Array","isArray","forEach","key","hasOwnProperty","removeClasses","elmts","classes","norm_classes","classesArray","castAsArray","map","el","cls","classList","remove","args","_classes","trim","split","concat","filter","Boolean","arg","nodeIndex","amongst","nodeName","i","previousElementSibling","matches","self","hook","new_pos","settings","mode","control","contains","control_input","items","length","Math","max","min","caretPos","isPending","controlChildren","child","j","insertAdjacentElement","appendChild","direction","isFocused","last_active","getLastActive","idx","setCaret","setActiveItem"],"mappings":";;;;;AAGA;AAOA,MAAMA,aAA4B,GAAG;AACpC,OAAK,IAD+B;AAEpC,OAAK,GAF+B;AAGpC,OAAK;AAH+B,CAArC;AAMoB,IAAIC,MAAJ,CAAWC,MAAM,CAACC,IAAP,CAAYH,aAAZ,EAA2BI,IAA3B,CAAgC,GAAhC,CAAX,EAAgD,GAAhD;;ACfpB;AA2EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,OAAO,GAAG,CAACC,MAAD,EAA+BC,QAA/B,KAA+E;AAErG,MAAKC,KAAK,CAACC,OAAN,CAAcH,MAAd,CAAL,EAA4B;AAC3BA,IAAAA,MAAM,CAACI,OAAP,CAAeH,QAAf;AAEA,GAHD,MAGK;AAEJ,SAAK,IAAII,GAAT,IAAgBL,MAAhB,EAAwB;AACvB,UAAIA,MAAM,CAACM,cAAP,CAAsBD,GAAtB,CAAJ,EAAgC;AAC/BJ,QAAAA,QAAQ,CAACD,MAAM,CAACK,GAAD,CAAP,EAAcA,GAAd,CAAR;AACA;AACD;AACD;AACD,CAbM;;ACZP;AACA;AACA;AACA;;AACQ,MAAME,aAAa,GAAG,CAAEC,KAAF,EAAmC,GAAGC,OAAtC,KAAuE;AAEnG,MAAIC,YAAY,GAAIC,YAAY,CAACF,OAAD,CAAhC;AACDD,EAAAA,KAAK,G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EAAiCmB,SAAD,IAAsB;AAErD,QAAI,CAACpB,IAAI,CAACqB,SAAV,EAAsB,OAF+B;;AAKrD,UAAMC,WAAW,GAAItB,IAAI,CAACuB,aAAL,CAAmBH,SAAnB,CAArB;;AACA,QAAIE,WAAJ,EAAiB;AAChB,YAAME,GAAG,GAAG9B,SAAS,CAAC4B,WAAD,CAArB;AACAtB,MAAAA,IAAI,CAACyB,QAAL,CAAcL,SAAS,GAAG,CAAZ,GAAgBI,GAAG,GAAG,CAAtB,GAAyBA,GAAvC;AACAxB,MAAAA,IAAI,CAAC0B,aAAL;AACAnD,MAAAA,aAAa,CAAC+C,WAAD,EAA4B,aAA5B,CAAb,CAJgB;AAOhB,KAPD,MAOK;AACJtB,MAAAA,IAAI,CAACyB,QAAL,CAAczB,IAAI,CAACa,QAAL,GAAgBO,SAA9B;AAEA;AAED,GAlBD;AAoBA;;;;"}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
/**
|
2
|
+
* Tom Select v2.0.3
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
*/
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Converts a scalar to its best string representation
|
8
|
+
* for hash keys and HTML attribute values.
|
9
|
+
*
|
10
|
+
* Transformations:
|
11
|
+
* 'str' -> 'str'
|
12
|
+
* null -> ''
|
13
|
+
* undefined -> ''
|
14
|
+
* true -> '1'
|
15
|
+
* false -> '0'
|
16
|
+
* 0 -> '0'
|
17
|
+
* 1 -> '1'
|
18
|
+
*
|
19
|
+
*/
|
20
|
+
/**
|
21
|
+
* Prevent default
|
22
|
+
*
|
23
|
+
*/
|
24
|
+
|
25
|
+
const addEvent = (target, type, callback, options) => {
|
26
|
+
target.addEventListener(type, callback, options);
|
27
|
+
};
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Plugin: "change_listener" (Tom Select)
|
31
|
+
* Copyright (c) contributors
|
32
|
+
*
|
33
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
34
|
+
* file except in compliance with the License. You may obtain a copy of the License at:
|
35
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
36
|
+
*
|
37
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
38
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
39
|
+
* ANY KIND, either express or implied. See the License for the specific language
|
40
|
+
* governing permissions and limitations under the License.
|
41
|
+
*
|
42
|
+
*/
|
43
|
+
function plugin () {
|
44
|
+
addEvent(this.input, 'change', () => {
|
45
|
+
this.sync();
|
46
|
+
});
|
47
|
+
}
|
48
|
+
|
49
|
+
export { plugin as default };
|
50
|
+
//# sourceMappingURL=plugin.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["../../../../src/utils.ts","../../../../src/plugins/change_listener/plugin.ts"],"sourcesContent":["\nimport TomSelect from './tom-select';\nimport { TomLoadCallback } from './types/index';\n\n\n/**\n * Converts a scalar to its best string representation\n * for hash keys and HTML attribute values.\n *\n * Transformations:\n * 'str' -> 'str'\n * null -> ''\n * undefined -> ''\n * true -> '1'\n * false -> '0'\n * 0 -> '0'\n * 1 -> '1'\n *\n */\nexport const hash_key = (value:undefined|null|boolean|string):string|null => {\n\tif (typeof value === 'undefined' || value === null) return null;\n\treturn get_hash(value);\n};\n\nexport const get_hash = (value:boolean|string):string => {\n\tif (typeof value === 'boolean') return value ? '1' : '0';\n\treturn value + '';\n};\n\n/**\n * Escapes a string for use within HTML.\n *\n */\nexport const escape_html = (str:string):string => {\n\treturn (str + '')\n\t\t.replace(/&/g, '&')\n\t\t.replace(/</g, '<')\n\t\t.replace(/>/g, '>')\n\t\t.replace(/\"/g, '"');\n};\n\n\n/**\n * Debounce the user provided load function\n *\n */\nexport const loadDebounce = (fn:(value:string,callback:TomLoadCallback) => void,delay:number) => {\n\tvar timeout: null|ReturnType<typeof setTimeout>;\n\treturn function(this:TomSelect, value:string,callback:TomLoadCallback) {\n\t\tvar self = this;\n\n\t\tif( timeout ){\n\t\t\tself.loading = Math.max(self.loading - 1, 0);\n\t\t\tclearTimeout(timeout);\n\t\t}\n\t\ttimeout = setTimeout(function() {\n\t\t\ttimeout = null;\n\t\t\tself.loadedSearches[value] = true;\n\t\t\tfn.call(self, value, callback);\n\n\t\t}, delay);\n\t};\n};\n\n\n/**\n * Debounce all fired events types listed in `types`\n * while executing the provided `fn`.\n *\n */\nexport const debounce_events = ( self:TomSelect, types:string[], fn:() => void ) => {\n\tvar type:string;\n\tvar trigger = self.trigger;\n\tvar event_args:{ [key: string]: any } = {};\n\n\t// override trigger method\n\tself.trigger = function(){\n\t\tvar type = arguments[0];\n\t\tif (types.indexOf(type) !== -1) {\n\t\t\tevent_args[type] = arguments;\n\t\t} else {\n\t\t\treturn trigger.apply(self, arguments);\n\t\t}\n\t};\n\n\t// invoke provided function\n\tfn.apply(self, []);\n\tself.trigger = trigger;\n\n\t// trigger queued events\n\tfor( type of types ){\n\t\tif( type in event_args ){\n\t\t\ttrigger.apply(self, event_args[type]);\n\t\t}\n\t}\n};\n\n\n/**\n * Determines the current selection within a text input control.\n * Returns an object containing:\n * - start\n * - length\n *\n */\nexport const getSelection = (input:HTMLInputElement):{ start: number; length: number } => {\n\treturn {\n\t\tstart\t: input.selectionStart || 0,\n\t\tlength\t: (input.selectionEnd||0) - (input.selectionStart||0),\n\t};\n};\n\n\n/**\n * Prevent default\n *\n */\nexport const preventDefault = (evt?:Event, stop:boolean=false):void => {\n\tif( evt ){\n\t\tevt.preventDefault();\n\t\tif( stop ){\n\t\t\tevt.stopPropagation();\n\t\t}\n\t}\n}\n\n\n/**\n * Prevent default\n *\n */\nexport const addEvent = (target:EventTarget, type:string, callback:EventListenerOrEventListenerObject, options?:object):void => {\n\ttarget.addEventListener(type,callback,options);\n};\n\n\n/**\n * Return true if the requested key is down\n * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )\n * The current evt may not always set ( eg calling advanceSelection() )\n *\n */\nexport const isKeyDown = ( key_name:keyof (KeyboardEvent|MouseEvent), evt?:KeyboardEvent|MouseEvent ) => {\n\n\tif( !evt ){\n\t\treturn false;\n\t}\n\n\tif( !evt[key_name] ){\n\t\treturn false;\n\t}\n\n\tvar count = (evt.altKey?1:0) + (evt.ctrlKey?1:0) + (evt.shiftKey?1:0) + (evt.metaKey?1:0);\n\n\tif( count === 1 ){\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\n\n/**\n * Get the id of an element\n * If the id attribute is not set, set the attribute with the given id\n *\n */\nexport const getId = (el:Element,id:string) => {\n\tconst existing_id = el.getAttribute('id');\n\tif( existing_id ){\n\t\treturn existing_id;\n\t}\n\n\tel.setAttribute('id',id);\n\treturn id;\n};\n\n\n/**\n * Returns a string with backslashes added before characters that need to be escaped.\n */\nexport const addSlashes = (str:string):string => {\n\treturn str.replace(/[\\\\\"']/g, '\\\\$&');\n};\n\n/**\n *\n */\nexport const append = ( parent:Element|DocumentFragment, node: string|Node|null|undefined ):void =>{\n\tif( node ) parent.append(node);\n};\n","/**\n * Plugin: \"change_listener\" (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 { addEvent } from '../../utils';\n\nexport default function(this:TomSelect) {\n\taddEvent(this.input,'change',()=>{\n\t\tthis.sync();\n\t});\n};\n"],"names":["addEvent","target","type","callback","options","addEventListener","input","sync"],"mappings":";;;;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA6GA;AACA;AACA;AACA;;AACO,MAAMA,QAAQ,GAAG,CAACC,MAAD,EAAqBC,IAArB,EAAkCC,QAAlC,EAA+EC,OAA/E,KAAwG;AAC/HH,EAAAA,MAAM,CAACI,gBAAP,CAAwBH,IAAxB,EAA6BC,QAA7B,EAAsCC,OAAtC;AACA,CAFM;;ACnIP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKe,mBAAyB;AACvCJ,EAAAA,QAAQ,CAAC,KAAKM,KAAN,EAAY,QAAZ,EAAqB,MAAI;AAChC,SAAKC,IAAL;AACA,GAFO,CAAR;AAGA;;;;"}
|
@@ -0,0 +1,172 @@
|
|
1
|
+
/**
|
2
|
+
* Tom Select v2.0.3
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
*/
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Converts a scalar to its best string representation
|
8
|
+
* for hash keys and HTML attribute values.
|
9
|
+
*
|
10
|
+
* Transformations:
|
11
|
+
* 'str' -> 'str'
|
12
|
+
* null -> ''
|
13
|
+
* undefined -> ''
|
14
|
+
* true -> '1'
|
15
|
+
* false -> '0'
|
16
|
+
* 0 -> '0'
|
17
|
+
* 1 -> '1'
|
18
|
+
*
|
19
|
+
*/
|
20
|
+
const hash_key = value => {
|
21
|
+
if (typeof value === 'undefined' || value === null) return null;
|
22
|
+
return get_hash(value);
|
23
|
+
};
|
24
|
+
const get_hash = value => {
|
25
|
+
if (typeof value === 'boolean') return value ? '1' : '0';
|
26
|
+
return value + '';
|
27
|
+
};
|
28
|
+
/**
|
29
|
+
* Prevent default
|
30
|
+
*
|
31
|
+
*/
|
32
|
+
|
33
|
+
const preventDefault = (evt, stop = false) => {
|
34
|
+
if (evt) {
|
35
|
+
evt.preventDefault();
|
36
|
+
|
37
|
+
if (stop) {
|
38
|
+
evt.stopPropagation();
|
39
|
+
}
|
40
|
+
}
|
41
|
+
};
|
42
|
+
|
43
|
+
// https://github.com/andrewrk/node-diacritics/blob/master/index.js
|
44
|
+
const latin_convert = {
|
45
|
+
'æ': 'ae',
|
46
|
+
'ⱥ': 'a',
|
47
|
+
'ø': 'o'
|
48
|
+
};
|
49
|
+
new RegExp(Object.keys(latin_convert).join('|'), 'g');
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Return a dom element from either a dom query string, jQuery object, a dom element or html string
|
53
|
+
* https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
|
54
|
+
*
|
55
|
+
* param query should be {}
|
56
|
+
*/
|
57
|
+
|
58
|
+
const getDom = query => {
|
59
|
+
if (query.jquery) {
|
60
|
+
return query[0];
|
61
|
+
}
|
62
|
+
|
63
|
+
if (query instanceof HTMLElement) {
|
64
|
+
return query;
|
65
|
+
}
|
66
|
+
|
67
|
+
if (isHtmlString(query)) {
|
68
|
+
let div = document.createElement('div');
|
69
|
+
div.innerHTML = query.trim(); // Never return a text node of whitespace as the result
|
70
|
+
|
71
|
+
return div.firstChild;
|
72
|
+
}
|
73
|
+
|
74
|
+
return document.querySelector(query);
|
75
|
+
};
|
76
|
+
const isHtmlString = arg => {
|
77
|
+
if (typeof arg === 'string' && arg.indexOf('<') > -1) {
|
78
|
+
return true;
|
79
|
+
}
|
80
|
+
|
81
|
+
return false;
|
82
|
+
};
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Plugin: "restore_on_backspace" (Tom Select)
|
86
|
+
* Copyright (c) contributors
|
87
|
+
*
|
88
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
89
|
+
* file except in compliance with the License. You may obtain a copy of the License at:
|
90
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
91
|
+
*
|
92
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
93
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
94
|
+
* ANY KIND, either express or implied. See the License for the specific language
|
95
|
+
* governing permissions and limitations under the License.
|
96
|
+
*
|
97
|
+
*/
|
98
|
+
function plugin () {
|
99
|
+
var self = this;
|
100
|
+
var orig_onOptionSelect = self.onOptionSelect;
|
101
|
+
self.settings.hideSelected = false; // update the checkbox for an option
|
102
|
+
|
103
|
+
var UpdateCheckbox = function UpdateCheckbox(option) {
|
104
|
+
setTimeout(() => {
|
105
|
+
var checkbox = option.querySelector('input');
|
106
|
+
|
107
|
+
if (option.classList.contains('selected')) {
|
108
|
+
checkbox.checked = true;
|
109
|
+
} else {
|
110
|
+
checkbox.checked = false;
|
111
|
+
}
|
112
|
+
}, 1);
|
113
|
+
}; // add checkbox to option template
|
114
|
+
|
115
|
+
|
116
|
+
self.hook('after', 'setupTemplates', () => {
|
117
|
+
var orig_render_option = self.settings.render.option;
|
118
|
+
|
119
|
+
self.settings.render.option = (data, escape_html) => {
|
120
|
+
var rendered = getDom(orig_render_option.call(self, data, escape_html));
|
121
|
+
var checkbox = document.createElement('input');
|
122
|
+
checkbox.addEventListener('click', function (evt) {
|
123
|
+
preventDefault(evt);
|
124
|
+
});
|
125
|
+
checkbox.type = 'checkbox';
|
126
|
+
const hashed = hash_key(data[self.settings.valueField]);
|
127
|
+
|
128
|
+
if (hashed && self.items.indexOf(hashed) > -1) {
|
129
|
+
checkbox.checked = true;
|
130
|
+
}
|
131
|
+
|
132
|
+
rendered.prepend(checkbox);
|
133
|
+
return rendered;
|
134
|
+
};
|
135
|
+
}); // uncheck when item removed
|
136
|
+
|
137
|
+
self.on('item_remove', value => {
|
138
|
+
var option = self.getOption(value);
|
139
|
+
|
140
|
+
if (option) {
|
141
|
+
// if dropdown hasn't been opened yet, the option won't exist
|
142
|
+
option.classList.remove('selected'); // selected class won't be removed yet
|
143
|
+
|
144
|
+
UpdateCheckbox(option);
|
145
|
+
}
|
146
|
+
}); // check when item added
|
147
|
+
|
148
|
+
self.on('item_add', value => {
|
149
|
+
var option = self.getOption(value);
|
150
|
+
|
151
|
+
if (option) {
|
152
|
+
// if dropdown hasn't been opened yet, the option won't exist
|
153
|
+
UpdateCheckbox(option);
|
154
|
+
}
|
155
|
+
}); // remove items when selected option is clicked
|
156
|
+
|
157
|
+
self.hook('instead', 'onOptionSelect', (evt, option) => {
|
158
|
+
if (option.classList.contains('selected')) {
|
159
|
+
option.classList.remove('selected');
|
160
|
+
self.removeItem(option.dataset.value);
|
161
|
+
self.refreshOptions();
|
162
|
+
preventDefault(evt, true);
|
163
|
+
return;
|
164
|
+
}
|
165
|
+
|
166
|
+
orig_onOptionSelect.call(self, evt, option);
|
167
|
+
UpdateCheckbox(option);
|
168
|
+
});
|
169
|
+
}
|
170
|
+
|
171
|
+
export { plugin as default };
|
172
|
+
//# sourceMappingURL=plugin.js.map
|