@moontra/moonui-pro 2.24.6 → 2.24.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.mjs CHANGED
@@ -4,7 +4,7 @@ import { twMerge } from 'tailwind-merge';
4
4
  import * as t from 'react';
5
5
  import t__default, { useState, useMemo, useCallback, useRef, useEffect, forwardRef, createContext, useContext, useLayoutEffect, useDebugValue, Component } from 'react';
6
6
  import * as AccordionPrimitive2 from '@radix-ui/react-accordion';
7
- import { Loader2, Play, ExternalLink, ChevronDown, Info, AlertCircle, AlertTriangle, Check, X, MoreHorizontal, Minus, Clock, ChevronUp, Search, Mic, MicOff, Settings, RefreshCw, Zap, ChevronRight, Crown, Circle, ChevronLeft, Plus, Lock, Sparkles, ZoomOut, ZoomIn, Pause, VolumeX, Volume2, Download, Maximize2, Filter, Image as Image$1, Video, RotateCw, Minimize2, Phone, Globe, Upload, Eye, CheckCircle2, RotateCcw, Copy, Share, Trash2, CreditCard, XCircle, HelpCircle, Bold as Bold$1, Italic as Italic$1, Underline as Underline$1, Strikethrough, AlignLeft, AlignCenter, AlignRight, AlignJustify, List, ListOrdered, Quote, Code as Code$1, Link as Link$1, Palette, Undo, Redo, Edit, GripVertical, Type, Heading1, Heading2, Heading3, CheckSquare, Highlighter, Link2, Table as Table$1, Wand2, Maximize, FileText, Briefcase, MessageSquare, Heart, GraduationCap, Languages, Lightbulb, BarChart3, Music, Archive, File, FileSpreadsheet, FileJson, FileDown, ArrowUp, ArrowDown, ArrowUpDown, ChevronsLeft, ChevronsRight, CheckCircle, Star, Shield, Award, Gem, Flame, Menu, Calendar as Calendar$1, Repeat, MapPin, Users, User, Move, EyeOff, Timer, Square, Cpu, Target, GitBranch, ArrowRight, MoreVertical, Trash, TrendingUp, MessageCircle, Paperclip, Printer, TrendingDown, Bell, CheckCheck, Settings2, LogOut, Edit3, LayoutGrid, Share2, Save, Github, Activity, Server, Monitor, MemoryStick, HardDrive, Network, Columns, Pin, Sun, Moon, Send, Tag, Flag, BellOff, CalendarIcon, DollarSign, Trophy, ArrowDownRight, ArrowUpRight, Grip, Unlock, Map as Map$1, GitFork, Package } from 'lucide-react';
7
+ import { Loader2, Play, ExternalLink, ChevronDown, Info, AlertCircle, AlertTriangle, Check, X, MoreHorizontal, Minus, Clock, ChevronUp, Search, Mic, MicOff, Settings, RefreshCw, Zap, ChevronRight, Crown, Circle, ChevronLeft, Plus, Lock, Sparkles, ZoomOut, ZoomIn, Pause, VolumeX, Volume2, Download, Maximize2, Filter, Image as Image$1, Video, RotateCw, Minimize2, Phone, Globe, Upload, Eye, CheckCircle2, RotateCcw, Copy, Share, Trash2, CreditCard, XCircle, HelpCircle, Bold as Bold$1, Italic as Italic$1, Underline as Underline$1, Strikethrough, AlignLeft, AlignCenter, AlignRight, AlignJustify, List, ListOrdered, Quote, Code as Code$1, Link as Link$1, Palette, Undo, Redo, Edit, GripVertical, Type, Heading1, Heading2, Heading3, CheckSquare, Highlighter, Link2, Table as Table$1, Wand2, Maximize, FileText, Briefcase, MessageSquare, Heart, GraduationCap, Languages, Lightbulb, BarChart3, Music, Archive, File, FileSpreadsheet, FileJson, FileDown, ArrowUp, ArrowDown, ArrowUpDown, ChevronsLeft, ChevronsRight, CheckCircle, Star, Shield, Award, Gem, Flame, Menu, Calendar as Calendar$1, Repeat, MapPin, Users, User, Move, EyeOff, Timer, Square, Cpu, Target, GitBranch, ArrowRight, MoreVertical, Trash, TrendingUp, MessageCircle, Paperclip, Printer, TrendingDown, Bell, CheckCheck, Settings2, LogOut, Edit3, LayoutGrid, Share2, Save, Github, Activity, Server, Monitor, MemoryStick, HardDrive, Network, Columns, Pin, Sun, Moon, Send, Tag, Flag, BellOff, CalendarIcon, DollarSign, Map as Map$1, Trophy, ArrowDownRight, ArrowUpRight, Grip, Unlock, GitFork, Package } from 'lucide-react';
8
8
  import { cva } from 'class-variance-authority';
