@moontra/moonui-pro 2.5.10 → 2.5.11
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 +30 -26
- package/package.json +1 -1
- package/src/components/sidebar/index.tsx +43 -34
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
import { twMerge } from 'tailwind-merge';
|
|
3
3
|
import * as t from 'react';
|
|
4
|
-
import t__default, { useState, useRef, useCallback, forwardRef, createContext, useContext, useMemo,
|
|
4
|
+
import t__default, { useState, useRef, useCallback, forwardRef, createContext, useEffect, useContext, useMemo, useDebugValue, Component, useLayoutEffect } from 'react';
|
|
5
5
|
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
6
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';
|
|
@@ -56306,37 +56306,42 @@ var TableRow2 = t__default.memo(({
|
|
|
56306
56306
|
return prevRowId === nextRowId && prevProps.isExpanded === nextProps.isExpanded && prevProps.row.getIsSelected() === nextProps.row.getIsSelected() && prevVisibilityKeys === nextVisibilityKeys && prevVisibilityValues === nextVisibilityValues;
|
|
56307
56307
|
});
|
|
56308
56308
|
TableRow2.displayName = "TableRow";
|
|
56309
|
-
var SearchInput = ({
|
|
56310
|
-
|
|
56311
|
-
|
|
56312
|
-
|
|
56313
|
-
|
|
56314
|
-
|
|
56315
|
-
|
|
56309
|
+
var SearchInput = t__default.forwardRef(({ placeholder, defaultValue, onChange, keyboardShortcuts }, ref) => {
|
|
56310
|
+
const localRef = useRef(null);
|
|
56311
|
+
const inputRef = ref || localRef;
|
|
56312
|
+
const handleChange = useCallback((e) => {
|
|
56313
|
+
onChange(e.target.value);
|
|
56314
|
+
}, [onChange]);
|
|
56315
|
+
useEffect(() => {
|
|
56316
|
+
const input = typeof inputRef === "object" && inputRef?.current;
|
|
56317
|
+
if (input && input.value !== defaultValue) {
|
|
56318
|
+
input.value = defaultValue;
|
|
56319
|
+
}
|
|
56320
|
+
}, [defaultValue, inputRef]);
|
|
56316
56321
|
return /* @__PURE__ */ jsx("div", { className: "p-4 border-b", children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
56317
|
-
/* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" }),
|
|
56322
|
+
/* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none" }),
|
|
56318
56323
|
/* @__PURE__ */ jsx(
|
|
56319
56324
|
"input",
|
|
56320
56325
|
{
|
|
56321
|
-
ref:
|
|
56322
|
-
type: "
|
|
56323
|
-
placeholder
|
|
56324
|
-
|
|
56325
|
-
onChange:
|
|
56326
|
+
ref: inputRef,
|
|
56327
|
+
type: "text",
|
|
56328
|
+
placeholder,
|
|
56329
|
+
defaultValue,
|
|
56330
|
+
onChange: handleChange,
|
|
56326
56331
|
autoComplete: "off",
|
|
56327
56332
|
autoCorrect: "off",
|
|
56328
56333
|
autoCapitalize: "off",
|
|
56329
56334
|
spellCheck: "false",
|
|
56330
56335
|
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"
|
|
56331
|
-
}
|
|
56332
|
-
"sidebar-search-input"
|
|
56336
|
+
}
|
|
56333
56337
|
),
|
|
56334
56338
|
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: [
|
|
56335
56339
|
/* @__PURE__ */ jsx("span", { className: "text-xs", children: "\u2318" }),
|
|
56336
56340
|
"K"
|
|
56337
56341
|
] })
|
|
56338
56342
|
] }) });
|
|
56339
|
-
};
|
|
56343
|
+
});
|
|
56344
|
+
SearchInput.displayName = "SearchInput";
|
|
56340
56345
|
function Sidebar({
|
|
56341
56346
|
sections,
|
|
56342
56347
|
footer,
|
|
@@ -56572,7 +56577,6 @@ function Sidebar({
|
|
|
56572
56577
|
) })
|
|
56573
56578
|
] }, item.id);
|
|
56574
56579
|
}, [activePath, pinnedItems, expandedSections, collapsed, customStyles, handleItemClick, toggleSection]);
|
|
56575
|
-
const MemoizedSearchInput = t__default.memo(SearchInput);
|
|
56576
56580
|
const SidebarHeader = t__default.memo(() => {
|
|
56577
56581
|
return /* @__PURE__ */ jsxs("div", { className: cn(
|
|
56578
56582
|
"flex items-center gap-3 p-4 border-b",
|
|
@@ -56607,20 +56611,20 @@ function Sidebar({
|
|
|
56607
56611
|
)
|
|
56608
56612
|
] });
|
|
56609
56613
|
});
|
|
56610
|
-
const
|
|
56611
|
-
if (!showSearch
|
|
56614
|
+
const searchComponent = useMemo(() => {
|
|
56615
|
+
if (!showSearch)
|
|
56612
56616
|
return null;
|
|
56613
56617
|
return /* @__PURE__ */ jsx(
|
|
56614
|
-
|
|
56618
|
+
SearchInput,
|
|
56615
56619
|
{
|
|
56616
|
-
searchInputRef,
|
|
56617
|
-
searchPlaceholder,
|
|
56618
|
-
|
|
56620
|
+
ref: searchInputRef,
|
|
56621
|
+
placeholder: searchPlaceholder,
|
|
56622
|
+
defaultValue: searchQuery,
|
|
56619
56623
|
onChange: handleSearch,
|
|
56620
56624
|
keyboardShortcuts
|
|
56621
56625
|
}
|
|
56622
56626
|
);
|
|
56623
|
-
});
|
|
56627
|
+
}, [showSearch, searchPlaceholder, keyboardShortcuts, handleSearch]);
|
|
56624
56628
|
const SidebarMenuContent = t__default.memo(() => {
|
|
56625
56629
|
return /* @__PURE__ */ jsx(ScrollArea, { className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "p-4 space-y-6", children: [
|
|
56626
56630
|
pinnedItems.length > 0 && (!collapsed || isMobile) && /* @__PURE__ */ jsxs("div", { children: [
|
|
@@ -56669,7 +56673,7 @@ function Sidebar({
|
|
|
56669
56673
|
const SidebarContent = t__default.memo(() => {
|
|
56670
56674
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
56671
56675
|
/* @__PURE__ */ jsx(SidebarHeader, {}),
|
|
56672
|
-
|
|
56676
|
+
showSearch && (!collapsed || isMobile) && searchComponent,
|
|
56673
56677
|
/* @__PURE__ */ jsx(SidebarMenuContent, {}),
|
|
56674
56678
|
/* @__PURE__ */ jsx(SidebarFooter, {})
|
|
56675
56679
|
] });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moontra/moonui-pro",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.11",
|
|
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",
|
|
@@ -36,31 +36,42 @@ import {
|
|
|
36
36
|
DropdownMenuTrigger,
|
|
37
37
|
} from '../ui/dropdown-menu'
|
|
38
38
|
|
|
39
|
-
// Search Input
|
|
40
|
-
const SearchInput =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
// Uncontrolled Search Input to preserve focus
|
|
40
|
+
const SearchInput = React.forwardRef<
|
|
41
|
+
HTMLInputElement,
|
|
42
|
+
{
|
|
43
|
+
placeholder: string
|
|
44
|
+
defaultValue: string
|
|
45
|
+
onChange: (value: string) => void
|
|
46
|
+
keyboardShortcuts: boolean
|
|
47
|
+
}
|
|
48
|
+
>(({ placeholder, defaultValue, onChange, keyboardShortcuts }, ref) => {
|
|
49
|
+
const localRef = useRef<HTMLInputElement>(null)
|
|
50
|
+
const inputRef = ref || localRef
|
|
51
|
+
|
|
52
|
+
// Use uncontrolled input with onChange
|
|
53
|
+
const handleChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
|
54
|
+
onChange(e.target.value)
|
|
55
|
+
}, [onChange])
|
|
56
|
+
|
|
57
|
+
// Update value programmatically when defaultValue changes
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
const input = typeof inputRef === 'object' && inputRef?.current
|
|
60
|
+
if (input && input.value !== defaultValue) {
|
|
61
|
+
input.value = defaultValue
|
|
62
|
+
}
|
|
63
|
+
}, [defaultValue, inputRef])
|
|
64
|
+
|
|
53
65
|
return (
|
|
54
66
|
<div className="p-4 border-b">
|
|
55
67
|
<div className="relative">
|
|
56
|
-
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" />
|
|
68
|
+
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none" />
|
|
57
69
|
<input
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
onChange={(e) => onChange(e.target.value)}
|
|
70
|
+
ref={inputRef as React.RefObject<HTMLInputElement>}
|
|
71
|
+
type="text"
|
|
72
|
+
placeholder={placeholder}
|
|
73
|
+
defaultValue={defaultValue}
|
|
74
|
+
onChange={handleChange}
|
|
64
75
|
autoComplete="off"
|
|
65
76
|
autoCorrect="off"
|
|
66
77
|
autoCapitalize="off"
|
|
@@ -75,7 +86,8 @@ const SearchInput = ({
|
|
|
75
86
|
</div>
|
|
76
87
|
</div>
|
|
77
88
|
)
|
|
78
|
-
}
|
|
89
|
+
})
|
|
90
|
+
SearchInput.displayName = 'SearchInput'
|
|
79
91
|
|
|
80
92
|
export interface SidebarItem {
|
|
81
93
|
id: string
|
|
@@ -451,8 +463,6 @@ export function Sidebar({
|
|
|
451
463
|
}, [activePath, pinnedItems, expandedSections, collapsed, customStyles, handleItemClick, toggleSection])
|
|
452
464
|
|
|
453
465
|
|
|
454
|
-
// Memoize SearchInput to prevent recreation
|
|
455
|
-
const MemoizedSearchInput = React.memo(SearchInput)
|
|
456
466
|
|
|
457
467
|
// Header Component
|
|
458
468
|
const SidebarHeader = React.memo(() => {
|
|
@@ -498,20 +508,19 @@ export function Sidebar({
|
|
|
498
508
|
)
|
|
499
509
|
})
|
|
500
510
|
|
|
501
|
-
//
|
|
502
|
-
const
|
|
503
|
-
if (!showSearch
|
|
504
|
-
|
|
511
|
+
// Create stable search component with uncontrolled input
|
|
512
|
+
const searchComponent = useMemo(() => {
|
|
513
|
+
if (!showSearch) return null
|
|
505
514
|
return (
|
|
506
|
-
<
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
515
|
+
<SearchInput
|
|
516
|
+
ref={searchInputRef}
|
|
517
|
+
placeholder={searchPlaceholder}
|
|
518
|
+
defaultValue={searchQuery}
|
|
510
519
|
onChange={handleSearch}
|
|
511
520
|
keyboardShortcuts={keyboardShortcuts}
|
|
512
521
|
/>
|
|
513
522
|
)
|
|
514
|
-
})
|
|
523
|
+
}, [showSearch, searchPlaceholder, keyboardShortcuts, handleSearch]) // Only re-create when these stable props change
|
|
515
524
|
|
|
516
525
|
// Menu Content
|
|
517
526
|
const SidebarMenuContent = React.memo(() => {
|
|
@@ -596,7 +605,7 @@ export function Sidebar({
|
|
|
596
605
|
return (
|
|
597
606
|
<>
|
|
598
607
|
<SidebarHeader />
|
|
599
|
-
|
|
608
|
+
{showSearch && (!collapsed || isMobile) && searchComponent}
|
|
600
609
|
<SidebarMenuContent />
|
|
601
610
|
<SidebarFooter />
|
|
602
611
|
</>
|