@moontra/moonui-pro 2.0.10 → 2.0.12

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.
Files changed (2) hide show
  1. package/dist/index.mjs +736 -2
  2. package/package.json +3 -2
package/dist/index.mjs CHANGED
@@ -5,13 +5,16 @@ import { motion, useMotionValue, useTransform, animate } from 'framer-motion';
5
5
  import { clsx } from 'clsx';
6
6
  import { twMerge } from 'tailwind-merge';
7
7
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
- import { Loader2, ChevronDown, ChevronUp, Check, X, ChevronRight, Circle, Lock, Sparkles, Calendar, ChevronLeft, Edit, Trash2, Clock, MapPin, User, Plus, MoreHorizontal, 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, Table as Table$1, Settings, Undo, Redo, Eye, RefreshCw, Wand2, Maximize, FileText, Languages } from 'lucide-react';
8
+ import { Loader2, ChevronDown, ChevronUp, Check, X, ChevronRight, Circle, Lock, Sparkles, Calendar, ChevronLeft, Edit, Trash2, Clock, MapPin, User, Plus, MoreHorizontal, 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, Table as Table$1, Settings, Undo, Redo, Eye, RefreshCw, Wand2, Maximize, FileText, Languages, TrendingUp, TrendingDown, Minus, Download, Maximize2, Activity, Star, ExternalLink, BarChart3, Users, DollarSign, CheckCircle2, AlertCircle, XCircle, ArrowDownRight, ArrowUpRight } from 'lucide-react';
9
9
  import * as ReactDOM from 'react-dom';
10
10
  import ReactDOM__default, { createPortal, flushSync } from 'react-dom';
11
11
  import * as AvatarPrimitive from '@radix-ui/react-avatar';
12
12
  import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
13
13
  import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js';
14
14
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
15
+ import { cn as cn$1 } from '@moontra/moonui';
16
+ import { ResponsiveContainer, ScatterChart, CartesianGrid, XAxis, YAxis, Tooltip as Tooltip$1, Legend, Scatter, PieChart, Pie, Cell, AreaChart, Area, ReferenceLine, Brush, BarChart, Bar, LineChart, Line, ReferenceArea } from 'recharts';
17
+ import { DragDropContext, Droppable, Draggable } from '@hello-pangea/dnd';
15
18
 
