1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
use *;
use ;
use component_doc;
use inject_style;
use InlineDrawer;
use OverlayDrawer;
use ;
use drawer_styles;
/// Drawers slide content in from an edge — filters, settings, or auxiliary nav.
/// [`OverlayDrawer`] (alias [`Drawer`]) teleports a modal panel with backdrop;
/// [`InlineDrawer`] keeps the panel in your layout. Bind `open` with [`OpenBind`]; set
/// `position`, `size`, and whether backdrop click or Escape dismisses.
///
/// Prefer composed scrims inside [`Dialog`](crate::Dialog) and [`Backdrop`](crate::Backdrop)
/// unless you need a standalone loading overlay. Bind `open` with [`OpenBind`] at the app
/// root and pass signals down — share one `open` signal between trigger, backdrop dismiss,
/// and footer buttons rather than relying on implicit internal-only state.
///
/// # When to use
///
/// - Filters, settings, or detail panels triggered from a page action
/// - Modal overlay from an edge — `OverlayDrawer` / `Drawer`
/// - Persistent in-layout panel — `InlineDrawer`
///
/// # Usage
///
/// 1. Bind `open` with [`OpenBind`] (typically `RwSignal<bool>`).
/// 2. Choose `OverlayDrawer` for teleported modal panels or `InlineDrawer` for in-layout panels.
/// 3. Set `mask_closeable=false` when backdrop clicks should not dismiss.
/// 4. Compose [`DrawerHeader`] and [`DrawerBody`]; add [`DrawerHeaderTitleAction`] for header actions.
///
/// # Examples
///
/// ## Default drawer (inline)
/// Inline drawer stays in the preview card; an overlay trigger exercises teleported panels for migration smoke tests.
/// <!-- preview -->
/// ```rust
/// use crate::Button;
/// let open_inline = RwSignal::new(true);
/// let open_overlay = RwSignal::new(false);
/// let overlay_mount = NodeRef::<leptos::html::Div>::new();
/// view! {
/// <div data-testid="drawer-preview" style="min-height: 120px;" node_ref=overlay_mount>
/// <InlineDrawer open=open_inline>
/// <DrawerHeader>
/// <DrawerHeaderTitle>"Title"</DrawerHeaderTitle>
/// </DrawerHeader>
/// <DrawerBody>"Drawer body"</DrawerBody>
/// </InlineDrawer>
/// <Button on_click=Callback::new(move |_| open_overlay.set(true))>"Open drawer"</Button>
/// <OverlayDrawer open=open_overlay mount=Some(overlay_mount)>
/// <DrawerBody>
/// <p data-testid="drawer-overlay-body">"Overlay drawer body"</p>
/// </DrawerBody>
/// </OverlayDrawer>
/// </div>
/// }
/// ```
///
/// ## Right overlay position
/// Modal panel that slides in from the right edge—the default drawer placement for detail panels, filters, and secondary workflows triggered by a button.
/// <!-- preview -->
/// ```rust
/// use crate::Button;
/// let open = RwSignal::new(false);
/// view! {
/// <div data-testid="drawer-right">
/// <Button on_click=Callback::new(move |_| open.set(true))>"Open right"</Button>
/// <OverlayDrawer open=open position=DrawerPosition::Right>
/// <DrawerBody>
/// <p data-testid="drawer-right-content">"Right panel"</p>
/// </DrawerBody>
/// </OverlayDrawer>
/// </div>
/// }
/// ```
///
/// ## Left overlay position
/// Panel anchored to the left edge, suited for navigation rails or persistent secondary content that mirrors a sidebar pattern.
/// <!-- preview -->
/// ```rust
/// use crate::Button;
/// let open = RwSignal::new(false);
/// view! {
/// <div data-testid="drawer-left">
/// <Button on_click=Callback::new(move |_| open.set(true))>"Open left"</Button>
/// <OverlayDrawer open=open position=DrawerPosition::Left>
/// <DrawerBody>
/// <p data-testid="drawer-left-content">"Left panel"</p>
/// </DrawerBody>
/// </OverlayDrawer>
/// </div>
/// }
/// ```
///
/// ## Top overlay position
/// Panel that drops from the top of the viewport—useful for banners, quick filters, or mobile-style sheets that occupy horizontal space.
/// <!-- preview -->
/// ```rust
/// use crate::Button;
/// let open = RwSignal::new(false);
/// view! {
/// <div data-testid="drawer-top">
/// <Button on_click=Callback::new(move |_| open.set(true))>"Open top"</Button>
/// <OverlayDrawer open=open position=DrawerPosition::Top>
/// <DrawerBody>
/// <p data-testid="drawer-top-content">"Top panel"</p>
/// </DrawerBody>
/// </OverlayDrawer>
/// </div>
/// }
/// ```
///
/// ## Bottom overlay position
/// Panel that rises from the bottom edge, a common pattern for action sheets, pickers, and thumb-friendly mobile overlays.
/// <!-- preview -->
/// ```rust
/// use crate::Button;
/// let open = RwSignal::new(false);
/// view! {
/// <div data-testid="drawer-bottom">
/// <Button on_click=Callback::new(move |_| open.set(true))>"Open bottom"</Button>
/// <OverlayDrawer open=open position=DrawerPosition::Bottom>
/// <DrawerBody>
/// <p data-testid="drawer-bottom-content">"Bottom panel"</p>
/// </DrawerBody>
/// </OverlayDrawer>
/// </div>
/// }
/// ```
///
/// ## Escape closes
/// Drawer that dismisses when the user presses Escape via `close_on_esc=true`. Enable this when keyboard users should be able to exit without clicking the backdrop.
/// <!-- preview -->
/// ```rust
/// use crate::Button;
/// let open = RwSignal::new(false);
/// view! {
/// <div data-testid="drawer-esc">
/// <Button on_click=Callback::new(move |_| open.set(true))>"Open drawer"</Button>
/// <OverlayDrawer open=open close_on_esc=true>
/// <DrawerBody>
/// <p data-testid="drawer-esc-content">"Press Escape to close"</p>
/// </DrawerBody>
/// </OverlayDrawer>
/// </div>
/// }
/// ```
///
/// ## Large size
/// Wider panel preset using `size=DrawerSize::Large` for forms, multi-column detail, or content that needs more room than the default small width.
/// <!-- preview -->
/// ```rust
/// use crate::Button;
/// let open = RwSignal::new(false);
/// view! {
/// <div data-testid="drawer-size">
/// <Button on_click=Callback::new(move |_| open.set(true))>"Open large"</Button>
/// <OverlayDrawer open=open size=DrawerSize::Large>
/// <DrawerBody>
/// <p data-testid="drawer-size-content">"Large drawer panel"</p>
/// </DrawerBody>
/// </OverlayDrawer>
/// </div>
/// }
/// ```
///
/// ## Backdrop not dismissible
/// Drawer that ignores backdrop clicks via `mask_closeable=false`. Use when dismissal must happen through an explicit close action.
/// <!-- preview -->
/// ```rust
/// use crate::Button;
/// let open = RwSignal::new(false);
/// view! {
/// <div data-testid="drawer-mask-not-closeable">
/// <Button on_click=Callback::new(move |_| open.set(true))>"Open drawer"</Button>
/// <OverlayDrawer open=open mask_closeable=false>
/// <DrawerBody>
/// <p data-testid="drawer-mask-not-closeable-content">"Backdrop click does not close"</p>
/// </DrawerBody>
/// </OverlayDrawer>
/// </div>
/// }
/// ```
///
/// ## Header title action
/// Drawer header with a trailing action slot beside the title.
/// <!-- preview -->
/// ```rust
/// use crate::{Button, ButtonAppearance, DrawerHeaderTitleAction};
/// let open = RwSignal::new(true);
/// view! {
/// <div data-testid="drawer-title-action" style="min-height: 120px;">
/// <InlineDrawer open=open>
/// <DrawerHeader>
/// <DrawerHeaderTitle>
/// "Settings"
/// <DrawerHeaderTitleAction slot>
/// <Button appearance=ButtonAppearance::Subtle>"Reset"</Button>
/// </DrawerHeaderTitleAction>
/// </DrawerHeaderTitle>
/// </DrawerHeader>
/// <DrawerBody>"Drawer body"</DrawerBody>
/// </InlineDrawer>
/// </div>
/// }
/// ```
]
mask_closeable: ,
/// When true, pressing Escape closes the drawer.
close_on_esc: bool,
/// Edge the panel slides from — `Right`, `Left`, `Top`, or `Bottom`.
position: ,
/// Panel width or height preset — `Small`, `Medium`, `Large`, or `Full`.
size: ,
/// Modal blocks page interaction; non-modal allows clicking content behind the panel.
modal_type: DrawerModalType,
/// Drawer body content — forms, detail panels, or navigation lists.
children: Children,
)