@hpcc-js/react 2.55.2 → 2.55.3

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/vertex4.tsx CHANGED
@@ -1,309 +1,309 @@
1
- /* eslint-disable no-debugger, no-console */
2
- import { Utility } from "@hpcc-js/common";
3
- import * as React from "@hpcc-js/preact-shim";
4
- import { Icon } from "./icon";
5
- import { TextBox } from "./text";
6
- import { VertexProps } from "./vertex";
7
-
8
- export interface IVertex4Annotation extends Icon {
9
- shapeOffsetX?: number;
10
- shapeOffsetY?: number;
11
- }
12
-
13
- export interface IVertex4 extends VertexProps {
14
- textboxStrokeWidth?: number;
15
- annotations?: IVertex4Annotation[];
16
- iconAnnotations?: IVertex4Annotation[];
17
- annotationGutter?: number;
18
- cornerRadius?: number;
19
- subText?: any;
20
- noLabelRadius?: number;
21
- iconBorderWidth?: number;
22
- iconBorderColor?: string;
23
- iconBackgroundColor?: string;
24
- shapeOffsetX?: number;
25
- shapeOffsetY?: number;
26
- iconOffsetX?: number;
27
- iconOffsetY?: number;
28
- iconPadding?: number;
29
- iconFontSize?: number;
30
- iconFontColor?: string;
31
- iconFontFamily?: string;
32
- iconText?: string;
33
- shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
34
- }
35
-
36
- export const Vertex4: React.FunctionComponent<IVertex4> = ({
37
- categoryID = "",
38
- text = "",
39
- textHeight = 10,
40
- textPadding = 4,
41
- textFill = "#287EC4",
42
- textboxFill = "white",
43
- textboxStroke = "#CCCCCC",
44
- textboxStrokeWidth = 1,
45
- textFontFamily = "Verdana",
46
- annotationGutter = 2,
47
- annotations = [],
48
- iconAnnotations = [],
49
- cornerRadius = 3,
50
- icon = {},
51
- subText = {},
52
- showLabel = true,
53
- noLabelRadius = 5,
54
-
55
- iconBorderWidth = 1,
56
- iconBorderColor = "#333",
57
-
58
- iconBackgroundColor = "#fff",
59
-
60
- iconFontColor = "#000",
61
- iconFontSize = 20,
62
- iconFontFamily = "FontAwesome",
63
-
64
- shapeOffsetX = 0,
65
- shapeOffsetY = 0,
66
- iconOffsetX = 0,
67
- iconOffsetY = 0,
68
-
69
- iconPadding = 4,
70
- iconText = "?",
71
- shapeRendering = "auto"
72
- }) => {
73
- icon = {
74
- height: 50,
75
- imageChar: "?",
76
- imageFontFamily: "FontAwesome",
77
- imageCharFill: "#555555",
78
- fill: "transparent",
79
- strokeWidth: 0,
80
- ...icon
81
- };
82
- subText = {
83
- text: "",
84
- fill: "white",
85
- textFill: "#555555",
86
- ...subText
87
- };
88
-
89
- const annoOffsetY = 0;
90
- const labelWidth = React.useMemo(() => {
91
- return Utility.textSize(text, textFontFamily, textHeight, false).width;
92
- }, [text, textFontFamily, textHeight]);
93
-
94
- let labelShapeWidth = 0;
95
- if (text !== "") {
96
- labelShapeWidth = labelWidth + (textPadding * 2) + (textboxStrokeWidth * 2);
97
- }
98
- let fullAnnotationWidth = labelShapeWidth + annotationGutter;
99
- const textOffsetX = fullAnnotationWidth - (labelShapeWidth / 2);
100
-
101
- const textShapeHeight = textHeight + (annotationGutter * 2) + (textboxStrokeWidth * 2);
102
- const annoWidthArr = annotations.map((anno, i) => {
103
- return Utility.textSize(anno.imageChar, anno.imageFontFamily, anno.height, false).width;
104
- });
105
- const annotationArr = [];
106
- let _labelAnnoOffsetX = fullAnnotationWidth;
107
- annotations.forEach((anno, i) => {
108
- const annoText = anno.imageChar;
109
- const annoTextHeight = anno.height ?? textShapeHeight;
110
- _labelAnnoOffsetX += annoWidthArr[i] + annotationGutter;
111
- const annoOffsetX = _labelAnnoOffsetX - (annoWidthArr[i] / 2);
112
- annotationArr.push(
113
- <g key={i} class="vertex3-anno" data-click={"annotation"} data-click-data={JSON.stringify(anno)} transform={`translate(${annoOffsetX} ${annoOffsetY})`}>
114
- <Icon
115
- {...anno}
116
- shape="rectangle"
117
- width={annoWidthArr[i]}
118
- height={annoTextHeight}
119
- imageChar={annoText}
120
- imageFontFamily={anno.imageFontFamily}
121
- cornerRadius={cornerRadius}
122
- strokeWidth={0}
123
- />
124
- </g>
125
- );
126
- });
127
-
128
- if (annotations.length > 0) {
129
- fullAnnotationWidth += annotationGutter * (annotations.length - 1);
130
- }
131
- const iconAnnotationArr = [];
132
- iconAnnotations.forEach((anno, i) => {
133
- const x = anno.shapeOffsetX;
134
- const y = anno.shapeOffsetY;
135
- iconAnnotationArr.push(
136
- <g key={i} class="vertex3-iconAnno" data-click={"icon-annotation"} data-click-data={JSON.stringify(anno)} transform={`translate(${x} ${y})`}>
137
- <Icon
138
- {...anno}
139
- shape={anno.shape ?? "square"}
140
- imageChar={anno.imageChar}
141
- imageFontFamily={anno.imageFontFamily}
142
- cornerRadius={cornerRadius}
143
- stroke={anno.stroke}
144
- strokeWidth={anno.strokeWidth}
145
- />
146
- </g>
147
- );
148
- });
149
-
150
- const textElement = <g data-click={"text"} transform={`translate(${textOffsetX} ${annoOffsetY})`}>
151
- {!showLabel || text === "" ? <circle r={noLabelRadius} stroke={textboxStroke} fill={textFill} /> : <TextBox
152
- text={text}
153
- height={textHeight}
154
- padding={textPadding}
155
- strokeWidth={textboxStrokeWidth}
156
- stroke={textboxStroke}
157
- fill={textboxFill}
158
- textFill={textFill}
159
- fontFamily={textFontFamily}
160
- cornerRadius={cornerRadius}
161
- />}
162
- </g>;
163
-
164
- const subTextOffsetX = 0;
165
- const subTextOffsetY = textShapeHeight + (annotationGutter * 2);
166
-
167
- const subtextElement = subText.text === "" ? null : <g data-click={"subtext"}
168
- transform={`translate(${subTextOffsetX} ${subTextOffsetY})`}
169
- >
170
- <TextBox
171
- fill={subText.fill || "#FFFFFF"}
172
- textFill={subText.textFill || textFill}
173
- {...subText}
174
- height={textHeight}
175
- padding={textPadding}
176
- strokeWidth={0}
177
- stroke={textboxStroke}
178
- fontFamily={textFontFamily}
179
- cornerRadius={cornerRadius}
180
- />
181
- </g>;
182
- return <g>
183
- <g data-click={"icon"}
184
- transform={`translate(${shapeOffsetX} ${shapeOffsetY})`}
185
- >
186
- <Icon
187
- {...icon}
188
- strokeWidth={iconBorderWidth}
189
- shape="circle"
190
- height={iconFontSize}
191
- fill={iconBackgroundColor}
192
- stroke={iconBorderColor}
193
- imageFontFamily={iconFontFamily}
194
- imageChar={iconText}
195
- imageCharFill={iconFontColor}
196
- padding={iconPadding}
197
- xOffset={iconOffsetX}
198
- yOffset={iconOffsetY}
199
- cornerRadius={cornerRadius}
200
- shapeRendering={shapeRendering}
201
- />
202
- {iconAnnotationArr}
203
- </g>
204
- <g
205
- transform={`translate(${-fullAnnotationWidth / 2} ${annoOffsetY})`}
206
- >
207
- {textElement}
208
- {annotationArr}
209
- </g>
210
- {subtextElement}
211
- </g>
212
- ;
213
- };
214
-
215
- export const CentroidVertex4: React.FunctionComponent<IVertex4> = function ({
216
- id,
217
- categoryID = "",
218
- text = "",
219
- textHeight = 12,
220
- textPadding = 10,
221
- textFill = "#287EC4",
222
- textboxFill = "white",
223
- textboxStroke = "#CCCCCC",
224
- textboxStrokeWidth = 1,
225
- textFontFamily = "Verdana",
226
- annotationGutter = 2,
227
- annotations = [],
228
- iconAnnotations = [],
229
- cornerRadius,
230
- icon = {},
231
- subText = {},
232
- showLabel = true,
233
- noLabelRadius = 5,
234
-
235
- iconBorderWidth = 1,
236
- iconBorderColor = "#333",
237
-
238
- iconBackgroundColor = "#fff",
239
-
240
- iconFontColor = "#000",
241
- iconFontSize = 20,
242
- iconFontFamily = "FontAwesome",
243
-
244
- shapeOffsetX = 0,
245
- shapeOffsetY = 0,
246
- iconOffsetX = 0,
247
- iconOffsetY = 0,
248
-
249
- iconPadding = 4,
250
- iconText = "?",
251
- shapeRendering = "auto"
252
- }) {
253
- icon = {
254
- height: 91,
255
- padding: 40,
256
- imageCharFill: "#555555",
257
- imageFontFamily: "FontAwesome",
258
- fill: "#FFCC33",
259
- stroke: "#DFDFDF",
260
- imageChar: "?",
261
- strokeWidth: 4,
262
- yOffset: -15,
263
- ...icon
264
- };
265
- subText = {
266
- text: "",
267
- fill: "transparent",
268
- textFill: "#555555",
269
- ...subText
270
- };
271
- const props = {
272
- id,
273
- categoryID,
274
- text,
275
- textHeight,
276
- textPadding,
277
- textFill,
278
- textboxFill,
279
- textboxStroke,
280
- textboxStrokeWidth,
281
- textFontFamily,
282
- annotationGutter,
283
- annotations,
284
- iconAnnotations,
285
- cornerRadius,
286
- icon,
287
- subText,
288
- showLabel,
289
- noLabelRadius,
290
- iconBorderWidth,
291
- iconBorderColor,
292
- iconBackgroundColor,
293
- iconFontColor,
294
- iconFontSize,
295
- iconFontFamily,
296
- shapeOffsetX,
297
- shapeOffsetY,
298
- iconOffsetX,
299
- iconOffsetY,
300
- iconPadding,
301
- iconText,
302
- shapeRendering
303
- };
304
- return <Vertex4
305
- {...props}
306
- icon={icon}
307
- subText={subText}
308
- />;
309
- };
1
+ /* eslint-disable no-debugger, no-console */
2
+ import { Utility } from "@hpcc-js/common";
3
+ import * as React from "@hpcc-js/preact-shim";
4
+ import { Icon } from "./icon";
5
+ import { TextBox } from "./text";
6
+ import { VertexProps } from "./vertex";
7
+
8
+ export interface IVertex4Annotation extends Icon {
9
+ shapeOffsetX?: number;
10
+ shapeOffsetY?: number;
11
+ }
12
+
13
+ export interface IVertex4 extends VertexProps {
14
+ textboxStrokeWidth?: number;
15
+ annotations?: IVertex4Annotation[];
16
+ iconAnnotations?: IVertex4Annotation[];
17
+ annotationGutter?: number;
18
+ cornerRadius?: number;
19
+ subText?: any;
20
+ noLabelRadius?: number;
21
+ iconBorderWidth?: number;
22
+ iconBorderColor?: string;
23
+ iconBackgroundColor?: string;
24
+ shapeOffsetX?: number;
25
+ shapeOffsetY?: number;
26
+ iconOffsetX?: number;
27
+ iconOffsetY?: number;
28
+ iconPadding?: number;
29
+ iconFontSize?: number;
30
+ iconFontColor?: string;
31
+ iconFontFamily?: string;
32
+ iconText?: string;
33
+ shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
34
+ }
35
+
36
+ export const Vertex4: React.FunctionComponent<IVertex4> = ({
37
+ categoryID = "",
38
+ text = "",
39
+ textHeight = 10,
40
+ textPadding = 4,
41
+ textFill = "#287EC4",
42
+ textboxFill = "white",
43
+ textboxStroke = "#CCCCCC",
44
+ textboxStrokeWidth = 1,
45
+ textFontFamily = "Verdana",
46
+ annotationGutter = 2,
47
+ annotations = [],
48
+ iconAnnotations = [],
49
+ cornerRadius = 3,
50
+ icon = {},
51
+ subText = {},
52
+ showLabel = true,
53
+ noLabelRadius = 5,
54
+
55
+ iconBorderWidth = 1,
56
+ iconBorderColor = "#333",
57
+
58
+ iconBackgroundColor = "#fff",
59
+
60
+ iconFontColor = "#000",
61
+ iconFontSize = 20,
62
+ iconFontFamily = "FontAwesome",
63
+
64
+ shapeOffsetX = 0,
65
+ shapeOffsetY = 0,
66
+ iconOffsetX = 0,
67
+ iconOffsetY = 0,
68
+
69
+ iconPadding = 4,
70
+ iconText = "?",
71
+ shapeRendering = "auto"
72
+ }) => {
73
+ icon = {
74
+ height: 50,
75
+ imageChar: "?",
76
+ imageFontFamily: "FontAwesome",
77
+ imageCharFill: "#555555",
78
+ fill: "transparent",
79
+ strokeWidth: 0,
80
+ ...icon
81
+ };
82
+ subText = {
83
+ text: "",
84
+ fill: "white",
85
+ textFill: "#555555",
86
+ ...subText
87
+ };
88
+
89
+ const annoOffsetY = 0;
90
+ const labelWidth = React.useMemo(() => {
91
+ return Utility.textSize(text, textFontFamily, textHeight, false).width;
92
+ }, [text, textFontFamily, textHeight]);
93
+
94
+ let labelShapeWidth = 0;
95
+ if (text !== "") {
96
+ labelShapeWidth = labelWidth + (textPadding * 2) + (textboxStrokeWidth * 2);
97
+ }
98
+ let fullAnnotationWidth = labelShapeWidth + annotationGutter;
99
+ const textOffsetX = fullAnnotationWidth - (labelShapeWidth / 2);
100
+
101
+ const textShapeHeight = textHeight + (annotationGutter * 2) + (textboxStrokeWidth * 2);
102
+ const annoWidthArr = annotations.map((anno, i) => {
103
+ return Utility.textSize(anno.imageChar, anno.imageFontFamily, anno.height, false).width;
104
+ });
105
+ const annotationArr = [];
106
+ let _labelAnnoOffsetX = fullAnnotationWidth;
107
+ annotations.forEach((anno, i) => {
108
+ const annoText = anno.imageChar;
109
+ const annoTextHeight = anno.height ?? textShapeHeight;
110
+ _labelAnnoOffsetX += annoWidthArr[i] + annotationGutter;
111
+ const annoOffsetX = _labelAnnoOffsetX - (annoWidthArr[i] / 2);
112
+ annotationArr.push(
113
+ <g key={i} class="vertex3-anno" data-click={"annotation"} data-click-data={JSON.stringify(anno)} transform={`translate(${annoOffsetX} ${annoOffsetY})`}>
114
+ <Icon
115
+ {...anno}
116
+ shape="rectangle"
117
+ width={annoWidthArr[i]}
118
+ height={annoTextHeight}
119
+ imageChar={annoText}
120
+ imageFontFamily={anno.imageFontFamily}
121
+ cornerRadius={cornerRadius}
122
+ strokeWidth={0}
123
+ />
124
+ </g>
125
+ );
126
+ });
127
+
128
+ if (annotations.length > 0) {
129
+ fullAnnotationWidth += annotationGutter * (annotations.length - 1);
130
+ }
131
+ const iconAnnotationArr = [];
132
+ iconAnnotations.forEach((anno, i) => {
133
+ const x = anno.shapeOffsetX;
134
+ const y = anno.shapeOffsetY;
135
+ iconAnnotationArr.push(
136
+ <g key={i} class="vertex3-iconAnno" data-click={"icon-annotation"} data-click-data={JSON.stringify(anno)} transform={`translate(${x} ${y})`}>
137
+ <Icon
138
+ {...anno}
139
+ shape={anno.shape ?? "square"}
140
+ imageChar={anno.imageChar}
141
+ imageFontFamily={anno.imageFontFamily}
142
+ cornerRadius={cornerRadius}
143
+ stroke={anno.stroke}
144
+ strokeWidth={anno.strokeWidth}
145
+ />
146
+ </g>
147
+ );
148
+ });
149
+
150
+ const textElement = <g data-click={"text"} transform={`translate(${textOffsetX} ${annoOffsetY})`}>
151
+ {!showLabel || text === "" ? <circle r={noLabelRadius} stroke={textboxStroke} fill={textFill} /> : <TextBox
152
+ text={text}
153
+ height={textHeight}
154
+ padding={textPadding}
155
+ strokeWidth={textboxStrokeWidth}
156
+ stroke={textboxStroke}
157
+ fill={textboxFill}
158
+ textFill={textFill}
159
+ fontFamily={textFontFamily}
160
+ cornerRadius={cornerRadius}
161
+ />}
162
+ </g>;
163
+
164
+ const subTextOffsetX = 0;
165
+ const subTextOffsetY = textShapeHeight + (annotationGutter * 2);
166
+
167
+ const subtextElement = subText.text === "" ? null : <g data-click={"subtext"}
168
+ transform={`translate(${subTextOffsetX} ${subTextOffsetY})`}
169
+ >
170
+ <TextBox
171
+ fill={subText.fill || "#FFFFFF"}
172
+ textFill={subText.textFill || textFill}
173
+ {...subText}
174
+ height={textHeight}
175
+ padding={textPadding}
176
+ strokeWidth={0}
177
+ stroke={textboxStroke}
178
+ fontFamily={textFontFamily}
179
+ cornerRadius={cornerRadius}
180
+ />
181
+ </g>;
182
+ return <g>
183
+ <g data-click={"icon"}
184
+ transform={`translate(${shapeOffsetX} ${shapeOffsetY})`}
185
+ >
186
+ <Icon
187
+ {...icon}
188
+ strokeWidth={iconBorderWidth}
189
+ shape="circle"
190
+ height={iconFontSize}
191
+ fill={iconBackgroundColor}
192
+ stroke={iconBorderColor}
193
+ imageFontFamily={iconFontFamily}
194
+ imageChar={iconText}
195
+ imageCharFill={iconFontColor}
196
+ padding={iconPadding}
197
+ xOffset={iconOffsetX}
198
+ yOffset={iconOffsetY}
199
+ cornerRadius={cornerRadius}
200
+ shapeRendering={shapeRendering}
201
+ />
202
+ {iconAnnotationArr}
203
+ </g>
204
+ <g
205
+ transform={`translate(${-fullAnnotationWidth / 2} ${annoOffsetY})`}
206
+ >
207
+ {textElement}
208
+ {annotationArr}
209
+ </g>
210
+ {subtextElement}
211
+ </g>
212
+ ;
213
+ };
214
+
215
+ export const CentroidVertex4: React.FunctionComponent<IVertex4> = function ({
216
+ id,
217
+ categoryID = "",
218
+ text = "",
219
+ textHeight = 12,
220
+ textPadding = 10,
221
+ textFill = "#287EC4",
222
+ textboxFill = "white",
223
+ textboxStroke = "#CCCCCC",
224
+ textboxStrokeWidth = 1,
225
+ textFontFamily = "Verdana",
226
+ annotationGutter = 2,
227
+ annotations = [],
228
+ iconAnnotations = [],
229
+ cornerRadius,
230
+ icon = {},
231
+ subText = {},
232
+ showLabel = true,
233
+ noLabelRadius = 5,
234
+
235
+ iconBorderWidth = 1,
236
+ iconBorderColor = "#333",
237
+
238
+ iconBackgroundColor = "#fff",
239
+
240
+ iconFontColor = "#000",
241
+ iconFontSize = 20,
242
+ iconFontFamily = "FontAwesome",
243
+
244
+ shapeOffsetX = 0,
245
+ shapeOffsetY = 0,
246
+ iconOffsetX = 0,
247
+ iconOffsetY = 0,
248
+
249
+ iconPadding = 4,
250
+ iconText = "?",
251
+ shapeRendering = "auto"
252
+ }) {
253
+ icon = {
254
+ height: 91,
255
+ padding: 40,
256
+ imageCharFill: "#555555",
257
+ imageFontFamily: "FontAwesome",
258
+ fill: "#FFCC33",
259
+ stroke: "#DFDFDF",
260
+ imageChar: "?",
261
+ strokeWidth: 4,
262
+ yOffset: -15,
263
+ ...icon
264
+ };
265
+ subText = {
266
+ text: "",
267
+ fill: "transparent",
268
+ textFill: "#555555",
269
+ ...subText
270
+ };
271
+ const props = {
272
+ id,
273
+ categoryID,
274
+ text,
275
+ textHeight,
276
+ textPadding,
277
+ textFill,
278
+ textboxFill,
279
+ textboxStroke,
280
+ textboxStrokeWidth,
281
+ textFontFamily,
282
+ annotationGutter,
283
+ annotations,
284
+ iconAnnotations,
285
+ cornerRadius,
286
+ icon,
287
+ subText,
288
+ showLabel,
289
+ noLabelRadius,
290
+ iconBorderWidth,
291
+ iconBorderColor,
292
+ iconBackgroundColor,
293
+ iconFontColor,
294
+ iconFontSize,
295
+ iconFontFamily,
296
+ shapeOffsetX,
297
+ shapeOffsetY,
298
+ iconOffsetX,
299
+ iconOffsetY,
300
+ iconPadding,
301
+ iconText,
302
+ shapeRendering
303
+ };
304
+ return <Vertex4
305
+ {...props}
306
+ icon={icon}
307
+ subText={subText}
308
+ />;
309
+ };