Sha256: e56f3f5d900e5ab1d576aa2ccc79550a6be120a6abcc4ea617cf9564634f045c
Contents?: true
Size: 974 Bytes
Versions: 5
Compression:
Stored size: 974 Bytes
Contents
module Lookbook class ParamsEditor::Field::Component < Lookbook::BaseComponent attr_reader :name 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 escaped_value = helpers.raw json_escape(value.to_json) "{name: '#{name}', value: #{escaped_value}}" end def alpine_component "paramsEditorFieldComponent" end end end
Version data entries
5 entries across 5 versions & 1 rubygems