@praxisui/dynamic-form 9.0.0-beta.4 → 9.0.0-beta.41

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
@@ -26,7 +26,7 @@ npm i @praxisui/dynamic-form@latest
26
26
  Peer dependencies:
27
27
 
28
28
  - `@angular/common`, `@angular/core`, `@angular/forms`, `@angular/cdk`, `@angular/material`, `@angular/router` `^21.0.0`
29
- - `@praxisui/ai`, `@praxisui/core`, `@praxisui/dynamic-fields`, `@praxisui/metadata-editor`, `@praxisui/rich-content`, `@praxisui/settings-panel`, `@praxisui/visual-builder` `^9.0.0-beta.4`
29
+ - `@praxisui/ai`, `@praxisui/core`, `@praxisui/dynamic-fields`, `@praxisui/metadata-editor`, `@praxisui/rich-content`, `@praxisui/settings-panel`, `@praxisui/visual-builder` `^9.0.0-beta.12`
30
30
  - `rxjs` `^7.8.0`
31
31
 
32
32
  ## Minimum Local Runtime
@@ -101,6 +101,117 @@ For schema-driven backend surfaces, prefer explicit `schemaUrl`, `submitUrl`, an
101
101
 
102
102
  When using resource, schema, read, or submit flows, the host must provide the effective API/CRUD service wiring for that scope.
103
103
 
104
+ Schema-driven layout materialization is opt-in through `layoutPolicy`. Use it when the backend
105
+ schema already publishes enough `x-ui` metadata for the runtime to build the layout without
106
+ local `FormConfig.sections`.
107
+
108
+ ```html
109
+ <praxis-dynamic-form
110
+ formId="employee-detail"
111
+ mode="view"
112
+ schemaUrl="/schemas/filtered?path=/api/employees/{id}&operation=get&schemaType=response"
113
+ [initialValue]="employee"
114
+ [layoutPolicy]="{
115
+ source: 'schema',
116
+ intent: 'detail',
117
+ preset: 'compactPresentation',
118
+ lifecycle: 'live',
119
+ persistence: 'transient',
120
+ schemaOperation: 'detail',
121
+ schemaType: 'response'
122
+ }">
123
+ </praxis-dynamic-form>
124
+ ```
125
+
126
+ For create/edit command forms, the policy must point at a request schema, normally through an
127
+ explicit `schemaUrl` containing `schemaType=request` and `operation=post|put|patch`. If the
128
+ declared `schemaUrl` conflicts with `layoutPolicy.schemaType` or `layoutPolicy.schemaOperation`,
129
+ the runtime fails initialization instead of rendering a form from the wrong business contract.
130
+
131
+ `layoutPolicy.source = "schema"` ignores authored or persisted `sections`, but preserves
132
+ non-layout host/persisted concerns such as `actions`, `api`, `messages`, rules, hooks and rich
133
+ blocks. Host-provided non-layout config has precedence over persisted config.
134
+
135
+ When `mode="view"` and the host does not provide `presentationModeGlobal`, a schema policy with
136
+ `intent: "detail"` or `preset: "compactPresentation"` also enables presentation rendering. Hosts
137
+ that need traditional disabled controls for the same schema can pass `[presentationModeGlobal]="false"`.
138
+ For compact detail screens, explicit schema `x-ui.width` values are honored as 12-column spans so
139
+ fieldsets can render multiple read-only fields per row. Fields without an explicit width remain
140
+ full-width to preserve existing layouts. Generated compact sections also receive semantic header
141
+ icons derived from their group role, while field icons continue to come from existing schema
142
+ metadata.
143
+
144
+ For fields published by the backend schema, server DTO metadata remains authoritative for semantic presentation data such as `label`, `hint`, `helpText`, `tooltip`, `tooltipOnHover`, and icon metadata. Local `FormConfig` should customize layout, grouping, transient fields, actions, and host-specific behavior, but it should not redefine DTO-owned field semantics.
145
+
146
+ Field-level access metadata follows the same authority boundary. When the backend publishes `x-ui.fieldAccess`, `@praxisui/core` preserves it in `FieldMetadata.fieldAccess` and `@praxisui/dynamic-form` can materialize it as hidden or read-only UX when the host supplies explicit `FormConfig.metadata.fieldAccessAuthorities` or enterprise runtime `authorities`. The runtime does not infer field authorities from `capabilities`; backend filtering and submit validation remain the security boundary.
147
+
148
+ Dense operational forms should keep DTO `hint`/`helpText` intact and use `FormConfig.helpPresentation` to choose the visual policy. For drawers or command forms, prefer `display: "auto"` with `preferPopoverForControls` for controls such as `toggle`, `checkbox`, and `select`; validation errors remain inline regardless of this policy. Field-level `helpDisplay` is still authoritative when present, including `helpDisplay: "auto"` for DTOs that need a local threshold.
149
+
150
+ Example backend-owned `x-ui` metadata:
151
+
152
+ ```json
153
+ {
154
+ "type": "object",
155
+ "properties": {
156
+ "frequencyType": {
157
+ "type": "string",
158
+ "x-ui": {
159
+ "label": "Frequency type",
160
+ "controlType": "async-select",
161
+ "helpText": "Select the operational class used by payroll and timekeeping rules.",
162
+ "tooltip": "Backend-owned DTO semantics; local FormConfig cannot override it.",
163
+ "tooltipOnHover": true,
164
+ "icon": "calendar_month",
165
+ "iconPosition": "start",
166
+ "iconColor": "primary",
167
+ "endpoint": "/api/frequency-types/options/filter",
168
+ "filterField": "name",
169
+ "sortField": "name",
170
+ "sortOrder": "asc",
171
+ "optionsPageSize": 20
172
+ }
173
+ }
174
+ }
175
+ }
176
+ ```
177
+
178
+ In that flow, local `FormConfig` may place `frequencyType` in sections, rows, tabs, custom actions, or corporate-only local fields. It should not persist competing `label`, `helpText`, `tooltip`, or icon metadata for `frequencyType`, because the next schema reconciliation will restore the backend DTO semantics.
179
+
180
+ ### ErgonX migration baseline
181
+
182
+ For ErgonX-style migrations, use schema-driven layout as the preferred target once the DTO/schema is semantically ready. Treat local `FormConfig.sections` as a temporary bridge, not as the standard for hundreds of screens.
183
+
184
+ Recommended defaults:
185
+
186
+ - detail/read-only: `layoutPolicy.source = "schema"`, `intent = "detail"`, `preset = "compactPresentation"`, `persistence = "transient"` and a response schema;
187
+ - create/edit: `layoutPolicy.source = "schema"`, `intent = "command"`, `preset = "groupedCommand"`, `persistence = "transient"` and a request schema;
188
+ - dense command drawers: `helpPresentation.display = "auto"` with popover preference for select, checkbox, toggle, date and numeric controls;
189
+ - operational input-heavy forms: `fieldIconPolicy = "presentation-only"` unless the icon is part of the actual affordance.
190
+
191
+ Schema-driven command forms do not need to declare empty manual sections. Keep host config focused on behavior, messages, actions and field metadata that is genuinely local:
192
+
193
+ ```ts
194
+ const commandConfig: FormConfig = {
195
+ metadata: { source: 'schema' },
196
+ behavior: {
197
+ disableMountAnimation: true,
198
+ focusFirstError: true,
199
+ scrollToErrors: true,
200
+ },
201
+ messages: {
202
+ submitSuccess: 'Registro salvo.',
203
+ submitError: 'Não foi possível salvar o registro.',
204
+ },
205
+ };
206
+ ```
207
+
208
+ Pair this config with an explicit schema source, such as `[schemaUrl]`,
209
+ `[submitUrl]`, `[submitMethod]` and, in detached hosts, `[apiEndpointKey]` or
210
+ `[apiUrlEntry]`. A sectionless config is valid only when the schema/runtime
211
+ source is the canonical owner of field grouping and controls.
212
+
213
+ Do not use Angular config to fix weak DTO semantics. Missing grouping, vague `helpText`, generic labels, raw coded values, wrong control types or absent option metadata should return to backend DTO/schema hardening. The detailed migration checklist lives in `docs/schema-driven-layout-materialization-rfc.md`.
214
+
104
215
  ## Runtime Inputs And Outputs
