icarys-fc-vant 1.0.14 → 1.0.16

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 (101) hide show
  1. package/README.md +87 -278
  2. package/dist/components/common/subform/package.json +48 -0
  3. package/dist/components/common/subform/src/component.jsx +75 -0
  4. package/dist/components/common/subform/src/index.js +3 -0
  5. package/dist/components/common/wangeditor/package-lock.json +114 -0
  6. package/dist/components/common/wangeditor/package.json +52 -0
  7. package/dist/components/common/wangeditor/src/component.jsx +74 -0
  8. package/dist/components/common/wangeditor/src/index.js +3 -0
  9. package/dist/core/babel.config.js +13 -0
  10. package/dist/core/bili.config.js +34 -0
  11. package/dist/core/package-lock.json +13 -0
  12. package/dist/core/package.json +61 -0
  13. package/dist/core/src/components/formCreate.js +287 -0
  14. package/dist/core/src/components/fragment.js +12 -0
  15. package/dist/core/src/factory/context.js +264 -0
  16. package/dist/core/src/factory/creator.js +63 -0
  17. package/dist/core/src/factory/maker.js +17 -0
  18. package/dist/core/src/factory/manager.js +87 -0
  19. package/dist/core/src/factory/node.js +89 -0
  20. package/dist/core/src/factory/parser.js +28 -0
  21. package/dist/core/src/frame/api.js +691 -0
  22. package/dist/core/src/frame/attrs.js +12 -0
  23. package/dist/core/src/frame/dataDriver.js +76 -0
  24. package/dist/core/src/frame/fetch.js +128 -0
  25. package/dist/core/src/frame/index.js +792 -0
  26. package/dist/core/src/frame/language.js +50 -0
  27. package/dist/core/src/frame/provider.js +297 -0
  28. package/dist/core/src/frame/util.js +311 -0
  29. package/dist/core/src/handler/context.js +573 -0
  30. package/dist/core/src/handler/effect.js +122 -0
  31. package/dist/core/src/handler/index.js +143 -0
  32. package/dist/core/src/handler/inject.js +199 -0
  33. package/dist/core/src/handler/input.js +199 -0
  34. package/dist/core/src/handler/lifecycle.js +55 -0
  35. package/dist/core/src/handler/loader.js +375 -0
  36. package/dist/core/src/handler/page.js +46 -0
  37. package/dist/core/src/handler/render.js +29 -0
  38. package/dist/core/src/index.js +12 -0
  39. package/dist/core/src/parser/html.js +17 -0
  40. package/dist/core/src/render/cache.js +47 -0
  41. package/dist/core/src/render/index.js +33 -0
  42. package/dist/core/src/render/render.js +418 -0
  43. package/dist/core/types/index.d.ts +842 -0
  44. package/dist/icarys-fc-vant.umd.js +17 -0
  45. package/dist/index.d.ts +27 -0
  46. package/dist/index.esm.js +39 -0
  47. package/dist/index.js +46 -0
  48. package/dist/utils/lib/console.js +16 -0
  49. package/dist/utils/lib/debounce.js +9 -0
  50. package/dist/utils/lib/deepextend.js +51 -0
  51. package/dist/utils/lib/deepset.js +14 -0
  52. package/dist/utils/lib/extend.js +20 -0
  53. package/dist/utils/lib/index.js +14 -0
  54. package/dist/utils/lib/json.js +90 -0
  55. package/dist/utils/lib/mergeprops.js +62 -0
  56. package/dist/utils/lib/mitt.js +43 -0
  57. package/dist/utils/lib/modify.js +8 -0
  58. package/dist/utils/lib/slot.js +8 -0
  59. package/dist/utils/lib/toarray.js +5 -0
  60. package/dist/utils/lib/tocase.js +11 -0
  61. package/dist/utils/lib/todate.js +10 -0
  62. package/dist/utils/lib/toline.js +10 -0
  63. package/dist/utils/lib/topromise.js +10 -0
  64. package/dist/utils/lib/tostring.js +7 -0
  65. package/dist/utils/lib/type.js +45 -0
  66. package/dist/utils/lib/unique.js +6 -0
  67. package/dist/utils/package.json +32 -0
  68. package/dist/vant/auto-import.d.ts +5 -0
  69. package/dist/vant/auto-import.js +50 -0
  70. package/dist/vant/babel.config.js +10 -0
  71. package/dist/vant/bili.config.js +40 -0
  72. package/dist/vant/examples/main.js +13 -0
  73. package/dist/vant/examples/rule.js +366 -0
  74. package/dist/vant/package.json +83 -0
  75. package/dist/vant/src/components/calendar.jsx +128 -0
  76. package/dist/vant/src/components/cascader.jsx +120 -0
  77. package/dist/vant/src/components/checkbox.jsx +38 -0
  78. package/dist/vant/src/components/datePicker.jsx +87 -0
  79. package/dist/vant/src/components/group.jsx +384 -0
  80. package/dist/vant/src/components/index.js +26 -0
  81. package/dist/vant/src/components/radio.jsx +38 -0
  82. package/dist/vant/src/components/select.jsx +81 -0
  83. package/dist/vant/src/components/timePicker.jsx +76 -0
  84. package/dist/vant/src/components/uploader.jsx +99 -0
  85. package/dist/vant/src/core/alias.js +31 -0
  86. package/dist/vant/src/core/api.js +135 -0
  87. package/dist/vant/src/core/config.js +35 -0
  88. package/dist/vant/src/core/index.js +45 -0
  89. package/dist/vant/src/core/manager.js +282 -0
  90. package/dist/vant/src/core/provider.js +63 -0
  91. package/dist/vant/src/core/utils.js +15 -0
  92. package/dist/vant/src/index.js +13 -0
  93. package/dist/vant/src/parsers/hidden.js +12 -0
  94. package/dist/vant/src/parsers/index.js +59 -0
  95. package/dist/vant/src/parsers/row.js +10 -0
  96. package/dist/vant/src/style/index.css +495 -0
  97. package/dist/vant/types/config.d.ts +99 -0
  98. package/dist/vant/types/index.d.ts +27 -0
  99. package/dist/vant/vue.config.js +21 -0
  100. package/package.json +29 -52
  101. package/dist/index.min.js +0 -7411
