Skip to content

Commit 2b0fe93

Browse files
committed
lint fix
1 parent cc8fa65 commit 2b0fe93

File tree

10 files changed

+38
-28
lines changed

10 files changed

+38
-28
lines changed

.eslintrc.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ module.exports = {
1818
'max-len': ['error', 180],
1919
'no-trailing-spaces': 'error',
2020
'prefer-const': 0,
21-
'@typescript-eslint/explicit-function-return-type': 0,
22-
'@typescript-eslint/ban-ts-comment': 0
21+
'@typescript-eslint/ban-ts-comment': 0,
2322
}
2423
};

src/dd-draggable.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,18 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
155155
this.dragEl.addEventListener('touchmove', touchmove);
156156
this.dragEl.addEventListener('touchend', touchend);
157157
}
158-
158+
159159
e.preventDefault();
160160
// preventDefault() prevents blur event which occurs just after mousedown event.
161-
// if an editable content has focus, then blur must be call
161+
// if an editable content has focus, then blur must be call
162162
if(document.activeElement) (document.activeElement as HTMLElement).blur();
163163

164164
DDManager.mouseHandled = true;
165165
return true;
166166
}
167167

168168
/** @internal method to call actual drag event */
169-
protected _callDrag(e: DragEvent) {
169+
protected _callDrag(e: DragEvent): void {
170170
if (!this.dragging) return;
171171
const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'drag' });
172172
if (this.option.drag) {

src/dd-droppable.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ import { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';
99
import { Utils } from './utils';
1010
import { DDElementHost } from './dd-element';
1111
import { isTouch, pointerenter, pointerleave } from './dd-touch';
12+
import { DDUIData } from './types';
1213

1314
export interface DDDroppableOpt {
1415
accept?: string | ((el: HTMLElement) => boolean);
15-
drop?: (event: DragEvent, ui) => void;
16-
over?: (event: DragEvent, ui) => void;
17-
out?: (event: DragEvent, ui) => void;
16+
drop?: (event: DragEvent, ui: DDUIData) => void;
17+
over?: (event: DragEvent, ui: DDUIData) => void;
18+
out?: (event: DragEvent, ui: DDUIData) => void;
1819
}
1920

2021
// let count = 0; // TEST
@@ -163,7 +164,7 @@ export class DDDroppable extends DDBaseImplement implements HTMLElementExtendOpt
163164
}
164165

165166
/** @internal */
166-
protected _ui(drag: DDDraggable) {
167+
protected _ui(drag: DDDraggable): DDUIData {
167168
return {
168169
draggable: drag.el,
169170
...drag.ui()

src/dd-resizable-handle.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class DDResizableHandle {
7272
}
7373

7474
/** @internal called on mouse down on us: capture move on the entire document (mouse might not stay on us) until we release the mouse */
75-
protected _mouseDown(e: MouseEvent) {
75+
protected _mouseDown(e: MouseEvent): void {
7676
this.mouseDownEvent = e;
7777
document.addEventListener('mousemove', this._mouseMove, true); // capture, not bubble
7878
document.addEventListener('mouseup', this._mouseUp, true);
@@ -85,7 +85,7 @@ export class DDResizableHandle {
8585
}
8686

8787
/** @internal */
88-
protected _mouseMove(e: MouseEvent) {
88+
protected _mouseMove(e: MouseEvent): void {
8989
let s = this.mouseDownEvent;
9090
if (this.moving) {
9191
this._triggerEvent('move', e);
@@ -100,7 +100,7 @@ export class DDResizableHandle {
100100
}
101101

102102
/** @internal */
103-
protected _mouseUp(e: MouseEvent) {
103+
protected _mouseUp(e: MouseEvent): void {
104104
if (this.moving) {
105105
this._triggerEvent('stop', e);
106106
}

src/dd-resizable.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
126126
}
127127

128128
/** @internal */
129-
protected _mouseOver(e: Event) {
129+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
130+
protected _mouseOver(e: Event): void {
130131
// console.log(`${count++} pre-enter ${(this.el as GridItemHTMLElement).gridstackNode._id}`)
131132
// already over a child, ignore. Ideally we just call e.stopPropagation() but see https://github.com/gridstack/gridstack.js/issues/2018
132133
if (DDManager.overResizeElement || DDManager.dragElement) return;
@@ -136,7 +137,8 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
136137
}
137138

138139
/** @internal */
139-
protected _mouseOut(e: Event) {
140+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
141+
protected _mouseOut(e: Event): void {
140142
// console.log(`${count++} pre-leave ${(this.el as GridItemHTMLElement).gridstackNode._id}`)
141143
if (DDManager.overResizeElement !== this) return;
142144
delete DDManager.overResizeElement;

src/dd-touch.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ export const isTouch: boolean = typeof window !== 'undefined' && typeof document
1414
( 'ontouchstart' in document
1515
|| 'ontouchstart' in window
1616
// || !!window.TouchEvent // true on Windows 10 Chrome desktop so don't use this
17+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1718
|| ((window as any).DocumentTouch && document instanceof (window as any).DocumentTouch)
1819
|| navigator.maxTouchPoints > 0
20+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1921
|| (navigator as any).msMaxTouchPoints > 0
2022
);
2123

@@ -114,7 +116,7 @@ function simulatePointerMouseEvent(e: PointerEvent, simulatedType: string) {
114116
* Handle the touchstart events
115117
* @param {Object} e The widget element's touchstart event
116118
*/
117-
export function touchstart(e: TouchEvent) {
119+
export function touchstart(e: TouchEvent): void {
118120
// Ignore the event if another widget is already being handled
119121
if (DDTouch.touchHandled) return; DDTouch.touchHandled = true;
120122

@@ -128,7 +130,7 @@ export function touchstart(e: TouchEvent) {
128130
* Handle the touchmove events
129131
* @param {Object} e The document's touchmove event
130132
*/
131-
export function touchmove(e: TouchEvent) {
133+
export function touchmove(e: TouchEvent): void {
132134
// Ignore event if not handled by us
133135
if (!DDTouch.touchHandled) return;
134136

@@ -139,7 +141,7 @@ export function touchmove(e: TouchEvent) {
139141
* Handle the touchend events
140142
* @param {Object} e The document's touchend event
141143
*/
142-
export function touchend(e: TouchEvent) {
144+
export function touchend(e: TouchEvent): void {
143145

144146
// Ignore event if not handled
145147
if (!DDTouch.touchHandled) return;
@@ -170,11 +172,11 @@ export function touchend(e: TouchEvent) {
170172
* see https://stackoverflow.com/questions/27908339/js-touch-equivalent-for-mouseenter
171173
* so instead of PointerEvent to still get enter/leave and send the matching mouse event.
172174
*/
173-
export function pointerdown(e: PointerEvent) {
175+
export function pointerdown(e: PointerEvent): void {
174176
(e.target as HTMLElement).releasePointerCapture(e.pointerId) // <- Important!
175177
}
176178

177-
export function pointerenter(e: PointerEvent) {
179+
export function pointerenter(e: PointerEvent): void {
178180
// ignore the initial one we get on pointerdown on ourself
179181
if (!DDManager.dragElement) {
180182
// console.log('pointerenter ignored');
@@ -184,7 +186,7 @@ export function pointerenter(e: PointerEvent) {
184186
simulatePointerMouseEvent(e, 'mouseenter');
185187
}
186188

187-
export function pointerleave(e: PointerEvent) {
189+
export function pointerleave(e: PointerEvent): void {
188190
// ignore the leave on ourself we get before releasing the mouse over ourself
189191
// by delaying sending the event and having the up event cancel us
190192
if (!DDManager.dragElement) {

src/gridstack-engine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import { Utils } from './utils';
7-
import { GridStackNode, ColumnOptions, GridStackPosition, GridStackMoveOpts, GridStackOptions } from './types';
7+
import { GridStackNode, ColumnOptions, GridStackPosition, GridStackMoveOpts } from './types';
88

99
/** callback to update the DOM attributes since this class is generic (no HTML or other info) for items that changed - see _notify() */
1010
type OnChangeCB = (nodes: GridStackNode[]) => void;

src/gridstack.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ interface GridCSSStyleSheet extends CSSStyleSheet {
4141
_max?: number; // internal tracker of the max # of rows we created
4242
}
4343

44+
// extend with internal fields we need - TODO: move other items in here
45+
interface InternalGridStackOptions extends GridStackOptions {
46+
_alwaysShowResizeHandle?: true | false | 'mobile'; // so we can restore for save
47+
}
48+
4449
/**
4550
* Main gridstack class - you will need to call `GridStack.init()` first to initialize your grid.
4651
* Note: your grid elements MUST have the following classes for the CSS layout to work:
@@ -141,7 +146,7 @@ export class GridStack {
141146
* See instead `GridStackOptions.engineClass` if you only need to
142147
* replace just one instance.
143148
*/
144-
static registerEngine(engineClass: typeof GridStackEngine) {
149+
static registerEngine(engineClass: typeof GridStackEngine): void {
145150
GridStack.engineClass = engineClass;
146151
}
147152

@@ -237,7 +242,7 @@ export class GridStack {
237242
}
238243
// save original setting so we can restore on save
239244
if (opts.alwaysShowResizeHandle !== undefined) {
240-
(opts as any)._alwaysShowResizeHandle = opts.alwaysShowResizeHandle;
245+
(opts as InternalGridStackOptions)._alwaysShowResizeHandle = opts.alwaysShowResizeHandle;
241246
}
242247

243248
// elements DOM attributes override any passed options (like CSS style) - merge the two together
@@ -575,7 +580,7 @@ export class GridStack {
575580

576581
// check if save entire grid options (needed for recursive) + children...
577582
if (saveGridOpt) {
578-
let o: GridStackOptions = Utils.cloneDeep(this.opts);
583+
let o: InternalGridStackOptions = Utils.cloneDeep(this.opts);
579584
// delete default values that will be recreated on launch
580585
if (o.marginBottom === o.marginTop && o.marginRight === o.marginLeft && o.marginTop === o.marginRight) {
581586
o.margin = o.marginTop;
@@ -589,8 +594,8 @@ export class GridStack {
589594
o.column = 'auto';
590595
delete o.disableOneColumnMode;
591596
}
592-
const origShow = (o as any)._alwaysShowResizeHandle;
593-
delete (o as any)._alwaysShowResizeHandle;
597+
const origShow = o._alwaysShowResizeHandle;
598+
delete o._alwaysShowResizeHandle;
594599
if (origShow !== undefined) {
595600
o.alwaysShowResizeHandle = origShow;
596601
} else {

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ export interface Rect extends Size, Position {}
361361
export interface DDUIData {
362362
position?: Position;
363363
size?: Size;
364+
draggable?: HTMLElement;
364365
/* fields not used by GridStack but sent by jq ? leave in case we go back to them...
365366
originalPosition? : Position;
366367
offset?: Position;

src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export class Utils {
273273
}
274274

275275
/** removes internal fields '_' and default values for saving */
276-
static removeInternalForSave(n: GridStackNode, removeEl = true) {
276+
static removeInternalForSave(n: GridStackNode, removeEl = true): void {
277277
for (let key in n) { if (key[0] === '_' || n[key] === null || n[key] === undefined ) delete n[key]; }
278278
delete n.grid;
279279
if (removeEl) delete n.el;
@@ -496,7 +496,7 @@ export class Utils {
496496
}
497497

498498
/** copies the MouseEvent properties and sends it as another event to the given target */
499-
public static simulateMouseEvent(e: MouseEvent, simulatedType: string, target?: EventTarget) {
499+
public static simulateMouseEvent(e: MouseEvent, simulatedType: string, target?: EventTarget): void {
500500
const simulatedEvent = document.createEvent('MouseEvents');
501501
simulatedEvent.initMouseEvent(
502502
simulatedType, // type

0 commit comments

Comments
 (0)