devextreme-react
Version:
DevExtreme React UI and Visualization Components
293 lines (291 loc) • 10.3 kB
JavaScript
/*!
* devextreme-react
* Version: 25.1.5
* Build date: Wed Sep 03 2025
*
* Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file in the root of the project for details.
*
* https://github.com/DevExpress/devextreme-react
*/
"use client";
import * as React from "react";
import { memo, forwardRef, useImperativeHandle, useRef, useMemo } from "react";
import dxScheduler from "devextreme/ui/scheduler";
import { Component as BaseComponent } from "./core/component";
import NestedOption from "./core/nested-option";
const Scheduler = memo(forwardRef((props, ref) => {
const baseRef = useRef(null);
useImperativeHandle(ref, () => ({
instance() {
return baseRef.current?.getInstance();
}
}), []);
const subscribableOptions = useMemo(() => (["currentDate", "currentView"]), []);
const independentEvents = useMemo(() => (["onAppointmentAdded", "onAppointmentAdding", "onAppointmentClick", "onAppointmentContextMenu", "onAppointmentDblClick", "onAppointmentDeleted", "onAppointmentDeleting", "onAppointmentFormOpening", "onAppointmentRendered", "onAppointmentTooltipShowing", "onAppointmentUpdated", "onAppointmentUpdating", "onCellClick", "onCellContextMenu", "onContentReady", "onDisposing", "onInitialized"]), []);
const defaults = useMemo(() => ({
defaultCurrentDate: "currentDate",
defaultCurrentView: "currentView",
}), []);
const expectedChildren = useMemo(() => ({
appointmentDragging: { optionName: "appointmentDragging", isCollectionItem: false },
editing: { optionName: "editing", isCollectionItem: false },
resource: { optionName: "resources", isCollectionItem: true },
scrolling: { optionName: "scrolling", isCollectionItem: false },
toolbar: { optionName: "toolbar", isCollectionItem: false },
view: { optionName: "views", isCollectionItem: true }
}), []);
const templateProps = useMemo(() => ([
{
tmplOption: "appointmentCollectorTemplate",
render: "appointmentCollectorRender",
component: "appointmentCollectorComponent"
},
{
tmplOption: "appointmentTemplate",
render: "appointmentRender",
component: "appointmentComponent"
},
{
tmplOption: "appointmentTooltipTemplate",
render: "appointmentTooltipRender",
component: "appointmentTooltipComponent"
},
{
tmplOption: "dataCellTemplate",
render: "dataCellRender",
component: "dataCellComponent"
},
{
tmplOption: "dateCellTemplate",
render: "dateCellRender",
component: "dateCellComponent"
},
{
tmplOption: "dropDownAppointmentTemplate",
render: "dropDownAppointmentRender",
component: "dropDownAppointmentComponent"
},
{
tmplOption: "resourceCellTemplate",
render: "resourceCellRender",
component: "resourceCellComponent"
},
{
tmplOption: "timeCellTemplate",
render: "timeCellRender",
component: "timeCellComponent"
},
]), []);
return (React.createElement((BaseComponent), {
WidgetClass: dxScheduler,
ref: baseRef,
subscribableOptions,
independentEvents,
defaults,
expectedChildren,
templateProps,
...props,
}));
}));
const _componentAppointmentDragging = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "appointmentDragging",
},
});
};
const AppointmentDragging = Object.assign(_componentAppointmentDragging, {
componentType: "option",
});
const _componentEditing = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "editing",
},
});
};
const Editing = Object.assign(_componentEditing, {
componentType: "option",
});
const _componentItem = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "items",
IsCollectionItem: true,
ExpectedChildren: {
options: { optionName: "options", isCollectionItem: false }
},
TemplateProps: [{
tmplOption: "menuItemTemplate",
render: "menuItemRender",
component: "menuItemComponent"
}, {
tmplOption: "template",
render: "render",
component: "component"
}],
},
});
};
const Item = Object.assign(_componentItem, {
componentType: "option",
});
const _componentOptions = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "options",
DefaultsProps: {
defaultSelectedItemKeys: "selectedItemKeys",
defaultSelectedItems: "selectedItems"
},
ExpectedChildren: {
item: { optionName: "items", isCollectionItem: true },
optionsItem: { optionName: "items", isCollectionItem: true }
},
TemplateProps: [{
tmplOption: "buttonTemplate",
render: "buttonRender",
component: "buttonComponent"
}],
},
});
};
const Options = Object.assign(_componentOptions, {
componentType: "option",
});
const _componentOptionsItem = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "items",
IsCollectionItem: true,
TemplateProps: [{
tmplOption: "template",
render: "render",
component: "component"
}],
},
});
};
const OptionsItem = Object.assign(_componentOptionsItem, {
componentType: "option",
});
const _componentResource = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "resources",
IsCollectionItem: true,
},
});
};
const Resource = Object.assign(_componentResource, {
componentType: "option",
});
const _componentScrolling = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "scrolling",
},
});
};
const Scrolling = Object.assign(_componentScrolling, {
componentType: "option",
});
const _componentToolbar = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "toolbar",
ExpectedChildren: {
item: { optionName: "items", isCollectionItem: true },
toolbarItem: { optionName: "items", isCollectionItem: true }
},
},
});
};
const Toolbar = Object.assign(_componentToolbar, {
componentType: "option",
});
const _componentToolbarItem = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "items",
IsCollectionItem: true,
ExpectedChildren: {
options: { optionName: "options", isCollectionItem: false }
},
TemplateProps: [{
tmplOption: "menuItemTemplate",
render: "menuItemRender",
component: "menuItemComponent"
}, {
tmplOption: "template",
render: "render",
component: "component"
}],
},
});
};
const ToolbarItem = Object.assign(_componentToolbarItem, {
componentType: "option",
});
const _componentView = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "views",
IsCollectionItem: true,
ExpectedChildren: {
scrolling: { optionName: "scrolling", isCollectionItem: false }
},
TemplateProps: [{
tmplOption: "appointmentCollectorTemplate",
render: "appointmentCollectorRender",
component: "appointmentCollectorComponent"
}, {
tmplOption: "appointmentTemplate",
render: "appointmentRender",
component: "appointmentComponent"
}, {
tmplOption: "appointmentTooltipTemplate",
render: "appointmentTooltipRender",
component: "appointmentTooltipComponent"
}, {
tmplOption: "dataCellTemplate",
render: "dataCellRender",
component: "dataCellComponent"
}, {
tmplOption: "dateCellTemplate",
render: "dateCellRender",
component: "dateCellComponent"
}, {
tmplOption: "dropDownAppointmentTemplate",
render: "dropDownAppointmentRender",
component: "dropDownAppointmentComponent"
}, {
tmplOption: "resourceCellTemplate",
render: "resourceCellRender",
component: "resourceCellComponent"
}, {
tmplOption: "timeCellTemplate",
render: "timeCellRender",
component: "timeCellComponent"
}],
},
});
};
const View = Object.assign(_componentView, {
componentType: "option",
});
export default Scheduler;
export { Scheduler, AppointmentDragging, Editing, Item, Options, OptionsItem, Resource, Scrolling, Toolbar, ToolbarItem, View };