import { HTMLWidget, publish, SVGWidget } from "@hpcc-js/common"; import * as React from "@hpcc-js/preact-shim"; export function render

(C: React.FunctionComponent

, props: Readonly

, parent: Element | Document | ShadowRoot | DocumentFragment, replaceNode?: Element | Text) { React.render(React.h(C, props), parent, replaceNode); } export interface FunctionComponent extends React.FunctionComponent { } export function svgRender

(C: React.FunctionComponent

, props: Readonly

, parent: Element | Document | ShadowRoot | DocumentFragment, replaceNode?: Element | Text) { React.render(React.h("svg", null, React.h(C, props)), parent, replaceNode); } export class HTMLAdapter

extends HTMLWidget { @publish({}, "object", "Properties") protected _props: P = {} as P; props(): P; props(_: Partial

): this; props(_?: Partial

): P | this { if (!arguments.length) return this._props; this._props = { ...this._props, ..._ }; return this; } prop(_: K): P[K]; prop(_: K, value: P[K]): this; prop(_: K, value?: P[K]): this | P[K] { if (arguments.length === 1) return this._props[_]; this._props[_] = value; return this; } constructor(protected readonly _component: React.FunctionComponent

) { super(); } update(domNode, element) { super.update(domNode, element); render(this._component, this._props, domNode); } } export class SVGAdapter

extends SVGWidget { @publish({}, "object", "Properties") protected _props: P = {} as P; props(): P; props(_: Partial

): this; props(_?: Partial

): P | this { if (!arguments.length) return this._props; this._props = { ...this._props, ..._ }; return this; } prop(_: K): P[K]; prop(_: K, value: P[K]): this; prop(_: K, value?: P[K]): this | P[K] { if (arguments.length === 1) return this._props[_]; this._props[_] = value; return this; } constructor(protected readonly _component: React.FunctionComponent

) { super(); } update(domNode, element) { super.update(domNode, element); render(this._component, this._props, domNode); } }