index.js
3.04 KB
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
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getTimeProps = getTimeProps;
exports["default"] = exports.Components = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _PickerButton = _interopRequireDefault(require("../PickerButton"));
var _PickerTag = _interopRequireDefault(require("../PickerTag"));
var _generateSinglePicker2 = _interopRequireDefault(require("./generateSinglePicker"));
var _generateRangePicker = _interopRequireDefault(require("./generateRangePicker"));
var Components = {
button: _PickerButton["default"],
rangeItem: _PickerTag["default"]
};
exports.Components = Components;
function toArray(list) {
if (!list) {
return [];
}
return Array.isArray(list) ? list : [list];
}
function getTimeProps(props) {
var format = props.format,
picker = props.picker,
showHour = props.showHour,
showMinute = props.showMinute,
showSecond = props.showSecond,
use12Hours = props.use12Hours;
var firstFormat = toArray(format)[0];
var showTimeObj = (0, _extends2["default"])({}, props);
if (firstFormat && typeof firstFormat === 'string') {
if (!firstFormat.includes('s') && showSecond === undefined) {
showTimeObj.showSecond = false;
}
if (!firstFormat.includes('m') && showMinute === undefined) {
showTimeObj.showMinute = false;
}
if (!firstFormat.includes('H') && !firstFormat.includes('h') && showHour === undefined) {
showTimeObj.showHour = false;
}
if ((firstFormat.includes('a') || firstFormat.includes('A')) && use12Hours === undefined) {
showTimeObj.use12Hours = true;
}
}
if (picker === 'time') {
return showTimeObj;
}
if (typeof firstFormat === 'function') {
// format of showTime should use default when format is custom format function
delete showTimeObj.format;
}
return {
showTime: showTimeObj
};
}
function generatePicker(generateConfig) {
// =========================== Picker ===========================
var _generateSinglePicker = (0, _generateSinglePicker2["default"])(generateConfig),
DatePicker = _generateSinglePicker.DatePicker,
WeekPicker = _generateSinglePicker.WeekPicker,
MonthPicker = _generateSinglePicker.MonthPicker,
YearPicker = _generateSinglePicker.YearPicker,
TimePicker = _generateSinglePicker.TimePicker,
QuarterPicker = _generateSinglePicker.QuarterPicker; // ======================== Range Picker ========================
var RangePicker = (0, _generateRangePicker["default"])(generateConfig);
var MergedDatePicker = DatePicker;
MergedDatePicker.WeekPicker = WeekPicker;
MergedDatePicker.MonthPicker = MonthPicker;
MergedDatePicker.YearPicker = YearPicker;
MergedDatePicker.RangePicker = RangePicker;
MergedDatePicker.TimePicker = TimePicker;
MergedDatePicker.QuarterPicker = QuarterPicker;
return MergedDatePicker;
}
var _default = generatePicker;
exports["default"] = _default;