1use leptos::{html, prelude::*};
2
3#[derive(Clone)]
4pub struct TextareaRef {
5 pub(super) textarea_ref: NodeRef<html::Textarea>,
6}
7
8impl TextareaRef {
9 pub fn focus(&self) {
11 if let Some(textarea_el) = self.textarea_ref.get_untracked() {
12 _ = textarea_el.focus();
13 }
14 }
15
16 pub fn blur(&self) {
18 if let Some(textarea_el) = self.textarea_ref.get_untracked() {
19 _ = textarea_el.blur();
20 }
21 }
22}
23
24#[derive(Clone, Default)]
25pub enum TextareaResize {
26 #[default]
27 None,
28 Both,
29 Horizontal,
30 Vertical,
31}
32
33impl TextareaResize {
34 pub fn as_str(&self) -> &'static str {
35 match self {
36 TextareaResize::None => "none",
37 TextareaResize::Both => "both",
38 TextareaResize::Horizontal => "horizontal",
39 TextareaResize::Vertical => "vertical",
40 }
41 }
42}
43
44#[derive(Debug, Default, PartialEq, Clone, Copy)]
45pub enum TextareaSize {
46 Small,
47 #[default]
48 Medium,
49 Large,
50}
51
52impl TextareaSize {
53 pub fn as_str(&self) -> &'static str {
54 match self {
55 Self::Small => "small",
56 Self::Medium => "medium",
57 Self::Large => "large",
58 }
59 }
60}