@form-engine-ts/react 1.0.0 → 2.0.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
@@ -38,3 +38,45 @@ export function ContactForm() {
38
38
  ```
39
39
 
40
40
  Use any compatible `TranslationAdapter` in place of the mock translator.
41
+
42
+ Define `schema.pages` to enable Back/Next navigation, page validation, conditional page skipping, and an accessible
43
+ progress indicator. Pass `autoSaveKey` to persist a versioned draft in `localStorage` after a 500ms debounce and restore it
44
+ on the next mount:
45
+
46
+ ```tsx
47
+ <FormRenderer autoSaveKey={`contact-draft:${schema.version}`} />
48
+ ```
49
+
50
+ `FormProvider` resolves authoring-time translations synchronously whenever `locale` changes. `FormBuilder` includes page
51
+ membership controls and localization editors; pass an `AsyncTranslationAdapter` as `translationAdapter` to enable its
52
+ batch-translation action.
53
+
54
+ ## Headless builder and renderer lifecycle
55
+
56
+ `useFormBuilder({ schema, onChange, policy, idFactory })` exposes controlled field, option, page, and locale actions.
57
+ `BuilderPolicy` can enforce allowed field types, 20-field/10-option style limits, text length, and required locales.
58
+ Rejected add operations return typed errors without changing the schema. `<FormBuilder>` uses the same hook and accepts
59
+ `policy` and `idFactory` props.
60
+
61
+ `FormRenderer` can also be used without an explicit provider:
62
+
63
+ ```tsx
64
+ <FormRenderer
65
+ schema={schema}
66
+ locale="en"
67
+ beforeSubmit={async (values) => (await confirmValues(values) ? "continue" : "cancel")}
68
+ onSubmit={saveValues}
69
+ onDraftSave={saveDraft}
70
+ slots={{
71
+ renderHeader: ({ title }) => <MyHeader>{title}</MyHeader>,
72
+ renderField: (props) => <MyField {...props} />,
73
+ renderSubmitButton: ({ isSubmitting, onSubmit }) => (
74
+ <MyButton disabled={isSubmitting} onClick={onSubmit}>Save</MyButton>
75
+ )
76
+ }}
77
+ />
78
+ ```
79
+
80
+ Validation runs before `beforeSubmit`. A `"cancel"` result does not call `onSubmit` and preserves values and drafts.
81
+ Header, field, navigation, submit, validation-summary, and completion slots can replace the default UI. The localized
82
+ `completionMessage` is displayed after a successful submission.