singlestage/components/dialog/close.rs
1use leptos::prelude::*;
2
3#[component]
4pub fn DialogClose(
5 // GLOBAL ATTRIBUTES
6 //
7 /// A space separated list of keys to focus this element. The first key available on the user's
8 /// keyboard layout is used.
9 #[prop(optional, into)]
10 accesskey: MaybeProp<String>,
11 /// Sets whether the input value should be capitalized and how. If a parent `<form>` has
12 /// `autocapitalize` rules set, it will override any rules set here.
13 ///
14 /// Accepted values: "none" or "off" | "sentences" or "on" | "words" | "characters".
15 #[prop(optional, into)]
16 autocapitalize: MaybeProp<String>,
17 /// Grabs focus once the page has finished loading. Only one element on the page can be focused
18 /// at a time.
19 #[prop(optional, into)]
20 autofocus: MaybeProp<bool>,
21 /// Apply classes to the element.
22 #[prop(optional, into)]
23 class: MaybeProp<String>,
24 /// Allows client-side editing of the element by the user.
25 ///
26 /// Accepted values: "true" | "false" | "plaintext-only"
27 #[prop(optional, into)]
28 contenteditable: MaybeProp<String>,
29 /// Indicate directionality of the element's text.
30 ///
31 /// Accepted values: "ltr" | "rtl" | "auto"
32 #[prop(optional, into)]
33 dir: MaybeProp<String>,
34 /// Toggle whether the element can be dragged.
35 #[prop(optional, into)]
36 draggable: MaybeProp<bool>,
37 /// Modifies the appearance of the enter key on virtual keyboards.
38 #[prop(optional, into)]
39 enterkeyhint: MaybeProp<String>,
40 /// Expose elements in the shadow DOM to be manipulated by the DOM.
41 #[prop(optional, into)]
42 exportparts: MaybeProp<String>,
43 /// Controls hidden status of the element.
44 #[prop(optional, into)]
45 hidden: MaybeProp<String>,
46 /// Set the id of this element.
47 #[prop(optional, into)]
48 id: MaybeProp<String>,
49 /// Toggle if the browser reacts to input events from this element.
50 #[prop(optional, into)]
51 inert: MaybeProp<bool>,
52 /// Hints to the browser of what type of virtual keyboard to display when editing this element
53 /// or its children.
54 #[prop(optional, into)]
55 inputmode: MaybeProp<String>,
56 /// Used to render a standard element as a custom element.
57 #[prop(optional, into)]
58 is: MaybeProp<String>,
59 /// Unique global identifier of an item.
60 #[prop(optional, into)]
61 itemid: MaybeProp<String>,
62 /// Used to add properties to an item.
63 #[prop(optional, into)]
64 itemprop: MaybeProp<String>,
65 /// Used to associate an item with a related non-parent element that's using `itemscope`.
66 #[prop(optional, into)]
67 itemref: MaybeProp<String>,
68 /// Used to declare that children elements are related to a particular item.
69 #[prop(optional, into)]
70 itemscope: MaybeProp<String>,
71 /// URL of data used to define `itemprops`.
72 #[prop(optional, into)]
73 itemtype: MaybeProp<String>,
74 /// Defines the language of an element.
75 #[prop(optional, into)]
76 lang: MaybeProp<String>,
77 /// Cryptographic "number used once".
78 #[prop(optional, into)]
79 nonce: MaybeProp<String>,
80 /// List of the part names of the element.
81 #[prop(optional, into)]
82 part: MaybeProp<String>,
83 /// Designate an element as a popover element.
84 #[prop(optional, into)]
85 popover: MaybeProp<String>,
86 /// Define the semantic meaning of content.
87 #[prop(optional, into)]
88 role: MaybeProp<String>,
89 /// Assigns a slot to an element.
90 #[prop(optional, into)]
91 slot: MaybeProp<String>,
92 /// Toggle spellcheck for this input.
93 ///
94 /// Accepted values: "default" | "true" | "false".
95 #[prop(optional, into)]
96 spellcheck: MaybeProp<String>,
97 /// Define CSS to be applied to the element.
98 #[prop(optional, into)]
99 style: MaybeProp<String>,
100 /// Controls how an element behaves when a user navigates using the tab key.
101 #[prop(optional, into)]
102 tabindex: MaybeProp<usize>,
103 /// Describes the content of the element to screen readers.
104 #[prop(optional, into)]
105 title: MaybeProp<String>,
106 /// Defines localization behavior for the element.
107 #[prop(optional, into)]
108 translate: MaybeProp<String>,
109
110 // BUTTON ATTRIBUTES
111 //
112 /// Set the default behavior of the button.
113 ///
114 /// Accepted values: "submit" | "reset" | "button"
115 #[prop(optional, into)]
116 button_type: MaybeProp<String>,
117 /// The action that's performed by the element this button controls.
118 ///
119 /// Accepted values: "show-modal" | "close" | "request-close" | "show-popover" | "hide-popover"
120 /// | "toggle-popover" | "--[custom value]"
121 #[prop(optional, into)]
122 command: MaybeProp<String>,
123 /// Turn this button into a command button for an element via id.
124 #[prop(optional, into)]
125 commandfor: MaybeProp<String>,
126 /// Toggle whether or not the input is disabled.
127 #[prop(optional, into)]
128 disabled: MaybeProp<bool>,
129 /// Associate this element with a form element that may not be its parent by its `id`.
130 #[prop(optional, into)]
131 form: MaybeProp<String>,
132 /// Defines the target for submitted form data. Overrides any parent `<form>` `action` values.
133 #[prop(optional, into)]
134 formaction: MaybeProp<String>,
135 /// Defines the encoding type for submitted form data. Overrides any parent `<form>`
136 /// `formenctype` values.
137 ///
138 /// Accepted values: "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain".
139 #[prop(optional, into)]
140 formenctype: MaybeProp<String>,
141 /// Defines the HTTP method used to submit form data. Overrides any parent `<form>` `method`
142 /// values.
143 ///
144 /// Accepted values: "get" | "post" | "dialog".
145 #[prop(optional, into)]
146 formmethod: MaybeProp<String>,
147 /// Toggle whether the form data is validated or not before submission. Overrides any parent
148 /// `<form>` `novalidate` values.
149 #[prop(optional, into)]
150 formnovalidate: MaybeProp<bool>,
151 /// Defines where to display the response received after submission. Overrides any parent
152 /// `<form>` `target` values.
153 ///
154 /// Accepted values: "_self" | "_blank" | "_parent" | "_top", or the `name` of any tab, window,
155 /// or iframe
156 #[prop(optional, into)]
157 formtarget: MaybeProp<String>,
158 /// Name of this element. Submitted with the form as part of a name/value pair.
159 #[prop(optional, into)]
160 name: MaybeProp<String>,
161 /// Id of a popover to control.
162 #[prop(optional, into)]
163 popovertarget: MaybeProp<String>,
164 /// The action to perform on the target popover.
165 ///
166 /// Accepted values: "hide" | "show" | "toggle"
167 #[prop(optional, into)]
168 popovertargetaction: MaybeProp<String>,
169 /// The value associated with this button.
170 #[prop(optional, into)]
171 value: MaybeProp<String>,
172) -> impl IntoView {
173 let global_attrs_1 = view! {
174 <{..}
175 accesskey=move || accesskey.get()
176 autocapitalize=move || autocapitalize.get()
177 autofocus=move || autofocus.get()
178 class=move || class.get()
179 contenteditable=move || contenteditable.get()
180 dir=move || dir.get()
181 draggable=move || draggable.get()
182 enterkeyhint=move || enterkeyhint.get()
183 exportparts=move || exportparts.get()
184 hidden=move || hidden.get()
185 id=move || id.get()
186 inert=move || inert.get()
187 inputmode=move || inputmode.get()
188 is=move || is.get()
189 itemid=move || itemid.get()
190 />
191 };
192
193 let global_attrs_2 = view! {
194 <{..}
195 itemprop=move || itemprop.get()
196 itemref=move || itemref.get()
197 itemscope=move || itemscope.get()
198 itemtype=move || itemtype.get()
199 lang=move || lang.get()
200 nonce=move || nonce.get()
201 part=move || part.get()
202 popover=move || popover.get()
203 role=move || role.get()
204 slot=move || slot.get()
205 spellcheck=move || spellcheck.get()
206 style=move || style.get()
207 tabindex=move || tabindex.get()
208 title=move || title.get()
209 translate=move || translate.get()
210 />
211 };
212
213 let button_attrs = view! {
214 <{..}
215 command=move || command.get()
216 commandfor=move || commandfor.get()
217 disabled=move || disabled.get()
218 form=move || form.get()
219 formaction=move || formaction.get()
220 formenctype=move || formenctype.get()
221 formmethod=move || formmethod.get()
222 formnovalidate=move || formnovalidate.get()
223 formtarget=move || formtarget.get()
224 name=move || name.get()
225 popovertarget=move || popovertarget.get()
226 popovertargetaction=move || popovertargetaction.get()
227 type=move || button_type.get()
228 value=move || value.get()
229 />
230 };
231
232 view! {
233 <form method="dialog">
234 <button
235 aria-label="Close dialog"
236
237 {..global_attrs_1}
238 {..global_attrs_2}
239 {..button_attrs}
240 >
241 <svg
242 xmlns="http://www.w3.org/2000/svg"
243 width="24"
244 height="24"
245 viewBox="0 0 24 24"
246 fill="none"
247 stroke="currentColor"
248 stroke-width="2"
249 stroke-linecap="round"
250 stroke-linejoin="round"
251 class="lucide lucide-x-icon lucide-x"
252 >
253 <path d="M18 6 6 18" />
254 <path d="m6 6 12 12" />
255 </svg>
256 </button>
257 </form>
258 }
259}