@ttt-productions/ui-core 0.11.18 → 0.11.19
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/package.json +2 -4
- package/src/index.ts +0 -3
- package/src/lib/format-numbers.ts +0 -17
- package/src/lib/utils.ts +0 -9
- package/src/react/components/accordion.tsx +0 -53
- package/src/react/components/alert-dialog.tsx +0 -131
- package/src/react/components/alert.tsx +0 -59
- package/src/react/components/avatar.tsx +0 -51
- package/src/react/components/badge.tsx +0 -31
- package/src/react/components/button.tsx +0 -102
- package/src/react/components/card.tsx +0 -54
- package/src/react/components/checkbox.tsx +0 -28
- package/src/react/components/chunk-error-recovery.tsx +0 -57
- package/src/react/components/collapsible.tsx +0 -11
- package/src/react/components/consequence-dialog.tsx +0 -282
- package/src/react/components/date-picker.tsx +0 -567
- package/src/react/components/dialog.tsx +0 -114
- package/src/react/components/dropdown-menu.tsx +0 -200
- package/src/react/components/end-of-list-indicator.tsx +0 -27
- package/src/react/components/form.tsx +0 -174
- package/src/react/components/input.tsx +0 -23
- package/src/react/components/label.tsx +0 -21
- package/src/react/components/layout/screen-adaptive-view.tsx +0 -106
- package/src/react/components/list-pagination.tsx +0 -101
- package/src/react/components/menubar.tsx +0 -220
- package/src/react/components/popover.tsx +0 -31
- package/src/react/components/progress.tsx +0 -27
- package/src/react/components/radio-group.tsx +0 -36
- package/src/react/components/relative-time.tsx +0 -56
- package/src/react/components/scroll-area.tsx +0 -56
- package/src/react/components/scroll-to-top-button.tsx +0 -85
- package/src/react/components/search-dropdown.tsx +0 -233
- package/src/react/components/select.tsx +0 -165
- package/src/react/components/separator.tsx +0 -26
- package/src/react/components/sheet.tsx +0 -140
- package/src/react/components/skeleton.tsx +0 -16
- package/src/react/components/slider.tsx +0 -25
- package/src/react/components/spinner.tsx +0 -49
- package/src/react/components/switch.tsx +0 -41
- package/src/react/components/table.tsx +0 -121
- package/src/react/components/tabs.tsx +0 -59
- package/src/react/components/textarea.tsx +0 -22
- package/src/react/components/toast.tsx +0 -193
- package/src/react/components/toaster.tsx +0 -43
- package/src/react/components/tooltip.tsx +0 -28
- package/src/react/hooks/use-async-action.ts +0 -63
- package/src/react/hooks/use-cursor-page.ts +0 -139
- package/src/react/hooks/use-media-query.tsx +0 -26
- package/src/react/hooks/use-paged-list.ts +0 -106
- package/src/react/hooks/use-return-scroll.ts +0 -149
- package/src/react/hooks/use-toast.tsx +0 -176
- package/src/react/index.ts +0 -85
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as React from "react"
|
|
4
|
-
import * as MenubarPrimitive from "@radix-ui/react-menubar"
|
|
5
|
-
import { Check, ChevronRight, Circle } from "lucide-react"
|
|
6
|
-
|
|
7
|
-
import { cn } from "../../lib/utils.js"
|
|
8
|
-
|
|
9
|
-
function MenubarMenu({ ...props }: React.ComponentProps<typeof MenubarPrimitive.Menu>) {
|
|
10
|
-
return <MenubarPrimitive.Menu {...props} />
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function MenubarGroup({ ...props }: React.ComponentProps<typeof MenubarPrimitive.Group>) {
|
|
14
|
-
return <MenubarPrimitive.Group {...props} />
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function MenubarPortal({ ...props }: React.ComponentProps<typeof MenubarPrimitive.Portal>) {
|
|
18
|
-
return <MenubarPrimitive.Portal {...props} />
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function MenubarRadioGroup({ ...props }: React.ComponentProps<typeof MenubarPrimitive.RadioGroup>) {
|
|
22
|
-
return <MenubarPrimitive.RadioGroup {...props} />
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function MenubarSub({ ...props }: React.ComponentProps<typeof MenubarPrimitive.Sub>) {
|
|
26
|
-
return <MenubarPrimitive.Sub data-slot="menubar-sub" {...props} />
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const Menubar = React.forwardRef<
|
|
30
|
-
React.ElementRef<typeof MenubarPrimitive.Root>,
|
|
31
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Root>
|
|
32
|
-
>(({ className, ...props }, ref) => (
|
|
33
|
-
<MenubarPrimitive.Root
|
|
34
|
-
ref={ref}
|
|
35
|
-
className={cn("flex h-10 items-center space-x-1 rounded-md border bg-background p-1", className)}
|
|
36
|
-
{...props}
|
|
37
|
-
/>
|
|
38
|
-
))
|
|
39
|
-
Menubar.displayName = MenubarPrimitive.Root.displayName
|
|
40
|
-
|
|
41
|
-
const MenubarTrigger = React.forwardRef<
|
|
42
|
-
React.ElementRef<typeof MenubarPrimitive.Trigger>,
|
|
43
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Trigger>
|
|
44
|
-
>(({ className, ...props }, ref) => (
|
|
45
|
-
<MenubarPrimitive.Trigger
|
|
46
|
-
ref={ref}
|
|
47
|
-
className={cn(
|
|
48
|
-
"flex cursor-default select-none items-center rounded-xs px-3 py-1.5 text-sm font-medium outline-hidden focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
|
49
|
-
className
|
|
50
|
-
)}
|
|
51
|
-
{...props}
|
|
52
|
-
/>
|
|
53
|
-
))
|
|
54
|
-
MenubarTrigger.displayName = MenubarPrimitive.Trigger.displayName
|
|
55
|
-
|
|
56
|
-
const MenubarSubTrigger = React.forwardRef<
|
|
57
|
-
React.ElementRef<typeof MenubarPrimitive.SubTrigger>,
|
|
58
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.SubTrigger> & { inset?: boolean }
|
|
59
|
-
>(({ className, inset, children, ...props }, ref) => (
|
|
60
|
-
<MenubarPrimitive.SubTrigger
|
|
61
|
-
ref={ref}
|
|
62
|
-
className={cn(
|
|
63
|
-
"flex cursor-default select-none items-center rounded-xs px-2 py-1.5 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
|
64
|
-
inset && "pl-8",
|
|
65
|
-
className
|
|
66
|
-
)}
|
|
67
|
-
{...props}
|
|
68
|
-
>
|
|
69
|
-
{children}
|
|
70
|
-
<ChevronRight className="ml-auto h-4 w-4" />
|
|
71
|
-
</MenubarPrimitive.SubTrigger>
|
|
72
|
-
))
|
|
73
|
-
MenubarSubTrigger.displayName = MenubarPrimitive.SubTrigger.displayName
|
|
74
|
-
|
|
75
|
-
const MenubarSubContent = React.forwardRef<
|
|
76
|
-
React.ElementRef<typeof MenubarPrimitive.SubContent>,
|
|
77
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.SubContent>
|
|
78
|
-
>(({ className, ...props }, ref) => (
|
|
79
|
-
<MenubarPrimitive.SubContent
|
|
80
|
-
ref={ref}
|
|
81
|
-
className={cn(
|
|
82
|
-
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 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",
|
|
83
|
-
className
|
|
84
|
-
)}
|
|
85
|
-
{...props}
|
|
86
|
-
/>
|
|
87
|
-
))
|
|
88
|
-
MenubarSubContent.displayName = MenubarPrimitive.SubContent.displayName
|
|
89
|
-
|
|
90
|
-
const MenubarContent = React.forwardRef<
|
|
91
|
-
React.ElementRef<typeof MenubarPrimitive.Content>,
|
|
92
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Content>
|
|
93
|
-
>(({ className, align = "start", alignOffset = -4, sideOffset = 8, ...props }, ref) => (
|
|
94
|
-
<MenubarPrimitive.Portal>
|
|
95
|
-
<MenubarPrimitive.Content
|
|
96
|
-
ref={ref}
|
|
97
|
-
align={align}
|
|
98
|
-
alignOffset={alignOffset}
|
|
99
|
-
sideOffset={sideOffset}
|
|
100
|
-
className={cn(
|
|
101
|
-
"z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground elevation-popover data-[state=open]:animate-in 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",
|
|
102
|
-
className
|
|
103
|
-
)}
|
|
104
|
-
{...props}
|
|
105
|
-
/>
|
|
106
|
-
</MenubarPrimitive.Portal>
|
|
107
|
-
))
|
|
108
|
-
MenubarContent.displayName = MenubarPrimitive.Content.displayName
|
|
109
|
-
|
|
110
|
-
const MenubarItem = React.forwardRef<
|
|
111
|
-
React.ElementRef<typeof MenubarPrimitive.Item>,
|
|
112
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Item> & { inset?: boolean }
|
|
113
|
-
>(({ className, inset, ...props }, ref) => (
|
|
114
|
-
<MenubarPrimitive.Item
|
|
115
|
-
ref={ref}
|
|
116
|
-
className={cn(
|
|
117
|
-
"relative flex cursor-default select-none items-center rounded-xs px-2 py-1.5 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
118
|
-
inset && "pl-8",
|
|
119
|
-
className
|
|
120
|
-
)}
|
|
121
|
-
{...props}
|
|
122
|
-
/>
|
|
123
|
-
))
|
|
124
|
-
MenubarItem.displayName = MenubarPrimitive.Item.displayName
|
|
125
|
-
|
|
126
|
-
const MenubarCheckboxItem = React.forwardRef<
|
|
127
|
-
React.ElementRef<typeof MenubarPrimitive.CheckboxItem>,
|
|
128
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.CheckboxItem>
|
|
129
|
-
>(({ className, children, checked, ...props }, ref) => (
|
|
130
|
-
<MenubarPrimitive.CheckboxItem
|
|
131
|
-
ref={ref}
|
|
132
|
-
className={cn(
|
|
133
|
-
"relative flex cursor-default select-none items-center rounded-xs py-1.5 pl-8 pr-2 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
134
|
-
className
|
|
135
|
-
)}
|
|
136
|
-
checked={checked}
|
|
137
|
-
{...props}
|
|
138
|
-
>
|
|
139
|
-
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
140
|
-
<MenubarPrimitive.ItemIndicator>
|
|
141
|
-
<Check className="h-4 w-4" />
|
|
142
|
-
</MenubarPrimitive.ItemIndicator>
|
|
143
|
-
</span>
|
|
144
|
-
{children}
|
|
145
|
-
</MenubarPrimitive.CheckboxItem>
|
|
146
|
-
))
|
|
147
|
-
MenubarCheckboxItem.displayName = MenubarPrimitive.CheckboxItem.displayName
|
|
148
|
-
|
|
149
|
-
const MenubarRadioItem = React.forwardRef<
|
|
150
|
-
React.ElementRef<typeof MenubarPrimitive.RadioItem>,
|
|
151
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.RadioItem>
|
|
152
|
-
>(({ className, children, ...props }, ref) => (
|
|
153
|
-
<MenubarPrimitive.RadioItem
|
|
154
|
-
ref={ref}
|
|
155
|
-
className={cn(
|
|
156
|
-
"relative flex cursor-default select-none items-center rounded-xs py-1.5 pl-8 pr-2 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
157
|
-
className
|
|
158
|
-
)}
|
|
159
|
-
{...props}
|
|
160
|
-
>
|
|
161
|
-
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
162
|
-
<MenubarPrimitive.ItemIndicator>
|
|
163
|
-
<Circle className="h-2 w-2 fill-current" />
|
|
164
|
-
</MenubarPrimitive.ItemIndicator>
|
|
165
|
-
</span>
|
|
166
|
-
{children}
|
|
167
|
-
</MenubarPrimitive.RadioItem>
|
|
168
|
-
))
|
|
169
|
-
MenubarRadioItem.displayName = MenubarPrimitive.RadioItem.displayName
|
|
170
|
-
|
|
171
|
-
const MenubarLabel = React.forwardRef<
|
|
172
|
-
React.ElementRef<typeof MenubarPrimitive.Label>,
|
|
173
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Label> & { inset?: boolean }
|
|
174
|
-
>(({ className, inset, ...props }, ref) => (
|
|
175
|
-
<MenubarPrimitive.Label
|
|
176
|
-
ref={ref}
|
|
177
|
-
className={cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className)}
|
|
178
|
-
{...props}
|
|
179
|
-
/>
|
|
180
|
-
))
|
|
181
|
-
MenubarLabel.displayName = MenubarPrimitive.Label.displayName
|
|
182
|
-
|
|
183
|
-
const MenubarSeparator = React.forwardRef<
|
|
184
|
-
React.ElementRef<typeof MenubarPrimitive.Separator>,
|
|
185
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Separator>
|
|
186
|
-
>(({ className, ...props }, ref) => (
|
|
187
|
-
<MenubarPrimitive.Separator
|
|
188
|
-
ref={ref}
|
|
189
|
-
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
|
190
|
-
{...props}
|
|
191
|
-
/>
|
|
192
|
-
))
|
|
193
|
-
MenubarSeparator.displayName = MenubarPrimitive.Separator.displayName
|
|
194
|
-
|
|
195
|
-
const MenubarShortcut = ({
|
|
196
|
-
className,
|
|
197
|
-
...props
|
|
198
|
-
}: React.HTMLAttributes<HTMLSpanElement>) => (
|
|
199
|
-
<span className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)} {...props} />
|
|
200
|
-
)
|
|
201
|
-
MenubarShortcut.displayname = "MenubarShortcut"
|
|
202
|
-
|
|
203
|
-
export {
|
|
204
|
-
Menubar,
|
|
205
|
-
MenubarMenu,
|
|
206
|
-
MenubarTrigger,
|
|
207
|
-
MenubarContent,
|
|
208
|
-
MenubarItem,
|
|
209
|
-
MenubarSeparator,
|
|
210
|
-
MenubarLabel,
|
|
211
|
-
MenubarCheckboxItem,
|
|
212
|
-
MenubarRadioGroup,
|
|
213
|
-
MenubarRadioItem,
|
|
214
|
-
MenubarPortal,
|
|
215
|
-
MenubarSubContent,
|
|
216
|
-
MenubarSubTrigger,
|
|
217
|
-
MenubarGroup,
|
|
218
|
-
MenubarSub,
|
|
219
|
-
MenubarShortcut,
|
|
220
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as React from "react"
|
|
4
|
-
import * as PopoverPrimitive from "@radix-ui/react-popover"
|
|
5
|
-
|
|
6
|
-
import { cn } from "../../lib/utils.js"
|
|
7
|
-
|
|
8
|
-
const Popover = PopoverPrimitive.Root
|
|
9
|
-
const PopoverTrigger = PopoverPrimitive.Trigger
|
|
10
|
-
const PopoverAnchor = PopoverPrimitive.Anchor
|
|
11
|
-
|
|
12
|
-
const PopoverContent = React.forwardRef<
|
|
13
|
-
React.ElementRef<typeof PopoverPrimitive.Content>,
|
|
14
|
-
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
|
|
15
|
-
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
|
16
|
-
<PopoverPrimitive.Portal>
|
|
17
|
-
<PopoverPrimitive.Content
|
|
18
|
-
ref={ref}
|
|
19
|
-
align={align}
|
|
20
|
-
sideOffset={sideOffset}
|
|
21
|
-
className={cn(
|
|
22
|
-
"z-50 w-72 rounded-md border !bg-card p-4 text-popover-foreground elevation-popover outline-hidden 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",
|
|
23
|
-
className
|
|
24
|
-
)}
|
|
25
|
-
{...props}
|
|
26
|
-
/>
|
|
27
|
-
</PopoverPrimitive.Portal>
|
|
28
|
-
))
|
|
29
|
-
PopoverContent.displayName = PopoverPrimitive.Content.displayName
|
|
30
|
-
|
|
31
|
-
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as React from "react"
|
|
4
|
-
import * as ProgressPrimitive from "@radix-ui/react-progress"
|
|
5
|
-
import { cn } from "../../lib/utils.js"
|
|
6
|
-
|
|
7
|
-
interface ProgressProps extends React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root> {
|
|
8
|
-
indicatorClassName?: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const Progress = React.forwardRef<React.ElementRef<typeof ProgressPrimitive.Root>, ProgressProps>(
|
|
12
|
-
({ className, value, indicatorClassName, ...props }, ref) => (
|
|
13
|
-
<ProgressPrimitive.Root
|
|
14
|
-
ref={ref}
|
|
15
|
-
className={cn("relative h-4 w-full overflow-hidden rounded-full bg-secondary", className)}
|
|
16
|
-
{...props}
|
|
17
|
-
>
|
|
18
|
-
<ProgressPrimitive.Indicator
|
|
19
|
-
className={cn("h-full w-full flex-1 bg-primary transition-all", indicatorClassName)}
|
|
20
|
-
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
|
|
21
|
-
/>
|
|
22
|
-
</ProgressPrimitive.Root>
|
|
23
|
-
)
|
|
24
|
-
)
|
|
25
|
-
Progress.displayName = ProgressPrimitive.Root.displayName
|
|
26
|
-
|
|
27
|
-
export { Progress }
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as React from "react"
|
|
4
|
-
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
|
|
5
|
-
import { Circle } from "lucide-react"
|
|
6
|
-
|
|
7
|
-
import { cn } from "../../lib/utils.js"
|
|
8
|
-
|
|
9
|
-
const RadioGroup = React.forwardRef<
|
|
10
|
-
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
|
11
|
-
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
|
|
12
|
-
>(({ className, ...props }, ref) => (
|
|
13
|
-
<RadioGroupPrimitive.Root className={cn("grid gap-2", className)} {...props} ref={ref} />
|
|
14
|
-
))
|
|
15
|
-
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName
|
|
16
|
-
|
|
17
|
-
const RadioGroupItem = React.forwardRef<
|
|
18
|
-
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
|
19
|
-
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
|
|
20
|
-
>(({ className, ...props }, ref) => (
|
|
21
|
-
<RadioGroupPrimitive.Item
|
|
22
|
-
ref={ref}
|
|
23
|
-
className={cn(
|
|
24
|
-
"aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
25
|
-
className
|
|
26
|
-
)}
|
|
27
|
-
{...props}
|
|
28
|
-
>
|
|
29
|
-
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
|
|
30
|
-
<Circle className="h-2.5 w-2.5 fill-current text-current" />
|
|
31
|
-
</RadioGroupPrimitive.Indicator>
|
|
32
|
-
</RadioGroupPrimitive.Item>
|
|
33
|
-
))
|
|
34
|
-
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName
|
|
35
|
-
|
|
36
|
-
export { RadioGroup, RadioGroupItem }
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { formatDistanceToNowStrict, toDate } from "@ttt-productions/firebase-helpers";
|
|
5
|
-
|
|
6
|
-
export interface RelativeTimeProps {
|
|
7
|
-
/** Number (ms or seconds), ISO string, Firestore Timestamp, or Date. */
|
|
8
|
-
timestamp: number | string | Date | undefined | null;
|
|
9
|
-
/** Fallback rendered before client hydration completes. Defaults to "...". */
|
|
10
|
-
placeholder?: string;
|
|
11
|
-
/** Fallback rendered when the timestamp can't be parsed. Defaults to "a while ago". */
|
|
12
|
-
fallback?: string;
|
|
13
|
-
/** Auto-refresh interval in ms. Defaults to 60000. Set to 0 to disable. */
|
|
14
|
-
refreshIntervalMs?: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* SSR-safe relative-time component.
|
|
19
|
-
* Renders `placeholder` on the server and pre-mount, then the live value.
|
|
20
|
-
*/
|
|
21
|
-
export function RelativeTime({
|
|
22
|
-
timestamp,
|
|
23
|
-
placeholder = "...",
|
|
24
|
-
fallback = "a while ago",
|
|
25
|
-
refreshIntervalMs = 60_000,
|
|
26
|
-
}: RelativeTimeProps) {
|
|
27
|
-
const [value, setValue] = React.useState<string>(placeholder);
|
|
28
|
-
|
|
29
|
-
React.useEffect(() => {
|
|
30
|
-
let date: Date | null = null;
|
|
31
|
-
if (timestamp instanceof Date) {
|
|
32
|
-
date = timestamp;
|
|
33
|
-
} else if (typeof timestamp === "number") {
|
|
34
|
-
date = toDate(timestamp);
|
|
35
|
-
} else if (typeof timestamp === "string") {
|
|
36
|
-
date = new Date(timestamp);
|
|
37
|
-
} else if (timestamp && typeof timestamp === "object" && "toDate" in timestamp) {
|
|
38
|
-
date = toDate(timestamp);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (!date || isNaN(date.getTime())) {
|
|
42
|
-
setValue(fallback);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
setValue(formatDistanceToNowStrict(date, { addSuffix: true }));
|
|
47
|
-
|
|
48
|
-
if (refreshIntervalMs <= 0) return;
|
|
49
|
-
const interval = setInterval(() => {
|
|
50
|
-
setValue(formatDistanceToNowStrict(date, { addSuffix: true }));
|
|
51
|
-
}, refreshIntervalMs);
|
|
52
|
-
return () => clearInterval(interval);
|
|
53
|
-
}, [timestamp, fallback, refreshIntervalMs]);
|
|
54
|
-
|
|
55
|
-
return <>{value}</>;
|
|
56
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as React from "react"
|
|
4
|
-
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"
|
|
5
|
-
|
|
6
|
-
import { cn } from "../../lib/utils.js"
|
|
7
|
-
|
|
8
|
-
interface ScrollAreaProps
|
|
9
|
-
extends React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> {
|
|
10
|
-
viewportRef?: React.Ref<HTMLDivElement>
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const ScrollArea = React.forwardRef<
|
|
14
|
-
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
|
15
|
-
ScrollAreaProps
|
|
16
|
-
>(({ className, children, viewportRef, ...props }, ref) => (
|
|
17
|
-
<ScrollAreaPrimitive.Root
|
|
18
|
-
ref={ref}
|
|
19
|
-
className={cn("relative overflow-hidden", className)}
|
|
20
|
-
{...props}
|
|
21
|
-
>
|
|
22
|
-
<ScrollAreaPrimitive.Viewport
|
|
23
|
-
ref={viewportRef}
|
|
24
|
-
className="h-full w-full rounded-[inherit]"
|
|
25
|
-
>
|
|
26
|
-
{children}
|
|
27
|
-
</ScrollAreaPrimitive.Viewport>
|
|
28
|
-
<ScrollBar />
|
|
29
|
-
<ScrollAreaPrimitive.Corner />
|
|
30
|
-
</ScrollAreaPrimitive.Root>
|
|
31
|
-
))
|
|
32
|
-
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName
|
|
33
|
-
|
|
34
|
-
const ScrollBar = React.forwardRef<
|
|
35
|
-
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
|
|
36
|
-
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
|
|
37
|
-
>(({ className, orientation = "vertical", ...props }, ref) => (
|
|
38
|
-
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
|
39
|
-
ref={ref}
|
|
40
|
-
orientation={orientation}
|
|
41
|
-
className={cn(
|
|
42
|
-
"flex touch-none select-none transition-colors",
|
|
43
|
-
orientation === "vertical" &&
|
|
44
|
-
"h-full w-2.5 border-l border-l-transparent p-[1px]",
|
|
45
|
-
orientation === "horizontal" &&
|
|
46
|
-
"h-2.5 flex-col border-t border-t-transparent p-[1px]",
|
|
47
|
-
className
|
|
48
|
-
)}
|
|
49
|
-
{...props}
|
|
50
|
-
>
|
|
51
|
-
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
|
|
52
|
-
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
|
53
|
-
))
|
|
54
|
-
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName
|
|
55
|
-
|
|
56
|
-
export { ScrollArea, ScrollBar }
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { ChevronUp } from "lucide-react";
|
|
5
|
-
import { Button, type ButtonProps } from "./button.js";
|
|
6
|
-
import { cn } from "../../lib/utils.js";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Standard button DOM props forwarded to the rendered element, minus the props
|
|
10
|
-
* this component owns. Owned props are excluded (not just overridden) so a
|
|
11
|
-
* consumer can never route them through the passthrough channel: `aria-label`
|
|
12
|
-
* is set via {@link ScrollToTopButtonProps.ariaLabel}, extra classes via the
|
|
13
|
-
* merge-aware {@link ScrollToTopButtonProps.className}, content via
|
|
14
|
-
* {@link ScrollToTopButtonProps.icon}, and `onClick` is fixed to scroll-to-top
|
|
15
|
-
* (its scroll animation configurable via
|
|
16
|
-
* {@link ScrollToTopButtonProps.scrollBehavior}). This mirrors how the sibling
|
|
17
|
-
* `Button` destructures its owned `className` out of the forwarded `...props`.
|
|
18
|
-
*/
|
|
19
|
-
type ScrollToTopButtonPassthrough = Omit<
|
|
20
|
-
React.ComponentPropsWithoutRef<"button">,
|
|
21
|
-
"className" | "onClick" | "aria-label" | "children"
|
|
22
|
-
>;
|
|
23
|
-
|
|
24
|
-
export interface ScrollToTopButtonProps extends ScrollToTopButtonPassthrough {
|
|
25
|
-
/** Scroll threshold (px) before the button appears. Default 400. */
|
|
26
|
-
threshold?: number;
|
|
27
|
-
/** Aria label. Default "Scroll to top". */
|
|
28
|
-
ariaLabel?: string;
|
|
29
|
-
/** Optional extra classes for the button. Merged with the component's own classes. */
|
|
30
|
-
className?: string;
|
|
31
|
-
/** Optional override for the icon. */
|
|
32
|
-
icon?: React.ReactNode;
|
|
33
|
-
/** Button variant. Forwarded to the underlying Button. Defaults to Button's own default. */
|
|
34
|
-
variant?: ButtonProps["variant"];
|
|
35
|
-
/** Button size. Forwarded to the underlying Button. Default "icon". */
|
|
36
|
-
size?: ButtonProps["size"];
|
|
37
|
-
/**
|
|
38
|
-
* Scroll behavior passed to `window.scrollTo`. Default "smooth". Pass "auto"
|
|
39
|
-
* to skip the smooth animation (e.g. for a reduced-motion mode). The package
|
|
40
|
-
* stays motion-policy agnostic: the consumer decides what to pass here — an
|
|
41
|
-
* explicit JS `behavior: "smooth"` is not overridden by a CSS
|
|
42
|
-
* `scroll-behavior` kill-switch, so an app-level reduced-motion mode must
|
|
43
|
-
* pass "auto" to actually stop the animation.
|
|
44
|
-
*/
|
|
45
|
-
scrollBehavior?: ScrollBehavior;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function ScrollToTopButton({
|
|
49
|
-
threshold = 400,
|
|
50
|
-
ariaLabel = "Scroll to top",
|
|
51
|
-
className,
|
|
52
|
-
icon,
|
|
53
|
-
variant,
|
|
54
|
-
size = "icon",
|
|
55
|
-
scrollBehavior = "smooth",
|
|
56
|
-
...rest
|
|
57
|
-
}: ScrollToTopButtonProps) {
|
|
58
|
-
const [isVisible, setIsVisible] = React.useState(false);
|
|
59
|
-
|
|
60
|
-
React.useEffect(() => {
|
|
61
|
-
const toggle = () => setIsVisible(window.scrollY > threshold);
|
|
62
|
-
toggle();
|
|
63
|
-
window.addEventListener("scroll", toggle, { passive: true });
|
|
64
|
-
return () => window.removeEventListener("scroll", toggle);
|
|
65
|
-
}, [threshold]);
|
|
66
|
-
|
|
67
|
-
const onClick = () => window.scrollTo({ top: 0, behavior: scrollBehavior });
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<Button
|
|
71
|
-
{...rest}
|
|
72
|
-
variant={variant}
|
|
73
|
-
size={size}
|
|
74
|
-
onClick={onClick}
|
|
75
|
-
aria-label={ariaLabel}
|
|
76
|
-
className={cn(
|
|
77
|
-
"fixed bottom-24 left-1/2 -translate-x-1/2 z-50 rounded-full elevation-raised transition-opacity duration-300",
|
|
78
|
-
isVisible ? "opacity-100" : "opacity-0 pointer-events-none",
|
|
79
|
-
className,
|
|
80
|
-
)}
|
|
81
|
-
>
|
|
82
|
-
{icon ?? <ChevronUp className="h-5 w-5" />}
|
|
83
|
-
</Button>
|
|
84
|
-
);
|
|
85
|
-
}
|