Class: Charming::Components::Form::Note
- Inherits:
-
Field
- Object
- View
- Charming::Component
- Field
- Charming::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.
12 13 14 15 |
# File 'lib/charming/presentation/components/form/note.rb', line 12 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.
18 19 20 |
# File 'lib/charming/presentation/components/form/note.rb', line 18 def bind(state) @state = state end |
#focusable? ⇒ Boolean
Notes are never focusable and therefore excluded from Tab/Enter traversal.
23 24 25 |
# File 'lib/charming/presentation/components/form/note.rb', line 23 def focusable? false end |
#render(active: false) ⇒ Object
Returns the literal text, ignoring the active: flag (notes have no focus state).
33 34 35 |
# File 'lib/charming/presentation/components/form/note.rb', line 33 def render(active: false) @text.to_s end |
#validate ⇒ Object
Notes never produce validation errors.
28 29 30 |
# File 'lib/charming/presentation/components/form/note.rb', line 28 def validate [] end |