UNPKG

antd

Version:

An enterprise-class UI design language and React components implementation

81 lines (80 loc) 2.64 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = exports.Components = void 0; exports.getTimeProps = getTimeProps; var _PickerButton = _interopRequireDefault(require("../PickerButton")); var _generateRangePicker = _interopRequireDefault(require("./generateRangePicker")); var _generateSinglePicker = _interopRequireDefault(require("./generateSinglePicker")); const Components = { button: _PickerButton.default }; exports.Components = Components; function toArray(list) { if (!list) { return []; } return Array.isArray(list) ? list : [list]; } function getTimeProps(props) { const { format, picker, showHour, showMinute, showSecond, use12Hours } = props; const firstFormat = toArray(format)[0]; const showTimeObj = Object.assign({}, 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 }; } const DataPickerPlacements = ['bottomLeft', 'bottomRight', 'topLeft', 'topRight']; function generatePicker(generateConfig) { // =========================== Picker =========================== const { DatePicker, WeekPicker, MonthPicker, YearPicker, TimePicker, QuarterPicker } = (0, _generateSinglePicker.default)(generateConfig); // ======================== Range Picker ======================== const RangePicker = (0, _generateRangePicker.default)(generateConfig); const 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;