@expressive/react 0.42.0 → 0.43.1
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 +2 -2
- package/dist/index.js +7 -17
- package/dist/index.mjs +7 -17
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -50,12 +50,12 @@ declare namespace Provider {
|
|
|
50
50
|
type NormalProps<E, I = Instance<E>> = {
|
|
51
51
|
for: E;
|
|
52
52
|
children?: Node;
|
|
53
|
-
use?: Model.
|
|
53
|
+
use?: Model.Assign<I>;
|
|
54
54
|
};
|
|
55
55
|
type MultipleProps<T extends Item> = {
|
|
56
56
|
for: Multiple<T>;
|
|
57
57
|
children?: Node;
|
|
58
|
-
use?: Model.
|
|
58
|
+
use?: Model.Assign<Instance<T>>;
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
declare function Provider<T extends Provider.Item>(props: Provider.Props<T>): Provider.Element;
|
package/dist/index.js
CHANGED
|
@@ -84,26 +84,19 @@ function useLocal(argument, repeat) {
|
|
|
84
84
|
const state = (0, import_react2.useState)(() => {
|
|
85
85
|
let enabled;
|
|
86
86
|
let local;
|
|
87
|
-
|
|
88
|
-
if (typeof argument == "function")
|
|
89
|
-
argument(this);
|
|
90
|
-
else if (argument) {
|
|
91
|
-
for (const key in this)
|
|
92
|
-
if (argument.hasOwnProperty(key))
|
|
93
|
-
this[key] = argument[key];
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
const instance = this.new(apply);
|
|
87
|
+
const instance = this.new(argument);
|
|
97
88
|
const release = instance.get((current) => {
|
|
98
89
|
local = current;
|
|
99
90
|
if (enabled)
|
|
100
91
|
state[1]((x) => x.bind(null));
|
|
101
92
|
});
|
|
102
93
|
return (props) => {
|
|
103
|
-
argument = props;
|
|
104
94
|
if (repeat && enabled) {
|
|
105
95
|
enabled = false;
|
|
106
|
-
|
|
96
|
+
if (typeof props == "function")
|
|
97
|
+
props.call(instance, instance);
|
|
98
|
+
else if (typeof props == "object")
|
|
99
|
+
instance.set(props);
|
|
107
100
|
const update = instance.set();
|
|
108
101
|
if (update)
|
|
109
102
|
update.then(() => enabled = true);
|
|
@@ -204,11 +197,8 @@ function Provider(props) {
|
|
|
204
197
|
const ambient = useContext();
|
|
205
198
|
const context = (0, import_react2.useMemo)(() => ambient.push(), []);
|
|
206
199
|
context.include(included).forEach((isExplicit, model) => {
|
|
207
|
-
if (assign && isExplicit)
|
|
208
|
-
|
|
209
|
-
if (K in model)
|
|
210
|
-
model.set(K, assign[K]);
|
|
211
|
-
}
|
|
200
|
+
if (assign && isExplicit)
|
|
201
|
+
model.set(assign);
|
|
212
202
|
setContext(model, context);
|
|
213
203
|
});
|
|
214
204
|
(0, import_react2.useEffect)(() => () => context.pop(), []);
|
package/dist/index.mjs
CHANGED
|
@@ -51,26 +51,19 @@ function useLocal(argument, repeat) {
|
|
|
51
51
|
const state = useState(() => {
|
|
52
52
|
let enabled;
|
|
53
53
|
let local;
|
|
54
|
-
|
|
55
|
-
if (typeof argument == "function")
|
|
56
|
-
argument(this);
|
|
57
|
-
else if (argument) {
|
|
58
|
-
for (const key in this)
|
|
59
|
-
if (argument.hasOwnProperty(key))
|
|
60
|
-
this[key] = argument[key];
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const instance = this.new(apply);
|
|
54
|
+
const instance = this.new(argument);
|
|
64
55
|
const release = instance.get((current) => {
|
|
65
56
|
local = current;
|
|
66
57
|
if (enabled)
|
|
67
58
|
state[1]((x) => x.bind(null));
|
|
68
59
|
});
|
|
69
60
|
return (props) => {
|
|
70
|
-
argument = props;
|
|
71
61
|
if (repeat && enabled) {
|
|
72
62
|
enabled = false;
|
|
73
|
-
|
|
63
|
+
if (typeof props == "function")
|
|
64
|
+
props.call(instance, instance);
|
|
65
|
+
else if (typeof props == "object")
|
|
66
|
+
instance.set(props);
|
|
74
67
|
const update = instance.set();
|
|
75
68
|
if (update)
|
|
76
69
|
update.then(() => enabled = true);
|
|
@@ -171,11 +164,8 @@ function Provider(props) {
|
|
|
171
164
|
const ambient = useContext();
|
|
172
165
|
const context = useMemo(() => ambient.push(), []);
|
|
173
166
|
context.include(included).forEach((isExplicit, model) => {
|
|
174
|
-
if (assign && isExplicit)
|
|
175
|
-
|
|
176
|
-
if (K in model)
|
|
177
|
-
model.set(K, assign[K]);
|
|
178
|
-
}
|
|
167
|
+
if (assign && isExplicit)
|
|
168
|
+
model.set(assign);
|
|
179
169
|
setContext(model, context);
|
|
180
170
|
});
|
|
181
171
|
useEffect(() => () => context.pop(), []);
|
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.
|
|
34
|
+
"@expressive/mvc": "^0.43.1"
|
|
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.
|
|
46
|
-
"gitHead": "
|
|
45
|
+
"version": "0.43.1",
|
|
46
|
+
"gitHead": "1fce74756afb4499f6b4da1c52bfbc2021b73ebb"
|
|
47
47
|
}
|