@ktjs/core 0.32.5 → 0.33.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/README.md CHANGED
@@ -12,11 +12,14 @@
12
12
 
13
13
  <p align="center"><strong>Visit KT.js: <a href="https://baendlorel.github.io/kt.js/">https://baendlorel.github.io/kt.js/</a></strong></p>
14
14
 
15
+ > kt.js is still under development, so there might be some breaking changes. Note the Update Log below
16
+
15
17
  ## Recent Updates
16
18
 
17
- 1. Special refs for `Array`, `Set`, `Map`, `WeakMap`, `WeakSet`, `Date` to better track mutations.
18
- - e.g. `const a = ref.array([1, 2])`, then we can call `a.push(3)` to make a reactive change instead of `a.value.push(3)`.
19
- 2. Fixed issues of `svg` and `mathml` elements.
19
+ 1. `ref.value` remains the standard read API, and it can also replace the whole outer value with `ref.value = nextValue`.
20
+ 2. `ref.draft` is the deep-mutation entry for nested objects, arrays, `Map` / `Set`, and custom mutable objects.
21
+ 3. `ref.draft` itself is not assignable; mutate nested fields or call mutating methods on the returned object instead.
22
+ 4. `addOnChange((newValue, oldValue) => ...)` keeps `oldValue` as the previous reference, not a deep snapshot.
20
23
 
21
24
  ## Community
22
25
 
