@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/CHANGELOG.md +28 -0
- package/dist/components/Popover/Popover.d.ts +1 -0
- package/dist/index.cjs.js +40 -17
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +40 -17
- 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 +46 -11
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,34 @@
|
|
|
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
|
+
|
|
13
|
+
## [15.11.3](https://github.com/ModaOperandi/om/compare/v15.11.2...v15.11.3) (2021-12-13)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **popover:** fixes open & !open logic ([#2265](https://github.com/ModaOperandi/om/issues/2265)) ([21e5bc9](https://github.com/ModaOperandi/om/commit/21e5bc995297ca3eeaaf4c4e0361ddb4860bd7b7))
|
|
19
|
+
|
|
20
|
+
## [15.11.2](https://github.com/ModaOperandi/om/compare/v15.11.1...v15.11.2) (2021-12-10)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* **popover smooth transitioning:** fixes problem with auto triggering ([#2260](https://github.com/ModaOperandi/om/issues/2260)) ([4700f11](https://github.com/ModaOperandi/om/commit/4700f11641478123d6220f8bef7d4a0ce81daf45))
|
|
26
|
+
|
|
27
|
+
## [15.11.1](https://github.com/ModaOperandi/om/compare/v15.11.0...v15.11.1) (2021-12-10)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Bug Fixes
|
|
31
|
+
|
|
32
|
+
* **popover:** clears out props, makes smooth transitioning optional ([#2259](https://github.com/ModaOperandi/om/issues/2259)) ([9880664](https://github.com/ModaOperandi/om/commit/988066478a0f226d54db5b374dc54e1840fd9aee))
|
|
33
|
+
|
|
6
34
|
# [15.11.0](https://github.com/ModaOperandi/om/compare/v15.10.3...v15.11.0) (2021-12-10)
|
|
7
35
|
|
|
8
36
|
|
|
@@ -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";
|
|
@@ -11295,17 +11296,22 @@ var Popover = function Popover(_ref) {
|
|
|
11295
11296
|
var className = _ref.className,
|
|
11296
11297
|
children = _ref.children,
|
|
11297
11298
|
content = _ref.content,
|
|
11298
|
-
|
|
11299
|
-
open = _ref$open === void 0 ? false : _ref$open,
|
|
11299
|
+
open = _ref.open,
|
|
11300
11300
|
_ref$anchor = _ref.anchor,
|
|
11301
11301
|
anchor = _ref$anchor === void 0 ? 'topLeft' : _ref$anchor,
|
|
11302
11302
|
zIndex = _ref.zIndex,
|
|
11303
11303
|
_ref$autoPreview = _ref.autoPreview,
|
|
11304
11304
|
autoPreview = _ref$autoPreview === void 0 ? false : _ref$autoPreview,
|
|
11305
|
+
_ref$smoothTransition = _ref.smoothTransitioning,
|
|
11306
|
+
smoothTransitioning = _ref$smoothTransition === void 0 ? false : _ref$smoothTransition,
|
|
11305
11307
|
rest = _objectWithoutProperties(_ref, _excluded$b);
|
|
11306
11308
|
|
|
11307
11309
|
var _useState = React$2.useState(function () {
|
|
11308
|
-
if (open) {
|
|
11310
|
+
if (open && smoothTransitioning) {
|
|
11311
|
+
return Mode.Opening;
|
|
11312
|
+
}
|
|
11313
|
+
|
|
11314
|
+
if (open && !smoothTransitioning) {
|
|
11309
11315
|
return Mode.Open;
|
|
11310
11316
|
}
|
|
11311
11317
|
|
|
@@ -11320,19 +11326,24 @@ var Popover = function Popover(_ref) {
|
|
|
11320
11326
|
setMode = _useState2[1];
|
|
11321
11327
|
|
|
11322
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]);
|
|
11323
11337
|
var handleMouseEnter = React$2.useCallback(function () {
|
|
11324
11338
|
if (!open) {
|
|
11325
11339
|
timeout.current && clearTimeout(timeout.current);
|
|
11326
|
-
|
|
11340
|
+
handleOpen();
|
|
11327
11341
|
}
|
|
11328
|
-
}, [open]);
|
|
11342
|
+
}, [handleOpen, open]);
|
|
11329
11343
|
var handleMouseLeave = React$2.useCallback(function () {
|
|
11330
|
-
if (
|
|
11331
|
-
|
|
11332
|
-
|
|
11333
|
-
}, POPOVER_MOUSEOUT_DELAY_MS);
|
|
11334
|
-
}
|
|
11335
|
-
}, [open]);
|
|
11344
|
+
if (open) return;
|
|
11345
|
+
timeout.current = setTimeout(handleClose, POPOVER_MOUSEOUT_DELAY_MS);
|
|
11346
|
+
}, [handleClose, open]);
|
|
11336
11347
|
React$2.useEffect(function () {
|
|
11337
11348
|
if (mode !== Mode.Closing) return;
|
|
11338
11349
|
var closingTimeout = setTimeout(function () {
|
|
@@ -11351,16 +11362,27 @@ var Popover = function Popover(_ref) {
|
|
|
11351
11362
|
return clearTimeout(openingTimeout);
|
|
11352
11363
|
};
|
|
11353
11364
|
}, [mode]);
|
|
11365
|
+
React$2.useEffect(function () {
|
|
11366
|
+
if (mode !== Mode.Opening) return;
|
|
11367
|
+
var openingTimeout = setTimeout(function () {
|
|
11368
|
+
return setMode(Mode.Open);
|
|
11369
|
+
}, 750);
|
|
11370
|
+
return function () {
|
|
11371
|
+
return clearTimeout(openingTimeout);
|
|
11372
|
+
};
|
|
11373
|
+
}, [mode]);
|
|
11354
11374
|
React$2.useEffect(function () {
|
|
11355
11375
|
if (mode !== Mode.AutoOpen) return;
|
|
11356
|
-
var stayingTimeout = setTimeout(
|
|
11357
|
-
return setMode(Mode.Closing);
|
|
11358
|
-
}, 5000);
|
|
11376
|
+
var stayingTimeout = setTimeout(handleClose, 5000);
|
|
11359
11377
|
return function () {
|
|
11360
11378
|
return clearTimeout(stayingTimeout);
|
|
11361
11379
|
};
|
|
11362
|
-
}, [mode]);
|
|
11363
|
-
|
|
11380
|
+
}, [handleClose, mode, smoothTransitioning]);
|
|
11381
|
+
React$2.useEffect(function () {
|
|
11382
|
+
if (open === undefined) return;
|
|
11383
|
+
open ? handleOpen() : handleClose();
|
|
11384
|
+
}, [handleClose, handleOpen, open]);
|
|
11385
|
+
var isOpen = mode === Mode.AutoOpen || mode === Mode.Opening || mode === Mode.Open || mode === Mode.Closing;
|
|
11364
11386
|
return /*#__PURE__*/React__default["default"].createElement("div", _extends$3({
|
|
11365
11387
|
className: classNames("Popover Popover--anchor-".concat(anchor), className),
|
|
11366
11388
|
onMouseEnter: handleMouseEnter,
|
|
@@ -11369,6 +11391,7 @@ var Popover = function Popover(_ref) {
|
|
|
11369
11391
|
className: "Popover__trigger"
|
|
11370
11392
|
}, isOpen && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
11371
11393
|
className: classNames('Popover__box', {
|
|
11394
|
+
'Popover__box--opening': mode === Mode.Opening,
|
|
11372
11395
|
'Popover__box--closing': mode === Mode.Closing
|
|
11373
11396
|
})
|
|
11374
11397
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|