@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.
package/dist/index.d.ts CHANGED
@@ -1,1468 +1,434 @@
1
- import { otherstring, HTMLTag, SVGTag, MathMLTag } from '@ktjs/shared';
2
- export { HTMLTag, InputElementTag, MathMLTag, SVGTag } from '@ktjs/shared';
3
-
4
- declare class KTComputed<T> {
5
- /**
6
- * Indicates that this is a KTRef instance
7
- */
8
- isKT: true;
9
- ktType: KTReactiveType;
10
- constructor(_calculator: () => T, reactives: Array<KTReactive<unknown>>);
11
- /**
12
- * If new value and old value are both nodes, the old one will be replaced in the DOM
13
- */
14
- get value(): T;
15
- set value(_newValue: T);
16
- /**
17
- * Force listeners to run once with the latest computed result.
18
- */
19
- notify(): void;
20
- /**
21
- * Computed values are derived from dependencies and should not be mutated manually.
22
- */
23
- mutate<R = void>(_mutator?: (value: T) => R): void;
24
- /**
25
- * Register a callback when the value changes
26
- * @param callback (newValue, oldValue) => xxx
27
- */
28
- addOnChange(callback: ReactiveChangeHandler<T>): void;
29
- /**
30
- * Unregister a callback
31
- * @param callback (newValue, oldValue) => xxx
32
- */
33
- removeOnChange(callback: ReactiveChangeHandler<T>): boolean;
34
- }
35
- /**
36
- * Create a reactive computed value
37
- * @param computeFn
38
- * @param reactives refs and computeds that this computed depends on
39
- */
40
- declare function computed<T = JSX.Element>(computeFn: () => T, reactives: Array<KTReactive<any>>): KTComputed<T>;
41
-
42
- interface KTEffectOptions {
43
- lazy: boolean;
44
- onCleanup: () => void;
45
- debugName: string;
46
- }
47
- /**
48
- * Register a reactive effect with options.
49
- * @param effectFn The effect function to run when dependencies change
50
- * @param reactives The reactive dependencies
51
- * @param options Effect options: lazy, onCleanup, debugName
52
- * @returns stop function to remove all listeners
53
- */
54
- declare function effect(effectFn: () => void, reactives: Array<KTReactive<any>>, options?: Partial<KTEffectOptions>): () => void;
55
-
56
- declare const toReactive: <T>(value: T | KTReactive<T>, onChange?: ReactiveChangeHandler<T>) => KTReactive<T>;
57
- /**
58
- * Extracts the value from a KTReactive, or returns the value directly if it's not reactive.
59
- */
60
- declare function dereactive<T = JSX.Element>(value: T | KTReactive<T>): T;
61
- type KTReactify<T> = T extends boolean ? KTReactive<boolean> : T extends any ? KTReactive<T> : never;
62
- type KTReactifyObject<T extends object> = {
63
- [K in keyof T]: KTReactify<T[K]>;
64
- };
65
- type KTReactifyProps<T extends object> = {
66
- [K in keyof T]: KTReactify<Exclude<T[K], undefined>> | T[K];
67
- };
68
-
69
- declare const enum KTReactiveType {
70
- REF = 1,
71
- COMPUTED = 2
72
- }
73
- declare const isKT: <T = any>(obj: any) => obj is KTReactive<T>;
74
- declare const isRef: <T = any>(obj: any) => obj is KTRef<T>;
75
- declare const isComputed: <T = any>(obj: any) => obj is KTComputed<T>;
76
-
77
- type ReactiveChangeHandler<T> = (newValue: T, oldValue: T) => void;
78
-
79
- declare class KTReactive<T> {
80
- /**
81
- * Indicates that this is a KTRef instance
82
- */
83
- isKT: boolean;
84
-
85
- ktType: KTReactiveType;
86
-
87
- /**
88
- * If new value and old value are both nodes, the old one will be replaced in the DOM
89
- */
90
- get value();
91
- set value(newValue: T);
92
-
93
- /**
94
- * Force all listeners to run even when reference identity has not changed.
95
- * Useful for in-place array/object mutations.
96
- */
97
- notify(): void;
98
-
99
- /**
100
- * Mutate current value in-place and notify listeners once.
101
- *
102
- * @example
103
- * const items = ref<number[]>([1, 2]);
104
- * items.mutate((list) => list.push(3));
105
- */
106
- mutate<R = void>(mutator: (currentValue: T) => R): R;
107
- /**
108
- * Register a callback when the value changes
109
- * @param callback (newValue, oldValue) => xxx
110
- */
111
- addOnChange(callback: ReactiveChangeHandler<T>): void;
112
- removeOnChange(callback: ReactiveChangeHandler<T>): void;
113
- }
114
-
115
- declare class KTRef<T> {
116
- /**
117
- * Indicates that this is a KTRef instance
118
- */
119
- isKT: true;
120
- ktType: KTReactiveType;
121
- constructor(_value: T, _onChanges: Array<ReactiveChangeHandler<T>>);
122
- /**
123
- * If new value and old value are both nodes, the old one will be replaced in the DOM
124
- */
125
- get value(): T;
126
- set value(newValue: T);
127
- /**
128
- * Force all listeners to run even when reference identity has not changed.
129
- * Useful for in-place array/object mutations.
130
- */
131
- notify(): void;
132
- /**
133
- * Mutate current value in-place and notify listeners once.
134
- *
135
- * @example
136
- * const items = ref<number[]>([1, 2]);
137
- * items.mutate((list) => list.push(3));
138
- */
139
- mutate<R = void>(mutator: (currentValue: T) => R): R;
140
- /**
141
- * Register a callback when the value changes
142
- * @param callback (newValue, oldValue) => xxx
143
- */
144
- addOnChange(callback: ReactiveChangeHandler<T>): void;
145
- removeOnChange(callback: ReactiveChangeHandler<T>): boolean;
146
- }
147
- /**
148
- * Reference to the created HTML element.
149
- * - **Only** respond to `ref.value` changes, not reactive to internal changes of the element.
150
- * - can alse be used to store normal values, but it is not reactive.
151
- * - if the value is already a `KTRef`, it will be returned **directly**.
152
- * @param value mostly an HTMLElement
153
- */
154
- declare function ref<T = JSX.Element>(value?: T, onChange?: ReactiveChangeHandler<T>): KTRef<T>;
155
- /**
156
- * Convert a value to `KTRef`.
157
- * - Returns the original value if it is already a `KTRef`.
158
- * - Throws error if the value is a `KTComputed`.
159
- * - Otherwise wraps the value with `ref()`.
160
- * @param o value to convert
161
- */
162
- declare const toRef: <T = any>(o: any) => KTRef<T>;
163
- type KTSurfaceRef<T extends Object> = {
164
- [K in keyof T]: KTRef<T[K]>;
165
- } & {
166
- /**
167
- * Get the dereferenced object like the original one
168
- */
169
- kcollect: () => T;
170
- };
171
- /**
172
- * Make all first-level properties of the object a `KTRef`.
173
- * - `obj.a.b` is not reactive
174
- */
175
- declare const surfaceRef: <T extends Object>(obj: T) => KTSurfaceRef<T>;
176
- /**
177
- * Assert k-model to be a ref object
178
- */
179
- declare const $modelOrRef: <T = any>(props: any, defaultValue?: T) => KTRef<T>;
180
- declare const $setRef: (props: {
181
- ref?: KTRef<any>;
182
- }, node: Node) => void;
183
-
184
- type HTML<T extends (HTMLTag | SVGTag | MathMLTag) & otherstring> = T extends SVGTag
185
- ? SVGElementTagNameMap[T]
186
- : T extends HTMLTag
187
- ? HTMLElementTagNameMap[T]
188
- : T extends MathMLTag
189
- ? MathMLElementTagNameMap[T]
190
- : HTMLElement;
191
-
192
- type SingleContent = KTRef<any> | HTMLElement | Element | Node | string | number | boolean | null | undefined;
193
- type KTAvailableContent = SingleContent | KTAvailableContent[];
194
- type KTRawContent = KTAvailableContent | Promise<KTAvailableContent>;
195
- type KTRawAttr = KTAttribute | null | undefined | '' | false;
196
- type KTRawContents = KTAvailableContent;
197
-
198
- /**
199
- * Event handler type for DOM events
200
- */
201
- type EventHandler<T extends Event = Event> = (this: HTMLElement, ev: T) => any;
202
-
203
- /**
204
- * Used to create enhanced HTML elements
205
- */
206
- interface KTBaseAttribute {
207
- [k: string]: any;
208
-
209
- // # kt-specific attributes
210
- ref?: KTRef<JSX.Element>;
211
-
212
- /**
213
- * If a `KTRef` is bound, it will be reactive; otherwise, it will be static.
214
- */
215
- 'k-if'?: any;
216
-
217
- /**
218
- * Register two-way data binding between an input element and a KTRef.
219
- * - Default to regist `input` event and `value` property(`checked` for checkboxes and radios).
220
- */
221
- 'k-model'?: KTRef<any>;
222
-
223
- /**
224
- * Directly apply html string to `innerHTML`.
225
- * - Would be reactive if `KTRef` instance is provided
226
- */
227
- 'k-html'?: any;
228
-
229
- // # normal HTML attributes
230
- id?: string;
231
- class?: string;
232
- className?: string;
233
- style?: string | Partial<CSSStyleDeclaration>;
234
-
235
- type?:
236
- | 'text'
237
- | 'password'
238
- | 'email'
239
- | 'number'
240
- | 'tel'
241
- | 'url'
242
- | 'search'
243
- | 'date'
244
- | 'datetime-local'
245
- | 'time'
246
- | 'month'
247
- | 'week'
248
- | 'color'
249
- | 'range'
250
- | 'file'
251
- | 'checkbox'
252
- | 'radio'
253
- | 'hidden'
254
- | 'submit'
255
- | 'reset'
256
- | 'button'
257
- | 'image'
258
- | otherstring;
259
- for?: string;
260
-
261
- name?: string;
262
- title?: string;
263
- placeholder?: string;
264
- contenteditable?: boolean;
265
- value?: any;
266
- valueAsDate?: Date;
267
- valueAsNumber?: number;
268
- label?: string;
269
- disabled?: boolean;
270
-
271
- min?: string | number;
272
- max?: string | number;
273
- step?: string | number;
274
-
275
- selected?: boolean;
276
- checked?: boolean;
277
-
278
- action?: string;
279
- method?: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'CONNECT' | 'TRACE' | otherstring;
280
- }
281
-
282
- type KTPrefixedEventAttribute = {
283
- [EventName in keyof HTMLElementEventMap as `on:${EventName}`]?: (ev: HTMLElementEventMap[EventName]) => void;
284
- };
285
-
286
- type KTAttribute = KTBaseAttribute & KTPrefixedEventAttribute;
287
-
288
- type KTComponent = (
289
- props: {
290
- ref?: KTRef<JSX.Element>;
291
- children?: KTRawContent;
292
- } & KTAttribute &
293
- any,
294
- ) => JSX.Element | Promise<JSX.Element> | any;
295
-
296
- /**
297
- * Create an enhanced HTMLElement.
298
- * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
299
- * @param tag tag of an `HTMLElement`
300
- * @param attr attribute object or className
301
- * @param content a string or an array of HTMLEnhancedElement as child nodes
302
- *
303
- * ## About
304
- * @package @ktjs/core
305
- * @author Kasukabe Tsumugi <futami16237@gmail.com>
306
- * @version 0.28.1 (Last Update: 2026.02.10 11:23:01.128)
307
- * @license MIT
308
- * @link https://github.com/baendlorel/kt.js
309
- * @link https://baendlorel.github.io/ Welcome to my site!
310
- * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
311
- * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
312
- */
313
- declare const h: <T extends HTMLTag | SVGTag | MathMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>;
314
-
315
- type JSXTag = HTMLTag | ((props?: any) => HTMLElement) | ((props?: any) => Promise<HTMLElement>);
316
- /**
317
- * @param tag html tag or function component
318
- * @param props properties/attributes
319
- */
320
- declare function jsx(tag: JSXTag, props: KTAttribute): JSX.Element;
321
- /**
322
- * Fragment support - returns an array of children
323
- * Enhanced Fragment component that manages arrays of elements
324
- */
325
- declare function Fragment(props: {
326
- children?: KTRawContent;
327
- }): JSX.Element;
328
- /**
329
- * JSX Development runtime - same as jsx but with additional dev checks
330
- */
331
- declare const jsxDEV: typeof jsx;
332
- /**
333
- * JSX runtime for React 17+ automatic runtime
334
- * This is called when using jsx: "react-jsx" or "react-jsxdev"
335
- */
336
- declare const jsxs: typeof jsx;
337
-
338
- /**
339
- * A helper to create redrawable elements
340
- * ```tsx
341
- * export function MyComponent() {
342
- * let aa = 10;
343
- * // ...
344
- * // aa might be changed
345
- * return createRedrawable(() => <div>{aa}</div>);
346
- * }
347
- * ```
348
- * Then the returned element has a `redraw` method to redraw itself with new values.
349
- * @param creator a simple creator function that returns an element
350
- * @returns created element's ref
351
- */
352
- declare function createRedrawable<T>(creator: () => T): KTRef<T> & {
353
- redraw: () => T;
354
- };
355
-
356
- // Base events available to all HTML elements
357
- type BaseAttr = KTPrefixedEventAttribute &
358
- KTReactifyProps<{
359
- [k: string]: any;
360
-
361
- // # base attributes
362
- class?: string;
363
- className?: string;
364
- style?: string | Partial<CSSStyleDeclaration>;
365
- }>;
366
-
367
- interface AttributesMap {
368
- // Anchor element
369
- a: BaseAttr &
370
- KTReactifyProps<{
371
- download?: string;
372
- href?: string;
373
- hreflang?: string;
374
- ping?: string;
375
- referrerpolicy?:
376
- | 'no-referrer'
377
- | 'no-referrer-when-downgrade'
378
- | 'origin'
379
- | 'origin-when-cross-origin'
380
- | 'same-origin'
381
- | 'strict-origin'
382
- | 'strict-origin-when-cross-origin'
383
- | 'unsafe-url';
384
- rel?: string;
385
- target?: '_self' | '_blank' | '_parent' | '_top' | string;
386
- type?: string;
387
- }>;
388
-
389
- // Area element
390
- area: BaseAttr &
391
- KTReactifyProps<{
392
- alt?: string;
393
- coords?: string;
394
- download?: string;
395
- href?: string;
396
- ping?: string;
397
- referrerpolicy?:
398
- | 'no-referrer'
399
- | 'no-referrer-when-downgrade'
400
- | 'origin'
401
- | 'origin-when-cross-origin'
402
- | 'same-origin'
403
- | 'strict-origin'
404
- | 'strict-origin-when-cross-origin'
405
- | 'unsafe-url';
406
- rel?: string;
407
- shape?: 'rect' | 'circle' | 'poly' | 'default';
408
- target?: '_self' | '_blank' | '_parent' | '_top' | string;
409
- }>;
410
-
411
- // Audio element
412
- audio: BaseAttr &
413
- KTReactifyProps<{
414
- autoplay?: boolean;
415
- controls?: boolean;
416
- crossorigin?: 'anonymous' | 'use-credentials' | '';
417
- loop?: boolean;
418
- muted?: boolean;
419
- preload?: 'none' | 'metadata' | 'auto' | '';
420
- src?: string;
421
- }>;
422
-
423
- // Base element
424
- base: BaseAttr &
425
- KTReactifyProps<{
426
- href?: string;
427
- target?: '_self' | '_blank' | '_parent' | '_top' | string;
428
- }>;
429
-
430
- // Body element
431
- body: BaseAttr & KTReactifyProps<{}>;
432
-
433
- // BR element
434
- br: BaseAttr & KTReactifyProps<{}>;
435
-
436
- // Button element
437
- button: BaseAttr &
438
- KTReactifyProps<{
439
- disabled?: boolean;
440
- form?: string;
441
- formaction?: string;
442
- formenctype?: 'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/plain';
443
- formmethod?: 'get' | 'post' | 'dialog';
444
- formnovalidate?: boolean;
445
- formtarget?: '_self' | '_blank' | '_parent' | '_top' | string;
446
- name?: string;
447
- type?: 'submit' | 'reset' | 'button';
448
- value?: string;
449
- }>;
450
-
451
- // Canvas element
452
- canvas: BaseAttr &
453
- KTReactifyProps<{
454
- height?: number | string;
455
- width?: number | string;
456
- }>;
457
-
458
- // Table caption element
459
- caption: BaseAttr & KTReactifyProps<{}>;
460
-
461
- // Col element
462
- col: BaseAttr &
463
- KTReactifyProps<{
464
- span?: number | string;
465
- }>;
466
-
467
- // Colgroup element
468
- colgroup: BaseAttr &
469
- KTReactifyProps<{
470
- span?: number | string;
471
- }>;
472
-
473
- // Data element
474
- data: BaseAttr &
475
- KTReactifyProps<{
476
- value?: string;
477
- }>;
478
-
479
- // Datalist element
480
- datalist: BaseAttr & KTReactifyProps<{}>;
481
-
482
- // Del element
483
- del: BaseAttr &
484
- KTReactifyProps<{
485
- cite?: string;
486
- datetime?: string;
487
- }>;
488
-
489
- // Details element
490
- details: BaseAttr &
491
- KTReactifyProps<{
492
- open?: boolean;
493
- }>;
494
-
495
- // Dialog element
496
- dialog: BaseAttr &
497
- KTReactifyProps<{
498
- open?: boolean;
499
- }>;
500
-
501
- // Embed element
502
- embed: BaseAttr &
503
- KTReactifyProps<{
504
- height?: number | string;
505
- src?: string;
506
- type?: string;
507
- width?: number | string;
508
- }>;
509
-
510
- // Fieldset element
511
- fieldset: BaseAttr &
512
- KTReactifyProps<{
513
- disabled?: boolean;
514
- form?: string;
515
- name?: string;
516
- }>;
517
-
518
- // Form element
519
- form: BaseAttr &
520
- KTReactifyProps<{
521
- 'accept-charset'?: string;
522
- action?: string;
523
- autocomplete?: 'on' | 'off';
524
- enctype?: 'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/plain';
525
- method?: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'CONNECT' | 'TRACE' | otherstring;
526
-
527
- name?: string;
528
- novalidate?: boolean;
529
- target?: '_self' | '_blank' | '_parent' | '_top' | string;
530
- }>;
531
-
532
- // Head element
533
- head: BaseAttr & KTReactifyProps<{}>;
534
-
535
- // HR element
536
- hr: BaseAttr & KTReactifyProps<{}>;
537
-
538
- // HTML element
539
- html: BaseAttr & KTReactifyProps<{}>;
540
-
541
- // IFrame element
542
- iframe: BaseAttr &
543
- KTReactifyProps<{
544
- allow?: string;
545
- allowfullscreen?: boolean;
546
- allowpaymentrequest?: boolean;
547
- height?: number | string;
548
- loading?: 'eager' | 'lazy';
549
- name?: string;
550
- referrerpolicy?:
551
- | 'no-referrer'
552
- | 'no-referrer-when-downgrade'
553
- | 'origin'
554
- | 'origin-when-cross-origin'
555
- | 'same-origin'
556
- | 'strict-origin'
557
- | 'strict-origin-when-cross-origin'
558
- | 'unsafe-url';
559
- sandbox?: string;
560
- src?: string;
561
- srcdoc?: string;
562
- width?: number | string;
563
- }>;
564
-
565
- // Image element
566
- img: BaseAttr &
567
- KTReactifyProps<{
568
- alt?: string;
569
- crossorigin?: 'anonymous' | 'use-credentials' | '';
570
- decoding?: 'sync' | 'async' | 'auto';
571
- height?: number | string;
572
- ismap?: boolean;
573
- loading?: 'eager' | 'lazy';
574
- referrerpolicy?:
575
- | 'no-referrer'
576
- | 'no-referrer-when-downgrade'
577
- | 'origin'
578
- | 'origin-when-cross-origin'
579
- | 'same-origin'
580
- | 'strict-origin'
581
- | 'strict-origin-when-cross-origin'
582
- | 'unsafe-url';
583
- sizes?: string;
584
- src?: string;
585
- srcset?: string;
586
- usemap?: string;
587
- width?: number | string;
588
- }>;
589
-
590
- // Input element
591
- input: BaseAttr &
592
- KTReactifyProps<{
593
- accept?: string;
594
- alt?: string;
595
- autocomplete?: string;
596
- checked?: boolean;
597
- dirname?: string;
598
- disabled?: boolean;
599
- form?: string;
600
- formaction?: string;
601
- formenctype?: 'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/plain';
602
- formmethod?: 'get' | 'post';
603
- formnovalidate?: boolean;
604
- formtarget?: '_self' | '_blank' | '_parent' | '_top' | string;
605
- height?: number | string;
606
- list?: string;
607
- max?: number | string;
608
- maxlength?: number | string;
609
- min?: number | string;
610
- minlength?: number | string;
611
- multiple?: boolean;
612
- name?: string;
613
- pattern?: string;
614
- placeholder?: string;
615
- readonly?: boolean;
616
- required?: boolean;
617
- size?: number | string;
618
- src?: string;
619
- step?: number | string;
620
- type?:
621
- | 'button'
622
- | 'checkbox'
623
- | 'color'
624
- | 'date'
625
- | 'datetime-local'
626
- | 'email'
627
- | 'file'
628
- | 'hidden'
629
- | 'image'
630
- | 'month'
631
- | 'number'
632
- | 'password'
633
- | 'radio'
634
- | 'range'
635
- | 'reset'
636
- | 'search'
637
- | 'submit'
638
- | 'tel'
639
- | 'text'
640
- | 'time'
641
- | 'url'
642
- | 'week';
643
- value?: string;
644
- width?: number | string;
645
- }>;
646
-
647
- // Ins element
648
- ins: BaseAttr &
649
- KTReactifyProps<{
650
- cite?: string;
651
- datetime?: string;
652
- }>;
653
-
654
- // Label element
655
- label: BaseAttr &
656
- KTReactifyProps<{
657
- for?: string;
658
- }>;
659
-
660
- // Legend element
661
- legend: BaseAttr & KTReactifyProps<{}>;
662
-
663
- // LI element
664
- li: BaseAttr &
665
- KTReactifyProps<{
666
- value?: number | string;
667
- }>;
668
-
669
- // Link element
670
- link: BaseAttr &
671
- KTReactifyProps<{
672
- as?: string;
673
- crossorigin?: 'anonymous' | 'use-credentials' | '';
674
- disabled?: boolean;
675
- href?: string;
676
- hreflang?: string;
677
- imagesizes?: string;
678
- imagesrcset?: string;
679
- integrity?: string;
680
- media?: string;
681
- referrerpolicy?:
682
- | 'no-referrer'
683
- | 'no-referrer-when-downgrade'
684
- | 'origin'
685
- | 'origin-when-cross-origin'
686
- | 'same-origin'
687
- | 'strict-origin'
688
- | 'strict-origin-when-cross-origin'
689
- | 'unsafe-url';
690
- rel?: string;
691
- sizes?: string;
692
- type?: string;
693
- }>;
694
-
695
- // Map element
696
- map: BaseAttr &
697
- KTReactifyProps<{
698
- name?: string;
699
- }>;
700
-
701
- // Menu element
702
- menu: BaseAttr & KTReactifyProps<{}>;
703
-
704
- // Meta element
705
- meta: BaseAttr &
706
- KTReactifyProps<{
707
- charset?: string;
708
- content?: string;
709
- 'http-equiv'?: 'content-security-policy' | 'content-type' | 'default-style' | 'refresh' | string;
710
- name?: string;
711
- }>;
712
-
713
- // Meter element
714
- meter: BaseAttr &
715
- KTReactifyProps<{
716
- form?: string;
717
- high?: number | string;
718
- low?: number | string;
719
- max?: number | string;
720
- min?: number | string;
721
- optimum?: number | string;
722
- value?: number | string;
723
- }>;
724
-
725
- // Object element
726
- object: BaseAttr &
727
- KTReactifyProps<{
728
- data?: string;
729
- form?: string;
730
- height?: number | string;
731
- name?: string;
732
- type?: string;
733
- usemap?: string;
734
- width?: number | string;
735
- }>;
736
-
737
- // OL element
738
- ol: BaseAttr &
739
- KTReactifyProps<{
740
- reversed?: boolean;
741
- start?: number | string;
742
- type?: '1' | 'a' | 'A' | 'i' | 'I';
743
- }>;
744
-
745
- // Optgroup element
746
- optgroup: BaseAttr &
747
- KTReactifyProps<{
748
- disabled?: boolean;
749
- label?: string;
750
- }>;
751
-
752
- // Option element
753
- option: BaseAttr &
754
- KTReactifyProps<{
755
- disabled?: boolean;
756
- label?: string;
757
- selected?: boolean;
758
- value?: string;
759
- }>;
760
-
761
- // Output element
762
- output: BaseAttr &
763
- KTReactifyProps<{
764
- for?: string;
765
- form?: string;
766
- name?: string;
767
- }>;
768
-
769
- // Picture element
770
- picture: BaseAttr & KTReactifyProps<{}>;
771
-
772
- // Pre element
773
- pre: BaseAttr & KTReactifyProps<{}>;
774
-
775
- // Progress element
776
- progress: BaseAttr &
777
- KTReactifyProps<{
778
- max?: number | string;
779
- value?: number | string;
780
- }>;
781
-
782
- // Quote element (q and blockquote)
783
- q: BaseAttr &
784
- KTReactifyProps<{
785
- cite?: string;
786
- }>;
787
-
788
- blockquote: BaseAttr &
789
- KTReactifyProps<{
790
- cite?: string;
791
- }>;
792
-
793
- // Script element
794
- script: BaseAttr &
795
- KTReactifyProps<{
796
- async?: boolean;
797
- crossorigin?: 'anonymous' | 'use-credentials' | '';
798
- defer?: boolean;
799
- integrity?: string;
800
- nomodule?: boolean;
801
- referrerpolicy?:
802
- | 'no-referrer'
803
- | 'no-referrer-when-downgrade'
804
- | 'origin'
805
- | 'origin-when-cross-origin'
806
- | 'same-origin'
807
- | 'strict-origin'
808
- | 'strict-origin-when-cross-origin'
809
- | 'unsafe-url';
810
- src?: string;
811
- type?: string;
812
- }>;
813
-
814
- // Select element
815
- select: BaseAttr &
816
- KTReactifyProps<{
817
- autocomplete?: string;
818
- disabled?: boolean;
819
- form?: string;
820
- multiple?: boolean;
821
- name?: string;
822
- required?: boolean;
823
- size?: number | string;
824
- }>;
825
-
826
- // Slot element
827
- slot: BaseAttr &
828
- KTReactifyProps<{
829
- name?: string;
830
- }>;
831
-
832
- // Source element
833
- source: BaseAttr &
834
- KTReactifyProps<{
835
- height?: number | string;
836
- media?: string;
837
- sizes?: string;
838
- src?: string;
839
- srcset?: string;
840
- type?: string;
841
- width?: number | string;
842
- }>;
843
-
844
- // Style element
845
- style: BaseAttr &
846
- KTReactifyProps<{
847
- media?: string;
848
- }>;
849
-
850
- // Table element
851
- table: BaseAttr & KTReactifyProps<{}>;
852
-
853
- // Table body/footer/header elements
854
- tbody: BaseAttr & KTReactifyProps<{}>;
855
-
856
- tfoot: BaseAttr & KTReactifyProps<{}>;
857
-
858
- thead: BaseAttr & KTReactifyProps<{}>;
859
-
860
- // Table cell elements
861
- td: BaseAttr &
862
- KTReactifyProps<{
863
- colspan?: number | string;
864
- headers?: string;
865
- rowspan?: number | string;
866
- }>;
867
-
868
- th: BaseAttr &
869
- KTReactifyProps<{
870
- abbr?: string;
871
- colspan?: number | string;
872
- headers?: string;
873
- rowspan?: number | string;
874
- scope?: 'row' | 'col' | 'rowgroup' | 'colgroup';
875
- }>;
876
-
877
- // Template element
878
- template: BaseAttr & KTReactifyProps<{}>;
879
-
880
- // Textarea element
881
- textarea: BaseAttr &
882
- KTReactifyProps<{
883
- autocomplete?: string;
884
- cols?: number | string;
885
- dirname?: string;
886
- disabled?: boolean;
887
- form?: string;
888
- maxlength?: number | string;
889
- minlength?: number | string;
890
- name?: string;
891
- placeholder?: string;
892
- readonly?: boolean;
893
- required?: boolean;
894
- rows?: number | string;
895
- wrap?: 'hard' | 'soft' | 'off';
896
- }>;
897
-
898
- // Time element
899
- time: BaseAttr &
900
- KTReactifyProps<{
901
- datetime?: string;
902
- }>;
903
-
904
- // Title element
905
- title: BaseAttr & KTReactifyProps<{}>;
906
-
907
- // TR element
908
- tr: BaseAttr & KTReactifyProps<{}>;
909
-
910
- // Track element
911
- track: BaseAttr &
912
- KTReactifyProps<{
913
- default?: boolean;
914
- kind?: 'subtitles' | 'captions' | 'descriptions' | 'chapters' | 'metadata';
915
- label?: string;
916
- src?: string;
917
- srclang?: string;
918
- }>;
919
-
920
- // UL element
921
- ul: BaseAttr & KTReactifyProps<{}>;
922
-
923
- // Video element
924
- video: BaseAttr &
925
- KTReactifyProps<{
926
- autoplay?: boolean;
927
- controls?: boolean;
928
- crossorigin?: 'anonymous' | 'use-credentials' | '';
929
- height?: number | string;
930
- loop?: boolean;
931
- muted?: boolean;
932
- playsinline?: boolean;
933
- poster?: string;
934
- preload?: 'none' | 'metadata' | 'auto' | '';
935
- src?: string;
936
- width?: number | string;
937
- }>;
938
-
939
- // Generic HTMLElement (no specific attributes beyond BaseEvent)
940
- abbr: BaseAttr & KTReactifyProps<{}>;
941
- address: BaseAttr & KTReactifyProps<{}>;
942
- article: BaseAttr & KTReactifyProps<{}>;
943
- aside: BaseAttr & KTReactifyProps<{}>;
944
- b: BaseAttr & KTReactifyProps<{}>;
945
- bdi: BaseAttr & KTReactifyProps<{}>;
946
- bdo: BaseAttr & KTReactifyProps<{}>;
947
- cite: BaseAttr & KTReactifyProps<{}>;
948
- code: BaseAttr & KTReactifyProps<{}>;
949
- dd: BaseAttr & KTReactifyProps<{}>;
950
- dfn: BaseAttr & KTReactifyProps<{}>;
951
- div: BaseAttr & KTReactifyProps<{}>;
952
- dl: BaseAttr & KTReactifyProps<{}>;
953
- dt: BaseAttr & KTReactifyProps<{}>;
954
- em: BaseAttr & KTReactifyProps<{}>;
955
- figcaption: BaseAttr & KTReactifyProps<{}>;
956
- figure: BaseAttr & KTReactifyProps<{}>;
957
- footer: BaseAttr & KTReactifyProps<{}>;
958
- h1: BaseAttr & KTReactifyProps<{}>;
959
- h2: BaseAttr & KTReactifyProps<{}>;
960
- h3: BaseAttr & KTReactifyProps<{}>;
961
- h4: BaseAttr & KTReactifyProps<{}>;
962
- h5: BaseAttr & KTReactifyProps<{}>;
963
- h6: BaseAttr & KTReactifyProps<{}>;
964
- header: BaseAttr & KTReactifyProps<{}>;
965
- hgroup: BaseAttr & KTReactifyProps<{}>;
966
- i: BaseAttr & KTReactifyProps<{}>;
967
- kbd: BaseAttr & KTReactifyProps<{}>;
968
- main: BaseAttr & KTReactifyProps<{}>;
969
- mark: BaseAttr & KTReactifyProps<{}>;
970
- nav: BaseAttr & KTReactifyProps<{}>;
971
- noscript: BaseAttr & KTReactifyProps<{}>;
972
- p: BaseAttr & KTReactifyProps<{}>;
973
- rp: BaseAttr & KTReactifyProps<{}>;
974
- rt: BaseAttr & KTReactifyProps<{}>;
975
- ruby: BaseAttr & KTReactifyProps<{}>;
976
- s: BaseAttr & KTReactifyProps<{}>;
977
- samp: BaseAttr & KTReactifyProps<{}>;
978
- search: BaseAttr & KTReactifyProps<{}>;
979
- section: BaseAttr & KTReactifyProps<{}>;
980
- small: BaseAttr & KTReactifyProps<{}>;
981
- span: BaseAttr & KTReactifyProps<{}>;
982
- strong: BaseAttr & KTReactifyProps<{}>;
983
- sub: BaseAttr & KTReactifyProps<{}>;
984
- summary: BaseAttr & KTReactifyProps<{}>;
985
- sup: BaseAttr & KTReactifyProps<{}>;
986
- u: BaseAttr & KTReactifyProps<{}>;
987
- var: BaseAttr & KTReactifyProps<{}>;
988
- wbr: BaseAttr & KTReactifyProps<{}>;
989
-
990
- svg: BaseAttr & {
991
- class?: string;
992
- style?: string | Partial<CSSStyleDeclaration>;
993
- width?: number | string;
994
- height?: number | string;
995
- viewBox?: string;
996
- xmlns?: string;
997
- fill?: string;
998
- stroke?: string;
999
- strokeWidth?: number | string;
1000
- strokeLinecap?: 'butt' | 'round' | 'square' | 'inherit';
1001
- strokeLinejoin?: 'miter' | 'round' | 'bevel' | 'inherit';
1002
- strokeDasharray?: string;
1003
- strokeDashoffset?: number | string;
1004
- opacity?: number | string;
1005
- preserveAspectRatio?: string;
1006
- transform?: string;
1007
- x?: number | string;
1008
- y?: number | string;
1009
- rx?: number | string;
1010
- ry?: number | string;
1011
- r?: number | string;
1012
- cx?: number | string;
1013
- cy?: number | string;
1014
- d?: string;
1015
- points?: string;
1016
- pathLength?: number | string;
1017
- viewbox?: string;
1018
- role?: string;
1019
- focusable?: boolean | 'true' | 'false';
1020
- xlinkHref?: string; // legacy xlink:href
1021
- };
1022
- }
1023
-
1024
- interface SVGAttributesMap {
1025
- a: AttributesMap['svg'] & { href?: string; x?: number | string; y?: number | string };
1026
- animate: AttributesMap['svg'] & {
1027
- attributeName?: string;
1028
- from?: string | number;
1029
- to?: string | number;
1030
- dur?: string;
1031
- repeatCount?: string | number;
1032
- };
1033
- animateMotion: AttributesMap['svg'] & { path?: string; dur?: string; rotate?: string };
1034
- animateTransform: AttributesMap['svg'] & { type?: string; from?: string; to?: string; dur?: string };
1035
- circle: AttributesMap['svg'] & { cx?: number | string; cy?: number | string; r?: number | string };
1036
- clipPath: AttributesMap['svg'] & { clipPathUnits?: 'userSpaceOnUse' | 'objectBoundingBox' };
1037
- defs: AttributesMap['svg'];
1038
- desc: AttributesMap['svg'];
1039
- ellipse: AttributesMap['svg'] & {
1040
- cx?: number | string;
1041
- cy?: number | string;
1042
- rx?: number | string;
1043
- ry?: number | string;
1044
- };
1045
-
1046
- // Filter primitives (provide common props)
1047
- feBlend: AttributesMap['svg'] & { in?: string; in2?: string; mode?: string };
1048
- feColorMatrix: AttributesMap['svg'] & {
1049
- type?: 'matrix' | 'saturate' | 'hueRotate' | 'luminanceToAlpha';
1050
- values?: string;
1051
- };
1052
- feComponentTransfer: AttributesMap['svg'] & {};
1053
- feComposite: AttributesMap['svg'] & {
1054
- in?: string;
1055
- in2?: string;
1056
- operator?: string;
1057
- k1?: number | string;
1058
- k2?: number | string;
1059
- k3?: number | string;
1060
- k4?: number | string;
1061
- };
1062
- feConvolveMatrix: AttributesMap['svg'] & {
1063
- order?: string | number;
1064
- kernelMatrix?: string;
1065
- divisor?: string | number;
1066
- bias?: string | number;
1067
- };
1068
- feDiffuseLighting: AttributesMap['svg'] & {};
1069
- feDisplacementMap: AttributesMap['svg'] & {
1070
- in?: string;
1071
- in2?: string;
1072
- scale?: number | string;
1073
- xChannelSelector?: string;
1074
- yChannelSelector?: string;
1075
- };
1076
- feDistantLight: AttributesMap['svg'] & { azimuth?: number | string; elevation?: number | string };
1077
- feDropShadow: AttributesMap['svg'] & {
1078
- dx?: number | string;
1079
- dy?: number | string;
1080
- stdDeviation?: number | string;
1081
- floodColor?: string;
1082
- floodOpacity?: number | string;
1083
- };
1084
- feFlood: AttributesMap['svg'] & { floodColor?: string; floodOpacity?: number | string };
1085
- feFuncA: AttributesMap['svg'] & {};
1086
- feFuncB: AttributesMap['svg'] & {};
1087
- feFuncG: AttributesMap['svg'] & {};
1088
- feFuncR: AttributesMap['svg'] & {};
1089
- feGaussianBlur: AttributesMap['svg'] & { stdDeviation?: number | string; edgeMode?: string };
1090
- feImage: AttributesMap['svg'] & { href?: string };
1091
- feMerge: AttributesMap['svg'] & {};
1092
- feMergeNode: AttributesMap['svg'] & { in?: string };
1093
- feMorphology: AttributesMap['svg'] & { operator?: 'erode' | 'dilate'; radius?: number | string };
1094
- feOffset: AttributesMap['svg'] & { dx?: number | string; dy?: number | string };
1095
- fePointLight: AttributesMap['svg'] & { x?: number | string; y?: number | string; z?: number | string };
1096
- feSpecularLighting: AttributesMap['svg'] & {
1097
- specularConstant?: number | string;
1098
- specularExponent?: number | string;
1099
- surfaceScale?: number | string;
1100
- };
1101
- feSpotLight: AttributesMap['svg'] & {
1102
- x?: number | string;
1103
- y?: number | string;
1104
- z?: number | string;
1105
- pointsAtX?: number | string;
1106
- pointsAtY?: number | string;
1107
- pointsAtZ?: number | string;
1108
- specularExponent?: number | string;
1109
- limitingConeAngle?: number | string;
1110
- };
1111
- feTile: AttributesMap['svg'] & {};
1112
- feTurbulence: AttributesMap['svg'] & {
1113
- baseFrequency?: number | string;
1114
- numOctaves?: number | string;
1115
- seed?: number | string;
1116
- stitchTiles?: string;
1117
- type?: 'fractalNoise' | 'turbulence';
1118
- };
1119
-
1120
- filter: AttributesMap['svg'] & {
1121
- x?: number | string;
1122
- y?: number | string;
1123
- width?: number | string;
1124
- height?: number | string;
1125
- filterUnits?: string;
1126
- primitiveUnits?: string;
1127
- };
1128
- foreignObject: AttributesMap['svg'] & {
1129
- x?: number | string;
1130
- y?: number | string;
1131
- width?: number | string;
1132
- height?: number | string;
1133
- };
1134
- g: AttributesMap['svg'];
1135
- image: AttributesMap['svg'] & {
1136
- href?: string;
1137
- x?: number | string;
1138
- y?: number | string;
1139
- width?: number | string;
1140
- height?: number | string;
1141
- };
1142
- line: AttributesMap['svg'] & {
1143
- x1?: number | string;
1144
- y1?: number | string;
1145
- x2?: number | string;
1146
- y2?: number | string;
1147
- };
1148
- linearGradient: AttributesMap['svg'] & {
1149
- x1?: number | string;
1150
- y1?: number | string;
1151
- x2?: number | string;
1152
- y2?: number | string;
1153
- gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox';
1154
- gradientTransform?: string;
1155
- };
1156
- marker: AttributesMap['svg'] & {
1157
- markerUnits?: string;
1158
- markerWidth?: number | string;
1159
- markerHeight?: number | string;
1160
- refX?: number | string;
1161
- refY?: number | string;
1162
- orient?: string;
1163
- };
1164
- mask: AttributesMap['svg'] & {
1165
- maskUnits?: string;
1166
- maskContentUnits?: string;
1167
- x?: number | string;
1168
- y?: number | string;
1169
- width?: number | string;
1170
- height?: number | string;
1171
- };
1172
- metadata: AttributesMap['svg'];
1173
- mpath: AttributesMap['svg'] & { href?: string };
1174
- path: AttributesMap['svg'] & { d?: string; pathLength?: number | string };
1175
- pattern: AttributesMap['svg'] & {
1176
- patternUnits?: string;
1177
- patternContentUnits?: string;
1178
- width?: number | string;
1179
- height?: number | string;
1180
- x?: number | string;
1181
- y?: number | string;
1182
- };
1183
- polygon: AttributesMap['svg'] & { points?: string };
1184
- polyline: AttributesMap['svg'] & { points?: string };
1185
- radialGradient: AttributesMap['svg'] & {
1186
- cx?: number | string;
1187
- cy?: number | string;
1188
- r?: number | string;
1189
- fx?: number | string;
1190
- fy?: number | string;
1191
- gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox';
1192
- gradientTransform?: string;
1193
- };
1194
- rect: AttributesMap['svg'] & {
1195
- x?: number | string;
1196
- y?: number | string;
1197
- width?: number | string;
1198
- height?: number | string;
1199
- rx?: number | string;
1200
- ry?: number | string;
1201
- };
1202
- script: AttributesMap['svg'] & { href?: string; type?: string };
1203
- set: AttributesMap['svg'] & { attributeName?: string; to?: string | number; begin?: string; dur?: string };
1204
- stop: AttributesMap['svg'] & { offset?: number | string; stopColor?: string; stopOpacity?: number | string };
1205
- style: AttributesMap['svg'] & { media?: string };
1206
- svg: AttributesMap['svg'];
1207
- switch: AttributesMap['svg'];
1208
- symbol: AttributesMap['svg'] & { viewBox?: string; preserveAspectRatio?: string };
1209
- text: AttributesMap['svg'] & {
1210
- x?: number | string;
1211
- y?: number | string;
1212
- dx?: number | string;
1213
- dy?: number | string;
1214
- textLength?: number | string;
1215
- };
1216
- textPath: AttributesMap['svg'] & { href?: string; startOffset?: number | string };
1217
- title: AttributesMap['svg'];
1218
- tspan: AttributesMap['svg'] & {
1219
- x?: number | string;
1220
- y?: number | string;
1221
- dx?: number | string;
1222
- dy?: number | string;
1223
- };
1224
- use: AttributesMap['svg'] & {
1225
- href?: string;
1226
- x?: number | string;
1227
- y?: number | string;
1228
- width?: number | string;
1229
- height?: number | string;
1230
- };
1231
- view: AttributesMap['svg'] & { viewBox?: string; preserveAspectRatio?: string };
1232
- }
1233
-
1234
- declare global {
1235
- namespace JSX {
1236
- type Element = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
1237
-
1238
- interface IntrinsicElements {
1239
- [k: string]: AttributesMap['div']; // Allow any element with div attributes as fallback
1240
-
1241
- // Document-level & metadata
1242
- html: AttributesMap['html'];
1243
- head: AttributesMap['head'];
1244
- title: AttributesMap['title'];
1245
- base: AttributesMap['base'];
1246
- link: AttributesMap['link'];
1247
- meta: AttributesMap['meta'];
1248
-
1249
- // Sectioning
1250
- body: AttributesMap['body'];
1251
- header: AttributesMap['header'];
1252
- footer: AttributesMap['footer'];
1253
- nav: AttributesMap['nav'];
1254
- main: AttributesMap['main'];
1255
- section: AttributesMap['section'];
1256
- article: AttributesMap['article'];
1257
- aside: AttributesMap['aside'];
1258
-
1259
- // Headings
1260
- h1: AttributesMap['h1'];
1261
- h2: AttributesMap['h2'];
1262
- h3: AttributesMap['h3'];
1263
- h4: AttributesMap['h4'];
1264
- h5: AttributesMap['h5'];
1265
- h6: AttributesMap['h6'];
1266
-
1267
- // Text content
1268
- p: AttributesMap['p'];
1269
- pre: AttributesMap['pre'];
1270
- code: AttributesMap['code'];
1271
- strong: AttributesMap['strong'];
1272
- small: AttributesMap['small'];
1273
- em: AttributesMap['em'];
1274
- br: AttributesMap['br'];
1275
- i: AttributesMap['i'];
1276
-
1277
- // Lists
1278
- ul: AttributesMap['ul'];
1279
- ol: AttributesMap['ol'];
1280
- li: AttributesMap['li'];
1281
-
1282
- // Tables
1283
- table: AttributesMap['table'];
1284
- thead: AttributesMap['thead'];
1285
- tbody: AttributesMap['tbody'];
1286
- tfoot: AttributesMap['tfoot'];
1287
- tr: AttributesMap['tr'];
1288
- th: AttributesMap['th'];
1289
- td: AttributesMap['td'];
1290
-
1291
- // Forms
1292
- form: AttributesMap['form'];
1293
- label: AttributesMap['label'];
1294
- input: AttributesMap['input'];
1295
- textarea: AttributesMap['textarea'];
1296
- select: AttributesMap['select'];
1297
- option: AttributesMap['option'];
1298
- optgroup: AttributesMap['optgroup'];
1299
- button: AttributesMap['button'];
1300
- fieldset: AttributesMap['fieldset'];
1301
- legend: AttributesMap['legend'];
1302
- datalist: AttributesMap['datalist'];
1303
- output: AttributesMap['output'];
1304
-
1305
- // Media & embedded
1306
- img: AttributesMap['img'];
1307
- picture: AttributesMap['picture'];
1308
- source: AttributesMap['source'];
1309
- audio: AttributesMap['audio'];
1310
- video: AttributesMap['video'];
1311
- track: AttributesMap['track'];
1312
- iframe: AttributesMap['iframe'];
1313
- embed: AttributesMap['embed'];
1314
- object: AttributesMap['object'];
1315
- canvas: AttributesMap['canvas'];
1316
-
1317
- // Interactive & misc
1318
- a: AttributesMap['a'] & SVGAttributesMap['a'];
1319
- area: AttributesMap['area'];
1320
- map: AttributesMap['map'];
1321
- details: AttributesMap['details'];
1322
- dialog: AttributesMap['dialog'];
1323
- summary: AttributesMap['summary'];
1324
- slot: AttributesMap['slot'];
1325
-
1326
- // Scripting & styles
1327
- script: AttributesMap['script'];
1328
- style: AttributesMap['style'];
1329
-
1330
- // Semantic & phrasing
1331
- figure: AttributesMap['figure'];
1332
- figcaption: AttributesMap['figcaption'];
1333
- blockquote: AttributesMap['blockquote'];
1334
- q: AttributesMap['q'];
1335
-
1336
- // Generic elements
1337
- div: AttributesMap['div'];
1338
- span: AttributesMap['span'];
1339
- address: AttributesMap['address'];
1340
- abbr: AttributesMap['abbr'];
1341
- b: AttributesMap['b'];
1342
- cite: AttributesMap['cite'];
1343
- dl: AttributesMap['dl'];
1344
- dt: AttributesMap['dt'];
1345
- dd: AttributesMap['dd'];
1346
- hr: AttributesMap['hr'];
1347
-
1348
- // SVG
1349
- svg: AttributesMap['svg'];
1350
- // a: SVGAttributesMap['a'];
1351
- animate: SVGAttributesMap['animate'];
1352
- animateMotion: SVGAttributesMap['animateMotion'];
1353
- animateTransform: SVGAttributesMap['animateTransform'];
1354
- circle: SVGAttributesMap['circle'];
1355
- clipPath: SVGAttributesMap['clipPath'];
1356
- defs: SVGAttributesMap['defs'];
1357
- desc: SVGAttributesMap['desc'];
1358
- ellipse: SVGAttributesMap['ellipse'];
1359
- feBlend: SVGAttributesMap['feBlend'];
1360
- feColorMatrix: SVGAttributesMap['feColorMatrix'];
1361
- feComponentTransfer: SVGAttributesMap['feComponentTransfer'];
1362
- feComposite: SVGAttributesMap['feComposite'];
1363
- feConvolveMatrix: SVGAttributesMap['feConvolveMatrix'];
1364
- feDiffuseLighting: SVGAttributesMap['feDiffuseLighting'];
1365
- feDisplacementMap: SVGAttributesMap['feDisplacementMap'];
1366
- feDistantLight: SVGAttributesMap['feDistantLight'];
1367
- feDropShadow: SVGAttributesMap['feDropShadow'];
1368
- feFlood: SVGAttributesMap['feFlood'];
1369
- feFuncA: SVGAttributesMap['feFuncA'];
1370
- feFuncB: SVGAttributesMap['feFuncB'];
1371
- feFuncG: SVGAttributesMap['feFuncG'];
1372
- feFuncR: SVGAttributesMap['feFuncR'];
1373
- feGaussianBlur: SVGAttributesMap['feGaussianBlur'];
1374
- feImage: SVGAttributesMap['feImage'];
1375
- feMerge: SVGAttributesMap['feMerge'];
1376
- feMergeNode: SVGAttributesMap['feMergeNode'];
1377
- feMorphology: SVGAttributesMap['feMorphology'];
1378
- feOffset: SVGAttributesMap['feOffset'];
1379
- fePointLight: SVGAttributesMap['fePointLight'];
1380
- feSpecularLighting: SVGAttributesMap['feSpecularLighting'];
1381
- feSpotLight: SVGAttributesMap['feSpotLight'];
1382
- feTile: SVGAttributesMap['feTile'];
1383
- feTurbulence: SVGAttributesMap['feTurbulence'];
1384
- filter: SVGAttributesMap['filter'];
1385
- foreignObject: SVGAttributesMap['foreignObject'];
1386
- g: SVGAttributesMap['g'];
1387
- image: SVGAttributesMap['image'];
1388
- line: SVGAttributesMap['line'];
1389
- linearGradient: SVGAttributesMap['linearGradient'];
1390
- marker: SVGAttributesMap['marker'];
1391
- mask: SVGAttributesMap['mask'];
1392
- metadata: SVGAttributesMap['metadata'];
1393
- mpath: SVGAttributesMap['mpath'];
1394
- path: SVGAttributesMap['path'];
1395
- pattern: SVGAttributesMap['pattern'];
1396
- polygon: SVGAttributesMap['polygon'];
1397
- polyline: SVGAttributesMap['polyline'];
1398
- radialGradient: SVGAttributesMap['radialGradient'];
1399
- rect: SVGAttributesMap['rect'];
1400
- set: SVGAttributesMap['set'];
1401
- stop: SVGAttributesMap['stop'];
1402
- switch: SVGAttributesMap['switch'];
1403
- symbol: SVGAttributesMap['symbol'];
1404
- text: SVGAttributesMap['text'];
1405
- textPath: SVGAttributesMap['textPath'];
1406
- tspan: SVGAttributesMap['tspan'];
1407
- use: SVGAttributesMap['use'];
1408
- view: SVGAttributesMap['view'];
1409
- }
1410
-
1411
- type IntrinsicAttributes = {
1412
- /**
1413
- * Make a reference to the created element
1414
- */
1415
- ref?: KTRef<any>;
1416
-
1417
- /**
1418
- * Conditional rendering
1419
- * - Provide a `KTRef` to make it reactive
1420
- */
1421
- 'k-if'?: any;
1422
-
1423
- /**
1424
- * 2-way binding
1425
- * - Provide a `KTRef` to make it reactive
1426
- */
1427
- 'k-model'?: KTRef<any>;
1428
-
1429
- /**
1430
- * Raw html binding
1431
- * - Provide a `KTRef` to make it reactive
1432
- */
1433
- 'k-html'?: any;
1434
- children?: KTRawContent;
1435
- };
1436
-
1437
- interface ElementChildrenAttribute {
1438
- children: {};
1439
- }
1440
- }
1441
- }
1442
-
1443
- /**
1444
- * Extract component props type (excluding ref and children)
1445
- */
1446
- type ExtractComponentProps<T> = T extends (props: infer P) => any ? Omit<P, 'ref' | 'children'> : {};
1447
- declare function KTAsync<T extends KTComponent>(props: {
1448
- ref?: KTRef<JSX.Element>;
1449
- skeleton?: JSX.Element;
1450
- component: T;
1451
- children?: KTRawContent;
1452
- } & ExtractComponentProps<T>): JSX.Element;
1453
-
1454
- type KTForElement = JSX.Element;
1455
- interface KTForProps<T> {
1456
- ref?: KTRef<KTForElement>;
1457
- list: T[] | KTReactive<T[]>;
1458
- key?: (item: T, index: number, array: T[]) => any;
1459
- map: (item: T, index: number, array: T[]) => HTMLElement;
1460
- }
1461
- /**
1462
- * KTFor - List rendering component with key-based optimization
1463
- * Returns a Comment anchor node with rendered elements in __kt_for_list__
1464
- */
1465
- declare function KTFor<T>(props: KTForProps<T>): KTForElement;
1466
-
1467
- export { $modelOrRef, $setRef, Fragment, KTAsync, KTComputed, KTFor, KTReactive, KTReactiveType, KTRef, computed, h as createElement, createRedrawable, dereactive, effect, h, isComputed, isKT, isRef, jsx, jsxDEV, jsxs, ref, surfaceRef, toReactive, toRef };
1468
- export type { EventHandler, KTAttribute, KTForElement, KTForProps, KTPrefixedEventAttribute, KTRawAttr, KTRawContent, KTRawContents, KTReactify, KTReactifyObject, KTReactifyProps, KTSurfaceRef, ReactiveChangeHandler };
1
+ /**
2
+ * Whether `props.ref` is a `KTRef` only needs to be checked in the initial render
3
+ */
4
+ export declare const $initRef: <T extends Node>(props: {
5
+ ref?: KTRef<T>;
6
+ }, node: T) => RefSetter<T>;
7
+
8
+ /**
9
+ * Assert k-model to be a ref object
10
+ */
11
+ export declare const $modelOrRef: <T = any>(props: any, defaultValue?: T) => KTRef<T>;
12
+
13
+ /**
14
+ * Create a reactive computed value
15
+ * @param computeFn
16
+ * @param reactives refs and computeds that this computed depends on
17
+ */
18
+ export declare function computed<T = JSX.Element>(computeFn: () => T, reactives: Array<KTReactive<any>>): KTComputed<T>;
19
+
20
+ /**
21
+ * A helper to create redrawable elements
22
+ * ```tsx
23
+ * export function MyComponent() {
24
+ * let aa = 10;
25
+ * // ...
26
+ * // aa might be changed
27
+ * return createRedrawable(() => <div>{aa}</div>);
28
+ * }
29
+ * ```
30
+ * Then the returned element has a `redraw` method to redraw itself with new values.
31
+ * @param creator a simple creator function that returns an element
32
+ * @returns created element's ref
33
+ */
34
+ export declare function createRedrawable<T>(creator: () => T): KTRef<T> & {
35
+ redraw: () => T;
36
+ };
37
+
38
+ /**
39
+ * Extracts the value from a KTReactive, or returns the value directly if it's not reactive.
40
+ */
41
+ export declare function dereactive<T = JSX.Element>(value: T | KTReactive<T>): T;
42
+
43
+ /**
44
+ * Register a reactive effect with options.
45
+ * @param effectFn The effect function to run when dependencies change
46
+ * @param reactives The reactive dependencies
47
+ * @param options Effect options: lazy, onCleanup, debugName
48
+ * @returns stop function to remove all listeners
49
+ */
50
+ export declare function effect(effectFn: () => void, reactives: Array<KTReactive<any>>, options?: Partial<KTEffectOptions>): () => void;
51
+
52
+ /**
53
+ * Event handler type for DOM events
54
+ */
55
+ export declare type EventHandler<T extends Event = Event> = (this: HTMLElement, ev: T) => any;
56
+
57
+ /**
58
+ * Extract component props type (excluding ref and children)
59
+ */
60
+ declare type ExtractComponentProps<T> = T extends (props: infer P) => any ? Omit<P, 'ref' | 'children'> : {};
61
+
62
+ /**
63
+ * Fragment support - returns an array of children
64
+ * Enhanced Fragment component that manages arrays of elements
65
+ */
66
+ export declare function Fragment(props: {
67
+ children?: KTRawContent;
68
+ }): JSX.Element;
69
+
70
+ /**
71
+ * Create an enhanced HTMLElement.
72
+ * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
73
+ * @param tag tag of an `HTMLElement`
74
+ * @param attr attribute object or className
75
+ * @param content a string or an array of HTMLEnhancedElement as child nodes
76
+ *
77
+ * __PKG_INFO__
78
+ */
79
+ declare const h: <T extends HTMLTag | SVGTag | MathMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>;
80
+ export { h as createElement }
81
+ export { h }
82
+
83
+ declare type HTML<T extends (HTMLTag | SVGTag | MathMLTag) & otherstring> = T extends SVGTag
84
+ ? SVGElementTagNameMap[T]
85
+ : T extends HTMLTag
86
+ ? HTMLElementTagNameMap[T]
87
+ : T extends MathMLTag
88
+ ? MathMLElementTagNameMap[T]
89
+ : HTMLElement;
90
+
91
+ declare type HTMLJSXTag = HTMLTag | ((props?: any) => HTMLElement) | ((props?: any) => Promise<HTMLElement>);
92
+
93
+ /**
94
+ * Normal HTML tags like `div`, `span`, `a`, etc.
95
+ */
96
+ export declare type HTMLTag = keyof HTMLElementTagNameMap;
97
+
98
+ export declare type InputElementTag = 'input' | 'select' | 'textarea';
99
+
100
+ export declare const isComputed: <T = any>(obj: any) => obj is KTComputed<T>;
101
+
102
+ export declare const isKT: <T = any>(obj: any) => obj is KTReactive<T>;
103
+
104
+ export declare const isRef: <T = any>(obj: any) => obj is KTRef<T>;
105
+
106
+ /**
107
+ * @param tag html tag or function component
108
+ * @param props properties/attributes
109
+ */
110
+ export declare function jsx(tag: JSXTag, props: KTAttribute): JSX.Element;
111
+
112
+ /**
113
+ * JSX Development runtime - same as jsx but with additional dev checks
114
+ */
115
+ export declare const jsxDEV: typeof jsx;
116
+
117
+ /**
118
+ * JSX runtime for React 17+ automatic runtime
119
+ * This is called when using jsx: "react-jsx" or "react-jsxdev"
120
+ */
121
+ export declare const jsxs: typeof jsx;
122
+
123
+ declare type JSXTag = HTMLJSXTag | SVGJSXTag | MathMLJSXTag;
124
+
125
+ export declare function KTAsync<T extends KTComponent>(props: {
126
+ ref?: KTRef<JSX.Element>;
127
+ skeleton?: JSX.Element;
128
+ component: T;
129
+ children?: KTRawContent;
130
+ } & ExtractComponentProps<T>): JSX.Element;
131
+
132
+ export declare type KTAttribute = KTBaseAttribute & KTPrefixedEventAttribute;
133
+
134
+ declare type KTAvailableContent = SingleContent | KTAvailableContent[];
135
+
136
+ /**
137
+ * Used to create enhanced HTML elements
138
+ */
139
+ declare interface KTBaseAttribute {
140
+ [k: string]: any;
141
+
142
+ // # kt-specific attributes
143
+ ref?: KTRef<JSX.Element>;
144
+
145
+ /**
146
+ * If a `KTRef` is bound, it will be reactive; otherwise, it will be static.
147
+ */
148
+ 'k-if'?: any;
149
+
150
+ /**
151
+ * Register two-way data binding between an input element and a KTRef.
152
+ * - Default to regist `input` event and `value` property(`checked` for checkboxes and radios).
153
+ */
154
+ 'k-model'?: KTRef<any>;
155
+
156
+ /**
157
+ * Directly apply html string to `innerHTML`.
158
+ * - Would be reactive if `KTRef` instance is provided
159
+ */
160
+ 'k-html'?: any;
161
+
162
+ // # normal HTML attributes
163
+ id?: string;
164
+ class?: string;
165
+ className?: string;
166
+ style?: string | Partial<CSSStyleDeclaration>;
167
+
168
+ type?:
169
+ | 'text'
170
+ | 'password'
171
+ | 'email'
172
+ | 'number'
173
+ | 'tel'
174
+ | 'url'
175
+ | 'search'
176
+ | 'date'
177
+ | 'datetime-local'
178
+ | 'time'
179
+ | 'month'
180
+ | 'week'
181
+ | 'color'
182
+ | 'range'
183
+ | 'file'
184
+ | 'checkbox'
185
+ | 'radio'
186
+ | 'hidden'
187
+ | 'submit'
188
+ | 'reset'
189
+ | 'button'
190
+ | 'image'
191
+ | otherstring;
192
+ for?: string;
193
+
194
+ name?: string;
195
+ title?: string;
196
+ placeholder?: string;
197
+ contenteditable?: boolean;
198
+ value?: any;
199
+ valueAsDate?: Date;
200
+ valueAsNumber?: number;
201
+ label?: string;
202
+ disabled?: boolean;
203
+
204
+ min?: string | number;
205
+ max?: string | number;
206
+ step?: string | number;
207
+
208
+ selected?: boolean;
209
+ checked?: boolean;
210
+
211
+ action?: string;
212
+ method?: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'CONNECT' | 'TRACE' | otherstring;
213
+ }
214
+
215
+ declare type KTComponent = (
216
+ props: {
217
+ ref?: KTRef<JSX.Element>;
218
+ children?: KTRawContent;
219
+ } & KTAttribute &
220
+ any,
221
+ ) => JSX.Element | Promise<JSX.Element> | any;
222
+
223
+ export declare class KTComputed<T> implements KTReactive<T> {
224
+ /**
225
+ * Indicates that this is a KTRef instance
226
+ */
227
+ isKT: true;
228
+ ktType: KTReactiveType;
229
+ /* Excluded from this release type: _calculator */
230
+ /* Excluded from this release type: _value */
231
+ /* Excluded from this release type: _onChanges */
232
+ /* Excluded from this release type: _emit */
233
+ /* Excluded from this release type: _recalculate */
234
+ /* Excluded from this release type: _subscribe */
235
+ constructor(_calculator: () => T, reactives: Array<KTReactive<unknown>>);
236
+ /**
237
+ * If new value and old value are both nodes, the old one will be replaced in the DOM
238
+ */
239
+ get value(): T;
240
+ set value(_newValue: T);
241
+ /**
242
+ * Force listeners to run once with the latest computed result.
243
+ */
244
+ notify(): void;
245
+ /**
246
+ * Computed values are derived from dependencies and should not be mutated manually.
247
+ */
248
+ mutate<R = void>(): R;
249
+ /**
250
+ * Register a callback when the value changes
251
+ * @param callback (newValue, oldValue) => xxx
252
+ */
253
+ addOnChange(callback: ReactiveChangeHandler<T>): void;
254
+ /**
255
+ * Unregister a callback
256
+ * @param callback (newValue, oldValue) => xxx
257
+ */
258
+ removeOnChange(callback: ReactiveChangeHandler<T>): boolean;
259
+ }
260
+
261
+ declare interface KTEffectOptions {
262
+ lazy: boolean;
263
+ onCleanup: () => void;
264
+ debugName: string;
265
+ }
266
+
267
+ /**
268
+ * KTFor - List rendering component with key-based optimization
269
+ * Returns a Comment anchor node with rendered elements in __kt_for_list__
270
+ */
271
+ export declare function KTFor<T>(props: KTForProps<T>): KTForElement;
272
+
273
+ export declare type KTForElement = JSX.Element;
274
+
275
+ export declare interface KTForProps<T> {
276
+ ref?: KTRef<KTForElement>;
277
+ list: T[] | KTReactive<T[]>;
278
+ key?: (item: T, index: number, array: T[]) => any;
279
+ map: (item: T, index: number, array: T[]) => HTMLElement;
280
+ }
281
+
282
+ export declare type KTPrefixedEventAttribute = {
283
+ [EventName in keyof HTMLElementEventMap as `on:${EventName}`]?: (ev: HTMLElementEventMap[EventName]) => void;
284
+ };
285
+
286
+ export declare type KTRawAttr = KTAttribute | null | undefined | '' | false;
287
+
288
+ export declare type KTRawContent = KTAvailableContent | Promise<KTAvailableContent>;
289
+
290
+ export declare type KTRawContents = KTAvailableContent;
291
+
292
+ export declare type KTReactify<T> = T extends boolean ? KTReactive<boolean> : T extends any ? KTReactive<T> : never;
293
+
294
+ export declare type KTReactifyObject<T extends object> = {
295
+ [K in keyof T]: KTReactify<T[K]>;
296
+ };
297
+
298
+ export declare type KTReactifyProps<T extends object> = {
299
+ [K in keyof T]: KTReactify<Exclude<T[K], undefined>> | T[K];
300
+ };
301
+
302
+ export declare class KTReactive<T> {
303
+ /**
304
+ * Indicates that this is a KTRef instance
305
+ */
306
+ isKT: boolean;
307
+
308
+ ktType: KTReactiveType;
309
+
310
+ /**
311
+ * If new value and old value are both nodes, the old one will be replaced in the DOM
312
+ */
313
+ get value();
314
+ set value(newValue: T);
315
+
316
+ /**
317
+ * Force all listeners to run even when reference identity has not changed.
318
+ * Useful for in-place array/object mutations.
319
+ */
320
+ notify(): void;
321
+
322
+ /**
323
+ * Mutate current value in-place and notify listeners once.
324
+ *
325
+ * @example
326
+ * const items = ref<number[]>([1, 2]);
327
+ * items.mutate((list) => list.push(3));
328
+ */
329
+ mutate<R = void>(mutator: (currentValue: T) => R): R;
330
+
331
+ /**
332
+ * Register a callback when the value changes
333
+ * - Value setter will check `Object.is(newValue, oldValue)`.
334
+ * @param callback (newValue, oldValue) => xxx
335
+ */
336
+ addOnChange(callback: ReactiveChangeHandler<T>): void;
337
+ removeOnChange(callback: ReactiveChangeHandler<T>): void;
338
+ }
339
+
340
+ export declare const enum KTReactiveType {
341
+ REF = 1,
342
+ COMPUTED = 2
343
+ }
344
+
345
+ export declare class KTRef<T> implements KTReactive<T> {
346
+ /**
347
+ * Indicates that this is a KTRef instance
348
+ */
349
+ isKT: true;
350
+ ktType: KTReactiveType;
351
+ /* Excluded from this release type: _value */
352
+ /* Excluded from this release type: _onChanges */
353
+ /* Excluded from this release type: _emit */
354
+ constructor(_value: T, _onChanges: Array<ReactiveChangeHandler<T>>);
355
+ /**
356
+ * If new value and old value are both nodes, the old one will be replaced in the DOM
357
+ */
358
+ get value(): T;
359
+ set value(newValue: T);
360
+ /**
361
+ * Force all listeners to run even when reference identity has not changed.
362
+ * Useful for in-place array/object mutations.
363
+ */
364
+ notify(): void;
365
+ /**
366
+ * Mutate current value in-place and notify listeners once.
367
+ *
368
+ * @example
369
+ * const items = ref<number[]>([1, 2]);
370
+ * items.mutate((list) => list.push(3));
371
+ */
372
+ mutate<R = void>(mutator: (currentValue: T) => R): R;
373
+ /**
374
+ * Register a callback when the value changes
375
+ * @param callback (newValue, oldValue) => xxx
376
+ */
377
+ addOnChange(callback: ReactiveChangeHandler<T>): void;
378
+ removeOnChange(callback: ReactiveChangeHandler<T>): boolean;
379
+ }
380
+
381
+ export declare type KTSurfaceRef<T extends object> = {
382
+ [K in keyof T]: KTRef<T[K]>;
383
+ } & {
384
+ /**
385
+ * Get the dereferenced object like the original one
386
+ */
387
+ kcollect: () => T;
388
+ };
389
+
390
+ declare type MathMLJSXTag = HTMLTag | ((props?: any) => MathMLElement) | ((props?: any) => Promise<MathMLElement>);
391
+
392
+ export declare type MathMLTag = keyof MathMLElementTagNameMap;
393
+
394
+ declare type otherstring = string & {};
395
+
396
+ export declare type ReactiveChangeHandler<T> = (newValue: T, oldValue: T) => void;
397
+
398
+ /**
399
+ * Reference to the created HTML element.
400
+ * - **Only** respond to `ref.value` changes, not reactive to internal changes of the element.
401
+ * - can alse be used to store normal values, but it is not reactive.
402
+ * - if the value is already a `KTRef`, it will be returned **directly**.
403
+ * @param value mostly an HTMLElement
404
+ */
405
+ export declare function ref<T = JSX.Element>(value?: T, onChange?: ReactiveChangeHandler<T>): KTRef<T>;
406
+
407
+ declare type RefSetter<T> = (props: {
408
+ ref?: KTRef<T>;
409
+ }, node: T) => void;
410
+
411
+ declare type SingleContent = KTRef<any> | HTMLElement | Element | Node | string | number | boolean | null | undefined;
412
+
413
+ /**
414
+ * Make all first-level properties of the object a `KTRef`.
415
+ * - `obj.a.b` is not reactive
416
+ */
417
+ export declare const surfaceRef: <T extends object>(obj: T) => KTSurfaceRef<T>;
418
+
419
+ declare type SVGJSXTag = HTMLTag | ((props?: any) => SVGElement) | ((props?: any) => Promise<SVGElement>);
420
+
421
+ export declare type SVGTag = keyof SVGElementTagNameMap;
422
+
423
+ export declare const toReactive: <T>(value: T | KTReactive<T>, onChange?: ReactiveChangeHandler<T>) => KTReactive<T>;
424
+
425
+ /**
426
+ * Convert a value to `KTRef`.
427
+ * - Returns the original value if it is already a `KTRef`.
428
+ * - Throws error if the value is a `KTComputed`.
429
+ * - Otherwise wraps the value with `ref()`.
430
+ * @param o value to convert
431
+ */
432
+ export declare const toRef: <T = any>(o: any) => KTRef<T>;
433
+
434
+ export { }