@hpcc-js/react 3.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hpcc-js/react",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "hpcc-js - Viz React",
5
5
  "type": "module",
6
6
  "exports": {
@@ -39,12 +39,7 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@hpcc-js/esbuild-plugins": "^1.3.0",
42
- "react": "18.3.1",
43
- "react-dom": "18.3.1"
44
- },
45
- "peerDependencies": {
46
- "react": "^17.0.0 || ^18.0.0",
47
- "react-dom": "^17.0.0 || ^18.0.0"
42
+ "@hpcc-js/preact-shim": "^3.0.0"
48
43
  },
49
44
  "repository": {
50
45
  "type": "git",
@@ -57,5 +52,5 @@
57
52
  "url": "https://github.com/hpcc-systems/Visualization/issues"
58
53
  },
59
54
  "homepage": "https://github.com/hpcc-systems/Visualization",
60
- "gitHead": "658c50fd965a7744ba8db675ba6878607c44d5e2"
55
+ "gitHead": "b4f63e027feea45ebdfc578ef9c85d107bd97322"
61
56
  }
package/src/ImageChar.tsx CHANGED
@@ -1,5 +1,5 @@
1
- import React, { useMemo } from "react";
2
1
  import { Utility } from "@hpcc-js/common";
2
+ import * as React from "@hpcc-js/preact-shim";
3
3
 
