@hpcc-js/react 2.55.0 → 3.1.1
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/index.js +2 -575
- package/dist/index.js.map +7 -1
- package/package.json +29 -33
- package/src/ImageChar.tsx +10 -7
- package/src/__package__.ts +2 -2
- package/src/edge.tsx +2 -2
- package/src/icon.tsx +9 -9
- package/src/image.tsx +2 -2
- package/src/index.ts +14 -12
- package/src/render.ts +13 -5
- package/src/shape.tsx +14 -14
- package/src/span.tsx +9 -0
- package/src/subgraph.tsx +2 -2
- package/src/text.tsx +53 -34
- package/src/vertex.tsx +16 -13
- package/src/vertex2.tsx +4 -4
- package/src/vertex3.tsx +10 -10
- package/src/vertex4.tsx +9 -10
- package/types/ImageChar.d.ts +3 -4
- package/types/__package__.d.ts +2 -3
- package/types/edge.d.ts +1 -2
- package/types/icon.d.ts +5 -6
- package/types/image.d.ts +2 -3
- package/types/index.d.ts +14 -13
- package/types/render.d.ts +6 -3
- package/types/shape.d.ts +8 -9
- package/types/span.d.ts +5 -0
- package/types/subgraph.d.ts +0 -1
- package/types/text.d.ts +10 -12
- package/types/vertex.d.ts +4 -5
- package/types/vertex2.d.ts +1 -2
- package/types/vertex3.d.ts +7 -8
- package/types/vertex4.d.ts +3 -4
- package/dist/index.es6.js +0 -542
- package/dist/index.es6.js.map +0 -1
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
- package/types/ImageChar.d.ts.map +0 -1
- package/types/__package__.d.ts.map +0 -1
- package/types/edge.d.ts.map +0 -1
- package/types/icon.d.ts.map +0 -1
- package/types/image.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types/render.d.ts.map +0 -1
- package/types/shape.d.ts.map +0 -1
- package/types/subgraph.d.ts.map +0 -1
- package/types/text.d.ts.map +0 -1
- package/types/vertex.d.ts.map +0 -1
- package/types/vertex2.d.ts.map +0 -1
- package/types/vertex3.d.ts.map +0 -1
- package/types/vertex4.d.ts.map +0 -1
- package/types-3.4/ImageChar.d.ts +0 -14
- package/types-3.4/__package__.d.ts +0 -4
- package/types-3.4/edge.d.ts +0 -30
- package/types-3.4/icon.d.ts +0 -27
- package/types-3.4/image.d.ts +0 -11
- package/types-3.4/index.d.ts +0 -15
- package/types-3.4/render.d.ts +0 -27
- package/types-3.4/shape.d.ts +0 -41
- package/types-3.4/subgraph.d.ts +0 -14
- package/types-3.4/text.d.ts +0 -51
- package/types-3.4/vertex.d.ts +0 -33
- package/types-3.4/vertex2.d.ts +0 -4
- package/types-3.4/vertex3.d.ts +0 -34
- package/types-3.4/vertex4.d.ts +0 -32
package/package.json
CHANGED
|
@@ -1,49 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hpcc-js/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "hpcc-js - Viz React",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
"*": [
|
|
13
|
-
"types-3.4/index.d.ts"
|
|
14
|
-
]
|
|
15
|
-
}
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./types/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./dist/*": "./dist/*"
|
|
16
12
|
},
|
|
13
|
+
"module": "./dist/index.js",
|
|
14
|
+
"browser": "./dist/index.js",
|
|
15
|
+
"types": "./types/index.d.ts",
|
|
17
16
|
"files": [
|
|
18
17
|
"dist/*",
|
|
19
|
-
"
|
|
20
|
-
"types
|
|
21
|
-
"src/*"
|
|
18
|
+
"src/*",
|
|
19
|
+
"types/*"
|
|
22
20
|
],
|
|
23
21
|
"scripts": {
|
|
24
|
-
"clean": "rimraf --glob lib* types dist *.tsbuildinfo",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"bundle-watch": "npm run bundle -- -w",
|
|
31
|
-
"minimize": "terser dist/index.js -c -m --source-map \"content='dist/index.js.map',url='index.min.js.map'\" -o dist/index.min.js",
|
|
32
|
-
"gen-legacy-types": "downlevel-dts ./types ./types-3.4",
|
|
33
|
-
"build": "npm run compile-es6 && npm run bundle",
|
|
34
|
-
"watch": "npm-run-all compile-es6 -p compile-es6-watch bundle-watch",
|
|
35
|
-
"stamp": "node ../../node_modules/@hpcc-js/bundle/src/stamp.js",
|
|
22
|
+
"clean": "rimraf --glob lib* types dist *.tsbuildinfo .turbo",
|
|
23
|
+
"bundle": "node esbuild.js",
|
|
24
|
+
"bundle-watch": "npm run bundle -- --development --watch",
|
|
25
|
+
"gen-types": "tsc --project tsconfig.json",
|
|
26
|
+
"gen-types-watch": "npm run gen-types -- --watch",
|
|
27
|
+
"build": "run-p gen-types bundle",
|
|
36
28
|
"lint": "eslint ./src",
|
|
29
|
+
"lint-fix": "eslint --fix src/**/*.ts",
|
|
37
30
|
"docs": "typedoc --options tdoptions.json .",
|
|
38
|
-
"
|
|
31
|
+
"test-browser": "vitest run --project browser",
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"coverage": "vitest run --coverage",
|
|
34
|
+
"update": "npx --yes npm-check-updates -u -t minor",
|
|
35
|
+
"update-major": "npx --yes npm-check-updates -u"
|
|
39
36
|
},
|
|
40
37
|
"dependencies": {
|
|
41
|
-
"@hpcc-js/common": "^2.
|
|
42
|
-
"@hpcc-js/preact-shim": "^2.18.0"
|
|
38
|
+
"@hpcc-js/common": "^3.2.0"
|
|
43
39
|
},
|
|
44
40
|
"devDependencies": {
|
|
45
|
-
"@hpcc-js/
|
|
46
|
-
"
|
|
41
|
+
"@hpcc-js/esbuild-plugins": "^1.3.0",
|
|
42
|
+
"@hpcc-js/preact-shim": "^3.0.0"
|
|
47
43
|
},
|
|
48
44
|
"repository": {
|
|
49
45
|
"type": "git",
|
|
@@ -56,5 +52,5 @@
|
|
|
56
52
|
"url": "https://github.com/hpcc-systems/Visualization/issues"
|
|
57
53
|
},
|
|
58
54
|
"homepage": "https://github.com/hpcc-systems/Visualization",
|
|
59
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "b4f63e027feea45ebdfc578ef9c85d107bd97322"
|
|
60
56
|
}
|
package/src/ImageChar.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Utility } from "@hpcc-js/common";
|
|
2
2
|
import * as React from "@hpcc-js/preact-shim";
|
|
3
3
|
|
|
4
|
-
interface
|
|
4
|
+
export interface ImageCharProps {
|
|
5
5
|
x?: number;
|
|
6
6
|
y?: number;
|
|
7
7
|
height?: number;
|
|
@@ -10,16 +10,18 @@ interface ImageChar {
|
|
|
10
10
|
fontFamily?: string;
|
|
11
11
|
char?: string;
|
|
12
12
|
yOffset?: number;
|
|
13
|
+
fontWeight?: number;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
export const ImageChar: React.FunctionComponent<
|
|
16
|
+
export const ImageChar: React.FunctionComponent<ImageCharProps> = ({
|
|
16
17
|
x,
|
|
17
18
|
y = 0,
|
|
18
19
|
height = 12,
|
|
19
20
|
fill,
|
|
20
21
|
stroke,
|
|
21
22
|
fontFamily = "FontAwesome",
|
|
22
|
-
char = ""
|
|
23
|
+
char = "",
|
|
24
|
+
fontWeight
|
|
23
25
|
}) => {
|
|
24
26
|
|
|
25
27
|
const renderChar = React.useMemo(() => {
|
|
@@ -31,9 +33,10 @@ export const ImageChar: React.FunctionComponent<ImageChar> = ({
|
|
|
31
33
|
y={y}
|
|
32
34
|
fill={fill}
|
|
33
35
|
stroke={stroke}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
fontFamily={fontFamily}
|
|
37
|
+
fontSize={`${height}px`}
|
|
38
|
+
fontWeight={fontWeight}
|
|
39
|
+
dominantBaseline="middle"
|
|
40
|
+
style={{ textAnchor: "middle", alignmentBaseline: "middle" }}
|
|
38
41
|
>{renderChar}</text>;
|
|
39
42
|
};
|
package/src/__package__.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export const PKG_NAME = "@hpcc-js/react";
|
|
2
|
-
export const PKG_VERSION = "
|
|
3
|
-
export const BUILD_VERSION = "2.
|
|
2
|
+
export const PKG_VERSION = "3.1.1";
|
|
3
|
+
export const BUILD_VERSION = "3.2.1";
|
package/src/edge.tsx
CHANGED
package/src/icon.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Palette } from "@hpcc-js/common";
|
|
2
2
|
import * as React from "@hpcc-js/preact-shim";
|
|
3
|
-
import { Image } from "./image";
|
|
4
|
-
import { ImageChar } from "./ImageChar";
|
|
5
|
-
import { Shape } from "./shape";
|
|
3
|
+
import { Image } from "./image.tsx";
|
|
4
|
+
import { ImageChar } from "./ImageChar.tsx";
|
|
5
|
+
import { Shape } from "./shape.tsx";
|
|
6
6
|
|
|
7
|
-
export interface
|
|
7
|
+
export interface IconProps {
|
|
8
8
|
shape?: "circle" | "square" | "rectangle";
|
|
9
9
|
width?: number;
|
|
10
10
|
height?: number;
|
|
@@ -22,7 +22,7 @@ export interface Icon {
|
|
|
22
22
|
shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export const Icon: React.FunctionComponent<
|
|
25
|
+
export const Icon: React.FunctionComponent<IconProps> = ({
|
|
26
26
|
shape = "circle",
|
|
27
27
|
width,
|
|
28
28
|
height = 32,
|
|
@@ -64,21 +64,21 @@ export const Icon: React.FunctionComponent<Icon> = ({
|
|
|
64
64
|
fontFamily={imageFontFamily}
|
|
65
65
|
char={imageChar}
|
|
66
66
|
fill={imageCharFill}
|
|
67
|
-
|
|
67
|
+
fontWeight={400}
|
|
68
68
|
></ImageChar>
|
|
69
69
|
}
|
|
70
70
|
</>;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
export interface IconEx extends
|
|
73
|
+
export interface IconEx extends IconProps {
|
|
74
74
|
id: string;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
export interface
|
|
77
|
+
export interface IconsProps {
|
|
78
78
|
icons: IconEx[];
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
export const Icons: React.FunctionComponent<
|
|
81
|
+
export const Icons: React.FunctionComponent<IconsProps> = ({
|
|
82
82
|
icons = []
|
|
83
83
|
}) => {
|
|
84
84
|
const IconComponents = icons.map(cat => {
|
package/src/image.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "@hpcc-js/preact-shim";
|
|
2
2
|
|
|
3
|
-
interface
|
|
3
|
+
interface ImageProps {
|
|
4
4
|
href: string;
|
|
5
5
|
x?: number;
|
|
6
6
|
y?: number;
|
|
@@ -8,7 +8,7 @@ interface Image {
|
|
|
8
8
|
yOffset?: number;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const Image: React.FunctionComponent<
|
|
11
|
+
export const Image: React.FunctionComponent<ImageProps> = ({
|
|
12
12
|
href,
|
|
13
13
|
x,
|
|
14
14
|
y = 0,
|
package/src/index.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
export * from "./__package__";
|
|
1
|
+
export * from "./__package__.ts";
|
|
2
2
|
|
|
3
|
-
export * from "./edge";
|
|
4
|
-
export * from "./ImageChar";
|
|
5
|
-
export * from "./icon";
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./
|
|
12
|
-
export * from "./
|
|
13
|
-
export * from "./
|
|
3
|
+
export * from "./edge.tsx";
|
|
4
|
+
export * from "./ImageChar.tsx";
|
|
5
|
+
export * from "./icon.tsx";
|
|
6
|
+
export * from "./image.tsx";
|
|
7
|
+
export * from "./render.ts";
|
|
8
|
+
export * from "./shape.tsx";
|
|
9
|
+
export * from "./span.tsx";
|
|
10
|
+
export * from "./text.tsx";
|
|
11
|
+
export * from "./vertex.tsx";
|
|
12
|
+
export * from "./vertex2.tsx";
|
|
13
|
+
export * from "./vertex3.tsx";
|
|
14
|
+
export * from "./vertex4.tsx";
|
|
15
|
+
export * from "./subgraph.tsx";
|
|
14
16
|
|
|
15
17
|
import * as React from "@hpcc-js/preact-shim";
|
|
16
18
|
export {
|
package/src/render.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HTMLWidget,
|
|
1
|
+
import { HTMLWidget, SVGWidget } from "@hpcc-js/common";
|
|
2
2
|
import * as React from "@hpcc-js/preact-shim";
|
|
3
3
|
|
|
4
4
|
export function render<P>(C: React.FunctionComponent<P>, props: Readonly<P>, parent: Element | Document | ShadowRoot | DocumentFragment, replaceNode?: Element | Text) {
|
|
@@ -14,8 +14,6 @@ export function svgRender<P>(C: React.FunctionComponent<P>, props: Readonly<P>,
|
|
|
14
14
|
|
|
15
15
|
export class HTMLAdapter<P> extends HTMLWidget {
|
|
16
16
|
|
|
17
|
-
@publish({}, "object", "Properties")
|
|
18
|
-
protected _props: P = {} as P;
|
|
19
17
|
props(): P;
|
|
20
18
|
props(_: Partial<P>): this;
|
|
21
19
|
props(_?: Partial<P>): P | this {
|
|
@@ -41,11 +39,15 @@ export class HTMLAdapter<P> extends HTMLWidget {
|
|
|
41
39
|
render(this._component, this._props, domNode);
|
|
42
40
|
}
|
|
43
41
|
}
|
|
42
|
+
HTMLAdapter.prototype._class += " react_HTMLAdapter";
|
|
43
|
+
|
|
44
|
+
export interface HTMLAdapter<P> {
|
|
45
|
+
_props: P;
|
|
46
|
+
}
|
|
47
|
+
HTMLAdapter.prototype.publish("props", {}, "object", "Properties");
|
|
44
48
|
|
|
45
49
|
export class SVGAdapter<P> extends SVGWidget {
|
|
46
50
|
|
|
47
|
-
@publish({}, "object", "Properties")
|
|
48
|
-
protected _props: P = {} as P;
|
|
49
51
|
props(): P;
|
|
50
52
|
props(_: Partial<P>): this;
|
|
51
53
|
props(_?: Partial<P>): P | this {
|
|
@@ -71,3 +73,9 @@ export class SVGAdapter<P> extends SVGWidget {
|
|
|
71
73
|
render(this._component, this._props, domNode);
|
|
72
74
|
}
|
|
73
75
|
}
|
|
76
|
+
SVGAdapter.prototype._class += " react_SVGAdapter";
|
|
77
|
+
|
|
78
|
+
export interface SVGAdapter<P> {
|
|
79
|
+
_props: P;
|
|
80
|
+
}
|
|
81
|
+
SVGAdapter.prototype.publish("props", {}, "object", "Properties");
|
package/src/shape.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "@hpcc-js/preact-shim";
|
|
2
2
|
|
|
3
|
-
interface
|
|
3
|
+
interface CircleProps {
|
|
4
4
|
radius?: number;
|
|
5
5
|
fill?: string;
|
|
6
6
|
stroke?: string;
|
|
@@ -8,7 +8,7 @@ interface Circle {
|
|
|
8
8
|
shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const Circle: React.FunctionComponent<
|
|
11
|
+
export const Circle: React.FunctionComponent<CircleProps> = ({
|
|
12
12
|
radius = 32,
|
|
13
13
|
fill = "navy",
|
|
14
14
|
stroke = fill,
|
|
@@ -18,11 +18,11 @@ export const Circle: React.FunctionComponent<Circle> = ({
|
|
|
18
18
|
r={radius}
|
|
19
19
|
fill={fill}
|
|
20
20
|
stroke={stroke}
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
strokeWidth={strokeWidth}
|
|
22
|
+
shapeRendering={shapeRendering}
|
|
23
23
|
/>;
|
|
24
24
|
|
|
25
|
-
interface
|
|
25
|
+
interface SquareProps {
|
|
26
26
|
radius?: number;
|
|
27
27
|
cornerRadius?: number;
|
|
28
28
|
fill?: string;
|
|
@@ -31,7 +31,7 @@ interface Square {
|
|
|
31
31
|
shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export const Square: React.FunctionComponent<
|
|
34
|
+
export const Square: React.FunctionComponent<SquareProps> = ({
|
|
35
35
|
radius = 30,
|
|
36
36
|
cornerRadius = 0,
|
|
37
37
|
fill = "white",
|
|
@@ -47,11 +47,11 @@ export const Square: React.FunctionComponent<Square> = ({
|
|
|
47
47
|
height={radius * 2}
|
|
48
48
|
fill={fill}
|
|
49
49
|
stroke={stroke || fill}
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
strokeWidth={strokeWidth}
|
|
51
|
+
shapeRendering={shapeRendering}
|
|
52
52
|
/>;
|
|
53
53
|
|
|
54
|
-
interface
|
|
54
|
+
interface RectangleProps {
|
|
55
55
|
width?: number;
|
|
56
56
|
height?: number;
|
|
57
57
|
cornerRadius?: number;
|
|
@@ -61,7 +61,7 @@ interface Rectangle {
|
|
|
61
61
|
shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export const Rectangle: React.FunctionComponent<
|
|
64
|
+
export const Rectangle: React.FunctionComponent<RectangleProps> = ({
|
|
65
65
|
width = 30,
|
|
66
66
|
height = 30,
|
|
67
67
|
cornerRadius = 0,
|
|
@@ -79,12 +79,12 @@ export const Rectangle: React.FunctionComponent<Rectangle> = ({
|
|
|
79
79
|
height={height}
|
|
80
80
|
fill={fill}
|
|
81
81
|
stroke={stroke || fill}
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
strokeWidth={strokeWidth}
|
|
83
|
+
shapeRendering={shapeRendering}
|
|
84
84
|
/>;
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
-
interface
|
|
87
|
+
interface ShapeProps {
|
|
88
88
|
shape?: "circle" | "square" | "rectangle";
|
|
89
89
|
height?: number;
|
|
90
90
|
width?: number;
|
|
@@ -95,7 +95,7 @@ interface Shape {
|
|
|
95
95
|
cornerRadius?: number;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
export const Shape: React.FunctionComponent<
|
|
98
|
+
export const Shape: React.FunctionComponent<ShapeProps> = ({
|
|
99
99
|
shape = "circle",
|
|
100
100
|
height = 128,
|
|
101
101
|
width,
|
package/src/span.tsx
ADDED
package/src/subgraph.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Utility } from "@hpcc-js/common";
|
|
2
2
|
import * as React from "@hpcc-js/preact-shim";
|
|
3
|
-
import { Rectangle } from "./shape";
|
|
4
|
-
import { Text } from "./text";
|
|
3
|
+
import { Rectangle } from "./shape.tsx";
|
|
4
|
+
import { Text } from "./text.tsx";
|
|
5
5
|
|
|
6
6
|
export interface SubgraphProps {
|
|
7
7
|
id: string;
|
package/src/text.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Utility } from "@hpcc-js/common";
|
|
2
2
|
import * as React from "@hpcc-js/preact-shim";
|
|
3
|
-
import { Icon } from "./icon";
|
|
4
|
-
import { Rectangle } from "./shape";
|
|
3
|
+
import { Icon } from "./icon.tsx";
|
|
4
|
+
import { Rectangle } from "./shape.tsx";
|
|
5
5
|
|
|
6
|
-
interface
|
|
6
|
+
export interface TextLineProps {
|
|
7
7
|
text: string;
|
|
8
8
|
height?: number;
|
|
9
9
|
anchor?: string;
|
|
@@ -12,7 +12,7 @@ interface TextLine {
|
|
|
12
12
|
fill?: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const TextLine: React.FunctionComponent<
|
|
15
|
+
export const TextLine: React.FunctionComponent<TextLineProps> = ({
|
|
16
16
|
text,
|
|
17
17
|
height = 12,
|
|
18
18
|
anchor = "middle",
|
|
@@ -29,7 +29,7 @@ export const TextLine: React.FunctionComponent<TextLine> = ({
|
|
|
29
29
|
>{text}</text>;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
interface
|
|
32
|
+
export interface TextProps {
|
|
33
33
|
text: string;
|
|
34
34
|
height?: number;
|
|
35
35
|
fontFamily?: string;
|
|
@@ -37,35 +37,36 @@ interface Text {
|
|
|
37
37
|
onSizeUpdate?: (size: { width: number, height: number }) => void;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export const Text: React.FunctionComponent<
|
|
40
|
+
export const Text: React.FunctionComponent<TextProps> = ({
|
|
41
41
|
text,
|
|
42
42
|
height = 12,
|
|
43
43
|
fontFamily = "Verdana",
|
|
44
44
|
fill = "black",
|
|
45
45
|
onSizeUpdate
|
|
46
46
|
}) => {
|
|
47
|
-
const [totalWidth,
|
|
48
|
-
const [totalHeight,
|
|
47
|
+
const [totalWidth, setTotalWidth] = React.useState(0);
|
|
48
|
+
const [totalHeight, setTotalHeight] = React.useState(0);
|
|
49
49
|
|
|
50
50
|
React.useEffect(() => {
|
|
51
|
-
onSizeUpdate
|
|
51
|
+
if (onSizeUpdate) {
|
|
52
|
+
onSizeUpdate({ width: totalWidth, height: totalHeight });
|
|
53
|
+
}
|
|
52
54
|
}, [totalWidth, totalHeight, onSizeUpdate]);
|
|
53
55
|
|
|
54
56
|
const parts = React.useMemo(() => {
|
|
55
57
|
return text.split("\n");
|
|
56
58
|
}, [text]);
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
React.useLayoutEffect(() => {
|
|
61
|
+
const size = Utility.textSize(parts, fontFamily, height);
|
|
62
|
+
setTotalWidth(size.width);
|
|
63
|
+
setTotalHeight(size.height);
|
|
60
64
|
}, [fontFamily, height, parts]);
|
|
61
65
|
|
|
62
|
-
setTotalWidthUpdate(ts.width);
|
|
63
|
-
setTotalHeightUpdate(parts.length * (height + 2) - 2);
|
|
64
|
-
|
|
65
|
-
const yOffset = -(totalHeight / 2) + (height / 2);
|
|
66
66
|
const TextLines = React.useMemo(() => {
|
|
67
|
+
const yOffset = -(totalHeight / 2) + (height / 2);
|
|
67
68
|
return parts.map((p, i) => {
|
|
68
|
-
return <g key={i} transform={`translate(0 ${yOffset + i * (height + 2)})`}>
|
|
69
|
+
return <g key={`key-${i}`} transform={`translate(0 ${yOffset + i * (height + 2)})`}>
|
|
69
70
|
<TextLine
|
|
70
71
|
text={p}
|
|
71
72
|
height={height}
|
|
@@ -74,12 +75,12 @@ export const Text: React.FunctionComponent<Text> = ({
|
|
|
74
75
|
/>
|
|
75
76
|
</g>;
|
|
76
77
|
});
|
|
77
|
-
}, [
|
|
78
|
+
}, [parts, totalHeight, height, fontFamily, fill]);
|
|
78
79
|
|
|
79
|
-
return
|
|
80
|
+
return <g>{TextLines}</g>;
|
|
80
81
|
};
|
|
81
82
|
|
|
82
|
-
export interface
|
|
83
|
+
export interface TextBoxProps {
|
|
83
84
|
text: string;
|
|
84
85
|
height?: number;
|
|
85
86
|
fontFamily?: string;
|
|
@@ -93,7 +94,7 @@ export interface TextBox {
|
|
|
93
94
|
onSizeUpdate?: (size: { width: number, height: number }) => void;
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
export const TextBox: React.FunctionComponent<
|
|
97
|
+
export const TextBox: React.FunctionComponent<TextBoxProps> = ({
|
|
97
98
|
text,
|
|
98
99
|
height = 12,
|
|
99
100
|
fontFamily = "Verdana",
|
|
@@ -109,7 +110,9 @@ export const TextBox: React.FunctionComponent<TextBox> = ({
|
|
|
109
110
|
const [textHeight, setTextHeightUpdate] = React.useState(0);
|
|
110
111
|
|
|
111
112
|
React.useEffect(() => {
|
|
112
|
-
onSizeUpdate
|
|
113
|
+
if (onSizeUpdate) {
|
|
114
|
+
onSizeUpdate({ width: textWidth, height: textHeight });
|
|
115
|
+
}
|
|
113
116
|
}, [textWidth, textHeight, onSizeUpdate]);
|
|
114
117
|
|
|
115
118
|
const onTextSizeUpdate = React.useCallback(size => {
|
|
@@ -142,17 +145,11 @@ export const TextBox: React.FunctionComponent<TextBox> = ({
|
|
|
142
145
|
</>;
|
|
143
146
|
};
|
|
144
147
|
|
|
145
|
-
export interface LabelledRect extends
|
|
148
|
+
export interface LabelledRect extends TextBoxProps {
|
|
146
149
|
width?: number;
|
|
147
150
|
fontSize?: number;
|
|
148
151
|
}
|
|
149
152
|
|
|
150
|
-
export interface IconLabelledRect extends LabelledRect {
|
|
151
|
-
icon: string;
|
|
152
|
-
iconFontFamily: string;
|
|
153
|
-
iconFontSize: number;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
153
|
export const LabelledRect: React.FunctionComponent<LabelledRect> = ({
|
|
157
154
|
text,
|
|
158
155
|
height = 12,
|
|
@@ -165,18 +162,34 @@ export const LabelledRect: React.FunctionComponent<LabelledRect> = ({
|
|
|
165
162
|
textFill = "black",
|
|
166
163
|
strokeWidth = 1,
|
|
167
164
|
cornerRadius = 0,
|
|
168
|
-
onSizeUpdate
|
|
165
|
+
onSizeUpdate
|
|
169
166
|
}) => {
|
|
167
|
+
|
|
168
|
+
const [actualWidth, setActualWidthUpdate] = React.useState(width);
|
|
169
|
+
const [actualHeight, setActualHeightUpdate] = React.useState(height);
|
|
170
|
+
|
|
171
|
+
React.useLayoutEffect(() => {
|
|
172
|
+
const size = Utility.textSize(text, fontFamily, fontSize);
|
|
173
|
+
setActualWidthUpdate(size.width + padding * 2);
|
|
174
|
+
setActualHeightUpdate(size.height + padding * 2);
|
|
175
|
+
}, [text, fontFamily, fontSize, padding]);
|
|
176
|
+
|
|
177
|
+
React.useLayoutEffect(() => {
|
|
178
|
+
if (onSizeUpdate) {
|
|
179
|
+
onSizeUpdate({ width: actualWidth, height: actualHeight });
|
|
180
|
+
}
|
|
181
|
+
}, [actualWidth, actualHeight, padding, onSizeUpdate]);
|
|
182
|
+
|
|
170
183
|
return <>
|
|
171
184
|
<Rectangle
|
|
172
|
-
width={
|
|
173
|
-
height={
|
|
185
|
+
width={actualWidth}
|
|
186
|
+
height={actualHeight}
|
|
174
187
|
fill={fill}
|
|
175
188
|
stroke={stroke}
|
|
176
189
|
strokeWidth={strokeWidth}
|
|
177
190
|
cornerRadius={cornerRadius}
|
|
178
191
|
/>
|
|
179
|
-
<g transform={`translate(${-(
|
|
192
|
+
<g transform={`translate(${-(actualWidth / 2) + padding} ${-(actualHeight / 2) + padding + fontSize * 0.15})`}>
|
|
180
193
|
<TextLine
|
|
181
194
|
text={text}
|
|
182
195
|
fontFamily={fontFamily}
|
|
@@ -189,6 +202,12 @@ export const LabelledRect: React.FunctionComponent<LabelledRect> = ({
|
|
|
189
202
|
</>;
|
|
190
203
|
};
|
|
191
204
|
|
|
205
|
+
export interface IconLabelledRect extends LabelledRect {
|
|
206
|
+
icon: string;
|
|
207
|
+
iconFontFamily?: string;
|
|
208
|
+
iconFontSize?: number;
|
|
209
|
+
}
|
|
210
|
+
|
|
192
211
|
export const IconLabelledRect: React.FunctionComponent<IconLabelledRect> = ({
|
|
193
212
|
icon,
|
|
194
213
|
iconFontFamily,
|
|
@@ -202,9 +221,9 @@ export const IconLabelledRect: React.FunctionComponent<IconLabelledRect> = ({
|
|
|
202
221
|
stroke = "lightgray",
|
|
203
222
|
textFill = "black",
|
|
204
223
|
strokeWidth = 1,
|
|
205
|
-
cornerRadius = 0
|
|
206
|
-
onSizeUpdate = (size: { width: number, height: number }) => { }
|
|
224
|
+
cornerRadius = 0
|
|
207
225
|
}) => {
|
|
226
|
+
|
|
208
227
|
return <>
|
|
209
228
|
<Rectangle
|
|
210
229
|
width={width}
|
package/src/vertex.tsx
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as React from "@hpcc-js/preact-shim";
|
|
2
|
-
import { Icon } from "./icon";
|
|
3
|
-
import { TextBox } from "./text";
|
|
2
|
+
import { Icon, IconProps } from "./icon.tsx";
|
|
3
|
+
import { TextBox } from "./text.tsx";
|
|
4
4
|
|
|
5
|
-
export interface
|
|
5
|
+
export interface AnnotationsProps {
|
|
6
6
|
x: number;
|
|
7
7
|
y: number;
|
|
8
8
|
annotationIDs: string[];
|
|
9
9
|
stepSize?: number;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const Annotations: React.FunctionComponent<
|
|
12
|
+
export const Annotations: React.FunctionComponent<AnnotationsProps> = ({
|
|
13
13
|
x,
|
|
14
14
|
y,
|
|
15
15
|
annotationIDs = [],
|
|
@@ -35,7 +35,7 @@ export interface VertexProps {
|
|
|
35
35
|
text: string;
|
|
36
36
|
textHeight?: number;
|
|
37
37
|
textPadding?: number;
|
|
38
|
-
icon?:
|
|
38
|
+
icon?: IconProps;
|
|
39
39
|
annotationsHeight?: number;
|
|
40
40
|
annotationIDs?: string[];
|
|
41
41
|
textFill?: string;
|
|
@@ -52,7 +52,7 @@ export const Vertex: React.FunctionComponent<VertexProps> = ({
|
|
|
52
52
|
text = "",
|
|
53
53
|
textHeight = 12,
|
|
54
54
|
textPadding = 4,
|
|
55
|
-
icon = {},
|
|
55
|
+
icon = {} as IconProps,
|
|
56
56
|
annotationsHeight = 12,
|
|
57
57
|
annotationIDs = [],
|
|
58
58
|
textFill,
|
|
@@ -63,19 +63,22 @@ export const Vertex: React.FunctionComponent<VertexProps> = ({
|
|
|
63
63
|
showLabel = true,
|
|
64
64
|
scale = 1
|
|
65
65
|
}) => {
|
|
66
|
-
const [textBoxWidth, setTextBoxWidthUpdate] = React.useState(0);
|
|
67
|
-
const [textBoxHeight, setTextBoxHeightUpdate] = React.useState(0);
|
|
68
|
-
|
|
69
|
-
React.useEffect(() => {
|
|
70
|
-
onSizeUpdate && onSizeUpdate({ width: 0, height: 0 });
|
|
71
|
-
}, [textBoxWidth, textBoxHeight, onSizeUpdate]);
|
|
72
|
-
|
|
73
66
|
icon = {
|
|
74
67
|
imageChar: "fa-question",
|
|
75
68
|
height: 32,
|
|
76
69
|
fill: "transparent",
|
|
77
70
|
...icon
|
|
78
71
|
};
|
|
72
|
+
|
|
73
|
+
const [textBoxWidth, setTextBoxWidthUpdate] = React.useState(0);
|
|
74
|
+
const [textBoxHeight, setTextBoxHeightUpdate] = React.useState(0);
|
|
75
|
+
|
|
76
|
+
React.useEffect(() => {
|
|
77
|
+
if (onSizeUpdate) {
|
|
78
|
+
onSizeUpdate({ width: 0, height: 0 });
|
|
79
|
+
}
|
|
80
|
+
}, [textBoxWidth, textBoxHeight, onSizeUpdate]);
|
|
81
|
+
|
|
79
82
|
let width = textBoxWidth;
|
|
80
83
|
width += 4;
|
|
81
84
|
let offsetY = -(icon.height * 2 / 6 + textHeight + 8) / 2;
|