@lobehub/ui 5.24.0 → 5.25.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/es/A/index.mjs +2 -1
- package/es/A/index.mjs.map +1 -1
- package/es/Accordion/AccordionItem.mjs +0 -1
- package/es/Accordion/AccordionItem.mjs.map +1 -1
- package/es/ActionIcon/components/utils.mjs +7 -9
- package/es/ActionIcon/components/utils.mjs.map +1 -1
- package/es/Checkbox/CheckboxGroup.mjs +4 -2
- package/es/Checkbox/CheckboxGroup.mjs.map +1 -1
- package/es/CodeDiff/CodeDiff.mjs +20 -18
- package/es/CodeDiff/CodeDiff.mjs.map +1 -1
- package/es/CodeDiff/PatchDiff.mjs +18 -16
- package/es/CodeDiff/PatchDiff.mjs.map +1 -1
- package/es/CopyButton/CopyButton.mjs +2 -1
- package/es/CopyButton/CopyButton.mjs.map +1 -1
- package/es/Highlighter/LangSelect.mjs +41 -40
- package/es/Highlighter/LangSelect.mjs.map +1 -1
- package/es/Highlighter/SyntaxHighlighter/StaticRenderer.mjs +2 -1
- package/es/Highlighter/SyntaxHighlighter/StaticRenderer.mjs.map +1 -1
- package/es/HotkeyInput/HotkeyInput.mjs +3 -1
- package/es/HotkeyInput/HotkeyInput.mjs.map +1 -1
- package/es/HtmlPreview/const.mjs +1 -1
- package/es/HtmlPreview/const.mjs.map +1 -1
- package/es/Icon/components/utils.mjs +7 -9
- package/es/Icon/components/utils.mjs.map +1 -1
- package/es/Image/components/Toolbar.mjs +2 -1
- package/es/Image/components/Toolbar.mjs.map +1 -1
- package/es/Img/index.mjs +2 -1
- package/es/Img/index.mjs.map +1 -1
- package/es/Markdown/SyntaxMarkdown/StreamdownRender.mjs +2 -1
- package/es/Markdown/SyntaxMarkdown/StreamdownRender.mjs.map +1 -1
- package/es/Markdown/SyntaxMarkdown/useSmoothStreamContent.mjs +2 -2
- package/es/Markdown/SyntaxMarkdown/useSmoothStreamContent.mjs.map +1 -1
- package/es/Modal/RawModalStackItem.mjs +6 -5
- package/es/Modal/RawModalStackItem.mjs.map +1 -1
- package/es/Modal/imperative.mjs +4 -2
- package/es/Modal/imperative.mjs.map +1 -1
- package/es/NeuralNetworkLoading/NeuralNetworkLoading.mjs +1 -1
- package/es/NeuralNetworkLoading/NeuralNetworkLoading.mjs.map +1 -1
- package/es/ScrollShadow/ScrollShadow.mjs +13 -12
- package/es/ScrollShadow/ScrollShadow.mjs.map +1 -1
- package/es/Skeleton/SkeletonButton.mjs +2 -1
- package/es/Skeleton/SkeletonButton.mjs.map +1 -1
- package/es/SortableList/SortableList.mjs +5 -1
- package/es/SortableList/SortableList.mjs.map +1 -1
- package/es/Text/Text.mjs +22 -21
- package/es/Text/Text.mjs.map +1 -1
- package/es/ThemeProvider/ThemeProvider.mjs +3 -2
- package/es/ThemeProvider/ThemeProvider.mjs.map +1 -1
- package/es/awesome/GradientButton/GradientButton.mjs +1 -3
- package/es/awesome/GradientButton/GradientButton.mjs.map +1 -1
- package/es/awesome/Spotlight/Spotlight.mjs +2 -1
- package/es/awesome/Spotlight/Spotlight.mjs.map +1 -1
- package/es/base-ui/Button/Button.mjs +13 -11
- package/es/base-ui/Button/Button.mjs.map +1 -1
- package/es/base-ui/Button/SplitButton.mjs +2 -1
- package/es/base-ui/Button/SplitButton.mjs.map +1 -1
- package/es/base-ui/ContextMenu/ContextMenuTrigger.mjs +2 -1
- package/es/base-ui/ContextMenu/ContextMenuTrigger.mjs.map +1 -1
- package/es/base-ui/ContextMenu/renderItems.mjs +2 -1
- package/es/base-ui/ContextMenu/renderItems.mjs.map +1 -1
- package/es/base-ui/Drawer/Drawer.d.mts +6 -0
- package/es/base-ui/Drawer/Drawer.mjs +152 -0
- package/es/base-ui/Drawer/Drawer.mjs.map +1 -0
- package/es/base-ui/Drawer/DrawerLayerContext.mjs +10 -0
- package/es/base-ui/Drawer/DrawerLayerContext.mjs.map +1 -0
- package/es/base-ui/Drawer/DrawerPushContext.mjs +27 -0
- package/es/base-ui/Drawer/DrawerPushContext.mjs.map +1 -0
- package/es/base-ui/Drawer/atoms.d.mts +58 -0
- package/es/base-ui/Drawer/atoms.mjs +262 -0
- package/es/base-ui/Drawer/atoms.mjs.map +1 -0
- package/es/base-ui/Drawer/constants.d.mts +17 -0
- package/es/base-ui/Drawer/constants.mjs +72 -0
- package/es/base-ui/Drawer/constants.mjs.map +1 -0
- package/es/base-ui/Drawer/index.d.mts +5 -0
- package/es/base-ui/Drawer/style.mjs +295 -0
- package/es/base-ui/Drawer/style.mjs.map +1 -0
- package/es/base-ui/Drawer/type.d.mts +65 -0
- package/es/base-ui/DropdownMenu/DropdownMenu.mjs +2 -1
- package/es/base-ui/DropdownMenu/DropdownMenu.mjs.map +1 -1
- package/es/base-ui/DropdownMenu/atoms.mjs +2 -1
- package/es/base-ui/DropdownMenu/atoms.mjs.map +1 -1
- package/es/base-ui/DropdownMenu/renderItems.mjs +2 -1
- package/es/base-ui/DropdownMenu/renderItems.mjs.map +1 -1
- package/es/base-ui/FloatingSheet/FloatingSheet.mjs +4 -1
- package/es/base-ui/FloatingSheet/FloatingSheet.mjs.map +1 -1
- package/es/base-ui/Input/style.d.mts +1 -1
- package/es/base-ui/Modal/atoms.mjs +7 -5
- package/es/base-ui/Modal/atoms.mjs.map +1 -1
- package/es/base-ui/Modal/imperative.mjs +2 -1
- package/es/base-ui/Modal/imperative.mjs.map +1 -1
- package/es/base-ui/Popover/atoms.mjs +2 -1
- package/es/base-ui/Popover/atoms.mjs.map +1 -1
- package/es/base-ui/Popover/context.mjs +4 -2
- package/es/base-ui/Popover/context.mjs.map +1 -1
- package/es/base-ui/Select/atoms.mjs +2 -1
- package/es/base-ui/Select/atoms.mjs.map +1 -1
- package/es/base-ui/index.d.mts +6 -1
- package/es/base-ui/index.mjs +4 -1
- package/es/brand/LobeChat/index.mjs +0 -1
- package/es/brand/LobeChat/index.mjs.map +1 -1
- package/es/brand/LobeHub/index.mjs +0 -1
- package/es/brand/LobeHub/index.mjs.map +1 -1
- package/es/brand/Logo3d/index.mjs +2 -1
- package/es/brand/Logo3d/index.mjs.map +1 -1
- package/es/chat/ChatItem/components/Actions.mjs +5 -4
- package/es/chat/ChatItem/components/Actions.mjs.map +1 -1
- package/es/chat/ChatList/ChatList.mjs +2 -1
- package/es/chat/ChatList/ChatList.mjs.map +1 -1
- package/es/color/ColorScales/ScaleRow.mjs +0 -2
- package/es/color/ColorScales/ScaleRow.mjs.map +1 -1
- package/es/hooks/useMermaid.mjs +2 -1
- package/es/hooks/useMermaid.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { DEFAULT_CONTAINER_MAX_WIDTH } from "./constants.mjs";
|
|
3
|
+
import { styles } from "./style.mjs";
|
|
4
|
+
import { DrawerBackdrop, DrawerContent, DrawerFooter, DrawerHeader, DrawerPopup, DrawerPortal, DrawerRoot, DrawerTitle } from "./atoms.mjs";
|
|
5
|
+
import { DrawerPushProvider, useDrawerPush } from "./DrawerPushContext.mjs";
|
|
6
|
+
import { memo, useCallback, useMemo } from "react";
|
|
7
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { cx } from "antd-style";
|
|
9
|
+
import { X } from "lucide-react";
|
|
10
|
+
//#region src/base-ui/Drawer/Drawer.tsx
|
|
11
|
+
const resolvePushDistance = (push) => {
|
|
12
|
+
if (push === false) return 0;
|
|
13
|
+
if (push === true) return 180;
|
|
14
|
+
return push.distance ?? 180;
|
|
15
|
+
};
|
|
16
|
+
const FULL_SIZES = /* @__PURE__ */ new Set([
|
|
17
|
+
"100%",
|
|
18
|
+
"100dvh",
|
|
19
|
+
"100dvw",
|
|
20
|
+
"100vh",
|
|
21
|
+
"100vw"
|
|
22
|
+
]);
|
|
23
|
+
const Drawer = memo(({ open, placement = "right", width, height, mask = true, maskClosable = true, keyboard = true, closable = true, closeIcon, extra, title, footer, noHeader, sidebar, sidebarWidth = 280, containerMaxWidth = DEFAULT_CONTAINER_MAX_WIDTH, push = true, zIndex, getContainer, className, classNames, style, styles: semanticStyles, afterOpenChange, onClose, children }) => {
|
|
24
|
+
const isOpen = open ?? false;
|
|
25
|
+
const { childValue, pushed } = useDrawerPush(isOpen);
|
|
26
|
+
const pushOffset = pushed ? resolvePushDistance(push) : 0;
|
|
27
|
+
const handleOpenChange = useCallback((nextOpen, eventDetails) => {
|
|
28
|
+
if (nextOpen || !isOpen) return;
|
|
29
|
+
if (!keyboard && eventDetails.reason === "escape-key") return;
|
|
30
|
+
if (!maskClosable && eventDetails.reason === "outside-press") return;
|
|
31
|
+
onClose?.();
|
|
32
|
+
}, [
|
|
33
|
+
isOpen,
|
|
34
|
+
keyboard,
|
|
35
|
+
maskClosable,
|
|
36
|
+
onClose
|
|
37
|
+
]);
|
|
38
|
+
const handleExitComplete = useCallback(() => afterOpenChange?.(false), [afterOpenChange]);
|
|
39
|
+
const handleAnimationComplete = useCallback(() => {
|
|
40
|
+
if (isOpen) afterOpenChange?.(true);
|
|
41
|
+
}, [isOpen, afterOpenChange]);
|
|
42
|
+
const isHorizontal = placement === "left" || placement === "right";
|
|
43
|
+
const resolvedWidth = isHorizontal ? width ?? 378 : width;
|
|
44
|
+
const resolvedHeight = isHorizontal ? height : height ?? 378;
|
|
45
|
+
const isFlush = FULL_SIZES.has(String(isHorizontal ? resolvedWidth : resolvedHeight));
|
|
46
|
+
const surfaceWeightClass = (() => {
|
|
47
|
+
if (isFlush) return void 0;
|
|
48
|
+
if (pushed) return styles.panelRecessed;
|
|
49
|
+
return mask ? void 0 : styles.panelBoosted;
|
|
50
|
+
})();
|
|
51
|
+
const showTitle = title !== void 0 && title !== null;
|
|
52
|
+
const showHeader = !noHeader && (showTitle || closable || !!extra);
|
|
53
|
+
const hasSidebar = !!sidebar;
|
|
54
|
+
const containerStyle = useMemo(() => ({ maxWidth: containerMaxWidth }), [containerMaxWidth]);
|
|
55
|
+
const closeNode = closable && /* @__PURE__ */ jsx("button", {
|
|
56
|
+
"aria-label": "Close",
|
|
57
|
+
className: cx(styles.close, classNames?.close),
|
|
58
|
+
style: semanticStyles?.close,
|
|
59
|
+
type: "button",
|
|
60
|
+
onClick: onClose,
|
|
61
|
+
children: closeIcon ?? /* @__PURE__ */ jsx(X, { size: 16 })
|
|
62
|
+
});
|
|
63
|
+
const extraNode = (extra || closeNode) && /* @__PURE__ */ jsxs("div", {
|
|
64
|
+
className: cx(styles.extra, !showHeader && styles.extraFloating, classNames?.extra),
|
|
65
|
+
style: semanticStyles?.extra,
|
|
66
|
+
children: [extra, closeNode]
|
|
67
|
+
});
|
|
68
|
+
const bodyNode = hasSidebar ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
|
|
69
|
+
className: cx(styles.sidebar, classNames?.sidebar),
|
|
70
|
+
style: {
|
|
71
|
+
width: sidebarWidth,
|
|
72
|
+
...semanticStyles?.sidebar
|
|
73
|
+
},
|
|
74
|
+
children: sidebar
|
|
75
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
76
|
+
className: cx(styles.sidebarContent, classNames?.sidebarContent),
|
|
77
|
+
style: semanticStyles?.sidebarContent,
|
|
78
|
+
children
|
|
79
|
+
})] }) : children;
|
|
80
|
+
return /* @__PURE__ */ jsx(DrawerRoot, {
|
|
81
|
+
modal: mask,
|
|
82
|
+
open: isOpen,
|
|
83
|
+
zIndex,
|
|
84
|
+
onExitComplete: handleExitComplete,
|
|
85
|
+
onOpenChange: handleOpenChange,
|
|
86
|
+
children: /* @__PURE__ */ jsxs(DrawerPortal, {
|
|
87
|
+
container: getContainer === false ? void 0 : getContainer ?? void 0,
|
|
88
|
+
children: [mask && /* @__PURE__ */ jsx(DrawerBackdrop, {
|
|
89
|
+
className: classNames?.backdrop,
|
|
90
|
+
style: semanticStyles?.backdrop
|
|
91
|
+
}), /* @__PURE__ */ jsx(DrawerPopup, {
|
|
92
|
+
className: classNames?.popup,
|
|
93
|
+
flush: isFlush,
|
|
94
|
+
height: resolvedHeight,
|
|
95
|
+
motionProps: { onAnimationComplete: handleAnimationComplete },
|
|
96
|
+
panelClassName: cx(surfaceWeightClass, className, classNames?.panel),
|
|
97
|
+
panelStyle: {
|
|
98
|
+
...style,
|
|
99
|
+
...semanticStyles?.panel
|
|
100
|
+
},
|
|
101
|
+
placement,
|
|
102
|
+
popupStyle: semanticStyles?.popup,
|
|
103
|
+
pushOffset,
|
|
104
|
+
width: resolvedWidth,
|
|
105
|
+
children: /* @__PURE__ */ jsxs(DrawerPushProvider, {
|
|
106
|
+
value: childValue,
|
|
107
|
+
children: [
|
|
108
|
+
showHeader ? /* @__PURE__ */ jsx(DrawerHeader, {
|
|
109
|
+
className: classNames?.header,
|
|
110
|
+
style: semanticStyles?.header,
|
|
111
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
112
|
+
className: styles.containerInner,
|
|
113
|
+
style: containerStyle,
|
|
114
|
+
children: [showTitle ? /* @__PURE__ */ jsx(DrawerTitle, {
|
|
115
|
+
className: classNames?.title,
|
|
116
|
+
style: semanticStyles?.title,
|
|
117
|
+
children: title
|
|
118
|
+
}) : /* @__PURE__ */ jsx("span", {}), extraNode]
|
|
119
|
+
})
|
|
120
|
+
}) : extraNode,
|
|
121
|
+
/* @__PURE__ */ jsx(DrawerContent, {
|
|
122
|
+
className: cx(hasSidebar && styles.contentSidebar, classNames?.content),
|
|
123
|
+
style: semanticStyles?.content,
|
|
124
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
125
|
+
style: {
|
|
126
|
+
...containerStyle,
|
|
127
|
+
...semanticStyles?.bodyContent
|
|
128
|
+
},
|
|
129
|
+
className: cx(styles.bodyContent, hasSidebar && styles.bodyContentSidebar, classNames?.bodyContent),
|
|
130
|
+
children: bodyNode
|
|
131
|
+
})
|
|
132
|
+
}),
|
|
133
|
+
footer && /* @__PURE__ */ jsx(DrawerFooter, {
|
|
134
|
+
className: classNames?.footer,
|
|
135
|
+
style: semanticStyles?.footer,
|
|
136
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
137
|
+
className: cx(styles.containerInner, styles.containerInnerFooter),
|
|
138
|
+
style: containerStyle,
|
|
139
|
+
children: footer
|
|
140
|
+
})
|
|
141
|
+
})
|
|
142
|
+
]
|
|
143
|
+
})
|
|
144
|
+
})]
|
|
145
|
+
})
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
Drawer.displayName = "Drawer";
|
|
149
|
+
//#endregion
|
|
150
|
+
export { Drawer as default };
|
|
151
|
+
|
|
152
|
+
//# sourceMappingURL=Drawer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.mjs","names":[],"sources":["../../../src/base-ui/Drawer/Drawer.tsx"],"sourcesContent":["'use client';\n\nimport { cx } from 'antd-style';\nimport { X } from 'lucide-react';\nimport type { CSSProperties } from 'react';\nimport { memo, useCallback, useMemo } from 'react';\n\nimport {\n DrawerBackdrop,\n DrawerContent,\n DrawerFooter,\n DrawerHeader,\n DrawerPopup,\n DrawerPortal,\n DrawerRoot,\n type DrawerRootProps,\n DrawerTitle,\n} from './atoms';\nimport {\n DEFAULT_CONTAINER_MAX_WIDTH,\n DEFAULT_DRAWER_HEIGHT,\n DEFAULT_DRAWER_WIDTH,\n DEFAULT_PUSH_DISTANCE,\n DEFAULT_SIDEBAR_WIDTH,\n} from './constants';\nimport { DrawerPushProvider, useDrawerPush } from './DrawerPushContext';\nimport { styles } from './style';\nimport type { DrawerProps, DrawerPush } from './type';\n\nconst resolvePushDistance = (push: DrawerPush) => {\n if (push === false) return 0;\n if (push === true) return DEFAULT_PUSH_DISTANCE;\n return push.distance ?? DEFAULT_PUSH_DISTANCE;\n};\n\nconst FULL_SIZES = new Set(['100%', '100dvh', '100dvw', '100vh', '100vw']);\n\nconst Drawer = memo<DrawerProps>(\n ({\n open,\n placement = 'right',\n width,\n height,\n mask = true,\n maskClosable = true,\n keyboard = true,\n closable = true,\n closeIcon,\n extra,\n title,\n footer,\n noHeader,\n sidebar,\n sidebarWidth = DEFAULT_SIDEBAR_WIDTH,\n containerMaxWidth = DEFAULT_CONTAINER_MAX_WIDTH,\n push = true,\n zIndex,\n getContainer,\n className,\n classNames,\n style,\n styles: semanticStyles,\n afterOpenChange,\n onClose,\n children,\n }) => {\n const isOpen = open ?? false;\n const { childValue, pushed } = useDrawerPush(isOpen);\n const pushOffset = pushed ? resolvePushDistance(push) : 0;\n\n const handleOpenChange = useCallback<NonNullable<DrawerRootProps['onOpenChange']>>(\n (nextOpen, eventDetails) => {\n if (nextOpen || !isOpen) return;\n if (!keyboard && eventDetails.reason === 'escape-key') return;\n if (!maskClosable && eventDetails.reason === 'outside-press') return;\n onClose?.();\n },\n [isOpen, keyboard, maskClosable, onClose],\n );\n\n const handleExitComplete = useCallback(() => afterOpenChange?.(false), [afterOpenChange]);\n const handleAnimationComplete = useCallback(() => {\n if (isOpen) afterOpenChange?.(true);\n }, [isOpen, afterOpenChange]);\n\n const isHorizontal = placement === 'left' || placement === 'right';\n const resolvedWidth = isHorizontal ? (width ?? DEFAULT_DRAWER_WIDTH) : width;\n const resolvedHeight = isHorizontal ? height : (height ?? DEFAULT_DRAWER_HEIGHT);\n\n const isFlush = FULL_SIZES.has(String(isHorizontal ? resolvedWidth : resolvedHeight));\n const surfaceWeightClass = (() => {\n if (isFlush) return undefined;\n if (pushed) return styles.panelRecessed;\n return mask ? undefined : styles.panelBoosted;\n })();\n\n const showTitle = title !== undefined && title !== null;\n const showHeader = !noHeader && (showTitle || closable || !!extra);\n const hasSidebar = !!sidebar;\n\n const containerStyle = useMemo<CSSProperties>(\n () => ({ maxWidth: containerMaxWidth }),\n [containerMaxWidth],\n );\n\n const closeNode = closable && (\n <button\n aria-label=\"Close\"\n className={cx(styles.close, classNames?.close)}\n style={semanticStyles?.close}\n type=\"button\"\n onClick={onClose}\n >\n {closeIcon ?? <X size={16} />}\n </button>\n );\n\n const extraNode = (extra || closeNode) && (\n <div\n className={cx(styles.extra, !showHeader && styles.extraFloating, classNames?.extra)}\n style={semanticStyles?.extra}\n >\n {extra}\n {closeNode}\n </div>\n );\n\n const bodyNode = hasSidebar ? (\n <>\n <div\n className={cx(styles.sidebar, classNames?.sidebar)}\n style={{ width: sidebarWidth, ...semanticStyles?.sidebar }}\n >\n {sidebar}\n </div>\n <div\n className={cx(styles.sidebarContent, classNames?.sidebarContent)}\n style={semanticStyles?.sidebarContent}\n >\n {children}\n </div>\n </>\n ) : (\n children\n );\n\n const container = getContainer === false ? undefined : (getContainer ?? undefined);\n\n return (\n <DrawerRoot\n modal={mask}\n open={isOpen}\n zIndex={zIndex}\n onExitComplete={handleExitComplete}\n onOpenChange={handleOpenChange}\n >\n <DrawerPortal container={container}>\n {mask && (\n <DrawerBackdrop className={classNames?.backdrop} style={semanticStyles?.backdrop} />\n )}\n <DrawerPopup\n className={classNames?.popup}\n flush={isFlush}\n height={resolvedHeight}\n motionProps={{ onAnimationComplete: handleAnimationComplete }}\n panelClassName={cx(surfaceWeightClass, className, classNames?.panel)}\n panelStyle={{ ...style, ...semanticStyles?.panel }}\n placement={placement}\n popupStyle={semanticStyles?.popup}\n pushOffset={pushOffset}\n width={resolvedWidth}\n >\n <DrawerPushProvider value={childValue}>\n {showHeader ? (\n <DrawerHeader className={classNames?.header} style={semanticStyles?.header}>\n <div className={styles.containerInner} style={containerStyle}>\n {showTitle ? (\n <DrawerTitle className={classNames?.title} style={semanticStyles?.title}>\n {title}\n </DrawerTitle>\n ) : (\n <span />\n )}\n {extraNode}\n </div>\n </DrawerHeader>\n ) : (\n extraNode\n )}\n <DrawerContent\n className={cx(hasSidebar && styles.contentSidebar, classNames?.content)}\n style={semanticStyles?.content}\n >\n <div\n style={{ ...containerStyle, ...semanticStyles?.bodyContent }}\n className={cx(\n styles.bodyContent,\n hasSidebar && styles.bodyContentSidebar,\n classNames?.bodyContent,\n )}\n >\n {bodyNode}\n </div>\n </DrawerContent>\n {footer && (\n <DrawerFooter className={classNames?.footer} style={semanticStyles?.footer}>\n <div\n className={cx(styles.containerInner, styles.containerInnerFooter)}\n style={containerStyle}\n >\n {footer}\n </div>\n </DrawerFooter>\n )}\n </DrawerPushProvider>\n </DrawerPopup>\n </DrawerPortal>\n </DrawerRoot>\n );\n },\n);\n\nDrawer.displayName = 'Drawer';\n\nexport default Drawer;\n"],"mappings":";;;;;;;;;;AA6BA,MAAM,uBAAuB,SAAqB;CAChD,IAAI,SAAS,OAAO,OAAO;CAC3B,IAAI,SAAS,MAAM,OAAA;CACnB,OAAO,KAAK,YAAA;AACd;AAEA,MAAM,6BAAa,IAAI,IAAI;CAAC;CAAQ;CAAU;CAAU;CAAS;AAAO,CAAC;AAEzE,MAAM,SAAS,MACZ,EACC,MACA,YAAY,SACZ,OACA,QACA,OAAO,MACP,eAAe,MACf,WAAW,MACX,WAAW,MACX,WACA,OACA,OACA,QACA,UACA,SACA,eAAA,KACA,oBAAoB,6BACpB,OAAO,MACP,QACA,cACA,WACA,YACA,OACA,QAAQ,gBACR,iBACA,SACA,eACI;CACJ,MAAM,SAAS,QAAQ;CACvB,MAAM,EAAE,YAAY,WAAW,cAAc,MAAM;CACnD,MAAM,aAAa,SAAS,oBAAoB,IAAI,IAAI;CAExD,MAAM,mBAAmB,aACtB,UAAU,iBAAiB;EAC1B,IAAI,YAAY,CAAC,QAAQ;EACzB,IAAI,CAAC,YAAY,aAAa,WAAW,cAAc;EACvD,IAAI,CAAC,gBAAgB,aAAa,WAAW,iBAAiB;EAC9D,UAAU;CACZ,GACA;EAAC;EAAQ;EAAU;EAAc;CAAO,CAC1C;CAEA,MAAM,qBAAqB,kBAAkB,kBAAkB,KAAK,GAAG,CAAC,eAAe,CAAC;CACxF,MAAM,0BAA0B,kBAAkB;EAChD,IAAI,QAAQ,kBAAkB,IAAI;CACpC,GAAG,CAAC,QAAQ,eAAe,CAAC;CAE5B,MAAM,eAAe,cAAc,UAAU,cAAc;CAC3D,MAAM,gBAAgB,eAAgB,SAAA,MAAiC;CACvE,MAAM,iBAAiB,eAAe,SAAU,UAAA;CAE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//#region src/base-ui/Drawer/DrawerLayerContext.tsx
|
|
4
|
+
const DrawerLayerContext = createContext(null);
|
|
5
|
+
const useDrawerLayer = () => use(DrawerLayerContext);
|
|
6
|
+
const DrawerLayerProvider = DrawerLayerContext.Provider;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { DrawerLayerProvider, useDrawerLayer };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=DrawerLayerContext.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawerLayerContext.mjs","names":[],"sources":["../../../src/base-ui/Drawer/DrawerLayerContext.tsx"],"sourcesContent":["'use client';\n\nimport { createContext, use } from 'react';\n\nexport interface DrawerLayer {\n popupRef: (node: HTMLElement | null) => void;\n zIndex: number | undefined;\n}\n\nconst DrawerLayerContext = createContext<DrawerLayer | null>(null);\n\nexport const useDrawerLayer = () => use(DrawerLayerContext);\nexport const DrawerLayerProvider = DrawerLayerContext.Provider;\n"],"mappings":";;;AASA,MAAM,qBAAqB,cAAkC,IAAI;AAEjE,MAAa,uBAAuB,IAAI,kBAAkB;AAC1D,MAAa,sBAAsB,mBAAmB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, use, useCallback, useEffect, useMemo, useState } from "react";
|
|
3
|
+
//#region src/base-ui/Drawer/DrawerPushContext.tsx
|
|
4
|
+
const DrawerPushContext = createContext(null);
|
|
5
|
+
const DrawerPushProvider = DrawerPushContext.Provider;
|
|
6
|
+
const useDrawerPush = (open) => {
|
|
7
|
+
const parent = use(DrawerPushContext);
|
|
8
|
+
const [pushedCount, setPushedCount] = useState(0);
|
|
9
|
+
const push = useCallback(() => setPushedCount((count) => count + 1), []);
|
|
10
|
+
const pull = useCallback(() => setPushedCount((count) => Math.max(0, count - 1)), []);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!open || !parent) return;
|
|
13
|
+
parent.push();
|
|
14
|
+
return () => parent.pull();
|
|
15
|
+
}, [open, parent]);
|
|
16
|
+
return {
|
|
17
|
+
childValue: useMemo(() => ({
|
|
18
|
+
pull,
|
|
19
|
+
push
|
|
20
|
+
}), [pull, push]),
|
|
21
|
+
pushed: pushedCount > 0
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { DrawerPushProvider, useDrawerPush };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=DrawerPushContext.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawerPushContext.mjs","names":[],"sources":["../../../src/base-ui/Drawer/DrawerPushContext.tsx"],"sourcesContent":["'use client';\n\nimport { createContext, use, useCallback, useEffect, useMemo, useState } from 'react';\n\nexport interface DrawerPushParent {\n pull: () => void;\n push: () => void;\n}\n\nconst DrawerPushContext = createContext<DrawerPushParent | null>(null);\n\nexport const DrawerPushProvider = DrawerPushContext.Provider;\n\nexport const useDrawerPush = (open: boolean) => {\n const parent = use(DrawerPushContext);\n const [pushedCount, setPushedCount] = useState(0);\n\n const push = useCallback(() => setPushedCount((count) => count + 1), []);\n const pull = useCallback(() => setPushedCount((count) => Math.max(0, count - 1)), []);\n\n useEffect(() => {\n if (!open || !parent) return;\n parent.push();\n return () => parent.pull();\n }, [open, parent]);\n\n const childValue = useMemo<DrawerPushParent>(() => ({ pull, push }), [pull, push]);\n\n return { childValue, pushed: pushedCount > 0 };\n};\n"],"mappings":";;;AASA,MAAM,oBAAoB,cAAuC,IAAI;AAErE,MAAa,qBAAqB,kBAAkB;AAEpD,MAAa,iBAAiB,SAAkB;CAC9C,MAAM,SAAS,IAAI,iBAAiB;CACpC,MAAM,CAAC,aAAa,kBAAkB,SAAS,CAAC;CAEhD,MAAM,OAAO,kBAAkB,gBAAgB,UAAU,QAAQ,CAAC,GAAG,CAAC,CAAC;CACvE,MAAM,OAAO,kBAAkB,gBAAgB,UAAU,KAAK,IAAI,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC;CAEpF,gBAAgB;EACd,IAAI,CAAC,QAAQ,CAAC,QAAQ;EACtB,OAAO,KAAK;EACZ,aAAa,OAAO,KAAK;CAC3B,GAAG,CAAC,MAAM,MAAM,CAAC;CAIjB,OAAO;EAAE,YAFU,eAAiC;GAAE;GAAM;EAAK,IAAI,CAAC,MAAM,IAAI,CAE9D;EAAG,QAAQ,cAAc;CAAE;AAC/C"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { DrawerPlacement } from "./type.mjs";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
4
|
+
//#region src/base-ui/Drawer/atoms.d.ts
|
|
5
|
+
interface DrawerAnimationActions {
|
|
6
|
+
onExitComplete: () => void;
|
|
7
|
+
}
|
|
8
|
+
declare const useDrawerOpen: () => boolean | null;
|
|
9
|
+
declare const useDrawerActions: () => DrawerAnimationActions | null;
|
|
10
|
+
type DrawerRootProps = Dialog.Root.Props & {
|
|
11
|
+
onExitComplete?: () => void;
|
|
12
|
+
zIndex?: number;
|
|
13
|
+
};
|
|
14
|
+
declare const DrawerRoot: ({ open, onExitComplete, ...rest }: DrawerRootProps) => React.JSX.Element;
|
|
15
|
+
type DrawerPortalProps = React.ComponentProps<typeof Dialog.Portal> & {
|
|
16
|
+
container?: HTMLElement | null;
|
|
17
|
+
};
|
|
18
|
+
declare const DrawerPortal: ({ container, ...rest }: DrawerPortalProps) => React.JSX.Element;
|
|
19
|
+
type DrawerBackdropProps = React.ComponentProps<typeof Dialog.Backdrop>;
|
|
20
|
+
declare const DrawerBackdrop: ({ className, style, ...rest }: DrawerBackdropProps) => React.JSX.Element;
|
|
21
|
+
type DrawerPopupProps = React.ComponentProps<typeof Dialog.Popup> & {
|
|
22
|
+
flush?: boolean;
|
|
23
|
+
height?: number | string;
|
|
24
|
+
motionProps?: Record<string, any>;
|
|
25
|
+
panelClassName?: string;
|
|
26
|
+
panelStyle?: React.CSSProperties;
|
|
27
|
+
placement?: DrawerPlacement;
|
|
28
|
+
popupStyle?: React.CSSProperties;
|
|
29
|
+
pushOffset?: number;
|
|
30
|
+
width?: number | string;
|
|
31
|
+
};
|
|
32
|
+
declare const DrawerPopup: ({ className, children, placement: placementProp, width: widthProp, height: heightProp, flush, pushOffset, motionProps, panelClassName, panelStyle, popupStyle, ref: forwardedRef, ...rest }: DrawerPopupProps) => React.JSX.Element;
|
|
33
|
+
type DrawerHeaderProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
34
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
35
|
+
};
|
|
36
|
+
declare const DrawerHeader: ({ className, ...rest }: DrawerHeaderProps) => React.JSX.Element;
|
|
37
|
+
type DrawerTitleProps = React.ComponentProps<typeof Dialog.Title>;
|
|
38
|
+
declare const DrawerTitle: ({ className, ...rest }: DrawerTitleProps) => React.JSX.Element;
|
|
39
|
+
type DrawerDescriptionProps = React.ComponentProps<typeof Dialog.Description>;
|
|
40
|
+
declare const DrawerDescription: React.FC<DrawerDescriptionProps>;
|
|
41
|
+
type DrawerContentProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
42
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
43
|
+
};
|
|
44
|
+
declare const DrawerContent: ({ className, ...rest }: DrawerContentProps) => React.JSX.Element;
|
|
45
|
+
type DrawerFooterProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
46
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
47
|
+
};
|
|
48
|
+
declare const DrawerFooter: ({ className, ...rest }: DrawerFooterProps) => React.JSX.Element;
|
|
49
|
+
type DrawerCloseProps = React.ComponentProps<typeof Dialog.Close>;
|
|
50
|
+
declare const DrawerClose: ({ className, children, ...rest }: DrawerCloseProps) => React.JSX.Element;
|
|
51
|
+
type DrawerTriggerProps = Omit<React.ComponentPropsWithRef<typeof Dialog.Trigger>, 'children' | 'render'> & {
|
|
52
|
+
children?: React.ReactNode;
|
|
53
|
+
nativeButton?: boolean;
|
|
54
|
+
};
|
|
55
|
+
declare const DrawerTrigger: ({ children, className, nativeButton, ref: refProp, ...rest }: DrawerTriggerProps) => React.JSX.Element;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { DrawerBackdrop, DrawerBackdropProps, DrawerClose, DrawerCloseProps, DrawerContent, DrawerContentProps, DrawerDescription, DrawerDescriptionProps, DrawerFooter, DrawerFooterProps, DrawerHeader, DrawerHeaderProps, DrawerPopup, DrawerPopupProps, DrawerPortal, DrawerPortalProps, DrawerRoot, DrawerRootProps, DrawerTitle, DrawerTitleProps, DrawerTrigger, DrawerTriggerProps, useDrawerActions, useDrawerOpen };
|
|
58
|
+
//# sourceMappingURL=atoms.d.mts.map
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMotionComponent } from "../../MotionProvider/index.mjs";
|
|
3
|
+
import { useNativeButton } from "../../hooks/useNativeButton.mjs";
|
|
4
|
+
import { useAppElement } from "../../ThemeProvider/AppElementContext.mjs";
|
|
5
|
+
import { useLayerZIndex } from "../zIndex/useLayerZIndex.mjs";
|
|
6
|
+
import { drawerBackdropTransition, getDrawerMotionConfig, pushAxis } from "./constants.mjs";
|
|
7
|
+
import { DrawerLayerProvider, useDrawerLayer } from "./DrawerLayerContext.mjs";
|
|
8
|
+
import { styles } from "./style.mjs";
|
|
9
|
+
import { cloneElement, createContext, createElement, isValidElement, use, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
import { cx } from "antd-style";
|
|
12
|
+
import { AnimatePresence } from "motion/react";
|
|
13
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
14
|
+
import { mergeRefs, useMergeRefs } from "react-merge-refs";
|
|
15
|
+
import { X } from "lucide-react";
|
|
16
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
17
|
+
//#region src/base-ui/Drawer/atoms.tsx
|
|
18
|
+
const mergeStateClassName = (base, className) => {
|
|
19
|
+
if (typeof className === "function") return (state) => cx(base, className(state));
|
|
20
|
+
return cx(base, className);
|
|
21
|
+
};
|
|
22
|
+
const popupPlacementClass = {
|
|
23
|
+
bottom: styles.popupBottom,
|
|
24
|
+
left: styles.popupLeft,
|
|
25
|
+
right: styles.popupRight,
|
|
26
|
+
top: styles.popupTop
|
|
27
|
+
};
|
|
28
|
+
const panelPlacementClass = {
|
|
29
|
+
bottom: styles.panelBottom,
|
|
30
|
+
left: styles.panelLeft,
|
|
31
|
+
right: styles.panelRight,
|
|
32
|
+
top: styles.panelTop
|
|
33
|
+
};
|
|
34
|
+
const panelRoundedClass = {
|
|
35
|
+
bottom: styles.panelRoundedBottom,
|
|
36
|
+
left: styles.panelRoundedLeft,
|
|
37
|
+
right: styles.panelRoundedRight,
|
|
38
|
+
top: styles.panelRoundedTop
|
|
39
|
+
};
|
|
40
|
+
const DrawerOpenContext = createContext(null);
|
|
41
|
+
const DrawerActionsContext = createContext(null);
|
|
42
|
+
const useDrawerOpen = () => use(DrawerOpenContext);
|
|
43
|
+
const useDrawerActions = () => use(DrawerActionsContext);
|
|
44
|
+
const AnimatedDrawerRoot = ({ open, children, onExitComplete: onExitCompleteProp, zIndex: explicitZIndex, ...rest }) => {
|
|
45
|
+
const [isPresent, setIsPresent] = useState(!!open);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (open) setIsPresent(true);
|
|
48
|
+
}, [open]);
|
|
49
|
+
const handleExitComplete = useCallback(() => {
|
|
50
|
+
setIsPresent(false);
|
|
51
|
+
onExitCompleteProp?.();
|
|
52
|
+
}, [onExitCompleteProp]);
|
|
53
|
+
const actions = useMemo(() => ({ onExitComplete: handleExitComplete }), [handleExitComplete]);
|
|
54
|
+
const { zIndex, ref: popupRef } = useLayerZIndex("modal", explicitZIndex);
|
|
55
|
+
const layer = useMemo(() => ({
|
|
56
|
+
popupRef,
|
|
57
|
+
zIndex
|
|
58
|
+
}), [zIndex, popupRef]);
|
|
59
|
+
if (!isPresent) return null;
|
|
60
|
+
return /* @__PURE__ */ jsx(DrawerOpenContext, {
|
|
61
|
+
value: open,
|
|
62
|
+
children: /* @__PURE__ */ jsx(DrawerActionsContext, {
|
|
63
|
+
value: actions,
|
|
64
|
+
children: /* @__PURE__ */ jsx(DrawerLayerProvider, {
|
|
65
|
+
value: layer,
|
|
66
|
+
children: /* @__PURE__ */ jsx(Dialog.Root, {
|
|
67
|
+
modal: true,
|
|
68
|
+
open: true,
|
|
69
|
+
...rest,
|
|
70
|
+
children
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
const NonAnimatedDrawerRoot = ({ zIndex: explicitZIndex, children, ...rest }) => {
|
|
77
|
+
const { zIndex, ref: popupRef } = useLayerZIndex("modal", explicitZIndex);
|
|
78
|
+
const layer = useMemo(() => ({
|
|
79
|
+
popupRef,
|
|
80
|
+
zIndex
|
|
81
|
+
}), [zIndex, popupRef]);
|
|
82
|
+
return /* @__PURE__ */ jsx(DrawerLayerProvider, {
|
|
83
|
+
value: layer,
|
|
84
|
+
children: /* @__PURE__ */ jsx(Dialog.Root, {
|
|
85
|
+
modal: true,
|
|
86
|
+
...rest,
|
|
87
|
+
children
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
const DrawerRoot = ({ open, onExitComplete, ...rest }) => {
|
|
92
|
+
if (open !== void 0) return /* @__PURE__ */ jsx(AnimatedDrawerRoot, {
|
|
93
|
+
open,
|
|
94
|
+
onExitComplete,
|
|
95
|
+
...rest
|
|
96
|
+
});
|
|
97
|
+
return /* @__PURE__ */ jsx(NonAnimatedDrawerRoot, { ...rest });
|
|
98
|
+
};
|
|
99
|
+
const DrawerPortal = ({ container, ...rest }) => {
|
|
100
|
+
const appElement = useAppElement();
|
|
101
|
+
return /* @__PURE__ */ jsx(Dialog.Portal, {
|
|
102
|
+
container: container ?? appElement ?? void 0,
|
|
103
|
+
...rest
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
const DrawerBackdrop = ({ className, style, ...rest }) => {
|
|
107
|
+
const open = useDrawerOpen();
|
|
108
|
+
const layer = useDrawerLayer();
|
|
109
|
+
const Motion = useMotionComponent();
|
|
110
|
+
const layerStyle = layer?.zIndex !== void 0 ? { zIndex: layer.zIndex } : void 0;
|
|
111
|
+
if (open !== null) return /* @__PURE__ */ jsx(Dialog.Backdrop, {
|
|
112
|
+
...rest,
|
|
113
|
+
className: cx(styles.backdrop, className),
|
|
114
|
+
style: {
|
|
115
|
+
...layerStyle,
|
|
116
|
+
...style,
|
|
117
|
+
transition: "none"
|
|
118
|
+
},
|
|
119
|
+
render: /* @__PURE__ */ jsx(Motion.div, {
|
|
120
|
+
animate: { opacity: open ? 1 : 0 },
|
|
121
|
+
initial: { opacity: 0 },
|
|
122
|
+
transition: drawerBackdropTransition
|
|
123
|
+
})
|
|
124
|
+
});
|
|
125
|
+
return /* @__PURE__ */ jsx(Dialog.Backdrop, {
|
|
126
|
+
...rest,
|
|
127
|
+
className: mergeStateClassName(styles.backdrop, className),
|
|
128
|
+
style: {
|
|
129
|
+
...layerStyle,
|
|
130
|
+
...style
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
const DrawerPopup = ({ className, children, placement: placementProp = "right", width: widthProp, height: heightProp, flush, pushOffset = 0, motionProps, panelClassName, panelStyle, popupStyle, ref: forwardedRef, ...rest }) => {
|
|
135
|
+
const open = useDrawerOpen();
|
|
136
|
+
const actions = useDrawerActions();
|
|
137
|
+
const layer = useDrawerLayer();
|
|
138
|
+
const Motion = useMotionComponent();
|
|
139
|
+
const composedRef = useMergeRefs([forwardedRef, layer?.popupRef]);
|
|
140
|
+
const openGeometryRef = useRef({
|
|
141
|
+
height: heightProp,
|
|
142
|
+
placement: placementProp,
|
|
143
|
+
width: widthProp
|
|
144
|
+
});
|
|
145
|
+
if (open !== false) openGeometryRef.current = {
|
|
146
|
+
height: heightProp,
|
|
147
|
+
placement: placementProp,
|
|
148
|
+
width: widthProp
|
|
149
|
+
};
|
|
150
|
+
const { height, placement, width } = openGeometryRef.current;
|
|
151
|
+
const sizeStyle = placement === "left" || placement === "right" ? { width } : { height };
|
|
152
|
+
const resolvedPopupStyle = {
|
|
153
|
+
...layer?.zIndex === void 0 ? void 0 : { zIndex: layer.zIndex + 1 },
|
|
154
|
+
...sizeStyle,
|
|
155
|
+
...popupStyle
|
|
156
|
+
};
|
|
157
|
+
const popupBaseClassName = cx(styles.popup, popupPlacementClass[placement]);
|
|
158
|
+
const resolvedPanelClassName = cx(styles.panel, panelPlacementClass[placement], flush ? styles.panelFlush : panelRoundedClass[placement], panelClassName);
|
|
159
|
+
if (open !== null && actions) {
|
|
160
|
+
const motionConfig = getDrawerMotionConfig(placement, pushOffset);
|
|
161
|
+
return /* @__PURE__ */ jsx(Dialog.Popup, {
|
|
162
|
+
...rest,
|
|
163
|
+
className: cx(popupBaseClassName, className),
|
|
164
|
+
"data-drawer-anchor": placement,
|
|
165
|
+
ref: composedRef,
|
|
166
|
+
style: resolvedPopupStyle,
|
|
167
|
+
children: /* @__PURE__ */ jsx(AnimatePresence, {
|
|
168
|
+
onExitComplete: actions.onExitComplete,
|
|
169
|
+
children: open ? /* @__PURE__ */ createElement(Motion.div, {
|
|
170
|
+
...motionConfig,
|
|
171
|
+
...motionProps,
|
|
172
|
+
className: resolvedPanelClassName,
|
|
173
|
+
"data-drawer-placement": placement,
|
|
174
|
+
key: "drawer-popup-panel",
|
|
175
|
+
style: {
|
|
176
|
+
transition: "none",
|
|
177
|
+
...panelStyle
|
|
178
|
+
}
|
|
179
|
+
}, children) : null
|
|
180
|
+
})
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
const { axis, sign } = pushAxis[placement];
|
|
184
|
+
const pushVars = { [axis === "x" ? "--drawer-push-x" : "--drawer-push-y"]: `${pushOffset * sign}px` };
|
|
185
|
+
return /* @__PURE__ */ jsx(Dialog.Popup, {
|
|
186
|
+
...rest,
|
|
187
|
+
className: mergeStateClassName(popupBaseClassName, className),
|
|
188
|
+
"data-drawer-anchor": placement,
|
|
189
|
+
ref: composedRef,
|
|
190
|
+
style: resolvedPopupStyle,
|
|
191
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
192
|
+
className: resolvedPanelClassName,
|
|
193
|
+
"data-drawer-placement": placement,
|
|
194
|
+
style: {
|
|
195
|
+
...pushVars,
|
|
196
|
+
...panelStyle
|
|
197
|
+
},
|
|
198
|
+
children
|
|
199
|
+
})
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
const DrawerHeader = ({ className, ...rest }) => /* @__PURE__ */ jsx("div", {
|
|
203
|
+
...rest,
|
|
204
|
+
className: cx(styles.header, className)
|
|
205
|
+
});
|
|
206
|
+
const DrawerTitle = ({ className, ...rest }) => /* @__PURE__ */ jsx(Dialog.Title, {
|
|
207
|
+
...rest,
|
|
208
|
+
className: mergeStateClassName(styles.title, className)
|
|
209
|
+
});
|
|
210
|
+
const DrawerDescription = Dialog.Description;
|
|
211
|
+
const DrawerContent = ({ className, ...rest }) => /* @__PURE__ */ jsx("div", {
|
|
212
|
+
...rest,
|
|
213
|
+
className: cx(styles.content, className)
|
|
214
|
+
});
|
|
215
|
+
const DrawerFooter = ({ className, ...rest }) => /* @__PURE__ */ jsx("div", {
|
|
216
|
+
...rest,
|
|
217
|
+
className: cx(styles.footer, className)
|
|
218
|
+
});
|
|
219
|
+
const DrawerClose = ({ className, children, ...rest }) => /* @__PURE__ */ jsx(Dialog.Close, {
|
|
220
|
+
...rest,
|
|
221
|
+
className: mergeStateClassName(styles.close, className),
|
|
222
|
+
children: children ?? /* @__PURE__ */ jsx(X, { size: 16 })
|
|
223
|
+
});
|
|
224
|
+
const DrawerTrigger = ({ children, className, nativeButton, ref: refProp, ...rest }) => {
|
|
225
|
+
const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({
|
|
226
|
+
children,
|
|
227
|
+
nativeButton
|
|
228
|
+
});
|
|
229
|
+
const renderer = (props) => {
|
|
230
|
+
const resolvedProps = (() => {
|
|
231
|
+
if (isNativeButtonTriggerElement) return props;
|
|
232
|
+
const { type, ...restProps } = props;
|
|
233
|
+
return restProps;
|
|
234
|
+
})();
|
|
235
|
+
const mergedProps = mergeProps(children.props, resolvedProps);
|
|
236
|
+
return cloneElement(children, {
|
|
237
|
+
...mergedProps,
|
|
238
|
+
ref: mergeRefs([
|
|
239
|
+
children.ref,
|
|
240
|
+
props.ref,
|
|
241
|
+
refProp
|
|
242
|
+
])
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
if (isValidElement(children)) return /* @__PURE__ */ jsx(Dialog.Trigger, {
|
|
246
|
+
...rest,
|
|
247
|
+
className,
|
|
248
|
+
nativeButton: resolvedNativeButton,
|
|
249
|
+
render: renderer
|
|
250
|
+
});
|
|
251
|
+
return /* @__PURE__ */ jsx(Dialog.Trigger, {
|
|
252
|
+
...rest,
|
|
253
|
+
className,
|
|
254
|
+
nativeButton: resolvedNativeButton,
|
|
255
|
+
ref: refProp,
|
|
256
|
+
children
|
|
257
|
+
});
|
|
258
|
+
};
|
|
259
|
+
//#endregion
|
|
260
|
+
export { DrawerBackdrop, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerPopup, DrawerPortal, DrawerRoot, DrawerTitle, DrawerTrigger, useDrawerActions, useDrawerOpen };
|
|
261
|
+
|
|
262
|
+
//# sourceMappingURL=atoms.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atoms.mjs","names":[],"sources":["../../../src/base-ui/Drawer/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Dialog } from '@base-ui/react/dialog';\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport { cx } from 'antd-style';\nimport { X } from 'lucide-react';\nimport { AnimatePresence } from 'motion/react';\nimport type React from 'react';\nimport {\n cloneElement,\n createContext,\n isValidElement,\n use,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { mergeRefs, useMergeRefs } from 'react-merge-refs';\n\nimport { useNativeButton } from '@/hooks/useNativeButton';\nimport { useMotionComponent } from '@/MotionProvider';\nimport { useAppElement } from '@/ThemeProvider';\n\nimport { useLayerZIndex } from '../zIndex';\nimport { drawerBackdropTransition, getDrawerMotionConfig, pushAxis } from './constants';\nimport { DrawerLayerProvider, useDrawerLayer } from './DrawerLayerContext';\nimport { styles } from './style';\nimport type { DrawerPlacement } from './type';\n\nconst mergeStateClassName = <TState,>(\n base: string,\n className: string | ((state: TState) => string | undefined) | undefined,\n) => {\n if (typeof className === 'function') return (state: TState) => cx(base, className(state));\n return cx(base, className);\n};\n\nconst popupPlacementClass: Record<DrawerPlacement, string> = {\n bottom: styles.popupBottom,\n left: styles.popupLeft,\n right: styles.popupRight,\n top: styles.popupTop,\n};\n\nconst panelPlacementClass: Record<DrawerPlacement, string> = {\n bottom: styles.panelBottom,\n left: styles.panelLeft,\n right: styles.panelRight,\n top: styles.panelTop,\n};\n\nconst panelRoundedClass: Record<DrawerPlacement, string> = {\n bottom: styles.panelRoundedBottom,\n left: styles.panelRoundedLeft,\n right: styles.panelRoundedRight,\n top: styles.panelRoundedTop,\n};\n\nconst DrawerOpenContext = createContext<boolean | null>(null);\n\ninterface DrawerAnimationActions {\n onExitComplete: () => void;\n}\nconst DrawerActionsContext = createContext<DrawerAnimationActions | null>(null);\n\nexport const useDrawerOpen = () => use(DrawerOpenContext);\nexport const useDrawerActions = () => use(DrawerActionsContext);\n\nexport type DrawerRootProps = Dialog.Root.Props & {\n onExitComplete?: () => void;\n zIndex?: number;\n};\n\nconst AnimatedDrawerRoot = ({\n open,\n children,\n onExitComplete: onExitCompleteProp,\n zIndex: explicitZIndex,\n ...rest\n}: Omit<DrawerRootProps, 'open'> & { open: boolean }) => {\n const [isPresent, setIsPresent] = useState(!!open);\n\n useEffect(() => {\n if (open) setIsPresent(true);\n }, [open]);\n\n const handleExitComplete = useCallback(() => {\n setIsPresent(false);\n onExitCompleteProp?.();\n }, [onExitCompleteProp]);\n\n const actions = useMemo(() => ({ onExitComplete: handleExitComplete }), [handleExitComplete]);\n\n const { zIndex, ref: popupRef } = useLayerZIndex<HTMLDivElement>('modal', explicitZIndex);\n const layer = useMemo(\n () => ({ popupRef: popupRef as (node: HTMLElement | null) => void, zIndex }),\n [zIndex, popupRef],\n );\n\n if (!isPresent) return null;\n\n return (\n <DrawerOpenContext value={open}>\n <DrawerActionsContext value={actions}>\n <DrawerLayerProvider value={layer}>\n <Dialog.Root modal open {...rest}>\n {children}\n </Dialog.Root>\n </DrawerLayerProvider>\n </DrawerActionsContext>\n </DrawerOpenContext>\n );\n};\n\nconst NonAnimatedDrawerRoot = ({ zIndex: explicitZIndex, children, ...rest }: DrawerRootProps) => {\n const { zIndex, ref: popupRef } = useLayerZIndex<HTMLDivElement>('modal', explicitZIndex);\n const layer = useMemo(\n () => ({ popupRef: popupRef as (node: HTMLElement | null) => void, zIndex }),\n [zIndex, popupRef],\n );\n\n return (\n <DrawerLayerProvider value={layer}>\n <Dialog.Root modal {...rest}>\n {children}\n </Dialog.Root>\n </DrawerLayerProvider>\n );\n};\n\nexport const DrawerRoot = ({ open, onExitComplete, ...rest }: DrawerRootProps) => {\n if (open !== undefined) {\n return <AnimatedDrawerRoot open={open} onExitComplete={onExitComplete} {...rest} />;\n }\n return <NonAnimatedDrawerRoot {...rest} />;\n};\n\nexport type DrawerPortalProps = React.ComponentProps<typeof Dialog.Portal> & {\n container?: HTMLElement | null;\n};\nexport const DrawerPortal = ({ container, ...rest }: DrawerPortalProps) => {\n const appElement = useAppElement();\n return <Dialog.Portal container={container ?? appElement ?? undefined} {...rest} />;\n};\n\nexport type DrawerBackdropProps = React.ComponentProps<typeof Dialog.Backdrop>;\nexport const DrawerBackdrop = ({ className, style, ...rest }: DrawerBackdropProps) => {\n const open = useDrawerOpen();\n const layer = useDrawerLayer();\n const Motion = useMotionComponent();\n const layerStyle = layer?.zIndex !== undefined ? { zIndex: layer.zIndex } : undefined;\n\n if (open !== null) {\n return (\n <Dialog.Backdrop\n {...rest}\n className={cx(styles.backdrop, className as string)}\n style={{ ...layerStyle, ...style, transition: 'none' }}\n render={\n <Motion.div\n animate={{ opacity: open ? 1 : 0 }}\n initial={{ opacity: 0 }}\n transition={drawerBackdropTransition}\n />\n }\n />\n );\n }\n\n return (\n <Dialog.Backdrop\n {...rest}\n className={mergeStateClassName(styles.backdrop, className as any) as any}\n style={{ ...layerStyle, ...style }}\n />\n );\n};\n\nexport type DrawerPopupProps = React.ComponentProps<typeof Dialog.Popup> & {\n flush?: boolean;\n height?: number | string;\n motionProps?: Record<string, any>;\n panelClassName?: string;\n panelStyle?: React.CSSProperties;\n placement?: DrawerPlacement;\n popupStyle?: React.CSSProperties;\n pushOffset?: number;\n width?: number | string;\n};\n\nexport const DrawerPopup = ({\n className,\n children,\n placement: placementProp = 'right',\n width: widthProp,\n height: heightProp,\n flush,\n pushOffset = 0,\n motionProps,\n panelClassName,\n panelStyle,\n popupStyle,\n ref: forwardedRef,\n ...rest\n}: DrawerPopupProps) => {\n const open = useDrawerOpen();\n const actions = useDrawerActions();\n const layer = useDrawerLayer();\n const Motion = useMotionComponent();\n const composedRef = useMergeRefs([forwardedRef, layer?.popupRef]);\n\n // The exiting panel lives inside AnimatePresence and keeps the props it had while open,\n // but this popup re-renders with whatever the consumer passes now. Freezing the geometry\n // during exit keeps the two in sync — otherwise a placement change on close teleports the\n // popup to the new edge while the panel animates out along the old axis.\n const openGeometryRef = useRef({\n height: heightProp,\n placement: placementProp,\n width: widthProp,\n });\n if (open !== false) {\n openGeometryRef.current = { height: heightProp, placement: placementProp, width: widthProp };\n }\n const { height, placement, width } = openGeometryRef.current;\n\n const isHorizontal = placement === 'left' || placement === 'right';\n const sizeStyle: React.CSSProperties = isHorizontal ? { width } : { height };\n const resolvedPopupStyle: React.CSSProperties = {\n ...(layer?.zIndex === undefined ? undefined : { zIndex: layer.zIndex + 1 }),\n ...sizeStyle,\n ...popupStyle,\n };\n const popupBaseClassName = cx(styles.popup, popupPlacementClass[placement]);\n const resolvedPanelClassName = cx(\n styles.panel,\n panelPlacementClass[placement],\n flush ? styles.panelFlush : panelRoundedClass[placement],\n panelClassName,\n );\n\n if (open !== null && actions) {\n const motionConfig = getDrawerMotionConfig(placement, pushOffset);\n return (\n <Dialog.Popup\n {...rest}\n className={cx(popupBaseClassName, className as string)}\n data-drawer-anchor={placement}\n ref={composedRef as any}\n style={resolvedPopupStyle}\n >\n <AnimatePresence onExitComplete={actions.onExitComplete}>\n {open ? (\n <Motion.div\n {...motionConfig}\n {...motionProps}\n className={resolvedPanelClassName}\n data-drawer-placement={placement}\n key=\"drawer-popup-panel\"\n style={{ transition: 'none', ...panelStyle }}\n >\n {children}\n </Motion.div>\n ) : null}\n </AnimatePresence>\n </Dialog.Popup>\n );\n }\n\n const { axis, sign } = pushAxis[placement];\n const pushVars = {\n [axis === 'x' ? '--drawer-push-x' : '--drawer-push-y']: `${pushOffset * sign}px`,\n } as React.CSSProperties;\n\n return (\n <Dialog.Popup\n {...rest}\n className={mergeStateClassName(popupBaseClassName, className as any) as any}\n data-drawer-anchor={placement}\n ref={composedRef as any}\n style={resolvedPopupStyle}\n >\n <div\n className={resolvedPanelClassName}\n data-drawer-placement={placement}\n style={{ ...pushVars, ...panelStyle }}\n >\n {children}\n </div>\n </Dialog.Popup>\n );\n};\n\nexport type DrawerHeaderProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const DrawerHeader = ({ className, ...rest }: DrawerHeaderProps) => (\n <div {...rest} className={cx(styles.header, className)} />\n);\n\nexport type DrawerTitleProps = React.ComponentProps<typeof Dialog.Title>;\nexport const DrawerTitle = ({ className, ...rest }: DrawerTitleProps) => (\n <Dialog.Title {...rest} className={mergeStateClassName(styles.title, className as any) as any} />\n);\n\nexport type DrawerDescriptionProps = React.ComponentProps<typeof Dialog.Description>;\nexport const DrawerDescription: React.FC<DrawerDescriptionProps> = Dialog.Description;\n\nexport type DrawerContentProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const DrawerContent = ({ className, ...rest }: DrawerContentProps) => (\n <div {...rest} className={cx(styles.content, className)} />\n);\n\nexport type DrawerFooterProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const DrawerFooter = ({ className, ...rest }: DrawerFooterProps) => (\n <div {...rest} className={cx(styles.footer, className)} />\n);\n\nexport type DrawerCloseProps = React.ComponentProps<typeof Dialog.Close>;\nexport const DrawerClose = ({ className, children, ...rest }: DrawerCloseProps) => (\n <Dialog.Close {...rest} className={mergeStateClassName(styles.close, className as any) as any}>\n {children ?? <X size={16} />}\n </Dialog.Close>\n);\n\nexport type DrawerTriggerProps = Omit<\n React.ComponentPropsWithRef<typeof Dialog.Trigger>,\n 'children' | 'render'\n> & {\n children?: React.ReactNode;\n nativeButton?: boolean;\n};\n\nexport const DrawerTrigger = ({\n children,\n className,\n nativeButton,\n ref: refProp,\n ...rest\n}: DrawerTriggerProps) => {\n const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({\n children,\n nativeButton,\n });\n\n const renderer = (props: any) => {\n const resolvedProps = (() => {\n if (isNativeButtonTriggerElement) return props as any;\n // eslint-disable-next-line unused-imports/no-unused-vars\n const { type, ...restProps } = props as any;\n return restProps;\n })();\n\n const mergedProps = mergeProps((children as any).props, resolvedProps);\n return cloneElement(children as any, {\n ...mergedProps,\n ref: mergeRefs([(children as any).ref, (props as any).ref, refProp]),\n });\n };\n\n if (isValidElement(children)) {\n return (\n <Dialog.Trigger\n {...rest}\n className={className}\n nativeButton={resolvedNativeButton}\n render={renderer as any}\n />\n );\n }\n\n return (\n <Dialog.Trigger\n {...rest}\n className={className}\n nativeButton={resolvedNativeButton}\n ref={refProp as any}\n >\n {children}\n </Dialog.Trigger>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA+BA,MAAM,uBACJ,MACA,cACG;CACH,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AC,GAAD,EAAG,MAAM,GAAK,CAAA;AACf,CAAA;AAWhB,MAAa,iBAAiB,EAC5B,UACA,WACA,cACA,KAAK,SACL,GAAG,WACqB;CACxB,MAAM,EAAE,8BAA8B,yBAAyB,gBAAgB;EAC7E;EACA;CACF,CAAC;CAED,MAAM,YAAY,UAAe;EAC/B,MAAM,uBAAuB;GAC3B,IAAI,8BAA8B,OAAO;GAEzC,MAAM,EAAE,MAAM,GAAG,cAAc;GAC/B,OAAO;EACT,EAAA,CAAG;EAEH,MAAM,cAAc,WAAY,SAAiB,OAAO,aAAa;EACrE,OAAO,aAAa,UAAiB;GACnC,GAAG;GACH,KAAK,UAAU;IAAE,SAAiB;IAAM,MAAc;IAAK;GAAO,CAAC;EACrE,CAAC;CACH;CAEA,IAAI,eAAe,QAAQ,GACzB,OACE,oBAAC,OAAO,SAAR;EACE,GAAI;EACO;EACX,cAAc;EACd,QAAQ;CACT,CAAA;CAIL,OACE,oBAAC,OAAO,SAAR;EACE,GAAI;EACO;EACX,cAAc;EACd,KAAK;EAEJ;CACa,CAAA;AAEpB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DrawerPlacement } from "./type.mjs";
|
|
2
|
+
import { MotionProps } from "motion/react";
|
|
3
|
+
//#region src/base-ui/Drawer/constants.d.ts
|
|
4
|
+
type CubicBezier = [number, number, number, number];
|
|
5
|
+
declare const getDrawerMotionConfig: (placement: DrawerPlacement, pushOffset?: number) => MotionProps & {
|
|
6
|
+
animate: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
declare const drawerBackdropTransition: {
|
|
12
|
+
duration: number;
|
|
13
|
+
ease: CubicBezier;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { drawerBackdropTransition, getDrawerMotionConfig };
|
|
17
|
+
//# sourceMappingURL=constants.d.mts.map
|