@orsetra/shared-ui 1.0.34 → 1.0.35

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.
@@ -49,6 +49,7 @@ export { ResizablePanelGroup, ResizablePanel, ResizableHandle } from './resizabl
49
49
  export { ScrollArea, ScrollBar } from './scroll-area'
50
50
  export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator } from './select'
51
51
  export { Sheet, SheetTrigger, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription } from './sheet'
52
+ export { SidePanel, SidePanelTrigger, SidePanelClose, SidePanelContent, SidePanelHeader, SidePanelTitle, SidePanelDescription, SidePanelBody, SidePanelFooter } from './side-panel'
52
53
  export { Skeleton } from './skeleton'
53
54
  export { Slider } from './slider'
54
55
  export { Toaster } from './toaster'
@@ -0,0 +1,153 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as DialogPrimitive from "@radix-ui/react-dialog"
5
+ import { X } from "lucide-react"
6
+ import { cn } from "../../lib/utils"
7
+
8
+ const SidePanel = DialogPrimitive.Root
9
+
10
+ const SidePanelTrigger = DialogPrimitive.Trigger
11
+
12
+ const SidePanelClose = DialogPrimitive.Close
13
+
14
+ const SidePanelPortal = DialogPrimitive.Portal
15
+
16
+ const SidePanelOverlay = React.forwardRef<
17
+ React.ElementRef<typeof DialogPrimitive.Overlay>,
18
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
19
+ >(({ className, ...props }, ref) => (
20
+ <DialogPrimitive.Overlay
21
+ ref={ref}
22
+ className={cn(
23
+ "fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
24
+ className
25
+ )}
26
+ {...props}
27
+ />
28
+ ))
29
+ SidePanelOverlay.displayName = DialogPrimitive.Overlay.displayName
30
+
31
+ interface SidePanelContentProps
32
+ extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {
33
+ side?: "left" | "right"
34
+ width?: string
35
+ }
36
+
37
+ const SidePanelContent = React.forwardRef<
38
+ React.ElementRef<typeof DialogPrimitive.Content>,
39
+ SidePanelContentProps
40
+ >(({ side = "right", width = "max-w-lg", className, children, ...props }, ref) => (
41
+ <SidePanelPortal>
42
+ <SidePanelOverlay />
43
+ <DialogPrimitive.Content
44
+ ref={ref}
45
+ className={cn(
46
+ "fixed z-50 gap-4 bg-white shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
47
+ side === "right" &&
48
+ "inset-y-0 right-0 h-full w-full border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right",
49
+ side === "left" &&
50
+ "inset-y-0 left-0 h-full w-full border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",
51
+ width,
52
+ className
53
+ )}
54
+ {...props}
55
+ >
56
+ {children}
57
+ </DialogPrimitive.Content>
58
+ </SidePanelPortal>
59
+ ))
60
+ SidePanelContent.displayName = DialogPrimitive.Content.displayName
61
+
62
+ interface SidePanelHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
63
+ onClose?: () => void
64
+ showCloseButton?: boolean
65
+ }
66
+
67
+ const SidePanelHeader = React.forwardRef<HTMLDivElement, SidePanelHeaderProps>(
68
+ ({ className, children, onClose, showCloseButton = true, ...props }, ref) => (
69
+ <div
70
+ ref={ref}
71
+ className={cn(
72
+ "flex items-center justify-between border-b border-ibm-gray-20 px-6 py-4",
73
+ className
74
+ )}
75
+ {...props}
76
+ >
77
+ <div className="flex-1">{children}</div>
78
+ {showCloseButton && (
79
+ <DialogPrimitive.Close
80
+ className="rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ibm-blue-60 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-ibm-gray-10"
81
+ onClick={onClose}
82
+ >
83
+ <X className="h-5 w-5 text-ibm-gray-70" />
84
+ <span className="sr-only">Close</span>
85
+ </DialogPrimitive.Close>
86
+ )}
87
+ </div>
88
+ )
89
+ )
90
+ SidePanelHeader.displayName = "SidePanelHeader"
91
+
92
+ const SidePanelTitle = React.forwardRef<
93
+ React.ElementRef<typeof DialogPrimitive.Title>,
94
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
95
+ >(({ className, ...props }, ref) => (
96
+ <DialogPrimitive.Title
97
+ ref={ref}
98
+ className={cn("text-lg font-semibold text-ibm-gray-100", className)}
99
+ {...props}
100
+ />
101
+ ))
102
+ SidePanelTitle.displayName = DialogPrimitive.Title.displayName
103
+
104
+ const SidePanelDescription = React.forwardRef<
105
+ React.ElementRef<typeof DialogPrimitive.Description>,
106
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
107
+ >(({ className, ...props }, ref) => (
108
+ <DialogPrimitive.Description
109
+ ref={ref}
110
+ className={cn("text-sm text-ibm-gray-60", className)}
111
+ {...props}
112
+ />
113
+ ))
114
+ SidePanelDescription.displayName = DialogPrimitive.Description.displayName
115
+
116
+ const SidePanelBody = React.forwardRef<
117
+ HTMLDivElement,
118
+ React.HTMLAttributes<HTMLDivElement>
119
+ >(({ className, ...props }, ref) => (
120
+ <div
121
+ ref={ref}
122
+ className={cn("flex-1 overflow-y-auto px-6 py-6", className)}
123
+ {...props}
124
+ />
125
+ ))
126
+ SidePanelBody.displayName = "SidePanelBody"
127
+
128
+ const SidePanelFooter = React.forwardRef<
129
+ HTMLDivElement,
130
+ React.HTMLAttributes<HTMLDivElement>
131
+ >(({ className, ...props }, ref) => (
132
+ <div
133
+ ref={ref}
134
+ className={cn(
135
+ "flex items-center justify-end gap-3 border-t border-ibm-gray-20 px-6 py-4",
136
+ className
137
+ )}
138
+ {...props}
139
+ />
140
+ ))
141
+ SidePanelFooter.displayName = "SidePanelFooter"
142
+
143
+ export {
144
+ SidePanel,
145
+ SidePanelTrigger,
146
+ SidePanelClose,
147
+ SidePanelContent,
148
+ SidePanelHeader,
149
+ SidePanelTitle,
150
+ SidePanelDescription,
151
+ SidePanelBody,
152
+ SidePanelFooter,
153
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orsetra/shared-ui",
3
- "version": "1.0.34",
3
+ "version": "1.0.35",
4
4
  "description": "Shared UI components for Orsetra platform",
5
5
  "main": "./index.ts",
6
6
  "types": "./index.ts",
@@ -93,4 +93,4 @@
93
93
  "next": "^16.0.7",
94
94
  "typescript": "^5"
95
95
  }
96
- }
96
+ }