@health-samurai/react-components 0.0.0-alpha.3 → 0.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.css +687 -446
- package/dist/src/components/code-editor/http/grammar/http.d.ts +3 -0
- package/dist/src/components/code-editor/http/grammar/http.d.ts.map +1 -0
- package/dist/src/components/code-editor/http/grammar/http.grammar +74 -0
- package/dist/src/components/code-editor/http/grammar/http.js +38 -0
- package/dist/src/components/code-editor/http/grammar/http.js.map +1 -0
- package/dist/src/components/code-editor/http/grammar/http.terms.d.ts +2 -0
- package/dist/src/components/code-editor/http/grammar/http.terms.d.ts.map +1 -0
- package/dist/src/components/code-editor/http/grammar/http.terms.js +4 -0
- package/dist/src/components/code-editor/http/grammar/http.terms.js.map +1 -0
- package/dist/src/components/code-editor/http/grammar/http.test.d.ts +2 -0
- package/dist/src/components/code-editor/http/grammar/http.test.d.ts.map +1 -0
- package/dist/src/components/code-editor/http/grammar/http.test.js +80 -0
- package/dist/src/components/code-editor/http/grammar/http.test.js.map +1 -0
- package/dist/src/components/code-editor/http/index.d.ts +4 -0
- package/dist/src/components/code-editor/http/index.d.ts.map +1 -0
- package/dist/src/components/code-editor/http/index.js +66 -0
- package/dist/src/components/code-editor/http/index.js.map +1 -0
- package/dist/src/components/code-editor/index.d.ts +13 -2
- package/dist/src/components/code-editor/index.d.ts.map +1 -1
- package/dist/src/components/code-editor/index.js +161 -20
- package/dist/src/components/code-editor/index.js.map +1 -1
- package/dist/src/components/code-editor.stories.js +3 -1
- package/dist/src/components/code-editor.stories.js.map +1 -1
- package/dist/src/components/request-line-editor.d.ts +11 -35
- package/dist/src/components/request-line-editor.d.ts.map +1 -1
- package/dist/src/components/request-line-editor.js +51 -49
- package/dist/src/components/request-line-editor.js.map +1 -1
- package/dist/src/components/request-line-editor.stories.d.ts.map +1 -1
- package/dist/src/components/request-line-editor.stories.js +17 -53
- package/dist/src/components/request-line-editor.stories.js.map +1 -1
- package/dist/src/components/tree-view.d.ts +16 -0
- package/dist/src/components/tree-view.d.ts.map +1 -0
- package/dist/src/components/tree-view.js +67 -0
- package/dist/src/components/tree-view.js.map +1 -0
- package/dist/src/components/tree-view.stories.d.ts +13 -0
- package/dist/src/components/tree-view.stories.d.ts.map +1 -0
- package/dist/src/components/tree-view.stories.js +274 -0
- package/dist/src/components/tree-view.stories.js.map +1 -0
- package/dist/src/icons.d.ts +3 -0
- package/dist/src/icons.d.ts.map +1 -0
- package/dist/src/icons.js +47 -0
- package/dist/src/icons.js.map +1 -0
- package/dist/src/index.css +42 -3
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/shadcn/components/ui/accordion.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/accordion.js +23 -5
- package/dist/src/shadcn/components/ui/accordion.js.map +1 -1
- package/dist/src/shadcn/components/ui/alert.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/alert.js +12 -5
- package/dist/src/shadcn/components/ui/alert.js.map +1 -1
- package/dist/src/shadcn/components/ui/avatar.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/avatar.js +4 -3
- package/dist/src/shadcn/components/ui/avatar.js.map +1 -1
- package/dist/src/shadcn/components/ui/badge.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/badge.js +16 -5
- package/dist/src/shadcn/components/ui/badge.js.map +1 -1
- package/dist/src/shadcn/components/ui/breadcrumb.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/breadcrumb.js +6 -6
- package/dist/src/shadcn/components/ui/breadcrumb.js.map +1 -1
- package/dist/src/shadcn/components/ui/button.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/button.js +19 -11
- package/dist/src/shadcn/components/ui/button.js.map +1 -1
- package/dist/src/shadcn/components/ui/card.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/card.js +14 -6
- package/dist/src/shadcn/components/ui/card.js.map +1 -1
- package/dist/src/shadcn/components/ui/carousel.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/carousel.js +1 -0
- package/dist/src/shadcn/components/ui/carousel.js.map +1 -1
- package/dist/src/shadcn/components/ui/checkbox.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/checkbox.js +20 -5
- package/dist/src/shadcn/components/ui/checkbox.js.map +1 -1
- package/dist/src/shadcn/components/ui/checkbox.stories.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/checkbox.stories.js +44 -35
- package/dist/src/shadcn/components/ui/checkbox.stories.js.map +1 -1
- package/dist/src/shadcn/components/ui/combobox.d.ts +18 -0
- package/dist/src/shadcn/components/ui/combobox.d.ts.map +1 -0
- package/dist/src/shadcn/components/ui/combobox.js +121 -0
- package/dist/src/shadcn/components/ui/combobox.js.map +1 -0
- package/dist/src/shadcn/components/ui/combobox.stories.d.ts +11 -0
- package/dist/src/shadcn/components/ui/combobox.stories.d.ts.map +1 -0
- package/dist/src/shadcn/components/ui/combobox.stories.js +16 -0
- package/dist/src/shadcn/components/ui/combobox.stories.js.map +1 -0
- package/dist/src/shadcn/components/ui/command.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/command.js +73 -12
- package/dist/src/shadcn/components/ui/command.js.map +1 -1
- package/dist/src/shadcn/components/ui/command.stories.js +0 -1
- package/dist/src/shadcn/components/ui/command.stories.js.map +1 -1
- package/dist/src/shadcn/components/ui/dialog.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/dialog.js +35 -7
- package/dist/src/shadcn/components/ui/dialog.js.map +1 -1
- package/dist/src/shadcn/components/ui/drawer.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/drawer.js +26 -5
- package/dist/src/shadcn/components/ui/drawer.js.map +1 -1
- package/dist/src/shadcn/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/dropdown-menu.js +12 -1
- package/dist/src/shadcn/components/ui/dropdown-menu.js.map +1 -1
- package/dist/src/shadcn/components/ui/form.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/form.js +12 -4
- package/dist/src/shadcn/components/ui/form.js.map +1 -1
- package/dist/src/shadcn/components/ui/input-otp.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/input-otp.js +1 -0
- package/dist/src/shadcn/components/ui/input-otp.js.map +1 -1
- package/dist/src/shadcn/components/ui/input.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/input.js +87 -16
- package/dist/src/shadcn/components/ui/input.js.map +1 -1
- package/dist/src/shadcn/components/ui/label.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/label.js +8 -1
- package/dist/src/shadcn/components/ui/label.js.map +1 -1
- package/dist/src/shadcn/components/ui/menubar.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/menubar.js +35 -13
- package/dist/src/shadcn/components/ui/menubar.js.map +1 -1
- package/dist/src/shadcn/components/ui/pagination.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/pagination.js +6 -6
- package/dist/src/shadcn/components/ui/pagination.js.map +1 -1
- package/dist/src/shadcn/components/ui/popover.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/popover.js +12 -1
- package/dist/src/shadcn/components/ui/popover.js.map +1 -1
- package/dist/src/shadcn/components/ui/progress.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/progress.js +6 -2
- package/dist/src/shadcn/components/ui/progress.js.map +1 -1
- package/dist/src/shadcn/components/ui/radio-group.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/radio-group.js +11 -6
- package/dist/src/shadcn/components/ui/radio-group.js.map +1 -1
- package/dist/src/shadcn/components/ui/radio-group.stories.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/radio-group.stories.js +57 -34
- package/dist/src/shadcn/components/ui/radio-group.stories.js.map +1 -1
- package/dist/src/shadcn/components/ui/resizable.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/resizable.js +1 -0
- package/dist/src/shadcn/components/ui/resizable.js.map +1 -1
- package/dist/src/shadcn/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/scroll-area.js +9 -3
- package/dist/src/shadcn/components/ui/scroll-area.js.map +1 -1
- package/dist/src/shadcn/components/ui/select.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/select.js +49 -14
- package/dist/src/shadcn/components/ui/select.js.map +1 -1
- package/dist/src/shadcn/components/ui/select.stories.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/select.stories.js +1 -4
- package/dist/src/shadcn/components/ui/select.stories.js.map +1 -1
- package/dist/src/shadcn/components/ui/separator.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/separator.js +7 -1
- package/dist/src/shadcn/components/ui/separator.js.map +1 -1
- package/dist/src/shadcn/components/ui/sidebar.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/sidebar.js +20 -6
- package/dist/src/shadcn/components/ui/sidebar.js.map +1 -1
- package/dist/src/shadcn/components/ui/skeleton.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/skeleton.js +3 -1
- package/dist/src/shadcn/components/ui/skeleton.js.map +1 -1
- package/dist/src/shadcn/components/ui/slider.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/slider.js +34 -4
- package/dist/src/shadcn/components/ui/slider.js.map +1 -1
- package/dist/src/shadcn/components/ui/sonner.d.ts +16 -1
- package/dist/src/shadcn/components/ui/sonner.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/sonner.js +23 -3
- package/dist/src/shadcn/components/ui/sonner.js.map +1 -1
- package/dist/src/shadcn/components/ui/sonner.stories.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/sonner.stories.js +19 -11
- package/dist/src/shadcn/components/ui/sonner.stories.js.map +1 -1
- package/dist/src/shadcn/components/ui/switch.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/switch.js +18 -2
- package/dist/src/shadcn/components/ui/switch.js.map +1 -1
- package/dist/src/shadcn/components/ui/table.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/table.js +12 -8
- package/dist/src/shadcn/components/ui/table.js.map +1 -1
- package/dist/src/shadcn/components/ui/tabs.d.ts +21 -3
- package/dist/src/shadcn/components/ui/tabs.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/tabs.js +314 -9
- package/dist/src/shadcn/components/ui/tabs.js.map +1 -1
- package/dist/src/shadcn/components/ui/tabs.stories.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/tabs.stories.js +50 -1
- package/dist/src/shadcn/components/ui/tabs.stories.js.map +1 -1
- package/dist/src/shadcn/components/ui/textarea.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/textarea.js +15 -1
- package/dist/src/shadcn/components/ui/textarea.js.map +1 -1
- package/dist/src/shadcn/components/ui/toggle-group.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/toggle-group.js +7 -2
- package/dist/src/shadcn/components/ui/toggle-group.js.map +1 -1
- package/dist/src/shadcn/components/ui/toggle.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/toggle.js +18 -6
- package/dist/src/shadcn/components/ui/toggle.js.map +1 -1
- package/dist/src/shadcn/components/ui/tooltip.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/tooltip.js +11 -1
- package/dist/src/shadcn/components/ui/tooltip.js.map +1 -1
- package/dist/src/shadcn/components/ui/tree.d.ts +20 -0
- package/dist/src/shadcn/components/ui/tree.d.ts.map +1 -0
- package/dist/src/shadcn/components/ui/tree.js +111 -0
- package/dist/src/shadcn/components/ui/tree.js.map +1 -0
- package/package.json +9 -2
- package/src/components/code-editor/http/grammar/http.grammar +74 -0
- package/src/components/code-editor/http/grammar/http.terms.ts +9 -0
- package/src/components/code-editor/http/grammar/http.test.ts +110 -0
- package/src/components/code-editor/http/grammar/http.ts +21 -0
- package/src/components/code-editor/http/index.ts +87 -0
- package/src/components/code-editor/index.tsx +182 -21
- package/src/components/code-editor.stories.tsx +1 -1
- package/src/components/request-line-editor.stories.tsx +17 -27
- package/src/components/request-line-editor.tsx +72 -61
- package/src/components/tree-view.stories.tsx +260 -0
- package/src/components/tree-view.tsx +101 -0
- package/src/icons.tsx +45 -0
- package/src/index.css +42 -3
- package/src/index.tsx +1 -1
- package/src/shadcn/components/ui/accordion.tsx +66 -8
- package/src/shadcn/components/ui/alert.tsx +53 -15
- package/src/shadcn/components/ui/avatar.tsx +17 -6
- package/src/shadcn/components/ui/badge.tsx +67 -18
- package/src/shadcn/components/ui/breadcrumb.tsx +35 -7
- package/src/shadcn/components/ui/button.tsx +118 -57
- package/src/shadcn/components/ui/card.tsx +44 -13
- package/src/shadcn/components/ui/carousel.tsx +1 -0
- package/src/shadcn/components/ui/checkbox.stories.tsx +20 -24
- package/src/shadcn/components/ui/checkbox.tsx +45 -4
- package/src/shadcn/components/ui/combobox.stories.tsx +19 -0
- package/src/shadcn/components/ui/combobox.tsx +142 -0
- package/src/shadcn/components/ui/command.stories.tsx +1 -1
- package/src/shadcn/components/ui/command.tsx +192 -36
- package/src/shadcn/components/ui/dialog.tsx +101 -13
- package/src/shadcn/components/ui/drawer.tsx +93 -18
- package/src/shadcn/components/ui/dropdown-menu.tsx +38 -9
- package/src/shadcn/components/ui/form.tsx +16 -4
- package/src/shadcn/components/ui/input-otp.tsx +1 -0
- package/src/shadcn/components/ui/input.tsx +281 -29
- package/src/shadcn/components/ui/label.tsx +21 -4
- package/src/shadcn/components/ui/menubar.tsx +188 -43
- package/src/shadcn/components/ui/pagination.tsx +12 -6
- package/src/shadcn/components/ui/popover.tsx +35 -4
- package/src/shadcn/components/ui/progress.tsx +21 -5
- package/src/shadcn/components/ui/radio-group.stories.tsx +22 -14
- package/src/shadcn/components/ui/radio-group.tsx +42 -5
- package/src/shadcn/components/ui/resizable.tsx +1 -0
- package/src/shadcn/components/ui/scroll-area.tsx +33 -5
- package/src/shadcn/components/ui/select.stories.tsx +0 -2
- package/src/shadcn/components/ui/select.tsx +184 -33
- package/src/shadcn/components/ui/separator.tsx +15 -5
- package/src/shadcn/components/ui/sidebar.tsx +68 -26
- package/src/shadcn/components/ui/skeleton.tsx +4 -1
- package/src/shadcn/components/ui/slider.tsx +82 -11
- package/src/shadcn/components/ui/sonner.stories.tsx +19 -15
- package/src/shadcn/components/ui/sonner.tsx +53 -3
- package/src/shadcn/components/ui/switch.tsx +53 -7
- package/src/shadcn/components/ui/table.tsx +38 -11
- package/src/shadcn/components/ui/tabs.stories.tsx +32 -0
- package/src/shadcn/components/ui/tabs.tsx +455 -17
- package/src/shadcn/components/ui/textarea.tsx +42 -4
- package/src/shadcn/components/ui/toggle-group.tsx +28 -5
- package/src/shadcn/components/ui/toggle.tsx +59 -18
- package/src/shadcn/components/ui/tooltip.tsx +33 -8
- package/src/shadcn/components/ui/tree.tsx +200 -0
|
@@ -4,27 +4,68 @@ import type * as React from "react";
|
|
|
4
4
|
|
|
5
5
|
import { cn } from "#shadcn/lib/utils";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
// Base toggle styles
|
|
8
|
+
const baseToggleStyles = cn(
|
|
9
|
+
// Layout
|
|
10
|
+
"inline-flex",
|
|
11
|
+
"items-center",
|
|
12
|
+
"justify-center",
|
|
13
|
+
"gap-2",
|
|
14
|
+
"whitespace-nowrap",
|
|
15
|
+
// Shape
|
|
16
|
+
"rounded-md",
|
|
17
|
+
// Typography
|
|
18
|
+
"text-sm",
|
|
19
|
+
"font-medium",
|
|
20
|
+
// Interaction
|
|
21
|
+
"outline-none",
|
|
22
|
+
"transition-[color,box-shadow]",
|
|
23
|
+
// Hover
|
|
24
|
+
"hover:bg-bg-tertiary",
|
|
25
|
+
"hover:text-text-secondary",
|
|
26
|
+
// Pressed/On state
|
|
27
|
+
"data-[state=on]:bg-bg-secondary",
|
|
28
|
+
"data-[state=on]:text-text-primary",
|
|
29
|
+
// Disabled
|
|
30
|
+
"disabled:pointer-events-none",
|
|
31
|
+
"disabled:opacity-50",
|
|
32
|
+
// SVG icons
|
|
33
|
+
"[&_svg]:pointer-events-none",
|
|
34
|
+
"[&_svg:not([class*='size-'])]:size-4",
|
|
35
|
+
"[&_svg]:shrink-0",
|
|
36
|
+
// Focus
|
|
37
|
+
"focus-visible:ring-2",
|
|
38
|
+
"focus-visible:ring-utility-blue/70",
|
|
39
|
+
// Invalid
|
|
40
|
+
"aria-invalid:ring-2",
|
|
41
|
+
"aria-invalid:ring-utility-red/70",
|
|
42
|
+
"aria-invalid:border-border-error",
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const toggleVariants = cva(baseToggleStyles, {
|
|
46
|
+
variants: {
|
|
47
|
+
variant: {
|
|
48
|
+
default: cn("bg-transparent"),
|
|
49
|
+
outline: cn(
|
|
50
|
+
"border",
|
|
51
|
+
"border-border-primary",
|
|
52
|
+
"bg-transparent",
|
|
53
|
+
"shadow-xs",
|
|
54
|
+
"hover:bg-bg-secondary",
|
|
55
|
+
"hover:text-text-primary",
|
|
56
|
+
),
|
|
21
57
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
58
|
+
size: {
|
|
59
|
+
default: cn("h-9", "px-2", "min-w-9"),
|
|
60
|
+
sm: cn("h-8", "px-1.5", "min-w-8"),
|
|
61
|
+
lg: cn("h-10", "px-2.5", "min-w-10"),
|
|
25
62
|
},
|
|
26
63
|
},
|
|
27
|
-
|
|
64
|
+
defaultVariants: {
|
|
65
|
+
variant: "default",
|
|
66
|
+
size: "default",
|
|
67
|
+
},
|
|
68
|
+
});
|
|
28
69
|
|
|
29
70
|
function Toggle({
|
|
30
71
|
className,
|
|
@@ -4,6 +4,38 @@ import type * as React from "react";
|
|
|
4
4
|
|
|
5
5
|
import { cn } from "#shadcn/lib/utils";
|
|
6
6
|
|
|
7
|
+
// Tooltip content styles
|
|
8
|
+
const tooltipContentStyles = cn(
|
|
9
|
+
// Layout
|
|
10
|
+
"z-50",
|
|
11
|
+
"w-fit",
|
|
12
|
+
"origin-(--radix-tooltip-content-transform-origin)",
|
|
13
|
+
// Shape
|
|
14
|
+
"rounded-md",
|
|
15
|
+
// Background & Colors
|
|
16
|
+
"bg-bg-overlay",
|
|
17
|
+
"text-text-primary_on-brand",
|
|
18
|
+
// Spacing
|
|
19
|
+
"px-3",
|
|
20
|
+
"py-1.5",
|
|
21
|
+
// Typography
|
|
22
|
+
"text-xs",
|
|
23
|
+
"text-balance",
|
|
24
|
+
// Animations - open
|
|
25
|
+
"animate-in",
|
|
26
|
+
"fade-in-0",
|
|
27
|
+
"zoom-in-95",
|
|
28
|
+
// Animations - closed
|
|
29
|
+
"data-[state=closed]:animate-out",
|
|
30
|
+
"data-[state=closed]:fade-out-0",
|
|
31
|
+
"data-[state=closed]:zoom-out-95",
|
|
32
|
+
// Slide animations
|
|
33
|
+
"data-[side=bottom]:slide-in-from-top-2",
|
|
34
|
+
"data-[side=left]:slide-in-from-right-2",
|
|
35
|
+
"data-[side=right]:slide-in-from-left-2",
|
|
36
|
+
"data-[side=top]:slide-in-from-bottom-2",
|
|
37
|
+
);
|
|
38
|
+
|
|
7
39
|
function TooltipProvider({
|
|
8
40
|
delayDuration = 0,
|
|
9
41
|
...props
|
|
@@ -44,14 +76,7 @@ function TooltipContent({
|
|
|
44
76
|
<TooltipPrimitive.Content
|
|
45
77
|
data-slot="tooltip-content"
|
|
46
78
|
sideOffset={sideOffset}
|
|
47
|
-
className={cn(
|
|
48
|
-
"bg-(--color-elements-assistive) text-(--color-elements-readable-inv) animate-in fade-in-0 zoom-in-95",
|
|
49
|
-
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
|
|
50
|
-
"data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2",
|
|
51
|
-
"data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md",
|
|
52
|
-
"px-3 py-1.5 text-xs text-balance",
|
|
53
|
-
className,
|
|
54
|
-
)}
|
|
79
|
+
className={cn(tooltipContentStyles, className)}
|
|
55
80
|
{...props}
|
|
56
81
|
>
|
|
57
82
|
{children}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import type { ItemInstance } from "@headless-tree/core";
|
|
2
|
+
import { ChevronDownIcon } from "lucide-react";
|
|
3
|
+
import { Slot } from "radix-ui";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
|
|
6
|
+
import { cn } from "#shadcn/lib/utils";
|
|
7
|
+
|
|
8
|
+
// biome-ignore lint/suspicious/noExplicitAny: FIXME Origin UI as-is
|
|
9
|
+
interface TreeContextValue<T = any> {
|
|
10
|
+
indent: number;
|
|
11
|
+
currentItem?: ItemInstance<T>;
|
|
12
|
+
// biome-ignore lint/suspicious/noExplicitAny: FIXME Origin UI as-is
|
|
13
|
+
tree?: any;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const TreeContext = React.createContext<TreeContextValue>({
|
|
17
|
+
indent: 20,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// biome-ignore lint/suspicious/noExplicitAny: FIXME Origin UI as-is
|
|
21
|
+
function useTreeContext<T = any>() {
|
|
22
|
+
return React.useContext(TreeContext) as TreeContextValue<T>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface TreeProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
26
|
+
indent?: number;
|
|
27
|
+
// biome-ignore lint/suspicious/noExplicitAny: FIXME Origin UI as-is
|
|
28
|
+
tree?: any;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function Tree({ indent = 20, tree, className, ...props }: TreeProps) {
|
|
32
|
+
const containerProps =
|
|
33
|
+
tree && typeof tree.getContainerProps === "function"
|
|
34
|
+
? tree.getContainerProps()
|
|
35
|
+
: {};
|
|
36
|
+
const mergedProps = { ...props, ...containerProps };
|
|
37
|
+
|
|
38
|
+
// Extract style from mergedProps to merge with our custom styles
|
|
39
|
+
const { style: propStyle, ...otherProps } = mergedProps;
|
|
40
|
+
|
|
41
|
+
// Merge styles
|
|
42
|
+
const mergedStyle = {
|
|
43
|
+
...propStyle,
|
|
44
|
+
"--tree-indent": `${indent}px`,
|
|
45
|
+
"--border": `var(--color-fg-disabled)`,
|
|
46
|
+
} as React.CSSProperties;
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<TreeContext.Provider value={{ indent, tree }}>
|
|
50
|
+
<div
|
|
51
|
+
data-slot="tree"
|
|
52
|
+
style={mergedStyle}
|
|
53
|
+
className={cn("flex flex-col", className)}
|
|
54
|
+
{...otherProps}
|
|
55
|
+
/>
|
|
56
|
+
</TreeContext.Provider>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// biome-ignore lint/suspicious/noExplicitAny: FIXME Origin UI as-is
|
|
61
|
+
interface TreeItemProps<T = any>
|
|
62
|
+
extends React.HTMLAttributes<HTMLButtonElement> {
|
|
63
|
+
item: ItemInstance<T>;
|
|
64
|
+
indent?: number;
|
|
65
|
+
asChild?: boolean;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// biome-ignore lint/suspicious/noExplicitAny: FIXME Origin UI as-is
|
|
69
|
+
function TreeItem<T = any>({
|
|
70
|
+
item,
|
|
71
|
+
className,
|
|
72
|
+
asChild,
|
|
73
|
+
children,
|
|
74
|
+
...props
|
|
75
|
+
}: Omit<TreeItemProps<T>, "indent">) {
|
|
76
|
+
const { indent } = useTreeContext<T>();
|
|
77
|
+
|
|
78
|
+
const itemProps = typeof item.getProps === "function" ? item.getProps() : {};
|
|
79
|
+
const mergedProps = { ...props, ...itemProps };
|
|
80
|
+
|
|
81
|
+
// Extract style from mergedProps to merge with our custom styles
|
|
82
|
+
const { style: propStyle, ...otherProps } = mergedProps;
|
|
83
|
+
|
|
84
|
+
// Merge styles
|
|
85
|
+
const mergedStyle = {
|
|
86
|
+
...propStyle,
|
|
87
|
+
"--tree-padding": `${item.getItemMeta().level * indent}px`,
|
|
88
|
+
} as React.CSSProperties;
|
|
89
|
+
|
|
90
|
+
const Comp = asChild ? Slot.Root : "button";
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<TreeContext.Provider value={{ indent, currentItem: item }}>
|
|
94
|
+
<Comp
|
|
95
|
+
data-slot="tree-item"
|
|
96
|
+
style={mergedStyle}
|
|
97
|
+
className={cn(
|
|
98
|
+
"z-10 ps-(--tree-padding) outline-hidden select-none focus:z-20 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
99
|
+
className,
|
|
100
|
+
)}
|
|
101
|
+
data-focus={
|
|
102
|
+
typeof item.isFocused === "function"
|
|
103
|
+
? item.isFocused() || false
|
|
104
|
+
: undefined
|
|
105
|
+
}
|
|
106
|
+
data-folder={
|
|
107
|
+
typeof item.isFolder === "function"
|
|
108
|
+
? item.isFolder() || false
|
|
109
|
+
: undefined
|
|
110
|
+
}
|
|
111
|
+
data-selected={
|
|
112
|
+
typeof item.isSelected === "function"
|
|
113
|
+
? item.isSelected() || false
|
|
114
|
+
: undefined
|
|
115
|
+
}
|
|
116
|
+
data-drag-target={
|
|
117
|
+
typeof item.isDragTarget === "function"
|
|
118
|
+
? item.isDragTarget() || false
|
|
119
|
+
: undefined
|
|
120
|
+
}
|
|
121
|
+
data-search-match={
|
|
122
|
+
typeof item.isMatchingSearch === "function"
|
|
123
|
+
? item.isMatchingSearch() || false
|
|
124
|
+
: undefined
|
|
125
|
+
}
|
|
126
|
+
aria-expanded={item.isExpanded()}
|
|
127
|
+
{...otherProps}
|
|
128
|
+
>
|
|
129
|
+
{children}
|
|
130
|
+
</Comp>
|
|
131
|
+
</TreeContext.Provider>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// biome-ignore lint/suspicious/noExplicitAny: FIXME Origin UI as-is
|
|
136
|
+
interface TreeItemLabelProps<T = any>
|
|
137
|
+
extends React.HTMLAttributes<HTMLSpanElement> {
|
|
138
|
+
item?: ItemInstance<T>;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// biome-ignore lint/suspicious/noExplicitAny: FIXME Origin UI as-is
|
|
142
|
+
function TreeItemLabel<T = any>({
|
|
143
|
+
item: propItem,
|
|
144
|
+
children,
|
|
145
|
+
className,
|
|
146
|
+
...props
|
|
147
|
+
}: TreeItemLabelProps<T>) {
|
|
148
|
+
const { currentItem } = useTreeContext<T>();
|
|
149
|
+
const item = propItem || currentItem;
|
|
150
|
+
|
|
151
|
+
if (!item) {
|
|
152
|
+
console.warn("TreeItemLabel: No item provided via props or context");
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return (
|
|
157
|
+
<span
|
|
158
|
+
data-slot="tree-item-label"
|
|
159
|
+
className={cn(
|
|
160
|
+
"group/tree-item-label cursor-pointer in-data-[selected=true]:border-l-border-brand border-l-2 border-l-transparent in-focus-visible:ring-ring/50 bg-background hover:bg-bg-secondary in-data-[selected=true]:bg-bg-quaternary! text-text-secondary hover:text-text-primary in-data-[selected=true]:text-text-primary in-data-[drag-target=true]:bg-accent flex items-center gap-2 pr-2 pl-1.5 py-1.5 text-sm transition-colors not-in-data-[folder=true]:ps-2.5 in-focus-visible:ring-[3px] in-data-[search-match=true]:bg-blue-400/20! [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
161
|
+
className,
|
|
162
|
+
)}
|
|
163
|
+
{...props}
|
|
164
|
+
>
|
|
165
|
+
{item.isFolder() && (
|
|
166
|
+
<ChevronDownIcon className="text-muted-foreground size-4 in-aria-[expanded=false]:-rotate-90" />
|
|
167
|
+
)}
|
|
168
|
+
{children ||
|
|
169
|
+
(typeof item.getItemName === "function" ? item.getItemName() : null)}
|
|
170
|
+
</span>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function TreeDragLine({
|
|
175
|
+
className,
|
|
176
|
+
...props
|
|
177
|
+
}: React.HTMLAttributes<HTMLDivElement>) {
|
|
178
|
+
const { tree } = useTreeContext();
|
|
179
|
+
|
|
180
|
+
if (!tree || typeof tree.getDragLineStyle !== "function") {
|
|
181
|
+
console.warn(
|
|
182
|
+
"TreeDragLine: No tree provided via context or tree does not have getDragLineStyle method",
|
|
183
|
+
);
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const dragLine = tree.getDragLineStyle();
|
|
188
|
+
return (
|
|
189
|
+
<div
|
|
190
|
+
style={dragLine}
|
|
191
|
+
className={cn(
|
|
192
|
+
"bg-primary before:bg-background before:border-primary absolute z-30 -mt-px h-0.5 w-[unset] before:absolute before:-top-[3px] before:left-0 before:size-2 before:rounded-full before:border-2",
|
|
193
|
+
className,
|
|
194
|
+
)}
|
|
195
|
+
{...props}
|
|
196
|
+
/>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export { Tree, TreeItem, TreeItemLabel, TreeDragLine };
|