// What Framework — JSX runtime type definitions. // // Enables type-checked JSX authoring with: // "jsx": "react-jsx", "jsxImportSource": "what-framework" (or "what-core") // // What is DOM-native and lenient at runtime: attributes pass through as-is, // both `class`/`className` and camelCase/lowercase event handlers are accepted // (events are bound via `key.slice(2).toLowerCase()`), and any attribute value // may be reactive — a plain value OR a `() => value` thunk. These types mirror // that behavior: common attributes are explicitly typed for autocomplete and // documentation, while an index signature keeps arbitrary/custom attributes and // web-component tags valid (never false-flagging code the runtime accepts). import type { VNode, VNodeChild } from './index.js'; export { Fragment } from './index.js'; /** Static or reactive attribute value; nullish values remove the attribute. */ export type Reactive = T | null | undefined | (() => T | null | undefined); export function jsx(type: any, props: any, key?: any): VNode; export function jsxs(type: any, props: any, key?: any): VNode; type EventHandler = (event: E & { currentTarget: EventTarget & Element; target: Element }) => void; interface WhatEventHandlers { // What lowercases the event name, so both spellings resolve to the same DOM event. onClick?: EventHandler; onclick?: EventHandler; onDblClick?: EventHandler; ondblclick?: EventHandler; onMouseDown?: EventHandler; onmousedown?: EventHandler; onMouseUp?: EventHandler; onmouseup?: EventHandler; onMouseEnter?: EventHandler; onmouseenter?: EventHandler; onMouseLeave?: EventHandler; onmouseleave?: EventHandler; onMouseMove?: EventHandler; onmousemove?: EventHandler; onInput?: EventHandler; oninput?: EventHandler; onChange?: EventHandler; onchange?: EventHandler; onSubmit?: EventHandler; onsubmit?: EventHandler; onReset?: EventHandler; onreset?: EventHandler; onKeyDown?: EventHandler; onkeydown?: EventHandler; onKeyUp?: EventHandler; onkeyup?: EventHandler; onKeyPress?: EventHandler; onkeypress?: EventHandler; onFocus?: EventHandler; onfocus?: EventHandler; onBlur?: EventHandler; onblur?: EventHandler; onScroll?: EventHandler; onscroll?: EventHandler; } interface WhatHTMLAttributes extends WhatEventHandlers { children?: VNodeChild; /** Component-list reconciliation key. */ key?: string | number; ref?: ((el: any) => void) | { current: any }; class?: Reactive; className?: Reactive; id?: Reactive; style?: Reactive>; title?: Reactive; role?: Reactive; slot?: Reactive; lang?: Reactive; dir?: Reactive; hidden?: Reactive; draggable?: Reactive; contentEditable?: Reactive; tabindex?: Reactive; tabIndex?: Reactive; // Common data-/aria- attributes remain typed; arbitrary ones fall through below. [dataAttr: `data-${string}`]: any; [ariaAttr: `aria-${string}`]: any; /** What passes unknown attributes straight to the DOM; keep them valid. */ [attr: string]: any; } interface WhatInputAttributes extends WhatHTMLAttributes { type?: Reactive; value?: Reactive; checked?: Reactive; placeholder?: Reactive; disabled?: Reactive; readonly?: Reactive; readOnly?: Reactive; required?: Reactive; name?: Reactive; min?: Reactive; max?: Reactive; step?: Reactive; pattern?: Reactive; autocomplete?: Reactive; autofocus?: Reactive; } interface WhatAnchorAttributes extends WhatHTMLAttributes { href?: Reactive; target?: Reactive; rel?: Reactive; download?: Reactive; } interface WhatImgAttributes extends WhatHTMLAttributes { src?: Reactive; srcset?: Reactive; alt?: Reactive; width?: Reactive; height?: Reactive; loading?: Reactive<'eager' | 'lazy'>; decoding?: Reactive<'async' | 'auto' | 'sync'>; } interface WhatButtonAttributes extends WhatHTMLAttributes { type?: Reactive<'button' | 'submit' | 'reset'>; disabled?: Reactive; name?: Reactive; value?: Reactive; form?: Reactive; } interface WhatFormAttributes extends WhatHTMLAttributes { action?: Reactive; method?: Reactive; enctype?: Reactive; novalidate?: Reactive; target?: Reactive; } interface WhatLabelAttributes extends WhatHTMLAttributes { for?: Reactive; htmlFor?: Reactive; } interface WhatOptionAttributes extends WhatHTMLAttributes { value?: Reactive; selected?: Reactive; disabled?: Reactive; } interface WhatSelectAttributes extends WhatHTMLAttributes { value?: Reactive; name?: Reactive; disabled?: Reactive; required?: Reactive; multiple?: Reactive; } interface WhatTextareaAttributes extends WhatHTMLAttributes { value?: Reactive; placeholder?: Reactive; rows?: Reactive; cols?: Reactive; disabled?: Reactive; readonly?: Reactive; required?: Reactive; name?: Reactive; } interface WhatMediaAttributes extends WhatHTMLAttributes { src?: Reactive; controls?: Reactive; autoplay?: Reactive; loop?: Reactive; muted?: Reactive; poster?: Reactive; preload?: Reactive; } // SVG (recharts and other chart libraries render through this). interface WhatSVGAttributes extends WhatHTMLAttributes { width?: Reactive; height?: Reactive; viewBox?: Reactive; fill?: Reactive; stroke?: Reactive; x?: Reactive; y?: Reactive; cx?: Reactive; cy?: Reactive; r?: Reactive; d?: Reactive; points?: Reactive; transform?: Reactive; } export namespace JSX { type Element = VNode; // TS 5.1+ checks component returns separately from the JSX expression type. // `never` accepts each component's own props without erasing JSX prop checks. type ElementType = string | ((props: never) => VNodeChild); interface ElementChildrenAttribute { children: {}; } interface IntrinsicAttributes { key?: string | number; } interface IntrinsicElements { // Element-specific typing (autocomplete for the props that matter most). a: WhatAnchorAttributes; img: WhatImgAttributes; input: WhatInputAttributes; button: WhatButtonAttributes; form: WhatFormAttributes; label: WhatLabelAttributes; option: WhatOptionAttributes; select: WhatSelectAttributes; textarea: WhatTextareaAttributes; video: WhatMediaAttributes; audio: WhatMediaAttributes; source: WhatMediaAttributes; // Structural / text / sectioning elements. div: WhatHTMLAttributes; span: WhatHTMLAttributes; p: WhatHTMLAttributes; section: WhatHTMLAttributes; article: WhatHTMLAttributes; header: WhatHTMLAttributes; footer: WhatHTMLAttributes; main: WhatHTMLAttributes; aside: WhatHTMLAttributes; nav: WhatHTMLAttributes; h1: WhatHTMLAttributes; h2: WhatHTMLAttributes; h3: WhatHTMLAttributes; h4: WhatHTMLAttributes; h5: WhatHTMLAttributes; h6: WhatHTMLAttributes; ul: WhatHTMLAttributes; ol: WhatHTMLAttributes; li: WhatHTMLAttributes; dl: WhatHTMLAttributes; dt: WhatHTMLAttributes; dd: WhatHTMLAttributes; table: WhatHTMLAttributes; thead: WhatHTMLAttributes; tbody: WhatHTMLAttributes; tfoot: WhatHTMLAttributes; tr: WhatHTMLAttributes; th: WhatHTMLAttributes; td: WhatHTMLAttributes; caption: WhatHTMLAttributes; colgroup: WhatHTMLAttributes; col: WhatHTMLAttributes; fieldset: WhatHTMLAttributes; legend: WhatHTMLAttributes; strong: WhatHTMLAttributes; em: WhatHTMLAttributes; b: WhatHTMLAttributes; i: WhatHTMLAttributes; u: WhatHTMLAttributes; small: WhatHTMLAttributes; mark: WhatHTMLAttributes; code: WhatHTMLAttributes; pre: WhatHTMLAttributes; kbd: WhatHTMLAttributes; blockquote: WhatHTMLAttributes; hr: WhatHTMLAttributes; br: WhatHTMLAttributes; figure: WhatHTMLAttributes; figcaption: WhatHTMLAttributes; details: WhatHTMLAttributes; summary: WhatHTMLAttributes; dialog: WhatHTMLAttributes; picture: WhatHTMLAttributes; iframe: WhatHTMLAttributes; canvas: WhatHTMLAttributes; template: WhatHTMLAttributes; slot: WhatHTMLAttributes; time: WhatHTMLAttributes; progress: WhatHTMLAttributes; meter: WhatHTMLAttributes; output: WhatHTMLAttributes; datalist: WhatHTMLAttributes; optgroup: WhatHTMLAttributes; // SVG. svg: WhatSVGAttributes; g: WhatSVGAttributes; path: WhatSVGAttributes; circle: WhatSVGAttributes; ellipse: WhatSVGAttributes; rect: WhatSVGAttributes; line: WhatSVGAttributes; polyline: WhatSVGAttributes; polygon: WhatSVGAttributes; text: WhatSVGAttributes; tspan: WhatSVGAttributes; defs: WhatSVGAttributes; linearGradient: WhatSVGAttributes; radialGradient: WhatSVGAttributes; stop: WhatSVGAttributes; clipPath: WhatSVGAttributes; use: WhatSVGAttributes; // Custom elements / web components remain valid. [tagName: string]: WhatHTMLAttributes; } }