New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@devexpress/dx-react-core

Package Overview
Dependencies
Maintainers
13
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@devexpress/dx-react-core - npm Package Compare versions

Comparing version 1.10.0 to 1.10.1

145

dist/dx-react-core.d.ts

@@ -0,7 +1,23 @@

// Dependencies for this module:
// ../../../../react
// ../../../../@devexpress/dx-core
import * as React from 'react';
import { IDependency } from '@devexpress/dx-core';
// -------------------------------------------------------------------------------------------------
// Action
// -------------------------------------------------------------------------------------------------
export interface PluginProps {
/** React elements that expose the plugin's state and actions and render the plugin's UI. */
children: React.ReactNode;
name?: string;
dependencies?: IDependency[];
}
export const Plugin: React.ComponentType<PluginProps>;
export type PluginHostProps = {
/** Plugin React elements. */
children?: React.ReactNode;
};
export class PluginHost extends React.PureComponent<PluginHostProps> {
}
export interface ActionProps {

@@ -11,95 +27,64 @@ /** The action name. */

/** A function that is called when the action is executed. */
action: (payload?: any) => void;
action: (payload: any, getters: Getters, actions: Actions) => void;
}
export const Action: React.ComponentType<ActionProps>;
/** A React component that shares a function between other plugins within a plugin-based component. */
export declare const Action: React.ComponentType<ActionProps>;
// -------------------------------------------------------------------------------------------------
// connectProps
// -------------------------------------------------------------------------------------------------
/** A function that creates a new component that allows you to pass additional properties to the wrapped component. */
export function connectProps(WrappedComponent: React.ComponentType<any>, getAdditionalProps: () => object): React.ComponentType<any>;
// -------------------------------------------------------------------------------------------------
// Getter
// -------------------------------------------------------------------------------------------------
export interface GetterProps {
/** The Getter's name. */
name: string;
/** The shared value. */
value?: any;
/** A function that calculates a value depending on the values other Getters expose. The value is computed each time a related Getter's value changes. Applies only if `value` is not defined. */
computed?: (getters: { [getterName: string]: any }) => any;
/** The Getter's name. */
name: string;
/** The shared value. */
value?: any;
/*** A function that calculates a value depending on the values other Getters expose.
* The value is computed each time a related Getter's value changes.
* Applies only if `value` is not defined.
*/
computed?: (getters: Getters, actions: Actions) => any;
}
export type Getters = {
readonly [getterName: string]: any;
};
export type Actions = {
[actionName: string]: (payload?: any) => void;
};
export const Getter: React.ComponentType<GetterProps>;
/** A React component that shares a value between other plugins within a plugin-based component. */
export declare const Getter: React.ComponentType<GetterProps>;
// -------------------------------------------------------------------------------------------------
// PluginHost
// -------------------------------------------------------------------------------------------------
export interface PluginHostProps {
/** Plugin React elements. */
children: React.ReactNode;
export interface TemplateProps {
/** The template name. The `root` name is reserved. A template called `root` is rendered as the plugin based component's root. */
name: string;
/** A predicate function that returns a Boolean value that specifies whether the template should be rendered. */
predicate?: (params: object) => boolean;
/** A markup or function that returns a markup based on the specified parameters. */
children: React.ReactNode | ((params: object) => React.ReactNode);
}
/*** A React component that defines a markup that is rendered
* as the corresponding TemplatePlaceholder.
*/
export const Template: React.ComponentType<TemplateProps>;
/** A React component that implements the plugin interaction mechanism in a plugin-based component. */
export declare const PluginHost: React.ComponentType<PluginHostProps>;
// -------------------------------------------------------------------------------------------------
// Plugin
// -------------------------------------------------------------------------------------------------
export interface PluginProps {
/** React elements that expose the plugin's state and actions and render the plugin's UI. */
children: React.ReactNode;
export interface TemplatePlaceholderProps {
/** The name of a template to be rendered. */
name?: string;
/** An object passed to the related template. */
params?: object;
children?: (content: any) => any;
}
/** A React component to which a related Template is rendered. */
export const TemplatePlaceholder: React.ComponentType<TemplatePlaceholderProps>;
/** A plugin component. The plugin's functionality is implemented in child Action, Getter and Template components. */
export declare const Plugin: React.ComponentType<PluginProps>;
// -------------------------------------------------------------------------------------------------
// TemplateConnector
// -------------------------------------------------------------------------------------------------
export interface TemplateConnectorProps {
/** A function that renders a markup using Getters and Actions passed as arguments. */
children: (getters: { [getterName: string]: any }, actions: { [actionName: string]: (payload?: any) => void }) => React.ReactNode;
children: (getters: Getters, actions: Actions) => React.ReactNode;
}
/** A React component that provides access to Getters and Actions within a Template. */
export declare const TemplateConnector: React.ComponentType<TemplateConnectorProps>;
export const TemplateConnector: React.ComponentType<TemplateConnectorProps>;
// -------------------------------------------------------------------------------------------------
// TemplatePlaceholder
// -------------------------------------------------------------------------------------------------
type connectPropsType = (WrappedComponent: React.ComponentType<any>, getAdditionalProps: () => object) => typeof WrappedComponent & {
update(): void;
};
/*** A function that creates a new component that allows you to pass additional properties
* to the wrapped component.
*/
export const connectProps: connectPropsType;
export interface TemplatePlaceholderProps {
/** The name of a template to be rendered. */
name?: string;
/** An object passed to the related template. */
params?: object;
}
/** A React component to which a related Template is rendered. */
export declare const TemplatePlaceholder: React.ComponentType<TemplatePlaceholderProps>;
// -------------------------------------------------------------------------------------------------
// Template
// -------------------------------------------------------------------------------------------------
export interface TemplateProps {
/** The template name. The `root` name is reserved. A template called `root` is rendered as the plugin based component's root. */
name: string;
/** A predicate function that returns a Boolean value that specifies whether the template should be rendered. */
predicate?: (params: object) => boolean;
/** A markup or function that returns a markup based on the specified parameters. */
children: React.ReactNode | ((params: object) => React.ReactNode);
}
/** A React component that defines a markup that is rendered as the corresponding TemplatePlaceholder. */
export declare const Template: React.ComponentType<TemplateProps>;
/**
* Bundle of @devexpress/dx-react-core
* Generated: 2018-12-25
* Version: 1.10.0
* Generated: 2019-02-06
* Version: 1.10.1
* License: https://js.devexpress.com/Licensing

@@ -9,1870 +9,1148 @@ */

import { createContext, createElement, Children, PureComponent, Component, createRef } from 'react';
import { node, object, func, string, arrayOf, shape, bool, any, oneOfType, instanceOf } from 'prop-types';
import { shallowEqual, PluginHost, EventEmitter } from '@devexpress/dx-core';
import { findDOMNode, unstable_batchedUpdates } from 'react-dom';
import { shape, instanceOf } from 'prop-types';
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
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);
}
}
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return obj;
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
}
return t;
};
return __assign.apply(this, arguments);
};
return target;
};
return _extends.apply(this, arguments);
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
/** @internal */
var PluginHostContext = createContext(null);
/** @internal */
var PositionContext = createContext(function () { return []; });
/** @internal */
var TemplateHostContext = createContext(null);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
/** @internal */
var PluginIndexer = /*#__PURE__*/ (function (_super) {
__extends(PluginIndexer, _super);
function PluginIndexer() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.indexes = {};
_this.memoize = function (index, positionContext) {
if (_this.indexes[index])
return _this.indexes[index];
var fn = function () {
var calculatedPosition = positionContext();
return calculatedPosition.concat([index]);
};
_this.indexes[index] = fn;
return fn;
};
return _this;
}
PluginIndexer.prototype.render = function () {
var _this = this;
var children = this.props.children;
return (createElement(PositionContext.Consumer, null, function (positionContext) { return (Children.map(children, function (child, index) {
if (!child || !child.type)
return child;
var childPosition = _this.memoize(index, positionContext);
return (createElement(PositionContext.Provider, { value: childPosition }, child));
})); }));
};
return PluginIndexer;
}(PureComponent));
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
function _objectWithoutProperties(source, excluded) {
if (source == null) return {};
var target = _objectWithoutPropertiesLoose(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _iterableToArrayLimit(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;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
var PluginHostContext = createContext();
var PositionContext = createContext();
var TemplateHostContext = createContext();
var PluginIndexer = function PluginIndexer(_ref) {
var children = _ref.children;
return createElement(PositionContext.Consumer, null, function (positionContext) {
return Children.map(children, function (child, index) {
if (!child || !child.type) return child;
var childPosition = function childPosition() {
var calculatedPosition = positionContext && positionContext() || [];
return [].concat(_toConsumableArray(calculatedPosition), [index]);
};
return createElement(PositionContext.Provider, {
value: childPosition
}, child);
});
});
};
process.env.NODE_ENV !== "production" ? PluginIndexer.propTypes = {
children: node
} : void 0;
PluginIndexer.defaultProps = {
children: undefined
};
/** @internal */
var PLUGIN_HOST_CONTEXT = 'dxcore_pluginHost_context';
/** @internal */
var POSITION_CONTEXT = 'dxcore_position_context';
/** @internal */
var TEMPLATE_HOST_CONTEXT = 'dxcore_templateHost_context';
/** @internal */
var RERENDER_TEMPLATE_EVENT = Symbol('rerenderTemplate');
/** @internal */
var RERENDER_TEMPLATE_SCOPE_EVENT = Symbol('rerenderTemplateScope');
/** @internal */
var UPDATE_CONNECTION_EVENT = Symbol('updateConnection');
var withContext = function withContext(Context, name) {
return function (Component$$1) {
return function (props) {
return createElement(Context.Consumer, null, function (context) {
return createElement(Component$$1, _extends({}, props, _defineProperty({}, name, context)));
});
};
};
};
var withHostAndPosition = function withHostAndPosition(Component$$1) {
return withContext(PluginHostContext, PLUGIN_HOST_CONTEXT)(withContext(PositionContext, POSITION_CONTEXT)(Component$$1));
};
/** @internal */
var withContext = function (Context, name) { return function (Component$$1) { return function (props) { return (createElement(Context.Consumer, null, function (context) {
var _a;
return (createElement(Component$$1, __assign({}, props, (_a = {}, _a[name] = context, _a))));
})); }; }; };
/** @internal */
var withHostAndPosition = function (Component$$1) { return withContext(PluginHostContext, PLUGIN_HOST_CONTEXT)(withContext(PositionContext, POSITION_CONTEXT)(Component$$1)); };
var _PluginBase$propTypes;
var PluginBase =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(PluginBase, _React$PureComponent);
function PluginBase() {
_classCallCheck(this, PluginBase);
return _possibleConstructorReturn(this, _getPrototypeOf(PluginBase).apply(this, arguments));
}
_createClass(PluginBase, [{
key: "componentDidMount",
value: function componentDidMount() {
var _this$props = this.props,
pluginHost = _this$props[PLUGIN_HOST_CONTEXT],
position = _this$props[POSITION_CONTEXT];
var _this$props2 = this.props,
name = _this$props2.name,
dependencies = _this$props2.dependencies;
this.plugin = {
position: position,
name: name,
dependencies: dependencies,
container: true
};
pluginHost.registerPlugin(this.plugin);
/** @internal */
var PluginBase = /*#__PURE__*/ (function (_super) {
__extends(PluginBase, _super);
function PluginBase() {
return _super !== null && _super.apply(this, arguments) || this;
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate() {
var pluginHost = this.props[PLUGIN_HOST_CONTEXT];
pluginHost.ensureDependencies();
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
var pluginHost = this.props[PLUGIN_HOST_CONTEXT];
pluginHost.unregisterPlugin(this.plugin);
}
}, {
key: "render",
value: function render() {
var children = this.props.children;
return createElement(PluginIndexer, null, children);
}
}]);
return PluginBase;
}(PureComponent);
process.env.NODE_ENV !== "production" ? PluginBase.propTypes = (_PluginBase$propTypes = {}, _defineProperty(_PluginBase$propTypes, PLUGIN_HOST_CONTEXT, object.isRequired), _defineProperty(_PluginBase$propTypes, POSITION_CONTEXT, func.isRequired), _defineProperty(_PluginBase$propTypes, "children", node.isRequired), _defineProperty(_PluginBase$propTypes, "name", string), _defineProperty(_PluginBase$propTypes, "dependencies", arrayOf(shape({
name: string,
optional: bool
}))), _PluginBase$propTypes) : void 0;
PluginBase.defaultProps = {
name: '',
dependencies: []
};
PluginBase.prototype.componentDidMount = function () {
var _a = this.props, _b = PLUGIN_HOST_CONTEXT, pluginHost = _a[_b], _c = POSITION_CONTEXT, position = _a[_c];
var _d = this.props, name = _d.name, dependencies = _d.dependencies;
this.plugin = {
position: position,
name: name,
dependencies: dependencies,
container: true,
};
pluginHost.registerPlugin(this.plugin);
};
PluginBase.prototype.componentDidUpdate = function () {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
pluginHost.ensureDependencies();
};
PluginBase.prototype.componentWillUnmount = function () {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
pluginHost.unregisterPlugin(this.plugin);
};
PluginBase.prototype.render = function () {
var children = this.props.children;
return (createElement(PluginIndexer, null, children));
};
return PluginBase;
}(PureComponent));
var Plugin = withHostAndPosition(PluginBase);
var _TemplatePlaceholderB, _TemplatePlaceholderB2;
var TemplatePlaceholderBase =
/*#__PURE__*/
function (_React$Component) {
_inherits(TemplatePlaceholderBase, _React$Component);
function TemplatePlaceholderBase(props) {
var _this$subscription;
var _this;
_classCallCheck(this, TemplatePlaceholderBase);
_this = _possibleConstructorReturn(this, _getPrototypeOf(TemplatePlaceholderBase).call(this, props));
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();
}
}), _defineProperty(_this$subscription, RERENDER_TEMPLATE_SCOPE_EVENT, function (name) {
if (propsName === name) {
_this.forceUpdate();
}
}), _this$subscription);
return _this;
}
_createClass(TemplatePlaceholderBase, [{
key: "componentDidMount",
value: function componentDidMount() {
var pluginHost = this.props[PLUGIN_HOST_CONTEXT];
pluginHost.registerSubscription(this.subscription);
var TemplatePlaceholderBase = /*#__PURE__*/ (function (_super) {
__extends(TemplatePlaceholderBase, _super);
function TemplatePlaceholderBase(props) {
var _a;
var _this = _super.call(this, props) || this;
_this.template = null;
_this.params = {};
_this.restTemplates = [];
var propsName = _this.props.name;
_this.subscription = (_a = {},
_a[RERENDER_TEMPLATE_EVENT] = function (id) {
if (_this.template && _this.template.id === id) {
_this.forceUpdate();
}
},
_a[RERENDER_TEMPLATE_SCOPE_EVENT] = function (name) {
if (propsName === name) {
_this.forceUpdate();
}
},
_a);
return _this;
}
}, {
key: "shouldComponentUpdate",
value: function shouldComponentUpdate(nextProps) {
var _this$getRenderingDat = this.getRenderingData(nextProps),
params = _this$getRenderingDat.params;
var children = this.props.children;
return !shallowEqual(params, this.params) || children !== nextProps.children;
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
var pluginHost = this.props[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.props[PLUGIN_HOST_CONTEXT];
TemplatePlaceholderBase.prototype.componentDidMount = function () {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
pluginHost.registerSubscription(this.subscription);
};
TemplatePlaceholderBase.prototype.shouldComponentUpdate = function (nextProps) {
var params = this.getRenderingData(nextProps).params;
var children = this.props.children;
return !shallowEqual(params, this.params) || children !== nextProps.children;
};
TemplatePlaceholderBase.prototype.componentWillUnmount = function () {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
pluginHost.unregisterSubscription(this.subscription);
};
TemplatePlaceholderBase.prototype.getRenderingData = function (props) {
var name = props.name, params = props.params;
if (name) {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
return {
params: params,
templates: pluginHost.collect(name + "Template")
.filter(function (template) { return template.predicate(params); })
.reverse(),
};
}
var _b = TEMPLATE_HOST_CONTEXT, templateHost = this.props[_b];
return {
params: params,
templates: pluginHost.collect("".concat(name, "Template")).filter(function (template) {
return template.predicate(params);
}).reverse()
params: params || templateHost.params(),
templates: templateHost.templates(),
};
}
var templateHost = this.props[TEMPLATE_HOST_CONTEXT];
return {
params: params || templateHost.params(),
templates: templateHost.templates()
};
}
}, {
key: "render",
value: function render() {
var _this2 = this;
var _this$getRenderingDat2 = this.getRenderingData(this.props),
params = _this$getRenderingDat2.params,
templates = _this$getRenderingDat2.templates;
this.params = params;
var _templates = _slicedToArray(templates, 1);
this.template = _templates[0];
this.restTemplates = templates.slice(1);
var content = null;
if (this.template) {
var templateContent = this.template.children;
content = templateContent() || null;
if (content && typeof content === 'function') {
content = content(params);
};
TemplatePlaceholderBase.prototype.render = function () {
var _this = this;
var _a = this.getRenderingData(this.props), params = _a.params, templates = _a.templates;
this.params = params;
this.template = templates[0];
this.restTemplates = templates.slice(1);
var content = null;
if (this.template) {
var templateContent = this.template.children;
content = templateContent() || null;
if (content && typeof content === 'function') {
content = content(params);
}
}
}
var templatePlaceholder = this.props.children;
return (createElement(TemplateHostContext.Provider, { value: {
templates: function () { return _this.restTemplates; },
params: function () { return _this.params; },
} }, templatePlaceholder ? templatePlaceholder(content) : content));
};
return TemplatePlaceholderBase;
}(Component));
/** A React component to which a related Template is rendered. */
var TemplatePlaceholder = withContext(PluginHostContext, PLUGIN_HOST_CONTEXT)(withContext(TemplateHostContext, TEMPLATE_HOST_CONTEXT)(TemplatePlaceholderBase));
var templatePlaceholder = this.props.children;
return createElement(TemplateHostContext.Provider, {
value: {
templates: function templates() {
return _this2.restTemplates;
},
params: function params() {
return _this2.params;
}
}
}, templatePlaceholder ? templatePlaceholder(content) : content);
var PluginHost$1 = /*#__PURE__*/ (function (_super) {
__extends(PluginHost$$1, _super);
/** @internal */
function PluginHost$$1(props) {
var _this = _super.call(this, props) || this;
_this.host = new PluginHost();
return _this;
}
}]);
/** @internal */
PluginHost$$1.prototype.render = function () {
var children = this.props.children;
return (createElement(PluginHostContext.Provider, { value: this.host },
createElement(PluginIndexer, null, children),
createElement(TemplatePlaceholder, { name: "root" })));
};
return PluginHost$$1;
}(PureComponent));
return TemplatePlaceholderBase;
}(Component);
process.env.NODE_ENV !== "production" ? TemplatePlaceholderBase.propTypes = (_TemplatePlaceholderB = {
name: string,
// eslint-disable-line react/no-unused-prop-types
params: object
}, _defineProperty(_TemplatePlaceholderB, TEMPLATE_HOST_CONTEXT, object), _defineProperty(_TemplatePlaceholderB, PLUGIN_HOST_CONTEXT, object.isRequired), _defineProperty(_TemplatePlaceholderB, "children", func), _TemplatePlaceholderB) : void 0;
TemplatePlaceholderBase.defaultProps = (_TemplatePlaceholderB2 = {}, _defineProperty(_TemplatePlaceholderB2, TEMPLATE_HOST_CONTEXT, undefined), _defineProperty(_TemplatePlaceholderB2, "name", undefined), _defineProperty(_TemplatePlaceholderB2, "params", undefined), _defineProperty(_TemplatePlaceholderB2, "children", undefined), _TemplatePlaceholderB2);
var TemplatePlaceholder = withContext(PluginHostContext, PLUGIN_HOST_CONTEXT)(withContext(TemplateHostContext, TEMPLATE_HOST_CONTEXT)(TemplatePlaceholderBase));
var PluginHost$1 =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(PluginHost$$1, _React$PureComponent);
function PluginHost$$1(props) {
var _this;
_classCallCheck(this, PluginHost$$1);
_this = _possibleConstructorReturn(this, _getPrototypeOf(PluginHost$$1).call(this, props));
_this.host = new PluginHost();
return _this;
}
_createClass(PluginHost$$1, [{
key: "render",
value: function render() {
var children = this.props.children;
return createElement(PluginHostContext.Provider, {
value: this.host
}, createElement(PluginIndexer, null, children), createElement(TemplatePlaceholder, {
name: "root"
}));
/** @internal */
var getAvailableGetters = function (pluginHost, getGetterValue) {
if (getGetterValue === void 0) { getGetterValue = function (getterName) { return pluginHost.get(getterName + "Getter"); }; }
var trackedDependencies = {};
var getters;
if (typeof Proxy !== 'undefined') {
getters = new Proxy({}, {
get: function (target, prop) {
if (typeof prop !== 'string')
return undefined;
var result = getGetterValue(prop);
trackedDependencies[prop] = result;
return result;
},
getOwnPropertyDescriptor: function (target, prop) {
return {
configurable: true,
enumerable: true,
value: this.get(target, prop, undefined),
};
},
ownKeys: function () {
return pluginHost.knownKeys('Getter');
},
});
}
}]);
return PluginHost$$1;
}(PureComponent);
process.env.NODE_ENV !== "production" ? PluginHost$1.propTypes = {
children: node
} : void 0;
PluginHost$1.defaultProps = {
children: undefined
else {
getters = pluginHost.knownKeys('Getter')
.reduce(function (acc, getterName) {
Object.defineProperty(acc, getterName, {
get: function () {
var result = getGetterValue(getterName);
trackedDependencies[getterName] = result;
return result;
},
});
return acc;
}, {});
}
return { getters: getters, trackedDependencies: trackedDependencies };
};
var getAvailableGetters = function getAvailableGetters(pluginHost) {
var getGetterValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (getterName) {
return pluginHost.get("".concat(getterName, "Getter"));
};
var trackedDependencies = {};
var getters;
if (typeof Proxy !== 'undefined') {
getters = new Proxy({}, {
get: function get(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() {
var result = getGetterValue(getterName);
trackedDependencies[getterName] = result;
return result;
}
});
return acc;
/** @internal */
var isTrackedDependenciesChanged = function (pluginHost, prevTrackedDependencies, getGetterValue) {
if (getGetterValue === void 0) { getGetterValue = function (getterName) { return pluginHost.get(getterName + "Getter"); }; }
var trackedDependencies = Object.keys(prevTrackedDependencies)
// tslint:disable-next-line: prefer-object-spread
.reduce(function (acc, getterName) {
var _a;
return Object.assign(acc, (_a = {},
_a[getterName] = getGetterValue(getterName),
_a));
}, {});
}
return {
getters: getters,
trackedDependencies: trackedDependencies
};
return !shallowEqual(prevTrackedDependencies, trackedDependencies);
};
var isTrackedDependenciesChanged = function isTrackedDependenciesChanged(pluginHost, prevTrackedDependencies) {
var getGetterValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (getterName) {
return pluginHost.get("".concat(getterName, "Getter"));
};
var trackedDependencies = Object.keys(prevTrackedDependencies).reduce(function (acc, getterName) {
return Object.assign(acc, _defineProperty({}, getterName, getGetterValue(getterName)));
}, {});
return !shallowEqual(prevTrackedDependencies, trackedDependencies);
/** @internal */
var getAvailableActions = function (pluginHost, getAction) {
if (getAction === void 0) { getAction = function (actionName) { return pluginHost.collect(actionName + "Action").slice().reverse()[0]; }; }
var actions;
if (typeof Proxy !== 'undefined') {
actions = new Proxy({}, {
get: function (target, prop) {
if (typeof prop !== 'string')
return undefined;
return getAction(prop);
},
getOwnPropertyDescriptor: function (target, prop) {
return {
configurable: true,
enumerable: true,
value: this.get(target, prop, undefined),
};
},
ownKeys: function () {
return pluginHost.knownKeys('Action');
},
});
}
else {
actions = pluginHost.knownKeys('Action')
.reduce(function (acc, actionName) {
Object.defineProperty(acc, actionName, {
get: function () { return getAction(actionName); },
});
return acc;
}, {});
}
return actions;
};
var getAvailableActions = function getAvailableActions(pluginHost) {
var getAction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (actionName) {
return pluginHost.collect("".concat(actionName, "Action")).slice().reverse()[0];
};
var actions;
if (typeof Proxy !== 'undefined') {
actions = new Proxy({}, {
get: function get(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() {
return getAction(actionName);
}
});
return acc;
}, {});
}
return actions;
};
var _ActionBase$propTypes;
var ActionBase =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(ActionBase, _React$PureComponent);
function ActionBase(props) {
var _this;
_classCallCheck(this, ActionBase);
_this = _possibleConstructorReturn(this, _getPrototypeOf(ActionBase).call(this, props));
var pluginHost = props[PLUGIN_HOST_CONTEXT],
positionContext = props[POSITION_CONTEXT];
var name = props.name;
_this.plugin = _defineProperty({
position: function position() {
return positionContext();
}
}, "".concat(name, "Action"), function Action(params) {
var action = _this.props.action;
var _getAvailableGetters = getAvailableGetters(pluginHost, function (getterName) {
return pluginHost.get("".concat(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("".concat(actionName, "Action"), _this.plugin).slice().reverse()[0];
});
action(params, getters, actions);
var nextAction = pluginHost.collect("".concat(name, "Action"), _this.plugin).slice().reverse()[0];
if (nextAction) {
nextAction(nextParams);
}
});
pluginHost.registerPlugin(_this.plugin);
return _this;
}
_createClass(ActionBase, [{
key: "componentWillUnmount",
value: function componentWillUnmount() {
var pluginHost = this.props[PLUGIN_HOST_CONTEXT];
pluginHost.unregisterPlugin(this.plugin);
var ActionBase = /*#__PURE__*/ (function (_super) {
__extends(ActionBase, _super);
function ActionBase(props) {
var _a;
var _this = _super.call(this, props) || this;
var _b = PLUGIN_HOST_CONTEXT, pluginHost = props[_b], _c = POSITION_CONTEXT, positionContext = props[_c];
var name = props.name;
_this.plugin = (_a = {
position: function () { return positionContext(); }
},
_a[name + "Action"] = function (params) {
var action = _this.props.action;
var getters = getAvailableGetters(pluginHost, function (getterName) { return pluginHost.get(getterName + "Getter", _this.plugin); }).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]); });
action(params, getters, actions);
var nextAction = pluginHost.collect(name + "Action", _this.plugin).slice().reverse()[0];
if (nextAction) {
nextAction(nextParams);
}
},
_a);
pluginHost.registerPlugin(_this.plugin);
return _this;
}
}, {
key: "render",
value: function render() {
return null;
}
}]);
return ActionBase;
}(PureComponent);
process.env.NODE_ENV !== "production" ? ActionBase.propTypes = (_ActionBase$propTypes = {
name: string.isRequired,
action: func.isRequired
}, _defineProperty(_ActionBase$propTypes, PLUGIN_HOST_CONTEXT, object.isRequired), _defineProperty(_ActionBase$propTypes, POSITION_CONTEXT, func.isRequired), _ActionBase$propTypes) : void 0;
ActionBase.prototype.componentWillUnmount = function () {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
pluginHost.unregisterPlugin(this.plugin);
};
ActionBase.prototype.render = function () {
return null;
};
return ActionBase;
}(PureComponent));
var Action = withHostAndPosition(ActionBase);
var _GetterBase$propTypes;
var GetterBase =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(GetterBase, _React$PureComponent);
function GetterBase(props) {
var _this;
_classCallCheck(this, GetterBase);
_this = _possibleConstructorReturn(this, _getPrototypeOf(GetterBase).call(this, props));
var pluginHost = props[PLUGIN_HOST_CONTEXT],
positionContext = props[POSITION_CONTEXT];
var name = props.name;
var lastComputed;
var lastTrackedDependencies = {};
var lastResult;
_this.plugin = _defineProperty({
position: function position() {
return positionContext();
}
}, "".concat(name, "Getter"), function Getter(original) {
var _this$props = _this.props,
value = _this$props.value,
computed = _this$props.computed;
if (computed === undefined) return value;
var getGetterValue = function getGetterValue(getterName) {
return getterName === name ? original : pluginHost.get("".concat(getterName, "Getter"), _this.plugin);
};
if (computed === lastComputed && !isTrackedDependenciesChanged(pluginHost, lastTrackedDependencies, getGetterValue)) {
return lastResult;
}
var _getAvailableGetters = getAvailableGetters(pluginHost, getGetterValue),
getters = _getAvailableGetters.getters,
trackedDependencies = _getAvailableGetters.trackedDependencies;
var actions = getAvailableActions(pluginHost);
lastComputed = computed;
lastTrackedDependencies = trackedDependencies;
lastResult = computed(getters, actions);
return lastResult;
});
pluginHost.registerPlugin(_this.plugin);
return _this;
}
_createClass(GetterBase, [{
key: "componentDidUpdate",
value: function componentDidUpdate() {
var pluginHost = this.props[PLUGIN_HOST_CONTEXT];
pluginHost.broadcast(UPDATE_CONNECTION_EVENT);
var GetterBase = /*#__PURE__*/ (function (_super) {
__extends(GetterBase, _super);
function GetterBase(props) {
var _a;
var _this = _super.call(this, props) || this;
var _b = PLUGIN_HOST_CONTEXT, pluginHost = props[_b], _c = POSITION_CONTEXT, positionContext = props[_c];
var name = props.name;
var lastComputed;
var lastTrackedDependencies = {};
var lastResult;
_this.plugin = (_a = {
position: function () { return positionContext(); }
},
_a[name + "Getter"] = function (original) {
var _a = _this.props, value = _a.value, computed = _a.computed;
if (computed === undefined)
return value;
var getGetterValue = function (getterName) { return ((getterName === name)
? original
: pluginHost.get(getterName + "Getter", _this.plugin)); };
if (computed === lastComputed
&& !isTrackedDependenciesChanged(pluginHost, lastTrackedDependencies, getGetterValue)) {
return lastResult;
}
var _b = getAvailableGetters(pluginHost, getGetterValue), getters = _b.getters, trackedDependencies = _b.trackedDependencies;
var actions = getAvailableActions(pluginHost);
lastComputed = computed;
lastTrackedDependencies = trackedDependencies;
lastResult = computed(getters, actions);
return lastResult;
},
_a);
pluginHost.registerPlugin(_this.plugin);
return _this;
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
var pluginHost = this.props[PLUGIN_HOST_CONTEXT];
pluginHost.unregisterPlugin(this.plugin);
}
}, {
key: "render",
value: function render() {
return null;
}
}]);
return GetterBase;
}(PureComponent);
process.env.NODE_ENV !== "production" ? GetterBase.propTypes = (_GetterBase$propTypes = {
name: string.isRequired,
value: any,
computed: func
}, _defineProperty(_GetterBase$propTypes, PLUGIN_HOST_CONTEXT, object.isRequired), _defineProperty(_GetterBase$propTypes, POSITION_CONTEXT, func.isRequired), _GetterBase$propTypes) : void 0;
GetterBase.defaultProps = {
value: undefined,
computed: undefined
};
GetterBase.prototype.componentDidUpdate = function () {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
pluginHost.broadcast(UPDATE_CONNECTION_EVENT);
};
GetterBase.prototype.componentWillUnmount = function () {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
pluginHost.unregisterPlugin(this.plugin);
};
GetterBase.prototype.render = function () {
return null;
};
return GetterBase;
}(PureComponent));
var Getter = withHostAndPosition(GetterBase);
var _TemplateBase$propTyp;
var globalTemplateId = 0;
var TemplateBase =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(TemplateBase, _React$PureComponent);
function TemplateBase(props) {
var _this;
_classCallCheck(this, TemplateBase);
_this = _possibleConstructorReturn(this, _getPrototypeOf(TemplateBase).call(this, props));
globalTemplateId += 1;
_this.id = globalTemplateId;
var pluginHost = props[PLUGIN_HOST_CONTEXT],
positionContext = props[POSITION_CONTEXT];
var name = props.name,
_predicate = props.predicate;
_this.plugin = _defineProperty({
position: function position() {
return positionContext();
}
}, "".concat(name, "Template"), {
id: _this.id,
predicate: function predicate(params) {
return _predicate ? _predicate(params) : true;
},
children: function children() {
var children = _this.props.children;
return children;
}
});
pluginHost.registerPlugin(_this.plugin);
pluginHost.broadcast(RERENDER_TEMPLATE_SCOPE_EVENT, name);
return _this;
}
_createClass(TemplateBase, [{
key: "componentDidUpdate",
value: function componentDidUpdate() {
var pluginHost = this.props[PLUGIN_HOST_CONTEXT];
pluginHost.broadcast(RERENDER_TEMPLATE_EVENT, this.id);
/** @internal */
var TemplateBase = /*#__PURE__*/ (function (_super) {
__extends(TemplateBase, _super);
function TemplateBase(props) {
var _a;
var _this = _super.call(this, props) || this;
_this.children = function () { return void 0; };
globalTemplateId += 1;
_this.id = globalTemplateId;
var _b = PLUGIN_HOST_CONTEXT, pluginHost = props[_b], _c = POSITION_CONTEXT, positionContext = props[_c];
var name = props.name, predicate = props.predicate;
_this.plugin = (_a = {
position: function () { return positionContext(); }
},
_a[name + "Template"] = {
id: _this.id,
predicate: function (params) { return (predicate ? predicate(params) : true); },
children: function () {
var children = _this.props.children;
return children;
},
},
_a);
pluginHost.registerPlugin(_this.plugin);
pluginHost.broadcast(RERENDER_TEMPLATE_SCOPE_EVENT, name);
return _this;
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
var pluginHost = this.props[PLUGIN_HOST_CONTEXT];
var name = this.props.name;
pluginHost.unregisterPlugin(this.plugin);
pluginHost.broadcast(RERENDER_TEMPLATE_SCOPE_EVENT, name);
}
}, {
key: "render",
value: function render() {
return null;
}
}]);
return TemplateBase;
}(PureComponent);
process.env.NODE_ENV !== "production" ? TemplateBase.propTypes = (_TemplateBase$propTyp = {}, _defineProperty(_TemplateBase$propTyp, PLUGIN_HOST_CONTEXT, object.isRequired), _defineProperty(_TemplateBase$propTyp, POSITION_CONTEXT, func.isRequired), _defineProperty(_TemplateBase$propTyp, "name", string.isRequired), _defineProperty(_TemplateBase$propTyp, "predicate", func), _defineProperty(_TemplateBase$propTyp, "children", oneOfType([func, node])), _TemplateBase$propTyp) : void 0;
TemplateBase.defaultProps = {
predicate: undefined,
children: undefined
};
TemplateBase.prototype.componentDidUpdate = function () {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
pluginHost.broadcast(RERENDER_TEMPLATE_EVENT, this.id);
};
TemplateBase.prototype.componentWillUnmount = function () {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
var name = this.props.name;
pluginHost.unregisterPlugin(this.plugin);
pluginHost.broadcast(RERENDER_TEMPLATE_SCOPE_EVENT, name);
};
TemplateBase.prototype.render = function () {
return null;
};
return TemplateBase;
}(PureComponent));
/*** A React component that defines a markup that is rendered
* as the corresponding TemplatePlaceholder.
*/
var Template = withHostAndPosition(TemplateBase);
var TemplateConnector =
/*#__PURE__*/
function (_React$Component) {
_inherits(TemplateConnector, _React$Component);
function TemplateConnector(props, context) {
var _this;
_classCallCheck(this, TemplateConnector);
_this = _possibleConstructorReturn(this, _getPrototypeOf(TemplateConnector).call(this, props, context));
_this.trackedDependencies = {};
_this.subscription = _defineProperty({}, UPDATE_CONNECTION_EVENT, function () {
return _this.updateConnection();
});
return _this;
}
_createClass(TemplateConnector, [{
key: "componentDidMount",
value: function componentDidMount() {
var pluginHost = this.context;
pluginHost.registerSubscription(this.subscription);
/** @internal */
var TemplateConnectorBase = /*#__PURE__*/ (function (_super) {
__extends(TemplateConnectorBase, _super);
function TemplateConnectorBase(props, context) {
var _a;
var _this = _super.call(this, props, context) || this;
_this.trackedDependencies = {};
_this.subscription = (_a = {},
_a[UPDATE_CONNECTION_EVENT] = function () { return _this.updateConnection(); },
_a);
return _this;
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
var pluginHost = this.context;
pluginHost.unregisterSubscription(this.subscription);
}
}, {
key: "updateConnection",
value: function updateConnection() {
var pluginHost = this.context;
TemplateConnectorBase.prototype.componentDidMount = function () {
var pluginHost = this.context;
pluginHost.registerSubscription(this.subscription);
};
TemplateConnectorBase.prototype.componentWillUnmount = function () {
var pluginHost = this.context;
pluginHost.unregisterSubscription(this.subscription);
};
TemplateConnectorBase.prototype.updateConnection = function () {
var pluginHost = this.context;
if (isTrackedDependenciesChanged(pluginHost, this.trackedDependencies)) {
this.forceUpdate();
}
};
TemplateConnectorBase.prototype.render = function () {
var pluginHost = this.context;
var children = this.props.children;
var _a = getAvailableGetters(pluginHost), getters = _a.getters, trackedDependencies = _a.trackedDependencies;
this.trackedDependencies = trackedDependencies;
var actions = getAvailableActions(pluginHost);
return children(getters, actions);
};
return TemplateConnectorBase;
}(Component));
TemplateConnectorBase.contextType = PluginHostContext;
/** A React component that provides access to Getters and Actions within a Template. */
var TemplateConnector = TemplateConnectorBase;
if (isTrackedDependenciesChanged(pluginHost, this.trackedDependencies)) {
this.forceUpdate();
}
}
}, {
key: "render",
value: function render() {
var pluginHost = this.context;
var children = this.props.children;
var _getAvailableGetters = getAvailableGetters(pluginHost),
getters = _getAvailableGetters.getters,
trackedDependencies = _getAvailableGetters.trackedDependencies;
this.trackedDependencies = trackedDependencies;
var actions = getAvailableActions(pluginHost);
return children(getters, actions);
}
}]);
return TemplateConnector;
}(Component);
process.env.NODE_ENV !== "production" ? TemplateConnector.propTypes = {
children: func.isRequired
} : void 0;
TemplateConnector.contextType = PluginHostContext;
var TIMEOUT = 180;
var TouchStrategy =
/*#__PURE__*/
function () {
function TouchStrategy(delegate) {
_classCallCheck(this, TouchStrategy);
this.delegate = delegate;
this.touchStartTimeout = null;
this.dragging = false;
}
_createClass(TouchStrategy, [{
key: "isDragging",
value: function isDragging() {
return this.dragging;
/** @internal */
var TouchStrategy = /*#__PURE__*/ (function () {
function TouchStrategy(delegate) {
this.delegate = delegate;
this.touchStartTimeout = null;
this.dragging = false;
}
}, {
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;
TouchStrategy.prototype.isDragging = function () {
return this.dragging;
};
TouchStrategy.prototype.isWaiting = function () {
return !!this.touchStartTimeout;
};
TouchStrategy.prototype.cancelWaiting = function () {
clearTimeout(this.touchStartTimeout);
this.touchStartTimeout = undefined;
};
TouchStrategy.prototype.start = function (e) {
var _this = this;
var _a = e.touches[0], x = _a.clientX, y = _a.clientY;
this.touchStartTimeout = setTimeout(function () {
_this.delegate.onStart({ x: x, y: y });
_this.dragging = true;
}, TIMEOUT);
};
TouchStrategy.prototype.move = function (e) {
this.cancelWaiting();
if (this.dragging) {
var _a = e.touches[0], clientX = _a.clientX, clientY = _a.clientY;
e.preventDefault();
this.delegate.onMove({ x: clientX, y: clientY });
}
};
TouchStrategy.prototype.end = function (e) {
this.cancelWaiting();
if (this.dragging) {
var _a = e.changedTouches[0], clientX = _a.clientX, clientY = _a.clientY;
this.delegate.onEnd({ x: clientX, y: clientY });
}
this.mouseInitialOffset = null;
this.dragging = false;
};
return TouchStrategy;
}());
var _e$touches$ = e.touches[0],
x = _e$touches$.clientX,
y = _e$touches$.clientY;
this.touchStartTimeout = setTimeout(function () {
_this.delegate.onStart({
x: x,
y: y
});
_this.dragging = true;
}, TIMEOUT);
/* globals document:true */
var gestureCover;
/** @internal */
var toggleGestureCover = function (toggle, cursor) {
var style = {
pointerEvents: toggle ? 'all' : 'none',
};
if (toggle && cursor) {
style = __assign({}, style, { cursor: cursor });
}
}, {
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;
e.preventDefault();
this.delegate.onMove({
x: clientX,
y: clientY
});
}
if (!gestureCover) {
style = __assign({}, style, { position: 'fixed', top: 0, right: 0, left: 0, bottom: 0, opacity: 0, zIndex: 2147483647 });
gestureCover = document.createElement('div');
document.body.appendChild(gestureCover);
}
}, {
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;
this.delegate.onEnd({
x: clientX,
y: clientY
});
}
this.mouseInitialOffset = null;
this.dragging = false;
}
}]);
return TouchStrategy;
}();
/* globals document:true */
var gestureCover = null;
var toggleGestureCover = function toggleGestureCover(toggle, cursor) {
var style = {
pointerEvents: toggle ? 'all' : 'none'
};
if (toggle && cursor) {
style = _objectSpread({}, style, {
cursor: cursor
});
}
if (!gestureCover) {
style = _objectSpread({}, style, {
position: 'fixed',
top: 0,
right: 0,
left: 0,
bottom: 0,
opacity: 0,
zIndex: 2147483647
});
gestureCover = document.createElement('div');
document.body.appendChild(gestureCover);
}
Object.keys(style).forEach(function (key) {
gestureCover.style[key] = style[key];
});
Object.keys(style).forEach(function (key) { gestureCover.style[key] = style[key]; });
};
/* globals window:true document:true */
var BOUNDARY = 10;
var clamp = function clamp(value, min, max) {
return Math.max(Math.min(value, max), min);
var clamp = function (value, min, max) { return Math.max(Math.min(value, max), min); };
var isBoundExceeded = function (_a, _b) {
var initialX = _a.x, initialY = _a.y;
var x = _b.x, y = _b.y;
return clamp(x, initialX - BOUNDARY, initialX + BOUNDARY) !== x
|| clamp(y, initialY - BOUNDARY, initialY + BOUNDARY) !== y;
};
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;
};
var MouseStrategy =
/*#__PURE__*/
function () {
function MouseStrategy(delegate) {
_classCallCheck(this, MouseStrategy);
this.delegate = delegate;
this.mouseInitialOffset = null;
this.dragging = false;
}
_createClass(MouseStrategy, [{
key: "isDragging",
value: function isDragging() {
return this.dragging;
/** @internal */
var MouseStrategy = /*#__PURE__*/ (function () {
function MouseStrategy(delegate) {
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;
MouseStrategy.prototype.isDragging = function () {
return this.dragging;
};
MouseStrategy.prototype.start = function (e) {
var x = e.clientX, y = e.clientY;
this.e = e;
this.mouseInitialOffset = { x: x, y: y };
};
MouseStrategy.prototype.move = function (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;
}
}
}
if (this.dragging) {
e.preventDefault();
this.delegate.onMove({ x: x, y: y });
}
if (dragStarted) {
var cursor = window.getComputedStyle(document.elementFromPoint(x, y)).cursor;
toggleGestureCover(true, cursor);
}
};
MouseStrategy.prototype.end = function (e) {
if (this.dragging) {
var x = e.clientX, y = e.clientY;
toggleGestureCover(false);
this.delegate.onEnd({ x: x, y: y });
}
this.mouseInitialOffset = null;
this.dragging = false;
};
return MouseStrategy;
}());
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);
}
/* globals window:true */
var eventEmitter;
/** @internal */
var getSharedEventEmitter = function () {
if (!eventEmitter) {
eventEmitter = new EventEmitter();
['mousemove', 'mouseup', 'touchmove', 'touchend', 'touchcancel']
.forEach(function (name) { return window.addEventListener(name, function (e) { return eventEmitter.emit([name, e]); }, { passive: false }); });
}
}, {
key: "end",
value: function end(e) {
if (this.dragging) {
var x = e.clientX,
y = e.clientY;
toggleGestureCover(false);
this.delegate.onEnd({
x: x,
y: y
});
}
this.mouseInitialOffset = null;
this.dragging = false;
}
}]);
return MouseStrategy;
}();
/* globals window:true */
var eventEmitter = null;
var getSharedEventEmitter = function getSharedEventEmitter() {
if (!eventEmitter) {
eventEmitter = new EventEmitter();
['mousemove', 'mouseup', 'touchmove', 'touchend', 'touchcancel'].forEach(function (name) {
return window.addEventListener(name, function (e) {
return eventEmitter.emit([name, e]);
}, {
passive: false
});
});
}
return eventEmitter;
return 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();
/** @internal */
var clear = function () {
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();
}
};
var draggingHandled = Symbol('draggingHandled');
var Draggable =
/*#__PURE__*/
function (_React$Component) {
_inherits(Draggable, _React$Component);
function Draggable(props, context) {
var _this;
_classCallCheck(this, Draggable);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Draggable).call(this, props, context));
var delegate = {
onStart: function onStart(_ref) {
var x = _ref.x,
y = _ref.y;
var onStart = _this.props.onStart;
if (!onStart) return;
unstable_batchedUpdates(function () {
onStart({
x: x,
y: y
});
});
},
onMove: function onMove(_ref2) {
var x = _ref2.x,
y = _ref2.y;
var onUpdate = _this.props.onUpdate;
if (!onUpdate) return;
unstable_batchedUpdates(function () {
onUpdate({
x: x,
y: y
});
});
},
onEnd: function onEnd(_ref3) {
var x = _ref3.x,
y = _ref3.y;
var onEnd = _this.props.onEnd;
if (!onEnd) return;
unstable_batchedUpdates(function () {
onEnd({
x: x,
y: y
});
});
}
/** @internal */
var Draggable = /*#__PURE__*/ (function (_super) {
__extends(Draggable, _super);
function Draggable(props, context) {
var _this = _super.call(this, props, context) || this;
var delegate = {
onStart: function (_a) {
var x = _a.x, y = _a.y;
var onStart = _this.props.onStart;
if (!onStart)
return;
unstable_batchedUpdates(function () {
onStart({ x: x, y: y });
});
},
onMove: function (_a) {
var x = _a.x, y = _a.y;
var onUpdate = _this.props.onUpdate;
if (!onUpdate)
return;
unstable_batchedUpdates(function () {
onUpdate({ x: x, y: y });
});
},
onEnd: function (_a) {
var x = _a.x, y = _a.y;
var onEnd = _this.props.onEnd;
if (!onEnd)
return;
unstable_batchedUpdates(function () {
onEnd({ x: x, y: y });
});
},
};
_this.mouseStrategy = new MouseStrategy(delegate);
_this.touchStrategy = new TouchStrategy(delegate);
_this.mouseDownListener = _this.mouseDownListener.bind(_this);
_this.touchStartListener = _this.touchStartListener.bind(_this);
_this.globalListener = _this.globalListener.bind(_this);
return _this;
}
Draggable.prototype.componentDidMount = function () {
getSharedEventEmitter().subscribe(this.globalListener);
this.setupNodeSubscription();
};
_this.mouseStrategy = new MouseStrategy(delegate);
_this.touchStrategy = new TouchStrategy(delegate);
_this.mouseDownListener = _this.mouseDownListener.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this.touchStartListener = _this.touchStartListener.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this.globalListener = _this.globalListener.bind(_assertThisInitialized(_assertThisInitialized(_this)));
return _this;
}
Draggable.prototype.shouldComponentUpdate = function (nextProps) {
var children = this.props.children;
return nextProps.children !== children;
};
Draggable.prototype.componentDidUpdate = function () {
this.setupNodeSubscription();
};
Draggable.prototype.componentWillUnmount = function () {
getSharedEventEmitter().unsubscribe(this.globalListener);
};
Draggable.prototype.setupNodeSubscription = function () {
var node = 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 });
};
Draggable.prototype.mouseDownListener = function (e) {
if (this.touchStrategy.isWaiting() || e[draggingHandled])
return;
this.mouseStrategy.start(e);
e[draggingHandled] = true;
};
Draggable.prototype.touchStartListener = function (e) {
if (e[draggingHandled])
return;
this.touchStrategy.start(e);
e[draggingHandled] = true;
};
Draggable.prototype.globalListener = function (_a) {
var name = _a[0], e = _a[1];
switch (name) {
case 'mousemove':
this.mouseStrategy.move(e);
break;
case 'mouseup':
this.mouseStrategy.end(e);
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();
}
};
Draggable.prototype.render = function () {
var children = this.props.children;
return children;
};
return Draggable;
}(Component));
_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$$1 = 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];
/** @internal */
var DragDropContext = createContext(null);
switch (name) {
case 'mousemove':
this.mouseStrategy.move(e);
break;
case 'mouseup':
this.mouseStrategy.end(e);
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();
}
/** @internal */
var DragDropProviderCore = /*#__PURE__*/ (function () {
function DragDropProviderCore() {
this.payload = null;
this.dragEmitter = new EventEmitter();
}
}, {
key: "render",
value: function render() {
var children = this.props.children;
return children;
}
}]);
return Draggable;
}(Component);
process.env.NODE_ENV !== "production" ? Draggable.propTypes = {
children: node.isRequired,
onStart: func,
onUpdate: func,
onEnd: func
} : void 0;
Draggable.defaultProps = {
onStart: undefined,
onUpdate: undefined,
onEnd: undefined
DragDropProviderCore.prototype.start = function (payload, clientOffset) {
this.payload = payload;
this.dragEmitter.emit({ clientOffset: clientOffset, payload: this.payload });
};
DragDropProviderCore.prototype.update = function (clientOffset) {
this.dragEmitter.emit({ clientOffset: clientOffset, payload: this.payload });
};
DragDropProviderCore.prototype.end = function (clientOffset) {
this.dragEmitter.emit({ clientOffset: clientOffset, payload: this.payload, end: true });
this.payload = null;
};
return DragDropProviderCore;
}());
var defaultProps = {
onChange: function (_a) {
var payload = _a.payload, clientOffset = _a.clientOffset;
},
};
var DragDropContext = createContext();
var DragDropProviderCore =
/*#__PURE__*/
function () {
function DragDropProviderCore() {
_classCallCheck(this, DragDropProviderCore);
this.payload = null;
this.dragEmitter = new EventEmitter();
}
_createClass(DragDropProviderCore, [{
key: "start",
value: function start(payload, clientOffset) {
this.payload = payload;
this.dragEmitter.emit({
payload: this.payload,
clientOffset: clientOffset
});
/** @internal */
// tslint:disable-next-line: max-classes-per-file
var DragDropProvider = /*#__PURE__*/ (function (_super) {
__extends(DragDropProvider, _super);
function DragDropProvider(props) {
var _this = _super.call(this, props) || this;
var onChange = _this.props.onChange;
_this.dragDropProvider = new DragDropProviderCore();
_this.dragDropProvider.dragEmitter.subscribe(function (_a) {
var payload = _a.payload, clientOffset = _a.clientOffset, end = _a.end;
onChange({
payload: end ? null : payload,
clientOffset: end ? null : clientOffset,
});
});
return _this;
}
}, {
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;
}
}]);
DragDropProvider.prototype.shouldComponentUpdate = function (nextProps) {
var children = this.props.children;
return nextProps.children !== children;
};
DragDropProvider.prototype.render = function () {
var children = this.props.children;
return (createElement(DragDropContext.Provider, { value: this.dragDropProvider }, children));
};
DragDropProvider.defaultProps = defaultProps;
return DragDropProvider;
}(Component));
return DragDropProviderCore;
}();
var DragDropProvider =
/*#__PURE__*/
function (_React$Component) {
_inherits(DragDropProvider, _React$Component);
function DragDropProvider(props) {
var _this;
_classCallCheck(this, DragDropProvider);
_this = _possibleConstructorReturn(this, _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;
onChange({
payload: end ? null : payload,
clientOffset: end ? null : clientOffset
});
});
return _this;
}
_createClass(DragDropProvider, [{
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;
return createElement(DragDropContext.Provider, {
value: this.dragDropProvider
}, children);
}
}]);
return DragDropProvider;
}(Component);
process.env.NODE_ENV !== "production" ? DragDropProvider.propTypes = {
children: node.isRequired,
onChange: func
} : void 0;
DragDropProvider.defaultProps = {
onChange: function onChange() {}
var defaultProps$1 = {
onStart: function (_a) {
var clientOffset = _a.clientOffset;
},
onUpdate: function (_a) {
var clientOffset = _a.clientOffset;
},
onEnd: function (_a) {
var clientOffset = _a.clientOffset;
},
};
var DragSource =
/*#__PURE__*/
function (_React$Component) {
_inherits(DragSource, _React$Component);
function DragSource() {
_classCallCheck(this, DragSource);
return _possibleConstructorReturn(this, _getPrototypeOf(DragSource).apply(this, arguments));
}
_createClass(DragSource, [{
key: "shouldComponentUpdate",
value: function shouldComponentUpdate(nextProps) {
var children = this.props.children;
return nextProps.children !== children;
/** @internal */
var DragSource = /*#__PURE__*/ (function (_super) {
__extends(DragSource, _super);
function DragSource() {
return _super !== null && _super.apply(this, arguments) || this;
}
}, {
key: "render",
value: function render() {
var dragDropProvider = this.context;
var _this$props = this.props,
_onStart = _this$props.onStart,
_onUpdate = _this$props.onUpdate,
_onEnd = _this$props.onEnd,
payload = _this$props.payload,
children = _this$props.children;
return createElement(Draggable, {
onStart: function onStart(_ref) {
var x = _ref.x,
y = _ref.y;
dragDropProvider.start(payload, {
x: x,
y: y
});
_onStart({
clientOffset: {
x: x,
y: y
}
});
},
onUpdate: function onUpdate(_ref2) {
var x = _ref2.x,
y = _ref2.y;
dragDropProvider.update({
x: x,
y: y
});
_onUpdate({
clientOffset: {
x: x,
y: y
}
});
},
onEnd: function onEnd(_ref3) {
var x = _ref3.x,
y = _ref3.y;
dragDropProvider.end({
x: x,
y: y
});
_onEnd({
clientOffset: {
x: x,
y: y
}
});
}
}, children);
}
}]);
return DragSource;
}(Component);
DragSource.prototype.shouldComponentUpdate = function (nextProps) {
var children = this.props.children;
return nextProps.children !== children;
};
DragSource.prototype.render = function () {
var dragDropProvider = this.context;
var _a = this.props, onStart = _a.onStart, onUpdate = _a.onUpdate, onEnd = _a.onEnd, payload = _a.payload, children = _a.children;
return (createElement(Draggable, { onStart: function (_a) {
var x = _a.x, y = _a.y;
dragDropProvider.start(payload, { x: x, y: y });
onStart({ clientOffset: { x: x, y: y } });
}, onUpdate: function (_a) {
var x = _a.x, y = _a.y;
dragDropProvider.update({ x: x, y: y });
onUpdate({ clientOffset: { x: x, y: y } });
}, onEnd: function (_a) {
var x = _a.x, y = _a.y;
dragDropProvider.end({ x: x, y: y });
onEnd({ clientOffset: { x: x, y: y } });
} }, children));
};
DragSource.defaultProps = defaultProps$1;
return DragSource;
}(Component));
DragSource.contextType = DragDropContext;
process.env.NODE_ENV !== "production" ? DragSource.propTypes = {
children: node.isRequired,
payload: any.isRequired,
onStart: func,
onUpdate: func,
onEnd: func
} : void 0;
DragSource.defaultProps = {
onStart: function onStart() {},
onUpdate: function onUpdate() {},
onEnd: function onEnd() {}
};
var clamp$1 = function clamp(value, min, max) {
return Math.max(Math.min(value, max), min);
var clamp$1 = function (value, min, max) { return Math.max(Math.min(value, max), min); };
var defaultProps$2 = {
onEnter: function (args) { },
onOver: function (args) { },
onLeave: function (args) { },
onDrop: function (args) { },
};
var DropTarget =
/*#__PURE__*/
function (_React$Component) {
_inherits(DropTarget, _React$Component);
function DropTarget(props) {
var _this;
_classCallCheck(this, DropTarget);
_this = _possibleConstructorReturn(this, _getPrototypeOf(DropTarget).call(this, props));
_this.node = null;
_this.isOver = false;
_this.handleDrag = _this.handleDrag.bind(_assertThisInitialized(_assertThisInitialized(_this)));
return _this;
}
_createClass(DropTarget, [{
key: "componentDidMount",
value: function componentDidMount() {
var dragEmitter = this.context.dragEmitter;
dragEmitter.subscribe(this.handleDrag);
/** @internal */
var DropTarget = /*#__PURE__*/ (function (_super) {
__extends(DropTarget, _super);
function DropTarget(props) {
var _this = _super.call(this, props) || this;
_this.isOver = false;
_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.dragEmitter;
dragEmitter.unsubscribe(this.handleDrag);
}
}, {
key: "handleDrag",
value: function handleDrag(_ref) {
var payload = _ref.payload,
clientOffset = _ref.clientOffset,
end = _ref.end;
var _findDOMNode$getBound = 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 _this$props = this.props,
onDrop = _this$props.onDrop,
onEnter = _this$props.onEnter,
onLeave = _this$props.onLeave,
onOver = _this$props.onOver;
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
});
this.isOver = isOver && !end;
}
}, {
key: "render",
value: function render() {
var children = this.props.children;
return Children.only(children);
}
}]);
return DropTarget;
}(Component);
DropTarget.prototype.componentDidMount = function () {
var dragEmitter = this.context.dragEmitter;
dragEmitter.subscribe(this.handleDrag);
};
DropTarget.prototype.shouldComponentUpdate = function (nextProps) {
var children = this.props.children;
return nextProps.children !== children;
};
DropTarget.prototype.componentWillUnmount = function () {
var dragEmitter = this.context.dragEmitter;
dragEmitter.unsubscribe(this.handleDrag);
};
DropTarget.prototype.handleDrag = function (_a) {
var payload = _a.payload, clientOffset = _a.clientOffset, end = _a.end;
var _b = findDOMNode(this).getBoundingClientRect(), left = _b.left, top = _b.top, right = _b.right, bottom = _b.bottom;
var _c = this.props, onDrop = _c.onDrop, onEnter = _c.onEnter, onLeave = _c.onLeave, onOver = _c.onOver;
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 });
this.isOver = isOver && !end;
};
DropTarget.prototype.render = function () {
var children = this.props.children;
return Children.only(children);
};
DropTarget.defaultProps = defaultProps$2;
return DropTarget;
}(Component));
DropTarget.contextType = DragDropContext;
process.env.NODE_ENV !== "production" ? DropTarget.propTypes = {
children: node.isRequired,
onEnter: func,
onOver: func,
onLeave: func,
onDrop: func
} : void 0;
DropTarget.defaultProps = {
onEnter: function onEnter() {},
onOver: function onOver() {},
onLeave: function onLeave() {},
onDrop: function onDrop() {}
};
var RefHolder =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(RefHolder, _React$PureComponent);
function RefHolder() {
_classCallCheck(this, RefHolder);
return _possibleConstructorReturn(this, _getPrototypeOf(RefHolder).apply(this, arguments));
}
_createClass(RefHolder, [{
key: "render",
value: function render() {
var children = this.props.children;
return children;
/** @internal */
var RefHolder = /*#__PURE__*/ (function (_super) {
__extends(RefHolder, _super);
function RefHolder() {
return _super !== null && _super.apply(this, arguments) || this;
}
}]);
RefHolder.prototype.render = function () {
var children = this.props.children;
return children;
};
return RefHolder;
}(PureComponent));
return RefHolder;
}(PureComponent);
process.env.NODE_ENV !== "production" ? RefHolder.propTypes = {
children: node.isRequired
} : void 0;
/* globals document:true */
var styles = {
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%'
}
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 Sizer =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(Sizer, _React$PureComponent);
function Sizer(props) {
var _this;
_classCallCheck(this, Sizer);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Sizer).call(this, props));
_this.setupListeners = _this.setupListeners.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this.rootRef = createRef();
return _this;
}
_createClass(Sizer, [{
key: "componentDidMount",
value: function componentDidMount() {
this.createListeners();
this.setupListeners();
/** @internal */
var Sizer = /*#__PURE__*/ (function (_super) {
__extends(Sizer, _super);
function Sizer(props) {
var _this = _super.call(this, props) || this;
_this.setupListeners = _this.setupListeners.bind(_this);
_this.rootRef = createRef();
return _this;
}
}, {
key: "setupListeners",
value: function setupListeners() {
// eslint-disable-next-line react/no-find-dom-node
var rootNode = findDOMNode(this.rootRef.current);
var size = {
height: rootNode.clientHeight,
width: rootNode.clientWidth
};
this.contractTrigger.scrollTop = size.height;
this.contractTrigger.scrollLeft = size.width;
this.expandNotifier.style.width = "".concat(size.width + 1, "px");
this.expandNotifier.style.height = "".concat(size.height + 1, "px");
this.expandTrigger.scrollTop = 1;
this.expandTrigger.scrollLeft = 1;
var onSizeChange = this.props.onSizeChange;
onSizeChange(size);
}
}, {
key: "createListeners",
value: function createListeners() {
// eslint-disable-next-line react/no-find-dom-node
var rootNode = findDOMNode(this.rootRef.current);
this.triggersRoot = document.createElement('div');
Object.assign(this.triggersRoot.style, styles.triggersRoot);
rootNode.appendChild(this.triggersRoot);
this.expandTrigger = document.createElement('div');
Object.assign(this.expandTrigger.style, styles.expandTrigger);
this.expandTrigger.addEventListener('scroll', this.setupListeners);
this.triggersRoot.appendChild(this.expandTrigger);
this.expandNotifier = document.createElement('div');
this.expandTrigger.appendChild(this.expandNotifier);
this.contractTrigger = document.createElement('div');
Object.assign(this.contractTrigger.style, styles.contractTrigger);
this.contractTrigger.addEventListener('scroll', this.setupListeners);
this.triggersRoot.appendChild(this.contractTrigger);
this.contractNotifier = document.createElement('div');
Object.assign(this.contractNotifier.style, styles.contractNotifier);
this.contractTrigger.appendChild(this.contractNotifier);
}
}, {
key: "render",
value: function render() {
var _this$props = this.props,
onSizeChange = _this$props.onSizeChange,
Container = _this$props.containerComponent,
restProps = _objectWithoutProperties(_this$props, ["onSizeChange", "containerComponent"]);
Sizer.prototype.componentDidMount = function () {
this.createListeners();
this.setupListeners();
};
// There is no need to remove listeners as divs are removed from DOM when component is unmount.
// But there is a little chance that component unmounting and 'scroll' event happen roughly
// at the same time so that `setupListeners` is called after component is unmount.
Sizer.prototype.componentWillUnmount = function () {
this.expandTrigger.removeEventListener('scroll', this.setupListeners);
this.contractTrigger.removeEventListener('scroll', this.setupListeners);
};
Sizer.prototype.setupListeners = function () {
var size = { height: this.rootNode.clientHeight, width: this.rootNode.clientWidth };
this.contractTrigger.scrollTop = size.height;
this.contractTrigger.scrollLeft = size.width;
this.expandNotifier.style.width = size.width + 1 + "px";
this.expandNotifier.style.height = size.height + 1 + "px";
this.expandTrigger.scrollTop = 1;
this.expandTrigger.scrollLeft = 1;
var onSizeChange = this.props.onSizeChange;
onSizeChange(size);
};
Sizer.prototype.createListeners = function () {
this.rootNode = findDOMNode(this.rootRef.current);
this.triggersRoot = document.createElement('div');
Object.assign(this.triggersRoot.style, styles.triggersRoot);
this.rootNode.appendChild(this.triggersRoot);
this.expandTrigger = document.createElement('div');
Object.assign(this.expandTrigger.style, styles.expandTrigger);
this.expandTrigger.addEventListener('scroll', this.setupListeners);
this.triggersRoot.appendChild(this.expandTrigger);
this.expandNotifier = document.createElement('div');
this.expandTrigger.appendChild(this.expandNotifier);
this.contractTrigger = document.createElement('div');
Object.assign(this.contractTrigger.style, styles.contractTrigger);
this.contractTrigger.addEventListener('scroll', this.setupListeners);
this.triggersRoot.appendChild(this.contractTrigger);
this.contractNotifier = document.createElement('div');
Object.assign(this.contractNotifier.style, styles.contractNotifier);
this.contractTrigger.appendChild(this.contractNotifier);
};
Sizer.prototype.render = function () {
var _a = this.props, onSizeChange = _a.onSizeChange, Container = _a.containerComponent, restProps = __rest(_a, ["onSizeChange", "containerComponent"]);
return (createElement(RefHolder, { ref: this.rootRef },
createElement(Container // NOTE: should have `position: relative`
, __assign({}, restProps))));
};
Sizer.defaultProps = {
containerComponent: 'div',
};
return Sizer;
}(PureComponent));
return createElement(RefHolder, {
ref: this.rootRef
}, createElement(Container // NOTE: should have `position: relative`
, restProps));
}
}]);
return Sizer;
}(PureComponent);
process.env.NODE_ENV !== "production" ? Sizer.propTypes = {
onSizeChange: func.isRequired,
containerComponent: oneOfType([string, func])
} : void 0;
Sizer.defaultProps = {
containerComponent: 'div'
};
var connectProps = function connectProps(WrappedComponent, getAdditionalProps) {
var storedAdditionalProps = getAdditionalProps();
var components = new Set();
var RenderComponent =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(RenderComponent, _React$PureComponent);
function RenderComponent() {
_classCallCheck(this, RenderComponent);
return _possibleConstructorReturn(this, _getPrototypeOf(RenderComponent).apply(this, arguments));
}
_createClass(RenderComponent, [{
key: "componentDidMount",
value: function componentDidMount() {
components.add(this);
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
components.delete(this);
}
}, {
key: "render",
value: function render() {
return createElement(WrappedComponent, _extends({}, this.props, storedAdditionalProps));
}
}]);
/*** A function that creates a new component that allows you to pass additional properties
* to the wrapped component.
*/
var connectProps = function (WrappedComponent, getAdditionalProps) {
var storedAdditionalProps = getAdditionalProps();
var components = new Set();
var RenderComponent = /*#__PURE__*/ (function (_super) {
__extends(RenderComponent, _super);
function RenderComponent() {
return _super !== null && _super.apply(this, arguments) || this;
}
RenderComponent.prototype.componentDidMount = function () {
components.add(this);
};
RenderComponent.prototype.componentWillUnmount = function () {
components.delete(this);
};
RenderComponent.prototype.render = function () {
return createElement(WrappedComponent, __assign({}, this.props, storedAdditionalProps));
};
return RenderComponent;
}(PureComponent));
RenderComponent.update = function () {
storedAdditionalProps = getAdditionalProps();
Array.from(components.values()).forEach(function (component) { return component.forceUpdate(); });
};
return RenderComponent;
}(PureComponent);
RenderComponent.update = function () {
storedAdditionalProps = getAdditionalProps();
Array.from(components.values()).forEach(function (component) {
return component.forceUpdate();
});
};
return RenderComponent;
};
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 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(_objectSpread({}, prevState), payload);
var state = _objectSpread({}, prevState, stateChange);
if (typeof callback === 'function') {
callback(state, prevState);
}
if (stateUpdater === lastStateUpdater) {
if (lastInitialState !== initialState) {
notifyStateChange(state, initialState);
lastInitialState = initialState;
}
initialState = null;
}
return stateChange;
/** @internal */
var createStateHelper = function (component, controlledStateProperties) {
if (controlledStateProperties === void 0) { controlledStateProperties = {}; }
var notifyStateChange = function (nextState, state) {
Object.keys(controlledStateProperties).forEach(function (propertyName) {
var changeEvent = controlledStateProperties[propertyName]();
if (changeEvent && nextState[propertyName] !== state[propertyName]) {
changeEvent(nextState[propertyName]);
}
});
};
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;
var initialState = null;
var lastInitialState = null;
var applyReducer = function (reduce, payload, callback) {
var stateUpdater = function (prevState) {
if (initialState === null) {
initialState = prevState;
}
var stateChange = reduce(__assign({}, prevState), payload);
var state = __assign({}, prevState, stateChange);
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 (field, reduce, payload) {
applyReducer(function (state) {
var _a;
return (_a = {},
_a[field] = reduce(state[field], payload),
_a);
});
};
return {
applyReducer: applyReducer,
applyFieldReducer: applyFieldReducer,
};
};
var makeBoundComponent = function makeBoundComponent(Target, components, exposed) {
var Component$$1 =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(Component$$1, _React$PureComponent);
function Component$$1() {
_classCallCheck(this, Component$$1);
return _possibleConstructorReturn(this, _getPrototypeOf(Component$$1).apply(this, arguments));
}
_createClass(Component$$1, [{
key: "render",
value: function render() {
return createElement(Target, _extends({}, components, this.props));
}
}]);
var makeBoundComponent = function (Target, components, exposed) {
var Component$$1 = /*#__PURE__*/ (function (_super) {
__extends(Component$$1, _super);
function Component$$1() {
return _super !== null && _super.apply(this, arguments) || this;
}
Component$$1.prototype.render = function () {
return createElement(Target, __assign({}, components, this.props));
};
return Component$$1;
}(PureComponent));
Component$$1.components = Target.components;
Object.assign(Component$$1, exposed);
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) {
// type ITargetComponentStatic = new() => ITargetComponent;
/** @internal */
var withComponents = function (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];
var targetComponents = Target.components;
Object.entries(targetComponents).forEach(function (_a) {
var fieldName = _a[0], componentName = _a[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;
};
};
return Object.keys(props).length > 0
? makeBoundComponent(Target, props, exposed) : Target;
}; };
/* globals Element */
/** @internal */
var RefType = shape({
current: instanceOf(typeof Element !== 'undefined' ? Element : Object)
current: instanceOf((typeof Element !== 'undefined') ? Element : Object),
});

@@ -1879,0 +1157,0 @@

/**
* Bundle of @devexpress/dx-react-core
* Generated: 2018-12-25
* Version: 1.10.0
* Generated: 2019-02-06
* Version: 1.10.1
* License: https://js.devexpress.com/Licensing

@@ -9,1896 +9,1174 @@ */

(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) :
(global = global || self, 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';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@devexpress/dx-core'), require('react-dom'), require('prop-types')) :
typeof define === 'function' && define.amd ? define(['exports', 'react', '@devexpress/dx-core', 'react-dom', 'prop-types'], factory) :
(global = global || self, factory((global.DevExpress = global.DevExpress || {}, global.DevExpress.DXReactCore = {}), global.React, global.DevExpress.DXCore, global.ReactDOM, global.PropTypes));
}(this, function (exports, React, dxCore, reactDom, PropTypes) { 'use strict';
if (typeof process === "undefined") { var process = { env: {} }; }
if (typeof process === "undefined") { var process = { env: {} }; }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
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);
}
}
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return _extends.apply(this, arguments);
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
return target;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
function _objectWithoutProperties(source, excluded) {
if (source == null) return {};
var target = _objectWithoutPropertiesLoose(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _iterableToArrayLimit(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;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
var PluginHostContext = React.createContext();
var PositionContext = React.createContext();
var TemplateHostContext = React.createContext();
var PluginIndexer = function PluginIndexer(_ref) {
var children = _ref.children;
return React.createElement(PositionContext.Consumer, null, function (positionContext) {
return React.Children.map(children, function (child, index) {
if (!child || !child.type) return child;
var childPosition = function childPosition() {
var calculatedPosition = positionContext && positionContext() || [];
return [].concat(_toConsumableArray(calculatedPosition), [index]);
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return React.createElement(PositionContext.Provider, {
value: childPosition
}, child);
});
});
};
process.env.NODE_ENV !== "production" ? PluginIndexer.propTypes = {
children: PropTypes.node
} : void 0;
PluginIndexer.defaultProps = {
children: undefined
};
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 withContext = function withContext(Context, name) {
return function (Component) {
return function (props) {
return React.createElement(Context.Consumer, null, function (context) {
return React.createElement(Component, _extends({}, props, _defineProperty({}, name, context)));
});
};
return __assign.apply(this, arguments);
};
};
var withHostAndPosition = function withHostAndPosition(Component) {
return withContext(PluginHostContext, PLUGIN_HOST_CONTEXT)(withContext(PositionContext, POSITION_CONTEXT)(Component));
};
var _PluginBase$propTypes;
var PluginBase =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(PluginBase, _React$PureComponent);
function PluginBase() {
_classCallCheck(this, PluginBase);
return _possibleConstructorReturn(this, _getPrototypeOf(PluginBase).apply(this, arguments));
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
}
_createClass(PluginBase, [{
key: "componentDidMount",
value: function componentDidMount() {
var _this$props = this.props,
pluginHost = _this$props[PLUGIN_HOST_CONTEXT],
position = _this$props[POSITION_CONTEXT];
var _this$props2 = this.props,
name = _this$props2.name,
dependencies = _this$props2.dependencies;
this.plugin = {
position: position,
name: name,
dependencies: dependencies,
container: true
};
pluginHost.registerPlugin(this.plugin);
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate() {
var pluginHost = this.props[PLUGIN_HOST_CONTEXT];
pluginHost.ensureDependencies();
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
var pluginHost = this.props[PLUGIN_HOST_CONTEXT];
pluginHost.unregisterPlugin(this.plugin);
}
}, {
key: "render",
value: function render() {
var children = this.props.children;
return React.createElement(PluginIndexer, null, children);
}
}]);
/** @internal */
var PluginHostContext = React.createContext(null);
/** @internal */
var PositionContext = React.createContext(function () { return []; });
/** @internal */
var TemplateHostContext = React.createContext(null);
return PluginBase;
}(React.PureComponent);
process.env.NODE_ENV !== "production" ? PluginBase.propTypes = (_PluginBase$propTypes = {}, _defineProperty(_PluginBase$propTypes, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired), _defineProperty(_PluginBase$propTypes, POSITION_CONTEXT, PropTypes.func.isRequired), _defineProperty(_PluginBase$propTypes, "children", PropTypes.node.isRequired), _defineProperty(_PluginBase$propTypes, "name", PropTypes.string), _defineProperty(_PluginBase$propTypes, "dependencies", PropTypes.arrayOf(PropTypes.shape({
name: PropTypes.string,
optional: PropTypes.bool
}))), _PluginBase$propTypes) : void 0;
PluginBase.defaultProps = {
name: '',
dependencies: []
};
var Plugin = withHostAndPosition(PluginBase);
var _TemplatePlaceholderB, _TemplatePlaceholderB2;
var TemplatePlaceholderBase =
/*#__PURE__*/
function (_React$Component) {
_inherits(TemplatePlaceholderBase, _React$Component);
function TemplatePlaceholderBase(props) {
var _this$subscription;
var _this;
_classCallCheck(this, TemplatePlaceholderBase);
_this = _possibleConstructorReturn(this, _getPrototypeOf(TemplatePlaceholderBase).call(this, props));
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();
/** @internal */
var PluginIndexer = /*#__PURE__*/ (function (_super) {
__extends(PluginIndexer, _super);
function PluginIndexer() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.indexes = {};
_this.memoize = function (index, positionContext) {
if (_this.indexes[index])
return _this.indexes[index];
var fn = function () {
var calculatedPosition = positionContext();
return calculatedPosition.concat([index]);
};
_this.indexes[index] = fn;
return fn;
};
return _this;
}
}), _defineProperty(_this$subscription, RERENDER_TEMPLATE_SCOPE_EVENT, function (name) {
if (propsName === name) {
_this.forceUpdate();
}
}), _this$subscription);
return _this;
}
PluginIndexer.prototype.render = function () {
var _this = this;
var children = this.props.children;
return (React.createElement(PositionContext.Consumer, null, function (positionContext) { return (React.Children.map(children, function (child, index) {
if (!child || !child.type)
return child;
var childPosition = _this.memoize(index, positionContext);
return (React.createElement(PositionContext.Provider, { value: childPosition }, child));
})); }));
};
return PluginIndexer;
}(React.PureComponent));
_createClass(TemplatePlaceholderBase, [{
key: "componentDidMount",
value: function componentDidMount() {
var pluginHost = this.props[PLUGIN_HOST_CONTEXT];
pluginHost.registerSubscription(this.subscription);
}
}, {
key: "shouldComponentUpdate",
value: function shouldComponentUpdate(nextProps) {
var _this$getRenderingDat = this.getRenderingData(nextProps),
params = _this$getRenderingDat.params;
/** @internal */
var PLUGIN_HOST_CONTEXT = 'dxcore_pluginHost_context';
/** @internal */
var POSITION_CONTEXT = 'dxcore_position_context';
/** @internal */
var TEMPLATE_HOST_CONTEXT = 'dxcore_templateHost_context';
/** @internal */
var RERENDER_TEMPLATE_EVENT = Symbol('rerenderTemplate');
/** @internal */
var RERENDER_TEMPLATE_SCOPE_EVENT = Symbol('rerenderTemplateScope');
/** @internal */
var UPDATE_CONNECTION_EVENT = Symbol('updateConnection');
var children = this.props.children;
return !dxCore.shallowEqual(params, this.params) || children !== nextProps.children;
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
var pluginHost = this.props[PLUGIN_HOST_CONTEXT];
pluginHost.unregisterSubscription(this.subscription);
}
}, {
key: "getRenderingData",
value: function getRenderingData(props) {
var name = props.name,
params = props.params;
/** @internal */
var withContext = function (Context, name) { return function (Component) { return function (props) { return (React.createElement(Context.Consumer, null, function (context) {
var _a;
return (React.createElement(Component, __assign({}, props, (_a = {}, _a[name] = context, _a))));
})); }; }; };
/** @internal */
var withHostAndPosition = function (Component) { return withContext(PluginHostContext, PLUGIN_HOST_CONTEXT)(withContext(PositionContext, POSITION_CONTEXT)(Component)); };
if (name) {
var pluginHost = this.props[PLUGIN_HOST_CONTEXT];
return {
params: params,
templates: pluginHost.collect("".concat(name, "Template")).filter(function (template) {
return template.predicate(params);
}).reverse()
};
/** @internal */
var PluginBase = /*#__PURE__*/ (function (_super) {
__extends(PluginBase, _super);
function PluginBase() {
return _super !== null && _super.apply(this, arguments) || this;
}
var templateHost = this.props[TEMPLATE_HOST_CONTEXT];
return {
params: params || templateHost.params(),
templates: templateHost.templates()
PluginBase.prototype.componentDidMount = function () {
var _a = this.props, _b = PLUGIN_HOST_CONTEXT, pluginHost = _a[_b], _c = POSITION_CONTEXT, position = _a[_c];
var _d = this.props, name = _d.name, dependencies = _d.dependencies;
this.plugin = {
position: position,
name: name,
dependencies: dependencies,
container: true,
};
pluginHost.registerPlugin(this.plugin);
};
}
}, {
key: "render",
value: function render() {
var _this2 = this;
PluginBase.prototype.componentDidUpdate = function () {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
pluginHost.ensureDependencies();
};
PluginBase.prototype.componentWillUnmount = function () {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
pluginHost.unregisterPlugin(this.plugin);
};
PluginBase.prototype.render = function () {
var children = this.props.children;
return (React.createElement(PluginIndexer, null, children));
};
return PluginBase;
}(React.PureComponent));
var Plugin = withHostAndPosition(PluginBase);
var _this$getRenderingDat2 = this.getRenderingData(this.props),
params = _this$getRenderingDat2.params,
templates = _this$getRenderingDat2.templates;
this.params = params;
var _templates = _slicedToArray(templates, 1);
this.template = _templates[0];
this.restTemplates = templates.slice(1);
var content = null;
if (this.template) {
var templateContent = this.template.children;
content = templateContent() || null;
if (content && typeof content === 'function') {
content = content(params);
}
var TemplatePlaceholderBase = /*#__PURE__*/ (function (_super) {
__extends(TemplatePlaceholderBase, _super);
function TemplatePlaceholderBase(props) {
var _a;
var _this = _super.call(this, props) || this;
_this.template = null;
_this.params = {};
_this.restTemplates = [];
var propsName = _this.props.name;
_this.subscription = (_a = {},
_a[RERENDER_TEMPLATE_EVENT] = function (id) {
if (_this.template && _this.template.id === id) {
_this.forceUpdate();
}
},
_a[RERENDER_TEMPLATE_SCOPE_EVENT] = function (name) {
if (propsName === name) {
_this.forceUpdate();
}
},
_a);
return _this;
}
var templatePlaceholder = this.props.children;
return React.createElement(TemplateHostContext.Provider, {
value: {
templates: function templates() {
return _this2.restTemplates;
},
params: function params() {
return _this2.params;
TemplatePlaceholderBase.prototype.componentDidMount = function () {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
pluginHost.registerSubscription(this.subscription);
};
TemplatePlaceholderBase.prototype.shouldComponentUpdate = function (nextProps) {
var params = this.getRenderingData(nextProps).params;
var children = this.props.children;
return !dxCore.shallowEqual(params, this.params) || children !== nextProps.children;
};
TemplatePlaceholderBase.prototype.componentWillUnmount = function () {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
pluginHost.unregisterSubscription(this.subscription);
};
TemplatePlaceholderBase.prototype.getRenderingData = function (props) {
var name = props.name, params = props.params;
if (name) {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
return {
params: params,
templates: pluginHost.collect(name + "Template")
.filter(function (template) { return template.predicate(params); })
.reverse(),
};
}
}
}, templatePlaceholder ? templatePlaceholder(content) : content);
}
}]);
var _b = TEMPLATE_HOST_CONTEXT, templateHost = this.props[_b];
return {
params: params || templateHost.params(),
templates: templateHost.templates(),
};
};
TemplatePlaceholderBase.prototype.render = function () {
var _this = this;
var _a = this.getRenderingData(this.props), params = _a.params, templates = _a.templates;
this.params = params;
this.template = templates[0];
this.restTemplates = templates.slice(1);
var content = null;
if (this.template) {
var templateContent = this.template.children;
content = templateContent() || null;
if (content && typeof content === 'function') {
content = content(params);
}
}
var templatePlaceholder = this.props.children;
return (React.createElement(TemplateHostContext.Provider, { value: {
templates: function () { return _this.restTemplates; },
params: function () { return _this.params; },
} }, templatePlaceholder ? templatePlaceholder(content) : content));
};
return TemplatePlaceholderBase;
}(React.Component));
/** A React component to which a related Template is rendered. */
var TemplatePlaceholder = withContext(PluginHostContext, PLUGIN_HOST_CONTEXT)(withContext(TemplateHostContext, TEMPLATE_HOST_CONTEXT)(TemplatePlaceholderBase));
return TemplatePlaceholderBase;
}(React.Component);
process.env.NODE_ENV !== "production" ? TemplatePlaceholderBase.propTypes = (_TemplatePlaceholderB = {
name: PropTypes.string,
// eslint-disable-line react/no-unused-prop-types
params: PropTypes.object
}, _defineProperty(_TemplatePlaceholderB, TEMPLATE_HOST_CONTEXT, PropTypes.object), _defineProperty(_TemplatePlaceholderB, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired), _defineProperty(_TemplatePlaceholderB, "children", PropTypes.func), _TemplatePlaceholderB) : void 0;
TemplatePlaceholderBase.defaultProps = (_TemplatePlaceholderB2 = {}, _defineProperty(_TemplatePlaceholderB2, TEMPLATE_HOST_CONTEXT, undefined), _defineProperty(_TemplatePlaceholderB2, "name", undefined), _defineProperty(_TemplatePlaceholderB2, "params", undefined), _defineProperty(_TemplatePlaceholderB2, "children", undefined), _TemplatePlaceholderB2);
var TemplatePlaceholder = withContext(PluginHostContext, PLUGIN_HOST_CONTEXT)(withContext(TemplateHostContext, TEMPLATE_HOST_CONTEXT)(TemplatePlaceholderBase));
var PluginHost = /*#__PURE__*/ (function (_super) {
__extends(PluginHost, _super);
/** @internal */
function PluginHost(props) {
var _this = _super.call(this, props) || this;
_this.host = new dxCore.PluginHost();
return _this;
}
/** @internal */
PluginHost.prototype.render = function () {
var children = this.props.children;
return (React.createElement(PluginHostContext.Provider, { value: this.host },
React.createElement(PluginIndexer, null, children),
React.createElement(TemplatePlaceholder, { name: "root" })));
};
return PluginHost;
}(React.PureComponent));
var PluginHost =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(PluginHost, _React$PureComponent);
function PluginHost(props) {
var _this;
_classCallCheck(this, PluginHost);
_this = _possibleConstructorReturn(this, _getPrototypeOf(PluginHost).call(this, props));
_this.host = new dxCore.PluginHost();
return _this;
}
_createClass(PluginHost, [{
key: "render",
value: function render() {
var children = this.props.children;
return React.createElement(PluginHostContext.Provider, {
value: this.host
}, React.createElement(PluginIndexer, null, children), React.createElement(TemplatePlaceholder, {
name: "root"
}));
}
}]);
return PluginHost;
}(React.PureComponent);
process.env.NODE_ENV !== "production" ? PluginHost.propTypes = {
children: PropTypes.node
} : void 0;
PluginHost.defaultProps = {
children: undefined
};
var getAvailableGetters = function getAvailableGetters(pluginHost) {
var getGetterValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (getterName) {
return pluginHost.get("".concat(getterName, "Getter"));
};
var trackedDependencies = {};
var getters;
if (typeof Proxy !== 'undefined') {
getters = new Proxy({}, {
get: function get(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');
/** @internal */
var getAvailableGetters = function (pluginHost, getGetterValue) {
if (getGetterValue === void 0) { getGetterValue = function (getterName) { return pluginHost.get(getterName + "Getter"); }; }
var trackedDependencies = {};
var getters;
if (typeof Proxy !== 'undefined') {
getters = new Proxy({}, {
get: function (target, prop) {
if (typeof prop !== 'string')
return undefined;
var result = getGetterValue(prop);
trackedDependencies[prop] = result;
return result;
},
getOwnPropertyDescriptor: function (target, prop) {
return {
configurable: true,
enumerable: true,
value: this.get(target, prop, undefined),
};
},
ownKeys: function () {
return pluginHost.knownKeys('Getter');
},
});
}
});
} else {
getters = pluginHost.knownKeys('Getter').reduce(function (acc, getterName) {
Object.defineProperty(acc, getterName, {
get: function get() {
var result = getGetterValue(getterName);
trackedDependencies[getterName] = result;
return result;
}
});
return acc;
}, {});
}
return {
getters: getters,
trackedDependencies: trackedDependencies
else {
getters = pluginHost.knownKeys('Getter')
.reduce(function (acc, getterName) {
Object.defineProperty(acc, getterName, {
get: function () {
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("".concat(getterName, "Getter"));
/** @internal */
var isTrackedDependenciesChanged = function (pluginHost, prevTrackedDependencies, getGetterValue) {
if (getGetterValue === void 0) { getGetterValue = function (getterName) { return pluginHost.get(getterName + "Getter"); }; }
var trackedDependencies = Object.keys(prevTrackedDependencies)
// tslint:disable-next-line: prefer-object-spread
.reduce(function (acc, getterName) {
var _a;
return Object.assign(acc, (_a = {},
_a[getterName] = getGetterValue(getterName),
_a));
}, {});
return !dxCore.shallowEqual(prevTrackedDependencies, trackedDependencies);
};
var trackedDependencies = Object.keys(prevTrackedDependencies).reduce(function (acc, getterName) {
return Object.assign(acc, _defineProperty({}, getterName, getGetterValue(getterName)));
}, {});
return !dxCore.shallowEqual(prevTrackedDependencies, trackedDependencies);
};
var getAvailableActions = function getAvailableActions(pluginHost) {
var getAction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (actionName) {
return pluginHost.collect("".concat(actionName, "Action")).slice().reverse()[0];
};
var actions;
if (typeof Proxy !== 'undefined') {
actions = new Proxy({}, {
get: function get(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');
/** @internal */
var getAvailableActions = function (pluginHost, getAction) {
if (getAction === void 0) { getAction = function (actionName) { return pluginHost.collect(actionName + "Action").slice().reverse()[0]; }; }
var actions;
if (typeof Proxy !== 'undefined') {
actions = new Proxy({}, {
get: function (target, prop) {
if (typeof prop !== 'string')
return undefined;
return getAction(prop);
},
getOwnPropertyDescriptor: function (target, prop) {
return {
configurable: true,
enumerable: true,
value: this.get(target, prop, undefined),
};
},
ownKeys: function () {
return pluginHost.knownKeys('Action');
},
});
}
});
} else {
actions = pluginHost.knownKeys('Action').reduce(function (acc, actionName) {
Object.defineProperty(acc, actionName, {
get: function get() {
return getAction(actionName);
}
});
return acc;
}, {});
}
return actions;
};
var _ActionBase$propTypes;
var ActionBase =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(ActionBase, _React$PureComponent);
function ActionBase(props) {
var _this;
_classCallCheck(this, ActionBase);
_this = _possibleConstructorReturn(this, _getPrototypeOf(ActionBase).call(this, props));
var pluginHost = props[PLUGIN_HOST_CONTEXT],
positionContext = props[POSITION_CONTEXT];
var name = props.name;
_this.plugin = _defineProperty({
position: function position() {
return positionContext();
else {
actions = pluginHost.knownKeys('Action')
.reduce(function (acc, actionName) {
Object.defineProperty(acc, actionName, {
get: function () { return getAction(actionName); },
});
return acc;
}, {});
}
}, "".concat(name, "Action"), function Action(params) {
var action = _this.props.action;
return actions;
};
var _getAvailableGetters = getAvailableGetters(pluginHost, function (getterName) {
return pluginHost.get("".concat(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("".concat(actionName, "Action"), _this.plugin).slice().reverse()[0];
});
action(params, getters, actions);
var nextAction = pluginHost.collect("".concat(name, "Action"), _this.plugin).slice().reverse()[0];
if (nextAction) {
nextAction(nextParams);
var ActionBase = /*#__PURE__*/ (function (_super) {
__extends(ActionBase, _super);
function ActionBase(props) {
var _a;
var _this = _super.call(this, props) || this;
var _b = PLUGIN_HOST_CONTEXT, pluginHost = props[_b], _c = POSITION_CONTEXT, positionContext = props[_c];
var name = props.name;
_this.plugin = (_a = {
position: function () { return positionContext(); }
},
_a[name + "Action"] = function (params) {
var action = _this.props.action;
var getters = getAvailableGetters(pluginHost, function (getterName) { return pluginHost.get(getterName + "Getter", _this.plugin); }).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]); });
action(params, getters, actions);
var nextAction = pluginHost.collect(name + "Action", _this.plugin).slice().reverse()[0];
if (nextAction) {
nextAction(nextParams);
}
},
_a);
pluginHost.registerPlugin(_this.plugin);
return _this;
}
});
pluginHost.registerPlugin(_this.plugin);
return _this;
}
ActionBase.prototype.componentWillUnmount = function () {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
pluginHost.unregisterPlugin(this.plugin);
};
ActionBase.prototype.render = function () {
return null;
};
return ActionBase;
}(React.PureComponent));
var Action = withHostAndPosition(ActionBase);
_createClass(ActionBase, [{
key: "componentWillUnmount",
value: function componentWillUnmount() {
var pluginHost = this.props[PLUGIN_HOST_CONTEXT];
pluginHost.unregisterPlugin(this.plugin);
}
}, {
key: "render",
value: function render() {
return null;
}
}]);
return ActionBase;
}(React.PureComponent);
process.env.NODE_ENV !== "production" ? ActionBase.propTypes = (_ActionBase$propTypes = {
name: PropTypes.string.isRequired,
action: PropTypes.func.isRequired
}, _defineProperty(_ActionBase$propTypes, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired), _defineProperty(_ActionBase$propTypes, POSITION_CONTEXT, PropTypes.func.isRequired), _ActionBase$propTypes) : void 0;
var Action = withHostAndPosition(ActionBase);
var _GetterBase$propTypes;
var GetterBase =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(GetterBase, _React$PureComponent);
function GetterBase(props) {
var _this;
_classCallCheck(this, GetterBase);
_this = _possibleConstructorReturn(this, _getPrototypeOf(GetterBase).call(this, props));
var pluginHost = props[PLUGIN_HOST_CONTEXT],
positionContext = props[POSITION_CONTEXT];
var name = props.name;
var lastComputed;
var lastTrackedDependencies = {};
var lastResult;
_this.plugin = _defineProperty({
position: function position() {
return positionContext();
var GetterBase = /*#__PURE__*/ (function (_super) {
__extends(GetterBase, _super);
function GetterBase(props) {
var _a;
var _this = _super.call(this, props) || this;
var _b = PLUGIN_HOST_CONTEXT, pluginHost = props[_b], _c = POSITION_CONTEXT, positionContext = props[_c];
var name = props.name;
var lastComputed;
var lastTrackedDependencies = {};
var lastResult;
_this.plugin = (_a = {
position: function () { return positionContext(); }
},
_a[name + "Getter"] = function (original) {
var _a = _this.props, value = _a.value, computed = _a.computed;
if (computed === undefined)
return value;
var getGetterValue = function (getterName) { return ((getterName === name)
? original
: pluginHost.get(getterName + "Getter", _this.plugin)); };
if (computed === lastComputed
&& !isTrackedDependenciesChanged(pluginHost, lastTrackedDependencies, getGetterValue)) {
return lastResult;
}
var _b = getAvailableGetters(pluginHost, getGetterValue), getters = _b.getters, trackedDependencies = _b.trackedDependencies;
var actions = getAvailableActions(pluginHost);
lastComputed = computed;
lastTrackedDependencies = trackedDependencies;
lastResult = computed(getters, actions);
return lastResult;
},
_a);
pluginHost.registerPlugin(_this.plugin);
return _this;
}
}, "".concat(name, "Getter"), function Getter(original) {
var _this$props = _this.props,
value = _this$props.value,
computed = _this$props.computed;
if (computed === undefined) return value;
var getGetterValue = function getGetterValue(getterName) {
return getterName === name ? original : pluginHost.get("".concat(getterName, "Getter"), _this.plugin);
GetterBase.prototype.componentDidUpdate = function () {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
pluginHost.broadcast(UPDATE_CONNECTION_EVENT);
};
GetterBase.prototype.componentWillUnmount = function () {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
pluginHost.unregisterPlugin(this.plugin);
};
GetterBase.prototype.render = function () {
return null;
};
return GetterBase;
}(React.PureComponent));
var Getter = withHostAndPosition(GetterBase);
if (computed === lastComputed && !isTrackedDependenciesChanged(pluginHost, lastTrackedDependencies, getGetterValue)) {
return lastResult;
var globalTemplateId = 0;
/** @internal */
var TemplateBase = /*#__PURE__*/ (function (_super) {
__extends(TemplateBase, _super);
function TemplateBase(props) {
var _a;
var _this = _super.call(this, props) || this;
_this.children = function () { return void 0; };
globalTemplateId += 1;
_this.id = globalTemplateId;
var _b = PLUGIN_HOST_CONTEXT, pluginHost = props[_b], _c = POSITION_CONTEXT, positionContext = props[_c];
var name = props.name, predicate = props.predicate;
_this.plugin = (_a = {
position: function () { return positionContext(); }
},
_a[name + "Template"] = {
id: _this.id,
predicate: function (params) { return (predicate ? predicate(params) : true); },
children: function () {
var children = _this.props.children;
return children;
},
},
_a);
pluginHost.registerPlugin(_this.plugin);
pluginHost.broadcast(RERENDER_TEMPLATE_SCOPE_EVENT, name);
return _this;
}
TemplateBase.prototype.componentDidUpdate = function () {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
pluginHost.broadcast(RERENDER_TEMPLATE_EVENT, this.id);
};
TemplateBase.prototype.componentWillUnmount = function () {
var _a = PLUGIN_HOST_CONTEXT, pluginHost = this.props[_a];
var name = this.props.name;
pluginHost.unregisterPlugin(this.plugin);
pluginHost.broadcast(RERENDER_TEMPLATE_SCOPE_EVENT, name);
};
TemplateBase.prototype.render = function () {
return null;
};
return TemplateBase;
}(React.PureComponent));
/*** A React component that defines a markup that is rendered
* as the corresponding TemplatePlaceholder.
*/
var Template = withHostAndPosition(TemplateBase);
var _getAvailableGetters = getAvailableGetters(pluginHost, getGetterValue),
getters = _getAvailableGetters.getters,
trackedDependencies = _getAvailableGetters.trackedDependencies;
var actions = getAvailableActions(pluginHost);
lastComputed = computed;
lastTrackedDependencies = trackedDependencies;
lastResult = computed(getters, actions);
return lastResult;
});
pluginHost.registerPlugin(_this.plugin);
return _this;
}
_createClass(GetterBase, [{
key: "componentDidUpdate",
value: function componentDidUpdate() {
var pluginHost = this.props[PLUGIN_HOST_CONTEXT];
pluginHost.broadcast(UPDATE_CONNECTION_EVENT);
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
var pluginHost = this.props[PLUGIN_HOST_CONTEXT];
pluginHost.unregisterPlugin(this.plugin);
}
}, {
key: "render",
value: function render() {
return null;
}
}]);
return GetterBase;
}(React.PureComponent);
process.env.NODE_ENV !== "production" ? GetterBase.propTypes = (_GetterBase$propTypes = {
name: PropTypes.string.isRequired,
value: PropTypes.any,
computed: PropTypes.func
}, _defineProperty(_GetterBase$propTypes, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired), _defineProperty(_GetterBase$propTypes, POSITION_CONTEXT, PropTypes.func.isRequired), _GetterBase$propTypes) : void 0;
GetterBase.defaultProps = {
value: undefined,
computed: undefined
};
var Getter = withHostAndPosition(GetterBase);
var _TemplateBase$propTyp;
var globalTemplateId = 0;
var TemplateBase =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(TemplateBase, _React$PureComponent);
function TemplateBase(props) {
var _this;
_classCallCheck(this, TemplateBase);
_this = _possibleConstructorReturn(this, _getPrototypeOf(TemplateBase).call(this, props));
globalTemplateId += 1;
_this.id = globalTemplateId;
var pluginHost = props[PLUGIN_HOST_CONTEXT],
positionContext = props[POSITION_CONTEXT];
var name = props.name,
_predicate = props.predicate;
_this.plugin = _defineProperty({
position: function position() {
return positionContext();
/** @internal */
var TemplateConnectorBase = /*#__PURE__*/ (function (_super) {
__extends(TemplateConnectorBase, _super);
function TemplateConnectorBase(props, context) {
var _a;
var _this = _super.call(this, props, context) || this;
_this.trackedDependencies = {};
_this.subscription = (_a = {},
_a[UPDATE_CONNECTION_EVENT] = function () { return _this.updateConnection(); },
_a);
return _this;
}
}, "".concat(name, "Template"), {
id: _this.id,
predicate: function predicate(params) {
return _predicate ? _predicate(params) : true;
},
children: function children() {
var children = _this.props.children;
return children;
}
});
pluginHost.registerPlugin(_this.plugin);
pluginHost.broadcast(RERENDER_TEMPLATE_SCOPE_EVENT, name);
return _this;
}
TemplateConnectorBase.prototype.componentDidMount = function () {
var pluginHost = this.context;
pluginHost.registerSubscription(this.subscription);
};
TemplateConnectorBase.prototype.componentWillUnmount = function () {
var pluginHost = this.context;
pluginHost.unregisterSubscription(this.subscription);
};
TemplateConnectorBase.prototype.updateConnection = function () {
var pluginHost = this.context;
if (isTrackedDependenciesChanged(pluginHost, this.trackedDependencies)) {
this.forceUpdate();
}
};
TemplateConnectorBase.prototype.render = function () {
var pluginHost = this.context;
var children = this.props.children;
var _a = getAvailableGetters(pluginHost), getters = _a.getters, trackedDependencies = _a.trackedDependencies;
this.trackedDependencies = trackedDependencies;
var actions = getAvailableActions(pluginHost);
return children(getters, actions);
};
return TemplateConnectorBase;
}(React.Component));
TemplateConnectorBase.contextType = PluginHostContext;
/** A React component that provides access to Getters and Actions within a Template. */
var TemplateConnector = TemplateConnectorBase;
_createClass(TemplateBase, [{
key: "componentDidUpdate",
value: function componentDidUpdate() {
var pluginHost = this.props[PLUGIN_HOST_CONTEXT];
pluginHost.broadcast(RERENDER_TEMPLATE_EVENT, this.id);
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
var pluginHost = this.props[PLUGIN_HOST_CONTEXT];
var name = this.props.name;
pluginHost.unregisterPlugin(this.plugin);
pluginHost.broadcast(RERENDER_TEMPLATE_SCOPE_EVENT, name);
}
}, {
key: "render",
value: function render() {
return null;
}
}]);
return TemplateBase;
}(React.PureComponent);
process.env.NODE_ENV !== "production" ? TemplateBase.propTypes = (_TemplateBase$propTyp = {}, _defineProperty(_TemplateBase$propTyp, PLUGIN_HOST_CONTEXT, PropTypes.object.isRequired), _defineProperty(_TemplateBase$propTyp, POSITION_CONTEXT, PropTypes.func.isRequired), _defineProperty(_TemplateBase$propTyp, "name", PropTypes.string.isRequired), _defineProperty(_TemplateBase$propTyp, "predicate", PropTypes.func), _defineProperty(_TemplateBase$propTyp, "children", PropTypes.oneOfType([PropTypes.func, PropTypes.node])), _TemplateBase$propTyp) : void 0;
TemplateBase.defaultProps = {
predicate: undefined,
children: undefined
};
var Template = withHostAndPosition(TemplateBase);
var TemplateConnector =
/*#__PURE__*/
function (_React$Component) {
_inherits(TemplateConnector, _React$Component);
function TemplateConnector(props, context) {
var _this;
_classCallCheck(this, TemplateConnector);
_this = _possibleConstructorReturn(this, _getPrototypeOf(TemplateConnector).call(this, props, context));
_this.trackedDependencies = {};
_this.subscription = _defineProperty({}, UPDATE_CONNECTION_EVENT, function () {
return _this.updateConnection();
});
return _this;
}
_createClass(TemplateConnector, [{
key: "componentDidMount",
value: function componentDidMount() {
var pluginHost = this.context;
pluginHost.registerSubscription(this.subscription);
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
var pluginHost = this.context;
pluginHost.unregisterSubscription(this.subscription);
}
}, {
key: "updateConnection",
value: function updateConnection() {
var pluginHost = this.context;
if (isTrackedDependenciesChanged(pluginHost, this.trackedDependencies)) {
this.forceUpdate();
var TIMEOUT = 180;
/** @internal */
var TouchStrategy = /*#__PURE__*/ (function () {
function TouchStrategy(delegate) {
this.delegate = delegate;
this.touchStartTimeout = null;
this.dragging = false;
}
}
}, {
key: "render",
value: function render() {
var pluginHost = this.context;
var children = this.props.children;
TouchStrategy.prototype.isDragging = function () {
return this.dragging;
};
TouchStrategy.prototype.isWaiting = function () {
return !!this.touchStartTimeout;
};
TouchStrategy.prototype.cancelWaiting = function () {
clearTimeout(this.touchStartTimeout);
this.touchStartTimeout = undefined;
};
TouchStrategy.prototype.start = function (e) {
var _this = this;
var _a = e.touches[0], x = _a.clientX, y = _a.clientY;
this.touchStartTimeout = setTimeout(function () {
_this.delegate.onStart({ x: x, y: y });
_this.dragging = true;
}, TIMEOUT);
};
TouchStrategy.prototype.move = function (e) {
this.cancelWaiting();
if (this.dragging) {
var _a = e.touches[0], clientX = _a.clientX, clientY = _a.clientY;
e.preventDefault();
this.delegate.onMove({ x: clientX, y: clientY });
}
};
TouchStrategy.prototype.end = function (e) {
this.cancelWaiting();
if (this.dragging) {
var _a = e.changedTouches[0], clientX = _a.clientX, clientY = _a.clientY;
this.delegate.onEnd({ x: clientX, y: clientY });
}
this.mouseInitialOffset = null;
this.dragging = false;
};
return TouchStrategy;
}());
var _getAvailableGetters = getAvailableGetters(pluginHost),
getters = _getAvailableGetters.getters,
trackedDependencies = _getAvailableGetters.trackedDependencies;
this.trackedDependencies = trackedDependencies;
var actions = getAvailableActions(pluginHost);
return children(getters, actions);
}
}]);
return TemplateConnector;
}(React.Component);
process.env.NODE_ENV !== "production" ? TemplateConnector.propTypes = {
children: PropTypes.func.isRequired
} : void 0;
TemplateConnector.contextType = PluginHostContext;
var TIMEOUT = 180;
var TouchStrategy =
/*#__PURE__*/
function () {
function TouchStrategy(delegate) {
_classCallCheck(this, TouchStrategy);
this.delegate = delegate;
this.touchStartTimeout = null;
this.dragging = false;
}
_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;
var _e$touches$ = e.touches[0],
x = _e$touches$.clientX,
y = _e$touches$.clientY;
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;
e.preventDefault();
this.delegate.onMove({
x: clientX,
y: clientY
});
/* globals document:true */
var gestureCover;
/** @internal */
var toggleGestureCover = function (toggle, cursor) {
var style = {
pointerEvents: toggle ? 'all' : 'none',
};
if (toggle && cursor) {
style = __assign({}, style, { cursor: cursor });
}
}
}, {
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;
this.delegate.onEnd({
x: clientX,
y: clientY
});
if (!gestureCover) {
style = __assign({}, style, { position: 'fixed', top: 0, right: 0, left: 0, bottom: 0, opacity: 0, zIndex: 2147483647 });
gestureCover = document.createElement('div');
document.body.appendChild(gestureCover);
}
Object.keys(style).forEach(function (key) { gestureCover.style[key] = style[key]; });
};
this.mouseInitialOffset = null;
this.dragging = false;
}
}]);
return TouchStrategy;
}();
/* globals document:true */
var gestureCover = null;
var toggleGestureCover = function toggleGestureCover(toggle, cursor) {
var style = {
pointerEvents: toggle ? 'all' : 'none'
/* globals window:true document:true */
var BOUNDARY = 10;
var clamp = function (value, min, max) { return Math.max(Math.min(value, max), min); };
var isBoundExceeded = function (_a, _b) {
var initialX = _a.x, initialY = _a.y;
var x = _b.x, y = _b.y;
return clamp(x, initialX - BOUNDARY, initialX + BOUNDARY) !== x
|| clamp(y, initialY - BOUNDARY, initialY + BOUNDARY) !== y;
};
if (toggle && cursor) {
style = _objectSpread({}, style, {
cursor: cursor
});
}
if (!gestureCover) {
style = _objectSpread({}, style, {
position: 'fixed',
top: 0,
right: 0,
left: 0,
bottom: 0,
opacity: 0,
zIndex: 2147483647
});
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;
};
var MouseStrategy =
/*#__PURE__*/
function () {
function MouseStrategy(delegate) {
_classCallCheck(this, MouseStrategy);
this.delegate = delegate;
this.mouseInitialOffset = null;
this.dragging = false;
}
_createClass(MouseStrategy, [{
key: "isDragging",
value: function isDragging() {
return this.dragging;
}
}, {
key: "start",
value: function start(e) {
var x = e.clientX,
y = e.clientY;
this.e = e;
this.mouseInitialOffset = {
x: x,
y: y
/** @internal */
var MouseStrategy = /*#__PURE__*/ (function () {
function MouseStrategy(delegate) {
this.delegate = delegate;
this.mouseInitialOffset = null;
this.dragging = false;
}
MouseStrategy.prototype.isDragging = function () {
return this.dragging;
};
}
}, {
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();
MouseStrategy.prototype.start = function (e) {
var x = e.clientX, y = e.clientY;
this.e = e;
this.mouseInitialOffset = { x: x, y: y };
};
MouseStrategy.prototype.move = function (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;
}
}
if (this.dragging) {
e.preventDefault();
this.delegate.onMove({ x: x, y: y });
}
if (dragStarted) {
var cursor = window.getComputedStyle(document.elementFromPoint(x, y)).cursor;
toggleGestureCover(true, cursor);
}
};
MouseStrategy.prototype.end = function (e) {
if (this.dragging) {
var x = e.clientX, y = e.clientY;
toggleGestureCover(false);
this.delegate.onEnd({ x: x, y: y });
}
this.mouseInitialOffset = null;
this.dragging = false;
};
return MouseStrategy;
}());
dragStarted = true;
this.dragging = true;
}
/* globals window:true */
var eventEmitter;
/** @internal */
var getSharedEventEmitter = function () {
if (!eventEmitter) {
eventEmitter = new dxCore.EventEmitter();
['mousemove', 'mouseup', 'touchmove', 'touchend', 'touchcancel']
.forEach(function (name) { return window.addEventListener(name, function (e) { return eventEmitter.emit([name, e]); }, { passive: false }); });
}
return eventEmitter;
};
if (this.dragging) {
e.preventDefault();
this.delegate.onMove({
x: x,
y: y
});
/* globals document:true window:true */
/** @internal */
var clear = function () {
if (window.getSelection) {
if (window.getSelection().empty) {
window.getSelection().empty();
}
else if (window.getSelection().removeAllRanges) {
window.getSelection().removeAllRanges();
}
}
};
if (dragStarted) {
var _window$getComputedSt = window.getComputedStyle(document.elementFromPoint(x, y)),
cursor = _window$getComputedSt.cursor;
toggleGestureCover(true, cursor);
var draggingHandled = Symbol('draggingHandled');
/** @internal */
var Draggable = /*#__PURE__*/ (function (_super) {
__extends(Draggable, _super);
function Draggable(props, context) {
var _this = _super.call(this, props, context) || this;
var delegate = {
onStart: function (_a) {
var x = _a.x, y = _a.y;
var onStart = _this.props.onStart;
if (!onStart)
return;
reactDom.unstable_batchedUpdates(function () {
onStart({ x: x, y: y });
});
},
onMove: function (_a) {
var x = _a.x, y = _a.y;
var onUpdate = _this.props.onUpdate;
if (!onUpdate)
return;
reactDom.unstable_batchedUpdates(function () {
onUpdate({ x: x, y: y });
});
},
onEnd: function (_a) {
var x = _a.x, y = _a.y;
var onEnd = _this.props.onEnd;
if (!onEnd)
return;
reactDom.unstable_batchedUpdates(function () {
onEnd({ x: x, y: y });
});
},
};
_this.mouseStrategy = new MouseStrategy(delegate);
_this.touchStrategy = new TouchStrategy(delegate);
_this.mouseDownListener = _this.mouseDownListener.bind(_this);
_this.touchStartListener = _this.touchStartListener.bind(_this);
_this.globalListener = _this.globalListener.bind(_this);
return _this;
}
}
}, {
key: "end",
value: function end(e) {
if (this.dragging) {
var x = e.clientX,
y = e.clientY;
toggleGestureCover(false);
this.delegate.onEnd({
x: x,
y: y
});
}
this.mouseInitialOffset = null;
this.dragging = false;
}
}]);
return MouseStrategy;
}();
/* globals window:true */
var eventEmitter = null;
var getSharedEventEmitter = function getSharedEventEmitter() {
if (!eventEmitter) {
eventEmitter = new dxCore.EventEmitter();
['mousemove', 'mouseup', 'touchmove', 'touchend', 'touchcancel'].forEach(function (name) {
return window.addEventListener(name, function (e) {
return eventEmitter.emit([name, e]);
}, {
passive: false
});
});
}
return 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();
}
} else if (document.selection) {
document.selection.empty();
}
};
var draggingHandled = Symbol('draggingHandled');
var Draggable =
/*#__PURE__*/
function (_React$Component) {
_inherits(Draggable, _React$Component);
function Draggable(props, context) {
var _this;
_classCallCheck(this, Draggable);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Draggable).call(this, props, context));
var delegate = {
onStart: function onStart(_ref) {
var x = _ref.x,
y = _ref.y;
var onStart = _this.props.onStart;
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;
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;
if (!onEnd) return;
reactDom.unstable_batchedUpdates(function () {
onEnd({
x: x,
y: y
});
});
}
};
_this.mouseStrategy = new MouseStrategy(delegate);
_this.touchStrategy = new TouchStrategy(delegate);
_this.mouseDownListener = _this.mouseDownListener.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this.touchStartListener = _this.touchStartListener.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this.globalListener = _this.globalListener.bind(_assertThisInitialized(_assertThisInitialized(_this)));
return _this;
}
_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 'mouseup':
this.mouseStrategy.end(e);
break;
case 'touchmove':
{
this.touchStrategy.move(e);
break;
Draggable.prototype.componentDidMount = function () {
getSharedEventEmitter().subscribe(this.globalListener);
this.setupNodeSubscription();
};
Draggable.prototype.shouldComponentUpdate = function (nextProps) {
var children = this.props.children;
return nextProps.children !== children;
};
Draggable.prototype.componentDidUpdate = function () {
this.setupNodeSubscription();
};
Draggable.prototype.componentWillUnmount = function () {
getSharedEventEmitter().unsubscribe(this.globalListener);
};
Draggable.prototype.setupNodeSubscription = function () {
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 });
};
Draggable.prototype.mouseDownListener = function (e) {
if (this.touchStrategy.isWaiting() || e[draggingHandled])
return;
this.mouseStrategy.start(e);
e[draggingHandled] = true;
};
Draggable.prototype.touchStartListener = function (e) {
if (e[draggingHandled])
return;
this.touchStrategy.start(e);
e[draggingHandled] = true;
};
Draggable.prototype.globalListener = function (_a) {
var name = _a[0], e = _a[1];
switch (name) {
case 'mousemove':
this.mouseStrategy.move(e);
break;
case 'mouseup':
this.mouseStrategy.end(e);
break;
case 'touchmove': {
this.touchStrategy.move(e);
break;
}
case 'touchend':
case 'touchcancel': {
this.touchStrategy.end(e);
break;
}
default:
break;
}
case 'touchend':
case 'touchcancel':
{
this.touchStrategy.end(e);
break;
if (this.mouseStrategy.isDragging() || this.touchStrategy.isDragging()) {
clear();
}
};
Draggable.prototype.render = function () {
var children = this.props.children;
return children;
};
return Draggable;
}(React.Component));
default:
break;
}
/** @internal */
var DragDropContext = React.createContext(null);
if (this.mouseStrategy.isDragging() || this.touchStrategy.isDragging()) {
clear();
/** @internal */
var DragDropProviderCore = /*#__PURE__*/ (function () {
function DragDropProviderCore() {
this.payload = null;
this.dragEmitter = new dxCore.EventEmitter();
}
}
}, {
key: "render",
value: function render() {
var children = this.props.children;
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;
Draggable.defaultProps = {
onStart: undefined,
onUpdate: undefined,
onEnd: undefined
};
var DragDropContext = React.createContext();
var DragDropProviderCore =
/*#__PURE__*/
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;
}
}]);
return DragDropProviderCore;
}();
var DragDropProvider =
/*#__PURE__*/
function (_React$Component) {
_inherits(DragDropProvider, _React$Component);
function DragDropProvider(props) {
var _this;
_classCallCheck(this, DragDropProvider);
_this = _possibleConstructorReturn(this, _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;
onChange({
payload: end ? null : payload,
clientOffset: end ? null : clientOffset
});
});
return _this;
}
_createClass(DragDropProvider, [{
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;
return React.createElement(DragDropContext.Provider, {
value: this.dragDropProvider
}, children);
}
}]);
return DragDropProvider;
}(React.Component);
process.env.NODE_ENV !== "production" ? DragDropProvider.propTypes = {
children: PropTypes.node.isRequired,
onChange: PropTypes.func
} : void 0;
DragDropProvider.defaultProps = {
onChange: function onChange() {}
};
var DragSource =
/*#__PURE__*/
function (_React$Component) {
_inherits(DragSource, _React$Component);
function DragSource() {
_classCallCheck(this, DragSource);
return _possibleConstructorReturn(this, _getPrototypeOf(DragSource).apply(this, arguments));
}
_createClass(DragSource, [{
key: "shouldComponentUpdate",
value: function shouldComponentUpdate(nextProps) {
var children = this.props.children;
return nextProps.children !== children;
}
}, {
key: "render",
value: function render() {
var dragDropProvider = this.context;
var _this$props = this.props,
_onStart = _this$props.onStart,
_onUpdate = _this$props.onUpdate,
_onEnd = _this$props.onEnd,
payload = _this$props.payload,
children = _this$props.children;
return React.createElement(Draggable, {
onStart: function onStart(_ref) {
var x = _ref.x,
y = _ref.y;
dragDropProvider.start(payload, {
x: x,
y: y
DragDropProviderCore.prototype.start = function (payload, clientOffset) {
this.payload = payload;
this.dragEmitter.emit({ clientOffset: clientOffset, payload: this.payload });
};
DragDropProviderCore.prototype.update = function (clientOffset) {
this.dragEmitter.emit({ clientOffset: clientOffset, payload: this.payload });
};
DragDropProviderCore.prototype.end = function (clientOffset) {
this.dragEmitter.emit({ clientOffset: clientOffset, payload: this.payload, end: true });
this.payload = null;
};
return DragDropProviderCore;
}());
var defaultProps = {
onChange: function (_a) {
var payload = _a.payload, clientOffset = _a.clientOffset;
},
};
/** @internal */
// tslint:disable-next-line: max-classes-per-file
var DragDropProvider = /*#__PURE__*/ (function (_super) {
__extends(DragDropProvider, _super);
function DragDropProvider(props) {
var _this = _super.call(this, props) || this;
var onChange = _this.props.onChange;
_this.dragDropProvider = new DragDropProviderCore();
_this.dragDropProvider.dragEmitter.subscribe(function (_a) {
var payload = _a.payload, clientOffset = _a.clientOffset, end = _a.end;
onChange({
payload: end ? null : payload,
clientOffset: end ? null : clientOffset,
});
});
_onStart({
clientOffset: {
x: x,
y: y
}
});
},
onUpdate: function onUpdate(_ref2) {
var x = _ref2.x,
y = _ref2.y;
dragDropProvider.update({
x: x,
y: y
});
_onUpdate({
clientOffset: {
x: x,
y: y
}
});
},
onEnd: function onEnd(_ref3) {
var x = _ref3.x,
y = _ref3.y;
dragDropProvider.end({
x: x,
y: y
});
_onEnd({
clientOffset: {
x: x,
y: y
}
});
}
}, children);
}
}]);
return DragSource;
}(React.Component);
DragSource.contextType = DragDropContext;
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;
DragSource.defaultProps = {
onStart: function onStart() {},
onUpdate: function onUpdate() {},
onEnd: function onEnd() {}
};
var clamp$1 = function clamp(value, min, max) {
return Math.max(Math.min(value, max), min);
};
var DropTarget =
/*#__PURE__*/
function (_React$Component) {
_inherits(DropTarget, _React$Component);
function DropTarget(props) {
var _this;
_classCallCheck(this, DropTarget);
_this = _possibleConstructorReturn(this, _getPrototypeOf(DropTarget).call(this, props));
_this.node = null;
_this.isOver = false;
_this.handleDrag = _this.handleDrag.bind(_assertThisInitialized(_assertThisInitialized(_this)));
return _this;
}
_createClass(DropTarget, [{
key: "componentDidMount",
value: function componentDidMount() {
var dragEmitter = this.context.dragEmitter;
dragEmitter.subscribe(this.handleDrag);
}
}, {
key: "shouldComponentUpdate",
value: function shouldComponentUpdate(nextProps) {
var children = this.props.children;
return nextProps.children !== children;
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
var dragEmitter = this.context.dragEmitter;
dragEmitter.unsubscribe(this.handleDrag);
}
}, {
key: "handleDrag",
value: function handleDrag(_ref) {
var payload = _ref.payload,
clientOffset = _ref.clientOffset,
end = _ref.end;
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 _this$props = this.props,
onDrop = _this$props.onDrop,
onEnter = _this$props.onEnter,
onLeave = _this$props.onLeave,
onOver = _this$props.onOver;
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
});
this.isOver = isOver && !end;
}
}, {
key: "render",
value: function render() {
var children = this.props.children;
return React.Children.only(children);
}
}]);
return DropTarget;
}(React.Component);
DropTarget.contextType = DragDropContext;
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;
DropTarget.defaultProps = {
onEnter: function onEnter() {},
onOver: function onOver() {},
onLeave: function onLeave() {},
onDrop: function onDrop() {}
};
var RefHolder =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(RefHolder, _React$PureComponent);
function RefHolder() {
_classCallCheck(this, RefHolder);
return _possibleConstructorReturn(this, _getPrototypeOf(RefHolder).apply(this, arguments));
}
_createClass(RefHolder, [{
key: "render",
value: function render() {
var children = this.props.children;
return children;
}
}]);
return RefHolder;
}(React.PureComponent);
process.env.NODE_ENV !== "production" ? RefHolder.propTypes = {
children: PropTypes.node.isRequired
} : void 0;
var styles = {
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 Sizer =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(Sizer, _React$PureComponent);
function Sizer(props) {
var _this;
_classCallCheck(this, Sizer);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Sizer).call(this, props));
_this.setupListeners = _this.setupListeners.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this.rootRef = React.createRef();
return _this;
}
_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.rootRef.current);
var size = {
height: rootNode.clientHeight,
width: rootNode.clientWidth
return _this;
}
DragDropProvider.prototype.shouldComponentUpdate = function (nextProps) {
var children = this.props.children;
return nextProps.children !== children;
};
this.contractTrigger.scrollTop = size.height;
this.contractTrigger.scrollLeft = size.width;
this.expandNotifier.style.width = "".concat(size.width + 1, "px");
this.expandNotifier.style.height = "".concat(size.height + 1, "px");
this.expandTrigger.scrollTop = 1;
this.expandTrigger.scrollLeft = 1;
var onSizeChange = this.props.onSizeChange;
onSizeChange(size);
}
}, {
key: "createListeners",
value: function createListeners() {
// eslint-disable-next-line react/no-find-dom-node
var rootNode = reactDom.findDOMNode(this.rootRef.current);
this.triggersRoot = document.createElement('div');
Object.assign(this.triggersRoot.style, styles.triggersRoot);
rootNode.appendChild(this.triggersRoot);
this.expandTrigger = document.createElement('div');
Object.assign(this.expandTrigger.style, styles.expandTrigger);
this.expandTrigger.addEventListener('scroll', this.setupListeners);
this.triggersRoot.appendChild(this.expandTrigger);
this.expandNotifier = document.createElement('div');
this.expandTrigger.appendChild(this.expandNotifier);
this.contractTrigger = document.createElement('div');
Object.assign(this.contractTrigger.style, styles.contractTrigger);
this.contractTrigger.addEventListener('scroll', this.setupListeners);
this.triggersRoot.appendChild(this.contractTrigger);
this.contractNotifier = document.createElement('div');
Object.assign(this.contractNotifier.style, styles.contractNotifier);
this.contractTrigger.appendChild(this.contractNotifier);
}
}, {
key: "render",
value: function render() {
var _this$props = this.props,
onSizeChange = _this$props.onSizeChange,
Container = _this$props.containerComponent,
restProps = _objectWithoutProperties(_this$props, ["onSizeChange", "containerComponent"]);
DragDropProvider.prototype.render = function () {
var children = this.props.children;
return (React.createElement(DragDropContext.Provider, { value: this.dragDropProvider }, children));
};
DragDropProvider.defaultProps = defaultProps;
return DragDropProvider;
}(React.Component));
return React.createElement(RefHolder, {
ref: this.rootRef
}, React.createElement(Container // NOTE: should have `position: relative`
, restProps));
}
}]);
return Sizer;
}(React.PureComponent);
process.env.NODE_ENV !== "production" ? Sizer.propTypes = {
onSizeChange: PropTypes.func.isRequired,
containerComponent: PropTypes.oneOfType([PropTypes.string, PropTypes.func])
} : void 0;
Sizer.defaultProps = {
containerComponent: 'div'
};
var connectProps = function connectProps(WrappedComponent, getAdditionalProps) {
var storedAdditionalProps = getAdditionalProps();
var components = new Set();
var RenderComponent =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(RenderComponent, _React$PureComponent);
function RenderComponent() {
_classCallCheck(this, RenderComponent);
return _possibleConstructorReturn(this, _getPrototypeOf(RenderComponent).apply(this, arguments));
}
_createClass(RenderComponent, [{
key: "componentDidMount",
value: function componentDidMount() {
components.add(this);
var defaultProps$1 = {
onStart: function (_a) {
var clientOffset = _a.clientOffset;
},
onUpdate: function (_a) {
var clientOffset = _a.clientOffset;
},
onEnd: function (_a) {
var clientOffset = _a.clientOffset;
},
};
/** @internal */
var DragSource = /*#__PURE__*/ (function (_super) {
__extends(DragSource, _super);
function DragSource() {
return _super !== null && _super.apply(this, arguments) || this;
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
components.delete(this);
}
}, {
key: "render",
value: function render() {
return React.createElement(WrappedComponent, _extends({}, this.props, storedAdditionalProps));
}
}]);
DragSource.prototype.shouldComponentUpdate = function (nextProps) {
var children = this.props.children;
return nextProps.children !== children;
};
DragSource.prototype.render = function () {
var dragDropProvider = this.context;
var _a = this.props, onStart = _a.onStart, onUpdate = _a.onUpdate, onEnd = _a.onEnd, payload = _a.payload, children = _a.children;
return (React.createElement(Draggable, { onStart: function (_a) {
var x = _a.x, y = _a.y;
dragDropProvider.start(payload, { x: x, y: y });
onStart({ clientOffset: { x: x, y: y } });
}, onUpdate: function (_a) {
var x = _a.x, y = _a.y;
dragDropProvider.update({ x: x, y: y });
onUpdate({ clientOffset: { x: x, y: y } });
}, onEnd: function (_a) {
var x = _a.x, y = _a.y;
dragDropProvider.end({ x: x, y: y });
onEnd({ clientOffset: { x: x, y: y } });
} }, children));
};
DragSource.defaultProps = defaultProps$1;
return DragSource;
}(React.Component));
DragSource.contextType = DragDropContext;
return RenderComponent;
}(React.PureComponent);
RenderComponent.update = function () {
storedAdditionalProps = getAdditionalProps();
Array.from(components.values()).forEach(function (component) {
return component.forceUpdate();
});
var clamp$1 = function (value, min, max) { return Math.max(Math.min(value, max), min); };
var defaultProps$2 = {
onEnter: function (args) { },
onOver: function (args) { },
onLeave: function (args) { },
onDrop: function (args) { },
};
return RenderComponent;
};
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]);
/** @internal */
var DropTarget = /*#__PURE__*/ (function (_super) {
__extends(DropTarget, _super);
function DropTarget(props) {
var _this = _super.call(this, props) || this;
_this.isOver = false;
_this.handleDrag = _this.handleDrag.bind(_this);
return _this;
}
});
};
DropTarget.prototype.componentDidMount = function () {
var dragEmitter = this.context.dragEmitter;
dragEmitter.subscribe(this.handleDrag);
};
DropTarget.prototype.shouldComponentUpdate = function (nextProps) {
var children = this.props.children;
return nextProps.children !== children;
};
DropTarget.prototype.componentWillUnmount = function () {
var dragEmitter = this.context.dragEmitter;
dragEmitter.unsubscribe(this.handleDrag);
};
DropTarget.prototype.handleDrag = function (_a) {
var payload = _a.payload, clientOffset = _a.clientOffset, end = _a.end;
var _b = reactDom.findDOMNode(this).getBoundingClientRect(), left = _b.left, top = _b.top, right = _b.right, bottom = _b.bottom;
var _c = this.props, onDrop = _c.onDrop, onEnter = _c.onEnter, onLeave = _c.onLeave, onOver = _c.onOver;
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 });
this.isOver = isOver && !end;
};
DropTarget.prototype.render = function () {
var children = this.props.children;
return React.Children.only(children);
};
DropTarget.defaultProps = defaultProps$2;
return DropTarget;
}(React.Component));
DropTarget.contextType = DragDropContext;
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;
/** @internal */
var RefHolder = /*#__PURE__*/ (function (_super) {
__extends(RefHolder, _super);
function RefHolder() {
return _super !== null && _super.apply(this, arguments) || this;
}
RefHolder.prototype.render = function () {
var children = this.props.children;
return children;
};
return RefHolder;
}(React.PureComponent));
var stateChange = reduce(_objectSpread({}, prevState), payload);
var state = _objectSpread({}, prevState, stateChange);
if (typeof callback === 'function') {
callback(state, prevState);
/* globals document:true */
var styles = {
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%',
},
};
/** @internal */
var Sizer = /*#__PURE__*/ (function (_super) {
__extends(Sizer, _super);
function Sizer(props) {
var _this = _super.call(this, props) || this;
_this.setupListeners = _this.setupListeners.bind(_this);
_this.rootRef = React.createRef();
return _this;
}
Sizer.prototype.componentDidMount = function () {
this.createListeners();
this.setupListeners();
};
// There is no need to remove listeners as divs are removed from DOM when component is unmount.
// But there is a little chance that component unmounting and 'scroll' event happen roughly
// at the same time so that `setupListeners` is called after component is unmount.
Sizer.prototype.componentWillUnmount = function () {
this.expandTrigger.removeEventListener('scroll', this.setupListeners);
this.contractTrigger.removeEventListener('scroll', this.setupListeners);
};
Sizer.prototype.setupListeners = function () {
var size = { height: this.rootNode.clientHeight, width: this.rootNode.clientWidth };
this.contractTrigger.scrollTop = size.height;
this.contractTrigger.scrollLeft = size.width;
this.expandNotifier.style.width = size.width + 1 + "px";
this.expandNotifier.style.height = size.height + 1 + "px";
this.expandTrigger.scrollTop = 1;
this.expandTrigger.scrollLeft = 1;
var onSizeChange = this.props.onSizeChange;
onSizeChange(size);
};
Sizer.prototype.createListeners = function () {
this.rootNode = reactDom.findDOMNode(this.rootRef.current);
this.triggersRoot = document.createElement('div');
Object.assign(this.triggersRoot.style, styles.triggersRoot);
this.rootNode.appendChild(this.triggersRoot);
this.expandTrigger = document.createElement('div');
Object.assign(this.expandTrigger.style, styles.expandTrigger);
this.expandTrigger.addEventListener('scroll', this.setupListeners);
this.triggersRoot.appendChild(this.expandTrigger);
this.expandNotifier = document.createElement('div');
this.expandTrigger.appendChild(this.expandNotifier);
this.contractTrigger = document.createElement('div');
Object.assign(this.contractTrigger.style, styles.contractTrigger);
this.contractTrigger.addEventListener('scroll', this.setupListeners);
this.triggersRoot.appendChild(this.contractTrigger);
this.contractNotifier = document.createElement('div');
Object.assign(this.contractNotifier.style, styles.contractNotifier);
this.contractTrigger.appendChild(this.contractNotifier);
};
Sizer.prototype.render = function () {
var _a = this.props, onSizeChange = _a.onSizeChange, Container = _a.containerComponent, restProps = __rest(_a, ["onSizeChange", "containerComponent"]);
return (React.createElement(RefHolder, { ref: this.rootRef },
React.createElement(Container // NOTE: should have `position: relative`
, __assign({}, restProps))));
};
Sizer.defaultProps = {
containerComponent: 'div',
};
return Sizer;
}(React.PureComponent));
if (stateUpdater === lastStateUpdater) {
if (lastInitialState !== initialState) {
notifyStateChange(state, initialState);
lastInitialState = initialState;
}
initialState = null;
}
return stateChange;
};
lastStateUpdater = stateUpdater;
component.setState(stateUpdater);
/*** A function that creates a new component that allows you to pass additional properties
* to the wrapped component.
*/
var connectProps = function (WrappedComponent, getAdditionalProps) {
var storedAdditionalProps = getAdditionalProps();
var components = new Set();
var RenderComponent = /*#__PURE__*/ (function (_super) {
__extends(RenderComponent, _super);
function RenderComponent() {
return _super !== null && _super.apply(this, arguments) || this;
}
RenderComponent.prototype.componentDidMount = function () {
components.add(this);
};
RenderComponent.prototype.componentWillUnmount = function () {
components.delete(this);
};
RenderComponent.prototype.render = function () {
return React.createElement(WrappedComponent, __assign({}, this.props, storedAdditionalProps));
};
return RenderComponent;
}(React.PureComponent));
RenderComponent.update = function () {
storedAdditionalProps = getAdditionalProps();
Array.from(components.values()).forEach(function (component) { return component.forceUpdate(); });
};
return RenderComponent;
};
var applyFieldReducer = function applyFieldReducer(field, reduce, payload) {
applyReducer(function (state) {
return _defineProperty({}, field, reduce(state[field], payload));
});
/** @internal */
var createStateHelper = function (component, controlledStateProperties) {
if (controlledStateProperties === void 0) { controlledStateProperties = {}; }
var notifyStateChange = function (nextState, state) {
Object.keys(controlledStateProperties).forEach(function (propertyName) {
var changeEvent = controlledStateProperties[propertyName]();
if (changeEvent && nextState[propertyName] !== state[propertyName]) {
changeEvent(nextState[propertyName]);
}
});
};
var lastStateUpdater;
var initialState = null;
var lastInitialState = null;
var applyReducer = function (reduce, payload, callback) {
var stateUpdater = function (prevState) {
if (initialState === null) {
initialState = prevState;
}
var stateChange = reduce(__assign({}, prevState), payload);
var state = __assign({}, prevState, stateChange);
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 (field, reduce, payload) {
applyReducer(function (state) {
var _a;
return (_a = {},
_a[field] = reduce(state[field], payload),
_a);
});
};
return {
applyReducer: applyReducer,
applyFieldReducer: applyFieldReducer,
};
};
return {
applyReducer: applyReducer,
applyFieldReducer: applyFieldReducer
var makeBoundComponent = function (Target, components, exposed) {
var Component = /*#__PURE__*/ (function (_super) {
__extends(Component, _super);
function Component() {
return _super !== null && _super.apply(this, arguments) || this;
}
Component.prototype.render = function () {
return React.createElement(Target, __assign({}, components, this.props));
};
return Component;
}(React.PureComponent));
Component.components = Target.components;
Object.assign(Component, exposed);
return Component;
};
};
// type ITargetComponentStatic = new() => ITargetComponent;
/** @internal */
var withComponents = function (components) { return function (Target) {
var props = {};
var exposed = {};
var targetComponents = Target.components;
Object.entries(targetComponents).forEach(function (_a) {
var fieldName = _a[0], componentName = _a[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;
}; };
var makeBoundComponent = function makeBoundComponent(Target, components, exposed) {
var Component =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(Component, _React$PureComponent);
/* globals Element */
/** @internal */
var RefType = PropTypes.shape({
current: PropTypes.instanceOf((typeof Element !== 'undefined') ? Element : Object),
});
function Component() {
_classCallCheck(this, Component);
exports.Plugin = Plugin;
exports.PluginHost = PluginHost;
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.connectProps = connectProps;
exports.createStateHelper = createStateHelper;
exports.withComponents = withComponents;
exports.RefType = RefType;
return _possibleConstructorReturn(this, _getPrototypeOf(Component).apply(this, arguments));
}
Object.defineProperty(exports, '__esModule', { value: true });
_createClass(Component, [{
key: "render",
value: function render() {
return React.createElement(Target, _extends({}, components, this.props));
}
}]);
return Component;
}(React.PureComponent);
Component.components = Target.components;
Object.assign(Component, exposed);
return Component;
};
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;
};
};
/* globals Element */
var RefType = PropTypes.shape({
current: PropTypes.instanceOf(typeof Element !== 'undefined' ? Element : Object)
});
exports.Plugin = Plugin;
exports.PluginHost = PluginHost;
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.connectProps = connectProps;
exports.createStateHelper = createStateHelper;
exports.withComponents = withComponents;
exports.RefType = RefType;
Object.defineProperty(exports, '__esModule', { value: true });
}));
//# sourceMappingURL=dx-react-core.umd.js.map
{
"name": "@devexpress/dx-react-core",
"version": "1.10.0",
"version": "1.10.1",
"description": "Core library for DevExtreme React Components",

@@ -39,34 +39,28 @@ "author": {

"build:watch": "rollup -c rollup.config.js -w",
"lint": "eslint \"src/**\"",
"lint:fix": "yarn run lint -- --fix"
"dts": "tsc -p tsconfig.dts.json && node ./merge-dts.js",
"lint": "tslint -p tsconfig.lint.json",
"lint:fix": "yarn run lint -- --fix",
"tsc": "tsc"
},
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/preset-env": "^7.2.3",
"@babel/preset-react": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.6.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.21",
"core-js": "^2.6.1",
"@types/enzyme": "^3.1.16",
"core-js": "^2.6.3",
"enzyme": "3.8.0",
"enzyme-adapter-react-16": "^1.7.1",
"eslint": "^5.11.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-filenames": "^1.3.2",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jest": "^22.1.2",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.11.1",
"jest": "^23.6.0",
"enzyme-adapter-react-16": "^1.8.0",
"jest": "^24.0.0",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-test-renderer": "^16.7.0",
"rollup": "^0.68.2",
"rollup-plugin-babel": "^4.1.0",
"rollup-plugin-license": "^0.7.0",
"rollup-plugin-node-resolve": "^4.0.0"
"rollup": "^1.1.2",
"rollup-plugin-license": "^0.8.1",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-typescript2": "^0.19.2",
"ts-jest": "^23.10.5",
"tslint": "^5.12.1",
"tslint-config-airbnb": "^5.11.1",
"typescript": "^3.3.1"
},
"dependencies": {
"@devexpress/dx-core": "1.10.0",
"@devexpress/dx-core": "^1.10.1",
"prop-types": "^15.6.2"

@@ -78,3 +72,3 @@ },

},
"gitHead": "0890839a23a7afd042ad3984dca69232767d60cd"
"gitHead": "c49e13b898b71a22a0d8045ab5b0aa28547e27b2"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc