@semcore/utils
Advanced tools
Comparing version 3.14.0 to 3.14.1
@@ -5,3 +5,3 @@ # Changelog | ||
## [3.14.0] - 2020-04-24 | ||
## [3.14.1] - 2020-04-24 | ||
@@ -8,0 +8,0 @@ ### Added |
@@ -1,4 +0,2 @@ | ||
/// <reference types="react" /> | ||
import React from 'react'; | ||
declare function findComponent(Children: any, names: any): string | number | {} | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)>) | (new (props: any) => React.Component<any, any, any>)> | React.ReactNodeArray | React.ReactPortal; | ||
declare function findComponent(Children: any, names: any): any; | ||
export { findComponent as default }; |
@@ -15,4 +15,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
function findComponent(Children, names) { | ||
return _react["default"].Children.toArray((0, _getOriginChildren["default"])(Children)).find(function (child) { | ||
var children = Children[_core.CHILDREN_COMPONENT] ? (0, _getOriginChildren["default"])(Children) : Children; | ||
return _react["default"].Children.toArray(children).find(function (child) { | ||
if (_react["default"].isValidElement(child)) { | ||
if (child.type === _react["default"].Fragment) { | ||
return findComponent(child.props.children, names); | ||
} | ||
return !!(child.type[_core.INHERITED_NAME] || []).find(function (name) { | ||
@@ -19,0 +24,0 @@ return names.includes(name); |
@@ -24,3 +24,3 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
// @ts-ignore | ||
var version = "3.14.0"; | ||
var version = "3.14.1"; | ||
sh = document.createElement('style'); | ||
@@ -27,0 +27,0 @@ sh.setAttribute('data-ui-v', version); |
{ | ||
"name": "@semcore/utils", | ||
"description": "SEMRush Utils Component", | ||
"version": "3.14.0", | ||
"version": "3.14.1", | ||
"author": "Roman Lysov <r.lysov@semrush.com>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
import React from 'react'; | ||
import { INHERITED_NAME } from '@semcore/core'; | ||
import { CHILDREN_COMPONENT, INHERITED_NAME } from '@semcore/core'; | ||
import getOriginChildren from './getOriginChildren'; | ||
function findComponent(Children, names) { | ||
return React.Children.toArray(getOriginChildren(Children)).find((child) => { | ||
const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children; | ||
return React.Children.toArray(children).find((child) => { | ||
if (React.isValidElement(child)) { | ||
if (child.type === React.Fragment) { | ||
return findComponent(child.props.children, names); | ||
} | ||
return !!(child.type[INHERITED_NAME] || []).find((name) => names.includes(name)); | ||
@@ -9,0 +13,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
216081
2962