module Coco class Popover < Coco::Component include Concerns::AcceptsOptions accepts_option :theme, from: ["netural", "info"], default: "neutral" accepts_option :trigger, from: ["click", "manual", "hover"], default: "click" accepts_option :placement, from: %w[top top-start top-end right right-start right-end bottom bottom-start bottom-end left left-start left-end auto auto-start auto-end], default: "auto", private: true before_initialize do |kwargs| [:placement, :trigger, :theme].each do |key| kwargs[key] = kwargs[key].to_s.tr("_", "-") if kwargs.key?(key) end kwargs end attr_reader :target def initialize(target: nil, options: {}, **) @target = target @options = options end def trigger (get_option_value(:trigger) == "hover") ? "mouseenter focus" : get_option_value(:trigger) end def options { placement: get_option_value(:placement), **@options } end end end