@expressive/react 0.35.2 → 0.35.5-alpha.0
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 +8 -6
- package/dist/index.js +3 -4
- package/dist/index.mjs +3 -4
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { Model, Context } from '@expressive/mvc';
|
|
2
2
|
export * from '@expressive/mvc';
|
|
3
3
|
export { Model as default } from '@expressive/mvc';
|
|
4
|
-
import { ReactElement, FunctionComponentElement, ProviderProps
|
|
4
|
+
import { ReactElement, FunctionComponentElement, ProviderProps } from 'react';
|
|
5
5
|
|
|
6
6
|
declare namespace Consumer {
|
|
7
7
|
type HasProps<T extends Model> = {
|
|
8
8
|
/** Type of controller to fetch from context. */
|
|
9
9
|
for: Model.Type<T>;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* If boolean, will assert controller of type `for` is present in context.
|
|
12
|
+
*
|
|
13
|
+
* If function, will called on every natural render of this component.
|
|
12
14
|
* Will throw if usable instance cannot be found in context.
|
|
13
15
|
*/
|
|
14
|
-
has: (value: T) => void;
|
|
16
|
+
has: ((value: T) => void) | boolean;
|
|
15
17
|
};
|
|
16
18
|
type GetProps<T extends Model> = {
|
|
17
19
|
/** Type of controller to fetch from context. */
|
|
18
20
|
for: Model.Type<T>;
|
|
19
|
-
/**
|
|
21
|
+
/** Function called on every natural render of this component. */
|
|
20
22
|
get: (value: T | undefined) => void;
|
|
21
23
|
};
|
|
22
24
|
type RenderProps<T extends Model> = {
|
|
@@ -44,12 +46,12 @@ declare namespace Provider {
|
|
|
44
46
|
type Props<T extends Item = Item> = MultipleProps<T> | NormalProps<T>;
|
|
45
47
|
type NormalProps<E, I = Instance<E>> = {
|
|
46
48
|
for: E;
|
|
47
|
-
children?:
|
|
49
|
+
children?: unknown;
|
|
48
50
|
use?: Model.Values<I>;
|
|
49
51
|
};
|
|
50
52
|
type MultipleProps<T extends Item> = {
|
|
51
53
|
for: Multiple<T>;
|
|
52
|
-
children?:
|
|
54
|
+
children?: unknown;
|
|
53
55
|
use?: Model.Values<Instance<T>>;
|
|
54
56
|
};
|
|
55
57
|
}
|
package/dist/index.js
CHANGED
|
@@ -156,11 +156,10 @@ __reExport(src_exports, require("@expressive/mvc"), module.exports);
|
|
|
156
156
|
// src/consumer.ts
|
|
157
157
|
function Consumer(props) {
|
|
158
158
|
const { children, has, get, for: Type } = props;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
const callback = has || get;
|
|
159
|
+
const instance = Type.get(!!has);
|
|
160
|
+
const callback = children || has || get;
|
|
162
161
|
if (typeof callback == "function")
|
|
163
|
-
callback(
|
|
162
|
+
callback(instance);
|
|
164
163
|
return null;
|
|
165
164
|
}
|
|
166
165
|
|
package/dist/index.mjs
CHANGED
|
@@ -129,11 +129,10 @@ export * from "@expressive/mvc";
|
|
|
129
129
|
// src/consumer.ts
|
|
130
130
|
function Consumer(props) {
|
|
131
131
|
const { children, has, get, for: Type } = props;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const callback = has || get;
|
|
132
|
+
const instance = Type.get(!!has);
|
|
133
|
+
const callback = children || has || get;
|
|
135
134
|
if (typeof callback == "function")
|
|
136
|
-
callback(
|
|
135
|
+
callback(instance);
|
|
137
136
|
return null;
|
|
138
137
|
}
|
|
139
138
|
|
package/package.json
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"preversion": "npm run test && npm run build"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@expressive/mvc": "^0.35.
|
|
34
|
+
"@expressive/mvc": "^0.35.5-alpha.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"react": ">=16.8.0 <19.0.0"
|
|
@@ -42,6 +42,6 @@
|
|
|
42
42
|
"react": "^18.2.0",
|
|
43
43
|
"react-test-renderer": "^18.2.0"
|
|
44
44
|
},
|
|
45
|
-
"version": "0.35.
|
|
46
|
-
"gitHead": "
|
|
45
|
+
"version": "0.35.5-alpha.0",
|
|
46
|
+
"gitHead": "9626c3d85bd2fa7a8e5368c845ff8d889843be0b"
|
|
47
47
|
}
|