@playfast/reform-better-hub-ui-primitives 0.2.2 → 0.4.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.
- package/README.md +9 -9
- package/dist/components/agent-icon.d.ts +7 -0
- package/dist/components/agent-icon.d.ts.map +1 -0
- package/dist/components/agent-icon.js +5 -0
- package/dist/components/agent-icon.js.map +1 -0
- package/dist/components/autocomplete.d.ts +20 -0
- package/dist/components/autocomplete.d.ts.map +1 -0
- package/dist/components/autocomplete.js +81 -0
- package/dist/components/autocomplete.js.map +1 -0
- package/dist/components/badge.d.ts +13 -0
- package/dist/components/badge.d.ts.map +1 -0
- package/dist/components/badge.js +26 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/button.d.ts +14 -0
- package/dist/components/button.d.ts.map +1 -0
- package/dist/components/button.js +32 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/combobox.d.ts +28 -0
- package/dist/components/combobox.d.ts.map +1 -0
- package/dist/components/combobox.js +58 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/command.d.ts +20 -0
- package/dist/components/command.d.ts.map +1 -0
- package/dist/components/command.js +34 -0
- package/dist/components/command.js.map +1 -0
- package/dist/components/dialog.d.ts +17 -0
- package/dist/components/dialog.d.ts.map +1 -0
- package/dist/components/dialog.js +36 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/dropdown-menu.d.ts +19 -0
- package/dist/components/dropdown-menu.d.ts.map +1 -0
- package/dist/components/dropdown-menu.js +33 -0
- package/dist/components/dropdown-menu.js.map +1 -0
- package/dist/components/github-background.d.ts +3 -0
- package/dist/components/github-background.d.ts.map +1 -0
- package/dist/components/github-background.js +99 -0
- package/dist/components/github-background.js.map +1 -0
- package/dist/components/halftone-background.d.ts +3 -0
- package/dist/components/halftone-background.d.ts.map +1 -0
- package/dist/components/halftone-background.js +247 -0
- package/dist/components/halftone-background.js.map +1 -0
- package/dist/components/halftone-config.d.ts +12 -0
- package/dist/components/halftone-config.d.ts.map +1 -0
- package/dist/components/halftone-config.js +12 -0
- package/dist/components/halftone-config.js.map +1 -0
- package/dist/components/input-group.d.ts +21 -0
- package/dist/components/input-group.d.ts.map +1 -0
- package/dist/components/input-group.js +58 -0
- package/dist/components/input-group.js.map +1 -0
- package/dist/components/input.d.ts +5 -0
- package/dist/components/input.d.ts.map +1 -0
- package/dist/components/input.js +7 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/live-duration.d.ts +9 -0
- package/dist/components/live-duration.d.ts.map +1 -0
- package/dist/components/live-duration.js +64 -0
- package/dist/components/live-duration.js.map +1 -0
- package/dist/components/logo.d.ts +8 -0
- package/dist/components/logo.d.ts.map +1 -0
- package/dist/components/logo.js +9 -0
- package/dist/components/logo.js.map +1 -0
- package/dist/components/popover.d.ts +12 -0
- package/dist/components/popover.d.ts.map +1 -0
- package/dist/components/popover.js +30 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/resize-handle.d.ts +12 -0
- package/dist/components/resize-handle.d.ts.map +1 -0
- package/dist/components/resize-handle.js +36 -0
- package/dist/components/resize-handle.js.map +1 -0
- package/dist/components/sheet.d.ts +18 -0
- package/dist/components/sheet.d.ts.map +1 -0
- package/dist/components/sheet.js +42 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/textarea.d.ts +5 -0
- package/dist/components/textarea.d.ts.map +1 -0
- package/dist/components/textarea.js +7 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/time-ago.d.ts +8 -0
- package/dist/components/time-ago.d.ts.map +1 -0
- package/dist/components/time-ago.js +56 -0
- package/dist/components/time-ago.js.map +1 -0
- package/dist/components/tooltip.d.ts +10 -0
- package/dist/components/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip.js +23 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/foundation/cn.d.ts +3 -0
- package/dist/foundation/cn.d.ts.map +1 -0
- package/dist/foundation/cn.js +5 -0
- package/dist/foundation/cn.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -27
- package/src/components/agent-icon.tsx +16 -16
- package/src/components/autocomplete.tsx +166 -162
- package/src/components/badge.tsx +46 -45
- package/src/components/button.tsx +56 -63
- package/src/components/combobox.tsx +233 -228
- package/src/components/command.tsx +135 -139
- package/src/components/dialog.tsx +106 -98
- package/src/components/dropdown-menu.tsx +118 -115
- package/src/components/github-background.tsx +214 -216
- package/src/components/halftone-background.tsx +164 -155
- package/src/components/halftone-config.ts +8 -8
- package/src/components/input-group.tsx +149 -147
- package/src/components/input.tsx +17 -17
- package/src/components/live-duration.tsx +70 -64
- package/src/components/logo.tsx +9 -13
- package/src/components/popover.tsx +60 -62
- package/src/components/resize-handle.tsx +73 -75
- package/src/components/sheet.tsx +120 -112
- package/src/components/textarea.tsx +15 -15
- package/src/components/time-ago.tsx +64 -62
- package/src/components/tooltip.tsx +48 -42
- package/src/foundation/styles.css +6 -4
- package/src/index.ts +21 -21
|
@@ -1,77 +1,79 @@
|
|
|
1
|
-
import { DateTime } from
|
|
2
|
-
import type * as React from
|
|
3
|
-
import { useState, useEffect } from 'react'
|
|
1
|
+
import { DateTime } from 'effect'
|
|
2
|
+
import type * as React from 'react'
|
|
3
|
+
import { useState, useEffect } from 'react'
|
|
4
4
|
|
|
5
|
-
const MS_PER_SECOND = 1000
|
|
6
|
-
const SECONDS_PER_MINUTE = 60
|
|
7
|
-
const SECONDS_PER_HOUR = 3600
|
|
8
|
-
const SECONDS_PER_DAY = 86400
|
|
9
|
-
const SECONDS_PER_WEEK = 604800
|
|
10
|
-
const SECONDS_PER_MONTH = 2592000
|
|
11
|
-
const MONTHS_PER_YEAR = 12
|
|
12
|
-
const REFRESH_INTERVAL_MS = 60_000
|
|
5
|
+
const MS_PER_SECOND = 1000
|
|
6
|
+
const SECONDS_PER_MINUTE = 60
|
|
7
|
+
const SECONDS_PER_HOUR = 3600
|
|
8
|
+
const SECONDS_PER_DAY = 86400
|
|
9
|
+
const SECONDS_PER_WEEK = 604800
|
|
10
|
+
const SECONDS_PER_MONTH = 2592000
|
|
11
|
+
const MONTHS_PER_YEAR = 12
|
|
12
|
+
const REFRESH_INTERVAL_MS = 60_000
|
|
13
13
|
|
|
14
14
|
function timeAgo(date: string | Date): string {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const now = DateTime.unsafeNow()
|
|
16
|
+
const then = DateTime.unsafeMake(date)
|
|
17
|
+
const seconds = Math.floor(
|
|
18
|
+
(DateTime.toEpochMillis(now) - DateTime.toEpochMillis(then)) / MS_PER_SECOND,
|
|
19
|
+
)
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
if (seconds < SECONDS_PER_MINUTE) {
|
|
22
|
+
return 'just now'
|
|
23
|
+
}
|
|
24
|
+
if (seconds < SECONDS_PER_HOUR) {
|
|
25
|
+
return `${Math.floor(seconds / SECONDS_PER_MINUTE)}m ago`
|
|
26
|
+
}
|
|
27
|
+
if (seconds < SECONDS_PER_DAY) {
|
|
28
|
+
return `${Math.floor(seconds / SECONDS_PER_HOUR)}h ago`
|
|
29
|
+
}
|
|
30
|
+
if (seconds < SECONDS_PER_WEEK) {
|
|
31
|
+
return `${Math.floor(seconds / SECONDS_PER_DAY)}d ago`
|
|
32
|
+
}
|
|
33
|
+
if (seconds < SECONDS_PER_MONTH) {
|
|
34
|
+
return `${Math.floor(seconds / SECONDS_PER_WEEK)}w ago`
|
|
35
|
+
}
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const months = Math.floor(seconds / SECONDS_PER_MONTH)
|
|
38
|
+
if (months < MONTHS_PER_YEAR) {
|
|
39
|
+
return `${months}mo ago`
|
|
40
|
+
}
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
const thenDate = DateTime.toDate(then)
|
|
43
|
+
const sameYear = thenDate.getFullYear() === DateTime.toDate(now).getFullYear()
|
|
44
|
+
if (sameYear) {
|
|
45
|
+
return thenDate.toLocaleDateString('en-US', { month: 'short', day: 'numeric' })
|
|
46
|
+
}
|
|
47
|
+
return thenDate.toLocaleDateString('en-US', {
|
|
48
|
+
month: 'short',
|
|
49
|
+
day: 'numeric',
|
|
50
|
+
year: 'numeric',
|
|
51
|
+
})
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
interface TimeAgoPropsExternalApi {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
date: string | Date
|
|
56
|
+
className?: string
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
export function TimeAgo({ date, className }: TimeAgoPropsExternalApi): React.JSX.Element {
|
|
58
|
-
|
|
60
|
+
const [text, setText] = useState(() => timeAgo(date))
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
setText(timeAgo(date))
|
|
64
|
+
// oxlint-disable-next-line reform-rules/no-set-timeout-interval -- browser-timer seam: periodic relative-time refresh for React, no Effect runtime here
|
|
65
|
+
const interval = setInterval(() => setText(timeAgo(date)), REFRESH_INTERVAL_MS)
|
|
66
|
+
return () => clearInterval(interval)
|
|
67
|
+
}, [date])
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
return (
|
|
70
|
+
<time
|
|
71
|
+
dateTime={typeof date === 'string' ? date : date.toISOString()}
|
|
72
|
+
title={DateTime.toDate(DateTime.unsafeMake(date)).toLocaleString()}
|
|
73
|
+
className={className}
|
|
74
|
+
suppressHydrationWarning
|
|
75
|
+
>
|
|
76
|
+
{text}
|
|
77
|
+
</time>
|
|
78
|
+
)
|
|
77
79
|
}
|
|
@@ -1,61 +1,67 @@
|
|
|
1
|
-
import * as TooltipPrimitive from
|
|
2
|
-
import type * as React from
|
|
3
|
-
import { cn } from
|
|
1
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip'
|
|
2
|
+
import type * as React from 'react'
|
|
3
|
+
import { cn } from '../foundation/cn'
|
|
4
4
|
|
|
5
5
|
function TooltipProvider({
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
delayDuration = 300,
|
|
7
|
+
...props
|
|
8
8
|
}: React.ComponentProps<typeof TooltipPrimitive.Provider>): React.JSX.Element {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
return (
|
|
10
|
+
<TooltipPrimitive.Provider
|
|
11
|
+
data-slot="tooltip-provider"
|
|
12
|
+
delayDuration={delayDuration}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
)
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function Tooltip({
|
|
19
|
-
|
|
18
|
+
function Tooltip({
|
|
19
|
+
...props
|
|
20
|
+
}: React.ComponentProps<typeof TooltipPrimitive.Root>): React.JSX.Element {
|
|
21
|
+
return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
function TooltipTrigger({
|
|
23
|
-
|
|
24
|
+
function TooltipTrigger({
|
|
25
|
+
...props
|
|
26
|
+
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>): React.JSX.Element {
|
|
27
|
+
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
function TooltipPortal({
|
|
27
|
-
|
|
30
|
+
function TooltipPortal({
|
|
31
|
+
...props
|
|
32
|
+
}: React.ComponentProps<typeof TooltipPrimitive.Portal>): React.JSX.Element {
|
|
33
|
+
return <TooltipPrimitive.Portal data-slot="tooltip-portal" {...props} />
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
function TooltipContent({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
className,
|
|
38
|
+
sideOffset = 4,
|
|
39
|
+
...props
|
|
34
40
|
}: React.ComponentProps<typeof TooltipPrimitive.Content>): React.JSX.Element {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
return (
|
|
42
|
+
<TooltipPrimitive.Content
|
|
43
|
+
data-slot="tooltip-content"
|
|
44
|
+
sideOffset={sideOffset}
|
|
45
|
+
className={cn(
|
|
46
|
+
'bg-background text-popover-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 z-50 overflow-hidden rounded-md border px-3 py-1.5 text-sm shadow-md',
|
|
47
|
+
className,
|
|
48
|
+
)}
|
|
49
|
+
{...props}
|
|
50
|
+
/>
|
|
51
|
+
)
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
function TooltipArrow({
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
className,
|
|
56
|
+
...props
|
|
51
57
|
}: React.ComponentProps<typeof TooltipPrimitive.Arrow>): React.JSX.Element {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
return (
|
|
59
|
+
<TooltipPrimitive.Arrow
|
|
60
|
+
data-slot="tooltip-arrow"
|
|
61
|
+
className={cn('fill-background', className)}
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
)
|
|
59
65
|
}
|
|
60
66
|
|
|
61
|
-
export { Tooltip, TooltipArrow, TooltipContent, TooltipPortal, TooltipProvider, TooltipTrigger }
|
|
67
|
+
export { Tooltip, TooltipArrow, TooltipContent, TooltipPortal, TooltipProvider, TooltipTrigger }
|
|
@@ -82,10 +82,12 @@
|
|
|
82
82
|
|
|
83
83
|
/* Default theme: Midnight (dark) */
|
|
84
84
|
:root {
|
|
85
|
-
--font-geist-sans:
|
|
86
|
-
'
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
--font-geist-sans:
|
|
86
|
+
'Geist', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
|
|
87
|
+
'Helvetica Neue', Arial, sans-serif;
|
|
88
|
+
--font-geist-mono:
|
|
89
|
+
'Geist Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono',
|
|
90
|
+
monospace;
|
|
89
91
|
--radius-sm: 0.25rem;
|
|
90
92
|
--radius-md: 0.5rem;
|
|
91
93
|
--radius-lg: 0.75rem;
|
package/src/index.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
export * from './components/agent-icon'
|
|
2
|
-
export * from './components/autocomplete'
|
|
3
|
-
export * from './components/badge'
|
|
4
|
-
export * from './components/button'
|
|
5
|
-
export * from './components/combobox'
|
|
6
|
-
export * from './components/command'
|
|
7
|
-
export * from './components/dialog'
|
|
8
|
-
export * from './components/dropdown-menu'
|
|
9
|
-
export * from './components/github-background'
|
|
10
|
-
export * from './components/halftone-background'
|
|
11
|
-
export * from './components/input'
|
|
12
|
-
export * from './components/input-group'
|
|
13
|
-
export * from './components/live-duration'
|
|
14
|
-
export * from './components/logo'
|
|
15
|
-
export * from './components/popover'
|
|
16
|
-
export * from './components/resize-handle'
|
|
17
|
-
export * from './components/sheet'
|
|
18
|
-
export * from './components/textarea'
|
|
19
|
-
export * from './components/time-ago'
|
|
20
|
-
export * from './components/tooltip'
|
|
1
|
+
export * from './components/agent-icon'
|
|
2
|
+
export * from './components/autocomplete'
|
|
3
|
+
export * from './components/badge'
|
|
4
|
+
export * from './components/button'
|
|
5
|
+
export * from './components/combobox'
|
|
6
|
+
export * from './components/command'
|
|
7
|
+
export * from './components/dialog'
|
|
8
|
+
export * from './components/dropdown-menu'
|
|
9
|
+
export * from './components/github-background'
|
|
10
|
+
export * from './components/halftone-background'
|
|
11
|
+
export * from './components/input'
|
|
12
|
+
export * from './components/input-group'
|
|
13
|
+
export * from './components/live-duration'
|
|
14
|
+
export * from './components/logo'
|
|
15
|
+
export * from './components/popover'
|
|
16
|
+
export * from './components/resize-handle'
|
|
17
|
+
export * from './components/sheet'
|
|
18
|
+
export * from './components/textarea'
|
|
19
|
+
export * from './components/time-ago'
|
|
20
|
+
export * from './components/tooltip'
|
|
21
21
|
|
|
22
|
-
export { cn } from './foundation/cn'
|
|
22
|
+
export { cn } from './foundation/cn'
|