Sha256: d9507d5760f29233895a2bfc7a90b21adad0ed01cccdd5516f2924fc1c9ff705
Contents?: true
Size: 963 Bytes
Versions: 4
Compression:
Stored size: 963 Bytes
Contents
module Lookbook class ParamsEditor::Field::Component < Lookbook::BaseComponent 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 = value.is_a?(String) ? helpers.j(value) : value "{name: '#{@name}', value: '#{escaped_value}'}" end def alpine_component "paramsEditorFieldComponent" end end end
Version data entries
4 entries across 4 versions & 1 rubygems