@moontra/moonui-pro 2.5.6 → 2.5.8
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.d.ts +1 -0
- package/dist/index.mjs +25 -16
- package/package.json +1 -1
- package/src/components/sidebar/index.tsx +25 -15
package/dist/index.d.ts
CHANGED
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, Pin, ExternalLink, CalendarIcon, DollarSign, Users, Github, Star, GitFork, Activity, Server, EyeOff, RotateCw, Zap,
|
|
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, Sun, Moon, Monitor, ExternalLink, CalendarIcon, DollarSign, Users, Github, Star, GitFork, Activity, Server, EyeOff, RotateCw, Zap, Timer, Cpu, MemoryStick, HardDrive, Network, CheckCircle, BarChart3, Video, Music, Archive, File, Columns, 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';
|
|
@@ -56430,6 +56430,10 @@ function Sidebar({
|
|
|
56430
56430
|
}
|
|
56431
56431
|
}
|
|
56432
56432
|
}, [onNavigate, isMobile]);
|
|
56433
|
+
const handleSearchChange = useCallback((value) => {
|
|
56434
|
+
setSearchQuery(value);
|
|
56435
|
+
onSearchChange?.(value);
|
|
56436
|
+
}, [onSearchChange]);
|
|
56433
56437
|
const filterItems = useCallback((items, query) => {
|
|
56434
56438
|
if (!query)
|
|
56435
56439
|
return items;
|
|
@@ -56444,10 +56448,13 @@ function Sidebar({
|
|
|
56444
56448
|
const filteredSections = useMemo(() => {
|
|
56445
56449
|
return sections.map((section) => ({
|
|
56446
56450
|
...section,
|
|
56447
|
-
filteredItems: filterItems(section.items, searchQuery)
|
|
56451
|
+
filteredItems: filterItems(section.items, searchQuery).map((item) => ({
|
|
56452
|
+
...item,
|
|
56453
|
+
filteredChildren: item.items ? filterItems(item.items, searchQuery) : void 0
|
|
56454
|
+
}))
|
|
56448
56455
|
})).filter((section) => section.filteredItems.length > 0);
|
|
56449
56456
|
}, [sections, searchQuery, filterItems]);
|
|
56450
|
-
const renderItem = useCallback((item, depth = 0) => {
|
|
56457
|
+
const renderItem = useCallback((item, depth = 0, filteredChildren) => {
|
|
56451
56458
|
const isActive2 = item.href === activePath;
|
|
56452
56459
|
const isPinned = pinnedItems.includes(item.id);
|
|
56453
56460
|
const hasChildren = item.items && item.items.length > 0;
|
|
@@ -56507,7 +56514,7 @@ function Sidebar({
|
|
|
56507
56514
|
/* @__PURE__ */ jsx(ItemWrapper, { children: itemContent }),
|
|
56508
56515
|
/* @__PURE__ */ jsx(MoonUITooltipContentPro, { side: "right", children: /* @__PURE__ */ jsx("p", { children: item.tooltip }) })
|
|
56509
56516
|
] }) }) : itemContent,
|
|
56510
|
-
hasChildren && !collapsed && /* @__PURE__ */ jsx(AnimatePresence, { children: isExpanded && /* @__PURE__ */ jsx(
|
|
56517
|
+
hasChildren && !collapsed && filteredChildren && /* @__PURE__ */ jsx(AnimatePresence, { children: isExpanded && /* @__PURE__ */ jsx(
|
|
56511
56518
|
motion.div,
|
|
56512
56519
|
{
|
|
56513
56520
|
initial: { height: 0, opacity: 0 },
|
|
@@ -56515,14 +56522,14 @@ function Sidebar({
|
|
|
56515
56522
|
exit: { height: 0, opacity: 0 },
|
|
56516
56523
|
transition: { duration: 0.2 },
|
|
56517
56524
|
className: "overflow-hidden",
|
|
56518
|
-
children: /* @__PURE__ */ jsx("div", { className: "pt-1 space-y-1", children:
|
|
56525
|
+
children: /* @__PURE__ */ jsx("div", { className: "pt-1 space-y-1", children: filteredChildren.map(
|
|
56519
56526
|
(child) => renderItem(child, depth + 1)
|
|
56520
56527
|
) })
|
|
56521
56528
|
}
|
|
56522
56529
|
) })
|
|
56523
56530
|
] }, item.id);
|
|
56524
|
-
}, [activePath, pinnedItems, expandedSections, collapsed, customStyles, handleItemClick, toggleSection
|
|
56525
|
-
const SidebarContent = () => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
56531
|
+
}, [activePath, pinnedItems, expandedSections, collapsed, customStyles, handleItemClick, toggleSection]);
|
|
56532
|
+
const SidebarContent = t__default.memo(() => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
56526
56533
|
/* @__PURE__ */ jsxs("div", { className: cn(
|
|
56527
56534
|
"flex items-center gap-3 p-4 border-b",
|
|
56528
56535
|
collapsed && !isMobile && "justify-center px-2"
|
|
@@ -56558,18 +56565,20 @@ function Sidebar({
|
|
|
56558
56565
|
showSearch && (!collapsed || isMobile) && /* @__PURE__ */ jsx("div", { className: "p-4 border-b", children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
56559
56566
|
/* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" }),
|
|
56560
56567
|
/* @__PURE__ */ jsx(
|
|
56561
|
-
|
|
56568
|
+
"input",
|
|
56562
56569
|
{
|
|
56563
56570
|
ref: searchInputRef,
|
|
56564
56571
|
type: "search",
|
|
56565
56572
|
placeholder: searchPlaceholder,
|
|
56566
56573
|
value: searchQuery,
|
|
56567
|
-
onChange: (e) =>
|
|
56568
|
-
|
|
56569
|
-
|
|
56570
|
-
|
|
56571
|
-
|
|
56572
|
-
|
|
56574
|
+
onChange: (e) => handleSearchChange(e.target.value),
|
|
56575
|
+
autoComplete: "off",
|
|
56576
|
+
autoCorrect: "off",
|
|
56577
|
+
autoCapitalize: "off",
|
|
56578
|
+
spellCheck: "false",
|
|
56579
|
+
className: "w-full h-10 pl-9 pr-9 text-sm bg-background border border-input rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
|
|
56580
|
+
},
|
|
56581
|
+
"sidebar-search-input"
|
|
56573
56582
|
),
|
|
56574
56583
|
keyboardShortcuts && /* @__PURE__ */ jsxs("kbd", { className: "absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none h-5 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 hidden sm:flex", children: [
|
|
56575
56584
|
/* @__PURE__ */ jsx("span", { className: "text-xs", children: "\u2318" }),
|
|
@@ -56584,7 +56593,7 @@ function Sidebar({
|
|
|
56584
56593
|
] }),
|
|
56585
56594
|
/* @__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
56595
|
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)) }),
|
|
56596
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1", children: section.filteredItems.map((item) => renderItem(item, 0, item.filteredChildren)) }),
|
|
56588
56597
|
section.showDivider && index < filteredSections.length - 1 && /* @__PURE__ */ jsx(MoonUISeparatorPro, { className: "mt-4" })
|
|
56589
56598
|
] }, section.id)) }) }),
|
|
56590
56599
|
footer && /* @__PURE__ */ jsxs("div", { className: "border-t p-4", children: [
|
|
@@ -56614,7 +56623,7 @@ function Sidebar({
|
|
|
56614
56623
|
] })
|
|
56615
56624
|
] })
|
|
56616
56625
|
] })
|
|
56617
|
-
] });
|
|
56626
|
+
] }));
|
|
56618
56627
|
const sidebarClasses = cn(
|
|
56619
56628
|
"flex h-full flex-col bg-background border-r",
|
|
56620
56629
|
glassmorphism && "bg-background/80 backdrop-blur-xl border-white/10",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moontra/moonui-pro",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.8",
|
|
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",
|
|
@@ -28,7 +28,6 @@ import {
|
|
|
28
28
|
Sparkles,
|
|
29
29
|
Command
|
|
30
30
|
} from 'lucide-react'
|
|
31
|
-
import { Input } from '../ui/input'
|
|
32
31
|
import {
|
|
33
32
|
DropdownMenu,
|
|
34
33
|
DropdownMenuContent,
|
|
@@ -48,6 +47,7 @@ export interface SidebarItem {
|
|
|
48
47
|
items?: SidebarItem[]
|
|
49
48
|
action?: () => void
|
|
50
49
|
tooltip?: string
|
|
50
|
+
filteredChildren?: SidebarItem[]
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export interface SidebarSection {
|
|
@@ -257,6 +257,11 @@ export function Sidebar({
|
|
|
257
257
|
}
|
|
258
258
|
}, [onNavigate, isMobile])
|
|
259
259
|
|
|
260
|
+
const handleSearchChange = useCallback((value: string) => {
|
|
261
|
+
setSearchQuery(value)
|
|
262
|
+
onSearchChange?.(value)
|
|
263
|
+
}, [onSearchChange])
|
|
264
|
+
|
|
260
265
|
const filterItems = useCallback((items: SidebarItem[], query: string): SidebarItem[] => {
|
|
261
266
|
if (!query) return items
|
|
262
267
|
|
|
@@ -273,11 +278,14 @@ export function Sidebar({
|
|
|
273
278
|
const filteredSections = useMemo(() => {
|
|
274
279
|
return sections.map(section => ({
|
|
275
280
|
...section,
|
|
276
|
-
filteredItems: filterItems(section.items, searchQuery)
|
|
281
|
+
filteredItems: filterItems(section.items, searchQuery).map(item => ({
|
|
282
|
+
...item,
|
|
283
|
+
filteredChildren: item.items ? filterItems(item.items, searchQuery) : undefined
|
|
284
|
+
}))
|
|
277
285
|
})).filter(section => section.filteredItems.length > 0)
|
|
278
286
|
}, [sections, searchQuery, filterItems])
|
|
279
287
|
|
|
280
|
-
const renderItem = useCallback((item: SidebarItem, depth = 0) => {
|
|
288
|
+
const renderItem = useCallback((item: SidebarItem, depth = 0, filteredChildren?: SidebarItem[]) => {
|
|
281
289
|
const isActive = item.href === activePath
|
|
282
290
|
const isPinned = pinnedItems.includes(item.id)
|
|
283
291
|
const hasChildren = item.items && item.items.length > 0
|
|
@@ -361,7 +369,7 @@ export function Sidebar({
|
|
|
361
369
|
itemContent
|
|
362
370
|
)}
|
|
363
371
|
|
|
364
|
-
{hasChildren && !collapsed && (
|
|
372
|
+
{hasChildren && !collapsed && filteredChildren && (
|
|
365
373
|
<AnimatePresence>
|
|
366
374
|
{isExpanded && (
|
|
367
375
|
<motion.div
|
|
@@ -372,7 +380,7 @@ export function Sidebar({
|
|
|
372
380
|
className="overflow-hidden"
|
|
373
381
|
>
|
|
374
382
|
<div className="pt-1 space-y-1">
|
|
375
|
-
{
|
|
383
|
+
{filteredChildren.map(child =>
|
|
376
384
|
renderItem(child, depth + 1)
|
|
377
385
|
)}
|
|
378
386
|
</div>
|
|
@@ -382,9 +390,9 @@ export function Sidebar({
|
|
|
382
390
|
)}
|
|
383
391
|
</div>
|
|
384
392
|
)
|
|
385
|
-
}, [activePath, pinnedItems, expandedSections, collapsed, customStyles, handleItemClick, toggleSection
|
|
393
|
+
}, [activePath, pinnedItems, expandedSections, collapsed, customStyles, handleItemClick, toggleSection])
|
|
386
394
|
|
|
387
|
-
const SidebarContent = () => (
|
|
395
|
+
const SidebarContent = React.memo(() => (
|
|
388
396
|
<>
|
|
389
397
|
{/* Header */}
|
|
390
398
|
<div className={cn(
|
|
@@ -431,16 +439,18 @@ export function Sidebar({
|
|
|
431
439
|
<div className="p-4 border-b">
|
|
432
440
|
<div className="relative">
|
|
433
441
|
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" />
|
|
434
|
-
<
|
|
442
|
+
<input
|
|
443
|
+
key="sidebar-search-input"
|
|
435
444
|
ref={searchInputRef}
|
|
436
445
|
type="search"
|
|
437
446
|
placeholder={searchPlaceholder}
|
|
438
447
|
value={searchQuery}
|
|
439
|
-
onChange={(e) =>
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
448
|
+
onChange={(e) => handleSearchChange(e.target.value)}
|
|
449
|
+
autoComplete="off"
|
|
450
|
+
autoCorrect="off"
|
|
451
|
+
autoCapitalize="off"
|
|
452
|
+
spellCheck="false"
|
|
453
|
+
className="w-full h-10 pl-9 pr-9 text-sm bg-background border border-input rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
|
|
444
454
|
/>
|
|
445
455
|
{keyboardShortcuts && (
|
|
446
456
|
<kbd className="absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none h-5 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 hidden sm:flex">
|
|
@@ -474,7 +484,7 @@ export function Sidebar({
|
|
|
474
484
|
</h4>
|
|
475
485
|
)}
|
|
476
486
|
<div className="space-y-1">
|
|
477
|
-
{section.filteredItems.map(item => renderItem(item))}
|
|
487
|
+
{section.filteredItems.map(item => renderItem(item, 0, item.filteredChildren))}
|
|
478
488
|
</div>
|
|
479
489
|
{section.showDivider && index < filteredSections.length - 1 && (
|
|
480
490
|
<Separator className="mt-4" />
|
|
@@ -522,7 +532,7 @@ export function Sidebar({
|
|
|
522
532
|
</div>
|
|
523
533
|
)}
|
|
524
534
|
</>
|
|
525
|
-
)
|
|
535
|
+
))
|
|
526
536
|
|
|
527
537
|
const sidebarClasses = cn(
|
|
528
538
|
"flex h-full flex-col bg-background border-r",
|