Class: ViewComponent::Storybook::Controls::MultiOptions
- Inherits:
-
BaseOptions
- Object
- Control
- SimpleControl
- BaseOptions
- ViewComponent::Storybook::Controls::MultiOptions
- Defined in:
- lib/view_component/storybook/controls/multi_options.rb
Constant Summary collapse
- TYPES =
%i[multi-select check inline-check].freeze
Instance Attribute Summary
Attributes inherited from BaseOptions
Attributes inherited from Control
#default, #description, #name, #param
Instance Method Summary collapse
-
#initialize(param, type:, options:, default: nil, labels: nil, name: nil, description: nil, **opts) ⇒ MultiOptions
constructor
A new instance of MultiOptions.
- #parse_param_value(value) ⇒ Object
- #to_csf_params ⇒ Object
Constructor Details
#initialize(param, type:, options:, default: nil, labels: nil, name: nil, description: nil, **opts) ⇒ MultiOptions
Returns a new instance of MultiOptions.
12 13 14 |
# File 'lib/view_component/storybook/controls/multi_options.rb', line 12 def initialize(param, type:, options:, default: nil, labels: nil, name: nil, description: nil, **opts) super(param, type: type, options: , default: Array.wrap(default), labels: labels, name: name, description: description, **opts) end |
Instance Method Details
#parse_param_value(value) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/view_component/storybook/controls/multi_options.rb', line 16 def parse_param_value(value) if value.is_a?(String) value = value.split(',') value = value.map(&:to_sym) if symbol_values end value end |
#to_csf_params ⇒ Object
24 25 26 |
# File 'lib/view_component/storybook/controls/multi_options.rb', line 24 def to_csf_params super.deep_merge(argTypes: { param => { options: } }) end |