Skip to content

feat(core): add field layout defaults and section width inheritance - #133

Merged
lattln merged 1 commit into
mainfrom
132-wrapped-default
Aug 3, 2026
Merged

feat(core): add field layout defaults and section width inheritance#133
lattln merged 1 commit into
mainfrom
132-wrapped-default

Conversation

@lattln

@lattln lattln commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Overview

This change introduces registry-driven default layout behavior for eSheet fields. Fields now receive sensible default widths and option layouts based on their field type, while sections can control the row width of their descendants.

The builder, renderer, custom field packages, documentation, and test coverage have all been updated to use the same layout rules.

What Changed

Field Type Defaults

The core field registry now defines default properties for built-in field types.

Text, selection, rating, and similar input fields default to:

  • width: 'third'

Matrix, rich, display, media, and container fields default to:

  • width: 'full'

The following option-based fields default to horizontal wrapping:

  • multitext
  • radio
  • check
  • openchoice

The new getDefaultProp API provides access to these registry defaults.

Section Width Inheritance

Section widths are now inherited by their descendants.

For example, a section with width: 'half' causes its child fields to render using half-row width. Nested sections can define their own width, which takes precedence over the outer section.

The new getInheritedSectionWidth helper resolves the nearest configured section width.

Builder Updates

The builder now uses registry defaults when displaying field properties.

The edit panel includes controls for:

  • Section row width
  • Child row width
  • Option layout

When a selected value matches the field type’s default, the property is removed from the saved definition. This keeps schemas smaller and preserves the distinction between defaults and explicit overrides.

Renderer and Field Updates

The field grid now resolves width in this order:

  1. Inherited section width
  2. Explicit field width
  3. Registry default width
  4. Full-width fallback

Radio, checkbox, open-choice, and multi-text fields now resolve their option layout from registry metadata when no explicit value is present.

Custom Field Packages

The following custom field types now explicitly default to full width:

  • Health allergy list
  • Health medication list
  • Kerebron rich text

Documentation

Updated:

  • Schema format documentation
  • FHIR extension documentation

The documentation now describes field-category defaults instead of treating full width and stacked options as universal defaults.

Tests Added

Coverage was added for:

  • Built-in field type layout metadata
  • Registry default property lookup
  • Default properties applied during field creation
  • Inherited section widths
  • Nested section precedence
  • Renderer behavior for section-controlled child widths

Relevant tests include:

  • normalize.spec.ts
  • registry.spec.ts
  • form-store.spec.ts
  • EsheetRenderer.spec.tsx

Compatibility

This is backward-compatible with existing schemas:

  • Explicit width values remain supported.
  • Explicit optionLayout values remain supported.
  • Existing schemas without these properties receive the new field-type defaults.
  • No database or schema migration is required.

+ Add registry-backed default widths and option layouts for built-in fields.

+ Apply default widths and wrapped options across the builder and renderer, including inherited section widths for nested fields. Add editor controls for section and child widths while keeping default values out of saved schemas.

+ Update health and rich-text field defaults, documentation, and tests covering registry defaults, normalization, form creation, and rendering.
@lattln lattln linked an issue Aug 3, 2026 that may be closed by this pull request
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying esheet with  Cloudflare Pages  Cloudflare Pages

Latest commit: de9a3b7
Status: ✅  Deploy successful!
Preview URL: https://fcbab88f.esheet.pages.dev
Branch Preview URL: https://132-wrapped-default.esheet.pages.dev

View logs

@lattln lattln changed the title feat(layout): add field-type defaults and section width inheritance feat(core): add field layout defaults and section width inheritance Aug 3, 2026
@lattln
lattln merged commit 90e5164 into main Aug 3, 2026
3 of 5 checks passed
@lattln
lattln deployed to production August 3, 2026 20:50 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wrapped look should be the default for forms

1 participant