@moontra/moonui-pro 2.24.9 → 2.24.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
@@ -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, Pin, Sun, Moon, Monitor, Bell, CheckCheck, Settings2, LogOut, Edit3, LayoutGrid, Share2, Save, Github, Activity, Server, MemoryStick, HardDrive, Network, Columns, Send, Tag, Flag, BellOff, CalendarIcon, DollarSign, Map as Map$1, Trophy, ArrowDownRight, ArrowUpRight, Grip, Unlock, 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';
@@ -64890,1011 +64890,398 @@ function TimeRangePicker({
64890
64890
  )
64891
64891
  ] });
64892
64892
  }
64893
- var SearchInput = t__default.memo(({
64894
- searchInputRef,
64895
- searchPlaceholder,
64896
- initialValue,
64897
- onSearchChange,
64898
- keyboardShortcuts
64899
- }) => {
64900
- const [localValue, setLocalValue] = useState(initialValue || "");
64901
- const timeoutRef = useRef(void 0);
64902
- useEffect(() => {
64903
- setLocalValue(initialValue);
64904
- }, [initialValue]);
64905
- const handleChange = useCallback((e) => {
64906
- const newValue = e.target.value;
64907
- setLocalValue(newValue);
64908
- if (timeoutRef.current) {
64909
- clearTimeout(timeoutRef.current);
64910
- }
64911
- timeoutRef.current = setTimeout(() => {
64912
- onSearchChange(newValue);
64913
- if (searchInputRef.current) {
64914
- searchInputRef.current.focus();
64915
- }
64916
- }, 150);
64917
- }, [onSearchChange, searchInputRef]);
64918
- useEffect(() => {
64919
- return () => {
64920
- if (timeoutRef.current) {
64921
- clearTimeout(timeoutRef.current);
64922
- }
64923
- };
64924
- }, []);
64925
- return /* @__PURE__ */ jsx("div", { className: "p-4 border-b", children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
64926
- /* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none" }),
64927
- /* @__PURE__ */ jsx(
64928
- "input",
64893
+ var DASHBOARD_TEMPLATES = [
64894
+ {
64895
+ id: "analytics",
64896
+ name: "Analytics Dashboard",
64897
+ description: "Comprehensive analytics with metrics and charts",
64898
+ category: "analytics",
64899
+ theme: "analytics",
64900
+ widgets: [
64929
64901
  {
64930
- ref: searchInputRef,
64931
- type: "text",
64932
- placeholder: searchPlaceholder,
64933
- value: localValue,
64934
- onChange: handleChange,
64935
- autoComplete: "off",
64936
- autoCorrect: "off",
64937
- autoCapitalize: "off",
64938
- spellCheck: "false",
64939
- 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"
64902
+ type: "metric",
64903
+ title: "Total Revenue",
64904
+ size: { w: 3, h: 2 },
64905
+ position: { x: 0, y: 0 },
64906
+ data: {
64907
+ id: "revenue",
64908
+ title: "Total Revenue",
64909
+ value: 125430,
64910
+ change: { value: 12, type: "increase", period: "last month" },
64911
+ color: "success",
64912
+ icon: /* @__PURE__ */ jsx(DollarSign, { className: "h-4 w-4" }),
64913
+ sparkline: [100, 120, 115, 125, 130, 128, 132],
64914
+ unit: "$"
64915
+ }
64916
+ },
64917
+ {
64918
+ type: "metric",
64919
+ title: "Active Users",
64920
+ size: { w: 3, h: 2 },
64921
+ position: { x: 3, y: 0 },
64922
+ data: {
64923
+ id: "users",
64924
+ title: "Active Users",
64925
+ value: 2543,
64926
+ change: { value: 8, type: "increase", period: "last week" },
64927
+ color: "primary",
64928
+ icon: /* @__PURE__ */ jsx(Users, { className: "h-4 w-4" }),
64929
+ sparkline: [200, 220, 210, 230, 225, 240, 254]
64930
+ }
64931
+ },
64932
+ {
64933
+ type: "chart",
64934
+ title: "Revenue Trend",
64935
+ size: { w: 6, h: 4 },
64936
+ position: { x: 0, y: 2 },
64937
+ data: {
64938
+ type: "area",
64939
+ data: [
64940
+ { name: "Jan", revenue: 4e3, profit: 2400 },
64941
+ { name: "Feb", revenue: 3e3, profit: 1398 },
64942
+ { name: "Mar", revenue: 5e3, profit: 3200 },
64943
+ { name: "Apr", revenue: 4500, profit: 2900 },
64944
+ { name: "May", revenue: 6e3, profit: 3800 },
64945
+ { name: "Jun", revenue: 5500, profit: 3400 }
64946
+ ]
64947
+ }
64948
+ },
64949
+ {
64950
+ type: "activity",
64951
+ title: "Recent Activity",
64952
+ size: { w: 3, h: 6 },
64953
+ position: { x: 9, y: 0 },
64954
+ data: {
64955
+ realtime: true,
64956
+ items: [
64957
+ {
64958
+ id: "1",
64959
+ type: "success",
64960
+ title: "completed a purchase",
64961
+ description: "Order #12345 - $250.00",
64962
+ timestamp: new Date(Date.now() - 1e3 * 60 * 5),
64963
+ user: { name: "John Doe" }
64964
+ },
64965
+ {
64966
+ id: "2",
64967
+ type: "info",
64968
+ title: "signed up",
64969
+ description: "New user registration",
64970
+ timestamp: new Date(Date.now() - 1e3 * 60 * 15),
64971
+ user: { name: "Jane Smith" }
64972
+ }
64973
+ ]
64974
+ }
64940
64975
  }
64941
- ),
64942
- 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: [
64943
- /* @__PURE__ */ jsx("span", { className: "text-xs", children: "\u2318" }),
64944
- "K"
64945
- ] })
64946
- ] }) });
64947
- });
64948
- SearchInput.displayName = "SearchInput";
64949
- function SidebarInternal({
64950
- sections,
64951
- footer,
64952
- showSearch = true,
64953
- searchPlaceholder = "Search...",
64954
- searchQuery = "",
64955
- onSearchChange,
64956
- showThemeToggle = false,
64957
- theme = "system",
64958
- onThemeChange,
64959
- branding,
64960
- collapsible = true,
64961
- defaultCollapsed = false,
64962
- floatingActionButton = true,
64963
- floatingActionButtonPosition = { bottom: "1rem", left: "1rem" },
64964
- floatingActionButtonClassName,
64965
- glassmorphism = false,
64966
- animatedBackground = false,
64967
- keyboardShortcuts = true,
64968
- persistState = true,
64969
- persistKey = "moonui-sidebar-state",
64970
- onStateChange,
64971
- customStyles,
64972
- fullWidthItems = true,
64976
+ ]
64977
+ },
64978
+ {
64979
+ id: "sales",
64980
+ name: "Sales Dashboard",
64981
+ description: "Track sales performance and targets",
64982
+ category: "sales",
64983
+ theme: "sales",
64984
+ widgets: [
64985
+ // Sales-specific widgets
64986
+ ]
64987
+ },
64988
+ {
64989
+ id: "monitoring",
64990
+ name: "System Monitoring",
64991
+ description: "Monitor system health and performance",
64992
+ category: "operations",
64993
+ theme: "monitoring",
64994
+ widgets: [
64995
+ // Monitoring widgets
64996
+ ]
64997
+ }
64998
+ ];
64999
+ var WIDGET_TYPE_ICONS = {
65000
+ metric: /* @__PURE__ */ jsx(BarChart3, { className: "h-4 w-4" }),
65001
+ chart: /* @__PURE__ */ jsx(Activity, { className: "h-4 w-4" }),
65002
+ table: /* @__PURE__ */ jsx(Table$1, { className: "h-4 w-4" }),
65003
+ map: /* @__PURE__ */ jsx(Map$1, { className: "h-4 w-4" }),
65004
+ activity: /* @__PURE__ */ jsx(Clock, { className: "h-4 w-4" }),
65005
+ calendar: /* @__PURE__ */ jsx(Calendar$1, { className: "h-4 w-4" }),
65006
+ progress: /* @__PURE__ */ jsx(Target, { className: "h-4 w-4" }),
65007
+ comparison: /* @__PURE__ */ jsx(TrendingUp, { className: "h-4 w-4" })
65008
+ };
65009
+ var THEME_COLORS = {
65010
+ analytics: "from-blue-500/10 to-purple-500/10",
65011
+ sales: "from-green-500/10 to-emerald-500/10",
65012
+ monitoring: "from-orange-500/10 to-red-500/10",
65013
+ finance: "from-indigo-500/10 to-blue-500/10",
65014
+ custom: "from-gray-500/10 to-gray-600/10"
65015
+ };
65016
+ function formatRelativeTime(date) {
65017
+ const now = /* @__PURE__ */ new Date();
65018
+ const diffInSeconds = Math.floor((now.getTime() - date.getTime()) / 1e3);
65019
+ if (diffInSeconds < 60)
65020
+ return "just now";
65021
+ if (diffInSeconds < 3600)
65022
+ return `${Math.floor(diffInSeconds / 60)}m ago`;
65023
+ if (diffInSeconds < 86400)
65024
+ return `${Math.floor(diffInSeconds / 3600)}h ago`;
65025
+ if (diffInSeconds < 604800)
65026
+ return `${Math.floor(diffInSeconds / 86400)}d ago`;
65027
+ return date.toLocaleDateString();
65028
+ }
65029
+ function DashboardInternal({
65030
+ config,
65031
+ widgets: initialWidgets = [],
65032
+ templates = DASHBOARD_TEMPLATES,
65033
+ onConfigChange,
65034
+ onWidgetAdd,
65035
+ onWidgetRemove,
65036
+ onWidgetUpdate,
65037
+ onExport,
65038
+ onImport,
64973
65039
  className,
64974
- activePath,
64975
- onNavigate
65040
+ showHeader = true,
65041
+ title = "Dashboard",
65042
+ description = "Real-time analytics and insights",
65043
+ editable = true,
65044
+ realtime = false,
65045
+ glassmorphism = true,
65046
+ children,
65047
+ mode = "widgets",
65048
+ contentClassName,
65049
+ sidebarPosition = "none",
65050
+ sidebarContent,
65051
+ notifications = [],
65052
+ onNotificationClick,
65053
+ onNotificationMarkAsRead,
65054
+ onNotificationMarkAllAsRead,
65055
+ onNotificationClear,
65056
+ onNotificationClearAll,
65057
+ user,
65058
+ userMenuItems,
65059
+ onUserMenuClick,
65060
+ onProfileClick,
65061
+ onLogout,
65062
+ onSearch,
65063
+ onThemeChange,
65064
+ onMenuClick,
65065
+ onRefresh,
65066
+ headerActions,
65067
+ timeRange: propTimeRange,
65068
+ onTimeRangeChange,
65069
+ logo,
65070
+ brandName
64976
65071
  }) {
64977
- const [isMobile, setIsMobile] = useState(false);
64978
- const [isOpen, setIsOpen] = useState(false);
64979
- const [collapsed, setCollapsed] = useState(defaultCollapsed);
64980
- const [expandedSections, setExpandedSections] = useState([]);
64981
- const [currentSearchQuery, setCurrentSearchQuery] = useState(searchQuery);
64982
- const [pinnedItems, setPinnedItems] = useState([]);
64983
- const searchInputRef = useRef(null);
64984
- const mouseX = useMotionValue(0);
64985
- const mouseY = useMotionValue(0);
64986
- const springX = useSpring(mouseX, { stiffness: 300, damping: 30 });
64987
- const springY = useSpring(mouseY, { stiffness: 300, damping: 30 });
64988
- useEffect(() => {
64989
- if (persistState && typeof window !== "undefined") {
64990
- const savedState = localStorage.getItem(persistKey);
64991
- if (savedState) {
64992
- const state = JSON.parse(savedState);
64993
- setCollapsed(state.collapsed);
64994
- setExpandedSections(state.expandedSections);
64995
- setPinnedItems(state.pinnedItems || []);
64996
- }
65072
+ const [editMode, setEditMode] = t__default.useState(false);
65073
+ const [widgets, setWidgets] = t__default.useState(() => initialWidgets);
65074
+ const [selectedTheme, setSelectedTheme] = t__default.useState("analytics");
65075
+ const [timeRange, setTimeRange] = t__default.useState(() => propTimeRange);
65076
+ const [searchQuery, setSearchQuery] = t__default.useState("");
65077
+ const [showWidgetLibrary, setShowWidgetLibrary] = t__default.useState(false);
65078
+ const [showTemplates, setShowTemplates] = t__default.useState(false);
65079
+ const [refreshing, setRefreshing] = t__default.useState(false);
65080
+ const [showNotifications, setShowNotifications] = t__default.useState(false);
65081
+ const prevInitialWidgetsRef = t__default.useRef(initialWidgets);
65082
+ const prevTimeRangeRef = t__default.useRef(propTimeRange);
65083
+ t__default.useEffect(() => {
65084
+ if (prevInitialWidgetsRef.current !== initialWidgets) {
65085
+ prevInitialWidgetsRef.current = initialWidgets;
65086
+ setWidgets(initialWidgets);
64997
65087
  }
64998
- }, [persistState, persistKey]);
64999
- useEffect(() => {
65000
- if (persistState && typeof window !== "undefined") {
65001
- const state = {
65002
- collapsed,
65003
- expandedSections,
65004
- searchQuery: currentSearchQuery,
65005
- pinnedItems,
65006
- recentItems: []
65007
- };
65008
- localStorage.setItem(persistKey, JSON.stringify(state));
65009
- onStateChange?.(state);
65088
+ }, [initialWidgets]);
65089
+ t__default.useEffect(() => {
65090
+ if (propTimeRange && prevTimeRangeRef.current !== propTimeRange) {
65091
+ prevTimeRangeRef.current = propTimeRange;
65092
+ setTimeRange(propTimeRange);
65010
65093
  }
65011
- }, [collapsed, expandedSections, currentSearchQuery, pinnedItems, persistState, persistKey, onStateChange]);
65012
- useEffect(() => {
65013
- const checkMobile = () => {
65014
- setIsMobile(window.innerWidth < 768);
65015
- };
65016
- checkMobile();
65017
- window.addEventListener("resize", checkMobile);
65018
- return () => window.removeEventListener("resize", checkMobile);
65019
- }, []);
65020
- useEffect(() => {
65021
- const sectionsToExpand = sections.filter((section) => section.defaultExpanded !== false).map((section) => section.id);
65022
- setExpandedSections(sectionsToExpand);
65023
- }, [sections]);
65024
- useEffect(() => {
65025
- if (!keyboardShortcuts)
65026
- return;
65027
- const handleKeyDown3 = (e) => {
65028
- if ((e.metaKey || e.ctrlKey) && e.key === "k") {
65029
- e.preventDefault();
65030
- searchInputRef.current?.focus();
65031
- }
65032
- if ((e.metaKey || e.ctrlKey) && e.key === "b") {
65033
- e.preventDefault();
65034
- if (isMobile) {
65035
- setIsOpen(!isOpen);
65036
- } else {
65037
- setCollapsed(!collapsed);
65038
- }
65039
- }
65040
- };
65041
- document.addEventListener("keydown", handleKeyDown3);
65042
- return () => document.removeEventListener("keydown", handleKeyDown3);
65043
- }, [keyboardShortcuts, isMobile, isOpen, collapsed]);
65044
- useEffect(() => {
65045
- if (!animatedBackground)
65094
+ }, [propTimeRange]);
65095
+ t__default.useEffect(() => {
65096
+ if (!realtime || mode !== "widgets")
65046
65097
  return;
65047
- const handleMouseMove2 = (e) => {
65048
- const rect = document.querySelector(".sidebar-container")?.getBoundingClientRect();
65049
- if (rect) {
65050
- mouseX.set(e.clientX - rect.left);
65051
- mouseY.set(e.clientY - rect.top);
65052
- }
65053
- };
65054
- document.addEventListener("mousemove", handleMouseMove2);
65055
- return () => document.removeEventListener("mousemove", handleMouseMove2);
65056
- }, [animatedBackground, mouseX, mouseY]);
65057
- const toggleSection = useCallback((sectionId) => {
65058
- setExpandedSections(
65059
- (prev) => prev.includes(sectionId) ? prev.filter((id) => id !== sectionId) : [...prev, sectionId]
65060
- );
65061
- }, []);
65062
- useCallback((itemId) => {
65063
- setPinnedItems(
65064
- (prev) => prev.includes(itemId) ? prev.filter((id) => id !== itemId) : [...prev, itemId]
65065
- );
65066
- }, []);
65067
- const handleItemClick = useCallback((item) => {
65068
- if (item.action) {
65069
- item.action();
65070
- } else if (item.href && onNavigate) {
65071
- onNavigate(item.href);
65072
- if (isMobile) {
65073
- setIsOpen(false);
65074
- }
65098
+ const interval = setInterval(() => {
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
+ });
65117
+ }, 5e3);
65118
+ return () => clearInterval(interval);
65119
+ }, [realtime, mode]);
65120
+ const generateDefaultData = t__default.useCallback((type) => {
65121
+ switch (type) {
65122
+ case "metric":
65123
+ return {
65124
+ id: "new-metric",
65125
+ title: "New Metric",
65126
+ value: 0,
65127
+ icon: /* @__PURE__ */ jsx(BarChart3, { className: "h-4 w-4" }),
65128
+ color: "primary"
65129
+ };
65130
+ case "chart":
65131
+ return {
65132
+ type: "line",
65133
+ data: [
65134
+ { name: "Mon", value: 100 },
65135
+ { name: "Tue", value: 120 },
65136
+ { name: "Wed", value: 110 },
65137
+ { name: "Thu", value: 130 },
65138
+ { name: "Fri", value: 125 }
65139
+ ]
65140
+ };
65141
+ case "activity":
65142
+ return {
65143
+ items: [],
65144
+ realtime: true
65145
+ };
65146
+ default:
65147
+ return {};
65075
65148
  }
65076
- }, [onNavigate, isMobile]);
65077
- useEffect(() => {
65078
- setCurrentSearchQuery(searchQuery);
65079
- }, [searchQuery]);
65080
- const handleSearch = useCallback((value) => {
65081
- setCurrentSearchQuery(value);
65082
- onSearchChange?.(value);
65083
- }, [onSearchChange]);
65084
- const filterItems = useCallback((items, query) => {
65085
- if (!query)
65086
- return items;
65087
- return items.filter((item) => {
65088
- const matchesTitle = item.title.toLowerCase().includes(query.toLowerCase());
65089
- const hasMatchingChildren = item.items?.some(
65090
- (child) => child.title.toLowerCase().includes(query.toLowerCase())
65091
- );
65092
- return matchesTitle || hasMatchingChildren;
65093
- });
65094
65149
  }, []);
65095
- const filteredSections = useMemo(() => {
65096
- if (!currentSearchQuery) {
65097
- return sections.map((section) => ({
65098
- ...section,
65099
- filteredItems: section.items.map((item) => ({
65100
- ...item,
65101
- filteredChildren: item.items
65102
- }))
65103
- }));
65104
- }
65105
- return sections.map((section) => ({
65106
- ...section,
65107
- filteredItems: filterItems(section.items, currentSearchQuery).map((item) => ({
65108
- ...item,
65109
- filteredChildren: item.items ? filterItems(item.items, currentSearchQuery) : void 0
65110
- }))
65111
- })).filter((section) => section.filteredItems.length > 0);
65112
- }, [sections, currentSearchQuery, filterItems]);
65113
- const renderCollapsedHoverContent = useCallback((item) => {
65114
- const hasChildren = item.items && item.items.length > 0;
65115
- if (!hasChildren && !item.title)
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)
65116
65176
  return null;
65117
- return /* @__PURE__ */ jsxs("div", { className: cn(
65118
- "min-w-[200px] p-2",
65119
- glassmorphism && "bg-background/95 backdrop-blur-sm"
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"
65120
65180
  ), children: [
65121
- /* @__PURE__ */ jsx("div", { className: "font-medium px-2 py-1 text-sm", children: item.title }),
65122
- hasChildren && /* @__PURE__ */ jsx("div", { className: "mt-1 space-y-0.5", children: item.items?.map((childItem) => {
65123
- const isChildActive = childItem.href === activePath;
65124
- const hasGrandChildren = childItem.items && childItem.items.length > 0;
65125
- return /* @__PURE__ */ jsx("div", { className: "relative", children: hasGrandChildren ? /* @__PURE__ */ jsxs(HoverCard2, { openDelay: 200, closeDelay: 100, children: [
65126
- /* @__PURE__ */ jsx(HoverCardTrigger2, { asChild: true, children: /* @__PURE__ */ jsxs(
65127
- "button",
65181
+ /* @__PURE__ */ jsxs(SheetHeader, { children: [
65182
+ /* @__PURE__ */ jsx(SheetTitle, { children: "Widget Library" }),
65183
+ /* @__PURE__ */ jsx(SheetDescription, { children: "Add widgets to customize your dashboard" })
65184
+ ] }),
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,
65128
65190
  {
65129
- onClick: () => handleItemClick(childItem),
65130
- disabled: childItem.disabled,
65131
- className: cn(
65132
- "w-full flex items-center justify-between gap-2 rounded-md px-2 py-1.5 text-sm transition-colors",
65133
- "hover:bg-accent hover:text-accent-foreground",
65134
- isChildActive && "bg-primary/10 text-primary font-medium",
65135
- childItem.disabled && "opacity-50 cursor-not-allowed"
65136
- ),
65137
- children: [
65138
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
65139
- childItem.icon && /* @__PURE__ */ jsx("span", { className: "flex-shrink-0", children: childItem.icon }),
65140
- /* @__PURE__ */ jsx("span", { className: "truncate", children: childItem.title })
65141
- ] }),
65142
- /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 flex-shrink-0" })
65143
- ]
65144
- }
65145
- ) }),
65146
- /* @__PURE__ */ jsx(
65147
- HoverCardContent2,
65148
- {
65149
- side: "right",
65150
- align: "start",
65151
- sideOffset: 10,
65152
- className: cn(
65153
- "p-2",
65154
- glassmorphism && "bg-background/95 backdrop-blur-sm"
65155
- ),
65156
- children: /* @__PURE__ */ jsx("div", { className: "space-y-0.5", children: childItem.items?.map((grandChild) => {
65157
- const isGrandChildActive = grandChild.href === activePath;
65158
- return /* @__PURE__ */ jsxs(
65159
- "button",
65160
- {
65161
- onClick: () => handleItemClick(grandChild),
65162
- disabled: grandChild.disabled,
65163
- className: cn(
65164
- "w-full flex items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors",
65165
- "hover:bg-accent hover:text-accent-foreground",
65166
- isGrandChildActive && "bg-primary/10 text-primary font-medium",
65167
- grandChild.disabled && "opacity-50 cursor-not-allowed"
65168
- ),
65169
- children: [
65170
- grandChild.icon && /* @__PURE__ */ jsx("span", { className: "flex-shrink-0", children: grandChild.icon }),
65171
- /* @__PURE__ */ jsx("span", { className: "truncate", children: grandChild.title }),
65172
- grandChild.badge && /* @__PURE__ */ jsx(
65173
- MoonUIBadgePro,
65174
- {
65175
- variant: grandChild.badgeVariant || "secondary",
65176
- className: "ml-auto flex-shrink-0 text-[10px] px-1.5 py-0 h-5",
65177
- children: grandChild.badge
65178
- }
65179
- )
65180
- ]
65181
- },
65182
- grandChild.id
65183
- );
65184
- }) })
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"
65185
65198
  }
65186
65199
  )
65187
- ] }) : /* @__PURE__ */ jsxs(
65188
- "button",
65189
- {
65190
- onClick: () => handleItemClick(childItem),
65191
- disabled: childItem.disabled,
65192
- className: cn(
65193
- "w-full flex items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors",
65194
- "hover:bg-accent hover:text-accent-foreground",
65195
- isChildActive && "bg-primary/10 text-primary font-medium",
65196
- childItem.disabled && "opacity-50 cursor-not-allowed"
65197
- ),
65198
- children: [
65199
- childItem.icon && /* @__PURE__ */ jsx("span", { className: "flex-shrink-0", children: childItem.icon }),
65200
- /* @__PURE__ */ jsx("span", { className: "truncate", children: childItem.title }),
65201
- childItem.badge && /* @__PURE__ */ jsx(
65202
- MoonUIBadgePro,
65203
- {
65204
- variant: childItem.badgeVariant || "secondary",
65205
- className: "ml-auto flex-shrink-0 text-[10px] px-1.5 py-0 h-5",
65206
- children: childItem.badge
65207
- }
65208
- )
65209
- ]
65210
- }
65211
- ) }, childItem.id);
65212
- }) })
65213
- ] });
65214
- }, [activePath, glassmorphism, handleItemClick]);
65215
- const renderItem = useCallback((item, depth = 0, filteredChildren) => {
65216
- const isActive2 = item.href === activePath;
65217
- const isPinned = pinnedItems.includes(item.id);
65218
- const hasChildren = item.items && item.items.length > 0;
65219
- const isExpanded = expandedSections.includes(item.id);
65220
- const shouldShowHoverMenu = collapsed && !isMobile && depth === 0 && (hasChildren || item.title);
65221
- const shouldShowTooltip = item.tooltip && !collapsed && !shouldShowHoverMenu;
65222
- const itemContent = /* @__PURE__ */ jsxs(
65223
- "button",
65224
- {
65225
- onClick: () => {
65226
- if (hasChildren) {
65227
- toggleSection(item.id);
65228
- } else {
65229
- handleItemClick(item);
65230
- }
65231
- },
65232
- className: cn(
65233
- "flex items-center gap-3 rounded-lg px-3 py-2 text-sm transition-all",
65234
- fullWidthItems ? "w-[calc(100%-1.5rem)] mx-3" : "w-full",
65235
- "hover:bg-accent hover:text-accent-foreground",
65236
- isActive2 && "bg-primary/10 text-primary font-medium",
65237
- item.disabled && "opacity-50 cursor-not-allowed",
65238
- depth > 0 && "ml-6 text-xs",
65239
- collapsed && depth === 0 && "justify-center px-2",
65240
- customStyles?.hover
65241
- ),
65242
- disabled: item.disabled,
65243
- children: [
65244
- item.icon && /* @__PURE__ */ jsx("span", { className: cn(
65245
- "flex-shrink-0",
65246
- collapsed && depth === 0 && "mx-auto"
65247
- ), children: item.icon }),
65248
- (!collapsed || depth > 0) && /* @__PURE__ */ jsxs(Fragment, { children: [
65249
- /* @__PURE__ */ jsx("span", { className: "flex-1 text-left truncate", children: item.title }),
65250
- item.badge && /* @__PURE__ */ jsx(
65251
- MoonUIBadgePro,
65252
- {
65253
- variant: item.badgeVariant || "secondary",
65254
- className: "ml-auto flex-shrink-0 text-[10px] px-1.5 py-0 h-5",
65255
- children: item.badge
65256
- }
65257
- ),
65258
- hasChildren && depth === 0 && /* @__PURE__ */ jsx(
65259
- ChevronDown,
65260
- {
65261
- className: cn(
65262
- "h-4 w-4 flex-shrink-0 transition-transform",
65263
- isExpanded && "rotate-180"
65264
- )
65265
- }
65266
- ),
65267
- isPinned && /* @__PURE__ */ jsx(Pin, { className: "h-3 w-3 flex-shrink-0" })
65268
- ] })
65269
- ]
65270
- }
65271
- );
65272
- if (shouldShowHoverMenu) {
65273
- return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(HoverCard2, { openDelay: 200, closeDelay: 100, children: [
65274
- /* @__PURE__ */ jsx(HoverCardTrigger2, { asChild: true, children: itemContent }),
65275
- /* @__PURE__ */ jsx(
65276
- HoverCardContent2,
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,
65277
65203
  {
65278
- side: "right",
65279
- align: "start",
65280
- sideOffset: 10,
65281
- className: cn(
65282
- "p-0 w-auto",
65283
- glassmorphism && "bg-background/95 backdrop-blur-sm",
65284
- "animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95"
65285
- ),
65286
- children: /* @__PURE__ */ jsx(
65287
- motion.div,
65204
+ whileHover: { scale: 1.02 },
65205
+ whileTap: { scale: 0.98 },
65206
+ children: /* @__PURE__ */ jsxs(
65207
+ MoonUIButtonPro,
65288
65208
  {
65289
- initial: { opacity: 0, x: -10 },
65290
- animate: { opacity: 1, x: 0 },
65291
- exit: { opacity: 0, x: -10 },
65292
- transition: { duration: 0.15 },
65293
- children: renderCollapsedHoverContent(item)
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
+ ]
65294
65216
  }
65295
65217
  )
65296
- }
65297
- )
65298
- ] }) }, item.id);
65299
- }
65300
- return /* @__PURE__ */ jsxs("div", { children: [
65301
- shouldShowTooltip ? /* @__PURE__ */ jsx(MoonUITooltipProviderPro, { children: /* @__PURE__ */ jsxs(MoonUITooltipPro, { children: [
65302
- /* @__PURE__ */ jsx(MoonUITooltipTriggerPro, { asChild: true, children: itemContent }),
65303
- /* @__PURE__ */ jsx(MoonUITooltipContentPro, { side: "right", children: /* @__PURE__ */ jsx("p", { children: item.tooltip }) })
65304
- ] }) }) : itemContent,
65305
- hasChildren && !collapsed && filteredChildren && /* @__PURE__ */ jsx(AnimatePresence, { children: isExpanded && /* @__PURE__ */ jsx(
65306
- motion.div,
65307
- {
65308
- initial: { height: 0, opacity: 0 },
65309
- animate: { height: "auto", opacity: 1 },
65310
- exit: { height: 0, opacity: 0 },
65311
- transition: { duration: 0.2 },
65312
- className: "overflow-hidden",
65313
- children: /* @__PURE__ */ jsx("div", { className: "pt-1 space-y-1", children: filteredChildren.map(
65314
- (child) => renderItem(child, depth + 1)
65315
- ) })
65316
- }
65317
- ) })
65318
- ] }, item.id);
65319
- }, [activePath, pinnedItems, expandedSections, collapsed, customStyles, handleItemClick, toggleSection, isMobile, glassmorphism, renderCollapsedHoverContent, fullWidthItems]);
65320
- const SidebarHeader = t__default.memo(() => {
65321
- return /* @__PURE__ */ jsxs("div", { className: cn(
65322
- "flex items-center gap-3 p-4 border-b",
65323
- collapsed && !isMobile && "justify-center px-2"
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"
65324
65230
  ), children: [
65325
- branding && /* @__PURE__ */ jsxs(Fragment, { children: [
65326
- branding.logo,
65327
- (!collapsed || isMobile) && branding.title && /* @__PURE__ */ jsx("span", { className: "font-semibold text-lg", children: branding.title })
65328
- ] }),
65329
- isMobile && /* @__PURE__ */ jsx(
65330
- MoonUIButtonPro,
65331
- {
65332
- variant: "ghost",
65333
- size: "sm",
65334
- className: "ml-auto h-8 w-8 p-0",
65335
- onClick: () => setIsOpen(false),
65336
- children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
65337
- }
65338
- ),
65339
- !isMobile && collapsible && /* @__PURE__ */ jsx(
65340
- MoonUIButtonPro,
65341
- {
65342
- variant: "ghost",
65343
- size: "sm",
65344
- className: cn(
65345
- "h-8 w-8 p-0",
65346
- !collapsed && "ml-auto"
65347
- ),
65348
- onClick: () => setCollapsed(!collapsed),
65349
- children: collapsed ? /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" })
65350
- }
65351
- )
65352
- ] });
65353
- });
65354
- const SidebarMenuContent = t__default.memo(() => {
65355
- return /* @__PURE__ */ jsx(ScrollArea, { className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "p-4 space-y-6", children: [
65356
- pinnedItems.length > 0 && (!collapsed || isMobile) && /* @__PURE__ */ jsxs("div", { children: [
65357
- /* @__PURE__ */ jsx("h4", { className: "text-xs font-medium text-muted-foreground mb-2", children: "Pinned" }),
65358
- /* @__PURE__ */ jsx("div", { className: "space-y-1", children: sections.flatMap(
65359
- (section) => section.items.filter((item) => pinnedItems.includes(item.id))
65360
- ).map((item) => renderItem(item)) }),
65361
- /* @__PURE__ */ jsx(MoonUISeparatorPro, { className: "mt-4" })
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" })
65362
65234
  ] }),
65363
- filteredSections.map((section, index2) => /* @__PURE__ */ jsxs("div", { children: [
65364
- section.title && (!collapsed || isMobile) && /* @__PURE__ */ jsx("h4", { className: "text-xs font-medium text-muted-foreground mb-2", children: section.title }),
65365
- /* @__PURE__ */ jsx("div", { className: "space-y-1", children: section.filteredItems.map((item) => renderItem(item, 0, item.filteredChildren)) }),
65366
- section.showDivider && index2 < filteredSections.length - 1 && /* @__PURE__ */ jsx(MoonUISeparatorPro, { className: "mt-4" })
65367
- ] }, section.id))
65368
- ] }) });
65369
- });
65370
- const SidebarFooter = t__default.memo(() => {
65371
- return footer ? /* @__PURE__ */ jsxs("div", { className: "border-t p-4", children: [
65372
- /* @__PURE__ */ jsx("div", { className: "space-y-1", children: footer.items.map((item) => renderItem(item)) }),
65373
- showThemeToggle && (!collapsed || isMobile) && /* @__PURE__ */ jsxs("div", { className: "mt-3 flex items-center justify-between", children: [
65374
- /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Theme" }),
65375
- /* @__PURE__ */ jsxs(MoonUIDropdownMenuPro, { children: [
65376
- /* @__PURE__ */ jsx(MoonUIDropdownMenuTriggerPro, { asChild: true, children: /* @__PURE__ */ jsxs(MoonUIButtonPro, { variant: "ghost", size: "sm", className: "h-7 px-2", children: [
65377
- theme === "light" && /* @__PURE__ */ jsx(Sun, { className: "h-3 w-3" }),
65378
- theme === "dark" && /* @__PURE__ */ jsx(Moon, { className: "h-3 w-3" }),
65379
- theme === "system" && /* @__PURE__ */ jsx(Monitor, { className: "h-3 w-3" })
65380
- ] }) }),
65381
- /* @__PURE__ */ jsxs(MoonUIDropdownMenuContentPro, { align: "end", children: [
65382
- /* @__PURE__ */ jsxs(MoonUIDropdownMenuItemPro, { onClick: () => onThemeChange?.("light"), children: [
65383
- /* @__PURE__ */ jsx(Sun, { className: "mr-2 h-4 w-4" }),
65384
- "Light"
65385
- ] }),
65386
- /* @__PURE__ */ jsxs(MoonUIDropdownMenuItemPro, { onClick: () => onThemeChange?.("dark"), children: [
65387
- /* @__PURE__ */ jsx(Moon, { className: "mr-2 h-4 w-4" }),
65388
- "Dark"
65389
- ] }),
65390
- /* @__PURE__ */ jsxs(MoonUIDropdownMenuItemPro, { onClick: () => onThemeChange?.("system"), children: [
65391
- /* @__PURE__ */ jsx(Monitor, { className: "mr-2 h-4 w-4" }),
65392
- "System"
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
+ ] })
65393
65264
  ] })
65394
- ] })
65395
- ] })
65396
- ] })
65397
- ] }) : null;
65398
- });
65399
- const SidebarContent = t__default.memo(() => {
65400
- return /* @__PURE__ */ jsxs(Fragment, { children: [
65401
- /* @__PURE__ */ jsx(SidebarMenuContent, {}),
65402
- /* @__PURE__ */ jsx(SidebarFooter, {})
65403
- ] });
65404
- });
65405
- const sidebarClasses = cn(
65406
- "moonui-pro flex h-full flex-col bg-background border-r",
65407
- glassmorphism && "bg-background/80 backdrop-blur-xl border-white/10",
65408
- collapsed && !isMobile && "w-16",
65409
- !collapsed && !isMobile && "w-64",
65410
- customStyles?.background,
65411
- customStyles?.border,
65412
- className
65413
- );
65414
- if (isMobile) {
65415
- return /* @__PURE__ */ jsxs(Fragment, { children: [
65416
- floatingActionButton && /* @__PURE__ */ jsx(
65417
- MoonUIButtonPro,
65418
- {
65419
- onClick: () => setIsOpen(true),
65420
- className: cn(
65421
- "fixed z-40 h-12 w-12 rounded-full shadow-lg md:hidden",
65422
- floatingActionButtonClassName
65423
- ),
65424
- size: "icon",
65425
- style: {
65426
- bottom: floatingActionButtonPosition?.bottom,
65427
- left: floatingActionButtonPosition?.left,
65428
- right: floatingActionButtonPosition?.right,
65429
- top: floatingActionButtonPosition?.top
65430
65265
  },
65431
- children: /* @__PURE__ */ jsx(Menu, { className: "h-5 w-5" })
65432
- }
65266
+ template.id
65267
+ )) }) })
65268
+ ] })
65269
+ ] }) });
65270
+ }, [showTemplates, glassmorphism, templates, applyTemplate]);
65271
+ return /* @__PURE__ */ jsxs(
65272
+ motion.div,
65273
+ {
65274
+ className: cn(
65275
+ "w-full min-h-screen",
65276
+ glassmorphism && "bg-gradient-to-br",
65277
+ glassmorphism && THEME_COLORS[selectedTheme],
65278
+ className
65433
65279
  ),
65434
- /* @__PURE__ */ jsx(Sheet, { open: isOpen, onOpenChange: setIsOpen, children: /* @__PURE__ */ jsx(SheetContent, { side: "left", className: "w-80 p-0", children: /* @__PURE__ */ jsxs("div", { className: cn(sidebarClasses, "sidebar-container flex flex-col"), children: [
65435
- animatedBackground && /* @__PURE__ */ jsx(
65436
- motion.div,
65437
- {
65438
- className: "absolute inset-0 opacity-30",
65439
- style: {
65440
- background: `radial-gradient(circle at ${springX}px ${springY}px, rgba(var(--primary-rgb), 0.15), transparent 50%)`
65441
- }
65442
- }
65443
- ),
65444
- /* @__PURE__ */ jsx(SidebarHeader, {}),
65445
- showSearch && (!collapsed || isMobile) && /* @__PURE__ */ jsx(
65446
- SearchInput,
65447
- {
65448
- searchInputRef,
65449
- searchPlaceholder,
65450
- initialValue: currentSearchQuery,
65451
- onSearchChange: handleSearch,
65452
- keyboardShortcuts
65453
- },
65454
- "sidebar-search-mobile"
65455
- ),
65456
- /* @__PURE__ */ jsx(SidebarContent, {})
65457
- ] }) }) })
65458
- ] });
65459
- }
65460
- return /* @__PURE__ */ jsxs("aside", { className: cn(sidebarClasses, "sidebar-container hidden md:flex flex-col"), children: [
65461
- animatedBackground && /* @__PURE__ */ jsx(
65462
- motion.div,
65463
- {
65464
- className: "absolute inset-0 opacity-30",
65465
- style: {
65466
- background: `radial-gradient(circle at ${springX}px ${springY}px, rgba(var(--primary-rgb), 0.15), transparent 50%)`
65467
- }
65468
- }
65469
- ),
65470
- /* @__PURE__ */ jsx(SidebarHeader, {}),
65471
- showSearch && (!collapsed || isMobile) && /* @__PURE__ */ jsx(
65472
- SearchInput,
65473
- {
65474
- searchInputRef,
65475
- searchPlaceholder,
65476
- initialValue: currentSearchQuery,
65477
- onSearchChange: handleSearch,
65478
- keyboardShortcuts
65479
- },
65480
- "sidebar-search-desktop"
65481
- ),
65482
- /* @__PURE__ */ jsx(SidebarContent, {})
65483
- ] });
65484
- }
65485
- function Sidebar(props) {
65486
- const { hasProAccess, isLoading } = useSubscription();
65487
- if (!isLoading && !hasProAccess) {
65488
- return /* @__PURE__ */ jsx(MoonUICardPro, { className: cn("w-full max-w-xs", props.className), children: /* @__PURE__ */ jsx(MoonUICardContentPro, { className: "py-12 text-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
65489
- /* @__PURE__ */ jsx("div", { className: "rounded-full bg-purple-100 dark:bg-purple-900/30 p-3 w-fit mx-auto", children: /* @__PURE__ */ jsx(Lock, { className: "h-6 w-6 text-purple-600 dark:text-purple-400" }) }),
65490
- /* @__PURE__ */ jsxs("div", { children: [
65491
- /* @__PURE__ */ jsx("h3", { className: "font-semibold text-lg mb-2", children: "Pro Feature" }),
65492
- /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm mb-4", children: "Advanced Sidebar is available exclusively to MoonUI Pro subscribers." }),
65493
- /* @__PURE__ */ jsx("a", { href: "/pricing", children: /* @__PURE__ */ jsxs(MoonUIButtonPro, { size: "sm", children: [
65494
- /* @__PURE__ */ jsx(Sparkles, { className: "mr-2 h-4 w-4" }),
65495
- "Upgrade to Pro"
65496
- ] }) })
65497
- ] })
65498
- ] }) }) });
65499
- }
65500
- return /* @__PURE__ */ jsx(SidebarInternal, { ...props });
65501
- }
65502
- var MoonUISidebarPro = Sidebar;
65503
- var DASHBOARD_TEMPLATES = [
65504
- {
65505
- id: "analytics",
65506
- name: "Analytics Dashboard",
65507
- description: "Comprehensive analytics with metrics and charts",
65508
- category: "analytics",
65509
- theme: "analytics",
65510
- widgets: [
65511
- {
65512
- type: "metric",
65513
- title: "Total Revenue",
65514
- size: { w: 3, h: 2 },
65515
- position: { x: 0, y: 0 },
65516
- data: {
65517
- id: "revenue",
65518
- title: "Total Revenue",
65519
- value: 125430,
65520
- change: { value: 12, type: "increase", period: "last month" },
65521
- color: "success",
65522
- icon: /* @__PURE__ */ jsx(DollarSign, { className: "h-4 w-4" }),
65523
- sparkline: [100, 120, 115, 125, 130, 128, 132],
65524
- unit: "$"
65525
- }
65526
- },
65527
- {
65528
- type: "metric",
65529
- title: "Active Users",
65530
- size: { w: 3, h: 2 },
65531
- position: { x: 3, y: 0 },
65532
- data: {
65533
- id: "users",
65534
- title: "Active Users",
65535
- value: 2543,
65536
- change: { value: 8, type: "increase", period: "last week" },
65537
- color: "primary",
65538
- icon: /* @__PURE__ */ jsx(Users, { className: "h-4 w-4" }),
65539
- sparkline: [200, 220, 210, 230, 225, 240, 254]
65540
- }
65541
- },
65542
- {
65543
- type: "chart",
65544
- title: "Revenue Trend",
65545
- size: { w: 6, h: 4 },
65546
- position: { x: 0, y: 2 },
65547
- data: {
65548
- type: "area",
65549
- data: [
65550
- { name: "Jan", revenue: 4e3, profit: 2400 },
65551
- { name: "Feb", revenue: 3e3, profit: 1398 },
65552
- { name: "Mar", revenue: 5e3, profit: 3200 },
65553
- { name: "Apr", revenue: 4500, profit: 2900 },
65554
- { name: "May", revenue: 6e3, profit: 3800 },
65555
- { name: "Jun", revenue: 5500, profit: 3400 }
65556
- ]
65557
- }
65558
- },
65559
- {
65560
- type: "activity",
65561
- title: "Recent Activity",
65562
- size: { w: 3, h: 6 },
65563
- position: { x: 9, y: 0 },
65564
- data: {
65565
- realtime: true,
65566
- items: [
65567
- {
65568
- id: "1",
65569
- type: "success",
65570
- title: "completed a purchase",
65571
- description: "Order #12345 - $250.00",
65572
- timestamp: new Date(Date.now() - 1e3 * 60 * 5),
65573
- user: { name: "John Doe" }
65574
- },
65575
- {
65576
- id: "2",
65577
- type: "info",
65578
- title: "signed up",
65579
- description: "New user registration",
65580
- timestamp: new Date(Date.now() - 1e3 * 60 * 15),
65581
- user: { name: "Jane Smith" }
65582
- }
65583
- ]
65584
- }
65585
- }
65586
- ]
65587
- },
65588
- {
65589
- id: "sales",
65590
- name: "Sales Dashboard",
65591
- description: "Track sales performance and targets",
65592
- category: "sales",
65593
- theme: "sales",
65594
- widgets: [
65595
- // Sales-specific widgets
65596
- ]
65597
- },
65598
- {
65599
- id: "monitoring",
65600
- name: "System Monitoring",
65601
- description: "Monitor system health and performance",
65602
- category: "operations",
65603
- theme: "monitoring",
65604
- widgets: [
65605
- // Monitoring widgets
65606
- ]
65607
- }
65608
- ];
65609
- var WIDGET_TYPE_ICONS = {
65610
- metric: /* @__PURE__ */ jsx(BarChart3, { className: "h-4 w-4" }),
65611
- chart: /* @__PURE__ */ jsx(Activity, { className: "h-4 w-4" }),
65612
- table: /* @__PURE__ */ jsx(Table$1, { className: "h-4 w-4" }),
65613
- map: /* @__PURE__ */ jsx(Map$1, { className: "h-4 w-4" }),
65614
- activity: /* @__PURE__ */ jsx(Clock, { className: "h-4 w-4" }),
65615
- calendar: /* @__PURE__ */ jsx(Calendar$1, { className: "h-4 w-4" }),
65616
- progress: /* @__PURE__ */ jsx(Target, { className: "h-4 w-4" }),
65617
- comparison: /* @__PURE__ */ jsx(TrendingUp, { className: "h-4 w-4" })
65618
- };
65619
- var THEME_COLORS = {
65620
- analytics: "from-blue-500/10 to-purple-500/10",
65621
- sales: "from-green-500/10 to-emerald-500/10",
65622
- monitoring: "from-orange-500/10 to-red-500/10",
65623
- finance: "from-indigo-500/10 to-blue-500/10",
65624
- custom: "from-gray-500/10 to-gray-600/10"
65625
- };
65626
- function formatRelativeTime(date) {
65627
- const now = /* @__PURE__ */ new Date();
65628
- const diffInSeconds = Math.floor((now.getTime() - date.getTime()) / 1e3);
65629
- if (diffInSeconds < 60)
65630
- return "just now";
65631
- if (diffInSeconds < 3600)
65632
- return `${Math.floor(diffInSeconds / 60)}m ago`;
65633
- if (diffInSeconds < 86400)
65634
- return `${Math.floor(diffInSeconds / 3600)}h ago`;
65635
- if (diffInSeconds < 604800)
65636
- return `${Math.floor(diffInSeconds / 86400)}d ago`;
65637
- return date.toLocaleDateString();
65638
- }
65639
- function DashboardInternal({
65640
- config,
65641
- widgets: initialWidgets = [],
65642
- templates = DASHBOARD_TEMPLATES,
65643
- onConfigChange,
65644
- onWidgetAdd,
65645
- onWidgetRemove,
65646
- onWidgetUpdate,
65647
- onExport,
65648
- onImport,
65649
- className,
65650
- showHeader = true,
65651
- title = "Dashboard",
65652
- description = "Real-time analytics and insights",
65653
- editable = true,
65654
- realtime = false,
65655
- glassmorphism = true,
65656
- children,
65657
- mode = "widgets",
65658
- contentClassName,
65659
- sidebarPosition = "none",
65660
- sidebarContent,
65661
- sidebarSections,
65662
- sidebarCollapsible = true,
65663
- sidebarDefaultCollapsed = false,
65664
- notifications = [],
65665
- onNotificationClick,
65666
- onNotificationMarkAsRead,
65667
- onNotificationMarkAllAsRead,
65668
- onNotificationClear,
65669
- onNotificationClearAll,
65670
- user,
65671
- userMenuItems,
65672
- onUserMenuClick,
65673
- onProfileClick,
65674
- onLogout,
65675
- onSearch,
65676
- onThemeChange,
65677
- onMenuClick,
65678
- onRefresh,
65679
- headerActions,
65680
- timeRange: propTimeRange,
65681
- onTimeRangeChange,
65682
- logo,
65683
- brandName
65684
- }) {
65685
- const [editMode, setEditMode] = t__default.useState(false);
65686
- const [widgets, setWidgets] = t__default.useState(() => initialWidgets);
65687
- const [selectedTheme, setSelectedTheme] = t__default.useState("analytics");
65688
- const [timeRange, setTimeRange] = t__default.useState(() => propTimeRange);
65689
- const [searchQuery, setSearchQuery] = t__default.useState("");
65690
- const [showWidgetLibrary, setShowWidgetLibrary] = t__default.useState(false);
65691
- const [showTemplates, setShowTemplates] = t__default.useState(false);
65692
- const [refreshing, setRefreshing] = t__default.useState(false);
65693
- const [showNotifications, setShowNotifications] = t__default.useState(false);
65694
- const prevInitialWidgetsRef = t__default.useRef(initialWidgets);
65695
- const prevTimeRangeRef = t__default.useRef(propTimeRange);
65696
- t__default.useEffect(() => {
65697
- if (prevInitialWidgetsRef.current !== initialWidgets) {
65698
- prevInitialWidgetsRef.current = initialWidgets;
65699
- setWidgets(initialWidgets);
65700
- }
65701
- }, [initialWidgets]);
65702
- t__default.useEffect(() => {
65703
- if (propTimeRange && prevTimeRangeRef.current !== propTimeRange) {
65704
- prevTimeRangeRef.current = propTimeRange;
65705
- setTimeRange(propTimeRange);
65706
- }
65707
- }, [propTimeRange]);
65708
- t__default.useEffect(() => {
65709
- if (!realtime || mode !== "widgets")
65710
- return;
65711
- const interval = setInterval(() => {
65712
- setWidgets((prev) => {
65713
- if (!prev || prev.length === 0)
65714
- return prev;
65715
- return prev.map((widget) => {
65716
- if (widget.type === "metric" && widget.data) {
65717
- const newValue = typeof widget.data.value === "number" ? widget.data.value + Math.floor(Math.random() * 10 - 5) : widget.data.value;
65718
- return {
65719
- ...widget,
65720
- data: {
65721
- ...widget.data,
65722
- value: newValue,
65723
- lastUpdated: /* @__PURE__ */ new Date()
65724
- }
65725
- };
65726
- }
65727
- return widget;
65728
- });
65729
- });
65730
- }, 5e3);
65731
- return () => clearInterval(interval);
65732
- }, [realtime, mode]);
65733
- const generateDefaultData = t__default.useCallback((type) => {
65734
- switch (type) {
65735
- case "metric":
65736
- return {
65737
- id: "new-metric",
65738
- title: "New Metric",
65739
- value: 0,
65740
- icon: /* @__PURE__ */ jsx(BarChart3, { className: "h-4 w-4" }),
65741
- color: "primary"
65742
- };
65743
- case "chart":
65744
- return {
65745
- type: "line",
65746
- data: [
65747
- { name: "Mon", value: 100 },
65748
- { name: "Tue", value: 120 },
65749
- { name: "Wed", value: 110 },
65750
- { name: "Thu", value: 130 },
65751
- { name: "Fri", value: 125 }
65752
- ]
65753
- };
65754
- case "activity":
65755
- return {
65756
- items: [],
65757
- realtime: true
65758
- };
65759
- default:
65760
- return {};
65761
- }
65762
- }, []);
65763
- const handleAddWidget = t__default.useCallback((type) => {
65764
- const newWidget = {
65765
- id: `widget-${Date.now()}`,
65766
- type,
65767
- title: `New ${type} Widget`,
65768
- size: { w: 3, h: 3 },
65769
- position: { x: 0, y: 0 },
65770
- data: generateDefaultData(type)
65771
- };
65772
- setWidgets((prev) => [...prev, newWidget]);
65773
- onWidgetAdd?.(newWidget);
65774
- setShowWidgetLibrary(false);
65775
- }, [onWidgetAdd, generateDefaultData]);
65776
- const applyTemplate = t__default.useCallback((template) => {
65777
- const newWidgets = template.widgets.map((w, index2) => ({
65778
- ...w,
65779
- id: `widget-${Date.now()}-${index2}`,
65780
- position: w.position || { x: index2 * 3 % 12, y: Math.floor(index2 * 3 / 12) * 3 },
65781
- size: w.size || { w: 3, h: 3 }
65782
- }));
65783
- setWidgets(newWidgets);
65784
- setSelectedTheme(template.theme);
65785
- setShowTemplates(false);
65786
- }, []);
65787
- const WidgetLibrary = t__default.useCallback(() => {
65788
- if (!showWidgetLibrary)
65789
- return null;
65790
- return /* @__PURE__ */ jsx(Sheet, { open: showWidgetLibrary, onOpenChange: setShowWidgetLibrary, children: /* @__PURE__ */ jsxs(SheetContent, { className: cn(
65791
- "w-[400px] sm:w-[540px]",
65792
- glassmorphism && "bg-background/95 backdrop-blur-md"
65793
- ), children: [
65794
- /* @__PURE__ */ jsxs(SheetHeader, { children: [
65795
- /* @__PURE__ */ jsx(SheetTitle, { children: "Widget Library" }),
65796
- /* @__PURE__ */ jsx(SheetDescription, { children: "Add widgets to customize your dashboard" })
65797
- ] }),
65798
- /* @__PURE__ */ jsxs("div", { className: "mt-6 space-y-4", children: [
65799
- /* @__PURE__ */ jsxs("div", { className: "relative", children: [
65800
- /* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-3 h-4 w-4 text-muted-foreground" }),
65801
- /* @__PURE__ */ jsx(
65802
- MoonUIInputPro,
65803
- {
65804
- placeholder: "Search widgets...",
65805
- value: searchQuery,
65806
- onChange: (e) => {
65807
- setSearchQuery(e.target.value);
65808
- onSearch?.(e.target.value);
65809
- },
65810
- className: "pl-10"
65811
- }
65812
- )
65813
- ] }),
65814
- /* @__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(
65815
- motion.div,
65816
- {
65817
- whileHover: { scale: 1.02 },
65818
- whileTap: { scale: 0.98 },
65819
- children: /* @__PURE__ */ jsxs(
65820
- MoonUIButtonPro,
65821
- {
65822
- variant: "outline",
65823
- className: "w-full h-24 flex-col gap-2",
65824
- onClick: () => handleAddWidget(type),
65825
- children: [
65826
- /* @__PURE__ */ jsx("div", { className: "p-2 rounded-lg bg-muted", children: icon }),
65827
- /* @__PURE__ */ jsx("span", { className: "capitalize text-sm", children: type })
65828
- ]
65829
- }
65830
- )
65831
- },
65832
- type
65833
- )) }) })
65834
- ] })
65835
- ] }) });
65836
- }, [showWidgetLibrary, searchQuery, glassmorphism, onSearch, handleAddWidget]);
65837
- const TemplateGallery = t__default.useCallback(() => {
65838
- if (!showTemplates)
65839
- return null;
65840
- return /* @__PURE__ */ jsx(MoonUIDialogPro, { open: showTemplates, onOpenChange: setShowTemplates, children: /* @__PURE__ */ jsxs(MoonUIDialogContentPro, { className: cn(
65841
- "max-w-4xl",
65842
- glassmorphism && "bg-background/95 backdrop-blur-md"
65843
- ), children: [
65844
- /* @__PURE__ */ jsxs(MoonUIDialogHeaderPro, { children: [
65845
- /* @__PURE__ */ jsx(MoonUIDialogTitlePro, { children: "Dashboard Templates" }),
65846
- /* @__PURE__ */ jsx(MoonUIDialogDescriptionPro, { children: "Start with a pre-built template or create your own" })
65847
- ] }),
65848
- /* @__PURE__ */ jsxs(Tabs, { defaultValue: "all", className: "mt-4", children: [
65849
- /* @__PURE__ */ jsxs(TabsList, { children: [
65850
- /* @__PURE__ */ jsx(TabsTrigger, { value: "all", children: "All Templates" }),
65851
- /* @__PURE__ */ jsx(TabsTrigger, { value: "analytics", children: "Analytics" }),
65852
- /* @__PURE__ */ jsx(TabsTrigger, { value: "sales", children: "Sales" }),
65853
- /* @__PURE__ */ jsx(TabsTrigger, { value: "operations", children: "Operations" })
65854
- ] }),
65855
- /* @__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(
65856
- motion.div,
65857
- {
65858
- whileHover: { y: -4 },
65859
- className: "cursor-pointer",
65860
- onClick: () => applyTemplate(template),
65861
- children: /* @__PURE__ */ jsxs("div", { className: cn(
65862
- "relative overflow-hidden rounded-lg border p-4 hover:shadow-lg transition-all",
65863
- "bg-gradient-to-br",
65864
- THEME_COLORS[template.theme]
65865
- ), children: [
65866
- template.isPro && /* @__PURE__ */ jsx(MoonUIBadgePro, { className: "absolute top-2 right-2", variant: "secondary", children: "PRO" }),
65867
- /* @__PURE__ */ jsx("h3", { className: "font-semibold mb-1", children: template.name }),
65868
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: template.description }),
65869
- /* @__PURE__ */ jsxs("div", { className: "mt-3 flex items-center gap-2 text-xs text-muted-foreground", children: [
65870
- /* @__PURE__ */ jsxs("span", { children: [
65871
- template.widgets.length,
65872
- " widgets"
65873
- ] }),
65874
- /* @__PURE__ */ jsx("span", { children: "\u2022" }),
65875
- /* @__PURE__ */ jsx("span", { className: "capitalize", children: template.category })
65876
- ] })
65877
- ] })
65878
- },
65879
- template.id
65880
- )) }) })
65881
- ] })
65882
- ] }) });
65883
- }, [showTemplates, glassmorphism, templates, applyTemplate]);
65884
- return /* @__PURE__ */ jsxs(
65885
- motion.div,
65886
- {
65887
- className: cn(
65888
- "w-full min-h-screen",
65889
- glassmorphism && "bg-gradient-to-br",
65890
- glassmorphism && THEME_COLORS[selectedTheme],
65891
- className
65892
- ),
65893
- initial: { opacity: 0 },
65894
- animate: { opacity: 1 },
65895
- transition: { duration: 0.5 },
65896
- children: [
65897
- showHeader && /* @__PURE__ */ jsxs(
65280
+ initial: { opacity: 0 },
65281
+ animate: { opacity: 1 },
65282
+ transition: { duration: 0.5 },
65283
+ children: [
65284
+ showHeader && /* @__PURE__ */ jsxs(
65898
65285
  motion.div,
65899
65286
  {
65900
65287
  className: cn(
@@ -66221,66 +65608,28 @@ function DashboardInternal({
66221
65608
  mode === "children" ? (
66222
65609
  // Children mode - use as layout wrapper
66223
65610
  /* @__PURE__ */ jsxs("div", { className: cn("flex flex-1", contentClassName), children: [
66224
- sidebarPosition === "left" && (sidebarSections || sidebarContent) && /* @__PURE__ */ jsx("div", { className: cn(
65611
+ sidebarPosition === "left" && sidebarContent && /* @__PURE__ */ jsx("div", { className: cn(
66225
65612
  "min-h-full",
66226
65613
  glassmorphism ? "bg-background/60 backdrop-blur-md" : "bg-background"
66227
- ), children: sidebarSections ? /* @__PURE__ */ jsx(
66228
- Sidebar,
66229
- {
66230
- sections: sidebarSections,
66231
- collapsible: sidebarCollapsible,
66232
- defaultCollapsed: sidebarDefaultCollapsed,
66233
- className: "h-full"
66234
- }
66235
- ) : (
66236
- /* Aksi halde custom sidebarContent'i render et */
66237
- sidebarContent
66238
- ) }),
65614
+ ), children: sidebarContent }),
66239
65615
  /* @__PURE__ */ jsx("div", { className: "flex-1 p-6", children }),
66240
- sidebarPosition === "right" && (sidebarSections || sidebarContent) && /* @__PURE__ */ jsx("div", { className: cn(
65616
+ sidebarPosition === "right" && sidebarContent && /* @__PURE__ */ jsx("div", { className: cn(
66241
65617
  "min-h-full",
66242
65618
  glassmorphism ? "bg-background/60 backdrop-blur-md" : "bg-background"
66243
- ), children: sidebarSections ? /* @__PURE__ */ jsx(
66244
- Sidebar,
66245
- {
66246
- sections: sidebarSections,
66247
- collapsible: sidebarCollapsible,
66248
- defaultCollapsed: sidebarDefaultCollapsed,
66249
- className: "h-full"
66250
- }
66251
- ) : (
66252
- /* Aksi halde custom sidebarContent'i render et */
66253
- sidebarContent
66254
- ) })
65619
+ ), children: sidebarContent })
66255
65620
  ] })
66256
65621
  ) : mode === "hybrid" ? (
66257
65622
  // Hybrid mode - both children and widgets
66258
65623
  /* @__PURE__ */ jsxs("div", { className: "flex flex-1", children: [
66259
- sidebarPosition === "left" && (sidebarSections || sidebarContent) && /* @__PURE__ */ jsx("div", { className: cn(
65624
+ sidebarPosition === "left" && sidebarContent && /* @__PURE__ */ jsx("div", { className: cn(
66260
65625
  "min-h-full",
66261
65626
  glassmorphism ? "bg-background/60 backdrop-blur-md" : "bg-background"
66262
- ), children: sidebarSections ? /* @__PURE__ */ jsx(
66263
- Sidebar,
66264
- {
66265
- sections: sidebarSections,
66266
- collapsible: sidebarCollapsible,
66267
- defaultCollapsed: sidebarDefaultCollapsed,
66268
- className: "h-full"
66269
- }
66270
- ) : sidebarContent }),
65627
+ ), children: sidebarContent }),
66271
65628
  /* @__PURE__ */ jsx("div", { className: "flex-1 p-6", children }),
66272
- sidebarPosition === "right" && (sidebarSections || sidebarContent) && /* @__PURE__ */ jsx("div", { className: cn(
65629
+ sidebarPosition === "right" && sidebarContent && /* @__PURE__ */ jsx("div", { className: cn(
66273
65630
  "min-h-full",
66274
65631
  glassmorphism ? "bg-background/60 backdrop-blur-md" : "bg-background"
66275
- ), children: sidebarSections ? /* @__PURE__ */ jsx(
66276
- Sidebar,
66277
- {
66278
- sections: sidebarSections,
66279
- collapsible: sidebarCollapsible,
66280
- defaultCollapsed: sidebarDefaultCollapsed,
66281
- className: "h-full"
66282
- }
66283
- ) : sidebarContent }),
65632
+ ), children: sidebarContent }),
66284
65633
  /* @__PURE__ */ jsx("div", { className: cn(
66285
65634
  "w-80 border-l p-6",
66286
65635
  glassmorphism ? "bg-background/60 backdrop-blur-md" : "bg-background"
@@ -72533,1062 +71882,1672 @@ function DataTableBulkActions({
72533
71882
  onClearSelection,
72534
71883
  className
72535
71884
  }) {
72536
- const [isLoading, setIsLoading] = t__default.useState(false);
72537
- const [pendingAction, setPendingAction] = t__default.useState(null);
72538
- const selectedCount = selectedRows.length;
72539
- const handleAction = async (action) => {
72540
- if (action.confirmMessage) {
72541
- setPendingAction(action);
71885
+ const [isLoading, setIsLoading] = t__default.useState(false);
71886
+ const [pendingAction, setPendingAction] = t__default.useState(null);
71887
+ const selectedCount = selectedRows.length;
71888
+ const handleAction = async (action) => {
71889
+ if (action.confirmMessage) {
71890
+ setPendingAction(action);
71891
+ return;
71892
+ }
71893
+ await executeAction(action);
71894
+ };
71895
+ const executeAction = async (action) => {
71896
+ setIsLoading(true);
71897
+ try {
71898
+ await action.action(selectedRows);
71899
+ if (onClearSelection) {
71900
+ onClearSelection();
71901
+ }
71902
+ } catch (error) {
71903
+ console.error("Bulk action failed:", error);
71904
+ } finally {
71905
+ setIsLoading(false);
71906
+ setPendingAction(null);
71907
+ }
71908
+ };
71909
+ const handleConfirm = async () => {
71910
+ if (pendingAction) {
71911
+ await executeAction(pendingAction);
71912
+ }
71913
+ };
71914
+ if (selectedCount === 0) {
71915
+ return null;
71916
+ }
71917
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
71918
+ /* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-2", className), children: [
71919
+ /* @__PURE__ */ jsxs(MoonUIBadgePro, { variant: "secondary", className: "gap-1", children: [
71920
+ /* @__PURE__ */ jsx("span", { className: "font-semibold", children: selectedCount }),
71921
+ /* @__PURE__ */ jsx("span", { children: "selected" })
71922
+ ] }),
71923
+ /* @__PURE__ */ jsxs(MoonUIDropdownMenuPro, { children: [
71924
+ /* @__PURE__ */ jsx(MoonUIDropdownMenuTriggerPro, { asChild: true, children: /* @__PURE__ */ jsx(
71925
+ MoonUIButtonPro,
71926
+ {
71927
+ variant: "outline",
71928
+ size: "sm",
71929
+ disabled: isLoading,
71930
+ className: "gap-2",
71931
+ children: isLoading ? /* @__PURE__ */ jsxs(Fragment, { children: [
71932
+ /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }),
71933
+ "Processing..."
71934
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
71935
+ /* @__PURE__ */ jsx(MoreHorizontal, { className: "h-4 w-4" }),
71936
+ "Bulk Actions"
71937
+ ] })
71938
+ }
71939
+ ) }),
71940
+ /* @__PURE__ */ jsxs(MoonUIDropdownMenuContentPro, { align: "end", className: "w-48", children: [
71941
+ actions.map((action, index2) => {
71942
+ const isDisabled = typeof action.disabled === "function" ? action.disabled(selectedRows) : action.disabled;
71943
+ return /* @__PURE__ */ jsxs(
71944
+ MoonUIDropdownMenuItemPro,
71945
+ {
71946
+ disabled: isDisabled || isLoading,
71947
+ onSelect: () => handleAction(action),
71948
+ className: cn(
71949
+ "cursor-pointer",
71950
+ action.variant === "destructive" && "text-destructive focus:text-destructive"
71951
+ ),
71952
+ children: [
71953
+ action.icon && /* @__PURE__ */ jsx("span", { className: "mr-2 h-4 w-4", children: action.icon }),
71954
+ action.label
71955
+ ]
71956
+ },
71957
+ index2
71958
+ );
71959
+ }),
71960
+ onClearSelection && /* @__PURE__ */ jsxs(Fragment, { children: [
71961
+ /* @__PURE__ */ jsx(MoonUIDropdownMenuSeparatorPro, {}),
71962
+ /* @__PURE__ */ jsx(
71963
+ MoonUIDropdownMenuItemPro,
71964
+ {
71965
+ onSelect: onClearSelection,
71966
+ className: "cursor-pointer text-muted-foreground",
71967
+ children: "Clear selection"
71968
+ }
71969
+ )
71970
+ ] })
71971
+ ] })
71972
+ ] })
71973
+ ] }),
71974
+ /* @__PURE__ */ jsx(
71975
+ AlertDialog2,
71976
+ {
71977
+ open: !!pendingAction,
71978
+ onOpenChange: (open) => !open && setPendingAction(null),
71979
+ children: /* @__PURE__ */ jsxs(AlertDialogContent2, { children: [
71980
+ /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
71981
+ /* @__PURE__ */ jsxs(AlertDialogTitle2, { className: "flex items-center gap-2", children: [
71982
+ pendingAction?.variant === "destructive" && /* @__PURE__ */ jsx(AlertTriangle, { className: "h-5 w-5 text-destructive" }),
71983
+ pendingAction?.confirmTitle || "Confirm Action"
71984
+ ] }),
71985
+ /* @__PURE__ */ jsx(AlertDialogDescription2, { children: pendingAction?.confirmMessage || `This action will affect ${selectedCount} selected item${selectedCount > 1 ? "s" : ""}. This action cannot be undone.` })
71986
+ ] }),
71987
+ /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
71988
+ /* @__PURE__ */ jsx(AlertDialogCancel2, { disabled: isLoading, children: "Cancel" }),
71989
+ /* @__PURE__ */ jsx(
71990
+ AlertDialogAction2,
71991
+ {
71992
+ onClick: handleConfirm,
71993
+ disabled: isLoading,
71994
+ className: cn(
71995
+ pendingAction?.variant === "destructive" && "bg-destructive text-destructive-foreground hover:bg-destructive/90"
71996
+ ),
71997
+ children: isLoading ? /* @__PURE__ */ jsxs(Fragment, { children: [
71998
+ /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
71999
+ "Processing..."
72000
+ ] }) : "Confirm"
72001
+ }
72002
+ )
72003
+ ] })
72004
+ ] })
72005
+ }
72006
+ )
72007
+ ] });
72008
+ }
72009
+
72010
+ // src/components/data-table/data-table-export.ts
72011
+ function dataToCSV(data, columns, includeHeaders = true) {
72012
+ if (data.length === 0)
72013
+ return "";
72014
+ const cols = columns || Object.keys(data[0]);
72015
+ const rows = [];
72016
+ if (includeHeaders) {
72017
+ const headers = cols.map((col) => {
72018
+ const value = String(col);
72019
+ return value.includes(",") || value.includes('"') || value.includes("\n") ? `"${value.replace(/"/g, '""')}"` : value;
72020
+ });
72021
+ rows.push(headers.join(","));
72022
+ }
72023
+ data.forEach((item) => {
72024
+ const row = cols.map((col) => {
72025
+ const value = item[col];
72026
+ if (value === null || value === void 0)
72027
+ return "";
72028
+ if (value instanceof Date)
72029
+ return value.toISOString();
72030
+ if (typeof value === "object")
72031
+ return JSON.stringify(value);
72032
+ const stringValue = String(value);
72033
+ return stringValue.includes(",") || stringValue.includes('"') || stringValue.includes("\n") ? `"${stringValue.replace(/"/g, '""')}"` : stringValue;
72034
+ });
72035
+ rows.push(row.join(","));
72036
+ });
72037
+ return rows.join("\n");
72038
+ }
72039
+ function dataToJSON(data, columns) {
72040
+ if (!columns || columns.length === 0) {
72041
+ return JSON.stringify(data, null, 2);
72042
+ }
72043
+ const filteredData = data.map((item) => {
72044
+ const filtered = {};
72045
+ columns.forEach((col) => {
72046
+ if (col in item) {
72047
+ filtered[col] = item[col];
72048
+ }
72049
+ });
72050
+ return filtered;
72051
+ });
72052
+ return JSON.stringify(filteredData, null, 2);
72053
+ }
72054
+ function downloadFile(content, filename, mimeType) {
72055
+ const blob = new Blob([content], { type: mimeType });
72056
+ const url = URL.createObjectURL(blob);
72057
+ const link = document.createElement("a");
72058
+ link.href = url;
72059
+ link.download = filename;
72060
+ document.body.appendChild(link);
72061
+ link.click();
72062
+ document.body.removeChild(link);
72063
+ URL.revokeObjectURL(url);
72064
+ }
72065
+ async function exportData2(data, options) {
72066
+ const { format: format8, filename = "data-export", columns, includeHeaders = true } = options;
72067
+ let content;
72068
+ let mimeType;
72069
+ let extension;
72070
+ switch (format8) {
72071
+ case "csv":
72072
+ content = dataToCSV(data, columns, includeHeaders);
72073
+ mimeType = "text/csv;charset=utf-8;";
72074
+ extension = "csv";
72075
+ break;
72076
+ case "json":
72077
+ content = dataToJSON(data, columns);
72078
+ mimeType = "application/json;charset=utf-8;";
72079
+ extension = "json";
72080
+ break;
72081
+ case "xlsx":
72082
+ throw new Error("XLSX export requires additional dependencies. Use CSV format instead.");
72083
+ default:
72084
+ throw new Error(`Unsupported export format: ${format8}`);
72085
+ }
72086
+ const finalFilename = `${filename}-${( new Date()).toISOString().split("T")[0]}.${extension}`;
72087
+ downloadFile(content, finalFilename, mimeType);
72088
+ }
72089
+ function getVisibleColumns(columns, columnVisibility) {
72090
+ return columns.filter((col) => {
72091
+ const key = col.id || col.accessorKey;
72092
+ return key && columnVisibility[key] !== false;
72093
+ }).map((col) => col.id || col.accessorKey).filter(Boolean);
72094
+ }
72095
+ var operatorLabels = {
72096
+ equals: "Equals",
72097
+ notEquals: "Not equals",
72098
+ contains: "Contains",
72099
+ notContains: "Not contains",
72100
+ startsWith: "Starts with",
72101
+ endsWith: "Ends with",
72102
+ greaterThan: "Greater than",
72103
+ lessThan: "Less than",
72104
+ greaterThanOrEqual: "Greater than or equal",
72105
+ lessThanOrEqual: "Less than or equal",
72106
+ between: "Between",
72107
+ in: "In",
72108
+ notIn: "Not in",
72109
+ isNull: "Is empty",
72110
+ isNotNull: "Is not empty"
72111
+ };
72112
+ function getOperatorsForColumnType(columnType) {
72113
+ switch (columnType) {
72114
+ case "number":
72115
+ return ["equals", "notEquals", "greaterThan", "lessThan", "greaterThanOrEqual", "lessThanOrEqual", "between", "isNull", "isNotNull"];
72116
+ case "date":
72117
+ return ["equals", "notEquals", "greaterThan", "lessThan", "greaterThanOrEqual", "lessThanOrEqual", "between", "isNull", "isNotNull"];
72118
+ case "boolean":
72119
+ return ["equals", "notEquals", "isNull", "isNotNull"];
72120
+ case "select":
72121
+ return ["equals", "notEquals", "in", "notIn", "isNull", "isNotNull"];
72122
+ default:
72123
+ return ["equals", "notEquals", "contains", "notContains", "startsWith", "endsWith", "isNull", "isNotNull"];
72124
+ }
72125
+ }
72126
+ function DataTableFilterDrawer({
72127
+ table,
72128
+ open,
72129
+ onOpenChange,
72130
+ position = "right",
72131
+ width = "400px",
72132
+ filters: externalFilters,
72133
+ onFiltersChange,
72134
+ customFilters,
72135
+ matchAll: externalMatchAll,
72136
+ onMatchAllChange
72137
+ }) {
72138
+ const [internalFilters, setInternalFilters] = useState([]);
72139
+ const [internalMatchAll, setInternalMatchAll] = useState(true);
72140
+ const filters = externalFilters || internalFilters;
72141
+ const setFilters = onFiltersChange || setInternalFilters;
72142
+ const matchAll = externalMatchAll !== void 0 ? externalMatchAll : internalMatchAll;
72143
+ const setMatchAll = onMatchAllChange || setInternalMatchAll;
72144
+ const filterableColumns = useMemo(() => {
72145
+ return table.getAllColumns().filter((column) => {
72146
+ if (column.id === "select" || column.id === "actions" || column.id === "expander") {
72147
+ return false;
72148
+ }
72149
+ return column.getCanFilter();
72150
+ });
72151
+ }, [table]);
72152
+ const addFilter = () => {
72153
+ const firstColumn = filterableColumns[0];
72154
+ if (!firstColumn)
72155
+ return;
72156
+ const newFilter = {
72157
+ column: firstColumn.id,
72158
+ operator: "contains",
72159
+ value: ""
72160
+ };
72161
+ setFilters([...filters, newFilter]);
72162
+ };
72163
+ const updateFilter = (index2, updates) => {
72164
+ const newFilters = [...filters];
72165
+ newFilters[index2] = { ...newFilters[index2], ...updates };
72166
+ setFilters(newFilters);
72167
+ };
72168
+ const removeFilter = (index2) => {
72169
+ setFilters(filters.filter((_, i) => i !== index2));
72170
+ };
72171
+ const clearAllFilters = () => {
72172
+ setFilters([]);
72173
+ table.resetColumnFilters();
72174
+ };
72175
+ const applyFilters = () => {
72176
+ table.resetColumnFilters();
72177
+ const columnsWithFilters = [...new Set(filters.map((f) => f.column))];
72178
+ columnsWithFilters.forEach((columnId) => {
72179
+ const column = table.getColumn(columnId);
72180
+ if (!column)
72181
+ return;
72182
+ column.setFilterValue({ custom: true, filters, matchAll });
72183
+ });
72184
+ if (filters.length === 0) {
72185
+ table.resetColumnFilters();
72186
+ }
72187
+ onOpenChange(false);
72188
+ };
72189
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
72190
+ /* @__PURE__ */ jsx(AnimatePresence, { children: open && /* @__PURE__ */ jsx(
72191
+ motion.div,
72192
+ {
72193
+ initial: { opacity: 0 },
72194
+ animate: { opacity: 1 },
72195
+ exit: { opacity: 0 },
72196
+ className: "fixed inset-0 bg-black/20 z-40",
72197
+ onClick: () => onOpenChange(false)
72198
+ }
72199
+ ) }),
72200
+ /* @__PURE__ */ jsx(AnimatePresence, { children: open && /* @__PURE__ */ jsx(
72201
+ motion.div,
72202
+ {
72203
+ initial: { x: position === "right" ? "100%" : "-100%" },
72204
+ animate: { x: 0 },
72205
+ exit: { x: position === "right" ? "100%" : "-100%" },
72206
+ transition: { type: "spring", damping: 30, stiffness: 300 },
72207
+ className: cn(
72208
+ "fixed top-0 bottom-0 z-50 bg-background border-l shadow-xl",
72209
+ position === "right" ? "right-0" : "left-0"
72210
+ ),
72211
+ style: { width },
72212
+ children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
72213
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between p-4 border-b", children: [
72214
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
72215
+ /* @__PURE__ */ jsx(Filter, { className: "h-5 w-5" }),
72216
+ /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold", children: "Filters" }),
72217
+ filters.length > 0 && /* @__PURE__ */ jsxs("span", { className: "text-sm text-muted-foreground", children: [
72218
+ "(",
72219
+ filters.length,
72220
+ " active)"
72221
+ ] })
72222
+ ] }),
72223
+ /* @__PURE__ */ jsx(
72224
+ MoonUIButtonPro,
72225
+ {
72226
+ variant: "ghost",
72227
+ size: "icon",
72228
+ onClick: () => onOpenChange(false),
72229
+ children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
72230
+ }
72231
+ )
72232
+ ] }),
72233
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 overflow-y-auto p-4", children: [
72234
+ /* @__PURE__ */ jsxs("div", { className: "mb-6", children: [
72235
+ /* @__PURE__ */ jsx(MoonUILabelPro, { className: "text-sm font-medium mb-2 block", children: "Match conditions" }),
72236
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
72237
+ /* @__PURE__ */ jsx(
72238
+ MoonUIButtonPro,
72239
+ {
72240
+ variant: matchAll ? "primary" : "outline",
72241
+ size: "sm",
72242
+ onClick: () => setMatchAll(true),
72243
+ className: "flex-1",
72244
+ children: "Match all"
72245
+ }
72246
+ ),
72247
+ /* @__PURE__ */ jsx(
72248
+ MoonUIButtonPro,
72249
+ {
72250
+ variant: !matchAll ? "primary" : "outline",
72251
+ size: "sm",
72252
+ onClick: () => setMatchAll(false),
72253
+ className: "flex-1",
72254
+ children: "Match any"
72255
+ }
72256
+ )
72257
+ ] })
72258
+ ] }),
72259
+ /* @__PURE__ */ jsx(MoonUISeparatorPro, { className: "mb-6" }),
72260
+ customFilters && /* @__PURE__ */ jsxs(Fragment, { children: [
72261
+ customFilters,
72262
+ /* @__PURE__ */ jsx(MoonUISeparatorPro, { className: "my-6" })
72263
+ ] }),
72264
+ /* @__PURE__ */ jsx("div", { className: "space-y-4", children: filters.map((filter, index2) => /* @__PURE__ */ jsx(
72265
+ FilterConditionRow,
72266
+ {
72267
+ filter,
72268
+ columns: filterableColumns,
72269
+ onUpdate: (updates) => updateFilter(index2, updates),
72270
+ onRemove: () => removeFilter(index2)
72271
+ },
72272
+ index2
72273
+ )) }),
72274
+ /* @__PURE__ */ jsxs(
72275
+ MoonUIButtonPro,
72276
+ {
72277
+ variant: "outline",
72278
+ size: "sm",
72279
+ onClick: addFilter,
72280
+ className: "w-full mt-4",
72281
+ children: [
72282
+ /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4 mr-2" }),
72283
+ "Add filter"
72284
+ ]
72285
+ }
72286
+ )
72287
+ ] }),
72288
+ /* @__PURE__ */ jsx("div", { className: "p-4 border-t space-y-2", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
72289
+ /* @__PURE__ */ jsxs(
72290
+ MoonUIButtonPro,
72291
+ {
72292
+ variant: "outline",
72293
+ onClick: clearAllFilters,
72294
+ disabled: filters.length === 0,
72295
+ className: "flex-1",
72296
+ children: [
72297
+ /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4 mr-2" }),
72298
+ "Clear all"
72299
+ ]
72300
+ }
72301
+ ),
72302
+ /* @__PURE__ */ jsx(MoonUIButtonPro, { onClick: applyFilters, className: "flex-1", children: "Apply filters" })
72303
+ ] }) })
72304
+ ] })
72305
+ }
72306
+ ) })
72307
+ ] });
72308
+ }
72309
+ function FilterConditionRow({
72310
+ filter,
72311
+ columns,
72312
+ onUpdate,
72313
+ onRemove
72314
+ }) {
72315
+ const selectedColumn = columns.find((col) => col.id === filter.column);
72316
+ const columnDef = selectedColumn?.columnDef;
72317
+ const columnType = columnDef?.meta?.filterType || "string";
72318
+ const availableOperators = getOperatorsForColumnType(columnType);
72319
+ const needsValue = filter.operator !== "isNull" && filter.operator !== "isNotNull";
72320
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-2 p-3 border rounded-lg bg-muted/30", children: [
72321
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
72322
+ /* @__PURE__ */ jsxs(
72323
+ MoonUISelectPro,
72324
+ {
72325
+ value: filter.column,
72326
+ onValueChange: (value) => onUpdate({ column: value }),
72327
+ children: [
72328
+ /* @__PURE__ */ jsx(MoonUISelectTriggerPro, { className: "flex-1", children: /* @__PURE__ */ jsx(MoonUISelectValuePro, {}) }),
72329
+ /* @__PURE__ */ jsx(MoonUISelectContentPro, { children: columns.map((column) => {
72330
+ const header = column.columnDef.header;
72331
+ const label = typeof header === "function" ? column.id : header || column.id;
72332
+ return /* @__PURE__ */ jsx(MoonUISelectItemPro, { value: column.id, children: label }, column.id);
72333
+ }) })
72334
+ ]
72335
+ }
72336
+ ),
72337
+ /* @__PURE__ */ jsx(
72338
+ MoonUIButtonPro,
72339
+ {
72340
+ variant: "ghost",
72341
+ size: "icon",
72342
+ onClick: onRemove,
72343
+ className: "h-8 w-8",
72344
+ children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
72345
+ }
72346
+ )
72347
+ ] }),
72348
+ /* @__PURE__ */ jsxs(
72349
+ MoonUISelectPro,
72350
+ {
72351
+ value: filter.operator,
72352
+ onValueChange: (value) => onUpdate({ operator: value }),
72353
+ children: [
72354
+ /* @__PURE__ */ jsx(MoonUISelectTriggerPro, { children: /* @__PURE__ */ jsx(MoonUISelectValuePro, {}) }),
72355
+ /* @__PURE__ */ jsx(MoonUISelectContentPro, { children: availableOperators.map((operator2) => /* @__PURE__ */ jsx(MoonUISelectItemPro, { value: operator2, children: operatorLabels[operator2] }, operator2)) })
72356
+ ]
72357
+ }
72358
+ ),
72359
+ needsValue && /* @__PURE__ */ jsx("div", { children: columnType === "boolean" ? /* @__PURE__ */ jsxs(
72360
+ MoonUISelectPro,
72361
+ {
72362
+ value: String(filter.value),
72363
+ onValueChange: (value) => onUpdate({ value: value === "true" }),
72364
+ children: [
72365
+ /* @__PURE__ */ jsx(MoonUISelectTriggerPro, { children: /* @__PURE__ */ jsx(MoonUISelectValuePro, {}) }),
72366
+ /* @__PURE__ */ jsxs(MoonUISelectContentPro, { children: [
72367
+ /* @__PURE__ */ jsx(MoonUISelectItemPro, { value: "true", children: "True" }),
72368
+ /* @__PURE__ */ jsx(MoonUISelectItemPro, { value: "false", children: "False" })
72369
+ ] })
72370
+ ]
72371
+ }
72372
+ ) : columnType === "number" ? /* @__PURE__ */ jsx(
72373
+ MoonUIInputPro,
72374
+ {
72375
+ type: "number",
72376
+ value: filter.value || "",
72377
+ onChange: (e) => onUpdate({ value: e.target.value }),
72378
+ placeholder: "Enter value..."
72379
+ }
72380
+ ) : /* @__PURE__ */ jsx(
72381
+ MoonUIInputPro,
72382
+ {
72383
+ value: filter.value || "",
72384
+ onChange: (e) => onUpdate({ value: e.target.value }),
72385
+ placeholder: "Enter value..."
72386
+ }
72387
+ ) })
72388
+ ] });
72389
+ }
72390
+ function DataTable({
72391
+ columns: originalColumns,
72392
+ data,
72393
+ searchable = true,
72394
+ filterable = true,
72395
+ exportable = true,
72396
+ selectable = false,
72397
+ pagination = true,
72398
+ pageSize = 10,
72399
+ className,
72400
+ onRowSelect,
72401
+ onExport,
72402
+ enableExpandable = false,
72403
+ renderSubComponent,
72404
+ expandedRows: controlledExpandedRows,
72405
+ onRowExpandChange,
72406
+ bulkActions = [],
72407
+ features = {},
72408
+ theme = {},
72409
+ texts = {},
72410
+ // Additional props
72411
+ enableSorting = true,
72412
+ enableFiltering = true,
72413
+ enablePagination = true,
72414
+ enableColumnVisibility = true,
72415
+ enableRowSelection,
72416
+ filterPlaceholder = "Search all columns...",
72417
+ defaultPageSize,
72418
+ manualPagination = false,
72419
+ pageCount,
72420
+ onPaginationChange,
72421
+ onSortingChange,
72422
+ onColumnFiltersChange,
72423
+ state: externalState
72424
+ }) {
72425
+ const columns = t__default.useMemo(() => {
72426
+ return originalColumns.map((col) => {
72427
+ const { enableHiding, ...restCol } = col;
72428
+ return {
72429
+ ...restCol,
72430
+ enableHiding: true,
72431
+ // Force all columns to be hideable
72432
+ filterFn: "custom"
72433
+ // Use our custom filter function
72434
+ };
72435
+ });
72436
+ }, [originalColumns]);
72437
+ const { hasProAccess, isLoading } = useSubscription();
72438
+ if (!isLoading && !hasProAccess) {
72439
+ return /* @__PURE__ */ jsx(MoonUICardPro, { className: cn("w-full", className), children: /* @__PURE__ */ jsx(MoonUICardContentPro, { className: "py-12 text-center", children: /* @__PURE__ */ jsxs("div", { className: "max-w-md mx-auto space-y-4", children: [
72440
+ /* @__PURE__ */ jsx("div", { className: "rounded-full bg-purple-100 dark:bg-purple-900/30 p-3 w-fit mx-auto", children: /* @__PURE__ */ jsx(Lock, { className: "h-6 w-6 text-purple-600 dark:text-purple-400" }) }),
72441
+ /* @__PURE__ */ jsxs("div", { children: [
72442
+ /* @__PURE__ */ jsx("h3", { className: "font-semibold text-lg mb-2", children: "Pro Feature" }),
72443
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm mb-4", children: "Data Table is available exclusively to MoonUI Pro subscribers." }),
72444
+ /* @__PURE__ */ jsx("div", { className: "flex gap-3 justify-center", children: /* @__PURE__ */ jsx("a", { href: "/pricing", children: /* @__PURE__ */ jsxs(MoonUIButtonPro, { size: "sm", children: [
72445
+ /* @__PURE__ */ jsx(Sparkles, { className: "mr-2 h-4 w-4" }),
72446
+ "Upgrade to Pro"
72447
+ ] }) }) })
72448
+ ] })
72449
+ ] }) }) });
72450
+ }
72451
+ const [sorting, setSorting] = t__default.useState([]);
72452
+ const [columnFilters, setColumnFilters] = t__default.useState([]);
72453
+ const [columnVisibility, setColumnVisibility] = t__default.useState({});
72454
+ const [rowSelection, setRowSelection] = t__default.useState({});
72455
+ const [globalFilter, setGlobalFilter] = t__default.useState("");
72456
+ const [isPaginationLoading, setIsPaginationLoading] = t__default.useState(false);
72457
+ const [internalExpandedRows, setInternalExpandedRows] = t__default.useState(/* @__PURE__ */ new Set());
72458
+ const [filterDrawerOpen, setFilterDrawerOpen] = t__default.useState(false);
72459
+ const expandedRows = controlledExpandedRows || internalExpandedRows;
72460
+ const actualPageSize = defaultPageSize || pageSize;
72461
+ const stableData = t__default.useMemo(() => data, [data]);
72462
+ const table = useReactTable({
72463
+ data: stableData,
72464
+ columns,
72465
+ onSortingChange: onSortingChange !== void 0 ? onSortingChange : setSorting,
72466
+ onColumnFiltersChange: onColumnFiltersChange !== void 0 ? onColumnFiltersChange : setColumnFilters,
72467
+ getCoreRowModel: getCoreRowModel(),
72468
+ getPaginationRowModel: getPaginationRowModel(),
72469
+ getSortedRowModel: getSortedRowModel(),
72470
+ getFilteredRowModel: getFilteredRowModel(),
72471
+ onColumnVisibilityChange: setColumnVisibility,
72472
+ onRowSelectionChange: setRowSelection,
72473
+ onGlobalFilterChange: setGlobalFilter,
72474
+ globalFilterFn: "includesString",
72475
+ filterFns: {
72476
+ custom: (row, columnId, filterValue) => {
72477
+ if (!filterValue?.custom || !filterValue?.filters)
72478
+ return true;
72479
+ const filters = filterValue.filters;
72480
+ const matchAll = filterValue.matchAll !== void 0 ? filterValue.matchAll : true;
72481
+ const allFilterResults = filters.map((filterCondition) => {
72482
+ const cellValue = row.getValue(filterCondition.column);
72483
+ const filterVal = filterCondition.value;
72484
+ switch (filterCondition.operator) {
72485
+ case "equals":
72486
+ return cellValue === filterVal;
72487
+ case "notEquals":
72488
+ return cellValue !== filterVal;
72489
+ case "contains":
72490
+ return String(cellValue).toLowerCase().includes(String(filterVal).toLowerCase());
72491
+ case "notContains":
72492
+ return !String(cellValue).toLowerCase().includes(String(filterVal).toLowerCase());
72493
+ case "startsWith":
72494
+ return String(cellValue).toLowerCase().startsWith(String(filterVal).toLowerCase());
72495
+ case "endsWith":
72496
+ return String(cellValue).toLowerCase().endsWith(String(filterVal).toLowerCase());
72497
+ case "greaterThan":
72498
+ return Number(cellValue) > Number(filterVal);
72499
+ case "lessThan":
72500
+ return Number(cellValue) < Number(filterVal);
72501
+ case "greaterThanOrEqual":
72502
+ return Number(cellValue) >= Number(filterVal);
72503
+ case "lessThanOrEqual":
72504
+ return Number(cellValue) <= Number(filterVal);
72505
+ case "isNull":
72506
+ return cellValue == null || cellValue === "";
72507
+ case "isNotNull":
72508
+ return cellValue != null && cellValue !== "";
72509
+ default:
72510
+ return true;
72511
+ }
72512
+ });
72513
+ if (matchAll) {
72514
+ return allFilterResults.every((result) => result);
72515
+ } else {
72516
+ return allFilterResults.some((result) => result);
72517
+ }
72518
+ }
72519
+ },
72520
+ manualPagination,
72521
+ pageCount,
72522
+ state: {
72523
+ sorting: externalState?.sorting ?? sorting,
72524
+ columnFilters: externalState?.columnFilters ?? columnFilters,
72525
+ columnVisibility: externalState?.columnVisibility ?? columnVisibility,
72526
+ rowSelection: externalState?.rowSelection ?? rowSelection,
72527
+ globalFilter: externalState?.globalFilter ?? globalFilter,
72528
+ ...externalState || {}
72529
+ },
72530
+ initialState: {
72531
+ pagination: {
72532
+ pageSize: actualPageSize
72533
+ }
72534
+ },
72535
+ // Prevent re-renders on state changes
72536
+ autoResetAll: false,
72537
+ autoResetPageIndex: false,
72538
+ autoResetExpanded: false,
72539
+ getRowId: (row) => row.id || row.orderId || Math.random().toString()
72540
+ });
72541
+ t__default.useEffect(() => {
72542
+ if (onRowSelect && selectable) {
72543
+ const selectedRows = table.getFilteredSelectedRowModel().rows.map((row) => row.original);
72544
+ onRowSelect(selectedRows);
72545
+ }
72546
+ }, [rowSelection, onRowSelect, selectable, table]);
72547
+ table.getState();
72548
+ const rowModel = table.getRowModel();
72549
+ const rowsRef = t__default.useRef(rowModel.rows);
72550
+ t__default.useMemo(() => {
72551
+ const changed = rowsRef.current !== rowModel.rows;
72552
+ if (changed) {
72553
+ rowsRef.current = rowModel.rows;
72554
+ }
72555
+ return changed;
72556
+ }, [rowModel.rows]);
72557
+ const rows = rowsRef.current;
72558
+ ({
72559
+ sorting: features.sorting !== false,
72560
+ filtering: features.filtering !== false || filterable,
72561
+ pagination: features.pagination !== false || pagination,
72562
+ search: features.search !== false || searchable,
72563
+ columnVisibility: features.columnVisibility !== false,
72564
+ rowSelection: features.rowSelection !== false || selectable,
72565
+ export: features.export !== false || exportable
72566
+ });
72567
+ const handleExport = async (format8) => {
72568
+ const selectedRows = table.getFilteredSelectedRowModel().rows;
72569
+ const dataToExport = selectedRows.length > 0 ? selectedRows.map((row) => row.original) : table.getFilteredRowModel().rows.map((row) => row.original);
72570
+ if (typeof exportable === "object" && exportable.onExport) {
72571
+ exportable.onExport(dataToExport, format8);
72542
72572
  return;
72543
72573
  }
72544
- await executeAction(action);
72545
- };
72546
- const executeAction = async (action) => {
72547
- setIsLoading(true);
72548
- try {
72549
- await action.action(selectedRows);
72550
- if (onClearSelection) {
72551
- onClearSelection();
72552
- }
72553
- } catch (error) {
72554
- console.error("Bulk action failed:", error);
72555
- } finally {
72556
- setIsLoading(false);
72557
- setPendingAction(null);
72574
+ if (onExport) {
72575
+ onExport(dataToExport);
72576
+ return;
72558
72577
  }
72578
+ const filename = typeof exportable === "object" && exportable.filename ? exportable.filename : "data-export";
72579
+ const visibleColumns = getVisibleColumns(columns, columnVisibility);
72580
+ await exportData2(dataToExport, {
72581
+ format: format8,
72582
+ filename,
72583
+ columns: visibleColumns,
72584
+ includeHeaders: true
72585
+ });
72559
72586
  };
72560
- const handleConfirm = async () => {
72561
- if (pendingAction) {
72562
- await executeAction(pendingAction);
72587
+ const exportFormats = t__default.useMemo(() => {
72588
+ if (!exportable)
72589
+ return [];
72590
+ if (exportable === true)
72591
+ return ["csv", "json"];
72592
+ if (typeof exportable === "object" && exportable.formats) {
72593
+ return exportable.formats;
72563
72594
  }
72595
+ return ["csv", "json"];
72596
+ }, [exportable]);
72597
+ const clearRowSelection = () => {
72598
+ table.resetRowSelection();
72564
72599
  };
72565
- if (selectedCount === 0) {
72566
- return null;
72567
- }
72568
- return /* @__PURE__ */ jsxs(Fragment, { children: [
72569
- /* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-2", className), children: [
72570
- /* @__PURE__ */ jsxs(MoonUIBadgePro, { variant: "secondary", className: "gap-1", children: [
72571
- /* @__PURE__ */ jsx("span", { className: "font-semibold", children: selectedCount }),
72572
- /* @__PURE__ */ jsx("span", { children: "selected" })
72573
- ] }),
72574
- /* @__PURE__ */ jsxs(MoonUIDropdownMenuPro, { children: [
72575
- /* @__PURE__ */ jsx(MoonUIDropdownMenuTriggerPro, { asChild: true, children: /* @__PURE__ */ jsx(
72600
+ return /* @__PURE__ */ jsxs("div", { className: cn("moonui-pro-datatable-container flex flex-col gap-4", className), children: [
72601
+ /* @__PURE__ */ jsxs("div", { className: "moonui-pro-datatable-toolbar flex items-center justify-between", children: [
72602
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
72603
+ searchable && /* @__PURE__ */ jsxs("div", { className: "relative", children: [
72604
+ /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }) }),
72605
+ /* @__PURE__ */ jsx(
72606
+ MoonUIInputPro,
72607
+ {
72608
+ placeholder: filterPlaceholder,
72609
+ value: globalFilter,
72610
+ onChange: (e) => setGlobalFilter(e.target.value),
72611
+ className: "pl-8 w-64"
72612
+ }
72613
+ )
72614
+ ] }),
72615
+ filterable && /* @__PURE__ */ jsxs(
72576
72616
  MoonUIButtonPro,
72577
72617
  {
72578
72618
  variant: "outline",
72579
72619
  size: "sm",
72580
- disabled: isLoading,
72581
- className: "gap-2",
72582
- children: isLoading ? /* @__PURE__ */ jsxs(Fragment, { children: [
72583
- /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }),
72584
- "Processing..."
72585
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
72586
- /* @__PURE__ */ jsx(MoreHorizontal, { className: "h-4 w-4" }),
72587
- "Bulk Actions"
72588
- ] })
72620
+ onClick: () => setFilterDrawerOpen(true),
72621
+ children: [
72622
+ /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Filter, { className: "mr-2 h-4 w-4" }) }),
72623
+ "Filters",
72624
+ columnFilters.length > 0 && /* @__PURE__ */ jsx("span", { className: "ml-2 rounded-full bg-primary px-2 py-0.5 text-xs text-primary-foreground", children: columnFilters.length })
72625
+ ]
72589
72626
  }
72590
- ) }),
72591
- /* @__PURE__ */ jsxs(MoonUIDropdownMenuContentPro, { align: "end", className: "w-48", children: [
72592
- actions.map((action, index2) => {
72593
- const isDisabled = typeof action.disabled === "function" ? action.disabled(selectedRows) : action.disabled;
72594
- return /* @__PURE__ */ jsxs(
72595
- MoonUIDropdownMenuItemPro,
72596
- {
72597
- disabled: isDisabled || isLoading,
72598
- onSelect: () => handleAction(action),
72599
- className: cn(
72600
- "cursor-pointer",
72601
- action.variant === "destructive" && "text-destructive focus:text-destructive"
72602
- ),
72603
- children: [
72604
- action.icon && /* @__PURE__ */ jsx("span", { className: "mr-2 h-4 w-4", children: action.icon }),
72605
- action.label
72606
- ]
72607
- },
72608
- index2
72609
- );
72610
- }),
72611
- onClearSelection && /* @__PURE__ */ jsxs(Fragment, { children: [
72612
- /* @__PURE__ */ jsx(MoonUIDropdownMenuSeparatorPro, {}),
72613
- /* @__PURE__ */ jsx(
72614
- MoonUIDropdownMenuItemPro,
72615
- {
72616
- onSelect: onClearSelection,
72617
- className: "cursor-pointer text-muted-foreground",
72618
- children: "Clear selection"
72619
- }
72620
- )
72627
+ ),
72628
+ selectable && bulkActions.length > 0 && /* @__PURE__ */ jsx(
72629
+ DataTableBulkActions,
72630
+ {
72631
+ selectedRows: table.getFilteredSelectedRowModel().rows.map((row) => row.original),
72632
+ actions: bulkActions,
72633
+ onClearSelection: clearRowSelection
72634
+ }
72635
+ )
72636
+ ] }),
72637
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
72638
+ exportable && exportFormats.length > 0 && /* @__PURE__ */ jsxs(MoonUIDropdownMenuPro, { children: [
72639
+ /* @__PURE__ */ jsx(MoonUIDropdownMenuTriggerPro, { asChild: true, children: /* @__PURE__ */ jsxs(MoonUIButtonPro, { variant: "outline", size: "sm", children: [
72640
+ /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Download, { className: "mr-2 h-4 w-4" }) }),
72641
+ "Export"
72642
+ ] }) }),
72643
+ /* @__PURE__ */ jsxs(MoonUIDropdownMenuContentPro, { align: "end", children: [
72644
+ exportFormats.includes("csv") && /* @__PURE__ */ jsxs(MoonUIDropdownMenuItemPro, { onClick: () => handleExport("csv"), children: [
72645
+ /* @__PURE__ */ jsx(FileSpreadsheet, { className: "mr-2 h-4 w-4" }),
72646
+ "Export as CSV"
72647
+ ] }),
72648
+ exportFormats.includes("json") && /* @__PURE__ */ jsxs(MoonUIDropdownMenuItemPro, { onClick: () => handleExport("json"), children: [
72649
+ /* @__PURE__ */ jsx(FileJson, { className: "mr-2 h-4 w-4" }),
72650
+ "Export as JSON"
72651
+ ] }),
72652
+ exportFormats.includes("xlsx") && /* @__PURE__ */ jsxs(MoonUIDropdownMenuItemPro, { onClick: () => handleExport("xlsx"), children: [
72653
+ /* @__PURE__ */ jsx(FileDown, { className: "mr-2 h-4 w-4" }),
72654
+ "Export as Excel"
72655
+ ] })
72621
72656
  ] })
72657
+ ] }),
72658
+ /* @__PURE__ */ jsx(DataTableColumnToggle, { table })
72659
+ ] })
72660
+ ] }),
72661
+ /* @__PURE__ */ jsx("div", { className: "moonui-pro-datatable-wrapper rounded-md border overflow-hidden", style: { contain: "layout style" }, children: /* @__PURE__ */ jsx("div", { style: { overflowX: "auto" }, children: /* @__PURE__ */ jsxs("table", { className: "moonui-pro-datatable", style: { width: "100%", tableLayout: "auto" }, children: [
72662
+ /* @__PURE__ */ jsx("thead", { className: "moonui-data-table-header", children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx("tr", { className: "moonui-data-table-row border-b", children: headerGroup.headers.filter((header) => header.column.getIsVisible()).map((header) => /* @__PURE__ */ jsx(
72663
+ "th",
72664
+ {
72665
+ className: "moonui-data-table-th h-12 px-4 text-left align-middle font-medium text-muted-foreground",
72666
+ children: header.isPlaceholder ? null : /* @__PURE__ */ jsxs(
72667
+ "div",
72668
+ {
72669
+ className: cn(
72670
+ "flex items-center space-x-2",
72671
+ header.column.getCanSort() && "cursor-pointer select-none"
72672
+ ),
72673
+ onClick: header.column.getToggleSortingHandler(),
72674
+ children: [
72675
+ flexRender(header.column.columnDef.header, header.getContext()),
72676
+ header.column.getCanSort() && /* @__PURE__ */ jsx("div", { className: "ml-2", children: header.column.getIsSorted() === "asc" ? /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ArrowUp, { className: "h-4 w-4" }) }) : header.column.getIsSorted() === "desc" ? /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ArrowDown, { className: "h-4 w-4" }) }) : /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ArrowUpDown, { className: "h-4 w-4" }) }) })
72677
+ ]
72678
+ }
72679
+ )
72680
+ },
72681
+ header.id
72682
+ )) }, headerGroup.id)) }),
72683
+ /* @__PURE__ */ jsx("tbody", { className: "moonui-data-table-body", children: isPaginationLoading ? /* @__PURE__ */ jsx(
72684
+ motion.tr,
72685
+ {
72686
+ initial: { opacity: 0 },
72687
+ animate: { opacity: 1 },
72688
+ exit: { opacity: 0 },
72689
+ transition: { duration: 0.2 },
72690
+ children: /* @__PURE__ */ jsx("td", { colSpan: table.getAllLeafColumns().filter((col) => col.getIsVisible()).length, className: "h-24 text-center", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center space-x-2", children: [
72691
+ /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) }),
72692
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: "Loading..." })
72693
+ ] }) })
72694
+ },
72695
+ "loading"
72696
+ ) : rows?.length ? /* @__PURE__ */ jsx(Fragment, { children: rows.map((row, index2) => {
72697
+ const rowId = row.original.id || row.id;
72698
+ const isExpanded = enableExpandable && expandedRows.has(rowId);
72699
+ return /* @__PURE__ */ jsx(
72700
+ TableRow2,
72701
+ {
72702
+ row,
72703
+ columns,
72704
+ isExpanded,
72705
+ enableExpandable,
72706
+ renderSubComponent,
72707
+ visibilityState: table.getState().columnVisibility
72708
+ },
72709
+ rowId
72710
+ );
72711
+ }) }) : /* @__PURE__ */ jsx(
72712
+ motion.tr,
72713
+ {
72714
+ initial: { opacity: 0 },
72715
+ animate: { opacity: 1 },
72716
+ exit: { opacity: 0 },
72717
+ transition: { duration: 0.2 },
72718
+ children: /* @__PURE__ */ jsx("td", { colSpan: table.getAllLeafColumns().filter((col) => col.getIsVisible()).length, className: "h-24 text-center", children: "No results found." })
72719
+ },
72720
+ "no-results"
72721
+ ) })
72722
+ ] }) }) }),
72723
+ pagination && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-2", children: [
72724
+ /* @__PURE__ */ jsx("div", { className: "flex-1 text-sm text-muted-foreground", children: selectable && table.getFilteredSelectedRowModel().rows.length > 0 && /* @__PURE__ */ jsxs("span", { children: [
72725
+ table.getFilteredSelectedRowModel().rows.length,
72726
+ " of",
72727
+ " ",
72728
+ table.getFilteredRowModel().rows.length,
72729
+ " row(s) selected."
72730
+ ] }) }),
72731
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-6 lg:space-x-8", children: [
72732
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
72733
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: "Rows per page" }),
72734
+ /* @__PURE__ */ jsx(
72735
+ "select",
72736
+ {
72737
+ value: table.getState().pagination.pageSize,
72738
+ onChange: async (e) => {
72739
+ setIsPaginationLoading(true);
72740
+ await new Promise((resolve) => setTimeout(resolve, 300));
72741
+ table.setPageSize(Number(e.target.value));
72742
+ setIsPaginationLoading(false);
72743
+ },
72744
+ className: "h-8 w-[70px] rounded border border-input bg-background px-3 py-1 text-sm",
72745
+ disabled: isPaginationLoading,
72746
+ children: [10, 20, 30, 40, 50].map((pageSize2) => /* @__PURE__ */ jsx("option", { value: pageSize2, children: pageSize2 }, pageSize2))
72747
+ }
72748
+ )
72749
+ ] }),
72750
+ /* @__PURE__ */ jsxs("div", { className: "flex w-[100px] items-center justify-center text-sm font-medium", children: [
72751
+ "Page ",
72752
+ table.getState().pagination.pageIndex + 1,
72753
+ " of",
72754
+ " ",
72755
+ table.getPageCount()
72756
+ ] }),
72757
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
72758
+ /* @__PURE__ */ jsx(
72759
+ MoonUIButtonPro,
72760
+ {
72761
+ variant: "outline",
72762
+ className: "hidden h-8 w-8 p-0 lg:flex",
72763
+ onClick: async () => {
72764
+ if (onPaginationChange) {
72765
+ onPaginationChange({ pageIndex: 0, pageSize: table.getState().pagination.pageSize });
72766
+ } else {
72767
+ setIsPaginationLoading(true);
72768
+ await new Promise((resolve) => setTimeout(resolve, 300));
72769
+ table.setPageIndex(0);
72770
+ setIsPaginationLoading(false);
72771
+ }
72772
+ },
72773
+ disabled: !table.getCanPreviousPage() || isPaginationLoading,
72774
+ children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronsLeft, { className: "h-4 w-4" }) })
72775
+ }
72776
+ ),
72777
+ /* @__PURE__ */ jsx(
72778
+ MoonUIButtonPro,
72779
+ {
72780
+ variant: "outline",
72781
+ className: "h-8 w-8 p-0",
72782
+ onClick: async () => {
72783
+ if (onPaginationChange) {
72784
+ const currentIndex = table.getState().pagination.pageIndex;
72785
+ onPaginationChange({ pageIndex: currentIndex - 1, pageSize: table.getState().pagination.pageSize });
72786
+ } else {
72787
+ setIsPaginationLoading(true);
72788
+ await new Promise((resolve) => setTimeout(resolve, 300));
72789
+ table.previousPage();
72790
+ setIsPaginationLoading(false);
72791
+ }
72792
+ },
72793
+ disabled: !table.getCanPreviousPage() || isPaginationLoading,
72794
+ children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" }) })
72795
+ }
72796
+ ),
72797
+ /* @__PURE__ */ jsx(
72798
+ MoonUIButtonPro,
72799
+ {
72800
+ variant: "outline",
72801
+ className: "h-8 w-8 p-0",
72802
+ onClick: async () => {
72803
+ setIsPaginationLoading(true);
72804
+ await new Promise((resolve) => setTimeout(resolve, 300));
72805
+ table.nextPage();
72806
+ setIsPaginationLoading(false);
72807
+ },
72808
+ disabled: !table.getCanNextPage() || isPaginationLoading,
72809
+ children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" }) })
72810
+ }
72811
+ ),
72812
+ /* @__PURE__ */ jsx(
72813
+ MoonUIButtonPro,
72814
+ {
72815
+ variant: "outline",
72816
+ className: "hidden h-8 w-8 p-0 lg:flex",
72817
+ onClick: async () => {
72818
+ setIsPaginationLoading(true);
72819
+ await new Promise((resolve) => setTimeout(resolve, 300));
72820
+ table.setPageIndex(table.getPageCount() - 1);
72821
+ setIsPaginationLoading(false);
72822
+ },
72823
+ disabled: !table.getCanNextPage() || isPaginationLoading,
72824
+ children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronsRight, { className: "h-4 w-4" }) })
72825
+ }
72826
+ )
72622
72827
  ] })
