@stevederico/skateboard-ui 3.12.0 → 4.0.0
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/CHANGELOG.md +12 -0
- package/README.md +37 -31
- package/dist/shadcn/ui/accordion.d.ts +1 -6
- package/dist/shadcn/ui/accordion.js +3 -17
- package/dist/shadcn/ui/alert-dialog.d.ts +1 -18
- package/dist/shadcn/ui/alert-dialog.js +3 -43
- package/dist/shadcn/ui/alert.d.ts +1 -13
- package/dist/shadcn/ui/alert.js +3 -28
- package/dist/shadcn/ui/aspect-ratio.d.ts +1 -4
- package/dist/shadcn/ui/aspect-ratio.js +3 -8
- package/dist/shadcn/ui/avatar.d.ts +1 -11
- package/dist/shadcn/ui/avatar.js +3 -24
- package/dist/shadcn/ui/badge.d.ts +1 -14
- package/dist/shadcn/ui/badge.js +3 -33
- package/dist/shadcn/ui/breadcrumb.d.ts +1 -10
- package/dist/shadcn/ui/breadcrumb.js +3 -37
- package/dist/shadcn/ui/button-group.d.ts +1 -13
- package/dist/shadcn/ui/button-group.js +3 -36
- package/dist/shadcn/ui/button.d.ts +1 -34
- package/dist/shadcn/ui/button.js +3 -53
- package/dist/shadcn/ui/calendar.d.ts +1 -13
- package/dist/shadcn/ui/calendar.js +3 -75
- package/dist/shadcn/ui/card.d.ts +1 -11
- package/dist/shadcn/ui/card.js +3 -25
- package/dist/shadcn/ui/checkbox.d.ts +1 -3
- package/dist/shadcn/ui/checkbox.js +3 -9
- package/dist/shadcn/ui/collapsible.d.ts +1 -5
- package/dist/shadcn/ui/collapsible.js +3 -13
- package/dist/shadcn/ui/command.d.ts +1 -19
- package/dist/shadcn/ui/command.js +3 -35
- package/dist/shadcn/ui/context-menu.d.ts +1 -29
- package/dist/shadcn/ui/context-menu.js +3 -52
- package/dist/shadcn/ui/dialog.d.ts +1 -17
- package/dist/shadcn/ui/dialog.js +3 -38
- package/dist/shadcn/ui/drawer.d.ts +1 -13
- package/dist/shadcn/ui/drawer.js +3 -196
- package/dist/shadcn/ui/dropdown-menu.d.ts +1 -29
- package/dist/shadcn/ui/dropdown-menu.js +3 -52
- package/dist/shadcn/ui/empty.d.ts +1 -14
- package/dist/shadcn/ui/empty.js +3 -33
- package/dist/shadcn/ui/field.d.ts +1 -28
- package/dist/shadcn/ui/field.js +3 -68
- package/dist/shadcn/ui/hover-card.d.ts +1 -5
- package/dist/shadcn/ui/hover-card.js +3 -14
- package/dist/shadcn/ui/input-group.d.ts +1 -28
- package/dist/shadcn/ui/input-group.js +3 -58
- package/dist/shadcn/ui/input.d.ts +1 -3
- package/dist/shadcn/ui/input.js +3 -8
- package/dist/shadcn/ui/item.d.ts +1 -34
- package/dist/shadcn/ui/item.js +3 -79
- package/dist/shadcn/ui/kbd.d.ts +1 -3
- package/dist/shadcn/ui/kbd.js +3 -9
- package/dist/shadcn/ui/label.d.ts +1 -3
- package/dist/shadcn/ui/label.js +3 -8
- package/dist/shadcn/ui/menubar.d.ts +1 -29
- package/dist/shadcn/ui/menubar.js +3 -57
- package/dist/shadcn/ui/navigation-menu.d.ts +1 -13
- package/dist/shadcn/ui/navigation-menu.js +3 -31
- package/dist/shadcn/ui/pagination.d.ts +1 -17
- package/dist/shadcn/ui/pagination.js +3 -27
- package/dist/shadcn/ui/popover.d.ts +1 -9
- package/dist/shadcn/ui/popover.js +3 -24
- package/dist/shadcn/ui/progress.d.ts +1 -7
- package/dist/shadcn/ui/progress.js +3 -20
- package/dist/shadcn/ui/radio-group.d.ts +1 -5
- package/dist/shadcn/ui/radio-group.js +3 -12
- package/dist/shadcn/ui/scroll-area.d.ts +1 -5
- package/dist/shadcn/ui/scroll-area.js +3 -12
- package/dist/shadcn/ui/select.d.ts +1 -15
- package/dist/shadcn/ui/select.js +3 -35
- package/dist/shadcn/ui/separator.d.ts +1 -3
- package/dist/shadcn/ui/separator.js +3 -8
- package/dist/shadcn/ui/sheet.d.ts +1 -14
- package/dist/shadcn/ui/sheet.js +3 -38
- package/dist/shadcn/ui/sidebar.d.ts +1 -70
- package/dist/shadcn/ui/sidebar.js +3 -256
- package/dist/shadcn/ui/skeleton.d.ts +1 -2
- package/dist/shadcn/ui/skeleton.js +3 -6
- package/dist/shadcn/ui/slider.d.ts +1 -3
- package/dist/shadcn/ui/slider.js +3 -12
- package/dist/shadcn/ui/spinner.d.ts +1 -2
- package/dist/shadcn/ui/spinner.js +3 -7
- package/dist/shadcn/ui/switch.d.ts +1 -5
- package/dist/shadcn/ui/switch.js +3 -8
- package/dist/shadcn/ui/table.d.ts +1 -10
- package/dist/shadcn/ui/table.js +3 -29
- package/dist/shadcn/ui/tabs.d.ts +1 -13
- package/dist/shadcn/ui/tabs.js +3 -29
- package/dist/shadcn/ui/textarea.d.ts +1 -3
- package/dist/shadcn/ui/textarea.js +3 -7
- package/dist/shadcn/ui/toggle-group.d.ts +1 -11
- package/dist/shadcn/ui/toggle-group.js +3 -25
- package/dist/shadcn/ui/toggle.d.ts +1 -15
- package/dist/shadcn/ui/toggle.js +3 -26
- package/dist/shadcn/ui/tooltip.d.ts +1 -6
- package/dist/shadcn/ui/tooltip.js +3 -17
- package/dist/ui/accordion.d.ts +21 -0
- package/dist/ui/accordion.js +67 -0
- package/dist/ui/alert-dialog.d.ts +32 -0
- package/dist/ui/alert-dialog.js +102 -0
- package/dist/ui/alert.d.ts +13 -0
- package/dist/ui/alert.js +28 -0
- package/dist/ui/aspect-ratio.d.ts +5 -0
- package/dist/ui/aspect-ratio.js +9 -0
- package/dist/ui/avatar.d.ts +14 -0
- package/dist/ui/avatar.js +49 -0
- package/dist/ui/badge.d.ts +22 -0
- package/dist/ui/badge.js +26 -0
- package/dist/ui/breadcrumb.d.ts +13 -0
- package/dist/ui/breadcrumb.js +29 -0
- package/dist/ui/button-group.d.ts +21 -0
- package/dist/ui/button-group.js +29 -0
- package/dist/ui/button.d.ts +38 -0
- package/dist/ui/button.js +49 -0
- package/dist/ui/calendar.d.ts +13 -0
- package/dist/ui/calendar.js +75 -0
- package/dist/ui/card.d.ts +11 -0
- package/dist/ui/card.js +25 -0
- package/dist/ui/checkbox.d.ts +17 -0
- package/dist/ui/checkbox.js +25 -0
- package/dist/ui/collapsible.d.ts +11 -0
- package/dist/ui/collapsible.js +40 -0
- package/dist/ui/command.d.ts +19 -0
- package/dist/ui/command.js +35 -0
- package/dist/ui/context-menu.d.ts +53 -0
- package/dist/ui/context-menu.js +345 -0
- package/dist/ui/dialog.d.ts +40 -0
- package/dist/ui/dialog.js +109 -0
- package/dist/ui/drawer.d.ts +36 -0
- package/dist/ui/drawer.js +234 -0
- package/dist/ui/dropdown-menu.d.ts +61 -0
- package/dist/ui/dropdown-menu.js +323 -0
- package/dist/ui/empty.d.ts +14 -0
- package/dist/ui/empty.js +33 -0
- package/dist/ui/field.d.ts +28 -0
- package/dist/ui/field.js +68 -0
- package/dist/ui/hover-card.d.ts +32 -0
- package/dist/ui/hover-card.js +119 -0
- package/dist/ui/input-group.d.ts +28 -0
- package/dist/ui/input-group.js +58 -0
- package/dist/ui/input.d.ts +3 -0
- package/dist/ui/input.js +7 -0
- package/dist/ui/item.d.ts +41 -0
- package/dist/ui/item.js +69 -0
- package/dist/ui/kbd.d.ts +4 -0
- package/dist/ui/kbd.js +10 -0
- package/dist/ui/label.d.ts +3 -0
- package/dist/ui/label.js +8 -0
- package/dist/ui/menubar.d.ts +59 -0
- package/dist/ui/menubar.js +384 -0
- package/dist/ui/navigation-menu.d.ts +24 -0
- package/dist/ui/navigation-menu.js +134 -0
- package/dist/ui/pagination.d.ts +17 -0
- package/dist/ui/pagination.js +36 -0
- package/dist/ui/popover.d.ts +25 -0
- package/dist/ui/popover.js +68 -0
- package/dist/ui/portal.d.ts +7 -0
- package/dist/ui/portal.js +12 -0
- package/dist/ui/progress.d.ts +15 -0
- package/dist/ui/progress.js +36 -0
- package/dist/ui/radio-group.d.ts +17 -0
- package/dist/ui/radio-group.js +54 -0
- package/dist/ui/scroll-area.d.ts +9 -0
- package/dist/ui/scroll-area.js +72 -0
- package/dist/ui/select.d.ts +37 -0
- package/dist/ui/select.js +216 -0
- package/dist/ui/separator.d.ts +14 -0
- package/dist/ui/separator.js +13 -0
- package/dist/ui/sheet.d.ts +31 -0
- package/dist/ui/sheet.js +121 -0
- package/dist/ui/sidebar.d.ts +86 -0
- package/dist/ui/sidebar.js +211 -0
- package/dist/ui/skeleton.d.ts +3 -0
- package/dist/ui/skeleton.js +7 -0
- package/dist/ui/slider.d.ts +18 -0
- package/dist/ui/slider.js +94 -0
- package/dist/ui/slot.d.ts +27 -0
- package/dist/ui/slot.js +62 -0
- package/dist/ui/spinner.d.ts +3 -0
- package/dist/ui/spinner.js +8 -0
- package/dist/ui/switch.d.ts +17 -0
- package/dist/ui/switch.js +23 -0
- package/dist/ui/table.d.ts +10 -0
- package/dist/ui/table.js +29 -0
- package/dist/ui/tabs.d.ts +29 -0
- package/dist/ui/tabs.js +82 -0
- package/dist/ui/textarea.d.ts +3 -0
- package/dist/ui/textarea.js +7 -0
- package/dist/ui/toggle-group.d.ts +23 -0
- package/dist/ui/toggle-group.js +52 -0
- package/dist/ui/toggle.d.ts +25 -0
- package/dist/ui/toggle.js +41 -0
- package/dist/ui/tooltip.d.ts +25 -0
- package/dist/ui/tooltip.js +90 -0
- package/dist/ui/use-controllable-state.d.ts +10 -0
- package/dist/ui/use-controllable-state.js +17 -0
- package/dist/ui/use-dismiss.d.ts +10 -0
- package/dist/ui/use-dismiss.js +51 -0
- package/dist/ui/use-floating.d.ts +38 -0
- package/dist/ui/use-floating.js +128 -0
- package/dist/ui/use-presence.d.ts +8 -0
- package/dist/ui/use-presence.js +48 -0
- package/package.json +6 -1
- package/dist/shadcn/lib/base-ui/LICENSE +0 -21
- package/dist/shadcn/lib/base-ui/_chunk-000kmre8.js +0 -150
- package/dist/shadcn/lib/base-ui/_chunk-1vw45v38.js +0 -64
- package/dist/shadcn/lib/base-ui/_chunk-23rx7haq.js +0 -81
- package/dist/shadcn/lib/base-ui/_chunk-242gh8ph.js +0 -230
- package/dist/shadcn/lib/base-ui/_chunk-26cc610z.js +0 -6
- package/dist/shadcn/lib/base-ui/_chunk-2z044bba.js +0 -5890
- package/dist/shadcn/lib/base-ui/_chunk-3cpd1vjz.js +0 -13
- package/dist/shadcn/lib/base-ui/_chunk-3enq1vat.js +0 -82
- package/dist/shadcn/lib/base-ui/_chunk-3xpke33f.js +0 -23
- package/dist/shadcn/lib/base-ui/_chunk-451nqgsa.js +0 -6
- package/dist/shadcn/lib/base-ui/_chunk-4maf6pas.js +0 -11
- package/dist/shadcn/lib/base-ui/_chunk-4zhfq4d3.js +0 -16
- package/dist/shadcn/lib/base-ui/_chunk-5gaqyne5.js +0 -21
- package/dist/shadcn/lib/base-ui/_chunk-5tt5hk59.js +0 -4
- package/dist/shadcn/lib/base-ui/_chunk-5tze5c8q.js +0 -13
- package/dist/shadcn/lib/base-ui/_chunk-5xmdvndx.js +0 -225
- package/dist/shadcn/lib/base-ui/_chunk-6adaer33.js +0 -435
- package/dist/shadcn/lib/base-ui/_chunk-6ejf1z1r.js +0 -9
- package/dist/shadcn/lib/base-ui/_chunk-6kqramh9.js +0 -27
- package/dist/shadcn/lib/base-ui/_chunk-7b9dc493.js +0 -14
- package/dist/shadcn/lib/base-ui/_chunk-8a9vv8am.js +0 -89
- package/dist/shadcn/lib/base-ui/_chunk-8ctgmf06.js +0 -129
- package/dist/shadcn/lib/base-ui/_chunk-8ganmsbg.js +0 -54
- package/dist/shadcn/lib/base-ui/_chunk-8xaqxgck.js +0 -15
- package/dist/shadcn/lib/base-ui/_chunk-95tf2rxq.js +0 -62
- package/dist/shadcn/lib/base-ui/_chunk-9x63vfqj.js +0 -70
- package/dist/shadcn/lib/base-ui/_chunk-ase0ydtt.js +0 -9
- package/dist/shadcn/lib/base-ui/_chunk-b0nc8wq7.js +0 -34
- package/dist/shadcn/lib/base-ui/_chunk-b5ya6xds.js +0 -10
- package/dist/shadcn/lib/base-ui/_chunk-b6dkjkbw.js +0 -43
- package/dist/shadcn/lib/base-ui/_chunk-c2bz952e.js +0 -19
- package/dist/shadcn/lib/base-ui/_chunk-cdgfsr3q.js +0 -15
- package/dist/shadcn/lib/base-ui/_chunk-cdj8cpx5.js +0 -347
- package/dist/shadcn/lib/base-ui/_chunk-cgptgywc.js +0 -104
- package/dist/shadcn/lib/base-ui/_chunk-cwvtvwc7.js +0 -35
- package/dist/shadcn/lib/base-ui/_chunk-dan0mva4.js +0 -23
- package/dist/shadcn/lib/base-ui/_chunk-dzvjwv25.js +0 -0
- package/dist/shadcn/lib/base-ui/_chunk-e13rsb6b.js +0 -184
- package/dist/shadcn/lib/base-ui/_chunk-e56mpvk1.js +0 -118
- package/dist/shadcn/lib/base-ui/_chunk-e6k2ecs7.js +0 -48
- package/dist/shadcn/lib/base-ui/_chunk-ebyxgtb4.js +0 -29
- package/dist/shadcn/lib/base-ui/_chunk-f2wttwrf.js +0 -39
- package/dist/shadcn/lib/base-ui/_chunk-fdzctasg.js +0 -38
- package/dist/shadcn/lib/base-ui/_chunk-ffpjy0ta.js +0 -39
- package/dist/shadcn/lib/base-ui/_chunk-fqry7pew.js +0 -603
- package/dist/shadcn/lib/base-ui/_chunk-ghn1tzt8.js +0 -84
- package/dist/shadcn/lib/base-ui/_chunk-gy0bpkmx.js +0 -12
- package/dist/shadcn/lib/base-ui/_chunk-hm5h9vsk.js +0 -16
- package/dist/shadcn/lib/base-ui/_chunk-htdj1jps.js +0 -833
- package/dist/shadcn/lib/base-ui/_chunk-j29xjete.js +0 -146
- package/dist/shadcn/lib/base-ui/_chunk-j3qkyd10.js +0 -50
- package/dist/shadcn/lib/base-ui/_chunk-ktvsd5k6.js +0 -2386
- package/dist/shadcn/lib/base-ui/_chunk-kw8nnq00.js +0 -546
- package/dist/shadcn/lib/base-ui/_chunk-m307wpdj.js +0 -18
- package/dist/shadcn/lib/base-ui/_chunk-mnd0j7v9.js +0 -15
- package/dist/shadcn/lib/base-ui/_chunk-n11h505c.js +0 -32
- package/dist/shadcn/lib/base-ui/_chunk-p0e2qacz.js +0 -26
- package/dist/shadcn/lib/base-ui/_chunk-pv7b791x.js +0 -106
- package/dist/shadcn/lib/base-ui/_chunk-q5cg71p7.js +0 -83
- package/dist/shadcn/lib/base-ui/_chunk-qbezxj1g.js +0 -385
- package/dist/shadcn/lib/base-ui/_chunk-qmsqz6nt.js +0 -15
- package/dist/shadcn/lib/base-ui/_chunk-rrh8rt4v.js +0 -65
- package/dist/shadcn/lib/base-ui/_chunk-s5pwkz8v.js +0 -25
- package/dist/shadcn/lib/base-ui/_chunk-svxv97ph.js +0 -218
- package/dist/shadcn/lib/base-ui/_chunk-t7ppm3t0.js +0 -68
- package/dist/shadcn/lib/base-ui/_chunk-vg16xxmb.js +0 -52
- package/dist/shadcn/lib/base-ui/_chunk-vgkfmtbe.js +0 -21
- package/dist/shadcn/lib/base-ui/_chunk-watha94s.js +0 -14
- package/dist/shadcn/lib/base-ui/_chunk-wdqynnjf.js +0 -35
- package/dist/shadcn/lib/base-ui/_chunk-wx2nxg0p.js +0 -15
- package/dist/shadcn/lib/base-ui/_chunk-x11e1k9r.js +0 -0
- package/dist/shadcn/lib/base-ui/_chunk-x8xehj6d.js +0 -302
- package/dist/shadcn/lib/base-ui/_chunk-xcqbtm2f.js +0 -28
- package/dist/shadcn/lib/base-ui/_chunk-ytnp24gq.js +0 -328
- package/dist/shadcn/lib/base-ui/_chunk-yzr7eg4b.js +0 -6
- package/dist/shadcn/lib/base-ui/_chunk-zk4mtm9m.js +0 -9
- package/dist/shadcn/lib/base-ui/accordion.d.ts +0 -447
- package/dist/shadcn/lib/base-ui/accordion.js +0 -630
- package/dist/shadcn/lib/base-ui/alert-dialog.d.ts +0 -1467
- package/dist/shadcn/lib/base-ui/alert-dialog.js +0 -98
- package/dist/shadcn/lib/base-ui/avatar.d.ts +0 -123
- package/dist/shadcn/lib/base-ui/avatar.js +0 -235
- package/dist/shadcn/lib/base-ui/button.d.ts +0 -84
- package/dist/shadcn/lib/base-ui/button.js +0 -51
- package/dist/shadcn/lib/base-ui/checkbox.d.ts +0 -341
- package/dist/shadcn/lib/base-ui/checkbox.js +0 -501
- package/dist/shadcn/lib/base-ui/collapsible.d.ts +0 -291
- package/dist/shadcn/lib/base-ui/collapsible.js +0 -264
- package/dist/shadcn/lib/base-ui/context-menu.d.ts +0 -2213
- package/dist/shadcn/lib/base-ui/context-menu.js +0 -323
- package/dist/shadcn/lib/base-ui/dialog.d.ts +0 -1448
- package/dist/shadcn/lib/base-ui/dialog.js +0 -79
- package/dist/shadcn/lib/base-ui/input.d.ts +0 -506
- package/dist/shadcn/lib/base-ui/input.js +0 -1027
- package/dist/shadcn/lib/base-ui/menu.d.ts +0 -2275
- package/dist/shadcn/lib/base-ui/menu.js +0 -60
- package/dist/shadcn/lib/base-ui/menubar.d.ts +0 -48
- package/dist/shadcn/lib/base-ui/menubar.js +0 -156
- package/dist/shadcn/lib/base-ui/merge-props.d.ts +0 -70
- package/dist/shadcn/lib/base-ui/merge-props.js +0 -15
- package/dist/shadcn/lib/base-ui/navigation-menu.d.ts +0 -825
- package/dist/shadcn/lib/base-ui/navigation-menu.js +0 -1849
- package/dist/shadcn/lib/base-ui/popover.d.ts +0 -1743
- package/dist/shadcn/lib/base-ui/popover.js +0 -1089
- package/dist/shadcn/lib/base-ui/preview-card.d.ts +0 -1608
- package/dist/shadcn/lib/base-ui/preview-card.js +0 -919
- package/dist/shadcn/lib/base-ui/progress.d.ts +0 -172
- package/dist/shadcn/lib/base-ui/progress.js +0 -272
- package/dist/shadcn/lib/base-ui/radio-group.d.ts +0 -260
- package/dist/shadcn/lib/base-ui/radio-group.js +0 -239
- package/dist/shadcn/lib/base-ui/radio.d.ts +0 -176
- package/dist/shadcn/lib/base-ui/radio.js +0 -387
- package/dist/shadcn/lib/base-ui/scroll-area.d.ts +0 -241
- package/dist/shadcn/lib/base-ui/scroll-area.js +0 -1055
- package/dist/shadcn/lib/base-ui/select.d.ts +0 -1266
- package/dist/shadcn/lib/base-ui/select.js +0 -2450
- package/dist/shadcn/lib/base-ui/separator.d.ts +0 -76
- package/dist/shadcn/lib/base-ui/separator.js +0 -11
- package/dist/shadcn/lib/base-ui/slider.d.ts +0 -551
- package/dist/shadcn/lib/base-ui/slider.js +0 -1583
- package/dist/shadcn/lib/base-ui/switch.d.ts +0 -313
- package/dist/shadcn/lib/base-ui/switch.js +0 -326
- package/dist/shadcn/lib/base-ui/tabs.d.ts +0 -406
- package/dist/shadcn/lib/base-ui/tabs.js +0 -915
- package/dist/shadcn/lib/base-ui/toggle-group.d.ts +0 -235
- package/dist/shadcn/lib/base-ui/toggle-group.js +0 -145
- package/dist/shadcn/lib/base-ui/toggle.d.ts +0 -224
- package/dist/shadcn/lib/base-ui/toggle.js +0 -127
- package/dist/shadcn/lib/base-ui/tooltip.d.ts +0 -1656
- package/dist/shadcn/lib/base-ui/tooltip.js +0 -920
- package/dist/shadcn/lib/base-ui/use-render.d.ts +0 -87
- package/dist/shadcn/lib/base-ui/use-render.js +0 -15
package/dist/ui/sheet.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cn } from "../shadcn/lib/utils.js";
|
|
5
|
+
import { Button } from "./button.js";
|
|
6
|
+
import { Slot, resolveRender } from "./slot.js";
|
|
7
|
+
import { XIcon } from "../icons/index.js";
|
|
8
|
+
import { useControllableState } from "./use-controllable-state.js";
|
|
9
|
+
import { usePresence } from "./use-presence.js";
|
|
10
|
+
const SheetContext = React.createContext(null);
|
|
11
|
+
function useSheet() {
|
|
12
|
+
const ctx = React.useContext(SheetContext);
|
|
13
|
+
if (!ctx)
|
|
14
|
+
throw new Error("Sheet parts must be used within <Sheet>");
|
|
15
|
+
return ctx;
|
|
16
|
+
}
|
|
17
|
+
/** Self-contained sheet (drawer) on native `<dialog>`, sliding in from an edge.
|
|
18
|
+
* Exit slide is preserved via {@link usePresence} before `dialog.close()`. */
|
|
19
|
+
function Sheet({ open, defaultOpen = false, onOpenChange, children }) {
|
|
20
|
+
const [isOpen, setOpen] = useControllableState({
|
|
21
|
+
value: open,
|
|
22
|
+
defaultValue: defaultOpen,
|
|
23
|
+
onChange: onOpenChange,
|
|
24
|
+
});
|
|
25
|
+
const titleId = React.useId();
|
|
26
|
+
const descriptionId = React.useId();
|
|
27
|
+
return (_jsx(SheetContext.Provider, { value: { open: isOpen, setOpen, titleId, descriptionId }, children: children }));
|
|
28
|
+
}
|
|
29
|
+
function SheetTrigger({ asChild = false, render, nativeButton: _nativeButton, children, onClick, ...props }) {
|
|
30
|
+
const { open, setOpen } = useSheet();
|
|
31
|
+
const { useSlot, slotChild } = resolveRender(asChild, render, children);
|
|
32
|
+
const Comp = useSlot ? Slot : "button";
|
|
33
|
+
return (_jsx(Comp, { type: useSlot ? undefined : "button", "data-slot": "sheet-trigger", "aria-haspopup": "dialog", "data-state": open ? "open" : "closed", onClick: (e) => {
|
|
34
|
+
onClick?.(e);
|
|
35
|
+
if (!e.defaultPrevented)
|
|
36
|
+
setOpen(true);
|
|
37
|
+
}, ...props, children: slotChild }));
|
|
38
|
+
}
|
|
39
|
+
function SheetClose({ asChild = false, render, nativeButton: _nativeButton, children, onClick, ...props }) {
|
|
40
|
+
const { setOpen } = useSheet();
|
|
41
|
+
const { useSlot, slotChild } = resolveRender(asChild, render, children);
|
|
42
|
+
const Comp = useSlot ? Slot : "button";
|
|
43
|
+
return (_jsx(Comp, { type: useSlot ? undefined : "button", "data-slot": "sheet-close", onClick: (e) => {
|
|
44
|
+
onClick?.(e);
|
|
45
|
+
if (!e.defaultPrevented)
|
|
46
|
+
setOpen(false);
|
|
47
|
+
}, ...props, children: slotChild }));
|
|
48
|
+
}
|
|
49
|
+
// `left-auto`/`right-auto`/etc. override the native <dialog> UA inset (left:0),
|
|
50
|
+
// otherwise `right-0` + a width would still anchor to the left edge.
|
|
51
|
+
const SIDE_POSITION = {
|
|
52
|
+
right: "inset-y-0 right-0 left-auto h-full w-3/4 border-l sm:max-w-sm",
|
|
53
|
+
left: "inset-y-0 left-0 right-auto h-full w-3/4 border-r sm:max-w-sm",
|
|
54
|
+
top: "inset-x-0 top-0 bottom-auto h-auto border-b",
|
|
55
|
+
bottom: "inset-x-0 bottom-0 top-auto h-auto border-t",
|
|
56
|
+
};
|
|
57
|
+
const SIDE_IN = {
|
|
58
|
+
right: "slide-in-from-right-52",
|
|
59
|
+
left: "slide-in-from-left-52",
|
|
60
|
+
top: "slide-in-from-top-52",
|
|
61
|
+
bottom: "slide-in-from-bottom-52",
|
|
62
|
+
};
|
|
63
|
+
const SIDE_OUT = {
|
|
64
|
+
right: "slide-out-to-right-52",
|
|
65
|
+
left: "slide-out-to-left-52",
|
|
66
|
+
top: "slide-out-to-top-52",
|
|
67
|
+
bottom: "slide-out-to-bottom-52",
|
|
68
|
+
};
|
|
69
|
+
function SheetContent({ className, children, side = "right", showCloseButton = true, ...props }) {
|
|
70
|
+
const { open, setOpen, titleId, descriptionId } = useSheet();
|
|
71
|
+
const ref = React.useRef(null);
|
|
72
|
+
const pointerDownOnBackdrop = React.useRef(false);
|
|
73
|
+
const [mounted] = usePresence(open);
|
|
74
|
+
React.useEffect(() => {
|
|
75
|
+
const node = ref.current;
|
|
76
|
+
if (!node)
|
|
77
|
+
return;
|
|
78
|
+
if (mounted && !node.open)
|
|
79
|
+
node.showModal();
|
|
80
|
+
else if (!mounted && node.open)
|
|
81
|
+
node.close();
|
|
82
|
+
}, [mounted]);
|
|
83
|
+
React.useEffect(() => {
|
|
84
|
+
if (!mounted)
|
|
85
|
+
return;
|
|
86
|
+
const prev = document.body.style.overflow;
|
|
87
|
+
document.body.style.overflow = "hidden";
|
|
88
|
+
return () => {
|
|
89
|
+
document.body.style.overflow = prev;
|
|
90
|
+
};
|
|
91
|
+
}, [mounted]);
|
|
92
|
+
if (!mounted)
|
|
93
|
+
return null;
|
|
94
|
+
return (_jsxs("dialog", { ...props, ref: ref, "aria-labelledby": titleId, "aria-describedby": descriptionId, "data-slot": "sheet-content", "data-side": side, "data-state": open ? "open" : "closed", "data-open": open ? "" : undefined, "data-closed": open ? undefined : "", onCancel: (e) => {
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
setOpen(false);
|
|
97
|
+
}, onClose: () => setOpen(false), onPointerDown: (e) => {
|
|
98
|
+
pointerDownOnBackdrop.current = e.target === ref.current;
|
|
99
|
+
}, onClick: (e) => {
|
|
100
|
+
if (e.target === ref.current && pointerDownOnBackdrop.current) {
|
|
101
|
+
setOpen(false);
|
|
102
|
+
}
|
|
103
|
+
}, className: cn("m-0 flex max-h-none flex-col gap-4 bg-background bg-clip-padding p-0 text-sm text-foreground shadow-lg backdrop:bg-black/10 backdrop:duration-150 supports-backdrop-filter:backdrop:backdrop-blur-xs fixed", SIDE_POSITION[side], open
|
|
104
|
+
? `animate-in fade-in-0 ${SIDE_IN[side]} duration-200`
|
|
105
|
+
: `animate-out fade-out-0 ${SIDE_OUT[side]} duration-200`, className), children: [children, showCloseButton && (_jsx(SheetClose, { asChild: true, children: _jsxs(Button, { variant: "ghost", className: "absolute top-4 right-4", size: "icon-sm", children: [_jsx(XIcon, {}), _jsx("span", { className: "sr-only", children: "Close" })] }) }))] }));
|
|
106
|
+
}
|
|
107
|
+
function SheetHeader({ className, ...props }) {
|
|
108
|
+
return (_jsx("div", { "data-slot": "sheet-header", className: cn("flex flex-col gap-1.5 p-4", className), ...props }));
|
|
109
|
+
}
|
|
110
|
+
function SheetFooter({ className, ...props }) {
|
|
111
|
+
return (_jsx("div", { "data-slot": "sheet-footer", className: cn("mt-auto flex flex-col gap-2 p-4", className), ...props }));
|
|
112
|
+
}
|
|
113
|
+
function SheetTitle({ className, ...props }) {
|
|
114
|
+
const { titleId } = useSheet();
|
|
115
|
+
return (_jsx("h2", { id: titleId, "data-slot": "sheet-title", className: cn("font-medium text-foreground", className), ...props }));
|
|
116
|
+
}
|
|
117
|
+
function SheetDescription({ className, ...props }) {
|
|
118
|
+
const { descriptionId } = useSheet();
|
|
119
|
+
return (_jsx("p", { id: descriptionId, "data-slot": "sheet-description", className: cn("text-sm text-muted-foreground", className), ...props }));
|
|
120
|
+
}
|
|
121
|
+
export { Sheet, SheetTrigger, SheetClose, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription, };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type VariantProps } from "../shadcn/lib/cva.js";
|
|
3
|
+
import { Button } from "./button.js";
|
|
4
|
+
import { Input } from "./input.js";
|
|
5
|
+
import { Separator } from "./separator.js";
|
|
6
|
+
import { TooltipContent } from "./tooltip.js";
|
|
7
|
+
type SidebarContextProps = {
|
|
8
|
+
state: "expanded" | "collapsed";
|
|
9
|
+
open: boolean;
|
|
10
|
+
setOpen: (open: boolean) => void;
|
|
11
|
+
openMobile: boolean;
|
|
12
|
+
setOpenMobile: (open: boolean) => void;
|
|
13
|
+
isMobile: boolean;
|
|
14
|
+
toggleSidebar: () => void;
|
|
15
|
+
};
|
|
16
|
+
declare function useSidebar(): SidebarContextProps;
|
|
17
|
+
declare function SidebarProvider({ defaultOpen, open: openProp, onOpenChange: setOpenProp, className, style, children, ...props }: React.ComponentProps<"div"> & {
|
|
18
|
+
defaultOpen?: boolean;
|
|
19
|
+
open?: boolean;
|
|
20
|
+
onOpenChange?: (open: boolean) => void;
|
|
21
|
+
}): React.JSX.Element;
|
|
22
|
+
declare function Sidebar({ side, variant, collapsible, className, children, dir, ...props }: React.ComponentProps<"div"> & {
|
|
23
|
+
side?: "left" | "right";
|
|
24
|
+
variant?: "sidebar" | "floating" | "inset";
|
|
25
|
+
collapsible?: "offcanvas" | "icon" | "none";
|
|
26
|
+
}): React.JSX.Element;
|
|
27
|
+
declare function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>): React.JSX.Element;
|
|
28
|
+
declare function SidebarRail({ className, ...props }: React.ComponentProps<"button">): React.JSX.Element;
|
|
29
|
+
declare function SidebarInset({ className, ...props }: React.ComponentProps<"main">): React.JSX.Element;
|
|
30
|
+
declare function SidebarInput({ className, ...props }: React.ComponentProps<typeof Input>): React.JSX.Element;
|
|
31
|
+
declare function SidebarHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
32
|
+
declare function SidebarFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
33
|
+
declare function SidebarSeparator({ className, ...props }: React.ComponentProps<typeof Separator>): React.JSX.Element;
|
|
34
|
+
declare function SidebarContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
35
|
+
declare function SidebarGroup({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
36
|
+
declare function SidebarGroupLabel({ className, asChild, render, nativeButton: _nativeButton, children, ...props }: React.ComponentProps<"div"> & {
|
|
37
|
+
asChild?: boolean;
|
|
38
|
+
render?: React.ReactElement;
|
|
39
|
+
nativeButton?: boolean;
|
|
40
|
+
}): React.JSX.Element;
|
|
41
|
+
declare function SidebarGroupAction({ className, asChild, render, nativeButton: _nativeButton, children, ...props }: React.ComponentProps<"button"> & {
|
|
42
|
+
asChild?: boolean;
|
|
43
|
+
render?: React.ReactElement;
|
|
44
|
+
nativeButton?: boolean;
|
|
45
|
+
}): React.JSX.Element;
|
|
46
|
+
declare function SidebarGroupContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
47
|
+
declare function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">): React.JSX.Element;
|
|
48
|
+
declare function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">): React.JSX.Element;
|
|
49
|
+
declare const sidebarMenuButtonVariants: (props?: import("../shadcn/lib/cva.js").CvaProps<{
|
|
50
|
+
variant: {
|
|
51
|
+
default: string;
|
|
52
|
+
outline: string;
|
|
53
|
+
};
|
|
54
|
+
size: {
|
|
55
|
+
default: string;
|
|
56
|
+
sm: string;
|
|
57
|
+
lg: string;
|
|
58
|
+
};
|
|
59
|
+
}> | undefined) => string;
|
|
60
|
+
declare function SidebarMenuButton({ asChild, render, nativeButton: _nativeButton, children, isActive, variant, size, tooltip, className, ...props }: React.ComponentProps<"button"> & {
|
|
61
|
+
asChild?: boolean;
|
|
62
|
+
render?: React.ReactElement;
|
|
63
|
+
nativeButton?: boolean;
|
|
64
|
+
isActive?: boolean;
|
|
65
|
+
tooltip?: string | React.ComponentProps<typeof TooltipContent>;
|
|
66
|
+
} & VariantProps<typeof sidebarMenuButtonVariants>): React.JSX.Element;
|
|
67
|
+
declare function SidebarMenuAction({ className, asChild, render, nativeButton: _nativeButton, children, showOnHover, ...props }: React.ComponentProps<"button"> & {
|
|
68
|
+
asChild?: boolean;
|
|
69
|
+
render?: React.ReactElement;
|
|
70
|
+
nativeButton?: boolean;
|
|
71
|
+
showOnHover?: boolean;
|
|
72
|
+
}): React.JSX.Element;
|
|
73
|
+
declare function SidebarMenuBadge({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
74
|
+
declare function SidebarMenuSkeleton({ className, showIcon, ...props }: React.ComponentProps<"div"> & {
|
|
75
|
+
showIcon?: boolean;
|
|
76
|
+
}): React.JSX.Element;
|
|
77
|
+
declare function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">): React.JSX.Element;
|
|
78
|
+
declare function SidebarMenuSubItem({ className, ...props }: React.ComponentProps<"li">): React.JSX.Element;
|
|
79
|
+
declare function SidebarMenuSubButton({ asChild, render, nativeButton: _nativeButton, children, size, isActive, className, ...props }: React.ComponentProps<"a"> & {
|
|
80
|
+
asChild?: boolean;
|
|
81
|
+
render?: React.ReactElement;
|
|
82
|
+
nativeButton?: boolean;
|
|
83
|
+
size?: "sm" | "md";
|
|
84
|
+
isActive?: boolean;
|
|
85
|
+
}): React.JSX.Element;
|
|
86
|
+
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar, };
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cva } from "../shadcn/lib/cva.js";
|
|
5
|
+
import { useIsMobile } from "../shadcn/hooks/use-mobile.js";
|
|
6
|
+
import { cn } from "../shadcn/lib/utils.js";
|
|
7
|
+
import { Slot, resolveRender } from "./slot.js";
|
|
8
|
+
import { Button } from "./button.js";
|
|
9
|
+
import { Input } from "./input.js";
|
|
10
|
+
import { Separator } from "./separator.js";
|
|
11
|
+
import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, } from "./sheet.js";
|
|
12
|
+
import { Skeleton } from "./skeleton.js";
|
|
13
|
+
import { Tooltip, TooltipContent, TooltipTrigger, } from "./tooltip.js";
|
|
14
|
+
import { PanelLeftIcon } from "../icons/index.js";
|
|
15
|
+
const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
16
|
+
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
17
|
+
const SIDEBAR_WIDTH = "12rem";
|
|
18
|
+
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
19
|
+
const SIDEBAR_WIDTH_ICON = "3rem";
|
|
20
|
+
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
21
|
+
const SidebarContext = React.createContext(null);
|
|
22
|
+
function useSidebar() {
|
|
23
|
+
const context = React.useContext(SidebarContext);
|
|
24
|
+
if (!context) {
|
|
25
|
+
throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
26
|
+
}
|
|
27
|
+
return context;
|
|
28
|
+
}
|
|
29
|
+
function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChange: setOpenProp, className, style, children, ...props }) {
|
|
30
|
+
const isMobile = useIsMobile();
|
|
31
|
+
const [openMobile, setOpenMobile] = React.useState(false);
|
|
32
|
+
// This is the internal state of the sidebar.
|
|
33
|
+
// We use openProp and setOpenProp for control from outside the component.
|
|
34
|
+
const [_open, _setOpen] = React.useState(defaultOpen);
|
|
35
|
+
const open = openProp ?? _open;
|
|
36
|
+
const setOpen = React.useCallback((value) => {
|
|
37
|
+
const openState = typeof value === "function" ? value(open) : value;
|
|
38
|
+
if (setOpenProp) {
|
|
39
|
+
setOpenProp(openState);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
_setOpen(openState);
|
|
43
|
+
}
|
|
44
|
+
// This sets the cookie to keep the sidebar state.
|
|
45
|
+
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
46
|
+
}, [setOpenProp, open]);
|
|
47
|
+
// Helper to toggle the sidebar.
|
|
48
|
+
const toggleSidebar = React.useCallback(() => {
|
|
49
|
+
return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
|
|
50
|
+
}, [isMobile, setOpen, setOpenMobile]);
|
|
51
|
+
// Adds a keyboard shortcut to toggle the sidebar.
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
const handleKeyDown = (event) => {
|
|
54
|
+
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
|
|
55
|
+
(event.metaKey || event.ctrlKey)) {
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
toggleSidebar();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
61
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
62
|
+
}, [toggleSidebar]);
|
|
63
|
+
// We add a state so that we can do data-state="expanded" or "collapsed".
|
|
64
|
+
// This makes it easier to style the sidebar with Tailwind classes.
|
|
65
|
+
const state = open ? "expanded" : "collapsed";
|
|
66
|
+
const contextValue = React.useMemo(() => ({
|
|
67
|
+
state,
|
|
68
|
+
open,
|
|
69
|
+
setOpen,
|
|
70
|
+
isMobile,
|
|
71
|
+
openMobile,
|
|
72
|
+
setOpenMobile,
|
|
73
|
+
toggleSidebar,
|
|
74
|
+
}), [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]);
|
|
75
|
+
return (_jsx(SidebarContext.Provider, { value: contextValue, children: _jsx("div", { "data-slot": "sidebar-wrapper", style: {
|
|
76
|
+
"--sidebar-width": SIDEBAR_WIDTH,
|
|
77
|
+
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
78
|
+
...style,
|
|
79
|
+
}, className: cn("group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar", className), ...props, children: children }) }));
|
|
80
|
+
}
|
|
81
|
+
function Sidebar({ side = "left", variant = "sidebar", collapsible = "offcanvas", className, children, dir, ...props }) {
|
|
82
|
+
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
83
|
+
if (collapsible === "none") {
|
|
84
|
+
return (_jsx("div", { "data-slot": "sidebar", className: cn("flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground", className), ...props, children: children }));
|
|
85
|
+
}
|
|
86
|
+
if (isMobile) {
|
|
87
|
+
return (_jsx(Sheet, { open: openMobile, onOpenChange: setOpenMobile, children: _jsxs(SheetContent, { dir: dir, "data-sidebar": "sidebar", "data-slot": "sidebar", "data-mobile": "true", showCloseButton: false, className: "w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden", style: {
|
|
88
|
+
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
|
|
89
|
+
}, side: side, children: [_jsxs(SheetHeader, { className: "sr-only", children: [_jsx(SheetTitle, { children: "Sidebar" }), _jsx(SheetDescription, { children: "Displays the mobile sidebar." })] }), _jsx("div", { className: "flex h-full w-full flex-col", children: children })] }) }));
|
|
90
|
+
}
|
|
91
|
+
return (_jsxs("div", { className: "group peer hidden text-sidebar-foreground md:block", "data-state": state, "data-collapsible": state === "collapsed" ? collapsible : "", "data-variant": variant, "data-side": side, "data-slot": "sidebar", children: [_jsx("div", { "data-slot": "sidebar-gap", className: cn("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear", "group-data-[collapsible=offcanvas]:w-0", "group-data-[side=right]:rotate-180", variant === "floating" || variant === "inset"
|
|
92
|
+
? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
|
|
93
|
+
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon)") }), _jsx("div", { "data-slot": "sidebar-container", "data-side": side, className: cn("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-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",
|
|
94
|
+
// Adjust the padding for floating and inset variants.
|
|
95
|
+
variant === "floating" || variant === "inset"
|
|
96
|
+
? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
|
|
97
|
+
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon)", className), ...props, children: _jsx("div", { "data-sidebar": "sidebar", "data-slot": "sidebar-inner", 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", children: children }) })] }));
|
|
98
|
+
}
|
|
99
|
+
function SidebarTrigger({ className, onClick, ...props }) {
|
|
100
|
+
const { toggleSidebar } = useSidebar();
|
|
101
|
+
return (_jsxs(Button, { "data-sidebar": "trigger", "data-slot": "sidebar-trigger", variant: "ghost", size: "icon-sm", className: cn(className), onClick: (event) => {
|
|
102
|
+
onClick?.(event);
|
|
103
|
+
toggleSidebar();
|
|
104
|
+
}, ...props, children: [_jsx(PanelLeftIcon, {}), _jsx("span", { className: "sr-only", children: "Toggle Sidebar" })] }));
|
|
105
|
+
}
|
|
106
|
+
function SidebarRail({ className, ...props }) {
|
|
107
|
+
const { toggleSidebar } = useSidebar();
|
|
108
|
+
return (_jsx("button", { "data-sidebar": "rail", "data-slot": "sidebar-rail", "aria-label": "Toggle Sidebar", tabIndex: -1, onClick: toggleSidebar, title: "Toggle Sidebar", className: cn("cursor-pointer 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:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2", "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize", "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize", "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar", "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2", "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2", className), ...props }));
|
|
109
|
+
}
|
|
110
|
+
function SidebarInset({ className, ...props }) {
|
|
111
|
+
return (_jsx("main", { "data-slot": "sidebar-inset", className: cn("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", className), ...props }));
|
|
112
|
+
}
|
|
113
|
+
function SidebarInput({ className, ...props }) {
|
|
114
|
+
return (_jsx(Input, { "data-slot": "sidebar-input", "data-sidebar": "input", className: cn("h-8 w-full bg-background shadow-none", className), ...props }));
|
|
115
|
+
}
|
|
116
|
+
function SidebarHeader({ className, ...props }) {
|
|
117
|
+
return (_jsx("div", { "data-slot": "sidebar-header", "data-sidebar": "header", className: cn("gap-2 px-2 pb-2 flex flex-col", className), ...props }));
|
|
118
|
+
}
|
|
119
|
+
function SidebarFooter({ className, ...props }) {
|
|
120
|
+
return (_jsx("div", { "data-slot": "sidebar-footer", "data-sidebar": "footer", className: cn("flex flex-col gap-2 p-2", className), ...props }));
|
|
121
|
+
}
|
|
122
|
+
function SidebarSeparator({ className, ...props }) {
|
|
123
|
+
return (_jsx(Separator, { "data-slot": "sidebar-separator", "data-sidebar": "separator", className: cn("mx-2 w-auto bg-sidebar-border", className), ...props }));
|
|
124
|
+
}
|
|
125
|
+
function SidebarContent({ className, ...props }) {
|
|
126
|
+
return (_jsx("div", { "data-slot": "sidebar-content", "data-sidebar": "content", className: cn("no-scrollbar flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden", className), ...props }));
|
|
127
|
+
}
|
|
128
|
+
function SidebarGroup({ className, ...props }) {
|
|
129
|
+
return (_jsx("div", { "data-slot": "sidebar-group", "data-sidebar": "group", className: cn("relative flex w-full min-w-0 flex-col p-2", className), ...props }));
|
|
130
|
+
}
|
|
131
|
+
function SidebarGroupLabel({ className, asChild = false, render, nativeButton: _nativeButton, children, ...props }) {
|
|
132
|
+
const { useSlot, slotChild } = resolveRender(asChild, render, children);
|
|
133
|
+
const Comp = useSlot ? Slot : "div";
|
|
134
|
+
return (_jsx(Comp, { "data-slot": "sidebar-group-label", "data-sidebar": "group-label", className: cn("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", className), ...props, children: slotChild }));
|
|
135
|
+
}
|
|
136
|
+
function SidebarGroupAction({ className, asChild = false, render, nativeButton: _nativeButton, children, ...props }) {
|
|
137
|
+
const { useSlot, slotChild } = resolveRender(asChild, render, children);
|
|
138
|
+
const Comp = useSlot ? Slot : "button";
|
|
139
|
+
return (_jsx(Comp, { "data-slot": "sidebar-group-action", "data-sidebar": "group-action", className: cn("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", className), ...props, children: slotChild }));
|
|
140
|
+
}
|
|
141
|
+
function SidebarGroupContent({ className, ...props }) {
|
|
142
|
+
return (_jsx("div", { "data-slot": "sidebar-group-content", "data-sidebar": "group-content", className: cn("w-full text-sm", className), ...props }));
|
|
143
|
+
}
|
|
144
|
+
function SidebarMenu({ className, ...props }) {
|
|
145
|
+
return (_jsx("ul", { "data-slot": "sidebar-menu", "data-sidebar": "menu", className: cn("flex w-full min-w-0 flex-col gap-1", className), ...props }));
|
|
146
|
+
}
|
|
147
|
+
function SidebarMenuItem({ className, ...props }) {
|
|
148
|
+
return (_jsx("li", { "data-slot": "sidebar-menu-item", "data-sidebar": "menu-item", className: cn("group/menu-item relative", className), ...props }));
|
|
149
|
+
}
|
|
150
|
+
const sidebarMenuButtonVariants = cva("cursor-pointer 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", {
|
|
151
|
+
variants: {
|
|
152
|
+
variant: {
|
|
153
|
+
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
154
|
+
outline: "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)]",
|
|
155
|
+
},
|
|
156
|
+
size: {
|
|
157
|
+
default: "h-10 text-base",
|
|
158
|
+
sm: "h-8 text-sm",
|
|
159
|
+
lg: "h-14 text-base group-data-[collapsible=icon]:p-0!",
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
defaultVariants: {
|
|
163
|
+
variant: "default",
|
|
164
|
+
size: "default",
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
function SidebarMenuButton({ asChild = false, render, nativeButton: _nativeButton, children, isActive = false, variant = "default", size = "default", tooltip, className, ...props }) {
|
|
168
|
+
const { isMobile, state } = useSidebar();
|
|
169
|
+
const { useSlot, slotChild } = resolveRender(asChild, render, children);
|
|
170
|
+
const Comp = useSlot ? Slot : "button";
|
|
171
|
+
const button = (_jsx(Comp, { "data-slot": "sidebar-menu-button", "data-sidebar": "menu-button", "data-size": size, "data-active": isActive ? "" : undefined, className: cn(sidebarMenuButtonVariants({ variant, size }), className), ...props, children: slotChild }));
|
|
172
|
+
if (!tooltip) {
|
|
173
|
+
return button;
|
|
174
|
+
}
|
|
175
|
+
if (typeof tooltip === "string") {
|
|
176
|
+
tooltip = {
|
|
177
|
+
children: tooltip,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: button }), state === "collapsed" && !isMobile && (_jsx(TooltipContent, { side: "right", align: "center", ...tooltip }))] }));
|
|
181
|
+
}
|
|
182
|
+
function SidebarMenuAction({ className, asChild = false, render, nativeButton: _nativeButton, children, showOnHover = false, ...props }) {
|
|
183
|
+
const { useSlot, slotChild } = resolveRender(asChild, render, children);
|
|
184
|
+
const Comp = useSlot ? Slot : "button";
|
|
185
|
+
return (_jsx(Comp, { "data-slot": "sidebar-menu-action", "data-sidebar": "menu-action", className: cn("cursor-pointer 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", showOnHover &&
|
|
186
|
+
"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", className), ...props, children: slotChild }));
|
|
187
|
+
}
|
|
188
|
+
function SidebarMenuBadge({ className, ...props }) {
|
|
189
|
+
return (_jsx("div", { "data-slot": "sidebar-menu-badge", "data-sidebar": "menu-badge", className: cn("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", className), ...props }));
|
|
190
|
+
}
|
|
191
|
+
function SidebarMenuSkeleton({ className, showIcon = false, ...props }) {
|
|
192
|
+
// Random width between 50 to 90%.
|
|
193
|
+
const [width] = React.useState(() => {
|
|
194
|
+
return `${Math.floor(Math.random() * 40) + 50}%`;
|
|
195
|
+
});
|
|
196
|
+
return (_jsxs("div", { "data-slot": "sidebar-menu-skeleton", "data-sidebar": "menu-skeleton", className: cn("flex h-8 items-center gap-2 rounded-md px-2", className), ...props, children: [showIcon && (_jsx(Skeleton, { className: "size-4 rounded-md", "data-sidebar": "menu-skeleton-icon" })), _jsx(Skeleton, { className: "h-4 max-w-(--skeleton-width) flex-1", "data-sidebar": "menu-skeleton-text", style: {
|
|
197
|
+
"--skeleton-width": width,
|
|
198
|
+
} })] }));
|
|
199
|
+
}
|
|
200
|
+
function SidebarMenuSub({ className, ...props }) {
|
|
201
|
+
return (_jsx("ul", { "data-slot": "sidebar-menu-sub", "data-sidebar": "menu-sub", className: cn("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", className), ...props }));
|
|
202
|
+
}
|
|
203
|
+
function SidebarMenuSubItem({ className, ...props }) {
|
|
204
|
+
return (_jsx("li", { "data-slot": "sidebar-menu-sub-item", "data-sidebar": "menu-sub-item", className: cn("group/menu-sub-item relative", className), ...props }));
|
|
205
|
+
}
|
|
206
|
+
function SidebarMenuSubButton({ asChild = false, render, nativeButton: _nativeButton, children, size = "md", isActive = false, className, ...props }) {
|
|
207
|
+
const { useSlot, slotChild } = resolveRender(asChild, render, children);
|
|
208
|
+
const Comp = useSlot ? Slot : "a";
|
|
209
|
+
return (_jsx(Comp, { "data-slot": "sidebar-menu-sub-button", "data-sidebar": "menu-sub-button", "data-size": size, "data-active": isActive ? "" : undefined, className: cn("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", className), ...props, children: slotChild }));
|
|
210
|
+
}
|
|
211
|
+
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar, };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../shadcn/lib/utils.js";
|
|
4
|
+
function Skeleton({ className, ...props }) {
|
|
5
|
+
return (_jsx("div", { "data-slot": "skeleton", className: cn("animate-pulse rounded-md bg-muted", className), ...props }));
|
|
6
|
+
}
|
|
7
|
+
export { Skeleton };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface SliderProps extends Omit<React.ComponentProps<"div">, "defaultValue" | "onChange"> {
|
|
3
|
+
value?: number[];
|
|
4
|
+
defaultValue?: number[];
|
|
5
|
+
onValueChange?: (value: number[]) => void;
|
|
6
|
+
min?: number;
|
|
7
|
+
max?: number;
|
|
8
|
+
step?: number;
|
|
9
|
+
orientation?: "horizontal" | "vertical";
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Self-contained slider with pointer drag and keyboard control. Supports one or
|
|
14
|
+
* more thumbs (the nearest thumb to the pointer is the one that moves). Track,
|
|
15
|
+
* range, and thumbs mirror the shadcn structure/classes.
|
|
16
|
+
*/
|
|
17
|
+
declare function Slider({ className, value, defaultValue, onValueChange, min, max, step, orientation, disabled, ...props }: SliderProps): React.JSX.Element;
|
|
18
|
+
export { Slider };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cn } from "../shadcn/lib/utils.js";
|
|
5
|
+
import { useControllableState } from "./use-controllable-state.js";
|
|
6
|
+
const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
7
|
+
/**
|
|
8
|
+
* Self-contained slider with pointer drag and keyboard control. Supports one or
|
|
9
|
+
* more thumbs (the nearest thumb to the pointer is the one that moves). Track,
|
|
10
|
+
* range, and thumbs mirror the shadcn structure/classes.
|
|
11
|
+
*/
|
|
12
|
+
function Slider({ className, value, defaultValue, onValueChange, min = 0, max = 100, step = 1, orientation = "horizontal", disabled = false, ...props }) {
|
|
13
|
+
const [values, setValues] = useControllableState({
|
|
14
|
+
value,
|
|
15
|
+
defaultValue: defaultValue ?? [min],
|
|
16
|
+
onChange: onValueChange,
|
|
17
|
+
});
|
|
18
|
+
const trackRef = React.useRef(null);
|
|
19
|
+
const activeThumb = React.useRef(0);
|
|
20
|
+
const vertical = orientation === "vertical";
|
|
21
|
+
const percent = (v) => ((v - min) / (max - min)) * 100;
|
|
22
|
+
const valueFromPointer = (clientX, clientY) => {
|
|
23
|
+
const track = trackRef.current;
|
|
24
|
+
if (!track)
|
|
25
|
+
return min;
|
|
26
|
+
const rect = track.getBoundingClientRect();
|
|
27
|
+
const ratio = vertical
|
|
28
|
+
? (rect.bottom - clientY) / rect.height
|
|
29
|
+
: (clientX - rect.left) / rect.width;
|
|
30
|
+
const raw = min + clamp(ratio, 0, 1) * (max - min);
|
|
31
|
+
return clamp(Math.round(raw / step) * step, min, max);
|
|
32
|
+
};
|
|
33
|
+
const updateThumb = (index, next) => {
|
|
34
|
+
setValues(values.map((v, i) => (i === index ? next : v)));
|
|
35
|
+
};
|
|
36
|
+
const nearestThumb = (v) => {
|
|
37
|
+
let best = 0;
|
|
38
|
+
let bestDist = Infinity;
|
|
39
|
+
values.forEach((tv, i) => {
|
|
40
|
+
const d = Math.abs(tv - v);
|
|
41
|
+
if (d < bestDist) {
|
|
42
|
+
bestDist = d;
|
|
43
|
+
best = i;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return best;
|
|
47
|
+
};
|
|
48
|
+
const onPointerDown = (e) => {
|
|
49
|
+
if (disabled)
|
|
50
|
+
return;
|
|
51
|
+
const v = valueFromPointer(e.clientX, e.clientY);
|
|
52
|
+
const idx = nearestThumb(v);
|
|
53
|
+
activeThumb.current = idx;
|
|
54
|
+
updateThumb(idx, v);
|
|
55
|
+
const target = e.currentTarget;
|
|
56
|
+
target.setPointerCapture(e.pointerId);
|
|
57
|
+
const onMove = (ev) => {
|
|
58
|
+
updateThumb(activeThumb.current, valueFromPointer(ev.clientX, ev.clientY));
|
|
59
|
+
};
|
|
60
|
+
const onUp = (ev) => {
|
|
61
|
+
target.releasePointerCapture(ev.pointerId);
|
|
62
|
+
target.removeEventListener("pointermove", onMove);
|
|
63
|
+
target.removeEventListener("pointerup", onUp);
|
|
64
|
+
};
|
|
65
|
+
target.addEventListener("pointermove", onMove);
|
|
66
|
+
target.addEventListener("pointerup", onUp);
|
|
67
|
+
};
|
|
68
|
+
const onThumbKeyDown = (index) => (e) => {
|
|
69
|
+
if (disabled)
|
|
70
|
+
return;
|
|
71
|
+
let next = null;
|
|
72
|
+
const cur = values[index];
|
|
73
|
+
if (e.key === "ArrowRight" || e.key === "ArrowUp")
|
|
74
|
+
next = cur + step;
|
|
75
|
+
else if (e.key === "ArrowLeft" || e.key === "ArrowDown")
|
|
76
|
+
next = cur - step;
|
|
77
|
+
else if (e.key === "Home")
|
|
78
|
+
next = min;
|
|
79
|
+
else if (e.key === "End")
|
|
80
|
+
next = max;
|
|
81
|
+
if (next !== null) {
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
updateThumb(index, clamp(next, min, max));
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const rangeStart = values.length > 1 ? Math.min(...values.map(percent)) : 0;
|
|
87
|
+
const rangeEnd = Math.max(...values.map(percent));
|
|
88
|
+
return (_jsx("div", { "data-slot": "slider", "data-orientation": orientation, "data-disabled": disabled ? "" : undefined, className: cn("data-horizontal:w-full data-vertical:h-full", className), ...props, children: _jsxs("div", { "data-orientation": orientation, onPointerDown: onPointerDown, className: "relative flex w-full touch-none items-center select-none data-disabled:opacity-50 data-vertical:h-full data-vertical:min-h-40 data-vertical:w-auto data-vertical:flex-col", children: [_jsx("div", { ref: trackRef, "data-slot": "slider-track", "data-orientation": orientation, className: "relative grow overflow-hidden rounded-full bg-muted select-none data-horizontal:h-1.5 data-horizontal:w-full data-vertical:h-full data-vertical:w-1.5", children: _jsx("div", { "data-slot": "slider-range", "data-orientation": orientation, className: "absolute bg-primary select-none data-horizontal:h-full data-vertical:w-full", style: vertical
|
|
89
|
+
? { bottom: `${rangeStart}%`, height: `${rangeEnd - rangeStart}%` }
|
|
90
|
+
: { left: `${rangeStart}%`, width: `${rangeEnd - rangeStart}%` } }) }), values.map((v, index) => (_jsx("span", { role: "slider", tabIndex: disabled ? -1 : 0, "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": v, "aria-orientation": orientation, "aria-disabled": disabled || undefined, "data-slot": "slider-thumb", onKeyDown: onThumbKeyDown(index), className: "absolute block size-4 shrink-0 -translate-x-1/2 cursor-pointer rounded-full border border-primary bg-white shadow-sm ring-ring/50 transition-[color,box-shadow] select-none hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50 data-vertical:translate-x-0 data-vertical:-translate-y-1/2", "data-orientation": orientation, style: vertical
|
|
91
|
+
? { bottom: `${percent(v)}%` }
|
|
92
|
+
: { left: `${percent(v)}%` } }, index)))] }) }));
|
|
93
|
+
}
|
|
94
|
+
export { Slider };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal `asChild` Slot — self-contained replacement for Radix Slot / Base UI's
|
|
4
|
+
* `render` prop. Merges this slot's props onto its single child element:
|
|
5
|
+
* `className` is class-merged, refs are composed, and the child's own props win
|
|
6
|
+
* on any other collision (the child is the concrete element).
|
|
7
|
+
*
|
|
8
|
+
* This is the only behavioral helper the self-contained `ui/` tier depends on;
|
|
9
|
+
* it carries no primitive framework. React 19 ref-as-prop, no forwardRef.
|
|
10
|
+
*/
|
|
11
|
+
declare function mergeRefs<T>(...refs: (React.Ref<T> | undefined)[]): (node: T | null) => void;
|
|
12
|
+
type SlotProps = React.HTMLAttributes<HTMLElement> & {
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
ref?: React.Ref<HTMLElement>;
|
|
15
|
+
};
|
|
16
|
+
declare function Slot({ children, className, style, ref, ...props }: SlotProps): React.ReactElement<Record<string, unknown>, string | React.JSXElementConstructor<any>>;
|
|
17
|
+
/**
|
|
18
|
+
* Base UI `render={<El/>}` compatibility. The old shadcn tier passed a React
|
|
19
|
+
* element to `render` to control the rendered element; here that maps onto the
|
|
20
|
+
* `asChild` + Slot mechanism. Returns whether to use the Slot and what child to
|
|
21
|
+
* render through it, so `render={<Button/>}` keeps working on the new components.
|
|
22
|
+
*/
|
|
23
|
+
declare function resolveRender(asChild: boolean | undefined, render: React.ReactElement | undefined, children: React.ReactNode): {
|
|
24
|
+
useSlot: boolean;
|
|
25
|
+
slotChild: React.ReactNode;
|
|
26
|
+
};
|
|
27
|
+
export { Slot, mergeRefs, resolveRender };
|