Sha256: c2db26a251dd9f3134a51b40f44fd977b702425d97215073e109e2135d798435
Contents?: true
Size: 888 Bytes
Versions: 3
Compression:
Stored size: 888 Bytes
Contents
module Lookbook class ParamsEditor::Field::Component < Lookbook::Component def initialize(input:, name:, default: nil, value: nil, input_type: nil, type: nil, options: nil, **html_attrs) @input = input @name = name @value = value @default_value = default @input_type = input_type @type = type @options = options super(**html_attrs) end def label @name.titleize end def value val = @value.presence || @default_value @type == "Boolean" ? val == "true" || val == true : val end def field_type @input.to_s end def input_type @input_type.nil? && field_type == "text" ? "text" : @input_type end protected def alpine_data "{name: '#{@name}', value: #{value.to_json}}" end def alpine_component "paramsEditorFieldComponent" end end end
Version data entries
3 entries across 3 versions & 1 rubygems