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