{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "scheduler-external-drag-and-drop",
  "framework": "react",
  "type": "registry:component",
  "component": "Scheduler",
  "variant": "external-drag-and-drop",
  "dependencies": [
    "@syncfusion/ej2-navigations",
    "@syncfusion/ej2-react-navigations",
    "@syncfusion/ej2-react-schedule"
  ],
  "description": "Scheduler accepts drag-and-drop from an external tree view into its time slots.",
  "meta": {
    "essentialStudioRelease": "2026 Volume 3 (v35.1.37)",
    "license": "commercial-or-community",
    "licenseNote": "The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md",
    "requiresLicenseKey": true,
    "requiresServerEndpoint": false,
    "platformIndex": "https://ai.syncfusion.com/react/llms.txt",
    "skillPack": "syncfusion/react-ui-components-skills",
    "docs": "https://ai.syncfusion.com/gallery/react/js/scheduler-external-drag-and-drop.md"
  },
  "files": [
    {
      "target": "src/components/scheduler-external-drag-and-drop/Scheduler.jsx",
      "content": "import { useRef } from 'react';\nimport { ScheduleComponent, ResourcesDirective, ResourceDirective, ViewsDirective, ViewDirective, Inject, TimelineViews, Resize, DragAndDrop, TimelineMonth } from '@syncfusion/ej2-react-schedule';\nimport { extend, closest, remove, addClass } from '@syncfusion/ej2-base';\nimport { TreeViewComponent } from '@syncfusion/ej2-react-navigations';\nimport { waitingList, hospitalData } from '../datasource/scheduler-data';\n\nconst SAMPLE_CSS = `\n.drag-sample-wrapper {\n  display: -ms-flexbox;\n  display: flex;\n}\n.schedule-container {\n  padding-right: 10px;\n  width: 100%;\n}\n.title-container {\n  padding-bottom: 10px;\n}\n.title-text {\n  font-size: 18px;\n  margin: 0px;\n  font-weight: bold;\n  text-align: center;\n  line-height: 1.1;\n}\n.treeview-external-drag #waiting {\n  height: 100%;\n  padding: 0;\n}\n.treeview-external-drag #waitdetails {\n  width: 95%;\n  float: left;\n  height: 100%;\n  padding: 0;\n}\n.treeview-external-drag #waitlist {\n  width: 100%;\n  height: 50%;\n  font-weight: bold;\n  font-family: \"Segoe UI\";\n  font-size: 12px;\n  padding: 5px 0 0 10px;\n  overflow: hidden;\n  text-overflow: ellipsis;\n}\n.treeview-external-drag #waitcategory {\n  height: 50%;\n  font-family: \"Segoe UI\";\n  font-size: 10px;\n  opacity: 0.6;\n  padding-left: 10px;\n  padding-top: 5px;\n  overflow: hidden;\n  text-overflow: ellipsis;\n}\n.treeview-external-drag .e-list-text, .treeview-external-drag.e-rtl .e-list-text, .e-bigger .treeview-external-drag .e-list-text, .e-bigger .treeview-external-drag.e-rtl .e-list-text {\n  border: 0.5px solid #E1E7EC;\n  height: 50px;\n  line-height: 15px !important;\n  padding: 0 5px;\n  width: 220px;\n}\n.treeview-external-drag .e-list-parent, .treeview-external-drag.e-rtl .e-list-parent, .e-bigger .treeview-external-drag .e-list-parent, .e-bigger .treeview-external-drag.e-rtl .e-list-parent {\n  height: 100%;\n  padding: 0 2px;\n}\n.treeview-external-drag .e-list-item, .e-bigger .treeview-external-drag .e-list-item {\n  height: 100%;\n  padding: 0 0 5px 0;\n}\n.treeview-external-drag .e-fullrow, .e-bigger .treeview-external-drag .e-fullrow {\n  height: 55px;\n}\n.treeview-external-drag .e-list-item.e-hover>.e-fullrow, .treeview-external-drag .e-list-item.e-active>.e-fullrow, .treeview-external-drag .e-list-item.e-active.e-hover>.e-fullrow, .e-bigger .treeview-external-drag .e-list-item.e-hover>.e-fullrow, .e-bigger .treeview-external-drag .e-list-item.e-active>.e-fullrow, .e-bigger .treeview-external-drag .e-list-item.e-active.e-hover>.e-fullrow {\n  background-color: transparent;\n  border-color: transparent;\n  box-shadow: none !important;\n}\n.treeview-external-drag .e-text-content, .e-bigger .treeview-external-drag .e-text-content, .treeview-external-drag.e-rtl .e-text-content, .e-bigger .treeview-external-drag.e-rtl .e-text-content {\n  padding: 0;\n  background-color: inherit;\n}\n.e-drag-item.e-treeview.treeview-external-drag, .e-bigger .e-drag-item.e-treeview.treeview-external-drag {\n  padding: 0 !important;\n}\n.e-device-hover {\n  background-color: #e0e0e0 !important;\n}\n.e-disble-not-allowed {\n  cursor: unset !important;\n}\n.e-drag-item.treeview-external-drag .e-icon-expandable {\n  display: none;\n}\n`;\n\n/**\n * schedule resources group-editing sample\n */\nconst ExternalDragDrop = () => {\n    let scheduleObj = useRef(null);\n    let treeObj = useRef(null);\n    let isTreeItemDropped = false;\n    let draggedItemId = '';\n    const allowDragAndDrops = true;\n    const fields = { dataSource: waitingList, id: 'Id', text: 'Name' };\n    const data = extend([], hospitalData, undefined, true);\n    const departmentData = [\n        { Text: 'GENERAL', Id: 1, Color: '#bbdc00' },\n        { Text: 'DENTAL', Id: 2, Color: '#9e5fff' }\n    ];\n    const consultantData = [\n        { Text: 'Alice', Id: 1, GroupId: 1, Color: '#bbdc00', Designation: 'Cardiologist' },\n        { Text: 'Nancy', Id: 2, GroupId: 2, Color: '#9e5fff', Designation: 'Orthodontist' },\n        { Text: 'Robert', Id: 3, GroupId: 1, Color: '#bbdc00', Designation: 'Optometrist' },\n        { Text: 'Robson', Id: 4, GroupId: 2, Color: '#9e5fff', Designation: 'Periodontist' },\n        { Text: 'Laura', Id: 5, GroupId: 1, Color: '#bbdc00', Designation: 'Orthopedic' },\n        { Text: 'Margaret', Id: 6, GroupId: 2, Color: '#9e5fff', Designation: 'Endodontist' }\n    ];\n    const getConsultantName = (value) => {\n        const textField = value.resource?.textField;\n        return value.resourceData?.[textField ?? ''];\n    };\n    const getConsultantImage = (value) => {\n        return getConsultantName(value).toLowerCase();\n    };\n    const getConsultantDesignation = (value) => {\n        return value.resourceData.Designation;\n    };\n    const resourceHeaderTemplate = (props) => {\n        return (<div className=\"template-wrap\">\n        <div className=\"specialist-category\">\n          <div className={\"specialist-image \" + getConsultantImage(props)}></div>\n          <div className=\"specialist-name\"> {getConsultantName(props)}</div>\n          <div className=\"specialist-designation\">{getConsultantDesignation(props)}</div>\n        </div>\n      </div>);\n    };\n    const treeTemplate = (props) => {\n        return (<div id=\"waiting\">\n        <div id=\"waitdetails\">\n          <div id=\"waitlist\">{props.Name}</div>\n          <div id=\"waitcategory\">{props.DepartmentName} - {props.Description}</div>\n        </div>\n      </div>);\n    };\n    const onItemSelecting = (args) => {\n        args.cancel = true;\n    };\n    const onTreeDrag = (event) => {\n        if (scheduleObj.current?.isAdaptive) {\n            let classElement = scheduleObj.current.element.querySelector('.e-device-hover');\n            if (classElement) {\n                classElement.classList.remove('e-device-hover');\n            }\n            if (event.target.classList.contains('e-work-cells')) {\n                addClass([event.target], 'e-device-hover');\n            }\n        }\n    };\n    const onActionBegin = (event) => {\n        if (event.requestType === 'eventCreate' && isTreeItemDropped && treeObj.current) {\n            let treeViewData = treeObj.current.fields.dataSource;\n            const filteredPeople = treeViewData.filter((item) => item.Id !== parseInt(draggedItemId, 10));\n            treeObj.current.fields.dataSource = filteredPeople;\n            let elements = document.querySelectorAll('.e-drag-item.treeview-external-drag');\n            for (let i = 0; i < elements.length; i++) {\n                remove(elements[i]);\n            }\n        }\n    };\n    const onTreeDragStop = (event) => {\n        let treeElement = closest(event.target, '.e-treeview');\n        let classElement = scheduleObj.current?.element.querySelector('.e-device-hover');\n        if (classElement) {\n            classElement.classList.remove('e-device-hover');\n        }\n        if (!treeElement) {\n            event.cancel = true;\n            let scheduleElement = closest(event.target, '.e-content-wrap');\n            if (scheduleElement && treeObj.current && scheduleObj.current) {\n                let treeviewData = treeObj.current.fields.dataSource;\n                if (event.target.classList.contains('e-work-cells')) {\n                    const filteredData = treeviewData.filter((item) => item.Id === parseInt(event.draggedNodeData.id, 10));\n                    let cellData = scheduleObj.current.getCellDetails(event.target);\n                    let resourceDetails = scheduleObj.current.getResourcesByIndex(cellData.groupIndex ?? 0);\n                    let eventData = {\n                        Name: filteredData[0].Name,\n                        StartTime: cellData.startTime,\n                        EndTime: cellData.endTime,\n                        IsAllDay: cellData.isAllDay,\n                        Description: filteredData[0].Description,\n                        DepartmentID: resourceDetails.resourceData.GroupId,\n                        ConsultantID: resourceDetails.resourceData.Id\n                    };\n                    scheduleObj.current.openEditor(eventData, 'Add', true);\n                    isTreeItemDropped = true;\n                    draggedItemId = event.draggedNodeData.id;\n                }\n            }\n        }\n        document.body.classList.remove('e-disble-not-allowed');\n    };\n    const onTreeDragStart = () => {\n        document.body.classList.add('e-disble-not-allowed');\n    };\n    return (<div>\n        <style>{SAMPLE_CSS}</style>\n        <div className='schedule-control-section'>\n      <div className='col-lg-12 control-section'>\n        <div className='control-wrapper drag-sample-wrapper'>\n          <div className=\"schedule-container\">\n            <div className=\"title-container\">\n              <h1 className=\"title-text\">Doctor's Appointments</h1>\n            </div>\n            <ScheduleComponent ref={scheduleObj} cssClass='schedule-drag-drop' width='100%' height='650px' selectedDate={new Date(2021, 7, 2)} currentView='TimelineDay' resourceHeaderTemplate={resourceHeaderTemplate} eventSettings={{ dataSource: data, fields: { subject: { title: 'Patient Name', name: 'Name' }, startTime: { title: \"From\", name: \"StartTime\" }, endTime: { title: \"To\", name: \"EndTime\" }, description: { title: 'Reason', name: 'Description' } } }} group={{ enableCompactView: false, resources: ['Departments', 'Consultants'] }} actionBegin={onActionBegin}>\n              <ResourcesDirective>\n                <ResourceDirective field='DepartmentID' title='Department' name='Departments' allowMultiple={false} dataSource={departmentData} textField='Text' idField='Id' colorField='Color'/>\n                <ResourceDirective field='ConsultantID' title='Consultant' name='Consultants' allowMultiple={false} dataSource={consultantData} textField='Text' idField='Id' groupIDField=\"GroupId\" colorField='Color'/>\n              </ResourcesDirective>\n              <ViewsDirective>\n                <ViewDirective option='TimelineDay'/>\n                <ViewDirective option='TimelineMonth'/>\n              </ViewsDirective>\n              <Inject services={[TimelineViews, TimelineMonth, Resize, DragAndDrop]}/>\n            </ScheduleComponent>\n          </div>\n          <div className=\"treeview-container\">\n            <div className=\"title-container\">\n              <h1 className=\"title-text\">Waiting List</h1>\n            </div>\n            <TreeViewComponent ref={treeObj} cssClass='treeview-external-drag' dragArea=\".drag-sample-wrapper\" nodeTemplate={treeTemplate} fields={fields} nodeDragStop={onTreeDragStop} nodeSelecting={onItemSelecting} nodeDragging={onTreeDrag} nodeDragStart={onTreeDragStart} allowDragAndDrop={allowDragAndDrops}/>\n          </div>\n        </div>\n      </div>\n    </div>\n    </div>\n    );\n};\nexport default ExternalDragDrop;\n"
    }
  ]
}