myshell-react-lib 0.1.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 +268 -0
- package/dist/assets/audio-playing.json +3657 -0
- package/dist/index.cjs +9654 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1431 -0
- package/dist/index.d.ts +1431 -0
- package/dist/index.js +8788 -0
- package/dist/index.js.map +1 -0
- package/package.json +140 -0
- package/src/common/assets/audio-playing.json +3657 -0
- package/src/common/constants/constants.ts +24 -0
- package/src/common/constants/types/common.ts +10 -0
- package/src/common/hooks/useAudioPlayer.tsx +198 -0
- package/src/common/hooks/useDevice.ts +26 -0
- package/src/common/hooks/useNativeBridge.ts +42 -0
- package/src/common/hooks/useNotification.tsx +179 -0
- package/src/common/hooks/useWindowWidth.ts +19 -0
- package/src/common/utils/common-helper.ts +81 -0
- package/src/components/ItemDemo.tsx +15 -0
- package/src/components/accordion.tsx +126 -0
- package/src/components/alert-dialog.tsx +148 -0
- package/src/components/alert.tsx +65 -0
- package/src/components/aspect-ratio.tsx +7 -0
- package/src/components/audio-player.tsx +58 -0
- package/src/components/avatar.tsx +133 -0
- package/src/components/badge.tsx +65 -0
- package/src/components/button/button.styles.ts +258 -0
- package/src/components/button/button.tsx +215 -0
- package/src/components/button/icon-button.styles.ts +101 -0
- package/src/components/button/icon-button.tsx +100 -0
- package/src/components/button/index.tsx +3 -0
- package/src/components/button/link-button.tsx +184 -0
- package/src/components/cascader.tsx +175 -0
- package/src/components/checkbox.tsx +135 -0
- package/src/components/command.tsx +155 -0
- package/src/components/context-menu.tsx +198 -0
- package/src/components/count-down.tsx +83 -0
- package/src/components/custom-notification.tsx +95 -0
- package/src/components/dialog.tsx +158 -0
- package/src/components/drawer.tsx +116 -0
- package/src/components/dropdown-menu.tsx +196 -0
- package/src/components/energy-progress.tsx +55 -0
- package/src/components/form.tsx +201 -0
- package/src/components/group.tsx +9 -0
- package/src/components/guide.tsx +243 -0
- package/src/components/icon.tsx +89 -0
- package/src/components/icons/outline/DownIcon.tsx +18 -0
- package/src/components/icons/outline/FilterIcon.tsx +21 -0
- package/src/components/icons/outline/arrow-left.tsx +16 -0
- package/src/components/icons/outline/arrow-up-tray.tsx +16 -0
- package/src/components/icons/outline/check-circle.tsx +17 -0
- package/src/components/icons/outline/config.tsx +42 -0
- package/src/components/icons/outline/pencil-square.tsx +16 -0
- package/src/components/icons/outline/trash.tsx +17 -0
- package/src/components/icons/outline/window.tsx +16 -0
- package/src/components/icons/outline/x-circle.tsx +17 -0
- package/src/components/icons/outline/x-mark.tsx +16 -0
- package/src/components/icons/solid/audio-playing.tsx +31 -0
- package/src/components/icons/solid/caret-down.tsx +14 -0
- package/src/components/icons/solid/code.tsx +18 -0
- package/src/components/icons/solid/drag.tsx +14 -0
- package/src/components/icons/solid/phone.tsx +23 -0
- package/src/components/icons/solid/rectangle-group.tsx +14 -0
- package/src/components/image.tsx +151 -0
- package/src/components/input.tsx +118 -0
- package/src/components/label.tsx +26 -0
- package/src/components/link.tsx +123 -0
- package/src/components/marquee/index.css +15 -0
- package/src/components/marquee/marquee.tsx +220 -0
- package/src/components/masonry.tsx +138 -0
- package/src/components/menubar.tsx +234 -0
- package/src/components/mobile/m-tooltip.tsx +34 -0
- package/src/components/modal.tsx +561 -0
- package/src/components/navigation-bar.tsx +100 -0
- package/src/components/number-input.tsx +143 -0
- package/src/components/page-content.tsx +16 -0
- package/src/components/popover.tsx +191 -0
- package/src/components/progress.tsx +80 -0
- package/src/components/radio-group.tsx +44 -0
- package/src/components/scroll-area.tsx +49 -0
- package/src/components/search-bar.tsx +140 -0
- package/src/components/secondary-navigation-bar.tsx +307 -0
- package/src/components/select.tsx +273 -0
- package/src/components/separator.tsx +31 -0
- package/src/components/sheet.tsx +143 -0
- package/src/components/skeleton.tsx +20 -0
- package/src/components/slider.tsx +160 -0
- package/src/components/spinner.tsx +48 -0
- package/src/components/swiper/index.module.scss +88 -0
- package/src/components/swiper/index.tsx +319 -0
- package/src/components/switch.tsx +67 -0
- package/src/components/tabs.tsx +325 -0
- package/src/components/textarea.tsx +71 -0
- package/src/components/toast/toast.tsx +182 -0
- package/src/components/toast/toaster.tsx +160 -0
- package/src/components/toast/use-toast.tsx +248 -0
- package/src/components/toggle-group.tsx +64 -0
- package/src/components/toggle.tsx +46 -0
- package/src/components/tooltip.tsx +283 -0
- package/src/components/typography.tsx +437 -0
- package/src/index.ts +66 -0
- package/src/lib/utils.ts +62 -0
- package/src/stories/Accordion.stories.tsx +64 -0
- package/src/stories/AccordionItem.stories.tsx +48 -0
- package/src/stories/Avatar.stories.ts +58 -0
- package/src/stories/Badge.stories.tsx +40 -0
- package/src/stories/BannerSwiper.stories.tsx +102 -0
- package/src/stories/Button.stories.tsx +543 -0
- package/src/stories/Checkbox.stories.tsx +161 -0
- package/src/stories/Configure.mdx +341 -0
- package/src/stories/CssProperties.mdx +30 -0
- package/src/stories/Description.stories.ts +70 -0
- package/src/stories/Display.stories.ts +64 -0
- package/src/stories/FeaturedSwiper.stories.tsx +6978 -0
- package/src/stories/GridSwiper.stories.tsx +1407 -0
- package/src/stories/Guide.stories.tsx +247 -0
- package/src/stories/Heading.stories.ts +89 -0
- package/src/stories/Icon.stories.ts +77 -0
- package/src/stories/IconButton.stories.tsx +301 -0
- package/src/stories/IconTextButton.stories.ts +59 -0
- package/src/stories/Image.stories.ts +55 -0
- package/src/stories/Input.stories.tsx +203 -0
- package/src/stories/Modal.stories.tsx +144 -0
- package/src/stories/NavigationBar.stories.tsx +81 -0
- package/src/stories/Notification.stories.tsx +276 -0
- package/src/stories/Popover.stories.tsx +100 -0
- package/src/stories/SearchBar.stories.ts +43 -0
- package/src/stories/SecondaryNavigationBar.stories.tsx +199 -0
- package/src/stories/Select.stories.tsx +107 -0
- package/src/stories/Separator.stories.tsx +49 -0
- package/src/stories/Spinner.stories.tsx +48 -0
- package/src/stories/SubHeading.stories.ts +64 -0
- package/src/stories/Swich.stories.tsx +69 -0
- package/src/stories/Tabs.stories.tsx +90 -0
- package/src/stories/Text.stories.ts +78 -0
- package/src/stories/Textarea.stories.tsx +155 -0
- package/src/stories/Toast.stories.tsx +424 -0
- package/src/stories/Tooltip.stories.tsx +244 -0
- package/src/stories/ViewAutoSwiper.stories.tsx +1408 -0
- package/src/styles/components-dark.scss +212 -0
- package/src/styles/components-light.scss +210 -0
- package/src/styles/design-dark.scss +330 -0
- package/src/styles/design-light.scss +345 -0
- package/src/styles/design2-dark.scss +319 -0
- package/src/styles/design2-light.scss +364 -0
- package/src/styles/font.css +19 -0
- package/src/styles/global.scss +251 -0
- package/src/styles/md-viewer.scss +155 -0
- package/src/styles/new-tokens.scss +255 -0
- package/src/styles/tokens.scss +401 -0
- package/src/types/scss.d.ts +24 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
|
|
4
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
|
|
7
|
+
import { toggleVariants } from './toggle';
|
|
8
|
+
import { cn } from '@/lib/utils';
|
|
9
|
+
|
|
10
|
+
const ToggleGroupContext = React.createContext<
|
|
11
|
+
VariantProps<typeof toggleVariants>
|
|
12
|
+
>({
|
|
13
|
+
size: 'default',
|
|
14
|
+
variant: 'default',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const ToggleGroup = React.forwardRef<
|
|
18
|
+
React.ElementRef<typeof ToggleGroupPrimitive.Root>,
|
|
19
|
+
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> &
|
|
20
|
+
VariantProps<typeof toggleVariants>
|
|
21
|
+
>(({ className, variant, size, children, ...props }, ref) => (
|
|
22
|
+
<ToggleGroupPrimitive.Root
|
|
23
|
+
ref={ref}
|
|
24
|
+
className={cn(
|
|
25
|
+
'flex items-center justify-center gap-1 p-0.5 rounded-md border border-Colors-Border-Default bg-Colors-Background-Neutral-Primary-Default',
|
|
26
|
+
className
|
|
27
|
+
)}
|
|
28
|
+
{...props}
|
|
29
|
+
>
|
|
30
|
+
<ToggleGroupContext.Provider value={{ variant, size }}>
|
|
31
|
+
{children}
|
|
32
|
+
</ToggleGroupContext.Provider>
|
|
33
|
+
</ToggleGroupPrimitive.Root>
|
|
34
|
+
));
|
|
35
|
+
|
|
36
|
+
ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
|
|
37
|
+
|
|
38
|
+
const ToggleGroupItem = React.forwardRef<
|
|
39
|
+
React.ElementRef<typeof ToggleGroupPrimitive.Item>,
|
|
40
|
+
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> &
|
|
41
|
+
VariantProps<typeof toggleVariants>
|
|
42
|
+
>(({ className, children, variant, size, ...props }, ref) => {
|
|
43
|
+
const context = React.useContext(ToggleGroupContext);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<ToggleGroupPrimitive.Item
|
|
47
|
+
ref={ref}
|
|
48
|
+
className={cn(
|
|
49
|
+
toggleVariants({
|
|
50
|
+
variant: context.variant || variant,
|
|
51
|
+
size: context.size || size,
|
|
52
|
+
}),
|
|
53
|
+
className
|
|
54
|
+
)}
|
|
55
|
+
{...props}
|
|
56
|
+
>
|
|
57
|
+
{children}
|
|
58
|
+
</ToggleGroupPrimitive.Item>
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
|
|
63
|
+
|
|
64
|
+
export { ToggleGroup, ToggleGroupItem };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as TogglePrimitive from '@radix-ui/react-toggle';
|
|
4
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
|
|
7
|
+
import { cn } from '@/lib/utils';
|
|
8
|
+
|
|
9
|
+
const toggleVariants = cva(
|
|
10
|
+
'inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-white text-Colors-Text-Subtlest hover:bg-slate-100 hover:text-slate-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-950 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-Colors-Background-Normal-Primary-Active data-[state=on]:text-Colors-Text-Brand-Default [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 gap-2 dark:ring-offset-slate-950 dark:hover:bg-slate-800 dark:hover:text-Colors-Text-Brand-Default dark:focus-visible:ring-slate-300 dark:data-[state=on]:bg-Colors-Background-Normal-Primary-Active dark:data-[state=on]:text-Colors-Text-Brand-Default',
|
|
11
|
+
{
|
|
12
|
+
variants: {
|
|
13
|
+
variant: {
|
|
14
|
+
default: 'bg-transparent',
|
|
15
|
+
outline:
|
|
16
|
+
'border border-slate-200 bg-transparent hover:bg-slate-100 hover:text-slate-900 dark:border-slate-800 dark:hover:bg-slate-800 dark:hover:text-slate-50',
|
|
17
|
+
},
|
|
18
|
+
size: {
|
|
19
|
+
default: 'h-10 px-3 min-w-10',
|
|
20
|
+
sm: 'h-9 px-2.5 min-w-9',
|
|
21
|
+
lg: 'h-11 px-5 min-w-11',
|
|
22
|
+
xs: 'h-5 min-w-8 text-xs px-3',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
defaultVariants: {
|
|
26
|
+
variant: 'default',
|
|
27
|
+
size: 'default',
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const Toggle = React.forwardRef<
|
|
33
|
+
React.ElementRef<typeof TogglePrimitive.Root>,
|
|
34
|
+
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> &
|
|
35
|
+
VariantProps<typeof toggleVariants>
|
|
36
|
+
>(({ className, variant, size, ...props }, ref) => (
|
|
37
|
+
<TogglePrimitive.Root
|
|
38
|
+
ref={ref}
|
|
39
|
+
className={cn(toggleVariants({ variant, size, className }))}
|
|
40
|
+
{...props}
|
|
41
|
+
/>
|
|
42
|
+
));
|
|
43
|
+
|
|
44
|
+
Toggle.displayName = TogglePrimitive.Root.displayName;
|
|
45
|
+
|
|
46
|
+
export { Toggle, toggleVariants };
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/* eslint-disable react/jsx-no-useless-fragment */
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
|
|
8
|
+
import { cn } from '@/lib/utils';
|
|
9
|
+
|
|
10
|
+
import { Popover } from './popover';
|
|
11
|
+
import { Description } from './typography';
|
|
12
|
+
import { useMedia } from 'react-use';
|
|
13
|
+
|
|
14
|
+
const TooltipProvider = TooltipPrimitive.Provider;
|
|
15
|
+
|
|
16
|
+
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
17
|
+
const TooltipArrow = TooltipPrimitive.Arrow;
|
|
18
|
+
|
|
19
|
+
const Tooltip = React.forwardRef<
|
|
20
|
+
React.ElementRef<typeof TooltipPrimitive.Root>,
|
|
21
|
+
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Root> & {
|
|
22
|
+
/**
|
|
23
|
+
* 文案大小
|
|
24
|
+
*/
|
|
25
|
+
size?: 'sm' | 'md';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 气泡是否打开
|
|
29
|
+
*/
|
|
30
|
+
open?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* 气泡是否默认打开
|
|
33
|
+
*/
|
|
34
|
+
defaultOpen?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* 气泡是否禁用
|
|
37
|
+
*/
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* 气泡标题
|
|
41
|
+
*/
|
|
42
|
+
title?: string;
|
|
43
|
+
/**
|
|
44
|
+
* 气泡标题是否危险
|
|
45
|
+
*/
|
|
46
|
+
titleDangerous?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* 气泡描述
|
|
49
|
+
*/
|
|
50
|
+
description?: string | React.ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* 气泡描述是否危险
|
|
53
|
+
*/
|
|
54
|
+
descriptionDangerous?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* 气泡样式类型
|
|
57
|
+
*
|
|
58
|
+
*
|
|
59
|
+
* @default 'default'
|
|
60
|
+
*/
|
|
61
|
+
variant?: 'default' | 'info' | 'message';
|
|
62
|
+
/**
|
|
63
|
+
* 气泡方向
|
|
64
|
+
*
|
|
65
|
+
* @default 'top'
|
|
66
|
+
*/
|
|
67
|
+
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
68
|
+
/**
|
|
69
|
+
* 气泡箭头位置
|
|
70
|
+
*
|
|
71
|
+
* @default 'center'
|
|
72
|
+
*/
|
|
73
|
+
align?: 'start' | 'center' | 'end';
|
|
74
|
+
/**
|
|
75
|
+
* 内容偏移量
|
|
76
|
+
*
|
|
77
|
+
* @default 6
|
|
78
|
+
*/
|
|
79
|
+
sideOffset?: number;
|
|
80
|
+
/**
|
|
81
|
+
* 箭头偏移量
|
|
82
|
+
*
|
|
83
|
+
* @default -2
|
|
84
|
+
*/
|
|
85
|
+
alignOffset?: number;
|
|
86
|
+
/**
|
|
87
|
+
* 箭头样式
|
|
88
|
+
*/
|
|
89
|
+
arrowClassName?: string;
|
|
90
|
+
/**
|
|
91
|
+
* 是否显示箭头
|
|
92
|
+
*
|
|
93
|
+
* @default true
|
|
94
|
+
*/
|
|
95
|
+
showArrow?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* 内容样式
|
|
98
|
+
*/
|
|
99
|
+
contentClassName?: string;
|
|
100
|
+
/**
|
|
101
|
+
* 触发器样式
|
|
102
|
+
*/
|
|
103
|
+
triggerClassName?: string;
|
|
104
|
+
}
|
|
105
|
+
>(
|
|
106
|
+
(
|
|
107
|
+
{
|
|
108
|
+
open,
|
|
109
|
+
defaultOpen,
|
|
110
|
+
disabled = false,
|
|
111
|
+
children,
|
|
112
|
+
title,
|
|
113
|
+
description,
|
|
114
|
+
size = 'sm',
|
|
115
|
+
titleDangerous = false,
|
|
116
|
+
descriptionDangerous = false,
|
|
117
|
+
contentClassName,
|
|
118
|
+
triggerClassName,
|
|
119
|
+
...props
|
|
120
|
+
},
|
|
121
|
+
ref
|
|
122
|
+
) => {
|
|
123
|
+
const isDesktop = !useMedia('(max-width: 768px)');
|
|
124
|
+
const defaultTitleColor =
|
|
125
|
+
props.variant === 'message'
|
|
126
|
+
? 'static'
|
|
127
|
+
: props.variant === 'default'
|
|
128
|
+
? 'warning-bolder'
|
|
129
|
+
: 'default';
|
|
130
|
+
const defaultDescColor =
|
|
131
|
+
props.variant === 'message'
|
|
132
|
+
? 'static'
|
|
133
|
+
: props.variant === 'info'
|
|
134
|
+
? 'warning-bolder'
|
|
135
|
+
: 'default';
|
|
136
|
+
|
|
137
|
+
if (disabled) {
|
|
138
|
+
return <>{children}</>;
|
|
139
|
+
}
|
|
140
|
+
return (
|
|
141
|
+
<>
|
|
142
|
+
{isDesktop ? (
|
|
143
|
+
<TooltipProvider>
|
|
144
|
+
<TooltipPrimitive.Root
|
|
145
|
+
open={disabled || (!description && !title) ? false : open}
|
|
146
|
+
defaultOpen={defaultOpen}
|
|
147
|
+
>
|
|
148
|
+
<TooltipTrigger asChild>
|
|
149
|
+
<div className={cn('cursor-pointer', triggerClassName)}>
|
|
150
|
+
{children}
|
|
151
|
+
</div>
|
|
152
|
+
</TooltipTrigger>
|
|
153
|
+
<TooltipContent ref={ref} className={contentClassName} {...props}>
|
|
154
|
+
{title && (
|
|
155
|
+
<p className="mb-1">
|
|
156
|
+
<Description
|
|
157
|
+
size="lg"
|
|
158
|
+
weight="medium"
|
|
159
|
+
color={defaultTitleColor}
|
|
160
|
+
dangerous={titleDangerous}
|
|
161
|
+
className={cn(
|
|
162
|
+
'text-wrap text-inherit',
|
|
163
|
+
size === 'md' && 'text-sm'
|
|
164
|
+
)}
|
|
165
|
+
>
|
|
166
|
+
{title}
|
|
167
|
+
</Description>
|
|
168
|
+
</p>
|
|
169
|
+
)}
|
|
170
|
+
{description && (
|
|
171
|
+
<Description
|
|
172
|
+
size="lg"
|
|
173
|
+
weight={title ? 'regular' : 'medium'}
|
|
174
|
+
color={title ? 'subtle' : defaultDescColor}
|
|
175
|
+
dangerous={descriptionDangerous}
|
|
176
|
+
className={cn(
|
|
177
|
+
'text-wrap text-inherit',
|
|
178
|
+
size === 'md' && 'text-sm'
|
|
179
|
+
)}
|
|
180
|
+
>
|
|
181
|
+
{description}
|
|
182
|
+
</Description>
|
|
183
|
+
)}
|
|
184
|
+
</TooltipContent>
|
|
185
|
+
</TooltipPrimitive.Root>
|
|
186
|
+
</TooltipProvider>
|
|
187
|
+
) : (
|
|
188
|
+
<Popover
|
|
189
|
+
open={open}
|
|
190
|
+
title={title}
|
|
191
|
+
content={description}
|
|
192
|
+
disabled={disabled}
|
|
193
|
+
triggerClassName={triggerClassName}
|
|
194
|
+
className={cn(contentClassName, size === 'md' && 'text-sm')}
|
|
195
|
+
isMTooltip
|
|
196
|
+
{...props}
|
|
197
|
+
>
|
|
198
|
+
{children}
|
|
199
|
+
</Popover>
|
|
200
|
+
)}
|
|
201
|
+
</>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
);
|
|
205
|
+
Tooltip.displayName = TooltipPrimitive.Root.displayName;
|
|
206
|
+
|
|
207
|
+
const TooltipContent = React.forwardRef<
|
|
208
|
+
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
209
|
+
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> & {
|
|
210
|
+
showArrow?: boolean;
|
|
211
|
+
variant?: 'default' | 'info' | 'message';
|
|
212
|
+
/**
|
|
213
|
+
* 气泡方向
|
|
214
|
+
*/
|
|
215
|
+
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
216
|
+
/**
|
|
217
|
+
* 气泡箭头位置
|
|
218
|
+
*
|
|
219
|
+
*/
|
|
220
|
+
align?: 'start' | 'center' | 'end';
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* 箭头样式
|
|
224
|
+
*/
|
|
225
|
+
arrowClassName?: string;
|
|
226
|
+
}
|
|
227
|
+
>(
|
|
228
|
+
(
|
|
229
|
+
{
|
|
230
|
+
className,
|
|
231
|
+
variant = 'default',
|
|
232
|
+
align = 'center',
|
|
233
|
+
side = 'top',
|
|
234
|
+
sideOffset = 6,
|
|
235
|
+
alignOffset = 0,
|
|
236
|
+
showArrow = true,
|
|
237
|
+
arrowClassName,
|
|
238
|
+
...props
|
|
239
|
+
},
|
|
240
|
+
ref
|
|
241
|
+
) => (
|
|
242
|
+
<TooltipPrimitive.Content
|
|
243
|
+
ref={ref}
|
|
244
|
+
align={align}
|
|
245
|
+
sideOffset={sideOffset}
|
|
246
|
+
alignOffset={alignOffset}
|
|
247
|
+
side={side}
|
|
248
|
+
className={cn(
|
|
249
|
+
'relative z-[49] mx-4 w-fit max-w-72 rounded-lg px-3 py-2 text-left text-xs shadow-modal-bolder',
|
|
250
|
+
'outline-none delay-0 data-[state=open]:animate-in data-[state=open]:fade-in-0 [&[data-state=open]>span]:animate-none',
|
|
251
|
+
'data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 [&[data-state=delayed-open]>span]:animate-none',
|
|
252
|
+
'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
|
|
253
|
+
'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',
|
|
254
|
+
variant === 'default'
|
|
255
|
+
? 'bg-cc-Tooltip-bg-default text-cc-Tooltip-fg-default border border-cc-Tooltip-border-default'
|
|
256
|
+
: variant === 'info'
|
|
257
|
+
? 'bg-surface-accent-yellow-subtle text-Colors-Text-Warning-Bolder'
|
|
258
|
+
: 'bg-Colors-Utility-Lake-Blue-50 text-cc-Tooltip-fg-default',
|
|
259
|
+
className
|
|
260
|
+
)}
|
|
261
|
+
{...props}
|
|
262
|
+
>
|
|
263
|
+
{props.children}
|
|
264
|
+
{showArrow && (
|
|
265
|
+
<TooltipArrow
|
|
266
|
+
width={12}
|
|
267
|
+
height={6}
|
|
268
|
+
className={cn(
|
|
269
|
+
variant === 'default'
|
|
270
|
+
? 'fill-cc-Tooltip-bg-default stroke-cc-Tooltip-border-default -ml-[0.5px]'
|
|
271
|
+
: variant === 'info'
|
|
272
|
+
? 'fill-surface-accent-yellow-subtle'
|
|
273
|
+
: 'fill-Colors-Utility-Lake-Blue-50',
|
|
274
|
+
arrowClassName
|
|
275
|
+
)}
|
|
276
|
+
/>
|
|
277
|
+
)}
|
|
278
|
+
</TooltipPrimitive.Content>
|
|
279
|
+
)
|
|
280
|
+
);
|
|
281
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
282
|
+
|
|
283
|
+
export { Tooltip, TooltipProvider };
|