solid-ctrl-flow 1.0.46 → 1.0.48
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 +3 -3
- package/dist/index.mjs +13 -13
- package/dist/index.umd.js +12 -12
- package/package.json +1 -1
- package/readMe.md +10 -10
package/dist/index.d.ts
CHANGED
|
@@ -167,7 +167,7 @@ export declare function memoProps<T, K extends readonly (keyof T)[]>(obj: T, key
|
|
|
167
167
|
* Example:
|
|
168
168
|
* ```tsx
|
|
169
169
|
* return <>
|
|
170
|
-
* <Nest each={[ 1, 2, 3 ]} template={(c, x) => <>({x}, {c
|
|
170
|
+
* <Nest each={[ 1, 2, 3 ]} template={(c, x) => <>({x}, {c}, -{x})</>}>
|
|
171
171
|
* CONTENT
|
|
172
172
|
* </Nest>
|
|
173
173
|
* </>
|
|
@@ -176,7 +176,7 @@ export declare function memoProps<T, K extends readonly (keyof T)[]>(obj: T, key
|
|
|
176
176
|
*/
|
|
177
177
|
export declare function Nest<T>(props: ParentProps<{
|
|
178
178
|
each: readonly T[] | undefined;
|
|
179
|
-
template: (c:
|
|
179
|
+
template: (c: JSX.Element, x: T, i: Accessor<number>) => JSX.Element;
|
|
180
180
|
}>): JSX.Element;
|
|
181
181
|
|
|
182
182
|
/**
|
|
@@ -311,7 +311,7 @@ declare type Standard<T> = ParentProps<{
|
|
|
311
311
|
}>;
|
|
312
312
|
|
|
313
313
|
/** Type of an element wrapping call-back which accepts an additional parameter */
|
|
314
|
-
declare type Template<T> = (c:
|
|
314
|
+
declare type Template<T> = (c: JSX.Element, x: T) => JSX.Element;
|
|
315
315
|
|
|
316
316
|
/**
|
|
317
317
|
* Creates a full-fledged solid {@link Setter} from a normal one
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useContext, createMemo, createComponent, createContext, createRoot, getOwner,
|
|
1
|
+
import { useContext, createMemo, createComponent, createContext, createRoot, getOwner, untrack, createEffect, on, createResource, splitProps, Show, onCleanup, For, mapArray, createSignal, onMount, Match, mergeProps, createRenderEffect, 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 {
|
|
@@ -64,6 +64,16 @@ function runWithContext(ctx2, value, f) {
|
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
+
function untrackCall(f, ...args) {
|
|
68
|
+
return untrack(() => f.apply(this, args));
|
|
69
|
+
}
|
|
70
|
+
function createReactiveResource(f) {
|
|
71
|
+
var refetch;
|
|
72
|
+
const memo = createMemo(f);
|
|
73
|
+
createEffect(on(memo, () => refetch?.()));
|
|
74
|
+
const [get] = [, { refetch }] = createResource(memo);
|
|
75
|
+
return get;
|
|
76
|
+
}
|
|
67
77
|
function memoProps(obj, keys = Object.keys(obj), equals = false) {
|
|
68
78
|
const out = {};
|
|
69
79
|
for (const elm of keys)
|
|
@@ -75,16 +85,6 @@ function splitAndMemoProps(obj, keys, equals) {
|
|
|
75
85
|
out[0] = memoProps(out[0], keys, equals);
|
|
76
86
|
return out;
|
|
77
87
|
}
|
|
78
|
-
function createReactiveResource(f) {
|
|
79
|
-
var refetch;
|
|
80
|
-
const memo = createMemo(f);
|
|
81
|
-
createEffect(on(memo, () => refetch?.()));
|
|
82
|
-
const [get] = [, { refetch }] = createResource(memo);
|
|
83
|
-
return get;
|
|
84
|
-
}
|
|
85
|
-
function untrackCall(f, ...args) {
|
|
86
|
-
return untrack(() => f.apply(this, args));
|
|
87
|
-
}
|
|
88
88
|
const unwrap = (f) => new Proxy(f, HANDLER);
|
|
89
89
|
const HANDLER = new Proxy({}, {
|
|
90
90
|
get(cache, k) {
|
|
@@ -106,7 +106,7 @@ function Enfold(props) {
|
|
|
106
106
|
get fallback() {
|
|
107
107
|
return children();
|
|
108
108
|
},
|
|
109
|
-
children: (x) => createMemo(() => untrackCall(props.template, children, x))
|
|
109
|
+
children: (x) => createMemo(() => untrackCall(props.template, createMemo(children), x))
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
var Slot;
|
|
@@ -221,7 +221,7 @@ function Nest(props) {
|
|
|
221
221
|
const memo = memoProps(props, ["template", "children"]);
|
|
222
222
|
const content = mapArray(() => props.each, (x, i) => {
|
|
223
223
|
const [get, set] = createSignal();
|
|
224
|
-
const out = createMemo(() => untrackCall(memo.template, get, x, i));
|
|
224
|
+
const out = createMemo(() => untrackCall(memo.template, createMemo(get), x, i));
|
|
225
225
|
return (x2) => {
|
|
226
226
|
onMount(() => set(() => x2));
|
|
227
227
|
onCleanup(() => set(void 0));
|
package/dist/index.umd.js
CHANGED
|
@@ -66,6 +66,16 @@
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
+
function untrackCall(f, ...args) {
|
|
70
|
+
return solidJs.untrack(() => f.apply(this, args));
|
|
71
|
+
}
|
|
72
|
+
function createReactiveResource(f) {
|
|
73
|
+
var refetch;
|
|
74
|
+
const memo = solidJs.createMemo(f);
|
|
75
|
+
solidJs.createEffect(solidJs.on(memo, () => refetch?.()));
|
|
76
|
+
const [get] = [, { refetch }] = solidJs.createResource(memo);
|
|
77
|
+
return get;
|
|
78
|
+
}
|
|
69
79
|
function memoProps(obj, keys = Object.keys(obj), equals = false) {
|
|
70
80
|
const out = {};
|
|
71
81
|
for (const elm of keys)
|
|
@@ -77,16 +87,6 @@
|
|
|
77
87
|
out[0] = memoProps(out[0], keys, equals);
|
|
78
88
|
return out;
|
|
79
89
|
}
|
|
80
|
-
function createReactiveResource(f) {
|
|
81
|
-
var refetch;
|
|
82
|
-
const memo = solidJs.createMemo(f);
|
|
83
|
-
solidJs.createEffect(solidJs.on(memo, () => refetch?.()));
|
|
84
|
-
const [get] = [, { refetch }] = solidJs.createResource(memo);
|
|
85
|
-
return get;
|
|
86
|
-
}
|
|
87
|
-
function untrackCall(f, ...args) {
|
|
88
|
-
return solidJs.untrack(() => f.apply(this, args));
|
|
89
|
-
}
|
|
90
90
|
const unwrap = (f) => new Proxy(f, HANDLER);
|
|
91
91
|
const HANDLER = new Proxy({}, {
|
|
92
92
|
get(cache, k) {
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
get fallback() {
|
|
109
109
|
return children();
|
|
110
110
|
},
|
|
111
|
-
children: (x) => solidJs.createMemo(() => untrackCall(props.template, children, x))
|
|
111
|
+
children: (x) => solidJs.createMemo(() => untrackCall(props.template, solidJs.createMemo(children), x))
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
exports2.Slot = void 0;
|
|
@@ -223,7 +223,7 @@
|
|
|
223
223
|
const memo = memoProps(props, ["template", "children"]);
|
|
224
224
|
const content = solidJs.mapArray(() => props.each, (x, i) => {
|
|
225
225
|
const [get, set] = solidJs.createSignal();
|
|
226
|
-
const out = solidJs.createMemo(() => untrackCall(memo.template, get, x, i));
|
|
226
|
+
const out = solidJs.createMemo(() => untrackCall(memo.template, solidJs.createMemo(get), x, i));
|
|
227
227
|
return (x2) => {
|
|
228
228
|
solidJs.onMount(() => set(() => x2));
|
|
229
229
|
solidJs.onCleanup(() => set(void 0));
|
package/package.json
CHANGED
package/readMe.md
CHANGED
|
@@ -22,7 +22,7 @@ The following code
|
|
|
22
22
|
```tsx
|
|
23
23
|
const value = true;
|
|
24
24
|
return <>
|
|
25
|
-
<Enfold when={value} template={c => <div style={{ background: "red" }}>{c
|
|
25
|
+
<Enfold when={value} template={c => <div style={{ background: "red" }}>{c}</div>}>
|
|
26
26
|
CONTENT
|
|
27
27
|
</Enfold>
|
|
28
28
|
</>
|
|
@@ -42,7 +42,7 @@ return <>CONTENT</>
|
|
|
42
42
|
If you are wrapping the content with a context provider you need to set the `unrecycled` attribute to `true` to run again the whole content, otherwise the `Owner` of the content won't be child of the template one
|
|
43
43
|
```tsx
|
|
44
44
|
return <>
|
|
45
|
-
<Enfold unrecycled when={value} template={c => <ctx.Provider value={2} children={c
|
|
45
|
+
<Enfold unrecycled when={value} template={c => <ctx.Provider value={2} children={c} />}>
|
|
46
46
|
{useContext(ctx)}
|
|
47
47
|
</Enfold>
|
|
48
48
|
</>
|
|
@@ -53,7 +53,7 @@ Like a `For`, but instead of putting an element after another it nests them.
|
|
|
53
53
|
The following code
|
|
54
54
|
```tsx
|
|
55
55
|
return <>
|
|
56
|
-
<Nest each={[ "red", "green", "blue" ]} template={(c, x) => <div style={{ background: x, padding: "1ch" }}>{c
|
|
56
|
+
<Nest each={[ "red", "green", "blue" ]} template={(c, x) => <div style={{ background: x, padding: "1ch" }}>{c}</div>}>
|
|
57
57
|
CONTENT
|
|
58
58
|
</Nest>
|
|
59
59
|
</>
|
|
@@ -234,14 +234,14 @@ return <>
|
|
|
234
234
|
</>
|
|
235
235
|
```
|
|
236
236
|
|
|
237
|
-
### `
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
### `splitAndMemoProps()`
|
|
241
|
-
Like `splitProps()` but memoizes the whole local part
|
|
237
|
+
### `untrackCall()`
|
|
238
|
+
Calls a function untracking what happens inside of it but not what gets passed as its argument
|
|
242
239
|
|
|
243
240
|
### `createReactiveResource()`
|
|
244
241
|
Like `createResource()` but the provided function will be reactive
|
|
245
242
|
|
|
246
|
-
### `
|
|
247
|
-
|
|
243
|
+
### `memoProps()`
|
|
244
|
+
Creates a partial version of an object with memoized remaining properties
|
|
245
|
+
|
|
246
|
+
### `splitAndMemoProps()`
|
|
247
|
+
Like `splitProps()` but memoizes the whole local part
|