UNPKG

@atlaskit/modal-dialog

Version:

A modal dialog displays content that requires user interaction, in a layer above the page.

54 lines (53 loc) 2.4 kB
/* modal-body.tsx generated by @compiled/babel-plugin v0.39.1 */ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; require("./modal-body.compiled.css"); var _runtime = require("@compiled/react/runtime"); var _react = _interopRequireDefault(require("react")); var _reactScrolllock = require("react-scrolllock"); var _hooks = require("./hooks"); var _scrollContainer = _interopRequireDefault(require("./internal/components/scroll-container")); var _useScroll = _interopRequireDefault(require("./internal/hooks/use-scroll")); var styles = { root: "_16jlkb7n _1o9zkb7n _i0dl1wug _11c8fhey", paddingBlock: "_1rjcv77o", paddingInline: "_18zr1ejb" }; /** * __Modal body__ * * A modal body is used to display the main content of a modal. * * - [Examples](https://atlassian.design/components/modal-dialog/examples) * - [Code](https://atlassian.design/components/modal-dialog/code#modal-body-props) * - [Usage](https://atlassian.design/components/modal-dialog/usage) */ var ModalBody = function ModalBody(props) { var children = props.children, userDefinedTestId = props.testId, _props$hasInlinePaddi = props.hasInlinePadding, hasInlinePadding = _props$hasInlinePaddi === void 0 ? true : _props$hasInlinePaddi; var _useModal = (0, _hooks.useModal)(), modalTestId = _useModal.testId; var shouldScrollInViewport = (0, _useScroll.default)(); var testId = userDefinedTestId || modalTestId && "".concat(modalTestId, "--body"); return shouldScrollInViewport ? /*#__PURE__*/_react.default.createElement("div", { "data-testid": testId, className: (0, _runtime.ax)([styles.root, hasInlinePadding && styles.paddingInline]) }, children) : /*#__PURE__*/_react.default.createElement(_reactScrolllock.TouchScrollable, null, /*#__PURE__*/_react.default.createElement(_scrollContainer.default, { testId: userDefinedTestId || modalTestId }, /*#__PURE__*/_react.default.createElement("div", { "data-testid": testId, className: (0, _runtime.ax)([styles.root, /** * Adding block padding for scroll keylines, which are only shown when the scrolling * is on the container. */ styles.paddingBlock, hasInlinePadding && styles.paddingInline]) }, children))); }; var _default = exports.default = ModalBody;