| @@ -707,12 +707,9 @@ | ||
| 707 | 707 | let lp_rest_url; |
| 708 | 708 | if ('undefined' !== typeof lpDataAdmin) { |
| 709 | 709 | lp_rest_url = lpDataAdmin.lp_rest_url; |
| 710 | 710 | lplistAPI.admin = { |
| 711 | - apiAdminNotice: lp_rest_url + 'lp/v1/admin/tools/admin-notices', | |
| 712 | - apiAddons: lp_rest_url + 'lp/v1/addon/all', | |
| 713 | - apiAddonAction: lp_rest_url + 'lp/v1/addon/action-n', | |
| 714 | - apiAddonsPurchase: lp_rest_url + 'lp/v1/addon/info-addons-purchase', | |
| 711 | + // apiAdminNotice: lp_rest_url + 'lp/v1/admin/tools/admin-notices', | |
| 715 | 712 | apiSearchCourses: lp_rest_url + 'lp/v1/admin/tools/search-course', |
| 716 | 713 | apiSearchUsers: lp_rest_url + 'lp/v1/admin/tools/search-user', |
| 717 | 714 | apiAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/assign-user-course', |
| 718 | 715 | apiUnAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/unassign-user-course' |
| @@ -3624,9 +3621,8 @@ | ||
| 3624 | 3621 | diacritics: true, |
| 3625 | 3622 | create: null, |
| 3626 | 3623 | createOnBlur: false, |
| 3627 | 3624 | createFilter: null, |
| 3628 | - clearAfterSelect: false, | |
| 3629 | 3625 | highlight: true, |
| 3630 | 3626 | openOnFocus: true, |
| 3631 | 3627 | shouldOpen: null, |
| 3632 | 3628 | maxOptions: 50, |
| @@ -3824,12 +3820,11 @@ | ||
| 3824 | 3820 | * Initialize from a <input type="text"> element. |
| 3825 | 3821 | * |
| 3826 | 3822 | */ |
| 3827 | 3823 | var init_textbox = () => { |
| 3828 | - var _a, _b; | |
| 3829 | 3824 | const data_raw = input.getAttribute(attr_data); |
| 3830 | 3825 | if (!data_raw) { |
| 3831 | - var value = (_b = (_a = input === null || input === void 0 ? void 0 : input.value) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : ''; | |
| 3826 | + var value = input.value.trim() || ''; | |
| 3832 | 3827 | if (!settings.allowEmptyOption && !value.length) |
| 3833 | 3828 | return; |
| 3834 | 3829 | const values = value.split(settings.delimiter); |
| 3835 | 3830 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(values, (value) => { |
| @@ -3871,9 +3866,9 @@ | ||
| 3871 | 3866 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3872 | 3867 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 3873 | 3868 | /* harmony export */ }); |
| 3874 | 3869 | /** |
| 3875 | -* Tom Select v2.6.2 | |
| 3870 | +* Tom Select v2.4.3 | |
| 3876 | 3871 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 3877 | 3872 | */ |
| 3878 | 3873 | |
| 3879 | 3874 | /** |
| @@ -4049,9 +4044,9 @@ | ||
| 4049 | 4044 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 4050 | 4045 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 4051 | 4046 | /* harmony export */ }); |
| 4052 | 4047 | /** |
| 4053 | -* Tom Select v2.6.2 | |
| 4048 | +* Tom Select v2.4.3 | |
| 4054 | 4049 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4055 | 4050 | */ |
| 4056 | 4051 | |
| 4057 | 4052 | /** |
| @@ -4115,9 +4110,9 @@ | ||
| 4115 | 4110 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 4116 | 4111 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 4117 | 4112 | /* harmony export */ }); |
| 4118 | 4113 | /** |
| 4119 | -* Tom Select v2.6.2 | |
| 4114 | +* Tom Select v2.4.3 | |
| 4120 | 4115 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4121 | 4116 | */ |
| 4122 | 4117 | |
| 4123 | 4118 | /** |
| @@ -4309,9 +4304,9 @@ | ||
| 4309 | 4304 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 4310 | 4305 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 4311 | 4306 | /* harmony export */ }); |
| 4312 | 4307 | /** |
| 4313 | -* Tom Select v2.6.2 | |
| 4308 | +* Tom Select v2.4.3 | |
| 4314 | 4309 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4315 | 4310 | */ |
| 4316 | 4311 | |
| 4317 | 4312 | /** |
| @@ -4360,12 +4355,10 @@ | ||
| 4360 | 4355 | const self = this; |
| 4361 | 4356 | const options = Object.assign({ |
| 4362 | 4357 | className: 'clear-button', |
| 4363 | 4358 | title: 'Clear All', |
| 4364 | - role: 'button', | |
| 4365 | - tabindex: 0, | |
| 4366 | 4359 | html: data => { |
| 4367 | - return `<div class="${data.className}" title="${data.title}" role="${data.role}" tabindex="${data.tabindex}">×</div>`; | |
| 4360 | + return `<div class="${data.className}" title="${data.title}">⨯</div>`; | |
| 4368 | 4361 | } |
| 4369 | 4362 | }, userOptions); |
| 4370 | 4363 | self.on('initialize', () => { |
| 4371 | 4364 | var button = getDom(options.html(options)); |
| @@ -4374,9 +4367,8 @@ | ||
| 4374 | 4367 | self.clear(); |
| 4375 | 4368 | if (self.settings.mode === 'single' && self.settings.allowEmptyOption) { |
| 4376 | 4369 | self.addItem(''); |
| 4377 | 4370 | } |
| 4378 | - self.refreshOptions(false); | |
| 4379 | 4371 | evt.preventDefault(); |
| 4380 | 4372 | evt.stopPropagation(); |
| 4381 | 4373 | }); |
| 4382 | 4374 | self.control.appendChild(button); |
| @@ -4400,9 +4392,9 @@ | ||
| 4400 | 4392 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 4401 | 4393 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 4402 | 4394 | /* harmony export */ }); |
| 4403 | 4395 | /** |
| 4404 | -* Tom Select v2.6.2 | |
| 4396 | +* Tom Select v2.4.3 | |
| 4405 | 4397 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4406 | 4398 | */ |
| 4407 | 4399 | |
| 4408 | 4400 | /** |
| @@ -4635,9 +4627,9 @@ | ||
| 4635 | 4627 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 4636 | 4628 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 4637 | 4629 | /* harmony export */ }); |
| 4638 | 4630 | /** |
| 4639 | -* Tom Select v2.6.2 | |
| 4631 | +* Tom Select v2.4.3 | |
| 4640 | 4632 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4641 | 4633 | */ |
| 4642 | 4634 | |
| 4643 | 4635 | /** |
| @@ -4752,9 +4744,9 @@ | ||
| 4752 | 4744 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 4753 | 4745 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 4754 | 4746 | /* harmony export */ }); |
| 4755 | 4747 | /** |
| 4756 | -* Tom Select v2.6.2 | |
| 4748 | +* Tom Select v2.4.3 | |
| 4757 | 4749 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4758 | 4750 | */ |
| 4759 | 4751 | |
| 4760 | 4752 | const KEY_ESC = 27; |
| @@ -4907,9 +4899,8 @@ | ||
| 4907 | 4899 | const self = this; |
| 4908 | 4900 | self.settings.shouldOpen = true; // make sure the input is shown even if there are no options to display in the dropdown |
| 4909 | 4901 | |
| 4910 | 4902 | self.hook('before', 'setup', () => { |
| 4911 | - var _self$input; | |
| 4912 | 4903 | self.focus_node = self.control; |
| 4913 | 4904 | addClasses(self.control_input, 'dropdown-input'); |
| 4914 | 4905 | const div = getDom('<div class="dropdown-input-wrap">'); |
| 4915 | 4906 | div.append(self.control_input); |
| @@ -4918,17 +4909,8 @@ | ||
| 4918 | 4909 | // set a placeholder in the select control |
| 4919 | 4910 | const placeholder = getDom('<input class="items-placeholder" tabindex="-1" />'); |
| 4920 | 4911 | placeholder.placeholder = self.settings.placeholder || ''; |
| 4921 | 4912 | self.control.append(placeholder); |
| 4922 | - /** | |
| 4923 | - * TomSelect renders a custom control with a focusable <input class="items-placeholder">. | |
| 4924 | - * The source <select>'s aria-label is not automatically propagated to that input, | |
| 4925 | - * which triggers "Missing form label" accessibility warnings. | |
| 4926 | - * This helper copies the label from the <select> onto the generated input. | |
| 4927 | - */ | |
| 4928 | - const label = (_self$input = self.input) == null ? void 0 : _self$input.getAttribute('aria-label'); | |
| 4929 | - if (!label) return; | |
| 4930 | - placeholder.setAttribute('aria-label', label); | |
| 4931 | 4913 | }); |
| 4932 | 4914 | self.on('initialize', () => { |
| 4933 | 4915 | // set tabIndex on control to -1, otherwise [shift+tab] will put focus right back on control_input |
| 4934 | 4916 | self.control_input.addEventListener('keydown', evt => { |
| @@ -4991,9 +4973,9 @@ | ||
| 4991 | 4973 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 4992 | 4974 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 4993 | 4975 | /* harmony export */ }); |
| 4994 | 4976 | /** |
| 4995 | -* Tom Select v2.6.2 | |
| 4977 | +* Tom Select v2.4.3 | |
| 4996 | 4978 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4997 | 4979 | */ |
| 4998 | 4980 | |
| 4999 | 4981 | /** |
| @@ -5080,9 +5062,9 @@ | ||
| 5080 | 5062 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 5081 | 5063 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 5082 | 5064 | /* harmony export */ }); |
| 5083 | 5065 | /** |
| 5084 | -* Tom Select v2.6.2 | |
| 5066 | +* Tom Select v2.4.3 | |
| 5085 | 5067 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5086 | 5068 | */ |
| 5087 | 5069 | |
| 5088 | 5070 | /** |
| @@ -5121,9 +5103,9 @@ | ||
| 5121 | 5103 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 5122 | 5104 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 5123 | 5105 | /* harmony export */ }); |
| 5124 | 5106 | /** |
| 5125 | -* Tom Select v2.6.2 | |
| 5107 | +* Tom Select v2.4.3 | |
| 5126 | 5108 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5127 | 5109 | */ |
| 5128 | 5110 | |
| 5129 | 5111 | /** |
| @@ -5168,9 +5150,9 @@ | ||
| 5168 | 5150 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 5169 | 5151 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 5170 | 5152 | /* harmony export */ }); |
| 5171 | 5153 | /** |
| 5172 | -* Tom Select v2.6.2 | |
| 5154 | +* Tom Select v2.4.3 | |
| 5173 | 5155 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5174 | 5156 | */ |
| 5175 | 5157 | |
| 5176 | 5158 | const KEY_LEFT = 37; |
| @@ -5269,9 +5251,9 @@ | ||
| 5269 | 5251 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 5270 | 5252 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 5271 | 5253 | /* harmony export */ }); |
| 5272 | 5254 | /** |
| 5273 | -* Tom Select v2.6.2 | |
| 5255 | +* Tom Select v2.4.3 | |
| 5274 | 5256 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5275 | 5257 | */ |
| 5276 | 5258 | |
| 5277 | 5259 | /** |
| @@ -5289,8 +5271,16 @@ | ||
| 5289 | 5271 | * |
| 5290 | 5272 | */ |
| 5291 | 5273 | |
| 5292 | 5274 | /** |
| 5275 | + * Escapes a string for use within HTML. | |
| 5276 | + * | |
| 5277 | + */ | |
| 5278 | +const escape_html = str => { | |
| 5279 | + return (str + '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); | |
| 5280 | +}; | |
| 5281 | + | |
| 5282 | +/** | |
| 5293 | 5283 | * Prevent default |
| 5294 | 5284 | * |
| 5295 | 5285 | */ |
| 5296 | 5286 | const preventDefault = (evt, stop = false) => { |
| @@ -5352,31 +5342,28 @@ | ||
| 5352 | 5342 | * |
| 5353 | 5343 | */ |
| 5354 | 5344 | |
| 5355 | 5345 | function plugin (userOptions) { |
| 5356 | - const self = this; | |
| 5357 | 5346 | const options = Object.assign({ |
| 5358 | - label: '×', | |
| 5347 | + label: '×', | |
| 5359 | 5348 | title: 'Remove', |
| 5360 | 5349 | className: 'remove', |
| 5361 | - tabindex: -1, | |
| 5362 | - role: 'button', | |
| 5363 | - html: data => { | |
| 5364 | - var _data$tabindex; | |
| 5365 | - const el = document.createElement('div'); | |
| 5366 | - el.className = data.className || ''; | |
| 5367 | - el.title = data.title || ''; | |
| 5368 | - el.setAttribute('role', data.role || 'button'); | |
| 5369 | - el.tabIndex = (_data$tabindex = data.tabindex) != null ? _data$tabindex : -1; | |
| 5370 | - el.textContent = data.label || ''; | |
| 5371 | - return el; | |
| 5372 | - } | |
| 5350 | + append: true | |
| 5373 | 5351 | }, userOptions); |
| 5352 | + | |
| 5353 | + //options.className = 'remove-single'; | |
| 5354 | + var self = this; | |
| 5355 | + | |
| 5356 | + // override the render method to add remove button to each item | |
| 5357 | + if (!options.append) { | |
| 5358 | + return; | |
| 5359 | + } | |
| 5360 | + var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>'; | |
| 5374 | 5361 | self.hook('after', 'setupTemplates', () => { |
| 5375 | 5362 | var orig_render_item = self.settings.render.item; |
| 5376 | 5363 | self.settings.render.item = (data, escape) => { |
| 5377 | 5364 | var item = getDom(orig_render_item.call(self, data, escape)); |
| 5378 | - var close_button = getDom(options.html(options)); | |
| 5365 | + var close_button = getDom(html); | |
| 5379 | 5366 | item.appendChild(close_button); |
| 5380 | 5367 | addEvent(close_button, 'mousedown', evt => { |
| 5381 | 5368 | preventDefault(evt, true); |
| 5382 | 5369 | }); |
| @@ -5413,9 +5400,9 @@ | ||
| 5413 | 5400 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 5414 | 5401 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 5415 | 5402 | /* harmony export */ }); |
| 5416 | 5403 | /** |
| 5417 | -* Tom Select v2.6.2 | |
| 5404 | +* Tom Select v2.4.3 | |
| 5418 | 5405 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5419 | 5406 | */ |
| 5420 | 5407 | |
| 5421 | 5408 | /** |
| @@ -5470,9 +5457,9 @@ | ||
| 5470 | 5457 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 5471 | 5458 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 5472 | 5459 | /* harmony export */ }); |
| 5473 | 5460 | /** |
| 5474 | -* Tom Select v2.6.2 | |
| 5461 | +* Tom Select v2.4.3 | |
| 5475 | 5462 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5476 | 5463 | */ |
| 5477 | 5464 | |
| 5478 | 5465 | /** |
| @@ -5554,9 +5541,9 @@ | ||
| 5554 | 5541 | return arg; |
| 5555 | 5542 | }; |
| 5556 | 5543 | |
| 5557 | 5544 | /** |
| 5558 | - * Plugin: "virtual_scroll" (Tom Select) | |
| 5545 | + * Plugin: "restore_on_backspace" (Tom Select) | |
| 5559 | 5546 | * Copyright (c) contributors |
| 5560 | 5547 | * |
| 5561 | 5548 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this |
| 5562 | 5549 | * file except in compliance with the License. You may obtain a copy of the License at: |
| @@ -5578,12 +5565,8 @@ | ||
| 5578 | 5565 | var dropdown_content; |
| 5579 | 5566 | var loading_more = false; |
| 5580 | 5567 | var load_more_opt; |
| 5581 | 5568 | var default_values = []; |
| 5582 | - var default_values_loaded = false; | |
| 5583 | - var default_pagination; | |
| 5584 | - var default_options = []; | |
| 5585 | - var html_values = []; | |
| 5586 | 5569 | if (!self.settings.shouldLoadMore) { |
| 5587 | 5570 | // return true if additional results should be loaded |
| 5588 | 5571 | self.settings.shouldLoadMore = () => { |
| 5589 | 5572 | const scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop); |
| @@ -5613,9 +5596,9 @@ | ||
| 5613 | 5596 | }]; |
| 5614 | 5597 | |
| 5615 | 5598 | // can we load more results for given query? |
| 5616 | 5599 | const canLoadMore = query => { |
| 5617 | - if (self.settings.maxOptions !== null && typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions) { | |
| 5600 | + if (typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions) { | |
| 5618 | 5601 | return false; |
| 5619 | 5602 | } |
| 5620 | 5603 | if (query in pagination && pagination[query]) { |
| 5621 | 5604 | return true; |
| @@ -5673,13 +5656,9 @@ | ||
| 5673 | 5656 | |
| 5674 | 5657 | // wrap the load |
| 5675 | 5658 | self.hook('instead', 'loadCallback', (options, optgroups) => { |
| 5676 | 5659 | if (!loading_more) { |
| 5677 | - // When searching (non-empty query), keep selected items and HTML default options, | |
| 5678 | - // but remove preloaded remote options so they don't bleed into search results. | |
| 5679 | - // For empty query, use clearFilter (keeps default_values + items). | |
| 5680 | - const activeFilter = self.lastValue !== '' ? (_option, value) => self.items.indexOf(value) >= 0 || html_values.indexOf(value) >= 0 : clearFilter; | |
| 5681 | - self.clearOptions(activeFilter); | |
| 5660 | + self.clearOptions(clearFilter); | |
| 5682 | 5661 | } else if (load_more_opt) { |
| 5683 | 5662 | const first_option = options[0]; |
| 5684 | 5663 | if (first_option !== undefined) { |
| 5685 | 5664 | load_more_opt.dataset.value = first_option[self.settings.valueField]; |
| @@ -5685,31 +5664,11 @@ | ||
| 5685 | 5664 | load_more_opt.dataset.value = first_option[self.settings.valueField]; |
| 5686 | 5665 | } |
| 5687 | 5666 | } |
| 5688 | 5667 | orig_loadCallback.call(self, options, optgroups); |
| 5689 | - | |
| 5690 | - // After the initial preload (empty query), snapshot default_values and option objects | |
| 5691 | - // so they can be restored when the user clears their search. | |
| 5692 | - if (!loading_more && !default_values_loaded) { | |
| 5693 | - default_values_loaded = true; | |
| 5694 | - if (self.lastValue === '') { | |
| 5695 | - default_values = Object.keys(self.options); | |
| 5696 | - default_pagination = pagination['']; | |
| 5697 | - default_options = Object.values(self.options); | |
| 5698 | - } | |
| 5699 | - } | |
| 5700 | 5668 | loading_more = false; |
| 5701 | 5669 | }); |
| 5702 | 5670 | |
| 5703 | - // as the “loading_more” element will be removed from the dropdown, | |
| 5704 | - // we activate the previous option if needed | |
| 5705 | - // to avoid the dropdown being scrolled back to the first one | |
| 5706 | - self.hook('before', 'refreshOptions', () => { | |
| 5707 | - if (self.activeOption && "option" !== self.activeOption.getAttribute("role")) { | |
| 5708 | - self.setActiveOption(self.activeOption.previousElementSibling); | |
| 5709 | - } | |
| 5710 | - }); | |
| 5711 | - | |
| 5712 | 5671 | // add templates to dropdown |
| 5713 | 5672 | // loading_more if we have another url in the queue |
| 5714 | 5673 | // no_more_results if we don't have another url in the queue |
| 5715 | 5674 | self.hook('after', 'refreshOptions', () => { |
| @@ -5733,32 +5692,10 @@ | ||
| 5733 | 5692 | dropdown_content.append(option); |
| 5734 | 5693 | } |
| 5735 | 5694 | }); |
| 5736 | 5695 | |
| 5737 | - // Restore preloaded options and pagination when clearing search | |
| 5738 | - const restoreDefaults = () => { | |
| 5739 | - if (!default_values_loaded) { | |
| 5740 | - return; | |
| 5741 | - } | |
| 5742 | - // Re-add preloaded option objects (clearOptions can only remove, not restore) | |
| 5743 | - self.addOptions(default_options); | |
| 5744 | - // Remove any search results that are not part of the preloaded defaults | |
| 5745 | - self.clearOptions(clearFilter); | |
| 5746 | - if (default_pagination) { | |
| 5747 | - pagination[''] = default_pagination; | |
| 5748 | - } | |
| 5749 | - }; | |
| 5750 | - self.on('type', query => { | |
| 5751 | - if (query === '') { | |
| 5752 | - restoreDefaults(); | |
| 5753 | - self.refreshOptions(false); | |
| 5754 | - } | |
| 5755 | - }); | |
| 5756 | - self.on('dropdown_close', restoreDefaults); | |
| 5757 | - | |
| 5758 | 5696 | // add scroll listener and default templates |
| 5759 | 5697 | self.on('initialize', () => { |
| 5760 | - html_values = Object.keys(self.options); | |
| 5761 | 5698 | default_values = Object.keys(self.options); |
| 5762 | 5699 | dropdown_content = self.dropdown_content; |
| 5763 | 5700 | |
| 5764 | 5701 | // default templates |
| @@ -5898,9 +5835,8 @@ | ||
| 5898 | 5835 | this.isLocked = false; |
| 5899 | 5836 | this.isFocused = false; |
| 5900 | 5837 | this.isInputHidden = false; |
| 5901 | 5838 | this.isSetup = false; |
| 5902 | - this.isDropdownContentStale = true; | |
| 5903 | 5839 | this.ignoreFocus = false; |
| 5904 | 5840 | this.ignoreHover = false; |
| 5905 | 5841 | this.hasOptions = false; |
| 5906 | 5842 | this.lastValue = ''; |
| @@ -5975,9 +5911,9 @@ | ||
| 5975 | 5911 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, settings.dropdownClass, inputMode); |
| 5976 | 5912 | if (settings.copyClassesToDropdown) { |
| 5977 | 5913 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, classes); |
| 5978 | 5914 | } |
| 5979 | - ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown_content, settings.dropdownContentClass); | |
| 5915 | + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown_content, settings.dropdownContentClass); | |
| 5980 | 5916 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown, dropdown_content); |
| 5981 | 5917 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.dropdownParent || wrapper).appendChild(dropdown); |
| 5982 | 5918 | // default controlInput |
| 5983 | 5919 | if ((0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isHtmlString)(settings.controlInput)) { |
| @@ -5982,9 +5918,9 @@ | ||
| 5982 | 5918 | // default controlInput |
| 5983 | 5919 | if ((0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isHtmlString)(settings.controlInput)) { |
| 5984 | 5920 | control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput); |
| 5985 | 5921 | // set attributes |
| 5986 | - var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck', 'aria-label']; | |
| 5922 | + var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck']; | |
| 5987 | 5923 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(attrs, (attr) => { |
| 5988 | 5924 | if (input.getAttribute(attr)) { |
| 5989 | 5925 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { [attr]: input.getAttribute(attr) }); |
| 5990 | 5926 | } |
| @@ -6045,10 +5981,8 @@ | ||
| 6045 | 5981 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, { 'aria-labelledby': label_id }); |
| 6046 | 5982 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, { 'aria-labelledby': label_id }); |
| 6047 | 5983 | } |
| 6048 | 5984 | wrapper.style.width = input.style.width; |
| 6049 | - wrapper.style.minWidth = input.style.minWidth; | |
| 6050 | - wrapper.style.maxWidth = input.style.maxWidth; | |
| 6051 | 5985 | if (self.plugins.names.length) { |
| 6052 | 5986 | const classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-'); |
| 6053 | 5987 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)([wrapper, dropdown], classes_plugins); |
| 6054 | 5988 | } |
| @@ -6066,9 +6000,9 @@ | ||
| 6066 | 6000 | // after initializePlugins() so plugins can create/modify user defined loaders |
| 6067 | 6001 | if (settings.load && settings.loadThrottle) { |
| 6068 | 6002 | settings.load = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.loadDebounce)(settings.load, settings.loadThrottle); |
| 6069 | 6003 | } |
| 6070 | - ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mousemove', () => { | |
| 6004 | + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mousemove', () => { | |
| 6071 | 6005 | self.ignoreHover = false; |
| 6072 | 6006 | }); |
| 6073 | 6007 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mouseenter', (e) => { |
| 6074 | 6008 | var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(e.target, '[data-selectable]', dropdown); |
| @@ -6131,21 +6065,12 @@ | ||
| 6131 | 6065 | if (self.isOpen) { |
| 6132 | 6066 | self.positionDropdown(); |
| 6133 | 6067 | } |
| 6134 | 6068 | }; |
| 6135 | - const input_invalid = () => { | |
| 6136 | - if (self.isValid) { | |
| 6137 | - self.isValid = false; | |
| 6138 | - self.isInvalid = true; | |
| 6139 | - self.refreshState(); | |
| 6140 | - } | |
| 6141 | - }; | |
| 6142 | - (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(input, 'invalid', input_invalid); | |
| 6143 | 6069 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(document, 'mousedown', doc_mousedown); |
| 6144 | 6070 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'scroll', win_scroll, passive_event); |
| 6145 | 6071 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'resize', win_scroll, passive_event); |
| 6146 | 6072 | this._destroy = () => { |
| 6147 | - input.removeEventListener('invalid', input_invalid); | |
| 6148 | 6073 | document.removeEventListener('mousedown', doc_mousedown); |
| 6149 | 6074 | window.removeEventListener('scroll', win_scroll); |
| 6150 | 6075 | window.removeEventListener('resize', win_scroll); |
| 6151 | 6076 | if (label) |
| @@ -6162,12 +6087,29 @@ | ||
| 6162 | 6087 | self.sync(false); |
| 6163 | 6088 | settings.items = []; |
| 6164 | 6089 | delete settings.optgroups; |
| 6165 | 6090 | delete settings.options; |
| 6091 | + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(input, 'invalid', () => { | |
| 6092 | + if (self.isValid) { | |
| 6093 | + self.isValid = false; | |
| 6094 | + self.isInvalid = true; | |
| 6095 | + self.refreshState(); | |
| 6096 | + } | |
| 6097 | + }); | |
| 6098 | + self.updateOriginalInput(); | |
| 6166 | 6099 | self.refreshItems(); |
| 6167 | 6100 | self.close(false); |
| 6168 | 6101 | self.inputState(); |
| 6169 | 6102 | self.isSetup = true; |
| 6103 | + if (input.disabled) { | |
| 6104 | + self.disable(); | |
| 6105 | + } | |
| 6106 | + else if (input.readOnly) { | |
| 6107 | + self.setReadOnly(true); | |
| 6108 | + } | |
| 6109 | + else { | |
| 6110 | + self.enable(); //sets tabIndex | |
| 6111 | + } | |
| 6170 | 6112 | self.on('change', this.onChange); |
| 6171 | 6113 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(input, 'tomselected', 'ts-hidden-accessible'); |
| 6172 | 6114 | self.trigger('initialize'); |
| 6173 | 6115 | // preload options |
| @@ -6263,20 +6205,11 @@ | ||
| 6263 | 6205 | * |
| 6264 | 6206 | */ |
| 6265 | 6207 | sync(get_settings = true) { |
| 6266 | 6208 | const self = this; |
| 6267 | - const settings = get_settings ? (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(self.input, { delimiter: self.settings.delimiter, allowEmptyOption: self.settings.allowEmptyOption }) : self.settings; | |
| 6209 | + const settings = get_settings ? (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(self.input, { delimiter: self.settings.delimiter }) : self.settings; | |
| 6268 | 6210 | self.setupOptions(settings.options, settings.optgroups); |
| 6269 | 6211 | self.setValue(settings.items || [], true); // silent prevents recursion |
| 6270 | - if (self.input.disabled) { | |
| 6271 | - self.disable(); | |
| 6272 | - } | |
| 6273 | - else if (self.input.readOnly) { | |
| 6274 | - self.setReadOnly(true); | |
| 6275 | - } | |
| 6276 | - else { | |
| 6277 | - self.enable(); //sets tabIndex | |
| 6278 | - } | |
| 6279 | 6212 | self.lastQuery = null; // so updated options will be displayed in dropdown |
| 6280 | 6213 | } |
| 6281 | 6214 | /** |
| 6282 | 6215 | * Triggered when the main control element |
| @@ -6307,9 +6240,9 @@ | ||
| 6307 | 6240 | * This should propagate the event to the original DOM |
| 6308 | 6241 | * input / select element. |
| 6309 | 6242 | */ |
| 6310 | 6243 | onChange() { |
| 6311 | - ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'input'); | |
| 6244 | + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'input'); | |
| 6312 | 6245 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'change'); |
| 6313 | 6246 | } |
| 6314 | 6247 | /** |
| 6315 | 6248 | * Triggered on <input> paste. |
| @@ -6404,9 +6337,9 @@ | ||
| 6404 | 6337 | let next = self.getAdjacent(self.activeOption, 1); |
| 6405 | 6338 | if (next) |
| 6406 | 6339 | self.setActiveOption(next); |
| 6407 | 6340 | } |
| 6408 | - ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e); | |
| 6341 | + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e); | |
| 6409 | 6342 | return; |
| 6410 | 6343 | // up: move selection up |
| 6411 | 6344 | case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_UP: |
| 6412 | 6345 | if (self.activeOption) { |
| @@ -6413,9 +6346,9 @@ | ||
| 6413 | 6346 | let prev = self.getAdjacent(self.activeOption, -1); |
| 6414 | 6347 | if (prev) |
| 6415 | 6348 | self.setActiveOption(prev); |
| 6416 | 6349 | } |
| 6417 | - ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e); | |
| 6350 | + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e); | |
| 6418 | 6351 | return; |
| 6419 | 6352 | // return: select active option |
| 6420 | 6353 | case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RETURN: |
| 6421 | 6354 | if (self.canSelect(self.activeOption)) { |
| @@ -6447,9 +6380,9 @@ | ||
| 6447 | 6380 | // prevent default [tab] behaviour of jump to the next field |
| 6448 | 6381 | // if select isFull, then the dropdown won't be open and [tab] will work normally |
| 6449 | 6382 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e); |
| 6450 | 6383 | } |
| 6451 | - else if (self.settings.create && self.createItem()) { | |
| 6384 | + if (self.settings.create && self.createItem()) { | |
| 6452 | 6385 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e); |
| 6453 | 6386 | } |
| 6454 | 6387 | } |
| 6455 | 6388 | return; |
| @@ -6571,24 +6504,18 @@ | ||
| 6571 | 6504 | self.createItem(null, () => { |
| 6572 | 6505 | if (self.settings.closeAfterSelect) { |
| 6573 | 6506 | self.close(); |
| 6574 | 6507 | } |
| 6575 | - else if (self.settings.clearAfterSelect) { | |
| 6576 | - self.setTextboxValue(); | |
| 6577 | - } | |
| 6578 | 6508 | }); |
| 6579 | 6509 | } |
| 6580 | 6510 | else { |
| 6581 | 6511 | value = option.dataset.value; |
| 6582 | 6512 | if (typeof value !== 'undefined') { |
| 6583 | - self.isDropdownContentStale = self.settings.hideSelected; | |
| 6513 | + self.lastQuery = null; | |
| 6584 | 6514 | self.addItem(value); |
| 6585 | 6515 | if (self.settings.closeAfterSelect) { |
| 6586 | 6516 | self.close(); |
| 6587 | 6517 | } |
| 6588 | - else if (self.settings.clearAfterSelect) { | |
| 6589 | - self.setTextboxValue(); | |
| 6590 | - } | |
| 6591 | 6518 | if (!self.settings.hideSelected && evt.type && /click/.test(evt.type)) { |
| 6592 | 6519 | self.setActiveOption(option); |
| 6593 | 6520 | } |
| 6594 | 6521 | } |
| @@ -6660,9 +6587,9 @@ | ||
| 6660 | 6587 | */ |
| 6661 | 6588 | loadCallback(options, optgroups) { |
| 6662 | 6589 | const self = this; |
| 6663 | 6590 | self.loading = Math.max(self.loading - 1, 0); |
| 6664 | - self.isDropdownContentStale = true; | |
| 6591 | + self.lastQuery = null; | |
| 6665 | 6592 | self.clearActiveOption(); // when new results load, focus should be on first option |
| 6666 | 6593 | self.setupOptions(options, optgroups); |
| 6667 | 6594 | self.refreshOptions(self.isFocused && !self.isInputHidden); |
| 6668 | 6595 | if (!self.loading) { |
| @@ -6759,9 +6686,9 @@ | ||
| 6759 | 6686 | if (self.activeItems.indexOf(item) === -1) { |
| 6760 | 6687 | self.setActiveItemClass(item); |
| 6761 | 6688 | } |
| 6762 | 6689 | } |
| 6763 | - ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e); | |
| 6690 | + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e); | |
| 6764 | 6691 | } |
| 6765 | 6692 | else if ((eventName === 'click' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) || (eventName === 'keydown' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)('shiftKey', e))) { |
| 6766 | 6693 | if (item.classList.contains('active')) { |
| 6767 | 6694 | self.removeActiveItem(item); |
| @@ -6808,9 +6735,9 @@ | ||
| 6808 | 6735 | * Clears all the active items |
| 6809 | 6736 | * |
| 6810 | 6737 | */ |
| 6811 | 6738 | clearActiveItems() { |
| 6812 | - ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeItems, 'active'); | |
| 6739 | + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeItems, 'active'); | |
| 6813 | 6740 | this.activeItems = []; |
| 6814 | 6741 | } |
| 6815 | 6742 | /** |
| 6816 | 6743 | * Sets the selected item in the dropdown menu |
| @@ -6925,21 +6852,17 @@ | ||
| 6925 | 6852 | var self = this; |
| 6926 | 6853 | if (self.isDisabled || self.isReadOnly) |
| 6927 | 6854 | return; |
| 6928 | 6855 | self.ignoreFocus = true; |
| 6929 | - const focusTarget = this.control_input.offsetWidth ? this.control_input : this.focus_node; | |
| 6930 | - focusTarget.focus(); | |
| 6856 | + if (self.control_input.offsetWidth) { | |
| 6857 | + self.control_input.focus(); | |
| 6858 | + } | |
| 6859 | + else { | |
| 6860 | + self.focus_node.focus(); | |
| 6861 | + } | |
| 6931 | 6862 | setTimeout(() => { |
| 6932 | 6863 | self.ignoreFocus = false; |
| 6933 | - // Fix https://github.com/orchidjs/tom-select/issues/806 | |
| 6934 | - // Only proceed if this instance's element is still the active element. If Edge autofill | |
| 6935 | - // (or anything else) has moved focus to a different element in the interim, calling | |
| 6936 | - // onFocus() here would steal focus back and restart the cascade loop. | |
| 6937 | - const root = focusTarget.getRootNode(); | |
| 6938 | - if (root.activeElement !== focusTarget) { | |
| 6939 | - return; | |
| 6940 | - } | |
| 6941 | - this.onFocus(); | |
| 6864 | + self.onFocus(); | |
| 6942 | 6865 | }, 0); |
| 6943 | 6866 | } |
| 6944 | 6867 | /** |
| 6945 | 6868 | * Forces the control out of focus. |
| @@ -6995,15 +6918,10 @@ | ||
| 6995 | 6918 | throw new Error('Tom Select "score" setting must be a function that returns a function'); |
| 6996 | 6919 | } |
| 6997 | 6920 | } |
| 6998 | 6921 | // perform search |
| 6999 | - if (self.isDropdownContentStale || query !== self.lastQuery) { | |
| 6922 | + if (query !== self.lastQuery) { | |
| 7000 | 6923 | self.lastQuery = query; |
| 7001 | - // temp fix for https://github.com/orchidjs/tom-select/issues/987 | |
| 7002 | - // UI crashed when more than 30 same chars in a row, prevent search and return empt result | |
| 7003 | - if (/(.)\1{15,}/.test(query)) { | |
| 7004 | - query = ''; | |
| 7005 | - } | |
| 7006 | 6924 | result = self.sifter.search(query, Object.assign(options, { score: calculateScore })); |
| 7007 | 6925 | self.currentResults = result; |
| 7008 | 6926 | } |
| 7009 | 6927 | else { |
| @@ -7012,9 +6930,9 @@ | ||
| 7012 | 6930 | // filter out selected items |
| 7013 | 6931 | if (self.settings.hideSelected) { |
| 7014 | 6932 | result.items = result.items.filter((item) => { |
| 7015 | 6933 | let hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item.id); |
| 7016 | - return !(hashed !== null && self.items.indexOf(hashed) !== -1); | |
| 6934 | + return !(hashed && self.items.indexOf(hashed) !== -1); | |
| 7017 | 6935 | }); |
| 7018 | 6936 | } |
| 7019 | 6937 | return result; |
| 7020 | 6938 | } |
| @@ -7084,15 +7002,8 @@ | ||
| 7084 | 7002 | for (j = 0, k = optgroups && optgroups.length; j < k; j++) { |
| 7085 | 7003 | optgroup = optgroups[j]; |
| 7086 | 7004 | let order = option.$order; |
| 7087 | 7005 | let self_optgroup = self.optgroups[optgroup]; |
| 7088 | - if (self_optgroup === undefined && typeof self.settings.optionGroupRegister === 'function') { | |
| 7089 | - var regGroup; | |
| 7090 | - if (regGroup = self.settings.optionGroupRegister.apply(self, [optgroup])) { | |
| 7091 | - self.registerOptionGroup(regGroup); | |
| 7092 | - } | |
| 7093 | - } | |
| 7094 | - self_optgroup = self.optgroups[optgroup]; | |
| 7095 | 7006 | if (self_optgroup === undefined) { |
| 7096 | 7007 | optgroup = ''; |
| 7097 | 7008 | } |
| 7098 | 7009 | else { |
| @@ -7145,9 +7056,8 @@ | ||
| 7145 | 7056 | } |
| 7146 | 7057 | }); |
| 7147 | 7058 | dropdown_content.innerHTML = ''; |
| 7148 | 7059 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown_content, html); |
| 7149 | - self.isDropdownContentStale = false; | |
| 7150 | 7060 | // highlight matching terms inline |
| 7151 | 7061 | if (self.settings.highlight) { |
| 7152 | 7062 | (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.removeHighlight)(dropdown_content); |
| 7153 | 7063 | if (results.query.length && results.tokens.length) { |
| @@ -7240,15 +7150,14 @@ | ||
| 7240 | 7150 | return false; |
| 7241 | 7151 | } |
| 7242 | 7152 | const key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]); |
| 7243 | 7153 | if (key === null || self.options.hasOwnProperty(key)) { |
| 7244 | - self.updateOption(data[self.settings.valueField], data); | |
| 7245 | 7154 | return false; |
| 7246 | 7155 | } |
| 7247 | 7156 | data.$order = data.$order || ++self.order; |
| 7248 | 7157 | data.$id = self.inputId + '-opt-' + data.$order; |
| 7249 | 7158 | self.options[key] = data; |
| 7250 | - self.isDropdownContentStale = true; | |
| 7159 | + self.lastQuery = null; | |
| 7251 | 7160 | if (user_created) { |
| 7252 | 7161 | self.userOptions[key] = user_created; |
| 7253 | 7162 | self.trigger('option_add', key, data); |
| 7254 | 7163 | } |
| @@ -7258,9 +7167,9 @@ | ||
| 7258 | 7167 | * Add multiple options |
| 7259 | 7168 | * |
| 7260 | 7169 | */ |
| 7261 | 7170 | addOptions(data, user_created = false) { |
| 7262 | - ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(data, (dat) => { | |
| 7171 | + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(data, (dat) => { | |
| 7263 | 7172 | this.addOption(dat, user_created); |
| 7264 | 7173 | }); |
| 7265 | 7174 | } |
| 7266 | 7175 | /** |
| @@ -7362,10 +7271,10 @@ | ||
| 7362 | 7271 | if (item.classList.contains('active')) |
| 7363 | 7272 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item_new, 'active'); |
| 7364 | 7273 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(item, item_new); |
| 7365 | 7274 | } |
| 7366 | - // we might have updated the sortField | |
| 7367 | - self.isDropdownContentStale = true; | |
| 7275 | + // invalidate last query because we might have updated the sortField | |
| 7276 | + self.lastQuery = null; | |
| 7368 | 7277 | } |
| 7369 | 7278 | /** |
| 7370 | 7279 | * Removes a single option. |
| 7371 | 7280 | * |
| @@ -7375,9 +7284,9 @@ | ||
| 7375 | 7284 | value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(value); |
| 7376 | 7285 | self.uncacheValue(value); |
| 7377 | 7286 | delete self.userOptions[value]; |
| 7378 | 7287 | delete self.options[value]; |
| 7379 | - self.isDropdownContentStale = true; | |
| 7288 | + self.lastQuery = null; | |
| 7380 | 7289 | self.trigger('option_remove', value); |
| 7381 | 7290 | self.removeItem(value, silent); |
| 7382 | 7291 | } |
| 7383 | 7292 | /** |
| @@ -7394,9 +7303,9 @@ | ||
| 7394 | 7303 | selected[key] = option; |
| 7395 | 7304 | } |
| 7396 | 7305 | }); |
| 7397 | 7306 | this.options = this.sifter.items = selected; |
| 7398 | - this.isDropdownContentStale = true; | |
| 7307 | + this.lastQuery = null; | |
| 7399 | 7308 | this.trigger('option_clear'); |
| 7400 | 7309 | } |
| 7401 | 7310 | /** |
| 7402 | 7311 | * Used by clearOptions() to decide whether or not an option should be removed |
| @@ -7526,12 +7435,8 @@ | ||
| 7526 | 7435 | if (next) { |
| 7527 | 7436 | self.setActiveOption(next); |
| 7528 | 7437 | } |
| 7529 | 7438 | } |
| 7530 | - //remove input value when enabled | |
| 7531 | - if (self.settings.clearAfterSelect) { | |
| 7532 | - self.setTextboxValue(); | |
| 7533 | - } | |
| 7534 | 7439 | // refreshOptions after setActiveOption(), |
| 7535 | 7440 | // otherwise setActiveOption() will be called by refreshOptions() with the wrong value |
| 7536 | 7441 | if (!self.isPending && !self.settings.closeAfterSelect) { |
| 7537 | 7442 | self.refreshOptions(self.isFocused && inputMode !== 'single'); |
| @@ -7573,9 +7478,9 @@ | ||
| 7573 | 7478 | self.activeItems.splice(idx, 1); |
| 7574 | 7479 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active'); |
| 7575 | 7480 | } |
| 7576 | 7481 | self.items.splice(i, 1); |
| 7577 | - self.isDropdownContentStale = true; | |
| 7482 | + self.lastQuery = null; | |
| 7578 | 7483 | if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) { |
| 7579 | 7484 | self.removeOption(value, silent); |
| 7580 | 7485 | } |
| 7581 | 7486 | if (i < self.caretPos) { |
| @@ -7607,14 +7512,8 @@ | ||
| 7607 | 7512 | var caret = self.caretPos; |
| 7608 | 7513 | var output; |
| 7609 | 7514 | input = input || self.inputValue(); |
| 7610 | 7515 | if (!self.canCreate(input)) { |
| 7611 | - const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(input); | |
| 7612 | - if (hash) { | |
| 7613 | - if (this.options[input]) { | |
| 7614 | - self.addItem(input); | |
| 7615 | - } | |
| 7616 | - } | |
| 7617 | 7516 | callback(); |
| 7618 | 7517 | return false; |
| 7619 | 7518 | } |
| 7620 | 7519 | self.lock(); |
| @@ -7652,9 +7551,9 @@ | ||
| 7652 | 7551 | * Re-renders the selected item lists. |
| 7653 | 7552 | */ |
| 7654 | 7553 | refreshItems() { |
| 7655 | 7554 | var self = this; |
| 7656 | - self.isDropdownContentStale = true; | |
| 7555 | + self.lastQuery = null; | |
| 7657 | 7556 | if (self.isSetup) { |
| 7658 | 7557 | self.addItems(self.items); |
| 7659 | 7558 | } |
| 7660 | 7559 | self.updateOriginalInput(); |
| @@ -7731,9 +7630,9 @@ | ||
| 7731 | 7630 | } |
| 7732 | 7631 | selected.push(option_el); |
| 7733 | 7632 | // marking empty option as selected can break validation |
| 7734 | 7633 | // fixes https://github.com/orchidjs/tom-select/issues/303 |
| 7735 | - if (option_el != empty_option || has_selected > 0 || self.settings.mode == 'multi') { | |
| 7634 | + if (option_el != empty_option || has_selected > 0) { | |
| 7736 | 7635 | option_el.selected = true; |
| 7737 | 7636 | } |
| 7738 | 7637 | return option_el; |
| 7739 | 7638 | } |
| @@ -7874,9 +7773,9 @@ | ||
| 7874 | 7773 | caret = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(tail); |
| 7875 | 7774 | if (direction > 0) { |
| 7876 | 7775 | caret++; |
| 7877 | 7776 | } |
| 7878 | - ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(self.activeItems, (item) => rm_items.push(item)); | |
| 7777 | + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(self.activeItems, (item) => rm_items.push(item)); | |
| 7879 | 7778 | } |
| 7880 | 7779 | else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) { |
| 7881 | 7780 | const items = self.controlChildren(); |
| 7882 | 7781 | let rm_item; |
| @@ -7892,9 +7791,9 @@ | ||
| 7892 | 7791 | } |
| 7893 | 7792 | if (!self.shouldDelete(rm_items, e)) { |
| 7894 | 7793 | return false; |
| 7895 | 7794 | } |
| 7896 | - ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true); | |
| 7795 | + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true); | |
| 7897 | 7796 | // perform removal |
| 7898 | 7797 | if (typeof caret !== 'undefined') { |
| 7899 | 7798 | self.setCaret(caret); |
| 7900 | 7799 | } |
| @@ -7911,9 +7810,9 @@ | ||
| 7911 | 7810 | */ |
| 7912 | 7811 | shouldDelete(items, evt) { |
| 7913 | 7812 | const values = items.map(item => item.dataset.value); |
| 7914 | 7813 | // allow the callback to abort |
| 7915 | - if (!values.length || (typeof this.settings.onDelete === 'function' && this.settings.onDelete.call(this, values, evt) === false)) { | |
| 7814 | + if (!values.length || (typeof this.settings.onDelete === 'function' && this.settings.onDelete(values, evt) === false)) { | |
| 7916 | 7815 | return false; |
| 7917 | 7816 | } |
| 7918 | 7817 | return true; |
| 7919 | 7818 | } |
| @@ -8130,9 +8029,9 @@ | ||
| 8130 | 8029 | * caches. |
| 8131 | 8030 | * |
| 8132 | 8031 | */ |
| 8133 | 8032 | clearCache() { |
| 8134 | - ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option) => { | |
| 8033 | + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option) => { | |
| 8135 | 8034 | if (option.$div) { |
| 8136 | 8035 | option.$div.remove(); |
| 8137 | 8036 | delete option.$div; |
| 8138 | 8037 | } |
| @@ -8611,19 +8510,19 @@ | ||
| 8611 | 8510 | |
| 8612 | 8511 | /******/ }); |
| 8613 | 8512 | /************************************************************************/ |
| 8614 | 8513 | /******/ // The module cache |
| 8615 | -/******/ const __webpack_module_cache__ = {}; | |
| 8514 | +/******/ var __webpack_module_cache__ = {}; | |
| 8616 | 8515 | /******/ |
| 8617 | 8516 | /******/ // The require function |
| 8618 | 8517 | /******/ function __webpack_require__(moduleId) { |
| 8619 | 8518 | /******/ // Check if module is in cache |
| 8620 | -/******/ const cachedModule = __webpack_module_cache__[moduleId]; | |
| 8519 | +/******/ var cachedModule = __webpack_module_cache__[moduleId]; | |
| 8621 | 8520 | /******/ if (cachedModule !== undefined) { |
| 8622 | 8521 | /******/ return cachedModule.exports; |
| 8623 | 8522 | /******/ } |
| 8624 | 8523 | /******/ // Create a new module (and put it into the cache) |
| 8625 | -/******/ const module = __webpack_module_cache__[moduleId] = { | |
| 8524 | +/******/ var module = __webpack_module_cache__[moduleId] = { | |
| 8626 | 8525 | /******/ id: moduleId, |
| 8627 | 8526 | /******/ // no module.loaded needed |
| 8628 | 8527 | /******/ exports: {} |
| 8629 | 8528 | /******/ }; |
| @@ -8630,9 +8529,9 @@ | ||
| 8630 | 8529 | /******/ |
| 8631 | 8530 | /******/ // Execute the module function |
| 8632 | 8531 | /******/ if (!(moduleId in __webpack_modules__)) { |
| 8633 | 8532 | /******/ delete __webpack_module_cache__[moduleId]; |
| 8634 | -/******/ const e = new Error("Cannot find module '" + moduleId + "'"); | |
| 8533 | +/******/ var e = new Error("Cannot find module '" + moduleId + "'"); | |
| 8635 | 8534 | /******/ e.code = 'MODULE_NOT_FOUND'; |
| 8636 | 8535 | /******/ throw e; |
| 8637 | 8536 | /******/ } |
| 8638 | 8537 | /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
| @@ -8645,9 +8544,9 @@ | ||
| 8645 | 8544 | /******/ /* webpack/runtime/compat get default export */ |
| 8646 | 8545 | /******/ (() => { |
| 8647 | 8546 | /******/ // getDefaultExport function for compatibility with non-harmony modules |
| 8648 | 8547 | /******/ __webpack_require__.n = (module) => { |
| 8649 | -/******/ const getter = module && module.__esModule ? | |
| 8548 | +/******/ var getter = module && module.__esModule ? | |
| 8650 | 8549 | /******/ () => (module['default']) : |
| 8651 | 8550 | /******/ () => (module); |
| 8652 | 8551 | /******/ __webpack_require__.d(getter, { a: getter }); |
| 8653 | 8552 | /******/ return getter; |
| @@ -8655,29 +8554,14 @@ | ||
| 8655 | 8554 | /******/ })(); |
| 8656 | 8555 | /******/ |
| 8657 | 8556 | /******/ /* webpack/runtime/define property getters */ |
| 8658 | 8557 | /******/ (() => { |
| 8659 | -/******/ // define getter/value functions for harmony exports | |
| 8558 | +/******/ // define getter functions for harmony exports | |
| 8660 | 8559 | /******/ __webpack_require__.d = (exports, definition) => { |
| 8661 | -/******/ if(Array.isArray(definition)) { | |
| 8662 | -/******/ var i = 0; | |
| 8663 | -/******/ while(i < definition.length) { | |
| 8664 | -/******/ var key = definition[i++]; | |
| 8665 | -/******/ var binding = definition[i++]; | |
| 8666 | -/******/ if(!__webpack_require__.o(exports, key)) { | |
| 8667 | -/******/ if(binding === 0) { | |
| 8668 | -/******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] }); | |
| 8669 | -/******/ } else { | |
| 8670 | -/******/ Object.defineProperty(exports, key, { enumerable: true, get: binding }); | |
| 8671 | -/******/ } | |
| 8672 | -/******/ } else if(binding === 0) { i++; } | |
| 8560 | +/******/ for(var key in definition) { | |
| 8561 | +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | |
| 8562 | +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | |
| 8673 | 8563 | /******/ } |
| 8674 | -/******/ } else { | |
| 8675 | -/******/ for(var key in definition) { | |
| 8676 | -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | |
| 8677 | -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | |
| 8678 | -/******/ } | |
| 8679 | -/******/ } | |
| 8680 | 8564 | /******/ } |
| 8681 | 8565 | /******/ }; |
| 8682 | 8566 | /******/ })(); |
| 8683 | 8567 | /******/ |
| @@ -8682,9 +8566,9 @@ | ||
| 8682 | 8566 | /******/ })(); |
| 8683 | 8567 | /******/ |
| 8684 | 8568 | /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 8685 | 8569 | /******/ (() => { |
| 8686 | -/******/ __webpack_require__.o = (obj, prop) => (Object.hasOwn(obj, prop)) | |
| 8570 | +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) | |
| 8687 | 8571 | /******/ })(); |
| 8688 | 8572 | /******/ |
| 8689 | 8573 | /******/ /* webpack/runtime/make namespace object */ |
| 8690 | 8574 | /******/ (() => { |
| @@ -8689,9 +8573,9 @@ | ||
| 8689 | 8573 | /******/ /* webpack/runtime/make namespace object */ |
| 8690 | 8574 | /******/ (() => { |
| 8691 | 8575 | /******/ // define __esModule on exports |
| 8692 | 8576 | /******/ __webpack_require__.r = (exports) => { |
| 8693 | -/******/ if(Symbol.toStringTag) { | |
| 8577 | +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | |
| 8694 | 8578 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 8695 | 8579 | /******/ } |
| 8696 | 8580 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 8697 | 8581 | /******/ }; |
| @@ -8702,9 +8586,9 @@ | ||
| 8702 | 8586 | /******/ __webpack_require__.nc = undefined; |
| 8703 | 8587 | /******/ })(); |
| 8704 | 8588 | /******/ |
| 8705 | 8589 | /************************************************************************/ |
| 8706 | -let __webpack_exports__ = {}; | |
| 8590 | +var __webpack_exports__ = {}; | |
| 8707 | 8591 | // This entry needs to be wrapped in an IIFE because it needs to be in strict mode. |
| 8708 | 8592 | (() => { |
| 8709 | 8593 | "use strict"; |
| 8710 | 8594 | /*!**************************************!*\ |