myshell-react-lib 0.1.5 → 0.1.7
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/index.cjs +50 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
- package/src/common/assets/audio-playing.json +0 -3657
- package/src/common/constants/constants.ts +0 -24
- package/src/common/constants/types/common.ts +0 -10
- package/src/common/hooks/useAudioPlayer.tsx +0 -198
- package/src/common/hooks/useDevice.ts +0 -26
- package/src/common/hooks/useNativeBridge.ts +0 -42
- package/src/common/hooks/useNotification.tsx +0 -179
- package/src/common/hooks/useWindowWidth.ts +0 -19
- package/src/common/utils/common-helper.ts +0 -81
- package/src/components/ItemDemo.tsx +0 -15
- package/src/components/accordion.tsx +0 -126
- package/src/components/alert-dialog.tsx +0 -148
- package/src/components/alert.tsx +0 -65
- package/src/components/aspect-ratio.tsx +0 -7
- package/src/components/audio-player.tsx +0 -60
- package/src/components/audio-playing.tsx +0 -33
- package/src/components/avatar.tsx +0 -133
- package/src/components/badge.tsx +0 -67
- package/src/components/button/button.styles.ts +0 -258
- package/src/components/button/button.tsx +0 -215
- package/src/components/button/icon-button.styles.ts +0 -103
- package/src/components/button/icon-button.tsx +0 -100
- package/src/components/button/index.tsx +0 -3
- package/src/components/button/link-button.tsx +0 -184
- package/src/components/cascader.tsx +0 -175
- package/src/components/checkbox.tsx +0 -135
- package/src/components/command.tsx +0 -155
- package/src/components/context-menu.tsx +0 -198
- package/src/components/count-down.tsx +0 -83
- package/src/components/custom-notification.tsx +0 -95
- package/src/components/dialog.tsx +0 -158
- package/src/components/drawer.tsx +0 -116
- package/src/components/dropdown-menu.tsx +0 -196
- package/src/components/energy-progress.tsx +0 -55
- package/src/components/form.tsx +0 -201
- package/src/components/group.tsx +0 -9
- package/src/components/guide.tsx +0 -243
- package/src/components/icon.tsx +0 -96
- package/src/components/icons/index.tsx +0 -13
- package/src/components/icons/outline/ArrowLeftIcon.tsx +0 -28
- package/src/components/icons/outline/ArrowUpTrayIcon.tsx +0 -28
- package/src/components/icons/outline/CheckCircleIcon.tsx +0 -27
- package/src/components/icons/outline/ConfigIcon.tsx +0 -42
- package/src/components/icons/outline/DownIcon.tsx +0 -18
- package/src/components/icons/outline/FilterIcon.tsx +0 -20
- package/src/components/icons/outline/PencilSquareIcon.tsx +0 -28
- package/src/components/icons/outline/WindowIcon.tsx +0 -26
- package/src/components/icons/solid/CaretDownIcon.tsx +0 -22
- package/src/components/icons/solid/CodeIcon.tsx +0 -25
- package/src/components/icons/solid/DragIcon.tsx +0 -24
- package/src/components/icons/solid/PhoneIcon.tsx +0 -29
- package/src/components/icons/solid/RectangleGroupIcon.tsx +0 -26
- package/src/components/image.tsx +0 -152
- package/src/components/input.tsx +0 -118
- package/src/components/label.tsx +0 -26
- package/src/components/link.tsx +0 -123
- package/src/components/marquee/index.css +0 -15
- package/src/components/marquee/marquee.tsx +0 -220
- package/src/components/masonry.tsx +0 -138
- package/src/components/menubar.tsx +0 -234
- package/src/components/mobile/m-tooltip.tsx +0 -34
- package/src/components/modal.tsx +0 -561
- package/src/components/navigation-bar.tsx +0 -100
- package/src/components/number-input.tsx +0 -143
- package/src/components/page-content.tsx +0 -16
- package/src/components/popover.tsx +0 -191
- package/src/components/progress.tsx +0 -80
- package/src/components/radio-group.tsx +0 -44
- package/src/components/scroll-area.tsx +0 -49
- package/src/components/search-bar.tsx +0 -140
- package/src/components/secondary-navigation-bar.tsx +0 -328
- package/src/components/select.tsx +0 -273
- package/src/components/separator.tsx +0 -31
- package/src/components/sheet.tsx +0 -143
- package/src/components/skeleton.tsx +0 -20
- package/src/components/slider.tsx +0 -160
- package/src/components/spinner.tsx +0 -50
- package/src/components/swiper/index.module.scss +0 -88
- package/src/components/swiper/index.tsx +0 -319
- package/src/components/switch.tsx +0 -67
- package/src/components/tabs.tsx +0 -325
- package/src/components/textarea.tsx +0 -71
- package/src/components/toast/toast.tsx +0 -182
- package/src/components/toast/toaster.tsx +0 -160
- package/src/components/toast/use-toast.tsx +0 -248
- package/src/components/toggle-group.tsx +0 -64
- package/src/components/toggle.tsx +0 -46
- package/src/components/tooltip.tsx +0 -283
- package/src/components/typography.tsx +0 -437
- package/src/index.ts +0 -70
- package/src/lib/utils.ts +0 -62
- package/src/stories/Accordion.stories.tsx +0 -64
- package/src/stories/AccordionItem.stories.tsx +0 -48
- package/src/stories/Avatar.stories.ts +0 -58
- package/src/stories/Badge.stories.tsx +0 -40
- package/src/stories/BannerSwiper.stories.tsx +0 -102
- package/src/stories/Button.stories.tsx +0 -543
- package/src/stories/Checkbox.stories.tsx +0 -161
- package/src/stories/Configure.mdx +0 -341
- package/src/stories/CssProperties.mdx +0 -30
- package/src/stories/Description.stories.ts +0 -70
- package/src/stories/Display.stories.ts +0 -64
- package/src/stories/FeaturedSwiper.stories.tsx +0 -6978
- package/src/stories/GridSwiper.stories.tsx +0 -1407
- package/src/stories/Guide.stories.tsx +0 -247
- package/src/stories/Heading.stories.ts +0 -89
- package/src/stories/Icon.stories.ts +0 -77
- package/src/stories/IconButton.stories.tsx +0 -301
- package/src/stories/IconTextButton.stories.ts +0 -59
- package/src/stories/Image.stories.ts +0 -55
- package/src/stories/Input.stories.tsx +0 -203
- package/src/stories/Modal.stories.tsx +0 -144
- package/src/stories/NavigationBar.stories.tsx +0 -81
- package/src/stories/Notification.stories.tsx +0 -276
- package/src/stories/Popover.stories.tsx +0 -100
- package/src/stories/SearchBar.stories.ts +0 -43
- package/src/stories/SecondaryNavigationBar.stories.tsx +0 -199
- package/src/stories/Select.stories.tsx +0 -107
- package/src/stories/Separator.stories.tsx +0 -49
- package/src/stories/Spinner.stories.tsx +0 -48
- package/src/stories/SubHeading.stories.ts +0 -64
- package/src/stories/Swich.stories.tsx +0 -69
- package/src/stories/Tabs.stories.tsx +0 -90
- package/src/stories/Text.stories.ts +0 -78
- package/src/stories/Textarea.stories.tsx +0 -155
- package/src/stories/Toast.stories.tsx +0 -424
- package/src/stories/Tooltip.stories.tsx +0 -244
- package/src/stories/ViewAutoSwiper.stories.tsx +0 -1408
- package/src/styles/components-dark.scss +0 -212
- package/src/styles/components-light.scss +0 -210
- package/src/styles/design-dark.scss +0 -330
- package/src/styles/design-light.scss +0 -345
- package/src/styles/design2-dark.scss +0 -319
- package/src/styles/design2-light.scss +0 -364
- package/src/styles/font.css +0 -19
- package/src/styles/global.scss +0 -251
- package/src/styles/md-viewer.scss +0 -155
- package/src/styles/new-tokens.scss +0 -255
- package/src/styles/tokens.scss +0 -401
- package/src/types/scss.d.ts +0 -24
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react/jsx-no-useless-fragment */
|
|
2
|
-
import { ArrowLeftIcon } from '@heroicons/react/24/outline';
|
|
3
|
-
import { LucideIcon } from 'lucide-react';
|
|
4
|
-
import { useEffect, useRef, useState } from 'react';
|
|
5
|
-
import { useMedia } from 'react-use';
|
|
6
|
-
|
|
7
|
-
import { HeroIcon } from '@/common/constants/types/common';
|
|
8
|
-
import { cn } from '@/lib/utils';
|
|
9
|
-
|
|
10
|
-
import { Avatar } from './avatar';
|
|
11
|
-
import { Button } from './button';
|
|
12
|
-
import { IconButton } from './button/icon-button';
|
|
13
|
-
import { Link } from './link';
|
|
14
|
-
import { SearchBar } from './search-bar';
|
|
15
|
-
import { Separator } from './separator';
|
|
16
|
-
import { Display, Text } from './typography';
|
|
17
|
-
import FilterIcon from './icons/outline/FilterIcon';
|
|
18
|
-
|
|
19
|
-
type IIcons = {
|
|
20
|
-
icon: HeroIcon | LucideIcon | React.ElementType;
|
|
21
|
-
onClick?: () => void;
|
|
22
|
-
};
|
|
23
|
-
type IActions = {
|
|
24
|
-
label: string;
|
|
25
|
-
onClick?: () => void;
|
|
26
|
-
icon?: HeroIcon | LucideIcon | React.ElementType;
|
|
27
|
-
variant?:
|
|
28
|
-
| 'primary'
|
|
29
|
-
| 'secondary'
|
|
30
|
-
| 'tertiary'
|
|
31
|
-
| 'static'
|
|
32
|
-
| 'link'
|
|
33
|
-
| 'plain'
|
|
34
|
-
| 'solid';
|
|
35
|
-
color?: 'default' | 'brand' | 'error';
|
|
36
|
-
};
|
|
37
|
-
type ISecondaryNavigationBar = {
|
|
38
|
-
/**
|
|
39
|
-
* 是否展示背景
|
|
40
|
-
* boolean
|
|
41
|
-
*
|
|
42
|
-
* @default true
|
|
43
|
-
*/
|
|
44
|
-
hasBackground?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* 右侧自定义内容
|
|
47
|
-
* ReactNode
|
|
48
|
-
*
|
|
49
|
-
*/
|
|
50
|
-
children?: React.ReactNode;
|
|
51
|
-
/**
|
|
52
|
-
* 导航栏title
|
|
53
|
-
* string
|
|
54
|
-
*/
|
|
55
|
-
title?: string;
|
|
56
|
-
/**
|
|
57
|
-
* 是否展示搜索框
|
|
58
|
-
* boolean
|
|
59
|
-
*
|
|
60
|
-
* @default false
|
|
61
|
-
*/
|
|
62
|
-
showSearchBar?: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* 搜索框值
|
|
65
|
-
* string
|
|
66
|
-
*/
|
|
67
|
-
searchValue?: string;
|
|
68
|
-
/**
|
|
69
|
-
* 搜索框占位值
|
|
70
|
-
* string
|
|
71
|
-
*/
|
|
72
|
-
searchPlaceholder?: string;
|
|
73
|
-
/**
|
|
74
|
-
* 是否显示底部border
|
|
75
|
-
* boolean
|
|
76
|
-
*/
|
|
77
|
-
border?: boolean;
|
|
78
|
-
/**
|
|
79
|
-
* 返回链接,有配置则显示返回icon
|
|
80
|
-
* string
|
|
81
|
-
*/
|
|
82
|
-
backUrl?: string;
|
|
83
|
-
/**
|
|
84
|
-
* 是否展示清除按钮
|
|
85
|
-
* boolean
|
|
86
|
-
*
|
|
87
|
-
* @default false
|
|
88
|
-
*/
|
|
89
|
-
showClear?: boolean;
|
|
90
|
-
/**
|
|
91
|
-
* 清除按钮文本
|
|
92
|
-
* string
|
|
93
|
-
*/
|
|
94
|
-
clearText?: string;
|
|
95
|
-
/**
|
|
96
|
-
* icon按钮配置
|
|
97
|
-
* IIcons
|
|
98
|
-
*/
|
|
99
|
-
icons?: IIcons[];
|
|
100
|
-
/**
|
|
101
|
-
* 操作按钮配置
|
|
102
|
-
* IActions
|
|
103
|
-
*/
|
|
104
|
-
actions?: IActions[];
|
|
105
|
-
/**
|
|
106
|
-
* 头像配置
|
|
107
|
-
* {
|
|
108
|
-
* logo: string;
|
|
109
|
-
* name?: string;
|
|
110
|
-
* }
|
|
111
|
-
*/
|
|
112
|
-
avatar?: {
|
|
113
|
-
logo: string;
|
|
114
|
-
name?: string;
|
|
115
|
-
};
|
|
116
|
-
onSearchChange?: (value: string) => void;
|
|
117
|
-
onClear?: () => void;
|
|
118
|
-
onBack?: () => void;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
function SecondaryNavigationBar({
|
|
122
|
-
showSearchBar = true,
|
|
123
|
-
searchValue,
|
|
124
|
-
searchPlaceholder,
|
|
125
|
-
title,
|
|
126
|
-
border,
|
|
127
|
-
backUrl,
|
|
128
|
-
showClear,
|
|
129
|
-
clearText,
|
|
130
|
-
icons,
|
|
131
|
-
actions,
|
|
132
|
-
children,
|
|
133
|
-
hasBackground = true,
|
|
134
|
-
avatar,
|
|
135
|
-
onSearchChange,
|
|
136
|
-
onClear,
|
|
137
|
-
onBack,
|
|
138
|
-
}: ISecondaryNavigationBar) {
|
|
139
|
-
const isMobile = useMedia('(max-width: 768px)');
|
|
140
|
-
const navbarRef = useRef<HTMLDivElement>(null);
|
|
141
|
-
const [showBackground, setShowBackground] = useState(hasBackground);
|
|
142
|
-
|
|
143
|
-
useEffect(() => {
|
|
144
|
-
if (hasBackground) {
|
|
145
|
-
setShowBackground(true);
|
|
146
|
-
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const handleScroll = () => {
|
|
151
|
-
if (navbarRef.current) {
|
|
152
|
-
const { height } = navbarRef.current.getBoundingClientRect();
|
|
153
|
-
setShowBackground(window.scrollY > height);
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
window.addEventListener('scroll', handleScroll);
|
|
158
|
-
|
|
159
|
-
return () => window.removeEventListener('scroll', handleScroll);
|
|
160
|
-
}, [hasBackground]);
|
|
161
|
-
|
|
162
|
-
return (
|
|
163
|
-
<div
|
|
164
|
-
ref={navbarRef}
|
|
165
|
-
className={cn(
|
|
166
|
-
'w-full flex flex-col md:flex-row justify-center items-center px-4 md:px-6',
|
|
167
|
-
!isMobile && border && 'border-b border-default',
|
|
168
|
-
showBackground && 'bg-Colors-Background-Normal-Primary-Default'
|
|
169
|
-
)}
|
|
170
|
-
>
|
|
171
|
-
<div
|
|
172
|
-
className={cn(
|
|
173
|
-
'relative w-full flex justify-between items-center h-14 md:h-15'
|
|
174
|
-
)}
|
|
175
|
-
>
|
|
176
|
-
<div
|
|
177
|
-
className={cn('flex items-center', avatar?.logo && 'min-w-[76px]')}
|
|
178
|
-
>
|
|
179
|
-
{(backUrl || onBack) && (
|
|
180
|
-
<div className="flex justify-start items-center">
|
|
181
|
-
{backUrl ? (
|
|
182
|
-
<Link
|
|
183
|
-
href={backUrl}
|
|
184
|
-
className="flex justify-center items-center"
|
|
185
|
-
>
|
|
186
|
-
<IconButton
|
|
187
|
-
variant={!hasBackground ? 'primary' : 'plain'}
|
|
188
|
-
color={!hasBackground ? 'gray' : 'brand'}
|
|
189
|
-
size="md"
|
|
190
|
-
icon={ArrowLeftIcon}
|
|
191
|
-
/>
|
|
192
|
-
</Link>
|
|
193
|
-
) : (
|
|
194
|
-
<IconButton
|
|
195
|
-
variant={!hasBackground ? 'primary' : 'plain'}
|
|
196
|
-
color={!hasBackground ? 'gray' : 'brand'}
|
|
197
|
-
size="md"
|
|
198
|
-
icon={ArrowLeftIcon}
|
|
199
|
-
onClick={onBack}
|
|
200
|
-
/>
|
|
201
|
-
)}
|
|
202
|
-
|
|
203
|
-
{!isMobile && title && (
|
|
204
|
-
<Separator orientation="vertical" className="h-5 ml-1.5 mr-3" />
|
|
205
|
-
)}
|
|
206
|
-
</div>
|
|
207
|
-
)}
|
|
208
|
-
|
|
209
|
-
{title &&
|
|
210
|
-
(!showSearchBar || !isMobile) &&
|
|
211
|
-
(!avatar?.logo || !isMobile) && (
|
|
212
|
-
<div className="flex-1 flex-shrink-0 absolute w-full md:relative md:w-auto flex items-center justify-center md:justify-start">
|
|
213
|
-
<Display
|
|
214
|
-
size={isMobile ? 'xs' : 'sm'}
|
|
215
|
-
className={cn(
|
|
216
|
-
'max-w-[calc(100%-168px)] md:max-w-fit flex-1 flex-shrink-0 absolute w-full md:relative md:w-auto text-center md:text-left line-clamp-1'
|
|
217
|
-
)}
|
|
218
|
-
>
|
|
219
|
-
{title}
|
|
220
|
-
</Display>
|
|
221
|
-
</div>
|
|
222
|
-
)}
|
|
223
|
-
</div>
|
|
224
|
-
|
|
225
|
-
{avatar?.logo && !showSearchBar && (
|
|
226
|
-
<div className="flex-shrink-0 flex relative px-3 justify-center items-center space-x-1.5">
|
|
227
|
-
<Avatar size="sm" src={avatar.logo} />
|
|
228
|
-
{avatar.name && !isMobile && (
|
|
229
|
-
<Text size="lg" weight="medium">
|
|
230
|
-
{avatar.name}
|
|
231
|
-
</Text>
|
|
232
|
-
)}
|
|
233
|
-
</div>
|
|
234
|
-
)}
|
|
235
|
-
|
|
236
|
-
<div
|
|
237
|
-
className={cn(
|
|
238
|
-
'w-fit flex md:w-auto justify-end',
|
|
239
|
-
!avatar?.logo && 'flex-1'
|
|
240
|
-
)}
|
|
241
|
-
>
|
|
242
|
-
{children ? (
|
|
243
|
-
<div className="w-fit">{children}</div>
|
|
244
|
-
) : (
|
|
245
|
-
<>
|
|
246
|
-
{icons || actions ? (
|
|
247
|
-
<div
|
|
248
|
-
className={cn(
|
|
249
|
-
'flex justify-end items-center',
|
|
250
|
-
icons && 'space-x-1 min-w-[76px]',
|
|
251
|
-
actions && 'space-x-3'
|
|
252
|
-
)}
|
|
253
|
-
>
|
|
254
|
-
{icons &&
|
|
255
|
-
icons.map((icon, index) => (
|
|
256
|
-
<IconButton
|
|
257
|
-
key={index}
|
|
258
|
-
variant={!hasBackground ? 'tertiary' : 'plain'}
|
|
259
|
-
color={!hasBackground ? 'default' : 'brand'}
|
|
260
|
-
size="md"
|
|
261
|
-
icon={icon.icon}
|
|
262
|
-
onClick={icon.onClick}
|
|
263
|
-
/>
|
|
264
|
-
))}
|
|
265
|
-
{actions &&
|
|
266
|
-
actions.map((action, index) => (
|
|
267
|
-
<Button key={index} size="md" {...action}>
|
|
268
|
-
{action.label}
|
|
269
|
-
</Button>
|
|
270
|
-
))}
|
|
271
|
-
</div>
|
|
272
|
-
) : (
|
|
273
|
-
<>
|
|
274
|
-
{showClear && !isMobile && (
|
|
275
|
-
<Button
|
|
276
|
-
aria-label={clearText || 'Clear Filters'}
|
|
277
|
-
size="md"
|
|
278
|
-
variant="secondary"
|
|
279
|
-
color="default"
|
|
280
|
-
className="hidden md:flex relative text-sm font-medium ml-2 mr-3 px-4 justify-center items-center"
|
|
281
|
-
onClick={onClear}
|
|
282
|
-
>
|
|
283
|
-
<div className="relative mr-1.5">
|
|
284
|
-
<FilterIcon className="w-5 h-5 fill-cc-Button-Secondary-fg-default" />
|
|
285
|
-
</div>
|
|
286
|
-
<span className="hidden md:block">
|
|
287
|
-
{clearText || 'Clear Filters'}
|
|
288
|
-
</span>
|
|
289
|
-
</Button>
|
|
290
|
-
)}
|
|
291
|
-
{showSearchBar && (
|
|
292
|
-
<div className="relative w-full md:w-60">
|
|
293
|
-
<SearchBar
|
|
294
|
-
color="gray"
|
|
295
|
-
size="xs"
|
|
296
|
-
searchValue={searchValue}
|
|
297
|
-
placeholder={searchPlaceholder || 'Search'}
|
|
298
|
-
onSearchChange={(value) => {
|
|
299
|
-
onSearchChange && onSearchChange(value);
|
|
300
|
-
}}
|
|
301
|
-
/>
|
|
302
|
-
</div>
|
|
303
|
-
)}
|
|
304
|
-
{showClear && isMobile && (
|
|
305
|
-
<IconButton
|
|
306
|
-
className="flex-shrink-0 flex relative text-sm font-medium px-4 justify-center items-center ml-3"
|
|
307
|
-
aria-label={clearText || 'Clear Filters'}
|
|
308
|
-
size="md"
|
|
309
|
-
variant="primary"
|
|
310
|
-
color="default"
|
|
311
|
-
onClick={onClear}
|
|
312
|
-
>
|
|
313
|
-
<div className="relative">
|
|
314
|
-
<FilterIcon />
|
|
315
|
-
</div>
|
|
316
|
-
</IconButton>
|
|
317
|
-
)}
|
|
318
|
-
</>
|
|
319
|
-
)}
|
|
320
|
-
</>
|
|
321
|
-
)}
|
|
322
|
-
</div>
|
|
323
|
-
</div>
|
|
324
|
-
</div>
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
export { SecondaryNavigationBar };
|
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
2
|
-
/* eslint-disable react/display-name */
|
|
3
|
-
|
|
4
|
-
'use client';
|
|
5
|
-
|
|
6
|
-
import { CheckIcon } from '@heroicons/react/24/outline';
|
|
7
|
-
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
8
|
-
import { ChevronDown, ChevronUp } from 'lucide-react';
|
|
9
|
-
import * as React from 'react';
|
|
10
|
-
|
|
11
|
-
import { cn } from '@/lib/utils';
|
|
12
|
-
|
|
13
|
-
export interface ISelectProps extends SelectPrimitive.SelectProps {
|
|
14
|
-
options?: Array<{
|
|
15
|
-
value: string;
|
|
16
|
-
label: string;
|
|
17
|
-
icon?: React.ReactNode | React.ElementType | string;
|
|
18
|
-
disabled?: boolean;
|
|
19
|
-
critical?: boolean;
|
|
20
|
-
}>;
|
|
21
|
-
placeholder?: React.ReactNode;
|
|
22
|
-
triggerClassName?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const Select = React.forwardRef<
|
|
26
|
-
React.ElementRef<typeof SelectPrimitive.Root>,
|
|
27
|
-
ISelectProps
|
|
28
|
-
>(({ children, placeholder, options, triggerClassName, ...props }, ref) => {
|
|
29
|
-
// 获取选中选项的图标
|
|
30
|
-
const icon = options?.find((item) => item.value === props.value)?.icon;
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<SelectPrimitive.Root {...props}>
|
|
34
|
-
{Array.isArray(options) && options.length ? (
|
|
35
|
-
<>
|
|
36
|
-
<SelectTrigger className={cn(triggerClassName)}>
|
|
37
|
-
<div className="flex items-center">
|
|
38
|
-
<SelectIcon icon={icon} />
|
|
39
|
-
<SelectValue placeholder={placeholder} />
|
|
40
|
-
</div>
|
|
41
|
-
</SelectTrigger>
|
|
42
|
-
<SelectContent>
|
|
43
|
-
{options.map((item, i) => (
|
|
44
|
-
<SelectItem key={`${item.value}_${i}`} {...item}>
|
|
45
|
-
{item.label}
|
|
46
|
-
</SelectItem>
|
|
47
|
-
))}
|
|
48
|
-
</SelectContent>
|
|
49
|
-
</>
|
|
50
|
-
) : (
|
|
51
|
-
children
|
|
52
|
-
)}
|
|
53
|
-
</SelectPrimitive.Root>
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const SelectGroup = SelectPrimitive.Group;
|
|
58
|
-
|
|
59
|
-
const SelectValue = SelectPrimitive.Value;
|
|
60
|
-
|
|
61
|
-
const SelectTrigger = React.forwardRef<
|
|
62
|
-
React.ElementRef<typeof SelectPrimitive.Trigger>,
|
|
63
|
-
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
|
|
64
|
-
>(({ className, children, ...props }, ref) => (
|
|
65
|
-
<SelectPrimitive.Trigger
|
|
66
|
-
ref={ref}
|
|
67
|
-
className={cn(
|
|
68
|
-
'flex h-10 w-full items-center justify-between rounded-md border border-Colors-Border-Default bg-Colors-Background-Neutral-On-Surface-Default text-Colors-Text-Default text-sm p-3 ring-offset-cc-Focus-Rings-Brand-default focus:shadow-cc-Focus-Rings-Brand-default placeholder:text-Colors-Text-Subtlest focus:outline-none focus:ring-0 focus:ring-offset-0 disabled:cursor-not-allowed disabled:opacity-30 [&>span]:line-clamp-1 [&>.select-chevron]:aria-expanded:rotate-180',
|
|
69
|
-
className
|
|
70
|
-
)}
|
|
71
|
-
{...props}
|
|
72
|
-
>
|
|
73
|
-
{children}
|
|
74
|
-
<SelectPrimitive.Icon asChild>
|
|
75
|
-
<ChevronDown className="select-chevron h-5 w-5 text-Colors-Foreground-Subtle duration-200" />
|
|
76
|
-
</SelectPrimitive.Icon>
|
|
77
|
-
</SelectPrimitive.Trigger>
|
|
78
|
-
));
|
|
79
|
-
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
80
|
-
|
|
81
|
-
const SelectScrollUpButton = React.forwardRef<
|
|
82
|
-
React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
|
|
83
|
-
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
|
|
84
|
-
>(({ className, ...props }, ref) => (
|
|
85
|
-
<SelectPrimitive.ScrollUpButton
|
|
86
|
-
ref={ref}
|
|
87
|
-
className={cn(
|
|
88
|
-
'flex cursor-default items-center justify-center py-1',
|
|
89
|
-
className
|
|
90
|
-
)}
|
|
91
|
-
{...props}
|
|
92
|
-
>
|
|
93
|
-
<ChevronUp className="h-4 w-4" />
|
|
94
|
-
</SelectPrimitive.ScrollUpButton>
|
|
95
|
-
));
|
|
96
|
-
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
97
|
-
|
|
98
|
-
const SelectScrollDownButton = React.forwardRef<
|
|
99
|
-
React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
|
|
100
|
-
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
|
|
101
|
-
>(({ className, ...props }, ref) => (
|
|
102
|
-
<SelectPrimitive.ScrollDownButton
|
|
103
|
-
ref={ref}
|
|
104
|
-
className={cn(
|
|
105
|
-
'flex cursor-default items-center justify-center py-1',
|
|
106
|
-
className
|
|
107
|
-
)}
|
|
108
|
-
{...props}
|
|
109
|
-
>
|
|
110
|
-
<ChevronDown className="h-4 w-4" />
|
|
111
|
-
</SelectPrimitive.ScrollDownButton>
|
|
112
|
-
));
|
|
113
|
-
SelectScrollDownButton.displayName =
|
|
114
|
-
SelectPrimitive.ScrollDownButton.displayName;
|
|
115
|
-
|
|
116
|
-
const SelectContent = React.forwardRef<
|
|
117
|
-
React.ElementRef<typeof SelectPrimitive.Content>,
|
|
118
|
-
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
|
119
|
-
>(({ className, children, position = 'popper', ...props }, ref) => (
|
|
120
|
-
<SelectPrimitive.Portal>
|
|
121
|
-
<SelectPrimitive.Content
|
|
122
|
-
ref={ref}
|
|
123
|
-
className={cn(
|
|
124
|
-
'relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-opaque bg-Colors-Background-Normal-Primary-Default text-Colors-Text-Default shadow-cc-Shadows-Modal-default data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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',
|
|
125
|
-
position === 'popper' &&
|
|
126
|
-
'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
|
|
127
|
-
className
|
|
128
|
-
)}
|
|
129
|
-
position={position}
|
|
130
|
-
{...props}
|
|
131
|
-
>
|
|
132
|
-
<SelectPrimitive.Viewport
|
|
133
|
-
className={cn(
|
|
134
|
-
'p-1.5 space-y-1.5',
|
|
135
|
-
position === 'popper' &&
|
|
136
|
-
'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]'
|
|
137
|
-
)}
|
|
138
|
-
>
|
|
139
|
-
{children}
|
|
140
|
-
</SelectPrimitive.Viewport>
|
|
141
|
-
</SelectPrimitive.Content>
|
|
142
|
-
</SelectPrimitive.Portal>
|
|
143
|
-
));
|
|
144
|
-
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
145
|
-
|
|
146
|
-
const SelectLabel = React.forwardRef<
|
|
147
|
-
React.ElementRef<typeof SelectPrimitive.Label>,
|
|
148
|
-
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
|
|
149
|
-
>(({ className, ...props }, ref) => (
|
|
150
|
-
<SelectPrimitive.Label
|
|
151
|
-
ref={ref}
|
|
152
|
-
className={cn(
|
|
153
|
-
'py-1 px-3 text-sm font-medium text-Colors-Text-Subtler',
|
|
154
|
-
className
|
|
155
|
-
)}
|
|
156
|
-
{...props}
|
|
157
|
-
/>
|
|
158
|
-
));
|
|
159
|
-
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
160
|
-
|
|
161
|
-
interface ISelectIconProps {
|
|
162
|
-
icon?: React.ReactNode | React.ElementType | string;
|
|
163
|
-
critical?: boolean;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function SelectIcon(props: ISelectIconProps) {
|
|
167
|
-
const { icon, critical } = props;
|
|
168
|
-
|
|
169
|
-
if (!icon) {
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return (
|
|
174
|
-
<SelectPrimitive.Icon>
|
|
175
|
-
{typeof icon === 'string' ? (
|
|
176
|
-
// 如果是字符串URL,作为背景图片显示
|
|
177
|
-
<div
|
|
178
|
-
className={cn(
|
|
179
|
-
'aspect-[20/20] w-5 h-5 relative bg-cover bg-no-repeat rounded-md overflow-hidden mr-1.5',
|
|
180
|
-
critical && 'text-Colors-Text-Critical-Default'
|
|
181
|
-
)}
|
|
182
|
-
style={{ backgroundImage: `url('${icon}')` }}
|
|
183
|
-
/>
|
|
184
|
-
) : React.isValidElement(icon) ? (
|
|
185
|
-
// 如果是React元素,直接渲染
|
|
186
|
-
<div
|
|
187
|
-
className={cn(
|
|
188
|
-
'mr-1.5 w-5 h-5 text-Colors-Foreground-Default',
|
|
189
|
-
critical && 'text-Colors-Foreground-Critical-Default'
|
|
190
|
-
)}
|
|
191
|
-
>
|
|
192
|
-
{icon}
|
|
193
|
-
</div>
|
|
194
|
-
) : (
|
|
195
|
-
// 如果是组件类型,创建元素
|
|
196
|
-
<div
|
|
197
|
-
className={cn(
|
|
198
|
-
'mr-1.5 w-5 h-5 text-Colors-Foreground-Default',
|
|
199
|
-
critical && 'text-Colors-Foreground-Critical-Default'
|
|
200
|
-
)}
|
|
201
|
-
>
|
|
202
|
-
{React.createElement(icon as React.ElementType, {
|
|
203
|
-
className: cn(
|
|
204
|
-
'w-5 h-5 text-Colors-Foreground-Default',
|
|
205
|
-
critical && 'text-Colors-Foreground-Critical-Default'
|
|
206
|
-
),
|
|
207
|
-
})}
|
|
208
|
-
</div>
|
|
209
|
-
)}
|
|
210
|
-
</SelectPrimitive.Icon>
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
SelectIcon.displayName = SelectPrimitive.Icon.displayName;
|
|
215
|
-
|
|
216
|
-
interface ISelectItemProps
|
|
217
|
-
extends SelectPrimitive.SelectItemProps,
|
|
218
|
-
ISelectIconProps {}
|
|
219
|
-
|
|
220
|
-
const SelectItem = React.forwardRef<
|
|
221
|
-
React.ElementRef<typeof SelectPrimitive.Item>,
|
|
222
|
-
ISelectItemProps
|
|
223
|
-
>(({ className, children, icon, critical, ...props }, ref) => (
|
|
224
|
-
<SelectPrimitive.Item
|
|
225
|
-
ref={ref}
|
|
226
|
-
className={cn(
|
|
227
|
-
'relative flex justify-between w-full text-sm cursor-pointer select-none items-center rounded-md py-1 px-1.5 outline-none',
|
|
228
|
-
'bg-Colors-Background-Normal-Secondary-Alt hover:bg-Colors-Background-Normal-Primary-Hover focus:bg-Colors-Background-Neutral-Primary-Default data-[disabled]:opacity-30 data-[disabled]:cursor-not-allowed',
|
|
229
|
-
critical
|
|
230
|
-
? 'text-Colors-Text-Critical-Default'
|
|
231
|
-
: 'focus:text-Colors-Text-Default',
|
|
232
|
-
className
|
|
233
|
-
)}
|
|
234
|
-
{...props}
|
|
235
|
-
>
|
|
236
|
-
<span className="flex items-center grow">
|
|
237
|
-
<SelectIcon icon={icon} critical={critical} />
|
|
238
|
-
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
239
|
-
</span>
|
|
240
|
-
<span className="flex h-4 w-4 items-center justify-center">
|
|
241
|
-
<SelectPrimitive.ItemIndicator>
|
|
242
|
-
<CheckIcon className="h-4 w-4 text-Colors-Foreground-Subtle stroke-[2px]" />
|
|
243
|
-
</SelectPrimitive.ItemIndicator>
|
|
244
|
-
</span>
|
|
245
|
-
</SelectPrimitive.Item>
|
|
246
|
-
));
|
|
247
|
-
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
248
|
-
|
|
249
|
-
const SelectSeparator = React.forwardRef<
|
|
250
|
-
React.ElementRef<typeof SelectPrimitive.Separator>,
|
|
251
|
-
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
|
|
252
|
-
>(({ className, ...props }, ref) => (
|
|
253
|
-
<SelectPrimitive.Separator
|
|
254
|
-
ref={ref}
|
|
255
|
-
className={cn('-mx-1 my-1 h-px bg-border-default', className)}
|
|
256
|
-
{...props}
|
|
257
|
-
/>
|
|
258
|
-
));
|
|
259
|
-
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
260
|
-
|
|
261
|
-
export {
|
|
262
|
-
Select,
|
|
263
|
-
SelectGroup,
|
|
264
|
-
SelectIcon,
|
|
265
|
-
SelectValue,
|
|
266
|
-
SelectTrigger,
|
|
267
|
-
SelectContent,
|
|
268
|
-
SelectLabel,
|
|
269
|
-
SelectItem,
|
|
270
|
-
SelectSeparator,
|
|
271
|
-
SelectScrollUpButton,
|
|
272
|
-
SelectScrollDownButton,
|
|
273
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
|
|
6
|
-
import { cn } from '@/lib/utils';
|
|
7
|
-
|
|
8
|
-
const Separator = React.forwardRef<
|
|
9
|
-
React.ElementRef<typeof SeparatorPrimitive.Root>,
|
|
10
|
-
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
|
|
11
|
-
>(
|
|
12
|
-
(
|
|
13
|
-
{ className, orientation = 'horizontal', decorative = true, ...props },
|
|
14
|
-
ref
|
|
15
|
-
) => (
|
|
16
|
-
<SeparatorPrimitive.Root
|
|
17
|
-
ref={ref}
|
|
18
|
-
decorative={decorative}
|
|
19
|
-
orientation={orientation}
|
|
20
|
-
className={cn(
|
|
21
|
-
'shrink-0 border-Colors-Alpha-Black-8',
|
|
22
|
-
orientation === 'horizontal' ? 'w-full border-b' : 'h-full border-r',
|
|
23
|
-
className
|
|
24
|
-
)}
|
|
25
|
-
{...props}
|
|
26
|
-
/>
|
|
27
|
-
)
|
|
28
|
-
);
|
|
29
|
-
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
|
30
|
-
|
|
31
|
-
export { Separator };
|