diff --git a/compat/src/index.d.ts b/compat/src/index.d.ts index a71a21564c..d9656f95a6 100644 --- a/compat/src/index.d.ts +++ b/compat/src/index.d.ts @@ -4,6 +4,14 @@ import { JSXInternal } from '../../src/jsx'; import * as _Suspense from './suspense'; import * as _SuspenseList from './suspense-list'; +interface SignalLike { + value: T; + peek(): T; + subscribe(fn: (value: T) => void): () => void; +} + +type Signalish = T | SignalLike; + // export default React; export = React; export as namespace React; @@ -77,10 +85,553 @@ declare namespace React { preact.ClassAttributes {} export import DetailedHTMLProps = JSXInternal.DetailedHTMLProps; export import CSSProperties = JSXInternal.CSSProperties; + export interface SVGProps extends JSXInternal.SVGAttributes, preact.ClassAttributes {} + interface SVGAttributes extends JSXInternal.SVGAttributes {} + + interface ReactSVG extends JSXInternal.IntrinsicSVGElements {} + + type HTMLAttributeReferrerPolicy = + | '' + | 'no-referrer' + | 'no-referrer-when-downgrade' + | 'origin' + | 'origin-when-cross-origin' + | 'same-origin' + | 'strict-origin' + | 'strict-origin-when-cross-origin' + | 'unsafe-url'; + + type HTMLAttributeAnchorTarget = + | '_self' + | '_blank' + | '_parent' + | '_top' + | (string & {}); + + interface AnchorHTMLAttributes + extends HTMLAttributes { + download?: Signalish; + href?: Signalish; + hrefLang?: Signalish; + media?: Signalish; + ping?: Signalish; + target?: Signalish; + type?: Signalish; + referrerPolicy?: Signalish; + } + + interface AudioHTMLAttributes + extends MediaHTMLAttributes {} + + interface AreaHTMLAttributes + extends HTMLAttributes { + alt?: Signalish; + coords?: Signalish; + download?: Signalish; + href?: Signalish; + hrefLang?: Signalish; + media?: Signalish; + referrerPolicy?: Signalish; + shape?: Signalish; + target?: Signalish; + } + + interface BaseHTMLAttributes + extends HTMLAttributes { + href?: Signalish; + target?: Signalish; + } + + interface BlockquoteHTMLAttributes + extends HTMLAttributes { + cite?: Signalish; + } + + interface ButtonHTMLAttributes + extends HTMLAttributes { + disabled?: Signalish; + form?: Signalish; + formAction?: Signalish; + formEncType?: Signalish; + formMethod?: Signalish; + formNoValidate?: Signalish; + formTarget?: Signalish; + name?: Signalish; + type?: Signalish<'submit' | 'reset' | 'button' | undefined>; + value?: Signalish; + } + + interface CanvasHTMLAttributes + extends HTMLAttributes { + height?: Signalish; + width?: Signalish; + } + + interface ColHTMLAttributes extends HTMLAttributes { + span?: Signalish; + width?: Signalish; + } + + interface ColgroupHTMLAttributes + extends HTMLAttributes { + span?: Signalish; + } + + interface DataHTMLAttributes + extends HTMLAttributes { + value?: Signalish; + } + + interface DetailsHTMLAttributes + extends HTMLAttributes { + open?: Signalish; + onToggle?: ChangeEventHandler | undefined; + } + + interface DelHTMLAttributes extends HTMLAttributes { + cite?: Signalish; + dateTime?: Signalish; + } + + interface DialogHTMLAttributes + extends HTMLAttributes { + onCancel?: ChangeEventHandler | undefined; + onClose?: ChangeEventHandler | undefined; + open?: Signalish; + } + + interface EmbedHTMLAttributes + extends HTMLAttributes { + height?: Signalish; + src?: Signalish; + type?: Signalish; + width?: Signalish; + } + + interface FieldsetHTMLAttributes + extends HTMLAttributes { + disabled?: Signalish; + form?: Signalish; + name?: Signalish; + } + + interface FormHTMLAttributes + extends HTMLAttributes { + acceptCharset?: Signalish; + action?: Signalish; + autoComplete?: Signalish; + encType?: Signalish; + method?: Signalish; + name?: Signalish; + noValidate?: Signalish; + target?: Signalish; + } + + interface HtmlHTMLAttributes + extends HTMLAttributes { + manifest?: Signalish; + } + + interface IframeHTMLAttributes + extends HTMLAttributes { + allow?: Signalish; + allowFullScreen?: Signalish; + allowTransparency?: Signalish; + /** @deprecated */ + frameBorder?: Signalish; + height?: Signalish; + loading?: 'eager' | 'lazy' | undefined; + /** @deprecated */ + marginHeight?: Signalish; + /** @deprecated */ + marginWidth?: Signalish; + name?: Signalish; + referrerPolicy?: Signalish; + sandbox?: Signalish; + /** @deprecated */ + scrolling?: Signalish; + seamless?: Signalish; + src?: Signalish; + srcDoc?: Signalish; + width?: Signalish; + } + + type HTMLAttributeCrossOrigin = 'anonymous' | 'use-credentials'; + + interface ImgHTMLAttributes extends HTMLAttributes { + alt?: Signalish; + crossOrigin?: Signalish; + decoding?: Signalish<'async' | 'auto' | 'sync' | undefined>; + height?: Signalish; + loading?: Signalish<'eager' | 'lazy' | undefined>; + referrerPolicy?: Signalish; + sizes?: Signalish; + src?: Signalish; + srcSet?: Signalish; + useMap?: Signalish; + width?: Signalish; + } + + interface InsHTMLAttributes extends HTMLAttributes { + cite?: Signalish; + dateTime?: Signalish; + } + + type HTMLInputTypeAttribute = + | 'button' + | 'checkbox' + | 'color' + | 'date' + | 'datetime-local' + | 'email' + | 'file' + | 'hidden' + | 'image' + | 'month' + | 'number' + | 'password' + | 'radio' + | 'range' + | 'reset' + | 'search' + | 'submit' + | 'tel' + | 'text' + | 'time' + | 'url' + | 'week' + | (string & {}); + + interface InputHTMLAttributes + extends HTMLAttributes { + accept?: Signalish; + alt?: Signalish; + autoComplete?: Signalish; + capture?: Signalish<'user' | 'environment' | undefined>; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute + checked?: Signalish; + disabled?: Signalish; + enterKeyHint?: Signalish< + | 'enter' + | 'done' + | 'go' + | 'next' + | 'previous' + | 'search' + | 'send' + | undefined + >; + form?: Signalish; + formAction?: Signalish; + formEncType?: Signalish; + formMethod?: Signalish; + formNoValidate?: Signalish; + formTarget?: Signalish; + height?: Signalish; + list?: Signalish; + max?: Signalish; + maxLength?: Signalish; + min?: Signalish; + minLength?: Signalish; + multiple?: Signalish; + name?: Signalish; + pattern?: Signalish; + placeholder?: Signalish; + readOnly?: Signalish; + required?: Signalish; + size?: Signalish; + src?: Signalish; + step?: Signalish; + type?: HTMLInputTypeAttribute | undefined; + value?: Signalish; + width?: Signalish; + onChange?: ChangeEventHandler | undefined; + } + + interface KeygenHTMLAttributes + extends HTMLAttributes { + challenge?: Signalish; + disabled?: Signalish; + form?: Signalish; + keyType?: Signalish; + keyParams?: Signalish; + name?: Signalish; + } + + interface LabelHTMLAttributes + extends HTMLAttributes { + form?: Signalish; + htmlFor?: Signalish; + } + + interface LiHTMLAttributes extends HTMLAttributes { + value?: Signalish; + } + + interface LinkHTMLAttributes + extends HTMLAttributes { + as?: Signalish; + crossOrigin?: Signalish; + fetchPriority?: Signalish<'high' | 'low' | 'auto'>; + href?: Signalish; + hrefLang?: Signalish; + integrity?: Signalish; + media?: Signalish; + imageSrcSet?: Signalish; + referrerPolicy?: HTMLAttributeReferrerPolicy | undefined; + sizes?: Signalish; + type?: Signalish; + charSet?: Signalish; + } + + interface MapHTMLAttributes extends HTMLAttributes { + name?: Signalish; + } + + interface MenuHTMLAttributes + extends HTMLAttributes { + type?: Signalish; + } + + interface MediaHTMLAttributes + extends HTMLAttributes { + autoPlay?: Signalish; + controls?: Signalish; + controlsList?: Signalish; + crossOrigin?: Signalish; + loop?: Signalish; + mediaGroup?: Signalish; + muted?: Signalish; + playsInline?: Signalish; + preload?: Signalish; + src?: Signalish; + } + + interface MetaHTMLAttributes + extends HTMLAttributes { + charSet?: Signalish; + httpEquiv?: Signalish; + name?: Signalish; + media?: Signalish; + } + + interface MeterHTMLAttributes + extends HTMLAttributes { + form?: Signalish; + high?: Signalish; + low?: Signalish; + max?: Signalish; + min?: Signalish; + optimum?: Signalish; + value?: Signalish; + } + + interface QuoteHTMLAttributes + extends HTMLAttributes { + cite?: Signalish; + } + + interface ObjectHTMLAttributes + extends HTMLAttributes { + classID?: Signalish; + data?: Signalish; + form?: Signalish; + height?: Signalish; + name?: Signalish; + type?: Signalish; + useMap?: Signalish; + width?: Signalish; + wmode?: Signalish; + } + + interface OlHTMLAttributes extends HTMLAttributes { + reversed?: Signalish; + start?: Signalish; + type?: Signalish<'1' | 'a' | 'A' | 'i' | 'I' | undefined>; + } + + interface OptgroupHTMLAttributes + extends HTMLAttributes { + disabled?: Signalish; + label?: Signalish; + } + + interface OptionHTMLAttributes + extends HTMLAttributes { + disabled?: Signalish; + label?: Signalish; + selected?: Signalish; + value?: Signalish; + } + + interface OutputHTMLAttributes + extends HTMLAttributes { + form?: Signalish; + htmlFor?: Signalish; + name?: Signalish; + } + + interface ParamHTMLAttributes + extends HTMLAttributes { + name?: Signalish; + value?: Signalish; + } + + interface ProgressHTMLAttributes + extends HTMLAttributes { + max?: Signalish; + value?: Signalish; + } + + interface SlotHTMLAttributes + extends HTMLAttributes { + name?: Signalish; + } + + interface ScriptHTMLAttributes + extends HTMLAttributes { + async?: Signalish; + /** @deprecated */ + charSet?: Signalish; + crossOrigin?: Signalish; + defer?: Signalish; + integrity?: Signalish; + noModule?: Signalish; + referrerPolicy?: HTMLAttributeReferrerPolicy | undefined; + src?: Signalish; + type?: Signalish; + } + + interface SelectHTMLAttributes + extends HTMLAttributes { + autoComplete?: Signalish; + disabled?: Signalish; + form?: Signalish; + multiple?: Signalish; + name?: Signalish; + required?: Signalish; + size?: Signalish; + value?: Signalish; + onChange?: ChangeEventHandler | undefined; + } + + interface SourceHTMLAttributes + extends HTMLAttributes { + height?: Signalish; + media?: Signalish; + sizes?: Signalish; + src?: Signalish; + srcSet?: Signalish; + type?: Signalish; + width?: Signalish; + } + + interface StyleHTMLAttributes + extends HTMLAttributes { + media?: Signalish; + scoped?: Signalish; + type?: Signalish; + } + + interface TableHTMLAttributes + extends HTMLAttributes { + cellPadding?: Signalish; + cellSpacing?: Signalish; + summary?: Signalish; + width?: Signalish; + } + + interface TextareaHTMLAttributes + extends HTMLAttributes { + autoComplete?: Signalish; + cols?: Signalish; + dirName?: Signalish; + disabled?: Signalish; + form?: Signalish; + maxLength?: Signalish; + minLength?: Signalish; + name?: Signalish; + placeholder?: Signalish; + readOnly?: Signalish; + required?: Signalish; + rows?: Signalish; + value?: Signalish; + wrap?: Signalish; + onChange?: ChangeEventHandler | undefined; + } + + interface TdHTMLAttributes extends HTMLAttributes { + align?: Signalish< + 'left' | 'center' | 'right' | 'justify' | 'char' | undefined + >; + colSpan?: Signalish; + headers?: Signalish; + rowSpan?: Signalish; + scope?: Signalish; + abbr?: Signalish; + height?: Signalish; + width?: Signalish; + valign?: Signalish<'top' | 'middle' | 'bottom' | 'baseline' | undefined>; + } + + interface ThHTMLAttributes extends HTMLAttributes { + align?: Signalish< + 'left' | 'center' | 'right' | 'justify' | 'char' | undefined + >; + colSpan?: Signalish; + headers?: Signalish; + rowSpan?: Signalish; + scope?: Signalish; + abbr?: Signalish; + } + + interface TimeHTMLAttributes + extends HTMLAttributes { + dateTime?: Signalish; + } + + interface TrackHTMLAttributes + extends HTMLAttributes { + default?: Signalish; + kind?: Signalish; + label?: Signalish; + src?: Signalish; + srcLang?: Signalish; + } + + interface VideoHTMLAttributes + extends MediaHTMLAttributes { + height?: Signalish; + playsInline?: Signalish; + poster?: Signalish; + width?: Signalish; + disablePictureInPicture?: Signalish; + disableRemotePlayback?: Signalish; + } + + interface WebViewHTMLAttributes + extends HTMLAttributes { + allowFullScreen?: Signalish; + allowpopups?: Signalish; + autosize?: Signalish; + blinkfeatures?: Signalish; + disableblinkfeatures?: Signalish; + disableguestresize?: Signalish; + disablewebsecurity?: Signalish; + guestinstance?: Signalish; + httpreferrer?: Signalish; + nodeintegration?: Signalish; + partition?: Signalish; + plugins?: Signalish; + preload?: Signalish; + src?: Signalish; + useragent?: Signalish; + webpreferences?: Signalish; + } + // Events export import TargetedEvent = JSXInternal.TargetedEvent; export import ChangeEvent = JSXInternal.TargetedEvent; diff --git a/src/jsx.d.ts b/src/jsx.d.ts index 138967a104..df2489ae00 100644 --- a/src/jsx.d.ts +++ b/src/jsx.d.ts @@ -2901,8 +2901,70 @@ export namespace JSXInternal { } export interface HTMLSemanticsElement extends MathMLElement {} + + export interface IntrinsicSVGElements { + svg: SVGAttributes; + animate: SVGAttributes; + circle: SVGAttributes; + animateMotion: SVGAttributes; + animateTransform: SVGAttributes; + clipPath: SVGAttributes; + defs: SVGAttributes; + desc: SVGAttributes; + ellipse: SVGAttributes; + feBlend: SVGAttributes; + feColorMatrix: SVGAttributes; + feComponentTransfer: SVGAttributes; + feComposite: SVGAttributes; + feConvolveMatrix: SVGAttributes; + feDiffuseLighting: SVGAttributes; + feDisplacementMap: SVGAttributes; + feDistantLight: SVGAttributes; + feDropShadow: SVGAttributes; + feFlood: SVGAttributes; + feFuncA: SVGAttributes; + feFuncB: SVGAttributes; + feFuncG: SVGAttributes; + feFuncR: SVGAttributes; + feGaussianBlur: SVGAttributes; + feImage: SVGAttributes; + feMerge: SVGAttributes; + feMergeNode: SVGAttributes; + feMorphology: SVGAttributes; + feOffset: SVGAttributes; + fePointLight: SVGAttributes; + feSpecularLighting: SVGAttributes; + feSpotLight: SVGAttributes; + feTile: SVGAttributes; + feTurbulence: SVGAttributes; + filter: SVGAttributes; + foreignObject: SVGAttributes; + g: SVGAttributes; + image: SVGAttributes; + line: SVGAttributes; + linearGradient: SVGAttributes; + marker: SVGAttributes; + mask: SVGAttributes; + metadata: SVGAttributes; + mpath: SVGAttributes; + path: SVGAttributes; + pattern: SVGAttributes; + polygon: SVGAttributes; + polyline: SVGAttributes; + radialGradient: SVGAttributes; + rect: SVGAttributes; + set: SVGAttributes; + stop: SVGAttributes; + switch: SVGAttributes; + symbol: SVGAttributes; + text: SVGAttributes; + textPath: SVGAttributes; + tspan: SVGAttributes; + use: SVGAttributes; + view: SVGAttributes; + } - export interface IntrinsicElements { + export interface IntrinsicElements extends IntrinsicSVGElements { // HTML a: HTMLAttributes; abbr: HTMLAttributes; @@ -3022,67 +3084,6 @@ export namespace JSXInternal { video: HTMLAttributes; wbr: HTMLAttributes; - //SVG - svg: SVGAttributes; - animate: SVGAttributes; - circle: SVGAttributes; - animateMotion: SVGAttributes; - animateTransform: SVGAttributes; - clipPath: SVGAttributes; - defs: SVGAttributes; - desc: SVGAttributes; - ellipse: SVGAttributes; - feBlend: SVGAttributes; - feColorMatrix: SVGAttributes; - feComponentTransfer: SVGAttributes; - feComposite: SVGAttributes; - feConvolveMatrix: SVGAttributes; - feDiffuseLighting: SVGAttributes; - feDisplacementMap: SVGAttributes; - feDistantLight: SVGAttributes; - feDropShadow: SVGAttributes; - feFlood: SVGAttributes; - feFuncA: SVGAttributes; - feFuncB: SVGAttributes; - feFuncG: SVGAttributes; - feFuncR: SVGAttributes; - feGaussianBlur: SVGAttributes; - feImage: SVGAttributes; - feMerge: SVGAttributes; - feMergeNode: SVGAttributes; - feMorphology: SVGAttributes; - feOffset: SVGAttributes; - fePointLight: SVGAttributes; - feSpecularLighting: SVGAttributes; - feSpotLight: SVGAttributes; - feTile: SVGAttributes; - feTurbulence: SVGAttributes; - filter: SVGAttributes; - foreignObject: SVGAttributes; - g: SVGAttributes; - image: SVGAttributes; - line: SVGAttributes; - linearGradient: SVGAttributes; - marker: SVGAttributes; - mask: SVGAttributes; - metadata: SVGAttributes; - mpath: SVGAttributes; - path: SVGAttributes; - pattern: SVGAttributes; - polygon: SVGAttributes; - polyline: SVGAttributes; - radialGradient: SVGAttributes; - rect: SVGAttributes; - set: SVGAttributes; - stop: SVGAttributes; - switch: SVGAttributes; - symbol: SVGAttributes; - text: SVGAttributes; - textPath: SVGAttributes; - tspan: SVGAttributes; - use: SVGAttributes; - view: SVGAttributes; - // MathML See https://developer.mozilla.org/en-US/docs/Web/MathML 'annotation-xml': MathMLAttributes; annotation: MathMLAttributes;