@pickle-ui/react 1.0.0-beta.18 → 1.0.0-beta.19
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/README.md +1 -0
- package/dist/components/BottomSheet.d.ts +48 -0
- package/dist/components/BottomSheet.d.ts.map +1 -0
- package/dist/components/BottomSheet.js +97 -0
- package/dist/components/BottomSheet.js.map +1 -0
- package/dist/components/Drawer.d.ts +9 -1
- package/dist/components/Drawer.d.ts.map +1 -1
- package/dist/components/Drawer.js +15 -5
- package/dist/components/Drawer.js.map +1 -1
- package/dist/components/_internal/dialog-styles.d.ts +1 -1
- package/dist/components/_internal/dialog-styles.d.ts.map +1 -1
- package/dist/components/_internal/dialog-styles.js +1 -1
- package/dist/components/_internal/dialog-styles.js.map +1 -1
- package/dist/entries/bottom-sheet.d.ts +3 -0
- package/dist/entries/bottom-sheet.d.ts.map +1 -0
- package/dist/entries/bottom-sheet.js +2 -0
- package/dist/entries/bottom-sheet.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/pickle-ui-react/SKILL.md +1 -0
- package/src/components/BottomSheet.stories.tsx +200 -0
- package/src/components/BottomSheet.test.tsx +143 -0
- package/src/components/BottomSheet.tsx +218 -0
- package/src/components/Drawer.tsx +41 -16
- package/src/components/_internal/dialog-styles.ts +1 -1
- package/src/entries/bottom-sheet.ts +12 -0
- package/src/index.ts +1 -0
package/README.md
CHANGED
|
@@ -87,6 +87,7 @@ Subpaths use the same named exports as the root entry (for example `Button` from
|
|
|
87
87
|
| `@pickle-ui/react/alert-dialog` | `AlertDialog` with `Trigger`, `Content`, `Header`, `Title`, `Description`, `Footer`, `Close` |
|
|
88
88
|
| `@pickle-ui/react/avatar` | `Avatar` with `Image`, `Fallback`, `Group` |
|
|
89
89
|
| `@pickle-ui/react/badge` | `Badge`, `badgeVariants` |
|
|
90
|
+
| `@pickle-ui/react/bottom-sheet` | `BottomSheet`, rising from below, with `Trigger`, `Content`, `Header`, `Title`, `Description`, `Panel`, `Footer`, `Close` |
|
|
90
91
|
| `@pickle-ui/react/button` | `Button`, `buttonVariants` |
|
|
91
92
|
| `@pickle-ui/react/card` | `Card` with `Header`, `Title`, `Description`, `Action`, `Content`, `Footer` |
|
|
92
93
|
| `@pickle-ui/react/checkbox` | `Checkbox` with `Label` |
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Drawer as DrawerPrimitive } from '@base-ui/react/drawer';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { type DrawerCloseProps, type DrawerDescriptionProps, type DrawerFooterProps, type DrawerHeaderProps, type DrawerPanelProps, type DrawerTitleProps, type DrawerTriggerProps } from './Drawer.js';
|
|
4
|
+
type BottomSheetCloseProps = DrawerCloseProps;
|
|
5
|
+
type BottomSheetContentProps = React.ComponentProps<typeof DrawerPrimitive.Popup> & {
|
|
6
|
+
/** Accessible name of the close icon button. Defaults to `"Close"`. */
|
|
7
|
+
closeLabel?: string;
|
|
8
|
+
/** Renders a close icon button in the top-right corner. Defaults to `false`. */
|
|
9
|
+
showCloseButton?: boolean;
|
|
10
|
+
};
|
|
11
|
+
type BottomSheetDescriptionProps = DrawerDescriptionProps;
|
|
12
|
+
type BottomSheetFooterProps = DrawerFooterProps;
|
|
13
|
+
type BottomSheetHeaderProps = DrawerHeaderProps;
|
|
14
|
+
type BottomSheetPanelProps = DrawerPanelProps;
|
|
15
|
+
type BottomSheetProps = Omit<React.ComponentProps<typeof DrawerPrimitive.Root>, 'swipeDirection'>;
|
|
16
|
+
type BottomSheetTitleProps = DrawerTitleProps;
|
|
17
|
+
type BottomSheetTriggerProps = DrawerTriggerProps;
|
|
18
|
+
declare function BottomSheetClose(props: BottomSheetCloseProps): React.JSX.Element;
|
|
19
|
+
declare function BottomSheetContent({ children, className, closeLabel, showCloseButton, ...props }: BottomSheetContentProps): React.JSX.Element;
|
|
20
|
+
declare function BottomSheetDescription(props: BottomSheetDescriptionProps): React.JSX.Element;
|
|
21
|
+
/**
|
|
22
|
+
* A touch swipe on the footer never closes the sheet, so its buttons take taps. At a lower
|
|
23
|
+
* snap point, it waits below the screen until the sheet rises.
|
|
24
|
+
*/
|
|
25
|
+
declare function BottomSheetFooter({ className, ...props }: BottomSheetFooterProps): React.JSX.Element;
|
|
26
|
+
declare function BottomSheetHeader(props: BottomSheetHeaderProps): React.JSX.Element;
|
|
27
|
+
/**
|
|
28
|
+
* The scrolling body between the header and the footer. A touch swipe in it scrolls it and
|
|
29
|
+
* never closes the sheet, but with snap points, Base UI moves the sheet when it can't scroll.
|
|
30
|
+
*/
|
|
31
|
+
declare function BottomSheetPanel({ className, ...props }: BottomSheetPanelProps): React.JSX.Element;
|
|
32
|
+
/** List `snapPoints` from the lowest to the highest: the Panel scrolls at the last one. */
|
|
33
|
+
declare function BottomSheetRoot({ onSnapPointChange, ...props }: BottomSheetProps): React.JSX.Element;
|
|
34
|
+
declare function BottomSheetTitle(props: BottomSheetTitleProps): React.JSX.Element;
|
|
35
|
+
declare function BottomSheetTrigger(props: BottomSheetTriggerProps): React.JSX.Element;
|
|
36
|
+
declare const BottomSheet: typeof BottomSheetRoot & {
|
|
37
|
+
Close: typeof BottomSheetClose;
|
|
38
|
+
Content: typeof BottomSheetContent;
|
|
39
|
+
Description: typeof BottomSheetDescription;
|
|
40
|
+
Footer: typeof BottomSheetFooter;
|
|
41
|
+
Header: typeof BottomSheetHeader;
|
|
42
|
+
Panel: typeof BottomSheetPanel;
|
|
43
|
+
Title: typeof BottomSheetTitle;
|
|
44
|
+
Trigger: typeof BottomSheetTrigger;
|
|
45
|
+
};
|
|
46
|
+
export { BottomSheet };
|
|
47
|
+
export type { BottomSheetCloseProps, BottomSheetContentProps, BottomSheetDescriptionProps, BottomSheetFooterProps, BottomSheetHeaderProps, BottomSheetPanelProps, BottomSheetProps, BottomSheetTitleProps, BottomSheetTriggerProps, };
|
|
48
|
+
//# sourceMappingURL=BottomSheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BottomSheet.d.ts","sourceRoot":"","sources":["../../src/components/BottomSheet.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACxB,MAAM,UAAU,CAAC;AAqBlB,KAAK,qBAAqB,GAAG,gBAAgB,CAAC;AAC9C,KAAK,uBAAuB,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,GAAG;IAClF,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gFAAgF;IAChF,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AACF,KAAK,2BAA2B,GAAG,sBAAsB,CAAC;AAC1D,KAAK,sBAAsB,GAAG,iBAAiB,CAAC;AAChD,KAAK,sBAAsB,GAAG,iBAAiB,CAAC;AAChD,KAAK,qBAAqB,GAAG,gBAAgB,CAAC;AAE9C,KAAK,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC,CAAC;AAClG,KAAK,qBAAqB,GAAG,gBAAgB,CAAC;AAC9C,KAAK,uBAAuB,GAAG,kBAAkB,CAAC;AAMlD,iBAAS,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,qBAErD;AAED,iBAAS,kBAAkB,CAAC,EAC1B,QAAQ,EACR,SAAS,EACT,UAAoB,EACpB,eAAuB,EACvB,GAAG,KAAK,EACT,EAAE,uBAAuB,qBAqCzB;AAED,iBAAS,sBAAsB,CAAC,KAAK,EAAE,2BAA2B,qBAEjE;AAED;;;GAGG;AACH,iBAAS,iBAAiB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,sBAAsB,qBASzE;AAED,iBAAS,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,qBAEvD;AAED;;;GAGG;AACH,iBAAS,gBAAgB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,qBAAqB,qBAgBvE;AAED,2FAA2F;AAC3F,iBAAS,eAAe,CAAC,EAAE,iBAAiB,EAAE,GAAG,KAAK,EAAE,EAAE,gBAAgB,qBA+BzE;AAED,iBAAS,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,qBAErD;AAED,iBAAS,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,qBAEzD;AAED,QAAA,MAAM,WAAW;;;;;;;;;CASf,CAAC;AAEH,OAAO,EAAE,WAAW,EAAE,CAAC;AACvB,YAAY,EACV,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,EAC3B,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,GACxB,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Drawer as DrawerPrimitive } from '@base-ui/react/drawer';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { cn } from '../lib/utils.js';
|
|
6
|
+
import { Drawer, DrawerBackdrop, DrawerCloseButton, drawerSwipeTransitionClassName, } from './Drawer.js';
|
|
7
|
+
// The top padding leaves 3rem of the page above a sheet as tall as the viewport.
|
|
8
|
+
// `touch-none` keeps the page from panning or pulling to refresh under a drag.
|
|
9
|
+
const bottomSheetViewportClassName = 'fixed inset-0 z-50 flex touch-none flex-col justify-end pt-12';
|
|
10
|
+
const bottomSheetPopupClassName = cn('bg-popover text-popover-foreground relative flex max-h-full w-full min-w-0 flex-col rounded-t-2xl pt-3 shadow-lg/5 outline-none not-dark:bg-clip-padding',
|
|
11
|
+
// Base UI's keyboard provider sets `--drawer-keyboard-inset`, so the keyboard lifts the
|
|
12
|
+
// sheet. A footer takes this padding instead, so its fill reaches the screen's edge.
|
|
13
|
+
'[--sheet-inset:max(env(safe-area-inset-bottom,0px),var(--drawer-keyboard-inset,0px))] pb-(--sheet-inset) has-data-[slot=bottom-sheet-footer]:pb-0', drawerSwipeTransitionClassName,
|
|
14
|
+
// `snapPoints` on the root rest the sheet lower by `--drawer-snap-point-offset`.
|
|
15
|
+
'[transform:translateY(calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y,0px)))] data-ending-style:[transform:translateY(100%)] data-starting-style:[transform:translateY(100%)]',
|
|
16
|
+
// Fills the gap past the screen edge when a drag pulls the sheet up, in the footer's tint
|
|
17
|
+
// if it has one; opaque and 1px inside the edge, so a fractional drag leaves no seam.
|
|
18
|
+
'before:bg-popover before:pointer-events-none before:absolute before:inset-x-0 before:top-[calc(100%-1px)] before:h-12', 'has-data-[slot=bottom-sheet-footer]:before:bg-linear-to-b has-data-[slot=bottom-sheet-footer]:before:from-muted/72 has-data-[slot=bottom-sheet-footer]:before:to-muted/72');
|
|
19
|
+
// Where the sheet rests: Base UI marks it expanded only at snap point 1, whatever the top one.
|
|
20
|
+
// `none` for no snap points or one, `lower` below the top one, `top` at it.
|
|
21
|
+
const SnapPointsContext = React.createContext('none');
|
|
22
|
+
function BottomSheetClose(props) {
|
|
23
|
+
return _jsx(Drawer.Close, { "data-slot": "bottom-sheet-close", ...props });
|
|
24
|
+
}
|
|
25
|
+
function BottomSheetContent({ children, className, closeLabel = 'Close', showCloseButton = false, ...props }) {
|
|
26
|
+
const hasSnapPoints = React.useContext(SnapPointsContext) !== 'none';
|
|
27
|
+
return (_jsx(DrawerPrimitive.VirtualKeyboardProvider, { children: _jsxs(DrawerPrimitive.Portal, { children: [_jsx(DrawerBackdrop
|
|
28
|
+
// Base UI's progress hides the backdrop at a lower snap point; keep it whole.
|
|
29
|
+
, {
|
|
30
|
+
// Base UI's progress hides the backdrop at a lower snap point; keep it whole.
|
|
31
|
+
className: cn(hasSnapPoints && 'opacity-100'), "data-slot": "bottom-sheet-backdrop" }), _jsx(DrawerPrimitive.Viewport, { className: bottomSheetViewportClassName, children: _jsxs(DrawerPrimitive.Popup, { className: cn(bottomSheetPopupClassName,
|
|
32
|
+
// Keeps the title clear of the close button.
|
|
33
|
+
showCloseButton && '**:data-[slot=bottom-sheet-header]:pr-12', className), "data-slot": "bottom-sheet-content", ...props, children: [children, _jsx("div", { "aria-hidden": true, className: "bg-input absolute top-1.5 left-1/2 h-1 w-10 -translate-x-1/2 rounded-full", "data-slot": "bottom-sheet-bar" }), showCloseButton ? (_jsx(DrawerCloseButton, { "aria-label": closeLabel, "data-slot": "bottom-sheet-close" })) : null] }) })] }) }));
|
|
34
|
+
}
|
|
35
|
+
function BottomSheetDescription(props) {
|
|
36
|
+
return _jsx(Drawer.Description, { "data-slot": "bottom-sheet-description", ...props });
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A touch swipe on the footer never closes the sheet, so its buttons take taps. At a lower
|
|
40
|
+
* snap point, it waits below the screen until the sheet rises.
|
|
41
|
+
*/
|
|
42
|
+
function BottomSheetFooter({ className, ...props }) {
|
|
43
|
+
return (_jsx(Drawer.Footer, { className: cn('pb-[calc(1rem+var(--sheet-inset))]', className), "data-base-ui-swipe-ignore": "", "data-slot": "bottom-sheet-footer", ...props }));
|
|
44
|
+
}
|
|
45
|
+
function BottomSheetHeader(props) {
|
|
46
|
+
return _jsx(Drawer.Header, { "data-slot": "bottom-sheet-header", ...props });
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The scrolling body between the header and the footer. A touch swipe in it scrolls it and
|
|
50
|
+
* never closes the sheet, but with snap points, Base UI moves the sheet when it can't scroll.
|
|
51
|
+
*/
|
|
52
|
+
function BottomSheetPanel({ className, ...props }) {
|
|
53
|
+
const snapState = React.useContext(SnapPointsContext);
|
|
54
|
+
return (_jsx(Drawer.Panel, { className: cn('touch-pan-y',
|
|
55
|
+
// Scrolls once the sheet is at its top snap point, so a drag below it moves the sheet.
|
|
56
|
+
snapState === 'lower' && 'overflow-hidden', className), "data-base-ui-swipe-ignore": snapState === 'none' ? '' : undefined, "data-slot": "bottom-sheet-panel", ...props }));
|
|
57
|
+
}
|
|
58
|
+
/** List `snapPoints` from the lowest to the highest: the Panel scrolls at the last one. */
|
|
59
|
+
function BottomSheetRoot({ onSnapPointChange, ...props }) {
|
|
60
|
+
const { defaultSnapPoint, snapPoint, snapPoints = [] } = props;
|
|
61
|
+
const firstSnapPoint = defaultSnapPoint ?? snapPoints[0] ?? null;
|
|
62
|
+
// Mirrors Base UI's own snap point when uncontrolled, as it reads only within its parts.
|
|
63
|
+
const [restingSnapPoint, setRestingSnapPoint] = React.useState(firstSnapPoint);
|
|
64
|
+
const activeSnapPoint = snapPoint !== undefined
|
|
65
|
+
? snapPoint
|
|
66
|
+
: snapPoints.some((point) => Object.is(point, restingSnapPoint))
|
|
67
|
+
? restingSnapPoint
|
|
68
|
+
: firstSnapPoint;
|
|
69
|
+
const snapState = snapPoints.length < 2
|
|
70
|
+
? 'none'
|
|
71
|
+
: Object.is(activeSnapPoint, snapPoints[snapPoints.length - 1])
|
|
72
|
+
? 'top'
|
|
73
|
+
: 'lower';
|
|
74
|
+
return (_jsx(SnapPointsContext.Provider, { value: snapState, children: _jsx(DrawerPrimitive.Root, { onSnapPointChange: (nextSnapPoint, eventDetails) => {
|
|
75
|
+
onSnapPointChange?.(nextSnapPoint, eventDetails);
|
|
76
|
+
if (!eventDetails.isCanceled)
|
|
77
|
+
setRestingSnapPoint(nextSnapPoint);
|
|
78
|
+
}, swipeDirection: "down", ...props }) }));
|
|
79
|
+
}
|
|
80
|
+
function BottomSheetTitle(props) {
|
|
81
|
+
return _jsx(Drawer.Title, { "data-slot": "bottom-sheet-title", ...props });
|
|
82
|
+
}
|
|
83
|
+
function BottomSheetTrigger(props) {
|
|
84
|
+
return _jsx(Drawer.Trigger, { "data-slot": "bottom-sheet-trigger", ...props });
|
|
85
|
+
}
|
|
86
|
+
const BottomSheet = Object.assign(BottomSheetRoot, {
|
|
87
|
+
Close: BottomSheetClose,
|
|
88
|
+
Content: BottomSheetContent,
|
|
89
|
+
Description: BottomSheetDescription,
|
|
90
|
+
Footer: BottomSheetFooter,
|
|
91
|
+
Header: BottomSheetHeader,
|
|
92
|
+
Panel: BottomSheetPanel,
|
|
93
|
+
Title: BottomSheetTitle,
|
|
94
|
+
Trigger: BottomSheetTrigger,
|
|
95
|
+
});
|
|
96
|
+
export { BottomSheet };
|
|
97
|
+
//# sourceMappingURL=BottomSheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BottomSheet.js","sourceRoot":"","sources":["../../src/components/BottomSheet.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EACL,MAAM,EACN,cAAc,EACd,iBAAiB,EAMjB,8BAA8B,GAG/B,MAAM,UAAU,CAAC;AAElB,iFAAiF;AACjF,+EAA+E;AAC/E,MAAM,4BAA4B,GAChC,+DAA+D,CAAC;AAElE,MAAM,yBAAyB,GAAG,EAAE,CAClC,0JAA0J;AAC1J,wFAAwF;AACxF,qFAAqF;AACrF,mJAAmJ,EACnJ,8BAA8B;AAC9B,iFAAiF;AACjF,sMAAsM;AACtM,0FAA0F;AAC1F,sFAAsF;AACtF,uHAAuH,EACvH,2KAA2K,CAC5K,CAAC;AAkBF,+FAA+F;AAC/F,4EAA4E;AAC5E,MAAM,iBAAiB,GAAG,KAAK,CAAC,aAAa,C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@ -1,10 +1,14 @@
|
|
|
1
1
|
import { Drawer as DrawerPrimitive } from '@base-ui/react/drawer';
|
|
2
2
|
import { type VariantProps } from 'class-variance-authority';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
+
declare const drawerSwipeTransitionClassName: string;
|
|
4
5
|
declare const drawerPopupVariants: (props?: ({
|
|
5
6
|
size?: "lg" | "md" | "sm" | null | undefined;
|
|
6
7
|
variant?: "attached" | "inset" | "straight" | null | undefined;
|
|
7
8
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
9
|
+
type DrawerBackdropProps = Omit<React.ComponentProps<typeof DrawerPrimitive.Backdrop>, 'className'> & {
|
|
10
|
+
className?: string;
|
|
11
|
+
};
|
|
8
12
|
type DrawerCloseProps = React.ComponentProps<typeof DrawerPrimitive.Close>;
|
|
9
13
|
type DrawerContentProps = React.ComponentProps<typeof DrawerPrimitive.Popup> & {
|
|
10
14
|
/** Accessible name of the close icon button. Defaults to `"Close"`. */
|
|
@@ -31,7 +35,11 @@ type DrawerSize = NonNullable<VariantProps<typeof drawerPopupVariants>['size']>;
|
|
|
31
35
|
type DrawerTitleProps = React.ComponentProps<typeof DrawerPrimitive.Title>;
|
|
32
36
|
type DrawerTriggerProps = React.ComponentProps<typeof DrawerPrimitive.Trigger>;
|
|
33
37
|
type DrawerVariant = NonNullable<VariantProps<typeof drawerPopupVariants>['variant']>;
|
|
38
|
+
/** The dimmed page behind the drawer; `BottomSheet` shares it. */
|
|
39
|
+
declare function DrawerBackdrop({ className, ...props }: DrawerBackdropProps): React.JSX.Element;
|
|
34
40
|
declare function DrawerClose({ ...props }: DrawerCloseProps): React.JSX.Element;
|
|
41
|
+
/** The close icon button in the popup's top-right corner; `BottomSheet` shares it. */
|
|
42
|
+
declare function DrawerCloseButton(props: DrawerCloseProps): React.JSX.Element;
|
|
35
43
|
declare function DrawerContent({ children, className, closeLabel, showCloseButton, size, variant, ...props }: DrawerContentProps): React.JSX.Element;
|
|
36
44
|
declare function DrawerDescription({ className, ...props }: DrawerDescriptionProps): React.JSX.Element;
|
|
37
45
|
declare function DrawerFooter({ className, ...props }: DrawerFooterProps): React.JSX.Element;
|
|
@@ -54,6 +62,6 @@ declare const Drawer: typeof DrawerRoot & {
|
|
|
54
62
|
Title: typeof DrawerTitle;
|
|
55
63
|
Trigger: typeof DrawerTrigger;
|
|
56
64
|
};
|
|
57
|
-
export { Drawer };
|
|
65
|
+
export { Drawer, DrawerBackdrop, DrawerCloseButton, drawerSwipeTransitionClassName };
|
|
58
66
|
export type { DrawerCloseProps, DrawerContentProps, DrawerDescriptionProps, DrawerFooterProps, DrawerHeaderProps, DrawerPanelProps, DrawerProps, DrawerTitleProps, DrawerTriggerProps, };
|
|
59
67
|
//# sourceMappingURL=Drawer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../src/components/Drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../src/components/Drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAgB/B,QAAA,MAAM,8BAA8B,QAGnC,CAAC;AAQF,QAAA,MAAM,mBAAmB;;;8EA+BxB,CAAC;AAEF,KAAK,mBAAmB,GAAG,IAAI,CAC7B,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,QAAQ,CAAC,EACrD,WAAW,CACZ,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,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AAkB,GACnB,CAAC"}
|
|
@@ -8,11 +8,12 @@ import { Button } from './Button.js';
|
|
|
8
8
|
// iOS sheet curve, as in coss ui's Drawer. Moves use `transform`, which Base
|
|
9
9
|
// UI's inline drag offset replaces, where `translate-*` would add to it.
|
|
10
10
|
const drawerMotion = 'duration-450 ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none';
|
|
11
|
-
|
|
11
|
+
// How a drawer's popup follows a drag and settles; `BottomSheet` shares it.
|
|
12
|
+
const drawerSwipeTransitionClassName = cn('transition-transform data-ending-style:duration-[calc(var(--drawer-swipe-strength,1)*400ms)] data-swiping:select-none', drawerMotion);
|
|
12
13
|
const drawerViewportClassName = 'fixed inset-0 z-50 flex';
|
|
13
14
|
// Fills the gap past the screen edge when a drag pulls a docked drawer inwards.
|
|
14
15
|
const drawerEdgeFillClassName = 'after:bg-popover after:pointer-events-none after:absolute after:inset-y-0 after:left-full after:w-12';
|
|
15
|
-
const drawerPopupVariants = cva(cn('bg-popover text-popover-foreground relative ml-auto flex w-[calc(100%-3rem)] min-w-0 flex-col shadow-lg/5 outline-none not-dark:bg-clip-padding',
|
|
16
|
+
const drawerPopupVariants = cva(cn('bg-popover text-popover-foreground relative ml-auto flex w-[calc(100%-3rem)] min-w-0 flex-col shadow-lg/5 outline-none not-dark:bg-clip-padding', drawerSwipeTransitionClassName, '[transform:translateX(var(--drawer-swipe-movement-x,0px))] data-ending-style:[transform:translateX(calc(100%+var(--inset,0px)))] data-starting-style:[transform:translateX(calc(100%+var(--inset,0px)))]'), {
|
|
16
17
|
defaultVariants: {
|
|
17
18
|
size: 'md',
|
|
18
19
|
variant: 'inset',
|
|
@@ -33,13 +34,21 @@ const drawerPopupVariants = cva(cn('bg-popover text-popover-foreground relative
|
|
|
33
34
|
},
|
|
34
35
|
},
|
|
35
36
|
});
|
|
37
|
+
/** The dimmed page behind the drawer; `BottomSheet` shares it. */
|
|
38
|
+
function DrawerBackdrop({ className, ...props }) {
|
|
39
|
+
return (_jsx(DrawerPrimitive.Backdrop, { className: cn('fixed inset-0 z-50 bg-black/32 opacity-[calc(1-var(--drawer-swipe-progress,0))] backdrop-blur-sm transition-opacity data-ending-style:opacity-0 data-starting-style:opacity-0 data-swiping:duration-0', drawerMotion, className), "data-slot": "drawer-backdrop", ...props }));
|
|
40
|
+
}
|
|
36
41
|
function DrawerClose({ ...props }) {
|
|
37
42
|
return _jsx(DrawerPrimitive.Close, { "data-slot": "drawer-close", ...props });
|
|
38
43
|
}
|
|
44
|
+
/** The close icon button in the popup's top-right corner; `BottomSheet` shares it. */
|
|
45
|
+
function DrawerCloseButton(props) {
|
|
46
|
+
return (_jsx(DrawerPrimitive.Close, { className: "absolute top-3 right-3", "data-slot": "drawer-close", render: _jsx(Button, { size: "icon-sm", variant: "ghost" }), ...props, children: _jsx(IconX, {}) }));
|
|
47
|
+
}
|
|
39
48
|
function DrawerContent({ children, className, closeLabel = 'Close', showCloseButton = false, size = 'md', variant = 'inset', ...props }) {
|
|
40
|
-
return (_jsxs(DrawerPrimitive.Portal, { children: [_jsx(
|
|
49
|
+
return (_jsxs(DrawerPrimitive.Portal, { children: [_jsx(DrawerBackdrop, {}), _jsx(DrawerPrimitive.Viewport, { className: drawerViewportClassName, children: _jsxs(DrawerPrimitive.Popup, { className: cn(drawerPopupVariants({ size, variant }),
|
|
41
50
|
// Keeps the title clear of the close button.
|
|
42
|
-
showCloseButton && '**:data-[slot=drawer-header]:pr-12', className), "data-size": size, "data-slot": "drawer-content", "data-variant": variant, ...props, children: [children, showCloseButton ?
|
|
51
|
+
showCloseButton && '**:data-[slot=drawer-header]:pr-12', className), "data-size": size, "data-slot": "drawer-content", "data-variant": variant, ...props, children: [children, showCloseButton ? _jsx(DrawerCloseButton, { "aria-label": closeLabel }) : null] }) })] }));
|
|
43
52
|
}
|
|
44
53
|
function DrawerDescription({ className, ...props }) {
|
|
45
54
|
return (_jsx(DrawerPrimitive.Description, { className: cn(dialogDescriptionClassName, className), "data-slot": "drawer-description", ...props }));
|
|
@@ -79,5 +88,6 @@ const Drawer = Object.assign(DrawerRoot, {
|
|
|
79
88
|
Title: DrawerTitle,
|
|
80
89
|
Trigger: DrawerTrigger,
|
|
81
90
|
});
|
|
82
|
-
|
|
91
|
+
// The parts `BottomSheet` builds on; `entries/drawer.ts` exports only `Drawer`.
|
|
92
|
+
export { Drawer, DrawerBackdrop, DrawerCloseButton, drawerSwipeTransitionClassName };
|
|
83
93
|
//# sourceMappingURL=Drawer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.js","sourceRoot":"","sources":["../../src/components/Drawer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,6EAA6E;AAC7E,yEAAyE;AACzE,MAAM,YAAY,GAChB,+EAA+E,CAAC;AAElF,MAAM,
|
|
1
|
+
{"version":3,"file":"Drawer.js","sourceRoot":"","sources":["../../src/components/Drawer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,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AAgF;AAChF,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
-
/** Shared look for `Dialog` and `
|
|
2
|
+
/** Shared look for `Dialog`, `AlertDialog` and `Drawer` (and `BottomSheet` through it); not part of the public API. */
|
|
3
3
|
declare const dialogBackdropClassName = "fixed inset-0 z-50 bg-black/32 backdrop-blur-sm duration-200 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0";
|
|
4
4
|
declare const dialogViewportClassName = "fixed inset-0 z-50 flex flex-col items-center overflow-y-auto p-4 sm:p-6";
|
|
5
5
|
declare const dialogPopupVariants: (props?: ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-styles.d.ts","sourceRoot":"","sources":["../../../src/components/_internal/dialog-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAKlE,
|
|
1
|
+
{"version":3,"file":"dialog-styles.d.ts","sourceRoot":"","sources":["../../../src/components/_internal/dialog-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAKlE,uHAAuH;AAEvH,QAAA,MAAM,uBAAuB,yJAC2H,CAAC;AAEzJ,QAAA,MAAM,uBAAuB,6EAC+C,CAAC;AAE7E,QAAA,MAAM,mBAAmB;;8EAcxB,CAAC;AAEF,QAAA,MAAM,qBAAqB,oDAAoD,CAAC;AAEhF,QAAA,MAAM,qBAAqB,2DAA2D,CAAC;AAEvF,QAAA,MAAM,oBAAoB,QAGzB,CAAC;AAEF,QAAA,MAAM,0BAA0B,QAG9B,CAAC;AAEH,KAAK,UAAU,GAAG,WAAW,CAAC,YAAY,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEhF,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,GACxB,CAAC;AACF,YAAY,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cva } from 'class-variance-authority';
|
|
2
2
|
import { cn } from '../../lib/utils.js';
|
|
3
3
|
import { textVariants } from '../Text.js';
|
|
4
|
-
/** Shared look for `Dialog` and `
|
|
4
|
+
/** Shared look for `Dialog`, `AlertDialog` and `Drawer` (and `BottomSheet` through it); not part of the public API. */
|
|
5
5
|
const dialogBackdropClassName = 'fixed inset-0 z-50 bg-black/32 backdrop-blur-sm duration-200 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0';
|
|
6
6
|
const dialogViewportClassName = 'fixed inset-0 z-50 flex flex-col items-center overflow-y-auto p-4 sm:p-6';
|
|
7
7
|
const dialogPopupVariants = cva('bg-popover text-popover-foreground relative my-auto flex w-full min-w-0 flex-col gap-4 rounded-2xl border p-6 shadow-lg/5 duration-200 outline-none not-dark:bg-clip-padding before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-2xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 dark:before:shadow-[0_-1px_--theme(--color-white/6%)]', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-styles.js","sourceRoot":"","sources":["../../../src/components/_internal/dialog-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,
|
|
1
|
+
{"version":3,"file":"dialog-styles.js","sourceRoot":"","sources":["../../../src/components/_internal/dialog-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,uHAAuH;AAEvH,MAAM,uBAAuB,GAC3B,sJAAsJ,CAAC;AAEzJ,MAAM,uBAAuB,GAC3B,0EAA0E,CAAC;AAE7E,MAAM,mBAAmB,GAAG,GAAG,CAC7B,ggBAAggB,EAChgB;IACE,eAAe,EAAE;QACf,IAAI,EAAE,IAAI;KACX;IACD,QAAQ,EAAE;QACR,IAAI,EAAE;YACJ,EAAE,EAAE,WAAW;YACf,EAAE,EAAE,UAAU;YACd,EAAE,EAAE,UAAU;SACf;KACF;CACF,CACF,CAAC;AAEF,MAAM,qBAAqB,GAAG,iDAAiD,CAAC;AAEhF,MAAM,qBAAqB,GAAG,wDAAwD,CAAC;AAEvF,MAAM,oBAAoB,GAAG,EAAE,CAC7B,YAAY,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAC/B,yCAAyC,CAC1C,CAAC;AAEF,MAAM,0BAA0B,GAAG,YAAY,CAAC;IAC9C,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,MAAM;CAChB,CAAC,CAAC;AAIH,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,GACxB,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { BottomSheet } from '../components/BottomSheet.js';
|
|
2
|
+
export type { BottomSheetCloseProps, BottomSheetContentProps, BottomSheetDescriptionProps, BottomSheetFooterProps, BottomSheetHeaderProps, BottomSheetPanelProps, BottomSheetProps, BottomSheetTitleProps, BottomSheetTriggerProps, } from '../components/BottomSheet.js';
|
|
3
|
+
//# sourceMappingURL=bottom-sheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bottom-sheet.d.ts","sourceRoot":"","sources":["../../src/entries/bottom-sheet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,YAAY,EACV,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,EAC3B,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bottom-sheet.js","sourceRoot":"","sources":["../../src/entries/bottom-sheet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './entries/alert.js';
|
|
|
2
2
|
export * from './entries/alert-dialog.js';
|
|
3
3
|
export * from './entries/avatar.js';
|
|
4
4
|
export * from './entries/badge.js';
|
|
5
|
+
export * from './entries/bottom-sheet.js';
|
|
5
6
|
export * from './entries/button.js';
|
|
6
7
|
export * from './entries/card.js';
|
|
7
8
|
export * from './entries/checkbox.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,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ChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from './entries/alert.js';
|
|
|
4
4
|
export * from './entries/alert-dialog.js';
|
|
5
5
|
export * from './entries/avatar.js';
|
|
6
6
|
export * from './entries/badge.js';
|
|
7
|
+
export * from './entries/bottom-sheet.js';
|
|
7
8
|
export * from './entries/button.js';
|
|
8
9
|
export * from './entries/card.js';
|
|
9
10
|
export * from './entries/checkbox.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,yEAAyE;AACzE,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AAC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AAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -22,6 +22,7 @@ If the package isn't installed yet, follow the README's "Use Pickle UI" section.
|
|
|
22
22
|
- **Reach parts through the component**: `<Dialog.Title>`, never `DialogTitle`. The root is `<Dialog>` itself; only `ScrollArea` has a `.Root`.
|
|
23
23
|
- **Swap the element with `render`**: `<Button render={<a href="/docs" />}>Docs</Button>`. There is no `asChild`. `Text`, `Flex`, `Grid`, `XStack` and `YStack` take `as` instead.
|
|
24
24
|
- **Overlays are one part**: each overlay's `Content` (`Dialog.Content`, `Popover.Content`, …) already renders the portal and the backdrop or positioner. Position `Popover`, `Menu`, `Tooltip`, `Select` and `Combobox` popups with `side`, `align`, `sideOffset` or `alignOffset` on `Content`.
|
|
25
|
+
- **Bottom sheets**: `BottomSheet` rises from the bottom edge and closes on a swipe down; `Drawer` slides in from the right. Swipes in `BottomSheet.Footer` never close it, nor do swipes in `BottomSheet.Panel` but with `snapPoints`, where a swipe the Panel can't scroll moves the sheet: put `data-base-ui-swipe-ignore` on other content of the sheet that holds a field. List `snapPoints` from the lowest to the highest; the Panel scrolls at the last one, and the Footer shows only there.
|
|
25
26
|
- **State props follow Base UI**: `open` / `defaultOpen` / `onOpenChange`, `value` / `defaultValue` / `onValueChange`, `disabled`.
|
|
26
27
|
- **Text goes in `Text`** with a `variant` (`h1` … `h4`, `lead`, `body`, `small`, `code`), not raw `h1`–`h6`, `p` or `span`.
|
|
27
28
|
- **Forms**: pass `useForm()`'s return to `<Form form={form}>`, wrap each control in `Form.Field` with a `label` and `name`, and use the bound controls (`Form.Input`, `Form.Select`, …). Rows of controls go in `Form.GroupField`.
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { useForm } from 'react-hook-form';
|
|
6
|
+
import { z } from 'zod/v4';
|
|
7
|
+
|
|
8
|
+
import { type ComponentMatrixCellProps, Story } from './_internal/Story';
|
|
9
|
+
import { BottomSheet } from './BottomSheet';
|
|
10
|
+
import { Button } from './Button';
|
|
11
|
+
import { Form } from './form/Form';
|
|
12
|
+
import { Input } from './form/Input';
|
|
13
|
+
import { Text } from './Text';
|
|
14
|
+
|
|
15
|
+
const meta = {
|
|
16
|
+
component: BottomSheet,
|
|
17
|
+
parameters: {
|
|
18
|
+
layout: 'fullscreen',
|
|
19
|
+
},
|
|
20
|
+
title: 'components/BottomSheet',
|
|
21
|
+
} satisfies Meta<typeof BottomSheet>;
|
|
22
|
+
|
|
23
|
+
export default meta;
|
|
24
|
+
type ExampleContent = 'close-button' | 'form' | 'list' | 'snap-points';
|
|
25
|
+
|
|
26
|
+
type StoryDefinition = StoryObj<typeof meta>;
|
|
27
|
+
|
|
28
|
+
const CONTENT_COLUMNS: {
|
|
29
|
+
description: string;
|
|
30
|
+
key: ExampleContent;
|
|
31
|
+
label: string;
|
|
32
|
+
}[] = [
|
|
33
|
+
{ description: 'Header, panel and footer', key: 'form', label: 'Form' },
|
|
34
|
+
{
|
|
35
|
+
description: 'The panel scrolls between header and footer',
|
|
36
|
+
key: 'list',
|
|
37
|
+
label: 'Long content',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
description: 'showCloseButton, no footer',
|
|
41
|
+
key: 'close-button',
|
|
42
|
+
label: 'With close button',
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
const SNAP_POINTS = [0.5, 1];
|
|
47
|
+
|
|
48
|
+
const SNAP_POINTS_COLUMNS: {
|
|
49
|
+
description: string;
|
|
50
|
+
key: ExampleContent;
|
|
51
|
+
label: string;
|
|
52
|
+
}[] = [
|
|
53
|
+
{
|
|
54
|
+
description: 'No footer: at half height it would sit below the screen',
|
|
55
|
+
key: 'snap-points',
|
|
56
|
+
label: 'Long content',
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
const profileSchema = z.object({
|
|
61
|
+
name: z.string().trim().min(1, 'Enter your name.'),
|
|
62
|
+
username: z.string().trim().min(2, 'Use at least 2 characters.'),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const ACTIVITY = Array.from({ length: 24 }, (_, index) => ({
|
|
66
|
+
id: index,
|
|
67
|
+
label: `Deployment #${240 - index}`,
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
function Activity({ description }: { description: string }) {
|
|
71
|
+
return (
|
|
72
|
+
<>
|
|
73
|
+
<BottomSheet.Header>
|
|
74
|
+
<BottomSheet.Title>Activity</BottomSheet.Title>
|
|
75
|
+
<BottomSheet.Description>{description}</BottomSheet.Description>
|
|
76
|
+
</BottomSheet.Header>
|
|
77
|
+
<BottomSheet.Panel className="grid content-start gap-2">
|
|
78
|
+
{ACTIVITY.map(({ id, label }) => (
|
|
79
|
+
<div className="rounded-lg border px-3 py-2" key={id}>
|
|
80
|
+
<Text variant="body">{label}</Text>
|
|
81
|
+
</div>
|
|
82
|
+
))}
|
|
83
|
+
</BottomSheet.Panel>
|
|
84
|
+
</>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function BottomSheetExample({ content, trigger }: { content: ExampleContent; trigger: string }) {
|
|
89
|
+
const [open, setOpen] = React.useState(false);
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<BottomSheet
|
|
93
|
+
onOpenChange={setOpen}
|
|
94
|
+
open={open}
|
|
95
|
+
snapPoints={content === 'snap-points' ? SNAP_POINTS : undefined}
|
|
96
|
+
>
|
|
97
|
+
<BottomSheet.Trigger render={<Button variant="outline" />}>{trigger}</BottomSheet.Trigger>
|
|
98
|
+
<BottomSheet.Content showCloseButton={content === 'close-button'}>
|
|
99
|
+
{content === 'form' ? <ProfileForm onSaved={() => setOpen(false)} /> : null}
|
|
100
|
+
{content === 'list' ? (
|
|
101
|
+
<>
|
|
102
|
+
<Activity description="The last 24 deployments." />
|
|
103
|
+
<BottomSheet.Footer>
|
|
104
|
+
<BottomSheet.Close render={<Button variant="outline" />}>Close</BottomSheet.Close>
|
|
105
|
+
</BottomSheet.Footer>
|
|
106
|
+
</>
|
|
107
|
+
) : null}
|
|
108
|
+
{content === 'snap-points' ? (
|
|
109
|
+
<Activity description="Drag up to see all 24 deployments." />
|
|
110
|
+
) : null}
|
|
111
|
+
{content === 'close-button' ? (
|
|
112
|
+
<>
|
|
113
|
+
<BottomSheet.Header>
|
|
114
|
+
<BottomSheet.Title>Share link</BottomSheet.Title>
|
|
115
|
+
<BottomSheet.Description>
|
|
116
|
+
Anyone with the link can view this project. Swipe down to close.
|
|
117
|
+
</BottomSheet.Description>
|
|
118
|
+
</BottomSheet.Header>
|
|
119
|
+
<BottomSheet.Panel>
|
|
120
|
+
<Input readOnly value="https://pickle-ui.dev/p/8f2a" />
|
|
121
|
+
</BottomSheet.Panel>
|
|
122
|
+
</>
|
|
123
|
+
) : null}
|
|
124
|
+
</BottomSheet.Content>
|
|
125
|
+
</BottomSheet>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function ContentCell({ column }: ComponentMatrixCellProps) {
|
|
130
|
+
return <BottomSheetExample content={column.key as ExampleContent} trigger="Open" />;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* A `Form` around the header, panel and footer, so `Form.Button` in the footer
|
|
135
|
+
* submits it. `contents` (and no `space-y`) keeps the three parts laid out
|
|
136
|
+
* by the sheet.
|
|
137
|
+
*/
|
|
138
|
+
function ProfileForm({ onSaved }: { onSaved: () => void }) {
|
|
139
|
+
const form = useForm<z.infer<typeof profileSchema>>({
|
|
140
|
+
defaultValues: { name: 'Ada Lovelace', username: 'ada' },
|
|
141
|
+
resolver: zodResolver(profileSchema),
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<Form className="contents space-y-0" form={form} onSubmit={onSaved}>
|
|
146
|
+
<BottomSheet.Header>
|
|
147
|
+
<BottomSheet.Title>Edit profile</BottomSheet.Title>
|
|
148
|
+
<BottomSheet.Description>
|
|
149
|
+
Make changes to your profile, then save when you are done.
|
|
150
|
+
</BottomSheet.Description>
|
|
151
|
+
</BottomSheet.Header>
|
|
152
|
+
<BottomSheet.Panel className="space-y-6">
|
|
153
|
+
<Form.Field label="Name" name="name">
|
|
154
|
+
<Form.Input autoComplete="name" />
|
|
155
|
+
</Form.Field>
|
|
156
|
+
<Form.Field description="Shown on your public profile." label="Username" name="username">
|
|
157
|
+
<Form.Input autoComplete="username" />
|
|
158
|
+
</Form.Field>
|
|
159
|
+
</BottomSheet.Panel>
|
|
160
|
+
<BottomSheet.Footer>
|
|
161
|
+
<BottomSheet.Close render={<Button variant="outline" />}>Cancel</BottomSheet.Close>
|
|
162
|
+
<Form.Button type="submit">Save changes</Form.Button>
|
|
163
|
+
</BottomSheet.Footer>
|
|
164
|
+
</Form>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export const All: StoryDefinition = {
|
|
169
|
+
render: () => (
|
|
170
|
+
<Story.Layout className="max-w-5xl" title="BottomSheet">
|
|
171
|
+
<Story.Section title="Content">
|
|
172
|
+
<Story.Matrix
|
|
173
|
+
Cell={ContentCell}
|
|
174
|
+
columns={CONTENT_COLUMNS}
|
|
175
|
+
rows={[
|
|
176
|
+
{
|
|
177
|
+
description: 'Rises from the bottom edge, closes on a swipe down',
|
|
178
|
+
key: 'content',
|
|
179
|
+
label: 'content',
|
|
180
|
+
},
|
|
181
|
+
]}
|
|
182
|
+
/>
|
|
183
|
+
</Story.Section>
|
|
184
|
+
|
|
185
|
+
<Story.Section title="Snap points">
|
|
186
|
+
<Story.Matrix
|
|
187
|
+
Cell={ContentCell}
|
|
188
|
+
columns={SNAP_POINTS_COLUMNS}
|
|
189
|
+
rows={[
|
|
190
|
+
{
|
|
191
|
+
description: 'Opens at half height, drags up to full height',
|
|
192
|
+
key: 'snap-points',
|
|
193
|
+
label: 'snapPoints={[0.5, 1]}',
|
|
194
|
+
},
|
|
195
|
+
]}
|
|
196
|
+
/>
|
|
197
|
+
</Story.Section>
|
|
198
|
+
</Story.Layout>
|
|
199
|
+
),
|
|
200
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Drawer as DrawerPrimitive } from '@base-ui/react/drawer';
|
|
2
|
+
import { fireEvent, render, screen, waitFor, within } from '@testing-library/react';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
|
|
5
|
+
import { BottomSheet, type BottomSheetContentProps } from './BottomSheet';
|
|
6
|
+
|
|
7
|
+
async function openSheet() {
|
|
8
|
+
fireEvent.click(screen.getByRole('button', { name: 'Open cart' }));
|
|
9
|
+
return screen.findByRole('dialog', { name: 'Cart' });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function renderSheet(contentProps?: BottomSheetContentProps) {
|
|
13
|
+
return render(
|
|
14
|
+
<BottomSheet>
|
|
15
|
+
<BottomSheet.Trigger>Open cart</BottomSheet.Trigger>
|
|
16
|
+
<BottomSheet.Content {...contentProps}>
|
|
17
|
+
<BottomSheet.Header>
|
|
18
|
+
<BottomSheet.Title>Cart</BottomSheet.Title>
|
|
19
|
+
<BottomSheet.Description>Review your items.</BottomSheet.Description>
|
|
20
|
+
</BottomSheet.Header>
|
|
21
|
+
<BottomSheet.Panel>Two items</BottomSheet.Panel>
|
|
22
|
+
<BottomSheet.Footer>
|
|
23
|
+
<BottomSheet.Close>Keep shopping</BottomSheet.Close>
|
|
24
|
+
</BottomSheet.Footer>
|
|
25
|
+
</BottomSheet.Content>
|
|
26
|
+
</BottomSheet>,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
describe('BottomSheet', () => {
|
|
31
|
+
it('opens from the trigger with an accessible name and description', async () => {
|
|
32
|
+
renderSheet();
|
|
33
|
+
|
|
34
|
+
const sheet = await openSheet();
|
|
35
|
+
|
|
36
|
+
expect(sheet).toHaveAccessibleDescription('Review your items.');
|
|
37
|
+
expect(sheet).toHaveAttribute('data-slot', 'bottom-sheet-content');
|
|
38
|
+
expect(screen.getByRole('heading', { name: 'Cart' })).toHaveAttribute(
|
|
39
|
+
'data-slot',
|
|
40
|
+
'bottom-sheet-title',
|
|
41
|
+
);
|
|
42
|
+
expect(document.querySelector('[data-slot=bottom-sheet-backdrop]')).toBeTruthy();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('names every part it builds on Drawer with its own slot', async () => {
|
|
46
|
+
renderSheet({ showCloseButton: true });
|
|
47
|
+
const trigger = screen.getByRole('button', { name: 'Open cart' });
|
|
48
|
+
|
|
49
|
+
const sheet = await openSheet();
|
|
50
|
+
|
|
51
|
+
expect(trigger).toHaveAttribute('data-slot', 'bottom-sheet-trigger');
|
|
52
|
+
for (const part of ['backdrop', 'header', 'description', 'panel', 'footer']) {
|
|
53
|
+
expect(document.querySelector(`[data-slot=bottom-sheet-${part}]`)).toBeTruthy();
|
|
54
|
+
}
|
|
55
|
+
for (const name of ['Close', 'Keep shopping']) {
|
|
56
|
+
expect(within(sheet).getByRole('button', { name })).toHaveAttribute(
|
|
57
|
+
'data-slot',
|
|
58
|
+
'bottom-sheet-close',
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
expect(document.querySelector('[data-slot^=drawer-]')).toBeNull();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('rises from the bottom with a hidden grab bar', async () => {
|
|
65
|
+
renderSheet();
|
|
66
|
+
|
|
67
|
+
const sheet = await openSheet();
|
|
68
|
+
|
|
69
|
+
expect(sheet).toHaveAttribute('data-swipe-direction', 'down');
|
|
70
|
+
expect(sheet.querySelector('[data-slot=bottom-sheet-bar]')).toHaveAttribute(
|
|
71
|
+
'aria-hidden',
|
|
72
|
+
'true',
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('never closes on a swipe in the panel or the footer', async () => {
|
|
77
|
+
renderSheet();
|
|
78
|
+
|
|
79
|
+
const sheet = await openSheet();
|
|
80
|
+
|
|
81
|
+
expect(within(sheet).getByText('Two items')).toHaveAttribute('data-base-ui-swipe-ignore');
|
|
82
|
+
expect(sheet.querySelector('[data-slot=bottom-sheet-footer]')).toHaveAttribute(
|
|
83
|
+
'data-base-ui-swipe-ignore',
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it.each([
|
|
88
|
+
{ defaultSnapPoint: '20rem', scrolls: false },
|
|
89
|
+
{ defaultSnapPoint: '40rem', scrolls: true },
|
|
90
|
+
])(
|
|
91
|
+
'with snapPoints, lets a swipe in the panel move the sheet; it scrolls only at the top one ($defaultSnapPoint)',
|
|
92
|
+
async ({ defaultSnapPoint, scrolls }) => {
|
|
93
|
+
render(
|
|
94
|
+
<BottomSheet defaultSnapPoint={defaultSnapPoint} snapPoints={['20rem', '40rem']}>
|
|
95
|
+
<BottomSheet.Trigger>Open cart</BottomSheet.Trigger>
|
|
96
|
+
<BottomSheet.Content>
|
|
97
|
+
<BottomSheet.Title>Cart</BottomSheet.Title>
|
|
98
|
+
<BottomSheet.Panel>Two items</BottomSheet.Panel>
|
|
99
|
+
</BottomSheet.Content>
|
|
100
|
+
</BottomSheet>,
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const panel = within(await openSheet()).getByText('Two items');
|
|
104
|
+
|
|
105
|
+
expect(panel).not.toHaveAttribute('data-base-ui-swipe-ignore');
|
|
106
|
+
expect(panel.classList.contains('overflow-hidden')).toBe(!scrolls);
|
|
107
|
+
},
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
it('closes from BottomSheet.Close', async () => {
|
|
111
|
+
renderSheet();
|
|
112
|
+
|
|
113
|
+
const sheet = await openSheet();
|
|
114
|
+
fireEvent.click(within(sheet).getByRole('button', { name: 'Keep shopping' }));
|
|
115
|
+
|
|
116
|
+
await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('closes from the close button, named with closeLabel', async () => {
|
|
120
|
+
renderSheet({ closeLabel: 'Fermer', showCloseButton: true });
|
|
121
|
+
|
|
122
|
+
const sheet = await openSheet();
|
|
123
|
+
fireEvent.click(within(sheet).getByRole('button', { name: 'Fermer' }));
|
|
124
|
+
|
|
125
|
+
await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("opens from a trigger outside it, through a Base UI drawer's handle", async () => {
|
|
129
|
+
const handle = DrawerPrimitive.createHandle();
|
|
130
|
+
render(
|
|
131
|
+
<>
|
|
132
|
+
<BottomSheet.Trigger handle={handle}>Open cart</BottomSheet.Trigger>
|
|
133
|
+
<BottomSheet handle={handle}>
|
|
134
|
+
<BottomSheet.Content>
|
|
135
|
+
<BottomSheet.Title>Cart</BottomSheet.Title>
|
|
136
|
+
</BottomSheet.Content>
|
|
137
|
+
</BottomSheet>
|
|
138
|
+
</>,
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
expect(await openSheet()).toBeInTheDocument();
|
|
142
|
+
});
|
|
143
|
+
});
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Drawer as DrawerPrimitive } from '@base-ui/react/drawer';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
import { cn } from '../lib/utils';
|
|
7
|
+
import {
|
|
8
|
+
Drawer,
|
|
9
|
+
DrawerBackdrop,
|
|
10
|
+
DrawerCloseButton,
|
|
11
|
+
type DrawerCloseProps,
|
|
12
|
+
type DrawerDescriptionProps,
|
|
13
|
+
type DrawerFooterProps,
|
|
14
|
+
type DrawerHeaderProps,
|
|
15
|
+
type DrawerPanelProps,
|
|
16
|
+
drawerSwipeTransitionClassName,
|
|
17
|
+
type DrawerTitleProps,
|
|
18
|
+
type DrawerTriggerProps,
|
|
19
|
+
} from './Drawer';
|
|
20
|
+
|
|
21
|
+
// The top padding leaves 3rem of the page above a sheet as tall as the viewport.
|
|
22
|
+
// `touch-none` keeps the page from panning or pulling to refresh under a drag.
|
|
23
|
+
const bottomSheetViewportClassName =
|
|
24
|
+
'fixed inset-0 z-50 flex touch-none flex-col justify-end pt-12';
|
|
25
|
+
|
|
26
|
+
const bottomSheetPopupClassName = cn(
|
|
27
|
+
'bg-popover text-popover-foreground relative flex max-h-full w-full min-w-0 flex-col rounded-t-2xl pt-3 shadow-lg/5 outline-none not-dark:bg-clip-padding',
|
|
28
|
+
// Base UI's keyboard provider sets `--drawer-keyboard-inset`, so the keyboard lifts the
|
|
29
|
+
// sheet. A footer takes this padding instead, so its fill reaches the screen's edge.
|
|
30
|
+
'[--sheet-inset:max(env(safe-area-inset-bottom,0px),var(--drawer-keyboard-inset,0px))] pb-(--sheet-inset) has-data-[slot=bottom-sheet-footer]:pb-0',
|
|
31
|
+
drawerSwipeTransitionClassName,
|
|
32
|
+
// `snapPoints` on the root rest the sheet lower by `--drawer-snap-point-offset`.
|
|
33
|
+
'[transform:translateY(calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y,0px)))] data-ending-style:[transform:translateY(100%)] data-starting-style:[transform:translateY(100%)]',
|
|
34
|
+
// Fills the gap past the screen edge when a drag pulls the sheet up, in the footer's tint
|
|
35
|
+
// if it has one; opaque and 1px inside the edge, so a fractional drag leaves no seam.
|
|
36
|
+
'before:bg-popover before:pointer-events-none before:absolute before:inset-x-0 before:top-[calc(100%-1px)] before:h-12',
|
|
37
|
+
'has-data-[slot=bottom-sheet-footer]:before:bg-linear-to-b has-data-[slot=bottom-sheet-footer]:before:from-muted/72 has-data-[slot=bottom-sheet-footer]:before:to-muted/72',
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
type BottomSheetCloseProps = DrawerCloseProps;
|
|
41
|
+
type BottomSheetContentProps = React.ComponentProps<typeof DrawerPrimitive.Popup> & {
|
|
42
|
+
/** Accessible name of the close icon button. Defaults to `"Close"`. */
|
|
43
|
+
closeLabel?: string;
|
|
44
|
+
/** Renders a close icon button in the top-right corner. Defaults to `false`. */
|
|
45
|
+
showCloseButton?: boolean;
|
|
46
|
+
};
|
|
47
|
+
type BottomSheetDescriptionProps = DrawerDescriptionProps;
|
|
48
|
+
type BottomSheetFooterProps = DrawerFooterProps;
|
|
49
|
+
type BottomSheetHeaderProps = DrawerHeaderProps;
|
|
50
|
+
type BottomSheetPanelProps = DrawerPanelProps;
|
|
51
|
+
// The sheet always swipes down to close.
|
|
52
|
+
type BottomSheetProps = Omit<React.ComponentProps<typeof DrawerPrimitive.Root>, 'swipeDirection'>;
|
|
53
|
+
type BottomSheetTitleProps = DrawerTitleProps;
|
|
54
|
+
type BottomSheetTriggerProps = DrawerTriggerProps;
|
|
55
|
+
|
|
56
|
+
// Where the sheet rests: Base UI marks it expanded only at snap point 1, whatever the top one.
|
|
57
|
+
// `none` for no snap points or one, `lower` below the top one, `top` at it.
|
|
58
|
+
const SnapPointsContext = React.createContext<'lower' | 'none' | 'top'>('none');
|
|
59
|
+
|
|
60
|
+
function BottomSheetClose(props: BottomSheetCloseProps) {
|
|
61
|
+
return <Drawer.Close data-slot="bottom-sheet-close" {...props} />;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function BottomSheetContent({
|
|
65
|
+
children,
|
|
66
|
+
className,
|
|
67
|
+
closeLabel = 'Close',
|
|
68
|
+
showCloseButton = false,
|
|
69
|
+
...props
|
|
70
|
+
}: BottomSheetContentProps) {
|
|
71
|
+
const hasSnapPoints = React.useContext(SnapPointsContext) !== 'none';
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
// Inside the root and around the viewport, where it writes the keyboard inset.
|
|
75
|
+
<DrawerPrimitive.VirtualKeyboardProvider>
|
|
76
|
+
<DrawerPrimitive.Portal>
|
|
77
|
+
<DrawerBackdrop
|
|
78
|
+
// Base UI's progress hides the backdrop at a lower snap point; keep it whole.
|
|
79
|
+
className={cn(hasSnapPoints && 'opacity-100')}
|
|
80
|
+
data-slot="bottom-sheet-backdrop"
|
|
81
|
+
/>
|
|
82
|
+
<DrawerPrimitive.Viewport className={bottomSheetViewportClassName}>
|
|
83
|
+
<DrawerPrimitive.Popup
|
|
84
|
+
className={cn(
|
|
85
|
+
bottomSheetPopupClassName,
|
|
86
|
+
// Keeps the title clear of the close button.
|
|
87
|
+
showCloseButton && '**:data-[slot=bottom-sheet-header]:pr-12',
|
|
88
|
+
className,
|
|
89
|
+
)}
|
|
90
|
+
data-slot="bottom-sheet-content"
|
|
91
|
+
{...props}
|
|
92
|
+
>
|
|
93
|
+
{children}
|
|
94
|
+
<div
|
|
95
|
+
aria-hidden
|
|
96
|
+
className="bg-input absolute top-1.5 left-1/2 h-1 w-10 -translate-x-1/2 rounded-full"
|
|
97
|
+
data-slot="bottom-sheet-bar"
|
|
98
|
+
/>
|
|
99
|
+
{showCloseButton ? (
|
|
100
|
+
<DrawerCloseButton aria-label={closeLabel} data-slot="bottom-sheet-close" />
|
|
101
|
+
) : null}
|
|
102
|
+
</DrawerPrimitive.Popup>
|
|
103
|
+
</DrawerPrimitive.Viewport>
|
|
104
|
+
</DrawerPrimitive.Portal>
|
|
105
|
+
</DrawerPrimitive.VirtualKeyboardProvider>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function BottomSheetDescription(props: BottomSheetDescriptionProps) {
|
|
110
|
+
return <Drawer.Description data-slot="bottom-sheet-description" {...props} />;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* A touch swipe on the footer never closes the sheet, so its buttons take taps. At a lower
|
|
115
|
+
* snap point, it waits below the screen until the sheet rises.
|
|
116
|
+
*/
|
|
117
|
+
function BottomSheetFooter({ className, ...props }: BottomSheetFooterProps) {
|
|
118
|
+
return (
|
|
119
|
+
<Drawer.Footer
|
|
120
|
+
className={cn('pb-[calc(1rem+var(--sheet-inset))]', className)}
|
|
121
|
+
data-base-ui-swipe-ignore=""
|
|
122
|
+
data-slot="bottom-sheet-footer"
|
|
123
|
+
{...props}
|
|
124
|
+
/>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function BottomSheetHeader(props: BottomSheetHeaderProps) {
|
|
129
|
+
return <Drawer.Header data-slot="bottom-sheet-header" {...props} />;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* The scrolling body between the header and the footer. A touch swipe in it scrolls it and
|
|
134
|
+
* never closes the sheet, but with snap points, Base UI moves the sheet when it can't scroll.
|
|
135
|
+
*/
|
|
136
|
+
function BottomSheetPanel({ className, ...props }: BottomSheetPanelProps) {
|
|
137
|
+
const snapState = React.useContext(SnapPointsContext);
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<Drawer.Panel
|
|
141
|
+
className={cn(
|
|
142
|
+
'touch-pan-y',
|
|
143
|
+
// Scrolls once the sheet is at its top snap point, so a drag below it moves the sheet.
|
|
144
|
+
snapState === 'lower' && 'overflow-hidden',
|
|
145
|
+
className,
|
|
146
|
+
)}
|
|
147
|
+
data-base-ui-swipe-ignore={snapState === 'none' ? '' : undefined}
|
|
148
|
+
data-slot="bottom-sheet-panel"
|
|
149
|
+
{...props}
|
|
150
|
+
/>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** List `snapPoints` from the lowest to the highest: the Panel scrolls at the last one. */
|
|
155
|
+
function BottomSheetRoot({ onSnapPointChange, ...props }: BottomSheetProps) {
|
|
156
|
+
const { defaultSnapPoint, snapPoint, snapPoints = [] } = props;
|
|
157
|
+
const firstSnapPoint = defaultSnapPoint ?? snapPoints[0] ?? null;
|
|
158
|
+
// Mirrors Base UI's own snap point when uncontrolled, as it reads only within its parts.
|
|
159
|
+
const [restingSnapPoint, setRestingSnapPoint] =
|
|
160
|
+
React.useState<BottomSheetProps['snapPoint']>(firstSnapPoint);
|
|
161
|
+
const activeSnapPoint =
|
|
162
|
+
snapPoint !== undefined
|
|
163
|
+
? snapPoint
|
|
164
|
+
: snapPoints.some((point) => Object.is(point, restingSnapPoint))
|
|
165
|
+
? restingSnapPoint
|
|
166
|
+
: firstSnapPoint;
|
|
167
|
+
const snapState =
|
|
168
|
+
snapPoints.length < 2
|
|
169
|
+
? 'none'
|
|
170
|
+
: Object.is(activeSnapPoint, snapPoints[snapPoints.length - 1])
|
|
171
|
+
? 'top'
|
|
172
|
+
: 'lower';
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<SnapPointsContext.Provider value={snapState}>
|
|
176
|
+
<DrawerPrimitive.Root
|
|
177
|
+
onSnapPointChange={(nextSnapPoint, eventDetails) => {
|
|
178
|
+
onSnapPointChange?.(nextSnapPoint, eventDetails);
|
|
179
|
+
if (!eventDetails.isCanceled) setRestingSnapPoint(nextSnapPoint);
|
|
180
|
+
}}
|
|
181
|
+
swipeDirection="down"
|
|
182
|
+
{...props}
|
|
183
|
+
/>
|
|
184
|
+
</SnapPointsContext.Provider>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function BottomSheetTitle(props: BottomSheetTitleProps) {
|
|
189
|
+
return <Drawer.Title data-slot="bottom-sheet-title" {...props} />;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function BottomSheetTrigger(props: BottomSheetTriggerProps) {
|
|
193
|
+
return <Drawer.Trigger data-slot="bottom-sheet-trigger" {...props} />;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const BottomSheet = Object.assign(BottomSheetRoot, {
|
|
197
|
+
Close: BottomSheetClose,
|
|
198
|
+
Content: BottomSheetContent,
|
|
199
|
+
Description: BottomSheetDescription,
|
|
200
|
+
Footer: BottomSheetFooter,
|
|
201
|
+
Header: BottomSheetHeader,
|
|
202
|
+
Panel: BottomSheetPanel,
|
|
203
|
+
Title: BottomSheetTitle,
|
|
204
|
+
Trigger: BottomSheetTrigger,
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
export { BottomSheet };
|
|
208
|
+
export type {
|
|
209
|
+
BottomSheetCloseProps,
|
|
210
|
+
BottomSheetContentProps,
|
|
211
|
+
BottomSheetDescriptionProps,
|
|
212
|
+
BottomSheetFooterProps,
|
|
213
|
+
BottomSheetHeaderProps,
|
|
214
|
+
BottomSheetPanelProps,
|
|
215
|
+
BottomSheetProps,
|
|
216
|
+
BottomSheetTitleProps,
|
|
217
|
+
BottomSheetTriggerProps,
|
|
218
|
+
};
|
|
@@ -16,8 +16,9 @@ import { Button } from './Button';
|
|
|
16
16
|
const drawerMotion =
|
|
17
17
|
'duration-450 ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none';
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
// How a drawer's popup follows a drag and settles; `BottomSheet` shares it.
|
|
20
|
+
const drawerSwipeTransitionClassName = cn(
|
|
21
|
+
'transition-transform data-ending-style:duration-[calc(var(--drawer-swipe-strength,1)*400ms)] data-swiping:select-none',
|
|
21
22
|
drawerMotion,
|
|
22
23
|
);
|
|
23
24
|
|
|
@@ -30,8 +31,7 @@ const drawerEdgeFillClassName =
|
|
|
30
31
|
const drawerPopupVariants = cva(
|
|
31
32
|
cn(
|
|
32
33
|
'bg-popover text-popover-foreground relative ml-auto flex w-[calc(100%-3rem)] min-w-0 flex-col shadow-lg/5 outline-none not-dark:bg-clip-padding',
|
|
33
|
-
|
|
34
|
-
drawerMotion,
|
|
34
|
+
drawerSwipeTransitionClassName,
|
|
35
35
|
'[transform:translateX(var(--drawer-swipe-movement-x,0px))] data-ending-style:[transform:translateX(calc(100%+var(--inset,0px)))] data-starting-style:[transform:translateX(calc(100%+var(--inset,0px)))]',
|
|
36
36
|
),
|
|
37
37
|
{
|
|
@@ -61,6 +61,10 @@ const drawerPopupVariants = cva(
|
|
|
61
61
|
},
|
|
62
62
|
);
|
|
63
63
|
|
|
64
|
+
type DrawerBackdropProps = Omit<
|
|
65
|
+
React.ComponentProps<typeof DrawerPrimitive.Backdrop>,
|
|
66
|
+
'className'
|
|
67
|
+
> & { className?: string };
|
|
64
68
|
type DrawerCloseProps = React.ComponentProps<typeof DrawerPrimitive.Close>;
|
|
65
69
|
|
|
66
70
|
type DrawerContentProps = React.ComponentProps<typeof DrawerPrimitive.Popup> & {
|
|
@@ -99,10 +103,39 @@ type DrawerTitleProps = React.ComponentProps<typeof DrawerPrimitive.Title>;
|
|
|
99
103
|
type DrawerTriggerProps = React.ComponentProps<typeof DrawerPrimitive.Trigger>;
|
|
100
104
|
type DrawerVariant = NonNullable<VariantProps<typeof drawerPopupVariants>['variant']>;
|
|
101
105
|
|
|
106
|
+
/** The dimmed page behind the drawer; `BottomSheet` shares it. */
|
|
107
|
+
function DrawerBackdrop({ className, ...props }: DrawerBackdropProps) {
|
|
108
|
+
return (
|
|
109
|
+
<DrawerPrimitive.Backdrop
|
|
110
|
+
className={cn(
|
|
111
|
+
'fixed inset-0 z-50 bg-black/32 opacity-[calc(1-var(--drawer-swipe-progress,0))] backdrop-blur-sm transition-opacity data-ending-style:opacity-0 data-starting-style:opacity-0 data-swiping:duration-0',
|
|
112
|
+
drawerMotion,
|
|
113
|
+
className,
|
|
114
|
+
)}
|
|
115
|
+
data-slot="drawer-backdrop"
|
|
116
|
+
{...props}
|
|
117
|
+
/>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
102
121
|
function DrawerClose({ ...props }: DrawerCloseProps) {
|
|
103
122
|
return <DrawerPrimitive.Close data-slot="drawer-close" {...props} />;
|
|
104
123
|
}
|
|
105
124
|
|
|
125
|
+
/** The close icon button in the popup's top-right corner; `BottomSheet` shares it. */
|
|
126
|
+
function DrawerCloseButton(props: DrawerCloseProps) {
|
|
127
|
+
return (
|
|
128
|
+
<DrawerPrimitive.Close
|
|
129
|
+
className="absolute top-3 right-3"
|
|
130
|
+
data-slot="drawer-close"
|
|
131
|
+
render={<Button size="icon-sm" variant="ghost" />}
|
|
132
|
+
{...props}
|
|
133
|
+
>
|
|
134
|
+
<IconX />
|
|
135
|
+
</DrawerPrimitive.Close>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
106
139
|
function DrawerContent({
|
|
107
140
|
children,
|
|
108
141
|
className,
|
|
@@ -114,7 +147,7 @@ function DrawerContent({
|
|
|
114
147
|
}: DrawerContentProps) {
|
|
115
148
|
return (
|
|
116
149
|
<DrawerPrimitive.Portal>
|
|
117
|
-
<
|
|
150
|
+
<DrawerBackdrop />
|
|
118
151
|
<DrawerPrimitive.Viewport className={drawerViewportClassName}>
|
|
119
152
|
<DrawerPrimitive.Popup
|
|
120
153
|
className={cn(
|
|
@@ -129,16 +162,7 @@ function DrawerContent({
|
|
|
129
162
|
{...props}
|
|
130
163
|
>
|
|
131
164
|
{children}
|
|
132
|
-
{showCloseButton ?
|
|
133
|
-
<DrawerPrimitive.Close
|
|
134
|
-
aria-label={closeLabel}
|
|
135
|
-
className="absolute top-3 right-3"
|
|
136
|
-
data-slot="drawer-close"
|
|
137
|
-
render={<Button size="icon-sm" variant="ghost" />}
|
|
138
|
-
>
|
|
139
|
-
<IconX />
|
|
140
|
-
</DrawerPrimitive.Close>
|
|
141
|
-
) : null}
|
|
165
|
+
{showCloseButton ? <DrawerCloseButton aria-label={closeLabel} /> : null}
|
|
142
166
|
</DrawerPrimitive.Popup>
|
|
143
167
|
</DrawerPrimitive.Viewport>
|
|
144
168
|
</DrawerPrimitive.Portal>
|
|
@@ -223,7 +247,8 @@ const Drawer = Object.assign(DrawerRoot, {
|
|
|
223
247
|
Trigger: DrawerTrigger,
|
|
224
248
|
});
|
|
225
249
|
|
|
226
|
-
|
|
250
|
+
// The parts `BottomSheet` builds on; `entries/drawer.ts` exports only `Drawer`.
|
|
251
|
+
export { Drawer, DrawerBackdrop, DrawerCloseButton, drawerSwipeTransitionClassName };
|
|
227
252
|
export type {
|
|
228
253
|
DrawerCloseProps,
|
|
229
254
|
DrawerContentProps,
|
|
@@ -3,7 +3,7 @@ import { cva, type VariantProps } from 'class-variance-authority';
|
|
|
3
3
|
import { cn } from '../../lib/utils';
|
|
4
4
|
import { textVariants } from '../Text';
|
|
5
5
|
|
|
6
|
-
/** Shared look for `Dialog` and `
|
|
6
|
+
/** Shared look for `Dialog`, `AlertDialog` and `Drawer` (and `BottomSheet` through it); not part of the public API. */
|
|
7
7
|
|
|
8
8
|
const dialogBackdropClassName =
|
|
9
9
|
'fixed inset-0 z-50 bg-black/32 backdrop-blur-sm duration-200 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { BottomSheet } from '../components/BottomSheet';
|
|
2
|
+
export type {
|
|
3
|
+
BottomSheetCloseProps,
|
|
4
|
+
BottomSheetContentProps,
|
|
5
|
+
BottomSheetDescriptionProps,
|
|
6
|
+
BottomSheetFooterProps,
|
|
7
|
+
BottomSheetHeaderProps,
|
|
8
|
+
BottomSheetPanelProps,
|
|
9
|
+
BottomSheetProps,
|
|
10
|
+
BottomSheetTitleProps,
|
|
11
|
+
BottomSheetTriggerProps,
|
|
12
|
+
} from '../components/BottomSheet';
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './entries/alert';
|
|
|
4
4
|
export * from './entries/alert-dialog';
|
|
5
5
|
export * from './entries/avatar';
|
|
6
6
|
export * from './entries/badge';
|
|
7
|
+
export * from './entries/bottom-sheet';
|
|
7
8
|
export * from './entries/button';
|
|
8
9
|
export * from './entries/card';
|
|
9
10
|
export * from './entries/checkbox';
|