class Ariadne::BaseComponent

:nodoc:

def audited_at(date = nil)

def audited_at(date = nil)
  if date.present?
    @audited_at = date
  else
    @audited_at
  end
end

def class_for(name)

def class_for(name)
  # @tag isolated-styles
  # stripping away UI and Component
  modulename = self.class.name.split("::")[1...-1].join("--").downcase
  "ariadne-#{modulename}-#{name}"
end

def component(name, ...)

Support relative component names within components
def component(name, ...)
  return super unless name.starts_with?(".")
  full_name = Pathname.new(File.join(self.class.component_name, name)).cleanpath.to_s
  super(full_name, ...)
end

def component_id(&block)

def component_id(&block)
  @component_id ||= block || proc { self.class.component_name.delete_prefix("ui/").gsub(/[^a-z0-9]+/, "-") }
end

def component_id

def component_id
  @component_id ||= instance_eval(&self.class.component_id)
end

def component_name

def component_name
  @component_name ||= name.sub(/::Component$/, "").underscore
end

def generate_id(base_name: stimulus_name)

def generate_id(base_name: stimulus_name)
  "#{base_name}-#{SecureRandom.uuid}"
end

def html_attributes

def html_attributes
  tag.attributes(html_attrs.except(:class))
end

def i18n_scope

def i18n_scope
  @i18n_scope ||= component_name.split("/")
end

def merge_data_attributes(html_attrs, component_data_attrs)

combines incoming user-defined data attributes with the component's data attributes
def merge_data_attributes(html_attrs, component_data_attrs)
  html_attrs[:data] ||= {}
  html_attrs[:data].tap do |_html_attrs_data|
    component_data_attrs.keys.each do |key|
      html_attrs[:data][key] ||= ""
      html_attrs[:data][key] = "#{html_attrs[:data][key]} #{component_data_attrs[key]}".strip
    end
  end
end

def merge_tailwind_classes(classes)

def merge_tailwind_classes(classes)
  Ariadne::ViewComponents.tailwind_merger.merge(classes)
end

def options

def options
  @options ||= self.class.dry_initializer.attributes(self)
end

def stimulus_name

def stimulus_name
  # @tag stimulus-id
  @stimulus_name ||= component_name.gsub(/[^a-z0-9]+/, "-")
end

def translate(key, scope: nil, **options)

def translate(key, scope: nil, **options)
  I18n.t(key, **options, scope: [*i18n_scope, *Array.wrap(scope)])
end

def validate_aria_label!(html_attrs)

def validate_aria_label!(html_attrs)
  aria_label = aria(html_attrs, "label")
  aria_labelledby = aria(html_attrs, "labelledby")
  raise ArgumentError, "`aria-label` or `aria-labelledby` is required." if aria_label.blank? && aria_labelledby.blank?
end