UNPKG

devextreme-react

Version:

DevExtreme React UI and Visualization Components

204 lines (202 loc) • 6.81 kB
/*! * devextreme-react * Version: 24.2.6 * Build date: Mon Mar 17 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 dxFileManager from "devextreme/ui/file_manager"; import { Component as BaseComponent } from "./core/component"; import NestedOption from "./core/nested-option"; const FileManager = memo(forwardRef((props, ref) => { const baseRef = useRef(null); useImperativeHandle(ref, () => ({ instance() { return baseRef.current?.getInstance(); } }), [baseRef.current]); const independentEvents = useMemo(() => (["onContentReady", "onContextMenuItemClick", "onContextMenuShowing", "onDirectoryCreated", "onDirectoryCreating", "onDisposing", "onErrorOccurred", "onFileUploaded", "onFileUploading", "onInitialized", "onItemCopied", "onItemCopying", "onItemDeleted", "onItemDeleting", "onItemDownloading", "onItemMoved", "onItemMoving", "onItemRenamed", "onItemRenaming", "onSelectedFileOpened", "onToolbarItemClick"]), []); const expectedChildren = useMemo(() => ({ contextMenu: { optionName: "contextMenu", isCollectionItem: false }, itemView: { optionName: "itemView", isCollectionItem: false }, notifications: { optionName: "notifications", isCollectionItem: false }, permissions: { optionName: "permissions", isCollectionItem: false }, toolbar: { optionName: "toolbar", isCollectionItem: false }, upload: { optionName: "upload", isCollectionItem: false } }), []); return (React.createElement((BaseComponent), { WidgetClass: dxFileManager, ref: baseRef, independentEvents, expectedChildren, ...props, })); })); const _componentColumn = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "columns", IsCollectionItem: true, }, }); }; const Column = Object.assign(_componentColumn, { componentType: "option", }); const _componentContextMenu = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "contextMenu", ExpectedChildren: { contextMenuItem: { optionName: "items", isCollectionItem: true }, item: { optionName: "items", isCollectionItem: true } }, }, }); }; const ContextMenu = Object.assign(_componentContextMenu, { componentType: "option", }); const _componentContextMenuItem = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "items", IsCollectionItem: true, ExpectedChildren: { item: { optionName: "items", isCollectionItem: true } }, }, }); }; const ContextMenuItem = Object.assign(_componentContextMenuItem, { componentType: "option", }); const _componentDetails = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "details", ExpectedChildren: { column: { optionName: "columns", isCollectionItem: true } }, }, }); }; const Details = Object.assign(_componentDetails, { componentType: "option", }); const _componentFileSelectionItem = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "fileSelectionItems", IsCollectionItem: true, }, }); }; const FileSelectionItem = Object.assign(_componentFileSelectionItem, { componentType: "option", }); const _componentItem = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "items", IsCollectionItem: true, ExpectedChildren: { item: { optionName: "items", isCollectionItem: true } }, }, }); }; const Item = Object.assign(_componentItem, { componentType: "option", }); const _componentItemView = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "itemView", ExpectedChildren: { details: { optionName: "details", isCollectionItem: false } }, }, }); }; const ItemView = Object.assign(_componentItemView, { componentType: "option", }); const _componentNotifications = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "notifications", }, }); }; const Notifications = Object.assign(_componentNotifications, { componentType: "option", }); const _componentPermissions = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "permissions", }, }); }; const Permissions = Object.assign(_componentPermissions, { componentType: "option", }); const _componentToolbar = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "toolbar", ExpectedChildren: { fileSelectionItem: { optionName: "fileSelectionItems", isCollectionItem: true }, 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, }, }); }; const ToolbarItem = Object.assign(_componentToolbarItem, { componentType: "option", }); const _componentUpload = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "upload", }, }); }; const Upload = Object.assign(_componentUpload, { componentType: "option", }); export default FileManager; export { FileManager, Column, ContextMenu, ContextMenuItem, Details, FileSelectionItem, Item, ItemView, Notifications, Permissions, Toolbar, ToolbarItem, Upload };