@react-typed-forms/schemas 16.0.1 → 16.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-typed-forms/schemas",
3
- "version": "16.0.1",
3
+ "version": "16.0.3",
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.0"
37
+ "@astroapps/forms-core": "^1.0.2"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "react": "^18.2.0 || ^19",
41
- "@react-typed-forms/core": "^4.4.0"
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.0",
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",
@@ -45,6 +45,7 @@ export interface RenderFormProps {
45
45
  renderer: FormRenderer;
46
46
  options?: ControlRenderOptions;
47
47
  }
48
+
48
49
  /* @trackControls */
49
50
  export function RenderForm({
50
51
  data,
@@ -56,7 +57,12 @@ export function RenderForm({
56
57
  const [formState, setFormState] = useState(
57
58
  () => options?.formState ?? createFormState(schemaInterface),
58
59
  );
59
- const state = formState.getControlState(data, form, options);
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);
60
66
 
61
67
  useEffect(() => {
62
68
  if (!options?.formState) {
@@ -160,6 +166,7 @@ export function RenderForm({
160
166
  parent ?? state.dataNode ?? data,
161
167
  child,
162
168
  childOptions,
169
+ runAsync,
163
170
  );
164
171
  },
165
172
  runExpression: (scope, expr, returnResult) => {
@@ -169,6 +176,7 @@ export function RenderForm({
169
176
  dataNode: data,
170
177
  schemaInterface,
171
178
  returnResult,
179
+ runAsync,
172
180
  });
173
181
  }
174
182
  },
@@ -182,7 +190,18 @@ export function RenderForm({
182
190
  const renderedControl = renderer.renderLayout(
183
191
  options.adjustLayout?.(dataContext, layoutProps) ?? layoutProps,
184
192
  );
185
- return renderer.renderVisibility({ visibility, ...renderedControl });
193
+ const rendered = renderer.renderVisibility({
194
+ visibility,
195
+ ...renderedControl,
196
+ });
197
+ useEffect(() => {
198
+ if (effects) {
199
+ const toRun = effects;
200
+ effects = undefined;
201
+ toRun.forEach((cb) => cb());
202
+ }
203
+ }, [effects]);
204
+ return rendered;
186
205
  }
187
206
 
188
207
  /**