@moda/om 15.11.0 → 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/dist/index.esm.js CHANGED
@@ -11252,11 +11252,12 @@ var Paginator = function Paginator(_ref) {
11252
11252
  })));
11253
11253
  };
11254
11254
 
11255
- var _excluded$b = ["className", "children", "content", "open", "anchor", "zIndex", "autoPreview"];
11255
+ var _excluded$b = ["className", "children", "content", "open", "anchor", "zIndex", "autoPreview", "smoothTransitioning"];
11256
11256
  var POPOVER_MOUSEOUT_DELAY_MS = 200;
11257
11257
  var Mode;
11258
11258
 
11259
11259
  (function (Mode) {
11260
+ Mode["Opening"] = "opening";
11260
11261
  Mode["Open"] = "open";
11261
11262
  Mode["Closing"] = "closing";
11262
11263
  Mode["AutoOpening"] = "autoOpening";
@@ -11268,17 +11269,22 @@ var Popover = function Popover(_ref) {
11268
11269
  var className = _ref.className,
11269
11270
  children = _ref.children,
11270
11271
  content = _ref.content,
11271
- _ref$open = _ref.open,
11272
- open = _ref$open === void 0 ? false : _ref$open,
11272
+ open = _ref.open,
11273
11273
  _ref$anchor = _ref.anchor,
11274
11274
  anchor = _ref$anchor === void 0 ? 'topLeft' : _ref$anchor,
11275
11275
  zIndex = _ref.zIndex,
11276
11276
  _ref$autoPreview = _ref.autoPreview,
11277
11277
  autoPreview = _ref$autoPreview === void 0 ? false : _ref$autoPreview,
11278
+ _ref$smoothTransition = _ref.smoothTransitioning,
11279
+ smoothTransitioning = _ref$smoothTransition === void 0 ? false : _ref$smoothTransition,
11278
11280
  rest = _objectWithoutProperties(_ref, _excluded$b);
11279
11281
 
11280
11282
  var _useState = useState(function () {
11281
- if (open) {
11283
+ if (open && smoothTransitioning) {
11284
+ return Mode.Opening;
11285
+ }
11286
+
11287
+ if (open && !smoothTransitioning) {
11282
11288
  return Mode.Open;
11283
11289
  }
11284
11290
 
@@ -11293,19 +11299,24 @@ var Popover = function Popover(_ref) {
11293
11299
  setMode = _useState2[1];
11294
11300
 
11295
11301
  var timeout = useRef(null);
11302
+ var handleOpen = useCallback(function () {
11303
+ if (smoothTransitioning) setMode(Mode.Opening);
11304
+ if (!smoothTransitioning) setMode(Mode.Open);
11305
+ }, [smoothTransitioning]);
11306
+ var handleClose = useCallback(function () {
11307
+ if (smoothTransitioning) setMode(Mode.Closing);
11308
+ if (!smoothTransitioning) setMode(Mode.Closed);
11309
+ }, [smoothTransitioning]);
11296
11310
  var handleMouseEnter = useCallback(function () {
11297
11311
  if (!open) {
11298
11312
  timeout.current && clearTimeout(timeout.current);
11299
- setMode(Mode.Open);
11313
+ handleOpen();
11300
11314
  }
11301
- }, [open]);
11315
+ }, [handleOpen, open]);
11302
11316
  var handleMouseLeave = useCallback(function () {
11303
- if (!open) {
11304
- timeout.current = setTimeout(function () {
11305
- return setMode(Mode.Closing);
11306
- }, POPOVER_MOUSEOUT_DELAY_MS);
11307
- }
11308
- }, [open]);
11317
+ if (open) return;
11318
+ timeout.current = setTimeout(handleClose, POPOVER_MOUSEOUT_DELAY_MS);
11319
+ }, [handleClose, open]);
11309
11320
  useEffect(function () {
11310
11321
  if (mode !== Mode.Closing) return;
11311
11322
  var closingTimeout = setTimeout(function () {
@@ -11324,16 +11335,27 @@ var Popover = function Popover(_ref) {
11324
11335
  return clearTimeout(openingTimeout);
11325
11336
  };
11326
11337
  }, [mode]);
11338
+ useEffect(function () {
11339
+ if (mode !== Mode.Opening) return;
11340
+ var openingTimeout = setTimeout(function () {
11341
+ return setMode(Mode.Open);
11342
+ }, 750);
11343
+ return function () {
11344
+ return clearTimeout(openingTimeout);
11345
+ };
11346
+ }, [mode]);
11327
11347
  useEffect(function () {
11328
11348
  if (mode !== Mode.AutoOpen) return;
11329
- var stayingTimeout = setTimeout(function () {
11330
- return setMode(Mode.Closing);
11331
- }, 5000);
11349
+ var stayingTimeout = setTimeout(handleClose, 5000);
11332
11350
  return function () {
11333
11351
  return clearTimeout(stayingTimeout);
11334
11352
  };
11335
- }, [mode]);
11336
- var isOpen = mode === Mode.AutoOpen || mode === Mode.Open || mode === Mode.Closing;
11353
+ }, [handleClose, mode, smoothTransitioning]);
11354
+ useEffect(function () {
11355
+ if (open === undefined) return;
11356
+ open ? handleOpen() : handleClose();
11357
+ }, [handleClose, handleOpen, open]);
11358
+ var isOpen = mode === Mode.AutoOpen || mode === Mode.Opening || mode === Mode.Open || mode === Mode.Closing;
11337
11359
  return /*#__PURE__*/React__default.createElement("div", _extends$3({
11338
11360
  className: classNames("Popover Popover--anchor-".concat(anchor), className),
11339
11361
  onMouseEnter: handleMouseEnter,
@@ -11342,6 +11364,7 @@ var Popover = function Popover(_ref) {
11342
11364
  className: "Popover__trigger"
11343
11365
  }, isOpen && /*#__PURE__*/React__default.createElement("div", {
11344
11366
  className: classNames('Popover__box', {
11367
+ 'Popover__box--opening': mode === Mode.Opening,
11345
11368
  'Popover__box--closing': mode === Mode.Closing
11346
11369
  })
11347
11370
  }, /*#__PURE__*/React__default.createElement("div", {