@devexpress/dx-react-core
Advanced tools
/** | ||
* Bundle of @devexpress/dx-react-core | ||
* Generated: 2018-09-07 | ||
* Version: 1.8.0-beta.1 | ||
* Generated: 2018-10-04 | ||
* Version: 1.8.0 | ||
* License: https://js.devexpress.com/Licensing | ||
*/ | ||
import { Children, Component, Fragment, PureComponent, createElement } from 'react'; | ||
import { any, arrayOf, bool, func, node, object, oneOfType, shape, string } from 'prop-types'; | ||
import { EventEmitter, PluginHost, shallowEqual } from '@devexpress/dx-core'; | ||
import { findDOMNode, unstable_batchedUpdates } from 'react-dom'; | ||
import { Component, createElement, PureComponent, Fragment, Children } from 'react'; | ||
import { node, func, oneOfType, string, object, arrayOf, shape, bool, any } from 'prop-types'; | ||
import { shallowEqual, PluginHost, EventEmitter } from '@devexpress/dx-core'; | ||
import { unstable_batchedUpdates, findDOMNode } from 'react-dom'; | ||
@@ -21,119 +21,2 @@ var PLUGIN_HOST_CONTEXT = 'dxcore_pluginHost_context'; | ||
var asyncGenerator = function () { | ||
function AwaitValue(value) { | ||
this.value = value; | ||
} | ||
function AsyncGenerator(gen) { | ||
var front, back; | ||
function send(key, arg) { | ||
return new Promise(function (resolve, reject) { | ||
var request = { | ||
key: key, | ||
arg: arg, | ||
resolve: resolve, | ||
reject: reject, | ||
next: null | ||
}; | ||
if (back) { | ||
back = back.next = request; | ||
} else { | ||
front = back = request; | ||
resume(key, arg); | ||
} | ||
}); | ||
} | ||
function resume(key, arg) { | ||
try { | ||
var result = gen[key](arg); | ||
var value = result.value; | ||
if (value instanceof AwaitValue) { | ||
Promise.resolve(value.value).then(function (arg) { | ||
resume("next", arg); | ||
}, function (arg) { | ||
resume("throw", arg); | ||
}); | ||
} else { | ||
settle(result.done ? "return" : "normal", result.value); | ||
} | ||
} catch (err) { | ||
settle("throw", err); | ||
} | ||
} | ||
function settle(type, value) { | ||
switch (type) { | ||
case "return": | ||
front.resolve({ | ||
value: value, | ||
done: true | ||
}); | ||
break; | ||
case "throw": | ||
front.reject(value); | ||
break; | ||
default: | ||
front.resolve({ | ||
value: value, | ||
done: false | ||
}); | ||
break; | ||
} | ||
front = front.next; | ||
if (front) { | ||
resume(front.key, front.arg); | ||
} else { | ||
back = null; | ||
} | ||
} | ||
this._invoke = send; | ||
if (typeof gen.return !== "function") { | ||
this.return = undefined; | ||
} | ||
} | ||
if (typeof Symbol === "function" && Symbol.asyncIterator) { | ||
AsyncGenerator.prototype[Symbol.asyncIterator] = function () { | ||
return this; | ||
}; | ||
} | ||
AsyncGenerator.prototype.next = function (arg) { | ||
return this._invoke("next", arg); | ||
}; | ||
AsyncGenerator.prototype.throw = function (arg) { | ||
return this._invoke("throw", arg); | ||
}; | ||
AsyncGenerator.prototype.return = function (arg) { | ||
return this._invoke("return", arg); | ||
}; | ||
return { | ||
wrap: function (fn) { | ||
return function () { | ||
return new AsyncGenerator(fn.apply(this, arguments)); | ||
}; | ||
}, | ||
await: function (value) { | ||
return new AwaitValue(value); | ||
} | ||
}; | ||
}(); | ||
var classCallCheck = function (instance, Constructor) { | ||
@@ -163,6 +46,2 @@ if (!(instance instanceof Constructor)) { | ||
var defineProperty = function (obj, key, value) { | ||
@@ -197,4 +76,2 @@ if (key in obj) { | ||
var inherits = function (subClass, superClass) { | ||
@@ -216,10 +93,2 @@ if (typeof superClass !== "function" && superClass !== null) { | ||
var objectWithoutProperties = function (obj, keys) { | ||
@@ -245,6 +114,2 @@ var target = {}; | ||
var slicedToArray = function () { | ||
@@ -288,14 +153,2 @@ function sliceIterator(arr, i) { | ||
var toConsumableArray = function (arr) { | ||
@@ -1248,3 +1101,2 @@ if (Array.isArray(arr)) { | ||
// eslint-disable-next-line camelcase | ||
var draggingHandled = Symbol('draggingHandled'); | ||
@@ -1937,3 +1789,45 @@ | ||
export { PluginHost$1 as PluginHost, Plugin, Action, Getter, Template, TemplatePlaceholder, TemplateConnector, Draggable, DragDropProvider, DragSource, DropTarget, Sizer, RefHolder, createRenderComponent, createStateHelper }; | ||
var makeBoundComponent = function makeBoundComponent(Target, components, exposed) { | ||
var Component$$1 = function (_React$PureComponent) { | ||
inherits(Component$$1, _React$PureComponent); | ||
function Component$$1() { | ||
classCallCheck(this, Component$$1); | ||
return possibleConstructorReturn(this, (Component$$1.__proto__ || Object.getPrototypeOf(Component$$1)).apply(this, arguments)); | ||
} | ||
createClass(Component$$1, [{ | ||
key: 'render', | ||
value: function render() { | ||
return createElement(Target, _extends({}, components, this.props)); | ||
} | ||
}]); | ||
return Component$$1; | ||
}(PureComponent); | ||
Component$$1.components = Target.components; | ||
Object.assign(Component$$1, exposed); | ||
return Component$$1; | ||
}; | ||
var withComponents = function withComponents(components) { | ||
return function (Target) { | ||
var props = {}; | ||
var exposed = {}; | ||
Object.entries(Target.components).forEach(function (_ref) { | ||
var _ref2 = slicedToArray(_ref, 2), | ||
fieldName = _ref2[0], | ||
componentName = _ref2[1]; | ||
var component = components[componentName]; | ||
if (component && component !== Target[componentName]) { | ||
props[fieldName] = component; | ||
} | ||
exposed[componentName] = component || Target[componentName]; | ||
}); | ||
return Object.keys(props).length > 0 ? makeBoundComponent(Target, props, exposed) : Target; | ||
}; | ||
}; | ||
export { PluginHost$1 as PluginHost, Plugin, Action, Getter, Template, TemplatePlaceholder, TemplateConnector, Draggable, DragDropProvider, DragSource, DropTarget, Sizer, RefHolder, createRenderComponent, createStateHelper, withComponents }; | ||
//# sourceMappingURL=dx-react-core.es.js.map |
/** | ||
* Bundle of @devexpress/dx-react-core | ||
* Generated: 2018-09-07 | ||
* Version: 1.8.0-beta.1 | ||
* Generated: 2018-10-04 | ||
* Version: 1.8.0 | ||
* License: https://js.devexpress.com/Licensing | ||
@@ -9,1945 +9,1840 @@ */ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('prop-types'), require('@devexpress/dx-core'), require('react-dom')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'react', 'prop-types', '@devexpress/dx-core', 'react-dom'], factory) : | ||
(factory((global.DevExpress = global.DevExpress || {}, global.DevExpress.DXReactCore = {}),global.React,global.PropTypes,global.DevExpress.DXCore,global.ReactDOM)); | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('prop-types'), require('@devexpress/dx-core'), require('react-dom')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'react', 'prop-types', '@devexpress/dx-core', 'react-dom'], factory) : | ||
(factory((global.DevExpress = global.DevExpress || {}, global.DevExpress.DXReactCore = {}),global.React,global.PropTypes,global.DevExpress.DXCore,global.ReactDOM)); | ||
}(this, (function (exports,React,PropTypes,dxCore,reactDom) { 'use strict'; | ||
if (typeof process === "undefined") { var process = { env: {} }; } | ||
if (typeof process === "undefined") { var process = { env: {} }; } | ||
var PLUGIN_HOST_CONTEXT = 'dxcore_pluginHost_context'; | ||
var POSITION_CONTEXT = 'dxcore_position_context'; | ||
var TEMPLATE_HOST_CONTEXT = 'dxcore_templateHost_context'; | ||
var PLUGIN_HOST_CONTEXT = 'dxcore_pluginHost_context'; | ||
var POSITION_CONTEXT = 'dxcore_position_context'; | ||
var TEMPLATE_HOST_CONTEXT = 'dxcore_templateHost_context'; | ||
var RERENDER_TEMPLATE_EVENT = Symbol('rerenderTemplate'); | ||
var RERENDER_TEMPLATE_SCOPE_EVENT = Symbol('rerenderTemplateScope'); | ||
var UPDATE_CONNECTION_EVENT = Symbol('updateConnection'); | ||
var RERENDER_TEMPLATE_EVENT = Symbol('rerenderTemplate'); | ||
var RERENDER_TEMPLATE_SCOPE_EVENT = Symbol('rerenderTemplateScope'); | ||
var UPDATE_CONNECTION_EVENT = Symbol('updateConnection'); | ||
var asyncGenerator = function () { | ||
function AwaitValue(value) { | ||
this.value = value; | ||
} | ||
function AsyncGenerator(gen) { | ||
var front, back; | ||
function send(key, arg) { | ||
return new Promise(function (resolve, reject) { | ||
var request = { | ||
key: key, | ||
arg: arg, | ||
resolve: resolve, | ||
reject: reject, | ||
next: null | ||
}; | ||
if (back) { | ||
back = back.next = request; | ||
} else { | ||
front = back = request; | ||
resume(key, arg); | ||
} | ||
}); | ||
var classCallCheck = function (instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
}; | ||
function resume(key, arg) { | ||
try { | ||
var result = gen[key](arg); | ||
var value = result.value; | ||
if (value instanceof AwaitValue) { | ||
Promise.resolve(value.value).then(function (arg) { | ||
resume("next", arg); | ||
}, function (arg) { | ||
resume("throw", arg); | ||
}); | ||
} else { | ||
settle(result.done ? "return" : "normal", result.value); | ||
} | ||
} catch (err) { | ||
settle("throw", err); | ||
var createClass = 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 settle(type, value) { | ||
switch (type) { | ||
case "return": | ||
front.resolve({ | ||
value: value, | ||
done: true | ||
}); | ||
break; | ||
return function (Constructor, protoProps, staticProps) { | ||
if (protoProps) defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
}; | ||
}(); | ||
case "throw": | ||
front.reject(value); | ||
break; | ||
var defineProperty = function (obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
default: | ||
front.resolve({ | ||
value: value, | ||
done: false | ||
}); | ||
break; | ||
} | ||
return obj; | ||
}; | ||
front = front.next; | ||
var _extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
if (front) { | ||
resume(front.key, front.arg); | ||
} else { | ||
back = null; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
this._invoke = send; | ||
return target; | ||
}; | ||
if (typeof gen.return !== "function") { | ||
this.return = undefined; | ||
var inherits = function (subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); | ||
} | ||
} | ||
if (typeof Symbol === "function" && Symbol.asyncIterator) { | ||
AsyncGenerator.prototype[Symbol.asyncIterator] = function () { | ||
return this; | ||
}; | ||
} | ||
AsyncGenerator.prototype.next = function (arg) { | ||
return this._invoke("next", arg); | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; | ||
}; | ||
AsyncGenerator.prototype.throw = function (arg) { | ||
return this._invoke("throw", arg); | ||
}; | ||
var objectWithoutProperties = function (obj, keys) { | ||
var target = {}; | ||
AsyncGenerator.prototype.return = function (arg) { | ||
return this._invoke("return", arg); | ||
}; | ||
for (var i in obj) { | ||
if (keys.indexOf(i) >= 0) continue; | ||
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; | ||
target[i] = obj[i]; | ||
} | ||
return { | ||
wrap: function (fn) { | ||
return function () { | ||
return new AsyncGenerator(fn.apply(this, arguments)); | ||
}; | ||
}, | ||
await: function (value) { | ||
return new AwaitValue(value); | ||
} | ||
return target; | ||
}; | ||
}(); | ||
var classCallCheck = function (instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
}; | ||
var createClass = 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); | ||
var possibleConstructorReturn = function (self, call) { | ||
if (!self) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
} | ||
return function (Constructor, protoProps, staticProps) { | ||
if (protoProps) defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
return call && (typeof call === "object" || typeof call === "function") ? call : self; | ||
}; | ||
}(); | ||
var slicedToArray = function () { | ||
function sliceIterator(arr, i) { | ||
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); | ||
var defineProperty = function (obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
}; | ||
var _extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"]) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
var inherits = function (subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
return _arr; | ||
} | ||
}); | ||
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; | ||
}; | ||
var objectWithoutProperties = function (obj, keys) { | ||
var target = {}; | ||
for (var i in obj) { | ||
if (keys.indexOf(i) >= 0) continue; | ||
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; | ||
target[i] = obj[i]; | ||
} | ||
return target; | ||
}; | ||
var possibleConstructorReturn = function (self, call) { | ||
if (!self) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return call && (typeof call === "object" || typeof call === "function") ? call : self; | ||
}; | ||
var slicedToArray = function () { | ||
function sliceIterator(arr, i) { | ||
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; | ||
return function (arr, i) { | ||
if (Array.isArray(arr)) { | ||
return arr; | ||
} else if (Symbol.iterator in Object(arr)) { | ||
return sliceIterator(arr, i); | ||
} else { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"]) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
}; | ||
}(); | ||
return _arr; | ||
} | ||
var toConsumableArray = function (arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
return function (arr, i) { | ||
if (Array.isArray(arr)) { | ||
return arr; | ||
} else if (Symbol.iterator in Object(arr)) { | ||
return sliceIterator(arr, i); | ||
return arr2; | ||
} else { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
return Array.from(arr); | ||
} | ||
}; | ||
}(); | ||
var PluginIndexer = function PluginIndexer(_ref, _ref2) { | ||
var children = _ref.children; | ||
var position = _ref2[POSITION_CONTEXT]; | ||
return React.createElement( | ||
React.Fragment, | ||
null, | ||
React.Children.map(children, function (child, index) { | ||
if (!child || !child.type) return child; | ||
var childPosition = function childPosition() { | ||
var calculatedPosition = position && position() || []; | ||
return [].concat(toConsumableArray(calculatedPosition), [index]); | ||
}; | ||
return React.createElement( | ||
PluginIndexerContext, | ||
{ position: childPosition }, | ||
child | ||
); | ||
}) | ||
); | ||
}; | ||
process.env.NODE_ENV !== "production" ? PluginIndexer.propTypes = { | ||
children: PropTypes.node | ||
} : void 0; | ||
PluginIndexer.defaultProps = { | ||
children: undefined | ||
}; | ||
PluginIndexer.contextTypes = defineProperty({}, POSITION_CONTEXT, PropTypes.func); | ||
var PluginIndexerContext = function (_React$Component) { | ||
inherits(PluginIndexerContext, _React$Component); | ||
function PluginIndexerContext() { | ||
classCallCheck(this, PluginIndexerContext); | ||
return possibleConstructorReturn(this, (PluginIndexerContext.__proto__ || Object.getPrototypeOf(PluginIndexerContext)).apply(this, arguments)); | ||
} | ||
createClass(PluginIndexerContext, [{ | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
var position = this.props.position; | ||
return defineProperty({}, POSITION_CONTEXT, position); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var children = this.props.children; | ||
return children; | ||
} | ||
}]); | ||
return PluginIndexerContext; | ||
}(React.Component); | ||
process.env.NODE_ENV !== "production" ? PluginIndexerContext.propTypes = { | ||
position: PropTypes.func.isRequired, | ||
children: PropTypes.node.isRequired | ||
} : void 0; | ||
var toConsumableArray = function (arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
PluginIndexerContext.childContextTypes = defineProperty({}, POSITION_CONTEXT, PropTypes.func); | ||
return arr2; | ||
} else { | ||
return Array.from(arr); | ||
} | ||
}; | ||
var _TemplatePlaceholder$; | ||
var PluginIndexer = function PluginIndexer(_ref, _ref2) { | ||
var children = _ref.children; | ||
var position = _ref2[POSITION_CONTEXT]; | ||
return React.createElement( | ||
React.Fragment, | ||
null, | ||
React.Children.map(children, function (child, index) { | ||
if (!child || !child.type) return child; | ||
var TemplatePlaceholder = function (_React$Component) { | ||
inherits(TemplatePlaceholder, _React$Component); | ||
var childPosition = function childPosition() { | ||
var calculatedPosition = position && position() || []; | ||
return [].concat(toConsumableArray(calculatedPosition), [index]); | ||
}; | ||
function TemplatePlaceholder(props, context) { | ||
var _this$subscription; | ||
return React.createElement( | ||
PluginIndexerContext, | ||
{ position: childPosition }, | ||
child | ||
); | ||
}) | ||
); | ||
}; | ||
classCallCheck(this, TemplatePlaceholder); | ||
process.env.NODE_ENV !== "production" ? PluginIndexer.propTypes = { | ||
children: PropTypes.node | ||
} : void 0; | ||
var _this = possibleConstructorReturn(this, (TemplatePlaceholder.__proto__ || Object.getPrototypeOf(TemplatePlaceholder)).call(this, props, context)); | ||
PluginIndexer.defaultProps = { | ||
children: undefined | ||
}; | ||
var propsName = _this.props.name; | ||
PluginIndexer.contextTypes = defineProperty({}, POSITION_CONTEXT, PropTypes.func); | ||
var PluginIndexerContext = function (_React$Component) { | ||
inherits(PluginIndexerContext, _React$Component); | ||
function PluginIndexerContext() { | ||
classCallCheck(this, PluginIndexerContext); | ||
return possibleConstructorReturn(this, (PluginIndexerContext.__proto__ || Object.getPrototypeOf(PluginIndexerContext)).apply(this, arguments)); | ||
} | ||
createClass(PluginIndexerContext, [{ | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
var position = this.props.position; | ||
return defineProperty({}, POSITION_CONTEXT, position); | ||
_this.subscription = (_this$subscription = {}, defineProperty(_this$subscription, RERENDER_TEMPLATE_EVENT, function (id) { | ||
if (_this.template && _this.template.id === id) { | ||
_this.forceUpdate(); | ||
} | ||
}), defineProperty(_this$subscription, RERENDER_TEMPLATE_SCOPE_EVENT, function (name) { | ||
if (propsName === name) { | ||
_this.forceUpdate(); | ||
} | ||
}), _this$subscription); | ||
return _this; | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var children = this.props.children; | ||
return children; | ||
} | ||
}]); | ||
return PluginIndexerContext; | ||
}(React.Component); | ||
createClass(TemplatePlaceholder, [{ | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
var _this2 = this; | ||
process.env.NODE_ENV !== "production" ? PluginIndexerContext.propTypes = { | ||
position: PropTypes.func.isRequired, | ||
children: PropTypes.node.isRequired | ||
} : void 0; | ||
return defineProperty({}, TEMPLATE_HOST_CONTEXT, { | ||
templates: function templates() { | ||
return _this2.restTemplates; | ||
}, | ||
params: function params() { | ||
return _this2.params; | ||
} | ||
}); | ||
} | ||
}, { | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
PluginIndexerContext.childContextTypes = defineProperty({}, POSITION_CONTEXT, PropTypes.func); | ||
pluginHost.registerSubscription(this.subscription); | ||
} | ||
}, { | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate(nextProps) { | ||
var _getRenderingData = this.getRenderingData(nextProps), | ||
params = _getRenderingData.params; | ||
var _TemplatePlaceholder$; | ||
var children = this.props.children; | ||
var TemplatePlaceholder = function (_React$Component) { | ||
inherits(TemplatePlaceholder, _React$Component); | ||
return !dxCore.shallowEqual(params, this.params) || children !== nextProps.children; | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
function TemplatePlaceholder(props, context) { | ||
var _this$subscription; | ||
classCallCheck(this, TemplatePlaceholder); | ||
var _this = possibleConstructorReturn(this, (TemplatePlaceholder.__proto__ || Object.getPrototypeOf(TemplatePlaceholder)).call(this, props, context)); | ||
var propsName = _this.props.name; | ||
_this.subscription = (_this$subscription = {}, defineProperty(_this$subscription, RERENDER_TEMPLATE_EVENT, function (id) { | ||
if (_this.template && _this.template.id === id) { | ||
_this.forceUpdate(); | ||
pluginHost.unregisterSubscription(this.subscription); | ||
} | ||
}), defineProperty(_this$subscription, RERENDER_TEMPLATE_SCOPE_EVENT, function (name) { | ||
if (propsName === name) { | ||
_this.forceUpdate(); | ||
} | ||
}), _this$subscription); | ||
return _this; | ||
} | ||
}, { | ||
key: 'getRenderingData', | ||
value: function getRenderingData(props) { | ||
var name = props.name, | ||
params = props.params; | ||
createClass(TemplatePlaceholder, [{ | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
var _this2 = this; | ||
if (name) { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
return defineProperty({}, TEMPLATE_HOST_CONTEXT, { | ||
templates: function templates() { | ||
return _this2.restTemplates; | ||
}, | ||
params: function params() { | ||
return _this2.params; | ||
return { | ||
params: params, | ||
templates: pluginHost.collect(name + 'Template').filter(function (template) { | ||
return template.predicate(params); | ||
}).reverse() | ||
}; | ||
} | ||
}); | ||
} | ||
}, { | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
var templateHost = this.context[TEMPLATE_HOST_CONTEXT]; | ||
pluginHost.registerSubscription(this.subscription); | ||
} | ||
}, { | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate(nextProps) { | ||
var _getRenderingData = this.getRenderingData(nextProps), | ||
params = _getRenderingData.params; | ||
var children = this.props.children; | ||
return !dxCore.shallowEqual(params, this.params) || children !== nextProps.children; | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
pluginHost.unregisterSubscription(this.subscription); | ||
} | ||
}, { | ||
key: 'getRenderingData', | ||
value: function getRenderingData(props) { | ||
var name = props.name, | ||
params = props.params; | ||
if (name) { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
return { | ||
params: params, | ||
templates: pluginHost.collect(name + 'Template').filter(function (template) { | ||
return template.predicate(params); | ||
}).reverse() | ||
params: params || templateHost.params(), | ||
templates: templateHost.templates() | ||
}; | ||
} | ||
var templateHost = this.context[TEMPLATE_HOST_CONTEXT]; | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _getRenderingData2 = this.getRenderingData(this.props), | ||
params = _getRenderingData2.params, | ||
templates = _getRenderingData2.templates; | ||
return { | ||
params: params || templateHost.params(), | ||
templates: templateHost.templates() | ||
}; | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _getRenderingData2 = this.getRenderingData(this.props), | ||
params = _getRenderingData2.params, | ||
templates = _getRenderingData2.templates; | ||
this.params = params; | ||
this.params = params; | ||
var _templates = slicedToArray(templates, 1); | ||
var _templates = slicedToArray(templates, 1); | ||
this.template = _templates[0]; | ||
this.template = _templates[0]; | ||
this.restTemplates = templates.slice(1); | ||
this.restTemplates = templates.slice(1); | ||
var content = null; | ||
if (this.template) { | ||
var templateContent = this.template.children; | ||
var content = null; | ||
if (this.template) { | ||
var templateContent = this.template.children; | ||
content = templateContent() || null; | ||
if (content && typeof content === 'function') { | ||
content = content(params); | ||
content = templateContent() || null; | ||
if (content && typeof content === 'function') { | ||
content = content(params); | ||
} | ||
} | ||
} | ||
var templatePlaceholder = this.props.children; | ||
var templatePlaceholder = this.props.children; | ||
return templatePlaceholder ? templatePlaceholder(content) : content; | ||
} | ||
}]); | ||
return TemplatePlaceholder; | ||
}(React.Component); | ||
return templatePlaceholder ? templatePlaceholder(content) : content; | ||
} | ||
}]); | ||
return TemplatePlaceholder; | ||
}(React.Component); | ||
process.env.NODE_ENV !== "production" ? TemplatePlaceholder.propTypes = { | ||
name: PropTypes.string, // eslint-disable-line react/no-unused-prop-types | ||
params: PropTypes.object, // eslint-disable-line react/no-unused-prop-types | ||
children: PropTypes.func | ||
} : void 0; | ||
process.env.NODE_ENV !== "production" ? TemplatePlaceholder.propTypes = { | ||
name: PropTypes.string, // eslint-disable-line react/no-unused-prop-types | ||
params: PropTypes.object, // eslint-disable-line react/no-unused-prop-types | ||
children: PropTypes.func | ||
} : void 0; | ||
TemplatePlaceholder.defaultProps = { | ||
name: undefined, | ||
params: undefined, | ||
children: undefined | ||
}; | ||
TemplatePlaceholder.defaultProps = { | ||
name: undefined, | ||
params: undefined, | ||
children: undefined | ||
}; | ||
TemplatePlaceholder.contextTypes = (_TemplatePlaceholder$ = {}, defineProperty(_TemplatePlaceholder$, TEMPLATE_HOST_CONTEXT, PropTypes.object), defineProperty(_TemplatePlaceholder$, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired), _TemplatePlaceholder$); | ||
TemplatePlaceholder.contextTypes = (_TemplatePlaceholder$ = {}, defineProperty(_TemplatePlaceholder$, TEMPLATE_HOST_CONTEXT, PropTypes.object), defineProperty(_TemplatePlaceholder$, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired), _TemplatePlaceholder$); | ||
TemplatePlaceholder.childContextTypes = defineProperty({}, TEMPLATE_HOST_CONTEXT, PropTypes.object.isRequired); | ||
TemplatePlaceholder.childContextTypes = defineProperty({}, TEMPLATE_HOST_CONTEXT, PropTypes.object.isRequired); | ||
var PluginHost$1 = function (_React$PureComponent) { | ||
inherits(PluginHost$$1, _React$PureComponent); | ||
var PluginHost = function (_React$PureComponent) { | ||
inherits(PluginHost, _React$PureComponent); | ||
function PluginHost$$1(props) { | ||
classCallCheck(this, PluginHost$$1); | ||
function PluginHost(props) { | ||
classCallCheck(this, PluginHost); | ||
var _this = possibleConstructorReturn(this, (PluginHost$$1.__proto__ || Object.getPrototypeOf(PluginHost$$1)).call(this, props)); | ||
var _this = possibleConstructorReturn(this, (PluginHost.__proto__ || Object.getPrototypeOf(PluginHost)).call(this, props)); | ||
_this.host = new dxCore.PluginHost(); | ||
return _this; | ||
} | ||
createClass(PluginHost$$1, [{ | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
return defineProperty({}, PLUGIN_HOST_CONTEXT, this.host); | ||
_this.host = new dxCore.PluginHost(); | ||
return _this; | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var children = this.props.children; | ||
createClass(PluginHost, [{ | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
return defineProperty({}, PLUGIN_HOST_CONTEXT, this.host); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var children = this.props.children; | ||
return React.createElement( | ||
React.Fragment, | ||
null, | ||
React.createElement( | ||
PluginIndexer, | ||
return React.createElement( | ||
React.Fragment, | ||
null, | ||
children | ||
), | ||
React.createElement(TemplatePlaceholder, { name: 'root' }) | ||
); | ||
} | ||
}]); | ||
return PluginHost$$1; | ||
}(React.PureComponent); | ||
React.createElement( | ||
PluginIndexer, | ||
null, | ||
children | ||
), | ||
React.createElement(TemplatePlaceholder, { name: 'root' }) | ||
); | ||
} | ||
}]); | ||
return PluginHost; | ||
}(React.PureComponent); | ||
process.env.NODE_ENV !== "production" ? PluginHost$1.propTypes = { | ||
children: PropTypes.node | ||
} : void 0; | ||
process.env.NODE_ENV !== "production" ? PluginHost.propTypes = { | ||
children: PropTypes.node | ||
} : void 0; | ||
PluginHost$1.defaultProps = { | ||
children: undefined | ||
}; | ||
PluginHost.defaultProps = { | ||
children: undefined | ||
}; | ||
PluginHost$1.childContextTypes = defineProperty({}, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired); | ||
PluginHost.childContextTypes = defineProperty({}, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired); | ||
var _Plugin$contextTypes; | ||
var _Plugin$contextTypes; | ||
var Plugin = function (_React$PureComponent) { | ||
inherits(Plugin, _React$PureComponent); | ||
var Plugin = function (_React$PureComponent) { | ||
inherits(Plugin, _React$PureComponent); | ||
function Plugin() { | ||
classCallCheck(this, Plugin); | ||
return possibleConstructorReturn(this, (Plugin.__proto__ || Object.getPrototypeOf(Plugin)).apply(this, arguments)); | ||
} | ||
function Plugin() { | ||
classCallCheck(this, Plugin); | ||
return possibleConstructorReturn(this, (Plugin.__proto__ || Object.getPrototypeOf(Plugin)).apply(this, arguments)); | ||
} | ||
createClass(Plugin, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
var _context = this.context, | ||
pluginHost = _context[PLUGIN_HOST_CONTEXT], | ||
position = _context[POSITION_CONTEXT]; | ||
var _props = this.props, | ||
name = _props.name, | ||
dependencies = _props.dependencies; | ||
createClass(Plugin, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
var _context = this.context, | ||
pluginHost = _context[PLUGIN_HOST_CONTEXT], | ||
position = _context[POSITION_CONTEXT]; | ||
var _props = this.props, | ||
name = _props.name, | ||
dependencies = _props.dependencies; | ||
this.plugin = { | ||
position: position, | ||
name: name, | ||
dependencies: dependencies, | ||
container: true | ||
}; | ||
pluginHost.registerPlugin(this.plugin); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
this.plugin = { | ||
position: position, | ||
name: name, | ||
dependencies: dependencies, | ||
container: true | ||
}; | ||
pluginHost.registerPlugin(this.plugin); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
pluginHost.ensureDependencies(); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
pluginHost.ensureDependencies(); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
pluginHost.unregisterPlugin(this.plugin); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var children = this.props.children; | ||
pluginHost.unregisterPlugin(this.plugin); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var children = this.props.children; | ||
return React.createElement( | ||
PluginIndexer, | ||
null, | ||
children | ||
); | ||
} | ||
}]); | ||
return Plugin; | ||
}(React.PureComponent); | ||
return React.createElement( | ||
PluginIndexer, | ||
null, | ||
children | ||
); | ||
} | ||
}]); | ||
return Plugin; | ||
}(React.PureComponent); | ||
process.env.NODE_ENV !== "production" ? Plugin.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
name: PropTypes.string, | ||
dependencies: PropTypes.arrayOf(PropTypes.shape({ | ||
process.env.NODE_ENV !== "production" ? Plugin.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
name: PropTypes.string, | ||
optional: PropTypes.bool | ||
})) | ||
} : void 0; | ||
dependencies: PropTypes.arrayOf(PropTypes.shape({ | ||
name: PropTypes.string, | ||
optional: PropTypes.bool | ||
})) | ||
} : void 0; | ||
Plugin.defaultProps = { | ||
name: '', | ||
dependencies: [] | ||
}; | ||
Plugin.defaultProps = { | ||
name: '', | ||
dependencies: [] | ||
}; | ||
Plugin.contextTypes = (_Plugin$contextTypes = {}, defineProperty(_Plugin$contextTypes, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired), defineProperty(_Plugin$contextTypes, POSITION_CONTEXT, PropTypes.func.isRequired), _Plugin$contextTypes); | ||
Plugin.contextTypes = (_Plugin$contextTypes = {}, defineProperty(_Plugin$contextTypes, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired), defineProperty(_Plugin$contextTypes, POSITION_CONTEXT, PropTypes.func.isRequired), _Plugin$contextTypes); | ||
var getAvailableGetters = function getAvailableGetters(pluginHost) { | ||
var getGetterValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (getterName) { | ||
return pluginHost.get(getterName + 'Getter'); | ||
}; | ||
var getAvailableGetters = function getAvailableGetters(pluginHost) { | ||
var getGetterValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (getterName) { | ||
return pluginHost.get(getterName + 'Getter'); | ||
}; | ||
var trackedDependencies = {}; | ||
var trackedDependencies = {}; | ||
var getters = void 0; | ||
if (typeof Proxy !== 'undefined') { | ||
getters = new Proxy({}, { | ||
get: function get$$1(target, prop) { | ||
if (typeof prop !== 'string') return undefined; | ||
var result = getGetterValue(prop); | ||
trackedDependencies[prop] = result; | ||
return result; | ||
}, | ||
getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, prop) { | ||
return { configurable: true, enumerable: true, value: this.get(target, prop) }; | ||
}, | ||
ownKeys: function ownKeys() { | ||
return pluginHost.knownKeys('Getter'); | ||
} | ||
}); | ||
} else { | ||
getters = pluginHost.knownKeys('Getter').reduce(function (acc, getterName) { | ||
Object.defineProperty(acc, getterName, { | ||
get: function get$$1() { | ||
var result = getGetterValue(getterName); | ||
trackedDependencies[getterName] = result; | ||
var getters = void 0; | ||
if (typeof Proxy !== 'undefined') { | ||
getters = new Proxy({}, { | ||
get: function get$$1(target, prop) { | ||
if (typeof prop !== 'string') return undefined; | ||
var result = getGetterValue(prop); | ||
trackedDependencies[prop] = result; | ||
return result; | ||
}, | ||
getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, prop) { | ||
return { configurable: true, enumerable: true, value: this.get(target, prop) }; | ||
}, | ||
ownKeys: function ownKeys() { | ||
return pluginHost.knownKeys('Getter'); | ||
} | ||
}); | ||
return acc; | ||
}, {}); | ||
} | ||
} else { | ||
getters = pluginHost.knownKeys('Getter').reduce(function (acc, getterName) { | ||
Object.defineProperty(acc, getterName, { | ||
get: function get$$1() { | ||
var result = getGetterValue(getterName); | ||
trackedDependencies[getterName] = result; | ||
return result; | ||
} | ||
}); | ||
return acc; | ||
}, {}); | ||
} | ||
return { getters: getters, trackedDependencies: trackedDependencies }; | ||
}; | ||
var isTrackedDependenciesChanged = function isTrackedDependenciesChanged(pluginHost, prevTrackedDependencies) { | ||
var getGetterValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (getterName) { | ||
return pluginHost.get(getterName + 'Getter'); | ||
return { getters: getters, trackedDependencies: trackedDependencies }; | ||
}; | ||
var trackedDependencies = Object.keys(prevTrackedDependencies).reduce(function (acc, getterName) { | ||
return Object.assign(acc, defineProperty({}, getterName, getGetterValue(getterName))); | ||
}, {}); | ||
var isTrackedDependenciesChanged = function isTrackedDependenciesChanged(pluginHost, prevTrackedDependencies) { | ||
var getGetterValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (getterName) { | ||
return pluginHost.get(getterName + 'Getter'); | ||
}; | ||
return !dxCore.shallowEqual(prevTrackedDependencies, trackedDependencies); | ||
}; | ||
var trackedDependencies = Object.keys(prevTrackedDependencies).reduce(function (acc, getterName) { | ||
return Object.assign(acc, defineProperty({}, getterName, getGetterValue(getterName))); | ||
}, {}); | ||
var getAvailableActions = function getAvailableActions(pluginHost) { | ||
var getAction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (actionName) { | ||
return pluginHost.collect(actionName + 'Action').slice().reverse()[0]; | ||
return !dxCore.shallowEqual(prevTrackedDependencies, trackedDependencies); | ||
}; | ||
var actions = void 0; | ||
if (typeof Proxy !== 'undefined') { | ||
actions = new Proxy({}, { | ||
get: function get$$1(target, prop) { | ||
if (typeof prop !== 'string') return undefined; | ||
return getAction(prop); | ||
}, | ||
getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, prop) { | ||
return { configurable: true, enumerable: true, value: this.get(target, prop) }; | ||
}, | ||
ownKeys: function ownKeys() { | ||
return pluginHost.knownKeys('Action'); | ||
} | ||
}); | ||
} else { | ||
actions = pluginHost.knownKeys('Action').reduce(function (acc, actionName) { | ||
Object.defineProperty(acc, actionName, { | ||
get: function get$$1() { | ||
return getAction(actionName); | ||
var getAvailableActions = function getAvailableActions(pluginHost) { | ||
var getAction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (actionName) { | ||
return pluginHost.collect(actionName + 'Action').slice().reverse()[0]; | ||
}; | ||
var actions = void 0; | ||
if (typeof Proxy !== 'undefined') { | ||
actions = new Proxy({}, { | ||
get: function get$$1(target, prop) { | ||
if (typeof prop !== 'string') return undefined; | ||
return getAction(prop); | ||
}, | ||
getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, prop) { | ||
return { configurable: true, enumerable: true, value: this.get(target, prop) }; | ||
}, | ||
ownKeys: function ownKeys() { | ||
return pluginHost.knownKeys('Action'); | ||
} | ||
}); | ||
return acc; | ||
}, {}); | ||
} | ||
return actions; | ||
}; | ||
} else { | ||
actions = pluginHost.knownKeys('Action').reduce(function (acc, actionName) { | ||
Object.defineProperty(acc, actionName, { | ||
get: function get$$1() { | ||
return getAction(actionName); | ||
} | ||
}); | ||
return acc; | ||
}, {}); | ||
} | ||
return actions; | ||
}; | ||
var _Action$contextTypes; | ||
var _Action$contextTypes; | ||
var Action = function (_React$PureComponent) { | ||
inherits(Action, _React$PureComponent); | ||
var Action = function (_React$PureComponent) { | ||
inherits(Action, _React$PureComponent); | ||
function Action(props, context) { | ||
classCallCheck(this, Action); | ||
function Action(props, context) { | ||
classCallCheck(this, Action); | ||
var _this = possibleConstructorReturn(this, (Action.__proto__ || Object.getPrototypeOf(Action)).call(this, props, context)); | ||
var _this = possibleConstructorReturn(this, (Action.__proto__ || Object.getPrototypeOf(Action)).call(this, props, context)); | ||
var pluginHost = context[PLUGIN_HOST_CONTEXT], | ||
positionContext = context[POSITION_CONTEXT]; | ||
var name = props.name; | ||
var pluginHost = context[PLUGIN_HOST_CONTEXT], | ||
positionContext = context[POSITION_CONTEXT]; | ||
var name = props.name; | ||
_this.plugin = defineProperty({ | ||
position: function position() { | ||
return positionContext(); | ||
} | ||
}, name + 'Action', function undefined(params) { | ||
var action = _this.props.action; | ||
_this.plugin = defineProperty({ | ||
position: function position() { | ||
return positionContext(); | ||
} | ||
}, name + 'Action', function undefined(params) { | ||
var action = _this.props.action; | ||
var _getAvailableGetters = getAvailableGetters(pluginHost, function (getterName) { | ||
return pluginHost.get(getterName + 'Getter', _this.plugin); | ||
}), | ||
getters = _getAvailableGetters.getters; | ||
var _getAvailableGetters = getAvailableGetters(pluginHost, function (getterName) { | ||
return pluginHost.get(getterName + 'Getter', _this.plugin); | ||
}), | ||
getters = _getAvailableGetters.getters; | ||
var nextParams = params; | ||
var actions = getAvailableActions(pluginHost, function (actionName) { | ||
return actionName === name ? function (newParams) { | ||
nextParams = newParams; | ||
} : pluginHost.collect(actionName + 'Action', _this.plugin).slice().reverse()[0]; | ||
var nextParams = params; | ||
var actions = getAvailableActions(pluginHost, function (actionName) { | ||
return actionName === name ? function (newParams) { | ||
nextParams = newParams; | ||
} : pluginHost.collect(actionName + 'Action', _this.plugin).slice().reverse()[0]; | ||
}); | ||
action(params, getters, actions); | ||
var nextAction = pluginHost.collect(name + 'Action', _this.plugin).slice().reverse()[0]; | ||
if (nextAction) { | ||
nextAction(nextParams); | ||
} | ||
}); | ||
action(params, getters, actions); | ||
var nextAction = pluginHost.collect(name + 'Action', _this.plugin).slice().reverse()[0]; | ||
if (nextAction) { | ||
nextAction(nextParams); | ||
} | ||
}); | ||
pluginHost.registerPlugin(_this.plugin); | ||
return _this; | ||
} | ||
createClass(Action, [{ | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
pluginHost.unregisterPlugin(this.plugin); | ||
pluginHost.registerPlugin(_this.plugin); | ||
return _this; | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return null; | ||
} | ||
}]); | ||
return Action; | ||
}(React.PureComponent); | ||
process.env.NODE_ENV !== "production" ? Action.propTypes = { | ||
name: PropTypes.string.isRequired, | ||
action: PropTypes.func.isRequired | ||
} : void 0; | ||
createClass(Action, [{ | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
Action.contextTypes = (_Action$contextTypes = {}, defineProperty(_Action$contextTypes, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired), defineProperty(_Action$contextTypes, POSITION_CONTEXT, PropTypes.func.isRequired), _Action$contextTypes); | ||
var _Getter$contextTypes; | ||
pluginHost.unregisterPlugin(this.plugin); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return null; | ||
} | ||
}]); | ||
return Action; | ||
}(React.PureComponent); | ||
var Getter = function (_React$PureComponent) { | ||
inherits(Getter, _React$PureComponent); | ||
process.env.NODE_ENV !== "production" ? Action.propTypes = { | ||
name: PropTypes.string.isRequired, | ||
action: PropTypes.func.isRequired | ||
} : void 0; | ||
function Getter(props, context) { | ||
classCallCheck(this, Getter); | ||
Action.contextTypes = (_Action$contextTypes = {}, defineProperty(_Action$contextTypes, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired), defineProperty(_Action$contextTypes, POSITION_CONTEXT, PropTypes.func.isRequired), _Action$contextTypes); | ||
var _this = possibleConstructorReturn(this, (Getter.__proto__ || Object.getPrototypeOf(Getter)).call(this, props, context)); | ||
var _Getter$contextTypes; | ||
var pluginHost = context[PLUGIN_HOST_CONTEXT], | ||
positionContext = context[POSITION_CONTEXT]; | ||
var name = props.name; | ||
var Getter = function (_React$PureComponent) { | ||
inherits(Getter, _React$PureComponent); | ||
function Getter(props, context) { | ||
classCallCheck(this, Getter); | ||
var lastComputed = void 0; | ||
var lastTrackedDependencies = {}; | ||
var lastResult = void 0; | ||
var _this = possibleConstructorReturn(this, (Getter.__proto__ || Object.getPrototypeOf(Getter)).call(this, props, context)); | ||
_this.plugin = defineProperty({ | ||
position: function position() { | ||
return positionContext(); | ||
} | ||
}, name + 'Getter', function (_undefined) { | ||
function undefined(_x) { | ||
return _undefined.apply(this, arguments); | ||
} | ||
var pluginHost = context[PLUGIN_HOST_CONTEXT], | ||
positionContext = context[POSITION_CONTEXT]; | ||
var name = props.name; | ||
undefined.toString = function () { | ||
return _undefined.toString(); | ||
}; | ||
return undefined; | ||
}(function (original) { | ||
var _this$props = _this.props, | ||
value = _this$props.value, | ||
computed = _this$props.computed; | ||
var lastComputed = void 0; | ||
var lastTrackedDependencies = {}; | ||
var lastResult = void 0; | ||
if (computed === undefined) return value; | ||
_this.plugin = defineProperty({ | ||
position: function position() { | ||
return positionContext(); | ||
} | ||
}, name + 'Getter', function (_undefined) { | ||
function undefined(_x) { | ||
return _undefined.apply(this, arguments); | ||
} | ||
var getGetterValue = function getGetterValue(getterName) { | ||
return getterName === name ? original : pluginHost.get(getterName + 'Getter', _this.plugin); | ||
}; | ||
undefined.toString = function () { | ||
return _undefined.toString(); | ||
}; | ||
if (computed === lastComputed && !isTrackedDependenciesChanged(pluginHost, lastTrackedDependencies, getGetterValue)) { | ||
return lastResult; | ||
} | ||
return undefined; | ||
}(function (original) { | ||
var _this$props = _this.props, | ||
value = _this$props.value, | ||
computed = _this$props.computed; | ||
var _getAvailableGetters = getAvailableGetters(pluginHost, getGetterValue), | ||
getters = _getAvailableGetters.getters, | ||
trackedDependencies = _getAvailableGetters.trackedDependencies; | ||
if (computed === undefined) return value; | ||
var actions = getAvailableActions(pluginHost); | ||
var getGetterValue = function getGetterValue(getterName) { | ||
return getterName === name ? original : pluginHost.get(getterName + 'Getter', _this.plugin); | ||
}; | ||
lastComputed = computed; | ||
lastTrackedDependencies = trackedDependencies; | ||
lastResult = computed(getters, actions); | ||
return lastResult; | ||
})); | ||
if (computed === lastComputed && !isTrackedDependenciesChanged(pluginHost, lastTrackedDependencies, getGetterValue)) { | ||
return lastResult; | ||
} | ||
pluginHost.registerPlugin(_this.plugin); | ||
return _this; | ||
} | ||
var _getAvailableGetters = getAvailableGetters(pluginHost, getGetterValue), | ||
getters = _getAvailableGetters.getters, | ||
trackedDependencies = _getAvailableGetters.trackedDependencies; | ||
createClass(Getter, [{ | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
var actions = getAvailableActions(pluginHost); | ||
lastComputed = computed; | ||
lastTrackedDependencies = trackedDependencies; | ||
lastResult = computed(getters, actions); | ||
return lastResult; | ||
})); | ||
pluginHost.broadcast(UPDATE_CONNECTION_EVENT); | ||
pluginHost.registerPlugin(_this.plugin); | ||
return _this; | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
createClass(Getter, [{ | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
pluginHost.unregisterPlugin(this.plugin); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return null; | ||
} | ||
}]); | ||
return Getter; | ||
}(React.PureComponent); | ||
process.env.NODE_ENV !== "production" ? Getter.propTypes = { | ||
name: PropTypes.string.isRequired, | ||
value: PropTypes.any, | ||
computed: PropTypes.func | ||
} : void 0; | ||
pluginHost.broadcast(UPDATE_CONNECTION_EVENT); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
Getter.defaultProps = { | ||
value: undefined, | ||
computed: undefined | ||
}; | ||
Getter.contextTypes = (_Getter$contextTypes = {}, defineProperty(_Getter$contextTypes, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired), defineProperty(_Getter$contextTypes, POSITION_CONTEXT, PropTypes.func.isRequired), _Getter$contextTypes); | ||
pluginHost.unregisterPlugin(this.plugin); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return null; | ||
} | ||
}]); | ||
return Getter; | ||
}(React.PureComponent); | ||
var _Template$contextType; | ||
process.env.NODE_ENV !== "production" ? Getter.propTypes = { | ||
name: PropTypes.string.isRequired, | ||
value: PropTypes.any, | ||
computed: PropTypes.func | ||
} : void 0; | ||
var globalTemplateId = 0; | ||
var Template = function (_React$PureComponent) { | ||
inherits(Template, _React$PureComponent); | ||
Getter.defaultProps = { | ||
value: undefined, | ||
computed: undefined | ||
}; | ||
function Template(props, context) { | ||
classCallCheck(this, Template); | ||
Getter.contextTypes = (_Getter$contextTypes = {}, defineProperty(_Getter$contextTypes, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired), defineProperty(_Getter$contextTypes, POSITION_CONTEXT, PropTypes.func.isRequired), _Getter$contextTypes); | ||
var _this = possibleConstructorReturn(this, (Template.__proto__ || Object.getPrototypeOf(Template)).call(this, props, context)); | ||
var _Template$contextType; | ||
globalTemplateId += 1; | ||
_this.id = globalTemplateId; | ||
var globalTemplateId = 0; | ||
var Template = function (_React$PureComponent) { | ||
inherits(Template, _React$PureComponent); | ||
var pluginHost = context[PLUGIN_HOST_CONTEXT], | ||
positionContext = context[POSITION_CONTEXT]; | ||
var name = props.name, | ||
_predicate = props.predicate; | ||
function Template(props, context) { | ||
classCallCheck(this, Template); | ||
var _this = possibleConstructorReturn(this, (Template.__proto__ || Object.getPrototypeOf(Template)).call(this, props, context)); | ||
_this.plugin = defineProperty({ | ||
position: function position() { | ||
return positionContext(); | ||
} | ||
}, name + 'Template', { | ||
id: _this.id, | ||
predicate: function predicate(params) { | ||
return _predicate ? _predicate(params) : true; | ||
}, | ||
children: function children() { | ||
var children = _this.props.children; | ||
globalTemplateId += 1; | ||
_this.id = globalTemplateId; | ||
return children; | ||
} | ||
}); | ||
pluginHost.registerPlugin(_this.plugin); | ||
pluginHost.broadcast(RERENDER_TEMPLATE_SCOPE_EVENT, name); | ||
return _this; | ||
} | ||
var pluginHost = context[PLUGIN_HOST_CONTEXT], | ||
positionContext = context[POSITION_CONTEXT]; | ||
var name = props.name, | ||
_predicate = props.predicate; | ||
createClass(Template, [{ | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
pluginHost.broadcast(RERENDER_TEMPLATE_EVENT, this.id); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
var name = this.props.name; | ||
_this.plugin = defineProperty({ | ||
position: function position() { | ||
return positionContext(); | ||
} | ||
}, name + 'Template', { | ||
id: _this.id, | ||
predicate: function predicate(params) { | ||
return _predicate ? _predicate(params) : true; | ||
}, | ||
children: function children() { | ||
var children = _this.props.children; | ||
pluginHost.unregisterPlugin(this.plugin); | ||
return children; | ||
} | ||
}); | ||
pluginHost.registerPlugin(_this.plugin); | ||
pluginHost.broadcast(RERENDER_TEMPLATE_SCOPE_EVENT, name); | ||
return _this; | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return null; | ||
} | ||
}]); | ||
return Template; | ||
}(React.PureComponent); | ||
process.env.NODE_ENV !== "production" ? Template.propTypes = { | ||
position: PropTypes.func, | ||
name: PropTypes.string.isRequired, | ||
predicate: PropTypes.func, | ||
children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]) | ||
} : void 0; | ||
createClass(Template, [{ | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
Template.defaultProps = { | ||
predicate: undefined, | ||
children: undefined, | ||
position: undefined | ||
}; | ||
pluginHost.broadcast(RERENDER_TEMPLATE_EVENT, this.id); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
var name = this.props.name; | ||
Template.contextTypes = (_Template$contextType = {}, defineProperty(_Template$contextType, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired), defineProperty(_Template$contextType, POSITION_CONTEXT, PropTypes.func.isRequired), _Template$contextType); | ||
pluginHost.unregisterPlugin(this.plugin); | ||
pluginHost.broadcast(RERENDER_TEMPLATE_SCOPE_EVENT, name); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return null; | ||
} | ||
}]); | ||
return Template; | ||
}(React.PureComponent); | ||
var TemplateConnector = function (_React$Component) { | ||
inherits(TemplateConnector, _React$Component); | ||
process.env.NODE_ENV !== "production" ? Template.propTypes = { | ||
position: PropTypes.func, | ||
name: PropTypes.string.isRequired, | ||
predicate: PropTypes.func, | ||
children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]) | ||
} : void 0; | ||
function TemplateConnector(props, context) { | ||
classCallCheck(this, TemplateConnector); | ||
Template.defaultProps = { | ||
predicate: undefined, | ||
children: undefined, | ||
position: undefined | ||
}; | ||
var _this = possibleConstructorReturn(this, (TemplateConnector.__proto__ || Object.getPrototypeOf(TemplateConnector)).call(this, props, context)); | ||
Template.contextTypes = (_Template$contextType = {}, defineProperty(_Template$contextType, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired), defineProperty(_Template$contextType, POSITION_CONTEXT, PropTypes.func.isRequired), _Template$contextType); | ||
_this.trackedDependencies = {}; | ||
_this.subscription = defineProperty({}, UPDATE_CONNECTION_EVENT, function () { | ||
return _this.updateConnection(); | ||
}); | ||
return _this; | ||
} | ||
var TemplateConnector = function (_React$Component) { | ||
inherits(TemplateConnector, _React$Component); | ||
createClass(TemplateConnector, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
function TemplateConnector(props, context) { | ||
classCallCheck(this, TemplateConnector); | ||
pluginHost.registerSubscription(this.subscription); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
var _this = possibleConstructorReturn(this, (TemplateConnector.__proto__ || Object.getPrototypeOf(TemplateConnector)).call(this, props, context)); | ||
pluginHost.unregisterSubscription(this.subscription); | ||
_this.trackedDependencies = {}; | ||
_this.subscription = defineProperty({}, UPDATE_CONNECTION_EVENT, function () { | ||
return _this.updateConnection(); | ||
}); | ||
return _this; | ||
} | ||
}, { | ||
key: 'updateConnection', | ||
value: function updateConnection() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
createClass(TemplateConnector, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
if (isTrackedDependenciesChanged(pluginHost, this.trackedDependencies)) { | ||
this.forceUpdate(); | ||
pluginHost.registerSubscription(this.subscription); | ||
} | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
var children = this.props.children; | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
var _getAvailableGetters = getAvailableGetters(pluginHost), | ||
getters = _getAvailableGetters.getters, | ||
trackedDependencies = _getAvailableGetters.trackedDependencies; | ||
pluginHost.unregisterSubscription(this.subscription); | ||
} | ||
}, { | ||
key: 'updateConnection', | ||
value: function updateConnection() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
this.trackedDependencies = trackedDependencies; | ||
var actions = getAvailableActions(pluginHost); | ||
return children(getters, actions); | ||
} | ||
}]); | ||
return TemplateConnector; | ||
}(React.Component); | ||
if (isTrackedDependenciesChanged(pluginHost, this.trackedDependencies)) { | ||
this.forceUpdate(); | ||
} | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var pluginHost = this.context[PLUGIN_HOST_CONTEXT]; | ||
var children = this.props.children; | ||
process.env.NODE_ENV !== "production" ? TemplateConnector.propTypes = { | ||
children: PropTypes.func.isRequired | ||
} : void 0; | ||
var _getAvailableGetters = getAvailableGetters(pluginHost), | ||
getters = _getAvailableGetters.getters, | ||
trackedDependencies = _getAvailableGetters.trackedDependencies; | ||
TemplateConnector.contextTypes = defineProperty({}, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired); | ||
this.trackedDependencies = trackedDependencies; | ||
var actions = getAvailableActions(pluginHost); | ||
var TIMEOUT = 180; | ||
return children(getters, actions); | ||
} | ||
}]); | ||
return TemplateConnector; | ||
}(React.Component); | ||
var TouchStrategy = function () { | ||
function TouchStrategy(delegate) { | ||
classCallCheck(this, TouchStrategy); | ||
process.env.NODE_ENV !== "production" ? TemplateConnector.propTypes = { | ||
children: PropTypes.func.isRequired | ||
} : void 0; | ||
this.delegate = delegate; | ||
this.touchStartTimeout = null; | ||
this.dragging = false; | ||
} | ||
TemplateConnector.contextTypes = defineProperty({}, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired); | ||
createClass(TouchStrategy, [{ | ||
key: "isDragging", | ||
value: function isDragging() { | ||
return this.dragging; | ||
} | ||
}, { | ||
key: "isWaiting", | ||
value: function isWaiting() { | ||
return !!this.touchStartTimeout; | ||
} | ||
}, { | ||
key: "cancelWaiting", | ||
value: function cancelWaiting() { | ||
clearTimeout(this.touchStartTimeout); | ||
var TIMEOUT = 180; | ||
var TouchStrategy = function () { | ||
function TouchStrategy(delegate) { | ||
classCallCheck(this, TouchStrategy); | ||
this.delegate = delegate; | ||
this.touchStartTimeout = null; | ||
this.dragging = false; | ||
} | ||
}, { | ||
key: "start", | ||
value: function start(e) { | ||
var _this = this; | ||
var _e$touches$ = e.touches[0], | ||
x = _e$touches$.clientX, | ||
y = _e$touches$.clientY; | ||
createClass(TouchStrategy, [{ | ||
key: "isDragging", | ||
value: function isDragging() { | ||
return this.dragging; | ||
} | ||
}, { | ||
key: "isWaiting", | ||
value: function isWaiting() { | ||
return !!this.touchStartTimeout; | ||
} | ||
}, { | ||
key: "cancelWaiting", | ||
value: function cancelWaiting() { | ||
clearTimeout(this.touchStartTimeout); | ||
this.touchStartTimeout = null; | ||
} | ||
}, { | ||
key: "start", | ||
value: function start(e) { | ||
var _this = this; | ||
this.touchStartTimeout = setTimeout(function () { | ||
_this.delegate.onStart({ x: x, y: y }); | ||
_this.dragging = true; | ||
}, TIMEOUT); | ||
} | ||
}, { | ||
key: "move", | ||
value: function move(e) { | ||
this.cancelWaiting(); | ||
if (this.dragging) { | ||
var _e$touches$2 = e.touches[0], | ||
clientX = _e$touches$2.clientX, | ||
clientY = _e$touches$2.clientY; | ||
var _e$touches$ = e.touches[0], | ||
x = _e$touches$.clientX, | ||
y = _e$touches$.clientY; | ||
e.preventDefault(); | ||
this.delegate.onMove({ x: clientX, y: clientY }); | ||
this.touchStartTimeout = setTimeout(function () { | ||
_this.delegate.onStart({ x: x, y: y }); | ||
_this.dragging = true; | ||
}, TIMEOUT); | ||
} | ||
} | ||
}, { | ||
key: "end", | ||
value: function end(e) { | ||
this.cancelWaiting(); | ||
if (this.dragging) { | ||
var _e$changedTouches$ = e.changedTouches[0], | ||
clientX = _e$changedTouches$.clientX, | ||
clientY = _e$changedTouches$.clientY; | ||
}, { | ||
key: "move", | ||
value: function move(e) { | ||
this.cancelWaiting(); | ||
if (this.dragging) { | ||
var _e$touches$2 = e.touches[0], | ||
clientX = _e$touches$2.clientX, | ||
clientY = _e$touches$2.clientY; | ||
this.delegate.onEnd({ x: clientX, y: clientY }); | ||
e.preventDefault(); | ||
this.delegate.onMove({ x: clientX, y: clientY }); | ||
} | ||
} | ||
this.mouseInitialOffset = null; | ||
this.dragging = false; | ||
} | ||
}]); | ||
return TouchStrategy; | ||
}(); | ||
}, { | ||
key: "end", | ||
value: function end(e) { | ||
this.cancelWaiting(); | ||
if (this.dragging) { | ||
var _e$changedTouches$ = e.changedTouches[0], | ||
clientX = _e$changedTouches$.clientX, | ||
clientY = _e$changedTouches$.clientY; | ||
/* globals document:true */ | ||
this.delegate.onEnd({ x: clientX, y: clientY }); | ||
} | ||
this.mouseInitialOffset = null; | ||
this.dragging = false; | ||
} | ||
}]); | ||
return TouchStrategy; | ||
}(); | ||
var gestureCover = null; | ||
var toggleGestureCover = function toggleGestureCover(toggle, cursor) { | ||
var style = { | ||
pointerEvents: toggle ? 'all' : 'none' | ||
}; | ||
if (toggle && cursor) { | ||
style = _extends({}, style, { | ||
cursor: cursor | ||
}); | ||
} | ||
if (!gestureCover) { | ||
style = _extends({}, style, { | ||
position: 'fixed', | ||
top: 0, | ||
right: 0, | ||
left: 0, | ||
bottom: 0, | ||
opacity: 0, | ||
zIndex: 2147483647 | ||
}); | ||
/* globals document:true */ | ||
gestureCover = document.createElement('div'); | ||
document.body.appendChild(gestureCover); | ||
} | ||
Object.keys(style).forEach(function (key) { | ||
gestureCover.style[key] = style[key]; | ||
}); | ||
}; | ||
var gestureCover = null; | ||
var toggleGestureCover = function toggleGestureCover(toggle, cursor) { | ||
var style = { | ||
pointerEvents: toggle ? 'all' : 'none' | ||
}; | ||
if (toggle && cursor) { | ||
style = _extends({}, style, { | ||
cursor: cursor | ||
}); | ||
} | ||
if (!gestureCover) { | ||
style = _extends({}, style, { | ||
position: 'fixed', | ||
top: 0, | ||
right: 0, | ||
left: 0, | ||
bottom: 0, | ||
opacity: 0, | ||
zIndex: 2147483647 | ||
}); | ||
/* globals window:true document:true */ | ||
gestureCover = document.createElement('div'); | ||
document.body.appendChild(gestureCover); | ||
} | ||
Object.keys(style).forEach(function (key) { | ||
gestureCover.style[key] = style[key]; | ||
}); | ||
}; | ||
var BOUNDARY = 10; | ||
var clamp = function clamp(value, min, max) { | ||
return Math.max(Math.min(value, max), min); | ||
}; | ||
var isBoundExceeded = function isBoundExceeded(_ref, _ref2) { | ||
var initialX = _ref.x, | ||
initialY = _ref.y; | ||
var x = _ref2.x, | ||
y = _ref2.y; | ||
return clamp(x, initialX - BOUNDARY, initialX + BOUNDARY) !== x || clamp(y, initialY - BOUNDARY, initialY + BOUNDARY) !== y; | ||
}; | ||
/* globals window:true document:true */ | ||
var MouseStrategy = function () { | ||
function MouseStrategy(delegate) { | ||
classCallCheck(this, MouseStrategy); | ||
var BOUNDARY = 10; | ||
var clamp = function clamp(value, min, max) { | ||
return Math.max(Math.min(value, max), min); | ||
}; | ||
var isBoundExceeded = function isBoundExceeded(_ref, _ref2) { | ||
var initialX = _ref.x, | ||
initialY = _ref.y; | ||
var x = _ref2.x, | ||
y = _ref2.y; | ||
return clamp(x, initialX - BOUNDARY, initialX + BOUNDARY) !== x || clamp(y, initialY - BOUNDARY, initialY + BOUNDARY) !== y; | ||
}; | ||
this.delegate = delegate; | ||
this.mouseInitialOffset = null; | ||
this.dragging = false; | ||
} | ||
var MouseStrategy = function () { | ||
function MouseStrategy(delegate) { | ||
classCallCheck(this, MouseStrategy); | ||
createClass(MouseStrategy, [{ | ||
key: 'isDragging', | ||
value: function isDragging() { | ||
return this.dragging; | ||
this.delegate = delegate; | ||
this.mouseInitialOffset = null; | ||
this.dragging = false; | ||
} | ||
}, { | ||
key: 'start', | ||
value: function start(e) { | ||
var x = e.clientX, | ||
y = e.clientY; | ||
this.e = e; | ||
this.mouseInitialOffset = { x: x, y: y }; | ||
} | ||
}, { | ||
key: 'move', | ||
value: function move(e) { | ||
var x = e.clientX, | ||
y = e.clientY; | ||
var dragStarted = false; | ||
if (!this.dragging && this.mouseInitialOffset) { | ||
if (isBoundExceeded(this.mouseInitialOffset, { x: x, y: y })) { | ||
this.delegate.onStart(this.mouseInitialOffset); | ||
if (window.getSelection) { | ||
window.getSelection().removeAllRanges(); | ||
} | ||
dragStarted = true; | ||
this.dragging = true; | ||
} | ||
createClass(MouseStrategy, [{ | ||
key: 'isDragging', | ||
value: function isDragging() { | ||
return this.dragging; | ||
} | ||
if (this.dragging) { | ||
e.preventDefault(); | ||
this.delegate.onMove({ x: x, y: y }); | ||
} | ||
if (dragStarted) { | ||
var _window$getComputedSt = window.getComputedStyle(document.elementFromPoint(x, y)), | ||
cursor = _window$getComputedSt.cursor; | ||
}, { | ||
key: 'start', | ||
value: function start(e) { | ||
var x = e.clientX, | ||
y = e.clientY; | ||
toggleGestureCover(true, cursor); | ||
this.e = e; | ||
this.mouseInitialOffset = { x: x, y: y }; | ||
} | ||
} | ||
}, { | ||
key: 'end', | ||
value: function end(e) { | ||
if (this.dragging) { | ||
}, { | ||
key: 'move', | ||
value: function move(e) { | ||
var x = e.clientX, | ||
y = e.clientY; | ||
toggleGestureCover(false); | ||
this.delegate.onEnd({ x: x, y: y }); | ||
var dragStarted = false; | ||
if (!this.dragging && this.mouseInitialOffset) { | ||
if (isBoundExceeded(this.mouseInitialOffset, { x: x, y: y })) { | ||
this.delegate.onStart(this.mouseInitialOffset); | ||
if (window.getSelection) { | ||
window.getSelection().removeAllRanges(); | ||
} | ||
dragStarted = true; | ||
this.dragging = true; | ||
} | ||
} | ||
if (this.dragging) { | ||
e.preventDefault(); | ||
this.delegate.onMove({ x: x, y: y }); | ||
} | ||
if (dragStarted) { | ||
var _window$getComputedSt = window.getComputedStyle(document.elementFromPoint(x, y)), | ||
cursor = _window$getComputedSt.cursor; | ||
toggleGestureCover(true, cursor); | ||
} | ||
} | ||
this.mouseInitialOffset = null; | ||
this.dragging = false; | ||
} | ||
}]); | ||
return MouseStrategy; | ||
}(); | ||
}, { | ||
key: 'end', | ||
value: function end(e) { | ||
if (this.dragging) { | ||
var x = e.clientX, | ||
y = e.clientY; | ||
/* globals window:true */ | ||
toggleGestureCover(false); | ||
this.delegate.onEnd({ x: x, y: y }); | ||
} | ||
this.mouseInitialOffset = null; | ||
this.dragging = false; | ||
} | ||
}]); | ||
return MouseStrategy; | ||
}(); | ||
var eventEmitter = null; | ||
var getSharedEventEmitter = function getSharedEventEmitter() { | ||
if (!eventEmitter) { | ||
eventEmitter = new dxCore.EventEmitter(); | ||
/* globals window:true */ | ||
['mousemove', 'mouseup', 'touchmove', 'touchend', 'touchcancel'].forEach(function (name) { | ||
return window.addEventListener(name, function (e) { | ||
return eventEmitter.emit([name, e]); | ||
}, { passive: false }); | ||
}); | ||
} | ||
return eventEmitter; | ||
}; | ||
var eventEmitter = null; | ||
var getSharedEventEmitter = function getSharedEventEmitter() { | ||
if (!eventEmitter) { | ||
eventEmitter = new dxCore.EventEmitter(); | ||
/* globals document:true window:true */ | ||
var clear = function clear() { | ||
if (window.getSelection) { | ||
if (window.getSelection().empty) { | ||
window.getSelection().empty(); | ||
} else if (window.getSelection().removeAllRanges) { | ||
window.getSelection().removeAllRanges(); | ||
['mousemove', 'mouseup', 'touchmove', 'touchend', 'touchcancel'].forEach(function (name) { | ||
return window.addEventListener(name, function (e) { | ||
return eventEmitter.emit([name, e]); | ||
}, { passive: false }); | ||
}); | ||
} | ||
} else if (document.selection) { | ||
document.selection.empty(); | ||
} | ||
}; | ||
return eventEmitter; | ||
}; | ||
// eslint-disable-next-line camelcase | ||
var draggingHandled = Symbol('draggingHandled'); | ||
/* globals document:true window:true */ | ||
var Draggable = function (_React$Component) { | ||
inherits(Draggable, _React$Component); | ||
var clear = function clear() { | ||
if (window.getSelection) { | ||
if (window.getSelection().empty) { | ||
window.getSelection().empty(); | ||
} else if (window.getSelection().removeAllRanges) { | ||
window.getSelection().removeAllRanges(); | ||
} | ||
} else if (document.selection) { | ||
document.selection.empty(); | ||
} | ||
}; | ||
function Draggable(props, context) { | ||
classCallCheck(this, Draggable); | ||
var draggingHandled = Symbol('draggingHandled'); | ||
var _this = possibleConstructorReturn(this, (Draggable.__proto__ || Object.getPrototypeOf(Draggable)).call(this, props, context)); | ||
var Draggable = function (_React$Component) { | ||
inherits(Draggable, _React$Component); | ||
var delegate = { | ||
onStart: function onStart(_ref) { | ||
var x = _ref.x, | ||
y = _ref.y; | ||
var onStart = _this.props.onStart; | ||
function Draggable(props, context) { | ||
classCallCheck(this, Draggable); | ||
if (!onStart) return; | ||
reactDom.unstable_batchedUpdates(function () { | ||
onStart({ x: x, y: y }); | ||
}); | ||
}, | ||
onMove: function onMove(_ref2) { | ||
var x = _ref2.x, | ||
y = _ref2.y; | ||
var onUpdate = _this.props.onUpdate; | ||
var _this = possibleConstructorReturn(this, (Draggable.__proto__ || Object.getPrototypeOf(Draggable)).call(this, props, context)); | ||
if (!onUpdate) return; | ||
reactDom.unstable_batchedUpdates(function () { | ||
onUpdate({ x: x, y: y }); | ||
}); | ||
}, | ||
onEnd: function onEnd(_ref3) { | ||
var x = _ref3.x, | ||
y = _ref3.y; | ||
var onEnd = _this.props.onEnd; | ||
var delegate = { | ||
onStart: function onStart(_ref) { | ||
var x = _ref.x, | ||
y = _ref.y; | ||
var onStart = _this.props.onStart; | ||
if (!onEnd) return; | ||
reactDom.unstable_batchedUpdates(function () { | ||
onEnd({ x: x, y: y }); | ||
}); | ||
} | ||
}; | ||
if (!onStart) return; | ||
reactDom.unstable_batchedUpdates(function () { | ||
onStart({ x: x, y: y }); | ||
}); | ||
}, | ||
onMove: function onMove(_ref2) { | ||
var x = _ref2.x, | ||
y = _ref2.y; | ||
var onUpdate = _this.props.onUpdate; | ||
_this.mouseStrategy = new MouseStrategy(delegate); | ||
_this.touchStrategy = new TouchStrategy(delegate); | ||
if (!onUpdate) return; | ||
reactDom.unstable_batchedUpdates(function () { | ||
onUpdate({ x: x, y: y }); | ||
}); | ||
}, | ||
onEnd: function onEnd(_ref3) { | ||
var x = _ref3.x, | ||
y = _ref3.y; | ||
var onEnd = _this.props.onEnd; | ||
_this.mouseDownListener = _this.mouseDownListener.bind(_this); | ||
_this.touchStartListener = _this.touchStartListener.bind(_this); | ||
_this.globalListener = _this.globalListener.bind(_this); | ||
return _this; | ||
} | ||
if (!onEnd) return; | ||
reactDom.unstable_batchedUpdates(function () { | ||
onEnd({ x: x, y: y }); | ||
}); | ||
} | ||
}; | ||
createClass(Draggable, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
getSharedEventEmitter().subscribe(this.globalListener); | ||
this.setupNodeSubscription(); | ||
} | ||
}, { | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate(nextProps) { | ||
var children = this.props.children; | ||
_this.mouseStrategy = new MouseStrategy(delegate); | ||
_this.touchStrategy = new TouchStrategy(delegate); | ||
return nextProps.children !== children; | ||
_this.mouseDownListener = _this.mouseDownListener.bind(_this); | ||
_this.touchStartListener = _this.touchStartListener.bind(_this); | ||
_this.globalListener = _this.globalListener.bind(_this); | ||
return _this; | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
this.setupNodeSubscription(); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
getSharedEventEmitter().unsubscribe(this.globalListener); | ||
} | ||
}, { | ||
key: 'setupNodeSubscription', | ||
value: function setupNodeSubscription() { | ||
// eslint-disable-next-line react/no-find-dom-node | ||
var node$$1 = reactDom.findDOMNode(this); | ||
if (!node$$1) return; | ||
node$$1.removeEventListener('mousedown', this.mouseDownListener); | ||
node$$1.removeEventListener('touchstart', this.touchStartListener); | ||
node$$1.addEventListener('mousedown', this.mouseDownListener, { passive: true }); | ||
node$$1.addEventListener('touchstart', this.touchStartListener, { passive: true }); | ||
} | ||
}, { | ||
key: 'mouseDownListener', | ||
value: function mouseDownListener(e) { | ||
if (this.touchStrategy.isWaiting() || e[draggingHandled]) return; | ||
this.mouseStrategy.start(e); | ||
e[draggingHandled] = true; | ||
} | ||
}, { | ||
key: 'touchStartListener', | ||
value: function touchStartListener(e) { | ||
if (e[draggingHandled]) return; | ||
this.touchStrategy.start(e); | ||
e[draggingHandled] = true; | ||
} | ||
}, { | ||
key: 'globalListener', | ||
value: function globalListener(_ref4) { | ||
var _ref5 = slicedToArray(_ref4, 2), | ||
name = _ref5[0], | ||
e = _ref5[1]; | ||
switch (name) { | ||
case 'mousemove': | ||
this.mouseStrategy.move(e); | ||
break; | ||
case 'mouseup': | ||
this.mouseStrategy.end(e); | ||
break; | ||
case 'touchmove': | ||
{ | ||
this.touchStrategy.move(e); | ||
createClass(Draggable, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
getSharedEventEmitter().subscribe(this.globalListener); | ||
this.setupNodeSubscription(); | ||
} | ||
}, { | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate(nextProps) { | ||
var children = this.props.children; | ||
return nextProps.children !== children; | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
this.setupNodeSubscription(); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
getSharedEventEmitter().unsubscribe(this.globalListener); | ||
} | ||
}, { | ||
key: 'setupNodeSubscription', | ||
value: function setupNodeSubscription() { | ||
// eslint-disable-next-line react/no-find-dom-node | ||
var node = reactDom.findDOMNode(this); | ||
if (!node) return; | ||
node.removeEventListener('mousedown', this.mouseDownListener); | ||
node.removeEventListener('touchstart', this.touchStartListener); | ||
node.addEventListener('mousedown', this.mouseDownListener, { passive: true }); | ||
node.addEventListener('touchstart', this.touchStartListener, { passive: true }); | ||
} | ||
}, { | ||
key: 'mouseDownListener', | ||
value: function mouseDownListener(e) { | ||
if (this.touchStrategy.isWaiting() || e[draggingHandled]) return; | ||
this.mouseStrategy.start(e); | ||
e[draggingHandled] = true; | ||
} | ||
}, { | ||
key: 'touchStartListener', | ||
value: function touchStartListener(e) { | ||
if (e[draggingHandled]) return; | ||
this.touchStrategy.start(e); | ||
e[draggingHandled] = true; | ||
} | ||
}, { | ||
key: 'globalListener', | ||
value: function globalListener(_ref4) { | ||
var _ref5 = slicedToArray(_ref4, 2), | ||
name = _ref5[0], | ||
e = _ref5[1]; | ||
switch (name) { | ||
case 'mousemove': | ||
this.mouseStrategy.move(e); | ||
break; | ||
} | ||
case 'touchend': | ||
case 'touchcancel': | ||
{ | ||
this.touchStrategy.end(e); | ||
case 'mouseup': | ||
this.mouseStrategy.end(e); | ||
break; | ||
} | ||
default: | ||
break; | ||
case 'touchmove': | ||
{ | ||
this.touchStrategy.move(e); | ||
break; | ||
} | ||
case 'touchend': | ||
case 'touchcancel': | ||
{ | ||
this.touchStrategy.end(e); | ||
break; | ||
} | ||
default: | ||
break; | ||
} | ||
if (this.mouseStrategy.isDragging() || this.touchStrategy.isDragging()) { | ||
clear(); | ||
} | ||
} | ||
if (this.mouseStrategy.isDragging() || this.touchStrategy.isDragging()) { | ||
clear(); | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var children = this.props.children; | ||
return children; | ||
} | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var children = this.props.children; | ||
}]); | ||
return Draggable; | ||
}(React.Component); | ||
return children; | ||
} | ||
}]); | ||
return Draggable; | ||
}(React.Component); | ||
process.env.NODE_ENV !== "production" ? Draggable.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
onStart: PropTypes.func, | ||
onUpdate: PropTypes.func, | ||
onEnd: PropTypes.func | ||
} : void 0; | ||
process.env.NODE_ENV !== "production" ? Draggable.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
onStart: PropTypes.func, | ||
onUpdate: PropTypes.func, | ||
onEnd: PropTypes.func | ||
} : void 0; | ||
Draggable.defaultProps = { | ||
onStart: undefined, | ||
onUpdate: undefined, | ||
onEnd: undefined | ||
}; | ||
Draggable.defaultProps = { | ||
onStart: undefined, | ||
onUpdate: undefined, | ||
onEnd: undefined | ||
}; | ||
var DragDropProviderCore = function () { | ||
function DragDropProviderCore() { | ||
classCallCheck(this, DragDropProviderCore); | ||
var DragDropProviderCore = function () { | ||
function DragDropProviderCore() { | ||
classCallCheck(this, DragDropProviderCore); | ||
this.payload = null; | ||
this.dragEmitter = new dxCore.EventEmitter(); | ||
} | ||
createClass(DragDropProviderCore, [{ | ||
key: 'start', | ||
value: function start(payload, clientOffset) { | ||
this.payload = payload; | ||
this.dragEmitter.emit({ payload: this.payload, clientOffset: clientOffset }); | ||
} | ||
}, { | ||
key: 'update', | ||
value: function update(clientOffset) { | ||
this.dragEmitter.emit({ payload: this.payload, clientOffset: clientOffset }); | ||
} | ||
}, { | ||
key: 'end', | ||
value: function end(clientOffset) { | ||
this.dragEmitter.emit({ payload: this.payload, clientOffset: clientOffset, end: true }); | ||
this.payload = null; | ||
this.dragEmitter = new dxCore.EventEmitter(); | ||
} | ||
}]); | ||
return DragDropProviderCore; | ||
}(); | ||
var DragDropProvider = function (_React$Component) { | ||
inherits(DragDropProvider, _React$Component); | ||
createClass(DragDropProviderCore, [{ | ||
key: 'start', | ||
value: function start(payload, clientOffset) { | ||
this.payload = payload; | ||
this.dragEmitter.emit({ payload: this.payload, clientOffset: clientOffset }); | ||
} | ||
}, { | ||
key: 'update', | ||
value: function update(clientOffset) { | ||
this.dragEmitter.emit({ payload: this.payload, clientOffset: clientOffset }); | ||
} | ||
}, { | ||
key: 'end', | ||
value: function end(clientOffset) { | ||
this.dragEmitter.emit({ payload: this.payload, clientOffset: clientOffset, end: true }); | ||
this.payload = null; | ||
} | ||
}]); | ||
return DragDropProviderCore; | ||
}(); | ||
function DragDropProvider(props) { | ||
classCallCheck(this, DragDropProvider); | ||
var DragDropProvider = function (_React$Component) { | ||
inherits(DragDropProvider, _React$Component); | ||
var _this = possibleConstructorReturn(this, (DragDropProvider.__proto__ || Object.getPrototypeOf(DragDropProvider)).call(this, props)); | ||
function DragDropProvider(props) { | ||
classCallCheck(this, DragDropProvider); | ||
var onChange = _this.props.onChange; | ||
var _this = possibleConstructorReturn(this, (DragDropProvider.__proto__ || Object.getPrototypeOf(DragDropProvider)).call(this, props)); | ||
var onChange = _this.props.onChange; | ||
_this.dragDropProvider = new DragDropProviderCore(); | ||
_this.dragDropProvider.dragEmitter.subscribe(function (_ref) { | ||
var payload = _ref.payload, | ||
clientOffset = _ref.clientOffset, | ||
end = _ref.end; | ||
_this.dragDropProvider = new DragDropProviderCore(); | ||
onChange({ | ||
payload: end ? null : payload, | ||
clientOffset: end ? null : clientOffset | ||
_this.dragDropProvider.dragEmitter.subscribe(function (_ref) { | ||
var payload = _ref.payload, | ||
clientOffset = _ref.clientOffset, | ||
end = _ref.end; | ||
onChange({ | ||
payload: end ? null : payload, | ||
clientOffset: end ? null : clientOffset | ||
}); | ||
}); | ||
}); | ||
return _this; | ||
} | ||
createClass(DragDropProvider, [{ | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
return { | ||
dragDropProvider: this.dragDropProvider | ||
}; | ||
return _this; | ||
} | ||
}, { | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate(nextProps) { | ||
var children = this.props.children; | ||
return nextProps.children !== children; | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var children = this.props.children; | ||
createClass(DragDropProvider, [{ | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
return { | ||
dragDropProvider: this.dragDropProvider | ||
}; | ||
} | ||
}, { | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate(nextProps) { | ||
var children = this.props.children; | ||
return children; | ||
} | ||
}]); | ||
return DragDropProvider; | ||
}(React.Component); | ||
return nextProps.children !== children; | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var children = this.props.children; | ||
DragDropProvider.childContextTypes = { | ||
dragDropProvider: PropTypes.object.isRequired | ||
}; | ||
return children; | ||
} | ||
}]); | ||
return DragDropProvider; | ||
}(React.Component); | ||
process.env.NODE_ENV !== "production" ? DragDropProvider.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
onChange: PropTypes.func | ||
} : void 0; | ||
DragDropProvider.childContextTypes = { | ||
dragDropProvider: PropTypes.object.isRequired | ||
}; | ||
DragDropProvider.defaultProps = { | ||
onChange: function onChange() {} | ||
}; | ||
process.env.NODE_ENV !== "production" ? DragDropProvider.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
onChange: PropTypes.func | ||
} : void 0; | ||
var DragSource = function (_React$Component) { | ||
inherits(DragSource, _React$Component); | ||
DragDropProvider.defaultProps = { | ||
onChange: function onChange() {} | ||
}; | ||
function DragSource() { | ||
classCallCheck(this, DragSource); | ||
return possibleConstructorReturn(this, (DragSource.__proto__ || Object.getPrototypeOf(DragSource)).apply(this, arguments)); | ||
} | ||
var DragSource = function (_React$Component) { | ||
inherits(DragSource, _React$Component); | ||
createClass(DragSource, [{ | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate(nextProps) { | ||
var children = this.props.children; | ||
return nextProps.children !== children; | ||
function DragSource() { | ||
classCallCheck(this, DragSource); | ||
return possibleConstructorReturn(this, (DragSource.__proto__ || Object.getPrototypeOf(DragSource)).apply(this, arguments)); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var dragDropProvider = this.context.dragDropProvider; | ||
var _props = this.props, | ||
_onStart = _props.onStart, | ||
_onUpdate = _props.onUpdate, | ||
_onEnd = _props.onEnd, | ||
payload = _props.payload, | ||
children = _props.children; | ||
return React.createElement( | ||
Draggable, | ||
{ | ||
onStart: function onStart(_ref) { | ||
var x = _ref.x, | ||
y = _ref.y; | ||
createClass(DragSource, [{ | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate(nextProps) { | ||
var children = this.props.children; | ||
dragDropProvider.start(payload, { x: x, y: y }); | ||
_onStart({ clientOffset: { x: x, y: y } }); | ||
}, | ||
onUpdate: function onUpdate(_ref2) { | ||
var x = _ref2.x, | ||
y = _ref2.y; | ||
return nextProps.children !== children; | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var dragDropProvider = this.context.dragDropProvider; | ||
var _props = this.props, | ||
_onStart = _props.onStart, | ||
_onUpdate = _props.onUpdate, | ||
_onEnd = _props.onEnd, | ||
payload = _props.payload, | ||
children = _props.children; | ||
dragDropProvider.update({ x: x, y: y }); | ||
_onUpdate({ clientOffset: { x: x, y: y } }); | ||
}, | ||
onEnd: function onEnd(_ref3) { | ||
var x = _ref3.x, | ||
y = _ref3.y; | ||
return React.createElement( | ||
Draggable, | ||
{ | ||
onStart: function onStart(_ref) { | ||
var x = _ref.x, | ||
y = _ref.y; | ||
dragDropProvider.end({ x: x, y: y }); | ||
_onEnd({ clientOffset: { x: x, y: y } }); | ||
} | ||
}, | ||
children | ||
); | ||
} | ||
}]); | ||
return DragSource; | ||
}(React.Component); | ||
dragDropProvider.start(payload, { x: x, y: y }); | ||
_onStart({ clientOffset: { x: x, y: y } }); | ||
}, | ||
onUpdate: function onUpdate(_ref2) { | ||
var x = _ref2.x, | ||
y = _ref2.y; | ||
DragSource.contextTypes = { | ||
dragDropProvider: PropTypes.object.isRequired | ||
}; | ||
dragDropProvider.update({ x: x, y: y }); | ||
_onUpdate({ clientOffset: { x: x, y: y } }); | ||
}, | ||
onEnd: function onEnd(_ref3) { | ||
var x = _ref3.x, | ||
y = _ref3.y; | ||
process.env.NODE_ENV !== "production" ? DragSource.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
payload: PropTypes.any.isRequired, | ||
onStart: PropTypes.func, | ||
onUpdate: PropTypes.func, | ||
onEnd: PropTypes.func | ||
} : void 0; | ||
dragDropProvider.end({ x: x, y: y }); | ||
_onEnd({ clientOffset: { x: x, y: y } }); | ||
} | ||
}, | ||
children | ||
); | ||
} | ||
}]); | ||
return DragSource; | ||
}(React.Component); | ||
DragSource.defaultProps = { | ||
onStart: function onStart() {}, | ||
onUpdate: function onUpdate() {}, | ||
onEnd: function onEnd() {} | ||
}; | ||
DragSource.contextTypes = { | ||
dragDropProvider: PropTypes.object.isRequired | ||
}; | ||
var clamp$1 = function clamp(value, min, max) { | ||
return Math.max(Math.min(value, max), min); | ||
}; | ||
process.env.NODE_ENV !== "production" ? DragSource.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
payload: PropTypes.any.isRequired, | ||
onStart: PropTypes.func, | ||
onUpdate: PropTypes.func, | ||
onEnd: PropTypes.func | ||
} : void 0; | ||
var DropTarget = function (_React$Component) { | ||
inherits(DropTarget, _React$Component); | ||
DragSource.defaultProps = { | ||
onStart: function onStart() {}, | ||
onUpdate: function onUpdate() {}, | ||
onEnd: function onEnd() {} | ||
}; | ||
function DropTarget(props, context) { | ||
classCallCheck(this, DropTarget); | ||
var clamp$1 = function clamp(value, min, max) { | ||
return Math.max(Math.min(value, max), min); | ||
}; | ||
var _this = possibleConstructorReturn(this, (DropTarget.__proto__ || Object.getPrototypeOf(DropTarget)).call(this, props, context)); | ||
var DropTarget = function (_React$Component) { | ||
inherits(DropTarget, _React$Component); | ||
_this.node = null; | ||
_this.isOver = false; | ||
function DropTarget(props, context) { | ||
classCallCheck(this, DropTarget); | ||
_this.handleDrag = _this.handleDrag.bind(_this); | ||
return _this; | ||
} | ||
var _this = possibleConstructorReturn(this, (DropTarget.__proto__ || Object.getPrototypeOf(DropTarget)).call(this, props, context)); | ||
createClass(DropTarget, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
var dragEmitter = this.context.dragDropProvider.dragEmitter; | ||
_this.node = null; | ||
_this.isOver = false; | ||
dragEmitter.subscribe(this.handleDrag); | ||
_this.handleDrag = _this.handleDrag.bind(_this); | ||
return _this; | ||
} | ||
}, { | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate(nextProps) { | ||
var children = this.props.children; | ||
return nextProps.children !== children; | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
var dragEmitter = this.context.dragDropProvider.dragEmitter; | ||
createClass(DropTarget, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
var dragEmitter = this.context.dragDropProvider.dragEmitter; | ||
dragEmitter.unsubscribe(this.handleDrag); | ||
} | ||
}, { | ||
key: 'handleDrag', | ||
value: function handleDrag(_ref) { | ||
var payload = _ref.payload, | ||
clientOffset = _ref.clientOffset, | ||
end = _ref.end; | ||
dragEmitter.subscribe(this.handleDrag); | ||
} | ||
}, { | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate(nextProps) { | ||
var children = this.props.children; | ||
var _findDOMNode$getBound = reactDom.findDOMNode(this).getBoundingClientRect(), | ||
left = _findDOMNode$getBound.left, | ||
top = _findDOMNode$getBound.top, | ||
right = _findDOMNode$getBound.right, | ||
bottom = _findDOMNode$getBound.bottom; // eslint-disable-line react/no-find-dom-node | ||
return nextProps.children !== children; | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
var dragEmitter = this.context.dragDropProvider.dragEmitter; | ||
dragEmitter.unsubscribe(this.handleDrag); | ||
} | ||
}, { | ||
key: 'handleDrag', | ||
value: function handleDrag(_ref) { | ||
var payload = _ref.payload, | ||
clientOffset = _ref.clientOffset, | ||
end = _ref.end; | ||
var _props = this.props, | ||
onDrop = _props.onDrop, | ||
onEnter = _props.onEnter, | ||
onLeave = _props.onLeave, | ||
onOver = _props.onOver; | ||
var _findDOMNode$getBound = reactDom.findDOMNode(this).getBoundingClientRect(), | ||
left = _findDOMNode$getBound.left, | ||
top = _findDOMNode$getBound.top, | ||
right = _findDOMNode$getBound.right, | ||
bottom = _findDOMNode$getBound.bottom; // eslint-disable-line react/no-find-dom-node | ||
var isOver = clientOffset && clamp$1(clientOffset.x, left, right) === clientOffset.x && clamp$1(clientOffset.y, top, bottom) === clientOffset.y; | ||
if (!this.isOver && isOver) onEnter({ payload: payload, clientOffset: clientOffset }); | ||
if (this.isOver && isOver) onOver({ payload: payload, clientOffset: clientOffset }); | ||
if (this.isOver && !isOver) onLeave({ payload: payload, clientOffset: clientOffset }); | ||
if (isOver && end) onDrop({ payload: payload, clientOffset: clientOffset }); | ||
var _props = this.props, | ||
onDrop = _props.onDrop, | ||
onEnter = _props.onEnter, | ||
onLeave = _props.onLeave, | ||
onOver = _props.onOver; | ||
this.isOver = isOver && !end; | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var children = this.props.children; | ||
var isOver = clientOffset && clamp$1(clientOffset.x, left, right) === clientOffset.x && clamp$1(clientOffset.y, top, bottom) === clientOffset.y; | ||
return React.Children.only(children); | ||
} | ||
}]); | ||
return DropTarget; | ||
}(React.Component); | ||
if (!this.isOver && isOver) onEnter({ payload: payload, clientOffset: clientOffset }); | ||
if (this.isOver && isOver) onOver({ payload: payload, clientOffset: clientOffset }); | ||
if (this.isOver && !isOver) onLeave({ payload: payload, clientOffset: clientOffset }); | ||
if (isOver && end) onDrop({ payload: payload, clientOffset: clientOffset }); | ||
DropTarget.contextTypes = { | ||
dragDropProvider: PropTypes.object.isRequired | ||
}; | ||
this.isOver = isOver && !end; | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var children = this.props.children; | ||
process.env.NODE_ENV !== "production" ? DropTarget.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
onEnter: PropTypes.func, | ||
onOver: PropTypes.func, | ||
onLeave: PropTypes.func, | ||
onDrop: PropTypes.func | ||
} : void 0; | ||
return React.Children.only(children); | ||
} | ||
}]); | ||
return DropTarget; | ||
}(React.Component); | ||
DropTarget.defaultProps = { | ||
onEnter: function onEnter() {}, | ||
onOver: function onOver() {}, | ||
onLeave: function onLeave() {}, | ||
onDrop: function onDrop() {} | ||
}; | ||
DropTarget.contextTypes = { | ||
dragDropProvider: PropTypes.object.isRequired | ||
}; | ||
var RefHolder = function (_React$PureComponent) { | ||
inherits(RefHolder, _React$PureComponent); | ||
process.env.NODE_ENV !== "production" ? DropTarget.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
onEnter: PropTypes.func, | ||
onOver: PropTypes.func, | ||
onLeave: PropTypes.func, | ||
onDrop: PropTypes.func | ||
} : void 0; | ||
function RefHolder() { | ||
classCallCheck(this, RefHolder); | ||
return possibleConstructorReturn(this, (RefHolder.__proto__ || Object.getPrototypeOf(RefHolder)).apply(this, arguments)); | ||
} | ||
DropTarget.defaultProps = { | ||
onEnter: function onEnter() {}, | ||
onOver: function onOver() {}, | ||
onLeave: function onLeave() {}, | ||
onDrop: function onDrop() {} | ||
}; | ||
createClass(RefHolder, [{ | ||
key: 'render', | ||
value: function render() { | ||
var children = this.props.children; | ||
var RefHolder = function (_React$PureComponent) { | ||
inherits(RefHolder, _React$PureComponent); | ||
return children; | ||
function RefHolder() { | ||
classCallCheck(this, RefHolder); | ||
return possibleConstructorReturn(this, (RefHolder.__proto__ || Object.getPrototypeOf(RefHolder)).apply(this, arguments)); | ||
} | ||
}]); | ||
return RefHolder; | ||
}(React.PureComponent); | ||
process.env.NODE_ENV !== "production" ? RefHolder.propTypes = { | ||
children: PropTypes.node.isRequired | ||
} : void 0; | ||
createClass(RefHolder, [{ | ||
key: 'render', | ||
value: function render() { | ||
var children = this.props.children; | ||
/* globals document:true */ | ||
return children; | ||
} | ||
}]); | ||
return RefHolder; | ||
}(React.PureComponent); | ||
var styles = { | ||
root: { | ||
position: 'relative' | ||
}, | ||
triggersRoot: { | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
height: '100%', | ||
width: '100%', | ||
overflow: 'hidden', | ||
zIndex: -1, | ||
visibility: 'hidden', | ||
opacity: 0 | ||
}, | ||
expandTrigger: { | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
height: '100%', | ||
width: '100%', | ||
overflow: 'auto' | ||
}, | ||
contractTrigger: { | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
height: '100%', | ||
width: '100%', | ||
overflow: 'auto', | ||
minHeight: '1px', | ||
minWidth: '1px' | ||
}, | ||
contractNotifier: { | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
width: '200%', | ||
height: '200%' | ||
} | ||
}; | ||
process.env.NODE_ENV !== "production" ? RefHolder.propTypes = { | ||
children: PropTypes.node.isRequired | ||
} : void 0; | ||
var Sizer = function (_React$PureComponent) { | ||
inherits(Sizer, _React$PureComponent); | ||
/* globals document:true */ | ||
function Sizer() { | ||
classCallCheck(this, Sizer); | ||
var styles = { | ||
root: { | ||
position: 'relative' | ||
}, | ||
triggersRoot: { | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
height: '100%', | ||
width: '100%', | ||
overflow: 'hidden', | ||
zIndex: -1, | ||
visibility: 'hidden', | ||
opacity: 0 | ||
}, | ||
expandTrigger: { | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
height: '100%', | ||
width: '100%', | ||
overflow: 'auto' | ||
}, | ||
contractTrigger: { | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
height: '100%', | ||
width: '100%', | ||
overflow: 'auto', | ||
minHeight: '1px', | ||
minWidth: '1px' | ||
}, | ||
contractNotifier: { | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
width: '200%', | ||
height: '200%' | ||
} | ||
}; | ||
var _this = possibleConstructorReturn(this, (Sizer.__proto__ || Object.getPrototypeOf(Sizer)).call(this)); | ||
var Sizer = function (_React$PureComponent) { | ||
inherits(Sizer, _React$PureComponent); | ||
_this.setupListeners = _this.setupListeners.bind(_this); | ||
return _this; | ||
} | ||
function Sizer() { | ||
classCallCheck(this, Sizer); | ||
createClass(Sizer, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this.createListeners(); | ||
this.setupListeners(); | ||
var _this = possibleConstructorReturn(this, (Sizer.__proto__ || Object.getPrototypeOf(Sizer)).call(this)); | ||
_this.setupListeners = _this.setupListeners.bind(_this); | ||
return _this; | ||
} | ||
}, { | ||
key: 'setupListeners', | ||
value: function setupListeners() { | ||
// eslint-disable-next-line react/no-find-dom-node | ||
var rootNode = reactDom.findDOMNode(this.root); | ||
var size = { height: rootNode.clientHeight, width: rootNode.clientWidth }; | ||
this.contractTrigger.scrollTop = size.height; | ||
this.contractTrigger.scrollLeft = size.width; | ||
createClass(Sizer, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this.createListeners(); | ||
this.setupListeners(); | ||
} | ||
}, { | ||
key: 'setupListeners', | ||
value: function setupListeners() { | ||
// eslint-disable-next-line react/no-find-dom-node | ||
var rootNode = reactDom.findDOMNode(this.root); | ||
var size = { height: rootNode.clientHeight, width: rootNode.clientWidth }; | ||
this.expandNotifier.style.width = size.width + 1 + 'px'; | ||
this.expandNotifier.style.height = size.height + 1 + 'px'; | ||
this.expandTrigger.scrollTop = 1; | ||
this.expandTrigger.scrollLeft = 1; | ||
this.contractTrigger.scrollTop = size.height; | ||
this.contractTrigger.scrollLeft = size.width; | ||
var onSizeChange = this.props.onSizeChange; | ||
this.expandNotifier.style.width = size.width + 1 + 'px'; | ||
this.expandNotifier.style.height = size.height + 1 + 'px'; | ||
this.expandTrigger.scrollTop = 1; | ||
this.expandTrigger.scrollLeft = 1; | ||
onSizeChange(size); | ||
} | ||
}, { | ||
key: 'createListeners', | ||
value: function createListeners() { | ||
// eslint-disable-next-line react/no-find-dom-node | ||
var rootNode = reactDom.findDOMNode(this.root); | ||
var onSizeChange = this.props.onSizeChange; | ||
this.triggersRoot = document.createElement('div'); | ||
Object.assign(this.triggersRoot.style, styles.triggersRoot); | ||
rootNode.appendChild(this.triggersRoot); | ||
onSizeChange(size); | ||
} | ||
}, { | ||
key: 'createListeners', | ||
value: function createListeners() { | ||
// eslint-disable-next-line react/no-find-dom-node | ||
var rootNode = reactDom.findDOMNode(this.root); | ||
this.expandTrigger = document.createElement('div'); | ||
Object.assign(this.expandTrigger.style, styles.expandTrigger); | ||
this.expandTrigger.addEventListener('scroll', this.setupListeners); | ||
this.triggersRoot.appendChild(this.expandTrigger); | ||
this.triggersRoot = document.createElement('div'); | ||
Object.assign(this.triggersRoot.style, styles.triggersRoot); | ||
rootNode.appendChild(this.triggersRoot); | ||
this.expandNotifier = document.createElement('div'); | ||
this.expandTrigger.appendChild(this.expandNotifier); | ||
this.expandTrigger = document.createElement('div'); | ||
Object.assign(this.expandTrigger.style, styles.expandTrigger); | ||
this.expandTrigger.addEventListener('scroll', this.setupListeners); | ||
this.triggersRoot.appendChild(this.expandTrigger); | ||
this.contractTrigger = document.createElement('div'); | ||
Object.assign(this.contractTrigger.style, styles.contractTrigger); | ||
this.contractTrigger.addEventListener('scroll', this.setupListeners); | ||
this.triggersRoot.appendChild(this.contractTrigger); | ||
this.expandNotifier = document.createElement('div'); | ||
this.expandTrigger.appendChild(this.expandNotifier); | ||
this.contractNotifier = document.createElement('div'); | ||
Object.assign(this.contractNotifier.style, styles.contractNotifier); | ||
this.contractTrigger.appendChild(this.contractNotifier); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _this2 = this; | ||
this.contractTrigger = document.createElement('div'); | ||
Object.assign(this.contractTrigger.style, styles.contractTrigger); | ||
this.contractTrigger.addEventListener('scroll', this.setupListeners); | ||
this.triggersRoot.appendChild(this.contractTrigger); | ||
var _props = this.props, | ||
onSizeChange = _props.onSizeChange, | ||
Container = _props.containerComponent, | ||
style = _props.style, | ||
restProps = objectWithoutProperties(_props, ['onSizeChange', 'containerComponent', 'style']); | ||
this.contractNotifier = document.createElement('div'); | ||
Object.assign(this.contractNotifier.style, styles.contractNotifier); | ||
this.contractTrigger.appendChild(this.contractNotifier); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _this2 = this; | ||
var _props = this.props, | ||
onSizeChange = _props.onSizeChange, | ||
Container = _props.containerComponent, | ||
style = _props.style, | ||
restProps = objectWithoutProperties(_props, ['onSizeChange', 'containerComponent', 'style']); | ||
return React.createElement( | ||
RefHolder, | ||
{ | ||
ref: function ref(_ref) { | ||
_this2.root = _ref; | ||
} | ||
}, | ||
React.createElement(Container, _extends({ | ||
style: _extends({}, styles.root, style) | ||
}, restProps)) | ||
); | ||
} | ||
}]); | ||
return Sizer; | ||
}(React.PureComponent); | ||
process.env.NODE_ENV !== "production" ? Sizer.propTypes = { | ||
onSizeChange: PropTypes.func.isRequired, | ||
containerComponent: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), | ||
style: PropTypes.object | ||
} : void 0; | ||
return React.createElement( | ||
RefHolder, | ||
{ | ||
ref: function ref(_ref) { | ||
_this2.root = _ref; | ||
} | ||
}, | ||
React.createElement(Container, _extends({ | ||
style: _extends({}, styles.root, style) | ||
}, restProps)) | ||
); | ||
} | ||
}]); | ||
return Sizer; | ||
}(React.PureComponent); | ||
Sizer.defaultProps = { | ||
containerComponent: 'div', | ||
style: null | ||
}; | ||
process.env.NODE_ENV !== "production" ? Sizer.propTypes = { | ||
onSizeChange: PropTypes.func.isRequired, | ||
containerComponent: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), | ||
style: PropTypes.object | ||
} : void 0; | ||
var createRenderComponent = function createRenderComponent(Component$$1, initialAdditionalProps) { | ||
var storedAdditionalProps = initialAdditionalProps; | ||
var components = new Set(); | ||
Sizer.defaultProps = { | ||
containerComponent: 'div', | ||
style: null | ||
}; | ||
var RenderComponent = function (_React$Component) { | ||
inherits(RenderComponent, _React$Component); | ||
var createRenderComponent = function createRenderComponent(Component, initialAdditionalProps) { | ||
var storedAdditionalProps = initialAdditionalProps; | ||
var components = new Set(); | ||
function RenderComponent() { | ||
classCallCheck(this, RenderComponent); | ||
return possibleConstructorReturn(this, (RenderComponent.__proto__ || Object.getPrototypeOf(RenderComponent)).apply(this, arguments)); | ||
} | ||
var RenderComponent = function (_React$Component) { | ||
inherits(RenderComponent, _React$Component); | ||
createClass(RenderComponent, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
components.add(this); | ||
function RenderComponent() { | ||
classCallCheck(this, RenderComponent); | ||
return possibleConstructorReturn(this, (RenderComponent.__proto__ || Object.getPrototypeOf(RenderComponent)).apply(this, arguments)); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
components.delete(this); | ||
createClass(RenderComponent, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
components.add(this); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
components.delete(this); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return React.createElement(Component, _extends({}, this.props, storedAdditionalProps)); | ||
} | ||
}]); | ||
return RenderComponent; | ||
}(React.Component); | ||
return { | ||
component: RenderComponent, | ||
update: function update(additionalProps) { | ||
storedAdditionalProps = additionalProps; | ||
Array.from(components.values()).forEach(function (component) { | ||
return component.forceUpdate(); | ||
}); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return React.createElement(Component$$1, _extends({}, this.props, storedAdditionalProps)); | ||
} | ||
}]); | ||
return RenderComponent; | ||
}(React.Component); | ||
}; | ||
}; | ||
return { | ||
component: RenderComponent, | ||
update: function update(additionalProps) { | ||
storedAdditionalProps = additionalProps; | ||
Array.from(components.values()).forEach(function (component) { | ||
return component.forceUpdate(); | ||
var createStateHelper = function createStateHelper(component) { | ||
var controlledStateProperties = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var notifyStateChange = function notifyStateChange(nextState, state) { | ||
Object.keys(controlledStateProperties).forEach(function (propertyName) { | ||
var changeEvent = controlledStateProperties[propertyName](); | ||
if (changeEvent && nextState[propertyName] !== state[propertyName]) { | ||
changeEvent(nextState[propertyName]); | ||
} | ||
}); | ||
} | ||
}; | ||
}; | ||
}; | ||
var createStateHelper = function createStateHelper(component) { | ||
var controlledStateProperties = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var lastStateUpdater = null; | ||
var initialState = null; | ||
var lastInitialState = null; | ||
var applyReducer = function applyReducer(reduce, payload, callback) { | ||
var stateUpdater = function stateUpdater(prevState) { | ||
if (initialState === null) { | ||
initialState = prevState; | ||
} | ||
var stateChange = reduce(_extends({}, prevState), payload); | ||
var state = _extends({}, prevState, stateChange); | ||
var notifyStateChange = function notifyStateChange(nextState, state) { | ||
Object.keys(controlledStateProperties).forEach(function (propertyName) { | ||
var changeEvent = controlledStateProperties[propertyName](); | ||
if (changeEvent && nextState[propertyName] !== state[propertyName]) { | ||
changeEvent(nextState[propertyName]); | ||
} | ||
}); | ||
if (typeof callback === 'function') { | ||
callback(state, prevState); | ||
} | ||
if (stateUpdater === lastStateUpdater) { | ||
if (lastInitialState !== initialState) { | ||
notifyStateChange(state, initialState); | ||
lastInitialState = initialState; | ||
} | ||
initialState = null; | ||
} | ||
return stateChange; | ||
}; | ||
lastStateUpdater = stateUpdater; | ||
component.setState(stateUpdater); | ||
}; | ||
var applyFieldReducer = function applyFieldReducer(field, reduce, payload) { | ||
applyReducer(function (state) { | ||
return defineProperty({}, field, reduce(state[field], payload)); | ||
}); | ||
}; | ||
return { | ||
applyReducer: applyReducer, | ||
applyFieldReducer: applyFieldReducer | ||
}; | ||
}; | ||
var lastStateUpdater = null; | ||
var initialState = null; | ||
var lastInitialState = null; | ||
var applyReducer = function applyReducer(reduce, payload, callback) { | ||
var stateUpdater = function stateUpdater(prevState) { | ||
if (initialState === null) { | ||
initialState = prevState; | ||
var makeBoundComponent = function makeBoundComponent(Target, components, exposed) { | ||
var Component = function (_React$PureComponent) { | ||
inherits(Component, _React$PureComponent); | ||
function Component() { | ||
classCallCheck(this, Component); | ||
return possibleConstructorReturn(this, (Component.__proto__ || Object.getPrototypeOf(Component)).apply(this, arguments)); | ||
} | ||
var stateChange = reduce(_extends({}, prevState), payload); | ||
var state = _extends({}, prevState, stateChange); | ||
if (typeof callback === 'function') { | ||
callback(state, prevState); | ||
} | ||
if (stateUpdater === lastStateUpdater) { | ||
if (lastInitialState !== initialState) { | ||
notifyStateChange(state, initialState); | ||
lastInitialState = initialState; | ||
createClass(Component, [{ | ||
key: 'render', | ||
value: function render() { | ||
return React.createElement(Target, _extends({}, components, this.props)); | ||
} | ||
initialState = null; | ||
} | ||
}]); | ||
return Component; | ||
}(React.PureComponent); | ||
return stateChange; | ||
}; | ||
lastStateUpdater = stateUpdater; | ||
component.setState(stateUpdater); | ||
Component.components = Target.components; | ||
Object.assign(Component, exposed); | ||
return Component; | ||
}; | ||
var applyFieldReducer = function applyFieldReducer(field, reduce, payload) { | ||
applyReducer(function (state) { | ||
return defineProperty({}, field, reduce(state[field], payload)); | ||
}); | ||
}; | ||
return { | ||
applyReducer: applyReducer, | ||
applyFieldReducer: applyFieldReducer | ||
var withComponents = function withComponents(components) { | ||
return function (Target) { | ||
var props = {}; | ||
var exposed = {}; | ||
Object.entries(Target.components).forEach(function (_ref) { | ||
var _ref2 = slicedToArray(_ref, 2), | ||
fieldName = _ref2[0], | ||
componentName = _ref2[1]; | ||
var component = components[componentName]; | ||
if (component && component !== Target[componentName]) { | ||
props[fieldName] = component; | ||
} | ||
exposed[componentName] = component || Target[componentName]; | ||
}); | ||
return Object.keys(props).length > 0 ? makeBoundComponent(Target, props, exposed) : Target; | ||
}; | ||
}; | ||
}; | ||
exports.PluginHost = PluginHost$1; | ||
exports.Plugin = Plugin; | ||
exports.Action = Action; | ||
exports.Getter = Getter; | ||
exports.Template = Template; | ||
exports.TemplatePlaceholder = TemplatePlaceholder; | ||
exports.TemplateConnector = TemplateConnector; | ||
exports.Draggable = Draggable; | ||
exports.DragDropProvider = DragDropProvider; | ||
exports.DragSource = DragSource; | ||
exports.DropTarget = DropTarget; | ||
exports.Sizer = Sizer; | ||
exports.RefHolder = RefHolder; | ||
exports.createRenderComponent = createRenderComponent; | ||
exports.createStateHelper = createStateHelper; | ||
exports.PluginHost = PluginHost; | ||
exports.Plugin = Plugin; | ||
exports.Action = Action; | ||
exports.Getter = Getter; | ||
exports.Template = Template; | ||
exports.TemplatePlaceholder = TemplatePlaceholder; | ||
exports.TemplateConnector = TemplateConnector; | ||
exports.Draggable = Draggable; | ||
exports.DragDropProvider = DragDropProvider; | ||
exports.DragSource = DragSource; | ||
exports.DropTarget = DropTarget; | ||
exports.Sizer = Sizer; | ||
exports.RefHolder = RefHolder; | ||
exports.createRenderComponent = createRenderComponent; | ||
exports.createStateHelper = createStateHelper; | ||
exports.withComponents = withComponents; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
//# sourceMappingURL=dx-react-core.umd.js.map |
{ | ||
"name": "@devexpress/dx-react-core", | ||
"version": "1.8.0-beta.1", | ||
"version": "1.8.0", | ||
"description": "Core library for DevExtreme React Components", | ||
@@ -43,3 +43,3 @@ "author": { | ||
"devDependencies": { | ||
"@devexpress/dx-testing": "^1.8.0-beta.1", | ||
"@devexpress/dx-testing": "^1.8.0", | ||
"babel-core": "^6.26.3", | ||
@@ -56,20 +56,20 @@ "babel-jest": "^23.4.2", | ||
"enzyme-adapter-react-16": "^1.2.0", | ||
"eslint": "^5.4.0", | ||
"eslint": "^5.6.1", | ||
"eslint-config-airbnb": "^17.1.0", | ||
"eslint-plugin-filenames": "^1.3.2", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-jest": "^21.22.0", | ||
"eslint-plugin-jest": "^21.24.0", | ||
"eslint-plugin-jsx-a11y": "^6.1.1", | ||
"eslint-plugin-react": "^7.11.1", | ||
"jest": "^23.5.0", | ||
"react": "^16.4.2", | ||
"react-dom": "^16.4.2", | ||
"react-test-renderer": "^16.4.2", | ||
"rollup": "0.50.0", | ||
"jest": "^23.6.0", | ||
"react": "^16.5.2", | ||
"react-dom": "^16.5.2", | ||
"react-test-renderer": "^16.5.2", | ||
"rollup": "^0.66.2", | ||
"rollup-plugin-babel": "^3.0.4", | ||
"rollup-plugin-license": "^0.6.0", | ||
"rollup-plugin-node-resolve": "^3.3.0" | ||
"rollup-plugin-license": "^0.7.0", | ||
"rollup-plugin-node-resolve": "^3.4.0" | ||
}, | ||
"dependencies": { | ||
"@devexpress/dx-core": "^1.8.0-beta.1", | ||
"@devexpress/dx-core": "^1.8.0", | ||
"prop-types": "^15.6.2" | ||
@@ -81,3 +81,3 @@ }, | ||
}, | ||
"gitHead": "8fb5dc5f32b4a02a8922917f07398b48902ecc5c" | ||
"gitHead": "30dd98f003c170e60ce6eb79d48fe4e3ac99338d" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
265805
4.28%0
-100%3145
-3.65%