@inbeat/ui 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/package.json +100 -0
  3. package/src/components/alert-dialog.tsx +246 -0
  4. package/src/components/alert.tsx +66 -0
  5. package/src/components/app-nav.tsx +55 -0
  6. package/src/components/app-shell.tsx +95 -0
  7. package/src/components/avatar.tsx +73 -0
  8. package/src/components/badge.tsx +42 -0
  9. package/src/components/breadcrumb.tsx +109 -0
  10. package/src/components/button.tsx +75 -0
  11. package/src/components/calendar.tsx +220 -0
  12. package/src/components/carousel.tsx +83 -0
  13. package/src/components/checkbox.tsx +29 -0
  14. package/src/components/collapsible-section.tsx +88 -0
  15. package/src/components/combobox.tsx +351 -0
  16. package/src/components/data-table-shell.tsx +6 -0
  17. package/src/components/data-table-sortable-header.tsx +29 -0
  18. package/src/components/data-table.tsx +141 -0
  19. package/src/components/destructive-action-dialog.tsx +108 -0
  20. package/src/components/dialog.tsx +187 -0
  21. package/src/components/dropdown-menu.tsx +228 -0
  22. package/src/components/empty-state.tsx +55 -0
  23. package/src/components/field.tsx +248 -0
  24. package/src/components/icon-button.tsx +51 -0
  25. package/src/components/input-group.tsx +170 -0
  26. package/src/components/input.tsx +22 -0
  27. package/src/components/label.tsx +24 -0
  28. package/src/components/labeled-field.tsx +18 -0
  29. package/src/components/load-more-sentinel.tsx +12 -0
  30. package/src/components/member-avatar-stack.tsx +44 -0
  31. package/src/components/multi-select-popover.tsx +202 -0
  32. package/src/components/nav-user.tsx +71 -0
  33. package/src/components/number-dot.tsx +13 -0
  34. package/src/components/person-identity.tsx +52 -0
  35. package/src/components/platform-disclaimer.tsx +70 -0
  36. package/src/components/popover.tsx +92 -0
  37. package/src/components/portal-container.tsx +21 -0
  38. package/src/components/progress.tsx +23 -0
  39. package/src/components/search-input.tsx +57 -0
  40. package/src/components/select.tsx +232 -0
  41. package/src/components/separator.tsx +28 -0
  42. package/src/components/sheet.tsx +147 -0
  43. package/src/components/sidebar.tsx +471 -0
  44. package/src/components/skeleton.tsx +13 -0
  45. package/src/components/sonner.tsx +46 -0
  46. package/src/components/spinner.tsx +21 -0
  47. package/src/components/table.tsx +92 -0
  48. package/src/components/tabs.tsx +62 -0
  49. package/src/components/textarea.tsx +18 -0
  50. package/src/components/toggle-pills.tsx +32 -0
  51. package/src/components/tooltip.tsx +67 -0
  52. package/src/hooks/use-mobile.ts +21 -0
  53. package/src/lib/easing.ts +5 -0
  54. package/src/lib/initials.ts +12 -0
  55. package/src/lib/utils.ts +6 -0
  56. package/theme.css +141 -0
