Class: ViewComponent::Storybook::Controls::MultiOptionsConfig

Inherits:
BaseOptionsConfig show all
Defined in:
lib/view_component/storybook/controls/multi_options_config.rb

Constant Summary collapse

TYPES =
%i[multi-select check inline-check].freeze

Instance Attribute Summary

Attributes inherited from BaseOptionsConfig

#labels, #options, #type

Attributes inherited from SimpleControlConfig

#default_value

Instance Method Summary collapse

Methods inherited from ControlConfig

#description, #name, #param, #prefix_param

Constructor Details

#initialize(type, options, default_value, labels: nil, param: nil, name: nil, description: nil) ⇒ MultiOptionsConfig

Returns a new instance of MultiOptionsConfig.



12
13
14
# File 'lib/view_component/storybook/controls/multi_options_config.rb', line 12

def initialize(type, options, default_value, labels: nil, param: nil, name: nil, description: nil)
  super(type, options, Array.wrap(default_value), labels: labels, param: param, name: name, description: description)
end

Instance Method Details

#to_csf_paramsObject



26
27
28
# File 'lib/view_component/storybook/controls/multi_options_config.rb', line 26

def to_csf_params
  super.deep_merge(argTypes: { param => { options: options } })
end

#value_from_params(params) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/view_component/storybook/controls/multi_options_config.rb', line 16

def value_from_params(params)
  params_value = super(params)

  if params_value.is_a?(String)
    params_value = params_value.split(',')
    params_value = params_value.map(&:to_sym) if symbol_values
  end
  params_value
end