@qin-ui/antdv-next-pro 1.1.14 → 1.2.0
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/AI-CONTEXT.md +281 -23
- package/LICENSE +9 -0
- package/README.md +75 -58
- package/api.json +70 -28
- package/bin/init-ai.mjs +404 -49
- package/es/antdv-next-pro.css +9 -9
- package/es/component-provider/{index-Daiw7IxY.js → index-Tesc9NuK.js} +2 -1
- package/es/component-provider/index-Tesc9NuK.js.map +1 -0
- package/es/component-provider/index.js +2 -1
- package/es/component-provider/index.js.map +1 -0
- package/es/components/component-provider/components/index.vue.d.ts +27 -0
- package/es/components/component-provider/components/index.vue.d.ts.map +1 -0
- package/es/components/component-provider/constants/index.d.ts +16 -0
- package/es/components/component-provider/constants/index.d.ts.map +1 -0
- package/es/components/component-provider/index.d.ts +4 -0
- package/es/components/component-provider/index.d.ts.map +1 -0
- package/es/components/component-provider/types/index.d.ts +26 -0
- package/es/components/component-provider/types/index.d.ts.map +1 -0
- package/es/components/form/components/BaseField/index.vue.d.ts +13 -0
- package/es/components/form/components/BaseField/index.vue.d.ts.map +1 -0
- package/es/components/form/components/BaseField/utils/index.d.ts +3 -0
- package/es/components/form/components/BaseField/utils/index.d.ts.map +1 -0
- package/es/components/form/components/BaseFormItem/index.vue.d.ts +9 -0
- package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -0
- package/es/components/form/components/ContainerFragment/index.vue.d.ts +23 -0
- package/es/components/form/components/ContainerFragment/index.vue.d.ts.map +1 -0
- package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts +31 -0
- package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts.map +1 -0
- package/es/components/form/components/PathProvider/index.vue.d.ts +24 -0
- package/es/components/form/components/PathProvider/index.vue.d.ts.map +1 -0
- package/es/components/form/components/ProForm/index.vue.d.ts +36 -0
- package/es/components/form/components/ProForm/index.vue.d.ts.map +1 -0
- package/es/components/form/components/SlotComponent/index.vue.d.ts +7 -0
- package/es/components/form/components/SlotComponent/index.vue.d.ts.map +1 -0
- package/es/components/form/components/index.d.ts +12 -0
- package/es/components/form/components/index.d.ts.map +1 -0
- package/es/components/form/constants/index.d.ts +81 -0
- package/es/components/form/constants/index.d.ts.map +1 -0
- package/es/components/form/hooks/index.d.ts +5 -0
- package/es/components/form/hooks/index.d.ts.map +1 -0
- package/es/components/form/hooks/useFields.d.ts +57 -0
- package/es/components/form/hooks/useFields.d.ts.map +1 -0
- package/es/components/form/hooks/useForm.d.ts +93 -0
- package/es/components/form/hooks/useForm.d.ts.map +1 -0
- package/es/components/form/hooks/useFormRef.d.ts +30 -0
- package/es/components/form/hooks/useFormRef.d.ts.map +1 -0
- package/es/components/form/index.d.ts +7 -0
- package/es/components/form/index.d.ts.map +1 -0
- package/es/components/form/types/index.d.ts +251 -0
- package/es/components/form/types/index.d.ts.map +1 -0
- package/es/components/table/components/ColumnControl.vue.d.ts +9 -0
- package/es/components/table/components/ColumnControl.vue.d.ts.map +1 -0
- package/es/components/table/components/DefaultSearchFormContainer.vue.d.ts +18 -0
- package/es/components/table/components/DefaultSearchFormContainer.vue.d.ts.map +1 -0
- package/es/components/table/components/DefaultTableContainer.vue.d.ts +18 -0
- package/es/components/table/components/DefaultTableContainer.vue.d.ts.map +1 -0
- package/es/components/table/components/ProTable.vue.d.ts +118 -0
- package/es/components/table/components/ProTable.vue.d.ts.map +1 -0
- package/es/components/table/components/SearchForm.vue.d.ts +48 -0
- package/es/components/table/components/SearchForm.vue.d.ts.map +1 -0
- package/es/components/table/components/SizeControl.vue.d.ts +12 -0
- package/es/components/table/components/SizeControl.vue.d.ts.map +1 -0
- package/es/components/table/components/icons/ColumnHeightOutlined.vue.d.ts +3 -0
- package/es/components/table/components/icons/ColumnHeightOutlined.vue.d.ts.map +1 -0
- package/es/components/table/components/icons/DownOutlined.vue.d.ts +3 -0
- package/es/components/table/components/icons/DownOutlined.vue.d.ts.map +1 -0
- package/es/components/table/components/icons/FilterOutlined.vue.d.ts +3 -0
- package/es/components/table/components/icons/FilterOutlined.vue.d.ts.map +1 -0
- package/es/components/table/components/index.d.ts +5 -0
- package/es/components/table/components/index.d.ts.map +1 -0
- package/es/components/table/index.d.ts +8 -0
- package/es/components/table/index.d.ts.map +1 -0
- package/es/components/table/types/index.d.ts +48 -0
- package/es/components/table/types/index.d.ts.map +1 -0
- package/es/components/table/useTable.d.ts +111 -0
- package/es/components/table/useTable.d.ts.map +1 -0
- package/es/form/{index-7clzY8ZD.js → index-CcP5OaUd.js} +12 -6
- package/es/form/index-CcP5OaUd.js.map +1 -0
- package/es/form/index.js +4 -3
- package/es/form/index.js.map +1 -0
- package/es/index.d.ts +76 -1522
- package/es/index.d.ts.map +1 -0
- package/es/index.js +14 -23
- package/es/index.js.map +1 -0
- package/es/shared/core/index.d.ts +6 -0
- package/es/shared/core/index.d.ts.map +1 -0
- package/es/shared/ui/index.d.ts +9 -0
- package/es/shared/ui/index.d.ts.map +1 -0
- package/es/table/index.js +11 -9
- package/es/table/index.js.map +1 -0
- package/package.json +10 -11
- package/src/components/component-provider/components/index.vue +67 -0
- package/src/components/component-provider/constants/index.ts +177 -0
- package/src/components/component-provider/index.ts +6 -0
- package/src/components/component-provider/types/index.ts +59 -0
- package/src/components/form/components/BaseField/index.vue +181 -0
- package/src/components/form/components/BaseField/utils/index.ts +16 -0
- package/src/components/form/components/BaseFormItem/index.vue +158 -0
- package/src/components/form/components/ContainerFragment/index.vue +24 -0
- package/src/components/form/components/GroupedFieldAttrs/index.vue +119 -0
- package/src/components/form/components/PathProvider/index.vue +19 -0
- package/src/components/form/components/ProForm/index.vue +104 -0
- package/src/components/form/components/SlotComponent/index.vue +26 -0
- package/src/components/form/components/index.ts +15 -0
- package/src/components/form/constants/index.ts +140 -0
- package/src/components/form/hooks/index.ts +5 -0
- package/src/components/form/hooks/useFields.ts +67 -0
- package/src/components/form/hooks/useForm.ts +110 -0
- package/src/components/form/hooks/useFormRef.ts +35 -0
- package/src/components/form/index.ts +29 -0
- package/src/components/form/types/index.ts +317 -0
- package/src/components/table/components/ColumnControl.vue +142 -0
- package/src/components/table/components/DefaultSearchFormContainer.vue +22 -0
- package/src/components/table/components/DefaultTableContainer.vue +19 -0
- package/src/components/table/components/ProTable.vue +372 -0
- package/src/components/table/components/SearchForm.vue +296 -0
- package/src/components/table/components/SizeControl.vue +54 -0
- package/src/components/table/components/icons/ColumnHeightOutlined.vue +4 -0
- package/src/components/table/components/icons/DownOutlined.vue +4 -0
- package/src/components/table/components/icons/FilterOutlined.vue +4 -0
- package/src/components/table/components/index.ts +4 -0
- package/src/components/table/index.ts +14 -0
- package/src/components/table/types/index.ts +52 -0
- package/src/components/table/useTable.ts +129 -0
- package/src/index.ts +81 -0
- package/src/shared/core/index.ts +37 -0
- package/src/shared/ui/index.ts +55 -0
- package/es/core/index-ghYuQ3Sy.js +0 -360
- package/es/vendor/utils/lodash-es-p6jau26B.js +0 -1120
package/AI-CONTEXT.md
CHANGED
|
@@ -1,37 +1,295 @@
|
|
|
1
|
-
# @qin-ui/antdv-next-pro
|
|
1
|
+
# @qin-ui/antdv-next-pro — AI 上下文
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Schema-driven Vue 3 高级组件库,基于 antdv-next。用 JavaScript 对象描述 UI,而非在模板中堆砌组件标签。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
## 1. 架构概览
|
|
8
|
+
|
|
9
|
+
### 1.1 三层架构
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
┌─────────────────────────────────────────────────┐
|
|
13
|
+
│ Field[] 配置层(用户编写的 JS 对象) │
|
|
14
|
+
├─────────────────────────────────────────────────┤
|
|
15
|
+
│ @qin-ui/antdv-next-pro(Schema 解析 + 属性分层) │
|
|
16
|
+
│ 逐层剥离 → Grid→a-col, FormItem→a-form-item, │
|
|
17
|
+
│ 剩余属性→输入控件 │
|
|
18
|
+
├─────────────────────────────────────────────────┤
|
|
19
|
+
│ antdv-next(Vue 3 组件库) │
|
|
20
|
+
│ a-input / a-select / a-date-picker / a-table ... │
|
|
21
|
+
└─────────────────────────────────────────────────┘
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
ProForm/ProTable 是**渲染引擎**,不是组件库。Field 属性被逐层剥离分发到不同层级的 antdv-next 组件。
|
|
25
|
+
|
|
26
|
+
### 1.2 组件解析链
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
Field.component → componentMap[component] → antdv-next 组件
|
|
30
|
+
'input' → Input (a-input)
|
|
31
|
+
'select' → Select (a-select)
|
|
32
|
+
'switch' → Switch (a-switch)
|
|
33
|
+
'custom' → VueComponent (直接渲染)
|
|
34
|
+
'my-custom' → ProComponentProvider 注入的自定义组件
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 1.3 内置组件映射表
|
|
38
|
+
|
|
39
|
+
| component | antdv-next 组件 | 常用输入控件层透传 Props |
|
|
40
|
+
| :------------------ | :-------------- | :--------------------------------------------------------------------- |
|
|
41
|
+
| `input` | Input | placeholder, maxlength, allowClear, addonBefore, addonAfter, showCount |
|
|
42
|
+
| `textarea` | TextArea | rows, maxlength, showCount, autoSize |
|
|
43
|
+
| `input-password` | InputPassword | placeholder, maxlength, visibilityToggle |
|
|
44
|
+
| `input-otp` | InputOTP | length, mask, separator |
|
|
45
|
+
| `input-search` | InputSearch | placeholder, loading, onSearch |
|
|
46
|
+
| `input-number` | InputNumber | min, max, step, precision, formatter, parser |
|
|
47
|
+
| `select` | Select | **options**, mode, showSearch, allowClear, maxTagCount, loading |
|
|
48
|
+
| `auto-complete` | AutoComplete | **options**, filterOption, allowClear |
|
|
49
|
+
| `cascader` | Cascader | **options**, fieldNames, showSearch, expandTrigger |
|
|
50
|
+
| `date-picker` | DatePicker | picker, format, showTime, disabledDate, allowClear |
|
|
51
|
+
| `range-picker` | RangePicker | format, showTime, disabledDate, allowClear |
|
|
52
|
+
| `time-picker` | TimePicker | format, showSecond, allowClear, hourStep |
|
|
53
|
+
| `time-range-picker` | TimeRangePicker | format, allowClear |
|
|
54
|
+
| `checkbox-group` | CheckboxGroup | **options**, direction |
|
|
55
|
+
| `radio-group` | RadioGroup | **options**, direction, buttonStyle |
|
|
56
|
+
| `switch` | Switch | checkedChildren, unCheckedChildren, loading |
|
|
57
|
+
| `slider` | Slider | min, max, step, marks, range, tooltip |
|
|
58
|
+
| `tree-select` | TreeSelect | **treeData**, showSearch, treeCheckable |
|
|
59
|
+
| `transfer` | Transfer | **dataSource**, **titles**, **targetKeys**, showSearch |
|
|
60
|
+
| `custom` | 自定义 | component 传入 Vue 组件或 h() 渲染函数 |
|
|
61
|
+
|
|
62
|
+
> **写任何输入控件属性前,必须查阅 [antdv-next 文档](https://antdv-next.com/llms-full-cn.txt) 确认属性名和类型。**
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 2. 属性分层传递(核心规则)
|
|
67
|
+
|
|
68
|
+
Field 属性逐层剥离,分发到渲染树的不同目标:
|
|
69
|
+
|
|
70
|
+
```html
|
|
71
|
+
<a-col :span="8">
|
|
72
|
+
<a-form-item label="城市" :rules="[...]">
|
|
73
|
+
<a-select placeholder="选择" :options="[...]" />
|
|
74
|
+
</a-form-item>
|
|
75
|
+
</a-col>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 属性归属
|
|
79
|
+
|
|
80
|
+
**Grid 层 → `<a-col>`**(仅 grid 启用时生效)
|
|
81
|
+
`span`, `order`, `offset`, `push`, `pull`, `flex`, `xs`, `sm`, `md`, `lg`, `xl`, `xxl`
|
|
82
|
+
|
|
83
|
+
**FormItem 层 → `<a-form-item>`**
|
|
84
|
+
`label`, `rules`, `colon`, `labelAlign`, `labelCol`, `wrapperCol`, `tooltip`, `extra`, `help`, `validateFirst`, `validateTrigger`, `valuePropName`, `normalize`, `formItemClass`, `formItemStyle`, `formItemContainer`, `formItemDataAttrs`
|
|
85
|
+
|
|
86
|
+
**输入控件层 → 输入组件**
|
|
87
|
+
其余所有属性(`disabled`, `placeholder`, `allowClear`, `options`, `showSearch`, `maxlength`, `mode`, `componentDataAttrs`, `componentClass`, `componentStyle` 等)
|
|
88
|
+
|
|
89
|
+
**ProForm 消费(不绑定 DOM):** `component`, `fields`, `hidden`, `slots`, `modelProp`, `valueFormatter`, `componentContainer`, `extraProps`
|
|
90
|
+
|
|
91
|
+
### modelProp
|
|
92
|
+
|
|
93
|
+
决定 `v-model:xxx` 绑定变量名:
|
|
94
|
+
|
|
95
|
+
- 默认 `'value'` → `v-model:value`
|
|
96
|
+
- Switch/Checkbox 使用 `'checked'`
|
|
97
|
+
- **ProComponentProvider 已为 `switch` 预设 `modelProp: 'checked'`**,通常无需手动指定
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 3. 渐进式用法
|
|
102
|
+
|
|
103
|
+
### 第一阶段:配置驱动
|
|
104
|
+
|
|
105
|
+
**禁止在模板中手写 `<a-form-item>` 或 `<a-input>`。**
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
import { ProForm, useForm } from '@qin-ui/antdv-next-pro';
|
|
109
|
+
|
|
110
|
+
const form = useForm({ username: '', password: '' }, [
|
|
111
|
+
{
|
|
112
|
+
path: 'username',
|
|
113
|
+
component: 'input',
|
|
114
|
+
label: '用户名',
|
|
115
|
+
placeholder: '请输入用户名',
|
|
116
|
+
rules: [{ required: true, message: '请输入' }],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
path: 'password',
|
|
120
|
+
component: 'input-password',
|
|
121
|
+
label: '密码',
|
|
122
|
+
placeholder: '请输入密码',
|
|
123
|
+
rules: [{ required: true, message: '请输入' }],
|
|
124
|
+
},
|
|
125
|
+
]);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
```html
|
|
129
|
+
<template>
|
|
130
|
+
<ProForm :form="form" />
|
|
131
|
+
</template>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 第二阶段:字段联动
|
|
135
|
+
|
|
136
|
+
`disabled`、`hidden`、`rules` 等控制属性支持多种联动方式:
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
import { computed, ref } from 'vue';
|
|
140
|
+
|
|
141
|
+
const form = useForm({ hasLimit: false, limitCount: undefined }, [
|
|
142
|
+
{ path: 'hasLimit', component: 'switch', label: '开启限制' },
|
|
143
|
+
{
|
|
144
|
+
path: 'limitCount',
|
|
145
|
+
component: 'input-number',
|
|
146
|
+
label: '限制次数',
|
|
147
|
+
// 方式一:computed() — 声明式,推荐用于初始化时已知的联动
|
|
148
|
+
disabled: computed(() => !form.formData.hasLimit),
|
|
149
|
+
rules: computed(() => [
|
|
150
|
+
{ required: form.formData.hasLimit, message: '请输入' },
|
|
151
|
+
]),
|
|
152
|
+
},
|
|
153
|
+
]);
|
|
154
|
+
|
|
155
|
+
// 方式二:ref() — 适合外部状态控制
|
|
156
|
+
const isDisabled = ref(false); // disabled: isDisabled
|
|
157
|
+
|
|
158
|
+
// 方式三:setField() — 命令式,适合运行时事件触发
|
|
159
|
+
form.setField('limitCount', { disabled: true });
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**选择:** 初始化联动 → `computed()`;运行时事件 → `setField()`;外部共享状态 → `ref()`。代码越简单越好。
|
|
163
|
+
|
|
164
|
+
### 第三阶段:自定义扩展
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
import { h } from 'vue';
|
|
168
|
+
|
|
169
|
+
const form = useForm({ agreement: false }, [
|
|
170
|
+
{
|
|
171
|
+
path: 'agreement',
|
|
172
|
+
component: (p, ctx) => h(MyCheckbox, { ...p, ...ctx.attrs }),
|
|
173
|
+
modelProp: 'checked',
|
|
174
|
+
rules: [
|
|
175
|
+
{
|
|
176
|
+
validator: (_, val) =>
|
|
177
|
+
val ? Promise.resolve() : Promise.reject('请同意'),
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
},
|
|
181
|
+
]);
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
```html
|
|
185
|
+
<ProForm :form="form">
|
|
186
|
+
<!-- 同名插槽接管渲染,scoped 内置 value/checked 等绑定参数 -->
|
|
187
|
+
<template #agreement="scoped">
|
|
188
|
+
<a-checkbox v-bind="scoped">同意协议</a-checkbox>
|
|
189
|
+
</template>
|
|
190
|
+
</ProForm>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## 4. 反模式
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
// ❌ 不要手写 a-form-item — ProForm 自动渲染
|
|
199
|
+
// ❌ 不要猜测属性名 — 必须查阅 antdv-next 文档
|
|
200
|
+
{ path: 'city', component: 'select', searchable: true } // 错:Select 没有 searchable
|
|
201
|
+
{ path: 'city', component: 'select', showSearch: true } // 对:查阅文档后使用 showSearch
|
|
202
|
+
|
|
203
|
+
// ❌ path 必须精确对应 formData 中的键名,否则数据/校验丢失
|
|
204
|
+
// ✅ 联动优先用 computed(),运行时用 setField(),不要过度设计
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## 5. ProComponentProvider:全局默认配置
|
|
210
|
+
|
|
211
|
+
应用顶层统一配置所有子组件默认属性。
|
|
212
|
+
|
|
213
|
+
**INJECT_CONFIG 预设默认值:**
|
|
214
|
+
|
|
215
|
+
| 组件 | 预设默认值 |
|
|
216
|
+
| :---------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------- |
|
|
217
|
+
| `switch` | `{ modelProp: 'checked' }` |
|
|
218
|
+
| `input` | `{ maxlength: 100, allowClear: true, placeholder: '请输入' }` |
|
|
219
|
+
| `textarea` | `{ maxlength: 200, autoSize: {minRows:3,maxRows:6}, showCount: true, allowClear: true, placeholder: '请输入' }` |
|
|
220
|
+
| `select` / `cascader` / `auto-complete` | `{ allowClear: true, placeholder: '请选择', getPopupContainer }` |
|
|
221
|
+
| `input-number` | `{ max: 10^15, min: -(10^15), controls: false, placeholder: '请输入', style: {width:'100%'} }` |
|
|
222
|
+
| `date-picker` / `range-picker` / `time-*` | `{ allowClear: true, getPopupContainer, style: {width:'100%'} }` |
|
|
223
|
+
| `pro-table` | `{ pagination: {showTotal, showSizeChanger, showQuickJumper}, searchFormConfig: {layout:'grid'}, control: true, addIndexColumn: true }` |
|
|
224
|
+
| `pro-form` | `{ grid: { gutter: {xs:8, sm:16, md:16, lg:24} } }` |
|
|
225
|
+
| `pro-form-item` | `{ validateFirst: true, span: 8 }` |
|
|
226
|
+
|
|
227
|
+
**优先级:** Field 级别配置 > `componentVars` > `INJECT_CONFIG` 预设
|
|
228
|
+
|
|
229
|
+
```vue
|
|
230
|
+
<template>
|
|
231
|
+
<ProComponentProvider :component-vars="config">
|
|
232
|
+
<ProForm :form="form" />
|
|
233
|
+
<ProTable :table="table" />
|
|
234
|
+
</ProComponentProvider>
|
|
235
|
+
</template>
|
|
236
|
+
|
|
237
|
+
<script setup lang="ts">
|
|
238
|
+
import { ProComponentProvider } from '@qin-ui/antdv-next-pro';
|
|
239
|
+
|
|
240
|
+
const config = {
|
|
241
|
+
'pro-form-item': { validateFirst: true, span: 6 },
|
|
242
|
+
input: { maxlength: 200 },
|
|
243
|
+
select: { showSearch: true },
|
|
244
|
+
'pro-table': { addIndexColumn: false },
|
|
245
|
+
};
|
|
246
|
+
</script>
|
|
9
247
|
```
|
|
10
248
|
|
|
11
|
-
|
|
249
|
+
---
|
|
12
250
|
|
|
13
|
-
|
|
251
|
+
## 6. ProTable 速览
|
|
14
252
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
253
|
+
```vue
|
|
254
|
+
<script setup lang="ts">
|
|
255
|
+
import { ProTable, useTable } from '@qin-ui/antdv-next-pro';
|
|
18
256
|
|
|
19
|
-
|
|
257
|
+
type Row = { id: number; name: string; status: string };
|
|
20
258
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
259
|
+
const table = useTable<Row>({
|
|
260
|
+
columns: [
|
|
261
|
+
{ title: 'ID', dataIndex: 'id', width: 80 },
|
|
262
|
+
{ title: '姓名', dataIndex: 'name', width: 120 },
|
|
263
|
+
{ title: '状态', dataIndex: 'status', width: 100 },
|
|
264
|
+
],
|
|
265
|
+
// searchFields 格式与 ProForm fields 完全一致,支持相同的分层剥离机制
|
|
266
|
+
searchFields: [
|
|
267
|
+
{ path: 'name', component: 'input', placeholder: '搜索姓名' },
|
|
268
|
+
{ path: 'status', component: 'select', options: [...], placeholder: '状态' },
|
|
269
|
+
],
|
|
270
|
+
});
|
|
25
271
|
|
|
26
|
-
|
|
272
|
+
// searchForm 是 ProForm 实例,可使用所有表单方法
|
|
273
|
+
table.searchForm.setField('name', { placeholder: '请输入' });
|
|
274
|
+
</script>
|
|
275
|
+
|
|
276
|
+
<template>
|
|
277
|
+
<ProTable
|
|
278
|
+
:table="table"
|
|
279
|
+
:search="() => fetchData()"
|
|
280
|
+
addIndexColumn
|
|
281
|
+
immediateSearch
|
|
282
|
+
/>
|
|
283
|
+
</template>
|
|
284
|
+
```
|
|
27
285
|
|
|
28
|
-
|
|
286
|
+
---
|
|
29
287
|
|
|
30
|
-
|
|
288
|
+
## 7. 参考
|
|
31
289
|
|
|
32
|
-
|
|
290
|
+
按优先级查阅:
|
|
33
291
|
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
292
|
+
1. **`node_modules/@qin-ui/antdv-next-pro/api.json`** — 结构化 API 元数据(函数签名、类型定义、JSDoc 示例)
|
|
293
|
+
2. **`node_modules/@qin-ui/antdv-next-pro/README.md`** — 完整使用文档和代码示例
|
|
294
|
+
3. **`https://antdv-next.com/llms-full-cn.txt`** — antdv-next 全部组件 API(确认输入控件层属性时必查)
|
|
295
|
+
4. **`https://antdv-next.com/llms-semantic-cn.md`** — antdv-next 组件语义化 DOM 结构(自定义样式时必查)
|
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present pro-components
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @qin-ui/antdv-next-pro
|
|
2
2
|
|
|
3
|
-
> 基于 **antdv-next
|
|
3
|
+
> 基于 **antdv-next**(Vue 3 组件库,对齐 Ant Design 设计规范)和 **Vue 3.x** 的二次封装高级组件库,提供高度可配置、Schema 驱动的 `ProForm`、`ProTable` 和 `ProComponentProvider`。
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<img src="https://img.shields.io/badge/antdv--next-v1.1%2B-blue" alt="antdv-next" />
|
|
@@ -63,23 +63,24 @@ const form = useForm<FormData>({}, [
|
|
|
63
63
|
|
|
64
64
|
### `useForm` 返回值 (Form 实例)
|
|
65
65
|
|
|
66
|
-
| 属性/方法 | 类型 | 说明
|
|
67
|
-
| :------------------------- | :------------------------------- |
|
|
68
|
-
| `formRef` | `Ref<FormInstance \| undefined>` |
|
|
69
|
-
| `formData` | `Reactive<D>` | 响应式表单数据对象
|
|
70
|
-
| `fields` | `Ref<Field<D>[]>` | 响应式字段配置数组
|
|
71
|
-
| `getFormData(path?)` | `(path?) => any` | 读取表单字段或整个表单的值(支持深层路径)
|
|
72
|
-
| `setFormData(path, value)` | `-` | 安全更新指定路径的值,支持批量设置与函数式更新
|
|
73
|
-
| `setField(path, patch)` | `-` | 动态增量更新某一个字段的 Schema 配置参数
|
|
74
|
-
| `resetFormData()` | `-` | 重置表单数据为初始值
|
|
66
|
+
| 属性/方法 | 类型 | 说明 |
|
|
67
|
+
| :------------------------- | :------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
68
|
+
| `formRef` | `Ref<FormInstance \| undefined>` | **antdv-next 原生 [FormInstance](https://antdv-next.com/components/form-cn#api)** 引用,可直接调用 `validate()`、`resetFields()`、`validateFields([paths])`、`clearValidate([paths])` 等原生方法 |
|
|
69
|
+
| `formData` | `Reactive<D>` | 响应式表单数据对象 |
|
|
70
|
+
| `fields` | `Ref<Field<D>[]>` | 响应式字段配置数组 |
|
|
71
|
+
| `getFormData(path?)` | `(path?) => any` | 读取表单字段或整个表单的值(支持深层路径) |
|
|
72
|
+
| `setFormData(path, value)` | `-` | 安全更新指定路径的值,支持批量设置与函数式更新 |
|
|
73
|
+
| `setField(path, patch)` | `-` | 动态增量更新某一个字段的 Schema 配置参数 |
|
|
74
|
+
| `resetFormData()` | `-` | 重置表单数据为初始值 |
|
|
75
75
|
|
|
76
76
|
### `ProForm` Props
|
|
77
77
|
|
|
78
|
-
| 属性
|
|
79
|
-
|
|
|
80
|
-
| `form`
|
|
81
|
-
| `grid`
|
|
82
|
-
|
|
|
78
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
79
|
+
| :--------- | :--------------------------------------------------------------------------- | :------ | :--------------------------------------------------------------------------------------- |
|
|
80
|
+
| `form` | `Form<D>` | - | `useForm` 返回的实例 |
|
|
81
|
+
| `grid` | `boolean \| GridProps` | `false` | 是否启用 Grid 网格布局 |
|
|
82
|
+
| `disabled` | `boolean` | `false` | 是否全局禁用整个表单 |
|
|
83
|
+
| 其余属性 | 继承 antdv-next [`FormProps`](https://antdv-next.com/components/form-cn#api) | - | 如 `labelCol`、`wrapperCol`、`labelAlign`、`colon` 等,直接透传至 antdv-next `Form` 组件 |
|
|
83
84
|
|
|
84
85
|
---
|
|
85
86
|
|
|
@@ -89,28 +90,28 @@ const form = useForm<FormData>({}, [
|
|
|
89
90
|
|
|
90
91
|
### 公共基础属性(`Base`)
|
|
91
92
|
|
|
92
|
-
| 属性 | 类型 | 说明
|
|
93
|
-
| :------------------- | :---------------------------------- |
|
|
94
|
-
| `path` | `Path<D>` | 字段标识,需对应 `formData` 中的 key
|
|
95
|
-
| `label` | `string \| Component` | 字段标签名称,支持直接传入 Vue 组件渲染
|
|
96
|
-
| `component` | 见下方内置组件列表 | 使用的内置组件名或自定义组件
|
|
97
|
-
| `hidden` | `MaybeRef<boolean>` | 字段是否隐藏,支持 Ref / Computed 响应式
|
|
98
|
-
| `disabled` | `MaybeRef<boolean>` | 组件是否禁用,支持 Ref / Computed 响应式
|
|
99
|
-
| `rules` | `FormItemRule[]` | 字段数据校验规则
|
|
100
|
-
| `span` | `number` | Grid 占位列宽(仅在开启 `grid` 模式下有效)
|
|
101
|
-
| `slots` | `Partial<ComponentSlots<FormItem>>` | FormItem 插槽(包含 `label`/`extra`/`help`/`tooltip` 等)
|
|
102
|
-
| `grid` | `boolean \| GridProps` | 嵌套子字段的 Grid 配置
|
|
103
|
-
| `fields` | `Fields<D>` | 嵌套子字段配置数组(用于复杂分组)
|
|
104
|
-
| `formItemStyle` | `CSSProperties` | FormItem 样式属性
|
|
105
|
-
| `formItemClass` | `string` | FormItem 自定义类名
|
|
106
|
-
| `formItemContainer` | `Component` | FormItem 外层包裹容器组件
|
|
107
|
-
| `formItemDataAttrs` | `Record<string, string>` | 附加到 FormItem DOM 节点上的自定义 data 属性
|
|
108
|
-
| `componentStyle` | `CSSProperties` | 表单输入组件的样式属性
|
|
109
|
-
| `componentClass` | `string` | 表单输入组件的自定义类名
|
|
110
|
-
| `componentContainer` | `Component` | 表单输入组件的外层包裹容器组件
|
|
111
|
-
| `componentDataAttrs` | `Record<string, string>` | 附加到输入组件 DOM 节点上的自定义 data 属性
|
|
112
|
-
| `valueFormatter` | `ValueFormatter` | 字段值格式化与转换器(支持 get/set 双向处理器)
|
|
113
|
-
| `modelProp` | `string` | 双向绑定的数据名,默认 `'value'`
|
|
93
|
+
| 属性 | 类型 | 说明 |
|
|
94
|
+
| :------------------- | :---------------------------------- | :------------------------------------------------------------------------------------------------------------------ |
|
|
95
|
+
| `path` | `Path<D>` | 字段标识,需对应 `formData` 中的 key |
|
|
96
|
+
| `label` | `string \| Component` | 字段标签名称,支持直接传入 Vue 组件渲染 |
|
|
97
|
+
| `component` | 见下方内置组件列表 | 使用的内置组件名或自定义组件 |
|
|
98
|
+
| `hidden` | `MaybeRef<boolean>` | 字段是否隐藏,支持 Ref / Computed 响应式 |
|
|
99
|
+
| `disabled` | `MaybeRef<boolean>` | 组件是否禁用,支持 Ref / Computed 响应式 |
|
|
100
|
+
| `rules` | `FormItemRule[]` | 字段数据校验规则 |
|
|
101
|
+
| `span` | `number` | Grid 占位列宽(仅在开启 `grid` 模式下有效) |
|
|
102
|
+
| `slots` | `Partial<ComponentSlots<FormItem>>` | FormItem 插槽(包含 `label`/`extra`/`help`/`tooltip` 等) |
|
|
103
|
+
| `grid` | `boolean \| GridProps` | 嵌套子字段的 Grid 配置 |
|
|
104
|
+
| `fields` | `Fields<D>` | 嵌套子字段配置数组(用于复杂分组) |
|
|
105
|
+
| `formItemStyle` | `CSSProperties` | FormItem 样式属性 |
|
|
106
|
+
| `formItemClass` | `string` | FormItem 自定义类名 |
|
|
107
|
+
| `formItemContainer` | `Component` | FormItem 外层包裹容器组件 |
|
|
108
|
+
| `formItemDataAttrs` | `Record<string, string>` | 附加到 FormItem DOM 节点上的自定义 data 属性 |
|
|
109
|
+
| `componentStyle` | `CSSProperties` | 表单输入组件的样式属性 |
|
|
110
|
+
| `componentClass` | `string` | 表单输入组件的自定义类名 |
|
|
111
|
+
| `componentContainer` | `Component` | 表单输入组件的外层包裹容器组件 |
|
|
112
|
+
| `componentDataAttrs` | `Record<string, string>` | 附加到输入组件 DOM 节点上的自定义 data 属性 |
|
|
113
|
+
| `valueFormatter` | `ValueFormatter` | 字段值格式化与转换器(支持 get/set 双向处理器) |
|
|
114
|
+
| `modelProp` | `string` | 双向绑定的数据名,默认 `'value'`。Switch/Checkbox 使用 `'checked'`,**ProComponentProvider 已为 `switch` 预设此值** |
|
|
114
115
|
|
|
115
116
|
> [!NOTE]
|
|
116
117
|
> **响应式支持**:除了 `component`、`fields`、`slots`、`modelProp`、`formItemContainer`、`componentContainer`、`valueFormatter` 之外,所有属性均高度支持 `Ref` 或 `ComputedRef` 响应式数据。
|
|
@@ -215,42 +216,58 @@ const table = useTable<Row>({
|
|
|
215
216
|
|
|
216
217
|
### `useTable` 配置参数
|
|
217
218
|
|
|
218
|
-
| 参数名 | 类型 | 说明
|
|
219
|
-
| :------------- | :--------------- |
|
|
220
|
-
| `columns` | `Column<D>[]` | 表格列 Schema 配置,支持响应式 `hidden`
|
|
221
|
-
| `dataSource` | `T[]` | 静态初始数据源数组
|
|
222
|
-
| `pageParam` | `PageParam` | 初始分页参数(current, pageSize, total)
|
|
223
|
-
| `searchParam` | `DeepPartial<D>` | 搜索栏表单初始填充数据
|
|
224
|
-
| `searchFields` | `Fields<D>` | 搜索栏字段 Schema
|
|
219
|
+
| 参数名 | 类型 | 说明 |
|
|
220
|
+
| :------------- | :--------------- | :---------------------------------------------------------------------------------------------- |
|
|
221
|
+
| `columns` | `Column<D>[]` | 表格列 Schema 配置,支持响应式 `hidden` |
|
|
222
|
+
| `dataSource` | `T[]` | 静态初始数据源数组 |
|
|
223
|
+
| `pageParam` | `PageParam` | 初始分页参数(current, pageSize, total) |
|
|
224
|
+
| `searchParam` | `DeepPartial<D>` | 搜索栏表单初始填充数据 |
|
|
225
|
+
| `searchFields` | `Fields<D>` | 搜索栏字段 Schema 配置,**格式与 ProForm 的 `fields` 完全一致**,同样支持配置驱动渲染和属性透传 |
|
|
226
|
+
|
|
227
|
+
### `useTable` 返回值 (Table 实例)
|
|
228
|
+
|
|
229
|
+
| 属性/方法 | 类型 | 说明 |
|
|
230
|
+
| :----------------- | :-------------------- | :----------------------------------------------------------------------------------------- |
|
|
231
|
+
| `columns` | `Ref<Column<T>[]>` | 响应式表格列配置数组 |
|
|
232
|
+
| `dataSource` | `Ref<T[]>` | 响应式表格数据源 |
|
|
233
|
+
| `pageParam` | `Reactive<PageParam>` | 响应式分页参数:`{ current, pageSize, total }` |
|
|
234
|
+
| `searchForm` | `Form<D>` | 搜索栏 ProForm 实例,可通过 `searchForm.formData` 获取搜索条件,也可调用其所有字段操作方法 |
|
|
235
|
+
| `setColumn` | `(path, col, opts?)` | 动态合并/覆盖列配置(`opts.updateType: 'merge' \| 'rewrite'`) |
|
|
236
|
+
| `deleteColumn` | `(path, opts?)` | 根据 dataIndex 路径或查找函数删除列 |
|
|
237
|
+
| `appendColumn` | `(path, col, opts?)` | 在指定列后追加新列 |
|
|
238
|
+
| `prependColumn` | `(path, col, opts?)` | 在指定列前插入新列 |
|
|
239
|
+
| `setPageParam` | `(pageParam)` | 更新分页参数(支持局部属性或函数式更新) |
|
|
240
|
+
| `resetQueryParams` | `()` | 重置分页状态和搜索表单数据至初始值 |
|
|
225
241
|
|
|
226
242
|
### `ProTable` Props
|
|
227
243
|
|
|
228
|
-
| 属性 | 类型
|
|
229
|
-
| :----------------- |
|
|
230
|
-
| `table` | `Table<D>`
|
|
231
|
-
| `search` | `() => Promise<void>`
|
|
232
|
-
| `addIndexColumn` | `boolean`
|
|
233
|
-
| `immediateSearch` | `boolean`
|
|
234
|
-
| `control` | `boolean \| { sizeControl, columnControl }`
|
|
235
|
-
| `searchFormConfig` | `SearchFormConfig`
|
|
236
|
-
| `tableContainer` | `Component \| false`
|
|
244
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
245
|
+
| :----------------- | :----------------------------------------------------------------------------- | :------ | :------------------------------------------------------------------------------------ |
|
|
246
|
+
| `table` | `Table<D>` | - | 由 `useTable` 返回的表格实例引用 |
|
|
247
|
+
| `search` | `() => Promise<void>` | - | 触发表格数据查询的异步回调函数 |
|
|
248
|
+
| `addIndexColumn` | `boolean` | `false` | 是否自动在表格首列插入序号列 |
|
|
249
|
+
| `immediateSearch` | `boolean` | `false` | 表格挂载完毕(onMounted)是否立即触发一次查询回调 |
|
|
250
|
+
| `control` | `boolean \| { sizeControl, columnControl }` | `true` | 是否展示表格右上角尺寸调节和列显示控制条 |
|
|
251
|
+
| `searchFormConfig` | `SearchFormConfig` | - | 搜索栏表单的排版布局及展开/收起配置参数 |
|
|
252
|
+
| `tableContainer` | `Component \| false` | - | 表格区域外层自定义包裹组件 |
|
|
253
|
+
| 其余属性 | 继承 antdv-next [`TableProps`](https://antdv-next.com/components/table-cn#api) | - | 如 `bordered`、`loading`、`size`、`pagination` 等,直接透传至 antdv-next `Table` 组件 |
|
|
237
254
|
|
|
238
255
|
---
|
|
239
256
|
|
|
240
|
-
## ⚙️
|
|
257
|
+
## ⚙️ ProComponentProvider
|
|
241
258
|
|
|
242
|
-
全局或局部的默认配置提供者,通过在最外层包裹 `
|
|
259
|
+
全局或局部的默认配置提供者,通过在最外层包裹 `ProComponentProvider`,传入 `componentVars` 属性,能够极其优雅地控制其所有子组件的默认配置。
|
|
243
260
|
|
|
244
261
|
```vue
|
|
245
262
|
<template>
|
|
246
|
-
<
|
|
263
|
+
<ProComponentProvider :component-vars="config">
|
|
247
264
|
<ProForm :form="form" />
|
|
248
265
|
<ProTable :table="table" />
|
|
249
|
-
</
|
|
266
|
+
</ProComponentProvider>
|
|
250
267
|
</template>
|
|
251
268
|
|
|
252
269
|
<script setup lang="ts">
|
|
253
|
-
import {
|
|
270
|
+
import { ProComponentProvider } from '@qin-ui/antdv-next-pro';
|
|
254
271
|
|
|
255
272
|
const config = {
|
|
256
273
|
'pro-form': { grid: { gutter: 24 } },
|