()
| 17 | this.max = max; |
| 18 | } |
| 19 | getHTML() { |
| 20 | const div = document.createElement("div"); |
| 21 | div.classList.add("fancySelect"); |
| 22 | const input = document.createElement("input"); |
| 23 | input.type = "text"; |
| 24 | div.append(input); |
| 25 | |
| 26 | const options = document.createElement("div"); |
| 27 | options.classList.add("fancyOptions"); |
| 28 | const genArgs = () => { |
| 29 | Array.from(div.getElementsByClassName("selected")).forEach((_) => _.remove()); |
| 30 | for (const option of this.options.toReversed()) { |
| 31 | if (!option.default) continue; |
| 32 | const span = document.createElement("span"); |
| 33 | span.classList.add("selected"); |
| 34 | span.textContent = option.label; |
| 35 | |
| 36 | const x = document.createElement("span"); |
| 37 | x.classList.add("svg-x"); |
| 38 | span.prepend(x); |
| 39 | x.onmousedown = (e) => { |
| 40 | e.preventDefault(); |
| 41 | e.stopImmediatePropagation(); |
| 42 | input.focus(); |
| 43 | span.remove(); |
| 44 | option.default = false; |
| 45 | genList(input.value); |
| 46 | }; |
| 47 | |
| 48 | div.prepend(span); |
| 49 | } |
| 50 | }; |
| 51 | const genList = (filter: string) => { |
| 52 | options.innerHTML = ""; |
| 53 | options.classList.remove("removeElm"); |
| 54 | for (const option of this.options) { |
| 55 | if ( |
| 56 | !option.label.includes(filter) && |
| 57 | !option.description?.includes(filter) && |
| 58 | !option.value.includes(filter) |
| 59 | ) { |
| 60 | continue; |
| 61 | } |
| 62 | const div = document.createElement("div"); |
| 63 | div.classList.add("flexltr"); |
| 64 | |
| 65 | const check = document.createElement("input"); |
| 66 | check.type = "checkbox"; |
| 67 | check.checked = option.default; |
| 68 | check.onclick = (e) => e.preventDefault(); |
| 69 | |
| 70 | const label = document.createElement("div"); |
| 71 | label.classList.add("flexttb"); |
| 72 | label.append(option.label); |
| 73 | if (option.description) { |
| 74 | const p = document.createElement("p"); |
| 75 | p.textContent = option.description; |
| 76 | label.append(p); |
no test coverage detected