@foresthubai/workflow-builder 0.4.2 → 0.4.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.
Files changed (123) hide show
  1. package/LICENSE +661 -661
  2. package/NOTICE +16 -16
  3. package/README.md +110 -110
  4. package/dist/components/ui/command.d.ts +2 -2
  5. package/dist/components/ui/input.d.ts +1 -1
  6. package/dist/components/ui/resizable.d.ts +1 -1
  7. package/dist/components/ui/textarea.d.ts +1 -1
  8. package/dist/graph/BaseNode.js +10 -10
  9. package/dist/graph/reactFlowRegistry.d.ts.map +1 -1
  10. package/dist/hooks/useWorkflowSerialization.d.ts.map +1 -1
  11. package/dist/hooks/useWorkflowSerialization.js +8 -11
  12. package/dist/hooks/useWorkflowSerialization.js.map +1 -1
  13. package/package.json +2 -2
  14. package/src/BuilderLayout.tsx +345 -345
  15. package/src/Canvas.tsx +261 -261
  16. package/src/CanvasEditor.tsx +142 -142
  17. package/src/CanvasTabsToolbar.tsx +176 -176
  18. package/src/RightConfigPanel.tsx +266 -266
  19. package/src/WorkflowBuilder.tsx +408 -408
  20. package/src/cn.ts +6 -6
  21. package/src/components/ui/add-button.tsx +39 -39
  22. package/src/components/ui/alert-dialog.tsx +141 -141
  23. package/src/components/ui/alert.tsx +59 -59
  24. package/src/components/ui/badge.tsx +36 -36
  25. package/src/components/ui/button.tsx +85 -85
  26. package/src/components/ui/card.tsx +79 -79
  27. package/src/components/ui/checkbox.tsx +28 -28
  28. package/src/components/ui/collapsible.tsx +9 -9
  29. package/src/components/ui/command.tsx +153 -153
  30. package/src/components/ui/delete-button.tsx +23 -23
  31. package/src/components/ui/dialog.tsx +125 -125
  32. package/src/components/ui/dropdown-menu.tsx +198 -198
  33. package/src/components/ui/input.tsx +55 -55
  34. package/src/components/ui/label.tsx +24 -24
  35. package/src/components/ui/readonly-banner.tsx +15 -15
  36. package/src/components/ui/resizable.tsx +43 -43
  37. package/src/components/ui/scroll-area.tsx +102 -102
  38. package/src/components/ui/select.tsx +160 -160
  39. package/src/components/ui/separator.tsx +29 -29
  40. package/src/components/ui/switch.tsx +27 -27
  41. package/src/components/ui/textarea.tsx +51 -51
  42. package/src/components/ui/toast.tsx +127 -127
  43. package/src/components/ui/toaster.tsx +33 -33
  44. package/src/components/ui/toggle-group.tsx +59 -59
  45. package/src/components/ui/toggle.tsx +43 -43
  46. package/src/components/ui/tooltip.tsx +32 -32
  47. package/src/dialogs/NodePickerDialog.tsx +84 -84
  48. package/src/dialogs/ValidationDialog.tsx +184 -184
  49. package/src/graph/BaseNode.tsx +557 -557
  50. package/src/graph/CustomEdge.tsx +185 -185
  51. package/src/graph/CustomNode.tsx +16 -16
  52. package/src/graph/FunctionCallNode.tsx +30 -30
  53. package/src/graph/PortHandle.tsx +189 -189
  54. package/src/graph/reactFlowRegistry.ts +26 -26
  55. package/src/hooks/use-toast.ts +125 -125
  56. package/src/hooks/useAvailableVariables.ts +20 -20
  57. package/src/hooks/useCanvasHistory.ts +22 -22
  58. package/src/hooks/useCanvasTabs.ts +168 -168
  59. package/src/hooks/useFunctionDiagnosticsSync.ts +40 -40
  60. package/src/hooks/useFunctionRegistry.ts +26 -26
  61. package/src/hooks/useFunctions.ts +44 -44
  62. package/src/hooks/useGraph.ts +161 -161
  63. package/src/hooks/useNodeDefinitions.ts +82 -82
  64. package/src/hooks/useParamErrors.ts +26 -26
  65. package/src/hooks/useResolvedTheme.ts +30 -30
  66. package/src/hooks/useResourceDiagnosticsSync.ts +58 -58
  67. package/src/hooks/useSuppressThemeTransition.ts +79 -79
  68. package/src/hooks/useWorkflowSerialization.ts +141 -144
  69. package/src/i18n/index.ts +53 -53
  70. package/src/i18n/locales/de.json +501 -501
  71. package/src/i18n/locales/en.json +557 -557
  72. package/src/index.ts +27 -27
  73. package/src/inputs/ExpressionInput.tsx +297 -297
  74. package/src/inputs/ParameterEditor.tsx +515 -515
  75. package/src/inputs/PortSection.tsx +144 -144
  76. package/src/panels/BuilderSidebar.tsx +301 -301
  77. package/src/panels/ChannelConfigPanel.tsx +49 -49
  78. package/src/panels/ChannelsPanel.tsx +28 -28
  79. package/src/panels/DebugConsolePanel.tsx +73 -73
  80. package/src/panels/DebugContextPanel.tsx +77 -77
  81. package/src/panels/DebugExternalIOPanel.tsx +180 -180
  82. package/src/panels/DiagnosticsPanel.tsx +170 -170
  83. package/src/panels/EdgeConfigPanel.tsx +104 -104
  84. package/src/panels/FunctionConfigPanel.tsx +179 -179
  85. package/src/panels/FunctionListPanel.tsx +45 -45
  86. package/src/panels/MemoryConfigPanel.tsx +55 -55
  87. package/src/panels/MemoryPanel.tsx +40 -40
  88. package/src/panels/ModelConfigPanel.tsx +41 -41
  89. package/src/panels/ModelsPanel.tsx +36 -36
  90. package/src/panels/NodeConfigPanel.tsx +630 -630
  91. package/src/panels/NodeLibrary.tsx +288 -288
  92. package/src/panels/ResourceConfigPanel.tsx +132 -132
  93. package/src/panels/ResourceListPanel.tsx +113 -113
  94. package/src/panels/VariableConfigPanel.tsx +161 -161
  95. package/src/panels/VariablesPanel.tsx +145 -145
  96. package/src/stores/canvasStore.test.ts +44 -44
  97. package/src/stores/canvasStore.ts +245 -245
  98. package/src/stores/debugStore.ts +74 -74
  99. package/src/stores/diagnosticsStore.ts +130 -130
  100. package/src/stores/editorStore.ts +190 -190
  101. package/src/styles/index.css +526 -526
  102. package/src/utils/categoryConstants.ts +26 -26
  103. package/src/utils/channelOperations.ts +86 -86
  104. package/src/utils/connectionRules.ts +137 -137
  105. package/src/utils/functionOperations.ts +179 -179
  106. package/src/utils/graphOperations.ts +550 -550
  107. package/src/utils/history.ts +207 -207
  108. package/src/utils/memoryOperations.ts +57 -57
  109. package/src/utils/migrateFunctionNodes.ts +107 -107
  110. package/src/utils/modelOperations.ts +55 -55
  111. package/src/utils/paramDisplay.ts +71 -71
  112. package/src/utils/resourceHelpers.ts +32 -32
  113. package/src/utils/translation.ts +28 -28
  114. package/src/utils/variableOperations.ts +75 -75
  115. package/tailwind-preset.ts +166 -166
  116. package/dist/lib/utils.d.ts +0 -3
  117. package/dist/lib/utils.d.ts.map +0 -1
  118. package/dist/lib/utils.js +0 -6
  119. package/dist/lib/utils.js.map +0 -1
  120. package/dist/toolbars/CanvasTabsToolbar.d.ts +0 -11
  121. package/dist/toolbars/CanvasTabsToolbar.d.ts.map +0 -1
  122. package/dist/toolbars/CanvasTabsToolbar.js +0 -101
  123. package/dist/toolbars/CanvasTabsToolbar.js.map +0 -1
