@moda/om 15.10.2 → 15.11.2
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 +2 -0
- package/dist/index.cjs.js +133 -42
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +134 -43
- package/dist/index.esm.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +9 -9
- package/src/components/Popover/Popover.scss +24 -0
- package/src/components/Popover/Popover.stories.tsx +5 -1
- package/src/components/Popover/Popover.tsx +93 -9
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.2](https://github.com/ModaOperandi/om/compare/v15.11.1...v15.11.2) (2021-12-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **popover smooth transitioning:** fixes problem with auto triggering ([#2260](https://github.com/ModaOperandi/om/issues/2260)) ([4700f11](https://github.com/ModaOperandi/om/commit/4700f11641478123d6220f8bef7d4a0ce81daf45))
|
|
12
|
+
|
|
13
|
+
## [15.11.1](https://github.com/ModaOperandi/om/compare/v15.11.0...v15.11.1) (2021-12-10)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **popover:** clears out props, makes smooth transitioning optional ([#2259](https://github.com/ModaOperandi/om/issues/2259)) ([9880664](https://github.com/ModaOperandi/om/commit/988066478a0f226d54db5b374dc54e1840fd9aee))
|
|
19
|
+
|
|
20
|
+
# [15.11.0](https://github.com/ModaOperandi/om/compare/v15.10.3...v15.11.0) (2021-12-10)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* **popover:** adds popover smooth animation ([#2256](https://github.com/ModaOperandi/om/issues/2256)) ([ad7562f](https://github.com/ModaOperandi/om/commit/ad7562f3256ba04b7b80a761c044ac17656f6588))
|
|
26
|
+
|
|
27
|
+
## [15.10.3](https://github.com/ModaOperandi/om/compare/v15.10.2...v15.10.3) (2021-10-27)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Bug Fixes
|
|
31
|
+
|
|
32
|
+
* upgrade deps ([4c65a4f](https://github.com/ModaOperandi/om/commit/4c65a4f56ae8ab3f716330c54095bef7149a23af))
|
|
33
|
+
|
|
6
34
|
## [15.10.2](https://github.com/ModaOperandi/om/compare/v15.10.1...v15.10.2) (2021-10-26)
|
|
7
35
|
|
|
8
36
|
|
|
@@ -6,6 +6,8 @@ export declare type PopoverProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
6
6
|
open?: boolean;
|
|
7
7
|
anchor?: 'topLeft' | 'topCenter' | 'topRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight';
|
|
8
8
|
zIndex?: number;
|
|
9
|
+
autoPreview?: boolean;
|
|
10
|
+
smoothTransitioning?: boolean;
|
|
9
11
|
};
|
|
10
12
|
export declare const POPOVER_MOUSEOUT_DELAY_MS = 200;
|
|
11
13
|
export declare const Popover: React.FC<PopoverProps>;
|
package/dist/index.cjs.js
CHANGED
|
@@ -354,6 +354,7 @@ colors.colors = void 0; // THIS FILE IS AUTO-GENERATED. DO NOT EDIT.
|
|
|
354
354
|
|
|
355
355
|
colors.colors = {
|
|
356
356
|
"all": {
|
|
357
|
+
"coal": "rgb(0, 0, 0)",
|
|
357
358
|
"ink": "rgb(25, 26, 27)",
|
|
358
359
|
"cement": "rgb(101, 101, 102)",
|
|
359
360
|
"fog": "rgb(151, 152, 153)",
|
|
@@ -411,6 +412,7 @@ colors.colors = {
|
|
|
411
412
|
"dark-fuchsia": "rgb(180, 60, 160)"
|
|
412
413
|
},
|
|
413
414
|
"greyscale": {
|
|
415
|
+
"coal": "rgb(0, 0, 0)",
|
|
414
416
|
"ink": "rgb(25, 26, 27)",
|
|
415
417
|
"cement": "rgb(101, 101, 102)",
|
|
416
418
|
"fog": "rgb(151, 152, 153)",
|
|
@@ -965,12 +967,14 @@ var __assign$9 = commonjsGlobal && commonjsGlobal.__assign || function () {
|
|
|
965
967
|
return __assign$9.apply(this, arguments);
|
|
966
968
|
};
|
|
967
969
|
|
|
968
|
-
var __spreadArray = commonjsGlobal && commonjsGlobal.__spreadArray || function (to, from) {
|
|
969
|
-
for (var i = 0,
|
|
970
|
-
|
|
970
|
+
var __spreadArray = commonjsGlobal && commonjsGlobal.__spreadArray || function (to, from, pack) {
|
|
971
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
972
|
+
if (ar || !(i in from)) {
|
|
973
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
974
|
+
ar[i] = from[i];
|
|
975
|
+
}
|
|
971
976
|
}
|
|
972
|
-
|
|
973
|
-
return to;
|
|
977
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
974
978
|
};
|
|
975
979
|
|
|
976
980
|
Object.defineProperty(helpers, "__esModule", {
|
|
@@ -1006,7 +1010,7 @@ var color = function color(name, alpha) {
|
|
|
1006
1010
|
var _a;
|
|
1007
1011
|
|
|
1008
1012
|
var color = colors_1.colors.all[name];
|
|
1009
|
-
return alpha != null ? colorString.to.rgb(__spreadArray(__spreadArray([], ((_a = colorString.get.rgb(color)) === null || _a === void 0 ? void 0 : _a.slice(0, 3)) || []), [alpha])) : color;
|
|
1013
|
+
return alpha != null ? colorString.to.rgb(__spreadArray(__spreadArray([], ((_a = colorString.get.rgb(color)) === null || _a === void 0 ? void 0 : _a.slice(0, 3)) || [], true), [alpha], false)) : color;
|
|
1010
1014
|
};
|
|
1011
1015
|
|
|
1012
1016
|
helpers.color = color;
|
|
@@ -2984,21 +2988,32 @@ var FocusLock = /*#__PURE__*/React__namespace.forwardRef(function FocusLockUI(pr
|
|
|
2984
2988
|
onDeactivationCallback(observed.current);
|
|
2985
2989
|
}
|
|
2986
2990
|
}, [onDeactivationCallback]);
|
|
2991
|
+
React$2.useEffect(function () {
|
|
2992
|
+
if (!disabled) {
|
|
2993
|
+
// cleanup return focus on trap deactivation
|
|
2994
|
+
// sideEffect/returnFocus should happen by this time
|
|
2995
|
+
originalFocusedElement.current = null;
|
|
2996
|
+
}
|
|
2997
|
+
}, []);
|
|
2987
2998
|
var returnFocus = React__namespace.useCallback(function (allowDefer) {
|
|
2988
|
-
var
|
|
2999
|
+
var returnFocusTo = originalFocusedElement.current;
|
|
2989
3000
|
|
|
2990
|
-
if (
|
|
2991
|
-
var
|
|
2992
|
-
originalFocusedElement.current = null;
|
|
3001
|
+
if (returnFocusTo && returnFocusTo.focus) {
|
|
3002
|
+
var howToReturnFocus = typeof shouldReturnFocus === 'function' ? shouldReturnFocus(returnFocusTo) : shouldReturnFocus;
|
|
2993
3003
|
|
|
2994
|
-
if (
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3004
|
+
if (Boolean(howToReturnFocus)) {
|
|
3005
|
+
var focusOptions = _typeof(howToReturnFocus) === 'object' ? howToReturnFocus : undefined;
|
|
3006
|
+
originalFocusedElement.current = null;
|
|
3007
|
+
|
|
3008
|
+
if (allowDefer) {
|
|
3009
|
+
// React might return focus after update
|
|
3010
|
+
// it's safer to defer the action
|
|
3011
|
+
Promise.resolve().then(function () {
|
|
3012
|
+
return returnFocusTo.focus(focusOptions);
|
|
3013
|
+
});
|
|
3014
|
+
} else {
|
|
3015
|
+
returnFocusTo.focus(focusOptions);
|
|
3016
|
+
}
|
|
3002
3017
|
}
|
|
3003
3018
|
}
|
|
3004
3019
|
}, [shouldReturnFocus]); // MEDIUM CALLBACKS
|
|
@@ -3936,13 +3951,13 @@ var onWindowBlur = function onWindowBlur() {
|
|
|
3936
3951
|
};
|
|
3937
3952
|
|
|
3938
3953
|
var attachHandler = function attachHandler() {
|
|
3939
|
-
document.addEventListener('focusin', onTrap
|
|
3954
|
+
document.addEventListener('focusin', onTrap);
|
|
3940
3955
|
document.addEventListener('focusout', onBlur);
|
|
3941
3956
|
window.addEventListener('blur', onWindowBlur);
|
|
3942
3957
|
};
|
|
3943
3958
|
|
|
3944
3959
|
var detachHandler = function detachHandler() {
|
|
3945
|
-
document.removeEventListener('focusin', onTrap
|
|
3960
|
+
document.removeEventListener('focusin', onTrap);
|
|
3946
3961
|
document.removeEventListener('focusout', onBlur);
|
|
3947
3962
|
window.removeEventListener('blur', onWindowBlur);
|
|
3948
3963
|
};
|
|
@@ -8612,30 +8627,30 @@ var useClickOutside = function useClickOutside(ref, onClickOutside) {
|
|
|
8612
8627
|
});
|
|
8613
8628
|
};
|
|
8614
8629
|
|
|
8615
|
-
var Mode;
|
|
8630
|
+
var Mode$1;
|
|
8616
8631
|
|
|
8617
8632
|
(function (Mode) {
|
|
8618
8633
|
Mode[Mode["Resting"] = 0] = "Resting";
|
|
8619
8634
|
Mode[Mode["Open"] = 1] = "Open";
|
|
8620
|
-
})(Mode || (Mode = {}));
|
|
8635
|
+
})(Mode$1 || (Mode$1 = {}));
|
|
8621
8636
|
|
|
8622
8637
|
var reducer = function reducer(state, action) {
|
|
8623
8638
|
switch (action.type) {
|
|
8624
8639
|
case 'OPEN':
|
|
8625
8640
|
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
8626
|
-
mode: Mode.Open
|
|
8641
|
+
mode: Mode$1.Open
|
|
8627
8642
|
});
|
|
8628
8643
|
|
|
8629
8644
|
case 'CLOSE':
|
|
8630
8645
|
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
8631
|
-
mode: Mode.Resting
|
|
8646
|
+
mode: Mode$1.Resting
|
|
8632
8647
|
});
|
|
8633
8648
|
|
|
8634
8649
|
case 'SELECT':
|
|
8635
8650
|
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
8636
8651
|
value: action.payload.value,
|
|
8637
8652
|
focused: undefined,
|
|
8638
|
-
mode: Mode.Resting
|
|
8653
|
+
mode: Mode$1.Resting
|
|
8639
8654
|
});
|
|
8640
8655
|
|
|
8641
8656
|
case 'FOCUS':
|
|
@@ -8654,7 +8669,7 @@ var useSelect = function useSelect(_ref) {
|
|
|
8654
8669
|
var _useReducer = React$2.useReducer(reducer, {
|
|
8655
8670
|
value: initialValue,
|
|
8656
8671
|
focused: _typeof(initialValue) == 'object' ? initialValue === null || initialValue === void 0 ? void 0 : initialValue[0] : initialValue,
|
|
8657
|
-
mode: Mode.Resting
|
|
8672
|
+
mode: Mode$1.Resting
|
|
8658
8673
|
}),
|
|
8659
8674
|
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
8660
8675
|
state = _useReducer2[0],
|
|
@@ -8696,7 +8711,7 @@ var useSelect = function useSelect(_ref) {
|
|
|
8696
8711
|
return {
|
|
8697
8712
|
state: state,
|
|
8698
8713
|
dispatch: dispatch,
|
|
8699
|
-
Mode: Mode,
|
|
8714
|
+
Mode: Mode$1,
|
|
8700
8715
|
selectRef: selectRef
|
|
8701
8716
|
};
|
|
8702
8717
|
};
|
|
@@ -11264,8 +11279,19 @@ var Paginator = function Paginator(_ref) {
|
|
|
11264
11279
|
})));
|
|
11265
11280
|
};
|
|
11266
11281
|
|
|
11267
|
-
var _excluded$b = ["className", "children", "content", "open", "anchor", "zIndex"];
|
|
11282
|
+
var _excluded$b = ["className", "children", "content", "open", "anchor", "zIndex", "autoPreview", "smoothTransitioning"];
|
|
11268
11283
|
var POPOVER_MOUSEOUT_DELAY_MS = 200;
|
|
11284
|
+
var Mode;
|
|
11285
|
+
|
|
11286
|
+
(function (Mode) {
|
|
11287
|
+
Mode["Opening"] = "opening";
|
|
11288
|
+
Mode["Open"] = "open";
|
|
11289
|
+
Mode["Closing"] = "closing";
|
|
11290
|
+
Mode["AutoOpening"] = "autoOpening";
|
|
11291
|
+
Mode["AutoOpen"] = "autoOpen";
|
|
11292
|
+
Mode["Closed"] = "closed";
|
|
11293
|
+
})(Mode || (Mode = {}));
|
|
11294
|
+
|
|
11269
11295
|
var Popover = function Popover(_ref) {
|
|
11270
11296
|
var className = _ref.className,
|
|
11271
11297
|
children = _ref.children,
|
|
@@ -11275,37 +11301,102 @@ var Popover = function Popover(_ref) {
|
|
|
11275
11301
|
_ref$anchor = _ref.anchor,
|
|
11276
11302
|
anchor = _ref$anchor === void 0 ? 'topLeft' : _ref$anchor,
|
|
11277
11303
|
zIndex = _ref.zIndex,
|
|
11304
|
+
_ref$autoPreview = _ref.autoPreview,
|
|
11305
|
+
autoPreview = _ref$autoPreview === void 0 ? false : _ref$autoPreview,
|
|
11306
|
+
_ref$smoothTransition = _ref.smoothTransitioning,
|
|
11307
|
+
smoothTransitioning = _ref$smoothTransition === void 0 ? false : _ref$smoothTransition,
|
|
11278
11308
|
rest = _objectWithoutProperties(_ref, _excluded$b);
|
|
11279
11309
|
|
|
11280
|
-
var _useState = React$2.useState(
|
|
11310
|
+
var _useState = React$2.useState(function () {
|
|
11311
|
+
if (open && smoothTransitioning) {
|
|
11312
|
+
return Mode.Opening;
|
|
11313
|
+
}
|
|
11314
|
+
|
|
11315
|
+
if (open && !smoothTransitioning) {
|
|
11316
|
+
return Mode.Open;
|
|
11317
|
+
}
|
|
11318
|
+
|
|
11319
|
+
if (autoPreview) {
|
|
11320
|
+
return Mode.AutoOpening;
|
|
11321
|
+
}
|
|
11322
|
+
|
|
11323
|
+
return Mode.Closed;
|
|
11324
|
+
}),
|
|
11281
11325
|
_useState2 = _slicedToArray(_useState, 2),
|
|
11282
|
-
|
|
11283
|
-
|
|
11326
|
+
mode = _useState2[0],
|
|
11327
|
+
setMode = _useState2[1];
|
|
11284
11328
|
|
|
11285
11329
|
var timeout = React$2.useRef(null);
|
|
11286
11330
|
var handleMouseEnter = React$2.useCallback(function () {
|
|
11287
11331
|
if (!open) {
|
|
11288
11332
|
timeout.current && clearTimeout(timeout.current);
|
|
11289
|
-
|
|
11333
|
+
setMode(smoothTransitioning ? Mode.Opening : Mode.Open);
|
|
11290
11334
|
}
|
|
11291
|
-
}, [open]);
|
|
11335
|
+
}, [open, smoothTransitioning]);
|
|
11292
11336
|
var handleMouseLeave = React$2.useCallback(function () {
|
|
11293
|
-
if (
|
|
11294
|
-
|
|
11295
|
-
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
|
|
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]);
|
|
11342
|
+
React$2.useEffect(function () {
|
|
11343
|
+
if (mode !== Mode.Closing) return;
|
|
11344
|
+
var closingTimeout = setTimeout(function () {
|
|
11345
|
+
return setMode(Mode.Closed);
|
|
11346
|
+
}, 750);
|
|
11347
|
+
return function () {
|
|
11348
|
+
return clearTimeout(closingTimeout);
|
|
11349
|
+
};
|
|
11350
|
+
}, [mode]);
|
|
11351
|
+
React$2.useEffect(function () {
|
|
11352
|
+
if (mode !== Mode.AutoOpening) return;
|
|
11353
|
+
var openingTimeout = setTimeout(function () {
|
|
11354
|
+
return setMode(Mode.AutoOpen);
|
|
11355
|
+
}, 1000);
|
|
11356
|
+
return function () {
|
|
11357
|
+
return clearTimeout(openingTimeout);
|
|
11358
|
+
};
|
|
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]);
|
|
11369
|
+
React$2.useEffect(function () {
|
|
11370
|
+
if (mode !== Mode.AutoOpen) return;
|
|
11371
|
+
var stayingTimeout = setTimeout(function () {
|
|
11372
|
+
return setMode(smoothTransitioning ? Mode.Closing : Mode.Closed);
|
|
11373
|
+
}, 5000);
|
|
11374
|
+
return function () {
|
|
11375
|
+
return clearTimeout(stayingTimeout);
|
|
11376
|
+
};
|
|
11377
|
+
}, [mode, smoothTransitioning]);
|
|
11299
11378
|
React$2.useEffect(function () {
|
|
11300
|
-
|
|
11301
|
-
|
|
11379
|
+
if (!open) return;
|
|
11380
|
+
|
|
11381
|
+
if (smoothTransitioning) {
|
|
11382
|
+
setMode(Mode.Opening);
|
|
11383
|
+
}
|
|
11384
|
+
|
|
11385
|
+
setMode(Mode.Open);
|
|
11386
|
+
}, [mode, open]);
|
|
11387
|
+
var isOpen = mode === Mode.AutoOpen || mode === Mode.Opening || mode === Mode.Open || mode === Mode.Closing;
|
|
11302
11388
|
return /*#__PURE__*/React__default["default"].createElement("div", _extends$3({
|
|
11303
11389
|
className: classNames("Popover Popover--anchor-".concat(anchor), className),
|
|
11304
11390
|
onMouseEnter: handleMouseEnter,
|
|
11305
11391
|
onMouseLeave: handleMouseLeave
|
|
11306
11392
|
}, rest), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
11307
11393
|
className: "Popover__trigger"
|
|
11308
|
-
}, isOpen && /*#__PURE__*/React__default["default"].createElement(
|
|
11394
|
+
}, isOpen && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
11395
|
+
className: classNames('Popover__box', {
|
|
11396
|
+
'Popover__box--opening': mode === Mode.Opening,
|
|
11397
|
+
'Popover__box--closing': mode === Mode.Closing
|
|
11398
|
+
})
|
|
11399
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
11309
11400
|
className: "Popover__caret",
|
|
11310
11401
|
style: {
|
|
11311
11402
|
zIndex: zIndex != null ? zIndex + 1 : undefined
|