@luxfi/ui 5.5.3 → 5.6.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/dist/accordion.cjs +213 -0
- package/dist/accordion.js +186 -0
- package/dist/alert.cjs +553 -0
- package/dist/alert.js +531 -0
- package/dist/avatar.cjs +149 -0
- package/dist/avatar.js +125 -0
- package/dist/badge.cjs +611 -0
- package/dist/badge.js +589 -0
- package/dist/button.cjs +689 -0
- package/dist/button.js +664 -0
- package/dist/checkbox.cjs +265 -0
- package/dist/checkbox.js +241 -0
- package/dist/close-button.cjs +73 -0
- package/dist/close-button.js +51 -0
- package/dist/collapsible.cjs +702 -0
- package/dist/collapsible.js +679 -0
- package/dist/color-mode.cjs +96 -0
- package/dist/color-mode.js +72 -0
- package/dist/dialog.cjs +279 -0
- package/dist/dialog.js +246 -0
- package/dist/drawer.cjs +207 -0
- package/dist/drawer.js +175 -0
- package/dist/empty-state.cjs +93 -0
- package/dist/empty-state.js +71 -0
- package/dist/field.cjs +183 -0
- package/dist/field.js +160 -0
- package/dist/heading.cjs +46 -0
- package/dist/heading.js +40 -0
- package/dist/icon-button.cjs +491 -0
- package/dist/icon-button.js +470 -0
- package/dist/image.cjs +572 -0
- package/dist/image.js +551 -0
- package/dist/index.cjs +5779 -0
- package/dist/index.js +5619 -0
- package/dist/input-group.cjs +155 -0
- package/dist/input-group.js +133 -0
- package/dist/input.cjs +65 -0
- package/dist/input.js +59 -0
- package/dist/link.cjs +630 -0
- package/dist/link.js +606 -0
- package/dist/menu.cjs +305 -0
- package/dist/menu.js +269 -0
- package/dist/pin-input.cjs +182 -0
- package/dist/pin-input.js +160 -0
- package/dist/popover.cjs +327 -0
- package/dist/popover.js +294 -0
- package/dist/progress-circle.cjs +152 -0
- package/dist/progress-circle.js +128 -0
- package/dist/progress.cjs +117 -0
- package/dist/progress.js +94 -0
- package/dist/provider.cjs +62 -0
- package/dist/provider.js +40 -0
- package/dist/radio.cjs +177 -0
- package/dist/radio.js +153 -0
- package/dist/rating.cjs +80 -0
- package/dist/rating.js +58 -0
- package/dist/select.cjs +791 -0
- package/dist/select.js +757 -0
- package/dist/separator.cjs +57 -0
- package/dist/separator.js +51 -0
- package/dist/skeleton.cjs +370 -0
- package/dist/skeleton.js +346 -0
- package/dist/slider.cjs +138 -0
- package/dist/slider.js +115 -0
- package/dist/switch.cjs +163 -0
- package/dist/switch.js +140 -0
- package/dist/table.cjs +1044 -0
- package/dist/table.js +1013 -0
- package/dist/tabs.cjs +240 -0
- package/dist/tabs.js +213 -0
- package/dist/tag.cjs +651 -0
- package/dist/tag.js +628 -0
- package/dist/textarea.cjs +65 -0
- package/dist/textarea.js +59 -0
- package/dist/toaster.cjs +99 -0
- package/dist/toaster.js +96 -0
- package/dist/tooltip.cjs +171 -0
- package/dist/tooltip.js +148 -0
- package/dist/utils.cjs +11 -0
- package/dist/utils.js +9 -0
- package/package.json +270 -65
- package/src/accordion.tsx +285 -0
- package/src/alert.tsx +221 -0
- package/src/avatar.tsx +174 -0
- package/src/badge.tsx +158 -0
- package/src/button.tsx +411 -0
- package/src/checkbox.tsx +307 -0
- package/src/close-button.tsx +51 -0
- package/src/collapsible.tsx +126 -0
- package/src/color-mode.tsx +125 -0
- package/src/dialog.tsx +356 -0
- package/src/drawer.tsx +186 -0
- package/src/empty-state.tsx +97 -0
- package/src/field.tsx +202 -0
- package/src/heading.tsx +55 -0
- package/src/icon-button.tsx +192 -0
- package/src/image.tsx +280 -0
- package/src/index.ts +192 -0
- package/src/input-group.tsx +159 -0
- package/src/input.tsx +60 -0
- package/src/link.tsx +326 -0
- package/src/menu.tsx +471 -0
- package/src/pin-input.tsx +187 -0
- package/src/popover.tsx +400 -0
- package/src/progress-circle.tsx +180 -0
- package/src/progress.tsx +109 -0
- package/src/provider.tsx +12 -0
- package/src/radio.tsx +175 -0
- package/src/rating.tsx +79 -0
- package/src/select.tsx +696 -0
- package/src/separator.tsx +59 -0
- package/src/skeleton.tsx +302 -0
- package/src/slider.tsx +152 -0
- package/src/switch.tsx +158 -0
- package/src/table.tsx +621 -0
- package/src/tabs.tsx +354 -0
- package/src/tag.tsx +159 -0
- package/src/textarea.tsx +60 -0
- package/src/toaster.tsx +117 -0
- package/src/tokens.css +438 -0
- package/src/tooltip.tsx +184 -0
- package/src/utils/cn.ts +7 -0
- package/src/utils.ts +6 -0
- package/tokens.css +438 -0
- package/commerce/ui/conf.ts +0 -13
- package/commerce/ui/context.tsx +0 -123
- package/commerce/ui/store.ts +0 -295
- package/components/access-code-input.tsx +0 -71
- package/components/analytics.tsx +0 -23
- package/components/auth/auth-listener.tsx +0 -29
- package/components/auth/auth-token/clear-auth-token.tsx +0 -12
- package/components/auth/auth-token/set-auth-token.tsx +0 -16
- package/components/auth/common-auth-domains.ts +0 -17
- package/components/auth/login-panel.tsx +0 -111
- package/components/auth/mobile-login-button.tsx +0 -107
- package/components/auth/signup-panel.tsx +0 -113
- package/components/back-button.tsx +0 -49
- package/components/chat-widget.tsx +0 -85
- package/components/commerce/bag-button.tsx +0 -98
- package/components/commerce/buy-button.tsx +0 -34
- package/components/commerce/checkout-button.tsx +0 -129
- package/components/commerce/checkout-panel/cart-accordian.tsx +0 -66
- package/components/commerce/checkout-panel/checkout-panel-props.ts +0 -10
- package/components/commerce/checkout-panel/desktop-bag-carousel.tsx +0 -36
- package/components/commerce/checkout-panel/desktop-cp.tsx +0 -83
- package/components/commerce/checkout-panel/index.tsx +0 -126
- package/components/commerce/checkout-panel/mobile-cp.tsx +0 -67
- package/components/commerce/checkout-panel/policy-links.tsx +0 -29
- package/components/commerce/checkout-panel/steps-indicator.tsx +0 -39
- package/components/commerce/checkout-panel/thank-you.tsx +0 -18
- package/components/commerce/desktop-bag-popup.tsx +0 -78
- package/components/commerce/drawer/index.tsx +0 -88
- package/components/commerce/drawer/micro.tsx +0 -145
- package/components/commerce/drawer/shell.tsx +0 -85
- package/components/contact-dialog/contact-form.tsx +0 -116
- package/components/contact-dialog/disclaimer.tsx +0 -13
- package/components/contact-dialog/index.tsx +0 -64
- package/components/copyright.tsx +0 -21
- package/components/drawer-margin.tsx +0 -28
- package/components/footer.tsx +0 -78
- package/components/header/desktop-nav-menu.tsx +0 -204
- package/components/header/desktop.tsx +0 -65
- package/components/header/index.tsx +0 -50
- package/components/header/mobile-bag-drawer.tsx +0 -51
- package/components/header/mobile-menu-toggle-button.tsx +0 -35
- package/components/header/mobile-nav-menu-ai.tsx +0 -51
- package/components/header/mobile-nav-menu-item.tsx +0 -47
- package/components/header/mobile-nav-menu.tsx +0 -102
- package/components/header/mobile.tsx +0 -170
- package/components/header/theme-toggle.tsx +0 -26
- package/components/icons/avatar.tsx +0 -11
- package/components/icons/bag-icon.tsx +0 -10
- package/components/icons/index.ts +0 -6
- package/components/icons/left-arrow.tsx +0 -11
- package/components/icons/lux-logo.tsx +0 -10
- package/components/icons/right-arrow.tsx +0 -10
- package/components/icons/social-icon.tsx +0 -35
- package/components/icons/social-svg.css +0 -3
- package/components/index.ts +0 -26
- package/components/logo.tsx +0 -92
- package/components/main.tsx +0 -27
- package/components/mini-chart/index.tsx +0 -8
- package/components/mini-chart/mini-chart-props.ts +0 -44
- package/components/mini-chart/mini-chart.tsx +0 -85
- package/components/mini-chart/wrapper.tsx +0 -23
- package/components/not-found/index.tsx +0 -28
- package/components/not-found/not-found-content.mdx +0 -5
- package/components/tooltip.tsx +0 -31
- package/environment.d.ts +0 -6
- package/next/analytics/fpixel.ts +0 -16
- package/next/analytics/google-analytics.ts +0 -14
- package/next/analytics/index.ts +0 -3
- package/next/analytics/pixel-analytics.tsx +0 -55
- package/next/font/get-app-router-font-classes.ts +0 -17
- package/next/font/load-and-return-lux-next-fonts-on-import.ts +0 -68
- package/next/font/local/Druk-Wide-Bold.ttf +0 -0
- package/next/font/local/Druk-Wide-Medium.ttf +0 -0
- package/next/font/local/InterVariable-Italic.ttf +0 -0
- package/next/font/local/InterVariable-Italic.woff2 +0 -0
- package/next/font/local/InterVariable.ttf +0 -0
- package/next/font/local/InterVariable.woff2 +0 -0
- package/next/font/next-font-desc.ts +0 -28
- package/next/font/pages-router-font-vars.tsx +0 -18
- package/next/head-metadata/from-next/metadata-types.ts +0 -158
- package/next/head-metadata/from-next/opengraph-types.ts +0 -267
- package/next/head-metadata/from-next/twitter-types.ts +0 -92
- package/next/head-metadata/index.tsx +0 -208
- package/next/index.ts +0 -2
- package/next/middleware/determine-device-mw.ts +0 -29
- package/root-layout/WHY_THIS_IS_SEPARATE.txt +0 -2
- package/root-layout/index.tsx +0 -112
- package/site-def/footer/community.tsx +0 -61
- package/site-def/footer/company.ts +0 -37
- package/site-def/footer/ecosystem.ts +0 -37
- package/site-def/footer/index.tsx +0 -26
- package/site-def/footer/legal.ts +0 -28
- package/site-def/footer/network.ts +0 -45
- package/site-def/footer/svg/warpcast-logo.svg +0 -12
- package/site-def/index.ts +0 -4
- package/site-def/main-nav.tsx +0 -460
- package/style/cart-animation.css +0 -29
- package/style/checkout-animation.css +0 -23
- package/style/drawer-handle-overrides.css +0 -160
- package/style/fonts/COPY_TO_PUBLIC_FOR_NON_NEXT.txt +0 -0
- package/style/fonts/Druk-Wide-Bold.ttf +0 -0
- package/style/fonts/Druk-Wide-Medium.ttf +0 -0
- package/style/fonts/InterVariable-Italic.ttf +0 -0
- package/style/fonts/InterVariable-Italic.woff2 +0 -0
- package/style/fonts/InterVariable.ttf +0 -0
- package/style/fonts/InterVariable.woff2 +0 -0
- package/style/lux-colors.css +0 -85
- package/style/lux-fonts.css +0 -30
- package/style/lux-global-non-next.css +0 -52
- package/style/lux-global.css +0 -51
- package/tailwind/fontFamily.tailwind.lux.ts +0 -18
- package/tailwind/index.ts +0 -2
- package/tailwind/lux-tw-fonts.ts +0 -40
- package/tailwind/tailwind.config.lux-preset.ts +0 -10
- package/tsconfig.json +0 -15
- package/types/chatbot-config.ts +0 -7
- package/types/chatbot-suggested-question.ts +0 -7
- package/types/contact-info.ts +0 -11
- package/types/index.ts +0 -4
- package/types/site-def.ts +0 -46
package/src/tabs.tsx
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import * as RadixTabs from '@radix-ui/react-tabs';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import { cn } from './utils';
|
|
5
|
+
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// Variant / size / fitted types (match the old Chakra recipe)
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
type TabsVariant = 'solid' | 'secondary' | 'segmented' | 'unstyled';
|
|
11
|
+
type TabsSize = 'sm' | 'md' | 'free';
|
|
12
|
+
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// TabsRoot
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
export interface TabsProps extends Omit<React.ComponentPropsWithoutRef<typeof RadixTabs.Root>, 'onValueChange'> {
|
|
18
|
+
|
|
19
|
+
/** Visual variant. Default: "solid". */
|
|
20
|
+
variant?: TabsVariant;
|
|
21
|
+
|
|
22
|
+
/** Size preset. Default: "md". */
|
|
23
|
+
size?: TabsSize;
|
|
24
|
+
|
|
25
|
+
/** Stretch triggers to fill the list width. */
|
|
26
|
+
fitted?: boolean;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Chakra-compat. Radix mounts lazily by default (content only
|
|
30
|
+
* renders when active). Kept so call-sites don't break at compile time.
|
|
31
|
+
*/
|
|
32
|
+
lazyMount?: boolean;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated Chakra-compat. Radix unmounts inactive content by default.
|
|
36
|
+
* Kept so call-sites don't break at compile time.
|
|
37
|
+
*/
|
|
38
|
+
unmountOnExit?: boolean;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Chakra-compatible value-change handler.
|
|
42
|
+
* Accepts both `(details: { value: string }) => void` (Chakra convention)
|
|
43
|
+
* and `(value: string) => void` (Radix convention).
|
|
44
|
+
*/
|
|
45
|
+
onValueChange?: ((details: { value: string }) => void) | ((value: string) => void);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const ROOT_SIZE_CLASSES: Record<TabsSize, string> = {
|
|
49
|
+
sm: '[--tabs-height:2rem] [--tabs-content-padding:1.5rem]',
|
|
50
|
+
md: '[--tabs-height:2.5rem] [--tabs-content-padding:1.5rem]',
|
|
51
|
+
free: '',
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const TabsRoot = React.forwardRef<HTMLDivElement, TabsProps>(
|
|
55
|
+
function TabsRoot(props, ref) {
|
|
56
|
+
const {
|
|
57
|
+
variant = 'solid',
|
|
58
|
+
size = 'md',
|
|
59
|
+
fitted,
|
|
60
|
+
lazyMount: _lazyMount,
|
|
61
|
+
unmountOnExit: _unmountOnExit,
|
|
62
|
+
onValueChange,
|
|
63
|
+
className,
|
|
64
|
+
...rest
|
|
65
|
+
} = props;
|
|
66
|
+
|
|
67
|
+
// Bridge Chakra-style `onValueChange({value})` to Radix `onValueChange(value)`
|
|
68
|
+
const handleValueChange = React.useCallback(
|
|
69
|
+
(value: string) => {
|
|
70
|
+
if (!onValueChange) return;
|
|
71
|
+
// Detect which signature the caller expects by trying the Chakra shape.
|
|
72
|
+
// Both signatures are valid TS, so we call with the object form since
|
|
73
|
+
// all existing consumers use `({ value })`.
|
|
74
|
+
(onValueChange as (details: { value: string }) => void)({ value });
|
|
75
|
+
},
|
|
76
|
+
[ onValueChange ],
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<RadixTabs.Root
|
|
81
|
+
ref={ ref }
|
|
82
|
+
data-variant={ variant }
|
|
83
|
+
data-size={ size }
|
|
84
|
+
data-fitted={ fitted ? '' : undefined }
|
|
85
|
+
className={ cn(
|
|
86
|
+
'relative',
|
|
87
|
+
ROOT_SIZE_CLASSES[size],
|
|
88
|
+
className,
|
|
89
|
+
) }
|
|
90
|
+
onValueChange={ onValueChange ? handleValueChange : undefined }
|
|
91
|
+
{ ...rest }
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
},
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
// ---------------------------------------------------------------------------
|
|
98
|
+
// TabsList
|
|
99
|
+
// ---------------------------------------------------------------------------
|
|
100
|
+
|
|
101
|
+
export interface TabsListProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
102
|
+
// Radix pass-through
|
|
103
|
+
asChild?: boolean;
|
|
104
|
+
loop?: boolean;
|
|
105
|
+
// Legacy Chakra style-prop shims
|
|
106
|
+
flexWrap?: string;
|
|
107
|
+
alignItems?: string;
|
|
108
|
+
whiteSpace?: string;
|
|
109
|
+
bgColor?: string;
|
|
110
|
+
marginBottom?: number | string;
|
|
111
|
+
mx?: string | Record<string, string>;
|
|
112
|
+
px?: string | Record<string, string>;
|
|
113
|
+
w?: string | Record<string, string>;
|
|
114
|
+
overflowX?: string | Record<string, string>;
|
|
115
|
+
overscrollBehaviorX?: string;
|
|
116
|
+
css?: Record<string, unknown>;
|
|
117
|
+
position?: string;
|
|
118
|
+
boxShadow?: string | Record<string, string>;
|
|
119
|
+
top?: number | string;
|
|
120
|
+
zIndex?: string | Record<string, string>;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export const TabsList = React.forwardRef<HTMLDivElement, TabsListProps>(
|
|
124
|
+
function TabsList(props, ref) {
|
|
125
|
+
const {
|
|
126
|
+
className,
|
|
127
|
+
// Strip Chakra style props
|
|
128
|
+
flexWrap: _flexWrap, alignItems: _alignItems, whiteSpace: _whiteSpace,
|
|
129
|
+
bgColor: _bgColor, marginBottom: _marginBottom, mx: _mx, px: _px,
|
|
130
|
+
w: _w, overflowX: _overflowX, overscrollBehaviorX: _overscrollBehaviorX,
|
|
131
|
+
css: _css, position: _position, boxShadow: _boxShadow, top: _top,
|
|
132
|
+
zIndex: _zIndex,
|
|
133
|
+
style: styleProp,
|
|
134
|
+
asChild, loop,
|
|
135
|
+
...rest
|
|
136
|
+
} = props;
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<RadixTabs.List
|
|
140
|
+
ref={ ref }
|
|
141
|
+
asChild={ asChild }
|
|
142
|
+
loop={ loop }
|
|
143
|
+
className={ cn(
|
|
144
|
+
'inline-flex w-full relative isolate flex-row',
|
|
145
|
+
'min-h-[var(--tabs-height,2.5rem)]',
|
|
146
|
+
className,
|
|
147
|
+
) }
|
|
148
|
+
style={ styleProp }
|
|
149
|
+
{ ...rest }
|
|
150
|
+
/>
|
|
151
|
+
);
|
|
152
|
+
},
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
// ---------------------------------------------------------------------------
|
|
156
|
+
// TabsTrigger
|
|
157
|
+
// ---------------------------------------------------------------------------
|
|
158
|
+
|
|
159
|
+
export interface TabsTriggerProps extends Omit<React.ComponentPropsWithoutRef<typeof RadixTabs.Trigger>, 'dir'> {
|
|
160
|
+
// Legacy Chakra style-prop shims
|
|
161
|
+
scrollSnapAlign?: string;
|
|
162
|
+
flexShrink?: number;
|
|
163
|
+
bgColor?: string | Record<string, string>;
|
|
164
|
+
w?: string;
|
|
165
|
+
py?: string;
|
|
166
|
+
borderRadius?: string;
|
|
167
|
+
fontWeight?: string;
|
|
168
|
+
color?: string;
|
|
169
|
+
_hover?: Record<string, string>;
|
|
170
|
+
position?: string;
|
|
171
|
+
top?: string;
|
|
172
|
+
left?: string;
|
|
173
|
+
visibility?: string;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const TRIGGER_BASE =
|
|
177
|
+
'outline-none min-w-[var(--tabs-height,2.5rem)] h-[var(--tabs-height,2.5rem)]' +
|
|
178
|
+
' flex items-center relative cursor-pointer gap-2' +
|
|
179
|
+
' focus-visible:z-[1] focus-visible:outline-2 focus-visible:outline-offset-0' +
|
|
180
|
+
' disabled:cursor-not-allowed disabled:opacity-50';
|
|
181
|
+
|
|
182
|
+
const TRIGGER_SIZE_CLASSES: Record<TabsSize, string> = {
|
|
183
|
+
sm: 'py-1 px-3 text-sm',
|
|
184
|
+
md: 'py-2 px-4 text-base',
|
|
185
|
+
free: '',
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const TRIGGER_VARIANT_CLASSES: Record<TabsVariant, string> = {
|
|
189
|
+
solid:
|
|
190
|
+
'font-semibold gap-1 rounded-md bg-transparent' +
|
|
191
|
+
' text-tabs-solid-fg' +
|
|
192
|
+
' data-[state=active]:bg-selected-control-bg data-[state=active]:text-selected-control-text' +
|
|
193
|
+
' data-[state=active]:hover:text-selected-control-text' +
|
|
194
|
+
' hover:text-hover',
|
|
195
|
+
secondary:
|
|
196
|
+
'font-medium bg-transparent' +
|
|
197
|
+
' text-tabs-secondary-fg' +
|
|
198
|
+
' border-2 border-solid border-tabs-secondary-border rounded-md' +
|
|
199
|
+
' data-[state=active]:bg-selected-control-bg data-[state=active]:text-selected-control-text' +
|
|
200
|
+
' data-[state=active]:border-transparent data-[state=active]:hover:border-transparent' +
|
|
201
|
+
' hover:text-hover hover:border-hover',
|
|
202
|
+
segmented:
|
|
203
|
+
'bg-transparent' +
|
|
204
|
+
' text-text-primary' +
|
|
205
|
+
' border-2 border-solid border-selected-control-bg' +
|
|
206
|
+
' hover:text-hover' +
|
|
207
|
+
' data-[state=active]:text-selected-control-text data-[state=active]:bg-selected-control-bg' +
|
|
208
|
+
' data-[state=active]:border-selected-control-bg' +
|
|
209
|
+
' data-[state=active]:hover:text-selected-control-text',
|
|
210
|
+
unstyled: '',
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export const TabsTrigger = React.forwardRef<HTMLButtonElement, TabsTriggerProps>(
|
|
214
|
+
function TabsTrigger(props, ref) {
|
|
215
|
+
const {
|
|
216
|
+
className,
|
|
217
|
+
// Strip Chakra style props
|
|
218
|
+
scrollSnapAlign: _scrollSnapAlign, flexShrink: _flexShrink, bgColor: _bgColor,
|
|
219
|
+
w: _w, py: _py, borderRadius: _borderRadius, fontWeight: _fontWeight,
|
|
220
|
+
color: _color, _hover, position: _position, top: _top, left: _left,
|
|
221
|
+
visibility: _visibility,
|
|
222
|
+
...rest
|
|
223
|
+
} = props;
|
|
224
|
+
|
|
225
|
+
// Read variant / size from the closest TabsRoot via DOM data attributes.
|
|
226
|
+
// We could use React context, but reading from data-* keeps the API surface
|
|
227
|
+
// identical to Chakra where recipe tokens cascade automatically.
|
|
228
|
+
const internalRef = React.useRef<HTMLButtonElement>(null);
|
|
229
|
+
const mergedRef = useMergedRef(ref, internalRef);
|
|
230
|
+
const { variant, size, fitted } = useTabsContext(internalRef);
|
|
231
|
+
|
|
232
|
+
return (
|
|
233
|
+
<RadixTabs.Trigger
|
|
234
|
+
ref={ mergedRef }
|
|
235
|
+
className={ cn(
|
|
236
|
+
'group',
|
|
237
|
+
TRIGGER_BASE,
|
|
238
|
+
TRIGGER_SIZE_CLASSES[size],
|
|
239
|
+
TRIGGER_VARIANT_CLASSES[variant],
|
|
240
|
+
fitted && 'flex-1 text-center justify-center',
|
|
241
|
+
className,
|
|
242
|
+
) }
|
|
243
|
+
{ ...rest }
|
|
244
|
+
/>
|
|
245
|
+
);
|
|
246
|
+
},
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
// ---------------------------------------------------------------------------
|
|
250
|
+
// TabsContent
|
|
251
|
+
// ---------------------------------------------------------------------------
|
|
252
|
+
|
|
253
|
+
export interface TabsContentProps extends React.ComponentPropsWithoutRef<typeof RadixTabs.Content> {
|
|
254
|
+
// Legacy Chakra style-prop shims
|
|
255
|
+
padding?: number | string;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export const TabsContent = React.forwardRef<HTMLDivElement, TabsContentProps>(
|
|
259
|
+
function TabsContent(props, ref) {
|
|
260
|
+
const { className, padding: _padding, ...rest } = props;
|
|
261
|
+
|
|
262
|
+
return (
|
|
263
|
+
<RadixTabs.Content
|
|
264
|
+
ref={ ref }
|
|
265
|
+
className={ cn(
|
|
266
|
+
'w-full pt-[var(--tabs-content-padding,1.5rem)]',
|
|
267
|
+
'focus-visible:outline-2 focus-visible:outline-offset-[-2px]',
|
|
268
|
+
className,
|
|
269
|
+
) }
|
|
270
|
+
{ ...rest }
|
|
271
|
+
/>
|
|
272
|
+
);
|
|
273
|
+
},
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
// ---------------------------------------------------------------------------
|
|
277
|
+
// TabsCounter
|
|
278
|
+
// ---------------------------------------------------------------------------
|
|
279
|
+
|
|
280
|
+
export interface TabsCounterProps {
|
|
281
|
+
count?: number | null;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const COUNTER_OVERLOAD = 50;
|
|
285
|
+
|
|
286
|
+
export const TabsCounter = ({ count }: TabsCounterProps): React.ReactElement | null => {
|
|
287
|
+
if (count === undefined || count === null) {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return (
|
|
292
|
+
<span
|
|
293
|
+
className={ cn(
|
|
294
|
+
'group-hover:text-inherit',
|
|
295
|
+
count > 0 ?
|
|
296
|
+
'text-text-secondary' :
|
|
297
|
+
'text-[rgba(16,17,18,0.24)] dark:text-[rgba(255,255,255,0.24)]',
|
|
298
|
+
) }
|
|
299
|
+
>
|
|
300
|
+
{ count > COUNTER_OVERLOAD ? `${ COUNTER_OVERLOAD }+` : count }
|
|
301
|
+
</span>
|
|
302
|
+
);
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
// ---------------------------------------------------------------------------
|
|
306
|
+
// Helpers
|
|
307
|
+
// ---------------------------------------------------------------------------
|
|
308
|
+
|
|
309
|
+
/** Read variant / size / fitted from the nearest ancestor [data-variant] element. */
|
|
310
|
+
function useTabsContext(triggerRef: React.RefObject<HTMLButtonElement | null>): {
|
|
311
|
+
variant: TabsVariant;
|
|
312
|
+
size: TabsSize;
|
|
313
|
+
fitted: boolean;
|
|
314
|
+
} {
|
|
315
|
+
const [ ctx, setCtx ] = React.useState<{
|
|
316
|
+
variant: TabsVariant;
|
|
317
|
+
size: TabsSize;
|
|
318
|
+
fitted: boolean;
|
|
319
|
+
}>({ variant: 'solid', size: 'md', fitted: false });
|
|
320
|
+
|
|
321
|
+
React.useEffect(() => {
|
|
322
|
+
const el = triggerRef.current;
|
|
323
|
+
if (!el) return;
|
|
324
|
+
const root = el.closest('[data-variant]');
|
|
325
|
+
if (!root) return;
|
|
326
|
+
setCtx({
|
|
327
|
+
variant: (root.getAttribute('data-variant') as TabsVariant) ?? 'solid',
|
|
328
|
+
size: (root.getAttribute('data-size') as TabsSize) ?? 'md',
|
|
329
|
+
fitted: root.hasAttribute('data-fitted'),
|
|
330
|
+
});
|
|
331
|
+
}, [ triggerRef ]);
|
|
332
|
+
|
|
333
|
+
return ctx;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** Merge multiple refs into one callback ref. */
|
|
337
|
+
function useMergedRef<T>(
|
|
338
|
+
...refs: Array<React.Ref<T> | undefined>
|
|
339
|
+
): React.RefCallback<T> {
|
|
340
|
+
return React.useCallback(
|
|
341
|
+
(instance: T | null) => {
|
|
342
|
+
for (const ref of refs) {
|
|
343
|
+
if (!ref) continue;
|
|
344
|
+
if (typeof ref === 'function') {
|
|
345
|
+
ref(instance);
|
|
346
|
+
} else {
|
|
347
|
+
(ref as React.MutableRefObject<T | null>).current = instance;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
352
|
+
refs,
|
|
353
|
+
);
|
|
354
|
+
}
|
package/src/tag.tsx
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { cva } from 'class-variance-authority';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import { cn } from './utils';
|
|
5
|
+
|
|
6
|
+
import { CloseButton } from './close-button';
|
|
7
|
+
import { Skeleton } from './skeleton';
|
|
8
|
+
import { Tooltip } from './tooltip';
|
|
9
|
+
|
|
10
|
+
// Inline constants
|
|
11
|
+
const nbsp = String.fromCharCode(160);
|
|
12
|
+
|
|
13
|
+
// Inline truncation tooltip
|
|
14
|
+
function TruncatedTextTooltip({ label, children }: { readonly label: React.ReactNode; readonly children: React.ReactNode }) {
|
|
15
|
+
return (
|
|
16
|
+
<Tooltip content={ label } positioning={{ placement: 'top' }}>
|
|
17
|
+
{ children }
|
|
18
|
+
</Tooltip>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type TagVariant = 'subtle' | 'clickable' | 'filter' | 'select';
|
|
23
|
+
type TagSize = 'sm' | 'md' | 'lg';
|
|
24
|
+
|
|
25
|
+
const tagVariants = cva(
|
|
26
|
+
[
|
|
27
|
+
'inline-flex items-center align-top max-w-full select-text rounded-sm',
|
|
28
|
+
'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-500',
|
|
29
|
+
].join(' '),
|
|
30
|
+
{
|
|
31
|
+
variants: {
|
|
32
|
+
variant: {
|
|
33
|
+
subtle: 'bg-[var(--color-tag-subtle-bg)] text-[var(--color-tag-subtle-fg)]',
|
|
34
|
+
clickable: [
|
|
35
|
+
'cursor-pointer',
|
|
36
|
+
'bg-[var(--color-tag-clickable-bg)] text-[var(--color-tag-clickable-fg)]',
|
|
37
|
+
'hover:opacity-76',
|
|
38
|
+
].join(' '),
|
|
39
|
+
filter: 'bg-[var(--color-tag-filter-bg)]',
|
|
40
|
+
select: [
|
|
41
|
+
'cursor-pointer',
|
|
42
|
+
'bg-[var(--color-tag-select-bg)] text-[var(--color-tag-select-fg)]',
|
|
43
|
+
'hover:text-[var(--color-hover)] hover:opacity-76',
|
|
44
|
+
].join(' '),
|
|
45
|
+
},
|
|
46
|
+
size: {
|
|
47
|
+
sm: 'px-1 py-0.5 min-h-5 gap-1 text-xs',
|
|
48
|
+
md: 'px-1 py-0.5 min-h-6 gap-1 text-sm',
|
|
49
|
+
lg: 'px-1.5 py-1.5 min-h-8 min-w-8 gap-1 text-sm',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
defaultVariants: {
|
|
53
|
+
variant: 'subtle',
|
|
54
|
+
size: 'md',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const TAG_SELECTED_CLASSES = [
|
|
60
|
+
'bg-[var(--color-tag-select-selected-bg)]',
|
|
61
|
+
'text-[var(--color-tag-select-selected-fg)]',
|
|
62
|
+
'hover:text-[var(--color-tag-select-selected-fg)]',
|
|
63
|
+
'hover:opacity-76',
|
|
64
|
+
].join(' ');
|
|
65
|
+
|
|
66
|
+
const TAG_DISABLED_CLASSES = 'opacity-40 pointer-events-none cursor-not-allowed';
|
|
67
|
+
|
|
68
|
+
export interface TagProps extends Omit<React.ComponentPropsWithRef<'span'>, 'size'> {
|
|
69
|
+
readonly variant?: TagVariant;
|
|
70
|
+
readonly size?: TagSize;
|
|
71
|
+
readonly startElement?: React.ReactNode;
|
|
72
|
+
readonly endElement?: React.ReactNode;
|
|
73
|
+
readonly endElementProps?: React.HTMLAttributes<HTMLSpanElement>;
|
|
74
|
+
readonly label?: string;
|
|
75
|
+
readonly onClose?: VoidFunction;
|
|
76
|
+
readonly closable?: boolean;
|
|
77
|
+
readonly truncated?: boolean;
|
|
78
|
+
readonly loading?: boolean;
|
|
79
|
+
readonly selected?: boolean;
|
|
80
|
+
readonly disabled?: boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const Tag = React.forwardRef<HTMLSpanElement, TagProps>(
|
|
84
|
+
function Tag(props, ref) {
|
|
85
|
+
const {
|
|
86
|
+
variant,
|
|
87
|
+
size,
|
|
88
|
+
startElement,
|
|
89
|
+
endElement,
|
|
90
|
+
endElementProps,
|
|
91
|
+
label,
|
|
92
|
+
onClose,
|
|
93
|
+
closable = Boolean(onClose),
|
|
94
|
+
children,
|
|
95
|
+
truncated = false,
|
|
96
|
+
loading,
|
|
97
|
+
selected,
|
|
98
|
+
disabled,
|
|
99
|
+
className,
|
|
100
|
+
...rest
|
|
101
|
+
} = props;
|
|
102
|
+
|
|
103
|
+
const labelElement = label ? (
|
|
104
|
+
<span className="text-[var(--color-text-secondary)]">{ label }:{ nbsp }</span>
|
|
105
|
+
) : null;
|
|
106
|
+
|
|
107
|
+
const labelSpan = (
|
|
108
|
+
<span className="line-clamp-1 whitespace-nowrap text-ellipsis font-medium inline">
|
|
109
|
+
{ labelElement }{ children }
|
|
110
|
+
</span>
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const contentElement = truncated ? (
|
|
114
|
+
<TruncatedTextTooltip label={ children }>
|
|
115
|
+
{ labelSpan }
|
|
116
|
+
</TruncatedTextTooltip>
|
|
117
|
+
) : labelSpan;
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<Skeleton loading={ loading } asChild>
|
|
121
|
+
<span
|
|
122
|
+
ref={ ref }
|
|
123
|
+
className={ cn(
|
|
124
|
+
tagVariants({ variant, size }),
|
|
125
|
+
selected && !loading && TAG_SELECTED_CLASSES,
|
|
126
|
+
disabled && TAG_DISABLED_CLASSES,
|
|
127
|
+
className,
|
|
128
|
+
) }
|
|
129
|
+
{ ...(selected && !loading && { 'data-selected': true }) }
|
|
130
|
+
{ ...(disabled && { 'data-disabled': true }) }
|
|
131
|
+
{ ...rest }
|
|
132
|
+
>
|
|
133
|
+
{ startElement && (
|
|
134
|
+
<span className="shrink-0 inline-flex items-center justify-center empty:hidden">
|
|
135
|
+
{ startElement }
|
|
136
|
+
</span>
|
|
137
|
+
) }
|
|
138
|
+
{ contentElement }
|
|
139
|
+
{ endElement && (
|
|
140
|
+
<span
|
|
141
|
+
{ ...endElementProps }
|
|
142
|
+
className={ cn(
|
|
143
|
+
'shrink-0 inline-flex items-center justify-center',
|
|
144
|
+
endElementProps?.className,
|
|
145
|
+
) }
|
|
146
|
+
>
|
|
147
|
+
{ endElement }
|
|
148
|
+
</span>
|
|
149
|
+
) }
|
|
150
|
+
{ closable && (
|
|
151
|
+
<span className="shrink-0 inline-flex items-center justify-center">
|
|
152
|
+
<CloseButton onClick={ onClose }/>
|
|
153
|
+
</span>
|
|
154
|
+
) }
|
|
155
|
+
</span>
|
|
156
|
+
</Skeleton>
|
|
157
|
+
);
|
|
158
|
+
},
|
|
159
|
+
);
|
package/src/textarea.tsx
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { cva } from 'class-variance-authority';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import { cn } from './utils';
|
|
5
|
+
|
|
6
|
+
const textareaVariants = cva(
|
|
7
|
+
[
|
|
8
|
+
'w-full appearance-none outline-none transition-colors resize-y',
|
|
9
|
+
'bg-[var(--color-input-bg)] text-[var(--color-input-fg)] border-[var(--color-input-border)]',
|
|
10
|
+
'placeholder:text-[var(--color-input-placeholder,theme(colors.gray.400))]',
|
|
11
|
+
'hover:border-[var(--color-input-border-hover,theme(colors.gray.400))]',
|
|
12
|
+
'focus:border-[var(--color-input-border-focus,theme(colors.blue.500))]',
|
|
13
|
+
'focus:placeholder:text-[var(--color-input-placeholder-focus,theme(colors.gray.300))]',
|
|
14
|
+
'disabled:opacity-40 disabled:cursor-not-allowed',
|
|
15
|
+
'read-only:opacity-70',
|
|
16
|
+
'data-[invalid]:border-[var(--color-input-border-invalid,theme(colors.red.500))]',
|
|
17
|
+
].join(' '),
|
|
18
|
+
{
|
|
19
|
+
variants: {
|
|
20
|
+
size: {
|
|
21
|
+
xs: 'px-2 py-1 text-xs rounded',
|
|
22
|
+
sm: 'px-3 py-2 text-sm rounded-md',
|
|
23
|
+
md: 'px-4 py-2 text-base rounded-md',
|
|
24
|
+
lg: 'px-4 py-3 text-lg rounded-lg',
|
|
25
|
+
'2xl': 'px-4 py-3 text-xl rounded-lg',
|
|
26
|
+
},
|
|
27
|
+
variant: {
|
|
28
|
+
outline: 'border border-solid',
|
|
29
|
+
filled: 'border-0 bg-[var(--color-input-filled-bg,theme(colors.gray.100))]',
|
|
30
|
+
unstyled: 'border-0 bg-transparent p-0',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
defaultVariants: {
|
|
34
|
+
size: 'md',
|
|
35
|
+
variant: 'outline',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
type TextareaSize = 'xs' | 'sm' | 'md' | 'lg' | '2xl';
|
|
41
|
+
type TextareaVariant = 'outline' | 'filled' | 'unstyled';
|
|
42
|
+
|
|
43
|
+
export interface TextareaProps extends Omit<React.ComponentPropsWithRef<'textarea'>, 'size'> {
|
|
44
|
+
readonly size?: TextareaSize;
|
|
45
|
+
readonly variant?: TextareaVariant;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
49
|
+
({ size, variant, className, ...rest }, ref) => {
|
|
50
|
+
return (
|
|
51
|
+
<textarea
|
|
52
|
+
ref={ ref }
|
|
53
|
+
className={ cn(textareaVariants({ size, variant }), className) }
|
|
54
|
+
{ ...rest }
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
Textarea.displayName = 'Textarea';
|
package/src/toaster.tsx
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type React from 'react';
|
|
4
|
+
import { Toaster as SonnerToaster, toast } from 'sonner';
|
|
5
|
+
|
|
6
|
+
const SECOND = 1_000;
|
|
7
|
+
const DURATION = 10 * SECOND;
|
|
8
|
+
|
|
9
|
+
interface ToastOptions {
|
|
10
|
+
readonly id?: string | number;
|
|
11
|
+
readonly title?: string;
|
|
12
|
+
readonly description?: string;
|
|
13
|
+
readonly type?: 'info' | 'warning' | 'success' | 'error' | 'loading';
|
|
14
|
+
readonly duration?: number;
|
|
15
|
+
readonly action?: { readonly label: string; readonly onClick: () => void };
|
|
16
|
+
readonly onStatusChange?: (details: { readonly status: string }) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function mapOptions(opts: ToastOptions): Parameters<typeof toast>[1] {
|
|
20
|
+
const external: Parameters<typeof toast>[1] = {
|
|
21
|
+
id: opts.id,
|
|
22
|
+
description: opts.description,
|
|
23
|
+
duration: opts.duration,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
if (opts.action) {
|
|
27
|
+
external.action = {
|
|
28
|
+
label: opts.action.label,
|
|
29
|
+
onClick: opts.action.onClick,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (opts.onStatusChange) {
|
|
34
|
+
const cb = opts.onStatusChange;
|
|
35
|
+
external.onDismiss = () => cb({ status: 'unmounted' });
|
|
36
|
+
external.onAutoClose = () => cb({ status: 'unmounted' });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return external;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function create(opts: ToastOptions): string | number {
|
|
43
|
+
const external = mapOptions(opts);
|
|
44
|
+
const title = opts.title ?? '';
|
|
45
|
+
|
|
46
|
+
switch (opts.type) {
|
|
47
|
+
case 'success':
|
|
48
|
+
return toast.success(title, external);
|
|
49
|
+
case 'error':
|
|
50
|
+
return toast.error(title, external);
|
|
51
|
+
case 'warning':
|
|
52
|
+
return toast.warning(title, external);
|
|
53
|
+
case 'loading':
|
|
54
|
+
return toast.loading(title, external);
|
|
55
|
+
case 'info':
|
|
56
|
+
default:
|
|
57
|
+
return toast.info(title, external);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function update(id: string | number, opts: ToastOptions): void {
|
|
62
|
+
const title = opts.title ?? '';
|
|
63
|
+
|
|
64
|
+
// Sonner does not have a dedicated update method.
|
|
65
|
+
// Re-calling a typed toast with the same id replaces it in-place.
|
|
66
|
+
const external = mapOptions({ ...opts, id });
|
|
67
|
+
|
|
68
|
+
switch (opts.type) {
|
|
69
|
+
case 'success':
|
|
70
|
+
toast.success(title, external);
|
|
71
|
+
break;
|
|
72
|
+
case 'error':
|
|
73
|
+
toast.error(title, external);
|
|
74
|
+
break;
|
|
75
|
+
case 'warning':
|
|
76
|
+
toast.warning(title, external);
|
|
77
|
+
break;
|
|
78
|
+
case 'loading':
|
|
79
|
+
toast.loading(title, external);
|
|
80
|
+
break;
|
|
81
|
+
case 'info':
|
|
82
|
+
default:
|
|
83
|
+
toast.info(title, external);
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const toaster = {
|
|
89
|
+
create,
|
|
90
|
+
success: (opts: ToastOptions) => create({ ...opts, type: 'success' }),
|
|
91
|
+
error: (opts: ToastOptions) => create({ ...opts, type: 'error' }),
|
|
92
|
+
loading: (opts: ToastOptions) => create({ ...opts, type: 'loading' }),
|
|
93
|
+
update,
|
|
94
|
+
remove: (id: string | number) => toast.dismiss(id),
|
|
95
|
+
} as const;
|
|
96
|
+
|
|
97
|
+
export const Toaster: React.FC = () => {
|
|
98
|
+
return (
|
|
99
|
+
<SonnerToaster
|
|
100
|
+
position="top-right"
|
|
101
|
+
richColors
|
|
102
|
+
closeButton
|
|
103
|
+
duration={ DURATION }
|
|
104
|
+
offset={{ top: 12, right: 12, bottom: 12, left: 12 }}
|
|
105
|
+
mobileOffset={{ top: 16, right: 16, bottom: 16, left: 16 }}
|
|
106
|
+
toastOptions={{
|
|
107
|
+
className: 'font-sans',
|
|
108
|
+
style: {
|
|
109
|
+
fontFamily: 'var(--font-sans, "Geist", sans-serif)',
|
|
110
|
+
color: 'var(--color-text-primary)',
|
|
111
|
+
backgroundColor: 'var(--color-bg-primary)',
|
|
112
|
+
borderColor: 'var(--color-border-divider)',
|
|
113
|
+
},
|
|
114
|
+
}}
|
|
115
|
+
/>
|
|
116
|
+
);
|
|
117
|
+
};
|