Skip to content

Commit a989dbb

Browse files
committed
Initial pass at compiling Hypergrid JS files with TypeScript
1 parent 1ee24aa commit a989dbb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+822
-424
lines changed

css/index.js

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
11
'use strict';
22

3-
exports.grid = [
4-
'.hypergrid-container {',
5-
' position: relative;',
6-
' height: 500px;',
7-
'}',
8-
'.hypergrid-container > div:first-child {',
9-
' position: absolute;',
10-
' left: 0;',
11-
' top: 0;',
12-
' right: 0;',
13-
' bottom: 0;',
14-
'}',
15-
'.hypergrid-container > div:first-child > div.info {',
16-
' position: absolute;',
17-
' display: none; /* initially hidden */',
18-
' margin-top: 150px; /* to place below headers */',
19-
' color: #eee;',
20-
' text-shadow: 1px 1px #ccc;',
21-
' font-size: 36pt;',
22-
' font-weight: bold;',
23-
' text-align: center;',
24-
' top: 0; right: 0; bottom: 0; left: 0;',
25-
'}',
26-
'.hypergrid-textfield {',
27-
' position: absolute;',
28-
' font-size: 12px;',
29-
' color: black;',
30-
' background-color: ivory;',
31-
' box-sizing: border-box;',
32-
' margin: 0;',
33-
' padding: 0 5px;',
34-
' border: 0; /*border: 1px solid #777;*/',
35-
' outline: 0;',
36-
'}',
37-
'',
38-
'.hypergrid {',
39-
' touch-action: none;',
40-
'}'
41-
].join('\n');
3+
exports.grid = `
4+
.hypergrid-container {
5+
position: relative;
6+
height: 500px;
7+
}
8+
.hypergrid-container > div:first-child {
9+
position: absolute;
10+
left: 0;
11+
top: 0;
12+
right: 0;
13+
bottom: 0;
14+
}
15+
.hypergrid-container > div:first-child > div.info {
16+
position: absolute;
17+
display: none; /* initially hidden */
18+
margin-top: 150px; /* to place below headers */
19+
color: #eee;
20+
text-shadow: 1px 1px #ccc;
21+
font-size: 36pt;
22+
font-weight: bold;
23+
text-align: center;
24+
top: 0; right: 0; bottom: 0; left: 0;
25+
}
26+
.hypergrid-textfield {
27+
position: absolute;
28+
font-size: 12px;
29+
color: black;
30+
background-color: ivory;
31+
box-sizing: border-box;
32+
margin: 0;
33+
padding: 0 5px;
34+
border: 0; /*border: 1px solid #777;*/
35+
outline: 0;
36+
}
37+
38+
.hypergrid {
39+
touch-action: none;
40+
}`;

images/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-nocheck
12
/* eslint-env browser */
23

34
/**

src/Base.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* globals alert */
22

3-
'use strict';
43

54
/**
65
* @constructor

src/Hypergrid/events.js

Lines changed: 41 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* eslint-env browser */
22

3-
'use strict';
43

54
var dispatchGridEvent = require('../lib/dispatchGridEvent');
65
var Button = require('../cellRenderers/Button');
@@ -96,6 +95,10 @@ exports.mixin = {
9695
}, this);
9796
},
9897

