@clayui/tooltip 3.78.2 → 3.79.0
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/lib/TooltipProvider.js +8 -7
- package/lib/useAlign.d.ts +2 -1
- package/lib/useAlign.js +4 -3
- package/package.json +3 -3
- package/src/TooltipProvider.tsx +6 -5
- package/src/useAlign.ts +9 -2
package/lib/TooltipProvider.js
CHANGED
|
@@ -54,8 +54,8 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
54
54
|
var initialState = {
|
|
55
55
|
align: 'top',
|
|
56
56
|
floating: false,
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
setAsHTML: false,
|
|
58
|
+
title: ''
|
|
59
59
|
};
|
|
60
60
|
var TRIGGER_HIDE_EVENTS = ['dragstart', 'mouseout', 'mouseup', 'pointerup', 'touchend'];
|
|
61
61
|
var TRIGGER_SHOW_EVENTS = ['mouseover', 'mouseup', 'pointerdown', 'touchstart'];
|
|
@@ -98,9 +98,9 @@ var TooltipProvider = function TooltipProvider(_ref2) {
|
|
|
98
98
|
_useReducer2$ = _useReducer2[0],
|
|
99
99
|
align = _useReducer2$.align,
|
|
100
100
|
floating = _useReducer2$.floating,
|
|
101
|
-
_useReducer2$$message = _useReducer2$.message,
|
|
102
|
-
message = _useReducer2$$message === void 0 ? '' : _useReducer2$$message,
|
|
103
101
|
setAsHTML = _useReducer2$.setAsHTML,
|
|
102
|
+
_useReducer2$$title = _useReducer2$.title,
|
|
103
|
+
title = _useReducer2$$title === void 0 ? '' : _useReducer2$$title,
|
|
104
104
|
dispatch = _useReducer2[1];
|
|
105
105
|
|
|
106
106
|
var tooltipRef = (0, _react.useRef)(null);
|
|
@@ -151,7 +151,8 @@ var TooltipProvider = function TooltipProvider(_ref2) {
|
|
|
151
151
|
});
|
|
152
152
|
}, []),
|
|
153
153
|
sourceElement: tooltipRef,
|
|
154
|
-
targetElement: titleNode
|
|
154
|
+
targetElement: titleNode,
|
|
155
|
+
title: title
|
|
155
156
|
});
|
|
156
157
|
var onShow = (0, _react.useCallback)(function (event) {
|
|
157
158
|
if (isHovered.current || isFocused.current) {
|
|
@@ -163,8 +164,8 @@ var TooltipProvider = function TooltipProvider(_ref2) {
|
|
|
163
164
|
dispatch({
|
|
164
165
|
align: (_ref3 = _props.align) !== null && _ref3 !== void 0 ? _ref3 : align,
|
|
165
166
|
floating: _props.floating,
|
|
166
|
-
message: _props.title,
|
|
167
167
|
setAsHTML: _props.setAsHTML,
|
|
168
|
+
title: _props.title,
|
|
168
169
|
type: 'update'
|
|
169
170
|
});
|
|
170
171
|
open(isFocused.current, _props.delay ? Number(_props.delay) : undefined);
|
|
@@ -243,7 +244,7 @@ var TooltipProvider = function TooltipProvider(_ref2) {
|
|
|
243
244
|
"production" !== "production" ? (0, _warning.default)((children === null || children === void 0 ? void 0 : children.type) !== _react.default.Fragment, '<TooltipProvider />: React Fragment is not allowed as a child to TooltipProvider. Child must be a single HTML element that accepts `onMouseOver` and `onMouseOut`.') : void 0;
|
|
244
245
|
var titleContent = contentRenderer({
|
|
245
246
|
targetNode: target.current,
|
|
246
|
-
title:
|
|
247
|
+
title: title
|
|
247
248
|
});
|
|
248
249
|
|
|
249
250
|
var tooltip = isOpen && /*#__PURE__*/_react.default.createElement(_shared.ClayPortal, containerProps, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
|
package/lib/useAlign.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ declare type Props = {
|
|
|
13
13
|
onAlign: (align: Align) => void;
|
|
14
14
|
sourceElement: React.MutableRefObject<HTMLElement | null>;
|
|
15
15
|
targetElement: React.MutableRefObject<HTMLElement | null>;
|
|
16
|
+
title: string;
|
|
16
17
|
};
|
|
17
|
-
export declare function useAlign({ align, autoAlign, floating, isOpen, onAlign, sourceElement, targetElement, }: Props): void;
|
|
18
|
+
export declare function useAlign({ align, autoAlign, floating, isOpen, onAlign, sourceElement, targetElement, title, }: Props): void;
|
|
18
19
|
export {};
|
package/lib/useAlign.js
CHANGED
|
@@ -77,7 +77,8 @@ function useAlign(_ref) {
|
|
|
77
77
|
isOpen = _ref.isOpen,
|
|
78
78
|
onAlign = _ref.onAlign,
|
|
79
79
|
sourceElement = _ref.sourceElement,
|
|
80
|
-
targetElement = _ref.targetElement
|
|
80
|
+
targetElement = _ref.targetElement,
|
|
81
|
+
title = _ref.title;
|
|
81
82
|
var mousePosition = (0, _shared.useMousePosition)(20);
|
|
82
83
|
(0, _react.useEffect)(function () {
|
|
83
84
|
if (sourceElement.current && isOpen && floating) {
|
|
@@ -97,7 +98,7 @@ function useAlign(_ref) {
|
|
|
97
98
|
}
|
|
98
99
|
}, [isOpen, floating]);
|
|
99
100
|
(0, _react.useEffect)(function () {
|
|
100
|
-
if (targetElement.current && sourceElement.current && !floating) {
|
|
101
|
+
if (targetElement.current && sourceElement.current && isOpen && !floating) {
|
|
101
102
|
var points = ALIGNMENTS_MAP[align || 'top'];
|
|
102
103
|
var alignment = (0, _shared.doAlign)({
|
|
103
104
|
overflow: {
|
|
@@ -117,5 +118,5 @@ function useAlign(_ref) {
|
|
|
117
118
|
onAlign(ALIGNMENTS_INVERSE_MAP[alignmentString]);
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
|
-
}, [align, isOpen]);
|
|
121
|
+
}, [align, title, isOpen]);
|
|
121
122
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clayui/tooltip",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.79.0",
|
|
4
4
|
"description": "ClayTooltip component",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"repository": "https://github.com/liferay/clay",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"react"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@clayui/shared": "^3.
|
|
29
|
+
"@clayui/shared": "^3.79.0",
|
|
30
30
|
"classnames": "^2.2.6",
|
|
31
31
|
"dom-align": "^1.12.2",
|
|
32
32
|
"warning": "^4.0.3"
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"browserslist": [
|
|
40
40
|
"extends browserslist-config-clay"
|
|
41
41
|
],
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "4bf7ee4967efc6c2c46aee28b69569f764a1926c"
|
|
43
43
|
}
|
package/src/TooltipProvider.tsx
CHANGED
|
@@ -21,15 +21,15 @@ import {useTooltipState} from './useTooltipState';
|
|
|
21
21
|
interface IState {
|
|
22
22
|
align: Align;
|
|
23
23
|
floating: boolean;
|
|
24
|
-
message?: string;
|
|
25
24
|
setAsHTML?: boolean;
|
|
25
|
+
title?: string;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const initialState: IState = {
|
|
29
29
|
align: 'top',
|
|
30
30
|
floating: false,
|
|
31
|
-
message: '',
|
|
32
31
|
setAsHTML: false,
|
|
32
|
+
title: '',
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
const TRIGGER_HIDE_EVENTS = [
|
|
@@ -117,7 +117,7 @@ const TooltipProvider = ({
|
|
|
117
117
|
delay = 600,
|
|
118
118
|
scope,
|
|
119
119
|
}: IPropsWithChildren | IPropsWithScope) => {
|
|
120
|
-
const [{align, floating,
|
|
120
|
+
const [{align, floating, setAsHTML, title = ''}, dispatch] = useReducer(
|
|
121
121
|
reducer,
|
|
122
122
|
initialState
|
|
123
123
|
);
|
|
@@ -153,6 +153,7 @@ const TooltipProvider = ({
|
|
|
153
153
|
onAlign: useCallback((align) => dispatch({align, type: 'update'}), []),
|
|
154
154
|
sourceElement: tooltipRef,
|
|
155
155
|
targetElement: titleNode,
|
|
156
|
+
title,
|
|
156
157
|
});
|
|
157
158
|
|
|
158
159
|
const onShow = useCallback(
|
|
@@ -164,8 +165,8 @@ const TooltipProvider = ({
|
|
|
164
165
|
dispatch({
|
|
165
166
|
align: (props.align as any) ?? align,
|
|
166
167
|
floating: props.floating,
|
|
167
|
-
message: props.title,
|
|
168
168
|
setAsHTML: props.setAsHTML,
|
|
169
|
+
title: props.title,
|
|
169
170
|
type: 'update',
|
|
170
171
|
});
|
|
171
172
|
open(
|
|
@@ -281,7 +282,7 @@ const TooltipProvider = ({
|
|
|
281
282
|
|
|
282
283
|
const titleContent = contentRenderer({
|
|
283
284
|
targetNode: target.current,
|
|
284
|
-
title
|
|
285
|
+
title,
|
|
285
286
|
});
|
|
286
287
|
|
|
287
288
|
const tooltip = isOpen && (
|
package/src/useAlign.ts
CHANGED
|
@@ -72,6 +72,7 @@ type Props = {
|
|
|
72
72
|
onAlign: (align: Align) => void;
|
|
73
73
|
sourceElement: React.MutableRefObject<HTMLElement | null>;
|
|
74
74
|
targetElement: React.MutableRefObject<HTMLElement | null>;
|
|
75
|
+
title: string;
|
|
75
76
|
};
|
|
76
77
|
|
|
77
78
|
export function useAlign({
|
|
@@ -82,6 +83,7 @@ export function useAlign({
|
|
|
82
83
|
onAlign,
|
|
83
84
|
sourceElement,
|
|
84
85
|
targetElement,
|
|
86
|
+
title,
|
|
85
87
|
}: Props) {
|
|
86
88
|
const mousePosition = useMousePosition(20);
|
|
87
89
|
|
|
@@ -108,7 +110,12 @@ export function useAlign({
|
|
|
108
110
|
}, [isOpen, floating]);
|
|
109
111
|
|
|
110
112
|
useEffect(() => {
|
|
111
|
-
if (
|
|
113
|
+
if (
|
|
114
|
+
targetElement.current &&
|
|
115
|
+
sourceElement.current &&
|
|
116
|
+
isOpen &&
|
|
117
|
+
!floating
|
|
118
|
+
) {
|
|
112
119
|
const points = ALIGNMENTS_MAP[align || 'top'] as [string, string];
|
|
113
120
|
|
|
114
121
|
const alignment = doAlign({
|
|
@@ -133,5 +140,5 @@ export function useAlign({
|
|
|
133
140
|
onAlign(ALIGNMENTS_INVERSE_MAP[alignmentString]);
|
|
134
141
|
}
|
|
135
142
|
}
|
|
136
|
-
}, [align, isOpen]);
|
|
143
|
+
}, [align, title, isOpen]);
|
|
137
144
|
}
|