@qin-ui/vant-pro 1.0.1 → 1.0.3
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 +38 -0
- package/LICENSE +9 -0
- package/README.md +9 -2
- package/api.json +163 -0
- package/es/component-provider/index-DC_k4_R3.js +121 -0
- package/es/component-provider/index.js +2 -120
- package/es/core/{index-D-2iAH6o.js → index-B5vvm4Fj.js} +20 -20
- package/es/form/index.js +77 -90
- package/es/index.d.ts +464 -564
- package/es/index.js +17 -20
- package/package.json +12 -9
package/AI-CONTEXT.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @qin-ui/vant-pro
|
|
2
|
+
|
|
3
|
+
> 基于 Vant v4 的配置驱动表单组件库。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @qin-ui/vant-pro vant vue
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 核心导出
|
|
12
|
+
|
|
13
|
+
### 组件
|
|
14
|
+
|
|
15
|
+
- `ProForm` - 配置驱动表单组件
|
|
16
|
+
- `ProComponentProvider` - 全局配置提供者
|
|
17
|
+
|
|
18
|
+
### Hooks
|
|
19
|
+
|
|
20
|
+
- `useForm<D>()` - 创建表单实例
|
|
21
|
+
- `useFields<D>()` - 字段配置管理
|
|
22
|
+
- `useFormRef()` - 表单组件引用
|
|
23
|
+
|
|
24
|
+
## 字段配置(Field)
|
|
25
|
+
|
|
26
|
+
每个字段支持:`path`, `label`, `component`, `hidden`, `disabled`, `rules`, `valueFormatter`, `fields`, `grid`, `slots`, `componentStyle`, `componentClass`, `componentContainer`, `formItemStyle`, `formItemClass`, `formItemContainer`, `modelProp`
|
|
27
|
+
|
|
28
|
+
内置组件:input, textarea, input-search, input-password, input-number, select, cascader, date-picker, range-picker, time-picker, checkbox-group, radio-group, switch, slider, tree-select, transfer, custom
|
|
29
|
+
|
|
30
|
+
## 类型扩展
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
declare module '@qin-ui/vant-pro' {
|
|
34
|
+
interface ComponentMap {
|
|
35
|
+
'my-custom-component': typeof MyComponent;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
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,8 +1,15 @@
|
|
|
1
1
|
# @qin-ui/vant-pro
|
|
2
2
|
|
|
3
|
-
> 基于 Vant 4 和
|
|
3
|
+
> 基于 **Vant 4** 和 **@qin-ui/core** 二次封装的移动端高级表单组件库,专门针对移动端 H5 精细化打造,助您极速构建交互流畅、配置驱动的移动端表单应用。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="https://img.shields.io/badge/Vant-4.x-blue" alt="Vant 4.x" />
|
|
7
|
+
<img src="https://img.shields.io/badge/Vue-3.5%2B-brightgreen" alt="Vue 3.5+" />
|
|
8
|
+
<img src="https://img.shields.io/badge/TypeScript-5.x-blue" alt="TypeScript" />
|
|
9
|
+
<img src="https://img.shields.io/badge/License-MIT-green" alt="MIT" />
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
## 📝 [使用示例和文档详细内容](https://dufan3715.github.io/pro-components/)
|
|
6
13
|
|
|
7
14
|
---
|
|
8
15
|
|
package/api.json
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generatedAt": "2026-05-26T08:14:28.580Z",
|
|
3
|
+
"name": "@qin-ui/vant-pro",
|
|
4
|
+
"api": [
|
|
5
|
+
{
|
|
6
|
+
"name": "ProComponentProvider",
|
|
7
|
+
"type": "component",
|
|
8
|
+
"package": "@qin-ui/vant-pro",
|
|
9
|
+
"signature": "<ProComponentProvider>",
|
|
10
|
+
"description": "@qin-ui/vant-pro 全局配置提供者组件\n用于在组件树的顶层配置所有子组件的全局默认属性。",
|
|
11
|
+
"examples": [
|
|
12
|
+
"```vue\n<ProComponentProvider\n:componentVars=\"{ 'field': { placeholder: '请输入' } }\"\n>\n<ProForm :form=\"form\" :fields=\"fields\" />\n</ProComponentProvider>\n```"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "ProForm",
|
|
17
|
+
"type": "component",
|
|
18
|
+
"package": "@qin-ui/vant-pro",
|
|
19
|
+
"signature": "<ProForm>",
|
|
20
|
+
"description": "@qin-ui/vant-pro 配置驱动表单组件(移动端)\n通过配置驱动的方式快速构建移动端表单,支持:\n- 字段联动、嵌套字段、自定义组件\n- 弹出层表单(Popup,适用于移动端选择器场景)",
|
|
21
|
+
"typeParams": [
|
|
22
|
+
{
|
|
23
|
+
"name": "F"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "ContainerFragment",
|
|
29
|
+
"type": "component",
|
|
30
|
+
"package": "@qin-ui/vant-pro",
|
|
31
|
+
"signature": "<ContainerFragment>",
|
|
32
|
+
"description": "容器分片渲染组件。用于动态渲染表单行或表单项的外部包裹容器(例如 Grid 行、Col 列等布局容器)。"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "SlotComponent",
|
|
36
|
+
"type": "component",
|
|
37
|
+
"package": "@qin-ui/vant-pro",
|
|
38
|
+
"signature": "<SlotComponent>",
|
|
39
|
+
"description": "插槽渲染辅助组件。用于在表单或表格的自定义插槽中动态渲染外部传入的 VNode、渲染函数或静态字符串。"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "ComponentMap",
|
|
43
|
+
"type": "interface",
|
|
44
|
+
"package": "@qin-ui/vant-pro",
|
|
45
|
+
"signature": "export interface ComponentMap {}",
|
|
46
|
+
"description": "组件映射扩展接口\n通过 TypeScript 声明合并添加自定义组件",
|
|
47
|
+
"examples": [
|
|
48
|
+
"```ts\ndeclare module '@qin-ui/vant-pro' {\ninterface ComponentMap {\n'my-custom': typeof MyComponent;\n}\n}\n```"
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "ComponentName",
|
|
53
|
+
"type": "type",
|
|
54
|
+
"package": "@qin-ui/vant-pro",
|
|
55
|
+
"signature": "export type ComponentName =\n | keyof BaseComponentMap\n | keyof ComponentMap\n | 'custom';",
|
|
56
|
+
"description": "组件名称联合类型\n所有支持的组件名称"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "useFormData",
|
|
60
|
+
"type": "function",
|
|
61
|
+
"package": "@qin-ui/vant-pro",
|
|
62
|
+
"signature": "export const useFormData = <D extends Data = Data>(\n initFormData?: ExtendWithAny<DeepPartial<D>>\n) =>",
|
|
63
|
+
"description": "表单数据处理 Hook\n提供响应式表单数据的管理能力,支持:\n- 响应式数据存储(基于 Vue reactive)\n- 深层路径读写(支持点号分隔,如 'address.city')\n- 类型安全的路径提示(传入泛型 D 后,path 参数可获得类型推导)\n- 父子表单自动注入(非根表单会从注入中获取数据)",
|
|
64
|
+
"returns": "{Function} .setFormData(path, value) - 设置指定路径的数据",
|
|
65
|
+
"typeParams": [
|
|
66
|
+
{
|
|
67
|
+
"name": "D"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"examples": [
|
|
71
|
+
"```ts\ninterface User { name: string; age: number; address: { city: string } }\n\nconst { formData, getFormData, setFormData } = useFormData<User>({\nname: '张三',\naddress: { city: '北京' }\n})\n\n// 读取\ngetFormData('name') // '张三'\ngetFormData('address.city') // '北京'\nformData.name // '张三'(响应式)\n\n// 设置\nsetFormData('name', '李四')\nsetFormData('address.city', '上海')\nsetFormData({ name: '王五', age: 30 }) // 批量覆盖\nsetFormData(prev => ({ ...prev, name: '赵六' })) // 函数式更新\n```"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "useFields",
|
|
76
|
+
"type": "function",
|
|
77
|
+
"package": "@qin-ui/vant-pro",
|
|
78
|
+
"signature": "export const useFields = _useFields as",
|
|
79
|
+
"description": "类型安全的 re-export。将 core useFields 的泛型参数绑定为本地类型:\n- 字段类型 F → Field<ComponentName, D>(支持 Vant 组件类型推导)\n- Field 实例 → Vant 的 FieldInstance",
|
|
80
|
+
"typeParams": [
|
|
81
|
+
{
|
|
82
|
+
"name": "D"
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"examples": [
|
|
86
|
+
"```ts\ninterface User { name: string; age: number }\n\nconst { fields, getField, setField } = useFields<User>([\n{ path: 'name', label: '姓名', component: 'field' },\n{ path: 'age', label: '年龄', component: 'stepper' },\n])\n```"
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "UseFields",
|
|
91
|
+
"type": "type",
|
|
92
|
+
"package": "@qin-ui/vant-pro",
|
|
93
|
+
"signature": "export type UseFields<D extends Data = Data> = ReturnType<typeof useFields<D>>;",
|
|
94
|
+
"description": "useFields 返回值类型,固定为本地 Fields<D>"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"name": "Form",
|
|
98
|
+
"type": "type",
|
|
99
|
+
"package": "@qin-ui/vant-pro",
|
|
100
|
+
"signature": "export type Form<\n D extends Data = Data,\n F extends Field<ComponentName, D> = Field<ComponentName, D>,\n> = _Form<D, F, FormInstance> & { formPopup: FormPopup };",
|
|
101
|
+
"description": "在 core Form 类型的基础上:\n1. 将字段类型 F 绑定为本地 Field<ComponentName, D>\n2. 将底层表单实例绑定为 Vant 的 FormInstance\n3. 额外包含 formPopup 对象,用于管理弹出层表单",
|
|
102
|
+
"typeParams": [
|
|
103
|
+
{
|
|
104
|
+
"name": "D"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"name": "F"
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"name": "useForm",
|
|
113
|
+
"type": "function",
|
|
114
|
+
"package": "@qin-ui/vant-pro",
|
|
115
|
+
"signature": "export function useForm<D extends Data = Data>(\n initFormData?: ExtendWithAny<DeepPartial<D>>,\n initFields?: Field<ComponentName, D>[],\n root?: boolean\n): Form<D, Field<ComponentName, D>>;",
|
|
116
|
+
"description": "创建 @qin-ui/vant-pro 表单实例的 Hook\n基于 core useForm 封装,额外提供了 formPopup 用于移动端弹窗表单。",
|
|
117
|
+
"typeParams": [
|
|
118
|
+
{
|
|
119
|
+
"name": "D"
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
"examples": [
|
|
123
|
+
"```ts\ninterface User { name: string; age: number }\n\nconst form = useForm<User>(\n{ name: '张三' },\n[\n{ path: 'name', label: '姓名', component: 'field' },\n]\n)\n\n// 打开弹出层表单\nform.formPopup.open('address')\nform.formPopup.close()\n```"
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"name": "PopupProps",
|
|
128
|
+
"type": "type",
|
|
129
|
+
"package": "@qin-ui/vant-pro",
|
|
130
|
+
"signature": "export type PopupProps = ComponentProps<typeof Popup> &",
|
|
131
|
+
"description": "Vant Popup 组件属性类型\n用于配置表单弹出层的属性"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"name": "FormPopup",
|
|
135
|
+
"type": "type",
|
|
136
|
+
"package": "@qin-ui/vant-pro",
|
|
137
|
+
"signature": "export type FormPopup =",
|
|
138
|
+
"description": "表单弹出层管理对象\nVant 移动端特有的表单弹出层功能"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"name": "useFormPopup",
|
|
142
|
+
"type": "function",
|
|
143
|
+
"package": "@qin-ui/vant-pro",
|
|
144
|
+
"signature": "export function useFormPopup(root?: boolean): FormPopup;",
|
|
145
|
+
"description": "用于管理 Vant 移动端的表单弹出层(Popup)。\n在移动端表单中,某些字段(如地址选择、日期选择)需要以弹出层形式展示。",
|
|
146
|
+
"returns": "{FormPopup} 弹出层管理对象",
|
|
147
|
+
"examples": [
|
|
148
|
+
"```ts\nconst formPopup = useFormPopup(true)\nformPopup.open('address') // 打开地址选择弹出层\nformPopup.close() // 关闭\nformPopup.updateProps({ position: 'top' })\n```"
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"name": "useFormRef",
|
|
153
|
+
"type": "function",
|
|
154
|
+
"package": "@qin-ui/vant-pro",
|
|
155
|
+
"signature": "export const useFormRef = _useFormRef as",
|
|
156
|
+
"description": "类型安全的 re-export。将 core useFormRef 的泛型参数绑定为 Vant 的 FormInstance。",
|
|
157
|
+
"returns": "{Function} .setFormRef(inst) - 设置表单组件实例",
|
|
158
|
+
"examples": [
|
|
159
|
+
"```ts\nconst { formRef, setFormRef } = useFormRef()\nformRef.value?.submit()\n```"
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { defineComponent, provide, renderSlot } from "vue";
|
|
2
|
+
import { g as getObject } from "../core/index-B5vvm4Fj.js";
|
|
3
|
+
const INJECT_CONFIG = {
|
|
4
|
+
"pro-form": {
|
|
5
|
+
injectionKey: Symbol(""),
|
|
6
|
+
default: {
|
|
7
|
+
inputAlign: "right",
|
|
8
|
+
errorMessageAlign: "right",
|
|
9
|
+
required: "auto",
|
|
10
|
+
scrollToError: true,
|
|
11
|
+
scrollToErrorPosition: "nearest"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
field: {
|
|
15
|
+
injectionKey: Symbol(""),
|
|
16
|
+
default: { clearable: true, placeholder: "请输入" }
|
|
17
|
+
},
|
|
18
|
+
switch: {
|
|
19
|
+
injectionKey: Symbol(""),
|
|
20
|
+
default: {}
|
|
21
|
+
},
|
|
22
|
+
stepper: {
|
|
23
|
+
injectionKey: Symbol(""),
|
|
24
|
+
default: {}
|
|
25
|
+
},
|
|
26
|
+
rate: {
|
|
27
|
+
injectionKey: Symbol(""),
|
|
28
|
+
default: {}
|
|
29
|
+
},
|
|
30
|
+
slider: {
|
|
31
|
+
injectionKey: Symbol(""),
|
|
32
|
+
default: {}
|
|
33
|
+
},
|
|
34
|
+
uploader: {
|
|
35
|
+
injectionKey: Symbol(""),
|
|
36
|
+
default: {}
|
|
37
|
+
},
|
|
38
|
+
"checkbox-group": {
|
|
39
|
+
injectionKey: Symbol(""),
|
|
40
|
+
default: {}
|
|
41
|
+
},
|
|
42
|
+
"radio-group": {
|
|
43
|
+
injectionKey: Symbol(""),
|
|
44
|
+
default: {}
|
|
45
|
+
},
|
|
46
|
+
picker: {
|
|
47
|
+
injectionKey: Symbol(""),
|
|
48
|
+
default: {}
|
|
49
|
+
},
|
|
50
|
+
"date-picker": {
|
|
51
|
+
injectionKey: Symbol(""),
|
|
52
|
+
default: {}
|
|
53
|
+
},
|
|
54
|
+
"time-picker": {
|
|
55
|
+
injectionKey: Symbol(""),
|
|
56
|
+
default: {}
|
|
57
|
+
},
|
|
58
|
+
cascader: {
|
|
59
|
+
injectionKey: Symbol(""),
|
|
60
|
+
default: {}
|
|
61
|
+
},
|
|
62
|
+
area: {
|
|
63
|
+
injectionKey: Symbol(""),
|
|
64
|
+
default: {}
|
|
65
|
+
},
|
|
66
|
+
signature: {
|
|
67
|
+
injectionKey: Symbol(""),
|
|
68
|
+
default: {}
|
|
69
|
+
},
|
|
70
|
+
button: {
|
|
71
|
+
injectionKey: Symbol(""),
|
|
72
|
+
default: {}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const INJECT_COMPONENTS = Symbol("INJECT_COMPONENTS");
|
|
76
|
+
const DYNAMIC_INJECT_CONFIG = /* @__PURE__ */ Object.create(null);
|
|
77
|
+
const getInjectConfig = (key) => {
|
|
78
|
+
return INJECT_CONFIG[key] || DYNAMIC_INJECT_CONFIG[key];
|
|
79
|
+
};
|
|
80
|
+
const ensureInjectConfig = (key) => {
|
|
81
|
+
const existing = getInjectConfig(key);
|
|
82
|
+
if (existing) return existing;
|
|
83
|
+
const created = {
|
|
84
|
+
injectionKey: Symbol(`dynamic:${key}`),
|
|
85
|
+
default: {}
|
|
86
|
+
};
|
|
87
|
+
DYNAMIC_INJECT_CONFIG[key] = created;
|
|
88
|
+
return created;
|
|
89
|
+
};
|
|
90
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
91
|
+
...{
|
|
92
|
+
name: "ProComponentProvider",
|
|
93
|
+
inheritAttrs: false
|
|
94
|
+
},
|
|
95
|
+
__name: "index",
|
|
96
|
+
props: {
|
|
97
|
+
componentVars: {},
|
|
98
|
+
componentMap: {}
|
|
99
|
+
},
|
|
100
|
+
setup(__props) {
|
|
101
|
+
const props = __props;
|
|
102
|
+
if (props.componentMap) {
|
|
103
|
+
provide(INJECT_COMPONENTS, props.componentMap);
|
|
104
|
+
}
|
|
105
|
+
if (props.componentVars) {
|
|
106
|
+
Object.entries(props.componentVars).forEach(([key, val]) => {
|
|
107
|
+
const config = ensureInjectConfig(key);
|
|
108
|
+
provide(config.injectionKey, { ...config.default, ...getObject(val) });
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return (_ctx, _cache) => {
|
|
112
|
+
return renderSlot(_ctx.$slots, "default");
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
export {
|
|
117
|
+
INJECT_COMPONENTS as I,
|
|
118
|
+
_sfc_main as _,
|
|
119
|
+
INJECT_CONFIG as a,
|
|
120
|
+
getInjectConfig as g
|
|
121
|
+
};
|
|
@@ -1,122 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { g as getObject } from "../core/index-D-2iAH6o.js";
|
|
3
|
-
const INJECT_CONFIG = {
|
|
4
|
-
"pro-form": {
|
|
5
|
-
injectionKey: Symbol(""),
|
|
6
|
-
default: {
|
|
7
|
-
inputAlign: "right",
|
|
8
|
-
errorMessageAlign: "right",
|
|
9
|
-
required: "auto",
|
|
10
|
-
scrollToError: true,
|
|
11
|
-
scrollToErrorPosition: "nearest"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
field: {
|
|
15
|
-
injectionKey: Symbol(""),
|
|
16
|
-
default: { clearable: true, placeholder: "请输入" }
|
|
17
|
-
},
|
|
18
|
-
switch: {
|
|
19
|
-
injectionKey: Symbol(""),
|
|
20
|
-
default: {}
|
|
21
|
-
},
|
|
22
|
-
stepper: {
|
|
23
|
-
injectionKey: Symbol(""),
|
|
24
|
-
default: {}
|
|
25
|
-
},
|
|
26
|
-
rate: {
|
|
27
|
-
injectionKey: Symbol(""),
|
|
28
|
-
default: {}
|
|
29
|
-
},
|
|
30
|
-
slider: {
|
|
31
|
-
injectionKey: Symbol(""),
|
|
32
|
-
default: {}
|
|
33
|
-
},
|
|
34
|
-
uploader: {
|
|
35
|
-
injectionKey: Symbol(""),
|
|
36
|
-
default: {}
|
|
37
|
-
},
|
|
38
|
-
"checkbox-group": {
|
|
39
|
-
injectionKey: Symbol(""),
|
|
40
|
-
default: {}
|
|
41
|
-
},
|
|
42
|
-
"radio-group": {
|
|
43
|
-
injectionKey: Symbol(""),
|
|
44
|
-
default: {}
|
|
45
|
-
},
|
|
46
|
-
picker: {
|
|
47
|
-
injectionKey: Symbol(""),
|
|
48
|
-
default: {}
|
|
49
|
-
},
|
|
50
|
-
"date-picker": {
|
|
51
|
-
injectionKey: Symbol(""),
|
|
52
|
-
default: {}
|
|
53
|
-
},
|
|
54
|
-
"time-picker": {
|
|
55
|
-
injectionKey: Symbol(""),
|
|
56
|
-
default: {}
|
|
57
|
-
},
|
|
58
|
-
cascader: {
|
|
59
|
-
injectionKey: Symbol(""),
|
|
60
|
-
default: {}
|
|
61
|
-
},
|
|
62
|
-
area: {
|
|
63
|
-
injectionKey: Symbol(""),
|
|
64
|
-
default: {}
|
|
65
|
-
},
|
|
66
|
-
signature: {
|
|
67
|
-
injectionKey: Symbol(""),
|
|
68
|
-
default: {}
|
|
69
|
-
},
|
|
70
|
-
button: {
|
|
71
|
-
injectionKey: Symbol(""),
|
|
72
|
-
default: {}
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
const INJECT_COMPONENTS = Symbol("INJECT_COMPONENTS");
|
|
76
|
-
const DYNAMIC_INJECT_CONFIG = /* @__PURE__ */ Object.create(null);
|
|
77
|
-
const getInjectConfig = (key) => {
|
|
78
|
-
return INJECT_CONFIG[key] || DYNAMIC_INJECT_CONFIG[key];
|
|
79
|
-
};
|
|
80
|
-
const ensureInjectConfig = (key) => {
|
|
81
|
-
const existing = getInjectConfig(key);
|
|
82
|
-
if (existing) return existing;
|
|
83
|
-
const created = {
|
|
84
|
-
injectionKey: Symbol(`dynamic:${key}`),
|
|
85
|
-
default: {}
|
|
86
|
-
};
|
|
87
|
-
DYNAMIC_INJECT_CONFIG[key] = created;
|
|
88
|
-
return created;
|
|
89
|
-
};
|
|
90
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
91
|
-
...{
|
|
92
|
-
name: "ProComponentProvider",
|
|
93
|
-
inheritAttrs: false
|
|
94
|
-
},
|
|
95
|
-
__name: "index",
|
|
96
|
-
props: {
|
|
97
|
-
componentVars: {},
|
|
98
|
-
componentMap: {}
|
|
99
|
-
},
|
|
100
|
-
setup(__props) {
|
|
101
|
-
const props = __props;
|
|
102
|
-
if (props.componentMap) {
|
|
103
|
-
provide(INJECT_COMPONENTS, props.componentMap);
|
|
104
|
-
}
|
|
105
|
-
if (props.componentVars) {
|
|
106
|
-
Object.entries(props.componentVars).forEach(([key, val]) => {
|
|
107
|
-
const config = ensureInjectConfig(key);
|
|
108
|
-
provide(config.injectionKey, { ...config.default, ...getObject(val) });
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
return (_ctx, _cache) => {
|
|
112
|
-
return renderSlot(_ctx.$slots, "default");
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
});
|
|
1
|
+
import { _ } from "./index-DC_k4_R3.js";
|
|
116
2
|
export {
|
|
117
|
-
|
|
118
|
-
INJECT_CONFIG,
|
|
119
|
-
_sfc_main as default,
|
|
120
|
-
ensureInjectConfig,
|
|
121
|
-
getInjectConfig
|
|
3
|
+
_ as default
|
|
122
4
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ref, inject, reactive, provide, camelize } from "vue";
|
|
2
2
|
import { i as isPlainObject, s as set, g as get, t as toPath } from "../vendor/utils/lodash-es-DN4QDiDm.js";
|
|
3
3
|
const InjectionFormKey = Symbol("form");
|
|
4
4
|
const InjectionPathKey = Symbol("path");
|
|
@@ -109,23 +109,6 @@ const useFields = (initFields) => {
|
|
|
109
109
|
options
|
|
110
110
|
);
|
|
111
111
|
}
|
|
112
|
-
function addFields(path, newFields, options, placement) {
|
|
113
|
-
if (newFields.length === 0) return;
|
|
114
|
-
if (path) {
|
|
115
|
-
updaterMatch(
|
|
116
|
-
path,
|
|
117
|
-
({ fieldIndex, parentField }) => {
|
|
118
|
-
const index = placement === "after" ? fieldIndex + 1 : fieldIndex;
|
|
119
|
-
parentField.fields.splice(index, 0, ...newFields);
|
|
120
|
-
},
|
|
121
|
-
options
|
|
122
|
-
);
|
|
123
|
-
} else if (placement === "after") {
|
|
124
|
-
fields.value.push(...newFields);
|
|
125
|
-
} else {
|
|
126
|
-
fields.value.unshift(...newFields);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
112
|
function appendField(path, field, options) {
|
|
130
113
|
const newFields = Array.isArray(field) ? field : [field];
|
|
131
114
|
addFields(path, newFields, options, "after");
|
|
@@ -146,6 +129,23 @@ const useFields = (initFields) => {
|
|
|
146
129
|
);
|
|
147
130
|
return (options == null ? void 0 : options.all) ? res : res[0];
|
|
148
131
|
}
|
|
132
|
+
function addFields(path, newFields, options, placement) {
|
|
133
|
+
if (newFields.length === 0) return;
|
|
134
|
+
if (path) {
|
|
135
|
+
updaterMatch(
|
|
136
|
+
path,
|
|
137
|
+
({ fieldIndex, parentField }) => {
|
|
138
|
+
const index = placement === "after" ? fieldIndex + 1 : fieldIndex;
|
|
139
|
+
parentField.fields.splice(index, 0, ...newFields);
|
|
140
|
+
},
|
|
141
|
+
options
|
|
142
|
+
);
|
|
143
|
+
} else if (placement === "after") {
|
|
144
|
+
fields.value.push(...newFields);
|
|
145
|
+
} else {
|
|
146
|
+
fields.value.unshift(...newFields);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
149
|
return {
|
|
150
150
|
fields,
|
|
151
151
|
getField,
|
|
@@ -225,8 +225,8 @@ function useForm(...args) {
|
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
227
|
export {
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
InjectionPathKey as I,
|
|
229
|
+
InjectionFormKey as a,
|
|
230
230
|
useFields as b,
|
|
231
231
|
camelizeProperties as c,
|
|
232
232
|
useFormRef as d,
|