@moda/om 15.11.0 → 15.11.1
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 +7 -0
- package/dist/components/Popover/Popover.d.ts +1 -0
- package/dist/index.cjs.js +29 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +29 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/Popover/Popover.scss +1 -1
- package/src/components/Popover/Popover.stories.tsx +2 -0
- package/src/components/Popover/Popover.tsx +33 -10
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.1](https://github.com/ModaOperandi/om/compare/v15.11.0...v15.11.1) (2021-12-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **popover:** clears out props, makes smooth transitioning optional ([#2259](https://github.com/ModaOperandi/om/issues/2259)) ([9880664](https://github.com/ModaOperandi/om/commit/988066478a0f226d54db5b374dc54e1840fd9aee))
|
|
12
|
+
|
|
6
13
|
# [15.11.0](https://github.com/ModaOperandi/om/compare/v15.10.3...v15.11.0) (2021-12-10)
|
|
7
14
|
|
|
8
15
|
|
|
@@ -7,6 +7,7 @@ export declare type PopoverProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
7
7
|
anchor?: 'topLeft' | 'topCenter' | 'topRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight';
|
|
8
8
|
zIndex?: number;
|
|
9
9
|
autoPreview?: boolean;
|
|
10
|
+
smoothTransitioning?: boolean;
|
|
10
11
|
};
|
|
11
12
|
export declare const POPOVER_MOUSEOUT_DELAY_MS = 200;
|
|
12
13
|
export declare const Popover: React.FC<PopoverProps>;
|
package/dist/index.cjs.js
CHANGED
|
@@ -11279,11 +11279,12 @@ var Paginator = function Paginator(_ref) {
|
|
|
11279
11279
|
})));
|
|
11280
11280
|
};
|
|
11281
11281
|
|
|
11282
|
-
var _excluded$b = ["className", "children", "content", "open", "anchor", "zIndex", "autoPreview"];
|
|
11282
|
+
var _excluded$b = ["className", "children", "content", "open", "anchor", "zIndex", "autoPreview", "smoothTransitioning"];
|
|
11283
11283
|
var POPOVER_MOUSEOUT_DELAY_MS = 200;
|
|
11284
11284
|
var Mode;
|
|
11285
11285
|
|
|
11286
11286
|
(function (Mode) {
|
|
11287
|
+
Mode["Opening"] = "opening";
|
|
11287
11288
|
Mode["Open"] = "open";
|
|
11288
11289
|
Mode["Closing"] = "closing";
|
|
11289
11290
|
Mode["AutoOpening"] = "autoOpening";
|
|
@@ -11302,10 +11303,16 @@ var Popover = function Popover(_ref) {
|
|
|
11302
11303
|
zIndex = _ref.zIndex,
|
|
11303
11304
|
_ref$autoPreview = _ref.autoPreview,
|
|
11304
11305
|
autoPreview = _ref$autoPreview === void 0 ? false : _ref$autoPreview,
|
|
11306
|
+
_ref$smoothTransition = _ref.smoothTransitioning,
|
|
11307
|
+
smoothTransitioning = _ref$smoothTransition === void 0 ? false : _ref$smoothTransition,
|
|
11305
11308
|
rest = _objectWithoutProperties(_ref, _excluded$b);
|
|
11306
11309
|
|
|
11307
11310
|
var _useState = React$2.useState(function () {
|
|
11308
|
-
if (open) {
|
|
11311
|
+
if (open && smoothTransitioning) {
|
|
11312
|
+
return Mode.Opening;
|
|
11313
|
+
}
|
|
11314
|
+
|
|
11315
|
+
if (open && !smoothTransitioning) {
|
|
11309
11316
|
return Mode.Open;
|
|
11310
11317
|
}
|
|
11311
11318
|
|
|
@@ -11323,16 +11330,15 @@ var Popover = function Popover(_ref) {
|
|
|
11323
11330
|
var handleMouseEnter = React$2.useCallback(function () {
|
|
11324
11331
|
if (!open) {
|
|
11325
11332
|
timeout.current && clearTimeout(timeout.current);
|
|
11326
|
-
setMode(Mode.Open);
|
|
11333
|
+
setMode(smoothTransitioning ? Mode.Opening : Mode.Open);
|
|
11327
11334
|
}
|
|
11328
|
-
}, [open]);
|
|
11335
|
+
}, [open, smoothTransitioning]);
|
|
11329
11336
|
var handleMouseLeave = React$2.useCallback(function () {
|
|
11330
|
-
if (
|
|
11331
|
-
|
|
11332
|
-
|
|
11333
|
-
|
|
11334
|
-
|
|
11335
|
-
}, [open]);
|
|
11337
|
+
if (open) return;
|
|
11338
|
+
timeout.current = setTimeout(function () {
|
|
11339
|
+
return setMode(smoothTransitioning ? Mode.Closing : Mode.Closed);
|
|
11340
|
+
}, POPOVER_MOUSEOUT_DELAY_MS);
|
|
11341
|
+
}, [open, smoothTransitioning]);
|
|
11336
11342
|
React$2.useEffect(function () {
|
|
11337
11343
|
if (mode !== Mode.Closing) return;
|
|
11338
11344
|
var closingTimeout = setTimeout(function () {
|
|
@@ -11351,16 +11357,25 @@ var Popover = function Popover(_ref) {
|
|
|
11351
11357
|
return clearTimeout(openingTimeout);
|
|
11352
11358
|
};
|
|
11353
11359
|
}, [mode]);
|
|
11360
|
+
React$2.useEffect(function () {
|
|
11361
|
+
if (mode !== Mode.Opening) return;
|
|
11362
|
+
var openingTimeout = setTimeout(function () {
|
|
11363
|
+
return setMode(Mode.Open);
|
|
11364
|
+
}, 750);
|
|
11365
|
+
return function () {
|
|
11366
|
+
return clearTimeout(openingTimeout);
|
|
11367
|
+
};
|
|
11368
|
+
}, [mode]);
|
|
11354
11369
|
React$2.useEffect(function () {
|
|
11355
11370
|
if (mode !== Mode.AutoOpen) return;
|
|
11356
11371
|
var stayingTimeout = setTimeout(function () {
|
|
11357
|
-
return setMode(Mode.Closing);
|
|
11372
|
+
return setMode(smoothTransitioning ? Mode.Closing : Mode.Closed);
|
|
11358
11373
|
}, 5000);
|
|
11359
11374
|
return function () {
|
|
11360
11375
|
return clearTimeout(stayingTimeout);
|
|
11361
11376
|
};
|
|
11362
|
-
}, [mode]);
|
|
11363
|
-
var isOpen = mode === Mode.AutoOpen || mode === Mode.Open || mode === Mode.Closing;
|
|
11377
|
+
}, [mode, smoothTransitioning]);
|
|
11378
|
+
var isOpen = mode === Mode.AutoOpen || mode === Mode.Opening || mode === Mode.Open || mode === Mode.Closing;
|
|
11364
11379
|
return /*#__PURE__*/React__default["default"].createElement("div", _extends$3({
|
|
11365
11380
|
className: classNames("Popover Popover--anchor-".concat(anchor), className),
|
|
11366
11381
|
onMouseEnter: handleMouseEnter,
|
|
@@ -11369,6 +11384,7 @@ var Popover = function Popover(_ref) {
|
|
|
11369
11384
|
className: "Popover__trigger"
|
|
11370
11385
|
}, isOpen && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
11371
11386
|
className: classNames('Popover__box', {
|
|
11387
|
+
'Popover__box--opening': mode === Mode.Opening,
|
|
11372
11388
|
'Popover__box--closing': mode === Mode.Closing
|
|
11373
11389
|
})
|
|
11374
11390
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|