@moontra/moonui-pro 2.5.9 → 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 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, useEffect, useDebugValue, Component, useLayoutEffect } from 'react';
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,25 +56306,27 @@ 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 = t__default.memo(({
56310
- searchInputRef,
56311
- searchPlaceholder,
56312
- value,
56313
- onChange,
56314
- keyboardShortcuts
56315
- }) => {
56309
+ var SearchInput = t__default.forwardRef(({ placeholder, defaultValue, onChange, keyboardShortcuts }, ref) => {
56310
+ const localRef = useRef(null);
56311
+ const inputRef = ref || localRef;
56316
56312
  const handleChange = useCallback((e) => {
56317
56313
  onChange(e.target.value);
56318
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]);
56319
56321
  return /* @__PURE__ */ jsx("div", { className: "p-4 border-b", children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
56320
- /* @__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" }),
56321
56323
  /* @__PURE__ */ jsx(
56322
56324
  "input",
56323
56325
  {
56324
- ref: searchInputRef,
56325
- type: "search",
56326
- placeholder: searchPlaceholder,
56327
- value,
56326
+ ref: inputRef,
56327
+ type: "text",
56328
+ placeholder,
56329
+ defaultValue,
56328
56330
  onChange: handleChange,
56329
56331
  autoComplete: "off",
56330
56332
  autoCorrect: "off",
@@ -56339,6 +56341,7 @@ var SearchInput = t__default.memo(({
56339
56341
  ] })
56340
56342
  ] }) });
56341
56343
  });
56344
+ SearchInput.displayName = "SearchInput";
56342
56345
  function Sidebar({
56343
56346
  sections,
56344
56347
  footer,
@@ -56608,23 +56611,20 @@ function Sidebar({
56608
56611
  )
56609
56612
  ] });
56610
56613
  });
56611
- const searchElement = useMemo(() => {
56614
+ const searchComponent = useMemo(() => {
56612
56615
  if (!showSearch)
56613
56616
  return null;
56614
56617
  return /* @__PURE__ */ jsx(
56615
56618
  SearchInput,
56616
56619
  {
56617
- searchInputRef,
56618
- searchPlaceholder,
56619
- value: searchQuery,
56620
+ ref: searchInputRef,
56621
+ placeholder: searchPlaceholder,
56622
+ defaultValue: searchQuery,
56620
56623
  onChange: handleSearch,
56621
56624
  keyboardShortcuts
56622
56625
  }
56623
56626
  );
56624
- }, [showSearch, searchPlaceholder, searchQuery, handleSearch, keyboardShortcuts]);
56625
- const SidebarSearch = t__default.memo(() => {
56626
- return showSearch && (!collapsed || isMobile) ? searchElement : null;
56627
- });
56627
+ }, [showSearch, searchPlaceholder, keyboardShortcuts, handleSearch]);
56628
56628
  const SidebarMenuContent = t__default.memo(() => {
56629
56629
  return /* @__PURE__ */ jsx(ScrollArea, { className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "p-4 space-y-6", children: [
56630
56630
  pinnedItems.length > 0 && (!collapsed || isMobile) && /* @__PURE__ */ jsxs("div", { children: [
@@ -56673,7 +56673,7 @@ function Sidebar({
56673
56673
  const SidebarContent = t__default.memo(() => {
56674
56674
  return /* @__PURE__ */ jsxs(Fragment, { children: [
56675
56675
  /* @__PURE__ */ jsx(SidebarHeader, {}),
56676
- /* @__PURE__ */ jsx(SidebarSearch, {}),
56676
+ showSearch && (!collapsed || isMobile) && searchComponent,
56677
56677
  /* @__PURE__ */ jsx(SidebarMenuContent, {}),
56678
56678
  /* @__PURE__ */ jsx(SidebarFooter, {})
56679
56679
  ] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "2.5.9",
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,33 +36,41 @@ import {
36
36
  DropdownMenuTrigger,
37
37
  } from '../ui/dropdown-menu'
38
38
 
39
- // Search Input Component
40
- const SearchInput = React.memo(({
41
- searchInputRef,
42
- searchPlaceholder,
43
- value,
44
- onChange,
45
- keyboardShortcuts
46
- }: {
47
- searchInputRef: React.RefObject<HTMLInputElement | null>
48
- searchPlaceholder: string
49
- value: string
50
- onChange: (value: string) => void
51
- keyboardShortcuts: boolean
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
53
  const handleChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
54
54
  onChange(e.target.value)
55
55
  }, [onChange])
56
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
+
57
65
  return (
58
66
  <div className="p-4 border-b">
59
67
  <div className="relative">
60
- <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" />
61
69
  <input
62
- ref={searchInputRef}
63
- type="search"
64
- placeholder={searchPlaceholder}
65
- value={value}
70
+ ref={inputRef as React.RefObject<HTMLInputElement>}
71
+ type="text"
72
+ placeholder={placeholder}
73
+ defaultValue={defaultValue}
66
74
  onChange={handleChange}
67
75
  autoComplete="off"
68
76
  autoCorrect="off"
@@ -79,6 +87,7 @@ const SearchInput = React.memo(({
79
87
  </div>
80
88
  )
81
89
  })
90
+ SearchInput.displayName = 'SearchInput'
82
91
 
83
92
  export interface SidebarItem {
84
93
  id: string
@@ -454,6 +463,7 @@ export function Sidebar({
454
463
  }, [activePath, pinnedItems, expandedSections, collapsed, customStyles, handleItemClick, toggleSection])
455
464
 
456
465
 
466
+
457
467
  // Header Component
458
468
  const SidebarHeader = React.memo(() => {
459
469
  return (
@@ -498,25 +508,19 @@ export function Sidebar({
498
508
  )
499
509
  })
500
510
 
501
- // Search element with controlled value
502
- const searchElement = useMemo(() => {
511
+ // Create stable search component with uncontrolled input
512
+ const searchComponent = useMemo(() => {
503
513
  if (!showSearch) return null
504
-
505
514
  return (
506
515
  <SearchInput
507
- searchInputRef={searchInputRef}
508
- searchPlaceholder={searchPlaceholder}
509
- value={searchQuery}
516
+ ref={searchInputRef}
517
+ placeholder={searchPlaceholder}
518
+ defaultValue={searchQuery}
510
519
  onChange={handleSearch}
511
520
  keyboardShortcuts={keyboardShortcuts}
512
521
  />
513
522
  )
514
- }, [showSearch, searchPlaceholder, searchQuery, handleSearch, keyboardShortcuts])
515
-
516
- // Search Component wrapper
517
- const SidebarSearch = React.memo(() => {
518
- return showSearch && (!collapsed || isMobile) ? searchElement : null
519
- })
523
+ }, [showSearch, searchPlaceholder, keyboardShortcuts, handleSearch]) // Only re-create when these stable props change
520
524
 
521
525
  // Menu Content
522
526
  const SidebarMenuContent = React.memo(() => {
@@ -601,7 +605,7 @@ export function Sidebar({
601
605
  return (
602
606
  <>
603
607
  <SidebarHeader />
604
- <SidebarSearch />
608
+ {showSearch && (!collapsed || isMobile) && searchComponent}
605
609
  <SidebarMenuContent />
606
610
  <SidebarFooter />
607
611
  </>