72623
72828
  ] })
72624
72829
  ] }),
72625
- /* @__PURE__ */ jsx(
72626
- AlertDialog2,
72830
+ filterable && /* @__PURE__ */ jsx(
72831
+ DataTableFilterDrawer,
72627
72832
  {
72628
- open: !!pendingAction,
72629
- onOpenChange: (open) => !open && setPendingAction(null),
72630
- children: /* @__PURE__ */ jsxs(AlertDialogContent2, { children: [
72631
- /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
72632
- /* @__PURE__ */ jsxs(AlertDialogTitle2, { className: "flex items-center gap-2", children: [
72633
- pendingAction?.variant === "destructive" && /* @__PURE__ */ jsx(AlertTriangle, { className: "h-5 w-5 text-destructive" }),
72634
- pendingAction?.confirmTitle || "Confirm Action"
72635
- ] }),
72636
- /* @__PURE__ */ jsx(AlertDialogDescription2, { children: pendingAction?.confirmMessage || `This action will affect ${selectedCount} selected item${selectedCount > 1 ? "s" : ""}. This action cannot be undone.` })
72637
- ] }),
72638
- /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
72639
- /* @__PURE__ */ jsx(AlertDialogCancel2, { disabled: isLoading, children: "Cancel" }),
72640
- /* @__PURE__ */ jsx(
72641
- AlertDialogAction2,
72642
- {
72643
- onClick: handleConfirm,
72644
- disabled: isLoading,
72645
- className: cn(
72646
- pendingAction?.variant === "destructive" && "bg-destructive text-destructive-foreground hover:bg-destructive/90"
72647
- ),
72648
- children: isLoading ? /* @__PURE__ */ jsxs(Fragment, { children: [
72649
- /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
72650
- "Processing..."
72651
- ] }) : "Confirm"
72652
- }
72653
- )
72654
- ] })
72655
- ] })
72833
+ table,
72834
+ open: filterDrawerOpen,
72835
+ onOpenChange: setFilterDrawerOpen
72656
72836
  }
