solid-ctrl-flow 1.0.47 → 1.0.49
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 -11
- package/dist/index.mjs +2 -4
- package/dist/index.umd.js +2 -4
- package/package.json +1 -1
- package/readMe.md +3 -6
package/dist/index.d.ts
CHANGED
|
@@ -127,14 +127,6 @@ export declare function createReactiveResource<R>(f: EffectFunction<R | undefine
|
|
|
127
127
|
/** Built-in {@link ReactiveContext} which allows you to display different things in debug mode */
|
|
128
128
|
export declare const debug: ReactiveContext<boolean>;
|
|
129
129
|
|
|
130
|
-
/**
|
|
131
|
-
* Utility function that makes you use an {@link Accessor} of a {@link JSX.Element} as a {@link JSX.Element} itself.
|
|
132
|
-
* Used to defer the execution of {@link f} until it gets rendered.
|
|
133
|
-
* Using {@link Function}s as {@link JSX.Element} is supported by default but is forbidden by the types
|
|
134
|
-
* @param f The {@link Accessor} to the actual content
|
|
135
|
-
*/
|
|
136
|
-
export declare const deferCall: (f: Accessor<JSX.Element>) => JSX.Element;
|
|
137
|
-
|
|
138
130
|
/**
|
|
139
131
|
* Eventually wraps its content into a template if a certain condition is met.
|
|
140
132
|
* The content is memoized in the beginning and will be recycled even if the wrapper changes.
|
|
@@ -175,7 +167,7 @@ export declare function memoProps<T, K extends readonly (keyof T)[]>(obj: T, key
|
|
|
175
167
|
* Example:
|
|
176
168
|
* ```tsx
|
|
177
169
|
* return <>
|
|
178
|
-
* <Nest each={[ 1, 2, 3 ]} template={(c, x) => <>({x}, {c}, -{x})</>}>
|
|
170
|
+
* <Nest each={[ 1, 2, 3 ]} template={(c, x) => <>({x}, {c()}, -{x})</>}>
|
|
179
171
|
* CONTENT
|
|
180
172
|
* </Nest>
|
|
181
173
|
* </>
|
|
@@ -184,7 +176,7 @@ export declare function memoProps<T, K extends readonly (keyof T)[]>(obj: T, key
|
|
|
184
176
|
*/
|
|
185
177
|
export declare function Nest<T>(props: ParentProps<{
|
|
186
178
|
each: readonly T[] | undefined;
|
|
187
|
-
template: (c: JSX.Element
|
|
179
|
+
template: (c: Accessor<JSX.Element>, x: T, i: Accessor<number>) => JSX.Element;
|
|
188
180
|
}>): JSX.Element;
|
|
189
181
|
|
|
190
182
|
/**
|
|
@@ -319,7 +311,7 @@ declare type Standard<T> = ParentProps<{
|
|
|
319
311
|
}>;
|
|
320
312
|
|
|
321
313
|
/** Type of an element wrapping call-back which accepts an additional parameter */
|
|
322
|
-
declare type Template<T> = (c: JSX.Element
|
|
314
|
+
declare type Template<T> = (c: Accessor<JSX.Element>, x: T) => JSX.Element;
|
|
323
315
|
|
|
324
316
|
/**
|
|
325
317
|
* Creates a full-fledged solid {@link Setter} from a normal one
|
package/dist/index.mjs
CHANGED
|
@@ -64,7 +64,6 @@ function runWithContext(ctx2, value, f) {
|
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
-
const deferCall = (f) => f;
|
|
68
67
|
function untrackCall(f, ...args) {
|
|
69
68
|
return untrack(() => f.apply(this, args));
|
|
70
69
|
}
|
|
@@ -107,7 +106,7 @@ function Enfold(props) {
|
|
|
107
106
|
get fallback() {
|
|
108
107
|
return children();
|
|
109
108
|
},
|
|
110
|
-
children: (x) => createMemo(() => untrackCall(props.template,
|
|
109
|
+
children: (x) => createMemo(() => untrackCall(props.template, children, x))
|
|
111
110
|
});
|
|
112
111
|
}
|
|
113
112
|
var Slot;
|
|
@@ -222,7 +221,7 @@ function Nest(props) {
|
|
|
222
221
|
const memo = memoProps(props, ["template", "children"]);
|
|
223
222
|
const content = mapArray(() => props.each, (x, i) => {
|
|
224
223
|
const [get, set] = createSignal();
|
|
225
|
-
const out = createMemo(() => untrackCall(memo.template,
|
|
224
|
+
const out = createMemo(() => untrackCall(memo.template, get, x, i));
|
|
226
225
|
return (x2) => {
|
|
227
226
|
onMount(() => set(() => x2));
|
|
228
227
|
onCleanup(() => set(void 0));
|
|
@@ -303,7 +302,6 @@ export {
|
|
|
303
302
|
createExtractor,
|
|
304
303
|
createReactiveResource,
|
|
305
304
|
debug,
|
|
306
|
-
deferCall,
|
|
307
305
|
memoProps,
|
|
308
306
|
runWithContext,
|
|
309
307
|
splitAndMemoProps,
|
package/dist/index.umd.js
CHANGED
|
@@ -66,7 +66,6 @@
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
-
const deferCall = (f) => f;
|
|
70
69
|
function untrackCall(f, ...args) {
|
|
71
70
|
return solidJs.untrack(() => f.apply(this, args));
|
|
72
71
|
}
|
|
@@ -109,7 +108,7 @@
|
|
|
109
108
|
get fallback() {
|
|
110
109
|
return children();
|
|
111
110
|
},
|
|
112
|
-
children: (x) => solidJs.createMemo(() => untrackCall(props.template,
|
|
111
|
+
children: (x) => solidJs.createMemo(() => untrackCall(props.template, children, x))
|
|
113
112
|
});
|
|
114
113
|
}
|
|
115
114
|
exports2.Slot = void 0;
|
|
@@ -224,7 +223,7 @@
|
|
|
224
223
|
const memo = memoProps(props, ["template", "children"]);
|
|
225
224
|
const content = solidJs.mapArray(() => props.each, (x, i) => {
|
|
226
225
|
const [get, set] = solidJs.createSignal();
|
|
227
|
-
const out = solidJs.createMemo(() => untrackCall(memo.template,
|
|
226
|
+
const out = solidJs.createMemo(() => untrackCall(memo.template, get, x, i));
|
|
228
227
|
return (x2) => {
|
|
229
228
|
solidJs.onMount(() => set(() => x2));
|
|
230
229
|
solidJs.onCleanup(() => set(void 0));
|
|
@@ -303,7 +302,6 @@
|
|
|
303
302
|
exports2.createExtractor = createExtractor;
|
|
304
303
|
exports2.createReactiveResource = createReactiveResource;
|
|
305
304
|
exports2.debug = debug;
|
|
306
|
-
exports2.deferCall = deferCall;
|
|
307
305
|
exports2.memoProps = memoProps;
|
|
308
306
|
exports2.runWithContext = runWithContext;
|
|
309
307
|
exports2.splitAndMemoProps = splitAndMemoProps;
|
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}</div>}>
|
|
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}</div>}>
|
|
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,9 +234,6 @@ return <>
|
|
|
234
234
|
</>
|
|
235
235
|
```
|
|
236
236
|
|
|
237
|
-
### `deferCall()`
|
|
238
|
-
Utility function that makes you use an `Accessor` of a `JSX.Element` as a `JSX.Element` itself
|
|
239
|
-
|
|
240
237
|
### `untrackCall()`
|
|
241
238
|
Calls a function untracking what happens inside of it but not what gets passed as its argument
|
|
242
239
|
|