@form-engine-ts/react 2.9.6 → 3.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 +32 -13
- package/dist/index.cjs +288 -50
- package/dist/index.d.cts +84 -8
- package/dist/index.d.ts +84 -8
- package/dist/index.js +287 -50
- package/dist/styles.css +34 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ export function ContactForm() {
|
|
|
29
29
|
schema={schema}
|
|
30
30
|
locale="en"
|
|
31
31
|
translator={mockTranslator}
|
|
32
|
-
onSubmit={async (values) => console.log(values)}
|
|
32
|
+
onSubmit={async (values, context) => console.log(values, context.attemptId)}
|
|
33
33
|
>
|
|
34
34
|
<FormRenderer />
|
|
35
35
|
</FormProvider>
|
|
@@ -95,7 +95,25 @@ translation lifecycle.
|
|
|
95
95
|
When either is enabled, the builder omits its `form-engine-builder` and `feb-*` classes. Injected `TextInput`, `TextArea`,
|
|
96
96
|
and `Select` components receive the field `label` and accessibility attributes and are responsible for rendering their
|
|
97
97
|
own labels. Builder action icons can be supplied with `renderIcon`, which resolves `actionType` values such as
|
|
98
|
-
`moveUp`, `moveDown`, `delete`, and `add`.
|
|
98
|
+
`moveUp`, `moveDown`, `delete`, and `add`. `renderFieldTypeIcon` supplies icons for field-type selectors. Select
|
|
99
|
+
options may be strings or `BuilderSelectOption` objects with `icon`, `description`, `kind`, and `metadata`; custom
|
|
100
|
+
`renderOption` and `renderValue` functions can control their presentation. `BUILDER_TRANSLATION_KEYS` exposes the
|
|
101
|
+
canonical typed builder translation keys while legacy catalog aliases remain supported.
|
|
102
|
+
|
|
103
|
+
The `fieldEditor` slot can expose only the type selector or header through `fieldTypeSelect` and `fieldEditorHeader`:
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
<FormBuilder
|
|
107
|
+
schema={schema}
|
|
108
|
+
onChange={setSchema}
|
|
109
|
+
slots={{
|
|
110
|
+
fieldTypeSelect: ({ currentType, onChangeType }) => (
|
|
111
|
+
<button type="button" onClick={() => onChangeType("textarea")}>{currentType}</button>
|
|
112
|
+
),
|
|
113
|
+
fieldEditorHeader: ({ field }) => <h3>{field.title}</h3>
|
|
114
|
+
}}
|
|
115
|
+
/>
|
|
116
|
+
```
|
|
99
117
|
|
|
100
118
|
```tsx
|
|
101
119
|
<FormBuilder
|
|
@@ -149,14 +167,15 @@ and `useSubmissionReceipts` loads multiple form/version receipts for list and da
|
|
|
149
167
|
|
|
150
168
|
Receipt persistence is best-effort: `onReceiptError` observes storage failures while the successful completion screen is
|
|
151
169
|
preserved. Pass an SSR-safe `createLocalStorageSubmissionAttemptStore()` as `attemptStore` to reserve an ID immediately
|
|
152
|
-
before submission.
|
|
153
|
-
|
|
154
|
-
to concurrent `get` calls.
|
|
155
|
-
|
|
156
|
-
After success, completion rendering receives a snapshot of `answers`, `schema`, the
|
|
157
|
-
`submittedItems`. Each summary item includes the field title, raw value, formatted display value,
|
|
158
|
-
metadata. Use `renderSubmittedValues` for a typed summary slot; hidden fields are omitted by default
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
`
|
|
162
|
-
`
|
|
170
|
+
before submission. `onSubmit(answers, context)` keeps `attemptId`, `formId`, `formVersion`, `locale`, and `submittedAt`
|
|
171
|
+
outside the answers object, retains the same attempt after a failed request, promotes it to the receipt after success,
|
|
172
|
+
and then clears the attempt. Custom receipt stores may omit `getBatch`; the hook falls back to concurrent `get` calls.
|
|
173
|
+
|
|
174
|
+
After success, completion rendering receives a typed `FormCompletionSlotProps` snapshot of `answers`, `schema`, the
|
|
175
|
+
optional response, and `submittedItems`. Each summary item includes the field title, raw value, formatted display value,
|
|
176
|
+
visibility, and field metadata. Use `renderSubmittedValues` for a typed summary slot; hidden fields are omitted by default
|
|
177
|
+
and can be included with `showHiddenFieldsInSummary`. Supply `messages` or `messageResolver` to localize standard buttons,
|
|
178
|
+
validation, retry, already-submitted, server-error, and sensitive-data confirmation UI. Server validation can be returned
|
|
179
|
+
by throwing `FormSubmissionError` or a payload with `fieldErrors` and `formError`; field messages are mapped back to the
|
|
180
|
+
form, scrolled into view, and focused. Use `submissionConfirmationRenderMode="replace"` or `"dialog"` for alternate
|
|
181
|
+
confirmation presentations, and `fieldsClassName` or `renderFields` to control the fields wrapper.
|