Skip to content

Commit

Permalink
Convert DroppableEvent to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
tsov committed Oct 4, 2023
1 parent 7734961 commit a0c3c90
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-clouds-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/draggable': patch
---

Convert DroppableEvent to typescript
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
import AbstractEvent from 'shared/AbstractEvent';

import {DragEvent, DragEventData} from '../../Draggable/DragEvent';

interface DroppableEventData {
dragEvent: DragEvent<DragEventData>;
}

/**
* Base droppable event
* @class DroppableEvent
* @module DroppableEvent
* @extends AbstractEvent
*/
export class DroppableEvent extends AbstractEvent {
export class DroppableEvent<
T extends DroppableEventData,
> extends AbstractEvent<DroppableEventData> {
static type = 'droppable';

/**
* DroppableEvent constructor.
* @constructs DroppableEvent
* @param {DroppableEventData} data - Event data
*/
constructor(public data: T) {
super(data);
}

/**
* Original drag event that triggered this droppable event
* @property dragEvent
Expand All @@ -20,13 +37,17 @@ export class DroppableEvent extends AbstractEvent {
}
}

interface DroppableStartEventData extends DroppableEventData {
dropzone: HTMLElement;
}

/**
* Droppable start event
* @class DroppableStartEvent
* @module DroppableStartEvent
* @extends DroppableEvent
*/
export class DroppableStartEvent extends DroppableEvent {
export class DroppableStartEvent extends DroppableEvent<DroppableStartEventData> {
static type = 'droppable:start';
static cancelable = true;

Expand All @@ -41,13 +62,17 @@ export class DroppableStartEvent extends DroppableEvent {
}
}

interface DroppableDroppedEventData extends DroppableEventData {
dropzone: HTMLElement;
}

/**
* Droppable dropped event
* @class DroppableDroppedEvent
* @module DroppableDroppedEvent
* @extends DroppableEvent
*/
export class DroppableDroppedEvent extends DroppableEvent {
export class DroppableDroppedEvent extends DroppableEvent<DroppableDroppedEventData> {
static type = 'droppable:dropped';
static cancelable = true;

Expand All @@ -62,13 +87,17 @@ export class DroppableDroppedEvent extends DroppableEvent {
}
}

interface DroppableReturnedEventData extends DroppableEventData {
dropzone: HTMLElement;
}

/**
* Droppable returned event
* @class DroppableReturnedEvent
* @module DroppableReturnedEvent
* @extends DroppableEvent
*/
export class DroppableReturnedEvent extends DroppableEvent {
export class DroppableReturnedEvent extends DroppableEvent<DroppableReturnedEventData> {
static type = 'droppable:returned';
static cancelable = true;

Expand All @@ -83,13 +112,17 @@ export class DroppableReturnedEvent extends DroppableEvent {
}
}

interface DroppableStopEventData extends DroppableEventData {
dropzone: HTMLElement;
}

/**
* Droppable stop event
* @class DroppableStopEvent
* @module DroppableStopEvent
* @extends DroppableEvent
*/
export class DroppableStopEvent extends DroppableEvent {
export class DroppableStopEvent extends DroppableEvent<DroppableStopEventData> {
static type = 'droppable:stop';
static cancelable = true;

Expand Down
File renamed without changes.

0 comments on commit a0c3c90

Please sign in to comment.