Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix types #1634

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions ember-power-select/src/components/power-select-multiple/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Args> {
export default class PowerSelectMultipleInputComponent extends Component<PowerSelectMultipleInputSignature> {
private inputFont?: string;

// Properties
Expand Down
42 changes: 23 additions & 19 deletions ember-power-select/src/components/power-select-multiple/trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,41 @@ 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<any>;
selectedItemComponent?: string | ComponentLike<any>;
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<any>;
selectedItemComponent?: string | ComponentLike<any>;
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<T> {
objectAt(index: number): T;
}
const isIndexAccesible = <T>(target: any): target is IndexAccesible<T> => {
return typeof target.objectAt === 'function';
};

export default class TriggerComponent extends Component<Args> {
export default class TriggerComponent extends Component<PowerSelectMultipleTriggerSignature> {
private _lastIsOpen: boolean = this.args.select.isOpen;

// Actions
Expand Down
31 changes: 17 additions & 14 deletions ember-power-select/src/components/power-select/before-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Args> {
export default class PowerSelectBeforeOptionsComponent extends Component<PowerSelectBeforeOptionsSignature> {
@action
clearSearch(): void {
scheduleOnce('actions', this.args.select.actions, 'search', '');
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Args> {}
export default class PowerSelectNoMatchesMessageComponent extends Component<PowerSelectNoMatchesMessageSignature> {}
14 changes: 9 additions & 5 deletions ember-power-select/src/components/power-select/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -14,9 +21,6 @@ interface Args {
extra: any;
groupComponent?: string | ComponentLike<any>;
optionsComponent?: string | ComponentLike<any>;
Blocks: {
default: [opt: Args, select: Select];
};
}

const isTouchDevice = !!window && 'ontouchstart' in window;
Expand Down Expand Up @@ -45,7 +49,7 @@ if (typeof FastBoot === 'undefined') {
})(window.Element.prototype);
}

export default class OptionsComponent extends Component<Args> {
export default class PowerSelectOptionsComponent extends Component<PowerSelectOptionsSignature> {
private isTouchDevice = this.args.extra?._isTouchDevice || isTouchDevice;
private touchMoveEvent?: TouchEvent;
private mouseOverHandler: EventListener = ((
Expand Down
14 changes: 8 additions & 6 deletions ember-power-select/src/components/power-select/placeholder.ts
Original file line number Diff line number Diff line change
@@ -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<Args> {}
export default class PowerSelectPlaceholderComponent extends Component<PowerSelectPlaceholderSignature> {}
Original file line number Diff line number Diff line change
@@ -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<Args> {}
export default class PowerSelectPowerSelectGroupComponent extends Component<PowerSelectPowerSelectGroupSignature> {}
Original file line number Diff line number Diff line change
@@ -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<Args> {}
export default class PowerSelectSearchMessageComponent extends Component<PowerSelectSearchMessageSignature> {}
19 changes: 11 additions & 8 deletions ember-power-select/src/components/power-select/trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>;
selectedItemComponent?: string | ComponentLike<any>;
interface PowerSelectTriggerSignature {
Element: HTMLElement;
Args: {
select: Select;
allowClear: boolean;
extra: any;
placeholder?: string;
placeholderComponent?: string | ComponentLike<any>;
selectedItemComponent?: string | ComponentLike<any>;
};
Blocks: {
default: [selected: any, select: Select];
};
}

export default class TriggerComponent extends Component<Args> {
export default class PowerSelectTriggerComponent extends Component<PowerSelectTriggerSignature> {
@action
clear(e: Event): false | void {
e.stopPropagation();
Expand Down