Latest updates from IceHrmPro
This commit is contained in:
50
web/node_modules/rc-dialog/lib/Dialog.d.ts
generated
vendored
Normal file
50
web/node_modules/rc-dialog/lib/Dialog.d.ts
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import * as React from 'react';
|
||||
import IDialogPropTypes from './IDialogPropTypes';
|
||||
export interface IDialogChildProps extends IDialogPropTypes {
|
||||
getOpenCount: () => number;
|
||||
switchScrollingEffect?: () => void;
|
||||
}
|
||||
export default class Dialog extends React.Component<IDialogChildProps, any> {
|
||||
static defaultProps: {
|
||||
className: string;
|
||||
mask: boolean;
|
||||
visible: boolean;
|
||||
keyboard: boolean;
|
||||
closable: boolean;
|
||||
maskClosable: boolean;
|
||||
destroyOnClose: boolean;
|
||||
prefixCls: string;
|
||||
focusTriggerAfterClose: boolean;
|
||||
};
|
||||
private inTransition;
|
||||
private titleId;
|
||||
private openTime;
|
||||
private lastOutSideFocusNode;
|
||||
private wrap;
|
||||
private dialog;
|
||||
private sentinelStart;
|
||||
private sentinelEnd;
|
||||
private dialogMouseDown;
|
||||
private timeoutId;
|
||||
private switchScrollingEffect;
|
||||
constructor(props: IDialogChildProps);
|
||||
componentDidMount(): void;
|
||||
componentDidUpdate(prevProps: IDialogPropTypes): void;
|
||||
componentWillUnmount(): void;
|
||||
tryFocus(): void;
|
||||
onAnimateLeave: () => void;
|
||||
onDialogMouseDown: () => void;
|
||||
onMaskMouseUp: React.MouseEventHandler<HTMLDivElement>;
|
||||
onMaskClick: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
||||
onKeyDown: (e: React.KeyboardEvent<HTMLDivElement>) => void;
|
||||
getDialogElement: () => JSX.Element;
|
||||
getZIndexStyle: () => any;
|
||||
getWrapStyle: () => any;
|
||||
getMaskStyle: () => any;
|
||||
getMaskElement: () => JSX.Element | undefined;
|
||||
getMaskTransitionName: () => string | undefined;
|
||||
getTransitionName: () => string | undefined;
|
||||
close: (e: any) => void;
|
||||
saveRef: (name: string) => (node: any) => void;
|
||||
render(): JSX.Element;
|
||||
}
|
||||
327
web/node_modules/rc-dialog/lib/Dialog.js
generated
vendored
Normal file
327
web/node_modules/rc-dialog/lib/Dialog.js
generated
vendored
Normal file
@@ -0,0 +1,327 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
var _extends2 = require('babel-runtime/helpers/extends');
|
||||
|
||||
var _extends3 = _interopRequireDefault(_extends2);
|
||||
|
||||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
|
||||
|
||||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
||||
|
||||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
|
||||
|
||||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
||||
|
||||
var _inherits2 = require('babel-runtime/helpers/inherits');
|
||||
|
||||
var _inherits3 = _interopRequireDefault(_inherits2);
|
||||
|
||||
var _react = require('react');
|
||||
|
||||
var React = _interopRequireWildcard(_react);
|
||||
|
||||
var _reactDom = require('react-dom');
|
||||
|
||||
var ReactDOM = _interopRequireWildcard(_reactDom);
|
||||
|
||||
var _KeyCode = require('rc-util/lib/KeyCode');
|
||||
|
||||
var _KeyCode2 = _interopRequireDefault(_KeyCode);
|
||||
|
||||
var _contains = require('rc-util/lib/Dom/contains');
|
||||
|
||||
var _contains2 = _interopRequireDefault(_contains);
|
||||
|
||||
var _rcAnimate = require('rc-animate');
|
||||
|
||||
var _rcAnimate2 = _interopRequireDefault(_rcAnimate);
|
||||
|
||||
var _LazyRenderBox = require('./LazyRenderBox');
|
||||
|
||||
var _LazyRenderBox2 = _interopRequireDefault(_LazyRenderBox);
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
var uuid = 0;
|
||||
/* eslint react/no-is-mounted:0 */
|
||||
function getScroll(w, top) {
|
||||
var ret = w['page' + (top ? 'Y' : 'X') + 'Offset'];
|
||||
var method = 'scroll' + (top ? 'Top' : 'Left');
|
||||
if (typeof ret !== 'number') {
|
||||
var d = w.document;
|
||||
ret = d.documentElement[method];
|
||||
if (typeof ret !== 'number') {
|
||||
ret = d.body[method];
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
function setTransformOrigin(node, value) {
|
||||
var style = node.style;
|
||||
['Webkit', 'Moz', 'Ms', 'ms'].forEach(function (prefix) {
|
||||
style[prefix + 'TransformOrigin'] = value;
|
||||
});
|
||||
style['transformOrigin'] = value;
|
||||
}
|
||||
function offset(el) {
|
||||
var rect = el.getBoundingClientRect();
|
||||
var pos = {
|
||||
left: rect.left,
|
||||
top: rect.top
|
||||
};
|
||||
var doc = el.ownerDocument;
|
||||
var w = doc.defaultView || doc.parentWindow;
|
||||
pos.left += getScroll(w);
|
||||
pos.top += getScroll(w, true);
|
||||
return pos;
|
||||
}
|
||||
|
||||
var Dialog = function (_React$Component) {
|
||||
(0, _inherits3['default'])(Dialog, _React$Component);
|
||||
|
||||
function Dialog(props) {
|
||||
(0, _classCallCheck3['default'])(this, Dialog);
|
||||
|
||||
var _this = (0, _possibleConstructorReturn3['default'])(this, _React$Component.call(this, props));
|
||||
|
||||
_this.inTransition = false;
|
||||
_this.onAnimateLeave = function () {
|
||||
var afterClose = _this.props.afterClose;
|
||||
// need demo?
|
||||
// https://github.com/react-component/dialog/pull/28
|
||||
|
||||
if (_this.wrap) {
|
||||
_this.wrap.style.display = 'none';
|
||||
}
|
||||
_this.inTransition = false;
|
||||
_this.switchScrollingEffect();
|
||||
if (afterClose) {
|
||||
afterClose();
|
||||
}
|
||||
};
|
||||
_this.onDialogMouseDown = function () {
|
||||
_this.dialogMouseDown = true;
|
||||
};
|
||||
_this.onMaskMouseUp = function () {
|
||||
if (_this.dialogMouseDown) {
|
||||
_this.timeoutId = setTimeout(function () {
|
||||
_this.dialogMouseDown = false;
|
||||
}, 0);
|
||||
}
|
||||
};
|
||||
_this.onMaskClick = function (e) {
|
||||
// android trigger click on open (fastclick??)
|
||||
if (Date.now() - _this.openTime < 300) {
|
||||
return;
|
||||
}
|
||||
if (e.target === e.currentTarget && !_this.dialogMouseDown) {
|
||||
_this.close(e);
|
||||
}
|
||||
};
|
||||
_this.onKeyDown = function (e) {
|
||||
var props = _this.props;
|
||||
if (props.keyboard && e.keyCode === _KeyCode2['default'].ESC) {
|
||||
e.stopPropagation();
|
||||
_this.close(e);
|
||||
return;
|
||||
}
|
||||
// keep focus inside dialog
|
||||
if (props.visible) {
|
||||
if (e.keyCode === _KeyCode2['default'].TAB) {
|
||||
var activeElement = document.activeElement;
|
||||
var sentinelStart = _this.sentinelStart;
|
||||
if (e.shiftKey) {
|
||||
if (activeElement === sentinelStart) {
|
||||
_this.sentinelEnd.focus();
|
||||
}
|
||||
} else if (activeElement === _this.sentinelEnd) {
|
||||
sentinelStart.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
_this.getDialogElement = function () {
|
||||
var props = _this.props;
|
||||
var closable = props.closable;
|
||||
var prefixCls = props.prefixCls;
|
||||
var dest = {};
|
||||
if (props.width !== undefined) {
|
||||
dest.width = props.width;
|
||||
}
|
||||
if (props.height !== undefined) {
|
||||
dest.height = props.height;
|
||||
}
|
||||
var footer = void 0;
|
||||
if (props.footer) {
|
||||
footer = React.createElement("div", { className: prefixCls + '-footer', ref: _this.saveRef('footer') }, props.footer);
|
||||
}
|
||||
var header = void 0;
|
||||
if (props.title) {
|
||||
header = React.createElement("div", { className: prefixCls + '-header', ref: _this.saveRef('header') }, React.createElement("div", { className: prefixCls + '-title', id: _this.titleId }, props.title));
|
||||
}
|
||||
var closer = void 0;
|
||||
if (closable) {
|
||||
closer = React.createElement("button", { type: "button", onClick: _this.close, "aria-label": "Close", className: prefixCls + '-close' }, props.closeIcon || React.createElement("span", { className: prefixCls + '-close-x' }));
|
||||
}
|
||||
var style = (0, _extends3['default'])({}, props.style, dest);
|
||||
var sentinelStyle = { width: 0, height: 0, overflow: 'hidden', outline: 'none' };
|
||||
var transitionName = _this.getTransitionName();
|
||||
var dialogElement = React.createElement(_LazyRenderBox2['default'], { key: "dialog-element", role: "document", ref: _this.saveRef('dialog'), style: style, className: prefixCls + ' ' + (props.className || ''), visible: props.visible, forceRender: props.forceRender, onMouseDown: _this.onDialogMouseDown }, React.createElement("div", { tabIndex: 0, ref: _this.saveRef('sentinelStart'), style: sentinelStyle, "aria-hidden": "true" }), React.createElement("div", { className: prefixCls + '-content' }, closer, header, React.createElement("div", (0, _extends3['default'])({ className: prefixCls + '-body', style: props.bodyStyle, ref: _this.saveRef('body') }, props.bodyProps), props.children), footer), React.createElement("div", { tabIndex: 0, ref: _this.saveRef('sentinelEnd'), style: sentinelStyle, "aria-hidden": "true" }));
|
||||
return React.createElement(_rcAnimate2['default'], { key: "dialog", showProp: "visible", onLeave: _this.onAnimateLeave, transitionName: transitionName, component: "", transitionAppear: true }, props.visible || !props.destroyOnClose ? dialogElement : null);
|
||||
};
|
||||
_this.getZIndexStyle = function () {
|
||||
var style = {};
|
||||
var props = _this.props;
|
||||
if (props.zIndex !== undefined) {
|
||||
style.zIndex = props.zIndex;
|
||||
}
|
||||
return style;
|
||||
};
|
||||
_this.getWrapStyle = function () {
|
||||
return (0, _extends3['default'])({}, _this.getZIndexStyle(), _this.props.wrapStyle);
|
||||
};
|
||||
_this.getMaskStyle = function () {
|
||||
return (0, _extends3['default'])({}, _this.getZIndexStyle(), _this.props.maskStyle);
|
||||
};
|
||||
_this.getMaskElement = function () {
|
||||
var props = _this.props;
|
||||
var maskElement = void 0;
|
||||
if (props.mask) {
|
||||
var maskTransition = _this.getMaskTransitionName();
|
||||
maskElement = React.createElement(_LazyRenderBox2['default'], (0, _extends3['default'])({ style: _this.getMaskStyle(), key: "mask", className: props.prefixCls + '-mask', hiddenClassName: props.prefixCls + '-mask-hidden', visible: props.visible }, props.maskProps));
|
||||
if (maskTransition) {
|
||||
maskElement = React.createElement(_rcAnimate2['default'], { key: "mask", showProp: "visible", transitionAppear: true, component: "", transitionName: maskTransition }, maskElement);
|
||||
}
|
||||
}
|
||||
return maskElement;
|
||||
};
|
||||
_this.getMaskTransitionName = function () {
|
||||
var props = _this.props;
|
||||
var transitionName = props.maskTransitionName;
|
||||
var animation = props.maskAnimation;
|
||||
if (!transitionName && animation) {
|
||||
transitionName = props.prefixCls + '-' + animation;
|
||||
}
|
||||
return transitionName;
|
||||
};
|
||||
_this.getTransitionName = function () {
|
||||
var props = _this.props;
|
||||
var transitionName = props.transitionName;
|
||||
var animation = props.animation;
|
||||
if (!transitionName && animation) {
|
||||
transitionName = props.prefixCls + '-' + animation;
|
||||
}
|
||||
return transitionName;
|
||||
};
|
||||
_this.close = function (e) {
|
||||
var onClose = _this.props.onClose;
|
||||
|
||||
if (onClose) {
|
||||
onClose(e);
|
||||
}
|
||||
};
|
||||
_this.saveRef = function (name) {
|
||||
return function (node) {
|
||||
_this[name] = node;
|
||||
};
|
||||
};
|
||||
_this.titleId = 'rcDialogTitle' + uuid++;
|
||||
_this.switchScrollingEffect = props.switchScrollingEffect || function () {};
|
||||
return _this;
|
||||
}
|
||||
|
||||
Dialog.prototype.componentDidMount = function componentDidMount() {
|
||||
this.componentDidUpdate({});
|
||||
// if forceRender is true, set element style display to be none;
|
||||
if ((this.props.forceRender || this.props.getContainer === false && !this.props.visible) && this.wrap) {
|
||||
this.wrap.style.display = 'none';
|
||||
}
|
||||
};
|
||||
|
||||
Dialog.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
|
||||
var _props = this.props,
|
||||
visible = _props.visible,
|
||||
mask = _props.mask,
|
||||
focusTriggerAfterClose = _props.focusTriggerAfterClose;
|
||||
|
||||
var mousePosition = this.props.mousePosition;
|
||||
if (visible) {
|
||||
// first show
|
||||
if (!prevProps.visible) {
|
||||
this.openTime = Date.now();
|
||||
this.switchScrollingEffect();
|
||||
this.tryFocus();
|
||||
var dialogNode = ReactDOM.findDOMNode(this.dialog);
|
||||
if (mousePosition) {
|
||||
var elOffset = offset(dialogNode);
|
||||
setTransformOrigin(dialogNode, mousePosition.x - elOffset.left + 'px ' + (mousePosition.y - elOffset.top) + 'px');
|
||||
} else {
|
||||
setTransformOrigin(dialogNode, '');
|
||||
}
|
||||
}
|
||||
} else if (prevProps.visible) {
|
||||
this.inTransition = true;
|
||||
if (mask && this.lastOutSideFocusNode && focusTriggerAfterClose) {
|
||||
try {
|
||||
this.lastOutSideFocusNode.focus();
|
||||
} catch (e) {
|
||||
this.lastOutSideFocusNode = null;
|
||||
}
|
||||
this.lastOutSideFocusNode = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Dialog.prototype.componentWillUnmount = function componentWillUnmount() {
|
||||
var _props2 = this.props,
|
||||
visible = _props2.visible,
|
||||
getOpenCount = _props2.getOpenCount;
|
||||
|
||||
if ((visible || this.inTransition) && !getOpenCount()) {
|
||||
this.switchScrollingEffect();
|
||||
}
|
||||
clearTimeout(this.timeoutId);
|
||||
};
|
||||
|
||||
Dialog.prototype.tryFocus = function tryFocus() {
|
||||
if (!(0, _contains2['default'])(this.wrap, document.activeElement)) {
|
||||
this.lastOutSideFocusNode = document.activeElement;
|
||||
this.sentinelStart.focus();
|
||||
}
|
||||
};
|
||||
|
||||
Dialog.prototype.render = function render() {
|
||||
var props = this.props;
|
||||
var prefixCls = props.prefixCls,
|
||||
maskClosable = props.maskClosable;
|
||||
|
||||
var style = this.getWrapStyle();
|
||||
// clear hide display
|
||||
// and only set display after async anim, not here for hide
|
||||
if (props.visible) {
|
||||
style.display = null;
|
||||
}
|
||||
return React.createElement("div", { className: prefixCls + '-root' }, this.getMaskElement(), React.createElement("div", (0, _extends3['default'])({ tabIndex: -1, onKeyDown: this.onKeyDown, className: prefixCls + '-wrap ' + (props.wrapClassName || ''), ref: this.saveRef('wrap'), onClick: maskClosable ? this.onMaskClick : null, onMouseUp: maskClosable ? this.onMaskMouseUp : null, role: "dialog", "aria-labelledby": props.title ? this.titleId : null, style: style }, props.wrapProps), this.getDialogElement()));
|
||||
};
|
||||
|
||||
return Dialog;
|
||||
}(React.Component);
|
||||
|
||||
exports['default'] = Dialog;
|
||||
|
||||
Dialog.defaultProps = {
|
||||
className: '',
|
||||
mask: true,
|
||||
visible: false,
|
||||
keyboard: true,
|
||||
closable: true,
|
||||
maskClosable: true,
|
||||
destroyOnClose: false,
|
||||
prefixCls: 'rc-dialog',
|
||||
focusTriggerAfterClose: true
|
||||
};
|
||||
module.exports = exports['default'];
|
||||
4
web/node_modules/rc-dialog/lib/DialogWrap.d.ts
generated
vendored
Normal file
4
web/node_modules/rc-dialog/lib/DialogWrap.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/// <reference types="react" />
|
||||
import IDialogPropTypes from './IDialogPropTypes';
|
||||
declare const _default: (props: IDialogPropTypes) => JSX.Element;
|
||||
export default _default;
|
||||
49
web/node_modules/rc-dialog/lib/DialogWrap.js
generated
vendored
Normal file
49
web/node_modules/rc-dialog/lib/DialogWrap.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
var _extends2 = require('babel-runtime/helpers/extends');
|
||||
|
||||
var _extends3 = _interopRequireDefault(_extends2);
|
||||
|
||||
var _react = require('react');
|
||||
|
||||
var React = _interopRequireWildcard(_react);
|
||||
|
||||
var _Dialog = require('./Dialog');
|
||||
|
||||
var _Dialog2 = _interopRequireDefault(_Dialog);
|
||||
|
||||
var _PortalWrapper = require('rc-util/lib/PortalWrapper');
|
||||
|
||||
var _PortalWrapper2 = _interopRequireDefault(_PortalWrapper);
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
// fix issue #10656
|
||||
/*
|
||||
* getContainer remarks
|
||||
* Custom container should not be return, because in the Portal component, it will remove the
|
||||
* return container element here, if the custom container is the only child of it's component,
|
||||
* like issue #10656, It will has a conflict with removeChild method in react-dom.
|
||||
* So here should add a child (div element) to custom container.
|
||||
* */
|
||||
exports['default'] = function (props) {
|
||||
var visible = props.visible,
|
||||
getContainer = props.getContainer,
|
||||
forceRender = props.forceRender;
|
||||
// 渲染在当前 dom 里;
|
||||
|
||||
if (getContainer === false) {
|
||||
return React.createElement(_Dialog2['default'], (0, _extends3['default'])({}, props, { getOpenCount: function getOpenCount() {
|
||||
return 2;
|
||||
} }));
|
||||
}
|
||||
return React.createElement(_PortalWrapper2['default'], { visible: visible, forceRender: forceRender, getContainer: getContainer }, function (childProps) {
|
||||
return React.createElement(_Dialog2['default'], (0, _extends3['default'])({}, props, childProps));
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = exports['default'];
|
||||
41
web/node_modules/rc-dialog/lib/IDialogPropTypes.d.ts
generated
vendored
Normal file
41
web/node_modules/rc-dialog/lib/IDialogPropTypes.d.ts
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
import { ReactNode, CSSProperties, SyntheticEvent } from 'react';
|
||||
declare type IStringOrHtmlElement = string | HTMLElement;
|
||||
interface IDialogPropTypes {
|
||||
className?: string;
|
||||
keyboard?: boolean;
|
||||
style?: CSSProperties;
|
||||
mask?: boolean;
|
||||
children?: any;
|
||||
afterClose?: () => any;
|
||||
onClose?: (e: SyntheticEvent<HTMLDivElement>) => any;
|
||||
closable?: boolean;
|
||||
maskClosable?: boolean;
|
||||
visible?: boolean;
|
||||
destroyOnClose?: boolean;
|
||||
mousePosition?: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
title?: ReactNode;
|
||||
footer?: ReactNode;
|
||||
transitionName?: string;
|
||||
maskTransitionName?: string;
|
||||
animation?: any;
|
||||
maskAnimation?: any;
|
||||
wrapStyle?: {};
|
||||
bodyStyle?: {};
|
||||
maskStyle?: {};
|
||||
prefixCls?: string;
|
||||
wrapClassName?: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
zIndex?: number;
|
||||
bodyProps?: any;
|
||||
maskProps?: any;
|
||||
wrapProps?: any;
|
||||
getContainer?: IStringOrHtmlElement | (() => IStringOrHtmlElement) | false;
|
||||
closeIcon?: ReactNode;
|
||||
forceRender?: boolean;
|
||||
focusTriggerAfterClose?: boolean;
|
||||
}
|
||||
export default IDialogPropTypes;
|
||||
1
web/node_modules/rc-dialog/lib/IDialogPropTypes.js
generated
vendored
Normal file
1
web/node_modules/rc-dialog/lib/IDialogPropTypes.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";
|
||||
14
web/node_modules/rc-dialog/lib/LazyRenderBox.d.ts
generated
vendored
Normal file
14
web/node_modules/rc-dialog/lib/LazyRenderBox.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import * as React from 'react';
|
||||
export interface ILazyRenderBoxPropTypes {
|
||||
className?: string;
|
||||
visible?: boolean;
|
||||
hiddenClassName?: string;
|
||||
role?: string;
|
||||
style?: {};
|
||||
forceRender?: boolean;
|
||||
onMouseDown?: React.MouseEventHandler<HTMLDivElement>;
|
||||
}
|
||||
export default class LazyRenderBox extends React.Component<ILazyRenderBoxPropTypes, any> {
|
||||
shouldComponentUpdate(nextProps: ILazyRenderBoxPropTypes): boolean;
|
||||
render(): JSX.Element;
|
||||
}
|
||||
71
web/node_modules/rc-dialog/lib/LazyRenderBox.js
generated
vendored
Normal file
71
web/node_modules/rc-dialog/lib/LazyRenderBox.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
var _extends2 = require("babel-runtime/helpers/extends");
|
||||
|
||||
var _extends3 = _interopRequireDefault(_extends2);
|
||||
|
||||
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
|
||||
|
||||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
||||
|
||||
var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn");
|
||||
|
||||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
||||
|
||||
var _inherits2 = require("babel-runtime/helpers/inherits");
|
||||
|
||||
var _inherits3 = _interopRequireDefault(_inherits2);
|
||||
|
||||
var _react = require("react");
|
||||
|
||||
var React = _interopRequireWildcard(_react);
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
||||
|
||||
var __rest = undefined && undefined.__rest || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) {
|
||||
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
||||
}if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
|
||||
}return t;
|
||||
};
|
||||
|
||||
var LazyRenderBox = function (_React$Component) {
|
||||
(0, _inherits3["default"])(LazyRenderBox, _React$Component);
|
||||
|
||||
function LazyRenderBox() {
|
||||
(0, _classCallCheck3["default"])(this, LazyRenderBox);
|
||||
return (0, _possibleConstructorReturn3["default"])(this, _React$Component.apply(this, arguments));
|
||||
}
|
||||
|
||||
LazyRenderBox.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
||||
if (nextProps.forceRender) {
|
||||
return true;
|
||||
}
|
||||
return !!nextProps.hiddenClassName || !!nextProps.visible;
|
||||
};
|
||||
|
||||
LazyRenderBox.prototype.render = function render() {
|
||||
var _a = this.props,
|
||||
className = _a.className,
|
||||
hiddenClassName = _a.hiddenClassName,
|
||||
visible = _a.visible,
|
||||
forceRender = _a.forceRender,
|
||||
restProps = __rest(_a, ["className", "hiddenClassName", "visible", "forceRender"]);
|
||||
var useClassName = className;
|
||||
if (!!hiddenClassName && !visible) {
|
||||
useClassName += " " + hiddenClassName;
|
||||
}
|
||||
return React.createElement("div", (0, _extends3["default"])({}, restProps, { className: useClassName }));
|
||||
};
|
||||
|
||||
return LazyRenderBox;
|
||||
}(React.Component);
|
||||
|
||||
exports["default"] = LazyRenderBox;
|
||||
module.exports = exports['default'];
|
||||
Reference in New Issue
Block a user