solid-ctrl-flow 1.0.53 → 1.0.55
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 +14 -8
- package/dist/index.mjs +13 -2
- package/dist/index.umd.js +12 -1
- package/package.json +1 -2
- package/readMe.md +3 -0
package/dist/index.d.ts
CHANGED
|
@@ -14,10 +14,9 @@ declare const BASE_CTOR: new <T>() => Accessor<T>;
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Creates a one-way binding between two {@link Signal}s.
|
|
17
|
-
* The function uses {@link
|
|
17
|
+
* The function uses {@link createComputed}, which means that:
|
|
18
18
|
* - As soon as the function is done executing the two {@link Signal}s will have the same value
|
|
19
|
-
* - If {@link source} changes, {@link dest}
|
|
20
|
-
* - If the current owner gets disposed before {@link dest} is updated, it never will
|
|
19
|
+
* - If {@link source} changes, {@link dest} will be instantly updated
|
|
21
20
|
* @param source The getter of the source of the binding
|
|
22
21
|
* @param dest The setter of the destination of the binding
|
|
23
22
|
* @param to Conversion function from {@link S} to {@link D}
|
|
@@ -46,19 +45,19 @@ export declare function Case(props: ParentProps<{
|
|
|
46
45
|
}>): JSX.Element;
|
|
47
46
|
|
|
48
47
|
export declare function Case(props: ParentProps<{
|
|
49
|
-
pred
|
|
48
|
+
pred(x: any): unknown;
|
|
50
49
|
}>): JSX.Element;
|
|
51
50
|
|
|
52
51
|
export declare function Case<T>(props: {
|
|
53
|
-
pred
|
|
52
|
+
pred(x: any): T;
|
|
54
53
|
keyed?: false;
|
|
55
|
-
children
|
|
54
|
+
children(x: Accessor<NonNullable<T>>): JSX.Element;
|
|
56
55
|
}): JSX.Element;
|
|
57
56
|
|
|
58
57
|
export declare function Case<T>(props: {
|
|
59
|
-
pred
|
|
58
|
+
pred(x: any): T;
|
|
60
59
|
keyed: true;
|
|
61
|
-
children
|
|
60
|
+
children(x: NonNullable<T>): JSX.Element;
|
|
62
61
|
}): JSX.Element;
|
|
63
62
|
|
|
64
63
|
/**
|
|
@@ -142,6 +141,13 @@ export declare function Enfold<T>(props: Unkeyed<T>): JSX.Element;
|
|
|
142
141
|
/** Handy type alias */
|
|
143
142
|
declare type Equals = MemoOptions<unknown>["equals"];
|
|
144
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Creates a {@link Signal} that behaves like the input one, with the only difference that each call to the setter will trigger the effects even if the value didn't change.
|
|
146
|
+
* Can give reactivity to a fake {@link Signal}
|
|
147
|
+
* @param param0 The {@link Signal} to force
|
|
148
|
+
*/
|
|
149
|
+
export declare function forceSignal<T>([get, set]: Signal<T>): Signal<T>;
|
|
150
|
+
|
|
145
151
|
/** Parameters to pass to a keyed {@link Enfold} */
|
|
146
152
|
declare type Keyed<T> = Standard<T> & {
|
|
147
153
|
keyed: true;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useContext, createMemo, createComponent, createContext, createRoot, getOwner, untrack, createEffect, on, createResource, splitProps, Show, onCleanup, For, Match, mergeProps,
|
|
1
|
+
import { useContext, createMemo, createComponent, createContext, createRoot, getOwner, untrack, createEffect, on, createResource, splitProps, Show, onCleanup, For, Match, mergeProps, createComputed, createSignal, getListener } from "solid-js";
|
|
2
2
|
import { createMutable } from "solid-js/store";
|
|
3
3
|
const BASE_CTOR = Function;
|
|
4
4
|
class ReactiveContext extends BASE_CTOR {
|
|
@@ -233,7 +233,7 @@ function Case(props) {
|
|
|
233
233
|
}
|
|
234
234
|
const IDENTITY = (x) => x;
|
|
235
235
|
function bind(source, dest, to = IDENTITY, skip = false) {
|
|
236
|
-
const d = createRoot((d2) => (
|
|
236
|
+
const d = createRoot((d2) => (createComputed(on(source, (x) => skip ? skip = false : dest((prev) => to(x, prev)))), d2));
|
|
237
237
|
return onCleanup(d), d;
|
|
238
238
|
}
|
|
239
239
|
function bindTwoWay(source, dest, to, from) {
|
|
@@ -254,6 +254,16 @@ function toSignal(obj, k) {
|
|
|
254
254
|
function unwrapSignal(f) {
|
|
255
255
|
return [() => f()[0](), (x) => f()[1](x)];
|
|
256
256
|
}
|
|
257
|
+
function forceSignal([get, set]) {
|
|
258
|
+
const [track, update] = createSignal(void 0, { equals: false });
|
|
259
|
+
return [
|
|
260
|
+
() => (track(), get()),
|
|
261
|
+
(x) => {
|
|
262
|
+
const out = set(x);
|
|
263
|
+
return update(), out;
|
|
264
|
+
}
|
|
265
|
+
];
|
|
266
|
+
}
|
|
257
267
|
function coalesceSignal([get, set], f) {
|
|
258
268
|
return [getter, set];
|
|
259
269
|
function getter() {
|
|
@@ -288,6 +298,7 @@ export {
|
|
|
288
298
|
createExtractor,
|
|
289
299
|
createReactiveResource,
|
|
290
300
|
debug,
|
|
301
|
+
forceSignal,
|
|
291
302
|
memoProps,
|
|
292
303
|
runWithContext,
|
|
293
304
|
splitAndMemoProps,
|
package/dist/index.umd.js
CHANGED
|
@@ -235,7 +235,7 @@
|
|
|
235
235
|
}
|
|
236
236
|
const IDENTITY = (x) => x;
|
|
237
237
|
function bind(source, dest, to = IDENTITY, skip = false) {
|
|
238
|
-
const d = solidJs.createRoot((d2) => (solidJs.
|
|
238
|
+
const d = solidJs.createRoot((d2) => (solidJs.createComputed(solidJs.on(source, (x) => skip ? skip = false : dest((prev) => to(x, prev)))), d2));
|
|
239
239
|
return solidJs.onCleanup(d), d;
|
|
240
240
|
}
|
|
241
241
|
function bindTwoWay(source, dest, to, from) {
|
|
@@ -256,6 +256,16 @@
|
|
|
256
256
|
function unwrapSignal(f) {
|
|
257
257
|
return [() => f()[0](), (x) => f()[1](x)];
|
|
258
258
|
}
|
|
259
|
+
function forceSignal([get, set]) {
|
|
260
|
+
const [track, update] = solidJs.createSignal(void 0, { equals: false });
|
|
261
|
+
return [
|
|
262
|
+
() => (track(), get()),
|
|
263
|
+
(x) => {
|
|
264
|
+
const out = set(x);
|
|
265
|
+
return update(), out;
|
|
266
|
+
}
|
|
267
|
+
];
|
|
268
|
+
}
|
|
259
269
|
function coalesceSignal([get, set], f) {
|
|
260
270
|
return [getter, set];
|
|
261
271
|
function getter() {
|
|
@@ -288,6 +298,7 @@
|
|
|
288
298
|
exports2.createExtractor = createExtractor;
|
|
289
299
|
exports2.createReactiveResource = createReactiveResource;
|
|
290
300
|
exports2.debug = debug;
|
|
301
|
+
exports2.forceSignal = forceSignal;
|
|
291
302
|
exports2.memoProps = memoProps;
|
|
292
303
|
exports2.runWithContext = runWithContext;
|
|
293
304
|
exports2.splitAndMemoProps = splitAndMemoProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-ctrl-flow",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.55",
|
|
4
4
|
"description": "Control flow components for solid-js",
|
|
5
5
|
"author": "AFatNiBBa",
|
|
6
6
|
"license": "ISC",
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/node": "^20.6.0",
|
|
19
|
-
"logic-types": "^1.3.2",
|
|
20
19
|
"vite": "^4.4.9",
|
|
21
20
|
"vite-plugin-dts": "^3.5.3",
|
|
22
21
|
"vite-plugin-solid": "^2.7.0"
|
package/readMe.md
CHANGED
|
@@ -179,6 +179,9 @@ Functions that create bindings between `Signal`s
|
|
|
179
179
|
>
|
|
180
180
|
> #### `unwrapSignal()`
|
|
181
181
|
> A `Signal`-specific version of `unwrap()` that allows the destructuring of its result
|
|
182
|
+
>
|
|
183
|
+
> #### `forceSignal()`
|
|
184
|
+
> Creates a `Signal` that behaves like the input one, with the only difference that each call to the setter will trigger the effects even if the value didn't change
|
|
182
185
|
>
|
|
183
186
|
> #### `coalesceSignal()`
|
|
184
187
|
> Creates a non nullable `Signal` from a nullable one
|