@tempots/dom 31.4.0 → 31.5.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 +36 -7
- package/index.cjs +1 -1
- package/index.js +564 -535
- package/package.json +1 -1
- package/std/signal-utils.d.ts +19 -3
package/package.json
CHANGED
package/std/signal-utils.d.ts
CHANGED
|
@@ -30,8 +30,9 @@ export declare class MemoryStore {
|
|
|
30
30
|
export type StoredPropOptions<T> = {
|
|
31
31
|
/**
|
|
32
32
|
* The key to use for storing and retrieving the value.
|
|
33
|
+
* Can be a static string or a reactive signal that changes over time.
|
|
33
34
|
*/
|
|
34
|
-
key: string
|
|
35
|
+
key: Value<string>;
|
|
35
36
|
/**
|
|
36
37
|
* The default value to use if the value is not found in the store.
|
|
37
38
|
* This can be a value of type `T` or a function that returns a value of type `T`.
|
|
@@ -79,6 +80,13 @@ export type StoredPropOptions<T> = {
|
|
|
79
80
|
* Whether to sync the value across tabs. Defaults to `true`.
|
|
80
81
|
*/
|
|
81
82
|
syncTabs?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Strategy for handling key changes when using a reactive key.
|
|
85
|
+
* - 'load' (default): Load value from new key, the current state is already stored at this point
|
|
86
|
+
* - 'migrate': Move current value to new key and continue with current value
|
|
87
|
+
* - 'keep': Keep current value without loading from new key
|
|
88
|
+
*/
|
|
89
|
+
onKeyChange?: 'load' | 'migrate' | 'keep';
|
|
82
90
|
};
|
|
83
91
|
/**
|
|
84
92
|
* Creates a stored property that persists its value in a storage mechanism.
|
|
@@ -88,7 +96,7 @@ export type StoredPropOptions<T> = {
|
|
|
88
96
|
* @returns - The created stored property.
|
|
89
97
|
* @public
|
|
90
98
|
*/
|
|
91
|
-
export declare const storedProp: <T>({ key, defaultValue, store, serialize, deserialize, equals, onLoad, syncTabs, }: StoredPropOptions<T>) => Prop<T>;
|
|
99
|
+
export declare const storedProp: <T>({ key, defaultValue, store, serialize, deserialize, equals, onLoad, syncTabs, onKeyChange, }: StoredPropOptions<T>) => Prop<T>;
|
|
92
100
|
/**
|
|
93
101
|
* Represents the properties required for storing and retrieving a value of type `T`.
|
|
94
102
|
*
|
|
@@ -98,8 +106,9 @@ export declare const storedProp: <T>({ key, defaultValue, store, serialize, dese
|
|
|
98
106
|
export type StorageOptions<T> = {
|
|
99
107
|
/**
|
|
100
108
|
* The key to use for storing and retrieving the value.
|
|
109
|
+
* Can be a static string or a reactive signal that changes over time.
|
|
101
110
|
*/
|
|
102
|
-
key: string
|
|
111
|
+
key: Value<string>;
|
|
103
112
|
/**
|
|
104
113
|
* The default value to use if the value is not found in the store.
|
|
105
114
|
* This can be a value of type `T` or a function that returns a value of type `T`.
|
|
@@ -130,6 +139,13 @@ export type StorageOptions<T> = {
|
|
|
130
139
|
* Whether to sync the value across tabs. Defaults to `true`.
|
|
131
140
|
*/
|
|
132
141
|
syncTabs?: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Strategy for handling key changes when using a reactive key.
|
|
144
|
+
* - 'load' (default): Load value from new key, the current state is already stored at this point
|
|
145
|
+
* - 'migrate': Move current value to new key and continue with current value
|
|
146
|
+
* - 'keep': Keep current value without loading from new key
|
|
147
|
+
*/
|
|
148
|
+
onKeyChange?: 'load' | 'migrate' | 'keep';
|
|
133
149
|
};
|
|
134
150
|
/**
|
|
135
151
|
* Creates a prop that is backed by the localStorage or a MemoryStore.
|