@arolariu/components 0.0.37 → 0.0.38
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 +7 -0
- package/dist/cjs/components/ui/background-beams.cjs +1 -11
- package/dist/cjs/components/ui/background-beams.cjs.map +1 -1
- package/dist/cjs/components/ui/chart.cjs.map +1 -1
- package/dist/cjs/components/ui/drawer.cjs.map +1 -1
- package/dist/cjs/components/ui/dropdown-menu.cjs.map +1 -1
- package/dist/cjs/components/ui/dropdrawer.cjs +627 -0
- package/dist/cjs/components/ui/dropdrawer.cjs.map +1 -0
- package/dist/cjs/components/ui/highlight-text.cjs.map +1 -1
- package/dist/cjs/components/ui/pagination.cjs.map +1 -1
- package/dist/cjs/hooks/use-mobile.cjs.map +1 -1
- package/dist/cjs/index.cjs +35 -1
- package/dist/cjs/index.css +2194 -79
- package/dist/esm/components/ui/background-beams.js +1 -1
- package/dist/esm/components/ui/background-beams.js.map +1 -1
- package/dist/esm/components/ui/chart.js.map +1 -1
- package/dist/esm/components/ui/drawer.js.map +1 -1
- package/dist/esm/components/ui/dropdown-menu.js.map +1 -1
- package/dist/esm/components/ui/dropdrawer.js +563 -0
- package/dist/esm/components/ui/dropdrawer.js.map +1 -0
- package/dist/esm/components/ui/highlight-text.js.map +1 -1
- package/dist/esm/components/ui/pagination.js.map +1 -1
- package/dist/esm/hooks/use-mobile.js.map +1 -1
- package/dist/esm/index.css +2194 -79
- package/dist/esm/index.js +13 -1
- package/dist/index.css +2194 -79
- package/dist/index.js +13 -1
- package/dist/types/components/ui/background-beams.d.ts +1 -1
- package/dist/types/components/ui/dropdrawer.d.ts +23 -0
- package/dist/types/hooks/use-mobile.d.ts +23 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +75 -62
- package/readme.md +2 -1
- package/src/components/ui/background-beams.tsx +3 -3
- package/src/components/ui/drawer.tsx +4 -4
- package/src/components/ui/dropdown-menu.tsx +9 -9
- package/src/components/ui/dropdrawer.tsx +973 -0
- package/src/hooks/use-mobile.tsx +37 -12
- package/src/index.ts +15 -0
- package/tsconfig.json +50 -50
|
@@ -0,0 +1,627 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.r = (exports1)=>{
|
|
17
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
18
|
+
value: 'Module'
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
21
|
+
value: true
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
25
|
+
var __webpack_exports__ = {};
|
|
26
|
+
__webpack_require__.r(__webpack_exports__);
|
|
27
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
+
DropDrawerSubTrigger: ()=>DropDrawerSubTrigger,
|
|
29
|
+
DropDrawerTrigger: ()=>DropDrawerTrigger,
|
|
30
|
+
DropDrawer: ()=>DropDrawer,
|
|
31
|
+
DropDrawerGroup: ()=>DropDrawerGroup,
|
|
32
|
+
DropDrawerItem: ()=>DropDrawerItem,
|
|
33
|
+
DropDrawerFooter: ()=>DropDrawerFooter,
|
|
34
|
+
DropDrawerSeparator: ()=>DropDrawerSeparator,
|
|
35
|
+
DropDrawerContent: ()=>DropDrawerContent,
|
|
36
|
+
DropDrawerLabel: ()=>DropDrawerLabel,
|
|
37
|
+
DropDrawerSub: ()=>DropDrawerSub,
|
|
38
|
+
DropDrawerSubContent: ()=>DropDrawerSubContent
|
|
39
|
+
});
|
|
40
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
41
|
+
const react_namespaceObject = require("motion/react");
|
|
42
|
+
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
43
|
+
const external_react_namespaceObject = require("react");
|
|
44
|
+
const external_drawer_cjs_namespaceObject = require("./drawer.cjs");
|
|
45
|
+
const external_dropdown_menu_cjs_namespaceObject = require("./dropdown-menu.cjs");
|
|
46
|
+
const use_mobile_cjs_namespaceObject = require("../../hooks/use-mobile.cjs");
|
|
47
|
+
const utils_cjs_namespaceObject = require("../../lib/utils.cjs");
|
|
48
|
+
const DropDrawerContext = /*#__PURE__*/ external_react_namespaceObject.createContext({
|
|
49
|
+
isMobile: false
|
|
50
|
+
});
|
|
51
|
+
const useDropDrawerContext = ()=>{
|
|
52
|
+
const context = external_react_namespaceObject.useContext(DropDrawerContext);
|
|
53
|
+
if (!context) throw new Error("DropDrawer components cannot be rendered outside the Context");
|
|
54
|
+
return context;
|
|
55
|
+
};
|
|
56
|
+
function DropDrawer({ children, ...props }) {
|
|
57
|
+
const isMobile = (0, use_mobile_cjs_namespaceObject.useIsMobile)();
|
|
58
|
+
const DropdownComponent = isMobile ? external_drawer_cjs_namespaceObject.Drawer : external_dropdown_menu_cjs_namespaceObject.DropdownMenu;
|
|
59
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(DropDrawerContext.Provider, {
|
|
60
|
+
value: {
|
|
61
|
+
isMobile
|
|
62
|
+
},
|
|
63
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(DropdownComponent, {
|
|
64
|
+
"data-slot": "drop-drawer",
|
|
65
|
+
...isMobile && {
|
|
66
|
+
autoFocus: true
|
|
67
|
+
},
|
|
68
|
+
...props,
|
|
69
|
+
children: children
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function DropDrawerTrigger({ className, children, ...props }) {
|
|
74
|
+
const { isMobile } = useDropDrawerContext();
|
|
75
|
+
const TriggerComponent = isMobile ? external_drawer_cjs_namespaceObject.DrawerTrigger : external_dropdown_menu_cjs_namespaceObject.DropdownMenuTrigger;
|
|
76
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TriggerComponent, {
|
|
77
|
+
"data-slot": "drop-drawer-trigger",
|
|
78
|
+
className: className,
|
|
79
|
+
...props,
|
|
80
|
+
children: children
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function DropDrawerContent({ className, children, ...props }) {
|
|
84
|
+
const { isMobile } = useDropDrawerContext();
|
|
85
|
+
const [activeSubmenu, setActiveSubmenu] = external_react_namespaceObject.useState(null);
|
|
86
|
+
const [submenuTitle, setSubmenuTitle] = external_react_namespaceObject.useState(null);
|
|
87
|
+
const [submenuStack, setSubmenuStack] = external_react_namespaceObject.useState([]);
|
|
88
|
+
const [animationDirection, setAnimationDirection] = external_react_namespaceObject.useState("forward");
|
|
89
|
+
const submenuContentRef = external_react_namespaceObject.useRef(new Map());
|
|
90
|
+
const navigateToSubmenu = external_react_namespaceObject.useCallback((id, title)=>{
|
|
91
|
+
setAnimationDirection("forward");
|
|
92
|
+
setActiveSubmenu(id);
|
|
93
|
+
setSubmenuTitle(title);
|
|
94
|
+
setSubmenuStack((prev)=>[
|
|
95
|
+
...prev,
|
|
96
|
+
{
|
|
97
|
+
id,
|
|
98
|
+
title
|
|
99
|
+
}
|
|
100
|
+
]);
|
|
101
|
+
}, []);
|
|
102
|
+
const goBack = external_react_namespaceObject.useCallback(()=>{
|
|
103
|
+
setAnimationDirection("backward");
|
|
104
|
+
if (submenuStack.length <= 1) {
|
|
105
|
+
setActiveSubmenu(null);
|
|
106
|
+
setSubmenuTitle(null);
|
|
107
|
+
setSubmenuStack([]);
|
|
108
|
+
} else {
|
|
109
|
+
const newStack = [
|
|
110
|
+
...submenuStack
|
|
111
|
+
];
|
|
112
|
+
newStack.pop();
|
|
113
|
+
const previous = newStack[newStack.length - 1];
|
|
114
|
+
setActiveSubmenu(previous.id);
|
|
115
|
+
setSubmenuTitle(previous.title);
|
|
116
|
+
setSubmenuStack(newStack);
|
|
117
|
+
}
|
|
118
|
+
}, [
|
|
119
|
+
submenuStack
|
|
120
|
+
]);
|
|
121
|
+
const registerSubmenuContent = external_react_namespaceObject.useCallback((id, content)=>{
|
|
122
|
+
submenuContentRef.current.set(id, content);
|
|
123
|
+
}, []);
|
|
124
|
+
const extractSubmenuContent = external_react_namespaceObject.useCallback((elements, targetId)=>{
|
|
125
|
+
const result = [];
|
|
126
|
+
const findSubmenuContent = (node)=>{
|
|
127
|
+
if (!/*#__PURE__*/ external_react_namespaceObject.isValidElement(node)) return;
|
|
128
|
+
const element = node;
|
|
129
|
+
const props = element.props;
|
|
130
|
+
if (element.type === DropDrawerSub) {
|
|
131
|
+
const elementId = props.id;
|
|
132
|
+
const dataSubmenuId = props["data-submenu-id"];
|
|
133
|
+
if (elementId === targetId || dataSubmenuId === targetId) {
|
|
134
|
+
if (props.children) external_react_namespaceObject.Children.forEach(props.children, (child)=>{
|
|
135
|
+
if (/*#__PURE__*/ external_react_namespaceObject.isValidElement(child) && child.type === DropDrawerSubContent) {
|
|
136
|
+
const subContentProps = child.props;
|
|
137
|
+
if (subContentProps.children) external_react_namespaceObject.Children.forEach(subContentProps.children, (contentChild)=>{
|
|
138
|
+
result.push(contentChild);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (props.children) if (Array.isArray(props.children)) props.children.forEach((child)=>findSubmenuContent(child));
|
|
146
|
+
else findSubmenuContent(props.children);
|
|
147
|
+
};
|
|
148
|
+
if (Array.isArray(elements)) elements.forEach((child)=>findSubmenuContent(child));
|
|
149
|
+
else findSubmenuContent(elements);
|
|
150
|
+
return result;
|
|
151
|
+
}, []);
|
|
152
|
+
const getSubmenuContent = external_react_namespaceObject.useCallback((id)=>{
|
|
153
|
+
const cachedContent = submenuContentRef.current.get(id || "");
|
|
154
|
+
if (cachedContent && cachedContent.length > 0) return cachedContent;
|
|
155
|
+
const submenuContent = extractSubmenuContent(children, id);
|
|
156
|
+
if (0 === submenuContent.length) return [];
|
|
157
|
+
if (id) submenuContentRef.current.set(id, submenuContent);
|
|
158
|
+
return submenuContent;
|
|
159
|
+
}, [
|
|
160
|
+
children,
|
|
161
|
+
extractSubmenuContent
|
|
162
|
+
]);
|
|
163
|
+
const variants = {
|
|
164
|
+
enter: (direction)=>({
|
|
165
|
+
x: "forward" === direction ? "100%" : "-100%",
|
|
166
|
+
opacity: 0
|
|
167
|
+
}),
|
|
168
|
+
center: {
|
|
169
|
+
x: 0,
|
|
170
|
+
opacity: 1
|
|
171
|
+
},
|
|
172
|
+
exit: (direction)=>({
|
|
173
|
+
x: "forward" === direction ? "-100%" : "100%",
|
|
174
|
+
opacity: 0
|
|
175
|
+
})
|
|
176
|
+
};
|
|
177
|
+
const transition = {
|
|
178
|
+
duration: 0.3,
|
|
179
|
+
ease: [
|
|
180
|
+
0.25,
|
|
181
|
+
0.1,
|
|
182
|
+
0.25,
|
|
183
|
+
1.0
|
|
184
|
+
]
|
|
185
|
+
};
|
|
186
|
+
if (isMobile) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SubmenuContext.Provider, {
|
|
187
|
+
value: {
|
|
188
|
+
activeSubmenu,
|
|
189
|
+
setActiveSubmenu: (id)=>{
|
|
190
|
+
if (null === id) {
|
|
191
|
+
setActiveSubmenu(null);
|
|
192
|
+
setSubmenuTitle(null);
|
|
193
|
+
setSubmenuStack([]);
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
submenuTitle,
|
|
197
|
+
setSubmenuTitle,
|
|
198
|
+
navigateToSubmenu,
|
|
199
|
+
registerSubmenuContent
|
|
200
|
+
},
|
|
201
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_drawer_cjs_namespaceObject.DrawerContent, {
|
|
202
|
+
"data-slot": "drop-drawer-content",
|
|
203
|
+
className: (0, utils_cjs_namespaceObject.cn)("max-h-[90vh]", className),
|
|
204
|
+
...props,
|
|
205
|
+
children: activeSubmenu ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
206
|
+
children: [
|
|
207
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_drawer_cjs_namespaceObject.DrawerHeader, {
|
|
208
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
209
|
+
className: "flex items-center gap-2",
|
|
210
|
+
children: [
|
|
211
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
212
|
+
onClick: goBack,
|
|
213
|
+
className: "hover:bg-neutral-100/50 rounded-full p-1 dark:hover:bg-neutral-800/50",
|
|
214
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ChevronLeftIcon, {
|
|
215
|
+
className: "h-5 w-5"
|
|
216
|
+
})
|
|
217
|
+
}),
|
|
218
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_drawer_cjs_namespaceObject.DrawerTitle, {
|
|
219
|
+
children: submenuTitle || "Submenu"
|
|
220
|
+
})
|
|
221
|
+
]
|
|
222
|
+
})
|
|
223
|
+
}),
|
|
224
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
225
|
+
className: "flex-1 relative overflow-y-auto max-h-[70vh]",
|
|
226
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.AnimatePresence, {
|
|
227
|
+
initial: false,
|
|
228
|
+
mode: "wait",
|
|
229
|
+
custom: animationDirection,
|
|
230
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.motion.div, {
|
|
231
|
+
custom: animationDirection,
|
|
232
|
+
variants: variants,
|
|
233
|
+
initial: "enter",
|
|
234
|
+
animate: "center",
|
|
235
|
+
exit: "exit",
|
|
236
|
+
transition: transition,
|
|
237
|
+
className: "pb-6 space-y-1.5 w-full h-full",
|
|
238
|
+
children: activeSubmenu ? getSubmenuContent(activeSubmenu) : children
|
|
239
|
+
}, activeSubmenu || "main")
|
|
240
|
+
})
|
|
241
|
+
})
|
|
242
|
+
]
|
|
243
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
244
|
+
children: [
|
|
245
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_drawer_cjs_namespaceObject.DrawerHeader, {
|
|
246
|
+
className: "sr-only",
|
|
247
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_drawer_cjs_namespaceObject.DrawerTitle, {
|
|
248
|
+
children: "Menu"
|
|
249
|
+
})
|
|
250
|
+
}),
|
|
251
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
252
|
+
className: "overflow-y-auto max-h-[70vh]",
|
|
253
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.AnimatePresence, {
|
|
254
|
+
initial: false,
|
|
255
|
+
mode: "wait",
|
|
256
|
+
custom: animationDirection,
|
|
257
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.motion.div, {
|
|
258
|
+
custom: animationDirection,
|
|
259
|
+
variants: variants,
|
|
260
|
+
initial: "enter",
|
|
261
|
+
animate: "center",
|
|
262
|
+
exit: "exit",
|
|
263
|
+
transition: transition,
|
|
264
|
+
className: "pb-6 space-y-1.5 w-full",
|
|
265
|
+
children: children
|
|
266
|
+
}, "main-menu")
|
|
267
|
+
})
|
|
268
|
+
})
|
|
269
|
+
]
|
|
270
|
+
})
|
|
271
|
+
})
|
|
272
|
+
});
|
|
273
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SubmenuContext.Provider, {
|
|
274
|
+
value: {
|
|
275
|
+
activeSubmenu,
|
|
276
|
+
setActiveSubmenu,
|
|
277
|
+
submenuTitle,
|
|
278
|
+
setSubmenuTitle,
|
|
279
|
+
registerSubmenuContent
|
|
280
|
+
},
|
|
281
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuContent, {
|
|
282
|
+
"data-slot": "drop-drawer-content",
|
|
283
|
+
align: "end",
|
|
284
|
+
sideOffset: 4,
|
|
285
|
+
className: (0, utils_cjs_namespaceObject.cn)("max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[220px] overflow-y-auto", className),
|
|
286
|
+
...props,
|
|
287
|
+
children: children
|
|
288
|
+
})
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
function DropDrawerItem({ className, children, onSelect, onClick, icon, variant = "default", inset, disabled, ...props }) {
|
|
292
|
+
const { isMobile } = useDropDrawerContext();
|
|
293
|
+
const isInGroup = external_react_namespaceObject.useCallback((element)=>{
|
|
294
|
+
if (!element) return false;
|
|
295
|
+
let parent = element.parentElement;
|
|
296
|
+
while(parent){
|
|
297
|
+
if (parent.hasAttribute("data-drop-drawer-group")) return true;
|
|
298
|
+
parent = parent.parentElement;
|
|
299
|
+
}
|
|
300
|
+
return false;
|
|
301
|
+
}, []);
|
|
302
|
+
const itemRef = external_react_namespaceObject.useRef(null);
|
|
303
|
+
const [isInsideGroup, setIsInsideGroup] = external_react_namespaceObject.useState(false);
|
|
304
|
+
external_react_namespaceObject.useEffect(()=>{
|
|
305
|
+
if (!isMobile) return;
|
|
306
|
+
const timer = setTimeout(()=>{
|
|
307
|
+
if (itemRef.current) setIsInsideGroup(isInGroup(itemRef.current));
|
|
308
|
+
}, 0);
|
|
309
|
+
return ()=>clearTimeout(timer);
|
|
310
|
+
}, [
|
|
311
|
+
isInGroup,
|
|
312
|
+
isMobile
|
|
313
|
+
]);
|
|
314
|
+
if (isMobile) {
|
|
315
|
+
const handleClick = (e)=>{
|
|
316
|
+
if (disabled) return;
|
|
317
|
+
if (onClick) onClick(e);
|
|
318
|
+
if (onSelect) onSelect(e);
|
|
319
|
+
};
|
|
320
|
+
const content = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
321
|
+
ref: itemRef,
|
|
322
|
+
"data-slot": "drop-drawer-item",
|
|
323
|
+
"data-variant": variant,
|
|
324
|
+
"data-inset": inset,
|
|
325
|
+
"data-disabled": disabled,
|
|
326
|
+
className: (0, utils_cjs_namespaceObject.cn)("flex cursor-pointer items-center justify-between px-4 py-4", !isInsideGroup && "bg-neutral-100 dark:bg-neutral-100 mx-2 my-1.5 rounded-md dark:bg-neutral-800 dark:dark:bg-neutral-800", isInsideGroup && "bg-transparent py-4", inset && "pl-8", "destructive" === variant && "text-red-500 dark:text-red-500 dark:text-red-900 dark:dark:text-red-900", disabled && "pointer-events-none opacity-50", className),
|
|
327
|
+
onClick: handleClick,
|
|
328
|
+
"aria-disabled": disabled,
|
|
329
|
+
...props,
|
|
330
|
+
children: [
|
|
331
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
332
|
+
className: "flex items-center gap-2",
|
|
333
|
+
children: children
|
|
334
|
+
}),
|
|
335
|
+
icon && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
336
|
+
className: "flex-shrink-0",
|
|
337
|
+
children: icon
|
|
338
|
+
})
|
|
339
|
+
]
|
|
340
|
+
});
|
|
341
|
+
const isInSubmenu = props["data-parent-submenu-id"] || props["data-parent-submenu"];
|
|
342
|
+
if (isInSubmenu) return content;
|
|
343
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_drawer_cjs_namespaceObject.DrawerClose, {
|
|
344
|
+
asChild: true,
|
|
345
|
+
children: content
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuItem, {
|
|
349
|
+
"data-slot": "drop-drawer-item",
|
|
350
|
+
"data-variant": variant,
|
|
351
|
+
"data-inset": inset,
|
|
352
|
+
className: className,
|
|
353
|
+
onSelect: onSelect,
|
|
354
|
+
onClick: onClick,
|
|
355
|
+
variant: variant,
|
|
356
|
+
inset: inset,
|
|
357
|
+
disabled: disabled,
|
|
358
|
+
...props,
|
|
359
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
360
|
+
className: "flex w-full items-center justify-between",
|
|
361
|
+
children: [
|
|
362
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
363
|
+
children: children
|
|
364
|
+
}),
|
|
365
|
+
icon && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
366
|
+
children: icon
|
|
367
|
+
})
|
|
368
|
+
]
|
|
369
|
+
})
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
function DropDrawerSeparator({ className, ...props }) {
|
|
373
|
+
const { isMobile } = useDropDrawerContext();
|
|
374
|
+
if (isMobile) return null;
|
|
375
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuSeparator, {
|
|
376
|
+
"data-slot": "drop-drawer-separator",
|
|
377
|
+
className: className,
|
|
378
|
+
...props
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
function DropDrawerLabel({ className, children, ...props }) {
|
|
382
|
+
const { isMobile } = useDropDrawerContext();
|
|
383
|
+
if (isMobile) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_drawer_cjs_namespaceObject.DrawerHeader, {
|
|
384
|
+
className: "p-0",
|
|
385
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_drawer_cjs_namespaceObject.DrawerTitle, {
|
|
386
|
+
"data-slot": "drop-drawer-label",
|
|
387
|
+
className: (0, utils_cjs_namespaceObject.cn)("text-neutral-500 px-4 py-2 text-sm font-medium dark:text-neutral-400", className),
|
|
388
|
+
...props,
|
|
389
|
+
children: children
|
|
390
|
+
})
|
|
391
|
+
});
|
|
392
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuLabel, {
|
|
393
|
+
"data-slot": "drop-drawer-label",
|
|
394
|
+
className: className,
|
|
395
|
+
...props,
|
|
396
|
+
children: children
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
function DropDrawerFooter({ className, children, ...props }) {
|
|
400
|
+
const { isMobile } = useDropDrawerContext();
|
|
401
|
+
if (isMobile) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_drawer_cjs_namespaceObject.DrawerFooter, {
|
|
402
|
+
"data-slot": "drop-drawer-footer",
|
|
403
|
+
className: (0, utils_cjs_namespaceObject.cn)("p-4", className),
|
|
404
|
+
...props,
|
|
405
|
+
children: children
|
|
406
|
+
});
|
|
407
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
408
|
+
"data-slot": "drop-drawer-footer",
|
|
409
|
+
className: (0, utils_cjs_namespaceObject.cn)("p-2", className),
|
|
410
|
+
...props,
|
|
411
|
+
children: children
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
function DropDrawerGroup({ className, children, ...props }) {
|
|
415
|
+
const { isMobile } = useDropDrawerContext();
|
|
416
|
+
const childrenWithSeparators = external_react_namespaceObject.useMemo(()=>{
|
|
417
|
+
if (!isMobile) return children;
|
|
418
|
+
const childArray = external_react_namespaceObject.Children.toArray(children);
|
|
419
|
+
const filteredChildren = childArray.filter((child)=>/*#__PURE__*/ external_react_namespaceObject.isValidElement(child) && child.type !== DropDrawerSeparator);
|
|
420
|
+
return filteredChildren.flatMap((child, index)=>{
|
|
421
|
+
if (index === filteredChildren.length - 1) return [
|
|
422
|
+
child
|
|
423
|
+
];
|
|
424
|
+
return [
|
|
425
|
+
child,
|
|
426
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
427
|
+
className: "bg-neutral-200 h-px dark:bg-neutral-800",
|
|
428
|
+
"aria-hidden": "true"
|
|
429
|
+
}, `separator-${index}`)
|
|
430
|
+
];
|
|
431
|
+
});
|
|
432
|
+
}, [
|
|
433
|
+
children,
|
|
434
|
+
isMobile
|
|
435
|
+
]);
|
|
436
|
+
if (isMobile) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
437
|
+
"data-drop-drawer-group": true,
|
|
438
|
+
"data-slot": "drop-drawer-group",
|
|
439
|
+
role: "group",
|
|
440
|
+
className: (0, utils_cjs_namespaceObject.cn)("bg-neutral-100 dark:bg-neutral-100 mx-2 my-3 overflow-hidden rounded-xl dark:bg-neutral-800 dark:dark:bg-neutral-800", className),
|
|
441
|
+
...props,
|
|
442
|
+
children: childrenWithSeparators
|
|
443
|
+
});
|
|
444
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
445
|
+
"data-drop-drawer-group": true,
|
|
446
|
+
"data-slot": "drop-drawer-group",
|
|
447
|
+
role: "group",
|
|
448
|
+
className: className,
|
|
449
|
+
...props,
|
|
450
|
+
children: children
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
const SubmenuContext = /*#__PURE__*/ external_react_namespaceObject.createContext({
|
|
454
|
+
activeSubmenu: null,
|
|
455
|
+
setActiveSubmenu: ()=>{},
|
|
456
|
+
submenuTitle: null,
|
|
457
|
+
setSubmenuTitle: ()=>{},
|
|
458
|
+
navigateToSubmenu: void 0,
|
|
459
|
+
registerSubmenuContent: void 0
|
|
460
|
+
});
|
|
461
|
+
let submenuIdCounter = 0;
|
|
462
|
+
function DropDrawerSub({ children, id, ...props }) {
|
|
463
|
+
const { isMobile } = useDropDrawerContext();
|
|
464
|
+
const { registerSubmenuContent } = external_react_namespaceObject.useContext(SubmenuContext);
|
|
465
|
+
const [generatedId] = external_react_namespaceObject.useState(()=>`submenu-${submenuIdCounter++}`);
|
|
466
|
+
const submenuId = id || generatedId;
|
|
467
|
+
external_react_namespaceObject.useEffect(()=>{
|
|
468
|
+
if (!registerSubmenuContent) return;
|
|
469
|
+
const contentItems = [];
|
|
470
|
+
external_react_namespaceObject.Children.forEach(children, (child)=>{
|
|
471
|
+
if (/*#__PURE__*/ external_react_namespaceObject.isValidElement(child) && child.type === DropDrawerSubContent) external_react_namespaceObject.Children.forEach(child.props.children, (contentChild)=>{
|
|
472
|
+
contentItems.push(contentChild);
|
|
473
|
+
});
|
|
474
|
+
});
|
|
475
|
+
if (contentItems.length > 0) registerSubmenuContent(submenuId, contentItems);
|
|
476
|
+
}, [
|
|
477
|
+
children,
|
|
478
|
+
registerSubmenuContent,
|
|
479
|
+
submenuId
|
|
480
|
+
]);
|
|
481
|
+
if (isMobile) {
|
|
482
|
+
const processedChildren = external_react_namespaceObject.Children.map(children, (child)=>{
|
|
483
|
+
if (!/*#__PURE__*/ external_react_namespaceObject.isValidElement(child)) return child;
|
|
484
|
+
if (child.type === DropDrawerSubTrigger) return /*#__PURE__*/ external_react_namespaceObject.cloneElement(child, {
|
|
485
|
+
...child.props,
|
|
486
|
+
"data-parent-submenu-id": submenuId,
|
|
487
|
+
"data-submenu-id": submenuId,
|
|
488
|
+
"data-parent-submenu": submenuId
|
|
489
|
+
});
|
|
490
|
+
if (child.type === DropDrawerSubContent) return /*#__PURE__*/ external_react_namespaceObject.cloneElement(child, {
|
|
491
|
+
...child.props,
|
|
492
|
+
"data-parent-submenu-id": submenuId,
|
|
493
|
+
"data-submenu-id": submenuId,
|
|
494
|
+
"data-parent-submenu": submenuId
|
|
495
|
+
});
|
|
496
|
+
return child;
|
|
497
|
+
});
|
|
498
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
499
|
+
"data-slot": "drop-drawer-sub",
|
|
500
|
+
"data-submenu-id": submenuId,
|
|
501
|
+
id: submenuId,
|
|
502
|
+
children: processedChildren
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuSub, {
|
|
506
|
+
"data-slot": "drop-drawer-sub",
|
|
507
|
+
"data-submenu-id": submenuId,
|
|
508
|
+
...props,
|
|
509
|
+
children: children
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
function DropDrawerSubTrigger({ className, inset, children, ...props }) {
|
|
513
|
+
const { isMobile } = useDropDrawerContext();
|
|
514
|
+
const { navigateToSubmenu } = external_react_namespaceObject.useContext(SubmenuContext);
|
|
515
|
+
const isInGroup = external_react_namespaceObject.useCallback((element)=>{
|
|
516
|
+
if (!element) return false;
|
|
517
|
+
let parent = element.parentElement;
|
|
518
|
+
while(parent){
|
|
519
|
+
if (parent.hasAttribute("data-drop-drawer-group")) return true;
|
|
520
|
+
parent = parent.parentElement;
|
|
521
|
+
}
|
|
522
|
+
return false;
|
|
523
|
+
}, []);
|
|
524
|
+
const itemRef = external_react_namespaceObject.useRef(null);
|
|
525
|
+
const [isInsideGroup, setIsInsideGroup] = external_react_namespaceObject.useState(false);
|
|
526
|
+
external_react_namespaceObject.useEffect(()=>{
|
|
527
|
+
if (!isMobile) return;
|
|
528
|
+
const timer = setTimeout(()=>{
|
|
529
|
+
if (itemRef.current) setIsInsideGroup(isInGroup(itemRef.current));
|
|
530
|
+
}, 0);
|
|
531
|
+
return ()=>clearTimeout(timer);
|
|
532
|
+
}, [
|
|
533
|
+
isInGroup,
|
|
534
|
+
isMobile
|
|
535
|
+
]);
|
|
536
|
+
if (isMobile) {
|
|
537
|
+
const handleClick = (e)=>{
|
|
538
|
+
e.preventDefault();
|
|
539
|
+
e.stopPropagation();
|
|
540
|
+
const element = e.currentTarget;
|
|
541
|
+
let submenuId = null;
|
|
542
|
+
if (element.closest("[data-submenu-id]")) {
|
|
543
|
+
const closestElement = element.closest("[data-submenu-id]");
|
|
544
|
+
const id = closestElement?.getAttribute("data-submenu-id");
|
|
545
|
+
if (id) submenuId = id;
|
|
546
|
+
}
|
|
547
|
+
if (!submenuId) submenuId = props["data-parent-submenu-id"] || props["data-parent-submenu"];
|
|
548
|
+
if (!submenuId) return;
|
|
549
|
+
const title = "string" == typeof children ? children : "Submenu";
|
|
550
|
+
if (navigateToSubmenu) navigateToSubmenu(submenuId, title);
|
|
551
|
+
};
|
|
552
|
+
const combinedOnClick = (e)=>{
|
|
553
|
+
const typedProps = props;
|
|
554
|
+
if (typedProps["onClick"]) {
|
|
555
|
+
const originalOnClick = typedProps["onClick"];
|
|
556
|
+
originalOnClick(e);
|
|
557
|
+
}
|
|
558
|
+
handleClick(e);
|
|
559
|
+
};
|
|
560
|
+
const { ...restProps } = props;
|
|
561
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
562
|
+
ref: itemRef,
|
|
563
|
+
"data-slot": "drop-drawer-sub-trigger",
|
|
564
|
+
"data-inset": inset,
|
|
565
|
+
className: (0, utils_cjs_namespaceObject.cn)("flex cursor-pointer items-center justify-between px-4 py-4", !isInsideGroup && "bg-neutral-100 dark:bg-neutral-100 mx-2 my-1.5 rounded-md dark:bg-neutral-800 dark:dark:bg-neutral-800", isInsideGroup && "bg-transparent py-4", inset && "pl-8", className),
|
|
566
|
+
onClick: combinedOnClick,
|
|
567
|
+
...restProps,
|
|
568
|
+
children: [
|
|
569
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
570
|
+
className: "flex items-center gap-2",
|
|
571
|
+
children: children
|
|
572
|
+
}),
|
|
573
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ChevronRightIcon, {
|
|
574
|
+
className: "h-5 w-5"
|
|
575
|
+
})
|
|
576
|
+
]
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuSubTrigger, {
|
|
580
|
+
"data-slot": "drop-drawer-sub-trigger",
|
|
581
|
+
"data-inset": inset,
|
|
582
|
+
className: className,
|
|
583
|
+
inset: inset,
|
|
584
|
+
...props,
|
|
585
|
+
children: children
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
function DropDrawerSubContent({ className, sideOffset = 4, children, ...props }) {
|
|
589
|
+
const { isMobile } = useDropDrawerContext();
|
|
590
|
+
if (isMobile) return null;
|
|
591
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuSubContent, {
|
|
592
|
+
"data-slot": "drop-drawer-sub-content",
|
|
593
|
+
sideOffset: sideOffset,
|
|
594
|
+
className: (0, utils_cjs_namespaceObject.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border border-neutral-200 p-1 shadow-lg dark:border-neutral-800", className),
|
|
595
|
+
...props,
|
|
596
|
+
children: children
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
exports.DropDrawer = __webpack_exports__.DropDrawer;
|
|
600
|
+
exports.DropDrawerContent = __webpack_exports__.DropDrawerContent;
|
|
601
|
+
exports.DropDrawerFooter = __webpack_exports__.DropDrawerFooter;
|
|
602
|
+
exports.DropDrawerGroup = __webpack_exports__.DropDrawerGroup;
|
|
603
|
+
exports.DropDrawerItem = __webpack_exports__.DropDrawerItem;
|
|
604
|
+
exports.DropDrawerLabel = __webpack_exports__.DropDrawerLabel;
|
|
605
|
+
exports.DropDrawerSeparator = __webpack_exports__.DropDrawerSeparator;
|
|
606
|
+
exports.DropDrawerSub = __webpack_exports__.DropDrawerSub;
|
|
607
|
+
exports.DropDrawerSubContent = __webpack_exports__.DropDrawerSubContent;
|
|
608
|
+
exports.DropDrawerSubTrigger = __webpack_exports__.DropDrawerSubTrigger;
|
|
609
|
+
exports.DropDrawerTrigger = __webpack_exports__.DropDrawerTrigger;
|
|
610
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
611
|
+
"DropDrawer",
|
|
612
|
+
"DropDrawerContent",
|
|
613
|
+
"DropDrawerFooter",
|
|
614
|
+
"DropDrawerGroup",
|
|
615
|
+
"DropDrawerItem",
|
|
616
|
+
"DropDrawerLabel",
|
|
617
|
+
"DropDrawerSeparator",
|
|
618
|
+
"DropDrawerSub",
|
|
619
|
+
"DropDrawerSubContent",
|
|
620
|
+
"DropDrawerSubTrigger",
|
|
621
|
+
"DropDrawerTrigger"
|
|
622
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
623
|
+
Object.defineProperty(exports, '__esModule', {
|
|
624
|
+
value: true
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
//# sourceMappingURL=dropdrawer.cjs.map
|