@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,497 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tom-select.css (v//@@version)
|
|
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
|
+
.ts-control {
|
|
16
|
+
border: 1px solid #d0d0d0;
|
|
17
|
+
padding: 8px 8px;
|
|
18
|
+
width: 100%;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
position: relative;
|
|
21
|
+
z-index: 1;
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.1);
|
|
24
|
+
border-radius: 3px;
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-wrap: wrap;
|
|
27
|
+
}
|
|
28
|
+
.ts-wrapper.multi.has-items .ts-control {
|
|
29
|
+
padding: calc(8px - 2px - 1px) 8px calc(8px - 2px - 3px - 1px);
|
|
30
|
+
}
|
|
31
|
+
.full .ts-control {
|
|
32
|
+
background-color: #fff;
|
|
33
|
+
}
|
|
34
|
+
.disabled .ts-control, .disabled .ts-control * {
|
|
35
|
+
cursor: default !important;
|
|
36
|
+
}
|
|
37
|
+
.focus .ts-control {
|
|
38
|
+
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
|
|
39
|
+
}
|
|
40
|
+
.ts-control > * {
|
|
41
|
+
vertical-align: baseline;
|
|
42
|
+
display: inline-block;
|
|
43
|
+
}
|
|
44
|
+
.ts-wrapper.multi .ts-control > div {
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
margin: 0 3px 3px 0;
|
|
47
|
+
padding: 2px 6px;
|
|
48
|
+
background: #1da7ee;
|
|
49
|
+
color: #fff;
|
|
50
|
+
border: 1px solid #0073bb;
|
|
51
|
+
overflow: auto;
|
|
52
|
+
}
|
|
53
|
+
.ts-wrapper.multi .ts-control > div.active {
|
|
54
|
+
background: #92c836;
|
|
55
|
+
color: #fff;
|
|
56
|
+
border: 1px solid #00578d;
|
|
57
|
+
}
|
|
58
|
+
.ts-wrapper.multi.disabled .ts-control > div, .ts-wrapper.multi.disabled .ts-control > div.active {
|
|
59
|
+
color: white;
|
|
60
|
+
background: #d2d2d2;
|
|
61
|
+
border: 1px solid #aaaaaa;
|
|
62
|
+
}
|
|
63
|
+
.ts-control > input {
|
|
64
|
+
flex: 1 1 auto;
|
|
65
|
+
min-width: 7rem;
|
|
66
|
+
display: inline-block !important;
|
|
67
|
+
padding: 0 !important;
|
|
68
|
+
min-height: 0 !important;
|
|
69
|
+
max-height: none !important;
|
|
70
|
+
max-width: 100% !important;
|
|
71
|
+
margin: 0 !important;
|
|
72
|
+
text-indent: 0 !important;
|
|
73
|
+
border: 0 none !important;
|
|
74
|
+
background: none !important;
|
|
75
|
+
line-height: inherit !important;
|
|
76
|
+
user-select: auto !important;
|
|
77
|
+
box-shadow: none !important;
|
|
78
|
+
}
|
|
79
|
+
.ts-control > input::-ms-clear {
|
|
80
|
+
display: none;
|
|
81
|
+
}
|
|
82
|
+
.ts-control > input:focus {
|
|
83
|
+
outline: none !important;
|
|
84
|
+
}
|
|
85
|
+
.has-items .ts-control > input {
|
|
86
|
+
margin: 0px 4px !important;
|
|
87
|
+
}
|
|
88
|
+
.ts-control.rtl {
|
|
89
|
+
text-align: right;
|
|
90
|
+
}
|
|
91
|
+
.ts-control.rtl.single .ts-control:after {
|
|
92
|
+
left: 15px;
|
|
93
|
+
right: auto;
|
|
94
|
+
}
|
|
95
|
+
.ts-control.rtl .ts-control > input {
|
|
96
|
+
margin: 0px 4px 0px -2px !important;
|
|
97
|
+
}
|
|
98
|
+
.disabled .ts-control {
|
|
99
|
+
opacity: 0.5;
|
|
100
|
+
background-color: #fafafa;
|
|
101
|
+
}
|
|
102
|
+
.input-hidden .ts-control > input {
|
|
103
|
+
opacity: 0;
|
|
104
|
+
position: absolute;
|
|
105
|
+
left: -10000px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.ts-dropdown {
|
|
109
|
+
position: absolute;
|
|
110
|
+
top: 100%;
|
|
111
|
+
left: 0;
|
|
112
|
+
width: 100%;
|
|
113
|
+
z-index: 10;
|
|
114
|
+
border: 1px solid #d0d0d0;
|
|
115
|
+
background: #fff;
|
|
116
|
+
margin: 0.25rem 0 0;
|
|
117
|
+
border-top: 0 none;
|
|
118
|
+
box-sizing: border-box;
|
|
119
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
120
|
+
border-radius: 0 0 3px 3px;
|
|
121
|
+
}
|
|
122
|
+
.ts-dropdown [data-selectable] {
|
|
123
|
+
cursor: pointer;
|
|
124
|
+
overflow: hidden;
|
|
125
|
+
}
|
|
126
|
+
.ts-dropdown [data-selectable] .highlight {
|
|
127
|
+
background: rgba(125, 168, 208, 0.2);
|
|
128
|
+
border-radius: 1px;
|
|
129
|
+
}
|
|
130
|
+
.ts-dropdown .option,
|
|
131
|
+
.ts-dropdown .optgroup-header,
|
|
132
|
+
.ts-dropdown .no-results,
|
|
133
|
+
.ts-dropdown .create {
|
|
134
|
+
padding: 5px 8px;
|
|
135
|
+
}
|
|
136
|
+
.ts-dropdown .option, .ts-dropdown [data-disabled], .ts-dropdown [data-disabled] [data-selectable].option {
|
|
137
|
+
cursor: inherit;
|
|
138
|
+
opacity: 0.5;
|
|
139
|
+
}
|
|
140
|
+
.ts-dropdown [data-selectable].option {
|
|
141
|
+
opacity: 1;
|
|
142
|
+
cursor: pointer;
|
|
143
|
+
}
|
|
144
|
+
.ts-dropdown .optgroup:first-child .optgroup-header {
|
|
145
|
+
border-top: 0 none;
|
|
146
|
+
}
|
|
147
|
+
.ts-dropdown .optgroup-header {
|
|
148
|
+
color: #303030;
|
|
149
|
+
background: #fff;
|
|
150
|
+
cursor: default;
|
|
151
|
+
}
|
|
152
|
+
.ts-dropdown .active {
|
|
153
|
+
background-color: #f5fafd;
|
|
154
|
+
color: #495c68;
|
|
155
|
+
}
|
|
156
|
+
.ts-dropdown .active.create {
|
|
157
|
+
color: #495c68;
|
|
158
|
+
}
|
|
159
|
+
.ts-dropdown .create {
|
|
160
|
+
color: rgba(48, 48, 48, 0.5);
|
|
161
|
+
}
|
|
162
|
+
.ts-dropdown .spinner {
|
|
163
|
+
display: inline-block;
|
|
164
|
+
width: 30px;
|
|
165
|
+
height: 30px;
|
|
166
|
+
margin: 5px 8px;
|
|
167
|
+
}
|
|
168
|
+
.ts-dropdown .spinner::after {
|
|
169
|
+
content: " ";
|
|
170
|
+
display: block;
|
|
171
|
+
width: 24px;
|
|
172
|
+
height: 24px;
|
|
173
|
+
margin: 3px;
|
|
174
|
+
border-radius: 50%;
|
|
175
|
+
border: 5px solid #d0d0d0;
|
|
176
|
+
border-color: #d0d0d0 transparent #d0d0d0 transparent;
|
|
177
|
+
animation: lds-dual-ring 1.2s linear infinite;
|
|
178
|
+
}
|
|
179
|
+
@keyframes lds-dual-ring {
|
|
180
|
+
0% {
|
|
181
|
+
transform: rotate(0deg);
|
|
182
|
+
}
|
|
183
|
+
100% {
|
|
184
|
+
transform: rotate(360deg);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.ts-dropdown-content {
|
|
189
|
+
overflow: hidden auto;
|
|
190
|
+
max-height: 200px;
|
|
191
|
+
scroll-behavior: smooth;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.ts-wrapper.plugin-drag_drop .ts-dragging {
|
|
195
|
+
color: transparent !important;
|
|
196
|
+
}
|
|
197
|
+
.ts-wrapper.plugin-drag_drop .ts-dragging > * {
|
|
198
|
+
visibility: hidden !important;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.plugin-checkbox_options:not(.rtl) .option input {
|
|
202
|
+
margin-right: 0.5rem;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.plugin-checkbox_options.rtl .option input {
|
|
206
|
+
margin-left: 0.5rem;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/* stylelint-disable function-name-case */
|
|
210
|
+
.plugin-clear_button {
|
|
211
|
+
--ts-pr-clear-button: 1em;
|
|
212
|
+
}
|
|
213
|
+
.plugin-clear_button .clear-button {
|
|
214
|
+
opacity: 0;
|
|
215
|
+
position: absolute;
|
|
216
|
+
top: 50%;
|
|
217
|
+
transform: translateY(-50%);
|
|
218
|
+
right: calc(8px - 6px);
|
|
219
|
+
margin-right: 0 !important;
|
|
220
|
+
background: transparent !important;
|
|
221
|
+
transition: opacity 0.5s;
|
|
222
|
+
cursor: pointer;
|
|
223
|
+
}
|
|
224
|
+
.plugin-clear_button.form-select .clear-button, .plugin-clear_button.single .clear-button {
|
|
225
|
+
right: max(var(--ts-pr-caret), 8px);
|
|
226
|
+
}
|
|
227
|
+
.plugin-clear_button.focus.has-items .clear-button, .plugin-clear_button:not(.disabled):hover.has-items .clear-button {
|
|
228
|
+
opacity: 1;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.ts-wrapper .dropdown-header {
|
|
232
|
+
position: relative;
|
|
233
|
+
padding: 10px 8px;
|
|
234
|
+
border-bottom: 1px solid #d0d0d0;
|
|
235
|
+
background: color-mix(#fff, #d0d0d0, 85%);
|
|
236
|
+
border-radius: 3px 3px 0 0;
|
|
237
|
+
}
|
|
238
|
+
.ts-wrapper .dropdown-header-close {
|
|
239
|
+
position: absolute;
|
|
240
|
+
right: 8px;
|
|
241
|
+
top: 50%;
|
|
242
|
+
color: #303030;
|
|
243
|
+
opacity: 0.4;
|
|
244
|
+
margin-top: -12px;
|
|
245
|
+
line-height: 20px;
|
|
246
|
+
font-size: 20px !important;
|
|
247
|
+
}
|
|
248
|
+
.ts-wrapper .dropdown-header-close:hover {
|
|
249
|
+
color: black;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.plugin-dropdown_input.focus.dropdown-active .ts-control {
|
|
253
|
+
box-shadow: none;
|
|
254
|
+
border: 1px solid #d0d0d0;
|
|
255
|
+
}
|
|
256
|
+
.plugin-dropdown_input .dropdown-input {
|
|
257
|
+
border: 1px solid #d0d0d0;
|
|
258
|
+
border-width: 0 0 1px;
|
|
259
|
+
display: block;
|
|
260
|
+
padding: 8px 8px;
|
|
261
|
+
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.1);
|
|
262
|
+
width: 100%;
|
|
263
|
+
background: transparent;
|
|
264
|
+
}
|
|
265
|
+
.plugin-dropdown_input .items-placeholder {
|
|
266
|
+
border: 0 none !important;
|
|
267
|
+
box-shadow: none !important;
|
|
268
|
+
width: 100%;
|
|
269
|
+
}
|
|
270
|
+
.plugin-dropdown_input.has-items .items-placeholder, .plugin-dropdown_input.dropdown-active .items-placeholder {
|
|
271
|
+
display: none !important;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.ts-wrapper.plugin-input_autogrow.has-items .ts-control > input {
|
|
275
|
+
min-width: 0;
|
|
276
|
+
}
|
|
277
|
+
.ts-wrapper.plugin-input_autogrow.has-items.focus .ts-control > input {
|
|
278
|
+
flex: none;
|
|
279
|
+
min-width: 4px;
|
|
280
|
+
}
|
|
281
|
+
.ts-wrapper.plugin-input_autogrow.has-items.focus .ts-control > input::placeholder {
|
|
282
|
+
color: transparent;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.ts-dropdown.plugin-optgroup_columns .ts-dropdown-content {
|
|
286
|
+
display: flex;
|
|
287
|
+
}
|
|
288
|
+
.ts-dropdown.plugin-optgroup_columns .optgroup {
|
|
289
|
+
border-right: 1px solid #f2f2f2;
|
|
290
|
+
border-top: 0 none;
|
|
291
|
+
flex-grow: 1;
|
|
292
|
+
flex-basis: 0;
|
|
293
|
+
min-width: 0;
|
|
294
|
+
}
|
|
295
|
+
.ts-dropdown.plugin-optgroup_columns .optgroup:last-child {
|
|
296
|
+
border-right: 0 none;
|
|
297
|
+
}
|
|
298
|
+
.ts-dropdown.plugin-optgroup_columns .optgroup::before {
|
|
299
|
+
display: none;
|
|
300
|
+
}
|
|
301
|
+
.ts-dropdown.plugin-optgroup_columns .optgroup-header {
|
|
302
|
+
border-top: 0 none;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.ts-wrapper.plugin-remove_button .item {
|
|
306
|
+
display: inline-flex;
|
|
307
|
+
align-items: center;
|
|
308
|
+
}
|
|
309
|
+
.ts-wrapper.plugin-remove_button .item .remove {
|
|
310
|
+
color: inherit;
|
|
311
|
+
text-decoration: none;
|
|
312
|
+
vertical-align: middle;
|
|
313
|
+
display: inline-block;
|
|
314
|
+
padding: 0 6px;
|
|
315
|
+
border-radius: 0 2px 2px 0;
|
|
316
|
+
box-sizing: border-box;
|
|
317
|
+
}
|
|
318
|
+
.ts-wrapper.plugin-remove_button .item .remove:hover {
|
|
319
|
+
background: rgba(0, 0, 0, 0.05);
|
|
320
|
+
}
|
|
321
|
+
.ts-wrapper.plugin-remove_button.disabled .item .remove:hover {
|
|
322
|
+
background: none;
|
|
323
|
+
}
|
|
324
|
+
.ts-wrapper.plugin-remove_button .remove-single {
|
|
325
|
+
position: absolute;
|
|
326
|
+
right: 0;
|
|
327
|
+
top: 0;
|
|
328
|
+
font-size: 23px;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.ts-wrapper.plugin-remove_button:not(.rtl) .item {
|
|
332
|
+
padding-right: 0 !important;
|
|
333
|
+
}
|
|
334
|
+
.ts-wrapper.plugin-remove_button:not(.rtl) .item .remove {
|
|
335
|
+
border-left: 1px solid #0073bb;
|
|
336
|
+
margin-left: 6px;
|
|
337
|
+
}
|
|
338
|
+
.ts-wrapper.plugin-remove_button:not(.rtl) .item.active .remove {
|
|
339
|
+
border-left-color: #00578d;
|
|
340
|
+
}
|
|
341
|
+
.ts-wrapper.plugin-remove_button:not(.rtl).disabled .item .remove {
|
|
342
|
+
border-left-color: #aaaaaa;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.ts-wrapper.plugin-remove_button.rtl .item {
|
|
346
|
+
padding-left: 0 !important;
|
|
347
|
+
}
|
|
348
|
+
.ts-wrapper.plugin-remove_button.rtl .item .remove {
|
|
349
|
+
border-right: 1px solid #0073bb;
|
|
350
|
+
margin-right: 6px;
|
|
351
|
+
}
|
|
352
|
+
.ts-wrapper.plugin-remove_button.rtl .item.active .remove {
|
|
353
|
+
border-right-color: #00578d;
|
|
354
|
+
}
|
|
355
|
+
.ts-wrapper.plugin-remove_button.rtl.disabled .item .remove {
|
|
356
|
+
border-right-color: #aaaaaa;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
:root {
|
|
360
|
+
--ts-pr-clear-button: 0px;
|
|
361
|
+
--ts-pr-caret: 0px;
|
|
362
|
+
--ts-pr-min: .75rem;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.ts-wrapper.single .ts-control, .ts-wrapper.single .ts-control input {
|
|
366
|
+
cursor: pointer;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
.ts-control:not(.rtl) {
|
|
370
|
+
padding-right: max(var(--ts-pr-min), var(--ts-pr-clear-button) + var(--ts-pr-caret)) !important;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.ts-control.rtl {
|
|
374
|
+
padding-left: max(var(--ts-pr-min), var(--ts-pr-clear-button) + var(--ts-pr-caret)) !important;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.ts-wrapper {
|
|
378
|
+
position: relative;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.ts-dropdown,
|
|
382
|
+
.ts-control,
|
|
383
|
+
.ts-control input {
|
|
384
|
+
color: #303030;
|
|
385
|
+
font-family: inherit;
|
|
386
|
+
font-size: 13px;
|
|
387
|
+
line-height: 18px;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
.ts-control,
|
|
391
|
+
.ts-wrapper.single.input-active .ts-control {
|
|
392
|
+
background: #fff;
|
|
393
|
+
cursor: text;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.ts-hidden-accessible {
|
|
397
|
+
border: 0 !important;
|
|
398
|
+
clip: rect(0 0 0 0) !important;
|
|
399
|
+
clip-path: inset(50%) !important;
|
|
400
|
+
overflow: hidden !important;
|
|
401
|
+
padding: 0 !important;
|
|
402
|
+
position: absolute !important;
|
|
403
|
+
width: 1px !important;
|
|
404
|
+
white-space: nowrap !important;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.ts-wrapper.single .ts-control {
|
|
408
|
+
--ts-pr-caret: 2rem;
|
|
409
|
+
}
|
|
410
|
+
.ts-wrapper.single .ts-control::after {
|
|
411
|
+
content: " ";
|
|
412
|
+
display: block;
|
|
413
|
+
position: absolute;
|
|
414
|
+
top: 50%;
|
|
415
|
+
margin-top: -3px;
|
|
416
|
+
width: 0;
|
|
417
|
+
height: 0;
|
|
418
|
+
border-style: solid;
|
|
419
|
+
border-width: 5px 5px 0 5px;
|
|
420
|
+
border-color: #808080 transparent transparent transparent;
|
|
421
|
+
}
|
|
422
|
+
.ts-wrapper.single .ts-control:not(.rtl)::after {
|
|
423
|
+
right: 15px;
|
|
424
|
+
}
|
|
425
|
+
.ts-wrapper.single .ts-control.rtl::after {
|
|
426
|
+
left: 15px;
|
|
427
|
+
}
|
|
428
|
+
.ts-wrapper.single.dropdown-active .ts-control::after {
|
|
429
|
+
margin-top: -4px;
|
|
430
|
+
border-width: 0 5px 5px 5px;
|
|
431
|
+
border-color: transparent transparent #808080 transparent;
|
|
432
|
+
}
|
|
433
|
+
.ts-wrapper.single.input-active .ts-control, .ts-wrapper.single.input-active .ts-control input {
|
|
434
|
+
cursor: text;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
.ts-wrapper {
|
|
438
|
+
display: flex;
|
|
439
|
+
min-height: 36px;
|
|
440
|
+
}
|
|
441
|
+
.ts-wrapper.multi.has-items .ts-control {
|
|
442
|
+
padding-left: 5px;
|
|
443
|
+
--ts-pr-min: 5px;
|
|
444
|
+
}
|
|
445
|
+
.ts-wrapper.multi .ts-control [data-value] {
|
|
446
|
+
text-shadow: 0 1px 0 rgba(0, 51, 83, 0.3);
|
|
447
|
+
border-radius: 3px;
|
|
448
|
+
background-color: color-mix(#1da7ee, #178ee9, 60%);
|
|
449
|
+
background-image: linear-gradient(to bottom, #1da7ee, #178ee9);
|
|
450
|
+
background-repeat: repeat-x;
|
|
451
|
+
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), inset 0 1px rgba(255, 255, 255, 0.03);
|
|
452
|
+
}
|
|
453
|
+
.ts-wrapper.multi .ts-control [data-value].active {
|
|
454
|
+
background-color: color-mix(#008fd8, #0075cf, 60%);
|
|
455
|
+
background-image: linear-gradient(to bottom, #008fd8, #0075cf);
|
|
456
|
+
background-repeat: repeat-x;
|
|
457
|
+
}
|
|
458
|
+
.ts-wrapper.multi.disabled .ts-control [data-value] {
|
|
459
|
+
color: #999;
|
|
460
|
+
text-shadow: none;
|
|
461
|
+
background: none;
|
|
462
|
+
box-shadow: none;
|
|
463
|
+
}
|
|
464
|
+
.ts-wrapper.multi.disabled .ts-control [data-value], .ts-wrapper.multi.disabled .ts-control [data-value] .remove {
|
|
465
|
+
border-color: #e6e6e6;
|
|
466
|
+
}
|
|
467
|
+
.ts-wrapper.multi.disabled .ts-control [data-value] .remove {
|
|
468
|
+
background: none;
|
|
469
|
+
}
|
|
470
|
+
.ts-wrapper.single .ts-control {
|
|
471
|
+
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.8);
|
|
472
|
+
background-color: color-mix(#fefefe, #f2f2f2, 60%);
|
|
473
|
+
background-image: linear-gradient(to bottom, #fefefe, #f2f2f2);
|
|
474
|
+
background-repeat: repeat-x;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
.ts-wrapper.single .ts-control, .ts-dropdown.single {
|
|
478
|
+
border-color: #b8b8b8;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
.dropdown-active .ts-control {
|
|
482
|
+
border-radius: 3px 3px 0 0;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
.ts-dropdown .optgroup-header {
|
|
486
|
+
padding-top: 7px;
|
|
487
|
+
font-weight: bold;
|
|
488
|
+
font-size: 0.85em;
|
|
489
|
+
}
|
|
490
|
+
.ts-dropdown .optgroup {
|
|
491
|
+
border-top: 1px solid #f0f0f0;
|
|
492
|
+
}
|
|
493
|
+
.ts-dropdown .optgroup:first-child {
|
|
494
|
+
border-top: 0 none;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/*# sourceMappingURL=tom-select.default.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../../src/scss/tom-select.scss","../../src/scss/_items.scss","../../src/scss/tom-select.default.scss","../../src/scss/_dropdown.scss","../../src/plugins/drag_drop/plugin.scss","../../src/plugins/checkbox_options/plugin.scss","../../src/plugins/clear_button/plugin.scss","../../src/plugins/dropdown_header/plugin.scss","../../src/plugins/dropdown_input/plugin.scss","../../src/plugins/input_autogrow/plugin.scss","../../src/plugins/optgroup_columns/plugin.scss","../../src/plugins/remove_button/plugin.scss"],"names":[],"mappings":"AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA;EACC,QD+CuB;EC9CvB;EACA;EACA;EACA;EACA;EACA;EACA,YCDwB;EDExB,eDyC4B;ECxC5B;EACA;;AAEA;EAKC;;AAGD;EACC,kBDCyB;;ACE1B;EAEC;;AAGD;EACC,YCvB4B;;AD0B7B;EACC;EACA;;AAGD;EACC;EACA;EACA;EACA,YC3CsB;ED4CtB,OC3CyB;ED4CzB;EACA;;AAEA;EACC,YC7C0B;ED8C1B,OChD8B;EDiD9B;;AAKD;EACC;EACA;EACA;;AAIF;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACC;;AAGD;EAAU;;AAGX;EACC;;AAGD;EACC;;AACA;EACC,MD9ByB;EC+BzB;;AAED;EACC;;AAIF;EACC,SD1D6B;EC2D7B,kBD9E4B;;ACmF7B;EACC;EACA;EACA;;;AE/GF;EACC;EACA;EACA;EACA;EACA;EACA,QH2C6B;EG1C7B,YHyB6B;EGxB7B;EACA;EACA;EACA;EACA;;AAEA;EACC;EACA;;AAEA;EACC,YHG2B;EGF3B;;AAIF;AAAA;AAAA;AAAA;EAIC;;AAGD;EACC;EACA;;AAGD;EACC;EACA;;AAGD;EACC;;AAGD;EACC,OH1ByB;EG2BzB,YHf4B;EGgB5B;;AAGD;EACC,kBHjBqC;EGkBrC,OHjBwC;;AGmBxC;EACC,OHpBuC;;AGwBzC;EACC,OHxBwC;;AG2BzC;EACC;EACA;EACA,QHD0B;EGE1B;;AAGA;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAED;EACC;IACC;;EAGD;IACC;;;;AAMJ;EACC;EACA,YH5CgC;EG6ChC;;;AChGA;EACC;;AAGD;EACC;;;ACLD;EACC;;;AAKD;EACC;;;ACRF;AAEA;EACC;;AAEA;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGD;EAIE;;AAOF;EAEC;;;AC7BD;EACC;EACA;EACA;EACA;EACA;;AAGD;EACC;EACA,OP0CwB;EOzCxB;EACA,OPOyB;EONzB;EACA;EACA;EACA;;AAGD;EACC;;;ACnBD;EACC;EACA,QR4CsB;;AQtCvB;EACC;EACA;EACA;EACA;EACA,YNRuB;EMSvB;EACA;;AAeD;EACC;EACA;EACA;;AAGD;EAEC;;;ACtCD;EACC;;AAGD;EACC;EACA;;AAEA;EACC;;;ACVF;EACC;;AAGD;EACC;EACA;EACA;EACA;EACA;;AAGD;EACC;;AAGD;EACC;;AAGD;EACC;;;ACrBD;EACC;EACA;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;;AAGD;EACC;;AAGD;EACC;;AAID;EACC;EACA;EACA;EACA;;;AAKD;EACC;;AAGD;EACC;EACA,aXe4B;;AWZ7B;EACC,mBTvCgC;;AS0CjC;EACC;;;AAKD;EACC;;AAGD;EACC;EACA,cXJ4B;;AWO7B;EACC,oBT1DgC;;AS6DjC;EACC;;;AXeF;EACC;EACA;EACA;;;AAWC;EACC;;;AAKH;EACC;;;AAGD;EACC;;;AA2CD;EACC;;;AAGD;AAAA;AAAA;EAGC,OAzI0B;EA0I1B,aA7I0B;EA8I1B,WA7IyB;EA8IzB,aA7I0B;;;AAgJ3B;AAAA;EAEC,YA9I0B;EA+I1B;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAjEC;EACC;;AAEA;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGD;EACC,OAlEwB;;AAqEzB;EACC,MAtEwB;;AA0E1B;EACC;EACA;EACA;;AAGD;EAEC;;;AEpIH;EACC;EACA;;AAGC;EAGC,cAFY;EAIZ;;AAIA;EACC;EACA;EF4DA;EACA;EACA;EE3DA;;AAEA;EFuDA;EACA;EACA;;AEnDF;EACC;EACA;EACA;EACA;;AAEA;EACC;;AAGD;EACC;;AAMF;EACC;EF+BC;EACA;EACA;;;AE3BJ;EACC;;;AAIA;EACC;;;AAKD;EACC;EACA;EACA;;AAGD;EACC;;AAEA;EACC","file":"tom-select.default.css"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tom Select v2.5.2
|
|
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
|
+
/**
|
|
22
|
+
* Iterates over arrays and hashes.
|
|
23
|
+
*
|
|
24
|
+
* ```
|
|
25
|
+
* iterate(this.items, function(item, id) {
|
|
26
|
+
* // invoked for each item
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
const iterate = (object, callback) => {
|
|
32
|
+
if (Array.isArray(object)) {
|
|
33
|
+
object.forEach(callback);
|
|
34
|
+
} else {
|
|
35
|
+
for (var key in object) {
|
|
36
|
+
if (object.hasOwnProperty(key)) {
|
|
37
|
+
callback(object[key], key);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Remove css classes
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
const removeClasses = (elmts, ...classes) => {
|
|
48
|
+
var norm_classes = classesArray(classes);
|
|
49
|
+
elmts = castAsArray(elmts);
|
|
50
|
+
elmts.map(el => {
|
|
51
|
+
norm_classes.map(cls => {
|
|
52
|
+
el.classList.remove(cls);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Return arguments
|
|
59
|
+
*
|
|
60
|
+
*/
|
|
61
|
+
const classesArray = args => {
|
|
62
|
+
var classes = [];
|
|
63
|
+
iterate(args, _classes => {
|
|
64
|
+
if (typeof _classes === 'string') {
|
|
65
|
+
_classes = _classes.trim().split(/[\t\n\f\r\s]/);
|
|
66
|
+
}
|
|
67
|
+
if (Array.isArray(_classes)) {
|
|
68
|
+
classes = classes.concat(_classes);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return classes.filter(Boolean);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Create an array from arg if it's not already an array
|
|
76
|
+
*
|
|
77
|
+
*/
|
|
78
|
+
const castAsArray = arg => {
|
|
79
|
+
if (!Array.isArray(arg)) {
|
|
80
|
+
arg = [arg];
|
|
81
|
+
}
|
|
82
|
+
return arg;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Get the index of an element amongst sibling nodes of the same type
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
const nodeIndex = (el, amongst) => {
|
|
90
|
+
if (!el) return -1;
|
|
91
|
+
amongst = amongst || el.nodeName;
|
|
92
|
+
var i = 0;
|
|
93
|
+
while (el = el.previousElementSibling) {
|
|
94
|
+
if (el.matches(amongst)) {
|
|
95
|
+
i++;
|
|
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
|
+
|
|
116
|
+
function plugin () {
|
|
117
|
+
var self = this;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Moves the caret to the specified index.
|
|
121
|
+
*
|
|
122
|
+
* The input must be moved by leaving it in place and moving the
|
|
123
|
+
* siblings, due to the fact that focus cannot be restored once lost
|
|
124
|
+
* on mobile webkit devices
|
|
125
|
+
*
|
|
126
|
+
*/
|
|
127
|
+
self.hook('instead', 'setCaret', new_pos => {
|
|
128
|
+
if (self.settings.mode === 'single' || !self.control.contains(self.control_input)) {
|
|
129
|
+
new_pos = self.items.length;
|
|
130
|
+
} else {
|
|
131
|
+
new_pos = Math.max(0, Math.min(self.items.length, new_pos));
|
|
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
|
+
self.caretPos = new_pos;
|
|
143
|
+
});
|
|
144
|
+
self.hook('instead', 'moveCaret', direction => {
|
|
145
|
+
if (!self.isFocused) return;
|
|
146
|
+
|
|
147
|
+
// move caret before or after selected items
|
|
148
|
+
const last_active = self.getLastActive(direction);
|
|
149
|
+
if (last_active) {
|
|
150
|
+
const idx = nodeIndex(last_active);
|
|
151
|
+
self.setCaret(direction > 0 ? idx + 1 : idx);
|
|
152
|
+
self.setActiveItem();
|
|
153
|
+
removeClasses(last_active, 'last-active');
|
|
154
|
+
|
|
155
|
+
// move caret left or right of current position
|
|
156
|
+
} else {
|
|
157
|
+
self.setCaret(self.caretPos + direction);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export { plugin as default };
|
|
163
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["../../../../src/utils.ts","../../../../src/vanilla.ts","../../../../src/plugins/caret_position/plugin.ts"],"sourcesContent":["\nimport type TomSelect from './tom-select.ts';\nimport { TomLoadCallback } from './types/index.ts';\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|number):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|number):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 * use setTimeout if timeout > 0 \n */\nexport const timeout = (fn:()=>void,timeout:number): number | null => {\n\tif( timeout > 0 ){\n\t\treturn window.setTimeout(fn,timeout);\n\t}\n\n\tfn.call(null);\n\treturn null;\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 * Note: \"selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password\"\n * \t- https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange\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 * Add event helper\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/**\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:any)=>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","\nimport { iterate } from './utils.ts';\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\tvar tpl = document.createElement('template');\n\t\ttpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result\n\t\treturn tpl.content.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(/[\\t\\n\\f\\r\\s]/);\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 type TomSelect from '../../tom-select.ts';\nimport { nodeIndex, removeClasses } from '../../vanilla.ts';\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":["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":"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"}
|