UNPKG

devextreme-react

Version:

DevExtreme React UI and Visualization Components

725 lines (723 loc) • 25.9 kB
/*! * devextreme-react * Version: 25.2.3 * Build date: Fri Dec 12 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", "editing.form.formData"]), []); 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: "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 _componentAIOptions = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "aiOptions", }, }); }; const AIOptions = Object.assign(_componentAIOptions, { componentType: "option", }); const _componentAppointmentDragging = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "appointmentDragging", }, }); }; const AppointmentDragging = Object.assign(_componentAppointmentDragging, { componentType: "option", }); const _componentAsyncRule = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "validationRules", IsCollectionItem: true, PredefinedProps: { type: "async" }, }, }); }; const AsyncRule = Object.assign(_componentAsyncRule, { componentType: "option", }); const _componentButtonItem = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "items", IsCollectionItem: true, ExpectedChildren: { buttonOptions: { optionName: "buttonOptions", isCollectionItem: false } }, PredefinedProps: { itemType: "button" }, }, }); }; const ButtonItem = Object.assign(_componentButtonItem, { componentType: "option", }); const _componentButtonOptions = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "buttonOptions", TemplateProps: [{ tmplOption: "template", render: "render", component: "component" }], }, }); }; const ButtonOptions = Object.assign(_componentButtonOptions, { componentType: "option", }); const _componentColCountByScreen = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "colCountByScreen", }, }); }; const ColCountByScreen = Object.assign(_componentColCountByScreen, { componentType: "option", }); const _componentCompareRule = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "validationRules", IsCollectionItem: true, PredefinedProps: { type: "compare" }, }, }); }; const CompareRule = Object.assign(_componentCompareRule, { componentType: "option", }); const _componentCustomRule = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "validationRules", IsCollectionItem: true, PredefinedProps: { type: "custom" }, }, }); }; const CustomRule = Object.assign(_componentCustomRule, { componentType: "option", }); const _componentEditing = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "editing", ExpectedChildren: { form: { optionName: "form", isCollectionItem: false } }, }, }); }; const Editing = Object.assign(_componentEditing, { componentType: "option", }); const _componentEmailRule = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "validationRules", IsCollectionItem: true, PredefinedProps: { type: "email" }, }, }); }; const EmailRule = Object.assign(_componentEmailRule, { componentType: "option", }); const _componentEmptyItem = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "items", IsCollectionItem: true, PredefinedProps: { itemType: "empty" }, }, }); }; const EmptyItem = Object.assign(_componentEmptyItem, { componentType: "option", }); const _componentForm = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "form", DefaultsProps: { defaultFormData: "formData" }, ExpectedChildren: { ButtonItem: { optionName: "items", isCollectionItem: true }, colCountByScreen: { optionName: "colCountByScreen", isCollectionItem: false }, EmptyItem: { optionName: "items", isCollectionItem: true }, GroupItem: { optionName: "items", isCollectionItem: true }, item: { optionName: "items", isCollectionItem: true }, SimpleItem: { optionName: "items", isCollectionItem: true }, TabbedItem: { optionName: "items", isCollectionItem: true } }, }, }); }; const Form = Object.assign(_componentForm, { componentType: "option", }); const _componentGroupItem = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "items", IsCollectionItem: true, ExpectedChildren: { colCountByScreen: { optionName: "colCountByScreen", isCollectionItem: false } }, TemplateProps: [{ tmplOption: "captionTemplate", render: "captionRender", component: "captionComponent" }, { tmplOption: "template", render: "render", component: "component" }], PredefinedProps: { itemType: "group" }, }, }); }; const GroupItem = Object.assign(_componentGroupItem, { componentType: "option", }); const _componentItem = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "items", IsCollectionItem: true, ExpectedChildren: { aiOptions: { optionName: "aiOptions", isCollectionItem: false }, AsyncRule: { optionName: "validationRules", isCollectionItem: true }, buttonOptions: { optionName: "buttonOptions", isCollectionItem: false }, colCountByScreen: { optionName: "colCountByScreen", isCollectionItem: false }, CompareRule: { optionName: "validationRules", isCollectionItem: true }, CustomRule: { optionName: "validationRules", isCollectionItem: true }, EmailRule: { optionName: "validationRules", isCollectionItem: true }, label: { optionName: "label", isCollectionItem: false }, NumericRule: { optionName: "validationRules", isCollectionItem: true }, options: { optionName: "options", isCollectionItem: false }, PatternRule: { optionName: "validationRules", isCollectionItem: true }, RangeRule: { optionName: "validationRules", isCollectionItem: true }, RequiredRule: { optionName: "validationRules", isCollectionItem: true }, StringLengthRule: { optionName: "validationRules", isCollectionItem: true }, tab: { optionName: "tabs", isCollectionItem: true }, tabPanelOptions: { optionName: "tabPanelOptions", isCollectionItem: false }, validationRule: { optionName: "validationRules", isCollectionItem: true } }, TemplateProps: [{ tmplOption: "tabTemplate", render: "tabRender", component: "tabComponent" }, { tmplOption: "template", render: "render", component: "component" }, { tmplOption: "captionTemplate", render: "captionRender", component: "captionComponent" }, { tmplOption: "menuItemTemplate", render: "menuItemRender", component: "menuItemComponent" }], }, }); }; const Item = Object.assign(_componentItem, { componentType: "option", }); const _componentLabel = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "label", TemplateProps: [{ tmplOption: "template", render: "render", component: "component" }], }, }); }; const Label = Object.assign(_componentLabel, { componentType: "option", }); const _componentNumericRule = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "validationRules", IsCollectionItem: true, PredefinedProps: { type: "numeric" }, }, }); }; const NumericRule = Object.assign(_componentNumericRule, { 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 _componentPatternRule = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "validationRules", IsCollectionItem: true, PredefinedProps: { type: "pattern" }, }, }); }; const PatternRule = Object.assign(_componentPatternRule, { componentType: "option", }); const _componentRangeRule = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "validationRules", IsCollectionItem: true, PredefinedProps: { type: "range" }, }, }); }; const RangeRule = Object.assign(_componentRangeRule, { componentType: "option", }); const _componentRequiredRule = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "validationRules", IsCollectionItem: true, PredefinedProps: { type: "required" }, }, }); }; const RequiredRule = Object.assign(_componentRequiredRule, { 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 _componentSimpleItem = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "items", IsCollectionItem: true, ExpectedChildren: { aiOptions: { optionName: "aiOptions", isCollectionItem: false }, AsyncRule: { optionName: "validationRules", isCollectionItem: true }, CompareRule: { optionName: "validationRules", isCollectionItem: true }, CustomRule: { optionName: "validationRules", isCollectionItem: true }, EmailRule: { optionName: "validationRules", isCollectionItem: true }, label: { optionName: "label", isCollectionItem: false }, NumericRule: { optionName: "validationRules", isCollectionItem: true }, PatternRule: { optionName: "validationRules", isCollectionItem: true }, RangeRule: { optionName: "validationRules", isCollectionItem: true }, RequiredRule: { optionName: "validationRules", isCollectionItem: true }, StringLengthRule: { optionName: "validationRules", isCollectionItem: true }, validationRule: { optionName: "validationRules", isCollectionItem: true } }, TemplateProps: [{ tmplOption: "template", render: "render", component: "component" }], PredefinedProps: { itemType: "simple" }, }, }); }; const SimpleItem = Object.assign(_componentSimpleItem, { componentType: "option", }); const _componentStringLengthRule = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "validationRules", IsCollectionItem: true, PredefinedProps: { type: "stringLength" }, }, }); }; const StringLengthRule = Object.assign(_componentStringLengthRule, { componentType: "option", }); const _componentTab = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "tabs", IsCollectionItem: true, ExpectedChildren: { colCountByScreen: { optionName: "colCountByScreen", isCollectionItem: false } }, TemplateProps: [{ tmplOption: "tabTemplate", render: "tabRender", component: "tabComponent" }, { tmplOption: "template", render: "render", component: "component" }], }, }); }; const Tab = Object.assign(_componentTab, { componentType: "option", }); const _componentTabbedItem = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "items", IsCollectionItem: true, ExpectedChildren: { tab: { optionName: "tabs", isCollectionItem: true }, tabPanelOptions: { optionName: "tabPanelOptions", isCollectionItem: false } }, PredefinedProps: { itemType: "tabbed" }, }, }); }; const TabbedItem = Object.assign(_componentTabbedItem, { componentType: "option", }); const _componentTabPanelOptions = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "tabPanelOptions", DefaultsProps: { defaultItems: "items", defaultSelectedIndex: "selectedIndex", defaultSelectedItem: "selectedItem" }, ExpectedChildren: { item: { optionName: "items", isCollectionItem: true }, tabPanelOptionsItem: { optionName: "items", isCollectionItem: true } }, TemplateProps: [{ tmplOption: "itemTemplate", render: "itemRender", component: "itemComponent" }, { tmplOption: "itemTitleTemplate", render: "itemTitleRender", component: "itemTitleComponent" }], }, }); }; const TabPanelOptions = Object.assign(_componentTabPanelOptions, { componentType: "option", }); const _componentTabPanelOptionsItem = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "items", IsCollectionItem: true, TemplateProps: [{ tmplOption: "tabTemplate", render: "tabRender", component: "tabComponent" }, { tmplOption: "template", render: "render", component: "component" }], }, }); }; const TabPanelOptionsItem = Object.assign(_componentTabPanelOptionsItem, { 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 _componentValidationRule = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "validationRules", IsCollectionItem: true, PredefinedProps: { type: "required" }, }, }); }; const ValidationRule = Object.assign(_componentValidationRule, { 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: "resourceCellTemplate", render: "resourceCellRender", component: "resourceCellComponent" }, { tmplOption: "timeCellTemplate", render: "timeCellRender", component: "timeCellComponent" }], }, }); }; const View = Object.assign(_componentView, { componentType: "option", }); export default Scheduler; export { Scheduler, AIOptions, AppointmentDragging, AsyncRule, ButtonItem, ButtonOptions, ColCountByScreen, CompareRule, CustomRule, Editing, EmailRule, EmptyItem, Form, GroupItem, Item, Label, NumericRule, Options, OptionsItem, PatternRule, RangeRule, RequiredRule, Resource, Scrolling, SimpleItem, StringLengthRule, Tab, TabbedItem, TabPanelOptions, TabPanelOptionsItem, Toolbar, ToolbarItem, ValidationRule, View };