@occmundial/occ-atomic 1.32.0 → 1.32.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/build/Tooltip/Tooltip.js +8 -1
- package/build/Tooltip/hooks.js +48 -48
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [1.32.1](https://github.com/occmundial/occ-atomic/compare/v1.32.0...v1.32.1) (2023-05-31)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* Tooltip close delay ([76c2c6b](https://github.com/occmundial/occ-atomic/commit/76c2c6b604193aff5d80668fe7a412c6778ca46b))
|
7
|
+
|
1
8
|
# [1.32.0](https://github.com/occmundial/occ-atomic/compare/v1.31.0...v1.32.0) (2023-05-26)
|
2
9
|
|
3
10
|
|
package/build/Tooltip/Tooltip.js
CHANGED
@@ -80,6 +80,8 @@ function Tooltip(_ref) {
|
|
80
80
|
fit = _ref$fit === void 0 ? false : _ref$fit,
|
81
81
|
_ref$width = _ref.width,
|
82
82
|
width = _ref$width === void 0 ? 220 : _ref$width,
|
83
|
+
_ref$strategy = _ref.strategy,
|
84
|
+
strategy = _ref$strategy === void 0 ? 'absolute' : _ref$strategy,
|
83
85
|
onChange = _ref.onChange;
|
84
86
|
var arrowRef = (0, _react.useRef)(null);
|
85
87
|
|
@@ -120,6 +122,7 @@ function Tooltip(_ref) {
|
|
120
122
|
open: open,
|
121
123
|
onOpenChange: setOpen,
|
122
124
|
placement: placement,
|
125
|
+
strategy: strategy,
|
123
126
|
whileElementsMounted: _react2.autoUpdate,
|
124
127
|
middleware: getMiddlewares
|
125
128
|
}),
|
@@ -146,7 +149,8 @@ function Tooltip(_ref) {
|
|
146
149
|
className: "".concat(classes.tooltip, " ").concat(className.hasOwnProperty('tooltip') && className.tooltip, " ").concat(classes[theme] || classes.purple),
|
147
150
|
ref: refs.setFloating,
|
148
151
|
style: _objectSpread(_objectSpread({}, floatingStyles), {}, {
|
149
|
-
zIndex: zIndex
|
152
|
+
zIndex: zIndex,
|
153
|
+
position: strategy
|
150
154
|
})
|
151
155
|
}, getFloatingProps()), text, showArrow && /*#__PURE__*/_react["default"].createElement(_react2.FloatingArrow, {
|
152
156
|
ref: arrowRef,
|
@@ -196,6 +200,9 @@ Tooltip.propTypes = {
|
|
196
200
|
/** The "Width" property of the Tooltip enables modification of its width and accepts a number (e.g., 220), a string (e.g., '220px' or 'auto') or null as its value. */
|
197
201
|
width: _propTypes["default"].number,
|
198
202
|
|
203
|
+
/** The CSS position property to use to compute the tooltip position */
|
204
|
+
strategy: _propTypes["default"].oneOf(['absolute', 'fixed']),
|
205
|
+
|
199
206
|
/** Callback fired when the Tooltip show state changes. */
|
200
207
|
onChange: _propTypes["default"].func
|
201
208
|
};
|
package/build/Tooltip/hooks.js
CHANGED
@@ -21,10 +21,12 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
21
21
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
22
22
|
|
23
23
|
function useOpenTooltipState(openExternal, setOpenExternal, closeDelay) {
|
24
|
-
var
|
24
|
+
var _useThrottle = useThrottle({
|
25
25
|
trailing: true,
|
26
26
|
leading: false
|
27
|
-
})
|
27
|
+
}),
|
28
|
+
throttle = _useThrottle.throttle,
|
29
|
+
cancel = _useThrottle.cancel;
|
28
30
|
|
29
31
|
var _useState = (0, _react.useState)(false),
|
30
32
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -37,20 +39,18 @@ function useOpenTooltipState(openExternal, setOpenExternal, closeDelay) {
|
|
37
39
|
var setOpenSource = (0, _react.useMemo)(function () {
|
38
40
|
return openExternal !== undefined ? setOpenExternal !== null && setOpenExternal !== void 0 ? setOpenExternal : function () {} : setOpenInternal;
|
39
41
|
}, [openExternal, setOpenExternal, setOpenInternal]);
|
40
|
-
var setOpenSourceDelay = (0, _react.
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
if (open) {
|
53
|
-
delay.cancel();
|
42
|
+
var setOpenSourceDelay = (0, _react.useCallback)(function (show) {
|
43
|
+
throttle({
|
44
|
+
throttleTime: closeDelay,
|
45
|
+
callback: function callback() {
|
46
|
+
return setOpenSource(show);
|
47
|
+
}
|
48
|
+
});
|
49
|
+
}, [closeDelay, setOpenSource, throttle]);
|
50
|
+
|
51
|
+
function setOpen(openValue) {
|
52
|
+
if (openValue) {
|
53
|
+
if (open) cancel();
|
54
54
|
setOpenSource(true);
|
55
55
|
} else {
|
56
56
|
closeDelay > 0 ? setOpenSourceDelay(false) : setOpenSource(false);
|
@@ -58,10 +58,14 @@ function useOpenTooltipState(openExternal, setOpenExternal, closeDelay) {
|
|
58
58
|
}
|
59
59
|
|
60
60
|
(0, _react.useEffect)(function () {
|
61
|
-
if (
|
62
|
-
|
63
|
-
|
64
|
-
|
61
|
+
if (closeDelay <= 0) return;
|
62
|
+
|
63
|
+
if (openExternal === false) {
|
64
|
+
cancel();
|
65
|
+
} else {
|
66
|
+
setOpenSourceDelay(false);
|
67
|
+
}
|
68
|
+
}, [openExternal, setOpenSourceDelay, setOpenSource, closeDelay, cancel]);
|
65
69
|
return [open, setOpen];
|
66
70
|
}
|
67
71
|
|
@@ -70,8 +74,20 @@ function useThrottle() {
|
|
70
74
|
var timeout = (0, _react.useRef)(null);
|
71
75
|
var lastCallback = (0, _react.useRef)(null);
|
72
76
|
var date = (0, _react.useRef)(null);
|
73
|
-
|
74
|
-
|
77
|
+
var cancel = (0, _react.useCallback)(function () {
|
78
|
+
if (!timeout.current) return;
|
79
|
+
window.clearTimeout(timeout.current);
|
80
|
+
timeout.current = null;
|
81
|
+
date.current = null;
|
82
|
+
}, []);
|
83
|
+
var flush = (0, _react.useCallback)(function () {
|
84
|
+
if (!lastCallback.current) return;
|
85
|
+
lastCallback.current();
|
86
|
+
lastCallback.current = null;
|
87
|
+
date.current = null;
|
88
|
+
cancel();
|
89
|
+
}, [cancel]);
|
90
|
+
var throttle = (0, _react.useCallback)(function (_ref) {
|
75
91
|
var _ref4;
|
76
92
|
|
77
93
|
var callback = _ref.callback,
|
@@ -100,33 +116,17 @@ function useThrottle() {
|
|
100
116
|
|
101
117
|
((_defaults$trailing = defaults === null || defaults === void 0 ? void 0 : defaults.trailing) !== null && _defaults$trailing !== void 0 ? _defaults$trailing : trailing) ? flush() : cancel();
|
102
118
|
}, (_ref4 = throttleTime !== null && throttleTime !== void 0 ? throttleTime : defaults.throttleTime) !== null && _ref4 !== void 0 ? _ref4 : 1000);
|
103
|
-
}
|
104
|
-
|
105
|
-
function flush() {
|
106
|
-
if (!lastCallback.current) return;
|
107
|
-
lastCallback.current();
|
108
|
-
lastCallback.current = null;
|
109
|
-
date.current = null;
|
110
|
-
cancel();
|
111
|
-
}
|
112
|
-
|
113
|
-
function cancel() {
|
114
|
-
if (!timeout.current) return;
|
115
|
-
window.clearTimeout(timeout.current);
|
116
|
-
timeout.current = null;
|
117
|
-
date.current = null;
|
118
|
-
}
|
119
|
-
|
119
|
+
}, [cancel, defaults.callback, defaults === null || defaults === void 0 ? void 0 : defaults.leading, defaults.throttleTime, defaults === null || defaults === void 0 ? void 0 : defaults.trailing, flush]);
|
120
120
|
(0, _react.useEffect)(function () {
|
121
121
|
return cancel;
|
122
|
-
}, []);
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
122
|
+
}, [cancel]);
|
123
|
+
return {
|
124
|
+
throttle: throttle,
|
125
|
+
flush: flush,
|
126
|
+
cancel: cancel,
|
127
|
+
isActive: function isActive() {
|
128
|
+
return !!date.current;
|
129
|
+
},
|
130
|
+
date: date
|
129
131
|
};
|
130
|
-
|
131
|
-
return throttle;
|
132
132
|
}
|
package/package.json
CHANGED