@moontra/moonui-pro 2.5.4 → 2.5.6
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/dist/index.mjs +25 -19
- package/package.json +1 -1
- package/src/components/sidebar/index.tsx +33 -30
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { twMerge } from 'tailwind-merge';
|
|
|
3
3
|
import * as t from 'react';
|
|
4
4
|
import t__default, { useState, useRef, useCallback, forwardRef, createContext, useContext, useMemo, useEffect, useDebugValue, Component, useLayoutEffect } from 'react';
|
|
5
5
|
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
6
|
-
import { ChevronDown, Info, AlertCircle, AlertTriangle, Check, X, MoreHorizontal, Loader2, Minus, Search, ChevronRight, Circle, ChevronUp, Lock, Sparkles, Plus, ChevronLeft, Calendar as Calendar$1, Edit, Trash2, Clock, MapPin, User, GripVertical, MessageCircle, Paperclip, Bold as Bold$1, Italic as Italic$1, Underline as Underline$1, Strikethrough, Code as Code$1, Type, Heading1, Heading2, Heading3, AlignLeft, AlignCenter, AlignRight, AlignJustify, List, ListOrdered, CheckSquare, Quote, Palette, Highlighter, Link2, Image as Image$1, Table as Table$1, Settings, Undo, Redo, Eye, RefreshCw, Wand2, Maximize, FileText, Languages, TrendingUp, TrendingDown, ZoomOut, ZoomIn, Download, FileSpreadsheet, FileJson, Maximize2, Move, Menu, Bell, Edit3, LayoutGrid, Upload, Share2, Save, CheckCircle2, Filter, FileDown, ArrowUp, ArrowDown, ArrowUpDown, ChevronsLeft, ChevronsRight, ExternalLink, CalendarIcon, DollarSign, Users, Github, Star, GitFork, Activity, Server, EyeOff, RotateCw, Zap, Monitor, Timer, Cpu, MemoryStick, HardDrive, Network, CheckCircle, BarChart3, Video, Music, Archive, File, Columns, Sun, Moon, XCircle, Grip, Unlock, Minimize2, Map as Map$1, Target,
|
|
6
|
+
import { ChevronDown, Info, AlertCircle, AlertTriangle, Check, X, MoreHorizontal, Loader2, Minus, Search, ChevronRight, Circle, ChevronUp, Lock, Sparkles, Plus, ChevronLeft, Calendar as Calendar$1, Edit, Trash2, Clock, MapPin, User, GripVertical, MessageCircle, Paperclip, Bold as Bold$1, Italic as Italic$1, Underline as Underline$1, Strikethrough, Code as Code$1, Type, Heading1, Heading2, Heading3, AlignLeft, AlignCenter, AlignRight, AlignJustify, List, ListOrdered, CheckSquare, Quote, Palette, Highlighter, Link2, Image as Image$1, Table as Table$1, Settings, Undo, Redo, Eye, RefreshCw, Wand2, Maximize, FileText, Languages, TrendingUp, TrendingDown, ZoomOut, ZoomIn, Download, FileSpreadsheet, FileJson, Maximize2, Move, Menu, Bell, Edit3, LayoutGrid, Upload, Share2, Save, CheckCircle2, Filter, FileDown, ArrowUp, ArrowDown, ArrowUpDown, ChevronsLeft, ChevronsRight, Pin, ExternalLink, CalendarIcon, DollarSign, Users, Github, Star, GitFork, Activity, Server, EyeOff, RotateCw, Zap, Monitor, Timer, Cpu, MemoryStick, HardDrive, Network, CheckCircle, BarChart3, Video, Music, Archive, File, Columns, Sun, Moon, XCircle, Grip, Unlock, Minimize2, Map as Map$1, Target, MoreVertical, BellOff, ArrowDownRight, ArrowUpRight } from 'lucide-react';
|
|
7
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
8
|
import { cva } from 'class-variance-authority';
|
|
9
9
|
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
@@ -56410,12 +56410,17 @@ function Sidebar({
|
|
|
56410
56410
|
document.addEventListener("mousemove", handleMouseMove2);
|
|
56411
56411
|
return () => document.removeEventListener("mousemove", handleMouseMove2);
|
|
56412
56412
|
}, [animatedBackground, mouseX, mouseY]);
|
|
56413
|
-
const toggleSection = (sectionId) => {
|
|
56413
|
+
const toggleSection = useCallback((sectionId) => {
|
|
56414
56414
|
setExpandedSections(
|
|
56415
56415
|
(prev) => prev.includes(sectionId) ? prev.filter((id) => id !== sectionId) : [...prev, sectionId]
|
|
56416
56416
|
);
|
|
56417
|
-
};
|
|
56418
|
-
|
|
56417
|
+
}, []);
|
|
56418
|
+
useCallback((itemId) => {
|
|
56419
|
+
setPinnedItems(
|
|
56420
|
+
(prev) => prev.includes(itemId) ? prev.filter((id) => id !== itemId) : [...prev, itemId]
|
|
56421
|
+
);
|
|
56422
|
+
}, []);
|
|
56423
|
+
const handleItemClick = useCallback((item) => {
|
|
56419
56424
|
if (item.action) {
|
|
56420
56425
|
item.action();
|
|
56421
56426
|
} else if (item.href && onNavigate) {
|
|
@@ -56424,8 +56429,8 @@ function Sidebar({
|
|
|
56424
56429
|
setIsOpen(false);
|
|
56425
56430
|
}
|
|
56426
56431
|
}
|
|
56427
|
-
};
|
|
56428
|
-
const filterItems = (items, query) => {
|
|
56432
|
+
}, [onNavigate, isMobile]);
|
|
56433
|
+
const filterItems = useCallback((items, query) => {
|
|
56429
56434
|
if (!query)
|
|
56430
56435
|
return items;
|
|
56431
56436
|
return items.filter((item) => {
|
|
@@ -56435,8 +56440,14 @@ function Sidebar({
|
|
|
56435
56440
|
);
|
|
56436
56441
|
return matchesTitle || hasMatchingChildren;
|
|
56437
56442
|
});
|
|
56438
|
-
};
|
|
56439
|
-
const
|
|
56443
|
+
}, []);
|
|
56444
|
+
const filteredSections = useMemo(() => {
|
|
56445
|
+
return sections.map((section) => ({
|
|
56446
|
+
...section,
|
|
56447
|
+
filteredItems: filterItems(section.items, searchQuery)
|
|
56448
|
+
})).filter((section) => section.filteredItems.length > 0);
|
|
56449
|
+
}, [sections, searchQuery, filterItems]);
|
|
56450
|
+
const renderItem = useCallback((item, depth = 0) => {
|
|
56440
56451
|
const isActive2 = item.href === activePath;
|
|
56441
56452
|
const isPinned = pinnedItems.includes(item.id);
|
|
56442
56453
|
const hasChildren = item.items && item.items.length > 0;
|
|
@@ -56510,7 +56521,7 @@ function Sidebar({
|
|
|
56510
56521
|
}
|
|
56511
56522
|
) })
|
|
56512
56523
|
] }, item.id);
|
|
56513
|
-
};
|
|
56524
|
+
}, [activePath, pinnedItems, expandedSections, collapsed, customStyles, handleItemClick, toggleSection, searchQuery, filterItems]);
|
|
56514
56525
|
const SidebarContent = () => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
56515
56526
|
/* @__PURE__ */ jsxs("div", { className: cn(
|
|
56516
56527
|
"flex items-center gap-3 p-4 border-b",
|
|
@@ -56571,16 +56582,11 @@ function Sidebar({
|
|
|
56571
56582
|
(section) => section.items.filter((item) => pinnedItems.includes(item.id))
|
|
56572
56583
|
).map((item) => renderItem(item)) })
|
|
56573
56584
|
] }),
|
|
56574
|
-
/* @__PURE__ */ jsx(ScrollArea, { className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ jsx("div", { className: "p-4 space-y-6", children:
|
|
56575
|
-
|
|
56576
|
-
|
|
56577
|
-
|
|
56578
|
-
|
|
56579
|
-
section.title && (!collapsed || isMobile) && /* @__PURE__ */ jsx("h4", { className: "text-xs font-medium text-muted-foreground mb-2", children: section.title }),
|
|
56580
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-1", children: filteredItems.map((item) => renderItem(item)) }),
|
|
56581
|
-
section.showDivider && index < sections.length - 1 && /* @__PURE__ */ jsx(MoonUISeparatorPro, { className: "mt-4" })
|
|
56582
|
-
] }, section.id);
|
|
56583
|
-
}) }) }),
|
|
56585
|
+
/* @__PURE__ */ jsx(ScrollArea, { className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ jsx("div", { className: "p-4 space-y-6", children: filteredSections.map((section, index) => /* @__PURE__ */ jsxs("div", { children: [
|
|
56586
|
+
section.title && (!collapsed || isMobile) && /* @__PURE__ */ jsx("h4", { className: "text-xs font-medium text-muted-foreground mb-2", children: section.title }),
|
|
56587
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1", children: section.filteredItems.map((item) => renderItem(item)) }),
|
|
56588
|
+
section.showDivider && index < filteredSections.length - 1 && /* @__PURE__ */ jsx(MoonUISeparatorPro, { className: "mt-4" })
|
|
56589
|
+
] }, section.id)) }) }),
|
|
56584
56590
|
footer && /* @__PURE__ */ jsxs("div", { className: "border-t p-4", children: [
|
|
56585
56591
|
/* @__PURE__ */ jsx("div", { className: "space-y-1", children: footer.items.map((item) => renderItem(item)) }),
|
|
56586
56592
|
showThemeToggle && (!collapsed || isMobile) && /* @__PURE__ */ jsxs("div", { className: "mt-3 flex items-center justify-between", children: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moontra/moonui-pro",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.6",
|
|
4
4
|
"description": "Premium React components for MoonUI - Advanced UI library with 50+ pro components including performance, interactive, and gesture components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import React, { useState, useEffect, useCallback, useRef } from 'react'
|
|
3
|
+
import React, { useState, useEffect, useCallback, useRef, useMemo } from 'react'
|
|
4
4
|
import { motion, AnimatePresence, useMotionValue, useSpring } from 'framer-motion'
|
|
5
5
|
import { cn } from '../../lib/utils'
|
|
6
6
|
import { Button } from '../ui/button'
|
|
@@ -230,23 +230,23 @@ export function Sidebar({
|
|
|
230
230
|
return () => document.removeEventListener('mousemove', handleMouseMove)
|
|
231
231
|
}, [animatedBackground, mouseX, mouseY])
|
|
232
232
|
|
|
233
|
-
const toggleSection = (sectionId: string) => {
|
|
233
|
+
const toggleSection = useCallback((sectionId: string) => {
|
|
234
234
|
setExpandedSections(prev =>
|
|
235
235
|
prev.includes(sectionId)
|
|
236
236
|
? prev.filter(id => id !== sectionId)
|
|
237
237
|
: [...prev, sectionId]
|
|
238
238
|
)
|
|
239
|
-
}
|
|
239
|
+
}, [])
|
|
240
240
|
|
|
241
|
-
const togglePinItem = (itemId: string) => {
|
|
241
|
+
const togglePinItem = useCallback((itemId: string) => {
|
|
242
242
|
setPinnedItems(prev =>
|
|
243
243
|
prev.includes(itemId)
|
|
244
244
|
? prev.filter(id => id !== itemId)
|
|
245
245
|
: [...prev, itemId]
|
|
246
246
|
)
|
|
247
|
-
}
|
|
247
|
+
}, [])
|
|
248
248
|
|
|
249
|
-
const handleItemClick = (item: SidebarItem) => {
|
|
249
|
+
const handleItemClick = useCallback((item: SidebarItem) => {
|
|
250
250
|
if (item.action) {
|
|
251
251
|
item.action()
|
|
252
252
|
} else if (item.href && onNavigate) {
|
|
@@ -255,9 +255,9 @@ export function Sidebar({
|
|
|
255
255
|
setIsOpen(false)
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
}
|
|
258
|
+
}, [onNavigate, isMobile])
|
|
259
259
|
|
|
260
|
-
const filterItems = (items: SidebarItem[], query: string): SidebarItem[] => {
|
|
260
|
+
const filterItems = useCallback((items: SidebarItem[], query: string): SidebarItem[] => {
|
|
261
261
|
if (!query) return items
|
|
262
262
|
|
|
263
263
|
return items.filter(item => {
|
|
@@ -267,9 +267,17 @@ export function Sidebar({
|
|
|
267
267
|
)
|
|
268
268
|
return matchesTitle || hasMatchingChildren
|
|
269
269
|
})
|
|
270
|
-
}
|
|
270
|
+
}, [])
|
|
271
|
+
|
|
272
|
+
// Filtered sections memoized to prevent re-renders
|
|
273
|
+
const filteredSections = useMemo(() => {
|
|
274
|
+
return sections.map(section => ({
|
|
275
|
+
...section,
|
|
276
|
+
filteredItems: filterItems(section.items, searchQuery)
|
|
277
|
+
})).filter(section => section.filteredItems.length > 0)
|
|
278
|
+
}, [sections, searchQuery, filterItems])
|
|
271
279
|
|
|
272
|
-
const renderItem = (item: SidebarItem, depth = 0) => {
|
|
280
|
+
const renderItem = useCallback((item: SidebarItem, depth = 0) => {
|
|
273
281
|
const isActive = item.href === activePath
|
|
274
282
|
const isPinned = pinnedItems.includes(item.id)
|
|
275
283
|
const hasChildren = item.items && item.items.length > 0
|
|
@@ -374,7 +382,7 @@ export function Sidebar({
|
|
|
374
382
|
)}
|
|
375
383
|
</div>
|
|
376
384
|
)
|
|
377
|
-
}
|
|
385
|
+
}, [activePath, pinnedItems, expandedSections, collapsed, customStyles, handleItemClick, toggleSection, searchQuery, filterItems])
|
|
378
386
|
|
|
379
387
|
const SidebarContent = () => (
|
|
380
388
|
<>
|
|
@@ -458,26 +466,21 @@ export function Sidebar({
|
|
|
458
466
|
{/* Main Content */}
|
|
459
467
|
<ScrollArea className="flex-1 overflow-y-auto">
|
|
460
468
|
<div className="p-4 space-y-6">
|
|
461
|
-
{
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
</h4>
|
|
471
|
-
)}
|
|
472
|
-
<div className="space-y-1">
|
|
473
|
-
{filteredItems.map(item => renderItem(item))}
|
|
474
|
-
</div>
|
|
475
|
-
{section.showDivider && index < sections.length - 1 && (
|
|
476
|
-
<Separator className="mt-4" />
|
|
477
|
-
)}
|
|
469
|
+
{filteredSections.map((section, index) => (
|
|
470
|
+
<div key={section.id}>
|
|
471
|
+
{section.title && (!collapsed || isMobile) && (
|
|
472
|
+
<h4 className="text-xs font-medium text-muted-foreground mb-2">
|
|
473
|
+
{section.title}
|
|
474
|
+
</h4>
|
|
475
|
+
)}
|
|
476
|
+
<div className="space-y-1">
|
|
477
|
+
{section.filteredItems.map(item => renderItem(item))}
|
|
478
478
|
</div>
|
|
479
|
-
|
|
480
|
-
|
|
479
|
+
{section.showDivider && index < filteredSections.length - 1 && (
|
|
480
|
+
<Separator className="mt-4" />
|
|
481
|
+
)}
|
|
482
|
+
</div>
|
|
483
|
+
))}
|
|
481
484
|
</div>
|
|
482
485
|
</ScrollArea>
|
|
483
486
|
|