@moda/om 15.11.3 → 15.11.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  All notable changes to this project will be documented in this file. See
4
4
  [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [15.11.4](https://github.com/ModaOperandi/om/compare/v15.11.3...v15.11.4) (2021-12-14)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **popover:** fixes error and clears out code[refactor] ([#2269](https://github.com/ModaOperandi/om/issues/2269)) ([974a3c6](https://github.com/ModaOperandi/om/commit/974a3c6f5355b38f9a2707e9c41a899fba1b17a6))
12
+
6
13
  ## [15.11.3](https://github.com/ModaOperandi/om/compare/v15.11.2...v15.11.3) (2021-12-13)
7
14
 
8
15
 
package/dist/index.cjs.js CHANGED
@@ -11296,8 +11296,7 @@ var Popover = function Popover(_ref) {
11296
11296
  var className = _ref.className,
11297
11297
  children = _ref.children,
11298
11298
  content = _ref.content,
11299
- _ref$open = _ref.open,
11300
- open = _ref$open === void 0 ? false : _ref$open,
11299
+ open = _ref.open,
11301
11300
  _ref$anchor = _ref.anchor,
11302
11301
  anchor = _ref$anchor === void 0 ? 'topLeft' : _ref$anchor,
11303
11302
  zIndex = _ref.zIndex,
@@ -11327,18 +11326,24 @@ var Popover = function Popover(_ref) {
11327
11326
  setMode = _useState2[1];
11328
11327
 
11329
11328
  var timeout = React$2.useRef(null);
11329
+ var handleOpen = React$2.useCallback(function () {
11330
+ if (smoothTransitioning) setMode(Mode.Opening);
11331
+ if (!smoothTransitioning) setMode(Mode.Open);
11332
+ }, [smoothTransitioning]);
11333
+ var handleClose = React$2.useCallback(function () {
11334
+ if (smoothTransitioning) setMode(Mode.Closing);
11335
+ if (!smoothTransitioning) setMode(Mode.Closed);
11336
+ }, [smoothTransitioning]);
11330
11337
  var handleMouseEnter = React$2.useCallback(function () {
11331
11338
  if (!open) {
11332
11339
  timeout.current && clearTimeout(timeout.current);
11333
- setMode(smoothTransitioning ? Mode.Opening : Mode.Open);
11340
+ handleOpen();
11334
11341
  }
11335
- }, [open, smoothTransitioning]);
11342
+ }, [handleOpen, open]);
11336
11343
  var handleMouseLeave = React$2.useCallback(function () {
11337
11344
  if (open) return;
11338
- timeout.current = setTimeout(function () {
11339
- return setMode(smoothTransitioning ? Mode.Closing : Mode.Closed);
11340
- }, POPOVER_MOUSEOUT_DELAY_MS);
11341
- }, [open, smoothTransitioning]);
11345
+ timeout.current = setTimeout(handleClose, POPOVER_MOUSEOUT_DELAY_MS);
11346
+ }, [handleClose, open]);
11342
11347
  React$2.useEffect(function () {
11343
11348
  if (mode !== Mode.Closing) return;
11344
11349
  var closingTimeout = setTimeout(function () {
@@ -11368,30 +11373,15 @@ var Popover = function Popover(_ref) {
11368
11373
  }, [mode]);
11369
11374
  React$2.useEffect(function () {
11370
11375
  if (mode !== Mode.AutoOpen) return;
11371
- var stayingTimeout = setTimeout(function () {
11372
- return setMode(smoothTransitioning ? Mode.Closing : Mode.Closed);
11373
- }, 5000);
11376
+ var stayingTimeout = setTimeout(handleClose, 5000);
11374
11377
  return function () {
11375
11378
  return clearTimeout(stayingTimeout);
11376
11379
  };
11377
- }, [mode, smoothTransitioning]);
11380
+ }, [handleClose, mode, smoothTransitioning]);
11378
11381
  React$2.useEffect(function () {
11379
- if (open && smoothTransitioning) {
11380
- setMode(Mode.Opening);
11381
- }
11382
-
11383
- if (open && !smoothTransitioning) {
11384
- setMode(Mode.Open);
11385
- }
11386
-
11387
- if (!open && smoothTransitioning) {
11388
- setMode(Mode.Closing);
11389
- }
11390
-
11391
- if (!open && !smoothTransitioning) {
11392
- setMode(Mode.Closed);
11393
- }
11394
- }, [open, smoothTransitioning]);
11382
+ if (open === undefined) return;
11383
+ open ? handleOpen() : handleClose();
11384
+ }, [handleClose, handleOpen, open]);
11395
11385
  var isOpen = mode === Mode.AutoOpen || mode === Mode.Opening || mode === Mode.Open || mode === Mode.Closing;
11396
11386
  return /*#__PURE__*/React__default["default"].createElement("div", _extends$3({
11397
11387
  className: classNames("Popover Popover--anchor-".concat(anchor), className),