@tempots/dom 18.0.0 → 19.0.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/dom/animatable.d.ts +12 -12
- package/dom/attr.d.ts +14 -7
- package/dom/dom-context.d.ts +47 -2
- package/dom/dom-utils.d.ts +6 -3
- package/dom/handle-anchor-click.d.ts +13 -2
- package/dom/ssr.d.ts +48 -16
- package/index.cjs +1 -1
- package/index.js +984 -744
- package/package.json +1 -1
- package/renderable/async.d.ts +33 -3
- package/renderable/attribute.d.ts +24 -7
- package/renderable/bind.d.ts +43 -13
- package/renderable/conjunction.d.ts +23 -4
- package/renderable/consumers.d.ts +54 -1
- package/renderable/domnode.d.ts +10 -2
- package/renderable/element.d.ts +50 -3
- package/renderable/empty.d.ts +5 -0
- package/renderable/ensure.d.ts +10 -0
- package/renderable/foreach.d.ts +12 -2
- package/renderable/fragment.d.ts +11 -0
- package/renderable/handler.d.ts +64 -10
- package/renderable/map-signal.d.ts +15 -0
- package/renderable/not-empty.d.ts +13 -1
- package/renderable/onctx.d.ts +9 -2
- package/renderable/oneof.d.ts +138 -16
- package/renderable/onmount.d.ts +8 -0
- package/renderable/onunmount.d.ts +6 -0
- package/renderable/portal.d.ts +12 -3
- package/renderable/providers.d.ts +39 -6
- package/renderable/render.d.ts +39 -3
- package/renderable/repeat.d.ts +11 -2
- package/renderable/style.d.ts +4 -0
- package/renderable/task.d.ts +18 -2
- package/renderable/text.d.ts +16 -3
- package/renderable/when.d.ts +21 -3
- package/std/interpolate.d.ts +56 -5
- package/std/position.d.ts +42 -2
- package/std/signal-utils.d.ts +195 -19
- package/std/signal.d.ts +399 -30
- package/types/aria-attributes.d.ts +5 -0
- package/types/css-styles.d.ts +11 -0
- package/types/domain.d.ts +62 -2
- package/types/html-attributes.d.ts +10 -0
- package/types/html-events.d.ts +5 -0
- package/types/html-tags.d.ts +5 -0
- package/types/mathml-attributes.d.ts +5 -0
- package/types/mathml-tags.d.ts +4 -0
- package/types/svg-attributes.d.ts +5 -0
- package/types/svg-tags.d.ts +5 -0
package/std/signal-utils.d.ts
CHANGED
|
@@ -1,50 +1,226 @@
|
|
|
1
1
|
import { RemoveSignals, Value } from '../types/domain';
|
|
2
2
|
import { AnySignal, Computed, Prop, Signal } from './signal';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Represents a memory store that stores key-value pairs.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
4
9
|
export declare class MemoryStore {
|
|
5
10
|
private readonly _store;
|
|
6
|
-
|
|
7
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves the value associated with the specified key from the memory store.
|
|
13
|
+
* @param key - The key to retrieve the value for.
|
|
14
|
+
* @returns The value associated with the key, or `null` if the key is not found.
|
|
15
|
+
*/
|
|
16
|
+
readonly getItem: (key: string) => string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Sets the value associated with the specified key in the memory store.
|
|
19
|
+
* @param key - The key to set the value for.
|
|
20
|
+
* @param value - The value to set.
|
|
21
|
+
*/
|
|
22
|
+
readonly setItem: (key: string, value: string) => void;
|
|
8
23
|
}
|
|
9
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Represents the properties required for storing and retrieving a value of type `T`.
|
|
26
|
+
*
|
|
27
|
+
* @typeParam T - The type of the value to be stored.
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export type StoredPropOptions<T> = {
|
|
31
|
+
/**
|
|
32
|
+
* The key to use for storing and retrieving the value.
|
|
33
|
+
*/
|
|
10
34
|
key: string;
|
|
35
|
+
/**
|
|
36
|
+
* The default value to use if the value is not found in the store.
|
|
37
|
+
* This can be a value of type `T` or a function that returns a value of type `T`.
|
|
38
|
+
* If a function is provided, it will be called to get the default value.
|
|
39
|
+
*/
|
|
11
40
|
defaultValue: T | (() => T);
|
|
41
|
+
/**
|
|
42
|
+
* The store to use for storing and retrieving the value.
|
|
43
|
+
*/
|
|
12
44
|
store: {
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves the value associated with the specified key from the store.
|
|
47
|
+
* @param key - The key to retrieve the value for.
|
|
48
|
+
* @returns The value associated with the key, or `null` if the key is not found.
|
|
49
|
+
*/
|
|
13
50
|
getItem: (key: string) => string | null;
|
|
51
|
+
/**
|
|
52
|
+
* Sets the value associated with the specified key in the store.
|
|
53
|
+
* @param key - The key to set the value for.
|
|
54
|
+
* @param value - The value to set.
|
|
55
|
+
*/
|
|
14
56
|
setItem: (key: string, value: string) => void;
|
|
15
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* A function that serializes a value of type `T` to a string.
|
|
60
|
+
* The default implementation uses `JSON.stringify`.
|
|
61
|
+
*/
|
|
16
62
|
serialize?: (v: T) => string;
|
|
63
|
+
/**
|
|
64
|
+
* A function that deserializes a string to a value of type `T`.
|
|
65
|
+
* The default implementation uses `JSON.parse`.
|
|
66
|
+
*/
|
|
17
67
|
deserialize?: (v: string) => T;
|
|
68
|
+
/**
|
|
69
|
+
* A function that compares two values of type `T` for equality.
|
|
70
|
+
* The default implementation uses strict equality (`===`).
|
|
71
|
+
*/
|
|
18
72
|
equals?: (a: T, b: T) => boolean;
|
|
73
|
+
/**
|
|
74
|
+
* A function that is called when a value is loaded from the store.
|
|
75
|
+
* The default implementation returns the value as is.
|
|
76
|
+
*/
|
|
19
77
|
onLoad?: (value: T) => T;
|
|
20
|
-
}
|
|
21
|
-
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Creates a stored property that persists its value in a storage mechanism.
|
|
81
|
+
*
|
|
82
|
+
* @typeParam T - The type of the property value.
|
|
83
|
+
* @param options - The options for creating the stored property.
|
|
84
|
+
* @returns - The created stored property.
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
export declare const storedProp: <T>({ key, defaultValue, store, serialize, deserialize, equals, onLoad, }: StoredPropOptions<T>) => Prop<T>;
|
|
88
|
+
/**
|
|
89
|
+
* Represents the properties required for storing and retrieving a value of type `T`.
|
|
90
|
+
*
|
|
91
|
+
* @typeParam T - The type of the value to be stored.
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
export type StorageOptions<T> = {
|
|
95
|
+
/**
|
|
96
|
+
* The key to use for storing and retrieving the value.
|
|
97
|
+
*/
|
|
22
98
|
key: string;
|
|
99
|
+
/**
|
|
100
|
+
* The default value to use if the value is not found in the store.
|
|
101
|
+
* This can be a value of type `T` or a function that returns a value of type `T`.
|
|
102
|
+
* If a function is provided, it will be called to get the default value.
|
|
103
|
+
*/
|
|
23
104
|
defaultValue: T | (() => T);
|
|
105
|
+
/**
|
|
106
|
+
* A function that serializes a value of type `T` to a string.
|
|
107
|
+
* The default implementation uses `JSON.stringify`.
|
|
108
|
+
*/
|
|
24
109
|
serialize?: (v: T) => string;
|
|
110
|
+
/**
|
|
111
|
+
* A function that deserializes a string to a value of type `T`.
|
|
112
|
+
* The default implementation uses `JSON.parse`.
|
|
113
|
+
*/
|
|
25
114
|
deserialize?: (v: string) => T;
|
|
115
|
+
/**
|
|
116
|
+
* A function that compares two values of type `T` for equality.
|
|
117
|
+
* The default implementation uses strict equality (`===`).
|
|
118
|
+
*/
|
|
26
119
|
equals?: (a: T, b: T) => boolean;
|
|
120
|
+
/**
|
|
121
|
+
* A function that is called when a value is loaded from the store.
|
|
122
|
+
* The default implementation returns the value as is.
|
|
123
|
+
*/
|
|
27
124
|
onLoad?: (value: T) => T;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Creates a prop that is backed by the localStorage or a MemoryStore.
|
|
128
|
+
*
|
|
129
|
+
* @param options - The options for creating the prop.
|
|
130
|
+
* @returns The created prop.
|
|
131
|
+
* @public
|
|
132
|
+
*/
|
|
133
|
+
export declare const localStorageProp: <T>(options: StorageOptions<T>) => Prop<T>;
|
|
134
|
+
/**
|
|
135
|
+
* Creates a prop that stores its value in the session storage.
|
|
136
|
+
*
|
|
137
|
+
* @param options - The options for the storage prop.
|
|
138
|
+
* @returns A prop that stores its value in the session storage.
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
export declare const sessionStorageProp: <T>(options: StorageOptions<T>) => Prop<T>;
|
|
142
|
+
/**
|
|
143
|
+
* Options for animating signals.
|
|
144
|
+
*
|
|
145
|
+
* @typeParam T - The type of the signal values.
|
|
146
|
+
* @public
|
|
147
|
+
*/
|
|
148
|
+
export type AnimateSignalsOptions<T> = {
|
|
149
|
+
/**
|
|
150
|
+
* The function that interpolates between two values.
|
|
151
|
+
*/
|
|
38
152
|
interpolate?: (start: T, end: T, delta: number) => T;
|
|
153
|
+
/**
|
|
154
|
+
* The duration of the animation in milliseconds.
|
|
155
|
+
*/
|
|
39
156
|
duration?: Value<number>;
|
|
157
|
+
/**
|
|
158
|
+
* The easing function for the animation.
|
|
159
|
+
*/
|
|
40
160
|
easing?: (t: number) => number;
|
|
161
|
+
/**
|
|
162
|
+
* The function that compares two values for equality.
|
|
163
|
+
*/
|
|
41
164
|
equals?: (a: T, b: T) => boolean;
|
|
42
|
-
}
|
|
43
|
-
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Animates signals based on the provided options.
|
|
168
|
+
*
|
|
169
|
+
* @typeParam T - The type of the animated value.
|
|
170
|
+
* @param initialValue - The initial value of the animation.
|
|
171
|
+
* @param fn - A function that returns the end value of the animation.
|
|
172
|
+
* @param dependencies - An array of signals that the animation depends on.
|
|
173
|
+
* @param options - Optional options for the animation.
|
|
174
|
+
* @returns - The animated value as Prop<T>
|
|
175
|
+
* @public
|
|
176
|
+
*/
|
|
177
|
+
export declare const animateSignals: <T>(initialValue: T, fn: () => T, dependencies: Array<AnySignal>, options?: AnimateSignalsOptions<T>) => Prop<T>;
|
|
178
|
+
/**
|
|
179
|
+
* Represents the configuration options for animating a signal.
|
|
180
|
+
*
|
|
181
|
+
* @typeParam T - The type of the signal value.
|
|
182
|
+
* @public
|
|
183
|
+
*/
|
|
184
|
+
export type AnimateSignal<T> = {
|
|
185
|
+
/**
|
|
186
|
+
* The initial value for the animation. If not provided, the current value of the input signal will be used.
|
|
187
|
+
*/
|
|
44
188
|
initialValue?: T;
|
|
189
|
+
/**
|
|
190
|
+
* The interpolation function to use for calculating intermediate values during the animation.
|
|
191
|
+
*/
|
|
45
192
|
interpolate?: (start: T, end: T, delta: number) => T;
|
|
193
|
+
/**
|
|
194
|
+
* The duration of the animation in milliseconds.
|
|
195
|
+
*/
|
|
46
196
|
duration?: number;
|
|
197
|
+
/**
|
|
198
|
+
* The easing function to use for controlling the animation progress.
|
|
199
|
+
*/
|
|
47
200
|
easing?: (t: number) => number;
|
|
201
|
+
/**
|
|
202
|
+
* The equality function to use for comparing signal values.
|
|
203
|
+
*/
|
|
48
204
|
equals?: (a: T, b: T) => boolean;
|
|
49
|
-
}
|
|
50
|
-
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Animates a signal by creating a new signal that transitions from an initial value to the current value of the input signal.
|
|
208
|
+
*
|
|
209
|
+
* @typeParam T - The type of the signal value.
|
|
210
|
+
* @param signal - The input signal to animate.
|
|
211
|
+
* @param options - The animation options.
|
|
212
|
+
* @returns - The animated signal.
|
|
213
|
+
* @public
|
|
214
|
+
*/
|
|
215
|
+
export declare const animateSignal: <T>(signal: Signal<T>, options?: AnimateSignal<T>) => Prop<T>;
|
|
216
|
+
/**
|
|
217
|
+
* Computes a value based on a record of signals and literals.
|
|
218
|
+
*
|
|
219
|
+
* @typeParam T - The type of the record containing signals and literals.
|
|
220
|
+
* @typeParam O - The type of the computed value.
|
|
221
|
+
* @param record - The record containing signals and literals.
|
|
222
|
+
* @param fn - The function to compute the value based on the literals.
|
|
223
|
+
* @returns - The computed value as a signal.
|
|
224
|
+
* @public
|
|
225
|
+
*/
|
|
226
|
+
export declare const makeComputedRecord: <T extends Record<string, Value<unknown>>, O>(record: T, fn: (value: RemoveSignals<T>) => O) => Computed<O>;
|