@ringcentral/juno 2.40.0 → 2.40.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.
@@ -24,15 +24,33 @@ var _RcTooltip = react_1.forwardRef(function (inProps, ref) {
24
24
  classNameProp = props.className, classesProp = props.classes, PopperPropsProp = props.PopperProps, textColor = props.textColor, color = props.color, ignorePointer = props.ignorePointer, size = props.size, maskProps = props.maskProps, title = props.title, injectGlobalStyle = props.injectGlobalStyle, rest = tslib_1.__rest(props, ["children", "tooltipForceHide", "open", "onOpen", "onClose", "className", "classes", "PopperProps", "textColor", "color", "ignorePointer", "size", "maskProps", "title", "injectGlobalStyle"]);
25
25
  var externalWindow = foundation_1.useRcPortalWindowContext().externalWindow;
26
26
  var _a = tslib_1.__read(react_1.useState(false), 2), isDisabledButton = _a[0], setIsDisabledButton = _a[1];
27
+ var popperInnerRef = react_1.useRef(null);
27
28
  var innerRef = react_1.useRef(null);
28
29
  var tooltipRef = foundation_1.useForkRef(ref, innerRef);
29
30
  var classes = react_1.useMemo(function () {
30
31
  return foundation_1.combineClasses(foundation_1.combineClasses({ popper: classNameProp }, utils_1.RcTooltipClasses), classesProp);
31
32
  }, [classNameProp, classesProp]);
32
33
  var PopperProps = react_1.useMemo(function () {
33
- return foundation_1.combineProps({
34
+ var _a = PopperPropsProp || {}, tooltipPopperRef = _a.ref, restPopperPropsProp = tslib_1.__rest(_a, ["ref"]);
35
+ return tslib_1.__assign(tslib_1.__assign({}, foundation_1.combineProps({
34
36
  container: externalWindow === null || externalWindow === void 0 ? void 0 : externalWindow.document.body,
35
- }, PopperPropsProp);
37
+ popperOptions: {
38
+ // when popper update position, if left < 0 and top <= 0, that means popper is out of window
39
+ // that occur when use not destroy component, use style hidden, host element be disappear, but popper still exist
40
+ onUpdate: function (e) {
41
+ var tooltipElm = popperInnerRef === null || popperInnerRef === void 0 ? void 0 : popperInnerRef.current;
42
+ if (tooltipElm &&
43
+ e.popper &&
44
+ e.popper.left < 0 &&
45
+ e.popper.top <= 0) {
46
+ tooltipElm.style.display = 'none';
47
+ }
48
+ },
49
+ },
50
+ }, restPopperPropsProp)), { ref: function (elm) {
51
+ popperInnerRef.current = elm;
52
+ foundation_1.setRef(tooltipPopperRef, elm);
53
+ } });
36
54
  }, [PopperPropsProp, externalWindow === null || externalWindow === void 0 ? void 0 : externalWindow.document.body]);
37
55
  var forceHideAdditionProps = utils_1.useTooltipForceHide({
38
56
  ref: innerRef,
@@ -1,7 +1,7 @@
1
1
  import { __assign, __makeTemplateObject, __read, __rest } from "tslib";
2
2
  import React, { forwardRef, useLayoutEffect, useMemo, useRef, useState, } from 'react';
3
3
  import MuiTooltip from '@material-ui/core/Tooltip';
4
- import { combineClasses, combineProps, logInDev, styled, useDeprecatedCheck, useForkRef, useRcPortalWindowContext, useThemeProps, } from '../../foundation';
4
+ import { combineClasses, combineProps, logInDev, styled, useDeprecatedCheck, useForkRef, useRcPortalWindowContext, useThemeProps, setRef, } from '../../foundation';
5
5
  import { Mask, tooltipStyle } from './styles';
6
6
  import { RcTooltipClasses, useTooltipForceHide } from './utils';
7
7
  var _RcTooltip = forwardRef(function (inProps, ref) {
@@ -22,15 +22,33 @@ var _RcTooltip = forwardRef(function (inProps, ref) {
22
22
  classNameProp = props.className, classesProp = props.classes, PopperPropsProp = props.PopperProps, textColor = props.textColor, color = props.color, ignorePointer = props.ignorePointer, size = props.size, maskProps = props.maskProps, title = props.title, injectGlobalStyle = props.injectGlobalStyle, rest = __rest(props, ["children", "tooltipForceHide", "open", "onOpen", "onClose", "className", "classes", "PopperProps", "textColor", "color", "ignorePointer", "size", "maskProps", "title", "injectGlobalStyle"]);
23
23
  var externalWindow = useRcPortalWindowContext().externalWindow;
24
24
  var _a = __read(useState(false), 2), isDisabledButton = _a[0], setIsDisabledButton = _a[1];
25
+ var popperInnerRef = useRef(null);
25
26
  var innerRef = useRef(null);
26
27
  var tooltipRef = useForkRef(ref, innerRef);
27
28
  var classes = useMemo(function () {
28
29
  return combineClasses(combineClasses({ popper: classNameProp }, RcTooltipClasses), classesProp);
29
30
  }, [classNameProp, classesProp]);
30
31
  var PopperProps = useMemo(function () {
31
- return combineProps({
32
+ var _a = PopperPropsProp || {}, tooltipPopperRef = _a.ref, restPopperPropsProp = __rest(_a, ["ref"]);
33
+ return __assign(__assign({}, combineProps({
32
34
  container: externalWindow === null || externalWindow === void 0 ? void 0 : externalWindow.document.body,
33
- }, PopperPropsProp);
35
+ popperOptions: {
36
+ // when popper update position, if left < 0 and top <= 0, that means popper is out of window
37
+ // that occur when use not destroy component, use style hidden, host element be disappear, but popper still exist
38
+ onUpdate: function (e) {
39
+ var tooltipElm = popperInnerRef === null || popperInnerRef === void 0 ? void 0 : popperInnerRef.current;
40
+ if (tooltipElm &&
41
+ e.popper &&
42
+ e.popper.left < 0 &&
43
+ e.popper.top <= 0) {
44
+ tooltipElm.style.display = 'none';
45
+ }
46
+ },
47
+ },
48
+ }, restPopperPropsProp)), { ref: function (elm) {
49
+ popperInnerRef.current = elm;
50
+ setRef(tooltipPopperRef, elm);
51
+ } });
34
52
  }, [PopperPropsProp, externalWindow === null || externalWindow === void 0 ? void 0 : externalWindow.document.body]);
35
53
  var forceHideAdditionProps = useTooltipForceHide({
36
54
  ref: innerRef,
@@ -1,4 +1,4 @@
1
- import { useForkRef as MuiUseForkRef } from '@material-ui/core/utils';
1
+ import { useForkRef as MuiUseForkRef, setRef as MuiSetRef, } from '@material-ui/core/utils';
2
2
  /**
3
3
  * That method will give you ability fork same value `ref object` or `method`
4
4
  * Example:
@@ -17,3 +17,4 @@ import { useForkRef as MuiUseForkRef } from '@material-ui/core/utils';
17
17
  * ```
18
18
  */
19
19
  export var useForkRef = MuiUseForkRef;
20
+ export var setRef = MuiSetRef;
@@ -1,4 +1,4 @@
1
- import { useForkRef as MuiUseForkRef } from '@material-ui/core/utils';
1
+ import { useForkRef as MuiUseForkRef, setRef as MuiSetRef } from '@material-ui/core/utils';
2
2
  /**
3
3
  * That method will give you ability fork same value `ref object` or `method`
4
4
  * Example:
@@ -17,3 +17,4 @@ import { useForkRef as MuiUseForkRef } from '@material-ui/core/utils';
17
17
  * ```
18
18
  */
19
19
  export declare const useForkRef: typeof MuiUseForkRef;
20
+ export declare const setRef: typeof MuiSetRef;
@@ -19,3 +19,4 @@ var utils_1 = require("@material-ui/core/utils");
19
19
  * ```
20
20
  */
21
21
  exports.useForkRef = utils_1.useForkRef;
22
+ exports.setRef = utils_1.setRef;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ringcentral/juno",
3
- "version": "2.40.0",
3
+ "version": "2.40.1",
4
4
  "author": "RingCentral",
5
5
  "license": "MIT",
6
6
  "main": "./index.js",