@motiadev/workbench 0.0.29 → 0.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.html +1 -1
  3. package/dist/src/components/app-sidebar.js +2 -2
  4. package/dist/src/components/logs/log-console.js +1 -1
  5. package/dist/src/components/logs/log-detail.js +1 -1
  6. package/dist/src/components/logs/log-field.js +7 -3
  7. package/dist/src/components/logs/logs.js +1 -1
  8. package/dist/src/components/states/state-detail.js +2 -4
  9. package/dist/src/components/states/state-value.d.ts +8 -0
  10. package/dist/src/components/states/state-value.js +51 -0
  11. package/dist/src/components/states/states.js +1 -1
  12. package/dist/src/components/ui/badge.js +2 -2
  13. package/dist/src/components/ui/button.d.ts +1 -1
  14. package/dist/src/components/ui/sidebar.d.ts +11 -55
  15. package/dist/src/components/ui/sidebar.js +14 -220
  16. package/dist/src/components/ui/table.js +1 -1
  17. package/dist/src/hooks/use-debounced.d.ts +1 -0
  18. package/dist/src/hooks/use-debounced.js +20 -0
  19. package/dist/src/index.css +17 -4
  20. package/dist/src/publicComponents/api-node.d.ts +2 -4
  21. package/dist/src/publicComponents/api-node.js +3 -3
  22. package/dist/src/publicComponents/base-handle.d.ts +1 -0
  23. package/dist/src/publicComponents/base-handle.js +5 -2
  24. package/dist/src/publicComponents/base-node.d.ts +3 -2
  25. package/dist/src/publicComponents/base-node.js +13 -9
  26. package/dist/src/publicComponents/colorMap.d.ts +6 -0
  27. package/dist/src/publicComponents/colorMap.js +6 -0
  28. package/dist/src/publicComponents/components/header-bar.d.ts +11 -0
  29. package/dist/src/publicComponents/components/header-bar.js +15 -0
  30. package/dist/src/publicComponents/cron-node.js +2 -2
  31. package/dist/src/publicComponents/emits.js +2 -2
  32. package/dist/src/publicComponents/event-node.d.ts +0 -1
  33. package/dist/src/publicComponents/event-node.js +3 -5
  34. package/dist/src/publicComponents/node-details.d.ts +17 -0
  35. package/dist/src/publicComponents/node-details.js +19 -0
  36. package/dist/src/publicComponents/subscribe.d.ts +1 -2
  37. package/dist/src/publicComponents/subscribe.js +2 -2
  38. package/dist/src/route-wrapper.js +2 -2
  39. package/dist/src/routes/flow.js +8 -4
  40. package/dist/src/routes/index.js +3 -2
  41. package/dist/src/views/flow/base-edge.js +3 -3
  42. package/dist/src/views/flow/flow-view.d.ts +7 -2
  43. package/dist/src/views/flow/flow-view.js +18 -5
  44. package/dist/src/views/flow/hooks/use-get-flow-state.d.ts +7 -3
  45. package/dist/src/views/flow/hooks/use-get-flow-state.js +9 -5
  46. package/dist/src/views/flow/hooks/use-save-workflow-config.d.ts +3 -0
  47. package/dist/src/views/flow/hooks/use-save-workflow-config.js +23 -0
  48. package/dist/src/views/flow/legend.js +46 -46
  49. package/dist/src/views/flow/node-organizer.js +3 -1
  50. package/dist/src/views/flow/nodes/language-indicator.js +7 -7
  51. package/dist/src/views/flow/nodes/nodes.types.d.ts +21 -7
  52. package/dist/tsconfig.app.tsbuildinfo +1 -1
  53. package/dist/tsconfig.node.tsbuildinfo +1 -1
  54. package/package.json +1 -1
  55. package/dist/src/components/states/state-field.d.ts +0 -8
  56. package/dist/src/components/states/state-field.js +0 -16
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Motia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
7
7
  <link
8
- href="https://fonts.googleapis.com/css2?family=PT+Sans:wght@0,200..1000;1,200..1000&display=swap&family=PT+Mono:wght@0,200..1000;1,200..1000&display=swap"
8
+ href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
9
9
  rel="stylesheet"
10
10
  />
11
11
 
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useListFlows } from '@/hooks/use-list-flows';
3
3
  import { File, Logs, Workflow } from 'lucide-react';
4
4
  import { Link, useLocation } from 'react-router';
5
- import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem, } from './ui/sidebar';
5
+ import { Sidebar, SidebarButton, SidebarGroup } from './ui/sidebar';
6
6
  import { Badge } from './ui/badge';
7
7
  import { useLogs } from '../stores/use-logs';
8
8
  export const AppSidebar = () => {
@@ -10,5 +10,5 @@ export const AppSidebar = () => {
10
10
  const { pathname } = useLocation();
11
11
  const isActive = (flowId) => pathname.includes(`/flow/${flowId}`);
12
12
  const unreadLogsCount = useLogs((state) => state.unreadLogsCount);
13
- return (_jsxs(Sidebar, { children: [_jsx(SidebarHeader, {}), _jsx(SidebarContent, { children: _jsxs(SidebarGroup, { children: [_jsx(SidebarGroupLabel, { children: "Motia" }), _jsx(SidebarGroupContent, { children: _jsxs(SidebarMenu, { children: [_jsx(SidebarMenuItem, { children: _jsx(SidebarMenuButton, { asChild: true, className: "cursor-pointer", isActive: pathname === '/logs', children: _jsxs(Link, { to: "/logs", children: [_jsx(Logs, {}), "Logs", pathname !== '/logs' && unreadLogsCount > 0 && (_jsx(Badge, { variant: "red-rounded", children: unreadLogsCount }))] }) }) }), _jsx(SidebarMenuItem, { children: _jsx(SidebarMenuButton, { asChild: true, className: "cursor-pointer", isActive: pathname === '/states', children: _jsxs(Link, { to: "/states", children: [_jsx(File, {}), "States"] }) }) })] }) }), _jsx(SidebarGroupLabel, { children: "Flows" }), _jsx(SidebarGroupContent, { children: _jsx(SidebarMenu, { children: flows.map((flow) => (_jsx(SidebarMenuItem, { children: _jsx(SidebarMenuButton, { asChild: true, className: "cursor-pointer", isActive: isActive(flow.id), children: _jsxs(Link, { to: `/flow/${flow.id}`, className: "flex items-center gap-2", "data-testid": `flow-link-${flow.id}`, children: [_jsx(Workflow, {}), _jsx("span", { children: flow.name })] }) }) }, flow.id))) }) })] }) }), _jsx(SidebarFooter, {})] }));
13
+ return (_jsxs(Sidebar, { children: [_jsxs(SidebarGroup, { title: "Motia", children: [_jsx(Link, { to: "/logs", children: _jsxs(SidebarButton, { isActive: pathname === '/logs', icon: _jsx(Logs, { className: "w-4 h-4" }), children: ["Logs", pathname !== '/logs' && unreadLogsCount > 0 && _jsx(Badge, { variant: "red-rounded", children: unreadLogsCount })] }) }), _jsx(Link, { to: "/states", children: _jsx(SidebarButton, { isActive: pathname === '/states', icon: _jsx(File, { className: "w-4 h-4" }), children: "States" }) })] }), _jsx(SidebarGroup, { title: "Flows", children: flows.map((flow) => (_jsx(Link, { to: `/flow/${flow.id}`, children: _jsx(SidebarButton, { isActive: isActive(flow.id), icon: _jsx(Workflow, { className: "w-4 h-4" }), children: flow.name }) }, flow.id))) })] }));
14
14
  };
@@ -41,5 +41,5 @@ export const LogConsole = () => {
41
41
  document.removeEventListener('mouseup', handleMouseUp);
42
42
  };
43
43
  }, [isDragging]);
44
- return (_jsxs("div", { className: "absolute bottom-0 left-0 right-0 w-full bg-zinc-900/90 border-t border-zinc-700", children: [_jsx("div", { ref: dragRef, onMouseDown: handleMouseDown, className: cn('absolute -top-1 left-0 right-0 h-1 cursor-ns-resize hover:bg-green-500/20', isDragging && 'bg-green-500/40') }), _jsxs("div", { className: "flex justify-between w-full items-center p-2", children: [_jsx("label", { className: "text-green-500 w-full text-left justify-start h-full text-lg font-bold", children: "Logs" }), logs.length > 0 && (_jsxs(Button, { variant: "link", onClick: resetLogs, className: "text-green-500", children: [_jsx(Trash2, { className: "w-4 h-4 text-green-500" }), "Clear logs"] })), _jsx(Button, { variant: "link", onClick: toggleExpand, className: "text-green-500", children: isExpanded ? _jsx(ChevronDown, { className: "w-4 h-4" }) : _jsx(ChevronUp, { className: "w-4 h-4" }) })] }), _jsx(AnimatePresence, { children: isExpanded && (_jsx(motion.div, { initial: { height: 0 }, animate: { height }, exit: { height: 0 }, transition: { duration: 0.2 }, className: "overflow-hidden", children: _jsx(Logs, {}) }, "log-content")) })] }));
44
+ return (_jsxs("div", { className: "absolute bottom-0 left-0 right-0 bg-background/80 border border-solid border-border m-4 rounded-lg", children: [_jsx("div", { ref: dragRef, onMouseDown: handleMouseDown, className: cn('absolute -top-1 left-0 right-0 h-1 cursor-ns-resize hover:bg-background/40', isDragging && 'bg-background/40') }), _jsxs("div", { className: "text-white/50 flex justify-between w-full items-center p-4 gap-2", children: [_jsx("label", { className: "w-full text-left justify-start h-full text-md uppercase", children: "Logs" }), logs.length > 0 && (_jsxs(Button, { variant: "outline", onClick: resetLogs, children: [_jsx(Trash2, { className: "w-4 h-4" }), "Clear logs"] })), _jsx(Button, { variant: "outline", onClick: toggleExpand, children: isExpanded ? _jsx(ChevronDown, { className: "w-4 h-4" }) : _jsx(ChevronUp, { className: "w-4 h-4" }) })] }), _jsx(AnimatePresence, { children: isExpanded && (_jsx(motion.div, { initial: { height: 0 }, animate: { height }, exit: { height: 0 }, transition: { duration: 0.2 }, className: "overflow-hidden", children: _jsx(Logs, {}) }, "log-content")) })] }));
45
45
  };
@@ -11,5 +11,5 @@ export const LogDetail = ({ log, onClose }) => {
11
11
  }
12
12
  };
13
13
  const otherProps = Object.keys(log ?? {}).filter((key) => !defaultProps.includes(key));
14
- return (_jsx(Sheet, { open: isOpen, onOpenChange: onOpenChange, children: _jsxs(SheetContent, { className: "flex flex-col h-full", children: [_jsxs(SheetHeader, { children: [_jsx(SheetTitle, { children: "Logs details" }), _jsx(SheetDescription, { children: "Log details and application." })] }), _jsx("div", { className: "font-mono overflow-y-auto", children: log && (_jsxs("div", { className: "flex flex-col gap-6 ", children: [_jsxs("div", { className: "flex flex-row gap-4", children: [_jsx("span", { className: "bg-gray-900 text-white p-4 rounded-lg flex items-center justify-center", children: _jsx(LogLevelBadge, { level: log.level, className: "text-xl" }) }), _jsx(LogField, { label: "Time", value: new Date(log.time).toLocaleTimeString(), className: "flex-1" })] }), _jsxs("div", { className: "flex flex-row gap-4", children: [_jsx(LogField, { label: "Step", value: log.step, className: "flex-1" }), _jsx(LogField, { label: "Flows", value: log.flows.join(', '), className: "flex-1" })] }), _jsx(LogField, { label: "Trace ID", value: log.traceId }), _jsx(LogField, { label: "Message", value: log.msg }), otherProps.map((key) => (_jsx(LogField, { label: key, value: log[key] }, key)))] })) })] }) }));
14
+ return (_jsx(Sheet, { open: isOpen, onOpenChange: onOpenChange, children: _jsxs(SheetContent, { className: "flex flex-col h-full", children: [_jsxs(SheetHeader, { children: [_jsx(SheetTitle, { children: "Logs details" }), _jsx(SheetDescription, { children: "Log details and application." })] }), _jsx("div", { className: "font-mono overflow-y-auto", children: log && (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("div", { className: "flex flex-row gap-2", children: [_jsx(LogField, { label: "Level", value: _jsx(LogLevelBadge, { level: log.level }), className: "flex-1" }), _jsx(LogField, { label: "Time", value: new Date(log.time).toLocaleString(), className: "flex-1" })] }), _jsxs("div", { className: "flex flex-row gap-2", children: [_jsx(LogField, { label: "Step", value: log.step, className: "flex-1" }), _jsx(LogField, { label: "Flows", value: log.flows.join(', '), className: "flex-1" })] }), _jsx(LogField, { label: "Trace ID", value: log.traceId }), _jsx(LogField, { label: "Message", value: log.msg }), otherProps.map((key) => (_jsx(LogField, { label: key, value: log[key] }, key)))] })) })] }) }));
15
15
  };
@@ -1,16 +1,20 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React from 'react';
3
3
  import { cn } from '../../lib/utils';
4
+ const Value = ({ value }) => {
5
+ const displayValue = typeof value === 'string' ? value : JSON.stringify(value);
6
+ return _jsx("div", { className: "text-gray-400 text-md", children: displayValue });
7
+ };
4
8
  const LogValue = ({ value }) => {
5
9
  if (React.isValidElement(value)) {
6
10
  return value;
7
11
  }
8
12
  if (typeof value === 'object') {
9
13
  const valueObject = value;
10
- return (_jsx("div", { className: "flex flex-col gap-2", children: Object.keys(valueObject).map((key) => (_jsxs("div", { className: "ml-8 flex flex-col", children: [_jsx("span", { className: "text-gray-400 text-xs font-bold", children: key }), _jsx("span", { className: "text-large font-bold", children: value ? (_jsx(LogValue, { value: valueObject[key] })) : (JSON.stringify(valueObject[key])) })] }, key))) }));
14
+ return (_jsx("div", { className: "flex flex-col gap-4", children: Object.keys(valueObject).map((key) => (_jsxs("div", { className: "ml-4 flex flex-col gap-2", children: [_jsx("span", { className: "text-md font-semibold", children: key }), _jsx("span", { className: "text-md", children: value ? (_jsx(LogValue, { value: valueObject[key] })) : (_jsx(Value, { value: valueObject[key] })) })] }, key))) }));
11
15
  }
12
- return `${value}`;
16
+ return _jsx(Value, { value: value });
13
17
  };
14
18
  export const LogField = ({ label, value, className }) => {
15
- return (_jsx("div", { className: cn('flex row gap-8 bg-gray-900 text-white p-4 rounded-lg font-bold text-sm', className), children: _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("span", { className: "text-gray-400 text-xs font-bold", children: label }), _jsx("span", { className: "text-large font-bold", children: value ? _jsx(LogValue, { value: value }) : JSON.stringify(value) })] }) }));
19
+ return (_jsx("div", { className: cn('flex row text-white p-2', className), children: _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("span", { className: "text-md font-semibold", children: label }), _jsx("span", { className: "", children: value ? _jsx(LogValue, { value: value }) : _jsx(Value, { value: value }) })] }) }));
16
20
  };