@@ -1,29 +1,29 @@
1
- import * as React from "react"
2
- import * as SeparatorPrimitive from "@radix-ui/react-separator"
3
-
4
- import { cn } from "../../cn"
5
-
6
- const Separator = React.forwardRef<
7
- React.ElementRef<typeof SeparatorPrimitive.Root>,
8
- React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
9
- >(
10
- (
11
- { className, orientation = "horizontal", decorative = true, ...props },
12
- ref
13
- ) => (
14
- <SeparatorPrimitive.Root
15
- ref={ref}
16
- decorative={decorative}
17
- orientation={orientation}
18
- className={cn(
19
- "shrink-0 bg-border",
20
- orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
21
- className
22
- )}
23
- {...props}
24
- />
25
- )
26
- )
27
- Separator.displayName = SeparatorPrimitive.Root.displayName
28
-
29
- export { Separator }
1
+ import * as React from "react"
2
+ import * as SeparatorPrimitive from "@radix-ui/react-separator"
3
+
4
+ import { cn } from "../../cn"
5
+
6
+ const Separator = React.forwardRef<
7
+ React.ElementRef<typeof SeparatorPrimitive.Root>,
8
+ React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
9
+ >(
10
+ (
11
+ { className, orientation = "horizontal", decorative = true, ...props },
12
+ ref
13
+ ) => (
14
+ <SeparatorPrimitive.Root
15
+ ref={ref}
16
+ decorative={decorative}
17
+ orientation={orientation}
18
+ className={cn(
19
+ "shrink-0 bg-border",
20
+ orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
21
+ className
22
+ )}
23
+ {...props}
24
+ />
25
+ )
26
+ )
27
+ Separator.displayName = SeparatorPrimitive.Root.displayName
28
+
29
+ export { Separator }
@@ -1,27 +1,27 @@
1
- import * as React from "react"
2
- import * as SwitchPrimitives from "@radix-ui/react-switch"
3
-
4
- import { cn } from "../../cn"
5
-
6
- const Switch = React.forwardRef<
7
- React.ElementRef<typeof SwitchPrimitives.Root>,
8
- React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
9
- >(({ className, ...props }, ref) => (
10
- <SwitchPrimitives.Root
11
- className={cn(
12
- "peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
13
- className
14
- )}
15
- {...props}
16
- ref={ref}
17
- >
18
- <SwitchPrimitives.Thumb
19
- className={cn(
20
- "pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
21
- )}
22
- />
23
- </SwitchPrimitives.Root>
24
- ))
25
- Switch.displayName = SwitchPrimitives.Root.displayName
26
-
27
- export { Switch }
1
+ import * as React from "react"
2
+ import * as SwitchPrimitives from "@radix-ui/react-switch"
3
+
4
+ import { cn } from "../../cn"
5
+
6
+ const Switch = React.forwardRef<
7
+ React.ElementRef<typeof SwitchPrimitives.Root>,
8
+ React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
9
+ >(({ className, ...props }, ref) => (
10
+ <SwitchPrimitives.Root
11
+ className={cn(
12
+ "peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
13
+ className
14
+ )}
15
+ {...props}
16
+ ref={ref}
17
+ >
18
+ <SwitchPrimitives.Thumb
19
+ className={cn(
20
+ "pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
21
+ )}
22
+ />
23
+ </SwitchPrimitives.Root>
24
+ ))
25
+ Switch.displayName = SwitchPrimitives.Root.displayName
26
+
27
+ export { Switch }
@@ -1,51 +1,51 @@
1
- import * as React from "react"
2
- import { cva, type VariantProps } from "class-variance-authority"
3
-
4
- import { cn } from "../../cn"
5
-
6
- export interface TextareaProps
7
- extends React.TextareaHTMLAttributes<HTMLTextAreaElement>,
8
- VariantProps<typeof textareaVariants> {}
9
-
10
- const textareaVariants = cva(
11
- "flex w-full rounded-md border ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid=true]:border-destructive aria-[invalid=true]:focus-visible:ring-destructive",
12
- {
13
- variants: {
14
- size: {
15
- sm: "min-h-[72px] px-3 py-2 text-sm",
16
- md: "min-h-[80px] px-3 py-2 text-sm",
17
- lg: "min-h-[96px] px-4 py-3 text-base",
18
- },
19
- variant: {
20
- default: "border-input bg-field",
21
- subtle: "border-transparent bg-muted focus-visible:border-input",
22
- ghost: "border-border bg-transparent focus-visible:bg-background/60",
23
- },
24
- status: {
25
- none: "",
26
- success: "border-success focus-visible:ring-success",
27
- error: "border-destructive focus-visible:ring-destructive",
28
- },
29
- },
30
- defaultVariants: {
31
- size: "md",
32
- variant: "default",
33
- status: "none",
34
- },
35
- }
36
- )
37
-
38
- const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
39
- ({ className, size, variant, status, ...props }, ref) => {
40
- return (
41
- <textarea
42
- className={cn(textareaVariants({ size, variant, status }), className)}
43
- ref={ref}
44
- {...props}
45
- />
46
- )
47
- }
48
- )
49
- Textarea.displayName = "Textarea"
50
-
51
- export { Textarea, textareaVariants }
1
+ import * as React from "react"
2
+ import { cva, type VariantProps } from "class-variance-authority"
3
+
4
+ import { cn } from "../../cn"
5
+
6
+ export interface TextareaProps
7
+ extends React.TextareaHTMLAttributes<HTMLTextAreaElement>,
8
+ VariantProps<typeof textareaVariants> {}
9
+
10
+ const textareaVariants = cva(
11
+ "flex w-full rounded-md border ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid=true]:border-destructive aria-[invalid=true]:focus-visible:ring-destructive",
12
+ {
13
+ variants: {
14
+ size: {
15
+ sm: "min-h-[72px] px-3 py-2 text-sm",
16
+ md: "min-h-[80px] px-3 py-2 text-sm",
17
+ lg: "min-h-[96px] px-4 py-3 text-base",
18
+ },
19
+ variant: {
20
+ default: "border-input bg-field",
21
+ subtle: "border-transparent bg-muted focus-visible:border-input",
22
+ ghost: "border-border bg-transparent focus-visible:bg-background/60",
23
+ },
24
+ status: {
25
+ none: "",
26
+ success: "border-success focus-visible:ring-success",
27
+ error: "border-destructive focus-visible:ring-destructive",
28
+ },
29
+ },
30
+ defaultVariants: {
31
+ size: "md",
32
+ variant: "default",
33
+ status: "none",
34
+ },
35
+ }
36
+ )
37
+
38
+ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
39
+ ({ className, size, variant, status, ...props }, ref) => {
40
+ return (
41
+ <textarea
42
+ className={cn(textareaVariants({ size, variant, status }), className)}
43
+ ref={ref}
44
+ {...props}
45
+ />
46
+ )
47
+ }
48
+ )
49
+ Textarea.displayName = "Textarea"
50
+
51
+ export { Textarea, textareaVariants }
@@ -1,127 +1,127 @@
1
- import * as React from "react"
2
- import * as ToastPrimitives from "@radix-ui/react-toast"
3
- import { cva, type VariantProps } from "class-variance-authority"
4
- import { X } from "lucide-react"
5
-
6
- import { cn } from "../../cn"
7
-
8
- const ToastProvider = ToastPrimitives.Provider
9
-
10
- const ToastViewport = React.forwardRef<
11
- React.ElementRef<typeof ToastPrimitives.Viewport>,
12
- React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>
13
- >(({ className, ...props }, ref) => (
14
- <ToastPrimitives.Viewport
15
- ref={ref}
16
- className={cn(
17
- "fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
18
- className
19
- )}
20
- {...props}
21
- />
22
- ))
23
- ToastViewport.displayName = ToastPrimitives.Viewport.displayName
24
-
25
- const toastVariants = cva(
26
- "group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
27
- {
28
- variants: {
29
- variant: {
30
- default: "border bg-background text-foreground",
31
- destructive:
32
- "destructive group border-destructive bg-destructive text-destructive-foreground",
33
- },
34
- },
35
- defaultVariants: {
36
- variant: "default",
37
- },
38
- }
39
- )
40
-
41
- const Toast = React.forwardRef<
42
- React.ElementRef<typeof ToastPrimitives.Root>,
43
- React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &
44
- VariantProps<typeof toastVariants>
45
- >(({ className, variant, ...props }, ref) => {
46
- return (
47
- <ToastPrimitives.Root
48
- ref={ref}
49
- className={cn(toastVariants({ variant }), className)}
50
- {...props}
51
- />
52
- )
53
- })
54
- Toast.displayName = ToastPrimitives.Root.displayName
55
-
56
- const ToastAction = React.forwardRef<
57
- React.ElementRef<typeof ToastPrimitives.Action>,
58
- React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>
59
- >(({ className, ...props }, ref) => (
60
- <ToastPrimitives.Action
61
- ref={ref}
62
- className={cn(
63
- "inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
64
- className
65
- )}
66
- {...props}
67
- />
68
- ))
69
- ToastAction.displayName = ToastPrimitives.Action.displayName
70
-
71
- const ToastClose = React.forwardRef<
72
- React.ElementRef<typeof ToastPrimitives.Close>,
73
- React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>
74
- >(({ className, ...props }, ref) => (
75
- <ToastPrimitives.Close
76
- ref={ref}
77
- className={cn(
78
- "absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
79
- className
80
- )}
81
- toast-close=""
82
- {...props}
83
- >
84
- <X className="h-4 w-4" />
85
- </ToastPrimitives.Close>
86
- ))
87
- ToastClose.displayName = ToastPrimitives.Close.displayName
88
-
89
- const ToastTitle = React.forwardRef<
90
- React.ElementRef<typeof ToastPrimitives.Title>,
91
- React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>
92
- >(({ className, ...props }, ref) => (
93
- <ToastPrimitives.Title
94
- ref={ref}
95
- className={cn("text-sm font-semibold", className)}
96
- {...props}
97
- />
98
- ))
99
- ToastTitle.displayName = ToastPrimitives.Title.displayName
100
-
101
- const ToastDescription = React.forwardRef<
102
- React.ElementRef<typeof ToastPrimitives.Description>,
103
- React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>
104
- >(({ className, ...props }, ref) => (
105
- <ToastPrimitives.Description
106
- ref={ref}
107
- className={cn("text-sm opacity-90", className)}
108
- {...props}
109
- />
110
- ))
111
- ToastDescription.displayName = ToastPrimitives.Description.displayName
112
-
113
- type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>
114
-
115
- type ToastActionElement = React.ReactElement<typeof ToastAction>
116
-
117
- export {
118
- type ToastProps,
119
- type ToastActionElement,
120
- ToastProvider,
121
- ToastViewport,
122
- Toast,
123
- ToastTitle,
124
- ToastDescription,
125
- ToastClose,
126
- ToastAction,
127
- }
1
+ import * as React from "react"
2
+ import * as ToastPrimitives from "@radix-ui/react-toast"
3
+ import { cva, type VariantProps } from "class-variance-authority"
4
+ import { X } from "lucide-react"
5
+
6
+ import { cn } from "../../cn"
7
+
8
+ const ToastProvider = ToastPrimitives.Provider
9
+
10
+ const ToastViewport = React.forwardRef<
11
+ React.ElementRef<typeof ToastPrimitives.Viewport>,
12
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>
13
+ >(({ className, ...props }, ref) => (
14
+ <ToastPrimitives.Viewport
15
+ ref={ref}
16
+ className={cn(
17
+ "fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
18
+ className
19
+ )}
20
+ {...props}
21
+ />
22
+ ))
23
+ ToastViewport.displayName = ToastPrimitives.Viewport.displayName
24
+
25
+ const toastVariants = cva(
26
+ "group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
27
+ {
28
+ variants: {
29
+ variant: {
30
+ default: "border bg-background text-foreground",
31
+ destructive:
32
+ "destructive group border-destructive bg-destructive text-destructive-foreground",
33
+ },
34
+ },
35
+ defaultVariants: {
36
+ variant: "default",
37
+ },
38
+ }
39
+ )
40
+
41
+ const Toast = React.forwardRef<
42
+ React.ElementRef<typeof ToastPrimitives.Root>,
43
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &
44
+ VariantProps<typeof toastVariants>
45
+ >(({ className, variant, ...props }, ref) => {
46
+ return (
47
+ <ToastPrimitives.Root
48
+ ref={ref}
49
+ className={cn(toastVariants({ variant }), className)}
50
+ {...props}
51
+ />
52
+ )
53
+ })
54
+ Toast.displayName = ToastPrimitives.Root.displayName
55
+
56
+ const ToastAction = React.forwardRef<
57
+ React.ElementRef<typeof ToastPrimitives.Action>,
58
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>
59
+ >(({ className, ...props }, ref) => (
60
+ <ToastPrimitives.Action
61
+ ref={ref}
62
+ className={cn(
63
+ "inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
64
+ className
65
+ )}
66
+ {...props}
67
+ />
68
+ ))
69
+ ToastAction.displayName = ToastPrimitives.Action.displayName
70
+
71
+ const ToastClose = React.forwardRef<
72
+ React.ElementRef<typeof ToastPrimitives.Close>,
73
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>
74
+ >(({ className, ...props }, ref) => (
75
+ <ToastPrimitives.Close
76
+ ref={ref}
77
+ className={cn(
78
+ "absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
79
+ className
80
+ )}
81
+ toast-close=""
82
+ {...props}
83
+ >
84
+ <X className="h-4 w-4" />
85
+ </ToastPrimitives.Close>
86
+ ))
87
+ ToastClose.displayName = ToastPrimitives.Close.displayName
88
+
89
+ const ToastTitle = React.forwardRef<
90
+ React.ElementRef<typeof ToastPrimitives.Title>,
91
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>
92
+ >(({ className, ...props }, ref) => (
93
+ <ToastPrimitives.Title
94
+ ref={ref}
95
+ className={cn("text-sm font-semibold", className)}
96
+ {...props}
97
+ />
98
+ ))
99
+ ToastTitle.displayName = ToastPrimitives.Title.displayName
100
+
101
+ const ToastDescription = React.forwardRef<
102
+ React.ElementRef<typeof ToastPrimitives.Description>,
103
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>
104
+ >(({ className, ...props }, ref) => (
105
+ <ToastPrimitives.Description
106
+ ref={ref}
107
+ className={cn("text-sm opacity-90", className)}
108
+ {...props}
109
+ />
110
+ ))
111
+ ToastDescription.displayName = ToastPrimitives.Description.displayName
112
+
113
+ type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>
114
+
115
+ type ToastActionElement = React.ReactElement<typeof ToastAction>
116
+
117
+ export {
118
+ type ToastProps,
119
+ type ToastActionElement,
120
+ ToastProvider,
121
+ ToastViewport,
122
+ Toast,
123
+ ToastTitle,
124
+ ToastDescription,
125
+ ToastClose,
126
+ ToastAction,
127
+ }
@@ -1,33 +1,33 @@
1
- import { useToast } from "../../hooks/use-toast"
2
- import {
3
- Toast,
4
- ToastClose,
5
- ToastDescription,
6
- ToastProvider,
7
- ToastTitle,
8
- ToastViewport,
9
- } from "./toast"
10
-
11
- export function Toaster() {
12
- const { toasts } = useToast()
13
-
14
- return (
15
- <ToastProvider>
16
- {toasts.map(function ({ id, title, description, action, ...props }) {
17
- return (
18
- <Toast key={id} {...props}>
19
- <div className="grid gap-1">
20
- {title && <ToastTitle>{title}</ToastTitle>}
21
- {description && (
22
- <ToastDescription>{description}</ToastDescription>
23
- )}
24
- </div>
25
- {action}
26
- <ToastClose />
27
- </Toast>
28
- )
29
- })}
30
- <ToastViewport />
31
- </ToastProvider>
32
- )
33
- }
1
+ import { useToast } from "../../hooks/use-toast"
2
+ import {
3
+ Toast,
4
+ ToastClose,
5
+ ToastDescription,
6
+ ToastProvider,
7
+ ToastTitle,
8
+ ToastViewport,
9
+ } from "./toast"
10
+
11
+ export function Toaster() {
12
+ const { toasts } = useToast()
13
+
14
+ return (
15
+ <ToastProvider>
16
+ {toasts.map(function ({ id, title, description, action, ...props }) {
17
+ return (
18
+ <Toast key={id} {...props}>
19
+ <div className="grid gap-1">
20
+ {title && <ToastTitle>{title}</ToastTitle>}
21
+ {description && (
22
+ <ToastDescription>{description}</ToastDescription>
23
+ )}
24
+ </div>
25
+ {action}
26
+ <ToastClose />
27
+ </Toast>
28
+ )
29
+ })}
30
+ <ToastViewport />
31
+ </ToastProvider>
32
+ )
33
+ }
@@ -1,59 +1,59 @@
1
- import * as React from "react"
2
- import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group"
3
- import { type VariantProps } from "class-variance-authority"
4
-
5
- import { cn } from "../../cn"
6
- import { toggleVariants } from "./toggle"
7
-
8
- const ToggleGroupContext = React.createContext<
9
- VariantProps<typeof toggleVariants>
10
- >({
11
- size: "default",
12
- variant: "default",
13
- })
14
-
15
- const ToggleGroup = React.forwardRef<
16
- React.ElementRef<typeof ToggleGroupPrimitive.Root>,
17
- React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> &
18
- VariantProps<typeof toggleVariants>
19
- >(({ className, variant, size, children, ...props }, ref) => (
20
- <ToggleGroupPrimitive.Root
21
- ref={ref}
22
- className={cn("flex items-center justify-center gap-1", className)}
23
- {...props}
24
- >
25
- <ToggleGroupContext.Provider value={{ variant, size }}>
26
- {children}
27
- </ToggleGroupContext.Provider>
28
- </ToggleGroupPrimitive.Root>
29
- ))
30
-
31
- ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName
32
-
33
- const ToggleGroupItem = React.forwardRef<
34
- React.ElementRef<typeof ToggleGroupPrimitive.Item>,
35
- React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> &
36
- VariantProps<typeof toggleVariants>
37
- >(({ className, children, variant, size, ...props }, ref) => {
38
- const context = React.useContext(ToggleGroupContext)
39
-
40
- return (
41
- <ToggleGroupPrimitive.Item
42
- ref={ref}
43
- className={cn(
44
- toggleVariants({
45
- variant: context.variant || variant,
46
- size: context.size || size,
47
- }),
48
- className
49
- )}
50
- {...props}
51
- >
52
- {children}
53
- </ToggleGroupPrimitive.Item>
54
- )
55
- })
56
-
57
- ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName
58
-
59
- export { ToggleGroup, ToggleGroupItem }
1
+ import * as React from "react"
2
+ import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group"
3
+ import { type VariantProps } from "class-variance-authority"
4
+
5
+ import { cn } from "../../cn"
6
+ import { toggleVariants } from "./toggle"
7
+
8
+ const ToggleGroupContext = React.createContext<
9
+ VariantProps<typeof toggleVariants>
10
+ >({
11
+ size: "default",
12
+ variant: "default",
13
+ })
14
+
15
+ const ToggleGroup = React.forwardRef<
16
+ React.ElementRef<typeof ToggleGroupPrimitive.Root>,
17
+ React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> &
18
+ VariantProps<typeof toggleVariants>
19
+ >(({ className, variant, size, children, ...props }, ref) => (
20
+ <ToggleGroupPrimitive.Root
21
+ ref={ref}
22
+ className={cn("flex items-center justify-center gap-1", className)}
23
+ {...props}
24
+ >
25
+ <ToggleGroupContext.Provider value={{ variant, size }}>
26
+ {children}
27
+ </ToggleGroupContext.Provider>
28
+ </ToggleGroupPrimitive.Root>
29
+ ))
30
+
31
+ ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName
32
+
33
+ const ToggleGroupItem = React.forwardRef<
34
+ React.ElementRef<typeof ToggleGroupPrimitive.Item>,
35
+ React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> &
36
+ VariantProps<typeof toggleVariants>
37
+ >(({ className, children, variant, size, ...props }, ref) => {
38
+ const context = React.useContext(ToggleGroupContext)
39
+
40
+ return (
41
+ <ToggleGroupPrimitive.Item
42
+ ref={ref}
43
+ className={cn(
44
+ toggleVariants({
45
+ variant: context.variant || variant,
46
+ size: context.size || size,
47
+ }),
48
+ className
49
+ )}
50
+ {...props}
51
+ >
52
+ {children}
53
+ </ToggleGroupPrimitive.Item>
54
+ )
55
+ })
56
+
57
+ ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName
58
+
59
+ export { ToggleGroup, ToggleGroupItem }