@ktjs/core 0.29.8 → 0.29.11
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 +1469 -10
- package/dist/index.mjs +1093 -301
- package/dist/index.mjs.map +1 -0
- package/package.json +7 -7
- package/dist/h/attr-helpers.d.ts +0 -6
- package/dist/h/attr.d.ts +0 -2
- package/dist/h/content.d.ts +0 -2
- package/dist/h/index.d.ts +0 -12
- package/dist/h/model.d.ts +0 -3
- package/dist/jsx/async.d.ts +0 -13
- package/dist/jsx/common.d.ts +0 -4
- package/dist/jsx/for.d.ts +0 -14
- package/dist/jsx/fragment.d.ts +0 -35
- package/dist/jsx/if.d.ts +0 -10
- package/dist/jsx/index.d.ts +0 -2
- package/dist/jsx/index.mjs +0 -1
- package/dist/jsx/jsx-runtime.d.ts +0 -43
- package/dist/jsx/jsx-runtime.mjs +0 -2
- package/dist/jsx-runtime-DGJHUQEM.js +0 -600
- package/dist/reactive/computed.d.ts +0 -63
- package/dist/reactive/core.d.ts +0 -9
- package/dist/reactive/effect.d.ts +0 -15
- package/dist/reactive/index.d.ts +0 -10
- package/dist/reactive/ref.d.ts +0 -89
package/dist/reactive/ref.d.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { KTReactive, ReactiveChangeHandler } from '../types/reactive.js';
|
|
2
|
-
import { KTReactiveType } from './core.js';
|
|
3
|
-
export declare class KTRef<T> implements KTReactive<T> {
|
|
4
|
-
/**
|
|
5
|
-
* Indicates that this is a KTRef instance
|
|
6
|
-
*/
|
|
7
|
-
isKT: true;
|
|
8
|
-
ktType: KTReactiveType;
|
|
9
|
-
/**
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
private _value;
|
|
13
|
-
/**
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
private _onChanges;
|
|
17
|
-
/**
|
|
18
|
-
* @internal
|
|
19
|
-
*/
|
|
20
|
-
private _emit;
|
|
21
|
-
constructor(_value: T, _onChanges: Array<ReactiveChangeHandler<T>>);
|
|
22
|
-
/**
|
|
23
|
-
* If new value and old value are both nodes, the old one will be replaced in the DOM
|
|
24
|
-
*/
|
|
25
|
-
get value(): T;
|
|
26
|
-
set value(newValue: T);
|
|
27
|
-
/**
|
|
28
|
-
* Force all listeners to run even when reference identity has not changed.
|
|
29
|
-
* Useful for in-place array/object mutations.
|
|
30
|
-
*/
|
|
31
|
-
notify(): void;
|
|
32
|
-
/**
|
|
33
|
-
* Mutate current value in-place and notify listeners once.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* const items = ref<number[]>([1, 2]);
|
|
37
|
-
* items.mutate((list) => list.push(3));
|
|
38
|
-
*/
|
|
39
|
-
mutate<R = void>(mutator: (currentValue: T) => R): R;
|
|
40
|
-
/**
|
|
41
|
-
* Register a callback when the value changes
|
|
42
|
-
* @param callback (newValue, oldValue) => xxx
|
|
43
|
-
*/
|
|
44
|
-
addOnChange(callback: ReactiveChangeHandler<T>): void;
|
|
45
|
-
removeOnChange(callback: ReactiveChangeHandler<T>): boolean;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Reference to the created HTML element.
|
|
49
|
-
* - **Only** respond to `ref.value` changes, not reactive to internal changes of the element.
|
|
50
|
-
* - can alse be used to store normal values, but it is not reactive.
|
|
51
|
-
* - if the value is already a `KTRef`, it will be returned **directly**.
|
|
52
|
-
* @param value mostly an HTMLElement
|
|
53
|
-
*/
|
|
54
|
-
export declare function ref<T = JSX.Element>(value?: T, onChange?: ReactiveChangeHandler<T>): KTRef<T>;
|
|
55
|
-
/**
|
|
56
|
-
* Convert a value to `KTRef`.
|
|
57
|
-
* - Returns the original value if it is already a `KTRef`.
|
|
58
|
-
* - Throws error if the value is a `KTComputed`.
|
|
59
|
-
* - Otherwise wraps the value with `ref()`.
|
|
60
|
-
* @param o value to convert
|
|
61
|
-
*/
|
|
62
|
-
export declare const toRef: <T = any>(o: any) => KTRef<T>;
|
|
63
|
-
export type KTSurfaceRef<T extends object> = {
|
|
64
|
-
[K in keyof T]: KTRef<T[K]>;
|
|
65
|
-
} & {
|
|
66
|
-
/**
|
|
67
|
-
* Get the dereferenced object like the original one
|
|
68
|
-
*/
|
|
69
|
-
kcollect: () => T;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Make all first-level properties of the object a `KTRef`.
|
|
73
|
-
* - `obj.a.b` is not reactive
|
|
74
|
-
*/
|
|
75
|
-
export declare const surfaceRef: <T extends object>(obj: T) => KTSurfaceRef<T>;
|
|
76
|
-
/**
|
|
77
|
-
* Assert k-model to be a ref object
|
|
78
|
-
*/
|
|
79
|
-
export declare const $modelOrRef: <T = any>(props: any, defaultValue?: T) => KTRef<T>;
|
|
80
|
-
type RefSetter<T> = (props: {
|
|
81
|
-
ref?: KTRef<T>;
|
|
82
|
-
}, node: T) => void;
|
|
83
|
-
/**
|
|
84
|
-
* Whether `props.ref` is a `KTRef` only needs to be checked in the initial render
|
|
85
|
-
*/
|
|
86
|
-
export declare const $initRef: <T extends Node>(props: {
|
|
87
|
-
ref?: KTRef<T>;
|
|
88
|
-
}, node: T) => RefSetter<T>;
|
|
89
|
-
export {};
|