Class: BetterUi::General::Input::Select::Component
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- BetterUi::General::Input::Select::Component
- Defined in:
- app/components/better_ui/general/input/select/component.rb
Constant Summary collapse
- SELECT_THEME =
Costanti con classi Tailwind dirette
{ default: 'border-gray-300 text-gray-800 focus:border-gray-600 focus:ring-gray-600', white: 'border-gray-300 text-gray-900 focus:border-gray-500 focus:ring-gray-500', red: 'border-gray-300 text-red-600 focus:border-red-500 focus:ring-red-500', rose: 'border-gray-300 text-rose-600 focus:border-rose-500 focus:ring-rose-500', orange: 'border-gray-300 text-orange-600 focus:border-orange-500 focus:ring-orange-500', green: 'border-gray-300 text-green-600 focus:border-green-500 focus:ring-green-500', blue: 'border-gray-300 text-blue-600 focus:border-blue-500 focus:ring-blue-500', yellow: 'border-gray-300 text-yellow-600 focus:border-yellow-500 focus:ring-yellow-500', violet: 'border-gray-300 text-violet-600 focus:border-violet-500 focus:ring-violet-500' }.freeze
- SELECT_SIZE =
{ small: 'px-2 py-1.5 text-xs', medium: 'px-3 py-2 text-sm', large: 'px-4 py-3 text-base' }.freeze
- SELECT_ROUNDED =
{ none: 'rounded-none', small: 'rounded-sm', medium: 'rounded', large: 'rounded-lg', full: 'rounded-full' }.freeze
- SELECT_BASE_CLASSES =
'block w-full bg-white border-2 shadow-sm focus:outline-none focus:ring-2 focus:ring-offset-2 transition-colors duration-200'.freeze
Instance Attribute Summary collapse
-
#classes ⇒ Object
readonly
Returns the value of attribute classes.
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#html_options ⇒ Object
readonly
Returns the value of attribute html_options.
-
#max_height ⇒ Object
readonly
Returns the value of attribute max_height.
-
#multiple ⇒ Object
readonly
Returns the value of attribute multiple.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#placeholder ⇒ Object
readonly
Returns the value of attribute placeholder.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#rounded ⇒ Object
readonly
Returns the value of attribute rounded.
-
#search_placeholder ⇒ Object
readonly
Returns the value of attribute search_placeholder.
-
#searchable ⇒ Object
readonly
Returns the value of attribute searchable.
-
#selected ⇒ Object
readonly
Returns the value of attribute selected.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
Instance Method Summary collapse
-
#initialize(name:, options:, selected: nil, required: false, disabled: false, multiple: false, searchable: true, theme: :default, size: :medium, rounded: :medium, placeholder: nil, search_placeholder: nil, max_height: "300px", form: nil, classes: '', **html_options) ⇒ Component
constructor
A new instance of Component.
Constructor Details
#initialize(name:, options:, selected: nil, required: false, disabled: false, multiple: false, searchable: true, theme: :default, size: :medium, rounded: :medium, placeholder: nil, search_placeholder: nil, max_height: "300px", form: nil, classes: '', **html_options) ⇒ Component
Returns a new instance of Component.
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 |
# File 'app/components/better_ui/general/input/select/component.rb', line 57 def initialize( name:, options:, selected: nil, required: false, disabled: false, multiple: false, searchable: true, theme: :default, size: :medium, rounded: :medium, placeholder: nil, search_placeholder: nil, max_height: "300px", form: nil, classes: '', ** ) @name = name @options = @selected = normalize_selected(selected) @required = required @disabled = disabled @multiple = multiple @searchable = searchable @theme = theme.to_sym @size = size.to_sym @rounded = rounded.to_sym @placeholder = placeholder || (multiple ? "Seleziona opzioni..." : "Seleziona...") @search_placeholder = search_placeholder || "Cerca..." @max_height = max_height @form = form @classes = classes @html_options = validate_params end |
Instance Attribute Details
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
37 38 39 |
# File 'app/components/better_ui/general/input/select/component.rb', line 37 def classes @classes end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
37 38 39 |
# File 'app/components/better_ui/general/input/select/component.rb', line 37 def disabled @disabled end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
37 38 39 |
# File 'app/components/better_ui/general/input/select/component.rb', line 37 def form @form end |
#html_options ⇒ Object (readonly)
Returns the value of attribute html_options.
37 38 39 |
# File 'app/components/better_ui/general/input/select/component.rb', line 37 def @html_options end |
#max_height ⇒ Object (readonly)
Returns the value of attribute max_height.
37 38 39 |
# File 'app/components/better_ui/general/input/select/component.rb', line 37 def max_height @max_height end |
#multiple ⇒ Object (readonly)
Returns the value of attribute multiple.
37 38 39 |
# File 'app/components/better_ui/general/input/select/component.rb', line 37 def multiple @multiple end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
37 38 39 |
# File 'app/components/better_ui/general/input/select/component.rb', line 37 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
37 38 39 |
# File 'app/components/better_ui/general/input/select/component.rb', line 37 def @options end |
#placeholder ⇒ Object (readonly)
Returns the value of attribute placeholder.
37 38 39 |
# File 'app/components/better_ui/general/input/select/component.rb', line 37 def placeholder @placeholder end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
37 38 39 |
# File 'app/components/better_ui/general/input/select/component.rb', line 37 def required @required end |
#rounded ⇒ Object (readonly)
Returns the value of attribute rounded.
37 38 39 |
# File 'app/components/better_ui/general/input/select/component.rb', line 37 def rounded @rounded end |
#search_placeholder ⇒ Object (readonly)
Returns the value of attribute search_placeholder.
37 38 39 |
# File 'app/components/better_ui/general/input/select/component.rb', line 37 def search_placeholder @search_placeholder end |
#searchable ⇒ Object (readonly)
Returns the value of attribute searchable.
37 38 39 |
# File 'app/components/better_ui/general/input/select/component.rb', line 37 def searchable @searchable end |
#selected ⇒ Object (readonly)
Returns the value of attribute selected.
37 38 39 |
# File 'app/components/better_ui/general/input/select/component.rb', line 37 def selected @selected end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
37 38 39 |
# File 'app/components/better_ui/general/input/select/component.rb', line 37 def size @size end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
37 38 39 |
# File 'app/components/better_ui/general/input/select/component.rb', line 37 def theme @theme end |