@tanstack/cta-ui-base 0.15.4
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/LICENSE +21 -0
- package/components.json +21 -0
- package/dist/app.d.ts +1 -0
- package/dist/app.js +10 -0
- package/dist/components/add-on-info-dialog.d.ts +5 -0
- package/dist/components/add-on-info-dialog.js +5 -0
- package/dist/components/background-animation.d.ts +1 -0
- package/dist/components/background-animation.js +144 -0
- package/dist/components/cta-provider.d.ts +3 -0
- package/dist/components/cta-provider.js +11 -0
- package/dist/components/cta-sidebar.d.ts +1 -0
- package/dist/components/cta-sidebar.js +15 -0
- package/dist/components/custom-add-on-dialog.d.ts +1 -0
- package/dist/components/custom-add-on-dialog.js +38 -0
- package/dist/components/file-navigator.d.ts +2 -0
- package/dist/components/file-navigator.js +86 -0
- package/dist/components/file-tree.d.ts +5 -0
- package/dist/components/file-tree.js +14 -0
- package/dist/components/file-viewer.d.ts +5 -0
- package/dist/components/file-viewer.js +40 -0
- package/dist/components/header.d.ts +1 -0
- package/dist/components/header.js +5 -0
- package/dist/components/icons/tailwind.d.ts +3 -0
- package/dist/components/icons/tailwind.js +5 -0
- package/dist/components/icons/tanstack.d.ts +3 -0
- package/dist/components/icons/tanstack.js +5 -0
- package/dist/components/icons/typescript.d.ts +3 -0
- package/dist/components/icons/typescript.js +5 -0
- package/dist/components/query-provider.d.ts +3 -0
- package/dist/components/query-provider.js +7 -0
- package/dist/components/sidebar-items/add-ons.d.ts +1 -0
- package/dist/components/sidebar-items/add-ons.js +27 -0
- package/dist/components/sidebar-items/mode-selector.d.ts +1 -0
- package/dist/components/sidebar-items/mode-selector.js +19 -0
- package/dist/components/sidebar-items/project-name.d.ts +1 -0
- package/dist/components/sidebar-items/project-name.js +12 -0
- package/dist/components/sidebar-items/run-add-ons.d.ts +1 -0
- package/dist/components/sidebar-items/run-add-ons.js +25 -0
- package/dist/components/sidebar-items/run-create-app.d.ts +1 -0
- package/dist/components/sidebar-items/run-create-app.js +28 -0
- package/dist/components/sidebar-items/sidebar-container.d.ts +3 -0
- package/dist/components/sidebar-items/sidebar-container.js +4 -0
- package/dist/components/sidebar-items/sidebar-group.d.ts +3 -0
- package/dist/components/sidebar-items/sidebar-group.js +4 -0
- package/dist/components/sidebar-items/starter.d.ts +1 -0
- package/dist/components/sidebar-items/starter.js +42 -0
- package/dist/components/sidebar-items/typescript-switch.d.ts +1 -0
- package/dist/components/sidebar-items/typescript-switch.js +18 -0
- package/dist/components/starters-carousel.d.ts +3 -0
- package/dist/components/starters-carousel.js +12 -0
- package/dist/components/startup-dialog.d.ts +1 -0
- package/dist/components/startup-dialog.js +30 -0
- package/dist/components/status-list.d.ts +5 -0
- package/dist/components/status-list.js +4 -0
- package/dist/components/toaster.d.ts +4 -0
- package/dist/components/toaster.js +15 -0
- package/dist/components/ui/button.d.ts +10 -0
- package/dist/components/ui/button.js +32 -0
- package/dist/components/ui/carousel.d.ts +20 -0
- package/dist/components/ui/carousel.js +90 -0
- package/dist/components/ui/checkbox.d.ts +4 -0
- package/dist/components/ui/checkbox.js +9 -0
- package/dist/components/ui/dialog.d.ts +15 -0
- package/dist/components/ui/dialog.js +36 -0
- package/dist/components/ui/dropdown-menu.d.ts +25 -0
- package/dist/components/ui/dropdown-menu.js +51 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/input.js +7 -0
- package/dist/components/ui/label.d.ts +4 -0
- package/dist/components/ui/label.js +8 -0
- package/dist/components/ui/popover.d.ts +7 -0
- package/dist/components/ui/popover.js +17 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/separator.js +9 -0
- package/dist/components/ui/sheet.d.ts +13 -0
- package/dist/components/ui/sheet.js +40 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/skeleton.js +6 -0
- package/dist/components/ui/sonner.d.ts +3 -0
- package/dist/components/ui/sonner.js +12 -0
- package/dist/components/ui/switch.d.ts +4 -0
- package/dist/components/ui/switch.js +8 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/table.js +28 -0
- package/dist/components/ui/tabs.d.ts +7 -0
- package/dist/components/ui/tabs.js +17 -0
- package/dist/components/ui/toggle-group.d.ts +7 -0
- package/dist/components/ui/toggle-group.js +20 -0
- package/dist/components/ui/toggle.d.ts +9 -0
- package/dist/components/ui/toggle.js +27 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/components/ui/tooltip.js +18 -0
- package/dist/components/ui/tree-view.d.ts +25 -0
- package/dist/components/ui/tree-view.js +151 -0
- package/dist/file-classes.d.ts +8 -0
- package/dist/file-classes.js +41 -0
- package/dist/hooks/use-mounted.d.ts +1 -0
- package/dist/hooks/use-mounted.js +8 -0
- package/dist/hooks/use-preferred-reduced-motion.d.ts +5 -0
- package/dist/hooks/use-preferred-reduced-motion.js +20 -0
- package/dist/hooks/use-streaming-status.d.ts +6 -0
- package/dist/hooks/use-streaming-status.js +55 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +20 -0
- package/dist/lib/api.d.ts +14 -0
- package/dist/lib/api.js +74 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +5 -0
- package/dist/store/add-ons.d.ts +7 -0
- package/dist/store/add-ons.js +59 -0
- package/dist/store/project.d.ts +76 -0
- package/dist/store/project.js +269 -0
- package/package.json +50 -0
- package/src/app.tsx +28 -0
- package/src/components/add-on-info-dialog.tsx +39 -0
- package/src/components/background-animation.tsx +224 -0
- package/src/components/cta-provider.tsx +22 -0
- package/src/components/cta-sidebar.tsx +43 -0
- package/src/components/custom-add-on-dialog.tsx +79 -0
- package/src/components/file-navigator.tsx +207 -0
- package/src/components/file-tree.tsx +35 -0
- package/src/components/file-viewer.tsx +67 -0
- package/src/components/header.tsx +29 -0
- package/src/components/icons/tailwind.tsx +26 -0
- package/src/components/icons/tanstack.tsx +338 -0
- package/src/components/icons/typescript.tsx +23 -0
- package/src/components/query-provider.tsx +10 -0
- package/src/components/sidebar-items/add-ons.tsx +94 -0
- package/src/components/sidebar-items/mode-selector.tsx +56 -0
- package/src/components/sidebar-items/project-name.tsx +32 -0
- package/src/components/sidebar-items/run-add-ons.tsx +71 -0
- package/src/components/sidebar-items/run-create-app.tsx +82 -0
- package/src/components/sidebar-items/sidebar-container.tsx +11 -0
- package/src/components/sidebar-items/sidebar-group.tsx +11 -0
- package/src/components/sidebar-items/starter.tsx +123 -0
- package/src/components/sidebar-items/typescript-switch.tsx +58 -0
- package/src/components/starters-carousel.tsx +41 -0
- package/src/components/startup-dialog.tsx +72 -0
- package/src/components/status-list.tsx +22 -0
- package/src/components/toaster.tsx +29 -0
- package/src/components/ui/button.tsx +61 -0
- package/src/components/ui/carousel.tsx +239 -0
- package/src/components/ui/checkbox.tsx +30 -0
- package/src/components/ui/dialog.tsx +138 -0
- package/src/components/ui/dropdown-menu.tsx +255 -0
- package/src/components/ui/input.tsx +21 -0
- package/src/components/ui/label.tsx +22 -0
- package/src/components/ui/popover.tsx +46 -0
- package/src/components/ui/separator.tsx +28 -0
- package/src/components/ui/sheet.tsx +137 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/sonner.tsx +24 -0
- package/src/components/ui/switch.tsx +29 -0
- package/src/components/ui/table.tsx +114 -0
- package/src/components/ui/tabs.tsx +64 -0
- package/src/components/ui/toggle-group.tsx +72 -0
- package/src/components/ui/toggle.tsx +49 -0
- package/src/components/ui/tooltip.tsx +61 -0
- package/src/components/ui/tree-view.tsx +497 -0
- package/src/file-classes.ts +54 -0
- package/src/hooks/use-mounted.ts +9 -0
- package/src/hooks/use-preferred-reduced-motion.ts +27 -0
- package/src/hooks/use-streaming-status.ts +70 -0
- package/src/index.ts +44 -0
- package/src/lib/api.ts +100 -0
- package/src/lib/utils.ts +8 -0
- package/src/store/add-ons.ts +81 -0
- package/src/store/project.ts +345 -0
- package/src/types.d.ts +109 -0
- package/tests/store/add-ons.test.ts +222 -0
- package/tsconfig.json +25 -0
- package/vitest.config.ts +6 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
function Label({ className, ...props }) {
|
|
6
|
+
return (_jsx(LabelPrimitive.Root, { "data-slot": "label", className: cn('flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50', className), ...props }));
|
|
7
|
+
}
|
|
8
|
+
export { Label };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
3
|
+
declare function Popover({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function PopoverTrigger({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function PopoverContent({ className, align, sideOffset, ...props }: React.ComponentProps<typeof PopoverPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function PopoverAnchor({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Anchor>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
function Popover({ ...props }) {
|
|
6
|
+
return _jsx(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
|
|
7
|
+
}
|
|
8
|
+
function PopoverTrigger({ ...props }) {
|
|
9
|
+
return _jsx(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
|
|
10
|
+
}
|
|
11
|
+
function PopoverContent({ className, align = 'center', sideOffset = 4, ...props }) {
|
|
12
|
+
return (_jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Content, { "data-slot": "popover-content", align: align, sideOffset: sideOffset, className: cn('bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden', className), ...props }) }));
|
|
13
|
+
}
|
|
14
|
+
function PopoverAnchor({ ...props }) {
|
|
15
|
+
return _jsx(PopoverPrimitive.Anchor, { "data-slot": "popover-anchor", ...props });
|
|
16
|
+
}
|
|
17
|
+
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
3
|
+
declare function Separator({ className, orientation, decorative, ...props }: React.ComponentProps<typeof SeparatorPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export { Separator };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
function Separator({ className, orientation = 'horizontal', decorative = true, ...props }) {
|
|
7
|
+
return (_jsx(SeparatorPrimitive.Root, { "data-slot": "separator-root", decorative: decorative, orientation: orientation, className: cn('bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px', className), ...props }));
|
|
8
|
+
}
|
|
9
|
+
export { Separator };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as SheetPrimitive from '@radix-ui/react-dialog';
|
|
3
|
+
declare function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function SheetTrigger({ ...props }: React.ComponentProps<typeof SheetPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function SheetClose({ ...props }: React.ComponentProps<typeof SheetPrimitive.Close>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function SheetContent({ className, children, side, ...props }: React.ComponentProps<typeof SheetPrimitive.Content> & {
|
|
7
|
+
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare function SheetHeader({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
declare function SheetFooter({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare function SheetTitle({ className, ...props }: React.ComponentProps<typeof SheetPrimitive.Title>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
declare function SheetDescription({ className, ...props }: React.ComponentProps<typeof SheetPrimitive.Description>): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export { Sheet, SheetTrigger, SheetClose, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription, };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as SheetPrimitive from '@radix-ui/react-dialog';
|
|
4
|
+
import { XIcon } from 'lucide-react';
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
function Sheet({ ...props }) {
|
|
7
|
+
return _jsx(SheetPrimitive.Root, { "data-slot": "sheet", ...props });
|
|
8
|
+
}
|
|
9
|
+
function SheetTrigger({ ...props }) {
|
|
10
|
+
return _jsx(SheetPrimitive.Trigger, { "data-slot": "sheet-trigger", ...props });
|
|
11
|
+
}
|
|
12
|
+
function SheetClose({ ...props }) {
|
|
13
|
+
return _jsx(SheetPrimitive.Close, { "data-slot": "sheet-close", ...props });
|
|
14
|
+
}
|
|
15
|
+
function SheetPortal({ ...props }) {
|
|
16
|
+
return _jsx(SheetPrimitive.Portal, { "data-slot": "sheet-portal", ...props });
|
|
17
|
+
}
|
|
18
|
+
function SheetOverlay({ className, ...props }) {
|
|
19
|
+
return (_jsx(SheetPrimitive.Overlay, { "data-slot": "sheet-overlay", className: cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50', className), ...props }));
|
|
20
|
+
}
|
|
21
|
+
function SheetContent({ className, children, side = 'right', ...props }) {
|
|
22
|
+
return (_jsxs(SheetPortal, { children: [_jsx(SheetOverlay, {}), _jsxs(SheetPrimitive.Content, { "data-slot": "sheet-content", className: cn('bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500', side === 'right' &&
|
|
23
|
+
'data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm', side === 'left' &&
|
|
24
|
+
'data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm', side === 'top' &&
|
|
25
|
+
'data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b', side === 'bottom' &&
|
|
26
|
+
'data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t', className), ...props, children: [children, _jsxs(SheetPrimitive.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none", children: [_jsx(XIcon, { className: "size-4" }), _jsx("span", { className: "sr-only", children: "Close" })] })] })] }));
|
|
27
|
+
}
|
|
28
|
+
function SheetHeader({ className, ...props }) {
|
|
29
|
+
return (_jsx("div", { "data-slot": "sheet-header", className: cn('flex flex-col gap-1.5 p-4', className), ...props }));
|
|
30
|
+
}
|
|
31
|
+
function SheetFooter({ className, ...props }) {
|
|
32
|
+
return (_jsx("div", { "data-slot": "sheet-footer", className: cn('mt-auto flex flex-col gap-2 p-4', className), ...props }));
|
|
33
|
+
}
|
|
34
|
+
function SheetTitle({ className, ...props }) {
|
|
35
|
+
return (_jsx(SheetPrimitive.Title, { "data-slot": "sheet-title", className: cn('text-foreground font-semibold', className), ...props }));
|
|
36
|
+
}
|
|
37
|
+
function SheetDescription({ className, ...props }) {
|
|
38
|
+
return (_jsx(SheetPrimitive.Description, { "data-slot": "sheet-description", className: cn('text-muted-foreground text-sm', className), ...props }));
|
|
39
|
+
}
|
|
40
|
+
export { Sheet, SheetTrigger, SheetClose, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription, };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../../lib/utils';
|
|
3
|
+
function Skeleton({ className, ...props }) {
|
|
4
|
+
return (_jsx("div", { "data-slot": "skeleton", className: cn('bg-accent animate-pulse rounded-md', className), ...props }));
|
|
5
|
+
}
|
|
6
|
+
export { Skeleton };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme } from 'next-themes';
|
|
3
|
+
import { Toaster as Sonner } from 'sonner';
|
|
4
|
+
const Toaster = ({ ...props }) => {
|
|
5
|
+
const { theme = 'system' } = useTheme();
|
|
6
|
+
return (_jsx(Sonner, { theme: theme, className: "toaster group", style: {
|
|
7
|
+
'--normal-bg': 'var(--popover)',
|
|
8
|
+
'--normal-text': 'var(--popover-foreground)',
|
|
9
|
+
'--normal-border': 'var(--border)',
|
|
10
|
+
}, ...props }));
|
|
11
|
+
};
|
|
12
|
+
export { Toaster };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
function Switch({ className, ...props }) {
|
|
6
|
+
return (_jsx(SwitchPrimitive.Root, { "data-slot": "switch", className: cn('peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 border-1 border-gray-500/30', className), ...props, children: _jsx(SwitchPrimitive.Thumb, { "data-slot": "switch-thumb", className: cn('bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0') }) }));
|
|
7
|
+
}
|
|
8
|
+
export { Switch };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
declare function Table({ className, ...props }: React.ComponentProps<'table'>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare function TableHeader({ className, ...props }: React.ComponentProps<'thead'>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function TableBody({ className, ...props }: React.ComponentProps<'tbody'>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function TableFooter({ className, ...props }: React.ComponentProps<'tfoot'>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function TableRow({ className, ...props }: React.ComponentProps<'tr'>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare function TableHead({ className, ...props }: React.ComponentProps<'th'>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare function TableCell({ className, ...props }: React.ComponentProps<'td'>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare function TableCaption({ className, ...props }: React.ComponentProps<'caption'>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { cn } from '../../lib/utils';
|
|
4
|
+
function Table({ className, ...props }) {
|
|
5
|
+
return (_jsx("div", { "data-slot": "table-container", className: "relative w-full overflow-x-auto", children: _jsx("table", { "data-slot": "table", className: cn('w-full caption-bottom text-sm', className), ...props }) }));
|
|
6
|
+
}
|
|
7
|
+
function TableHeader({ className, ...props }) {
|
|
8
|
+
return (_jsx("thead", { "data-slot": "table-header", className: cn('[&_tr]:border-b', className), ...props }));
|
|
9
|
+
}
|
|
10
|
+
function TableBody({ className, ...props }) {
|
|
11
|
+
return (_jsx("tbody", { "data-slot": "table-body", className: cn('[&_tr:last-child]:border-0', className), ...props }));
|
|
12
|
+
}
|
|
13
|
+
function TableFooter({ className, ...props }) {
|
|
14
|
+
return (_jsx("tfoot", { "data-slot": "table-footer", className: cn('bg-muted/50 border-t font-medium [&>tr]:last:border-b-0', className), ...props }));
|
|
15
|
+
}
|
|
16
|
+
function TableRow({ className, ...props }) {
|
|
17
|
+
return (_jsx("tr", { "data-slot": "table-row", className: cn('hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors', className), ...props }));
|
|
18
|
+
}
|
|
19
|
+
function TableHead({ className, ...props }) {
|
|
20
|
+
return (_jsx("th", { "data-slot": "table-head", className: cn('text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]', className), ...props }));
|
|
21
|
+
}
|
|
22
|
+
function TableCell({ className, ...props }) {
|
|
23
|
+
return (_jsx("td", { "data-slot": "table-cell", className: cn('p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]', className), ...props }));
|
|
24
|
+
}
|
|
25
|
+
function TableCaption({ className, ...props }) {
|
|
26
|
+
return (_jsx("caption", { "data-slot": "table-caption", className: cn('text-muted-foreground mt-4 text-sm', className), ...props }));
|
|
27
|
+
}
|
|
28
|
+
export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
3
|
+
declare function Tabs({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function TabsList({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.List>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function TabsTrigger({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function TabsContent({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
function Tabs({ className, ...props }) {
|
|
6
|
+
return (_jsx(TabsPrimitive.Root, { "data-slot": "tabs", className: cn('flex flex-col gap-2', className), ...props }));
|
|
7
|
+
}
|
|
8
|
+
function TabsList({ className, ...props }) {
|
|
9
|
+
return (_jsx(TabsPrimitive.List, { "data-slot": "tabs-list", className: cn('bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]', className), ...props }));
|
|
10
|
+
}
|
|
11
|
+
function TabsTrigger({ className, ...props }) {
|
|
12
|
+
return (_jsx(TabsPrimitive.Trigger, { "data-slot": "tabs-trigger", className: cn("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className), ...props }));
|
|
13
|
+
}
|
|
14
|
+
function TabsContent({ className, ...props }) {
|
|
15
|
+
return (_jsx(TabsPrimitive.Content, { "data-slot": "tabs-content", className: cn('flex-1 outline-none', className), ...props }));
|
|
16
|
+
}
|
|
17
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
|
|
3
|
+
import { toggleVariants } from './toggle';
|
|
4
|
+
import type { VariantProps } from 'class-variance-authority';
|
|
5
|
+
declare function ToggleGroup({ className, variant, size, children, ...props }: React.ComponentProps<typeof ToggleGroupPrimitive.Root> & VariantProps<typeof toggleVariants>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function ToggleGroupItem({ className, children, variant, size, ...props }: React.ComponentProps<typeof ToggleGroupPrimitive.Item> & VariantProps<typeof toggleVariants>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export { ToggleGroup, ToggleGroupItem };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
import { toggleVariants } from './toggle';
|
|
6
|
+
const ToggleGroupContext = React.createContext({
|
|
7
|
+
size: 'default',
|
|
8
|
+
variant: 'default',
|
|
9
|
+
});
|
|
10
|
+
function ToggleGroup({ className, variant, size, children, ...props }) {
|
|
11
|
+
return (_jsx(ToggleGroupPrimitive.Root, { "data-slot": "toggle-group", "data-variant": variant, "data-size": size, className: cn('group/toggle-group flex w-fit items-center rounded-md data-[variant=outline]:shadow-xs', className), ...props, children: _jsx(ToggleGroupContext.Provider, { value: { variant, size }, children: children }) }));
|
|
12
|
+
}
|
|
13
|
+
function ToggleGroupItem({ className, children, variant, size, ...props }) {
|
|
14
|
+
const context = React.useContext(ToggleGroupContext);
|
|
15
|
+
return (_jsx(ToggleGroupPrimitive.Item, { "data-slot": "toggle-group-item", "data-variant": context.variant || variant, "data-size": context.size || size, className: cn(toggleVariants({
|
|
16
|
+
variant: context.variant || variant,
|
|
17
|
+
size: context.size || size,
|
|
18
|
+
}), 'min-w-0 flex-1 shrink-0 rounded-none shadow-none first:rounded-l-md last:rounded-r-md focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0 data-[variant=outline]:first:border-l', className), ...props, children: children }));
|
|
19
|
+
}
|
|
20
|
+
export { ToggleGroup, ToggleGroupItem };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as TogglePrimitive from '@radix-ui/react-toggle';
|
|
3
|
+
import type { VariantProps } from 'class-variance-authority';
|
|
4
|
+
declare const toggleVariants: (props?: ({
|
|
5
|
+
variant?: "default" | "outline" | null | undefined;
|
|
6
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
7
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
|
+
declare function Toggle({ className, variant, size, ...props }: React.ComponentProps<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export { Toggle, toggleVariants };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as TogglePrimitive from '@radix-ui/react-toggle';
|
|
5
|
+
import { cva } from 'class-variance-authority';
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
7
|
+
const toggleVariants = cva("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap", {
|
|
8
|
+
variants: {
|
|
9
|
+
variant: {
|
|
10
|
+
default: 'bg-transparent',
|
|
11
|
+
outline: 'border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground',
|
|
12
|
+
},
|
|
13
|
+
size: {
|
|
14
|
+
default: 'h-9 px-2 min-w-9',
|
|
15
|
+
sm: 'h-8 px-1.5 min-w-8',
|
|
16
|
+
lg: 'h-10 px-2.5 min-w-10',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
variant: 'default',
|
|
21
|
+
size: 'default',
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
function Toggle({ className, variant, size, ...props }) {
|
|
25
|
+
return (_jsx(TogglePrimitive.Root, { "data-slot": "toggle", className: cn(toggleVariants({ variant, size, className })), ...props }));
|
|
26
|
+
}
|
|
27
|
+
export { Toggle, toggleVariants };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
3
|
+
declare function TooltipProvider({ delayDuration, ...props }: React.ComponentProps<typeof TooltipPrimitive.Provider>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function Tooltip({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function TooltipTrigger({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function TooltipContent({ className, sideOffset, children, ...props }: React.ComponentProps<typeof TooltipPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
function TooltipProvider({ delayDuration = 0, ...props }) {
|
|
7
|
+
return (_jsx(TooltipPrimitive.Provider, { "data-slot": "tooltip-provider", delayDuration: delayDuration, ...props }));
|
|
8
|
+
}
|
|
9
|
+
function Tooltip({ ...props }) {
|
|
10
|
+
return (_jsx(TooltipProvider, { children: _jsx(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props }) }));
|
|
11
|
+
}
|
|
12
|
+
function TooltipTrigger({ ...props }) {
|
|
13
|
+
return _jsx(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
|
|
14
|
+
}
|
|
15
|
+
function TooltipContent({ className, sideOffset = 0, children, ...props }) {
|
|
16
|
+
return (_jsx(TooltipPrimitive.Portal, { children: _jsxs(TooltipPrimitive.Content, { "data-slot": "tooltip-content", sideOffset: sideOffset, className: cn('bg-primary text-primary-foreground 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance', className), ...props, children: [children, _jsx(TooltipPrimitive.Arrow, { className: "bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })] }) }));
|
|
17
|
+
}
|
|
18
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface TreeDataItem {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
icon?: any;
|
|
6
|
+
selectedIcon?: any;
|
|
7
|
+
openIcon?: any;
|
|
8
|
+
children?: Array<TreeDataItem>;
|
|
9
|
+
actions?: React.ReactNode;
|
|
10
|
+
onClick?: () => void;
|
|
11
|
+
draggable?: boolean;
|
|
12
|
+
droppable?: boolean;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
declare const TreeView: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
16
|
+
data: Array<TreeDataItem> | TreeDataItem;
|
|
17
|
+
initialSelectedItemId?: string;
|
|
18
|
+
onSelectChange?: (item: TreeDataItem | undefined) => void;
|
|
19
|
+
expandAll?: boolean;
|
|
20
|
+
initialExpandedItemIds?: Array<string>;
|
|
21
|
+
defaultNodeIcon?: any;
|
|
22
|
+
defaultLeafIcon?: any;
|
|
23
|
+
onDocumentDrag?: (sourceItem: TreeDataItem, targetItem: TreeDataItem) => void;
|
|
24
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
25
|
+
export { TreeView, type TreeDataItem };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
4
|
+
import { ChevronRight } from 'lucide-react';
|
|
5
|
+
import { cva } from 'class-variance-authority';
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
7
|
+
const treeVariants = cva('group hover:before:opacity-100 before:absolute before:rounded-lg before:left-0 px-2 before:w-full before:opacity-0 before:bg-accent/70 before:h-[2rem] before:-z-10');
|
|
8
|
+
const selectedTreeVariants = cva('before:opacity-100 before:bg-accent/70 text-accent-foreground');
|
|
9
|
+
const dragOverVariants = cva('before:opacity-100 before:bg-primary/20 text-primary-foreground');
|
|
10
|
+
const TreeView = React.forwardRef(({ data, initialSelectedItemId, onSelectChange, expandAll, initialExpandedItemIds, defaultLeafIcon, defaultNodeIcon, className, onDocumentDrag, ...props }, ref) => {
|
|
11
|
+
const [selectedItemId, setSelectedItemId] = React.useState(initialSelectedItemId);
|
|
12
|
+
const [draggedItem, setDraggedItem] = React.useState(null);
|
|
13
|
+
const handleSelectChange = React.useCallback((item) => {
|
|
14
|
+
setSelectedItemId(item?.id);
|
|
15
|
+
if (onSelectChange) {
|
|
16
|
+
onSelectChange(item);
|
|
17
|
+
}
|
|
18
|
+
}, [onSelectChange]);
|
|
19
|
+
const handleDragStart = React.useCallback((item) => {
|
|
20
|
+
setDraggedItem(item);
|
|
21
|
+
}, []);
|
|
22
|
+
const handleDrop = React.useCallback((targetItem) => {
|
|
23
|
+
if (draggedItem && onDocumentDrag && draggedItem.id !== targetItem.id) {
|
|
24
|
+
onDocumentDrag(draggedItem, targetItem);
|
|
25
|
+
}
|
|
26
|
+
setDraggedItem(null);
|
|
27
|
+
}, [draggedItem, onDocumentDrag]);
|
|
28
|
+
const expandedItemIds = React.useMemo(() => {
|
|
29
|
+
if (initialExpandedItemIds) {
|
|
30
|
+
return initialExpandedItemIds;
|
|
31
|
+
}
|
|
32
|
+
if (!initialSelectedItemId && !expandAll) {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
const ids = [];
|
|
36
|
+
function walkTreeItems(items, targetId) {
|
|
37
|
+
if (items instanceof Array) {
|
|
38
|
+
for (let i = 0; i < items.length; i++) {
|
|
39
|
+
ids.push(items[i].id);
|
|
40
|
+
if (walkTreeItems(items[i], targetId) && !expandAll) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
if (!expandAll)
|
|
44
|
+
ids.pop();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else if (!expandAll && items.id === targetId) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
else if (items.children) {
|
|
51
|
+
return walkTreeItems(items.children, targetId);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
walkTreeItems(data, initialSelectedItemId ?? '');
|
|
55
|
+
return ids;
|
|
56
|
+
}, [data, expandAll, initialSelectedItemId, initialExpandedItemIds]);
|
|
57
|
+
return (_jsxs("div", { className: cn('overflow-hidden relative p-2', className), children: [_jsx(TreeItem, { data: data, ref: ref, selectedItemId: selectedItemId, handleSelectChange: handleSelectChange, expandedItemIds: expandedItemIds, defaultLeafIcon: defaultLeafIcon, defaultNodeIcon: defaultNodeIcon, handleDragStart: handleDragStart, handleDrop: handleDrop, draggedItem: draggedItem, ...props }), _jsx("div", { className: "w-full h-[48px]", onDrop: () => {
|
|
58
|
+
handleDrop({ id: '', name: 'parent_div' });
|
|
59
|
+
} })] }));
|
|
60
|
+
});
|
|
61
|
+
TreeView.displayName = 'TreeView';
|
|
62
|
+
const TreeItem = React.forwardRef(({ className, data, selectedItemId, handleSelectChange, expandedItemIds, defaultNodeIcon, defaultLeafIcon, handleDragStart, handleDrop, draggedItem, ...props }, ref) => {
|
|
63
|
+
if (!(data instanceof Array)) {
|
|
64
|
+
data = [data];
|
|
65
|
+
}
|
|
66
|
+
return (_jsx("div", { ref: ref, role: "tree", className: className, ...props, children: _jsx("ul", { children: data.map((item) => (_jsx("li", { children: item.children ? (_jsx(TreeNode, { item: item, selectedItemId: selectedItemId, expandedItemIds: expandedItemIds, handleSelectChange: handleSelectChange, defaultNodeIcon: defaultNodeIcon, defaultLeafIcon: defaultLeafIcon, handleDragStart: handleDragStart, handleDrop: handleDrop, draggedItem: draggedItem })) : (_jsx(TreeLeaf, { item: item, selectedItemId: selectedItemId, handleSelectChange: handleSelectChange, defaultLeafIcon: defaultLeafIcon, handleDragStart: handleDragStart, handleDrop: handleDrop, draggedItem: draggedItem, className: item.className })) }, item.id))) }) }));
|
|
67
|
+
});
|
|
68
|
+
TreeItem.displayName = 'TreeItem';
|
|
69
|
+
const TreeNode = ({ item, handleSelectChange, expandedItemIds, selectedItemId, defaultNodeIcon, defaultLeafIcon, handleDragStart, handleDrop, draggedItem, }) => {
|
|
70
|
+
const [value, setValue] = React.useState(expandedItemIds.includes(item.id) ? [item.id] : []);
|
|
71
|
+
const [isDragOver, setIsDragOver] = React.useState(false);
|
|
72
|
+
const onDragStart = (e) => {
|
|
73
|
+
if (!item.draggable) {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
e.dataTransfer.setData('text/plain', item.id);
|
|
78
|
+
handleDragStart?.(item);
|
|
79
|
+
};
|
|
80
|
+
const onDragOver = (e) => {
|
|
81
|
+
if (item.droppable !== false && draggedItem && draggedItem.id !== item.id) {
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
setIsDragOver(true);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const onDragLeave = () => {
|
|
87
|
+
setIsDragOver(false);
|
|
88
|
+
};
|
|
89
|
+
const onDrop = (e) => {
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
setIsDragOver(false);
|
|
92
|
+
handleDrop?.(item);
|
|
93
|
+
};
|
|
94
|
+
return (_jsx(AccordionPrimitive.Root, { type: "multiple", value: value, onValueChange: (s) => setValue(s), children: _jsxs(AccordionPrimitive.Item, { value: item.id, children: [_jsxs(AccordionTrigger, { className: cn(treeVariants(), selectedItemId === item.id && selectedTreeVariants(), isDragOver && dragOverVariants()), onClick: () => {
|
|
95
|
+
handleSelectChange(item);
|
|
96
|
+
item.onClick?.();
|
|
97
|
+
}, draggable: !!item.draggable, onDragStart: onDragStart, onDragOver: onDragOver, onDragLeave: onDragLeave, onDrop: onDrop, children: [_jsx(TreeIcon, { item: item, isSelected: selectedItemId === item.id, isOpen: value.includes(item.id), default: defaultNodeIcon }), _jsx("span", { className: "text-md truncate", children: item.name }), _jsx(TreeActions, { isSelected: selectedItemId === item.id, children: item.actions })] }), _jsx(AccordionContent, { className: "ml-4 pl-1 border-l", children: _jsx(TreeItem, { data: item.children ? item.children : item, selectedItemId: selectedItemId, handleSelectChange: handleSelectChange, expandedItemIds: expandedItemIds, defaultLeafIcon: defaultLeafIcon, defaultNodeIcon: defaultNodeIcon, handleDragStart: handleDragStart, handleDrop: handleDrop, draggedItem: draggedItem }) })] }) }));
|
|
98
|
+
};
|
|
99
|
+
const TreeLeaf = React.forwardRef(({ className, item, selectedItemId, handleSelectChange, defaultLeafIcon, handleDragStart, handleDrop, draggedItem, ...props }, ref) => {
|
|
100
|
+
const [isDragOver, setIsDragOver] = React.useState(false);
|
|
101
|
+
const onDragStart = (e) => {
|
|
102
|
+
if (!item.draggable) {
|
|
103
|
+
e.preventDefault();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
e.dataTransfer.setData('text/plain', item.id);
|
|
107
|
+
handleDragStart?.(item);
|
|
108
|
+
};
|
|
109
|
+
const onDragOver = (e) => {
|
|
110
|
+
if (item.droppable !== false &&
|
|
111
|
+
draggedItem &&
|
|
112
|
+
draggedItem.id !== item.id) {
|
|
113
|
+
e.preventDefault();
|
|
114
|
+
setIsDragOver(true);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const onDragLeave = () => {
|
|
118
|
+
setIsDragOver(false);
|
|
119
|
+
};
|
|
120
|
+
const onDrop = (e) => {
|
|
121
|
+
e.preventDefault();
|
|
122
|
+
setIsDragOver(false);
|
|
123
|
+
handleDrop?.(item);
|
|
124
|
+
};
|
|
125
|
+
return (_jsxs("div", { ref: ref, className: cn('ml-5 flex text-left items-center py-2 cursor-pointer before:right-1', treeVariants(), className, selectedItemId === item.id && selectedTreeVariants(), isDragOver && dragOverVariants()), onClick: () => {
|
|
126
|
+
handleSelectChange(item);
|
|
127
|
+
item.onClick?.();
|
|
128
|
+
}, draggable: !!item.draggable, onDragStart: onDragStart, onDragOver: onDragOver, onDragLeave: onDragLeave, onDrop: onDrop, ...props, children: [_jsx(TreeIcon, { item: item, isSelected: selectedItemId === item.id, default: defaultLeafIcon }), _jsx("span", { className: "flex-grow text-md truncate", children: item.name }), _jsx(TreeActions, { isSelected: selectedItemId === item.id, children: item.actions })] }));
|
|
129
|
+
});
|
|
130
|
+
TreeLeaf.displayName = 'TreeLeaf';
|
|
131
|
+
const AccordionTrigger = React.forwardRef(({ className, children, ...props }, ref) => (_jsx(AccordionPrimitive.Header, { children: _jsxs(AccordionPrimitive.Trigger, { ref: ref, className: cn('flex flex-1 w-full items-center py-2 transition-all first:[&[data-state=open]>svg]:rotate-90', className), ...props, children: [_jsx(ChevronRight, { className: "h-4 w-4 shrink-0 transition-transform duration-200 text-accent-foreground/50 mr-1" }), children] }) })));
|
|
132
|
+
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
|
|
133
|
+
const AccordionContent = React.forwardRef(({ className, children, ...props }, ref) => (_jsx(AccordionPrimitive.Content, { ref: ref, className: cn('overflow-hidden text-md transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down', className), ...props, children: _jsx("div", { className: "pb-1 pt-0", children: children }) })));
|
|
134
|
+
AccordionContent.displayName = AccordionPrimitive.Content.displayName;
|
|
135
|
+
const TreeIcon = ({ item, isOpen, isSelected, default: defaultIcon, }) => {
|
|
136
|
+
let Icon = defaultIcon;
|
|
137
|
+
if (isSelected && item.selectedIcon) {
|
|
138
|
+
Icon = item.selectedIcon;
|
|
139
|
+
}
|
|
140
|
+
else if (isOpen && item.openIcon) {
|
|
141
|
+
Icon = item.openIcon;
|
|
142
|
+
}
|
|
143
|
+
else if (item.icon) {
|
|
144
|
+
Icon = item.icon;
|
|
145
|
+
}
|
|
146
|
+
return Icon ? _jsx(Icon, { className: "h-4 w-4 shrink-0 mr-2" }) : _jsx(_Fragment, {});
|
|
147
|
+
};
|
|
148
|
+
const TreeActions = ({ children, isSelected, }) => {
|
|
149
|
+
return (_jsx("div", { className: cn(isSelected ? 'block' : 'hidden', 'absolute right-3 group-hover:block'), children: children }));
|
|
150
|
+
};
|
|
151
|
+
export { TreeView };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FileClass } from './types';
|
|
2
|
+
export declare const twClasses: Record<FileClass, string>;
|
|
3
|
+
export type FileClassAndInfo = {
|
|
4
|
+
fileClass: FileClass;
|
|
5
|
+
originalFile?: string;
|
|
6
|
+
modifiedFile?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const getFileClass: (file: string, tree: Record<string, string>, originalTree: Record<string, string>, localTree: Record<string, string>, deletedFiles: Array<string>) => FileClassAndInfo;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const twClasses = {
|
|
2
|
+
unchanged: 'text-gray-500',
|
|
3
|
+
added: 'text-green-500 font-bold',
|
|
4
|
+
modified: 'text-blue-500 italic',
|
|
5
|
+
deleted: 'text-red-500 line-through',
|
|
6
|
+
overwritten: 'text-red-700 underline',
|
|
7
|
+
};
|
|
8
|
+
export const getFileClass = (file, tree, originalTree, localTree, deletedFiles) => {
|
|
9
|
+
if (localTree[file]) {
|
|
10
|
+
if (deletedFiles.includes(file)) {
|
|
11
|
+
return { fileClass: 'deleted', originalFile: localTree[file] };
|
|
12
|
+
}
|
|
13
|
+
// We have a local file and it's in the new tree
|
|
14
|
+
if (tree[file]) {
|
|
15
|
+
// Our new tree has changed this file
|
|
16
|
+
if (localTree[file] !== tree[file]) {
|
|
17
|
+
// Was the local tree different from the original?
|
|
18
|
+
if (originalTree[file] && localTree[file] !== originalTree[file]) {
|
|
19
|
+
// Yes, it was overwritten
|
|
20
|
+
return {
|
|
21
|
+
fileClass: 'overwritten',
|
|
22
|
+
originalFile: localTree[file],
|
|
23
|
+
modifiedFile: tree[file],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
// No, it just being modified
|
|
28
|
+
return {
|
|
29
|
+
fileClass: 'modified',
|
|
30
|
+
originalFile: localTree[file],
|
|
31
|
+
modifiedFile: tree[file],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return { fileClass: 'unchanged', modifiedFile: localTree[file] };
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return { fileClass: 'added', modifiedFile: tree[file] };
|
|
40
|
+
}
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useMounted(): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Hook that returns the user's preference for reduced motion.
|
|
4
|
+
* @returns null if the value is not yet determined or the user's preference for reduced motion.
|
|
5
|
+
*/
|
|
6
|
+
export const usePrefersReducedMotion = () => {
|
|
7
|
+
const [prefersReducedMotion, setPrefersReducedMotion] = React.useState(null);
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
const mediaQueryList = window.matchMedia('(prefers-reduced-motion: reduce)');
|
|
10
|
+
setPrefersReducedMotion(mediaQueryList.matches);
|
|
11
|
+
const listener = (event) => {
|
|
12
|
+
setPrefersReducedMotion(event.matches);
|
|
13
|
+
};
|
|
14
|
+
mediaQueryList.addEventListener('change', listener);
|
|
15
|
+
return () => {
|
|
16
|
+
mediaQueryList.removeEventListener('change', listener);
|
|
17
|
+
};
|
|
18
|
+
}, []);
|
|
19
|
+
return prefersReducedMotion;
|
|
20
|
+
};
|