@toptal/picasso-tree-view 1.0.21 → 2.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.
- package/dist-package/src/TreeView/TreeView.d.ts +1 -11
- package/dist-package/src/TreeView/TreeView.d.ts.map +1 -1
- package/dist-package/src/TreeView/TreeView.js +5 -23
- package/dist-package/src/TreeView/TreeView.js.map +1 -1
- package/dist-package/src/TreeView/variables.d.ts +1 -0
- package/dist-package/src/TreeView/variables.d.ts.map +1 -1
- package/dist-package/src/TreeView/variables.js +1 -0
- package/dist-package/src/TreeView/variables.js.map +1 -1
- package/package.json +1 -1
- package/src/TreeView/TreeView.tsx +4 -36
- package/src/TreeView/variables.ts +1 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { TreeViewPropsBase
|
|
2
|
+
import type { TreeViewPropsBase } from './types';
|
|
3
3
|
export interface Props extends TreeViewPropsBase {
|
|
4
4
|
/** Set the scale extent to the specified array of numbers [k0, k1] where k0 is the minimum allowed scale factor and k1 is the maximum allowed scale factor */
|
|
5
5
|
scaleExtent?: [number, number];
|
|
@@ -9,16 +9,6 @@ export interface Props extends TreeViewPropsBase {
|
|
|
9
9
|
showZoom?: boolean;
|
|
10
10
|
/** Scales the current zoom transform by coefficient */
|
|
11
11
|
scaleCoefficient?: number;
|
|
12
|
-
/**
|
|
13
|
-
* Custom center translation vector (happens after zoom center translation on selected node is applied)
|
|
14
|
-
* @deprecated [FX-4718] If you happen to rely on it, you are likely would want to migrate to StaticTreeView component instead of TreeView
|
|
15
|
-
*/
|
|
16
|
-
centerTranslation?: Vector2;
|
|
17
|
-
/**
|
|
18
|
-
* Transition duration for centering animation in ms
|
|
19
|
-
* @deprecated [FX-4718] If you happen to rely on it, you are likely would want to migrate to StaticTreeView component instead of TreeView
|
|
20
|
-
*/
|
|
21
|
-
transitionDuration?: number;
|
|
22
12
|
}
|
|
23
13
|
export declare const TreeView: {
|
|
24
14
|
(props: Props): JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeView.d.ts","sourceRoot":"","sources":["../../../src/TreeView/TreeView.tsx"],"names":[],"mappings":";AAqBA,OAAO,KAAK,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"TreeView.d.ts","sourceRoot":"","sources":["../../../src/TreeView/TreeView.tsx"],"names":[],"mappings":";AAqBA,OAAO,KAAK,EAAE,iBAAiB,EAAW,MAAM,SAAS,CAAA;AAIzD,MAAM,WAAW,KAAM,SAAQ,iBAAiB;IAC9C,8JAA8J;IAC9J,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,wBAAwB;IACxB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,uDAAuD;IACvD,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAID,eAAO,MAAM,QAAQ;YAAW,KAAK;;;;;;;;;;;;;;CA2FpC,CAAA;AAYD,eAAe,QAAQ,CAAA"}
|
|
@@ -1,35 +1,17 @@
|
|
|
1
1
|
import React, { createRef, useContext, useEffect, useState, useMemo, } from 'react';
|
|
2
2
|
import { makeStyles } from '@material-ui/core/styles';
|
|
3
|
-
import { usePropDeprecationWarning } from '@toptal/picasso-utils';
|
|
4
3
|
import { TreeViewContext } from './TreeViewContainer';
|
|
5
4
|
import { useTree } from './use-tree';
|
|
6
5
|
import Zoom from './Zoom';
|
|
7
6
|
import styles from './styles';
|
|
8
7
|
import { useZoom } from './use-zoom';
|
|
9
|
-
import { DEFAULT_SCALE_EXTENT, ZERO_VECTOR2, TreeViewPropsDefaults, } from './variables';
|
|
8
|
+
import { DEFAULT_SCALE_EXTENT, DEFAULT_TRANSITION_DURATION, ZERO_VECTOR2, TreeViewPropsDefaults, } from './variables';
|
|
10
9
|
import { TreeViewSvg } from './TreeViewSvg';
|
|
11
10
|
import { useFinalMargins } from './use-final-margins';
|
|
12
11
|
const useStyles = makeStyles(styles, { name: 'PicassoTreeView' });
|
|
13
12
|
export const TreeView = (props) => {
|
|
14
13
|
var _a, _b, _c;
|
|
15
|
-
|
|
16
|
-
usePropDeprecationWarning({
|
|
17
|
-
props,
|
|
18
|
-
name: 'centerTranslation',
|
|
19
|
-
componentName: 'TreeView',
|
|
20
|
-
description: 'If you happen to rely on it, you are likely would want to migrate to StaticTreeView component instead of TreeView',
|
|
21
|
-
});
|
|
22
|
-
// TODO: [FX-4718]
|
|
23
|
-
usePropDeprecationWarning({
|
|
24
|
-
props,
|
|
25
|
-
name: 'transitionDuration',
|
|
26
|
-
componentName: 'TreeView',
|
|
27
|
-
description: 'If you happen to rely on it, you are likely would want to migrate to StaticTreeView component instead of TreeView',
|
|
28
|
-
});
|
|
29
|
-
const { data, renderNode, nodeWidth = TreeView.defaultProps.nodeWidth, nodeHeight = TreeView.defaultProps.nodeHeight, scaleExtent = TreeView.defaultProps.scaleExtent, initialScale = TreeView.defaultProps.initialScale, scaleCoefficient = TreeView.defaultProps.scaleCoefficient, showZoom = TreeView.defaultProps.showZoom,
|
|
30
|
-
// NOTE: these two are intentionally removed from defaultProps in order
|
|
31
|
-
// to make usePropDeprecationWarning hook correctly detect their usage
|
|
32
|
-
centerTranslation = ZERO_VECTOR2, transitionDuration = 750, } = props;
|
|
14
|
+
const { data, renderNode, nodeWidth = TreeView.defaultProps.nodeWidth, nodeHeight = TreeView.defaultProps.nodeHeight, scaleExtent = TreeView.defaultProps.scaleExtent, initialScale = TreeView.defaultProps.initialScale, scaleCoefficient = TreeView.defaultProps.scaleCoefficient, showZoom = TreeView.defaultProps.showZoom, } = props;
|
|
33
15
|
const { direction = TreeView.defaultProps.directionProps.direction, variant = TreeView.defaultProps.directionProps.variant, } = (_a = props.directionProps) !== null && _a !== void 0 ? _a : TreeView.defaultProps.directionProps;
|
|
34
16
|
const classes = useStyles();
|
|
35
17
|
const rootRef = createRef();
|
|
@@ -58,10 +40,10 @@ export const TreeView = (props) => {
|
|
|
58
40
|
rootRef,
|
|
59
41
|
scaleExtent,
|
|
60
42
|
center: {
|
|
61
|
-
x: center.x +
|
|
62
|
-
y: center.y +
|
|
43
|
+
x: center.x + ZERO_VECTOR2.x,
|
|
44
|
+
y: center.y + ZERO_VECTOR2.y,
|
|
63
45
|
},
|
|
64
|
-
transitionDuration,
|
|
46
|
+
transitionDuration: DEFAULT_TRANSITION_DURATION,
|
|
65
47
|
initialScale,
|
|
66
48
|
});
|
|
67
49
|
const [initialized, setInitialized] = useState(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeView.js","sourceRoot":"","sources":["../../../src/TreeView/TreeView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,EACR,OAAO,GACR,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"TreeView.js","sourceRoot":"","sources":["../../../src/TreeView/TreeView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,EACR,OAAO,GACR,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,IAAI,MAAM,QAAQ,CAAA;AACzB,OAAO,MAAM,MAAM,UAAU,CAAA;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,YAAY,EACZ,qBAAqB,GACtB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,O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O,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAA;IAE7C,OAAO,CACL,6BAAK,SAAS,EAAE,OAAO,CAAC,IAAI;QACzB,QAAQ,IAAI,CACX,oBAAC,IAAI,IAAC,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,GAAI,CACrE;QACD,oBAAC,WAAW,IACV,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,EAAE,GACpC,CACE,CACP,CAAA;AACH,CAAC,CAAA;AAED,QAAQ,CAAC,YAAY,mCAChB,qBAAqB,KACxB,WAAW,EAAE,oBAAoB,EACjC,YAAY,EAAE,CAAC,EACf,gBAAgB,EAAE,GAAG,EACrB,QAAQ,EAAE,IAAI,GACf,CAAA;AAED,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAA;AAEjC,eAAe,QAAQ,CAAA"}
|
|
@@ -7,6 +7,7 @@ export declare const DEFAULT_WIDTH = 236;
|
|
|
7
7
|
export declare const DEFAULT_HEIGHT = 59;
|
|
8
8
|
export declare const DEFAULT_SCALE_EXTENT: [number, number];
|
|
9
9
|
export declare const ZERO_VECTOR2: Vector2;
|
|
10
|
+
export declare const DEFAULT_TRANSITION_DURATION = 750;
|
|
10
11
|
export declare const TreeViewPropsDefaults: {
|
|
11
12
|
nodeWidth: number;
|
|
12
13
|
nodeHeight: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../../src/TreeView/variables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEvE,eAAO,MAAM,yBAAyB,KAAK,CAAA;AAC3C,eAAO,MAAM,yBAAyB,KAAK,CAAA;AAC3C,eAAO,MAAM,2BAA2B,KAAK,CAAA;AAC7C,eAAO,MAAM,2BAA2B,KAAK,CAAA;AAC7C,eAAO,MAAM,aAAa,MAAM,CAAA;AAChC,eAAO,MAAM,cAAc,KAAK,CAAA;AAChC,eAAO,MAAM,oBAAoB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAY,CAAA;AAC9D,eAAO,MAAM,YAAY,EAAE,OAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../../src/TreeView/variables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEvE,eAAO,MAAM,yBAAyB,KAAK,CAAA;AAC3C,eAAO,MAAM,yBAAyB,KAAK,CAAA;AAC3C,eAAO,MAAM,2BAA2B,KAAK,CAAA;AAC7C,eAAO,MAAM,2BAA2B,KAAK,CAAA;AAC7C,eAAO,MAAM,aAAa,MAAM,CAAA;AAChC,eAAO,MAAM,cAAc,KAAK,CAAA;AAChC,eAAO,MAAM,oBAAoB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAY,CAAA;AAC9D,eAAO,MAAM,YAAY,EAAE,OAAwB,CAAA;AACnD,eAAO,MAAM,2BAA2B,MAAM,CAAA;AAE9C,eAAO,MAAM,qBAAqB;;;;;;;CAOjC,CAAA"}
|
|
@@ -6,6 +6,7 @@ export const DEFAULT_WIDTH = 236;
|
|
|
6
6
|
export const DEFAULT_HEIGHT = 59;
|
|
7
7
|
export const DEFAULT_SCALE_EXTENT = [0.1, 5];
|
|
8
8
|
export const ZERO_VECTOR2 = { x: 0, y: 0 };
|
|
9
|
+
export const DEFAULT_TRANSITION_DURATION = 750;
|
|
9
10
|
export const TreeViewPropsDefaults = {
|
|
10
11
|
nodeWidth: DEFAULT_WIDTH,
|
|
11
12
|
nodeHeight: DEFAULT_HEIGHT,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variables.js","sourceRoot":"","sources":["../../../src/TreeView/variables.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAA;AAC3C,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAA;AAC3C,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAA;AAC7C,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAA;AAC7C,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAA;AAChC,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAA;AAChC,MAAM,CAAC,MAAM,oBAAoB,GAAqB,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;AAC9D,MAAM,CAAC,MAAM,YAAY,GAAY,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"variables.js","sourceRoot":"","sources":["../../../src/TreeView/variables.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAA;AAC3C,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAA;AAC3C,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAA;AAC7C,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAA;AAC7C,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAA;AAChC,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAA;AAChC,MAAM,CAAC,MAAM,oBAAoB,GAAqB,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;AAC9D,MAAM,CAAC,MAAM,YAAY,GAAY,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAA;AACnD,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAA;AAE9C,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,SAAS,EAAE,aAAa;IACxB,UAAU,EAAE,cAAc;IAC1B,cAAc,EAAE;QACd,SAAS,EAAE,UAA4B;QACvC,OAAO,EAAE,QAA2B;KACrC;CACF,CAAA"}
|
package/package.json
CHANGED
|
@@ -7,7 +7,6 @@ import React, {
|
|
|
7
7
|
} from 'react'
|
|
8
8
|
import type { Theme } from '@material-ui/core/styles'
|
|
9
9
|
import { makeStyles } from '@material-ui/core/styles'
|
|
10
|
-
import { usePropDeprecationWarning } from '@toptal/picasso-utils'
|
|
11
10
|
|
|
12
11
|
import { TreeViewContext } from './TreeViewContainer'
|
|
13
12
|
import { useTree } from './use-tree'
|
|
@@ -16,6 +15,7 @@ import styles from './styles'
|
|
|
16
15
|
import { useZoom } from './use-zoom'
|
|
17
16
|
import {
|
|
18
17
|
DEFAULT_SCALE_EXTENT,
|
|
18
|
+
DEFAULT_TRANSITION_DURATION,
|
|
19
19
|
ZERO_VECTOR2,
|
|
20
20
|
TreeViewPropsDefaults,
|
|
21
21
|
} from './variables'
|
|
@@ -32,39 +32,11 @@ export interface Props extends TreeViewPropsBase {
|
|
|
32
32
|
showZoom?: boolean
|
|
33
33
|
/** Scales the current zoom transform by coefficient */
|
|
34
34
|
scaleCoefficient?: number
|
|
35
|
-
/**
|
|
36
|
-
* Custom center translation vector (happens after zoom center translation on selected node is applied)
|
|
37
|
-
* @deprecated [FX-4718] If you happen to rely on it, you are likely would want to migrate to StaticTreeView component instead of TreeView
|
|
38
|
-
*/
|
|
39
|
-
centerTranslation?: Vector2
|
|
40
|
-
/**
|
|
41
|
-
* Transition duration for centering animation in ms
|
|
42
|
-
* @deprecated [FX-4718] If you happen to rely on it, you are likely would want to migrate to StaticTreeView component instead of TreeView
|
|
43
|
-
*/
|
|
44
|
-
transitionDuration?: number
|
|
45
35
|
}
|
|
46
36
|
|
|
47
37
|
const useStyles = makeStyles<Theme>(styles, { name: 'PicassoTreeView' })
|
|
48
38
|
|
|
49
39
|
export const TreeView = (props: Props) => {
|
|
50
|
-
// TODO: [FX-4718]
|
|
51
|
-
usePropDeprecationWarning({
|
|
52
|
-
props,
|
|
53
|
-
name: 'centerTranslation',
|
|
54
|
-
componentName: 'TreeView',
|
|
55
|
-
description:
|
|
56
|
-
'If you happen to rely on it, you are likely would want to migrate to StaticTreeView component instead of TreeView',
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
// TODO: [FX-4718]
|
|
60
|
-
usePropDeprecationWarning({
|
|
61
|
-
props,
|
|
62
|
-
name: 'transitionDuration',
|
|
63
|
-
componentName: 'TreeView',
|
|
64
|
-
description:
|
|
65
|
-
'If you happen to rely on it, you are likely would want to migrate to StaticTreeView component instead of TreeView',
|
|
66
|
-
})
|
|
67
|
-
|
|
68
40
|
const {
|
|
69
41
|
data,
|
|
70
42
|
renderNode,
|
|
@@ -74,10 +46,6 @@ export const TreeView = (props: Props) => {
|
|
|
74
46
|
initialScale = TreeView.defaultProps.initialScale,
|
|
75
47
|
scaleCoefficient = TreeView.defaultProps.scaleCoefficient,
|
|
76
48
|
showZoom = TreeView.defaultProps.showZoom,
|
|
77
|
-
// NOTE: these two are intentionally removed from defaultProps in order
|
|
78
|
-
// to make usePropDeprecationWarning hook correctly detect their usage
|
|
79
|
-
centerTranslation = ZERO_VECTOR2,
|
|
80
|
-
transitionDuration = 750,
|
|
81
49
|
} = props
|
|
82
50
|
|
|
83
51
|
const {
|
|
@@ -121,10 +89,10 @@ export const TreeView = (props: Props) => {
|
|
|
121
89
|
rootRef,
|
|
122
90
|
scaleExtent,
|
|
123
91
|
center: {
|
|
124
|
-
x: center.x +
|
|
125
|
-
y: center.y +
|
|
92
|
+
x: center.x + ZERO_VECTOR2.x,
|
|
93
|
+
y: center.y + ZERO_VECTOR2.y,
|
|
126
94
|
},
|
|
127
|
-
transitionDuration,
|
|
95
|
+
transitionDuration: DEFAULT_TRANSITION_DURATION,
|
|
128
96
|
initialScale,
|
|
129
97
|
})
|
|
130
98
|
const [initialized, setInitialized] = useState(false)
|
|
@@ -8,6 +8,7 @@ export const DEFAULT_WIDTH = 236
|
|
|
8
8
|
export const DEFAULT_HEIGHT = 59
|
|
9
9
|
export const DEFAULT_SCALE_EXTENT: [number, number] = [0.1, 5]
|
|
10
10
|
export const ZERO_VECTOR2: Vector2 = { x: 0, y: 0 }
|
|
11
|
+
export const DEFAULT_TRANSITION_DURATION = 750
|
|
11
12
|
|
|
12
13
|
export const TreeViewPropsDefaults = {
|
|
13
14
|
nodeWidth: DEFAULT_WIDTH,
|