Class: BetterUi::General::Input::Datetime::Component
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- BetterUi::General::Input::Datetime::Component
- Defined in:
- app/components/better_ui/general/input/datetime/component.rb
Constant Summary collapse
- DATETIME_INPUT_THEME =
Temi supportati per il Datetime Input
{ default: 'border-gray-300 focus:border-blue-500 focus:ring-blue-500', white: 'border-white focus:border-gray-300 focus:ring-gray-300 bg-white', red: 'border-red-300 focus:border-red-500 focus:ring-red-500', rose: 'border-rose-300 focus:border-rose-500 focus:ring-rose-500', orange: 'border-orange-300 focus:border-orange-500 focus:ring-orange-500', green: 'border-green-300 focus:border-green-500 focus:ring-green-500', blue: 'border-blue-300 focus:border-blue-500 focus:ring-blue-500', yellow: 'border-yellow-300 focus:border-yellow-500 focus:ring-yellow-500', violet: 'border-violet-300 focus:border-violet-500 focus:ring-violet-500' }.freeze
- DATETIME_INPUT_SIZES =
Dimensioni supportate per il Datetime Input
{ small: 'h-8 px-2 py-1 text-xs', medium: 'h-10 px-3 py-2 text-sm', large: 'h-12 px-4 py-3 text-base' }.freeze
- DATETIME_INPUT_RADIUS =
Border radius supportati per il Datetime Input
{ none: 'rounded-none', small: 'rounded-sm', medium: 'rounded-md', large: 'rounded-lg', full: 'rounded-full' }.freeze
- DATETIME_INPUT_TYPES =
Tipi supportati per il Datetime Input
[ :date, :month, :week, :time ].freeze
- DATETIME_FORMAT_PATTERNS =
Formati di validazione per tipo
{ date: /^\d{4}-\d{2}-\d{2}$/, month: /^\d{4}-\d{2}$/, week: /^\d{4}-W\d{2}$/, time: /^\d{2}:\d{2}$/ }.freeze
- DATETIME_INPUT_BASE_CLASSES =
Classi base per il Datetime Input
'block w-full border shadow-sm disabled:bg-gray-100 disabled:cursor-not-allowed focus:outline-none focus:ring-1'
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.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#rounded ⇒ Object
readonly
Returns the value of attribute rounded.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#form_field_method ⇒ Object
Metodo helper per Rails form builder specifico per tipo.
-
#form_input_attributes ⇒ Object
Attributi per l’elemento input con form builder.
-
#initialize(name:, type: :date, value: nil, required: false, disabled: false, min: nil, max: nil, theme: :default, size: :medium, rounded: :medium, classes: '', form: nil, **options) ⇒ Component
constructor
A new instance of Component.
-
#input_attributes ⇒ Object
Attributi per l’elemento input standalone.
Constructor Details
#initialize(name:, type: :date, value: nil, required: false, disabled: false, min: nil, max: nil, theme: :default, size: :medium, rounded: :medium, classes: '', form: nil, **options) ⇒ Component
Returns a new instance of Component.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/components/better_ui/general/input/datetime/component.rb', line 69 def initialize(name:, type: :date, value: nil, required: false, disabled: false, min: nil, max: nil, theme: :default, size: :medium, rounded: :medium, classes: '', form: nil, **) @name = name @type = type @value = value @required = required @disabled = disabled @min = min @max = max @theme = theme @size = size @rounded = rounded @classes = classes @form = form = validate_params super() end |
Instance Attribute Details
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
8 9 10 |
# File 'app/components/better_ui/general/input/datetime/component.rb', line 8 def classes @classes end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
8 9 10 |
# File 'app/components/better_ui/general/input/datetime/component.rb', line 8 def disabled @disabled end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
8 9 10 |
# File 'app/components/better_ui/general/input/datetime/component.rb', line 8 def form @form end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
8 9 10 |
# File 'app/components/better_ui/general/input/datetime/component.rb', line 8 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
8 9 10 |
# File 'app/components/better_ui/general/input/datetime/component.rb', line 8 def min @min end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'app/components/better_ui/general/input/datetime/component.rb', line 8 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'app/components/better_ui/general/input/datetime/component.rb', line 8 def end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
8 9 10 |
# File 'app/components/better_ui/general/input/datetime/component.rb', line 8 def required @required end |
#rounded ⇒ Object (readonly)
Returns the value of attribute rounded.
8 9 10 |
# File 'app/components/better_ui/general/input/datetime/component.rb', line 8 def rounded @rounded end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
8 9 10 |
# File 'app/components/better_ui/general/input/datetime/component.rb', line 8 def size @size end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
8 9 10 |
# File 'app/components/better_ui/general/input/datetime/component.rb', line 8 def theme @theme end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'app/components/better_ui/general/input/datetime/component.rb', line 8 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
8 9 10 |
# File 'app/components/better_ui/general/input/datetime/component.rb', line 8 def value @value end |
Instance Method Details
#form_field_method ⇒ Object
Metodo helper per Rails form builder specifico per tipo
116 117 118 119 120 121 122 123 124 |
# File 'app/components/better_ui/general/input/datetime/component.rb', line 116 def form_field_method case @type when :date then :date_field when :month then :month_field when :week then :week_field when :time then :time_field else :date_field end end |
#form_input_attributes ⇒ Object
Attributi per l’elemento input con form builder
105 106 107 108 109 110 111 112 113 |
# File 'app/components/better_ui/general/input/datetime/component.rb', line 105 def form_input_attributes { class: build_classes, required: @required, disabled: @disabled, min: @min, max: @max }.compact.merge() end |
#input_attributes ⇒ Object
Attributi per l’elemento input standalone
90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'app/components/better_ui/general/input/datetime/component.rb', line 90 def input_attributes { type: @type, name: @name, id: @name, value: @value, required: @required, disabled: @disabled, min: @min, max: @max, class: build_classes }.compact.merge() end |