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