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
package/README.md
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# MyShell React Library
|
|
2
|
+
|
|
3
|
+
一个基于React和Tailwind CSS的组件库,提供美观、易用的UI组件和Tailwind配置。基于Radix UI和其他现代库构建,提供高度可访问性和可定制性。
|
|
4
|
+
|
|
5
|
+
## 特性
|
|
6
|
+
|
|
7
|
+
- 🎨 精美的UI组件,基于Tailwind CSS和Radix UI
|
|
8
|
+
- 🛠️ TypeScript支持,提供完整的类型定义
|
|
9
|
+
- 📦 易于集成到现有项目中
|
|
10
|
+
- 🔧 可自定义的Tailwind配置
|
|
11
|
+
- 📱 响应式设计,适配各种屏幕尺寸
|
|
12
|
+
- ♿ 高度可访问性,符合WCAG标准
|
|
13
|
+
- 🌙 支持暗色模式
|
|
14
|
+
|
|
15
|
+
## 安装
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install myshell-react-lib
|
|
19
|
+
# 或
|
|
20
|
+
yarn add myshell-react-lib
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 使用方法
|
|
24
|
+
|
|
25
|
+
### 1. 配置Tailwind CSS
|
|
26
|
+
|
|
27
|
+
在你的`tailwind.config.js`文件中引入我们的配置:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
const { preset } = require('myshell-react-lib/dist/tailwind');
|
|
31
|
+
|
|
32
|
+
module.exports = {
|
|
33
|
+
// 继承我们的预设配置
|
|
34
|
+
presets: [preset],
|
|
35
|
+
// 你的自定义配置
|
|
36
|
+
content: ['./src/**/*.{js,jsx,ts,tsx}'],
|
|
37
|
+
theme: {
|
|
38
|
+
extend: {
|
|
39
|
+
// 你的自定义主题扩展
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
plugins: [],
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 2. 使用组件
|
|
47
|
+
|
|
48
|
+
```jsx
|
|
49
|
+
import React from 'react';
|
|
50
|
+
import { Button, Card, Input, Tabs, TabsContent, TabsList, TabsTrigger } from 'myshell-react-lib';
|
|
51
|
+
|
|
52
|
+
const MyComponent = () => {
|
|
53
|
+
return (
|
|
54
|
+
<div>
|
|
55
|
+
<Card
|
|
56
|
+
title="欢迎使用"
|
|
57
|
+
subtitle="这是一个示例卡片"
|
|
58
|
+
>
|
|
59
|
+
<Tabs defaultValue="account">
|
|
60
|
+
<TabsList>
|
|
61
|
+
<TabsTrigger value="account">账户</TabsTrigger>
|
|
62
|
+
<TabsTrigger value="password">密码</TabsTrigger>
|
|
63
|
+
</TabsList>
|
|
64
|
+
<TabsContent value="account">
|
|
65
|
+
<Input
|
|
66
|
+
label="用户名"
|
|
67
|
+
placeholder="请输入用户名"
|
|
68
|
+
fullWidth
|
|
69
|
+
/>
|
|
70
|
+
<div className="mt-4">
|
|
71
|
+
<Button variant="primary">提交</Button>
|
|
72
|
+
</div>
|
|
73
|
+
</TabsContent>
|
|
74
|
+
<TabsContent value="password">
|
|
75
|
+
<Input
|
|
76
|
+
label="密码"
|
|
77
|
+
type="password"
|
|
78
|
+
placeholder="请输入密码"
|
|
79
|
+
fullWidth
|
|
80
|
+
/>
|
|
81
|
+
<div className="mt-4">
|
|
82
|
+
<Button variant="primary">更新密码</Button>
|
|
83
|
+
</div>
|
|
84
|
+
</TabsContent>
|
|
85
|
+
</Tabs>
|
|
86
|
+
</Card>
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export default MyComponent;
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 组件列表
|
|
95
|
+
|
|
96
|
+
我们的组件库包含以下组件:
|
|
97
|
+
|
|
98
|
+
### 基础组件
|
|
99
|
+
- Button - 按钮
|
|
100
|
+
- Input - 输入框
|
|
101
|
+
- Textarea - 文本域
|
|
102
|
+
- Select - 选择器
|
|
103
|
+
- Checkbox - 复选框
|
|
104
|
+
- Radio - 单选框
|
|
105
|
+
- Switch - 开关
|
|
106
|
+
- Slider - 滑块
|
|
107
|
+
- NumberInput - 数字输入框
|
|
108
|
+
|
|
109
|
+
### 布局组件
|
|
110
|
+
- Card - 卡片
|
|
111
|
+
- AspectRatio - 宽高比
|
|
112
|
+
- Separator - 分隔线
|
|
113
|
+
- Group - 组
|
|
114
|
+
- ScrollArea - 滚动区域
|
|
115
|
+
|
|
116
|
+
### 导航组件
|
|
117
|
+
- Tabs - 标签页
|
|
118
|
+
- NavigationBar - 导航栏
|
|
119
|
+
- SecondaryNavigationBar - 次级导航栏
|
|
120
|
+
- Dropdown - 下拉菜单
|
|
121
|
+
- Menubar - 菜单栏
|
|
122
|
+
- Pagination - 分页
|
|
123
|
+
|
|
124
|
+
### 反馈组件
|
|
125
|
+
- Alert - 警告提示
|
|
126
|
+
- AlertDialog - 警告对话框
|
|
127
|
+
- Dialog - 对话框
|
|
128
|
+
- Drawer - 抽屉
|
|
129
|
+
- Modal - 模态框
|
|
130
|
+
- Toast - 轻提示
|
|
131
|
+
- Progress - 进度条
|
|
132
|
+
- Spinner - 加载中
|
|
133
|
+
- Skeleton - 骨架屏
|
|
134
|
+
|
|
135
|
+
### 数据展示组件
|
|
136
|
+
- Avatar - 头像
|
|
137
|
+
- Badge - 徽章
|
|
138
|
+
- Tooltip - 文字提示
|
|
139
|
+
- Popover - 气泡卡片
|
|
140
|
+
- Image - 图片
|
|
141
|
+
- Swiper - 轮播图
|
|
142
|
+
- Masonry - 瀑布流
|
|
143
|
+
|
|
144
|
+
### 其他组件
|
|
145
|
+
- Form - 表单
|
|
146
|
+
- Command - 命令菜单
|
|
147
|
+
- ContextMenu - 上下文菜单
|
|
148
|
+
- CountDown - 倒计时
|
|
149
|
+
- AudioPlayer - 音频播放器
|
|
150
|
+
- Typography - 排版
|
|
151
|
+
|
|
152
|
+
## 详细组件文档
|
|
153
|
+
|
|
154
|
+
### Button
|
|
155
|
+
|
|
156
|
+
按钮组件,支持多种变体和尺寸。
|
|
157
|
+
|
|
158
|
+
```jsx
|
|
159
|
+
<Button
|
|
160
|
+
variant="primary" // 'primary' | 'secondary' | 'outline' | 'ghost' | 'link' | 'plain'
|
|
161
|
+
size="md" // 'sm' | 'md' | 'lg'
|
|
162
|
+
fullWidth={false}
|
|
163
|
+
rounded={false}
|
|
164
|
+
disabled={false}
|
|
165
|
+
loading={false}
|
|
166
|
+
icon={IconComponent}
|
|
167
|
+
iconDirection="left" // 'left' | 'right'
|
|
168
|
+
>
|
|
169
|
+
按钮文本
|
|
170
|
+
</Button>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Input
|
|
174
|
+
|
|
175
|
+
输入框组件,支持多种变体和尺寸。
|
|
176
|
+
|
|
177
|
+
```jsx
|
|
178
|
+
<Input
|
|
179
|
+
label="输入框标签"
|
|
180
|
+
helperText="帮助文本"
|
|
181
|
+
error="错误信息"
|
|
182
|
+
size="md" // 'sm' | 'md' | 'lg'
|
|
183
|
+
variant="outline" // 'outline' | 'filled' | 'flushed'
|
|
184
|
+
fullWidth={false}
|
|
185
|
+
disabled={false}
|
|
186
|
+
readOnly={false}
|
|
187
|
+
required={false}
|
|
188
|
+
placeholder="请输入..."
|
|
189
|
+
leftIcon={<IconComponent />}
|
|
190
|
+
rightIcon={<IconComponent />}
|
|
191
|
+
/>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Tabs
|
|
195
|
+
|
|
196
|
+
标签页组件,用于在不同内容区域之间切换。
|
|
197
|
+
|
|
198
|
+
```jsx
|
|
199
|
+
<Tabs defaultValue="tab1">
|
|
200
|
+
<TabsList>
|
|
201
|
+
<TabsTrigger value="tab1">标签1</TabsTrigger>
|
|
202
|
+
<TabsTrigger value="tab2">标签2</TabsTrigger>
|
|
203
|
+
</TabsList>
|
|
204
|
+
<TabsContent value="tab1">
|
|
205
|
+
标签1内容
|
|
206
|
+
</TabsContent>
|
|
207
|
+
<TabsContent value="tab2">
|
|
208
|
+
标签2内容
|
|
209
|
+
</TabsContent>
|
|
210
|
+
</Tabs>
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Toast
|
|
214
|
+
|
|
215
|
+
轻提示组件,用于显示简短的消息通知。
|
|
216
|
+
|
|
217
|
+
```jsx
|
|
218
|
+
import { useToast } from 'myshell-react-lib';
|
|
219
|
+
|
|
220
|
+
function MyComponent() {
|
|
221
|
+
const { toast } = useToast();
|
|
222
|
+
|
|
223
|
+
return (
|
|
224
|
+
<Button
|
|
225
|
+
onClick={() => {
|
|
226
|
+
toast({
|
|
227
|
+
title: "成功",
|
|
228
|
+
description: "操作已完成",
|
|
229
|
+
variant: "success",
|
|
230
|
+
})
|
|
231
|
+
}}
|
|
232
|
+
>
|
|
233
|
+
显示提示
|
|
234
|
+
</Button>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Tailwind 主题
|
|
240
|
+
|
|
241
|
+
你可以在JavaScript/TypeScript中使用我们导出的主题变量:
|
|
242
|
+
|
|
243
|
+
```js
|
|
244
|
+
import { colors, theme } from 'myshell-react-lib/dist/tailwind';
|
|
245
|
+
|
|
246
|
+
// 使用主题颜色
|
|
247
|
+
console.log(colors.primary[500]); // #0ea5e9
|
|
248
|
+
|
|
249
|
+
// 使用其他主题配置
|
|
250
|
+
console.log(theme.fontFamily.sans); // ['Inter', 'sans-serif']
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## 开发
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
# 安装依赖
|
|
257
|
+
npm install
|
|
258
|
+
|
|
259
|
+
# 启动Storybook开发环境
|
|
260
|
+
npm run storybook
|
|
261
|
+
|
|
262
|
+
# 构建组件库
|
|
263
|
+
npm run build
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## 许可证
|
|
267
|
+
|
|
268
|
+
MIT
|