@@ -0,0 +1,232 @@
1
+ "use client";
2
+
3
+ import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react";
4
+ import { Select as SelectPrimitive } from "radix-ui";
5
+ import * as React from "react";
6
+
7
+ import { usePortalContainer } from "./portal-container";
8
+ import { cn } from "../lib/utils";
9
+
10
+ // Sentinel used internally so Radix never sees two items with the same value/key.
11
+ // Consumers never deal with this — Select and SelectContent handle it transparently.
12
+ const CLEAR_SENTINEL = "__clear__";
13
+
14
+ type SelectClearableContext = { clearable: boolean; noneSelected: boolean };
15
+ const ClearableCtx = React.createContext<SelectClearableContext>({
16
+ clearable: false,
17
+ noneSelected: false,
18
+ });
19
+
20
+ function Select({
21
+ clearable = false,
22
+ value,
23
+ onValueChange,
24
+ ...props
25
+ }: React.ComponentProps<typeof SelectPrimitive.Root> & { clearable?: boolean }) {
26
+ const effectiveValue = clearable ? value || CLEAR_SENTINEL : value;
27
+ const noneSelected = clearable && !value;
28
+ const handleChange = React.useCallback(
29
+ (v: string) => onValueChange?.(clearable && v === CLEAR_SENTINEL ? "" : v),
30
+ [clearable, onValueChange],
31
+ );
32
+
33
+ return (
34
+ <ClearableCtx.Provider value={{ clearable, noneSelected }}>
35
+ <SelectPrimitive.Root
36
+ data-slot="select"
37
+ value={effectiveValue}
38
+ onValueChange={handleChange}
39
+ {...props}
40
+ />
41
+ </ClearableCtx.Provider>
42
+ );
43
+ }
44
+
45
+ function SelectGroup({ ...props }: React.ComponentProps<typeof SelectPrimitive.Group>) {
46
+ return <SelectPrimitive.Group data-slot="select-group" {...props} />;
47
+ }
48
+
49
+ function SelectValue({ ...props }: React.ComponentProps<typeof SelectPrimitive.Value>) {
50
+ return <SelectPrimitive.Value data-slot="select-value" {...props} />;
51
+ }
52
+
53
+ function selectTriggerClassName({
54
+ className,
55
+ noneSelected,
56
+ }: {
57
+ className?: string;
58
+ noneSelected?: boolean;
59
+ } = {}) {
60
+ return cn(
61
+ "min-w-36 border-input data-placeholder:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-1.5 rounded-lg border bg-transparent px-2.5 py-1.5 text-sm whitespace-nowrap transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
62
+ noneSelected && "text-muted-foreground",
63
+ className,
64
+ );
65
+ }
66
+
67
+ function SelectTrigger({
68
+ className,
69
+ size = "default",
70
+ children,
71
+ ...props
72
+ }: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
73
+ size?: "sm" | "default";
74
+ }) {
75
+ const { noneSelected } = React.useContext(ClearableCtx);
76
+
77
+ return (
78
+ <SelectPrimitive.Trigger
79
+ data-slot="select-trigger"
80
+ data-size={size}
81
+ className={selectTriggerClassName({ className, noneSelected })}
82
+ {...props}
83
+ >
84
+ {children}
85
+ <SelectPrimitive.Icon asChild>
86
+ <ChevronDownIcon className="size-3.5 opacity-50" />
87
+ </SelectPrimitive.Icon>
88
+ </SelectPrimitive.Trigger>
89
+ );
90
+ }
91
+
92
+ function SelectContent({
93
+ className,
94
+ children,
95
+ position = "item-aligned",
96
+ align = "center",
97
+ ...props
98
+ }: React.ComponentProps<typeof SelectPrimitive.Content>) {
99
+ const { clearable } = React.useContext(ClearableCtx);
100
+ const portalContainer = usePortalContainer();
101
+
102
+ return (
103
+ <SelectPrimitive.Portal container={portalContainer ?? undefined}>
104
+ <SelectPrimitive.Content
105
+ data-slot="select-content"
106
+ className={cn(
107
+ "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 relative z-60 max-h-(--radix-select-content-available-height) min-w-32 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border",
108
+ position === "popper" &&
109
+ "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
110
+ className,
111
+ )}
112
+ position={position}
113
+ align={align}
114
+ {...props}
115
+ >
116
+ <SelectScrollUpButton />
117
+ <SelectPrimitive.Viewport
118
+ className={cn(
119
+ "p-1",
120
+ position === "popper" &&
121
+ "h-(--radix-select-trigger-height) w-full min-w-(--radix-select-trigger-width) scroll-my-1",
122
+ )}
123
+ >
124
+ {clearable && (
125
+ <SelectPrimitive.Item
126
+ value={CLEAR_SENTINEL}
127
+ className="focus:bg-accent text-muted-foreground relative flex w-full items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none"
128
+ >
129
+ <SelectPrimitive.ItemText>Select</SelectPrimitive.ItemText>
130
+ </SelectPrimitive.Item>
131
+ )}
132
+ {children}
133
+ </SelectPrimitive.Viewport>
134
+ <SelectScrollDownButton />
135
+ </SelectPrimitive.Content>
136
+ </SelectPrimitive.Portal>
137
+ );
138
+ }
139
+
140
+ function SelectLabel({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.Label>) {
141
+ return (
142
+ <SelectPrimitive.Label
143
+ data-slot="select-label"
144
+ className={cn("text-muted-foreground px-2 py-1.5 text-xs", className)}
145
+ {...props}
146
+ />
147
+ );
148
+ }
149
+
150
+ function SelectItem({
151
+ className,
152
+ children,
153
+ ...props
154
+ }: React.ComponentProps<typeof SelectPrimitive.Item>) {
155
+ return (
156
+ <SelectPrimitive.Item
157
+ data-slot="select-item"
158
+ className={cn(
159
+ "focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
160
+ className,
161
+ )}
162
+ {...props}
163
+ >
164
+ <span
165
+ data-slot="select-item-indicator"
166
+ className="absolute right-2 flex size-3.5 items-center justify-center"
167
+ >
168
+ <SelectPrimitive.ItemIndicator>
169
+ <CheckIcon className="size-4" />
170
+ </SelectPrimitive.ItemIndicator>
171
+ </span>
172
+ <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
173
+ </SelectPrimitive.Item>
174
+ );
175
+ }
176
+
177
+ function SelectSeparator({
178
+ className,
179
+ ...props
180
+ }: React.ComponentProps<typeof SelectPrimitive.Separator>) {
181
+ return (
182
+ <SelectPrimitive.Separator
183
+ data-slot="select-separator"
184
+ className={cn("bg-border pointer-events-none -mx-1 my-1 h-px", className)}
185
+ {...props}
186
+ />
187
+ );
188
+ }
189
+
190
+ function SelectScrollUpButton({
191
+ className,
192
+ ...props
193
+ }: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {
194
+ return (
195
+ <SelectPrimitive.ScrollUpButton
196
+ data-slot="select-scroll-up-button"
197
+ className={cn("flex items-center justify-center py-1", className)}
198
+ {...props}
199
+ >
200
+ <ChevronUpIcon className="size-4" />
201
+ </SelectPrimitive.ScrollUpButton>
202
+ );
203
+ }
204
+
205
+ function SelectScrollDownButton({
206
+ className,
207
+ ...props
208
+ }: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {
209
+ return (
210
+ <SelectPrimitive.ScrollDownButton
211
+ data-slot="select-scroll-down-button"
212
+ className={cn("flex items-center justify-center py-1", className)}
213
+ {...props}
214
+ >
215
+ <ChevronDownIcon className="size-4" />
216
+ </SelectPrimitive.ScrollDownButton>
217
+ );
218
+ }
219
+
220
+ export {
221
+ Select,
222
+ SelectContent,
223
+ SelectGroup,
224
+ SelectItem,
225
+ SelectLabel,
226
+ SelectScrollDownButton,
227
+ SelectScrollUpButton,
228
+ SelectSeparator,
229
+ SelectTrigger,
230
+ SelectValue,
231
+ selectTriggerClassName,
232
+ };
@@ -0,0 +1,28 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Separator as SeparatorPrimitive } from "radix-ui"
5
+
6
+ import { cn } from "../lib/utils"
7
+
8
+ function Separator({
9
+ className,
10
+ orientation = "horizontal",
11
+ decorative = true,
12
+ ...props
13
+ }: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
14
+ return (
15
+ <SeparatorPrimitive.Root
16
+ data-slot="separator"
17
+ decorative={decorative}
18
+ orientation={orientation}
19
+ className={cn(
20
+ "shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
21
+ className
22
+ )}
23
+ {...props}
24
+ />
25
+ )
26
+ }
27
+
28
+ export { Separator }
@@ -0,0 +1,147 @@
1
+ "use client";
2
+
3
+ import { Dialog as SheetPrimitive } from "radix-ui";
4
+ import { useCallback } from "react";
5
+ import { cn } from "../lib/utils";
6
+
7
+ /** Swallow pointer-up + click that complete on the element under the removed overlay (Radix / modal ghost click). */
8
+ function swallowGhostPointerEvents(durationMs: number) {
9
+ const until = performance.now() + durationMs;
10
+ const swallow = (e: Event) => {
11
+ if (performance.now() <= until) {
12
+ e.preventDefault();
13
+ e.stopPropagation();
14
+ }
15
+ };
16
+ document.addEventListener("pointerup", swallow, true);
17
+ document.addEventListener("click", swallow, true);
18
+ window.setTimeout(() => {
19
+ document.removeEventListener("pointerup", swallow, true);
20
+ document.removeEventListener("click", swallow, true);
21
+ }, durationMs);
22
+ }
23
+
24
+ function Sheet({
25
+ onOpenChange,
26
+ ...props
27
+ }: React.ComponentProps<typeof SheetPrimitive.Root>) {
28
+ const handleOpenChange = useCallback(
29
+ (open: boolean) => {
30
+ if (!open) {
31
+ swallowGhostPointerEvents(100);
32
+ }
33
+ onOpenChange?.(open);
34
+ },
35
+ [onOpenChange],
36
+ );
37
+
38
+ return <SheetPrimitive.Root data-slot="sheet" {...props} onOpenChange={handleOpenChange} />;
39
+ }
40
+
41
+ function SheetTrigger({ ...props }: React.ComponentProps<typeof SheetPrimitive.Trigger>) {
42
+ return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />;
43
+ }
44
+
45
+ function SheetClose({ ...props }: React.ComponentProps<typeof SheetPrimitive.Close>) {
46
+ return <SheetPrimitive.Close data-slot="sheet-close" {...props} />;
47
+ }
48
+
49
+ function SheetPortal({ ...props }: React.ComponentProps<typeof SheetPrimitive.Portal>) {
50
+ return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />;
51
+ }
52
+
53
+ function SheetOverlay({
54
+ className,
55
+ ...props
56
+ }: React.ComponentProps<typeof SheetPrimitive.Overlay>) {
57
+ return (
58
+ <SheetPrimitive.Overlay
59
+ data-slot="sheet-overlay"
60
+ className={cn(
61
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 bg-black/10 duration-100 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 z-50",
62
+ className,
63
+ )}
64
+ {...props}
65
+ />
66
+ );
67
+ }
68
+
69
+ function SheetContent({
70
+ className,
71
+ children,
72
+ side = "right",
73
+ ...props
74
+ }: React.ComponentProps<typeof SheetPrimitive.Content> & {
75
+ side?: "top" | "right" | "bottom" | "left";
76
+ }) {
77
+ return (
78
+ <SheetPortal>
79
+ <SheetOverlay />
80
+ <SheetPrimitive.Content
81
+ data-slot="sheet-content"
82
+ data-side={side}
83
+ className={cn(
84
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[side=right]:data-[state=closed]:slide-out-to-right-10 data-[side=right]:data-[state=open]:slide-in-from-right-10 data-[side=left]:data-[state=closed]:slide-out-to-left-10 data-[side=left]:data-[state=open]:slide-in-from-left-10 data-[side=top]:data-[state=closed]:slide-out-to-top-10 data-[side=top]:data-[state=open]:slide-in-from-top-10 data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[side=bottom]:data-[state=closed]:slide-out-to-bottom-10 data-[side=bottom]:data-[state=open]:slide-in-from-bottom-10 fixed z-50 flex flex-col gap-4 bg-clip-padding text-sm shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm",
85
+ className,
86
+ )}
87
+ {...props}
88
+ >
89
+ {children}
90
+ </SheetPrimitive.Content>
91
+ </SheetPortal>
92
+ );
93
+ }
94
+
95
+ function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
96
+ return (
97
+ <div
98
+ data-slot="sheet-header"
99
+ className={cn("gap-0.5 p-4 flex flex-col", className)}
100
+ {...props}
101
+ />
102
+ );
103
+ }
104
+
105
+ function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
106
+ return (
107
+ <div
108
+ data-slot="sheet-footer"
109
+ className={cn("gap-2 p-4 mt-auto flex flex-col", className)}
110
+ {...props}
111
+ />
112
+ );
113
+ }
114
+
115
+ function SheetTitle({ className, ...props }: React.ComponentProps<typeof SheetPrimitive.Title>) {
116
+ return (
117
+ <SheetPrimitive.Title
118
+ data-slot="sheet-title"
119
+ className={cn("text-foreground text-base font-medium", className)}
120
+ {...props}
121
+ />
122
+ );
123
+ }
124
+
125
+ function SheetDescription({
126
+ className,
127
+ ...props
128
+ }: React.ComponentProps<typeof SheetPrimitive.Description>) {
129
+ return (
130
+ <SheetPrimitive.Description
131
+ data-slot="sheet-description"
132
+ className={cn("text-muted-foreground text-sm", className)}
133
+ {...props}
134
+ />
135
+ );
136
+ }
137
+
138
+ export {
139
+ Sheet,
140
+ SheetTrigger,
141
+ SheetClose,
142
+ SheetContent,
143
+ SheetHeader,
144
+ SheetFooter,
145
+ SheetTitle,
146
+ SheetDescription,
147
+ };