Latest updates from IceHrmPro
This commit is contained in:
261
web/node_modules/antd/es/tooltip/index.js
generated
vendored
Normal file
261
web/node_modules/antd/es/tooltip/index.js
generated
vendored
Normal file
@@ -0,0 +1,261 @@
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
|
||||
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
|
||||
import * as React from 'react';
|
||||
import RcTooltip from 'rc-tooltip';
|
||||
import classNames from 'classnames';
|
||||
import _getPlacements from './placements';
|
||||
import { ConfigConsumer } from '../config-provider';
|
||||
|
||||
var splitObject = function splitObject(obj, keys) {
|
||||
var picked = {};
|
||||
|
||||
var omitted = _extends({}, obj);
|
||||
|
||||
keys.forEach(function (key) {
|
||||
if (obj && key in obj) {
|
||||
picked[key] = obj[key];
|
||||
delete omitted[key];
|
||||
}
|
||||
});
|
||||
return {
|
||||
picked: picked,
|
||||
omitted: omitted
|
||||
};
|
||||
}; // Fix Tooltip won't hide at disabled button
|
||||
// mouse events don't trigger at disabled button in Chrome
|
||||
// https://github.com/react-component/tooltip/issues/18
|
||||
|
||||
|
||||
function getDisabledCompatibleChildren(element, prefixCls) {
|
||||
var elementType = element.type;
|
||||
|
||||
if ((elementType.__ANT_BUTTON === true || elementType.__ANT_SWITCH === true || elementType.__ANT_CHECKBOX === true || element.type === 'button') && element.props.disabled) {
|
||||
// Pick some layout related style properties up to span
|
||||
// Prevent layout bugs like https://github.com/ant-design/ant-design/issues/5254
|
||||
var _splitObject = splitObject(element.props.style, ['position', 'left', 'right', 'top', 'bottom', 'float', 'display', 'zIndex']),
|
||||
picked = _splitObject.picked,
|
||||
omitted = _splitObject.omitted;
|
||||
|
||||
var spanStyle = _extends(_extends({
|
||||
display: 'inline-block'
|
||||
}, picked), {
|
||||
cursor: 'not-allowed',
|
||||
width: element.props.block ? '100%' : null
|
||||
});
|
||||
|
||||
var buttonStyle = _extends(_extends({}, omitted), {
|
||||
pointerEvents: 'none'
|
||||
});
|
||||
|
||||
var child = React.cloneElement(element, {
|
||||
style: buttonStyle,
|
||||
className: null
|
||||
});
|
||||
return /*#__PURE__*/React.createElement("span", {
|
||||
style: spanStyle,
|
||||
className: classNames(element.props.className, "".concat(prefixCls, "-disabled-compatible-wrapper"))
|
||||
}, child);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
var Tooltip = /*#__PURE__*/function (_React$Component) {
|
||||
_inherits(Tooltip, _React$Component);
|
||||
|
||||
var _super = _createSuper(Tooltip);
|
||||
|
||||
function Tooltip(props) {
|
||||
var _this;
|
||||
|
||||
_classCallCheck(this, Tooltip);
|
||||
|
||||
_this = _super.call(this, props);
|
||||
|
||||
_this.onVisibleChange = function (visible) {
|
||||
var onVisibleChange = _this.props.onVisibleChange;
|
||||
|
||||
if (!('visible' in _this.props)) {
|
||||
_this.setState({
|
||||
visible: _this.isNoTitle() ? false : visible
|
||||
});
|
||||
}
|
||||
|
||||
if (onVisibleChange && !_this.isNoTitle()) {
|
||||
onVisibleChange(visible);
|
||||
}
|
||||
};
|
||||
|
||||
_this.saveTooltip = function (node) {
|
||||
_this.tooltip = node;
|
||||
}; // 动态设置动画点
|
||||
|
||||
|
||||
_this.onPopupAlign = function (domNode, align) {
|
||||
var placements = _this.getPlacements(); // 当前返回的位置
|
||||
|
||||
|
||||
var placement = Object.keys(placements).filter(function (key) {
|
||||
return placements[key].points[0] === align.points[0] && placements[key].points[1] === align.points[1];
|
||||
})[0]; // 根据当前坐标设置动画点
|
||||
|
||||
var rect = domNode.getBoundingClientRect();
|
||||
var transformOrigin = {
|
||||
top: '50%',
|
||||
left: '50%'
|
||||
};
|
||||
|
||||
if (placement.indexOf('top') >= 0 || placement.indexOf('Bottom') >= 0) {
|
||||
transformOrigin.top = "".concat(rect.height - align.offset[1], "px");
|
||||
} else if (placement.indexOf('Top') >= 0 || placement.indexOf('bottom') >= 0) {
|
||||
transformOrigin.top = "".concat(-align.offset[1], "px");
|
||||
}
|
||||
|
||||
if (placement.indexOf('left') >= 0 || placement.indexOf('Right') >= 0) {
|
||||
transformOrigin.left = "".concat(rect.width - align.offset[0], "px");
|
||||
} else if (placement.indexOf('right') >= 0 || placement.indexOf('Left') >= 0) {
|
||||
transformOrigin.left = "".concat(-align.offset[0], "px");
|
||||
}
|
||||
|
||||
domNode.style.transformOrigin = "".concat(transformOrigin.left, " ").concat(transformOrigin.top);
|
||||
};
|
||||
|
||||
_this.renderTooltip = function (_ref) {
|
||||
var getContextPopupContainer = _ref.getPopupContainer,
|
||||
getPrefixCls = _ref.getPrefixCls,
|
||||
direction = _ref.direction;
|
||||
|
||||
var _assertThisInitialize = _assertThisInitialized(_this),
|
||||
props = _assertThisInitialize.props,
|
||||
state = _assertThisInitialize.state;
|
||||
|
||||
var customizePrefixCls = props.prefixCls,
|
||||
openClassName = props.openClassName,
|
||||
getPopupContainer = props.getPopupContainer,
|
||||
getTooltipContainer = props.getTooltipContainer,
|
||||
overlayClassName = props.overlayClassName;
|
||||
var children = props.children;
|
||||
var prefixCls = getPrefixCls('tooltip', customizePrefixCls);
|
||||
var visible = state.visible; // Hide tooltip when there is no title
|
||||
|
||||
if (!('visible' in props) && _this.isNoTitle()) {
|
||||
visible = false;
|
||||
}
|
||||
|
||||
var child = getDisabledCompatibleChildren(React.isValidElement(children) ? children : /*#__PURE__*/React.createElement("span", null, children), prefixCls);
|
||||
var childProps = child.props;
|
||||
var childCls = classNames(childProps.className, _defineProperty({}, openClassName || "".concat(prefixCls, "-open"), true));
|
||||
var customOverlayClassName = classNames(overlayClassName, _defineProperty({}, "".concat(prefixCls, "-rtl"), direction === 'rtl'));
|
||||
return /*#__PURE__*/React.createElement(RcTooltip, _extends({}, _this.props, {
|
||||
prefixCls: prefixCls,
|
||||
overlayClassName: customOverlayClassName,
|
||||
getTooltipContainer: getPopupContainer || getTooltipContainer || getContextPopupContainer,
|
||||
ref: _this.saveTooltip,
|
||||
builtinPlacements: _this.getPlacements(),
|
||||
overlay: _this.getOverlay(),
|
||||
visible: visible,
|
||||
onVisibleChange: _this.onVisibleChange,
|
||||
onPopupAlign: _this.onPopupAlign
|
||||
}), visible ? React.cloneElement(child, {
|
||||
className: childCls
|
||||
}) : child);
|
||||
};
|
||||
|
||||
_this.state = {
|
||||
visible: !!props.visible || !!props.defaultVisible
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(Tooltip, [{
|
||||
key: "getPopupDomNode",
|
||||
value: function getPopupDomNode() {
|
||||
return this.tooltip.getPopupDomNode();
|
||||
}
|
||||
}, {
|
||||
key: "getPlacements",
|
||||
value: function getPlacements() {
|
||||
var _this$props = this.props,
|
||||
builtinPlacements = _this$props.builtinPlacements,
|
||||
arrowPointAtCenter = _this$props.arrowPointAtCenter,
|
||||
autoAdjustOverflow = _this$props.autoAdjustOverflow;
|
||||
return builtinPlacements || _getPlacements({
|
||||
arrowPointAtCenter: arrowPointAtCenter,
|
||||
autoAdjustOverflow: autoAdjustOverflow
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "isNoTitle",
|
||||
value: function isNoTitle() {
|
||||
var _this$props2 = this.props,
|
||||
title = _this$props2.title,
|
||||
overlay = _this$props2.overlay;
|
||||
return !title && !overlay && title !== 0; // overlay for old version compatibility
|
||||
}
|
||||
}, {
|
||||
key: "getOverlay",
|
||||
value: function getOverlay() {
|
||||
var _this$props3 = this.props,
|
||||
title = _this$props3.title,
|
||||
overlay = _this$props3.overlay;
|
||||
|
||||
if (title === 0) {
|
||||
return title;
|
||||
}
|
||||
|
||||
return overlay || title || '';
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
return /*#__PURE__*/React.createElement(ConfigConsumer, null, this.renderTooltip);
|
||||
}
|
||||
}], [{
|
||||
key: "getDerivedStateFromProps",
|
||||
value: function getDerivedStateFromProps(nextProps) {
|
||||
if ('visible' in nextProps) {
|
||||
return {
|
||||
visible: nextProps.visible
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Tooltip;
|
||||
}(React.Component);
|
||||
|
||||
Tooltip.defaultProps = {
|
||||
placement: 'top',
|
||||
transitionName: 'zoom-big-fast',
|
||||
mouseEnterDelay: 0.1,
|
||||
mouseLeaveDelay: 0.1,
|
||||
arrowPointAtCenter: false,
|
||||
autoAdjustOverflow: true
|
||||
};
|
||||
export default Tooltip;
|
||||
Reference in New Issue
Block a user