Sha256: 931e6bd475a5064d172fc4f350a7cf1ef821657eba726ccea912609dac804828

Contents?: true

Size: 564 Bytes

Versions: 46

Compression:

Stored size: 564 Bytes

Contents

module Lookbook
  module DisplayOptions
    class Field::Component < Lookbook::BaseComponent
      attr_reader :name, :value

      def initialize(name:, opts:, value:, **html_attrs)
        @name = name
        @opts = opts
        @value = value
        super(**html_attrs)
      end

      def choices
        @opts.is_a?(Hash) ? @opts[:choices].to_a : @opts
      end

      protected

      def alpine_data
        "{name: '#{name}', value: '#{value}'}"
      end

      def alpine_component
        "displayOptionsFieldComponent"
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
lookbook-1.3.4 app/components/lookbook/display_options/field/component.rb
lookbook-1.3.3 app/components/lookbook/display_options/field/component.rb
lookbook-1.3.1 app/components/lookbook/display_options/field/component.rb
lookbook-1.3.0 app/components/lookbook/display_options/field/component.rb
lookbook-1.2.1 app/components/lookbook/display_options/field/component.rb
lookbook-1.2.0 app/components/lookbook/display_options/field/component.rb