solid-ctrl-flow 1.0.17 → 1.0.19

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
@@ -60,11 +60,11 @@ export declare function Case(props: {
60
60
  * @param name Name to give to the context of the extractor
61
61
  */
62
62
  export declare function createExtractor(name?: string): {
63
- /** Bound {@link Dest} */
63
+ /** Shows the content of the closest {@link Source} child of the closest {@link Joint} ancestor of this component */
64
64
  Dest: () => JSX.Element;
65
- /** Bound {@link Source} */
65
+ /** Puts its content inside of a {@link Dest} if it is available; There is no need to include this component on the DOM tree */
66
66
  Source: (props: Info) => JSX.Element;
67
- /** Bound {@link Joint} */
67
+ /** Allows {@link Dest} and {@link Source} childrens to communicate with each other */
68
68
  Joint: (props: {
69
69
  children: JSX.Element;
70
70
  }) => JSX.Element;
@@ -77,24 +77,33 @@ export declare function createExtractor(name?: string): {
77
77
 
78
78
  /**
79
79
  * Creates a context with a reactive value.
80
- * It returns the provider directly
80
+ * Returns a provider with additional fields:
81
+ * - The `read` getter, which returns an {@link Accessor} to the value
82
+ * - The `runWith()` method, which executes {@link runWithContext} on the option
81
83
  * @param init Initial value for the context
82
84
  * @param def Default value to set when calling the provider without one
83
85
  * @param name Name to give to the context
84
86
  */
85
- export declare function createOption<T>(init: T, def?: T, name?: string): ((props: {
86
- value?: T;
87
- children: JSX.Element;
88
- }) => JSX.Element) & {
87
+ export declare function createOption<T>(init: T, def?: T, name?: string): {
88
+ (props: {
89
+ value?: T;
90
+ children: JSX.Element;
91
+ }): JSX.Element;
92
+ /** Executes {@link runWithContext} on the provided option */
93
+ runWith<V extends T, R>(x: V, f: (x: V) => R): R;
94
+ } & {
89
95
  /** Returns the {@link Accessor} for the value in the current context */
90
96
  read: Accessor<T>;
91
97
  };
92
98
 
93
99
  /** Creates a scope for the value of {@link Debug.read}, which allows you to display different things in debug mode */
94
- export declare const Debug: ((props: {
95
- value?: boolean | undefined;
96
- children: JSX.Element;
97
- }) => JSX.Element) & {
100
+ export declare const Debug: {
101
+ (props: {
102
+ value?: boolean | undefined;
103
+ children: JSX.Element;
104
+ }): JSX.Element;
105
+ runWith<V extends boolean, R>(x: V, f: (x: V) => R): R;
106
+ } & {
98
107
  read: Accessor<boolean>;
99
108
  };
100
109
 
package/dist/index.mjs CHANGED
@@ -31,6 +31,7 @@ function createOption(init, def = init, name) {
31
31
  Object.defineProperty(provider, prop, {
32
32
  get: () => useContext(ctx2)
33
33
  });
34
+ provider.runWith = (x, f) => runWithContext(ctx2, () => x, () => f(x));
34
35
  return provider;
35
36
  }
36
37
  function runWithContext(ctx2, value, f) {
@@ -75,11 +76,11 @@ function createExtractor(name = "extractor") {
75
76
  name
76
77
  });
77
78
  return {
78
- /** Bound {@link Dest} */
79
+ /** Shows the content of the closest {@link Source} child of the closest {@link Joint} ancestor of this component */
79
80
  Dest: Dest.bind(ctx2),
80
- /** Bound {@link Source} */
81
+ /** Puts its content inside of a {@link Dest} if it is available; There is no need to include this component on the DOM tree */
81
82
  Source: Source.bind(ctx2),
82
- /** Bound {@link Joint} */
83
+ /** Allows {@link Dest} and {@link Source} childrens to communicate with each other */
83
84
  Joint: Joint.bind(ctx2),
84
85
  /**
85
86
  * 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})
package/dist/index.umd.js CHANGED
@@ -33,6 +33,7 @@
33
33
  Object.defineProperty(provider, prop, {
34
34
  get: () => solidJs.useContext(ctx2)
35
35
  });
36
+ provider.runWith = (x, f) => runWithContext(ctx2, () => x, () => f(x));
36
37
  return provider;
37
38
  }
38
39
  function runWithContext(ctx2, value, f) {
@@ -77,11 +78,11 @@
77
78
  name
78
79
  });
79
80
  return {
80
- /** Bound {@link Dest} */
81
+ /** Shows the content of the closest {@link Source} child of the closest {@link Joint} ancestor of this component */
81
82
  Dest: Dest.bind(ctx2),
82
- /** Bound {@link Source} */
83
+ /** Puts its content inside of a {@link Dest} if it is available; There is no need to include this component on the DOM tree */
83
84
  Source: Source.bind(ctx2),
84
- /** Bound {@link Joint} */
85
+ /** Allows {@link Dest} and {@link Source} childrens to communicate with each other */
85
86
  Joint: Joint.bind(ctx2),
86
87
  /**
87
88
  * 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})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-ctrl-flow",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "Control flow components for solid-js",
5
5
  "author": "AFatNiBBa",
6
6
  "license": "ISC",
package/readMe.md CHANGED
@@ -112,6 +112,14 @@ return <>
112
112
  21
113
113
  </>
114
114
  ```
115
+ Notice that you can use a `Source` component without adding it to the DOM:
116
+ ```tsx
117
+ <myCustomExtractor.Source>
118
+ {/* This doesn't get returned, but still gets shown if there is an available "Dest" */}
119
+ Something
120
+ </myCustomExtractor.Source>
121
+ return <>Something else</>
122
+ ```
115
123
 
116
124
  ## Utility functions
117
125
  Utility functions needed for the components above