Repository navigation
feat: add Stepper control - #41
Merged
Merged
Conversation
Add stepper and stepper_step (alias stepperstep) helpers with the Stepper and Step wire types. CLASS_MAP also registers step, but no public step helper is defined (D-6). current_step defaults to 0 and type to vertical; the type prop is stored after super because it collides with Ruflet::Control's own type keyword.
AdamMusa
force-pushed
the
feat/stepper
branch
from
October 28, 2026 04:53
086dd7f to
ef603fe
Compare
D-6 means no public `step` name at all. A "step" CLASS_MAP key became a Rails view helper (define_registry_helpers!) and made Kernel#method_missing build a Step control for any object calling step(...). Drop the key and register the child only as stepper_step/stepperstep, with TYPE "stepper_step" so registry lookups by type still resolve. The wire type stays "Step".
2 tasks
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 the Ruby side of
Stepperand itsStepchild type (Work Package F, item F1).Engine counterpart (renderer): AdamMusa/ruflet-engine#25
Usage
API
controls/materials/stepper_control.rb:StepperControl, TYPEstepper, WIREStepper.cancel_text clip_behavior connector_color connector_thickness continue_text controls current_step elevation show_controls steps typeplus the common layout keywords.on_step_cancel on_step_continue on_step_tap(pluson_animation_end on_size_change).current_step = 0andtype = "vertical".controls/materials/step_control.rb:StepControl, TYPEstepper_step, WIREStep.content data is_active key label state subtitle title visible.ArgumentErrorwhentitleis missing.stepper,stepper_stepandstepperstepin the materials and top-level registries. There is nostepkey (see the D-6 section below).stepper(steps = nil, **props, &block),stepper_step(**props)andstepperstepare inmaterial_control_methods.rb,shared_control_forwarders.rbanddsl.rb. There is nostephelper.change, soPagenever writes them back into props. The stepper is controlled by your handlers.Deviation:
typecollides withRuflet::Control#initialize(type:)The spec's
typekeyword (vertical or horizontal) has the same name as the base class's control-type keyword. Passing it throughsuper(type: TYPE, **props)would silently replaceTYPE, and the control would serialize as_c: "Horizontal".StepperControltherefore stores@props["type"]aftersuper. The wire key staystype, as the spec and the Dart renderer expect, andcontrol.typestays"stepper". A test covers this throughRuflet.stepper,Ruflet.control(:stepper, type: ...)andpage.update.D-6: no public
stepname (second commit)An earlier version of this PR registered a
"step"CLASS_MAP key, as the SPEC suggested, so thatRuflet.control(:step)would work. That key leaked a publicstepname in two places:Ruflet::Rails::HtmlDsl::ViewHelpers.define_registry_helpers!defines a view helper for everyControlFactory::CLASS_MAPkey. Every Rails view gotstep, which clashes with wicked and similar gems.Kernel#method_missing. It builds a control for any nameControlFactory.known_control?accepts. Sostep(title: ...)on any object returned a Step control instead of raisingNoMethodError.The second commit (
fix: keep the Stepper child off the public step name):"step"key from both registries;stepper_stepthroughbuild_widget(:stepper_step);StepControl::TYPEfrom"step"to"stepper_step". The TYPE is the control's registry type, and lookups that go through it, such asControl#schema_class_for_validation,CLASS_MAP[type]and the Rails transformer'sregistry_props, must resolve to a real key.to_patchtakes the wire name fromWIRE, so it is still"Step". The Dart renderer needed no change.New tests:
"step"key, andknown_control?(:step)is false whileknown_control?(:stepper_step)is true;Object.new.respond_to?(:step)is false, including private methods;Object.new.instance_eval { step(title: "x") }raisesNoMethodError; before the fix it returned a StepControl;stepper(steps: [stepper_step(title: ...)])serializes_c: "Step"children, andstepper_step(...).type == "stepper_step".test/html_dsl_helpers_test.rb):ControlFactory::CLASS_MAP.keysthatdefine_registry_helpers!iterates: there is no"step",ViewHelpersdefines no public or privatestep, and a view does not respond tostep;stepper,stepper_stepandstepperstephelpers exist;<%= stepper do stepper_step(title: ...) end %>markup round-trips through the transformer to aStepperwithStepchildren.Notes for review
Ruflet::DSLapp scripts, astepper_step(...)passed in thesteps:list is also attached as a page root. This is the existing behaviour for every typed child list (segment,data_column, ...), becauseDSL::App#controlalways attaches. The block form avoids it. It is not changed here.stepper,stepper_stepandstepperstephelpers fromdefine_registry_helpers!. They do not getstep.Tests
test/stepper_compatibility_test.rb(12 runs, 76 assertions). It covers:_cand the serialized props for Stepper and Step (string and Control titles, state, label);typecollision, includingpage.update(type:);controls;steps:serializingStepchildren;Ruflet::DSLhelpers;has_handler?for all three events;page.dispatch_eventforstep_tap,step_continueandstep_cancelreaches the handlers withe.valueand does not movecurrent_step.test/html_dsl_helpers_test.rb: 2 new tests (20 runs in that file).verify_pr.shwithRUBY_PKGS="ruflet_core ruflet_rails"after rebasing ontoorigin/main:test_every_registry_control_is_reachable_from_markup;