devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
66 lines (65 loc) • 2.51 kB
JavaScript
/**
* DevExtreme (cjs/__internal/scheduler/__tests__/__mock__/model/appointment.js)
* Version: 25.2.7
* Build date: Tue May 05 2026
*
* Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createAppointmentModel = void 0;
const EMPTY_POSITION = {
top: 0,
left: 0,
width: 0,
height: 0
};
const getColor = appointment => appointment.style.backgroundColor;
const getAgendaColor = appointment => {
const marker = appointment.querySelector(".dx-scheduler-agenda-appointment-marker");
return getColor(marker)
};
const getText = element => {
var _element$querySelecto;
return (null === element || void 0 === element || null === (_element$querySelecto = element.querySelector(".dx-scheduler-appointment-title")) || void 0 === _element$querySelecto ? void 0 : _element$querySelecto.textContent) ?? ""
};
const getDisplayDate = element => {
var _element$querySelecto2;
return (null === element || void 0 === element || null === (_element$querySelecto2 = element.querySelector(".dx-scheduler-appointment-content-date")) || void 0 === _element$querySelecto2 ? void 0 : _element$querySelecto2.textContent) ?? ""
};
const getGeometry = element => {
if (!element) {
return EMPTY_POSITION
}
const match = /translate\(([0-9.]*)px, ([0-9.]*)px\)/.exec(element.style.transform);
if (!match) {
return EMPTY_POSITION
}
return {
top: parseInt(match[2], 10),
left: parseInt(match[1], 10),
width: parseInt(element.style.width, 10),
height: parseInt(element.style.height, 10)
}
};
const createAppointmentModel = element => ({
element: element,
getText: () => getText(element),
getDisplayDate: () => getDisplayDate(element),
getAriaLabel: () => (null === element || void 0 === element ? void 0 : element.getAttribute("aria-label")) ?? "",
getGeometry: () => getGeometry(element),
getColor(view) {
if (!element) {
return
}
return "agenda" === view ? getAgendaColor(element) : getColor(element)
},
getSnapshot: () => Object.assign({
text: getText(element),
date: getDisplayDate(element)
}, getGeometry(element))
});
exports.createAppointmentModel = createAppointmentModel;