Latest updates from IceHrmPro
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = mapSelf;
|
||||
|
||||
var _react = _interopRequireDefault(require("react"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function mirror(o) {
|
||||
return o;
|
||||
}
|
||||
|
||||
function mapSelf(children) {
|
||||
// return ReactFragment
|
||||
return _react.default.Children.map(children, mirror);
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
import React from 'react';
|
||||
export default function toArray(children: React.ReactNode): React.ReactElement[];
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = toArray;
|
||||
|
||||
var _react = _interopRequireDefault(require("react"));
|
||||
|
||||
var _reactIs = require("react-is");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function toArray(children) {
|
||||
var ret = [];
|
||||
|
||||
_react.default.Children.forEach(children, function (child) {
|
||||
if (child === undefined || child === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(child)) {
|
||||
ret = ret.concat(toArray(child));
|
||||
} else if ((0, _reactIs.isFragment)(child) && child.props) {
|
||||
ret = ret.concat(toArray(child.props.children));
|
||||
} else {
|
||||
ret.push(child);
|
||||
}
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _react = _interopRequireDefault(require("react"));
|
||||
|
||||
var _reactDom = _interopRequireDefault(require("react-dom"));
|
||||
|
||||
var _propTypes = _interopRequireDefault(require("prop-types"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
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 _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 _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 _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); }
|
||||
|
||||
var ContainerRender = /*#__PURE__*/function (_React$Component) {
|
||||
_inherits(ContainerRender, _React$Component);
|
||||
|
||||
var _super = _createSuper(ContainerRender);
|
||||
|
||||
function ContainerRender() {
|
||||
var _this;
|
||||
|
||||
_classCallCheck(this, ContainerRender);
|
||||
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
_this = _super.call.apply(_super, [this].concat(args));
|
||||
|
||||
_this.removeContainer = function () {
|
||||
if (_this.container) {
|
||||
_reactDom.default.unmountComponentAtNode(_this.container);
|
||||
|
||||
_this.container.parentNode.removeChild(_this.container);
|
||||
|
||||
_this.container = null;
|
||||
}
|
||||
};
|
||||
|
||||
_this.renderComponent = function (props, ready) {
|
||||
var _this$props = _this.props,
|
||||
visible = _this$props.visible,
|
||||
getComponent = _this$props.getComponent,
|
||||
forceRender = _this$props.forceRender,
|
||||
getContainer = _this$props.getContainer,
|
||||
parent = _this$props.parent;
|
||||
|
||||
if (visible || parent._component || forceRender) {
|
||||
if (!_this.container) {
|
||||
_this.container = getContainer();
|
||||
}
|
||||
|
||||
_reactDom.default.unstable_renderSubtreeIntoContainer(parent, getComponent(props), _this.container, function callback() {
|
||||
if (ready) {
|
||||
ready.call(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(ContainerRender, [{
|
||||
key: "componentDidMount",
|
||||
value: function componentDidMount() {
|
||||
if (this.props.autoMount) {
|
||||
this.renderComponent();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "componentDidUpdate",
|
||||
value: function componentDidUpdate() {
|
||||
if (this.props.autoMount) {
|
||||
this.renderComponent();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "componentWillUnmount",
|
||||
value: function componentWillUnmount() {
|
||||
if (this.props.autoDestroy) {
|
||||
this.removeContainer();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
return this.props.children({
|
||||
renderComponent: this.renderComponent,
|
||||
removeContainer: this.removeContainer
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
return ContainerRender;
|
||||
}(_react.default.Component);
|
||||
|
||||
exports.default = ContainerRender;
|
||||
ContainerRender.propTypes = {
|
||||
autoMount: _propTypes.default.bool,
|
||||
autoDestroy: _propTypes.default.bool,
|
||||
visible: _propTypes.default.bool,
|
||||
forceRender: _propTypes.default.bool,
|
||||
parent: _propTypes.default.any,
|
||||
getComponent: _propTypes.default.func.isRequired,
|
||||
getContainer: _propTypes.default.func.isRequired,
|
||||
children: _propTypes.default.func.isRequired
|
||||
};
|
||||
ContainerRender.defaultProps = {
|
||||
autoMount: true,
|
||||
autoDestroy: true,
|
||||
forceRender: false
|
||||
};
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = addEventListenerWrap;
|
||||
|
||||
var _addDomEventListener = _interopRequireDefault(require("add-dom-event-listener"));
|
||||
|
||||
var _reactDom = _interopRequireDefault(require("react-dom"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function addEventListenerWrap(target, eventType, cb, option) {
|
||||
/* eslint camelcase: 2 */
|
||||
var callback = _reactDom.default.unstable_batchedUpdates ? function run(e) {
|
||||
_reactDom.default.unstable_batchedUpdates(cb, e);
|
||||
} : cb;
|
||||
return (0, _addDomEventListener.default)(target, eventType, callback, option);
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = canUseDom;
|
||||
|
||||
function canUseDom() {
|
||||
return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.hasClass = hasClass;
|
||||
exports.addClass = addClass;
|
||||
exports.removeClass = removeClass;
|
||||
|
||||
function hasClass(node, className) {
|
||||
if (node.classList) {
|
||||
return node.classList.contains(className);
|
||||
}
|
||||
|
||||
var originClass = node.className;
|
||||
return " ".concat(originClass, " ").indexOf(" ".concat(className, " ")) > -1;
|
||||
}
|
||||
|
||||
function addClass(node, className) {
|
||||
if (node.classList) {
|
||||
node.classList.add(className);
|
||||
} else {
|
||||
if (!hasClass(node, className)) {
|
||||
node.className = "".concat(node.className, " ").concat(className);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function removeClass(node, className) {
|
||||
if (node.classList) {
|
||||
node.classList.remove(className);
|
||||
} else {
|
||||
if (hasClass(node, className)) {
|
||||
var originClass = node.className;
|
||||
node.className = " ".concat(originClass, " ").replace(" ".concat(className, " "), ' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = contains;
|
||||
|
||||
function contains(root, n) {
|
||||
var node = n;
|
||||
|
||||
while (node) {
|
||||
if (node === root) {
|
||||
return true;
|
||||
}
|
||||
|
||||
node = node.parentNode;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.get = get;
|
||||
exports.set = set;
|
||||
exports.getOuterWidth = getOuterWidth;
|
||||
exports.getOuterHeight = getOuterHeight;
|
||||
exports.getDocSize = getDocSize;
|
||||
exports.getClientSize = getClientSize;
|
||||
exports.getScroll = getScroll;
|
||||
exports.getOffset = getOffset;
|
||||
|
||||
/* eslint-disable no-nested-ternary */
|
||||
var PIXEL_PATTERN = /margin|padding|width|height|max|min|offset/;
|
||||
var removePixel = {
|
||||
left: true,
|
||||
top: true
|
||||
};
|
||||
var floatMap = {
|
||||
cssFloat: 1,
|
||||
styleFloat: 1,
|
||||
float: 1
|
||||
};
|
||||
|
||||
function getComputedStyle(node) {
|
||||
return node.nodeType === 1 ? node.ownerDocument.defaultView.getComputedStyle(node, null) : {};
|
||||
}
|
||||
|
||||
function getStyleValue(node, type, value) {
|
||||
type = type.toLowerCase();
|
||||
|
||||
if (value === 'auto') {
|
||||
if (type === 'height') {
|
||||
return node.offsetHeight;
|
||||
}
|
||||
|
||||
if (type === 'width') {
|
||||
return node.offsetWidth;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(type in removePixel)) {
|
||||
removePixel[type] = PIXEL_PATTERN.test(type);
|
||||
}
|
||||
|
||||
return removePixel[type] ? parseFloat(value) || 0 : value;
|
||||
}
|
||||
|
||||
function get(node, name) {
|
||||
var length = arguments.length;
|
||||
var style = getComputedStyle(node);
|
||||
name = floatMap[name] ? 'cssFloat' in node.style ? 'cssFloat' : 'styleFloat' : name;
|
||||
return length === 1 ? style : getStyleValue(node, name, style[name] || node.style[name]);
|
||||
}
|
||||
|
||||
function set(node, name, value) {
|
||||
var length = arguments.length;
|
||||
name = floatMap[name] ? 'cssFloat' in node.style ? 'cssFloat' : 'styleFloat' : name;
|
||||
|
||||
if (length === 3) {
|
||||
if (typeof value === 'number' && PIXEL_PATTERN.test(name)) {
|
||||
value = "".concat(value, "px");
|
||||
}
|
||||
|
||||
node.style[name] = value; // Number
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
for (var x in name) {
|
||||
if (name.hasOwnProperty(x)) {
|
||||
set(node, x, name[x]);
|
||||
}
|
||||
}
|
||||
|
||||
return getComputedStyle(node);
|
||||
}
|
||||
|
||||
function getOuterWidth(el) {
|
||||
if (el === document.body) {
|
||||
return document.documentElement.clientWidth;
|
||||
}
|
||||
|
||||
return el.offsetWidth;
|
||||
}
|
||||
|
||||
function getOuterHeight(el) {
|
||||
if (el === document.body) {
|
||||
return window.innerHeight || document.documentElement.clientHeight;
|
||||
}
|
||||
|
||||
return el.offsetHeight;
|
||||
}
|
||||
|
||||
function getDocSize() {
|
||||
var width = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth);
|
||||
var height = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);
|
||||
return {
|
||||
width: width,
|
||||
height: height
|
||||
};
|
||||
}
|
||||
|
||||
function getClientSize() {
|
||||
var width = document.documentElement.clientWidth;
|
||||
var height = window.innerHeight || document.documentElement.clientHeight;
|
||||
return {
|
||||
width: width,
|
||||
height: height
|
||||
};
|
||||
}
|
||||
|
||||
function getScroll() {
|
||||
return {
|
||||
scrollLeft: Math.max(document.documentElement.scrollLeft, document.body.scrollLeft),
|
||||
scrollTop: Math.max(document.documentElement.scrollTop, document.body.scrollTop)
|
||||
};
|
||||
}
|
||||
|
||||
function getOffset(node) {
|
||||
var box = node.getBoundingClientRect();
|
||||
var docElem = document.documentElement; // < ie8 不支持 win.pageXOffset, 则使用 docElem.scrollLeft
|
||||
|
||||
return {
|
||||
left: box.left + (window.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || document.body.clientLeft || 0),
|
||||
top: box.top + (window.pageYOffset || docElem.scrollTop) - (docElem.clientTop || document.body.clientTop || 0)
|
||||
};
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/// <reference types="react" />
|
||||
/**
|
||||
* Return if a node is a DOM node. Else will return by `findDOMNode`
|
||||
*/
|
||||
export default function findDOMNode<T = Element | Text>(node: React.ReactInstance | HTMLElement): T;
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = findDOMNode;
|
||||
|
||||
var _reactDom = _interopRequireDefault(require("react-dom"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Return if a node is a DOM node. Else will return by `findDOMNode`
|
||||
*/
|
||||
function findDOMNode(node) {
|
||||
if (node instanceof HTMLElement) {
|
||||
return node;
|
||||
}
|
||||
|
||||
return _reactDom.default.findDOMNode(node);
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getFocusNodeList = getFocusNodeList;
|
||||
exports.saveLastFocusNode = saveLastFocusNode;
|
||||
exports.clearLastFocusNode = clearLastFocusNode;
|
||||
exports.backLastFocusNode = backLastFocusNode;
|
||||
exports.limitTabRange = limitTabRange;
|
||||
|
||||
function hidden(node) {
|
||||
return node.style.display === 'none';
|
||||
}
|
||||
|
||||
function visible(node) {
|
||||
while (node) {
|
||||
if (node === document.body) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (hidden(node)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
node = node.parentNode;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function focusable(node) {
|
||||
var nodeName = node.nodeName.toLowerCase();
|
||||
var tabIndex = parseInt(node.getAttribute('tabindex'), 10);
|
||||
var hasTabIndex = !isNaN(tabIndex) && tabIndex > -1;
|
||||
|
||||
if (visible(node)) {
|
||||
if (['input', 'select', 'textarea', 'button'].indexOf(nodeName) > -1) {
|
||||
return !node.disabled;
|
||||
} else if (nodeName === 'a') {
|
||||
return node.getAttribute('href') || hasTabIndex;
|
||||
}
|
||||
|
||||
return node.isContentEditable || hasTabIndex;
|
||||
}
|
||||
}
|
||||
|
||||
function getFocusNodeList(node) {
|
||||
var res = [].slice.call(node.querySelectorAll('*'), 0).filter(function (child) {
|
||||
return focusable(child);
|
||||
});
|
||||
|
||||
if (focusable(node)) {
|
||||
res.unshift(node);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
var lastFocusElement = null;
|
||||
|
||||
function saveLastFocusNode() {
|
||||
lastFocusElement = document.activeElement;
|
||||
}
|
||||
|
||||
function clearLastFocusNode() {
|
||||
lastFocusElement = null;
|
||||
}
|
||||
|
||||
function backLastFocusNode() {
|
||||
if (lastFocusElement) {
|
||||
try {
|
||||
// 元素可能已经被移动了
|
||||
lastFocusElement.focus();
|
||||
/* eslint-disable no-empty */
|
||||
} catch (e) {} // empty
|
||||
|
||||
/* eslint-enable no-empty */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function limitTabRange(node, e) {
|
||||
if (e.keyCode === 9) {
|
||||
var tabNodeList = getFocusNodeList(node);
|
||||
var lastTabNode = tabNodeList[e.shiftKey ? 0 : tabNodeList.length - 1];
|
||||
var leavingTab = lastTabNode === document.activeElement || node === document.activeElement;
|
||||
|
||||
if (leavingTab) {
|
||||
var target = tabNodeList[e.shiftKey ? tabNodeList.length - 1 : 0];
|
||||
target.focus();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.transition = exports.animation = void 0;
|
||||
|
||||
var _canUseDom = _interopRequireDefault(require("./canUseDom"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var animationEndEventNames = {
|
||||
WebkitAnimation: 'webkitAnimationEnd',
|
||||
OAnimation: 'oAnimationEnd',
|
||||
animation: 'animationend'
|
||||
};
|
||||
var transitionEventNames = {
|
||||
WebkitTransition: 'webkitTransitionEnd',
|
||||
OTransition: 'oTransitionEnd',
|
||||
transition: 'transitionend'
|
||||
};
|
||||
|
||||
function supportEnd(names) {
|
||||
var el = document.createElement('div');
|
||||
|
||||
for (var name in names) {
|
||||
if (names.hasOwnProperty(name) && el.style[name] !== undefined) {
|
||||
return {
|
||||
end: names[name]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var animation = (0, _canUseDom.default)() && supportEnd(animationEndEventNames);
|
||||
exports.animation = animation;
|
||||
var transition = (0, _canUseDom.default)() && supportEnd(transitionEventNames);
|
||||
exports.transition = transition;
|
||||
+436
@@ -0,0 +1,436 @@
|
||||
/**
|
||||
* @ignore
|
||||
* some key-codes definition and utils from closure-library
|
||||
* @author yiminghe@gmail.com
|
||||
*/
|
||||
declare const KeyCode: {
|
||||
/**
|
||||
* MAC_ENTER
|
||||
*/
|
||||
MAC_ENTER: number;
|
||||
/**
|
||||
* BACKSPACE
|
||||
*/
|
||||
BACKSPACE: number;
|
||||
/**
|
||||
* TAB
|
||||
*/
|
||||
TAB: number;
|
||||
/**
|
||||
* NUMLOCK on FF/Safari Mac
|
||||
*/
|
||||
NUM_CENTER: number;
|
||||
/**
|
||||
* ENTER
|
||||
*/
|
||||
ENTER: number;
|
||||
/**
|
||||
* SHIFT
|
||||
*/
|
||||
SHIFT: number;
|
||||
/**
|
||||
* CTRL
|
||||
*/
|
||||
CTRL: number;
|
||||
/**
|
||||
* ALT
|
||||
*/
|
||||
ALT: number;
|
||||
/**
|
||||
* PAUSE
|
||||
*/
|
||||
PAUSE: number;
|
||||
/**
|
||||
* CAPS_LOCK
|
||||
*/
|
||||
CAPS_LOCK: number;
|
||||
/**
|
||||
* ESC
|
||||
*/
|
||||
ESC: number;
|
||||
/**
|
||||
* SPACE
|
||||
*/
|
||||
SPACE: number;
|
||||
/**
|
||||
* PAGE_UP
|
||||
*/
|
||||
PAGE_UP: number;
|
||||
/**
|
||||
* PAGE_DOWN
|
||||
*/
|
||||
PAGE_DOWN: number;
|
||||
/**
|
||||
* END
|
||||
*/
|
||||
END: number;
|
||||
/**
|
||||
* HOME
|
||||
*/
|
||||
HOME: number;
|
||||
/**
|
||||
* LEFT
|
||||
*/
|
||||
LEFT: number;
|
||||
/**
|
||||
* UP
|
||||
*/
|
||||
UP: number;
|
||||
/**
|
||||
* RIGHT
|
||||
*/
|
||||
RIGHT: number;
|
||||
/**
|
||||
* DOWN
|
||||
*/
|
||||
DOWN: number;
|
||||
/**
|
||||
* PRINT_SCREEN
|
||||
*/
|
||||
PRINT_SCREEN: number;
|
||||
/**
|
||||
* INSERT
|
||||
*/
|
||||
INSERT: number;
|
||||
/**
|
||||
* DELETE
|
||||
*/
|
||||
DELETE: number;
|
||||
/**
|
||||
* ZERO
|
||||
*/
|
||||
ZERO: number;
|
||||
/**
|
||||
* ONE
|
||||
*/
|
||||
ONE: number;
|
||||
/**
|
||||
* TWO
|
||||
*/
|
||||
TWO: number;
|
||||
/**
|
||||
* THREE
|
||||
*/
|
||||
THREE: number;
|
||||
/**
|
||||
* FOUR
|
||||
*/
|
||||
FOUR: number;
|
||||
/**
|
||||
* FIVE
|
||||
*/
|
||||
FIVE: number;
|
||||
/**
|
||||
* SIX
|
||||
*/
|
||||
SIX: number;
|
||||
/**
|
||||
* SEVEN
|
||||
*/
|
||||
SEVEN: number;
|
||||
/**
|
||||
* EIGHT
|
||||
*/
|
||||
EIGHT: number;
|
||||
/**
|
||||
* NINE
|
||||
*/
|
||||
NINE: number;
|
||||
/**
|
||||
* QUESTION_MARK
|
||||
*/
|
||||
QUESTION_MARK: number;
|
||||
/**
|
||||
* A
|
||||
*/
|
||||
A: number;
|
||||
/**
|
||||
* B
|
||||
*/
|
||||
B: number;
|
||||
/**
|
||||
* C
|
||||
*/
|
||||
C: number;
|
||||
/**
|
||||
* D
|
||||
*/
|
||||
D: number;
|
||||
/**
|
||||
* E
|
||||
*/
|
||||
E: number;
|
||||
/**
|
||||
* F
|
||||
*/
|
||||
F: number;
|
||||
/**
|
||||
* G
|
||||
*/
|
||||
G: number;
|
||||
/**
|
||||
* H
|
||||
*/
|
||||
H: number;
|
||||
/**
|
||||
* I
|
||||
*/
|
||||
I: number;
|
||||
/**
|
||||
* J
|
||||
*/
|
||||
J: number;
|
||||
/**
|
||||
* K
|
||||
*/
|
||||
K: number;
|
||||
/**
|
||||
* L
|
||||
*/
|
||||
L: number;
|
||||
/**
|
||||
* M
|
||||
*/
|
||||
M: number;
|
||||
/**
|
||||
* N
|
||||
*/
|
||||
N: number;
|
||||
/**
|
||||
* O
|
||||
*/
|
||||
O: number;
|
||||
/**
|
||||
* P
|
||||
*/
|
||||
P: number;
|
||||
/**
|
||||
* Q
|
||||
*/
|
||||
Q: number;
|
||||
/**
|
||||
* R
|
||||
*/
|
||||
R: number;
|
||||
/**
|
||||
* S
|
||||
*/
|
||||
S: number;
|
||||
/**
|
||||
* T
|
||||
*/
|
||||
T: number;
|
||||
/**
|
||||
* U
|
||||
*/
|
||||
U: number;
|
||||
/**
|
||||
* V
|
||||
*/
|
||||
V: number;
|
||||
/**
|
||||
* W
|
||||
*/
|
||||
W: number;
|
||||
/**
|
||||
* X
|
||||
*/
|
||||
X: number;
|
||||
/**
|
||||
* Y
|
||||
*/
|
||||
Y: number;
|
||||
/**
|
||||
* Z
|
||||
*/
|
||||
Z: number;
|
||||
/**
|
||||
* META
|
||||
*/
|
||||
META: number;
|
||||
/**
|
||||
* WIN_KEY_RIGHT
|
||||
*/
|
||||
WIN_KEY_RIGHT: number;
|
||||
/**
|
||||
* CONTEXT_MENU
|
||||
*/
|
||||
CONTEXT_MENU: number;
|
||||
/**
|
||||
* NUM_ZERO
|
||||
*/
|
||||
NUM_ZERO: number;
|
||||
/**
|
||||
* NUM_ONE
|
||||
*/
|
||||
NUM_ONE: number;
|
||||
/**
|
||||
* NUM_TWO
|
||||
*/
|
||||
NUM_TWO: number;
|
||||
/**
|
||||
* NUM_THREE
|
||||
*/
|
||||
NUM_THREE: number;
|
||||
/**
|
||||
* NUM_FOUR
|
||||
*/
|
||||
NUM_FOUR: number;
|
||||
/**
|
||||
* NUM_FIVE
|
||||
*/
|
||||
NUM_FIVE: number;
|
||||
/**
|
||||
* NUM_SIX
|
||||
*/
|
||||
NUM_SIX: number;
|
||||
/**
|
||||
* NUM_SEVEN
|
||||
*/
|
||||
NUM_SEVEN: number;
|
||||
/**
|
||||
* NUM_EIGHT
|
||||
*/
|
||||
NUM_EIGHT: number;
|
||||
/**
|
||||
* NUM_NINE
|
||||
*/
|
||||
NUM_NINE: number;
|
||||
/**
|
||||
* NUM_MULTIPLY
|
||||
*/
|
||||
NUM_MULTIPLY: number;
|
||||
/**
|
||||
* NUM_PLUS
|
||||
*/
|
||||
NUM_PLUS: number;
|
||||
/**
|
||||
* NUM_MINUS
|
||||
*/
|
||||
NUM_MINUS: number;
|
||||
/**
|
||||
* NUM_PERIOD
|
||||
*/
|
||||
NUM_PERIOD: number;
|
||||
/**
|
||||
* NUM_DIVISION
|
||||
*/
|
||||
NUM_DIVISION: number;
|
||||
/**
|
||||
* F1
|
||||
*/
|
||||
F1: number;
|
||||
/**
|
||||
* F2
|
||||
*/
|
||||
F2: number;
|
||||
/**
|
||||
* F3
|
||||
*/
|
||||
F3: number;
|
||||
/**
|
||||
* F4
|
||||
*/
|
||||
F4: number;
|
||||
/**
|
||||
* F5
|
||||
*/
|
||||
F5: number;
|
||||
/**
|
||||
* F6
|
||||
*/
|
||||
F6: number;
|
||||
/**
|
||||
* F7
|
||||
*/
|
||||
F7: number;
|
||||
/**
|
||||
* F8
|
||||
*/
|
||||
F8: number;
|
||||
/**
|
||||
* F9
|
||||
*/
|
||||
F9: number;
|
||||
/**
|
||||
* F10
|
||||
*/
|
||||
F10: number;
|
||||
/**
|
||||
* F11
|
||||
*/
|
||||
F11: number;
|
||||
/**
|
||||
* F12
|
||||
*/
|
||||
F12: number;
|
||||
/**
|
||||
* NUMLOCK
|
||||
*/
|
||||
NUMLOCK: number;
|
||||
/**
|
||||
* SEMICOLON
|
||||
*/
|
||||
SEMICOLON: number;
|
||||
/**
|
||||
* DASH
|
||||
*/
|
||||
DASH: number;
|
||||
/**
|
||||
* EQUALS
|
||||
*/
|
||||
EQUALS: number;
|
||||
/**
|
||||
* COMMA
|
||||
*/
|
||||
COMMA: number;
|
||||
/**
|
||||
* PERIOD
|
||||
*/
|
||||
PERIOD: number;
|
||||
/**
|
||||
* SLASH
|
||||
*/
|
||||
SLASH: number;
|
||||
/**
|
||||
* APOSTROPHE
|
||||
*/
|
||||
APOSTROPHE: number;
|
||||
/**
|
||||
* SINGLE_QUOTE
|
||||
*/
|
||||
SINGLE_QUOTE: number;
|
||||
/**
|
||||
* OPEN_SQUARE_BRACKET
|
||||
*/
|
||||
OPEN_SQUARE_BRACKET: number;
|
||||
/**
|
||||
* BACKSLASH
|
||||
*/
|
||||
BACKSLASH: number;
|
||||
/**
|
||||
* CLOSE_SQUARE_BRACKET
|
||||
*/
|
||||
CLOSE_SQUARE_BRACKET: number;
|
||||
/**
|
||||
* WIN_KEY
|
||||
*/
|
||||
WIN_KEY: number;
|
||||
/**
|
||||
* MAC_FF_META
|
||||
*/
|
||||
MAC_FF_META: number;
|
||||
/**
|
||||
* WIN_IME
|
||||
*/
|
||||
WIN_IME: number;
|
||||
/**
|
||||
* whether text and modified key is entered at the same time.
|
||||
*/
|
||||
isTextModifyingKeyEvent: (e: KeyboardEvent) => boolean;
|
||||
/**
|
||||
* whether character is entered.
|
||||
*/
|
||||
isCharacterKey: (keyCode: number) => boolean;
|
||||
};
|
||||
export default KeyCode;
|
||||
+631
@@ -0,0 +1,631 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* some key-codes definition and utils from closure-library
|
||||
* @author yiminghe@gmail.com
|
||||
*/
|
||||
var KeyCode = {
|
||||
/**
|
||||
* MAC_ENTER
|
||||
*/
|
||||
MAC_ENTER: 3,
|
||||
|
||||
/**
|
||||
* BACKSPACE
|
||||
*/
|
||||
BACKSPACE: 8,
|
||||
|
||||
/**
|
||||
* TAB
|
||||
*/
|
||||
TAB: 9,
|
||||
|
||||
/**
|
||||
* NUMLOCK on FF/Safari Mac
|
||||
*/
|
||||
NUM_CENTER: 12,
|
||||
|
||||
/**
|
||||
* ENTER
|
||||
*/
|
||||
ENTER: 13,
|
||||
|
||||
/**
|
||||
* SHIFT
|
||||
*/
|
||||
SHIFT: 16,
|
||||
|
||||
/**
|
||||
* CTRL
|
||||
*/
|
||||
CTRL: 17,
|
||||
|
||||
/**
|
||||
* ALT
|
||||
*/
|
||||
ALT: 18,
|
||||
|
||||
/**
|
||||
* PAUSE
|
||||
*/
|
||||
PAUSE: 19,
|
||||
|
||||
/**
|
||||
* CAPS_LOCK
|
||||
*/
|
||||
CAPS_LOCK: 20,
|
||||
|
||||
/**
|
||||
* ESC
|
||||
*/
|
||||
ESC: 27,
|
||||
|
||||
/**
|
||||
* SPACE
|
||||
*/
|
||||
SPACE: 32,
|
||||
|
||||
/**
|
||||
* PAGE_UP
|
||||
*/
|
||||
PAGE_UP: 33,
|
||||
|
||||
/**
|
||||
* PAGE_DOWN
|
||||
*/
|
||||
PAGE_DOWN: 34,
|
||||
|
||||
/**
|
||||
* END
|
||||
*/
|
||||
END: 35,
|
||||
|
||||
/**
|
||||
* HOME
|
||||
*/
|
||||
HOME: 36,
|
||||
|
||||
/**
|
||||
* LEFT
|
||||
*/
|
||||
LEFT: 37,
|
||||
|
||||
/**
|
||||
* UP
|
||||
*/
|
||||
UP: 38,
|
||||
|
||||
/**
|
||||
* RIGHT
|
||||
*/
|
||||
RIGHT: 39,
|
||||
|
||||
/**
|
||||
* DOWN
|
||||
*/
|
||||
DOWN: 40,
|
||||
|
||||
/**
|
||||
* PRINT_SCREEN
|
||||
*/
|
||||
PRINT_SCREEN: 44,
|
||||
|
||||
/**
|
||||
* INSERT
|
||||
*/
|
||||
INSERT: 45,
|
||||
|
||||
/**
|
||||
* DELETE
|
||||
*/
|
||||
DELETE: 46,
|
||||
|
||||
/**
|
||||
* ZERO
|
||||
*/
|
||||
ZERO: 48,
|
||||
|
||||
/**
|
||||
* ONE
|
||||
*/
|
||||
ONE: 49,
|
||||
|
||||
/**
|
||||
* TWO
|
||||
*/
|
||||
TWO: 50,
|
||||
|
||||
/**
|
||||
* THREE
|
||||
*/
|
||||
THREE: 51,
|
||||
|
||||
/**
|
||||
* FOUR
|
||||
*/
|
||||
FOUR: 52,
|
||||
|
||||
/**
|
||||
* FIVE
|
||||
*/
|
||||
FIVE: 53,
|
||||
|
||||
/**
|
||||
* SIX
|
||||
*/
|
||||
SIX: 54,
|
||||
|
||||
/**
|
||||
* SEVEN
|
||||
*/
|
||||
SEVEN: 55,
|
||||
|
||||
/**
|
||||
* EIGHT
|
||||
*/
|
||||
EIGHT: 56,
|
||||
|
||||
/**
|
||||
* NINE
|
||||
*/
|
||||
NINE: 57,
|
||||
|
||||
/**
|
||||
* QUESTION_MARK
|
||||
*/
|
||||
QUESTION_MARK: 63,
|
||||
|
||||
/**
|
||||
* A
|
||||
*/
|
||||
A: 65,
|
||||
|
||||
/**
|
||||
* B
|
||||
*/
|
||||
B: 66,
|
||||
|
||||
/**
|
||||
* C
|
||||
*/
|
||||
C: 67,
|
||||
|
||||
/**
|
||||
* D
|
||||
*/
|
||||
D: 68,
|
||||
|
||||
/**
|
||||
* E
|
||||
*/
|
||||
E: 69,
|
||||
|
||||
/**
|
||||
* F
|
||||
*/
|
||||
F: 70,
|
||||
|
||||
/**
|
||||
* G
|
||||
*/
|
||||
G: 71,
|
||||
|
||||
/**
|
||||
* H
|
||||
*/
|
||||
H: 72,
|
||||
|
||||
/**
|
||||
* I
|
||||
*/
|
||||
I: 73,
|
||||
|
||||
/**
|
||||
* J
|
||||
*/
|
||||
J: 74,
|
||||
|
||||
/**
|
||||
* K
|
||||
*/
|
||||
K: 75,
|
||||
|
||||
/**
|
||||
* L
|
||||
*/
|
||||
L: 76,
|
||||
|
||||
/**
|
||||
* M
|
||||
*/
|
||||
M: 77,
|
||||
|
||||
/**
|
||||
* N
|
||||
*/
|
||||
N: 78,
|
||||
|
||||
/**
|
||||
* O
|
||||
*/
|
||||
O: 79,
|
||||
|
||||
/**
|
||||
* P
|
||||
*/
|
||||
P: 80,
|
||||
|
||||
/**
|
||||
* Q
|
||||
*/
|
||||
Q: 81,
|
||||
|
||||
/**
|
||||
* R
|
||||
*/
|
||||
R: 82,
|
||||
|
||||
/**
|
||||
* S
|
||||
*/
|
||||
S: 83,
|
||||
|
||||
/**
|
||||
* T
|
||||
*/
|
||||
T: 84,
|
||||
|
||||
/**
|
||||
* U
|
||||
*/
|
||||
U: 85,
|
||||
|
||||
/**
|
||||
* V
|
||||
*/
|
||||
V: 86,
|
||||
|
||||
/**
|
||||
* W
|
||||
*/
|
||||
W: 87,
|
||||
|
||||
/**
|
||||
* X
|
||||
*/
|
||||
X: 88,
|
||||
|
||||
/**
|
||||
* Y
|
||||
*/
|
||||
Y: 89,
|
||||
|
||||
/**
|
||||
* Z
|
||||
*/
|
||||
Z: 90,
|
||||
|
||||
/**
|
||||
* META
|
||||
*/
|
||||
META: 91,
|
||||
|
||||
/**
|
||||
* WIN_KEY_RIGHT
|
||||
*/
|
||||
WIN_KEY_RIGHT: 92,
|
||||
|
||||
/**
|
||||
* CONTEXT_MENU
|
||||
*/
|
||||
CONTEXT_MENU: 93,
|
||||
|
||||
/**
|
||||
* NUM_ZERO
|
||||
*/
|
||||
NUM_ZERO: 96,
|
||||
|
||||
/**
|
||||
* NUM_ONE
|
||||
*/
|
||||
NUM_ONE: 97,
|
||||
|
||||
/**
|
||||
* NUM_TWO
|
||||
*/
|
||||
NUM_TWO: 98,
|
||||
|
||||
/**
|
||||
* NUM_THREE
|
||||
*/
|
||||
NUM_THREE: 99,
|
||||
|
||||
/**
|
||||
* NUM_FOUR
|
||||
*/
|
||||
NUM_FOUR: 100,
|
||||
|
||||
/**
|
||||
* NUM_FIVE
|
||||
*/
|
||||
NUM_FIVE: 101,
|
||||
|
||||
/**
|
||||
* NUM_SIX
|
||||
*/
|
||||
NUM_SIX: 102,
|
||||
|
||||
/**
|
||||
* NUM_SEVEN
|
||||
*/
|
||||
NUM_SEVEN: 103,
|
||||
|
||||
/**
|
||||
* NUM_EIGHT
|
||||
*/
|
||||
NUM_EIGHT: 104,
|
||||
|
||||
/**
|
||||
* NUM_NINE
|
||||
*/
|
||||
NUM_NINE: 105,
|
||||
|
||||
/**
|
||||
* NUM_MULTIPLY
|
||||
*/
|
||||
NUM_MULTIPLY: 106,
|
||||
|
||||
/**
|
||||
* NUM_PLUS
|
||||
*/
|
||||
NUM_PLUS: 107,
|
||||
|
||||
/**
|
||||
* NUM_MINUS
|
||||
*/
|
||||
NUM_MINUS: 109,
|
||||
|
||||
/**
|
||||
* NUM_PERIOD
|
||||
*/
|
||||
NUM_PERIOD: 110,
|
||||
|
||||
/**
|
||||
* NUM_DIVISION
|
||||
*/
|
||||
NUM_DIVISION: 111,
|
||||
|
||||
/**
|
||||
* F1
|
||||
*/
|
||||
F1: 112,
|
||||
|
||||
/**
|
||||
* F2
|
||||
*/
|
||||
F2: 113,
|
||||
|
||||
/**
|
||||
* F3
|
||||
*/
|
||||
F3: 114,
|
||||
|
||||
/**
|
||||
* F4
|
||||
*/
|
||||
F4: 115,
|
||||
|
||||
/**
|
||||
* F5
|
||||
*/
|
||||
F5: 116,
|
||||
|
||||
/**
|
||||
* F6
|
||||
*/
|
||||
F6: 117,
|
||||
|
||||
/**
|
||||
* F7
|
||||
*/
|
||||
F7: 118,
|
||||
|
||||
/**
|
||||
* F8
|
||||
*/
|
||||
F8: 119,
|
||||
|
||||
/**
|
||||
* F9
|
||||
*/
|
||||
F9: 120,
|
||||
|
||||
/**
|
||||
* F10
|
||||
*/
|
||||
F10: 121,
|
||||
|
||||
/**
|
||||
* F11
|
||||
*/
|
||||
F11: 122,
|
||||
|
||||
/**
|
||||
* F12
|
||||
*/
|
||||
F12: 123,
|
||||
|
||||
/**
|
||||
* NUMLOCK
|
||||
*/
|
||||
NUMLOCK: 144,
|
||||
|
||||
/**
|
||||
* SEMICOLON
|
||||
*/
|
||||
SEMICOLON: 186,
|
||||
|
||||
/**
|
||||
* DASH
|
||||
*/
|
||||
DASH: 189,
|
||||
|
||||
/**
|
||||
* EQUALS
|
||||
*/
|
||||
EQUALS: 187,
|
||||
|
||||
/**
|
||||
* COMMA
|
||||
*/
|
||||
COMMA: 188,
|
||||
|
||||
/**
|
||||
* PERIOD
|
||||
*/
|
||||
PERIOD: 190,
|
||||
|
||||
/**
|
||||
* SLASH
|
||||
*/
|
||||
SLASH: 191,
|
||||
|
||||
/**
|
||||
* APOSTROPHE
|
||||
*/
|
||||
APOSTROPHE: 192,
|
||||
|
||||
/**
|
||||
* SINGLE_QUOTE
|
||||
*/
|
||||
SINGLE_QUOTE: 222,
|
||||
|
||||
/**
|
||||
* OPEN_SQUARE_BRACKET
|
||||
*/
|
||||
OPEN_SQUARE_BRACKET: 219,
|
||||
|
||||
/**
|
||||
* BACKSLASH
|
||||
*/
|
||||
BACKSLASH: 220,
|
||||
|
||||
/**
|
||||
* CLOSE_SQUARE_BRACKET
|
||||
*/
|
||||
CLOSE_SQUARE_BRACKET: 221,
|
||||
|
||||
/**
|
||||
* WIN_KEY
|
||||
*/
|
||||
WIN_KEY: 224,
|
||||
|
||||
/**
|
||||
* MAC_FF_META
|
||||
*/
|
||||
MAC_FF_META: 224,
|
||||
|
||||
/**
|
||||
* WIN_IME
|
||||
*/
|
||||
WIN_IME: 229,
|
||||
// ======================== Function ========================
|
||||
|
||||
/**
|
||||
* whether text and modified key is entered at the same time.
|
||||
*/
|
||||
isTextModifyingKeyEvent: function isTextModifyingKeyEvent(e) {
|
||||
var keyCode = e.keyCode;
|
||||
|
||||
if (e.altKey && !e.ctrlKey || e.metaKey || // Function keys don't generate text
|
||||
keyCode >= KeyCode.F1 && keyCode <= KeyCode.F12) {
|
||||
return false;
|
||||
} // The following keys are quite harmless, even in combination with
|
||||
// CTRL, ALT or SHIFT.
|
||||
|
||||
|
||||
switch (keyCode) {
|
||||
case KeyCode.ALT:
|
||||
case KeyCode.CAPS_LOCK:
|
||||
case KeyCode.CONTEXT_MENU:
|
||||
case KeyCode.CTRL:
|
||||
case KeyCode.DOWN:
|
||||
case KeyCode.END:
|
||||
case KeyCode.ESC:
|
||||
case KeyCode.HOME:
|
||||
case KeyCode.INSERT:
|
||||
case KeyCode.LEFT:
|
||||
case KeyCode.MAC_FF_META:
|
||||
case KeyCode.META:
|
||||
case KeyCode.NUMLOCK:
|
||||
case KeyCode.NUM_CENTER:
|
||||
case KeyCode.PAGE_DOWN:
|
||||
case KeyCode.PAGE_UP:
|
||||
case KeyCode.PAUSE:
|
||||
case KeyCode.PRINT_SCREEN:
|
||||
case KeyCode.RIGHT:
|
||||
case KeyCode.SHIFT:
|
||||
case KeyCode.UP:
|
||||
case KeyCode.WIN_KEY:
|
||||
case KeyCode.WIN_KEY_RIGHT:
|
||||
return false;
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* whether character is entered.
|
||||
*/
|
||||
isCharacterKey: function isCharacterKey(keyCode) {
|
||||
if (keyCode >= KeyCode.ZERO && keyCode <= KeyCode.NINE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (keyCode >= KeyCode.NUM_ZERO && keyCode <= KeyCode.NUM_MULTIPLY) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (keyCode >= KeyCode.A && keyCode <= KeyCode.Z) {
|
||||
return true;
|
||||
} // Safari sends zero key code for non-latin characters.
|
||||
|
||||
|
||||
if (window.navigator.userAgent.indexOf('WebKit') !== -1 && keyCode === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (keyCode) {
|
||||
case KeyCode.SPACE:
|
||||
case KeyCode.QUESTION_MARK:
|
||||
case KeyCode.NUM_PLUS:
|
||||
case KeyCode.NUM_MINUS:
|
||||
case KeyCode.NUM_PERIOD:
|
||||
case KeyCode.NUM_DIVISION:
|
||||
case KeyCode.SEMICOLON:
|
||||
case KeyCode.DASH:
|
||||
case KeyCode.EQUALS:
|
||||
case KeyCode.COMMA:
|
||||
case KeyCode.PERIOD:
|
||||
case KeyCode.SLASH:
|
||||
case KeyCode.APOSTROPHE:
|
||||
case KeyCode.SINGLE_QUOTE:
|
||||
case KeyCode.OPEN_SQUARE_BRACKET:
|
||||
case KeyCode.BACKSLASH:
|
||||
case KeyCode.CLOSE_SQUARE_BRACKET:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
var _default = KeyCode;
|
||||
exports.default = _default;
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _react = _interopRequireDefault(require("react"));
|
||||
|
||||
var _reactDom = _interopRequireDefault(require("react-dom"));
|
||||
|
||||
var _propTypes = _interopRequireDefault(require("prop-types"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
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 _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 _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 _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); }
|
||||
|
||||
var Portal = /*#__PURE__*/function (_React$Component) {
|
||||
_inherits(Portal, _React$Component);
|
||||
|
||||
var _super = _createSuper(Portal);
|
||||
|
||||
function Portal() {
|
||||
_classCallCheck(this, Portal);
|
||||
|
||||
return _super.apply(this, arguments);
|
||||
}
|
||||
|
||||
_createClass(Portal, [{
|
||||
key: "componentDidMount",
|
||||
value: function componentDidMount() {
|
||||
this.createContainer();
|
||||
}
|
||||
}, {
|
||||
key: "componentDidUpdate",
|
||||
value: function componentDidUpdate(prevProps) {
|
||||
var didUpdate = this.props.didUpdate;
|
||||
|
||||
if (didUpdate) {
|
||||
didUpdate(prevProps);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "componentWillUnmount",
|
||||
value: function componentWillUnmount() {
|
||||
this.removeContainer();
|
||||
}
|
||||
}, {
|
||||
key: "createContainer",
|
||||
value: function createContainer() {
|
||||
this._container = this.props.getContainer();
|
||||
this.forceUpdate();
|
||||
}
|
||||
}, {
|
||||
key: "removeContainer",
|
||||
value: function removeContainer() {
|
||||
if (this._container) {
|
||||
this._container.parentNode.removeChild(this._container);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
if (this._container) {
|
||||
return _reactDom.default.createPortal(this.props.children, this._container);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Portal;
|
||||
}(_react.default.Component);
|
||||
|
||||
exports.default = Portal;
|
||||
Portal.propTypes = {
|
||||
getContainer: _propTypes.default.func.isRequired,
|
||||
children: _propTypes.default.node.isRequired,
|
||||
didUpdate: _propTypes.default.func
|
||||
};
|
||||
+272
@@ -0,0 +1,272 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _react = _interopRequireDefault(require("react"));
|
||||
|
||||
var _reactDom = _interopRequireDefault(require("react-dom"));
|
||||
|
||||
var _propTypes = _interopRequireDefault(require("prop-types"));
|
||||
|
||||
var _reactLifecyclesCompat = require("react-lifecycles-compat");
|
||||
|
||||
var _ContainerRender = _interopRequireDefault(require("./ContainerRender"));
|
||||
|
||||
var _Portal = _interopRequireDefault(require("./Portal"));
|
||||
|
||||
var _switchScrollingEffect = _interopRequireDefault(require("./switchScrollingEffect"));
|
||||
|
||||
var _setStyle = _interopRequireDefault(require("./setStyle"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
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(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(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 _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 _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 _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 _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); }
|
||||
|
||||
var openCount = 0;
|
||||
var windowIsUndefined = !(typeof window !== 'undefined' && window.document && window.document.createElement);
|
||||
var IS_REACT_16 = ('createPortal' in _reactDom.default); // https://github.com/ant-design/ant-design/issues/19340
|
||||
// https://github.com/ant-design/ant-design/issues/19332
|
||||
|
||||
var cacheOverflow = {};
|
||||
|
||||
var PortalWrapper = /*#__PURE__*/function (_React$Component) {
|
||||
_inherits(PortalWrapper, _React$Component);
|
||||
|
||||
var _super = _createSuper(PortalWrapper);
|
||||
|
||||
function PortalWrapper(props) {
|
||||
var _this;
|
||||
|
||||
_classCallCheck(this, PortalWrapper);
|
||||
|
||||
_this = _super.call(this, props);
|
||||
|
||||
_this.getParent = function () {
|
||||
var getContainer = _this.props.getContainer;
|
||||
|
||||
if (getContainer) {
|
||||
if (typeof getContainer === 'string') {
|
||||
return document.querySelectorAll(getContainer)[0];
|
||||
}
|
||||
|
||||
if (typeof getContainer === 'function') {
|
||||
return getContainer();
|
||||
}
|
||||
|
||||
if (_typeof(getContainer) === 'object' && getContainer instanceof window.HTMLElement) {
|
||||
return getContainer;
|
||||
}
|
||||
}
|
||||
|
||||
return document.body;
|
||||
};
|
||||
|
||||
_this.getContainer = function () {
|
||||
if (windowIsUndefined) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!_this.container) {
|
||||
_this.container = document.createElement('div');
|
||||
|
||||
var parent = _this.getParent();
|
||||
|
||||
if (parent) {
|
||||
parent.appendChild(_this.container);
|
||||
}
|
||||
}
|
||||
|
||||
_this.setWrapperClassName();
|
||||
|
||||
return _this.container;
|
||||
};
|
||||
|
||||
_this.setWrapperClassName = function () {
|
||||
var wrapperClassName = _this.props.wrapperClassName;
|
||||
|
||||
if (_this.container && wrapperClassName && wrapperClassName !== _this.container.className) {
|
||||
_this.container.className = wrapperClassName;
|
||||
}
|
||||
};
|
||||
|
||||
_this.savePortal = function (c) {
|
||||
// Warning: don't rename _component
|
||||
// https://github.com/react-component/util/pull/65#discussion_r352407916
|
||||
_this._component = c;
|
||||
};
|
||||
|
||||
_this.removeCurrentContainer = function (visible) {
|
||||
_this.container = null;
|
||||
_this._component = null;
|
||||
|
||||
if (!IS_REACT_16) {
|
||||
if (visible) {
|
||||
_this.renderComponent({
|
||||
afterClose: _this.removeContainer,
|
||||
onClose: function onClose() {},
|
||||
visible: false
|
||||
});
|
||||
} else {
|
||||
_this.removeContainer();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_this.switchScrollingEffect = function () {
|
||||
if (openCount === 1 && !Object.keys(cacheOverflow).length) {
|
||||
(0, _switchScrollingEffect.default)(); // Must be set after switchScrollingEffect
|
||||
|
||||
cacheOverflow = (0, _setStyle.default)({
|
||||
overflow: 'hidden',
|
||||
overflowX: 'hidden',
|
||||
overflowY: 'hidden'
|
||||
});
|
||||
} else if (!openCount) {
|
||||
(0, _setStyle.default)(cacheOverflow);
|
||||
cacheOverflow = {};
|
||||
(0, _switchScrollingEffect.default)(true);
|
||||
}
|
||||
};
|
||||
|
||||
var _visible = props.visible;
|
||||
openCount = _visible ? openCount + 1 : openCount;
|
||||
_this.state = {
|
||||
_self: _assertThisInitialized(_this)
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(PortalWrapper, [{
|
||||
key: "componentDidUpdate",
|
||||
value: function componentDidUpdate() {
|
||||
this.setWrapperClassName();
|
||||
}
|
||||
}, {
|
||||
key: "componentWillUnmount",
|
||||
value: function componentWillUnmount() {
|
||||
var visible = this.props.visible; // 离开时不会 render, 导到离开时数值不变,改用 func 。。
|
||||
|
||||
openCount = visible && openCount ? openCount - 1 : openCount;
|
||||
this.removeCurrentContainer(visible);
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this2 = this;
|
||||
|
||||
var _this$props = this.props,
|
||||
children = _this$props.children,
|
||||
forceRender = _this$props.forceRender,
|
||||
visible = _this$props.visible;
|
||||
var portal = null;
|
||||
var childProps = {
|
||||
getOpenCount: function getOpenCount() {
|
||||
return openCount;
|
||||
},
|
||||
getContainer: this.getContainer,
|
||||
switchScrollingEffect: this.switchScrollingEffect
|
||||
}; // suppport react15
|
||||
|
||||
if (!IS_REACT_16) {
|
||||
return /*#__PURE__*/_react.default.createElement(_ContainerRender.default, {
|
||||
parent: this,
|
||||
visible: visible,
|
||||
autoDestroy: false,
|
||||
getComponent: function getComponent() {
|
||||
var extra = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
return children(_objectSpread({}, extra, {}, childProps, {
|
||||
ref: _this2.savePortal
|
||||
}));
|
||||
},
|
||||
getContainer: this.getContainer,
|
||||
forceRender: forceRender
|
||||
}, function (_ref) {
|
||||
var renderComponent = _ref.renderComponent,
|
||||
removeContainer = _ref.removeContainer;
|
||||
_this2.renderComponent = renderComponent;
|
||||
_this2.removeContainer = removeContainer;
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
if (forceRender || visible || this._component) {
|
||||
portal = /*#__PURE__*/_react.default.createElement(_Portal.default, {
|
||||
getContainer: this.getContainer,
|
||||
ref: this.savePortal
|
||||
}, children(childProps));
|
||||
}
|
||||
|
||||
return portal;
|
||||
}
|
||||
}], [{
|
||||
key: "getDerivedStateFromProps",
|
||||
value: function getDerivedStateFromProps(props, _ref2) {
|
||||
var prevProps = _ref2.prevProps,
|
||||
_self = _ref2._self;
|
||||
var visible = props.visible,
|
||||
getContainer = props.getContainer;
|
||||
|
||||
if (prevProps) {
|
||||
var prevVisible = prevProps.visible,
|
||||
prevGetContainer = prevProps.getContainer;
|
||||
|
||||
if (visible !== prevVisible) {
|
||||
openCount = visible && !prevVisible ? openCount + 1 : openCount - 1;
|
||||
}
|
||||
|
||||
var getContainerIsFunc = typeof getContainer === 'function' && typeof prevGetContainer === 'function';
|
||||
|
||||
if (getContainerIsFunc ? getContainer.toString() !== prevGetContainer.toString() : getContainer !== prevGetContainer) {
|
||||
_self.removeCurrentContainer(false);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
prevProps: props
|
||||
};
|
||||
}
|
||||
}]);
|
||||
|
||||
return PortalWrapper;
|
||||
}(_react.default.Component);
|
||||
|
||||
PortalWrapper.propTypes = {
|
||||
wrapperClassName: _propTypes.default.string,
|
||||
forceRender: _propTypes.default.bool,
|
||||
getContainer: _propTypes.default.any,
|
||||
children: _propTypes.default.func,
|
||||
visible: _propTypes.default.bool
|
||||
};
|
||||
|
||||
var _default = (0, _reactLifecyclesCompat.polyfill)(PortalWrapper);
|
||||
|
||||
exports.default = _default;
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule ReactComponentWithPureRenderMixin
|
||||
*/
|
||||
var shallowEqual = require('shallowequal');
|
||||
|
||||
function shallowCompare(instance, nextProps, nextState) {
|
||||
return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);
|
||||
}
|
||||
/**
|
||||
* If your React component's render function is "pure", e.g. it will render the
|
||||
* same result given the same props and state, provide this mixin for a
|
||||
* considerable performance boost.
|
||||
*
|
||||
* Most React components have pure render functions.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* var ReactComponentWithPureRenderMixin =
|
||||
* require('ReactComponentWithPureRenderMixin');
|
||||
* React.createClass({
|
||||
* mixins: [ReactComponentWithPureRenderMixin],
|
||||
*
|
||||
* render: function() {
|
||||
* return <div className={this.props.className}>foo</div>;
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* Note: This only checks shallow equality for props and state. If these contain
|
||||
* complex data structures this mixin may have false-negatives for deeper
|
||||
* differences. Only mixin to components which have simple props and state, or
|
||||
* use `forceUpdate()` when you know deep data structures have changed.
|
||||
*
|
||||
* See https://facebook.github.io/react/docs/pure-render-mixin.html
|
||||
*/
|
||||
|
||||
|
||||
var ReactComponentWithPureRenderMixin = {
|
||||
shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) {
|
||||
return shallowCompare(this, nextProps, nextState);
|
||||
}
|
||||
};
|
||||
module.exports = ReactComponentWithPureRenderMixin;
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = createChainedFunction;
|
||||
|
||||
/**
|
||||
* Safe chained function
|
||||
*
|
||||
* Will only create a new function if needed,
|
||||
* otherwise will pass back existing functions or null.
|
||||
*
|
||||
* @returns {function|null}
|
||||
*/
|
||||
function createChainedFunction() {
|
||||
var args = [].slice.call(arguments, 0);
|
||||
|
||||
if (args.length === 1) {
|
||||
return args[0];
|
||||
}
|
||||
|
||||
return function chainedFunction() {
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
if (args[i] && args[i].apply) {
|
||||
args[i].apply(this, arguments);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = diff;
|
||||
|
||||
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
||||
|
||||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
||||
|
||||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
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(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(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; }
|
||||
|
||||
/* eslint no-proto: 0 */
|
||||
function createArray() {
|
||||
var arr = [];
|
||||
arr.__proto__ = new Array();
|
||||
|
||||
arr.__proto__.format = function toString() {
|
||||
return this.map(function (obj) {
|
||||
return _objectSpread({}, obj, {
|
||||
path: obj.path.join(' > ')
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
arr.__proto__.toString = function toString() {
|
||||
return JSON.stringify(this.format(), null, 2);
|
||||
};
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
function diff(obj1, obj2) {
|
||||
var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
|
||||
var path = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
||||
var diffList = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : createArray();
|
||||
if (depth <= 0) return diffList;
|
||||
var keys = new Set([].concat(_toConsumableArray(Object.keys(obj1)), _toConsumableArray(Object.keys(obj2))));
|
||||
keys.forEach(function (key) {
|
||||
var value1 = obj1[key];
|
||||
var value2 = obj2[key]; // Same value
|
||||
|
||||
if (value1 === value2) return;
|
||||
|
||||
var type1 = _typeof(value1);
|
||||
|
||||
var type2 = _typeof(value2); // Diff type
|
||||
|
||||
|
||||
if (type1 !== type2) {
|
||||
diffList.push({
|
||||
path: path.concat(key),
|
||||
value1: value1,
|
||||
value2: value2
|
||||
});
|
||||
return;
|
||||
} // NaN
|
||||
|
||||
|
||||
if (Number.isNaN(value1) && Number.isNaN(value2)) {
|
||||
return;
|
||||
} // Object & Array
|
||||
|
||||
|
||||
if (type1 === 'object' && value1 !== null && value2 !== null) {
|
||||
diff(value1, value2, depth - 1, path.concat(key), diffList);
|
||||
return;
|
||||
} // Rest
|
||||
|
||||
|
||||
diffList.push({
|
||||
path: path.concat(key),
|
||||
value1: value1,
|
||||
value2: value2
|
||||
});
|
||||
});
|
||||
return diffList;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = deprecated;
|
||||
|
||||
function deprecated(props, instead, component) {
|
||||
if (typeof window !== 'undefined' && window.console && window.console.error) {
|
||||
window.console.error("Warning: ".concat(props, " is deprecated at [ ").concat(component, " ], ") + "use [ ".concat(instead, " ] instead of it."));
|
||||
}
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = getContainerRenderMixin;
|
||||
|
||||
var _reactDom = _interopRequireDefault(require("react-dom"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
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(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(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 defaultGetContainer() {
|
||||
var container = document.createElement('div');
|
||||
document.body.appendChild(container);
|
||||
return container;
|
||||
}
|
||||
|
||||
function getContainerRenderMixin(config) {
|
||||
var _config$autoMount = config.autoMount,
|
||||
autoMount = _config$autoMount === void 0 ? true : _config$autoMount,
|
||||
_config$autoDestroy = config.autoDestroy,
|
||||
autoDestroy = _config$autoDestroy === void 0 ? true : _config$autoDestroy,
|
||||
isVisible = config.isVisible,
|
||||
isForceRender = config.isForceRender,
|
||||
getComponent = config.getComponent,
|
||||
_config$getContainer = config.getContainer,
|
||||
getContainer = _config$getContainer === void 0 ? defaultGetContainer : _config$getContainer;
|
||||
var mixin;
|
||||
|
||||
function _renderComponent(instance, componentArg, ready) {
|
||||
if (!isVisible || instance._component || isVisible(instance) || isForceRender && isForceRender(instance)) {
|
||||
if (!instance._container) {
|
||||
instance._container = getContainer(instance);
|
||||
}
|
||||
|
||||
var component;
|
||||
|
||||
if (instance.getComponent) {
|
||||
component = instance.getComponent(componentArg);
|
||||
} else {
|
||||
component = getComponent(instance, componentArg);
|
||||
}
|
||||
|
||||
_reactDom.default.unstable_renderSubtreeIntoContainer(instance, component, instance._container, function callback() {
|
||||
instance._component = this;
|
||||
|
||||
if (ready) {
|
||||
ready.call(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (autoMount) {
|
||||
mixin = _objectSpread({}, mixin, {
|
||||
componentDidMount: function componentDidMount() {
|
||||
_renderComponent(this);
|
||||
},
|
||||
componentDidUpdate: function componentDidUpdate() {
|
||||
_renderComponent(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!autoMount || !autoDestroy) {
|
||||
mixin = _objectSpread({}, mixin, {
|
||||
renderComponent: function renderComponent(componentArg, ready) {
|
||||
_renderComponent(this, componentArg, ready);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function _removeContainer(instance) {
|
||||
if (instance._container) {
|
||||
var container = instance._container;
|
||||
|
||||
_reactDom.default.unmountComponentAtNode(container);
|
||||
|
||||
container.parentNode.removeChild(container);
|
||||
instance._container = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (autoDestroy) {
|
||||
mixin = _objectSpread({}, mixin, {
|
||||
componentWillUnmount: function componentWillUnmount() {
|
||||
_removeContainer(this);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mixin = _objectSpread({}, mixin, {
|
||||
removeContainer: function removeContainer() {
|
||||
_removeContainer(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return mixin;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = getScrollBarSize;
|
||||
var cached;
|
||||
|
||||
function getScrollBarSize(fresh) {
|
||||
if (typeof document === 'undefined') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fresh || cached === undefined) {
|
||||
var inner = document.createElement('div');
|
||||
inner.style.width = '100%';
|
||||
inner.style.height = '200px';
|
||||
var outer = document.createElement('div');
|
||||
var outerStyle = outer.style;
|
||||
outerStyle.position = 'absolute';
|
||||
outerStyle.top = 0;
|
||||
outerStyle.left = 0;
|
||||
outerStyle.pointerEvents = 'none';
|
||||
outerStyle.visibility = 'hidden';
|
||||
outerStyle.width = '200px';
|
||||
outerStyle.height = '150px';
|
||||
outerStyle.overflow = 'hidden';
|
||||
outer.appendChild(inner);
|
||||
document.body.appendChild(outer);
|
||||
var widthContained = inner.offsetWidth;
|
||||
outer.style.overflow = 'scroll';
|
||||
var widthScroll = inner.offsetWidth;
|
||||
|
||||
if (widthContained === widthScroll) {
|
||||
widthScroll = outer.clientWidth;
|
||||
}
|
||||
|
||||
document.body.removeChild(outer);
|
||||
cached = widthContained - widthScroll;
|
||||
}
|
||||
|
||||
return cached;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = guid;
|
||||
var seed = 0;
|
||||
|
||||
function guid() {
|
||||
return "".concat(Date.now(), "_").concat(seed++);
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/** As `React.useEffect` but pass origin value in callback and not need care deps length change. */
|
||||
export default function useEffect(callback: (prevDeps: any[]) => void, deps: any[]): void;
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
|
||||
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); }
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = useEffect;
|
||||
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; 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; }
|
||||
|
||||
/** As `React.useEffect` but pass origin value in callback and not need care deps length change. */
|
||||
function useEffect(callback, deps) {
|
||||
var prevRef = React.useRef(deps);
|
||||
React.useEffect(function () {
|
||||
if (deps.length !== prevRef.current.length || deps.some(function (dep, index) {
|
||||
return dep !== prevRef.current[index];
|
||||
})) {
|
||||
callback(prevRef.current);
|
||||
}
|
||||
|
||||
prevRef.current = deps;
|
||||
});
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export default function useMemo<Value, Condition = any[]>(getValue: () => Value, condition: Condition, shouldUpdate: (prev: Condition, next: Condition) => boolean): Value;
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
|
||||
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); }
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = useMemo;
|
||||
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; 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; }
|
||||
|
||||
function useMemo(getValue, condition, shouldUpdate) {
|
||||
var cacheRef = React.useRef({});
|
||||
|
||||
if (!('value' in cacheRef.current) || shouldUpdate(cacheRef.current.condition, condition)) {
|
||||
cacheRef.current.value = getValue();
|
||||
cacheRef.current.condition = condition;
|
||||
}
|
||||
|
||||
return cacheRef.current.value;
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
export default function useControlledState<T, R = T>(defaultStateValue: T | (() => T), option?: {
|
||||
defaultValue?: T | (() => T);
|
||||
value?: T;
|
||||
onChange?: (value: T, prevValue: T) => void;
|
||||
postState?: (value: T) => T;
|
||||
}): [R, (value: T) => void];
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
"use strict";
|
||||
|
||||
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); }
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = useControlledState;
|
||||
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; 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; }
|
||||
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
||||
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
|
||||
function useControlledState(defaultStateValue, option) {
|
||||
var _ref = option || {},
|
||||
defaultValue = _ref.defaultValue,
|
||||
value = _ref.value,
|
||||
onChange = _ref.onChange,
|
||||
postState = _ref.postState;
|
||||
|
||||
var _React$useState = React.useState(function () {
|
||||
if (value !== undefined) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (defaultValue !== undefined) {
|
||||
return typeof defaultValue === 'function' ? defaultValue() : defaultValue;
|
||||
}
|
||||
|
||||
return typeof defaultStateValue === 'function' ? defaultStateValue() : defaultStateValue;
|
||||
}),
|
||||
_React$useState2 = _slicedToArray(_React$useState, 2),
|
||||
innerValue = _React$useState2[0],
|
||||
setInnerValue = _React$useState2[1];
|
||||
|
||||
var mergedValue = value !== undefined ? value : innerValue;
|
||||
|
||||
if (postState) {
|
||||
mergedValue = postState(mergedValue);
|
||||
}
|
||||
|
||||
function triggerChange(newValue) {
|
||||
setInnerValue(newValue);
|
||||
|
||||
if (mergedValue !== newValue && onChange) {
|
||||
onChange(newValue, mergedValue);
|
||||
}
|
||||
}
|
||||
|
||||
return [mergedValue, triggerChange];
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = pickAttrs;
|
||||
|
||||
/* eslint-disable max-len */
|
||||
var attributes = "accept acceptCharset accessKey action allowFullScreen allowTransparency\n alt async autoComplete autoFocus autoPlay capture cellPadding cellSpacing challenge\n charSet checked classID className colSpan cols content contentEditable contextMenu\n controls coords crossOrigin data dateTime default defer dir disabled download draggable\n encType form formAction formEncType formMethod formNoValidate formTarget frameBorder\n headers height hidden high href hrefLang htmlFor httpEquiv icon id inputMode integrity\n is keyParams keyType kind label lang list loop low manifest marginHeight marginWidth max maxLength media\n mediaGroup method min minLength multiple muted name noValidate nonce open\n optimum pattern placeholder poster preload radioGroup readOnly rel required\n reversed role rowSpan rows sandbox scope scoped scrolling seamless selected\n shape size sizes span spellCheck src srcDoc srcLang srcSet start step style\n summary tabIndex target title type useMap value width wmode wrap".replace(/\s+/g, ' ').replace(/\t|\n|\r/g, '').split(' ');
|
||||
var eventsName = "onCopy onCut onPaste onCompositionEnd onCompositionStart onCompositionUpdate onKeyDown\n onKeyPress onKeyUp onFocus onBlur onChange onInput onSubmit onClick onContextMenu onDoubleClick\n onDrag onDragEnd onDragEnter onDragExit onDragLeave onDragOver onDragStart onDrop onMouseDown\n onMouseEnter onMouseLeave onMouseMove onMouseOut onMouseOver onMouseUp onSelect onTouchCancel\n onTouchEnd onTouchMove onTouchStart onScroll onWheel onAbort onCanPlay onCanPlayThrough\n onDurationChange onEmptied onEncrypted onEnded onError onLoadedData onLoadedMetadata\n onLoadStart onPause onPlay onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend onTimeUpdate onVolumeChange onWaiting onLoad onError".replace(/\s+/g, ' ').replace(/\t|\n|\r/g, '').split(' ');
|
||||
/* eslint-enable max-len */
|
||||
|
||||
var attrsPrefix = ['data', 'aria'];
|
||||
|
||||
function pickAttrs(props) {
|
||||
var attrs = {};
|
||||
|
||||
var _loop = function _loop(key) {
|
||||
if (attributes.indexOf(key) > -1 || eventsName.indexOf(key) > -1) {
|
||||
attrs[key] = props[key];
|
||||
/* eslint-disable no-loop-func */
|
||||
} else if (attrsPrefix.map(function (prefix) {
|
||||
return new RegExp("^".concat(prefix));
|
||||
}).some(function (reg) {
|
||||
return key.replace(reg, '') !== key;
|
||||
})) {
|
||||
/* eslint-enable no-loop-func */
|
||||
attrs[key] = props[key];
|
||||
}
|
||||
};
|
||||
|
||||
for (var key in props) {
|
||||
_loop(key);
|
||||
}
|
||||
|
||||
return attrs;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import * as React from 'react';
|
||||
export declare function fillRef<T>(ref: React.Ref<T>, node: T): void;
|
||||
/**
|
||||
* Merge refs into one ref function to support ref passing.
|
||||
*/
|
||||
export declare function composeRef<T>(...refs: React.Ref<T>[]): React.Ref<T>;
|
||||
export declare function supportRef(nodeOrComponent: any): boolean;
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.fillRef = fillRef;
|
||||
exports.composeRef = composeRef;
|
||||
exports.supportRef = supportRef;
|
||||
|
||||
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 fillRef(ref, node) {
|
||||
if (typeof ref === 'function') {
|
||||
ref(node);
|
||||
} else if (_typeof(ref) === 'object' && ref && 'current' in ref) {
|
||||
ref.current = node;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge refs into one ref function to support ref passing.
|
||||
*/
|
||||
|
||||
|
||||
function composeRef() {
|
||||
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
refs[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return function (node) {
|
||||
refs.forEach(function (ref) {
|
||||
fillRef(ref, node);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function supportRef(nodeOrComponent) {
|
||||
// Function component node
|
||||
if (nodeOrComponent.type && nodeOrComponent.type.prototype && !nodeOrComponent.type.prototype.render) {
|
||||
return false;
|
||||
} // Class component
|
||||
|
||||
|
||||
if (typeof nodeOrComponent === 'function' && nodeOrComponent.prototype && !nodeOrComponent.prototype.render) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/* eslint-enable */
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import * as React from 'react';
|
||||
export interface SetStyleOptions {
|
||||
element?: HTMLElement;
|
||||
}
|
||||
/**
|
||||
* Easy to set element style, return previous style
|
||||
* IE browser compatible(IE browser doesn't merge overflow style, need to set it separately)
|
||||
* https://github.com/ant-design/ant-design/issues/19393
|
||||
*
|
||||
*/
|
||||
declare function setStyle(style: React.CSSProperties, options?: SetStyleOptions): React.CSSProperties;
|
||||
export default setStyle;
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
/**
|
||||
* Easy to set element style, return previous style
|
||||
* IE browser compatible(IE browser doesn't merge overflow style, need to set it separately)
|
||||
* https://github.com/ant-design/ant-design/issues/19393
|
||||
*
|
||||
*/
|
||||
function setStyle(style) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
var _options$element = options.element,
|
||||
element = _options$element === void 0 ? document.body : _options$element;
|
||||
var oldStyle = {};
|
||||
var styleKeys = Object.keys(style); // IE browser compatible
|
||||
|
||||
styleKeys.forEach(function (key) {
|
||||
oldStyle[key] = element.style[key];
|
||||
});
|
||||
styleKeys.forEach(function (key) {
|
||||
element.style[key] = style[key];
|
||||
});
|
||||
return oldStyle;
|
||||
}
|
||||
|
||||
var _default = setStyle;
|
||||
exports.default = _default;
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _getScrollBarSize = _interopRequireDefault(require("./getScrollBarSize"));
|
||||
|
||||
var _setStyle = _interopRequireDefault(require("./setStyle"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function isBodyOverflowing() {
|
||||
return document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight) && window.innerWidth > document.body.offsetWidth;
|
||||
}
|
||||
|
||||
var cacheStyle = {};
|
||||
|
||||
var _default = function _default(close) {
|
||||
if (!isBodyOverflowing() && !close) {
|
||||
return;
|
||||
} // https://github.com/ant-design/ant-design/issues/19729
|
||||
|
||||
|
||||
var scrollingEffectClassName = 'ant-scrolling-effect';
|
||||
var scrollingEffectClassNameReg = new RegExp("".concat(scrollingEffectClassName), 'g');
|
||||
var bodyClassName = document.body.className;
|
||||
|
||||
if (close) {
|
||||
if (!scrollingEffectClassNameReg.test(bodyClassName)) return;
|
||||
(0, _setStyle.default)(cacheStyle);
|
||||
cacheStyle = {};
|
||||
document.body.className = bodyClassName.replace(scrollingEffectClassNameReg, '').trim();
|
||||
return;
|
||||
}
|
||||
|
||||
var scrollBarSize = (0, _getScrollBarSize.default)();
|
||||
|
||||
if (scrollBarSize) {
|
||||
cacheStyle = (0, _setStyle.default)({
|
||||
position: 'relative',
|
||||
width: "calc(100% - ".concat(scrollBarSize, "px)")
|
||||
});
|
||||
|
||||
if (!scrollingEffectClassNameReg.test(bodyClassName)) {
|
||||
var addClassName = "".concat(bodyClassName, " ").concat(scrollingEffectClassName);
|
||||
document.body.className = addClassName.trim();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.default = _default;
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
export declare type ElementClass = Function;
|
||||
export declare type Property = PropertyDescriptor | Function;
|
||||
export declare function spyElementPrototypes<T extends ElementClass>(elementClass: T, properties: Record<string, Property>): {
|
||||
mockRestore(): void;
|
||||
};
|
||||
export declare function spyElementPrototype(Element: ElementClass, propName: string, property: Property): {
|
||||
mockRestore(): void;
|
||||
};
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.spyElementPrototypes = spyElementPrototypes;
|
||||
exports.spyElementPrototype = spyElementPrototype;
|
||||
|
||||
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(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(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; }
|
||||
|
||||
/* eslint-disable no-param-reassign */
|
||||
var NO_EXIST = {
|
||||
__NOT_EXIST: true
|
||||
};
|
||||
|
||||
function spyElementPrototypes(elementClass, properties) {
|
||||
var propNames = Object.keys(properties);
|
||||
var originDescriptors = {};
|
||||
propNames.forEach(function (propName) {
|
||||
var originDescriptor = Object.getOwnPropertyDescriptor(elementClass.prototype, propName);
|
||||
originDescriptors[propName] = originDescriptor || NO_EXIST;
|
||||
var spyProp = properties[propName];
|
||||
|
||||
if (typeof spyProp === 'function') {
|
||||
// If is a function
|
||||
elementClass.prototype[propName] = function spyFunc() {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return spyProp.call.apply(spyProp, [this, originDescriptor].concat(args));
|
||||
};
|
||||
} else {
|
||||
// Otherwise tread as a property
|
||||
Object.defineProperty(elementClass.prototype, propName, _objectSpread({}, spyProp, {
|
||||
set: function set(value) {
|
||||
if (spyProp.set) {
|
||||
return spyProp.set.call(this, originDescriptor, value);
|
||||
}
|
||||
|
||||
return originDescriptor.set(value);
|
||||
},
|
||||
get: function get() {
|
||||
if (spyProp.get) {
|
||||
return spyProp.get.call(this, originDescriptor);
|
||||
}
|
||||
|
||||
return originDescriptor.get();
|
||||
},
|
||||
configurable: true
|
||||
}));
|
||||
}
|
||||
});
|
||||
return {
|
||||
mockRestore: function mockRestore() {
|
||||
propNames.forEach(function (propName) {
|
||||
var originDescriptor = originDescriptors[propName];
|
||||
|
||||
if (originDescriptor === NO_EXIST) {
|
||||
delete elementClass.prototype[propName];
|
||||
} else if (typeof originDescriptor === 'function') {
|
||||
elementClass.prototype[propName] = originDescriptor;
|
||||
} else {
|
||||
Object.defineProperty(elementClass.prototype, propName, originDescriptor);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function spyElementPrototype(Element, propName, property) {
|
||||
return spyElementPrototypes(Element, _defineProperty({}, propName, property));
|
||||
}
|
||||
/* eslint-enable */
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _react = _interopRequireDefault(require("react"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var unsafeLifecyclesPolyfill = function unsafeLifecyclesPolyfill(Component) {
|
||||
var prototype = Component.prototype;
|
||||
|
||||
if (!prototype || !prototype.isReactComponent) {
|
||||
throw new Error('Can only polyfill class components');
|
||||
} // only handle componentWillReceiveProps
|
||||
|
||||
|
||||
if (typeof prototype.componentWillReceiveProps !== 'function') {
|
||||
return Component;
|
||||
} // In React 16.9, React.Profiler was introduced together with UNSAFE_componentWillReceiveProps
|
||||
// https://reactjs.org/blog/2019/08/08/react-v16.9.0.html#performance-measurements-with-reactprofiler
|
||||
|
||||
|
||||
if (!_react.default.Profiler) {
|
||||
return Component;
|
||||
} // Here polyfill get started
|
||||
|
||||
|
||||
prototype.UNSAFE_componentWillReceiveProps = prototype.componentWillReceiveProps;
|
||||
delete prototype.componentWillReceiveProps;
|
||||
return Component;
|
||||
};
|
||||
|
||||
var _default = unsafeLifecyclesPolyfill;
|
||||
exports.default = _default;
|
||||
+1
@@ -0,0 +1 @@
|
||||
export default function get<T = any>(entity: any, path: (string | number)[]): any;
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = get;
|
||||
|
||||
function get(entity, path) {
|
||||
var current = entity;
|
||||
|
||||
for (var i = 0; i < path.length; i += 1) {
|
||||
if (current === null || current === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
current = current[path[i]];
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export default function set<Entity = any, Output = Entity, Value = any>(entity: Entity, paths: (string | number)[], value: Value): Output;
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = set;
|
||||
|
||||
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(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
||||
|
||||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
||||
|
||||
function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
|
||||
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
||||
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
|
||||
function set(entity, paths, value) {
|
||||
if (!paths.length) {
|
||||
return value;
|
||||
}
|
||||
|
||||
var _paths = _toArray(paths),
|
||||
path = _paths[0],
|
||||
restPath = _paths.slice(1);
|
||||
|
||||
var clone;
|
||||
|
||||
if (!entity && typeof path === 'number') {
|
||||
clone = [];
|
||||
} else if (Array.isArray(entity)) {
|
||||
clone = _toConsumableArray(entity);
|
||||
} else {
|
||||
clone = _objectSpread({}, entity);
|
||||
}
|
||||
|
||||
clone[path] = set(clone[path], restPath, value);
|
||||
return clone;
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = warn;
|
||||
|
||||
function warn(msg) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (typeof console !== 'undefined' && console.warn) {
|
||||
console.warn(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
export declare function warning(valid: boolean, message: string): void;
|
||||
export declare function note(valid: boolean, message: string): void;
|
||||
export declare function resetWarned(): void;
|
||||
export declare function call(method: (valid: boolean, message: string) => void, valid: boolean, message: string): void;
|
||||
export declare function warningOnce(valid: boolean, message: string): void;
|
||||
export declare function noteOnce(valid: boolean, message: string): void;
|
||||
export default warningOnce;
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.warning = warning;
|
||||
exports.note = note;
|
||||
exports.resetWarned = resetWarned;
|
||||
exports.call = call;
|
||||
exports.warningOnce = warningOnce;
|
||||
exports.noteOnce = noteOnce;
|
||||
exports.default = void 0;
|
||||
|
||||
/* eslint-disable no-console */
|
||||
var warned = {};
|
||||
|
||||
function warning(valid, message) {
|
||||
// Support uglify
|
||||
if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
|
||||
console.error("Warning: ".concat(message));
|
||||
}
|
||||
}
|
||||
|
||||
function note(valid, message) {
|
||||
// Support uglify
|
||||
if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
|
||||
console.warn("Note: ".concat(message));
|
||||
}
|
||||
}
|
||||
|
||||
function resetWarned() {
|
||||
warned = {};
|
||||
}
|
||||
|
||||
function call(method, valid, message) {
|
||||
if (!valid && !warned[message]) {
|
||||
method(false, message);
|
||||
warned[message] = true;
|
||||
}
|
||||
}
|
||||
|
||||
function warningOnce(valid, message) {
|
||||
call(warning, valid, message);
|
||||
}
|
||||
|
||||
function noteOnce(valid, message) {
|
||||
call(note, valid, message);
|
||||
}
|
||||
|
||||
var _default = warningOnce;
|
||||
/* eslint-enable */
|
||||
|
||||
exports.default = _default;
|
||||
Reference in New Issue
Block a user