@aoao-y33/ui 0.0.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 (211) hide show
  1. package/README.md +811 -0
  2. package/dist/button/components/button/button.vue.d.ts +22 -0
  3. package/dist/button/components/button/button.vue.d.ts.map +1 -0
  4. package/dist/button/components/button/index.d.ts +3 -0
  5. package/dist/button/components/button/index.d.ts.map +1 -0
  6. package/dist/button/components/button/props.d.ts +21 -0
  7. package/dist/button/components/button/props.d.ts.map +1 -0
  8. package/dist/button/components/fields/index.d.ts +2 -0
  9. package/dist/button/components/fields/index.d.ts.map +1 -0
  10. package/dist/button/hoc/index.d.ts +2 -0
  11. package/dist/button/hoc/index.d.ts.map +1 -0
  12. package/dist/button/hoc/useButton.d.ts +19 -0
  13. package/dist/button/hoc/useButton.d.ts.map +1 -0
  14. package/dist/button/index.d.ts +5 -0
  15. package/dist/button/index.d.ts.map +1 -0
  16. package/dist/button/utils/index.d.ts +4 -0
  17. package/dist/button/utils/index.d.ts.map +1 -0
  18. package/dist/common/index.d.ts +2 -0
  19. package/dist/common/index.d.ts.map +1 -0
  20. package/dist/common/utils/iconUtils.d.ts +2 -0
  21. package/dist/common/utils/iconUtils.d.ts.map +1 -0
  22. package/dist/common/utils/index.d.ts +2 -0
  23. package/dist/common/utils/index.d.ts.map +1 -0
  24. package/dist/form/components/fields/index.d.ts +2 -0
  25. package/dist/form/components/fields/index.d.ts.map +1 -0
  26. package/dist/form/components/form/form.vue.d.ts +42 -0
  27. package/dist/form/components/form/form.vue.d.ts.map +1 -0
  28. package/dist/form/components/form/index.d.ts +90 -0
  29. package/dist/form/components/form/index.d.ts.map +1 -0
  30. package/dist/form/components/form/props.d.ts +21 -0
  31. package/dist/form/components/form/props.d.ts.map +1 -0
  32. package/dist/form/components/form-item/form-item.vue.d.ts +19 -0
  33. package/dist/form/components/form-item/form-item.vue.d.ts.map +1 -0
  34. package/dist/form/components/form-item/index.d.ts +31 -0
  35. package/dist/form/components/form-item/index.d.ts.map +1 -0
  36. package/dist/form/components/form-item/props.d.ts +14 -0
  37. package/dist/form/components/form-item/props.d.ts.map +1 -0
  38. package/dist/form/hoc/index.d.ts +4 -0
  39. package/dist/form/hoc/index.d.ts.map +1 -0
  40. package/dist/form/hoc/useForm.d.ts +13 -0
  41. package/dist/form/hoc/useForm.d.ts.map +1 -0
  42. package/dist/form/hoc/useFormExpose.d.ts +24 -0
  43. package/dist/form/hoc/useFormExpose.d.ts.map +1 -0
  44. package/dist/form/hoc/useFormFetch.d.ts +25 -0
  45. package/dist/form/hoc/useFormFetch.d.ts.map +1 -0
  46. package/dist/form/index.d.ts +6 -0
  47. package/dist/form/index.d.ts.map +1 -0
  48. package/dist/form/utils/index.d.ts +9 -0
  49. package/dist/form/utils/index.d.ts.map +1 -0
  50. package/dist/global.d.ts +33 -0
  51. package/dist/global.d.ts.map +1 -0
  52. package/dist/index.css +3 -0
  53. package/dist/index.d.ts +12 -0
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +38948 -0
  56. package/dist/layout/components/fields/basic/basic.vue.d.ts +20 -0
  57. package/dist/layout/components/fields/basic/basic.vue.d.ts.map +1 -0
  58. package/dist/layout/components/fields/index.d.ts +2 -0
  59. package/dist/layout/components/fields/index.d.ts.map +1 -0
  60. package/dist/layout/components/fields/side/side.vue.d.ts +20 -0
  61. package/dist/layout/components/fields/side/side.vue.d.ts.map +1 -0
  62. package/dist/layout/components/fields/top/top.vue.d.ts +18 -0
  63. package/dist/layout/components/fields/top/top.vue.d.ts.map +1 -0
  64. package/dist/layout/components/layout/index.d.ts +22 -0
  65. package/dist/layout/components/layout/index.d.ts.map +1 -0
  66. package/dist/layout/components/layout/layout.vue.d.ts +15 -0
  67. package/dist/layout/components/layout/layout.vue.d.ts.map +1 -0
  68. package/dist/layout/components/layout/props.d.ts +4 -0
  69. package/dist/layout/components/layout/props.d.ts.map +1 -0
  70. package/dist/layout/hoc/index.d.ts +2 -0
  71. package/dist/layout/hoc/index.d.ts.map +1 -0
  72. package/dist/layout/hoc/useLayout.d.ts +12 -0
  73. package/dist/layout/hoc/useLayout.d.ts.map +1 -0
  74. package/dist/layout/index.d.ts +5 -0
  75. package/dist/layout/index.d.ts.map +1 -0
  76. package/dist/layout/utils/index.d.ts +4 -0
  77. package/dist/layout/utils/index.d.ts.map +1 -0
  78. package/dist/modal/components/form-modal/form-modal.vue.d.ts +46 -0
  79. package/dist/modal/components/form-modal/form-modal.vue.d.ts.map +1 -0
  80. package/dist/modal/components/form-modal/index.d.ts +101 -0
  81. package/dist/modal/components/form-modal/index.d.ts.map +1 -0
  82. package/dist/modal/components/form-modal/props.d.ts +19 -0
  83. package/dist/modal/components/form-modal/props.d.ts.map +1 -0
  84. package/dist/modal/components/modal/index.d.ts +53 -0
  85. package/dist/modal/components/modal/index.d.ts.map +1 -0
  86. package/dist/modal/components/modal/modal.vue.d.ts +29 -0
  87. package/dist/modal/components/modal/modal.vue.d.ts.map +1 -0
  88. package/dist/modal/components/modal/props.d.ts +24 -0
  89. package/dist/modal/components/modal/props.d.ts.map +1 -0
  90. package/dist/modal/hoc/index.d.ts +4 -0
  91. package/dist/modal/hoc/index.d.ts.map +1 -0
  92. package/dist/modal/hoc/useFormModal.d.ts +13 -0
  93. package/dist/modal/hoc/useFormModal.d.ts.map +1 -0
  94. package/dist/modal/hoc/useModal.d.ts +12 -0
  95. package/dist/modal/hoc/useModal.d.ts.map +1 -0
  96. package/dist/modal/hoc/useModalExpose.d.ts +8 -0
  97. package/dist/modal/hoc/useModalExpose.d.ts.map +1 -0
  98. package/dist/modal/index.d.ts +4 -0
  99. package/dist/modal/index.d.ts.map +1 -0
  100. package/dist/table/components/fields/action-column/action-column.vue.d.ts +6 -0
  101. package/dist/table/components/fields/action-column/action-column.vue.d.ts.map +1 -0
  102. package/dist/table/components/fields/action-column/props.d.ts +8 -0
  103. package/dist/table/components/fields/action-column/props.d.ts.map +1 -0
  104. package/dist/table/components/fields/index.d.ts +2 -0
  105. package/dist/table/components/fields/index.d.ts.map +1 -0
  106. package/dist/table/components/table/index.d.ts +58 -0
  107. package/dist/table/components/table/index.d.ts.map +1 -0
  108. package/dist/table/components/table/props.d.ts +43 -0
  109. package/dist/table/components/table/props.d.ts.map +1 -0
  110. package/dist/table/components/table/table.vue.d.ts +33 -0
  111. package/dist/table/components/table/table.vue.d.ts.map +1 -0
  112. package/dist/table/components/table-column/index.d.ts +6 -0
  113. package/dist/table/components/table-column/index.d.ts.map +1 -0
  114. package/dist/table/components/table-column/props.d.ts +6 -0
  115. package/dist/table/components/table-column/props.d.ts.map +1 -0
  116. package/dist/table/components/table-column/table-column.vue.d.ts +6 -0
  117. package/dist/table/components/table-column/table-column.vue.d.ts.map +1 -0
  118. package/dist/table/components/table-page/index.d.ts +12 -0
  119. package/dist/table/components/table-page/index.d.ts.map +1 -0
  120. package/dist/table/components/table-page/props.d.ts +13 -0
  121. package/dist/table/components/table-page/props.d.ts.map +1 -0
  122. package/dist/table/components/table-page/table-page.vue.d.ts +11 -0
  123. package/dist/table/components/table-page/table-page.vue.d.ts.map +1 -0
  124. package/dist/table/components/table-select/index.d.ts +73 -0
  125. package/dist/table/components/table-select/index.d.ts.map +1 -0
  126. package/dist/table/components/table-select/props.d.ts +21 -0
  127. package/dist/table/components/table-select/props.d.ts.map +1 -0
  128. package/dist/table/components/table-select/table-select.vue.d.ts +36 -0
  129. package/dist/table/components/table-select/table-select.vue.d.ts.map +1 -0
  130. package/dist/table/hoc/index.d.ts +3 -0
  131. package/dist/table/hoc/index.d.ts.map +1 -0
  132. package/dist/table/hoc/useTable.d.ts +33 -0
  133. package/dist/table/hoc/useTable.d.ts.map +1 -0
  134. package/dist/table/hoc/useTableExpose.d.ts +7 -0
  135. package/dist/table/hoc/useTableExpose.d.ts.map +1 -0
  136. package/dist/table/index.d.ts +8 -0
  137. package/dist/table/index.d.ts.map +1 -0
  138. package/dist/table/utils/index.d.ts +4 -0
  139. package/dist/table/utils/index.d.ts.map +1 -0
  140. package/package.json +42 -0
  141. package/src/button/components/button/button.vue +64 -0
  142. package/src/button/components/button/index.ts +2 -0
  143. package/src/button/components/button/props.ts +75 -0
  144. package/src/button/components/fields/index.ts +6 -0
  145. package/src/button/hoc/index.ts +1 -0
  146. package/src/button/hoc/useButton.ts +27 -0
  147. package/src/button/index.ts +4 -0
  148. package/src/button/utils/index.ts +32 -0
  149. package/src/common/index.ts +1 -0
  150. package/src/common/utils/iconUtils.ts +21 -0
  151. package/src/common/utils/index.ts +1 -0
  152. package/src/form/components/fields/index.ts +35 -0
  153. package/src/form/components/form/form.vue +130 -0
  154. package/src/form/components/form/index.ts +6 -0
  155. package/src/form/components/form/props.ts +73 -0
  156. package/src/form/components/form-item/form-item.vue +90 -0
  157. package/src/form/components/form-item/index.ts +6 -0
  158. package/src/form/components/form-item/props.ts +50 -0
  159. package/src/form/hoc/index.ts +3 -0
  160. package/src/form/hoc/useForm.ts +106 -0
  161. package/src/form/hoc/useFormExpose.ts +97 -0
  162. package/src/form/hoc/useFormFetch.ts +103 -0
  163. package/src/form/index.ts +5 -0
  164. package/src/form/utils/index.ts +149 -0
  165. package/src/global.ts +40 -0
  166. package/src/index.ts +37 -0
  167. package/src/layout/components/fields/basic/basic.vue +18 -0
  168. package/src/layout/components/fields/index.ts +10 -0
  169. package/src/layout/components/fields/side/side.vue +26 -0
  170. package/src/layout/components/fields/top/top.vue +13 -0
  171. package/src/layout/components/layout/index.ts +6 -0
  172. package/src/layout/components/layout/layout.vue +19 -0
  173. package/src/layout/components/layout/props.ts +3 -0
  174. package/src/layout/hoc/index.ts +1 -0
  175. package/src/layout/hoc/useLayout.ts +32 -0
  176. package/src/layout/index.ts +4 -0
  177. package/src/layout/utils/index.ts +31 -0
  178. package/src/modal/components/form-modal/form-modal.vue +158 -0
  179. package/src/modal/components/form-modal/index.ts +5 -0
  180. package/src/modal/components/form-modal/props.ts +61 -0
  181. package/src/modal/components/modal/index.ts +6 -0
  182. package/src/modal/components/modal/modal.vue +127 -0
  183. package/src/modal/components/modal/props.ts +78 -0
  184. package/src/modal/hoc/index.ts +3 -0
  185. package/src/modal/hoc/useFormModal.ts +140 -0
  186. package/src/modal/hoc/useModal.ts +151 -0
  187. package/src/modal/hoc/useModalExpose.ts +52 -0
  188. package/src/modal/index.ts +3 -0
  189. package/src/style/index.css +21 -0
  190. package/src/table/components/fields/action-column/action-column.vue +34 -0
  191. package/src/table/components/fields/action-column/props.ts +8 -0
  192. package/src/table/components/fields/index.ts +6 -0
  193. package/src/table/components/table/index.ts +6 -0
  194. package/src/table/components/table/props.ts +148 -0
  195. package/src/table/components/table/table.vue +77 -0
  196. package/src/table/components/table-column/index.ts +6 -0
  197. package/src/table/components/table-column/props.ts +26 -0
  198. package/src/table/components/table-column/table-column.vue +31 -0
  199. package/src/table/components/table-page/index.ts +6 -0
  200. package/src/table/components/table-page/props.ts +48 -0
  201. package/src/table/components/table-page/table-page.vue +51 -0
  202. package/src/table/components/table-select/index.ts +6 -0
  203. package/src/table/components/table-select/props.ts +79 -0
  204. package/src/table/components/table-select/table-select.vue +70 -0
  205. package/src/table/hoc/index.ts +2 -0
  206. package/src/table/hoc/useTable.ts +206 -0
  207. package/src/table/hoc/useTableExpose.ts +46 -0
  208. package/src/table/index.ts +7 -0
  209. package/src/table/utils/index.ts +37 -0
  210. package/tsconfig.json +30 -0
  211. package/vite.config.ts +49 -0
