File tree Expand file tree Collapse file tree 3 files changed +77
-0
lines changed
Expand file tree Collapse file tree 3 files changed +77
-0
lines changed Original file line number Diff line number Diff line change 3030 - [ padding] ( ./templates/elements/padding.md )
3131 - [ canvas] ( ./templates/elements/canvas.md )
3232 - [ container] ( ./templates/elements/container.md )
33+ - [ Inputs and other components] ( ./anathema-extras.md )
34+ - [ Inputs and other components] ( ./anathema-extras/input.md )
Original file line number Diff line number Diff line change 1+ # Some generic components are worked on and maintained by core developers
2+
3+ To use these components add ` anathema-extras ` as a dependency to ` Cargo.toml `
4+
5+ ```
6+ [dependencies]
7+ anathema-extras = { version = "0.1" }
8+ ```
9+
10+ * [ Input (single line)] ( ./anathema-extras/input.md )
11+
Original file line number Diff line number Diff line change 1+ # Input
2+
3+ A single line input field.
4+
5+ ``` rust
6+ builder
7+ . default :: <Input >(" input" , Input :: template ())
8+ . unwrap ();
9+
10+ ```
11+
12+ The input component can be registered as a prototype as well.
13+
14+ ``` rust
15+ builder
16+ . prototype (" input" , Input :: template (), Input :: new , InputState :: new )
17+ . unwrap ();
18+
19+ ```
20+
21+ ## Supported events:
22+
23+ The following events are provided:
24+
25+ ### ` on_enter `
26+
27+ The enter key was pressed.
28+ This event publishes ` anathema_extras::Text ` , which implements ` Deref<str> ` .
29+
30+ ### ` on_change `
31+
32+ A change was made to the text (insert or remove).
33+ This event publishes ` anathema_extras::InputChange ` .
34+
35+ ### ` on_focus `
36+
37+ The input component gained focus.
38+ This event publishes ` () ` .
39+
40+ ### ` on_blur `
41+
42+ The input component lost focus.
43+ This event publishes ` () ` .
44+
45+ ## Attributes
46+
47+ ### ` clear_on_enter `
48+
49+ If the desired outcome is to retain the text when the enter key is pressed set
50+ this attribute to false.
51+
52+ ```
53+ @input [clear_on_enter: false]
54+ ```
55+
56+ ## Example
57+
58+ ```
59+ vstack
60+ @input (on_enter->update_label_a)
61+ @input (on_enter->update_label_b)
62+ ```
63+
64+ # Button
You can’t perform that action at this time.
0 commit comments