@aloudata/aloudata-design 0.2.0-beta.7 → 0.2.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 +188 -51
- package/es/Alert/index.d.ts +4 -0
- package/es/Alert/index.js +3 -0
- package/es/Alert/style/index.d.ts +2 -0
- package/es/Alert/style/index.js +2 -0
- package/es/Alert/style/index.less +1 -0
- package/es/Button/style/index.less +113 -63
- package/es/Checkbox/index.d.ts +11 -0
- package/es/Checkbox/index.js +38 -0
- package/es/Checkbox/style/index.d.ts +2 -0
- package/es/Checkbox/style/index.js +2 -0
- package/es/Checkbox/style/index.less +79 -0
- package/es/Col/index.d.ts +4 -0
- package/es/Col/index.js +3 -0
- package/es/Col/style/index.d.ts +2 -0
- package/es/Col/style/index.js +2 -0
- package/es/Col/style/index.less +1 -0
- package/es/ConfigProvider/index.d.ts +3 -0
- package/es/ConfigProvider/index.js +3 -0
- package/es/ConfigProvider/style/index.d.ts +2 -0
- package/es/ConfigProvider/style/index.js +2 -0
- package/es/ConfigProvider/style/index.less +1 -0
- package/es/DatePicker/index.d.ts +4 -0
- package/es/DatePicker/index.js +3 -0
- package/es/DatePicker/style/index.d.ts +2 -0
- package/es/DatePicker/style/index.js +2 -0
- package/es/DatePicker/style/index.less +1 -0
- package/es/Divider/index.d.ts +3 -0
- package/es/Divider/index.js +3 -0
- package/es/Divider/style/index.d.ts +2 -0
- package/es/Divider/style/index.js +2 -0
- package/es/Divider/style/index.less +1 -0
- package/es/Dropdown/Button.d.ts +1 -0
- package/es/Dropdown/Button.js +2 -1
- package/es/Dropdown/index.d.ts +22 -0
- package/es/Dropdown/style/index.d.ts +1 -0
- package/es/Dropdown/style/index.js +1 -0
- package/es/Empty/style/index.less +8 -7
- package/es/Form/index.d.ts +8 -0
- package/es/Form/index.js +3 -0
- package/es/Form/style/index.d.ts +2 -0
- package/es/Form/style/index.js +2 -0
- package/es/Form/style/index.less +1 -0
- package/es/Icon/index.d.ts +3 -0
- package/es/Icon/index.js +5 -2
- package/es/Input/components/Group/index.d.ts +1 -2
- package/es/Input/components/Input/index.d.ts +67 -0
- package/es/Input/components/Input/index.js +38 -0
- package/es/Input/components/Password/index.d.ts +5 -5
- package/es/Input/components/Password/index.js +5 -4
- package/es/Input/components/TextArea/index.d.ts +10 -4
- package/es/Input/components/TextArea/index.js +16 -6
- package/es/Input/index.d.ts +14 -62
- package/es/Input/index.js +4 -40
- package/es/Input/style/index.d.ts +1 -0
- package/es/Input/style/index.js +1 -0
- package/es/Input/style/index.less +44 -12
- package/es/Layout/index.d.ts +4 -0
- package/es/Layout/index.js +3 -0
- package/es/Layout/style/index.d.ts +2 -0
- package/es/Layout/style/index.js +2 -0
- package/es/Layout/style/index.less +1 -0
- package/es/Menu/MenuItem.d.ts +7 -1
- package/es/Menu/style/index.d.ts +1 -0
- package/es/Menu/style/index.js +1 -0
- package/es/Menu/style/index.less +9 -5
- package/es/Message/index.d.ts +4 -0
- package/es/Message/index.js +3 -0
- package/es/Message/style/index.d.ts +2 -0
- package/es/Message/style/index.js +2 -0
- package/es/Message/style/index.less +1 -0
- package/es/Navigator/components/Menu/index.js +2 -2
- package/es/Notification/index.d.ts +3 -0
- package/es/Notification/index.js +3 -0
- package/es/Notification/style/index.d.ts +2 -0
- package/es/Notification/style/index.js +2 -0
- package/es/Notification/style/index.less +1 -0
- package/es/Radio/index.d.ts +4 -0
- package/es/Radio/index.js +3 -0
- package/es/Radio/style/index.d.ts +2 -0
- package/es/Radio/style/index.js +2 -0
- package/es/Radio/style/index.less +1 -0
- package/es/Row/index.d.ts +3 -0
- package/es/Row/index.js +1 -0
- package/es/Row/style/index.d.ts +2 -0
- package/es/Row/style/index.js +2 -0
- package/es/Row/style/index.less +1 -0
- package/es/Select/BaseSelect.js +18 -5
- package/es/Select/OptionsList/OptionItem/RenderLabelIcon.d.ts +2 -1
- package/es/Select/OptionsList/OptionItem/RenderLabelIcon.js +1 -0
- package/es/Select/OptionsList/index.js +13 -20
- package/es/Select/Selector/index.js +13 -9
- package/es/Select/interface.d.ts +10 -2
- package/es/Select/style/index.less +63 -30
- package/es/Skeleton/index.d.ts +3 -0
- package/es/Skeleton/index.js +2 -0
- package/es/Skeleton/style/index.d.ts +2 -0
- package/es/Skeleton/style/index.js +2 -0
- package/es/Skeleton/style/index.less +1 -0
- package/es/Space/index.d.ts +4 -0
- package/es/Space/index.js +3 -0
- package/es/Space/style/index.d.ts +2 -0
- package/es/Space/style/index.js +2 -0
- package/es/Space/style/index.less +1 -0
- package/es/Spin/index.d.ts +4 -0
- package/es/Spin/index.js +2 -0
- package/es/Spin/style/index.d.ts +2 -0
- package/es/Spin/style/index.js +2 -0
- package/es/Spin/style/index.less +1 -0
- package/es/Steps/index.d.ts +3 -0
- package/es/Steps/index.js +2 -0
- package/es/Steps/style/index.d.ts +2 -0
- package/es/Steps/style/index.js +2 -0
- package/es/Steps/style/index.less +1 -0
- package/es/Switch/index.d.ts +4 -0
- package/es/Switch/index.js +2 -0
- package/es/Switch/style/index.d.ts +2 -0
- package/es/Switch/style/index.js +2 -0
- package/es/Switch/style/index.less +1 -0
- package/es/Table/index.d.ts +3 -3
- package/es/Table/index.js +286 -157
- package/es/Table/interface.d.ts +12 -4
- package/es/Table/react-table-config.d.ts +45 -45
- package/es/Table/style/index.less +121 -63
- package/es/Tabs/index.d.ts +5 -0
- package/es/Tabs/index.js +7 -4
- package/es/Tabs/style/index.d.ts +1 -0
- package/es/Tabs/style/index.js +1 -0
- package/es/Tabs/style/index.less +9 -2
- package/es/Tooltip/style/index.less +1 -1
- package/es/Tree/index.d.ts +5 -0
- package/es/Tree/index.js +2 -0
- package/es/Tree/style/index.d.ts +2 -0
- package/es/Tree/style/index.js +2 -0
- package/es/Tree/style/index.less +1 -0
- package/es/Typography/index.d.ts +3 -0
- package/es/Typography/index.js +3 -0
- package/es/Typography/style/index.d.ts +2 -0
- package/es/Typography/style/index.js +2 -0
- package/es/Typography/style/index.less +1 -0
- package/es/Upload/index.d.ts +4 -0
- package/es/Upload/index.js +3 -0
- package/es/Upload/style/index.d.ts +2 -0
- package/es/Upload/style/index.js +2 -0
- package/es/Upload/style/index.less +1 -0
- package/es/_utils/hooks/useControlledState.d.ts +1 -1
- package/es/_utils/hooks/useControlledState.js +11 -11
- package/es/index.d.ts +39 -1
- package/es/index.js +21 -1
- package/es/locale/zh_CN.d.ts +2 -0
- package/es/locale/zh_CN.js +2 -0
- package/es/style/index.d.ts +1 -1
- package/es/style/index.js +1 -1
- package/es/style/themes/default/index.less +1 -1
- package/lib/Alert/index.d.ts +4 -0
- package/lib/Alert/index.js +15 -0
- package/lib/Alert/style/index.d.ts +2 -0
- package/lib/Alert/style/index.js +5 -0
- package/lib/Alert/style/index.less +1 -0
- package/lib/Button/style/index.less +113 -63
- package/lib/Checkbox/index.d.ts +11 -0
- package/lib/Checkbox/index.js +52 -0
- package/lib/Checkbox/style/index.d.ts +2 -0
- package/lib/Checkbox/style/index.js +5 -0
- package/lib/Checkbox/style/index.less +79 -0
- package/lib/Col/index.d.ts +4 -0
- package/lib/Col/index.js +15 -0
- package/lib/Col/style/index.d.ts +2 -0
- package/lib/Col/style/index.js +5 -0
- package/lib/Col/style/index.less +1 -0
- package/lib/ConfigProvider/index.d.ts +3 -0
- package/lib/ConfigProvider/index.js +15 -0
- package/lib/ConfigProvider/style/index.d.ts +2 -0
- package/lib/ConfigProvider/style/index.js +5 -0
- package/lib/ConfigProvider/style/index.less +1 -0
- package/lib/DatePicker/index.d.ts +4 -0
- package/lib/DatePicker/index.js +15 -0
- package/lib/DatePicker/style/index.d.ts +2 -0
- package/lib/DatePicker/style/index.js +5 -0
- package/lib/DatePicker/style/index.less +1 -0
- package/lib/Divider/index.d.ts +3 -0
- package/lib/Divider/index.js +15 -0
- package/lib/Divider/style/index.d.ts +2 -0
- package/lib/Divider/style/index.js +5 -0
- package/lib/Divider/style/index.less +1 -0
- package/lib/Dropdown/Button.d.ts +1 -0
- package/lib/Dropdown/Button.js +2 -0
- package/lib/Dropdown/index.d.ts +22 -0
- package/lib/Dropdown/style/index.d.ts +1 -0
- package/lib/Dropdown/style/index.js +2 -0
- package/lib/Empty/style/index.less +8 -7
- package/lib/Form/index.d.ts +8 -0
- package/lib/Form/index.js +15 -0
- package/lib/Form/style/index.d.ts +2 -0
- package/lib/Form/style/index.js +5 -0
- package/lib/Form/style/index.less +1 -0
- package/lib/Icon/index.d.ts +3 -0
- package/lib/Icon/index.js +11 -3
- package/lib/Input/components/Group/index.d.ts +1 -2
- package/lib/Input/components/Input/index.d.ts +67 -0
- package/lib/Input/components/Input/index.js +51 -0
- package/lib/Input/components/Password/index.d.ts +5 -5
- package/lib/Input/components/Password/index.js +10 -8
- package/lib/Input/components/TextArea/index.d.ts +10 -4
- package/lib/Input/components/TextArea/index.js +18 -7
- package/lib/Input/index.d.ts +14 -62
- package/lib/Input/index.js +4 -42
- package/lib/Input/style/index.d.ts +1 -0
- package/lib/Input/style/index.js +2 -0
- package/lib/Input/style/index.less +44 -12
- package/lib/Layout/index.d.ts +4 -0
- package/lib/Layout/index.js +15 -0
- package/lib/Layout/style/index.d.ts +2 -0
- package/lib/Layout/style/index.js +5 -0
- package/lib/Layout/style/index.less +1 -0
- package/lib/Menu/MenuItem.d.ts +7 -1
- package/lib/Menu/style/index.d.ts +1 -0
- package/lib/Menu/style/index.js +2 -0
- package/lib/Menu/style/index.less +9 -5
- package/lib/Message/index.d.ts +4 -0
- package/lib/Message/index.js +15 -0
- package/lib/Message/style/index.d.ts +2 -0
- package/lib/Message/style/index.js +5 -0
- package/lib/Message/style/index.less +1 -0
- package/lib/Navigator/components/Menu/index.js +2 -2
- package/lib/Notification/index.d.ts +3 -0
- package/lib/Notification/index.js +15 -0
- package/lib/Notification/style/index.d.ts +2 -0
- package/lib/Notification/style/index.js +5 -0
- package/lib/Notification/style/index.less +1 -0
- package/lib/Radio/index.d.ts +4 -0
- package/lib/Radio/index.js +15 -0
- package/lib/Radio/style/index.d.ts +2 -0
- package/lib/Radio/style/index.js +5 -0
- package/lib/Radio/style/index.less +1 -0
- package/lib/Row/index.d.ts +3 -0
- package/lib/Row/index.js +8 -0
- package/lib/Row/style/index.d.ts +2 -0
- package/lib/Row/style/index.js +5 -0
- package/lib/Row/style/index.less +1 -0
- package/lib/Select/BaseSelect.js +18 -5
- package/lib/Select/OptionsList/OptionItem/RenderLabelIcon.d.ts +2 -1
- package/lib/Select/OptionsList/OptionItem/RenderLabelIcon.js +2 -0
- package/lib/Select/OptionsList/index.js +12 -20
- package/lib/Select/Selector/index.js +13 -9
- package/lib/Select/interface.d.ts +10 -2
- package/lib/Select/style/index.less +63 -30
- package/lib/Skeleton/index.d.ts +3 -0
- package/lib/Skeleton/index.js +13 -0
- package/lib/Skeleton/style/index.d.ts +2 -0
- package/lib/Skeleton/style/index.js +5 -0
- package/lib/Skeleton/style/index.less +1 -0
- package/lib/Space/index.d.ts +4 -0
- package/lib/Space/index.js +23 -0
- package/lib/Space/style/index.d.ts +2 -0
- package/lib/Space/style/index.js +5 -0
- package/lib/Space/style/index.less +1 -0
- package/lib/Spin/index.d.ts +4 -0
- package/lib/Spin/index.js +13 -0
- package/lib/Spin/style/index.d.ts +2 -0
- package/lib/Spin/style/index.js +5 -0
- package/lib/Spin/style/index.less +1 -0
- package/lib/Steps/index.d.ts +3 -0
- package/lib/Steps/index.js +13 -0
- package/lib/Steps/style/index.d.ts +2 -0
- package/lib/Steps/style/index.js +5 -0
- package/lib/Steps/style/index.less +1 -0
- package/lib/Switch/index.d.ts +4 -0
- package/lib/Switch/index.js +13 -0
- package/lib/Switch/style/index.d.ts +2 -0
- package/lib/Switch/style/index.js +5 -0
- package/lib/Switch/style/index.less +1 -0
- package/lib/Table/index.d.ts +3 -3
- package/lib/Table/index.js +295 -165
- package/lib/Table/interface.d.ts +12 -4
- package/lib/Table/react-table-config.d.ts +45 -45
- package/lib/Table/style/index.less +121 -63
- package/lib/Tabs/index.d.ts +5 -0
- package/lib/Tabs/index.js +6 -3
- package/lib/Tabs/style/index.d.ts +1 -0
- package/lib/Tabs/style/index.js +2 -0
- package/lib/Tabs/style/index.less +9 -2
- package/lib/Tooltip/style/index.less +1 -1
- package/lib/Tree/index.d.ts +5 -0
- package/lib/Tree/index.js +13 -0
- package/lib/Tree/style/index.d.ts +2 -0
- package/lib/Tree/style/index.js +5 -0
- package/lib/Tree/style/index.less +1 -0
- package/lib/Typography/index.d.ts +3 -0
- package/lib/Typography/index.js +15 -0
- package/lib/Typography/style/index.d.ts +2 -0
- package/lib/Typography/style/index.js +5 -0
- package/lib/Typography/style/index.less +1 -0
- package/lib/Upload/index.d.ts +4 -0
- package/lib/Upload/index.js +15 -0
- package/lib/Upload/style/index.d.ts +2 -0
- package/lib/Upload/style/index.js +5 -0
- package/lib/Upload/style/index.less +1 -0
- package/lib/_utils/hooks/useControlledState.d.ts +1 -1
- package/lib/_utils/hooks/useControlledState.js +11 -11
- package/lib/index.d.ts +39 -1
- package/lib/index.js +160 -0
- package/lib/locale/zh_CN.d.ts +2 -0
- package/lib/locale/zh_CN.js +13 -0
- package/lib/style/index.d.ts +1 -1
- package/lib/style/index.js +1 -1
- package/lib/style/themes/default/index.less +1 -1
- package/package.json +16 -5
package/README.md
CHANGED
|
@@ -1,91 +1,228 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 组件库开发规范
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 简介
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
本文档用于介绍组件库开发相关的规范以及组件库开发过程中的注意事项。
|
|
6
|
+
|
|
7
|
+
## 环境配置
|
|
8
|
+
|
|
9
|
+
组件库开发过程中,需要满足以下条件:
|
|
10
|
+
|
|
11
|
+
Node version >= 16.0.0
|
|
12
|
+
|
|
13
|
+
## 组件库介绍
|
|
14
|
+
|
|
15
|
+
### 1 快速开始
|
|
16
|
+
|
|
17
|
+
#### 安装和启动
|
|
6
18
|
|
|
7
19
|
```bash
|
|
8
|
-
|
|
20
|
+
git clone https://codeup.aliyun.com/60dd34bf4690c27532d3d021/fe/aloudata-design.git
|
|
21
|
+
cd aloudata-design
|
|
22
|
+
yarn install
|
|
23
|
+
yarn start
|
|
9
24
|
```
|
|
10
25
|
|
|
11
|
-
|
|
26
|
+
#### 创建组件模板
|
|
12
27
|
|
|
13
28
|
```bash
|
|
14
|
-
|
|
29
|
+
yarn run cmt //根据指令输入组件名称,创建组件开发模板
|
|
15
30
|
```
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
npm run lint
|
|
19
|
-
```
|
|
20
|
-
打包组件库 通过 `father-build`,
|
|
31
|
+
|
|
32
|
+
#### 组件校验
|
|
21
33
|
|
|
22
34
|
```bash
|
|
23
|
-
|
|
35
|
+
yarn run lint //stylelint、eslint 校验
|
|
24
36
|
```
|
|
25
37
|
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
#### 组件测试
|
|
39
|
+
|
|
28
40
|
```bash
|
|
29
|
-
|
|
41
|
+
yarn run test //单元测试
|
|
30
42
|
```
|
|
31
43
|
|
|
32
|
-
|
|
44
|
+
#### 组件打包
|
|
33
45
|
|
|
34
46
|
```bash
|
|
35
|
-
|
|
47
|
+
yarn run build //打包
|
|
36
48
|
```
|
|
37
|
-
|
|
49
|
+
|
|
50
|
+
#### 组件本地link
|
|
38
51
|
|
|
39
52
|
```bash
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
## 组件开发目录结构
|
|
53
|
+
npm link //将组件库link到本地npm
|
|
54
|
+
// 切换到业务项目目录,·引入组件库
|
|
55
|
+
npm link @aloudata/aloudata-design // 业务项目中引入组件库
|
|
45
56
|
```
|
|
46
57
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
### 2 目录结构
|
|
59
|
+
|
|
60
|
+
```text
|
|
61
|
+
.
|
|
62
|
+
├── README.md --> readme
|
|
63
|
+
├── docs --> 文档目录
|
|
64
|
+
│ └── index.md
|
|
65
|
+
├── jest --> jest 脚本目录
|
|
66
|
+
├── public --> 公共资源目录
|
|
67
|
+
│ ├── ad_logo.png
|
|
68
|
+
│ ├── favicon.ico
|
|
69
|
+
│ └── style
|
|
70
|
+
├── scripts --> 自定义脚本目录
|
|
71
|
+
│ └── createComponentTemplate.mjs
|
|
72
|
+
├── lib --> 组件打包生成的lib目录
|
|
73
|
+
├── es --> 组件打包生成的es目录
|
|
74
|
+
├── src --> 组件目录
|
|
75
|
+
├── tsconfig.json --> tsconfig ts配置文件
|
|
76
|
+
├── .editorconfig
|
|
77
|
+
├── .eslintrc.js --> eslint ts等校验规则配置
|
|
78
|
+
├── .fatherrc.ts ---> father组件打包配置
|
|
79
|
+
├── .prettierrc.js ---> prettier 代码格式化配置
|
|
80
|
+
├── .stylelintrc.json ---> less 校验规则配置
|
|
81
|
+
├── .umirc.js ---> 脚手架配置
|
|
82
|
+
├── commitlint.config.js --> commit 配置规则
|
|
83
|
+
├── typings.d.ts
|
|
84
|
+
├── package-lock.json
|
|
85
|
+
├── package.json
|
|
86
|
+
├── yarn-error.log
|
|
87
|
+
└── yarn.lock
|
|
56
88
|
```
|
|
57
89
|
|
|
58
|
-
###
|
|
90
|
+
### 3 代码风格
|
|
91
|
+
|
|
92
|
+
我们使用eslint+stylelint+prettier 来统一代码风格,同时**需要对vscode做一定的配置**,具体[配置参考](https://docs.dingtalk.com/i/nodes/mM3zoYAw1Rr8D5Nong2XWnZ07y9NpXxD?dontjump=true&iframeQuery=utm_source%3Dportal%26utm_medium%3Dportal_space_file_tree&navQuery=spaceId%3Da0gX104nML97WzeJ&nav=spaces)
|
|
93
|
+
|
|
94
|
+
ts文件使用 *eslint* 校验, 配置文件 .eslintrc.js [查看规则](https://cn.eslint.org/docs/rules/)
|
|
95
|
+
less文件使用 *stylelint* 校验, 配置文件 .stylelintrc.json [查看规则](https://stylelint.bootcss.com/user-guide/rules/list)
|
|
96
|
+
使用 *prettier* 格式化代码,配置文件 .prettierrc.js
|
|
97
|
+
|
|
98
|
+
## 组件开发指南(必读)
|
|
99
|
+
|
|
100
|
+
### 了解组件分类
|
|
101
|
+
|
|
102
|
+
1. 毛坯组件
|
|
103
|
+
原始的未做任何修改的antd组件
|
|
104
|
+
2. 简装组件
|
|
105
|
+
是指在毛坯组件的基础上,只简单了修改了一些颜色、样式等的组件
|
|
106
|
+
3. 精装组件
|
|
107
|
+
所谓精装组件,是指设计师精心设计过组件应用场景和UI的组件,可能基于antd,也可以完全自定义
|
|
108
|
+
|
|
109
|
+
### 单元测试
|
|
110
|
+
|
|
111
|
+
组件开发过程中需要写单测的,建议先写单测,然后进行开发。[了解TDD](https://baike.baidu.com/item/TDD/9064369)
|
|
112
|
+
|
|
113
|
+
哪些情况需要写单元测试:
|
|
114
|
+
|
|
115
|
+
1. 如果是基于antd的组件,但凡组件有api接口变动,必须要写单元测试
|
|
116
|
+
2. 非基于antd的组件,必须要写单元测试
|
|
117
|
+
3. 单元测试需要覆盖组件每一个api接口的各个状态
|
|
118
|
+
4. 单元测试文件以 *.test.tsx* 结尾
|
|
119
|
+
|
|
120
|
+
单元测试参考资料:
|
|
121
|
+
|
|
122
|
+
- [jestjs](https://jestjs.io/zh-Hans/docs/getting-started)
|
|
123
|
+
- [jest-dom](https://testing-library.com/docs/ecosystem-jest-dom/)
|
|
124
|
+
|
|
125
|
+
### 组件开发注意事项
|
|
59
126
|
|
|
60
|
-
|
|
127
|
+
组件开发支持两种模式,基于antd开发和其它自定义开发。
|
|
61
128
|
|
|
129
|
+
**基于antd开发:** 在业务满足的情况下,建议基于antd开发或者rc组件开发。方式是把antd组件引用过来,然后做升级修改之后,再作为ald组件暴露出去
|
|
130
|
+
|
|
131
|
+
**自定义开发:** 当antd组件不满足业务的时候,可以自定义开发,允许引用其它基础组件进行二次开发或者完全自定义组件进行开发。通常是精装组件。
|
|
132
|
+
|
|
133
|
+
组件开发有以下几个**必须要注意**的点
|
|
134
|
+
|
|
135
|
+
1. 组件样式要和组件类进行分离,即在组件开发的过程中,不允许引用css、less等样式组件。样式单独写在style文件夹下。
|
|
136
|
+
2. 组件文档内的api接口展示,是获取组件属性props的接口interface定义来实现的(自定义md表格除外)。组件库脚手架对于组件接口interface有处理,即凡是接口来自于外部库引入的部分,不会被文档api识别,即无法展示。interface接口的每一个想要暴露的属性,都必须要写注释,主要包括类型、描述、默认值等。
|
|
137
|
+
3. 组件简装及以上,必须要写demo样例,用于展示已经支持的样式及功能
|
|
138
|
+
4. 精装组件必须要写单元测试。每一个组件的属性,都要在测例中进行测试,保证在组件的的维护修改过程中,不会出现bug。
|
|
139
|
+
5. 组件由ts编写,必须对外暴露所有可能在业务使用过程中需要的ts类型。
|
|
140
|
+
6. 组件库不使用css-module,请考虑权重问题,禁止出现 **!important** 这样的样式
|
|
141
|
+
|
|
142
|
+
### 组件库文档编写注意事项
|
|
143
|
+
|
|
144
|
+
#### 文档前文frontMatter编写
|
|
145
|
+
|
|
146
|
+
在组件库官网展示的时候,会根据文档头部的信息,对文档进行分类,我们当前的计划是分成三类:设计、文档、组件;
|
|
147
|
+
|
|
148
|
+
在文档头部,使用YAML预发进行编写,用于描述组件的文档的信息,如:
|
|
149
|
+
|
|
150
|
+
```yaml
|
|
151
|
+
---
|
|
152
|
+
nav:
|
|
153
|
+
title: 组件
|
|
154
|
+
path: /components
|
|
155
|
+
title: Select 选择器
|
|
156
|
+
group:
|
|
157
|
+
title: 组件
|
|
158
|
+
---
|
|
62
159
|
```
|
|
63
|
-
@import '~@/Icon/index.less';
|
|
64
160
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
161
|
+
具体参考:[FrontMatter](https://d.umijs.org/zh-CN/config/frontmatter)
|
|
162
|
+
|
|
163
|
+
#### 组件场景用例demo展示
|
|
164
|
+
|
|
165
|
+
每个简装以上组件都需要展示场景用例,写在src/**/demos/文件夹下
|
|
166
|
+
demo项目中,像在业务中使用aloudata-design一样,脚手架会自动关联项目到node-modules下。(建议先build一下,然后再进行demo展示)
|
|
167
|
+
在组件的md文档中使用code引入用例,在文档中展示用例,如:
|
|
168
|
+
|
|
169
|
+
```jsx
|
|
170
|
+
<code src="./demos/single/index.tsx" title="单项选择"/>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
关于demo的配置,即code的用法,请参考[demo配置](https://d.umijs.org/zh-CN/config/frontmatter#demo-%E9%85%8D%E7%BD%AE%E9%A1%B9)
|
|
174
|
+
|
|
175
|
+
#### 组件api展示
|
|
176
|
+
|
|
177
|
+
api展示为表格形势,可以使用**API**标签,如:
|
|
178
|
+
|
|
179
|
+
```jsx
|
|
180
|
+
<API src="/path/to/your/component.tsx" hideTitle></API>
|
|
70
181
|
```
|
|
71
182
|
|
|
72
|
-
|
|
183
|
+
参考文档:[API](https://d.umijs.org/zh-CN/guide/advanced#%E5%9C%A8%E6%96%87%E6%A1%A3%E4%B8%AD%E5%B1%95%E7%A4%BA-api)
|
|
73
184
|
|
|
74
|
-
|
|
185
|
+
也可以自己使用md语法写表格
|
|
186
|
+
|
|
187
|
+
```md
|
|
188
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
189
|
+
| ---- | ---- | ---- | ---- |
|
|
190
|
+
| value | 某个值 | string | 当前选中的值 |
|
|
191
|
+
```
|
|
75
192
|
|
|
76
|
-
|
|
193
|
+
### 关于组件模板创建
|
|
77
194
|
|
|
78
|
-
|
|
195
|
+
使用 *npm run cmt* 创建的组件模板只是做一个参考,需要自己根据实际需求进行修改
|
|
79
196
|
|
|
80
|
-
|
|
197
|
+
## 关于组件库打包
|
|
81
198
|
|
|
82
|
-
|
|
199
|
+
### 一、组件打包
|
|
83
200
|
|
|
201
|
+
```bash
|
|
202
|
+
npm run build
|
|
84
203
|
```
|
|
85
|
-
npm link
|
|
86
|
-
//转到 目标项目
|
|
87
|
-
npm link @aloudata/aloudata-design
|
|
88
204
|
|
|
89
|
-
|
|
90
|
-
|
|
205
|
+
组件打包的入口在src/index.tsx,必须在文件总暴露出来,组件才会被打包。
|
|
206
|
+
组件打包使用umi框架的 [falter](https://github.com/umijs/father) 打包工具, 具体配置在 .fatherrc.ts中。打包后会生成lib目录,es目录。
|
|
207
|
+
|
|
208
|
+
### 二、官方网站打包
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
npm run docs:build
|
|
91
212
|
```
|
|
213
|
+
|
|
214
|
+
官网打包我们默认使用dumi站点模式,会分为设计、文档、组件三个版块,其中设计和文档版块的内容在docs目录下,组件版块的内容在src/**/*.test.md文件中。
|
|
215
|
+
|
|
216
|
+
1. 设计部分用于描述组件的设计理念,内容由设计师提供,可以是链接,也可以是资料等。
|
|
217
|
+
2. 文档用于描述组件库开发的一些信息等。
|
|
218
|
+
3. 组件用于展示组件的使用场景用例,组件的一些信息,组件的api接口等
|
|
219
|
+
|
|
220
|
+
### 官方网站样式修改
|
|
221
|
+
|
|
222
|
+
请在./public/style/common.css 中自定义修改样式
|
|
223
|
+
|
|
224
|
+
## 组件开发踩过的坑(持续更新中)
|
|
225
|
+
|
|
226
|
+
1. 组件未暴露className
|
|
227
|
+
2. 组件未暴露ref
|
|
228
|
+
3. 组件未打包出ts校验类型
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import '../../style/index.less';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
@import '../../style/index.less';
|
|
2
2
|
|
|
3
|
-
@ald-prefix:ant;
|
|
4
|
-
@ald-iconfont-css-prefix:anticon;
|
|
5
|
-
.@{ald-prefix}-btn {
|
|
3
|
+
@ald-prefix: ant;
|
|
4
|
+
@ald-iconfont-css-prefix: anticon;
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
.ant-btn {
|
|
7
|
+
&.ant-btn {
|
|
8
8
|
// &-loading::before{
|
|
9
9
|
// // display: none !important;
|
|
10
10
|
// }
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
&-secondary,
|
|
15
15
|
&-text,
|
|
16
16
|
&-link {
|
|
17
|
-
font-size: 12px;
|
|
18
|
-
height: @height-base;
|
|
19
|
-
padding: 0 12px;
|
|
20
17
|
display: inline-flex;
|
|
21
|
-
line-height: @height-base;
|
|
22
18
|
align-items: center;
|
|
23
|
-
font-weight: 500;
|
|
24
19
|
justify-content: center;
|
|
20
|
+
height: @height-base;
|
|
21
|
+
padding: 0 11px;
|
|
22
|
+
font-weight: 500;
|
|
23
|
+
font-size: 12px;
|
|
24
|
+
line-height: @height-base;
|
|
25
25
|
.@{ald-iconfont-css-prefix} {
|
|
26
26
|
+ span {
|
|
27
27
|
margin-left: 4px;
|
|
@@ -38,171 +38,216 @@
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
&-primary {
|
|
41
|
+
text-shadow: @text-shadow;
|
|
41
42
|
background-color: @B40;
|
|
42
43
|
border-color: @B40;
|
|
43
|
-
box-shadow: none;
|
|
44
44
|
border-radius: @border-radius-base;
|
|
45
|
-
|
|
45
|
+
box-shadow: none;
|
|
46
|
+
|
|
47
|
+
&:focus {
|
|
48
|
+
text-shadow: @text-shadow;
|
|
49
|
+
background-color: @B40;
|
|
50
|
+
border-color: @B40;
|
|
51
|
+
border-radius: @border-radius-base;
|
|
52
|
+
box-shadow: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
46
55
|
&:hover,
|
|
47
|
-
&:focus,
|
|
48
56
|
&:active,
|
|
49
|
-
|
|
57
|
+
&.ant-btn-loading {
|
|
58
|
+
color: @ND0;
|
|
50
59
|
background-color: @B20;
|
|
51
60
|
border-color: @B20;
|
|
52
|
-
color: @ND0;
|
|
53
61
|
}
|
|
54
62
|
|
|
55
63
|
&[disabled] {
|
|
64
|
+
color: @NL80;
|
|
56
65
|
background-color: @NL90;
|
|
57
66
|
border-color: transparent;
|
|
58
|
-
|
|
67
|
+
cursor: default;
|
|
59
68
|
|
|
60
69
|
&:hover,
|
|
61
70
|
&:focus,
|
|
62
71
|
&:active {
|
|
72
|
+
color: @NL80;
|
|
63
73
|
background-color: @NL90;
|
|
64
74
|
border-color: transparent;
|
|
65
|
-
color: @NL80;
|
|
66
75
|
}
|
|
67
76
|
}
|
|
68
77
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
border-color: @SC40;
|
|
78
|
+
|
|
79
|
+
&-dangerous.ant-btn-primary {
|
|
72
80
|
color: @ND0;
|
|
73
81
|
text-shadow: @text-shadow;
|
|
82
|
+
background-color: @SC40;
|
|
83
|
+
border-color: @SC40;
|
|
74
84
|
box-shadow: unset;
|
|
75
85
|
|
|
76
|
-
&:
|
|
77
|
-
background-color: @SC20;
|
|
78
|
-
border-color: @SC20;
|
|
86
|
+
&:focus {
|
|
79
87
|
color: @ND0;
|
|
88
|
+
text-shadow: @text-shadow;
|
|
89
|
+
background-color: @SC40;
|
|
90
|
+
border-color: @SC40;
|
|
91
|
+
box-shadow: unset;
|
|
80
92
|
}
|
|
81
|
-
|
|
93
|
+
|
|
94
|
+
&:hover,
|
|
82
95
|
&:active,
|
|
83
|
-
|
|
96
|
+
&.ant-btn-loading {
|
|
97
|
+
color: @ND0;
|
|
84
98
|
background-color: @SC20;
|
|
85
99
|
border-color: @SC20;
|
|
86
|
-
color: @ND0;
|
|
87
100
|
}
|
|
88
101
|
|
|
89
102
|
&[disabled] {
|
|
103
|
+
color: @NL80;
|
|
90
104
|
background-color: @NL90;
|
|
91
105
|
border-color: transparent;
|
|
92
|
-
|
|
106
|
+
cursor: default;
|
|
93
107
|
|
|
94
108
|
&:hover,
|
|
95
109
|
&:focus,
|
|
96
110
|
&:active {
|
|
111
|
+
color: @NL80;
|
|
97
112
|
background-color: @NL90;
|
|
98
113
|
border-color: transparent;
|
|
99
|
-
color: @NL80;
|
|
100
114
|
}
|
|
101
115
|
}
|
|
102
116
|
}
|
|
103
117
|
|
|
104
118
|
&-secondary {
|
|
119
|
+
color: @NL30;
|
|
120
|
+
text-shadow: @text-shadow;
|
|
105
121
|
background-color: @BG100;
|
|
106
122
|
border-color: @NL90;
|
|
107
|
-
color: @NL30;
|
|
108
|
-
box-shadow: none;
|
|
109
123
|
border-radius: @border-radius-base;
|
|
110
|
-
|
|
124
|
+
box-shadow: none;
|
|
125
|
+
|
|
126
|
+
&:focus {
|
|
127
|
+
color: @NL30;
|
|
128
|
+
text-shadow: @text-shadow;
|
|
129
|
+
background-color: @BG100;
|
|
130
|
+
border-color: @NL90;
|
|
131
|
+
border-radius: @border-radius-base;
|
|
132
|
+
box-shadow: none;
|
|
133
|
+
}
|
|
111
134
|
|
|
112
135
|
&:hover,
|
|
113
|
-
&:focus,
|
|
114
136
|
&:active,
|
|
115
|
-
|
|
137
|
+
&.ant-btn-loading {
|
|
138
|
+
color: @NL30;
|
|
116
139
|
background-color: @NL97;
|
|
117
140
|
border-color: @NL90;
|
|
118
|
-
color: @NL30;
|
|
119
141
|
}
|
|
120
142
|
|
|
121
143
|
&[disabled] {
|
|
144
|
+
color: @NL80;
|
|
122
145
|
background-color: @BG100;
|
|
123
146
|
border-color: @NL90;
|
|
124
|
-
|
|
147
|
+
cursor: default;
|
|
125
148
|
|
|
126
149
|
&:hover,
|
|
127
150
|
&:focus,
|
|
128
151
|
&:active {
|
|
152
|
+
color: @NL80;
|
|
129
153
|
background-color: @BG100;
|
|
130
154
|
border-color: @NL90;
|
|
131
|
-
color: @NL80;
|
|
132
155
|
}
|
|
133
156
|
}
|
|
134
157
|
}
|
|
135
158
|
|
|
136
159
|
&-text {
|
|
160
|
+
color: @NL30;
|
|
161
|
+
text-shadow: @text-shadow;
|
|
137
162
|
background-color: @BG100;
|
|
138
163
|
border-color: @BG100;
|
|
139
|
-
color: @NL30;
|
|
140
|
-
box-shadow: none;
|
|
141
164
|
border-radius: @border-radius-base;
|
|
142
|
-
|
|
165
|
+
box-shadow: none;
|
|
166
|
+
|
|
167
|
+
&:focus {
|
|
168
|
+
color: @NL30;
|
|
169
|
+
text-shadow: @text-shadow;
|
|
170
|
+
background-color: @BG100;
|
|
171
|
+
border-color: @BG100;
|
|
172
|
+
border-radius: @border-radius-base;
|
|
173
|
+
box-shadow: none;
|
|
174
|
+
}
|
|
175
|
+
|
|
143
176
|
&:hover,
|
|
144
|
-
&:focus,
|
|
145
177
|
&:active,
|
|
146
|
-
|
|
147
|
-
background-color: @NL97;
|
|
178
|
+
&.ant-btn-loading {
|
|
148
179
|
// border-color: @NL97;
|
|
149
180
|
color: @NL30;
|
|
181
|
+
background-color: @NL97;
|
|
150
182
|
}
|
|
151
183
|
|
|
152
184
|
&[disabled] {
|
|
185
|
+
color: @NL80;
|
|
153
186
|
background-color: transparent;
|
|
154
187
|
border-color: transparent;
|
|
155
|
-
|
|
188
|
+
cursor: default;
|
|
156
189
|
|
|
157
190
|
&:hover,
|
|
158
191
|
&:focus,
|
|
159
192
|
&:active {
|
|
193
|
+
color: @NL80;
|
|
160
194
|
background-color: transparent;
|
|
161
195
|
border-color: transparent;
|
|
162
|
-
color: @NL80;
|
|
163
196
|
}
|
|
164
197
|
}
|
|
165
198
|
}
|
|
166
199
|
|
|
167
200
|
&-link {
|
|
168
|
-
background-color: @BG100;
|
|
169
|
-
border-color: @BG100;
|
|
170
201
|
color: @B40;
|
|
171
202
|
font-weight: 400;
|
|
172
|
-
box-shadow: none;
|
|
173
|
-
border-radius: @border-radius-base;
|
|
174
203
|
text-shadow: @text-shadow;
|
|
204
|
+
background-color: @BG100;
|
|
205
|
+
border-color: @BG100;
|
|
206
|
+
border-radius: @border-radius-base;
|
|
207
|
+
box-shadow: none;
|
|
208
|
+
|
|
209
|
+
&:focus {
|
|
210
|
+
color: @B40;
|
|
211
|
+
font-weight: 400;
|
|
212
|
+
text-shadow: @text-shadow;
|
|
213
|
+
background-color: @BG100;
|
|
214
|
+
border-color: @BG100;
|
|
215
|
+
border-radius: @border-radius-base;
|
|
216
|
+
box-shadow: none;
|
|
217
|
+
}
|
|
218
|
+
|
|
175
219
|
&:hover,
|
|
176
|
-
&:focus,
|
|
177
220
|
&:active,
|
|
178
|
-
|
|
221
|
+
&.ant-btn-loading {
|
|
222
|
+
color: @B20;
|
|
179
223
|
background-color: @BG100;
|
|
180
224
|
border-color: @BG100;
|
|
181
|
-
color: @B20;
|
|
182
225
|
}
|
|
183
226
|
|
|
184
227
|
&[disabled] {
|
|
228
|
+
color: @NL80;
|
|
185
229
|
background-color: transparent;
|
|
186
230
|
border-color: transparent;
|
|
187
|
-
|
|
231
|
+
cursor: default;
|
|
188
232
|
|
|
189
233
|
&:hover,
|
|
190
234
|
&:focus,
|
|
191
235
|
&:active {
|
|
236
|
+
color: @NL80;
|
|
192
237
|
background-color: transparent;
|
|
193
238
|
border-color: transparent;
|
|
194
|
-
color: @NL80;
|
|
195
239
|
}
|
|
196
240
|
}
|
|
197
241
|
}
|
|
198
242
|
|
|
199
243
|
&-icon-only {
|
|
200
244
|
justify-content: center;
|
|
245
|
+
width: @height-base;
|
|
246
|
+
height: @height-base;
|
|
201
247
|
padding: 0;
|
|
202
248
|
vertical-align: bottom;
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
&.@{ald-prefix}-btn-loading-icon {
|
|
249
|
+
|
|
250
|
+
&.ant-btn-loading-icon {
|
|
206
251
|
vertical-align: baseline;
|
|
207
252
|
}
|
|
208
253
|
.@{ald-iconfont-css-prefix} {
|
|
@@ -214,23 +259,25 @@
|
|
|
214
259
|
}
|
|
215
260
|
|
|
216
261
|
&-circle {
|
|
262
|
+
justify-content: center;
|
|
217
263
|
width: @height-base;
|
|
218
264
|
min-width: auto;
|
|
219
265
|
padding: 0;
|
|
220
|
-
justify-content: center;
|
|
221
266
|
border-radius: 50%;
|
|
222
267
|
}
|
|
223
268
|
|
|
224
269
|
&-lg {
|
|
270
|
+
min-width: auto;
|
|
225
271
|
height: 32px;
|
|
226
272
|
font-size: 14px;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
height: 32px;
|
|
273
|
+
|
|
274
|
+
&.ant-btn-icon-only {
|
|
230
275
|
width: 32px;
|
|
231
276
|
min-width: auto;
|
|
277
|
+
height: 32px;
|
|
232
278
|
}
|
|
233
|
-
|
|
279
|
+
|
|
280
|
+
&.ant-btn-circle {
|
|
234
281
|
width: 32px;
|
|
235
282
|
height: 32px;
|
|
236
283
|
border-radius: 50%;
|
|
@@ -239,13 +286,16 @@
|
|
|
239
286
|
|
|
240
287
|
&-sm {
|
|
241
288
|
height: 24px;
|
|
289
|
+
line-height: 22px;
|
|
242
290
|
border-radius: @border-radius-sm;
|
|
243
|
-
|
|
244
|
-
|
|
291
|
+
|
|
292
|
+
&.ant-btn-icon-only {
|
|
245
293
|
width: 24px;
|
|
294
|
+
height: 24px;
|
|
246
295
|
border-radius: @border-radius-sm;
|
|
247
296
|
}
|
|
248
|
-
|
|
297
|
+
|
|
298
|
+
&.ant-btn-circle {
|
|
249
299
|
width: 32px;
|
|
250
300
|
height: 32px;
|
|
251
301
|
border-radius: 50%;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CheckboxProps } from 'antd';
|
|
3
|
+
import { CheckboxGroupProps } from 'antd/lib/checkbox';
|
|
4
|
+
export type { CheckboxValueType, CheckboxOptionType } from 'antd/es/checkbox/Group';
|
|
5
|
+
export type { CheckboxChangeEvent } from 'antd/es/checkbox/Checkbox';
|
|
6
|
+
declare function Checkbox(props: CheckboxProps): JSX.Element;
|
|
7
|
+
declare namespace Checkbox {
|
|
8
|
+
var Group: (props: CheckboxGroupProps) => JSX.Element;
|
|
9
|
+
}
|
|
10
|
+
export type { CheckboxProps };
|
|
11
|
+
export default Checkbox;
|