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