@hpcc-js/react 3.1.0 → 3.2.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/src/render.ts CHANGED
@@ -1,16 +1,15 @@
1
- import React from "react";
2
- import { render as reactRender } from "react-dom";
3
- import { createRoot, Root } from "react-dom/client";
1
+ import { h, FunctionComponent, render as preactRender } from "preact";
4
2
  import { HTMLWidget, SVGWidget } from "@hpcc-js/common";
5
3
 
6
- export function render<P>(C: React.FunctionComponent<P>, props: Readonly<P>, parent: Element | Document | ShadowRoot | DocumentFragment) {
7
- const re = React.createElement(C, props);
8
- reactRender(re, parent);
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);
9
6
  }
10
7
 
11
- export class HTMLAdapter<P> extends HTMLWidget {
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
+ }
12
11
 
13
- protected _root: Root;
12
+ export class HTMLAdapter<P> extends HTMLWidget {
14
13
 
15
14
  props(): P;
16
15
  props(_: Partial<P>): this;
@@ -28,23 +27,13 @@ export class HTMLAdapter<P> extends HTMLWidget {
28
27
  return this;
29
28
  }
30
29
 
31
- constructor(protected readonly _component: React.FunctionComponent<P>) {
30
+ constructor(protected readonly _component: FunctionComponent<P>) {
32
31
  super();
33
32
  }
34
33
 
35
- enter(domNode, element) {
36
- super.enter(domNode, element);
37
- this._root = createRoot(domNode);
38
- }
39
-
40
34
  update(domNode, element) {
41
35
  super.update(domNode, element);
42
- this._root.render(React.createElement(this._component, this.props()));
43
- }
44
-
45
- exit(domNode, element) {
46
- this._root.unmount();
47
- super.exit(domNode, element);
36
+ render(this._component, this._props, domNode);
48
37
  }
49
38
  }
50
39
  HTMLAdapter.prototype._class += " react_HTMLAdapter";
@@ -56,8 +45,6 @@ HTMLAdapter.prototype.publish("props", {}, "object", "Properties");
56
45
 
57
46
  export class SVGAdapter<P> extends SVGWidget {
58
47
 
59
- protected _root: Root;
60
-
61
48
  props(): P;
62
49
  props(_: Partial<P>): this;
63
50
  props(_?: Partial<P>): P | this {
@@ -74,24 +61,13 @@ export class SVGAdapter<P> extends SVGWidget {
74
61
  return this;
75
62
  }
76
63
 
77
- constructor(protected readonly _component: React.FunctionComponent<P>) {
64
+ constructor(protected readonly _component: FunctionComponent<P>) {
78
65
  super();
79
66
  }
80
67
 
81
- _c2: React.ReactElement;
82
- enter(domNode, element) {
83
- super.enter(domNode, element);
84
- this._root = createRoot(domNode);
85
- }
86
-
87
68
  update(domNode, element) {
88
69
  super.update(domNode, element);
89
- this._root.render(React.createElement(this._component, this.props()));
90
- }
91
-
92
- exit(domNode, element) {
93
- this._root.unmount();
94
- super.exit(domNode, element);
70
+ render(this._component, this._props, domNode);
95
71
  }
96
72
  }
97
73
  SVGAdapter.prototype._class += " react_SVGAdapter";
package/src/shape.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import { FunctionComponent } from "preact";
2
2
 
3
3
  interface CircleProps {
4
4
  radius?: number;
@@ -8,7 +8,7 @@ interface CircleProps {
8
8
  shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
9
9
  }
10
10
 
11
- export const Circle: React.FunctionComponent<CircleProps> = ({
11
+ export const Circle: FunctionComponent<CircleProps> = ({
12
12
  radius = 32,
13
13
  fill = "navy",
14
14
  stroke = fill,
@@ -31,7 +31,7 @@ interface SquareProps {
31
31
  shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
32
32
  }
33
33
 
34
- export const Square: React.FunctionComponent<SquareProps> = ({
34
+ export const Square: FunctionComponent<SquareProps> = ({
35
35
  radius = 30,
36
36
  cornerRadius = 0,
37
37
  fill = "white",
@@ -61,7 +61,7 @@ interface RectangleProps {
61
61
  shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
62
62
  }
63
63
 
64
- export const Rectangle: React.FunctionComponent<RectangleProps> = ({
64
+ export const Rectangle: FunctionComponent<RectangleProps> = ({
65
65
  width = 30,
66
66
  height = 30,
67
67
  cornerRadius = 0,
@@ -95,7 +95,7 @@ interface ShapeProps {
95
95
  cornerRadius?: number;
96
96
  }
97
97
 
98
- export const Shape: React.FunctionComponent<ShapeProps> = ({
98
+ export const Shape: FunctionComponent<ShapeProps> = ({
99
99
  shape = "circle",
100
100
  height = 128,
101
101
  width,
package/src/span.tsx CHANGED
@@ -1,9 +1,9 @@
1
- import React from "react";
1
+ import { FunctionComponent } from "preact";
2
2
 
3
3
  export interface SpanProps {
4
4
  text: string;
5
5
  }
6
6
 
7
- export const Span: React.FunctionComponent<SpanProps> = ({
7
+ export const Span: FunctionComponent<SpanProps> = ({
8
8
  text
9
9
  }) => <span>{text}</span>;
package/src/subgraph.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import { FunctionComponent } from "preact";
2
2
  import { Utility } from "@hpcc-js/common";
3
3
  import { Rectangle } from "./shape.tsx";
4
4
  import { Text } from "./text.tsx";
@@ -15,7 +15,7 @@ export interface SubgraphProps {
15
15
  fontFamily?: string;
16
16
  }
17
17
 
18
- export const Subgraph: React.FunctionComponent<SubgraphProps> = ({
18
+ export const Subgraph: FunctionComponent<SubgraphProps> = ({
19
19
  text,
20
20
  width = 100,
21
21
  height = 100,
package/src/text.tsx CHANGED
@@ -1,4 +1,5 @@
1
- import React from "react";
1
+ import { FunctionComponent } from "preact";
2
+ import { useCallback, useEffect, useLayoutEffect, useMemo, useState } from "preact/hooks";
2
3
  import { Utility } from "@hpcc-js/common";
3
4
  import { Icon } from "./icon.tsx";
4
5
  import { Rectangle } from "./shape.tsx";
@@ -12,7 +13,7 @@ export interface TextLineProps {
12
13
  fill?: string;
13
14
  }
14
15
 
15
- export const TextLine: React.FunctionComponent<TextLineProps> = ({
16
+ export const TextLine: FunctionComponent<TextLineProps> = ({
16
17
  text,
17
18
  height = 12,
18
19
  anchor = "middle",
@@ -21,10 +22,10 @@ export const TextLine: React.FunctionComponent<TextLineProps> = ({
21
22
  fill = "black"
22
23
  }) => {
23
24
  return <text
24
- fontFamily={fontFamily}
25
- fontSize={`${height}px`}
26
- textAnchor={anchor}
27
- dominantBaseline={baseline}
25
+ font-family={fontFamily}
26
+ font-size={`${height}px`}
27
+ text-anchor={anchor}
28
+ dominant-baseline={baseline}
28
29
  fill={fill}
29
30
  >{text}</text>;
30
31
  };
@@ -37,33 +38,33 @@ export interface TextProps {
37
38
  onSizeUpdate?: (size: { width: number, height: number }) => void;
38
39
  }
39
40
 
40
- export const Text: React.FunctionComponent<TextProps> = ({
41
+ export const Text: FunctionComponent<TextProps> = ({
41
42
  text,
42
43
  height = 12,
43
44
  fontFamily = "Verdana",
44
45
  fill = "black",
45
46
  onSizeUpdate
46
47
  }) => {
47
- const [totalWidth, setTotalWidth] = React.useState(0);
48
- const [totalHeight, setTotalHeight] = React.useState(0);
48
+ const [totalWidth, setTotalWidth] = useState(0);
49
+ const [totalHeight, setTotalHeight] = useState(0);
49
50
 
50
- React.useEffect(() => {
51
+ useEffect(() => {
51
52
  if (onSizeUpdate) {
52
53
  onSizeUpdate({ width: totalWidth, height: totalHeight });
53
54
  }
54
55
  }, [totalWidth, totalHeight, onSizeUpdate]);
55
56
 
56
- const parts = React.useMemo(() => {
57
+ const parts = useMemo(() => {
57
58
  return text.split("\n");
58
59
  }, [text]);
59
60
 
60
- React.useLayoutEffect(() => {
61
+ useLayoutEffect(() => {
61
62
  const size = Utility.textSize(parts, fontFamily, height);
62
63
  setTotalWidth(size.width);
63
64
  setTotalHeight(size.height);
64
65
  }, [fontFamily, height, parts]);
65
66
 
66
- const TextLines = React.useMemo(() => {
67
+ const TextLines = useMemo(() => {
67
68
  const yOffset = -(totalHeight / 2) + (height / 2);
68
69
  return parts.map((p, i) => {
69
70
  return <g key={`key-${i}`} transform={`translate(0 ${yOffset + i * (height + 2)})`}>
@@ -94,7 +95,7 @@ export interface TextBoxProps {
94
95
  onSizeUpdate?: (size: { width: number, height: number }) => void;
95
96
  }
96
97
 
97
- export const TextBox: React.FunctionComponent<TextBoxProps> = ({
98
+ export const TextBox: FunctionComponent<TextBoxProps> = ({
98
99
  text,
99
100
  height = 12,
100
101
  fontFamily = "Verdana",
@@ -106,16 +107,16 @@ export const TextBox: React.FunctionComponent<TextBoxProps> = ({
106
107
  cornerRadius = 0,
107
108
  onSizeUpdate
108
109
  }) => {
109
- const [textWidth, setTextWidthUpdate] = React.useState(0);
110
- const [textHeight, setTextHeightUpdate] = React.useState(0);
110
+ const [textWidth, setTextWidthUpdate] = useState(0);
111
+ const [textHeight, setTextHeightUpdate] = useState(0);
111
112
 
112
- React.useEffect(() => {
113
+ useEffect(() => {
113
114
  if (onSizeUpdate) {
114
115
  onSizeUpdate({ width: textWidth, height: textHeight });
115
116
  }
116
117
  }, [textWidth, textHeight, onSizeUpdate]);
117
118
 
118
- const onTextSizeUpdate = React.useCallback(size => {
119
+ const onTextSizeUpdate = useCallback(size => {
119
120
  setTextWidthUpdate(size.width);
120
121
  setTextHeightUpdate(size.height);
121
122
  }, []);
@@ -150,7 +151,7 @@ export interface LabelledRect extends TextBoxProps {
150
151
  fontSize?: number;
151
152
  }
152
153
 
153
- export const LabelledRect: React.FunctionComponent<LabelledRect> = ({
154
+ export const LabelledRect: FunctionComponent<LabelledRect> = ({
154
155
  text,
155
156
  height = 12,
156
157
  width = 12,
@@ -165,16 +166,16 @@ export const LabelledRect: React.FunctionComponent<LabelledRect> = ({
165
166
  onSizeUpdate
166
167
  }) => {
167
168
 
168
- const [actualWidth, setActualWidthUpdate] = React.useState(width);
169
- const [actualHeight, setActualHeightUpdate] = React.useState(height);
169
+ const [actualWidth, setActualWidthUpdate] = useState(width);
170
+ const [actualHeight, setActualHeightUpdate] = useState(height);
170
171
 
171
- React.useLayoutEffect(() => {
172
+ useLayoutEffect(() => {
172
173
  const size = Utility.textSize(text, fontFamily, fontSize);
173
174
  setActualWidthUpdate(size.width + padding * 2);
174
175
  setActualHeightUpdate(size.height + padding * 2);
175
176
  }, [text, fontFamily, fontSize, padding]);
176
177
 
177
- React.useLayoutEffect(() => {
178
+ useLayoutEffect(() => {
178
179
  if (onSizeUpdate) {
179
180
  onSizeUpdate({ width: actualWidth, height: actualHeight });
180
181
  }
@@ -182,14 +183,14 @@ export const LabelledRect: React.FunctionComponent<LabelledRect> = ({
182
183
 
183
184
  return <>
184
185
  <Rectangle
185
- width={actualWidth}
186
- height={actualHeight}
186
+ width={width}
187
+ height={height}
187
188
  fill={fill}
188
189
  stroke={stroke}
189
190
  strokeWidth={strokeWidth}
190
191
  cornerRadius={cornerRadius}
191
192
  />
192
- <g transform={`translate(${-(actualWidth / 2) + padding} ${-(actualHeight / 2) + padding + fontSize * 0.15})`}>
193
+ <g transform={`translate(${-(width / 2) + padding} ${-(height / 2) + padding})`}>
193
194
  <TextLine
194
195
  text={text}
195
196
  fontFamily={fontFamily}
@@ -208,7 +209,7 @@ export interface IconLabelledRect extends LabelledRect {
208
209
  iconFontSize?: number;
209
210
  }
210
211
 
211
- export const IconLabelledRect: React.FunctionComponent<IconLabelledRect> = ({
212
+ export const IconLabelledRect: FunctionComponent<IconLabelledRect> = ({
212
213
  icon,
213
214
  iconFontFamily,
214
215
  text,
package/src/vertex.tsx CHANGED
@@ -1,4 +1,5 @@
1
- import React from "react";
1
+ import { FunctionComponent } from "preact";
2
+ import { useCallback, useEffect, useState } from "preact/hooks";
2
3
  import { Icon, IconProps } from "./icon.tsx";
3
4
  import { TextBox } from "./text.tsx";
4
5
 
@@ -9,7 +10,7 @@ export interface AnnotationsProps {
9
10
  stepSize?: number;
10
11
  }
11
12
 
12
- export const Annotations: React.FunctionComponent<AnnotationsProps> = ({
13
+ export const Annotations: FunctionComponent<AnnotationsProps> = ({
13
14
  x,
14
15
  y,
15
16
  annotationIDs = [],
@@ -20,7 +21,7 @@ export const Annotations: React.FunctionComponent<AnnotationsProps> = ({
20
21
  transform={`translate(${x + i * stepSize} ${y})`}
21
22
  >
22
23
  <use
23
- href={"#" + id}
24
+ xlinkHref={"#" + id}
24
25
  />
25
26
  </g>
26
27
  );
@@ -47,7 +48,7 @@ export interface VertexProps {
47
48
  scale?: number
48
49
  }
49
50
 
50
- export const Vertex: React.FunctionComponent<VertexProps> = ({
51
+ export const Vertex: FunctionComponent<VertexProps> = ({
51
52
  categoryID = "",
52
53
  text = "",
53
54
  textHeight = 12,
@@ -70,10 +71,10 @@ export const Vertex: React.FunctionComponent<VertexProps> = ({
70
71
  ...icon
71
72
  };
72
73
 
73
- const [textBoxWidth, setTextBoxWidthUpdate] = React.useState(0);
74
- const [textBoxHeight, setTextBoxHeightUpdate] = React.useState(0);
74
+ const [textBoxWidth, setTextBoxWidthUpdate] = useState(0);
75
+ const [textBoxHeight, setTextBoxHeightUpdate] = useState(0);
75
76
 
76
- React.useEffect(() => {
77
+ useEffect(() => {
77
78
  if (onSizeUpdate) {
78
79
  onSizeUpdate({ width: 0, height: 0 });
79
80
  }
@@ -89,7 +90,7 @@ export const Vertex: React.FunctionComponent<VertexProps> = ({
89
90
  annotationOffsetY -= textBoxHeight + textPadding;
90
91
  }
91
92
 
92
- const onTextBoxSizeUpdate = React.useCallback(size => {
93
+ const onTextBoxSizeUpdate = useCallback(size => {
93
94
  setTextBoxWidthUpdate(size.width);
94
95
  setTextBoxHeightUpdate(size.height);
95
96
  }, []);
@@ -108,7 +109,7 @@ export const Vertex: React.FunctionComponent<VertexProps> = ({
108
109
  </g> : undefined;
109
110
  return categoryID ?
110
111
  <g transform={`translate(0 ${offsetY}) scale(${scale})`}>
111
- <use href={"#" + categoryID} />
112
+ <use xlinkHref={"#" + categoryID} />
112
113
  {label}
113
114
  <Annotations x={width / 2} y={annotationOffsetY} annotationIDs={annotationIDs} />
114
115
  </g> :
package/src/vertex2.tsx CHANGED
@@ -1,10 +1,11 @@
1
- import React from "react";
1
+ import { FunctionComponent } from "preact";
2
+ import { useMemo } from "preact/hooks";
2
3
  import { Utility } from "@hpcc-js/common";
3
4
  import { Icon, IconProps } from "./icon.tsx";
4
5
  import { TextBox } from "./text.tsx";
5
6
  import { Annotations, VertexProps } from "./vertex.tsx";
6
7
 
7
- export const Vertex2: React.FunctionComponent<VertexProps> = ({
8
+ export const Vertex2: FunctionComponent<VertexProps> = ({
8
9
  categoryID = "",
9
10
  text = "",
10
11
  textHeight = 12,
@@ -26,7 +27,7 @@ export const Vertex2: React.FunctionComponent<VertexProps> = ({
26
27
  ...icon
27
28
  };
28
29
  const textBoxHeight = textHeight + textPadding * 2;
29
- const { width } = React.useMemo(() => {
30
+ const { width } = useMemo(() => {
30
31
  return Utility.textSize(text, textFontFamily, textHeight, false);
31
32
  }, [text, textFontFamily, textHeight]);
32
33
 
@@ -51,7 +52,7 @@ export const Vertex2: React.FunctionComponent<VertexProps> = ({
51
52
  transform={`translate(${iconOffsetX} ${iconOffsetY})`}
52
53
  >
53
54
  <use
54
- href={"#" + categoryID}
55
+ xlinkHref={"#" + categoryID}
55
56
  />
56
57
  </g>
57
58
  <g
package/src/vertex3.tsx CHANGED
@@ -1,4 +1,5 @@
1
- import React from "react";
1
+ import { FunctionComponent } from "preact";
2
+ import { useMemo } from "preact/hooks";
2
3
  import { Utility } from "@hpcc-js/common";
3
4
  import { Icon, IconProps } from "./icon.tsx";
4
5
  import { TextBox, TextBoxProps } from "./text.tsx";
@@ -29,7 +30,7 @@ export interface Vertex3Props extends VertexProps {
29
30
  scale?: number;
30
31
  }
31
32
 
32
- export const Vertex3: React.FunctionComponent<Vertex3Props> = ({
33
+ export const Vertex3: FunctionComponent<Vertex3Props> = ({
33
34
  text = "",
34
35
  textHeight = 10,
35
36
  textPadding = 4,
@@ -79,7 +80,7 @@ export const Vertex3: React.FunctionComponent<Vertex3Props> = ({
79
80
 
80
81
  const annoOffsetY = 0;
81
82
 
82
- const labelWidth = React.useMemo(() => {
83
+ const labelWidth = useMemo(() => {
83
84
  return Utility.textSize(text, textFontFamily, textHeight, false).width;
84
85
  }, [text, textFontFamily, textHeight]);
85
86
 
@@ -174,7 +175,7 @@ export const Vertex3: React.FunctionComponent<Vertex3Props> = ({
174
175
  </g >;
175
176
  };
176
177
 
177
- export const CentroidVertex3: React.FunctionComponent<Vertex3Props> = function ({
178
+ export const CentroidVertex3: FunctionComponent<Vertex3Props> = function ({
178
179
  id,
179
180
  categoryID = "",
180
181
  text = "",
package/src/vertex4.tsx CHANGED
@@ -1,4 +1,5 @@
1
- import React from "react";
1
+ import { FunctionComponent } from "preact";
2
+ import { useMemo } from "preact/hooks";
2
3
  import { Utility } from "@hpcc-js/common";
3
4
  import { Icon, IconProps } from "./icon.tsx";
4
5
  import { TextBox, TextBoxProps } from "./text.tsx";
@@ -32,7 +33,7 @@ export interface IVertex4 extends VertexProps {
32
33
  shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
33
34
  }
34
35
 
35
- export const Vertex4: React.FunctionComponent<IVertex4> = ({
36
+ export const Vertex4: FunctionComponent<IVertex4> = ({
36
37
  categoryID = "",
37
38
  text = "",
38
39
  textHeight = 10,
@@ -86,7 +87,7 @@ export const Vertex4: React.FunctionComponent<IVertex4> = ({
86
87
  };
87
88
 
88
89
  const annoOffsetY = 0;
89
- const labelWidth = React.useMemo(() => {
90
+ const labelWidth = useMemo(() => {
90
91
  return Utility.textSize(text, textFontFamily, textHeight, false).width;
91
92
  }, [text, textFontFamily, textHeight]);
92
93
 
@@ -211,7 +212,7 @@ export const Vertex4: React.FunctionComponent<IVertex4> = ({
211
212
  ;
212
213
  };
213
214
 
214
- export const CentroidVertex4: React.FunctionComponent<IVertex4> = function ({
215
+ export const CentroidVertex4: FunctionComponent<IVertex4> = function ({
215
216
  id,
216
217
  categoryID = "",
217
218
  text = "",
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import { FunctionComponent } from "preact";
2
2
  export interface ImageCharProps {
3
3
  x?: number;
4
4
  y?: number;
@@ -10,4 +10,4 @@ export interface ImageCharProps {
10
10
  yOffset?: number;
11
11
  fontWeight?: number;
12
12
  }
13
- export declare const ImageChar: React.FunctionComponent<ImageCharProps>;
13
+ export declare const ImageChar: FunctionComponent<ImageCharProps>;
@@ -1,3 +1,3 @@
1
1
  export declare const PKG_NAME = "@hpcc-js/react";
2
- export declare const PKG_VERSION = "3.1.0";
3
- export declare const BUILD_VERSION = "3.2.0";
2
+ export declare const PKG_VERSION = "3.1.1";
3
+ export declare const BUILD_VERSION = "3.2.1";
package/types/edge.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import { FunctionComponent } from "preact";
2
2
  import { VertexProps } from "./vertex.tsx";
3
3
  type Point = [number, number];
4
4
  export interface EdgeProps<V extends VertexProps = VertexProps> {
@@ -19,5 +19,5 @@ export interface EdgeProps<V extends VertexProps = VertexProps> {
19
19
  points?: Array<[number, number]>;
20
20
  curveDepth?: number;
21
21
  }
22
- export declare const Edge: React.FunctionComponent<EdgeProps>;
22
+ export declare const Edge: FunctionComponent<EdgeProps>;
23
23
  export {};
package/types/icon.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import { FunctionComponent } from "preact";
2
2
  export interface IconProps {
3
3
  shape?: "circle" | "square" | "rectangle";
4
4
  width?: number;
@@ -16,11 +16,11 @@ export interface IconProps {
16
16
  cornerRadius?: number;
17
17
  shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
18
18
  }
19
- export declare const Icon: React.FunctionComponent<IconProps>;
19
+ export declare const Icon: FunctionComponent<IconProps>;
20
20
  export interface IconEx extends IconProps {
21
21
  id: string;
22
22
  }
23
23
  export interface IconsProps {
24
24
  icons: IconEx[];
25
25
  }
26
- export declare const Icons: React.FunctionComponent<IconsProps>;
26
+ export declare const Icons: FunctionComponent<IconsProps>;
package/types/image.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import { FunctionComponent } from "preact";
2
2
  interface ImageProps {
3
3
  href: string;
4
4
  x?: number;
@@ -6,5 +6,5 @@ interface ImageProps {
6
6
  height?: number;
7
7
  yOffset?: number;
8
8
  }
9
- export declare const Image: React.FunctionComponent<ImageProps>;
9
+ export declare const Image: FunctionComponent<ImageProps>;
10
10
  export {};
package/types/index.d.ts CHANGED
@@ -12,5 +12,4 @@ export * from "./vertex2.tsx";
12
12
  export * from "./vertex3.tsx";
13
13
  export * from "./vertex4.tsx";
14
14
  export * from "./subgraph.tsx";
15
- import React from "react";
16
- export { React };
15
+ export * as React from "./preact-shim.ts";
@@ -0,0 +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";
package/types/render.d.ts CHANGED
@@ -1,34 +1,27 @@
1
- import React from "react";
2
- import { Root } from "react-dom/client";
1
+ import { FunctionComponent } from "preact";
3
2
  import { HTMLWidget, SVGWidget } from "@hpcc-js/common";
4
- export declare function render<P>(C: React.FunctionComponent<P>, props: Readonly<P>, parent: Element | Document | ShadowRoot | DocumentFragment): void;
3
+ export declare function render<P>(C: FunctionComponent<P>, props: Readonly<P>, parent: Element | Document | ShadowRoot | DocumentFragment, replaceNode?: Element | Text): void;
4
+ export declare function svgRender<P>(C: FunctionComponent<P>, props: Readonly<P>, parent: Element | Document | ShadowRoot | DocumentFragment, replaceNode?: Element | Text): void;
5
5
  export declare class HTMLAdapter<P> extends HTMLWidget {
6
- protected readonly _component: React.FunctionComponent<P>;
7
- protected _root: Root;
6
+ protected readonly _component: FunctionComponent<P>;
8
7
  props(): P;
9
8
  props(_: Partial<P>): this;
10
9
  prop<K extends keyof P>(_: K): P[K];
11
10
  prop<K extends keyof P>(_: K, value: P[K]): this;
12
- constructor(_component: React.FunctionComponent<P>);
13
- enter(domNode: any, element: any): void;
11
+ constructor(_component: FunctionComponent<P>);
14
12
  update(domNode: any, element: any): void;
15
- exit(domNode: any, element: any): void;
16
13
  }
17
14
  export interface HTMLAdapter<P> {
18
15
  _props: P;
19
16
  }
20
17
  export declare class SVGAdapter<P> extends SVGWidget {
21
- protected readonly _component: React.FunctionComponent<P>;
22
- protected _root: Root;
18
+ protected readonly _component: FunctionComponent<P>;
23
19
  props(): P;
24
20
  props(_: Partial<P>): this;
25
21
  prop<K extends keyof P>(_: K): P[K];
26
22
  prop<K extends keyof P>(_: K, value: P[K]): this;
27
- constructor(_component: React.FunctionComponent<P>);
28
- _c2: React.ReactElement;
29
- enter(domNode: any, element: any): void;
23
+ constructor(_component: FunctionComponent<P>);
30
24
  update(domNode: any, element: any): void;
31
- exit(domNode: any, element: any): void;
32
25
  }
33
26
  export interface SVGAdapter<P> {
34
27
  _props: P;
package/types/shape.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import { FunctionComponent } from "preact";
2
2
  interface CircleProps {
3
3
  radius?: number;
4
4
  fill?: string;
@@ -6,7 +6,7 @@ interface CircleProps {
6
6
  strokeWidth?: number;
7
7
  shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
8
8
  }
9
- export declare const Circle: React.FunctionComponent<CircleProps>;
9
+ export declare const Circle: FunctionComponent<CircleProps>;
10
10
  interface SquareProps {
11
11
  radius?: number;
12
12
  cornerRadius?: number;
@@ -15,7 +15,7 @@ interface SquareProps {
15
15
  strokeWidth?: number;
16
16
  shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
17
17
  }
18
- export declare const Square: React.FunctionComponent<SquareProps>;
18
+ export declare const Square: FunctionComponent<SquareProps>;
19
19
  interface RectangleProps {
20
20
  width?: number;
21
21
  height?: number;
@@ -25,7 +25,7 @@ interface RectangleProps {
25
25
  strokeWidth?: number;
26
26
  shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
27
27
  }
28
- export declare const Rectangle: React.FunctionComponent<RectangleProps>;
28
+ export declare const Rectangle: FunctionComponent<RectangleProps>;
29
29
  interface ShapeProps {
30
30
  shape?: "circle" | "square" | "rectangle";
31
31
  height?: number;
@@ -36,5 +36,5 @@ interface ShapeProps {
36
36
  shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
37
37
  cornerRadius?: number;
38
38
  }
39
- export declare const Shape: React.FunctionComponent<ShapeProps>;
39
+ export declare const Shape: FunctionComponent<ShapeProps>;
40
40
  export {};
package/types/span.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import React from "react";
1
+ import { FunctionComponent } from "preact";
2
2
  export interface SpanProps {
3
3
  text: string;
4
4
  }
5
- export declare const Span: React.FunctionComponent<SpanProps>;
5
+ export declare const Span: FunctionComponent<SpanProps>;
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import { FunctionComponent } from "preact";
2
2
  export interface SubgraphProps {
3
3
  id: string;
4
4
  origData?: any;
@@ -10,4 +10,4 @@ export interface SubgraphProps {
10
10
  fontHeight?: number;
11
11
  fontFamily?: string;
12
12
  }
13
- export declare const Subgraph: React.FunctionComponent<SubgraphProps>;
13
+ export declare const Subgraph: FunctionComponent<SubgraphProps>;