fat-design 0.0.1-beta.20250918153356 → 0.0.1-beta.20250927123155

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 (242) hide show
  1. package/README.md +576 -1
  2. package/index.browser.js +4 -4
  3. package/index.js +10 -3
  4. package/index.umd.cjs +3 -3
  5. package/index.umd.js +3 -3
  6. package/libs/config-16.js +7 -7
  7. package/libs/config-17.js +7 -7
  8. package/libs/config-18.js +9 -9
  9. package/libs/config-19.js +9 -9
  10. package/libs/theme/theme-blue1.css +58 -58
  11. package/libs/theme/theme-blue2.css +63 -63
  12. package/libs/theme/theme-blue3.css +73 -73
  13. package/libs/theme/theme-blue4.css +53 -53
  14. package/libs/theme/theme-default.css +60 -60
  15. package/libs/theme/theme-green.css +96 -96
  16. package/libs/theme/theme-green2.css +97 -0
  17. package/libs/theme/theme-orange.css +58 -58
  18. package/libs/theme/theme-pink.css +53 -53
  19. package/libs/theme/theme-purple.css +53 -53
  20. package/libs/theme/theme-red.css +55 -55
  21. package/package.json +2 -2
  22. package/types/0buildTypes/config-provider/constants.d.ts +3 -3
  23. package/types/0buildTypes/config-provider/index.d.ts +4 -4
  24. package/types/0buildTypes/config-provider/v2/consumer.d.ts +3 -3
  25. package/types/0buildTypes/config-provider/v2/context.d.ts +6 -6
  26. package/types/0buildTypes/config-provider/v2/error-boundary.d.ts +27 -27
  27. package/types/0buildTypes/config-provider/v2/functions.d.ts +66 -66
  28. package/types/0buildTypes/config-provider/v2/index.d.ts +36 -37
  29. package/types/0buildTypes/config-provider/v2/provider.d.ts +4 -4
  30. package/types/0buildTypes/config-provider/v2/types.d.ts +22 -22
  31. package/types/0buildTypes/dependencies.d.ts +2 -2
  32. package/types/0buildTypes/empty/empty.d.ts +22 -22
  33. package/types/0buildTypes/empty/index.d.ts +2 -2
  34. package/types/0buildTypes/filter/filter-types.d.ts +21 -21
  35. package/types/0buildTypes/filter/filter.d.ts +10 -10
  36. package/types/0buildTypes/filter/index.d.ts +9 -9
  37. package/types/0buildTypes/form2/deps.d.ts +10 -10
  38. package/types/0buildTypes/form2/form-actions.d.ts +36 -36
  39. package/types/0buildTypes/form2/form-buttons.d.ts +28 -28
  40. package/types/0buildTypes/form2/form-context.d.ts +4 -4
  41. package/types/0buildTypes/form2/form-error.d.ts +3 -3
  42. package/types/0buildTypes/form2/form-item-card.d.ts +4 -4
  43. package/types/0buildTypes/form2/form-item-comp.d.ts +4 -4
  44. package/types/0buildTypes/form2/form-item-label.d.ts +4 -4
  45. package/types/0buildTypes/form2/form-item-preview.d.ts +4 -4
  46. package/types/0buildTypes/form2/form-item.d.ts +7 -7
  47. package/types/0buildTypes/form2/form-layout.d.ts +3 -3
  48. package/types/0buildTypes/form2/form-rules.d.ts +3 -3
  49. package/types/0buildTypes/form2/form-section.d.ts +25 -25
  50. package/types/0buildTypes/form2/form-types.d.ts +390 -390
  51. package/types/0buildTypes/form2/form.d.ts +36 -36
  52. package/types/0buildTypes/form2/helper/buildParams.d.ts +5 -5
  53. package/types/0buildTypes/form2/helper/constants.d.ts +24 -24
  54. package/types/0buildTypes/form2/helper/fixItemProps.d.ts +16 -16
  55. package/types/0buildTypes/form2/helper/fnInheritProps.d.ts +2 -2
  56. package/types/0buildTypes/form2/helper/linkageFormState.d.ts +16 -16
  57. package/types/0buildTypes/form2/helper/useDataSource.d.ts +14 -14
  58. package/types/0buildTypes/form2/helper/useFormChildren.d.ts +5 -5
  59. package/types/0buildTypes/form2/helper/useFormItemState.d.ts +3 -3
  60. package/types/0buildTypes/form2/helper/useGetXProps.d.ts +3 -3
  61. package/types/0buildTypes/form2/index.d.ts +20 -20
  62. package/types/0buildTypes/form2/layout/from-float-layout.d.ts +3 -3
  63. package/types/0buildTypes/hooks/index.d.ts +16 -16
  64. package/types/0buildTypes/hooks/useCurrentState.d.ts +11 -11
  65. package/types/0buildTypes/hooks/useOnKeyPressSave.d.ts +12 -12
  66. package/types/0buildTypes/hooks/usePersistFn.d.ts +3 -3
  67. package/types/0buildTypes/hooks/usePreciseStore.d.ts +53 -53
  68. package/types/0buildTypes/hooks/useSize.d.ts +6 -6
  69. package/types/0buildTypes/hooks/useUniqueId.d.ts +2 -2
  70. package/types/0buildTypes/hooks/useValueOnChange.d.ts +2 -2
  71. package/types/0buildTypes/image/Image.d.ts +42 -42
  72. package/types/0buildTypes/image/Operations.d.ts +25 -25
  73. package/types/0buildTypes/image/Preview.d.ts +64 -64
  74. package/types/0buildTypes/image/PreviewGroup.d.ts +32 -32
  75. package/types/0buildTypes/image/common.d.ts +2 -2
  76. package/types/0buildTypes/image/context.d.ts +7 -7
  77. package/types/0buildTypes/image/getFixScaleEleTransPosition.d.ts +17 -17
  78. package/types/0buildTypes/image/hooks/useImageTransform.d.ts +28 -28
  79. package/types/0buildTypes/image/hooks/useMouseEvent.d.ts +9 -9
  80. package/types/0buildTypes/image/hooks/usePreviewItems.d.ts +7 -7
  81. package/types/0buildTypes/image/hooks/useRegisterImage.d.ts +2 -2
  82. package/types/0buildTypes/image/hooks/useStatus.d.ts +14 -14
  83. package/types/0buildTypes/image/hooks/useTouchEvent.d.ts +8 -8
  84. package/types/0buildTypes/image/index.d.ts +6 -6
  85. package/types/0buildTypes/image/interface.d.ts +14 -14
  86. package/types/0buildTypes/image/previewConfig.d.ts +4 -4
  87. package/types/0buildTypes/image/util.d.ts +1 -1
  88. package/types/0buildTypes/image/utils/KeyCode.d.ts +23 -23
  89. package/types/0buildTypes/image/utils/addEventListener.d.ts +4 -4
  90. package/types/0buildTypes/image/utils/buildIcons.d.ts +2 -2
  91. package/types/0buildTypes/image/utils/css.d.ts +8 -8
  92. package/types/0buildTypes/image/utils/isEqual.d.ts +8 -8
  93. package/types/0buildTypes/image/utils/raf.d.ts +6 -6
  94. package/types/0buildTypes/image/utils/useEvent.d.ts +1 -1
  95. package/types/0buildTypes/image/utils/useLayoutEffect.d.ts +4 -4
  96. package/types/0buildTypes/image/utils/useMergedState.d.ts +12 -12
  97. package/types/0buildTypes/image/utils/useSafeState.d.ts +14 -14
  98. package/types/0buildTypes/index.d.ts +4 -4
  99. package/types/0buildTypes/libs.d.ts +66 -66
  100. package/types/0buildTypes/nav/group.d.ts +30 -30
  101. package/types/0buildTypes/nav/index.d.ts +4 -4
  102. package/types/0buildTypes/nav/item.d.ts +30 -30
  103. package/types/0buildTypes/nav/nav.d.ts +2 -2
  104. package/types/0buildTypes/nav/popup-item.d.ts +24 -24
  105. package/types/0buildTypes/nav/sub-nav.d.ts +30 -30
  106. package/types/0buildTypes/nav/types.d.ts +375 -375
  107. package/types/0buildTypes/others.d.ts +10 -10
  108. package/types/0buildTypes/pages/deps.d.ts +5 -5
  109. package/types/0buildTypes/pages/detail-page/detail-page-card-form.d.ts +12 -12
  110. package/types/0buildTypes/pages/detail-page/detail-page-form-item.d.ts +9 -9
  111. package/types/0buildTypes/pages/detail-page/detail-page-section.d.ts +19 -19
  112. package/types/0buildTypes/pages/detail-page/detail-page-summary.d.ts +9 -9
  113. package/types/0buildTypes/pages/detail-page/detail-page.d.ts +14 -14
  114. package/types/0buildTypes/pages/detail-page/index.d.ts +2 -2
  115. package/types/0buildTypes/pages/detail-page/types.d.ts +29 -29
  116. package/types/0buildTypes/pages/page-card/types.d.ts +6 -6
  117. package/types/0buildTypes/previews/renderFileImage.d.ts +34 -34
  118. package/types/0buildTypes/query-form/index.d.ts +2 -2
  119. package/types/0buildTypes/query-form/query-form-items.d.ts +3 -3
  120. package/types/0buildTypes/query-form/query-form-layout.d.ts +2 -2
  121. package/types/0buildTypes/query-form/query-form.d.ts +17 -17
  122. package/types/0buildTypes/query-form/types.d.ts +5 -5
  123. package/types/0buildTypes/sortable-list/helpers.d.ts +8 -8
  124. package/types/0buildTypes/sortable-list/hooks.d.ts +24 -24
  125. package/types/0buildTypes/sortable-list/index.d.ts +14 -14
  126. package/types/0buildTypes/sortable-list/sortable-editable-table.d.ts +2 -2
  127. package/types/0buildTypes/sortable-list/sortable-list.d.ts +560 -560
  128. package/types/0buildTypes/sortable-list/sortable-table.d.ts +2 -2
  129. package/types/0buildTypes/sortable-list/types.d.ts +15 -15
  130. package/types/0buildTypes/table-pro/index.d.ts +26 -26
  131. package/types/0buildTypes/table-pro/table-pro.d.ts +17 -17
  132. package/types/0buildTypes/table-pro/types.d.ts +95 -95
  133. package/types/0buildTypes/table-pro/useTablePro.d.ts +10 -10
  134. package/types/0buildTypes/table-pro/utils/formatQueryRes.d.ts +1 -1
  135. package/types/0buildTypes/table-pro/widget/column-setting.d.ts +5 -5
  136. package/types/0buildTypes/table-pro/widget/deps.d.ts +2 -2
  137. package/types/0buildTypes/table-pro/widget/index.d.ts +25 -25
  138. package/types/0buildTypes/table-pro/widget/operations.d.ts +5 -5
  139. package/types/0buildTypes/table-pro/widget/operationsActions.d.ts +2 -2
  140. package/types/0buildTypes/table-pro/widget/renderFormats.d.ts +17 -17
  141. package/types/0buildTypes/table-pro/widget/renderMultiFieldCell.d.ts +4 -4
  142. package/types/0buildTypes/table-pro/widget/renderOperationCell.d.ts +4 -4
  143. package/types/0buildTypes/table-pro/widget/renderToolbar.d.ts +6 -6
  144. package/types/0buildTypes/table-pro/widget/table-utils-types.d.ts +40 -40
  145. package/types/0buildTypes/util/comp.d.ts +16 -16
  146. package/types/0buildTypes/util/component.d.ts +1 -1
  147. package/types/0buildTypes/util/constants.d.ts +4 -4
  148. package/types/0buildTypes/util/dom.d.ts +116 -116
  149. package/types/0buildTypes/util/env.d.ts +7 -7
  150. package/types/0buildTypes/util/func-wrapper.d.ts +1 -1
  151. package/types/0buildTypes/util/func.d.ts +73 -73
  152. package/types/0buildTypes/util/guid.d.ts +11 -11
  153. package/types/0buildTypes/util/isStateEquals.d.ts +4 -4
  154. package/types/0buildTypes/util/localforage.d.ts +11 -11
  155. package/types/0buildTypes/util/log.d.ts +18 -18
  156. package/types/0buildTypes/util/pick-res-data.d.ts +28 -28
  157. package/types/0buildTypes/util/react-dom.d.ts +27 -27
  158. package/types/0buildTypes/util/shallowEqual.d.ts +3 -3
  159. package/types/0buildTypes/util/string.d.ts +32 -32
  160. package/types/0buildTypes/util/tiny-emitter.d.ts +10 -10
  161. package/types/0buildTypes/util/toMap.d.ts +7 -7
  162. package/types/affix/index.d.ts +33 -33
  163. package/types/animate/index.d.ts +80 -80
  164. package/types/avatar/index.d.ts +41 -41
  165. package/types/badge/index.d.ts +38 -38
  166. package/types/balloon/index.d.ts +254 -254
  167. package/types/balloon-confirm/index.d.ts +78 -78
  168. package/types/batch-input/index.d.ts +152 -152
  169. package/types/box/index.d.ts +18 -18
  170. package/types/breadcrumb/index.d.ts +60 -60
  171. package/types/button/index.d.ts +179 -179
  172. package/types/calendar/index.d.ts +76 -76
  173. package/types/card/index.d.ts +147 -147
  174. package/types/cascader/index.d.ts +135 -135
  175. package/types/cascader-select/index.d.ts +230 -230
  176. package/types/checkbox/index.d.ts +175 -175
  177. package/types/collapse/index.d.ts +96 -96
  178. package/types/config-provider/index.d.ts +3 -3
  179. package/types/date-picker/index.d.ts +123 -123
  180. package/types/dialog/index.d.ts +328 -328
  181. package/types/divider/index.d.ts +21 -21
  182. package/types/drawer/index.d.ts +121 -121
  183. package/types/dropdown/index.d.ts +198 -198
  184. package/types/field/index.d.ts +33 -33
  185. package/types/filter/index.d.ts +2 -2
  186. package/types/form/index.d.ts +5 -5
  187. package/types/grid/index.d.ts +142 -142
  188. package/types/hooks/index.d.ts +2 -2
  189. package/types/icon/index.d.ts +29 -29
  190. package/types/image/index.d.ts +3 -3
  191. package/types/index.d.ts +67 -67
  192. package/types/input/index.d.ts +367 -367
  193. package/types/list/index.d.ts +69 -69
  194. package/types/loading/index.d.ts +100 -100
  195. package/types/locale/default.d.ts +143 -143
  196. package/types/locale/en-us.d.ts +1 -1
  197. package/types/locale/id-id.d.ts +1 -1
  198. package/types/locale/it-it.d.ts +1 -1
  199. package/types/locale/ja-jp.d.ts +1 -1
  200. package/types/locale/ko-kr.d.ts +1 -1
  201. package/types/locale/ms-my.d.ts +1 -1
  202. package/types/locale/pt-pt.d.ts +1 -1
  203. package/types/locale/th-th.d.ts +1 -1
  204. package/types/locale/vi-vn.d.ts +1 -1
  205. package/types/locale/zh-cn.d.ts +1 -1
  206. package/types/locale/zh-hk.d.ts +1 -1
  207. package/types/locale/zh-tw.d.ts +1 -1
  208. package/types/menu/index.d.ts +336 -336
  209. package/types/menu-button/index.d.ts +100 -100
  210. package/types/message/index.d.ts +165 -164
  211. package/types/nav/index.d.ts +313 -313
  212. package/types/notification/index.d.ts +35 -35
  213. package/types/number-picker/index.d.ts +161 -161
  214. package/types/overlay/index.d.ts +363 -363
  215. package/types/pagination/index.d.ts +115 -115
  216. package/types/paragraph/index.d.ts +23 -23
  217. package/types/progress/index.d.ts +53 -53
  218. package/types/query-form/index.d.ts +3 -3
  219. package/types/radio/index.d.ts +180 -180
  220. package/types/range/index.d.ts +120 -120
  221. package/types/rating/index.d.ts +84 -84
  222. package/types/responsive-grid/index.d.ts +30 -30
  223. package/types/search/index.d.ts +219 -219
  224. package/types/select/index.d.ts +479 -479
  225. package/types/shell/index.d.ts +53 -53
  226. package/types/slider/index.d.ts +172 -172
  227. package/types/split-button/index.d.ts +134 -134
  228. package/types/step/index.d.ts +108 -108
  229. package/types/switch/index.d.ts +85 -85
  230. package/types/tab/index.d.ts +170 -170
  231. package/types/table/index.d.ts +407 -407
  232. package/types/table-pro/index.d.ts +3 -3
  233. package/types/tag/index.d.ts +142 -124
  234. package/types/time-picker/index.d.ts +193 -193
  235. package/types/timeline/index.d.ts +95 -95
  236. package/types/transfer/index.d.ts +199 -199
  237. package/types/tree/index.d.ts +421 -421
  238. package/types/tree-select/index.d.ts +251 -251
  239. package/types/typography/index.d.ts +28 -28
  240. package/types/upload/index.d.ts +711 -711
  241. package/types/util.d.ts +50 -50
  242. package/types/virtual-list/index.d.ts +44 -44
