UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

78 lines (77 loc) 3.5 kB
/** * DevExtreme (esm/__internal/scheduler/appointments/appointment/text_utils.js) * Version: 26.1.3 * Build date: Wed Jun 10 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import messageLocalization from "../../../../common/core/localization/message"; import { isDefined } from "../../../../core/utils/type"; import { formatImplicitSchedulerDate, formatImplicitSchedulerTime } from "../../utils/global_formats"; const localizeDate = date => formatImplicitSchedulerDate(date); const localizeTime = date => formatImplicitSchedulerTime(date); const getDate = (options, propName) => { var _options$timeZoneCalc; const result = options.dataAccessors.get(propName, options.data); if (!result) { return result } const date = new Date(result); const gridDate = null === (_options$timeZoneCalc = options.timeZoneCalculator) || void 0 === _options$timeZoneCalc ? void 0 : _options$timeZoneCalc.createDate(date, "toGrid"); return gridDate ?? date }; const getDateText = options => { const startDate = getDate(options, "startDate"); const endDate = getDate(options, "endDate"); const startDateText = localizeDate(startDate); const endDateText = localizeDate(endDate); const startTimeText = localizeTime(startDate); const endTimeText = localizeTime(endDate); const isAllDay = options.dataAccessors.get("allDay", options.data); const allDayText = messageLocalization.format("dxScheduler-allDay"); if (startDateText === endDateText) { return isAllDay ? `${startDateText}, ${allDayText}` : `${startDateText}, ${startTimeText} - ${endTimeText}` } return isAllDay ? `${startDateText} - ${endDateText}, ${allDayText}` : `${startDateText}, ${startTimeText} - ${endDateText}, ${endTimeText}` }; const getPartsText = _ref => { let { partIndex: partIndex, partTotalCount: partTotalCount } = _ref; return isDefined(partIndex) && partTotalCount > 0 ? ` (${partIndex+1}/${partTotalCount})` : "" }; export const getAriaLabel = options => { const name = options.dataAccessors.get("text", options.data) ?? ""; const dates = getDateText(options); const parts = getPartsText(options); return `${name}: ${dates}${parts}` }; export const getReducedIconTooltip = options => { const tooltipLabel = messageLocalization.format("dxScheduler-editorLabelEndDate"); const endDateText = localizeDate(getDate(options, "endDate")); return `${tooltipLabel}: ${endDateText}` }; const getGroupText = options => { if (!options.groupTexts.length) { return "" } const groupText = options.groupTexts.join(", "); return messageLocalization.format("dxScheduler-appointmentAriaDescription-group", groupText) }; const getResourceText = async options => { const resourceManager = options.getResourceManager(); const list = await resourceManager.getAppointmentResourcesValues(options.data); return list.map(item => `${item.label}: ${item.values.join(", ")}`) }; export const getAriaDescription = async options => { const resources = await getResourceText(options); const text = [getGroupText(options), ...resources, options.allowDelete ? messageLocalization.format("dxScheduler-hotkeysAriaDescription-delete") : null, messageLocalization.format("dxScheduler-hotkeysAriaDescription-homeEnd")].filter(Boolean).join("; "); return text };