Skip to content

Commit 4955167

Browse files
authored
Add contextmenu_cell event to grid. (#191)
1 parent 05eb83c commit 4955167

22 files changed

+153
-33
lines changed

.vscode/settings.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
"eslint.validate": [
44
"javascript",
55
"javascriptreact",
6-
{ "language": "html", "autoFix": true },
7-
{ "language": "handlebars", "autoFix": true },
8-
{ "language": "vue", "autoFix": true }
6+
"html",
7+
"vue"
98
],
9+
"editor.codeActionsOnSave": {
10+
"source.fixAll.eslint": true
11+
}
1012
}

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The fastest open-source data table for web.
2323
[![npm](https://img.shields.io/npm/v/cheetah-grid.svg)](https://www.npmjs.com/package/cheetah-grid)
2424

2525
```html
26-
<script src="https://unpkg.com/cheetah-grid@0.14"></script>
26+
<script src="https://unpkg.com/cheetah-grid@0.15"></script>
2727
```
2828

2929
### Downloading Cheetah Grid using npm
@@ -46,10 +46,10 @@ const cheetahGrid = require("cheetah-grid")
4646

4747
[![npm](https://img.shields.io/npm/v/cheetah-grid.svg)](https://www.npmjs.com/package/cheetah-grid)
4848

49-
[cheetahGrid.es5.min.js](https://unpkg.com/cheetah-grid@0.14/dist/cheetahGrid.es5.min.js)
49+
[cheetahGrid.es5.min.js](https://unpkg.com/cheetah-grid@0.15/dist/cheetahGrid.es5.min.js)
5050

5151
SourceMap
52-
[cheetahGrid.es5.min.js.map](https://unpkg.com/cheetah-grid@0.14/dist/cheetahGrid.es5.min.js.map)
52+
[cheetahGrid.es5.min.js.map](https://unpkg.com/cheetah-grid@0.15/dist/cheetahGrid.es5.min.js.map)
5353

5454

5555
### Downloading Cheetah Grid using GitHub

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "cheetah-grid-manager",
33
"private": true,
4-
"version": "0.14.0",
4+
"version": "0.15.0",
55
"description": "Cheetah Grid is a high performance grid engine that works on canvas",
66
"keywords": [
77
"spreadsheet",

packages/cheetah-grid-icon-svg-loader/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cheetah-grid-icon-svg-loader/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cheetah-grid-icon-svg-loader",
3-
"version": "0.14.0",
3+
"version": "0.15.0",
44
"description": "Webpack loader that loads the icon module for Cheetah Grid from SVG.",
55
"main": "lib/index.js",
66
"files": [

packages/cheetah-grid/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cheetah-grid/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cheetah-grid",
3-
"version": "0.14.2",
3+
"version": "0.15.0",
44
"description": "Cheetah Grid is a high performance grid engine that works on canvas",
55
"keywords": [
66
"spreadsheet",

packages/cheetah-grid/src/js/core/DG_EVENT_TYPE.ts

+32
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,52 @@
11
export interface DrawGridEvents {
2+
/**
3+
* Indicates when the cell was clicked.
4+
*/
25
CLICK_CELL: "click_cell";
6+
/**
7+
* Indicates when the cell was double-clicked.
8+
*/
39
DBLCLICK_CELL: "dblclick_cell";
10+
/**
11+
* Indicates when the cell was double-taped.
12+
*/
413
DBLTAP_CELL: "dbltap_cell";
14+
/**
15+
* Indicates when pointing device button is pressed in a cell.
16+
*/
517
MOUSEDOWN_CELL: "mousedown_cell";
18+
/**
19+
* Indicates when pointing device button is released in a cell.
20+
*/
621
MOUSEUP_CELL: "mouseup_cell";
22+
/**
23+
* Indicates the cell selection state has changed.
24+
*/
725
SELECTED_CELL: "selected_cell";
26+
/**
27+
* Indicates key-downed.
28+
*/
829
KEYDOWN: "keydown";
930
MOUSEMOVE_CELL: "mousemove_cell";
1031
MOUSEENTER_CELL: "mouseenter_cell";
1132
MOUSELEAVE_CELL: "mouseleave_cell";
1233
MOUSEOVER_CELL: "mouseover_cell";
1334
MOUSEOUT_CELL: "mouseout_cell";
35+
/**
36+
* Indicates when the user attempts to open a context menu in the cell.
37+
*/
38+
CONTEXTMENU_CELL: "contextmenu_cell";
1439
INPUT_CELL: "input_cell";
1540
PASTE_CELL: "paste_cell";
1641
EDITABLEINPUT_CELL: "editableinput_cell";
1742
MODIFY_STATUS_EDITABLEINPUT_CELL: "modify_status_editableinput_cell";
43+
/**
44+
* Indicates when the column width has changed.
45+
*/
1846
RESIZE_COLUMN: "resize_column";
47+
/**
48+
* Indicates when scrolled.
49+
*/
1950
SCROLL: "scroll";
2051
FOCUS_GRID: "focus_grid";
2152
BLUR_GRID: "blur_grid";
@@ -38,6 +69,7 @@ export const DG_EVENT_TYPE: DrawGridEvents = {
3869
MOUSELEAVE_CELL: "mouseleave_cell",
3970
MOUSEOVER_CELL: "mouseover_cell",
4071
MOUSEOUT_CELL: "mouseout_cell",
72+
CONTEXTMENU_CELL: "contextmenu_cell",
4173
INPUT_CELL: "input_cell",
4274
PASTE_CELL: "paste_cell",
4375
EDITABLEINPUT_CELL: "editableinput_cell",

packages/cheetah-grid/src/js/core/DrawGrid.ts

+10
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,16 @@ function _bindEvents(this: DrawGrid): void {
12561256
}
12571257
grid.fireListeners(DG_EVENT_TYPE.CLICK_CELL, eventArgs);
12581258
});
1259+
handler.on(element, "contextmenu", e => {
1260+
if (!grid.hasListeners(DG_EVENT_TYPE.CONTEXTMENU_CELL)) {
1261+
return;
1262+
}
1263+
const { eventArgs } = getCellEventArgsSet(e);
1264+
if (!eventArgs) {
1265+
return;
1266+
}
1267+
grid.fireListeners(DG_EVENT_TYPE.CONTEXTMENU_CELL, eventArgs);
1268+
});
12591269
handler.on(element, "dblclick", e => {
12601270
if (!grid.hasListeners(DG_EVENT_TYPE.DBLCLICK_CELL)) {
12611271
return;

packages/cheetah-grid/src/js/list-grid/LG_EVENT_TYPE.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { DG_EVENT_TYPE, DrawGridEvents } from "../core/DG_EVENT_TYPE";
22
import { extend } from "../internal/utils";
33

4-
// eslint-disable-next-line @typescript-eslint/class-name-casing
54
export interface ListGidEvents extends DrawGridEvents {
5+
/**
6+
* Indicates when the cell value was changed.
7+
*/
68
CHANGED_VALUE: "changed_value";
9+
/**
10+
* Indicates when the header cell value was changed.
11+
*/
712
CHANGED_HEADER_VALUE: "changed_header_value";
813
}
914

packages/cheetah-grid/src/js/ts-types/events.ts

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export interface DrawGridEventHandlersEventMap {
6363
mousemove_cell: [MouseCellEvent];
6464
mousedown_cell: [MouseCellEvent];
6565
mouseup_cell: [MouseCellEvent];
66+
contextmenu_cell: [MouseCellEvent];
6667
dbltap_cell: [TouchCellEvent];
6768
keydown: [number, KeyboardEvent];
6869
paste_cell: [PasteCellEvent];
@@ -86,6 +87,7 @@ export interface DrawGridEventHandlersReturnMap {
8687
mousemove_cell: void;
8788
mousedown_cell: boolean;
8889
mouseup_cell: void;
90+
contextmenu_cell: void;
8991
dbltap_cell: void;
9092
keydown: void;
9193
paste_cell: void;

packages/demo/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/demo/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "cheetah-grid-demo",
33
"private": true,
4-
"version": "0.14.0",
4+
"version": "0.15.0",
55
"description": "",
66
"main": "index.js",
77
"scripts": {

packages/docs/api/js/events.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ order: 200
66

77
You can set an event listener using the `listen(type, listener)` method.
88

9-
Please get the event type from `cheetahGrid.ListGrid.EVENT_TYPE`.
9+
Please get the event type from [`cheetahGrid.ListGrid.EVENT_TYPE`](https://future-architect.github.io/cheetah-grid/documents/tsdoc/interfaces/listgidevents.html).
1010

1111
<code-preview>
1212

packages/docs/introduction/getting-started-with-vue.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ order: 20
1111
[![npm](https://img.shields.io/npm/v/vue-cheetah-grid.svg)](https://www.npmjs.com/package/vue-cheetah-grid)
1212

1313
```html
14-
<script src="https://unpkg.com/cheetah-grid@0.14"></script>
15-
<script src="https://unpkg.com/vue-cheetah-grid@0.14"></script>
14+
<script src="https://unpkg.com/cheetah-grid@0.15"></script>
15+
<script src="https://unpkg.com/vue-cheetah-grid@0.15"></script>
1616
```
1717

1818
```js

packages/docs/introduction/getting-started.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ order: 10
1111
[![npm](https://img.shields.io/npm/v/cheetah-grid.svg)](https://www.npmjs.com/package/cheetah-grid)
1212

1313
```html
14-
<script src="https://unpkg.com/cheetah-grid@0.14"></script>
14+
<script src="https://unpkg.com/cheetah-grid@0.15"></script>
1515
```
1616

1717
### Via npm
@@ -30,11 +30,11 @@ const cheetahGrid = require("cheetah-grid")
3030

3131
[![npm](https://img.shields.io/npm/v/cheetah-grid.svg)](https://www.npmjs.com/package/cheetah-grid)
3232

33-
[cheetahGrid.es5.min.js](https://unpkg.com/cheetah-grid@0.14/dist/cheetahGrid.es5.min.js)
33+
[cheetahGrid.es5.min.js](https://unpkg.com/cheetah-grid@0.15/dist/cheetahGrid.es5.min.js)
3434

3535
#### SourceMap
3636

37-
[cheetahGrid.es5.min.js.map](https://unpkg.com/cheetah-grid@0.14/dist/cheetahGrid.es5.min.js.map)
37+
[cheetahGrid.es5.min.js.map](https://unpkg.com/cheetah-grid@0.15/dist/cheetahGrid.es5.min.js.map)
3838

3939
### Via GitHub
4040

packages/docs/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/docs/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "cheetah-grid-docs",
33
"private": true,
4-
"version": "0.14.0",
4+
"version": "0.15.0",
55
"scripts": {
66
"watch": "vuepress dev . --debug",
77
"build": "npm-run-all build:*",

packages/vue-cheetah-grid/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/vue-cheetah-grid/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-cheetah-grid",
3-
"version": "0.14.1",
3+
"version": "0.15.0",
44
"description": "Cheetah Grid for Vue.js",
55
"main": "dist/vueCheetahGrid.js",
66
"files": [

0 commit comments

Comments
 (0)