import type { ContentNode, ContentNodeComponent } from 'tungsten/ContentNode.js'
import { TungstenBaseComponent } from 'tungsten/Components.jsx'
import type { FunctionComponent } from 'tungsten/FunctionComponent.js'
import type { TungstenRef } from 'tungsten/createRef.js'
import type { HTMLWebViewElement } from './html.global.js'
import type {
AnchorHTMLAttributes, AreaHTMLAttributes, AudioHTMLAttributes, BaseHTMLAttributes,
BlockquoteHTMLAttributes, ButtonHTMLAttributes, CanvasHTMLAttributes, ColHTMLAttributes, ColgroupHTMLAttributes, DataHTMLAttributes, DelHTMLAttributes, DetailsHTMLAttributes, DialogHTMLAttributes, EmbedHTMLAttributes, FieldsetHTMLAttributes, FormHTMLAttributes, HTMLAttributes, HtmlHTMLAttributes, IframeHTMLAttributes, ImgHTMLAttributes, InputHTMLAttributes, InsHTMLAttributes, KeygenHTMLAttributes, LabelHTMLAttributes, LiHTMLAttributes, LinkHTMLAttributes, MapHTMLAttributes, MenuHTMLAttributes, MetaHTMLAttributes, MeterHTMLAttributes, ObjectHTMLAttributes, OlHTMLAttributes, OptgroupHTMLAttributes, OptionHTMLAttributes, OutputHTMLAttributes, ParamHTMLAttributes, ProgressHTMLAttributes, QuoteHTMLAttributes, SVGAttributes, ScriptHTMLAttributes, SelectHTMLAttributes, SlotHTMLAttributes, SourceHTMLAttributes, StyleHTMLAttributes, TableHTMLAttributes, TdHTMLAttributes, TextareaHTMLAttributes, ThHTMLAttributes, TimeHTMLAttributes, TrackHTMLAttributes, VideoHTMLAttributes, WebViewHTMLAttributes
} from './html.d.js'
interface ErrorInfo {
componentStack: string;
}
/////////////////////////////////////////////////////
// React types that we are going to replace
/////////////////////////////////////////////////////
interface NewLifecycle
{
getSnapshotBeforeUpdate?(prevProps: Readonly
, prevState: Readonly): SS | null;
componentDidUpdate?(prevProps: Readonly
, prevState: Readonly, snapshot?: SS): void;
}
interface DeprecatedLifecycle
{
componentWillMount?(): void;
UNSAFE_componentWillMount?(): void;
componentWillReceiveProps?(nextProps: Readonly
, nextContext: any): void;
UNSAFE_componentWillReceiveProps?(nextProps: Readonly
, nextContext: any): void;
componentWillUpdate?(nextProps: Readonly
, nextState: Readonly, nextContext: any): void;
UNSAFE_componentWillUpdate?(nextProps: Readonly
, nextState: Readonly, nextContext: any): void;
}
interface ComponentLifecycle
extends NewLifecycle
, DeprecatedLifecycle
{
componentDidMount?(): void;
shouldComponentUpdate?(nextProps: Readonly
, nextState: Readonly, nextContext: any): boolean;
componentWillUnmount?(): void;
componentDidCatch?(error: Error, errorInfo: ErrorInfo): void;
}
interface Component
extends ComponentLifecycle
{ }
type JSXElementConstructor
=
| ((
props: P,
/**
* @deprecated https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-stateless-function-components
*/
deprecatedLegacyContext?: any,
) => ContentNode)
| (new (props: P) => Component);
// interface ReactElement = string | JSXElementConstructor> {
// type: T;
// props: P;
// key: Key | null;
// }
// interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES {}
// type ReactNode =
// | ReactElement
// | string
// | number
// | Iterable
// | ReactPortal
// | boolean
// | null
// | undefined
// | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES];
// interface ReactPortal extends ReactElement {
// key: Key | null;
// children: ReactNode;
// }
/////////////////////////////////////////////////////
// End: React types that we are going to replace
/////////////////////////////////////////////////////
type Key = string | number;
interface RefObject {
readonly current: T | null;
}
// Bivariance hack for consistent unsoundness with RefObject
// type RefCallback = { bivarianceHack(instance: T | null): void }['bivarianceHack'];
// type Ref = RefCallback | RefObject | null;
//type LegacyRef = string | Ref;
interface Attributes {
key?: Key | null | undefined;
}
interface RefAttributes extends Attributes {
/**
* Allows getting a ref to the component instance.
* Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
* @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom
*/
ref?: TungstenRef | undefined;
}
interface ClassAttributes extends Attributes {
/**
* Allows getting a ref to the component instance.
* Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
* @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom
*/
ref?: TungstenRef | undefined;
}
interface ClassAttributes extends Attributes {
/**
* Allows getting a ref to the component instance.
* Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
* @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom
*/
ref?: TungstenRef | undefined;
}
type DetailedHTMLProps, T> = ClassAttributes & E;
interface SVGProps extends SVGAttributes, ClassAttributes { }
interface SVGLineElementAttributes extends SVGProps {}
interface SVGTextElementAttributes extends SVGProps {}
/*
// We can't recurse forever because `type` can't be self-referential;
// let's assume it's reasonable to do a single React.lazy() around a single React.memo() / vice-versa
type LibraryManagedAttributes = C extends React.MemoExoticComponent | React.LazyExoticComponent
? T extends React.MemoExoticComponent | React.LazyExoticComponent
? ReactManagedAttributes
: ReactManagedAttributes
: ReactManagedAttributes;
*/
export interface TungstenIntrinsicAttributes extends Attributes { }
export interface TungstenIntrinsicClassAttributes extends ClassAttributes { }
export interface TungstenIntrinsicElements {
// HTML
a: DetailedHTMLProps, HTMLAnchorElement>;
abbr: DetailedHTMLProps, HTMLElement>;
address: DetailedHTMLProps, HTMLElement>;
area: DetailedHTMLProps, HTMLAreaElement>;
article: DetailedHTMLProps, HTMLElement>;
aside: DetailedHTMLProps, HTMLElement>;
audio: DetailedHTMLProps, HTMLAudioElement>;
b: DetailedHTMLProps, HTMLElement>;
base: DetailedHTMLProps, HTMLBaseElement>;
bdi: DetailedHTMLProps, HTMLElement>;
bdo: DetailedHTMLProps, HTMLElement>;
big: DetailedHTMLProps, HTMLElement>;
blockquote: DetailedHTMLProps, HTMLQuoteElement>;
body: DetailedHTMLProps, HTMLBodyElement>;
br: DetailedHTMLProps, HTMLBRElement>;
button: DetailedHTMLProps, HTMLButtonElement>;
canvas: DetailedHTMLProps, HTMLCanvasElement>;
caption: DetailedHTMLProps, HTMLElement>;
center: DetailedHTMLProps, HTMLElement>;
cite: DetailedHTMLProps, HTMLElement>;
code: DetailedHTMLProps, HTMLElement>;
col: DetailedHTMLProps, HTMLTableColElement>;
colgroup: DetailedHTMLProps, HTMLTableColElement>;
data: DetailedHTMLProps, HTMLDataElement>;
datalist: DetailedHTMLProps, HTMLDataListElement>;
dd: DetailedHTMLProps, HTMLElement>;
del: DetailedHTMLProps, HTMLModElement>;
details: DetailedHTMLProps, HTMLDetailsElement>;
dfn: DetailedHTMLProps, HTMLElement>;
dialog: DetailedHTMLProps, HTMLDialogElement>;
div: DetailedHTMLProps, HTMLDivElement>;
dl: DetailedHTMLProps, HTMLDListElement>;
dt: DetailedHTMLProps, HTMLElement>;
em: DetailedHTMLProps, HTMLElement>;
embed: DetailedHTMLProps, HTMLEmbedElement>;
fieldset: DetailedHTMLProps, HTMLFieldSetElement>;
figcaption: DetailedHTMLProps, HTMLElement>;
figure: DetailedHTMLProps, HTMLElement>;
footer: DetailedHTMLProps, HTMLElement>;
form: DetailedHTMLProps, HTMLFormElement>;
h1: DetailedHTMLProps, HTMLHeadingElement>;
h2: DetailedHTMLProps, HTMLHeadingElement>;
h3: DetailedHTMLProps, HTMLHeadingElement>;
h4: DetailedHTMLProps, HTMLHeadingElement>;
h5: DetailedHTMLProps, HTMLHeadingElement>;
h6: DetailedHTMLProps, HTMLHeadingElement>;
head: DetailedHTMLProps, HTMLHeadElement>;
header: DetailedHTMLProps, HTMLElement>;
hgroup: DetailedHTMLProps, HTMLElement>;
hr: DetailedHTMLProps, HTMLHRElement>;
html: DetailedHTMLProps, HTMLHtmlElement>;
i: DetailedHTMLProps, HTMLElement>;
iframe: DetailedHTMLProps, HTMLIFrameElement>;
img: DetailedHTMLProps, HTMLImageElement>;
input: DetailedHTMLProps, HTMLInputElement>;
ins: DetailedHTMLProps, HTMLModElement>;
kbd: DetailedHTMLProps, HTMLElement>;
keygen: DetailedHTMLProps, HTMLElement>;
label: DetailedHTMLProps, HTMLLabelElement>;
legend: DetailedHTMLProps, HTMLLegendElement>;
li: DetailedHTMLProps, HTMLLIElement>;
link: DetailedHTMLProps, HTMLLinkElement>;
main: DetailedHTMLProps, HTMLElement>;
map: DetailedHTMLProps, HTMLMapElement>;
mark: DetailedHTMLProps, HTMLElement>;
menu: DetailedHTMLProps, HTMLElement>;
menuitem: DetailedHTMLProps, HTMLElement>;
meta: DetailedHTMLProps, HTMLMetaElement>;
meter: DetailedHTMLProps, HTMLMeterElement>;
nav: DetailedHTMLProps, HTMLElement>;
noindex: DetailedHTMLProps, HTMLElement>;
noscript: DetailedHTMLProps, HTMLElement>;
object: DetailedHTMLProps, HTMLObjectElement>;
ol: DetailedHTMLProps, HTMLOListElement>;
optgroup: DetailedHTMLProps, HTMLOptGroupElement>;
option: DetailedHTMLProps, HTMLOptionElement>;
output: DetailedHTMLProps, HTMLOutputElement>;
p: DetailedHTMLProps, HTMLParagraphElement>;
param: DetailedHTMLProps, HTMLParamElement>;
picture: DetailedHTMLProps, HTMLElement>;
pre: DetailedHTMLProps, HTMLPreElement>;
progress: DetailedHTMLProps, HTMLProgressElement>;
q: DetailedHTMLProps, HTMLQuoteElement>;
rp: DetailedHTMLProps, HTMLElement>;
rt: DetailedHTMLProps, HTMLElement>;
ruby: DetailedHTMLProps, HTMLElement>;
s: DetailedHTMLProps, HTMLElement>;
samp: DetailedHTMLProps, HTMLElement>;
search: DetailedHTMLProps, HTMLElement>;
slot: DetailedHTMLProps, HTMLSlotElement>;
script: DetailedHTMLProps, HTMLScriptElement>;
section: DetailedHTMLProps, HTMLElement>;
select: DetailedHTMLProps, HTMLSelectElement>;
small: DetailedHTMLProps, HTMLElement>;
source: DetailedHTMLProps, HTMLSourceElement>;
span: DetailedHTMLProps, HTMLSpanElement>;
strong: DetailedHTMLProps, HTMLElement>;
style: DetailedHTMLProps, HTMLStyleElement>;
sub: DetailedHTMLProps, HTMLElement>;
summary: DetailedHTMLProps, HTMLElement>;
sup: DetailedHTMLProps, HTMLElement>;
table: DetailedHTMLProps, HTMLTableElement>;
template: DetailedHTMLProps, HTMLTemplateElement>;
tbody: DetailedHTMLProps, HTMLTableSectionElement>;
td: DetailedHTMLProps, HTMLTableDataCellElement>;
textarea: DetailedHTMLProps, HTMLTextAreaElement>;
tfoot: DetailedHTMLProps, HTMLTableSectionElement>;
th: DetailedHTMLProps, HTMLTableHeaderCellElement>;
thead: DetailedHTMLProps, HTMLTableSectionElement>;
time: DetailedHTMLProps, HTMLTimeElement>;
title: DetailedHTMLProps, HTMLTitleElement>;
tr: DetailedHTMLProps, HTMLTableRowElement>;
track: DetailedHTMLProps, HTMLTrackElement>;
u: DetailedHTMLProps, HTMLElement>;
ul: DetailedHTMLProps, HTMLUListElement>;
'var': DetailedHTMLProps, HTMLElement>;
video: DetailedHTMLProps, HTMLVideoElement>;
wbr: DetailedHTMLProps, HTMLElement>;
webview: DetailedHTMLProps, HTMLWebViewElement>;
// SVG
svg: SVGProps;
animate: SVGProps; // TODO: It is SVGAnimateElement but is not in TypeScript's lib.dom.d.ts for now.
animateMotion: SVGProps;
animateTransform: SVGProps; // TODO: It is SVGAnimateTransformElement but is not in TypeScript's lib.dom.d.ts for now.
circle: SVGProps;
clipPath: SVGProps;
defs: SVGProps;
desc: SVGProps;
ellipse: SVGProps;
feBlend: SVGProps;
feColorMatrix: SVGProps;
feComponentTransfer: SVGProps;
feComposite: SVGProps;
feConvolveMatrix: SVGProps;
feDiffuseLighting: SVGProps;
feDisplacementMap: SVGProps;
feDistantLight: SVGProps;
feDropShadow: SVGProps;
feFlood: SVGProps;
feFuncA: SVGProps;
feFuncB: SVGProps;
feFuncG: SVGProps;
feFuncR: SVGProps;
feGaussianBlur: SVGProps;
feImage: SVGProps;
feMerge: SVGProps;
feMergeNode: SVGProps;
feMorphology: SVGProps;
feOffset: SVGProps;
fePointLight: SVGProps;
feSpecularLighting: SVGProps;
feSpotLight: SVGProps;
feTile: SVGProps;
feTurbulence: SVGProps;
filter: SVGProps;
foreignObject: SVGProps;
g: SVGProps;
image: SVGProps;
line: SVGLineElementAttributes;
linearGradient: SVGProps;
marker: SVGProps;
mask: SVGProps;
metadata: SVGProps;
mpath: SVGProps;
path: SVGProps;
pattern: SVGProps;
polygon: SVGProps;
polyline: SVGProps;
radialGradient: SVGProps;
rect: SVGProps;
stop: SVGProps;
switch: SVGProps;
symbol: SVGProps;
text: SVGTextElementAttributes;
textPath: SVGProps;
tspan: SVGProps;
use: SVGProps;
view: SVGProps;
}
type IntrinsicElement = TungstenIntrinsicElements[keyof TungstenIntrinsicElements]
type TungstenElementType = string | JSXElementConstructor;
export type TungstenElement = IntrinsicElement | ContentNodeComponent
export interface TungstenElementAttributesProperty { props: {}; } // eslint-disable-line @typescript-eslint/ban-types
export interface TungstenElementChildrenAttribute { children: {}; } // eslint-disable-line @typescript-eslint/ban-types
declare global {
namespace JSX {
export type Element = ContentNode // ContentNode allows an array. Use Core because Element is exclusive of an array of Elements
export interface ElementAttributesProperty extends TungstenElementAttributesProperty {}
export interface ElementChildrenAttribute extends TungstenElementChildrenAttribute {}
export type ElementClass = TungstenBaseComponent | FunctionComponent
export interface IntrinsicAttributes extends TungstenIntrinsicAttributes { }
export interface IntrinsicClassAttributes extends TungstenIntrinsicClassAttributes {}
export interface IntrinsicElements extends TungstenIntrinsicElements {}
}
}