@catalystsoftware/ui 1.0.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 +7 -0
- package/components/catalyst-ui/buttons/burger.tsx +207 -0
- package/components/catalyst-ui/core/data-display/timeline.tsx +210 -0
- package/components/catalyst-ui/core/feedback/alert.tsx +491 -0
- package/components/catalyst-ui/core/feedback/spinner-1.tsx +65 -0
- package/components/catalyst-ui/core/feedback/toast.tsx +1857 -0
- package/components/catalyst-ui/core/navigation/menu.tsx +164 -0
- package/components/catalyst-ui/forms/toggle-class.tsx +176 -0
- package/components/catalyst-ui/hooks/use-copy-to-clipboard.tsx +419 -0
- package/components/catalyst-ui/hooks/use-counter.tsx +13 -0
- package/components/catalyst-ui/hooks/use-event-listener.tsx +23 -0
- package/components/catalyst-ui/hooks/use-export-markdown.tsx +47 -0
- package/components/catalyst-ui/hooks/use-focus.tsx +17 -0
- package/components/catalyst-ui/hooks/use-interval.tsx +23 -0
- package/components/catalyst-ui/hooks/use-is-client.tsx +16 -0
- package/components/catalyst-ui/hooks/use-media-query.tsx +19 -0
- package/components/catalyst-ui/hooks/use-mobile.tsx +19 -0
- package/components/catalyst-ui/hooks/use-resize-observer.tsx +81 -0
- package/components/catalyst-ui/hooks/use-timeout.tsx +21 -0
- package/components/catalyst-ui/hooks/use-timer.tsx +209 -0
- package/components/catalyst-ui/hooks/use-toggle.tsx +12 -0
- package/components/catalyst-ui/media/image.tsx +13 -0
- package/components/catalyst-ui/overlays/dual-sidebar.tsx +4142 -0
- package/components/catalyst-ui/overlays/sidebar-original.tsx +726 -0
- package/components/catalyst-ui/primitives/accordion.tsx +250 -0
- package/components/catalyst-ui/primitives/alert-dialog.tsx +126 -0
- package/components/catalyst-ui/primitives/aspect-ratio.tsx +9 -0
- package/components/catalyst-ui/primitives/avatar.tsx +296 -0
- package/components/catalyst-ui/primitives/badge.tsx +57 -0
- package/components/catalyst-ui/primitives/breadcrumb.tsx +101 -0
- package/components/catalyst-ui/primitives/button.tsx +265 -0
- package/components/catalyst-ui/primitives/calendar-v4.tsx +208 -0
- package/components/catalyst-ui/primitives/calendar.tsx +295 -0
- package/components/catalyst-ui/primitives/card.tsx +618 -0
- package/components/catalyst-ui/primitives/carousel.tsx +238 -0
- package/components/catalyst-ui/primitives/chart.tsx +347 -0
- package/components/catalyst-ui/primitives/checkbox.tsx +225 -0
- package/components/catalyst-ui/primitives/collapsible.tsx +212 -0
- package/components/catalyst-ui/primitives/command.tsx +393 -0
- package/components/catalyst-ui/primitives/context-menu.tsx +236 -0
- package/components/catalyst-ui/primitives/dialog.tsx +471 -0
- package/components/catalyst-ui/primitives/drawer.tsx +761 -0
- package/components/catalyst-ui/primitives/dropdown-menu.tsx +290 -0
- package/components/catalyst-ui/primitives/empty.tsx +104 -0
- package/components/catalyst-ui/primitives/field.tsx +244 -0
- package/components/catalyst-ui/primitives/hover-card.tsx +124 -0
- package/components/catalyst-ui/primitives/input-otp.tsx +76 -0
- package/components/catalyst-ui/primitives/input.tsx +64 -0
- package/components/catalyst-ui/primitives/item.tsx +196 -0
- package/components/catalyst-ui/primitives/kbd.tsx +75 -0
- package/components/catalyst-ui/primitives/label.tsx +24 -0
- package/components/catalyst-ui/primitives/navigation-menu.tsx +150 -0
- package/components/catalyst-ui/primitives/pagination.tsx +198 -0
- package/components/catalyst-ui/primitives/popover.tsx +232 -0
- package/components/catalyst-ui/primitives/progress.tsx +34 -0
- package/components/catalyst-ui/primitives/radio-group.tsx +43 -0
- package/components/catalyst-ui/primitives/resizable.tsx +56 -0
- package/components/catalyst-ui/primitives/select.tsx +155 -0
- package/components/catalyst-ui/primitives/separator.tsx +74 -0
- package/components/catalyst-ui/primitives/sheet.tsx +126 -0
- package/components/catalyst-ui/primitives/skeleton.tsx +15 -0
- package/components/catalyst-ui/primitives/slider.tsx +27 -0
- package/components/catalyst-ui/primitives/switch.tsx +187 -0
- package/components/catalyst-ui/primitives/tabs.tsx +335 -0
- package/components/catalyst-ui/primitives/textarea.tsx +24 -0
- package/components/catalyst-ui/primitives/toggle-group.tsx +55 -0
- package/components/catalyst-ui/primitives/toggle.tsx +42 -0
- package/components/catalyst-ui/primitives/tooltip.tsx +116 -0
- package/components/catalyst-ui/utils/basic-auth.tsx +40 -0
- package/components/catalyst-ui/utils/context-storage.tsx +19 -0
- package/components/catalyst-ui/utils/cors-middleware.tsx +71 -0
- package/components/catalyst-ui/utils/deferred-content.tsx +595 -0
- package/components/catalyst-ui/utils/honeypot-middleware.tsx +38 -0
- package/components/catalyst-ui/utils/incId.tsx +75 -0
- package/components/catalyst-ui/utils/jwk-auth.tsx +36 -0
- package/components/catalyst-ui/utils/request-id.tsx +14 -0
- package/components/catalyst-ui/utils/secure-headers.tsx +37 -0
- package/components/catalyst-ui/utils/server-timing.tsx +23 -0
- package/components/catalyst-ui/utils/utils.ts +43 -0
- package/components/catalyst-ui/utils/with-cookie.tsx +43 -0
- package/components/catalyst-ui/x/accordian-x.tsx +428 -0
- package/components/catalyst-ui/x/alert-x.tsx +413 -0
- package/components/catalyst-ui/x/animated-text-x.tsx +2242 -0
- package/components/catalyst-ui/x/avatar-x.tsx +515 -0
- package/components/catalyst-ui/x/badge-x.tsx +670 -0
- package/components/catalyst-ui/x/button-X.tsx +2857 -0
- package/components/catalyst-ui/x/button-group-x.tsx +847 -0
- package/components/catalyst-ui/x/calendar-x.tsx +1910 -0
- package/components/catalyst-ui/x/card-x.tsx +2597 -0
- package/components/catalyst-ui/x/checkbox-x.tsx +656 -0
- package/components/catalyst-ui/x/collapsible-x.tsx +1360 -0
- package/components/catalyst-ui/x/combobox-x.tsx +911 -0
- package/components/catalyst-ui/x/data-table-x.tsx +1753 -0
- package/components/catalyst-ui/x/date-picker-x.tsx +648 -0
- package/components/catalyst-ui/x/dialog-x.tsx +659 -0
- package/components/catalyst-ui/x/dropdown-menu-x.tsx +612 -0
- package/components/catalyst-ui/x/hover-card-x.tsx +375 -0
- package/components/catalyst-ui/x/icon-x.tsx +840 -0
- package/components/catalyst-ui/x/input-mask-x.tsx +981 -0
- package/components/catalyst-ui/x/input-otp-x.tsx +659 -0
- package/components/catalyst-ui/x/loader-x.tsx +1757 -0
- package/components/catalyst-ui/x/pagination-x.tsx +622 -0
- package/components/catalyst-ui/x/popover-x.tsx +744 -0
- package/components/catalyst-ui/x/radio-group-x.tsx +499 -0
- package/components/catalyst-ui/x/select-x.tsx +1127 -0
- package/components/catalyst-ui/x/sheet-x.tsx +668 -0
- package/components/catalyst-ui/x/switch-x.tsx +681 -0
- package/components/catalyst-ui/x/table-x.tsx +574 -0
- package/components/catalyst-ui/x/tabs-x.tsx +839 -0
- package/components/catalyst-ui/x/textarea-x.tsx +1263 -0
- package/components/catalyst-ui/x/tooltip-x.tsx +396 -0
- package/components/catalyst-ui/x/tracker-x.tsx +560 -0
- package/data/bg-data.tsx +901 -0
- package/data/buttons-data.tsx +2327 -0
- package/data/charts-data.tsx +102 -0
- package/data/chat-data.tsx +83 -0
- package/data/code-data.tsx +1040 -0
- package/data/comboboxes-data.tsx +1843 -0
- package/data/command-data.tsx +1381 -0
- package/data/core-data.tsx +15953 -0
- package/data/crm-data.tsx +47 -0
- package/data/data.tsx +159 -0
- package/data/date-and-time-data.tsx +554 -0
- package/data/dependencies.tsx +7 -0
- package/data/ecommerce-data.tsx +1387 -0
- package/data/forms-data.tsx +7890 -0
- package/data/hooks-data.tsx +5487 -0
- package/data/index.ts +34 -0
- package/data/inputs-data.tsx +557 -0
- package/data/interactive-data.tsx +5394 -0
- package/data/lofi-data.tsx +18295 -0
- package/data/marketing-data.tsx +2546 -0
- package/data/media-data.tsx +1510 -0
- package/data/motion-data.tsx +5801 -0
- package/data/overlay-data.tsx +4136 -0
- package/data/pdf-data.tsx +124 -0
- package/data/pos-data.tsx +213 -0
- package/data/postcss.config.js +6 -0
- package/data/primitive-data.tsx +5170 -0
- package/data/prompt-data.tsx +1226 -0
- package/data/requiredLibs.ts +4 -0
- package/data/sandbox-data.tsx +1 -0
- package/data/sidebars-data.tsx +5421 -0
- package/data/stacks-data.tsx +32 -0
- package/data/table-data.tsx +706 -0
- package/data/tailwind.config.js +3830 -0
- package/data/tailwind.config.ngin.js +3830 -0
- package/data/tailwind.css +431 -0
- package/data/tools-data.tsx +6910 -0
- package/data/typography-data.tsx +2050 -0
- package/data/utils-data.tsx +6500 -0
- package/data/x-data.tsx +1171 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30245 -0
- package/dist/index.js.map +362 -0
- package/package.json +50 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs'
|
|
3
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
4
|
+
import { cn } from '~/components/catalyst-ui'
|
|
5
|
+
|
|
6
|
+
interface TabsProps
|
|
7
|
+
extends React.ComponentPropsWithoutRef<typeof TabsPrimitive.Root>,
|
|
8
|
+
VariantProps<typeof tabsVariants> { }
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
// @devsearch app/components/catalyst-ui/data/primitive-data.tsx:TabsList
|
|
12
|
+
export const tabsVariants = cva('', {
|
|
13
|
+
variants: {
|
|
14
|
+
variant: {
|
|
15
|
+
default: '',
|
|
16
|
+
underline: '',
|
|
17
|
+
compact: 'border border-zinc-700 bg-zinc-900/40 rounded overflow-hidden',
|
|
18
|
+
glass: '',
|
|
19
|
+
frosted: '',
|
|
20
|
+
pill: '',
|
|
21
|
+
neon: 'rounded-xl bg-black/40 border border-cyan-500/30 p-2',
|
|
22
|
+
vertical: 'flex flex-row gap-4',
|
|
23
|
+
minimal: '',
|
|
24
|
+
bordered: 'rounded-xl border border-border bg-background/50 p-1',
|
|
25
|
+
elevated: '',
|
|
26
|
+
segmented: 'inline-block rounded-xl bg-muted/50 p-1',
|
|
27
|
+
dots: '',
|
|
28
|
+
floating: 'inline-block rounded-2xl bg-background shadow-2xl border border-border p-1',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: {
|
|
32
|
+
variant: 'default',
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
export const tabsListVariants = cva('', {
|
|
37
|
+
variants: {
|
|
38
|
+
variant: {
|
|
39
|
+
default: 'inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground',
|
|
40
|
+
underline: 'mb-px flex gap-x-6 border-b border-border whitespace-nowrap justify-start bg-transparent rounded-[0xp]',
|
|
41
|
+
compact: '',
|
|
42
|
+
glass: 'inline-flex h-10 items-center justify-center rounded-lg bg-white/10 backdrop-blur-md border border-white/20 p-1 shadow-lg',
|
|
43
|
+
frosted: 'inline-flex h-10 items-center justify-center rounded-lg bg-white/5 backdrop-blur-xl border border-white/10 p-1',
|
|
44
|
+
pill: 'inline-flex h-10 items-center gap-2 rounded-full bg-muted/50 p-1',
|
|
45
|
+
neon: 'inline-flex h-10 items-center gap-2 p-1',
|
|
46
|
+
vertical: 'flex flex-col gap-1 w-48 p-2 bg-muted/50 rounded-lg',
|
|
47
|
+
minimal: 'flex gap-6 p-0',
|
|
48
|
+
bordered: 'inline-flex h-10 items-center gap-1 p-1',
|
|
49
|
+
elevated: 'inline-flex h-10 items-center gap-2 p-1',
|
|
50
|
+
segmented: 'inline-flex h-9 items-center justify-center w-full',
|
|
51
|
+
dots: 'flex gap-4 p-0 border-b border-border',
|
|
52
|
+
floating: 'inline-flex h-11 items-center gap-2',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
defaultVariants: {
|
|
56
|
+
variant: 'default',
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
export const tabsTriggerVariants = cva('', {
|
|
61
|
+
variants: {
|
|
62
|
+
variant: {
|
|
63
|
+
default: 'inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm',
|
|
64
|
+
underline: '-mb-px flex border-b-2 pb-2 text-sm/7 font-medium border-transparent text-muted-foreground hover:border-[#1447e6]/25 data-[state=active]:border-[#1447e6] data-[state=active]:text-foreground rounded-[0px]',
|
|
65
|
+
compact: 'px-3 py-1 text-sm transition-colors hover:text-zinc-200 data-[state=active]:text-zinc-200 data-[state=inactive]:text-zinc-500 hover:text-zinc-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
|
|
66
|
+
glass: 'inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1.5 text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 text-white/70 hover:text-white data-[state=active]:bg-white/20 data-[state=active]:text-white data-[state=active]:shadow-md',
|
|
67
|
+
frosted: 'inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1.5 text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 text-white/60 hover:text-white/90 data-[state=active]:bg-white/15 data-[state=active]:text-white data-[state=active]:backdrop-blur-sm',
|
|
68
|
+
pill: 'rounded-full px-4 py-1.5 text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 text-muted-foreground hover:text-foreground data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-md',
|
|
69
|
+
neon: 'rounded-md px-4 py-2 text-sm font-medium text-cyan-400 transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cyan-500 disabled:pointer-events-none disabled:opacity-50 hover:text-cyan-300 data-[state=active]:bg-cyan-500/20 data-[state=active]:text-cyan-300 data-[state=active]:shadow-[0_0_15px_rgba(6,182,212,0.5)] data-[state=active]:border data-[state=active]:border-cyan-400',
|
|
70
|
+
vertical: 'justify-start rounded-md px-4 py-2 text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 text-muted-foreground hover:text-foreground hover:bg-background/50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm',
|
|
71
|
+
minimal: 'text-sm font-medium text-muted-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:text-foreground/80 data-[state=active]:text-foreground',
|
|
72
|
+
bordered: 'rounded-md px-4 py-2 text-sm font-medium border border-transparent transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 text-muted-foreground hover:text-foreground data-[state=active]:border-border data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm',
|
|
73
|
+
elevated: 'rounded-lg px-4 py-2 text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 text-muted-foreground hover:text-foreground hover:shadow-md data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-lg data-[state=active]:shadow-primary/20',
|
|
74
|
+
segmented: 'rounded-md px-4 py-1.5 text-sm font-medium transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 text-muted-foreground hover:text-foreground data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm',
|
|
75
|
+
dots: 'relative pb-3 text-sm font-medium text-muted-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:text-foreground/80 data-[state=active]:text-foreground after:absolute after:bottom-0 after:left-1/2 after:-translate-x-1/2 after:w-1 after:h-1 after:rounded-full after:transition-colors data-[state=active]:after:bg-primary',
|
|
76
|
+
floating: 'rounded-lg px-4 py-2 text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 text-muted-foreground hover:text-foreground data-[state=active]:bg-primary data-[state=active]:text-primary-foreground',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
defaultVariants: {
|
|
80
|
+
variant: 'default',
|
|
81
|
+
},
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
export const tabsContentVariants = cva('', {
|
|
85
|
+
variants: {
|
|
86
|
+
variant: {
|
|
87
|
+
default: 'mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
88
|
+
underline: '',
|
|
89
|
+
compact: 'bg-zinc-900/40 overflow-hidden max-h-[80vh] max-w-[80vw] h-full w-full border-t border-zinc-700',
|
|
90
|
+
blueLine: '',
|
|
91
|
+
glass: 'mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 bg-white/5 backdrop-blur-sm rounded-lg border border-white/10 p-4',
|
|
92
|
+
frosted: 'mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 bg-white/5 backdrop-blur-xl rounded-lg border border-white/5 p-4',
|
|
93
|
+
pill: 'mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
94
|
+
neon: 'mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cyan-500 focus-visible:ring-offset-2 rounded-lg bg-black/20 border border-cyan-500/20 p-4',
|
|
95
|
+
vertical: 'ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 flex-1 rounded-lg bg-background/50 p-4',
|
|
96
|
+
minimal: 'mt-4 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
97
|
+
bordered: 'mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 p-4',
|
|
98
|
+
elevated: 'mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
99
|
+
segmented: 'mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 p-4',
|
|
100
|
+
dots: 'mt-4 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
101
|
+
floating: 'mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 p-4',
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
defaultVariants: {
|
|
105
|
+
variant: 'default',
|
|
106
|
+
},
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
// Create a context to share the variant
|
|
111
|
+
const TabsVariantContext = React.createContext<string>('default')
|
|
112
|
+
|
|
113
|
+
interface TabsProps
|
|
114
|
+
extends React.ComponentPropsWithoutRef<typeof TabsPrimitive.Root>,
|
|
115
|
+
VariantProps<typeof tabsVariants> { }
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
const Tabs = React.forwardRef<
|
|
119
|
+
React.ElementRef<typeof TabsPrimitive.Root>,
|
|
120
|
+
TabsProps
|
|
121
|
+
> (({ className, variant = 'default', defaultValue, children, ...props }, ref) => {
|
|
122
|
+
// Auto-detect first tab's value if no defaultValue provided
|
|
123
|
+
const autoDefaultValue = React.useMemo(() => {
|
|
124
|
+
if (defaultValue) return defaultValue
|
|
125
|
+
|
|
126
|
+
let firstValue: string | undefined
|
|
127
|
+
|
|
128
|
+
React.Children.forEach(children, (child) => {
|
|
129
|
+
if (firstValue) return
|
|
130
|
+
|
|
131
|
+
if (React.isValidElement(child) && child.type === TabsList) {
|
|
132
|
+
React.Children.forEach(child.props.children, (tabChild) => {
|
|
133
|
+
if (firstValue) return
|
|
134
|
+
|
|
135
|
+
if (React.isValidElement(tabChild) && tabChild.type === TabsTrigger) {
|
|
136
|
+
// Use explicit value or fallback to children text
|
|
137
|
+
firstValue = tabChild.props.value ||
|
|
138
|
+
(typeof tabChild.props.children === 'string'
|
|
139
|
+
? tabChild.props.children
|
|
140
|
+
: undefined)
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
return firstValue
|
|
147
|
+
}, [defaultValue, children])
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<TabsVariantContext.Provider value={variant as string}>
|
|
151
|
+
<TabsPrimitive.Root
|
|
152
|
+
ref={ref}
|
|
153
|
+
className={cn(tabsVariants({ variant }), className)}
|
|
154
|
+
defaultValue={autoDefaultValue}
|
|
155
|
+
{...props}
|
|
156
|
+
>
|
|
157
|
+
{children}
|
|
158
|
+
</TabsPrimitive.Root>
|
|
159
|
+
</TabsVariantContext.Provider>
|
|
160
|
+
)
|
|
161
|
+
})
|
|
162
|
+
Tabs.displayName = TabsPrimitive.Root.displayName
|
|
163
|
+
|
|
164
|
+
interface TabsListProps
|
|
165
|
+
extends Omit<React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>, 'variant'> {
|
|
166
|
+
variant?: VariantProps<typeof tabsListVariants>['variant']
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const TabsList = React.forwardRef<
|
|
170
|
+
React.ElementRef<typeof TabsPrimitive.List>,
|
|
171
|
+
TabsListProps
|
|
172
|
+
> (({ className, variant: variantOverride, ...props }, ref) => {
|
|
173
|
+
const contextVariant = React.useContext(TabsVariantContext)
|
|
174
|
+
const variant = variantOverride ?? contextVariant
|
|
175
|
+
|
|
176
|
+
const list = (
|
|
177
|
+
<TabsPrimitive.List
|
|
178
|
+
ref={ref}
|
|
179
|
+
className={cn(tabsListVariants({ variant: variant as any }), className)}
|
|
180
|
+
{...props}
|
|
181
|
+
/>
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
if (variant === 'underline') {
|
|
185
|
+
return <div className="min-w-full flex-none px-4 sm:px-6">{list}</div>
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return list
|
|
189
|
+
})
|
|
190
|
+
TabsList.displayName = TabsPrimitive.List.displayName
|
|
191
|
+
|
|
192
|
+
interface TabsTriggerProps
|
|
193
|
+
extends Omit<React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>, 'variant' | 'value'> {
|
|
194
|
+
variant?: VariantProps<typeof tabsTriggerVariants>['variant']
|
|
195
|
+
value?: string // Now optional
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const TabsTrigger = React.forwardRef<
|
|
199
|
+
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
|
200
|
+
TabsTriggerProps
|
|
201
|
+
> (({ className, variant: variantOverride, value, children, ...props }, ref) => {
|
|
202
|
+
const contextVariant = React.useContext(TabsVariantContext)
|
|
203
|
+
const variant = variantOverride ?? contextVariant
|
|
204
|
+
|
|
205
|
+
// Auto-use children as value if not explicitly provided
|
|
206
|
+
const finalValue = value || (typeof children === 'string' ? children : undefined)
|
|
207
|
+
|
|
208
|
+
return (
|
|
209
|
+
<TabsPrimitive.Trigger
|
|
210
|
+
ref={ref}
|
|
211
|
+
className={cn(tabsTriggerVariants({ variant: variant as any }), className)}
|
|
212
|
+
value={finalValue}
|
|
213
|
+
{...props}
|
|
214
|
+
>
|
|
215
|
+
{children}
|
|
216
|
+
</TabsPrimitive.Trigger>
|
|
217
|
+
)
|
|
218
|
+
})
|
|
219
|
+
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
|
|
220
|
+
|
|
221
|
+
interface TabsContentProps
|
|
222
|
+
extends Omit<React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>, 'variant'> {
|
|
223
|
+
variant?: VariantProps<typeof tabsContentVariants>['variant']
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const TabsContent = React.forwardRef<
|
|
227
|
+
React.ElementRef<typeof TabsPrimitive.Content>,
|
|
228
|
+
TabsContentProps
|
|
229
|
+
> (({ className, variant: variantOverride, ...props }, ref) => {
|
|
230
|
+
const contextVariant = React.useContext(TabsVariantContext)
|
|
231
|
+
const variant = variantOverride ?? contextVariant
|
|
232
|
+
|
|
233
|
+
return (
|
|
234
|
+
<TabsPrimitive.Content
|
|
235
|
+
ref={ref}
|
|
236
|
+
className={cn(tabsContentVariants({ variant: variant as any }), className)}
|
|
237
|
+
{...props}
|
|
238
|
+
/>
|
|
239
|
+
)
|
|
240
|
+
})
|
|
241
|
+
TabsContent.displayName = TabsPrimitive.Content.displayName
|
|
242
|
+
|
|
243
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent }
|
|
244
|
+
/**
|
|
245
|
+
|
|
246
|
+
const TabsVariantContext = React.createContext<string>('default')
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
const Tabs = React.forwardRef<
|
|
250
|
+
React.ElementRef<typeof TabsPrimitive.Root>,
|
|
251
|
+
TabsProps
|
|
252
|
+
>(({ className, variant = 'default', ...props }, ref) => (
|
|
253
|
+
<TabsVariantContext.Provider value={variant as string}>
|
|
254
|
+
<TabsPrimitive.Root
|
|
255
|
+
ref={ref}
|
|
256
|
+
className={cn(tabsVariants({ variant }), className)}
|
|
257
|
+
{...props}
|
|
258
|
+
/>
|
|
259
|
+
</TabsVariantContext.Provider>
|
|
260
|
+
))
|
|
261
|
+
Tabs.displayName = TabsPrimitive.Root.displayName
|
|
262
|
+
|
|
263
|
+
interface TabsListProps
|
|
264
|
+
extends Omit<React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>, 'variant'> {
|
|
265
|
+
variant?: VariantProps<typeof tabsListVariants>['variant']
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const TabsList = React.forwardRef<
|
|
269
|
+
React.ElementRef<typeof TabsPrimitive.List>,
|
|
270
|
+
TabsListProps
|
|
271
|
+
>(({ className, variant: variantOverride, ...props }, ref) => {
|
|
272
|
+
const contextVariant = React.useContext(TabsVariantContext)
|
|
273
|
+
const variant = variantOverride ?? contextVariant
|
|
274
|
+
|
|
275
|
+
const list = (
|
|
276
|
+
<TabsPrimitive.List
|
|
277
|
+
ref={ref}
|
|
278
|
+
className={cn(tabsListVariants({ variant: variant as any }), className)}
|
|
279
|
+
{...props}
|
|
280
|
+
/>
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
if (variant === 'underline') {
|
|
284
|
+
return <div className="min-w-full flex-none px-4 sm:px-6">{list}</div>
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return list
|
|
288
|
+
})
|
|
289
|
+
TabsList.displayName = TabsPrimitive.List.displayName
|
|
290
|
+
|
|
291
|
+
interface TabsTriggerProps
|
|
292
|
+
extends Omit<React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>, 'variant'> {
|
|
293
|
+
variant?: VariantProps<typeof tabsTriggerVariants>['variant']
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const TabsTrigger = React.forwardRef<
|
|
297
|
+
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
|
298
|
+
TabsTriggerProps
|
|
299
|
+
>(({ className, variant: variantOverride, ...props }, ref) => {
|
|
300
|
+
const contextVariant = React.useContext(TabsVariantContext)
|
|
301
|
+
const variant = variantOverride ?? contextVariant
|
|
302
|
+
|
|
303
|
+
return (
|
|
304
|
+
<TabsPrimitive.Trigger
|
|
305
|
+
ref={ref}
|
|
306
|
+
className={cn(tabsTriggerVariants({ variant: variant as any }), className)}
|
|
307
|
+
{...props}
|
|
308
|
+
/>
|
|
309
|
+
)
|
|
310
|
+
})
|
|
311
|
+
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
|
|
312
|
+
|
|
313
|
+
interface TabsContentProps
|
|
314
|
+
extends Omit<React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>, 'variant'> {
|
|
315
|
+
variant?: VariantProps<typeof tabsContentVariants>['variant']
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const TabsContent = React.forwardRef<
|
|
319
|
+
React.ElementRef<typeof TabsPrimitive.Content>,
|
|
320
|
+
TabsContentProps
|
|
321
|
+
>(({ className, variant: variantOverride, ...props }, ref) => {
|
|
322
|
+
const contextVariant = React.useContext(TabsVariantContext)
|
|
323
|
+
const variant = variantOverride ?? contextVariant
|
|
324
|
+
|
|
325
|
+
return (
|
|
326
|
+
<TabsPrimitive.Content
|
|
327
|
+
ref={ref}
|
|
328
|
+
className={cn(tabsContentVariants({ variant: variant as any }), className)}
|
|
329
|
+
{...props}
|
|
330
|
+
/>
|
|
331
|
+
)
|
|
332
|
+
})
|
|
333
|
+
TabsContent.displayName = TabsPrimitive.Content.displayName
|
|
334
|
+
|
|
335
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent } */
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { cn } from '~/components/catalyst-ui'
|
|
3
|
+
|
|
4
|
+
// @dev app/components/catalyst-ui/data/primitive-data.tsx:3931
|
|
5
|
+
export interface TextareaProps
|
|
6
|
+
extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
|
|
7
|
+
|
|
8
|
+
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
9
|
+
({ className, ...props }, ref) => {
|
|
10
|
+
return (
|
|
11
|
+
<textarea
|
|
12
|
+
className={cn(
|
|
13
|
+
'flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
|
|
14
|
+
className
|
|
15
|
+
)}
|
|
16
|
+
ref={ref}
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
Textarea.displayName = 'Textarea'
|
|
23
|
+
|
|
24
|
+
export { Textarea }
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
|
2
|
+
import { cn } from "~/components/catalyst-ui";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { toggleVariants } from '~/components/catalyst-ui'
|
|
5
|
+
|
|
6
|
+
// @dev app/components/catalyst-ui/data/primitive-data.tsx:3118
|
|
7
|
+
const ToggleGroupContext = React.createContext<
|
|
8
|
+
VariantProps<typeof toggleVariants>
|
|
9
|
+
>({});
|
|
10
|
+
|
|
11
|
+
const ToggleGroup = React.forwardRef<
|
|
12
|
+
React.ElementRef<typeof ToggleGroupPrimitive.Root>,
|
|
13
|
+
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> &
|
|
14
|
+
VariantProps<typeof toggleVariants>
|
|
15
|
+
>(({ className, variant, size, children, ...props }, ref) => (
|
|
16
|
+
<ToggleGroupPrimitive.Root
|
|
17
|
+
ref={ref}
|
|
18
|
+
className={cn("flex items-center justify-center gap-1", className)}
|
|
19
|
+
{...props}
|
|
20
|
+
>
|
|
21
|
+
<ToggleGroupContext.Provider value={{ variant, size }}>
|
|
22
|
+
{children}
|
|
23
|
+
</ToggleGroupContext.Provider>
|
|
24
|
+
</ToggleGroupPrimitive.Root>
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
|
|
28
|
+
|
|
29
|
+
const ToggleGroupItem = React.forwardRef<
|
|
30
|
+
React.ElementRef<typeof ToggleGroupPrimitive.Item>,
|
|
31
|
+
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> &
|
|
32
|
+
VariantProps<typeof toggleVariants>
|
|
33
|
+
>(({ className, children, variant, size, ...props }, ref) => {
|
|
34
|
+
const context = React.useContext(ToggleGroupContext);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<ToggleGroupPrimitive.Item
|
|
38
|
+
ref={ref}
|
|
39
|
+
className={cn(
|
|
40
|
+
toggleVariants({
|
|
41
|
+
variant: context.variant || variant,
|
|
42
|
+
size: context.size || size,
|
|
43
|
+
}),
|
|
44
|
+
className
|
|
45
|
+
)}
|
|
46
|
+
{...props}
|
|
47
|
+
>
|
|
48
|
+
{children}
|
|
49
|
+
</ToggleGroupPrimitive.Item>
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
|
|
54
|
+
|
|
55
|
+
export { ToggleGroup, ToggleGroupItem }
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as TogglePrimitive from "@radix-ui/react-toggle";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
import { cn } from "~/components/catalyst-ui";
|
|
4
|
+
import React from "react";
|
|
5
|
+
|
|
6
|
+
// @dev app/components/catalyst-ui/data/primitive-data.tsx:3076
|
|
7
|
+
const toggleVariants = cva(
|
|
8
|
+
"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default: "bg-transparent",
|
|
13
|
+
outline:
|
|
14
|
+
"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground",
|
|
15
|
+
},
|
|
16
|
+
size: {
|
|
17
|
+
default: "h-10 px-3",
|
|
18
|
+
sm: "h-9 px-2.5",
|
|
19
|
+
lg: "h-11 px-5",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
variant: "default",
|
|
24
|
+
size: "default",
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const Toggle = React.forwardRef<
|
|
30
|
+
React.ElementRef<typeof TogglePrimitive.Root>,
|
|
31
|
+
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> &
|
|
32
|
+
VariantProps<typeof toggleVariants>
|
|
33
|
+
>(({ className, variant, size, ...props }, ref) => (
|
|
34
|
+
<TogglePrimitive.Root
|
|
35
|
+
ref={ref}
|
|
36
|
+
className={cn(toggleVariants({ variant, size, className }))}
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
));
|
|
40
|
+
|
|
41
|
+
Toggle.displayName = TogglePrimitive.Root.displayName;
|
|
42
|
+
export { Toggle, toggleVariants }
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { cn } from "~/components/catalyst-ui";
|
|
4
|
+
import React from "react";
|
|
5
|
+
|
|
6
|
+
// @dev app/components/catalyst-ui/data/primitive-data.tsx:4707
|
|
7
|
+
|
|
8
|
+
const TooltipVariantContext = React.createContext<{
|
|
9
|
+
variant?: "default" | "light" | "error";
|
|
10
|
+
arrow?: "visible" | "hidden";
|
|
11
|
+
rounded?: "default" | "full";
|
|
12
|
+
}>({});
|
|
13
|
+
|
|
14
|
+
const TooltipProvider = TooltipPrimitive.Provider;
|
|
15
|
+
|
|
16
|
+
const Tooltip = ({ children, ...props }: React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Root> & {
|
|
17
|
+
variant?: "default" | "light" | "error";
|
|
18
|
+
arrow?: "visible" | "hidden";
|
|
19
|
+
rounded?: "default" | "full";
|
|
20
|
+
}) => {
|
|
21
|
+
const { variant, arrow, rounded, ...rootProps } = props;
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<TooltipVariantContext.Provider value={{ variant, arrow, rounded }}>
|
|
25
|
+
<TooltipPrimitive.Root {...rootProps}>
|
|
26
|
+
{children}
|
|
27
|
+
</TooltipPrimitive.Root>
|
|
28
|
+
</TooltipVariantContext.Provider>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
33
|
+
|
|
34
|
+
const tooltipContentVariants = cva(
|
|
35
|
+
"z-50 overflow-hidden border px-3 py-1.5 text-sm shadow-md 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",
|
|
36
|
+
{
|
|
37
|
+
variants: {
|
|
38
|
+
variant: {
|
|
39
|
+
default: "bg-popover text-popover-foreground",
|
|
40
|
+
light: "bg-neutral-200 text-neutral-950 dark:bg-neutral-50 [&_svg]:bg-neutral-200 [&_svg]:fill-neutral-200 dark:[&_svg]:bg-neutral-50 dark:[&_svg]:fill-neutral-50",
|
|
41
|
+
error: "bg-destructive text-white [&_svg]:bg-destructive [&_svg]:fill-destructive",
|
|
42
|
+
},
|
|
43
|
+
arrow: {
|
|
44
|
+
visible: "",
|
|
45
|
+
hidden: "[&_svg]:invisible",
|
|
46
|
+
},
|
|
47
|
+
rounded: {
|
|
48
|
+
default: "rounded-md",
|
|
49
|
+
full: "rounded-full",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
defaultVariants: {
|
|
53
|
+
variant: "default",
|
|
54
|
+
arrow: "visible",
|
|
55
|
+
rounded: "default",
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const TooltipContent = React.forwardRef<
|
|
61
|
+
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
62
|
+
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> &
|
|
63
|
+
VariantProps<typeof tooltipContentVariants>
|
|
64
|
+
>(({ className, sideOffset = 4, ...props }, ref) => {
|
|
65
|
+
const { variant, arrow, rounded } = React.useContext(TooltipVariantContext);
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<TooltipPrimitive.Content
|
|
69
|
+
ref={ref}
|
|
70
|
+
sideOffset={sideOffset}
|
|
71
|
+
className={cn(
|
|
72
|
+
tooltipContentVariants({ variant, arrow, rounded, }), className)}
|
|
73
|
+
{...props}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
TooltipProvider,
|
|
81
|
+
Tooltip,
|
|
82
|
+
TooltipTrigger,
|
|
83
|
+
TooltipContent,
|
|
84
|
+
tooltipContentVariants,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
89
|
+
import { cn } from "~/components/catalyst-ui";
|
|
90
|
+
import React from "react";
|
|
91
|
+
|
|
92
|
+
const TooltipProvider = TooltipPrimitive.Provider;
|
|
93
|
+
|
|
94
|
+
const Tooltip = TooltipPrimitive.Root;
|
|
95
|
+
|
|
96
|
+
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
97
|
+
|
|
98
|
+
const TooltipContent = React.forwardRef<
|
|
99
|
+
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
100
|
+
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
|
|
101
|
+
>(({ className, sideOffset = 4, ...props }, ref) => (
|
|
102
|
+
<TooltipPrimitive.Content
|
|
103
|
+
ref={ref}
|
|
104
|
+
sideOffset={sideOffset}
|
|
105
|
+
className={cn(
|
|
106
|
+
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md 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",
|
|
107
|
+
className
|
|
108
|
+
)}
|
|
109
|
+
{...props}
|
|
110
|
+
/>
|
|
111
|
+
));
|
|
112
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
113
|
+
|
|
114
|
+
export {
|
|
115
|
+
TooltipProvider, Tooltip, TooltipTrigger, TooltipContent
|
|
116
|
+
} */
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
export function BasicAuthMiddleware() {
|
|
4
|
+
const validateBasicAuth = useCallback((
|
|
5
|
+
request: Request,
|
|
6
|
+
credentials: BasicAuthCredentials[]
|
|
7
|
+
): BasicAuthCredentials | null => {
|
|
8
|
+
const authHeader = request.headers.get('authorization');
|
|
9
|
+
if (!authHeader?.startsWith('Basic ')) return null;
|
|
10
|
+
|
|
11
|
+
const encoded = authHeader.slice(6);
|
|
12
|
+
const decoded = atob(encoded);
|
|
13
|
+
const [username, password] = decoded.split(':');
|
|
14
|
+
|
|
15
|
+
const validCredential = credentials.find(
|
|
16
|
+
cred => cred.username === username && cred.password === password
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
return validCredential || null;
|
|
20
|
+
}, []);
|
|
21
|
+
|
|
22
|
+
const requireBasicAuth = useCallback((
|
|
23
|
+
request: Request,
|
|
24
|
+
credentials: BasicAuthCredentials[],
|
|
25
|
+
realm = 'Restricted Area'
|
|
26
|
+
) => {
|
|
27
|
+
const auth = validateBasicAuth(request, credentials);
|
|
28
|
+
if (!auth) {
|
|
29
|
+
return new Response('Unauthorized', {
|
|
30
|
+
status: 401,
|
|
31
|
+
headers: {
|
|
32
|
+
'WWW-Authenticate': `Basic realm="${realm}"`
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}, [validateBasicAuth]);
|
|
38
|
+
|
|
39
|
+
return { validateBasicAuth, requireBasicAuth };
|
|
40
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
export function ContextStorageMiddleware() {
|
|
4
|
+
const storage = new Map<string, ContextData>();
|
|
5
|
+
|
|
6
|
+
const setContext = useCallback((requestId: string, data: ContextData) => {
|
|
7
|
+
storage.set(requestId, data);
|
|
8
|
+
}, []);
|
|
9
|
+
|
|
10
|
+
const getContext = useCallback((requestId: string): ContextData | undefined => {
|
|
11
|
+
return storage.get(requestId);
|
|
12
|
+
}, []);
|
|
13
|
+
|
|
14
|
+
const clearContext = useCallback((requestId: string) => {
|
|
15
|
+
storage.delete(requestId);
|
|
16
|
+
}, []);
|
|
17
|
+
|
|
18
|
+
return { setContext, getContext, clearContext };
|
|
19
|
+
}
|