package/README.md CHANGED
@@ -1 +1,576 @@
1
- # fat-design
1
+ # Fat Design 组件库使用指南
2
+
3
+ <div align="center">
4
+ <h1>🎨 Fat Design</h1>
5
+ <p>一套功能强大、体积轻量的 React 组件库</p>
6
+
7
+ <p>
8
+ 项目网站:
9
+ https://uifaas.com/ns/app/fat-design-doc/index
10
+ </p>
11
+
12
+ <p>
13
+ <img src="https://img.shields.io/badge/React-16%2B-blue" alt="React 版本" />
14
+ <img src="https://img.shields.io/badge/TypeScript-4.9%2B-blue" alt="TypeScript 版本" />
15
+ <img src="https://img.shields.io/badge/Bundle%20Size-761KB-green" alt="包大小" />
16
+ </p>
17
+ </div>
18
+
19
+ ## ✨ 特性
20
+
21
+ - 🎯 **体积轻量**:构建后仅 761KB,比同类产品小 30%+
22
+ - 🚀 **功能强大**:提供 60+ 高质量组件,涵盖企业级应用的各种场景
23
+ - 💪 **兼容性强**:支持 React 16、17、18 多个版本
24
+ - 🎨 **主题丰富**:内置 11 套精美主题,支持自定义主题
25
+ - 📦 **按需加载**:支持 Tree Shaking,减少打包体积
26
+ - 🛡️ **类型安全**:完整的 TypeScript 支持
27
+ - 📚 **文档完善**:详细的组件文档和丰富的示例
28
+
29
+ ## 🎯 对比优势
30
+
31
+ 与其他主流组件库相比:
32
+
33
+ | 特性 | Fat Design | Ant Design | Next UI |
34
+ |------|------------|------------|----------|
35
+ | 包体积 | 761KB | 1.2MB+ | 1.1MB+ |
36
+ | React 版本支持 | 16/17/18 | 16/17/18 | 17/18 |
37
+ | TypeScript | ✅ 完整支持 | ✅ 完整支持 | ✅ 完整支持 |
38
+ | 主题系统 | 11 套预设主题 | 默认主题 | 多套主题 |
39
+ | 高级组件 | Form、TablePro、QueryForm | 基础组件 | 基础组件 |
40
+
41
+ ## 📦 安装
42
+
43
+ ### 使用 npm
44
+
45
+ ```bash
46
+ # 安装最新版本
47
+ npm install fat-design
48
+
49
+ # 安装指定版本
50
+ npm install fat-design@latest
51
+ ```
52
+
53
+ ### 使用 yarn
54
+
55
+ ```bash
56
+ # 安装最新版本
57
+ yarn add fat-design
58
+
59
+ # 安装指定版本
60
+ yarn add fat-design@latest
61
+ ```
62
+
63
+ ### 使用 pnpm
64
+
65
+ ```bash
66
+ # 安装最新版本
67
+ pnpm add fat-design
68
+
69
+ # 安装指定版本
70
+ pnpm add fat-design@latest
71
+ ```
72
+
73
+ ## 🚀 快速开始
74
+
75
+ ### 1. 引入样式
76
+
77
+ 在项目入口文件中引入样式文件:
78
+
79
+ ```javascript
80
+ // 引入默认主题
81
+ import 'fat-design/dist/theme-default.css'
82
+
83
+ // 或选择其他主题
84
+ import 'fat-design/dist/theme-blue1.css'
85
+ import 'fat-design/dist/theme-green.css'
86
+ ```
87
+
88
+ ### 2. 使用组件
89
+
90
+ #### 全量导入(不推荐)
91
+
92
+ ```javascript
93
+ import FatDesign from 'fat-design'
94
+
95
+ function App() {
96
+ return (
97
+ <div>
98
+ <FatDesign.Button type="primary">点击我</FatDesign.Button>
99
+ </div>
100
+ )
101
+ }
102
+ ```
103
+
104
+ #### 按需导入(推荐)
105
+
106
+ ```javascript
107
+ import { Button, Form, Table, Message } from 'fat-design'
108
+
109
+ function App() {
110
+ const handleClick = () => {
111
+ Message.success('按钮被点击了!')
112
+ }
113
+
114
+ return (
115
+ <div>
116
+ <Button type="primary" onClick={handleClick}>
117
+ 点击我
118
+ </Button>
119
+ </div>
120
+ )
121
+ }
122
+ ```
123
+
124
+ ### 3. 完整示例
125
+
126
+ ```javascript
127
+ import React from 'react'
128
+ import {
129
+ Button,
130
+ Form,
131
+ Input,
132
+ Select,
133
+ DatePicker,
134
+ Message,
135
+ Card
136
+ } from 'fat-design'
137
+ import 'fat-design/dist/theme-default.css'
138
+
139
+ function App() {
140
+ const [form] = Form.useForm()
141
+
142
+ const handleSubmit = (values) => {
143
+ console.log('表单数据:', values)
144
+ Message.success('提交成功!')
145
+ }
146
+
147
+ return (
148
+ <Card title="用户信息" style={{ maxWidth: 600, margin: '50px auto' }}>
149
+ <Form
150
+ form={form}
151
+ onFinish={handleSubmit}
152
+ labelCol={{ span: 6 }}
153
+ wrapperCol={{ span: 18 }}
154
+ >
155
+ <Form.Item
156
+ label="用户名"
157
+ name="username"
158
+ rules={[{ required: true, message: '请输入用户名' }]}
159
+ >
160
+ <Input placeholder="请输入用户名" />
161
+ </Form.Item>
162
+
163
+ <Form.Item
164
+ label="性别"
165
+ name="gender"
166
+ rules={[{ required: true, message: '请选择性别' }]}
167
+ >
168
+ <Select placeholder="请选择性别">
169
+ <Select.Option value="male">男</Select.Option>
170
+ <Select.Option value="female">女</Select.Option>
171
+ </Select>
172
+ </Form.Item>
173
+
174
+ <Form.Item
175
+ label="生日"
176
+ name="birthday"
177
+ >
178
+ <DatePicker placeholder="请选择生日" />
179
+ </Form.Item>
180
+
181
+ <Form.Item wrapperCol={{ offset: 6, span: 18 }}>
182
+ <Button type="primary" htmlType="submit">
183
+ 提交
184
+ </Button>
185
+ <Button style={{ marginLeft: 8 }} onClick={() => form.resetFields()}>
186
+ 重置
187
+ </Button>
188
+ </Form.Item>
189
+ </Form>
190
+ </Card>
191
+ )
192
+ }
193
+
194
+ export default App
195
+ ```
196
+
197
+ ## 🎨 主题系统
198
+
199
+ Fat Design 提供了丰富的主题系统,包含 11 套精美的预设主题:
200
+
201
+ ### 预设主题
202
+
203
+ ```javascript
204
+ // 默认主题
205
+ import 'fat-design/dist/theme-default.css'
206
+
207
+ // 蓝色系主题
208
+ import 'fat-design/dist/theme-blue1.css'
209
+ import 'fat-design/dist/theme-blue2.css'
210
+ import 'fat-design/dist/theme-blue3.css'
211
+ import 'fat-design/dist/theme-blue4.css'
212
+
213
+ // 绿色系主题
214
+ import 'fat-design/dist/theme-green.css'
215
+ import 'fat-design/dist/theme-green2.css'
216
+
217
+ // 其他颜色主题
218
+ import 'fat-design/dist/theme-orange.css'
219
+ import 'fat-design/dist/theme-pink.css'
220
+ import 'fat-design/dist/theme-purple.css'
221
+ import 'fat-design/dist/theme-red.css'
222
+ ```
223
+
224
+ ### 动态切换主题
225
+
226
+ ```javascript
227
+ function changeTheme(themeName) {
228
+ const link = document.getElementById('fat-design-theme')
229
+ if (link) {
230
+ link.href = `/node_modules/fat-design/dist/${themeName}.css`
231
+ } else {
232
+ const newLink = document.createElement('link')
233
+ newLink.id = 'fat-design-theme'
234
+ newLink.rel = 'stylesheet'
235
+ newLink.href = `/node_modules/fat-design/dist/${themeName}.css`
236
+ document.head.appendChild(newLink)
237
+ }
238
+ }
239
+
240
+ // 使用示例
241
+ changeTheme('theme-blue1')
242
+ ```
243
+
244
+ ### 自定义主题
245
+
246
+ ```scss
247
+ // 自定义主题变量
248
+ :root {
249
+ --color-brand1-1: #f0f8ff;
250
+ --color-brand1-6: #4169e1;
251
+ --color-brand1-9: #0000cd;
252
+
253
+ --color-text1-1: #666;
254
+ --color-text1-2: #333;
255
+ --color-text1-3: #000;
256
+
257
+ --color-line1-1: #eee;
258
+ --color-line1-2: #ddd;
259
+ --color-line1-3: #ccc;
260
+ }
261
+ ```
262
+
263
+ ## 📚 核心组件
264
+
265
+ ### 基础组件
266
+
267
+ - **Button 按钮**:支持多种类型、尺寸、状态的按钮组件
268
+ - **Icon 图标**:丰富的图标库
269
+ - **Avatar 头像**:用户头像展示组件
270
+ - **Badge 徽标**:消息提醒、状态标识组件
271
+
272
+ ### 布局组件
273
+
274
+ - **Grid 栅格**:24 栅格系统
275
+ - **Box 盒子**:灵活的布局容器
276
+ - **Divider 分割线**:内容分割组件
277
+
278
+ ### 表单组件
279
+
280
+ - **Form/Form2 表单**:强大的表单解决方案
281
+ - **Input 输入框**:文本输入组件
282
+ - **Select 选择器**:下拉选择组件
283
+ - **DatePicker 日期选择**:日期时间选择组件
284
+ - **Checkbox 复选框**:多选组件
285
+ - **Radio 单选框**:单选组件
286
+ - **Switch 开关**:开关切换组件
287
+ - **BatchInput 批量输入**:批量数据输入组件
288
+
289
+ ### 数据展示
290
+
291
+ - **Table 表格**:基础表格组件
292
+ - **TablePro 增强表格**:高级表格功能
293
+ - **Tree 树形控件**:层级数据展示
294
+ - **Tag 标签**:标记和分类
295
+ - **Timeline 时间轴**:时间流展示
296
+
297
+ ### 反馈组件
298
+
299
+ - **Message 全局提示**:操作反馈信息
300
+ - **Notification 通知提醒**:系统通知
301
+ - **Dialog 对话框**:模态对话框
302
+ - **Drawer 抽屉**:侧边抽屉
303
+ - **Loading 加载**:加载状态提示
304
+
305
+ ### 导航组件
306
+
307
+ - **Menu 导航菜单**:导航菜单组件
308
+ - **Breadcrumb 面包屑**:页面导航路径
309
+ - **Pagination 分页**:数据分页组件
310
+ - **Nav 导航**:页面导航组件
311
+
312
+ ### 高级组件
313
+
314
+ - **Image 图片**:图片展示和预览
315
+ - **Upload 上传**:文件上传组件
316
+ - **SortableList 可排序列表**:拖拽排序列表
317
+ - **VirtualList 虚拟列表**:大数据量列表
318
+ - **QueryForm 查询表单**:搜索表单组件
319
+
320
+ ## 🔧 构建工具集成
321
+
322
+ ### Vite 集成(推荐)
323
+
324
+ ```javascript
325
+ // vite.config.ts
326
+ import { defineConfig } from 'vite'
327
+ import react from '@vitejs/plugin-react'
328
+
329
+ export default defineConfig({
330
+ plugins: [react()],
331
+ css: {
332
+ preprocessorOptions: {
333
+ scss: {
334
+ additionalData: `@import "fat-design/dist/variables.scss";`
335
+ }
336
+ }
337
+ }
338
+ })
339
+ ```
340
+
341
+ ### Webpack 集成
342
+
343
+ ```javascript
344
+ // webpack.config.js
345
+ module.exports = {
346
+ module: {
347
+ rules: [
348
+ {
349
+ test: /\.scss$/,
350
+ use: ['style-loader', 'css-loader', 'sass-loader']
351
+ }
352
+ ]
353
+ },
354
+ externals: {
355
+ react: 'React',
356
+ 'react-dom': 'ReactDOM'
357
+ }
358
+ }
359
+ ```
360
+
361
+ ### Next.js 集成
362
+
363
+ ```javascript
364
+ // next.config.js
365
+ module.exports = {
366
+ transpilePackages: ['fat-design'],
367
+ experimental: {
368
+ esmExternals: 'loose'
369
+ }
370
+ }
371
+ ```
372
+
373
+ ## 🛠️ TypeScript 支持
374
+
375
+ Fat Design 提供完整的 TypeScript 类型定义:
376
+
377
+ ```typescript
378
+ import { ButtonProps, FormProps, TableProps } from 'fat-design'
379
+
380
+ // 组件 Props 类型
381
+ const buttonProps: ButtonProps = {
382
+ type: 'primary',
383
+ size: 'medium',
384
+ onClick: () => console.log('clicked')
385
+ }
386
+
387
+ // 表单验证
388
+ interface FormData {
389
+ username: string
390
+ email: string
391
+ }
392
+
393
+ const formProps: FormProps<FormData> = {
394
+ onFinish: (values: FormData) => {
395
+ console.log(values.username, values.email)
396
+ }
397
+ }
398
+ ```
399
+
400
+ ## 🔍 按需加载
401
+
402
+ 为了减少打包体积,推荐使用按需加载:
403
+
404
+ ```javascript
405
+ // 推荐写法 - 自动 Tree Shaking
406
+ import { Button, Form, Table } from 'fat-design'
407
+
408
+ // 避免以下写法
409
+ import FatDesign from 'fat-design' // ❌
410
+ import * as FatDesign from 'fat-design' // ❌
411
+ ```
412
+
413
+ ## 🐛 常见问题
414
+
415
+ ### 1. React 版本兼容性
416
+
417
+ Fat Design 支持 React 16、17、18,如遇到兼容性问题:
418
+
419
+ ```javascript
420
+ import { tryAutoConfig } from 'fat-design'
421
+
422
+ // 自动配置
423
+ tryAutoConfig()
424
+ ```
425
+
426
+ ### 2. 样式问题
427
+
428
+ 如果样式没有正确加载,请确保:
429
+
430
+ ```javascript
431
+ // 1. 正确引入样式文件
432
+ import 'fat-design/dist/theme-default.css'
433
+
434
+ // 2. 检查 CSS 加载器配置
435
+ // 3. 确保样式文件路径正确
436
+ ```
437
+
438
+ ### 3. TypeScript 类型错误
439
+
440
+ ```typescript
441
+ // tsconfig.json 配置
442
+ {
443
+ "compilerOptions": {
444
+ "typeRoots": ["node_modules/@types", "node_modules/fat-design/types"],
445
+ "types": ["fat-design"]
446
+ }
447
+ }
448
+ ```
449
+
450
+ ## 📖 进阶使用
451
+
452
+ ### 自定义 Hook
453
+
454
+ ```javascript
455
+ import { hooks } from 'fat-design'
456
+
457
+ function MyComponent() {
458
+ const [value, setValue] = hooks.useCurrentState('')
459
+ const persistFn = hooks.usePersistFn(() => {
460
+ console.log('持久化函数')
461
+ })
462
+
463
+ return <div>{/* 组件内容 */}</div>
464
+ }
465
+ ```
466
+
467
+ ### 工具函数
468
+
469
+ ```javascript
470
+ import { utils } from 'fat-design'
471
+
472
+ // ID 生成
473
+ const id = utils.generateId()
474
+
475
+ // 对象操作
476
+ const isEqual = utils.shallowEqual(obj1, obj2)
477
+
478
+ // DOM 操作
479
+ const element = utils.findDOMNode(ref.current)
480
+ ```
481
+
482
+ ## 🌟 最佳实践
483
+
484
+ ### 1. 组件设计
485
+
486
+ ```javascript
487
+ // 推荐:组合使用组件
488
+ function UserCard({ user }) {
489
+ return (
490
+ <Card
491
+ title={
492
+ <div>
493
+ <Avatar src={user.avatar} />
494
+ <span>{user.name}</span>
495
+ </div>
496
+ }
497
+ extra={<Tag color="blue">{user.role}</Tag>}
498
+ >
499
+ <p>{user.description}</p>
500
+ </Card>
501
+ )
502
+ }
503
+ ```
504
+
505
+ ### 2. 表单处理
506
+
507
+ ```javascript
508
+ // 推荐:使用 Form2 处理复杂表单
509
+ function UserForm() {
510
+ return (
511
+ <Form
512
+ labelCol={{ span: 6 }}
513
+ wrapperCol={{ span: 18 }}
514
+ onFinish={handleSubmit}
515
+ >
516
+ <Form.Item name="username" label="用户名" rules={[{ required: true }]}>
517
+ <Input />
518
+ </Form.Item>
519
+
520
+ <Form.Item name="profile" label="个人信息">
521
+ <Form
522
+ layout="inline"
523
+ initialValues={{ age: 18 }}
524
+ >
525
+ <Form.Item name="age" label="年龄">
526
+ <NumberPicker />
527
+ </Form.Item>
528
+ <Form.Item name="city" label="城市">
529
+ <Select />
530
+ </Form.Item>
531
+ </Form>
532
+ </Form.Item>
533
+ </Form>
534
+ )
535
+ }
536
+ ```
537
+
538
+ ### 3. 数据展示
539
+
540
+ ```javascript
541
+ // 推荐:使用 TablePro 处理复杂表格
542
+ function UserTable() {
543
+ const columns = [
544
+ {
545
+ title: '用户名',
546
+ dataIndex: 'username',
547
+ sorter: true,
548
+ filter: true
549
+ },
550
+ {
551
+ title: '状态',
552
+ dataIndex: 'status',
553
+ render: (status) => (
554
+ <Tag color={status === 'active' ? 'green' : 'red'}>
555
+ {status}
556
+ </Tag>
557
+ )
558
+ }
559
+ ]
560
+
561
+ return (
562
+ <TablePro
563
+ columns={columns}
564
+ dataSource={users}
565
+ pagination={{ pageSize: 10 }}
566
+ toolbar={{
567
+ search: true,
568
+ filter: true,
569
+ export: true
570
+ }}
571
+ />
572
+ )
573
+ }
574
+ ```
575
+
576
+