package/README.md ADDED
@@ -0,0 +1,811 @@
1
+ # @aoao-y33/ui
2
+
3
+ 基于 Vue 3 + Element Plus 的企业级 UI 组件库,提供丰富的业务组件和 Hooks,支持高度自定义和动态配置。
4
+
5
+ ## ✨ 特性
6
+
7
+ - 🎨 **基于 Element Plus**:无缝集成 Element Plus 组件,保持一致的设计语言
8
+ - 🔧 **高度可配置**:支持动态配置组件属性、事件和样式
9
+ - 📦 **丰富的组件**:提供 Button、Form、Table、Modal、Layout 等常用业务组件
10
+ - 🎯 **TypeScript 支持**:完整的类型定义,提供良好的 IDE 提示
11
+ - 🚀 **Hooks 驱动**:使用 Composition API 和自定义 Hooks,提升开发效率
12
+ - 🌲 **动态组件池**:支持动态注册和管理组件,灵活扩展功能
13
+ - 📱 **响应式设计**:适配各种屏幕尺寸
14
+ - 🌓 **深色模式**:内置深色主题支持
15
+
16
+ ## 📦 安装
17
+
18
+ ````bash
19
+ bash npm install @aoao-y33/ui
20
+
21
+ pnpm add @aoao-y33/ui
22
+
23
+ yarn add @aoao-y33/ui
24
+ ````
25
+
26
+
27
+
28
+ ## 🚀 快速开始
29
+
30
+ ### 全局引入
31
+
32
+ ````typescript
33
+ import { createApp } from 'vue'
34
+ import AoaoUI from '@aoao-y33/ui'
35
+ import App from './App.vue'
36
+ const app = createApp(App)
37
+ app.use(AoaoUI)
38
+ app.mount('#app')
39
+ ````
40
+
41
+ ### 按需引入
42
+
43
+ ```typescript
44
+ import { AxButton, useForm, useTable, useModal } from '@aoao-y33/ui'
45
+ ```
46
+
47
+ ### 样式引入
48
+
49
+ 组件库默认会自动引入样式,如果需要单独引入:
50
+
51
+ ```typescript
52
+ import '@aoao-y33/ui/dist/index.css'
53
+ ```
54
+
55
+ ## 📖 组件文档
56
+
57
+ ### 1. Button 按钮组件
58
+
59
+ 基础按钮组件,支持多种类型和自定义配置。
60
+
61
+ #### 基础用法
62
+
63
+ ```vue
64
+ <template>
65
+ <AxButton text="点击我" type="primary" @click="handleClick" /> </template>
66
+ <script setup lang="ts">
67
+ import { AxButton } from '@aoao-y33/ui'
68
+ const handleClick = () => {
69
+ console.log('按钮被点击')
70
+ }
71
+ </script>
72
+ ```
73
+
74
+ #### 带图标按钮
75
+
76
+ ```vue
77
+ <template>
78
+ <AxButton text="搜索" type="primary" icon="Search" @click="handleSearch" />
79
+ </template>
80
+ ```
81
+
82
+ #### 动态控制显示/隐藏
83
+
84
+ ````vue
85
+ <template>
86
+ <AxButton text="编辑" :hidden="(data) => !data.canEdit" :disabled="(data) => data.isLocked" />
87
+ </template>
88
+ ````
89
+
90
+ #### 注册自定义按钮类型
91
+
92
+ ```typescript
93
+ import { addButtonField } from '@aoao-y33/ui'
94
+ import CustomButton from './CustomButton.vue'
95
+ addButtonField('custom', CustomButton)
96
+ ```
97
+
98
+ #### API
99
+
100
+ ##### AxButtonProps
101
+
102
+ | 属性 | 类型 | 默认值 | 说明 |
103
+ | -------------- | -------------------------------- | ------ | ---------------------------- |
104
+ | text | `string` | - | 按钮文本 |
105
+ | type | `keyof buttonFields` | - | 按钮类型 |
106
+ | icon | `string \| Component` | - | 图标名称或组件 |
107
+ | disabled | `boolean \| ((data) => boolean)` | - | 禁用状态 |
108
+ | hidden | `boolean \| ((data) => boolean)` | - | 隐藏状态 |
109
+ | className | `string` | - | 自定义类名 |
110
+ | isMl | `boolean` | - | 是否添加左边距 |
111
+ | componentProps | `ButtonProps` | - | Element Plus Button 额外属性 |
112
+
113
+ ##### 事件
114
+
115
+ | 事件名 | 参数 | 说明 |
116
+ | -------- | ------------------- | -------- |
117
+ | click | `(data: T) => void` | 单击事件 |
118
+ | dblClick | `(data: T) => void` | 双击事件 |
119
+
120
+ ---
121
+
122
+ ### 2. Form 表单组件
123
+
124
+ 强大的表单组件,支持动态字段配置、验证和数据提交。
125
+
126
+ #### 使用 ax-form组件
127
+
128
+ ```vue
129
+ <template>
130
+ <ax-form ref="form">
131
+ <ax-form label="用户名" field-name="username" type="text"></ax-form>
132
+ <ax-form label="邮箱" field-name="mail" type="text" :vtypes="['required','mail']"></ax-form>
133
+ <template #button>
134
+ <ax-button @click="handleSubmit">提交</ax-button>
135
+ <ax-button @click="handleReset">重置</ax-button>
136
+ </template>
137
+ </ax-form>
138
+ </template>
139
+ <script setup lang="ts">
140
+ import { AxForm,AxFormItem,AxButton } from '@aoao-y33/ui'
141
+ const form = ref()
142
+ const handleSubmit = async (data:any) => {
143
+ await form.value?.load(data)
144
+ }
145
+ const handleReset = () => {
146
+ form.value?.resetValues()
147
+ }
148
+ </script>
149
+ ```
150
+
151
+
152
+
153
+ #### 使用 useForm Hook
154
+
155
+ ```vue
156
+ <template>
157
+ <Form />
158
+ </template>
159
+ <script setup lang="ts">
160
+ import { useForm } from '@aoao-y33/ui'
161
+ const [Form, formApi] = useForm({
162
+ fieldConfig: {
163
+ fields: [
164
+ {
165
+ label: "用户名",
166
+ fieldName: 'username',
167
+ type: 'text'
168
+ },
169
+ {
170
+ label: "邮箱",
171
+ fieldName: 'email',
172
+ type: 'text',
173
+ vtypes: ['required', 'mail']
174
+ }
175
+ ]
176
+ },
177
+ buttonConfig: {
178
+ fields: [
179
+ {
180
+ text: '提交',
181
+ onClick: handleSubmit,
182
+ },
183
+ { text: '重置',
184
+ onClick: handleReset
185
+ }
186
+ ]
187
+ }
188
+ })
189
+ const handleSubmit = async (data:any) => {
190
+ await formApi.requestApi.load(data)
191
+ }
192
+ const handleReset = () => {
193
+ formApi.resetValues()
194
+ }
195
+ </script>
196
+ ```
197
+
198
+ #### 表单验证规则
199
+
200
+ 内置验证规则:
201
+ - `required`: 必填
202
+ - `phone`: 手机号
203
+ - `tel`: 固定电话
204
+ - `mail`: 邮箱
205
+
206
+ ```typescript
207
+ import { addFormRules } from '@aoao-y33/ui'
208
+ // 注册自定义验证规则
209
+ addFormRules('idCard', (type, label) => ({ pattern: /^\d{17}[\dXx]$/, message: `${label}身份证号格式错误` }))
210
+ ```
211
+
212
+ #### API
213
+
214
+ ##### useForm 返回值
215
+
216
+ | 属性 | 类型 | 说明 |
217
+ | ---------- | -------------- | ---------------------------- |
218
+ | Form | `Component` | 表单组件 |
219
+ | setForm | `StateApi` | 更新表单属性 |
220
+ | requestApi | `FormFetchApi` | 请求 API(submit、fetch 等) |
221
+ | fieldsApi | `FieldsApi` | 字段管理 API |
222
+ | buttonsApi | `FieldsApi` | 按钮管理 API |
223
+
224
+ ##### formApi方法
225
+
226
+ - 类型:`FormApi<T>`
227
+ - `getElForm()`: 获取底层的Element UI表单实例
228
+ - `getValues()`: 获取表单的所有字段值
229
+ - `getValue(field:string)`: 获取表单指定字段的值
230
+ - `getFields()`: 获取表单的所有字段名称列表
231
+ - `getDefaultValues()`: 获取表单字段的默认值
232
+ - `setValues(data:T)`: 批量设置表单字段的值
233
+ - `resetValues()`: 重置表单所有字段的值到默认状态
234
+ - `clearValues()`: 清空表单所有字段的值
235
+
236
+ ##### requestApi 方法
237
+
238
+ - 类型:`FormFetchApi<T,R>`
239
+ - `setConfig(config: FetchOptions<T, R>)`: 设置请求配置等信息
240
+ - `setApi(api: RequestFetch<T, R>)`: 设置请求API
241
+ - `load(params?: T)`: 加载表单数据,可选择传入参数
242
+ - `getConfig()`: 获取当前请求的配置信息
243
+ - `get()`: 获取请求结果
244
+ - `getReady()`: 获取接口是否就绪状态
245
+ - `setParams(data: T, load?: boolean)`: 设置请求参数,指示设置参数后是否立即执行加载操作
246
+ - `reload()`: 重新加载表单数据
247
+
248
+ ---
249
+
250
+ ### 3. Table 表格组件
251
+
252
+ 高级表格组件,集成数据展示、分页、搜索、工具栏等功能。
253
+
254
+ #### 使用 ax-table组件
255
+
256
+ ```vue
257
+ <template>
258
+ <ax-table :api="getUserList">
259
+ <template #search>
260
+ <ax-table-select>
261
+ <ax-form-item label="用户名" field-name="username"></ax-form-item>
262
+ </ax-table-select>
263
+ </template>
264
+ <template #tool>
265
+ <ax-button @click=handleAdd>新增</ax-button>
266
+ </template>
267
+ <ax-table-column type="selection"/>
268
+ <ax-table-column label="序号" type="index"/>
269
+ <ax-table-column label="用户名" prop="username"/>
270
+ <ax-table-column label="邮箱" prop="username"/>
271
+ <ax-table-column label="操作" :component-props="actionConfig"/>
272
+ <template #footer>
273
+ <ax-table-page :pageSizes="[10, 20, 50, 100]"/>
274
+ </template>
275
+ </ax-table>
276
+ </template>
277
+ <script setup lang="ts">
278
+ import {getUserList} from '../api'
279
+ const actionConfig = {
280
+ actionList: [ {
281
+ text: "修改",
282
+ onClick: handleEdit
283
+ }, {
284
+ text: "删除",
285
+ onClick: handleDelete
286
+ }
287
+ ]
288
+ }
289
+ const handleEdit = (row: any) => {
290
+ console.log('编辑', row)
291
+ }
292
+ const handleDelete = (row: any) => {
293
+ console.log('删除', row)
294
+ }
295
+ const handleAdd = () => {
296
+ console.log('新增')
297
+ } </script>
298
+ ```
299
+
300
+
301
+
302
+ #### 使用 useTable Hook
303
+
304
+ ```vue
305
+ <template>
306
+ <Table />
307
+ </template>
308
+ <script setup lang="ts">
309
+ import { useTable } from '@aoao-y33/ui'
310
+ import {getUserList} from '../api'
311
+ const [Table, tableApi] = useTable({
312
+ api: getUserList,
313
+ columnConfig: {
314
+ fields: [
315
+ { type: 'selection' },
316
+ { label: "序号", type: "index", width: 80 },
317
+ { label: "用户名", prop: "username" },
318
+ { label: "邮箱", prop: "email" },
319
+ {
320
+ label: "操作",
321
+ type: "action",
322
+ componentProps: {
323
+ actionList: [
324
+ {
325
+ text: "修改",
326
+ onClick: handleEdit
327
+ },
328
+ {
329
+ text: "删除",
330
+ onClick: handleDelete
331
+ }
332
+ ]
333
+ }
334
+ }
335
+ ]
336
+ },
337
+ searchConfig: {
338
+ fieldConfig: {
339
+ fields: [
340
+ { label: "用户名", fieldName: "username", type: "text" }
341
+ ]
342
+ }
343
+ },
344
+ toolConfig: {
345
+ fields: [
346
+ {
347
+ text: "新增",
348
+ type: "primary",
349
+ onClick: handleAdd
350
+ }
351
+ ]
352
+ },
353
+ pageConfig: {
354
+ pageSizes: [10, 20, 50, 100]
355
+ }
356
+ })
357
+ const handleEdit = (row: any) => {
358
+ console.log('编辑', row)
359
+ }
360
+ const handleDelete = (row: any) => {
361
+ console.log('删除', row)
362
+ }
363
+ const handleAdd = () => {
364
+ console.log('新增')
365
+ } </script>
366
+ ```
367
+
368
+ #### 注册自定义列类型
369
+
370
+ ```typescript
371
+ import { addTableColumnField } from '@aoao-y33/ui'
372
+ import StatusColumn from './StatusColumn.vue'
373
+ addTableColumnField('status', StatusColumn)
374
+ ```
375
+
376
+ #### API
377
+
378
+ ##### useTable 返回值
379
+
380
+ | 属性 | 类型 | 说明 |
381
+ | ---------- | ------------- | ------------------ |
382
+ | Table | `Component` | 表格组件 |
383
+ | setTable | `StateApi` | 更新表格属性 |
384
+ | setPage | `StateApi` | 更新分页配置 |
385
+ | setSearch | `StateApi` | 更新搜索配置 |
386
+ | toolsApi | ``FieldsApi`` | 工具栏按钮管理 API |
387
+ | searchApi | `FieldsApi` | 搜索表单 API |
388
+ | fieldsApi | `FieldsApi` | 搜索字段管理 API |
389
+ | buttonsApi | `FieldsApi` | 搜索按钮管理API |
390
+
391
+ ##### tableApi 方法
392
+
393
+ - 类型:`TableApi`
394
+ - `getElTable()`: 获取ElTable 的所有原生方法和属性
395
+
396
+ **requestApi**方法:同上
397
+
398
+ ---
399
+
400
+ ### 4. Modal 弹窗组件
401
+
402
+ 通用弹窗组件,支持 Drawer 和 Dialog 两种模式,可动态渲染内容。
403
+
404
+ #### 使用ax-modal组件
405
+
406
+ ```vue
407
+ <template>
408
+ <ax-modal title="用户详情" v-model:open="open">
409
+ <user-detail/>
410
+ <template>
411
+ <ax-button @clicl="open = false">关闭</ax-button>
412
+ </template>
413
+ </ax-modal>
414
+ <button @click="open = true">打开弹窗</button>
415
+ </template>
416
+ <script setup lang="ts">
417
+ import { useModal } from '@aoao-y33/ui'
418
+ import UserDetail from './UserDetail.vue'
419
+ const open = ref(false);
420
+ </script>
421
+ ```
422
+
423
+
424
+
425
+ #### 使用 useModal Hook
426
+
427
+ ```vue
428
+ <template>
429
+ <Modal />
430
+ <button @click="openModal">打开弹窗</button> </template>
431
+ <script setup lang="ts">
432
+ import { useModal } from '@aoao-y33/ui'
433
+ import UserDetail from './UserDetail.vue'
434
+ const [Modal, modalApi] = useModal({
435
+ title: '用户详情',
436
+ type: 'dialog', // 'drawer' | 'dialog'
437
+ component: UserDetail,
438
+ buttonConfig: {
439
+ fields: [
440
+ {
441
+ text: '关闭',
442
+ onClick: () => modalApi.close()
443
+ }
444
+ ]
445
+ }
446
+ })
447
+ const openModal = () => {
448
+ modalApi.open()
449
+ }
450
+ // 获取内部组件实例
451
+ const componentInstance = modalApi.getComponent()
452
+ </script>
453
+ ```
454
+
455
+ #### API
456
+
457
+ ##### useModal 返回值
458
+
459
+ | 属性 | 类型 | 说明 |
460
+ | ------------ | ----------- | ---------------- |
461
+ | Modal | `Component` | 弹窗组件 |
462
+ | buttonsApi | `FieldsApi` | 按钮管理 |
463
+ | setModal | ` StateApi` | 设置弹窗属性 |
464
+ | open | `Function` | 打开弹窗 |
465
+ | getComponent | `Function` | 获取内部组件实例 |
466
+
467
+ ##### ModalApi 方法
468
+
469
+ - `close()`: 关闭弹窗
470
+ - `getModal()`: 获取原生弹窗组件实例
471
+
472
+ ---
473
+
474
+ ### 5. FormModal 表单弹窗组件
475
+
476
+ 结合表单和弹窗的组件,适用于编辑、新增等场景。
477
+
478
+ #### 使用ax-form-modal组件
479
+
480
+ ```vue
481
+ <template>
482
+ <ax-form-modal ref="modalRef" :api="updateUser" title="编辑用户" :api-config="apiConfog">
483
+ <ax-form-item label="用户名" field-name="username" :vtypes="['required']"></ax-form-item>
484
+ <ax-form-item label="用户名" field-name="username" :vtypes="['required', 'mail']"></ax-form-item>
485
+ </ax-form-modal>
486
+ <button @click="openEditModal">编辑</button>
487
+ </template>
488
+ <script setup lang="ts">
489
+ import {AxFormModal,AxFormItem } from '@aoao-y33/ui'
490
+ improt {updateUser} from './api'
491
+ const modalRef = ref();
492
+ const apiConfog = {
493
+ success(data){
494
+ modalRef.value?.close()
495
+ return data
496
+ }
497
+ }
498
+ })
499
+ </script>
500
+ ```
501
+
502
+
503
+
504
+ #### 使用 useFormModal Hook
505
+
506
+ ```vue
507
+ <template>
508
+ <FormModal />
509
+ <button @click="openEditModal">编辑</button>
510
+ </template>
511
+ <script setup lang="ts">
512
+ import { useFormModal } from '@aoao-y33/ui'
513
+ improt {updateUser} from './api'
514
+ const [FormModal, modalApi] = useFormModal({
515
+ title: '编辑用户',
516
+ api:updateUser,
517
+ fieldConfig: {
518
+ fields: [
519
+ { label: "用户名", fieldName: "username", type: "input", vtypes: ['required'] },
520
+ { label: "邮箱", fieldName: "email", type: "input", vtypes: ['required', 'mail'] } ]
521
+ },
522
+ onConfrim:(data:any)=>{
523
+ modalApi.load(data)
524
+ },
525
+ apiConfig:{
526
+ success(data){
527
+ modalApi.close()
528
+ return data
529
+ }
530
+ }
531
+ })
532
+ </script>
533
+ ```
534
+
535
+ #### API
536
+
537
+ ##### useFormModal 返回值
538
+
539
+ | 属性 | 类型 | 说明 |
540
+ | ---------- | ----------- | ---------------- |
541
+ | FormModal | `Component` | 表单弹窗组件 |
542
+ | open | `Function` | 打开弹窗 |
543
+ | close | `Function` | 关闭弹窗 |
544
+ | setModal | `StateApi` | 更新弹窗属性 |
545
+ | buttonsApi | `FieldsApi` | 按钮管理 API |
546
+ | fieldsApi | `FieldsApi` | 表单字段管理 API |
547
+
548
+ ##### formApi方法
549
+
550
+ **requestApi** 方法
551
+
552
+ **modalApi** 方法
553
+
554
+ ---
555
+
556
+ ### 6. Layout 布局组件
557
+
558
+ 灵活的布局组件,支持自定义布局方案。
559
+
560
+ #### 文件位置
561
+
562
+ #### 使用ax-layout组件
563
+
564
+ ```vue
565
+ <template>
566
+ <AxLayout :type="type">
567
+ <template #header>
568
+ <div>头部内容</div>
569
+ </template>
570
+ <template #aside>
571
+ <div>侧边栏内容</div>
572
+ </template>
573
+ <template #main>
574
+ <div>主要内容</div>
575
+ </template>
576
+ <template #footer>
577
+ <div>底部</div>
578
+ </template>
579
+ </AxLayout>
580
+ <button @click="setLayout('side')">切换布局</button>
581
+ </template>
582
+ <script setup lang="ts">
583
+ import { AxLayout } from '@aoao-y33/ui'
584
+ const type = ref("basic");
585
+ const setLayout = (_type:string)=>{
586
+ type.value = _type
587
+ }
588
+ </script>
589
+ ```
590
+
591
+ #### 使用useLayout Hook
592
+
593
+ ```vue
594
+ <template>
595
+ <Layout/>
596
+ <button @click="setLayout({type:'side'})">切换布局</button>
597
+ </template>
598
+ <script setup lang="ts">
599
+ import { useLayout } from '@aoao-y33/ui'
600
+ const [Layout,setLayout] = useLayout({
601
+ type:"basice",
602
+ header:()=>h("div","头部")
603
+ aside:()=>h("div","侧边栏内容")
604
+ main:()=>h("div","主要内容")
605
+ footer:()=>h("div","底部")
606
+ })
607
+ </script>
608
+ ```
609
+
610
+ #### 注册自定义布局
611
+
612
+ ```typescript
613
+ import { addLayoutField } from '@aoao-y33/ui'
614
+ import SidebarLayout from './SidebarLayout.vue'
615
+ addLayoutField('sidebar', SidebarLayout)
616
+ ```
617
+
618
+ #### API
619
+
620
+ ##### AxLayout Props
621
+
622
+ | 属性 | 类型 | 默认值 | 说明 |
623
+ | ---- | -------------------- | ------- | -------- |
624
+ | type | `keyof layoutFields` | 'basic' | 布局类型 |
625
+
626
+ ##### 插槽
627
+
628
+ | 插槽名 | 说明 |
629
+ | ------ | ------------ |
630
+ | header | 头部区域 |
631
+ | aside | 侧边栏区域 |
632
+ | main | 主要内容区域 |
633
+ | footer | 底部区域 |
634
+
635
+ ---
636
+
637
+ ## 🎨 工具函数
638
+
639
+ ### 图标工具
640
+
641
+ ```typescript
642
+ // 获取 Element Plus 图标
643
+ const SearchIcon = getIcons('Search')
644
+ ```
645
+
646
+ #### API
647
+
648
+ ##### getIcons(icon: string)
649
+
650
+ | 参数 | 类型 | 说明 |
651
+ | ------ | ------------------------ | ------------------------------ |
652
+ | icon | `string` | 图标名称(Element Plus Icons) |
653
+ | 返回值 | `Component \| undefined` | 图标组件 |
654
+
655
+ ### 组件注册工具
656
+
657
+ ```typescript
658
+ import { addButtonField, addFormField, addFormRules, addTableColumnField, addLayoutField } from '@aoao-y33/ui'
659
+ // 注册各类自定义组件
660
+ addButtonField('custom', CustomButtonComponent)
661
+ addFormField('custom-input', CustomInputComponent)
662
+ addFormRules('custom-rule', customRuleFunction)
663
+ addTableColumnField('custom-column', CustomColumnComponent)
664
+ addLayoutField('custom-layout', CustomLayoutComponent)
665
+ ```
666
+
667
+ #### API
668
+
669
+ ##### addButtonField(type: string, component: Component)
670
+
671
+ 注册自定义按钮类型
672
+
673
+ ##### addFormField(type: string, component: Component)
674
+
675
+ 注册自定义表单字段组件
676
+
677
+ ##### addFormRules(type: string, rule: VFormItemRule)
678
+
679
+ 注册自定义表单验证规则
680
+
681
+ ##### addTableColumnField(type: string, component: Component)
682
+
683
+ 注册自定义表格列组件
684
+
685
+ ##### addLayoutField(type: string, component: Component)
686
+
687
+ 注册自定义布局组件
688
+
689
+ ---
690
+
691
+ ## 📖 完整 API 参考
692
+
693
+ ### 导出组件
694
+
695
+ #### 按钮组件
696
+ - `AxButton` - 按钮组件
697
+ - `useButton` - 按钮 Hook
698
+
699
+ #### 表单组件
700
+ - `AxForm` - 表单组件
701
+ - `AxFormItem` - 表单项组件
702
+ - `useForm` - 表单 Hook
703
+ - `useFormExpose` - 表单暴露 API
704
+ - `useFormFetch` - 表单请求 Hook
705
+
706
+ #### 表格组件
707
+ - `AxTable` - 表格组件
708
+ - `AxTableColumn` - 表格列组件
709
+ - `AxTablePage` - 分页组件
710
+ - `AxTableSelect` - 搜索选择组件
711
+ - `useTable` - 表格 Hook
712
+ - `useTableExpose` - 表格暴露 API
713
+
714
+ #### 弹窗组件
715
+ - `AxModal` - 弹窗组件
716
+ - `AxFormModal` - 表单弹窗组件
717
+ - `useModal` - 弹窗 Hook
718
+ - `useFormModal` - 表单弹窗 Hook
719
+ - `useModalExpose` - 弹窗暴露 API
720
+
721
+ #### 布局组件
722
+ - `AxLayout` - 布局组件
723
+ - `useLayout` - 布局 Hook
724
+
725
+ #### 工具函数
726
+ - `getIcons` - 获取图标组件
727
+ - `addButtonField` - 注册按钮类型
728
+ - `addFormField` - 注册表单字段
729
+ - `addFormRules` - 注册表单规则
730
+ - `addTableColumnField` - 注册表格列
731
+ - `addLayoutField` - 注册布局类型
732
+
733
+ ### 类型导出
734
+
735
+ #### Button 类型
736
+ - `AxButtonProps` - 按钮属性类型
737
+ - `AxButtonEmits` - 按钮事件类型
738
+ - `AxButtonOptions` - 按钮配置类型
739
+
740
+ #### Form 类型
741
+ - `AxFormProps` - 表单属性类型
742
+ - `AxFormOptions` - 表单配置类型
743
+ - `AxFormItemProps` - 表单项属性类型
744
+ - `AxFormItemOptions` - 表单项配置类型
745
+ - `FormApi` - 表单 API 类型
746
+ - `FormFetchApi` - 表单请求 API 类型
747
+ - `VFormItemRule` - 表单验证规则类型
748
+
749
+ #### Table 类型
750
+ - `AxTableProps` - 表格属性类型
751
+ - `AxTableOptions` - 表格配置类型
752
+ - `AxTableColumnsProps` - 表格列属性类型
753
+ - `AxTablePageProps` - 分页属性类型
754
+ - `AxTableSelectProps` - 搜索选择属性类型
755
+
756
+ #### Modal 类型
757
+ - `AxModalProps` - 弹窗属性类型
758
+ - `AxModalOptions` - 弹窗配置类型
759
+ - `AxFormModalProps` - 表单弹窗属性类型
760
+ - `AxFormModalOptions` - 表单弹窗配置类型
761
+ - `ModalApi` - 弹窗 API 类型
762
+
763
+ #### 其他类型
764
+ - `StateApi` - 状态管理 API 类型
765
+ - `FieldsApi` - 字段管理 API 类型
766
+
767
+ ---
768
+
769
+ ## 🎨 主题定制
770
+
771
+ ### CSS 变量
772
+
773
+ 组件库提供了以下 CSS 变量用于主题定制:
774
+
775
+ ```css
776
+ root {
777
+ --ax-bg-color: #F5F5F5;
778
+ --ax-block-color: #FFFFFF;
779
+ --ax-border-color: #E7E7E7;
780
+ --ax-small-radius: 4px;
781
+ --ax-normal-radius: 10px;
782
+ --el-fill-color-lighter: #EEF1F5;
783
+ --el-fill-color-blank: #fff;
784
+ }
785
+ :root.dark {
786
+ --ax-bg-color: #14161A;
787
+ --ax-block-color: #1C1E23;
788
+ --ax-border-color: #1C1E23;
789
+ --el-fill-color-lighter: #313740;
790
+ --el-fill-color-blank: #191E27;
791
+ }
792
+ ```
793
+
794
+ ### 深色模式
795
+
796
+ 组件库内置深色模式支持,通过给根元素添加 `dark` 类来启用:
797
+
798
+ ```html
799
+ <html class="dark"> <!-- 深色模式 --> </html>
800
+ ```
801
+
802
+ ---
803
+
804
+ ## 🔗 相关项目
805
+
806
+ - [@aoao-y33/hooks](../hooks/README.md) - Hooks 工具库
807
+ - [@aoao-y33/utils](../utils/README.md) - 通用工具函数
808
+
809
+ ## 📄 许可证
810
+
811
+ MIT License