"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports.default = void 0; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _utils = require("../utils"); var _string = require("../utils/format/string"); var _number = require("../utils/format/number"); var _shared = require("./shared"); var _createNamespace = (0, _utils.createNamespace)('time-picker'), createComponent = _createNamespace[0]; var _default = createComponent({ mixins: [_shared.TimePickerMixin], props: (0, _extends2.default)({}, _shared.sharedProps, { minHour: { type: [Number, String], default: 0 }, maxHour: { type: [Number, String], default: 23 }, minMinute: { type: [Number, String], default: 0 }, maxMinute: { type: [Number, String], default: 59 } }), computed: { ranges: function ranges() { return [{ type: 'hour', range: [+this.minHour, +this.maxHour] }, { type: 'minute', range: [+this.minMinute, +this.maxMinute] }]; } }, watch: { filter: 'updateInnerValue', minHour: 'updateInnerValue', maxHour: 'updateInnerValue', minMinute: 'updateInnerValue', maxMinute: 'updateInnerValue', value: function value(val) { val = this.formatValue(val); if (val !== this.innerValue) { this.innerValue = val; this.updateColumnValue(); } } }, methods: { formatValue: function formatValue(value) { if (!value) { value = (0, _string.padZero)(this.minHour) + ":" + (0, _string.padZero)(this.minMinute); } var _value$split = value.split(':'), hour = _value$split[0], minute = _value$split[1]; hour = (0, _string.padZero)((0, _number.range)(hour, this.minHour, this.maxHour)); minute = (0, _string.padZero)((0, _number.range)(minute, this.minMinute, this.maxMinute)); return hour + ":" + minute; }, updateInnerValue: function updateInnerValue() { var _this$getPicker$getIn = this.getPicker().getIndexes(), hourIndex = _this$getPicker$getIn[0], minuteIndex = _this$getPicker$getIn[1]; var _this$originColumns = this.originColumns, hourColumn = _this$originColumns[0], minuteColumn = _this$originColumns[1]; var hour = hourColumn.values[hourIndex] || hourColumn.values[0]; var minute = minuteColumn.values[minuteIndex] || minuteColumn.values[0]; this.innerValue = this.formatValue(hour + ":" + minute); this.updateColumnValue(); }, onChange: function onChange(picker) { var _this = this; this.updateInnerValue(); this.$nextTick(function () { _this.$nextTick(function () { _this.$emit('change', picker); }); }); }, updateColumnValue: function updateColumnValue() { var _this2 = this; var formatter = this.formatter; var pair = this.innerValue.split(':'); var values = [formatter('hour', pair[0]), formatter('minute', pair[1])]; this.$nextTick(function () { _this2.getPicker().setValues(values); }); } } }); exports.default = _default;