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

chore(types): fix the types of sensors #499

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
18 changes: 13 additions & 5 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ declare module '@shopify/draggable/lib/es5/draggable.bundle.legacy' {
export * from '@shopify/draggable';
}

declare module '@shopify/draggable/esm/Draggable/Sensors' {
export {
Sensor,
DragSensor,
ForceTouchSensor,
MouseSensor,
TouchSensor,
} from '@shopify/draggable';
}

declare module '@shopify/draggable' {
abstract class AbstractEvent<DataT = { [key: string]: any }> {
constructor(data: DataT);
Expand Down Expand Up @@ -181,7 +191,7 @@ declare module '@shopify/draggable' {
handle?: string | NodeList | HTMLElement[] | HTMLElement | ((currentElement: HTMLElement) => HTMLElement);
delay?: number | DelayOptions;
plugins?: Array<typeof AbstractPlugin>;
sensors?: Sensor[];
sensors?: Array<typeof Sensor>;
classes?: { [key in DraggableClassNames]: string | string[] };
announcements?: AnnouncementOptions;
collidables?: Collidables;
Expand Down Expand Up @@ -338,6 +348,8 @@ declare module '@shopify/draggable' {
delay?: number | DelayOptions;
}

export * as Sensors from '@shopify/draggable/esm/Draggable/Sensors'

export class Sensor {
constructor(containers: HTMLElement | HTMLElement[] | NodeList, options?: SensorOptions);
attach(): this;
Expand All @@ -347,10 +359,6 @@ declare module '@shopify/draggable' {
trigger(element: HTMLElement, sensorEvent: SensorEvent): SensorEvent;
}

export interface Sensors {
DragSensor: typeof DragSensor;
}

export class DragSensor extends Sensor { }

export class ForceTouchSensor extends Sensor { }
Expand Down