solid-ctrl-flow 1.0.22 → 1.0.24
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 +9 -3
- package/dist/index.mjs +15 -11
- package/dist/index.umd.js +14 -10
- package/package.json +1 -1
- package/readMe.md +8 -6
package/dist/index.d.ts
CHANGED
|
@@ -184,10 +184,10 @@ export declare function toSetter<T>(get: Accessor<T>, set: (x: T) => void): Sett
|
|
|
184
184
|
|
|
185
185
|
/**
|
|
186
186
|
* Creates a {@link Signal} from a property access
|
|
187
|
-
* @param obj The object from which to get the property
|
|
188
|
-
* @param k The key of the property
|
|
187
|
+
* @param obj The {@link Accessor} to the object from which to get the property
|
|
188
|
+
* @param k The {@link Accessor} to the key of the property
|
|
189
189
|
*/
|
|
190
|
-
export declare function toSignal<T, K extends keyof T>(obj: T
|
|
190
|
+
export declare function toSignal<T, K extends keyof T>(obj: Accessor<T>, k: Accessor<K>): Signal<T[K]>;
|
|
191
191
|
|
|
192
192
|
/**
|
|
193
193
|
* Executes {@link f} untracking it.
|
|
@@ -199,6 +199,12 @@ export declare function toSignal<T, K extends keyof T>(obj: T, k: K): Signal<T[K
|
|
|
199
199
|
*/
|
|
200
200
|
export declare function untrackCall<F extends (...args: any[]) => any>(this: ThisParameterType<F>, f: F, ...args: Parameters<F>): any;
|
|
201
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Calls {@link f} maintaining its reactivity
|
|
204
|
+
* @param f An {@link Accessor} to a {@link Signal}
|
|
205
|
+
*/
|
|
206
|
+
export declare function unwrapSignal<T>(f: Accessor<Signal<T>>): Signal<T>;
|
|
207
|
+
|
|
202
208
|
/** Like a {@link Match} but gets the value from the closest {@link Case} ancestor */
|
|
203
209
|
export declare function When(props: {
|
|
204
210
|
value: unknown;
|
package/dist/index.mjs
CHANGED
|
@@ -59,16 +59,6 @@ function runWithContext(ctx2, value, f) {
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
const IDENTITY = (x) => x;
|
|
62
|
-
function toSetter(get, set) {
|
|
63
|
-
return (x) => {
|
|
64
|
-
const out = typeof x === "function" ? x(untrack(get)) : x;
|
|
65
|
-
return set(out), out;
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
function toSignal(obj, k) {
|
|
69
|
-
const get = () => obj[k];
|
|
70
|
-
return [get, toSetter(get, (v) => obj[k] = v)];
|
|
71
|
-
}
|
|
72
62
|
function bind(source, dest, to = IDENTITY) {
|
|
73
63
|
const d = createRoot((d2) => (createEffect(on(source[0], (x) => dest[1]((prev) => to(x, prev)))), d2));
|
|
74
64
|
return onCleanup(d), d;
|
|
@@ -78,6 +68,19 @@ function bindTwoWay(source, dest, to = IDENTITY, from = IDENTITY) {
|
|
|
78
68
|
const b = bind(dest, source, from);
|
|
79
69
|
return () => (a(), b());
|
|
80
70
|
}
|
|
71
|
+
function toSetter(get, set) {
|
|
72
|
+
return (x) => {
|
|
73
|
+
const out = typeof x === "function" ? x(untrack(get)) : x;
|
|
74
|
+
return set(out), out;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function toSignal(obj, k) {
|
|
78
|
+
const get = () => obj()[k()];
|
|
79
|
+
return [get, toSetter(get, (v) => obj()[k()] = v)];
|
|
80
|
+
}
|
|
81
|
+
function unwrapSignal(f) {
|
|
82
|
+
return [() => f()[0](), (x) => f()[1](x)];
|
|
83
|
+
}
|
|
81
84
|
const ctx = createContext(() => void 0, {
|
|
82
85
|
name: "case-when"
|
|
83
86
|
});
|
|
@@ -188,5 +191,6 @@ export {
|
|
|
188
191
|
splitAndMemoProps,
|
|
189
192
|
toSetter,
|
|
190
193
|
toSignal,
|
|
191
|
-
untrackCall
|
|
194
|
+
untrackCall,
|
|
195
|
+
unwrapSignal
|
|
192
196
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -61,16 +61,6 @@
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
const IDENTITY = (x) => x;
|
|
64
|
-
function toSetter(get, set) {
|
|
65
|
-
return (x) => {
|
|
66
|
-
const out = typeof x === "function" ? x(solidJs.untrack(get)) : x;
|
|
67
|
-
return set(out), out;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function toSignal(obj, k) {
|
|
71
|
-
const get = () => obj[k];
|
|
72
|
-
return [get, toSetter(get, (v) => obj[k] = v)];
|
|
73
|
-
}
|
|
74
64
|
function bind(source, dest, to = IDENTITY) {
|
|
75
65
|
const d = solidJs.createRoot((d2) => (solidJs.createEffect(solidJs.on(source[0], (x) => dest[1]((prev) => to(x, prev)))), d2));
|
|
76
66
|
return solidJs.onCleanup(d), d;
|
|
@@ -80,6 +70,19 @@
|
|
|
80
70
|
const b = bind(dest, source, from);
|
|
81
71
|
return () => (a(), b());
|
|
82
72
|
}
|
|
73
|
+
function toSetter(get, set) {
|
|
74
|
+
return (x) => {
|
|
75
|
+
const out = typeof x === "function" ? x(solidJs.untrack(get)) : x;
|
|
76
|
+
return set(out), out;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function toSignal(obj, k) {
|
|
80
|
+
const get = () => obj()[k()];
|
|
81
|
+
return [get, toSetter(get, (v) => obj()[k()] = v)];
|
|
82
|
+
}
|
|
83
|
+
function unwrapSignal(f) {
|
|
84
|
+
return [() => f()[0](), (x) => f()[1](x)];
|
|
85
|
+
}
|
|
83
86
|
const ctx = solidJs.createContext(() => void 0, {
|
|
84
87
|
name: "case-when"
|
|
85
88
|
});
|
|
@@ -190,5 +193,6 @@
|
|
|
190
193
|
exports2.toSetter = toSetter;
|
|
191
194
|
exports2.toSignal = toSignal;
|
|
192
195
|
exports2.untrackCall = untrackCall;
|
|
196
|
+
exports2.unwrapSignal = unwrapSignal;
|
|
193
197
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
194
198
|
});
|
package/package.json
CHANGED
package/readMe.md
CHANGED
|
@@ -124,18 +124,20 @@ return <>Something else</>
|
|
|
124
124
|
## Bindings
|
|
125
125
|
Functions that create bindings between `Signal`s
|
|
126
126
|
|
|
127
|
-
### `toSetter()`
|
|
128
|
-
Creates a full-fledged solid `Setter` from a normal one
|
|
129
|
-
|
|
130
|
-
### `toSignal()`
|
|
131
|
-
Creates a `Signal` from a property of an object
|
|
132
|
-
|
|
133
127
|
### `bind()`
|
|
134
128
|
Creates a one-way binding between two `Signal`s
|
|
135
129
|
|
|
136
130
|
### `bindTwoWay()`
|
|
137
131
|
Creates a two-way binding between two `Signal`s
|
|
138
132
|
|
|
133
|
+
### `toSetter()`
|
|
134
|
+
Creates a full-fledged solid `Setter` from a normal one
|
|
135
|
+
|
|
136
|
+
### `toSignal()`
|
|
137
|
+
Creates a `Signal` from a property of an object
|
|
138
|
+
|
|
139
|
+
### `unwrapSignal()`
|
|
140
|
+
Calls an `Accessor` to a `Signal` maintaining its reactivity
|
|
139
141
|
|
|
140
142
|
## Utility functions
|
|
141
143
|
Utility functions needed for the components above
|