@react-typed-forms/schemas 16.0.2 → 16.1.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/lib/index.cjs +13 -12
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +12 -5
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- package/src/RenderForm.tsx +13 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-typed-forms/schemas",
|
|
3
|
-
"version": "16.0
|
|
3
|
+
"version": "16.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.cjs",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"clsx": "^1 || ^2",
|
|
35
35
|
"uuid": "^10.0.0",
|
|
36
36
|
"jsonata": "^2.0.4",
|
|
37
|
-
"@astroapps/forms-core": "^1.0
|
|
37
|
+
"@astroapps/forms-core": "^1.1.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"react": "^18.2.0 || ^19",
|
|
41
|
-
"@react-typed-forms/core": "^4.4.
|
|
41
|
+
"@react-typed-forms/core": "^4.4.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"react": "^18.2.0 || ^19",
|
|
45
|
-
"@react-typed-forms/core": "^4.4.
|
|
45
|
+
"@react-typed-forms/core": "^4.4.2",
|
|
46
46
|
"@react-typed-forms/transform": "^0.2.0",
|
|
47
47
|
"jest": "^29.7.0",
|
|
48
48
|
"tsx": "^4.19.1",
|
package/src/RenderForm.tsx
CHANGED
|
@@ -57,10 +57,12 @@ export function RenderForm({
|
|
|
57
57
|
const [formState, setFormState] = useState(
|
|
58
58
|
() => options?.formState ?? createFormState(schemaInterface),
|
|
59
59
|
);
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
effects.push(cb)
|
|
63
|
-
|
|
60
|
+
let effects: (() => void)[] | undefined = [];
|
|
61
|
+
const runAsync = (cb: () => void) => {
|
|
62
|
+
if (effects) effects.push(cb);
|
|
63
|
+
else cb();
|
|
64
|
+
};
|
|
65
|
+
const state = formState.getControlState(data, form, options, runAsync);
|
|
64
66
|
|
|
65
67
|
useEffect(() => {
|
|
66
68
|
if (!options?.formState) {
|
|
@@ -164,7 +166,7 @@ export function RenderForm({
|
|
|
164
166
|
parent ?? state.dataNode ?? data,
|
|
165
167
|
child,
|
|
166
168
|
childOptions,
|
|
167
|
-
|
|
169
|
+
runAsync,
|
|
168
170
|
);
|
|
169
171
|
},
|
|
170
172
|
runExpression: (scope, expr, returnResult) => {
|
|
@@ -174,7 +176,7 @@ export function RenderForm({
|
|
|
174
176
|
dataNode: data,
|
|
175
177
|
schemaInterface,
|
|
176
178
|
returnResult,
|
|
177
|
-
runAsync
|
|
179
|
+
runAsync,
|
|
178
180
|
});
|
|
179
181
|
}
|
|
180
182
|
},
|
|
@@ -193,7 +195,11 @@ export function RenderForm({
|
|
|
193
195
|
...renderedControl,
|
|
194
196
|
});
|
|
195
197
|
useEffect(() => {
|
|
196
|
-
effects
|
|
198
|
+
if (effects) {
|
|
199
|
+
const toRun = effects;
|
|
200
|
+
effects = undefined;
|
|
201
|
+
toRun.forEach((cb) => cb());
|
|
202
|
+
}
|
|
197
203
|
}, [effects]);
|
|
198
204
|
return rendered;
|
|
199
205
|
}
|