Skip to content

Commit

Permalink
Merge pull request #59 from Gavant/update-power-select-types
Browse files Browse the repository at this point in the history
Update power select types
  • Loading branch information
napafundi authored Nov 8, 2022
2 parents 0655195 + ad4a563 commit e73817d
Show file tree
Hide file tree
Showing 24 changed files with 386 additions and 722 deletions.
240 changes: 120 additions & 120 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@types/ember__template": "^4.0.0",
"auto-changelog": "^2.4.0",
"ember-animated": "^1.0.0",
"ember-basic-dropdown": "^6.0.0",
"ember-basic-dropdown": "^6.0.1",
"ember-concurrency": "^2.0.3",
"ember-concurrency-async": "^1.0.0",
"ember-concurrency-ts": "^0.3.0",
Expand Down
9 changes: 0 additions & 9 deletions types/@gavant/ember-power-select-infinity/options.d.ts

This file was deleted.

134 changes: 0 additions & 134 deletions types/@gavant/ember-power-select-infinity/power-select-infinity.d.ts

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import Component from '@glimmer/component';

import { Dropdown } from 'ember-basic-dropdown/addon/components/basic-dropdown';
import { Dropdown, RepositionChanges } from './basic-dropdown';

export interface DropdownContentArgs {
interface Args {
transitioningInClass?: string;
transitionedInClass?: string;
transitioningOutClass?: string;
isTouchDevice?: boolean;
destination: string;
dropdown: Dropdown;
hPosition: string;
vPosition: string;
renderInPlace: boolean;
preventScroll?: boolean;
rootEventType: 'click' | 'mousedown';
Expand All @@ -24,16 +22,18 @@ export interface DropdownContentArgs {
onFocusOut?: (dropdown?: Dropdown, event?: FocusEvent) => void;
onMouseEnter?: (dropdown?: Dropdown, event?: MouseEvent) => void;
onMouseLeave?: (dropdown?: Dropdown, event?: MouseEvent) => void;
shouldReposition?: (mutations: MutationRecord[], dropdown: Dropdown) => boolean;
shouldReposition: (mutations: MutationRecord[], dropdown: Dropdown) => boolean;
hPosition: RepositionChanges['hPosition'];
vPosition: RepositionChanges['vPosition'];
}
type RootMouseDownHandler = (ev: MouseEvent | TouchEvent) => void;

export interface DropdownContentSignature {
Element: HTMLElement;
Args: DropdownContentArgs;
Args: Args;
Blocks: {
default?: [];
};
}

export class DropdownContent extends Component<DropdownContentSignature> {}
export default DropdownContent;
export default class BasicDropdownContent extends Component<DropdownContentSignature> {}
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import Component from '@glimmer/component';

import { Dropdown } from 'ember-basic-dropdown/addon/components/basic-dropdown';
import { Dropdown, RepositionChanges } from './basic-dropdown';

export interface DropdownTriggerArgs {
interface Args {
dropdown: Dropdown;
eventType: 'click' | 'mousedown';
stopPropagation: boolean;
hPosition: string;
renderInPlace: boolean;
vPosition: string;
htmlTag?: string;
onBlur?: (dropdown?: Dropdown, event?: FocusEvent) => void;
onClick?: (dropdown?: Dropdown, event?: MouseEvent) => void;
onFocus?: (dropdown?: Dropdown, event?: FocusEvent) => void;
Expand All @@ -20,15 +16,17 @@ export interface DropdownTriggerArgs {
onMouseEnter?: (dropdown?: Dropdown, event?: MouseEvent) => void;
onMouseLeave?: (dropdown?: Dropdown, event?: MouseEvent) => void;
onTouchEnd?: (dropdown?: Dropdown, event?: TouchEvent) => void;
hPosition: RepositionChanges['hPosition'];
vPosition: RepositionChanges['vPosition'];
renderInPlace: boolean;
}

export interface DropdownTriggerSignature {
Element: HTMLElement;
Args: DropdownTriggerArgs;
Args: Args;
Blocks: {
default: [];
};
}

export class DropdownTrigger extends Component<DropdownTriggerSignature> {}
export default DropdownTrigger;
export default class BasicDropdownTrigger extends Component<DropdownTriggerSignature> {}
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
import { action } from '@ember/object';
import Component from '@glimmer/component';

import { DropdownActions } from 'ember-basic-dropdown/addon/components/basic-dropdown';
import { CalculatePosition } from 'ember-basic-dropdown/addon/utils/calculate-position';
import { WithBoundArgs } from '@glint/template';

import { DropdownContent } from '@gavant/glint-template-types/types/ember-basic-dropdown/content';
import { DropdownTrigger } from '@gavant/glint-template-types/types/ember-basic-dropdown/trigger';
import { CalculatePosition } from '../utils/calculate-position';
import DropdownContent from './basic-dropdown-content';
import DropdownTrigger from './basic-dropdown-trigger';

import { WithBoundArgs } from '@glint/template';
export interface DropdownActions {
toggle: (e?: Event) => void;
close: (e?: Event, skipFocus?: boolean) => void;
open: (e?: Event) => void;
reposition: (...args: any[]) => undefined | RepositionChanges;
}
export interface Dropdown {
uniqueId: string;
disabled: boolean;
isOpen: boolean;
actions: DropdownActions;
}

export interface DropdownArgs {
interface Args {
initiallyOpened?: boolean;
renderInPlace?: boolean;
verticalPosition?: string;
Expand All @@ -24,9 +36,20 @@ export interface DropdownArgs {
calculatePosition?: CalculatePosition;
}

export interface DropdownSignature {
type RepositionChanges = {
hPosition: string;
vPosition: string;
otherStyles: Record<string, string | number | undefined>;
top?: string;
left?: string;
right?: string;
width?: string;
height?: string;
};

export interface BasicDropdownSignature {
Element: HTMLDivElement;
Args: DropdownArgs;
Args: Args;
Blocks: {
default: [
{
Expand Down Expand Up @@ -59,5 +82,4 @@ export interface DropdownSignature {
};
}

export class Dropdown extends Component<DropdownSignature> {}
export default Dropdown;
export default class BasicDropdown extends Component<BasicDropdownSignature> {}
28 changes: 28 additions & 0 deletions types/ember-basic-dropdown/utils/calculate-position.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
interface CalculatePositionOptions {
horizontalPosition: string;
verticalPosition: string;
matchTriggerWidth: boolean;
previousHorizontalPosition?: string;
previousVerticalPosition?: string;
renderInPlace: boolean;
dropdown: any;
}
export type CalculatePositionResultStyle = {
top?: number;
left?: number;
right?: number;
width?: number;
height?: number;
[key: string]: string | number | undefined;
};
export type CalculatePositionResult = {
horizontalPosition: string;
verticalPosition: string;
style: CalculatePositionResultStyle;
};
export type CalculatePosition = (
trigger: Element,
content: HTMLElement,
destination: HTMLElement,
options: CalculatePositionOptions
) => CalculatePositionResult;
Loading

0 comments on commit e73817d

Please sign in to comment.