UNPKG

devextreme-react

Version:

DevExtreme React UI and Visualization Components

59 lines (57 loc) 2.06 kB
/*! * devextreme-react * Version: 25.2.3 * Build date: Fri Dec 12 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 */ import { Template as TemplateComponent } from '../../template'; var ElementType; (function (ElementType) { ElementType[ElementType["Option"] = 0] = "Option"; ElementType[ElementType["Template"] = 1] = "Template"; ElementType[ElementType["Unknown"] = 2] = "Unknown"; })(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, }; } function getElementType(element) { const reactElement = element; if (!reactElement?.type) { return ElementType.Unknown; } if (reactElement.type === TemplateComponent) { return ElementType.Template; } const nestedComponentMeta = reactElement.type; if (nestedComponentMeta.componentType === 'option') { return ElementType.Option; } return ElementType.Unknown; } export { getElementType, getOptionInfo, ElementType, };