Outlook_Addin_LLM/node_modules/@fluentui/react-motion/lib-commonjs/utils/getChildElement.js

30 lines
1.2 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getChildElement", {
enumerable: true,
get: function() {
return getChildElement;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _reactis = /*#__PURE__*/ _interop_require_wildcard._(require("react-is"));
function getChildElement(children) {
try {
const child = _react.Children.only(children);
if (typeof child.type === 'string' || _reactis.isForwardRef(child)) {
return child;
}
// We don't need to do anything here: we catch the exception from React to throw a more meaningful error
// eslint-disable-next-line no-empty
} catch {}
throw new Error([
'@fluentui/react-motion: Invalid child element.',
'\n',
'Motion factories require a single child element to be passed. ',
'That element element should support ref forwarding i.e. it should be either an intrinsic element (e.g. div) or a component that uses React.forwardRef().'
].join(''));
}