fiberplane_models/providers/schema/fields/
text_field.rs1#[cfg(feature = "fp-bindgen")]
2use fp_bindgen::prelude::Serializable;
3use serde::{Deserialize, Serialize};
4
5#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq)]
9#[cfg_attr(
10 feature = "fp-bindgen",
11 derive(Serializable),
12 fp(rust_module = "fiberplane_models::providers")
13)]
14#[non_exhaustive]
15#[serde(rename_all = "camelCase")]
16pub struct TextField {
17 pub label: String,
19
20 pub multiline: bool,
22
23 pub multiple: bool,
25
26 pub name: String,
29
30 pub placeholder: String,
32
33 pub prerequisites: Vec<String>,
38
39 pub required: bool,
41
42 pub supports_suggestions: bool,
44}
45
46impl TextField {
47 pub fn new() -> Self {
49 Default::default()
50 }
51
52 pub fn multiline(self) -> Self {
54 Self {
55 multiline: true,
56 ..self
57 }
58 }
59
60 pub fn multiple(self) -> Self {
62 Self {
63 multiple: true,
64 ..self
65 }
66 }
67
68 pub fn required(self) -> Self {
70 Self {
71 required: true,
72 ..self
73 }
74 }
75
76 pub fn with_label(self, label: impl Into<String>) -> Self {
77 Self {
78 label: label.into(),
79 ..self
80 }
81 }
82
83 pub fn with_name(self, name: impl Into<String>) -> Self {
84 Self {
85 name: name.into(),
86 ..self
87 }
88 }
89
90 pub fn with_placeholder(self, placeholder: impl Into<String>) -> Self {
91 Self {
92 placeholder: placeholder.into(),
93 ..self
94 }
95 }
96
97 pub fn with_prerequisites(self, prerequisites: impl Into<Vec<String>>) -> Self {
98 Self {
99 prerequisites: prerequisites.into(),
100 ..self
101 }
102 }
103
104 pub fn with_suggestions(self) -> Self {
106 Self {
107 supports_suggestions: true,
108 ..self
109 }
110 }
111}