amis-rpc-design/node_modules/antd/lib/_util/reactNode.js
2023-10-07 19:42:30 +08:00

27 lines
884 B
JavaScript

"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.cloneElement = cloneElement;
exports.isFragment = isFragment;
exports.isValidElement = void 0;
exports.replaceElement = replaceElement;
var React = _interopRequireWildcard(require("react"));
const {
isValidElement
} = React;
exports.isValidElement = isValidElement;
function isFragment(child) {
return child && isValidElement(child) && child.type === React.Fragment;
}
function replaceElement(element, replacement, props) {
if (!isValidElement(element)) {
return replacement;
}
return /*#__PURE__*/React.cloneElement(element, typeof props === 'function' ? props(element.props || {}) : props);
}
function cloneElement(element, props) {
return replaceElement(element, element, props);
}