From 185bcc8f68ad9bf6dbd7c9133c0ba578ea7d485e Mon Sep 17 00:00:00 2001 From: Markus Sanin Date: Mon, 8 Jan 2024 11:16:17 +0100 Subject: [PATCH] Fix types --- .../components/power-select-multiple/input.ts | 36 ++++++++-------- .../power-select-multiple/trigger.ts | 42 ++++++++++--------- .../components/power-select/before-options.ts | 31 +++++++------- .../power-select/no-matches-message.ts | 9 ++-- .../src/components/power-select/options.ts | 14 ++++--- .../components/power-select/placeholder.ts | 14 ++++--- .../power-select/power-select-group.ts | 9 ++-- .../components/power-select/search-message.ts | 8 ++-- .../src/components/power-select/trigger.ts | 19 +++++---- 9 files changed, 104 insertions(+), 78 deletions(-) diff --git a/ember-power-select/src/components/power-select-multiple/input.ts b/ember-power-select/src/components/power-select-multiple/input.ts index e7fc6a71b..f7a50d1a7 100644 --- a/ember-power-select/src/components/power-select-multiple/input.ts +++ b/ember-power-select/src/components/power-select-multiple/input.ts @@ -7,29 +7,31 @@ import { isBlank } from '@ember/utils'; import { htmlSafe } from '@ember/template'; import type { Select } from '../power-select'; -interface Args { +interface PowerSelectMultipleInputSignature { Element: HTMLElement; - select: Select; - placeholder?: string; - searchField: string; - tabindex?: string; - listboxId?: string; - ariaLabel?: string; - ariaActiveDescendant?: string; - ariaLabelledBy?: string; - placeholderComponent?: string; - isDefaultPlaceholder?: boolean; - onInput?: (e: InputEvent) => boolean; - onKeydown?: (e: KeyboardEvent) => boolean; - onFocus: (e: FocusEvent) => void; - onBlur: (e: FocusEvent) => void; - buildSelection: (lastSelection: any, select: Select) => any[]; + Args: { + select: Select; + placeholder?: string; + searchField: string; + tabindex?: string; + listboxId?: string; + ariaLabel?: string; + ariaActiveDescendant?: string; + ariaLabelledBy?: string; + placeholderComponent?: string; + isDefaultPlaceholder?: boolean; + onInput?: (e: InputEvent) => boolean; + onKeydown?: (e: KeyboardEvent) => boolean; + onFocus: (e: FocusEvent) => void; + onBlur: (e: FocusEvent) => void; + buildSelection: (lastSelection: any, select: Select) => any[]; + }; } const ua = window && window.navigator ? window.navigator.userAgent : ''; const isIE = ua.indexOf('MSIE ') > -1 || ua.indexOf('Trident/') > -1; -export default class PowerSelectMultipleInputComponent extends Component { +export default class PowerSelectMultipleInputComponent extends Component { private inputFont?: string; // Properties diff --git a/ember-power-select/src/components/power-select-multiple/trigger.ts b/ember-power-select/src/components/power-select-multiple/trigger.ts index 3de2af978..331b7e55d 100644 --- a/ember-power-select/src/components/power-select-multiple/trigger.ts +++ b/ember-power-select/src/components/power-select-multiple/trigger.ts @@ -5,29 +5,33 @@ import { scheduleOnce } from '@ember/runloop'; import type { Select } from '../power-select'; import type { ComponentLike } from '@glint/template'; -interface Args { +interface PowerSelectMultipleTriggerSignature { Element: HTMLElement; - select: Select; - searchEnabled: boolean; - placeholder?: string; - searchField: string; - listboxId?: string; - tabindex?: string; - ariaLabel?: string; - ariaLabelledBy?: string; - ariaActiveDescendant: string; - extra?: any; - placeholderComponent?: string | ComponentLike; - selectedItemComponent?: string | ComponentLike; - onInput?: (e: InputEvent) => boolean; - onKeydown?: (e: KeyboardEvent) => boolean; - onFocus?: (e: FocusEvent) => void; - onBlur?: (e: FocusEvent) => void; - buildSelection: (lastSelection: any, select: Select) => any[]; + Args: { + Element: HTMLElement; + select: Select; + searchEnabled: boolean; + placeholder?: string; + searchField: string; + listboxId?: string; + tabindex?: string; + ariaLabel?: string; + ariaLabelledBy?: string; + ariaActiveDescendant: string; + extra?: any; + placeholderComponent?: string | ComponentLike; + selectedItemComponent?: string | ComponentLike; + onInput?: (e: InputEvent) => boolean; + onKeydown?: (e: KeyboardEvent) => boolean; + onFocus?: (e: FocusEvent) => void; + onBlur?: (e: FocusEvent) => void; + buildSelection: (lastSelection: any, select: Select) => any[]; + }; Blocks: { default: [opt: any, select: Select]; }; } + interface IndexAccesible { objectAt(index: number): T; } @@ -35,7 +39,7 @@ const isIndexAccesible = (target: any): target is IndexAccesible => { return typeof target.objectAt === 'function'; }; -export default class TriggerComponent extends Component { +export default class TriggerComponent extends Component { private _lastIsOpen: boolean = this.args.select.isOpen; // Actions diff --git a/ember-power-select/src/components/power-select/before-options.ts b/ember-power-select/src/components/power-select/before-options.ts index a01383ecb..fc760c335 100644 --- a/ember-power-select/src/components/power-select/before-options.ts +++ b/ember-power-select/src/components/power-select/before-options.ts @@ -3,22 +3,25 @@ import { scheduleOnce, later } from '@ember/runloop'; import { action } from '@ember/object'; import type { Select } from '../power-select'; -interface Args { - select: Select; - searchEnabled: boolean; - ariaLabel?: string; - ariaLabelledBy?: string; - searchPlaceholder?: string; - ariaActiveDescendant?: string; - listboxId?: string; - onKeydown: (e: KeyboardEvent) => false | void; - onBlur: (e: FocusEvent) => void; - onFocus: (e: FocusEvent) => void; - onInput: (e: InputEvent) => boolean; - autofocus?: boolean; +interface PowerSelectBeforeOptionsSignature { + Element: HTMLElement; + Args: { + select: Select; + searchEnabled: boolean; + ariaLabel?: string; + ariaLabelledBy?: string; + searchPlaceholder?: string; + ariaActiveDescendant?: string; + listboxId?: string; + onKeydown: (e: KeyboardEvent) => false | void; + onBlur: (e: FocusEvent) => void; + onFocus: (e: FocusEvent) => void; + onInput: (e: InputEvent) => boolean; + autofocus?: boolean; + }; } -export default class BeforeOptionsComponent extends Component { +export default class PowerSelectBeforeOptionsComponent extends Component { @action clearSearch(): void { scheduleOnce('actions', this.args.select.actions, 'search', ''); diff --git a/ember-power-select/src/components/power-select/no-matches-message.ts b/ember-power-select/src/components/power-select/no-matches-message.ts index 173f371d9..fffdccf1c 100644 --- a/ember-power-select/src/components/power-select/no-matches-message.ts +++ b/ember-power-select/src/components/power-select/no-matches-message.ts @@ -1,7 +1,10 @@ import Component from '@glimmer/component'; -interface Args { - noMatchesMessage: any; +interface PowerSelectNoMatchesMessageSignature { + Element: HTMLElement; + Args: { + noMatchesMessage: any; + }; } -export default class NoMatchesMessageComponent extends Component {} +export default class PowerSelectNoMatchesMessageComponent extends Component {} diff --git a/ember-power-select/src/components/power-select/options.ts b/ember-power-select/src/components/power-select/options.ts index 7748c02f9..52c30a6de 100644 --- a/ember-power-select/src/components/power-select/options.ts +++ b/ember-power-select/src/components/power-select/options.ts @@ -4,8 +4,15 @@ import type { Select } from '../power-select'; import type { ComponentLike } from '@glint/template'; declare const FastBoot: any; -interface Args { +interface PowerSelectOptionsSignature { Element: HTMLElement; + Args: PowerSelectOptionsArgs; + Blocks: { + default: [opt: PowerSelectOptionsArgs, select: Select]; + }; +} + +interface PowerSelectOptionsArgs { select: Select; highlightOnHover?: boolean; groupIndex: string; @@ -14,9 +21,6 @@ interface Args { extra: any; groupComponent?: string | ComponentLike; optionsComponent?: string | ComponentLike; - Blocks: { - default: [opt: Args, select: Select]; - }; } const isTouchDevice = !!window && 'ontouchstart' in window; @@ -45,7 +49,7 @@ if (typeof FastBoot === 'undefined') { })(window.Element.prototype); } -export default class OptionsComponent extends Component { +export default class PowerSelectOptionsComponent extends Component { private isTouchDevice = this.args.extra?._isTouchDevice || isTouchDevice; private touchMoveEvent?: TouchEvent; private mouseOverHandler: EventListener = (( diff --git a/ember-power-select/src/components/power-select/placeholder.ts b/ember-power-select/src/components/power-select/placeholder.ts index bad3772b7..da13f2260 100644 --- a/ember-power-select/src/components/power-select/placeholder.ts +++ b/ember-power-select/src/components/power-select/placeholder.ts @@ -1,10 +1,12 @@ -import Component from '@glimmer/component'; +import Component from '@glimmer/component'; -interface Args { +interface PowerSelectPlaceholderSignature { Element: HTMLElement; - isMultipleWithSearch: boolean; - placeholder: any; - inputComponent?: any; + Args: { + isMultipleWithSearch: boolean; + placeholder: any; + inputComponent?: any; + }; } -export default class PlaceholderComponent extends Component {} +export default class PowerSelectPlaceholderComponent extends Component {} diff --git a/ember-power-select/src/components/power-select/power-select-group.ts b/ember-power-select/src/components/power-select/power-select-group.ts index 458aadc47..5624421ab 100644 --- a/ember-power-select/src/components/power-select/power-select-group.ts +++ b/ember-power-select/src/components/power-select/power-select-group.ts @@ -1,10 +1,13 @@ import Component from '@glimmer/component'; -interface Args { - group: any; +interface PowerSelectPowerSelectGroupSignature { + Element: HTMLElement; + Args: { + group: any; + }; Blocks: { default: []; }; } -export default class PowerSelectGroupComponent extends Component {} +export default class PowerSelectPowerSelectGroupComponent extends Component {} diff --git a/ember-power-select/src/components/power-select/search-message.ts b/ember-power-select/src/components/power-select/search-message.ts index 4a4e05095..9733d8961 100644 --- a/ember-power-select/src/components/power-select/search-message.ts +++ b/ember-power-select/src/components/power-select/search-message.ts @@ -1,8 +1,10 @@ import Component from '@glimmer/component'; -interface Args { +interface PowerSelectSearchMessageSignature { Element: HTMLElement; - searchMessage: string; + Args: { + searchMessage: string; + }; } -export default class SearchMessageComponent extends Component {} +export default class PowerSelectSearchMessageComponent extends Component {} diff --git a/ember-power-select/src/components/power-select/trigger.ts b/ember-power-select/src/components/power-select/trigger.ts index dd718ee3c..0934361a1 100644 --- a/ember-power-select/src/components/power-select/trigger.ts +++ b/ember-power-select/src/components/power-select/trigger.ts @@ -3,19 +3,22 @@ import { action } from '@ember/object'; import type { Select } from '../power-select'; import type { ComponentLike } from '@glint/template'; -interface Args { - select: Select; - allowClear: boolean; - extra: any; - placeholder?: string; - placeholderComponent?: string | ComponentLike; - selectedItemComponent?: string | ComponentLike; +interface PowerSelectTriggerSignature { + Element: HTMLElement; + Args: { + select: Select; + allowClear: boolean; + extra: any; + placeholder?: string; + placeholderComponent?: string | ComponentLike; + selectedItemComponent?: string | ComponentLike; + }; Blocks: { default: [selected: any, select: Select]; }; } -export default class TriggerComponent extends Component { +export default class PowerSelectTriggerComponent extends Component { @action clear(e: Event): false | void { e.stopPropagation();