forked from ElementUI/lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
time-select.js
1839 lines (1577 loc) · 55 KB
/
time-select.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/dist/";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 192);
/******/ })
/************************************************************************/
/******/ ({
/***/ 0:
/***/ (function(module, exports) {
/* globals __VUE_SSR_CONTEXT__ */
// IMPORTANT: Do NOT use ES2015 features in this file.
// This module is a runtime utility for cleaner component module output and will
// be included in the final webpack user bundle.
module.exports = function normalizeComponent (
rawScriptExports,
compiledTemplate,
functionalTemplate,
injectStyles,
scopeId,
moduleIdentifier /* server only */
) {
var esModule
var scriptExports = rawScriptExports = rawScriptExports || {}
// ES6 modules interop
var type = typeof rawScriptExports.default
if (type === 'object' || type === 'function') {
esModule = rawScriptExports
scriptExports = rawScriptExports.default
}
// Vue.extend constructor export interop
var options = typeof scriptExports === 'function'
? scriptExports.options
: scriptExports
// render functions
if (compiledTemplate) {
options.render = compiledTemplate.render
options.staticRenderFns = compiledTemplate.staticRenderFns
options._compiled = true
}
// functional template
if (functionalTemplate) {
options.functional = true
}
// scopedId
if (scopeId) {
options._scopeId = scopeId
}
var hook
if (moduleIdentifier) { // server build
hook = function (context) {
// 2.3 injection
context =
context || // cached call
(this.$vnode && this.$vnode.ssrContext) || // stateful
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
// 2.2 with runInNewContext: true
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
context = __VUE_SSR_CONTEXT__
}
// inject component styles
if (injectStyles) {
injectStyles.call(this, context)
}
// register component module identifier for async chunk inferrence
if (context && context._registeredComponents) {
context._registeredComponents.add(moduleIdentifier)
}
}
// used by ssr in case component is cached and beforeCreate
// never gets called
options._ssrRegister = hook
} else if (injectStyles) {
hook = injectStyles
}
if (hook) {
var functional = options.functional
var existing = functional
? options.render
: options.beforeCreate
if (!functional) {
// inject component registration as beforeCreate hook
options.beforeCreate = existing
? [].concat(existing, hook)
: [hook]
} else {
// for template-only hot-reload because in that case the render fn doesn't
// go through the normalizer
options._injectStyles = hook
// register for functioal component in vue file
options.render = function renderWithStyleInjection (h, context) {
hook.call(context)
return existing(h, context)
}
}
}
return {
esModule: esModule,
exports: scriptExports,
options: options
}
}
/***/ }),
/***/ 1:
/***/ (function(module, exports) {
module.exports = require("element-ui/lib/mixins/emitter");
/***/ }),
/***/ 10:
/***/ (function(module, exports) {
module.exports = require("element-ui/lib/utils/clickoutside");
/***/ }),
/***/ 11:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.extractTimeFormat = exports.extractDateFormat = exports.nextYear = exports.prevYear = exports.nextMonth = exports.prevMonth = exports.changeYearMonthAndClampDate = exports.timeWithinRange = exports.limitTimeRange = exports.clearMilliseconds = exports.clearTime = exports.modifyWithTimeString = exports.modifyTime = exports.modifyDate = exports.range = exports.getRangeMinutes = exports.getRangeHours = exports.getWeekNumber = exports.getStartDateOfMonth = exports.nextDate = exports.prevDate = exports.getFirstDayOfMonth = exports.getDayCountOfYear = exports.getDayCountOfMonth = exports.parseDate = exports.formatDate = exports.isDateObject = exports.isDate = exports.toDate = undefined;
var _date = __webpack_require__(29);
var _date2 = _interopRequireDefault(_date);
var _locale = __webpack_require__(12);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var weeks = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
var months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
var getI18nSettings = function getI18nSettings() {
return {
dayNamesShort: weeks.map(function (week) {
return (0, _locale.t)('el.datepicker.weeks.' + week);
}),
dayNames: weeks.map(function (week) {
return (0, _locale.t)('el.datepicker.weeks.' + week);
}),
monthNamesShort: months.map(function (month) {
return (0, _locale.t)('el.datepicker.months.' + month);
}),
monthNames: months.map(function (month, index) {
return (0, _locale.t)('el.datepicker.month' + (index + 1));
}),
amPm: ['am', 'pm']
};
};
var newArray = function newArray(start, end) {
var result = [];
for (var i = start; i <= end; i++) {
result.push(i);
}
return result;
};
var toDate = exports.toDate = function toDate(date) {
return isDate(date) ? new Date(date) : null;
};
var isDate = exports.isDate = function isDate(date) {
if (date === null || date === undefined) return false;
if (isNaN(new Date(date).getTime())) return false;
if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
return true;
};
var isDateObject = exports.isDateObject = function isDateObject(val) {
return val instanceof Date;
};
var formatDate = exports.formatDate = function formatDate(date, format) {
date = toDate(date);
if (!date) return '';
return _date2.default.format(date, format || 'yyyy-MM-dd', getI18nSettings());
};
var parseDate = exports.parseDate = function parseDate(string, format) {
return _date2.default.parse(string, format || 'yyyy-MM-dd', getI18nSettings());
};
var getDayCountOfMonth = exports.getDayCountOfMonth = function getDayCountOfMonth(year, month) {
if (month === 3 || month === 5 || month === 8 || month === 10) {
return 30;
}
if (month === 1) {
if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
return 29;
} else {
return 28;
}
}
return 31;
};
var getDayCountOfYear = exports.getDayCountOfYear = function getDayCountOfYear(year) {
var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
return isLeapYear ? 366 : 365;
};
var getFirstDayOfMonth = exports.getFirstDayOfMonth = function getFirstDayOfMonth(date) {
var temp = new Date(date.getTime());
temp.setDate(1);
return temp.getDay();
};
// see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
// {prev, next} Date should work for Daylight Saving Time
// Adding 24 * 60 * 60 * 1000 does not work in the above scenario
var prevDate = exports.prevDate = function prevDate(date) {
var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
};
var nextDate = exports.nextDate = function nextDate(date) {
var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
};
var getStartDateOfMonth = exports.getStartDateOfMonth = function getStartDateOfMonth(year, month) {
var result = new Date(year, month, 1);
var day = result.getDay();
if (day === 0) {
return prevDate(result, 7);
} else {
return prevDate(result, day);
}
};
var getWeekNumber = exports.getWeekNumber = function getWeekNumber(src) {
if (!isDate(src)) return null;
var date = new Date(src.getTime());
date.setHours(0, 0, 0, 0);
// Thursday in current week decides the year.
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
// January 4 is always in week 1.
var week1 = new Date(date.getFullYear(), 0, 4);
// Adjust to Thursday in week 1 and count number of weeks from date to week 1.
// Rounding should be fine for Daylight Saving Time. Its shift should never be more than 12 hours.
return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 - 3 + (week1.getDay() + 6) % 7) / 7);
};
var getRangeHours = exports.getRangeHours = function getRangeHours(ranges) {
var hours = [];
var disabledHours = [];
(ranges || []).forEach(function (range) {
var value = range.map(function (date) {
return date.getHours();
});
disabledHours = disabledHours.concat(newArray(value[0], value[1]));
});
if (disabledHours.length) {
for (var i = 0; i < 24; i++) {
hours[i] = disabledHours.indexOf(i) === -1;
}
} else {
for (var _i = 0; _i < 24; _i++) {
hours[_i] = false;
}
}
return hours;
};
function setRangeData(arr, start, end, value) {
for (var i = start; i < end; i++) {
arr[i] = value;
}
}
var getRangeMinutes = exports.getRangeMinutes = function getRangeMinutes(ranges, hour) {
var minutes = new Array(60);
if (ranges.length > 0) {
ranges.forEach(function (range) {
var start = range[0];
var end = range[1];
var startHour = start.getHours();
var startMinute = start.getMinutes();
var endHour = end.getHours();
var endMinute = end.getMinutes();
if (startHour === hour && endHour !== hour) {
setRangeData(minutes, startMinute, 60, true);
} else if (startHour === hour && endHour === hour) {
setRangeData(minutes, startMinute, endMinute + 1, true);
} else if (startHour !== hour && endHour === hour) {
setRangeData(minutes, 0, endMinute + 1, true);
} else if (startHour < hour && endHour > hour) {
setRangeData(minutes, 0, 60, true);
}
});
} else {
setRangeData(minutes, 0, 60, true);
}
return minutes;
};
var range = exports.range = function range(n) {
// see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
return Array.apply(null, { length: n }).map(function (_, n) {
return n;
});
};
var modifyDate = exports.modifyDate = function modifyDate(date, y, m, d) {
return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
};
var modifyTime = exports.modifyTime = function modifyTime(date, h, m, s) {
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
};
var modifyWithTimeString = exports.modifyWithTimeString = function modifyWithTimeString(date, time) {
if (date == null || !time) {
return date;
}
time = parseDate(time, 'HH:mm:ss');
return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
};
var clearTime = exports.clearTime = function clearTime(date) {
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
};
var clearMilliseconds = exports.clearMilliseconds = function clearMilliseconds(date) {
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
};
var limitTimeRange = exports.limitTimeRange = function limitTimeRange(date, ranges) {
var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
// TODO: refactory a more elegant solution
if (ranges.length === 0) return date;
var normalizeDate = function normalizeDate(date) {
return _date2.default.parse(_date2.default.format(date, format), format);
};
var ndate = normalizeDate(date);
var nranges = ranges.map(function (range) {
return range.map(normalizeDate);
});
if (nranges.some(function (nrange) {
return ndate >= nrange[0] && ndate <= nrange[1];
})) return date;
var minDate = nranges[0][0];
var maxDate = nranges[0][0];
nranges.forEach(function (nrange) {
minDate = new Date(Math.min(nrange[0], minDate));
maxDate = new Date(Math.max(nrange[1], minDate));
});
var ret = ndate < minDate ? minDate : maxDate;
// preserve Year/Month/Date
return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
};
var timeWithinRange = exports.timeWithinRange = function timeWithinRange(date, selectableRange, format) {
var limitedDate = limitTimeRange(date, selectableRange, format);
return limitedDate.getTime() === date.getTime();
};
var changeYearMonthAndClampDate = exports.changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
// clamp date to the number of days in `year`, `month`
// eg: (2010-1-31, 2010, 2) => 2010-2-28
var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
return modifyDate(date, year, month, monthDate);
};
var prevMonth = exports.prevMonth = function prevMonth(date) {
var year = date.getFullYear();
var month = date.getMonth();
return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
};
var nextMonth = exports.nextMonth = function nextMonth(date) {
var year = date.getFullYear();
var month = date.getMonth();
return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
};
var prevYear = exports.prevYear = function prevYear(date) {
var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
var year = date.getFullYear();
var month = date.getMonth();
return changeYearMonthAndClampDate(date, year - amount, month);
};
var nextYear = exports.nextYear = function nextYear(date) {
var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
var year = date.getFullYear();
var month = date.getMonth();
return changeYearMonthAndClampDate(date, year + amount, month);
};
var extractDateFormat = exports.extractDateFormat = function extractDateFormat(format) {
return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
};
var extractTimeFormat = exports.extractTimeFormat = function extractTimeFormat(format) {
return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
};
/***/ }),
/***/ 12:
/***/ (function(module, exports) {
module.exports = require("element-ui/lib/locale");
/***/ }),
/***/ 17:
/***/ (function(module, exports) {
module.exports = require("element-ui/lib/scrollbar");
/***/ }),
/***/ 192:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _timeSelect = __webpack_require__(193);
var _timeSelect2 = _interopRequireDefault(_timeSelect);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* istanbul ignore next */
_timeSelect2.default.install = function (Vue) {
Vue.component(_timeSelect2.default.name, _timeSelect2.default);
};
exports.default = _timeSelect2.default;
/***/ }),
/***/ 193:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _picker = __webpack_require__(27);
var _picker2 = _interopRequireDefault(_picker);
var _timeSelect = __webpack_require__(194);
var _timeSelect2 = _interopRequireDefault(_timeSelect);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = {
mixins: [_picker2.default],
name: 'ElTimeSelect',
componentName: 'ElTimeSelect',
props: {
type: {
type: String,
default: 'time-select'
}
},
beforeCreate: function beforeCreate() {
this.panel = _timeSelect2.default;
}
};
/***/ }),
/***/ 194:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_time_select_vue__ = __webpack_require__(195);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_time_select_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_time_select_vue__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_3cf1dfe3_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_time_select_vue__ = __webpack_require__(196);
var normalizeComponent = __webpack_require__(0)
/* script */
/* template */
/* template functional */
var __vue_template_functional__ = false
/* styles */
var __vue_styles__ = null
/* scopeId */
var __vue_scopeId__ = null
/* moduleIdentifier (server only) */
var __vue_module_identifier__ = null
var Component = normalizeComponent(
__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_time_select_vue___default.a,
__WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_3cf1dfe3_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_time_select_vue__["a" /* default */],
__vue_template_functional__,
__vue_styles__,
__vue_scopeId__,
__vue_module_identifier__
)
/* harmony default export */ __webpack_exports__["default"] = (Component.exports);
/***/ }),
/***/ 195:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _scrollbar = __webpack_require__(17);
var _scrollbar2 = _interopRequireDefault(_scrollbar);
var _scrollIntoView = __webpack_require__(26);
var _scrollIntoView2 = _interopRequireDefault(_scrollIntoView);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
var parseTime = function parseTime(time) {
var values = (time || '').split(':');
if (values.length >= 2) {
var hours = parseInt(values[0], 10);
var minutes = parseInt(values[1], 10);
return {
hours: hours,
minutes: minutes
};
}
/* istanbul ignore next */
return null;
};
var compareTime = function compareTime(time1, time2) {
var value1 = parseTime(time1);
var value2 = parseTime(time2);
var minutes1 = value1.minutes + value1.hours * 60;
var minutes2 = value2.minutes + value2.hours * 60;
if (minutes1 === minutes2) {
return 0;
}
return minutes1 > minutes2 ? 1 : -1;
};
var formatTime = function formatTime(time) {
return (time.hours < 10 ? '0' + time.hours : time.hours) + ':' + (time.minutes < 10 ? '0' + time.minutes : time.minutes);
};
var nextTime = function nextTime(time, step) {
var timeValue = parseTime(time);
var stepValue = parseTime(step);
var next = {
hours: timeValue.hours,
minutes: timeValue.minutes
};
next.minutes += stepValue.minutes;
next.hours += stepValue.hours;
next.hours += Math.floor(next.minutes / 60);
next.minutes = next.minutes % 60;
return formatTime(next);
};
exports.default = {
components: { ElScrollbar: _scrollbar2.default },
watch: {
value: function value(val) {
var _this = this;
if (!val) return;
this.$nextTick(function () {
return _this.scrollToOption();
});
}
},
methods: {
handleClick: function handleClick(item) {
if (!item.disabled) {
this.$emit('pick', item.value);
}
},
handleClear: function handleClear() {
this.$emit('pick', null);
},
scrollToOption: function scrollToOption() {
var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '.selected';
var menu = this.$refs.popper.querySelector('.el-picker-panel__content');
(0, _scrollIntoView2.default)(menu, menu.querySelector(selector));
},
handleMenuEnter: function handleMenuEnter() {
var _this2 = this;
var selected = this.items.map(function (item) {
return item.value;
}).indexOf(this.value) !== -1;
var hasDefault = this.items.map(function (item) {
return item.value;
}).indexOf(this.defaultValue) !== -1;
var option = selected && '.selected' || hasDefault && '.default' || '.time-select-item:not(.disabled)';
this.$nextTick(function () {
return _this2.scrollToOption(option);
});
},
scrollDown: function scrollDown(step) {
var items = this.items;
var length = items.length;
var total = items.length;
var index = items.map(function (item) {
return item.value;
}).indexOf(this.value);
while (total--) {
index = (index + step + length) % length;
if (!items[index].disabled) {
this.$emit('pick', items[index].value, true);
return;
}
}
},
isValidValue: function isValidValue(date) {
return this.items.filter(function (item) {
return !item.disabled;
}).map(function (item) {
return item.value;
}).indexOf(date) !== -1;
},
handleKeydown: function handleKeydown(event) {
var keyCode = event.keyCode;
if (keyCode === 38 || keyCode === 40) {
var mapping = { 40: 1, 38: -1 };
var offset = mapping[keyCode.toString()];
this.scrollDown(offset);
event.stopPropagation();
return;
}
}
},
data: function data() {
return {
popperClass: '',
start: '09:00',
end: '18:00',
step: '00:30',
value: '',
defaultValue: '',
visible: false,
minTime: '',
maxTime: '',
width: 0
};
},
computed: {
items: function items() {
var start = this.start;
var end = this.end;
var step = this.step;
var result = [];
if (start && end && step) {
var current = start;
while (compareTime(current, end) <= 0) {
result.push({
value: current,
disabled: compareTime(current, this.minTime || '-1:-1') <= 0 || compareTime(current, this.maxTime || '100:100') >= 0
});
current = nextTime(current, step);
}
}
return result;
}
}
};
/***/ }),
/***/ 196:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('transition',{attrs:{"name":"el-zoom-in-top"},on:{"before-enter":_vm.handleMenuEnter,"after-leave":function($event){_vm.$emit('dodestroy')}}},[_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.visible),expression:"visible"}],ref:"popper",staticClass:"el-picker-panel time-select el-popper",class:_vm.popperClass,style:({ width: _vm.width + 'px' })},[_c('el-scrollbar',{attrs:{"noresize":"","wrap-class":"el-picker-panel__content"}},_vm._l((_vm.items),function(item){return _c('div',{staticClass:"time-select-item",class:{ selected: _vm.value === item.value, disabled: item.disabled, default: item.value === _vm.defaultValue },attrs:{"disabled":item.disabled},on:{"click":function($event){_vm.handleClick(item)}}},[_vm._v(_vm._s(item.value))])}))],1)])}
var staticRenderFns = []
var esExports = { render: render, staticRenderFns: staticRenderFns }
/* harmony default export */ __webpack_exports__["a"] = (esExports);
/***/ }),
/***/ 26:
/***/ (function(module, exports) {
module.exports = require("element-ui/lib/utils/scroll-into-view");
/***/ }),
/***/ 27:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_picker_vue__ = __webpack_require__(28);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_picker_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_picker_vue__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_66b1c70c_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_picker_vue__ = __webpack_require__(30);
var normalizeComponent = __webpack_require__(0)
/* script */
/* template */
/* template functional */
var __vue_template_functional__ = false
/* styles */
var __vue_styles__ = null
/* scopeId */
var __vue_scopeId__ = null
/* moduleIdentifier (server only) */
var __vue_module_identifier__ = null
var Component = normalizeComponent(
__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_picker_vue___default.a,
__WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_66b1c70c_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_picker_vue__["a" /* default */],
__vue_template_functional__,
__vue_styles__,
__vue_scopeId__,
__vue_module_identifier__
)
/* harmony default export */ __webpack_exports__["default"] = (Component.exports);
/***/ }),
/***/ 28:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _vue = __webpack_require__(4);
var _vue2 = _interopRequireDefault(_vue);
var _clickoutside = __webpack_require__(10);
var _clickoutside2 = _interopRequireDefault(_clickoutside);
var _util = __webpack_require__(11);
var _vuePopper = __webpack_require__(7);
var _vuePopper2 = _interopRequireDefault(_vuePopper);
var _emitter = __webpack_require__(1);
var _emitter2 = _interopRequireDefault(_emitter);
var _input = __webpack_require__(6);
var _input2 = _interopRequireDefault(_input);
var _merge = __webpack_require__(9);
var _merge2 = _interopRequireDefault(_merge);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var NewPopper = {
props: {
appendToBody: _vuePopper2.default.props.appendToBody,
offset: _vuePopper2.default.props.offset,
boundariesPadding: _vuePopper2.default.props.boundariesPadding,
arrowOffset: _vuePopper2.default.props.arrowOffset
},
methods: _vuePopper2.default.methods,
data: function data() {
return (0, _merge2.default)({ visibleArrow: true }, _vuePopper2.default.data);
},
beforeDestroy: _vuePopper2.default.beforeDestroy
}; //
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//