Class: Inquirex::UI::DSL::StepBuilder
- Inherits:
-
DSL::StepBuilder
- Object
- DSL::StepBuilder
- Inquirex::UI::DSL::StepBuilder
- Defined in:
- lib/inquirex/ui/dsl/step_builder.rb
Overview
Extends Inquirex::DSL::StepBuilder with widget rendering hint methods. Used by FlowBuilder whenever a step block is evaluated inside Inquirex::UI.define.
Additional DSL methods:
:radio_group, columns: 2 # desktop/default hint
:dropdown # mobile-specific hint
Instance Method Summary collapse
-
#build(id) ⇒ UI::Node
Builds a UI::Node with widget hints (explicit or registry defaults).
-
#initialize(verb) ⇒ StepBuilder
constructor
A new instance of StepBuilder.
-
#widget(type:, target: :desktop, **opts) ⇒ Object
Sets a rendering hint for the given target context.
Constructor Details
#initialize(verb) ⇒ StepBuilder
Returns a new instance of StepBuilder.
13 14 15 16 |
# File 'lib/inquirex/ui/dsl/step_builder.rb', line 13 def initialize(verb) super @widget_hints = {} end |
Instance Method Details
#build(id) ⇒ UI::Node
Builds a UI::Node with widget hints (explicit or registry defaults).
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/inquirex/ui/dsl/step_builder.rb', line 37 def build(id) effective_type = resolve_type hints = @widget_hints.dup # Fill in registry defaults for any targets not explicitly set. %i[desktop mobile].each do |target| hints[target] ||= WidgetRegistry.default_hint_for(effective_type, context: target) end hints.compact! UI::Node.new( id:, verb: @verb, type: effective_type, question: @question, text: @text, options: @options, transitions: @transitions, skip_if: @skip_if, default: @default, widget_hints: hints.empty? ? nil : hints ) end |
#widget(type:, target: :desktop, **opts) ⇒ Object
Sets a rendering hint for the given target context. Call once per target. Recognized targets: :desktop, :mobile (and any future targets adapters may define).
29 30 31 |
# File 'lib/inquirex/ui/dsl/step_builder.rb', line 29 def (type:, target: :desktop, **opts) @widget_hints[target.to_sym] = WidgetHint.new(type:, options: opts) end |