@drecchia/tom-select 2.5.2-virtual-scroll.0
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.
- package/LICENSE +202 -0
- package/README.md +104 -0
- package/dist/css/tom-select.bootstrap4.css +573 -0
- package/dist/css/tom-select.bootstrap5.css +612 -0
- package/dist/css/tom-select.css +405 -0
- package/dist/css/tom-select.default.css +497 -0
- package/dist/css/tom-select.default.css.map +1 -0
- package/dist/esm/plugins/caret_position/plugin.js +163 -0
- package/dist/esm/plugins/caret_position/plugin.js.map +1 -0
- package/dist/esm/plugins/change_listener/plugin.js +51 -0
- package/dist/esm/plugins/change_listener/plugin.js.map +1 -0
- package/dist/esm/plugins/checkbox_options/plugin.js +179 -0
- package/dist/esm/plugins/checkbox_options/plugin.js.map +1 -0
- package/dist/esm/plugins/clear_button/plugin.js +76 -0
- package/dist/esm/plugins/clear_button/plugin.js.map +1 -0
- package/dist/esm/plugins/drag_drop/plugin.js +220 -0
- package/dist/esm/plugins/drag_drop/plugin.js.map +1 -0
- package/dist/esm/plugins/dropdown_header/plugin.js +102 -0
- package/dist/esm/plugins/dropdown_header/plugin.js.map +1 -0
- package/dist/esm/plugins/dropdown_input/plugin.js +224 -0
- package/dist/esm/plugins/dropdown_input/plugin.js.map +1 -0
- package/dist/esm/plugins/input_autogrow/plugin.js +74 -0
- package/dist/esm/plugins/input_autogrow/plugin.js.map +1 -0
- package/dist/esm/plugins/local_virtual_scroll/plugin.js +305 -0
- package/dist/esm/plugins/local_virtual_scroll/plugin.js.map +1 -0
- package/dist/esm/plugins/no_active_items/plugin.js +26 -0
- package/dist/esm/plugins/no_active_items/plugin.js.map +1 -0
- package/dist/esm/plugins/no_backspace_delete/plugin.js +32 -0
- package/dist/esm/plugins/no_backspace_delete/plugin.js.map +1 -0
- package/dist/esm/plugins/optgroup_columns/plugin.js +86 -0
- package/dist/esm/plugins/optgroup_columns/plugin.js.map +1 -0
- package/dist/esm/plugins/remove_button/plugin.js +134 -0
- package/dist/esm/plugins/remove_button/plugin.js.map +1 -0
- package/dist/esm/plugins/restore_on_backspace/plugin.js +42 -0
- package/dist/esm/plugins/restore_on_backspace/plugin.js.map +1 -0
- package/dist/esm/plugins/virtual_scroll/plugin.js +272 -0
- package/dist/esm/plugins/virtual_scroll/plugin.js.map +1 -0
- package/dist/js/plugins/caret_position.js +171 -0
- package/dist/js/plugins/caret_position.js.map +1 -0
- package/dist/js/plugins/change_listener.js +59 -0
- package/dist/js/plugins/change_listener.js.map +1 -0
- package/dist/js/plugins/checkbox_options.js +187 -0
- package/dist/js/plugins/checkbox_options.js.map +1 -0
- package/dist/js/plugins/clear_button.js +84 -0
- package/dist/js/plugins/clear_button.js.map +1 -0
- package/dist/js/plugins/drag_drop.js +228 -0
- package/dist/js/plugins/drag_drop.js.map +1 -0
- package/dist/js/plugins/dropdown_header.js +110 -0
- package/dist/js/plugins/dropdown_header.js.map +1 -0
- package/dist/js/plugins/dropdown_input.js +232 -0
- package/dist/js/plugins/dropdown_input.js.map +1 -0
- package/dist/js/plugins/input_autogrow.js +82 -0
- package/dist/js/plugins/input_autogrow.js.map +1 -0
- package/dist/js/plugins/local_virtual_scroll.js +313 -0
- package/dist/js/plugins/local_virtual_scroll.js.map +1 -0
- package/dist/js/plugins/no_active_items.js +34 -0
- package/dist/js/plugins/no_active_items.js.map +1 -0
- package/dist/js/plugins/no_backspace_delete.js +40 -0
- package/dist/js/plugins/no_backspace_delete.js.map +1 -0
- package/dist/js/plugins/optgroup_columns.js +94 -0
- package/dist/js/plugins/optgroup_columns.js.map +1 -0
- package/dist/js/plugins/remove_button.js +142 -0
- package/dist/js/plugins/remove_button.js.map +1 -0
- package/dist/js/plugins/restore_on_backspace.js +50 -0
- package/dist/js/plugins/restore_on_backspace.js.map +1 -0
- package/dist/js/plugins/virtual_scroll.js +280 -0
- package/dist/js/plugins/virtual_scroll.js.map +1 -0
- package/dist/js/tom-select.base.js +4167 -0
- package/dist/js/tom-select.base.js.map +1 -0
- package/dist/js/tom-select.base.min.js +373 -0
- package/dist/js/tom-select.base.min.js.map +1 -0
- package/dist/js/tom-select.complete.js +5364 -0
- package/dist/js/tom-select.complete.js.map +1 -0
- package/dist/js/tom-select.complete.min.js +489 -0
- package/dist/js/tom-select.complete.min.js.map +1 -0
- package/dist/js/tom-select.popular.js +4436 -0
- package/dist/js/tom-select.popular.js.map +1 -0
- package/dist/js/tom-select.popular.min.js +396 -0
- package/dist/js/tom-select.popular.min.js.map +1 -0
- package/dist/types/constants.d.ts +12 -0
- package/dist/types/contrib/highlight.d.ts +13 -0
- package/dist/types/contrib/microevent.d.ts +20 -0
- package/dist/types/contrib/microplugin.d.ts +71 -0
- package/dist/types/defaults.d.ts +53 -0
- package/dist/types/getSettings.d.ts +3 -0
- package/dist/types/plugins/caret_position/plugin.d.ts +16 -0
- package/dist/types/plugins/change_listener/plugin.d.ts +16 -0
- package/dist/types/plugins/checkbox_options/plugin.d.ts +17 -0
- package/dist/types/plugins/checkbox_options/types.d.ts +14 -0
- package/dist/types/plugins/clear_button/plugin.d.ts +17 -0
- package/dist/types/plugins/clear_button/types.d.ts +7 -0
- package/dist/types/plugins/drag_drop/plugin.d.ts +16 -0
- package/dist/types/plugins/dropdown_header/plugin.d.ts +17 -0
- package/dist/types/plugins/dropdown_header/types.d.ts +8 -0
- package/dist/types/plugins/dropdown_input/plugin.d.ts +16 -0
- package/dist/types/plugins/input_autogrow/plugin.d.ts +15 -0
- package/dist/types/plugins/local_virtual_scroll/plugin.d.ts +19 -0
- package/dist/types/plugins/local_virtual_scroll/types.d.ts +14 -0
- package/dist/types/plugins/no_active_items/plugin.d.ts +15 -0
- package/dist/types/plugins/no_backspace_delete/plugin.d.ts +15 -0
- package/dist/types/plugins/optgroup_columns/plugin.d.ts +16 -0
- package/dist/types/plugins/remove_button/plugin.d.ts +17 -0
- package/dist/types/plugins/remove_button/types.d.ts +6 -0
- package/dist/types/plugins/restore_on_backspace/plugin.d.ts +21 -0
- package/dist/types/plugins/virtual_scroll/plugin.d.ts +16 -0
- package/dist/types/tom-select.complete.d.ts +2 -0
- package/dist/types/tom-select.d.ts +594 -0
- package/dist/types/tom-select.popular.d.ts +2 -0
- package/dist/types/types/core.d.ts +50 -0
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/settings.d.ts +81 -0
- package/dist/types/utils.d.ts +95 -0
- package/dist/types/vanilla.d.ts +76 -0
- package/package.json +156 -0
- package/src/constants.ts +13 -0
- package/src/contrib/highlight.ts +81 -0
- package/src/contrib/microevent.ts +73 -0
- package/src/contrib/microplugin.ts +137 -0
- package/src/defaults.ts +95 -0
- package/src/getSettings.ts +176 -0
- package/src/plugins/caret_position/plugin.ts +73 -0
- package/src/plugins/change_listener/plugin.ts +23 -0
- package/src/plugins/checkbox_options/plugin.scss +11 -0
- package/src/plugins/checkbox_options/plugin.ts +130 -0
- package/src/plugins/checkbox_options/types.ts +15 -0
- package/src/plugins/clear_button/plugin.scss +33 -0
- package/src/plugins/clear_button/plugin.ts +54 -0
- package/src/plugins/clear_button/types.ts +8 -0
- package/src/plugins/drag_drop/plugin.scss +10 -0
- package/src/plugins/drag_drop/plugin.ts +143 -0
- package/src/plugins/dropdown_header/plugin.scss +24 -0
- package/src/plugins/dropdown_header/plugin.ts +57 -0
- package/src/plugins/dropdown_header/types.ts +9 -0
- package/src/plugins/dropdown_input/plugin.scss +43 -0
- package/src/plugins/dropdown_input/plugin.ts +97 -0
- package/src/plugins/input_autogrow/plugin.scss +15 -0
- package/src/plugins/input_autogrow/plugin.ts +56 -0
- package/src/plugins/local_virtual_scroll/plugin.ts +309 -0
- package/src/plugins/local_virtual_scroll/types.ts +9 -0
- package/src/plugins/no_active_items/plugin.ts +20 -0
- package/src/plugins/no_backspace_delete/plugin.ts +30 -0
- package/src/plugins/optgroup_columns/plugin.scss +25 -0
- package/src/plugins/optgroup_columns/plugin.ts +59 -0
- package/src/plugins/remove_button/plugin.scss +70 -0
- package/src/plugins/remove_button/plugin.ts +78 -0
- package/src/plugins/remove_button/types.ts +7 -0
- package/src/plugins/restore_on_backspace/plugin.ts +44 -0
- package/src/plugins/virtual_scroll/plugin.ts +219 -0
- package/src/scss/-tom-select.bootstrap4.scss +4 -0
- package/src/scss/-tom-select.bootstrap5.scss +4 -0
- package/src/scss/_dropdown.scss +99 -0
- package/src/scss/_items.scss +114 -0
- package/src/scss/tom-select.bootstrap4.scss +218 -0
- package/src/scss/tom-select.bootstrap5.scss +270 -0
- package/src/scss/tom-select.default.scss +89 -0
- package/src/scss/tom-select.scss +179 -0
- package/src/tom-select.complete.ts +35 -0
- package/src/tom-select.popular.ts +15 -0
- package/src/tom-select.ts +2807 -0
- package/src/types/core.ts +68 -0
- package/src/types/index.ts +3 -0
- package/src/types/settings.ts +98 -0
- package/src/utils.ts +230 -0
- package/src/vanilla.ts +210 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin: "restore_on_backspace" (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
|
+
|
|
16
|
+
import type TomSelect from '../../tom-select.ts';
|
|
17
|
+
import { TomOption } from '../../types/index.ts';
|
|
18
|
+
import { addClasses } from '../../vanilla.ts';
|
|
19
|
+
|
|
20
|
+
export default function(this:TomSelect) {
|
|
21
|
+
const self = this;
|
|
22
|
+
const orig_canLoad = self.canLoad;
|
|
23
|
+
const orig_clearActiveOption = self.clearActiveOption;
|
|
24
|
+
const orig_loadCallback = self.loadCallback;
|
|
25
|
+
|
|
26
|
+
var pagination:{[key:string]:any} = {};
|
|
27
|
+
var dropdown_content:HTMLElement;
|
|
28
|
+
var loading_more = false;
|
|
29
|
+
var load_more_opt:HTMLElement;
|
|
30
|
+
var default_values: string[] = [];
|
|
31
|
+
|
|
32
|
+
if( !self.settings.shouldLoadMore ){
|
|
33
|
+
|
|
34
|
+
// return true if additional results should be loaded
|
|
35
|
+
self.settings.shouldLoadMore = ():boolean=>{
|
|
36
|
+
|
|
37
|
+
const scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop);
|
|
38
|
+
if( scroll_percent > 0.9 ){
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if( self.activeOption ){
|
|
43
|
+
var selectable = self.selectable();
|
|
44
|
+
var index = Array.from(selectable).indexOf(self.activeOption);
|
|
45
|
+
if( index >= (selectable.length-2) ){
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
if( !self.settings.firstUrl ){
|
|
56
|
+
throw 'virtual_scroll plugin requires a firstUrl() method';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
// in order for virtual scrolling to work,
|
|
61
|
+
// options need to be ordered the same way they're returned from the remote data source
|
|
62
|
+
self.settings.sortField = [{field:'$order'},{field:'$score'}];
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
// can we load more results for given query?
|
|
66
|
+
const canLoadMore = (query:string):boolean => {
|
|
67
|
+
|
|
68
|
+
if( typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions ){
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if( (query in pagination) && pagination[query] ){
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return false;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const clearFilter = (option:TomOption, value:string):boolean => {
|
|
80
|
+
if( self.items.indexOf(value) >= 0 || default_values.indexOf(value) >= 0 ){
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
// set the next url that will be
|
|
88
|
+
self.setNextUrl = (value:string,next_url:any):void => {
|
|
89
|
+
pagination[value] = next_url;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// getUrl() to be used in settings.load()
|
|
93
|
+
self.getUrl = (query:string):any =>{
|
|
94
|
+
|
|
95
|
+
if( query in pagination ){
|
|
96
|
+
const next_url = pagination[query];
|
|
97
|
+
pagination[query] = false;
|
|
98
|
+
return next_url;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// if the user goes back to a previous query
|
|
102
|
+
// we need to load the first page again
|
|
103
|
+
self.clearPagination();
|
|
104
|
+
|
|
105
|
+
return self.settings.firstUrl.call(self,query);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// clear pagination
|
|
109
|
+
self.clearPagination = ():void =>{
|
|
110
|
+
pagination = {};
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// don't clear the active option (and cause unwanted dropdown scroll)
|
|
114
|
+
// while loading more results
|
|
115
|
+
self.hook('instead','clearActiveOption',()=>{
|
|
116
|
+
|
|
117
|
+
if( loading_more ){
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return orig_clearActiveOption.call(self);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// override the canLoad method
|
|
125
|
+
self.hook('instead','canLoad',(query:string)=>{
|
|
126
|
+
|
|
127
|
+
// first time the query has been seen
|
|
128
|
+
if( !(query in pagination) ){
|
|
129
|
+
return orig_canLoad.call(self,query);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return canLoadMore(query);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
// wrap the load
|
|
137
|
+
self.hook('instead','loadCallback',( options:TomOption[], optgroups:TomOption[])=>{
|
|
138
|
+
|
|
139
|
+
if( !loading_more ){
|
|
140
|
+
self.clearOptions(clearFilter);
|
|
141
|
+
}else if( load_more_opt ){
|
|
142
|
+
const first_option = options[0];
|
|
143
|
+
if( first_option !== undefined ){
|
|
144
|
+
load_more_opt.dataset.value = first_option[self.settings.valueField];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
orig_loadCallback.call( self, options, optgroups);
|
|
149
|
+
|
|
150
|
+
loading_more = false;
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
// add templates to dropdown
|
|
155
|
+
// loading_more if we have another url in the queue
|
|
156
|
+
// no_more_results if we don't have another url in the queue
|
|
157
|
+
self.hook('after','refreshOptions',()=>{
|
|
158
|
+
|
|
159
|
+
const query = self.lastValue;
|
|
160
|
+
var option;
|
|
161
|
+
|
|
162
|
+
if( canLoadMore(query) ){
|
|
163
|
+
|
|
164
|
+
option = self.render('loading_more',{query:query});
|
|
165
|
+
if( option ){
|
|
166
|
+
option.setAttribute('data-selectable',''); // so that navigating dropdown with [down] keypresses can navigate to this node
|
|
167
|
+
load_more_opt = option;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
}else if( (query in pagination) && !dropdown_content.querySelector('.no-results') ){
|
|
171
|
+
option = self.render('no_more_results',{query:query});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if( option ){
|
|
175
|
+
addClasses(option,self.settings.optionClass);
|
|
176
|
+
dropdown_content.append( option );
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
// add scroll listener and default templates
|
|
183
|
+
self.on('initialize',()=>{
|
|
184
|
+
default_values = Object.keys(self.options);
|
|
185
|
+
dropdown_content = self.dropdown_content;
|
|
186
|
+
|
|
187
|
+
// default templates
|
|
188
|
+
self.settings.render = Object.assign({}, {
|
|
189
|
+
loading_more:() => {
|
|
190
|
+
return `<div class="loading-more-results">Loading more results ... </div>`;
|
|
191
|
+
},
|
|
192
|
+
no_more_results:() =>{
|
|
193
|
+
return `<div class="no-more-results">No more results</div>`;
|
|
194
|
+
}
|
|
195
|
+
},self.settings.render);
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
// watch dropdown content scroll position
|
|
199
|
+
dropdown_content.addEventListener('scroll',()=>{
|
|
200
|
+
|
|
201
|
+
if( !self.settings.shouldLoadMore.call(self) ){
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// !important: this will get checked again in load() but we still need to check here otherwise loading_more will be set to true
|
|
206
|
+
if( !canLoadMore(self.lastValue) ){
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// don't call load() too much
|
|
211
|
+
if( loading_more ) return;
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
loading_more = true;
|
|
215
|
+
self.load.call(self,self.lastValue);
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
.#{$select-ns}-dropdown {
|
|
2
|
+
position: absolute;
|
|
3
|
+
top: 100%;
|
|
4
|
+
left: 0;
|
|
5
|
+
width: 100%;
|
|
6
|
+
z-index: 10;
|
|
7
|
+
border: $select-dropdown-border;
|
|
8
|
+
background: $select-color-dropdown;
|
|
9
|
+
margin: 0.25rem 0 0;
|
|
10
|
+
border-top: 0 none;
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 10%);
|
|
13
|
+
border-radius: 0 0 $select-border-radius $select-border-radius;
|
|
14
|
+
|
|
15
|
+
[data-selectable] {
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
|
|
19
|
+
.highlight {
|
|
20
|
+
background: $select-color-highlight;
|
|
21
|
+
border-radius: 1px;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.option,
|
|
26
|
+
.optgroup-header,
|
|
27
|
+
.no-results,
|
|
28
|
+
.create {
|
|
29
|
+
padding: $select-padding-dropdown-item-y $select-padding-dropdown-item-x;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.option, [data-disabled], [data-disabled] [data-selectable].option {
|
|
33
|
+
cursor: inherit;
|
|
34
|
+
opacity: 0.5;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
[data-selectable].option {
|
|
38
|
+
opacity: 1;
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.optgroup:first-child .optgroup-header {
|
|
43
|
+
border-top: 0 none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.optgroup-header {
|
|
47
|
+
color: $select-color-optgroup-text;
|
|
48
|
+
background: $select-color-optgroup;
|
|
49
|
+
cursor: default;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.active {
|
|
53
|
+
background-color: $select-color-dropdown-item-active;
|
|
54
|
+
color: $select-color-dropdown-item-active-text;
|
|
55
|
+
|
|
56
|
+
&.create {
|
|
57
|
+
color: $select-color-dropdown-item-create-active-text;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.create {
|
|
62
|
+
color: $select-color-dropdown-item-create-text;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.spinner{
|
|
66
|
+
display: inline-block;
|
|
67
|
+
width: $select-spinner-size;
|
|
68
|
+
height: $select-spinner-size;
|
|
69
|
+
margin: $select-padding-dropdown-item-y $select-padding-dropdown-item-x;
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
&::after {
|
|
73
|
+
content: " ";
|
|
74
|
+
display: block;
|
|
75
|
+
width: $select-spinner-size * .8;
|
|
76
|
+
height: $select-spinner-size * .8;
|
|
77
|
+
margin: $select-spinner-size * .1;
|
|
78
|
+
border-radius: 50%;
|
|
79
|
+
border: $select-spinner-border-size solid $select-spinner-border-color;
|
|
80
|
+
border-color: $select-spinner-border-color transparent $select-spinner-border-color transparent;
|
|
81
|
+
animation: lds-dual-ring 1.2s linear infinite;
|
|
82
|
+
}
|
|
83
|
+
@keyframes lds-dual-ring {
|
|
84
|
+
0% {
|
|
85
|
+
transform: rotate(0deg);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
100% {
|
|
89
|
+
transform: rotate(360deg);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.#{$select-ns}-dropdown-content {
|
|
96
|
+
overflow: hidden auto;
|
|
97
|
+
max-height: $select-max-height-dropdown;
|
|
98
|
+
scroll-behavior: smooth;
|
|
99
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
.#{$select-ns}-control {
|
|
2
|
+
border: $select-border;
|
|
3
|
+
padding: $select-padding-y $select-padding-x;
|
|
4
|
+
width: 100%;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
position: relative;
|
|
7
|
+
z-index: 1;
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
box-shadow: $select-shadow-input;
|
|
10
|
+
border-radius: $select-border-radius;
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-wrap: wrap;
|
|
13
|
+
|
|
14
|
+
.#{$select-ns}-wrapper.multi.has-items & {
|
|
15
|
+
$padding-x: $select-padding-x;
|
|
16
|
+
$padding-top: calc( #{$select-padding-y} - #{$select-padding-item-y} - #{$select-width-item-border});
|
|
17
|
+
$padding-bottom: calc( #{$select-padding-y} - #{$select-padding-item-y} - #{$select-margin-item-y} - #{$select-width-item-border});
|
|
18
|
+
|
|
19
|
+
padding: $padding-top $padding-x $padding-bottom;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.full & {
|
|
23
|
+
background-color: $select-color-input-full;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.disabled &,
|
|
27
|
+
.disabled & * {
|
|
28
|
+
cursor: default !important;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.focus & {
|
|
32
|
+
box-shadow: $select-shadow-input-focus;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
> * {
|
|
36
|
+
vertical-align: baseline;
|
|
37
|
+
display: inline-block;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.#{$select-ns}-wrapper.multi & > div {
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
margin: 0 $select-margin-item-x $select-margin-item-y 0;
|
|
43
|
+
padding: $select-padding-item-y $select-padding-item-x;
|
|
44
|
+
background: $select-color-item;
|
|
45
|
+
color: $select-color-item-text;
|
|
46
|
+
border: $select-width-item-border solid $select-color-item-border;
|
|
47
|
+
overflow: auto;
|
|
48
|
+
|
|
49
|
+
&.active {
|
|
50
|
+
background: $select-color-item-active;
|
|
51
|
+
color: $select-color-item-active-text;
|
|
52
|
+
border: $select-width-item-border solid $select-color-item-active-border;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.#{$select-ns}-wrapper.multi.disabled & > div {
|
|
57
|
+
&, &.active {
|
|
58
|
+
color: lighten(desaturate($select-color-item-text, 100%), $select-lighten-disabled-item-text);
|
|
59
|
+
background: lighten(desaturate($select-color-item, 100%), $select-lighten-disabled-item);
|
|
60
|
+
border: $select-width-item-border solid lighten(desaturate($select-color-item-border, 100%), $select-lighten-disabled-item-border);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
> input {
|
|
65
|
+
flex: 1 1 auto;
|
|
66
|
+
min-width: 7rem;
|
|
67
|
+
display: inline-block !important;
|
|
68
|
+
padding: 0 !important;
|
|
69
|
+
min-height: 0 !important;
|
|
70
|
+
max-height: none !important;
|
|
71
|
+
max-width: 100% !important;
|
|
72
|
+
margin: 0 !important;
|
|
73
|
+
text-indent: 0 !important;
|
|
74
|
+
border: 0 none !important;
|
|
75
|
+
background: none !important;
|
|
76
|
+
line-height: inherit !important;
|
|
77
|
+
user-select: auto !important;
|
|
78
|
+
box-shadow: none !important;
|
|
79
|
+
|
|
80
|
+
&::-ms-clear {
|
|
81
|
+
display: none;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&:focus { outline: none !important; }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.has-items & > input{
|
|
88
|
+
margin: $select-caret-margin !important;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&.rtl {
|
|
92
|
+
text-align: right;
|
|
93
|
+
&.single .#{$select-ns}-control:after {
|
|
94
|
+
left: $select-arrow-offset;
|
|
95
|
+
right: auto;
|
|
96
|
+
}
|
|
97
|
+
.#{$select-ns}-control > input {
|
|
98
|
+
margin: $select-caret-margin-rtl !important;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.disabled & {
|
|
103
|
+
opacity: $select-opacity-disabled;
|
|
104
|
+
background-color: $select-color-disabled;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// hide input, while retaining its focus, and maintain layout so users can still click on the space to bring the display back
|
|
108
|
+
// visibility:hidden can prevent the input from receiving focus
|
|
109
|
+
.input-hidden & > input {
|
|
110
|
+
opacity: 0;
|
|
111
|
+
position: absolute;
|
|
112
|
+
left: -10000px;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tom Select Bootstrap 4
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Import Bootstrap 4 functions and variables
|
|
6
|
+
$state-valid: map-get($form-validation-states,'valid') !default;
|
|
7
|
+
$state-invalid: map-get($form-validation-states,'invalid') !default;
|
|
8
|
+
$enable-shadows: true !default;
|
|
9
|
+
$select-font-family: inherit !default;
|
|
10
|
+
$select-font-size: inherit !default;
|
|
11
|
+
$select-line-height: $input-btn-line-height !default; // formerly line-height-computed
|
|
12
|
+
|
|
13
|
+
$select-color-text: gray("800") !default; // $gray-800
|
|
14
|
+
$select-color-highlight: rgba(255, 237, 40, 40%) !default;
|
|
15
|
+
$select-color-input: $input-bg !default;
|
|
16
|
+
$select-color-input-full: $input-bg !default;
|
|
17
|
+
$select-color-input-error: map-get($state-invalid,'color') !default;
|
|
18
|
+
$select-color-input-error-focus: darken($select-color-input-error, 10%) !default;
|
|
19
|
+
$select-color-disabled: $input-disabled-bg !default;
|
|
20
|
+
$select-color-item: #efefef !default;
|
|
21
|
+
$select-color-item-border: $border-color !default;
|
|
22
|
+
$select-color-item-active: $component-active-bg !default;
|
|
23
|
+
$select-color-item-active-text: #fff !default;
|
|
24
|
+
$select-color-item-active-border: rgba(0, 0, 0, 0%) !default;
|
|
25
|
+
$select-color-optgroup: $dropdown-bg !default;
|
|
26
|
+
$select-color-optgroup-text: $dropdown-header-color !default;
|
|
27
|
+
$select-color-optgroup-border: $dropdown-divider-bg !default;
|
|
28
|
+
$select-color-dropdown: $dropdown-bg !default;
|
|
29
|
+
$select-color-dropdown-border-top: mix($input-border-color, $input-bg, 80%) !default;
|
|
30
|
+
$select-color-dropdown-item-active: $dropdown-link-hover-bg !default;
|
|
31
|
+
$select-color-dropdown-item-active-text: $dropdown-link-hover-color !default;
|
|
32
|
+
$select-color-dropdown-item-create-active-text: $dropdown-link-hover-color !default;
|
|
33
|
+
$select-opacity-disabled: 0.5 !default;
|
|
34
|
+
$select-border: 1px solid $input-border-color !default;
|
|
35
|
+
$select-border-radius: $input-border-radius !default;
|
|
36
|
+
$select-width-item-border: 0 !default;
|
|
37
|
+
$select-padding-x: $input-btn-padding-x !default;
|
|
38
|
+
$select-padding-y: $input-btn-padding-y !default;
|
|
39
|
+
$select-padding-dropdown-item-x: $input-btn-padding-x !default;
|
|
40
|
+
$select-padding-dropdown-item-y: 3px !default;
|
|
41
|
+
$select-padding-item-x: 5px !default;
|
|
42
|
+
$select-padding-item-y: 1px !default;
|
|
43
|
+
$select-margin-item-x: 3px !default;
|
|
44
|
+
$select-margin-item-y: 3px !default;
|
|
45
|
+
$select-arrow-size: 5px !default;
|
|
46
|
+
$select-arrow-color: $select-color-text !default;
|
|
47
|
+
$select-arrow-offset: calc(#{$select-padding-x} + 5px) !default;
|
|
48
|
+
|
|
49
|
+
@import "tom-select";
|
|
50
|
+
@include ts-caret;
|
|
51
|
+
|
|
52
|
+
.#{$select-ns}-wrapper.form-control,
|
|
53
|
+
.#{$select-ns}-wrapper.form-select {
|
|
54
|
+
padding:0 !important;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.#{$select-ns}-dropdown,
|
|
58
|
+
.#{$select-ns}-dropdown.form-control {
|
|
59
|
+
height: auto;
|
|
60
|
+
padding: 0;
|
|
61
|
+
z-index: $zindex-dropdown;
|
|
62
|
+
background: $select-color-dropdown;
|
|
63
|
+
border: 1px solid $dropdown-border-color; // $dropdown-fallback-border
|
|
64
|
+
border-radius: $border-radius;
|
|
65
|
+
box-shadow: 0 6px 12px rgba(0, 0, 0, 17.5%);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.#{$select-ns}-dropdown {
|
|
69
|
+
.optgroup-header {
|
|
70
|
+
font-size: $font-size-sm;
|
|
71
|
+
line-height: $line-height-base;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.optgroup:first-child::before {
|
|
75
|
+
display: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.optgroup::before {
|
|
79
|
+
content: ' ';
|
|
80
|
+
display: block;
|
|
81
|
+
height: 0;
|
|
82
|
+
margin: $dropdown-divider-margin-y 0;
|
|
83
|
+
overflow: hidden;
|
|
84
|
+
border-top: 1px solid $dropdown-divider-bg;
|
|
85
|
+
margin-left: $select-padding-dropdown-item-x * -1;
|
|
86
|
+
margin-right: $select-padding-dropdown-item-x * -1;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.create {
|
|
90
|
+
padding-left: $select-padding-dropdown-item-x;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.#{$select-ns}-dropdown-content {
|
|
95
|
+
padding: 5px 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.#{$select-ns}-control {
|
|
99
|
+
min-height: $input-height;
|
|
100
|
+
@include box-shadow($input-box-shadow);
|
|
101
|
+
@include transition($input-transition);
|
|
102
|
+
|
|
103
|
+
display:flex;
|
|
104
|
+
align-items: center;
|
|
105
|
+
|
|
106
|
+
.focus & {
|
|
107
|
+
border-color: $input-focus-border-color;
|
|
108
|
+
outline: 0;
|
|
109
|
+
@if $enable-shadows {
|
|
110
|
+
box-shadow: $input-box-shadow, $input-focus-box-shadow;
|
|
111
|
+
} @else {
|
|
112
|
+
box-shadow: $input-focus-box-shadow;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
input::placeholder {
|
|
117
|
+
color: #a7aeb8;
|
|
118
|
+
opacity: 1;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.is-invalid .#{$select-ns}-control,
|
|
123
|
+
.was-validated .invalid .#{$select-ns}-control{
|
|
124
|
+
border-color: $select-color-input-error;
|
|
125
|
+
|
|
126
|
+
.focus & {
|
|
127
|
+
border-color: $select-color-input-error-focus;
|
|
128
|
+
box-shadow: 0 0 0 $input-focus-width rgba($select-color-input-error, .25);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.is-valid .#{$select-ns}-control {
|
|
133
|
+
$_color: map-get($state-valid,'color');
|
|
134
|
+
|
|
135
|
+
border-color: $_color;
|
|
136
|
+
|
|
137
|
+
.focus & {
|
|
138
|
+
border-color: $_color;
|
|
139
|
+
box-shadow: 0 0 0 $input-focus-width rgba($_color, .25);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.#{$select-ns}-wrapper {
|
|
144
|
+
.input-group-sm > &,
|
|
145
|
+
&.form-control-sm {
|
|
146
|
+
|
|
147
|
+
.#{$select-ns}-control {
|
|
148
|
+
min-height: $input-height-sm;
|
|
149
|
+
padding: 0 .75rem;
|
|
150
|
+
|
|
151
|
+
// padding: $input-padding-y-sm $input-padding-x-sm;
|
|
152
|
+
@include border-radius($input-border-radius-sm);
|
|
153
|
+
@include font-size($input-font-size-sm);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
&.has-items .#{$select-ns}-control {
|
|
157
|
+
min-height: $input-height-sm !important;
|
|
158
|
+
font-size: $input-font-size-sm;
|
|
159
|
+
padding-bottom: 0;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.input-group-sm > &.multi.has-items,
|
|
164
|
+
&.form-control-sm.multi.has-items {
|
|
165
|
+
.#{$select-ns}-control {
|
|
166
|
+
// padding-top = ($input-height-sm - border-width - item-height) / 2;
|
|
167
|
+
// item-height = ($select-line-height * $input-font-size-sm) + ($select-padding-item-y * 2)
|
|
168
|
+
$border-and-padding: add($input-border-width,$select-padding-item-y) * 2;
|
|
169
|
+
$ts-select-padding-sm: calc( (#{$input-height-sm} - (#{$select-line-height} * #{$input-font-size-sm}) - #{$border-and-padding})/2);
|
|
170
|
+
|
|
171
|
+
padding-top: $ts-select-padding-sm !important;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
&.multi {
|
|
176
|
+
&.has-items .#{$select-ns}-control {
|
|
177
|
+
padding-left: calc(#{$select-padding-x} - #{$select-padding-item-x});
|
|
178
|
+
|
|
179
|
+
--ts-pr-min: calc(#{$select-padding-x} - #{$select-padding-item-x});
|
|
180
|
+
}
|
|
181
|
+
.#{$select-ns}-control > div {
|
|
182
|
+
border-radius: calc(#{$select-border-radius} - 1px);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.input-group-lg > & >,
|
|
187
|
+
&.form-control-lg {
|
|
188
|
+
.#{$select-ns}-control {
|
|
189
|
+
min-height: $input-height-lg;
|
|
190
|
+
@include border-radius($input-border-radius-lg);
|
|
191
|
+
@include font-size($input-font-size-lg);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.form-control.#{$select-ns}-wrapper {
|
|
197
|
+
padding: 0;
|
|
198
|
+
height: auto;
|
|
199
|
+
border: none;
|
|
200
|
+
background: none;
|
|
201
|
+
border-radius: 0;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.input-group {
|
|
205
|
+
& > .#{$select-ns}-wrapper {
|
|
206
|
+
flex-grow: 1;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
& > .#{$select-ns}-wrapper:not(:nth-child(2)) > .#{$select-ns}-control {
|
|
210
|
+
border-top-left-radius: 0;
|
|
211
|
+
border-bottom-left-radius: 0;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
& > .#{$select-ns}-wrapper:not(:last-child) > .#{$select-ns}-control {
|
|
215
|
+
border-top-right-radius: 0;
|
|
216
|
+
border-bottom-right-radius: 0;
|
|
217
|
+
}
|
|
218
|
+
}
|