@multicomma/arkcn 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/registry/index.json +1 -1
- package/registry/items/accordion.json +302 -0
- package/registry/items/activity-feed.json +408 -0
- package/registry/items/alert-dialog.json +676 -0
- package/registry/items/alert.json +113 -0
- package/registry/items/angle-slider.json +378 -0
- package/registry/items/app-shell.json +2654 -1
- package/registry/items/aspect-ratio.json +36 -0
- package/registry/items/attachment.json +299 -1
- package/registry/items/avatar.json +213 -0
- package/registry/items/badge.json +44 -0
- package/registry/items/breadcrumb.json +191 -0
- package/registry/items/bubble.json +146 -0
- package/registry/items/button-group.json +110 -0
- package/registry/items/button.json +52 -0
- package/registry/items/calendar.json +499 -1
- package/registry/items/canvas.json +446 -1
- package/registry/items/card.json +192 -0
- package/registry/items/carousel.json +208 -1
- package/registry/items/cascader.json +797 -1
- package/registry/items/chart.json +1764 -1
- package/registry/items/chat.json +993 -0
- package/registry/items/checkbox.json +503 -0
- package/registry/items/clipboard.json +308 -0
- package/registry/items/collapsible.json +226 -0
- package/registry/items/color-picker.json +1261 -0
- package/registry/items/combobox.json +1123 -1
- package/registry/items/command.json +837 -1
- package/registry/items/comment-thread.json +952 -1
- package/registry/items/context-menu.json +1344 -1
- package/registry/items/data-grid.json +449 -1
- package/registry/items/data-table.json +1310 -1
- package/registry/items/date-input.json +476 -0
- package/registry/items/dialog.json +592 -0
- package/registry/items/direction.json +29 -1
- package/registry/items/drawer.json +797 -0
- package/registry/items/dropdown-menu.json +1311 -1
- package/registry/items/editable.json +503 -0
- package/registry/items/empty.json +166 -0
- package/registry/items/field.json +286 -1
- package/registry/items/file-upload.json +638 -0
- package/registry/items/floating-panel.json +720 -0
- package/registry/items/floating-toolbar.json +43 -0
- package/registry/items/format.json +109 -0
- package/registry/items/gantt.json +773 -1
- package/registry/items/hooks/use-mobile.json +1 -0
- package/registry/items/hotkeys.json +99 -1
- package/registry/items/hover-card.json +357 -0
- package/registry/items/image-cropper.json +431 -0
- package/registry/items/input-group.json +189 -0
- package/registry/items/input-otp.json +181 -0
- package/registry/items/input.json +28 -0
- package/registry/items/item.json +308 -0
- package/registry/items/json-tree-view.json +336 -0
- package/registry/items/kanban.json +624 -1
- package/registry/items/kbd.json +54 -0
- package/registry/items/label.json +28 -0
- package/registry/items/lib/controllable.json +1 -0
- package/registry/items/lib/data-table-adapter.json +1 -0
- package/registry/items/lib/drag-preview.json +1 -0
- package/registry/items/lib/form.json +1 -0
- package/registry/items/lib/history.json +1 -0
- package/registry/items/lib/row-layout.json +1 -0
- package/registry/items/lib/table.json +1 -0
- package/registry/items/lib/time.json +1 -0
- package/registry/items/lib/utils.json +1 -0
- package/registry/items/live-region.json +43 -0
- package/registry/items/marker.json +96 -0
- package/registry/items/marquee.json +300 -0
- package/registry/items/menubar.json +1282 -1
- package/registry/items/message.json +166 -0
- package/registry/items/navigation-menu.json +561 -1
- package/registry/items/node-graph.json +1037 -1
- package/registry/items/number-input.json +519 -0
- package/registry/items/pagination.json +244 -1
- package/registry/items/password-input.json +311 -0
- package/registry/items/popconfirm.json +566 -0
- package/registry/items/popover.json +615 -0
- package/registry/items/progress.json +516 -0
- package/registry/items/qr-code.json +249 -0
- package/registry/items/query-builder.json +1368 -1
- package/registry/items/radio-group.json +362 -0
- package/registry/items/rating-group.json +304 -0
- package/registry/items/resizable.json +242 -1
- package/registry/items/rich-text-editor.json +934 -1
- package/registry/items/scheduler.json +1013 -1
- package/registry/items/scroll-area.json +227 -0
- package/registry/items/segment-group.json +363 -0
- package/registry/items/select.json +956 -0
- package/registry/items/separator.json +45 -1
- package/registry/items/sheet.json +592 -0
- package/registry/items/sidebar.json +785 -1
- package/registry/items/signature-pad.json +330 -0
- package/registry/items/skeleton.json +28 -0
- package/registry/items/slider.json +799 -0
- package/registry/items/sonner.json +135 -0
- package/registry/items/spinner.json +28 -0
- package/registry/items/steps.json +483 -0
- package/registry/items/swap.json +107 -0
- package/registry/items/switch.json +362 -0
- package/registry/items/table.json +210 -0
- package/registry/items/tabs.json +326 -0
- package/registry/items/tags-input.json +640 -0
- package/registry/items/textarea.json +28 -0
- package/registry/items/timer.json +289 -0
- package/registry/items/toc.json +372 -0
- package/registry/items/toggle-group.json +214 -1
- package/registry/items/toggle.json +124 -0
- package/registry/items/tooltip.json +417 -0
- package/registry/items/tour.json +498 -0
- package/registry/items/transfer-list.json +609 -1
- package/registry/items/tree-select.json +742 -1
- package/registry/items/tree-view.json +794 -0
- package/registry/items/virtual-list.json +214 -1
- package/src/components/ui/app-shell.tsx +11 -0
- package/src/components/ui/attachment.tsx +1 -0
- package/src/components/ui/calendar.tsx +1 -0
- package/src/components/ui/canvas.tsx +8 -0
- package/src/components/ui/carousel.tsx +3 -0
- package/src/components/ui/cascader.tsx +1 -0
- package/src/components/ui/chart.tsx +10 -0
- package/src/components/ui/combobox.tsx +3 -0
- package/src/components/ui/command.tsx +1 -0
- package/src/components/ui/comment-thread.tsx +11 -0
- package/src/components/ui/context-menu.tsx +6 -0
- package/src/components/ui/data-grid.tsx +8 -0
- package/src/components/ui/data-table.tsx +6 -0
- package/src/components/ui/direction.tsx +2 -0
- package/src/components/ui/dropdown-menu.tsx +6 -0
- package/src/components/ui/field.tsx +1 -0
- package/src/components/ui/gantt.tsx +15 -0
- package/src/components/ui/hotkeys.tsx +3 -0
- package/src/components/ui/kanban.tsx +3 -0
- package/src/components/ui/menubar.tsx +6 -0
- package/src/components/ui/navigation-menu.tsx +1 -0
- package/src/components/ui/node-graph.tsx +23 -0
- package/src/components/ui/pagination.tsx +1 -0
- package/src/components/ui/query-builder.tsx +7 -0
- package/src/components/ui/resizable.tsx +1 -0
- package/src/components/ui/rich-text-editor.tsx +54 -0
- package/src/components/ui/scheduler.tsx +26 -0
- package/src/components/ui/separator.tsx +1 -0
- package/src/components/ui/sidebar.tsx +5 -0
- package/src/components/ui/toggle-group.tsx +3 -0
- package/src/components/ui/transfer-list.tsx +11 -0
- package/src/components/ui/tree-select.tsx +5 -0
- package/src/components/ui/virtual-list.tsx +7 -0
|
@@ -28,6 +28,790 @@
|
|
|
28
28
|
"SidebarTrigger",
|
|
29
29
|
"useSidebar"
|
|
30
30
|
],
|
|
31
|
+
"parts": [
|
|
32
|
+
{
|
|
33
|
+
"name": "Sidebar",
|
|
34
|
+
"props": [
|
|
35
|
+
{
|
|
36
|
+
"name": "collapsible",
|
|
37
|
+
"type": "\"icon\" | \"offcanvas\" | \"none\"",
|
|
38
|
+
"required": false,
|
|
39
|
+
"default": "\"offcanvas\"",
|
|
40
|
+
"description": "Collapse mode: `offcanvas`, `icon`, or `none`.",
|
|
41
|
+
"from": "arkcn"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "side",
|
|
45
|
+
"type": "\"left\" | \"right\"",
|
|
46
|
+
"required": false,
|
|
47
|
+
"default": "\"left\"",
|
|
48
|
+
"description": "Which side of the anchor or container the part sits on.",
|
|
49
|
+
"from": "arkcn"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "variant",
|
|
53
|
+
"type": "\"sidebar\" | \"floating\" | \"inset\"",
|
|
54
|
+
"required": false,
|
|
55
|
+
"default": "\"sidebar\"",
|
|
56
|
+
"description": "Visual variant, styled with `cva`; sets a `data-variant` attribute.",
|
|
57
|
+
"from": "arkcn"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "children",
|
|
61
|
+
"type": "ReactNode",
|
|
62
|
+
"required": false,
|
|
63
|
+
"description": "Content rendered inside the part.",
|
|
64
|
+
"from": "@types/react"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"name": "className",
|
|
68
|
+
"type": "string",
|
|
69
|
+
"required": false,
|
|
70
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
71
|
+
"from": "@types/react"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "style",
|
|
75
|
+
"type": "CSSProperties",
|
|
76
|
+
"required": false,
|
|
77
|
+
"description": "Inline styles applied to the rendered element.",
|
|
78
|
+
"from": "@types/react"
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "SidebarContent",
|
|
84
|
+
"props": [
|
|
85
|
+
{
|
|
86
|
+
"name": "children",
|
|
87
|
+
"type": "ReactNode",
|
|
88
|
+
"required": false,
|
|
89
|
+
"description": "Content rendered inside the part.",
|
|
90
|
+
"from": "@types/react"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"name": "className",
|
|
94
|
+
"type": "string",
|
|
95
|
+
"required": false,
|
|
96
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
97
|
+
"from": "@types/react"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"name": "style",
|
|
101
|
+
"type": "CSSProperties",
|
|
102
|
+
"required": false,
|
|
103
|
+
"description": "Inline styles applied to the rendered element.",
|
|
104
|
+
"from": "@types/react"
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"name": "SidebarFooter",
|
|
110
|
+
"props": [
|
|
111
|
+
{
|
|
112
|
+
"name": "children",
|
|
113
|
+
"type": "ReactNode",
|
|
114
|
+
"required": false,
|
|
115
|
+
"description": "Content rendered inside the part.",
|
|
116
|
+
"from": "@types/react"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"name": "className",
|
|
120
|
+
"type": "string",
|
|
121
|
+
"required": false,
|
|
122
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
123
|
+
"from": "@types/react"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"name": "style",
|
|
127
|
+
"type": "CSSProperties",
|
|
128
|
+
"required": false,
|
|
129
|
+
"description": "Inline styles applied to the rendered element.",
|
|
130
|
+
"from": "@types/react"
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "SidebarGroup",
|
|
136
|
+
"props": [
|
|
137
|
+
{
|
|
138
|
+
"name": "children",
|
|
139
|
+
"type": "ReactNode",
|
|
140
|
+
"required": false,
|
|
141
|
+
"description": "Content rendered inside the part.",
|
|
142
|
+
"from": "@types/react"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"name": "className",
|
|
146
|
+
"type": "string",
|
|
147
|
+
"required": false,
|
|
148
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
149
|
+
"from": "@types/react"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"name": "style",
|
|
153
|
+
"type": "CSSProperties",
|
|
154
|
+
"required": false,
|
|
155
|
+
"description": "Inline styles applied to the rendered element.",
|
|
156
|
+
"from": "@types/react"
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "SidebarGroupAction",
|
|
162
|
+
"props": [
|
|
163
|
+
{
|
|
164
|
+
"name": "asChild",
|
|
165
|
+
"type": "boolean",
|
|
166
|
+
"required": false,
|
|
167
|
+
"default": "false",
|
|
168
|
+
"description": "Render the child element instead of the default one, merging props and behaviour onto it.",
|
|
169
|
+
"from": "arkcn"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"name": "children",
|
|
173
|
+
"type": "ReactNode",
|
|
174
|
+
"required": false,
|
|
175
|
+
"description": "Content rendered inside the part.",
|
|
176
|
+
"from": "@types/react"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"name": "className",
|
|
180
|
+
"type": "string",
|
|
181
|
+
"required": false,
|
|
182
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
183
|
+
"from": "@types/react"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"name": "style",
|
|
187
|
+
"type": "CSSProperties",
|
|
188
|
+
"required": false,
|
|
189
|
+
"description": "Inline styles applied to the rendered element.",
|
|
190
|
+
"from": "@types/react"
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"name": "SidebarGroupContent",
|
|
196
|
+
"props": [
|
|
197
|
+
{
|
|
198
|
+
"name": "children",
|
|
199
|
+
"type": "ReactNode",
|
|
200
|
+
"required": false,
|
|
201
|
+
"description": "Content rendered inside the part.",
|
|
202
|
+
"from": "@types/react"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"name": "className",
|
|
206
|
+
"type": "string",
|
|
207
|
+
"required": false,
|
|
208
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
209
|
+
"from": "@types/react"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"name": "style",
|
|
213
|
+
"type": "CSSProperties",
|
|
214
|
+
"required": false,
|
|
215
|
+
"description": "Inline styles applied to the rendered element.",
|
|
216
|
+
"from": "@types/react"
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"name": "SidebarGroupLabel",
|
|
222
|
+
"props": [
|
|
223
|
+
{
|
|
224
|
+
"name": "asChild",
|
|
225
|
+
"type": "boolean",
|
|
226
|
+
"required": false,
|
|
227
|
+
"default": "false",
|
|
228
|
+
"description": "Render the child element instead of the default one, merging props and behaviour onto it.",
|
|
229
|
+
"from": "arkcn"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"name": "children",
|
|
233
|
+
"type": "ReactNode",
|
|
234
|
+
"required": false,
|
|
235
|
+
"description": "Content rendered inside the part.",
|
|
236
|
+
"from": "@types/react"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"name": "className",
|
|
240
|
+
"type": "string",
|
|
241
|
+
"required": false,
|
|
242
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
243
|
+
"from": "@types/react"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"name": "style",
|
|
247
|
+
"type": "CSSProperties",
|
|
248
|
+
"required": false,
|
|
249
|
+
"description": "Inline styles applied to the rendered element.",
|
|
250
|
+
"from": "@types/react"
|
|
251
|
+
}
|
|
252
|
+
]
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"name": "SidebarHeader",
|
|
256
|
+
"props": [
|
|
257
|
+
{
|
|
258
|
+
"name": "children",
|
|
259
|
+
"type": "ReactNode",
|
|
260
|
+
"required": false,
|
|
261
|
+
"description": "Content rendered inside the part.",
|
|
262
|
+
"from": "@types/react"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"name": "className",
|
|
266
|
+
"type": "string",
|
|
267
|
+
"required": false,
|
|
268
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
269
|
+
"from": "@types/react"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"name": "style",
|
|
273
|
+
"type": "CSSProperties",
|
|
274
|
+
"required": false,
|
|
275
|
+
"description": "Inline styles applied to the rendered element.",
|
|
276
|
+
"from": "@types/react"
|
|
277
|
+
}
|
|
278
|
+
]
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
"name": "SidebarInput",
|
|
282
|
+
"props": [
|
|
283
|
+
{
|
|
284
|
+
"name": "children",
|
|
285
|
+
"type": "ReactNode",
|
|
286
|
+
"required": false,
|
|
287
|
+
"description": "Content rendered inside the part.",
|
|
288
|
+
"from": "@types/react"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"name": "className",
|
|
292
|
+
"type": "string",
|
|
293
|
+
"required": false,
|
|
294
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
295
|
+
"from": "@types/react"
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
"name": "style",
|
|
299
|
+
"type": "CSSProperties",
|
|
300
|
+
"required": false,
|
|
301
|
+
"description": "Inline styles applied to the rendered element.",
|
|
302
|
+
"from": "@types/react"
|
|
303
|
+
}
|
|
304
|
+
]
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"name": "SidebarInset",
|
|
308
|
+
"props": [
|
|
309
|
+
{
|
|
310
|
+
"name": "children",
|
|
311
|
+
"type": "ReactNode",
|
|
312
|
+
"required": false,
|
|
313
|
+
"description": "Content rendered inside the part.",
|
|
314
|
+
"from": "@types/react"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"name": "className",
|
|
318
|
+
"type": "string",
|
|
319
|
+
"required": false,
|
|
320
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
321
|
+
"from": "@types/react"
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
"name": "style",
|
|
325
|
+
"type": "CSSProperties",
|
|
326
|
+
"required": false,
|
|
327
|
+
"description": "Inline styles applied to the rendered element.",
|
|
328
|
+
"from": "@types/react"
|
|
329
|
+
}
|
|
330
|
+
]
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
"name": "SidebarMenu",
|
|
334
|
+
"props": [
|
|
335
|
+
{
|
|
336
|
+
"name": "children",
|
|
337
|
+
"type": "ReactNode",
|
|
338
|
+
"required": false,
|
|
339
|
+
"description": "Content rendered inside the part.",
|
|
340
|
+
"from": "@types/react"
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
"name": "className",
|
|
344
|
+
"type": "string",
|
|
345
|
+
"required": false,
|
|
346
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
347
|
+
"from": "@types/react"
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
"name": "style",
|
|
351
|
+
"type": "CSSProperties",
|
|
352
|
+
"required": false,
|
|
353
|
+
"description": "Inline styles applied to the rendered element.",
|
|
354
|
+
"from": "@types/react"
|
|
355
|
+
}
|
|
356
|
+
]
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
"name": "SidebarMenuAction",
|
|
360
|
+
"props": [
|
|
361
|
+
{
|
|
362
|
+
"name": "asChild",
|
|
363
|
+
"type": "boolean",
|
|
364
|
+
"required": false,
|
|
365
|
+
"default": "false",
|
|
366
|
+
"description": "Render the child element instead of the default one, merging props and behaviour onto it.",
|
|
367
|
+
"from": "arkcn"
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
"name": "showOnHover",
|
|
371
|
+
"type": "boolean",
|
|
372
|
+
"required": false,
|
|
373
|
+
"default": "false",
|
|
374
|
+
"description": "Only reveal the action when the item is hovered or focused.",
|
|
375
|
+
"from": "arkcn"
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
"name": "children",
|
|
379
|
+
"type": "ReactNode",
|
|
380
|
+
"required": false,
|
|
381
|
+
"description": "Content rendered inside the part.",
|
|
382
|
+
"from": "@types/react"
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
"name": "className",
|
|
386
|
+
"type": "string",
|
|
387
|
+
"required": false,
|
|
388
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
389
|
+
"from": "@types/react"
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"name": "style",
|
|
393
|
+
"type": "CSSProperties",
|
|
394
|
+
"required": false,
|
|
395
|
+
"description": "Inline styles applied to the rendered element.",
|
|
396
|
+
"from": "@types/react"
|
|
397
|
+
}
|
|
398
|
+
]
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"name": "SidebarMenuBadge",
|
|
402
|
+
"props": [
|
|
403
|
+
{
|
|
404
|
+
"name": "children",
|
|
405
|
+
"type": "ReactNode",
|
|
406
|
+
"required": false,
|
|
407
|
+
"description": "Content rendered inside the part.",
|
|
408
|
+
"from": "@types/react"
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
"name": "className",
|
|
412
|
+
"type": "string",
|
|
413
|
+
"required": false,
|
|
414
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
415
|
+
"from": "@types/react"
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
"name": "style",
|
|
419
|
+
"type": "CSSProperties",
|
|
420
|
+
"required": false,
|
|
421
|
+
"description": "Inline styles applied to the rendered element.",
|
|
422
|
+
"from": "@types/react"
|
|
423
|
+
}
|
|
424
|
+
]
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
"name": "SidebarMenuButton",
|
|
428
|
+
"props": [
|
|
429
|
+
{
|
|
430
|
+
"name": "asChild",
|
|
431
|
+
"type": "boolean",
|
|
432
|
+
"required": false,
|
|
433
|
+
"default": "false",
|
|
434
|
+
"description": "Render the child element instead of the default one, merging props and behaviour onto it.",
|
|
435
|
+
"from": "arkcn"
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
"name": "isActive",
|
|
439
|
+
"type": "boolean",
|
|
440
|
+
"required": false,
|
|
441
|
+
"default": "false",
|
|
442
|
+
"description": "Marks the current item.",
|
|
443
|
+
"from": "arkcn"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
"name": "size",
|
|
447
|
+
"type": "\"default\" | \"sm\" | \"lg\" | null",
|
|
448
|
+
"required": false,
|
|
449
|
+
"default": "\"default\"",
|
|
450
|
+
"description": "Size variant; sets a `data-size` attribute.",
|
|
451
|
+
"from": "arkcn"
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
"name": "tooltip",
|
|
455
|
+
"type": "string | (TooltipContentProps & RefAttributes<HTMLDivElement>)",
|
|
456
|
+
"required": false,
|
|
457
|
+
"description": "Tooltip content shown on hover, or `false` to disable it.",
|
|
458
|
+
"from": "arkcn"
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
"name": "variant",
|
|
462
|
+
"type": "\"default\" | \"outline\" | null",
|
|
463
|
+
"required": false,
|
|
464
|
+
"default": "\"default\"",
|
|
465
|
+
"description": "Visual variant, styled with `cva`; sets a `data-variant` attribute.",
|
|
466
|
+
"from": "arkcn"
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
"name": "children",
|
|
470
|
+
"type": "ReactNode",
|
|
471
|
+
"required": false,
|
|
472
|
+
"description": "Content rendered inside the part.",
|
|
473
|
+
"from": "@types/react"
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
"name": "className",
|
|
477
|
+
"type": "string",
|
|
478
|
+
"required": false,
|
|
479
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
480
|
+
"from": "@types/react"
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
"name": "style",
|
|
484
|
+
"type": "CSSProperties",
|
|
485
|
+
"required": false,
|
|
486
|
+
"description": "Inline styles applied to the rendered element.",
|
|
487
|
+
"from": "@types/react"
|
|
488
|
+
}
|
|
489
|
+
]
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
"name": "SidebarMenuItem",
|
|
493
|
+
"props": [
|
|
494
|
+
{
|
|
495
|
+
"name": "children",
|
|
496
|
+
"type": "ReactNode",
|
|
497
|
+
"required": false,
|
|
498
|
+
"description": "Content rendered inside the part.",
|
|
499
|
+
"from": "@types/react"
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
"name": "className",
|
|
503
|
+
"type": "string",
|
|
504
|
+
"required": false,
|
|
505
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
506
|
+
"from": "@types/react"
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
"name": "style",
|
|
510
|
+
"type": "CSSProperties",
|
|
511
|
+
"required": false,
|
|
512
|
+
"description": "Inline styles applied to the rendered element.",
|
|
513
|
+
"from": "@types/react"
|
|
514
|
+
}
|
|
515
|
+
]
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
"name": "SidebarMenuSkeleton",
|
|
519
|
+
"props": [
|
|
520
|
+
{
|
|
521
|
+
"name": "showIcon",
|
|
522
|
+
"type": "boolean",
|
|
523
|
+
"required": false,
|
|
524
|
+
"default": "false",
|
|
525
|
+
"description": "Render an icon placeholder in the skeleton.",
|
|
526
|
+
"from": "arkcn"
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
"name": "children",
|
|
530
|
+
"type": "ReactNode",
|
|
531
|
+
"required": false,
|
|
532
|
+
"description": "Content rendered inside the part.",
|
|
533
|
+
"from": "@types/react"
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
"name": "className",
|
|
537
|
+
"type": "string",
|
|
538
|
+
"required": false,
|
|
539
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
540
|
+
"from": "@types/react"
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
"name": "style",
|
|
544
|
+
"type": "CSSProperties",
|
|
545
|
+
"required": false,
|
|
546
|
+
"description": "Inline styles applied to the rendered element.",
|
|
547
|
+
"from": "@types/react"
|
|
548
|
+
}
|
|
549
|
+
]
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
"name": "SidebarMenuSub",
|
|
553
|
+
"props": [
|
|
554
|
+
{
|
|
555
|
+
"name": "children",
|
|
556
|
+
"type": "ReactNode",
|
|
557
|
+
"required": false,
|
|
558
|
+
"description": "Content rendered inside the part.",
|
|
559
|
+
"from": "@types/react"
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
"name": "className",
|
|
563
|
+
"type": "string",
|
|
564
|
+
"required": false,
|
|
565
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
566
|
+
"from": "@types/react"
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
"name": "style",
|
|
570
|
+
"type": "CSSProperties",
|
|
571
|
+
"required": false,
|
|
572
|
+
"description": "Inline styles applied to the rendered element.",
|
|
573
|
+
"from": "@types/react"
|
|
574
|
+
}
|
|
575
|
+
]
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
"name": "SidebarMenuSubButton",
|
|
579
|
+
"props": [
|
|
580
|
+
{
|
|
581
|
+
"name": "asChild",
|
|
582
|
+
"type": "boolean",
|
|
583
|
+
"required": false,
|
|
584
|
+
"default": "false",
|
|
585
|
+
"description": "Render the child element instead of the default one, merging props and behaviour onto it.",
|
|
586
|
+
"from": "arkcn"
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
"name": "isActive",
|
|
590
|
+
"type": "boolean",
|
|
591
|
+
"required": false,
|
|
592
|
+
"default": "false",
|
|
593
|
+
"description": "Marks the current item.",
|
|
594
|
+
"from": "arkcn"
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
"name": "size",
|
|
598
|
+
"type": "\"sm\" | \"md\"",
|
|
599
|
+
"required": false,
|
|
600
|
+
"default": "\"md\"",
|
|
601
|
+
"description": "Size variant; sets a `data-size` attribute.",
|
|
602
|
+
"from": "arkcn"
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
"name": "children",
|
|
606
|
+
"type": "ReactNode",
|
|
607
|
+
"required": false,
|
|
608
|
+
"description": "Content rendered inside the part.",
|
|
609
|
+
"from": "@types/react"
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
"name": "className",
|
|
613
|
+
"type": "string",
|
|
614
|
+
"required": false,
|
|
615
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
616
|
+
"from": "@types/react"
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
"name": "style",
|
|
620
|
+
"type": "CSSProperties",
|
|
621
|
+
"required": false,
|
|
622
|
+
"description": "Inline styles applied to the rendered element.",
|
|
623
|
+
"from": "@types/react"
|
|
624
|
+
}
|
|
625
|
+
]
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
"name": "SidebarMenuSubItem",
|
|
629
|
+
"props": [
|
|
630
|
+
{
|
|
631
|
+
"name": "children",
|
|
632
|
+
"type": "ReactNode",
|
|
633
|
+
"required": false,
|
|
634
|
+
"description": "Content rendered inside the part.",
|
|
635
|
+
"from": "@types/react"
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
"name": "className",
|
|
639
|
+
"type": "string",
|
|
640
|
+
"required": false,
|
|
641
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
642
|
+
"from": "@types/react"
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
"name": "style",
|
|
646
|
+
"type": "CSSProperties",
|
|
647
|
+
"required": false,
|
|
648
|
+
"description": "Inline styles applied to the rendered element.",
|
|
649
|
+
"from": "@types/react"
|
|
650
|
+
}
|
|
651
|
+
]
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
"name": "SidebarProvider",
|
|
655
|
+
"props": [
|
|
656
|
+
{
|
|
657
|
+
"name": "defaultOpen",
|
|
658
|
+
"type": "boolean",
|
|
659
|
+
"required": false,
|
|
660
|
+
"default": "true",
|
|
661
|
+
"description": "The initial open state when uncontrolled.",
|
|
662
|
+
"from": "arkcn"
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
"name": "onOpenChange",
|
|
666
|
+
"type": "((open: boolean) => void)",
|
|
667
|
+
"required": false,
|
|
668
|
+
"description": "Called when the open state changes.",
|
|
669
|
+
"from": "arkcn"
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
"name": "open",
|
|
673
|
+
"type": "boolean",
|
|
674
|
+
"required": false,
|
|
675
|
+
"description": "The controlled open state.",
|
|
676
|
+
"from": "arkcn"
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
"name": "children",
|
|
680
|
+
"type": "ReactNode",
|
|
681
|
+
"required": false,
|
|
682
|
+
"description": "Content rendered inside the part.",
|
|
683
|
+
"from": "@types/react"
|
|
684
|
+
},
|
|
685
|
+
{
|
|
686
|
+
"name": "className",
|
|
687
|
+
"type": "string",
|
|
688
|
+
"required": false,
|
|
689
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
690
|
+
"from": "@types/react"
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
"name": "style",
|
|
694
|
+
"type": "CSSProperties",
|
|
695
|
+
"required": false,
|
|
696
|
+
"description": "Inline styles applied to the rendered element.",
|
|
697
|
+
"from": "@types/react"
|
|
698
|
+
}
|
|
699
|
+
]
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
"name": "SidebarRail",
|
|
703
|
+
"props": [
|
|
704
|
+
{
|
|
705
|
+
"name": "children",
|
|
706
|
+
"type": "ReactNode",
|
|
707
|
+
"required": false,
|
|
708
|
+
"description": "Content rendered inside the part.",
|
|
709
|
+
"from": "@types/react"
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
"name": "className",
|
|
713
|
+
"type": "string",
|
|
714
|
+
"required": false,
|
|
715
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
716
|
+
"from": "@types/react"
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
"name": "style",
|
|
720
|
+
"type": "CSSProperties",
|
|
721
|
+
"required": false,
|
|
722
|
+
"description": "Inline styles applied to the rendered element.",
|
|
723
|
+
"from": "@types/react"
|
|
724
|
+
}
|
|
725
|
+
]
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
"name": "SidebarSeparator",
|
|
729
|
+
"props": [
|
|
730
|
+
{
|
|
731
|
+
"name": "decorative",
|
|
732
|
+
"type": "boolean",
|
|
733
|
+
"required": false,
|
|
734
|
+
"description": "Hide the separator from assistive technology.",
|
|
735
|
+
"from": "arkcn"
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
"name": "orientation",
|
|
739
|
+
"type": "\"horizontal\" | \"vertical\"",
|
|
740
|
+
"required": false,
|
|
741
|
+
"description": "Layout direction of the part.",
|
|
742
|
+
"from": "arkcn"
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
"name": "children",
|
|
746
|
+
"type": "ReactNode",
|
|
747
|
+
"required": false,
|
|
748
|
+
"description": "Content rendered inside the part.",
|
|
749
|
+
"from": "@types/react"
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
"name": "className",
|
|
753
|
+
"type": "string",
|
|
754
|
+
"required": false,
|
|
755
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
756
|
+
"from": "@types/react"
|
|
757
|
+
},
|
|
758
|
+
{
|
|
759
|
+
"name": "style",
|
|
760
|
+
"type": "CSSProperties",
|
|
761
|
+
"required": false,
|
|
762
|
+
"description": "Inline styles applied to the rendered element.",
|
|
763
|
+
"from": "@types/react"
|
|
764
|
+
}
|
|
765
|
+
]
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
"name": "SidebarTrigger",
|
|
769
|
+
"props": [
|
|
770
|
+
{
|
|
771
|
+
"name": "asChild",
|
|
772
|
+
"type": "boolean",
|
|
773
|
+
"required": false,
|
|
774
|
+
"description": "Render the child element instead of the default one, merging props and behaviour onto it.",
|
|
775
|
+
"from": "arkcn"
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
"name": "size",
|
|
779
|
+
"type": "\"default\" | \"xs\" | \"sm\" | \"lg\" | \"icon\" | \"icon-xs\" | \"icon-sm\" | \"icon-lg\" | null",
|
|
780
|
+
"required": false,
|
|
781
|
+
"description": "Size variant; sets a `data-size` attribute.",
|
|
782
|
+
"from": "arkcn"
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
"name": "variant",
|
|
786
|
+
"type": "\"link\" | \"default\" | \"outline\" | \"secondary\" | \"ghost\" | \"destructive\" | null",
|
|
787
|
+
"required": false,
|
|
788
|
+
"description": "Visual variant, styled with `cva`; sets a `data-variant` attribute.",
|
|
789
|
+
"from": "arkcn"
|
|
790
|
+
},
|
|
791
|
+
{
|
|
792
|
+
"name": "children",
|
|
793
|
+
"type": "ReactNode",
|
|
794
|
+
"required": false,
|
|
795
|
+
"description": "Content rendered inside the part.",
|
|
796
|
+
"from": "@types/react"
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
"name": "className",
|
|
800
|
+
"type": "string",
|
|
801
|
+
"required": false,
|
|
802
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
803
|
+
"from": "@types/react"
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
"name": "style",
|
|
807
|
+
"type": "CSSProperties",
|
|
808
|
+
"required": false,
|
|
809
|
+
"description": "Inline styles applied to the rendered element.",
|
|
810
|
+
"from": "@types/react"
|
|
811
|
+
}
|
|
812
|
+
]
|
|
813
|
+
}
|
|
814
|
+
],
|
|
31
815
|
"dependencies": {
|
|
32
816
|
"@ark-ui/react": "^5.39.1",
|
|
33
817
|
"class-variance-authority": "^0.7.1",
|
|
@@ -46,7 +830,7 @@
|
|
|
46
830
|
"files": [
|
|
47
831
|
{
|
|
48
832
|
"path": "components/ui/sidebar.tsx",
|
|
49
|
-
"content": "import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"@/lib/utils\"\nimport { ark } from \"@ark-ui/react\"\n\nimport { useIsMobile } from \"@/hooks/use-mobile\"\nimport { Button } from \"@/components/ui/button\"\nimport { Input } from \"@/components/ui/input\"\nimport { Separator } from \"@/components/ui/separator\"\nimport { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from \"@/components/ui/sheet\"\nimport { Skeleton } from \"@/components/ui/skeleton\"\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@/components/ui/tooltip\"\nimport { PanelLeftIcon } from \"lucide-react\"\n\nconst SIDEBAR_COOKIE_NAME = \"sidebar_state\"\nconst SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7\nconst SIDEBAR_WIDTH = \"16rem\"\nconst SIDEBAR_WIDTH_MOBILE = \"18rem\"\nconst SIDEBAR_WIDTH_ICON = \"3rem\"\nconst SIDEBAR_KEYBOARD_SHORTCUT = \"b\"\n\ntype SidebarContextProps = {\n state: \"expanded\" | \"collapsed\"\n open: boolean\n setOpen: (open: boolean) => void\n openMobile: boolean\n setOpenMobile: (open: boolean) => void\n isMobile: boolean\n toggleSidebar: () => void\n}\n\nconst SidebarContext = React.createContext<SidebarContextProps | null>(null)\n\nfunction useSidebar() {\n const context = React.useContext(SidebarContext)\n if (!context) {\n throw new Error(\"useSidebar must be used within a SidebarProvider.\")\n }\n\n return context\n}\n\nfunction SidebarProvider({\n defaultOpen = true,\n open: openProp,\n onOpenChange: setOpenProp,\n className,\n style,\n children,\n ...props\n}: React.ComponentProps<\"div\"> & {\n defaultOpen?: boolean\n open?: boolean\n onOpenChange?: (open: boolean) => void\n}) {\n const isMobile = useIsMobile()\n const [openMobile, setOpenMobile] = React.useState(false)\n\n // This is the internal state of the sidebar.\n // We use openProp and setOpenProp for control from outside the component.\n const [_open, _setOpen] = React.useState(defaultOpen)\n const open = openProp ?? _open\n const setOpen = React.useCallback(\n (value: boolean | ((value: boolean) => boolean)) => {\n const openState = typeof value === \"function\" ? value(open) : value\n if (setOpenProp) {\n setOpenProp(openState)\n } else {\n _setOpen(openState)\n }\n\n // This sets the cookie to keep the sidebar state.\n document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`\n },\n [setOpenProp, open]\n )\n\n // Helper to toggle the sidebar.\n const toggleSidebar = React.useCallback(() => {\n return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open)\n }, [isMobile, setOpen, setOpenMobile])\n\n // Adds a keyboard shortcut to toggle the sidebar.\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {\n event.preventDefault()\n toggleSidebar()\n }\n }\n\n window.addEventListener(\"keydown\", handleKeyDown)\n return () => window.removeEventListener(\"keydown\", handleKeyDown)\n }, [toggleSidebar])\n\n // We add a state so that we can do data-state=\"expanded\" or \"collapsed\".\n // This makes it easier to style the sidebar with Tailwind classes.\n const state = open ? \"expanded\" : \"collapsed\"\n\n const contextValue = React.useMemo<SidebarContextProps>(\n () => ({\n state,\n open,\n setOpen,\n isMobile,\n openMobile,\n setOpenMobile,\n toggleSidebar,\n }),\n [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]\n )\n\n return (\n <SidebarContext.Provider value={contextValue}>\n <div\n data-slot=\"sidebar-wrapper\"\n style={\n {\n \"--sidebar-width\": SIDEBAR_WIDTH,\n \"--sidebar-width-icon\": SIDEBAR_WIDTH_ICON,\n ...style,\n } as React.CSSProperties\n }\n className={cn(\"group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar\", className)}\n {...props}\n >\n {children}\n </div>\n </SidebarContext.Provider>\n )\n}\n\nfunction Sidebar({\n side = \"left\",\n variant = \"sidebar\",\n collapsible = \"offcanvas\",\n className,\n children,\n dir,\n ...props\n}: React.ComponentProps<\"div\"> & {\n side?: \"left\" | \"right\"\n variant?: \"sidebar\" | \"floating\" | \"inset\"\n collapsible?: \"offcanvas\" | \"icon\" | \"none\"\n}) {\n const { isMobile, state, openMobile, setOpenMobile } = useSidebar()\n\n if (collapsible === \"none\") {\n return (\n <div\n data-slot=\"sidebar\"\n className={cn(\"flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground\", className)}\n {...props}\n >\n {children}\n </div>\n )\n }\n\n if (isMobile) {\n return (\n <Sheet open={openMobile} onOpenChange={({ open }) => setOpenMobile(open)}>\n <SheetContent\n {...props}\n dir={dir}\n data-sidebar=\"sidebar\"\n data-slot=\"sidebar\"\n data-mobile=\"true\"\n className=\"w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden\"\n style={\n {\n \"--sidebar-width\": SIDEBAR_WIDTH_MOBILE,\n } as React.CSSProperties\n }\n side={side}\n >\n <SheetHeader className=\"sr-only\">\n <SheetTitle>Sidebar</SheetTitle>\n <SheetDescription>Displays the mobile sidebar.</SheetDescription>\n </SheetHeader>\n <div className=\"flex size-full flex-col\">{children}</div>\n </SheetContent>\n </Sheet>\n )\n }\n\n return (\n <div\n className=\"group peer hidden text-sidebar-foreground md:block\"\n data-state={state}\n data-collapsible={state === \"collapsed\" ? collapsible : \"\"}\n data-variant={variant}\n data-side={side}\n data-slot=\"sidebar\"\n >\n {/* This is what handles the sidebar gap on desktop */}\n <div\n data-slot=\"sidebar-gap\"\n className={cn(\n \"relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear\",\n \"group-data-[collapsible=offcanvas]:w-0\",\n \"group-data-[side=right]:rotate-180\",\n variant === \"floating\" || variant === \"inset\"\n ? \"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]\"\n : \"group-data-[collapsible=icon]:w-(--sidebar-width-icon)\"\n )}\n />\n <div\n data-slot=\"sidebar-container\"\n data-side={side}\n className={cn(\n \"fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:-left-(--sidebar-width) data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:-right-(--sidebar-width) md:flex\",\n // Adjust the padding for floating and inset variants.\n variant === \"floating\" || variant === \"inset\"\n ? \"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]\"\n : \"group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l\",\n className\n )}\n {...props}\n >\n <div\n data-sidebar=\"sidebar\"\n data-slot=\"sidebar-inner\"\n className=\"flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border\"\n >\n {children}\n </div>\n </div>\n </div>\n )\n}\n\nfunction SidebarTrigger({ className, onClick, asChild, children, ...props }: React.ComponentProps<typeof Button>) {\n const { toggleSidebar } = useSidebar()\n\n return (\n <Button\n data-sidebar=\"trigger\"\n data-slot=\"sidebar-trigger\"\n variant=\"ghost\"\n size=\"icon-sm\"\n asChild={asChild}\n className={cn(className)}\n onClick={(event) => {\n onClick?.(event)\n toggleSidebar()\n }}\n {...props}\n >\n {asChild\n ? children\n : (children ?? (\n <>\n <PanelLeftIcon />\n <span className=\"sr-only\">Toggle Sidebar</span>\n </>\n ))}\n </Button>\n )\n}\n\nfunction SidebarRail({ className, ...props }: React.ComponentProps<\"button\">) {\n const { toggleSidebar } = useSidebar()\n\n return (\n <button\n data-sidebar=\"rail\"\n data-slot=\"sidebar-rail\"\n aria-label=\"Toggle Sidebar\"\n tabIndex={-1}\n onClick={toggleSidebar}\n title=\"Toggle Sidebar\"\n className={cn(\n \"absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:inset-s-1/2 after:w-0.5 hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2\",\n \"in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize\",\n \"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize\",\n \"group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar\",\n \"[[data-side=left][data-collapsible=offcanvas]_&]:-right-2\",\n \"[[data-side=right][data-collapsible=offcanvas]_&]:-left-2\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarInset({ className, ...props }: React.ComponentProps<\"main\">) {\n return (\n <main\n data-slot=\"sidebar-inset\"\n className={cn(\n \"relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarInput({ className, ...props }: React.ComponentProps<typeof Input>) {\n return (\n <Input\n data-slot=\"sidebar-input\"\n data-sidebar=\"input\"\n className={cn(\"h-8 w-full bg-background shadow-none\", className)}\n {...props}\n />\n )\n}\n\nfunction SidebarHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"sidebar-header\"\n data-sidebar=\"header\"\n className={cn(\"flex flex-col gap-2 p-2\", className)}\n {...props}\n />\n )\n}\n\nfunction SidebarFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"sidebar-footer\"\n data-sidebar=\"footer\"\n className={cn(\"flex flex-col gap-2 p-2\", className)}\n {...props}\n />\n )\n}\n\nfunction SidebarSeparator({ className, ...props }: React.ComponentProps<typeof Separator>) {\n return (\n <Separator\n data-slot=\"sidebar-separator\"\n data-sidebar=\"separator\"\n className={cn(\"mx-2 w-auto bg-sidebar-border\", className)}\n {...props}\n />\n )\n}\n\nfunction SidebarContent({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"sidebar-content\"\n data-sidebar=\"content\"\n className={cn(\n \"no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"sidebar-group\"\n data-sidebar=\"group\"\n className={cn(\"relative flex w-full min-w-0 flex-col p-2\", className)}\n {...props}\n />\n )\n}\n\nfunction SidebarGroupLabel({\n className,\n asChild = false,\n ...props\n}: React.ComponentProps<\"div\"> & { asChild?: boolean }) {\n const Comp = ark.div\n\n return (\n <Comp\n asChild={asChild}\n data-slot=\"sidebar-group-label\"\n data-sidebar=\"group-label\"\n className={cn(\n \"flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarGroupAction({\n className,\n asChild = false,\n ...props\n}: React.ComponentProps<\"button\"> & { asChild?: boolean }) {\n const Comp = ark.button\n\n return (\n <Comp\n asChild={asChild}\n data-slot=\"sidebar-group-action\"\n data-sidebar=\"group-action\"\n className={cn(\n \"absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarGroupContent({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"sidebar-group-content\"\n data-sidebar=\"group-content\"\n className={cn(\"w-full text-sm\", className)}\n {...props}\n />\n )\n}\n\nfunction SidebarMenu({ className, ...props }: React.ComponentProps<\"ul\">) {\n return (\n <ul\n data-slot=\"sidebar-menu\"\n data-sidebar=\"menu\"\n className={cn(\"flex w-full min-w-0 flex-col gap-0\", className)}\n {...props}\n />\n )\n}\n\nfunction SidebarMenuItem({ className, ...props }: React.ComponentProps<\"li\">) {\n return (\n <li\n data-slot=\"sidebar-menu-item\"\n data-sidebar=\"menu-item\"\n className={cn(\"group/menu-item relative\", className)}\n {...props}\n />\n )\n}\n\nconst sidebarMenuButtonVariants = cva(\n \"peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate\",\n {\n variants: {\n variant: {\n default: \"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground\",\n outline:\n \"bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]\",\n },\n size: {\n default: \"h-8 text-sm\",\n sm: \"h-7 text-xs\",\n lg: \"h-12 text-sm group-data-[collapsible=icon]:p-0!\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n }\n)\n\nfunction SidebarMenuButton({\n asChild = false,\n isActive = false,\n variant = \"default\",\n size = \"default\",\n tooltip,\n className,\n ...props\n}: React.ComponentProps<\"button\"> & {\n asChild?: boolean\n isActive?: boolean\n tooltip?: string | React.ComponentProps<typeof TooltipContent>\n} & VariantProps<typeof sidebarMenuButtonVariants>) {\n const Comp = ark.button\n const { isMobile, state } = useSidebar()\n\n const button = (\n <Comp\n asChild={asChild}\n data-slot=\"sidebar-menu-button\"\n data-sidebar=\"menu-button\"\n data-size={size}\n data-active={isActive}\n className={cn(sidebarMenuButtonVariants({ variant, size }), className)}\n {...props}\n />\n )\n\n if (!tooltip) {\n return button\n }\n\n if (typeof tooltip === \"string\") {\n tooltip = {\n children: tooltip,\n }\n }\n\n return (\n <Tooltip positioning={{ placement: \"right\" }}>\n <TooltipTrigger asChild>{button}</TooltipTrigger>\n <TooltipContent hidden={state !== \"collapsed\" || isMobile} {...tooltip} />\n </Tooltip>\n )\n}\n\nfunction SidebarMenuAction({\n className,\n asChild = false,\n showOnHover = false,\n ...props\n}: React.ComponentProps<\"button\"> & {\n asChild?: boolean\n showOnHover?: boolean\n}) {\n const Comp = ark.button\n\n return (\n <Comp\n asChild={asChild}\n data-slot=\"sidebar-menu-action\"\n data-sidebar=\"menu-action\"\n className={cn(\n \"absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0\",\n showOnHover &&\n \"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarMenuBadge({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"sidebar-menu-badge\"\n data-sidebar=\"menu-badge\"\n className={cn(\n \"pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarMenuSkeleton({\n className,\n showIcon = false,\n ...props\n}: React.ComponentProps<\"div\"> & {\n showIcon?: boolean\n}) {\n // Random width between 50 to 90%.\n const [width] = React.useState(() => {\n return `${Math.floor(Math.random() * 40) + 50}%`\n })\n\n return (\n <div\n data-slot=\"sidebar-menu-skeleton\"\n data-sidebar=\"menu-skeleton\"\n className={cn(\"flex h-8 items-center gap-2 rounded-md px-2\", className)}\n {...props}\n >\n {showIcon && <Skeleton className=\"size-4 rounded-md\" data-sidebar=\"menu-skeleton-icon\" />}\n <Skeleton\n className=\"h-4 max-w-(--skeleton-width) flex-1\"\n data-sidebar=\"menu-skeleton-text\"\n style={\n {\n \"--skeleton-width\": width,\n } as React.CSSProperties\n }\n />\n </div>\n )\n}\n\nfunction SidebarMenuSub({ className, ...props }: React.ComponentProps<\"ul\">) {\n return (\n <ul\n data-slot=\"sidebar-menu-sub\"\n data-sidebar=\"menu-sub\"\n className={cn(\n \"mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarMenuSubItem({ className, ...props }: React.ComponentProps<\"li\">) {\n return (\n <li\n data-slot=\"sidebar-menu-sub-item\"\n data-sidebar=\"menu-sub-item\"\n className={cn(\"group/menu-sub-item relative\", className)}\n {...props}\n />\n )\n}\n\nfunction SidebarMenuSubButton({\n asChild = false,\n size = \"md\",\n isActive = false,\n className,\n ...props\n}: React.ComponentProps<\"a\"> & {\n asChild?: boolean\n size?: \"sm\" | \"md\"\n isActive?: boolean\n}) {\n const Comp = ark.a\n\n return (\n <Comp\n asChild={asChild}\n data-slot=\"sidebar-menu-sub-button\"\n data-sidebar=\"menu-sub-button\"\n data-size={size}\n data-active={isActive}\n className={cn(\n \"flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground\",\n className\n )}\n {...props}\n />\n )\n}\n\nexport {\n Sidebar,\n SidebarContent,\n SidebarFooter,\n SidebarGroup,\n SidebarGroupAction,\n SidebarGroupContent,\n SidebarGroupLabel,\n SidebarHeader,\n SidebarInput,\n SidebarInset,\n SidebarMenu,\n SidebarMenuAction,\n SidebarMenuBadge,\n SidebarMenuButton,\n SidebarMenuItem,\n SidebarMenuSkeleton,\n SidebarMenuSub,\n SidebarMenuSubButton,\n SidebarMenuSubItem,\n SidebarProvider,\n SidebarRail,\n SidebarSeparator,\n SidebarTrigger,\n useSidebar,\n}\n"
|
|
833
|
+
"content": "import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"@/lib/utils\"\nimport { ark } from \"@ark-ui/react\"\n\nimport { useIsMobile } from \"@/hooks/use-mobile\"\nimport { Button } from \"@/components/ui/button\"\nimport { Input } from \"@/components/ui/input\"\nimport { Separator } from \"@/components/ui/separator\"\nimport { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from \"@/components/ui/sheet\"\nimport { Skeleton } from \"@/components/ui/skeleton\"\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@/components/ui/tooltip\"\nimport { PanelLeftIcon } from \"lucide-react\"\n\nconst SIDEBAR_COOKIE_NAME = \"sidebar_state\"\nconst SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7\nconst SIDEBAR_WIDTH = \"16rem\"\nconst SIDEBAR_WIDTH_MOBILE = \"18rem\"\nconst SIDEBAR_WIDTH_ICON = \"3rem\"\nconst SIDEBAR_KEYBOARD_SHORTCUT = \"b\"\n\ntype SidebarContextProps = {\n state: \"expanded\" | \"collapsed\"\n open: boolean\n setOpen: (open: boolean) => void\n openMobile: boolean\n setOpenMobile: (open: boolean) => void\n isMobile: boolean\n toggleSidebar: () => void\n}\n\nconst SidebarContext = React.createContext<SidebarContextProps | null>(null)\n\nfunction useSidebar() {\n const context = React.useContext(SidebarContext)\n if (!context) {\n throw new Error(\"useSidebar must be used within a SidebarProvider.\")\n }\n\n return context\n}\n\nfunction SidebarProvider({\n defaultOpen = true,\n open: openProp,\n onOpenChange: setOpenProp,\n className,\n style,\n children,\n ...props\n}: React.ComponentProps<\"div\"> & {\n defaultOpen?: boolean\n open?: boolean\n onOpenChange?: (open: boolean) => void\n}) {\n const isMobile = useIsMobile()\n const [openMobile, setOpenMobile] = React.useState(false)\n\n // This is the internal state of the sidebar.\n // We use openProp and setOpenProp for control from outside the component.\n const [_open, _setOpen] = React.useState(defaultOpen)\n const open = openProp ?? _open\n const setOpen = React.useCallback(\n (value: boolean | ((value: boolean) => boolean)) => {\n const openState = typeof value === \"function\" ? value(open) : value\n if (setOpenProp) {\n setOpenProp(openState)\n } else {\n _setOpen(openState)\n }\n\n // This sets the cookie to keep the sidebar state.\n document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`\n },\n [setOpenProp, open]\n )\n\n // Helper to toggle the sidebar.\n const toggleSidebar = React.useCallback(() => {\n return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open)\n }, [isMobile, setOpen, setOpenMobile])\n\n // Adds a keyboard shortcut to toggle the sidebar.\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {\n event.preventDefault()\n toggleSidebar()\n }\n }\n\n window.addEventListener(\"keydown\", handleKeyDown)\n return () => window.removeEventListener(\"keydown\", handleKeyDown)\n }, [toggleSidebar])\n\n // We add a state so that we can do data-state=\"expanded\" or \"collapsed\".\n // This makes it easier to style the sidebar with Tailwind classes.\n const state = open ? \"expanded\" : \"collapsed\"\n\n const contextValue = React.useMemo<SidebarContextProps>(\n () => ({\n state,\n open,\n setOpen,\n isMobile,\n openMobile,\n setOpenMobile,\n toggleSidebar,\n }),\n [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]\n )\n\n return (\n <SidebarContext.Provider value={contextValue}>\n <div\n data-slot=\"sidebar-wrapper\"\n style={\n {\n \"--sidebar-width\": SIDEBAR_WIDTH,\n \"--sidebar-width-icon\": SIDEBAR_WIDTH_ICON,\n ...style,\n } as React.CSSProperties\n }\n className={cn(\"group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar\", className)}\n {...props}\n >\n {children}\n </div>\n </SidebarContext.Provider>\n )\n}\n\nfunction Sidebar({\n side = \"left\",\n variant = \"sidebar\",\n collapsible = \"offcanvas\",\n className,\n children,\n dir,\n ...props\n}: React.ComponentProps<\"div\"> & {\n side?: \"left\" | \"right\"\n variant?: \"sidebar\" | \"floating\" | \"inset\"\n /** Collapse mode: `offcanvas`, `icon`, or `none`. */\n collapsible?: \"offcanvas\" | \"icon\" | \"none\"\n}) {\n const { isMobile, state, openMobile, setOpenMobile } = useSidebar()\n\n if (collapsible === \"none\") {\n return (\n <div\n data-slot=\"sidebar\"\n className={cn(\"flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground\", className)}\n {...props}\n >\n {children}\n </div>\n )\n }\n\n if (isMobile) {\n return (\n <Sheet open={openMobile} onOpenChange={({ open }) => setOpenMobile(open)}>\n <SheetContent\n {...props}\n dir={dir}\n data-sidebar=\"sidebar\"\n data-slot=\"sidebar\"\n data-mobile=\"true\"\n className=\"w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden\"\n style={\n {\n \"--sidebar-width\": SIDEBAR_WIDTH_MOBILE,\n } as React.CSSProperties\n }\n side={side}\n >\n <SheetHeader className=\"sr-only\">\n <SheetTitle>Sidebar</SheetTitle>\n <SheetDescription>Displays the mobile sidebar.</SheetDescription>\n </SheetHeader>\n <div className=\"flex size-full flex-col\">{children}</div>\n </SheetContent>\n </Sheet>\n )\n }\n\n return (\n <div\n className=\"group peer hidden text-sidebar-foreground md:block\"\n data-state={state}\n data-collapsible={state === \"collapsed\" ? collapsible : \"\"}\n data-variant={variant}\n data-side={side}\n data-slot=\"sidebar\"\n >\n {/* This is what handles the sidebar gap on desktop */}\n <div\n data-slot=\"sidebar-gap\"\n className={cn(\n \"relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear\",\n \"group-data-[collapsible=offcanvas]:w-0\",\n \"group-data-[side=right]:rotate-180\",\n variant === \"floating\" || variant === \"inset\"\n ? \"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]\"\n : \"group-data-[collapsible=icon]:w-(--sidebar-width-icon)\"\n )}\n />\n <div\n data-slot=\"sidebar-container\"\n data-side={side}\n className={cn(\n \"fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:-left-(--sidebar-width) data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:-right-(--sidebar-width) md:flex\",\n // Adjust the padding for floating and inset variants.\n variant === \"floating\" || variant === \"inset\"\n ? \"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]\"\n : \"group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l\",\n className\n )}\n {...props}\n >\n <div\n data-sidebar=\"sidebar\"\n data-slot=\"sidebar-inner\"\n className=\"flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border\"\n >\n {children}\n </div>\n </div>\n </div>\n )\n}\n\nfunction SidebarTrigger({ className, onClick, asChild, children, ...props }: React.ComponentProps<typeof Button>) {\n const { toggleSidebar } = useSidebar()\n\n return (\n <Button\n data-sidebar=\"trigger\"\n data-slot=\"sidebar-trigger\"\n variant=\"ghost\"\n size=\"icon-sm\"\n asChild={asChild}\n className={cn(className)}\n onClick={(event) => {\n onClick?.(event)\n toggleSidebar()\n }}\n {...props}\n >\n {asChild\n ? children\n : (children ?? (\n <>\n <PanelLeftIcon />\n <span className=\"sr-only\">Toggle Sidebar</span>\n </>\n ))}\n </Button>\n )\n}\n\nfunction SidebarRail({ className, ...props }: React.ComponentProps<\"button\">) {\n const { toggleSidebar } = useSidebar()\n\n return (\n <button\n data-sidebar=\"rail\"\n data-slot=\"sidebar-rail\"\n aria-label=\"Toggle Sidebar\"\n tabIndex={-1}\n onClick={toggleSidebar}\n title=\"Toggle Sidebar\"\n className={cn(\n \"absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:inset-s-1/2 after:w-0.5 hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2\",\n \"in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize\",\n \"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize\",\n \"group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar\",\n \"[[data-side=left][data-collapsible=offcanvas]_&]:-right-2\",\n \"[[data-side=right][data-collapsible=offcanvas]_&]:-left-2\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarInset({ className, ...props }: React.ComponentProps<\"main\">) {\n return (\n <main\n data-slot=\"sidebar-inset\"\n className={cn(\n \"relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarInput({ className, ...props }: React.ComponentProps<typeof Input>) {\n return (\n <Input\n data-slot=\"sidebar-input\"\n data-sidebar=\"input\"\n className={cn(\"h-8 w-full bg-background shadow-none\", className)}\n {...props}\n />\n )\n}\n\nfunction SidebarHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"sidebar-header\"\n data-sidebar=\"header\"\n className={cn(\"flex flex-col gap-2 p-2\", className)}\n {...props}\n />\n )\n}\n\nfunction SidebarFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"sidebar-footer\"\n data-sidebar=\"footer\"\n className={cn(\"flex flex-col gap-2 p-2\", className)}\n {...props}\n />\n )\n}\n\nfunction SidebarSeparator({ className, ...props }: React.ComponentProps<typeof Separator>) {\n return (\n <Separator\n data-slot=\"sidebar-separator\"\n data-sidebar=\"separator\"\n className={cn(\"mx-2 w-auto bg-sidebar-border\", className)}\n {...props}\n />\n )\n}\n\nfunction SidebarContent({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"sidebar-content\"\n data-sidebar=\"content\"\n className={cn(\n \"no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"sidebar-group\"\n data-sidebar=\"group\"\n className={cn(\"relative flex w-full min-w-0 flex-col p-2\", className)}\n {...props}\n />\n )\n}\n\nfunction SidebarGroupLabel({\n className,\n asChild = false,\n ...props\n}: React.ComponentProps<\"div\"> & { asChild?: boolean }) {\n const Comp = ark.div\n\n return (\n <Comp\n asChild={asChild}\n data-slot=\"sidebar-group-label\"\n data-sidebar=\"group-label\"\n className={cn(\n \"flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarGroupAction({\n className,\n asChild = false,\n ...props\n}: React.ComponentProps<\"button\"> & { asChild?: boolean }) {\n const Comp = ark.button\n\n return (\n <Comp\n asChild={asChild}\n data-slot=\"sidebar-group-action\"\n data-sidebar=\"group-action\"\n className={cn(\n \"absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarGroupContent({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"sidebar-group-content\"\n data-sidebar=\"group-content\"\n className={cn(\"w-full text-sm\", className)}\n {...props}\n />\n )\n}\n\nfunction SidebarMenu({ className, ...props }: React.ComponentProps<\"ul\">) {\n return (\n <ul\n data-slot=\"sidebar-menu\"\n data-sidebar=\"menu\"\n className={cn(\"flex w-full min-w-0 flex-col gap-0\", className)}\n {...props}\n />\n )\n}\n\nfunction SidebarMenuItem({ className, ...props }: React.ComponentProps<\"li\">) {\n return (\n <li\n data-slot=\"sidebar-menu-item\"\n data-sidebar=\"menu-item\"\n className={cn(\"group/menu-item relative\", className)}\n {...props}\n />\n )\n}\n\nconst sidebarMenuButtonVariants = cva(\n \"peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate\",\n {\n variants: {\n variant: {\n default: \"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground\",\n outline:\n \"bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]\",\n },\n size: {\n default: \"h-8 text-sm\",\n sm: \"h-7 text-xs\",\n lg: \"h-12 text-sm group-data-[collapsible=icon]:p-0!\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n }\n)\n\nfunction SidebarMenuButton({\n asChild = false,\n isActive = false,\n variant = \"default\",\n size = \"default\",\n tooltip,\n className,\n ...props\n}: React.ComponentProps<\"button\"> & {\n asChild?: boolean\n /** Marks the current item. */\n isActive?: boolean\n tooltip?: string | React.ComponentProps<typeof TooltipContent>\n} & VariantProps<typeof sidebarMenuButtonVariants>) {\n const Comp = ark.button\n const { isMobile, state } = useSidebar()\n\n const button = (\n <Comp\n asChild={asChild}\n data-slot=\"sidebar-menu-button\"\n data-sidebar=\"menu-button\"\n data-size={size}\n data-active={isActive}\n className={cn(sidebarMenuButtonVariants({ variant, size }), className)}\n {...props}\n />\n )\n\n if (!tooltip) {\n return button\n }\n\n if (typeof tooltip === \"string\") {\n tooltip = {\n children: tooltip,\n }\n }\n\n return (\n <Tooltip positioning={{ placement: \"right\" }}>\n <TooltipTrigger asChild>{button}</TooltipTrigger>\n <TooltipContent hidden={state !== \"collapsed\" || isMobile} {...tooltip} />\n </Tooltip>\n )\n}\n\nfunction SidebarMenuAction({\n className,\n asChild = false,\n showOnHover = false,\n ...props\n}: React.ComponentProps<\"button\"> & {\n asChild?: boolean\n /** Only reveal the action when the item is hovered or focused. */\n showOnHover?: boolean\n}) {\n const Comp = ark.button\n\n return (\n <Comp\n asChild={asChild}\n data-slot=\"sidebar-menu-action\"\n data-sidebar=\"menu-action\"\n className={cn(\n \"absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0\",\n showOnHover &&\n \"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarMenuBadge({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"sidebar-menu-badge\"\n data-sidebar=\"menu-badge\"\n className={cn(\n \"pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarMenuSkeleton({\n className,\n showIcon = false,\n ...props\n}: React.ComponentProps<\"div\"> & {\n /** Render an icon placeholder in the skeleton. */\n showIcon?: boolean\n}) {\n // Random width between 50 to 90%.\n const [width] = React.useState(() => {\n return `${Math.floor(Math.random() * 40) + 50}%`\n })\n\n return (\n <div\n data-slot=\"sidebar-menu-skeleton\"\n data-sidebar=\"menu-skeleton\"\n className={cn(\"flex h-8 items-center gap-2 rounded-md px-2\", className)}\n {...props}\n >\n {showIcon && <Skeleton className=\"size-4 rounded-md\" data-sidebar=\"menu-skeleton-icon\" />}\n <Skeleton\n className=\"h-4 max-w-(--skeleton-width) flex-1\"\n data-sidebar=\"menu-skeleton-text\"\n style={\n {\n \"--skeleton-width\": width,\n } as React.CSSProperties\n }\n />\n </div>\n )\n}\n\nfunction SidebarMenuSub({ className, ...props }: React.ComponentProps<\"ul\">) {\n return (\n <ul\n data-slot=\"sidebar-menu-sub\"\n data-sidebar=\"menu-sub\"\n className={cn(\n \"mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarMenuSubItem({ className, ...props }: React.ComponentProps<\"li\">) {\n return (\n <li\n data-slot=\"sidebar-menu-sub-item\"\n data-sidebar=\"menu-sub-item\"\n className={cn(\"group/menu-sub-item relative\", className)}\n {...props}\n />\n )\n}\n\nfunction SidebarMenuSubButton({\n asChild = false,\n size = \"md\",\n isActive = false,\n className,\n ...props\n}: React.ComponentProps<\"a\"> & {\n asChild?: boolean\n size?: \"sm\" | \"md\"\n /** Marks the current item. */\n isActive?: boolean\n}) {\n const Comp = ark.a\n\n return (\n <Comp\n asChild={asChild}\n data-slot=\"sidebar-menu-sub-button\"\n data-sidebar=\"menu-sub-button\"\n data-size={size}\n data-active={isActive}\n className={cn(\n \"flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground\",\n className\n )}\n {...props}\n />\n )\n}\n\nexport {\n Sidebar,\n SidebarContent,\n SidebarFooter,\n SidebarGroup,\n SidebarGroupAction,\n SidebarGroupContent,\n SidebarGroupLabel,\n SidebarHeader,\n SidebarInput,\n SidebarInset,\n SidebarMenu,\n SidebarMenuAction,\n SidebarMenuBadge,\n SidebarMenuButton,\n SidebarMenuItem,\n SidebarMenuSkeleton,\n SidebarMenuSub,\n SidebarMenuSubButton,\n SidebarMenuSubItem,\n SidebarProvider,\n SidebarRail,\n SidebarSeparator,\n SidebarTrigger,\n useSidebar,\n}\n"
|
|
50
834
|
}
|
|
51
835
|
],
|
|
52
836
|
"docs": "## App shell\n`src/components/ui/app-shell.tsx` is a compositional, router-agnostic shell built on\n`sidebar.tsx` (shadcn-admin layout): `AppShell` (context: sidebar variant/collapsible,\nsearch open state, `searchShortcut` for cmd/ctrl+K), `AppShellSidebar` + `AppShellBrand*`,\n`AppShellNav*` (groups, links with `active`, badges, `AppShellNavCollapsible` that becomes\na dropdown flyout when the sidebar is icon-collapsed), `AppShellUser*`, `AppShellContent`,\n`AppShellHeader` (fixed/sticky with scroll shadow, includes the sidebar trigger),\n`AppShellHeaderActions`, `AppShellMain` (`fixed` = viewport-height, `fluid` = full width),\n`AppShellTopNav*`, `AppShellSearch` + `AppShellCommandDialog` (bound to shell search\nstate; nest a `Command` inside), `AppShellNotifications*` (Popover-based bell with a `count`\nbadge on the trigger; header/title/action, list, `AppShellNotificationItem` with `unread` +\n`asChild` surface, icon/content/title/description/time/indicator, empty, footer; data and read\nstate are the consumer's), and `AppShellThemeToggle` (`theme`/`onThemeChange`, no theme\nlibrary assumed). Header icon buttons use `size=\"icon-lg\"` (size-9, `scale-95 rounded-full`)\nand `AppShellHeaderActions` uses the header's `gap-3 sm:gap-4` to match shadcn-admin. Navigation is plain anchors with `asChild` so any router works.\n`src/demo/shell/` is the reference (nav data, hash router, team/user menus, command menu)\nand `src/app.tsx` wraps every demo route in it. `AppShellDemo` takes `headerStart` for\npage-specific header content (the dashboard passes its `AppShellTopNav` + `AppShellTopNavMenu`)."
|