Class: HakumiComponents::Table::EllipsisConfig

Inherits:
Object
  • Object
show all
Extended by:
T::Helpers, T::Sig
Defined in:
app/components/hakumi_components/table/ellipsis_config.rb

Direct Known Subclasses

Simple, WithTooltip

Defined Under Namespace

Modules: TooltipConfigBuilder Classes: Simple, TooltipConfig, WithTooltip

Constant Summary collapse

InputValue =
T.type_alias { HakumiComponents::Table::DefinitionTypes::ConfigInputValue }
InputHash =
T.type_alias { HakumiComponents::Table::DefinitionTypes::ConfigInputHash }
Input =
T.type_alias do
  T.nilable(T.any(
    T::Boolean,
    String,
    InputHash
  ))
end

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_input(input) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'app/components/hakumi_components/table/ellipsis_config.rb', line 81

def self.from_input(input)
  return nil if input.nil? || input == false
  return Simple.new(show_title: true) if input == true

  if input.is_a?(Hash)
    normalized = input.deep_symbolize_keys
    tooltip = TooltipConfigBuilder.build(coerce_tooltip_input(normalized[:tooltip]))
    show = normalized[:show_title] == true
    return tooltip ? WithTooltip.new(show_title: show, tooltip: tooltip) : Simple.new(show_title: show)
  end

  # String input → tooltip whose title is the string itself
  tooltip = TooltipConfigBuilder.build(input)
  return nil unless tooltip

  WithTooltip.new(show_title: false, tooltip: tooltip)
end

Instance Method Details

#show_titleObject



78
# File 'app/components/hakumi_components/table/ellipsis_config.rb', line 78

def show_title; end