@progress/kendo-vue-dateinputs
Version:
12 lines (11 loc) • 3.54 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
*-------------------------------------------------------------------------------------------
*/
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../models/CalendarViewEnum.js"),n=require("../../utils.js"),v=require("@progress/kendo-vue-common");class x{constructor(){this.didCalculate=!1}ensureHeights(){this.calendarHeight===void 0&&this.calculateHeights()}calculateHeights(i){if(!v.canUseDOM)return;const s=n.domContainerFactory("div"),a=n.domContainerFactory("ul"),l=n.domContainerFactory("li"),W=n.domContainerFactory("td"),C=n.domContainerFactory("th"),w=n.domContainerFactory("tr"),D=n.domContainerFactory("tbody"),S=n.domContainerFactory("thead"),b=n.domContainerFactory("table"),V=()=>s(`
<span class="k-calendar-title">March 2017</span>
<span class="k-calendar-today">TODAY</span>
`,"k-calendar-header"),M=()=>b([S([w([C("MO")])])]),f=(e,t)=>new Array(e).fill("1").map(t),O=(e,t=1)=>b([D([w([C("1")])].concat(f(e,()=>w(f(t,c=>W(`<span class="k-link">${c}</span>`))))))]),y=e=>s(e,"k-content k-scrollable"),q=(e,t,c)=>s(c?[V(),M(),y([e,e])]:[V(),y([e,e])],t,{left:"-10000px",position:"absolute"}),$=(()=>{let e;return()=>v.canUseDOM?(e||(e=s([y([a([l("<span>FEB</span>")])])],"k-calendar-navigation",{left:"0px",position:"absolute"})),e):null})(),g=({cells:e,rows:t},c,Y)=>{let p;return()=>v.canUseDOM?(p||(p=q(O(t,e),c,Y)),p):null},d=e=>e.querySelector(".k-scrollable"),m=e=>{const t=d(e);return t.className=`${t.className} k-scrollable-horizontal`,e},H=g({cells:7,rows:6},"k-calendar-view k-calendar-monthview",!0),k=g({cells:5,rows:3},"k-calendar-view k-calendar-yearview",!1),F=g({cells:5,rows:2},"k-calendar-view k-calendar-decadeview",!1),z=()=>m(H()),E=()=>m(k()),U=()=>m(F()),o=e=>parseFloat(window.getComputedStyle(e).height)||e.offsetHeight,h=e=>{const t=window.getComputedStyle(e);return parseFloat(t.width)+parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)||e.offsetWidth},r=e=>e.querySelector("tbody");this.didCalculate=!0,i&&(this.hostContainer=i),this.batch(H(),e=>{const t=r(e);this.calendarHeight=o(e),this.monthViewHeight=o(t),this.headerHeight=o(t.children[0]),this.scrollableContentHeight=o(d(e))}),this.batch(z(),e=>{const t=r(e);this.calendarWidth=h(e),this.monthViewWidth=h(t),this.scrollableContentWidth=h(d(e))}),this.batch(k(),e=>{this.yearViewHeight=o(r(e)),this.scrollableYearContentHeight=o(d(e))}),this.batch(E(),e=>{this.yearViewWidth=h(r(e))}),this.batch(F(),e=>{this.decadeViewHeight=o(r(e)),this.centuryViewHeight=this.decadeViewHeight}),this.batch(U(),e=>{this.decadeViewWidth=h(r(e)),this.centuryViewWidth=this.decadeViewWidth}),this.batch($(),e=>{this.navigationItemHeight=o(e.querySelector("li"))})}viewHeight(i){return this.viewDimension(i,"height")}viewWidth(i){return this.viewDimension(i,"width")}viewDimension(i,s){const a=s==="height"?"ViewHeight":"ViewWidth";switch(i){case u.CalendarViewEnum.month:return this[`month${a}`];case u.CalendarViewEnum.year:return this[`year${a}`];case u.CalendarViewEnum.decade:return this[`decade${a}`];case u.CalendarViewEnum.century:return this[`century${a}`];default:return 1}}batch(i,s){const a=this.hostContainer||document.body,l=a.appendChild(i);s(l),a.removeChild(l)}}exports.DOMService=x;