9
9
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
10
  import * as AvatarPrimitive from '@radix-ui/react-avatar';
@@ -65070,68 +65070,54 @@ function DashboardInternal({
65070
65070
  brandName
65071
65071
  }) {
65072
65072
  const [editMode, setEditMode] = t__default.useState(false);
65073
- const [widgets, setWidgets] = t__default.useState(initialWidgets);
65073
+ const [widgets, setWidgets] = t__default.useState(() => initialWidgets);
65074
65074
  const [selectedTheme, setSelectedTheme] = t__default.useState("analytics");
65075
- const [timeRange, setTimeRange] = t__default.useState(propTimeRange);
65075
+ const [timeRange, setTimeRange] = t__default.useState(() => propTimeRange);
65076
65076
  const [searchQuery, setSearchQuery] = t__default.useState("");
65077
65077
  const [showWidgetLibrary, setShowWidgetLibrary] = t__default.useState(false);
65078
65078
  const [showTemplates, setShowTemplates] = t__default.useState(false);
65079
65079
  const [refreshing, setRefreshing] = t__default.useState(false);
65080
65080
  const [showNotifications, setShowNotifications] = t__default.useState(false);
65081
+ const prevInitialWidgetsRef = t__default.useRef(initialWidgets);
65082
+ const prevTimeRangeRef = t__default.useRef(propTimeRange);
65081
65083
  t__default.useEffect(() => {
65082
- setWidgets(initialWidgets);
65084
+ if (prevInitialWidgetsRef.current !== initialWidgets) {
65085
+ prevInitialWidgetsRef.current = initialWidgets;
65086
+ setWidgets(initialWidgets);
65087
+ }
65083
65088
  }, [initialWidgets]);
65084
65089
  t__default.useEffect(() => {
65085
- if (propTimeRange) {
65090
+ if (propTimeRange && prevTimeRangeRef.current !== propTimeRange) {
65091
+ prevTimeRangeRef.current = propTimeRange;
65086
65092
  setTimeRange(propTimeRange);
65087
65093
  }
65088
65094
  }, [propTimeRange]);
65089
65095
  t__default.useEffect(() => {
65090
- if (!realtime)
65096
+ if (!realtime || mode !== "widgets")
65091
65097
  return;
65092
65098
  const interval = setInterval(() => {
65093
- setWidgets((prev) => prev.map((widget) => {
65094
- if (widget.type === "metric" && widget.data) {
65095
- const newValue = typeof widget.data.value === "number" ? widget.data.value + Math.floor(Math.random() * 10 - 5) : widget.data.value;
65096
- return {
65097
- ...widget,
65098
- data: {
65099
- ...widget.data,
65100
- value: newValue,
65101
- lastUpdated: /* @__PURE__ */ new Date()
65102
- }
65103
- };
65104
- }
65105
- return widget;
65106
- }));
65099
+ setWidgets((prev) => {
65100
+ if (!prev || prev.length === 0)
65101
+ return prev;
65102
+ return prev.map((widget) => {
65103
+ if (widget.type === "metric" && widget.data) {
65104
+ const newValue = typeof widget.data.value === "number" ? widget.data.value + Math.floor(Math.random() * 10 - 5) : widget.data.value;
65105
+ return {
65106
+ ...widget,
65107
+ data: {
65108
+ ...widget.data,
65109
+ value: newValue,
65110
+ lastUpdated: /* @__PURE__ */ new Date()
65111
+ }
65112
+ };
65113
+ }
65114
+ return widget;
65115
+ });
65116
+ });
65107
65117
  }, 5e3);
65108
65118
  return () => clearInterval(interval);
65109
- }, [realtime]);
65110
- const handleAddWidget = (type) => {
65111
- const newWidget = {
65112
- id: `widget-${Date.now()}`,
65113
- type,
65114
- title: `New ${type} Widget`,
65115
- size: { w: 3, h: 3 },
65116
- position: { x: 0, y: 0 },
65117
- data: generateDefaultData(type)
65118
- };
65119
- setWidgets((prev) => [...prev, newWidget]);
65120
- onWidgetAdd?.(newWidget);
65121
- setShowWidgetLibrary(false);
65122
- };
65123
- const applyTemplate = (template) => {
65124
- const newWidgets = template.widgets.map((w, index2) => ({
65125
- ...w,
65126
- id: `widget-${Date.now()}-${index2}`,
65127
- position: w.position || { x: index2 * 3 % 12, y: Math.floor(index2 * 3 / 12) * 3 },
65128
- size: w.size || { w: 3, h: 3 }
65129
- }));
65130
- setWidgets(newWidgets);
65131
- setSelectedTheme(template.theme);
65132
- setShowTemplates(false);
65133
- };
65134
- const generateDefaultData = (type) => {
65119
+ }, [realtime, mode]);
65120
+ const generateDefaultData = t__default.useCallback((type) => {
65135
65121
  switch (type) {
65136
65122
  case "metric":
65137
65123
  return {
@@ -65160,96 +65146,128 @@ function DashboardInternal({
65160
65146
  default:
65161
65147
  return {};
65162
65148
  }
65163
- };
65164
- const WidgetLibrary = () => /* @__PURE__ */ jsx(Sheet, { open: showWidgetLibrary, onOpenChange: setShowWidgetLibrary, children: /* @__PURE__ */ jsxs(SheetContent, { className: cn(
65165
- "w-[400px] sm:w-[540px]",
65166
- glassmorphism && "bg-background/95 backdrop-blur-md"
65167
- ), children: [
65168
- /* @__PURE__ */ jsxs(SheetHeader, { children: [
65169
- /* @__PURE__ */ jsx(SheetTitle, { children: "Widget Library" }),
65170
- /* @__PURE__ */ jsx(SheetDescription, { children: "Add widgets to customize your dashboard" })
65171
- ] }),
65172
- /* @__PURE__ */ jsxs("div", { className: "mt-6 space-y-4", children: [
65173
- /* @__PURE__ */ jsxs("div", { className: "relative", children: [
65174
- /* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-3 h-4 w-4 text-muted-foreground" }),
65175
- /* @__PURE__ */ jsx(
65176
- MoonUIInputPro,
65177
- {
65178
- placeholder: "Search widgets...",
65179
- value: searchQuery,
65180
- onChange: (e) => {
65181
- setSearchQuery(e.target.value);
65182
- onSearch?.(e.target.value);
65183
- },
65184
- className: "pl-10"
65185
- }
65186
- )
65149
+ }, []);
65150
+ const handleAddWidget = t__default.useCallback((type) => {
65151
+ const newWidget = {
65152
+ id: `widget-${Date.now()}`,
65153
+ type,
65154
+ title: `New ${type} Widget`,
65155
+ size: { w: 3, h: 3 },
65156
+ position: { x: 0, y: 0 },
65157
+ data: generateDefaultData(type)
65158
+ };
65159
+ setWidgets((prev) => [...prev, newWidget]);
65160
+ onWidgetAdd?.(newWidget);
65161
+ setShowWidgetLibrary(false);
65162
+ }, [onWidgetAdd, generateDefaultData]);
65163
+ const applyTemplate = t__default.useCallback((template) => {
65164
+ const newWidgets = template.widgets.map((w, index2) => ({
65165
+ ...w,
65166
+ id: `widget-${Date.now()}-${index2}`,
65167
+ position: w.position || { x: index2 * 3 % 12, y: Math.floor(index2 * 3 / 12) * 3 },
65168
+ size: w.size || { w: 3, h: 3 }
65169
+ }));
65170
+ setWidgets(newWidgets);
65171
+ setSelectedTheme(template.theme);
65172
+ setShowTemplates(false);
65173
+ }, []);
65174
+ const WidgetLibrary = t__default.useCallback(() => {
65175
+ if (!showWidgetLibrary)
65176
+ return null;
65177
+ return /* @__PURE__ */ jsx(Sheet, { open: showWidgetLibrary, onOpenChange: setShowWidgetLibrary, children: /* @__PURE__ */ jsxs(SheetContent, { className: cn(
65178
+ "w-[400px] sm:w-[540px]",
65179
+ glassmorphism && "bg-background/95 backdrop-blur-md"
65180
+ ), children: [
65181
+ /* @__PURE__ */ jsxs(SheetHeader, { children: [
65182
+ /* @__PURE__ */ jsx(SheetTitle, { children: "Widget Library" }),
65183
+ /* @__PURE__ */ jsx(SheetDescription, { children: "Add widgets to customize your dashboard" })
65187
65184
  ] }),
65188
- /* @__PURE__ */ jsx(ScrollArea, { className: "h-[calc(100vh-200px)]", children: /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-4", children: Object.entries(WIDGET_TYPE_ICONS).filter(([type]) => type.toLowerCase().includes(searchQuery.toLowerCase())).map(([type, icon]) => /* @__PURE__ */ jsx(
65189
- motion.div,
65190
- {
65191
- whileHover: { scale: 1.02 },
65192
- whileTap: { scale: 0.98 },
65193
- children: /* @__PURE__ */ jsxs(
65194
- MoonUIButtonPro,
65185
+ /* @__PURE__ */ jsxs("div", { className: "mt-6 space-y-4", children: [
65186
+ /* @__PURE__ */ jsxs("div", { className: "relative", children: [
65187
+ /* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-3 h-4 w-4 text-muted-foreground" }),
65188
+ /* @__PURE__ */ jsx(
65189
+ MoonUIInputPro,
65195
65190
  {
65196
- variant: "outline",
65197
- className: "w-full h-24 flex-col gap-2",
65198
- onClick: () => handleAddWidget(type),
65199
- children: [
65200
- /* @__PURE__ */ jsx("div", { className: "p-2 rounded-lg bg-muted", children: icon }),
65201
- /* @__PURE__ */ jsx("span", { className: "capitalize text-sm", children: type })
65202
- ]
65191
+ placeholder: "Search widgets...",
65192
+ value: searchQuery,
65193
+ onChange: (e) => {
65194
+ setSearchQuery(e.target.value);
65195
+ onSearch?.(e.target.value);
65196
+ },
65197
+ className: "pl-10"
65203
65198
  }
65204
65199
  )
65205
- },
65206
- type
65207
- )) }) })
65208
- ] })
65209
- ] }) });
65210
- const TemplateGallery = () => /* @__PURE__ */ jsx(MoonUIDialogPro, { open: showTemplates, onOpenChange: setShowTemplates, children: /* @__PURE__ */ jsxs(MoonUIDialogContentPro, { className: cn(
65211
- "max-w-4xl",
65212
- glassmorphism && "bg-background/95 backdrop-blur-md"
65213
- ), children: [
65214
- /* @__PURE__ */ jsxs(MoonUIDialogHeaderPro, { children: [
65215
- /* @__PURE__ */ jsx(MoonUIDialogTitlePro, { children: "Dashboard Templates" }),
65216
- /* @__PURE__ */ jsx(MoonUIDialogDescriptionPro, { children: "Start with a pre-built template or create your own" })
65217
- ] }),
65218
- /* @__PURE__ */ jsxs(Tabs, { defaultValue: "all", className: "mt-4", children: [
65219
- /* @__PURE__ */ jsxs(TabsList, { children: [
65220
- /* @__PURE__ */ jsx(TabsTrigger, { value: "all", children: "All Templates" }),
65221
- /* @__PURE__ */ jsx(TabsTrigger, { value: "analytics", children: "Analytics" }),
65222
- /* @__PURE__ */ jsx(TabsTrigger, { value: "sales", children: "Sales" }),
65223
- /* @__PURE__ */ jsx(TabsTrigger, { value: "operations", children: "Operations" })
65200
+ ] }),
65201
+ /* @__PURE__ */ jsx(ScrollArea, { className: "h-[calc(100vh-200px)]", children: /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-4", children: Object.entries(WIDGET_TYPE_ICONS).filter(([type]) => type.toLowerCase().includes(searchQuery.toLowerCase())).map(([type, icon]) => /* @__PURE__ */ jsx(
65202
+ motion.div,
65203
+ {
65204
+ whileHover: { scale: 1.02 },
65205
+ whileTap: { scale: 0.98 },
65206
+ children: /* @__PURE__ */ jsxs(
65207
+ MoonUIButtonPro,
65208
+ {
65209
+ variant: "outline",
65210
+ className: "w-full h-24 flex-col gap-2",
65211
+ onClick: () => handleAddWidget(type),
65212
+ children: [
65213
+ /* @__PURE__ */ jsx("div", { className: "p-2 rounded-lg bg-muted", children: icon }),
65214
+ /* @__PURE__ */ jsx("span", { className: "capitalize text-sm", children: type })
65215
+ ]
65216
+ }
65217
+ )
65218
+ },
65219
+ type
65220
+ )) }) })
65221
+ ] })
65222
+ ] }) });
65223
+ }, [showWidgetLibrary, searchQuery, glassmorphism, onSearch, handleAddWidget]);
65224
+ const TemplateGallery = t__default.useCallback(() => {
65225
+ if (!showTemplates)
65226
+ return null;
65227
+ return /* @__PURE__ */ jsx(MoonUIDialogPro, { open: showTemplates, onOpenChange: setShowTemplates, children: /* @__PURE__ */ jsxs(MoonUIDialogContentPro, { className: cn(
65228
+ "max-w-4xl",
65229
+ glassmorphism && "bg-background/95 backdrop-blur-md"
65230
+ ), children: [
65231
+ /* @__PURE__ */ jsxs(MoonUIDialogHeaderPro, { children: [
65232
+ /* @__PURE__ */ jsx(MoonUIDialogTitlePro, { children: "Dashboard Templates" }),
65233
+ /* @__PURE__ */ jsx(MoonUIDialogDescriptionPro, { children: "Start with a pre-built template or create your own" })
65224
65234
  ] }),
65225
- /* @__PURE__ */ jsx(TabsContent, { value: "all", className: "mt-4", children: /* @__PURE__ */ jsx("div", { className: "grid grid-cols-3 gap-4", children: templates.map((template) => /* @__PURE__ */ jsx(
65226
- motion.div,
65227
- {
65228
- whileHover: { y: -4 },
65229
- className: "cursor-pointer",
65230
- onClick: () => applyTemplate(template),
65231
- children: /* @__PURE__ */ jsxs("div", { className: cn(
65232
- "relative overflow-hidden rounded-lg border p-4 hover:shadow-lg transition-all",
65233
- "bg-gradient-to-br",
65234
- THEME_COLORS[template.theme]
65235
- ), children: [
65236
- template.isPro && /* @__PURE__ */ jsx(MoonUIBadgePro, { className: "absolute top-2 right-2", variant: "secondary", children: "PRO" }),
65237
- /* @__PURE__ */ jsx("h3", { className: "font-semibold mb-1", children: template.name }),
65238
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: template.description }),
65239
- /* @__PURE__ */ jsxs("div", { className: "mt-3 flex items-center gap-2 text-xs text-muted-foreground", children: [
65240
- /* @__PURE__ */ jsxs("span", { children: [
65241
- template.widgets.length,
65242
- " widgets"
65243
- ] }),
65244
- /* @__PURE__ */ jsx("span", { children: "\u2022" }),
65245
- /* @__PURE__ */ jsx("span", { className: "capitalize", children: template.category })
65235
+ /* @__PURE__ */ jsxs(Tabs, { defaultValue: "all", className: "mt-4", children: [
65236
+ /* @__PURE__ */ jsxs(TabsList, { children: [
65237
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "all", children: "All Templates" }),
65238
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "analytics", children: "Analytics" }),
65239
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "sales", children: "Sales" }),
65240
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "operations", children: "Operations" })
65241
+ ] }),
65242
+ /* @__PURE__ */ jsx(TabsContent, { value: "all", className: "mt-4", children: /* @__PURE__ */ jsx("div", { className: "grid grid-cols-3 gap-4", children: templates.map((template) => /* @__PURE__ */ jsx(
65243
+ motion.div,
65244
+ {
65245
+ whileHover: { y: -4 },
65246
+ className: "cursor-pointer",
65247
+ onClick: () => applyTemplate(template),
65248
+ children: /* @__PURE__ */ jsxs("div", { className: cn(
65249
+ "relative overflow-hidden rounded-lg border p-4 hover:shadow-lg transition-all",
65250
+ "bg-gradient-to-br",
65251
+ THEME_COLORS[template.theme]
65252
+ ), children: [
65253
+ template.isPro && /* @__PURE__ */ jsx(MoonUIBadgePro, { className: "absolute top-2 right-2", variant: "secondary", children: "PRO" }),
65254
+ /* @__PURE__ */ jsx("h3", { className: "font-semibold mb-1", children: template.name }),
65255
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: template.description }),
65256
+ /* @__PURE__ */ jsxs("div", { className: "mt-3 flex items-center gap-2 text-xs text-muted-foreground", children: [
65257
+ /* @__PURE__ */ jsxs("span", { children: [
65258
+ template.widgets.length,
65259
+ " widgets"
65260
+ ] }),
65261
+ /* @__PURE__ */ jsx("span", { children: "\u2022" }),
65262
+ /* @__PURE__ */ jsx("span", { className: "capitalize", children: template.category })
65263
+ ] })
65246
65264
  ] })
65247
- ] })
65248
- },
65249
- template.id
65250
- )) }) })
65251
- ] })
65252
- ] }) });
65265
+ },
65266
+ template.id
65267
+ )) }) })
65268
+ ] })
65269
+ ] }) });
65270
+ }, [showTemplates, glassmorphism, templates, applyTemplate]);
65253
65271
  return /* @__PURE__ */ jsxs(
65254
65272
  motion.div,
65255
65273
  {
@@ -65727,8 +65745,8 @@ function DashboardInternal({
65727
65745
  )
65728
65746
  ) })
65729
65747
  ),
65730
- /* @__PURE__ */ jsx(WidgetLibrary, {}),
65731
- /* @__PURE__ */ jsx(TemplateGallery, {})
65748
+ showWidgetLibrary && /* @__PURE__ */ jsx(WidgetLibrary, {}),
65749
+ showTemplates && /* @__PURE__ */ jsx(TemplateGallery, {})
65732
65750
  ]
65733
65751
  }
65734
65752
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "2.24.6",
3
+ "version": "2.24.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",