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V;AAEF,4BAAQ,KAAK;AAFX,iBA5BuC;AAgC3C,qBAAK;AAhCsC,aAAtC,CAAP;AAkCD,SApIM;AAqIP,qBArIO,2BAqIM;AACX,mBAAO,KAAK,cAAL,CAAoB,KAApB,EAA2B;AAChC,6BAAa,gCADmB;AAEhC,qBAAK,KAAK;AAFsB,aAA3B,EAGJ,CAAC,KAAK,QAAL,EAAD,CAHI,CAAP;AAID,SA1IM;AA2IP,sBA3IO,4BA2IO;AAAA;;AACZ,mBAAO,KAAK,cAAL,CAAoB,0BAApB,EAAsC;AAC3C,uBAAO;AACL,0BAAM,KAAK,MADN;AAEL,8BAAU,KAAK,QAFV;AAGL,0BAAM,KAAK,SAHN;AAIL,4BAAQ,KAAK,WAJR;AAKL,4BAAQ,KAAK,WALR;AAML,4BAAQ,KAAK,MANR;AAOL,8BAAU,KAAK,QAPV;AAQL,gCAAY,KAAK,UARZ;AASL,+BAAW,KAAK;AATX,iBADoC;AAY3C,oBAAI;AACF,wCAAoB,yBAAC,KAAD;AAAA,+BAAuB,OAAK,SAAL,GAAiB,KAAxC;AAAA,qBADlB;AAEF,qCAAiB,KAAK;AAFpB,iBAZuC;AAgB3C,qBAAK,OAhBsC;AAiB3C,sBAAM;AAjBqC,aAAtC,CAAP;AAmBD;AA/JM,KA7HF;AA+RP,UA/RO,oBA+RD;AACJ,eAAO,KAAK,SAAL,CAAe,gBAAf,CAAP;AACD;AAjSM,CAHM,C","sourcesContent":["// Components\nimport VTimePickerTitle from './VTimePickerTitle'\nimport VTimePickerClock from './VTimePickerClock'\n\n// Mixins\nimport Picker from '../../mixins/picker'\n\n// Utils\nimport { createRange } from '../../util/helpers'\nimport pad from '../VDatePicker/util/pad'\nimport mixins from '../../util/mixins'\n\n// Types\nimport { VNode } from 'vue'\nimport { PropValidator } from 'vue/types/options'\n\nconst rangeHours24 = createRange(24)\nconst rangeHours12am = createRange(12)\nconst rangeHours12pm = rangeHours12am.map(v => v + 12)\nconst range60 = createRange(60)\nconst selectingTimes: {\n hour: 1\n minute: 2\n second: 3\n} = { hour: 1, minute: 2, second: 3 }\nconst selectingNames = { 1: 'hour', 2: 'minute', 3: 'second' }\nexport { selectingTimes }\n\ntype Period = 'am' | 'pm'\n\nexport default mixins(\n Picker\n/* @vue/component */\n).extend({\n name: 'v-time-picker',\n\n props: {\n allowedHours: Function,\n allowedMinutes: Function,\n allowedSeconds: Function,\n disabled: Boolean,\n format: {\n type: String,\n default: 'ampm',\n validator (val) {\n return ['ampm', '24hr'].includes(val)\n }\n } as PropValidator<'ampm' | '24hr'>,\n min: String,\n max: String,\n readonly: Boolean,\n scrollable: Boolean,\n useSeconds: Boolean,\n value: null as any as PropValidator<any>\n },\n\n data () {\n return {\n inputHour: null as number | null,\n inputMinute: null as number | null,\n inputSecond: null as number | null,\n lazyInputHour: null as number | null,\n lazyInputMinute: null as number | null,\n lazyInputSecond: null as number | null,\n period: 'am' as Period,\n selecting: selectingTimes.hour as 1 | 2 | 3\n }\n },\n\n computed: {\n selectingHour: {\n get () {\n return this.selecting === selectingTimes.hour\n },\n set (v: boolean) {\n this.selecting = selectingTimes.hour\n }\n },\n selectingMinute: {\n get () {\n return this.selecting === selectingTimes.minute\n },\n set (v: boolean) {\n this.selecting = selectingTimes.minute\n }\n },\n selectingSecond: {\n get () {\n return this.selecting === selectingTimes.second\n },\n set (v: boolean) {\n this.selecting = selectingTimes.second\n }\n },\n isAllowedHourCb () {\n if (!this.min && !this.max) return this.allowedHours\n\n const minHour = this.min ? Number(this.min.split(':')[0]) : 0\n const maxHour = this.max ? Number(this.max.split(':')[0]) : 23\n\n return (val: number) => {\n return val >= minHour * 1 &&\n val <= maxHour * 1 &&\n (!this.allowedHours || this.allowedHours(val))\n }\n },\n isAllowedMinuteCb () {\n const isHourAllowed = !this.allowedHours || this.allowedHours(this.inputHour)\n if (!this.min && !this.max) {\n return isHourAllowed ? this.allowedMinutes : () => false\n }\n\n const [minHour, minMinute] = this.min ? this.min.split(':').map(Number) : [0, 0]\n const [maxHour, maxMinute] = this.max ? this.max.split(':').map(Number) : [23, 59]\n const minTime = minHour * 60 + minMinute * 1\n const maxTime = maxHour * 60 + maxMinute * 1\n\n return (val: number) => {\n const time = 60 * this.inputHour! + val\n return time >= minTime &&\n time <= maxTime &&\n isHourAllowed &&\n (!this.allowedMinutes || this.allowedMinutes(val))\n }\n },\n isAllowedSecondCb () {\n const isHourAllowed = !this.allowedHours || this.allowedHours(this.inputHour)\n const isMinuteAllowed = !this.allowedMinutes || this.allowedMinutes(this.inputMinute)\n if (!this.min && !this.max) {\n return isHourAllowed && isMinuteAllowed ? this.allowedSeconds : () => false\n }\n\n const [minHour, minMinute, minSecond] = this.min ? this.min.split(':').map(Number) : [0, 0, 0]\n const [maxHour, maxMinute, maxSecond] = this.max ? this.max.split(':').map(Number) : [23, 59, 59]\n const minTime = minHour * 3600 + minMinute * 60 + (minSecond || 0) * 1\n const maxTime = maxHour * 3600 + maxMinute * 60 + (maxSecond || 0) * 1\n\n return (val: number) => {\n const time = 3600 * this.inputHour! + 60 * this.inputMinute! + val\n return time >= minTime &&\n time <= maxTime &&\n isHourAllowed && isMinuteAllowed &&\n (!this.allowedSeconds || this.allowedSeconds(val))\n }\n },\n isAmPm () {\n return this.format === 'ampm'\n }\n },\n\n watch: {\n value: 'setInputData'\n },\n\n mounted () {\n this.setInputData(this.value)\n },\n\n methods: {\n genValue () {\n if (this.inputHour != null && this.inputMinute != null && (!this.useSeconds || this.inputSecond != null)) {\n return `${pad(this.inputHour)}:${pad(this.inputMinute)}` + (this.useSeconds ? `:${pad(this.inputSecond!)}` : '')\n }\n\n return null\n },\n emitValue () {\n const value = this.genValue()\n if (value !== null) this.$emit('input', value)\n },\n setPeriod (period: Period) {\n this.period = period\n if (this.inputHour != null) {\n const newHour = this.inputHour! + (period === 'am' ? -12 : 12)\n this.inputHour = this.firstAllowed('hour', newHour)\n this.emitValue()\n }\n },\n setInputData (value: string | null | Date) {\n if (value == null || value === '') {\n this.inputHour = null\n this.inputMinute = null\n this.inputSecond = null\n } else if (value instanceof Date) {\n this.inputHour = value.getHours()\n this.inputMinute = value.getMinutes()\n this.inputSecond = value.getSeconds()\n } else {\n const [, hour, minute, , second, period] = value.trim().toLowerCase().match(/^(\\d+):(\\d+)(:(\\d+))?([ap]m)?$/) || new Array(6)\n\n this.inputHour = period ? this.convert12to24(parseInt(hour, 10), period as Period) : parseInt(hour, 10)\n this.inputMinute = parseInt(minute, 10)\n this.inputSecond = parseInt(second || 0, 10)\n }\n\n this.period = (this.inputHour == null || this.inputHour < 12) ? 'am' : 'pm'\n },\n convert24to12 (hour: number) {\n return hour ? ((hour - 1) % 12 + 1) : 12\n },\n convert12to24 (hour: number, period: Period) {\n return hour % 12 + (period === 'pm' ? 12 : 0)\n },\n onInput (value: number) {\n if (this.selecting === selectingTimes.hour) {\n this.inputHour = this.isAmPm ? this.convert12to24(value, this.period) : value\n } else if (this.selecting === selectingTimes.minute) {\n this.inputMinute = value\n } else {\n this.inputSecond = value\n }\n this.emitValue()\n },\n onChange (value: number) {\n this.$emit(`click:${selectingNames[this.selecting]}`, value)\n\n const emitChange = this.selecting === (this.useSeconds ? selectingTimes.second : selectingTimes.minute)\n\n if (this.selecting === selectingTimes.hour) {\n this.selecting = selectingTimes.minute\n } else if (this.useSeconds && this.selecting === selectingTimes.minute) {\n this.selecting = selectingTimes.second\n }\n\n if (this.inputHour === this.lazyInputHour &&\n this.inputMinute === this.lazyInputMinute &&\n (!this.useSeconds || this.inputSecond === this.lazyInputSecond)\n ) return\n\n const time = this.genValue()\n if (time === null) return\n\n this.lazyInputHour = this.inputHour\n this.lazyInputMinute = this.inputMinute\n this.useSeconds && (this.lazyInputSecond = this.inputSecond)\n\n emitChange && this.$emit('change', time)\n },\n firstAllowed (type: 'hour' | 'minute' | 'second', value: number) {\n const allowedFn = type === 'hour' ? this.isAllowedHourCb : (type === 'minute' ? this.isAllowedMinuteCb : this.isAllowedSecondCb)\n if (!allowedFn) return value\n\n // TODO: clean up\n const range = type === 'minute'\n ? range60\n : (type === 'second'\n ? range60\n : (this.isAmPm\n ? (value < 12\n ? rangeHours12am\n : rangeHours12pm)\n : rangeHours24))\n const first = range.find(v => allowedFn((v + value) % range.length + range[0]))\n return ((first || 0) + value) % range.length + range[0]\n },\n genClock () {\n return this.$createElement(VTimePickerClock, {\n props: {\n allowedValues:\n this.selecting === selectingTimes.hour\n ? this.isAllowedHourCb\n : (this.selecting === selectingTimes.minute\n ? this.isAllowedMinuteCb\n : this.isAllowedSecondCb),\n color: this.color,\n dark: this.dark,\n disabled: this.disabled,\n double: this.selecting === selectingTimes.hour && !this.isAmPm,\n format: this.selecting === selectingTimes.hour\n ? (this.isAmPm ? this.convert24to12 : (val: number) => val)\n : (val: number) => pad(val, 2),\n light: this.light,\n max: this.selecting === selectingTimes.hour ? (this.isAmPm && this.period === 'am' ? 11 : 23) : 59,\n min: this.selecting === selectingTimes.hour && this.isAmPm && this.period === 'pm' ? 12 : 0,\n readonly: this.readonly,\n scrollable: this.scrollable,\n size: Number(this.width) - ((!this.fullWidth && this.landscape) ? 80 : 20),\n step: this.selecting === selectingTimes.hour ? 1 : 5,\n value: this.selecting === selectingTimes.hour\n ? this.inputHour\n : (this.selecting === selectingTimes.minute\n ? this.inputMinute\n : this.inputSecond)\n },\n on: {\n input: this.onInput,\n change: this.onChange\n },\n ref: 'clock'\n })\n },\n genPickerBody () {\n return this.$createElement('div', {\n staticClass: 'v-time-picker-clock__container',\n key: this.selecting\n }, [this.genClock()])\n },\n genPickerTitle () {\n return this.$createElement(VTimePickerTitle, {\n props: {\n ampm: this.isAmPm,\n disabled: this.disabled,\n hour: this.inputHour,\n minute: this.inputMinute,\n second: this.inputSecond,\n period: this.period,\n readonly: this.readonly,\n useSeconds: this.useSeconds,\n selecting: this.selecting\n },\n on: {\n 'update:selecting': (value: 1 | 2 | 3) => (this.selecting = value),\n 'update:period': this.setPeriod\n },\n ref: 'title',\n slot: 'title'\n })\n }\n },\n\n render (): VNode {\n return this.genPicker('v-picker--time')\n }\n})\n"],"sourceRoot":""}
|