@momentum-ui/react-collaboration
Version:
Cisco Momentum UI Framework for React Collaboration Applications
30 lines • 1.06 kB
JavaScript
import React from 'react';
import ButtonSimple from '../components/ButtonSimple';
import ButtonPill from '../components/ButtonPill';
export var MRv2Buttons = [ButtonPill, ButtonSimple];
/**
* Returns true if all children are the correct type, false otherwise
* @param children
* @param type the type to be checked
* @returns boolean
*/
export var verifyTypes = function (children, type) {
if (React.Children.count(children) === 0)
return false;
return React.Children.toArray(children).every(function (child) { return verifyType(child, type); });
};
/**
* Returns true if the element has the given type, false otherwise
* @param element
* @param type
* @returns
*/
export var verifyType = function (element, type) {
return (React.isValidElement(element) &&
// eslint-disable-next-line @typescript-eslint/no-explicit-any
element.type === type);
};
export var isMRv2Button = function (element) {
return MRv2Buttons.some(function (type) { return verifyType(element, type); });
};
//# sourceMappingURL=verifyTypes.js.map