myshell-react-lib 0.1.5 → 0.1.6
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.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,196 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
4
|
-
import { Check, ChevronRight, Circle } from 'lucide-react';
|
|
5
|
-
import * as React from 'react';
|
|
6
|
-
|
|
7
|
-
import { cn } from '@/lib/utils';
|
|
8
|
-
|
|
9
|
-
const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
10
|
-
|
|
11
|
-
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
12
|
-
|
|
13
|
-
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
14
|
-
|
|
15
|
-
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
16
|
-
|
|
17
|
-
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
18
|
-
|
|
19
|
-
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
20
|
-
|
|
21
|
-
const DropdownMenuSubTrigger = React.forwardRef<
|
|
22
|
-
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
|
23
|
-
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
24
|
-
inset?: boolean;
|
|
25
|
-
}
|
|
26
|
-
>(({ className, inset, children, ...props }, ref) => (
|
|
27
|
-
<DropdownMenuPrimitive.SubTrigger
|
|
28
|
-
ref={ref}
|
|
29
|
-
className={cn(
|
|
30
|
-
'flex cursor-default select-none items-center rounded-lg px-3 py-2 outline-none focus:bg-Colors-Background-Neutral-Primary-Default data-[state=open]:bg-Colors-Background-Neutral-Primary-Default',
|
|
31
|
-
inset && 'pl-8',
|
|
32
|
-
className
|
|
33
|
-
)}
|
|
34
|
-
{...props}
|
|
35
|
-
>
|
|
36
|
-
{children}
|
|
37
|
-
<ChevronRight className="ml-auto h-4 w-4" />
|
|
38
|
-
</DropdownMenuPrimitive.SubTrigger>
|
|
39
|
-
));
|
|
40
|
-
DropdownMenuSubTrigger.displayName =
|
|
41
|
-
DropdownMenuPrimitive.SubTrigger.displayName;
|
|
42
|
-
|
|
43
|
-
const DropdownMenuSubContent = React.forwardRef<
|
|
44
|
-
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
|
45
|
-
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
|
|
46
|
-
>(({ className, ...props }, ref) => (
|
|
47
|
-
<DropdownMenuPrimitive.SubContent
|
|
48
|
-
ref={ref}
|
|
49
|
-
className={cn(
|
|
50
|
-
'z-50 min-w-[8rem] overflow-hidden rounded-xl border border-alpha bg-Colors-Background-Normal-Primary-Active p-2 text-Colors-Text-Default shadow-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',
|
|
51
|
-
className
|
|
52
|
-
)}
|
|
53
|
-
{...props}
|
|
54
|
-
/>
|
|
55
|
-
));
|
|
56
|
-
DropdownMenuSubContent.displayName =
|
|
57
|
-
DropdownMenuPrimitive.SubContent.displayName;
|
|
58
|
-
|
|
59
|
-
const DropdownMenuContent = React.forwardRef<
|
|
60
|
-
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
|
61
|
-
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
|
|
62
|
-
>(({ className, sideOffset = 4, ...props }, ref) => {
|
|
63
|
-
return (
|
|
64
|
-
<DropdownMenuPrimitive.Content
|
|
65
|
-
ref={ref}
|
|
66
|
-
sideOffset={sideOffset}
|
|
67
|
-
className={cn(
|
|
68
|
-
'z-[100] min-w-[8rem] overflow-hidden rounded-xl border border-opaque bg-Colors-Background-Normal-Primary-Default p-1 text-Colors-Text-Default shadow-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',
|
|
69
|
-
className
|
|
70
|
-
)}
|
|
71
|
-
{...props}
|
|
72
|
-
/>
|
|
73
|
-
);
|
|
74
|
-
});
|
|
75
|
-
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
76
|
-
|
|
77
|
-
const DropdownMenuItem = React.forwardRef<
|
|
78
|
-
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
|
79
|
-
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
|
80
|
-
inset?: boolean;
|
|
81
|
-
}
|
|
82
|
-
>(({ className, inset, ...props }, ref) => (
|
|
83
|
-
<DropdownMenuPrimitive.Item
|
|
84
|
-
ref={ref}
|
|
85
|
-
className={cn(
|
|
86
|
-
'relative flex cursor-default select-none items-center rounded-lg px-2 py-1 outline-none transition-colors focus:bg-Colors-Background-Neutral-Primary-Default data-[disabled]:pointer-events-none data-[disabled]:opacity-30',
|
|
87
|
-
inset && 'pl-8',
|
|
88
|
-
className
|
|
89
|
-
)}
|
|
90
|
-
{...props}
|
|
91
|
-
/>
|
|
92
|
-
));
|
|
93
|
-
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
|
94
|
-
|
|
95
|
-
const DropdownMenuCheckboxItem = React.forwardRef<
|
|
96
|
-
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
|
97
|
-
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
|
|
98
|
-
>(({ className, children, checked, ...props }, ref) => (
|
|
99
|
-
<DropdownMenuPrimitive.CheckboxItem
|
|
100
|
-
ref={ref}
|
|
101
|
-
className={cn(
|
|
102
|
-
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-slate-100 focus:text-slate-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-30',
|
|
103
|
-
className
|
|
104
|
-
)}
|
|
105
|
-
checked={checked}
|
|
106
|
-
{...props}
|
|
107
|
-
>
|
|
108
|
-
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
109
|
-
<DropdownMenuPrimitive.ItemIndicator>
|
|
110
|
-
<Check className="h-4 w-4" />
|
|
111
|
-
</DropdownMenuPrimitive.ItemIndicator>
|
|
112
|
-
</span>
|
|
113
|
-
{children}
|
|
114
|
-
</DropdownMenuPrimitive.CheckboxItem>
|
|
115
|
-
));
|
|
116
|
-
DropdownMenuCheckboxItem.displayName =
|
|
117
|
-
DropdownMenuPrimitive.CheckboxItem.displayName;
|
|
118
|
-
|
|
119
|
-
const DropdownMenuRadioItem = React.forwardRef<
|
|
120
|
-
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
|
121
|
-
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
|
|
122
|
-
>(({ className, children, ...props }, ref) => (
|
|
123
|
-
<DropdownMenuPrimitive.RadioItem
|
|
124
|
-
ref={ref}
|
|
125
|
-
className={cn(
|
|
126
|
-
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-slate-100 focus:text-slate-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:focus:bg-slate-800 dark:focus:text-slate-50',
|
|
127
|
-
className
|
|
128
|
-
)}
|
|
129
|
-
{...props}
|
|
130
|
-
>
|
|
131
|
-
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
132
|
-
<DropdownMenuPrimitive.ItemIndicator>
|
|
133
|
-
<Circle className="h-2 w-2 fill-current" />
|
|
134
|
-
</DropdownMenuPrimitive.ItemIndicator>
|
|
135
|
-
</span>
|
|
136
|
-
{children}
|
|
137
|
-
</DropdownMenuPrimitive.RadioItem>
|
|
138
|
-
));
|
|
139
|
-
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
|
140
|
-
|
|
141
|
-
const DropdownMenuLabel = React.forwardRef<
|
|
142
|
-
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
|
143
|
-
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
|
144
|
-
inset?: boolean;
|
|
145
|
-
}
|
|
146
|
-
>(({ className, inset, ...props }, ref) => (
|
|
147
|
-
<DropdownMenuPrimitive.Label
|
|
148
|
-
ref={ref}
|
|
149
|
-
className={cn('px-3 py-1 text-sm font-medium', inset && 'pl-8', className)}
|
|
150
|
-
{...props}
|
|
151
|
-
/>
|
|
152
|
-
));
|
|
153
|
-
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
|
154
|
-
|
|
155
|
-
const DropdownMenuSeparator = React.forwardRef<
|
|
156
|
-
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
|
157
|
-
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
|
158
|
-
>(({ className, ...props }, ref) => (
|
|
159
|
-
<DropdownMenuPrimitive.Separator
|
|
160
|
-
ref={ref}
|
|
161
|
-
className={cn('my-1 h-px bg-[var(--border)]', className)}
|
|
162
|
-
{...props}
|
|
163
|
-
/>
|
|
164
|
-
));
|
|
165
|
-
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
|
166
|
-
|
|
167
|
-
const DropdownMenuShortcut = ({
|
|
168
|
-
className,
|
|
169
|
-
...props
|
|
170
|
-
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
171
|
-
return (
|
|
172
|
-
<span
|
|
173
|
-
className={cn('ml-auto text-xs tracking-widest opacity-60', className)}
|
|
174
|
-
{...props}
|
|
175
|
-
/>
|
|
176
|
-
);
|
|
177
|
-
};
|
|
178
|
-
DropdownMenuShortcut.displayName = 'DropdownMenuShortcut';
|
|
179
|
-
|
|
180
|
-
export {
|
|
181
|
-
DropdownMenu,
|
|
182
|
-
DropdownMenuCheckboxItem,
|
|
183
|
-
DropdownMenuContent,
|
|
184
|
-
DropdownMenuGroup,
|
|
185
|
-
DropdownMenuItem,
|
|
186
|
-
DropdownMenuLabel,
|
|
187
|
-
DropdownMenuPortal,
|
|
188
|
-
DropdownMenuRadioGroup,
|
|
189
|
-
DropdownMenuRadioItem,
|
|
190
|
-
DropdownMenuSeparator,
|
|
191
|
-
DropdownMenuShortcut,
|
|
192
|
-
DropdownMenuSub,
|
|
193
|
-
DropdownMenuSubContent,
|
|
194
|
-
DropdownMenuSubTrigger,
|
|
195
|
-
DropdownMenuTrigger,
|
|
196
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import Image from 'next/image';
|
|
2
|
-
|
|
3
|
-
import { getAssetsUrl } from '../common/utils/common-helper';
|
|
4
|
-
import { cn } from '@/lib/utils';
|
|
5
|
-
|
|
6
|
-
import { Progress } from './progress';
|
|
7
|
-
import { Tooltip } from './tooltip';
|
|
8
|
-
|
|
9
|
-
type EnergyProgressBarProps = {
|
|
10
|
-
energy: number;
|
|
11
|
-
dailyEnergy: number;
|
|
12
|
-
hoverText?: string;
|
|
13
|
-
className?: string;
|
|
14
|
-
};
|
|
15
|
-
function EnergyProgress(props: EnergyProgressBarProps) {
|
|
16
|
-
const { energy, dailyEnergy, hoverText, className } = props;
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<div className={cn('flex items-center relative', className)}>
|
|
20
|
-
<div className="absolute left-[-20px] justify-center items-center w-6 h-6 border border-solid border-[#F3D42D] dark:border-[#A48F07] bg-white dark:bg-[#24210B] rounded-[6px] z-10">
|
|
21
|
-
<Image
|
|
22
|
-
src={getAssetsUrl('image/bot/tag/20231214/1719340128612116720.png')}
|
|
23
|
-
alt="energy"
|
|
24
|
-
width={22}
|
|
25
|
-
height={22}
|
|
26
|
-
/>
|
|
27
|
-
</div>
|
|
28
|
-
|
|
29
|
-
<Tooltip
|
|
30
|
-
description={
|
|
31
|
-
hoverText ??
|
|
32
|
-
`Utilize battery to chat with bots or set up your own bot. Recharge ⚡️${Math.floor(
|
|
33
|
-
dailyEnergy / 24
|
|
34
|
-
)} per hour when battery is below ${dailyEnergy}`
|
|
35
|
-
}
|
|
36
|
-
side="bottom"
|
|
37
|
-
align="end"
|
|
38
|
-
sideOffset={16}
|
|
39
|
-
alignOffset={-16}
|
|
40
|
-
showArrow={false}
|
|
41
|
-
>
|
|
42
|
-
<Progress
|
|
43
|
-
value={energy}
|
|
44
|
-
max={dailyEnergy}
|
|
45
|
-
className="rounded-[6px] rounded-l-none border border-solid border-cc-Energy-border-default bg-cc-Energy-bg-alt flex items-center justify-start"
|
|
46
|
-
indicatorClassName={'bg-cc-Energy-bg-on'}
|
|
47
|
-
label={
|
|
48
|
-
<span className="text-cc-Energy-fg-default font-medium text-xs ml-[2px]">{`${energy}/${dailyEnergy}`}</span>
|
|
49
|
-
}
|
|
50
|
-
/>
|
|
51
|
-
</Tooltip>
|
|
52
|
-
</div>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
export default EnergyProgress;
|
package/src/components/form.tsx
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
2
|
-
import { Slot } from '@radix-ui/react-slot';
|
|
3
|
-
import { cva } from 'class-variance-authority';
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import {
|
|
6
|
-
Controller,
|
|
7
|
-
ControllerProps,
|
|
8
|
-
FieldPath,
|
|
9
|
-
FieldValues,
|
|
10
|
-
FormProvider,
|
|
11
|
-
useFormContext,
|
|
12
|
-
} from 'react-hook-form';
|
|
13
|
-
|
|
14
|
-
import { Label } from './label';
|
|
15
|
-
import { cn } from '@/lib/utils';
|
|
16
|
-
|
|
17
|
-
const Form = FormProvider;
|
|
18
|
-
|
|
19
|
-
type FormFieldContextValue<
|
|
20
|
-
TFieldValues extends FieldValues = FieldValues,
|
|
21
|
-
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
|
|
22
|
-
> = {
|
|
23
|
-
name: TName;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const FormFieldContext = React.createContext<FormFieldContextValue>(
|
|
27
|
-
{} as FormFieldContextValue
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
function FormField<
|
|
31
|
-
TFieldValues extends FieldValues = FieldValues,
|
|
32
|
-
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
|
|
33
|
-
>({ ...props }: ControllerProps<TFieldValues, TName>) {
|
|
34
|
-
return (
|
|
35
|
-
<FormFieldContext.Provider value={{ name: props.name }}>
|
|
36
|
-
<Controller {...props} />
|
|
37
|
-
</FormFieldContext.Provider>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const useFormField = () => {
|
|
42
|
-
const fieldContext = React.useContext(FormFieldContext);
|
|
43
|
-
const itemContext = React.useContext(FormItemContext);
|
|
44
|
-
const { getFieldState, formState } = useFormContext();
|
|
45
|
-
|
|
46
|
-
const fieldState = getFieldState(fieldContext.name, formState);
|
|
47
|
-
|
|
48
|
-
if (!fieldContext) {
|
|
49
|
-
throw new Error('useFormField should be used within <FormField>');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const { id } = itemContext;
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
id,
|
|
56
|
-
name: fieldContext.name,
|
|
57
|
-
formItemId: `${id}-form-item`,
|
|
58
|
-
formDescriptionId: `${id}-form-item-description`,
|
|
59
|
-
formMessageId: `${id}-form-item-message`,
|
|
60
|
-
...fieldState,
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
type FormItemContextValue = {
|
|
65
|
-
id: string;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const FormItemContext = React.createContext<FormItemContextValue>(
|
|
69
|
-
{} as FormItemContextValue
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
interface IFormItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
73
|
-
layout?: 'Vertical' | 'Horizontal';
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const formLayoutVariants = cva('', {
|
|
77
|
-
variants: {
|
|
78
|
-
layout: {
|
|
79
|
-
Vertical: 'space-y-1.5',
|
|
80
|
-
Horizontal: 'flex flex-row items-center space-x-3',
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
defaultVariants: {
|
|
84
|
-
layout: 'Vertical',
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const FormItem = React.forwardRef<HTMLDivElement, IFormItemProps>(
|
|
89
|
-
({ className, layout, ...props }, ref) => {
|
|
90
|
-
const id = React.useId();
|
|
91
|
-
|
|
92
|
-
const cls = cn(className, formLayoutVariants({ layout }));
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
<FormItemContext.Provider value={{ id }}>
|
|
96
|
-
<div ref={ref} className={cls} {...props} />
|
|
97
|
-
</FormItemContext.Provider>
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
);
|
|
101
|
-
FormItem.displayName = 'FormItem';
|
|
102
|
-
|
|
103
|
-
interface IFormLabelProps
|
|
104
|
-
extends React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> {
|
|
105
|
-
required?: boolean;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const FormLabel = React.forwardRef<
|
|
109
|
-
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
110
|
-
IFormLabelProps
|
|
111
|
-
>(({ className, required, children, ...props }, ref) => {
|
|
112
|
-
const { formItemId } = useFormField();
|
|
113
|
-
|
|
114
|
-
return (
|
|
115
|
-
<Label ref={ref} className={className} htmlFor={formItemId} {...props}>
|
|
116
|
-
{required ? (
|
|
117
|
-
<span className="text-Colors-Text-Critical-Default mr-1">*</span>
|
|
118
|
-
) : null}
|
|
119
|
-
{children}
|
|
120
|
-
</Label>
|
|
121
|
-
);
|
|
122
|
-
});
|
|
123
|
-
FormLabel.displayName = 'FormLabel';
|
|
124
|
-
|
|
125
|
-
const FormControl = React.forwardRef<
|
|
126
|
-
React.ElementRef<typeof Slot>,
|
|
127
|
-
React.ComponentPropsWithoutRef<typeof Slot>
|
|
128
|
-
>(({ ...props }, ref) => {
|
|
129
|
-
const { error, formItemId, formDescriptionId, formMessageId } =
|
|
130
|
-
useFormField();
|
|
131
|
-
|
|
132
|
-
return (
|
|
133
|
-
<Slot
|
|
134
|
-
ref={ref}
|
|
135
|
-
id={formItemId}
|
|
136
|
-
aria-describedby={
|
|
137
|
-
!error
|
|
138
|
-
? `${formDescriptionId}`
|
|
139
|
-
: `${formDescriptionId} ${formMessageId}`
|
|
140
|
-
}
|
|
141
|
-
aria-invalid={!!error}
|
|
142
|
-
{...props}
|
|
143
|
-
/>
|
|
144
|
-
);
|
|
145
|
-
});
|
|
146
|
-
FormControl.displayName = 'FormControl';
|
|
147
|
-
|
|
148
|
-
const FormDescription = React.forwardRef<
|
|
149
|
-
HTMLParagraphElement,
|
|
150
|
-
React.HTMLAttributes<HTMLParagraphElement>
|
|
151
|
-
>(({ className, ...props }, ref) => {
|
|
152
|
-
const { formDescriptionId } = useFormField();
|
|
153
|
-
|
|
154
|
-
return (
|
|
155
|
-
<p
|
|
156
|
-
ref={ref}
|
|
157
|
-
id={formDescriptionId}
|
|
158
|
-
className={cn('text-sm text-Colors-Text-Subtler', className)}
|
|
159
|
-
{...props}
|
|
160
|
-
/>
|
|
161
|
-
);
|
|
162
|
-
});
|
|
163
|
-
FormDescription.displayName = 'FormDescription';
|
|
164
|
-
|
|
165
|
-
const FormMessage = React.forwardRef<
|
|
166
|
-
HTMLParagraphElement,
|
|
167
|
-
React.HTMLAttributes<HTMLParagraphElement>
|
|
168
|
-
>(({ className, children, ...props }, ref) => {
|
|
169
|
-
const { error, formMessageId } = useFormField();
|
|
170
|
-
const body = error ? String(error?.message) : children;
|
|
171
|
-
|
|
172
|
-
if (!body) {
|
|
173
|
-
return null;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return (
|
|
177
|
-
<p
|
|
178
|
-
ref={ref}
|
|
179
|
-
id={formMessageId}
|
|
180
|
-
className={cn(
|
|
181
|
-
'text-sm font-medium text-Colors-Text-Critical-Default',
|
|
182
|
-
className
|
|
183
|
-
)}
|
|
184
|
-
{...props}
|
|
185
|
-
>
|
|
186
|
-
{body}
|
|
187
|
-
</p>
|
|
188
|
-
);
|
|
189
|
-
});
|
|
190
|
-
FormMessage.displayName = 'FormMessage';
|
|
191
|
-
|
|
192
|
-
export {
|
|
193
|
-
Form,
|
|
194
|
-
FormControl,
|
|
195
|
-
FormDescription,
|
|
196
|
-
FormField,
|
|
197
|
-
FormItem,
|
|
198
|
-
FormLabel,
|
|
199
|
-
FormMessage,
|
|
200
|
-
useFormField,
|
|
201
|
-
};
|
package/src/components/group.tsx
DELETED
package/src/components/guide.tsx
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
AllowedButtons,
|
|
5
|
-
Config,
|
|
6
|
-
DriveStep,
|
|
7
|
-
PopoverDOM,
|
|
8
|
-
State,
|
|
9
|
-
driver,
|
|
10
|
-
} from 'driver.js';
|
|
11
|
-
import * as React from 'react';
|
|
12
|
-
import { useEffect, useMemo, useRef } from 'react';
|
|
13
|
-
|
|
14
|
-
import { cn } from '@/lib/utils';
|
|
15
|
-
|
|
16
|
-
// Import driver.js styles
|
|
17
|
-
import 'driver.js/dist/driver.css';
|
|
18
|
-
|
|
19
|
-
interface GuideProps {
|
|
20
|
-
/*
|
|
21
|
-
引导步骤
|
|
22
|
-
*/
|
|
23
|
-
steps: DriveStep[];
|
|
24
|
-
/*
|
|
25
|
-
是否显示进度条
|
|
26
|
-
@default true
|
|
27
|
-
*/
|
|
28
|
-
showProgress?: boolean;
|
|
29
|
-
/*
|
|
30
|
-
是否显示遮罩层
|
|
31
|
-
@default true
|
|
32
|
-
*/
|
|
33
|
-
showOverlay?: boolean;
|
|
34
|
-
/*
|
|
35
|
-
是否显示关闭按钮
|
|
36
|
-
@default true
|
|
37
|
-
*/
|
|
38
|
-
hasCloseBtn?: boolean;
|
|
39
|
-
/*
|
|
40
|
-
是否允许点击背景蒙层关闭
|
|
41
|
-
@default true
|
|
42
|
-
*/
|
|
43
|
-
allowClose?: boolean;
|
|
44
|
-
/*
|
|
45
|
-
是否显示跳过按钮
|
|
46
|
-
@default true
|
|
47
|
-
*/
|
|
48
|
-
hasSkip?: boolean;
|
|
49
|
-
/*
|
|
50
|
-
跳过按钮文本
|
|
51
|
-
@default 'Skip'
|
|
52
|
-
*/
|
|
53
|
-
skipText?: string;
|
|
54
|
-
/*
|
|
55
|
-
是否显示下一步按钮
|
|
56
|
-
@default true
|
|
57
|
-
*/
|
|
58
|
-
hasNextBtn?: boolean;
|
|
59
|
-
/*
|
|
60
|
-
是否显示上一步按钮
|
|
61
|
-
@default false
|
|
62
|
-
*/
|
|
63
|
-
hasPrevBtn?: boolean;
|
|
64
|
-
/*
|
|
65
|
-
上一步按钮文本
|
|
66
|
-
@default 'Previous'
|
|
67
|
-
*/
|
|
68
|
-
prevBtnText?: string;
|
|
69
|
-
/*
|
|
70
|
-
下一步按钮文本
|
|
71
|
-
@default 'Next'
|
|
72
|
-
*/
|
|
73
|
-
nextBtnText?: string;
|
|
74
|
-
/*
|
|
75
|
-
完成按钮文本
|
|
76
|
-
@default 'Done'
|
|
77
|
-
*/
|
|
78
|
-
doneBtnText?: string;
|
|
79
|
-
/*
|
|
80
|
-
自定义类名
|
|
81
|
-
*/
|
|
82
|
-
className?: string;
|
|
83
|
-
/*
|
|
84
|
-
完成的回调
|
|
85
|
-
*/
|
|
86
|
-
onComplete?: () => void;
|
|
87
|
-
/*
|
|
88
|
-
跳过的回调
|
|
89
|
-
*/
|
|
90
|
-
onSkip?: () => void;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export const Guide: React.FC<GuideProps> = ({
|
|
94
|
-
steps,
|
|
95
|
-
showProgress = true,
|
|
96
|
-
showOverlay = false,
|
|
97
|
-
hasSkip = true,
|
|
98
|
-
hasCloseBtn = true,
|
|
99
|
-
hasPrevBtn = false,
|
|
100
|
-
hasNextBtn = true,
|
|
101
|
-
allowClose = false,
|
|
102
|
-
skipText = 'Skip',
|
|
103
|
-
prevBtnText = 'Previous',
|
|
104
|
-
nextBtnText = 'Next',
|
|
105
|
-
doneBtnText = 'Done',
|
|
106
|
-
className,
|
|
107
|
-
onComplete,
|
|
108
|
-
onSkip,
|
|
109
|
-
}) => {
|
|
110
|
-
const driverRef = useRef<any>(null);
|
|
111
|
-
const buttons = useMemo(() => {
|
|
112
|
-
const buttons = [] as AllowedButtons[];
|
|
113
|
-
if (hasPrevBtn) {
|
|
114
|
-
buttons.push('previous');
|
|
115
|
-
}
|
|
116
|
-
if (hasNextBtn) {
|
|
117
|
-
buttons.push('next');
|
|
118
|
-
}
|
|
119
|
-
if (hasCloseBtn) {
|
|
120
|
-
buttons.push('close');
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return buttons;
|
|
124
|
-
}, [hasNextBtn, hasPrevBtn, hasCloseBtn]);
|
|
125
|
-
useEffect(() => {
|
|
126
|
-
driverRef.current = driver({
|
|
127
|
-
overlayOpacity: showOverlay ? 0.8 : 0,
|
|
128
|
-
animate: true,
|
|
129
|
-
showButtons: buttons?.length > 0 ? buttons : [],
|
|
130
|
-
showProgress,
|
|
131
|
-
steps,
|
|
132
|
-
prevBtnText,
|
|
133
|
-
nextBtnText,
|
|
134
|
-
doneBtnText,
|
|
135
|
-
allowClose,
|
|
136
|
-
progressText: '{{current}}/{{total}}',
|
|
137
|
-
onDestroyed: onComplete,
|
|
138
|
-
onPopoverRender: (
|
|
139
|
-
popover: PopoverDOM,
|
|
140
|
-
{ config, state }: { config: Config; state: State }
|
|
141
|
-
) => {
|
|
142
|
-
const closeBtn = popover.closeButton as HTMLElement;
|
|
143
|
-
|
|
144
|
-
if (hasCloseBtn && closeBtn) {
|
|
145
|
-
closeBtn.className = cn(
|
|
146
|
-
'driver-popover-close-btn !text-Colors-Text-Static-White !opacity-70 !w-4.5 !h-4.5 !right-3 !top-3',
|
|
147
|
-
closeBtn.className
|
|
148
|
-
);
|
|
149
|
-
closeBtn.style.display = 'block';
|
|
150
|
-
closeBtn.innerHTML =
|
|
151
|
-
'<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_21201_7803)"><path d="M4.10225 4.10225C4.32192 3.88258 4.67808 3.88258 4.89775 4.10225L9 8.20451L13.1023 4.10225C13.3219 3.88258 13.6781 3.88258 13.8977 4.10225C14.1174 4.32192 14.1174 4.67808 13.8977 4.89775L9.7955 9L13.8977 13.1023C14.1174 13.3219 14.1174 13.6781 13.8977 13.8977C13.6781 14.1174 13.3219 14.1174 13.1023 13.8977L9 9.7955L4.89775 13.8977C4.67808 14.1174 4.32192 14.1174 4.10225 13.8977C3.88258 13.6781 3.88258 13.3219 4.10225 13.1023L8.20451 9L4.10225 4.89775C3.88258 4.67808 3.88258 4.32192 4.10225 4.10225Z" fill="white" fill-opacity="0.7"/></g><defs><clipPath id="clip0_21201_7803"><rect width="18" height="18" fill="white"/></clipPath></defs></svg>';
|
|
152
|
-
closeBtn.onclick = () => {
|
|
153
|
-
driverRef.current.destroy();
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
const content = popover.wrapper as HTMLElement;
|
|
157
|
-
if (content) {
|
|
158
|
-
content.className = cn(
|
|
159
|
-
'!bg-Colors-Utility-Lake-Blue-50 !p-3 !shadow-modal-default',
|
|
160
|
-
content.className
|
|
161
|
-
);
|
|
162
|
-
const arrow = popover.arrow as HTMLElement;
|
|
163
|
-
if (arrow) {
|
|
164
|
-
arrow.className = cn(
|
|
165
|
-
'border-t-Colors-Utility-Lake-Blue-50',
|
|
166
|
-
arrow.className
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
const title = popover.title as HTMLElement;
|
|
170
|
-
const description = popover.description as HTMLElement;
|
|
171
|
-
const footer = popover.footer as HTMLElement;
|
|
172
|
-
const footerButtons = popover.footerButtons as HTMLElement;
|
|
173
|
-
|
|
174
|
-
if (title) {
|
|
175
|
-
title.className = cn('mb-1', title.className);
|
|
176
|
-
title.innerHTML = `<p class="text-base font-medium text-Colors-Beta-White-100">${title.innerHTML}</p>`;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (description) {
|
|
180
|
-
description.innerHTML = `<p class="text-sm !text-Colors-Beta-White-80">${description.innerHTML}</p>`;
|
|
181
|
-
}
|
|
182
|
-
if (footer) {
|
|
183
|
-
footer.className = cn('!mt-3 space-x-1.5', footer.className);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (footer && footerButtons && hasSkip) {
|
|
187
|
-
footer.style.display = 'flex';
|
|
188
|
-
const skipBtn = document.createElement('button');
|
|
189
|
-
skipBtn.innerText = skipText;
|
|
190
|
-
skipBtn.className =
|
|
191
|
-
'driver-popover-skip-btn driver-popover-close-btn !text-Colors-Beta-White-80';
|
|
192
|
-
skipBtn.addEventListener('click', () => {
|
|
193
|
-
driverRef.current.destroy();
|
|
194
|
-
onSkip && onSkip();
|
|
195
|
-
});
|
|
196
|
-
footerButtons.className = cn(
|
|
197
|
-
'flex-1 flex justify-end items-center',
|
|
198
|
-
footerButtons.className
|
|
199
|
-
);
|
|
200
|
-
footerButtons.insertBefore(skipBtn, footerButtons.firstChild);
|
|
201
|
-
}
|
|
202
|
-
popover.previousButton.style.display = hasPrevBtn ? 'block' : 'none';
|
|
203
|
-
popover.nextButton.style.display = hasNextBtn ? 'block' : 'none';
|
|
204
|
-
popover.closeButton.style.display = hasCloseBtn ? 'block' : 'none';
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const { progress } = popover;
|
|
208
|
-
if (progress) {
|
|
209
|
-
progress.className = cn(
|
|
210
|
-
'text-sm text-Colors-Beta-White-60 opacity-60',
|
|
211
|
-
progress.className
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
driverRef.current.drive();
|
|
218
|
-
|
|
219
|
-
return () => {
|
|
220
|
-
if (driverRef.current) {
|
|
221
|
-
driverRef.current.destroy();
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
}, [
|
|
225
|
-
steps,
|
|
226
|
-
showProgress,
|
|
227
|
-
hasSkip,
|
|
228
|
-
hasPrevBtn,
|
|
229
|
-
hasNextBtn,
|
|
230
|
-
skipText,
|
|
231
|
-
prevBtnText,
|
|
232
|
-
nextBtnText,
|
|
233
|
-
doneBtnText,
|
|
234
|
-
className,
|
|
235
|
-
onComplete,
|
|
236
|
-
onSkip,
|
|
237
|
-
showOverlay,
|
|
238
|
-
hasCloseBtn,
|
|
239
|
-
buttons,
|
|
240
|
-
]);
|
|
241
|
-
|
|
242
|
-
return null;
|
|
243
|
-
};
|