72657
72837
  )
72658
72838
  ] });
72659
72839
  }
72660
-
72661
- // src/components/data-table/data-table-export.ts
72662
- function dataToCSV(data, columns, includeHeaders = true) {
72663
- if (data.length === 0)
72664
- return "";
72665
- const cols = columns || Object.keys(data[0]);
72666
- const rows = [];
72667
- if (includeHeaders) {
72668
- const headers = cols.map((col) => {
72669
- const value = String(col);
72670
- return value.includes(",") || value.includes('"') || value.includes("\n") ? `"${value.replace(/"/g, '""')}"` : value;
72671
- });
72672
- rows.push(headers.join(","));
72673
- }
72674
- data.forEach((item) => {
72675
- const row = cols.map((col) => {
72676
- const value = item[col];
72677
- if (value === null || value === void 0)
72678
- return "";
72679
- if (value instanceof Date)
72680
- return value.toISOString();
72681
- if (typeof value === "object")
72682
- return JSON.stringify(value);
72683
- const stringValue = String(value);
72684
- return stringValue.includes(",") || stringValue.includes('"') || stringValue.includes("\n") ? `"${stringValue.replace(/"/g, '""')}"` : stringValue;
72685
- });
72686
- rows.push(row.join(","));
72687
- });
72688
- return rows.join("\n");
72689
- }
72690
- function dataToJSON(data, columns) {
72691
- if (!columns || columns.length === 0) {
72692
- return JSON.stringify(data, null, 2);
72693
- }
72694
- const filteredData = data.map((item) => {
72695
- const filtered = {};
72696
- columns.forEach((col) => {
72697
- if (col in item) {
72698
- filtered[col] = item[col];
72699
- }
72700
- });
72701
- return filtered;
72702
- });
72703
- return JSON.stringify(filteredData, null, 2);
72704
- }
72705
- function downloadFile(content, filename, mimeType) {
72706
- const blob = new Blob([content], { type: mimeType });
72707
- const url = URL.createObjectURL(blob);
72708
- const link = document.createElement("a");
72709
- link.href = url;
72710
- link.download = filename;
72711
- document.body.appendChild(link);
72712
- link.click();
72713
- document.body.removeChild(link);
72714
- URL.revokeObjectURL(url);
72715
- }
72716
- async function exportData2(data, options) {
72717
- const { format: format8, filename = "data-export", columns, includeHeaders = true } = options;
72718
- let content;
72719
- let mimeType;
72720
- let extension;
72721
- switch (format8) {
72722
- case "csv":
72723
- content = dataToCSV(data, columns, includeHeaders);
72724
- mimeType = "text/csv;charset=utf-8;";
72725
- extension = "csv";
72726
- break;
72727
- case "json":
72728
- content = dataToJSON(data, columns);
72729
- mimeType = "application/json;charset=utf-8;";
72730
- extension = "json";
72731
- break;
72732
- case "xlsx":
72733
- throw new Error("XLSX export requires additional dependencies. Use CSV format instead.");
72734
- default:
72735
- throw new Error(`Unsupported export format: ${format8}`);
72736
- }
72737
- const finalFilename = `${filename}-${( new Date()).toISOString().split("T")[0]}.${extension}`;
72738
- downloadFile(content, finalFilename, mimeType);
72739
- }
72740
- function getVisibleColumns(columns, columnVisibility) {
72741
- return columns.filter((col) => {
72742
- const key = col.id || col.accessorKey;
72743
- return key && columnVisibility[key] !== false;
72744
- }).map((col) => col.id || col.accessorKey).filter(Boolean);
72745
- }
72746
- var operatorLabels = {
72747
- equals: "Equals",
72748
- notEquals: "Not equals",
72749
- contains: "Contains",
72750
- notContains: "Not contains",
72751
- startsWith: "Starts with",
72752
- endsWith: "Ends with",
72753
- greaterThan: "Greater than",
72754
- lessThan: "Less than",
72755
- greaterThanOrEqual: "Greater than or equal",
72756
- lessThanOrEqual: "Less than or equal",
72757
- between: "Between",
72758
- in: "In",
72759
- notIn: "Not in",
72760
- isNull: "Is empty",
72761
- isNotNull: "Is not empty"
72762
- };
72763
- function getOperatorsForColumnType(columnType) {
72764
- switch (columnType) {
72765
- case "number":
72766
- return ["equals", "notEquals", "greaterThan", "lessThan", "greaterThanOrEqual", "lessThanOrEqual", "between", "isNull", "isNotNull"];
72767
- case "date":
72768
- return ["equals", "notEquals", "greaterThan", "lessThan", "greaterThanOrEqual", "lessThanOrEqual", "between", "isNull", "isNotNull"];
72769
- case "boolean":
72770
- return ["equals", "notEquals", "isNull", "isNotNull"];
72771
- case "select":
72772
- return ["equals", "notEquals", "in", "notIn", "isNull", "isNotNull"];
72773
- default:
72774
- return ["equals", "notEquals", "contains", "notContains", "startsWith", "endsWith", "isNull", "isNotNull"];
72775
- }
72840
+ function getExpandableColumn(expandedRows, onToggle) {
72841
+ return {
72842
+ id: "expander",
72843
+ header: () => null,
72844
+ size: 50,
72845
+ cell: ({ row }) => {
72846
+ const rowId = row.original.id || row.id;
72847
+ const isExpanded = expandedRows.has(rowId);
72848
+ return /* @__PURE__ */ jsx(
72849
+ "button",
72850
+ {
72851
+ onClick: (e) => {
72852
+ e.stopPropagation();
72853
+ onToggle(rowId);
72854
+ },
72855
+ className: "p-2 hover:bg-muted rounded-md transition-colors",
72856
+ "aria-label": isExpanded ? "Collapse row" : "Expand row",
72857
+ children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: isExpanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 text-muted-foreground" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 text-muted-foreground" }) })
72858
+ }
72859
+ );
72860
+ }
72861
+ };
72776
72862
  }
