Class: Charming::Presentation::Components::Form::Note
- Inherits:
-
Field
- Object
- View
- Charming::Presentation::Component
- Field
- Charming::Presentation::Components::Form::Note
- Defined in:
- lib/charming/presentation/components/form/note.rb
Overview
Note is a non-interactive Form field that renders a static string of text. Notes never receive focus, never validate, and store no value — they are presentational only, useful for headings, dividers, or instructional text inside a form.
Instance Attribute Summary
Attributes inherited from Field
Instance Method Summary collapse
-
#bind(state) ⇒ Object
Binds the field to the form state but does not create any per-field storage.
-
#focusable? ⇒ Boolean
Notes are never focusable and therefore excluded from Tab/Enter traversal.
-
#initialize(text, name: :note, theme: nil) ⇒ Note
constructor
text is the literal string to render.
-
#render(active: false) ⇒ Object
Returns the literal text, ignoring the active: flag (notes have no focus state).
-
#validate ⇒ Object
Notes never produce validation errors.
Methods inherited from Field
Methods inherited from View
Constructor Details
#initialize(text, name: :note, theme: nil) ⇒ Note
text is the literal string to render. name is unused (defaults to :note) and exists only because the Field base class requires a name.
13 14 15 16 |
# File 'lib/charming/presentation/components/form/note.rb', line 13 def initialize(text, name: :note, theme: nil) super(name, theme: theme) @text = text end |
Instance Method Details
#bind(state) ⇒ Object
Binds the field to the form state but does not create any per-field storage.
19 20 21 |
# File 'lib/charming/presentation/components/form/note.rb', line 19 def bind(state) @state = state end |
#focusable? ⇒ Boolean
Notes are never focusable and therefore excluded from Tab/Enter traversal.
24 25 26 |
# File 'lib/charming/presentation/components/form/note.rb', line 24 def focusable? false end |
#render(active: false) ⇒ Object
Returns the literal text, ignoring the active: flag (notes have no focus state).
34 35 36 |
# File 'lib/charming/presentation/components/form/note.rb', line 34 def render(active: false) @text.to_s end |
#validate ⇒ Object
Notes never produce validation errors.
29 30 31 |
# File 'lib/charming/presentation/components/form/note.rb', line 29 def validate [] end |