@stevederico/skateboard-ui 5.5.0 → 5.6.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 +4 -0
- package/dist/components/Sheet.d.ts +3 -0
- package/dist/components/Sheet.js +7 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,8 @@ export interface SheetProps {
|
|
|
11
11
|
title?: string;
|
|
12
12
|
minHeight?: string;
|
|
13
13
|
children?: ReactNode;
|
|
14
|
+
/** Called when the person closes the sheet (swipe, outside tap, Escape), not when code calls hide(). */
|
|
15
|
+
onUserClose?: () => void;
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* Bottom sheet (drawer) component with imperative open/close API.
|
|
@@ -21,6 +23,7 @@ export interface SheetProps {
|
|
|
21
23
|
* @param {string} [props.title=""] - Sheet header title
|
|
22
24
|
* @param {string} [props.minHeight="auto"] - Minimum sheet height CSS value
|
|
23
25
|
* @param {React.ReactNode} props.children - Sheet body content
|
|
26
|
+
* @param {Function} [props.onUserClose] - Called when the person closes the sheet, not when code calls hide()
|
|
24
27
|
* @param {React.Ref} ref - Ref exposing { show, hide, open, close, toggle }
|
|
25
28
|
* @returns {JSX.Element} Drawer sheet
|
|
26
29
|
*
|
package/dist/components/Sheet.js
CHANGED
|
@@ -10,6 +10,7 @@ import { Drawer, DrawerContent, DrawerHeader, DrawerTitle, } from "../ui/drawer.
|
|
|
10
10
|
* @param {string} [props.title=""] - Sheet header title
|
|
11
11
|
* @param {string} [props.minHeight="auto"] - Minimum sheet height CSS value
|
|
12
12
|
* @param {React.ReactNode} props.children - Sheet body content
|
|
13
|
+
* @param {Function} [props.onUserClose] - Called when the person closes the sheet, not when code calls hide()
|
|
13
14
|
* @param {React.Ref} ref - Ref exposing { show, hide, open, close, toggle }
|
|
14
15
|
* @returns {JSX.Element} Drawer sheet
|
|
15
16
|
*
|
|
@@ -30,7 +31,7 @@ import { Drawer, DrawerContent, DrawerHeader, DrawerTitle, } from "../ui/drawer.
|
|
|
30
31
|
* }
|
|
31
32
|
*/
|
|
32
33
|
const MySheet = forwardRef(function MySheet(props, ref) {
|
|
33
|
-
const { title = "", minHeight = "auto", children } = props;
|
|
34
|
+
const { title = "", minHeight = "auto", children, onUserClose } = props;
|
|
34
35
|
const [isOpen, setIsOpen] = useState(false);
|
|
35
36
|
useImperativeHandle(ref, () => ({
|
|
36
37
|
show: () => setIsOpen(true),
|
|
@@ -39,6 +40,10 @@ const MySheet = forwardRef(function MySheet(props, ref) {
|
|
|
39
40
|
close: () => setIsOpen(false),
|
|
40
41
|
toggle: () => setIsOpen(prev => !prev)
|
|
41
42
|
}));
|
|
42
|
-
return (_jsx(Drawer, { open: isOpen, onOpenChange:
|
|
43
|
+
return (_jsx(Drawer, { open: isOpen, onOpenChange: (open) => {
|
|
44
|
+
setIsOpen(open);
|
|
45
|
+
if (!open)
|
|
46
|
+
onUserClose?.();
|
|
47
|
+
}, children: _jsxs(DrawerContent, { style: { minHeight }, children: [_jsx(DrawerHeader, { children: _jsx(DrawerTitle, { children: title }) }), _jsx("div", { className: "px-4 pb-4", children: children })] }) }));
|
|
43
48
|
});
|
|
44
49
|
export default MySheet;
|