@@ -0,0 +1,50 @@
1
+ import {
2
+ Form,
3
+ Cell,
4
+ Button,
5
+ Field,
6
+ Col,
7
+ Row,
8
+ Popup,
9
+ Calendar,
10
+ Cascader,
11
+ CheckboxGroup,
12
+ Checkbox,
13
+ DatePicker,
14
+ Picker,
15
+ RadioGroup,
16
+ Radio,
17
+ Rate,
18
+ Slider,
19
+ Stepper,
20
+ Switch,
21
+ TimePicker,
22
+ Uploader
23
+ } from 'vant';
24
+
25
+ export default function install(formCreate) {
26
+ formCreate.useApp((_, app) => {
27
+ app.component(Form.name) || app.use(Form);
28
+ app.component(Cell.name) || app.use(Cell);
29
+ app.component(Button.name) || app.use(Button);
30
+ app.component(Field.name) || app.use(Field);
31
+ app.component(Col.name) || app.use(Col);
32
+ app.component(Row.name) || app.use(Row);
33
+ app.component(Popup.name) || app.use(Popup);
34
+ app.component(Calendar.name) || app.use(Calendar);
35
+ app.component(Cascader.name) || app.use(Cascader);
36
+ app.component(CheckboxGroup.name) || app.use(CheckboxGroup);
37
+ app.component(Checkbox.name) || app.use(Checkbox);
38
+ app.component(RadioGroup.name) || app.use(RadioGroup);
39
+ app.component(Radio.name) || app.use(Radio);
40
+ app.component(DatePicker.name) || app.use(DatePicker);
41
+ app.component(Picker.name) || app.use(Picker);
42
+ app.component(Rate.name) || app.use(Rate);
43
+ app.component(Slider.name) || app.use(Slider);
44
+ app.component(Stepper.name) || app.use(Stepper);
45
+ app.component(Switch.name) || app.use(Switch);
46
+ app.component(TimePicker.name) || app.use(TimePicker);
47
+ app.component(Uploader.name) || app.use(Uploader);
48
+ });
49
+
50
+ }
@@ -0,0 +1,10 @@
1
+ module.exports = {
2
+ presets: [
3
+ [
4
+ '@vue/cli-plugin-babel/preset',
5
+ {
6
+ useBuiltIns: false
7
+ }
8
+ ]
9
+ ]
10
+ }
@@ -0,0 +1,40 @@
1
+ const {join} = require('path');
2
+ const {author, license, name, version} = require('./package.json');
3
+ const cwd = __dirname;
4
+
5
+ const {UI_LIB} = process.env;
6
+ console.log(`开始打包 -> ${UI_LIB} \n`);
7
+
8
+ module.exports = {
9
+ plugins: {
10
+ commonjs: true,
11
+ postcss: {
12
+ modules: {
13
+ generateScopedName: '[local]'
14
+ }
15
+ }
16
+ },
17
+ banner: {
18
+ author: `2018-${new Date().getFullYear()} ${author}\n * Github https://github.com/xaboy/form-create`,
19
+ license,
20
+ name,
21
+ version
22
+ },
23
+ globals: {
24
+ vue: 'Vue',
25
+ vant: 'vant'
26
+ },
27
+ externals: ['vue', 'Vue', 'vant'],
28
+ output: {
29
+ format: ['umd', 'umd-min'],
30
+ moduleName: 'formCreateMobile',
31
+ fileName: 'form-create[min].js',
32
+ extractCSS: false
33
+ },
34
+ input: join(cwd, '/src/index.js'),
35
+ env: {
36
+ 'NODE_ENV': 'production',
37
+ 'VERSION': version,
38
+ 'UI': UI_LIB,
39
+ }
40
+ };
@@ -0,0 +1,13 @@
1
+ import {createApp} from 'vue'
2
+ import FormCreateMobile from '../src'
3
+ import 'vant/lib/index.css';
4
+ import App from './App.vue'
5
+ import install from '../auto-import';
6
+
7
+ const app = createApp(App)
8
+
9
+ FormCreateMobile.use(install);
10
+
11
+ app.use(FormCreateMobile);
12
+
13
+ app.mount('#app')
@@ -0,0 +1,366 @@
1
+ export default function mock() {
2
+
3
+ return [
4
+ {
5
+ type: 'input',
6
+ title: '商品名称',
7
+ field: 'goods_name2',
8
+ info: {
9
+ align: 'left',
10
+ info:'这个是商品名称',
11
+ },
12
+ value: 'iphone',
13
+ props: {
14
+ placeholder: '请输入商品名称', //输入框占位文本
15
+ disabled: false, //禁用
16
+ },
17
+ validate: [
18
+ {required: true, message: '请输入商品名称', trigger: 'onBlur'}
19
+ ]
20
+ },
21
+ {
22
+ type: 'field',
23
+ title: '商品名称2',
24
+ field: 'goods_name3',
25
+ value: 'iphone',
26
+ $required: true,
27
+ props: {
28
+ placeholder: '请输入商品名称', //输入框占位文本
29
+ type: 'textarea', //禁用
30
+ autosize: true,
31
+ },
32
+ },
33
+ {
34
+ type: 'subform',
35
+ title:'子表单',
36
+ field: 'subform',
37
+ props: {
38
+ rule: [
39
+ {
40
+ type: 'input',
41
+ title: '商品名称',
42
+ field: 'goods_name2',
43
+ info: {
44
+ align: 'left',
45
+ info:'这个是商品名称',
46
+ },
47
+ value: 'iphone',
48
+ props: {
49
+ placeholder: '请输入商品名称', //输入框占位文本
50
+ disabled: false, //禁用
51
+ },
52
+ },
53
+ {
54
+ type: 'calendar',
55
+ title: '日期选择',
56
+ field: 'Calendar1',
57
+ value: '2024-06-11',
58
+ props: {
59
+ placeholder: '请选择',
60
+ },
61
+ on: {
62
+ open(){
63
+ console.log('open');
64
+ },
65
+ confirm(){
66
+ console.log('confirm');
67
+ },
68
+ },
69
+ },
70
+ {
71
+ type: 'calendar',
72
+ title: '日期区间',
73
+ field: 'Calendar2',
74
+ value: ['2024-06-11', '2024-07-11'],
75
+ props: {
76
+ type: 'range',
77
+ placeholder: '请选择',
78
+ },
79
+
80
+ },
81
+ ]
82
+ }
83
+ },
84
+ {
85
+ type: 'group',
86
+ title:'组合',
87
+ field: 'group',
88
+ props: {
89
+ disabled: false,
90
+ expand: 3,
91
+ rule: [
92
+ {
93
+ type: 'input',
94
+ title: '商品名称',
95
+ field: 'goods_name2',
96
+ info: {
97
+ align: 'left',
98
+ info:'这个是商品名称',
99
+ },
100
+ value: 'iphone',
101
+ props: {
102
+ placeholder: '请输入商品名称', //输入框占位文本
103
+ disabled: true, //禁用
104
+ },
105
+ },
106
+ {
107
+ type: 'calendar',
108
+ title: '日期选择',
109
+ field: 'Calendar1',
110
+ value: '2024-06-11',
111
+ props: {
112
+ placeholder: '请选择',
113
+ },
114
+ },
115
+ {
116
+ type: 'calendar',
117
+ title: '日期区间',
118
+ field: 'Calendar2',
119
+ value: ['2024-06-11', '2024-07-11'],
120
+ props: {
121
+ type: 'range',
122
+ placeholder: '请选择',
123
+ },
124
+ },
125
+ ]
126
+ }
127
+ },
128
+ {
129
+ type: 'calendar',
130
+ title: '日期多选',
131
+ field: 'Calendar3',
132
+ value: ['2024-06-11', '2024-07-11', '2024-07-12'],
133
+ props: {
134
+ type: 'multiple',
135
+ placeholder: '请选择',
136
+ clearable: true,
137
+ minDate: '2024-06-10'
138
+ },
139
+ },
140
+ {
141
+ type: 'cascader',
142
+ title: '多级选择',
143
+ field: 'Cascader1',
144
+ value: '330100',
145
+ props: {
146
+ clearable: true,
147
+ options: [
148
+ {
149
+ text: '浙江省',
150
+ value: '330000',
151
+ children: [{text: '杭州市', value: '330100'}],
152
+ },
153
+ {
154
+ text: '江苏省',
155
+ value: '320000',
156
+ children: [{text: '南京市', value: '320100'}],
157
+ },
158
+ ],
159
+ placeholder: '请选择',
160
+ },
161
+ },
162
+ {
163
+ type: 'checkbox',
164
+ title: '多选框',
165
+ field: 'checkbox',
166
+ value: ['1'],
167
+ props: {
168
+ options: [
169
+ {
170
+ label: '复选框1',
171
+ value: '1',
172
+ },
173
+ {
174
+ label: '复选框2',
175
+ value: '2',
176
+ },
177
+ ],
178
+ },
179
+ },
180
+ {
181
+ type: 'radio',
182
+ title: '单选框',
183
+ field: 'radio',
184
+ value: '1',
185
+ props: {
186
+ options: [
187
+ {
188
+ label: '复选框1',
189
+ value: '1',
190
+ },
191
+ {
192
+ label: '复选框2',
193
+ value: '2',
194
+ },
195
+ ],
196
+ },
197
+ },
198
+ {
199
+ type: 'select',
200
+ title: '下拉选择',
201
+ field: 'select',
202
+ value: 'Wednesday',
203
+ props: {
204
+ title: '预约',
205
+ options: [
206
+ { text: '周一', value: 'Monday' },
207
+ { text: '周二', value: 'Tuesday' },
208
+ { text: '周三', value: 'Wednesday' },
209
+ { text: '周四', value: 'Thursday' },
210
+ { text: '周五', value: 'Friday' },
211
+ ],
212
+ placeholder: '请选择',
213
+ },
214
+ },
215
+ {
216
+ type: 'rate',
217
+ title: '评分',
218
+ field: 'rate',
219
+ value: 5,
220
+ props: {
221
+ },
222
+ },
223
+ {
224
+ type: 'slider',
225
+ title: '滑块',
226
+ field: 'slider',
227
+ value: 50,
228
+ props: {
229
+ },
230
+ },
231
+ {
232
+ type: 'slider',
233
+ title: '双滑块',
234
+ field: 'slider2',
235
+ value: [30, 70],
236
+ props: {
237
+ range: true,
238
+ },
239
+ },
240
+ {
241
+ type: 'stepper',
242
+ title: '数字输入',
243
+ field: 'stepper',
244
+ value: 6,
245
+ col: {
246
+ span:16
247
+ },
248
+ props: {
249
+ min:5,
250
+ max:10
251
+ },
252
+ },
253
+ {
254
+ type: 'switch',
255
+ title: '',
256
+ field: 'switch',
257
+ value: 1,
258
+ col: {
259
+ span:8
260
+ },
261
+ props: {
262
+ activeValue:1,
263
+ inactiveValue:0
264
+ },
265
+ },
266
+ {
267
+ type: 'uploader',
268
+ title: '上传',
269
+ field: 'uploader',
270
+ value: [],
271
+ props: {
272
+ action: 'https://run.mocky.io/v3/88bff269-1d6d-4799-8b3b-5736402b3d4a',
273
+ onSuccess(res, file) {
274
+ file.url = res.url;
275
+ }
276
+ },
277
+ },
278
+ {
279
+ type: 'datePicker',
280
+ title: '年月日选择',
281
+ field: 'date',
282
+ value: '2024-06-12',
283
+ props: {
284
+ clearable: true,
285
+ title: '年月日选择',
286
+ // minDate: '2024-06-11'
287
+ },
288
+ },
289
+ {
290
+ type: 'datePicker',
291
+ title: '年月选择',
292
+ field: 'date2',
293
+ value: '2024-06',
294
+ props: {
295
+ title: '年月选择',
296
+ columnsType: ['year', 'month']
297
+ },
298
+ },
299
+ {
300
+ type: 'datePicker',
301
+ title: '年选择',
302
+ field: 'date3',
303
+ value: '2024',
304
+ col: {
305
+ span:12
306
+ },
307
+ props: {
308
+ title: '年选择',
309
+ columnsType: ['year'],
310
+ },
311
+ },
312
+ {
313
+ type: 'datePicker',
314
+ title: '月日选择',
315
+ field: 'date4',
316
+ value: '06-12',
317
+ col: {
318
+ span:12
319
+ },
320
+ props: {
321
+ title: '月日选择',
322
+ columnsType: ['month', 'day'],
323
+ },
324
+ },
325
+ {
326
+ type: 'timePicker',
327
+ title: '时间选择',
328
+ field: 'time1',
329
+ value: '12:47',
330
+ props: {
331
+ clearable: true,
332
+ title: '时间选择',
333
+ },
334
+ },
335
+ {
336
+ type: 'timePicker',
337
+ title: '时分秒选择',
338
+ field: 'time2',
339
+ value: '12:47:58',
340
+ props: {
341
+ title: '时分秒选择',
342
+ columnsType: ['hour', 'minute', 'second']
343
+ },
344
+ },
345
+ {
346
+ type: 'timePicker',
347
+ title: '小时选择',
348
+ field: 'time3',
349
+ value: '12',
350
+ props: {
351
+ title: '小时选择',
352
+ columnsType: ['hour']
353
+ },
354
+ },
355
+ {
356
+ type: 'timePicker',
357
+ title: '分钟选择',
358
+ field: 'time4',
359
+ value: '58',
360
+ props: {
361
+ title: '分钟选择',
362
+ columnsType: ['minute']
363
+ },
364
+ },
365
+ ];
366
+ }
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "icarys-fc-vant",
3
+ "version": "3.2.37",
4
+ "description": "VantUI版本低代码表单|FormCreate 是一个可以通过 JSON 生成具有动态渲染、数据收集、验证和提交功能的低代码表单生成组件。支持6个UI框架,适配移动端,并且支持生成任何 Vue 组件。内置20种常用表单组件和自定义组件,再复杂的表单都可以轻松搞定。",
5
+ "main": "./dist/icarys-fc-vant.min.js",
6
+ "module": "./dist/icarys-fc-vant.esm.js",
7
+ "unpkg": "./dist/icarys-fc-vant.min.js",
8
+ "jsdelivr": "./dist/icarys-fc-vant.min.js",
9
+ "typings": "./dist/index.d.ts",
10
+ "scripts": {
11
+ "clean": "rimraf dist/",
12
+ "dev:vant": "vue-cli-service serve",
13
+ "bili": "cross-env UI_LIB=vant bili",
14
+ "build": "npm-run-all clean bili"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/xaboy/form-create.git"
19
+ },
20
+ "keywords": [
21
+ "动态表单",
22
+ "低代码",
23
+ "@form-create",
24
+ "form-builder",
25
+ "form",
26
+ "components",
27
+ "vue3",
28
+ "mobile",
29
+ "vant",
30
+ "lowcode",
31
+ "dynamic-form"
32
+ ],
33
+ "files": [
34
+ "README.md",
35
+ "package.json",
36
+ "LICENSE",
37
+ "auto-import.js",
38
+ "auto-import.d.ts",
39
+ "src",
40
+ "types",
41
+ "dist"
42
+ ],
43
+ "author": "xaboy",
44
+ "license": "MIT",
45
+ "bugs": {
46
+ "url": "https://github.com/xaboy/form-create/issues"
47
+ },
48
+ "homepage": "http://www.form-create.com/v3/",
49
+ "dependencies": {
50
+ "@form-create/component-subform": "^3.2.34",
51
+ "@form-create/core": "^3.2.37",
52
+ "@form-create/utils": "^3.2.31",
53
+ "dayjs": "^1.11.11"
54
+ },
55
+ "publishConfig": {
56
+ "access": "public"
57
+ },
58
+ "peerDependencies": {
59
+ "vue": "^3.1.0"
60
+ },
61
+ "devDependencies": {
62
+ "@vue/cli-plugin-babel": "~4.5.0",
63
+ "@vue/cli-service": "^4.5.3",
64
+ "v-jsoneditor": "^1.4.2",
65
+ "vant": "^4.9"
66
+ },
67
+ "buildFormCreateOptions": {
68
+ "name": "@form-create/vant",
69
+ "exportName": "formCreateMobile",
70
+ "extendExternals": [
71
+ "vant"
72
+ ],
73
+ "extendGlobal": {
74
+ "vue": "Vue"
75
+ },
76
+ "fileName": "form-create",
77
+ "formats": [
78
+ "umd",
79
+ "esm"
80
+ ]
81
+ },
82
+ "gitHead": "3d024534b3ee103a96da1d3629582c0cdf19d9a8"
83
+ }
@@ -0,0 +1,128 @@
1
+ import {computed, defineComponent, ref, toRef, watch} from 'vue';
2
+ import is, {hasProperty} from '@form-create/utils/lib/type';
3
+ import dayjs from 'dayjs';
4
+
5
+ const NAME = 'fcCalendar';
6
+
7
+ export default defineComponent({
8
+ name: NAME,
9
+ inheritAttrs: false,
10
+ props: {
11
+ placeholder: String,
12
+ formCreateInject: Object,
13
+ disabled: Boolean,
14
+ clearable: Boolean,
15
+ type: String,
16
+ modelValue: [String, Array],
17
+ minDate: [String, Date],
18
+ maxDate: [String, Date],
19
+ },
20
+ emits: ['update:modelValue', 'change', 'fc.el'],
21
+ setup(props, _) {
22
+ const show = ref(false);
23
+ const modelValue = toRef(props, 'modelValue');
24
+ const formCreateInject = toRef(props, 'formCreateInject');
25
+ const inputValue = ref(modelValue.value);
26
+
27
+ watch(() => modelValue.value, (n) => {
28
+ inputValue.value = n;
29
+ })
30
+
31
+ const formatter = (date) => {
32
+ return dayjs(date).format('YYYY-MM-DD');
33
+ }
34
+ const toDate = (str) => {
35
+ return dayjs(str).toDate();
36
+ }
37
+
38
+ const defaultDate = computed(() => {
39
+ const value = modelValue.value;
40
+ if (Array.isArray(value)) {
41
+ return value.map(toDate);
42
+ } else if (value) {
43
+ return toDate(value);
44
+ } else {
45
+ return null;
46
+ }
47
+ })
48
+
49
+ const dateRange = computed(() => {
50
+ return {
51
+ minDate: props.minDate ? dayjs(props.minDate).toDate() : undefined,
52
+ maxDate: props.maxDate ? dayjs(props.maxDate).toDate() : undefined,
53
+ }
54
+ })
55
+
56
+ const formatValue = (value) => {
57
+ if (Array.isArray(value)) {
58
+ inputValue.value = value.map(formatter);
59
+ } else if (value) {
60
+ inputValue.value = formatter(value);
61
+ } else {
62
+ inputValue.value = value;
63
+ }
64
+ }
65
+ const onInput = () => {
66
+ _.emit('update:modelValue', inputValue.value);
67
+ _.emit('change', inputValue.value);
68
+ }
69
+ const strValue = {
70
+ range() {
71
+ return inputValue.value.length ? inputValue.value.join(' - ') : '';
72
+ },
73
+ multiple() {
74
+ return inputValue.value.length ? (formCreateInject.value.t('selectedData', {length: inputValue.value.length}) ||`选择了 ${inputValue.value.length} 个日期`) : '';
75
+ }
76
+ }
77
+
78
+ return {
79
+ show,
80
+ inputValue,
81
+ defaultDate,
82
+ dateRange,
83
+ open() {
84
+ if (props.disabled) {
85
+ return;
86
+ }
87
+ show.value = true;
88
+ },
89
+ confirm(value) {
90
+ formatValue(value);
91
+ show.value = false;
92
+ onInput();
93
+ },
94
+ getStrValue() {
95
+ if (inputValue.value) {
96
+ return hasProperty(strValue, props.type) ? strValue[props.type]() : (inputValue.value || '');
97
+ }
98
+ return '';
99
+ },
100
+ clear(e) {
101
+ e.stopPropagation();
102
+ const value = Array.isArray(inputValue.value) ? [] : '';
103
+ formatValue(value);
104
+ onInput();
105
+ }
106
+ }
107
+ },
108
+ render() {
109
+ const clearIcon = () => {
110
+ return this.$props.clearable && !is.empty(this.inputValue) ?
111
+ <i class="van-badge__wrapper van-icon van-icon-clear van-field__clear"
112
+ onClick={this.clear}></i> : undefined;
113
+ }
114
+ return <div class="_fc-calendar">
115
+ <van-field ref="el" placeholder={this.placeholder} readonly disabled={this.$props.disabled}
116
+ onClick={this.open}
117
+ model-value={this.getStrValue()} isLink border={false} v-slots={{
118
+ 'right-icon': clearIcon
119
+ }}/>
120
+ <van-calendar {...{...this.$attrs, ...this.dateRange}} show={this.show} onUpdate:show={v => (this.show = v)}
121
+ type={this.type}
122
+ onConfirm={this.confirm} defaultDate={this.defaultDate}/>
123
+ </div>
124
+ },
125
+ mounted() {
126
+ this.$emit('fc.el', this.$refs.el);
127
+ }
128
+ });