feat: conditional control visibility via visibleWhen#30
Open
Mekwek wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
withVisibility(control, rule)helper andVisibleWhentype, exported from react / solid / svelte / vue entry pointsfilterByVisibilityruns onregisterPanel,updatePanel,updateValue,loadPreset, andclearActivePresetunwrapVisibilityutility used by all four framework hooks (eliminates duplicated unwrap logic)/conditionalexercises scalar, array, boolean, nested folder, and transition control visibility in combinationAlso fixes
updateTransitionModenot auto-saving the mode to the active preset or baseValues (same pattern as theloadPresetfix; discovered while testing the demo across multiple preset versions).Why
Fully opt-in — configs without the
withVisibilitywrapper behave exactly as before. Zero DOM changes, zero CSS changes, no impact on existing theme customizations or consumers with custom DialKit styles.The
isVisibleevaluator 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)/conditionaldemo, PhotoStack demo, and Release demo — all functional