@form-engine-ts/react 2.0.0 → 2.1.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/README.md CHANGED
@@ -53,10 +53,19 @@ batch-translation action.
53
53
 
54
54
  ## Headless builder and renderer lifecycle
55
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.
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
+ Visual-builder field creation uses `defaultFieldType` when it is allowed, otherwise the first allowed policy type, then
65
+ `text` when unrestricted. The add button is disabled when no type is allowed or `maxFields` is reached.
66
+ `onActionError` receives typed failures from visual headless actions, and `createManualTranslationMetadata` can attach
67
+ per-locale/property metadata to manual edits. Automatic translation defaults to `overwrite: "missing-only"`; explicitly
68
+ pass `{ overwrite: "all" }` to replace existing translations.
60
69
 
61
70
  `FormRenderer` can also be used without an explicit provider:
62
71
 
@@ -69,14 +78,16 @@ Rejected add operations return typed errors without changing the schema. `<FormB
69
78
  onDraftSave={saveDraft}
70
79
  slots={{
71
80
  renderHeader: ({ title }) => <MyHeader>{title}</MyHeader>,
81
+ renderPageHeader: ({ page }) => <MyPageHeader page={page} />,
72
82
  renderField: (props) => <MyField {...props} />,
73
83
  renderSubmitButton: ({ isSubmitting, onSubmit }) => (
74
84
  <MyButton disabled={isSubmitting} onClick={onSubmit}>Save</MyButton>
75
- )
85
+ ),
86
+ renderSubmitError: ({ error, onRetry }) => <MyError error={error} onRetry={onRetry} />
76
87
  }}
77
88
  />
78
89
  ```
79
90
 
80
91
  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.
92
+ Header, page-header, field, navigation, submit, validation-summary, completion, and submit-error slots can replace the
93
+ default UI. The localized `completionMessage` is displayed after a successful submission.