@progress/kendo-vue-dateinputs
Version:
9 lines (8 loc) • 5.56 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue"),l=require("@progress/kendo-date-math"),p=require("@progress/kendo-vue-intl"),m=require("./View.js"),w=require("../../utils.js"),i=require("../models/CalendarViewEnum.js"),r=require("@progress/kendo-vue-common"),k=1,v=5,$=s.defineComponent({name:"KendoViewList",inheritAttrs:!1,inject:{kendoIntlService:{default:null}},props:{allowReverse:Boolean,hasFocusedDate:Boolean,activeView:{type:Number,required:!0},bottomOffset:{type:Number},cell:[String,Function,Object],cellUID:{type:String,required:!0},dates:Array,focusedDate:{type:Date,required:!0},isActive:{type:Boolean,default:void 0},max:{type:Date,required:!0},min:{type:Date,required:!0},selectionRange:Object,showWeekNumbers:{type:Boolean,default:!1},take:{type:Number,default:v},value:{type:[Date,Array,Object]},views:{type:Number,default:k},viewHeight:Number,viewOffset:Number,bus:Object,dom:Object,weekCell:[String,Function,Object],service:Object,tabIndex:Number,shouldScroll:Boolean,onChange:Function,onWeekcellclick:Function,onWeeknameclick:Function,onCellenter:Function,onViewmousedown:Function,onListfocus:Function,onListblur:Function,onListkeydown:Function,onListmousedown:Function},data:function(){return{lastViewsCount:0,valueHasUpdated:!1,shouldScrollValue:!1}},computed:{weekNames(){this._intl=p.provideIntlService(this);const e=w.shiftWeekNames(this._intl.dateFormatNames({nameType:"short",type:"days"}),this._intl.firstDay());return this.weekNumber?[""].concat(e):e},weekNumber(){return!!(this.$props.showWeekNumbers&&this.$props.activeView===i.CalendarViewEnum.month)}},created(){this.lastView=this.$props.activeView,this.lastFocus=this.$props.focusedDate,this.shouldScrollValue=this.$props.shouldScroll},updated(){this.shouldScrollValue=!1,this.lastView=this.$props.activeView,this.$data.lastViewsCount=this.$props.views,this.indexToScroll=void 0},methods:{handleFocus(e){this.$emit("listfocus",e)},handleBlur(e){this.$emit("listblur",e)},handleKeyDown(e){this.$emit("listkeydown",e)},handleVirtualizationMount(e){},calculateHeights(){if(!this.$props.dom)return;const e=this.$props.activeView===i.CalendarViewEnum.month?this.$props.dom.scrollableContentHeight:this.$props.dom.scrollableYearContentHeight;this._bottomOffset=e-this.$props.dom.viewHeight(this.$props.activeView),this._viewOffset=-1*this.$props.dom.headerHeight,this._viewHeight=this.$props.dom.viewHeight(this.$props.activeView)||1},getTake(e,t){return Math.min(t-e,this.$props.take)},handleScrollAction(){},handleTodayClick(e){this.shouldScrollValue=!0,this.handleDateChange(e,!0)},handleMouseDown(e){const t={event:e.event,value:l.cloneDate(e.value),target:this};this.$emit("listmousedown",t)},handleDateChange(e,t=!1){const a={event:e.event,value:l.cloneDate(e.value),target:this,isTodayClick:t};this.$emit("change",a)},handleWeekCellClick(e){this.$emit("weekcellclick",e)},handleWeekNameClick(e,t){const a={value:t,event:e};this.$emit("weeknameclick",a)},handleCellEnter(e){this.$emit("cellenter",e)},rotateSelectionRange(e){if(e.start===null||e.end===null)return e;const t=e.end<e.start;return{start:t?e.end:e.start,end:t?e.start:e.end}}},setup(){return{kendoIntlService:s.inject("kendoIntlService",{})}},mounted(){this._calendarView=this.$refs.calendarView},render(){const e=this.$props.allowReverse?this.rotateSelectionRange(this.$props.selectionRange):this.$props.selectionRange,t=r.classNames("k-calendar-view","k-hstack k-align-items-start k-justify-content-center",{"k-calendar-monthview":this.$props.activeView===i.CalendarViewEnum.month,"k-calendar-yearview":this.$props.activeView===i.CalendarViewEnum.year,"k-calendar-decadeview":this.$props.activeView===i.CalendarViewEnum.decade,"k-calendar-centuryview":this.$props.activeView===i.CalendarViewEnum.century}),a=r.classNames("k-calendar-table"),c=function(o){return s.createVNode("thead",{class:"k-calendar-thead"},[s.createVNode("tr",{class:"k-calendar-tr"},[o.map((n,u)=>s.createVNode("th",{class:"k-calendar-th",key:u,onClick:d=>this.handleWeekNameClick(d,n)},[n]),this)])])},h=function(){const o=this.$props.cellUID;return this.$props.dates.map(function(n){return s.createVNode("table",{role:"grid","aria-label":this.$props.service.title(this.$props.focusedDate),"aria-live":"polite","aria-activedescendant":o+this.$props.focusedDate.getTime(),tabindex:this.$props.tabIndex,class:a,onKeydown:this.handleKeyDown},[this.$props.activeView===i.CalendarViewEnum.month&&c.call(this,this.weekNames),s.createVNode(m.View,{key:n.getTime(),activeView:this.$props.activeView,viewDate:n,min:this.$props.min,max:this.$props.max,cellUID:o,isActive:this.$props.isActive,focusedDate:this.$props.focusedDate,cell:this.$props.cell,selectionRange:e,selectedDate:this.$props.value,showWeekNumbers:this.weekNumber,onChange:this.handleDateChange,onWeekcellclick:this.handleWeekCellClick,onCellenter:this.handleCellEnter,onViewmousedown:this.handleMouseDown,bus:this.$props.bus,service:this.$props.service,weekCell:this.$props.weekCell},null)])},this)};return s.createVNode("div",{style:this.$attrs.style,class:t,onFocusin:this.handleFocus,onFocusout:this.handleBlur},[h.call(this)])}});exports.ViewList=$;