Class: Polaris::AutocompleteComponent
- Defined in:
- app/components/polaris/autocomplete_component.rb
Constant Summary
Constants included from ViewHelper
ViewHelper::POLARIS_HELPERS, ViewHelper::POLARIS_TEXT_STYLES
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Method Summary collapse
-
#initialize(form: nil, attribute: nil, name: nil, multiple: false, url: nil, selected: [], popover_arguments: {}, **system_arguments) ⇒ AutocompleteComponent
constructor
A new instance of AutocompleteComponent.
- #option_list_arguments ⇒ Object
- #popover_arguments ⇒ Object
- #system_arguments ⇒ Object
Methods included from ViewHelper
#polaris_body_styles, #polaris_html_classes, #polaris_html_styles, #polaris_icon_source
Methods included from StylesListHelper
Methods included from OptionHelper
#append_option, #prepend_option
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #fetch_or_fallback_nested
Methods included from ClassNameHelper
Constructor Details
#initialize(form: nil, attribute: nil, name: nil, multiple: false, url: nil, selected: [], popover_arguments: {}, **system_arguments) ⇒ AutocompleteComponent
Returns a new instance of AutocompleteComponent.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/components/polaris/autocomplete_component.rb', line 24 def initialize( form: nil, attribute: nil, name: nil, multiple: false, url: nil, selected: [], popover_arguments: {}, **system_arguments ) @form = form @attribute = attribute @name = name @multiple = multiple @url = url @selected = selected @popover_arguments = popover_arguments @system_arguments = system_arguments end |
Instance Method Details
#option_list_arguments ⇒ Object
70 71 72 73 74 |
# File 'app/components/polaris/autocomplete_component.rb', line 70 def option_list_arguments { data: {polaris_autocomplete_target: "results"} } end |
#popover_arguments ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/components/polaris/autocomplete_component.rb', line 57 def popover_arguments { alignment: :left, full_width: true, inline: false, text_field_activator: true, wrapper_arguments: {} }.deep_merge(@popover_arguments).tap do |opts| opts[:wrapper_arguments][:data] ||= {} prepend_option(opts[:wrapper_arguments][:data], :polaris_autocomplete_target, "popover") end end |
#system_arguments ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/components/polaris/autocomplete_component.rb', line 44 def system_arguments @system_arguments.tap do |opts| opts[:tag] = "div" opts[:data] ||= {} opts[:data][:controller] = "polaris-autocomplete" if @url.present? opts[:data][:polaris_autocomplete_url_value] = @url end opts[:data][:polaris_autocomplete_selected_value] = @selected opts[:data][:polaris_autocomplete_multiple_value] = @multiple if @multiple.present? end end |