@praxisui/dynamic-form 7.0.0-beta.0 → 8.0.0-beta.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 +74 -4
- package/fesm2022/praxisui-dynamic-form.mjs +618 -99
- package/index.d.ts +60 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ keywords:
|
|
|
37
37
|
- "schema-driven"
|
|
38
38
|
- "layout editor"
|
|
39
39
|
- "settings integration"
|
|
40
|
-
last_updated: "2026-
|
|
40
|
+
last_updated: "2026-04-12"
|
|
41
41
|
---
|
|
42
42
|
|
|
43
43
|
# @praxisui/dynamic-form
|
|
@@ -136,6 +136,74 @@ Tip: connect to a backend resource by setting `resourcePath`/`resourceId`. The c
|
|
|
136
136
|
For metadata-driven surfaces published by the backend, prefer passing `schemaUrl`, `submitUrl` and `submitMethod` explicitly. In dialog/drawer hosts detached from the route injector, pass `apiUrlEntry` in addition to `apiEndpointKey` so relative runtime URLs still resolve against the remote backend instead of the local shell origin.
|
|
137
137
|
When a late `config` hydration rebuilds the surface, the runtime preserves the current form values already mounted in memory only when the logical context remains the same (`resourcePath`, `resourceId`, and mode). If the form was preloaded from `resourceId`, that entity hydration remains visible after the rebuild only for the same entity context; entity switches and create-mode transitions do not restore the previous record snapshot.
|
|
138
138
|
|
|
139
|
+
## Local fields, transient state, and submit payloads
|
|
140
|
+
|
|
141
|
+
`praxis-dynamic-form` supports host-owned fields that participate in the form runtime without becoming part of the backend DTO. This is the right model for confirmation controls, wizard state, client-side calculated previews, host notes, and other UI context that should be available to rules and hooks but should not be persisted by default.
|
|
142
|
+
|
|
143
|
+
The submit contract exposes two values:
|
|
144
|
+
|
|
145
|
+
| Property | Meaning | Typical consumer |
|
|
146
|
+
| --- | --- | --- |
|
|
147
|
+
| `formSubmit.formData` | filtered persistence payload after submit policy is applied | HTTP submit, persistence hooks, backend DTO integration |
|
|
148
|
+
| `formSubmit.rawFormData` | full form value before filtering | host hooks, UI audit context, diagnostics, calculations |
|
|
149
|
+
|
|
150
|
+
Default behavior:
|
|
151
|
+
|
|
152
|
+
- schema-backed fields are included in `formData`.
|
|
153
|
+
- fields with `source: 'local'` are omitted from `formData` and kept in `rawFormData`.
|
|
154
|
+
- fields with `transient: true` are omitted from `formData` and kept in `rawFormData`.
|
|
155
|
+
- `submitPolicy` has priority over `source` and `transient`.
|
|
156
|
+
|
|
157
|
+
| `submitPolicy` | Effect |
|
|
158
|
+
| --- | --- |
|
|
159
|
+
| `include` | always include the field in `formData` |
|
|
160
|
+
| `omit` | always omit the field from `formData` |
|
|
161
|
+
| `includeWhenDirty` | include the field in `formData` only when the control is dirty |
|
|
162
|
+
|
|
163
|
+
Example:
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
fieldMetadata: [
|
|
167
|
+
{ name: 'fullName', label: 'Full name', controlType: 'input' },
|
|
168
|
+
{
|
|
169
|
+
name: 'approvalComment',
|
|
170
|
+
label: 'Approval comment',
|
|
171
|
+
controlType: 'textarea',
|
|
172
|
+
source: 'local',
|
|
173
|
+
submitPolicy: 'omit',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: 'calculatedRiskScore',
|
|
177
|
+
label: 'Risk score',
|
|
178
|
+
controlType: 'numericTextBox',
|
|
179
|
+
transient: true,
|
|
180
|
+
readOnly: true,
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: 'manualOverrideReason',
|
|
184
|
+
label: 'Manual override reason',
|
|
185
|
+
controlType: 'textarea',
|
|
186
|
+
source: 'local',
|
|
187
|
+
submitPolicy: 'includeWhenDirty',
|
|
188
|
+
},
|
|
189
|
+
];
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
For a submitted value like:
|
|
193
|
+
|
|
194
|
+
```json
|
|
195
|
+
{
|
|
196
|
+
"fullName": "Ana Souza",
|
|
197
|
+
"approvalComment": "Checked with HR",
|
|
198
|
+
"calculatedRiskScore": 72,
|
|
199
|
+
"manualOverrideReason": "Approved exception"
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
`rawFormData` keeps all four values. `formData` keeps `fullName` and, when dirty, `manualOverrideReason`; it omits `approvalComment` and `calculatedRiskScore`.
|
|
204
|
+
|
|
205
|
+
Do not use local/transient fields to hide a backend contract problem. If a field exists in the backend schema, keep it server-backed and fix the canonical schema or metadata mapping instead of creating a parallel local convention.
|
|
206
|
+
|
|
139
207
|
Presentation/read-only note:
|
|
140
208
|
- `praxis-dynamic-form` hospeda `FieldMetadata`, mas não é o resolvedor direto de `valuePresentation`.
|
|
141
209
|
- quando campos entram em modo view/presentation, a semântica de apresentação vem do metadata do campo e é resolvida por `@praxisui/dynamic-fields`.
|
|
@@ -666,9 +734,11 @@ Apache-2.0 – see the `LICENSE` packaged with this library or the repository ro
|
|
|
666
734
|
- `form-schema-prefs:{formId}` → `{ notifyIfOutdated?, snoozeMs?, autoOpenSettingsOnOutdated? }`
|
|
667
735
|
- Por hash (suppress): `schemaIgnore:{formId}:{hash}`, `schemaSnooze:{formId}:{hash}`, `schemaNotified:{formId}:{hash}`
|
|
668
736
|
- Comportamento:
|
|
669
|
-
- Quando
|
|
670
|
-
-
|
|
671
|
-
-
|
|
737
|
+
- Quando existe uma config persistida para o `formId`, o componente normaliza a config local, baixa o schema estrutural canônico e reconcilia `fieldMetadata` antes de montar o formulário.
|
|
738
|
+
- Essa reconciliação preserva customizações locais intencionais, incluindo campos com `source: "local"`, `transient: true` e `submitPolicy`, mas atualiza semântica server-backed publicada pelo schema.
|
|
739
|
+
- Campos de select publicados com `x-ui.endpoint` em `/options/filter` preservam `endpoint` como operação concreta e `resourcePath` como recurso dono. Isso evita usar `/filter` ou consultar schema do endpoint de options por engano.
|
|
740
|
+
- 304 em verificações posteriores apenas atualiza `lastVerifiedAt` e emite `schemaStatusChange(outdated=false)`.
|
|
741
|
+
- 200 em verificações posteriores atualiza `serverHash/lastVerifiedAt`, define `schemaOutdated = enableCustomization && hadBase` e emite `schemaStatusChange`.
|
|
672
742
|
- Primeira vez (sem base): baixa o corpo do schema para gerar o layout; persiste `form-schema-meta:{formId}`.
|
|
673
743
|
- Notificações respeitam preferências e são one‑shot por hash; o banner/snackbar oferecem ações para Reconciliar, Lembrar depois (snooze) e Ignorar.
|
|
674
744
|
|