"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.LoadingBackdrop = void 0;
var _react = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _reactTransitionGroup = require("react-transition-group");
var _message = require("../message");
var _useTranslation = require("../hooks/use-translation");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** Shows loader when content is not ready
 * [CAPITALIZATION] Use sentence case
 * @midnight-gray-supported
 * @alpine-light-supported
 */
const LoadingBackdrop = ({
  message,
  isLoading = true,
  customClassName = '',
  onTransitionEnd = () => {},
  testId = 'loading-backdrop'
}) => {
  const {
    t
  } = (0, _useTranslation.useTranslation)();
  const nodeRef = (0, _react.useRef)(null);
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactTransitionGroup.CSSTransition, {
    classNames: "loading-backdrop",
    nodeRef: nodeRef,
    in: isLoading,
    onExited: onTransitionEnd,
    timeout: 500,
    appear: true,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      ref: nodeRef,
      className: (0, _classnames.default)('loading-backdrop center-status ', customClassName),
      "test-id": testId,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_message.Message, {
        type: _message.MESSAGE_TYPES.IN_PROGRESS,
        children: message ?? t('Loading...')
      })
    })
  });
};
exports.LoadingBackdrop = LoadingBackdrop;