@form-engine-ts/react 1.1.0 → 2.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/README.md CHANGED
@@ -50,3 +50,38 @@ on the next mount:
50
50
  `FormProvider` resolves authoring-time translations synchronously whenever `locale` changes. `FormBuilder` includes page
51
51
  membership controls and localization editors; pass an `AsyncTranslationAdapter` as `translationAdapter` to enable its
52
52
  batch-translation action.
53
+
54
+ ## Headless builder and renderer lifecycle
55
+
56
+ `useFormBuilder({ schema, onChange, policy, idFactory, factories })` exposes controlled field, option, page, condition,
57
+ source-text, and localized-text actions. Core's `FormPolicy` enforces allowed field types, field/option limits, text and
58
+ schema-byte limits, and required locales identically in browser and server code. Every mutation returns a typed
59
+ `BuilderActionResult`; invalid, empty, or duplicate generated IDs leave the schema unchanged. `BuilderFactories` injects
60
+ initial field, option, and page shapes. `<FormBuilder>` delegates its UI mutations to this hook and accepts the same
61
+ options. Its completion-message editors cover both source and locale text. `translationOptions` and
62
+ `onTranslationReport` expose automatic-translation policy and reporting.
63
+
64
+ `FormRenderer` can also be used without an explicit provider:
65
+
66
+ ```tsx
67
+ <FormRenderer
68
+ schema={schema}
69
+ locale="en"
70
+ beforeSubmit={async (values) => (await confirmValues(values) ? "continue" : "cancel")}
71
+ onSubmit={saveValues}
72
+ onDraftSave={saveDraft}
73
+ slots={{
74
+ renderHeader: ({ title }) => <MyHeader>{title}</MyHeader>,
75
+ renderPageHeader: ({ page }) => <MyPageHeader page={page} />,
76
+ renderField: (props) => <MyField {...props} />,
77
+ renderSubmitButton: ({ isSubmitting, onSubmit }) => (
78
+ <MyButton disabled={isSubmitting} onClick={onSubmit}>Save</MyButton>
79
+ ),
80
+ renderSubmitError: ({ error, onRetry }) => <MyError error={error} onRetry={onRetry} />
81
+ }}
82
+ />
83
+ ```
84
+
85
+ Validation runs before `beforeSubmit`. A `"cancel"` result does not call `onSubmit` and preserves values and drafts.
86
+ Header, page-header, field, navigation, submit, validation-summary, completion, and submit-error slots can replace the
87
+ default UI. The localized `completionMessage` is displayed after a successful submission.