solid-ctrl-flow 1.0.31 → 1.0.32

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 CHANGED
@@ -172,6 +172,13 @@ declare type Info = {
172
172
  */
173
173
  export declare function memoProps<T, K extends readonly (keyof T)[] = (keyof T)[]>(obj: T, keys?: K): Pick<T, K[number]>;
174
174
 
175
+ /** Like a {@link Suspence}, but enables you to turn it off and show the loading state */
176
+ export declare function OptionalSuspense(props: {
177
+ active: boolean;
178
+ children: JSX.Element;
179
+ fallback?: JSX.Element;
180
+ }): JSX.Element;
181
+
175
182
  /**
176
183
  * Executes a {@link Ref}.
177
184
  * Throws a {@link ReferenceError} if {@link ref} its not a function at runtime (Which should never be the case thanks to the solid compiler)
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { untrack, createMemo, splitProps, createContext, createRoot, createEffect, on, createResource, createComponent, useContext, getOwner, createRenderEffect, onCleanup, Match, mergeProps, For, Show } from "solid-js";
1
+ import { untrack, createMemo, splitProps, createContext, createRoot, createEffect, on, createResource, createComponent, useContext, getOwner, createRenderEffect, onCleanup, Match, mergeProps, For, Show, Suspense } from "solid-js";
2
2
  import { createMutable } from "solid-js/store";
3
3
  function untrackCall(f, ...args) {
4
4
  return untrack(() => f.apply(this, args));
@@ -189,9 +189,30 @@ function Joint(props) {
189
189
  });
190
190
  }
191
191
  const Debug = createOption(false, true, "debug-scope");
192
+ function OptionalSuspense(props) {
193
+ return createComponent(Show, {
194
+ get when() {
195
+ return props.active;
196
+ },
197
+ get fallback() {
198
+ return props.children;
199
+ },
200
+ get children() {
201
+ return createComponent(Suspense, {
202
+ get fallback() {
203
+ return props.fallback;
204
+ },
205
+ get children() {
206
+ return props.children;
207
+ }
208
+ });
209
+ }
210
+ });
211
+ }
192
212
  export {
193
213
  Case,
194
214
  Debug,
215
+ OptionalSuspense,
195
216
  When,
196
217
  bind,
197
218
  bindTwoWay,
package/dist/index.umd.js CHANGED
@@ -191,8 +191,29 @@
191
191
  });
192
192
  }
193
193
  const Debug = createOption(false, true, "debug-scope");
194
+ function OptionalSuspense(props) {
195
+ return solidJs.createComponent(solidJs.Show, {
196
+ get when() {
197
+ return props.active;
198
+ },
199
+ get fallback() {
200
+ return props.children;
201
+ },
202
+ get children() {
203
+ return solidJs.createComponent(solidJs.Suspense, {
204
+ get fallback() {
205
+ return props.fallback;
206
+ },
207
+ get children() {
208
+ return props.children;
209
+ }
210
+ });
211
+ }
212
+ });
213
+ }
194
214
  exports2.Case = Case;
195
215
  exports2.Debug = Debug;
216
+ exports2.OptionalSuspense = OptionalSuspense;
196
217
  exports2.When = When;
197
218
  exports2.bind = bind;
198
219
  exports2.bindTwoWay = bindTwoWay;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-ctrl-flow",
3
- "version": "1.0.31",
3
+ "version": "1.0.32",
4
4
  "description": "Control flow components for solid-js",
5
5
  "author": "AFatNiBBa",
6
6
  "license": "ISC",
package/readMe.md CHANGED
@@ -47,6 +47,9 @@ return <>
47
47
  </>
48
48
  ```
49
49
 
50
+ ### `OptionalSuspense`
51
+ Like a `Suspence`, but enables you to turn it off and show the loading state
52
+
50
53
  ### `createExtractor()`
51
54
  Creates a context for components that may need to be out of their parent in certain conditions.
52
55
  If you have this component