Class: HakumiComponents::Popconfirm::Component
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- HakumiComponents::Popconfirm::Component
- Extended by:
- T::Sig
- Defined in:
- app/components/hakumi_components/popconfirm/component.rb
Constant Summary collapse
- Placement =
T.type_alias { T.any(Symbol, String) }
- Trigger =
T.type_alias { T.any(Symbol, String) }
- ButtonType =
T.type_alias { T.any(Symbol, String) }
- PLACEMENTS =
T.let(%i[ top topLeft topRight bottom bottomLeft bottomRight left leftTop leftBottom right rightTop rightBottom auto ].freeze, T::Array[Symbol])
- TRIGGERS =
T.let(%i[click hover focus].freeze, T::Array[Symbol])
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
- #data_attributes ⇒ Object
-
#initialize(placement: :top, trigger: :click, disabled: false, ok_type: :primary, show_cancel: true, auto_adjust_overflow: true, **html_options) ⇒ Component
constructor
A new instance of Component.
- #wrapper_classes ⇒ Object
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(placement: :top, trigger: :click, disabled: false, ok_type: :primary, show_cancel: true, auto_adjust_overflow: true, **html_options) ⇒ Component
Returns a new instance of Component.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/components/hakumi_components/popconfirm/component.rb', line 55 def initialize( placement: :top, trigger: :click, disabled: false, ok_type: :primary, show_cancel: true, auto_adjust_overflow: true, ** ) @placement = T.let(placement.to_sym, Symbol) @trigger = T.let(trigger.to_sym, Symbol) @disabled = T.let(disabled, T::Boolean) @ok_type = T.let(ok_type.to_sym, Symbol) @show_cancel = T.let(show_cancel, T::Boolean) @auto_adjust_overflow = T.let(auto_adjust_overflow, T::Boolean) @html_options = T.let(, HakumiComponents::Types::HtmlAttributes) validate_props! end |
Class Method Details
.extract_controller_locals(params) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'app/components/hakumi_components/popconfirm/component.rb', line 33 def self.extract_controller_locals(params) { placement: symbol_html_param(html_param(params, :placement)), trigger: symbol_html_param(html_param(params, :trigger)), disabled: boolean_html_param(html_param(params, :disabled)), ok_type: symbol_html_param(html_param(params, :ok_type)), show_cancel: boolean_html_param(html_param(params, :show_cancel) || true), auto_adjust_overflow: boolean_html_param(html_param(params, :auto_adjust_overflow) || true) }.compact end |
Instance Method Details
#data_attributes ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'app/components/hakumi_components/popconfirm/component.rb', line 89 def data_attributes data = T.let({ controller: "hakumi--popconfirm", hakumi__popconfirm_placement_value: @placement, hakumi__popconfirm_trigger_value: @trigger, hakumi__popconfirm_disabled_value: @disabled, hakumi__popconfirm_show_cancel_value: @show_cancel, hakumi__popconfirm_auto_adjust_overflow_value: @auto_adjust_overflow }, HakumiComponents::Types::DataAttributes) existing = @html_options[:data] return data unless existing.is_a?(Hash) existing.each { |key, value| data[key] = value } data end |
#wrapper_classes ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/components/hakumi_components/popconfirm/component.rb', line 76 def wrapper_classes extras = T.let([], T::Array[T.nilable(String)]) extras << "hakumi-popconfirm-disabled" if @disabled extras.concat(Array(html_classes(@html_options)).compact) class_names( "popconfirm-wrapper", {}, extras ) end |