@praxisui/dynamic-form 9.0.0-beta.22 → 9.0.0-beta.25

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
@@ -101,8 +101,50 @@ 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
+
104
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.
105
145
 
146
+ 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.
147
+
106
148
  Example backend-owned `x-ui` metadata:
107
149
 
108
150
  ```json
@@ -133,6 +175,19 @@ Example backend-owned `x-ui` metadata:
133
175
 
134
176
  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.
135
177
 
178
+ ### ErgonX migration baseline
179
+
180
+ 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.
181
+
182
+ Recommended defaults:
183
+
184
+ - detail/read-only: `layoutPolicy.source = "schema"`, `intent = "detail"`, `preset = "compactPresentation"`, `persistence = "transient"` and a response schema;
185
+ - create/edit: `layoutPolicy.source = "schema"`, `intent = "command"`, `preset = "groupedCommand"`, `persistence = "transient"` and a request schema;
186
+ - dense command drawers: `helpPresentation.display = "auto"` with popover preference for select, checkbox, toggle, date and numeric controls;
187
+ - operational input-heavy forms: `fieldIconPolicy = "presentation-only"` unless the icon is part of the actual affordance.
188
+
189
+ 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`.
190
+
136
191
  ## Runtime Inputs And Outputs
137
192
 
138
193
  Common inputs:
@@ -144,7 +199,7 @@ Common inputs:
144
199
  - `apiEndpointKey`, `apiUrlEntry`
145
200
  - `actions`, `layout`, `backConfig`, `hooks`
146
201
  - `enableCustomization`
147
- - `readonlyModeGlobal`, `disabledModeGlobal`, `presentationModeGlobal`, `visibleGlobal`
202
+ - `readonlyModeGlobal`, `disabledModeGlobal`, `presentationModeGlobal`, `fieldIconPolicy`, `visibleGlobal`
148
203
  - `notifyIfOutdated`, `snoozeMs`, `autoOpenSettingsOnOutdated`
149
204
  - `domainRules`
150
205
  - `editorialContext`
@@ -206,6 +261,54 @@ Do not model backend DTO fields as local/transient fields. If a field belongs to
206
261
 
207
262
  Presentation formatting of field values is resolved by `@praxisui/dynamic-fields` from field metadata such as `valuePresentation`.
208
263
 
264
+ ### Compact Presentation Preset
265
+
266
+ For dense enterprise read-only screens, `DynamicFormLayoutService.generateFormConfigFromMetadata`
267
+ can materialize a compact presentation layout directly from governed field metadata:
268
+
269
+ ```ts
270
+ const config = layout.generateFormConfigFromMetadata(fields, {
271
+ layoutPreset: 'compactPresentation',
272
+ presentationRoleMap: {
273
+ Identificacao: 'core-attributes',
274
+ Regras: 'technical-scope',
275
+ Marcadores: 'behavior-flags',
276
+ },
277
+ });
278
+ ```
279
+
280
+ The preset keeps field semantics in `FieldMetadata`, creates compact rows from field width/data
281
+ type, derives semantic section header icons from group roles, marks generated sections with
282
+ `className: "pdx-presentation-section ..."`, and annotates
283
+ metadata with `generatedLayoutPreset: "compactPresentation"` and `presentationDensity: "compact"`.
284
+ Boolean fields are displayed through the canonical `valuePresentation: { type: "boolean" }` path,
285
+ so DTO-normalized booleans and legacy display values such as `S/N` are formatted by
286
+ `@praxisui/dynamic-fields`.
287
+
288
+ When a compact read-only screen needs operational signals, use `formBlocksBefore` with a short
289
+ `RichContentDocument` strip such as `metric` and `progress` nodes. Keep those blocks visual-only:
290
+ they must not duplicate DTO fields in `fieldMetadata`, enter `formData`, or push the first business
291
+ field below the useful viewport. Larger guidance cards, timelines, and stat groups belong in a
292
+ dedicated row, side context, or a separate rich-content demonstration tab rather than the compact
293
+ detail header.
294
+
295
+ The runtime exposes host-themeable CSS variables for this mode:
296
+
297
+ - `--pdx-presentation-label-width`
298
+ - `--pdx-presentation-label-size`
299
+ - `--pdx-presentation-value-size`
300
+ - `--pdx-presentation-row-gap`
301
+ - `--pdx-presentation-section-gap`
302
+ - `--pdx-presentation-flag-height`
303
+ - `--pdx-presentation-flag-padding`
304
+ - `--pdx-presentation-flag-radius`
305
+ - `--pdx-presentation-flag-font-size`
306
+
307
+ Use this preset for read/detail surfaces. Do not use it to replace backend DTO documentation,
308
+ business validation, or editable command forms. In table/detail workbenches, keep the table
309
+ selection and the detail `initialValue` synchronized in the host; the compact form only renders
310
+ the selected DTO state.
311
+
209
312
  ## LLM-Safe Authoring Subset
210
313
 
211
314
  For AI-generated or tool-generated configuration, prefer canonical `FormConfig` JSON and keep edits reviewable: