@aloudata/aloudata-design 0.2.0-beta.8 → 0.2.2

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 (306) hide show
  1. package/README.md +188 -51
  2. package/es/Alert/index.d.ts +4 -0
  3. package/es/Alert/index.js +3 -0
  4. package/es/Alert/style/index.d.ts +2 -0
  5. package/es/Alert/style/index.js +2 -0
  6. package/es/Alert/style/index.less +1 -0
  7. package/es/Button/style/index.less +90 -50
  8. package/es/Checkbox/index.d.ts +11 -0
  9. package/es/Checkbox/index.js +38 -0
  10. package/es/Checkbox/style/index.d.ts +2 -0
  11. package/es/Checkbox/style/index.js +2 -0
  12. package/es/Checkbox/style/index.less +79 -0
  13. package/es/Col/index.d.ts +4 -0
  14. package/es/Col/index.js +3 -0
  15. package/es/Col/style/index.d.ts +2 -0
  16. package/es/Col/style/index.js +2 -0
  17. package/es/Col/style/index.less +1 -0
  18. package/es/ConfigProvider/index.d.ts +3 -0
  19. package/es/ConfigProvider/index.js +3 -0
  20. package/es/ConfigProvider/style/index.d.ts +2 -0
  21. package/es/ConfigProvider/style/index.js +2 -0
  22. package/es/ConfigProvider/style/index.less +1 -0
  23. package/es/DatePicker/index.d.ts +4 -0
  24. package/es/DatePicker/index.js +3 -0
  25. package/es/DatePicker/style/index.d.ts +2 -0
  26. package/es/DatePicker/style/index.js +2 -0
  27. package/es/DatePicker/style/index.less +1 -0
  28. package/es/Divider/index.d.ts +3 -0
  29. package/es/Divider/index.js +3 -0
  30. package/es/Divider/style/index.d.ts +2 -0
  31. package/es/Divider/style/index.js +2 -0
  32. package/es/Divider/style/index.less +1 -0
  33. package/es/Dropdown/Button.d.ts +1 -0
  34. package/es/Dropdown/Button.js +2 -1
  35. package/es/Dropdown/index.d.ts +27 -0
  36. package/es/Dropdown/style/index.d.ts +1 -0
  37. package/es/Dropdown/style/index.js +1 -0
  38. package/es/Empty/style/index.less +6 -6
  39. package/es/Form/index.d.ts +8 -0
  40. package/es/Form/index.js +3 -0
  41. package/es/Form/style/index.d.ts +2 -0
  42. package/es/Form/style/index.js +2 -0
  43. package/es/Form/style/index.less +1 -0
  44. package/es/Icon/index.d.ts +3 -0
  45. package/es/Icon/index.js +2 -1
  46. package/es/Input/components/Group/index.d.ts +1 -2
  47. package/es/Input/components/Input/index.d.ts +67 -0
  48. package/es/Input/components/Input/index.js +38 -0
  49. package/es/Input/components/Password/index.d.ts +5 -5
  50. package/es/Input/components/Password/index.js +5 -4
  51. package/es/Input/components/TextArea/index.d.ts +10 -4
  52. package/es/Input/components/TextArea/index.js +16 -6
  53. package/es/Input/index.d.ts +14 -62
  54. package/es/Input/index.js +4 -40
  55. package/es/Input/style/index.d.ts +1 -0
  56. package/es/Input/style/index.js +1 -0
  57. package/es/Input/style/index.less +40 -10
  58. package/es/Layout/index.d.ts +4 -0
  59. package/es/Layout/index.js +3 -0
  60. package/es/Layout/style/index.d.ts +2 -0
  61. package/es/Layout/style/index.js +2 -0
  62. package/es/Layout/style/index.less +1 -0
  63. package/es/Menu/MenuItem.d.ts +7 -1
  64. package/es/Menu/style/index.d.ts +1 -0
  65. package/es/Menu/style/index.js +1 -0
  66. package/es/Menu/style/index.less +9 -5
  67. package/es/Message/index.d.ts +4 -0
  68. package/es/Message/index.js +3 -0
  69. package/es/Message/style/index.d.ts +2 -0
  70. package/es/Message/style/index.js +2 -0
  71. package/es/Message/style/index.less +1 -0
  72. package/es/Navigator/components/Menu/index.js +2 -2
  73. package/es/Notification/index.d.ts +3 -0
  74. package/es/Notification/index.js +3 -0
  75. package/es/Notification/style/index.d.ts +2 -0
  76. package/es/Notification/style/index.js +2 -0
  77. package/es/Notification/style/index.less +1 -0
  78. package/es/Radio/index.d.ts +4 -0
  79. package/es/Radio/index.js +3 -0
  80. package/es/Radio/style/index.d.ts +2 -0
  81. package/es/Radio/style/index.js +2 -0
  82. package/es/Radio/style/index.less +1 -0
  83. package/es/Row/index.d.ts +3 -0
  84. package/es/Row/index.js +3 -0
  85. package/es/Row/style/index.d.ts +2 -0
  86. package/es/Row/style/index.js +2 -0
  87. package/es/Row/style/index.less +1 -0
  88. package/es/Select/BaseSelect.js +18 -5
  89. package/es/Select/OptionsList/OptionItem/RenderLabelIcon.d.ts +2 -1
  90. package/es/Select/OptionsList/OptionItem/RenderLabelIcon.js +1 -0
  91. package/es/Select/OptionsList/index.js +13 -20
  92. package/es/Select/Selector/index.js +13 -9
  93. package/es/Select/interface.d.ts +10 -2
  94. package/es/Select/style/index.less +63 -30
  95. package/es/Skeleton/index.d.ts +3 -0
  96. package/es/Skeleton/index.js +2 -0
  97. package/es/Skeleton/style/index.d.ts +2 -0
  98. package/es/Skeleton/style/index.js +2 -0
  99. package/es/Skeleton/style/index.less +1 -0
  100. package/es/Space/index.d.ts +4 -0
  101. package/es/Space/index.js +3 -0
  102. package/es/Space/style/index.d.ts +2 -0
  103. package/es/Space/style/index.js +2 -0
  104. package/es/Space/style/index.less +1 -0
  105. package/es/Spin/index.d.ts +4 -0
  106. package/es/Spin/index.js +2 -0
  107. package/es/Spin/style/index.d.ts +2 -0
  108. package/es/Spin/style/index.js +2 -0
  109. package/es/Spin/style/index.less +1 -0
  110. package/es/Steps/index.d.ts +3 -0
  111. package/es/Steps/index.js +2 -0
  112. package/es/Steps/style/index.d.ts +2 -0
  113. package/es/Steps/style/index.js +2 -0
  114. package/es/Steps/style/index.less +1 -0
  115. package/es/Switch/index.d.ts +4 -0
  116. package/es/Switch/index.js +2 -0
  117. package/es/Switch/style/index.d.ts +2 -0
  118. package/es/Switch/style/index.js +2 -0
  119. package/es/Switch/style/index.less +1 -0
  120. package/es/Table/index.d.ts +3 -3
  121. package/es/Table/index.js +286 -157
  122. package/es/Table/interface.d.ts +12 -4
  123. package/es/Table/react-table-config.d.ts +45 -45
  124. package/es/Table/style/index.less +89 -39
  125. package/es/Tabs/index.d.ts +5 -0
  126. package/es/Tabs/index.js +7 -4
  127. package/es/Tabs/style/index.d.ts +1 -0
  128. package/es/Tabs/style/index.js +1 -0
  129. package/es/Tabs/style/index.less +9 -2
  130. package/es/Tooltip/style/index.less +1 -1
  131. package/es/Tree/index.d.ts +5 -0
  132. package/es/Tree/index.js +2 -0
  133. package/es/Tree/style/index.d.ts +2 -0
  134. package/es/Tree/style/index.js +2 -0
  135. package/es/Tree/style/index.less +1 -0
  136. package/es/Typography/index.d.ts +3 -0
  137. package/es/Typography/index.js +3 -0
  138. package/es/Typography/style/index.d.ts +2 -0
  139. package/es/Typography/style/index.js +2 -0
  140. package/es/Typography/style/index.less +1 -0
  141. package/es/Upload/index.d.ts +4 -0
  142. package/es/Upload/index.js +3 -0
  143. package/es/Upload/style/index.d.ts +2 -0
  144. package/es/Upload/style/index.js +2 -0
  145. package/es/Upload/style/index.less +1 -0
  146. package/es/_utils/hooks/useControlledState.d.ts +1 -1
  147. package/es/_utils/hooks/useControlledState.js +11 -11
  148. package/es/index.d.ts +39 -1
  149. package/es/index.js +21 -1
  150. package/es/locale/zh_CN.d.ts +2 -0
  151. package/es/locale/zh_CN.js +2 -0
  152. package/es/style/index.d.ts +1 -1
  153. package/es/style/index.js +1 -1
  154. package/lib/Alert/index.d.ts +4 -0
  155. package/lib/Alert/index.js +15 -0
  156. package/lib/Alert/style/index.d.ts +2 -0
  157. package/lib/Alert/style/index.js +5 -0
  158. package/lib/Alert/style/index.less +1 -0
  159. package/lib/Button/style/index.less +90 -50
  160. package/lib/Checkbox/index.d.ts +11 -0
  161. package/lib/Checkbox/index.js +52 -0
  162. package/lib/Checkbox/style/index.d.ts +2 -0
  163. package/lib/Checkbox/style/index.js +5 -0
  164. package/lib/Checkbox/style/index.less +79 -0
  165. package/lib/Col/index.d.ts +4 -0
  166. package/lib/Col/index.js +15 -0
  167. package/lib/Col/style/index.d.ts +2 -0
  168. package/lib/Col/style/index.js +5 -0
  169. package/lib/Col/style/index.less +1 -0
  170. package/lib/ConfigProvider/index.d.ts +3 -0
  171. package/lib/ConfigProvider/index.js +15 -0
  172. package/lib/ConfigProvider/style/index.d.ts +2 -0
  173. package/lib/ConfigProvider/style/index.js +5 -0
  174. package/lib/ConfigProvider/style/index.less +1 -0
  175. package/lib/DatePicker/index.d.ts +4 -0
  176. package/lib/DatePicker/index.js +15 -0
  177. package/lib/DatePicker/style/index.d.ts +2 -0
  178. package/lib/DatePicker/style/index.js +5 -0
  179. package/lib/DatePicker/style/index.less +1 -0
  180. package/lib/Divider/index.d.ts +3 -0
  181. package/lib/Divider/index.js +15 -0
  182. package/lib/Divider/style/index.d.ts +2 -0
  183. package/lib/Divider/style/index.js +5 -0
  184. package/lib/Divider/style/index.less +1 -0
  185. package/lib/Dropdown/Button.d.ts +1 -0
  186. package/lib/Dropdown/Button.js +2 -0
  187. package/lib/Dropdown/index.d.ts +27 -0
  188. package/lib/Dropdown/style/index.d.ts +1 -0
  189. package/lib/Dropdown/style/index.js +2 -0
  190. package/lib/Empty/style/index.less +6 -6
  191. package/lib/Form/index.d.ts +8 -0
  192. package/lib/Form/index.js +15 -0
  193. package/lib/Form/style/index.d.ts +2 -0
  194. package/lib/Form/style/index.js +5 -0
  195. package/lib/Form/style/index.less +1 -0
  196. package/lib/Icon/index.d.ts +3 -0
  197. package/lib/Icon/index.js +6 -0
  198. package/lib/Input/components/Group/index.d.ts +1 -2
  199. package/lib/Input/components/Input/index.d.ts +67 -0
  200. package/lib/Input/components/Input/index.js +51 -0
  201. package/lib/Input/components/Password/index.d.ts +5 -5
  202. package/lib/Input/components/Password/index.js +10 -8
  203. package/lib/Input/components/TextArea/index.d.ts +10 -4
  204. package/lib/Input/components/TextArea/index.js +18 -7
  205. package/lib/Input/index.d.ts +14 -62
  206. package/lib/Input/index.js +4 -42
  207. package/lib/Input/style/index.d.ts +1 -0
  208. package/lib/Input/style/index.js +2 -0
  209. package/lib/Input/style/index.less +40 -10
  210. package/lib/Layout/index.d.ts +4 -0
  211. package/lib/Layout/index.js +15 -0
  212. package/lib/Layout/style/index.d.ts +2 -0
  213. package/lib/Layout/style/index.js +5 -0
  214. package/lib/Layout/style/index.less +1 -0
  215. package/lib/Menu/MenuItem.d.ts +7 -1
  216. package/lib/Menu/style/index.d.ts +1 -0
  217. package/lib/Menu/style/index.js +2 -0
  218. package/lib/Menu/style/index.less +9 -5
  219. package/lib/Message/index.d.ts +4 -0
  220. package/lib/Message/index.js +15 -0
  221. package/lib/Message/style/index.d.ts +2 -0
  222. package/lib/Message/style/index.js +5 -0
  223. package/lib/Message/style/index.less +1 -0
  224. package/lib/Navigator/components/Menu/index.js +2 -2
  225. package/lib/Notification/index.d.ts +3 -0
  226. package/lib/Notification/index.js +15 -0
  227. package/lib/Notification/style/index.d.ts +2 -0
  228. package/lib/Notification/style/index.js +5 -0
  229. package/lib/Notification/style/index.less +1 -0
  230. package/lib/Radio/index.d.ts +4 -0
  231. package/lib/Radio/index.js +15 -0
  232. package/lib/Radio/style/index.d.ts +2 -0
  233. package/lib/Radio/style/index.js +5 -0
  234. package/lib/Radio/style/index.less +1 -0
  235. package/lib/Row/index.d.ts +3 -0
  236. package/lib/Row/index.js +15 -0
  237. package/lib/Row/style/index.d.ts +2 -0
  238. package/lib/Row/style/index.js +5 -0
  239. package/lib/Row/style/index.less +1 -0
  240. package/lib/Select/BaseSelect.js +18 -5
  241. package/lib/Select/OptionsList/OptionItem/RenderLabelIcon.d.ts +2 -1
  242. package/lib/Select/OptionsList/OptionItem/RenderLabelIcon.js +2 -0
  243. package/lib/Select/OptionsList/index.js +12 -20
  244. package/lib/Select/Selector/index.js +13 -9
  245. package/lib/Select/interface.d.ts +10 -2
  246. package/lib/Select/style/index.less +63 -30
  247. package/lib/Skeleton/index.d.ts +3 -0
  248. package/lib/Skeleton/index.js +13 -0
  249. package/lib/Skeleton/style/index.d.ts +2 -0
  250. package/lib/Skeleton/style/index.js +5 -0
  251. package/lib/Skeleton/style/index.less +1 -0
  252. package/lib/Space/index.d.ts +4 -0
  253. package/lib/Space/index.js +23 -0
  254. package/lib/Space/style/index.d.ts +2 -0
  255. package/lib/Space/style/index.js +5 -0
  256. package/lib/Space/style/index.less +1 -0
  257. package/lib/Spin/index.d.ts +4 -0
  258. package/lib/Spin/index.js +13 -0
  259. package/lib/Spin/style/index.d.ts +2 -0
  260. package/lib/Spin/style/index.js +5 -0
  261. package/lib/Spin/style/index.less +1 -0
  262. package/lib/Steps/index.d.ts +3 -0
  263. package/lib/Steps/index.js +13 -0
  264. package/lib/Steps/style/index.d.ts +2 -0
  265. package/lib/Steps/style/index.js +5 -0
  266. package/lib/Steps/style/index.less +1 -0
  267. package/lib/Switch/index.d.ts +4 -0
  268. package/lib/Switch/index.js +13 -0
  269. package/lib/Switch/style/index.d.ts +2 -0
  270. package/lib/Switch/style/index.js +5 -0
  271. package/lib/Switch/style/index.less +1 -0
  272. package/lib/Table/index.d.ts +3 -3
  273. package/lib/Table/index.js +295 -165
  274. package/lib/Table/interface.d.ts +12 -4
  275. package/lib/Table/react-table-config.d.ts +45 -45
  276. package/lib/Table/style/index.less +89 -39
  277. package/lib/Tabs/index.d.ts +5 -0
  278. package/lib/Tabs/index.js +6 -3
  279. package/lib/Tabs/style/index.d.ts +1 -0
  280. package/lib/Tabs/style/index.js +2 -0
  281. package/lib/Tabs/style/index.less +9 -2
  282. package/lib/Tooltip/style/index.less +1 -1
  283. package/lib/Tree/index.d.ts +5 -0
  284. package/lib/Tree/index.js +13 -0
  285. package/lib/Tree/style/index.d.ts +2 -0
  286. package/lib/Tree/style/index.js +5 -0
  287. package/lib/Tree/style/index.less +1 -0
  288. package/lib/Typography/index.d.ts +3 -0
  289. package/lib/Typography/index.js +15 -0
  290. package/lib/Typography/style/index.d.ts +2 -0
  291. package/lib/Typography/style/index.js +5 -0
  292. package/lib/Typography/style/index.less +1 -0
  293. package/lib/Upload/index.d.ts +4 -0
  294. package/lib/Upload/index.js +15 -0
  295. package/lib/Upload/style/index.d.ts +2 -0
  296. package/lib/Upload/style/index.js +5 -0
  297. package/lib/Upload/style/index.less +1 -0
  298. package/lib/_utils/hooks/useControlledState.d.ts +1 -1
  299. package/lib/_utils/hooks/useControlledState.js +11 -11
  300. package/lib/index.d.ts +39 -1
  301. package/lib/index.js +160 -0
  302. package/lib/locale/zh_CN.d.ts +2 -0
  303. package/lib/locale/zh_CN.js +13 -0
  304. package/lib/style/index.d.ts +1 -1
  305. package/lib/style/index.js +1 -1
  306. package/package.json +15 -4
