Class: NitroKit::Textarea
- Defined in:
- app/components/nitro_kit/textarea.rb
Constant Summary collapse
- WRAPS =
%i[soft hard off].freeze
- OWNED_ATTRIBUTES =
%i[ id name value placeholder disabled readonly required autocomplete rows cols minlength maxlength wrap ].freeze
Constants inherited from Component
Component::ADDITIVE_DATA_ATTRIBUTES, Component::COMPONENT_OWNED_DATA_ATTRIBUTES, Component::FORBIDDEN_ATTRIBUTES, Component::RESERVED_DATA_ATTRIBUTES
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(id: nil, name: nil, value: nil, placeholder: nil, disabled: false, readonly: false, required: false, autocomplete: nil, rows: nil, cols: nil, minlength: nil, maxlength: nil, wrap: nil, html: {}, aria: {}, data: {}, desperately_need_a_class: nil) ⇒ Textarea
constructor
A new instance of Textarea.
- #view_template ⇒ Object
Constructor Details
#initialize(id: nil, name: nil, value: nil, placeholder: nil, disabled: false, readonly: false, required: false, autocomplete: nil, rows: nil, cols: nil, minlength: nil, maxlength: nil, wrap: nil, html: {}, aria: {}, data: {}, desperately_need_a_class: nil) ⇒ Textarea
Returns a new instance of Textarea.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/components/nitro_kit/textarea.rb', line 11 def initialize( id: nil, name: nil, value: nil, placeholder: nil, disabled: false, readonly: false, required: false, autocomplete: nil, rows: nil, cols: nil, minlength: nil, maxlength: nil, wrap: nil, html: {}, aria: {}, data: {}, desperately_need_a_class: nil ) @value = value disabled = validate_boolean!(:disabled, disabled) readonly = validate_boolean!(:readonly, readonly) required = validate_boolean!(:required, required) rows = validate_positive_integer!(:rows, rows) cols = validate_positive_integer!(:cols, cols) minlength = validate_non_negative_integer!(:minlength, minlength) maxlength = validate_non_negative_integer!(:maxlength, maxlength) if minlength && maxlength && minlength > maxlength raise ArgumentError, "minlength cannot exceed maxlength" end wrap = validate_choice!(:wrap, wrap.to_s.to_sym, WRAPS) unless wrap.nil? reject_owned_attributes!(html) super( component: :textarea, attributes: { id:, name:, placeholder:, disabled:, readonly:, required:, autocomplete:, rows:, cols:, minlength:, maxlength:, wrap: }.compact, html:, aria:, data:, desperately_need_a_class: ) end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
67 68 69 |
# File 'app/components/nitro_kit/textarea.rb', line 67 def value @value end |
Instance Method Details
#view_template ⇒ Object
69 70 71 |
# File 'app/components/nitro_kit/textarea.rb', line 69 def view_template textarea(**root_attributes) { plain(value.to_s) } end |