= C extends abstract new (
...args: any
) => ElementClass
? Partial
: P
/*
JSX.IntrinsicClassAttributes // class attributes
JSX.IntrinsicElements // tags
JSX.IntrinsicAttributes // leaks to class and functional components
*/
// JSX.Element - return `value` of components
type Element =
| string
| number
| bigint
| boolean
| symbol
| undefined
| void
// fancy
| object // such CSSStyleSheet
// dom
| DOMElement
| ChildNode
| ElementType
// | DocumentFragment cannot be `children`, we use `childNodes` instead
// recurse
| (() => Element)
| Promise
| Element[]
// JSX.ElementType - shape of a `component`
type ElementType =
| keyof IntrinsicElements
| (new (
props?: Record,
) => ElementClass)
| ((props?: Record) => Element)
| { toString(): Element }
// JSX.ElementClass - shape of `class` component
type ElementClass = {
props?: Record
ready?: () => void
cleanup?: () => void
render: (props?: Record) => Element
}
// TYPES
type Props = T & { children?: Element }
type BooleanAttribute = boolean | ''
type EnumeratedPseudoBoolean = 'false' | 'true'
type StyleAttribute = Attribute
// EVENTS
type EventHandler =
| EventFunction
| EventObject
| (EventObject & EventHandlerOptions)
type EventHandlers =
| EventHandler
| EventHandlers[] // recursive type
type EventEvent = Event & {
currentTarget: Element
}
type EventFunction =
| ((e?: EventEvent) => void)
| Function
type EventObject = {
handleEvent(e: EventEvent): void
}
type EventHandlerOptions = AddEventListenerOptions &
EventListenerOptions
// CALLBACKS
type CallbackElement =
| ((node: Element) => void)
| CallbackElement[] // recursive type
type CallbackBind = SignalFunction | CallbackBind[] // recursive type
// CORE
interface PotaAttributes {
children?: JSX.Element // This is `JSX.Element`! Not `Element` argument
// rendering
'use:normalize'?: true
// lifecycles
'use:ref'?: CallbackElement
'use:connected'?: CallbackElement
'use:disconnected'?: CallbackElement
// PLUGINS
'use:bind'?: CallbackBind // no `` !
}
// all elements
interface IntrinsicElements
extends HTMLDeprecatedElements,
MathMLDeprecatedElements,
MathMLElements,
SVGElements,
HTMLElements,
HTMLSpecialElements {}
interface Elements extends IntrinsicElements {}
/* Attributes */
interface ElementAttributes
extends PotaAttributes,
CSSAttributes,
AriaAttributes,
EventHandlersElement {
// properties
'prop:innerHTML'?: Attribute
'prop:textContent'?: Attribute
// attributes
// xml
xmlns?: Attribute
[attr: `xmlns:${string}`]: Attribute
autofocus?: Attribute
elementtiming?: Attribute
id?: Attribute
nonce?: Attribute
part?: Attribute
slot?: Attribute
tabindex?: Attribute
}
interface HTMLAttributes
extends ElementAttributes {
// properties
'prop:innerText'?: Attribute
// attributes
accesskey?: Attribute
anchor?: Attribute
autocapitalize?: Attribute<
'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters'
>
autocorrect?: Attribute<'on' | 'off'>
contenteditable?: Attribute<
EnumeratedPseudoBoolean | 'plaintext-only' | 'inherit' | ''
>
dir?: Attribute<'ltr' | 'rtl' | 'auto'>
draggable?: Attribute
enterkeyhint?: Attribute<
| 'enter'
| 'done'
| 'go'
| 'next'
| 'previous'
| 'search'
| 'send'
>
exportparts?: Attribute
hidden?: Attribute<'' | 'hidden' | 'until-found'>
inert?: Attribute
inputmode?: Attribute<
| 'decimal'
| 'email'
| 'none'
| 'numeric'
| 'search'
| 'tel'
| 'text'
| 'url'
>
is?: Attribute
lang?: Attribute
popover?: Attribute<'' | 'manual' | 'auto' | 'hint'>
spellcheck?: Attribute<'' | EnumeratedPseudoBoolean>
title?: Attribute
translate?: Attribute<'yes' | 'no'>
// microdata
itemid?: Attribute
itemprop?: Attribute
itemref?: Attribute
itemscope?: Attribute
itemtype?: Attribute
// RDFa attributes
about?: Attribute
datatype?: Attribute
inlist?: Attribute
prefix?: Attribute
property?: Attribute
resource?: Attribute
typeof?: Attribute
vocab?: Attribute
/** @experimental */
virtualkeyboardpolicy?: Attribute<'' | 'auto' | 'manual'>
/** @experimental */
writingsuggestions?: Attribute
/** @deprecated */
contextmenu?: Attribute
}
interface SVGAttributes
extends ElementAttributes {
[attr: `${string}`]: Attribute // catch all TODO
}
interface MathMLAttributes
extends ElementAttributes {
dir?: Attribute<'ltr' | 'rtl' | 'auto'>
displaystyle?: Attribute
scriptlevel?: Attribute
/** @deprecated */
href?: Attribute
/** @deprecated */
mathbackground?: Attribute
/** @deprecated */
mathcolor?: Attribute
/** @deprecated */
mathsize?: Attribute
}
/* SPECIAL INTERFACES */
interface HTMLMediaHTMLAttributes {
// attributes
autoplay?: Attribute
controls?: Attribute
controlslist?: Attribute<
| 'nodownload'
| 'nofullscreen'
| 'noplaybackrate'
| 'noremoteplayback'
| (string & {})
>
crossorigin?: Attribute<'anonymous' | 'use-credentials' | ''>
disableremoteplayback?: Attribute
loop?: Attribute
muted?: Attribute
preload?: Attribute<'none' | 'metadata' | 'auto' | ''>
src?: Attribute
'on:encrypted'?: EventHandlers
'on:waitingforkey'?: EventHandlers
/** @deprecated */
mediagroup?: Attribute
}
/* SPECIAL ELEMENTS */
interface HTMLWebViewElementAttributes
extends HTMLAttributes {
allowpopups?: Attribute
disableblinkfeatures?: Attribute
disablewebsecurity?: Attribute
enableblinkfeatures?: Attribute
httpreferrer?: Attribute
nodeintegration?: Attribute
nodeintegrationinsubframes?: Attribute
partition?: Attribute
plugins?: Attribute
preload?: Attribute
src?: Attribute
useragent?: Attribute
webpreferences?: Attribute
// does this exists?
allowfullscreen?: Attribute
autosize?: Attribute
/** @deprecated */
blinkfeatures?: Attribute
/** @deprecated */
disableguestresize?: Attribute
/** @deprecated */
guestinstance?: Attribute
}
/* HTMLElements */
interface HTMLAnchorElementAttributes
extends HTMLAttributes {
download?: Attribute
href?: Attribute
hreflang?: Attribute
ping?: Attribute
referrerpolicy?: Attribute<
| 'no-referrer'
| 'no-referrer-when-downgrade'
| 'origin'
| 'origin-when-cross-origin'
| 'same-origin'
| 'strict-origin'
| 'strict-origin-when-cross-origin'
| 'unsafe-url'
>
rel?: Attribute
target?: Attribute<
'_self' | '_blank' | '_parent' | '_top' | (string & {})
>
type?: Attribute
/** @experimental */
attributionsrc?: Attribute
/** @deprecated */
charset?: Attribute
/** @deprecated */
coords?: Attribute
/** @deprecated */
name?: Attribute
/** @deprecated */
rev?: Attribute
/** @deprecated */
shape?: Attribute<'rect' | 'circle' | 'poly' | 'default'>
}
interface HTMLAreaElementAttributes
extends HTMLAttributes {
alt?: Attribute
coords?: Attribute
download?: Attribute
href?: Attribute
ping?: Attribute
referrerpolicy?: Attribute<
| 'no-referrer'
| 'no-referrer-when-downgrade'
| 'origin'
| 'origin-when-cross-origin'
| 'same-origin'
| 'strict-origin'
| 'strict-origin-when-cross-origin'
| 'unsafe-url'
>
rel?: Attribute
shape?: Attribute<'rect' | 'circle' | 'poly' | 'default'>
target?: Attribute<
'_self' | '_blank' | '_parent' | '_top' | (string & {})
>
/** @experimental */
attributionsrc?: Attribute
/** @deprecated */
nohref?: Attribute
}
interface HTMLAudioElementAttributes
extends HTMLAttributes,
HTMLMediaHTMLAttributes {}
interface HTMLBRElementAttributes
extends HTMLAttributes {
/** @deprecated */
clear?: Attribute
}
interface HTMLBaseElementAttributes
extends HTMLAttributes {
href?: Attribute
target?: Attribute<
'_self' | '_blank' | '_parent' | '_top' | (string & {})
>
}
interface HTMLBdoElementAttributes
extends HTMLAttributes {}
interface HTMLBodyElementAttributes
extends HTMLAttributes,
EventHandlersWindow {
/** @deprecated */
alink?: Attribute
/** @deprecated */
background?: Attribute
/** @deprecated */
bgcolor?: Attribute
/** @deprecated */
bottommargin?: Attribute
/** @deprecated */
leftmargin?: Attribute
/** @deprecated */
link?: Attribute
/** @deprecated */
rightmargin?: Attribute
/** @deprecated */
text?: Attribute
/** @deprecated */
topmargin?: Attribute
/** @deprecated */
vlink?: Attribute
}
interface HTMLButtonElementAttributes
extends HTMLAttributes {
command?: Attribute<
| 'show-modal'
| 'close'
| 'show-popover'
| 'hide-popover'
| 'toggle-popover'
| (string & {})
>
commandfor?: Attribute
disabled?: Attribute
form?: Attribute
formaction?: Attribute
formenctype?: Attribute<
| 'application/x-www-form-urlencoded'
| 'multipart/form-data'
| 'text/plain'
>
formmethod?: Attribute<'post' | 'get' | 'dialog'>
formnovalidate?: Attribute
formtarget?: Attribute<
'_self' | '_blank' | '_parent' | '_top' | (string & {})
>
name?: Attribute
popovertarget?: Attribute
popovertargetaction?: Attribute<'hide' | 'show' | 'toggle'>
type?: Attribute<'submit' | 'reset' | 'button' | 'menu'>
value?: Attribute
}
interface HTMLCanvasElementAttributes
extends HTMLAttributes {
height?: Attribute
width?: Attribute
/** @deprecated */
'moz-opaque'?: Attribute
}
interface HTMLDListElementAttributes
extends HTMLAttributes {
/** @deprecated */
compact?: Attribute
}
interface HTMLDataElementAttributes
extends HTMLAttributes {
value?: Attribute
}
interface HTMLDataListElementAttributes
extends HTMLAttributes {}
interface HTMLDetailsElementAttributes
extends HTMLAttributes {
name?: Attribute
open?: Attribute
}
interface HTMLDialogElementAttributes
extends HTMLAttributes {
open?: Attribute
tabindex?: never
'prop:tabindex'?: never
/** @experimental */
closedby?: Attribute<'any' | 'closerequest' | 'none'>
}
interface HTMLDivElementAttributes
extends HTMLAttributes {
/** @deprecated */
align?: Attribute<'left' | 'right' | 'justify' | 'center'>
}
interface HTMLElementAttributes
extends HTMLAttributes {}
interface HTMLEmbedElementAttributes
extends HTMLAttributes {
height?: Attribute
src?: Attribute
type?: Attribute
width?: Attribute
/** @deprecated */
align?: Attribute<'left' | 'right' | 'justify' | 'center'>
/** @deprecated */
name?: Attribute
}
interface HTMLFieldSetElementAttributes
extends HTMLAttributes {
disabled?: Attribute
form?: Attribute
name?: Attribute
}
interface HTMLFormElementAttributes
extends HTMLAttributes {
'accept-charset'?: Attribute
action?: Attribute
autocomplete?: Attribute<'on' | 'off'>
encoding?: Attribute<
| 'application/x-www-form-urlencoded'
| 'multipart/form-data'
| 'text/plain'
>
enctype?: Attribute<
| 'application/x-www-form-urlencoded'
| 'multipart/form-data'
| 'text/plain'
>
method?: Attribute<'post' | 'get' | 'dialog'>
name?: Attribute
novalidate?: Attribute
rel?: Attribute
target?: Attribute<
'_self' | '_blank' | '_parent' | '_top' | (string & {})
>
/** @deprecated */
accept?: Attribute
}
interface HTMLHRElementAttributes
extends HTMLAttributes {
/** @deprecated */
align?: Attribute
/** @deprecated */
color?: Attribute
/** @deprecated */
noshade?: Attribute
/** @deprecated */
size?: Attribute
/** @deprecated */
width?: Attribute
}
interface HTMLHeadElementAttributes
extends HTMLAttributes {
/** @deprecated */
profile?: Attribute
}
interface HTMLHeadingElementAttributes
extends HTMLAttributes {
/** @deprecated */
align?: Attribute<'left' | 'right' | 'justify' | 'center'>
}
interface HTMLHtmlElementAttributes
extends HTMLAttributes {
/** @deprecated */
version?: Attribute
}
interface HTMLIFrameElementAttributes
extends HTMLAttributes {
allow?: Attribute
allowfullscreen?: Attribute
height?: Attribute
loading?: Attribute<'eager' | 'lazy'>
name?: Attribute
referrerpolicy?: Attribute<
| 'no-referrer'
| 'no-referrer-when-downgrade'
| 'origin'
| 'origin-when-cross-origin'
| 'same-origin'
| 'strict-origin'
| 'strict-origin-when-cross-origin'
| 'unsafe-url'
>
sandbox?: Attribute<
| 'allow-downloads-without-user-activation'
| 'allow-downloads'
| 'allow-forms'
| 'allow-modals'
| 'allow-orientation-lock'
| 'allow-pointer-lock'
| 'allow-popups'
| 'allow-popups-to-escape-sandbox'
| 'allow-presentation'
| 'allow-same-origin'
| 'allow-scripts'
| 'allow-storage-access-by-user-activation'
| 'allow-top-navigation'
| 'allow-top-navigation-by-user-activation'
| 'allow-top-navigation-to-custom-protocols'
| string
>
src?: Attribute
srcdoc?: Attribute
width?: Attribute
/** @non-standard */
browsingtopics?: Attribute
/** @experimental */
credentialless?: Attribute
/** @experimental */
csp?: Attribute
/** @experimental */
sharedstoragewritable?: Attribute
/** @experimental */
adauctionheaders?: Attribute
/** @experimental */
privatetoken?: Attribute
/** @deprecated */
allowpaymentrequest?: Attribute
/** @deprecated */
allowtransparency?: Attribute
/** @deprecated */
align?: Attribute
/** @deprecated */
frameborder?: Attribute
/** @deprecated */
longdesc?: Attribute
/** @deprecated */
marginheight?: Attribute
/** @deprecated */
marginwidth?: Attribute
/** @deprecated */
scrolling?: Attribute<'yes' | 'no' | 'auto'>
/** @deprecated */
seamless?: Attribute
}
interface HTMLImageElementAttributes
extends HTMLAttributes