package/README.md CHANGED
@@ -1,91 +1,228 @@
1
- # aloudata-design
1
+ # 组件库开发规范
2
2
 
3
- ## Getting Started
3
+ ## 简介
4
4
 
5
- Install dependencies,
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
- $ yarn i
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
- 开始 dev 环境开发,
26
+ #### 创建组件模板
12
27
 
13
28
  ```bash
14
- $ yarn start
29
+ yarn run cmt //根据指令输入组件名称,创建组件开发模板
15
30
  ```
16
- lint校验
17
- ```
18
- npm run lint
19
- ```
20
- 打包组件库 通过 `father-build`,
31
+
32
+ #### 组件校验
21
33
 
22
34
  ```bash
23
- $ npm run build
35
+ yarn run lint //stylelint、eslint 校验
24
36
  ```
25
37
 
26
- 构建 doc 文档
27
-
38
+ #### 组件测试
39
+
28
40
  ```bash
29
- $ npm run docs:build
41
+ yarn run test //单元测试
30
42
  ```
31
43
 
32
- 测试命令
44
+ #### 组件打包
33
45
 
34
46
  ```bash
35
- $ npm test
47
+ yarn run build //打包
36
48
  ```
37
- 发布npm包
49
+
50
+ #### 组件本地link
38
51
 
