UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

41 lines (34 loc) 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; /** * Returns an object consisting of props beyond the scope of the Component. * Useful for getting and spreading unknown props from the user. * @param {function} Component A function or ReactClass. * @param {object} props A ReactElement props object * @returns {{}} A shallow copy of the prop object */ var getUnhandledProps = function getUnhandledProps(Component, props) { var _Component$handledPro = Component.handledProps, handledProps = _Component$handledPro === void 0 ? [] : _Component$handledPro, _Component$propTypes = Component.propTypes, propTypes = _Component$propTypes === void 0 ? {} : _Component$propTypes; var propTypeKeys = Object.keys(propTypes); return Object.keys(props).reduce(function (acc, prop) { if (prop === 'childKey') { return acc; } if (handledProps.length > 0 && handledProps.indexOf(prop) === -1) { acc[prop] = props[prop]; } if (propTypeKeys.length > 0 && propTypeKeys.indexOf(prop) === -1) { acc[prop] = props[prop]; } return acc; }, {}); }; var _default = getUnhandledProps; exports["default"] = _default; //# sourceMappingURL=getUnhandledProps.js.map