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e;AAErB,QAAA,KAAK,EAAE;AACL,UAAA,IAAI,EAAG,CAAD,IAAsB,CAAC,CAAC,OAAF,GAAY,CAAC,EAAd,IAAqB,KAAK,KAAL,CAAW,CAAX,EAAc,kBAAd,CAD3C;AAEL,UAAA,KAAK,EAAG,CAAD,IAAsB,CAAC,CAAC,OAAF,GAAY,EAAb,IAAoB,KAAK,KAAL,CAAW,CAAC,CAAZ,EAAe,kBAAf;AAF3C;AAFc,OAAvB;AAQA,aAAO,KAAK,cAAL,CAAoB,KAApB,EAA2B;AAChC,QAAA,WADgC;AAEhC,QAAA,KAAK,EAAE;AACL,2CAAiC,KAAK,QADjC;AAEL,aAAG,KAAK;AAFH,SAFyB;AAMhC,QAAA,EAAE,EAAG,CAAC,KAAK,QAAN,IAAkB,KAAK,UAAxB,GAAsC;AACxC,UAAA,KAAK,EAAG,CAAD,IAAmB,KAAK,KAAL,CAAW,CAAX,EAAc,kBAAd;AADc,SAAtC,GAEA,SAR4B;AAShC,QAAA,UAAU,EAAE,CAAC,cAAD;AAToB,OAA3B,EAUJ,CAAC,UAAD,CAVI,CAAP;AAWD;;AArHM;AAjDF,CALM,CAAf","sourcesContent":["import '../VDatePickerTable.sass'\n\n// Directives\nimport Touch, { TouchWrapper } from '../../../directives/touch'\n\n// Mixins\nimport Colorable from '../../../mixins/colorable'\nimport Localable from '../../../mixins/localable'\nimport Themeable from '../../../mixins/themeable'\n\n// Utils\nimport isDateAllowed, { AllowedDateFunction } from '../util/isDateAllowed'\nimport mixins from '../../../util/mixins'\n\n// Types\nimport { VNodeChildren } from 'vue'\nimport { PropValidator } from 'vue/types/options'\nimport { DatePickerFormatter } from '../util/createNativeLocaleFormatter'\nimport { DateEvents, DateEventColors, DateEventColorValue } from '../VDatePicker'\n\ntype CalculateTableDateFunction = (v: number) => string\n\nexport default mixins(\n Colorable,\n Localable,\n Themeable\n/* @vue/component */\n).extend({\n directives: { Touch },\n\n props: {\n allowedDates: Function as PropValidator<AllowedDateFunction | undefined>,\n current: String,\n disabled: Boolean,\n format: Function as PropValidator<DatePickerFormatter | undefined>,\n events: {\n type: [Array, Function, Object],\n default: () => null,\n } as any as PropValidator<DateEvents>,\n eventColor: {\n type: [Array, Function, Object, String],\n default: () => 'warning',\n } as any as PropValidator<DateEventColors>,\n min: String,\n max: String,\n readonly: Boolean,\n scrollable: Boolean,\n tableDate: {\n type: String,\n required: true,\n },\n value: [String, Array],\n },\n\n data: () => ({\n isReversing: false,\n }),\n\n computed: {\n computedTransition (): string {\n return (this.isReversing === !this.$vuetify.rtl) ? 'tab-reverse-transition' : 'tab-transition'\n },\n displayedMonth (): number {\n return Number(this.tableDate.split('-')[1]) - 1\n },\n displayedYear (): number {\n return Number(this.tableDate.split('-')[0])\n },\n },\n\n watch: {\n tableDate (newVal: string, oldVal: string) {\n this.isReversing = newVal < oldVal\n },\n },\n\n methods: {\n genButtonClasses (isAllowed: boolean, isFloating: boolean, isSelected: boolean, isCurrent: boolean) {\n return {\n 'v-size--default': !isFloating,\n 'v-btn--active': isSelected,\n 'v-btn--flat': !isAllowed || this.disabled,\n 'v-btn--text': isSelected === isCurrent,\n 'v-btn--rounded': isFloating,\n 'v-btn--disabled': !isAllowed || this.disabled,\n 'v-btn--outlined': isCurrent && !isSelected,\n ...this.themeClasses,\n }\n },\n genButtonEvents (value: string, isAllowed: boolean, mouseEventType: string) {\n if (this.disabled) return undefined\n\n return {\n click: () => {\n isAllowed && !this.readonly && this.$emit('input', value)\n this.$emit(`click:${mouseEventType}`, value)\n },\n dblclick: () => this.$emit(`dblclick:${mouseEventType}`, value),\n }\n },\n genButton (value: string, isFloating: boolean, mouseEventType: string, formatter: DatePickerFormatter) {\n const isAllowed = isDateAllowed(value, this.min, this.max, this.allowedDates)\n const isSelected = value === this.value || (Array.isArray(this.value) && this.value.indexOf(value) !== -1)\n const isCurrent = value === this.current\n const setColor = isSelected ? this.setBackgroundColor : this.setTextColor\n const color = (isSelected || isCurrent) && (this.color || 'accent')\n\n return this.$createElement('button', setColor(color, {\n staticClass: 'v-btn',\n class: this.genButtonClasses(isAllowed, isFloating, isSelected, isCurrent),\n attrs: {\n type: 'button',\n },\n domProps: {\n disabled: this.disabled || !isAllowed,\n },\n on: this.genButtonEvents(value, isAllowed, mouseEventType),\n }), [\n this.$createElement('div', {\n staticClass: 'v-btn__content',\n }, [formatter(value)]),\n this.genEvents(value),\n ])\n },\n getEventColors (date: string) {\n const arrayize = (v: string | string[]) => Array.isArray(v) ? v : [v]\n let eventData: boolean | DateEventColorValue\n let eventColors: string[] = []\n\n if (Array.isArray(this.events)) {\n eventData = this.events.includes(date)\n } else if (this.events instanceof Function) {\n eventData = this.events(date) || false\n } else if (this.events) {\n eventData = this.events[date] || false\n } else {\n eventData = false\n }\n\n if (!eventData) {\n return []\n } else if (eventData !== true) {\n eventColors = arrayize(eventData)\n } else if (typeof this.eventColor === 'string') {\n eventColors = [this.eventColor]\n } else if (typeof this.eventColor === 'function') {\n eventColors = arrayize(this.eventColor(date))\n } else if (Array.isArray(this.eventColor)) {\n eventColors = this.eventColor\n } else {\n eventColors = arrayize(this.eventColor[date])\n }\n\n return eventColors.filter(v => v)\n },\n genEvents (date: string) {\n const eventColors = this.getEventColors(date)\n\n return eventColors.length ? this.$createElement('div', {\n staticClass: 'v-date-picker-table__events',\n }, eventColors.map(color => this.$createElement('div', this.setBackgroundColor(color)))) : null\n },\n wheel (e: WheelEvent, calculateTableDate: CalculateTableDateFunction) {\n e.preventDefault()\n this.$emit('update:table-date', calculateTableDate(e.deltaY))\n },\n touch (value: number, calculateTableDate: CalculateTableDateFunction) {\n this.$emit('update:table-date', calculateTableDate(value))\n },\n genTable (staticClass: string, children: VNodeChildren, calculateTableDate: CalculateTableDateFunction) {\n const transition = this.$createElement('transition', {\n props: { name: this.computedTransition },\n }, [this.$createElement('table', { key: this.tableDate }, children)])\n\n const touchDirective = {\n name: 'touch',\n value: {\n left: (e: TouchWrapper) => (e.offsetX < -15) && this.touch(1, calculateTableDate),\n right: (e: TouchWrapper) => (e.offsetX > 15) && this.touch(-1, calculateTableDate),\n },\n }\n\n return this.$createElement('div', {\n staticClass,\n class: {\n 'v-date-picker-table--disabled': this.disabled,\n ...this.themeClasses,\n },\n on: (!this.disabled && this.scrollable) ? {\n wheel: (e: WheelEvent) => this.wheel(e, calculateTableDate),\n } : undefined,\n directives: [touchDirective],\n }, [transition])\n },\n },\n})\n"],"sourceRoot":"","file":"date-picker-table.js"} |