4
4
  export interface ImageCharProps {
5
5
  x?: number;
@@ -24,7 +24,7 @@ export const ImageChar: React.FunctionComponent<ImageCharProps> = ({
24
24
  fontWeight
25
25
  }) => {
26
26
 
27
- const renderChar = useMemo(() => {
27
+ const renderChar = React.useMemo(() => {
28
28
  return fontFamily === "FontAwesome" ? Utility.faChar(char) : char;
29
29
  }, [char, fontFamily]);
30
30
 
@@ -1,3 +1,3 @@
1
1
  export const PKG_NAME = "@hpcc-js/react";
2
- export const PKG_VERSION = "3.1.0";
3
- export const BUILD_VERSION = "3.2.0";
2
+ export const PKG_VERSION = "3.1.1";
3
+ export const BUILD_VERSION = "3.2.1";
package/src/edge.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import * as React from "@hpcc-js/preact-shim";
2
2
  import { VertexProps } from "./vertex.tsx";
3
3
  import { Text } from "./text.tsx";
4
4
 
package/src/icon.tsx CHANGED
@@ -1,5 +1,5 @@
1
- import React from "react";
2
1
  import { Palette } from "@hpcc-js/common";
2
+ import * as React from "@hpcc-js/preact-shim";
3
3
  import { Image } from "./image.tsx";
4
4
  import { ImageChar } from "./ImageChar.tsx";
5
5
  import { Shape } from "./shape.tsx";
package/src/image.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import * as React from "@hpcc-js/preact-shim";
2
2
 
3
3
  interface ImageProps {
4
4
  href: string;
package/src/index.ts CHANGED
@@ -14,7 +14,7 @@ export * from "./vertex3.tsx";
14
14
  export * from "./vertex4.tsx";
15
15
  export * from "./subgraph.tsx";
16
16
 
17
- import React from "react";
17
+ import * as React from "@hpcc-js/preact-shim";
18
18
  export {
19
19
  React
20
20
  };
package/src/render.ts CHANGED
@@ -1,16 +1,18 @@
1
- import React from "react";
2
- import { render as reactRender } from "react-dom";
3
- import { createRoot, Root } from "react-dom/client";
4
1
  import { HTMLWidget, SVGWidget } from "@hpcc-js/common";
2
+ import * as React from "@hpcc-js/preact-shim";
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: React.FunctionComponent<P>, props: Readonly<P>, parent: Element | Document | ShadowRoot | DocumentFragment, replaceNode?: Element | Text) {
5
+ React.render(React.h(C, props), parent, replaceNode);
9
6
  }
10
7
 
11
- export class HTMLAdapter<P> extends HTMLWidget {
8
+ export interface FunctionComponent<T> extends React.FunctionComponent<T> {
9
+ }
12
10
 
13
- protected _root: Root;
11
+ export function svgRender<P>(C: React.FunctionComponent<P>, props: Readonly<P>, parent: Element | Document | ShadowRoot | DocumentFragment, replaceNode?: Element | Text) {
12
+ React.render(React.h("svg", null, React.h(C, props)), parent, replaceNode);
13
+ }
14
+
15
+ export class HTMLAdapter<P> extends HTMLWidget {
14
16
 
15
17
  props(): P;
16
18
  props(_: Partial<P>): this;
@@ -32,19 +34,9 @@ export class HTMLAdapter<P> extends HTMLWidget {
32
34
  super();
33
35
  }
34
36
 
35
- enter(domNode, element) {
36
- super.enter(domNode, element);
37
- this._root = createRoot(domNode);
38
- }
39
-
40
37
  update(domNode, element) {
41
38
  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);
39
+ render(this._component, this._props, domNode);
48
40
  }
49
41
  }
50
42
  HTMLAdapter.prototype._class += " react_HTMLAdapter";
@@ -56,8 +48,6 @@ HTMLAdapter.prototype.publish("props", {}, "object", "Properties");
56
48
 
57
49
  export class SVGAdapter<P> extends SVGWidget {
58
50
 
59
- protected _root: Root;
60
-
61
51
  props(): P;
62
52
  props(_: Partial<P>): this;
63
53
  props(_?: Partial<P>): P | this {
@@ -78,20 +68,9 @@ export class SVGAdapter<P> extends SVGWidget {
78
68
  super();
79
69
  }
80
70
 
81
- _c2: React.ReactElement;
82
- enter(domNode, element) {
83
- super.enter(domNode, element);
84
- this._root = createRoot(domNode);
85
- }
86
-
87
71
  update(domNode, element) {
88
72
  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);
73
+ render(this._component, this._props, domNode);
95
74
  }
96
75
  }
97
76
  SVGAdapter.prototype._class += " react_SVGAdapter";
package/src/shape.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import * as React from "@hpcc-js/preact-shim";
2
2
 
3
3
  interface CircleProps {
4
4
  radius?: number;
package/src/span.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import * as React from "@hpcc-js/preact-shim";
2
2
 
3
3
  export interface SpanProps {
4
4
  text: string;
package/src/subgraph.tsx CHANGED
@@ -1,5 +1,5 @@
1
- import React from "react";
2
1
  import { Utility } from "@hpcc-js/common";
2
+ import * as React from "@hpcc-js/preact-shim";
3
3
  import { Rectangle } from "./shape.tsx";
4
4
  import { Text } from "./text.tsx";
5
5
 
package/src/text.tsx CHANGED
@@ -1,5 +1,5 @@
1
- import React from "react";
2
1
  import { Utility } from "@hpcc-js/common";
2
+ import * as React from "@hpcc-js/preact-shim";
3
3
  import { Icon } from "./icon.tsx";
4
4
  import { Rectangle } from "./shape.tsx";
5
5
 
@@ -21,10 +21,10 @@ export const TextLine: React.FunctionComponent<TextLineProps> = ({
21
21
  fill = "black"
22
22
  }) => {
23
23
  return <text
24
- fontFamily={fontFamily}
25
- fontSize={`${height}px`}
26
- textAnchor={anchor}
27
- dominantBaseline={baseline}
24
+ font-family={fontFamily}
25
+ font-size={`${height}px`}
26
+ text-anchor={anchor}
27
+ dominant-baseline={baseline}
28
28
  fill={fill}
29
29
  >{text}</text>;
30
30
  };
package/src/vertex.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import * as React from "@hpcc-js/preact-shim";
2
2
  import { Icon, IconProps } from "./icon.tsx";
3
3
  import { TextBox } from "./text.tsx";
4
4
 
package/src/vertex2.tsx CHANGED
@@ -1,5 +1,5 @@
1
- import React from "react";
2
1
  import { Utility } from "@hpcc-js/common";
2
+ import * as React from "@hpcc-js/preact-shim";
3
3
  import { Icon, IconProps } from "./icon.tsx";
4
4
  import { TextBox } from "./text.tsx";
5
5
  import { Annotations, VertexProps } from "./vertex.tsx";
package/src/vertex3.tsx CHANGED
@@ -1,5 +1,5 @@
1
- import React from "react";
2
1
  import { Utility } from "@hpcc-js/common";
2
+ import * as React from "@hpcc-js/preact-shim";
3
3
  import { Icon, IconProps } from "./icon.tsx";
4
4
  import { TextBox, TextBoxProps } from "./text.tsx";
5
5
  import { VertexProps } from "./vertex.tsx";
package/src/vertex4.tsx CHANGED
@@ -1,5 +1,5 @@
1
- import React from "react";
2
1
  import { Utility } from "@hpcc-js/common";
2
+ import * as React from "@hpcc-js/preact-shim";
3
3
  import { Icon, IconProps } from "./icon.tsx";
4
4
  import { TextBox, TextBoxProps } from "./text.tsx";
5
5
  import { VertexProps } from "./vertex.tsx";
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import * as React from "@hpcc-js/preact-shim";
2
2
  export interface ImageCharProps {
3
3
  x?: number;
4
4
  y?: number;
@@ -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 * as React from "@hpcc-js/preact-shim";
2
2
  import { VertexProps } from "./vertex.tsx";
3
3
  type Point = [number, number];
4
4
  export interface EdgeProps<V extends VertexProps = VertexProps> {
package/types/icon.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import * as React from "@hpcc-js/preact-shim";
2
2
  export interface IconProps {
3
3
  shape?: "circle" | "square" | "rectangle";
4
4
  width?: number;
package/types/image.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import * as React from "@hpcc-js/preact-shim";
2
2
  interface ImageProps {
3
3
  href: string;
4
4
  x?: number;
package/types/index.d.ts CHANGED
@@ -12,5 +12,5 @@ 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";
15
+ import * as React from "@hpcc-js/preact-shim";
16
16
  export { React };
package/types/render.d.ts CHANGED
@@ -1,34 +1,29 @@
1
- import React from "react";
2
- import { Root } from "react-dom/client";
3
1
  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;
2
+ import * as React from "@hpcc-js/preact-shim";
3
+ export declare function render<P>(C: React.FunctionComponent<P>, props: Readonly<P>, parent: Element | Document | ShadowRoot | DocumentFragment, replaceNode?: Element | Text): void;
4
+ export interface FunctionComponent<T> extends React.FunctionComponent<T> {
5
+ }
6
+ export declare function svgRender<P>(C: React.FunctionComponent<P>, props: Readonly<P>, parent: Element | Document | ShadowRoot | DocumentFragment, replaceNode?: Element | Text): void;
5
7
  export declare class HTMLAdapter<P> extends HTMLWidget {
6
8
  protected readonly _component: React.FunctionComponent<P>;
7
- protected _root: Root;
8
9
  props(): P;
9
10
  props(_: Partial<P>): this;
10
11
  prop<K extends keyof P>(_: K): P[K];
11
12
  prop<K extends keyof P>(_: K, value: P[K]): this;
12
13
  constructor(_component: React.FunctionComponent<P>);
13
- enter(domNode: any, element: any): void;
14
14
  update(domNode: any, element: any): void;
15
- exit(domNode: any, element: any): void;
16
15
  }
17
16
  export interface HTMLAdapter<P> {
18
17
  _props: P;
19
18
  }
20
19
  export declare class SVGAdapter<P> extends SVGWidget {
21
20
  protected readonly _component: React.FunctionComponent<P>;
22
- protected _root: Root;
23
21
  props(): P;
24
22
  props(_: Partial<P>): this;
25
23
  prop<K extends keyof P>(_: K): P[K];
26
24
  prop<K extends keyof P>(_: K, value: P[K]): this;
27
25
  constructor(_component: React.FunctionComponent<P>);
28
- _c2: React.ReactElement;
29
- enter(domNode: any, element: any): void;
30
26
  update(domNode: any, element: any): void;
31
- exit(domNode: any, element: any): void;
32
27
  }
33
28
  export interface SVGAdapter<P> {
34
29
  _props: P;
package/types/shape.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import * as React from "@hpcc-js/preact-shim";
2
2
  interface CircleProps {
3
3
  radius?: number;
4
4
  fill?: string;
package/types/span.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import * as React from "@hpcc-js/preact-shim";
2
2
  export interface SpanProps {
3
3
  text: string;
4
4
  }
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import * as React from "@hpcc-js/preact-shim";
2
2
  export interface SubgraphProps {
3
3
  id: string;
4
4
  origData?: any;
package/types/text.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import * as React from "@hpcc-js/preact-shim";
2
2
  export interface TextLineProps {
3
3
  text: string;
4
4
  height?: number;
package/types/vertex.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import * as React from "@hpcc-js/preact-shim";
2
2
  import { IconProps } from "./icon.tsx";
3
3
  export interface AnnotationsProps {
4
4
  x: number;
@@ -1,3 +1,3 @@
1
- import React from "react";
1
+ import * as React from "@hpcc-js/preact-shim";
2
2
  import { VertexProps } from "./vertex.tsx";
3
3
  export declare const Vertex2: React.FunctionComponent<VertexProps>;
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import * as React from "@hpcc-js/preact-shim";
2
2
  import { IconProps } from "./icon.tsx";
3
3
  import { TextBoxProps } from "./text.tsx";
4
4
  import { VertexProps } from "./vertex.tsx";
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import * as React from "@hpcc-js/preact-shim";
2
2
  import { IconProps } from "./icon.tsx";
3
3
  import { VertexProps } from "./vertex.tsx";
4
4
  export interface IVertex4Annotation extends IconProps {