devextreme-react
Version:
DevExtreme React UI and Visualization Components
113 lines (111 loc) • 3.5 kB
JavaScript
/*!
* 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 dxResponsiveBox from "devextreme/ui/responsive_box";
import { Component as BaseComponent } from "./core/component";
import NestedOption from "./core/nested-option";
const ResponsiveBox = memo(forwardRef((props, ref) => {
const baseRef = useRef(null);
useImperativeHandle(ref, () => ({
instance() {
return baseRef.current?.getInstance();
}
}), [baseRef.current]);
const subscribableOptions = useMemo(() => (["items"]), []);
const independentEvents = useMemo(() => (["onContentReady", "onDisposing", "onInitialized", "onItemClick", "onItemContextMenu", "onItemHold", "onItemRendered"]), []);
const defaults = useMemo(() => ({
defaultItems: "items",
}), []);
const expectedChildren = useMemo(() => ({
col: { optionName: "cols", isCollectionItem: true },
item: { optionName: "items", isCollectionItem: true },
row: { optionName: "rows", isCollectionItem: true }
}), []);
const templateProps = useMemo(() => ([
{
tmplOption: "itemTemplate",
render: "itemRender",
component: "itemComponent"
},
]), []);
return (React.createElement((BaseComponent), {
WidgetClass: dxResponsiveBox,
ref: baseRef,
subscribableOptions,
independentEvents,
defaults,
expectedChildren,
templateProps,
...props,
}));
}));
const _componentCol = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "cols",
IsCollectionItem: true,
},
});
};
const Col = Object.assign(_componentCol, {
componentType: "option",
});
const _componentItem = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "items",
IsCollectionItem: true,
ExpectedChildren: {
location: { optionName: "location", isCollectionItem: true }
},
TemplateProps: [{
tmplOption: "template",
render: "render",
component: "component"
}],
},
});
};
const Item = Object.assign(_componentItem, {
componentType: "option",
});
const _componentLocation = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "location",
IsCollectionItem: true,
},
});
};
const Location = Object.assign(_componentLocation, {
componentType: "option",
});
const _componentRow = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "rows",
IsCollectionItem: true,
},
});
};
const Row = Object.assign(_componentRow, {
componentType: "option",
});
export default ResponsiveBox;
export { ResponsiveBox, Col, Item, Location, Row };