"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireDefault(require("react"));
var _useCollapse = require("../../providers/useCollapse");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/Transition/Toggle/Toggle.tsx";
/** Toggle is a component to solve ReactTransitionGroup bug with lagging collapse and expand transitions. */
var Toggle = _ref => {
  var {
    children,
    dataHook,
    mountOnEnter,
    show,
    timeout,
    unmountOnExit,
    onEnd,
    onStart
  } = _ref;
  var {
    getCollapseProps,
    exitAnimationEnded
  } = (0, _useCollapse.useCollapse)({
    isExpanded: show,
    duration: process.env.NODE_ENV === 'test' ? 0 : timeout,
    onCollapseStart: onEnd,
    onExpandStart: onStart
  });
  return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
    "data-hook": dataHook
  }, getCollapseProps(), {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 25,
      columnNumber: 5
    }
  }), !show && (unmountOnExit || mountOnEnter && unmountOnExit === false) && exitAnimationEnded ? null : children);
};
Toggle.displayName = 'Toggle';
var _default = exports.default = Toggle;
//# sourceMappingURL=Toggle.js.map