Class: HakumiComponents::Modal::Component

Inherits:
BaseComponent
  • Object
show all
Extended by:
T::Sig
Defined in:
app/components/hakumi_components/modal/component.rb

Constant Summary

Constants inherited from BaseComponent

BaseComponent::ControllerOptions, BaseComponent::DateInput, BaseComponent::DateLikeValue, BaseComponent::DimensionInput, BaseComponent::HtmlPayloadInput, BaseComponent::I18nOptionValue, BaseComponent::PresenceArray, BaseComponent::PresenceScalar, BaseComponent::PresenceValue, BaseComponent::RawHtmlInput, BaseComponent::SIZES, BaseComponent::SizeValue, BaseComponent::SymbolInput

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseComponent

#append_data_token, boolean_html_param, #build_inline_style, cast_boolean, #cast_boolean, #class_names, #component_classes, #data_attributes_from, #dimension_to_css, #ensure_dom_id!, float_html_param, #generate_id, #html_classes, html_param, html_primitive_param, #html_style, #i18n_scope, integer_html_param, #merge_attributes, #render_value, #size_to_pixels, #stimulus_attrs, string_html_param, string_or_symbol_array_html_param, symbol_html_param, #t_default, #translate_with_default, #validate_inclusion!, #validate_required!, #value_present?

Constructor Details

#initialize(title: nil, message: nil, open: false, width: 520, centered: false, closable: true, mask: true, mask_closable: true, keyboard: true, confirm_loading: false, **html_options) ⇒ Component

Returns a new instance of Component.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/components/hakumi_components/modal/component.rb', line 49

def initialize(
  title: nil,
  message: nil,
  open: false,
  width: 520,
  centered: false,
  closable: true,
  mask: true,
  mask_closable: true,
  keyboard: true,
  confirm_loading: false,
  **html_options
)
  @title = T.let(title, HakumiComponents::Types::Renderable)
  @message = T.let(message, HakumiComponents::Types::Renderable)
  @open = T.let(cast_boolean(open) ? true : false, T::Boolean)
  @width = T.let(width, T.any(Integer, String))
  @centered = T.let(cast_boolean(centered) ? true : false, T::Boolean)
  @closable = T.let(cast_boolean(closable) != false, T::Boolean)
  @mask = T.let(cast_boolean(mask) != false, T::Boolean)
  @mask_closable = T.let(cast_boolean(mask_closable) != false, T::Boolean)
  @keyboard = T.let(cast_boolean(keyboard) != false, T::Boolean)
  @confirm_loading = T.let(cast_boolean(confirm_loading) ? true : false, T::Boolean)
  @html_options = T.let(html_options, HakumiComponents::Types::HtmlAttributes)
end

Class Method Details

.extract_controller_locals(params) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/components/hakumi_components/modal/component.rb', line 19

def self.extract_controller_locals(params)
  {
    title: html_primitive_param(html_param(params, :title)),
    message: html_primitive_param(html_param(params, :message)),
    open: boolean_html_param(html_param(params, :open)),
    width: integer_html_param(html_param(params, :width)),
    centered: boolean_html_param(html_param(params, :centered)),
    closable: boolean_html_param(html_param(params, :closable)),
    mask: boolean_html_param(html_param(params, :mask)),
    mask_closable: boolean_html_param(html_param(params, :mask_closable)),
    keyboard: boolean_html_param(html_param(params, :keyboard)),
    confirm_loading: boolean_html_param(html_param(params, :confirm_loading))
  }
end