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.
Files changed (147) hide show
  1. package/dist/index.cjs +50 -2
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +1 -2
  4. package/dist/index.d.ts +1 -2
  5. package/dist/index.js +6 -1
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -2
  8. package/src/common/assets/audio-playing.json +0 -3657
  9. package/src/common/constants/constants.ts +0 -24
  10. package/src/common/constants/types/common.ts +0 -10
  11. package/src/common/hooks/useAudioPlayer.tsx +0 -198
  12. package/src/common/hooks/useDevice.ts +0 -26
  13. package/src/common/hooks/useNativeBridge.ts +0 -42
  14. package/src/common/hooks/useNotification.tsx +0 -179
  15. package/src/common/hooks/useWindowWidth.ts +0 -19
  16. package/src/common/utils/common-helper.ts +0 -81
  17. package/src/components/ItemDemo.tsx +0 -15
  18. package/src/components/accordion.tsx +0 -126
  19. package/src/components/alert-dialog.tsx +0 -148
  20. package/src/components/alert.tsx +0 -65
  21. package/src/components/aspect-ratio.tsx +0 -7
  22. package/src/components/audio-player.tsx +0 -60
  23. package/src/components/audio-playing.tsx +0 -33
  24. package/src/components/avatar.tsx +0 -133
  25. package/src/components/badge.tsx +0 -67
  26. package/src/components/button/button.styles.ts +0 -258
  27. package/src/components/button/button.tsx +0 -215
  28. package/src/components/button/icon-button.styles.ts +0 -103
  29. package/src/components/button/icon-button.tsx +0 -100
  30. package/src/components/button/index.tsx +0 -3
  31. package/src/components/button/link-button.tsx +0 -184
  32. package/src/components/cascader.tsx +0 -175
  33. package/src/components/checkbox.tsx +0 -135
  34. package/src/components/command.tsx +0 -155
  35. package/src/components/context-menu.tsx +0 -198
  36. package/src/components/count-down.tsx +0 -83
  37. package/src/components/custom-notification.tsx +0 -95
  38. package/src/components/dialog.tsx +0 -158
  39. package/src/components/drawer.tsx +0 -116
  40. package/src/components/dropdown-menu.tsx +0 -196
  41. package/src/components/energy-progress.tsx +0 -55
  42. package/src/components/form.tsx +0 -201
  43. package/src/components/group.tsx +0 -9
  44. package/src/components/guide.tsx +0 -243
  45. package/src/components/icon.tsx +0 -96
  46. package/src/components/icons/index.tsx +0 -13
  47. package/src/components/icons/outline/ArrowLeftIcon.tsx +0 -28
  48. package/src/components/icons/outline/ArrowUpTrayIcon.tsx +0 -28
  49. package/src/components/icons/outline/CheckCircleIcon.tsx +0 -27
  50. package/src/components/icons/outline/ConfigIcon.tsx +0 -42
  51. package/src/components/icons/outline/DownIcon.tsx +0 -18
  52. package/src/components/icons/outline/FilterIcon.tsx +0 -20
  53. package/src/components/icons/outline/PencilSquareIcon.tsx +0 -28
  54. package/src/components/icons/outline/WindowIcon.tsx +0 -26
  55. package/src/components/icons/solid/CaretDownIcon.tsx +0 -22
  56. package/src/components/icons/solid/CodeIcon.tsx +0 -25
  57. package/src/components/icons/solid/DragIcon.tsx +0 -24
  58. package/src/components/icons/solid/PhoneIcon.tsx +0 -29
  59. package/src/components/icons/solid/RectangleGroupIcon.tsx +0 -26
  60. package/src/components/image.tsx +0 -152
  61. package/src/components/input.tsx +0 -118
  62. package/src/components/label.tsx +0 -26
  63. package/src/components/link.tsx +0 -123
  64. package/src/components/marquee/index.css +0 -15
  65. package/src/components/marquee/marquee.tsx +0 -220
  66. package/src/components/masonry.tsx +0 -138
  67. package/src/components/menubar.tsx +0 -234
  68. package/src/components/mobile/m-tooltip.tsx +0 -34
  69. package/src/components/modal.tsx +0 -561
  70. package/src/components/navigation-bar.tsx +0 -100
  71. package/src/components/number-input.tsx +0 -143
  72. package/src/components/page-content.tsx +0 -16
  73. package/src/components/popover.tsx +0 -191
  74. package/src/components/progress.tsx +0 -80
  75. package/src/components/radio-group.tsx +0 -44
  76. package/src/components/scroll-area.tsx +0 -49
  77. package/src/components/search-bar.tsx +0 -140
  78. package/src/components/secondary-navigation-bar.tsx +0 -328
  79. package/src/components/select.tsx +0 -273
  80. package/src/components/separator.tsx +0 -31
  81. package/src/components/sheet.tsx +0 -143
  82. package/src/components/skeleton.tsx +0 -20
  83. package/src/components/slider.tsx +0 -160
  84. package/src/components/spinner.tsx +0 -50
  85. package/src/components/swiper/index.module.scss +0 -88
  86. package/src/components/swiper/index.tsx +0 -319
  87. package/src/components/switch.tsx +0 -67
  88. package/src/components/tabs.tsx +0 -325
  89. package/src/components/textarea.tsx +0 -71
  90. package/src/components/toast/toast.tsx +0 -182
  91. package/src/components/toast/toaster.tsx +0 -160
  92. package/src/components/toast/use-toast.tsx +0 -248
  93. package/src/components/toggle-group.tsx +0 -64
  94. package/src/components/toggle.tsx +0 -46
  95. package/src/components/tooltip.tsx +0 -283
  96. package/src/components/typography.tsx +0 -437
  97. package/src/index.ts +0 -70
  98. package/src/lib/utils.ts +0 -62
  99. package/src/stories/Accordion.stories.tsx +0 -64
  100. package/src/stories/AccordionItem.stories.tsx +0 -48
  101. package/src/stories/Avatar.stories.ts +0 -58
  102. package/src/stories/Badge.stories.tsx +0 -40
  103. package/src/stories/BannerSwiper.stories.tsx +0 -102
  104. package/src/stories/Button.stories.tsx +0 -543
  105. package/src/stories/Checkbox.stories.tsx +0 -161
  106. package/src/stories/Configure.mdx +0 -341
  107. package/src/stories/CssProperties.mdx +0 -30
  108. package/src/stories/Description.stories.ts +0 -70
  109. package/src/stories/Display.stories.ts +0 -64
  110. package/src/stories/FeaturedSwiper.stories.tsx +0 -6978
  111. package/src/stories/GridSwiper.stories.tsx +0 -1407
  112. package/src/stories/Guide.stories.tsx +0 -247
  113. package/src/stories/Heading.stories.ts +0 -89
  114. package/src/stories/Icon.stories.ts +0 -77
  115. package/src/stories/IconButton.stories.tsx +0 -301
  116. package/src/stories/IconTextButton.stories.ts +0 -59
  117. package/src/stories/Image.stories.ts +0 -55
  118. package/src/stories/Input.stories.tsx +0 -203
  119. package/src/stories/Modal.stories.tsx +0 -144
  120. package/src/stories/NavigationBar.stories.tsx +0 -81
  121. package/src/stories/Notification.stories.tsx +0 -276
  122. package/src/stories/Popover.stories.tsx +0 -100
  123. package/src/stories/SearchBar.stories.ts +0 -43
  124. package/src/stories/SecondaryNavigationBar.stories.tsx +0 -199
  125. package/src/stories/Select.stories.tsx +0 -107
  126. package/src/stories/Separator.stories.tsx +0 -49
  127. package/src/stories/Spinner.stories.tsx +0 -48
  128. package/src/stories/SubHeading.stories.ts +0 -64
  129. package/src/stories/Swich.stories.tsx +0 -69
  130. package/src/stories/Tabs.stories.tsx +0 -90
  131. package/src/stories/Text.stories.ts +0 -78
  132. package/src/stories/Textarea.stories.tsx +0 -155
  133. package/src/stories/Toast.stories.tsx +0 -424
  134. package/src/stories/Tooltip.stories.tsx +0 -244
  135. package/src/stories/ViewAutoSwiper.stories.tsx +0 -1408
  136. package/src/styles/components-dark.scss +0 -212
  137. package/src/styles/components-light.scss +0 -210
  138. package/src/styles/design-dark.scss +0 -330
  139. package/src/styles/design-light.scss +0 -345
  140. package/src/styles/design2-dark.scss +0 -319
  141. package/src/styles/design2-light.scss +0 -364
  142. package/src/styles/font.css +0 -19
  143. package/src/styles/global.scss +0 -251
  144. package/src/styles/md-viewer.scss +0 -155
  145. package/src/styles/new-tokens.scss +0 -255
  146. package/src/styles/tokens.scss +0 -401
  147. package/src/types/scss.d.ts +0 -24
