icarys-fc-vant 1.0.15 → 1.0.17

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 (112) hide show
  1. package/README.md +40 -205
  2. package/dist/index.js +7590 -0
  3. package/dist/index.min.js +3 -7407
  4. package/dist/index.min.js.map +1 -0
  5. package/package.json +6 -19
  6. package/src/components/common/subform/LICENSE +21 -0
  7. package/src/components/common/subform/README.md +6 -0
  8. package/src/components/common/subform/package.json +48 -0
  9. package/src/components/common/subform/src/component.jsx +75 -0
  10. package/src/components/common/subform/src/index.js +3 -0
  11. package/src/components/common/wangeditor/LICENSE +21 -0
  12. package/src/components/common/wangeditor/README.md +14 -0
  13. package/src/components/common/wangeditor/package-lock.json +114 -0
  14. package/src/components/common/wangeditor/package.json +52 -0
  15. package/src/components/common/wangeditor/src/component.jsx +74 -0
  16. package/src/components/common/wangeditor/src/index.js +3 -0
  17. package/src/core/LICENSE +21 -0
  18. package/src/core/README.md +120 -0
  19. package/src/core/babel.config.js +13 -0
  20. package/src/core/bili.config.js +34 -0
  21. package/src/core/package-lock.json +13 -0
  22. package/src/core/package.json +61 -0
  23. package/src/core/src/components/formCreate.js +287 -0
  24. package/src/core/src/components/fragment.js +12 -0
  25. package/src/core/src/factory/context.js +264 -0
  26. package/src/core/src/factory/creator.js +63 -0
  27. package/src/core/src/factory/maker.js +17 -0
  28. package/src/core/src/factory/manager.js +87 -0
  29. package/src/core/src/factory/node.js +89 -0
  30. package/src/core/src/factory/parser.js +28 -0
  31. package/src/core/src/frame/api.js +691 -0
  32. package/src/core/src/frame/attrs.js +12 -0
  33. package/src/core/src/frame/dataDriver.js +76 -0
  34. package/src/core/src/frame/fetch.js +128 -0
  35. package/src/core/src/frame/index.js +792 -0
  36. package/src/core/src/frame/language.js +50 -0
  37. package/src/core/src/frame/provider.js +297 -0
  38. package/src/core/src/frame/util.js +311 -0
  39. package/src/core/src/handler/context.js +573 -0
  40. package/src/core/src/handler/effect.js +122 -0
  41. package/src/core/src/handler/index.js +143 -0
  42. package/src/core/src/handler/inject.js +199 -0
  43. package/src/core/src/handler/input.js +199 -0
  44. package/src/core/src/handler/lifecycle.js +55 -0
  45. package/src/core/src/handler/loader.js +375 -0
  46. package/src/core/src/handler/page.js +46 -0
  47. package/src/core/src/handler/render.js +29 -0
  48. package/src/core/src/index.js +12 -0
  49. package/src/core/src/parser/html.js +17 -0
  50. package/src/core/src/render/cache.js +47 -0
  51. package/src/core/src/render/index.js +33 -0
  52. package/src/core/src/render/render.js +418 -0
  53. package/src/core/types/index.d.ts +842 -0
  54. package/src/index.js +5 -0
  55. package/src/utils/LICENSE +21 -0
  56. package/src/utils/README.md +24 -0
  57. package/src/utils/lib/console.js +16 -0
  58. package/src/utils/lib/debounce.js +9 -0
  59. package/src/utils/lib/deepextend.js +51 -0
  60. package/src/utils/lib/deepset.js +14 -0
  61. package/src/utils/lib/extend.js +20 -0
  62. package/src/utils/lib/index.js +14 -0
  63. package/src/utils/lib/json.js +90 -0
  64. package/src/utils/lib/mergeprops.js +62 -0
  65. package/src/utils/lib/mitt.js +43 -0
  66. package/src/utils/lib/modify.js +8 -0
  67. package/src/utils/lib/slot.js +8 -0
  68. package/src/utils/lib/toarray.js +5 -0
  69. package/src/utils/lib/tocase.js +11 -0
  70. package/src/utils/lib/todate.js +10 -0
  71. package/src/utils/lib/toline.js +10 -0
  72. package/src/utils/lib/topromise.js +10 -0
  73. package/src/utils/lib/tostring.js +7 -0
  74. package/src/utils/lib/type.js +45 -0
  75. package/src/utils/lib/unique.js +6 -0
  76. package/src/utils/package.json +32 -0
  77. package/src/vant/LICENSE +21 -0
  78. package/src/vant/auto-import.d.ts +5 -0
  79. package/src/vant/auto-import.js +50 -0
  80. package/src/vant/babel.config.js +10 -0
  81. package/src/vant/bili.config.js +40 -0
  82. package/src/vant/examples/App.vue +96 -0
  83. package/src/vant/examples/main.js +13 -0
  84. package/src/vant/examples/rule.js +366 -0
  85. package/src/vant/package.json +83 -0
  86. package/src/vant/public/index.html +14 -0
  87. package/src/vant/src/components/calendar.jsx +128 -0
  88. package/src/vant/src/components/cascader.jsx +120 -0
  89. package/src/vant/src/components/checkbox.jsx +38 -0
  90. package/src/vant/src/components/datePicker.jsx +87 -0
  91. package/src/vant/src/components/group.jsx +384 -0
  92. package/src/vant/src/components/icon/IconWarning.vue +12 -0
  93. package/src/vant/src/components/index.js +26 -0
  94. package/src/vant/src/components/radio.jsx +38 -0
  95. package/src/vant/src/components/select.jsx +81 -0
  96. package/src/vant/src/components/timePicker.jsx +76 -0
  97. package/src/vant/src/components/uploader.jsx +99 -0
  98. package/src/vant/src/core/alias.js +31 -0
  99. package/src/vant/src/core/api.js +135 -0
  100. package/src/vant/src/core/config.js +35 -0
  101. package/src/vant/src/core/index.js +45 -0
  102. package/src/vant/src/core/manager.js +282 -0
  103. package/src/vant/src/core/provider.js +63 -0
  104. package/src/vant/src/core/utils.js +15 -0
  105. package/src/vant/src/index.js +13 -0
  106. package/src/vant/src/parsers/hidden.js +12 -0
  107. package/src/vant/src/parsers/index.js +59 -0
  108. package/src/vant/src/parsers/row.js +10 -0
  109. package/src/vant/src/style/index.css +495 -0
  110. package/src/vant/types/config.d.ts +99 -0
  111. package/src/vant/types/index.d.ts +27 -0
  112. package/src/vant/vue.config.js +21 -0
