UNPKG

@pantheon-systems/design-toolkit-react

Version:
29 lines (26 loc) 1.14 kB
import PropTypes from 'prop-types'; import { Children } from 'react'; var getDisplayName = function getDisplayName(component) { return component.displayName || component.name || 'Unknown'; }; var DTIcon = function DTIcon(props, propName, componentName) { var prop = props[propName]; var error = null; Children.forEach(prop, function (child) { if (getDisplayName(child.type) !== 'Icon') { error = new Error("`".concat(componentName, "` only accepts children of type `Icon`.")); } }); return error; }; DTIcon.isRequired = function (props, propName, componentName) { return props[propName] == null ? new Error("".concat(propName, " is required in `").concat(componentName, "`")) : DTIcon(props, propName, componentName); }; var FAIcon = PropTypes.shape({ icon: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.any), PropTypes.number, PropTypes.string])).isRequired, iconName: PropTypes.string.isRequired, prefix: PropTypes.string.isRequired }); var HeadingLevel = PropTypes.oneOf([1, 2, 3, 4, 5, 6]); export { DTIcon, FAIcon, HeadingLevel }; //# sourceMappingURL=customPropTypes.js.map