@94ai/nf-double-week 3.1.37 → 3.1.38

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.
@@ -0,0 +1,780 @@
1
+ <template>
2
+ <div
3
+ ref="reference"
4
+ v-clickoutside="handleClose"
5
+ class="el-date-editor nf-double-week el-range-editor el-input__inner nf-double-week-picker"
6
+ :class="[
7
+ 'el-date-editor--daterange',
8
+ pickerSize ? `el-range-editor--${ pickerSize }` : '',
9
+ pickerDisabled ? 'is-disabled' : '',
10
+ pickerVisible ? 'is-active' : ''
11
+ ]"
12
+ @click="handleRangeClick"
13
+ @mouseenter="handleMouseEnter"
14
+ @mouseleave="showClose = false"
15
+ @keydown="handleKeydown"
16
+ >
17
+ <i :class="['el-input__icon', 'el-range__icon', triggerClass]" />
18
+ <input
19
+ :readonly="!editable || readonly"
20
+ autocomplete="off"
21
+ :placeholder="startPlaceholder"
22
+ :value="displayValue && displayValue[0]"
23
+ :disabled="pickerDisabled"
24
+ v-bind="firstInputId"
25
+ :name="name && name[0]"
26
+ :size="pickerSize"
27
+ class="el-range-input"
28
+ >
29
+ <slot name="range-separator">
30
+ <span class="el-range-separator">{{ rangeSeparator }}</span>
31
+ </slot>
32
+ <input
33
+ autocomplete="off"
34
+ :placeholder="endPlaceholder"
35
+ :value="displayValue && displayValue[1]"
36
+ :disabled="pickerDisabled"
37
+ v-bind="secondInputId"
38
+ :size="pickerSize"
39
+ :name="name && name[1]"
40
+ :readonly="!editable || readonly"
41
+ class="el-range-input"
42
+ >
43
+ <i
44
+ v-if="haveTrigger"
45
+ :class="[showClose ? '' + clearIcon : '']"
46
+ class="el-input__icon el-range__close-icon"
47
+ @click="handleClickIcon"
48
+ />
49
+ </div>
50
+ </template>
51
+
52
+ <script>
53
+ import Vue from 'vue'
54
+ import Clickoutside from 'element-ui/src/utils/clickoutside'
55
+ import { formatDate, isDateObject, getWeekNumber, parseDate } from 'element-ui/src/utils/date-util'
56
+ import Popper from 'element-ui/src/utils/vue-popper'
57
+ import Emitter from 'element-ui/src/mixins/emitter'
58
+ import merge from 'element-ui/src/utils/merge'
59
+
60
+ const NewPopper = {
61
+ props: {
62
+ appendToBody: Popper.props.appendToBody,
63
+ offset: Popper.props.offset,
64
+ boundariesPadding: Popper.props.boundariesPadding,
65
+ arrowOffset: Popper.props.arrowOffset
66
+ },
67
+ methods: Popper.methods,
68
+ data() {
69
+ return merge({ visibleArrow: true, type: 'weekrange' }, Popper.data)
70
+ },
71
+ beforeDestroy: Popper.beforeDestroy
72
+ }
73
+
74
+ const DEFAULT_FORMATS = {
75
+ weekrange: 'WW周(yyyy年)'
76
+ }
77
+
78
+ const DATE_PARSER = function(text, format) {
79
+ if (format === 'timestamp') return new Date(Number(text))
80
+ return parseDate(text, format)
81
+ }
82
+
83
+ const RANGE_PARSER = function(array, format) {
84
+ if (array.length === 2) {
85
+ const range1 = array[0]
86
+ const range2 = array[1]
87
+
88
+ return [DATE_PARSER(range1, format), DATE_PARSER(range2, format)]
89
+ }
90
+ return []
91
+ }
92
+
93
+ const TYPE_VALUE_RESOLVER_MAP = {
94
+ default: {
95
+ formatter(value) {
96
+ if (!value) return ''
97
+ return '' + value
98
+ },
99
+ parser(text) {
100
+ if (text === undefined || text === '') return null
101
+ return text
102
+ }
103
+ },
104
+ weekrange: {
105
+ formatter(value, format) {
106
+ function getDate(value) {
107
+ // 是否闰年
108
+ function isLeapYear(year) {
109
+ return (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
110
+ }
111
+
112
+ // 判断天数
113
+ function getDays(date) {
114
+ const year = date.getFullYear()
115
+ const month = date.getMonth() + 1
116
+ const day = date.getDate()
117
+
118
+ let days = day
119
+
120
+ // 天数没有规律,故放在一个数组中
121
+ const monthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
122
+ for (let i = 0; i < month - 1; i++) { // 传进来的月份,对应的下标是-1的
123
+ days += monthDays[i]
124
+ }
125
+
126
+ // 如果是闰年,天数加一
127
+ if (isLeapYear(year) && month > 2) {
128
+ days++
129
+ }
130
+ return days++
131
+ }
132
+
133
+ if (!value) {
134
+ return
135
+ }
136
+
137
+ const y = value.getFullYear()
138
+ const yearOneDateSun = new Date(y + '-01-01').getDay() || 7
139
+ const days = getDays(value)
140
+
141
+ const week = getWeekNumber(value)
142
+ const month = value.getMonth()
143
+ const trueDate = new Date(value)
144
+ if (week === 1 && month === 11) {
145
+ trueDate.setHours(0, 0, 0, 0)
146
+ trueDate.setDate(trueDate.getDate() + 3 - (trueDate.getDay() + 6) % 7)
147
+ }
148
+ let date = formatDate(trueDate, format)
149
+
150
+ if (7 - yearOneDateSun < 4 && 7 - yearOneDateSun >= days) {
151
+ date = date.replace(new RegExp(y, 'ig'), y - 1)
152
+ }
153
+
154
+ date = /WW/.test(date)
155
+ ? date.replace(/WW/, week < 10 ? '0' + week : week)
156
+ : date.replace(/W/, week)
157
+ return date
158
+ }
159
+
160
+ if (!Array.isArray(value)) {
161
+ return getDate(value)
162
+ }
163
+
164
+ const dateList = []
165
+ for (const val of value) {
166
+ dateList.push(getDate(val))
167
+ }
168
+
169
+ return dateList
170
+ },
171
+ parser: RANGE_PARSER
172
+ }
173
+ }
174
+ const PLACEMENT_MAP = {
175
+ left: 'bottom-start',
176
+ center: 'bottom',
177
+ right: 'bottom-end'
178
+ }
179
+
180
+ const parseAsFormatAndType = (value, customFormat, type) => {
181
+ if (!value) return null
182
+ const parser = (
183
+ TYPE_VALUE_RESOLVER_MAP[type] ||
184
+ TYPE_VALUE_RESOLVER_MAP['default']
185
+ ).parser
186
+ const format = customFormat || DEFAULT_FORMATS[type]
187
+ return parser(value, format)
188
+ }
189
+
190
+ const formatAsFormatAndType = (value, customFormat, type = 'weekrange') => {
191
+ if (!value) return null
192
+ const formatter = (
193
+ TYPE_VALUE_RESOLVER_MAP[type] ||
194
+ TYPE_VALUE_RESOLVER_MAP['default']
195
+ ).formatter
196
+ const format = customFormat || DEFAULT_FORMATS[type]
197
+ return formatter(value, format)
198
+ }
199
+
200
+ /*
201
+ * Considers:
202
+ * 1. Date object
203
+ * 2. date string
204
+ * 3. array of 1 or 2
205
+ */
206
+ const valueEquals = function(a, b) {
207
+ // considers Date object and string
208
+ const dateEquals = function(a, b) {
209
+ const aIsDate = a instanceof Date
210
+ const bIsDate = b instanceof Date
211
+ if (aIsDate && bIsDate) {
212
+ return a.getTime() === b.getTime()
213
+ }
214
+ if (!aIsDate && !bIsDate) {
215
+ return a === b
216
+ }
217
+ return false
218
+ }
219
+
220
+ const aIsArray = a instanceof Array
221
+ const bIsArray = b instanceof Array
222
+ if (aIsArray && bIsArray) {
223
+ if (a.length !== b.length) {
224
+ return false
225
+ }
226
+ return a.every((item, index) => dateEquals(item, b[index]))
227
+ }
228
+ if (!aIsArray && !bIsArray) {
229
+ return dateEquals(a, b)
230
+ }
231
+ return false
232
+ }
233
+
234
+ const isString = function(val) {
235
+ return typeof val === 'string' || val instanceof String
236
+ }
237
+
238
+ const validator = function(val) {
239
+ // either: String, Array of String, null / undefined
240
+ return (
241
+ val === null ||
242
+ val === undefined ||
243
+ isString(val) ||
244
+ (Array.isArray(val) && val.length === 2 && val.every(isString))
245
+ )
246
+ }
247
+
248
+ export default {
249
+
250
+ directives: { Clickoutside },
251
+ mixins: [Emitter, NewPopper],
252
+
253
+ inject: {
254
+ elForm: {
255
+ default: ''
256
+ },
257
+ elFormItem: {
258
+ default: ''
259
+ }
260
+ },
261
+
262
+ props: {
263
+ size: {
264
+ type: String,
265
+ default: 'small'
266
+ },
267
+ format: String,
268
+ valueFormat: String,
269
+ readonly: Boolean,
270
+ startPlaceholder: {
271
+ type: String,
272
+ default: '开始周'
273
+ },
274
+ endPlaceholder: {
275
+ type: String,
276
+ default: '结束周'
277
+ },
278
+ prefixIcon: String,
279
+ clearIcon: {
280
+ type: String,
281
+ default: 'el-icon-circle-close'
282
+ },
283
+ name: {
284
+ default: '',
285
+ validator
286
+ },
287
+ disabled: Boolean,
288
+ clearable: {
289
+ type: Boolean,
290
+ default: true
291
+ },
292
+ id: {
293
+ default: '',
294
+ validator
295
+ },
296
+ popperClass: String,
297
+ editable: {
298
+ type: Boolean,
299
+ default: true
300
+ },
301
+ align: {
302
+ type: String,
303
+ default: 'left'
304
+ },
305
+ value: {},
306
+ defaultValue: {},
307
+ defaultTime: {},
308
+ rangeSeparator: {
309
+ default: '-'
310
+ },
311
+ pickerOptions: {},
312
+ unlinkPanels: Boolean,
313
+ validateEvent: {
314
+ type: Boolean,
315
+ default: true
316
+ }
317
+ },
318
+
319
+ data() {
320
+ return {
321
+ pickerVisible: false,
322
+ showClose: false,
323
+ userInput: null,
324
+ valueOnOpen: null, // value when picker opens, used to determine whether to emit change
325
+ unwatchPickerOptions: null,
326
+ dateList: []
327
+ }
328
+ },
329
+
330
+ computed: {
331
+ reference() {
332
+ const reference = this.$refs.reference
333
+ return reference.$el || reference
334
+ },
335
+
336
+ refInput() {
337
+ if (this.reference) {
338
+ return [].slice.call(this.reference.querySelectorAll('input'))
339
+ }
340
+ return []
341
+ },
342
+
343
+ valueIsEmpty() {
344
+ const val = this.value
345
+ if (Array.isArray(val)) {
346
+ for (let i = 0, len = val.length; i < len; i++) {
347
+ if (val[i]) {
348
+ return false
349
+ }
350
+ }
351
+ } else {
352
+ if (val) {
353
+ return false
354
+ }
355
+ }
356
+ return true
357
+ },
358
+
359
+ triggerClass() {
360
+ return this.prefixIcon || 'el-icon-date'
361
+ },
362
+
363
+ haveTrigger() {
364
+ if (typeof this.showTrigger !== 'undefined') {
365
+ return this.showTrigger
366
+ }
367
+ return true
368
+ },
369
+
370
+ displayValue() {
371
+ const formattedValue = formatAsFormatAndType(this.parsedValue, this.format)
372
+ if (Array.isArray(this.userInput)) {
373
+ return [
374
+ this.userInput[0] || (formattedValue && formattedValue[0]) || '',
375
+ this.userInput[1] || (formattedValue && formattedValue[1]) || ''
376
+ ]
377
+ } else if (this.userInput !== null) {
378
+ return this.userInput
379
+ } else if (formattedValue && !Array.isArray(formattedValue) || Array.isArray(formattedValue) && formattedValue.length >= 2) {
380
+ return formattedValue
381
+ } else {
382
+ return ''
383
+ }
384
+ },
385
+
386
+ parsedValue() {
387
+ if (!this.value) return this.value // component value is not set
388
+ const valueIsDateObject = isDateObject(this.value) || (Array.isArray(this.value) && this.value.every(isDateObject))
389
+ if (valueIsDateObject) {
390
+ return this.value
391
+ }
392
+ if (this.valueFormat) {
393
+ if (this.dateList?.length) {
394
+ return this.dateList
395
+ } else {
396
+ if (Array.isArray(this.value)) {
397
+ this.value.forEach(v => {
398
+ this.dateList.push(new Date(v))
399
+ })
400
+ } else {
401
+ // eslint-disable-next-line vue/no-side-effects-in-computed-properties
402
+ this.dateList = this.value || []
403
+ }
404
+
405
+ return this.dateList
406
+ }
407
+ }
408
+
409
+ // NOTE: deal with common but incorrect usage, should remove in next major version
410
+ // user might provide string / timestamp without value-format, coerce them into date (or array of date)
411
+ return Array.isArray(this.value) ? this.value.map(val => new Date(val)) : new Date(this.value)
412
+ },
413
+
414
+ _elFormItemSize() {
415
+ return (this.elFormItem || {}).elFormItemSize
416
+ },
417
+
418
+ pickerSize() {
419
+ return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size
420
+ },
421
+
422
+ pickerDisabled() {
423
+ return this.disabled || (this.elForm || {}).disabled
424
+ },
425
+
426
+ firstInputId() {
427
+ const obj = {}
428
+ const id = this.id && this.id[0]
429
+
430
+ if (id) obj.id = id
431
+ return obj
432
+ },
433
+
434
+ secondInputId() {
435
+ const obj = {}
436
+ const id = this.id && this.id[1]
437
+
438
+ if (id) obj.id = id
439
+ return obj
440
+ }
441
+ },
442
+
443
+ watch: {
444
+ pickerVisible(val) {
445
+ if (this.readonly || this.pickerDisabled) return
446
+ if (val) {
447
+ this.showPicker()
448
+ this.valueOnOpen = Array.isArray(this.value) ? [...this.value] : this.value
449
+ } else {
450
+ this.hidePicker()
451
+ this.emitChange(this.value)
452
+ this.userInput = null
453
+ if (this.validateEvent) {
454
+ this.dispatch('ElFormItem', 'el.form.blur')
455
+ }
456
+ this.$emit('blur', this)
457
+ this.blur()
458
+ }
459
+ },
460
+ parsedValue: {
461
+ immediate: true,
462
+ handler(val) {
463
+ if (this.picker) {
464
+ this.picker.value = val
465
+ }
466
+ }
467
+ },
468
+ defaultValue(val) {
469
+ // NOTE: should eventually move to jsx style picker + panel ?
470
+ if (this.picker) {
471
+ this.picker.defaultValue = val
472
+ }
473
+ },
474
+ value(val, oldVal) {
475
+ if (!valueEquals(val, oldVal) && !this.pickerVisible && this.validateEvent) {
476
+ this.dispatch('ElFormItem', 'el.form.change', val)
477
+ }
478
+ }
479
+ },
480
+
481
+ created() {
482
+ // vue-popper
483
+ this.popperOptions = {
484
+ boundariesPadding: 0,
485
+ gpuAcceleration: false
486
+ }
487
+ this.placement = PLACEMENT_MAP[this.align] || PLACEMENT_MAP.left
488
+
489
+ this.$on('fieldReset', this.handleFieldReset)
490
+ },
491
+
492
+ methods: {
493
+ focus() {
494
+ this.handleFocus()
495
+ },
496
+
497
+ blur() {
498
+ this.refInput.forEach(input => input.blur())
499
+ },
500
+
501
+ // {parse, formatTo} Value deals maps component value with internal Date
502
+ parseValue(value) {
503
+ const isParsed = isDateObject(value) || (Array.isArray(value) && value.every(isDateObject))
504
+ if (this.valueFormat && !isParsed) {
505
+ return parseAsFormatAndType(value, this.valueFormat, this.type) || value
506
+ } else {
507
+ return value
508
+ }
509
+ },
510
+
511
+ formatToValue(date) {
512
+ const isFormattable = isDateObject(date) || (Array.isArray(date) && date.every(isDateObject))
513
+ if (this.valueFormat && isFormattable) {
514
+ return formatAsFormatAndType(date, this.valueFormat)
515
+ } else {
516
+ return date
517
+ }
518
+ },
519
+
520
+ // {parse, formatTo} String deals with user input
521
+ parseString(value) {
522
+ return parseAsFormatAndType(value, this.format, this.type)
523
+ },
524
+
525
+ formatToString(value) {
526
+ return formatAsFormatAndType(value, this.format)
527
+ },
528
+
529
+ handleMouseEnter() {
530
+ if (this.readonly || this.pickerDisabled) return
531
+ if (!this.valueIsEmpty && this.clearable) {
532
+ this.showClose = true
533
+ }
534
+ },
535
+
536
+ handleChange() {
537
+ if (this.userInput) {
538
+ const value = this.parseString(this.displayValue)
539
+ if (value) {
540
+ this.picker.value = value
541
+ console.log(1)
542
+ if (this.isValidValue(value)) {
543
+ this.emitInput(value)
544
+ this.userInput = null
545
+ }
546
+ }
547
+ }
548
+ if (this.userInput === '') {
549
+ this.emitInput(null)
550
+ this.emitChange(null)
551
+ this.userInput = null
552
+ }
553
+ },
554
+
555
+ handleClickIcon(event) {
556
+ if (this.readonly || this.pickerDisabled) return
557
+ if (this.showClose) {
558
+ this.valueOnOpen = this.value
559
+ event.stopPropagation()
560
+ this.emitInput(null)
561
+ this.emitChange(null)
562
+ this.showClose = false
563
+ if (this.picker && typeof this.picker.handleClear === 'function') {
564
+ this.picker.handleClear()
565
+ }
566
+ } else {
567
+ this.pickerVisible = !this.pickerVisible
568
+ }
569
+ },
570
+
571
+ handleClose() {
572
+ if (!this.pickerVisible) return
573
+ this.pickerVisible = false
574
+ },
575
+
576
+ handleFieldReset(initialValue) {
577
+ this.userInput = initialValue === '' ? null : initialValue
578
+ },
579
+
580
+ handleFocus() {
581
+ if (!this.pickerVisible) {
582
+ this.pickerVisible = true
583
+ }
584
+ this.$emit('focus', this)
585
+ },
586
+
587
+ handleKeydown(event) {
588
+ const keyCode = event.keyCode
589
+
590
+ // ESC
591
+ if (keyCode === 27) {
592
+ this.pickerVisible = false
593
+ event.stopPropagation()
594
+ return
595
+ }
596
+
597
+ // Tab
598
+ if (keyCode === 9) {
599
+ // user may change focus between two input
600
+ let timer = setTimeout(() => {
601
+ if (this.refInput.indexOf(document.activeElement) === -1) {
602
+ this.pickerVisible = false
603
+ this.blur()
604
+ event.stopPropagation()
605
+ }
606
+ clearTimeout(timer)
607
+ timer = null
608
+ }, 0)
609
+ return
610
+ }
611
+
612
+ // Enter
613
+ if (keyCode === 13) {
614
+ if (this.userInput === '' || this.isValidValue(this.parseString(this.displayValue))) {
615
+ this.handleChange()
616
+ this.pickerVisible = this.picker.visible = false
617
+ this.blur()
618
+ }
619
+ event.stopPropagation()
620
+ return
621
+ }
622
+
623
+ // if user is typing, do not let picker handle key input
624
+ if (this.userInput) {
625
+ event.stopPropagation()
626
+ return
627
+ }
628
+
629
+ // delegate other keys to panel
630
+ if (this.picker && this.picker.handleKeydown) {
631
+ this.picker.handleKeydown(event)
632
+ }
633
+ },
634
+
635
+ handleRangeClick() {
636
+ if (!this.pickerVisible) {
637
+ this.pickerVisible = true
638
+ }
639
+ this.$emit('focus', this)
640
+ },
641
+
642
+ hidePicker() {
643
+ if (this.picker) {
644
+ let timer = setTimeout(() => {
645
+ this.picker.resetView && this.picker.resetView()
646
+ }, 100)
647
+ this.pickerVisible = this.picker.visible = false
648
+ this.destroyPopper()
649
+ clearTimeout(timer)
650
+ timer = null
651
+ }
652
+ },
653
+
654
+ showPicker() {
655
+ if (this.$isServer) return
656
+ if (!this.picker) {
657
+ this.mountPicker()
658
+ }
659
+ this.pickerVisible = this.picker.visible = true
660
+
661
+ this.updatePopper()
662
+
663
+ this.picker.value = this.parsedValue
664
+ this.picker.resetView && this.picker.resetView()
665
+
666
+ this.$nextTick(() => {
667
+ this.picker.adjustSpinners && this.picker.adjustSpinners()
668
+ })
669
+ },
670
+
671
+ mountPicker() {
672
+ this.picker = new Vue(this.panel).$mount()
673
+ this.picker.defaultValue = this.defaultValue
674
+ this.picker.defaultTime = this.defaultTime
675
+ this.picker.popperClass = this.popperClass
676
+ this.popperElm = this.picker.$el
677
+ this.picker.width = this.reference.getBoundingClientRect().width
678
+ this.picker.showTime = false
679
+ this.picker.unlinkPanels = this.unlinkPanels
680
+ this.picker.arrowControl = this.arrowControl || this.timeArrowControl || false
681
+ this.$watch('format', (format) => {
682
+ this.picker.format = format
683
+ })
684
+
685
+ const updateOptions = () => {
686
+ const options = this.pickerOptions
687
+
688
+ if (options && options.selectableRange) {
689
+ let ranges = options.selectableRange
690
+ const parser = TYPE_VALUE_RESOLVER_MAP.datetimerange.parser
691
+ const format = DEFAULT_FORMATS.timerange
692
+
693
+ ranges = Array.isArray(ranges) ? ranges : [ranges]
694
+ this.picker.selectableRange = ranges.map(range => parser(range, format, this.rangeSeparator))
695
+ }
696
+
697
+ for (const option in options) {
698
+ if (Object.hasOwnProperty.call(options, option) &&
699
+ // 忽略 time-picker 的该配置项
700
+ option !== 'selectableRange') {
701
+ this.picker[option] = options[option]
702
+ }
703
+ }
704
+
705
+ // main format must prevail over undocumented pickerOptions.format
706
+ if (this.format) {
707
+ this.picker.format = this.format
708
+ }
709
+ }
710
+ updateOptions()
711
+ this.unwatchPickerOptions = this.$watch('pickerOptions', () => updateOptions(), { deep: true })
712
+ this.$el.appendChild(this.picker.$el)
713
+ this.picker.resetView && this.picker.resetView()
714
+
715
+ this.picker.$on('dodestroy', this.doDestroy)
716
+ this.picker.$on('pick', (date = '', visible = false) => {
717
+ this.userInput = null
718
+ this.pickerVisible = this.picker.visible = visible
719
+
720
+ this.emitInput(date)
721
+ this.picker.resetView && this.picker.resetView()
722
+ })
723
+
724
+ this.picker.$on('select-range', (start, end, pos) => {
725
+ if (this.refInput.length === 0) return
726
+ if (!pos || pos === 'min') {
727
+ this.refInput[0].setSelectionRange(start, end)
728
+ this.refInput[0].focus()
729
+ } else if (pos === 'max') {
730
+ this.refInput[1].setSelectionRange(start, end)
731
+ this.refInput[1].focus()
732
+ }
733
+ })
734
+ },
735
+
736
+ unmountPicker() {
737
+ if (this.picker) {
738
+ this.picker.$destroy()
739
+ this.picker.$off()
740
+ if (typeof this.unwatchPickerOptions === 'function') {
741
+ this.unwatchPickerOptions()
742
+ }
743
+ this.picker.$el.parentNode.removeChild(this.picker.$el)
744
+ }
745
+ },
746
+
747
+ emitChange(val) {
748
+ // determine user real change only
749
+ if (!valueEquals(val, this.valueOnOpen)) {
750
+ this.$emit('change', val)
751
+ this.$emit('update:value', val)
752
+ this.valueOnOpen = val
753
+ if (this.validateEvent) {
754
+ this.dispatch('ElFormItem', 'el.form.change', val)
755
+ }
756
+ }
757
+ },
758
+
759
+ emitInput(val) {
760
+ this.dateList = val
761
+ const formatted = this.formatToValue(val)
762
+ if (!valueEquals(this.value, formatted)) {
763
+ this.$emit('input', formatted)
764
+ this.$emit('update:value', formatted)
765
+ }
766
+ },
767
+
768
+ isValidValue(value) {
769
+ if (!this.picker) {
770
+ this.mountPicker()
771
+ }
772
+ if (this.picker.isValidValue) {
773
+ return value && this.picker.isValidValue(value)
774
+ } else {
775
+ return true
776
+ }
777
+ }
778
+ }
779
+ }
780
+ </script>