|
1 | | -import { debounce } from "../../modules/utility.js" |
| 1 | +import { debounce, registerBootstrapBlazorModule } from "../../modules/utility.js" |
2 | 2 | import { handleKeyUp, select, selectAllByFocus, selectAllByEnter } from "../Input/BootstrapInput.razor.js" |
3 | 3 | import Data from "../../modules/data.js" |
4 | 4 | import EventHandler from "../../modules/event-handler.js" |
5 | 5 | import Input from "../../modules/input.js" |
6 | 6 | import Popover from "../../modules/base-popover.js" |
7 | 7 |
|
8 | | -if (window.BootstrapBlazor === void 0) { |
9 | | - window.BootstrapBlazor = {}; |
10 | | -} |
11 | | - |
12 | 8 | export function init(id, invoke) { |
13 | 9 | const el = document.getElementById(id) |
14 | 10 | const menu = el.querySelector('.dropdown-menu') |
@@ -76,31 +72,28 @@ export function init(id, invoke) { |
76 | 72 | filterCallback(v); |
77 | 73 | }); |
78 | 74 |
|
79 | | - if (window.BootstrapBlazor.AutoComplete === void 0) { |
80 | | - window.BootstrapBlazor.AutoComplete = { |
81 | | - hooked: false, |
82 | | - registerCloseDropdownHandler: function () { |
83 | | - if (this.hooked === false) { |
84 | | - this.hooked = true; |
85 | | - |
86 | | - EventHandler.on(document, 'click', e => { |
87 | | - [...document.querySelectorAll('.auto-complete.show')].forEach(a => { |
88 | | - const ac = e.target.closest('.auto-complete'); |
89 | | - if (ac === a) { |
90 | | - return; |
91 | | - } |
92 | | - |
93 | | - const el = a.querySelector('[data-bs-toggle="bb.dropdown"]'); |
94 | | - if (el === null) { |
95 | | - a.classList.remove('show'); |
96 | | - } |
97 | | - }); |
| 75 | + registerBootstrapBlazorModule('AutoComplete', { |
| 76 | + hooked: false, |
| 77 | + registerCloseDropdownHandler: function () { |
| 78 | + if (this.hooked === false) { |
| 79 | + this.hooked = true; |
| 80 | + |
| 81 | + EventHandler.on(document, 'click', e => { |
| 82 | + [...document.querySelectorAll('.auto-complete.show')].forEach(a => { |
| 83 | + const ac = e.target.closest('.auto-complete'); |
| 84 | + if (ac === a) { |
| 85 | + return; |
| 86 | + } |
| 87 | + |
| 88 | + const el = a.querySelector('[data-bs-toggle="bb.dropdown"]'); |
| 89 | + if (el === null) { |
| 90 | + a.classList.remove('show'); |
| 91 | + } |
98 | 92 | }); |
99 | | - } |
| 93 | + }); |
100 | 94 | } |
101 | 95 | } |
102 | | - } |
103 | | - |
| 96 | + }); |
104 | 97 | window.BootstrapBlazor.AutoComplete.registerCloseDropdownHandler(); |
105 | 98 | } |
106 | 99 |
|
|
0 commit comments