@lobehub/ui 5.24.0 → 5.26.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/Image.mjs +138 -37
- package/es/Image/Image.mjs.map +1 -1
- package/es/Image/PreviewGroup.d.mts +1 -0
- package/es/Image/PreviewGroup.mjs +33 -10
- package/es/Image/PreviewGroup.mjs.map +1 -1
- package/es/Image/index.d.mts +2 -2
- package/es/Image/index.mjs +1 -1
- package/es/Image/style.mjs +126 -71
- package/es/Image/style.mjs.map +1 -1
- package/es/Image/type.d.mts +14 -17
- package/es/Image/viewer/GalleryNav.mjs +44 -0
- package/es/Image/viewer/GalleryNav.mjs.map +1 -0
- package/es/Image/viewer/ImageViewer.mjs +275 -0
- package/es/Image/viewer/ImageViewer.mjs.map +1 -0
- package/es/Image/viewer/PreviewOutlet.mjs +19 -0
- package/es/Image/viewer/PreviewOutlet.mjs.map +1 -0
- package/es/Image/viewer/Toolbar.mjs +184 -0
- package/es/Image/viewer/Toolbar.mjs.map +1 -0
- package/es/Image/viewer/ViewerChrome.mjs +54 -0
- package/es/Image/viewer/ViewerChrome.mjs.map +1 -0
- package/es/Image/viewer/geometry.mjs +85 -0
- package/es/Image/viewer/geometry.mjs.map +1 -0
- package/es/Image/viewer/registry.d.mts +2 -0
- package/es/Image/viewer/registry.mjs +52 -0
- package/es/Image/viewer/registry.mjs.map +1 -0
- package/es/Image/viewer/useChromeIdle.mjs +72 -0
- package/es/Image/viewer/useChromeIdle.mjs.map +1 -0
- package/es/Image/viewer/useFinalFocus.mjs +10 -0
- package/es/Image/viewer/useFinalFocus.mjs.map +1 -0
- package/es/Image/viewer/useFlipTransition.mjs +321 -0
- package/es/Image/viewer/useFlipTransition.mjs.map +1 -0
- package/es/Image/viewer/useGalleryNav.mjs +89 -0
- package/es/Image/viewer/useGalleryNav.mjs.map +1 -0
- package/es/Image/viewer/useRefitTransition.mjs +47 -0
- package/es/Image/viewer/useRefitTransition.mjs.map +1 -0
- package/es/Image/viewer/useViewerGestures.mjs +148 -0
- package/es/Image/viewer/useViewerGestures.mjs.map +1 -0
- package/es/Image/viewer/useZoomPan.mjs +346 -0
- package/es/Image/viewer/useZoomPan.mjs.map +1 -0
- 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/Toast/hostGuard.mjs +26 -0
- package/es/base-ui/Toast/hostGuard.mjs.map +1 -0
- package/es/base-ui/Toast/imperative.mjs +43 -20
- package/es/base-ui/Toast/imperative.mjs.map +1 -1
- package/es/base-ui/Toast/pendingQueue.mjs +30 -0
- package/es/base-ui/Toast/pendingQueue.mjs.map +1 -0
- package/es/base-ui/index.d.mts +6 -1
- package/es/base-ui/index.mjs +5 -2
- 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/es/i18n/resources/en/image.d.mts +5 -0
- package/es/i18n/resources/en/image.mjs +6 -1
- package/es/i18n/resources/en/image.mjs.map +1 -1
- package/es/i18n/resources/zhCn/image.d.mts +5 -0
- package/es/i18n/resources/zhCn/image.mjs +6 -1
- package/es/i18n/resources/zhCn/image.mjs.map +1 -1
- package/es/index.mjs +8 -8
- package/package.json +1 -1
- package/es/Image/components/Preview.mjs +0 -23
- package/es/Image/components/Preview.mjs.map +0 -1
- package/es/Image/components/Toolbar.mjs +0 -128
- package/es/Image/components/Toolbar.mjs.map +0 -1
- package/es/Image/components/usePreview.mjs +0 -58
- package/es/Image/components/usePreview.mjs.map +0 -1
- package/es/Image/components/usePreviewGroup.mjs +0 -57
- package/es/Image/components/usePreviewGroup.mjs.map +0 -1
|
@@ -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,IAAI,OAAO,cAAc,YAAY,QAAQ,UAAkB,GAAG,MAAM,UAAU,KAAK,CAAC;CACxF,OAAO,GAAG,MAAM,SAAS;AAC3B;AAEA,MAAM,sBAAuD;CAC3D,QAAQ,OAAO;CACf,MAAM,OAAO;CACb,OAAO,OAAO;CACd,KAAK,OAAO;AACd;AAEA,MAAM,sBAAuD;CAC3D,QAAQ,OAAO;CACf,MAAM,OAAO;CACb,OAAO,OAAO;CACd,KAAK,OAAO;AACd;AAEA,MAAM,oBAAqD;CACzD,QAAQ,OAAO;CACf,MAAM,OAAO;CACb,OAAO,OAAO;CACd,KAAK,OAAO;AACd;AAEA,MAAM,oBAAoB,cAA8B,IAAI;AAK5D,MAAM,uBAAuB,cAA6C,IAAI;AAE9E,MAAa,sBAAsB,IAAI,iBAAiB;AACxD,MAAa,yBAAyB,IAAI,oBAAoB;AAO9D,MAAM,sBAAsB,EAC1B,MACA,UACA,gBAAgB,oBAChB,QAAQ,gBACR,GAAG,WACoD;CACvD,MAAM,CAAC,WAAW,gBAAgB,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;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
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region src/base-ui/Drawer/constants.ts
|
|
2
|
+
const softEase = [
|
|
3
|
+
.32,
|
|
4
|
+
.72,
|
|
5
|
+
0,
|
|
6
|
+
1
|
|
7
|
+
];
|
|
8
|
+
const exitEase = [
|
|
9
|
+
.4,
|
|
10
|
+
0,
|
|
11
|
+
1,
|
|
12
|
+
1
|
|
13
|
+
];
|
|
14
|
+
const DEFAULT_CONTAINER_MAX_WIDTH = 1024;
|
|
15
|
+
const offscreen = {
|
|
16
|
+
bottom: { y: "100%" },
|
|
17
|
+
left: { x: "-100%" },
|
|
18
|
+
right: { x: "100%" },
|
|
19
|
+
top: { y: "-100%" }
|
|
20
|
+
};
|
|
21
|
+
const pushAxis = {
|
|
22
|
+
bottom: {
|
|
23
|
+
axis: "y",
|
|
24
|
+
sign: -1
|
|
25
|
+
},
|
|
26
|
+
left: {
|
|
27
|
+
axis: "x",
|
|
28
|
+
sign: 1
|
|
29
|
+
},
|
|
30
|
+
right: {
|
|
31
|
+
axis: "x",
|
|
32
|
+
sign: -1
|
|
33
|
+
},
|
|
34
|
+
top: {
|
|
35
|
+
axis: "y",
|
|
36
|
+
sign: 1
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const getDrawerMotionConfig = (placement, pushOffset = 0) => {
|
|
40
|
+
const hidden = offscreen[placement];
|
|
41
|
+
const { axis, sign } = pushAxis[placement];
|
|
42
|
+
const shift = pushOffset === 0 ? 0 : pushOffset * sign;
|
|
43
|
+
return {
|
|
44
|
+
animate: axis === "x" ? {
|
|
45
|
+
x: shift,
|
|
46
|
+
y: 0
|
|
47
|
+
} : {
|
|
48
|
+
x: 0,
|
|
49
|
+
y: shift
|
|
50
|
+
},
|
|
51
|
+
exit: {
|
|
52
|
+
...hidden,
|
|
53
|
+
transition: {
|
|
54
|
+
duration: .22,
|
|
55
|
+
ease: exitEase
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
initial: hidden,
|
|
59
|
+
transition: {
|
|
60
|
+
duration: .3,
|
|
61
|
+
ease: softEase
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const drawerBackdropTransition = {
|
|
66
|
+
duration: .18,
|
|
67
|
+
ease: softEase
|
|
68
|
+
};
|
|
69
|
+
//#endregion
|
|
70
|
+
export { DEFAULT_CONTAINER_MAX_WIDTH, drawerBackdropTransition, getDrawerMotionConfig, pushAxis };
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../../../src/base-ui/Drawer/constants.ts"],"sourcesContent":["import type { MotionProps } from 'motion/react';\n\nimport type { DrawerPlacement } from './type';\n\ntype CubicBezier = [number, number, number, number];\n\nconst softEase: CubicBezier = [0.32, 0.72, 0, 1];\nconst exitEase: CubicBezier = [0.4, 0, 1, 1];\n\nexport const DEFAULT_PUSH_DISTANCE = 180;\nexport const DEFAULT_SIDEBAR_WIDTH = 280;\nexport const DEFAULT_CONTAINER_MAX_WIDTH = 1024;\nexport const DEFAULT_DRAWER_WIDTH = 378;\nexport const DEFAULT_DRAWER_HEIGHT = 378;\n\nconst offscreen: Record<DrawerPlacement, MotionProps['initial']> = {\n bottom: { y: '100%' },\n left: { x: '-100%' },\n right: { x: '100%' },\n top: { y: '-100%' },\n};\n\nexport const pushAxis: Record<DrawerPlacement, { axis: 'x' | 'y'; sign: 1 | -1 }> = {\n bottom: { axis: 'y', sign: -1 },\n left: { axis: 'x', sign: 1 },\n right: { axis: 'x', sign: -1 },\n top: { axis: 'y', sign: 1 },\n};\n\nexport const getDrawerMotionConfig = (\n placement: DrawerPlacement,\n pushOffset = 0,\n): MotionProps & { animate: { x: number; y: number } } => {\n const hidden = offscreen[placement];\n const { axis, sign } = pushAxis[placement];\n const shift = pushOffset === 0 ? 0 : pushOffset * sign;\n\n return {\n animate: axis === 'x' ? { x: shift, y: 0 } : { x: 0, y: shift },\n exit: {\n ...(hidden as object),\n transition: { duration: 0.22, ease: exitEase },\n },\n initial: hidden,\n transition: { duration: 0.3, ease: softEase },\n };\n};\n\nexport const drawerBackdropTransition = {\n duration: 0.18,\n ease: softEase,\n};\n"],"mappings":";AAMA,MAAM,WAAwB;CAAC;CAAM;CAAM;CAAG;AAAC;AAC/C,MAAM,WAAwB;CAAC;CAAK;CAAG;CAAG;AAAC;AAI3C,MAAa,8BAA8B;AAI3C,MAAM,YAA6D;CACjE,QAAQ,EAAE,GAAG,OAAO;CACpB,MAAM,EAAE,GAAG,QAAQ;CACnB,OAAO,EAAE,GAAG,OAAO;CACnB,KAAK,EAAE,GAAG,QAAQ;AACpB;AAEA,MAAa,WAAuE;CAClF,QAAQ;EAAE,MAAM;EAAK,MAAM;CAAG;CAC9B,MAAM;EAAE,MAAM;EAAK,MAAM;CAAE;CAC3B,OAAO;EAAE,MAAM;EAAK,MAAM;CAAG;CAC7B,KAAK;EAAE,MAAM;EAAK,MAAM;CAAE;AAC5B;AAEA,MAAa,yBACX,WACA,aAAa,MAC2C;CACxD,MAAM,SAAS,UAAU;CACzB,MAAM,EAAE,MAAM,SAAS,SAAS;CAChC,MAAM,QAAQ,eAAe,IAAI,IAAI,aAAa;CAElD,OAAO;EACL,SAAS,SAAS,MAAM;GAAE,GAAG;GAAO,GAAG;EAAE,IAAI;GAAE,GAAG;GAAG,GAAG;EAAM;EAC9D,MAAM;GACJ,GAAI;GACJ,YAAY;IAAE,UAAU;IAAM,MAAM;GAAS;EAC/C;EACA,SAAS;EACT,YAAY;GAAE,UAAU;GAAK,MAAM;EAAS;CAC9C;AACF;AAEA,MAAa,2BAA2B;CACtC,UAAU;CACV,MAAM;AACR"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DrawerPlacement, DrawerProps, DrawerPush, DrawerSemanticNames, DrawerSemanticStyles } from "./type.mjs";
|
|
2
|
+
import Drawer from "./Drawer.mjs";
|
|
3
|
+
import { DrawerBackdrop, DrawerBackdropProps, DrawerClose, DrawerCloseProps, DrawerContent, DrawerContentProps, DrawerDescription, DrawerDescriptionProps, DrawerFooter, DrawerFooterProps, DrawerHeader, DrawerHeaderProps, DrawerPopup, DrawerPopupProps, DrawerPortal, DrawerPortalProps, DrawerRoot, DrawerRootProps, DrawerTitle, DrawerTitleProps, DrawerTrigger, DrawerTriggerProps, useDrawerActions, useDrawerOpen } from "./atoms.mjs";
|
|
4
|
+
import { drawerBackdropTransition, getDrawerMotionConfig } from "./constants.mjs";
|
|
5
|
+
export { Drawer, DrawerBackdrop, type DrawerBackdropProps, DrawerClose, type DrawerCloseProps, DrawerContent, type DrawerContentProps, DrawerDescription, type DrawerDescriptionProps, DrawerFooter, type DrawerFooterProps, DrawerHeader, type DrawerHeaderProps, type DrawerPlacement, DrawerPopup, type DrawerPopupProps, DrawerPortal, type DrawerPortalProps, type DrawerProps, type DrawerPush, DrawerRoot, type DrawerRootProps, type DrawerSemanticNames, type DrawerSemanticStyles, DrawerTitle, type DrawerTitleProps, DrawerTrigger, type DrawerTriggerProps, drawerBackdropTransition, getDrawerMotionConfig, useDrawerActions, useDrawerOpen };
|