39
52
  ```bash
40
- # 先登录npm账号
41
- $ npm run release
42
- //会自动打包,并基于version打tag
43
- ```
44
- ## 组件开发目录结构
53
+ npm link //将组件库link到本地npm
54
+ // 切换到业务项目目录,·引入组件库
55
+ npm link @aloudata/aloudata-design // 业务项目中引入组件库
45
56
  ```
46
57
 
47
- --- component
48
- --- index.tsx //组件开发 需引用./style
49
- --- index.test.tsx //单测
50
- --- index.md //组件文档
51
- style文件夹
52
- ---index.ts //引用../../style ,引用./index.less
53
- ---index.less //用于自定义,需引用'../../style/index.less';
54
- demo文件夹 //用于放组件文档用例
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
- ### 覆盖antd组件的icon
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
- 在组件对应的 less 文件中
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
- // 找到antd组件的svg的父节点,覆盖其样式
66
- .ant-icon-parent-node-class {
67
- // \e691 是 iconfont 中图标对应的 Unicode 码
68
- .ald-iconfont('\e691');
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
- ### 更新iconfont文件
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
- 在 iconfont 网站上点击“下载至本地”按钮。解压为名为 download 的文件夹。
185
+ 也可以自己使用md语法写表格
186
+
187
+ ```md
188
+ | 属性 | 描述 | 类型 | 默认值 |
189
+ | ---- | ---- | ---- | ---- |
190
+ | value | 某个值 | string | 当前选中的值 |
191
+ ```
75
192
 
76
- `src/Icon/iconfont` 文件夹中的所有内容替换成 download 文件夹的内容。
193
+ ### 关于组件模板创建
77
194
 
78
- `src/Icon/index.less` 文件中的 `@font-face` 下的 `src` 属性的内容,替换成 `src/Icon/iconfont/iconfont.css` 文件中的 `@font-face` 下的 `src` 属性的内容。并将 `url(iconfont.woff` 和 `url(iconfont.ttf` 更改为 `url(./iconfont/iconfont.woff` 和 `url(./iconfont/iconfont.ttf`。
195
+ 使用 *npm run cmt* 创建的组件模板只是做一个参考,需要自己根据实际需求进行修改
79
196
 
80
- ### link 到本地
197
+ ## 关于组件库打包
81
198
 
82
- link 到本地后,其它项目可以通过 link 本项目直接 import 使用
199
+ ### 一、组件打包
83
200
 
201
+ ```bash
202
+ npm run build
84
203
  ```
85
- npm link
86
- //转到 目标项目
87
- npm link @aloudata/aloudata-design
88
204
 
89
- // 移除link
90
- npm unlink @aloudata/aloudata-design
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,4 @@
1
+ import { Alert } from 'antd';
2
+ import { AlertProps } from 'antd/lib/alert';
3
+ export { AlertProps };
4
+ export default Alert;
@@ -0,0 +1,3 @@
1
+ import "antd/es/alert/style";
2
+ import _Alert from "antd/es/alert";
3
+ export default _Alert;
@@ -0,0 +1,2 @@
1
+ import '../../style';
2
+ import './index.less';
@@ -0,0 +1,2 @@
1
+ import '../../style';
2
+ import './index.less';
@@ -0,0 +1 @@
1
+ @import '../../style/index.less';
@@ -1,7 +1,7 @@
1
1
  @import '../../style/index.less';
2
2
 
3
- @ald-prefix:ant;
4
- @ald-iconfont-css-prefix:anticon;
3
+ @ald-prefix: ant;
4
+ @ald-iconfont-css-prefix: anticon;
5
5
 
6
6
  .ant-btn {
7
7
  &.ant-btn {
@@ -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,175 +38,214 @@
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
- text-shadow: @text-shadow;
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
+ }
46
54
 
47
55
  &:hover,
48
- &:focus,
49
56
  &:active,
50
57
  &.ant-btn-loading {
58
+ color: @ND0;
51
59
  background-color: @B20;
52
60
  border-color: @B20;
53
- color: @ND0;
54
61
  }
55
62
 
56
63
  &[disabled] {
64
+ color: @NL80;
57
65
  background-color: @NL90;
58
66
  border-color: transparent;
59
- color: @NL80;
67
+ cursor: default;
60
68
 
61
69
  &:hover,
62
70
  &:focus,
63
71
  &:active {
72
+ color: @NL80;
64
73
  background-color: @NL90;
65
74
  border-color: transparent;
66
- color: @NL80;
67
75
  }
68
76
  }
69
77
  }
70
78
 
71
79
  &-dangerous.ant-btn-primary {
72
- background-color: @SC40;
73
- border-color: @SC40;
74
80
  color: @ND0;
75
81
  text-shadow: @text-shadow;
82
+ background-color: @SC40;
83
+ border-color: @SC40;
76
84
  box-shadow: unset;
77
85
 
78
- &:hover {
79
- background-color: @SC20;
80
- border-color: @SC20;
86
+ &:focus {
81
87
  color: @ND0;
88
+ text-shadow: @text-shadow;
89
+ background-color: @SC40;
90
+ border-color: @SC40;
91
+ box-shadow: unset;
82
92
  }
83
93
 
84
- &:focus,
94
+ &:hover,
85
95
  &:active,
86
96
  &.ant-btn-loading {
97
+ color: @ND0;
87
98
  background-color: @SC20;
88
99
  border-color: @SC20;
89
- color: @ND0;
90
100
  }
91
101
 
92
102
  &[disabled] {
103
+ color: @NL80;
93
104
  background-color: @NL90;
94
105
  border-color: transparent;
95
- color: @NL80;
106
+ cursor: default;
96
107
 
97
108
  &:hover,
98
109
  &:focus,
99
110
  &:active {
111
+ color: @NL80;
100
112
  background-color: @NL90;
101
113
  border-color: transparent;
102
- color: @NL80;
103
114
  }
104
115
  }
105
116
  }
106
117
 
107
118
  &-secondary {
119
+ color: @NL30;
120
+ text-shadow: @text-shadow;
108
121
  background-color: @BG100;
109
122
  border-color: @NL90;
110
- color: @NL30;
111
- box-shadow: none;
112
123
  border-radius: @border-radius-base;
113
- text-shadow: @text-shadow;
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
+ }
114
134
 
115
135
  &:hover,
116
- &:focus,
117
136
  &:active,
118
137
  &.ant-btn-loading {
138
+ color: @NL30;
119
139
  background-color: @NL97;
120
140
  border-color: @NL90;
121
- color: @NL30;
122
141
  }
123
142
 
124
143
  &[disabled] {
144
+ color: @NL80;
125
145
  background-color: @BG100;
126
146
  border-color: @NL90;
127
- color: @NL80;
147
+ cursor: default;
128
148
 
129
149
  &:hover,
130
150
  &:focus,
131
151
  &:active {
152
+ color: @NL80;
132
153
  background-color: @BG100;
133
154
  border-color: @NL90;
134
- color: @NL80;
135
155
  }
136
156
  }
137
157
  }
138
158
 
139
159
  &-text {
160
+ color: @NL30;
161
+ text-shadow: @text-shadow;
140
162
  background-color: @BG100;
141
163
  border-color: @BG100;
142
- color: @NL30;
143
- box-shadow: none;
144
164
  border-radius: @border-radius-base;
145
- text-shadow: @text-shadow;
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
+ }
146
175
 
147
176
  &:hover,
148
- &:focus,
149
177
  &:active,
150
178
  &.ant-btn-loading {
151
- background-color: @NL97;
152
179
  // border-color: @NL97;
153
180
  color: @NL30;
181
+ background-color: @NL97;
154
182
  }
155
183
 
156
184
  &[disabled] {
185
+ color: @NL80;
157
186
  background-color: transparent;
158
187
  border-color: transparent;
159
- color: @NL80;
188
+ cursor: default;
160
189
 
161
190
  &:hover,
162
191
  &:focus,
163
192
  &:active {
193
+ color: @NL80;
164
194
  background-color: transparent;
165
195
  border-color: transparent;
166
- color: @NL80;
167
196
  }
168
197
  }
169
198
  }
170
199
 
171
200
  &-link {
172
- background-color: @BG100;
173
- border-color: @BG100;
174
201
  color: @B40;
175
202
  font-weight: 400;
176
- box-shadow: none;
177
- border-radius: @border-radius-base;
178
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
+ }
179
218
 
180
219
  &:hover,
181
- &:focus,
182
220
  &:active,
183
221
  &.ant-btn-loading {
222
+ color: @B20;
184
223
  background-color: @BG100;
185
224
  border-color: @BG100;
186
- color: @B20;
187
225
  }
188
226
 
189
227
  &[disabled] {
228
+ color: @NL80;
190
229
  background-color: transparent;
191
230
  border-color: transparent;
192
- color: @NL80;
231
+ cursor: default;
193
232
 
194
233
  &:hover,
195
234
  &:focus,
196
235
  &:active {
236
+ color: @NL80;
197
237
  background-color: transparent;
198
238
  border-color: transparent;
199
- color: @NL80;
200
239
  }
201
240
  }
202
241
  }
203
242
 
204
243
  &-icon-only {
205
244
  justify-content: center;
245
+ width: @height-base;
246
+ height: @height-base;
206
247
  padding: 0;
207
248
  vertical-align: bottom;
208
- height: @height-base;
209
- width: @height-base;
210
249
 
211
250
  &.ant-btn-loading-icon {
212
251
  vertical-align: baseline;
@@ -220,22 +259,22 @@
220
259
  }
221
260
 
222
261
  &-circle {
262
+ justify-content: center;
223
263
  width: @height-base;
224
264
  min-width: auto;
225
265
  padding: 0;
226
- justify-content: center;
227
266
  border-radius: 50%;
228
267
  }
229
268
 
230
269
  &-lg {
270
+ min-width: auto;
231
271
  height: 32px;
232
272
  font-size: 14px;
233
- min-width: auto;
234
273
 
235
274
  &.ant-btn-icon-only {
236
- height: 32px;
237
275
  width: 32px;
238
276
  min-width: auto;
277
+ height: 32px;
239
278
  }
240
279
 
241
280
  &.ant-btn-circle {
@@ -247,11 +286,12 @@
247
286
 
248
287
  &-sm {
249
288
  height: 24px;
289
+ line-height: 22px;
250
290
  border-radius: @border-radius-sm;
251
291
 
252
292
  &.ant-btn-icon-only {
253
- height: 24px;
254
293
  width: 24px;
294
+ height: 24px;
255
295
  border-radius: @border-radius-sm;
256
296
  }
257
297
 
@@ -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;
@@ -0,0 +1,38 @@
1
+ import "antd/es/checkbox/style";
2
+ import _Checkbox from "antd/es/checkbox";
3
+ var _excluded = ["className"],
4
+ _excluded2 = ["className"];
5
+
6
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
+
8
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
+
10
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
+
12
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
13
+
14
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
15
+
16
+ import React from 'react';
17
+ import classNames from 'classnames';
18
+ var CheckboxGroup = _Checkbox.Group;
19
+
20
+ function Checkbox(props) {
21
+ var className = props.className,
22
+ otherProps = _objectWithoutProperties(props, _excluded);
23
+
24
+ return /*#__PURE__*/React.createElement(_Checkbox, _objectSpread({
25
+ className: classNames('ald-checkbox', className)
26
+ }, otherProps));
27
+ }
28
+
29
+ Checkbox.Group = function (props) {
30
+ var className = props.className,
31
+ otherProps = _objectWithoutProperties(props, _excluded2);
32
+
33
+ return /*#__PURE__*/React.createElement(CheckboxGroup, _objectSpread({
34
+ className: classNames('ald-checkbox', className)
35
+ }, otherProps));
36
+ };
37
+
38
+ export default Checkbox;
@@ -0,0 +1,2 @@
1
+ import '../../style';
2
+ import './index.less';
@@ -0,0 +1,2 @@
1
+ import '../../style';
2
+ import './index.less';