@ktjs/core 0.28.1 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,201 +0,0 @@
1
- import { otherstring, HTMLTag, SVGTag, MathMLTag } from '@ktjs/shared';
2
-
3
- declare const enum KTReactiveType {
4
- REF = 1,
5
- COMPUTED = 2
6
- }
7
-
8
- type ReactiveChangeHandler<T> = (newValue: T, oldValue: T) => void;
9
-
10
- declare class KTRef<T> {
11
- /**
12
- * Indicates that this is a KTRef instance
13
- */
14
- isKT: true;
15
- ktType: KTReactiveType;
16
- constructor(_value: T, _onChanges: Array<ReactiveChangeHandler<T>>);
17
- /**
18
- * If new value and old value are both nodes, the old one will be replaced in the DOM
19
- */
20
- get value(): T;
21
- set value(newValue: T);
22
- /**
23
- * Force all listeners to run even when reference identity has not changed.
24
- * Useful for in-place array/object mutations.
25
- */
26
- notify(): void;
27
- /**
28
- * Mutate current value in-place and notify listeners once.
29
- *
30
- * @example
31
- * const items = ref<number[]>([1, 2]);
32
- * items.mutate((list) => list.push(3));
33
- */
34
- mutate<R = void>(mutator: (currentValue: T) => R): R;
35
- /**
36
- * Register a callback when the value changes
37
- * @param callback (newValue, oldValue) => xxx
38
- */
39
- addOnChange(callback: ReactiveChangeHandler<T>): void;
40
- removeOnChange(callback: ReactiveChangeHandler<T>): boolean;
41
- }
42
-
43
- type HTML<T extends (HTMLTag | SVGTag | MathMLTag) & otherstring> = T extends SVGTag
44
- ? SVGElementTagNameMap[T]
45
- : T extends HTMLTag
46
- ? HTMLElementTagNameMap[T]
47
- : T extends MathMLTag
48
- ? MathMLElementTagNameMap[T]
49
- : HTMLElement;
50
-
51
- type SingleContent = KTRef<any> | HTMLElement | Element | Node | string | number | boolean | null | undefined;
52
- type KTAvailableContent = SingleContent | KTAvailableContent[];
53
- type KTRawContent = KTAvailableContent | Promise<KTAvailableContent>;
54
- type KTRawAttr = KTAttribute | null | undefined | '' | false;
55
-
56
- /**
57
- * Used to create enhanced HTML elements
58
- */
59
- interface KTBaseAttribute {
60
- [k: string]: any;
61
-
62
- // # kt-specific attributes
63
- ref?: KTRef<JSX.Element>;
64
-
65
- /**
66
- * If a `KTRef` is bound, it will be reactive; otherwise, it will be static.
67
- */
68
- 'k-if'?: any;
69
-
70
- /**
71
- * Register two-way data binding between an input element and a KTRef.
72
- * - Default to regist `input` event and `value` property(`checked` for checkboxes and radios).
73
- */
74
- 'k-model'?: KTRef<any>;
75
-
76
- /**
77
- * Directly apply html string to `innerHTML`.
78
- * - Would be reactive if `KTRef` instance is provided
79
- */
80
- 'k-html'?: any;
81
-
82
- // # normal HTML attributes
83
- id?: string;
84
- class?: string;
85
- className?: string;
86
- style?: string | Partial<CSSStyleDeclaration>;
87
-
88
- type?:
89
- | 'text'
90
- | 'password'
91
- | 'email'
92
- | 'number'
93
- | 'tel'
94
- | 'url'
95
- | 'search'
96
- | 'date'
97
- | 'datetime-local'
98
- | 'time'
99
- | 'month'
100
- | 'week'
101
- | 'color'
102
- | 'range'
103
- | 'file'
104
- | 'checkbox'
105
- | 'radio'
106
- | 'hidden'
107
- | 'submit'
108
- | 'reset'
109
- | 'button'
110
- | 'image'
111
- | otherstring;
112
- for?: string;
113
-
114
- name?: string;
115
- title?: string;
116
- placeholder?: string;
117
- contenteditable?: boolean;
118
- value?: any;
119
- valueAsDate?: Date;
120
- valueAsNumber?: number;
121
- label?: string;
122
- disabled?: boolean;
123
-
124
- min?: string | number;
125
- max?: string | number;
126
- step?: string | number;
127
-
128
- selected?: boolean;
129
- checked?: boolean;
130
-
131
- action?: string;
132
- method?: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'CONNECT' | 'TRACE' | otherstring;
133
- }
134
-
135
- type KTPrefixedEventAttribute = {
136
- [EventName in keyof HTMLElementEventMap as `on:${EventName}`]?: (ev: HTMLElementEventMap[EventName]) => void;
137
- };
138
-
139
- type KTAttribute = KTBaseAttribute & KTPrefixedEventAttribute;
140
-
141
- /**
142
- * Create an enhanced HTMLElement.
143
- * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
144
- * @param tag tag of an `HTMLElement`
145
- * @param attr attribute object or className
146
- * @param content a string or an array of HTMLEnhancedElement as child nodes
147
- *
148
- * ## About
149
- * @package @ktjs/core
150
- * @author Kasukabe Tsumugi <futami16237@gmail.com>
151
- * @version 0.28.1 (Last Update: 2026.02.10 11:23:01.128)
152
- * @license MIT
153
- * @link https://github.com/baendlorel/kt.js
154
- * @link https://baendlorel.github.io/ Welcome to my site!
155
- * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
156
- * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
157
- */
158
- declare const h: <T extends HTMLTag | SVGTag | MathMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>;
159
-
160
- type JSXTag = HTMLTag | ((props?: any) => HTMLElement) | ((props?: any) => Promise<HTMLElement>);
161
- /**
162
- * @param tag html tag or function component
163
- * @param props properties/attributes
164
- */
165
- declare function jsx(tag: JSXTag, props: KTAttribute): JSX.Element;
166
- /**
167
- * Fragment support - returns an array of children
168
- * Enhanced Fragment component that manages arrays of elements
169
- */
170
- declare function Fragment(props: {
171
- children?: KTRawContent;
172
- }): JSX.Element;
173
- /**
174
- * JSX Development runtime - same as jsx but with additional dev checks
175
- */
176
- declare const jsxDEV: typeof jsx;
177
- /**
178
- * JSX runtime for React 17+ automatic runtime
179
- * This is called when using jsx: "react-jsx" or "react-jsxdev"
180
- */
181
- declare const jsxs: typeof jsx;
182
-
183
- /**
184
- * A helper to create redrawable elements
185
- * ```tsx
186
- * export function MyComponent() {
187
- * let aa = 10;
188
- * // ...
189
- * // aa might be changed
190
- * return createRedrawable(() => <div>{aa}</div>);
191
- * }
192
- * ```
193
- * Then the returned element has a `redraw` method to redraw itself with new values.
194
- * @param creator a simple creator function that returns an element
195
- * @returns created element's ref
196
- */
197
- declare function createRedrawable<T>(creator: () => T): KTRef<T> & {
198
- redraw: () => T;
199
- };
200
-
201
- export { Fragment, h as createElement, createRedrawable, h, jsx, jsxDEV, jsxs };