@yungu-fed/componentlibrary 0.0.1
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 +85 -0
- package/dist/components/Button/index.d.ts +15 -0
- package/dist/components/Popover/index.d.ts +21 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +793 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +31 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/style.css +1 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Component Library
|
|
2
|
+
|
|
3
|
+
基于 Vite + React 的组件库项目
|
|
4
|
+
|
|
5
|
+
## 技术栈
|
|
6
|
+
|
|
7
|
+
- **构建工具**: Vite 5.x
|
|
8
|
+
- **框架**: React 18.2.0
|
|
9
|
+
- **样式**: Less
|
|
10
|
+
- **类型**: TypeScript (可选)
|
|
11
|
+
|
|
12
|
+
## 开发
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# 安装依赖
|
|
16
|
+
npm install
|
|
17
|
+
|
|
18
|
+
# 启动开发服务器
|
|
19
|
+
npm run dev
|
|
20
|
+
|
|
21
|
+
# 构建库
|
|
22
|
+
npm run build
|
|
23
|
+
|
|
24
|
+
# 预览构建产物
|
|
25
|
+
npm run preview
|
|
26
|
+
|
|
27
|
+
# 监听模式构建
|
|
28
|
+
npm run build:watch
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 项目结构
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
componentlibrary/
|
|
35
|
+
├── src/
|
|
36
|
+
│ ├── components/ # 组件目录
|
|
37
|
+
│ │ ├── Button/
|
|
38
|
+
│ │ │ ├── index.js
|
|
39
|
+
│ │ │ └── index.less
|
|
40
|
+
│ │ └── Popover/
|
|
41
|
+
│ │ ├── index.js
|
|
42
|
+
│ │ └── index.less
|
|
43
|
+
│ ├── styles/ # 全局样式
|
|
44
|
+
│ │ └── variables.less
|
|
45
|
+
│ ├── demo/ # 开发演示页面
|
|
46
|
+
│ │ └── index.tsx
|
|
47
|
+
│ └── index.ts # 库入口文件
|
|
48
|
+
├── dist/ # 构建输出目录
|
|
49
|
+
├── vite.config.js # Vite 配置
|
|
50
|
+
└── package.json
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## 使用
|
|
54
|
+
|
|
55
|
+
### 在项目中使用
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# 通过 npm link 本地开发
|
|
59
|
+
cd componentlibrary
|
|
60
|
+
npm link
|
|
61
|
+
|
|
62
|
+
cd ../umiprojects
|
|
63
|
+
npm link @yungu-fed/componentlibrary
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 导入组件
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
import { Button, Popover } from '@yungu-fed/componentlibrary';
|
|
70
|
+
import '@yungu-fed/componentlibrary/style'; // 引入样式
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 构建说明
|
|
74
|
+
|
|
75
|
+
- **ES 模块**: `dist/index.es.js` - 用于现代打包工具
|
|
76
|
+
- **UMD**: `dist/index.umd.js` - 用于浏览器直接引用
|
|
77
|
+
- **类型定义**: `dist/index.d.ts` - TypeScript 类型
|
|
78
|
+
- **样式文件**: `dist/style.css` - 组件样式
|
|
79
|
+
|
|
80
|
+
## 注意事项
|
|
81
|
+
|
|
82
|
+
1. React 和 React-DOM 作为 peerDependencies,需要在宿主项目中安装
|
|
83
|
+
2. 组件库使用 Less,确保宿主项目支持 Less 或引入编译后的 CSS
|
|
84
|
+
3. 开发时使用 `npm run dev` 启动演示页面
|
|
85
|
+
4. 构建时使用 `npm run build` 生成生产版本
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface ButtonProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'color'> {
|
|
4
|
+
type?: string;
|
|
5
|
+
size?: 'small' | 'middle' | 'large' | (string & {});
|
|
6
|
+
color?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
onClick?: React.MouseEventHandler<HTMLSpanElement>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Button 组件(从 umiProjects 迁移)
|
|
12
|
+
* 支持通过 props 设置类型、尺寸、颜色等属性
|
|
13
|
+
*/
|
|
14
|
+
declare const Button: React.FC<ButtonProps>;
|
|
15
|
+
export default Button;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
|
|
3
|
+
export type PopoverPlacement = 'TL' | 'TC' | 'TR' | 'CL' | 'CC' | 'CR' | 'BL' | 'BC' | 'BR' | (string & {});
|
|
4
|
+
export type PopoverTrigger = 'click' | 'hover' | (string & {});
|
|
5
|
+
export interface PopoverProps {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
content?: React.ReactNode;
|
|
8
|
+
placement?: PopoverPlacement;
|
|
9
|
+
offset?: number;
|
|
10
|
+
trigger?: PopoverTrigger;
|
|
11
|
+
visible?: boolean;
|
|
12
|
+
onVisibleChange?: (visible: boolean) => void;
|
|
13
|
+
className?: string;
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Popover 组件(从 umiProjects 迁移)
|
|
18
|
+
* 支持点击和 hover 触发,九宫格定位
|
|
19
|
+
*/
|
|
20
|
+
declare const Popover: React.FC<PopoverProps>;
|
|
21
|
+
export default Popover;
|
package/dist/index.d.ts
ADDED