@boyernick/standard-ui-react 0.1.1-canary.3 → 0.1.1-canary.34
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 +5 -3
- package/src/accordion.tsx +5 -2
- package/src/alert-dialog.tsx +1 -1
- package/src/attachment.tsx +5 -2
- package/src/autocomplete.tsx +12 -9
- package/src/badge.tsx +73 -9
- package/src/block-editor.tsx +1747 -0
- package/src/brand.tsx +2 -2
- package/src/breadcrumb.tsx +46 -21
- package/src/button.tsx +23 -12
- package/src/calendar.tsx +25 -11
- package/src/card.tsx +57 -14
- package/src/carousel.tsx +339 -15
- package/src/checkbox.tsx +36 -13
- package/src/code-block.tsx +66 -5
- package/src/collapsible.tsx +7 -3
- package/src/combobox.tsx +17 -15
- package/src/command.tsx +41 -14
- package/src/context-menu.tsx +6 -3
- package/src/date-picker.tsx +174 -0
- package/src/dialog.tsx +33 -10
- package/src/empty.tsx +4 -4
- package/src/field.tsx +4 -3
- package/src/filter-group.tsx +143 -0
- package/src/icons.tsx +55 -1
- package/src/illustrations.tsx +219 -141
- package/src/index.ts +263 -18
- package/src/input.tsx +8 -5
- package/src/kbd.tsx +49 -0
- package/src/lib/focus.ts +41 -0
- package/src/lib/motion.ts +16 -1
- package/src/lib/popup.ts +45 -0
- package/src/lifeline/company-icon.tsx +71 -0
- package/src/lifeline/index.ts +42 -0
- package/src/lifeline/lifeline-data.ts +97 -0
- package/src/lifeline/lifeline-desktop.tsx +204 -0
- package/src/lifeline/lifeline-event.tsx +108 -0
- package/src/lifeline/lifeline-fireworks.tsx +302 -0
- package/src/lifeline/lifeline-hover-image.tsx +269 -0
- package/src/lifeline/lifeline-icons.tsx +39 -0
- package/src/lifeline/lifeline-intro-timing.ts +105 -0
- package/src/lifeline/lifeline-labels.tsx +24 -0
- package/src/lifeline/lifeline-layout.ts +1 -0
- package/src/lifeline/lifeline-legend.tsx +31 -0
- package/src/lifeline/lifeline-lightbox.tsx +309 -0
- package/src/lifeline/lifeline-marker.tsx +183 -0
- package/src/lifeline/lifeline-people.tsx +99 -0
- package/src/lifeline/lifeline-photos.tsx +366 -0
- package/src/lifeline/lifeline-shell.tsx +135 -0
- package/src/lifeline/lifeline-utils.ts +83 -0
- package/src/lifeline/lifeline-vertical.tsx +482 -0
- package/src/lifeline/lifeline.tsx +69 -0
- package/src/lifeline/types.ts +112 -0
- package/src/lifeline/use-lifeline-intro.ts +130 -0
- package/src/lifeline/use-lifeline-scroll.ts +1011 -0
- package/src/lifeline/use-lifeline-vertical-scroll.ts +271 -0
- package/src/menu.tsx +7 -4
- package/src/menubar.tsx +9 -2
- package/src/minimap.tsx +296 -0
- package/src/modal.tsx +608 -0
- package/src/navigation-menu.tsx +340 -67
- package/src/number-field.tsx +336 -61
- package/src/otp-field.tsx +4 -3
- package/src/pagination.tsx +262 -42
- package/src/password-protection.tsx +345 -0
- package/src/popover.tsx +3 -1
- package/src/preview-card.tsx +3 -1
- package/src/progress.tsx +5 -0
- package/src/questionnaire.tsx +284 -0
- package/src/radio.tsx +4 -2
- package/src/scroll-area.tsx +4 -1
- package/src/select.tsx +12 -7
- package/src/sidebar.tsx +113 -28
- package/src/slider.tsx +66 -6
- package/src/sounds.tsx +6 -10
- package/src/spinner.tsx +105 -32
- package/src/switch.tsx +4 -1
- package/src/table.tsx +82 -15
- package/src/tabs.tsx +189 -38
- package/src/text-animate.tsx +71 -28
- package/src/textarea.tsx +6 -1
- package/src/timeline.tsx +378 -0
- package/src/toast.tsx +214 -35
- package/src/toggle.tsx +4 -2
- package/src/toolbar.tsx +12 -7
- package/src/tooltip.tsx +43 -3
- package/src/video-player.tsx +396 -127
- package/src/image-modal.tsx +0 -110
- package/src/markdown-editor.tsx +0 -302
package/src/slider.tsx
CHANGED
|
@@ -1,21 +1,52 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { Slider as BaseSlider } from "@base-ui/react/slider"
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
4
5
|
import type { ComponentProps } from "react"
|
|
5
6
|
import { cn } from "./lib/cn"
|
|
7
|
+
import { focusRing } from "./lib/focus"
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
const sliderVariants = cva(
|
|
10
|
+
"group/slider relative flex w-full data-disabled:opacity-50 data-[orientation=vertical]:h-48 data-[orientation=vertical]:w-fit",
|
|
11
|
+
{
|
|
12
|
+
variants: {
|
|
13
|
+
size: {
|
|
14
|
+
sm: "[--slider-thumb-size:0.875rem] [--slider-track-size:0.25rem]",
|
|
15
|
+
md: "[--slider-thumb-size:1rem] [--slider-track-size:0.375rem]",
|
|
16
|
+
lg: "[--slider-thumb-size:1.25rem] [--slider-track-size:0.5rem]",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
size: "md",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
export type SliderProps = Omit<
|
|
26
|
+
ComponentProps<typeof BaseSlider.Root>,
|
|
27
|
+
"size"
|
|
28
|
+
> &
|
|
29
|
+
VariantProps<typeof sliderVariants>
|
|
8
30
|
export type SliderControlProps = ComponentProps<typeof BaseSlider.Control>
|
|
9
31
|
export type SliderTrackProps = ComponentProps<typeof BaseSlider.Track>
|
|
10
32
|
export type SliderIndicatorProps = ComponentProps<typeof BaseSlider.Indicator>
|
|
11
33
|
export type SliderThumbProps = ComponentProps<typeof BaseSlider.Thumb>
|
|
34
|
+
export type SliderTicksProps = ComponentProps<"div"> & {
|
|
35
|
+
/** Number of evenly spaced marks, including both ends. */
|
|
36
|
+
count?: number
|
|
37
|
+
}
|
|
12
38
|
|
|
13
|
-
export const Slider = (props: SliderProps) =>
|
|
39
|
+
export const Slider = ({ className, size, ...props }: SliderProps) => (
|
|
40
|
+
<BaseSlider.Root
|
|
41
|
+
className={cn(sliderVariants({ size }), className)}
|
|
42
|
+
{...props}
|
|
43
|
+
/>
|
|
44
|
+
)
|
|
14
45
|
|
|
15
46
|
export const SliderControl = ({ className, ...props }: SliderControlProps) => (
|
|
16
47
|
<BaseSlider.Control
|
|
17
48
|
className={cn(
|
|
18
|
-
"flex w-full touch-none items-center py-3 select-none",
|
|
49
|
+
"flex w-full touch-none items-center py-3 select-none data-disabled:cursor-not-allowed data-[orientation=vertical]:h-full data-[orientation=vertical]:w-auto data-[orientation=vertical]:px-3 data-[orientation=vertical]:py-0",
|
|
19
50
|
className,
|
|
20
51
|
)}
|
|
21
52
|
{...props}
|
|
@@ -25,7 +56,7 @@ export const SliderControl = ({ className, ...props }: SliderControlProps) => (
|
|
|
25
56
|
export const SliderTrack = ({ className, ...props }: SliderTrackProps) => (
|
|
26
57
|
<BaseSlider.Track
|
|
27
58
|
className={cn(
|
|
28
|
-
"relative h-
|
|
59
|
+
"relative h-[var(--slider-track-size)] w-full rounded-full bg-background-quaternary transition-colors duration-[var(--duration-sm)] group-hover/slider:bg-background-active data-[orientation=vertical]:h-full data-[orientation=vertical]:w-[var(--slider-track-size)]",
|
|
29
60
|
className,
|
|
30
61
|
)}
|
|
31
62
|
{...props}
|
|
@@ -38,7 +69,7 @@ export const SliderIndicator = ({
|
|
|
38
69
|
}: SliderIndicatorProps) => (
|
|
39
70
|
<BaseSlider.Indicator
|
|
40
71
|
className={cn(
|
|
41
|
-
"absolute h-full rounded-full bg-brand-primary
|
|
72
|
+
"absolute h-full rounded-full bg-brand-primary data-[orientation=vertical]:h-auto data-[orientation=vertical]:w-full",
|
|
42
73
|
className,
|
|
43
74
|
)}
|
|
44
75
|
{...props}
|
|
@@ -48,9 +79,38 @@ export const SliderIndicator = ({
|
|
|
48
79
|
export const SliderThumb = ({ className, ...props }: SliderThumbProps) => (
|
|
49
80
|
<BaseSlider.Thumb
|
|
50
81
|
className={cn(
|
|
51
|
-
"size-
|
|
82
|
+
"flex size-[var(--slider-thumb-size)] cursor-grab items-center justify-center rounded-full border border-brand-primary-border bg-surface shadow-sm transition-[scale,box-shadow,background-color,border-color] duration-[var(--duration-sm)] ease-enter after:size-1 after:rounded-full after:bg-brand-primary after:content-[''] hover:scale-110 hover:bg-background-secondary active:scale-105 data-dragging:cursor-grabbing data-dragging:scale-110 data-disabled:cursor-not-allowed data-disabled:hover:scale-100",
|
|
83
|
+
focusRing,
|
|
52
84
|
className,
|
|
53
85
|
)}
|
|
54
86
|
{...props}
|
|
55
87
|
/>
|
|
56
88
|
)
|
|
89
|
+
|
|
90
|
+
export const SliderTicks = ({
|
|
91
|
+
count = 5,
|
|
92
|
+
className,
|
|
93
|
+
...props
|
|
94
|
+
}: SliderTicksProps) => {
|
|
95
|
+
const tickCount = Number.isFinite(count) ? Math.max(2, Math.floor(count)) : 2
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<div
|
|
99
|
+
aria-hidden
|
|
100
|
+
className={cn(
|
|
101
|
+
"pointer-events-none absolute inset-0 flex items-center justify-between group-data-[orientation=vertical]/slider:flex-col",
|
|
102
|
+
className,
|
|
103
|
+
)}
|
|
104
|
+
{...props}
|
|
105
|
+
>
|
|
106
|
+
{Array.from({ length: tickCount }, (_, index) => (
|
|
107
|
+
<span
|
|
108
|
+
key={index}
|
|
109
|
+
className="h-2 w-px rounded-full bg-surface/70 group-data-[orientation=vertical]/slider:h-px group-data-[orientation=vertical]/slider:w-2"
|
|
110
|
+
/>
|
|
111
|
+
))}
|
|
112
|
+
</div>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export { sliderVariants }
|
package/src/sounds.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
+
import { IconPlay } from "@central-icons-react/round-filled-radius-2-stroke-2/IconPlay"
|
|
3
4
|
import {
|
|
4
5
|
createContext,
|
|
5
6
|
useCallback,
|
|
@@ -28,7 +29,7 @@ const SOUND_PRESETS: SoundPreset[] = [
|
|
|
28
29
|
{
|
|
29
30
|
id: "click",
|
|
30
31
|
label: "Click",
|
|
31
|
-
description: "
|
|
32
|
+
description: "Confirmation for toggles and secondary actions.",
|
|
32
33
|
play: (ctx, when, destination) => {
|
|
33
34
|
const osc = ctx.createOscillator()
|
|
34
35
|
const gain = ctx.createGain()
|
|
@@ -219,14 +220,15 @@ export const Sound = ({
|
|
|
219
220
|
>
|
|
220
221
|
<Button
|
|
221
222
|
type="button"
|
|
222
|
-
variant="
|
|
223
|
-
size="
|
|
223
|
+
variant="secondary"
|
|
224
|
+
size="md"
|
|
224
225
|
iconOnly
|
|
225
226
|
rounded
|
|
227
|
+
className="shrink-0 hover:scale-[1.04] active:scale-95"
|
|
226
228
|
aria-label={`Play ${resolvedLabel}`}
|
|
227
229
|
onClick={handlePlay}
|
|
228
230
|
>
|
|
229
|
-
<
|
|
231
|
+
<IconPlay size={12} mode="raw" className="size-3" aria-hidden />
|
|
230
232
|
</Button>
|
|
231
233
|
<div className="min-w-0 flex-1">
|
|
232
234
|
<p className="text-sm-strong text-fg-primary">{resolvedLabel}</p>
|
|
@@ -262,9 +264,3 @@ export const SoundToggle = ({
|
|
|
262
264
|
</Button>
|
|
263
265
|
)
|
|
264
266
|
}
|
|
265
|
-
|
|
266
|
-
const PlayIcon = () => (
|
|
267
|
-
<svg viewBox="0 0 24 24" fill="none" className="size-4" aria-hidden>
|
|
268
|
-
<path d="M9 7.5v9l8-4.5-8-4.5Z" fill="currentColor" />
|
|
269
|
-
</svg>
|
|
270
|
-
)
|
package/src/spinner.tsx
CHANGED
|
@@ -2,44 +2,117 @@ import { cva, type VariantProps } from "class-variance-authority";
|
|
|
2
2
|
import type { ComponentProps } from "react";
|
|
3
3
|
import { cn } from "./lib/cn";
|
|
4
4
|
|
|
5
|
+
const SPINNER_SPOKES = Array.from({ length: 12 }, (_, index) => index);
|
|
6
|
+
|
|
5
7
|
const spinnerVariants = cva(
|
|
6
|
-
"
|
|
7
|
-
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
"text-current motion-reduce:animate-none",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
ring: "animate-spin",
|
|
13
|
+
arc: "animate-spin",
|
|
14
|
+
dots: "",
|
|
15
|
+
spokes: "",
|
|
16
|
+
},
|
|
17
|
+
size: {
|
|
18
|
+
sm: "size-3.5",
|
|
19
|
+
md: "size-4",
|
|
20
|
+
lg: "size-5",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
variant: "ring",
|
|
25
|
+
size: "md",
|
|
12
26
|
},
|
|
13
27
|
},
|
|
14
|
-
|
|
15
|
-
size: "md",
|
|
16
|
-
},
|
|
17
|
-
});
|
|
28
|
+
);
|
|
18
29
|
|
|
19
30
|
export type SpinnerProps = ComponentProps<"svg"> &
|
|
20
31
|
VariantProps<typeof spinnerVariants>;
|
|
21
32
|
|
|
22
|
-
export const Spinner = ({
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
export const Spinner = ({
|
|
34
|
+
className,
|
|
35
|
+
variant,
|
|
36
|
+
size,
|
|
37
|
+
...props
|
|
38
|
+
}: SpinnerProps) => {
|
|
39
|
+
const resolvedVariant = variant ?? "ring";
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<svg
|
|
43
|
+
role="status"
|
|
44
|
+
aria-label="Loading"
|
|
45
|
+
className={cn(
|
|
46
|
+
spinnerVariants({ variant: resolvedVariant, size }),
|
|
47
|
+
className,
|
|
48
|
+
)}
|
|
49
|
+
viewBox="0 0 24 24"
|
|
50
|
+
fill="none"
|
|
51
|
+
{...props}
|
|
52
|
+
>
|
|
53
|
+
{resolvedVariant === "spokes" ? (
|
|
54
|
+
<g stroke="currentColor" strokeWidth="2.25" strokeLinecap="round">
|
|
55
|
+
{SPINNER_SPOKES.map((spoke) => (
|
|
56
|
+
<line
|
|
57
|
+
key={spoke}
|
|
58
|
+
x1="12"
|
|
59
|
+
y1="3"
|
|
60
|
+
x2="12"
|
|
61
|
+
y2="6.25"
|
|
62
|
+
transform={`rotate(${spoke * 30} 12 12)`}
|
|
63
|
+
className="animate-[spinner-spoke_1.2s_linear_infinite] motion-reduce:animate-none motion-reduce:opacity-40"
|
|
64
|
+
style={{ animationDelay: `${spoke * -0.1}s` }}
|
|
65
|
+
/>
|
|
66
|
+
))}
|
|
67
|
+
</g>
|
|
68
|
+
) : resolvedVariant === "dots" ? (
|
|
69
|
+
<g fill="currentColor">
|
|
70
|
+
<circle
|
|
71
|
+
cx="5"
|
|
72
|
+
cy="12"
|
|
73
|
+
r="2.25"
|
|
74
|
+
className="animate-[spinner-dot_1.2s_var(--ease-passive)_infinite] [animation-delay:-0.32s] motion-reduce:animate-none"
|
|
75
|
+
/>
|
|
76
|
+
<circle
|
|
77
|
+
cx="12"
|
|
78
|
+
cy="12"
|
|
79
|
+
r="2.25"
|
|
80
|
+
className="animate-[spinner-dot_1.2s_var(--ease-passive)_infinite] [animation-delay:-0.16s] motion-reduce:animate-none"
|
|
81
|
+
/>
|
|
82
|
+
<circle
|
|
83
|
+
cx="19"
|
|
84
|
+
cy="12"
|
|
85
|
+
r="2.25"
|
|
86
|
+
className="animate-[spinner-dot_1.2s_var(--ease-passive)_infinite] motion-reduce:animate-none"
|
|
87
|
+
/>
|
|
88
|
+
</g>
|
|
89
|
+
) : resolvedVariant === "arc" ? (
|
|
90
|
+
<circle
|
|
91
|
+
cx="12"
|
|
92
|
+
cy="12"
|
|
93
|
+
r="9"
|
|
94
|
+
stroke="currentColor"
|
|
95
|
+
strokeWidth="2.5"
|
|
96
|
+
strokeLinecap="round"
|
|
97
|
+
strokeDasharray="42 15"
|
|
98
|
+
/>
|
|
99
|
+
) : (
|
|
100
|
+
<>
|
|
101
|
+
<path
|
|
102
|
+
d="M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z"
|
|
103
|
+
stroke="currentColor"
|
|
104
|
+
strokeOpacity="0.3"
|
|
105
|
+
strokeWidth="2"
|
|
106
|
+
/>
|
|
107
|
+
<path
|
|
108
|
+
d="M21 12C21 16.9706 16.9706 21 12 21"
|
|
109
|
+
stroke="currentColor"
|
|
110
|
+
strokeWidth="2"
|
|
111
|
+
/>
|
|
112
|
+
</>
|
|
113
|
+
)}
|
|
114
|
+
</svg>
|
|
115
|
+
);
|
|
116
|
+
};
|
|
44
117
|
|
|
45
118
|
export { spinnerVariants };
|
package/src/switch.tsx
CHANGED
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
import { Switch as BaseSwitch } from "@base-ui/react/switch"
|
|
4
4
|
import type { ComponentProps } from "react"
|
|
5
5
|
import { cn } from "./lib/cn"
|
|
6
|
+
import { focusRing, focusRingBorder } from "./lib/focus"
|
|
6
7
|
|
|
7
8
|
export type SwitchProps = ComponentProps<typeof BaseSwitch.Root>
|
|
8
9
|
|
|
9
10
|
export const Switch = ({ className, ...props }: SwitchProps) => (
|
|
10
11
|
<BaseSwitch.Root
|
|
11
12
|
className={cn(
|
|
12
|
-
"relative inline-flex h-6 w-10 shrink-0 items-center rounded-full bg-background-quaternary transition-colors duration-[var(--duration-sm)] ease-enter motion-reduce:transition-none
|
|
13
|
+
"relative inline-flex h-6 w-10 shrink-0 items-center rounded-full bg-background-quaternary transition-colors duration-[var(--duration-sm)] ease-enter motion-reduce:transition-none data-checked:bg-brand-primary data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
|
14
|
+
focusRingBorder,
|
|
15
|
+
focusRing,
|
|
13
16
|
className,
|
|
14
17
|
)}
|
|
15
18
|
{...props}
|
package/src/table.tsx
CHANGED
|
@@ -1,8 +1,60 @@
|
|
|
1
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
1
2
|
import type { ComponentProps } from "react";
|
|
2
3
|
import { cn } from "./lib/cn";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
const tableVariants = cva(
|
|
6
|
+
"group/table w-full text-sm text-fg-primary",
|
|
7
|
+
{
|
|
8
|
+
variants: {
|
|
9
|
+
variant: {
|
|
10
|
+
default: "border-collapse",
|
|
11
|
+
grid: [
|
|
12
|
+
"border-separate border-spacing-0",
|
|
13
|
+
"[&_tr]:border-b-0",
|
|
14
|
+
"[&_tr>*]:border-r [&_tr>*]:border-b [&_tr>*]:border-border-primary",
|
|
15
|
+
"[&_tr>*:last-child]:border-r-0",
|
|
16
|
+
"[&_tbody_tr:last-child>*]:border-b-0 [&_tfoot_tr:last-child>*]:border-b-0",
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
density: {
|
|
20
|
+
default: "",
|
|
21
|
+
compact: "[&_th]:h-8 [&_th]:px-3 [&_td]:px-3 [&_td]:py-2",
|
|
22
|
+
},
|
|
23
|
+
striped: {
|
|
24
|
+
true: "[&_tbody_tr:nth-child(even)]:bg-background-secondary",
|
|
25
|
+
false: "",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
defaultVariants: {
|
|
29
|
+
variant: "default",
|
|
30
|
+
density: "default",
|
|
31
|
+
striped: false,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const tableHeaderVariants = cva(
|
|
37
|
+
"bg-background-secondary [&_tr]:border-b [&_tr]:border-border-primary",
|
|
38
|
+
{
|
|
39
|
+
variants: {
|
|
40
|
+
sticky: {
|
|
41
|
+
true: "[&_th]:sticky [&_th]:top-0 [&_th]:z-10 [&_th]:bg-background-secondary [&_th]:py-2.5",
|
|
42
|
+
false: "",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
defaultVariants: {
|
|
46
|
+
sticky: false,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
export type TableProps = ComponentProps<"table"> &
|
|
52
|
+
VariantProps<typeof tableVariants> & {
|
|
53
|
+
/** Classes for the bordered horizontal-scroll container. */
|
|
54
|
+
containerClassName?: string;
|
|
55
|
+
};
|
|
56
|
+
export type TableHeaderProps = ComponentProps<"thead"> &
|
|
57
|
+
VariantProps<typeof tableHeaderVariants>;
|
|
6
58
|
export type TableBodyProps = ComponentProps<"tbody">;
|
|
7
59
|
export type TableFooterProps = ComponentProps<"tfoot">;
|
|
8
60
|
export type TableRowProps = ComponentProps<"tr">;
|
|
@@ -10,24 +62,37 @@ export type TableHeadProps = ComponentProps<"th">;
|
|
|
10
62
|
export type TableCellProps = ComponentProps<"td">;
|
|
11
63
|
export type TableCaptionProps = ComponentProps<"caption">;
|
|
12
64
|
|
|
13
|
-
export const Table = ({
|
|
14
|
-
|
|
65
|
+
export const Table = ({
|
|
66
|
+
className,
|
|
67
|
+
containerClassName,
|
|
68
|
+
variant,
|
|
69
|
+
density,
|
|
70
|
+
striped,
|
|
71
|
+
...props
|
|
72
|
+
}: TableProps) => (
|
|
73
|
+
<div
|
|
74
|
+
className={cn(
|
|
75
|
+
"w-full overflow-auto rounded-lg border border-border-primary bg-surface",
|
|
76
|
+
containerClassName,
|
|
77
|
+
)}
|
|
78
|
+
>
|
|
15
79
|
<table
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
)}
|
|
80
|
+
data-variant={variant ?? "default"}
|
|
81
|
+
data-density={density ?? "default"}
|
|
82
|
+
data-striped={striped || undefined}
|
|
83
|
+
className={cn(tableVariants({ variant, density, striped }), className)}
|
|
20
84
|
{...props}
|
|
21
85
|
/>
|
|
22
86
|
</div>
|
|
23
87
|
);
|
|
24
88
|
|
|
25
|
-
export const TableHeader = ({
|
|
89
|
+
export const TableHeader = ({
|
|
90
|
+
className,
|
|
91
|
+
sticky,
|
|
92
|
+
...props
|
|
93
|
+
}: TableHeaderProps) => (
|
|
26
94
|
<thead
|
|
27
|
-
className={cn(
|
|
28
|
-
"bg-background-secondary [&_tr]:border-b [&_tr]:border-border-primary",
|
|
29
|
-
className,
|
|
30
|
-
)}
|
|
95
|
+
className={cn(tableHeaderVariants({ sticky }), className)}
|
|
31
96
|
{...props}
|
|
32
97
|
/>
|
|
33
98
|
);
|
|
@@ -39,7 +104,7 @@ export const TableBody = ({ className, ...props }: TableBodyProps) => (
|
|
|
39
104
|
export const TableFooter = ({ className, ...props }: TableFooterProps) => (
|
|
40
105
|
<tfoot
|
|
41
106
|
className={cn(
|
|
42
|
-
"border-t border-border-primary bg-background-secondary font-medium",
|
|
107
|
+
"border-t border-border-primary bg-background-secondary font-medium [&_tr]:hover:bg-transparent",
|
|
43
108
|
className,
|
|
44
109
|
)}
|
|
45
110
|
{...props}
|
|
@@ -49,7 +114,7 @@ export const TableFooter = ({ className, ...props }: TableFooterProps) => (
|
|
|
49
114
|
export const TableRow = ({ className, ...props }: TableRowProps) => (
|
|
50
115
|
<tr
|
|
51
116
|
className={cn(
|
|
52
|
-
"border-b border-border-primary hover:bg-background-secondary",
|
|
117
|
+
"border-b border-border-primary transition-colors duration-[var(--duration-sm)] ease-enter hover:bg-background-secondary aria-selected:bg-background-tertiary data-[selected]:bg-background-tertiary data-[state=selected]:bg-background-tertiary",
|
|
53
118
|
className,
|
|
54
119
|
)}
|
|
55
120
|
{...props}
|
|
@@ -79,3 +144,5 @@ export const TableCaption = ({ className, ...props }: TableCaptionProps) => (
|
|
|
79
144
|
{...props}
|
|
80
145
|
/>
|
|
81
146
|
);
|
|
147
|
+
|
|
148
|
+
export { tableHeaderVariants, tableVariants };
|