rc-tooltip
Advanced tools
Comparing version 3.7.3 to 4.0.0-alpha.0
@@ -1,46 +0,14 @@ | ||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; | ||
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; | ||
import _inherits from 'babel-runtime/helpers/inherits'; | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
var Content = function (_React$Component) { | ||
_inherits(Content, _React$Component); | ||
var Content = function Content(props) { | ||
var overlay = props.overlay, | ||
prefixCls = props.prefixCls, | ||
id = props.id; | ||
return React.createElement("div", { | ||
className: "".concat(prefixCls, "-inner"), | ||
id: id, | ||
role: "tooltip" | ||
}, typeof overlay === 'function' ? overlay() : overlay); | ||
}; | ||
function Content() { | ||
_classCallCheck(this, Content); | ||
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); | ||
} | ||
Content.prototype.componentDidUpdate = function componentDidUpdate() { | ||
var trigger = this.props.trigger; | ||
if (trigger) { | ||
trigger.forcePopupAlign(); | ||
} | ||
}; | ||
Content.prototype.render = function render() { | ||
var _props = this.props, | ||
overlay = _props.overlay, | ||
prefixCls = _props.prefixCls, | ||
id = _props.id; | ||
return React.createElement( | ||
'div', | ||
{ className: prefixCls + '-inner', id: id, role: 'tooltip' }, | ||
typeof overlay === 'function' ? overlay() : overlay | ||
); | ||
}; | ||
return Content; | ||
}(React.Component); | ||
Content.propTypes = { | ||
prefixCls: PropTypes.string, | ||
overlay: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired, | ||
id: PropTypes.string, | ||
trigger: PropTypes.any | ||
}; | ||
export default Content; |
import Tooltip from './Tooltip'; | ||
export default Tooltip; |
@@ -5,5 +5,3 @@ var autoAdjustOverflow = { | ||
}; | ||
var targetOffset = [0, 0]; | ||
export var placements = { | ||
@@ -83,3 +81,2 @@ left: { | ||
}; | ||
export default placements; |
@@ -1,8 +0,12 @@ | ||
import _extends from 'babel-runtime/helpers/extends'; | ||
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; | ||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; | ||
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; | ||
import _inherits from 'babel-runtime/helpers/inherits'; | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
import React, { useRef, useImperativeHandle, forwardRef } from 'react'; | ||
import Trigger from 'rc-trigger'; | ||
@@ -12,128 +16,77 @@ import { placements } from './placements'; | ||
var Tooltip = function (_Component) { | ||
_inherits(Tooltip, _Component); | ||
var Tooltip = function Tooltip(props, ref) { | ||
var overlayClassName = props.overlayClassName, | ||
_props$trigger = props.trigger, | ||
trigger = _props$trigger === void 0 ? ['hover'] : _props$trigger, | ||
_props$mouseEnterDela = props.mouseEnterDelay, | ||
mouseEnterDelay = _props$mouseEnterDela === void 0 ? 0 : _props$mouseEnterDela, | ||
_props$mouseLeaveDela = props.mouseLeaveDelay, | ||
mouseLeaveDelay = _props$mouseLeaveDela === void 0 ? 0.1 : _props$mouseLeaveDela, | ||
overlayStyle = props.overlayStyle, | ||
_props$prefixCls = props.prefixCls, | ||
prefixCls = _props$prefixCls === void 0 ? 'rc-tooltip' : _props$prefixCls, | ||
children = props.children, | ||
onVisibleChange = props.onVisibleChange, | ||
afterVisibleChange = props.afterVisibleChange, | ||
transitionName = props.transitionName, | ||
animation = props.animation, | ||
_props$placement = props.placement, | ||
placement = _props$placement === void 0 ? 'right' : _props$placement, | ||
_props$align = props.align, | ||
align = _props$align === void 0 ? {} : _props$align, | ||
_props$destroyTooltip = props.destroyTooltipOnHide, | ||
destroyTooltipOnHide = _props$destroyTooltip === void 0 ? false : _props$destroyTooltip, | ||
defaultVisible = props.defaultVisible, | ||
getTooltipContainer = props.getTooltipContainer, | ||
restProps = _objectWithoutProperties(props, ["overlayClassName", "trigger", "mouseEnterDelay", "mouseLeaveDelay", "overlayStyle", "prefixCls", "children", "onVisibleChange", "afterVisibleChange", "transitionName", "animation", "placement", "align", "destroyTooltipOnHide", "defaultVisible", "getTooltipContainer"]); | ||
function Tooltip() { | ||
var _temp, _this, _ret; | ||
var domRef = useRef(null); | ||
useImperativeHandle(ref, function () { | ||
return domRef.current; | ||
}); | ||
_classCallCheck(this, Tooltip); | ||
var extraProps = _objectSpread({}, restProps); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.getPopupElement = function () { | ||
var _this$props = _this.props, | ||
arrowContent = _this$props.arrowContent, | ||
overlay = _this$props.overlay, | ||
prefixCls = _this$props.prefixCls, | ||
id = _this$props.id; | ||
return [React.createElement( | ||
'div', | ||
{ className: prefixCls + '-arrow', key: 'arrow' }, | ||
arrowContent | ||
), React.createElement(Content, { | ||
key: 'content', | ||
trigger: _this.trigger, | ||
prefixCls: prefixCls, | ||
id: id, | ||
overlay: overlay | ||
})]; | ||
}, _this.saveTrigger = function (node) { | ||
_this.trigger = node; | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
if ('visible' in props) { | ||
extraProps.popupVisible = props.visible; | ||
} | ||
Tooltip.prototype.getPopupDomNode = function getPopupDomNode() { | ||
return this.trigger.getPopupDomNode(); | ||
var getPopupElement = function getPopupElement() { | ||
var _props$arrowContent = props.arrowContent, | ||
arrowContent = _props$arrowContent === void 0 ? null : _props$arrowContent, | ||
overlay = props.overlay, | ||
id = props.id; | ||
return [React.createElement("div", { | ||
className: "".concat(prefixCls, "-arrow"), | ||
key: "arrow" | ||
}, arrowContent), React.createElement(Content, { | ||
key: "content", | ||
prefixCls: prefixCls, | ||
id: id, | ||
overlay: overlay | ||
})]; | ||
}; | ||
Tooltip.prototype.render = function render() { | ||
var _props = this.props, | ||
overlayClassName = _props.overlayClassName, | ||
trigger = _props.trigger, | ||
mouseEnterDelay = _props.mouseEnterDelay, | ||
mouseLeaveDelay = _props.mouseLeaveDelay, | ||
overlayStyle = _props.overlayStyle, | ||
prefixCls = _props.prefixCls, | ||
children = _props.children, | ||
onVisibleChange = _props.onVisibleChange, | ||
afterVisibleChange = _props.afterVisibleChange, | ||
transitionName = _props.transitionName, | ||
animation = _props.animation, | ||
placement = _props.placement, | ||
align = _props.align, | ||
destroyTooltipOnHide = _props.destroyTooltipOnHide, | ||
defaultVisible = _props.defaultVisible, | ||
getTooltipContainer = _props.getTooltipContainer, | ||
restProps = _objectWithoutProperties(_props, ['overlayClassName', 'trigger', 'mouseEnterDelay', 'mouseLeaveDelay', 'overlayStyle', 'prefixCls', 'children', 'onVisibleChange', 'afterVisibleChange', 'transitionName', 'animation', 'placement', 'align', 'destroyTooltipOnHide', 'defaultVisible', 'getTooltipContainer']); | ||
var extraProps = _extends({}, restProps); | ||
if ('visible' in this.props) { | ||
extraProps.popupVisible = this.props.visible; | ||
} | ||
return React.createElement( | ||
Trigger, | ||
_extends({ | ||
popupClassName: overlayClassName, | ||
ref: this.saveTrigger, | ||
prefixCls: prefixCls, | ||
popup: this.getPopupElement, | ||
action: trigger, | ||
builtinPlacements: placements, | ||
popupPlacement: placement, | ||
popupAlign: align, | ||
getPopupContainer: getTooltipContainer, | ||
onPopupVisibleChange: onVisibleChange, | ||
afterPopupVisibleChange: afterVisibleChange, | ||
popupTransitionName: transitionName, | ||
popupAnimation: animation, | ||
defaultPopupVisible: defaultVisible, | ||
destroyPopupOnHide: destroyTooltipOnHide, | ||
mouseLeaveDelay: mouseLeaveDelay, | ||
popupStyle: overlayStyle, | ||
mouseEnterDelay: mouseEnterDelay | ||
}, extraProps), | ||
children | ||
); | ||
}; | ||
return Tooltip; | ||
}(Component); | ||
Tooltip.propTypes = { | ||
trigger: PropTypes.any, | ||
children: PropTypes.any, | ||
defaultVisible: PropTypes.bool, | ||
visible: PropTypes.bool, | ||
placement: PropTypes.string, | ||
transitionName: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), | ||
animation: PropTypes.any, | ||
onVisibleChange: PropTypes.func, | ||
afterVisibleChange: PropTypes.func, | ||
overlay: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired, | ||
overlayStyle: PropTypes.object, | ||
overlayClassName: PropTypes.string, | ||
prefixCls: PropTypes.string, | ||
mouseEnterDelay: PropTypes.number, | ||
mouseLeaveDelay: PropTypes.number, | ||
getTooltipContainer: PropTypes.func, | ||
destroyTooltipOnHide: PropTypes.bool, | ||
align: PropTypes.object, | ||
arrowContent: PropTypes.any, | ||
id: PropTypes.string | ||
return React.createElement(Trigger, Object.assign({ | ||
popupClassName: overlayClassName, | ||
prefixCls: prefixCls, | ||
popup: getPopupElement, | ||
action: trigger, | ||
builtinPlacements: placements, | ||
popupPlacement: placement, | ||
ref: domRef, | ||
popupAlign: align, | ||
getPopupContainer: getTooltipContainer, | ||
onPopupVisibleChange: onVisibleChange, | ||
afterPopupVisibleChange: afterVisibleChange, | ||
popupTransitionName: transitionName, | ||
popupAnimation: animation, | ||
defaultPopupVisible: defaultVisible, | ||
destroyPopupOnHide: destroyTooltipOnHide, | ||
mouseLeaveDelay: mouseLeaveDelay, | ||
popupStyle: overlayStyle, | ||
mouseEnterDelay: mouseEnterDelay | ||
}, extraProps), children); | ||
}; | ||
Tooltip.defaultProps = { | ||
prefixCls: 'rc-tooltip', | ||
mouseEnterDelay: 0, | ||
destroyTooltipOnHide: false, | ||
mouseLeaveDelay: 0.1, | ||
align: {}, | ||
placement: 'right', | ||
trigger: ['hover'], | ||
arrowContent: null | ||
}; | ||
export default Tooltip; | ||
export default forwardRef(Tooltip); |
@@ -1,66 +0,24 @@ | ||
'use strict'; | ||
"use strict"; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | ||
var Content = function Content(props) { | ||
var overlay = props.overlay, | ||
prefixCls = props.prefixCls, | ||
id = props.id; | ||
return _react.default.createElement("div", { | ||
className: "".concat(prefixCls, "-inner"), | ||
id: id, | ||
role: "tooltip" | ||
}, typeof overlay === 'function' ? overlay() : overlay); | ||
}; | ||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
var _inherits2 = require('babel-runtime/helpers/inherits'); | ||
var _inherits3 = _interopRequireDefault(_inherits2); | ||
var _react = require('react'); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var Content = function (_React$Component) { | ||
(0, _inherits3['default'])(Content, _React$Component); | ||
function Content() { | ||
(0, _classCallCheck3['default'])(this, Content); | ||
return (0, _possibleConstructorReturn3['default'])(this, _React$Component.apply(this, arguments)); | ||
} | ||
Content.prototype.componentDidUpdate = function componentDidUpdate() { | ||
var trigger = this.props.trigger; | ||
if (trigger) { | ||
trigger.forcePopupAlign(); | ||
} | ||
}; | ||
Content.prototype.render = function render() { | ||
var _props = this.props, | ||
overlay = _props.overlay, | ||
prefixCls = _props.prefixCls, | ||
id = _props.id; | ||
return _react2['default'].createElement( | ||
'div', | ||
{ className: prefixCls + '-inner', id: id, role: 'tooltip' }, | ||
typeof overlay === 'function' ? overlay() : overlay | ||
); | ||
}; | ||
return Content; | ||
}(_react2['default'].Component); | ||
Content.propTypes = { | ||
prefixCls: _propTypes2['default'].string, | ||
overlay: _propTypes2['default'].oneOfType([_propTypes2['default'].node, _propTypes2['default'].func]).isRequired, | ||
id: _propTypes2['default'].string, | ||
trigger: _propTypes2['default'].any | ||
}; | ||
exports['default'] = Content; | ||
module.exports = exports['default']; | ||
var _default = Content; | ||
exports.default = _default; |
@@ -1,12 +0,13 @@ | ||
'use strict'; | ||
"use strict"; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _Tooltip = require('./Tooltip'); | ||
var _Tooltip = _interopRequireDefault(require("./Tooltip")); | ||
var _Tooltip2 = _interopRequireDefault(_Tooltip); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
exports['default'] = _Tooltip2['default']; | ||
module.exports = exports['default']; | ||
var _default = _Tooltip.default; | ||
exports.default = _default; |
@@ -1,4 +0,7 @@ | ||
'use strict'; | ||
"use strict"; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.placements = void 0; | ||
var autoAdjustOverflow = { | ||
@@ -8,6 +11,4 @@ adjustX: 1, | ||
}; | ||
var targetOffset = [0, 0]; | ||
var placements = exports.placements = { | ||
var placements = { | ||
left: { | ||
@@ -86,3 +87,4 @@ points: ['cr', 'cl'], | ||
}; | ||
exports['default'] = placements; | ||
exports.placements = placements; | ||
var _default = placements; | ||
exports.default = _default; |
@@ -1,170 +0,109 @@ | ||
'use strict'; | ||
"use strict"; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _extends2 = require('babel-runtime/helpers/extends'); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _extends3 = _interopRequireDefault(_extends2); | ||
var _rcTrigger = _interopRequireDefault(require("rc-trigger")); | ||
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties'); | ||
var _placements = require("./placements"); | ||
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2); | ||
var _Content = _interopRequireDefault(require("./Content")); | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
var _inherits2 = require('babel-runtime/helpers/inherits'); | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
var _inherits3 = _interopRequireDefault(_inherits2); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var _react = require('react'); | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
var _react2 = _interopRequireDefault(_react); | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
var _propTypes = require('prop-types'); | ||
var Tooltip = function Tooltip(props, ref) { | ||
var overlayClassName = props.overlayClassName, | ||
_props$trigger = props.trigger, | ||
trigger = _props$trigger === void 0 ? ['hover'] : _props$trigger, | ||
_props$mouseEnterDela = props.mouseEnterDelay, | ||
mouseEnterDelay = _props$mouseEnterDela === void 0 ? 0 : _props$mouseEnterDela, | ||
_props$mouseLeaveDela = props.mouseLeaveDelay, | ||
mouseLeaveDelay = _props$mouseLeaveDela === void 0 ? 0.1 : _props$mouseLeaveDela, | ||
overlayStyle = props.overlayStyle, | ||
_props$prefixCls = props.prefixCls, | ||
prefixCls = _props$prefixCls === void 0 ? 'rc-tooltip' : _props$prefixCls, | ||
children = props.children, | ||
onVisibleChange = props.onVisibleChange, | ||
afterVisibleChange = props.afterVisibleChange, | ||
transitionName = props.transitionName, | ||
animation = props.animation, | ||
_props$placement = props.placement, | ||
placement = _props$placement === void 0 ? 'right' : _props$placement, | ||
_props$align = props.align, | ||
align = _props$align === void 0 ? {} : _props$align, | ||
_props$destroyTooltip = props.destroyTooltipOnHide, | ||
destroyTooltipOnHide = _props$destroyTooltip === void 0 ? false : _props$destroyTooltip, | ||
defaultVisible = props.defaultVisible, | ||
getTooltipContainer = props.getTooltipContainer, | ||
restProps = _objectWithoutProperties(props, ["overlayClassName", "trigger", "mouseEnterDelay", "mouseLeaveDelay", "overlayStyle", "prefixCls", "children", "onVisibleChange", "afterVisibleChange", "transitionName", "animation", "placement", "align", "destroyTooltipOnHide", "defaultVisible", "getTooltipContainer"]); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var domRef = (0, _react.useRef)(null); | ||
(0, _react.useImperativeHandle)(ref, function () { | ||
return domRef.current; | ||
}); | ||
var _rcTrigger = require('rc-trigger'); | ||
var extraProps = _objectSpread({}, restProps); | ||
var _rcTrigger2 = _interopRequireDefault(_rcTrigger); | ||
var _placements = require('./placements'); | ||
var _Content = require('./Content'); | ||
var _Content2 = _interopRequireDefault(_Content); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var Tooltip = function (_Component) { | ||
(0, _inherits3['default'])(Tooltip, _Component); | ||
function Tooltip() { | ||
var _temp, _this, _ret; | ||
(0, _classCallCheck3['default'])(this, Tooltip); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3['default'])(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.getPopupElement = function () { | ||
var _this$props = _this.props, | ||
arrowContent = _this$props.arrowContent, | ||
overlay = _this$props.overlay, | ||
prefixCls = _this$props.prefixCls, | ||
id = _this$props.id; | ||
return [_react2['default'].createElement( | ||
'div', | ||
{ className: prefixCls + '-arrow', key: 'arrow' }, | ||
arrowContent | ||
), _react2['default'].createElement(_Content2['default'], { | ||
key: 'content', | ||
trigger: _this.trigger, | ||
prefixCls: prefixCls, | ||
id: id, | ||
overlay: overlay | ||
})]; | ||
}, _this.saveTrigger = function (node) { | ||
_this.trigger = node; | ||
}, _temp), (0, _possibleConstructorReturn3['default'])(_this, _ret); | ||
if ('visible' in props) { | ||
extraProps.popupVisible = props.visible; | ||
} | ||
Tooltip.prototype.getPopupDomNode = function getPopupDomNode() { | ||
return this.trigger.getPopupDomNode(); | ||
var getPopupElement = function getPopupElement() { | ||
var _props$arrowContent = props.arrowContent, | ||
arrowContent = _props$arrowContent === void 0 ? null : _props$arrowContent, | ||
overlay = props.overlay, | ||
id = props.id; | ||
return [_react.default.createElement("div", { | ||
className: "".concat(prefixCls, "-arrow"), | ||
key: "arrow" | ||
}, arrowContent), _react.default.createElement(_Content.default, { | ||
key: "content", | ||
prefixCls: prefixCls, | ||
id: id, | ||
overlay: overlay | ||
})]; | ||
}; | ||
Tooltip.prototype.render = function render() { | ||
var _props = this.props, | ||
overlayClassName = _props.overlayClassName, | ||
trigger = _props.trigger, | ||
mouseEnterDelay = _props.mouseEnterDelay, | ||
mouseLeaveDelay = _props.mouseLeaveDelay, | ||
overlayStyle = _props.overlayStyle, | ||
prefixCls = _props.prefixCls, | ||
children = _props.children, | ||
onVisibleChange = _props.onVisibleChange, | ||
afterVisibleChange = _props.afterVisibleChange, | ||
transitionName = _props.transitionName, | ||
animation = _props.animation, | ||
placement = _props.placement, | ||
align = _props.align, | ||
destroyTooltipOnHide = _props.destroyTooltipOnHide, | ||
defaultVisible = _props.defaultVisible, | ||
getTooltipContainer = _props.getTooltipContainer, | ||
restProps = (0, _objectWithoutProperties3['default'])(_props, ['overlayClassName', 'trigger', 'mouseEnterDelay', 'mouseLeaveDelay', 'overlayStyle', 'prefixCls', 'children', 'onVisibleChange', 'afterVisibleChange', 'transitionName', 'animation', 'placement', 'align', 'destroyTooltipOnHide', 'defaultVisible', 'getTooltipContainer']); | ||
return _react.default.createElement(_rcTrigger.default, Object.assign({ | ||
popupClassName: overlayClassName, | ||
prefixCls: prefixCls, | ||
popup: getPopupElement, | ||
action: trigger, | ||
builtinPlacements: _placements.placements, | ||
popupPlacement: placement, | ||
ref: domRef, | ||
popupAlign: align, | ||
getPopupContainer: getTooltipContainer, | ||
onPopupVisibleChange: onVisibleChange, | ||
afterPopupVisibleChange: afterVisibleChange, | ||
popupTransitionName: transitionName, | ||
popupAnimation: animation, | ||
defaultPopupVisible: defaultVisible, | ||
destroyPopupOnHide: destroyTooltipOnHide, | ||
mouseLeaveDelay: mouseLeaveDelay, | ||
popupStyle: overlayStyle, | ||
mouseEnterDelay: mouseEnterDelay | ||
}, extraProps), children); | ||
}; | ||
var extraProps = (0, _extends3['default'])({}, restProps); | ||
if ('visible' in this.props) { | ||
extraProps.popupVisible = this.props.visible; | ||
} | ||
return _react2['default'].createElement( | ||
_rcTrigger2['default'], | ||
(0, _extends3['default'])({ | ||
popupClassName: overlayClassName, | ||
ref: this.saveTrigger, | ||
prefixCls: prefixCls, | ||
popup: this.getPopupElement, | ||
action: trigger, | ||
builtinPlacements: _placements.placements, | ||
popupPlacement: placement, | ||
popupAlign: align, | ||
getPopupContainer: getTooltipContainer, | ||
onPopupVisibleChange: onVisibleChange, | ||
afterPopupVisibleChange: afterVisibleChange, | ||
popupTransitionName: transitionName, | ||
popupAnimation: animation, | ||
defaultPopupVisible: defaultVisible, | ||
destroyPopupOnHide: destroyTooltipOnHide, | ||
mouseLeaveDelay: mouseLeaveDelay, | ||
popupStyle: overlayStyle, | ||
mouseEnterDelay: mouseEnterDelay | ||
}, extraProps), | ||
children | ||
); | ||
}; | ||
var _default = (0, _react.forwardRef)(Tooltip); | ||
return Tooltip; | ||
}(_react.Component); | ||
Tooltip.propTypes = { | ||
trigger: _propTypes2['default'].any, | ||
children: _propTypes2['default'].any, | ||
defaultVisible: _propTypes2['default'].bool, | ||
visible: _propTypes2['default'].bool, | ||
placement: _propTypes2['default'].string, | ||
transitionName: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].object]), | ||
animation: _propTypes2['default'].any, | ||
onVisibleChange: _propTypes2['default'].func, | ||
afterVisibleChange: _propTypes2['default'].func, | ||
overlay: _propTypes2['default'].oneOfType([_propTypes2['default'].node, _propTypes2['default'].func]).isRequired, | ||
overlayStyle: _propTypes2['default'].object, | ||
overlayClassName: _propTypes2['default'].string, | ||
prefixCls: _propTypes2['default'].string, | ||
mouseEnterDelay: _propTypes2['default'].number, | ||
mouseLeaveDelay: _propTypes2['default'].number, | ||
getTooltipContainer: _propTypes2['default'].func, | ||
destroyTooltipOnHide: _propTypes2['default'].bool, | ||
align: _propTypes2['default'].object, | ||
arrowContent: _propTypes2['default'].any, | ||
id: _propTypes2['default'].string | ||
}; | ||
Tooltip.defaultProps = { | ||
prefixCls: 'rc-tooltip', | ||
mouseEnterDelay: 0, | ||
destroyTooltipOnHide: false, | ||
mouseLeaveDelay: 0.1, | ||
align: {}, | ||
placement: 'right', | ||
trigger: ['hover'], | ||
arrowContent: null | ||
}; | ||
exports['default'] = Tooltip; | ||
module.exports = exports['default']; | ||
exports.default = _default; |
103
package.json
{ | ||
"name": "rc-tooltip", | ||
"version": "3.7.3", | ||
"version": "4.0.0-alpha.0", | ||
"description": "React Tooltip", | ||
@@ -11,2 +11,11 @@ "keywords": [ | ||
], | ||
"homepage": "http://github.com/react-component/tooltip", | ||
"bugs": { | ||
"url": "http://github.com/react-component/tooltip/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:react-component/tooltip.git" | ||
}, | ||
"license": "MIT", | ||
"files": [ | ||
@@ -16,70 +25,42 @@ "dist", | ||
"es", | ||
"assets/*.css" | ||
"assets/*.css", | ||
"assets/*.less" | ||
], | ||
"main": "lib/index", | ||
"module": "es/index", | ||
"homepage": "http://github.com/react-component/tooltip", | ||
"maintainers": [ | ||
"yiminghe@gmail.com" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:react-component/tooltip.git" | ||
}, | ||
"bugs": { | ||
"url": "http://github.com/react-component/tooltip/issues" | ||
}, | ||
"license": "MIT", | ||
"config": { | ||
"port": 8007, | ||
"entry": { | ||
"rc-tooltip": [ | ||
"./src/index.js" | ||
] | ||
} | ||
}, | ||
"scripts": { | ||
"dist": "rc-tools run dist", | ||
"build": "rc-tools run build", | ||
"gh-pages": "rc-tools run gh-pages", | ||
"start": "rc-tools run server", | ||
"compile": "rc-tools run compile --babel-runtime", | ||
"pub": "rc-tools run pub --babel-runtime", | ||
"lint": "rc-tools run lint", | ||
"test": "jest", | ||
"coverage": "jest --coverage" | ||
"build": "father doc build --storybook", | ||
"compile": "father build", | ||
"coverage": "father test --coverage", | ||
"lint": "eslint src/ examples/ --ext .tsx,.ts,.jsx,.js", | ||
"now-build": "npm run build", | ||
"prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish", | ||
"start": "cross-env NODE_ENV=development father doc dev --storybook", | ||
"test": "father test" | ||
}, | ||
"jest": { | ||
"setupFiles": [ | ||
"./tests/setup.js" | ||
], | ||
"collectCoverageFrom": [ | ||
"src/**/*" | ||
], | ||
"snapshotSerializers": [ | ||
"enzyme-to-json/serializer" | ||
], | ||
"transform": { | ||
"\\.jsx?$": "./node_modules/rc-tools/scripts/jestPreprocessor.js" | ||
} | ||
"dependencies": { | ||
"rc-trigger": "^4.0.0-alpha.5" | ||
}, | ||
"devDependencies": { | ||
"bootstrap": "~3.3.2", | ||
"enzyme": "^3.1.1", | ||
"enzyme-adapter-react-16": "^1.0.4", | ||
"enzyme-to-json": "^3.2.1", | ||
"jest": "^21.2.1", | ||
"pre-commit": "1.x", | ||
"rc-tools": "^7.0.2", | ||
"react": "^16.0.0", | ||
"react-dom": "^16.0.0" | ||
"@types/jest": "^24.0.19", | ||
"@types/react": "^16.9.9", | ||
"@types/react-dom": "^16.9.2", | ||
"@types/warning": "^3.0.0", | ||
"cross-env": "^6.0.3", | ||
"enzyme": "^3.10.0", | ||
"enzyme-adapter-react-16": "^1.15.1", | ||
"enzyme-to-json": "^3.4.3", | ||
"father": "^2.23.1", | ||
"np": "^5.1.1", | ||
"react": "^16.10.2", | ||
"react-dom": "^16.10.2", | ||
"typescript": "^3.6.4" | ||
}, | ||
"pre-commit": [ | ||
"lint" | ||
], | ||
"dependencies": { | ||
"babel-runtime": "6.x", | ||
"prop-types": "^15.5.8", | ||
"rc-trigger": "^2.2.2" | ||
} | ||
"peerDependencies": { | ||
"react": "*", | ||
"react-dom": "*" | ||
}, | ||
"maintainers": [ | ||
"yiminghe@gmail.com" | ||
] | ||
} |
@@ -13,4 +13,4 @@ # rc-tooltip | ||
[npm-image]: http://img.shields.io/npm/v/rc-tooltip.svg?style=flat-square | ||
[npm-url]: http://npmjs.org/package/rc-tooltip | ||
[npm-image]: https://img.shields.io/npm/v/rc-tooltip.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/package/rc-tooltip | ||
[travis-image]: https://img.shields.io/travis/react-component/tooltip.svg?style=flat-square | ||
@@ -20,6 +20,6 @@ [travis-url]: https://travis-ci.org/react-component/tooltip | ||
[coveralls-url]: https://coveralls.io/r/react-component/tooltip?branch=master | ||
[gemnasium-image]: http://img.shields.io/gemnasium/react-component/tooltip.svg?style=flat-square | ||
[gemnasium-image]: https://img.shields.io/gemnasium/react-component/tooltip.svg?style=flat-square | ||
[gemnasium-url]: https://gemnasium.com/react-component/tooltip | ||
[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square | ||
[node-url]: http://nodejs.org/download/ | ||
[node-url]: https://nodejs.org/download/ | ||
[download-image]: https://img.shields.io/npm/dm/rc-tooltip.svg?style=flat-square | ||
@@ -30,3 +30,3 @@ [download-url]: https://npmjs.org/package/rc-tooltip | ||
<img src="http://gtms03.alicdn.com/tps/i3/TB1NQUSHpXXXXaUXFXXlQqyZXXX-1312-572.png" width="600"/> | ||
<img src="https://gtms03.alicdn.com/tps/i3/TB1NQUSHpXXXXaUXFXXlQqyZXXX-1312-572.png" width="600"/> | ||
@@ -37,3 +37,3 @@ ## Browsers support | ||
| --------- | --------- | --------- | --------- | --------- | | ||
| IE 8 + ✔ | Chrome 31.0+ ✔ | Firefox 31.0+ ✔ | Opera 30.0+ ✔ | Safari 7.0+ ✔ | | ||
| IE 8 + ✔ | Firefox 31.0+ ✔ | Chrome 31.0+ ✔ | Safari 7.0+ ✔ | Opera 30.0+ ✔ | | ||
@@ -67,5 +67,5 @@ | ||
`npm start` and then go to | ||
[http://localhost:8007/examples](http://localhost:8007/examples) | ||
<http://localhost:8007/examples> | ||
Online examples: [http://react-component.github.io/tooltip/examples/](http://react-component.github.io/tooltip/examples/) | ||
Online examples: <https://react-component.github.io/tooltip/examples/> | ||
@@ -72,0 +72,0 @@ ## API |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
24
0
53090
13
1031
+ Added@babel/runtime@7.26.0(transitive)
+ Addedrc-align@4.0.15(transitive)
+ Addedrc-motion@1.1.2(transitive)
+ Addedrc-trigger@4.4.3(transitive)
+ Addedrc-util@5.43.0(transitive)
+ Addedreact@16.14.018.3.1(transitive)
+ Addedreact-dom@16.14.018.3.1(transitive)
+ Addedreact-is@18.3.1(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
+ Addedresize-observer-polyfill@1.5.1(transitive)
+ Addedscheduler@0.19.10.23.2(transitive)
- Removedbabel-runtime@6.x
- Removedprop-types@^15.5.8
- Removedadd-dom-event-listener@1.1.0(transitive)
- Removedbabel-runtime@6.26.0(transitive)
- Removedcomponent-classes@1.2.6(transitive)
- Removedcomponent-indexof@0.0.3(transitive)
- Removedcore-js@2.6.12(transitive)
- Removedcss-animation@1.6.1(transitive)
- Removedrc-align@2.4.5(transitive)
- Removedrc-animate@2.11.1(transitive)
- Removedrc-trigger@2.6.5(transitive)
- Removedrc-util@4.21.1(transitive)
- Removedreact-lifecycles-compat@3.0.4(transitive)
- Removedregenerator-runtime@0.11.1(transitive)
- Removedshallowequal@1.1.0(transitive)
Updatedrc-trigger@^4.0.0-alpha.5