icarys-fc-vant 1.0.3 → 1.0.4
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/README.md +190 -88
- package/dist/index.js +2214 -0
- package/dist/index.min.js +8 -0
- package/dist/index.min.js.map +1 -0
- package/package.json +6 -4
- package/src/components/common/subform/LICENSE +0 -21
- package/src/components/common/subform/README.md +0 -6
- package/src/components/common/subform/package.json +0 -48
- package/src/components/common/subform/src/component.jsx +0 -75
- package/src/components/common/subform/src/index.js +0 -3
- package/src/components/common/wangeditor/LICENSE +0 -21
- package/src/components/common/wangeditor/README.md +0 -14
- package/src/components/common/wangeditor/package-lock.json +0 -114
- package/src/components/common/wangeditor/package.json +0 -52
- package/src/components/common/wangeditor/src/component.jsx +0 -74
- package/src/components/common/wangeditor/src/index.js +0 -3
- package/src/core/LICENSE +0 -21
- package/src/core/README.md +0 -120
- package/src/core/babel.config.js +0 -13
- package/src/core/bili.config.js +0 -34
- package/src/core/package-lock.json +0 -13
- package/src/core/package.json +0 -61
- package/src/core/src/components/formCreate.js +0 -287
- package/src/core/src/components/fragment.js +0 -12
- package/src/core/src/factory/context.js +0 -264
- package/src/core/src/factory/creator.js +0 -63
- package/src/core/src/factory/maker.js +0 -17
- package/src/core/src/factory/manager.js +0 -87
- package/src/core/src/factory/node.js +0 -89
- package/src/core/src/factory/parser.js +0 -28
- package/src/core/src/frame/api.js +0 -691
- package/src/core/src/frame/attrs.js +0 -12
- package/src/core/src/frame/dataDriver.js +0 -76
- package/src/core/src/frame/fetch.js +0 -128
- package/src/core/src/frame/index.js +0 -792
- package/src/core/src/frame/language.js +0 -50
- package/src/core/src/frame/provider.js +0 -297
- package/src/core/src/frame/util.js +0 -311
- package/src/core/src/handler/context.js +0 -573
- package/src/core/src/handler/effect.js +0 -122
- package/src/core/src/handler/index.js +0 -143
- package/src/core/src/handler/inject.js +0 -199
- package/src/core/src/handler/input.js +0 -199
- package/src/core/src/handler/lifecycle.js +0 -55
- package/src/core/src/handler/loader.js +0 -375
- package/src/core/src/handler/page.js +0 -46
- package/src/core/src/handler/render.js +0 -29
- package/src/core/src/index.js +0 -12
- package/src/core/src/parser/html.js +0 -17
- package/src/core/src/render/cache.js +0 -47
- package/src/core/src/render/index.js +0 -33
- package/src/core/src/render/render.js +0 -418
- package/src/core/types/index.d.ts +0 -842
- package/src/index.js +0 -5
- package/src/utils/LICENSE +0 -21
- package/src/utils/README.md +0 -24
- package/src/utils/lib/console.js +0 -16
- package/src/utils/lib/debounce.js +0 -9
- package/src/utils/lib/deepextend.js +0 -51
- package/src/utils/lib/deepset.js +0 -14
- package/src/utils/lib/extend.js +0 -20
- package/src/utils/lib/index.js +0 -14
- package/src/utils/lib/json.js +0 -90
- package/src/utils/lib/mergeprops.js +0 -62
- package/src/utils/lib/mitt.js +0 -43
- package/src/utils/lib/modify.js +0 -8
- package/src/utils/lib/slot.js +0 -8
- package/src/utils/lib/toarray.js +0 -5
- package/src/utils/lib/tocase.js +0 -11
- package/src/utils/lib/todate.js +0 -10
- package/src/utils/lib/toline.js +0 -10
- package/src/utils/lib/topromise.js +0 -10
- package/src/utils/lib/tostring.js +0 -7
- package/src/utils/lib/type.js +0 -45
- package/src/utils/lib/unique.js +0 -6
- package/src/utils/package.json +0 -32
- package/src/vant/LICENSE +0 -21
- package/src/vant/README.md +0 -137
- package/src/vant/auto-import.d.ts +0 -5
- package/src/vant/auto-import.js +0 -50
- package/src/vant/babel.config.js +0 -10
- package/src/vant/bili.config.js +0 -40
- package/src/vant/examples/App.vue +0 -96
- package/src/vant/examples/main.js +0 -13
- package/src/vant/examples/rule.js +0 -366
- package/src/vant/package-lock.json +0 -11367
- package/src/vant/package.json +0 -83
- package/src/vant/public/index.html +0 -14
- package/src/vant/src/components/calendar.jsx +0 -128
- package/src/vant/src/components/cascader.jsx +0 -120
- package/src/vant/src/components/checkbox.jsx +0 -38
- package/src/vant/src/components/datePicker.jsx +0 -87
- package/src/vant/src/components/group.jsx +0 -384
- package/src/vant/src/components/icon/IconWarning.vue +0 -12
- package/src/vant/src/components/index.js +0 -26
- package/src/vant/src/components/radio.jsx +0 -38
- package/src/vant/src/components/select.jsx +0 -81
- package/src/vant/src/components/timePicker.jsx +0 -76
- package/src/vant/src/components/uploader.jsx +0 -99
- package/src/vant/src/core/alias.js +0 -31
- package/src/vant/src/core/api.js +0 -135
- package/src/vant/src/core/config.js +0 -35
- package/src/vant/src/core/index.js +0 -45
- package/src/vant/src/core/manager.js +0 -282
- package/src/vant/src/core/provider.js +0 -63
- package/src/vant/src/core/utils.js +0 -15
- package/src/vant/src/index.js +0 -13
- package/src/vant/src/parsers/hidden.js +0 -12
- package/src/vant/src/parsers/index.js +0 -59
- package/src/vant/src/parsers/row.js +0 -10
- package/src/vant/src/style/index.css +0 -495
- package/src/vant/types/config.d.ts +0 -99
- package/src/vant/types/index.d.ts +0 -27
- package/src/vant/vue.config.js +0 -21
package/README.md
CHANGED
|
@@ -13,139 +13,241 @@
|
|
|
13
13
|
## 安装
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
#
|
|
17
|
-
npm install
|
|
16
|
+
# 安装组件库(包含预构建文件)
|
|
17
|
+
npm install icarys-fc-vant
|
|
18
18
|
|
|
19
|
-
#
|
|
19
|
+
# 安装必需的依赖
|
|
20
20
|
npm install vue@^3.1.0 vant@^4.0.0
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
##
|
|
23
|
+
## 使用方式
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
### 在Vue模板中使用
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
```vue
|
|
28
|
+
<template>
|
|
29
|
+
<form-create
|
|
30
|
+
:disabled="disabled"
|
|
31
|
+
:rule="rule"
|
|
32
|
+
v-model="_value"
|
|
33
|
+
:option="option"
|
|
34
|
+
ref="formRef"
|
|
35
|
+
v-model:api="fapi"
|
|
36
|
+
/>
|
|
37
|
+
</template>
|
|
28
38
|
|
|
29
|
-
|
|
39
|
+
<script>
|
|
40
|
+
import formCreate from 'icarys-fc-vant'
|
|
30
41
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
export default {
|
|
43
|
+
data() {
|
|
44
|
+
return {
|
|
45
|
+
disabled: false,
|
|
46
|
+
_value: {},
|
|
47
|
+
rule: [
|
|
48
|
+
{ type: 'input', field: 'name', title: '姓名' }
|
|
49
|
+
],
|
|
50
|
+
option: {},
|
|
51
|
+
fapi: null
|
|
37
52
|
}
|
|
53
|
+
},
|
|
54
|
+
created() {
|
|
55
|
+
// 解析配置 - 按照您的方式使用
|
|
56
|
+
this.option = formCreate.parseJson(this.config?.option || '{}')
|
|
57
|
+
this.rule = formCreate.parseJson(this.config?.rule || '[]')
|
|
38
58
|
}
|
|
39
59
|
}
|
|
60
|
+
</script>
|
|
40
61
|
```
|
|
41
62
|
|
|
42
|
-
###
|
|
43
|
-
|
|
44
|
-
确保 `vite.config.js` 中配置了对JSX的支持:
|
|
63
|
+
### 编程式使用
|
|
45
64
|
|
|
46
65
|
```javascript
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
]
|
|
57
|
-
})
|
|
66
|
+
import formCreate from 'icarys-fc-vant'
|
|
67
|
+
|
|
68
|
+
// 解析配置
|
|
69
|
+
const option = formCreate.parseJson(props.config.option)
|
|
70
|
+
const rule = formCreate.parseJson(props.config.rule)
|
|
71
|
+
|
|
72
|
+
// 创建表单实例
|
|
73
|
+
const $f = formCreate(rule, option)
|
|
74
|
+
$f.mount('#form-container')
|
|
58
75
|
```
|
|
59
76
|
|
|
60
|
-
|
|
77
|
+
## 使用
|
|
61
78
|
|
|
62
|
-
在
|
|
79
|
+
### 在Vue组件中使用
|
|
63
80
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
81
|
+
#### 模板中使用组件
|
|
82
|
+
|
|
83
|
+
```vue
|
|
84
|
+
<template>
|
|
85
|
+
<div>
|
|
86
|
+
<!-- 在模板中使用组件 -->
|
|
87
|
+
<FormCreate
|
|
88
|
+
ref="formCreateRef"
|
|
89
|
+
:rule="rule"
|
|
90
|
+
:option="option"
|
|
91
|
+
/>
|
|
92
|
+
<van-button @click="handleSubmit">提交表单</van-button>
|
|
93
|
+
</div>
|
|
94
|
+
</template>
|
|
95
|
+
|
|
96
|
+
<script>
|
|
97
|
+
import Vue from 'vue'
|
|
98
|
+
import Vant from 'vant'
|
|
99
|
+
import 'vant/lib/index.css'
|
|
100
|
+
import formCreate from 'icarys-fc-vant'
|
|
101
|
+
import FormCreate from './components/FormCreate.vue'
|
|
102
|
+
|
|
103
|
+
Vue.use(Vant)
|
|
104
|
+
|
|
105
|
+
export default {
|
|
106
|
+
components: {
|
|
107
|
+
FormCreate
|
|
68
108
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
plugins: ['@vue/babel-plugin-jsx']
|
|
109
|
+
data() {
|
|
110
|
+
return {
|
|
111
|
+
rule: [
|
|
112
|
+
{
|
|
113
|
+
type: 'input',
|
|
114
|
+
field: 'name',
|
|
115
|
+
title: '姓名',
|
|
116
|
+
props: {
|
|
117
|
+
placeholder: '请输入姓名'
|
|
79
118
|
}
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
type: 'select',
|
|
122
|
+
field: 'city',
|
|
123
|
+
title: '城市',
|
|
124
|
+
options: [
|
|
125
|
+
{ label: '北京', value: 'beijing' },
|
|
126
|
+
{ label: '上海', value: 'shanghai' }
|
|
127
|
+
]
|
|
80
128
|
}
|
|
129
|
+
],
|
|
130
|
+
option: {
|
|
131
|
+
// 表单配置选项
|
|
81
132
|
}
|
|
82
|
-
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
methods: {
|
|
136
|
+
handleSubmit() {
|
|
137
|
+
// 使用组件方法
|
|
138
|
+
this.$refs.formCreateRef.submit().then(data => {
|
|
139
|
+
console.log('表单数据:', data)
|
|
140
|
+
}).catch(error => {
|
|
141
|
+
console.error('验证失败:', error)
|
|
142
|
+
})
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
// 使用formCreate的工具方法
|
|
146
|
+
loadFormFromJson(jsonString) {
|
|
147
|
+
try {
|
|
148
|
+
const rules = formCreate.parseJson(jsonString)
|
|
149
|
+
this.rule = rules
|
|
150
|
+
} catch (error) {
|
|
151
|
+
console.error('解析JSON失败:', error)
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
// 序列化表单规则
|
|
156
|
+
saveFormToJson() {
|
|
157
|
+
const jsonString = formCreate.stringifyJson(this.rule)
|
|
158
|
+
console.log('表单JSON:', jsonString)
|
|
159
|
+
return jsonString
|
|
160
|
+
}
|
|
83
161
|
}
|
|
84
162
|
}
|
|
163
|
+
</script>
|
|
85
164
|
```
|
|
86
165
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
### 基础用法
|
|
166
|
+
#### Composition API中使用
|
|
90
167
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
168
|
+
```vue
|
|
169
|
+
<template>
|
|
170
|
+
<div>
|
|
171
|
+
<FormCreate
|
|
172
|
+
ref="formCreateRef"
|
|
173
|
+
:rule="rule"
|
|
174
|
+
:option="option"
|
|
175
|
+
/>
|
|
176
|
+
</div>
|
|
177
|
+
</template>
|
|
94
178
|
|
|
95
|
-
|
|
96
|
-
import
|
|
97
|
-
import
|
|
98
|
-
import '
|
|
99
|
-
|
|
179
|
+
<script setup>
|
|
180
|
+
import { ref, reactive } from 'vue'
|
|
181
|
+
import formCreate from 'icarys-fc-vant'
|
|
182
|
+
import FormCreate from './components/FormCreate.vue'
|
|
183
|
+
|
|
184
|
+
// 使用formCreate的工具方法
|
|
185
|
+
const loadForm = (jsonString) => {
|
|
186
|
+
try {
|
|
187
|
+
return formCreate.parseJson(jsonString)
|
|
188
|
+
} catch (error) {
|
|
189
|
+
console.error('解析失败:', error)
|
|
190
|
+
return []
|
|
191
|
+
}
|
|
192
|
+
}
|
|
100
193
|
|
|
101
|
-
|
|
194
|
+
const saveForm = (rules) => {
|
|
195
|
+
return formCreate.stringifyJson(rules)
|
|
196
|
+
}
|
|
102
197
|
|
|
103
|
-
//
|
|
104
|
-
const rule = [
|
|
198
|
+
// 表单数据
|
|
199
|
+
const rule = ref([
|
|
105
200
|
{
|
|
106
201
|
type: 'input',
|
|
107
202
|
field: 'name',
|
|
108
|
-
title: '姓名'
|
|
109
|
-
props: {
|
|
110
|
-
placeholder: '请输入姓名'
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
type: 'select',
|
|
115
|
-
field: 'city',
|
|
116
|
-
title: '城市',
|
|
117
|
-
options: [
|
|
118
|
-
{ label: '北京', value: 'beijing' },
|
|
119
|
-
{ label: '上海', value: 'shanghai' }
|
|
120
|
-
]
|
|
203
|
+
title: '姓名'
|
|
121
204
|
}
|
|
122
|
-
]
|
|
205
|
+
])
|
|
123
206
|
|
|
124
|
-
|
|
125
|
-
|
|
207
|
+
const option = reactive({
|
|
208
|
+
// 配置选项
|
|
209
|
+
})
|
|
126
210
|
|
|
127
|
-
//
|
|
128
|
-
|
|
211
|
+
// 组件引用
|
|
212
|
+
const formCreateRef = ref(null)
|
|
129
213
|
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
214
|
+
// 提交表单
|
|
215
|
+
const handleSubmit = async () => {
|
|
216
|
+
try {
|
|
217
|
+
const data = await formCreateRef.value.submit()
|
|
218
|
+
console.log('提交成功:', data)
|
|
219
|
+
} catch (error) {
|
|
220
|
+
console.error('提交失败:', error)
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
</script>
|
|
134
224
|
```
|
|
135
225
|
|
|
136
|
-
|
|
226
|
+
### 编程式使用
|
|
137
227
|
|
|
138
228
|
```javascript
|
|
139
|
-
import formCreate from '
|
|
229
|
+
import formCreate from 'icarys-fc-vant'
|
|
140
230
|
|
|
141
|
-
//
|
|
142
|
-
const
|
|
231
|
+
// 1. 创建表单实例
|
|
232
|
+
const $f = formCreate([
|
|
233
|
+
{
|
|
234
|
+
type: 'input',
|
|
235
|
+
field: 'name',
|
|
236
|
+
title: '姓名'
|
|
237
|
+
}
|
|
238
|
+
])
|
|
239
|
+
|
|
240
|
+
// 2. 挂载到DOM
|
|
241
|
+
$f.mount('#form-container')
|
|
143
242
|
|
|
144
|
-
//
|
|
145
|
-
const
|
|
243
|
+
// 3. 使用工具方法
|
|
244
|
+
const jsonRules = formCreate.parseJson('[{"type":"input","field":"name"}]')
|
|
245
|
+
const jsonString = formCreate.toJson(rules)
|
|
146
246
|
|
|
147
|
-
//
|
|
148
|
-
|
|
247
|
+
// 4. 表单操作
|
|
248
|
+
$f.submit().then(data => console.log(data))
|
|
249
|
+
$f.validate().then(() => console.log('验证通过'))
|
|
250
|
+
$f.resetFields()
|
|
149
251
|
```
|
|
150
252
|
|
|
151
253
|
### 在 Vue 组件中使用
|