Skip to content

feat: conditional control visibility via visibleWhen#30

Open
Mekwek wants to merge 1 commit into
joshpuckett:mainfrom
Mekwek:feat/conditional-visibility
Open

feat: conditional control visibility via visibleWhen#30
Mekwek wants to merge 1 commit into
joshpuckett:mainfrom
Mekwek:feat/conditional-visibility

Conversation

@Mekwek
Copy link
Copy Markdown

@Mekwek Mekwek commented Apr 10, 2026

Adds a store-layer conditional visibility feature so controls can be shown or hidden based on other controls' values in the same panel.

What changed

  • New withVisibility(control, rule) helper and VisibleWhen type, exported from react / solid / svelte / vue entry points
  • Store-level evaluation: filterByVisibility runs on registerPanel, updatePanel, updateValue, loadPreset, and clearActivePreset
  • Empty folders are pruned recursively when all children become hidden
  • Hidden controls retain their values across hide/show cycles
  • Exported unwrapVisibility utility used by all four framework hooks (eliminates duplicated unwrap logic)
  • Example demo at /conditional exercises scalar, array, boolean, nested folder, and transition control visibility in combination

Also fixes updateTransitionMode not auto-saving the mode to the active preset or baseValues (same pattern as the loadPreset fix; discovered while testing the demo across multiple preset versions).

Why

Fully opt-in — configs without the withVisibility wrapper behave exactly as before. Zero DOM changes, zero CSS changes, no impact on existing theme customizations or consumers with custom DialKit styles.

The isVisible evaluator and empty-folder pruner are direct ports from a production app with conditional visibility rules across multiple UI surfaces.

A follow-up PR (stacked on this branch) adds smooth enter/exit animations for conditional controls.

Validation

  • npm run build
  • npm run typecheck ✓ (pre-existing Svelte DialRoot error unrelated)
  • Tested on /conditional demo, PhotoStack demo, and Release demo — all functional

Adds a store-layer conditional visibility feature so controls can be
shown or hidden based on other controls' values in the same panel.

- New withVisibility(control, rule) helper and VisibleWhen type,
  exported from react / solid / svelte / vue entry points
- Store-level evaluation: filterByVisibility runs on registerPanel,
  updatePanel, updateValue, loadPreset, and clearActivePreset
- Empty folders are pruned recursively when all children become hidden
- Hidden controls retain their values across hide/show cycles
- Example demo at /conditional exercises scalar, array, boolean,
  nested folder, and transition control visibility in combination

Also fixes updateTransitionMode not auto-saving the mode to the active
preset or baseValues (same pattern as the loadPreset fix; discovered
while testing the demo across multiple preset versions).

Fully opt-in — configs without the withVisibility wrapper behave
exactly as before. Zero DOM changes, zero CSS changes, no impact on
existing theme customizations or consumers with custom DialKit styles.

A follow-up PR adds smooth enter/exit animations for conditional
controls without introducing any DOM wrapping layer.
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.

1 participant