devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
139 lines (134 loc) • 5.7 kB
JavaScript
/**
* DevExtreme (cjs/__internal/scheduler/r1/components/base/date_table_cell_base.js)
* Version: 23.2.6
* Build date: Wed May 01 2024
*
* Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DateTableCellBase = exports.DateTableCallBaseDefaultProps = void 0;
var _inferno = require("inferno");
var _inferno2 = require("@devextreme/runtime/inferno");
var _index = require("../../../../core/r1/utils/index");
var _index2 = require("../../utils/index");
var _const = require("../const");
var _cell = require("./cell");
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
_setPrototypeOf(subClass, superClass)
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, p) {
o.__proto__ = p;
return o
};
return _setPrototypeOf(o, p)
}
function _extends() {
_extends = Object.assign ? Object.assign.bind() : function(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key]
}
}
}
return target
};
return _extends.apply(this, arguments)
}
const DateTableCallBaseDefaultProps = _extends(_extends({}, _cell.CellBaseDefaultProps), {
otherMonth: false,
today: false,
firstDayOfMonth: false,
isSelected: false,
isFocused: false
});
exports.DateTableCallBaseDefaultProps = DateTableCallBaseDefaultProps;
const ADD_APPOINTMENT_LABEL = "Add appointment";
let DateTableCellBase = function(_BaseInfernoComponent) {
_inheritsLoose(DateTableCellBase, _BaseInfernoComponent);
function DateTableCellBase() {
var _this;
_this = _BaseInfernoComponent.apply(this, arguments) || this;
_this.dataCellTemplateProps = null;
return _this
}
var _proto = DateTableCellBase.prototype;
_proto.getDataCellTemplateProps = function() {
if (null !== this.dataCellTemplateProps) {
return this.dataCellTemplateProps
}
const {
allDay: allDay,
contentTemplateProps: contentTemplateProps,
endDate: endDate,
groupIndex: groupIndex,
groups: groups,
index: index,
startDate: startDate
} = this.props;
this.dataCellTemplateProps = {
data: _extends({
startDate: startDate,
endDate: endDate,
groups: groups,
groupIndex: groups ? groupIndex : void 0,
text: "",
allDay: !!allDay || void 0
}, null === contentTemplateProps || void 0 === contentTemplateProps ? void 0 : contentTemplateProps.data),
index: index
};
return this.dataCellTemplateProps
};
_proto.componentWillUpdate = function(nextProps) {
if (this.props.allDay !== nextProps.allDay || this.props.contentTemplateProps !== nextProps.contentTemplateProps || this.props.endDate !== nextProps.endDate || this.props.groupIndex !== nextProps.groupIndex || this.props.groups !== nextProps.groups || this.props.index !== nextProps.index || this.props.startDate !== nextProps.startDate) {
this.dataCellTemplateProps = null
}
};
_proto.render = function() {
const {
allDay: allDay,
className: className,
isFocused: isFocused,
isSelected: isSelected,
isFirstGroupCell: isFirstGroupCell,
isLastGroupCell: isLastGroupCell,
dataCellTemplate: dataCellTemplate,
children: children
} = this.props;
const classes = _index2.renderUtils.combineClasses({
"dx-scheduler-cell-sizes-horizontal": true,
"dx-scheduler-cell-sizes-vertical": !allDay,
[_const.DATE_TABLE_CELL_CLASS]: !allDay,
"dx-state-focused": isSelected,
"dx-scheduler-focused-cell": isFocused,
[null !== className && void 0 !== className ? className : ""]: true
});
const ariaLabel = isSelected ? "Add appointment" : void 0;
const dataCellTemplateProps = this.getDataCellTemplateProps();
const DataCellTemplateComponent = (0, _index.getTemplate)(dataCellTemplate);
return (0, _inferno.createComponentVNode)(2, _cell.CellBase, {
isFirstGroupCell: isFirstGroupCell,
isLastGroupCell: isLastGroupCell,
className: classes,
ariaLabel: ariaLabel,
startDate: _cell.CellBaseDefaultProps.startDate,
endDate: _cell.CellBaseDefaultProps.endDate,
index: _cell.CellBaseDefaultProps.index,
children: (0, _inferno.createFragment)([!DataCellTemplateComponent && children, !!DataCellTemplateComponent && DataCellTemplateComponent({
index: dataCellTemplateProps.index,
data: dataCellTemplateProps.data
})], 0)
})
};
return DateTableCellBase
}(_inferno2.BaseInfernoComponent);
exports.DateTableCellBase = DateTableCellBase;
DateTableCellBase.defaultProps = DateTableCallBaseDefaultProps;