98+
/**
99+
* @param {boolean} allow
100+
* @this {any}
101+
*/
99102
allowEvents: function(allow){
100103
this.allowEventHandlers = !!allow;
101104

@@ -206,7 +209,7 @@ exports.mixin = {
206209
/**
207210
* @memberOf Hypergrid#
208211
* @desc Synthesize and fire a `fin-context-menu` event
209-
* @param {keyEvent} event - The canvas event.
212+
* @param {KeyboardEvent} event - The canvas event.
210213
* @returns {boolean} Proceed; event was not [canceled](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent#Return_Value `EventTarget.dispatchEvent`).
211214
*/
212215
fireSyntheticContextMenuEvent: function(event) {
@@ -419,7 +422,7 @@ exports.mixin = {
419422
* @desc Synthesize and fire a fin-request-cell-edit event.
420423
*
421424
* This event is cancelable.
422-
* @param {CellEvent} cellEvent
425+
* @param {unknown} cellEvent
423426
* @param {*} value
424427
* @returns {boolean} Proceed; event was not [canceled](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent#Return_Value `EventTarget.dispatchEvent`).
425428
*/
@@ -446,7 +449,6 @@ exports.mixin = {
446449

447450
/**
448451
* @memberOf Hypergrid#
449-
* @returns {Renderer} sub-component
450452
* @param {Point} cell - The x,y coordinates.
451453
* @param {Object} oldValue - The old value.
452454
* @param {Object} newValue - The new value.
@@ -533,121 +535,45 @@ exports.mixin = {
533535
return;
534536
}
535537

536-
handleMouseEvent(e, function(mouseEvent) {
537-
mouseEvent.keys = e.detail.keys;
538-
this.mouseDownState = mouseEvent;
539-
this.delegateMouseDown(mouseEvent);
540-
this.fireSyntheticMouseDownEvent(mouseEvent);
541-
this.repaint();
542-
});
538+
handleMouseEvent(e,
539+
/**
540+
* @this {any}
541+
* @param {any} mouseEvent
542+
*/
543+
function(mouseEvent) {
544+
mouseEvent.keys = e.detail.keys;
545+
this.mouseDownState = mouseEvent;
546+
this.delegateMouseDown(mouseEvent);
547+
this.fireSyntheticMouseDownEvent(mouseEvent);
548+
this.repaint();
549+
}
550+
);
543551
});
544552

545553
this.addInternalEventListener('fin-canvas-click', function(e) {
546554
if (grid.properties.readOnly) {
547555
return;
548556
}
549-
handleMouseEvent(e, function(mouseEvent) {
550-
var isMouseDownCell = this.mouseDownState && this.mouseDownState.gridCell.equals(mouseEvent.gridCell);
551-
if (isMouseDownCell && mouseEvent.mousePointInClickRect) {
552-
mouseEvent.keys = e.detail.keys; // todo: this was in fin-tap but wasn't here
553-
if (this.mouseDownState) {
554-
this.fireSyntheticButtonPressedEvent(this.mouseDownState);
557+
handleMouseEvent(e,
558+
/**
559+
* @this {any}
560+
* @param {{ gridCell: any; mousePointInClickRect: any; keys: any; }} mouseEvent
561+
*/
562+
function(mouseEvent) {
563+
var isMouseDownCell = this.mouseDownState && this.mouseDownState.gridCell.equals(mouseEvent.gridCell);
564+
if (isMouseDownCell && mouseEvent.mousePointInClickRect) {
565+
mouseEvent.keys = e.detail.keys; // todo: this was in fin-tap but wasn't here
566+
if (this.mouseDownState) {
567+
this.fireSyntheticButtonPressedEvent(this.mouseDownState);
568+
}
569+
this.fireSyntheticClickEvent(mouseEvent);
570+
this.delegateClick(mouseEvent);
555571
}
556-
this.fireSyntheticClickEvent(mouseEvent);
557-
this.delegateClick(mouseEvent);
572+
this.mouseDownState = null;
558573
}
559-
this.mouseDownState = null;
560-
});
561-
});
562-
563-
this.addInternalEventListener('fin-canvas-mouseup', function(e) {
564-
if (grid.properties.readOnly) {
565-
return;
566-
}
567-
grid.dragging = false;
568-
if (grid.isScrollingNow()) {
569-
grid.setScrollingNow(false);
570-
}
571-
if (grid.columnDragAutoScrolling) {
572-
grid.columnDragAutoScrolling = false;
573-
}
574-
handleMouseEvent(e, function(mouseEvent) {
575-
this.delegateMouseUp(mouseEvent);
576-
this.fireSyntheticMouseUpEvent(mouseEvent);
577-
});
578-
});
579-
580-
this.addInternalEventListener('fin-canvas-dblclick', function(e) {
581-
if (grid.properties.readOnly) {
582-
return;
583-
}
584-
handleMouseEvent(e, function(mouseEvent) {
585-
this.fireSyntheticDoubleClickEvent(mouseEvent, e);
586-
this.delegateDoubleClick(mouseEvent);
587-
});
588-
});
589-
590-
this.addInternalEventListener('fin-canvas-drag', function(e) {
591-
if (grid.properties.readOnly) {
592-
return;
593-
}
594-
grid.dragging = true;
595-
handleMouseEvent(e, grid.delegateMouseDrag);
574+
);
596575
});
597576

598-
this.addInternalEventListener('fin-canvas-keydown', function(e) {
599-
if (grid.properties.readOnly) {
600-
return;
601-
}
602-
grid.fireSyntheticKeydownEvent(e);
603-
grid.delegateKeyDown(e);
604-
});
605-
606-
this.addInternalEventListener('fin-canvas-keyup', function(e) {
607-
if (grid.properties.readOnly) {
608-
return;
609-
}
610-
grid.fireSyntheticKeyupEvent(e);
611-
grid.delegateKeyUp(e);
612-
});
613-
614-
this.addInternalEventListener('fin-canvas-wheelmoved', function(e) {
615-
handleMouseEvent(e, grid.delegateWheelMoved);
616-
});
617-
618-
this.addInternalEventListener('fin-canvas-mouseout', function(e) {
619-
if (grid.properties.readOnly) {
620-
return;
621-
}
622-
handleMouseEvent(e, grid.delegateMouseExit);
623-
});
624-
625-
this.addInternalEventListener('fin-canvas-context-menu', function(e) {
626-
handleMouseEvent(e, function(mouseEvent) {
627-
grid.delegateContextMenu(mouseEvent);
628-
grid.fireSyntheticContextMenuEvent(mouseEvent);
629-
});
630-
});
631-
632-
this.addInternalEventListener('fin-canvas-touchstart', function(e) {
633-
grid.delegateTouchStart(e);
634-
grid.fireSyntheticTouchStartEvent(e);
635-
});
636-
637-
this.addInternalEventListener('fin-canvas-touchmove', function(e) {
638-
grid.delegateTouchMove(e);
639-
grid.fireSyntheticTouchMoveEvent(e);
640-
});
641-
642-
this.addInternalEventListener('fin-canvas-touchend', function(e) {
643-
grid.delegateTouchEnd(e);
644-
grid.fireSyntheticTouchEndEvent(e);
645-
});
646-
647-
//Register a listener for the copy event so we can copy our selected region to the pastebuffer if conditions are right.
648-
document.body.addEventListener('copy', function(evt) {
649-
grid.checkClipboardCopy(evt);
650-
});
651577
},
652578

653579
/**
@@ -680,7 +606,7 @@ exports.mixin = {
680606
/**
681607
* @memberOf Hypergrid#
682608
* @desc Delegate MouseMove to the behavior (model).
683-
* @param {mouseDetails} mouseDetails - An enriched mouse event from fin-canvas.
609+
* @param {unknown} mouseDetails - An enriched mouse event from fin-canvas.
684610
*/
685611
delegateMouseMove: function(mouseDetails) {
686612
this.behavior.onMouseMove(this, mouseDetails);
@@ -689,7 +615,7 @@ exports.mixin = {
689615
/**
690616
* @memberOf Hypergrid#
691617
* @desc Delegate mousedown to the behavior (model).
692-
* @param {mouseDetails} mouseDetails - An enriched mouse event from fin-canvas.
618+
* @param {unknown} mouseDetails - An enriched mouse event from fin-canvas.
693619
*/
694620
delegateMouseDown: function(mouseDetails) {
695621
this.behavior.handleMouseDown(this, mouseDetails);
@@ -698,7 +624,7 @@ exports.mixin = {
698624
/**
699625
* @memberOf Hypergrid#
700626
* @desc Delegate mouseup to the behavior (model).
701-
* @param {mouseDetails} mouseDetails - An enriched mouse event from fin-canvas.
627+
* @param {unknown} mouseDetails - An enriched mouse event from fin-canvas.
702628
*/
703629
delegateMouseUp: function(mouseDetails) {
704630
this.behavior.onMouseUp(this, mouseDetails);
@@ -707,7 +633,7 @@ exports.mixin = {
707633
/**
708634
* @memberOf Hypergrid#
709635
* @desc Delegate click to the behavior (model).
710-
* @param {mouseDetails} mouseDetails - An enriched mouse event from fin-canvas.
636+
* @param {unknown} mouseDetails - An enriched mouse event from fin-canvas.
711637
*/
712638
delegateClick: function(mouseDetails) {
713639
this.behavior.onClick(this, mouseDetails);
@@ -716,7 +642,7 @@ exports.mixin = {
716642
/**
717643
* @memberOf Hypergrid#
718644
* @desc Delegate mouseDrag to the behavior (model).
719-
* @param {mouseDetails} mouseDetails - An enriched mouse event from fin-canvas.
645+
* @param {unknown} mouseDetails - An enriched mouse event from fin-canvas.
720646
*/
721647
delegateMouseDrag: function(mouseDetails) {
722648
this.behavior.onMouseDrag(this, mouseDetails);
@@ -725,7 +651,7 @@ exports.mixin = {
725651
/**
726652
* @memberOf Hypergrid#
727653
* @desc We've been doubleclicked on. Delegate through the behavior (model).
728-
* @param {mouseDetails} mouseDetails - An enriched mouse event from fin-canvas.
654+
* @param {unknown} mouseDetails - An enriched mouse event from fin-canvas.
729655
*/
730656
delegateDoubleClick: function(mouseDetails) {
731657
this.behavior.onDoubleClick(this, mouseDetails);

0 commit comments

Comments
 (0)