New source found from dndbeyond.com
This commit is contained in:
Generated
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
import isFunction from '../isFunction';
|
||||
/*
|
||||
* Composes multiple callbacks into a single callback that will invoke them all with the same arguments.
|
||||
*
|
||||
* Usage:
|
||||
* onAdd={callAll(onAdd, onClose, close)}
|
||||
*/
|
||||
var callAll = function () {
|
||||
var callbacks = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
callbacks[_i] = arguments[_i];
|
||||
}
|
||||
return function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return callbacks.filter(isFunction).forEach(function (callback) { return callback.apply(void 0, args); });
|
||||
};
|
||||
};
|
||||
export default callAll;
|
||||
//# sourceMappingURL=callAll.js.map
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
import isFunction from '../isFunction';
|
||||
import callAll from './callAll';
|
||||
/*
|
||||
* Combines one or more conditions with one or more callbacks to create a single callback function that will invoke all callbacks if all conditions are true
|
||||
*
|
||||
* Usage:
|
||||
* onKeyDown={ifAll(isCtrl, isZ)(onUndo, preventDefault)}
|
||||
*/
|
||||
var ifAll = function () {
|
||||
var conditions = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
conditions[_i] = arguments[_i];
|
||||
}
|
||||
return function () {
|
||||
var callbacks = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
callbacks[_i] = arguments[_i];
|
||||
}
|
||||
return function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
var conditionsToCheck = conditions.filter(isFunction);
|
||||
if (conditionsToCheck.length && conditionsToCheck.every(function (condition) { return condition.apply(void 0, args); })) {
|
||||
callAll.apply(void 0, callbacks).apply(void 0, args);
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
export default ifAll;
|
||||
//# sourceMappingURL=ifAll.js.map
|
||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
var isCtrl = function (event) {
|
||||
return event.ctrlKey ||
|
||||
// Also check metaKey for Mac command key (⌘)
|
||||
event.metaKey;
|
||||
};
|
||||
export default isCtrl;
|
||||
//# sourceMappingURL=isCtrl.js.map
|
||||
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
var isEscape = function (event) {
|
||||
return event.code === 'Escape' ||
|
||||
event.code === 'Esc' ||
|
||||
// eslint-disable-next-line no-magic-numbers
|
||||
event.keyCode === 27;
|
||||
};
|
||||
export default isEscape;
|
||||
//# sourceMappingURL=isEscape.js.map
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
var isY = function (event) {
|
||||
return event.code === 'KeyY' ||
|
||||
// eslint-disable-next-line no-magic-numbers
|
||||
event.keyCode === 89;
|
||||
};
|
||||
export default isY;
|
||||
//# sourceMappingURL=isY.js.map
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
var isZ = function (event) {
|
||||
return event.code === 'KeyZ' ||
|
||||
// eslint-disable-next-line no-magic-numbers
|
||||
event.keyCode === 90;
|
||||
};
|
||||
export default isZ;
|
||||
//# sourceMappingURL=isZ.js.map
|
||||
Generated
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
import ifAll from './ifAll';
|
||||
import isEscape from './isEscape';
|
||||
export default ifAll(isEscape);
|
||||
//# sourceMappingURL=onEscape.js.map
|
||||
Generated
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
import ifAll from './ifAll';
|
||||
import isCtrl from './isCtrl';
|
||||
import isY from './isY';
|
||||
export default ifAll(isCtrl, isY);
|
||||
//# sourceMappingURL=onRedoHotkey.js.map
|
||||
Generated
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
import ifAll from './ifAll';
|
||||
import isCtrl from './isCtrl';
|
||||
import isZ from './isZ';
|
||||
export default ifAll(isCtrl, isZ);
|
||||
//# sourceMappingURL=onUndoHotkey.js.map
|
||||
Generated
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
// https://reactjs.org/docs/higher-order-components.html#convention-wrap-the-display-name-for-easy-debugging
|
||||
export default (function (WrappedComponent) {
|
||||
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
||||
});
|
||||
//# sourceMappingURL=getDisplayName.js.map
|
||||
Generated
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
var portalId = 'ddbcc-popup-container';
|
||||
var getPortalRoot = function () { return document.querySelector("#" + portalId); };
|
||||
var createPortalRoot = function () {
|
||||
var portalRoot = document.createElement('div');
|
||||
portalRoot.id = portalId;
|
||||
document.body.appendChild(portalRoot);
|
||||
return portalRoot;
|
||||
};
|
||||
export default (function () {
|
||||
return getPortalRoot() ||
|
||||
createPortalRoot();
|
||||
});
|
||||
//# sourceMappingURL=getPopupPortalRoot.js.map
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
var isFunction = function (value) { return typeof value === 'function'; };
|
||||
export default isFunction;
|
||||
//# sourceMappingURL=isFunction.js.map
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
import React from 'react';
|
||||
import getDisplayName from './getDisplayName';
|
||||
/**
|
||||
* Applies a mapping function over the props for a component.
|
||||
* @param {function(object): object} map The mapping function to apply to the props
|
||||
* @returns {function(Component): Component} HOC that will apply the provided mapping function
|
||||
*/
|
||||
var mapProps = function (map) { return function (WrappedComponent) {
|
||||
var MappedPropsComponent = React.forwardRef(function (props, ref) {
|
||||
return React.createElement(WrappedComponent, __assign({ ref: ref }, map(props)));
|
||||
});
|
||||
MappedPropsComponent.displayName = "MappedPropsComponent(" + getDisplayName(WrappedComponent) + ")";
|
||||
return MappedPropsComponent;
|
||||
}; };
|
||||
export default mapProps;
|
||||
//# sourceMappingURL=mapProps.js.map
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
var pipe = function () {
|
||||
var funcs = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
funcs[_i] = arguments[_i];
|
||||
}
|
||||
return function (arg) { return funcs.reduce(function (result, func) { return func(result); }, arg); };
|
||||
};
|
||||
export default pipe;
|
||||
//# sourceMappingURL=pipe.js.map
|
||||
Generated
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
import React from 'react';
|
||||
import getDisplayName from './getDisplayName';
|
||||
var renderIfProp = function (propSelector) { return function (WrappedComponent) {
|
||||
var WithPortal = function (props) {
|
||||
return propSelector(props) ?
|
||||
React.createElement(WrappedComponent, __assign({}, props)) :
|
||||
null;
|
||||
};
|
||||
WithPortal.displayName = "RenderIfProp(" + getDisplayName(WrappedComponent) + ")";
|
||||
return WithPortal;
|
||||
}; };
|
||||
export default renderIfProp;
|
||||
//# sourceMappingURL=renderIfProp.js.map
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import getDisplayName from './getDisplayName';
|
||||
var withPortal = function (portalRoot) { return function (WrappedComponent) {
|
||||
var WithPortal = function (props) {
|
||||
return ReactDOM.createPortal(React.createElement(WrappedComponent, __assign({}, props)), portalRoot);
|
||||
};
|
||||
WithPortal.displayName = "WithPortal(" + getDisplayName(WrappedComponent) + ")";
|
||||
return WithPortal;
|
||||
}; };
|
||||
export default withPortal;
|
||||
//# sourceMappingURL=withPortal.js.map
|
||||
Reference in New Issue
Block a user