| @@ -428,8 +428,9 @@ | ||
| 428 | 428 | __webpack_require__.r(__webpack_exports__); |
| 429 | 429 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 430 | 430 | /* harmony export */ debounce: () => (/* binding */ debounce), |
| 431 | 431 | /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers), |
| 432 | +/* harmony export */ fullScreenView: () => (/* binding */ fullScreenView), | |
| 432 | 433 | /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm), |
| 433 | 434 | /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm), |
| 434 | 435 | /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated), |
| 435 | 436 | /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed), |
| @@ -441,9 +442,10 @@ | ||
| 441 | 442 | /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady), |
| 442 | 443 | /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl), |
| 443 | 444 | /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl), |
| 444 | 445 | /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm), |
| 445 | -/* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse) | |
| 446 | +/* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse), | |
| 447 | +/* harmony export */ toggleEnable: () => (/* binding */ toggleEnable) | |
| 446 | 448 | /* harmony export */ }); |
| 447 | 449 | /** |
| 448 | 450 | * Utils functions |
| 449 | 451 | * |
| @@ -450,9 +452,9 @@ | ||
| 450 | 452 | * @param url |
| 451 | 453 | * @param data |
| 452 | 454 | * @param functions |
| 453 | 455 | * @since 4.2.5.1 |
| 454 | - * @version 1.0.6 | |
| 456 | + * @version 1.0.7 | |
| 455 | 457 | */ |
| 456 | 458 | const lpClassName = { |
| 457 | 459 | hidden: 'lp-hidden', |
| 458 | 460 | loading: 'loading', |
| @@ -457,9 +459,12 @@ | ||
| 457 | 459 | hidden: 'lp-hidden', |
| 458 | 460 | loading: 'loading', |
| 459 | 461 | elCollapse: 'lp-collapse', |
| 460 | 462 | elSectionToggle: '.lp-section-toggle', |
| 461 | - elTriggerToggle: '.lp-trigger-toggle' | |
| 463 | + elTriggerToggle: '.lp-trigger-toggle', | |
| 464 | + elBtnFullScreen: '.lp-btn-full-screen-view', | |
| 465 | + elFullScreen: 'lp-full-screen-view', | |
| 466 | + elBtnFullScreenClose: 'lp-full-screen-view__close' | |
| 462 | 467 | }; |
| 463 | 468 | const lpFetchAPI = (url, data = {}, functions = {}) => { |
| 464 | 469 | if ('function' === typeof functions.before) { |
| 465 | 470 | functions.before(); |
| @@ -777,8 +782,141 @@ | ||
| 777 | 782 | timer = setTimeout(() => func(args), wait); |
| 778 | 783 | }; |
| 779 | 784 | }; |
| 780 | 785 | |
| 786 | +/** | |
| 787 | + * Initialize lp-toggle-enable components. | |
| 788 | + * | |
| 789 | + * Finds all `.lp-toggle-enable` elements and wires up toggle behavior. | |
| 790 | + * Reads initial state from `data-enabled` attribute ("true"/"false"). | |
| 791 | + * Calls `data-on-toggle` callback (if provided via options) on state change. | |
| 792 | + * | |
| 793 | + * HTML structure: | |
| 794 | + * <label class="lp-toggle-enable" data-enabled="true"> | |
| 795 | + * <input type="checkbox" class="lp-toggle-enable__input" /> | |
| 796 | + * <span class="lp-toggle-enable__track"></span> | |
| 797 | + * </label> | |
| 798 | + * | |
| 799 | + * @param {string} selector CSS selector for toggle elements (default: '.lp-toggle-enable') | |
| 800 | + * @param {Function} onToggle Optional callback( el, isEnabled ) called on state change | |
| 801 | + * @since 4.4.5 | |
| 802 | + * @version 1.0.0 | |
| 803 | + */ | |
| 804 | +window.lpToggleEnableInit = 0; | |
| 805 | +const toggleEnable = (onToggle = null) => { | |
| 806 | + if (window.lpToggleEnableInit) { | |
| 807 | + return; | |
| 808 | + } | |
| 809 | + window.lpToggleEnableInit = 1; | |
| 810 | + const selector = '.lp-toggle-enable'; | |
| 811 | + const updateUI = (toggle, isEnabled) => { | |
| 812 | + toggle.classList.toggle('is-enabled', isEnabled); | |
| 813 | + const input = toggle.querySelector('.lp-toggle-enable__input'); | |
| 814 | + if (input) { | |
| 815 | + input.checked = isEnabled; | |
| 816 | + input.value = isEnabled ? '1' : '0'; | |
| 817 | + } | |
| 818 | + }; | |
| 819 | + | |
| 820 | + // Delegate click handling via eventHandlers. | |
| 821 | + eventHandlers('click', [{ | |
| 822 | + selector, | |
| 823 | + callBack: args => { | |
| 824 | + const { | |
| 825 | + e, | |
| 826 | + target | |
| 827 | + } = args; | |
| 828 | + const toggle = target.closest(selector); | |
| 829 | + if (!toggle || toggle.classList.contains('is-disabled')) { | |
| 830 | + return; | |
| 831 | + } | |
| 832 | + e.preventDefault(); | |
| 833 | + const isEnabled = !toggle.classList.contains('is-enabled'); | |
| 834 | + updateUI(toggle, isEnabled); | |
| 835 | + if ('function' === typeof onToggle) { | |
| 836 | + onToggle(toggle, isEnabled); | |
| 837 | + } | |
| 838 | + } | |
| 839 | + }]); | |
| 840 | +}; | |
| 841 | + | |
| 842 | +/** | |
| 843 | + * Initialize custom fullscreen view buttons. | |
| 844 | + * | |
| 845 | + * Delegates clicks on `.lp-btn-full-screen-view` buttons to | |
| 846 | + * `lpToggleFullscreenView`. Reads the `data-target` attribute to find the | |
| 847 | + * target element. Falls back to the button's parent element when | |
| 848 | + * `data-target` is not provided. | |
| 849 | + * | |
| 850 | + * @since 4.4.5 | |
| 851 | + * @version 1.0.0 | |
| 852 | + */ | |
| 853 | +window.lpFullScreenViewInit = 0; | |
| 854 | +const fullScreenView = () => { | |
| 855 | + if (window.lpFullScreenViewInit) { | |
| 856 | + return; | |
| 857 | + } | |
| 858 | + window.lpFullScreenViewInit = 1; | |
| 859 | + let lastScrollY = 0; | |
| 860 | + const lpToggleFullscreenView = (elTarget, elBtnFullScreen = null) => { | |
| 861 | + const isFullscreen = elTarget.classList.contains(lpClassName.elFullScreen); | |
| 862 | + if (isFullscreen) { | |
| 863 | + elTarget.classList.remove(lpClassName.elFullScreen); | |
| 864 | + document.documentElement.classList.remove('lp-full-screen-active'); | |
| 865 | + window.scrollTo(0, lastScrollY); | |
| 866 | + } else { | |
| 867 | + lastScrollY = window.scrollY; | |
| 868 | + elTarget.classList.add(lpClassName.elFullScreen); | |
| 869 | + document.documentElement.classList.add('lp-full-screen-active'); | |
| 870 | + } | |
| 871 | + if (!isFullscreen) { | |
| 872 | + if (!elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`)) { | |
| 873 | + const closeButton = document.createElement('button'); | |
| 874 | + closeButton.type = 'button'; | |
| 875 | + closeButton.className = lpClassName.elBtnFullScreenClose; | |
| 876 | + closeButton.setAttribute('aria-label', 'Close'); | |
| 877 | + closeButton.innerHTML = lpData.i18n.closeButtonFullScreen || 'Close ×'; | |
| 878 | + closeButton.addEventListener('click', e => { | |
| 879 | + e.preventDefault(); | |
| 880 | + lpToggleFullscreenView(elTarget); | |
| 881 | + }); | |
| 882 | + elTarget.appendChild(closeButton); | |
| 883 | + } | |
| 884 | + } else { | |
| 885 | + const closeButton = elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`); | |
| 886 | + if (closeButton) { | |
| 887 | + closeButton.remove(); | |
| 888 | + } | |
| 889 | + } | |
| 890 | + }; | |
| 891 | + eventHandlers('click', [{ | |
| 892 | + selector: lpClassName.elBtnFullScreen, | |
| 893 | + callBack: args => { | |
| 894 | + const { | |
| 895 | + e, | |
| 896 | + target | |
| 897 | + } = args; | |
| 898 | + const elBtnFullScreen = target.closest(lpClassName.elBtnFullScreen); | |
| 899 | + if (!elBtnFullScreen) { | |
| 900 | + console.log('No full screen button found'); | |
| 901 | + return; | |
| 902 | + } | |
| 903 | + e.preventDefault(); | |
| 904 | + let elTarget = null; | |
| 905 | + const targetSelector = elBtnFullScreen.dataset.targetFullscreen; | |
| 906 | + console.log(targetSelector); | |
| 907 | + if (targetSelector) { | |
| 908 | + elTarget = document.querySelector(targetSelector); | |
| 909 | + } | |
| 910 | + if (!elTarget) { | |
| 911 | + console.log('No target element found'); | |
| 912 | + return; | |
| 913 | + } | |
| 914 | + lpToggleFullscreenView(elTarget, elBtnFullScreen); | |
| 915 | + } | |
| 916 | + }]); | |
| 917 | +}; | |
| 918 | + | |
| 781 | 919 | /***/ }, |
| 782 | 920 | |
| 783 | 921 | /***/ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js" |
| 784 | 922 | /*!**********************************************************!*\ |
| @@ -2085,9 +2223,8 @@ | ||
| 2085 | 2223 | diacritics: true, |
| 2086 | 2224 | create: null, |
| 2087 | 2225 | createOnBlur: false, |
| 2088 | 2226 | createFilter: null, |
| 2089 | - clearAfterSelect: false, | |
| 2090 | 2227 | highlight: true, |
| 2091 | 2228 | openOnFocus: true, |
| 2092 | 2229 | shouldOpen: null, |
| 2093 | 2230 | maxOptions: 50, |
| @@ -2284,12 +2421,11 @@ | ||
| 2284 | 2421 | * Initialize from a <input type="text"> element. |
| 2285 | 2422 | * |
| 2286 | 2423 | */ |
| 2287 | 2424 | var init_textbox = () => { |
| 2288 | - var _a, _b; | |
| 2289 | 2425 | const data_raw = input.getAttribute(attr_data); |
| 2290 | 2426 | if (!data_raw) { |
| 2291 | - 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 : ''; | |
| 2427 | + var value = input.value.trim() || ''; | |
| 2292 | 2428 | if (!settings.allowEmptyOption && !value.length) |
| 2293 | 2429 | return; |
| 2294 | 2430 | const values = value.split(settings.delimiter); |
| 2295 | 2431 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(values, (value) => { |
| @@ -2330,9 +2466,9 @@ | ||
| 2330 | 2466 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2331 | 2467 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 2332 | 2468 | /* harmony export */ }); |
| 2333 | 2469 | /** |
| 2334 | -* Tom Select v2.6.2 | |
| 2470 | +* Tom Select v2.4.3 | |
| 2335 | 2471 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 2336 | 2472 | */ |
| 2337 | 2473 | |
| 2338 | 2474 | /** |
| @@ -2507,9 +2643,9 @@ | ||
| 2507 | 2643 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2508 | 2644 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 2509 | 2645 | /* harmony export */ }); |
| 2510 | 2646 | /** |
| 2511 | -* Tom Select v2.6.2 | |
| 2647 | +* Tom Select v2.4.3 | |
| 2512 | 2648 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 2513 | 2649 | */ |
| 2514 | 2650 | |
| 2515 | 2651 | /** |
| @@ -2572,9 +2708,9 @@ | ||
| 2572 | 2708 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2573 | 2709 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 2574 | 2710 | /* harmony export */ }); |
| 2575 | 2711 | /** |
| 2576 | -* Tom Select v2.6.2 | |
| 2712 | +* Tom Select v2.4.3 | |
| 2577 | 2713 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 2578 | 2714 | */ |
| 2579 | 2715 | |
| 2580 | 2716 | /** |
| @@ -2765,9 +2901,9 @@ | ||
| 2765 | 2901 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2766 | 2902 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 2767 | 2903 | /* harmony export */ }); |
| 2768 | 2904 | /** |
| 2769 | -* Tom Select v2.6.2 | |
| 2905 | +* Tom Select v2.4.3 | |
| 2770 | 2906 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 2771 | 2907 | */ |
| 2772 | 2908 | |
| 2773 | 2909 | /** |
| @@ -2816,12 +2952,10 @@ | ||
| 2816 | 2952 | const self = this; |
| 2817 | 2953 | const options = Object.assign({ |
| 2818 | 2954 | className: 'clear-button', |
| 2819 | 2955 | title: 'Clear All', |
| 2820 | - role: 'button', | |
| 2821 | - tabindex: 0, | |
| 2822 | 2956 | html: data => { |
| 2823 | - return `<div class="${data.className}" title="${data.title}" role="${data.role}" tabindex="${data.tabindex}">×</div>`; | |
| 2957 | + return `<div class="${data.className}" title="${data.title}">⨯</div>`; | |
| 2824 | 2958 | } |
| 2825 | 2959 | }, userOptions); |
| 2826 | 2960 | self.on('initialize', () => { |
| 2827 | 2961 | var button = getDom(options.html(options)); |
| @@ -2830,9 +2964,8 @@ | ||
| 2830 | 2964 | self.clear(); |
| 2831 | 2965 | if (self.settings.mode === 'single' && self.settings.allowEmptyOption) { |
| 2832 | 2966 | self.addItem(''); |
| 2833 | 2967 | } |
| 2834 | - self.refreshOptions(false); | |
| 2835 | 2968 | evt.preventDefault(); |
| 2836 | 2969 | evt.stopPropagation(); |
| 2837 | 2970 | }); |
| 2838 | 2971 | self.control.appendChild(button); |
| @@ -2855,9 +2988,9 @@ | ||
| 2855 | 2988 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2856 | 2989 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 2857 | 2990 | /* harmony export */ }); |
| 2858 | 2991 | /** |
| 2859 | -* Tom Select v2.6.2 | |
| 2992 | +* Tom Select v2.4.3 | |
| 2860 | 2993 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 2861 | 2994 | */ |
| 2862 | 2995 | |
| 2863 | 2996 | /** |
| @@ -3089,9 +3222,9 @@ | ||
| 3089 | 3222 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3090 | 3223 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 3091 | 3224 | /* harmony export */ }); |
| 3092 | 3225 | /** |
| 3093 | -* Tom Select v2.6.2 | |
| 3226 | +* Tom Select v2.4.3 | |
| 3094 | 3227 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 3095 | 3228 | */ |
| 3096 | 3229 | |
| 3097 | 3230 | /** |
| @@ -3205,9 +3338,9 @@ | ||
| 3205 | 3338 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3206 | 3339 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 3207 | 3340 | /* harmony export */ }); |
| 3208 | 3341 | /** |
| 3209 | -* Tom Select v2.6.2 | |
| 3342 | +* Tom Select v2.4.3 | |
| 3210 | 3343 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 3211 | 3344 | */ |
| 3212 | 3345 | |
| 3213 | 3346 | const KEY_ESC = 27; |
| @@ -3360,9 +3493,8 @@ | ||
| 3360 | 3493 | const self = this; |
| 3361 | 3494 | self.settings.shouldOpen = true; // make sure the input is shown even if there are no options to display in the dropdown |
| 3362 | 3495 | |
| 3363 | 3496 | self.hook('before', 'setup', () => { |
| 3364 | - var _self$input; | |
| 3365 | 3497 | self.focus_node = self.control; |
| 3366 | 3498 | addClasses(self.control_input, 'dropdown-input'); |
| 3367 | 3499 | const div = getDom('<div class="dropdown-input-wrap">'); |
| 3368 | 3500 | div.append(self.control_input); |
| @@ -3371,17 +3503,8 @@ | ||
| 3371 | 3503 | // set a placeholder in the select control |
| 3372 | 3504 | const placeholder = getDom('<input class="items-placeholder" tabindex="-1" />'); |
| 3373 | 3505 | placeholder.placeholder = self.settings.placeholder || ''; |
| 3374 | 3506 | self.control.append(placeholder); |
| 3375 | - /** | |
| 3376 | - * TomSelect renders a custom control with a focusable <input class="items-placeholder">. | |
| 3377 | - * The source <select>'s aria-label is not automatically propagated to that input, | |
| 3378 | - * which triggers "Missing form label" accessibility warnings. | |
| 3379 | - * This helper copies the label from the <select> onto the generated input. | |
| 3380 | - */ | |
| 3381 | - const label = (_self$input = self.input) == null ? void 0 : _self$input.getAttribute('aria-label'); | |
| 3382 | - if (!label) return; | |
| 3383 | - placeholder.setAttribute('aria-label', label); | |
| 3384 | 3507 | }); |
| 3385 | 3508 | self.on('initialize', () => { |
| 3386 | 3509 | // set tabIndex on control to -1, otherwise [shift+tab] will put focus right back on control_input |
| 3387 | 3510 | self.control_input.addEventListener('keydown', evt => { |
| @@ -3443,9 +3566,9 @@ | ||
| 3443 | 3566 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3444 | 3567 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 3445 | 3568 | /* harmony export */ }); |
| 3446 | 3569 | /** |
| 3447 | -* Tom Select v2.6.2 | |
| 3570 | +* Tom Select v2.4.3 | |
| 3448 | 3571 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 3449 | 3572 | */ |
| 3450 | 3573 | |
| 3451 | 3574 | /** |
| @@ -3531,9 +3654,9 @@ | ||
| 3531 | 3654 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3532 | 3655 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 3533 | 3656 | /* harmony export */ }); |
| 3534 | 3657 | /** |
| 3535 | -* Tom Select v2.6.2 | |
| 3658 | +* Tom Select v2.4.3 | |
| 3536 | 3659 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 3537 | 3660 | */ |
| 3538 | 3661 | |
| 3539 | 3662 | /** |
| @@ -3571,9 +3694,9 @@ | ||
| 3571 | 3694 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3572 | 3695 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 3573 | 3696 | /* harmony export */ }); |
| 3574 | 3697 | /** |
| 3575 | -* Tom Select v2.6.2 | |
| 3698 | +* Tom Select v2.4.3 | |
| 3576 | 3699 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 3577 | 3700 | */ |
| 3578 | 3701 | |
| 3579 | 3702 | /** |
| @@ -3617,9 +3740,9 @@ | ||
| 3617 | 3740 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3618 | 3741 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 3619 | 3742 | /* harmony export */ }); |
| 3620 | 3743 | /** |
| 3621 | -* Tom Select v2.6.2 | |
| 3744 | +* Tom Select v2.4.3 | |
| 3622 | 3745 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 3623 | 3746 | */ |
| 3624 | 3747 | |
| 3625 | 3748 | const KEY_LEFT = 37; |
| @@ -3717,9 +3840,9 @@ | ||
| 3717 | 3840 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3718 | 3841 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 3719 | 3842 | /* harmony export */ }); |
| 3720 | 3843 | /** |
| 3721 | -* Tom Select v2.6.2 | |
| 3844 | +* Tom Select v2.4.3 | |
| 3722 | 3845 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 3723 | 3846 | */ |
| 3724 | 3847 | |
| 3725 | 3848 | /** |
| @@ -3737,8 +3860,16 @@ | ||
| 3737 | 3860 | * |
| 3738 | 3861 | */ |
| 3739 | 3862 | |
| 3740 | 3863 | /** |
| 3864 | + * Escapes a string for use within HTML. | |
| 3865 | + * | |
| 3866 | + */ | |
| 3867 | +const escape_html = str => { | |
| 3868 | + return (str + '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); | |
| 3869 | +}; | |
| 3870 | + | |
| 3871 | +/** | |
| 3741 | 3872 | * Prevent default |
| 3742 | 3873 | * |
| 3743 | 3874 | */ |
| 3744 | 3875 | const preventDefault = (evt, stop = false) => { |
| @@ -3800,31 +3931,28 @@ | ||
| 3800 | 3931 | * |
| 3801 | 3932 | */ |
| 3802 | 3933 | |
| 3803 | 3934 | function plugin (userOptions) { |
| 3804 | - const self = this; | |
| 3805 | 3935 | const options = Object.assign({ |
| 3806 | - label: '×', | |
| 3936 | + label: '×', | |
| 3807 | 3937 | title: 'Remove', |
| 3808 | 3938 | className: 'remove', |
| 3809 | - tabindex: -1, | |
| 3810 | - role: 'button', | |
| 3811 | - html: data => { | |
| 3812 | - var _data$tabindex; | |
| 3813 | - const el = document.createElement('div'); | |
| 3814 | - el.className = data.className || ''; | |
| 3815 | - el.title = data.title || ''; | |
| 3816 | - el.setAttribute('role', data.role || 'button'); | |
| 3817 | - el.tabIndex = (_data$tabindex = data.tabindex) != null ? _data$tabindex : -1; | |
| 3818 | - el.textContent = data.label || ''; | |
| 3819 | - return el; | |
| 3820 | - } | |
| 3939 | + append: true | |
| 3821 | 3940 | }, userOptions); |
| 3941 | + | |
| 3942 | + //options.className = 'remove-single'; | |
| 3943 | + var self = this; | |
| 3944 | + | |
| 3945 | + // override the render method to add remove button to each item | |
| 3946 | + if (!options.append) { | |
| 3947 | + return; | |
| 3948 | + } | |
| 3949 | + var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>'; | |
| 3822 | 3950 | self.hook('after', 'setupTemplates', () => { |
| 3823 | 3951 | var orig_render_item = self.settings.render.item; |
| 3824 | 3952 | self.settings.render.item = (data, escape) => { |
| 3825 | 3953 | var item = getDom(orig_render_item.call(self, data, escape)); |
| 3826 | - var close_button = getDom(options.html(options)); | |
| 3954 | + var close_button = getDom(html); | |
| 3827 | 3955 | item.appendChild(close_button); |
| 3828 | 3956 | addEvent(close_button, 'mousedown', evt => { |
| 3829 | 3957 | preventDefault(evt, true); |
| 3830 | 3958 | }); |
| @@ -3860,9 +3988,9 @@ | ||
| 3860 | 3988 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3861 | 3989 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 3862 | 3990 | /* harmony export */ }); |
| 3863 | 3991 | /** |
| 3864 | -* Tom Select v2.6.2 | |
| 3992 | +* Tom Select v2.4.3 | |
| 3865 | 3993 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 3866 | 3994 | */ |
| 3867 | 3995 | |
| 3868 | 3996 | /** |
| @@ -3916,9 +4044,9 @@ | ||
| 3916 | 4044 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3917 | 4045 | /* harmony export */ "default": () => (/* binding */ plugin) |
| 3918 | 4046 | /* harmony export */ }); |
| 3919 | 4047 | /** |
| 3920 | -* Tom Select v2.6.2 | |
| 4048 | +* Tom Select v2.4.3 | |
| 3921 | 4049 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 3922 | 4050 | */ |
| 3923 | 4051 | |
| 3924 | 4052 | /** |
| @@ -4000,9 +4128,9 @@ | ||
| 4000 | 4128 | return arg; |
| 4001 | 4129 | }; |
| 4002 | 4130 | |
| 4003 | 4131 | /** |
| 4004 | - * Plugin: "virtual_scroll" (Tom Select) | |
| 4132 | + * Plugin: "restore_on_backspace" (Tom Select) | |
| 4005 | 4133 | * Copyright (c) contributors |
| 4006 | 4134 | * |
| 4007 | 4135 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this |
| 4008 | 4136 | * file except in compliance with the License. You may obtain a copy of the License at: |
| @@ -4024,12 +4152,8 @@ | ||
| 4024 | 4152 | var dropdown_content; |
| 4025 | 4153 | var loading_more = false; |
| 4026 | 4154 | var load_more_opt; |
| 4027 | 4155 | var default_values = []; |
| 4028 | - var default_values_loaded = false; | |
| 4029 | - var default_pagination; | |
| 4030 | - var default_options = []; | |
| 4031 | - var html_values = []; | |
| 4032 | 4156 | if (!self.settings.shouldLoadMore) { |
| 4033 | 4157 | // return true if additional results should be loaded |
| 4034 | 4158 | self.settings.shouldLoadMore = () => { |
| 4035 | 4159 | const scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop); |
| @@ -4059,9 +4183,9 @@ | ||
| 4059 | 4183 | }]; |
| 4060 | 4184 | |
| 4061 | 4185 | // can we load more results for given query? |
| 4062 | 4186 | const canLoadMore = query => { |
| 4063 | - if (self.settings.maxOptions !== null && typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions) { | |
| 4187 | + if (typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions) { | |
| 4064 | 4188 | return false; |
| 4065 | 4189 | } |
| 4066 | 4190 | if (query in pagination && pagination[query]) { |
| 4067 | 4191 | return true; |
| @@ -4119,13 +4243,9 @@ | ||
| 4119 | 4243 | |
| 4120 | 4244 | // wrap the load |
| 4121 | 4245 | self.hook('instead', 'loadCallback', (options, optgroups) => { |
| 4122 | 4246 | if (!loading_more) { |
| 4123 | - // When searching (non-empty query), keep selected items and HTML default options, | |
| 4124 | - // but remove preloaded remote options so they don't bleed into search results. | |
| 4125 | - // For empty query, use clearFilter (keeps default_values + items). | |
| 4126 | - const activeFilter = self.lastValue !== '' ? (_option, value) => self.items.indexOf(value) >= 0 || html_values.indexOf(value) >= 0 : clearFilter; | |
| 4127 | - self.clearOptions(activeFilter); | |
| 4247 | + self.clearOptions(clearFilter); | |
| 4128 | 4248 | } else if (load_more_opt) { |
| 4129 | 4249 | const first_option = options[0]; |
| 4130 | 4250 | if (first_option !== undefined) { |
| 4131 | 4251 | load_more_opt.dataset.value = first_option[self.settings.valueField]; |
| @@ -4131,31 +4251,11 @@ | ||
| 4131 | 4251 | load_more_opt.dataset.value = first_option[self.settings.valueField]; |
| 4132 | 4252 | } |
| 4133 | 4253 | } |
| 4134 | 4254 | orig_loadCallback.call(self, options, optgroups); |
| 4135 | - | |
| 4136 | - // After the initial preload (empty query), snapshot default_values and option objects | |
| 4137 | - // so they can be restored when the user clears their search. | |
| 4138 | - if (!loading_more && !default_values_loaded) { | |
| 4139 | - default_values_loaded = true; | |
| 4140 | - if (self.lastValue === '') { | |
| 4141 | - default_values = Object.keys(self.options); | |
| 4142 | - default_pagination = pagination['']; | |
| 4143 | - default_options = Object.values(self.options); | |
| 4144 | - } | |
| 4145 | - } | |
| 4146 | 4255 | loading_more = false; |
| 4147 | 4256 | }); |
| 4148 | 4257 | |
| 4149 | - // as the “loading_more” element will be removed from the dropdown, | |
| 4150 | - // we activate the previous option if needed | |
| 4151 | - // to avoid the dropdown being scrolled back to the first one | |
| 4152 | - self.hook('before', 'refreshOptions', () => { | |
| 4153 | - if (self.activeOption && "option" !== self.activeOption.getAttribute("role")) { | |
| 4154 | - self.setActiveOption(self.activeOption.previousElementSibling); | |
| 4155 | - } | |
| 4156 | - }); | |
| 4157 | - | |
| 4158 | 4258 | // add templates to dropdown |
| 4159 | 4259 | // loading_more if we have another url in the queue |
| 4160 | 4260 | // no_more_results if we don't have another url in the queue |
| 4161 | 4261 | self.hook('after', 'refreshOptions', () => { |
| @@ -4179,32 +4279,10 @@ | ||
| 4179 | 4279 | dropdown_content.append(option); |
| 4180 | 4280 | } |
| 4181 | 4281 | }); |
| 4182 | 4282 | |
| 4183 | - // Restore preloaded options and pagination when clearing search | |
| 4184 | - const restoreDefaults = () => { | |
| 4185 | - if (!default_values_loaded) { | |
| 4186 | - return; | |
| 4187 | - } | |
| 4188 | - // Re-add preloaded option objects (clearOptions can only remove, not restore) | |
| 4189 | - self.addOptions(default_options); | |
| 4190 | - // Remove any search results that are not part of the preloaded defaults | |
| 4191 | - self.clearOptions(clearFilter); | |
| 4192 | - if (default_pagination) { | |
| 4193 | - pagination[''] = default_pagination; | |
| 4194 | - } | |
| 4195 | - }; | |
| 4196 | - self.on('type', query => { | |
| 4197 | - if (query === '') { | |
| 4198 | - restoreDefaults(); | |
| 4199 | - self.refreshOptions(false); | |
| 4200 | - } | |
| 4201 | - }); | |
| 4202 | - self.on('dropdown_close', restoreDefaults); | |
| 4203 | - | |
| 4204 | 4283 | // add scroll listener and default templates |
| 4205 | 4284 | self.on('initialize', () => { |
| 4206 | - html_values = Object.keys(self.options); | |
| 4207 | 4285 | default_values = Object.keys(self.options); |
| 4208 | 4286 | dropdown_content = self.dropdown_content; |
| 4209 | 4287 | |
| 4210 | 4288 | // default templates |
| @@ -4342,9 +4420,8 @@ | ||
| 4342 | 4420 | this.isLocked = false; |
| 4343 | 4421 | this.isFocused = false; |
| 4344 | 4422 | this.isInputHidden = false; |
| 4345 | 4423 | this.isSetup = false; |
| 4346 | - this.isDropdownContentStale = true; | |
| 4347 | 4424 | this.ignoreFocus = false; |
| 4348 | 4425 | this.ignoreHover = false; |
| 4349 | 4426 | this.hasOptions = false; |
| 4350 | 4427 | this.lastValue = ''; |
| @@ -4419,9 +4496,9 @@ | ||
| 4419 | 4496 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, settings.dropdownClass, inputMode); |
| 4420 | 4497 | if (settings.copyClassesToDropdown) { |
| 4421 | 4498 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, classes); |
| 4422 | 4499 | } |
| 4423 | - ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown_content, settings.dropdownContentClass); | |
| 4500 | + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown_content, settings.dropdownContentClass); | |
| 4424 | 4501 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown, dropdown_content); |
| 4425 | 4502 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.dropdownParent || wrapper).appendChild(dropdown); |
| 4426 | 4503 | // default controlInput |
| 4427 | 4504 | if ((0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isHtmlString)(settings.controlInput)) { |
| @@ -4426,9 +4503,9 @@ | ||
| 4426 | 4503 | // default controlInput |
| 4427 | 4504 | if ((0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isHtmlString)(settings.controlInput)) { |
| 4428 | 4505 | control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput); |
| 4429 | 4506 | // set attributes |
| 4430 | - var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck', 'aria-label']; | |
| 4507 | + var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck']; | |
| 4431 | 4508 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(attrs, (attr) => { |
| 4432 | 4509 | if (input.getAttribute(attr)) { |
| 4433 | 4510 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { [attr]: input.getAttribute(attr) }); |
| 4434 | 4511 | } |
| @@ -4489,10 +4566,8 @@ | ||
| 4489 | 4566 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, { 'aria-labelledby': label_id }); |
| 4490 | 4567 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, { 'aria-labelledby': label_id }); |
| 4491 | 4568 | } |
| 4492 | 4569 | wrapper.style.width = input.style.width; |
| 4493 | - wrapper.style.minWidth = input.style.minWidth; | |
| 4494 | - wrapper.style.maxWidth = input.style.maxWidth; | |
| 4495 | 4570 | if (self.plugins.names.length) { |
| 4496 | 4571 | const classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-'); |
| 4497 | 4572 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)([wrapper, dropdown], classes_plugins); |
| 4498 | 4573 | } |
| @@ -4510,9 +4585,9 @@ | ||
| 4510 | 4585 | // after initializePlugins() so plugins can create/modify user defined loaders |
| 4511 | 4586 | if (settings.load && settings.loadThrottle) { |
| 4512 | 4587 | settings.load = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.loadDebounce)(settings.load, settings.loadThrottle); |
| 4513 | 4588 | } |
| 4514 | - ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mousemove', () => { | |
| 4589 | + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mousemove', () => { | |
| 4515 | 4590 | self.ignoreHover = false; |
| 4516 | 4591 | }); |
| 4517 | 4592 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mouseenter', (e) => { |
| 4518 | 4593 | var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(e.target, '[data-selectable]', dropdown); |
| @@ -4575,21 +4650,12 @@ | ||
| 4575 | 4650 | if (self.isOpen) { |
| 4576 | 4651 | self.positionDropdown(); |
| 4577 | 4652 | } |
| 4578 | 4653 | }; |
| 4579 | - const input_invalid = () => { | |
| 4580 | - if (self.isValid) { | |
| 4581 | - self.isValid = false; | |
| 4582 | - self.isInvalid = true; | |
| 4583 | - self.refreshState(); | |
| 4584 | - } | |
| 4585 | - }; | |
| 4586 | - (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(input, 'invalid', input_invalid); | |
| 4587 | 4654 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(document, 'mousedown', doc_mousedown); |
| 4588 | 4655 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'scroll', win_scroll, passive_event); |
| 4589 | 4656 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'resize', win_scroll, passive_event); |
| 4590 | 4657 | this._destroy = () => { |
| 4591 | - input.removeEventListener('invalid', input_invalid); | |
| 4592 | 4658 | document.removeEventListener('mousedown', doc_mousedown); |
| 4593 | 4659 | window.removeEventListener('scroll', win_scroll); |
| 4594 | 4660 | window.removeEventListener('resize', win_scroll); |
| 4595 | 4661 | if (label) |
| @@ -4606,12 +4672,29 @@ | ||
| 4606 | 4672 | self.sync(false); |
| 4607 | 4673 | settings.items = []; |
| 4608 | 4674 | delete settings.optgroups; |
| 4609 | 4675 | delete settings.options; |
| 4676 | + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(input, 'invalid', () => { | |
| 4677 | + if (self.isValid) { | |
| 4678 | + self.isValid = false; | |
| 4679 | + self.isInvalid = true; | |
| 4680 | + self.refreshState(); | |
| 4681 | + } | |
| 4682 | + }); | |
| 4683 | + self.updateOriginalInput(); | |
| 4610 | 4684 | self.refreshItems(); |
| 4611 | 4685 | self.close(false); |
| 4612 | 4686 | self.inputState(); |
| 4613 | 4687 | self.isSetup = true; |
| 4688 | + if (input.disabled) { | |
| 4689 | + self.disable(); | |
| 4690 | + } | |
| 4691 | + else if (input.readOnly) { | |
| 4692 | + self.setReadOnly(true); | |
| 4693 | + } | |
| 4694 | + else { | |
| 4695 | + self.enable(); //sets tabIndex | |
| 4696 | + } | |
| 4614 | 4697 | self.on('change', this.onChange); |
| 4615 | 4698 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(input, 'tomselected', 'ts-hidden-accessible'); |
| 4616 | 4699 | self.trigger('initialize'); |
| 4617 | 4700 | // preload options |
| @@ -4707,20 +4790,11 @@ | ||
| 4707 | 4790 | * |
| 4708 | 4791 | */ |
| 4709 | 4792 | sync(get_settings = true) { |
| 4710 | 4793 | const self = this; |
| 4711 | - const settings = get_settings ? (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(self.input, { delimiter: self.settings.delimiter, allowEmptyOption: self.settings.allowEmptyOption }) : self.settings; | |
| 4794 | + const settings = get_settings ? (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(self.input, { delimiter: self.settings.delimiter }) : self.settings; | |
| 4712 | 4795 | self.setupOptions(settings.options, settings.optgroups); |
| 4713 | 4796 | self.setValue(settings.items || [], true); // silent prevents recursion |
| 4714 | - if (self.input.disabled) { | |
| 4715 | - self.disable(); | |
| 4716 | - } | |
| 4717 | - else if (self.input.readOnly) { | |
| 4718 | - self.setReadOnly(true); | |
| 4719 | - } | |
| 4720 | - else { | |
| 4721 | - self.enable(); //sets tabIndex | |
| 4722 | - } | |
| 4723 | 4797 | self.lastQuery = null; // so updated options will be displayed in dropdown |
| 4724 | 4798 | } |
| 4725 | 4799 | /** |
| 4726 | 4800 | * Triggered when the main control element |
| @@ -4751,9 +4825,9 @@ | ||
| 4751 | 4825 | * This should propagate the event to the original DOM |
| 4752 | 4826 | * input / select element. |
| 4753 | 4827 | */ |
| 4754 | 4828 | onChange() { |
| 4755 | - ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'input'); | |
| 4829 | + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'input'); | |
| 4756 | 4830 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'change'); |
| 4757 | 4831 | } |
| 4758 | 4832 | /** |
| 4759 | 4833 | * Triggered on <input> paste. |
| @@ -4848,9 +4922,9 @@ | ||
| 4848 | 4922 | let next = self.getAdjacent(self.activeOption, 1); |
| 4849 | 4923 | if (next) |
| 4850 | 4924 | self.setActiveOption(next); |
| 4851 | 4925 | } |
| 4852 | - ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e); | |
| 4926 | + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e); | |
| 4853 | 4927 | return; |
| 4854 | 4928 | // up: move selection up |
| 4855 | 4929 | case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_UP: |
| 4856 | 4930 | if (self.activeOption) { |
| @@ -4857,9 +4931,9 @@ | ||
| 4857 | 4931 | let prev = self.getAdjacent(self.activeOption, -1); |
| 4858 | 4932 | if (prev) |
| 4859 | 4933 | self.setActiveOption(prev); |
| 4860 | 4934 | } |
| 4861 | - ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e); | |
| 4935 | + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e); | |
| 4862 | 4936 | return; |
| 4863 | 4937 | // return: select active option |
| 4864 | 4938 | case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RETURN: |
| 4865 | 4939 | if (self.canSelect(self.activeOption)) { |
| @@ -4891,9 +4965,9 @@ | ||
| 4891 | 4965 | // prevent default [tab] behaviour of jump to the next field |
| 4892 | 4966 | // if select isFull, then the dropdown won't be open and [tab] will work normally |
| 4893 | 4967 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e); |
| 4894 | 4968 | } |
| 4895 | - else if (self.settings.create && self.createItem()) { | |
| 4969 | + if (self.settings.create && self.createItem()) { | |
| 4896 | 4970 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e); |
| 4897 | 4971 | } |
| 4898 | 4972 | } |
| 4899 | 4973 | return; |
| @@ -5015,24 +5089,18 @@ | ||
| 5015 | 5089 | self.createItem(null, () => { |
| 5016 | 5090 | if (self.settings.closeAfterSelect) { |
| 5017 | 5091 | self.close(); |
| 5018 | 5092 | } |
| 5019 | - else if (self.settings.clearAfterSelect) { | |
| 5020 | - self.setTextboxValue(); | |
| 5021 | - } | |
| 5022 | 5093 | }); |
| 5023 | 5094 | } |
| 5024 | 5095 | else { |
| 5025 | 5096 | value = option.dataset.value; |
| 5026 | 5097 | if (typeof value !== 'undefined') { |
| 5027 | - self.isDropdownContentStale = self.settings.hideSelected; | |
| 5098 | + self.lastQuery = null; | |
| 5028 | 5099 | self.addItem(value); |
| 5029 | 5100 | if (self.settings.closeAfterSelect) { |
| 5030 | 5101 | self.close(); |
| 5031 | 5102 | } |
| 5032 | - else if (self.settings.clearAfterSelect) { | |
| 5033 | - self.setTextboxValue(); | |
| 5034 | - } | |
| 5035 | 5103 | if (!self.settings.hideSelected && evt.type && /click/.test(evt.type)) { |
| 5036 | 5104 | self.setActiveOption(option); |
| 5037 | 5105 | } |
| 5038 | 5106 | } |
| @@ -5104,9 +5172,9 @@ | ||
| 5104 | 5172 | */ |
| 5105 | 5173 | loadCallback(options, optgroups) { |
| 5106 | 5174 | const self = this; |
| 5107 | 5175 | self.loading = Math.max(self.loading - 1, 0); |
| 5108 | - self.isDropdownContentStale = true; | |
| 5176 | + self.lastQuery = null; | |
| 5109 | 5177 | self.clearActiveOption(); // when new results load, focus should be on first option |
| 5110 | 5178 | self.setupOptions(options, optgroups); |
| 5111 | 5179 | self.refreshOptions(self.isFocused && !self.isInputHidden); |
| 5112 | 5180 | if (!self.loading) { |
| @@ -5203,9 +5271,9 @@ | ||
| 5203 | 5271 | if (self.activeItems.indexOf(item) === -1) { |
| 5204 | 5272 | self.setActiveItemClass(item); |
| 5205 | 5273 | } |
| 5206 | 5274 | } |
| 5207 | - ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e); | |
| 5275 | + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e); | |
| 5208 | 5276 | } |
| 5209 | 5277 | 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))) { |
| 5210 | 5278 | if (item.classList.contains('active')) { |
| 5211 | 5279 | self.removeActiveItem(item); |
| @@ -5252,9 +5320,9 @@ | ||
| 5252 | 5320 | * Clears all the active items |
| 5253 | 5321 | * |
| 5254 | 5322 | */ |
| 5255 | 5323 | clearActiveItems() { |
| 5256 | - ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeItems, 'active'); | |
| 5324 | + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeItems, 'active'); | |
| 5257 | 5325 | this.activeItems = []; |
| 5258 | 5326 | } |
| 5259 | 5327 | /** |
| 5260 | 5328 | * Sets the selected item in the dropdown menu |
| @@ -5369,21 +5437,17 @@ | ||
| 5369 | 5437 | var self = this; |
| 5370 | 5438 | if (self.isDisabled || self.isReadOnly) |
| 5371 | 5439 | return; |
| 5372 | 5440 | self.ignoreFocus = true; |
| 5373 | - const focusTarget = this.control_input.offsetWidth ? this.control_input : this.focus_node; | |
| 5374 | - focusTarget.focus(); | |
| 5441 | + if (self.control_input.offsetWidth) { | |
| 5442 | + self.control_input.focus(); | |
| 5443 | + } | |
| 5444 | + else { | |
| 5445 | + self.focus_node.focus(); | |
| 5446 | + } | |
| 5375 | 5447 | setTimeout(() => { |
| 5376 | 5448 | self.ignoreFocus = false; |
| 5377 | - // Fix https://github.com/orchidjs/tom-select/issues/806 | |
| 5378 | - // Only proceed if this instance's element is still the active element. If Edge autofill | |
| 5379 | - // (or anything else) has moved focus to a different element in the interim, calling | |
| 5380 | - // onFocus() here would steal focus back and restart the cascade loop. | |
| 5381 | - const root = focusTarget.getRootNode(); | |
| 5382 | - if (root.activeElement !== focusTarget) { | |
| 5383 | - return; | |
| 5384 | - } | |
| 5385 | - this.onFocus(); | |
| 5449 | + self.onFocus(); | |
| 5386 | 5450 | }, 0); |
| 5387 | 5451 | } |
| 5388 | 5452 | /** |
| 5389 | 5453 | * Forces the control out of focus. |
| @@ -5439,15 +5503,10 @@ | ||
| 5439 | 5503 | throw new Error('Tom Select "score" setting must be a function that returns a function'); |
| 5440 | 5504 | } |
| 5441 | 5505 | } |
| 5442 | 5506 | // perform search |
| 5443 | - if (self.isDropdownContentStale || query !== self.lastQuery) { | |
| 5507 | + if (query !== self.lastQuery) { | |
| 5444 | 5508 | self.lastQuery = query; |
| 5445 | - // temp fix for https://github.com/orchidjs/tom-select/issues/987 | |
| 5446 | - // UI crashed when more than 30 same chars in a row, prevent search and return empt result | |
| 5447 | - if (/(.)\1{15,}/.test(query)) { | |
| 5448 | - query = ''; | |
| 5449 | - } | |
| 5450 | 5509 | result = self.sifter.search(query, Object.assign(options, { score: calculateScore })); |
| 5451 | 5510 | self.currentResults = result; |
| 5452 | 5511 | } |
| 5453 | 5512 | else { |
| @@ -5456,9 +5515,9 @@ | ||
| 5456 | 5515 | // filter out selected items |
| 5457 | 5516 | if (self.settings.hideSelected) { |
| 5458 | 5517 | result.items = result.items.filter((item) => { |
| 5459 | 5518 | let hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item.id); |
| 5460 | - return !(hashed !== null && self.items.indexOf(hashed) !== -1); | |
| 5519 | + return !(hashed && self.items.indexOf(hashed) !== -1); | |
| 5461 | 5520 | }); |
| 5462 | 5521 | } |
| 5463 | 5522 | return result; |
| 5464 | 5523 | } |
| @@ -5528,15 +5587,8 @@ | ||
| 5528 | 5587 | for (j = 0, k = optgroups && optgroups.length; j < k; j++) { |
| 5529 | 5588 | optgroup = optgroups[j]; |
| 5530 | 5589 | let order = option.$order; |
| 5531 | 5590 | let self_optgroup = self.optgroups[optgroup]; |
| 5532 | - if (self_optgroup === undefined && typeof self.settings.optionGroupRegister === 'function') { | |
| 5533 | - var regGroup; | |
| 5534 | - if (regGroup = self.settings.optionGroupRegister.apply(self, [optgroup])) { | |
| 5535 | - self.registerOptionGroup(regGroup); | |
| 5536 | - } | |
| 5537 | - } | |
| 5538 | - self_optgroup = self.optgroups[optgroup]; | |
| 5539 | 5591 | if (self_optgroup === undefined) { |
| 5540 | 5592 | optgroup = ''; |
| 5541 | 5593 | } |
| 5542 | 5594 | else { |
| @@ -5589,9 +5641,8 @@ | ||
| 5589 | 5641 | } |
| 5590 | 5642 | }); |
| 5591 | 5643 | dropdown_content.innerHTML = ''; |
| 5592 | 5644 | (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown_content, html); |
| 5593 | - self.isDropdownContentStale = false; | |
| 5594 | 5645 | // highlight matching terms inline |
| 5595 | 5646 | if (self.settings.highlight) { |
| 5596 | 5647 | (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.removeHighlight)(dropdown_content); |
| 5597 | 5648 | if (results.query.length && results.tokens.length) { |
| @@ -5684,15 +5735,14 @@ | ||
| 5684 | 5735 | return false; |
| 5685 | 5736 | } |
| 5686 | 5737 | const key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]); |
| 5687 | 5738 | if (key === null || self.options.hasOwnProperty(key)) { |
| 5688 | - self.updateOption(data[self.settings.valueField], data); | |
| 5689 | 5739 | return false; |
| 5690 | 5740 | } |
| 5691 | 5741 | data.$order = data.$order || ++self.order; |
| 5692 | 5742 | data.$id = self.inputId + '-opt-' + data.$order; |
| 5693 | 5743 | self.options[key] = data; |
| 5694 | - self.isDropdownContentStale = true; | |
| 5744 | + self.lastQuery = null; | |
| 5695 | 5745 | if (user_created) { |
| 5696 | 5746 | self.userOptions[key] = user_created; |
| 5697 | 5747 | self.trigger('option_add', key, data); |
| 5698 | 5748 | } |
| @@ -5702,9 +5752,9 @@ | ||
| 5702 | 5752 | * Add multiple options |
| 5703 | 5753 | * |
| 5704 | 5754 | */ |
| 5705 | 5755 | addOptions(data, user_created = false) { |
| 5706 | - ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(data, (dat) => { | |
| 5756 | + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(data, (dat) => { | |
| 5707 | 5757 | this.addOption(dat, user_created); |
| 5708 | 5758 | }); |
| 5709 | 5759 | } |
| 5710 | 5760 | /** |
| @@ -5806,10 +5856,10 @@ | ||
| 5806 | 5856 | if (item.classList.contains('active')) |
| 5807 | 5857 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item_new, 'active'); |
| 5808 | 5858 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(item, item_new); |
| 5809 | 5859 | } |
| 5810 | - // we might have updated the sortField | |
| 5811 | - self.isDropdownContentStale = true; | |
| 5860 | + // invalidate last query because we might have updated the sortField | |
| 5861 | + self.lastQuery = null; | |
| 5812 | 5862 | } |
| 5813 | 5863 | /** |
| 5814 | 5864 | * Removes a single option. |
| 5815 | 5865 | * |
| @@ -5819,9 +5869,9 @@ | ||
| 5819 | 5869 | value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(value); |
| 5820 | 5870 | self.uncacheValue(value); |
| 5821 | 5871 | delete self.userOptions[value]; |
| 5822 | 5872 | delete self.options[value]; |
| 5823 | - self.isDropdownContentStale = true; | |
| 5873 | + self.lastQuery = null; | |
| 5824 | 5874 | self.trigger('option_remove', value); |
| 5825 | 5875 | self.removeItem(value, silent); |
| 5826 | 5876 | } |
| 5827 | 5877 | /** |
| @@ -5838,9 +5888,9 @@ | ||
| 5838 | 5888 | selected[key] = option; |
| 5839 | 5889 | } |
| 5840 | 5890 | }); |
| 5841 | 5891 | this.options = this.sifter.items = selected; |
| 5842 | - this.isDropdownContentStale = true; | |
| 5892 | + this.lastQuery = null; | |
| 5843 | 5893 | this.trigger('option_clear'); |
| 5844 | 5894 | } |
| 5845 | 5895 | /** |
| 5846 | 5896 | * Used by clearOptions() to decide whether or not an option should be removed |
| @@ -5970,12 +6020,8 @@ | ||
| 5970 | 6020 | if (next) { |
| 5971 | 6021 | self.setActiveOption(next); |
| 5972 | 6022 | } |
| 5973 | 6023 | } |
| 5974 | - //remove input value when enabled | |
| 5975 | - if (self.settings.clearAfterSelect) { | |
| 5976 | - self.setTextboxValue(); | |
| 5977 | - } | |
| 5978 | 6024 | // refreshOptions after setActiveOption(), |
| 5979 | 6025 | // otherwise setActiveOption() will be called by refreshOptions() with the wrong value |
| 5980 | 6026 | if (!self.isPending && !self.settings.closeAfterSelect) { |
| 5981 | 6027 | self.refreshOptions(self.isFocused && inputMode !== 'single'); |
| @@ -6017,9 +6063,9 @@ | ||
| 6017 | 6063 | self.activeItems.splice(idx, 1); |
| 6018 | 6064 | (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active'); |
| 6019 | 6065 | } |
| 6020 | 6066 | self.items.splice(i, 1); |
| 6021 | - self.isDropdownContentStale = true; | |
| 6067 | + self.lastQuery = null; | |
| 6022 | 6068 | if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) { |
| 6023 | 6069 | self.removeOption(value, silent); |
| 6024 | 6070 | } |
| 6025 | 6071 | if (i < self.caretPos) { |
| @@ -6051,14 +6097,8 @@ | ||
| 6051 | 6097 | var caret = self.caretPos; |
| 6052 | 6098 | var output; |
| 6053 | 6099 | input = input || self.inputValue(); |
| 6054 | 6100 | if (!self.canCreate(input)) { |
| 6055 | - const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(input); | |
| 6056 | - if (hash) { | |
| 6057 | - if (this.options[input]) { | |
| 6058 | - self.addItem(input); | |
| 6059 | - } | |
| 6060 | - } | |
| 6061 | 6101 | callback(); |
| 6062 | 6102 | return false; |
| 6063 | 6103 | } |
| 6064 | 6104 | self.lock(); |
| @@ -6096,9 +6136,9 @@ | ||
| 6096 | 6136 | * Re-renders the selected item lists. |
| 6097 | 6137 | */ |
| 6098 | 6138 | refreshItems() { |
| 6099 | 6139 | var self = this; |
| 6100 | - self.isDropdownContentStale = true; | |
| 6140 | + self.lastQuery = null; | |
| 6101 | 6141 | if (self.isSetup) { |
| 6102 | 6142 | self.addItems(self.items); |
| 6103 | 6143 | } |
| 6104 | 6144 | self.updateOriginalInput(); |
| @@ -6175,9 +6215,9 @@ | ||
| 6175 | 6215 | } |
| 6176 | 6216 | selected.push(option_el); |
| 6177 | 6217 | // marking empty option as selected can break validation |
| 6178 | 6218 | // fixes https://github.com/orchidjs/tom-select/issues/303 |
| 6179 | - if (option_el != empty_option || has_selected > 0 || self.settings.mode == 'multi') { | |
| 6219 | + if (option_el != empty_option || has_selected > 0) { | |
| 6180 | 6220 | option_el.selected = true; |
| 6181 | 6221 | } |
| 6182 | 6222 | return option_el; |
| 6183 | 6223 | } |
| @@ -6318,9 +6358,9 @@ | ||
| 6318 | 6358 | caret = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(tail); |
| 6319 | 6359 | if (direction > 0) { |
| 6320 | 6360 | caret++; |
| 6321 | 6361 | } |
| 6322 | - ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(self.activeItems, (item) => rm_items.push(item)); | |
| 6362 | + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(self.activeItems, (item) => rm_items.push(item)); | |
| 6323 | 6363 | } |
| 6324 | 6364 | else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) { |
| 6325 | 6365 | const items = self.controlChildren(); |
| 6326 | 6366 | let rm_item; |
| @@ -6336,9 +6376,9 @@ | ||
| 6336 | 6376 | } |
| 6337 | 6377 | if (!self.shouldDelete(rm_items, e)) { |
| 6338 | 6378 | return false; |
| 6339 | 6379 | } |
| 6340 | - ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true); | |
| 6380 | + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true); | |
| 6341 | 6381 | // perform removal |
| 6342 | 6382 | if (typeof caret !== 'undefined') { |
| 6343 | 6383 | self.setCaret(caret); |
| 6344 | 6384 | } |
| @@ -6355,9 +6395,9 @@ | ||
| 6355 | 6395 | */ |
| 6356 | 6396 | shouldDelete(items, evt) { |
| 6357 | 6397 | const values = items.map(item => item.dataset.value); |
| 6358 | 6398 | // allow the callback to abort |
| 6359 | - if (!values.length || (typeof this.settings.onDelete === 'function' && this.settings.onDelete.call(this, values, evt) === false)) { | |
| 6399 | + if (!values.length || (typeof this.settings.onDelete === 'function' && this.settings.onDelete(values, evt) === false)) { | |
| 6360 | 6400 | return false; |
| 6361 | 6401 | } |
| 6362 | 6402 | return true; |
| 6363 | 6403 | } |
| @@ -6574,9 +6614,9 @@ | ||
| 6574 | 6614 | * caches. |
| 6575 | 6615 | * |
| 6576 | 6616 | */ |
| 6577 | 6617 | clearCache() { |
| 6578 | - ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option) => { | |
| 6618 | + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option) => { | |
| 6579 | 6619 | if (option.$div) { |
| 6580 | 6620 | option.$div.remove(); |
| 6581 | 6621 | delete option.$div; |
| 6582 | 6622 | } |
| @@ -7053,19 +7093,19 @@ | ||
| 7053 | 7093 | |
| 7054 | 7094 | /******/ }); |
| 7055 | 7095 | /************************************************************************/ |
| 7056 | 7096 | /******/ // The module cache |
| 7057 | -/******/ const __webpack_module_cache__ = {}; | |
| 7097 | +/******/ var __webpack_module_cache__ = {}; | |
| 7058 | 7098 | /******/ |
| 7059 | 7099 | /******/ // The require function |
| 7060 | 7100 | /******/ function __webpack_require__(moduleId) { |
| 7061 | 7101 | /******/ // Check if module is in cache |
| 7062 | -/******/ const cachedModule = __webpack_module_cache__[moduleId]; | |
| 7102 | +/******/ var cachedModule = __webpack_module_cache__[moduleId]; | |
| 7063 | 7103 | /******/ if (cachedModule !== undefined) { |
| 7064 | 7104 | /******/ return cachedModule.exports; |
| 7065 | 7105 | /******/ } |
| 7066 | 7106 | /******/ // Create a new module (and put it into the cache) |
| 7067 | -/******/ const module = __webpack_module_cache__[moduleId] = { | |
| 7107 | +/******/ var module = __webpack_module_cache__[moduleId] = { | |
| 7068 | 7108 | /******/ // no module.id needed |
| 7069 | 7109 | /******/ // no module.loaded needed |
| 7070 | 7110 | /******/ exports: {} |
| 7071 | 7111 | /******/ }; |
| @@ -7072,9 +7112,9 @@ | ||
| 7072 | 7112 | /******/ |
| 7073 | 7113 | /******/ // Execute the module function |
| 7074 | 7114 | /******/ if (!(moduleId in __webpack_modules__)) { |
| 7075 | 7115 | /******/ delete __webpack_module_cache__[moduleId]; |
| 7076 | -/******/ const e = new Error("Cannot find module '" + moduleId + "'"); | |
| 7116 | +/******/ var e = new Error("Cannot find module '" + moduleId + "'"); | |
| 7077 | 7117 | /******/ e.code = 'MODULE_NOT_FOUND'; |
| 7078 | 7118 | /******/ throw e; |
| 7079 | 7119 | /******/ } |
| 7080 | 7120 | /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); |
| @@ -7085,29 +7125,14 @@ | ||
| 7085 | 7125 | /******/ |
| 7086 | 7126 | /************************************************************************/ |
| 7087 | 7127 | /******/ /* webpack/runtime/define property getters */ |
| 7088 | 7128 | /******/ (() => { |
| 7089 | -/******/ // define getter/value functions for harmony exports | |
| 7129 | +/******/ // define getter functions for harmony exports | |
| 7090 | 7130 | /******/ __webpack_require__.d = (exports, definition) => { |
| 7091 | -/******/ if(Array.isArray(definition)) { | |
| 7092 | -/******/ var i = 0; | |
| 7093 | -/******/ while(i < definition.length) { | |
| 7094 | -/******/ var key = definition[i++]; | |
| 7095 | -/******/ var binding = definition[i++]; | |
| 7096 | -/******/ if(!__webpack_require__.o(exports, key)) { | |
| 7097 | -/******/ if(binding === 0) { | |
| 7098 | -/******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] }); | |
| 7099 | -/******/ } else { | |
| 7100 | -/******/ Object.defineProperty(exports, key, { enumerable: true, get: binding }); | |
| 7101 | -/******/ } | |
| 7102 | -/******/ } else if(binding === 0) { i++; } | |
| 7131 | +/******/ for(var key in definition) { | |
| 7132 | +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | |
| 7133 | +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | |
| 7103 | 7134 | /******/ } |
| 7104 | -/******/ } else { | |
| 7105 | -/******/ for(var key in definition) { | |
| 7106 | -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | |
| 7107 | -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | |
| 7108 | -/******/ } | |
| 7109 | -/******/ } | |
| 7110 | 7135 | /******/ } |
| 7111 | 7136 | /******/ }; |
| 7112 | 7137 | /******/ })(); |
| 7113 | 7138 | /******/ |
| @@ -7112,9 +7137,9 @@ | ||
| 7112 | 7137 | /******/ })(); |
| 7113 | 7138 | /******/ |
| 7114 | 7139 | /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 7115 | 7140 | /******/ (() => { |
| 7116 | -/******/ __webpack_require__.o = (obj, prop) => (Object.hasOwn(obj, prop)) | |
| 7141 | +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) | |
| 7117 | 7142 | /******/ })(); |
| 7118 | 7143 | /******/ |
| 7119 | 7144 | /******/ /* webpack/runtime/make namespace object */ |
| 7120 | 7145 | /******/ (() => { |
| @@ -7119,9 +7144,9 @@ | ||
| 7119 | 7144 | /******/ /* webpack/runtime/make namespace object */ |
| 7120 | 7145 | /******/ (() => { |
| 7121 | 7146 | /******/ // define __esModule on exports |
| 7122 | 7147 | /******/ __webpack_require__.r = (exports) => { |
| 7123 | -/******/ if(Symbol.toStringTag) { | |
| 7148 | +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | |
| 7124 | 7149 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 7125 | 7150 | /******/ } |
| 7126 | 7151 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 7127 | 7152 | /******/ }; |
| @@ -7127,9 +7152,9 @@ | ||
| 7127 | 7152 | /******/ }; |
| 7128 | 7153 | /******/ })(); |
| 7129 | 7154 | /******/ |
| 7130 | 7155 | /************************************************************************/ |
| 7131 | -let __webpack_exports__ = {}; | |
| 7156 | +var __webpack_exports__ = {}; | |
| 7132 | 7157 | // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk. |
| 7133 | 7158 | (() => { |
| 7134 | 7159 | /*!********************************************!*\ |
| 7135 | 7160 | !*** ./assets/src/js/admin/admin-tools.js ***! |