105
216
 
106
217
  Common inputs:
@@ -112,7 +223,7 @@ Common inputs:
112
223
  - `apiEndpointKey`, `apiUrlEntry`
113
224
  - `actions`, `layout`, `backConfig`, `hooks`
114
225
  - `enableCustomization`
115
- - `readonlyModeGlobal`, `disabledModeGlobal`, `presentationModeGlobal`, `visibleGlobal`
226
+ - `readonlyModeGlobal`, `disabledModeGlobal`, `presentationModeGlobal`, `fieldIconPolicy`, `visibleGlobal`
116
227
  - `notifyIfOutdated`, `snoozeMs`, `autoOpenSettingsOnOutdated`
117
228
  - `domainRules`
118
229
  - `editorialContext`
@@ -169,10 +280,70 @@ Do not model backend DTO fields as local/transient fields. If a field belongs to
169
280
  - `kind: "field"` references `fieldMetadata[].name`.
170
281
  - `kind: "richContent"` hosts a `RichContentDocument` and does not enter `fieldMetadata`, `formData`, or HTTP payloads.
171
282
  - `formRules` govern visibility, required state, values, labels, styles, and other whitelisted runtime properties.
283
+ - `formRulesState` is internal visual-builder state. LLMs and external tools should not write it directly.
172
284
  - `formCommandRules` are used for governed side effects such as global actions.
173
285
 
174
286
  Presentation formatting of field values is resolved by `@praxisui/dynamic-fields` from field metadata such as `valuePresentation`.
175
287
 
