Class: LightningUiKit::TextareaComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- LightningUiKit::TextareaComponent
- Includes:
- Errors
- Defined in:
- app/components/lightning_ui_kit/textarea_component.rb
Instance Method Summary collapse
- #data ⇒ Object
- #description_data ⇒ Object
- #error_data ⇒ Object
-
#initialize(name:, value: nil, autofocus: false, label: nil, form: nil, type: :text, error: nil, description: nil, disabled: false, multiple: false, rows: 3, cols: nil, **options) ⇒ TextareaComponent
constructor
A new instance of TextareaComponent.
- #input_data ⇒ Object
- #label_data ⇒ Object
Methods included from Errors
#error_messages, #has_errors?, #infer_errors_from_association
Methods inherited from BaseComponent
Methods included from HeroiconHelper
Constructor Details
#initialize(name:, value: nil, autofocus: false, label: nil, form: nil, type: :text, error: nil, description: nil, disabled: false, multiple: false, rows: 3, cols: nil, **options) ⇒ TextareaComponent
Returns a new instance of TextareaComponent.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/components/lightning_ui_kit/textarea_component.rb', line 6 def initialize(name:, value: nil, autofocus: false, label: nil, form: nil, type: :text, error: nil, description: nil, disabled: false, multiple: false, rows: 3, cols: nil, **) @name = name @value = value @disabled = disabled @autofocus = autofocus @rows = rows @multiple = multiple @cols = cols @error = error @label = label @form = form @type = type @description = description = end |
Instance Method Details
#data ⇒ Object
22 23 24 |
# File 'app/components/lightning_ui_kit/textarea_component.rb', line 22 def data [:data] || {} end |
#description_data ⇒ Object
42 43 44 45 46 47 48 |
# File 'app/components/lightning_ui_kit/textarea_component.rb', line 42 def description_data {slot: "description"}.merge([:description_data] || {}).tap do |data| if @disabled data[:disabled] = "true" end end end |
#error_data ⇒ Object
50 51 52 53 54 55 56 |
# File 'app/components/lightning_ui_kit/textarea_component.rb', line 50 def error_data {slot: "error"}.merge([:error_data] || {}).tap do |data| if @disabled data[:disabled] = "true" end end end |
#input_data ⇒ Object
26 27 28 29 30 31 32 |
# File 'app/components/lightning_ui_kit/textarea_component.rb', line 26 def input_data ([:input_data] || {}).tap do |data| if has_errors? data[:invalid] = "true" end end end |
#label_data ⇒ Object
34 35 36 37 38 39 40 |
# File 'app/components/lightning_ui_kit/textarea_component.rb', line 34 def label_data {slot: "label"}.merge([:label_data] || {}).tap do |data| if @disabled data[:disabled] = "true" end end end |