UNPKG

@atlaskit/inline-dialog

Version:

An inline dialog is a pop-up container for small amounts of information. It can also contain controls.

28 lines 1.29 kB
import React from 'react'; import NodeResolver from 'react-node-resolver'; /** * A wrapper component that conditionally applies a NodeResolver to its children. * * Note: NodeResolver should not be used in React 18 concurrent mode. This component * is intended to be removed once the feature flag is removed. * @param {boolean} props.hasNodeResolver - Determines whether to apply the NodeResolver. * @param {ReactElement} props.children - The child elements to be wrapped. * @param {(instance: HTMLDivElement) => void} props.innerRef - A ref callback to get the instance of the HTMLDivElement. * @returns {ReactElement} The children wrapped with NodeResolver if hasNodeResolver is true, wrape the children in a div setting innerRef with ref to the div. */ var NodeResolverWrapper = function NodeResolverWrapper(_ref) { var hasNodeResolver = _ref.hasNodeResolver, children = _ref.children, innerRef = _ref.innerRef; if (hasNodeResolver) { return /*#__PURE__*/React.createElement(NodeResolver, { innerRef: innerRef }, children); } return /*#__PURE__*/React.createElement("div", { ref: function ref(node) { innerRef(node === null || node === void 0 ? void 0 : node.firstElementChild); } }, children); }; export default NodeResolverWrapper;