288
+ ### Compact Presentation Preset
289
+
290
+ For dense enterprise read-only screens, `DynamicFormLayoutService.generateFormConfigFromMetadata`
291
+ can materialize a compact presentation layout directly from governed field metadata:
292
+
293
+ ```ts
294
+ const config = layout.generateFormConfigFromMetadata(fields, {
295
+ layoutPreset: 'compactPresentation',
296
+ presentationRoleMap: {
297
+ Identificacao: 'core-attributes',
298
+ Regras: 'technical-scope',
299
+ Marcadores: 'behavior-flags',
300
+ },
301
+ });
302
+ ```
303
+
304
+ The preset keeps field semantics in `FieldMetadata`, creates compact rows from field width/data
305
+ type, derives semantic section header icons from group roles, marks generated sections with
306
+ `className: "pdx-presentation-section ..."`, and annotates
307
+ metadata with `generatedLayoutPreset: "compactPresentation"` and `presentationDensity: "compact"`.
308
+ Boolean fields are displayed through the canonical `valuePresentation: { type: "boolean" }` path,
309
+ so DTO-normalized booleans and legacy display values such as `S/N` are formatted by
310
+ `@praxisui/dynamic-fields`.
311
+
312
+ When a compact read-only screen needs operational signals, use `formBlocksBefore` with a short
313
+ `RichContentDocument` strip such as `metric` and `progress` nodes. Keep those blocks visual-only:
314
+ they must not duplicate DTO fields in `fieldMetadata`, enter `formData`, or push the first business
315
+ field below the useful viewport. Larger guidance cards, timelines, and stat groups belong in a
316
+ dedicated row, side context, or a separate rich-content demonstration tab rather than the compact
317
+ detail header.
318
+
319
+ The runtime exposes host-themeable CSS variables for this mode:
320
+
321
+ - `--pdx-presentation-label-width`
322
+ - `--pdx-presentation-label-size`
323
+ - `--pdx-presentation-value-size`
324
+ - `--pdx-presentation-row-gap`
325
+ - `--pdx-presentation-section-gap`
326
+ - `--pdx-presentation-flag-height`
327
+ - `--pdx-presentation-flag-padding`
328
+ - `--pdx-presentation-flag-radius`
329
+ - `--pdx-presentation-flag-font-size`
330
+
331
+ Use this preset for read/detail surfaces. Do not use it to replace backend DTO documentation,
332
+ business validation, or editable command forms. In table/detail workbenches, keep the table
333
+ selection and the detail `initialValue` synchronized in the host; the compact form only renders
334
+ the selected DTO state.
335
+
336
+ ## LLM-Safe Authoring Subset
337
+
338
+ For AI-generated or tool-generated configuration, prefer canonical `FormConfig` JSON and keep edits reviewable:
339
+
340
+ - Write rule suggestions to `formRules[]` with `metadata: { origin: "llm", reviewStatus: "pending" }`.
341
+ - Do not write `formRulesState`; the editor may derive it after human review when the rule is visually representable.
342
+ - Treat simple field comparisons, scalar literals, field-to-field comparisons, and `and`/`or` groups as the stable visual round-trip subset.
343
+ - Treat advanced JsonLogic such as `!`, `xor`, `implies`, `between`, `notIn`, custom functions, context operands, and computed expressions as runtime-supported JSON-only unless a focused visual round-trip test exists.
344
+ - Use only properties allowed by the target rule schema. Unsupported or sanitized properties appear in rule diagnostics and should be fixed before publication.
345
+ - Keep side effects in `formCommandRules` with structured `globalAction: { actionId, payload }`; do not encode commands inside `formRules[].effect.properties`.
346
+
176
347
  ## Visual Editor
177
348
 
178
349
  Use `PraxisDynamicFormConfigEditor` directly or enable customization on the runtime.
@@ -192,6 +363,8 @@ dialog.open(PraxisDynamicFormConfigEditor, {
192
363
 
193
364
  The editor preserves the same `FormConfig` contract used by the runtime. Field type names, descriptions, and icons come from the dynamic-fields editorial metadata chain, not from a local map inside Dynamic Form.
194
365
 
366
+ Runtime-only rules remain valid JSON when they pass diagnostics, but they may open in JSON review instead of the visual rule builder until their condition and effect shape are covered by the visual-safe subset.
367
+
195
368
  ## AI Authoring
196
369
 
197
370
  `PRAXIS_DYNAMIC_FORM_AUTHORING_MANIFEST` declares executable operations for governed edits to:
@@ -205,6 +378,8 @@ The editor preserves the same `FormConfig` contract used by the runtime. Field t
205
378
 
206
379
  The manifest is meant to keep AI-generated patches compatible with the visual editor and the runtime `FormConfig` contract.
207
380
 
381
+ Rule operations in the manifest write `formRules[]`, require pending review metadata, and intentionally avoid `formRulesState`. A valid JsonLogic condition is not automatically a visual round-trip guarantee; LLMs should use the safe subset above unless the operation explicitly targets a JSON-only/runtime-only path.
382
+
208
383
  ## Public API
209
384
 
210
385
  Main exports: