diff --git a/packages/devextreme/js/__internal/scheduler/m_table_creator.ts b/packages/devextreme/js/__internal/scheduler/m_table_creator.ts deleted file mode 100644 index d38fdba2f3f1..000000000000 --- a/packages/devextreme/js/__internal/scheduler/m_table_creator.ts +++ /dev/null @@ -1,450 +0,0 @@ -import type { Orientation } from '@js/common'; -import domAdapter from '@js/core/dom_adapter'; -import { getPublicElement } from '@js/core/element'; -import { data as elementData } from '@js/core/element_data'; -import type { dxElementWrapper } from '@js/core/renderer'; -import $ from '@js/core/renderer'; -import type { TemplateBase } from '@js/core/templates/template_base'; -import { isFunction } from '@js/core/utils/type'; - -import type { ResourceLoader } from './utils/loader/resource_loader'; -import type { GroupNode } from './utils/resource_manager/types'; - -const ROW_SELECTOR = 'tr'; - -export interface GroupCssClasses { - groupHeaderRowClass?: string; - groupRowClass?: string; - groupHeaderClass: string | ((index: number) => string); - groupHeaderContentClass?: string; -} - -export interface GroupRows { - elements: dxElementWrapper | dxElementWrapper[]; - cellTemplates: (() => dxElementWrapper)[]; -} - -class SchedulerTableCreator { - readonly VERTICAL = 'vertical'; - - readonly HORIZONTAL = 'horizontal'; - - insertAllDayRow(allDayElements, tableBody, index) { - if (allDayElements[index]) { - let row = allDayElements[index].find(ROW_SELECTOR); - - if (!row.length) { - row = $(domAdapter.createElement(ROW_SELECTOR)); - row.append(allDayElements[index].get(0)); - } - - tableBody.appendChild(row.get ? row.get(0) : row); - } - } - - makeTable(options) { - const tableBody = domAdapter.createElement('tbody'); - const templateCallbacks: any[] = []; - let row; - const rowCountInGroup = options.groupCount ? options.rowCount / options.groupCount : options.rowCount; - let allDayElementIndex = 0; - const { allDayElements } = options; - const { groupIndex } = options; - const { rowCount } = options; - - $(options.container).append(tableBody); - - if (allDayElements) { - this.insertAllDayRow(allDayElements, tableBody, 0); - allDayElementIndex++; - } - - for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) { - row = domAdapter.createElement(ROW_SELECTOR); - tableBody.appendChild(row); - - const isLastRowInGroup = (rowIndex + 1) % rowCountInGroup === 0; - - if (options.rowClass) { - row.className = options.rowClass; - } - - for (let columnIndex = 0; columnIndex < options.cellCount; columnIndex++) { - const td = domAdapter.createElement('td'); - row.appendChild(td); - - if (options.cellClass) { - if (isFunction(options.cellClass)) { - td.className = options.cellClass(rowIndex, columnIndex); - } else { - td.className = options.cellClass; - } - } - - let cellDataObject; - let dataKey; - let dataValue; - - if (options.getCellData) { - cellDataObject = options.getCellData(td, rowIndex, columnIndex, groupIndex); - dataKey = cellDataObject.key; - dataValue = cellDataObject.value; - dataKey && elementData(td, dataKey, dataValue); - } - - options.setAdditionalClasses?.($(td), dataValue); - - if (options.cellTemplate && options.cellTemplate.render) { - const additionalTemplateData = options.getTemplateData - ? options.getTemplateData(rowIndex) - : {}; - - const templateOptions = { - model: { - text: options.getCellText ? options.getCellText(rowIndex, columnIndex) : '', - date: options.getCellDate ? options.getCellDate(rowIndex) : undefined, - ...additionalTemplateData, - }, - container: getPublicElement($(td)), - index: rowIndex * options.cellCount + columnIndex, - }; - - if (dataValue) { - if (dataValue.startDate) { - templateOptions.model.startDate = dataValue.startDate; - } - - if (dataValue.endDate) { - templateOptions.model.endDate = dataValue.endDate; - } - - if (dataValue.groups) { - templateOptions.model.groups = dataValue.groups; - } - - if (dataValue.allDay) { - templateOptions.model.allDay = dataValue.allDay; - } - } - - templateCallbacks.push(options.cellTemplate.render.bind(options.cellTemplate, templateOptions)); - } else if (options.getCellText) { - $('