icarys-form-create-vant 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 lvyanrui
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # icarys-form-create-vant
2
+
3
+ 基于 FormCreate 和 Vant 的移动端低代码表单组件库
4
+
5
+ ## 特性
6
+
7
+ - 🚀 基于 Vue 3 + Vant 4
8
+ - 📱 专为移动端优化
9
+ - 🎯 通过 JSON 配置生成表单
10
+ - 🔧 支持动态渲染、数据收集、验证和提交
11
+ - 📦 开箱即用,简单易集成
12
+
13
+ ## 安装
14
+
15
+ ```bash
16
+ npm install icarys-form-create-vant
17
+ ```
18
+
19
+ ## 使用
20
+
21
+ ### 基础用法
22
+
23
+ ```javascript
24
+ import Vue from 'vue'
25
+ import Vant from 'vant'
26
+ import 'vant/lib/index.css'
27
+ import { formCreateMobile } from 'icarys-form-create-vant'
28
+
29
+ Vue.use(Vant)
30
+
31
+ // 创建表单生成器
32
+ const formCreate = formCreateMobile
33
+
34
+ // 使用表单生成器
35
+ const rule = [
36
+ {
37
+ type: 'input',
38
+ field: 'name',
39
+ title: '姓名',
40
+ props: {
41
+ placeholder: '请输入姓名'
42
+ }
43
+ },
44
+ {
45
+ type: 'select',
46
+ field: 'city',
47
+ title: '城市',
48
+ options: [
49
+ { label: '北京', value: 'beijing' },
50
+ { label: '上海', value: 'shanghai' }
51
+ ]
52
+ }
53
+ ]
54
+
55
+ // 创建表单实例
56
+ const $f = formCreate(rule)
57
+
58
+ // 挂载到DOM
59
+ $f.mount('#form-container')
60
+ ```
61
+
62
+ ### 在 Vue 组件中使用
63
+
64
+ ```vue
65
+ <template>
66
+ <div>
67
+ <div id="form-container"></div>
68
+ </div>
69
+ </template>
70
+
71
+ <script>
72
+ import { formCreateMobile } from 'icarys-form-create-vant'
73
+
74
+ export default {
75
+ mounted() {
76
+ const rule = [
77
+ {
78
+ type: 'input',
79
+ field: 'name',
80
+ title: '姓名',
81
+ props: {
82
+ placeholder: '请输入姓名'
83
+ }
84
+ }
85
+ ]
86
+
87
+ const $f = formCreateMobile(rule)
88
+ $f.mount('#form-container')
89
+ }
90
+ }
91
+ </script>
92
+ ```
93
+
94
+ ## API
95
+
96
+ ### formCreateMobile(rule, options)
97
+
98
+ 创建表单实例
99
+
100
+ - `rule`: 表单配置规则数组
101
+ - `options`: 配置选项
102
+
103
+ 返回表单实例对象,包含以下方法:
104
+
105
+ - `mount(selector)`: 挂载到DOM元素
106
+ - `destroy()`: 销毁表单实例
107
+ - `resetFields()`: 重置表单
108
+ - `validate()`: 验证表单
109
+ - `getValue()`: 获取表单值
110
+ - `setValue(data)`: 设置表单值
111
+
112
+ ## 支持的组件类型
113
+
114
+ - input - 输入框
115
+ - textarea - 文本域
116
+ - select - 下拉选择
117
+ - radio - 单选框
118
+ - checkbox - 多选框
119
+ - switch - 开关
120
+ - datePicker - 日期选择器
121
+ - timePicker - 时间选择器
122
+ - calendar - 日历
123
+ - uploader - 文件上传
124
+ - cascader - 级联选择
125
+
126
+ ## 依赖要求
127
+
128
+ - Vue ^3.1.0
129
+ - Vant ^4.0.0
130
+
131
+ ## 开发
132
+
133
+ ```bash
134
+ # 安装依赖
135
+ npm install
136
+
137
+ # 开发模式
138
+ npm run dev
139
+
140
+ # 构建
141
+ npm run build
142
+
143
+ # 发布
144
+ npm run pub
145
+ ```
146
+
147
+ ## 许可证
148
+
149
+ MIT