@@ -14,5 +14,5 @@ export const Logs = () => {
14
14
  const handleLogClick = (log) => {
15
15
  setSelectedLog(log);
16
16
  };
17
- return (_jsxs("div", { className: "overflow-y-auto h-full text-bold p-4", children: [_jsx(LogDetail, { log: selectedLog, onClose: () => setSelectedLog(undefined) }), _jsxs(Table, { children: [_jsx(TableHeader, { className: "sticky top-0", children: _jsxs(TableRow, { className: "bg-zinc-800 border-b border-zinc-700 [&>th]:font-bold", children: [_jsx(TableHead, { children: "Time" }), _jsx(TableHead, { children: "Level" }), _jsx(TableHead, { children: "Trace" }), _jsx(TableHead, { children: "Flow" }), _jsx(TableHead, { children: "Step" }), _jsx(TableHead, { children: "Message" })] }) }), _jsx(TableBody, { className: "text-md font-mono", children: logs.map((log, index) => (_jsxs(TableRow, { className: "font-bold border-b border-zinc-800/50", onClick: () => handleLogClick(log), children: [_jsx(TableCell, { children: timestamp(log.time) }), _jsx(TableCell, { children: _jsx(LogLevelBadge, { level: log.level }) }), _jsx(TableCell, { children: log.traceId.split('-').pop() }), _jsx(TableCell, { children: log.flows?.join?.(', ') }), _jsx(TableCell, { children: log.step }), _jsx(TableCell, { children: log.msg })] }, index))) })] })] }));
17
+ return (_jsxs("div", { className: "overflow-y-auto h-full text-bold p-4", children: [_jsx(LogDetail, { log: selectedLog, onClose: () => setSelectedLog(undefined) }), _jsxs(Table, { children: [_jsx(TableHeader, { className: "sticky top-0", children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Time" }), _jsx(TableHead, { children: "Level" }), _jsx(TableHead, { children: "Trace" }), _jsx(TableHead, { children: "Flow" }), _jsx(TableHead, { children: "Step" }), _jsx(TableHead, { children: "Message" })] }) }), _jsx(TableBody, { className: "text-md font-mono", children: logs.map((log, index) => (_jsxs(TableRow, { className: "text-white border-b border-zinc-800/50", onClick: () => handleLogClick(log), children: [_jsx(TableCell, { className: "whitespace-nowrap", children: timestamp(log.time) }), _jsx(TableCell, { children: _jsx(LogLevelBadge, { level: log.level }) }), _jsx(TableCell, { children: log.traceId }), _jsx(TableCell, { children: log.flows?.join?.(', ') }), _jsx(TableCell, { children: log.step }), _jsx(TableCell, { children: log.msg })] }, index))) })] })] }));
18
18
  };
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { StateField } from './state-field';
2
+ import { StateValue } from './state-value';
3
3
  import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from '../ui/sheet';
4
4
  export const StateDetail = ({ state, onClose }) => {
5
5
  const isOpen = !!state;
@@ -8,7 +8,5 @@ export const StateDetail = ({ state, onClose }) => {
8
8
  onClose();
9
9
  }
10
10
  };
11
- const isObject = typeof state === 'object';
12
- const fields = Object.keys(state ?? {});
13
- return (_jsx(Sheet, { open: isOpen, onOpenChange: onOpenChange, children: _jsxs(SheetContent, { className: "flex flex-col h-full", children: [_jsxs(SheetHeader, { children: [_jsx(SheetTitle, { children: "State details" }), _jsx(SheetDescription, { children: "State details and application." })] }), _jsx("div", { className: "font-mono overflow-y-auto", children: state && (_jsxs("div", { className: "flex flex-col gap-6 ", children: [isObject && fields.map((key) => _jsx(StateField, { label: key, value: state[key] }, key)), !isObject && _jsx(StateField, { label: "Value", value: state })] })) })] }) }));
11
+ return (_jsx(Sheet, { open: isOpen, onOpenChange: onOpenChange, children: _jsxs(SheetContent, { className: "flex flex-col h-full", children: [_jsxs(SheetHeader, { children: [_jsx(SheetTitle, { children: "State details" }), _jsx(SheetDescription, { children: "State details and application." })] }), _jsx("div", { className: "font-mono overflow-y-auto", children: state && (_jsx("div", { className: "flex flex-col gap-2", children: _jsx(StateValue, { value: state, isRoot: true }) })) })] }) }));
14
12
  };
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ type Props = {
3
+ value: unknown;
4
+ isRoot?: boolean;
5
+ label?: string;
6
+ };
7
+ export declare const StateValue: React.FC<Props>;
8
+ export {};
@@ -0,0 +1,51 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cva } from 'class-variance-authority';
3
+ import { SquareMinus, SquarePlus } from 'lucide-react';
4
+ import React, { useState } from 'react';
5
+ import { cn } from '../../lib/utils';
6
+ const valueVariants = cva('text-white/60 text-sm py-2', {
7
+ variants: {
8
+ variant: {
9
+ boolean: 'text-sky-400',
10
+ number: 'text-teal-400',
11
+ undefined: 'text-white/60',
12
+ string: 'text-white/60',
13
+ object: 'text-gray-800',
14
+ },
15
+ },
16
+ defaultVariants: {
17
+ variant: 'string',
18
+ },
19
+ });
20
+ const Value = ({ value, variant, label, }) => {
21
+ const displayValue = typeof value === 'string' ? value : JSON.stringify(value);
22
+ return (_jsxs("div", { className: "flex flex-col gap-1", children: [label && _jsx("div", { className: "text-md font-semibold py-2", children: label }), _jsx("div", { className: valueVariants({ variant }), children: displayValue })] }));
23
+ };
24
+ export const StateValue = ({ value, label, isRoot = false }) => {
25
+ const [isOpen, setIsOpen] = useState(true);
26
+ const toggle = () => setIsOpen(!isOpen);
27
+ if (React.isValidElement(value)) {
28
+ return value;
29
+ }
30
+ if (typeof value === 'boolean') {
31
+ return _jsx(Value, { label: label, variant: "boolean", value: value ? 'true' : 'false' });
32
+ }
33
+ if (typeof value === 'number') {
34
+ return _jsx(Value, { label: label, variant: "number", value: value });
35
+ }
36
+ if (typeof value === 'undefined') {
37
+ return _jsx(Value, { label: label, variant: "undefined", value: value });
38
+ }
39
+ if (typeof value === 'string') {
40
+ return _jsx(Value, { label: label, variant: "string", value: value });
41
+ }
42
+ const isArray = Array.isArray(value);
43
+ const [openBracket, closeBracket] = isRoot ? [] : isArray ? ['[', ']'] : ['{', '}'];
44
+ if (typeof value === 'object' && !!value) {
45
+ const valueObject = value;
46
+ return (_jsxs("div", { className: "flex flex-col gap-2", children: [(label || openBracket) && (_jsxs("div", { className: "flex gap-1 items-center text-md font-semibold hover:bg-gray-800 rounded-md py-2", onClick: toggle, children: [isOpen ? (_jsx(SquareMinus, { className: "w-4 h-4 text-white/60" })) : (_jsx(SquarePlus, { className: "w-4 h-4 text-white/60" })), label, ' ', !isRoot && (_jsxs("span", { className: "text-white/60 text-sm", children: [openBracket, !isOpen && ` ... ${closeBracket}`] }))] })), isOpen &&
47
+ !!valueObject &&
48
+ Object.keys(valueObject).map((key) => (_jsx("div", { className: cn('flex flex-col gap-2', !isRoot && 'ml-4'), children: _jsx("span", { className: "text-md", children: _jsx(StateValue, { label: isArray ? undefined : key, value: valueObject[key] }) }) }, key))), !isRoot && isOpen && _jsx("span", { className: "text-white/60 text-sm", children: closeBracket })] }));
49
+ }
50
+ return _jsx(Value, { value: undefined, variant: "object" });
51
+ };
@@ -17,5 +17,5 @@ export const States = () => {
17
17
  const handleStateClick = (state) => {
18
18
  setSelectedState(state);
19
19
  };
20
- return (_jsxs("div", { className: "flex flex-row gap-4 h-full", children: [_jsx(StateDetail, { state: values, onClose: () => setSelectedState(undefined) }), _jsx("div", { className: "flex flex-col gap-2 flex-1 pl-4 py-4", children: _jsxs(Table, { children: [_jsx(TableHeader, { className: "sticky top-0", children: _jsx(TableRow, { className: "bg-zinc-800 border-b border-zinc-700 [&>th]:font-bold", children: _jsx(TableHead, { children: "Root Field (Trace ID)" }) }) }), _jsx(TableBody, { className: "text-md font-mono", children: traces.map((trace) => (_jsx(TableRow, { className: `border-b border-zinc-800/50 cursor-pointer font-bold ${selectedTraceId === trace ? 'bg-indigo-900/50 hover:bg-indigo-900/30' : ''}`, onClick: () => handleTraceClick(trace), children: _jsx(TableCell, { children: trace }) }, trace))) })] }) }), _jsx("div", { className: "flex flex-col gap-2 flex-1 pr-4 py-4", children: _jsxs(Table, { children: [_jsx(TableHeader, { className: "sticky top-0", children: _jsx(TableRow, { className: "bg-zinc-800 border-b border-zinc-700 [&>th]:font-bold", children: _jsx(TableHead, { children: "Fields" }) }) }), _jsx(TableBody, { className: "text-md font-mono", children: fields.map((field) => (_jsx(TableRow, { className: `border-b border-zinc-800/50 cursor-pointer font-bold ${selectedState === field ? 'bg-indigo-900/50 hover:bg-indigo-900/30' : ''}`, onClick: () => handleStateClick(field), children: _jsx(TableCell, { children: field }) }, field))) })] }) })] }));
20
+ return (_jsxs("div", { className: "flex flex-row gap-4 h-full", children: [_jsx(StateDetail, { state: values, onClose: () => setSelectedState(undefined) }), _jsx("div", { className: "flex flex-col gap-2 flex-1 pl-4 py-4", children: _jsxs(Table, { children: [_jsx(TableHeader, { className: "sticky top-0", children: _jsx(TableRow, { children: _jsx(TableHead, { children: "Root Field (Trace ID)" }) }) }), _jsx(TableBody, { children: traces.map((trace) => (_jsx(TableRow, { onClick: () => handleTraceClick(trace), children: _jsx(TableCell, { className: `rounded-lg font-mono font-semibold ${selectedTraceId === trace ? 'bg-indigo-900/50 hover:bg-indigo-900/30' : ''}`, children: trace }) }, trace))) })] }) }), _jsx("div", { className: "flex flex-col gap-2 flex-1 pr-4 py-4", children: _jsxs(Table, { children: [_jsx(TableHeader, { className: "sticky top-0", children: _jsx(TableRow, { children: _jsx(TableHead, { children: "Fields" }) }) }), _jsx(TableBody, { children: fields.map((field) => (_jsx(TableRow, { className: `font-semibold font-mono ${selectedState === field ? 'bg-indigo-900/50 hover:bg-indigo-900/30' : ''}`, onClick: () => handleStateClick(field), children: _jsx(TableCell, { children: field }) }, field))) })] }) })] }));
21
21
  };
@@ -1,12 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { cva } from 'class-variance-authority';
3
3
  import { cn } from '@/lib/utils';
4
- const badgeVariants = cva('inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-bold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2', {
4
+ const badgeVariants = cva('inline-flex items-center rounded-lg border px-2 py-1 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2', {
5
5
  variants: {
6
6
  variant: {
7
7
  default: 'border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80',
8
8
  secondary: 'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',
9
- info: 'border-transparent bg-sky-500 text-black hover:bg-sky/80',
9
+ info: 'border-transparent bg-[#47B2FF33] text-[#47B2FF] hover:bg-sky/80',
10
10
  error: 'border-transparent bg-rose-500 text-black shadow hover:bg-rose/80',
11
11
  warning: 'border-transparent bg-amber-300 text-amber-950 hover:bg-amber/80',
12
12
  destructive: 'border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80',
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { type VariantProps } from 'class-variance-authority';
3
3
  declare const buttonVariants: (props?: ({
4
- variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | "none" | null | undefined;
4
+ variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | "none" | null | undefined;
5
5
  size?: "default" | "sm" | "lg" | "icon" | null | undefined;
6
6
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
7
  export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
@@ -1,55 +1,11 @@
1
- import * as React from 'react';
2
- import { VariantProps } from 'class-variance-authority';
3
- import { TooltipContent } from '@/components/ui/tooltip';
4
- declare const SidebarProvider: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
5
- defaultOpen?: boolean;
6
- open?: boolean;
7
- onOpenChange?: (open: boolean) => void;
8
- }, "ref"> & React.RefAttributes<HTMLDivElement>>;
9
- declare const Sidebar: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
10
- side?: "left" | "right";
11
- variant?: "sidebar" | "floating" | "inset";
12
- collapsible?: "offcanvas" | "icon" | "none";
13
- }, "ref"> & React.RefAttributes<HTMLDivElement>>;
14
- declare const SidebarTrigger: React.ForwardRefExoticComponent<Omit<import("@/components/ui/button").ButtonProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
15
- declare const SidebarRail: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
16
- declare const SidebarInset: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
17
- declare const SidebarInput: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & React.RefAttributes<HTMLInputElement>, "ref"> & React.RefAttributes<HTMLInputElement>>;
18
- declare const SidebarHeader: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
19
- declare const SidebarFooter: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
20
- declare const SidebarSeparator: React.ForwardRefExoticComponent<Omit<Omit<import("@radix-ui/react-separator").SeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
21
- declare const SidebarContent: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
22
- declare const SidebarGroup: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
23
- declare const SidebarGroupLabel: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
24
- asChild?: boolean;
25
- }, "ref"> & React.RefAttributes<HTMLDivElement>>;
26
- declare const SidebarGroupAction: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & {
27
- asChild?: boolean;
28
- }, "ref"> & React.RefAttributes<HTMLButtonElement>>;
29
- declare const SidebarGroupContent: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
30
- declare const SidebarMenu: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & React.RefAttributes<HTMLUListElement>>;
31
- declare const SidebarMenuItem: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & React.RefAttributes<HTMLLIElement>>;
32
- declare const SidebarMenuButton: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & {
33
- asChild?: boolean;
34
- isActive?: boolean;
35
- tooltip?: string | React.ComponentProps<typeof TooltipContent>;
36
- } & VariantProps<(props?: ({
37
- variant?: "default" | "outline" | null | undefined;
38
- size?: "default" | "sm" | "lg" | null | undefined;
39
- } & import("class-variance-authority/types").ClassProp) | undefined) => string>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
40
- declare const SidebarMenuAction: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & {
41
- asChild?: boolean;
42
- showOnHover?: boolean;
43
- }, "ref"> & React.RefAttributes<HTMLButtonElement>>;
44
- declare const SidebarMenuBadge: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
45
- declare const SidebarMenuSkeleton: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
46
- showIcon?: boolean;
47
- }, "ref"> & React.RefAttributes<HTMLDivElement>>;
48
- declare const SidebarMenuSub: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & React.RefAttributes<HTMLUListElement>>;
49
- declare const SidebarMenuSubItem: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & React.RefAttributes<HTMLLIElement>>;
50
- declare const SidebarMenuSubButton: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLAnchorElement> & React.AnchorHTMLAttributes<HTMLAnchorElement> & {
51
- asChild?: boolean;
52
- size?: "sm" | "md";
53
- isActive?: boolean;
54
- }, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
55
- export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, };
1
+ import React, { PropsWithChildren } from 'react';
2
+ export declare const Sidebar: React.FC<PropsWithChildren>;
3
+ export declare const SidebarGroup: React.FC<PropsWithChildren<{
4
+ title: string;
5
+ }>>;
6
+ type SidebarButtonProps = PropsWithChildren<{
7
+ isActive: boolean;
8
+ icon: React.ReactNode;
9
+ }>;
10
+ export declare const SidebarButton: React.FC<SidebarButtonProps>;
11
+ export {};
@@ -1,221 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import { Slot } from '@radix-ui/react-slot';
4
- import { cva } from 'class-variance-authority';
5
- import { PanelLeft } from 'lucide-react';
6
- import { useIsMobile } from '@/hooks/use-mobile';
7
- import { cn } from '@/lib/utils';
8
- import { Button } from '@/components/ui/button';
9
- import { Input } from '@/components/ui/input';
10
- import { Separator } from '@/components/ui/separator';
11
- import { Sheet, SheetContent } from '@/components/ui/sheet';
12
- import { Skeleton } from '@/components/ui/skeleton';
13
- import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
14
- const SIDEBAR_COOKIE_NAME = 'sidebar:state';
15
- const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
16
- const SIDEBAR_WIDTH = '16rem';
17
- const SIDEBAR_WIDTH_MOBILE = '18rem';
18
- const SIDEBAR_WIDTH_ICON = '3rem';
19
- const SIDEBAR_KEYBOARD_SHORTCUT = 'b';
20
- const SidebarContext = React.createContext(null);
21
- function useSidebar() {
22
- const context = React.useContext(SidebarContext);
23
- if (!context) {
24
- throw new Error('useSidebar must be used within a SidebarProvider.');
25
- }
26
- return context;
27
- }
28
- const SidebarProvider = React.forwardRef(({ defaultOpen = true, open: openProp, onOpenChange: setOpenProp, className, style, children, ...props }, ref) => {
29
- const isMobile = useIsMobile();
30
- const [openMobile, setOpenMobile] = React.useState(false);
31
- // This is the internal state of the sidebar.
32
- // We use openProp and setOpenProp for control from outside the component.
33
- const [_open, _setOpen] = React.useState(defaultOpen);
34
- const open = openProp ?? _open;
35
- const setOpen = React.useCallback((value) => {
36
- const openState = typeof value === 'function' ? value(open) : value;
37
- if (setOpenProp) {
38
- setOpenProp(openState);
39
- }
40
- else {
41
- _setOpen(openState);
42
- }
43
- // This sets the cookie to keep the sidebar state.
44
- document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
45
- }, [setOpenProp, open]);
46
- // Helper to toggle the sidebar.
47
- const toggleSidebar = React.useCallback(() => {
48
- return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
49
- }, [isMobile, setOpen, setOpenMobile]);
50
- // Adds a keyboard shortcut to toggle the sidebar.
51
- React.useEffect(() => {
52
- const handleKeyDown = (event) => {
53
- if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
54
- event.preventDefault();
55
- toggleSidebar();
56
- }
57
- };
58
- window.addEventListener('keydown', handleKeyDown);
59
- return () => window.removeEventListener('keydown', handleKeyDown);
60
- }, [toggleSidebar]);
61
- // We add a state so that we can do data-state="expanded" or "collapsed".
62
- // This makes it easier to style the sidebar with Tailwind classes.
63
- const state = open ? 'expanded' : 'collapsed';
64
- const contextValue = React.useMemo(() => ({
65
- state,
66
- open,
67
- setOpen,
68
- isMobile,
69
- openMobile,
70
- setOpenMobile,
71
- toggleSidebar,
72
- }), [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]);
73
- return (_jsx(SidebarContext.Provider, { value: contextValue, children: _jsx(TooltipProvider, { delayDuration: 0, children: _jsx("div", { style: {
74
- '--sidebar-width': SIDEBAR_WIDTH,
75
- '--sidebar-width-icon': SIDEBAR_WIDTH_ICON,
76
- ...style,
77
- }, className: cn('group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar', className), ref: ref, ...props, children: children }) }) }));
78
- });
79
- SidebarProvider.displayName = 'SidebarProvider';
80
- const Sidebar = React.forwardRef(({ side = 'left', variant = 'sidebar', collapsible = 'offcanvas', className, children, ...props }, ref) => {
81
- const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
82
- if (collapsible === 'none') {
83
- return (_jsx("div", { className: cn('flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground', className), ref: ref, ...props, children: children }));
84
- }
85
- if (isMobile) {
86
- return (_jsx(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: _jsx(SheetContent, { "data-sidebar": "sidebar", "data-mobile": "true", className: "w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden", style: {
87
- '--sidebar-width': SIDEBAR_WIDTH_MOBILE,
88
- }, side: side, children: _jsx("div", { className: "flex h-full w-full flex-col", children: children }) }) }));
89
- }
90
- return (_jsxs("div", { ref: ref, className: "group peer hidden md:block text-sidebar-foreground", "data-state": state, "data-collapsible": state === 'collapsed' ? collapsible : '', "data-variant": variant, "data-side": side, children: [_jsx("div", { className: cn('duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear', 'group-data-[collapsible=offcanvas]:w-0', 'group-data-[side=right]:rotate-180', variant === 'floating' || variant === 'inset'
91
- ? 'group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]'
92
- : 'group-data-[collapsible=icon]:w-[--sidebar-width-icon]') }), _jsx("div", { className: cn('duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex', side === 'left'
93
- ? 'left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]'
94
- : 'right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]',
95
- // Adjust the padding for floating and inset variants.
96
- variant === 'floating' || variant === 'inset'
97
- ? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]'
98
- : 'group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l', className), ...props, children: _jsx("div", { "data-sidebar": "sidebar", className: "flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow", children: children }) })] }));
99
- });
100
- Sidebar.displayName = 'Sidebar';
101
- const SidebarTrigger = React.forwardRef(({ className, onClick, ...props }, ref) => {
102
- const { toggleSidebar } = useSidebar();
103
- return (_jsxs(Button, { ref: ref, "data-sidebar": "trigger", variant: "ghost", size: "icon", className: cn('h-7 w-7', className), onClick: (event) => {
104
- onClick?.(event);
105
- toggleSidebar();
106
- }, ...props, children: [_jsx(PanelLeft, {}), _jsx("span", { className: "sr-only", children: "Toggle Sidebar" })] }));
107
- });
108
- SidebarTrigger.displayName = 'SidebarTrigger';
109
- const SidebarRail = React.forwardRef(({ className, ...props }, ref) => {
110
- const { toggleSidebar } = useSidebar();
111
- return (_jsx("button", { ref: ref, "data-sidebar": "rail", "aria-label": "Toggle Sidebar", tabIndex: -1, onClick: toggleSidebar, title: "Toggle Sidebar", className: cn('absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex', '[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize', '[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize', 'group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar', '[[data-side=left][data-collapsible=offcanvas]_&]:-right-2', '[[data-side=right][data-collapsible=offcanvas]_&]:-left-2', className), ...props }));
112
- });
113
- SidebarRail.displayName = 'SidebarRail';
114
- const SidebarInset = React.forwardRef(({ className, ...props }, ref) => {
115
- return (_jsx("main", { ref: ref, className: cn('relative flex min-h-svh flex-1 flex-col bg-background', 'peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow', className), ...props }));
116
- });
117
- SidebarInset.displayName = 'SidebarInset';
118
- const SidebarInput = React.forwardRef(({ className, ...props }, ref) => {
119
- return (_jsx(Input, { ref: ref, "data-sidebar": "input", className: cn('h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring', className), ...props }));
120
- });
121
- SidebarInput.displayName = 'SidebarInput';
122
- const SidebarHeader = React.forwardRef(({ className, ...props }, ref) => {
123
- return _jsx("div", { ref: ref, "data-sidebar": "header", className: cn('flex flex-col gap-2 p-2', className), ...props });
124
- });
125
- SidebarHeader.displayName = 'SidebarHeader';
126
- const SidebarFooter = React.forwardRef(({ className, ...props }, ref) => {
127
- return _jsx("div", { ref: ref, "data-sidebar": "footer", className: cn('flex flex-col gap-2 p-2', className), ...props });
128
- });
129
- SidebarFooter.displayName = 'SidebarFooter';
130
- const SidebarSeparator = React.forwardRef(({ className, ...props }, ref) => {
131
- return (_jsx(Separator, { ref: ref, "data-sidebar": "separator", className: cn('mx-2 w-auto bg-sidebar-border', className), ...props }));
132
- });
133
- SidebarSeparator.displayName = 'SidebarSeparator';
134
- const SidebarContent = React.forwardRef(({ className, ...props }, ref) => {
135
- return (_jsx("div", { ref: ref, "data-sidebar": "content", className: cn('flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden', className), ...props }));
136
- });
137
- SidebarContent.displayName = 'SidebarContent';
138
- const SidebarGroup = React.forwardRef(({ className, ...props }, ref) => {
139
- return (_jsx("div", { ref: ref, "data-sidebar": "group", className: cn('relative flex w-full min-w-0 flex-col p-2', className), ...props }));
140
- });
141
- SidebarGroup.displayName = 'SidebarGroup';
142
- const SidebarGroupLabel = React.forwardRef(({ className, asChild = false, ...props }, ref) => {
143
- const Comp = asChild ? Slot : 'div';
144
- return (_jsx(Comp, { ref: ref, "data-sidebar": "group-label", className: cn('duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0', 'group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0', className), ...props }));
145
- });
146
- SidebarGroupLabel.displayName = 'SidebarGroupLabel';
147
- const SidebarGroupAction = React.forwardRef(({ className, asChild = false, ...props }, ref) => {
148
- const Comp = asChild ? Slot : 'button';
149
- return (_jsx(Comp, { ref: ref, "data-sidebar": "group-action", className: cn('absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
150
- // Increases the hit area of the button on mobile.
151
- 'after:absolute after:-inset-2 after:md:hidden', 'group-data-[collapsible=icon]:hidden', className), ...props }));
152
- });
153
- SidebarGroupAction.displayName = 'SidebarGroupAction';
154
- const SidebarGroupContent = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-sidebar": "group-content", className: cn('w-full text-sm', className), ...props })));
155
- SidebarGroupContent.displayName = 'SidebarGroupContent';
156
- const SidebarMenu = React.forwardRef(({ className, ...props }, ref) => (_jsx("ul", { ref: ref, "data-sidebar": "menu", className: cn('flex w-full min-w-0 flex-col gap-1', className), ...props })));
157
- SidebarMenu.displayName = 'SidebarMenu';
158
- const SidebarMenuItem = React.forwardRef(({ className, ...props }, ref) => (_jsx("li", { ref: ref, "data-sidebar": "menu-item", className: cn('group/menu-item relative', className), ...props })));
159
- SidebarMenuItem.displayName = 'SidebarMenuItem';
160
- const sidebarMenuButtonVariants = cva('peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0', {
161
- variants: {
162
- variant: {
163
- default: 'hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
164
- outline: 'bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]',
165
- },
166
- size: {
167
- default: 'h-8 text-sm',
168
- sm: 'h-7 text-xs',
169
- lg: 'h-12 text-sm group-data-[collapsible=icon]:!p-0',
170
- },
171
- },
172
- defaultVariants: {
173
- variant: 'default',
174
- size: 'default',
175
- },
176
- });
177
- const SidebarMenuButton = React.forwardRef(({ asChild = false, isActive = false, variant = 'default', size = 'default', tooltip, className, ...props }, ref) => {
178
- const Comp = asChild ? Slot : 'button';
179
- const { isMobile, state } = useSidebar();
180
- const button = (_jsx(Comp, { ref: ref, "data-sidebar": "menu-button", "data-size": size, "data-active": isActive, className: cn(sidebarMenuButtonVariants({ variant, size }), className), ...props }));
181
- if (!tooltip) {
182
- return button;
183
- }
184
- if (typeof tooltip === 'string') {
185
- tooltip = {
186
- children: tooltip,
187
- };
188
- }
189
- return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: button }), _jsx(TooltipContent, { side: "right", align: "center", hidden: state !== 'collapsed' || isMobile, ...tooltip })] }));
190
- });
191
- SidebarMenuButton.displayName = 'SidebarMenuButton';
192
- const SidebarMenuAction = React.forwardRef(({ className, asChild = false, showOnHover = false, ...props }, ref) => {
193
- const Comp = asChild ? Slot : 'button';
194
- return (_jsx(Comp, { ref: ref, "data-sidebar": "menu-action", className: cn('absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0',
195
- // Increases the hit area of the button on mobile.
196
- 'after:absolute after:-inset-2 after:md:hidden', 'peer-data-[size=sm]/menu-button:top-1', 'peer-data-[size=default]/menu-button:top-1.5', 'peer-data-[size=lg]/menu-button:top-2.5', 'group-data-[collapsible=icon]:hidden', showOnHover &&
197
- 'group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0', className), ...props }));
198
- });
199
- SidebarMenuAction.displayName = 'SidebarMenuAction';
200
- const SidebarMenuBadge = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-sidebar": "menu-badge", className: cn('absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none', 'peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground', 'peer-data-[size=sm]/menu-button:top-1', 'peer-data-[size=default]/menu-button:top-1.5', 'peer-data-[size=lg]/menu-button:top-2.5', 'group-data-[collapsible=icon]:hidden', className), ...props })));
201
- SidebarMenuBadge.displayName = 'SidebarMenuBadge';
202
- const SidebarMenuSkeleton = React.forwardRef(({ className, showIcon = false, ...props }, ref) => {
203
- // Random width between 50 to 90%.
204
- const width = React.useMemo(() => {
205
- return `${Math.floor(Math.random() * 40) + 50}%`;
206
- }, []);
207
- return (_jsxs("div", { ref: ref, "data-sidebar": "menu-skeleton", className: cn('rounded-md h-8 flex gap-2 px-2 items-center', className), ...props, children: [showIcon && _jsx(Skeleton, { className: "size-4 rounded-md", "data-sidebar": "menu-skeleton-icon" }), _jsx(Skeleton, { className: "h-4 flex-1 max-w-[--skeleton-width]", "data-sidebar": "menu-skeleton-text", style: {
208
- '--skeleton-width': width,
209
- } })] }));
210
- });
211
- SidebarMenuSkeleton.displayName = 'SidebarMenuSkeleton';
212
- const SidebarMenuSub = React.forwardRef(({ className, ...props }, ref) => (_jsx("ul", { ref: ref, "data-sidebar": "menu-sub", className: cn('mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5', 'group-data-[collapsible=icon]:hidden', className), ...props })));
213
- SidebarMenuSub.displayName = 'SidebarMenuSub';
214
- const SidebarMenuSubItem = React.forwardRef(({ ...props }, ref) => (_jsx("li", { ref: ref, ...props })));
215
- SidebarMenuSubItem.displayName = 'SidebarMenuSubItem';
216
- const SidebarMenuSubButton = React.forwardRef(({ asChild = false, size = 'md', isActive, className, ...props }, ref) => {
217
- const Comp = asChild ? Slot : 'a';
218
- return (_jsx(Comp, { ref: ref, "data-sidebar": "menu-sub-button", "data-size": size, "data-active": isActive, className: cn('flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground', 'data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground', size === 'sm' && 'text-xs', size === 'md' && 'text-sm', 'group-data-[collapsible=icon]:hidden', className), ...props }));
219
- });
220
- SidebarMenuSubButton.displayName = 'SidebarMenuSubButton';
221
- export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, };
2
+ import { useState } from 'react';
3
+ import { cn } from '../../lib/utils';
4
+ import { PanelLeftClose, PanelLeftOpen } from 'lucide-react';
5
+ import { Button } from './button';
6
+ export const Sidebar = ({ children }) => {
7
+ const [isCollapsed, setIsCollapsed] = useState(false);
8
+ return (_jsxs("div", { className: cn('max-h-screen overflow-y-auto transition-[width] duration-300', isCollapsed ? 'w-[50px]' : 'w-[250px]'), children: [_jsx("div", { className: "flex items-center justify-end gap-2 px-4 py-3", children: _jsx(Button, { variant: "ghost", size: "icon", onClick: () => setIsCollapsed(!isCollapsed), children: isCollapsed ? _jsx(PanelLeftOpen, { className: "w-4 h-4" }) : _jsx(PanelLeftClose, { className: "w-4 h-4" }) }) }), !isCollapsed && _jsx("div", { className: "overflow-y-auto w-[250px]", children: children })] }));
9
+ };
10
+ export const SidebarGroup = ({ children, title }) => {
11
+ return (_jsxs("div", { className: "flex flex-col", children: [_jsx("h2", { className: "text-lg text-white/60 px-4 py-2 uppercase", children: title }), children] }));
12
+ };
13
+ export const SidebarButton = ({ children, isActive, icon }) => {
14
+ return (_jsxs("div", { className: cn('flex items-center gap-2 px-4 py-3 ', isActive && 'bg-[#242036]'), children: [_jsx("div", { className: "text-gray-500", children: icon }), children] }));
15
+ };
@@ -11,7 +11,7 @@ const TableFooter = React.forwardRef(({ className, ...props }, ref) => (_jsx("tf
11
11
  TableFooter.displayName = 'TableFooter';
12
12
  const TableRow = React.forwardRef(({ className, ...props }, ref) => (_jsx("tr", { ref: ref, className: cn('border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted', className), ...props })));
13
13
  TableRow.displayName = 'TableRow';
14
- const TableHead = React.forwardRef(({ className, ...props }, ref) => (_jsx("th", { ref: ref, className: cn('h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]', className), ...props })));
14
+ const TableHead = React.forwardRef(({ className, ...props }, ref) => (_jsx("th", { ref: ref, className: cn('h-10 px-2 text-left align-middle text-lg bg-[#252234] text-muted-foreground first:rounded-l-lg last:rounded-r-lg [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]', className), ...props })));
15
15
  TableHead.displayName = 'TableHead';
16
16
  const TableCell = React.forwardRef(({ className, ...props }, ref) => (_jsx("td", { ref: ref, className: cn('p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]', className), ...props })));
17
17
  TableCell.displayName = 'TableCell';
@@ -0,0 +1 @@
1
+ export declare const useDebounced: (fn: () => void, delay?: number) => () => void;
@@ -0,0 +1,20 @@
1
+ import { useCallback, useEffect, useRef } from 'react';
2
+ export const useDebounced = (fn, delay = 500) => {
3
+ const saveTimeoutRef = useRef(null);
4
+ const debouncedFn = useCallback(() => {
5
+ if (saveTimeoutRef.current) {
6
+ clearTimeout(saveTimeoutRef.current);
7
+ }
8
+ saveTimeoutRef.current = setTimeout(() => {
9
+ fn();
10
+ }, delay);
11
+ }, [fn, delay]);
12
+ useEffect(() => {
13
+ return () => {
14
+ if (saveTimeoutRef.current) {
15
+ clearTimeout(saveTimeoutRef.current);
16
+ }
17
+ };
18
+ }, []);
19
+ return debouncedFn;
20
+ };