];
* ```
*/
declare function createFragment(props: FragmentProps): JSX.Element & KTFragmentAnchor;
export declare const createMathMLElement: (tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML;
export declare const createSVGElement: (tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML;
export declare type Dereactive = T extends KTReactive ? U : T;
/**
* Register a reactive effect with options.
* @param effectFn The effect function to run when dependencies change
* @param reactives The reactive dependencies
* @param options Effect options: lazy, onCleanup, debugName
* @returns stop function to remove all listeners
*/
export declare function effect(effectFn: () => void, reactives: Array>, options?: Partial): () => void;
/**
* Fragment support - returns an array of children
* Enhanced Fragment component that manages arrays of elements
*/
export declare const Fragment: typeof createFragment;
declare interface FragmentProps {
ref?: KTRef;
children: SingleContent[];
}
/**
* Create an enhanced HTMLElement.
* - Only supports HTMLElements, **NOT** SVGElements or other Elements.
* @param tag tag of an `HTMLElement`
* @param attr attribute object or className
* @param content a string or an array of HTMLEnhancedElement as child nodes
*
* ## About
* @package @ktjs/core
* @author Kasukabe Tsumugi
* @version 0.40.26 (Last Update: 2026.05.24 06:13:25.666)
* @license MIT
* @link https://github.com/baendlorel/kt.js
* @link https://baendlorel.github.io/ Welcome to my site!
* @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
* @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
*/
declare const h: (tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML;
export { h as createElement }
export { h }
export declare type HTML = T extends SVGTag ? SVGElementTagNameMap[T] : T extends HTMLTag ? HTMLElementTagNameMap[T] : T extends MathMLTag ? MathMLElementTagNameMap[T] : HTMLElement;
export { HTMLTag }
export { InputElementTag }
export declare const isComputed: (o: any) => o is KTComputed;
/**
* Only checks if `ktype` is a number, which is the common property of all KTReactive instances.
*/
export declare const isKT: (o: any) => o is KTReactive;
/**
* @returns `true` for both `KTRef` and `KTSubRef`, since `KTSubRef` is a subclass of `KTRef`
*/
export declare const isRef: (o: any) => o is KTRef;
export declare const isRefExact: (o: any) => o is KTRef;
export declare const isSubRef: (o: any) => o is KTSubRef;
export declare namespace JSX {
export type Element = AliasElement;
export interface IntrinsicElements {
[k: string]: AttributesMap['div'];
html: AttributesMap['html'];
head: AttributesMap['head'];
title: AttributesMap['title'];
base: AttributesMap['base'];
link: AttributesMap['link'];
meta: AttributesMap['meta'];
body: AttributesMap['body'];
header: AttributesMap['header'];
footer: AttributesMap['footer'];
nav: AttributesMap['nav'];
main: AttributesMap['main'];
section: AttributesMap['section'];
article: AttributesMap['article'];
aside: AttributesMap['aside'];
h1: AttributesMap['h1'];
h2: AttributesMap['h2'];
h3: AttributesMap['h3'];
h4: AttributesMap['h4'];
h5: AttributesMap['h5'];
h6: AttributesMap['h6'];
p: AttributesMap['p'];
pre: AttributesMap['pre'];
code: AttributesMap['code'];
strong: AttributesMap['strong'];
small: AttributesMap['small'];
em: AttributesMap['em'];
br: AttributesMap['br'];
i: AttributesMap['i'];
ul: AttributesMap['ul'];
ol: AttributesMap['ol'];
li: AttributesMap['li'];
table: AttributesMap['table'];
thead: AttributesMap['thead'];
tbody: AttributesMap['tbody'];
tfoot: AttributesMap['tfoot'];
tr: AttributesMap['tr'];
th: AttributesMap['th'];
td: AttributesMap['td'];
form: AttributesMap['form'];
label: AttributesMap['label'];
input: AttributesMap['input'];
textarea: AttributesMap['textarea'];
select: AttributesMap['select'];
option: AttributesMap['option'];
optgroup: AttributesMap['optgroup'];
button: AttributesMap['button'];
fieldset: AttributesMap['fieldset'];
legend: AttributesMap['legend'];
datalist: AttributesMap['datalist'];
output: AttributesMap['output'];
img: AttributesMap['img'];
picture: AttributesMap['picture'];
source: AttributesMap['source'];
audio: AttributesMap['audio'];
video: AttributesMap['video'];
track: AttributesMap['track'];
iframe: AttributesMap['iframe'];
embed: AttributesMap['embed'];
object: AttributesMap['object'];
canvas: AttributesMap['canvas'];
a: AttributesMap['a'] & SVGAttributesMap['a'];
area: AttributesMap['area'];
map: AttributesMap['map'];
details: AttributesMap['details'];
dialog: AttributesMap['dialog'];
summary: AttributesMap['summary'];
slot: AttributesMap['slot'];
script: AttributesMap['script'];
style: AttributesMap['style'];
figure: AttributesMap['figure'];
figcaption: AttributesMap['figcaption'];
blockquote: AttributesMap['blockquote'];
q: AttributesMap['q'];
div: AttributesMap['div'];
span: AttributesMap['span'];
address: AttributesMap['address'];
abbr: AttributesMap['abbr'];
b: AttributesMap['b'];
cite: AttributesMap['cite'];
dl: AttributesMap['dl'];
dt: AttributesMap['dt'];
dd: AttributesMap['dd'];
hr: AttributesMap['hr'];
svg: AttributesMap['svg'];
animate: SVGAttributesMap['animate'];
animateMotion: SVGAttributesMap['animateMotion'];
animateTransform: SVGAttributesMap['animateTransform'];
circle: SVGAttributesMap['circle'];
clipPath: SVGAttributesMap['clipPath'];
defs: SVGAttributesMap['defs'];
desc: SVGAttributesMap['desc'];
ellipse: SVGAttributesMap['ellipse'];
feBlend: SVGAttributesMap['feBlend'];
feColorMatrix: SVGAttributesMap['feColorMatrix'];
feComponentTransfer: SVGAttributesMap['feComponentTransfer'];
feComposite: SVGAttributesMap['feComposite'];
feConvolveMatrix: SVGAttributesMap['feConvolveMatrix'];
feDiffuseLighting: SVGAttributesMap['feDiffuseLighting'];
feDisplacementMap: SVGAttributesMap['feDisplacementMap'];
feDistantLight: SVGAttributesMap['feDistantLight'];
feDropShadow: SVGAttributesMap['feDropShadow'];
feFlood: SVGAttributesMap['feFlood'];
feFuncA: SVGAttributesMap['feFuncA'];
feFuncB: SVGAttributesMap['feFuncB'];
feFuncG: SVGAttributesMap['feFuncG'];
feFuncR: SVGAttributesMap['feFuncR'];
feGaussianBlur: SVGAttributesMap['feGaussianBlur'];
feImage: SVGAttributesMap['feImage'];
feMerge: SVGAttributesMap['feMerge'];
feMergeNode: SVGAttributesMap['feMergeNode'];
feMorphology: SVGAttributesMap['feMorphology'];
feOffset: SVGAttributesMap['feOffset'];
fePointLight: SVGAttributesMap['fePointLight'];
feSpecularLighting: SVGAttributesMap['feSpecularLighting'];
feSpotLight: SVGAttributesMap['feSpotLight'];
feTile: SVGAttributesMap['feTile'];
feTurbulence: SVGAttributesMap['feTurbulence'];
filter: SVGAttributesMap['filter'];
foreignObject: SVGAttributesMap['foreignObject'];
g: SVGAttributesMap['g'];
image: SVGAttributesMap['image'];
line: SVGAttributesMap['line'];
linearGradient: SVGAttributesMap['linearGradient'];
marker: SVGAttributesMap['marker'];
mask: SVGAttributesMap['mask'];
metadata: SVGAttributesMap['metadata'];
mpath: SVGAttributesMap['mpath'];
path: SVGAttributesMap['path'];
pattern: SVGAttributesMap['pattern'];
polygon: SVGAttributesMap['polygon'];
polyline: SVGAttributesMap['polyline'];
radialGradient: SVGAttributesMap['radialGradient'];
rect: SVGAttributesMap['rect'];
set: SVGAttributesMap['set'];
stop: SVGAttributesMap['stop'];
switch: SVGAttributesMap['switch'];
symbol: SVGAttributesMap['symbol'];
text: SVGAttributesMap['text'];
textPath: SVGAttributesMap['textPath'];
tspan: SVGAttributesMap['tspan'];
use: SVGAttributesMap['use'];
view: SVGAttributesMap['view'];
}
export interface IntrinsicAttributes {
/**
* Make a reference to the created element
*/
ref?: KTRef;
/**
* Conditional rendering
* - Provide a `KTRef` to make it reactive
*/
'k-if'?: any;
/**
* Conditional rendering, must come after `k-if`
* @throws Error if used without a preceding `k-if` or coexisting with another `k-if`
*/
'k-else'?: any;
/**
* List rendering. Must provide an iterable or array-like `KTReactive`
*/
'k-for'?: any;
/**
* List key. Use it with `k-for`
*/
'k-key'?: any;
/**
* 2-way binding. Must provide a `KTRef`
*/
'k-model'?: KTRef;
/**
* Raw HTML escape hatch.
* - Provide a `KTRef` to make it reactive.
* - Directly writes to `innerHTML` with no sanitization.
* - Only use trusted HTML.
* - Do not pass user-controlled strings unless you sanitize them yourself first.
*/
'k-html'?: any;
children?: KTRawContent;
}
export interface ElementChildrenAttribute {
children: {};
}
}
export declare const jsx: JSXCreator;
export declare type JSXCreator = (tag: JSXTag, props: KTAttribute) => JSX.Element;
/**
* JSX Development runtime - same as jsx but with additional dev checks
*/
export declare const jsxDEV: typeof jsx;
/**
* JSX runtime for React 17+ automatic runtime
* This is called when using jsx: "react-jsx" or "react-jsxdev"
*/
export declare const jsxs: JSXCreator;
declare abstract class KTAnchor extends Comment {
readonly atype: AType;
constructor(atype: AType);
/**
* [WARN] Different from `_remove`, removes the elements **and itself**.
*/
remove(): void;
}
export declare function KTAsync
(props: KTAsyncProps
): JSX.Element;
declare interface KTAsyncProps
{
/**
* Will be assigned as this Anchor
*/
ref?: KTRef;
/**
* Display this when loading the async component.
*/
skeleton?: JSX.Element;
/**
* Async Component(a promise holds an component)
*/
component: (props: P) => Thenable;
props?: P;
}
export declare type KTAttribute = KTBaseAttribute & KTPrefixedEventAttribute;
/**
* Used to create enhanced HTML elements
*/
declare interface KTBaseAttribute {
/**
* Additional attributes are forwarded to the DOM as-is.
* kt.js does not sanitize raw HTML, URLs, `srcdoc`, or native `on*` attribute values.
* If you bind untrusted input here, sanitization is the application's responsibility.
*/
[k: string]: any;
ref?: KTRef;
/**
* If a `KTRef` is bound, it will be reactive; otherwise, it will be static.
*/
'k-if'?: any;
/**
* Register two-way data binding between an input element and a KTRef.
* - Default to register `input` event and `value` property(`checked` for checkboxes and radios).
*/
'k-model'?: KTRef;
/**
* Raw HTML escape hatch. Directly assigns to `innerHTML`.
* - Provide a `KTRef` to make it reactive.
* - No sanitization is performed by kt.js.
* - Only pass trusted HTML.
* - Never bind user-controlled strings here without application-level sanitization.
*/
'k-html'?: any;
id?: string;
class?: string;
className?: string;
style?: string | Partial;
type?: 'text' | 'password' | 'email' | 'number' | 'tel' | 'url' | 'search' | 'date' | 'datetime-local' | 'time' | 'month' | 'week' | 'color' | 'range' | 'file' | 'checkbox' | 'radio' | 'hidden' | 'submit' | 'reset' | 'button' | 'image' | otherstring;
for?: string;
name?: string;
title?: string;
placeholder?: string;
contenteditable?: boolean;
value?: any;
valueAsDate?: Date;
valueAsNumber?: number;
label?: string;
disabled?: boolean;
min?: string | number;
max?: string | number;
step?: string | number;
selected?: boolean;
checked?: boolean;
action?: string;
method?: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'CONNECT' | 'TRACE' | otherstring;
}
export declare class KTComputed extends KTReactive {
readonly ktype = KType.Computed;
constructor(calculator: () => T, dependencies: Array>);
notify(): this;
unlisten(listener: ChangeListener): this;
dispose(): void;
}
declare interface KTEffectOptions {
lazy: boolean;
onCleanup: () => void;
debugName: string;
owner: Node;
}
/**
* KTFor - List rendering component with key-based optimization
* Returns a Comment anchor node with rendered elements in anchor.list
*/
export declare function KTFor(props: KTForProps): KTForElement;
declare class KTForAnchor extends KTAnchor {
constructor(list: KTForList, key: Required>['key'], map: Required>['map']);
}
declare type KTForElement = JSX.Element & KTForAnchor;
declare type KTForList = TList | KTReactive;
export declare interface KTForProps {
list: KTForList;
key?: (item: TList[number], index: number, array: TList) => any;
map?: (item: TList[number], index: number, array: TList) => SingleContent;
}
declare class KTFragmentAnchor extends KTAnchor {
constructor(children: SingleContent[]);
}
/**
* @param cond Can be reactive or static.
*/
export declare function KTIf(cond: any, tagIf: JSXTag, pIf: PropGetter, tagElse?: JSXTag, pElse?: PropGetter): JSX.Element;
export declare interface KTListenOptions {
owner?: Node;
}
export declare type KTMaybeReactive = T | KTReactify;
export declare type KTMaybeReactiveProps = {
[K in keyof T]: K extends `on:${string}` ? T[K] : KTMaybeReactive> | T[K];
};
export declare type KTPrefixedEventAttribute = {
[EventName in keyof HTMLElementEventMap as `on:${EventName}`]?: (ev: HTMLElementEventMap[EventName]) => void;
};
export declare type KTRawAttr = KTAttribute | null | undefined | '' | false;
export declare type KTRawContent = SingleContent | MultiContent;
/**
* Makes `KTReactify<'a' | 'b'>` to be `KTReactive<'a' | 'b'>`
*/
export declare type KTReactify = [T] extends [KTReactive] ? KTReactive : KTReactive;
export declare type KTReactifyObject = {
[K in keyof T]: KTReactifySplit;
};
export declare type KTReactifyProps = {
[K in keyof T]: KTReactifySplit> | T[K];
};
/**
* Makes `KTReactify<'a' | 'b'> to be KTReactive<'a'> | KTReactive<'b'>`
*/
export declare type KTReactifySplit = T extends boolean ? KTReactive : T extends any ? KTReactive : never;
export declare abstract class KTReactive {
readonly kid: number;
constructor(value: T);
get value(): T;
set value(newValue: T);
listen(listener: ChangeListener, options?: KTListenOptions | Node): this;
unlisten(listener: ChangeListener): this;
unlistenAll(): this;
notify(): this;
/**
* Create a computed value via current reactive value.
* - No matter `this` is added to `dependencies` or not, it is always listened.
* @param calculator A function that generates a new value based on current value.
* @param dependencies optional other dependencies that the computed value depends on.
*/
map(calculator: (value: T) => U, dependencies?: Array>): KTComputed;
/**
* Make a computed value that checks if the reactive value is strictly equal to a specific value.
* - Use `Object.is` for comparison.
* - if `o` is reactive-like, it will be added to dependencies
*/
is(o: T | KTReactive): KTComputed;
/**
* Make a computed value that checks if the reactive value matches a specific object structure.
* - Deeply match.
* - if `o` is reactive-like, it will be added to dependencies
*/
match(o: object | KTReactive