@tempots/dom 18.0.0 → 19.1.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.
Files changed (49) hide show
  1. package/dom/animatable.d.ts +12 -12
  2. package/dom/attr.d.ts +14 -7
  3. package/dom/dom-context.d.ts +47 -2
  4. package/dom/dom-utils.d.ts +6 -3
  5. package/dom/handle-anchor-click.d.ts +13 -2
  6. package/dom/ssr.d.ts +48 -16
  7. package/index.cjs +1 -1
  8. package/index.js +1000 -755
  9. package/package.json +1 -1
  10. package/renderable/async.d.ts +33 -3
  11. package/renderable/attribute.d.ts +24 -7
  12. package/renderable/bind.d.ts +43 -13
  13. package/renderable/conjunction.d.ts +23 -4
  14. package/renderable/consumers.d.ts +54 -1
  15. package/renderable/domnode.d.ts +10 -2
  16. package/renderable/element.d.ts +50 -3
  17. package/renderable/empty.d.ts +5 -0
  18. package/renderable/ensure.d.ts +10 -0
  19. package/renderable/foreach.d.ts +12 -2
  20. package/renderable/fragment.d.ts +11 -0
  21. package/renderable/handler.d.ts +64 -10
  22. package/renderable/map-signal.d.ts +15 -0
  23. package/renderable/not-empty.d.ts +13 -1
  24. package/renderable/onctx.d.ts +9 -2
  25. package/renderable/oneof.d.ts +138 -16
  26. package/renderable/onmount.d.ts +8 -0
  27. package/renderable/onunmount.d.ts +6 -0
  28. package/renderable/portal.d.ts +12 -3
  29. package/renderable/providers.d.ts +39 -6
  30. package/renderable/render.d.ts +39 -3
  31. package/renderable/repeat.d.ts +11 -2
  32. package/renderable/style.d.ts +4 -0
  33. package/renderable/task.d.ts +18 -2
  34. package/renderable/text.d.ts +16 -3
  35. package/renderable/when.d.ts +21 -3
  36. package/std/interpolate.d.ts +56 -5
  37. package/std/position.d.ts +46 -2
  38. package/std/signal-utils.d.ts +195 -19
  39. package/std/signal.d.ts +401 -30
  40. package/types/aria-attributes.d.ts +5 -0
  41. package/types/css-styles.d.ts +11 -0
  42. package/types/domain.d.ts +62 -2
  43. package/types/html-attributes.d.ts +10 -0
  44. package/types/html-events.d.ts +5 -0
  45. package/types/html-tags.d.ts +5 -0
  46. package/types/mathml-attributes.d.ts +5 -0
  47. package/types/mathml-tags.d.ts +4 -0
  48. package/types/svg-attributes.d.ts +5 -0
  49. package/types/svg-tags.d.ts +5 -0
@@ -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
- getItem: (key: string) => string | null;
7
- setItem: (key: string, value: string) => void;
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
- export declare function storedProp<T>({ key, defaultValue, store, serialize, deserialize, equals, onLoad, }: {
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
- }): Prop<T>;
21
- export declare function localStorageProp<T>(options: {
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
- }): Prop<T>;
29
- export declare function sessionStorageProp<T>(options: {
30
- key: string;
31
- defaultValue: T | (() => T);
32
- serialize?: (v: T) => string;
33
- deserialize?: (v: string) => T;
34
- equals?: (a: T, b: T) => boolean;
35
- onLoad?: (value: T) => T;
36
- }): Prop<T>;
37
- export declare function animateSignals<T>(initialValue: T, fn: () => T, dependencies: Array<AnySignal>, options?: {
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
- }): Prop<T>;
43
- export declare function animateSignal<T>(signal: Signal<T>, options?: {
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
- }): Prop<T>;
50
- export declare function computedRecord<T extends Record<string, Value<unknown>>, U>(record: T, fn: (value: RemoveSignals<T>) => U): Computed<U>;
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>;