@hpcc-js/react 3.4.15 → 3.4.16
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/LICENSE +43 -43
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +3 -3
- package/src/ImageChar.tsx +42 -42
- package/src/__package__.ts +3 -3
- package/src/edge.tsx +45 -45
- package/src/icon.tsx +95 -95
- package/src/image.tsx +25 -25
- package/src/index.ts +17 -17
- package/src/preact-shim.ts +4 -4
- package/src/render.ts +78 -78
- package/src/shape.tsx +138 -138
- package/src/span.tsx +9 -9
- package/src/subgraph.tsx +45 -45
- package/src/text.tsx +257 -257
- package/src/vertex.tsx +119 -119
- package/src/vertex2.tsx +100 -100
- package/src/vertex3.tsx +238 -238
- package/src/vertex4.tsx +308 -308
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hpcc-js/react",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.16",
|
|
4
4
|
"description": "hpcc-js - Viz React",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.umd.cjs",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"update-major": "npx --yes npm-check-updates -u"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@hpcc-js/common": "^3.7.
|
|
40
|
+
"@hpcc-js/common": "^3.7.6"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@hpcc-js/esbuild-plugins": "^1.8.7",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"url": "https://github.com/hpcc-systems/Visualization/issues"
|
|
56
56
|
},
|
|
57
57
|
"homepage": "https://github.com/hpcc-systems/Visualization",
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "6f134126379fe058a052986758b792d7b4ddb84b"
|
|
59
59
|
}
|
package/src/ImageChar.tsx
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import * as PReact from "./preact-shim.ts";
|
|
2
|
-
import { Utility } from "@hpcc-js/common";
|
|
3
|
-
|
|
4
|
-
export interface ImageCharProps {
|
|
5
|
-
x?: number;
|
|
6
|
-
y?: number;
|
|
7
|
-
height?: number;
|
|
8
|
-
fill?: string;
|
|
9
|
-
stroke?: string;
|
|
10
|
-
fontFamily?: string;
|
|
11
|
-
char?: string;
|
|
12
|
-
yOffset?: number;
|
|
13
|
-
fontWeight?: number;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const ImageChar: PReact.FunctionComponent<ImageCharProps> = ({
|
|
17
|
-
x,
|
|
18
|
-
y = 0,
|
|
19
|
-
height = 12,
|
|
20
|
-
fill,
|
|
21
|
-
stroke,
|
|
22
|
-
fontFamily = "FontAwesome",
|
|
23
|
-
char = "",
|
|
24
|
-
fontWeight
|
|
25
|
-
}) => {
|
|
26
|
-
|
|
27
|
-
const renderChar = PReact.useMemo(() => {
|
|
28
|
-
return fontFamily === "FontAwesome" ? Utility.faChar(char) : char;
|
|
29
|
-
}, [char, fontFamily]);
|
|
30
|
-
|
|
31
|
-
return <text
|
|
32
|
-
x={x}
|
|
33
|
-
y={y}
|
|
34
|
-
fill={fill}
|
|
35
|
-
stroke={stroke}
|
|
36
|
-
fontFamily={fontFamily}
|
|
37
|
-
fontSize={`${height}px`}
|
|
38
|
-
fontWeight={fontWeight}
|
|
39
|
-
dominantBaseline="middle"
|
|
40
|
-
style={{ textAnchor: "middle", alignmentBaseline: "middle" }}
|
|
41
|
-
>{renderChar}</text>;
|
|
42
|
-
};
|
|
1
|
+
import * as PReact from "./preact-shim.ts";
|
|
2
|
+
import { Utility } from "@hpcc-js/common";
|
|
3
|
+
|
|
4
|
+
export interface ImageCharProps {
|
|
5
|
+
x?: number;
|
|
6
|
+
y?: number;
|
|
7
|
+
height?: number;
|
|
8
|
+
fill?: string;
|
|
9
|
+
stroke?: string;
|
|
10
|
+
fontFamily?: string;
|
|
11
|
+
char?: string;
|
|
12
|
+
yOffset?: number;
|
|
13
|
+
fontWeight?: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const ImageChar: PReact.FunctionComponent<ImageCharProps> = ({
|
|
17
|
+
x,
|
|
18
|
+
y = 0,
|
|
19
|
+
height = 12,
|
|
20
|
+
fill,
|
|
21
|
+
stroke,
|
|
22
|
+
fontFamily = "FontAwesome",
|
|
23
|
+
char = "",
|
|
24
|
+
fontWeight
|
|
25
|
+
}) => {
|
|
26
|
+
|
|
27
|
+
const renderChar = PReact.useMemo(() => {
|
|
28
|
+
return fontFamily === "FontAwesome" ? Utility.faChar(char) : char;
|
|
29
|
+
}, [char, fontFamily]);
|
|
30
|
+
|
|
31
|
+
return <text
|
|
32
|
+
x={x}
|
|
33
|
+
y={y}
|
|
34
|
+
fill={fill}
|
|
35
|
+
stroke={stroke}
|
|
36
|
+
fontFamily={fontFamily}
|
|
37
|
+
fontSize={`${height}px`}
|
|
38
|
+
fontWeight={fontWeight}
|
|
39
|
+
dominantBaseline="middle"
|
|
40
|
+
style={{ textAnchor: "middle", alignmentBaseline: "middle" }}
|
|
41
|
+
>{renderChar}</text>;
|
|
42
|
+
};
|
package/src/__package__.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const PKG_NAME = "__PACKAGE_NAME__";
|
|
2
|
-
export const PKG_VERSION = "__PACKAGE_VERSION__";
|
|
3
|
-
export const BUILD_VERSION = "__BUILD_VERSION__";
|
|
1
|
+
export const PKG_NAME = "__PACKAGE_NAME__";
|
|
2
|
+
export const PKG_VERSION = "__PACKAGE_VERSION__";
|
|
3
|
+
export const BUILD_VERSION = "__BUILD_VERSION__";
|
package/src/edge.tsx
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import * as PReact from "./preact-shim.ts";
|
|
2
|
-
import { VertexProps } from "./vertex.tsx";
|
|
3
|
-
import { Text } from "./text.tsx";
|
|
4
|
-
|
|
5
|
-
type Point = [number, number];
|
|
6
|
-
|
|
7
|
-
export interface EdgeProps<V extends VertexProps = VertexProps> {
|
|
8
|
-
id: string | number;
|
|
9
|
-
origData?: any;
|
|
10
|
-
source: V;
|
|
11
|
-
target: V;
|
|
12
|
-
label?: string;
|
|
13
|
-
labelPos?: Point;
|
|
14
|
-
weight?: number;
|
|
15
|
-
strokeDasharray?: string;
|
|
16
|
-
strokeWidth?: number;
|
|
17
|
-
stroke?: string;
|
|
18
|
-
fontFamily?: string;
|
|
19
|
-
labelFill?: string;
|
|
20
|
-
labelHeight?: number,
|
|
21
|
-
path?: string;
|
|
22
|
-
points?: Array<[number, number]>;
|
|
23
|
-
curveDepth?: number;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const Edge: PReact.FunctionComponent<EdgeProps> = ({
|
|
27
|
-
label,
|
|
28
|
-
labelPos,
|
|
29
|
-
labelFill = "black",
|
|
30
|
-
labelHeight = 12,
|
|
31
|
-
path,
|
|
32
|
-
stroke,
|
|
33
|
-
strokeWidth,
|
|
34
|
-
strokeDasharray
|
|
35
|
-
}) => {
|
|
36
|
-
return <>
|
|
37
|
-
<path d={path} stroke={stroke} style={{ strokeWidth, strokeDasharray }}></path>
|
|
38
|
-
{
|
|
39
|
-
label && labelPos && labelPos.length === 2 ?
|
|
40
|
-
<g transform={`translate(${labelPos[0]} ${labelPos[1]})`}>
|
|
41
|
-
<Text text={label} fill={labelFill} height={labelHeight} />
|
|
42
|
-
</g> : undefined
|
|
43
|
-
}
|
|
44
|
-
</>;
|
|
45
|
-
};
|
|
1
|
+
import * as PReact from "./preact-shim.ts";
|
|
2
|
+
import { VertexProps } from "./vertex.tsx";
|
|
3
|
+
import { Text } from "./text.tsx";
|
|
4
|
+
|
|
5
|
+
type Point = [number, number];
|
|
6
|
+
|
|
7
|
+
export interface EdgeProps<V extends VertexProps = VertexProps> {
|
|
8
|
+
id: string | number;
|
|
9
|
+
origData?: any;
|
|
10
|
+
source: V;
|
|
11
|
+
target: V;
|
|
12
|
+
label?: string;
|
|
13
|
+
labelPos?: Point;
|
|
14
|
+
weight?: number;
|
|
15
|
+
strokeDasharray?: string;
|
|
16
|
+
strokeWidth?: number;
|
|
17
|
+
stroke?: string;
|
|
18
|
+
fontFamily?: string;
|
|
19
|
+
labelFill?: string;
|
|
20
|
+
labelHeight?: number,
|
|
21
|
+
path?: string;
|
|
22
|
+
points?: Array<[number, number]>;
|
|
23
|
+
curveDepth?: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const Edge: PReact.FunctionComponent<EdgeProps> = ({
|
|
27
|
+
label,
|
|
28
|
+
labelPos,
|
|
29
|
+
labelFill = "black",
|
|
30
|
+
labelHeight = 12,
|
|
31
|
+
path,
|
|
32
|
+
stroke,
|
|
33
|
+
strokeWidth,
|
|
34
|
+
strokeDasharray
|
|
35
|
+
}) => {
|
|
36
|
+
return <>
|
|
37
|
+
<path d={path} stroke={stroke} style={{ strokeWidth, strokeDasharray }}></path>
|
|
38
|
+
{
|
|
39
|
+
label && labelPos && labelPos.length === 2 ?
|
|
40
|
+
<g transform={`translate(${labelPos[0]} ${labelPos[1]})`}>
|
|
41
|
+
<Text text={label} fill={labelFill} height={labelHeight} />
|
|
42
|
+
</g> : undefined
|
|
43
|
+
}
|
|
44
|
+
</>;
|
|
45
|
+
};
|
package/src/icon.tsx
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
import * as PReact from "./preact-shim.ts";
|
|
2
|
-
import { Palette } from "@hpcc-js/common";
|
|
3
|
-
import { Image } from "./image.tsx";
|
|
4
|
-
import { ImageChar } from "./ImageChar.tsx";
|
|
5
|
-
import { Shape } from "./shape.tsx";
|
|
6
|
-
|
|
7
|
-
export interface IconProps {
|
|
8
|
-
shape?: "circle" | "square" | "rectangle";
|
|
9
|
-
width?: number;
|
|
10
|
-
height?: number;
|
|
11
|
-
padding?: number;
|
|
12
|
-
fill?: string;
|
|
13
|
-
stroke?: string;
|
|
14
|
-
strokeWidth?: number;
|
|
15
|
-
imageUrl?: string;
|
|
16
|
-
imageFontFamily?: string;
|
|
17
|
-
imageChar?: string;
|
|
18
|
-
imageCharFill?: string;
|
|
19
|
-
xOffset?: number;
|
|
20
|
-
yOffset?: number;
|
|
21
|
-
cornerRadius?: number;
|
|
22
|
-
shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const Icon: PReact.FunctionComponent<IconProps> = ({
|
|
26
|
-
shape = "circle",
|
|
27
|
-
width,
|
|
28
|
-
height = 32,
|
|
29
|
-
fill,
|
|
30
|
-
stroke,
|
|
31
|
-
strokeWidth = 0,
|
|
32
|
-
imageUrl = "",
|
|
33
|
-
imageFontFamily = "FontAwesome",
|
|
34
|
-
imageChar = "",
|
|
35
|
-
imageCharFill = Palette.textColor(fill),
|
|
36
|
-
padding = height / 5,
|
|
37
|
-
xOffset = 0,
|
|
38
|
-
yOffset = 0,
|
|
39
|
-
cornerRadius,
|
|
40
|
-
shapeRendering
|
|
41
|
-
}) => {
|
|
42
|
-
return <>
|
|
43
|
-
<Shape
|
|
44
|
-
shape={shape}
|
|
45
|
-
width={width}
|
|
46
|
-
height={height}
|
|
47
|
-
fill={fill}
|
|
48
|
-
stroke={stroke}
|
|
49
|
-
strokeWidth={strokeWidth}
|
|
50
|
-
shapeRendering={shapeRendering}
|
|
51
|
-
cornerRadius={cornerRadius}
|
|
52
|
-
/>
|
|
53
|
-
{imageUrl ?
|
|
54
|
-
<Image
|
|
55
|
-
href={imageUrl}
|
|
56
|
-
x={xOffset}
|
|
57
|
-
y={yOffset}
|
|
58
|
-
height={height - padding}
|
|
59
|
-
></Image> :
|
|
60
|
-
<ImageChar
|
|
61
|
-
x={xOffset}
|
|
62
|
-
y={yOffset}
|
|
63
|
-
height={height - padding}
|
|
64
|
-
fontFamily={imageFontFamily}
|
|
65
|
-
char={imageChar}
|
|
66
|
-
fill={imageCharFill}
|
|
67
|
-
fontWeight={400}
|
|
68
|
-
></ImageChar>
|
|
69
|
-
}
|
|
70
|
-
</>;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export interface IconEx extends IconProps {
|
|
74
|
-
id: string;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export interface IconsProps {
|
|
78
|
-
icons: IconEx[];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export const Icons: PReact.FunctionComponent<IconsProps> = ({
|
|
82
|
-
icons = []
|
|
83
|
-
}) => {
|
|
84
|
-
const IconComponents = icons.map(cat => {
|
|
85
|
-
return <g
|
|
86
|
-
key={cat.id}
|
|
87
|
-
id={cat.id}
|
|
88
|
-
>
|
|
89
|
-
<Icon
|
|
90
|
-
{...cat}
|
|
91
|
-
/>
|
|
92
|
-
</g>;
|
|
93
|
-
});
|
|
94
|
-
return <>{IconComponents}</>;
|
|
95
|
-
};
|
|
1
|
+
import * as PReact from "./preact-shim.ts";
|
|
2
|
+
import { Palette } from "@hpcc-js/common";
|
|
3
|
+
import { Image } from "./image.tsx";
|
|
4
|
+
import { ImageChar } from "./ImageChar.tsx";
|
|
5
|
+
import { Shape } from "./shape.tsx";
|
|
6
|
+
|
|
7
|
+
export interface IconProps {
|
|
8
|
+
shape?: "circle" | "square" | "rectangle";
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
padding?: number;
|
|
12
|
+
fill?: string;
|
|
13
|
+
stroke?: string;
|
|
14
|
+
strokeWidth?: number;
|
|
15
|
+
imageUrl?: string;
|
|
16
|
+
imageFontFamily?: string;
|
|
17
|
+
imageChar?: string;
|
|
18
|
+
imageCharFill?: string;
|
|
19
|
+
xOffset?: number;
|
|
20
|
+
yOffset?: number;
|
|
21
|
+
cornerRadius?: number;
|
|
22
|
+
shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const Icon: PReact.FunctionComponent<IconProps> = ({
|
|
26
|
+
shape = "circle",
|
|
27
|
+
width,
|
|
28
|
+
height = 32,
|
|
29
|
+
fill,
|
|
30
|
+
stroke,
|
|
31
|
+
strokeWidth = 0,
|
|
32
|
+
imageUrl = "",
|
|
33
|
+
imageFontFamily = "FontAwesome",
|
|
34
|
+
imageChar = "",
|
|
35
|
+
imageCharFill = Palette.textColor(fill),
|
|
36
|
+
padding = height / 5,
|
|
37
|
+
xOffset = 0,
|
|
38
|
+
yOffset = 0,
|
|
39
|
+
cornerRadius,
|
|
40
|
+
shapeRendering
|
|
41
|
+
}) => {
|
|
42
|
+
return <>
|
|
43
|
+
<Shape
|
|
44
|
+
shape={shape}
|
|
45
|
+
width={width}
|
|
46
|
+
height={height}
|
|
47
|
+
fill={fill}
|
|
48
|
+
stroke={stroke}
|
|
49
|
+
strokeWidth={strokeWidth}
|
|
50
|
+
shapeRendering={shapeRendering}
|
|
51
|
+
cornerRadius={cornerRadius}
|
|
52
|
+
/>
|
|
53
|
+
{imageUrl ?
|
|
54
|
+
<Image
|
|
55
|
+
href={imageUrl}
|
|
56
|
+
x={xOffset}
|
|
57
|
+
y={yOffset}
|
|
58
|
+
height={height - padding}
|
|
59
|
+
></Image> :
|
|
60
|
+
<ImageChar
|
|
61
|
+
x={xOffset}
|
|
62
|
+
y={yOffset}
|
|
63
|
+
height={height - padding}
|
|
64
|
+
fontFamily={imageFontFamily}
|
|
65
|
+
char={imageChar}
|
|
66
|
+
fill={imageCharFill}
|
|
67
|
+
fontWeight={400}
|
|
68
|
+
></ImageChar>
|
|
69
|
+
}
|
|
70
|
+
</>;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export interface IconEx extends IconProps {
|
|
74
|
+
id: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface IconsProps {
|
|
78
|
+
icons: IconEx[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const Icons: PReact.FunctionComponent<IconsProps> = ({
|
|
82
|
+
icons = []
|
|
83
|
+
}) => {
|
|
84
|
+
const IconComponents = icons.map(cat => {
|
|
85
|
+
return <g
|
|
86
|
+
key={cat.id}
|
|
87
|
+
id={cat.id}
|
|
88
|
+
>
|
|
89
|
+
<Icon
|
|
90
|
+
{...cat}
|
|
91
|
+
/>
|
|
92
|
+
</g>;
|
|
93
|
+
});
|
|
94
|
+
return <>{IconComponents}</>;
|
|
95
|
+
};
|
package/src/image.tsx
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import * as PReact from "./preact-shim.ts";
|
|
2
|
-
|
|
3
|
-
interface ImageProps {
|
|
4
|
-
href: string;
|
|
5
|
-
x?: number;
|
|
6
|
-
y?: number;
|
|
7
|
-
height?: number;
|
|
8
|
-
yOffset?: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const Image: PReact.FunctionComponent<ImageProps> = ({
|
|
12
|
-
href,
|
|
13
|
-
x,
|
|
14
|
-
y = 0,
|
|
15
|
-
height = 12
|
|
16
|
-
}) => {
|
|
17
|
-
|
|
18
|
-
return <image
|
|
19
|
-
xlinkHref={href}
|
|
20
|
-
x={x - height / 2}
|
|
21
|
-
y={y - height / 2}
|
|
22
|
-
width={height}
|
|
23
|
-
height={height}
|
|
24
|
-
></image>;
|
|
25
|
-
};
|
|
1
|
+
import * as PReact from "./preact-shim.ts";
|
|
2
|
+
|
|
3
|
+
interface ImageProps {
|
|
4
|
+
href: string;
|
|
5
|
+
x?: number;
|
|
6
|
+
y?: number;
|
|
7
|
+
height?: number;
|
|
8
|
+
yOffset?: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const Image: PReact.FunctionComponent<ImageProps> = ({
|
|
12
|
+
href,
|
|
13
|
+
x,
|
|
14
|
+
y = 0,
|
|
15
|
+
height = 12
|
|
16
|
+
}) => {
|
|
17
|
+
|
|
18
|
+
return <image
|
|
19
|
+
xlinkHref={href}
|
|
20
|
+
x={x - height / 2}
|
|
21
|
+
y={y - height / 2}
|
|
22
|
+
width={height}
|
|
23
|
+
height={height}
|
|
24
|
+
></image>;
|
|
25
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export * from "./__package__.ts";
|
|
2
|
-
|
|
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";
|
|
16
|
-
|
|
17
|
-
export * as React from "./preact-shim.ts";
|
|
1
|
+
export * from "./__package__.ts";
|
|
2
|
+
|
|
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";
|
|
16
|
+
|
|
17
|
+
export * as React from "./preact-shim.ts";
|
package/src/preact-shim.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createElement, Component, Fragment, h, render } from "preact";
|
|
2
|
-
export { unmountComponentAtNode } from "preact/compat";
|
|
3
|
-
export type { FunctionComponent } from "preact";
|
|
4
|
-
export { useCallback, useEffect, useLayoutEffect, useMemo, useReducer, useState } from "preact/hooks";
|
|
1
|
+
export { createElement, Component, Fragment, h, render } from "preact";
|
|
2
|
+
export { unmountComponentAtNode } from "preact/compat";
|
|
3
|
+
export type { FunctionComponent } from "preact";
|
|
4
|
+
export { useCallback, useEffect, useLayoutEffect, useMemo, useReducer, useState } from "preact/hooks";
|
package/src/render.ts
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import { h, FunctionComponent, render as preactRender } from "preact";
|
|
2
|
-
import { HTMLWidget, SVGWidget } from "@hpcc-js/common";
|
|
3
|
-
|
|
4
|
-
export function render<P>(C: FunctionComponent<P>, props: Readonly<P>, parent: Element | Document | ShadowRoot | DocumentFragment, replaceNode?: Element | Text) {
|
|
5
|
-
preactRender(h(C, props), parent, replaceNode);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function svgRender<P>(C: FunctionComponent<P>, props: Readonly<P>, parent: Element | Document | ShadowRoot | DocumentFragment, replaceNode?: Element | Text) {
|
|
9
|
-
preactRender(h("svg", null, h(C, props)), parent, replaceNode);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class HTMLAdapter<P> extends HTMLWidget {
|
|
13
|
-
|
|
14
|
-
props(): P;
|
|
15
|
-
props(_: Partial<P>): this;
|
|
16
|
-
props(_?: Partial<P>): P | this {
|
|
17
|
-
if (!arguments.length) return this._props;
|
|
18
|
-
this._props = { ...this._props, ..._ };
|
|
19
|
-
return this;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
prop<K extends keyof P>(_: K): P[K];
|
|
23
|
-
prop<K extends keyof P>(_: K, value: P[K]): this;
|
|
24
|
-
prop<K extends keyof P>(_: K, value?: P[K]): this | P[K] {
|
|
25
|
-
if (arguments.length === 1) return this._props[_];
|
|
26
|
-
this._props[_] = value;
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
constructor(protected readonly _component: FunctionComponent<P>) {
|
|
31
|
-
super();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
update(domNode, element) {
|
|
35
|
-
super.update(domNode, element);
|
|
36
|
-
render(this._component, this._props, domNode);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
HTMLAdapter.prototype._class += " react_HTMLAdapter";
|
|
40
|
-
|
|
41
|
-
export interface HTMLAdapter<P> {
|
|
42
|
-
_props: P;
|
|
43
|
-
}
|
|
44
|
-
HTMLAdapter.prototype.publish("props", {}, "object", "Properties");
|
|
45
|
-
|
|
46
|
-
export class SVGAdapter<P> extends SVGWidget {
|
|
47
|
-
|
|
48
|
-
props(): P;
|
|
49
|
-
props(_: Partial<P>): this;
|
|
50
|
-
props(_?: Partial<P>): P | this {
|
|
51
|
-
if (!arguments.length) return this._props;
|
|
52
|
-
this._props = { ...this._props, ..._ };
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
prop<K extends keyof P>(_: K): P[K];
|
|
57
|
-
prop<K extends keyof P>(_: K, value: P[K]): this;
|
|
58
|
-
prop<K extends keyof P>(_: K, value?: P[K]): this | P[K] {
|
|
59
|
-
if (arguments.length === 1) return this._props[_];
|
|
60
|
-
this._props[_] = value;
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
constructor(protected readonly _component: FunctionComponent<P>) {
|
|
65
|
-
super();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
update(domNode, element) {
|
|
69
|
-
super.update(domNode, element);
|
|
70
|
-
render(this._component, this._props, domNode);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
SVGAdapter.prototype._class += " react_SVGAdapter";
|
|
74
|
-
|
|
75
|
-
export interface SVGAdapter<P> {
|
|
76
|
-
_props: P;
|
|
77
|
-
}
|
|
78
|
-
SVGAdapter.prototype.publish("props", {}, "object", "Properties");
|
|
1
|
+
import { h, FunctionComponent, render as preactRender } from "preact";
|
|
2
|
+
import { HTMLWidget, SVGWidget } from "@hpcc-js/common";
|
|
3
|
+
|
|
4
|
+
export function render<P>(C: FunctionComponent<P>, props: Readonly<P>, parent: Element | Document | ShadowRoot | DocumentFragment, replaceNode?: Element | Text) {
|
|
5
|
+
preactRender(h(C, props), parent, replaceNode);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function svgRender<P>(C: FunctionComponent<P>, props: Readonly<P>, parent: Element | Document | ShadowRoot | DocumentFragment, replaceNode?: Element | Text) {
|
|
9
|
+
preactRender(h("svg", null, h(C, props)), parent, replaceNode);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class HTMLAdapter<P> extends HTMLWidget {
|
|
13
|
+
|
|
14
|
+
props(): P;
|
|
15
|
+
props(_: Partial<P>): this;
|
|
16
|
+
props(_?: Partial<P>): P | this {
|
|
17
|
+
if (!arguments.length) return this._props;
|
|
18
|
+
this._props = { ...this._props, ..._ };
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
prop<K extends keyof P>(_: K): P[K];
|
|
23
|
+
prop<K extends keyof P>(_: K, value: P[K]): this;
|
|
24
|
+
prop<K extends keyof P>(_: K, value?: P[K]): this | P[K] {
|
|
25
|
+
if (arguments.length === 1) return this._props[_];
|
|
26
|
+
this._props[_] = value;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
constructor(protected readonly _component: FunctionComponent<P>) {
|
|
31
|
+
super();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
update(domNode, element) {
|
|
35
|
+
super.update(domNode, element);
|
|
36
|
+
render(this._component, this._props, domNode);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
HTMLAdapter.prototype._class += " react_HTMLAdapter";
|
|
40
|
+
|
|
41
|
+
export interface HTMLAdapter<P> {
|
|
42
|
+
_props: P;
|
|
43
|
+
}
|
|
44
|
+
HTMLAdapter.prototype.publish("props", {}, "object", "Properties");
|
|
45
|
+
|
|
46
|
+
export class SVGAdapter<P> extends SVGWidget {
|
|
47
|
+
|
|
48
|
+
props(): P;
|
|
49
|
+
props(_: Partial<P>): this;
|
|
50
|
+
props(_?: Partial<P>): P | this {
|
|
51
|
+
if (!arguments.length) return this._props;
|
|
52
|
+
this._props = { ...this._props, ..._ };
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
prop<K extends keyof P>(_: K): P[K];
|
|
57
|
+
prop<K extends keyof P>(_: K, value: P[K]): this;
|
|
58
|
+
prop<K extends keyof P>(_: K, value?: P[K]): this | P[K] {
|
|
59
|
+
if (arguments.length === 1) return this._props[_];
|
|
60
|
+
this._props[_] = value;
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
constructor(protected readonly _component: FunctionComponent<P>) {
|
|
65
|
+
super();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
update(domNode, element) {
|
|
69
|
+
super.update(domNode, element);
|
|
70
|
+
render(this._component, this._props, domNode);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
SVGAdapter.prototype._class += " react_SVGAdapter";
|
|
74
|
+
|
|
75
|
+
export interface SVGAdapter<P> {
|
|
76
|
+
_props: P;
|
|
77
|
+
}
|
|
78
|
+
SVGAdapter.prototype.publish("props", {}, "object", "Properties");
|