///
import { DefaultReflexBaseProps, VNode } from "./common";
import { IAtom } from "./states";
/**
* JSX types are straight stolen from Preact. Thanks Preact core team ✌️
* https://github.com/preactjs/preact/blob/master/src/jsx.d.ts
* It has been a bit adapted for Reflex API
*
* TODO : Missing
* - JSX.Element
* - JSX.ElementClass
* - Default const r = ref() without generics should work
*
* TODO : Errors
* - Disallow a component render function to return a component as main node !
* () => <- Forbidden
* - Disallow a component which render an array
* () => [
, ] <- Forbidden
*/
export type ComponentChild = VNode | string | number | null | undefined | boolean | object | bigint | (() => VNode);
export interface DefaultReflexJSXAttributes extends DefaultReflexBaseProps {
children?: ComponentChild | ComponentChild[];
}
type TargetedEvent = TypedEvent;
type TargetedAnimationEvent = TargetedEvent;
type TargetedClipboardEvent = TargetedEvent;
type TargetedCompositionEvent = TargetedEvent;
type TargetedDragEvent = TargetedEvent;
type TargetedFocusEvent = TargetedEvent;
type TargetedKeyboardEvent = TargetedEvent;
type TargetedMouseEvent = TargetedEvent;
type TargetedPointerEvent = TargetedEvent;
type TargetedTouchEvent = TargetedEvent;
type TargetedTransitionEvent = TargetedEvent;
type TargetedUIEvent = TargetedEvent;
type TargetedWheelEvent = TargetedEvent;
interface EventHandler {
/**
* The `this` keyword always points to the DOM element the event handler
* was invoked on. See: https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Event_handlers#Event_handlers_parameters_this_binding_and_the_return_value
*/
(this: never, event: E): void;
}
type AnimationEventHandler = EventHandler>;
type ClipboardEventHandler = EventHandler>;
type CompositionEventHandler = EventHandler>;
type DragEventHandler = EventHandler>;
type FocusEventHandler = EventHandler>;
type GenericEventHandler = EventHandler>;
type KeyboardEventHandler = EventHandler>;
type MouseEventHandler = EventHandler>;
type PointerEventHandler = EventHandler>;
type TouchEventHandler = EventHandler>;
type TransitionEventHandler = EventHandler>;
type UIEventHandler = EventHandler>;
type WheelEventHandler = EventHandler>;
export interface DOMAttributes {
onLoad?: GenericEventHandler;
onLoadCapture?: GenericEventHandler;
onError?: GenericEventHandler;
onErrorCapture?: GenericEventHandler;
onCopy?: ClipboardEventHandler;
onCopyCapture?: ClipboardEventHandler;
onCut?: ClipboardEventHandler;
onCutCapture?: ClipboardEventHandler;
onPaste?: ClipboardEventHandler;
onPasteCapture?: ClipboardEventHandler;
onCompositionEnd?: CompositionEventHandler;
onCompositionEndCapture?: CompositionEventHandler;
onCompositionStart?: CompositionEventHandler;
onCompositionStartCapture?: CompositionEventHandler;
onCompositionUpdate?: CompositionEventHandler;
onCompositionUpdateCapture?: CompositionEventHandler;
onToggle?: GenericEventHandler;
onFocus?: FocusEventHandler;
onFocusCapture?: FocusEventHandler;
onfocusin?: FocusEventHandler;
onfocusinCapture?: FocusEventHandler;
onfocusout?: FocusEventHandler;
onfocusoutCapture?: FocusEventHandler;
onBlur?: FocusEventHandler;
onBlurCapture?: FocusEventHandler;
onChange?: GenericEventHandler;
onChangeCapture?: GenericEventHandler;
onInput?: GenericEventHandler;
onInputCapture?: GenericEventHandler;
onBeforeInput?: GenericEventHandler;
onBeforeInputCapture?: GenericEventHandler;
onSearch?: GenericEventHandler;
onSearchCapture?: GenericEventHandler;
onSubmit?: GenericEventHandler;
onSubmitCapture?: GenericEventHandler;
onInvalid?: GenericEventHandler;
onInvalidCapture?: GenericEventHandler;
onReset?: GenericEventHandler;
onResetCapture?: GenericEventHandler;
onFormData?: GenericEventHandler;
onFormDataCapture?: GenericEventHandler;
onKeyDown?: KeyboardEventHandler;
onKeyDownCapture?: KeyboardEventHandler;
onKeyPress?: KeyboardEventHandler;
onKeyPressCapture?: KeyboardEventHandler;
onKeyUp?: KeyboardEventHandler;
onKeyUpCapture?: KeyboardEventHandler;
onAbort?: GenericEventHandler;
onAbortCapture?: GenericEventHandler;
onCanPlay?: GenericEventHandler;
onCanPlayCapture?: GenericEventHandler;
onCanPlayThrough?: GenericEventHandler;
onCanPlayThroughCapture?: GenericEventHandler;
onDurationChange?: GenericEventHandler;
onDurationChangeCapture?: GenericEventHandler;
onEmptied?: GenericEventHandler;
onEmptiedCapture?: GenericEventHandler;
onEncrypted?: GenericEventHandler;
onEncryptedCapture?: GenericEventHandler;
onEnded?: GenericEventHandler;
onEndedCapture?: GenericEventHandler;
onLoadedData?: GenericEventHandler;
onLoadedDataCapture?: GenericEventHandler;
onLoadedMetadata?: GenericEventHandler;
onLoadedMetadataCapture?: GenericEventHandler;
onLoadStart?: GenericEventHandler;
onLoadStartCapture?: GenericEventHandler;
onPause?: GenericEventHandler;
onPauseCapture?: GenericEventHandler;
onPlay?: GenericEventHandler;
onPlayCapture?: GenericEventHandler;
onPlaying?: GenericEventHandler;
onPlayingCapture?: GenericEventHandler;
onProgress?: GenericEventHandler;
onProgressCapture?: GenericEventHandler;
onRateChange?: GenericEventHandler;
onRateChangeCapture?: GenericEventHandler;
onSeeked?: GenericEventHandler;
onSeekedCapture?: GenericEventHandler;
onSeeking?: GenericEventHandler;
onSeekingCapture?: GenericEventHandler;
onStalled?: GenericEventHandler;
onStalledCapture?: GenericEventHandler;
onSuspend?: GenericEventHandler;
onSuspendCapture?: GenericEventHandler;
onTimeUpdate?: GenericEventHandler;
onTimeUpdateCapture?: GenericEventHandler;
onVolumeChange?: GenericEventHandler;
onVolumeChangeCapture?: GenericEventHandler;
onWaiting?: GenericEventHandler;
onWaitingCapture?: GenericEventHandler;
onClick?: MouseEventHandler;
onClickCapture?: MouseEventHandler;
onContextMenu?: MouseEventHandler;
onContextMenuCapture?: MouseEventHandler;
onDblClick?: MouseEventHandler;
onDblClickCapture?: MouseEventHandler;
onDrag?: DragEventHandler;
onDragCapture?: DragEventHandler;
onDragEnd?: DragEventHandler;
onDragEndCapture?: DragEventHandler;
onDragEnter?: DragEventHandler;
onDragEnterCapture?: DragEventHandler;
onDragExit?: DragEventHandler;
onDragExitCapture?: DragEventHandler;
onDragLeave?: DragEventHandler;
onDragLeaveCapture?: DragEventHandler;
onDragOver?: DragEventHandler;
onDragOverCapture?: DragEventHandler;
onDragStart?: DragEventHandler;
onDragStartCapture?: DragEventHandler;
onDrop?: DragEventHandler;
onDropCapture?: DragEventHandler;
onMouseDown?: MouseEventHandler;
onMouseDownCapture?: MouseEventHandler;
onMouseEnter?: MouseEventHandler;
onMouseEnterCapture?: MouseEventHandler;
onMouseLeave?: MouseEventHandler;
onMouseLeaveCapture?: MouseEventHandler;
onMouseMove?: MouseEventHandler;
onMouseMoveCapture?: MouseEventHandler;
onMouseOut?: MouseEventHandler;
onMouseOutCapture?: MouseEventHandler;
onMouseOver?: MouseEventHandler;
onMouseOverCapture?: MouseEventHandler;
onMouseUp?: MouseEventHandler;
onMouseUpCapture?: MouseEventHandler;
onSelect?: GenericEventHandler;
onSelectCapture?: GenericEventHandler;
onTouchCancel?: TouchEventHandler;
onTouchCancelCapture?: TouchEventHandler;
onTouchEnd?: TouchEventHandler;
onTouchEndCapture?: TouchEventHandler;
onTouchMove?: TouchEventHandler;
onTouchMoveCapture?: TouchEventHandler;
onTouchStart?: TouchEventHandler;
onTouchStartCapture?: TouchEventHandler;
onPointerOver?: PointerEventHandler;
onPointerOverCapture?: PointerEventHandler;
onPointerEnter?: PointerEventHandler;
onPointerEnterCapture?: PointerEventHandler;
onPointerDown?: PointerEventHandler;
onPointerDownCapture?: PointerEventHandler;
onPointerMove?: PointerEventHandler;
onPointerMoveCapture?: PointerEventHandler;
onPointerUp?: PointerEventHandler;
onPointerUpCapture?: PointerEventHandler;
onPointerCancel?: PointerEventHandler;
onPointerCancelCapture?: PointerEventHandler;
onPointerOut?: PointerEventHandler;
onPointerOutCapture?: PointerEventHandler;
onPointerLeave?: PointerEventHandler;
onPointerLeaveCapture?: PointerEventHandler;
onGotPointerCapture?: PointerEventHandler;
onGotPointerCaptureCapture?: PointerEventHandler;
onLostPointerCapture?: PointerEventHandler;
onLostPointerCaptureCapture?: PointerEventHandler;
onScroll?: UIEventHandler;
onScrollCapture?: UIEventHandler;
onWheel?: WheelEventHandler;
onWheelCapture?: WheelEventHandler;
onAnimationStart?: AnimationEventHandler;
onAnimationStartCapture?: AnimationEventHandler;
onAnimationEnd?: AnimationEventHandler;
onAnimationEndCapture?: AnimationEventHandler;
onAnimationIteration?: AnimationEventHandler;
onAnimationIterationCapture?: AnimationEventHandler;
onTransitionEnd?: TransitionEventHandler;
onTransitionEndCapture?: TransitionEventHandler;
}
interface HTMLMarqueeElement extends HTMLElement {
behavior?: 'scroll' | 'slide' | 'alternate';
bgColor?: string;
direction?: 'left' | 'right' | 'up' | 'down';
height?: number | string;
hspace?: number | string;
loop?: number | string;
scrollAmount?: number | string;
scrollDelay?: number | string;
trueSpeed?: boolean;
vspace?: number | string;
width?: number | string;
}
type DOMCSSProperties = {
[key in keyof Omit]?: string | number | null | undefined;
};
type AllCSSProperties = {
[key: string]: string | number | null | undefined;
};
export interface CSSProperties extends AllCSSProperties, DOMCSSProperties {
cssText?: string | null;
}
export type ClassNameItem = string | boolean;
export type ClassName = (ClassNameItem | (ClassNameItem | (ClassNameItem[]))[]);
type AttributeState = (G | IAtom);
export interface HTMLAttributes extends DefaultReflexJSXAttributes, DOMAttributes {
accept?: AttributeState;
acceptCharset?: AttributeState;
accessKey?: AttributeState;
action?: AttributeState;
allow?: AttributeState;
allowFullScreen?: AttributeState;
allowTransparency?: AttributeState;
alt?: AttributeState;
as?: AttributeState;
async?: AttributeState;
autocomplete?: AttributeState;
autoComplete?: AttributeState;
autocorrect?: AttributeState;
autoCorrect?: AttributeState;
autofocus?: AttributeState;
autoFocus?: AttributeState;
autoPlay?: AttributeState;
capture?: AttributeState;
cellPadding?: AttributeState;
cellSpacing?: AttributeState;
charSet?: AttributeState;
challenge?: AttributeState;
checked?: AttributeState;
cite?: AttributeState;
class?: AttributeState;
className?: AttributeState;
inert?: AttributeState