72777
- function DataTableFilterDrawer({
72778
- table,
72779
- open,
72780
- onOpenChange,
72781
- position = "right",
72782
- width = "400px",
72783
- filters: externalFilters,
72784
- onFiltersChange,
72785
- customFilters,
72786
- matchAll: externalMatchAll,
72787
- onMatchAllChange
72788
- }) {
72789
- const [internalFilters, setInternalFilters] = useState([]);
72790
- const [internalMatchAll, setInternalMatchAll] = useState(true);
72791
- const filters = externalFilters || internalFilters;
72792
- const setFilters = onFiltersChange || setInternalFilters;
72793
- const matchAll = externalMatchAll !== void 0 ? externalMatchAll : internalMatchAll;
72794
- const setMatchAll = onMatchAllChange || setInternalMatchAll;
72795
- const filterableColumns = useMemo(() => {
72796
- return table.getAllColumns().filter((column) => {
72797
- if (column.id === "select" || column.id === "actions" || column.id === "expander") {
72798
- return false;
72863
+ function useExpandableRows(initialExpanded = /* @__PURE__ */ new Set()) {
72864
+ const [expandedRows, setExpandedRows] = t__default.useState(initialExpanded);
72865
+ const toggleRow = t__default.useCallback((id) => {
72866
+ setExpandedRows((prev) => {
72867
+ const newExpanded = new Set(prev);
72868
+ if (newExpanded.has(id)) {
72869
+ newExpanded.delete(id);
72870
+ } else {
72871
+ newExpanded.add(id);
72799
72872
  }
72800
- return column.getCanFilter();
72801
- });
72802
- }, [table]);
72803
- const addFilter = () => {
72804
- const firstColumn = filterableColumns[0];
72805
- if (!firstColumn)
72806
- return;
72807
- const newFilter = {
72808
- column: firstColumn.id,
72809
- operator: "contains",
72810
- value: ""
72811
- };
72812
- setFilters([...filters, newFilter]);
72813
- };
72814
- const updateFilter = (index2, updates) => {
72815
- const newFilters = [...filters];
72816
- newFilters[index2] = { ...newFilters[index2], ...updates };
72817
- setFilters(newFilters);
72818
- };
72819
- const removeFilter = (index2) => {
72820
- setFilters(filters.filter((_, i) => i !== index2));
72821
- };
72822
- const clearAllFilters = () => {
72823
- setFilters([]);
72824
- table.resetColumnFilters();
72825
- };
72826
- const applyFilters = () => {
72827
- table.resetColumnFilters();
72828
- const columnsWithFilters = [...new Set(filters.map((f) => f.column))];
72829
- columnsWithFilters.forEach((columnId) => {
72830
- const column = table.getColumn(columnId);
72831
- if (!column)
72832
- return;
72833
- column.setFilterValue({ custom: true, filters, matchAll });
72873
+ return newExpanded;
72834
72874
  });
72835
- if (filters.length === 0) {
72836
- table.resetColumnFilters();
72837
- }
72838
- onOpenChange(false);
72875
+ }, []);
72876
+ const expandAll = t__default.useCallback((rowIds) => {
72877
+ setExpandedRows(new Set(rowIds));
72878
+ }, []);
72879
+ const collapseAll = t__default.useCallback(() => {
72880
+ setExpandedRows(/* @__PURE__ */ new Set());
72881
+ }, []);
72882
+ return {
72883
+ expandedRows,
72884
+ setExpandedRows,
72885
+ toggleRow,
72886
+ expandAll,
72887
+ collapseAll
72839
72888
  };
72889
+ }
72890
+ var TableRow2 = t__default.memo(({
72891
+ row,
72892
+ columns,
72893
+ isExpanded,
72894
+ enableExpandable,
72895
+ renderSubComponent,
72896
+ visibilityState
72897
+ }) => {
72898
+ const rowId = row.original.id || row.id;
72840
72899
  return /* @__PURE__ */ jsxs(Fragment, { children: [
72841
- /* @__PURE__ */ jsx(AnimatePresence, { children: open && /* @__PURE__ */ jsx(
72842
- motion.div,
72843
- {
72844
- initial: { opacity: 0 },
72845
- animate: { opacity: 1 },
72846
- exit: { opacity: 0 },
72847
- className: "fixed inset-0 bg-black/20 z-40",
72848
- onClick: () => onOpenChange(false)
72849
- }
72850
- ) }),
72851
- /* @__PURE__ */ jsx(AnimatePresence, { children: open && /* @__PURE__ */ jsx(
72852
- motion.div,
72900
+ /* @__PURE__ */ jsx(
72901
+ "tr",
72853
72902
  {
72854
- initial: { x: position === "right" ? "100%" : "-100%" },
72855
- animate: { x: 0 },
72856
- exit: { x: position === "right" ? "100%" : "-100%" },
72857
- transition: { type: "spring", damping: 30, stiffness: 300 },
72858
72903
  className: cn(
72859
- "fixed top-0 bottom-0 z-50 bg-background border-l shadow-xl",
72860
- position === "right" ? "right-0" : "left-0"
72904
+ "border-b transition-colors hover:bg-muted/50",
72905
+ row.getIsSelected() && "bg-muted",
72906
+ isExpanded && "border-b-0"
72861
72907
  ),
72862
- style: { width },
72863
- children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
72864
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between p-4 border-b", children: [
72865
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
72866
- /* @__PURE__ */ jsx(Filter, { className: "h-5 w-5" }),
72867
- /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold", children: "Filters" }),
72868
- filters.length > 0 && /* @__PURE__ */ jsxs("span", { className: "text-sm text-muted-foreground", children: [
72869
- "(",
72870
- filters.length,
72871
- " active)"
72872
- ] })
72873
- ] }),
72874
- /* @__PURE__ */ jsx(
72875
- MoonUIButtonPro,
72876
- {
72877
- variant: "ghost",
72878
- size: "icon",
72879
- onClick: () => onOpenChange(false),
72880
- children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
72881
- }
72882
- )
72883
- ] }),
72884
- /* @__PURE__ */ jsxs("div", { className: "flex-1 overflow-y-auto p-4", children: [
72885
- /* @__PURE__ */ jsxs("div", { className: "mb-6", children: [
72886
- /* @__PURE__ */ jsx(MoonUILabelPro, { className: "text-sm font-medium mb-2 block", children: "Match conditions" }),
72887
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
72888
- /* @__PURE__ */ jsx(
72889
- MoonUIButtonPro,
72890
- {
72891
- variant: matchAll ? "primary" : "outline",
72892
- size: "sm",
72893
- onClick: () => setMatchAll(true),
72894
- className: "flex-1",
72895
- children: "Match all"
72896
- }
72897
- ),
72898
- /* @__PURE__ */ jsx(
72899
- MoonUIButtonPro,
72900
- {
72901
- variant: !matchAll ? "primary" : "outline",
72902
- size: "sm",
72903
- onClick: () => setMatchAll(false),
72904
- className: "flex-1",
72905
- children: "Match any"
72906
- }
72907
- )
72908
- ] })
72909
- ] }),
72910
- /* @__PURE__ */ jsx(MoonUISeparatorPro, { className: "mb-6" }),
72911
- customFilters && /* @__PURE__ */ jsxs(Fragment, { children: [
72912
- customFilters,
72913
- /* @__PURE__ */ jsx(MoonUISeparatorPro, { className: "my-6" })
72914
- ] }),
72915
- /* @__PURE__ */ jsx("div", { className: "space-y-4", children: filters.map((filter, index2) => /* @__PURE__ */ jsx(
72916
- FilterConditionRow,
72917
- {
72918
- filter,
72919
- columns: filterableColumns,
72920
- onUpdate: (updates) => updateFilter(index2, updates),
72921
- onRemove: () => removeFilter(index2)
72922
- },
72923
- index2
72924
- )) }),
72925
- /* @__PURE__ */ jsxs(
72926
- MoonUIButtonPro,
72927
- {
72928
- variant: "outline",
72929
- size: "sm",
72930
- onClick: addFilter,
72931
- className: "w-full mt-4",
72932
- children: [
72933
- /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4 mr-2" }),
72934
- "Add filter"
72935
- ]
72936
- }
72937
- )
72938
- ] }),
72939
- /* @__PURE__ */ jsx("div", { className: "p-4 border-t space-y-2", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
72940
- /* @__PURE__ */ jsxs(
72941
- MoonUIButtonPro,
72942
- {
72943
- variant: "outline",
72944
- onClick: clearAllFilters,
72945
- disabled: filters.length === 0,
72946
- className: "flex-1",
72947
- children: [
72948
- /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4 mr-2" }),
72949
- "Clear all"
72950
- ]
72951
- }
72952
- ),
72953
- /* @__PURE__ */ jsx(MoonUIButtonPro, { onClick: applyFilters, className: "flex-1", children: "Apply filters" })
72954
- ] }) })
72955
- ] })
72956
- }
72957
- ) })
72958
- ] });
72959
- }
72960
- function FilterConditionRow({
72961
- filter,
72962
- columns,
72963
- onUpdate,
72964
- onRemove
72965
- }) {
72966
- const selectedColumn = columns.find((col) => col.id === filter.column);
72967
- const columnDef = selectedColumn?.columnDef;
72968
- const columnType = columnDef?.meta?.filterType || "string";
72969
- const availableOperators = getOperatorsForColumnType(columnType);
72970
- const needsValue = filter.operator !== "isNull" && filter.operator !== "isNotNull";
72971
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2 p-3 border rounded-lg bg-muted/30", children: [
72972
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
72973
- /* @__PURE__ */ jsxs(
72974
- MoonUISelectPro,
72975
- {
72976
- value: filter.column,
72977
- onValueChange: (value) => onUpdate({ column: value }),
72978
- children: [
72979
- /* @__PURE__ */ jsx(MoonUISelectTriggerPro, { className: "flex-1", children: /* @__PURE__ */ jsx(MoonUISelectValuePro, {}) }),
72980
- /* @__PURE__ */ jsx(MoonUISelectContentPro, { children: columns.map((column) => {
72981
- const header = column.columnDef.header;
72982
- const label = typeof header === "function" ? column.id : header || column.id;
72983
- return /* @__PURE__ */ jsx(MoonUISelectItemPro, { value: column.id, children: label }, column.id);
72984
- }) })
72985
- ]
72986
- }
72987
- ),
72988
- /* @__PURE__ */ jsx(
72989
- MoonUIButtonPro,
72990
- {
72991
- variant: "ghost",
72992
- size: "icon",
72993
- onClick: onRemove,
72994
- className: "h-8 w-8",
72995
- children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
72996
- }
72997
- )
72998
- ] }),
72999
- /* @__PURE__ */ jsxs(
73000
- MoonUISelectPro,
73001
- {
73002
- value: filter.operator,
73003
- onValueChange: (value) => onUpdate({ operator: value }),
73004
- children: [
73005
- /* @__PURE__ */ jsx(MoonUISelectTriggerPro, { children: /* @__PURE__ */ jsx(MoonUISelectValuePro, {}) }),
73006
- /* @__PURE__ */ jsx(MoonUISelectContentPro, { children: availableOperators.map((operator2) => /* @__PURE__ */ jsx(MoonUISelectItemPro, { value: operator2, children: operatorLabels[operator2] }, operator2)) })
73007
- ]
72908
+ children: row.getAllCells().filter((cell) => {
72909
+ const isVisible = visibilityState[cell.column.id] !== false;
72910
+ return isVisible;
72911
+ }).map((cell) => {
72912
+ return /* @__PURE__ */ jsx("td", { className: "moonui-data-table-td p-4 align-middle", children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id);
72913
+ })
73008
72914
  }
73009
72915
  ),
73010
- needsValue && /* @__PURE__ */ jsx("div", { children: columnType === "boolean" ? /* @__PURE__ */ jsxs(
73011
- MoonUISelectPro,
72916
+ isExpanded && renderSubComponent && /* @__PURE__ */ jsx("tr", { className: "border-b", children: /* @__PURE__ */ jsx("td", { colSpan: row.getAllCells().filter(
72917
+ (cell) => visibilityState[cell.column.id] !== false
72918
+ ).length || 1, className: "p-0 overflow-hidden", children: /* @__PURE__ */ jsx(
72919
+ "div",
73012
72920
  {
73013
- value: String(filter.value),
73014
- onValueChange: (value) => onUpdate({ value: value === "true" }),
73015
- children: [
73016
- /* @__PURE__ */ jsx(MoonUISelectTriggerPro, { children: /* @__PURE__ */ jsx(MoonUISelectValuePro, {}) }),
73017
- /* @__PURE__ */ jsxs(MoonUISelectContentPro, { children: [
73018
- /* @__PURE__ */ jsx(MoonUISelectItemPro, { value: "true", children: "True" }),
73019
- /* @__PURE__ */ jsx(MoonUISelectItemPro, { value: "false", children: "False" })
73020
- ] })
73021
- ]
72921
+ className: "transition-all duration-300 ease-out",
72922
+ style: {
72923
+ maxHeight: isExpanded ? "1000px" : "0",
72924
+ opacity: isExpanded ? 1 : 0
72925
+ },
72926
+ children: /* @__PURE__ */ jsx("div", { className: "border-t border-border/50", children: renderSubComponent({ row: { original: row.original, id: rowId } }) })
73022
72927
  }
73023
- ) : columnType === "number" ? /* @__PURE__ */ jsx(
73024
- MoonUIInputPro,
73025
- {
73026
- type: "number",
73027
- value: filter.value || "",
73028
- onChange: (e) => onUpdate({ value: e.target.value }),
73029
- placeholder: "Enter value..."
72928
+ ) }) })
72929
+ ] });
72930
+ }, (prevProps, nextProps) => {
72931
+ const prevRowId = prevProps.row.original.id || prevProps.row.id;
72932
+ const nextRowId = nextProps.row.original.id || nextProps.row.id;
72933
+ const prevVisibilityKeys = Object.keys(prevProps.visibilityState).sort().join(",");
72934
+ const nextVisibilityKeys = Object.keys(nextProps.visibilityState).sort().join(",");
72935
+ const prevVisibilityValues = Object.values(prevProps.visibilityState).join(",");
72936
+ const nextVisibilityValues = Object.values(nextProps.visibilityState).join(",");
72937
+ return prevRowId === nextRowId && prevProps.isExpanded === nextProps.isExpanded && prevProps.row.getIsSelected() === nextProps.row.getIsSelected() && prevVisibilityKeys === nextVisibilityKeys && prevVisibilityValues === nextVisibilityValues;
72938
+ });
72939
+ TableRow2.displayName = "TableRow";
72940
+ var MoonUIDataTablePro = DataTable;
72941
+ var SearchInput = t__default.memo(({
72942
+ searchInputRef,
72943
+ searchPlaceholder,
72944
+ initialValue,
72945
+ onSearchChange,
72946
+ keyboardShortcuts
72947
+ }) => {
72948
+ const [localValue, setLocalValue] = useState(initialValue || "");
72949
+ const timeoutRef = useRef(void 0);
72950
+ useEffect(() => {
72951
+ setLocalValue(initialValue);
72952
+ }, [initialValue]);
72953
+ const handleChange = useCallback((e) => {
72954
+ const newValue = e.target.value;
72955
+ setLocalValue(newValue);
72956
+ if (timeoutRef.current) {
72957
+ clearTimeout(timeoutRef.current);
72958
+ }
72959
+ timeoutRef.current = setTimeout(() => {
72960
+ onSearchChange(newValue);
72961
+ if (searchInputRef.current) {
72962
+ searchInputRef.current.focus();
73030
72963
  }
73031
- ) : /* @__PURE__ */ jsx(
73032
- MoonUIInputPro,
72964
+ }, 150);
72965
+ }, [onSearchChange, searchInputRef]);
72966
+ useEffect(() => {
72967
+ return () => {
72968
+ if (timeoutRef.current) {
72969
+ clearTimeout(timeoutRef.current);
72970
+ }
72971
+ };
72972
+ }, []);
72973
+ return /* @__PURE__ */ jsx("div", { className: "p-4 border-b", children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
72974
+ /* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none" }),
72975
+ /* @__PURE__ */ jsx(
72976
+ "input",
73033
72977
  {
73034
- value: filter.value || "",
73035
- onChange: (e) => onUpdate({ value: e.target.value }),
73036
- placeholder: "Enter value..."
72978
+ ref: searchInputRef,
72979
+ type: "text",
72980
+ placeholder: searchPlaceholder,
72981
+ value: localValue,
72982
+ onChange: handleChange,
72983
+ autoComplete: "off",
72984
+ autoCorrect: "off",
72985
+ autoCapitalize: "off",
72986
+ spellCheck: "false",
72987
+ 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"
73037
72988
  }
73038
- ) })
73039
- ] });
73040
- }
73041
- function DataTable({
73042
- columns: originalColumns,
73043
- data,
73044
- searchable = true,
73045
- filterable = true,
73046
- exportable = true,
73047
- selectable = false,
73048
- pagination = true,
73049
- pageSize = 10,
72989
+ ),
72990
+ 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: [
72991
+ /* @__PURE__ */ jsx("span", { className: "text-xs", children: "\u2318" }),
72992
+ "K"
72993
+ ] })
72994
+ ] }) });
72995
+ });
72996
+ SearchInput.displayName = "SearchInput";
72997
+ function SidebarInternal({
72998
+ sections,
72999
+ footer,
73000
+ showSearch = true,
73001
+ searchPlaceholder = "Search...",
73002
+ searchQuery = "",
73003
+ onSearchChange,
73004
+ showThemeToggle = false,
73005
+ theme = "system",
73006
+ onThemeChange,
73007
+ branding,
73008
+ collapsible = true,
73009
+ defaultCollapsed = false,
73010
+ floatingActionButton = true,
73011
+ floatingActionButtonPosition = { bottom: "1rem", left: "1rem" },
73012
+ floatingActionButtonClassName,
73013
+ glassmorphism = false,
73014
+ animatedBackground = false,
73015
+ keyboardShortcuts = true,
73016
+ persistState = true,
73017
+ persistKey = "moonui-sidebar-state",
73018
+ onStateChange,
73019
+ customStyles,
73020
+ fullWidthItems = true,
73050
73021
  className,
73051
- onRowSelect,
73052
- onExport,
73053
- enableExpandable = false,
73054
- renderSubComponent,
73055
- expandedRows: controlledExpandedRows,
73056
- onRowExpandChange,
73057
- bulkActions = [],
73058
- features = {},
73059
- theme = {},
73060
- texts = {},
73061
- // Additional props
73062
- enableSorting = true,
73063
- enableFiltering = true,
73064
- enablePagination = true,
73065
- enableColumnVisibility = true,
73066
- enableRowSelection,
73067
- filterPlaceholder = "Search all columns...",
73068
- defaultPageSize,
73069
- manualPagination = false,
73070
- pageCount,
73071
- onPaginationChange,
73072
- onSortingChange,
73073
- onColumnFiltersChange,
73074
- state: externalState
73022
+ activePath,
73023
+ onNavigate
73075
73024
  }) {
73076
- const columns = t__default.useMemo(() => {
73077
- return originalColumns.map((col) => {
73078
- const { enableHiding, ...restCol } = col;
73079
- return {
73080
- ...restCol,
73081
- enableHiding: true,
73082
- // Force all columns to be hideable
73083
- filterFn: "custom"
73084
- // Use our custom filter function
73085
- };
73086
- });
73087
- }, [originalColumns]);
73088
- const { hasProAccess, isLoading } = useSubscription();
73089
- if (!isLoading && !hasProAccess) {
73090
- return /* @__PURE__ */ jsx(MoonUICardPro, { className: cn("w-full", className), children: /* @__PURE__ */ jsx(MoonUICardContentPro, { className: "py-12 text-center", children: /* @__PURE__ */ jsxs("div", { className: "max-w-md mx-auto space-y-4", children: [
73091
- /* @__PURE__ */ jsx("div", { className: "rounded-full bg-purple-100 dark:bg-purple-900/30 p-3 w-fit mx-auto", children: /* @__PURE__ */ jsx(Lock, { className: "h-6 w-6 text-purple-600 dark:text-purple-400" }) }),
73092
- /* @__PURE__ */ jsxs("div", { children: [
73093
- /* @__PURE__ */ jsx("h3", { className: "font-semibold text-lg mb-2", children: "Pro Feature" }),
73094
- /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm mb-4", children: "Data Table is available exclusively to MoonUI Pro subscribers." }),
73095
- /* @__PURE__ */ jsx("div", { className: "flex gap-3 justify-center", children: /* @__PURE__ */ jsx("a", { href: "/pricing", children: /* @__PURE__ */ jsxs(MoonUIButtonPro, { size: "sm", children: [
73096
- /* @__PURE__ */ jsx(Sparkles, { className: "mr-2 h-4 w-4" }),
73097
- "Upgrade to Pro"
73098
- ] }) }) })
73099
- ] })
73100
- ] }) }) });
73101
- }
73102
- const [sorting, setSorting] = t__default.useState([]);
73103
- const [columnFilters, setColumnFilters] = t__default.useState([]);
73104
- const [columnVisibility, setColumnVisibility] = t__default.useState({});
73105
- const [rowSelection, setRowSelection] = t__default.useState({});
73106
- const [globalFilter, setGlobalFilter] = t__default.useState("");
73107
- const [isPaginationLoading, setIsPaginationLoading] = t__default.useState(false);
73108
- const [internalExpandedRows, setInternalExpandedRows] = t__default.useState(/* @__PURE__ */ new Set());
73109
- const [filterDrawerOpen, setFilterDrawerOpen] = t__default.useState(false);
73110
- const expandedRows = controlledExpandedRows || internalExpandedRows;
73111
- const actualPageSize = defaultPageSize || pageSize;
73112
- const stableData = t__default.useMemo(() => data, [data]);
73113
- const table = useReactTable({
73114
- data: stableData,
73115
- columns,
73116
- onSortingChange: onSortingChange !== void 0 ? onSortingChange : setSorting,
73117
- onColumnFiltersChange: onColumnFiltersChange !== void 0 ? onColumnFiltersChange : setColumnFilters,
73118
- getCoreRowModel: getCoreRowModel(),
73119
- getPaginationRowModel: getPaginationRowModel(),
73120
- getSortedRowModel: getSortedRowModel(),
73121
- getFilteredRowModel: getFilteredRowModel(),
73122
- onColumnVisibilityChange: setColumnVisibility,
73123
- onRowSelectionChange: setRowSelection,
73124
- onGlobalFilterChange: setGlobalFilter,
73125
- globalFilterFn: "includesString",
73126
- filterFns: {
73127
- custom: (row, columnId, filterValue) => {
73128
- if (!filterValue?.custom || !filterValue?.filters)
73129
- return true;
73130
- const filters = filterValue.filters;
73131
- const matchAll = filterValue.matchAll !== void 0 ? filterValue.matchAll : true;
73132
- const allFilterResults = filters.map((filterCondition) => {
73133
- const cellValue = row.getValue(filterCondition.column);
73134
- const filterVal = filterCondition.value;
73135
- switch (filterCondition.operator) {
73136
- case "equals":
73137
- return cellValue === filterVal;
73138
- case "notEquals":
73139
- return cellValue !== filterVal;
73140
- case "contains":
73141
- return String(cellValue).toLowerCase().includes(String(filterVal).toLowerCase());
73142
- case "notContains":
73143
- return !String(cellValue).toLowerCase().includes(String(filterVal).toLowerCase());
73144
- case "startsWith":
73145
- return String(cellValue).toLowerCase().startsWith(String(filterVal).toLowerCase());
73146
- case "endsWith":
73147
- return String(cellValue).toLowerCase().endsWith(String(filterVal).toLowerCase());
73148
- case "greaterThan":
73149
- return Number(cellValue) > Number(filterVal);
73150
- case "lessThan":
73151
- return Number(cellValue) < Number(filterVal);
73152
- case "greaterThanOrEqual":
73153
- return Number(cellValue) >= Number(filterVal);
73154
- case "lessThanOrEqual":
73155
- return Number(cellValue) <= Number(filterVal);
73156
- case "isNull":
73157
- return cellValue == null || cellValue === "";
73158
- case "isNotNull":
73159
- return cellValue != null && cellValue !== "";
73160
- default:
73161
- return true;
73162
- }
73163
- });
73164
- if (matchAll) {
73165
- return allFilterResults.every((result) => result);
73166
- } else {
73167
- return allFilterResults.some((result) => result);
73168
- }
73169
- }
73170
- },
73171
- manualPagination,
73172
- pageCount,
73173
- state: {
73174
- sorting: externalState?.sorting ?? sorting,
73175
- columnFilters: externalState?.columnFilters ?? columnFilters,
73176
- columnVisibility: externalState?.columnVisibility ?? columnVisibility,
73177
- rowSelection: externalState?.rowSelection ?? rowSelection,
73178
- globalFilter: externalState?.globalFilter ?? globalFilter,
73179
- ...externalState || {}
73180
- },
73181
- initialState: {
73182
- pagination: {
73183
- pageSize: actualPageSize
73025
+ const [isMobile, setIsMobile] = useState(false);
73026
+ const [isOpen, setIsOpen] = useState(false);
73027
+ const [collapsed, setCollapsed] = useState(defaultCollapsed);
73028
+ const [expandedSections, setExpandedSections] = useState([]);
73029
+ const [currentSearchQuery, setCurrentSearchQuery] = useState(searchQuery);
73030
+ const [pinnedItems, setPinnedItems] = useState([]);
73031
+ const searchInputRef = useRef(null);
73032
+ const mouseX = useMotionValue(0);
73033
+ const mouseY = useMotionValue(0);
73034
+ const springX = useSpring(mouseX, { stiffness: 300, damping: 30 });
73035
+ const springY = useSpring(mouseY, { stiffness: 300, damping: 30 });
73036
+ useEffect(() => {
73037
+ if (persistState && typeof window !== "undefined") {
73038
+ const savedState = localStorage.getItem(persistKey);
73039
+ if (savedState) {
73040
+ const state = JSON.parse(savedState);
73041
+ setCollapsed(state.collapsed);
73042
+ setExpandedSections(state.expandedSections);
73043
+ setPinnedItems(state.pinnedItems || []);
73184
73044
  }
73185
- },
73186
- // Prevent re-renders on state changes
73187
- autoResetAll: false,
73188
- autoResetPageIndex: false,
73189
- autoResetExpanded: false,
73190
- getRowId: (row) => row.id || row.orderId || Math.random().toString()
73191
- });
73192
- t__default.useEffect(() => {
73193
- if (onRowSelect && selectable) {
73194
- const selectedRows = table.getFilteredSelectedRowModel().rows.map((row) => row.original);
73195
- onRowSelect(selectedRows);
73196
73045
  }
73197
- }, [rowSelection, onRowSelect, selectable, table]);
73198
- table.getState();
73199
- const rowModel = table.getRowModel();
73200
- const rowsRef = t__default.useRef(rowModel.rows);
73201
- t__default.useMemo(() => {
73202
- const changed = rowsRef.current !== rowModel.rows;
73203
- if (changed) {
73204
- rowsRef.current = rowModel.rows;
73046
+ }, [persistState, persistKey]);
73047
+ useEffect(() => {
73048
+ if (persistState && typeof window !== "undefined") {
73049
+ const state = {
73050
+ collapsed,
73051
+ expandedSections,
73052
+ searchQuery: currentSearchQuery,
73053
+ pinnedItems,
73054
+ recentItems: []
73055
+ };
73056
+ localStorage.setItem(persistKey, JSON.stringify(state));
73057
+ onStateChange?.(state);
73205
73058
  }
73206
- return changed;
73207
- }, [rowModel.rows]);
73208
- const rows = rowsRef.current;
73209
- ({
73210
- sorting: features.sorting !== false,
73211
- filtering: features.filtering !== false || filterable,
73212
- pagination: features.pagination !== false || pagination,
73213
- search: features.search !== false || searchable,
73214
- columnVisibility: features.columnVisibility !== false,
73215
- rowSelection: features.rowSelection !== false || selectable,
73216
- export: features.export !== false || exportable
73217
- });
73218
- const handleExport = async (format8) => {
73219
- const selectedRows = table.getFilteredSelectedRowModel().rows;
73220
- const dataToExport = selectedRows.length > 0 ? selectedRows.map((row) => row.original) : table.getFilteredRowModel().rows.map((row) => row.original);
73221
- if (typeof exportable === "object" && exportable.onExport) {
73222
- exportable.onExport(dataToExport, format8);
73059
+ }, [collapsed, expandedSections, currentSearchQuery, pinnedItems, persistState, persistKey, onStateChange]);
73060
+ useEffect(() => {
73061
+ const checkMobile = () => {
73062
+ setIsMobile(window.innerWidth < 768);
73063
+ };
73064
+ checkMobile();
73065
+ window.addEventListener("resize", checkMobile);
73066
+ return () => window.removeEventListener("resize", checkMobile);
73067
+ }, []);
73068
+ useEffect(() => {
73069
+ const sectionsToExpand = sections.filter((section) => section.defaultExpanded !== false).map((section) => section.id);
73070
+ setExpandedSections(sectionsToExpand);
73071
+ }, [sections]);
73072
+ useEffect(() => {
73073
+ if (!keyboardShortcuts)
73223
73074
  return;
73224
- }
73225
- if (onExport) {
73226
- onExport(dataToExport);
73075
+ const handleKeyDown3 = (e) => {
73076
+ if ((e.metaKey || e.ctrlKey) && e.key === "k") {
73077
+ e.preventDefault();
73078
+ searchInputRef.current?.focus();
73079
+ }
73080
+ if ((e.metaKey || e.ctrlKey) && e.key === "b") {
73081
+ e.preventDefault();
73082
+ if (isMobile) {
73083
+ setIsOpen(!isOpen);
73084
+ } else {
73085
+ setCollapsed(!collapsed);
73086
+ }
73087
+ }
73088
+ };
73089
+ document.addEventListener("keydown", handleKeyDown3);
73090
+ return () => document.removeEventListener("keydown", handleKeyDown3);
73091
+ }, [keyboardShortcuts, isMobile, isOpen, collapsed]);
73092
+ useEffect(() => {
73093
+ if (!animatedBackground)
73227
73094
  return;
73095
+ const handleMouseMove2 = (e) => {
73096
+ const rect = document.querySelector(".sidebar-container")?.getBoundingClientRect();
73097
+ if (rect) {
73098
+ mouseX.set(e.clientX - rect.left);
73099
+ mouseY.set(e.clientY - rect.top);
73100
+ }
73101
+ };
73102
+ document.addEventListener("mousemove", handleMouseMove2);
73103
+ return () => document.removeEventListener("mousemove", handleMouseMove2);
73104
+ }, [animatedBackground, mouseX, mouseY]);
73105
+ const toggleSection = useCallback((sectionId) => {
73106
+ setExpandedSections(
73107
+ (prev) => prev.includes(sectionId) ? prev.filter((id) => id !== sectionId) : [...prev, sectionId]
73108
+ );
73109
+ }, []);
73110
+ useCallback((itemId) => {
73111
+ setPinnedItems(
73112
+ (prev) => prev.includes(itemId) ? prev.filter((id) => id !== itemId) : [...prev, itemId]
73113
+ );
73114
+ }, []);
73115
+ const handleItemClick = useCallback((item) => {
73116
+ if (item.action) {
73117
+ item.action();
73118
+ } else if (item.href && onNavigate) {
73119
+ onNavigate(item.href);
73120
+ if (isMobile) {
73121
+ setIsOpen(false);
73122
+ }
73228
73123
  }
73229
- const filename = typeof exportable === "object" && exportable.filename ? exportable.filename : "data-export";
73230
- const visibleColumns = getVisibleColumns(columns, columnVisibility);
73231
- await exportData2(dataToExport, {
73232
- format: format8,
73233
- filename,
73234
- columns: visibleColumns,
73235
- includeHeaders: true
73124
+ }, [onNavigate, isMobile]);
73125
+ useEffect(() => {
73126
+ setCurrentSearchQuery(searchQuery);
73127
+ }, [searchQuery]);
73128
+ const handleSearch = useCallback((value) => {
73129
+ setCurrentSearchQuery(value);
73130
+ onSearchChange?.(value);
73131
+ }, [onSearchChange]);
73132
+ const filterItems = useCallback((items, query) => {
73133
+ if (!query)
73134
+ return items;
73135
+ return items.filter((item) => {
73136
+ const matchesTitle = item.title.toLowerCase().includes(query.toLowerCase());
73137
+ const hasMatchingChildren = item.items?.some(
73138
+ (child) => child.title.toLowerCase().includes(query.toLowerCase())
73139
+ );
73140
+ return matchesTitle || hasMatchingChildren;
73236
73141
  });
73237
- };
73238
- const exportFormats = t__default.useMemo(() => {
73239
- if (!exportable)
73240
- return [];
73241
- if (exportable === true)
73242
- return ["csv", "json"];
73243
- if (typeof exportable === "object" && exportable.formats) {
73244
- return exportable.formats;
73142
+ }, []);
73143
+ const filteredSections = useMemo(() => {
73144
+ if (!currentSearchQuery) {
73145
+ return sections.map((section) => ({
73146
+ ...section,
73147
+ filteredItems: section.items.map((item) => ({
73148
+ ...item,
73149
+ filteredChildren: item.items
73150
+ }))
73151
+ }));
73245
73152
  }
73246
- return ["csv", "json"];
73247
- }, [exportable]);
73248
- const clearRowSelection = () => {
73249
- table.resetRowSelection();
73250
- };
73251
- return /* @__PURE__ */ jsxs("div", { className: cn("moonui-pro-datatable-container flex flex-col gap-4", className), children: [
73252
- /* @__PURE__ */ jsxs("div", { className: "moonui-pro-datatable-toolbar flex items-center justify-between", children: [
73253
- /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
73254
- searchable && /* @__PURE__ */ jsxs("div", { className: "relative", children: [
73255
- /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }) }),
73153
+ return sections.map((section) => ({
73154
+ ...section,
73155
+ filteredItems: filterItems(section.items, currentSearchQuery).map((item) => ({
73156
+ ...item,
73157
+ filteredChildren: item.items ? filterItems(item.items, currentSearchQuery) : void 0
73158
+ }))
73159
+ })).filter((section) => section.filteredItems.length > 0);
73160
+ }, [sections, currentSearchQuery, filterItems]);
73161
+ const renderCollapsedHoverContent = useCallback((item) => {
73162
+ const hasChildren = item.items && item.items.length > 0;
73163
+ if (!hasChildren && !item.title)
73164
+ return null;
73165
+ return /* @__PURE__ */ jsxs("div", { className: cn(
73166
+ "min-w-[200px] p-2",
73167
+ glassmorphism && "bg-background/95 backdrop-blur-sm"
73168
+ ), children: [
73169
+ /* @__PURE__ */ jsx("div", { className: "font-medium px-2 py-1 text-sm", children: item.title }),
73170
+ hasChildren && /* @__PURE__ */ jsx("div", { className: "mt-1 space-y-0.5", children: item.items?.map((childItem) => {
73171
+ const isChildActive = childItem.href === activePath;
73172
+ const hasGrandChildren = childItem.items && childItem.items.length > 0;
73173
+ return /* @__PURE__ */ jsx("div", { className: "relative", children: hasGrandChildren ? /* @__PURE__ */ jsxs(HoverCard2, { openDelay: 200, closeDelay: 100, children: [
73174
+ /* @__PURE__ */ jsx(HoverCardTrigger2, { asChild: true, children: /* @__PURE__ */ jsxs(
73175
+ "button",
73176
+ {
73177
+ onClick: () => handleItemClick(childItem),
73178
+ disabled: childItem.disabled,
73179
+ className: cn(
73180
+ "w-full flex items-center justify-between gap-2 rounded-md px-2 py-1.5 text-sm transition-colors",
73181
+ "hover:bg-accent hover:text-accent-foreground",
73182
+ isChildActive && "bg-primary/10 text-primary font-medium",
73183
+ childItem.disabled && "opacity-50 cursor-not-allowed"
73184
+ ),
73185
+ children: [
73186
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
73187
+ childItem.icon && /* @__PURE__ */ jsx("span", { className: "flex-shrink-0", children: childItem.icon }),
73188
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: childItem.title })
73189
+ ] }),
73190
+ /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 flex-shrink-0" })
73191
+ ]
73192
+ }
73193
+ ) }),
73256
73194
  /* @__PURE__ */ jsx(
73257
- MoonUIInputPro,
73195
+ HoverCardContent2,
73258
73196
  {
73259
- placeholder: filterPlaceholder,
73260
- value: globalFilter,
73261
- onChange: (e) => setGlobalFilter(e.target.value),
73262
- className: "pl-8 w-64"
73197
+ side: "right",
73198
+ align: "start",
73199
+ sideOffset: 10,
73200
+ className: cn(
73201
+ "p-2",
73202
+ glassmorphism && "bg-background/95 backdrop-blur-sm"
73203
+ ),
73204
+ children: /* @__PURE__ */ jsx("div", { className: "space-y-0.5", children: childItem.items?.map((grandChild) => {
73205
+ const isGrandChildActive = grandChild.href === activePath;
73206
+ return /* @__PURE__ */ jsxs(
73207
+ "button",
73208
+ {
73209
+ onClick: () => handleItemClick(grandChild),
73210
+ disabled: grandChild.disabled,
73211
+ className: cn(
73212
+ "w-full flex items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors",
73213
+ "hover:bg-accent hover:text-accent-foreground",
73214
+ isGrandChildActive && "bg-primary/10 text-primary font-medium",
73215
+ grandChild.disabled && "opacity-50 cursor-not-allowed"
73216
+ ),
73217
+ children: [
73218
+ grandChild.icon && /* @__PURE__ */ jsx("span", { className: "flex-shrink-0", children: grandChild.icon }),
73219
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: grandChild.title }),
73220
+ grandChild.badge && /* @__PURE__ */ jsx(
73221
+ MoonUIBadgePro,
73222
+ {
73223
+ variant: grandChild.badgeVariant || "secondary",
73224
+ className: "ml-auto flex-shrink-0 text-[10px] px-1.5 py-0 h-5",
73225
+ children: grandChild.badge
73226
+ }
73227
+ )
73228
+ ]
73229
+ },
73230
+ grandChild.id
73231
+ );
73232
+ }) })
73263
73233
  }
73264
73234
  )
73265
- ] }),
73266
- filterable && /* @__PURE__ */ jsxs(
73267
- MoonUIButtonPro,
73235
+ ] }) : /* @__PURE__ */ jsxs(
73236
+ "button",
73268
73237
  {
73269
- variant: "outline",
73270
- size: "sm",
73271
- onClick: () => setFilterDrawerOpen(true),
73238
+ onClick: () => handleItemClick(childItem),
73239
+ disabled: childItem.disabled,
73240
+ className: cn(
73241
+ "w-full flex items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors",
73242
+ "hover:bg-accent hover:text-accent-foreground",
73243
+ isChildActive && "bg-primary/10 text-primary font-medium",
73244
+ childItem.disabled && "opacity-50 cursor-not-allowed"
73245
+ ),
73272
73246
  children: [
73273
- /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Filter, { className: "mr-2 h-4 w-4" }) }),
73274
- "Filters",
73275
- columnFilters.length > 0 && /* @__PURE__ */ jsx("span", { className: "ml-2 rounded-full bg-primary px-2 py-0.5 text-xs text-primary-foreground", children: columnFilters.length })
73247
+ childItem.icon && /* @__PURE__ */ jsx("span", { className: "flex-shrink-0", children: childItem.icon }),
73248
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: childItem.title }),
73249
+ childItem.badge && /* @__PURE__ */ jsx(
73250
+ MoonUIBadgePro,
73251
+ {
73252
+ variant: childItem.badgeVariant || "secondary",
73253
+ className: "ml-auto flex-shrink-0 text-[10px] px-1.5 py-0 h-5",
73254
+ children: childItem.badge
73255
+ }
73256
+ )
73276
73257
  ]
73277
73258
  }
73259
+ ) }, childItem.id);
73260
+ }) })
73261
+ ] });
73262
+ }, [activePath, glassmorphism, handleItemClick]);
73263
+ const renderItem = useCallback((item, depth = 0, filteredChildren) => {
73264
+ const isActive2 = item.href === activePath;
73265
+ const isPinned = pinnedItems.includes(item.id);
73266
+ const hasChildren = item.items && item.items.length > 0;
73267
+ const isExpanded = expandedSections.includes(item.id);
73268
+ const shouldShowHoverMenu = collapsed && !isMobile && depth === 0 && (hasChildren || item.title);
73269
+ const shouldShowTooltip = item.tooltip && !collapsed && !shouldShowHoverMenu;
73270
+ const itemContent = /* @__PURE__ */ jsxs(
73271
+ "button",
73272
+ {
73273
+ onClick: () => {
73274
+ if (hasChildren) {
73275
+ toggleSection(item.id);
73276
+ } else {
73277
+ handleItemClick(item);
73278
+ }
73279
+ },
73280
+ className: cn(
73281
+ "flex items-center gap-3 rounded-lg px-3 py-2 text-sm transition-all",
73282
+ fullWidthItems ? "w-[calc(100%-1.5rem)] mx-3" : "w-full",
73283
+ "hover:bg-accent hover:text-accent-foreground",
73284
+ isActive2 && "bg-primary/10 text-primary font-medium",
73285
+ item.disabled && "opacity-50 cursor-not-allowed",
73286
+ depth > 0 && "ml-6 text-xs",
73287
+ collapsed && depth === 0 && "justify-center px-2",
73288
+ customStyles?.hover
73278
73289
  ),
73279
- selectable && bulkActions.length > 0 && /* @__PURE__ */ jsx(
73280
- DataTableBulkActions,
73290
+ disabled: item.disabled,
73291
+ children: [
73292
+ item.icon && /* @__PURE__ */ jsx("span", { className: cn(
73293
+ "flex-shrink-0",
73294
+ collapsed && depth === 0 && "mx-auto"
73295
+ ), children: item.icon }),
73296
+ (!collapsed || depth > 0) && /* @__PURE__ */ jsxs(Fragment, { children: [
73297
+ /* @__PURE__ */ jsx("span", { className: "flex-1 text-left truncate", children: item.title }),
73298
+ item.badge && /* @__PURE__ */ jsx(
73299
+ MoonUIBadgePro,
73300
+ {
73301
+ variant: item.badgeVariant || "secondary",
73302
+ className: "ml-auto flex-shrink-0 text-[10px] px-1.5 py-0 h-5",
73303
+ children: item.badge
73304
+ }
73305
+ ),
73306
+ hasChildren && depth === 0 && /* @__PURE__ */ jsx(
73307
+ ChevronDown,
73308
+ {
73309
+ className: cn(
73310
+ "h-4 w-4 flex-shrink-0 transition-transform",
73311
+ isExpanded && "rotate-180"
73312
+ )
73313
+ }
73314
+ ),
73315
+ isPinned && /* @__PURE__ */ jsx(Pin, { className: "h-3 w-3 flex-shrink-0" })
73316
+ ] })
73317
+ ]
73318
+ }
73319
+ );
73320
+ if (shouldShowHoverMenu) {
73321
+ return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(HoverCard2, { openDelay: 200, closeDelay: 100, children: [
73322
+ /* @__PURE__ */ jsx(HoverCardTrigger2, { asChild: true, children: itemContent }),
73323
+ /* @__PURE__ */ jsx(
73324
+ HoverCardContent2,
73281
73325
  {
73282
- selectedRows: table.getFilteredSelectedRowModel().rows.map((row) => row.original),
73283
- actions: bulkActions,
73284
- onClearSelection: clearRowSelection
73326
+ side: "right",
73327
+ align: "start",
73328
+ sideOffset: 10,
73329
+ className: cn(
73330
+ "p-0 w-auto",
73331
+ glassmorphism && "bg-background/95 backdrop-blur-sm",
73332
+ "animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95"
73333
+ ),
73334
+ children: /* @__PURE__ */ jsx(
73335
+ motion.div,
73336
+ {
73337
+ initial: { opacity: 0, x: -10 },
73338
+ animate: { opacity: 1, x: 0 },
73339
+ exit: { opacity: 0, x: -10 },
73340
+ transition: { duration: 0.15 },
73341
+ children: renderCollapsedHoverContent(item)
73342
+ }
73343
+ )
73285
73344
  }
73286
73345
  )
73346
+ ] }) }, item.id);
73347
+ }
73348
+ return /* @__PURE__ */ jsxs("div", { children: [
73349
+ shouldShowTooltip ? /* @__PURE__ */ jsx(MoonUITooltipProviderPro, { children: /* @__PURE__ */ jsxs(MoonUITooltipPro, { children: [
73350
+ /* @__PURE__ */ jsx(MoonUITooltipTriggerPro, { asChild: true, children: itemContent }),
73351
+ /* @__PURE__ */ jsx(MoonUITooltipContentPro, { side: "right", children: /* @__PURE__ */ jsx("p", { children: item.tooltip }) })
73352
+ ] }) }) : itemContent,
73353
+ hasChildren && !collapsed && filteredChildren && /* @__PURE__ */ jsx(AnimatePresence, { children: isExpanded && /* @__PURE__ */ jsx(
73354
+ motion.div,
73355
+ {
73356
+ initial: { height: 0, opacity: 0 },
73357
+ animate: { height: "auto", opacity: 1 },
73358
+ exit: { height: 0, opacity: 0 },
73359
+ transition: { duration: 0.2 },
73360
+ className: "overflow-hidden",
73361
+ children: /* @__PURE__ */ jsx("div", { className: "pt-1 space-y-1", children: filteredChildren.map(
73362
+ (child) => renderItem(child, depth + 1)
73363
+ ) })
73364
+ }
73365
+ ) })
73366
+ ] }, item.id);
73367
+ }, [activePath, pinnedItems, expandedSections, collapsed, customStyles, handleItemClick, toggleSection, isMobile, glassmorphism, renderCollapsedHoverContent, fullWidthItems]);
73368
+ const SidebarHeader = t__default.memo(() => {
73369
+ return /* @__PURE__ */ jsxs("div", { className: cn(
73370
+ "flex items-center gap-3 p-4 border-b",
73371
+ collapsed && !isMobile && "justify-center px-2"
73372
+ ), children: [
73373
+ branding && /* @__PURE__ */ jsxs(Fragment, { children: [
73374
+ branding.logo,
73375
+ (!collapsed || isMobile) && branding.title && /* @__PURE__ */ jsx("span", { className: "font-semibold text-lg", children: branding.title })
73287
73376
  ] }),
73288
- /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
73289
- exportable && exportFormats.length > 0 && /* @__PURE__ */ jsxs(MoonUIDropdownMenuPro, { children: [
73290
- /* @__PURE__ */ jsx(MoonUIDropdownMenuTriggerPro, { asChild: true, children: /* @__PURE__ */ jsxs(MoonUIButtonPro, { variant: "outline", size: "sm", children: [
73291
- /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Download, { className: "mr-2 h-4 w-4" }) }),
73292
- "Export"
73377
+ isMobile && /* @__PURE__ */ jsx(
73378
+ MoonUIButtonPro,
73379
+ {
73380
+ variant: "ghost",
73381
+ size: "sm",
73382
+ className: "ml-auto h-8 w-8 p-0",
73383
+ onClick: () => setIsOpen(false),
73384
+ children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
73385
+ }
73386
+ ),
73387
+ !isMobile && collapsible && /* @__PURE__ */ jsx(
73388
+ MoonUIButtonPro,
73389
+ {
73390
+ variant: "ghost",
73391
+ size: "sm",
73392
+ className: cn(
73393
+ "h-8 w-8 p-0",
73394
+ !collapsed && "ml-auto"
73395
+ ),
73396
+ onClick: () => setCollapsed(!collapsed),
73397
+ children: collapsed ? /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" })
73398
+ }
73399
+ )
73400
+ ] });
73401
+ });
73402
+ const SidebarMenuContent = t__default.memo(() => {
73403
+ return /* @__PURE__ */ jsx(ScrollArea, { className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "p-4 space-y-6", children: [
73404
+ pinnedItems.length > 0 && (!collapsed || isMobile) && /* @__PURE__ */ jsxs("div", { children: [
73405
+ /* @__PURE__ */ jsx("h4", { className: "text-xs font-medium text-muted-foreground mb-2", children: "Pinned" }),
73406
+ /* @__PURE__ */ jsx("div", { className: "space-y-1", children: sections.flatMap(
73407
+ (section) => section.items.filter((item) => pinnedItems.includes(item.id))
73408
+ ).map((item) => renderItem(item)) }),
73409
+ /* @__PURE__ */ jsx(MoonUISeparatorPro, { className: "mt-4" })
73410
+ ] }),
73411
+ filteredSections.map((section, index2) => /* @__PURE__ */ jsxs("div", { children: [
73412
+ section.title && (!collapsed || isMobile) && /* @__PURE__ */ jsx("h4", { className: "text-xs font-medium text-muted-foreground mb-2", children: section.title }),
73413
+ /* @__PURE__ */ jsx("div", { className: "space-y-1", children: section.filteredItems.map((item) => renderItem(item, 0, item.filteredChildren)) }),
73414
+ section.showDivider && index2 < filteredSections.length - 1 && /* @__PURE__ */ jsx(MoonUISeparatorPro, { className: "mt-4" })
73415
+ ] }, section.id))
73416
+ ] }) });
73417
+ });
73418
+ const SidebarFooter = t__default.memo(() => {
73419
+ return footer ? /* @__PURE__ */ jsxs("div", { className: "border-t p-4", children: [
73420
+ /* @__PURE__ */ jsx("div", { className: "space-y-1", children: footer.items.map((item) => renderItem(item)) }),
73421
+ showThemeToggle && (!collapsed || isMobile) && /* @__PURE__ */ jsxs("div", { className: "mt-3 flex items-center justify-between", children: [
73422
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Theme" }),
73423
+ /* @__PURE__ */ jsxs(MoonUIDropdownMenuPro, { children: [
73424
+ /* @__PURE__ */ jsx(MoonUIDropdownMenuTriggerPro, { asChild: true, children: /* @__PURE__ */ jsxs(MoonUIButtonPro, { variant: "ghost", size: "sm", className: "h-7 px-2", children: [
73425
+ theme === "light" && /* @__PURE__ */ jsx(Sun, { className: "h-3 w-3" }),
73426
+ theme === "dark" && /* @__PURE__ */ jsx(Moon, { className: "h-3 w-3" }),
73427
+ theme === "system" && /* @__PURE__ */ jsx(Monitor, { className: "h-3 w-3" })
73293
73428
  ] }) }),
73294
73429
  /* @__PURE__ */ jsxs(MoonUIDropdownMenuContentPro, { align: "end", children: [
73295
- exportFormats.includes("csv") && /* @__PURE__ */ jsxs(MoonUIDropdownMenuItemPro, { onClick: () => handleExport("csv"), children: [
73296
- /* @__PURE__ */ jsx(FileSpreadsheet, { className: "mr-2 h-4 w-4" }),
73297
- "Export as CSV"
73430
+ /* @__PURE__ */ jsxs(MoonUIDropdownMenuItemPro, { onClick: () => onThemeChange?.("light"), children: [
73431
+ /* @__PURE__ */ jsx(Sun, { className: "mr-2 h-4 w-4" }),
73432
+ "Light"
73298
73433
  ] }),
73299
- exportFormats.includes("json") && /* @__PURE__ */ jsxs(MoonUIDropdownMenuItemPro, { onClick: () => handleExport("json"), children: [
73300
- /* @__PURE__ */ jsx(FileJson, { className: "mr-2 h-4 w-4" }),
73301
- "Export as JSON"
73434
+ /* @__PURE__ */ jsxs(MoonUIDropdownMenuItemPro, { onClick: () => onThemeChange?.("dark"), children: [
73435
+ /* @__PURE__ */ jsx(Moon, { className: "mr-2 h-4 w-4" }),
73436
+ "Dark"
73302
73437
  ] }),
73303
- exportFormats.includes("xlsx") && /* @__PURE__ */ jsxs(MoonUIDropdownMenuItemPro, { onClick: () => handleExport("xlsx"), children: [
73304
- /* @__PURE__ */ jsx(FileDown, { className: "mr-2 h-4 w-4" }),
73305
- "Export as Excel"
73438
+ /* @__PURE__ */ jsxs(MoonUIDropdownMenuItemPro, { onClick: () => onThemeChange?.("system"), children: [
73439
+ /* @__PURE__ */ jsx(Monitor, { className: "mr-2 h-4 w-4" }),
73440
+ "System"
73306
73441
  ] })
73307
73442
  ] })
73308
- ] }),
73309
- /* @__PURE__ */ jsx(DataTableColumnToggle, { table })
73443
+ ] })
73310
73444
  ] })
73311
- ] }),
73312
- /* @__PURE__ */ jsx("div", { className: "moonui-pro-datatable-wrapper rounded-md border overflow-hidden", style: { contain: "layout style" }, children: /* @__PURE__ */ jsx("div", { style: { overflowX: "auto" }, children: /* @__PURE__ */ jsxs("table", { className: "moonui-pro-datatable", style: { width: "100%", tableLayout: "auto" }, children: [
73313
- /* @__PURE__ */ jsx("thead", { className: "moonui-data-table-header", children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx("tr", { className: "moonui-data-table-row border-b", children: headerGroup.headers.filter((header) => header.column.getIsVisible()).map((header) => /* @__PURE__ */ jsx(
73314
- "th",
73445
+ ] }) : null;
73446
+ });
73447
+ const SidebarContent = t__default.memo(() => {
73448
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
73449
+ /* @__PURE__ */ jsx(SidebarMenuContent, {}),
73450
+ /* @__PURE__ */ jsx(SidebarFooter, {})
73451
+ ] });
73452
+ });
73453
+ const sidebarClasses = cn(
73454
+ "moonui-pro flex h-full flex-col bg-background border-r",
73455
+ glassmorphism && "bg-background/80 backdrop-blur-xl border-white/10",
73456
+ collapsed && !isMobile && "w-16",
73457
+ !collapsed && !isMobile && "w-64",
73458
+ customStyles?.background,
73459
+ customStyles?.border,
73460
+ className
73461
+ );
73462
+ if (isMobile) {
73463
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
73464
+ floatingActionButton && /* @__PURE__ */ jsx(
73465
+ MoonUIButtonPro,
73315
73466
  {
73316
- className: "moonui-data-table-th h-12 px-4 text-left align-middle font-medium text-muted-foreground",
73317
- children: header.isPlaceholder ? null : /* @__PURE__ */ jsxs(
73318
- "div",
73319
- {
73320
- className: cn(
73321
- "flex items-center space-x-2",
73322
- header.column.getCanSort() && "cursor-pointer select-none"
73323
- ),
73324
- onClick: header.column.getToggleSortingHandler(),
73325
- children: [
73326
- flexRender(header.column.columnDef.header, header.getContext()),
73327
- header.column.getCanSort() && /* @__PURE__ */ jsx("div", { className: "ml-2", children: header.column.getIsSorted() === "asc" ? /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ArrowUp, { className: "h-4 w-4" }) }) : header.column.getIsSorted() === "desc" ? /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ArrowDown, { className: "h-4 w-4" }) }) : /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ArrowUpDown, { className: "h-4 w-4" }) }) })
73328
- ]
73467
+ onClick: () => setIsOpen(true),
73468
+ className: cn(
73469
+ "fixed z-40 h-12 w-12 rounded-full shadow-lg md:hidden",
73470
+ floatingActionButtonClassName
73471
+ ),
73472
+ size: "icon",
73473
+ style: {
73474
+ bottom: floatingActionButtonPosition?.bottom,
73475
+ left: floatingActionButtonPosition?.left,
73476
+ right: floatingActionButtonPosition?.right,
73477
+ top: floatingActionButtonPosition?.top
73478
+ },
73479
+ children: /* @__PURE__ */ jsx(Menu, { className: "h-5 w-5" })
73480
+ }
73481
+ ),
73482
+ /* @__PURE__ */ jsx(Sheet, { open: isOpen, onOpenChange: setIsOpen, children: /* @__PURE__ */ jsx(SheetContent, { side: "left", className: "w-80 p-0", children: /* @__PURE__ */ jsxs("div", { className: cn(sidebarClasses, "sidebar-container flex flex-col"), children: [
73483
+ animatedBackground && /* @__PURE__ */ jsx(
73484
+ motion.div,
73485
+ {
73486
+ className: "absolute inset-0 opacity-30",
73487
+ style: {
73488
+ background: `radial-gradient(circle at ${springX}px ${springY}px, rgba(var(--primary-rgb), 0.15), transparent 50%)`
73329
73489
  }
73330
- )
73331
- },
73332
- header.id
73333
- )) }, headerGroup.id)) }),
73334
- /* @__PURE__ */ jsx("tbody", { className: "moonui-data-table-body", children: isPaginationLoading ? /* @__PURE__ */ jsx(
73335
- motion.tr,
73336
- {
73337
- initial: { opacity: 0 },
73338
- animate: { opacity: 1 },
73339
- exit: { opacity: 0 },
73340
- transition: { duration: 0.2 },
73341
- children: /* @__PURE__ */ jsx("td", { colSpan: table.getAllLeafColumns().filter((col) => col.getIsVisible()).length, className: "h-24 text-center", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center space-x-2", children: [
73342
- /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) }),
73343
- /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: "Loading..." })
73344
- ] }) })
73345
- },
73346
- "loading"
73347
- ) : rows?.length ? /* @__PURE__ */ jsx(Fragment, { children: rows.map((row, index2) => {
73348
- const rowId = row.original.id || row.id;
73349
- const isExpanded = enableExpandable && expandedRows.has(rowId);
73350
- return /* @__PURE__ */ jsx(
73351
- TableRow2,
73490
+ }
73491
+ ),
73492
+ /* @__PURE__ */ jsx(SidebarHeader, {}),
73493
+ showSearch && (!collapsed || isMobile) && /* @__PURE__ */ jsx(
73494
+ SearchInput,
73352
73495
  {
73353
- row,
73354
- columns,
73355
- isExpanded,
73356
- enableExpandable,
73357
- renderSubComponent,
73358
- visibilityState: table.getState().columnVisibility
73496
+ searchInputRef,
73497
+ searchPlaceholder,
73498
+ initialValue: currentSearchQuery,
73499
+ onSearchChange: handleSearch,
73500
+ keyboardShortcuts
73359
73501
  },
73360
- rowId
73361
- );
73362
- }) }) : /* @__PURE__ */ jsx(
73363
- motion.tr,
73364
- {
73365
- initial: { opacity: 0 },
73366
- animate: { opacity: 1 },
73367
- exit: { opacity: 0 },
73368
- transition: { duration: 0.2 },
73369
- children: /* @__PURE__ */ jsx("td", { colSpan: table.getAllLeafColumns().filter((col) => col.getIsVisible()).length, className: "h-24 text-center", children: "No results found." })
73370
- },
73371
- "no-results"
73372
- ) })
73373
- ] }) }) }),
73374
- pagination && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-2", children: [
73375
- /* @__PURE__ */ jsx("div", { className: "flex-1 text-sm text-muted-foreground", children: selectable && table.getFilteredSelectedRowModel().rows.length > 0 && /* @__PURE__ */ jsxs("span", { children: [
73376
- table.getFilteredSelectedRowModel().rows.length,
73377
- " of",
73378
- " ",
73379
- table.getFilteredRowModel().rows.length,
73380
- " row(s) selected."
73381
- ] }) }),
73382
- /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-6 lg:space-x-8", children: [
73383
- /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
73384
- /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: "Rows per page" }),
73385
- /* @__PURE__ */ jsx(
73386
- "select",
73387
- {
73388
- value: table.getState().pagination.pageSize,
73389
- onChange: async (e) => {
73390
- setIsPaginationLoading(true);
73391
- await new Promise((resolve) => setTimeout(resolve, 300));
73392
- table.setPageSize(Number(e.target.value));
73393
- setIsPaginationLoading(false);
73394
- },
73395
- className: "h-8 w-[70px] rounded border border-input bg-background px-3 py-1 text-sm",
73396
- disabled: isPaginationLoading,
73397
- children: [10, 20, 30, 40, 50].map((pageSize2) => /* @__PURE__ */ jsx("option", { value: pageSize2, children: pageSize2 }, pageSize2))
73398
- }
73399
- )
73400
- ] }),
73401
- /* @__PURE__ */ jsxs("div", { className: "flex w-[100px] items-center justify-center text-sm font-medium", children: [
73402
- "Page ",
73403
- table.getState().pagination.pageIndex + 1,
73404
- " of",
73405
- " ",
73406
- table.getPageCount()
73407
- ] }),
73408
- /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
73409
- /* @__PURE__ */ jsx(
73410
- MoonUIButtonPro,
73411
- {
73412
- variant: "outline",
73413
- className: "hidden h-8 w-8 p-0 lg:flex",
73414
- onClick: async () => {
73415
- if (onPaginationChange) {
73416
- onPaginationChange({ pageIndex: 0, pageSize: table.getState().pagination.pageSize });
73417
- } else {
73418
- setIsPaginationLoading(true);
73419
- await new Promise((resolve) => setTimeout(resolve, 300));
73420
- table.setPageIndex(0);
73421
- setIsPaginationLoading(false);
73422
- }
73423
- },
73424
- disabled: !table.getCanPreviousPage() || isPaginationLoading,
73425
- children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronsLeft, { className: "h-4 w-4" }) })
73426
- }
73427
- ),
73428
- /* @__PURE__ */ jsx(
73429
- MoonUIButtonPro,
73430
- {
73431
- variant: "outline",
73432
- className: "h-8 w-8 p-0",
73433
- onClick: async () => {
73434
- if (onPaginationChange) {
73435
- const currentIndex = table.getState().pagination.pageIndex;
73436
- onPaginationChange({ pageIndex: currentIndex - 1, pageSize: table.getState().pagination.pageSize });
73437
- } else {
73438
- setIsPaginationLoading(true);
73439
- await new Promise((resolve) => setTimeout(resolve, 300));
73440
- table.previousPage();
73441
- setIsPaginationLoading(false);
73442
- }
73443
- },
73444
- disabled: !table.getCanPreviousPage() || isPaginationLoading,
73445
- children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" }) })
73446
- }
73447
- ),
73448
- /* @__PURE__ */ jsx(
73449
- MoonUIButtonPro,
73450
- {
73451
- variant: "outline",
73452
- className: "h-8 w-8 p-0",
73453
- onClick: async () => {
73454
- setIsPaginationLoading(true);
73455
- await new Promise((resolve) => setTimeout(resolve, 300));
73456
- table.nextPage();
73457
- setIsPaginationLoading(false);
73458
- },
73459
- disabled: !table.getCanNextPage() || isPaginationLoading,
73460
- children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" }) })
73461
- }
73462
- ),
73463
- /* @__PURE__ */ jsx(
73464
- MoonUIButtonPro,
73465
- {
73466
- variant: "outline",
73467
- className: "hidden h-8 w-8 p-0 lg:flex",
73468
- onClick: async () => {
73469
- setIsPaginationLoading(true);
73470
- await new Promise((resolve) => setTimeout(resolve, 300));
73471
- table.setPageIndex(table.getPageCount() - 1);
73472
- setIsPaginationLoading(false);
73473
- },
73474
- disabled: !table.getCanNextPage() || isPaginationLoading,
73475
- children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronsRight, { className: "h-4 w-4" }) })
73476
- }
73477
- )
73478
- ] })
73479
- ] })
73480
- ] }),
73481
- filterable && /* @__PURE__ */ jsx(
73482
- DataTableFilterDrawer,
73502
+ "sidebar-search-mobile"
73503
+ ),
73504
+ /* @__PURE__ */ jsx(SidebarContent, {})
73505
+ ] }) }) })
73506
+ ] });
73507
+ }
73508
+ return /* @__PURE__ */ jsxs("aside", { className: cn(sidebarClasses, "sidebar-container hidden md:flex flex-col"), children: [
73509
+ animatedBackground && /* @__PURE__ */ jsx(
73510
+ motion.div,
73483
73511
  {
73484
- table,
73485
- open: filterDrawerOpen,
73486
- onOpenChange: setFilterDrawerOpen
73487
- }
73488
- )
73489
- ] });
73490
- }
73491
- function getExpandableColumn(expandedRows, onToggle) {
73492
- return {
73493
- id: "expander",
73494
- header: () => null,
73495
- size: 50,
73496
- cell: ({ row }) => {
73497
- const rowId = row.original.id || row.id;
73498
- const isExpanded = expandedRows.has(rowId);
73499
- return /* @__PURE__ */ jsx(
73500
- "button",
73501
- {
73502
- onClick: (e) => {
73503
- e.stopPropagation();
73504
- onToggle(rowId);
73505
- },
73506
- className: "p-2 hover:bg-muted rounded-md transition-colors",
73507
- "aria-label": isExpanded ? "Collapse row" : "Expand row",
73508
- children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: isExpanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 text-muted-foreground" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 text-muted-foreground" }) })
73512
+ className: "absolute inset-0 opacity-30",
73513
+ style: {
73514
+ background: `radial-gradient(circle at ${springX}px ${springY}px, rgba(var(--primary-rgb), 0.15), transparent 50%)`
73509
73515
  }
73510
- );
73511
- }
73512
- };
73513
- }
73514
- function useExpandableRows(initialExpanded = /* @__PURE__ */ new Set()) {
73515
- const [expandedRows, setExpandedRows] = t__default.useState(initialExpanded);
73516
- const toggleRow = t__default.useCallback((id) => {
73517
- setExpandedRows((prev) => {
73518
- const newExpanded = new Set(prev);
73519
- if (newExpanded.has(id)) {
73520
- newExpanded.delete(id);
73521
- } else {
73522
- newExpanded.add(id);
73523
- }
73524
- return newExpanded;
73525
- });
73526
- }, []);
73527
- const expandAll = t__default.useCallback((rowIds) => {
73528
- setExpandedRows(new Set(rowIds));
73529
- }, []);
73530
- const collapseAll = t__default.useCallback(() => {
73531
- setExpandedRows(/* @__PURE__ */ new Set());
73532
- }, []);
73533
- return {
73534
- expandedRows,
73535
- setExpandedRows,
73536
- toggleRow,
73537
- expandAll,
73538
- collapseAll
73539
- };
73540
- }
73541
- var TableRow2 = t__default.memo(({
73542
- row,
73543
- columns,
73544
- isExpanded,
73545
- enableExpandable,
73546
- renderSubComponent,
73547
- visibilityState
73548
- }) => {
73549
- const rowId = row.original.id || row.id;
73550
- return /* @__PURE__ */ jsxs(Fragment, { children: [
73551
- /* @__PURE__ */ jsx(
73552
- "tr",
73553
- {
73554
- className: cn(
73555
- "border-b transition-colors hover:bg-muted/50",
73556
- row.getIsSelected() && "bg-muted",
73557
- isExpanded && "border-b-0"
73558
- ),
73559
- children: row.getAllCells().filter((cell) => {
73560
- const isVisible = visibilityState[cell.column.id] !== false;
73561
- return isVisible;
73562
- }).map((cell) => {
73563
- return /* @__PURE__ */ jsx("td", { className: "moonui-data-table-td p-4 align-middle", children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id);
73564
- })
73565
73516
  }
73566
73517
  ),
73567
- isExpanded && renderSubComponent && /* @__PURE__ */ jsx("tr", { className: "border-b", children: /* @__PURE__ */ jsx("td", { colSpan: row.getAllCells().filter(
73568
- (cell) => visibilityState[cell.column.id] !== false
73569
- ).length || 1, className: "p-0 overflow-hidden", children: /* @__PURE__ */ jsx(
73570
- "div",
73518
+ /* @__PURE__ */ jsx(SidebarHeader, {}),
73519
+ showSearch && (!collapsed || isMobile) && /* @__PURE__ */ jsx(
73520
+ SearchInput,
73571
73521
  {
73572
- className: "transition-all duration-300 ease-out",
73573
- style: {
73574
- maxHeight: isExpanded ? "1000px" : "0",
73575
- opacity: isExpanded ? 1 : 0
73576
- },
73577
- children: /* @__PURE__ */ jsx("div", { className: "border-t border-border/50", children: renderSubComponent({ row: { original: row.original, id: rowId } }) })
73578
- }
73579
- ) }) })
73522
+ searchInputRef,
73523
+ searchPlaceholder,
73524
+ initialValue: currentSearchQuery,
73525
+ onSearchChange: handleSearch,
73526
+ keyboardShortcuts
73527
+ },
73528
+ "sidebar-search-desktop"
73529
+ ),
73530
+ /* @__PURE__ */ jsx(SidebarContent, {})
73580
73531
  ] });
73581
- }, (prevProps, nextProps) => {
73582
- const prevRowId = prevProps.row.original.id || prevProps.row.id;
73583
- const nextRowId = nextProps.row.original.id || nextProps.row.id;
73584
- const prevVisibilityKeys = Object.keys(prevProps.visibilityState).sort().join(",");
73585
- const nextVisibilityKeys = Object.keys(nextProps.visibilityState).sort().join(",");
73586
- const prevVisibilityValues = Object.values(prevProps.visibilityState).join(",");
73587
- const nextVisibilityValues = Object.values(nextProps.visibilityState).join(",");
73588
- return prevRowId === nextRowId && prevProps.isExpanded === nextProps.isExpanded && prevProps.row.getIsSelected() === nextProps.row.getIsSelected() && prevVisibilityKeys === nextVisibilityKeys && prevVisibilityValues === nextVisibilityValues;
73589
- });
73590
- TableRow2.displayName = "TableRow";
73591
- var MoonUIDataTablePro = DataTable;
73532
+ }
73533
+ function Sidebar(props) {
73534
+ const { hasProAccess, isLoading } = useSubscription();
73535
+ if (!isLoading && !hasProAccess) {
73536
+ return /* @__PURE__ */ jsx(MoonUICardPro, { className: cn("w-full max-w-xs", props.className), children: /* @__PURE__ */ jsx(MoonUICardContentPro, { className: "py-12 text-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
73537
+ /* @__PURE__ */ jsx("div", { className: "rounded-full bg-purple-100 dark:bg-purple-900/30 p-3 w-fit mx-auto", children: /* @__PURE__ */ jsx(Lock, { className: "h-6 w-6 text-purple-600 dark:text-purple-400" }) }),
73538
+ /* @__PURE__ */ jsxs("div", { children: [
73539
+ /* @__PURE__ */ jsx("h3", { className: "font-semibold text-lg mb-2", children: "Pro Feature" }),
73540
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm mb-4", children: "Advanced Sidebar is available exclusively to MoonUI Pro subscribers." }),
73541
+ /* @__PURE__ */ jsx("a", { href: "/pricing", children: /* @__PURE__ */ jsxs(MoonUIButtonPro, { size: "sm", children: [
73542
+ /* @__PURE__ */ jsx(Sparkles, { className: "mr-2 h-4 w-4" }),
73543
+ "Upgrade to Pro"
73544
+ ] }) })
73545
+ ] })
73546
+ ] }) }) });
73547
+ }
73548
+ return /* @__PURE__ */ jsx(SidebarInternal, { ...props });
73549
+ }
73550
+ var MoonUISidebarPro = Sidebar;
73592
73551
  function NavbarInternal({
73593
73552
  sections,
73594
73553
  branding,