UNPKG

devextreme-react

Version:

DevExtreme UI and Visualization Components for React

64 lines (62 loc) 2.21 kB
/*! * devextreme-react * Version: 26.1.3 * Build date: Wed Jun 10 2026 * * Copyright (c) 2012 - 2026 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 */ "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?.[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?.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;