UNPKG

@razorpay/blade

Version:

The Design System that powers Razorpay

29 lines (23 loc) 1.44 kB
import React__default from 'react'; /* eslint-disable no-restricted-properties */ /* eslint-disable @typescript-eslint/no-explicit-any */ /** * Gets the `componentId` prop of React component if it exists. */ var getComponentId = function getComponentId(component) { var _component$props, _component$props2, _component$props2$ori, _component$type; if (! /*#__PURE__*/React__default.isValidElement(component)) return null; // Storybook wraps MDX components in a wrapper component, so we need to get componentId from originalType if (component !== null && component !== void 0 && (_component$props = component.props) !== null && _component$props !== void 0 && _component$props.mdxType && component !== null && component !== void 0 && (_component$props2 = component.props) !== null && _component$props2 !== void 0 && (_component$props2$ori = _component$props2.originalType) !== null && _component$props2$ori !== void 0 && _component$props2$ori.componentId) { return component.props.originalType.componentId; } return (_component$type = component.type) === null || _component$type === void 0 ? void 0 : _component$type.componentId; }; /** * Checks if the `component` matches the `componentId` */ var isValidAllowedChildren = function isValidAllowedChildren(component, id) { return getComponentId(component) === id; }; export { getComponentId, isValidAllowedChildren }; //# sourceMappingURL=isValidAllowedChildren.js.map