src/js/lib/react.js
function parseActiveChildren(values, active) {
	let activeChild = false;

	const activeValues = values.map(function (val) {
		const childrenTraversed = (val.children && parseActiveChildren(val.children, active));
		const isActive = val.value === active || Boolean(childrenTraversed && childrenTraversed.hasActiveChild);

		if (isActive) {
			activeChild = true;
		}

		const activatedChild = Object.assign({}, val, {
			active: isActive
		});

		if (val.children) {
			activatedChild.children = childrenTraversed.children;
		}

		return activatedChild;
	});

	return {
		children: activeValues,
		hasActiveChild: activeChild
	};
}
function parseActiveChildren(values, active) {
	let activeChild = false;

	const activeValues = values.map(function (val) {
		const childrenTraversed = (val.children && parseActiveChildren(val.children, active));
		const isActive = val.value === active || Boolean(childrenTraversed && childrenTraversed.hasActiveChild);

		if (isActive) {
			activeChild = true;
		}

		const activatedChild = Object.assign({}, val, {
			active: isActive
		});

		if (val.children) {
			activatedChild.children = childrenTraversed.children;
		}

		return activatedChild;
	});

	return {
		children: activeValues,
		hasActiveChild: activeChild
	};
}
function parseActiveChildren ( values , active ) { let activeChild = false ; const activeValues = values . map ( function ( val ) { const childrenTraversed = ( val . children && parseActiveChildren ( val . children , active ) ) ; const isActive = val . value === active || Boolean ( childrenTraversed && childrenTraversed . hasActiveChild ) ; if ( isActive ) { activeChild = true ; } const activatedChild = Object . assign ( { } , val , { active : isActive } ) ; if ( val . children ) { activatedChild . children = childrenTraversed . children ; } return activatedChild ; } ) ; return { children : activeValues , hasActiveChild : activeChild } ; }
Class handles boilerplate javascript to attribute active state to a data array.
This does not handle array of active values. Recursively searches children.
@param   {array}  values Array of data for iteratively rendered child components
@param   {string} active Active element of child components
@returns {object}        Returns hasActiveChild and children properties
Class handles boilerplate javascript to attribute active state to a data array . This does not handle array of active values . Recursively searches children .