mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
fix: type
This commit is contained in:
parent
db1ac85acf
commit
9f9749548a
@ -32,21 +32,23 @@ window.customElements.define(
|
|||||||
this.attachShadow({ mode: 'open' });
|
this.attachShadow({ mode: 'open' });
|
||||||
this.shadowRoot?.append(SelectTemplate.content.cloneNode(true));
|
this.shadowRoot?.append(SelectTemplate.content.cloneNode(true));
|
||||||
|
|
||||||
this._button = this.shadowRoot.querySelector('div[part="button"]');
|
this._button = this.shadowRoot!.querySelector('div[part="button"]')!;
|
||||||
this._text = this.shadowRoot.querySelector('input[part="current-text"]');
|
this._text = this.shadowRoot!.querySelector('input[part="current-text"]')!;
|
||||||
this._context = this.shadowRoot.querySelector('ul[part="option-list"]');
|
this._context = this.shadowRoot!.querySelector('ul[part="option-list"]')!;
|
||||||
|
|
||||||
const buttonClick = () => {
|
const buttonClick = () => {
|
||||||
const isHidden = this._context.classList.toggle('hidden');
|
const isHidden = this._context.classList.toggle('hidden');
|
||||||
window[`${isHidden ? 'remove' : 'add'}EventListener`]('pointerdown', windowPointerDown);
|
window[`${isHidden ? 'remove' : 'add'}EventListener`]('pointerdown', windowPointerDown);
|
||||||
};
|
};
|
||||||
|
|
||||||
const windowPointerDown = ({ target }) => {
|
const windowPointerDown = ({ target }: any) => {
|
||||||
if (!this.contains(target)) buttonClick();
|
if (!this.contains(target)) buttonClick();
|
||||||
};
|
};
|
||||||
|
|
||||||
this._button.addEventListener('click', buttonClick);
|
this._button.addEventListener('click', buttonClick);
|
||||||
this._context.addEventListener('click', ({ target }: MouseEventExtend) => {
|
this._context.addEventListener('click', (event) => {
|
||||||
|
const { target } = event as MouseEventExtend;
|
||||||
|
|
||||||
if (target.tagName !== 'SETTING-OPTION') return;
|
if (target.tagName !== 'SETTING-OPTION') return;
|
||||||
buttonClick();
|
buttonClick();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user