Class: ViewComponent::Storybook::Controls::MultiOptions

Inherits:
BaseOptions show all
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

#labels, #options, #type

Attributes inherited from Control

#default, #description, #name, #param

Instance Method Summary collapse

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: 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_paramsObject



24
25
26
# File 'lib/view_component/storybook/controls/multi_options.rb', line 24

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