@@ -1,561 +0,0 @@
1
- /* eslint-disable no-nested-ternary */
2
-
3
- 'use client';
4
-
5
- import CheckCircleIcon from '@heroicons/react/24/outline/esm/CheckCircleIcon';
6
- import ExclamationTriangleIcon from '@heroicons/react/24/outline/esm/ExclamationTriangleIcon';
7
- import InformationCircleIcon from '@heroicons/react/24/outline/esm/InformationCircleIcon';
8
- import XCircleIcon from '@heroicons/react/24/outline/esm/XCircleIcon';
9
- import XMarkIcon from '@heroicons/react/24/outline/esm/XMarkIcon';
10
- import * as DialogPrimitive from '@radix-ui/react-dialog';
11
- import { FocusScope, FocusScopeProps } from '@radix-ui/react-focus-scope';
12
- import { cva, type VariantProps } from 'class-variance-authority';
13
- import * as React from 'react';
14
- import { Drawer as DrawerPrimitive } from 'vaul';
15
-
16
- import { cn } from '@/lib/utils';
17
-
18
- import { Button } from './button/button';
19
- import { IconButton } from './button/icon-button';
20
- import { Display, Text } from './typography';
21
- import { useMedia } from 'react-use';
22
-
23
- const ModalOverlay = React.forwardRef<
24
- React.ElementRef<typeof DialogPrimitive.Overlay>,
25
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
26
- >(({ className, onClick, ...props }, ref) => (
27
- <DialogPrimitive.Overlay
28
- ref={ref}
29
- className={cn(
30
- 'fixed inset-0 z-50 bg-Colors-Background-Utilities-Overlay data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
31
- className
32
- )}
33
- onClick={(e) => {
34
- onClick && onClick(e);
35
- }}
36
- {...props}
37
- />
38
- ));
39
- ModalOverlay.displayName = DialogPrimitive.Overlay.displayName;
40
-
41
- const DrawerOverlay = React.forwardRef<
42
- React.ElementRef<typeof DrawerPrimitive.Overlay>,
43
- React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>
44
- >(({ className, ...props }, ref) => (
45
- <DrawerPrimitive.Overlay
46
- ref={ref}
47
- className={cn(
48
- 'fixed inset-0 z-50 bg-Colors-Background-Utilities-Overlay',
49
- className
50
- )}
51
- {...props}
52
- />
53
- ));
54
-
55
- DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
56
-
57
- const ModalContent = React.forwardRef<
58
- React.ElementRef<typeof DialogPrimitive.Content>,
59
- React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
60
- >(({ className, children, ...props }, ref) => (
61
- <DialogPrimitive.Content
62
- className={cn(
63
- 'absolute left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2 !touch-auto !select-text',
64
- 'duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] focus:outline-none',
65
- className
66
- )}
67
- {...props}
68
- >
69
- {children}
70
- </DialogPrimitive.Content>
71
- ));
72
-
73
- const ModalRoot: React.FC<
74
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Dialog>
75
- > = ({ children, ...props }) => (
76
- <DialogPrimitive.Dialog {...props}>
77
- <DialogPrimitive.Portal>{children}</DialogPrimitive.Portal>
78
- </DialogPrimitive.Dialog>
79
- );
80
-
81
- const ModalTitle = React.forwardRef<
82
- React.ElementRef<typeof DialogPrimitive.Title>,
83
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
84
- >(({ className, ...props }, ref) => {
85
- const isMobile = useMedia('(max-width: 768px)');
86
-
87
- if (isMobile) {
88
- return (
89
- <DrawerPrimitive.Title
90
- ref={ref}
91
- {...props}
92
- className={cn(
93
- 'text-xl text-Colors-Text-Default font-medium line-clamp-1',
94
- className
95
- )}
96
- />
97
- );
98
- }
99
-
100
- return (
101
- <DialogPrimitive.Title
102
- ref={ref}
103
- {...props}
104
- className={cn(
105
- 'text-xl text-Colors-Text-Default font-medium line-clamp-1',
106
- className
107
- )}
108
- />
109
- );
110
- });
111
- ModalTitle.displayName = DialogPrimitive.Title.displayName;
112
-
113
- const modalVariants = cva('', {
114
- variants: {
115
- size: {
116
- lg: 'w-[750px] max-h-[640px]',
117
- md: 'w-[620px] max-h-[640px]',
118
- sm: 'w-[380px] max-h-[640px]',
119
- },
120
- zIndex: {
121
- 9: 'z-[9]',
122
- 99: 'z-[99]',
123
- 999: 'z-[999]',
124
- 9999: 'z-[9999]',
125
- },
126
- },
127
- defaultVariants: {
128
- size: 'lg',
129
- zIndex: 99,
130
- },
131
- });
132
-
133
- export type TModalState = 'info' | 'success' | 'warning' | 'error';
134
-
135
- const Modal: React.FC<
136
- React.ComponentPropsWithoutRef<typeof ModalRoot> & {
137
- /**
138
- * 模态框标题文本
139
- */
140
- title?: string;
141
- /**
142
- * 模态框描述文本
143
- */
144
- description?: string;
145
- /**
146
- * 点击覆盖层是否关闭模态框
147
- */
148
- overlayClose?: boolean;
149
- /**
150
- * 是否隐藏关闭按钮
151
- */
152
- hideClose?: boolean;
153
- /**
154
- * 模态框是否仅作为模态框显示(而不是抽屉)
155
- */
156
- modalOnly?: boolean;
157
- /**
158
- * 覆盖层的额外类名
159
- */
160
- overlayClassName?: string;
161
- /**
162
- * 模态框内容的额外类名
163
- */
164
- contentClassName?: string;
165
- /**
166
- * 关闭按钮的额外类名
167
- */
168
- closeClassName?: string;
169
- /**
170
- * 图标的额外类名
171
- */
172
- iconClassName?: string;
173
- /**
174
- * 模态框是否以全屏显示
175
- */
176
- fullScreen?: boolean;
177
- /**
178
- * 焦点范围管理的选项
179
- */
180
- focusScopeOptions?: FocusScopeProps;
181
- /**
182
- * 登录模态框的特殊逻辑
183
- */
184
- isLogin?: boolean;
185
- /**
186
- * 表示模态框是否为通知
187
- */
188
- isNotification?: boolean;
189
- /**
190
- * 模态框的状态(信息、成功、警告、错误)
191
- */
192
- state?: TModalState;
193
- /**
194
- * isNotification 的情况下可能会需要
195
- */
196
- showCancel?: boolean;
197
- /**
198
- * 是否为水平布局
199
- */
200
- isHorizontal?: boolean;
201
- /**
202
- * 确认按钮的加载状态
203
- */
204
- confirmLoading?: boolean;
205
- /**
206
- * 取消按钮的文本
207
- */
208
- cancelText?: string;
209
- /**
210
- * 确认按钮的文本
211
- */
212
- confirmText?: string;
213
- /**
214
- * 是否自动聚焦
215
- * @default false
216
- */
217
- autoFocus?: string;
218
- /**
219
- * 关闭模态框时的回调函数
220
- */
221
- onClose?: () => void;
222
- /**
223
- * 确认操作时的回调函数
224
- */
225
- onConfirm?: () => void;
226
- } & VariantProps<typeof modalVariants>
227
- > = ({
228
- title,
229
- description,
230
- size = 'lg',
231
- zIndex = 99,
232
- hideClose = false,
233
- overlayClose = true,
234
- modalOnly = true,
235
- contentClassName,
236
- overlayClassName,
237
- iconClassName,
238
- closeClassName,
239
- fullScreen = false,
240
- focusScopeOptions,
241
- isLogin = false,
242
- isNotification = false,
243
- isHorizontal = false,
244
- state,
245
- showCancel = true,
246
- confirmLoading = false,
247
- cancelText,
248
- confirmText,
249
- children,
250
- autoFocus = false,
251
- onClose,
252
- onConfirm,
253
- ...props
254
- }) => {
255
- const isMobile = useMedia('(max-width: 768px)');
256
-
257
- if (isMobile && !modalOnly && !isNotification) {
258
- const drawerContent = (
259
- <DrawerPrimitive.Content
260
- className={cn(
261
- 'fixed inset-x-0 bottom-0 z-50 h-auto overflow-hidden no-scrollbar border-Colors-Border-Opaque bg-Colors-Background-Normal-Secondary-Alt shadow-modal-default focus:outline-none',
262
- fullScreen
263
- ? 'rounded-t-none max-h-full'
264
- : 'rounded-t-2xl max-h-[85vh]',
265
- contentClassName
266
- )}
267
- onOpenAutoFocus={(e) => {
268
- !autoFocus && e.preventDefault();
269
- }}
270
- >
271
- {title ? (
272
- <ModalHeader>
273
- <ModalTitle>{title}</ModalTitle>
274
- </ModalHeader>
275
- ) : (
276
- <ModalTitle className="hidden"></ModalTitle>
277
- )}
278
- <div
279
- className={cn(
280
- isLogin ? 'overflow-y-scroll' : 'overflow-y-auto',
281
- fullScreen
282
- ? title
283
- ? 'max-h-[calc(100vh-60px)]'
284
- : 'max-h-[100vh]'
285
- : title
286
- ? 'max-h-[calc(85vh-60px)]'
287
- : 'max-h-[85vh]'
288
- )}
289
- >
290
- {children}
291
- </div>
292
- {!hideClose && (
293
- <DrawerPrimitive.Close asChild>
294
- <div
295
- className={cn('absolute right-4 top-3', closeClassName)}
296
- onClick={() => {
297
- onClose && onClose();
298
- }}
299
- >
300
- <IconButton
301
- icon={XMarkIcon}
302
- size="md"
303
- variant="plain"
304
- color="default"
305
- className={iconClassName}
306
- />
307
- <span className="sr-only">Close</span>
308
- </div>
309
- </DrawerPrimitive.Close>
310
- )}
311
- </DrawerPrimitive.Content>
312
- );
313
-
314
- return (
315
- <DrawerPrimitive.Root
316
- {...props}
317
- repositionInputs={false}
318
- onOpenChange={(open) => {
319
- if (!open) {
320
- onClose && onClose();
321
- }
322
- }}
323
- >
324
- <DrawerPrimitive.Portal>
325
- <DrawerOverlay
326
- onClick={() => {
327
- overlayClose && onClose && onClose();
328
- }}
329
- className={overlayClassName}
330
- />
331
- {focusScopeOptions ? (
332
- <FocusScope {...focusScopeOptions}>{drawerContent}</FocusScope>
333
- ) : (
334
- drawerContent
335
- )}
336
- </DrawerPrimitive.Portal>
337
- </DrawerPrimitive.Root>
338
- );
339
- }
340
-
341
- const renderIcon = (state: TModalState) => {
342
- switch (state) {
343
- case 'info':
344
- return (
345
- <InformationCircleIcon className="text-cc-Icon-Featured-icon-fg-Info w-6 h-6" />
346
- );
347
- case 'success':
348
- return (
349
- <CheckCircleIcon className="text-cc-Icon-Featured-icon-fg-Success w-6 h-6" />
350
- );
351
- case 'warning':
352
- return (
353
- <ExclamationTriangleIcon className="text-cc-Icon-Featured-icon-fg-Warning w-6 h-6" />
354
- );
355
- case 'error':
356
- return (
357
- <XCircleIcon className="text-cc-Icon-Featured-icon-fg-Error w-6 h-6" />
358
- );
359
- }
360
- };
361
-
362
- const getBackgroundColor = (state: TModalState) => {
363
- switch (state) {
364
- case 'info':
365
- return 'bg-Colors-Background-Info-Default';
366
- case 'success':
367
- return 'bg-Colors-Background-Success-Default';
368
- case 'warning':
369
- return 'bg-Colors-Background-Warning-Default';
370
- case 'error':
371
- return 'bg-Colors-Background-Critical-Default';
372
- }
373
- };
374
-
375
- const dialogContent = (
376
- <ModalContent
377
- className={cn(
378
- 'rounded-2xl border-Colors-Border-Opaque bg-Colors-Background-Normal-Primary-Default shadow-modal-default overflow-hidden',
379
- !isMobile
380
- ? modalVariants({ size, zIndex })
381
- : isLogin
382
- ? 'w-[90%]'
383
- : 'w-[80%]',
384
- isNotification && 'w-[312px] md:w-[380px]',
385
- contentClassName
386
- )}
387
- onOpenAutoFocus={(e) => {
388
- !autoFocus && e.preventDefault();
389
- }}
390
- >
391
- {isNotification ? (
392
- <>
393
- <ModalHeader className={cn(isNotification && 'border-none !pb-3')}>
394
- {state && (
395
- <div
396
- className={cn(
397
- 'flex items-center justify-center w-10 h-10 rounded-full flex-shrink-0 flex-grow-0',
398
- getBackgroundColor(state)
399
- )}
400
- >
401
- {renderIcon(state)}
402
- </div>
403
- )}
404
- </ModalHeader>
405
- <div className="space-y-1.5">
406
- {title ? (
407
- <div className="px-5">
408
- <Display size="sm">{title}</Display>
409
- </div>
410
- ) : null}
411
- {children ||
412
- (description ? (
413
- <div className="px-5">
414
- <Text size="sm" weight="regular">
415
- {description}
416
- </Text>
417
- </div>
418
- ) : null)}
419
- </div>
420
-
421
- <ModalFooter
422
- className={cn(
423
- 'gap-x-5 min-h-[76px] p-5 border-none justify-center w-full'
424
- )}
425
- >
426
- {showCancel && (
427
- <Button variant="tertiary" onClick={onClose} className="flex-1">
428
- {cancelText || 'Cancel'}
429
- </Button>
430
- )}
431
-
432
- <Button
433
- variant="primary"
434
- onClick={onConfirm}
435
- loading={confirmLoading}
436
- color={state === 'error' ? 'error' : 'default'}
437
- className="flex-1"
438
- >
439
- {confirmText || 'Confirm'}
440
- </Button>
441
- </ModalFooter>
442
- </>
443
- ) : (
444
- <>
445
- {title ? (
446
- <ModalHeader>
447
- <ModalTitle>{title}</ModalTitle>
448
- </ModalHeader>
449
- ) : (
450
- <ModalTitle className="hidden"></ModalTitle>
451
- )}
452
- {children}
453
- </>
454
- )}
455
-
456
- {!hideClose && (
457
- <DialogPrimitive.Close asChild>
458
- <div
459
- onClick={() => {
460
- onClose && onClose();
461
- }}
462
- className={cn(
463
- 'absolute right-4 top-4',
464
- isNotification && 'top-5',
465
- closeClassName
466
- )}
467
- >
468
- <IconButton
469
- icon={XMarkIcon}
470
- size="md"
471
- variant="plain"
472
- color="default"
473
- className={iconClassName}
474
- />
475
- <span className="sr-only">Close</span>
476
- </div>
477
- </DialogPrimitive.Close>
478
- )}
479
- </ModalContent>
480
- );
481
-
482
- return (
483
- <ModalRoot {...props}>
484
- <ModalOverlay
485
- onClick={() => {
486
- overlayClose && onClose && onClose();
487
- }}
488
- className={overlayClassName}
489
- />
490
- {focusScopeOptions ? (
491
- <FocusScope {...focusScopeOptions}>{dialogContent}</FocusScope>
492
- ) : (
493
- dialogContent
494
- )}
495
- </ModalRoot>
496
- );
497
- };
498
-
499
- function ModalHeader({
500
- className,
501
- children,
502
- ...props
503
- }: React.HTMLAttributes<HTMLDivElement>) {
504
- return (
505
- <div
506
- className={cn(
507
- 'border-b border-Colors-Border-Default flex flex-col py-4 md:py-5 px-4 justify-center',
508
- className
509
- )}
510
- {...props}
511
- >
512
- {children}
513
- </div>
514
- );
515
- }
516
- ModalHeader.displayName = 'ModalHeader';
517
-
518
- function ModalFooter({
519
- className,
520
- children,
521
- ...props
522
- }: React.HTMLAttributes<HTMLDivElement>) {
523
- return (
524
- <div
525
- className={cn(
526
- 'border-t border-Colors-Border-Default flex justify-end p-4',
527
- className
528
- )}
529
- {...props}
530
- >
531
- {children}
532
- </div>
533
- );
534
- }
535
-
536
- ModalFooter.displayName = 'ModalFooter';
537
-
538
- function ModalBody({
539
- className,
540
- children,
541
- ...props
542
- }: React.HTMLAttributes<HTMLDivElement>) {
543
- return (
544
- <div className={cn('py-3', className)} {...props}>
545
- {children}
546
- </div>
547
- );
548
- }
549
-
550
- ModalBody.displayName = 'ModalBody';
551
-
552
- export {
553
- Modal,
554
- ModalBody,
555
- ModalContent,
556
- ModalFooter,
557
- ModalHeader,
558
- ModalOverlay,
559
- ModalRoot,
560
- ModalTitle,
561
- };
@@ -1,100 +0,0 @@
1
- /* eslint-disable react/jsx-no-useless-fragment */
2
-
3
- import { cn } from '@/lib/utils';
4
- import { SearchBar } from './search-bar';
5
- import { Display } from './typography';
6
- import EnergyProgress from './energy-progress';
7
-
8
- type INavigationBar = {
9
- /**
10
- * 右侧自定义内容
11
- * ReactNode
12
- *
13
- */
14
- children?: React.ReactNode;
15
- /**
16
- * 导航栏title
17
- * string
18
- */
19
- title?: string;
20
- /**
21
- * 是否展示搜索框
22
- * boolean
23
- *
24
- * @default false
25
- */
26
- showSearchBar?: boolean;
27
- /**
28
- * 搜索框值
29
- * string
30
- */
31
- searchValue?: string;
32
- /**
33
- * 搜索框占位值
34
- * string
35
- */
36
- searchPlaceholder?: string;
37
- /**
38
- * 电量值
39
- * number
40
- */
41
- energy?: number;
42
- /**
43
- * 每日电量值
44
- * number
45
- */
46
- dailyEnergy?: number;
47
- onSearchChange?: (value: string) => void;
48
- };
49
-
50
- function NavigationBar({
51
- showSearchBar = true,
52
- searchValue,
53
- searchPlaceholder,
54
- title,
55
- children,
56
- energy = 0,
57
- dailyEnergy,
58
- onSearchChange,
59
- }: INavigationBar) {
60
- return (
61
- <div
62
- className={cn(
63
- 'relative w-full flex flex-col justify-between items-center px-4 md:px-6'
64
- )}
65
- >
66
- <div className="w-full pt-5 md:pt-6 pb-1 md:pb-3 flex justify-between items-center">
67
- <div className="flex-1 text-start">
68
- <Display size="md">{title}</Display>
69
- </div>
70
- {children ? (
71
- <div className="w-fit">{children}</div>
72
- ) : (
73
- <>
74
- {dailyEnergy ? (
75
- <EnergyProgress
76
- dailyEnergy={dailyEnergy}
77
- energy={energy}
78
- className="flex relative items-center flex-shrink-0"
79
- />
80
- ) : null}
81
- </>
82
- )}
83
- </div>
84
-
85
- {showSearchBar && (
86
- <div className="w-full py-2 md:py-0">
87
- <SearchBar
88
- placeholder={searchPlaceholder}
89
- searchValue={searchValue}
90
- onSearchChange={(value: string) =>
91
- onSearchChange && onSearchChange(value)
92
- }
93
- />
94
- </div>
95
- )}
96
- </div>
97
- );
98
- }
99
-
100
- export { NavigationBar };