@vitessce/tooltip 2.0.3 → 3.0.0

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.
@@ -0,0 +1,2 @@
1
+ export default function Tooltip(props: any): JSX.Element;
2
+ //# sourceMappingURL=Tooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../src/Tooltip.js"],"names":[],"mappings":"AAKA,yDA+CC"}
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { useEffect, useRef, useState } from 'react';
3
+ import { Paper, Popper } from '@material-ui/core';
4
+ import { useVitessceContainer } from '@vitessce/vit-s';
5
+ import { styles } from './styles.js';
6
+ export default function Tooltip(props) {
7
+ const { x, y, parentWidth, parentHeight, children, } = props;
8
+ const ref = useRef();
9
+ const classes = styles();
10
+ const [placementX, setPlacementX] = useState('start');
11
+ const [placementY, setPlacementY] = useState('bottom');
12
+ const getTooltipContainer = useVitessceContainer(ref);
13
+ // Do collision detection based on the bounds of the tooltip ancestor element.
14
+ useEffect(() => {
15
+ if (ref && ref.current) {
16
+ const flipX = (x > parentWidth / 2);
17
+ const flipY = (y > parentHeight / 2);
18
+ setPlacementX(flipX ? 'end' : 'start');
19
+ setPlacementY(flipY ? 'top' : 'bottom');
20
+ ref.current.style.left = `${x + (flipX ? -20 : 5)}px`;
21
+ ref.current.style.top = `${y + (flipY ? -20 : 5)}px`;
22
+ }
23
+ }, [x, y, parentWidth, parentHeight]);
24
+ return (_jsx("div", { ref: ref, className: classes.tooltipAnchor, children: ref && ref.current ? (_jsx(Popper, { open: true, anchorEl: ref.current, container: getTooltipContainer, transition: true, placement: `${placementY}-${placementX}`, children: _jsx(Paper, { elevation: 4, className: classes.tooltipContent, children: children }) })) : null }));
25
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * A tooltip component that also incorporates a crosshair element.
3
+ * @param {object} props
4
+ * @param {string} props.parentUuid A unique identifier corresponding to the plot
5
+ * with which this scatterplot is associated.
6
+ * @param {string} props.sourceUuid A unique identifier corresponding to the plot
7
+ * from which this tooltip originated.
8
+ * @param {number} props.x The x coordinate for the tooltip.
9
+ * @param {number} props.y The y coordinate for the tooltip.
10
+ * @param {number} props.parentWidth The width of the parent plot container element.
11
+ * @param {number} props.parentHeight The height of the parent plot container element.
12
+ * @param {React.Component} props.children The tooltip contents as a react component.
13
+ */
14
+ export default function Tooltip2D(props: {
15
+ parentUuid: string;
16
+ sourceUuid: string;
17
+ x: number;
18
+ y: number;
19
+ parentWidth: number;
20
+ parentHeight: number;
21
+ children: React.Component;
22
+ }): JSX.Element | null;
23
+ //# sourceMappingURL=Tooltip2D.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip2D.d.ts","sourceRoot":"","sources":["../src/Tooltip2D.js"],"names":[],"mappings":"AAcA;;;;;;;;;;;;GAYG;AACH;IAVyB,UAAU,EAAxB,MAAM;IAEQ,UAAU,EAAxB,MAAM;IAEQ,CAAC,EAAf,MAAM;IACQ,CAAC,EAAf,MAAM;IACQ,WAAW,EAAzB,MAAM;IACQ,YAAY,EAA1B,MAAM;IACiB,QAAQ;uBA6DzC"}
@@ -0,0 +1,48 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { makeStyles } from '@material-ui/core';
4
+ import Tooltip from './Tooltip.js';
5
+ const useStyles = makeStyles(theme => ({
6
+ cellEmphasisCrosshair: {
7
+ zIndex: 50,
8
+ position: 'absolute',
9
+ pointerEvents: 'none',
10
+ boxSizing: 'border-box',
11
+ backgroundColor: theme.palette.secondaryForeground,
12
+ },
13
+ }));
14
+ /**
15
+ * A tooltip component that also incorporates a crosshair element.
16
+ * @param {object} props
17
+ * @param {string} props.parentUuid A unique identifier corresponding to the plot
18
+ * with which this scatterplot is associated.
19
+ * @param {string} props.sourceUuid A unique identifier corresponding to the plot
20
+ * from which this tooltip originated.
21
+ * @param {number} props.x The x coordinate for the tooltip.
22
+ * @param {number} props.y The y coordinate for the tooltip.
23
+ * @param {number} props.parentWidth The width of the parent plot container element.
24
+ * @param {number} props.parentHeight The height of the parent plot container element.
25
+ * @param {React.Component} props.children The tooltip contents as a react component.
26
+ */
27
+ export default function Tooltip2D(props) {
28
+ const { parentUuid, sourceUuid, x, y, parentWidth, parentHeight, children, } = props;
29
+ const classes = useStyles();
30
+ // Check if out of bounds.
31
+ if (x < 0 || x > parentWidth || y < 0 || y > parentHeight) {
32
+ return null;
33
+ }
34
+ // Show tooltip or crosshair?
35
+ const isTooltipVisible = (parentUuid === sourceUuid);
36
+ const crosshairWidth = 1;
37
+ return (_jsx(_Fragment, { children: isTooltipVisible ? (_jsx(Tooltip, { x: x, y: y, parentWidth: parentWidth, parentHeight: parentHeight, children: children })) : (_jsxs(_Fragment, { children: [x !== null ? (_jsx("div", { className: classes.cellEmphasisCrosshair, style: {
38
+ left: `${x - crosshairWidth / 2}px`,
39
+ top: 0,
40
+ width: `${crosshairWidth}px`,
41
+ height: `${parentHeight}px`,
42
+ } })) : null, y !== null ? (_jsx("div", { className: classes.cellEmphasisCrosshair, style: {
43
+ left: 0,
44
+ top: `${y - crosshairWidth / 2}px`,
45
+ width: `${parentWidth}px`,
46
+ height: `${crosshairWidth}px`,
47
+ } })) : null] })) }));
48
+ }
@@ -0,0 +1,2 @@
1
+ export default function TooltipContent(props: any): JSX.Element;
2
+ //# sourceMappingURL=TooltipContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TooltipContent.d.ts","sourceRoot":"","sources":["../src/TooltipContent.js"],"names":[],"mappings":"AAEA,gEAiBC"}
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ export default function TooltipContent(props) {
4
+ const { info, } = props;
5
+ return (_jsx("table", { children: _jsx("tbody", { children: Object.entries(info).map(([key, value]) => (_jsxs("tr", { children: [_jsx("th", { children: key }), _jsx("td", { children: value })] }, key))) }) }));
6
+ }
@@ -0,0 +1,5 @@
1
+ export { default as Tooltip2D } from "./Tooltip2D.js";
2
+ export { default as Tooltip } from "./Tooltip.js";
3
+ export { default as TooltipContent } from "./TooltipContent.js";
4
+ export { styles as useTooltipStyles } from "./styles.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
package/dist-tsc/index.js CHANGED
@@ -1,3 +1,4 @@
1
- export { default as Tooltip2D } from './Tooltip2D';
2
- export { default as Tooltip } from './Tooltip';
3
- export { default as TooltipContent } from './TooltipContent';
1
+ export { default as Tooltip2D } from './Tooltip2D.js';
2
+ export { default as Tooltip } from './Tooltip.js';
3
+ export { default as TooltipContent } from './TooltipContent.js';
4
+ export { styles as useTooltipStyles } from './styles.js';
@@ -0,0 +1,2 @@
1
+ export const styles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"tooltipAnchor" | "tooltipContent">;
2
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.js"],"names":[],"mappings":"AAEA,qIAgCI"}
@@ -0,0 +1,34 @@
1
+ import { makeStyles } from '@material-ui/core';
2
+ export const styles = makeStyles(theme => ({
3
+ tooltipAnchor: {
4
+ position: 'relative',
5
+ width: '0px',
6
+ height: '0px',
7
+ pointerEvents: 'none',
8
+ userSelect: 'none',
9
+ },
10
+ tooltipContent: {
11
+ opacity: 0.9,
12
+ padding: '5px',
13
+ pointerEvents: 'none',
14
+ backgroundColor: theme.palette.gridLayoutBackground,
15
+ '& table > tbody > tr > th, & table > tbody > tr > td': {
16
+ border: 'none',
17
+ fontSize: '12px',
18
+ lineHeight: 1.43,
19
+ opacity: 0.8,
20
+ outline: 0,
21
+ padding: '0 2px !important',
22
+ textAlign: 'left',
23
+ color: theme.palette.tooltipText,
24
+ backgroundColor: theme.palette.gridLayoutBackground,
25
+ },
26
+ '& table > tr:nth-child(2)': {
27
+ backgroundColor: 'inherit !important',
28
+ },
29
+ '& table': {
30
+ borderCollapse: 'collapse',
31
+ marginBottom: '0px',
32
+ },
33
+ },
34
+ }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/tooltip",
3
- "version": "2.0.3",
3
+ "version": "3.0.0",
4
4
  "author": "Gehlenborg Lab",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -8,18 +8,20 @@
8
8
  "url": "git+https://github.com/vitessce/vitessce.git"
9
9
  },
10
10
  "license": "MIT",
11
- "main": "dist/index.mjs",
11
+ "type": "module",
12
+ "main": "dist/index.js",
12
13
  "files": [
14
+ "src",
13
15
  "dist",
14
- "src"
16
+ "dist-tsc"
15
17
  ],
16
18
  "dependencies": {
17
19
  "@material-ui/core": "~4.12.3",
18
- "@vitessce/vit-s": "2.0.3"
20
+ "@vitessce/vit-s": "3.0.0"
19
21
  },
20
22
  "devDependencies": {
21
23
  "react": "^18.0.0",
22
- "vite": "^3.0.0",
24
+ "vite": "^4.3.0",
23
25
  "vitest": "^0.23.4"
24
26
  },
25
27
  "peerDependencies": {
@@ -28,5 +30,12 @@
28
30
  "scripts": {
29
31
  "bundle": "pnpm exec vite build -c ../../scripts/vite.config.js",
30
32
  "test": "pnpm exec vitest --run -r ../../ --dir ."
33
+ },
34
+ "module": "dist/index.js",
35
+ "exports": {
36
+ ".": {
37
+ "types": "./dist-tsc/index.d.ts",
38
+ "import": "./dist/index.js"
39
+ }
31
40
  }
32
41
  }
package/src/Tooltip.js CHANGED
@@ -1,8 +1,7 @@
1
1
  import React, { useEffect, useRef, useState } from 'react';
2
- import Paper from '@material-ui/core/Paper';
3
- import Popper from '@material-ui/core/Popper';
2
+ import { Paper, Popper } from '@material-ui/core';
4
3
  import { useVitessceContainer } from '@vitessce/vit-s';
5
- import { styles } from './styles';
4
+ import { styles } from './styles.js';
6
5
 
7
6
  export default function Tooltip(props) {
8
7
  const {
package/src/Tooltip2D.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { makeStyles } from '@material-ui/core/styles';
3
- import Tooltip from './Tooltip';
2
+ import { makeStyles } from '@material-ui/core';
3
+ import Tooltip from './Tooltip.js';
4
4
 
5
5
  const useStyles = makeStyles(theme => ({
6
6
  cellEmphasisCrosshair: {
package/src/index.js CHANGED
@@ -1,3 +1,4 @@
1
- export { default as Tooltip2D } from './Tooltip2D';
2
- export { default as Tooltip } from './Tooltip';
3
- export { default as TooltipContent } from './TooltipContent';
1
+ export { default as Tooltip2D } from './Tooltip2D.js';
2
+ export { default as Tooltip } from './Tooltip.js';
3
+ export { default as TooltipContent } from './TooltipContent.js';
4
+ export { styles as useTooltipStyles } from './styles.js';
package/src/styles.js CHANGED
@@ -1,6 +1,6 @@
1
- import { makeStyles } from '@material-ui/core/styles';
1
+ import { makeStyles } from '@material-ui/core';
2
2
 
3
- export const styles = makeStyles(() => ({
3
+ export const styles = makeStyles(theme => ({
4
4
  tooltipAnchor: {
5
5
  position: 'relative',
6
6
  width: '0px',
@@ -12,14 +12,24 @@ export const styles = makeStyles(() => ({
12
12
  opacity: 0.9,
13
13
  padding: '5px',
14
14
  pointerEvents: 'none',
15
+ backgroundColor: theme.palette.gridLayoutBackground,
15
16
  '& table > tbody > tr > th, & table > tbody > tr > td': {
16
- fontSize: '80%',
17
+ border: 'none',
18
+ fontSize: '12px',
19
+ lineHeight: 1.43,
17
20
  opacity: 0.8,
18
21
  outline: 0,
19
- padding: '0 2px',
22
+ padding: '0 2px !important',
23
+ textAlign: 'left',
24
+ color: theme.palette.tooltipText,
25
+ backgroundColor: theme.palette.gridLayoutBackground,
26
+ },
27
+ '& table > tr:nth-child(2)': {
28
+ backgroundColor: 'inherit !important',
20
29
  },
21
30
  '& table': {
22
31
  borderCollapse: 'collapse',
32
+ marginBottom: '0px',
23
33
  },
24
34
  },
25
35
  }));