@hpcc-js/react 2.55.3 → 2.55.4

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/src/shape.tsx CHANGED
@@ -1,138 +1,138 @@
1
- import * as React from "@hpcc-js/preact-shim";
2
-
3
- interface Circle {
4
- radius?: number;
5
- fill?: string;
6
- stroke?: string;
7
- strokeWidth?: number;
8
- shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
9
- }
10
-
11
- export const Circle: React.FunctionComponent<Circle> = ({
12
- radius = 32,
13
- fill = "navy",
14
- stroke = fill,
15
- strokeWidth = 1,
16
- shapeRendering
17
- }) => <circle
18
- r={radius}
19
- fill={fill}
20
- stroke={stroke}
21
- stroke-width={strokeWidth}
22
- shape-rendering={shapeRendering}
23
- />;
24
-
25
- interface Square {
26
- radius?: number;
27
- cornerRadius?: number;
28
- fill?: string;
29
- stroke?: string;
30
- strokeWidth?: number;
31
- shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
32
- }
33
-
34
- export const Square: React.FunctionComponent<Square> = ({
35
- radius = 30,
36
- cornerRadius = 0,
37
- fill = "white",
38
- stroke,
39
- strokeWidth = 1,
40
- shapeRendering
41
- }) => <rect
42
- x={-radius}
43
- y={-radius}
44
- rx={cornerRadius}
45
- ry={cornerRadius}
46
- width={radius * 2}
47
- height={radius * 2}
48
- fill={fill}
49
- stroke={stroke || fill}
50
- stroke-width={strokeWidth}
51
- shape-rendering={shapeRendering}
52
- />;
53
-
54
- interface Rectangle {
55
- width?: number;
56
- height?: number;
57
- cornerRadius?: number;
58
- fill?: string;
59
- stroke?: string;
60
- strokeWidth?: number;
61
- shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
62
- }
63
-
64
- export const Rectangle: React.FunctionComponent<Rectangle> = ({
65
- width = 30,
66
- height = 30,
67
- cornerRadius = 0,
68
- fill = "white",
69
- stroke = "black",
70
- strokeWidth = 1,
71
- shapeRendering
72
- }) => {
73
- return <rect
74
- x={-width / 2}
75
- y={-height / 2}
76
- rx={cornerRadius}
77
- ry={cornerRadius}
78
- width={width}
79
- height={height}
80
- fill={fill}
81
- stroke={stroke || fill}
82
- stroke-width={strokeWidth}
83
- shape-rendering={shapeRendering}
84
- />;
85
- };
86
-
87
- interface Shape {
88
- shape?: "circle" | "square" | "rectangle";
89
- height?: number;
90
- width?: number;
91
- fill?: string;
92
- stroke?: string;
93
- strokeWidth?: number;
94
- shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
95
- cornerRadius?: number;
96
- }
97
-
98
- export const Shape: React.FunctionComponent<Shape> = ({
99
- shape = "circle",
100
- height = 128,
101
- width,
102
- fill,
103
- stroke,
104
- strokeWidth = 1,
105
- shapeRendering,
106
- cornerRadius
107
- }) => {
108
- switch (shape) {
109
- case "square":
110
- return <Square
111
- radius={height / 2}
112
- fill={fill}
113
- stroke={stroke}
114
- strokeWidth={strokeWidth}
115
- shapeRendering={shapeRendering}
116
- cornerRadius={cornerRadius}
117
- />;
118
- case "rectangle":
119
- return <Rectangle
120
- width={width ?? height}
121
- height={height}
122
- fill={fill}
123
- stroke={stroke}
124
- strokeWidth={strokeWidth}
125
- shapeRendering={shapeRendering}
126
- cornerRadius={cornerRadius}
127
- />;
128
- case "circle":
129
- default:
130
- return <Circle
131
- radius={height / 2}
132
- fill={fill}
133
- stroke={stroke}
134
- strokeWidth={strokeWidth}
135
- shapeRendering={shapeRendering}
136
- />;
137
- }
138
- };
1
+ import * as React from "@hpcc-js/preact-shim";
2
+
3
+ interface Circle {
4
+ radius?: number;
5
+ fill?: string;
6
+ stroke?: string;
7
+ strokeWidth?: number;
8
+ shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
9
+ }
10
+
11
+ export const Circle: React.FunctionComponent<Circle> = ({
12
+ radius = 32,
13
+ fill = "navy",
14
+ stroke = fill,
15
+ strokeWidth = 1,
16
+ shapeRendering
17
+ }) => <circle
18
+ r={radius}
19
+ fill={fill}
20
+ stroke={stroke}
21
+ stroke-width={strokeWidth}
22
+ shape-rendering={shapeRendering}
23
+ />;
24
+
25
+ interface Square {
26
+ radius?: number;
27
+ cornerRadius?: number;
28
+ fill?: string;
29
+ stroke?: string;
30
+ strokeWidth?: number;
31
+ shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
32
+ }
33
+
34
+ export const Square: React.FunctionComponent<Square> = ({
35
+ radius = 30,
36
+ cornerRadius = 0,
37
+ fill = "white",
38
+ stroke,
39
+ strokeWidth = 1,
40
+ shapeRendering
41
+ }) => <rect
42
+ x={-radius}
43
+ y={-radius}
44
+ rx={cornerRadius}
45
+ ry={cornerRadius}
46
+ width={radius * 2}
47
+ height={radius * 2}
48
+ fill={fill}
49
+ stroke={stroke || fill}
50
+ stroke-width={strokeWidth}
51
+ shape-rendering={shapeRendering}
52
+ />;
53
+
54
+ interface Rectangle {
55
+ width?: number;
56
+ height?: number;
57
+ cornerRadius?: number;
58
+ fill?: string;
59
+ stroke?: string;
60
+ strokeWidth?: number;
61
+ shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
62
+ }
63
+
64
+ export const Rectangle: React.FunctionComponent<Rectangle> = ({
65
+ width = 30,
66
+ height = 30,
67
+ cornerRadius = 0,
68
+ fill = "white",
69
+ stroke = "black",
70
+ strokeWidth = 1,
71
+ shapeRendering
72
+ }) => {
73
+ return <rect
74
+ x={-width / 2}
75
+ y={-height / 2}
76
+ rx={cornerRadius}
77
+ ry={cornerRadius}
78
+ width={width}
79
+ height={height}
80
+ fill={fill}
81
+ stroke={stroke || fill}
82
+ stroke-width={strokeWidth}
83
+ shape-rendering={shapeRendering}
84
+ />;
85
+ };
86
+
87
+ interface Shape {
88
+ shape?: "circle" | "square" | "rectangle";
89
+ height?: number;
90
+ width?: number;
91
+ fill?: string;
92
+ stroke?: string;
93
+ strokeWidth?: number;
94
+ shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
95
+ cornerRadius?: number;
96
+ }
97
+
98
+ export const Shape: React.FunctionComponent<Shape> = ({
99
+ shape = "circle",
100
+ height = 128,
101
+ width,
102
+ fill,
103
+ stroke,
104
+ strokeWidth = 1,
105
+ shapeRendering,
106
+ cornerRadius
107
+ }) => {
108
+ switch (shape) {
109
+ case "square":
110
+ return <Square
111
+ radius={height / 2}
112
+ fill={fill}
113
+ stroke={stroke}
114
+ strokeWidth={strokeWidth}
115
+ shapeRendering={shapeRendering}
116
+ cornerRadius={cornerRadius}
117
+ />;
118
+ case "rectangle":
119
+ return <Rectangle
120
+ width={width ?? height}
121
+ height={height}
122
+ fill={fill}
123
+ stroke={stroke}
124
+ strokeWidth={strokeWidth}
125
+ shapeRendering={shapeRendering}
126
+ cornerRadius={cornerRadius}
127
+ />;
128
+ case "circle":
129
+ default:
130
+ return <Circle
131
+ radius={height / 2}
132
+ fill={fill}
133
+ stroke={stroke}
134
+ strokeWidth={strokeWidth}
135
+ shapeRendering={shapeRendering}
136
+ />;
137
+ }
138
+ };
package/src/subgraph.tsx CHANGED
@@ -1,45 +1,45 @@
1
- import { Utility } from "@hpcc-js/common";
2
- import * as React from "@hpcc-js/preact-shim";
3
- import { Rectangle } from "./shape";
4
- import { Text } from "./text";
5
-
6
- export interface SubgraphProps {
7
- id: string;
8
- origData?: any;
9
- text: string;
10
- width?: number;
11
- height?: number;
12
- fill?: string;
13
- stroke?: string;
14
- fontHeight?: number;
15
- fontFamily?: string;
16
- }
17
-
18
- export const Subgraph: React.FunctionComponent<SubgraphProps> = ({
19
- text,
20
- width = 100,
21
- height = 100,
22
- fill = "transparent",
23
- stroke = "black",
24
- fontHeight = 12,
25
- fontFamily
26
- }) => {
27
- const tSize = Utility.textSize(text, fontFamily, fontHeight, false);
28
- return <>
29
- <Rectangle
30
- width={width}
31
- height={height}
32
- fill={fill}
33
- stroke={stroke}
34
- />
35
- <g
36
- transform={`translate(${(-width + tSize.width) / 2 + 4} ${(-height + tSize.height) / 2 + 4})`}
37
- >
38
- <Text
39
- height={fontHeight}
40
- text={text}
41
- fontFamily={fontFamily}
42
- />
43
- </g>
44
- </>;
45
- };
1
+ import { Utility } from "@hpcc-js/common";
2
+ import * as React from "@hpcc-js/preact-shim";
3
+ import { Rectangle } from "./shape";
4
+ import { Text } from "./text";
5
+
6
+ export interface SubgraphProps {
7
+ id: string;
8
+ origData?: any;
9
+ text: string;
10
+ width?: number;
11
+ height?: number;
12
+ fill?: string;
13
+ stroke?: string;
14
+ fontHeight?: number;
15
+ fontFamily?: string;
16
+ }
17
+
18
+ export const Subgraph: React.FunctionComponent<SubgraphProps> = ({
19
+ text,
20
+ width = 100,
21
+ height = 100,
22
+ fill = "transparent",
23
+ stroke = "black",
24
+ fontHeight = 12,
25
+ fontFamily
26
+ }) => {
27
+ const tSize = Utility.textSize(text, fontFamily, fontHeight, false);
28
+ return <>
29
+ <Rectangle
30
+ width={width}
31
+ height={height}
32
+ fill={fill}
33
+ stroke={stroke}
34
+ />
35
+ <g
36
+ transform={`translate(${(-width + tSize.width) / 2 + 4} ${(-height + tSize.height) / 2 + 4})`}
37
+ >
38
+ <Text
39
+ height={fontHeight}
40
+ text={text}
41
+ fontFamily={fontFamily}
42
+ />
43
+ </g>
44
+ </>;
45
+ };