solid-ctrl-flow 1.0.1 → 1.0.3

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/flow.d.ts CHANGED
@@ -70,9 +70,9 @@ export declare function createExtractor(name?: string): {
70
70
  }) => JSX.Element;
71
71
  /**
72
72
  * Gets an {@link Accessor} that tells if the context in which THIS getter has been executed has been extracted (Is inside of a {@link Dest})
73
- * @returns Returns `null` if there is no parent {@link Joint}, `false` if there is a {@link Joint} but not a {@link Dest} and `true` otherwise
73
+ * @returns Returns `null` if there is no parent {@link Joint}, the number of {@link Dest}s in which this component is being displayed otherwise (Usually 1)
74
74
  */
75
- readonly isExtracted: () => boolean | null;
75
+ readonly isExtracted: () => number | null;
76
76
  };
77
77
 
78
78
  /** Sets the value that will be returned by {@link Debug.isDebug} for the children of the current component */
package/dist/flow.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { createContext, createMemo, createComponent, useContext, Match, mergeProps, onCleanup, children, Show, splitProps } from "solid-js";
1
+ import { createContext, createMemo, createComponent, useContext, Match, mergeProps, onCleanup, Show, splitProps } from "solid-js";
2
2
  import { createMutable } from "solid-js/store";
3
3
  const ctx$1 = createContext(() => void 0, {
4
4
  name: "case-when"
@@ -51,7 +51,7 @@ function createExtractor(name = "extractor") {
51
51
  Joint: Joint.bind(ctx2),
52
52
  /**
53
53
  * Gets an {@link Accessor} that tells if the context in which THIS getter has been executed has been extracted (Is inside of a {@link Dest})
54
- * @returns Returns `null` if there is no parent {@link Joint}, `false` if there is a {@link Joint} but not a {@link Dest} and `true` otherwise
54
+ * @returns Returns `null` if there is no parent {@link Joint}, the number of {@link Dest}s in which this component is being displayed otherwise (Usually 1)
55
55
  */
56
56
  get isExtracted() {
57
57
  const obj = useContext(ctx2);
@@ -63,10 +63,8 @@ function Dest() {
63
63
  const obj = useContext(this);
64
64
  if (!obj)
65
65
  return;
66
- if (obj.attached)
67
- throw new Error("Un extractor non può avere più di una destinazione");
68
- obj.attached = true;
69
- onCleanup(() => obj.attached = false);
66
+ obj.attached++;
67
+ onCleanup(() => obj.attached--);
70
68
  return createMemo(() => obj.source);
71
69
  }
72
70
  function Source(props) {
@@ -74,8 +72,8 @@ function Source(props) {
74
72
  if (!obj)
75
73
  return props.children;
76
74
  if (obj.source)
77
- throw new Error("Un extractor non può avere più di una sorgente");
78
- const memo = children(() => props.children);
75
+ throw new Error("An extractor can't have more than one source");
76
+ const memo = createMemo(() => props.children);
79
77
  obj.source = createMemo(memo);
80
78
  onCleanup(() => obj.source = void 0);
81
79
  return createComponent(Show, {
@@ -92,7 +90,7 @@ function Joint(props) {
92
90
  Provider
93
91
  } = this;
94
92
  const obj = createMutable({
95
- attached: false
93
+ attached: 0
96
94
  });
97
95
  return createComponent(Provider, {
98
96
  value: obj,
package/dist/flow.umd.js CHANGED
@@ -53,7 +53,7 @@
53
53
  Joint: Joint.bind(ctx2),
54
54
  /**
55
55
  * Gets an {@link Accessor} that tells if the context in which THIS getter has been executed has been extracted (Is inside of a {@link Dest})
56
- * @returns Returns `null` if there is no parent {@link Joint}, `false` if there is a {@link Joint} but not a {@link Dest} and `true` otherwise
56
+ * @returns Returns `null` if there is no parent {@link Joint}, the number of {@link Dest}s in which this component is being displayed otherwise (Usually 1)
57
57
  */
58
58
  get isExtracted() {
59
59
  const obj = solidJs.useContext(ctx2);
@@ -65,10 +65,8 @@
65
65
  const obj = solidJs.useContext(this);
66
66
  if (!obj)
67
67
  return;
68
- if (obj.attached)
69
- throw new Error("Un extractor non può avere più di una destinazione");
70
- obj.attached = true;
71
- solidJs.onCleanup(() => obj.attached = false);
68
+ obj.attached++;
69
+ solidJs.onCleanup(() => obj.attached--);
72
70
  return solidJs.createMemo(() => obj.source);
73
71
  }
74
72
  function Source(props) {
@@ -76,8 +74,8 @@
76
74
  if (!obj)
77
75
  return props.children;
78
76
  if (obj.source)
79
- throw new Error("Un extractor non può avere più di una sorgente");
80
- const memo = solidJs.children(() => props.children);
77
+ throw new Error("An extractor can't have more than one source");
78
+ const memo = solidJs.createMemo(() => props.children);
81
79
  obj.source = solidJs.createMemo(memo);
82
80
  solidJs.onCleanup(() => obj.source = void 0);
83
81
  return solidJs.createComponent(solidJs.Show, {
@@ -94,7 +92,7 @@
94
92
  Provider
95
93
  } = this;
96
94
  const obj = store.createMutable({
97
- attached: false
95
+ attached: 0
98
96
  });
99
97
  return solidJs.createComponent(Provider, {
100
98
  value: obj,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-ctrl-flow",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Control flow components for solid-js",
5
5
  "author": "AFatNiBBa",
6
6
  "license": "ISC",
package/readme.md CHANGED
@@ -63,7 +63,7 @@ function MyCustomComponent() {
63
63
  </>
64
64
  }
65
65
  ```
66
- If you use it normally it will output `1`, `2`, `3`, `4`, `5`
66
+ If you use it normally it will output `4`, `1`, `2`, `3`, `5`
67
67
  ```tsx
68
68
  return <>
69
69
  4