@@ -0,0 +1,384 @@
1
+ import {hasProperty} from '@form-create/utils/lib/type';
2
+ import {defineComponent, markRaw, nextTick, watch} from 'vue';
3
+ import deepExtend, {deepCopy} from '@form-create/utils/lib/deepextend';
4
+ import extend from '@form-create/utils/lib/extend';
5
+ import {toPromise} from '@form-create/utils';
6
+
7
+ const NAME = 'fcGroup';
8
+
9
+
10
+ export default defineComponent({
11
+ name: NAME,
12
+ props: {
13
+ field: String,
14
+ rule: Array,
15
+ expand: Number,
16
+ options: Object,
17
+ button: {
18
+ type: Boolean,
19
+ default: true
20
+ },
21
+ max: {
22
+ type: Number,
23
+ default: 0
24
+ },
25
+ min: {
26
+ type: Number,
27
+ default: 0
28
+ },
29
+ modelValue: {
30
+ type: Array,
31
+ default: () => []
32
+ },
33
+ defaultValue: Object,
34
+ sortBtn: {
35
+ type: Boolean,
36
+ default: false
37
+ },
38
+ disabled: {
39
+ type: Boolean,
40
+ default: undefined
41
+ },
42
+ title: {
43
+ type: [String, Function],
44
+ default: null
45
+ },
46
+ type: {
47
+ type: String,
48
+ default: 'default'
49
+ },
50
+ onBeforeRemove: {
51
+ type: Function,
52
+ default: () => {
53
+ }
54
+ },
55
+ onBeforeAdd: {
56
+ type: Function,
57
+ default: () => {
58
+ }
59
+ },
60
+ formCreateInject: Object,
61
+ parse: Function,
62
+ },
63
+ data() {
64
+ return {
65
+ len: 0,
66
+ cacheRule: {},
67
+ cacheValue: {},
68
+ sort: [],
69
+ form: markRaw(this.formCreateInject.form.$form())
70
+ }
71
+ },
72
+ emits: ['update:modelValue', 'change', 'itemMounted', 'remove', 'add'],
73
+ watch: {
74
+ rule: {
75
+ handler(n, o) {
76
+ Object.keys(this.cacheRule).forEach(v => {
77
+ const item = this.cacheRule[v];
78
+ if (item.$f) {
79
+ const val = item.$f.formData();
80
+ if (n === o) {
81
+ item.$f.deferSyncValue(() => {
82
+ deepExtend(item.rule, n);
83
+ item.$f.setValue(val);
84
+ }, true);
85
+ } else {
86
+ const val = item.$f.formData();
87
+ item.$f.once('reloading', () => {
88
+ item.$f.setValue(val);
89
+ })
90
+ item.rule = deepCopy(n);
91
+ }
92
+ }
93
+ })
94
+ },
95
+ deep: true
96
+ },
97
+ expand(n) {
98
+ let d = n - this.modelValue.length;
99
+ if (d > 0) {
100
+ this.expandRule(d);
101
+ }
102
+ },
103
+ modelValue: {
104
+ handler(n) {
105
+ n = n || [];
106
+ let keys = this.sort, total = keys.length, len = total - n.length;
107
+ if (len < 0) {
108
+ for (let i = len; i < 0; i++) {
109
+ this.addRule(n.length + i, true);
110
+ }
111
+ for (let i = 0; i < total; i++) {
112
+ this.setValue(keys[i], n[i]);
113
+ }
114
+ } else {
115
+ if (len > 0) {
116
+ for (let i = 0; i < len; i++) {
117
+ this.removeRule(keys[total - i - 1]);
118
+ }
119
+ }
120
+ n.forEach((val, i) => {
121
+ this.setValue(keys[i], n[i]);
122
+ });
123
+ }
124
+ },
125
+ deep: true,
126
+ }
127
+ },
128
+ methods: {
129
+ _value(v) {
130
+ return (v && hasProperty(v, this.field)) ? v[this.field] : v;
131
+ },
132
+ cache(k, val) {
133
+ this.cacheValue[k] = JSON.stringify(val);
134
+ },
135
+ input(value) {
136
+ this.$emit('update:modelValue', value);
137
+ this.$emit('change', value);
138
+ },
139
+ formData(key, formData) {
140
+ const cacheRule = this.cacheRule;
141
+ const keys = this.sort;
142
+ if (keys.filter(k => cacheRule[k] && cacheRule[k].$f).length !== keys.length) {
143
+ return;
144
+ }
145
+ const value = keys.map(k => {
146
+ const data = key === k ? formData : {...this.cacheRule[k].$f.form};
147
+ const value = this.field ? data[this.field] || null : data;
148
+ this.cache(k, value);
149
+ return value;
150
+ });
151
+ this.input(value);
152
+ },
153
+ setValue(key, value) {
154
+ const field = this.field
155
+ if (field) {
156
+ value = {[field]: this._value(value)};
157
+ }
158
+ if (this.cacheValue[key] === JSON.stringify(field ? value[field] : value)) {
159
+ return;
160
+ }
161
+ this.cacheRule[key].$f && this.cacheRule[key].$f.coverValue(value);
162
+ this.cache(key, value);
163
+ },
164
+ addRule(i, emit) {
165
+ const rule = this.formCreateInject.form.copyRules(this.rule || []);
166
+ const options = this.options ? {...this.options} : {
167
+ submitBtn: false,
168
+ resetBtn: false,
169
+ };
170
+ if (this.defaultValue) {
171
+ if (!options.formData) options.formData = {};
172
+ const defVal = deepCopy(this.defaultValue);
173
+ extend(options.formData, this.field ? {[this.field]: defVal} : defVal);
174
+ }
175
+ this.parse && this.parse({rule, options, index: this.sort.length});
176
+ this.cacheRule[++this.len] = {rule, options};
177
+ this.sort = Object.keys(this.cacheRule);
178
+ if (emit) {
179
+ nextTick(() => this.$emit('add', rule, Object.keys(this.cacheRule).length - 1));
180
+ }
181
+ },
182
+ add$f(i, key, $f) {
183
+ this.cacheRule[key].$f = $f;
184
+ nextTick(() => {
185
+ this.$emit('itemMounted', $f, Object.keys(this.cacheRule).indexOf(key));
186
+ });
187
+ },
188
+ removeRule(key, emit) {
189
+ const index = Object.keys(this.cacheRule).indexOf(key);
190
+ delete this.cacheRule[key];
191
+ delete this.cacheValue[key];
192
+ this.sort = Object.keys(this.cacheRule);
193
+ if (emit) {
194
+ nextTick(() => this.$emit('remove', index));
195
+ }
196
+ },
197
+ add(i) {
198
+ if (this.disabled || false === this.onBeforeAdd(this.modelValue)) {
199
+ return;
200
+ }
201
+ const value = [...this.modelValue];
202
+ value.push(this.defaultValue ? deepCopy(this.defaultValue) : (this.field ? null : {}));
203
+ this.input(value);
204
+ },
205
+ del(index, key) {
206
+ if (this.disabled) {
207
+ return;
208
+ }
209
+ const del = () => {
210
+ this.removeRule(key, true);
211
+ const value = [...this.modelValue];
212
+ value.splice(index, 1);
213
+ this.input(value);
214
+ }
215
+ toPromise(this.onBeforeRemove(this.modelValue, index)).then(res => {
216
+ if (false !== res) {
217
+ del();
218
+ }
219
+ })
220
+ },
221
+ addIcon(key) {
222
+ return <div class="_fc-m-group-btn _fc-m-group-plus-minus" onClick={this.add}></div>;
223
+ },
224
+ delIcon(index, key) {
225
+ return <div class="_fc-m-group-btn _fc-m-group-plus-minus _fc-m-group-minus"
226
+ onClick={() => this.del(index, key)}></div>
227
+ },
228
+ sortUpIcon(index) {
229
+ return <div class="_fc-m-group-btn _fc-m-group-arrow _fc-m-group-up"
230
+ onClick={() => this.changeSort(index, -1)}></div>
231
+ },
232
+ sortDownIcon(index) {
233
+ return <div class="_fc-m-group-btn _fc-m-group-arrow _fc-m-group-down"
234
+ onClick={() => this.changeSort(index, 1)}></div>
235
+ },
236
+ changeSort(index, sort) {
237
+ const a = this.sort[index];
238
+ this.sort[index] = this.sort[index + sort];
239
+ this.sort[index + sort] = a;
240
+ this.formCreateInject.subForm(this.sort.map(k=>{
241
+ return this.cacheRule[k].$f;
242
+ }));
243
+ this.formData(0);
244
+ },
245
+ sortIcon(index, total) {
246
+ const canMoveUp = index > 0;
247
+ const canMoveDown = index < total - 1;
248
+
249
+ if (!canMoveUp && !canMoveDown) {
250
+ return null;
251
+ }
252
+
253
+ if (canMoveUp && canMoveDown) {
254
+ // 显示合并的上下箭头按钮
255
+ return <div class="_fc-m-group-btn _fc-m-group-sort">
256
+ <div class="_fc-m-group-sort-up" onClick={() => this.changeSort(index, -1)}></div>
257
+ <div class="_fc-m-group-sort-down" onClick={() => this.changeSort(index, 1)}></div>
258
+ </div>;
259
+ }
260
+
261
+ if (canMoveUp) {
262
+ return this.sortUpIcon(index);
263
+ }
264
+
265
+ if (canMoveDown) {
266
+ return this.sortDownIcon(index);
267
+ }
268
+ },
269
+ makeIcon(total, index, key) {
270
+ if (this.$slots.button) {
271
+ return this.$slots.button({
272
+ total,
273
+ index,
274
+ vm: this,
275
+ key,
276
+ del: () => this.del(index, key),
277
+ add: this.add
278
+ });
279
+ }
280
+ const btn = [];
281
+ if ((!this.max || total < this.max) && total === index + 1) {
282
+ btn.push(this.addIcon(key));
283
+ }
284
+ if (total > this.min) {
285
+ btn.push(this.delIcon(index, key));
286
+ }
287
+ if (this.sortBtn) {
288
+ const sortBtn = this.sortIcon(index, total);
289
+ if (sortBtn) {
290
+ btn.push(sortBtn);
291
+ }
292
+ }
293
+ return btn;
294
+ },
295
+ expandRule(n) {
296
+ for (let i = 0; i < n; i++) {
297
+ this.modelValue.push(this.field ? null : {});
298
+ }
299
+ this.input([...this.modelValue]);
300
+ },
301
+ getTitle(index, key) {
302
+ if (typeof this.title === 'function') {
303
+ return this.title(index, this.modelValue[index], key);
304
+ }
305
+ if (typeof this.title === 'string') {
306
+ return this.title.replace('{index}', index + 1);
307
+ }
308
+ return false;
309
+ }
310
+ },
311
+ created() {
312
+ const d = (this.expand || 0) - this.modelValue.length;
313
+ for (let i = 0; i < this.modelValue.length; i++) {
314
+ this.addRule(i);
315
+ }
316
+ if (d > 0) {
317
+ this.expandRule(d);
318
+ }
319
+ },
320
+ render() {
321
+ const keys = this.sort;
322
+ const button = this.button;
323
+ const Type = this.form;
324
+ const disabled = this.disabled;
325
+ const isCardType = this.type === 'card';
326
+
327
+ const children = keys.length === 0 ?
328
+ (this.$slots.default ? (this.$slots.default({
329
+ vm: this,
330
+ add: this.add
331
+ })) : <div key={'a_def'} class="_fc-m-group-plus-minus _fc-m-group-add fc-clock"
332
+ onClick={this.add}/>) : keys.map((key, index) => {
333
+ const {rule, options} = this.cacheRule[key];
334
+ const btn = button && !disabled ? this.makeIcon(keys.length, index, key) : [];
335
+ const title = this.getTitle(index, key);
336
+
337
+ if (isCardType) {
338
+ return <div class="_fc-m-group-container" key={key}>
339
+ <div class="_fc-m-group-header">
340
+ {title === false ? <div class="_fc-m-group-idx">{index + 1}</div> : null}
341
+ {title !== false ? <div class="_fc-m-group-title">{title}</div> : null}
342
+ <div class="_fc-m-group-handle fc-clock">
343
+ {(btn.length) ? btn : null}
344
+ </div>
345
+ </div>
346
+ <div class="_fc-m-group-content">
347
+ <Type
348
+ key={key}
349
+ {...{
350
+ disabled,
351
+ 'onUpdate:modelValue': (formData) => this.formData(key, formData),
352
+ 'onUpdate:api': ($f) => this.add$f(index, key, $f),
353
+ inFor: true,
354
+ modelValue: this.field ? {[this.field]: this._value(this.modelValue[index])} : this.modelValue[index],
355
+ rule,
356
+ option: options,
357
+ extendOption: true
358
+ }}
359
+ />
360
+ </div>
361
+ </div>
362
+ } else {
363
+ return <div class="_fc-m-group-container" key={key}>
364
+ <Type
365
+ key={key}
366
+ {...{
367
+ disabled,
368
+ 'onUpdate:modelValue': (formData) => this.formData(key, formData),
369
+ 'onUpdate:api': ($f) => this.add$f(index, key, $f),
370
+ inFor: true,
371
+ modelValue: this.field ? {[this.field]: this._value(this.modelValue[index])} : this.modelValue[index],
372
+ rule,
373
+ option: options,
374
+ extendOption: true
375
+ }}
376
+ />
377
+ <div class="_fc-m-group-idx">{index + 1}</div>
378
+ {(btn.length) ? <div class="_fc-m-group-handle fc-clock">{btn}</div> : null}
379
+ </div>
380
+ }
381
+ });
382
+ return <div key={'con'} class={'_fc-m-group ' + (disabled ? '_fc-m-group-disabled' : '') + (isCardType ? ' _fc-m-group-card' : '')}>{children}</div>
383
+ }
384
+ });
@@ -0,0 +1,12 @@
1
+ <template>
2
+ <svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
3
+ <path fill="currentColor"
4
+ d="M512 64a448 448 0 110 896 448 448 0 010-896zm0 832a384 384 0 000-768 384 384 0 000 768zm48-176a48 48 0 11-96 0 48 48 0 0196 0zm-48-464a32 32 0 0132 32v288a32 32 0 01-64 0V288a32 32 0 0132-32z"></path>
5
+ </svg>
6
+ </template>
7
+
8
+ <script>
9
+ export default {
10
+ name: 'IconWarning'
11
+ }
12
+ </script>
@@ -0,0 +1,26 @@
1
+ import subForm from '@form-create/components/common/subform/src/index';
2
+ import Calendar from './calendar';
3
+ import Cascader from './cascader';
4
+ import Checkbox from './checkbox';
5
+ import Select from './select';
6
+ import Uploader from './uploader';
7
+ import Radio from './radio';
8
+ import DatePicker from './datePicker';
9
+ import TimePicker from './timePicker';
10
+ import Group from './group';
11
+ import IconWarning from './icon/IconWarning.vue';
12
+
13
+
14
+ export default [
15
+ subForm,
16
+ IconWarning,
17
+ Calendar,
18
+ Cascader,
19
+ Checkbox,
20
+ Radio,
21
+ Select,
22
+ DatePicker,
23
+ TimePicker,
24
+ Group,
25
+ Uploader,
26
+ ]
@@ -0,0 +1,38 @@
1
+ import {defineComponent, toRef} from 'vue';
2
+
3
+ const NAME = 'fcRadio';
4
+
5
+ export default defineComponent({
6
+ name: NAME,
7
+ inheritAttrs: false,
8
+ props: {
9
+ modelValue: [String, Number, Boolean],
10
+ options: Array,
11
+ },
12
+ emits: ['update:modelValue', 'change'],
13
+ setup(props, _) {
14
+ const modelValue = toRef(props, 'modelValue', []);
15
+ const options = toRef(props, 'options');
16
+
17
+ return {
18
+ options,
19
+ modelValue,
20
+ onInput(val) {
21
+ _.emit('update:modelValue', val);
22
+ _.emit('change', val);
23
+ },
24
+ }
25
+ },
26
+ render() {
27
+ return <van-radio-group direction="horizontal" {...this.$attrs} modelValue={this.modelValue}
28
+ onUpdate:modelValue={this.onInput}>
29
+ {(this.options || []).map(opt => {
30
+ const tmp = {...opt};
31
+ const {text, value} = opt;
32
+ delete tmp.text;
33
+ delete tmp.value;
34
+ return <van-radio name={value} {...tmp}>{text || opt.label || value}</van-radio>
35
+ })}
36
+ </van-radio-group>
37
+ }
38
+ });
@@ -0,0 +1,81 @@
1
+ import {computed, defineComponent, ref, toRef} from 'vue';
2
+ import {normalizeOptions} from '../core/utils';
3
+
4
+ const NAME = 'fcSelect';
5
+
6
+ export default defineComponent({
7
+ name: NAME,
8
+ inheritAttrs: false,
9
+ props: {
10
+ disabled: Boolean,
11
+ placeholder: String,
12
+ columnsFieldNames: Object,
13
+ modelValue: [String, Number, Boolean],
14
+ options: Array,
15
+ },
16
+ emits: ['update:modelValue', 'fc.el', 'change'],
17
+ setup(props, _) {
18
+ const show = ref(false);
19
+ const modelValue = toRef(props, 'modelValue');
20
+ const fieldNames = toRef(props, 'columnsFieldNames', {});
21
+ const options = computed(() => {
22
+ if (fieldNames?.value?.text) {
23
+ return props.options || [];
24
+ } else {
25
+ return normalizeOptions(props.options || []);
26
+ }
27
+ })
28
+
29
+ const inputValue = computed(() => {
30
+ if (modelValue.value == null || modelValue.value === '') {
31
+ return '';
32
+ }
33
+ for (let i = 0; i < (options.value || []).length; i++) {
34
+ if (options.value[i][fieldNames.value.value || 'value'] === modelValue.value) {
35
+ return options.value[i][fieldNames.value.text || 'text'];
36
+ }
37
+ }
38
+ return modelValue.value;
39
+ });
40
+
41
+ const onInput = (val) => {
42
+ _.emit('update:modelValue', val);
43
+ _.emit('change', val);
44
+ }
45
+
46
+ return {
47
+ show,
48
+ inputValue,
49
+ options,
50
+ open() {
51
+ if (props.disabled) {
52
+ return;
53
+ }
54
+ show.value = true;
55
+ },
56
+ confirm({selectedValues}) {
57
+ onInput(selectedValues[0]);
58
+ show.value = false;
59
+ },
60
+ }
61
+ },
62
+ render() {
63
+ return <div class="_fc-select">
64
+ <van-field ref="el" placeholder={this.placeholder} readonly disabled={this.$props.disabled} onClick={this.open}
65
+ model-value={this.inputValue} isLink/>
66
+ <van-popup show={this.show} onUpdate:show={(v) => this.show = v} round position="bottom">
67
+ <van-picker
68
+ {...this.$attrs}
69
+ modelValue={[this.modelValue]}
70
+ columnsFieldNames={this.columnsFieldNames}
71
+ columns={this.options}
72
+ onCancel={() => this.show = false}
73
+ onConfirm={this.confirm}
74
+ />
75
+ </van-popup>
76
+ </div>
77
+ },
78
+ mounted() {
79
+ this.$emit('fc.el', this.$refs.el);
80
+ }
81
+ });
@@ -0,0 +1,76 @@
1
+ import {computed, defineComponent, ref, toRef} from 'vue';
2
+
3
+ const NAME = 'fcTimePicker';
4
+
5
+ export default defineComponent({
6
+ name: NAME,
7
+ inheritAttrs: false,
8
+ props: {
9
+ disabled: Boolean,
10
+ clearable: Boolean,
11
+ placeholder: String,
12
+ modelValue: [String, Number],
13
+ },
14
+ emits: ['update:modelValue', 'fc.el', 'change'],
15
+ setup(props, _) {
16
+ const show = ref(false);
17
+ const modelValue = toRef(props, 'modelValue');
18
+
19
+ const formValue = computed(() => {
20
+ if (modelValue.value == null || modelValue.value === '') {
21
+ return [];
22
+ }
23
+ return modelValue.value.split(':');
24
+ });
25
+
26
+ const onInput = (val) => {
27
+ _.emit('update:modelValue', val);
28
+ _.emit('change', val);
29
+ }
30
+
31
+ return {
32
+ show,
33
+ formValue,
34
+ open() {
35
+ if (props.disabled) {
36
+ return;
37
+ }
38
+ show.value = true;
39
+ },
40
+ confirm({selectedValues}) {
41
+ onInput(selectedValues.join(':'));
42
+ show.value = false;
43
+ },
44
+ clear(e) {
45
+ e.stopPropagation();
46
+ onInput('');
47
+ }
48
+ }
49
+ },
50
+ render() {
51
+ const clearIcon = () => {
52
+ return this.$props.clearable && this.modelValue ?
53
+ <i class="van-badge__wrapper van-icon van-icon-clear van-field__clear"
54
+ onClick={this.clear}></i> : undefined;
55
+ }
56
+ return <div class="_fc-time-picker">
57
+ <van-field ref="el" placeholder={this.placeholder} readonly disabled={this.$props.disabled}
58
+ onClick={this.open}
59
+ model-value={this.modelValue} border={false} isLink v-slots={{
60
+ 'right-icon': clearIcon
61
+ }}/>
62
+ <van-popup show={this.show} onUpdate:show={(v) => this.show = v} round position="bottom">
63
+ <van-time-picker
64
+ columnsType={['hour', 'minute']}
65
+ {...this.$attrs}
66
+ modelValue={this.formValue}
67
+ onConfirm={this.confirm}
68
+ onCancel={() => this.show = false}
69
+ />
70
+ </van-popup>
71
+ </div>
72
+ },
73
+ mounted() {
74
+ this.$emit('fc.el', this.$refs.el);
75
+ }
76
+ });