Class: HakumiComponents::Autocomplete::Component
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- HakumiComponents::Autocomplete::Component
- Extended by:
- T::Sig
- Includes:
- Concerns::SelectionControl
- Defined in:
- app/components/hakumi_components/autocomplete/component.rb
Constant Summary collapse
- InputRenderer =
T.type_alias do T.proc.params(attrs: Types::HtmlAttributes).returns(T.any(String, ActiveSupport::SafeBuffer)) end
- VARIANTS =
T.let(%i[outlined filled borderless underlined].freeze, T::Array[Symbol])
- STATUSES =
T.let(%i[error warning].freeze, T::Array[Symbol])
- FILTER_MODES =
T.let(%i[contains starts_with].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
Instance Method Summary collapse
Methods included from Concerns::SelectionControl
#selection_control_allow_clear, #selection_control_contract, #selection_control_disabled, #selection_control_has_value?, #selection_control_placeholder, #selection_control_size, #selection_control_value
Methods included from Concerns::SelectionControlInterface
#selection_control_allow_clear, #selection_control_contract, #selection_control_disabled, #selection_control_has_value?, #selection_control_placeholder, #selection_control_size, #selection_control_value
Methods included from Concerns::FormField
#describedby_ids, #error?, #error_message, #form_field_caption, #form_field_contract, #form_field_errors, #form_field_html_options, #form_field_label, #form_field_name, #form_field_required, #form_field_rules, #form_field_standalone, #form_item_attributes, #form_item_classes, #input_id, #render_caption, #render_error, #render_explain, #render_label, #standalone?
Methods included from Concerns::FormFieldInterface
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(name:, options: [], label: nil, caption: nil, value: nil, placeholder: nil, size: :default, variant: :outlined, status: nil, disabled: false, required: false, allow_clear: false, clear_icon: :close_circle, input_renderer: nil, case_sensitive: false, filter_mode: :contains, not_found_content: nil, standalone: true, rules: nil, errors: [], **html_options) ⇒ Component
Returns a new instance of Component.
44 45 46 47 48 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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'app/components/hakumi_components/autocomplete/component.rb', line 44 def initialize( name:, options: [], label: nil, caption: nil, value: nil, placeholder: nil, size: :default, variant: :outlined, status: nil, disabled: false, required: false, allow_clear: false, clear_icon: :close_circle, input_renderer: nil, case_sensitive: false, filter_mode: :contains, not_found_content: nil, standalone: true, rules: nil, errors: [], ** ) @name = T.let(name, Types::FormFieldName) @options = T.let(HakumiComponents::SelectionControl::Coercion.entries(Array()), T::Array[HakumiComponents::SelectionControl::Entry]) @label = label @caption = caption @value = T.let(value, Types::FormFieldValue) @placeholder = placeholder @size = size @variant = variant @status = status @disabled = disabled @required = required @allow_clear = allow_clear @clear_icon = clear_icon @input_renderer = T.let(input_renderer, T.nilable(InputRenderer)) @case_sensitive = case_sensitive @filter_mode = filter_mode @not_found_content = not_found_content @standalone = standalone @rules = T.let(rules, T.nilable(T::Array[Types::ValidationRule])) @errors = T.let(errors, Types::FormFieldErrors) @html_options = T.let(, Types::HtmlAttributes) initialize_selection_control_contract!( name: @name, label: @label, caption: @caption, value: @value, placeholder: @placeholder, size: @size, disabled: @disabled, allow_clear: @allow_clear, required: @required, standalone: @standalone, errors: @errors, html_options: @html_options, rules: @rules ) validate_props! end |