UNPKG

devextreme-react

Version:

DevExtreme React UI and Visualization Components

64 lines (62 loc) 2.26 kB
/*! * devextreme-react * Version: 25.1.5 * Build date: Wed Sep 03 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 strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ElementType = exports.getOptionInfo = exports.getElementType = void 0; const template_1 = require("../../template"); var ElementType; (function (ElementType) { ElementType[ElementType["Option"] = 0] = "Option"; ElementType[ElementType["Template"] = 1] = "Template"; ElementType[ElementType["Unknown"] = 2] = "Unknown"; })(ElementType || (ElementType = {})); exports.ElementType = ElementType; function getOptionInfo(elementDescriptor, props, parentExpectedChildren) { let name = elementDescriptor.OptionName; let isCollectionItem = elementDescriptor.IsCollectionItem; const expectation = parentExpectedChildren && parentExpectedChildren[name]; if (expectation) { isCollectionItem = expectation.isCollectionItem; if (expectation.optionName) { name = expectation.optionName; } } return { type: ElementType.Option, descriptor: { name, isCollection: !!isCollectionItem, templates: elementDescriptor.TemplateProps || [], initialValuesProps: elementDescriptor.DefaultsProps || {}, predefinedValuesProps: elementDescriptor.PredefinedProps || {}, expectedChildren: elementDescriptor.ExpectedChildren || {}, }, props, }; } exports.getOptionInfo = getOptionInfo; function getElementType(element) { const reactElement = element; if (!reactElement || !reactElement.type) { return ElementType.Unknown; } if (reactElement.type === template_1.Template) { return ElementType.Template; } const nestedComponentMeta = reactElement.type; if (nestedComponentMeta.componentType === 'option') { return ElementType.Option; } return ElementType.Unknown; } exports.getElementType = getElementType;