@@ -29,6 +32,35 @@ kt.js is a simple framework with a tiny runtime that renders real DOM directly (
29
32
 
30
33
  KT.js focuses on one principle: keep direct control of the DOM and avoid unnecessary repainting.
31
34
 
35
+ ## Reactive Contract
36
+
37
+ ```ts
38
+ const user = ref({ profile: { name: 'John' }, tags: ['new'] });
39
+
40
+ console.log(user.value.profile.name); // read
41
+
42
+ user.value = {
43
+ ...user.value,
44
+ profile: { ...user.value.profile, name: 'Jane' },
45
+ tags: [...user.value.tags],
46
+ }; // replace the whole outer value
47
+
48
+ user.draft.profile.name = 'Jane'; // deep write
49
+ user.draft.tags.push('active'); // array / map / set / custom-object style mutation
50
+ ```
51
+
52
+ Rules:
53
+
54
+ - Read with `.value`.
55
+ - Replace the whole outer value with `.value = nextValue`.
56
+ - Use `.draft` for deep mutations on nested objects, arrays, `Map` / `Set`, or other mutable instances.
57
+ - Do not assign to `.draft` itself; mutate inside it.
58
+ - `computed` stays read-only and is consumed through `.value`.
59
+ - `oldValue` in change listeners is the previous reference only, not a deep-cloned snapshot.
60
+ - Correctness is expected to come from the transformer and TypeScript checks; runtime hot paths stay minimal on purpose.
61
+
62
+ This is an explicit contract, closer to a Rust-style model than permissive runtime magic: unclear code should fail early.
63
+
32
64
  ## Quick Start
33
65
 
34
66
  ```bash
package/dist/index.d.ts CHANGED
@@ -1,6 +1,75 @@
1
1
  import { otherstring, HTMLTag, SVGTag, MathMLTag, JSXTag } from '@ktjs/shared';
2
2
  export { HTMLTag, InputElementTag, MathMLTag, SVGTag } from '@ktjs/shared';
3
3
 
4
+ interface KTEffectOptions {
5
+ lazy: boolean;
6
+ onCleanup: () => void;
7
+ debugName: string;
8
+ }
9
+ /**
10
+ * Register a reactive effect with options.
11
+ * @param effectFn The effect function to run when dependencies change
12
+ * @param reactives The reactive dependencies
13
+ * @param options Effect options: lazy, onCleanup, debugName
14
+ * @returns stop function to remove all listeners
15
+ */
16
+ declare function effect(effectFn: () => void, reactives: Array<KTReactive<any>>, options?: Partial<KTEffectOptions>): () => void;
17
+
18
+ /**
19
+ *
20
+ * @param value
21
+ * @returns
22
+ */
23
+ declare const toReactive: <T>(value: T | KTReactive<T>) => KTReactive<T>;
24
+ /**
25
+ * Extracts the value from a KTReactive, or returns the value directly if it's not reactive.
26
+ */
27
+ declare function dereactive<T = JSX.Element>(value: T | KTReactive<T>): T;
28
+
29
+ declare const enum KTReactiveType {
30
+ Reative = 1,
31
+ Computed = 2,
32
+ Ref = 3
33
+ }
34
+ declare const isKT: <T = any>(obj: any) => obj is KTReactive<T>;
35
+ declare const isRef: <T = any>(obj: any) => obj is KTRef<T>;
36
+ declare const isComputed: <T = any>(obj: any) => obj is KTComputed<T>;
37
+
38
+ declare class KTRef<T> extends KTReactive<T> {
39
+ readonly ktType = KTReactiveType.Ref;
40
+ get value(): T;
41
+ set value(newValue: T);
42
+ get draft(): T;
43
+ /**
44
+ * Force all listeners to run even when reference identity has not changed.
45
+ */
46
+ notify(oldValue?: T, newValue?: T, handlerKeys?: ChangeHandlerKey[]): this;
47
+ }
48
+ /**
49
+ * Create a `KTRef` object.
50
+ * - use `refObject.state` to get plain data
51
+ * - use `refObject.map(calculator)` to create a computed value based on this ref
52
+ * - use `refObject.mutable` to set too, but it will recalculate in the next microtask. Useful for deep objects, `Map`, `Set` or other custom objects
53
+ *
54
+ * @param value any data
55
+ * @param onChange event handler triggered when the value changes, with signature `(newValue, oldValue) => void`
56
+ * @returns
57
+ */
58
+ declare const ref: <T = JSX.Element>(value?: T) => KTRef<T>;
59
+ /**
60
+ * Assert k-model to be a ref object
61
+ */
62
+ declare const $modelOrRef: <T = any>(props: any, defaultValue?: T) => KTRef<T>;
63
+ type RefSetter<T> = (props: {
64
+ ref?: KTRef<T>;
65
+ }, node: T) => void;
66
+ /**
67
+ * Whether `props.ref` is a `KTRef` only needs to be checked in the initial render
68
+ */
69
+ declare const $initRef: <T extends Node>(props: {
70
+ ref?: KTRef<T>;
71
+ }, node: T) => RefSetter<T>;
72
+
4
73
  // Base events available to all HTML elements
5
74
  type BaseAttr = KTPrefixedEventAttribute & {
6
75
  [k: string]: KTMaybeReactive<any>;
@@ -914,8 +983,9 @@ interface SVGAttributesMap {
914
983
  view: AttributesMap['svg'] & KTMaybeReactiveProps<{ viewBox?: string; preserveAspectRatio?: string }>;
915
984
  }
916
985
 
986
+ type AliasElement = Element;
917
987
  declare namespace JSX {
918
- type Element = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
988
+ type Element = AliasElement;
919
989
 
920
990
  interface IntrinsicElements {
921
991
  [k: string]: AttributesMap['div']; // Allow any element with div attributes as fallback
@@ -1136,359 +1206,84 @@ declare namespace JSX {
1136
1206
  }
1137
1207
  }
1138
1208
 
1139
- declare class KTArrayRef<T> extends KTRef<T[]> {
1140
- constructor(value: T[], onChange?: ReactiveChangeHandler<T[]>);
1141
- get length(): number;
1142
- set length(newLength: number);
1143
- push(...items: T[]): number;
1144
- /**
1145
- * Same as `Array.prototype.pop`, but emits change after calling it
1146
- */
1147
- pop(): T | undefined;
1148
- /**
1149
- * Same as `Array.prototype.shift`, but emits change after calling it
1150
- */
1151
- shift(): T | undefined;
1152
- /**
1153
- * Same as `Array.prototype.unshift`, but emits change after calling it
1154
- */
1155
- unshift(...items: T[]): number;
1156
- /**
1157
- * Same as `Array.prototype.splice`, but emits change after calling it
1158
- */
1159
- splice(start: number, deleteCount?: number): T[];
1160
- splice(start: number, deleteCount: number, ...items: T[]): T[];
1161
- /**
1162
- * Same as `Array.prototype.sort`, but emits change after calling it
1163
- */
1164
- sort(compareFn?: (a: T, b: T) => number): this;
1165
- /**
1166
- * Same as `Array.prototype.reverse`, but emits change after calling it
1167
- */
1168
- reverse(): this;
1209
+ declare class KTComputed<T> extends KTReactive<T> {
1210
+ readonly ktType = KTReactiveType.Computed;
1211
+ constructor(_calculator: () => T, dependencies: Array<KTReactive<unknown>>);
1169
1212
  /**
1170
- * Same as `Array.prototype.fill`, but emits change after calling it
1213
+ * If new value and old value are both nodes, the old one will be replaced in the DOM
1171
1214
  */
1172
- fill(value: T, start?: number, end?: number): this;
1215
+ get value(): T;
1216
+ set value(_newValue: T);
1173
1217
  /**
1174
- * Same as `Array.prototype.copyWithin`, but emits change after calling it
1218
+ * Force listeners to run once with the latest computed result.
1175
1219
  */
1176
- copyWithin(target: number, start: number, end?: number): this;
1177
- }
1178
- declare const arrayRef: (value: unknown, onChange?: ReactiveChangeHandler<any>) => KTArrayRef<any>;
1179
-
1180
- declare class KTDateRef extends KTRef<Date> {
1181
- constructor(value: Date, onChange?: ReactiveChangeHandler<Date>);
1182
- setTime(timeValue: number): number;
1183
- setMilliseconds(millisecondsValue: number): number;
1184
- setUTCMilliseconds(millisecondsValue: number): number;
1185
- setSeconds(secondsValue: number, millisecondsValue?: number): number;
1186
- setUTCSeconds(secondsValue: number, millisecondsValue?: number): number;
1187
- setMinutes(minutesValue: number, secondsValue?: number, millisecondsValue?: number): number;
1188
- setUTCMinutes(minutesValue: number, secondsValue?: number, millisecondsValue?: number): number;
1189
- setHours(hoursValue: number, minutesValue?: number, secondsValue?: number, millisecondsValue?: number): number;
1190
- setUTCHours(hoursValue: number, minutesValue?: number, secondsValue?: number, millisecondsValue?: number): number;
1191
- setDate(dateValue: number): number;
1192
- setUTCDate(dateValue: number): number;
1193
- setMonth(monthValue: number, dateValue?: number): number;
1194
- setUTCMonth(monthValue: number, dateValue?: number): number;
1195
- setFullYear(yearValue: number, monthValue?: number, dateValue?: number): number;
1196
- setUTCFullYear(yearValue: number, monthValue?: number, dateValue?: number): number;
1197
- }
1198
- declare const dateRef: (value: unknown, onChange?: ReactiveChangeHandler<any>) => KTDateRef;
1199
-
1200
- declare class KTMapRef<K, V> extends KTRef<Map<K, V>> {
1201
- constructor(value: Map<K, V>, onChange?: ReactiveChangeHandler<Map<K, V>>);
1202
- get size(): number;
1203
- has(key: K): boolean;
1204
- get(key: K): V | undefined;
1205
- set(key: K, value: V): this;
1206
- delete(key: K): boolean;
1207
- clear(): any;
1208
- }
1209
- declare const mapRef: (value: unknown, onChange?: ReactiveChangeHandler<any>) => KTMapRef<unknown, unknown>;
1210
-
1211
- declare class KTSetRef<T> extends KTRef<Set<T>> {
1212
- constructor(value: Set<T>, onChange?: ReactiveChangeHandler<Set<T>>);
1213
- get size(): number;
1214
- has(value: T): boolean;
1215
- add(value: T): this;
1216
- delete(value: T): boolean;
1217
- clear(): any;
1218
- }
1219
- declare const setRef: (value: unknown, onChange?: ReactiveChangeHandler<any>) => KTSetRef<unknown>;
1220
-
1221
- declare class KTWeakMapRef<K extends WeakKey = WeakKey, V = any> extends KTRef<WeakMap<K, V>> {
1222
- constructor(value: WeakMap<K, V>, onChange?: ReactiveChangeHandler<WeakMap<K, V>>);
1223
- has(key: K): boolean;
1224
- get(key: K): V | undefined;
1225
- set(key: K, value: V): this;
1226
- delete(key: K): boolean;
1227
- }
1228
- declare const weakMapRef: (value: unknown, onChange?: ReactiveChangeHandler<any>) => KTWeakMapRef<WeakKey, any>;
1229
-
1230
- declare class KTWeakSetRef<T extends WeakKey = WeakKey> extends KTRef<WeakSet<T>> {
1231
- constructor(value: WeakSet<T>, onChange?: ReactiveChangeHandler<WeakSet<T>>);
1232
- has(value: T): boolean;
1233
- add(value: T): this;
1234
- delete(value: T): boolean;
1235
- }
1236
- declare const weakSetRef: (value: unknown, onChange?: ReactiveChangeHandler<any>) => KTWeakSetRef<WeakKey>;
1237
-
1238
- type KTIsExactlyBoolean<T> = [T] extends [boolean] ? ([boolean] extends [T] ? true : false) : false;
1239
-
1240
- type KTAutoRef<T> =
1241
- KTIsExactlyBoolean<T> extends true
1242
- ? KTRef<boolean>
1243
- : T extends Array<infer A>
1244
- ? KTArrayRef<A>
1245
- : T extends Map<infer K, infer V>
1246
- ? KTMapRef<K, V>
1247
- : T extends Set<infer U>
1248
- ? KTSetRef<U>
1249
- : T extends Date
1250
- ? KTDateRef
1251
- : T extends WeakSet<infer U>
1252
- ? KTWeakSetRef<U>
1253
- : T extends WeakMap<infer K, infer V>
1254
- ? KTWeakMapRef<K, V>
1255
- : KTRef<T>;
1256
-
1257
- /**
1258
- * Reference to the created HTML element or other reactive data.
1259
- * - **Only** respond to `ref.value` changes, not reactive to internal changes of the element.
1260
- * - Automatically wrap the value with corresponding ref type based on its type.
1261
- * - When wrapped, setter-like methods will be reactive. like `push` for `Array`, `set` for `Map`, `add` for `Set`, etc.
1262
- * - Supports: `Array`, `Map`, `Set`, `WeakMap`, `WeakSet`, `Date`.
1263
- * - Since there will be some cost for runtime detection, and compilation plugin might not be able to analyze all cases. It is recommended to use specific ref type directly if you already know the type of value, like `ref.array`, `ref.map`, etc.
1264
- * @param value any data
1265
- * @param onChange event handler triggered when the value changes, with signature `(newValue, oldValue) => void`
1266
- */
1267
- declare function autoRef<T>(value?: T, onChange?: ReactiveChangeHandler<T>): KTAutoRef<T>;
1268
- type RefCreator = (<T = JSX.Element>(value?: T, onChange?: ReactiveChangeHandler<T>) => KTRef<T>) & {
1269
- array: typeof arrayRef;
1270
- date: typeof dateRef;
1271
- map: typeof mapRef;
1272
- set: typeof setRef;
1273
- weakMap: typeof weakMapRef;
1274
- weakSet: typeof weakSetRef;
1275
- };
1276
- /**
1277
- * Create a plain `KTRef` object.
1278
- *
1279
- * If you want the value to be automatically wrapped with corresponding ref type based on its type, please use `autoRef` instead.
1280
- *
1281
- * @param value any data
1282
- * @param onChange event handler triggered when the value changes, with signature `(newValue, oldValue) => void`
1283
- * @returns
1284
- */
1285
- declare const ref: RefCreator;
1286
-
1287
- /**
1288
- * Assert k-model to be a ref object
1289
- */
1290
- declare const $modelOrRef: <T = any>(props: any, defaultValue?: T) => KTRef<T>;
1291
- type RefSetter<T> = (props: {
1292
- ref?: KTRef<T>;
1293
- }, node: T) => void;
1294
- /**
1295
- * Whether `props.ref` is a `KTRef` only needs to be checked in the initial render
1296
- */
1297
- declare const $initRef: <T extends Node>(props: {
1298
- ref?: KTRef<T>;
1299
- }, node: T) => RefSetter<T>;
1300
-
1301
- interface KTEffectOptions {
1302
- lazy: boolean;
1303
- onCleanup: () => void;
1304
- debugName: string;
1220
+ notify(handlerKeys?: ChangeHandlerKey[]): this;
1305
1221
  }
1306
1222
  /**
1307
- * Register a reactive effect with options.
1308
- * @param effectFn The effect function to run when dependencies change
1309
- * @param reactives The reactive dependencies
1310
- * @param options Effect options: lazy, onCleanup, debugName
1311
- * @returns stop function to remove all listeners
1312
- */
1313
- declare function effect(effectFn: () => void, reactives: Array<KTReactive<any>>, options?: Partial<KTEffectOptions>): () => void;
1314
-
1315
- declare const toReactive: <T>(value: T | KTReactive<T>, onChange?: ReactiveChangeHandler<T>) => KTReactive<T>;
1316
- /**
1317
- * Extracts the value from a KTReactive, or returns the value directly if it's not reactive.
1223
+ * Create a reactive computed value
1224
+ * @param computeFn
1225
+ * @param dependencies refs and computeds that this computed depends on
1318
1226
  */
1319
- declare function dereactive<T = JSX.Element>(value: T | KTReactive<T>): T;
1320
-
1321
- declare const enum KTReactiveType {
1322
- Computed = 1,
1323
- Ref = 2,
1324
- ObjectRef = 3,
1325
- ArrayRef = 4,
1326
- MapRef = 5,
1327
- SetRef = 6,
1328
- WeakMapRef = 7,
1329
- WeakSetRef = 8,
1330
- DateRef = 9
1331
- }
1332
- declare const isKT: <T = any>(obj: any) => obj is KTReactive<T>;
1333
- declare const isRef: <T = any>(obj: any) => obj is KTRef<T>;
1334
- declare const isArrayRef: <T = any>(obj: any) => obj is KTRef<T[]>;
1335
- declare const isMapRef: <K = any, V = any>(obj: any) => obj is KTRef<Map<K, V>>;
1336
- declare const isSetRef: <T = any>(obj: any) => obj is KTRef<Set<T>>;
1337
- declare const isWeakMapRef: <K extends WeakKey = WeakKey, V = any>(obj: any) => obj is KTRef<WeakMap<K, V>>;
1338
- declare const isWeakSetRef: <T extends WeakKey = WeakKey>(obj: any) => obj is KTRef<WeakSet<T>>;
1339
- declare const isDateRef: (obj: any) => obj is KTRef<Date>;
1340
- declare const isComputed: <T = any>(obj: any) => obj is KTComputed<T>;
1227
+ declare function computed<T = JSX.Element>(computeFn: () => T, dependencies: Array<KTReactive<any>>): KTComputed<T>;
1341
1228
 
1342
- declare class KTComputed<T> implements KTReactive<T> {
1229
+ type ChangeHandler<T> = (newValue: T, oldValue: T) => void;
1230
+ type ChangeHandlerKey = string | number;
1231
+ declare class KTReactive<T> {
1343
1232
  /**
1344
1233
  * Indicates that this is a KTRef instance
1345
1234
  */
1346
- isKT: true;
1347
- ktType: KTReactiveType;
1348
- constructor(_calculator: () => T, reactives: Array<KTReactive<unknown>>);
1235
+ readonly isKT: true;
1236
+ readonly ktType: KTReactiveType;
1237
+ constructor(_value: T);
1349
1238
  /**
1350
1239
  * If new value and old value are both nodes, the old one will be replaced in the DOM
1240
+ * - Use `.mutable` to modify the value.
1241
+ * @readonly
1351
1242
  */
1352
1243
  get value(): T;
1353
1244
  set value(_newValue: T);
1354
1245
  /**
1355
- * Force listeners to run once with the latest computed result.
1246
+ * Force all listeners to run even when reference identity has not changed.
1247
+ * Useful for in-place array/object mutations.
1248
+ * - Is implemented differently in `KTRef` and `KTComputed`
1356
1249
  */
1357
- notify(handlerKeys?: ReactiveChangeKey[]): void;
1250
+ notify(..._args: unknown[]): this;
1358
1251
  /**
1359
- * Computed values are derived from dependencies and should not be mutated manually.
1252
+ * Ccreate a computed value based on this `KTReactive` instance.
1253
+ * @param calculator A function that calculates the computed value based on the current value of this `KTReactive` instance.
1254
+ * @param dependencies Optional additional dependencies that the computed value relies on.
1255
+ * @returns A `KTComputed` instance
1256
+ *
1257
+ * @see ./computed.ts implemented in `KTComputed`
1360
1258
  */
1361
- mutate<R = void>(_mutator?: (currentValue: T) => R, handlerKeys?: ReactiveChangeKey[]): R;
1362
- toComputed<R>(calculator: (currentValue: T) => R, dependencies?: KTReactive<any>[]): KTComputed<R>;
1259
+ map<R>(calculator: (currentValue: T) => R, dependencies?: Array<KTReactive<any>>): KTComputed<R>;
1363
1260
  /**
1364
1261
  * Register a callback when the value changes
1365
- * @param callback (newValue, oldValue) => xxx
1366
- */
1367
- addOnChange<K extends ReactiveChangeKey | undefined>(callback: ReactiveChangeHandler<T>, key?: K): K extends undefined ? number : K;
1368
- /**
1369
- * Unregister a callback
1370
- * @param key registered listener key
1262
+ * @param callback newValue and oldValue are references. You can use `a.draft` to make in-place mutations since `a.value` will not trigger `onChange` handers.
1263
+ * @param key Optional key to identify the callback, allowing multiple listeners on the same ref and individual removal. If not provided, a unique ID will be generated.
1371
1264
  */
1372
- removeOnChange(key: ReactiveChangeKey): ReactiveChangeHandler<any> | undefined;
1265
+ addOnChange(callback: ChangeHandler<T>, key?: ChangeHandlerKey): this;
1266
+ removeOnChange(key: ChangeHandlerKey): ChangeHandler<any> | undefined;
1373
1267
  }
1374
- /**
1375
- * Create a reactive computed value
1376
- * @param computeFn
1377
- * @param dependencies refs and computeds that this computed depends on
1378
- */
1379
- declare function computed<T = JSX.Element>(computeFn: () => T, dependencies: Array<KTReactive<any>>): KTComputed<T>;
1380
-
1381
- type ReactiveChangeHandler<T> = (newValue: T, oldValue: T) => void;
1382
- type ReactiveChangeKey = string | number;
1383
-
1384
- interface KTReactive<T> {
1385
- /**
1386
- * Indicates that this is a KTRef instance
1387
- */
1388
- isKT: boolean;
1389
-
1390
- ktType: KTReactiveType;
1391
-
1392
- /**
1393
- * If new value and old value are both nodes, the old one will be replaced in the DOM
1394
- */
1395
- get value();
1396
- set value(newValue: T);
1397
-
1398
- /**
1399
- * Force all listeners to run even when reference identity has not changed.
1400
- * Useful for in-place array/object mutations.
1401
- */
1402
- notify(handlerKeys?: ReactiveChangeKey[]): void;
1403
-
1404
- /**
1405
- * Mutate current value in-place and notify listeners once.
1406
- *
1407
- * @example
1408
- * const items = ref<number[]>([1, 2]);
1409
- * items.mutate((list) => list.push(3));
1410
- */
1411
- mutate<R = void>(mutator: (currentValue: T) => R, handlerKeys?: ReactiveChangeKey[]): R;
1412
-
1413
- /**
1414
- * Ccreate a computed value based on this `KTReactive` instance.
1415
- * @param calculator A function that calculates the computed value based on the current value of this `KTReactive` instance.
1416
- * @param dependencies Optional additional dependencies that the computed value relies on.
1417
- * @returns A `KTComputed` instance
1418
- */
1419
- toComputed<R>(calculator: (currentValue: T) => R, dependencies?: KTReactive<any>[]): KTComputed<R>;
1420
-
1421
- /**
1422
- * Register a callback when the value changes
1423
- * - Value setter will check `Object.is(newValue, oldValue)`.
1424
- * @param callback (newValue, oldValue) => xxx
1425
- * @param key Optional key to identify this change handler. If not provided, a numeric id will be generated and returned.
1426
- */
1427
- addOnChange<K extends ReactiveChangeKey | undefined>(
1428
- callback: ReactiveChangeHandler<T>,
1429
- key?: K,
1430
- ): K extends undefined ? number : K;
1431
- removeOnChange(key: ReactiveChangeKey): ReactiveChangeHandler<any> | undefined;
1432
- }
1433
-
1434
- // & Shockingly, If T is boolean, KTReactify<T> becomes KTReactive<true> | KTReactive<false>. It causes @ktjs/mui that disabledRefs not assignable.
1435
1268
  /**
1436
1269
  * Makes `KTReactify<'a' | 'b'> to be KTReactive<'a'> | KTReactive<'b'>`
1437
1270
  */
1438
1271
  type KTReactifySplit<T> = T extends boolean ? KTReactive<boolean> : T extends any ? KTReactive<T> : never;
1439
-
1440
1272
  type KTReactifyObject<T extends object> = {
1441
- [K in keyof T]: KTReactifySplit<T[K]>;
1273
+ [K in keyof T]: KTReactifySplit<T[K]>;
1442
1274
  };
1443
-
1444
1275
  type KTReactifyProps<T extends object> = {
1445
- [K in keyof T]: KTReactifySplit<Exclude<T[K], undefined>> | T[K];
1276
+ [K in keyof T]: KTReactifySplit<Exclude<T[K], undefined>> | T[K];
1446
1277
  };
1447
-
1448
1278
  /**
1449
1279
  * Makes `KTReactify<'a' | 'b'>` to be `KTReactive<'a' | 'b'>`
1450
1280
  */
1451
1281
  type KTReactify<T> = [T] extends [KTReactive<infer U>] ? KTReactive<U> : KTReactive<T>;
1452
1282
  type KTMaybeReactive<T> = T | KTReactify<T>;
1453
1283
  type KTMaybeReactiveProps<T extends object> = {
1454
- [K in keyof T]: K extends `on:${string}` ? T[K] : KTMaybeReactive<Exclude<T[K], undefined>> | T[K];
1284
+ [K in keyof T]: K extends `on:${string}` ? T[K] : KTMaybeReactive<Exclude<T[K], undefined>> | T[K];
1455
1285
  };
1456
1286
 
1457
- declare class KTRef<T> implements KTReactive<T> {
1458
- /**
1459
- * Indicates that this is a KTRef instance
1460
- */
1461
- isKT: true;
1462
- ktType: KTReactiveType;
1463
- constructor(_value: T, _onChange?: ReactiveChangeHandler<T>);
1464
- /**
1465
- * If new value and old value are both nodes, the old one will be replaced in the DOM
1466
- */
1467
- get value(): T;
1468
- set value(newValue: T);
1469
- /**
1470
- * Force all listeners to run even when reference identity has not changed.
1471
- * Useful for in-place array/object mutations.
1472
- */
1473
- notify(handlerKeys?: ReactiveChangeKey[]): void;
1474
- /**
1475
- * Mutate current value in-place and notify listeners once.
1476
- *
1477
- * @example
1478
- * const items = ref<number[]>([1, 2]);
1479
- * items.mutate((list) => list.push(3));
1480
- */
1481
- mutate<R = void>(mutator: (currentValue: T) => R, handlerKeys?: ReactiveChangeKey[]): R;
1482
- toComputed<R>(calculator: (currentValue: T) => R, dependencies?: KTReactive<any>[]): KTComputed<R>;
1483
- /**
1484
- * Register a callback when the value changes
1485
- * @param callback (newValue, oldValue) => xxx
1486
- * @param key Optional key to identify the callback, allowing multiple listeners on the same ref and individual removal. If not provided, a unique ID will be generated.
1487
- */
1488
- addOnChange<K extends ReactiveChangeKey | undefined>(callback: ReactiveChangeHandler<T>, key?: K): K extends undefined ? number : K;
1489
- removeOnChange(key: ReactiveChangeKey): ReactiveChangeHandler<any> | undefined;
1490
- }
1491
-
1492
1287
  type HTML<T extends (HTMLTag | SVGTag | MathMLTag) & otherstring> = T extends SVGTag
1493
1288
  ? SVGElementTagNameMap[T]
1494
1289
  : T extends HTMLTag
@@ -1653,7 +1448,7 @@ interface KTForProps<T> {
1653
1448
  ref?: KTRef<KTForElement>;
1654
1449
  list: T[] | KTReactive<T[]>;
1655
1450
  key?: (item: T, index: number, array: T[]) => any;
1656
- map?: (item: T, index: number, array: T[]) => HTMLElement;
1451
+ map?: (item: T, index: number, array: T[]) => JSX.Element;
1657
1452
  }
1658
1453
  /**
1659
1454
  * KTFor - List rendering component with key-based optimization
@@ -1661,7 +1456,7 @@ interface KTForProps<T> {
1661
1456
  */
1662
1457
  declare function KTFor<T>(props: KTForProps<T>): KTForElement;
1663
1458
 
1664
- declare function KTConditional(condition: any | KTReactive<any>, tagIf: JSXTag, propsIf: KTAttribute, tagElse?: JSXTag, propsElse?: KTAttribute): JSX.Element;
1459
+ declare function KTConditional(condition: any | KTReactive<any>, tagIf: JSXTag, propsIf: KTAttribute, tagElse?: JSXTag, propsElse?: KTAttribute): Element;
1665
1460
 
1666
- export { $initRef, $modelOrRef, Fragment, JSX, KTArrayRef, KTAsync, KTComputed, KTConditional, KTDateRef, KTFor, KTMapRef, KTReactiveType, KTSetRef, KTWeakMapRef, KTWeakSetRef, applyAttr, autoRef, computed, h as createElement, mathml$1 as createMathMLElement, svg$1 as createSVGElement, dereactive, effect, h, isArrayRef, isComputed, isDateRef, isKT, isMapRef, isRef, isSetRef, isWeakMapRef, isWeakSetRef, jsx, jsxDEV, jsxs, mathml, mathml as mathmlRuntime, ref, svg, svg as svgRuntime, toReactive };
1667
- export type { EventHandler, HTML, KTAttribute, KTForElement, KTForProps, KTMaybeReactive, KTMaybeReactiveProps, KTPrefixedEventAttribute, KTRawAttr, KTRawContent, KTRawContents, KTReactify, KTReactifyObject, KTReactifyProps, KTReactifySplit, KTReactive, ReactiveChangeHandler, ReactiveChangeKey };
1461
+ export { $initRef, $modelOrRef, Fragment, JSX, KTAsync, KTComputed, KTConditional, KTFor, KTReactive, KTReactiveType, KTRef, applyAttr, computed, h as createElement, mathml$1 as createMathMLElement, svg$1 as createSVGElement, dereactive, effect, h, isComputed, isKT, isRef, jsx, jsxDEV, jsxs, mathml, mathml as mathmlRuntime, ref, svg, svg as svgRuntime, toReactive };
1462
+ export type { AliasElement, ChangeHandler, ChangeHandlerKey, EventHandler, HTML, KTAttribute, KTForElement, KTForProps, KTMaybeReactive, KTMaybeReactiveProps, KTPrefixedEventAttribute, KTRawAttr, KTRawContent, KTRawContents, KTReactify, KTReactifyObject, KTReactifyProps, KTReactifySplit };