16
19
  /**
17
20
  * @moontra/moonui-pro v2.0.9
@@ -54340,5 +54343,736 @@ var SwipeableCard = React50__default.forwardRef(
54340
54343
  }
54341
54344
  );
54342
54345
  SwipeableCard.displayName = "SwipeableCard";
54346
+ var EVENT_COLORS2 = {
54347
+ success: "bg-green-500 border-green-500",
54348
+ warning: "bg-yellow-500 border-yellow-500",
54349
+ error: "bg-red-500 border-red-500",
54350
+ info: "bg-blue-500 border-blue-500",
54351
+ pending: "bg-gray-400 border-gray-400"
54352
+ };
54353
+ var EVENT_ICONS = {
54354
+ success: /* @__PURE__ */ jsx(CheckCircle2, { className: "h-4 w-4 text-white" }),
54355
+ warning: /* @__PURE__ */ jsx(AlertCircle, { className: "h-4 w-4 text-white" }),
54356
+ error: /* @__PURE__ */ jsx(XCircle, { className: "h-4 w-4 text-white" }),
54357
+ info: /* @__PURE__ */ jsx(Circle, { className: "h-4 w-4 text-white" }),
54358
+ pending: /* @__PURE__ */ jsx(Clock, { className: "h-4 w-4 text-white" })
54359
+ };
54360
+ var EVENT_TEXT_COLORS = {
54361
+ success: "text-green-700",
54362
+ warning: "text-yellow-700",
54363
+ error: "text-red-700",
54364
+ info: "text-blue-700",
54365
+ pending: "text-gray-700"
54366
+ };
54367
+ function Timeline({
54368
+ events,
54369
+ onEventClick,
54370
+ className,
54371
+ showUserInfo = true,
54372
+ showMetadata = true,
54373
+ showRelativeTime = true,
54374
+ groupByDate = false,
54375
+ orientation = "vertical",
54376
+ compact = false,
54377
+ interactive = true
54378
+ }) {
54379
+ const sortedEvents = [...events].sort((a, b) => b.date.getTime() - a.date.getTime());
54380
+ const formatDate = (date) => {
54381
+ return date.toLocaleDateString("en-US", {
54382
+ year: "numeric",
54383
+ month: "long",
54384
+ day: "numeric"
54385
+ });
54386
+ };
54387
+ const formatTime = (date) => {
54388
+ return date.toLocaleTimeString("en-US", {
54389
+ hour: "2-digit",
54390
+ minute: "2-digit",
54391
+ hour12: true
54392
+ });
54393
+ };
54394
+ const getRelativeTime = (date) => {
54395
+ const now = /* @__PURE__ */ new Date();
54396
+ const diffInSeconds = Math.floor((now.getTime() - date.getTime()) / 1e3);
54397
+ if (diffInSeconds < 60) {
54398
+ return "Just now";
54399
+ } else if (diffInSeconds < 3600) {
54400
+ const minutes = Math.floor(diffInSeconds / 60);
54401
+ return `${minutes} minute${minutes > 1 ? "s" : ""} ago`;
54402
+ } else if (diffInSeconds < 86400) {
54403
+ const hours = Math.floor(diffInSeconds / 3600);
54404
+ return `${hours} hour${hours > 1 ? "s" : ""} ago`;
54405
+ } else if (diffInSeconds < 2592e3) {
54406
+ const days = Math.floor(diffInSeconds / 86400);
54407
+ return `${days} day${days > 1 ? "s" : ""} ago`;
54408
+ } else {
54409
+ return formatDate(date);
54410
+ }
54411
+ };
54412
+ const getInitials = (name) => {
54413
+ return name.split(" ").map((n) => n[0]).join("").toUpperCase();
54414
+ };
54415
+ const groupEventsByDate = (events2) => {
54416
+ const groups = {};
54417
+ events2.forEach((event) => {
54418
+ const dateKey = formatDate(event.date);
54419
+ if (!groups[dateKey]) {
54420
+ groups[dateKey] = [];
54421
+ }
54422
+ groups[dateKey].push(event);
54423
+ });
54424
+ return groups;
54425
+ };
54426
+ const handleEventClick = (event) => {
54427
+ if (interactive && onEventClick) {
54428
+ onEventClick(event);
54429
+ }
54430
+ };
54431
+ const renderEvent = (event, index2, isLast) => {
54432
+ const eventColor = event.color || EVENT_COLORS2[event.type];
54433
+ const eventIcon = event.icon || EVENT_ICONS[event.type];
54434
+ const textColor = EVENT_TEXT_COLORS[event.type];
54435
+ return /* @__PURE__ */ jsxs(
54436
+ "div",
54437
+ {
54438
+ className: cn$1(
54439
+ "relative flex gap-4",
54440
+ compact ? "pb-4" : "pb-8",
54441
+ interactive && "cursor-pointer hover:bg-muted/50 rounded-lg p-2 -m-2 transition-colors"
54442
+ ),
54443
+ onClick: () => handleEventClick(event),
54444
+ children: [
54445
+ orientation === "vertical" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center", children: [
54446
+ /* @__PURE__ */ jsx("div", { className: cn$1(
54447
+ "flex items-center justify-center w-8 h-8 rounded-full border-2 bg-background",
54448
+ eventColor
54449
+ ), children: eventIcon }),
54450
+ !isLast && /* @__PURE__ */ jsx("div", { className: "w-0.5 h-full bg-border mt-2" })
54451
+ ] }),
54452
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
54453
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
54454
+ /* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
54455
+ /* @__PURE__ */ jsx("h4", { className: cn$1(
54456
+ "font-medium text-sm",
54457
+ compact ? "mb-1" : "mb-2"
54458
+ ), children: event.title }),
54459
+ event.description && /* @__PURE__ */ jsx("p", { className: cn$1(
54460
+ "text-muted-foreground text-sm",
54461
+ compact ? "mb-1" : "mb-2"
54462
+ ), children: event.description })
54463
+ ] }),
54464
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
54465
+ showRelativeTime ? /* @__PURE__ */ jsx("span", { children: getRelativeTime(event.date) }) : /* @__PURE__ */ jsx("span", { children: formatTime(event.date) }),
54466
+ /* @__PURE__ */ jsx(Badge, { variant: "outline", className: cn$1("text-xs", textColor), children: event.type })
54467
+ ] })
54468
+ ] }),
54469
+ showUserInfo && event.user && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mb-2", children: [
54470
+ /* @__PURE__ */ jsxs(Avatar, { className: "h-6 w-6", children: [
54471
+ /* @__PURE__ */ jsx(AvatarImage, { src: event.user.avatar }),
54472
+ /* @__PURE__ */ jsx(AvatarFallback, { className: "text-xs", children: getInitials(event.user.name) })
54473
+ ] }),
54474
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: event.user.name })
54475
+ ] }),
54476
+ showMetadata && event.metadata && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3 text-xs text-muted-foreground", children: [
54477
+ event.metadata.duration && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
54478
+ /* @__PURE__ */ jsx(Clock, { className: "h-3 w-3" }),
54479
+ /* @__PURE__ */ jsx("span", { children: event.metadata.duration })
54480
+ ] }),
54481
+ event.metadata.location && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
54482
+ /* @__PURE__ */ jsx(Calendar, { className: "h-3 w-3" }),
54483
+ /* @__PURE__ */ jsx("span", { children: event.metadata.location })
54484
+ ] }),
54485
+ event.metadata.comments && event.metadata.comments > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
54486
+ /* @__PURE__ */ jsx(MessageCircle, { className: "h-3 w-3" }),
54487
+ /* @__PURE__ */ jsx("span", { children: event.metadata.comments })
54488
+ ] }),
54489
+ event.metadata.attachments && event.metadata.attachments > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
54490
+ /* @__PURE__ */ jsx(Paperclip, { className: "h-3 w-3" }),
54491
+ /* @__PURE__ */ jsx("span", { children: event.metadata.attachments })
54492
+ ] }),
54493
+ event.metadata.externalLink && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
54494
+ /* @__PURE__ */ jsx(ExternalLink, { className: "h-3 w-3" }),
54495
+ /* @__PURE__ */ jsx("span", { children: "View details" })
54496
+ ] })
54497
+ ] }),
54498
+ event.metadata?.tags && event.metadata.tags.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1 mt-2", children: event.metadata.tags.map((tag, tagIndex) => /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: tag }, tagIndex)) })
54499
+ ] })
54500
+ ]
54501
+ },
54502
+ event.id
54503
+ );
54504
+ };
54505
+ const renderGroupedEvents = () => {
54506
+ const groups = groupEventsByDate(sortedEvents);
54507
+ return Object.entries(groups).map(([date, events2], groupIndex) => /* @__PURE__ */ jsxs("div", { className: "mb-8", children: [
54508
+ /* @__PURE__ */ jsx("div", { className: "sticky top-0 bg-background/80 backdrop-blur-sm border-b p-2 mb-4", children: /* @__PURE__ */ jsx("h3", { className: "font-medium text-sm text-muted-foreground", children: date }) }),
54509
+ events2.map((event, index2) => renderEvent(event, index2, index2 === events2.length - 1))
54510
+ ] }, date));
54511
+ };
54512
+ return /* @__PURE__ */ jsxs(Card, { className: cn$1("w-full", className), children: [
54513
+ /* @__PURE__ */ jsxs(CardHeader, { children: [
54514
+ /* @__PURE__ */ jsxs(CardTitle, { className: "flex items-center gap-2", children: [
54515
+ /* @__PURE__ */ jsx(Clock, { className: "h-5 w-5" }),
54516
+ "Timeline"
54517
+ ] }),
54518
+ /* @__PURE__ */ jsxs(CardDescription, { children: [
54519
+ sortedEvents.length,
54520
+ " event",
54521
+ sortedEvents.length !== 1 ? "s" : "",
54522
+ " tracked"
54523
+ ] })
54524
+ ] }),
54525
+ /* @__PURE__ */ jsx(CardContent, { children: sortedEvents.length > 0 ? /* @__PURE__ */ jsx("div", { className: cn$1(
54526
+ "space-y-0",
54527
+ orientation === "horizontal" && "flex overflow-x-auto gap-6"
54528
+ ), children: groupByDate ? renderGroupedEvents() : sortedEvents.map(
54529
+ (event, index2) => renderEvent(event, index2, index2 === sortedEvents.length - 1)
54530
+ ) }) : /* @__PURE__ */ jsxs("div", { className: "text-center py-8", children: [
54531
+ /* @__PURE__ */ jsx(Clock, { className: "h-12 w-12 mx-auto mb-4 text-muted-foreground" }),
54532
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: "No events to display" })
54533
+ ] }) })
54534
+ ] });
54535
+ }
54536
+ var DEFAULT_COLORS = [
54537
+ "#3b82f6",
54538
+ "#ef4444",
54539
+ "#10b981",
54540
+ "#f59e0b",
54541
+ "#8b5cf6",
54542
+ "#06b6d4",
54543
+ "#f97316",
54544
+ "#84cc16",
54545
+ "#ec4899",
54546
+ "#6366f1"
54547
+ ];
54548
+ function AdvancedChart({
54549
+ data,
54550
+ type,
54551
+ series,
54552
+ title,
54553
+ subtitle,
54554
+ height = 400,
54555
+ width = "100%",
54556
+ xAxisKey = "name",
54557
+ yAxisKey,
54558
+ showGrid = true,
54559
+ showTooltip = true,
54560
+ showLegend = true,
54561
+ showBrush = false,
54562
+ showReference = false,
54563
+ referenceLines = [],
54564
+ referenceAreas = [],
54565
+ colors = DEFAULT_COLORS,
54566
+ className,
54567
+ onDataPointClick,
54568
+ onExport,
54569
+ onRefresh,
54570
+ customTooltip,
54571
+ customLegend,
54572
+ loading = false,
54573
+ error = null,
54574
+ animated = true,
54575
+ responsive = true
54576
+ }) {
54577
+ const [isFullscreen, setIsFullscreen] = React50__default.useState(false);
54578
+ const chartRef = React50__default.useRef(null);
54579
+ const trend = React50__default.useMemo(() => {
54580
+ if (!data.length || !series.length)
54581
+ return null;
54582
+ const firstSeries = series[0];
54583
+ const values = data.map((d) => Number(d[firstSeries.dataKey])).filter((v) => !isNaN(v));
54584
+ if (values.length < 2)
54585
+ return null;
54586
+ const first2 = values[0];
54587
+ const last = values[values.length - 1];
54588
+ const change = (last - first2) / first2 * 100;
54589
+ return {
54590
+ direction: change > 0 ? "up" : change < 0 ? "down" : "neutral",
54591
+ percentage: Math.abs(change).toFixed(1)
54592
+ };
54593
+ }, [data, series]);
54594
+ const handleExport = (format) => {
54595
+ if (onExport) {
54596
+ onExport(format);
54597
+ }
54598
+ };
54599
+ const renderChart = () => {
54600
+ const commonProps = {
54601
+ data,
54602
+ width: typeof width === "string" ? void 0 : width,
54603
+ height,
54604
+ margin: { top: 20, right: 30, left: 20, bottom: 20 }
54605
+ // onClick: onDataPointClick,
54606
+ };
54607
+ const visibleSeries = series.filter((s) => !s.hide);
54608
+ switch (type) {
54609
+ case "line":
54610
+ return /* @__PURE__ */ jsxs(LineChart, { ...commonProps, children: [
54611
+ showGrid && /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
54612
+ /* @__PURE__ */ jsx(XAxis, { dataKey: xAxisKey }),
54613
+ /* @__PURE__ */ jsx(YAxis, {}),
54614
+ showTooltip && /* @__PURE__ */ jsx(Tooltip$1, {}),
54615
+ showLegend && /* @__PURE__ */ jsx(Legend, {}),
54616
+ visibleSeries.map((s, index2) => /* @__PURE__ */ jsx(
54617
+ Line,
54618
+ {
54619
+ type: s.type || "monotone",
54620
+ dataKey: s.dataKey,
54621
+ stroke: s.color || colors[index2 % colors.length],
54622
+ strokeWidth: s.strokeWidth || 2,
54623
+ name: s.name,
54624
+ animationDuration: animated ? 1e3 : 0
54625
+ },
54626
+ s.dataKey
54627
+ )),
54628
+ showReference && referenceLines.map((ref, index2) => /* @__PURE__ */ jsx(
54629
+ ReferenceLine,
54630
+ {
54631
+ y: ref.value,
54632
+ stroke: ref.color || "#666",
54633
+ strokeDasharray: "5 5",
54634
+ label: ref.label
54635
+ },
54636
+ index2
54637
+ )),
54638
+ showReference && referenceAreas.map((ref, index2) => /* @__PURE__ */ jsx(
54639
+ ReferenceArea,
54640
+ {
54641
+ x1: ref.x1,
54642
+ x2: ref.x2,
54643
+ fill: ref.color || "#f0f0f0",
54644
+ fillOpacity: 0.3,
54645
+ label: ref.label
54646
+ },
54647
+ index2
54648
+ )),
54649
+ showBrush && /* @__PURE__ */ jsx(Brush, {})
54650
+ ] });
54651
+ case "bar":
54652
+ return /* @__PURE__ */ jsxs(BarChart, { ...commonProps, children: [
54653
+ showGrid && /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
54654
+ /* @__PURE__ */ jsx(XAxis, { dataKey: xAxisKey }),
54655
+ /* @__PURE__ */ jsx(YAxis, {}),
54656
+ showTooltip && /* @__PURE__ */ jsx(Tooltip$1, {}),
54657
+ showLegend && /* @__PURE__ */ jsx(Legend, {}),
54658
+ visibleSeries.map((s, index2) => /* @__PURE__ */ jsx(
54659
+ Bar,
54660
+ {
54661
+ dataKey: s.dataKey,
54662
+ fill: s.color || colors[index2 % colors.length],
54663
+ name: s.name,
54664
+ animationDuration: animated ? 1e3 : 0
54665
+ },
54666
+ s.dataKey
54667
+ )),
54668
+ showReference && referenceLines.map((ref, index2) => /* @__PURE__ */ jsx(
54669
+ ReferenceLine,
54670
+ {
54671
+ y: ref.value,
54672
+ stroke: ref.color || "#666",
54673
+ strokeDasharray: "5 5",
54674
+ label: ref.label
54675
+ },
54676
+ index2
54677
+ )),
54678
+ showBrush && /* @__PURE__ */ jsx(Brush, {})
54679
+ ] });
54680
+ case "area":
54681
+ return /* @__PURE__ */ jsxs(AreaChart, { ...commonProps, children: [
54682
+ showGrid && /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
54683
+ /* @__PURE__ */ jsx(XAxis, { dataKey: xAxisKey }),
54684
+ /* @__PURE__ */ jsx(YAxis, {}),
54685
+ showTooltip && /* @__PURE__ */ jsx(Tooltip$1, {}),
54686
+ showLegend && /* @__PURE__ */ jsx(Legend, {}),
54687
+ visibleSeries.map((s, index2) => /* @__PURE__ */ jsx(
54688
+ Area,
54689
+ {
54690
+ type: s.type || "monotone",
54691
+ dataKey: s.dataKey,
54692
+ stroke: s.color || colors[index2 % colors.length],
54693
+ fill: s.color || colors[index2 % colors.length],
54694
+ fillOpacity: s.fillOpacity || 0.3,
54695
+ name: s.name,
54696
+ animationDuration: animated ? 1e3 : 0
54697
+ },
54698
+ s.dataKey
54699
+ )),
54700
+ showReference && referenceLines.map((ref, index2) => /* @__PURE__ */ jsx(
54701
+ ReferenceLine,
54702
+ {
54703
+ y: ref.value,
54704
+ stroke: ref.color || "#666",
54705
+ strokeDasharray: "5 5",
54706
+ label: ref.label
54707
+ },
54708
+ index2
54709
+ )),
54710
+ showBrush && /* @__PURE__ */ jsx(Brush, {})
54711
+ ] });
54712
+ case "pie":
54713
+ return /* @__PURE__ */ jsxs(PieChart, { ...commonProps, children: [
54714
+ showTooltip && /* @__PURE__ */ jsx(Tooltip$1, {}),
54715
+ showLegend && /* @__PURE__ */ jsx(Legend, {}),
54716
+ /* @__PURE__ */ jsx(
54717
+ Pie,
54718
+ {
54719
+ data,
54720
+ dataKey: series[0]?.dataKey || "value",
54721
+ nameKey: xAxisKey,
54722
+ cx: "50%",
54723
+ cy: "50%",
54724
+ outerRadius: Math.min(height, typeof width === "number" ? width : 400) / 3,
54725
+ animationDuration: animated ? 1e3 : 0,
54726
+ children: data.map((entry, index2) => /* @__PURE__ */ jsx(Cell, { fill: colors[index2 % colors.length] }, `cell-${index2}`))
54727
+ }
54728
+ )
54729
+ ] });
54730
+ case "scatter":
54731
+ return /* @__PURE__ */ jsxs(ScatterChart, { ...commonProps, children: [
54732
+ showGrid && /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
54733
+ /* @__PURE__ */ jsx(XAxis, { dataKey: xAxisKey }),
54734
+ /* @__PURE__ */ jsx(YAxis, { dataKey: yAxisKey }),
54735
+ showTooltip && /* @__PURE__ */ jsx(Tooltip$1, {}),
54736
+ showLegend && /* @__PURE__ */ jsx(Legend, {}),
54737
+ visibleSeries.map((s, index2) => /* @__PURE__ */ jsx(
54738
+ Scatter,
54739
+ {
54740
+ dataKey: s.dataKey,
54741
+ fill: s.color || colors[index2 % colors.length],
54742
+ name: s.name,
54743
+ animationDuration: animated ? 1e3 : 0
54744
+ },
54745
+ s.dataKey
54746
+ ))
54747
+ ] });
54748
+ default:
54749
+ return /* @__PURE__ */ jsx("div", { children: "Unsupported chart type" });
54750
+ }
54751
+ };
54752
+ if (loading) {
54753
+ return /* @__PURE__ */ jsx(Card, { className: cn$1("w-full", className), children: /* @__PURE__ */ jsx(CardContent, { className: "flex items-center justify-center", style: { height }, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
54754
+ /* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4 animate-spin" }),
54755
+ /* @__PURE__ */ jsx("span", { children: "Loading chart..." })
54756
+ ] }) }) });
54757
+ }
54758
+ if (error) {
54759
+ return /* @__PURE__ */ jsx(Card, { className: cn$1("w-full", className), children: /* @__PURE__ */ jsx(CardContent, { className: "flex items-center justify-center", style: { height }, children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
54760
+ /* @__PURE__ */ jsx("p", { className: "text-destructive mb-2", children: error }),
54761
+ onRefresh && /* @__PURE__ */ jsxs(Button, { variant: "outline", onClick: onRefresh, children: [
54762
+ /* @__PURE__ */ jsx(RefreshCw, { className: "mr-2 h-4 w-4" }),
54763
+ "Retry"
54764
+ ] })
54765
+ ] }) }) });
54766
+ }
54767
+ return /* @__PURE__ */ jsxs(Card, { className: cn$1("w-full", className), ref: chartRef, children: [
54768
+ /* @__PURE__ */ jsxs(CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
54769
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
54770
+ /* @__PURE__ */ jsxs(CardTitle, { className: "text-base font-medium", children: [
54771
+ title,
54772
+ trend && /* @__PURE__ */ jsxs("span", { className: "ml-2 inline-flex items-center", children: [
54773
+ trend.direction === "up" && /* @__PURE__ */ jsx(TrendingUp, { className: "h-4 w-4 text-green-500" }),
54774
+ trend.direction === "down" && /* @__PURE__ */ jsx(TrendingDown, { className: "h-4 w-4 text-red-500" }),
54775
+ trend.direction === "neutral" && /* @__PURE__ */ jsx(Minus, { className: "h-4 w-4 text-gray-500" }),
54776
+ /* @__PURE__ */ jsxs("span", { className: cn$1(
54777
+ "ml-1 text-sm",
54778
+ trend.direction === "up" && "text-green-500",
54779
+ trend.direction === "down" && "text-red-500",
54780
+ trend.direction === "neutral" && "text-gray-500"
54781
+ ), children: [
54782
+ trend.percentage,
54783
+ "%"
54784
+ ] })
54785
+ ] })
54786
+ ] }),
54787
+ subtitle && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: subtitle })
54788
+ ] }),
54789
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-1", children: [
54790
+ onRefresh && /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onClick: onRefresh, children: /* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }) }),
54791
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", children: /* @__PURE__ */ jsx(Settings, { className: "h-4 w-4" }) }),
54792
+ onExport && /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onClick: () => handleExport("png"), children: /* @__PURE__ */ jsx(Download, { className: "h-4 w-4" }) }),
54793
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onClick: () => setIsFullscreen(!isFullscreen), children: /* @__PURE__ */ jsx(Maximize2, { className: "h-4 w-4" }) })
54794
+ ] })
54795
+ ] }),
54796
+ /* @__PURE__ */ jsx(CardContent, { children: responsive ? /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: renderChart() }) : /* @__PURE__ */ jsx("div", { style: { width: "100%", height: `${height}px` }, children: renderChart() }) })
54797
+ ] });
54798
+ }
54799
+ var METRIC_COLORS = {
54800
+ primary: "text-blue-600",
54801
+ success: "text-green-600",
54802
+ warning: "text-yellow-600",
54803
+ danger: "text-red-600",
54804
+ info: "text-purple-600"
54805
+ };
54806
+ var WIDGET_SIZES = {
54807
+ sm: "col-span-1",
54808
+ md: "col-span-2",
54809
+ lg: "col-span-3",
54810
+ xl: "col-span-4"
54811
+ };
54812
+ function Dashboard({
54813
+ metrics = [],
54814
+ widgets = [],
54815
+ onMetricClick,
54816
+ onWidgetAction,
54817
+ className,
54818
+ showHeader = true,
54819
+ title = "Dashboard",
54820
+ description = "Overview of your key metrics and performance",
54821
+ refreshable = true,
54822
+ onRefresh,
54823
+ loading = false
54824
+ }) {
54825
+ const [refreshing, setRefreshing] = React50__default.useState(false);
54826
+ const handleRefresh = async () => {
54827
+ if (onRefresh) {
54828
+ setRefreshing(true);
54829
+ try {
54830
+ await onRefresh();
54831
+ } finally {
54832
+ setRefreshing(false);
54833
+ }
54834
+ }
54835
+ };
54836
+ const formatValue = (value) => {
54837
+ if (typeof value === "number") {
54838
+ if (value >= 1e6) {
54839
+ return (value / 1e6).toFixed(1) + "M";
54840
+ } else if (value >= 1e3) {
54841
+ return (value / 1e3).toFixed(1) + "K";
54842
+ }
54843
+ return value.toLocaleString();
54844
+ }
54845
+ return value.toString();
54846
+ };
54847
+ const getChangeIcon = (type) => {
54848
+ switch (type) {
54849
+ case "increase":
54850
+ return /* @__PURE__ */ jsx(ArrowUpRight, { className: "h-4 w-4" });
54851
+ case "decrease":
54852
+ return /* @__PURE__ */ jsx(ArrowDownRight, { className: "h-4 w-4" });
54853
+ case "neutral":
54854
+ return /* @__PURE__ */ jsx(Minus, { className: "h-4 w-4" });
54855
+ }
54856
+ };
54857
+ const getChangeColor = (type) => {
54858
+ switch (type) {
54859
+ case "increase":
54860
+ return "text-green-600";
54861
+ case "decrease":
54862
+ return "text-red-600";
54863
+ case "neutral":
54864
+ return "text-gray-600";
54865
+ }
54866
+ };
54867
+ const renderMetricCard = (metric) => {
54868
+ const colorClass = metric.color ? METRIC_COLORS[metric.color] : "text-foreground";
54869
+ return /* @__PURE__ */ jsxs(
54870
+ Card,
54871
+ {
54872
+ className: cn$1(
54873
+ "cursor-pointer hover:shadow-md transition-shadow",
54874
+ onMetricClick && "hover:bg-muted/50"
54875
+ ),
54876
+ onClick: () => onMetricClick?.(metric),
54877
+ children: [
54878
+ /* @__PURE__ */ jsxs(CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
54879
+ /* @__PURE__ */ jsx(CardTitle, { className: "text-sm font-medium", children: metric.title }),
54880
+ /* @__PURE__ */ jsx("div", { className: cn$1("h-4 w-4", colorClass), children: metric.icon })
54881
+ ] }),
54882
+ /* @__PURE__ */ jsxs(CardContent, { children: [
54883
+ /* @__PURE__ */ jsx("div", { className: "text-2xl font-bold", children: formatValue(metric.value) }),
54884
+ metric.change && /* @__PURE__ */ jsxs("div", { className: cn$1(
54885
+ "flex items-center text-xs mt-1",
54886
+ getChangeColor(metric.change.type)
54887
+ ), children: [
54888
+ getChangeIcon(metric.change.type),
54889
+ /* @__PURE__ */ jsxs("span", { className: "ml-1", children: [
54890
+ Math.abs(metric.change.value),
54891
+ "% from ",
54892
+ metric.change.period
54893
+ ] })
54894
+ ] }),
54895
+ metric.description && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-1", children: metric.description })
54896
+ ] })
54897
+ ]
54898
+ },
54899
+ metric.id
54900
+ );
54901
+ };
54902
+ const renderWidget = (widget) => {
54903
+ const sizeClass = WIDGET_SIZES[widget.size || "md"];
54904
+ return /* @__PURE__ */ jsxs(Card, { className: cn$1("h-fit", sizeClass), children: [
54905
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
54906
+ /* @__PURE__ */ jsxs("div", { children: [
54907
+ /* @__PURE__ */ jsx(CardTitle, { className: "text-base", children: widget.title }),
54908
+ widget.description && /* @__PURE__ */ jsx(CardDescription, { className: "mt-1", children: widget.description })
54909
+ ] }),
54910
+ /* @__PURE__ */ jsx(
54911
+ Button,
54912
+ {
54913
+ variant: "ghost",
54914
+ size: "sm",
54915
+ onClick: () => onWidgetAction?.(widget.id, "menu"),
54916
+ children: /* @__PURE__ */ jsx(BarChart3, { className: "h-4 w-4" })
54917
+ }
54918
+ )
54919
+ ] }) }),
54920
+ /* @__PURE__ */ jsx(CardContent, { children: widget.loading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center h-32", children: /* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-primary" }) }) : widget.error ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center h-32 text-destructive", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: widget.error }) }) : widget.content })
54921
+ ] }, widget.id);
54922
+ };
54923
+ const defaultMetrics = [
54924
+ {
54925
+ id: "total-users",
54926
+ title: "Total Users",
54927
+ value: 2543,
54928
+ change: { value: 12, type: "increase", period: "last month" },
54929
+ icon: /* @__PURE__ */ jsx(Users, { className: "h-4 w-4" }),
54930
+ color: "primary"
54931
+ },
54932
+ {
54933
+ id: "revenue",
54934
+ title: "Revenue",
54935
+ value: "$12,345",
54936
+ change: { value: 8, type: "increase", period: "last month" },
54937
+ icon: /* @__PURE__ */ jsx(DollarSign, { className: "h-4 w-4" }),
54938
+ color: "success"
54939
+ },
54940
+ {
54941
+ id: "active-sessions",
54942
+ title: "Active Sessions",
54943
+ value: 1234,
54944
+ change: { value: 2, type: "decrease", period: "last hour" },
54945
+ icon: /* @__PURE__ */ jsx(Activity, { className: "h-4 w-4" }),
54946
+ color: "warning"
54947
+ },
54948
+ {
54949
+ id: "conversion-rate",
54950
+ title: "Conversion Rate",
54951
+ value: "3.2%",
54952
+ change: { value: 0.3, type: "increase", period: "last week" },
54953
+ icon: /* @__PURE__ */ jsx(TrendingUp, { className: "h-4 w-4" }),
54954
+ color: "info"
54955
+ }
54956
+ ];
54957
+ const displayMetrics = metrics.length > 0 ? metrics : defaultMetrics;
54958
+ if (loading) {
54959
+ return /* @__PURE__ */ jsx("div", { className: cn$1("w-full", className), children: /* @__PURE__ */ jsxs("div", { className: "animate-pulse space-y-4", children: [
54960
+ /* @__PURE__ */ jsx("div", { className: "h-8 bg-muted rounded w-1/4" }),
54961
+ /* @__PURE__ */ jsx("div", { className: "grid gap-4 md:grid-cols-2 lg:grid-cols-4", children: [...Array(4)].map((_, i) => /* @__PURE__ */ jsx("div", { className: "h-32 bg-muted rounded" }, i)) })
54962
+ ] }) });
54963
+ }
54964
+ return /* @__PURE__ */ jsxs("div", { className: cn$1("w-full space-y-6", className), children: [
54965
+ showHeader && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
54966
+ /* @__PURE__ */ jsxs("div", { children: [
54967
+ /* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold tracking-tight", children: title }),
54968
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: description })
54969
+ ] }),
54970
+ refreshable && /* @__PURE__ */ jsxs(
54971
+ Button,
54972
+ {
54973
+ variant: "outline",
54974
+ onClick: handleRefresh,
54975
+ disabled: refreshing,
54976
+ children: [
54977
+ refreshing ? /* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-4 w-4 border-b-2 border-primary mr-2" }) : /* @__PURE__ */ jsx(Activity, { className: "h-4 w-4 mr-2" }),
54978
+ "Refresh"
54979
+ ]
54980
+ }
54981
+ )
54982
+ ] }),
54983
+ /* @__PURE__ */ jsx("div", { className: "grid gap-4 md:grid-cols-2 lg:grid-cols-4", children: displayMetrics.map(renderMetricCard) }),
54984
+ widgets.length > 0 && /* @__PURE__ */ jsx("div", { className: "grid gap-4 md:grid-cols-2 lg:grid-cols-4", children: widgets.map(renderWidget) }),
54985
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pt-4 border-t", children: [
54986
+ /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", children: [
54987
+ /* @__PURE__ */ jsx(Download, { className: "h-4 w-4 mr-2" }),
54988
+ "Export Data"
54989
+ ] }),
54990
+ /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", children: [
54991
+ /* @__PURE__ */ jsx(Calendar, { className: "h-4 w-4 mr-2" }),
54992
+ "Schedule Report"
54993
+ ] }),
54994
+ /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", children: [
54995
+ /* @__PURE__ */ jsx(Star, { className: "h-4 w-4 mr-2" }),
54996
+ "Save View"
54997
+ ] })
54998
+ ] })
54999
+ ] });
55000
+ }
55001
+ function DraggableList({
55002
+ items,
55003
+ onReorder,
55004
+ renderItem,
55005
+ keyExtractor,
55006
+ direction = "vertical",
55007
+ className,
55008
+ droppableId = "draggable-list",
55009
+ disabled = false
55010
+ }) {
55011
+ const handleDragEnd = (result) => {
55012
+ if (!result.destination || disabled) {
55013
+ return;
55014
+ }
55015
+ const sourceIndex = result.source.index;
55016
+ const destinationIndex = result.destination.index;
55017
+ if (sourceIndex === destinationIndex) {
55018
+ return;
55019
+ }
55020
+ const newItems = Array.from(items);
55021
+ const [reorderedItem] = newItems.splice(sourceIndex, 1);
55022
+ newItems.splice(destinationIndex, 0, reorderedItem);
55023
+ onReorder(newItems);
55024
+ };
55025
+ return /* @__PURE__ */ jsx(DragDropContext, { onDragEnd: handleDragEnd, children: /* @__PURE__ */ jsx(
55026
+ Droppable,
55027
+ {
55028
+ droppableId,
55029
+ direction,
55030
+ isDropDisabled: disabled,
55031
+ children: (provided, snapshot) => /* @__PURE__ */ jsxs(
55032
+ "div",
55033
+ {
55034
+ ...provided.droppableProps,
55035
+ ref: provided.innerRef,
55036
+ className: cn$1(
55037
+ "space-y-2",
55038
+ direction === "horizontal" && "flex space-y-0 space-x-2",
55039
+ snapshot.isDraggingOver && "bg-muted/50 rounded-lg",
55040
+ className
55041
+ ),
55042
+ children: [
55043
+ items.map((item, index2) => /* @__PURE__ */ jsx(
55044
+ Draggable,
55045
+ {
55046
+ draggableId: keyExtractor(item),
55047
+ index: index2,
55048
+ isDragDisabled: disabled,
55049
+ children: (provided2, snapshot2) => /* @__PURE__ */ jsx(
55050
+ "div",
55051
+ {
55052
+ ref: provided2.innerRef,
55053
+ ...provided2.draggableProps,
55054
+ ...provided2.dragHandleProps,
55055
+ className: cn$1(
55056
+ "transition-all duration-200",
55057
+ snapshot2.isDragging && "rotate-2 scale-105 shadow-lg z-50",
55058
+ disabled && "cursor-not-allowed opacity-50"
55059
+ ),
55060
+ style: {
55061
+ ...provided2.draggableProps.style,
55062
+ transform: snapshot2.isDragging ? provided2.draggableProps.style?.transform : "none"
55063
+ },
55064
+ children: renderItem(item, index2)
55065
+ }
55066
+ )
55067
+ },
55068
+ keyExtractor(item)
55069
+ )),
55070
+ provided.placeholder
55071
+ ]
55072
+ }
55073
+ )
55074
+ }
55075
+ ) });
55076
+ }
54343
55077
 
54344
- export { Calendar2 as Calendar, Kanban, MemoryAnalytics, MemoryEfficientData, RichTextEditor, SelectableVirtualList, SwipeableCard, VirtualList, useStreamingData, useVirtualList };
55078
+ export { AdvancedChart, Calendar2 as Calendar, Dashboard, DraggableList, Kanban, MemoryAnalytics, MemoryEfficientData, RichTextEditor, SelectableVirtualList, SwipeableCard, Timeline, VirtualList, useStreamingData, useVirtualList };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "2.0.10",
3
+ "version": "2.0.12",
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",
@@ -70,11 +70,12 @@
70
70
  },
71
71
  "homepage": "https://moonui.dev",
72
72
  "peerDependencies": {
73
- "@moontra/moonui": ">=2.0.0",
73
+ "@moontra/moonui": "^2.0.6",
74
74
  "react": ">=18.0.0",
75
75
  "react-dom": ">=18.0.0"
76
76
  },
77
77
  "dependencies": {
78
+ "@moontra/moonui-pro": "^2.0.9",
78
79
  "@radix-ui/react-accordion": "^1.2.11",
79
80
  "@radix-ui/react-avatar": "^1.1.10",
80
81
  "@radix-ui/react-checkbox": "^1.3.2",