devextreme-react
Version:
DevExtreme React UI and Visualization Components
157 lines (155 loc) • 5.64 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";
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SearchEditorOptions = exports.Options = exports.Item = exports.Button = exports.TreeView = void 0;
const React = __importStar(require("react"));
const react_1 = require("react");
const tree_view_1 = __importDefault(require("devextreme/ui/tree_view"));
const component_1 = require("./core/component");
const nested_option_1 = __importDefault(require("./core/nested-option"));
const TreeView = (0, react_1.memo)((0, react_1.forwardRef)((props, ref) => {
const baseRef = (0, react_1.useRef)(null);
(0, react_1.useImperativeHandle)(ref, () => ({
instance() {
return baseRef.current?.getInstance();
}
}), [baseRef.current]);
const subscribableOptions = (0, react_1.useMemo)(() => (["items"]), []);
const independentEvents = (0, react_1.useMemo)(() => (["onContentReady", "onDisposing", "onInitialized", "onItemClick", "onItemCollapsed", "onItemContextMenu", "onItemExpanded", "onItemHold", "onItemRendered", "onSelectAllValueChanged"]), []);
const defaults = (0, react_1.useMemo)(() => ({
defaultItems: "items",
}), []);
const expectedChildren = (0, react_1.useMemo)(() => ({
item: { optionName: "items", isCollectionItem: true },
searchEditorOptions: { optionName: "searchEditorOptions", isCollectionItem: false }
}), []);
const templateProps = (0, react_1.useMemo)(() => ([
{
tmplOption: "itemTemplate",
render: "itemRender",
component: "itemComponent"
},
]), []);
return (React.createElement((component_1.Component), {
WidgetClass: tree_view_1.default,
ref: baseRef,
subscribableOptions,
independentEvents,
defaults,
expectedChildren,
templateProps,
...props,
}));
}));
exports.TreeView = TreeView;
const _componentButton = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "buttons",
IsCollectionItem: true,
ExpectedChildren: {
options: { optionName: "options", isCollectionItem: false }
},
},
});
};
const Button = Object.assign(_componentButton, {
componentType: "option",
});
exports.Button = Button;
const _componentItem = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "items",
IsCollectionItem: true,
ExpectedChildren: {
item: { optionName: "items", isCollectionItem: true }
},
TemplateProps: [{
tmplOption: "template",
render: "render",
component: "component"
}],
},
});
};
const Item = Object.assign(_componentItem, {
componentType: "option",
});
exports.Item = Item;
const _componentOptions = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "options",
TemplateProps: [{
tmplOption: "template",
render: "render",
component: "component"
}],
},
});
};
const Options = Object.assign(_componentOptions, {
componentType: "option",
});
exports.Options = Options;
const _componentSearchEditorOptions = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "searchEditorOptions",
DefaultsProps: {
defaultValue: "value"
},
ExpectedChildren: {
button: { optionName: "buttons", isCollectionItem: true }
},
},
});
};
const SearchEditorOptions = Object.assign(_componentSearchEditorOptions, {
componentType: "option",
});
exports.SearchEditorOptions = SearchEditorOptions;
exports.default = TreeView;