@deephaven/components 0.49.1-beta.2 → 0.49.1-deephaven-ui.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenuRoot.d.ts","sourceRoot":"","sources":["../../src/context-actions/ContextMenuRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAA2B,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEpE,KAAK,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,UAAU,oBAAoB;IAC5B,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,cAAM,eAAgB,SAAQ,SAAS,CACrC,oBAAoB,EACpB,oBAAoB,CACrB;gBACa,KAAK,EAAE,oBAAoB;IAevC,iBAAiB,IAAI,IAAI;IASzB,oBAAoB,IAAI,IAAI;IAS5B,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAE3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAEvC,iBAAiB,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"ContextMenuRoot.d.ts","sourceRoot":"","sources":["../../src/context-actions/ContextMenuRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAA2B,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEpE,KAAK,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,UAAU,oBAAoB;IAC5B,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,cAAM,eAAgB,SAAQ,SAAS,CACrC,oBAAoB,EACpB,oBAAoB,CACrB;gBACa,KAAK,EAAE,oBAAoB;IAevC,iBAAiB,IAAI,IAAI;IASzB,oBAAoB,IAAI,IAAI;IAS5B,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAE3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAEvC,iBAAiB,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI;IA4DtC,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAMxC,MAAM,IAAI,GAAG,CAAC,OAAO;CA4BtB;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -37,45 +37,10 @@ class ContextMenuRoot extends Component {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
handleContextMenu(e) {
|
|
40
|
-
if (!
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
var parentRect = this.container.current.getBoundingClientRect();
|
|
44
|
-
var top = e.clientY - parentRect.top;
|
|
45
|
-
var left = e.clientX - parentRect.left;
|
|
46
|
-
var {
|
|
47
|
-
actions
|
|
48
|
-
} = this.state;
|
|
49
|
-
|
|
50
|
-
// Context menu is open and user clicked on the context-root blocking layer
|
|
51
|
-
// Mac and Linux appear to trigger contextmenu events on mousedown vs. mouseup on Windows
|
|
52
|
-
// Mouseup on Windows triggers blur before contextmenu which effectively does what this path does
|
|
53
|
-
if (actions != null && e.target === this.container.current) {
|
|
54
|
-
// re-emit right clicks that hit the context-root blocking layer
|
|
55
|
-
// while we already have a custom context menu open
|
|
56
|
-
e.preventDefault();
|
|
57
|
-
|
|
58
|
-
// Set actions to null removes the menu
|
|
59
|
-
// That allows a new menu to be opened on a different element so initial position is set properly
|
|
60
|
-
// Otherwise the instance of this menu may be reused
|
|
61
|
-
// A new contextmenu event is triggered on the element at the location the user clicked on the blocking layer
|
|
62
|
-
this.setState({
|
|
63
|
-
actions: null
|
|
64
|
-
}, () => {
|
|
65
|
-
var element = document.elementFromPoint(left, top); // x y
|
|
66
|
-
|
|
67
|
-
var mouseEvent = new MouseEvent('contextmenu', {
|
|
68
|
-
clientX: e.clientX,
|
|
69
|
-
clientY: e.clientY,
|
|
70
|
-
bubbles: true,
|
|
71
|
-
cancelable: true
|
|
72
|
-
});
|
|
73
|
-
element === null || element === void 0 ? void 0 : element.dispatchEvent(mouseEvent);
|
|
74
|
-
});
|
|
40
|
+
if (!ContextActionUtils.isContextActionEvent(e)) {
|
|
75
41
|
return;
|
|
76
42
|
}
|
|
77
|
-
if (!
|
|
78
|
-
// Open native menu if no custom context actions
|
|
43
|
+
if (!this.container.current) {
|
|
79
44
|
return;
|
|
80
45
|
}
|
|
81
46
|
if (e.metaKey || e.ctrlKey) {
|
|
@@ -83,8 +48,38 @@ class ContextMenuRoot extends Component {
|
|
|
83
48
|
return;
|
|
84
49
|
}
|
|
85
50
|
var contextActions = ContextActionUtils.getMenuItems(e.contextActions);
|
|
51
|
+
var parentRect = this.container.current.getBoundingClientRect();
|
|
52
|
+
var top = e.clientY - parentRect.top;
|
|
53
|
+
var left = e.clientX - parentRect.left;
|
|
86
54
|
if (contextActions.length === 0) {
|
|
87
|
-
//
|
|
55
|
+
// This code path seems to only exist for Chrome on Mac
|
|
56
|
+
// Mac appears to trigger contextmenu events on mousedown vs. mouseup on Windows
|
|
57
|
+
// Mouseup on Windows triggers blur before contextmenu which effectively does what this path does
|
|
58
|
+
if (e.target === this.container.current) {
|
|
59
|
+
// re-emit right clicks that hit the context-root blocking layer
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
|
|
62
|
+
// Set actions to null removes the menu
|
|
63
|
+
// That allows a new menu to be opened on a different element so initial position is set properly
|
|
64
|
+
// Otherwise the instance of this menu may be reused
|
|
65
|
+
// A new contextmenu event is triggered on the element at the location the user clicked on the blocking layer
|
|
66
|
+
this.setState({
|
|
67
|
+
actions: null
|
|
68
|
+
}, () => {
|
|
69
|
+
var element = document.elementFromPoint(left, top); // x y
|
|
70
|
+
|
|
71
|
+
var mouseEvent = new MouseEvent('contextmenu', {
|
|
72
|
+
clientX: e.clientX,
|
|
73
|
+
clientY: e.clientY,
|
|
74
|
+
bubbles: true,
|
|
75
|
+
cancelable: true
|
|
76
|
+
});
|
|
77
|
+
element === null || element === void 0 ? void 0 : element.dispatchEvent(mouseEvent);
|
|
78
|
+
});
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// target was a menu item
|
|
88
83
|
return;
|
|
89
84
|
}
|
|
90
85
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenuRoot.js","names":["React","Component","classNames","ContextMenu","ContextActionUtils","ContextMenuRoot","constructor","props","handleMenuClose","bind","handleContextMenu","container","createRef","openMenu","state","actions","left","top","componentDidMount","current","parentElement","addEventListener","componentWillUnmount","removeEventListener","e","
|
|
1
|
+
{"version":3,"file":"ContextMenuRoot.js","names":["React","Component","classNames","ContextMenu","ContextActionUtils","ContextMenuRoot","constructor","props","handleMenuClose","bind","handleContextMenu","container","createRef","openMenu","state","actions","left","top","componentDidMount","current","parentElement","addEventListener","componentWillUnmount","removeEventListener","e","isContextActionEvent","metaKey","ctrlKey","contextActions","getMenuItems","parentRect","getBoundingClientRect","clientY","clientX","length","target","preventDefault","setState","element","document","elementFromPoint","mouseEvent","MouseEvent","bubbles","cancelable","dispatchEvent","menu","render","dataTestId","verifiedTop","verifiedLeft","active"],"sources":["../../src/context-actions/ContextMenuRoot.tsx"],"sourcesContent":["import React, { Component } from 'react';\nimport classNames from 'classnames';\nimport ContextMenu from './ContextMenu';\nimport ContextActionUtils, { MenuItem } from './ContextActionUtils';\n\ntype ContextMenuRootProps = Record<string, never> & {\n 'data-testid'?: string;\n};\n\ninterface ContextMenuRootState {\n actions: MenuItem[] | null;\n left: number;\n top: number;\n}\n\n/**\n * Put at your root container, any contextmenu events that are unhandled in the root container will be handled by this\n */\nclass ContextMenuRoot extends Component<\n ContextMenuRootProps,\n ContextMenuRootState\n> {\n constructor(props: ContextMenuRootProps) {\n super(props);\n\n this.handleMenuClose = this.handleMenuClose.bind(this);\n this.handleContextMenu = this.handleContextMenu.bind(this);\n this.container = React.createRef();\n this.openMenu = React.createRef();\n\n this.state = {\n actions: null,\n left: 0,\n top: 0,\n };\n }\n\n componentDidMount(): void {\n if (this.container.current?.parentElement) {\n this.container.current.parentElement.addEventListener(\n 'contextmenu',\n this.handleContextMenu\n );\n }\n }\n\n componentWillUnmount(): void {\n if (this.container.current?.parentElement) {\n this.container.current.parentElement.removeEventListener(\n 'contextmenu',\n this.handleContextMenu\n );\n }\n }\n\n container: React.RefObject<HTMLDivElement>;\n\n openMenu: React.RefObject<ContextMenu>;\n\n handleContextMenu(e: MouseEvent): void {\n if (!ContextActionUtils.isContextActionEvent(e)) {\n return;\n }\n\n if (!this.container.current) {\n return;\n }\n\n if (e.metaKey || e.ctrlKey) {\n // debug escape hatch to native menu\n return;\n }\n\n const contextActions = ContextActionUtils.getMenuItems(e.contextActions);\n\n const parentRect = this.container.current.getBoundingClientRect();\n const top = e.clientY - parentRect.top;\n const left = e.clientX - parentRect.left;\n\n if (contextActions.length === 0) {\n // This code path seems to only exist for Chrome on Mac\n // Mac appears to trigger contextmenu events on mousedown vs. mouseup on Windows\n // Mouseup on Windows triggers blur before contextmenu which effectively does what this path does\n if (e.target === this.container.current) {\n // re-emit right clicks that hit the context-root blocking layer\n e.preventDefault();\n\n // Set actions to null removes the menu\n // That allows a new menu to be opened on a different element so initial position is set properly\n // Otherwise the instance of this menu may be reused\n // A new contextmenu event is triggered on the element at the location the user clicked on the blocking layer\n this.setState({ actions: null }, () => {\n const element = document.elementFromPoint(left, top); // x y\n\n const mouseEvent = new MouseEvent('contextmenu', {\n clientX: e.clientX,\n clientY: e.clientY,\n bubbles: true,\n cancelable: true,\n });\n\n element?.dispatchEvent(mouseEvent);\n });\n return;\n }\n\n // target was a menu item\n return;\n }\n\n // new clicks, set actions\n e.preventDefault();\n this.setState({\n actions: contextActions,\n top,\n left,\n });\n }\n\n handleMenuClose(menu: ContextMenu): void {\n if (menu === this.openMenu.current) {\n this.setState({ actions: null });\n }\n }\n\n render(): JSX.Element {\n let menu = null;\n const { 'data-testid': dataTestId } = this.props;\n const { actions, top, left } = this.state;\n if (actions) {\n menu = (\n <ContextMenu\n ref={this.openMenu}\n actions={actions}\n onMenuClosed={this.handleMenuClose}\n top={top}\n left={left}\n updatePosition={(verifiedTop, verifiedLeft) => {\n this.setState({ top: verifiedTop, left: verifiedLeft });\n }}\n data-testid={dataTestId}\n />\n );\n }\n return (\n <div\n className={classNames('context-menu-root', { active: actions })}\n ref={this.container}\n >\n {menu}\n </div>\n );\n }\n}\n\nexport default ContextMenuRoot;\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,OAAOC,UAAU,MAAM,YAAY;AAAC,OAC7BC,WAAW;AAAA,OACXC,kBAAkB;AAAA;AAYzB;AACA;AACA;AACA,MAAMC,eAAe,SAASJ,SAAS,CAGrC;EACAK,WAAW,CAACC,KAA2B,EAAE;IACvC,KAAK,CAACA,KAAK,CAAC;IAAC;IAAA;IAEb,IAAI,CAACC,eAAe,GAAG,IAAI,CAACA,eAAe,CAACC,IAAI,CAAC,IAAI,CAAC;IACtD,IAAI,CAACC,iBAAiB,GAAG,IAAI,CAACA,iBAAiB,CAACD,IAAI,CAAC,IAAI,CAAC;IAC1D,IAAI,CAACE,SAAS,gBAAGX,KAAK,CAACY,SAAS,EAAE;IACl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B,OAAO,EAAEE,OAAQ;QACjB,YAAY,EAAE,IAAI,CAACP,eAAgB;QACnC,GAAG,EAAES,GAAI;QACT,IAAI,EAAED,IAAK;QACX,cAAc,EAAE,CAACiC,WAAW,EAAEC,YAAY,KAAK;UAC7C,IAAI,CAACb,QAAQ,CAAC;YAAEpB,GAAG,EAAEgC,WAAW;YAAEjC,IAAI,EAAEkC;UAAa,CAAC,CAAC;QACzD,CAAE;QACF,eAAaF;MAAW,EAE3B;IACH;IACA,oBACE;MACE,SAAS,EAAE9C,UAAU,CAAC,mBAAmB,EAAE;QAAEiD,MAAM,EAAEpC;MAAQ,CAAC,CAAE;MAChE,GAAG,EAAE,IAAI,CAACJ,SAAU;MAAA,UAEnBmC;IAAI,EACD;EAEV;AACF;AAEA,eAAezC,eAAe"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/components",
|
|
3
|
-
"version": "0.49.1-
|
|
3
|
+
"version": "0.49.1-deephaven-ui.6+45d47859",
|
|
4
4
|
"description": "Deephaven React component library",
|
|
5
5
|
"author": "Deephaven Data Labs LLC",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@adobe/react-spectrum": "^3.29.0",
|
|
27
|
-
"@deephaven/icons": "^0.49.1-
|
|
28
|
-
"@deephaven/log": "^0.49.1-
|
|
29
|
-
"@deephaven/react-hooks": "^0.49.1-
|
|
30
|
-
"@deephaven/utils": "^0.49.1-
|
|
27
|
+
"@deephaven/icons": "^0.49.1-deephaven-ui.6+45d47859",
|
|
28
|
+
"@deephaven/log": "^0.49.1-deephaven-ui.6+45d47859",
|
|
29
|
+
"@deephaven/react-hooks": "^0.49.1-deephaven-ui.6+45d47859",
|
|
30
|
+
"@deephaven/utils": "^0.49.1-deephaven-ui.6+45d47859",
|
|
31
31
|
"@fortawesome/fontawesome-svg-core": "^6.2.1",
|
|
32
32
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
33
33
|
"@react-spectrum/theme-default": "^3.5.1",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"react-dom": "^17.x"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@deephaven/mocks": "^0.49.1-
|
|
54
|
+
"@deephaven/mocks": "^0.49.1-deephaven-ui.6+45d47859"
|
|
55
55
|
},
|
|
56
56
|
"files": [
|
|
57
57
|
"dist",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "45d47859e11c64ac6579efeb373ba6de6245c7ab"
|
|
68
68
|
}
|